@unisource/sdk 0.7.0 → 1.0.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/README.md +56 -23
- package/dist/index.d.mts +115 -1
- package/dist/index.mjs +92 -1
- package/package.json +6 -1
- package/src/client.ts +54 -0
- package/src/index.ts +22 -0
- package/src/v2.ts +69 -0
package/README.md
CHANGED
|
@@ -1,55 +1,88 @@
|
|
|
1
1
|
# @unisource/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Główne, współdzielone biblioteki oraz klient HTTP (SDK) wykorzystywane zarówno przez aplikację `frontend`, jak i `backend` (w ramach repozytorium UniSource).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Zawartość pakietu
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- `UnisourceClient` for authenticated app and admin API calls
|
|
9
|
-
- Standalone public share helpers: `getPublicFileInfo()` and `unlockPublicFile()`
|
|
10
|
-
- Typed error classes: `UnisourceError` and `UnisourceNetworkError`
|
|
7
|
+
SDK zapewnia pojedyncze źródło prawdy dla kontraktów API i upraszcza komunikację z backendem. Zawiera m.in.:
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
- **Zod Schemas & TypeScript Types**: Pełne definicje typów dla wszystkich encji w systemie: Pliki, Foldery, Udostępnienia (Share Links), Upload (w tym Multipart), Magazyn (Main Storage), Usługi (Services), Role Użytkowników oraz Audyty (Audit Logs).
|
|
10
|
+
- **UnisourceClient**: Silnie typowany klient HTTP służący do bezpiecznej komunikacji z API z uwzględnieniem identyfikacji usługi (`X-Service-ID`) oraz autoryzacji (JWT/API Key).
|
|
11
|
+
- **Publiczne Helpery**: Samodzielne metody do obsługi udostępnionych, publicznych linków (bez wymagania logowania) takie jak `getPublicFileInfo()` czy `unlockPublicFile()`.
|
|
12
|
+
- **Obsługa Błędów**: Precyzyjne klasy błędów `UnisourceError` oraz `UnisourceNetworkError`.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## Użycie (Usage)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
pnpm install
|
|
18
|
-
pnpm --filter @unisource/sdk build
|
|
19
|
-
pnpm --filter @unisource/sdk test
|
|
20
|
-
pnpm --filter @unisource/sdk typecheck
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
16
|
+
Przykład konfiguracji i pobrania listy plików przypisanych do użytkownika przy wykorzystaniu instancji klienta:
|
|
24
17
|
|
|
25
18
|
```ts
|
|
26
19
|
import { UnisourceClient } from '@unisource/sdk';
|
|
27
20
|
|
|
21
|
+
// 1. Konfiguracja klienta
|
|
28
22
|
const client = new UnisourceClient({
|
|
29
|
-
baseUrl: 'https://api.
|
|
23
|
+
baseUrl: 'https://api.usrc.dev',
|
|
30
24
|
serviceId: 'usrc',
|
|
31
|
-
getToken: async () => 'jwt-
|
|
25
|
+
getToken: async () => 'twoj-token-jwt-lub-api-key', // Zwróć null dla zapytań publicznych
|
|
32
26
|
});
|
|
33
27
|
|
|
28
|
+
// 2. Zapytanie API (np. lista plików z paginacją)
|
|
34
29
|
const files = await client.myFiles.list({ folder_id: null, limit: 25 });
|
|
35
30
|
```
|
|
36
31
|
|
|
37
|
-
|
|
32
|
+
### Obsługa udostępnień publicznych
|
|
33
|
+
Zapytania o zasoby publiczne nie wymagają pełnej inicjalizacji klienta i posiadają dedykowane, lekkie metody:
|
|
38
34
|
|
|
39
35
|
```ts
|
|
40
36
|
import { getPublicFileInfo, unlockPublicFile } from '@unisource/sdk';
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
const
|
|
38
|
+
// Pobranie metadanych udostępnionego pliku na podstawie slug'a
|
|
39
|
+
const info = await getPublicFileInfo('https://api.usrc.dev', 'moj-unikalny-slug');
|
|
40
|
+
|
|
41
|
+
// Odblokowanie dostępu do pliku chronionego hasłem
|
|
42
|
+
const unlocked = await unlockPublicFile('https://api.usrc.dev', 'moj-unikalny-slug', 'tajne-haslo123');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Rozwój lokalny (Development)
|
|
46
|
+
|
|
47
|
+
W ramach monorepo (narzędzie pnpm):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Instalacja wszystkich zależności (w roocie)
|
|
51
|
+
pnpm install
|
|
52
|
+
|
|
53
|
+
# Kompilacja SDK
|
|
54
|
+
pnpm --filter @unisource/sdk build
|
|
55
|
+
|
|
56
|
+
# Sprawdzanie typów
|
|
57
|
+
pnpm --filter @unisource/sdk typecheck
|
|
58
|
+
|
|
59
|
+
# Uruchomienie testów
|
|
60
|
+
pnpm --filter @unisource/sdk test
|
|
44
61
|
```
|
|
45
62
|
|
|
46
|
-
|
|
63
|
+
Pakiet może być linkowany lokalnie w ramach workspace, wystarczy w innym projekcie monorepo dodać zależność:
|
|
64
|
+
`"@unisource/sdk": "workspace:*"`
|
|
47
65
|
|
|
48
|
-
|
|
66
|
+
## Wydawanie nowej wersji (Release Workflow)
|
|
67
|
+
|
|
68
|
+
Pakiet `@unisource/sdk` jest pakietem publicznym na rejestrze NPM i korzysta z narzędzia [Changesets](https://github.com/changesets/changesets) do zarządzania wersjami.
|
|
69
|
+
|
|
70
|
+
Aby opublikować nową wersję, wykonaj poniższe kroki z głównego katalogu (root) monorepo:
|
|
49
71
|
|
|
50
72
|
```bash
|
|
73
|
+
# 1. Dodaj plik z opisem zmian (wybierz paczkę, typ bumpa i napisz komentarz)
|
|
51
74
|
pnpm changeset
|
|
75
|
+
|
|
76
|
+
# 2. Zatwierdź nową wersję na podstawie plików changeset (aktualizacja package.json oraz CHANGELOG.md)
|
|
52
77
|
pnpm changeset version
|
|
78
|
+
|
|
79
|
+
# 3. Zbuduj SDK by upewnić się, że kod wynikowy jest poprawny
|
|
53
80
|
pnpm --filter @unisource/sdk build
|
|
81
|
+
|
|
82
|
+
# 4. Sprawdź przed publikacją
|
|
83
|
+
pnpm --filter @unisource/sdk publish --dry-run --access public --no-git-checks
|
|
84
|
+
|
|
85
|
+
# 5. Opublikuj na rejestr NPM
|
|
54
86
|
pnpm changeset publish
|
|
55
87
|
```
|
|
88
|
+
Pamiętaj o dodaniu nowo powstałych tagów i commitów do głównego repozytorium po opublikowaniu paczki.
|
package/dist/index.d.mts
CHANGED
|
@@ -1209,6 +1209,87 @@ declare const sharesCreateRequestSchema: z.ZodObject<{
|
|
|
1209
1209
|
}, z.core.$strip>;
|
|
1210
1210
|
type SharesCreateRequest = z.infer<typeof sharesCreateRequestSchema>;
|
|
1211
1211
|
//#endregion
|
|
1212
|
+
//#region src/v2.d.ts
|
|
1213
|
+
declare const fileRecordsListV2QuerySchema: z.ZodObject<{
|
|
1214
|
+
folder_id: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null | undefined, string | null | undefined>>;
|
|
1215
|
+
is_trashed: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
1216
|
+
false: "false";
|
|
1217
|
+
true: "true";
|
|
1218
|
+
}>, z.ZodTransform<boolean, "false" | "true">>>;
|
|
1219
|
+
search: z.ZodOptional<z.ZodString>;
|
|
1220
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
1221
|
+
sort_by: z.ZodOptional<z.ZodEnum<{
|
|
1222
|
+
created_at: "created_at";
|
|
1223
|
+
name: "name";
|
|
1224
|
+
size: "size";
|
|
1225
|
+
}>>;
|
|
1226
|
+
sort_dir: z.ZodOptional<z.ZodEnum<{
|
|
1227
|
+
asc: "asc";
|
|
1228
|
+
desc: "desc";
|
|
1229
|
+
}>>;
|
|
1230
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1231
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
1232
|
+
}, z.core.$strip>;
|
|
1233
|
+
type FileRecordsListV2Query = z.infer<typeof fileRecordsListV2QuerySchema>;
|
|
1234
|
+
declare const bulkFileIdsSchema: z.ZodObject<{
|
|
1235
|
+
ids: z.ZodArray<z.ZodString>;
|
|
1236
|
+
}, z.core.$strip>;
|
|
1237
|
+
type BulkFileIds = z.infer<typeof bulkFileIdsSchema>;
|
|
1238
|
+
declare const bulkFileMoveRequestSchema: z.ZodObject<{
|
|
1239
|
+
ids: z.ZodArray<z.ZodString>;
|
|
1240
|
+
folder_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1241
|
+
}, z.core.$strip>;
|
|
1242
|
+
type BulkFileMoveRequest = z.infer<typeof bulkFileMoveRequestSchema>;
|
|
1243
|
+
declare const bulkOperationResponseSchema: z.ZodObject<{
|
|
1244
|
+
success: z.ZodBoolean;
|
|
1245
|
+
processed_count: z.ZodNumber;
|
|
1246
|
+
failed_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1247
|
+
}, z.core.$strip>;
|
|
1248
|
+
type BulkOperationResponse = z.infer<typeof bulkOperationResponseSchema>;
|
|
1249
|
+
declare const folderListV2QuerySchema: z.ZodObject<{
|
|
1250
|
+
parent_id: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null | undefined, string | null | undefined>>;
|
|
1251
|
+
is_trashed: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
1252
|
+
false: "false";
|
|
1253
|
+
true: "true";
|
|
1254
|
+
}>, z.ZodTransform<boolean, "false" | "true">>>;
|
|
1255
|
+
search: z.ZodOptional<z.ZodString>;
|
|
1256
|
+
sort_by: z.ZodOptional<z.ZodEnum<{
|
|
1257
|
+
created_at: "created_at";
|
|
1258
|
+
name: "name";
|
|
1259
|
+
}>>;
|
|
1260
|
+
sort_dir: z.ZodOptional<z.ZodEnum<{
|
|
1261
|
+
asc: "asc";
|
|
1262
|
+
desc: "desc";
|
|
1263
|
+
}>>;
|
|
1264
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1265
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
1266
|
+
}, z.core.$strip>;
|
|
1267
|
+
type FolderListV2Query = z.infer<typeof folderListV2QuerySchema>;
|
|
1268
|
+
declare const bulkFolderIdsSchema: z.ZodObject<{
|
|
1269
|
+
ids: z.ZodArray<z.ZodString>;
|
|
1270
|
+
}, z.core.$strip>;
|
|
1271
|
+
type BulkFolderIds = z.infer<typeof bulkFolderIdsSchema>;
|
|
1272
|
+
declare const bulkFolderMoveRequestSchema: z.ZodObject<{
|
|
1273
|
+
ids: z.ZodArray<z.ZodString>;
|
|
1274
|
+
parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1275
|
+
}, z.core.$strip>;
|
|
1276
|
+
type BulkFolderMoveRequest = z.infer<typeof bulkFolderMoveRequestSchema>;
|
|
1277
|
+
declare const folderBreadcrumbsResponseSchema: z.ZodObject<{
|
|
1278
|
+
breadcrumbs: z.ZodArray<z.ZodObject<{
|
|
1279
|
+
id: z.ZodString;
|
|
1280
|
+
service_id: z.ZodString;
|
|
1281
|
+
user_id: z.ZodString;
|
|
1282
|
+
parent_id: z.ZodNullable<z.ZodString>;
|
|
1283
|
+
name: z.ZodString;
|
|
1284
|
+
color_tag: z.ZodNullable<z.ZodString>;
|
|
1285
|
+
is_trashed: z.ZodBoolean;
|
|
1286
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
1287
|
+
created_at: z.ZodNumber;
|
|
1288
|
+
updated_at: z.ZodNumber;
|
|
1289
|
+
}, z.core.$strip>>;
|
|
1290
|
+
}, z.core.$strip>;
|
|
1291
|
+
type FolderBreadcrumbsResponse = z.infer<typeof folderBreadcrumbsResponseSchema>;
|
|
1292
|
+
//#endregion
|
|
1212
1293
|
//#region src/client.d.ts
|
|
1213
1294
|
declare class UnisourceError extends Error {
|
|
1214
1295
|
readonly status: number;
|
|
@@ -1394,6 +1475,39 @@ declare class UnisourceClient {
|
|
|
1394
1475
|
get: (id: string, signal?: AbortSignal) => Promise<ShareLinkDetailResponse>; /** Delete a share link */
|
|
1395
1476
|
delete: (id: string, signal?: AbortSignal) => Promise<ShareLinkDeleteResponse>;
|
|
1396
1477
|
};
|
|
1478
|
+
readonly v2: {
|
|
1479
|
+
files: {
|
|
1480
|
+
/** List files with advanced search, sorting, and filtering capabilities */list: (query?: FileRecordsListV2Query, signal?: AbortSignal, options?: {
|
|
1481
|
+
asUser?: string;
|
|
1482
|
+
}) => Promise<FileRecordsListResponse>; /** Move multiple files at once */
|
|
1483
|
+
bulkMove: (body: BulkFileMoveRequest, signal?: AbortSignal, options?: {
|
|
1484
|
+
asUser?: string;
|
|
1485
|
+
}) => Promise<BulkOperationResponse>; /** Move multiple files to trash */
|
|
1486
|
+
bulkTrash: (body: BulkFileIds, signal?: AbortSignal, options?: {
|
|
1487
|
+
asUser?: string;
|
|
1488
|
+
}) => Promise<BulkOperationResponse>; /** Restore multiple files from trash */
|
|
1489
|
+
bulkRestore: (body: BulkFileIds, signal?: AbortSignal, options?: {
|
|
1490
|
+
asUser?: string;
|
|
1491
|
+
}) => Promise<BulkOperationResponse>;
|
|
1492
|
+
};
|
|
1493
|
+
folders: {
|
|
1494
|
+
/** List folders with advanced search, sorting, and filtering capabilities */list: (query?: FolderListV2Query, signal?: AbortSignal, options?: {
|
|
1495
|
+
asUser?: string;
|
|
1496
|
+
}) => Promise<FolderListResponse>; /** Get the breadcrumb hierarchy for a specific folder */
|
|
1497
|
+
breadcrumbs: (id: string, signal?: AbortSignal, options?: {
|
|
1498
|
+
asUser?: string;
|
|
1499
|
+
}) => Promise<FolderBreadcrumbsResponse>; /** Move multiple folders at once */
|
|
1500
|
+
bulkMove: (body: BulkFolderMoveRequest, signal?: AbortSignal, options?: {
|
|
1501
|
+
asUser?: string;
|
|
1502
|
+
}) => Promise<BulkOperationResponse>; /** Move multiple folders to trash */
|
|
1503
|
+
bulkTrash: (body: BulkFolderIds, signal?: AbortSignal, options?: {
|
|
1504
|
+
asUser?: string;
|
|
1505
|
+
}) => Promise<BulkOperationResponse>; /** Restore multiple folders from trash */
|
|
1506
|
+
bulkRestore: (body: BulkFolderIds, signal?: AbortSignal, options?: {
|
|
1507
|
+
asUser?: string;
|
|
1508
|
+
}) => Promise<BulkOperationResponse>;
|
|
1509
|
+
};
|
|
1510
|
+
};
|
|
1397
1511
|
readonly app: {
|
|
1398
1512
|
releases: {
|
|
1399
1513
|
/**
|
|
@@ -1406,4 +1520,4 @@ declare class UnisourceClient {
|
|
|
1406
1520
|
};
|
|
1407
1521
|
}
|
|
1408
1522
|
//#endregion
|
|
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 };
|
|
1523
|
+
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, type BulkFileIds, type BulkFileMoveRequest, type BulkFolderIds, type BulkFolderMoveRequest, type BulkOperationResponse, FILES_DEFAULT_LIMIT, FILES_MAX_LIMIT, type FileDeleteResponse, type FileDownloadUrlResponse, type FileMoveRequest, type FileRecord, type FileRecordDetailResponse, type FileRecordsListQuery, type FileRecordsListResponse, type FileRecordsListV2Query, type FileRestoreResponse, type FileUpdateRequest, type FileUpdateResponse, type Folder, type FolderBreadcrumbsResponse, type FolderCreateRequest, type FolderCreateResponse, type FolderDeleteResponse, type FolderDetailResponse, type FolderListQuery, type FolderListResponse, type FolderListV2Query, 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, bulkFileIdsSchema, bulkFileMoveRequestSchema, bulkFolderIdsSchema, bulkFolderMoveRequestSchema, bulkOperationResponseSchema, fileDeleteResponseSchema, fileDownloadUrlResponseSchema, fileMoveRequestSchema, fileRecordDetailResponseSchema, fileRecordSchema, fileRecordsListQuerySchema, fileRecordsListResponseSchema, fileRecordsListV2QuerySchema, fileRestoreResponseSchema, fileUpdateRequestSchema, fileUpdateResponseSchema, folderBreadcrumbsResponseSchema, folderCreateRequestSchema, folderCreateResponseSchema, folderDeleteResponseSchema, folderDetailResponseSchema, folderListQuerySchema, folderListResponseSchema, folderListV2QuerySchema, 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
|
@@ -943,10 +943,101 @@ var UnisourceClient = class {
|
|
|
943
943
|
get: (id, signal) => apiRequest(this.config, "GET", `/shares/${id}`, { signal }),
|
|
944
944
|
delete: (id, signal) => apiRequest(this.config, "DELETE", `/shares/${id}`, { signal })
|
|
945
945
|
};
|
|
946
|
+
v2 = {
|
|
947
|
+
files: {
|
|
948
|
+
list: (query, signal, options) => apiRequest(this.config, "GET", "/v2/files", {
|
|
949
|
+
query,
|
|
950
|
+
signal,
|
|
951
|
+
extraHeaders: this.withAsUser(options)
|
|
952
|
+
}),
|
|
953
|
+
bulkMove: (body, signal, options) => apiRequest(this.config, "POST", "/v2/files/bulk-move", {
|
|
954
|
+
body,
|
|
955
|
+
signal,
|
|
956
|
+
extraHeaders: this.withAsUser(options)
|
|
957
|
+
}),
|
|
958
|
+
bulkTrash: (body, signal, options) => apiRequest(this.config, "POST", "/v2/files/bulk-trash", {
|
|
959
|
+
body,
|
|
960
|
+
signal,
|
|
961
|
+
extraHeaders: this.withAsUser(options)
|
|
962
|
+
}),
|
|
963
|
+
bulkRestore: (body, signal, options) => apiRequest(this.config, "POST", "/v2/files/bulk-restore", {
|
|
964
|
+
body,
|
|
965
|
+
signal,
|
|
966
|
+
extraHeaders: this.withAsUser(options)
|
|
967
|
+
})
|
|
968
|
+
},
|
|
969
|
+
folders: {
|
|
970
|
+
list: (query, signal, options) => apiRequest(this.config, "GET", "/v2/folders", {
|
|
971
|
+
query,
|
|
972
|
+
signal,
|
|
973
|
+
extraHeaders: this.withAsUser(options)
|
|
974
|
+
}),
|
|
975
|
+
breadcrumbs: (id, signal, options) => apiRequest(this.config, "GET", `/v2/folders/${id}/breadcrumbs`, {
|
|
976
|
+
signal,
|
|
977
|
+
extraHeaders: this.withAsUser(options)
|
|
978
|
+
}),
|
|
979
|
+
bulkMove: (body, signal, options) => apiRequest(this.config, "POST", "/v2/folders/bulk-move", {
|
|
980
|
+
body,
|
|
981
|
+
signal,
|
|
982
|
+
extraHeaders: this.withAsUser(options)
|
|
983
|
+
}),
|
|
984
|
+
bulkTrash: (body, signal, options) => apiRequest(this.config, "POST", "/v2/folders/bulk-trash", {
|
|
985
|
+
body,
|
|
986
|
+
signal,
|
|
987
|
+
extraHeaders: this.withAsUser(options)
|
|
988
|
+
}),
|
|
989
|
+
bulkRestore: (body, signal, options) => apiRequest(this.config, "POST", "/v2/folders/bulk-restore", {
|
|
990
|
+
body,
|
|
991
|
+
signal,
|
|
992
|
+
extraHeaders: this.withAsUser(options)
|
|
993
|
+
})
|
|
994
|
+
}
|
|
995
|
+
};
|
|
946
996
|
app = { releases: { latest: (channel = "stable", signal) => apiRequest(this.config, "GET", "/app/releases/latest", {
|
|
947
997
|
query: { channel },
|
|
948
998
|
signal
|
|
949
999
|
}) } };
|
|
950
1000
|
};
|
|
951
1001
|
//#endregion
|
|
952
|
-
|
|
1002
|
+
//#region src/v2.ts
|
|
1003
|
+
const fileRecordsListV2QuerySchema = z.object({
|
|
1004
|
+
folder_id: nonEmptyString.nullable().optional().transform((v) => v === "null" ? null : v),
|
|
1005
|
+
is_trashed: z.enum(["true", "false"]).transform((v) => v === "true").optional(),
|
|
1006
|
+
search: z.string().optional(),
|
|
1007
|
+
mime_type: z.string().optional(),
|
|
1008
|
+
sort_by: z.enum([
|
|
1009
|
+
"created_at",
|
|
1010
|
+
"name",
|
|
1011
|
+
"size"
|
|
1012
|
+
]).optional(),
|
|
1013
|
+
sort_dir: z.enum(["asc", "desc"]).optional(),
|
|
1014
|
+
cursor: nonEmptyString.optional(),
|
|
1015
|
+
limit: z.coerce.number().int().min(1).max(100).optional()
|
|
1016
|
+
});
|
|
1017
|
+
const bulkFileIdsSchema = z.object({ ids: z.array(nonEmptyString).min(1).max(100) });
|
|
1018
|
+
const bulkFileMoveRequestSchema = z.object({
|
|
1019
|
+
ids: z.array(nonEmptyString).min(1).max(100),
|
|
1020
|
+
folder_id: nonEmptyString.nullable().optional()
|
|
1021
|
+
});
|
|
1022
|
+
const bulkOperationResponseSchema = z.object({
|
|
1023
|
+
success: z.boolean(),
|
|
1024
|
+
processed_count: z.number().int().nonnegative(),
|
|
1025
|
+
failed_ids: z.array(nonEmptyString).optional()
|
|
1026
|
+
});
|
|
1027
|
+
const folderListV2QuerySchema = z.object({
|
|
1028
|
+
parent_id: nonEmptyString.nullable().optional().transform((v) => v === "null" ? null : v),
|
|
1029
|
+
is_trashed: z.enum(["true", "false"]).transform((v) => v === "true").optional(),
|
|
1030
|
+
search: z.string().optional(),
|
|
1031
|
+
sort_by: z.enum(["created_at", "name"]).optional(),
|
|
1032
|
+
sort_dir: z.enum(["asc", "desc"]).optional(),
|
|
1033
|
+
cursor: nonEmptyString.optional(),
|
|
1034
|
+
limit: z.coerce.number().int().min(1).max(100).optional()
|
|
1035
|
+
});
|
|
1036
|
+
const bulkFolderIdsSchema = z.object({ ids: z.array(nonEmptyString).min(1).max(100) });
|
|
1037
|
+
const bulkFolderMoveRequestSchema = z.object({
|
|
1038
|
+
ids: z.array(nonEmptyString).min(1).max(100),
|
|
1039
|
+
parent_id: nonEmptyString.nullable().optional()
|
|
1040
|
+
});
|
|
1041
|
+
const folderBreadcrumbsResponseSchema = z.object({ breadcrumbs: z.array(folderSchema) });
|
|
1042
|
+
//#endregion
|
|
1043
|
+
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, bulkFileIdsSchema, bulkFileMoveRequestSchema, bulkFolderIdsSchema, bulkFolderMoveRequestSchema, bulkOperationResponseSchema, fileDeleteResponseSchema, fileDownloadUrlResponseSchema, fileMoveRequestSchema, fileRecordDetailResponseSchema, fileRecordSchema, fileRecordsListQuerySchema, fileRecordsListResponseSchema, fileRecordsListV2QuerySchema, fileRestoreResponseSchema, fileUpdateRequestSchema, fileUpdateResponseSchema, folderBreadcrumbsResponseSchema, folderCreateRequestSchema, folderCreateResponseSchema, folderDeleteResponseSchema, folderDetailResponseSchema, folderListQuerySchema, folderListResponseSchema, folderListV2QuerySchema, 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
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
"name": "@unisource/sdk",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "1.0.0",
|
|
6
6
|
"description": "Wspolne kontrakty danych dla backendu i frontendu UniSource.",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Dan1el-19/UniSource.git",
|
|
11
|
+
"directory": "packages/unisource-sdk"
|
|
12
|
+
},
|
|
8
13
|
"publishConfig": {
|
|
9
14
|
"access": "public"
|
|
10
15
|
},
|
package/src/client.ts
CHANGED
|
@@ -40,6 +40,16 @@ import type {
|
|
|
40
40
|
FolderDeleteResponse,
|
|
41
41
|
FolderRestoreResponse,
|
|
42
42
|
} from './folders';
|
|
43
|
+
import type {
|
|
44
|
+
FileRecordsListV2Query,
|
|
45
|
+
FolderListV2Query,
|
|
46
|
+
BulkFileIds,
|
|
47
|
+
BulkFileMoveRequest,
|
|
48
|
+
BulkFolderIds,
|
|
49
|
+
BulkFolderMoveRequest,
|
|
50
|
+
BulkOperationResponse,
|
|
51
|
+
FolderBreadcrumbsResponse,
|
|
52
|
+
} from './v2';
|
|
43
53
|
import type {
|
|
44
54
|
ServiceDetailResponse,
|
|
45
55
|
ServiceUsageResponse,
|
|
@@ -627,6 +637,50 @@ export class UnisourceClient {
|
|
|
627
637
|
apiRequest(this.config, 'DELETE', `/shares/${id}`, { signal }),
|
|
628
638
|
};
|
|
629
639
|
|
|
640
|
+
// ─── V2 API Endpoints ───────────────────────────────────────────────────────
|
|
641
|
+
|
|
642
|
+
readonly v2 = {
|
|
643
|
+
files: {
|
|
644
|
+
/** List files with advanced search, sorting, and filtering capabilities */
|
|
645
|
+
list: (query?: FileRecordsListV2Query, signal?: AbortSignal, options?: { asUser?: string }): Promise<FileRecordsListResponse> =>
|
|
646
|
+
apiRequest(this.config, 'GET', '/v2/files', { query, signal, extraHeaders: this.withAsUser(options) }),
|
|
647
|
+
|
|
648
|
+
/** Move multiple files at once */
|
|
649
|
+
bulkMove: (body: BulkFileMoveRequest, signal?: AbortSignal, options?: { asUser?: string }): Promise<BulkOperationResponse> =>
|
|
650
|
+
apiRequest(this.config, 'POST', '/v2/files/bulk-move', { body, signal, extraHeaders: this.withAsUser(options) }),
|
|
651
|
+
|
|
652
|
+
/** Move multiple files to trash */
|
|
653
|
+
bulkTrash: (body: BulkFileIds, signal?: AbortSignal, options?: { asUser?: string }): Promise<BulkOperationResponse> =>
|
|
654
|
+
apiRequest(this.config, 'POST', '/v2/files/bulk-trash', { body, signal, extraHeaders: this.withAsUser(options) }),
|
|
655
|
+
|
|
656
|
+
/** Restore multiple files from trash */
|
|
657
|
+
bulkRestore: (body: BulkFileIds, signal?: AbortSignal, options?: { asUser?: string }): Promise<BulkOperationResponse> =>
|
|
658
|
+
apiRequest(this.config, 'POST', '/v2/files/bulk-restore', { body, signal, extraHeaders: this.withAsUser(options) }),
|
|
659
|
+
},
|
|
660
|
+
|
|
661
|
+
folders: {
|
|
662
|
+
/** List folders with advanced search, sorting, and filtering capabilities */
|
|
663
|
+
list: (query?: FolderListV2Query, signal?: AbortSignal, options?: { asUser?: string }): Promise<FolderListResponse> =>
|
|
664
|
+
apiRequest(this.config, 'GET', '/v2/folders', { query, signal, extraHeaders: this.withAsUser(options) }),
|
|
665
|
+
|
|
666
|
+
/** Get the breadcrumb hierarchy for a specific folder */
|
|
667
|
+
breadcrumbs: (id: string, signal?: AbortSignal, options?: { asUser?: string }): Promise<FolderBreadcrumbsResponse> =>
|
|
668
|
+
apiRequest(this.config, 'GET', `/v2/folders/${id}/breadcrumbs`, { signal, extraHeaders: this.withAsUser(options) }),
|
|
669
|
+
|
|
670
|
+
/** Move multiple folders at once */
|
|
671
|
+
bulkMove: (body: BulkFolderMoveRequest, signal?: AbortSignal, options?: { asUser?: string }): Promise<BulkOperationResponse> =>
|
|
672
|
+
apiRequest(this.config, 'POST', '/v2/folders/bulk-move', { body, signal, extraHeaders: this.withAsUser(options) }),
|
|
673
|
+
|
|
674
|
+
/** Move multiple folders to trash */
|
|
675
|
+
bulkTrash: (body: BulkFolderIds, signal?: AbortSignal, options?: { asUser?: string }): Promise<BulkOperationResponse> =>
|
|
676
|
+
apiRequest(this.config, 'POST', '/v2/folders/bulk-trash', { body, signal, extraHeaders: this.withAsUser(options) }),
|
|
677
|
+
|
|
678
|
+
/** Restore multiple folders from trash */
|
|
679
|
+
bulkRestore: (body: BulkFolderIds, signal?: AbortSignal, options?: { asUser?: string }): Promise<BulkOperationResponse> =>
|
|
680
|
+
apiRequest(this.config, 'POST', '/v2/folders/bulk-restore', { body, signal, extraHeaders: this.withAsUser(options) }),
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
|
|
630
684
|
// ─── App-facing endpoints (/app/*) — public release distribution ──────────────
|
|
631
685
|
|
|
632
686
|
readonly app = {
|
package/src/index.ts
CHANGED
|
@@ -265,3 +265,25 @@ export {
|
|
|
265
265
|
unlockPublicFile,
|
|
266
266
|
} from './client';
|
|
267
267
|
export type { UnisourceClientConfig } from './client';
|
|
268
|
+
|
|
269
|
+
// ─── V2 API ───────────────────────────────────────────────────────────────────
|
|
270
|
+
export {
|
|
271
|
+
fileRecordsListV2QuerySchema,
|
|
272
|
+
bulkFileIdsSchema,
|
|
273
|
+
bulkFileMoveRequestSchema,
|
|
274
|
+
bulkOperationResponseSchema,
|
|
275
|
+
folderListV2QuerySchema,
|
|
276
|
+
bulkFolderIdsSchema,
|
|
277
|
+
bulkFolderMoveRequestSchema,
|
|
278
|
+
folderBreadcrumbsResponseSchema,
|
|
279
|
+
} from './v2';
|
|
280
|
+
export type {
|
|
281
|
+
FileRecordsListV2Query,
|
|
282
|
+
BulkFileIds,
|
|
283
|
+
BulkFileMoveRequest,
|
|
284
|
+
BulkOperationResponse,
|
|
285
|
+
FolderListV2Query,
|
|
286
|
+
BulkFolderIds,
|
|
287
|
+
BulkFolderMoveRequest,
|
|
288
|
+
FolderBreadcrumbsResponse,
|
|
289
|
+
} from './v2';
|
package/src/v2.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { nonEmptyString, FILES_MAX_LIMIT } from './primitives';
|
|
3
|
+
import { folderSchema } from './folders';
|
|
4
|
+
|
|
5
|
+
// ─── File Records V2 ─────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
export const fileRecordsListV2QuerySchema = z.object({
|
|
8
|
+
folder_id: nonEmptyString.nullable().optional().transform(v => v === 'null' ? null : v),
|
|
9
|
+
is_trashed: z.enum(['true', 'false']).transform(v => v === 'true').optional(),
|
|
10
|
+
search: z.string().optional(),
|
|
11
|
+
mime_type: z.string().optional(),
|
|
12
|
+
sort_by: z.enum(['created_at', 'name', 'size']).optional(),
|
|
13
|
+
sort_dir: z.enum(['asc', 'desc']).optional(),
|
|
14
|
+
cursor: nonEmptyString.optional(),
|
|
15
|
+
limit: z.coerce.number().int().min(1).max(FILES_MAX_LIMIT).optional(),
|
|
16
|
+
});
|
|
17
|
+
export type FileRecordsListV2Query = z.infer<typeof fileRecordsListV2QuerySchema>;
|
|
18
|
+
|
|
19
|
+
// Bulk Operations for Files
|
|
20
|
+
export const bulkFileIdsSchema = z.object({
|
|
21
|
+
ids: z.array(nonEmptyString).min(1).max(100),
|
|
22
|
+
});
|
|
23
|
+
export type BulkFileIds = z.infer<typeof bulkFileIdsSchema>;
|
|
24
|
+
|
|
25
|
+
export const bulkFileMoveRequestSchema = z.object({
|
|
26
|
+
ids: z.array(nonEmptyString).min(1).max(100),
|
|
27
|
+
folder_id: nonEmptyString.nullable().optional(),
|
|
28
|
+
});
|
|
29
|
+
export type BulkFileMoveRequest = z.infer<typeof bulkFileMoveRequestSchema>;
|
|
30
|
+
|
|
31
|
+
export const bulkOperationResponseSchema = z.object({
|
|
32
|
+
success: z.boolean(),
|
|
33
|
+
processed_count: z.number().int().nonnegative(),
|
|
34
|
+
failed_ids: z.array(nonEmptyString).optional(),
|
|
35
|
+
});
|
|
36
|
+
export type BulkOperationResponse = z.infer<typeof bulkOperationResponseSchema>;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// ─── Folders V2 ──────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
export const folderListV2QuerySchema = z.object({
|
|
42
|
+
parent_id: nonEmptyString.nullable().optional().transform(v => v === 'null' ? null : v),
|
|
43
|
+
is_trashed: z.enum(['true', 'false']).transform(v => v === 'true').optional(),
|
|
44
|
+
search: z.string().optional(),
|
|
45
|
+
sort_by: z.enum(['created_at', 'name']).optional(),
|
|
46
|
+
sort_dir: z.enum(['asc', 'desc']).optional(),
|
|
47
|
+
cursor: nonEmptyString.optional(),
|
|
48
|
+
limit: z.coerce.number().int().min(1).max(FILES_MAX_LIMIT).optional(),
|
|
49
|
+
});
|
|
50
|
+
export type FolderListV2Query = z.infer<typeof folderListV2QuerySchema>;
|
|
51
|
+
|
|
52
|
+
// Bulk Operations for Folders
|
|
53
|
+
export const bulkFolderIdsSchema = z.object({
|
|
54
|
+
ids: z.array(nonEmptyString).min(1).max(100),
|
|
55
|
+
});
|
|
56
|
+
export type BulkFolderIds = z.infer<typeof bulkFolderIdsSchema>;
|
|
57
|
+
|
|
58
|
+
export const bulkFolderMoveRequestSchema = z.object({
|
|
59
|
+
ids: z.array(nonEmptyString).min(1).max(100),
|
|
60
|
+
parent_id: nonEmptyString.nullable().optional(),
|
|
61
|
+
});
|
|
62
|
+
export type BulkFolderMoveRequest = z.infer<typeof bulkFolderMoveRequestSchema>;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// Breadcrumbs
|
|
66
|
+
export const folderBreadcrumbsResponseSchema = z.object({
|
|
67
|
+
breadcrumbs: z.array(folderSchema),
|
|
68
|
+
});
|
|
69
|
+
export type FolderBreadcrumbsResponse = z.infer<typeof folderBreadcrumbsResponseSchema>;
|