@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.
Files changed (56) hide show
  1. package/README.md +90 -13
  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/app/index.d.ts +10 -0
  6. package/dist/app/index.js +198 -0
  7. package/dist/app/types.d.ts +101 -0
  8. package/dist/app/types.js +1 -0
  9. package/dist/app-token/index.d.ts +7 -0
  10. package/dist/app-token/index.js +58 -0
  11. package/dist/app-token/types.d.ts +25 -0
  12. package/dist/app-token/types.js +1 -0
  13. package/dist/attachment/index.d.ts +17 -0
  14. package/dist/attachment/index.js +247 -0
  15. package/dist/attachment/types.d.ts +82 -0
  16. package/dist/attachment/types.js +1 -0
  17. package/dist/attachment-type/index.d.ts +15 -0
  18. package/dist/attachment-type/index.js +203 -0
  19. package/dist/attachment-type/types.d.ts +60 -0
  20. package/dist/attachment-type/types.js +1 -0
  21. package/dist/auth/index.d.ts +21 -21
  22. package/dist/auth/index.js +66 -66
  23. package/dist/auth/types.d.ts +51 -51
  24. package/dist/cms/file.d.ts +88 -70
  25. package/dist/cms/file.js +228 -77
  26. package/dist/cms/folder.d.ts +9 -9
  27. package/dist/cms/folder.js +18 -18
  28. package/dist/cms/types.d.ts +58 -38
  29. package/dist/common/http.d.ts +17 -0
  30. package/dist/common/http.js +141 -0
  31. package/dist/common/types.d.ts +58 -63
  32. package/dist/index.d.ts +6 -1
  33. package/dist/index.js +4 -0
  34. package/dist/rbac/index.d.ts +37 -42
  35. package/dist/rbac/index.js +96 -98
  36. package/dist/rbac/types.d.ts +38 -40
  37. package/dist/status.d.ts +11 -11
  38. package/dist/status.js +30 -3
  39. package/dist/task/index.d.ts +15 -147
  40. package/dist/task/index.js +170 -161
  41. package/dist/task/types.d.ts +57 -81
  42. package/dist/task-type/index.d.ts +7 -7
  43. package/dist/task-type/index.js +12 -12
  44. package/dist/task-type/types.d.ts +18 -34
  45. package/dist/token.d.ts +3 -3
  46. package/dist/token.js +4 -4
  47. package/dist/user/index.d.ts +28 -29
  48. package/dist/user/index.js +69 -74
  49. package/dist/user/types.d.ts +32 -33
  50. package/dist/user-attribute/index.d.ts +4 -7
  51. package/dist/user-attribute/index.js +19 -22
  52. package/dist/user-attribute/types.d.ts +29 -29
  53. package/dist/user-group/index.d.ts +4 -223
  54. package/dist/user-group/index.js +61 -479
  55. package/dist/user-group/types.d.ts +1 -1
  56. package/package.json +1 -1
@@ -4,92 +4,92 @@ export type { Role, Privilege };
4
4
  * Request for creating a role
5
5
  */
6
6
  export interface CreateRoleRequest {
7
- role_name: string;
8
- role_type?: string;
9
- role_property?: Record<string, unknown>;
10
- role_config?: Record<string, unknown>;
11
- privilege_ids?: string[];
7
+ roleName: string;
8
+ roleType?: string;
9
+ roleProperty?: Record<string, unknown>;
10
+ roleConfig?: Record<string, unknown>;
11
+ privilegeIds?: string[];
12
12
  remark?: string;
13
13
  }
14
14
  /**
15
15
  * Request for updating a role
16
16
  */
17
17
  export interface UpdateRoleRequest {
18
- role_name?: string;
19
- role_type?: string;
20
- role_property?: Record<string, unknown>;
21
- role_config?: Record<string, unknown>;
22
- privilege_ids?: string[];
18
+ roleName?: string;
19
+ roleType?: string;
20
+ roleProperty?: Record<string, unknown>;
21
+ roleConfig?: Record<string, unknown>;
22
+ privilegeIds?: string[];
23
23
  remark?: string;
24
24
  }
25
25
  /**
26
26
  * Request for creating a privilege
27
27
  */
28
28
  export interface CreatePrivilegeRequest {
29
- privilege_name: string;
30
- privilege_type?: string;
31
- privilege_property?: Record<string, unknown>;
32
- privilege_config?: Record<string, unknown>;
33
- resource_ids?: string[];
29
+ privilegeName: string;
30
+ privilegeType?: string;
31
+ privilegeProperty?: Record<string, unknown>;
32
+ privilegeConfig?: Record<string, unknown>;
33
+ resourceIds?: string[];
34
34
  remark?: string;
35
35
  }
