diff --git a/packages/types/package.json b/packages/types/package.json index d4ba123..142eb7f 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@tailor-platform/function-types", - "version": "0.7.2", + "version": "0.8.0", "description": "TypeScript types for Tailor Platform Function service", "repository": { "type": "git", diff --git a/packages/types/tailor.d.ts b/packages/types/tailor.d.ts index 9832b52..df3ee5c 100644 --- a/packages/types/tailor.d.ts +++ b/packages/types/tailor.d.ts @@ -117,7 +117,7 @@ declare namespace tailor.iconv { */ declare class TailorDBFileError extends Error { name: 'TailorDBFileError'; - code?: 'INVALID_PARAMS' | 'INVALID_DATA_TYPE' | 'OPERATION_FAILED' | 'DELETE_FAILED' | 'STREAM_OPEN_FAILED' | 'STREAM_READ_ERROR' | 'STREAM_ERROR'; + code?: 'INVALID_PARAMS' | 'INVALID_DATA_TYPE' | 'OPERATION_FAILED' | 'DELETE_FAILED' | 'STREAM_OPEN_FAILED' | 'STREAM_READ_ERROR' | 'STREAM_ERROR' | 'FILE_TOO_LARGE'; cause?: unknown; } @@ -135,6 +135,8 @@ interface UploadMetadata { interface DownloadMetadata { contentType: string; fileSize: number; + sha256sum: string; + lastUploadedAt: string; } /** @@ -179,6 +181,14 @@ interface FileDownloadResponse { metadata: DownloadMetadata; } +/** + * Download as Base64 response interface + */ +interface FileDownloadAsBase64Response { + data: string; + metadata: DownloadMetadata; +} + /** * Stream chunk types */ @@ -213,6 +223,7 @@ interface TailorDBFileAPI { /** * Download a file from TailorDB + * @throws {TailorDBFileError} FILE_TOO_LARGE if file exceeds 10MB - use openDownloadStream() for large files */ download( namespace: string, @@ -221,6 +232,20 @@ interface TailorDBFileAPI { recordId: string ): Promise; + /** + * Download a file from TailorDB as Base64 string + * 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 + */ + downloadAsBase64( + namespace: string, + typeName: string, + fieldName: string, + recordId: string + ): Promise; + /** * Delete a file from TailorDB */