Skip to content

Commit 395d4ba

Browse files
authored
improve: Add Base64 download support to TailorDBFileAPI and extend metadata (#120)
1 parent a6d3d00 commit 395d4ba

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tailor-platform/function-types",
3-
"version": "0.7.2",
3+
"version": "0.8.0",
44
"description": "TypeScript types for Tailor Platform Function service",
55
"repository": {
66
"type": "git",

packages/types/tailor.d.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ declare namespace tailor.iconv {
117117
*/
118118
declare class TailorDBFileError extends Error {
119119
name: 'TailorDBFileError';
120-
code?: 'INVALID_PARAMS' | 'INVALID_DATA_TYPE' | 'OPERATION_FAILED' | 'DELETE_FAILED' | 'STREAM_OPEN_FAILED' | 'STREAM_READ_ERROR' | 'STREAM_ERROR';
120+
code?: 'INVALID_PARAMS' | 'INVALID_DATA_TYPE' | 'OPERATION_FAILED' | 'DELETE_FAILED' | 'STREAM_OPEN_FAILED' | 'STREAM_READ_ERROR' | 'STREAM_ERROR' | 'FILE_TOO_LARGE';
121121
cause?: unknown;
122122
}
123123

@@ -135,6 +135,8 @@ interface UploadMetadata {
135135
interface DownloadMetadata {
136136
contentType: string;
137137
fileSize: number;
138+
sha256sum: string;
139+
lastUploadedAt: string;
138140
}
139141

140142
/**
@@ -179,6 +181,14 @@ interface FileDownloadResponse {
179181
metadata: DownloadMetadata;
180182
}
181183

184+
/**
185+
* Download as Base64 response interface
186+
*/
187+
interface FileDownloadAsBase64Response {
188+
data: string;
189+
metadata: DownloadMetadata;
190+
}
191+
182192
/**
183193
* Stream chunk types
184194
*/
@@ -213,6 +223,7 @@ interface TailorDBFileAPI {
213223

214224
/**
215225
* Download a file from TailorDB
226+
* @throws {TailorDBFileError} FILE_TOO_LARGE if file exceeds 10MB - use openDownloadStream() for large files
216227
*/
217228
download(
218229
namespace: string,
@@ -221,6 +232,20 @@ interface TailorDBFileAPI {
221232
recordId: string
222233
): Promise<FileDownloadResponse>;
223234

235+
/**
236+
* Download a file from TailorDB as Base64 string
237+
* Unlike download which returns decoded binary data (Uint8Array),
238+
* this returns the raw Base64-encoded string for use cases requiring
239+
* Base64 format (e.g., embedding in JSON responses, data URIs)
240+
* @throws {TailorDBFileError} FILE_TOO_LARGE if file exceeds 10MB - use openDownloadStream() for large files
241+
*/
242+
downloadAsBase64(
243+
namespace: string,
244+
typeName: string,
245+
fieldName: string,
246+
recordId: string
247+
): Promise<FileDownloadAsBase64Response>;
248+
224249
/**
225250
* Delete a file from TailorDB
226251
*/

0 commit comments

Comments
 (0)