36
36
  /**
37
37
  * Request for updating a privilege
38
38
  */
39
39
  export interface UpdatePrivilegeRequest {
40
- privilege_name?: string;
41
- privilege_type?: string;
42
- privilege_property?: Record<string, unknown>;
43
- privilege_config?: Record<string, unknown>;
44
- resource_ids?: string[];
40
+ privilegeName?: string;
41
+ privilegeType?: string;
42
+ privilegeProperty?: Record<string, unknown>;
43
+ privilegeConfig?: Record<string, unknown>;
44
+ resourceIds?: string[];
45
45
  remark?: string;
46
46
  }
47
47
  /**
48
48
  * Request for assigning roles to a user
49
49
  */
50
50
  export interface UserRoleAssignmentRequest {
51
- role_ids: string[];
52
- started_at?: string;
53
- expired_at?: string;
54
- assignment_type?: string;
55
- assignment_ref?: string;
51
+ roleIds: string[];
52
+ startedAt?: string;
53
+ expiredAt?: string;
54
+ assignmentType?: string;
55
+ assignmentRef?: string;
56
56
  remark?: string;
57
57
  }
58
58
  /**
59
59
  * Request for unassigning roles from a user
60
60
  */
61
61
  export interface UserRoleUnassignmentRequest {
62
- role_ids: string[];
62
+ roleIds: string[];
63
63
  }
64
64
  /**
65
65
  * Request for assigning privileges to a user
66
66
  */
67
67
  export interface UserPrivilegeAssignmentRequest {
68
- privilege_ids: string[];
69
- started_at?: string;
70
- expired_at?: string;
71
- assignment_type?: string;
72
- assignment_ref?: string;
68
+ privilegeIds: string[];
69
+ startedAt?: string;
70
+ expiredAt?: string;
71
+ assignmentType?: string;
72
+ assignmentRef?: string;
73
73
  remark?: string;
74
74
  }
75
75
  /**
76
76
  * Request for unassigning privileges from a user
77
77
  */
78
78
  export interface UserPrivilegeUnassignmentRequest {
79
- privilege_ids: string[];
79
+ privilegeIds: string[];
80
80
  }
81
81
  /**
82
82
  * Request for assigning privileges to a role
83
83
  */
84
84
  export interface RolePrivilegeAssignmentRequest {
85
- privilege_ids: string[];
85
+ privilegeIds: string[];
86
86
  remark?: string;
87
87
  }
88
88
  /**
89
89
  * Request for unassigning privileges from a role
90
90
  */
91
91
  export interface RolePrivilegeUnassignmentRequest {
92
- privilege_ids: string[];
92
+ privilegeIds: string[];
93
93
  }
