@tailor-platform/function-types 0.4.0 → 0.6.0

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 +149 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/function-types",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
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 {
@@ -53,6 +54,13 @@ declare namespace tailor.secretmanager {
53
54
  ): Promise<string | undefined>;
54
55
  }
55
56
 
57
+ declare namespace tailor.authconnection {
58
+ /**
59
+ * getConnectionToken returns the access token for an auth connection
60
+ */
61
+ function getConnectionToken(connectionName: string): Promise<any>;
62
+ }
63
+
56
64
  declare namespace tailor.iconv {
57
65
  /**
58
66
  * Convert string from one encoding to another
@@ -101,3 +109,144 @@ declare namespace tailor.iconv {
101
109
  convert(input: string | Uint8Array | ArrayBuffer): string | Uint8Array;
102
110
  }
103
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
+ 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
+ }