UNPKG

7.91 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3import type { Stream } from 'node:stream';
4import type { CursorPaginationEnabled, OptionalTeamAssignable, TokenOverridable, TraditionalPagingEnabled } from './common';
5import type { FilesGetUploadURLExternalResponse } from '../response/index';
6import type { ExcludeFromUnion } from '../helpers';
7interface FileArgument {
8 /** @description Encoded file ID. */
9 file: string;
10}
11interface ExternalIDArgument {
12 /** @description Creator defined GUID for the file. */
13 external_id: string;
14}
15interface ChannelsArgument {
16 /**
17 * @description Comma-seperated list of channel IDs where the file will be shared. If not specified the file will
18 * be private.
19 */
20 channels?: string;
21}
22interface FileType {
23 /**
24 * @description A file type identifier.
25 * @see {@link https://api.slack.com/types/file#file_types File types} for a complete list of supported file types.
26 */
27 filetype?: string;
28}
29interface FileUploadComplete {
30 /** @description Encoded file ID. */
31 id: string;
32 /** @description File title. */
33 title?: string;
34}
35interface FileChannelDestinationArgument {
36 /** @description Channel ID where the file will be shared. If not specified the file will be private. */
37 channel_id?: string;
38 thread_ts?: never;
39}
40interface FileThreadDestinationArgument {
41 /** @description Channel ID where the file will be shared as a thread reply. */
42 channel_id: string;
43 /** @description Provide another message's `ts` value to upload this file as a reply. */
44 thread_ts: string;
45}
46type FileDestinationArgument = FileChannelDestinationArgument | FileThreadDestinationArgument;
47interface FileChannelDestinationArgumentChannels extends ChannelsArgument {
48 thread_ts?: never;
49}
50interface FileThreadDestinationArgumentChannels extends Required<ChannelsArgument> {
51 /** @description Provide another message's `ts` value to upload this file as a reply. */
52 thread_ts: string;
53}
54type FileDestinationArgumentChannels = FileChannelDestinationArgumentChannels | FileThreadDestinationArgumentChannels;
55export type FilesCompleteUploadExternalArguments = FileDestinationArgument & TokenOverridable & {
56 /** @description Array of file IDs and their corresponding (optional) titles. */
57 files: [FileUploadComplete, ...FileUploadComplete[]];
58 /** @description The message text introducing the file in the specified channel. */
59 initial_comment?: string;
60};
61export interface FilesDeleteArguments extends FileArgument, TokenOverridable {
62}
63export interface FilesGetUploadURLExternalArguments extends TokenOverridable {
64 /** @description Name of the file being uploaded. */
65 filename: string;
66 /** @description Size in bytes of the file being uploaded. */
67 length: number;
68 /** @description Description of image for screen-reader. */
69 alt_text?: string;
70 /** @description Syntax type of the snippet being uploaded. E.g. `python`. */
71 snippet_type?: string;
72}
73export interface FilesInfoArguments extends FileArgument, TokenOverridable, CursorPaginationEnabled, TraditionalPagingEnabled {
74}
75export interface FilesListArguments extends TokenOverridable, TraditionalPagingEnabled, OptionalTeamAssignable {
76 /** @description Filter files appearing in a specific channel, indicated by its ID. */
77 channel?: string;
78 /**
79 * @description Show truncated file info for files hidden due to being too old, and the team who owns the file
80 * being over the file limit.
81 */
82 show_files_hidden_by_limit?: boolean;
83 /** @description Filter files created after this timestamp (inclusive). */
84 ts_from?: string;
85 /** @description Filter files created before this timestamp (inclusive). */
86 ts_to?: string;
87 /**
88 * @description Filter files by type. Pass multiple values for `types` argument by comma-seperating the values.
89 * The default value is `all`, which does not filter the list.
90 * Available types are `all`, `spaces`, `snippets`, `images`, `gdocs`, `zips` and `pdfs`.
91 */
92 types?: string;
93 /** @description Filter files created by a single user. */
94 user?: string;
95}
96export interface FilesRevokePublicURLArguments extends FileArgument, TokenOverridable {
97}
98export interface FilesSharedPublicURLArguments extends FileArgument, TokenOverridable {
99}
100export interface FileUploadStringContents {
101 /** @description File contents. If omitted, you must provide the `file` argument. */
102 content: string;
103}
104export interface FileUploadBinaryContents {
105 /**
106 * @description File contents as a `Buffer` or `Stream`.
107 * If providing a `string`, this parameter will be interpreted as a _path_ to a file, which will be read from disk
108 * before uploading. If omitted, you must provide the `content` argument.
109 */
110 file: Buffer | Stream | string;
111}
112type FileUploadContents = FileUploadStringContents | FileUploadBinaryContents;
113type FileUpload = FileUploadContents & FileDestinationArgumentChannels & FileType & {
114 /** @description Name of the file. */
115 filename?: string;
116 /** @description The message text introducing the file in specified channel(s). */
117 initial_comment?: string;
118 /** @description File title. */
119 title?: string;
120};
121export type FilesUploadArguments = FileUpload & TokenOverridable;
122export type FileUploadV2 = FileUpload & {
123 /** @description Description of image for screen-reader. */
124 alt_text?: string;
125 /** @description Channel ID where the file will be shared. If not specified the file will be private. */
126 channel_id?: string;
127 /** @description Syntax type of the snippet being uploaded. E.g. `python`. */
128 snippet_type?: string;
129};
130interface FilesUploadV2ArgumentsMultipleFiles {
131 file_uploads: ExcludeFromUnion<FileUploadV2, 'channel_id' | 'channels' | 'initial_comment' | 'thread_ts'>[];
132}
133export type FilesUploadV2Arguments = TokenOverridable & (FileUploadV2 | (Omit<FileUploadV2, 'file' | 'content'> & FilesUploadV2ArgumentsMultipleFiles));
134export type FileUploadV2Job = FileUploadV2 & TokenOverridable & Pick<FilesGetUploadURLExternalResponse, 'file_id' | 'upload_url' | 'error'> & {
135 length?: number;
136 data?: Buffer;
137};
138export interface FilesCommentsDeleteArguments extends FileArgument, TokenOverridable {
139 /** @description The ID of the comment to delete. */
140 id: string;
141}
142interface SharedFile {
143 /** @description Title of the file being shared. */
144 title: string;
145 /** @description URL of the remote file. */
146 external_url: string;
147 /** @description Preview of the document. */
148 preview_image?: Buffer | Stream;
149 /**
150 * @description A text file (txt, pdf, doc, etc.) containing textual search terms that are used to improve discovery
151 * of the remote file.
152 */
153 indexable_file_contents?: Buffer | Stream;
154}
155export interface FilesRemoteAddArguments extends SharedFile, FileType, ExternalIDArgument, TokenOverridable {
156}
157type FileOrExternalID = (FileArgument & {
158 external_id?: never;
159}) | (ExternalIDArgument & {
160 file?: never;
161});
162export type FilesRemoteInfoArguments = FileOrExternalID & TokenOverridable;
163export interface FilesRemoteListArguments extends TokenOverridable, CursorPaginationEnabled {
164 /** @description Filter files appearing in a specific channel, indicated by its ID. */
165 channel?: string;
166 /** @description Filter files created after this timestamp (inclusive). */
167 ts_from?: string;
168 /** @description Filter files created before this timestamp (inclusive). */
169 ts_to?: string;
170}
171export type FilesRemoteRemoveArguments = FileOrExternalID & TokenOverridable;
172export type FilesRemoteShareArguments = Required<ChannelsArgument> & FileOrExternalID & TokenOverridable;
173export type FilesRemoteUpdateArguments = Partial<SharedFile> & FileOrExternalID & FileType & TokenOverridable;
174export {};
175//# sourceMappingURL=files.d.ts.map
\No newline at end of file