94
94
  /**
95
95
  * Options for RBAC operations
@@ -102,9 +102,8 @@ export interface RbacOptions extends CommonOptions {
102
102
  export interface ListRolesRequest {
103
103
  page?: number;
104
104
  size?: number;
105
- role_type?: string;
106
- sort_by?: string;
107
- sort_direction?: "asc" | "desc";
105
+ roleType?: string;
106
+ sort?: string;
108
107
  }
109
108
  /**
110
109
  * Request for listing privileges
@@ -112,9 +111,8 @@ export interface ListRolesRequest {
112
111
  export interface ListPrivilegesRequest {
113
112
  page?: number;
114
113
  size?: number;
115
- privilege_type?: string;
116
- sort_by?: string;
117
- sort_direction?: "asc" | "desc";
114
+ privilegeType?: string;
115
+ sort?: string;
118
116
  }
119
117
  /**
120
118
  * Privilege and role pair
package/dist/status.d.ts CHANGED
@@ -7,8 +7,8 @@ export type SdkStatus = {
7
7
  taleAppSecret: string;
8
8
  };
9
9
  export type StatusData = {
10
- service_name: string;
11
- host_name: string;
10
+ serviceName: string;
11
+ hostName: string;
12
12
  };
13
13
  export type StatusJson = {
14
14
  status: string;
@@ -17,15 +17,15 @@ export type StatusJson = {
17
17
  msg: string;
18
18
  };
19
19
  export type AppInfoData = {
20
- app_id: string;
21
- app_key: string;
22
- app_name: string;
23
- app_property: Record<string, unknown>;
24
- app_roles: unknown[];
25
- app_privileges: unknown[];
26
- app_admins: Record<string, unknown>;
27
- role_config: Record<string, unknown>;
28
- user_group_config: Record<string, unknown>;
20
+ appId: string;
21
+ appKey: string;
22
+ appName: string;
23
+ appProperty: Record<string, unknown>;
24
+ appRoles: unknown[];
25
+ appPrivileges: unknown[];
26
+ appAdmins: Record<string, unknown>;
27
+ roleConfig: Record<string, unknown>;
28
+ userGroupConfig: Record<string, unknown>;
29
29
  remark: string;
30
30
  };
31
31
  export type AppInfoJson = {
package/dist/status.js CHANGED
@@ -1,5 +1,25 @@
1
1
  import pkg from "../package.json" with { type: "json" };
2
2
  import { getAppToken, ConfigurationError, ApiError, NetworkError, } from "./token.js";
3
+ function normalizeStatusData(data) {
4
+ return {
5
+ serviceName: data?.serviceName,
6
+ hostName: data?.hostName,
7
+ };
8
+ }
9
+ function normalizeAppInfoData(data) {
10
+ return {
11
+ appId: data?.appId,
12
+ appKey: data?.appKey,
13
+ appName: data?.appName,
14
+ appProperty: data?.appProperty ?? {},
15
+ appRoles: data?.appRoles ?? [],
16
+ appPrivileges: data?.appPrivileges ?? [],
17
+ appAdmins: data?.appAdmins ?? {},
18
+ roleConfig: data?.roleConfig ?? {},
19
+ userGroupConfig: data?.userGroupConfig ?? {},
20
+ remark: data?.remark ?? "",
21
+ };
22
+ }
3
23
  export async function checkTaleStatus(baseUrl) {
4
24
  const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
5
25
  const base = baseUrl ?? env?.TALE_BASE_URL ?? undefined;
@@ -17,7 +37,10 @@ export async function checkTaleStatus(baseUrl) {
17
37
  let statusJson;
18
38
  try {
19
39
  const json = await response.json();
20
- statusJson = json;
40
+ statusJson = {
41
+ ...json,
42
+ data: normalizeStatusData(json.data),
43
+ };
21
44
  }
22
45
  catch (error) {
23
46
  throw new ApiError(`Failed to parse status response: ${error instanceof Error ? error.message : "Invalid JSON"}`);
@@ -25,12 +48,16 @@ export async function checkTaleStatus(baseUrl) {
25
48
  let appJson;
26
49
  try {
27
50
  const token = await getAppToken({ baseUrl: base });
28
- const appUrl = String(base).replace(/\/+$/, "") + "/app/v1/app";
51
+ const appUrl = String(base).replace(/\/+$/, "") + "/app/v2/app";
29
52
  const appRes = await globalThis.fetch(appUrl, {
30
53
  method: "GET",
31
54
  headers: { "x-t-token": token },
32
55
  });
33
- appJson = (await appRes.json());
56
+ const rawAppJson = (await appRes.json());
57
+ appJson = {
58
+ ...rawAppJson,
59
+ data: normalizeAppInfoData(rawAppJson.data),
60
+ };
34
61
  }
35
62
  catch {
36
63
  appJson = undefined;
@@ -1,163 +1,31 @@
1
- import type { UserTask, CreateUserTaskRequest, UpdateUserTaskRequest, BatchCreateUserTasksRequest, BatchQueryUserTasksRequest, BatchCreateUserTasksResponse, ListUserTasksRequest, UpdateTaskStatusRequest, TaskStatistics, TaskStatusResponse, UserTaskOptions } from "./types.js";
1
+ import type { UserTask, CreateUserTaskRequest, UpdateUserTaskRequest, BatchCreateUserTasksRequest, BatchQueryUserTasksRequest, BatchCreateUserTasksResponse, ListUserTasksRequest, UpdateTaskStatusRequest, TaskStatistics, TaskStatusResponse, TaskFrozenStatusResponse, UpdateTaskFrozenStatusRequest, UserTaskOptions } from "./types.js";
2
+ import type { Attachment } from "../attachment/types.js";
2
3
  import type { PageResponse } from "../common/types.js";
3
- export type { UserTask, CreateUserTaskRequest, UpdateUserTaskRequest, BatchCreateUserTasksRequest, BatchQueryUserTasksRequest, BatchCreateUserTasksResponse, ListUserTasksRequest, UpdateTaskStatusRequest, TaskStatistics, TaskStatusResponse, UserTaskOptions, };
4
- /**
5
- * Creates a new user task.
6
- *
7
- * @param request - Task creation request
8
- * @param options - Optional configuration
9
- * @returns Promise resolving to created task
10
- * @throws {ConfigurationError} When required environment variables are missing
11
- * @throws {ApiError} When API request fails
12
- * @throws {NetworkError} When network request fails
13
- */
4
+ export type { UserTask, CreateUserTaskRequest, UpdateUserTaskRequest, BatchCreateUserTasksRequest, BatchQueryUserTasksRequest, BatchCreateUserTasksResponse, ListUserTasksRequest, UpdateTaskStatusRequest, TaskStatistics, TaskStatusResponse, TaskFrozenStatusResponse, UpdateTaskFrozenStatusRequest, UserTaskOptions, };
14
5
  export declare function createUserTask(request: CreateUserTaskRequest, options?: UserTaskOptions): Promise<UserTask>;
