@turinhub/tale-js-sdk 1.3.0 → 2.1.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 +90 -13
- package/dist/acl/index.d.ts +62 -49
- package/dist/acl/index.js +262 -67
- package/dist/acl/types.d.ts +63 -98
- package/dist/app/index.d.ts +10 -0
- package/dist/app/index.js +198 -0
- package/dist/app/types.d.ts +101 -0
- package/dist/app/types.js +1 -0
- package/dist/app-token/index.d.ts +7 -0
- package/dist/app-token/index.js +58 -0
- package/dist/app-token/types.d.ts +25 -0
- package/dist/app-token/types.js +1 -0
- package/dist/attachment/index.d.ts +17 -0
- package/dist/attachment/index.js +247 -0
- package/dist/attachment/types.d.ts +82 -0
- package/dist/attachment/types.js +1 -0
- package/dist/attachment-type/index.d.ts +15 -0
- package/dist/attachment-type/index.js +203 -0
- package/dist/attachment-type/types.d.ts +60 -0
- package/dist/attachment-type/types.js +1 -0
- package/dist/auth/index.d.ts +21 -21
- package/dist/auth/index.js +66 -66
- package/dist/auth/types.d.ts +51 -51
- package/dist/cms/file.d.ts +88 -70
- package/dist/cms/file.js +228 -77
- package/dist/cms/folder.d.ts +9 -9
- package/dist/cms/folder.js +18 -18
- package/dist/cms/types.d.ts +58 -38
- package/dist/common/http.d.ts +17 -0
- package/dist/common/http.js +141 -0
- package/dist/common/types.d.ts +58 -63
- package/dist/index.d.ts +6 -1
- package/dist/index.js +4 -0
- package/dist/rbac/index.d.ts +37 -42
- package/dist/rbac/index.js +96 -98
- package/dist/rbac/types.d.ts +38 -40
- package/dist/status.d.ts +11 -11
- package/dist/status.js +30 -3
- package/dist/task/index.d.ts +15 -147
- package/dist/task/index.js +170 -161
- package/dist/task/types.d.ts +57 -81
- package/dist/task-type/index.d.ts +7 -7
- package/dist/task-type/index.js +12 -12
- package/dist/task-type/types.d.ts +18 -34
- package/dist/token.d.ts +3 -3
- package/dist/token.js +4 -4
- package/dist/user/index.d.ts +28 -29
- package/dist/user/index.js +69 -74
- package/dist/user/types.d.ts +32 -33
- package/dist/user-attribute/index.d.ts +4 -7
- package/dist/user-attribute/index.js +19 -22
- package/dist/user-attribute/types.d.ts +29 -29
- package/dist/user-group/index.d.ts +4 -223
- package/dist/user-group/index.js +61 -479
- package/dist/user-group/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/cms/file.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PageResponse } from "../common/types.js";
|
|
2
|
-
import type { File, CreateFileRequest, UpdateFileRequest, ListFilesRequest, FileOptions } from "./types.js";
|
|
2
|
+
import type { File, CreateFileRequest, UpdateFileRequest, ListFilesRequest, FileOptions, FileAttachment } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Gets a file by ID.
|
|
5
5
|
*
|
|
@@ -15,9 +15,9 @@ import type { File, CreateFileRequest, UpdateFileRequest, ListFilesRequest, File
|
|
|
15
15
|
* import { getFile } from '@tale/client';
|
|
16
16
|
*
|
|
17
17
|
* try {
|
|
18
|
-
* const file = await getFile('
|
|
19
|
-
* console.log('File name:', file.
|
|
20
|
-
* console.log('File type:', file.
|
|
18
|
+
* const file = await getFile('fileId_here');
|
|
19
|
+
* console.log('File name:', file.fileName);
|
|
20
|
+
* console.log('File type:', file.fileType);
|
|
21
21
|
* } catch (error) {
|
|
22
22
|
* console.error('Failed to get file:', error.message);
|
|
23
23
|
* }
|
|
@@ -39,10 +39,10 @@ export declare function getFile(fileId: string, options?: FileOptions): Promise<
|
|
|
39
39
|
*
|
|
40
40
|
* try {
|
|
41
41
|
* const result = await listFiles({
|
|
42
|
-
*
|
|
42
|
+
* folderId: 'folderId_here',
|
|
43
43
|
* page: 0,
|
|
44
44
|
* size: 20,
|
|
45
|
-
*
|
|
45
|
+
* sort: 'createdAt'
|
|
46
46
|
* });
|
|
47
47
|
* console.log(`Found ${result.total} files`);
|
|
48
48
|
* } catch (error) {
|
|
@@ -67,9 +67,9 @@ export declare function listFiles(options?: ListFilesRequest & FileOptions): Pro
|
|
|
67
67
|
*
|
|
68
68
|
* try {
|
|
69
69
|
* const file = await createFile({
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* folderId: 'folderId_here',
|
|
71
|
+
* fileName: 'My Document',
|
|
72
|
+
* fileType: 'markdown',
|
|
73
73
|
* content: '# Hello World'
|
|
74
74
|
* });
|
|
75
75
|
* console.log('File created:', file.id);
|
|
@@ -95,11 +95,11 @@ export declare function createFile(request: CreateFileRequest, options?: FileOpt
|
|
|
95
95
|
* import { updateFile } from '@tale/client';
|
|
96
96
|
*
|
|
97
97
|
* try {
|
|
98
|
-
* const file = await updateFile('
|
|
99
|
-
*
|
|
98
|
+
* const file = await updateFile('fileId_here', {
|
|
99
|
+
* fileName: 'Updated Name',
|
|
100
100
|
* remark: 'Updated remark'
|
|
101
101
|
* });
|
|
102
|
-
* console.log('File updated:', file.
|
|
102
|
+
* console.log('File updated:', file.fileName);
|
|
103
103
|
* } catch (error) {
|
|
104
104
|
* console.error('Failed to update file:', error.message);
|
|
105
105
|
* }
|
|
@@ -122,7 +122,7 @@ export declare function updateFile(fileId: string, request: UpdateFileRequest, o
|
|
|
122
122
|
* import { updateFileContent } from '@tale/client';
|
|
123
123
|
*
|
|
124
124
|
* try {
|
|
125
|
-
* const file = await updateFileContent('
|
|
125
|
+
* const file = await updateFileContent('fileId_here', '# New Content');
|
|
126
126
|
* console.log('Content updated:', file.content);
|
|
127
127
|
* } catch (error) {
|
|
128
128
|
* console.error('Failed to update content:', error.message);
|
|
@@ -145,7 +145,7 @@ export declare function updateFileContent(fileId: string, content: string, optio
|
|
|
145
145
|
* import { deleteFile } from '@tale/client';
|
|
146
146
|
*
|
|
147
147
|
* try {
|
|
148
|
-
* await deleteFile('
|
|
148
|
+
* await deleteFile('fileId_here');
|
|
149
149
|
* console.log('File deleted successfully');
|
|
150
150
|
* } catch (error) {
|
|
151
151
|
* console.error('Failed to delete file:', error.message);
|
|
@@ -169,8 +169,8 @@ export declare function deleteFile(fileId: string, options?: FileOptions): Promi
|
|
|
169
169
|
* import { getFilePresignedUrl } from '@tale/client';
|
|
170
170
|
*
|
|
171
171
|
* try {
|
|
172
|
-
* const result = await getFilePresignedUrl('
|
|
173
|
-
* console.log('Presigned URL:', result.
|
|
172
|
+
* const result = await getFilePresignedUrl('fileId_here', 3600);
|
|
173
|
+
* console.log('Presigned URL:', result.presignedUrl);
|
|
174
174
|
* // Now you can download the file directly
|
|
175
175
|
* } catch (error) {
|
|
176
176
|
* console.error('Failed to get presigned URL:', error.message);
|
|
@@ -178,11 +178,11 @@ export declare function deleteFile(fileId: string, options?: FileOptions): Promi
|
|
|
178
178
|
* ```
|
|
179
179
|
*/
|
|
180
180
|
export declare function getFilePresignedUrl(fileId: string, expireTimeInSeconds?: number, options?: FileOptions): Promise<{
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
fileId: string;
|
|
182
|
+
fileName: string;
|
|
183
|
+
ossKey: string;
|
|
184
|
+
presignedUrl: string;
|
|
185
|
+
expireTimeInSeconds: number;
|
|
186
186
|
}>;
|
|
187
187
|
/**
|
|
188
188
|
* Batch gets presigned URLs for multiple files.
|
|
@@ -201,14 +201,14 @@ export declare function getFilePresignedUrl(fileId: string, expireTimeInSeconds?
|
|
|
201
201
|
*
|
|
202
202
|
* try {
|
|
203
203
|
* const results = await batchGetFilePresignedUrl(
|
|
204
|
-
* ['
|
|
204
|
+
* ['fileId_1', 'fileId_2'],
|
|
205
205
|
* 3600
|
|
206
206
|
* );
|
|
207
207
|
* results.forEach(result => {
|
|
208
208
|
* if (result.error) {
|
|
209
|
-
* console.error('Error for file:', result.
|
|
209
|
+
* console.error('Error for file:', result.fileId, result.error);
|
|
210
210
|
* } else {
|
|
211
|
-
* console.log('URL:', result.
|
|
211
|
+
* console.log('URL:', result.presignedUrl);
|
|
212
212
|
* }
|
|
213
213
|
* });
|
|
214
214
|
* } catch (error) {
|
|
@@ -217,11 +217,11 @@ export declare function getFilePresignedUrl(fileId: string, expireTimeInSeconds?
|
|
|
217
217
|
* ```
|
|
218
218
|
*/
|
|
219
219
|
export declare function batchGetFilePresignedUrl(fileIds: string[], expireTimeInSeconds?: number, options?: FileOptions): Promise<Array<{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
fileId: string;
|
|
221
|
+
fileName?: string;
|
|
222
|
+
ossKey?: string;
|
|
223
|
+
presignedUrl?: string;
|
|
224
|
+
expireTimeInSeconds?: number;
|
|
225
225
|
error?: string;
|
|
226
226
|
}>>;
|
|
227
227
|
/**
|
|
@@ -240,18 +240,18 @@ export declare function batchGetFilePresignedUrl(fileIds: string[], expireTimeIn
|
|
|
240
240
|
*
|
|
241
241
|
* try {
|
|
242
242
|
* const metadata = await getOssMetadata('cms/appkey/folder/fileid.pdf');
|
|
243
|
-
* console.log('File size:', metadata.
|
|
244
|
-
* console.log('Content type:', metadata.
|
|
243
|
+
* console.log('File size:', metadata.contentLength);
|
|
244
|
+
* console.log('Content type:', metadata.contentType);
|
|
245
245
|
* } catch (error) {
|
|
246
246
|
* console.error('Failed to get OSS metadata:', error.message);
|
|
247
247
|
* }
|
|
248
248
|
* ```
|
|
249
249
|
*/
|
|
250
250
|
export declare function getOssMetadata(ossKey: string, options?: FileOptions): Promise<{
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
ossKey: string;
|
|
252
|
+
contentType?: string;
|
|
253
|
+
contentLength?: number;
|
|
254
|
+
lastModified?: string;
|
|
255
255
|
etag?: string;
|
|
256
256
|
metadata?: Record<string, string>;
|
|
257
257
|
}>;
|
|
@@ -271,31 +271,31 @@ export declare function getOssMetadata(ossKey: string, options?: FileOptions): P
|
|
|
271
271
|
*
|
|
272
272
|
* try {
|
|
273
273
|
* const auth = await getUploadAuthorization({
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
274
|
+
* folderId: 'folderId_here',
|
|
275
|
+
* fileName: 'document.pdf',
|
|
276
|
+
* fileType: 'pdf'
|
|
277
277
|
* });
|
|
278
|
-
* console.log('OSS Key:', auth.
|
|
279
|
-
* console.log('Upload URL:', auth.
|
|
280
|
-
* console.log('File ID:', auth.
|
|
281
|
-
* // Use
|
|
278
|
+
* console.log('OSS Key:', auth.ossKey);
|
|
279
|
+
* console.log('Upload URL:', auth.presignedUrl);
|
|
280
|
+
* console.log('File ID:', auth.fileId);
|
|
281
|
+
* // Use presignedUrl to upload the file directly to OSS
|
|
282
282
|
* } catch (error) {
|
|
283
283
|
* console.error('Failed to get upload authorization:', error.message);
|
|
284
284
|
* }
|
|
285
285
|
* ```
|
|
286
286
|
*/
|
|
287
287
|
export declare function getUploadAuthorization(request: {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
folderId: string;
|
|
289
|
+
fileName: string;
|
|
290
|
+
fileType: string;
|
|
291
|
+
expireTimeInSeconds?: number;
|
|
292
292
|
}, options?: FileOptions): Promise<{
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
ossKey: string;
|
|
294
|
+
presignedUrl: string;
|
|
295
|
+
fileName: string;
|
|
296
|
+
fileType: string;
|
|
297
|
+
expireTimeInSeconds: number;
|
|
298
|
+
fileId: string;
|
|
299
299
|
}>;
|
|
300
300
|
/**
|
|
301
301
|
* Gets STS credentials for uploading to an existing file.
|
|
@@ -314,11 +314,11 @@ export declare function getUploadAuthorization(request: {
|
|
|
314
314
|
* import { getFileStsCredentials } from '@tale/client';
|
|
315
315
|
*
|
|
316
316
|
* try {
|
|
317
|
-
* const credentials = await getFileStsCredentials('
|
|
318
|
-
* console.log('Access Key ID:', credentials.
|
|
319
|
-
* console.log('Secret Access Key:', credentials.
|
|
320
|
-
* console.log('Session Token:', credentials.
|
|
321
|
-
* console.log('Upload Path:', credentials.
|
|
317
|
+
* const credentials = await getFileStsCredentials('fileId_here', '.pdf', 1800);
|
|
318
|
+
* console.log('Access Key ID:', credentials.accessKeyId);
|
|
319
|
+
* console.log('Secret Access Key:', credentials.secretAccessKey);
|
|
320
|
+
* console.log('Session Token:', credentials.sessionToken);
|
|
321
|
+
* console.log('Upload Path:', credentials.uploadPath);
|
|
322
322
|
* // Use these credentials to upload with OSS SDK
|
|
323
323
|
* } catch (error) {
|
|
324
324
|
* console.error('Failed to get STS credentials:', error.message);
|
|
@@ -326,12 +326,18 @@ export declare function getUploadAuthorization(request: {
|
|
|
326
326
|
* ```
|
|
327
327
|
*/
|
|
328
328
|
export declare function getFileStsCredentials(fileId: string, fileExtension: string, durationSeconds?: number, options?: FileOptions): Promise<{
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
329
|
+
credentials: {
|
|
330
|
+
tmpSecretId: string;
|
|
331
|
+
tmpSecretKey: string;
|
|
332
|
+
sessionToken: string;
|
|
333
|
+
bucket: string;
|
|
334
|
+
region: string;
|
|
335
|
+
};
|
|
336
|
+
startTime: number;
|
|
337
|
+
expiredTime: number;
|
|
338
|
+
bucket: string;
|
|
334
339
|
region: string;
|
|
340
|
+
allowPrefix: string;
|
|
335
341
|
}>;
|
|
336
342
|
/**
|
|
337
343
|
* Marks file upload as complete and updates OSS information.
|
|
@@ -349,9 +355,9 @@ export declare function getFileStsCredentials(fileId: string, fileExtension: str
|
|
|
349
355
|
* import { fileUploadComplete } from '@tale/client';
|
|
350
356
|
*
|
|
351
357
|
* try {
|
|
352
|
-
* const result = await fileUploadComplete('
|
|
353
|
-
*
|
|
354
|
-
*
|
|
358
|
+
* const result = await fileUploadComplete('fileId_here', {
|
|
359
|
+
* ossKey: 'cms/appkey/folder/fileid.pdf',
|
|
360
|
+
* fileSize: 12345,
|
|
355
361
|
* etag: 'abc123'
|
|
356
362
|
* });
|
|
357
363
|
* console.log('Upload complete:', result.message);
|
|
@@ -361,12 +367,12 @@ export declare function getFileStsCredentials(fileId: string, fileExtension: str
|
|
|
361
367
|
* ```
|
|
362
368
|
*/
|
|
363
369
|
export declare function fileUploadComplete(fileId: string, request: {
|
|
364
|
-
|
|
365
|
-
|
|
370
|
+
ossKey: string;
|
|
371
|
+
fileSize: number;
|
|
366
372
|
etag: string;
|
|
367
373
|
}, options?: FileOptions): Promise<{
|
|
368
374
|
message: string;
|
|
369
|
-
|
|
375
|
+
fileId: string;
|
|
370
376
|
}>;
|
|
371
377
|
/**
|
|
372
378
|
* Sets a preview image for a file.
|
|
@@ -388,11 +394,23 @@ export declare function fileUploadComplete(fileId: string, request: {
|
|
|
388
394
|
* const input = document.getElementById('previewInput');
|
|
389
395
|
* const file = input.files[0];
|
|
390
396
|
*
|
|
391
|
-
* const updatedFile = await setFilePreviewImage('
|
|
392
|
-
* console.log('Preview image set:', updatedFile.
|
|
397
|
+
* const updatedFile = await setFilePreviewImage('fileId_here', file);
|
|
398
|
+
* console.log('Preview image set:', updatedFile.previewImageUrl);
|
|
393
399
|
* } catch (error) {
|
|
394
400
|
* console.error('Failed to set preview image:', error.message);
|
|
395
401
|
* }
|
|
396
402
|
* ```
|
|
397
403
|
*/
|
|
398
404
|
export declare function setFilePreviewImage(fileId: string, imageFile: File | Blob, options?: FileOptions): Promise<File>;
|
|
405
|
+
/** List attachments for a file */
|
|
406
|
+
export declare function listFileAttachments(fileId: string, options?: FileOptions & {
|
|
407
|
+
page?: number;
|
|
408
|
+
size?: number;
|
|
409
|
+
sort?: string;
|
|
410
|
+
}): Promise<PageResponse<FileAttachment>>;
|
|
411
|
+
/** Get a file attachment by ID */
|
|
412
|
+
export declare function getFileAttachment(fileId: string, attachmentId: string, options?: FileOptions): Promise<FileAttachment>;
|
|
413
|
+
/** Upload an attachment to a file */
|
|
414
|
+
export declare function uploadFileAttachment(fileId: string, attachmentTypeId: string, file: File | Blob, remark?: string, options?: FileOptions): Promise<FileAttachment>;
|
|
415
|
+
/** Delete a file attachment */
|
|
416
|
+
export declare function deleteFileAttachment(fileId: string, attachmentId: string, options?: FileOptions): Promise<void>;
|