@unisource/sdk 0.3.0 → 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 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.infer<typeof uploadR2InitRequestSchema>;
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.infer<typeof uploadAppwriteInitRequestSchema>;
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.infer<typeof uploadLifecycleRequestSchema>;
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;
@@ -455,6 +455,8 @@ declare const auditEventSchema: z.ZodObject<{
455
455
  resource_id: z.ZodString;
456
456
  metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
457
457
  ip_address: z.ZodNullable<z.ZodString>;
458
+ actor_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
459
+ target_user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
458
460
  created_at: z.ZodNumber;
459
461
  }, z.core.$strip>;
460
462
  type AuditEvent = z.infer<typeof auditEventSchema>;
@@ -498,6 +500,8 @@ declare const auditLogListResponseSchema: z.ZodObject<{
498
500
  resource_id: z.ZodString;
499
501
  metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
500
502
  ip_address: z.ZodNullable<z.ZodString>;
503
+ actor_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
504
+ target_user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
501
505
  created_at: z.ZodNumber;
502
506
  }, z.core.$strip>>;
503
507
  next_cursor: z.ZodNullable<z.ZodString>;
@@ -578,6 +582,18 @@ declare const adminUserPasswordResetResponseSchema: z.ZodObject<{
578
582
  user_id: z.ZodString;
579
583
  }, z.core.$strip>;
580
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>;
581
597
  //#endregion
582
598
  //#region src/mainStorage.d.ts
