@amaster.ai/client 1.1.0-beta.3 → 1.1.0-beta.31
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 +4 -7
- package/dist/index.cjs +66 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +66 -8
- package/dist/index.js.map +1 -1
- package/package.json +15 -11
- 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 +54 -96
- 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 +8 -32
- package/types/bpm.d.ts +53 -168
- package/types/common.d.ts +52 -44
- package/types/copilot.d.ts +202 -104
- package/types/entity.d.ts +65 -342
- package/types/function.d.ts +11 -88
- package/types/index.d.ts +85 -278
- package/types/s3.d.ts +96 -0
- package/types/tts.d.ts +10 -128
- package/types/workflow.d.ts +16 -165
- package/types/auth/permissions.d.ts +0 -254
package/types/bpm.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ============================================================================
|
|
3
|
-
* BPM Module - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* This module provides Business Process Management (BPM) capabilities
|
|
7
|
-
* based on Camunda BPMN engine.
|
|
8
|
-
*
|
|
9
|
-
* ## Key Features
|
|
10
|
-
* - Start and manage BPMN processes
|
|
11
|
-
* - Query and complete user tasks
|
|
12
|
-
* - Manage process variables
|
|
13
|
-
* - Query process history
|
|
14
|
-
* - Handle BPMN flows (approval, business processes, etc.)
|
|
15
2
|
*
|
|
16
3
|
* @module bpm
|
|
17
4
|
*/
|
|
@@ -47,14 +34,7 @@ export type CamundaVariableValue =
|
|
|
47
34
|
|
|
48
35
|
/**
|
|
49
36
|
* Camunda variable with type hint
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const variable: CamundaVariable = {
|
|
54
|
-
* value: 1000,
|
|
55
|
-
* type: 'Long'
|
|
56
|
-
* };
|
|
57
|
-
* ```
|
|
37
|
+
*
|
|
58
38
|
*/
|
|
59
39
|
export interface CamundaVariable {
|
|
60
40
|
value: CamundaVariableValue;
|
|
@@ -63,17 +43,7 @@ export interface CamundaVariable {
|
|
|
63
43
|
|
|
64
44
|
/**
|
|
65
45
|
* Variable submission format for process/task
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* const submission: VariableSubmission = {
|
|
70
|
-
* variables: {
|
|
71
|
-
* amount: { value: 1000, type: 'Long' },
|
|
72
|
-
* requester: { value: 'user-123', type: 'String' },
|
|
73
|
-
* approved: { value: false, type: 'Boolean' }
|
|
74
|
-
* }
|
|
75
|
-
* };
|
|
76
|
-
* ```
|
|
46
|
+
*
|
|
77
47
|
*/
|
|
78
48
|
export interface VariableSubmission {
|
|
79
49
|
variables: Record<string, CamundaVariable>;
|
|
@@ -203,33 +173,7 @@ export interface TaskCount {
|
|
|
203
173
|
*
|
|
204
174
|
* Provides methods for managing BPMN processes and tasks.
|
|
205
175
|
*
|
|
206
|
-
* @
|
|
207
|
-
* Complete BPM flow:
|
|
208
|
-
* ```typescript
|
|
209
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
210
|
-
*
|
|
211
|
-
* // 1. Start a process
|
|
212
|
-
* const process = await client.bpm.startProcess('approval', {
|
|
213
|
-
* amount: { value: 5000, type: 'Long' },
|
|
214
|
-
* requester: { value: 'user-123', type: 'String' },
|
|
215
|
-
* description: { value: 'Purchase request', type: 'String' }
|
|
216
|
-
* });
|
|
217
|
-
*
|
|
218
|
-
* console.log('Process started:', process.data.id);
|
|
219
|
-
*
|
|
220
|
-
* // 2. Get user's tasks
|
|
221
|
-
* const tasks = await client.bpm.getTasks({
|
|
222
|
-
* assignee: 'manager-456',
|
|
223
|
-
* processDefinitionKey: 'approval'
|
|
224
|
-
* });
|
|
225
|
-
*
|
|
226
|
-
* // 3. Complete a task
|
|
227
|
-
* const taskId = tasks.data[0].id;
|
|
228
|
-
* await client.bpm.completeTask(taskId, {
|
|
229
|
-
* approved: { value: true, type: 'Boolean' },
|
|
230
|
-
* comment: { value: 'Approved!', type: 'String' }
|
|
231
|
-
* });
|
|
232
|
-
* ```
|
|
176
|
+
* @since 1.0.0
|
|
233
177
|
*/
|
|
234
178
|
export interface BpmClientAPI {
|
|
235
179
|
// ==================== Process Management ====================
|
|
@@ -242,26 +186,24 @@ export interface BpmClientAPI {
|
|
|
242
186
|
* @returns New process instance information
|
|
243
187
|
*
|
|
244
188
|
* @example
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* const result = await client.bpm.startProcess('approval', {
|
|
189
|
+
* // Simple start
|
|
190
|
+
* const result = await client.bpm.startProcess('approval-process', {
|
|
248
191
|
* amount: 1000,
|
|
249
|
-
* requester: '
|
|
250
|
-
* urgent: true
|
|
192
|
+
* requester: 'john@example.com'
|
|
251
193
|
* });
|
|
252
|
-
*
|
|
194
|
+
*
|
|
195
|
+
* if (result.success) {
|
|
196
|
+
* console.log('Process started:', result.data.id);
|
|
197
|
+
* }
|
|
253
198
|
*
|
|
254
199
|
* @example
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* amount: { value: 5000, type: 'Long' },
|
|
260
|
-
* supplier: { value: 'ABC Corp', type: 'String' },
|
|
261
|
-
* requestDate: { value: new Date(), type: 'Date' }
|
|
262
|
-
* }
|
|
200
|
+
* // With business key
|
|
201
|
+
* const result = await client.bpm.startProcess('order-fulfillment', {
|
|
202
|
+
* orderId: 'ORDER-12345',
|
|
203
|
+
* items: [{ sku: 'ITEM-1', qty: 2 }]
|
|
263
204
|
* });
|
|
264
|
-
*
|
|
205
|
+
*
|
|
206
|
+
* @since 1.0.0
|
|
265
207
|
*/
|
|
266
208
|
startProcess(
|
|
267
209
|
processKey: string,
|
|
@@ -273,15 +215,7 @@ export interface BpmClientAPI {
|
|
|
273
215
|
*
|
|
274
216
|
* @param params - Query parameters
|
|
275
217
|
* @returns Array of process instances
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
* Get all active approval processes:
|
|
279
|
-
* ```typescript
|
|
280
|
-
* const result = await client.bpm.getProcessInstances({
|
|
281
|
-
* processDefinitionKey: 'approval',
|
|
282
|
-
* active: true
|
|
283
|
-
* });
|
|
284
|
-
* ```
|
|
218
|
+
*
|
|
285
219
|
*/
|
|
286
220
|
getProcessInstances(
|
|
287
221
|
params?: ProcessInstanceQueryParams
|
|
@@ -292,12 +226,7 @@ export interface BpmClientAPI {
|
|
|
292
226
|
*
|
|
293
227
|
* @param processInstanceId - Process instance ID
|
|
294
228
|
* @returns Process instance information
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* ```typescript
|
|
298
|
-
* const result = await client.bpm.getProcessInstance('proc-123-456');
|
|
299
|
-
* console.log('Process:', result.data);
|
|
300
|
-
* ```
|
|
229
|
+
*
|
|
301
230
|
*/
|
|
302
231
|
getProcessInstance(
|
|
303
232
|
processInstanceId: string
|
|
@@ -309,11 +238,7 @@ export interface BpmClientAPI {
|
|
|
309
238
|
* @param processInstanceId - Process instance ID
|
|
310
239
|
* @param params - Optional parameters
|
|
311
240
|
* @returns null on success
|
|
312
|
-
*
|
|
313
|
-
* @example
|
|
314
|
-
* ```typescript
|
|
315
|
-
* await client.bpm.deleteProcessInstance('proc-123');
|
|
316
|
-
* ```
|
|
241
|
+
*
|
|
317
242
|
*/
|
|
318
243
|
deleteProcessInstance(
|
|
319
244
|
processInstanceId: string,
|
|
@@ -325,23 +250,7 @@ export interface BpmClientAPI {
|
|
|
325
250
|
*
|
|
326
251
|
* @param params - Process instance ID and optional variable name
|
|
327
252
|
* @returns Array of process variables
|
|
328
|
-
*
|
|
329
|
-
* @example
|
|
330
|
-
* Get all variables:
|
|
331
|
-
* ```typescript
|
|
332
|
-
* const result = await client.bpm.getProcessVariables({
|
|
333
|
-
* processInstanceId: 'proc-123'
|
|
334
|
-
* });
|
|
335
|
-
* ```
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* Get specific variable:
|
|
339
|
-
* ```typescript
|
|
340
|
-
* const result = await client.bpm.getProcessVariables({
|
|
341
|
-
* processInstanceId: 'proc-123',
|
|
342
|
-
* variableName: 'amount'
|
|
343
|
-
* });
|
|
344
|
-
* ```
|
|
253
|
+
*
|
|
345
254
|
*/
|
|
346
255
|
getProcessVariables(params: {
|
|
347
256
|
processInstanceId: string;
|
|
@@ -357,25 +266,23 @@ export interface BpmClientAPI {
|
|
|
357
266
|
* @returns Array of tasks
|
|
358
267
|
*
|
|
359
268
|
* @example
|
|
360
|
-
* Get tasks
|
|
361
|
-
*
|
|
362
|
-
* const result = await client.bpm.getTasks({
|
|
363
|
-
* assignee: 'user-123'
|
|
364
|
-
* });
|
|
269
|
+
* // Get all tasks
|
|
270
|
+
* const result = await client.bpm.getTasks();
|
|
365
271
|
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
272
|
+
* @example
|
|
273
|
+
* // Get tasks for current user
|
|
274
|
+
* const result = await client.bpm.getTasks({
|
|
275
|
+
* assignee: 'currentUserId'
|
|
368
276
|
* });
|
|
369
|
-
* ```
|
|
370
277
|
*
|
|
371
278
|
* @example
|
|
372
|
-
* Get tasks for
|
|
373
|
-
* ```typescript
|
|
279
|
+
* // Get tasks for a process
|
|
374
280
|
* const result = await client.bpm.getTasks({
|
|
375
|
-
*
|
|
376
|
-
*
|
|
281
|
+
* processDefinitionKey: 'approval-process',
|
|
282
|
+
* maxResults: 10
|
|
377
283
|
* });
|
|
378
|
-
*
|
|
284
|
+
*
|
|
285
|
+
* @since 1.0.0
|
|
379
286
|
*/
|
|
380
287
|
getTasks(params?: TaskQueryParams): Promise<ClientResult<Task[]>>;
|
|
381
288
|
|
|
@@ -385,13 +292,7 @@ export interface BpmClientAPI {
|
|
|
385
292
|
* @param params - Query parameters
|
|
386
293
|
* @returns Task count
|
|
387
294
|
*
|
|
388
|
-
* @
|
|
389
|
-
* ```typescript
|
|
390
|
-
* const result = await client.bpm.getTaskCount({
|
|
391
|
-
* assignee: 'user-123'
|
|
392
|
-
* });
|
|
393
|
-
* console.log(`You have ${result.data.count} tasks`);
|
|
394
|
-
* ```
|
|
295
|
+
* @since 1.0.0
|
|
395
296
|
*/
|
|
396
297
|
getTaskCount(params?: TaskQueryParams): Promise<ClientResult<TaskCount>>;
|
|
397
298
|
|
|
@@ -402,10 +303,12 @@ export interface BpmClientAPI {
|
|
|
402
303
|
* @returns Task information
|
|
403
304
|
*
|
|
404
305
|
* @example
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
306
|
+
* const result = await client.bpm.getTask('task-123');
|
|
307
|
+
* if (result.success) {
|
|
308
|
+
* console.log('Task:', result.data.name);
|
|
309
|
+
* }
|
|
310
|
+
*
|
|
311
|
+
* @since 1.0.0
|
|
409
312
|
*/
|
|
410
313
|
getTask(taskId: string): Promise<ClientResult<Task>>;
|
|
411
314
|
|
|
@@ -417,24 +320,24 @@ export interface BpmClientAPI {
|
|
|
417
320
|
* @returns null on success
|
|
418
321
|
*
|
|
419
322
|
* @example
|
|
420
|
-
* Complete with
|
|
421
|
-
*
|
|
422
|
-
* await client.bpm.completeTask('task-123', {
|
|
323
|
+
* // Complete with approval
|
|
324
|
+
* const result = await client.bpm.completeTask('task-123', {
|
|
423
325
|
* approved: true,
|
|
424
|
-
*
|
|
326
|
+
* comments: 'Looks good!'
|
|
425
327
|
* });
|
|
426
|
-
*
|
|
328
|
+
*
|
|
329
|
+
* if (result.success) {
|
|
330
|
+
* console.log('Task completed');
|
|
331
|
+
* }
|
|
427
332
|
*
|
|
428
333
|
* @example
|
|
429
|
-
* Complete with
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* approved: { value: false, type: 'Boolean' },
|
|
434
|
-
* reason: { value: 'Insufficient budget', type: 'String' }
|
|
435
|
-
* }
|
|
334
|
+
* // Complete with rejection
|
|
335
|
+
* const result = await client.bpm.completeTask('task-456', {
|
|
336
|
+
* approved: false,
|
|
337
|
+
* reason: 'Missing documentation'
|
|
436
338
|
* });
|
|
437
|
-
*
|
|
339
|
+
*
|
|
340
|
+
* @since 1.0.0
|
|
438
341
|
*/
|
|
439
342
|
completeTask(
|
|
440
343
|
taskId: string,
|
|
@@ -448,17 +351,7 @@ export interface BpmClientAPI {
|
|
|
448
351
|
*
|
|
449
352
|
* @param params - Query parameters
|
|
450
353
|
* @returns Array of historical process instances
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* Get completed processes:
|
|
454
|
-
* ```typescript
|
|
455
|
-
* const result = await client.bpm.getHistoryProcessInstances({
|
|
456
|
-
* finished: true,
|
|
457
|
-
* processDefinitionKey: 'approval',
|
|
458
|
-
* sortBy: 'startTime',
|
|
459
|
-
* sortOrder: 'desc'
|
|
460
|
-
* });
|
|
461
|
-
* ```
|
|
354
|
+
*
|
|
462
355
|
*/
|
|
463
356
|
getHistoryProcessInstances(
|
|
464
357
|
params?: HistoryProcessInstanceQueryParams
|
|
@@ -469,15 +362,7 @@ export interface BpmClientAPI {
|
|
|
469
362
|
*
|
|
470
363
|
* @param params - Query parameters
|
|
471
364
|
* @returns Process count
|
|
472
|
-
*
|
|
473
|
-
* @example
|
|
474
|
-
* ```typescript
|
|
475
|
-
* const result = await client.bpm.getHistoryProcessInstanceCount({
|
|
476
|
-
* startedBy: 'user-123',
|
|
477
|
-
* finished: true
|
|
478
|
-
* });
|
|
479
|
-
* console.log(`Completed: ${result.data.count} processes`);
|
|
480
|
-
* ```
|
|
365
|
+
*
|
|
481
366
|
*/
|
|
482
367
|
getHistoryProcessInstanceCount(
|
|
483
368
|
params?: HistoryProcessInstanceQueryParams
|
package/types/common.d.ts
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Common Types - Shared across all modules
|
|
4
|
-
* ============================================================================
|
|
2
|
+
* Error information structure
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
4
|
+
* @since 1.1.0
|
|
9
5
|
*/
|
|
6
|
+
export interface ClientError {
|
|
7
|
+
/**
|
|
8
|
+
* HTTP status code
|
|
9
|
+
*/
|
|
10
|
+
status: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Error message
|
|
14
|
+
*/
|
|
15
|
+
message: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Application-specific error code (e.g., 'INVALID_TOKEN', 'PERMISSION_DENIED')
|
|
19
|
+
*
|
|
20
|
+
* @since 1.1.0
|
|
21
|
+
*/
|
|
22
|
+
code?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Additional error details (optional)
|
|
26
|
+
*/
|
|
27
|
+
details?: unknown;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Error timestamp (ISO 8601 format)
|
|
31
|
+
*
|
|
32
|
+
* @since 1.1.0
|
|
33
|
+
*/
|
|
34
|
+
timestamp?: string;
|
|
35
|
+
}
|
|
10
36
|
|
|
11
37
|
/**
|
|
12
38
|
* Standard API response wrapper
|
|
@@ -17,33 +43,21 @@
|
|
|
17
43
|
* @template T - The type of the successful response data
|
|
18
44
|
*
|
|
19
45
|
* @example
|
|
20
|
-
* Success
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* console.log('User:', result.data); // Type: User
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* Error handling:
|
|
30
|
-
* ```typescript
|
|
31
|
-
* const result = await client.entity.get('default', 'users', '123');
|
|
32
|
-
* if (result.error) {
|
|
33
|
-
* console.error(`Error ${result.error.status}:`, result.error.message);
|
|
46
|
+
* // Success case
|
|
47
|
+
* const result = await client.entity.list('default', 'users');
|
|
48
|
+
* if (result.success) {
|
|
49
|
+
* console.log('Data:', result.data);
|
|
34
50
|
* }
|
|
35
|
-
* ```
|
|
36
51
|
*
|
|
37
52
|
* @example
|
|
38
|
-
*
|
|
39
|
-
* ```typescript
|
|
53
|
+
* // Error case
|
|
40
54
|
* const result = await client.auth.login({ email, password });
|
|
41
|
-
* if (result.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* // Unauthorized
|
|
55
|
+
* if (!result.success) {
|
|
56
|
+
* console.error('Error:', result.error.message);
|
|
57
|
+
* console.error('Code:', result.error.code);
|
|
45
58
|
* }
|
|
46
|
-
*
|
|
59
|
+
*
|
|
60
|
+
* @since 1.0.0
|
|
47
61
|
*/
|
|
48
62
|
export interface ClientResult<T> {
|
|
49
63
|
/**
|
|
@@ -54,27 +68,21 @@ export interface ClientResult<T> {
|
|
|
54
68
|
/**
|
|
55
69
|
* Error information (null if successful)
|
|
56
70
|
*/
|
|
57
|
-
error:
|
|
58
|
-
/**
|
|
59
|
-
* HTTP status code
|
|
60
|
-
*/
|
|
61
|
-
status: number;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Error message
|
|
65
|
-
*/
|
|
66
|
-
message: string;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Additional error details (optional)
|
|
70
|
-
*/
|
|
71
|
-
details?: unknown;
|
|
72
|
-
} | null;
|
|
71
|
+
error: ClientError | null;
|
|
73
72
|
|
|
74
73
|
/**
|
|
75
74
|
* HTTP response status code
|
|
76
75
|
*/
|
|
77
76
|
status: number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Convenience flag for checking if request was successful
|
|
80
|
+
*
|
|
81
|
+
* Equivalent to `error === null`
|
|
82
|
+
*
|
|
83
|
+
* @since 1.1.0
|
|
84
|
+
*/
|
|
85
|
+
success: boolean;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
/**
|