From 9ed1db97f241f716001c80a7596f3e433c488d43 Mon Sep 17 00:00:00 2001 From: haru0017 Date: Fri, 29 May 2026 19:03:08 +0900 Subject: [PATCH] add downloadStream and uploadStream types --- .changeset/witty-lands-thank.md | 5 ++++ packages/types/tailor.d.ts | 43 +++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .changeset/witty-lands-thank.md diff --git a/.changeset/witty-lands-thank.md b/.changeset/witty-lands-thank.md new file mode 100644 index 0000000..41d7a9d --- /dev/null +++ b/.changeset/witty-lands-thank.md @@ -0,0 +1,5 @@ +--- +"@tailor-platform/function-types": minor +--- + +Add `downloadStream` and `uploadStream` types to `TailorDBFileAPI`. Mark `openDownloadStream` as deprecated. diff --git a/packages/types/tailor.d.ts b/packages/types/tailor.d.ts index 70070c2..24ce00d 100644 --- a/packages/types/tailor.d.ts +++ b/packages/types/tailor.d.ts @@ -166,6 +166,14 @@ interface FileUploadOptions { contentType?: string; } +/** + * Upload stream options interface + */ +interface FileUploadStreamOptions { + contentType?: string; + fileSize?: number; +} + /** * Upload response interface */ @@ -189,6 +197,14 @@ interface FileDownloadAsBase64Response { metadata: DownloadMetadata; } +/** + * Download stream response interface + */ +interface FileDownloadStreamResponse { + body: ReadableStream; + metadata: DownloadMetadata; +} + /** * Stream chunk types */ @@ -223,7 +239,7 @@ interface TailorDBFileAPI { /** * Download a file from TailorDB - * @throws {TailorDBFileError} FILE_TOO_LARGE if file exceeds 10MB - use openDownloadStream() for large files + * @throws {TailorDBFileError} FILE_TOO_LARGE if file exceeds 10MB - use downloadStream() for large files */ download( namespace: string, @@ -237,7 +253,7 @@ interface TailorDBFileAPI { * Unlike download which returns decoded binary data (Uint8Array), * this returns the raw Base64-encoded string for use cases requiring * Base64 format (e.g., embedding in JSON responses, data URIs) - * @throws {TailorDBFileError} FILE_TOO_LARGE if file exceeds 10MB - use openDownloadStream() for large files + * @throws {TailorDBFileError} FILE_TOO_LARGE if file exceeds 10MB - use downloadStream() for large files */ downloadAsBase64( namespace: string, @@ -268,6 +284,7 @@ interface TailorDBFileAPI { /** * Open a download stream for large files + * @deprecated Use downloadStream() instead */ openDownloadStream( namespace: string, @@ -275,6 +292,28 @@ interface TailorDBFileAPI { fieldName: string, recordId: string ): Promise; + + /** + * Download a file as a ReadableStream + */ + downloadStream( + namespace: string, + typeName: string, + fieldName: string, + recordId: string + ): Promise; + + /** + * Upload a file using a ReadableStream + */ + uploadStream( + namespace: string, + typeName: string, + fieldName: string, + recordId: string, + readableStream: ReadableStream, + options?: FileUploadStreamOptions + ): Promise; } declare namespace tailor.idp {