583
599
  declare const mainStorageListQuerySchema: z.ZodObject<{
@@ -585,6 +601,25 @@ declare const mainStorageListQuerySchema: z.ZodObject<{
585
601
  cursor: z.ZodOptional<z.ZodString>;
586
602
  }, z.core.$strip>;
587
603
  type MainStorageListQuery = z.infer<typeof mainStorageListQuerySchema>;
604
+ declare const mainStorageFileSchema: z.ZodObject<{
605
+ id: z.ZodString;
606
+ service_id: z.ZodString;
607
+ user_id: z.ZodString;
608
+ folder_id: z.ZodNullable<z.ZodString>;
609
+ upload_id: z.ZodNullable<z.ZodString>;
610
+ filename: z.ZodString;
611
+ size: z.ZodNumber;
612
+ mime_type: z.ZodString;
613
+ storage_destination: z.ZodEnum<{
614
+ appwrite: "appwrite";
615
+ r2: "r2";
616
+ }>;
617
+ is_trashed: z.ZodBoolean;
618
+ trashed_at: z.ZodNullable<z.ZodNumber>;
619
+ created_at: z.ZodNumber;
620
+ updated_at: z.ZodNumber;
621
+ }, z.core.$strip>;
622
+ type MainStorageFile = z.infer<typeof mainStorageFileSchema>;
588
623
  declare const mainStorageListResponseSchema: z.ZodObject<{
589
624
  items: z.ZodArray<z.ZodObject<{
590
625
  id: z.ZodString;
@@ -607,10 +642,50 @@ declare const mainStorageListResponseSchema: z.ZodObject<{
607
642
  next_cursor: z.ZodNullable<z.ZodString>;
608
643
  }, z.core.$strip>;
609
644
  type MainStorageListResponse = z.infer<typeof mainStorageListResponseSchema>;
645
+ declare const mainStorageDetailResponseSchema: z.ZodObject<{
646
+ id: z.ZodString;
647
+ service_id: z.ZodString;
648
+ user_id: z.ZodString;
649
+ folder_id: z.ZodNullable<z.ZodString>;
650
+ upload_id: z.ZodNullable<z.ZodString>;
651
+ filename: z.ZodString;
652
+ size: z.ZodNumber;
653
+ mime_type: z.ZodString;
654
+ storage_destination: z.ZodEnum<{
655
+ appwrite: "appwrite";
656
+ r2: "r2";
657
+ }>;
658
+ is_trashed: z.ZodBoolean;
659
+ trashed_at: z.ZodNullable<z.ZodNumber>;
660
+ created_at: z.ZodNumber;
661
+ updated_at: z.ZodNumber;
662
+ }, z.core.$strip>;
663
+ type MainStorageDetailResponse = z.infer<typeof mainStorageDetailResponseSchema>;
610
664
  declare const mainStorageRenameRequestSchema: z.ZodObject<{
611
665
  filename: z.ZodString;
612
666
  }, z.core.$strip>;
613
667
  type MainStorageRenameRequest = z.infer<typeof mainStorageRenameRequestSchema>;
668
+ declare const mainStorageRenameResponseSchema: z.ZodObject<{
669
+ file: z.ZodObject<{
670
+ id: z.ZodString;
671
+ service_id: z.ZodString;
672
+ user_id: z.ZodString;
673
+ folder_id: z.ZodNullable<z.ZodString>;
674
+ upload_id: z.ZodNullable<z.ZodString>;
675
+ filename: z.ZodString;
676
+ size: z.ZodNumber;
677
+ mime_type: z.ZodString;
678
+ storage_destination: z.ZodEnum<{
679
+ appwrite: "appwrite";
680
+ r2: "r2";
681
+ }>;
682
+ is_trashed: z.ZodBoolean;
683
+ trashed_at: z.ZodNullable<z.ZodNumber>;
684
+ created_at: z.ZodNumber;
685
+ updated_at: z.ZodNumber;
686
+ }, z.core.$strip>;
687
+ }, z.core.$strip>;
688
+ type MainStorageRenameResponse = z.infer<typeof mainStorageRenameResponseSchema>;
614
689
  declare const mainStorageDeleteResponseSchema: z.ZodObject<{
615
690
  success: z.ZodBoolean;
616
691
  file_id: z.ZodString;
@@ -869,6 +944,32 @@ declare const shareLinkDeleteResponseSchema: z.ZodObject<{
869
944
  id: z.ZodString;
870
945
  }, z.core.$strip>;
871
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>;
872
973
  //#endregion
873
974
  //#region src/client.d.ts
874
975
  declare class UnisourceError extends Error {
@@ -961,8 +1062,8 @@ declare class UnisourceClient {
961
1062
  };
962
1063
  readonly mainStorage: {
963
1064
  /** List files in the main storage pool */list: (query?: MainStorageListQuery) => Promise<MainStorageListResponse>; /** Get a single main-storage file record */
964
- get: (fileId: string) => Promise<FileRecord>; /** Rename a main-storage file */
965
- rename: (fileId: string, filename: string) => Promise<FileRecord>; /** Delete a main-storage file (soft by default; pass permanent=true for hard delete) */
1065
+ get: (fileId: string) => Promise<MainStorageDetailResponse>; /** Rename a main-storage file */
1066
+ rename: (fileId: string, filename: string) => Promise<MainStorageRenameResponse>; /** Delete a main-storage file (soft by default; pass permanent=true for hard delete) */
966
1067
  delete: (fileId: string, permanent?: boolean) => Promise<MainStorageDeleteResponse>; /** Restore a soft-deleted main-storage file */
967
1068
  restore: (fileId: string) => Promise<MainStorageRestoreResponse>;
968
1069
  upload: {
@@ -1004,7 +1105,9 @@ declare class UnisourceClient {
1004
1105
  limit?: number;
1005
1106
  }, signal?: AbortSignal) => Promise<AdminUserListResponse>; /** Update Appwrite user properties and service-specific quota/role */
1006
1107
  updateUser: (userId: string, body: AdminUserUpdateRequest, signal?: AbortSignal) => Promise<AdminUserUpdateResponse>; /** Overwrite a user's password and revoke active sessions */
1007
- 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>;
1008
1111
  };
1009
1112
  readonly shareLinks: {
1010
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 */
@@ -1012,6 +1115,31 @@ declare class UnisourceClient {
1012
1115
  update: (linkId: string, body: ShareLinkUpdateRequest, signal?: AbortSignal) => Promise<ShareLinkUpdateResponse>; /** Permanently delete a share link */
1013
1116
  delete: (linkId: string, signal?: AbortSignal) => Promise<ShareLinkDeleteResponse>;
1014
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
+ };
1015
1143
  }
1016
1144
  //#endregion
1017
- 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, MainStorageListQuery, MainStorageListResponse, MainStorageRenameRequest, 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, mainStorageListQuerySchema, mainStorageListResponseSchema, mainStorageRenameRequestSchema, 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
@@ -225,6 +225,8 @@ const auditEventSchema = z.object({
225
225
  resource_id: nonEmptyString,
226
226
  metadata: z.record(z.string(), z.unknown()).nullable(),
227
227
  ip_address: z.string().nullable(),
228
+ actor_id: z.string().nullable().optional(),
229
+ target_user_id: z.string().nullable().optional(),
228
230
  created_at: unixTimestamp
229
231
  });
230
232
  const auditLogListQuerySchema = z.object({
@@ -281,17 +283,26 @@ const adminUserPasswordResetResponseSchema = z.object({
281
283
  success: z.literal(true),
282
284
  user_id: nonEmptyString
283
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() });
284
292
  //#endregion
285
293
  //#region src/mainStorage.ts
286
294
  const mainStorageListQuerySchema = z.object({
287
- limit: z.number().int().positive().optional(),
295
+ limit: z.number().int().min(1).max(100).optional(),
288
296
  cursor: nonEmptyString.optional()
289
297
  });
298
+ const mainStorageFileSchema = fileRecordSchema;
290
299
  const mainStorageListResponseSchema = z.object({
291
- items: z.array(fileRecordSchema),
300
+ items: z.array(mainStorageFileSchema),
292
301
  next_cursor: z.string().nullable()
293
302
  });
294
- const mainStorageRenameRequestSchema = z.object({ filename: nonEmptyString });
303
+ const mainStorageDetailResponseSchema = mainStorageFileSchema;
304
+ const mainStorageRenameRequestSchema = z.object({ filename: nonEmptyString.max(255) });
305
+ const mainStorageRenameResponseSchema = z.object({ file: mainStorageFileSchema });
295
306
  const mainStorageDeleteResponseSchema = z.object({
296
307
  success: z.boolean(),
297
308
  file_id: nonEmptyString
@@ -441,6 +452,14 @@ const shareLinkDeleteResponseSchema = z.object({
441
452
  success: z.literal(true),
442
453
  id: nonEmptyString
443
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
+ });
444
463
  //#endregion
445
464
  //#region src/client.ts
446
465
  var UnisourceError = class extends Error {
@@ -613,7 +632,7 @@ var UnisourceClient = class {
613
632
  list: (query) => this.request("GET", "/main", { query }),
614
633
  get: (fileId) => this.request("GET", `/main/${fileId}`),
615
634
  rename: (fileId, filename) => this.request("PATCH", `/main/${fileId}`, { body: { filename } }),
616
- delete: (fileId, permanent = false) => this.request("DELETE", `/main/${fileId}${permanent ? "?permanent=true" : ""}`),
635
+ delete: (fileId, permanent = false) => this.request("DELETE", `/main/${fileId}`, { query: { permanent: permanent || void 0 } }),
617
636
  restore: (fileId) => this.request("POST", `/main/${fileId}/restore`),
618
637
  upload: {
619
638
  r2Init: (input) => this.request("POST", "/upload/r2/init", { body: {
@@ -669,13 +688,13 @@ var UnisourceClient = class {
669
688
  signal
670
689
  }),
671
690
  usage: (signal) => apiRequest(this.config, "GET", "/admin/service/usage", { signal }),
672
- listUploads: (query, signal) => apiRequest(this.config, "GET", "/files", {
691
+ listUploads: (query, signal) => apiRequest(this.config, "GET", "/admin/files", {
673
692
  query,
674
693
  signal
675
694
  }),
676
- getUpload: (id, signal) => apiRequest(this.config, "GET", `/files/${id}`, { signal }),
677
- downloadUploadUrl: (id, signal) => apiRequest(this.config, "GET", `/files/${id}/download-url`, { signal }),
678
- 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 }),
679
698
  auditLog: (query, signal) => apiRequest(this.config, "GET", "/admin/audit-log", {
680
699
  query,
681
700
  signal
@@ -691,6 +710,14 @@ var UnisourceClient = class {
691
710
  resetUserPassword: (userId, body, signal) => apiRequest(this.config, "POST", `/admin/users/${userId}/password`, {
692
711
  body,
693
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
694
721
  })
695
722
  };
696
723
  shareLinks = {
@@ -705,6 +732,39 @@ var UnisourceClient = class {
705
732
  }),
706
733
  delete: (linkId, signal) => apiRequest(this.config, "DELETE", `/share-links/${linkId}`, { signal })
707
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
+ };
708
768
  };
709
769
  //#endregion
710
- 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, mainStorageListQuerySchema, mainStorageListResponseSchema, mainStorageRenameRequestSchema, 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
@@ -2,7 +2,7 @@
2
2
  "name": "@unisource/sdk",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.3.0",
5
+ "version": "0.3.2",
6
6
  "description": "Wspolne kontrakty danych dla backendu i frontendu UniSource.",
7
7
  "license": "MIT",
8
8
  "publishConfig": {
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,
@@ -57,8 +61,10 @@ import type {
57
61
  ShareLinkDeleteResponse,
58
62
  } from './shareLinks';
59
63
  import type {
64
+ MainStorageDetailResponse,
60
65
  MainStorageListQuery,
61
66
  MainStorageListResponse,
67
+ MainStorageRenameResponse,
62
68
  MainStorageDeleteResponse,
63
69
  MainStorageRestoreResponse,
64
70
  } from './mainStorage';
@@ -316,16 +322,16 @@ export class UnisourceClient {
316
322
  this.request('GET', '/main', { query }),
317
323
 
318
324
  /** Get a single main-storage file record */
319
- get: (fileId: string): Promise<FileRecord> =>
325
+ get: (fileId: string): Promise<MainStorageDetailResponse> =>
320
326
  this.request('GET', `/main/${fileId}`),
321
327
 
322
328
  /** Rename a main-storage file */
323
- rename: (fileId: string, filename: string): Promise<FileRecord> =>
329
+ rename: (fileId: string, filename: string): Promise<MainStorageRenameResponse> =>
324
330
  this.request('PATCH', `/main/${fileId}`, { body: { filename } }),
325
331
 
326
332
  /** Delete a main-storage file (soft by default; pass permanent=true for hard delete) */
327
333
  delete: (fileId: string, permanent = false): Promise<MainStorageDeleteResponse> =>
328
- this.request('DELETE', `/main/${fileId}${permanent ? '?permanent=true' : ''}`),
334
+ this.request('DELETE', `/main/${fileId}`, { query: { permanent: permanent || undefined } }),
329
335
 
330
336
  /** Restore a soft-deleted main-storage file */
331
337
  restore: (fileId: string): Promise<MainStorageRestoreResponse> =>
@@ -409,19 +415,19 @@ export class UnisourceClient {
409
415
 
410
416
  /** List all uploads (pending/completed/failed) for this service */
411
417
  listUploads: (query?: { status?: UploadStatus; cursor?: string; limit?: number }, signal?: AbortSignal): Promise<UploadsListResponse> =>
412
- apiRequest(this.config, 'GET', '/files', { query, signal }),
418
+ apiRequest(this.config, 'GET', '/admin/files', { query, signal }),
413
419
 
414
420
  /** Get a single upload for this service */
415
421
  getUpload: (id: string, signal?: AbortSignal): Promise<UploadRecordDetailResponse> =>
416
- apiRequest(this.config, 'GET', `/files/${id}`, { signal }),
422
+ apiRequest(this.config, 'GET', `/admin/files/${id}`, { signal }),
417
423
 
418
424
  /** Get a time-limited download URL for an upload owned by this service */
419
425
  downloadUploadUrl: (id: string, signal?: AbortSignal): Promise<FileDownloadUrlResponse> =>
420
- apiRequest(this.config, 'GET', `/files/${id}/download-url`, { signal }),
426
+ apiRequest(this.config, 'GET', `/admin/files/${id}/download-url`, { signal }),
421
427
 
422
428
  /** Permanently delete an upload owned by this service */
423
429
  deleteUpload: (id: string, signal?: AbortSignal): Promise<FileDeleteResponse> =>
424
- apiRequest(this.config, 'DELETE', `/files/${id}`, { signal }),
430
+ apiRequest(this.config, 'DELETE', `/admin/files/${id}`, { signal }),
425
431
 
426
432
  /** List audit log events for this service */
427
433
  auditLog: (query?: AuditLogListQuery, signal?: AbortSignal): Promise<AuditLogListResponse> =>
@@ -448,9 +454,25 @@ export class UnisourceClient {
448
454
  signal?: AbortSignal
449
455
  ): Promise<AdminUserPasswordResetResponse> =>
450
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 }),
451
473
  };
452
474
 
453
- // ─── Share Links ──────────────────────────────────────────────────────────────
475
+ // ─── Share Links (legacy — per-file endpoints) ────────────────────────────────
454
476
 
455
477
  readonly shareLinks = {
456
478
  /** Create a public share link for a file */
@@ -469,4 +491,48 @@ export class UnisourceClient {
469
491
  delete: (linkId: string, signal?: AbortSignal): Promise<ShareLinkDeleteResponse> =>
470
492
  apiRequest(this.config, 'DELETE', `/share-links/${linkId}`, { signal }),
471
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
+ };
472
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';
@@ -1,28 +1,39 @@
1
1
  import { z } from 'zod';
2
- import { nonEmptyString } from './primitives';
2
+ import { FILES_MAX_LIMIT, nonEmptyString } from './primitives';
3
3
  import { fileRecordSchema } from './fileRecords';
4
4
 
5
5
  // ─── List ──────────────────────────────────────────────────────────────────────
6
6
 
7
7
  export const mainStorageListQuerySchema = z.object({
8
- limit: z.number().int().positive().optional(),
8
+ limit: z.number().int().min(1).max(FILES_MAX_LIMIT).optional(),
9
9
  cursor: nonEmptyString.optional(),
10
10
  });
11
11
  export type MainStorageListQuery = z.infer<typeof mainStorageListQuerySchema>;
12
12
 
13
+ export const mainStorageFileSchema = fileRecordSchema;
14
+ export type MainStorageFile = z.infer<typeof mainStorageFileSchema>;
15
+
13
16
  export const mainStorageListResponseSchema = z.object({
14
- items: z.array(fileRecordSchema),
17
+ items: z.array(mainStorageFileSchema),
15
18
  next_cursor: z.string().nullable(),
16
19
  });
17
20
  export type MainStorageListResponse = z.infer<typeof mainStorageListResponseSchema>;
18
21
 
22
+ export const mainStorageDetailResponseSchema = mainStorageFileSchema;
23
+ export type MainStorageDetailResponse = z.infer<typeof mainStorageDetailResponseSchema>;
24
+
19
25
  // ─── Rename ────────────────────────────────────────────────────────────────────
20
26
 
21
27
  export const mainStorageRenameRequestSchema = z.object({
22
- filename: nonEmptyString,
28
+ filename: nonEmptyString.max(255),
23
29
  });
24
30
  export type MainStorageRenameRequest = z.infer<typeof mainStorageRenameRequestSchema>;
25
31
 
32
+ export const mainStorageRenameResponseSchema = z.object({
33
+ file: mainStorageFileSchema,
34
+ });
35
+ export type MainStorageRenameResponse = z.infer<typeof mainStorageRenameResponseSchema>;
36
+
26
37
  // ─── Delete ────────────────────────────────────────────────────────────────────
27
38
 
28
39
  export const mainStorageDeleteResponseSchema = z.object({
package/src/services.ts CHANGED
@@ -64,6 +64,8 @@ export const auditEventSchema = z.object({
64
64
  resource_id: nonEmptyString,
65
65
  metadata: z.record(z.string(), z.unknown()).nullable(),
66
66
  ip_address: z.string().nullable(),
67
+ actor_id: z.string().nullable().optional(),
68
+ target_user_id: z.string().nullable().optional(),
67
69
  created_at: unixTimestamp,
68
70
  });
69
71
  export type AuditEvent = z.infer<typeof auditEventSchema>;
@@ -133,3 +135,15 @@ export const adminUserPasswordResetResponseSchema = z.object({
133
135
  user_id: nonEmptyString,
134
136
  });
135
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.infer<typeof uploadR2InitRequestSchema>;
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.infer<typeof uploadAppwriteInitRequestSchema>;
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.infer<typeof uploadLifecycleRequestSchema>;
53
+ export type UploadLifecycleRequest = z.input<typeof uploadLifecycleRequestSchema>;
54
54
 
55
55
  export const uploadCompleteResponseSchema = z.object({
56
56
  success: z.literal(true),