@unisource/sdk 0.6.0 → 0.7.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 +56 -1
- package/dist/index.mjs +43 -5
- package/package.json +1 -1
- package/src/client.ts +23 -2
- package/src/fileRecords.ts +12 -3
- package/src/index.ts +12 -1
- package/src/primitives.ts +13 -0
- package/src/releases.ts +26 -0
- package/src/services.ts +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -3,14 +3,30 @@ import { z } from "zod";
|
|
|
3
3
|
//#region src/primitives.d.ts
|
|
4
4
|
declare const nonEmptyString: z.ZodString;
|
|
5
5
|
declare const positiveInt: z.ZodNumber;
|
|
6
|
+
declare const nonNegativeInt: z.ZodNumber;
|
|
6
7
|
declare const unixTimestamp: z.ZodNumber;
|
|
7
8
|
declare const FILES_DEFAULT_LIMIT = 25;
|
|
8
9
|
declare const FILES_MAX_LIMIT = 100;
|
|
10
|
+
/**
|
|
11
|
+
* Storage backend a file lives on.
|
|
12
|
+
* - 'r2' — Cloudflare R2 via presigned PUT / multipart
|
|
13
|
+
* - 'appwrite' — Appwrite Storage via direct browser SDK upload
|
|
14
|
+
*
|
|
15
|
+
* `recommendedUploadDestinationSchema` adds the meta-value 'hybrid' which is
|
|
16
|
+
* only valid as a service-wide setting (the upload manager picks r2/appwrite
|
|
17
|
+
* per-file based on size).
|
|
18
|
+
*/
|
|
9
19
|
declare const uploadDestinationSchema: z.ZodEnum<{
|
|
10
20
|
appwrite: "appwrite";
|
|
11
21
|
r2: "r2";
|
|
12
22
|
}>;
|
|
13
23
|
type UploadDestination = z.infer<typeof uploadDestinationSchema>;
|
|
24
|
+
declare const recommendedUploadDestinationSchema: z.ZodEnum<{
|
|
25
|
+
appwrite: "appwrite";
|
|
26
|
+
hybrid: "hybrid";
|
|
27
|
+
r2: "r2";
|
|
28
|
+
}>;
|
|
29
|
+
type RecommendedUploadDestination = z.infer<typeof recommendedUploadDestinationSchema>;
|
|
14
30
|
declare const uploadStatusSchema: z.ZodEnum<{
|
|
15
31
|
completed: "completed";
|
|
16
32
|
failed: "failed";
|
|
@@ -333,6 +349,7 @@ declare const fileRestoreResponseSchema: z.ZodObject<{
|
|
|
333
349
|
id: z.ZodString;
|
|
334
350
|
}, z.core.$strip>;
|
|
335
351
|
type FileRestoreResponse = z.infer<typeof fileRestoreResponseSchema>;
|
|
352
|
+
/** SDK4: filename hard-capped to 255 to match backend Zod validation. */
|
|
336
353
|
declare const fileUpdateRequestSchema: z.ZodObject<{
|
|
337
354
|
filename: z.ZodString;
|
|
338
355
|
}, z.core.$strip>;
|
|
@@ -477,6 +494,7 @@ declare const serviceSchema: z.ZodObject<{
|
|
|
477
494
|
max_file_size_bytes: z.ZodNumber;
|
|
478
495
|
recommended_upload_destination: z.ZodOptional<z.ZodEnum<{
|
|
479
496
|
appwrite: "appwrite";
|
|
497
|
+
hybrid: "hybrid";
|
|
480
498
|
r2: "r2";
|
|
481
499
|
}>>;
|
|
482
500
|
created_at: z.ZodNumber;
|
|
@@ -491,6 +509,7 @@ declare const serviceDetailResponseSchema: z.ZodObject<{
|
|
|
491
509
|
max_file_size_bytes: z.ZodNumber;
|
|
492
510
|
recommended_upload_destination: z.ZodOptional<z.ZodEnum<{
|
|
493
511
|
appwrite: "appwrite";
|
|
512
|
+
hybrid: "hybrid";
|
|
494
513
|
r2: "r2";
|
|
495
514
|
}>>;
|
|
496
515
|
created_at: z.ZodNumber;
|
|
@@ -511,6 +530,7 @@ declare const adminServiceUpdateResponseSchema: z.ZodObject<{
|
|
|
511
530
|
max_file_size_bytes: z.ZodNumber;
|
|
512
531
|
recommended_upload_destination: z.ZodOptional<z.ZodEnum<{
|
|
513
532
|
appwrite: "appwrite";
|
|
533
|
+
hybrid: "hybrid";
|
|
514
534
|
r2: "r2";
|
|
515
535
|
}>>;
|
|
516
536
|
created_at: z.ZodNumber;
|
|
@@ -525,6 +545,7 @@ type AdminServiceUpdateResponse = z.infer<typeof adminServiceUpdateResponseSchem
|
|
|
525
545
|
declare const adminServiceSettingsRequestSchema: z.ZodObject<{
|
|
526
546
|
recommended_upload_destination: z.ZodOptional<z.ZodEnum<{
|
|
527
547
|
appwrite: "appwrite";
|
|
548
|
+
hybrid: "hybrid";
|
|
528
549
|
r2: "r2";
|
|
529
550
|
}>>;
|
|
530
551
|
}, z.core.$strip>;
|
|
@@ -538,6 +559,7 @@ declare const adminServiceSettingsResponseSchema: z.ZodObject<{
|
|
|
538
559
|
max_file_size_bytes: z.ZodNumber;
|
|
539
560
|
recommended_upload_destination: z.ZodOptional<z.ZodEnum<{
|
|
540
561
|
appwrite: "appwrite";
|
|
562
|
+
hybrid: "hybrid";
|
|
541
563
|
r2: "r2";
|
|
542
564
|
}>>;
|
|
543
565
|
created_at: z.ZodNumber;
|
|
@@ -1025,6 +1047,28 @@ declare const releaseSyncResponseSchema: z.ZodObject<{
|
|
|
1025
1047
|
}, z.core.$strip>>;
|
|
1026
1048
|
}, z.core.$strip>;
|
|
1027
1049
|
type ReleaseSyncResponse = z.infer<typeof releaseSyncResponseSchema>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Response of `GET /app/releases/latest?channel=...` — used by client apps to
|
|
1052
|
+
* discover the most recent completed release for a given distribution channel
|
|
1053
|
+
* (e.g. `stable`, `beta`). Includes a short-lived presigned download URL.
|
|
1054
|
+
*/
|
|
1055
|
+
declare const appReleaseLatestQuerySchema: z.ZodObject<{
|
|
1056
|
+
channel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1057
|
+
}, z.core.$strip>;
|
|
1058
|
+
type AppReleaseLatestQuery = z.input<typeof appReleaseLatestQuerySchema>;
|
|
1059
|
+
declare const appReleaseLatestResponseSchema: z.ZodObject<{
|
|
1060
|
+
id: z.ZodString;
|
|
1061
|
+
name: z.ZodString;
|
|
1062
|
+
size: z.ZodNumber;
|
|
1063
|
+
r2_key: z.ZodString;
|
|
1064
|
+
tags: z.ZodArray<z.ZodString>;
|
|
1065
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
1066
|
+
force_update: z.ZodBoolean;
|
|
1067
|
+
created_at: z.ZodString;
|
|
1068
|
+
download_url: z.ZodString;
|
|
1069
|
+
download_url_expires_at: z.ZodNumber;
|
|
1070
|
+
}, z.core.$strip>;
|
|
1071
|
+
type AppReleaseLatestResponse = z.infer<typeof appReleaseLatestResponseSchema>;
|
|
1028
1072
|
//#endregion
|
|
1029
1073
|
//#region src/shareLinks.d.ts
|
|
1030
1074
|
declare const shareLinkSchema: z.ZodObject<{
|
|
@@ -1300,6 +1344,7 @@ declare class UnisourceClient {
|
|
|
1300
1344
|
updateServiceSettings: (body: AdminServiceSettingsRequest, signal?: AbortSignal) => Promise<AdminServiceSettingsResponse>; /** Get real-time storage usage for the service */
|
|
1301
1345
|
usage: (signal?: AbortSignal) => Promise<ServiceUsageResponse>; /** List all uploads (pending/completed/failed) for this service */
|
|
1302
1346
|
listUploads: (query?: {
|
|
1347
|
+
destination?: UploadDestination;
|
|
1303
1348
|
status?: UploadStatus;
|
|
1304
1349
|
cursor?: string;
|
|
1305
1350
|
limit?: number;
|
|
@@ -1349,6 +1394,16 @@ declare class UnisourceClient {
|
|
|
1349
1394
|
get: (id: string, signal?: AbortSignal) => Promise<ShareLinkDetailResponse>; /** Delete a share link */
|
|
1350
1395
|
delete: (id: string, signal?: AbortSignal) => Promise<ShareLinkDeleteResponse>;
|
|
1351
1396
|
};
|
|
1397
|
+
readonly app: {
|
|
1398
|
+
releases: {
|
|
1399
|
+
/**
|
|
1400
|
+
* Get the latest completed release for a channel (e.g. `stable`, `beta`).
|
|
1401
|
+
* Backed by `GET /app/releases/latest`. Returns the release metadata plus
|
|
1402
|
+
* a short-lived presigned download URL.
|
|
1403
|
+
*/
|
|
1404
|
+
latest: (channel?: string, signal?: AbortSignal) => Promise<AppReleaseLatestResponse>;
|
|
1405
|
+
};
|
|
1406
|
+
};
|
|
1352
1407
|
}
|
|
1353
1408
|
//#endregion
|
|
1354
|
-
export { type AdminServiceSettingsRequest, type AdminServiceSettingsResponse, type AdminServiceUpdateRequest, type AdminServiceUpdateResponse, type AdminUser, type AdminUserListResponse, type AdminUserPasswordResetRequest, type AdminUserPasswordResetResponse, type AdminUserRoleUpdateRequest, type AdminUserStorageLimitUpdateRequest, type AdminUserUpdateRequest, type AdminUserUpdateResponse, 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 FileUpdateRequest, type FileUpdateResponse, type Folder, type FolderCreateRequest, type FolderCreateResponse, type FolderDeleteResponse, type FolderDetailResponse, type FolderListQuery, type FolderListResponse, type FolderRestoreResponse, type FolderUpdateRequest, type FolderUpdateResponse, MainStorageDeleteResponse, MainStorageDetailResponse, MainStorageFile, MainStorageListQuery, MainStorageListResponse, MainStorageRenameRequest, MainStorageRenameResponse, MainStorageRestoreResponse, type MultipartAbortRequest, type MultipartAbortResponse, type MultipartCompleteRequest, type MultipartCompleteResponse, type MultipartCreateRequest, type MultipartCreateResponse, type MultipartListPartsQuery, type MultipartListPartsResponse, type MultipartPart, type MultipartSignPartQuery, type MultipartSignPartResponse, type PublicFileAccessResponse, type PublicFileLockedResponse, type ReleaseDTO, type ReleaseDeleteResponse, type ReleaseMultipartAbortRequest, type ReleaseMultipartAbortResponse, type ReleaseMultipartCompleteRequest, type ReleaseMultipartCompleteResponse, type ReleaseMultipartCreateRequest, type ReleaseMultipartCreateResponse, type ReleaseMultipartListPartsQuery, type ReleaseMultipartListPartsResponse, type ReleaseMultipartPart, type ReleaseMultipartSignPartQuery, type ReleaseMultipartSignPartResponse, type ReleaseSyncManifest, type ReleaseSyncRequest, type ReleaseSyncResponse, type ReleaseSyncResult, type ReleaseUpdateRequest, type ReleaseUploadCompleteRequest, type ReleaseUploadCompleteResponse, type ReleaseUploadFailResponse, type ReleaseUploadInitRequest, type ReleaseUploadInitResponse, type ReleasesListQuery, type ReleasesListResponse, type Service, type ServiceDetailResponse, type ServiceUsageResponse, type ShareLink, type ShareLinkCreateRequest, type ShareLinkCreateResponse, type ShareLinkDeleteResponse, type ShareLinkDetailResponse, type ShareLinkListResponse, type ShareLinkUpdateRequest, type ShareLinkUpdateResponse, type SharesCreateRequest, UnisourceClient, type UnisourceClientConfig, UnisourceError, UnisourceNetworkError, type UploadAppwriteInitRequest, type UploadAppwriteInitResponse, type UploadCompleteResponse, type UploadDestination, type UploadFailResponse, type UploadLifecycleRequest, type UploadR2InitRequest, type UploadR2InitResponse, type UploadRecord, type UploadRecordDetailResponse, type UploadStatus, type UploadType, type UploadsListResponse, adminServiceSettingsRequestSchema, adminServiceSettingsResponseSchema, adminServiceUpdateRequestSchema, adminServiceUpdateResponseSchema, adminUserListResponseSchema, adminUserPasswordResetRequestSchema, adminUserPasswordResetResponseSchema, adminUserRoleUpdateRequestSchema, adminUserSchema, adminUserStorageLimitUpdateRequestSchema, adminUserUpdateRequestSchema, adminUserUpdateResponseSchema, apiErrorSchema, auditEventActionSchema, auditEventSchema, auditLogListQuerySchema, auditLogListResponseSchema, fileDeleteResponseSchema, fileDownloadUrlResponseSchema, fileMoveRequestSchema, fileRecordDetailResponseSchema, fileRecordSchema, fileRecordsListQuerySchema, fileRecordsListResponseSchema, fileRestoreResponseSchema, fileUpdateRequestSchema, fileUpdateResponseSchema, folderCreateRequestSchema, folderCreateResponseSchema, folderDeleteResponseSchema, folderDetailResponseSchema, folderListQuerySchema, folderListResponseSchema, folderRestoreResponseSchema, folderSchema, folderUpdateRequestSchema, folderUpdateResponseSchema, getPublicFileInfo, mainStorageDeleteResponseSchema, mainStorageDetailResponseSchema, mainStorageFileSchema, mainStorageListQuerySchema, mainStorageListResponseSchema, mainStorageRenameRequestSchema, mainStorageRenameResponseSchema, mainStorageRestoreResponseSchema, multipartAbortRequestSchema, multipartAbortResponseSchema, multipartCompleteRequestSchema, multipartCompleteResponseSchema, multipartCreateRequestSchema, multipartCreateResponseSchema, multipartListPartsQuerySchema, multipartListPartsResponseSchema, multipartPartSchema, multipartSignPartQuerySchema, multipartSignPartResponseSchema, nonEmptyString, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, releaseDTOSchema, releaseDeleteResponseSchema, releaseMultipartAbortRequestSchema, releaseMultipartAbortResponseSchema, releaseMultipartCompleteRequestSchema, releaseMultipartCompleteResponseSchema, releaseMultipartCreateRequestSchema, releaseMultipartCreateResponseSchema, releaseMultipartListPartsQuerySchema, releaseMultipartListPartsResponseSchema, releaseMultipartPartSchema, releaseMultipartSignPartQuerySchema, releaseMultipartSignPartResponseSchema, releaseSyncManifestSchema, releaseSyncRequestSchema, releaseSyncResponseSchema, releaseSyncResultSchema, releaseUpdateRequestSchema, releaseUploadCompleteRequestSchema, releaseUploadCompleteResponseSchema, releaseUploadFailResponseSchema, releaseUploadInitRequestSchema, releaseUploadInitResponseSchema, releasesListQuerySchema, releasesListResponseSchema, serviceDetailResponseSchema, serviceSchema, serviceUsageResponseSchema, shareLinkCreateRequestSchema, shareLinkCreateResponseSchema, shareLinkDeleteResponseSchema, shareLinkDetailResponseSchema, shareLinkListResponseSchema, shareLinkSchema, shareLinkUpdateRequestSchema, shareLinkUpdateResponseSchema, sharesCreateRequestSchema, unixTimestamp, unlockPublicFile, uploadAppwriteInitRequestSchema, uploadAppwriteInitResponseSchema, uploadCompleteResponseSchema, uploadDestinationSchema, uploadFailResponseSchema, uploadLifecycleRequestSchema, uploadR2InitRequestSchema, uploadR2InitResponseSchema, uploadRecordDetailResponseSchema, uploadRecordSchema, uploadStatusSchema, uploadTypeSchema, uploadsListResponseSchema };
|
|
1409
|
+
export { type AdminServiceSettingsRequest, type AdminServiceSettingsResponse, type AdminServiceUpdateRequest, type AdminServiceUpdateResponse, type AdminUser, type AdminUserListResponse, type AdminUserPasswordResetRequest, type AdminUserPasswordResetResponse, type AdminUserRoleUpdateRequest, type AdminUserStorageLimitUpdateRequest, type AdminUserUpdateRequest, type AdminUserUpdateResponse, type ApiError, type AppReleaseLatestQuery, type AppReleaseLatestResponse, 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 FileUpdateRequest, type FileUpdateResponse, type Folder, type FolderCreateRequest, type FolderCreateResponse, type FolderDeleteResponse, type FolderDetailResponse, type FolderListQuery, type FolderListResponse, type FolderRestoreResponse, type FolderUpdateRequest, type FolderUpdateResponse, MainStorageDeleteResponse, MainStorageDetailResponse, MainStorageFile, MainStorageListQuery, MainStorageListResponse, MainStorageRenameRequest, MainStorageRenameResponse, MainStorageRestoreResponse, type MultipartAbortRequest, type MultipartAbortResponse, type MultipartCompleteRequest, type MultipartCompleteResponse, type MultipartCreateRequest, type MultipartCreateResponse, type MultipartListPartsQuery, type MultipartListPartsResponse, type MultipartPart, type MultipartSignPartQuery, type MultipartSignPartResponse, type PublicFileAccessResponse, type PublicFileLockedResponse, type RecommendedUploadDestination, type ReleaseDTO, type ReleaseDeleteResponse, type ReleaseMultipartAbortRequest, type ReleaseMultipartAbortResponse, type ReleaseMultipartCompleteRequest, type ReleaseMultipartCompleteResponse, type ReleaseMultipartCreateRequest, type ReleaseMultipartCreateResponse, type ReleaseMultipartListPartsQuery, type ReleaseMultipartListPartsResponse, type ReleaseMultipartPart, type ReleaseMultipartSignPartQuery, type ReleaseMultipartSignPartResponse, type ReleaseSyncManifest, type ReleaseSyncRequest, type ReleaseSyncResponse, type ReleaseSyncResult, type ReleaseUpdateRequest, type ReleaseUploadCompleteRequest, type ReleaseUploadCompleteResponse, type ReleaseUploadFailResponse, type ReleaseUploadInitRequest, type ReleaseUploadInitResponse, type ReleasesListQuery, type ReleasesListResponse, type Service, type ServiceDetailResponse, type ServiceUsageResponse, type ShareLink, type ShareLinkCreateRequest, type ShareLinkCreateResponse, type ShareLinkDeleteResponse, type ShareLinkDetailResponse, type ShareLinkListResponse, type ShareLinkUpdateRequest, type ShareLinkUpdateResponse, type SharesCreateRequest, UnisourceClient, type UnisourceClientConfig, UnisourceError, UnisourceNetworkError, type UploadAppwriteInitRequest, type UploadAppwriteInitResponse, type UploadCompleteResponse, type UploadDestination, type UploadFailResponse, type UploadLifecycleRequest, type UploadR2InitRequest, type UploadR2InitResponse, type UploadRecord, type UploadRecordDetailResponse, type UploadStatus, type UploadType, type UploadsListResponse, adminServiceSettingsRequestSchema, adminServiceSettingsResponseSchema, adminServiceUpdateRequestSchema, adminServiceUpdateResponseSchema, adminUserListResponseSchema, adminUserPasswordResetRequestSchema, adminUserPasswordResetResponseSchema, adminUserRoleUpdateRequestSchema, adminUserSchema, adminUserStorageLimitUpdateRequestSchema, adminUserUpdateRequestSchema, adminUserUpdateResponseSchema, apiErrorSchema, appReleaseLatestQuerySchema, appReleaseLatestResponseSchema, auditEventActionSchema, auditEventSchema, auditLogListQuerySchema, auditLogListResponseSchema, fileDeleteResponseSchema, fileDownloadUrlResponseSchema, fileMoveRequestSchema, fileRecordDetailResponseSchema, fileRecordSchema, fileRecordsListQuerySchema, fileRecordsListResponseSchema, fileRestoreResponseSchema, fileUpdateRequestSchema, fileUpdateResponseSchema, folderCreateRequestSchema, folderCreateResponseSchema, folderDeleteResponseSchema, folderDetailResponseSchema, folderListQuerySchema, folderListResponseSchema, folderRestoreResponseSchema, folderSchema, folderUpdateRequestSchema, folderUpdateResponseSchema, getPublicFileInfo, mainStorageDeleteResponseSchema, mainStorageDetailResponseSchema, mainStorageFileSchema, mainStorageListQuerySchema, mainStorageListResponseSchema, mainStorageRenameRequestSchema, mainStorageRenameResponseSchema, mainStorageRestoreResponseSchema, multipartAbortRequestSchema, multipartAbortResponseSchema, multipartCompleteRequestSchema, multipartCompleteResponseSchema, multipartCreateRequestSchema, multipartCreateResponseSchema, multipartListPartsQuerySchema, multipartListPartsResponseSchema, multipartPartSchema, multipartSignPartQuerySchema, multipartSignPartResponseSchema, nonEmptyString, nonNegativeInt, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, recommendedUploadDestinationSchema, releaseDTOSchema, releaseDeleteResponseSchema, releaseMultipartAbortRequestSchema, releaseMultipartAbortResponseSchema, releaseMultipartCompleteRequestSchema, releaseMultipartCompleteResponseSchema, releaseMultipartCreateRequestSchema, releaseMultipartCreateResponseSchema, releaseMultipartListPartsQuerySchema, releaseMultipartListPartsResponseSchema, releaseMultipartPartSchema, releaseMultipartSignPartQuerySchema, releaseMultipartSignPartResponseSchema, releaseSyncManifestSchema, releaseSyncRequestSchema, releaseSyncResponseSchema, releaseSyncResultSchema, releaseUpdateRequestSchema, releaseUploadCompleteRequestSchema, releaseUploadCompleteResponseSchema, releaseUploadFailResponseSchema, releaseUploadInitRequestSchema, releaseUploadInitResponseSchema, releasesListQuerySchema, releasesListResponseSchema, serviceDetailResponseSchema, serviceSchema, serviceUsageResponseSchema, shareLinkCreateRequestSchema, shareLinkCreateResponseSchema, shareLinkDeleteResponseSchema, shareLinkDetailResponseSchema, shareLinkListResponseSchema, shareLinkSchema, shareLinkUpdateRequestSchema, shareLinkUpdateResponseSchema, sharesCreateRequestSchema, unixTimestamp, unlockPublicFile, uploadAppwriteInitRequestSchema, uploadAppwriteInitResponseSchema, uploadCompleteResponseSchema, uploadDestinationSchema, uploadFailResponseSchema, uploadLifecycleRequestSchema, uploadR2InitRequestSchema, uploadR2InitResponseSchema, uploadRecordDetailResponseSchema, uploadRecordSchema, uploadStatusSchema, uploadTypeSchema, uploadsListResponseSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,25 @@ import { z } from "zod";
|
|
|
2
2
|
//#region src/primitives.ts
|
|
3
3
|
const nonEmptyString = z.string().trim().min(1);
|
|
4
4
|
const positiveInt = z.number().int().positive();
|
|
5
|
+
const nonNegativeInt = z.number().int().nonnegative();
|
|
5
6
|
const unixTimestamp = z.number().int().nonnegative();
|
|
6
7
|
const FILES_DEFAULT_LIMIT = 25;
|
|
7
8
|
const FILES_MAX_LIMIT = 100;
|
|
9
|
+
/**
|
|
10
|
+
* Storage backend a file lives on.
|
|
11
|
+
* - 'r2' — Cloudflare R2 via presigned PUT / multipart
|
|
12
|
+
* - 'appwrite' — Appwrite Storage via direct browser SDK upload
|
|
13
|
+
*
|
|
14
|
+
* `recommendedUploadDestinationSchema` adds the meta-value 'hybrid' which is
|
|
15
|
+
* only valid as a service-wide setting (the upload manager picks r2/appwrite
|
|
16
|
+
* per-file based on size).
|
|
17
|
+
*/
|
|
8
18
|
const uploadDestinationSchema = z.enum(["r2", "appwrite"]);
|
|
19
|
+
const recommendedUploadDestinationSchema = z.enum([
|
|
20
|
+
"r2",
|
|
21
|
+
"appwrite",
|
|
22
|
+
"hybrid"
|
|
23
|
+
]);
|
|
9
24
|
const uploadStatusSchema = z.enum([
|
|
10
25
|
"pending",
|
|
11
26
|
"completed",
|
|
@@ -137,7 +152,7 @@ const fileRecordSchema = z.object({
|
|
|
137
152
|
folder_id: nonEmptyString.nullable(),
|
|
138
153
|
upload_id: nonEmptyString.nullable(),
|
|
139
154
|
filename: nonEmptyString,
|
|
140
|
-
size:
|
|
155
|
+
size: nonNegativeInt,
|
|
141
156
|
mime_type: nonEmptyString,
|
|
142
157
|
storage_destination: uploadDestinationSchema,
|
|
143
158
|
is_trashed: z.boolean(),
|
|
@@ -173,7 +188,8 @@ const fileRestoreResponseSchema = z.object({
|
|
|
173
188
|
success: z.literal(true),
|
|
174
189
|
id: nonEmptyString
|
|
175
190
|
});
|
|
176
|
-
|
|
191
|
+
/** SDK4: filename hard-capped to 255 to match backend Zod validation. */
|
|
192
|
+
const fileUpdateRequestSchema = z.object({ filename: z.string().trim().min(1).max(255) });
|
|
177
193
|
const fileUpdateResponseSchema = z.object({ file: fileRecordSchema });
|
|
178
194
|
//#endregion
|
|
179
195
|
//#region src/folders.ts
|
|
@@ -232,7 +248,7 @@ const serviceSchema = z.object({
|
|
|
232
248
|
max_storage_bytes: positiveInt,
|
|
233
249
|
current_used_bytes: z.number().int().nonnegative(),
|
|
234
250
|
max_file_size_bytes: positiveInt,
|
|
235
|
-
recommended_upload_destination:
|
|
251
|
+
recommended_upload_destination: recommendedUploadDestinationSchema.optional(),
|
|
236
252
|
created_at: unixTimestamp
|
|
237
253
|
});
|
|
238
254
|
const serviceDetailResponseSchema = z.object({ service: serviceSchema });
|
|
@@ -246,7 +262,7 @@ const adminServiceUpdateResponseSchema = serviceDetailResponseSchema;
|
|
|
246
262
|
* can flip the recommended default upload destination per service without
|
|
247
263
|
* disturbing quota-related fields.
|
|
248
264
|
*/
|
|
249
|
-
const adminServiceSettingsRequestSchema = z.object({ recommended_upload_destination:
|
|
265
|
+
const adminServiceSettingsRequestSchema = z.object({ recommended_upload_destination: recommendedUploadDestinationSchema.optional() }).refine((v) => v.recommended_upload_destination !== void 0, { message: "At least one setting must be provided" });
|
|
250
266
|
const adminServiceSettingsResponseSchema = serviceDetailResponseSchema;
|
|
251
267
|
const serviceUsageResponseSchema = z.object({
|
|
252
268
|
service_id: nonEmptyString,
|
|
@@ -486,6 +502,24 @@ const releaseSyncResponseSchema = z.object({
|
|
|
486
502
|
synced: z.number().int().nonnegative(),
|
|
487
503
|
results: z.array(releaseSyncResultSchema)
|
|
488
504
|
});
|
|
505
|
+
/**
|
|
506
|
+
* Response of `GET /app/releases/latest?channel=...` — used by client apps to
|
|
507
|
+
* discover the most recent completed release for a given distribution channel
|
|
508
|
+
* (e.g. `stable`, `beta`). Includes a short-lived presigned download URL.
|
|
509
|
+
*/
|
|
510
|
+
const appReleaseLatestQuerySchema = z.object({ channel: nonEmptyString.optional().default("stable") });
|
|
511
|
+
const appReleaseLatestResponseSchema = z.object({
|
|
512
|
+
id: nonEmptyString,
|
|
513
|
+
name: nonEmptyString,
|
|
514
|
+
size: z.number().int().nonnegative(),
|
|
515
|
+
r2_key: nonEmptyString,
|
|
516
|
+
tags: z.array(nonEmptyString),
|
|
517
|
+
notes: z.string().nullable(),
|
|
518
|
+
force_update: z.boolean(),
|
|
519
|
+
created_at: nonEmptyString,
|
|
520
|
+
download_url: z.string().url(),
|
|
521
|
+
download_url_expires_at: positiveInt
|
|
522
|
+
});
|
|
489
523
|
//#endregion
|
|
490
524
|
//#region src/shareLinks.ts
|
|
491
525
|
const shareLinkSchema = z.object({
|
|
@@ -909,6 +943,10 @@ var UnisourceClient = class {
|
|
|
909
943
|
get: (id, signal) => apiRequest(this.config, "GET", `/shares/${id}`, { signal }),
|
|
910
944
|
delete: (id, signal) => apiRequest(this.config, "DELETE", `/shares/${id}`, { signal })
|
|
911
945
|
};
|
|
946
|
+
app = { releases: { latest: (channel = "stable", signal) => apiRequest(this.config, "GET", "/app/releases/latest", {
|
|
947
|
+
query: { channel },
|
|
948
|
+
signal
|
|
949
|
+
}) } };
|
|
912
950
|
};
|
|
913
951
|
//#endregion
|
|
914
|
-
export { FILES_DEFAULT_LIMIT, FILES_MAX_LIMIT, UnisourceClient, UnisourceError, UnisourceNetworkError, adminServiceSettingsRequestSchema, adminServiceSettingsResponseSchema, adminServiceUpdateRequestSchema, adminServiceUpdateResponseSchema, adminUserListResponseSchema, adminUserPasswordResetRequestSchema, adminUserPasswordResetResponseSchema, adminUserRoleUpdateRequestSchema, adminUserSchema, adminUserStorageLimitUpdateRequestSchema, adminUserUpdateRequestSchema, adminUserUpdateResponseSchema, apiErrorSchema, auditEventActionSchema, auditEventSchema, auditLogListQuerySchema, auditLogListResponseSchema, fileDeleteResponseSchema, fileDownloadUrlResponseSchema, fileMoveRequestSchema, fileRecordDetailResponseSchema, fileRecordSchema, fileRecordsListQuerySchema, fileRecordsListResponseSchema, fileRestoreResponseSchema, fileUpdateRequestSchema, fileUpdateResponseSchema, folderCreateRequestSchema, folderCreateResponseSchema, folderDeleteResponseSchema, folderDetailResponseSchema, folderListQuerySchema, folderListResponseSchema, folderRestoreResponseSchema, folderSchema, folderUpdateRequestSchema, folderUpdateResponseSchema, getPublicFileInfo, mainStorageDeleteResponseSchema, mainStorageDetailResponseSchema, mainStorageFileSchema, mainStorageListQuerySchema, mainStorageListResponseSchema, mainStorageRenameRequestSchema, mainStorageRenameResponseSchema, mainStorageRestoreResponseSchema, multipartAbortRequestSchema, multipartAbortResponseSchema, multipartCompleteRequestSchema, multipartCompleteResponseSchema, multipartCreateRequestSchema, multipartCreateResponseSchema, multipartListPartsQuerySchema, multipartListPartsResponseSchema, multipartPartSchema, multipartSignPartQuerySchema, multipartSignPartResponseSchema, nonEmptyString, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, releaseDTOSchema, releaseDeleteResponseSchema, releaseMultipartAbortRequestSchema, releaseMultipartAbortResponseSchema, releaseMultipartCompleteRequestSchema, releaseMultipartCompleteResponseSchema, releaseMultipartCreateRequestSchema, releaseMultipartCreateResponseSchema, releaseMultipartListPartsQuerySchema, releaseMultipartListPartsResponseSchema, releaseMultipartPartSchema, releaseMultipartSignPartQuerySchema, releaseMultipartSignPartResponseSchema, releaseSyncManifestSchema, releaseSyncRequestSchema, releaseSyncResponseSchema, releaseSyncResultSchema, releaseUpdateRequestSchema, releaseUploadCompleteRequestSchema, releaseUploadCompleteResponseSchema, releaseUploadFailResponseSchema, releaseUploadInitRequestSchema, releaseUploadInitResponseSchema, releasesListQuerySchema, releasesListResponseSchema, serviceDetailResponseSchema, serviceSchema, serviceUsageResponseSchema, shareLinkCreateRequestSchema, shareLinkCreateResponseSchema, shareLinkDeleteResponseSchema, shareLinkDetailResponseSchema, shareLinkListResponseSchema, shareLinkSchema, shareLinkUpdateRequestSchema, shareLinkUpdateResponseSchema, sharesCreateRequestSchema, unixTimestamp, unlockPublicFile, uploadAppwriteInitRequestSchema, uploadAppwriteInitResponseSchema, uploadCompleteResponseSchema, uploadDestinationSchema, uploadFailResponseSchema, uploadLifecycleRequestSchema, uploadR2InitRequestSchema, uploadR2InitResponseSchema, uploadRecordDetailResponseSchema, uploadRecordSchema, uploadStatusSchema, uploadTypeSchema, uploadsListResponseSchema };
|
|
952
|
+
export { FILES_DEFAULT_LIMIT, FILES_MAX_LIMIT, UnisourceClient, UnisourceError, UnisourceNetworkError, adminServiceSettingsRequestSchema, adminServiceSettingsResponseSchema, adminServiceUpdateRequestSchema, adminServiceUpdateResponseSchema, adminUserListResponseSchema, adminUserPasswordResetRequestSchema, adminUserPasswordResetResponseSchema, adminUserRoleUpdateRequestSchema, adminUserSchema, adminUserStorageLimitUpdateRequestSchema, adminUserUpdateRequestSchema, adminUserUpdateResponseSchema, apiErrorSchema, appReleaseLatestQuerySchema, appReleaseLatestResponseSchema, auditEventActionSchema, auditEventSchema, auditLogListQuerySchema, auditLogListResponseSchema, fileDeleteResponseSchema, fileDownloadUrlResponseSchema, fileMoveRequestSchema, fileRecordDetailResponseSchema, fileRecordSchema, fileRecordsListQuerySchema, fileRecordsListResponseSchema, fileRestoreResponseSchema, fileUpdateRequestSchema, fileUpdateResponseSchema, folderCreateRequestSchema, folderCreateResponseSchema, folderDeleteResponseSchema, folderDetailResponseSchema, folderListQuerySchema, folderListResponseSchema, folderRestoreResponseSchema, folderSchema, folderUpdateRequestSchema, folderUpdateResponseSchema, getPublicFileInfo, mainStorageDeleteResponseSchema, mainStorageDetailResponseSchema, mainStorageFileSchema, mainStorageListQuerySchema, mainStorageListResponseSchema, mainStorageRenameRequestSchema, mainStorageRenameResponseSchema, mainStorageRestoreResponseSchema, multipartAbortRequestSchema, multipartAbortResponseSchema, multipartCompleteRequestSchema, multipartCompleteResponseSchema, multipartCreateRequestSchema, multipartCreateResponseSchema, multipartListPartsQuerySchema, multipartListPartsResponseSchema, multipartPartSchema, multipartSignPartQuerySchema, multipartSignPartResponseSchema, nonEmptyString, nonNegativeInt, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, recommendedUploadDestinationSchema, releaseDTOSchema, releaseDeleteResponseSchema, releaseMultipartAbortRequestSchema, releaseMultipartAbortResponseSchema, releaseMultipartCompleteRequestSchema, releaseMultipartCompleteResponseSchema, releaseMultipartCreateRequestSchema, releaseMultipartCreateResponseSchema, releaseMultipartListPartsQuerySchema, releaseMultipartListPartsResponseSchema, releaseMultipartPartSchema, releaseMultipartSignPartQuerySchema, releaseMultipartSignPartResponseSchema, releaseSyncManifestSchema, releaseSyncRequestSchema, releaseSyncResponseSchema, releaseSyncResultSchema, releaseUpdateRequestSchema, releaseUploadCompleteRequestSchema, releaseUploadCompleteResponseSchema, releaseUploadFailResponseSchema, releaseUploadInitRequestSchema, releaseUploadInitResponseSchema, releasesListQuerySchema, releasesListResponseSchema, serviceDetailResponseSchema, serviceSchema, serviceUsageResponseSchema, shareLinkCreateRequestSchema, shareLinkCreateResponseSchema, shareLinkDeleteResponseSchema, shareLinkDetailResponseSchema, shareLinkListResponseSchema, shareLinkSchema, shareLinkUpdateRequestSchema, shareLinkUpdateResponseSchema, sharesCreateRequestSchema, unixTimestamp, unlockPublicFile, uploadAppwriteInitRequestSchema, uploadAppwriteInitResponseSchema, uploadCompleteResponseSchema, uploadDestinationSchema, uploadFailResponseSchema, uploadLifecycleRequestSchema, uploadR2InitRequestSchema, uploadR2InitResponseSchema, uploadRecordDetailResponseSchema, uploadRecordSchema, uploadStatusSchema, uploadTypeSchema, uploadsListResponseSchema };
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiError, UploadStatus } from './primitives';
|
|
1
|
+
import type { ApiError, UploadDestination, UploadStatus } from './primitives';
|
|
2
2
|
import type {
|
|
3
3
|
UploadR2InitRequest,
|
|
4
4
|
UploadR2InitResponse,
|
|
@@ -97,6 +97,7 @@ import type {
|
|
|
97
97
|
ReleaseMultipartCompleteRequest,
|
|
98
98
|
ReleaseMultipartCompleteResponse,
|
|
99
99
|
ReleaseMultipartAbortResponse,
|
|
100
|
+
AppReleaseLatestResponse,
|
|
100
101
|
} from './releases';
|
|
101
102
|
|
|
102
103
|
// ─── SDK Error classes ────────────────────────────────────────────────────────
|
|
@@ -501,7 +502,10 @@ export class UnisourceClient {
|
|
|
501
502
|
apiRequest(this.config, 'GET', '/admin/service/usage', { signal }),
|
|
502
503
|
|
|
503
504
|
/** List all uploads (pending/completed/failed) for this service */
|
|
504
|
-
listUploads: (
|
|
505
|
+
listUploads: (
|
|
506
|
+
query?: { destination?: UploadDestination; status?: UploadStatus; cursor?: string; limit?: number },
|
|
507
|
+
signal?: AbortSignal
|
|
508
|
+
): Promise<UploadsListResponse> =>
|
|
505
509
|
apiRequest(this.config, 'GET', '/admin/files', { query, signal }),
|
|
506
510
|
|
|
507
511
|
/** Get a single upload for this service */
|
|
@@ -622,4 +626,21 @@ export class UnisourceClient {
|
|
|
622
626
|
delete: (id: string, signal?: AbortSignal): Promise<ShareLinkDeleteResponse> =>
|
|
623
627
|
apiRequest(this.config, 'DELETE', `/shares/${id}`, { signal }),
|
|
624
628
|
};
|
|
629
|
+
|
|
630
|
+
// ─── App-facing endpoints (/app/*) — public release distribution ──────────────
|
|
631
|
+
|
|
632
|
+
readonly app = {
|
|
633
|
+
releases: {
|
|
634
|
+
/**
|
|
635
|
+
* Get the latest completed release for a channel (e.g. `stable`, `beta`).
|
|
636
|
+
* Backed by `GET /app/releases/latest`. Returns the release metadata plus
|
|
637
|
+
* a short-lived presigned download URL.
|
|
638
|
+
*/
|
|
639
|
+
latest: (
|
|
640
|
+
channel: string = 'stable',
|
|
641
|
+
signal?: AbortSignal
|
|
642
|
+
): Promise<AppReleaseLatestResponse> =>
|
|
643
|
+
apiRequest(this.config, 'GET', '/app/releases/latest', { query: { channel }, signal }),
|
|
644
|
+
},
|
|
645
|
+
};
|
|
625
646
|
}
|
package/src/fileRecords.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
nonEmptyString,
|
|
4
|
+
nonNegativeInt,
|
|
5
|
+
positiveInt,
|
|
6
|
+
uploadDestinationSchema,
|
|
7
|
+
FILES_DEFAULT_LIMIT,
|
|
8
|
+
FILES_MAX_LIMIT,
|
|
9
|
+
} from './primitives';
|
|
3
10
|
|
|
4
11
|
// ─── User-facing file record ──────────────────────────────────────────────────
|
|
5
12
|
|
|
@@ -14,7 +21,8 @@ export const fileRecordSchema = z.object({
|
|
|
14
21
|
folder_id: nonEmptyString.nullable(),
|
|
15
22
|
upload_id: nonEmptyString.nullable(),
|
|
16
23
|
filename: nonEmptyString,
|
|
17
|
-
|
|
24
|
+
/** SDK6: zero-byte uploads are valid (e.g. placeholders). */
|
|
25
|
+
size: nonNegativeInt,
|
|
18
26
|
mime_type: nonEmptyString,
|
|
19
27
|
storage_destination: uploadDestinationSchema,
|
|
20
28
|
is_trashed: z.boolean(),
|
|
@@ -88,8 +96,9 @@ export type FileRestoreResponse = z.infer<typeof fileRestoreResponseSchema>;
|
|
|
88
96
|
|
|
89
97
|
// ─── Update (rename) ──────────────────────────────────────────────────────────
|
|
90
98
|
|
|
99
|
+
/** SDK4: filename hard-capped to 255 to match backend Zod validation. */
|
|
91
100
|
export const fileUpdateRequestSchema = z.object({
|
|
92
|
-
filename:
|
|
101
|
+
filename: z.string().trim().min(1).max(255),
|
|
93
102
|
});
|
|
94
103
|
export type FileUpdateRequest = z.infer<typeof fileUpdateRequestSchema>;
|
|
95
104
|
|
package/src/index.ts
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
export {
|
|
3
3
|
nonEmptyString,
|
|
4
4
|
positiveInt,
|
|
5
|
+
nonNegativeInt,
|
|
5
6
|
unixTimestamp,
|
|
6
7
|
uploadDestinationSchema,
|
|
8
|
+
recommendedUploadDestinationSchema,
|
|
7
9
|
uploadStatusSchema,
|
|
8
10
|
apiErrorSchema,
|
|
9
11
|
FILES_DEFAULT_LIMIT,
|
|
10
12
|
FILES_MAX_LIMIT,
|
|
11
13
|
} from './primitives';
|
|
12
|
-
export type {
|
|
14
|
+
export type {
|
|
15
|
+
UploadDestination,
|
|
16
|
+
RecommendedUploadDestination,
|
|
17
|
+
UploadStatus,
|
|
18
|
+
ApiError,
|
|
19
|
+
} from './primitives';
|
|
13
20
|
|
|
14
21
|
|
|
15
22
|
// ─── Upload ───────────────────────────────────────────────────────────────────
|
|
@@ -188,6 +195,8 @@ export {
|
|
|
188
195
|
releaseMultipartCompleteResponseSchema,
|
|
189
196
|
releaseMultipartAbortRequestSchema,
|
|
190
197
|
releaseMultipartAbortResponseSchema,
|
|
198
|
+
appReleaseLatestQuerySchema,
|
|
199
|
+
appReleaseLatestResponseSchema,
|
|
191
200
|
} from './releases';
|
|
192
201
|
export type {
|
|
193
202
|
ReleaseDTO,
|
|
@@ -215,6 +224,8 @@ export type {
|
|
|
215
224
|
ReleaseMultipartCompleteResponse,
|
|
216
225
|
ReleaseMultipartAbortRequest,
|
|
217
226
|
ReleaseMultipartAbortResponse,
|
|
227
|
+
AppReleaseLatestQuery,
|
|
228
|
+
AppReleaseLatestResponse,
|
|
218
229
|
} from './releases';
|
|
219
230
|
|
|
220
231
|
// ─── Share Links ─────────────────────────────────────────────────────────────
|
package/src/primitives.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
|
|
5
5
|
export const nonEmptyString = z.string().trim().min(1);
|
|
6
6
|
export const positiveInt = z.number().int().positive();
|
|
7
|
+
export const nonNegativeInt = z.number().int().nonnegative();
|
|
7
8
|
export const unixTimestamp = z.number().int().nonnegative();
|
|
8
9
|
|
|
9
10
|
// ─── Pagination constants ─────────────────────────────────────────────────────
|
|
@@ -13,9 +14,21 @@ export const FILES_MAX_LIMIT = 100;
|
|
|
13
14
|
|
|
14
15
|
// ─── Upload Destination ──────────────────────────────────────────────────────
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Storage backend a file lives on.
|
|
19
|
+
* - 'r2' — Cloudflare R2 via presigned PUT / multipart
|
|
20
|
+
* - 'appwrite' — Appwrite Storage via direct browser SDK upload
|
|
21
|
+
*
|
|
22
|
+
* `recommendedUploadDestinationSchema` adds the meta-value 'hybrid' which is
|
|
23
|
+
* only valid as a service-wide setting (the upload manager picks r2/appwrite
|
|
24
|
+
* per-file based on size).
|
|
25
|
+
*/
|
|
16
26
|
export const uploadDestinationSchema = z.enum(['r2', 'appwrite']);
|
|
17
27
|
export type UploadDestination = z.infer<typeof uploadDestinationSchema>;
|
|
18
28
|
|
|
29
|
+
export const recommendedUploadDestinationSchema = z.enum(['r2', 'appwrite', 'hybrid']);
|
|
30
|
+
export type RecommendedUploadDestination = z.infer<typeof recommendedUploadDestinationSchema>;
|
|
31
|
+
|
|
19
32
|
// ─── Upload Status ────────────────────────────────────────────────────────────
|
|
20
33
|
|
|
21
34
|
export const uploadStatusSchema = z.enum(['pending', 'completed', 'failed']);
|
package/src/releases.ts
CHANGED
|
@@ -208,3 +208,29 @@ export const releaseSyncResponseSchema = z.object({
|
|
|
208
208
|
results: z.array(releaseSyncResultSchema),
|
|
209
209
|
});
|
|
210
210
|
export type ReleaseSyncResponse = z.infer<typeof releaseSyncResponseSchema>;
|
|
211
|
+
|
|
212
|
+
// ─── App-facing /app/releases/latest ─────────────────────────────────────────
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Response of `GET /app/releases/latest?channel=...` — used by client apps to
|
|
216
|
+
* discover the most recent completed release for a given distribution channel
|
|
217
|
+
* (e.g. `stable`, `beta`). Includes a short-lived presigned download URL.
|
|
218
|
+
*/
|
|
219
|
+
export const appReleaseLatestQuerySchema = z.object({
|
|
220
|
+
channel: nonEmptyString.optional().default('stable'),
|
|
221
|
+
});
|
|
222
|
+
export type AppReleaseLatestQuery = z.input<typeof appReleaseLatestQuerySchema>;
|
|
223
|
+
|
|
224
|
+
export const appReleaseLatestResponseSchema = z.object({
|
|
225
|
+
id: nonEmptyString,
|
|
226
|
+
name: nonEmptyString,
|
|
227
|
+
size: z.number().int().nonnegative(),
|
|
228
|
+
r2_key: nonEmptyString,
|
|
229
|
+
tags: z.array(nonEmptyString),
|
|
230
|
+
notes: z.string().nullable(),
|
|
231
|
+
force_update: z.boolean(),
|
|
232
|
+
created_at: nonEmptyString,
|
|
233
|
+
download_url: z.string().url(),
|
|
234
|
+
download_url_expires_at: positiveInt,
|
|
235
|
+
});
|
|
236
|
+
export type AppReleaseLatestResponse = z.infer<typeof appReleaseLatestResponseSchema>;
|
package/src/services.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { nonEmptyString, positiveInt,
|
|
2
|
+
import { nonEmptyString, positiveInt, recommendedUploadDestinationSchema, unixTimestamp } from './primitives';
|
|
3
3
|
|
|
4
4
|
// ─── Service record ───────────────────────────────────────────────────────────
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ export const serviceSchema = z.object({
|
|
|
10
10
|
max_storage_bytes: positiveInt,
|
|
11
11
|
current_used_bytes: z.number().int().nonnegative(),
|
|
12
12
|
max_file_size_bytes: positiveInt,
|
|
13
|
-
recommended_upload_destination:
|
|
13
|
+
recommended_upload_destination: recommendedUploadDestinationSchema.optional(),
|
|
14
14
|
created_at: unixTimestamp,
|
|
15
15
|
});
|
|
16
16
|
export type Service = z.infer<typeof serviceSchema>;
|
|
@@ -43,7 +43,7 @@ export type AdminServiceUpdateResponse = z.infer<typeof adminServiceUpdateRespon
|
|
|
43
43
|
*/
|
|
44
44
|
export const adminServiceSettingsRequestSchema = z
|
|
45
45
|
.object({
|
|
46
|
-
recommended_upload_destination:
|
|
46
|
+
recommended_upload_destination: recommendedUploadDestinationSchema.optional(),
|
|
47
47
|
})
|
|
48
48
|
.refine((v) => v.recommended_upload_destination !== undefined, {
|
|
49
49
|
message: 'At least one setting must be provided',
|