Skip to content

Commit

Permalink
Refactor file upload types in files.ts.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
racTaiga533 committed Dec 18, 2023
1 parent b735fec commit be9ee11
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/typed-method-types/files.ts
Original file line number Diff line number Diff line change
@@ -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<Uint8Array> | string | ArrayBuffer;
};
file: Exclude<BodyInit, FormData | URLSearchParams>;
}

// Channels and filetype is no longer a supported field and filename is required for file.uploadV2.
export type FileUploadV2 =
& Omit<FileUpload, "channels" | "filetype" | "content">
& {
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[];
Expand Down

0 comments on commit be9ee11

Please sign in to comment.