@unisource/sdk 0.3.1 → 0.3.2
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 +70 -5
- package/dist/index.mjs +60 -5
- package/package.json +1 -1
- package/src/client.ts +69 -5
- package/src/index.ts +8 -0
- package/src/services.ts +12 -0
- package/src/shareLinks.ts +16 -0
- package/src/uploads.ts +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -31,7 +31,7 @@ declare const uploadR2InitRequestSchema: z.ZodObject<{
|
|
|
31
31
|
folder_id: z.ZodOptional<z.ZodString>;
|
|
32
32
|
is_main_storage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
33
33
|
}, z.core.$strip>;
|
|
34
|
-
type UploadR2InitRequest = z.
|
|
34
|
+
type UploadR2InitRequest = z.input<typeof uploadR2InitRequestSchema>;
|
|
35
35
|
declare const uploadR2InitResponseSchema: z.ZodObject<{
|
|
36
36
|
upload_id: z.ZodString;
|
|
37
37
|
destination: z.ZodLiteral<"r2">;
|
|
@@ -48,7 +48,7 @@ declare const uploadAppwriteInitRequestSchema: z.ZodObject<{
|
|
|
48
48
|
folder_id: z.ZodOptional<z.ZodString>;
|
|
49
49
|
is_main_storage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
50
50
|
}, z.core.$strip>;
|
|
51
|
-
type UploadAppwriteInitRequest = z.
|
|
51
|
+
type UploadAppwriteInitRequest = z.input<typeof uploadAppwriteInitRequestSchema>;
|
|
52
52
|
declare const uploadAppwriteInitResponseSchema: z.ZodObject<{
|
|
53
53
|
upload_id: z.ZodString;
|
|
54
54
|
destination: z.ZodLiteral<"appwrite">;
|
|
@@ -63,7 +63,7 @@ declare const uploadLifecycleRequestSchema: z.ZodObject<{
|
|
|
63
63
|
upload_id: z.ZodString;
|
|
64
64
|
is_main_storage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
65
65
|
}, z.core.$strip>;
|
|
66
|
-
type UploadLifecycleRequest = z.
|
|
66
|
+
type UploadLifecycleRequest = z.input<typeof uploadLifecycleRequestSchema>;
|
|
67
67
|
declare const uploadCompleteResponseSchema: z.ZodObject<{
|
|
68
68
|
success: z.ZodLiteral<true>;
|
|
69
69
|
upload_id: z.ZodString;
|
|
@@ -582,6 +582,18 @@ declare const adminUserPasswordResetResponseSchema: z.ZodObject<{
|
|
|
582
582
|
user_id: z.ZodString;
|
|
583
583
|
}, z.core.$strip>;
|
|
584
584
|
type AdminUserPasswordResetResponse = z.infer<typeof adminUserPasswordResetResponseSchema>;
|
|
585
|
+
declare const adminUserRoleUpdateRequestSchema: z.ZodObject<{
|
|
586
|
+
role: z.ZodEnum<{
|
|
587
|
+
admin: "admin";
|
|
588
|
+
plus: "plus";
|
|
589
|
+
user: "user";
|
|
590
|
+
}>;
|
|
591
|
+
}, z.core.$strip>;
|
|
592
|
+
type AdminUserRoleUpdateRequest = z.infer<typeof adminUserRoleUpdateRequestSchema>;
|
|
593
|
+
declare const adminUserStorageLimitUpdateRequestSchema: z.ZodObject<{
|
|
594
|
+
limit_bytes: z.ZodNullable<z.ZodNumber>;
|
|
595
|
+
}, z.core.$strip>;
|
|
596
|
+
type AdminUserStorageLimitUpdateRequest = z.infer<typeof adminUserStorageLimitUpdateRequestSchema>;
|
|
585
597
|
//#endregion
|
|
586
598
|
//#region src/mainStorage.d.ts
|
|
587
599
|
declare const mainStorageListQuerySchema: z.ZodObject<{
|
|
@@ -932,6 +944,32 @@ declare const shareLinkDeleteResponseSchema: z.ZodObject<{
|
|
|
932
944
|
id: z.ZodString;
|
|
933
945
|
}, z.core.$strip>;
|
|
934
946
|
type ShareLinkDeleteResponse = z.infer<typeof shareLinkDeleteResponseSchema>;
|
|
947
|
+
declare const shareLinkDetailResponseSchema: z.ZodObject<{
|
|
948
|
+
link: z.ZodObject<{
|
|
949
|
+
id: z.ZodString;
|
|
950
|
+
service_id: z.ZodString;
|
|
951
|
+
file_id: z.ZodString;
|
|
952
|
+
user_id: z.ZodString;
|
|
953
|
+
slug: z.ZodString;
|
|
954
|
+
name: z.ZodNullable<z.ZodString>;
|
|
955
|
+
has_password: z.ZodBoolean;
|
|
956
|
+
expires_at: z.ZodNullable<z.ZodNumber>;
|
|
957
|
+
download_count: z.ZodNumber;
|
|
958
|
+
max_downloads: z.ZodNullable<z.ZodNumber>;
|
|
959
|
+
is_active: z.ZodBoolean;
|
|
960
|
+
created_at: z.ZodNumber;
|
|
961
|
+
updated_at: z.ZodNumber;
|
|
962
|
+
}, z.core.$strip>;
|
|
963
|
+
}, z.core.$strip>;
|
|
964
|
+
type ShareLinkDetailResponse = z.infer<typeof shareLinkDetailResponseSchema>;
|
|
965
|
+
declare const sharesCreateRequestSchema: z.ZodObject<{
|
|
966
|
+
file_id: z.ZodString;
|
|
967
|
+
name: z.ZodOptional<z.ZodString>;
|
|
968
|
+
expires_at: z.ZodOptional<z.ZodNumber>;
|
|
969
|
+
max_downloads: z.ZodOptional<z.ZodNumber>;
|
|
970
|
+
password: z.ZodOptional<z.ZodString>;
|
|
971
|
+
}, z.core.$strip>;
|
|
972
|
+
type SharesCreateRequest = z.infer<typeof sharesCreateRequestSchema>;
|
|
935
973
|
//#endregion
|
|
936
974
|
//#region src/client.d.ts
|
|
937
975
|
declare class UnisourceError extends Error {
|
|
@@ -1067,7 +1105,9 @@ declare class UnisourceClient {
|
|
|
1067
1105
|
limit?: number;
|
|
1068
1106
|
}, signal?: AbortSignal) => Promise<AdminUserListResponse>; /** Update Appwrite user properties and service-specific quota/role */
|
|
1069
1107
|
updateUser: (userId: string, body: AdminUserUpdateRequest, signal?: AbortSignal) => Promise<AdminUserUpdateResponse>; /** Overwrite a user's password and revoke active sessions */
|
|
1070
|
-
resetUserPassword: (userId: string, body: AdminUserPasswordResetRequest, signal?: AbortSignal) => Promise<AdminUserPasswordResetResponse>;
|
|
1108
|
+
resetUserPassword: (userId: string, body: AdminUserPasswordResetRequest, signal?: AbortSignal) => Promise<AdminUserPasswordResetResponse>; /** Update a user's role */
|
|
1109
|
+
updateUserRole: (userId: string, body: AdminUserRoleUpdateRequest, signal?: AbortSignal) => Promise<AdminUserUpdateResponse>; /** Update a user's storage limit */
|
|
1110
|
+
updateUserStorageLimit: (userId: string, body: AdminUserStorageLimitUpdateRequest, signal?: AbortSignal) => Promise<AdminUserUpdateResponse>;
|
|
1071
1111
|
};
|
|
1072
1112
|
readonly shareLinks: {
|
|
1073
1113
|
/** Create a public share link for a file */create: (fileId: string, body: ShareLinkCreateRequest, signal?: AbortSignal) => Promise<ShareLinkCreateResponse>; /** List all share links for a file */
|
|
@@ -1075,6 +1115,31 @@ declare class UnisourceClient {
|
|
|
1075
1115
|
update: (linkId: string, body: ShareLinkUpdateRequest, signal?: AbortSignal) => Promise<ShareLinkUpdateResponse>; /** Permanently delete a share link */
|
|
1076
1116
|
delete: (linkId: string, signal?: AbortSignal) => Promise<ShareLinkDeleteResponse>;
|
|
1077
1117
|
};
|
|
1118
|
+
readonly files: {
|
|
1119
|
+
/** Get a single file record */get: (id: string, signal?: AbortSignal, options?: {
|
|
1120
|
+
asUser?: string;
|
|
1121
|
+
}) => Promise<FileRecordDetailResponse>; /** Rename or update a file */
|
|
1122
|
+
update: (id: string, body: FileUpdateRequest, signal?: AbortSignal, options?: {
|
|
1123
|
+
asUser?: string;
|
|
1124
|
+
}) => Promise<FileUpdateResponse>; /** Soft-delete or permanently delete a file */
|
|
1125
|
+
delete: (id: string, query?: {
|
|
1126
|
+
permanent?: boolean;
|
|
1127
|
+
}, signal?: AbortSignal, options?: {
|
|
1128
|
+
asUser?: string;
|
|
1129
|
+
}) => Promise<FileDeleteResponse>; /** Restore a file from trash */
|
|
1130
|
+
restore: (id: string, signal?: AbortSignal, options?: {
|
|
1131
|
+
asUser?: string;
|
|
1132
|
+
}) => Promise<FileRestoreResponse>; /** Get a time-limited download URL */
|
|
1133
|
+
downloadUrl: (id: string, signal?: AbortSignal, options?: {
|
|
1134
|
+
asUser?: string;
|
|
1135
|
+
}) => Promise<FileDownloadUrlResponse>;
|
|
1136
|
+
};
|
|
1137
|
+
readonly shares: {
|
|
1138
|
+
/** List all share links for the authenticated user */list: (signal?: AbortSignal) => Promise<ShareLinkListResponse>; /** Create a share link (file_id in body) */
|
|
1139
|
+
create: (body: SharesCreateRequest, signal?: AbortSignal) => Promise<ShareLinkCreateResponse>; /** Get a single share link by ID */
|
|
1140
|
+
get: (id: string, signal?: AbortSignal) => Promise<ShareLinkDetailResponse>; /** Delete a share link */
|
|
1141
|
+
delete: (id: string, signal?: AbortSignal) => Promise<ShareLinkDeleteResponse>;
|
|
1142
|
+
};
|
|
1078
1143
|
}
|
|
1079
1144
|
//#endregion
|
|
1080
|
-
export { type AdminServiceUpdateRequest, type AdminServiceUpdateResponse, type AdminUser, type AdminUserListResponse, type AdminUserPasswordResetRequest, type AdminUserPasswordResetResponse, 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 PublicFileAccessResponse, type PublicFileLockedResponse, type ReleaseDTO, type ReleaseDeleteResponse, 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 ShareLinkListResponse, type ShareLinkUpdateRequest, type ShareLinkUpdateResponse, 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 UploadsListResponse, adminServiceUpdateRequestSchema, adminServiceUpdateResponseSchema, adminUserListResponseSchema, adminUserPasswordResetRequestSchema, adminUserPasswordResetResponseSchema, adminUserSchema, 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, nonEmptyString, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, releaseDTOSchema, releaseDeleteResponseSchema, releaseSyncManifestSchema, releaseSyncRequestSchema, releaseSyncResponseSchema, releaseSyncResultSchema, releaseUpdateRequestSchema, releaseUploadCompleteRequestSchema, releaseUploadCompleteResponseSchema, releaseUploadFailResponseSchema, releaseUploadInitRequestSchema, releaseUploadInitResponseSchema, releasesListQuerySchema, releasesListResponseSchema, serviceDetailResponseSchema, serviceSchema, serviceUsageResponseSchema, shareLinkCreateRequestSchema, shareLinkCreateResponseSchema, shareLinkDeleteResponseSchema, shareLinkListResponseSchema, shareLinkSchema, shareLinkUpdateRequestSchema, shareLinkUpdateResponseSchema, unixTimestamp, unlockPublicFile, uploadAppwriteInitRequestSchema, uploadAppwriteInitResponseSchema, uploadCompleteResponseSchema, uploadDestinationSchema, uploadFailResponseSchema, uploadLifecycleRequestSchema, uploadR2InitRequestSchema, uploadR2InitResponseSchema, uploadRecordDetailResponseSchema, uploadRecordSchema, uploadStatusSchema, uploadsListResponseSchema };
|
|
1145
|
+
export { 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 PublicFileAccessResponse, type PublicFileLockedResponse, type ReleaseDTO, type ReleaseDeleteResponse, 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 UploadsListResponse, 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, nonEmptyString, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, releaseDTOSchema, releaseDeleteResponseSchema, 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, uploadsListResponseSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -283,6 +283,12 @@ const adminUserPasswordResetResponseSchema = z.object({
|
|
|
283
283
|
success: z.literal(true),
|
|
284
284
|
user_id: nonEmptyString
|
|
285
285
|
});
|
|
286
|
+
const adminUserRoleUpdateRequestSchema = z.object({ role: z.enum([
|
|
287
|
+
"user",
|
|
288
|
+
"plus",
|
|
289
|
+
"admin"
|
|
290
|
+
]) });
|
|
291
|
+
const adminUserStorageLimitUpdateRequestSchema = z.object({ limit_bytes: positiveInt.nullable() });
|
|
286
292
|
//#endregion
|
|
287
293
|
//#region src/mainStorage.ts
|
|
288
294
|
const mainStorageListQuerySchema = z.object({
|
|
@@ -446,6 +452,14 @@ const shareLinkDeleteResponseSchema = z.object({
|
|
|
446
452
|
success: z.literal(true),
|
|
447
453
|
id: nonEmptyString
|
|
448
454
|
});
|
|
455
|
+
const shareLinkDetailResponseSchema = z.object({ link: shareLinkSchema });
|
|
456
|
+
const sharesCreateRequestSchema = z.object({
|
|
457
|
+
file_id: nonEmptyString,
|
|
458
|
+
name: z.string().trim().max(128).optional(),
|
|
459
|
+
expires_at: positiveInt.optional(),
|
|
460
|
+
max_downloads: positiveInt.optional(),
|
|
461
|
+
password: z.string().min(1).optional()
|
|
462
|
+
});
|
|
449
463
|
//#endregion
|
|
450
464
|
//#region src/client.ts
|
|
451
465
|
var UnisourceError = class extends Error {
|
|
@@ -674,13 +688,13 @@ var UnisourceClient = class {
|
|
|
674
688
|
signal
|
|
675
689
|
}),
|
|
676
690
|
usage: (signal) => apiRequest(this.config, "GET", "/admin/service/usage", { signal }),
|
|
677
|
-
listUploads: (query, signal) => apiRequest(this.config, "GET", "/files", {
|
|
691
|
+
listUploads: (query, signal) => apiRequest(this.config, "GET", "/admin/files", {
|
|
678
692
|
query,
|
|
679
693
|
signal
|
|
680
694
|
}),
|
|
681
|
-
getUpload: (id, signal) => apiRequest(this.config, "GET", `/files/${id}`, { signal }),
|
|
682
|
-
downloadUploadUrl: (id, signal) => apiRequest(this.config, "GET", `/files/${id}/download-url`, { signal }),
|
|
683
|
-
deleteUpload: (id, signal) => apiRequest(this.config, "DELETE", `/files/${id}`, { signal }),
|
|
695
|
+
getUpload: (id, signal) => apiRequest(this.config, "GET", `/admin/files/${id}`, { signal }),
|
|
696
|
+
downloadUploadUrl: (id, signal) => apiRequest(this.config, "GET", `/admin/files/${id}/download-url`, { signal }),
|
|
697
|
+
deleteUpload: (id, signal) => apiRequest(this.config, "DELETE", `/admin/files/${id}`, { signal }),
|
|
684
698
|
auditLog: (query, signal) => apiRequest(this.config, "GET", "/admin/audit-log", {
|
|
685
699
|
query,
|
|
686
700
|
signal
|
|
@@ -696,6 +710,14 @@ var UnisourceClient = class {
|
|
|
696
710
|
resetUserPassword: (userId, body, signal) => apiRequest(this.config, "POST", `/admin/users/${userId}/password`, {
|
|
697
711
|
body,
|
|
698
712
|
signal
|
|
713
|
+
}),
|
|
714
|
+
updateUserRole: (userId, body, signal) => apiRequest(this.config, "PATCH", `/admin/users/${userId}/role`, {
|
|
715
|
+
body,
|
|
716
|
+
signal
|
|
717
|
+
}),
|
|
718
|
+
updateUserStorageLimit: (userId, body, signal) => apiRequest(this.config, "PATCH", `/admin/users/${userId}/storage-limit`, {
|
|
719
|
+
body,
|
|
720
|
+
signal
|
|
699
721
|
})
|
|
700
722
|
};
|
|
701
723
|
shareLinks = {
|
|
@@ -710,6 +732,39 @@ var UnisourceClient = class {
|
|
|
710
732
|
}),
|
|
711
733
|
delete: (linkId, signal) => apiRequest(this.config, "DELETE", `/share-links/${linkId}`, { signal })
|
|
712
734
|
};
|
|
735
|
+
files = {
|
|
736
|
+
get: (id, signal, options) => apiRequest(this.config, "GET", `/files/${id}`, {
|
|
737
|
+
signal,
|
|
738
|
+
extraHeaders: this.withAsUser(options)
|
|
739
|
+
}),
|
|
740
|
+
update: (id, body, signal, options) => apiRequest(this.config, "PATCH", `/files/${id}`, {
|
|
741
|
+
body,
|
|
742
|
+
signal,
|
|
743
|
+
extraHeaders: this.withAsUser(options)
|
|
744
|
+
}),
|
|
745
|
+
delete: (id, query, signal, options) => apiRequest(this.config, "DELETE", `/files/${id}`, {
|
|
746
|
+
query,
|
|
747
|
+
signal,
|
|
748
|
+
extraHeaders: this.withAsUser(options)
|
|
749
|
+
}),
|
|
750
|
+
restore: (id, signal, options) => apiRequest(this.config, "POST", `/files/${id}/restore`, {
|
|
751
|
+
signal,
|
|
752
|
+
extraHeaders: this.withAsUser(options)
|
|
753
|
+
}),
|
|
754
|
+
downloadUrl: (id, signal, options) => apiRequest(this.config, "GET", `/files/${id}/download-url`, {
|
|
755
|
+
signal,
|
|
756
|
+
extraHeaders: this.withAsUser(options)
|
|
757
|
+
})
|
|
758
|
+
};
|
|
759
|
+
shares = {
|
|
760
|
+
list: (signal) => apiRequest(this.config, "GET", "/shares", { signal }),
|
|
761
|
+
create: (body, signal) => apiRequest(this.config, "POST", "/shares", {
|
|
762
|
+
body,
|
|
763
|
+
signal
|
|
764
|
+
}),
|
|
765
|
+
get: (id, signal) => apiRequest(this.config, "GET", `/shares/${id}`, { signal }),
|
|
766
|
+
delete: (id, signal) => apiRequest(this.config, "DELETE", `/shares/${id}`, { signal })
|
|
767
|
+
};
|
|
713
768
|
};
|
|
714
769
|
//#endregion
|
|
715
|
-
export { FILES_DEFAULT_LIMIT, FILES_MAX_LIMIT, UnisourceClient, UnisourceError, UnisourceNetworkError, adminServiceUpdateRequestSchema, adminServiceUpdateResponseSchema, adminUserListResponseSchema, adminUserPasswordResetRequestSchema, adminUserPasswordResetResponseSchema, adminUserSchema, 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, nonEmptyString, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, releaseDTOSchema, releaseDeleteResponseSchema, releaseSyncManifestSchema, releaseSyncRequestSchema, releaseSyncResponseSchema, releaseSyncResultSchema, releaseUpdateRequestSchema, releaseUploadCompleteRequestSchema, releaseUploadCompleteResponseSchema, releaseUploadFailResponseSchema, releaseUploadInitRequestSchema, releaseUploadInitResponseSchema, releasesListQuerySchema, releasesListResponseSchema, serviceDetailResponseSchema, serviceSchema, serviceUsageResponseSchema, shareLinkCreateRequestSchema, shareLinkCreateResponseSchema, shareLinkDeleteResponseSchema, shareLinkListResponseSchema, shareLinkSchema, shareLinkUpdateRequestSchema, shareLinkUpdateResponseSchema, unixTimestamp, unlockPublicFile, uploadAppwriteInitRequestSchema, uploadAppwriteInitResponseSchema, uploadCompleteResponseSchema, uploadDestinationSchema, uploadFailResponseSchema, uploadLifecycleRequestSchema, uploadR2InitRequestSchema, uploadR2InitResponseSchema, uploadRecordDetailResponseSchema, uploadRecordSchema, uploadStatusSchema, uploadsListResponseSchema };
|
|
770
|
+
export { FILES_DEFAULT_LIMIT, FILES_MAX_LIMIT, UnisourceClient, UnisourceError, UnisourceNetworkError, 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, nonEmptyString, positiveInt, publicFileAccessResponseSchema, publicFileLockedResponseSchema, releaseDTOSchema, releaseDeleteResponseSchema, 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, uploadsListResponseSchema };
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -45,11 +45,15 @@ import type {
|
|
|
45
45
|
AdminUserUpdateResponse,
|
|
46
46
|
AdminUserPasswordResetRequest,
|
|
47
47
|
AdminUserPasswordResetResponse,
|
|
48
|
+
AdminUserRoleUpdateRequest,
|
|
49
|
+
AdminUserStorageLimitUpdateRequest,
|
|
48
50
|
} from './services';
|
|
49
51
|
import type {
|
|
50
52
|
ShareLinkCreateRequest,
|
|
51
53
|
ShareLinkCreateResponse,
|
|
52
54
|
ShareLinkListResponse,
|
|
55
|
+
ShareLinkDetailResponse,
|
|
56
|
+
SharesCreateRequest,
|
|
53
57
|
PublicFileAccessResponse,
|
|
54
58
|
PublicFileLockedResponse,
|
|
55
59
|
ShareLinkUpdateRequest,
|
|
@@ -411,19 +415,19 @@ export class UnisourceClient {
|
|
|
411
415
|
|
|
412
416
|
/** List all uploads (pending/completed/failed) for this service */
|
|
413
417
|
listUploads: (query?: { status?: UploadStatus; cursor?: string; limit?: number }, signal?: AbortSignal): Promise<UploadsListResponse> =>
|
|
414
|
-
apiRequest(this.config, 'GET', '/files', { query, signal }),
|
|
418
|
+
apiRequest(this.config, 'GET', '/admin/files', { query, signal }),
|
|
415
419
|
|
|
416
420
|
/** Get a single upload for this service */
|
|
417
421
|
getUpload: (id: string, signal?: AbortSignal): Promise<UploadRecordDetailResponse> =>
|
|
418
|
-
apiRequest(this.config, 'GET', `/files/${id}`, { signal }),
|
|
422
|
+
apiRequest(this.config, 'GET', `/admin/files/${id}`, { signal }),
|
|
419
423
|
|
|
420
424
|
/** Get a time-limited download URL for an upload owned by this service */
|
|
421
425
|
downloadUploadUrl: (id: string, signal?: AbortSignal): Promise<FileDownloadUrlResponse> =>
|
|
422
|
-
apiRequest(this.config, 'GET', `/files/${id}/download-url`, { signal }),
|
|
426
|
+
apiRequest(this.config, 'GET', `/admin/files/${id}/download-url`, { signal }),
|
|
423
427
|
|
|
424
428
|
/** Permanently delete an upload owned by this service */
|
|
425
429
|
deleteUpload: (id: string, signal?: AbortSignal): Promise<FileDeleteResponse> =>
|
|
426
|
-
apiRequest(this.config, 'DELETE', `/files/${id}`, { signal }),
|
|
430
|
+
apiRequest(this.config, 'DELETE', `/admin/files/${id}`, { signal }),
|
|
427
431
|
|
|
428
432
|
/** List audit log events for this service */
|
|
429
433
|
auditLog: (query?: AuditLogListQuery, signal?: AbortSignal): Promise<AuditLogListResponse> =>
|
|
@@ -450,9 +454,25 @@ export class UnisourceClient {
|
|
|
450
454
|
signal?: AbortSignal
|
|
451
455
|
): Promise<AdminUserPasswordResetResponse> =>
|
|
452
456
|
apiRequest(this.config, 'POST', `/admin/users/${userId}/password`, { body, signal }),
|
|
457
|
+
|
|
458
|
+
/** Update a user's role */
|
|
459
|
+
updateUserRole: (
|
|
460
|
+
userId: string,
|
|
461
|
+
body: AdminUserRoleUpdateRequest,
|
|
462
|
+
signal?: AbortSignal
|
|
463
|
+
): Promise<AdminUserUpdateResponse> =>
|
|
464
|
+
apiRequest(this.config, 'PATCH', `/admin/users/${userId}/role`, { body, signal }),
|
|
465
|
+
|
|
466
|
+
/** Update a user's storage limit */
|
|
467
|
+
updateUserStorageLimit: (
|
|
468
|
+
userId: string,
|
|
469
|
+
body: AdminUserStorageLimitUpdateRequest,
|
|
470
|
+
signal?: AbortSignal
|
|
471
|
+
): Promise<AdminUserUpdateResponse> =>
|
|
472
|
+
apiRequest(this.config, 'PATCH', `/admin/users/${userId}/storage-limit`, { body, signal }),
|
|
453
473
|
};
|
|
454
474
|
|
|
455
|
-
// ─── Share Links
|
|
475
|
+
// ─── Share Links (legacy — per-file endpoints) ────────────────────────────────
|
|
456
476
|
|
|
457
477
|
readonly shareLinks = {
|
|
458
478
|
/** Create a public share link for a file */
|
|
@@ -471,4 +491,48 @@ export class UnisourceClient {
|
|
|
471
491
|
delete: (linkId: string, signal?: AbortSignal): Promise<ShareLinkDeleteResponse> =>
|
|
472
492
|
apiRequest(this.config, 'DELETE', `/share-links/${linkId}`, { signal }),
|
|
473
493
|
};
|
|
494
|
+
|
|
495
|
+
// ─── Files (Plan 2 contract — /files/:id) ────────────────────────────────────
|
|
496
|
+
|
|
497
|
+
readonly files = {
|
|
498
|
+
/** Get a single file record */
|
|
499
|
+
get: (id: string, signal?: AbortSignal, options?: { asUser?: string }): Promise<FileRecordDetailResponse> =>
|
|
500
|
+
apiRequest(this.config, 'GET', `/files/${id}`, { signal, extraHeaders: this.withAsUser(options) }),
|
|
501
|
+
|
|
502
|
+
/** Rename or update a file */
|
|
503
|
+
update: (id: string, body: FileUpdateRequest, signal?: AbortSignal, options?: { asUser?: string }): Promise<FileUpdateResponse> =>
|
|
504
|
+
apiRequest(this.config, 'PATCH', `/files/${id}`, { body, signal, extraHeaders: this.withAsUser(options) }),
|
|
505
|
+
|
|
506
|
+
/** Soft-delete or permanently delete a file */
|
|
507
|
+
delete: (id: string, query?: { permanent?: boolean }, signal?: AbortSignal, options?: { asUser?: string }): Promise<FileDeleteResponse> =>
|
|
508
|
+
apiRequest(this.config, 'DELETE', `/files/${id}`, { query, signal, extraHeaders: this.withAsUser(options) }),
|
|
509
|
+
|
|
510
|
+
/** Restore a file from trash */
|
|
511
|
+
restore: (id: string, signal?: AbortSignal, options?: { asUser?: string }): Promise<FileRestoreResponse> =>
|
|
512
|
+
apiRequest(this.config, 'POST', `/files/${id}/restore`, { signal, extraHeaders: this.withAsUser(options) }),
|
|
513
|
+
|
|
514
|
+
/** Get a time-limited download URL */
|
|
515
|
+
downloadUrl: (id: string, signal?: AbortSignal, options?: { asUser?: string }): Promise<FileDownloadUrlResponse> =>
|
|
516
|
+
apiRequest(this.config, 'GET', `/files/${id}/download-url`, { signal, extraHeaders: this.withAsUser(options) }),
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// ─── Shares (Plan 2 contract — /shares) ──────────────────────────────────────
|
|
520
|
+
|
|
521
|
+
readonly shares = {
|
|
522
|
+
/** List all share links for the authenticated user */
|
|
523
|
+
list: (signal?: AbortSignal): Promise<ShareLinkListResponse> =>
|
|
524
|
+
apiRequest(this.config, 'GET', '/shares', { signal }),
|
|
525
|
+
|
|
526
|
+
/** Create a share link (file_id in body) */
|
|
527
|
+
create: (body: SharesCreateRequest, signal?: AbortSignal): Promise<ShareLinkCreateResponse> =>
|
|
528
|
+
apiRequest(this.config, 'POST', '/shares', { body, signal }),
|
|
529
|
+
|
|
530
|
+
/** Get a single share link by ID */
|
|
531
|
+
get: (id: string, signal?: AbortSignal): Promise<ShareLinkDetailResponse> =>
|
|
532
|
+
apiRequest(this.config, 'GET', `/shares/${id}`, { signal }),
|
|
533
|
+
|
|
534
|
+
/** Delete a share link */
|
|
535
|
+
delete: (id: string, signal?: AbortSignal): Promise<ShareLinkDeleteResponse> =>
|
|
536
|
+
apiRequest(this.config, 'DELETE', `/shares/${id}`, { signal }),
|
|
537
|
+
};
|
|
474
538
|
}
|
package/src/index.ts
CHANGED
|
@@ -107,6 +107,8 @@ export {
|
|
|
107
107
|
adminUserUpdateResponseSchema,
|
|
108
108
|
adminUserPasswordResetRequestSchema,
|
|
109
109
|
adminUserPasswordResetResponseSchema,
|
|
110
|
+
adminUserRoleUpdateRequestSchema,
|
|
111
|
+
adminUserStorageLimitUpdateRequestSchema,
|
|
110
112
|
} from './services';
|
|
111
113
|
export type {
|
|
112
114
|
Service,
|
|
@@ -124,6 +126,8 @@ export type {
|
|
|
124
126
|
AdminUserUpdateResponse,
|
|
125
127
|
AdminUserPasswordResetRequest,
|
|
126
128
|
AdminUserPasswordResetResponse,
|
|
129
|
+
AdminUserRoleUpdateRequest,
|
|
130
|
+
AdminUserStorageLimitUpdateRequest,
|
|
127
131
|
} from './services';
|
|
128
132
|
|
|
129
133
|
// ─── Main Storage ─────────────────────────────────────────────────────────────
|
|
@@ -172,6 +176,8 @@ export {
|
|
|
172
176
|
shareLinkCreateResponseSchema,
|
|
173
177
|
shareLinkUpdateResponseSchema,
|
|
174
178
|
shareLinkDeleteResponseSchema,
|
|
179
|
+
shareLinkDetailResponseSchema,
|
|
180
|
+
sharesCreateRequestSchema,
|
|
175
181
|
publicFileAccessResponseSchema,
|
|
176
182
|
publicFileLockedResponseSchema,
|
|
177
183
|
} from './shareLinks';
|
|
@@ -183,6 +189,8 @@ export type {
|
|
|
183
189
|
ShareLinkCreateResponse,
|
|
184
190
|
ShareLinkUpdateResponse,
|
|
185
191
|
ShareLinkDeleteResponse,
|
|
192
|
+
ShareLinkDetailResponse,
|
|
193
|
+
SharesCreateRequest,
|
|
186
194
|
PublicFileAccessResponse,
|
|
187
195
|
PublicFileLockedResponse,
|
|
188
196
|
} from './shareLinks';
|
package/src/services.ts
CHANGED
|
@@ -135,3 +135,15 @@ export const adminUserPasswordResetResponseSchema = z.object({
|
|
|
135
135
|
user_id: nonEmptyString,
|
|
136
136
|
});
|
|
137
137
|
export type AdminUserPasswordResetResponse = z.infer<typeof adminUserPasswordResetResponseSchema>;
|
|
138
|
+
|
|
139
|
+
// ─── Separate role/storage-limit update endpoints ─────────────────────────────
|
|
140
|
+
|
|
141
|
+
export const adminUserRoleUpdateRequestSchema = z.object({
|
|
142
|
+
role: z.enum(['user', 'plus', 'admin']),
|
|
143
|
+
});
|
|
144
|
+
export type AdminUserRoleUpdateRequest = z.infer<typeof adminUserRoleUpdateRequestSchema>;
|
|
145
|
+
|
|
146
|
+
export const adminUserStorageLimitUpdateRequestSchema = z.object({
|
|
147
|
+
limit_bytes: positiveInt.nullable(),
|
|
148
|
+
});
|
|
149
|
+
export type AdminUserStorageLimitUpdateRequest = z.infer<typeof adminUserStorageLimitUpdateRequestSchema>;
|
package/src/shareLinks.ts
CHANGED
|
@@ -91,3 +91,19 @@ export const shareLinkDeleteResponseSchema = z.object({
|
|
|
91
91
|
id: nonEmptyString,
|
|
92
92
|
});
|
|
93
93
|
export type ShareLinkDeleteResponse = z.infer<typeof shareLinkDeleteResponseSchema>;
|
|
94
|
+
|
|
95
|
+
// ─── Get single share link ────────────────────────────────────────────────────
|
|
96
|
+
export const shareLinkDetailResponseSchema = z.object({
|
|
97
|
+
link: shareLinkSchema,
|
|
98
|
+
});
|
|
99
|
+
export type ShareLinkDetailResponse = z.infer<typeof shareLinkDetailResponseSchema>;
|
|
100
|
+
|
|
101
|
+
// ─── Create via /shares (file_id in body) ────────────────────────────────────
|
|
102
|
+
export const sharesCreateRequestSchema = z.object({
|
|
103
|
+
file_id: nonEmptyString,
|
|
104
|
+
name: z.string().trim().max(128).optional(),
|
|
105
|
+
expires_at: positiveInt.optional(),
|
|
106
|
+
max_downloads: positiveInt.optional(),
|
|
107
|
+
password: z.string().min(1).optional(),
|
|
108
|
+
});
|
|
109
|
+
export type SharesCreateRequest = z.infer<typeof sharesCreateRequestSchema>;
|
package/src/uploads.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const uploadR2InitRequestSchema = z.object({
|
|
|
10
10
|
folder_id: nonEmptyString.optional(),
|
|
11
11
|
is_main_storage: z.boolean().optional().default(false),
|
|
12
12
|
});
|
|
13
|
-
export type UploadR2InitRequest = z.
|
|
13
|
+
export type UploadR2InitRequest = z.input<typeof uploadR2InitRequestSchema>;
|
|
14
14
|
|
|
15
15
|
export const uploadR2InitResponseSchema = z.object({
|
|
16
16
|
upload_id: nonEmptyString,
|
|
@@ -31,7 +31,7 @@ export const uploadAppwriteInitRequestSchema = z.object({
|
|
|
31
31
|
folder_id: nonEmptyString.optional(),
|
|
32
32
|
is_main_storage: z.boolean().optional().default(false),
|
|
33
33
|
});
|
|
34
|
-
export type UploadAppwriteInitRequest = z.
|
|
34
|
+
export type UploadAppwriteInitRequest = z.input<typeof uploadAppwriteInitRequestSchema>;
|
|
35
35
|
|
|
36
36
|
export const uploadAppwriteInitResponseSchema = z.object({
|
|
37
37
|
upload_id: nonEmptyString,
|
|
@@ -50,7 +50,7 @@ export const uploadLifecycleRequestSchema = z.object({
|
|
|
50
50
|
upload_id: nonEmptyString,
|
|
51
51
|
is_main_storage: z.boolean().optional().default(false),
|
|
52
52
|
});
|
|
53
|
-
export type UploadLifecycleRequest = z.
|
|
53
|
+
export type UploadLifecycleRequest = z.input<typeof uploadLifecycleRequestSchema>;
|
|
54
54
|
|
|
55
55
|
export const uploadCompleteResponseSchema = z.object({
|
|
56
56
|
success: z.literal(true),
|