@tailor-platform/function-types 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tailor.d.ts +143 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/function-types",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "TypeScript types for Tailor Platform Function service",
5
5
  "repository": {
6
6
  "type": "git",
package/tailor.d.ts CHANGED
@@ -28,6 +28,7 @@ declare namespace Tailordb {
28
28
 
29
29
  declare const tailordb: {
30
30
  Client: typeof Tailordb.Client;
31
+ file: TailorDBFileAPI;
31
32
  };
32
33
 
33
34
  declare namespace tailor.secretmanager {
@@ -108,3 +109,145 @@ declare namespace tailor.iconv {
108
109
  convert(input: string | Uint8Array | ArrayBuffer): string | Uint8Array;
109
110
  }
110
111
  }
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
+ urlPath: string;
148
+ lastUploadedAt?: string;
149
+ }
150
+
151
+ /**
152
+ * Stream metadata (first chunk)
153
+ */
154
+ interface StreamMetadata {
155
+ contentType: string;
156
+ fileSize: number;
157
+ sha256sum: string;
158
+ }
159
+
160
+ /**
161
+ * Upload options interface
162
+ */
163
+ interface FileUploadOptions {
164
+ contentType?: string;
165
+ }
166
+
167
+ /**
168
+ * Upload response interface
169
+ */
170
+ interface FileUploadResponse {
171
+ metadata: UploadMetadata;
172
+ }
173
+
174
+ /**
175
+ * Download response interface
176
+ */
177
+ interface FileDownloadResponse {
178
+ data: Uint8Array;
179
+ metadata: DownloadMetadata;
180
+ }
181
+
182
+ /**
183
+ * Stream chunk types
184
+ */
185
+ type StreamValue =
186
+ | { type: 'metadata'; metadata: StreamMetadata }
187
+ | { type: 'chunk'; data: Uint8Array; position: number }
188
+ | { type: 'complete' };
189
+
190
+ /**
191
+ * Stream iterator interface
192
+ */
193
+ interface FileStreamIterator extends AsyncIterableIterator<StreamValue> {
194
+ next(): Promise<IteratorResult<StreamValue>>;
195
+ close(): Promise<void>;
196
+ }
197
+
198
+ /**
199
+ * TailorDB File API
200
+ */
201
+ interface TailorDBFileAPI {
202
+ /**
203
+ * Upload a file to TailorDB
204
+ */
205
+ upload(
206
+ namespace: string,
207
+ typeName: string,
208
+ fieldName: string,
209
+ recordId: string,
210
+ data: string | ArrayBuffer | Uint8Array | number[],
211
+ options?: FileUploadOptions
212
+ ): Promise<FileUploadResponse>;
213
+
214
+ /**
215
+ * Download a file from TailorDB
216
+ */
217
+ download(
218
+ namespace: string,
219
+ typeName: string,
220
+ fieldName: string,
221
+ recordId: string
222
+ ): Promise<FileDownloadResponse>;
223
+
224
+ /**
225
+ * Delete a file from TailorDB
226
+ */
227
+ delete(
228
+ namespace: string,
229
+ typeName: string,
230
+ fieldName: string,
231
+ recordId: string
232
+ ): Promise<void>;
233
+
234
+ /**
235
+ * Get file metadata from TailorDB
236
+ */
237
+ getMetadata(
238
+ namespace: string,
239
+ typeName: string,
240
+ fieldName: string,
241
+ recordId: string
242
+ ): Promise<FileMetadata>;
243
+
244
+ /**
245
+ * Open a download stream for large files
246
+ */
247
+ openDownloadStream(
248
+ namespace: string,
249
+ typeName: string,
250
+ fieldName: string,
251
+ recordId: string
252
+ ): Promise<FileStreamIterator>;
253
+ }