15
- /**
16
- * Batch creates user tasks.
17
- *
18
- * @param request - Batch creation request
19
- * @param options - Optional configuration
20
- * @returns Promise resolving to batch creation response
21
- * @throws {ConfigurationError} When required environment variables are missing
22
- * @throws {ApiError} When API request fails
23
- * @throws {NetworkError} When network request fails
24
- */
25
6
  export declare function batchCreateUserTasks(request: BatchCreateUserTasksRequest, options?: UserTaskOptions): Promise<BatchCreateUserTasksResponse>;
26
- /**
27
- * Gets a user task by ID.
28
- *
29
- * @param taskId - Task ID
30
- * @param options - Optional configuration (include_attachments, include_sub_tasks)
31
- * @returns Promise resolving to task
32
- * @throws {ConfigurationError} When required environment variables are missing
33
- * @throws {ApiError} When API request fails
34
- * @throws {NetworkError} When network request fails
35
- */
36
7
  export declare function getUserTask(taskId: string, options?: UserTaskOptions & {
37
- include_attachments?: boolean;
38
- include_sub_tasks?: boolean;
8
+ includeAttachments?: boolean;
9
+ includeSubTasks?: boolean;
39
10
  }): Promise<UserTask>;
40
- /**
41
- * Batch gets user tasks by IDs.
42
- *
43
- * @param request - Batch query request
44
- * @param options - Optional configuration
45
- * @returns Promise resolving to array of tasks
46
- * @throws {ConfigurationError} When required environment variables are missing
47
- * @throws {ApiError} When API request fails
48
- * @throws {NetworkError} When network request fails
49
- */
50
11
  export declare function batchGetUserTasks(request: BatchQueryUserTasksRequest, options?: UserTaskOptions): Promise<UserTask[]>;
51
- /**
52
- * Lists user tasks with pagination and optional filtering.
53
- *
54
- * @param request - List request parameters
55
- * @param options - Optional configuration
56
- * @returns Promise resolving to paginated list of tasks
57
- * @throws {ConfigurationError} When required environment variables are missing
58
- * @throws {ApiError} When API request fails
59
- * @throws {NetworkError} When network request fails
60
- */
61
12
  export declare function listUserTasks(request?: ListUserTasksRequest & UserTaskOptions): Promise<PageResponse<UserTask>>;
62
- /**
63
- * Updates a user task.
64
- *
65
- * @param taskId - Task ID
66
- * @param request - Update request
67
- * @param options - Optional configuration
68
- * @returns Promise resolving to updated task
69
- * @throws {ConfigurationError} When required environment variables are missing
70
- * @throws {ApiError} When API request fails
71
- * @throws {NetworkError} When network request fails
72
- */
73
13
  export declare function updateUserTask(taskId: string, request: UpdateUserTaskRequest, options?: UserTaskOptions): Promise<UserTask>;
74
- /**
75
- * Deletes a user task.
76
- *
77
- * @param taskId - Task ID
78
- * @param options - Optional configuration
79
- * @throws {ConfigurationError} When required environment variables are missing
80
- * @throws {ApiError} When API request fails
81
- * @throws {NetworkError} When network request fails
82
- */
83
14
  export declare function deleteUserTask(taskId: string, options?: UserTaskOptions): Promise<void>;
