tale-js-sdk 0.1.2 → 0.1.4
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/dist/acl/index.d.ts +170 -0
- package/dist/acl/index.js +747 -0
- package/dist/acl/types.d.ts +208 -0
- package/dist/acl/types.js +1 -0
- package/dist/auth/index.d.ts +2 -134
- package/dist/auth/index.js +120 -96
- package/dist/auth/types.d.ts +122 -0
- package/dist/auth/types.js +1 -0
- package/dist/common/types.d.ts +82 -0
- package/dist/common/types.js +2 -0
- package/dist/errors.js +18 -18
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/rbac/acl.d.ts +152 -0
- package/dist/rbac/acl.js +723 -0
- package/dist/rbac/index.d.ts +2 -0
- package/dist/rbac/index.js +2 -0
- package/dist/rbac/rbac.d.ts +198 -0
- package/dist/rbac/rbac.js +984 -0
- package/dist/rbac/types.d.ts +356 -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.js +3 -3
- package/dist/token.d.ts +1 -1
- package/dist/token.js +5 -4
- package/dist/user/index.d.ts +165 -142
- package/dist/user/index.js +511 -59
- package/dist/user/types.d.ts +149 -0
- package/dist/user/types.js +1 -0
- package/dist/user-group/index.d.ts +230 -0
- package/dist/user-group/index.js +560 -0
- package/dist/user-group/types.d.ts +64 -0
- package/dist/user-group/types.js +1 -0
- package/package.json +4 -3
- package/dist/auth.d.ts +0 -271
- package/dist/auth.js +0 -461
- package/dist/client.d.ts +0 -20
- package/dist/client.js +0 -62
- package/dist/info.d.ts +0 -9
- package/dist/info.js +0 -18
- package/dist/package.json +0 -36
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/info.d.ts +0 -6
- package/dist/src/info.js +0 -4
- package/dist/user.d.ts +0 -242
- package/dist/user.js +0 -331
package/dist/user/index.d.ts
CHANGED
|
@@ -1,145 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
password_encrypted?: string;
|
|
4
|
-
nickname?: string;
|
|
5
|
-
phone?: string;
|
|
6
|
-
email?: string;
|
|
7
|
-
avatar_url?: string;
|
|
8
|
-
role_ids?: string[];
|
|
9
|
-
}
|
|
10
|
-
export interface AppInfo {
|
|
11
|
-
app_id: string;
|
|
12
|
-
org_id: string;
|
|
13
|
-
app_key: string;
|
|
14
|
-
app_name: string;
|
|
15
|
-
}
|
|
16
|
-
export interface User {
|
|
17
|
-
user_id: string;
|
|
18
|
-
nick_name: string;
|
|
19
|
-
avatar_url: string;
|
|
20
|
-
username: string;
|
|
21
|
-
email: string;
|
|
22
|
-
phone: string;
|
|
23
|
-
registered_at: string;
|
|
24
|
-
remark: string | null;
|
|
25
|
-
is_frozen: boolean;
|
|
26
|
-
latest_login_time?: string;
|
|
27
|
-
}
|
|
28
|
-
export interface Role {
|
|
29
|
-
role_id: string;
|
|
30
|
-
role_name: string;
|
|
31
|
-
description?: string;
|
|
32
|
-
}
|
|
33
|
-
export interface Privilege {
|
|
34
|
-
privilege_id: string;
|
|
35
|
-
privilege_name: string;
|
|
36
|
-
description?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface UserGroup {
|
|
39
|
-
group_id: string;
|
|
40
|
-
group_name: string;
|
|
41
|
-
description?: string;
|
|
42
|
-
}
|
|
43
|
-
export interface UserLoginMethod {
|
|
44
|
-
method: string;
|
|
45
|
-
enabled: boolean;
|
|
46
|
-
}
|
|
47
|
-
export interface CreateUserResponse {
|
|
48
|
-
app: AppInfo;
|
|
49
|
-
user: User;
|
|
50
|
-
user_roles: Role[];
|
|
51
|
-
user_privileges: Privilege[];
|
|
52
|
-
user_groups: UserGroup[];
|
|
53
|
-
user_login_methods: UserLoginMethod[];
|
|
54
|
-
}
|
|
55
|
-
export interface CreateUserJson {
|
|
56
|
-
data: CreateUserResponse;
|
|
57
|
-
code: number;
|
|
58
|
-
msg: string;
|
|
59
|
-
}
|
|
60
|
-
export interface CreateUserOptions {
|
|
61
|
-
baseUrl?: string;
|
|
62
|
-
appKey?: string;
|
|
63
|
-
appSecret?: string;
|
|
64
|
-
appToken?: string;
|
|
65
|
-
}
|
|
66
|
-
export interface GetUserRequest {
|
|
67
|
-
user_id?: string;
|
|
68
|
-
include_rbac?: boolean;
|
|
69
|
-
include_login_methods?: boolean;
|
|
70
|
-
include_user_groups?: boolean;
|
|
71
|
-
include_acl?: boolean;
|
|
72
|
-
}
|
|
73
|
-
export interface DeleteUserResponse {
|
|
74
|
-
deleted: boolean;
|
|
75
|
-
user_id: string;
|
|
76
|
-
}
|
|
77
|
-
export interface DeleteUserJson {
|
|
78
|
-
data: DeleteUserResponse;
|
|
79
|
-
code: number;
|
|
80
|
-
msg: string;
|
|
81
|
-
}
|
|
82
|
-
export interface CommonOptions {
|
|
83
|
-
baseUrl?: string;
|
|
84
|
-
appKey?: string;
|
|
85
|
-
appSecret?: string;
|
|
86
|
-
appToken?: string;
|
|
87
|
-
}
|
|
88
|
-
export interface ListUsersRequest {
|
|
89
|
-
page?: number;
|
|
90
|
-
size?: number;
|
|
91
|
-
sort_by?: string;
|
|
92
|
-
sort_direction?: 'asc' | 'desc';
|
|
93
|
-
user_groups?: string[];
|
|
94
|
-
user_roles?: string[];
|
|
95
|
-
user_ids?: string[];
|
|
96
|
-
keyword?: string;
|
|
97
|
-
include_attributes?: boolean;
|
|
98
|
-
}
|
|
99
|
-
export interface UserAttribute {
|
|
100
|
-
attribute_id: string;
|
|
101
|
-
attribute_name: string;
|
|
102
|
-
attribute_value: string;
|
|
103
|
-
}
|
|
104
|
-
export interface UserListItem {
|
|
105
|
-
app: AppInfo;
|
|
106
|
-
user: User;
|
|
107
|
-
user_roles: Role[];
|
|
108
|
-
user_privileges: Privilege[];
|
|
109
|
-
user_groups: UserGroup[];
|
|
110
|
-
user_attributes?: UserAttribute[];
|
|
111
|
-
}
|
|
112
|
-
export interface Sort {
|
|
113
|
-
empty: boolean;
|
|
114
|
-
sorted: boolean;
|
|
115
|
-
unsorted: boolean;
|
|
116
|
-
}
|
|
117
|
-
export interface Pageable {
|
|
118
|
-
sort: Sort;
|
|
119
|
-
offset: number;
|
|
120
|
-
pageNumber: number;
|
|
121
|
-
pageSize: number;
|
|
122
|
-
paged: boolean;
|
|
123
|
-
unpaged: boolean;
|
|
124
|
-
}
|
|
125
|
-
export interface ListUsersResponse {
|
|
126
|
-
content: UserListItem[];
|
|
127
|
-
pageable: Pageable;
|
|
128
|
-
last: boolean;
|
|
129
|
-
totalPages: number;
|
|
130
|
-
totalElements: number;
|
|
131
|
-
size: number;
|
|
132
|
-
number: number;
|
|
133
|
-
sort: Sort;
|
|
134
|
-
first: boolean;
|
|
135
|
-
numberOfElements: number;
|
|
136
|
-
empty: boolean;
|
|
137
|
-
}
|
|
138
|
-
export interface ListUsersJson {
|
|
139
|
-
data: ListUsersResponse;
|
|
140
|
-
code: number;
|
|
141
|
-
msg: string;
|
|
142
|
-
}
|
|
1
|
+
import type { CreateUserRequest, AppInfo, User, Role, Privilege, UserGroup, UserLoginMethod, CreateUserResponse, CreateUserJson, CreateUserOptions, GetUserRequest, DeleteUserResponse, DeleteUserJson, CommonOptions, ListUsersRequest, UserAttribute, 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, UserAttribute, UserListItem, ListUsersResponse, ListUsersJson, UpdateUserRequest, UpdateUserResponse, UpdateUserJson, UpdateUserPasswordRequest, UpdateUserPasswordResponse, UpdateUserPasswordJson, UploadAvatarResponse, UploadAvatarJson, AvatarPresignedUrlResponse, AvatarPresignedUrlJson, UpdateUserFrozenStatusRequest, UserFrozenStatusResponse, UpdateUserFrozenStatusJson, GetUserFrozenStatusJson, };
|
|
143
3
|
/**
|
|
144
4
|
* Creates a new user in the Tale application.
|
|
145
5
|
*
|
|
@@ -242,3 +102,166 @@ export declare function deleteUser(userId: string, options?: CommonOptions): Pro
|
|
|
242
102
|
* ```
|
|
243
103
|
*/
|
|
244
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>;
|