@centrali-io/centrali-sdk 4.4.7 → 4.4.8
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.js +88 -1
- package/index.ts +88 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3371,7 +3371,7 @@ class CentraliSDK {
|
|
|
3371
3371
|
*
|
|
3372
3372
|
* @param file - The file to upload
|
|
3373
3373
|
* @param location - Target folder path (e.g., '/root/shared/images'). Defaults to '/root/shared' if not specified.
|
|
3374
|
-
*
|
|
3374
|
+
* /root/shared always exists. For custom subfolders, create them first with createFolder().
|
|
3375
3375
|
* @param isPublic - If true, the file will be publicly accessible without authentication. Defaults to false.
|
|
3376
3376
|
* @returns The file URL or render ID
|
|
3377
3377
|
*
|
|
@@ -3406,6 +3406,93 @@ class CentraliSDK {
|
|
|
3406
3406
|
});
|
|
3407
3407
|
});
|
|
3408
3408
|
}
|
|
3409
|
+
// ------------------ Folder API Methods ------------------
|
|
3410
|
+
/**
|
|
3411
|
+
* Create a folder in the storage service.
|
|
3412
|
+
* Use this to create subfolders under /root/shared (which always exists).
|
|
3413
|
+
*
|
|
3414
|
+
* @param name - The folder name (e.g., 'logos', 'avatars')
|
|
3415
|
+
* @param location - Parent folder path (e.g., '/root/shared'). Defaults to '/root/shared'.
|
|
3416
|
+
* @returns The created folder object
|
|
3417
|
+
*
|
|
3418
|
+
* @example
|
|
3419
|
+
* ```ts
|
|
3420
|
+
* // Create a folder under /root/shared
|
|
3421
|
+
* const folder = await client.createFolder('logos', '/root/shared');
|
|
3422
|
+
* // Result: folder at /root/shared/logos
|
|
3423
|
+
*
|
|
3424
|
+
* // Then upload to it
|
|
3425
|
+
* const { data: renderId } = await client.uploadFile(file, '/root/shared/logos', true);
|
|
3426
|
+
* ```
|
|
3427
|
+
*/
|
|
3428
|
+
createFolder(name_1) {
|
|
3429
|
+
return __awaiter(this, arguments, void 0, function* (name, location = '/root/shared') {
|
|
3430
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders`;
|
|
3431
|
+
return this.request('POST', path, { name, location });
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
/**
|
|
3435
|
+
* List folders in the workspace, optionally filtered by parent location.
|
|
3436
|
+
*
|
|
3437
|
+
* @param location - Parent folder path to list contents of (e.g., '/root/shared'). If omitted, lists top-level folders.
|
|
3438
|
+
* @returns Array of folder objects
|
|
3439
|
+
*
|
|
3440
|
+
* @example
|
|
3441
|
+
* ```ts
|
|
3442
|
+
* // List all folders under /root/shared
|
|
3443
|
+
* const folders = await client.listFolders('/root/shared');
|
|
3444
|
+
*
|
|
3445
|
+
* // Check if a folder exists before uploading
|
|
3446
|
+
* const folders = await client.listFolders('/root/shared');
|
|
3447
|
+
* const hasLogos = folders.data.some(f => f.name === 'logos');
|
|
3448
|
+
* if (!hasLogos) {
|
|
3449
|
+
* await client.createFolder('logos', '/root/shared');
|
|
3450
|
+
* }
|
|
3451
|
+
* ```
|
|
3452
|
+
*/
|
|
3453
|
+
listFolders(location) {
|
|
3454
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3455
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders`;
|
|
3456
|
+
const params = location ? { location } : undefined;
|
|
3457
|
+
return this.request('GET', path, null, params);
|
|
3458
|
+
});
|
|
3459
|
+
}
|
|
3460
|
+
/**
|
|
3461
|
+
* Get a specific folder by ID.
|
|
3462
|
+
*
|
|
3463
|
+
* @param folderId - The folder ID (UUID)
|
|
3464
|
+
* @returns The folder object
|
|
3465
|
+
*/
|
|
3466
|
+
getFolder(folderId) {
|
|
3467
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3468
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders/${folderId}`;
|
|
3469
|
+
return this.request('GET', path);
|
|
3470
|
+
});
|
|
3471
|
+
}
|
|
3472
|
+
/**
|
|
3473
|
+
* List sub-folders within a specific folder.
|
|
3474
|
+
*
|
|
3475
|
+
* @param folderId - The parent folder ID (UUID)
|
|
3476
|
+
* @returns Array of sub-folder objects
|
|
3477
|
+
*/
|
|
3478
|
+
listSubFolders(folderId) {
|
|
3479
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3480
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders/${folderId}/sub-folders`;
|
|
3481
|
+
return this.request('GET', path);
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
/**
|
|
3485
|
+
* Delete a folder by ID. System folders (/root, /root/shared, /root/users) cannot be deleted.
|
|
3486
|
+
*
|
|
3487
|
+
* @param folderId - The folder ID (UUID) to delete
|
|
3488
|
+
*/
|
|
3489
|
+
deleteFolder(folderId) {
|
|
3490
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3491
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders/${folderId}`;
|
|
3492
|
+
return this.request('DELETE', path);
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
// ------------------ File Render/Download URL Methods ------------------
|
|
3409
3496
|
/**
|
|
3410
3497
|
* Get the render URL for a file. Use this URL to display files inline (e.g., images in img tags).
|
|
3411
3498
|
* Supports optional image transformation parameters.
|
package/index.ts
CHANGED
|
@@ -5886,7 +5886,7 @@ export class CentraliSDK {
|
|
|
5886
5886
|
*
|
|
5887
5887
|
* @param file - The file to upload
|
|
5888
5888
|
* @param location - Target folder path (e.g., '/root/shared/images'). Defaults to '/root/shared' if not specified.
|
|
5889
|
-
*
|
|
5889
|
+
* /root/shared always exists. For custom subfolders, create them first with createFolder().
|
|
5890
5890
|
* @param isPublic - If true, the file will be publicly accessible without authentication. Defaults to false.
|
|
5891
5891
|
* @returns The file URL or render ID
|
|
5892
5892
|
*
|
|
@@ -5927,6 +5927,93 @@ export class CentraliSDK {
|
|
|
5927
5927
|
});
|
|
5928
5928
|
}
|
|
5929
5929
|
|
|
5930
|
+
// ------------------ Folder API Methods ------------------
|
|
5931
|
+
|
|
5932
|
+
/**
|
|
5933
|
+
* Create a folder in the storage service.
|
|
5934
|
+
* Use this to create subfolders under /root/shared (which always exists).
|
|
5935
|
+
*
|
|
5936
|
+
* @param name - The folder name (e.g., 'logos', 'avatars')
|
|
5937
|
+
* @param location - Parent folder path (e.g., '/root/shared'). Defaults to '/root/shared'.
|
|
5938
|
+
* @returns The created folder object
|
|
5939
|
+
*
|
|
5940
|
+
* @example
|
|
5941
|
+
* ```ts
|
|
5942
|
+
* // Create a folder under /root/shared
|
|
5943
|
+
* const folder = await client.createFolder('logos', '/root/shared');
|
|
5944
|
+
* // Result: folder at /root/shared/logos
|
|
5945
|
+
*
|
|
5946
|
+
* // Then upload to it
|
|
5947
|
+
* const { data: renderId } = await client.uploadFile(file, '/root/shared/logos', true);
|
|
5948
|
+
* ```
|
|
5949
|
+
*/
|
|
5950
|
+
public async createFolder(
|
|
5951
|
+
name: string,
|
|
5952
|
+
location: string = '/root/shared'
|
|
5953
|
+
): Promise<ApiResponse<any>> {
|
|
5954
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders`;
|
|
5955
|
+
return this.request<any>('POST', path, { name, location });
|
|
5956
|
+
}
|
|
5957
|
+
|
|
5958
|
+
/**
|
|
5959
|
+
* List folders in the workspace, optionally filtered by parent location.
|
|
5960
|
+
*
|
|
5961
|
+
* @param location - Parent folder path to list contents of (e.g., '/root/shared'). If omitted, lists top-level folders.
|
|
5962
|
+
* @returns Array of folder objects
|
|
5963
|
+
*
|
|
5964
|
+
* @example
|
|
5965
|
+
* ```ts
|
|
5966
|
+
* // List all folders under /root/shared
|
|
5967
|
+
* const folders = await client.listFolders('/root/shared');
|
|
5968
|
+
*
|
|
5969
|
+
* // Check if a folder exists before uploading
|
|
5970
|
+
* const folders = await client.listFolders('/root/shared');
|
|
5971
|
+
* const hasLogos = folders.data.some(f => f.name === 'logos');
|
|
5972
|
+
* if (!hasLogos) {
|
|
5973
|
+
* await client.createFolder('logos', '/root/shared');
|
|
5974
|
+
* }
|
|
5975
|
+
* ```
|
|
5976
|
+
*/
|
|
5977
|
+
public async listFolders(location?: string): Promise<ApiResponse<any[]>> {
|
|
5978
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders`;
|
|
5979
|
+
const params = location ? { location } : undefined;
|
|
5980
|
+
return this.request<any[]>('GET', path, null, params);
|
|
5981
|
+
}
|
|
5982
|
+
|
|
5983
|
+
/**
|
|
5984
|
+
* Get a specific folder by ID.
|
|
5985
|
+
*
|
|
5986
|
+
* @param folderId - The folder ID (UUID)
|
|
5987
|
+
* @returns The folder object
|
|
5988
|
+
*/
|
|
5989
|
+
public async getFolder(folderId: string): Promise<ApiResponse<any>> {
|
|
5990
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders/${folderId}`;
|
|
5991
|
+
return this.request<any>('GET', path);
|
|
5992
|
+
}
|
|
5993
|
+
|
|
5994
|
+
/**
|
|
5995
|
+
* List sub-folders within a specific folder.
|
|
5996
|
+
*
|
|
5997
|
+
* @param folderId - The parent folder ID (UUID)
|
|
5998
|
+
* @returns Array of sub-folder objects
|
|
5999
|
+
*/
|
|
6000
|
+
public async listSubFolders(folderId: string): Promise<ApiResponse<any[]>> {
|
|
6001
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders/${folderId}/sub-folders`;
|
|
6002
|
+
return this.request<any[]>('GET', path);
|
|
6003
|
+
}
|
|
6004
|
+
|
|
6005
|
+
/**
|
|
6006
|
+
* Delete a folder by ID. System folders (/root, /root/shared, /root/users) cannot be deleted.
|
|
6007
|
+
*
|
|
6008
|
+
* @param folderId - The folder ID (UUID) to delete
|
|
6009
|
+
*/
|
|
6010
|
+
public async deleteFolder(folderId: string): Promise<ApiResponse<void>> {
|
|
6011
|
+
const path = `storage/ws/${this.options.workspaceId}/api/v1/folders/${folderId}`;
|
|
6012
|
+
return this.request<void>('DELETE', path);
|
|
6013
|
+
}
|
|
6014
|
+
|
|
6015
|
+
// ------------------ File Render/Download URL Methods ------------------
|
|
6016
|
+
|
|
5930
6017
|
/**
|
|
5931
6018
|
* Get the render URL for a file. Use this URL to display files inline (e.g., images in img tags).
|
|
5932
6019
|
* Supports optional image transformation parameters.
|