tale-js-sdk 0.1.2 → 0.1.3

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 (48) hide show
  1. package/dist/acl/index.d.ts +170 -0
  2. package/dist/acl/index.js +747 -0
  3. package/dist/acl/types.d.ts +208 -0
  4. package/dist/acl/types.js +1 -0
  5. package/dist/auth/index.d.ts +2 -134
  6. package/dist/auth/index.js +120 -96
  7. package/dist/auth/types.d.ts +122 -0
  8. package/dist/auth/types.js +1 -0
  9. package/dist/common/types.d.ts +76 -0
  10. package/dist/common/types.js +3 -0
  11. package/dist/errors.js +18 -18
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +2 -0
  14. package/dist/rbac/acl.d.ts +152 -0
  15. package/dist/rbac/acl.js +723 -0
  16. package/dist/rbac/index.d.ts +2 -0
  17. package/dist/rbac/index.js +2 -0
  18. package/dist/rbac/rbac.d.ts +198 -0
  19. package/dist/rbac/rbac.js +984 -0
  20. package/dist/rbac/types.d.ts +356 -0
  21. package/dist/rbac/types.js +1 -0
  22. package/dist/rbac/user-group.d.ts +122 -0
  23. package/dist/rbac/user-group.js +570 -0
  24. package/dist/status.js +3 -3
  25. package/dist/token.d.ts +1 -1
  26. package/dist/token.js +5 -4
  27. package/dist/user/index.d.ts +2 -142
  28. package/dist/user/index.js +60 -59
  29. package/dist/user/types.d.ts +96 -0
  30. package/dist/user/types.js +1 -0
  31. package/dist/user-group/index.d.ts +230 -0
  32. package/dist/user-group/index.js +560 -0
  33. package/dist/user-group/types.d.ts +61 -0
  34. package/dist/user-group/types.js +1 -0
  35. package/package.json +13 -14
  36. package/dist/auth.d.ts +0 -271
  37. package/dist/auth.js +0 -461
  38. package/dist/client.d.ts +0 -20
  39. package/dist/client.js +0 -62
  40. package/dist/info.d.ts +0 -9
  41. package/dist/info.js +0 -18
  42. package/dist/package.json +0 -36
  43. package/dist/src/index.d.ts +0 -1
  44. package/dist/src/index.js +0 -1
  45. package/dist/src/info.d.ts +0 -6
  46. package/dist/src/info.js +0 -4
  47. package/dist/user.d.ts +0 -242
  48. package/dist/user.js +0 -331
