@@ -28,6 +28,7 @@ declare namespace Tailordb {
2828
2929declare const tailordb : {
3030 Client : typeof Tailordb . Client ;
31+ file : TailorDBFileAPI ;
3132} ;
3233
3334declare namespace tailor . secretmanager {
@@ -108,3 +109,144 @@ declare namespace tailor.iconv {
108109 convert ( input : string | Uint8Array | ArrayBuffer ) : string | Uint8Array ;
109110 }
110111}
112+
113+ // TailorDB File Extension Types
114+
115+ /**
116+ * Custom error class for TailorDB File operations
117+ */
118+ declare class TailorDBFileError extends Error {
119+ name : 'TailorDBFileError' ;
120+ code ?: 'INVALID_PARAMS' | 'INVALID_DATA_TYPE' | 'OPERATION_FAILED' | 'DELETE_FAILED' | 'STREAM_OPEN_FAILED' | 'STREAM_READ_ERROR' | 'STREAM_ERROR' ;
121+ cause ?: unknown ;
122+ }
123+
124+ /**
125+ * Upload response metadata
126+ */
127+ interface UploadMetadata {
128+ fileSize : number ;
129+ sha256sum : string ;
130+ }
131+
132+ /**
133+ * Download response metadata
134+ */
135+ interface DownloadMetadata {
136+ contentType : string ;
137+ fileSize : number ;
138+ }
139+
140+ /**
141+ * File metadata (for getMetadata API)
142+ */
143+ interface FileMetadata {
144+ contentType : string ;
145+ fileSize : number ;
146+ sha256sum : string ;
147+ lastUploadedAt ?: string ;
148+ }
149+
150+ /**
151+ * Stream metadata (first chunk)
152+ */
153+ interface StreamMetadata {
154+ contentType : string ;
155+ fileSize : number ;
156+ sha256sum : string ;
157+ }
158+
159+ /**
160+ * Upload options interface
161+ */
162+ interface FileUploadOptions {
163+ contentType ?: string ;
164+ }
165+
166+ /**
167+ * Upload response interface
168+ */
169+ interface FileUploadResponse {
170+ metadata : UploadMetadata ;
171+ }
172+
173+ /**
174+ * Download response interface
175+ */
176+ interface FileDownloadResponse {
177+ data : Uint8Array ;
178+ metadata : DownloadMetadata ;
179+ }
180+
181+ /**
182+ * Stream chunk types
183+ */
184+ type StreamValue =
185+ | { type : 'metadata' ; metadata : StreamMetadata }
186+ | { type : 'chunk' ; data : Uint8Array ; position : number }
187+ | { type : 'complete' } ;
188+
189+ /**
190+ * Stream iterator interface
191+ */
192+ interface FileStreamIterator extends AsyncIterableIterator < StreamValue > {
193+ next ( ) : Promise < IteratorResult < StreamValue > > ;
194+ close ( ) : Promise < void > ;
195+ }
196+
197+ /**
198+ * TailorDB File API
199+ */
200+ interface TailorDBFileAPI {
201+ /**
202+ * Upload a file to TailorDB
203+ */
204+ upload (
205+ namespace : string ,
206+ typeName : string ,
207+ fieldName : string ,
208+ recordId : string ,
209+ data : string | ArrayBuffer | Uint8Array | number [ ] ,
210+ options ?: FileUploadOptions
211+ ) : Promise < FileUploadResponse > ;
212+
213+ /**
214+ * Download a file from TailorDB
215+ */
216+ download (
217+ namespace : string ,
218+ typeName : string ,
219+ fieldName : string ,
220+ recordId : string
221+ ) : Promise < FileDownloadResponse > ;
222+
223+ /**
224+ * Delete a file from TailorDB
225+ */
226+ delete (
227+ namespace : string ,
228+ typeName : string ,
229+ fieldName : string ,
230+ recordId : string
231+ ) : Promise < void > ;
232+
233+ /**
234+ * Get file metadata from TailorDB
235+ */
236+ getMetadata (
237+ namespace : string ,
238+ typeName : string ,
239+ fieldName : string ,
240+ recordId : string
241+ ) : Promise < FileMetadata > ;
242+
243+ /**
244+ * Open a download stream for large files
245+ */
246+ openDownloadStream (
247+ namespace : string ,
248+ typeName : string ,
249+ fieldName : string ,
250+ recordId : string
251+ ) : Promise < FileStreamIterator > ;
252+ }
0 commit comments