@turinhub/tale-js-sdk 1.3.0 → 2.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.
Files changed (46) hide show
  1. package/README.md +6 -6
  2. package/dist/acl/index.d.ts +62 -49
  3. package/dist/acl/index.js +262 -67
  4. package/dist/acl/types.d.ts +63 -98
  5. package/dist/attachment/index.d.ts +17 -0
  6. package/dist/attachment/index.js +247 -0
  7. package/dist/attachment/types.d.ts +82 -0
  8. package/dist/attachment/types.js +1 -0
  9. package/dist/attachment-type/index.d.ts +15 -0
  10. package/dist/attachment-type/index.js +203 -0
  11. package/dist/attachment-type/types.d.ts +60 -0
  12. package/dist/attachment-type/types.js +1 -0
  13. package/dist/auth/index.d.ts +21 -21
  14. package/dist/auth/index.js +66 -66
  15. package/dist/auth/types.d.ts +51 -51
  16. package/dist/cms/file.d.ts +88 -70
  17. package/dist/cms/file.js +228 -77
  18. package/dist/cms/folder.d.ts +9 -9
  19. package/dist/cms/folder.js +18 -18
  20. package/dist/cms/types.d.ts +58 -38
  21. package/dist/common/types.d.ts +47 -63
  22. package/dist/index.d.ts +4 -1
  23. package/dist/index.js +2 -0
  24. package/dist/rbac/index.d.ts +37 -42
  25. package/dist/rbac/index.js +96 -98
  26. package/dist/rbac/types.d.ts +38 -40
  27. package/dist/status.d.ts +11 -11
  28. package/dist/status.js +30 -3
  29. package/dist/task/index.d.ts +15 -147
  30. package/dist/task/index.js +170 -161
  31. package/dist/task/types.d.ts +57 -81
  32. package/dist/task-type/index.d.ts +7 -7
  33. package/dist/task-type/index.js +12 -12
  34. package/dist/task-type/types.d.ts +18 -34
  35. package/dist/token.d.ts +3 -3
  36. package/dist/token.js +4 -4
  37. package/dist/user/index.d.ts +28 -29
  38. package/dist/user/index.js +69 -74
  39. package/dist/user/types.d.ts +32 -33
  40. package/dist/user-attribute/index.d.ts +4 -7
  41. package/dist/user-attribute/index.js +19 -22
  42. package/dist/user-attribute/types.d.ts +29 -29
  43. package/dist/user-group/index.d.ts +4 -223
  44. package/dist/user-group/index.js +61 -479
  45. package/dist/user-group/types.d.ts +1 -1
  46. package/package.json +1 -1
