Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/witty-lands-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tailor-platform/function-types": minor
---

Add `downloadStream` and `uploadStream` types to `TailorDBFileAPI`. Mark `openDownloadStream` as deprecated.
43 changes: 41 additions & 2 deletions packages/types/tailor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ interface FileUploadOptions {
contentType?: string;
}

/**
* Upload stream options interface
*/
interface FileUploadStreamOptions {
contentType?: string;
fileSize?: number;
}

/**
* Upload response interface
*/
Expand All @@ -189,6 +197,14 @@ interface FileDownloadAsBase64Response {
metadata: DownloadMetadata;
}

/**
* Download stream response interface
*/
interface FileDownloadStreamResponse {
body: ReadableStream<Uint8Array>;
metadata: DownloadMetadata;
}

/**
* Stream chunk types
*/
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -268,13 +284,36 @@ interface TailorDBFileAPI {

/**
* Open a download stream for large files
* @deprecated Use downloadStream() instead
*/
openDownloadStream(
namespace: string,
typeName: string,
fieldName: string,
recordId: string
): Promise<FileStreamIterator>;

/**
* Download a file as a ReadableStream
*/
downloadStream(
namespace: string,
typeName: string,
fieldName: string,
recordId: string
): Promise<FileDownloadStreamResponse>;

/**
* Upload a file using a ReadableStream
*/
uploadStream(
namespace: string,
typeName: string,
fieldName: string,
recordId: string,
readableStream: ReadableStream<Uint8Array | ArrayBuffer>,
options?: FileUploadStreamOptions
): Promise<FileUploadResponse>;
}

declare namespace tailor.idp {
Expand Down