@unisource/sdk 0.1.2 → 0.2.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.
- package/dist/index.d.mts +348 -44
- package/dist/index.d.ts +348 -44
- package/dist/index.mjs +274 -53
- package/package.json +2 -2
- package/src/client.ts +233 -0
- package/src/fileRecords.ts +87 -0
- package/src/folders.ts +84 -0
- package/src/index.ts +106 -125
- package/src/primitives.ts +25 -0
- package/src/services.ts +69 -0
- package/src/uploadDestination.ts +4 -0
- package/src/uploads.ts +90 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
3
|
+
//#region src/primitives.d.ts
|
|
4
|
+
declare const nonEmptyString: z.ZodString;
|
|
5
|
+
declare const positiveInt: z.ZodNumber;
|
|
6
|
+
declare const unixTimestamp: z.ZodNumber;
|
|
6
7
|
declare const uploadDestinationSchema: z.ZodEnum<{
|
|
7
8
|
appwrite: "appwrite";
|
|
8
9
|
r2: "r2";
|
|
@@ -19,11 +20,12 @@ declare const apiErrorSchema: z.ZodObject<{
|
|
|
19
20
|
message: z.ZodString;
|
|
20
21
|
}, z.core.$strip>;
|
|
21
22
|
type ApiError = z.infer<typeof apiErrorSchema>;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/uploads.d.ts
|
|
22
25
|
declare const uploadR2InitRequestSchema: z.ZodObject<{
|
|
23
26
|
filename: z.ZodString;
|
|
24
27
|
size: z.ZodNumber;
|
|
25
28
|
mime_type: z.ZodString;
|
|
26
|
-
bucket: z.ZodOptional<z.ZodString>;
|
|
27
29
|
}, z.core.$strip>;
|
|
28
30
|
type UploadR2InitRequest = z.infer<typeof uploadR2InitRequestSchema>;
|
|
29
31
|
declare const uploadR2InitResponseSchema: z.ZodObject<{
|
|
@@ -67,8 +69,13 @@ declare const uploadFailResponseSchema: z.ZodObject<{
|
|
|
67
69
|
status: z.ZodLiteral<"failed">;
|
|
68
70
|
}, z.core.$strip>;
|
|
69
71
|
type UploadFailResponse = z.infer<typeof uploadFailResponseSchema>;
|
|
70
|
-
declare const
|
|
72
|
+
declare const FILES_DEFAULT_LIMIT = 25;
|
|
73
|
+
declare const FILES_MAX_LIMIT = 100;
|
|
74
|
+
/** Raw upload record — returned by admin `/files` endpoints. */
|
|
75
|
+
declare const uploadRecordSchema: z.ZodObject<{
|
|
71
76
|
id: z.ZodString;
|
|
77
|
+
service_id: z.ZodString;
|
|
78
|
+
user_id: z.ZodNullable<z.ZodString>;
|
|
72
79
|
filename: z.ZodString;
|
|
73
80
|
size: z.ZodNumber;
|
|
74
81
|
mime_type: z.ZodString;
|
|
@@ -76,8 +83,6 @@ declare const fileRecordSchema: z.ZodObject<{
|
|
|
76
83
|
appwrite: "appwrite";
|
|
77
84
|
r2: "r2";
|
|
78
85
|
}>;
|
|
79
|
-
storage_key: z.ZodString;
|
|
80
|
-
bucket: z.ZodString;
|
|
81
86
|
status: z.ZodEnum<{
|
|
82
87
|
completed: "completed";
|
|
83
88
|
failed: "failed";
|
|
@@ -87,24 +92,12 @@ declare const fileRecordSchema: z.ZodObject<{
|
|
|
87
92
|
created_at: z.ZodNumber;
|
|
88
93
|
updated_at: z.ZodNumber;
|
|
89
94
|
}, z.core.$strip>;
|
|
90
|
-
type
|
|
91
|
-
declare const
|
|
92
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
93
|
-
cursor: z.ZodOptional<z.ZodString>;
|
|
94
|
-
destination: z.ZodOptional<z.ZodEnum<{
|
|
95
|
-
appwrite: "appwrite";
|
|
96
|
-
r2: "r2";
|
|
97
|
-
}>>;
|
|
98
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
99
|
-
completed: "completed";
|
|
100
|
-
failed: "failed";
|
|
101
|
-
pending: "pending";
|
|
102
|
-
}>>;
|
|
103
|
-
}, z.core.$strip>;
|
|
104
|
-
type FilesListQuery = z.infer<typeof filesListQuerySchema>;
|
|
105
|
-
declare const filesListResponseSchema: z.ZodObject<{
|
|
95
|
+
type UploadRecord = z.infer<typeof uploadRecordSchema>;
|
|
96
|
+
declare const uploadsListResponseSchema: z.ZodObject<{
|
|
106
97
|
items: z.ZodArray<z.ZodObject<{
|
|
107
98
|
id: z.ZodString;
|
|
99
|
+
service_id: z.ZodString;
|
|
100
|
+
user_id: z.ZodNullable<z.ZodString>;
|
|
108
101
|
filename: z.ZodString;
|
|
109
102
|
size: z.ZodNumber;
|
|
110
103
|
mime_type: z.ZodString;
|
|
@@ -112,8 +105,6 @@ declare const filesListResponseSchema: z.ZodObject<{
|
|
|
112
105
|
appwrite: "appwrite";
|
|
113
106
|
r2: "r2";
|
|
114
107
|
}>;
|
|
115
|
-
storage_key: z.ZodString;
|
|
116
|
-
bucket: z.ZodString;
|
|
117
108
|
status: z.ZodEnum<{
|
|
118
109
|
completed: "completed";
|
|
119
110
|
failed: "failed";
|
|
@@ -126,30 +117,87 @@ declare const filesListResponseSchema: z.ZodObject<{
|
|
|
126
117
|
next_cursor: z.ZodNullable<z.ZodString>;
|
|
127
118
|
limit: z.ZodNumber;
|
|
128
119
|
}, z.core.$strip>;
|
|
129
|
-
type
|
|
130
|
-
|
|
131
|
-
|
|
120
|
+
type UploadsListResponse = z.infer<typeof uploadsListResponseSchema>;
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/fileRecords.d.ts
|
|
123
|
+
/**
|
|
124
|
+
* A confirmed file record owned by a user.
|
|
125
|
+
* Internal fields (storage_key, bucket) are intentionally excluded from the public API.
|
|
126
|
+
*/
|
|
127
|
+
declare const fileRecordSchema: z.ZodObject<{
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
service_id: z.ZodString;
|
|
130
|
+
user_id: z.ZodString;
|
|
131
|
+
folder_id: z.ZodNullable<z.ZodString>;
|
|
132
|
+
upload_id: z.ZodNullable<z.ZodString>;
|
|
133
|
+
filename: z.ZodString;
|
|
134
|
+
size: z.ZodNumber;
|
|
135
|
+
mime_type: z.ZodString;
|
|
136
|
+
storage_destination: z.ZodEnum<{
|
|
137
|
+
appwrite: "appwrite";
|
|
138
|
+
r2: "r2";
|
|
139
|
+
}>;
|
|
140
|
+
is_trashed: z.ZodBoolean;
|
|
141
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
142
|
+
created_at: z.ZodNumber;
|
|
143
|
+
updated_at: z.ZodNumber;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
type FileRecord = z.infer<typeof fileRecordSchema>;
|
|
146
|
+
declare const fileRecordsListQuerySchema: z.ZodObject<{
|
|
147
|
+
folder_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
148
|
+
is_trashed: z.ZodOptional<z.ZodBoolean>;
|
|
149
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
150
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
type FileRecordsListQuery = z.infer<typeof fileRecordsListQuerySchema>;
|
|
153
|
+
declare const fileRecordsListResponseSchema: z.ZodObject<{
|
|
154
|
+
items: z.ZodArray<z.ZodObject<{
|
|
132
155
|
id: z.ZodString;
|
|
156
|
+
service_id: z.ZodString;
|
|
157
|
+
user_id: z.ZodString;
|
|
158
|
+
folder_id: z.ZodNullable<z.ZodString>;
|
|
159
|
+
upload_id: z.ZodNullable<z.ZodString>;
|
|
133
160
|
filename: z.ZodString;
|
|
134
161
|
size: z.ZodNumber;
|
|
135
162
|
mime_type: z.ZodString;
|
|
136
|
-
|
|
163
|
+
storage_destination: z.ZodEnum<{
|
|
137
164
|
appwrite: "appwrite";
|
|
138
165
|
r2: "r2";
|
|
139
166
|
}>;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
167
|
+
is_trashed: z.ZodBoolean;
|
|
168
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
169
|
+
created_at: z.ZodNumber;
|
|
170
|
+
updated_at: z.ZodNumber;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
173
|
+
limit: z.ZodNumber;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
type FileRecordsListResponse = z.infer<typeof fileRecordsListResponseSchema>;
|
|
176
|
+
declare const fileRecordDetailResponseSchema: z.ZodObject<{
|
|
177
|
+
file: z.ZodObject<{
|
|
178
|
+
id: z.ZodString;
|
|
179
|
+
service_id: z.ZodString;
|
|
180
|
+
user_id: z.ZodString;
|
|
181
|
+
folder_id: z.ZodNullable<z.ZodString>;
|
|
182
|
+
upload_id: z.ZodNullable<z.ZodString>;
|
|
183
|
+
filename: z.ZodString;
|
|
184
|
+
size: z.ZodNumber;
|
|
185
|
+
mime_type: z.ZodString;
|
|
186
|
+
storage_destination: z.ZodEnum<{
|
|
187
|
+
appwrite: "appwrite";
|
|
188
|
+
r2: "r2";
|
|
146
189
|
}>;
|
|
147
|
-
|
|
190
|
+
is_trashed: z.ZodBoolean;
|
|
191
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
148
192
|
created_at: z.ZodNumber;
|
|
149
193
|
updated_at: z.ZodNumber;
|
|
150
194
|
}, z.core.$strip>;
|
|
151
195
|
}, z.core.$strip>;
|
|
152
|
-
type
|
|
196
|
+
type FileRecordDetailResponse = z.infer<typeof fileRecordDetailResponseSchema>;
|
|
197
|
+
declare const fileMoveRequestSchema: z.ZodObject<{
|
|
198
|
+
folder_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
type FileMoveRequest = z.infer<typeof fileMoveRequestSchema>;
|
|
153
201
|
declare const fileDownloadUrlResponseSchema: z.ZodObject<{
|
|
154
202
|
upload_id: z.ZodString;
|
|
155
203
|
destination: z.ZodEnum<{
|
|
@@ -162,13 +210,269 @@ declare const fileDownloadUrlResponseSchema: z.ZodObject<{
|
|
|
162
210
|
type FileDownloadUrlResponse = z.infer<typeof fileDownloadUrlResponseSchema>;
|
|
163
211
|
declare const fileDeleteResponseSchema: z.ZodObject<{
|
|
164
212
|
success: z.ZodLiteral<true>;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
appwrite: "appwrite";
|
|
168
|
-
r2: "r2";
|
|
169
|
-
}>;
|
|
170
|
-
storage_not_found: z.ZodBoolean;
|
|
213
|
+
id: z.ZodString;
|
|
214
|
+
permanent: z.ZodBoolean;
|
|
171
215
|
}, z.core.$strip>;
|
|
172
216
|
type FileDeleteResponse = z.infer<typeof fileDeleteResponseSchema>;
|
|
217
|
+
declare const fileRestoreResponseSchema: z.ZodObject<{
|
|
218
|
+
success: z.ZodLiteral<true>;
|
|
219
|
+
id: z.ZodString;
|
|
220
|
+
}, z.core.$strip>;
|
|
221
|
+
type FileRestoreResponse = z.infer<typeof fileRestoreResponseSchema>;
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/folders.d.ts
|
|
224
|
+
declare const folderSchema: z.ZodObject<{
|
|
225
|
+
id: z.ZodString;
|
|
226
|
+
service_id: z.ZodString;
|
|
227
|
+
user_id: z.ZodString;
|
|
228
|
+
parent_id: z.ZodNullable<z.ZodString>;
|
|
229
|
+
name: z.ZodString;
|
|
230
|
+
color_tag: z.ZodNullable<z.ZodString>;
|
|
231
|
+
is_trashed: z.ZodBoolean;
|
|
232
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
233
|
+
created_at: z.ZodNumber;
|
|
234
|
+
updated_at: z.ZodNumber;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
type Folder = z.infer<typeof folderSchema>;
|
|
237
|
+
declare const folderListQuerySchema: z.ZodObject<{
|
|
238
|
+
parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
239
|
+
is_trashed: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
241
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
type FolderListQuery = z.infer<typeof folderListQuerySchema>;
|
|
244
|
+
declare const folderListResponseSchema: z.ZodObject<{
|
|
245
|
+
items: z.ZodArray<z.ZodObject<{
|
|
246
|
+
id: z.ZodString;
|
|
247
|
+
service_id: z.ZodString;
|
|
248
|
+
user_id: z.ZodString;
|
|
249
|
+
parent_id: z.ZodNullable<z.ZodString>;
|
|
250
|
+
name: z.ZodString;
|
|
251
|
+
color_tag: z.ZodNullable<z.ZodString>;
|
|
252
|
+
is_trashed: z.ZodBoolean;
|
|
253
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
254
|
+
created_at: z.ZodNumber;
|
|
255
|
+
updated_at: z.ZodNumber;
|
|
256
|
+
}, z.core.$strip>>;
|
|
257
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
258
|
+
limit: z.ZodNumber;
|
|
259
|
+
}, z.core.$strip>;
|
|
260
|
+
type FolderListResponse = z.infer<typeof folderListResponseSchema>;
|
|
261
|
+
declare const folderCreateRequestSchema: z.ZodObject<{
|
|
262
|
+
name: z.ZodString;
|
|
263
|
+
parent_id: z.ZodOptional<z.ZodString>;
|
|
264
|
+
color_tag: z.ZodOptional<z.ZodString>;
|
|
265
|
+
}, z.core.$strip>;
|
|
266
|
+
type FolderCreateRequest = z.infer<typeof folderCreateRequestSchema>;
|
|
267
|
+
declare const folderCreateResponseSchema: z.ZodObject<{
|
|
268
|
+
folder: z.ZodObject<{
|
|
269
|
+
id: z.ZodString;
|
|
270
|
+
service_id: z.ZodString;
|
|
271
|
+
user_id: z.ZodString;
|
|
272
|
+
parent_id: z.ZodNullable<z.ZodString>;
|
|
273
|
+
name: z.ZodString;
|
|
274
|
+
color_tag: z.ZodNullable<z.ZodString>;
|
|
275
|
+
is_trashed: z.ZodBoolean;
|
|
276
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
277
|
+
created_at: z.ZodNumber;
|
|
278
|
+
updated_at: z.ZodNumber;
|
|
279
|
+
}, z.core.$strip>;
|
|
280
|
+
}, z.core.$strip>;
|
|
281
|
+
type FolderCreateResponse = z.infer<typeof folderCreateResponseSchema>;
|
|
282
|
+
declare const folderUpdateRequestSchema: z.ZodObject<{
|
|
283
|
+
name: z.ZodOptional<z.ZodString>;
|
|
284
|
+
color_tag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
285
|
+
}, z.core.$strip>;
|
|
286
|
+
type FolderUpdateRequest = z.infer<typeof folderUpdateRequestSchema>;
|
|
287
|
+
declare const folderUpdateResponseSchema: z.ZodObject<{
|
|
288
|
+
folder: z.ZodObject<{
|
|
289
|
+
id: z.ZodString;
|
|
290
|
+
service_id: z.ZodString;
|
|
291
|
+
user_id: z.ZodString;
|
|
292
|
+
parent_id: z.ZodNullable<z.ZodString>;
|
|
293
|
+
name: z.ZodString;
|
|
294
|
+
color_tag: z.ZodNullable<z.ZodString>;
|
|
295
|
+
is_trashed: z.ZodBoolean;
|
|
296
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
297
|
+
created_at: z.ZodNumber;
|
|
298
|
+
updated_at: z.ZodNumber;
|
|
299
|
+
}, z.core.$strip>;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
type FolderUpdateResponse = z.infer<typeof folderUpdateResponseSchema>;
|
|
302
|
+
declare const folderDeleteResponseSchema: z.ZodObject<{
|
|
303
|
+
success: z.ZodLiteral<true>;
|
|
304
|
+
id: z.ZodString;
|
|
305
|
+
permanent: z.ZodBoolean;
|
|
306
|
+
folders_deleted: z.ZodOptional<z.ZodNumber>;
|
|
307
|
+
}, z.core.$strip>;
|
|
308
|
+
type FolderDeleteResponse = z.infer<typeof folderDeleteResponseSchema>;
|
|
309
|
+
declare const folderRestoreResponseSchema: z.ZodObject<{
|
|
310
|
+
success: z.ZodLiteral<true>;
|
|
311
|
+
id: z.ZodString;
|
|
312
|
+
}, z.core.$strip>;
|
|
313
|
+
type FolderRestoreResponse = z.infer<typeof folderRestoreResponseSchema>;
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/services.d.ts
|
|
316
|
+
/** Public service info returned to admins. Never exposes secrets. */
|
|
317
|
+
declare const serviceSchema: z.ZodObject<{
|
|
318
|
+
id: z.ZodString;
|
|
319
|
+
name: z.ZodString;
|
|
320
|
+
max_storage_bytes: z.ZodNumber;
|
|
321
|
+
current_used_bytes: z.ZodNumber;
|
|
322
|
+
max_file_size_bytes: z.ZodNumber;
|
|
323
|
+
created_at: z.ZodNumber;
|
|
324
|
+
}, z.core.$strip>;
|
|
325
|
+
type Service = z.infer<typeof serviceSchema>;
|
|
326
|
+
declare const serviceDetailResponseSchema: z.ZodObject<{
|
|
327
|
+
service: z.ZodObject<{
|
|
328
|
+
id: z.ZodString;
|
|
329
|
+
name: z.ZodString;
|
|
330
|
+
max_storage_bytes: z.ZodNumber;
|
|
331
|
+
current_used_bytes: z.ZodNumber;
|
|
332
|
+
max_file_size_bytes: z.ZodNumber;
|
|
333
|
+
created_at: z.ZodNumber;
|
|
334
|
+
}, z.core.$strip>;
|
|
335
|
+
}, z.core.$strip>;
|
|
336
|
+
type ServiceDetailResponse = z.infer<typeof serviceDetailResponseSchema>;
|
|
337
|
+
declare const serviceUsageResponseSchema: z.ZodObject<{
|
|
338
|
+
service_id: z.ZodString;
|
|
339
|
+
max_storage_bytes: z.ZodNumber;
|
|
340
|
+
current_used_bytes: z.ZodNumber;
|
|
341
|
+
used_percent: z.ZodNumber;
|
|
342
|
+
}, z.core.$strip>;
|
|
343
|
+
type ServiceUsageResponse = z.infer<typeof serviceUsageResponseSchema>;
|
|
344
|
+
declare const auditEventActionSchema: z.ZodEnum<{
|
|
345
|
+
file_deleted: "file_deleted";
|
|
346
|
+
folder_deleted: "folder_deleted";
|
|
347
|
+
quota_exceeded: "quota_exceeded";
|
|
348
|
+
upload_completed: "upload_completed";
|
|
349
|
+
}>;
|
|
350
|
+
type AuditEventAction = z.infer<typeof auditEventActionSchema>;
|
|
351
|
+
declare const auditEventSchema: z.ZodObject<{
|
|
352
|
+
id: z.ZodString;
|
|
353
|
+
service_id: z.ZodString;
|
|
354
|
+
user_id: z.ZodString;
|
|
355
|
+
action: z.ZodEnum<{
|
|
356
|
+
file_deleted: "file_deleted";
|
|
357
|
+
folder_deleted: "folder_deleted";
|
|
358
|
+
quota_exceeded: "quota_exceeded";
|
|
359
|
+
upload_completed: "upload_completed";
|
|
360
|
+
}>;
|
|
361
|
+
resource_type: z.ZodEnum<{
|
|
362
|
+
file: "file";
|
|
363
|
+
folder: "folder";
|
|
364
|
+
service: "service";
|
|
365
|
+
}>;
|
|
366
|
+
resource_id: z.ZodString;
|
|
367
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
368
|
+
ip_address: z.ZodNullable<z.ZodString>;
|
|
369
|
+
created_at: z.ZodNumber;
|
|
370
|
+
}, z.core.$strip>;
|
|
371
|
+
type AuditEvent = z.infer<typeof auditEventSchema>;
|
|
372
|
+
declare const auditLogListQuerySchema: z.ZodObject<{
|
|
373
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
374
|
+
action: z.ZodOptional<z.ZodEnum<{
|
|
375
|
+
file_deleted: "file_deleted";
|
|
376
|
+
folder_deleted: "folder_deleted";
|
|
377
|
+
quota_exceeded: "quota_exceeded";
|
|
378
|
+
upload_completed: "upload_completed";
|
|
379
|
+
}>>;
|
|
380
|
+
resource_type: z.ZodOptional<z.ZodEnum<{
|
|
381
|
+
file: "file";
|
|
382
|
+
folder: "folder";
|
|
383
|
+
service: "service";
|
|
384
|
+
}>>;
|
|
385
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
386
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
387
|
+
}, z.core.$strip>;
|
|
388
|
+
type AuditLogListQuery = z.infer<typeof auditLogListQuerySchema>;
|
|
389
|
+
declare const auditLogListResponseSchema: z.ZodObject<{
|
|
390
|
+
items: z.ZodArray<z.ZodObject<{
|
|
391
|
+
id: z.ZodString;
|
|
392
|
+
service_id: z.ZodString;
|
|
393
|
+
user_id: z.ZodString;
|
|
394
|
+
action: z.ZodEnum<{
|
|
395
|
+
file_deleted: "file_deleted";
|
|
396
|
+
folder_deleted: "folder_deleted";
|
|
397
|
+
quota_exceeded: "quota_exceeded";
|
|
398
|
+
upload_completed: "upload_completed";
|
|
399
|
+
}>;
|
|
400
|
+
resource_type: z.ZodEnum<{
|
|
401
|
+
file: "file";
|
|
402
|
+
folder: "folder";
|
|
403
|
+
service: "service";
|
|
404
|
+
}>;
|
|
405
|
+
resource_id: z.ZodString;
|
|
406
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
407
|
+
ip_address: z.ZodNullable<z.ZodString>;
|
|
408
|
+
created_at: z.ZodNumber;
|
|
409
|
+
}, z.core.$strip>>;
|
|
410
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
411
|
+
limit: z.ZodNumber;
|
|
412
|
+
}, z.core.$strip>;
|
|
413
|
+
type AuditLogListResponse = z.infer<typeof auditLogListResponseSchema>;
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/client.d.ts
|
|
416
|
+
declare class UnisourceError extends Error {
|
|
417
|
+
readonly status: number;
|
|
418
|
+
readonly body: ApiError;
|
|
419
|
+
constructor(message: string, status: number, body: ApiError);
|
|
420
|
+
}
|
|
421
|
+
declare class UnisourceNetworkError extends Error {
|
|
422
|
+
readonly cause: unknown;
|
|
423
|
+
constructor(message: string, cause: unknown);
|
|
424
|
+
}
|
|
425
|
+
interface UnisourceClientConfig {
|
|
426
|
+
/** Base URL of the UniSource API, e.g. https://api.usrc.dev */
|
|
427
|
+
baseUrl: string;
|
|
428
|
+
/** Service identifier — tells the backend which service this client belongs to */
|
|
429
|
+
serviceId: string;
|
|
430
|
+
/**
|
|
431
|
+
* Returns a fresh JWT or API key for each request.
|
|
432
|
+
* Return null/undefined to send unauthenticated requests.
|
|
433
|
+
*/
|
|
434
|
+
getToken: () => string | null | undefined | Promise<string | null | undefined>;
|
|
435
|
+
}
|
|
436
|
+
declare class UnisourceClient {
|
|
437
|
+
private config;
|
|
438
|
+
constructor(config: UnisourceClientConfig);
|
|
439
|
+
readonly upload: {
|
|
440
|
+
/** Initiate an R2 upload — returns a presigned PUT URL */r2Init: (body: UploadR2InitRequest) => Promise<UploadR2InitResponse>; /** Initiate an Appwrite upload — returns credentials for direct SDK upload */
|
|
441
|
+
appwriteInit: (body: UploadAppwriteInitRequest) => Promise<UploadAppwriteInitResponse>; /** Confirm that the file was successfully uploaded to storage */
|
|
442
|
+
complete: (body: UploadLifecycleRequest) => Promise<UploadCompleteResponse>; /** Mark an upload as failed and release reserved quota */
|
|
443
|
+
fail: (body: UploadLifecycleRequest) => Promise<UploadFailResponse>;
|
|
444
|
+
};
|
|
445
|
+
readonly myFiles: {
|
|
446
|
+
/** List files owned by the authenticated user */list: (query?: FileRecordsListQuery) => Promise<FileRecordsListResponse>; /** Get a single file record */
|
|
447
|
+
get: (id: string) => Promise<FileRecordDetailResponse>; /** Get a time-limited download URL (never cached by proxy) */
|
|
448
|
+
downloadUrl: (id: string) => Promise<FileDownloadUrlResponse>; /** Move file to a different folder (null = root) */
|
|
449
|
+
move: (id: string, body: FileMoveRequest) => Promise<{
|
|
450
|
+
file: FileRecord;
|
|
451
|
+
}>; /** Soft-delete (move to trash) or permanently delete */
|
|
452
|
+
delete: (id: string, query?: {
|
|
453
|
+
permanent?: boolean;
|
|
454
|
+
}) => Promise<FileDeleteResponse>; /** Restore a file from trash */
|
|
455
|
+
restore: (id: string) => Promise<FileRestoreResponse>;
|
|
456
|
+
};
|
|
457
|
+
readonly folders: {
|
|
458
|
+
/** List folders owned by the authenticated user */list: (query?: FolderListQuery) => Promise<FolderListResponse>; /** Create a new folder */
|
|
459
|
+
create: (body: FolderCreateRequest) => Promise<FolderCreateResponse>; /** Update folder name or color tag */
|
|
460
|
+
update: (id: string, body: FolderUpdateRequest) => Promise<FolderUpdateResponse>; /** Soft-delete or permanently delete a folder and its contents */
|
|
461
|
+
delete: (id: string, query?: {
|
|
462
|
+
permanent?: boolean;
|
|
463
|
+
}) => Promise<FolderDeleteResponse>; /** Restore a folder from trash */
|
|
464
|
+
restore: (id: string) => Promise<FolderRestoreResponse>;
|
|
465
|
+
};
|
|
466
|
+
readonly admin: {
|
|
467
|
+
/** Get service info and quota limits */serviceDetail: () => Promise<ServiceDetailResponse>; /** Get real-time storage usage for the service */
|
|
468
|
+
usage: () => Promise<ServiceUsageResponse>; /** List all uploads (pending/completed/failed) for this service */
|
|
469
|
+
listUploads: (query?: {
|
|
470
|
+
status?: string;
|
|
471
|
+
cursor?: string;
|
|
472
|
+
limit?: number;
|
|
473
|
+
}) => Promise<UploadsListResponse>; /** List audit log events for this service */
|
|
474
|
+
auditLog: (query?: AuditLogListQuery) => Promise<AuditLogListResponse>;
|
|
475
|
+
};
|
|
476
|
+
}
|
|
173
477
|
//#endregion
|
|
174
|
-
export { ApiError, FILES_DEFAULT_LIMIT, FILES_MAX_LIMIT, FileDeleteResponse,
|
|
478
|
+
export { type ApiError, type AuditEvent, type AuditEventAction, type AuditLogListQuery, type AuditLogListResponse, FILES_DEFAULT_LIMIT, FILES_MAX_LIMIT, type FileDeleteResponse, type FileDownloadUrlResponse, type FileMoveRequest, type FileRecord, type FileRecordDetailResponse, type FileRecordsListQuery, type FileRecordsListResponse, type FileRestoreResponse, type Folder, type FolderCreateRequest, type FolderCreateResponse, type FolderDeleteResponse, type FolderListQuery, type FolderListResponse, type FolderRestoreResponse, type FolderUpdateRequest, type FolderUpdateResponse, type Service, type ServiceDetailResponse, type ServiceUsageResponse, UnisourceClient, type UnisourceClientConfig, UnisourceError, UnisourceNetworkError, type UploadAppwriteInitRequest, type UploadAppwriteInitResponse, type UploadCompleteResponse, type UploadDestination, type UploadFailResponse, type UploadLifecycleRequest, type UploadR2InitRequest, type UploadR2InitResponse, type UploadRecord, type UploadStatus, type UploadsListResponse, apiErrorSchema, auditEventActionSchema, auditEventSchema, auditLogListQuerySchema, auditLogListResponseSchema, fileDeleteResponseSchema, fileDownloadUrlResponseSchema, fileMoveRequestSchema, fileRecordDetailResponseSchema, fileRecordSchema, fileRecordsListQuerySchema, fileRecordsListResponseSchema, fileRestoreResponseSchema, folderCreateRequestSchema, folderCreateResponseSchema, folderDeleteResponseSchema, folderListQuerySchema, folderListResponseSchema, folderRestoreResponseSchema, folderSchema, folderUpdateRequestSchema, folderUpdateResponseSchema, nonEmptyString, positiveInt, serviceDetailResponseSchema, serviceSchema, serviceUsageResponseSchema, unixTimestamp, uploadAppwriteInitRequestSchema, uploadAppwriteInitResponseSchema, uploadCompleteResponseSchema, uploadDestinationSchema, uploadFailResponseSchema, uploadLifecycleRequestSchema, uploadR2InitRequestSchema, uploadR2InitResponseSchema, uploadRecordSchema, uploadStatusSchema, uploadsListResponseSchema };
|