@turinhub/tale-js-sdk 1.3.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/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/acl/index.d.ts +295 -0
- package/dist/acl/index.js +653 -0
- package/dist/acl/types.d.ts +142 -0
- package/dist/acl/types.js +1 -0
- package/dist/auth/index.d.ts +166 -0
- package/dist/auth/index.js +522 -0
- package/dist/auth/types.d.ts +127 -0
- package/dist/auth/types.js +1 -0
- package/dist/cms/file.d.ts +398 -0
- package/dist/cms/file.js +800 -0
- package/dist/cms/folder.d.ts +128 -0
- package/dist/cms/folder.js +294 -0
- package/dist/cms/index.d.ts +3 -0
- package/dist/cms/index.js +6 -0
- package/dist/cms/types.d.ts +157 -0
- package/dist/cms/types.js +1 -0
- package/dist/common/types.d.ts +91 -0
- package/dist/common/types.js +2 -0
- package/dist/errors.d.ts +52 -0
- package/dist/errors.js +109 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +12 -0
- package/dist/rbac/acl.d.ts +152 -0
- package/dist/rbac/acl.js +723 -0
- package/dist/rbac/index.d.ts +464 -0
- package/dist/rbac/index.js +1121 -0
- package/dist/rbac/rbac.d.ts +198 -0
- package/dist/rbac/rbac.js +984 -0
- package/dist/rbac/types.d.ts +125 -0
- package/dist/rbac/types.js +1 -0
- package/dist/rbac/user-group.d.ts +122 -0
- package/dist/rbac/user-group.js +570 -0
- package/dist/status.d.ts +40 -0
- package/dist/status.js +56 -0
- package/dist/task/index.d.ts +163 -0
- package/dist/task/index.js +495 -0
- package/dist/task/types.d.ts +116 -0
- package/dist/task/types.js +1 -0
- package/dist/task-type/index.d.ts +92 -0
- package/dist/task-type/index.js +256 -0
- package/dist/task-type/types.d.ts +54 -0
- package/dist/task-type/types.js +1 -0
- package/dist/token.d.ts +21 -0
- package/dist/token.js +114 -0
- package/dist/user/index.d.ts +267 -0
- package/dist/user/index.js +786 -0
- package/dist/user/types.d.ts +145 -0
- package/dist/user/types.js +1 -0
- package/dist/user-attribute/index.d.ts +186 -0
- package/dist/user-attribute/index.js +615 -0
- package/dist/user-attribute/types.d.ts +109 -0
- package/dist/user-attribute/types.js +1 -0
- package/dist/user-group/index.d.ts +231 -0
- package/dist/user-group/index.js +566 -0
- package/dist/user-group/types.d.ts +50 -0
- package/dist/user-group/types.js +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import type { CreateUserRequest, AppInfo, User, Role, Privilege, UserGroup, UserLoginMethod, CreateUserResponse, CreateUserJson, CreateUserOptions, GetUserRequest, DeleteUserResponse, DeleteUserJson, CommonOptions, ListUsersRequest, UserAttributeItemDTO, UserListItem, ListUsersResponse, ListUsersJson, UpdateUserRequest, UpdateUserResponse, UpdateUserJson, UpdateUserPasswordRequest, UpdateUserPasswordResponse, UpdateUserPasswordJson, UploadAvatarResponse, UploadAvatarJson, AvatarPresignedUrlResponse, AvatarPresignedUrlJson, UpdateUserFrozenStatusRequest, UserFrozenStatusResponse, UpdateUserFrozenStatusJson, GetUserFrozenStatusJson } from "./types.js";
|
|
2
|
+
export type { CreateUserRequest, AppInfo, User, Role, Privilege, UserGroup, UserLoginMethod, CreateUserResponse, CreateUserJson, CreateUserOptions, GetUserRequest, DeleteUserResponse, DeleteUserJson, CommonOptions, ListUsersRequest, UserAttributeItemDTO, UserListItem, ListUsersResponse, ListUsersJson, UpdateUserRequest, UpdateUserResponse, UpdateUserJson, UpdateUserPasswordRequest, UpdateUserPasswordResponse, UpdateUserPasswordJson, UploadAvatarResponse, UploadAvatarJson, AvatarPresignedUrlResponse, AvatarPresignedUrlJson, UpdateUserFrozenStatusRequest, UserFrozenStatusResponse, UpdateUserFrozenStatusJson, GetUserFrozenStatusJson, };
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new user in the Tale application.
|
|
5
|
+
*
|
|
6
|
+
* @param userData - User data to create the new user
|
|
7
|
+
* @param options - Optional configuration for the request
|
|
8
|
+
* @returns Promise resolving to the created user information
|
|
9
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
10
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
11
|
+
* @throws {NetworkError} When network request fails
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createUser } from '@tale/client';
|
|
16
|
+
*
|
|
17
|
+
* try {
|
|
18
|
+
* const result = await createUser({
|
|
19
|
+
* username: 'john_doe',
|
|
20
|
+
* nickname: 'John Doe',
|
|
21
|
+
* email: 'john@example.com'
|
|
22
|
+
* });
|
|
23
|
+
* console.log('User created:', result.user.user_id);
|
|
24
|
+
* } catch (error) {
|
|
25
|
+
* console.error('Failed to create user:', error.message);
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createUser(userData: CreateUserRequest, options?: CreateUserOptions): Promise<CreateUserResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves user information by ID or open ID.
|
|
32
|
+
*
|
|
33
|
+
* @param userId - Optional user ID (open_id) to query. If not provided, returns current user info
|
|
34
|
+
* @param options - Optional parameters for inclusion flags and configuration
|
|
35
|
+
* @returns Promise resolving to the user information
|
|
36
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
37
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
38
|
+
* @throws {NetworkError} When network request fails
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { getUserById } from '@tale/client';
|
|
43
|
+
*
|
|
44
|
+
* try {
|
|
45
|
+
* const result = await getUserById('user_open_id_here');
|
|
46
|
+
* console.log('User info:', result.user.username);
|
|
47
|
+
* } catch (error) {
|
|
48
|
+
* console.error('Failed to get user:', error.message);
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function getUserById(userId?: string, options?: GetUserRequest & CommonOptions): Promise<CreateUserResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Deletes a user by ID or open ID.
|
|
55
|
+
*
|
|
56
|
+
* @param userId - User ID (open_id) to delete
|
|
57
|
+
* @param options - Optional configuration for the request
|
|
58
|
+
* @returns Promise resolving to the deletion result
|
|
59
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
60
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
61
|
+
* @throws {NetworkError} When network request fails
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { deleteUser } from '@tale/client';
|
|
66
|
+
*
|
|
67
|
+
* try {
|
|
68
|
+
* const result = await deleteUser('user_open_id_here');
|
|
69
|
+
* console.log('User deleted:', result.deleted);
|
|
70
|
+
* } catch (error) {
|
|
71
|
+
* console.error('Failed to delete user:', error.message);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function deleteUser(userId: string, options?: CommonOptions): Promise<DeleteUserResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Lists users with pagination, filtering, and search capabilities.
|
|
78
|
+
*
|
|
79
|
+
* @param options - Optional parameters for pagination, filtering, and configuration
|
|
80
|
+
* @returns Promise resolving to paginated user list with metadata
|
|
81
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
82
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
83
|
+
* @throws {NetworkError} When network request fails
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* import { listUsers } from '@tale/client';
|
|
88
|
+
*
|
|
89
|
+
* try {
|
|
90
|
+
* const result = await listUsers({
|
|
91
|
+
* page: 0,
|
|
92
|
+
* size: 20,
|
|
93
|
+
* keyword: 'john',
|
|
94
|
+
* sort_by: 'username',
|
|
95
|
+
* sort_direction: 'asc'
|
|
96
|
+
* });
|
|
97
|
+
* console.log(`Found ${result.totalElements} users`);
|
|
98
|
+
* console.log('First user:', result.content[0].user.username);
|
|
99
|
+
* } catch (error) {
|
|
100
|
+
* console.error('Failed to list users:', error.message);
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function listUsers(options?: ListUsersRequest & CommonOptions): Promise<ListUsersResponse>;
|
|
105
|
+
/**
|
|
106
|
+
* Updates user information by user ID or open ID.
|
|
107
|
+
*
|
|
108
|
+
* @param userId - User ID (open_id) to update
|
|
109
|
+
* @param userData - User data to update
|
|
110
|
+
* @param options - Optional configuration for the request
|
|
111
|
+
* @returns Promise resolving to the update result
|
|
112
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
113
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
114
|
+
* @throws {NetworkError} When network request fails
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* import { updateUser } from '@tale/client';
|
|
119
|
+
*
|
|
120
|
+
* try {
|
|
121
|
+
* const result = await updateUser('user_open_id_here', {
|
|
122
|
+
* nick_name: 'John Doe',
|
|
123
|
+
* email: 'john@example.com'
|
|
124
|
+
* });
|
|
125
|
+
* console.log('User updated:', result.success);
|
|
126
|
+
* } catch (error) {
|
|
127
|
+
* console.error('Failed to update user:', error.message);
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export declare function updateUser(userId: string, userData: UpdateUserRequest, options?: CommonOptions): Promise<UpdateUserResponse>;
|
|
132
|
+
/**
|
|
133
|
+
* Updates user password.
|
|
134
|
+
*
|
|
135
|
+
* @param passwordData - Password data including user_id and encrypted password
|
|
136
|
+
* @param options - Optional configuration for the request
|
|
137
|
+
* @returns Promise resolving to the update result
|
|
138
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
139
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
140
|
+
* @throws {NetworkError} When network request fails
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* import { updateUserPassword } from '@tale/client';
|
|
145
|
+
*
|
|
146
|
+
* try {
|
|
147
|
+
* const result = await updateUserPassword({
|
|
148
|
+
* user_id: 'user_open_id_here',
|
|
149
|
+
* password_encrypted: 'encrypted_password_here'
|
|
150
|
+
* });
|
|
151
|
+
* console.log('Password updated:', result.success);
|
|
152
|
+
* } catch (error) {
|
|
153
|
+
* console.error('Failed to update password:', error.message);
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare function updateUserPassword(passwordData: UpdateUserPasswordRequest, options?: CommonOptions): Promise<UpdateUserPasswordResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Uploads user avatar image.
|
|
160
|
+
*
|
|
161
|
+
* @param file - File object to upload as avatar
|
|
162
|
+
* @param userId - User ID (open_id) of the user
|
|
163
|
+
* @param options - Optional configuration for the request
|
|
164
|
+
* @returns Promise resolving to the upload result with avatar OSS key
|
|
165
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
166
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
167
|
+
* @throws {NetworkError} When network request fails
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* import { uploadAvatar } from '@tale/client';
|
|
172
|
+
*
|
|
173
|
+
* try {
|
|
174
|
+
* const fileInput = document.querySelector('input[type="file"]');
|
|
175
|
+
* const file = fileInput.files[0];
|
|
176
|
+
* const result = await uploadAvatar(file, 'user_open_id_here');
|
|
177
|
+
* console.log('Avatar uploaded:', result.avatar_oss_key);
|
|
178
|
+
* } catch (error) {
|
|
179
|
+
* console.error('Failed to upload avatar:', error.message);
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare function uploadAvatar(file: File, userId: string, options?: CommonOptions): Promise<UploadAvatarResponse>;
|
|
184
|
+
/**
|
|
185
|
+
* Gets presigned URL for avatar access.
|
|
186
|
+
*
|
|
187
|
+
* @param ossKey - OSS key of the avatar
|
|
188
|
+
* @param options - Optional configuration for the request
|
|
189
|
+
* @returns Promise resolving to presigned URL information
|
|
190
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
191
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
192
|
+
* @throws {NetworkError} When network request fails
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* import { getAvatarPresignedUrl } from '@tale/client';
|
|
197
|
+
*
|
|
198
|
+
* try {
|
|
199
|
+
* const result = await getAvatarPresignedUrl('avatars/user123.jpg');
|
|
200
|
+
* console.log('Presigned URL:', result.presignedUrl);
|
|
201
|
+
* console.log('Expires in:', result.expireTimeInSeconds, 'seconds');
|
|
202
|
+
* } catch (error) {
|
|
203
|
+
* console.error('Failed to get presigned URL:', error.message);
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export declare function getAvatarPresignedUrl(ossKey: string, options?: CommonOptions): Promise<AvatarPresignedUrlResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* Updates user frozen status (freeze or unfreeze a user account).
|
|
210
|
+
*
|
|
211
|
+
* @param userId - User ID (open_id) to update frozen status
|
|
212
|
+
* @param frozenData - Frozen status data including is_frozen flag and optional remark
|
|
213
|
+
* @param options - Optional configuration for the request
|
|
214
|
+
* @returns Promise resolving to the updated frozen status information
|
|
215
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
216
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
217
|
+
* @throws {NetworkError} When network request fails
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* import { updateUserFrozenStatus } from '@tale/client';
|
|
222
|
+
*
|
|
223
|
+
* try {
|
|
224
|
+
* // Freeze a user account
|
|
225
|
+
* const result = await updateUserFrozenStatus('user_open_id_here', {
|
|
226
|
+
* is_frozen: true,
|
|
227
|
+
* remark: 'Violated community guidelines'
|
|
228
|
+
* });
|
|
229
|
+
* console.log('User frozen:', result.is_frozen);
|
|
230
|
+
*
|
|
231
|
+
* // Unfreeze a user account
|
|
232
|
+
* const unfrozenResult = await updateUserFrozenStatus('user_open_id_here', {
|
|
233
|
+
* is_frozen: false,
|
|
234
|
+
* remark: 'Account reactivated'
|
|
235
|
+
* });
|
|
236
|
+
* console.log('User unfrozen:', !unfrozenResult.is_frozen);
|
|
237
|
+
* } catch (error) {
|
|
238
|
+
* console.error('Failed to update frozen status:', error.message);
|
|
239
|
+
* }
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export declare function updateUserFrozenStatus(userId: string, frozenData: UpdateUserFrozenStatusRequest, options?: CommonOptions): Promise<UserFrozenStatusResponse>;
|
|
243
|
+
/**
|
|
244
|
+
* Gets user frozen status by user ID.
|
|
245
|
+
*
|
|
246
|
+
* @param userId - User ID (open_id) to query frozen status
|
|
247
|
+
* @param options - Optional configuration for the request
|
|
248
|
+
* @returns Promise resolving to the user frozen status information
|
|
249
|
+
* @throws {ConfigurationError} When required environment variables are missing
|
|
250
|
+
* @throws {ApiError} When API request fails or returns invalid response
|
|
251
|
+
* @throws {NetworkError} When network request fails
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* import { getUserFrozenStatus } from '@tale/client';
|
|
256
|
+
*
|
|
257
|
+
* try {
|
|
258
|
+
* const status = await getUserFrozenStatus('user_open_id_here');
|
|
259
|
+
* console.log('User is frozen:', status.is_frozen);
|
|
260
|
+
* console.log('Remark:', status.remark);
|
|
261
|
+
* console.log('Last updated:', status.updated_at);
|
|
262
|
+
* } catch (error) {
|
|
263
|
+
* console.error('Failed to get frozen status:', error.message);
|
|
264
|
+
* }
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare function getUserFrozenStatus(userId: string, options?: CommonOptions): Promise<UserFrozenStatusResponse>;
|