@amaster.ai/client 1.1.0-beta.7 → 1.1.0-beta.70

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.
@@ -1,9 +1,5 @@
1
1
  /**
2
- * ============================================================================
3
- * Password Authentication - Type Definitions
4
- * ============================================================================
5
- *
6
- * Password-based authentication including:
2
+ * * Password-based authentication including:
7
3
  * - Email/username/phone + password login
8
4
  * - User registration
9
5
  * - Password change
@@ -20,45 +16,7 @@ import type { User } from './user';
20
16
  * User registration parameters
21
17
  *
22
18
  * At least one identifier (username, email, or phone) must be provided.
23
- *
24
- * @example
25
- * Register with email:
26
- * ```typescript
27
- * await client.auth.register({
28
- * email: 'user@example.com',
29
- * password: 'Password@123',
30
- * displayName: 'John Doe'
31
- * });
32
- * ```
33
- *
34
- * @example
35
- * Register with username and email:
36
- * ```typescript
37
- * await client.auth.register({
38
- * username: 'johndoe',
39
- * email: 'john@example.com',
40
- * password: 'Password@123',
41
- * displayName: 'John Doe'
42
- * });
43
- * ```
44
- *
45
- * @example
46
- * Register with captcha verification:
47
- * ```typescript
48
- * // 1. Get captcha
49
- * const captcha = await client.auth.getCaptcha();
50
- *
51
- * // 2. Show captcha.data.captchaImage to user
52
- * const userInput = prompt('Enter captcha:');
53
- *
54
- * // 3. Register with captcha
55
- * await client.auth.register({
56
- * username: 'johndoe',
57
- * email: 'john@example.com',
58
- * password: 'Password@123',
59
- * captcha: `${captcha.data.captchaId}:${userInput}`
60
- * });
61
- * ```
19
+ *
62
20
  */
