@amaster.ai/client 1.1.0-beta.30 → 1.1.0-beta.32
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/index.cjs +63 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +63 -8
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/types/__tests__/type-checks.test-d.ts +163 -0
- package/types/asr.d.ts +10 -114
- package/types/auth/code-auth.d.ts +5 -154
- package/types/auth/index.d.ts +20 -166
- package/types/auth/oauth.d.ts +6 -143
- package/types/auth/password-auth.d.ts +38 -137
- package/types/auth/profile.d.ts +4 -103
- package/types/auth/user.d.ts +3 -33
- package/types/bpm.d.ts +182 -92
- package/types/common.d.ts +52 -44
- package/types/copilot.d.ts +50 -117
- package/types/entity.d.ts +65 -342
- package/types/function.d.ts +11 -88
- package/types/index.d.ts +52 -302
- package/types/s3.d.ts +25 -56
- package/types/tts.d.ts +10 -128
- package/types/workflow.d.ts +16 -165
package/types/asr.d.ts
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* ASR (Automatic Speech Recognition) - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* Real-time speech recognition using WebSocket connection.
|
|
2
|
+
* * Real-time speech recognition using WebSocket connection.
|
|
7
3
|
*
|
|
8
4
|
* @module asr
|
|
9
5
|
*/
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* ASR Client Configuration
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* Configure ASR with custom voice settings:
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
18
|
-
*
|
|
19
|
-
* // Reconfigure ASR client
|
|
20
|
-
* client.asr = createASRClient({
|
|
21
|
-
* audioFormat: 'pcm16',
|
|
22
|
-
* sampleRate: 16000,
|
|
23
|
-
* onTranscript: (text, isFinal) => {
|
|
24
|
-
* console.log(isFinal ? `Final: ${text}` : `Interim: ${text}`);
|
|
25
|
-
* },
|
|
26
|
-
* onError: (error) => console.error('ASR Error:', error)
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
9
|
+
*
|
|
29
10
|
*/
|
|
30
11
|
export interface ASRClientConfig {
|
|
31
12
|
/** Audio format, default 'pcm16' */
|
|
@@ -61,78 +42,20 @@ export interface ASRClientConfig {
|
|
|
61
42
|
}
|
|
62
43
|
|
|
63
44
|
/**
|
|
64
|
-
* ASR Client API
|
|
65
|
-
*
|
|
66
|
-
* Real-time speech recognition client using WebSocket.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* Basic usage:
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
72
|
-
*
|
|
73
|
-
* // Configure callbacks
|
|
74
|
-
* client.asr = createASRClient({
|
|
75
|
-
* onTranscript: (text, isFinal) => {
|
|
76
|
-
* if (isFinal) {
|
|
77
|
-
* console.log('Final transcript:', text);
|
|
78
|
-
* } else {
|
|
79
|
-
* console.log('Interim transcript:', text);
|
|
80
|
-
* }
|
|
81
|
-
* }
|
|
82
|
-
* });
|
|
83
|
-
*
|
|
84
|
-
* // Connect and start recording
|
|
85
|
-
* await client.asr.connect();
|
|
86
|
-
* await client.asr.startRecording();
|
|
45
|
+
* ASR (Automatic Speech Recognition) Client API
|
|
87
46
|
*
|
|
88
|
-
*
|
|
89
|
-
* client.asr.stopRecording();
|
|
47
|
+
* Provides real-time speech-to-text conversion via WebSocket.
|
|
90
48
|
*
|
|
91
|
-
*
|
|
92
|
-
* client.asr.close();
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* With error handling:
|
|
97
|
-
* ```typescript
|
|
98
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
99
|
-
*
|
|
100
|
-
* client.asr = createASRClient({
|
|
101
|
-
* onReady: () => console.log('ASR ready'),
|
|
102
|
-
* onSpeechStart: () => console.log('Speech detected'),
|
|
103
|
-
* onSpeechEnd: () => console.log('Speech ended'),
|
|
104
|
-
* onTranscript: (text, isFinal) => {
|
|
105
|
-
* console.log(isFinal ? `[FINAL] ${text}` : `[INTERIM] ${text}`);
|
|
106
|
-
* },
|
|
107
|
-
* onError: (error) => {
|
|
108
|
-
* console.error('ASR Error:', error.message);
|
|
109
|
-
* },
|
|
110
|
-
* onClose: () => {
|
|
111
|
-
* console.log('ASR connection closed');
|
|
112
|
-
* }
|
|
113
|
-
* });
|
|
114
|
-
*
|
|
115
|
-
* try {
|
|
116
|
-
* await client.asr.connect();
|
|
117
|
-
* await client.asr.startRecording();
|
|
118
|
-
* } catch (error) {
|
|
119
|
-
* console.error('Failed to start ASR:', error);
|
|
120
|
-
* }
|
|
121
|
-
* ```
|
|
49
|
+
* @since 1.0.0
|
|
122
50
|
*/
|
|
123
|
-
export interface
|
|
51
|
+
export interface ASRClientAPI {
|
|
124
52
|
/**
|
|
125
53
|
* Connect to ASR service
|
|
126
54
|
*
|
|
127
55
|
* Establishes WebSocket connection to the speech recognition service.
|
|
128
56
|
*
|
|
129
57
|
* @returns Promise that resolves when connected
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```typescript
|
|
133
|
-
* await client.asr.connect();
|
|
134
|
-
* console.log('Connected to ASR service');
|
|
135
|
-
* ```
|
|
58
|
+
*
|
|
136
59
|
*/
|
|
137
60
|
connect(): Promise<void>;
|
|
138
61
|
|
|
@@ -143,19 +66,7 @@ export interface ASRClient {
|
|
|
143
66
|
* Requires microphone permission from the user.
|
|
144
67
|
*
|
|
145
68
|
* @returns Promise that resolves when recording starts
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* // Request microphone permission and start recording
|
|
150
|
-
* try {
|
|
151
|
-
* await client.asr.startRecording();
|
|
152
|
-
* console.log('Recording started');
|
|
153
|
-
* } catch (error) {
|
|
154
|
-
* if (error.name === 'NotAllowedError') {
|
|
155
|
-
* console.error('Microphone permission denied');
|
|
156
|
-
* }
|
|
157
|
-
* }
|
|
158
|
-
* ```
|
|
69
|
+
*
|
|
159
70
|
*/
|
|
160
71
|
startRecording(): Promise<void>;
|
|
161
72
|
|
|
@@ -163,16 +74,7 @@ export interface ASRClient {
|
|
|
163
74
|
* Stop recording
|
|
164
75
|
*
|
|
165
76
|
* Stops capturing audio from the microphone but keeps the WebSocket connection open.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```typescript
|
|
169
|
-
* // Stop recording after 10 seconds
|
|
170
|
-
* await client.asr.startRecording();
|
|
171
|
-
* setTimeout(() => {
|
|
172
|
-
* client.asr.stopRecording();
|
|
173
|
-
* console.log('Recording stopped');
|
|
174
|
-
* }, 10000);
|
|
175
|
-
* ```
|
|
77
|
+
*
|
|
176
78
|
*/
|
|
177
79
|
stopRecording(): void;
|
|
178
80
|
|
|
@@ -180,13 +82,7 @@ export interface ASRClient {
|
|
|
180
82
|
* Close connection
|
|
181
83
|
*
|
|
182
84
|
* Closes the WebSocket connection and releases resources.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```typescript
|
|
186
|
-
* // Cleanup when done
|
|
187
|
-
* client.asr.stopRecording();
|
|
188
|
-
* client.asr.close();
|
|
189
|
-
* ```
|
|
85
|
+
*
|
|
190
86
|
*/
|
|
191
87
|
close(): void;
|
|
192
88
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Verification Code Authentication - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* Verification code-based authentication including:
|
|
2
|
+
* * Verification code-based authentication including:
|
|
7
3
|
* - Email verification code login
|
|
8
4
|
* - SMS verification code login
|
|
9
5
|
* - Send verification code
|
|
@@ -24,46 +20,7 @@ export type CodeLoginType = 'email' | 'phone';
|
|
|
24
20
|
|
|
25
21
|
/**
|
|
26
22
|
* Verification code login parameters
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* Email code login:
|
|
30
|
-
* ```typescript
|
|
31
|
-
* // 1. Send verification code
|
|
32
|
-
* await client.auth.sendCode({
|
|
33
|
-
* type: 'email',
|
|
34
|
-
* email: 'user@example.com'
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // 2. User receives code via email: "123456"
|
|
38
|
-
*
|
|
39
|
-
* // 3. Login with code
|
|
40
|
-
* const result = await client.auth.codeLogin({
|
|
41
|
-
* email: 'user@example.com',
|
|
42
|
-
* code: '123456'
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* if (result.data) {
|
|
46
|
-
* console.log('Logged in successfully!');
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* Phone code login:
|
|
52
|
-
* ```typescript
|
|
53
|
-
* // 1. Send SMS code
|
|
54
|
-
* await client.auth.sendCode({
|
|
55
|
-
* type: 'phone',
|
|
56
|
-
* phone: '+86-13800138000'
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // 2. User receives SMS: "654321"
|
|
60
|
-
*
|
|
61
|
-
* // 3. Login with code
|
|
62
|
-
* await client.auth.codeLogin({
|
|
63
|
-
* phone: '+86-13800138000',
|
|
64
|
-
* code: '654321'
|
|
65
|
-
* });
|
|
66
|
-
* ```
|
|
23
|
+
*
|
|
67
24
|
*/
|
|
68
25
|
export interface CodeLoginParams {
|
|
69
26
|
/** Login method (optional, auto-detected) */
|
|
@@ -119,45 +76,7 @@ export interface CodeAuthAPI {
|
|
|
119
76
|
*
|
|
120
77
|
* @param params - Email/phone and verification code
|
|
121
78
|
* @returns User info and access token
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* Complete code login flow:
|
|
125
|
-
* ```typescript
|
|
126
|
-
* // 1. Send verification code
|
|
127
|
-
* await client.auth.sendCode({
|
|
128
|
-
* type: 'email',
|
|
129
|
-
* email: 'user@example.com'
|
|
130
|
-
* });
|
|
131
|
-
*
|
|
132
|
-
* // 2. User receives code: "123456"
|
|
133
|
-
*
|
|
134
|
-
* // 3. Login with code
|
|
135
|
-
* const result = await client.auth.codeLogin({
|
|
136
|
-
* email: 'user@example.com',
|
|
137
|
-
* code: '123456'
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* if (result.data) {
|
|
141
|
-
* console.log('Logged in successfully!');
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* SMS code login with error handling:
|
|
147
|
-
* ```typescript
|
|
148
|
-
* const result = await client.auth.codeLogin({
|
|
149
|
-
* phone: '+86-13800138000',
|
|
150
|
-
* code: userInputCode
|
|
151
|
-
* });
|
|
152
|
-
*
|
|
153
|
-
* if (result.error) {
|
|
154
|
-
* if (result.status === 400) {
|
|
155
|
-
* console.error('Invalid or expired code');
|
|
156
|
-
* } else {
|
|
157
|
-
* console.error('Login failed:', result.error.message);
|
|
158
|
-
* }
|
|
159
|
-
* }
|
|
160
|
-
* ```
|
|
79
|
+
*
|
|
161
80
|
*/
|
|
162
81
|
codeLogin(params: CodeLoginParams): Promise<ClientResult<LoginResponse>>;
|
|
163
82
|
|
|
@@ -169,43 +88,7 @@ export interface CodeAuthAPI {
|
|
|
169
88
|
*
|
|
170
89
|
* @param params - Email or phone to send code to
|
|
171
90
|
* @returns Success status
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* Send email verification code:
|
|
175
|
-
* ```typescript
|
|
176
|
-
* const result = await client.auth.sendCode({
|
|
177
|
-
* type: 'email',
|
|
178
|
-
* email: 'user@example.com'
|
|
179
|
-
* });
|
|
180
|
-
*
|
|
181
|
-
* if (result.data?.success) {
|
|
182
|
-
* console.log('Code sent to email');
|
|
183
|
-
* showCodeInputForm();
|
|
184
|
-
* }
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* Send SMS verification code:
|
|
189
|
-
* ```typescript
|
|
190
|
-
* await client.auth.sendCode({
|
|
191
|
-
* type: 'phone',
|
|
192
|
-
* phone: '+86-13800138000'
|
|
193
|
-
* });
|
|
194
|
-
* console.log('SMS sent');
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* With rate limiting handling:
|
|
199
|
-
* ```typescript
|
|
200
|
-
* const result = await client.auth.sendCode({
|
|
201
|
-
* type: 'email',
|
|
202
|
-
* email: 'user@example.com'
|
|
203
|
-
* });
|
|
204
|
-
*
|
|
205
|
-
* if (result.status === 429) {
|
|
206
|
-
* console.error('Too many requests. Please try again later.');
|
|
207
|
-
* }
|
|
208
|
-
* ```
|
|
91
|
+
*
|
|
209
92
|
*/
|
|
210
93
|
sendCode(params: SendCodeParams): Promise<ClientResult<SuccessResponse>>;
|
|
211
94
|
|
|
@@ -216,39 +99,7 @@ export interface CodeAuthAPI {
|
|
|
216
99
|
* Used during registration or sensitive operations.
|
|
217
100
|
*
|
|
218
101
|
* @returns Captcha ID and image (base64)
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* Display captcha to user:
|
|
222
|
-
* ```typescript
|
|
223
|
-
* const result = await client.auth.getCaptcha();
|
|
224
|
-
* if (result.data) {
|
|
225
|
-
* // Display image to user
|
|
226
|
-
* const img = document.createElement('img');
|
|
227
|
-
* img.src = result.data.captchaImage;
|
|
228
|
-
* document.body.appendChild(img);
|
|
229
|
-
*
|
|
230
|
-
* // Save captchaId for later verification
|
|
231
|
-
* const captchaId = result.data.captchaId;
|
|
232
|
-
* }
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* Use with registration:
|
|
237
|
-
* ```typescript
|
|
238
|
-
* // 1. Get captcha
|
|
239
|
-
* const captchaResult = await client.auth.getCaptcha();
|
|
240
|
-
* showCaptchaImage(captchaResult.data.captchaImage);
|
|
241
|
-
*
|
|
242
|
-
* // 2. Get user input
|
|
243
|
-
* const userInput = await promptUserForCaptcha();
|
|
244
|
-
*
|
|
245
|
-
* // 3. Register with captcha
|
|
246
|
-
* await client.auth.register({
|
|
247
|
-
* email: 'user@example.com',
|
|
248
|
-
* password: 'Password@123',
|
|
249
|
-
* captcha: `${captchaResult.data.captchaId}:${userInput}`
|
|
250
|
-
* });
|
|
251
|
-
* ```
|
|
102
|
+
*
|
|
252
103
|
*/
|
|
253
104
|
getCaptcha(): Promise<ClientResult<CaptchaResponse>>;
|
|
254
105
|
}
|
package/types/auth/index.d.ts
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Authentication Module - Unified Entry Point
|
|
4
|
-
* ============================================================================
|
|
2
|
+
* Authentication module - provides user authentication and management capabilities.
|
|
5
3
|
*
|
|
6
|
-
* This module
|
|
7
|
-
* Import from submodules for better tree-shaking and AI readability:
|
|
8
|
-
*
|
|
9
|
-
* - `@amaster.ai/client/auth/user` - User types
|
|
10
|
-
* - `@amaster.ai/client/auth/password-auth` - Password login/register
|
|
11
|
-
* - `@amaster.ai/client/auth/code-auth` - Verification code login
|
|
12
|
-
* - `@amaster.ai/client/auth/oauth` - OAuth & social login
|
|
13
|
-
* - `@amaster.ai/client/auth/profile` - User profile management
|
|
4
|
+
* This module exports all auth-related types for convenient importing:
|
|
14
5
|
*
|
|
15
6
|
* @example
|
|
16
|
-
* Import
|
|
17
|
-
*
|
|
18
|
-
* import type { AuthClientAPI } from '@amaster.ai/client/auth';
|
|
19
|
-
* ```
|
|
7
|
+
* // Import specific types
|
|
8
|
+
* import type { LoginParams, User, OAuthProvider } from '@amaster.ai/client/auth';
|
|
20
9
|
*
|
|
21
10
|
* @example
|
|
22
|
-
* Import
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
11
|
+
* // Import multiple types
|
|
12
|
+
* import type {
|
|
13
|
+
* LoginParams,
|
|
14
|
+
* RegisterParams,
|
|
15
|
+
* User,
|
|
16
|
+
* Role,
|
|
17
|
+
* Permission
|
|
18
|
+
* } from '@amaster.ai/client/auth';
|
|
27
19
|
*
|
|
28
20
|
* @module auth
|
|
21
|
+
* @since 1.0.0
|
|
29
22
|
*/
|
|
30
23
|
|
|
31
24
|
import type { ClientResult } from '../common';
|
|
32
25
|
|
|
33
|
-
// Re-export all submodule types
|
|
26
|
+
// Re-export all submodule types for convenient importing
|
|
34
27
|
export * from './user';
|
|
35
28
|
export * from './password-auth';
|
|
36
29
|
export * from './code-auth';
|
|
@@ -74,37 +67,7 @@ export interface SuccessResponse {
|
|
|
74
67
|
*
|
|
75
68
|
* Combines all authentication capabilities into a single interface.
|
|
76
69
|
* All methods return a `ClientResult<T>` for consistent error handling.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* Complete authentication flow:
|
|
80
|
-
* ```typescript
|
|
81
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
82
|
-
*
|
|
83
|
-
* // 1. Register new user
|
|
84
|
-
* await client.auth.register({
|
|
85
|
-
* email: 'user@example.com',
|
|
86
|
-
* password: 'Password@123',
|
|
87
|
-
* displayName: 'John Doe'
|
|
88
|
-
* });
|
|
89
|
-
*
|
|
90
|
-
* // 2. Login (token is automatically stored and attached to all requests)
|
|
91
|
-
* await client.auth.login({
|
|
92
|
-
* email: 'user@example.com',
|
|
93
|
-
* password: 'Password@123'
|
|
94
|
-
* });
|
|
95
|
-
*
|
|
96
|
-
* // 3. Get current user info
|
|
97
|
-
* const userResult = await client.auth.getMe();
|
|
98
|
-
* console.log(userResult.data);
|
|
99
|
-
*
|
|
100
|
-
* // 4. Update profile
|
|
101
|
-
* await client.auth.updateProfile({
|
|
102
|
-
* displayName: 'Jane Doe'
|
|
103
|
-
* });
|
|
104
|
-
*
|
|
105
|
-
* // 5. Logout
|
|
106
|
-
* await client.auth.logout();
|
|
107
|
-
* ```
|
|
70
|
+
*
|
|
108
71
|
*/
|
|
109
72
|
export interface AuthClientAPI
|
|
110
73
|
extends PasswordAuthAPI,
|
|
@@ -119,22 +82,7 @@ export interface AuthClientAPI
|
|
|
119
82
|
* All subsequent requests will be unauthenticated until login again.
|
|
120
83
|
*
|
|
121
84
|
* @returns Success status
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```typescript
|
|
125
|
-
* await client.auth.logout();
|
|
126
|
-
* console.log('Logged out successfully');
|
|
127
|
-
*
|
|
128
|
-
* // Token is cleared, requests are now unauthenticated
|
|
129
|
-
* console.log(client.isAuthenticated()); // false
|
|
130
|
-
* ```
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* Logout with redirect:
|
|
134
|
-
* ```typescript
|
|
135
|
-
* await client.auth.logout();
|
|
136
|
-
* window.location.href = '/login';
|
|
137
|
-
* ```
|
|
85
|
+
*
|
|
138
86
|
*/
|
|
139
87
|
logout(): Promise<ClientResult<SuccessResponse>>;
|
|
140
88
|
|
|
@@ -146,32 +94,7 @@ export interface AuthClientAPI
|
|
|
146
94
|
* This method is exposed for manual refresh scenarios.
|
|
147
95
|
*
|
|
148
96
|
* @returns New access token
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* const result = await client.auth.refreshToken();
|
|
153
|
-
* if (result.data) {
|
|
154
|
-
* console.log('Token refreshed:', result.data.accessToken);
|
|
155
|
-
* }
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* Manual token refresh on 401:
|
|
160
|
-
* ```typescript
|
|
161
|
-
* try {
|
|
162
|
-
* const result = await client.entity.list('default', 'users');
|
|
163
|
-
* if (result.status === 401) {
|
|
164
|
-
* // Try to refresh token
|
|
165
|
-
* const refreshResult = await client.auth.refreshToken();
|
|
166
|
-
* if (refreshResult.data) {
|
|
167
|
-
* // Retry original request
|
|
168
|
-
* return await client.entity.list('default', 'users');
|
|
169
|
-
* }
|
|
170
|
-
* }
|
|
171
|
-
* } catch (error) {
|
|
172
|
-
* // Handle error
|
|
173
|
-
* }
|
|
174
|
-
* ```
|
|
97
|
+
*
|
|
175
98
|
*/
|
|
176
99
|
refreshToken(): Promise<ClientResult<RefreshTokenResponse>>;
|
|
177
100
|
|
|
@@ -185,22 +108,7 @@ export interface AuthClientAPI
|
|
|
185
108
|
*
|
|
186
109
|
* @param roleCode - Role code to check (e.g., "admin", "user", "anonymous")
|
|
187
110
|
* @returns True if user has the role
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* Check admin role:
|
|
191
|
-
* ```typescript
|
|
192
|
-
* if (client.auth.hasRole('admin')) {
|
|
193
|
-
* showAdminPanel();
|
|
194
|
-
* }
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* Check anonymous user:
|
|
199
|
-
* ```typescript
|
|
200
|
-
* if (client.auth.hasRole('anonymous')) {
|
|
201
|
-
* showLoginPrompt();
|
|
202
|
-
* }
|
|
203
|
-
* ```
|
|
111
|
+
*
|
|
204
112
|
*/
|
|
205
113
|
hasRole(roleCode: string): boolean;
|
|
206
114
|
|
|
@@ -213,37 +121,7 @@ export interface AuthClientAPI
|
|
|
213
121
|
* @param resource - Resource name (e.g., "user", "order")
|
|
214
122
|
* @param action - Action name (e.g., "read", "write", "delete")
|
|
215
123
|
* @returns True if user has the permission
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* Check permission for authenticated users:
|
|
219
|
-
* ```typescript
|
|
220
|
-
* if (client.auth.hasPermission('user', 'delete')) {
|
|
221
|
-
* showDeleteButton();
|
|
222
|
-
* }
|
|
223
|
-
* ```
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* Check permission for anonymous users:
|
|
227
|
-
* ```typescript
|
|
228
|
-
* // If backend configured anonymous role with article:read permission
|
|
229
|
-
* if (client.auth.hasPermission('article', 'read')) {
|
|
230
|
-
* showArticleList();
|
|
231
|
-
* }
|
|
232
|
-
* ```
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* Control UI elements:
|
|
236
|
-
* ```typescript
|
|
237
|
-
* const canEdit = client.auth.hasPermission('post', 'write');
|
|
238
|
-
* const canDelete = client.auth.hasPermission('post', 'delete');
|
|
239
|
-
*
|
|
240
|
-
* return (
|
|
241
|
-
* <div>
|
|
242
|
-
* {canEdit && <button>Edit</button>}
|
|
243
|
-
* {canDelete && <button>Delete</button>}
|
|
244
|
-
* </div>
|
|
245
|
-
* );
|
|
246
|
-
* ```
|
|
124
|
+
*
|
|
247
125
|
*/
|
|
248
126
|
hasPermission(resource: string, action: string): boolean;
|
|
249
127
|
|
|
@@ -254,31 +132,7 @@ export interface AuthClientAPI
|
|
|
254
132
|
* Returns true if user has the 'anonymous' role.
|
|
255
133
|
*
|
|
256
134
|
* @returns True if user is anonymous
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* Show login prompt for anonymous users:
|
|
260
|
-
* ```typescript
|
|
261
|
-
* if (client.auth.isAnonymous()) {
|
|
262
|
-
* showLoginButton();
|
|
263
|
-
* showLimitedFeatures();
|
|
264
|
-
* } else {
|
|
265
|
-
* showFullFeatures();
|
|
266
|
-
* }
|
|
267
|
-
* ```
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* Conditional rendering:
|
|
271
|
-
* ```typescript
|
|
272
|
-
* return (
|
|
273
|
-
* <div>
|
|
274
|
-
* {client.auth.isAnonymous() ? (
|
|
275
|
-
* <button onClick={handleLogin}>Login to continue</button>
|
|
276
|
-
* ) : (
|
|
277
|
-
* <UserDashboard />
|
|
278
|
-
* )}
|
|
279
|
-
* </div>
|
|
280
|
-
* );
|
|
281
|
-
* ```
|
|
135
|
+
*
|
|
282
136
|
*/
|
|
283
137
|
isAnonymous(): boolean;
|
|
284
138
|
}
|