@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.
- package/README.md +6 -6
- 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/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/types.d.ts +47 -63
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -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/user/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { ApiError, ConfigurationError, NetworkError } from "../errors.js";
|
|
|
20
20
|
* nickname: 'John Doe',
|
|
21
21
|
* email: 'john@example.com'
|
|
22
22
|
* });
|
|
23
|
-
* console.log('User created:', result.user.
|
|
23
|
+
* console.log('User created:', result.user.userId);
|
|
24
24
|
* } catch (error) {
|
|
25
25
|
* console.error('Failed to create user:', error.message);
|
|
26
26
|
* }
|
|
@@ -39,7 +39,7 @@ export async function createUser(userData, options) {
|
|
|
39
39
|
if (!base) {
|
|
40
40
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
41
41
|
}
|
|
42
|
-
const url = String(base).replace(/\/+$/, "") + "/account/
|
|
42
|
+
const url = String(base).replace(/\/+$/, "") + "/account/v2/user";
|
|
43
43
|
let response;
|
|
44
44
|
try {
|
|
45
45
|
response = await globalThis.fetch(url, {
|
|
@@ -76,7 +76,7 @@ export async function createUser(userData, options) {
|
|
|
76
76
|
/**
|
|
77
77
|
* Retrieves user information by ID or open ID.
|
|
78
78
|
*
|
|
79
|
-
* @param userId - Optional user ID (
|
|
79
|
+
* @param userId - Optional user ID (openId) to query. If not provided, returns current user info
|
|
80
80
|
* @param options - Optional parameters for inclusion flags and configuration
|
|
81
81
|
* @returns Promise resolving to the user information
|
|
82
82
|
* @throws {ConfigurationError} When required environment variables are missing
|
|
@@ -88,7 +88,7 @@ export async function createUser(userData, options) {
|
|
|
88
88
|
* import { getUserById } from '@tale/client';
|
|
89
89
|
*
|
|
90
90
|
* try {
|
|
91
|
-
* const result = await getUserById('
|
|
91
|
+
* const result = await getUserById('userOpenId_here');
|
|
92
92
|
* console.log('User info:', result.user.username);
|
|
93
93
|
* } catch (error) {
|
|
94
94
|
* console.error('Failed to get user:', error.message);
|
|
@@ -105,14 +105,14 @@ export async function getUserById(userId, options) {
|
|
|
105
105
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
106
106
|
}
|
|
107
107
|
// Build URL with query parameters
|
|
108
|
-
const url = new URL(String(base).replace(/\/+$/, "") + "/account/
|
|
108
|
+
const url = new URL(String(base).replace(/\/+$/, "") + "/account/v2/user");
|
|
109
109
|
// Add query parameters
|
|
110
110
|
const queryParams = {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
userId: userId,
|
|
112
|
+
includeRbac: true,
|
|
113
|
+
includeLoginMethods: true,
|
|
114
|
+
includeUserGroups: true,
|
|
115
|
+
includeAcl: false,
|
|
116
116
|
...options,
|
|
117
117
|
};
|
|
118
118
|
Object.entries(queryParams).forEach(([key, value]) => {
|
|
@@ -155,7 +155,7 @@ export async function getUserById(userId, options) {
|
|
|
155
155
|
/**
|
|
156
156
|
* Deletes a user by ID or open ID.
|
|
157
157
|
*
|
|
158
|
-
* @param userId - User ID (
|
|
158
|
+
* @param userId - User ID (openId) to delete
|
|
159
159
|
* @param options - Optional configuration for the request
|
|
160
160
|
* @returns Promise resolving to the deletion result
|
|
161
161
|
* @throws {ConfigurationError} When required environment variables are missing
|
|
@@ -167,7 +167,7 @@ export async function getUserById(userId, options) {
|
|
|
167
167
|
* import { deleteUser } from '@tale/client';
|
|
168
168
|
*
|
|
169
169
|
* try {
|
|
170
|
-
* const result = await deleteUser('
|
|
170
|
+
* const result = await deleteUser('userOpenId_here');
|
|
171
171
|
* console.log('User deleted:', result.deleted);
|
|
172
172
|
* } catch (error) {
|
|
173
173
|
* console.error('Failed to delete user:', error.message);
|
|
@@ -177,7 +177,7 @@ export async function getUserById(userId, options) {
|
|
|
177
177
|
export async function deleteUser(userId, options) {
|
|
178
178
|
// Validate required fields
|
|
179
179
|
if (!userId || userId.trim() === "") {
|
|
180
|
-
throw new ApiError("
|
|
180
|
+
throw new ApiError("userId is required for deletion", 400, "9400");
|
|
181
181
|
}
|
|
182
182
|
// Use provided app token or get one from token service
|
|
183
183
|
const token = options?.appToken ?? (await getAppToken(options));
|
|
@@ -188,7 +188,7 @@ export async function deleteUser(userId, options) {
|
|
|
188
188
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
189
189
|
}
|
|
190
190
|
const url = String(base).replace(/\/+$/, "") +
|
|
191
|
-
`/account/
|
|
191
|
+
`/account/v2/users/${encodeURIComponent(userId)}`;
|
|
192
192
|
let response;
|
|
193
193
|
try {
|
|
194
194
|
response = await globalThis.fetch(url, {
|
|
@@ -239,10 +239,9 @@ export async function deleteUser(userId, options) {
|
|
|
239
239
|
* page: 0,
|
|
240
240
|
* size: 20,
|
|
241
241
|
* keyword: 'john',
|
|
242
|
-
*
|
|
243
|
-
* sort_direction: 'asc'
|
|
242
|
+
* sort: 'username,asc'
|
|
244
243
|
* });
|
|
245
|
-
* console.log(`Found ${result.
|
|
244
|
+
* console.log(`Found ${result.total} users`);
|
|
246
245
|
* console.log('First user:', result.content[0].user.username);
|
|
247
246
|
* } catch (error) {
|
|
248
247
|
* console.error('Failed to list users:', error.message);
|
|
@@ -259,25 +258,24 @@ export async function listUsers(options) {
|
|
|
259
258
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
260
259
|
}
|
|
261
260
|
// Build URL with query parameters
|
|
262
|
-
const url = new URL(String(base).replace(/\/+$/, "") + "/account/
|
|
261
|
+
const url = new URL(String(base).replace(/\/+$/, "") + "/account/v2/users");
|
|
263
262
|
// Add query parameters with defaults
|
|
264
263
|
const queryParams = {
|
|
265
264
|
page: 0,
|
|
266
265
|
size: 20,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
include_attributes: false,
|
|
266
|
+
sort: "createdAt,desc",
|
|
267
|
+
includeAttributes: false,
|
|
270
268
|
...options,
|
|
271
269
|
};
|
|
272
270
|
// Handle array parameters (need to be comma-separated)
|
|
273
|
-
if (queryParams.
|
|
274
|
-
url.searchParams.append("
|
|
271
|
+
if (queryParams.userGroups && queryParams.userGroups.length > 0) {
|
|
272
|
+
url.searchParams.append("userGroups", queryParams.userGroups.join(","));
|
|
275
273
|
}
|
|
276
|
-
if (queryParams.
|
|
277
|
-
url.searchParams.append("
|
|
274
|
+
if (queryParams.userRoles && queryParams.userRoles.length > 0) {
|
|
275
|
+
url.searchParams.append("userRoles", queryParams.userRoles.join(","));
|
|
278
276
|
}
|
|
279
|
-
if (queryParams.
|
|
280
|
-
url.searchParams.append("
|
|
277
|
+
if (queryParams.userIds && queryParams.userIds.length > 0) {
|
|
278
|
+
url.searchParams.append("userIds", queryParams.userIds.join(","));
|
|
281
279
|
}
|
|
282
280
|
// Add other parameters
|
|
283
281
|
if (queryParams.page !== undefined) {
|
|
@@ -286,17 +284,14 @@ export async function listUsers(options) {
|
|
|
286
284
|
if (queryParams.size !== undefined) {
|
|
287
285
|
url.searchParams.append("size", String(queryParams.size));
|
|
288
286
|
}
|
|
289
|
-
if (queryParams.
|
|
290
|
-
url.searchParams.append("
|
|
291
|
-
}
|
|
292
|
-
if (queryParams.sort_direction) {
|
|
293
|
-
url.searchParams.append("sort_direction", queryParams.sort_direction);
|
|
287
|
+
if (queryParams.sort) {
|
|
288
|
+
url.searchParams.append("sort", queryParams.sort);
|
|
294
289
|
}
|
|
295
290
|
if (queryParams.keyword) {
|
|
296
291
|
url.searchParams.append("keyword", queryParams.keyword);
|
|
297
292
|
}
|
|
298
|
-
if (queryParams.
|
|
299
|
-
url.searchParams.append("
|
|
293
|
+
if (queryParams.includeAttributes !== undefined) {
|
|
294
|
+
url.searchParams.append("includeAttributes", String(queryParams.includeAttributes));
|
|
300
295
|
}
|
|
301
296
|
let response;
|
|
302
297
|
try {
|
|
@@ -333,7 +328,7 @@ export async function listUsers(options) {
|
|
|
333
328
|
/**
|
|
334
329
|
* Updates user information by user ID or open ID.
|
|
335
330
|
*
|
|
336
|
-
* @param userId - User ID (
|
|
331
|
+
* @param userId - User ID (openId) to update
|
|
337
332
|
* @param userData - User data to update
|
|
338
333
|
* @param options - Optional configuration for the request
|
|
339
334
|
* @returns Promise resolving to the update result
|
|
@@ -346,8 +341,8 @@ export async function listUsers(options) {
|
|
|
346
341
|
* import { updateUser } from '@tale/client';
|
|
347
342
|
*
|
|
348
343
|
* try {
|
|
349
|
-
* const result = await updateUser('
|
|
350
|
-
*
|
|
344
|
+
* const result = await updateUser('userOpenId_here', {
|
|
345
|
+
* nickName: 'John Doe',
|
|
351
346
|
* email: 'john@example.com'
|
|
352
347
|
* });
|
|
353
348
|
* console.log('User updated:', result.success);
|
|
@@ -370,7 +365,7 @@ export async function updateUser(userId, userData, options) {
|
|
|
370
365
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
371
366
|
}
|
|
372
367
|
const url = String(base).replace(/\/+$/, "") +
|
|
373
|
-
`/account/
|
|
368
|
+
`/account/v2/user/${encodeURIComponent(userId)}`;
|
|
374
369
|
let response;
|
|
375
370
|
try {
|
|
376
371
|
response = await globalThis.fetch(url, {
|
|
@@ -400,13 +395,13 @@ export async function updateUser(userId, userData, options) {
|
|
|
400
395
|
}
|
|
401
396
|
return {
|
|
402
397
|
success: true,
|
|
403
|
-
|
|
398
|
+
userId: userId,
|
|
404
399
|
};
|
|
405
400
|
}
|
|
406
401
|
/**
|
|
407
402
|
* Updates user password.
|
|
408
403
|
*
|
|
409
|
-
* @param passwordData - Password data including
|
|
404
|
+
* @param passwordData - Password data including userId and encrypted password
|
|
410
405
|
* @param options - Optional configuration for the request
|
|
411
406
|
* @returns Promise resolving to the update result
|
|
412
407
|
* @throws {ConfigurationError} When required environment variables are missing
|
|
@@ -419,8 +414,8 @@ export async function updateUser(userId, userData, options) {
|
|
|
419
414
|
*
|
|
420
415
|
* try {
|
|
421
416
|
* const result = await updateUserPassword({
|
|
422
|
-
*
|
|
423
|
-
*
|
|
417
|
+
* userId: 'userOpenId_here',
|
|
418
|
+
* passwordEncrypted: 'encrypted_password_here'
|
|
424
419
|
* });
|
|
425
420
|
* console.log('Password updated:', result.success);
|
|
426
421
|
* } catch (error) {
|
|
@@ -430,12 +425,12 @@ export async function updateUser(userId, userData, options) {
|
|
|
430
425
|
*/
|
|
431
426
|
export async function updateUserPassword(passwordData, options) {
|
|
432
427
|
// Validate required fields
|
|
433
|
-
if (!passwordData.
|
|
434
|
-
throw new ApiError("
|
|
428
|
+
if (!passwordData.userId || passwordData.userId.trim() === "") {
|
|
429
|
+
throw new ApiError("userId is required for password update", 400, "9400");
|
|
435
430
|
}
|
|
436
|
-
if (!passwordData.
|
|
437
|
-
passwordData.
|
|
438
|
-
throw new ApiError("
|
|
431
|
+
if (!passwordData.passwordEncrypted ||
|
|
432
|
+
passwordData.passwordEncrypted.trim() === "") {
|
|
433
|
+
throw new ApiError("passwordEncrypted is required", 400, "9400");
|
|
439
434
|
}
|
|
440
435
|
// Use provided app token or get one from token service
|
|
441
436
|
const token = options?.appToken ?? (await getAppToken(options));
|
|
@@ -445,7 +440,7 @@ export async function updateUserPassword(passwordData, options) {
|
|
|
445
440
|
if (!base) {
|
|
446
441
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
447
442
|
}
|
|
448
|
-
const url = String(base).replace(/\/+$/, "") + "/account/
|
|
443
|
+
const url = String(base).replace(/\/+$/, "") + "/account/v2/user/password";
|
|
449
444
|
let response;
|
|
450
445
|
try {
|
|
451
446
|
response = await globalThis.fetch(url, {
|
|
@@ -475,14 +470,14 @@ export async function updateUserPassword(passwordData, options) {
|
|
|
475
470
|
}
|
|
476
471
|
return {
|
|
477
472
|
success: true,
|
|
478
|
-
|
|
473
|
+
userId: passwordData.userId,
|
|
479
474
|
};
|
|
480
475
|
}
|
|
481
476
|
/**
|
|
482
477
|
* Uploads user avatar image.
|
|
483
478
|
*
|
|
484
479
|
* @param file - File object to upload as avatar
|
|
485
|
-
* @param userId - User ID (
|
|
480
|
+
* @param userId - User ID (openId) of the user
|
|
486
481
|
* @param options - Optional configuration for the request
|
|
487
482
|
* @returns Promise resolving to the upload result with avatar OSS key
|
|
488
483
|
* @throws {ConfigurationError} When required environment variables are missing
|
|
@@ -496,8 +491,8 @@ export async function updateUserPassword(passwordData, options) {
|
|
|
496
491
|
* try {
|
|
497
492
|
* const fileInput = document.querySelector('input[type="file"]');
|
|
498
493
|
* const file = fileInput.files[0];
|
|
499
|
-
* const result = await uploadAvatar(file, '
|
|
500
|
-
* console.log('Avatar uploaded:', result.
|
|
494
|
+
* const result = await uploadAvatar(file, 'userOpenId_here');
|
|
495
|
+
* console.log('Avatar uploaded:', result.avatarOssKey);
|
|
501
496
|
* } catch (error) {
|
|
502
497
|
* console.error('Failed to upload avatar:', error.message);
|
|
503
498
|
* }
|
|
@@ -519,11 +514,11 @@ export async function uploadAvatar(file, userId, options) {
|
|
|
519
514
|
if (!base) {
|
|
520
515
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
521
516
|
}
|
|
522
|
-
const url = String(base).replace(/\/+$/, "") + "/account/
|
|
517
|
+
const url = String(base).replace(/\/+$/, "") + "/account/v2/user/avatar/upload";
|
|
523
518
|
// Create FormData
|
|
524
519
|
const formData = new FormData();
|
|
525
520
|
formData.append("file", file);
|
|
526
|
-
formData.append("
|
|
521
|
+
formData.append("userOpenId", userId);
|
|
527
522
|
let response;
|
|
528
523
|
try {
|
|
529
524
|
response = await globalThis.fetch(url, {
|
|
@@ -551,8 +546,8 @@ export async function uploadAvatar(file, userId, options) {
|
|
|
551
546
|
throw new ApiError(errorMsg, response.status, json.code);
|
|
552
547
|
}
|
|
553
548
|
// Validate response structure
|
|
554
|
-
if (!json.data || !json.data.
|
|
555
|
-
throw new ApiError("Invalid avatar upload response: missing
|
|
549
|
+
if (!json.data || !json.data.avatarOssKey) {
|
|
550
|
+
throw new ApiError("Invalid avatar upload response: missing avatarOssKey", response.status);
|
|
556
551
|
}
|
|
557
552
|
return json.data;
|
|
558
553
|
}
|
|
@@ -629,8 +624,8 @@ export async function getAvatarPresignedUrl(ossKey, options) {
|
|
|
629
624
|
/**
|
|
630
625
|
* Updates user frozen status (freeze or unfreeze a user account).
|
|
631
626
|
*
|
|
632
|
-
* @param userId - User ID (
|
|
633
|
-
* @param frozenData - Frozen status data including
|
|
627
|
+
* @param userId - User ID (openId) to update frozen status
|
|
628
|
+
* @param frozenData - Frozen status data including isFrozen flag and optional remark
|
|
634
629
|
* @param options - Optional configuration for the request
|
|
635
630
|
* @returns Promise resolving to the updated frozen status information
|
|
636
631
|
* @throws {ConfigurationError} When required environment variables are missing
|
|
@@ -643,18 +638,18 @@ export async function getAvatarPresignedUrl(ossKey, options) {
|
|
|
643
638
|
*
|
|
644
639
|
* try {
|
|
645
640
|
* // Freeze a user account
|
|
646
|
-
* const result = await updateUserFrozenStatus('
|
|
647
|
-
*
|
|
641
|
+
* const result = await updateUserFrozenStatus('userOpenId_here', {
|
|
642
|
+
* isFrozen: true,
|
|
648
643
|
* remark: 'Violated community guidelines'
|
|
649
644
|
* });
|
|
650
|
-
* console.log('User frozen:', result.
|
|
645
|
+
* console.log('User frozen:', result.isFrozen);
|
|
651
646
|
*
|
|
652
647
|
* // Unfreeze a user account
|
|
653
|
-
* const unfrozenResult = await updateUserFrozenStatus('
|
|
654
|
-
*
|
|
648
|
+
* const unfrozenResult = await updateUserFrozenStatus('userOpenId_here', {
|
|
649
|
+
* isFrozen: false,
|
|
655
650
|
* remark: 'Account reactivated'
|
|
656
651
|
* });
|
|
657
|
-
* console.log('User unfrozen:', !unfrozenResult.
|
|
652
|
+
* console.log('User unfrozen:', !unfrozenResult.isFrozen);
|
|
658
653
|
* } catch (error) {
|
|
659
654
|
* console.error('Failed to update frozen status:', error.message);
|
|
660
655
|
* }
|
|
@@ -665,8 +660,8 @@ export async function updateUserFrozenStatus(userId, frozenData, options) {
|
|
|
665
660
|
if (!userId || userId.trim() === "") {
|
|
666
661
|
throw new ApiError("userId is required for updating frozen status", 400, "9400");
|
|
667
662
|
}
|
|
668
|
-
if (frozenData.
|
|
669
|
-
throw new ApiError("
|
|
663
|
+
if (frozenData.isFrozen === undefined || frozenData.isFrozen === null) {
|
|
664
|
+
throw new ApiError("isFrozen is required", 400, "9400");
|
|
670
665
|
}
|
|
671
666
|
// Use provided app token or get one from token service
|
|
672
667
|
const token = options?.appToken ?? (await getAppToken(options));
|
|
@@ -677,7 +672,7 @@ export async function updateUserFrozenStatus(userId, frozenData, options) {
|
|
|
677
672
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
678
673
|
}
|
|
679
674
|
const url = String(base).replace(/\/+$/, "") +
|
|
680
|
-
`/account/
|
|
675
|
+
`/account/v2/user/${encodeURIComponent(userId)}/frozen-status`;
|
|
681
676
|
let response;
|
|
682
677
|
try {
|
|
683
678
|
response = await globalThis.fetch(url, {
|
|
@@ -708,7 +703,7 @@ export async function updateUserFrozenStatus(userId, frozenData, options) {
|
|
|
708
703
|
throw new ApiError(errorMsg, response.status, json.code);
|
|
709
704
|
}
|
|
710
705
|
// Validate response structure
|
|
711
|
-
if (!json.data || json.data.
|
|
706
|
+
if (!json.data || json.data.userId === undefined) {
|
|
712
707
|
throw new ApiError("Invalid frozen status update response: missing required data", response.status);
|
|
713
708
|
}
|
|
714
709
|
return json.data;
|
|
@@ -716,7 +711,7 @@ export async function updateUserFrozenStatus(userId, frozenData, options) {
|
|
|
716
711
|
/**
|
|
717
712
|
* Gets user frozen status by user ID.
|
|
718
713
|
*
|
|
719
|
-
* @param userId - User ID (
|
|
714
|
+
* @param userId - User ID (openId) to query frozen status
|
|
720
715
|
* @param options - Optional configuration for the request
|
|
721
716
|
* @returns Promise resolving to the user frozen status information
|
|
722
717
|
* @throws {ConfigurationError} When required environment variables are missing
|
|
@@ -728,10 +723,10 @@ export async function updateUserFrozenStatus(userId, frozenData, options) {
|
|
|
728
723
|
* import { getUserFrozenStatus } from '@tale/client';
|
|
729
724
|
*
|
|
730
725
|
* try {
|
|
731
|
-
* const status = await getUserFrozenStatus('
|
|
732
|
-
* console.log('User is frozen:', status.
|
|
726
|
+
* const status = await getUserFrozenStatus('userOpenId_here');
|
|
727
|
+
* console.log('User is frozen:', status.isFrozen);
|
|
733
728
|
* console.log('Remark:', status.remark);
|
|
734
|
-
* console.log('Last updated:', status.
|
|
729
|
+
* console.log('Last updated:', status.updatedAt);
|
|
735
730
|
* } catch (error) {
|
|
736
731
|
* console.error('Failed to get frozen status:', error.message);
|
|
737
732
|
* }
|
|
@@ -751,7 +746,7 @@ export async function getUserFrozenStatus(userId, options) {
|
|
|
751
746
|
throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
|
|
752
747
|
}
|
|
753
748
|
const url = String(base).replace(/\/+$/, "") +
|
|
754
|
-
`/account/
|
|
749
|
+
`/account/v2/user/${encodeURIComponent(userId)}/frozen-status`;
|
|
755
750
|
let response;
|
|
756
751
|
try {
|
|
757
752
|
response = await globalThis.fetch(url, {
|
|
@@ -779,7 +774,7 @@ export async function getUserFrozenStatus(userId, options) {
|
|
|
779
774
|
throw new ApiError(errorMsg, response.status, json.code);
|
|
780
775
|
}
|
|
781
776
|
// Validate response structure
|
|
782
|
-
if (!json.data || json.data.
|
|
777
|
+
if (!json.data || json.data.userId === undefined) {
|
|
783
778
|
throw new ApiError("Invalid frozen status response: missing required data", response.status);
|
|
784
779
|
}
|
|
785
780
|
return json.data;
|
package/dist/user/types.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import type { UserAttributeItemDTO } from "../user-attribute/types.js";
|
|
|
3
3
|
export type { AppInfo, User, UserGroup, Role, Privilege, CommonOptions, PageResponse, UserAttributeItemDTO, };
|
|
4
4
|
export interface CreateUserRequest {
|
|
5
5
|
username: string;
|
|
6
|
-
|
|
6
|
+
passwordEncrypted?: string;
|
|
7
7
|
nickname?: string;
|
|
8
8
|
phone?: string;
|
|
9
9
|
email?: string;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
avatarUrl?: string;
|
|
11
|
+
roleIds?: string[];
|
|
12
12
|
}
|
|
13
13
|
export interface UserLoginMethod {
|
|
14
14
|
method: string;
|
|
@@ -17,10 +17,10 @@ export interface UserLoginMethod {
|
|
|
17
17
|
export interface CreateUserResponse {
|
|
18
18
|
app: AppInfo;
|
|
19
19
|
user: User;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
userRoles: Role[];
|
|
21
|
+
userPrivileges: Privilege[];
|
|
22
|
+
userGroups: UserGroup[];
|
|
23
|
+
userLoginMethods: UserLoginMethod[];
|
|
24
24
|
}
|
|
25
25
|
export interface CreateUserJson {
|
|
26
26
|
data: CreateUserResponse;
|
|
@@ -34,15 +34,15 @@ export interface CreateUserOptions {
|
|
|
34
34
|
appToken?: string;
|
|
35
35
|
}
|
|
36
36
|
export interface GetUserRequest {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
userId?: string;
|
|
38
|
+
includeRbac?: boolean;
|
|
39
|
+
includeLoginMethods?: boolean;
|
|
40
|
+
includeUserGroups?: boolean;
|
|
41
|
+
includeAcl?: boolean;
|
|
42
42
|
}
|
|
43
43
|
export interface DeleteUserResponse {
|
|
44
44
|
deleted: boolean;
|
|
45
|
-
|
|
45
|
+
userId: string;
|
|
46
46
|
}
|
|
47
47
|
export interface DeleteUserJson {
|
|
48
48
|
data: DeleteUserResponse;
|
|
@@ -52,21 +52,20 @@ export interface DeleteUserJson {
|
|
|
52
52
|
export interface ListUsersRequest {
|
|
53
53
|
page?: number;
|
|
54
54
|
size?: number;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
user_ids?: string[];
|
|
55
|
+
sort?: string;
|
|
56
|
+
userGroups?: string[];
|
|
57
|
+
userRoles?: string[];
|
|
58
|
+
userIds?: string[];
|
|
60
59
|
keyword?: string;
|
|
61
|
-
|
|
60
|
+
includeAttributes?: boolean;
|
|
62
61
|
}
|
|
63
62
|
export interface UserListItem {
|
|
64
63
|
app: AppInfo;
|
|
65
64
|
user: User;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
userRoles: Role[];
|
|
66
|
+
userPrivileges: Privilege[];
|
|
67
|
+
userGroups: UserGroup[];
|
|
68
|
+
userAttributes?: UserAttributeItemDTO[];
|
|
70
69
|
}
|
|
71
70
|
export interface ListUsersResponse extends PageResponse<UserListItem> {
|
|
72
71
|
content: UserListItem[];
|
|
@@ -78,14 +77,14 @@ export interface ListUsersJson {
|
|
|
78
77
|
}
|
|
79
78
|
export interface UpdateUserRequest {
|
|
80
79
|
username?: string;
|
|
81
|
-
|
|
80
|
+
nickname?: string;
|
|
82
81
|
email?: string;
|
|
83
82
|
phone?: string;
|
|
84
83
|
remark?: string;
|
|
85
84
|
}
|
|
86
85
|
export interface UpdateUserResponse {
|
|
87
86
|
success: boolean;
|
|
88
|
-
|
|
87
|
+
userId: string;
|
|
89
88
|
}
|
|
90
89
|
export interface UpdateUserJson {
|
|
91
90
|
data?: UpdateUserResponse;
|
|
@@ -93,12 +92,12 @@ export interface UpdateUserJson {
|
|
|
93
92
|
msg: string;
|
|
94
93
|
}
|
|
95
94
|
export interface UpdateUserPasswordRequest {
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
userId: string;
|
|
96
|
+
passwordEncrypted: string;
|
|
98
97
|
}
|
|
99
98
|
export interface UpdateUserPasswordResponse {
|
|
100
99
|
success: boolean;
|
|
101
|
-
|
|
100
|
+
userId: string;
|
|
102
101
|
}
|
|
103
102
|
export interface UpdateUserPasswordJson {
|
|
104
103
|
data?: UpdateUserPasswordResponse;
|
|
@@ -106,7 +105,7 @@ export interface UpdateUserPasswordJson {
|
|
|
106
105
|
msg: string;
|
|
107
106
|
}
|
|
108
107
|
export interface UploadAvatarResponse {
|
|
109
|
-
|
|
108
|
+
avatarOssKey: string;
|
|
110
109
|
}
|
|
111
110
|
export interface UploadAvatarJson {
|
|
112
111
|
data: UploadAvatarResponse;
|
|
@@ -124,14 +123,14 @@ export interface AvatarPresignedUrlJson {
|
|
|
124
123
|
msg: string;
|
|
125
124
|
}
|
|
126
125
|
export interface UpdateUserFrozenStatusRequest {
|
|
127
|
-
|
|
126
|
+
isFrozen: boolean;
|
|
128
127
|
remark?: string;
|
|
129
128
|
}
|
|
130
129
|
export interface UserFrozenStatusResponse {
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
userId: string;
|
|
131
|
+
isFrozen: boolean;
|
|
133
132
|
remark: string;
|
|
134
|
-
|
|
133
|
+
updatedAt: string;
|
|
135
134
|
}
|
|
136
135
|
export interface UpdateUserFrozenStatusJson {
|
|
137
136
|
data: UserFrozenStatusResponse;
|
|
@@ -14,10 +14,10 @@ export type { UserAttributeDefinition, UserAttributeDTO, UserAttributeItemDTO, U
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
16
16
|
* const definition = await createUserAttributeDefinition({
|
|
17
|
-
*
|
|
17
|
+
* attributeName: "department",
|
|
18
18
|
* description: "User's department",
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* schemaDefinition: { type: "string" },
|
|
20
|
+
* isEnabled: true,
|
|
21
21
|
* });
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
@@ -169,10 +169,7 @@ export declare function listUserAttributes(userId: string, request?: ListUserAtt
|
|
|
169
169
|
* @throws {ApiError} When API request fails
|
|
170
170
|
* @throws {NetworkError} When network request fails
|
|
171
171
|
*/
|
|
172
|
-
export declare function listAttributeUsers(attributeDefinitionId: string, request?: ListUserAttributesRequest & UserAttributeOptions): Promise<
|
|
173
|
-
content: UserAttributeDTO[];
|
|
174
|
-
totalElements: number;
|
|
175
|
-
}>;
|
|
172
|
+
export declare function listAttributeUsers(attributeDefinitionId: string, request?: ListUserAttributesRequest & UserAttributeOptions): Promise<PageResponse<UserAttributeDTO>>;
|
|
176
173
|
/**
|
|
177
174
|
* Lists all user attributes grouped by user with pagination.
|
|
178
175
|
*
|