84
- /**
85
- * Gets task input data.
86
- *
87
- * @param taskId - Task ID
88
- * @param options - Optional configuration
89
- * @returns Promise resolving to task input data
90
- * @throws {ConfigurationError} When required environment variables are missing
91
- * @throws {ApiError} When API request fails
92
- * @throws {NetworkError} When network request fails
93
- */
94
15
  export declare function getTaskInput(taskId: string, options?: UserTaskOptions): Promise<Record<string, unknown>>;
95
- /**
96
- * Gets task output data.
97
- *
98
- * @param taskId - Task ID
99
- * @param options - Optional configuration
100
- * @returns Promise resolving to task output data
101
- * @throws {ConfigurationError} When required environment variables are missing
102
- * @throws {ApiError} When API request fails
103
- * @throws {NetworkError} When network request fails
104
- */
105
16
  export declare function getTaskOutput(taskId: string, options?: UserTaskOptions): Promise<Record<string, unknown>>;
106
- /**
107
- * Updates task input data.
108
- *
109
- * @param taskId - Task ID
110
- * @param taskInput - New task input data
111
- * @param options - Optional configuration
112
- * @returns Promise resolving to updated task
113
- * @throws {ConfigurationError} When required environment variables are missing
114
- * @throws {ApiError} When API request fails
115
- * @throws {NetworkError} When network request fails
116
- */
117
17
  export declare function updateTaskInput(taskId: string, taskInput: Record<string, unknown>, options?: UserTaskOptions): Promise<UserTask>;
118
- /**
119
- * Updates task output data.
120
- *
121
- * @param taskId - Task ID
122
- * @param taskOutput - New task output data
123
- * @param options - Optional configuration
124
- * @returns Promise resolving to updated task
125
- * @throws {ConfigurationError} When required environment variables are missing
126
- * @throws {ApiError} When API request fails
127
- * @throws {NetworkError} When network request fails
128
- */
129
18
  export declare function updateTaskOutput(taskId: string, taskOutput: Record<string, unknown>, options?: UserTaskOptions): Promise<UserTask>;
130
- /**
131
- * Gets task status.
132
- *
133
- * @param taskId - Task ID
134
- * @param options - Optional configuration
135
- * @returns Promise resolving to task status
136
- * @throws {ConfigurationError} When required environment variables are missing
137
- * @throws {ApiError} When API request fails
138
- * @throws {NetworkError} When network request fails
139
- */
140
19
  export declare function getTaskStatus(taskId: string, options?: UserTaskOptions): Promise<string>;
141
- /**
142
- * Updates task status.
143
- *
144
- * @param taskId - Task ID
145
- * @param request - Status update request
146
- * @param options - Optional configuration
147
- * @returns Promise resolving to updated task
148
- * @throws {ConfigurationError} When required environment variables are missing
149
- * @throws {ApiError} When API request fails
150
- * @throws {NetworkError} When network request fails
151
- */
152
20
  export declare function updateTaskStatus(taskId: string, request: UpdateTaskStatusRequest, options?: UserTaskOptions): Promise<UserTask>;
153
- /**
154
- * Gets task statistics.
155
- *
156
- * @param userId - Optional user ID filter
157
- * @param options - Optional configuration
158
- * @returns Promise resolving to task statistics
159
- * @throws {ConfigurationError} When required environment variables are missing
160
- * @throws {ApiError} When API request fails
161
- * @throws {NetworkError} When network request fails
162
- */
163
21
  export declare function getTaskStatistics(userId?: string, options?: UserTaskOptions): Promise<TaskStatistics>;
22
+ export declare function getTaskFrozenStatus(taskId: string, options?: UserTaskOptions): Promise<TaskFrozenStatusResponse>;
23
+ export declare function updateTaskFrozenStatus(taskId: string, request: UpdateTaskFrozenStatusRequest, options?: UserTaskOptions): Promise<TaskFrozenStatusResponse>;
24
+ export declare function listTaskAttachments(taskId: string, options?: UserTaskOptions & {
25
+ page?: number;
26
+ size?: number;
27
+ sort?: string;
28
+ }): Promise<PageResponse<Attachment>>;
29
+ export declare function getTaskAttachment(taskId: string, attachmentId: string, options?: UserTaskOptions): Promise<Attachment>;
30
+ export declare function uploadTaskAttachment(taskId: string, attachmentTypeId: string, file: File | Blob, remark?: string, options?: UserTaskOptions): Promise<Attachment>;
31
+ export declare function deleteTaskAttachment(taskId: string, attachmentId: string, options?: UserTaskOptions): Promise<void>;