63
21
  export interface RegisterParams {
64
22
  /** Username (optional, but one of username/email/phone required) */
@@ -82,7 +40,6 @@ export interface RegisterParams {
82
40
  /**
83
41
  * Captcha verification (optional)
84
42
  * Format: "captchaId:userInput"
85
- * @example "abc-123:XY7K"
86
43
  */
87
44
  captcha?: string;
88
45
  }
@@ -97,34 +54,7 @@ export type LoginType = 'username' | 'email' | 'phone';
97
54
  *
98
55
  * The `loginType` field is optional - it will be auto-detected based on
99
56
  * which identifier field (username/email/phone) you provide.
100
- *
101
- * @example
102
- * Login with email (auto-detect):
103
- * ```typescript
104
- * await client.auth.login({
105
- * email: 'user@example.com',
106
- * password: 'Password@123'
107
- * });
108
- * ```
109
- *
110
- * @example
111
- * Login with username (explicit type):
112
- * ```typescript
113
- * await client.auth.login({
114
- * loginType: 'username',
115
- * username: 'johndoe',
116
- * password: 'Password@123'
117
- * });
118
- * ```
119
- *
120
- * @example
121
- * Login with phone:
122
- * ```typescript
123
- * await client.auth.login({
124
- * phone: '+86-13800138000',
125
- * password: 'Password@123'
126
- * });
127
- * ```
57
+ *
128
58
  */
129
59
  export interface LoginParams {
130
60
  /** Login method (optional, auto-detected if not provided) */
@@ -145,18 +75,7 @@ export interface LoginParams {
145
75
 
146
76
  /**
147
77
  * Change password parameters
148
- *
149
- * @example
150
- * ```typescript
151
- * const result = await client.auth.changePassword({
152
- * oldPassword: 'OldPassword@123',
153
- * newPassword: 'NewPassword@456'
154
- * });
155
- *
156
- * if (result.data?.success) {
157
- * console.log('Password changed successfully');
158
- * }
159
- * ```
78
+ *
160
79
  */
161
80
  export interface ChangePasswordParams {
162
81
  /** Current password (for verification) */
@@ -173,23 +92,7 @@ export interface ChangePasswordParams {
173
92
 
174
93
  /**
175
94
  * Login/Registration response with user info and access token
176
- *
177
- * @example
178
- * ```typescript
179
- * const result = await client.auth.login({
180
- * email: 'user@example.com',
181
- * password: 'password123'
182
- * });
183
- *
184
- * if (result.data) {
185
- * const { user, accessToken } = result.data;
186
- * console.log(`Welcome ${user.displayName}!`);
187
- * console.log(`Token: ${accessToken}`);
188
- *
189
- * // All subsequent requests now include this token automatically
190
- * await client.entity.list('default', 'users');
191
- * }
192
- * ```
95
+ *
193
96
  */
194
97
  export interface LoginResponse {
195
98
  /** User information */
@@ -222,6 +125,8 @@ export interface SuccessResponse {
222
125
  * Password Authentication API
223
126
  *
224
127
  * Methods for password-based authentication and account management.
128
+ *
129
+ * @since 1.0.0
225
130
  */
226
131
  export interface PasswordAuthAPI {
227
132
  /**
@@ -234,30 +139,25 @@ export interface PasswordAuthAPI {
234
139
  * @returns User info and access token (if auto-login enabled)
235
140
  *
236
141
  * @example
237
- * Basic registration:
238
- * ```typescript
142
+ * // Register with email
239
143
  * const result = await client.auth.register({
240
144
  * email: 'user@example.com',
241
- * password: 'Password@123',
145
+ * password: 'SecurePass123',
242
146
  * displayName: 'John Doe'
243
147
  * });
244
148
  *
245
- * if (result.data) {
246
- * console.log('Registration successful!');
247
- * console.log('User:', result.data.user);
149
+ * if (result.success) {
150
+ * console.log('User registered:', result.data.user.uid);
248
151
  * }
249
- * ```
250
152
  *
251
153
  * @example
252
- * Registration with username:
253
- * ```typescript
254
- * await client.auth.register({
154
+ * // Register with username
155
+ * const result = await client.auth.register({
255
156
  * username: 'johndoe',
256
- * email: 'john@example.com',
257
- * password: 'Password@123',
258
- * displayName: 'John Doe'
157
+ * password: 'SecurePass123'
259
158
  * });
260
- * ```
159
+ *
160
+ * @since 1.0.0
261
161
  */
262
162
  register(params: RegisterParams): Promise<ClientResult<LoginResponse>>;
263
163
 
@@ -271,30 +171,33 @@ export interface PasswordAuthAPI {
271
171
  * @returns User info and access token
272
172
  *
273
173
  * @example
274
- * Login with email:
275
- * ```typescript
174
+ * // Login with email
276
175
  * const result = await client.auth.login({
277
176
  * email: 'user@example.com',
278
- * password: 'Password@123'
177
+ * password: 'myPassword123'
279
178
  * });
280
179
  *
281
- * if (result.data) {
282
- * console.log('Welcome', result.data.user.displayName);
283
- * // Token is now automatically attached to all requests
180
+ * if (result.success) {
181
+ * console.log('Welcome,', result.data.user.displayName);
284
182
  * } else {
285
- * console.error('Login failed:', result.error?.message);
183
+ * console.error('Login failed:', result.error.message);
286
184
  * }
287
- * ```
288
185
  *
289
186
  * @example
290
- * Login with username:
291
- * ```typescript
292
- * await client.auth.login({
293
- * loginType: 'username',
187
+ * // Login with username
188
+ * const result = await client.auth.login({
294
189
  * username: 'johndoe',
295
- * password: 'Password@123'
190
+ * password: 'myPassword123'
191
+ * });
192
+ *
193
+ * @example
194
+ * // Login with phone
195
+ * const result = await client.auth.login({
196
+ * phone: '+1234567890',
197
+ * password: 'myPassword123'
296
198
  * });
297
- * ```
199
+ *
200
+ * @since 1.0.0
298
201
  */
299
202
  login(params: LoginParams): Promise<ClientResult<LoginResponse>>;
300
203
 
@@ -308,18 +211,16 @@ export interface PasswordAuthAPI {
308
211
  * @returns Success status
309
212
  *
310
213
  * @example
311
- * ```typescript
312
214
  * const result = await client.auth.changePassword({
313
- * oldPassword: 'OldPassword@123',
314
- * newPassword: 'NewPassword@456'
215
+ * oldPassword: 'currentPass123',
216
+ * newPassword: 'newSecurePass456'
315
217
  * });
316
218
  *
317
- * if (result.data?.success) {
219
+ * if (result.success) {
318
220
  * console.log('Password changed successfully');
319
- * } else {
320
- * console.error('Failed:', result.error?.message);
321
221
  * }
322
- * ```
222
+ *
223
+ * @since 1.0.0
323
224
  */
324
225
  changePassword(params: ChangePasswordParams): Promise<ClientResult<SuccessResponse>>;
325
226
  }
@@ -1,9 +1,5 @@
1
1
  /**
2
- * ============================================================================
3
- * User Profile Management - Type Definitions
4
- * ============================================================================
5
- *
6
- * User profile operations including:
2
+ * * User profile operations including:
7
3
  * - Get current user information
8
4
  * - Update profile fields
9
5
  * - Avatar management
@@ -20,36 +16,7 @@ import type { User } from './user';
20
16
  * Update user profile parameters
21
17
  *
22
18
  * All fields are optional - only update what you want to change.
23
- *
24
- * @example
25
- * Update display name:
26
- * ```typescript
27
- * await client.auth.updateProfile({
28
- * displayName: 'Jane Doe'
29
- * });
30
- * ```
31
- *
32
- * @example
33
- * Update multiple fields:
34
- * ```typescript
35
- * await client.auth.updateProfile({
36
- * displayName: 'John Smith',
37
- * avatarUrl: 'https://cdn.example.com/avatar.jpg',
38
- * phone: '+86-13900139000'
39
- * });
40
- * ```
41
- *
42
- * @example
43
- * Update email (may require verification):
44
- * ```typescript
45
- * const result = await client.auth.updateProfile({
46
- * email: 'newemail@example.com'
47
- * });
48
- *
49
- * if (result.data && !result.data.emailVerified) {
50
- * console.log('Verification email sent to new address');
51
- * }
52
- * ```
19
+ *
53
20
  */
54
21
  export interface UpdateProfileParams {
55
22
  /** New display name */
@@ -79,41 +46,7 @@ export interface ProfileAPI {
79
46
  * Retrieves the profile of the currently authenticated user.
80
47
  *
81
48
  * @returns Current user info with roles and permissions
82
- *
83
- * @example
84
- * Basic usage:
85
- * ```typescript
86
- * const result = await client.auth.getMe();
87
- * if (result.data) {
88
- * console.log('Current user:', result.data.displayName);
89
- * console.log('Email:', result.data.email);
90
- * console.log('Roles:', result.data.roles);
91
- * console.log('Permissions:', result.data.permissions);
92
- * }
93
- * ```
94
- *
95
- * @example
96
- * Check permissions:
97
- * ```typescript
98
- * const result = await client.auth.getMe();
99
- * if (result.data?.permissions.includes('user:delete')) {
100
- * showDeleteButton();
101
- * }
102
- *
103
- * if (result.data?.roles.includes('admin')) {
104
- * showAdminPanel();
105
- * }
106
- * ```
107
- *
108
- * @example
109
- * Display verification status:
110
- * ```typescript
111
- * const user = (await client.auth.getMe()).data;
112
- * if (user) {
113
- * console.log(`Email ${user.email}${user.emailVerified ? ' ✓' : ' (unverified)'}`);
114
- * console.log(`Phone ${user.phone}${user.phoneVerified ? ' ✓' : ' (unverified)'}`);
115
- * }
116
- * ```
49
+ *
117
50
  */
118
51
  getMe(): Promise<ClientResult<User>>;
119
52
 
@@ -125,39 +58,7 @@ export interface ProfileAPI {
125
58
  *
126
59
  * @param params - Fields to update
127
60
  * @returns Updated user info
128
- *
129
- * @example
130
- * Update display name:
131
- * ```typescript
132
- * const result = await client.auth.updateProfile({
133
- * displayName: 'Jane Smith'
134
- * });
135
- *
136
- * if (result.data) {
137
- * console.log('Profile updated:', result.data.displayName);
138
- * }
139
- * ```
140
- *
141
- * @example
142
- * Update avatar:
143
- * ```typescript
144
- * // After uploading avatar to CDN
145
- * const avatarUrl = 'https://cdn.example.com/avatars/user-123.jpg';
146
- *
147
- * await client.auth.updateProfile({
148
- * avatarUrl: avatarUrl
149
- * });
150
- * ```
151
- *
152
- * @example
153
- * Update multiple fields:
154
- * ```typescript
155
- * await client.auth.updateProfile({
156
- * displayName: 'John Doe',
157
- * avatarUrl: 'https://cdn.example.com/avatar.jpg',
158
- * phone: '+86-13900139000'
159
- * });
160
- * ```
61
+ *
161
62
  */
162
63
  updateProfile(params: UpdateProfileParams): Promise<ClientResult<User>>;
163
64
  }
@@ -1,9 +1,5 @@
1
1
  /**
2
- * ============================================================================
3
- * User Types - Base User Information
4
- * ============================================================================
5
- *
6
- * Core user data structures including:
2
+ * * Core user data structures including:
7
3
  * - User profile information
8
4
  * - Role and permission types
9
5
  * - User status enums
@@ -16,31 +12,8 @@
16
12
  *
17
13
  * Roles and permissions are returned as simple string arrays for efficient client-side use:
18
14
  * - `roles`: ["admin", "user", "manager"]
19
- * - `permissions`: ["user:read", "user:write", "order:read"]
20
- *
21
- * @example
22
- * Check user permissions:
23
- * ```typescript
24
- * const result = await client.auth.getMe();
25
- * const user = result.data;
26
- *
27
- * if (user.roles.includes('admin')) {
28
- * console.log('User is an admin');
29
- * }
30
- *
31
- * if (user.permissions.includes('user:delete')) {
32
- * showDeleteButton();
33
- * }
34
- * ```
35
- *
36
- * @example
37
- * Display user info:
38
- * ```typescript
39
- * const user = result.data;
40
- * console.log(`Name: ${user.displayName}`);
41
- * console.log(`Email: ${user.email}${user.emailVerified ? ' ✓' : ''}`);
42
- * console.log(`Roles: ${user.roles.join(', ')}`);
43
- * ```
15
+ * - `permissions`: ["user.read", "user.write", "order.read"]
16
+ *
44
17
  */
45
18
  export interface User {
46
19
  /** Unique user identifier */
@@ -77,15 +50,18 @@ export interface User {
77
50
  phoneVerifiedAt: string | null;
78
51
 
79
52
  /**
80
- * Role codes assigned to user
81
- * @example ["admin", "user", "manager"]
53
+ * Role codes assigned to user
54
+ *
55
+ * Includes system roles and custom roles:
56
+ * - System roles: "anonymous" (unauthenticated), "member" (default), "admin"
57
+ * - Custom roles: defined in app.settings.yml
58
+ *
82
59
  */
83
60
  roles: string[];
84
61
 
85
62
  /**
86
63
  * Permission names granted to user
87
- * Format: "resource:action"
88
- * @example ["user:read", "user:write", "order:read", "order:delete"]
64
+ * Format: "resource.action"
89
65
  */
90
66
  permissions: string[];
91
67