@@ -34,8 +34,8 @@ function parseApiResponse(json, errorMessage, statusCode) {
34
34
  * import { getFolder } from '@tale/client';
35
35
  *
36
36
  * try {
37
- * const folder = await getFolder('folder_id_here');
38
- * console.log('Folder name:', folder.folder_name);
37
+ * const folder = await getFolder('folderId_here');
38
+ * console.log('Folder name:', folder.folderName);
39
39
  * } catch (error) {
40
40
  * console.error('Failed to get folder:', error.message);
41
41
  * }
@@ -52,7 +52,7 @@ export async function getFolder(folderId, options) {
52
52
  throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
53
53
  }
54
54
  const url = String(base).replace(/\/+$/, "") +
55
- `/cms/v1/folders/${encodeURIComponent(folderId)}`;
55
+ `/cms/v2/folders/${encodeURIComponent(folderId)}`;
56
56
  let response;
57
57
  try {
58
58
  response = await globalThis.fetch(url, {
@@ -86,7 +86,7 @@ export async function getFolder(folderId, options) {
86
86
  * const result = await listFolders({
87
87
  * page: 0,
88
88
  * size: 20,
89
- * sort_by: 'createdAt'
89
+ * sort: 'createdAt'
90
90
  * });
91
91
  * console.log(`Found ${result.total} folders`);
92
92
  * } catch (error) {
@@ -101,12 +101,12 @@ export async function listFolders(options) {
101
101
  if (!base) {
102
102
  throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
103
103
  }
104
- const url = new URL(String(base).replace(/\/+$/, "") + "/cms/v1/folders");
104
+ const url = new URL(String(base).replace(/\/+$/, "") + "/cms/v2/folders");
105
105
  const { appToken, baseUrl, ...requestParams } = options || {};
106
106
  const queryParams = {
107
107
  page: 0,
108
- size: 10,
109
- sort_by: "createdAt",
108
+ size: 20,
109
+ sort: "createdAt,desc",
110
110
  ...requestParams,
111
111
  };
112
112
  Object.entries(queryParams).forEach(([key, value]) => {
@@ -146,8 +146,8 @@ export async function listFolders(options) {
146
146
  *
147
147
  * try {
148
148
  * const folder = await createFolder({
149
- * folder_name: 'Images',
150
- * folder_type: ['IMAGE', 'VIDEO'],
149
+ * folderName: 'Images',
150
+ * folderType: ['IMAGE', 'VIDEO'],
151
151
  * remark: 'Image and video files'
152
152
  * });
153
153
  * console.log('Folder created:', folder.id);
@@ -157,8 +157,8 @@ export async function listFolders(options) {
157
157
  * ```
158
158
  */
159
159
  export async function createFolder(request, options) {
160
- if (!request.folder_name || request.folder_name.trim() === "") {
161
- throw new ApiError("folder_name is required", 400, "9400");
160
+ if (!request.folderName || request.folderName.trim() === "") {
161
+ throw new ApiError("folderName is required", 400, "9400");
162
162
  }
163
163
  const token = options?.appToken ?? (await getAppToken(options));
164
164
  const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
@@ -166,7 +166,7 @@ export async function createFolder(request, options) {
166
166
  if (!base) {
167
167
  throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
168
168
  }
169
- const url = String(base).replace(/\/+$/, "") + "/cms/v1/folders";
169
+ const url = String(base).replace(/\/+$/, "") + "/cms/v2/folders";
170
170
  let response;
171
171
  try {
172
172
  response = await globalThis.fetch(url, {
@@ -200,11 +200,11 @@ export async function createFolder(request, options) {
200
200
  * import { updateFolder } from '@tale/client';
201
201
  *
202
202
  * try {
203
- * const folder = await updateFolder('folder_id_here', {
204
- * folder_name: 'Updated Name',
203
+ * const folder = await updateFolder('folderId_here', {
204
+ * folderName: 'Updated Name',
205
205
  * remark: 'Updated remark'
206
206
  * });
207
- * console.log('Folder updated:', folder.folder_name);
207
+ * console.log('Folder updated:', folder.folderName);
208
208
  * } catch (error) {
209
209
  * console.error('Failed to update folder:', error.message);
210
210
  * }
@@ -221,7 +221,7 @@ export async function updateFolder(folderId, request, options) {
221
221
  throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
222
222
  }
223
223
  const url = String(base).replace(/\/+$/, "") +
224
- `/cms/v1/folders/${encodeURIComponent(folderId)}`;
224
+ `/cms/v2/folders/${encodeURIComponent(folderId)}`;
225
225
  let response;
226
226
  try {
227
227
  response = await globalThis.fetch(url, {
@@ -254,7 +254,7 @@ export async function updateFolder(folderId, request, options) {
254
254
  * import { deleteFolder } from '@tale/client';
255
255
  *
256
256
  * try {
257
- * await deleteFolder('folder_id_here');
257
+ * await deleteFolder('folderId_here');
258
258
  * console.log('Folder deleted successfully');
259
259
  * } catch (error) {
260
260
  * console.error('Failed to delete folder:', error.message);
@@ -272,7 +272,7 @@ export async function deleteFolder(folderId, options) {
272
272
  throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
273
273
  }
274
274
  const url = String(base).replace(/\/+$/, "") +
275
- `/cms/v1/folders/${encodeURIComponent(folderId)}`;
275
+ `/cms/v2/folders/${encodeURIComponent(folderId)}`;
276
276
  let response;
277
277
  try {
278
278
  response = await globalThis.fetch(url, {
@@ -10,30 +10,30 @@ export interface Folder {
10
10
  /** Folder ID (UUID) */
11
11
  id: string;
12
12
  /** Application key */
13
- app_key: string;
13
+ appKey: string;
14
14
  /** Folder name */
15
- folder_name: string;
15
+ folderName: string;
16
16
  /** Folder types (array of file types allowed in this folder) */
17
- folder_type: FileType[];
17
+ folderType: FileType[];
18
18
  /** Folder attributes (custom metadata) */
19
- folder_attr: Record<string, unknown> | null;
19
+ folderAttr: Record<string, unknown> | null;
20
20
  /** Remark/note */
21
21
  remark: string | null;
22
22
  /** Creation timestamp */
23
- created_at: string;
23
+ createdAt: string;
24
24
  /** Last update timestamp */
25
- updated_at: string;
25
+ updatedAt: string;
26
26
  }
27
27
  /**
28
28
  * Request to create a folder
29
29
  */
30
30
  export interface CreateFolderRequest {
31
31
  /** Folder name (required) */
32
- folder_name: string;
32
+ folderName: string;
33
33
  /** Folder types (optional) */
34
- folder_type?: FileType[];
34
+ folderType?: FileType[];
35
35
  /** Folder attributes (optional) */
36
- folder_attr?: Record<string, unknown>;
36
+ folderAttr?: Record<string, unknown>;
37
37
  /** Remark (optional) */
38
38
  remark?: string;
39
39
  }
@@ -42,11 +42,11 @@ export interface CreateFolderRequest {
42
42
  */
43
43
  export interface UpdateFolderRequest {
44
44
  /** Folder name (optional) */
45
- folder_name?: string;
45
+ folderName?: string;
46
46
  /** Folder types (optional) */
47
- folder_type?: FileType[];
47
+ folderType?: FileType[];
48
48
  /** Folder attributes (optional) */
49
- folder_attr?: Record<string, unknown>;
49
+ folderAttr?: Record<string, unknown>;
50
50
  /** Remark (optional) */
51
51
  remark?: string;
52
52
  }
@@ -69,7 +69,7 @@ export interface ListFoldersRequest {
69
69
  /** Page size (default: 10) */
70
70
  size?: number;
71
71
  /** Sort field (default: "createdAt") */
72
- sort_by?: string;
72
+ sort?: string;
73
73
  }
74
74
  /**
75
75
  * File information
@@ -78,44 +78,44 @@ export interface File {
78
78
  /** File ID (UUID) */
79
79
  id: string;
80
80
  /** Application key */
81
- app_key: string;
81
+ appKey: string;
82
82
  /** Folder ID (UUID) */
83
- folder_id: string;
83
+ folderId: string;
84
84
  /** File name */
85
- file_name: string;
85
+ fileName: string;
86
86
  /** File type */
87
- file_type: FileType;
87
+ fileType: FileType;
88
88
  /** File attributes (custom metadata) */
89
- file_attr: Record<string, unknown> | null;
89
+ fileAttr: Record<string, unknown> | null;
90
90
  /** Link URL (for LINK type files) */
91
- link_url: string | null;
91
+ linkUrl: string | null;
92
92
  /** OSS URL (for uploaded files) */
93
- oss_url: string | null;
93
+ ossUrl: string | null;
94
94
  /** Content (for MARKDOWN type files) */
95
95
  content: string | null;
96
96
  /** Remark/note */
97
97
  remark: string | null;
98
98
  /** Preview image URL (presigned) */
99
- preview_image_url: string | null;
99
+ previewImageUrl: string | null;
100
100
  /** Creation timestamp */
101
- created_at: string;
101
+ createdAt: string;
102
102
  /** Last update timestamp */
103
- updated_at: string;
103
+ updatedAt: string;
104
104
  }
105
105
  /**
106
106
  * Request to create a file
107
107
  */
108
108
  export interface CreateFileRequest {
109
109
  /** Folder ID (UUID, required) */
110
- folder_id: string;
110
+ folderId: string;
111
111
  /** File name (required) */
112
- file_name: string;
112
+ fileName: string;
113
113
  /** File type (required) */
114
- file_type: FileType;
114
+ fileType: FileType;
115
115
  /** File attributes (optional) */
116
- file_attr?: Record<string, unknown>;
116
+ fileAttr?: Record<string, unknown>;
117
117
  /** Link URL (for LINK type, optional) */
118
- link_url?: string;
118
+ linkUrl?: string;
119
119
  /** Content (for MARKDOWN type, optional) */
120
120
  content?: string;
121
121
  /** Remark (optional) */
@@ -126,15 +126,15 @@ export interface CreateFileRequest {
126
126
  */
127
127
  export interface UpdateFileRequest {
128
128
  /** Folder ID (optional) */
129
- folder_id?: string;
129
+ folderId?: string;
130
130
  /** File name (optional) */
131
- file_name?: string;
131
+ fileName?: string;
132
132
  /** File type (optional) */
133
- file_type?: FileType;
133
+ fileType?: FileType;
134
134
  /** File attributes (optional) */
135
- file_attr?: Record<string, unknown>;
135
+ fileAttr?: Record<string, unknown>;
136
136
  /** Link URL (optional) */
137
- link_url?: string;
137
+ linkUrl?: string;
138
138
  /** Content (optional) */
139
139
  content?: string;
140
140
  /** Remark (optional) */
@@ -144,14 +144,34 @@ export interface UpdateFileRequest {
144
144
  * Request to list files with pagination
145
145
  */
146
146
  export interface ListFilesRequest {
147
- /** Folder ID (optional, filters by folder if provided) */
148
- folder_id?: string;
147
+ /** Folder ID (required for listing files) */
148
+ folderId: string;
149
149
  /** Page number (0-based, default: 0) */
150
150
  page?: number;
151
151
  /** Page size (default: 10) */
152
152
  size?: number;
153
153
  /** Sort field (default: "createdAt") */
154
- sort_by?: string;
155
- /** Include attachments in response (default: false) */
156
- include_attachments?: boolean;
154
+ sort?: string;
155
+ }
156
+ /**
157
+ * File attachment (camelCase, matches AttachmentRespVO)
158
+ */
159
+ export interface FileAttachment {
160
+ attachmentId: string;
161
+ appId: string;
162
+ typeId: string;
163
+ refId: string;
164
+ refType: string;
165
+ fileName: string;
166
+ fileOriginalName: string;
167
+ fileExtension: string;
168
+ fileOssKey: string;
169
+ fileSize: number;
170
+ fileHash: string;
171
+ mimeType: string;
172
+ uploadStatus: string;
173
+ sortOrder: number;
174
+ remark?: string;
175
+ createdAt: string;
176
+ updatedAt: string;
157
177
  }
@@ -3,89 +3,73 @@ export interface CommonOptions {
3
3
  appToken?: string;
4
4
  }
5
5
  /**
6
- * Pagination response format used by Tale backend
7
- *
8
- * This matches the actual backend response format with simplified pagination metadata
6
+ * Pagination response format used by Tale backend (PageResponseVO)
9
7
  */
10
8
  export interface PageResponse<T> {
11
- /** Page content */
12
9
  content: T[];
13
- /** Total number of elements across all pages */
14
10
  total: number;
15
- /** Pagination information */
16
- pageable: {
17
- /** Current page number (0-based) */
18
- pageNumber: number;
19
- /** Page size */
20
- pageSize: number;
21
- /** Sort information */
22
- sort?: {
23
- orders?: Array<{
24
- direction: "ASC" | "DESC";
25
- property: string;
26
- ignoreCase: boolean;
27
- nullHandling: string;
28
- }>;
29
- };
30
- };
11
+ page: number;
12
+ totalPages: number;
13
+ size: number;
14
+ numberOfElements: number;
15
+ first: boolean;
16
+ last: boolean;
17
+ empty: boolean;
18
+ sort: Array<{
19
+ property: string;
20
+ direction: "ASC" | "DESC";
21
+ }>;
31
22
  }
32
23
  export interface UserGroup {
33
- group_id: string;
34
- group_name: string;
24
+ groupId: string;
25
+ name: string;
35
26
  description?: string;
27
+ type?: string;
36
28
  remark?: string;
37
29
  }
38
30
  export interface Role {
39
- role_id: string;
40
- role_name: string;
41
- role_type?: string;
42
- role_property?: Record<string, unknown>;
43
- role_privileges?: Privilege[];
44
- privilege_ids?: string[];
45
- resource_ids?: string[];
46
- expired_at?: string;
31
+ roleId: string;
32
+ roleName: string;
33
+ roleType?: string;
34
+ roleProperty?: Record<string, unknown>;
35
+ roleConfig?: Record<string, unknown>;
36
+ rolePrivileges?: Privilege[];
37
+ privilegeIds?: string[];
38
+ resourceIds?: string[];
39
+ expiredAt?: string;
47
40
  remark?: string;
48
41
  }
49
42
  export interface Privilege {
50
- privilege_id: string;
51
- privilege_name: string;
52
- privilege_type?: string;
53
- privilege_property?: Record<string, unknown>;
54
- resource_ids?: string[];
55
- expired_at?: string;
43
+ privilegeId: string;
44
+ privilegeName: string;
45
+ privilegeType?: string;
46
+ privilegeProperty?: Record<string, unknown>;
47
+ privilegeConfig?: Record<string, unknown>;
48
+ resourceIds?: string[];
49
+ expiredAt?: string;
56
50
  remark?: string;
57
51
  }
58
52
  export interface AppInfo {
59
- app_id: string;
60
- app_key: string;
61
- app_name: string;
53
+ appId: string;
54
+ appKey: string;
55
+ appName: string;
56
+ appProperty?: Record<string, unknown>;
57
+ appRoles?: unknown[];
58
+ appPrivileges?: unknown[];
59
+ appAdmins?: Record<string, unknown>;
60
+ roleConfig?: Record<string, unknown>;
61
+ userGroupConfig?: Record<string, unknown>;
62
62
  }
63
63
  export interface User {
64
- user_id: string;
65
- open_id: string;
64
+ userId: string;
65
+ openId: string;
66
66
  username: string;
67
- nick_name: string;
67
+ nickname: string;
68
68
  email: string;
69
69
  phone: string;
70
- avatar_url?: string;
71
- is_frozen: boolean;
72
- created_at: string;
73
- updated_at: string;
70
+ avatarUrl?: string;
71
+ isFrozen: boolean;
72
+ createdAt: string;
73
+ updatedAt: string;
74
74
  remark?: string;
75
75
  }
76
- /**
77
- * Attachment data (common type used across modules)
78
- */
79
- export interface Attachment {
80
- attachment_id: string;
81
- app_id: string;
82
- attachment_type_id: string;
83
- ref_id: string;
84
- file_name: string;
85
- file_url: string;
86
- file_size: number;
87
- mime_type: string;
88
- remark?: string;
89
- created_at: string;
90
- updated_at: string;
91
- }
package/dist/index.d.ts CHANGED
@@ -9,5 +9,8 @@ export * from "./user-attribute/index.js";
9
9
  export * from "./task-type/index.js";
10
10
  export * from "./task/index.js";
11
11
  export * from "./cms/index.js";
12
+ export * from "./attachment/index.js";
13
+ export * from "./attachment-type/index.js";
12
14
  export * from "./errors.js";
13
- export type { CommonOptions, PageResponse, UserGroup, Role, Privilege, AppInfo, User, Attachment, } from "./common/types.js";
15
+ export type { CommonOptions, PageResponse, UserGroup, Role, Privilege, AppInfo, User, } from "./common/types.js";
16
+ export type { Attachment, AttachmentRefType, ListAttachmentsByRefRequest, UploadAttachmentRequest, UploadAuthorizationRequest, CompleteUploadRequest, DeleteAttachmentRequest, DownloadAttachmentUrlRequest, DownloadUrlResponse, AttachmentOptions, } from "./attachment/types.js";
package/dist/index.js CHANGED
@@ -9,4 +9,6 @@ export * from "./user-attribute/index.js";
9
9
  export * from "./task-type/index.js";
10
10
  export * from "./task/index.js";
11
11
  export * from "./cms/index.js";
12
+ export * from "./attachment/index.js";
13
+ export * from "./attachment-type/index.js";
12
14
  export * from "./errors.js";