@@ -0,0 +1,560 @@
1
+ import { getAppToken } from "../token.js";
2
+ import { ApiError, ConfigurationError, NetworkError } from "../errors.js";
3
+ // ==================== Functions ====================
4
+ /**
5
+ * Gets a user group by ID.
6
+ *
7
+ * @param groupId - User group ID
8
+ * @param options - Optional configuration
9
+ * @returns Promise resolving to user group information
10
+ * @throws {ConfigurationError} When required environment variables are missing
11
+ * @throws {ApiError} When API request fails
12
+ * @throws {NetworkError} When network request fails
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { getUserGroup } from '@tale/client';
17
+ *
18
+ * try {
19
+ * const group = await getUserGroup('group_id_here');
20
+ * console.log('Group name:', group.name);
21
+ * } catch (error) {
22
+ * console.error('Failed to get user group:', error.message);
23
+ * }
24
+ * ```
25
+ */
26
+ export async function getUserGroup(groupId, options) {
27
+ if (!groupId || groupId.trim() === "") {
28
+ throw new ApiError("groupId is required", 400, "9400");
29
+ }
30
+ const token = options?.appToken ?? (await getAppToken(options));
31
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
32
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
33
+ if (!base) {
34
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
35
+ }
36
+ const url = String(base).replace(/\/+$/, "") +
37
+ `/user-group/v1/${encodeURIComponent(groupId)}`;
38
+ let response;
39
+ try {
40
+ response = await globalThis.fetch(url, {
41
+ method: "GET",
42
+ headers: {
43
+ "Content-Type": "application/json",
44
+ "x-t-token": token,
45
+ },
46
+ });
47
+ }
48
+ catch (error) {
49
+ throw new NetworkError(`Failed to get user group: ${error instanceof Error ? error.message : "Unknown error"}`);
50
+ }
51
+ const json = (await response.json());
52
+ if (json.code !== 200) {
53
+ const errorMsg = typeof json.msg === "string" ? json.msg : "Failed to get user group";
54
+ throw new ApiError(errorMsg, response.status, json.code);
55
+ }
56
+ if (!json.data) {
57
+ throw new ApiError("Invalid user group response: missing data", response.status);
58
+ }
59
+ return json.data;
60
+ }
61
+ /**
62
+ * Lists user groups with pagination and optional keyword filtering.
63
+ *
64
+ * @param options - Optional parameters for pagination and filtering
65
+ * @returns Promise resolving to paginated user group list
66
+ * @throws {ConfigurationError} When required environment variables are missing
67
+ * @throws {ApiError} When API request fails
68
+ * @throws {NetworkError} When network request fails
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * import { listUserGroups } from '@tale/client';
73
+ *
74
+ * try {
75
+ * const result = await listUserGroups({
76
+ * page: 0,
77
+ * size: 20,
78
+ * keyword: 'admin'
79
+ * });
80
+ * console.log(`Found ${result.totalElements} user groups`);
81
+ * } catch (error) {
82
+ * console.error('Failed to list user groups:', error.message);
83
+ * }
84
+ * ```
85
+ */
86
+ export async function listUserGroups(options) {
87
+ const token = options?.appToken ?? (await getAppToken(options));
88
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
89
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
90
+ if (!base) {
91
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
92
+ }
93
+ const url = new URL(String(base).replace(/\/+$/, "") + "/user-group/v1");
94
+ const queryParams = {
95
+ page: 0,
96
+ size: 10,
97
+ ...options,
98
+ };
99
+ Object.entries(queryParams).forEach(([key, value]) => {
100
+ if (value !== undefined) {
101
+ url.searchParams.append(key, String(value));
102
+ }
103
+ });
104
+ let response;
105
+ try {
106
+ response = await globalThis.fetch(url.toString(), {
107
+ method: "GET",
108
+ headers: {
109
+ "Content-Type": "application/json",
110
+ "x-t-token": token,
111
+ },
112
+ });
113
+ }
114
+ catch (error) {
115
+ throw new NetworkError(`Failed to list user groups: ${error instanceof Error ? error.message : "Unknown error"}`);
116
+ }
117
+ const json = (await response.json());
118
+ if (json.code !== 200) {
119
+ const errorMsg = typeof json.msg === "string" ? json.msg : "Failed to list user groups";
120
+ throw new ApiError(errorMsg, response.status, json.code);
121
+ }
122
+ if (!json.data || !Array.isArray(json.data.content)) {
123
+ throw new ApiError("Invalid user groups response: missing data", response.status);
124
+ }
125
+ return json.data;
126
+ }
127
+ /**
128
+ * Creates a new user group.
129
+ *
130
+ * @param request - User group creation request
131
+ * @param options - Optional configuration
132
+ * @returns Promise resolving to created user group
133
+ * @throws {ConfigurationError} When required environment variables are missing
134
+ * @throws {ApiError} When API request fails
135
+ * @throws {NetworkError} When network request fails
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * import { createUserGroup } from '@tale/client';
140
+ *
141
+ * try {
142
+ * const group = await createUserGroup({
143
+ * name: 'Administrators',
144
+ * description: 'Admin users',
145
+ * type: 'system'
146
+ * });
147
+ * console.log('Group created:', group.group_id);
148
+ * } catch (error) {
149
+ * console.error('Failed to create user group:', error.message);
150
+ * }
151
+ * ```
152
+ */
153
+ export async function createUserGroup(request, options) {
154
+ if (!request.name || request.name.trim() === "") {
155
+ throw new ApiError("name is required", 400, "9400");
156
+ }
157
+ const token = options?.appToken ?? (await getAppToken(options));
158
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
159
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
160
+ if (!base) {
161
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
162
+ }
163
+ const url = String(base).replace(/\/+$/, "") + "/user-group/v1";
164
+ let response;
165
+ try {
166
+ response = await globalThis.fetch(url, {
167
+ method: "POST",
168
+ headers: {
169
+ "Content-Type": "application/json",
170
+ "x-t-token": token,
171
+ },
172
+ body: JSON.stringify(request),
173
+ });
174
+ }
175
+ catch (error) {
176
+ throw new NetworkError(`Failed to create user group: ${error instanceof Error ? error.message : "Unknown error"}`);
177
+ }
178
+ const json = (await response.json());
179
+ if (json.code !== 200) {
180
+ const errorMsg = typeof json.msg === "string" ? json.msg : "Failed to create user group";
181
+ throw new ApiError(errorMsg, response.status, json.code);
182
+ }
183
+ if (!json.data) {
184
+ throw new ApiError("Invalid user group creation response: missing data", response.status);
185
+ }
186
+ return json.data;
187
+ }
188
+ /**
189
+ * Updates an existing user group.
190
+ *
191
+ * @param groupId - User group ID to update
192
+ * @param request - Update request with fields to modify
193
+ * @param options - Optional configuration
194
+ * @returns Promise resolving to updated user group
195
+ * @throws {ConfigurationError} When required environment variables are missing
196
+ * @throws {ApiError} When API request fails
197
+ * @throws {NetworkError} When network request fails
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * import { updateUserGroup } from '@tale/client';
202
+ *
203
+ * try {
204
+ * const group = await updateUserGroup('group_id_here', {
205
+ * name: 'Updated Name',
206
+ * description: 'Updated description'
207
+ * });
208
+ * console.log('Group updated:', group.name);
209
+ * } catch (error) {
210
+ * console.error('Failed to update user group:', error.message);
211
+ * }
212
+ * ```
213
+ */
214
+ export async function updateUserGroup(groupId, request, options) {
215
+ if (!groupId || groupId.trim() === "") {
216
+ throw new ApiError("groupId is required", 400, "9400");
217
+ }
218
+ const token = options?.appToken ?? (await getAppToken(options));
219
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
220
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
221
+ if (!base) {
222
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
223
+ }
224
+ const url = String(base).replace(/\/+$/, "") +
225
+ `/user-group/v1/${encodeURIComponent(groupId)}`;
226
+ let response;
227
+ try {
228
+ response = await globalThis.fetch(url, {
229
+ method: "PUT",
230
+ headers: {
231
+ "Content-Type": "application/json",
232
+ "x-t-token": token,
233
+ },
234
+ body: JSON.stringify(request),
235
+ });
236
+ }
237
+ catch (error) {
238
+ throw new NetworkError(`Failed to update user group: ${error instanceof Error ? error.message : "Unknown error"}`);
239
+ }
240
+ const json = (await response.json());
241
+ if (json.code !== 200) {
242
+ const errorMsg = typeof json.msg === "string" ? json.msg : "Failed to update user group";
243
+ throw new ApiError(errorMsg, response.status, json.code);
244
+ }
245
+ if (!json.data) {
246
+ throw new ApiError("Invalid user group update response: missing data", response.status);
247
+ }
248
+ return json.data;
249
+ }
250
+ /**
251
+ * Deletes a user group.
252
+ *
253
+ * @param groupId - User group ID to delete
254
+ * @param options - Optional configuration
255
+ * @returns Promise that resolves when deletion is successful
256
+ * @throws {ConfigurationError} When required environment variables are missing
257
+ * @throws {ApiError} When API request fails
258
+ * @throws {NetworkError} When network request fails
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * import { deleteUserGroup } from '@tale/client';
263
+ *
264
+ * try {
265
+ * await deleteUserGroup('group_id_here');
266
+ * console.log('Group deleted successfully');
267
+ * } catch (error) {
268
+ * console.error('Failed to delete user group:', error.message);
269
+ * }
270
+ * ```
271
+ */
272
+ export async function deleteUserGroup(groupId, options) {
273
+ if (!groupId || groupId.trim() === "") {
274
+ throw new ApiError("groupId is required", 400, "9400");
275
+ }
276
+ const token = options?.appToken ?? (await getAppToken(options));
277
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
278
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
279
+ if (!base) {
280
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
281
+ }
282
+ const url = String(base).replace(/\/+$/, "") +
283
+ `/user-group/v1/${encodeURIComponent(groupId)}`;
284
+ let response;
285
+ try {
286
+ response = await globalThis.fetch(url, {
287
+ method: "DELETE",
288
+ headers: {
289
+ "Content-Type": "application/json",
290
+ "x-t-token": token,
291
+ },
292
+ });
293
+ }
294
+ catch (error) {
295
+ throw new NetworkError(`Failed to delete user group: ${error instanceof Error ? error.message : "Unknown error"}`);
296
+ }
297
+ const json = (await response.json());
298
+ if (json.code !== 200) {
299
+ const errorMsg = typeof json.msg === "string" ? json.msg : "Failed to delete user group";
300
+ throw new ApiError(errorMsg, response.status, json.code);
301
+ }
302
+ }
303
+ /**
304
+ * Gets members of a user group with pagination.
305
+ *
306
+ * @param groupId - User group ID
307
+ * @param options - Optional parameters for pagination
308
+ * @returns Promise resolving to paginated member list
309
+ * @throws {ConfigurationError} When required environment variables are missing
310
+ * @throws {ApiError} When API request fails
311
+ * @throws {NetworkError} When network request fails
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * import { listUserGroupMembers } from '@tale/client';
316
+ *
317
+ * try {
318
+ * const result = await listUserGroupMembers('group_id_here', {
319
+ * page: 0,
320
+ * size: 20
321
+ * });
322
+ * console.log(`Found ${result.totalElements} members`);
323
+ * } catch (error) {
324
+ * console.error('Failed to list user group members:', error.message);
325
+ * }
326
+ * ```
327
+ */
328
+ export async function listUserGroupMembers(groupId, options) {
329
+ if (!groupId || groupId.trim() === "") {
330
+ throw new ApiError("groupId is required", 400, "9400");
331
+ }
332
+ const token = options?.appToken ?? (await getAppToken(options));
333
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
334
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
335
+ if (!base) {
336
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
337
+ }
338
+ const url = new URL(String(base).replace(/\/+$/, "") +
339
+ `/user-group/v1/${encodeURIComponent(groupId)}/members`);
340
+ const queryParams = {
341
+ page: 0,
342
+ size: 10,
343
+ ...options,
344
+ };
345
+ Object.entries(queryParams).forEach(([key, value]) => {
346
+ if (value !== undefined) {
347
+ url.searchParams.append(key, String(value));
348
+ }
349
+ });
350
+ let response;
351
+ try {
352
+ response = await globalThis.fetch(url.toString(), {
353
+ method: "GET",
354
+ headers: {
355
+ "Content-Type": "application/json",
356
+ "x-t-token": token,
357
+ },
358
+ });
359
+ }
360
+ catch (error) {
361
+ throw new NetworkError(`Failed to list user group members: ${error instanceof Error ? error.message : "Unknown error"}`);
362
+ }
363
+ const json = (await response.json());
364
+ if (json.code !== 200) {
365
+ const errorMsg = typeof json.msg === "string"
366
+ ? json.msg
367
+ : "Failed to list user group members";
368
+ throw new ApiError(errorMsg, response.status, json.code);
369
+ }
370
+ if (!json.data || !Array.isArray(json.data.content)) {
371
+ throw new ApiError("Invalid user group members response: missing data", response.status);
372
+ }
373
+ return json.data;
374
+ }
375
+ /**
376
+ * Adds members to a user group.
377
+ *
378
+ * @param groupId - User group ID
379
+ * @param request - Request containing user IDs to add
380
+ * @param options - Optional configuration
381
+ * @returns Promise that resolves when members are added
382
+ * @throws {ConfigurationError} When required environment variables are missing
383
+ * @throws {ApiError} When API request fails
384
+ * @throws {NetworkError} When network request fails
385
+ *
386
+ * @example
387
+ * ```typescript
388
+ * import { addUserGroupMembers } from '@tale/client';
389
+ *
390
+ * try {
391
+ * await addUserGroupMembers('group_id_here', {
392
+ * user_ids: ['user1', 'user2', 'user3']
393
+ * });
394
+ * console.log('Members added successfully');
395
+ * } catch (error) {
396
+ * console.error('Failed to add members:', error.message);
397
+ * }
398
+ * ```
399
+ */
400
+ export async function addUserGroupMembers(groupId, request, options) {
401
+ if (!groupId || groupId.trim() === "") {
402
+ throw new ApiError("groupId is required", 400, "9400");
403
+ }
404
+ if (!request.user_ids ||
405
+ !Array.isArray(request.user_ids) ||
406
+ request.user_ids.length === 0) {
407
+ throw new ApiError("user_ids is required and must be a non-empty array", 400, "9400");
408
+ }
409
+ const token = options?.appToken ?? (await getAppToken(options));
410
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
411
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
412
+ if (!base) {
413
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
414
+ }
415
+ const url = String(base).replace(/\/+$/, "") +
416
+ `/user-group/v1/${encodeURIComponent(groupId)}/members`;
417
+ let response;
418
+ try {
419
+ response = await globalThis.fetch(url, {
420
+ method: "POST",
421
+ headers: {
422
+ "Content-Type": "application/json",
423
+ "x-t-token": token,
424
+ },
425
+ body: JSON.stringify(request),
426
+ });
427
+ }
428
+ catch (error) {
429
+ throw new NetworkError(`Failed to add user group members: ${error instanceof Error ? error.message : "Unknown error"}`);
430
+ }
431
+ const json = (await response.json());
432
+ if (json.code !== 200) {
433
+ const errorMsg = typeof json.msg === "string"
434
+ ? json.msg
435
+ : "Failed to add user group members";
436
+ throw new ApiError(errorMsg, response.status, json.code);
437
+ }
438
+ }
439
+ /**
440
+ * Removes members from a user group.
441
+ *
442
+ * @param groupId - User group ID
443
+ * @param request - Request containing user IDs to remove
444
+ * @param options - Optional configuration
445
+ * @returns Promise that resolves when members are removed
446
+ * @throws {ConfigurationError} When required environment variables are missing
447
+ * @throws {ApiError} When API request fails
448
+ * @throws {NetworkError} When network request fails
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * import { removeUserGroupMembers } from '@tale/client';
453
+ *
454
+ * try {
455
+ * await removeUserGroupMembers('group_id_here', {
456
+ * user_ids: ['user1', 'user2']
457
+ * });
458
+ * console.log('Members removed successfully');
459
+ * } catch (error) {
460
+ * console.error('Failed to remove members:', error.message);
461
+ * }
462
+ * ```
463
+ */
464
+ export async function removeUserGroupMembers(groupId, request, options) {
465
+ if (!groupId || groupId.trim() === "") {
466
+ throw new ApiError("groupId is required", 400, "9400");
467
+ }
468
+ if (!request.user_ids ||
469
+ !Array.isArray(request.user_ids) ||
470
+ request.user_ids.length === 0) {
471
+ throw new ApiError("user_ids is required and must be a non-empty array", 400, "9400");
472
+ }
473
+ const token = options?.appToken ?? (await getAppToken(options));
474
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
475
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
476
+ if (!base) {
477
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
478
+ }
479
+ const url = String(base).replace(/\/+$/, "") +
480
+ `/user-group/v1/${encodeURIComponent(groupId)}/members`;
481
+ let response;
482
+ try {
483
+ response = await globalThis.fetch(url, {
484
+ method: "DELETE",
485
+ headers: {
486
+ "Content-Type": "application/json",
487
+ "x-t-token": token,
488
+ },
489
+ body: JSON.stringify(request),
490
+ });
491
+ }
492
+ catch (error) {
493
+ throw new NetworkError(`Failed to remove user group members: ${error instanceof Error ? error.message : "Unknown error"}`);
494
+ }
495
+ const json = (await response.json());
496
+ if (json.code !== 200) {
497
+ const errorMsg = typeof json.msg === "string"
498
+ ? json.msg
499
+ : "Failed to remove user group members";
500
+ throw new ApiError(errorMsg, response.status, json.code);
501
+ }
502
+ }
503
+ /**
504
+ * Gets all user groups that a user belongs to.
505
+ *
506
+ * @param userId - User ID
507
+ * @param options - Optional configuration
508
+ * @returns Promise resolving to list of user groups
509
+ * @throws {ConfigurationError} When required environment variables are missing
510
+ * @throws {ApiError} When API request fails
511
+ * @throws {NetworkError} When network request fails
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * import { getUserGroups } from '@tale/client';
516
+ *
517
+ * try {
518
+ * const groups = await getUserGroups('user_id_here');
519
+ * console.log(`User belongs to ${groups.length} groups`);
520
+ * groups.forEach(group => console.log('-', group.name));
521
+ * } catch (error) {
522
+ * console.error('Failed to get user groups:', error.message);
523
+ * }
524
+ * ```
525
+ */
526
+ export async function getUserGroups(userId, options) {
527
+ if (!userId || userId.trim() === "") {
528
+ throw new ApiError("userId is required", 400, "9400");
529
+ }
530
+ const token = options?.appToken ?? (await getAppToken(options));
531
+ const env = globalThis?.process?.env ?? import.meta?.env ?? undefined;
532
+ const base = options?.baseUrl ?? env?.TALE_BASE_URL ?? undefined;
533
+ if (!base) {
534
+ throw new ConfigurationError("Missing required environment variable: TALE_BASE_URL");
535
+ }
536
+ const url = String(base).replace(/\/+$/, "") +
537
+ `/user-group/v1/by-user/${encodeURIComponent(userId)}`;
538
+ let response;
539
+ try {
540
+ response = await globalThis.fetch(url, {
541
+ method: "GET",
542
+ headers: {
543
+ "Content-Type": "application/json",
544
+ "x-t-token": token,
545
+ },
546
+ });
547
+ }
548
+ catch (error) {
549
+ throw new NetworkError(`Failed to get user groups: ${error instanceof Error ? error.message : "Unknown error"}`);
550
+ }
551
+ const json = (await response.json());
552
+ if (json.code !== 200) {
553
+ const errorMsg = typeof json.msg === "string" ? json.msg : "Failed to get user groups";
554
+ throw new ApiError(errorMsg, response.status, json.code);
555
+ }
556
+ if (!json.data || !Array.isArray(json.data)) {
557
+ throw new ApiError("Invalid user groups response: missing data", response.status);
558
+ }
559
+ return json.data;
560
+ }
@@ -0,0 +1,61 @@
1
+ import type { Sort, Pageable, CommonOptions } from "../user/types.js";
2
+ export interface UserGroupInfo {
3
+ group_id: string;
4
+ name: string;
5
+ description?: string;
6
+ type?: string;
7
+ remark?: string;
8
+ member_count: number;
9
+ created_at: string;
10
+ updated_at: string;
11
+ }
12
+ export interface UserGroupMember {
13
+ user_id: string;
14
+ nickname: string;
15
+ username: string;
16
+ phone: string;
17
+ email: string;
18
+ avatar_url: string;
19
+ is_frozen: boolean;
20
+ created_at: string;
21
+ remark: string;
22
+ }
23
+ export interface CreateUserGroupRequest {
24
+ name: string;
25
+ description?: string;
26
+ type?: string;
27
+ remark?: string;
28
+ }
29
+ export interface UpdateUserGroupRequest {
30
+ name?: string;
31
+ description?: string;
32
+ type?: string;
33
+ remark?: string;
34
+ }
35
+ export interface UserGroupMemberRequest {
36
+ user_ids: string[];
37
+ }
38
+ export interface UserGroupOptions extends CommonOptions {
39
+ }
40
+ export interface ListUserGroupsRequest {
41
+ page?: number;
42
+ size?: number;
43
+ keyword?: string;
44
+ }
45
+ export interface ListUserGroupMembersRequest {
46
+ page?: number;
47
+ size?: number;
48
+ }
49
+ export interface UserGroupPaginatedResponse<T> {
50
+ content: T[];
51
+ pageable: Pageable;
52
+ last: boolean;
53
+ totalPages: number;
54
+ totalElements: number;
55
+ size: number;
56
+ number: number;
57
+ sort: Sort;
58
+ first: boolean;
59
+ numberOfElements: number;
60
+ empty: boolean;
61
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tale-js-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Official TypeScript SDK for Tale backend services",
5
5
  "keywords": [
6
6
  "tale",
@@ -22,15 +22,6 @@
22
22
  "author": "Turinhub <dev@turinhub.com>",
23
23
  "type": "module",
24
24
  "main": "dist/index.js",
25
- "scripts": {
26
- "test": "pnpm run build && node --env-file=.env --experimental-vm-modules ./node_modules/jest/bin/jest.js",
27
- "build": "tsc -p tsconfig.json",
28
- "typecheck": "tsc -p tsconfig.json --noEmit",
29
- "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx}\" \"*.json\" \"*.md\"",
30
- "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx}\" \"*.json\" \"*.md\"",
31
- "docs": "typedoc --entryPoints src/index.ts --out docs",
32
- "docs:md": "typedoc --entryPoints src/index.ts --plugin typedoc-plugin-markdown --hideBreadcrumbs --out docs"
33
- },
34
25
  "devDependencies": {
35
26
  "@types/jest": "^30.0.0",
36
27
  "jest": "^30.2.0",
@@ -39,11 +30,19 @@
39
30
  "typedoc-plugin-markdown": "^4.9.0",
40
31
  "typescript": "^5.9.3"
41
32
  },
42
- "types": "dist/index.d.ts"
43
- ,
33
+ "types": "dist/index.d.ts",
44
34
  "files": [
45
35
  "dist",
46
36
  "README.md",
47
37
  "LICENSE"
48
- ]
49
- }
38
+ ],
39
+ "scripts": {
40
+ "test": "pnpm run build && node --env-file=.env --experimental-vm-modules ./node_modules/jest/bin/jest.js",
41
+ "build": "tsc -p tsconfig.json",
42
+ "typecheck": "tsc -p tsconfig.json --noEmit",
43
+ "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx}\" \"*.json\" \"*.md\"",
44
+ "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx}\" \"*.json\" \"*.md\"",
45
+ "docs": "typedoc --entryPoints src/index.ts --out docs",
46
+ "docs:md": "typedoc --entryPoints src/index.ts --plugin typedoc-plugin-markdown --hideBreadcrumbs --out docs"
47
+ }
48
+ }