From f380310644b515fa7a65b876ef47070f6161c0e6 Mon Sep 17 00:00:00 2001 From: "kawasaki.taiga" Date: Mon, 18 Dec 2023 23:23:35 +0900 Subject: [PATCH] Refactor file upload types in files.ts. Modify the definition of the FileUploadV2 type to extend the FileUpload type. And modify the FileUpload type so that it does not directly reference ReadableStream, ensuring npm build succeeds. --- src/typed-method-types/files.ts | 38 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/typed-method-types/files.ts b/src/typed-method-types/files.ts index f805307..4d24248 100644 --- a/src/typed-method-types/files.ts +++ b/src/typed-method-types/files.ts @@ -1,26 +1,38 @@ import { BaseResponse } from "../types.ts"; -export type FileUploadV2 = { - /** @description Description of image for screen-reader. */ - alt_text?: string; - /** @description Syntax type of the snippet being uploaded. */ - snippet_type?: string; - /** @description The message text introducing the file in specified channels. */ - channel_id?: string; +interface FileUpload { + /** @description Comma-separated list of channel names or IDs where the file will be shared. */ + channels?: string; + /** @description If omitting this parameter, you must provide a file. */ + content?: string; + /** @description A file type identifier. */ + filetype?: string; /** @description Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. */ thread_ts?: string; /** @description The message text introducing the file in specified channels. */ initial_comment?: string; /** @description Title of the file being uploaded */ title?: string; - - /** @description Size in bytes of the file being uploaded. */ - length: string; /** @description Name of the file being uploaded. */ - filename: string; + filename?: string; /** @description Filetype of the file being uploaded. */ - file: Blob | ReadableStream | string | ArrayBuffer; -}; + file: Exclude; +} + +// Channels and filetype is no longer a supported field and filename is required for file.uploadV2. +export type FileUploadV2 = + & Omit + & { + channel_id?: string; + /** @description Description of image for screen-reader. */ + alt_text?: string; + /** @description Syntax type of the snippet being uploaded. */ + snippet_type?: string; + /** @description Size in bytes of the file being uploaded. */ + length: string; + /** @description Name of the file being uploaded. */ + filename: string; + }; export type FileUploadV2Args = { file_uploads: FileUploadV2[];