@amaster.ai/client 1.1.0-beta.31 → 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.
Files changed (2) hide show
  1. package/package.json +12 -12
  2. package/types/bpm.d.ts +259 -54
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/client",
3
- "version": "1.1.0-beta.31",
3
+ "version": "1.1.0-beta.32",
4
4
  "description": "Unified API client for Amaster platform - All services in one package",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -72,17 +72,17 @@
72
72
  "registry": "https://registry.npmjs.org/"
73
73
  },
74
74
  "dependencies": {
75
- "@amaster.ai/asr-http-client": "1.1.0-beta.31",
76
- "@amaster.ai/copilot-client": "1.1.0-beta.31",
77
- "@amaster.ai/auth-client": "1.1.0-beta.31",
78
- "@amaster.ai/asr-client": "1.1.0-beta.31",
79
- "@amaster.ai/http-client": "1.1.0-beta.31",
80
- "@amaster.ai/function-client": "1.1.0-beta.31",
81
- "@amaster.ai/bpm-client": "1.1.0-beta.31",
82
- "@amaster.ai/s3-client": "1.1.0-beta.31",
83
- "@amaster.ai/entity-client": "1.1.0-beta.31",
84
- "@amaster.ai/workflow-client": "1.1.0-beta.31",
85
- "@amaster.ai/tts-client": "1.1.0-beta.31"
75
+ "@amaster.ai/bpm-client": "1.1.0-beta.32",
76
+ "@amaster.ai/entity-client": "1.1.0-beta.32",
77
+ "@amaster.ai/asr-client": "1.1.0-beta.32",
78
+ "@amaster.ai/auth-client": "1.1.0-beta.32",
79
+ "@amaster.ai/http-client": "1.1.0-beta.32",
80
+ "@amaster.ai/s3-client": "1.1.0-beta.32",
81
+ "@amaster.ai/workflow-client": "1.1.0-beta.32",
82
+ "@amaster.ai/function-client": "1.1.0-beta.32",
83
+ "@amaster.ai/copilot-client": "1.1.0-beta.32",
84
+ "@amaster.ai/asr-http-client": "1.1.0-beta.32",
85
+ "@amaster.ai/tts-client": "1.1.0-beta.32"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "axios": "^1.11.0"
package/types/bpm.d.ts CHANGED
@@ -1,9 +1,22 @@
1
1
  /**
2
- *
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
+ *
3
16
  * @module bpm
4
17
  */
5
18
 
6
- import type { ClientResult } from './common';
19
+ import type { ClientResult } from "./common";
7
20
 
8
21
  // ==================== Variable Types ====================
9
22
 
@@ -11,13 +24,13 @@ import type { ClientResult } from './common';
11
24
  * Camunda variable type
12
25
  */
13
26
  export type CamundaVariableType =
14
- | 'String'
15
- | 'Boolean'
16
- | 'Integer'
17
- | 'Long'
18
- | 'Double'
19
- | 'Date'
20
- | 'Json';
27
+ | "String"
28
+ | "Boolean"
29
+ | "Integer"
30
+ | "Long"
31
+ | "Double"
32
+ | "Date"
33
+ | "Json";
21
34
 
22
35
  /**
23
36
  * Camunda variable value (can be any JSON-serializable type)
@@ -35,6 +48,13 @@ export type CamundaVariableValue =
35
48
  /**
36
49
  * Camunda variable with type hint
37
50
  *
51
+ * @example
52
+ * ```typescript
53
+ * const variable: CamundaVariable = {
54
+ * value: 1000,
55
+ * type: 'Long'
56
+ * };
57
+ * ```
38
58
  */
39
59
  export interface CamundaVariable {
40
60
  value: CamundaVariableValue;
@@ -44,6 +64,16 @@ export interface CamundaVariable {
44
64
  /**
45
65
  * Variable submission format for process/task
46
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
+ * ```
47
77
  */
48
78
  export interface VariableSubmission {
49
79
  variables: Record<string, CamundaVariable>;
@@ -127,18 +157,50 @@ export interface Task {
127
157
  id: string;
128
158
  /** Task name */
129
159
  name: string;
160
+ /** Task description */
161
+ description?: string | null;
130
162
  /** Assignee user ID */
131
- assignee: string | null;
132
- /** Process instance ID */
133
- processInstanceId: string;
134
- /** Task definition key */
135
- taskDefinitionKey: string;
163
+ assignee?: string | null;
164
+ /** Task owner */
165
+ owner?: string | null;
136
166
  /** Task creation time */
137
- created: string;
167
+ created?: string | null;
138
168
  /** Task due date */
139
- due: string | null;
169
+ due?: string | null;
170
+ /** Task follow-up date */
171
+ followUp?: string | null;
172
+ /** Last update time */
173
+ lastUpdated?: string | null;
174
+ /** Delegation state */
175
+ delegationState?: string | null;
140
176
  /** Task priority */
141
- priority: number;
177
+ priority?: number;
178
+ /** Process instance ID */
179
+ processInstanceId?: string | null;
180
+ /** Process definition ID */
181
+ processDefinitionId?: string | null;
182
+ /** Execution ID */
183
+ executionId?: string | null;
184
+ /** Task definition key */
185
+ taskDefinitionKey?: string | null;
186
+ /** Parent task ID */
187
+ parentTaskId?: string | null;
188
+ /** Case execution ID */
189
+ caseExecutionId?: string | null;
190
+ /** Case instance ID */
191
+ caseInstanceId?: string | null;
192
+ /** Case definition ID */
193
+ caseDefinitionId?: string | null;
194
+ /** Whether task is suspended */
195
+ suspended?: boolean;
196
+ /** Form key */
197
+ formKey?: string | null;
198
+ /** Camunda form reference */
199
+ camundaFormRef?: string | null;
200
+ /** Tenant ID */
201
+ tenantId?: string | null;
202
+ /** Task state */
203
+ taskState?: string | null;
142
204
  }
143
205
 
144
206
  /**
@@ -166,36 +228,119 @@ export interface TaskCount {
166
228
  count: number;
167
229
  }
168
230
 
231
+ /**
232
+ * Historical task information
233
+ */
234
+ export interface HistoryTask {
235
+ /** Task ID */
236
+ id: string;
237
+ /** Task name */
238
+ name: string;
239
+ /** Task description */
240
+ description?: string | null;
241
+ /** Assignee user ID */
242
+ assignee?: string | null;
243
+ /** Task owner */
244
+ owner?: string | null;
245
+ /** Task start time */
246
+ startTime: string;
247
+ /** Task end time */
248
+ endTime?: string | null;
249
+ /** Task duration in milliseconds */
250
+ duration?: number | null;
251
+ /** Task due date */
252
+ due?: string | null;
253
+ /** Task follow-up date */
254
+ followUp?: string | null;
255
+ /** Task priority */
256
+ priority?: number;
257
+ /** Task state */
258
+ taskState?: string | null;
259
+ /** Delete reason */
260
+ deleteReason?: string | null;
261
+ /** Process instance ID */
262
+ processInstanceId?: string | null;
263
+ /** Process definition ID */
264
+ processDefinitionId?: string | null;
265
+ /** Process definition key */
266
+ processDefinitionKey?: string | null;
267
+ /** Execution ID */
268
+ executionId?: string | null;
269
+ /** Task definition key */
270
+ taskDefinitionKey?: string | null;
271
+ /** Parent task ID */
272
+ parentTaskId?: string | null;
273
+ /** Activity instance ID */
274
+ activityInstanceId?: string | null;
275
+ /** Case definition key */
276
+ caseDefinitionKey?: string | null;
277
+ /** Case definition ID */
278
+ caseDefinitionId?: string | null;
279
+ /** Case instance ID */
280
+ caseInstanceId?: string | null;
281
+ /** Case execution ID */
282
+ caseExecutionId?: string | null;
283
+ /** Tenant ID */
284
+ tenantId?: string | null;
285
+ /** Removal time */
286
+ removalTime?: string | null;
287
+ /** Root process instance ID */
288
+ rootProcessInstanceId?: string | null;
289
+ }
290
+
169
291
  // ==================== BPM Client API ====================
170
292
 
171
293
  /**
172
294
  * Business Process Management (BPM) Client API
173
- *
295
+ *
174
296
  * Provides methods for managing BPMN processes and tasks.
175
- *
176
- * @since 1.0.0
297
+ *
298
+ * @example
299
+ * Complete BPM flow:
300
+ * ```typescript
301
+ * const client = createClient({ baseURL: 'https://api.amaster.ai' });
302
+ *
303
+ * // 1. Start a process
304
+ * const process = await client.bpm.startProcess('approval', {
305
+ * amount: { value: 5000, type: 'Long' },
306
+ * requester: { value: 'user-123', type: 'String' },
307
+ * description: { value: 'Purchase request', type: 'String' }
308
+ * });
309
+ *
310
+ * console.log('Process started:', process.data.id);
311
+ *
312
+ * // 2. Get user's tasks
313
+ * const tasks = await client.bpm.getTasks({
314
+ * assignee: 'manager-456',
315
+ * processDefinitionKey: 'approval'
316
+ * });
317
+ *
318
+ * // 3. Complete a task
319
+ * const taskId = tasks.data[0].id;
320
+ * await client.bpm.completeTask(taskId, {
321
+ * approved: { value: true, type: 'Boolean' },
322
+ * comment: { value: 'Approved!', type: 'String' }
323
+ * });
324
+ * ```
177
325
  */
178
326
  export interface BpmClientAPI {
179
327
  // ==================== Process Management ====================
180
328
 
181
329
  /**
182
330
  * Start a new process instance
183
- *
331
+ *
184
332
  * @param processKey - Process definition key (from BPMN diagram)
185
333
  * @param inputs - Process variables (can be simple object or VariableSubmission)
186
334
  * @returns New process instance information
187
- *
335
+ *
188
336
  * @example
189
337
  * // Simple start
190
338
  * const result = await client.bpm.startProcess('approval-process', {
191
339
  * amount: 1000,
192
340
  * requester: 'john@example.com'
193
341
  * });
194
- *
195
- * if (result.success) {
196
- * console.log('Process started:', result.data.id);
197
- * }
198
- *
342
+ * ```
343
+ *
199
344
  * @example
200
345
  * // With business key
201
346
  * const result = await client.bpm.startProcess('order-fulfillment', {
@@ -212,10 +357,18 @@ export interface BpmClientAPI {
212
357
 
213
358
  /**
214
359
  * Query process instances
215
- *
360
+ *
216
361
  * @param params - Query parameters
217
362
  * @returns Array of process instances
218
363
  *
364
+ * @example
365
+ * Get all active approval processes:
366
+ * ```typescript
367
+ * const result = await client.bpm.getProcessInstances({
368
+ * processDefinitionKey: 'approval',
369
+ * active: true
370
+ * });
371
+ * ```
219
372
  */
220
373
  getProcessInstances(
221
374
  params?: ProcessInstanceQueryParams
@@ -223,22 +376,29 @@ export interface BpmClientAPI {
223
376
 
224
377
  /**
225
378
  * Get a single process instance by ID
226
- *
379
+ *
227
380
  * @param processInstanceId - Process instance ID
228
381
  * @returns Process instance information
229
382
  *
383
+ * @example
384
+ * ```typescript
385
+ * const result = await client.bpm.getProcessInstance('proc-123-456');
386
+ * console.log('Process:', result.data);
387
+ * ```
230
388
  */
231
- getProcessInstance(
232
- processInstanceId: string
233
- ): Promise<ClientResult<ProcessInstance>>;
389
+ getProcessInstance(processInstanceId: string): Promise<ClientResult<ProcessInstance>>;
234
390
 
235
391
  /**
236
392
  * Delete a process instance
237
- *
393
+ *
238
394
  * @param processInstanceId - Process instance ID
239
395
  * @param params - Optional parameters
240
396
  * @returns null on success
241
397
  *
398
+ * @example
399
+ * ```typescript
400
+ * await client.bpm.deleteProcessInstance('proc-123');
401
+ * ```
242
402
  */
243
403
  deleteProcessInstance(
244
404
  processInstanceId: string,
@@ -247,10 +407,26 @@ export interface BpmClientAPI {
247
407
 
248
408
  /**
249
409
  * Get process variables
250
- *
410
+ *
251
411
  * @param params - Process instance ID and optional variable name
252
412
  * @returns Array of process variables
253
413
  *
414
+ * @example
415
+ * Get all variables:
416
+ * ```typescript
417
+ * const result = await client.bpm.getProcessVariables({
418
+ * processInstanceId: 'proc-123'
419
+ * });
420
+ * ```
421
+ *
422
+ * @example
423
+ * Get specific variable:
424
+ * ```typescript
425
+ * const result = await client.bpm.getProcessVariables({
426
+ * processInstanceId: 'proc-123',
427
+ * variableName: 'amount'
428
+ * });
429
+ * ```
254
430
  */
255
431
  getProcessVariables(params: {
256
432
  processInstanceId: string;
@@ -261,14 +437,22 @@ export interface BpmClientAPI {
261
437
 
262
438
  /**
263
439
  * Query user tasks
264
- *
440
+ *
265
441
  * @param params - Query parameters
266
442
  * @returns Array of tasks
267
- *
443
+ *
268
444
  * @example
269
- * // Get all tasks
270
- * const result = await client.bpm.getTasks();
271
- *
445
+ * Get tasks assigned to current user:
446
+ * ```typescript
447
+ * const result = await client.bpm.getTasks({
448
+ * assignee: 'user-123'
449
+ * });
450
+ *
451
+ * result.data.forEach(task => {
452
+ * console.log(`Task: ${task.name} (${task.id})`);
453
+ * });
454
+ * ```
455
+ *
272
456
  * @example
273
457
  * // Get tasks for current user
274
458
  * const result = await client.bpm.getTasks({
@@ -288,20 +472,26 @@ export interface BpmClientAPI {
288
472
 
289
473
  /**
290
474
  * Get task count
291
- *
475
+ *
292
476
  * @param params - Query parameters
293
477
  * @returns Task count
294
- *
295
- * @since 1.0.0
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * const result = await client.bpm.getTaskCount({
482
+ * assignee: 'user-123'
483
+ * });
484
+ * console.log(`You have ${result.data.count} tasks`);
485
+ * ```
296
486
  */
297
487
  getTaskCount(params?: TaskQueryParams): Promise<ClientResult<TaskCount>>;
298
488
 
299
489
  /**
300
490
  * Get a single task by ID
301
- *
491
+ *
302
492
  * @param taskId - Task ID
303
493
  * @returns Task information
304
- *
494
+ *
305
495
  * @example
306
496
  * const result = await client.bpm.getTask('task-123');
307
497
  * if (result.success) {
@@ -314,22 +504,19 @@ export interface BpmClientAPI {
314
504
 
315
505
  /**
316
506
  * Complete a user task
317
- *
507
+ *
318
508
  * @param taskId - Task ID
319
509
  * @param inputs - Task variables (can be simple object or VariableSubmission)
320
510
  * @returns null on success
321
- *
511
+ *
322
512
  * @example
323
513
  * // Complete with approval
324
514
  * const result = await client.bpm.completeTask('task-123', {
325
515
  * approved: true,
326
516
  * comments: 'Looks good!'
327
517
  * });
328
- *
329
- * if (result.success) {
330
- * console.log('Task completed');
331
- * }
332
- *
518
+ * ```
519
+ *
333
520
  * @example
334
521
  * // Complete with rejection
335
522
  * const result = await client.bpm.completeTask('task-456', {
@@ -348,10 +535,20 @@ export interface BpmClientAPI {
348
535
 
349
536
  /**
350
537
  * Query historical process instances
351
- *
538
+ *
352
539
  * @param params - Query parameters
353
540
  * @returns Array of historical process instances
354
541
  *
542
+ * @example
543
+ * Get completed processes:
544
+ * ```typescript
545
+ * const result = await client.bpm.getHistoryProcessInstances({
546
+ * finished: true,
547
+ * processDefinitionKey: 'approval',
548
+ * sortBy: 'startTime',
549
+ * sortOrder: 'desc'
550
+ * });
551
+ * ```
355
552
  */
356
553
  getHistoryProcessInstances(
357
554
  params?: HistoryProcessInstanceQueryParams
@@ -359,10 +556,18 @@ export interface BpmClientAPI {
359
556
 
360
557
  /**
361
558
  * Get historical process instance count
362
- *
559
+ *
363
560
  * @param params - Query parameters
364
561
  * @returns Process count
365
562
  *
563
+ * @example
564
+ * ```typescript
565
+ * const result = await client.bpm.getHistoryProcessInstanceCount({
566
+ * startedBy: 'user-123',
567
+ * finished: true
568
+ * });
569
+ * console.log(`Completed: ${result.data.count} processes`);
570
+ * ```
366
571
  */
367
572
  getHistoryProcessInstanceCount(
368
573
  params?: HistoryProcessInstanceQueryParams
@@ -408,7 +613,7 @@ export interface HistoryProcessInstanceQueryParams {
408
613
  /** Sort field */
409
614
  sortBy?: string;
410
615
  /** Sort order */
411
- sortOrder?: 'asc' | 'desc';
616
+ sortOrder?: "asc" | "desc";
412
617
  /** Pagination: first result index */
413
618
  firstResult?: number;
414
619
  /** Pagination: max results to return */