@amaster.ai/client 1.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +847 -0
- package/dist/index.cjs +162 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +421 -0
- package/dist/index.d.ts +421 -0
- package/dist/index.js +160 -0
- package/dist/index.js.map +1 -0
- package/package.json +108 -0
- package/types/__tests__/type-checks.test-d.ts +163 -0
- package/types/asr.d.ts +237 -0
- package/types/auth/code-auth.d.ts +105 -0
- package/types/auth/index.d.ts +138 -0
- package/types/auth/oauth.d.ts +143 -0
- package/types/auth/password-auth.d.ts +226 -0
- package/types/auth/profile.d.ts +64 -0
- package/types/auth/user.d.ts +73 -0
- package/types/bpm.d.ts +621 -0
- package/types/common.d.ts +140 -0
- package/types/copilot.d.ts +49 -0
- package/types/entity.d.ts +433 -0
- package/types/function.d.ts +41 -0
- package/types/http.d.ts +95 -0
- package/types/index.d.ts +338 -0
- package/types/s3.d.ts +96 -0
- package/types/tts.d.ts +88 -0
- package/types/workflow.d.ts +142 -0
package/types/bpm.d.ts
ADDED
|
@@ -0,0 +1,621 @@
|
|
|
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
|
+
*
|
|
16
|
+
* @module bpm
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { ClientResult } from "./common";
|
|
20
|
+
|
|
21
|
+
// ==================== Variable Types ====================
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Camunda variable type
|
|
25
|
+
*/
|
|
26
|
+
export type CamundaVariableType =
|
|
27
|
+
| "String"
|
|
28
|
+
| "Boolean"
|
|
29
|
+
| "Integer"
|
|
30
|
+
| "Long"
|
|
31
|
+
| "Double"
|
|
32
|
+
| "Date"
|
|
33
|
+
| "Json";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Camunda variable value (can be any JSON-serializable type)
|
|
37
|
+
*/
|
|
38
|
+
export type CamundaVariableValue =
|
|
39
|
+
| string
|
|
40
|
+
| number
|
|
41
|
+
| boolean
|
|
42
|
+
| Date
|
|
43
|
+
| null
|
|
44
|
+
| undefined
|
|
45
|
+
| Record<string, unknown>
|
|
46
|
+
| unknown[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Camunda variable with type hint
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const variable: CamundaVariable = {
|
|
54
|
+
* value: 1000,
|
|
55
|
+
* type: 'Long'
|
|
56
|
+
* };
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export interface CamundaVariable {
|
|
60
|
+
value: CamundaVariableValue;
|
|
61
|
+
type?: CamundaVariableType;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 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
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export interface VariableSubmission {
|
|
79
|
+
variables: Record<string, CamundaVariable>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ==================== Process Types ====================
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Process instance information
|
|
86
|
+
*/
|
|
87
|
+
export interface ProcessInstance {
|
|
88
|
+
/** Process instance ID (UUID) */
|
|
89
|
+
id: string;
|
|
90
|
+
/** Process definition ID */
|
|
91
|
+
definitionId?: string;
|
|
92
|
+
/** Business key for correlation */
|
|
93
|
+
businessKey?: string;
|
|
94
|
+
/** Whether the process has ended */
|
|
95
|
+
ended?: boolean;
|
|
96
|
+
/** Whether the process is suspended */
|
|
97
|
+
suspended?: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Process instance query parameters
|
|
102
|
+
*/
|
|
103
|
+
export interface ProcessInstanceQueryParams {
|
|
104
|
+
/** Filter by process definition key */
|
|
105
|
+
processDefinitionKey?: string;
|
|
106
|
+
/** Filter active/inactive processes */
|
|
107
|
+
active?: boolean;
|
|
108
|
+
/** Pagination: first result index */
|
|
109
|
+
firstResult?: number;
|
|
110
|
+
/** Pagination: max results to return */
|
|
111
|
+
maxResults?: number;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Historical process instance
|
|
116
|
+
*/
|
|
117
|
+
export interface HistoryProcessInstance {
|
|
118
|
+
/** Process instance ID */
|
|
119
|
+
id: string;
|
|
120
|
+
/** Business key */
|
|
121
|
+
businessKey: string;
|
|
122
|
+
/** Process definition ID */
|
|
123
|
+
processDefinitionId: string;
|
|
124
|
+
/** Process definition key */
|
|
125
|
+
processDefinitionKey: string;
|
|
126
|
+
/** Process definition name */
|
|
127
|
+
processDefinitionName: string;
|
|
128
|
+
/** Process definition version */
|
|
129
|
+
processDefinitionVersion: number;
|
|
130
|
+
/** Start timestamp (ISO 8601) */
|
|
131
|
+
startTime: string;
|
|
132
|
+
/** End timestamp (null if still running) */
|
|
133
|
+
endTime: string | null;
|
|
134
|
+
/** Duration in milliseconds (null if still running) */
|
|
135
|
+
durationInMillis: number | null;
|
|
136
|
+
/** User who started the process */
|
|
137
|
+
startUserId: string;
|
|
138
|
+
/** Start activity ID */
|
|
139
|
+
startActivityId: string;
|
|
140
|
+
/** Delete reason (if deleted) */
|
|
141
|
+
deleteReason: string | null;
|
|
142
|
+
/** Process state */
|
|
143
|
+
state: string;
|
|
144
|
+
/** Parent process instance ID (if subprocess) */
|
|
145
|
+
superProcessInstanceId?: string;
|
|
146
|
+
/** Parent case instance ID (if CMMN) */
|
|
147
|
+
superCaseInstanceId?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ==================== Task Types ====================
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* User task information
|
|
154
|
+
*/
|
|
155
|
+
export interface Task {
|
|
156
|
+
/** Task ID */
|
|
157
|
+
id: string;
|
|
158
|
+
/** Task name */
|
|
159
|
+
name: string;
|
|
160
|
+
/** Task description */
|
|
161
|
+
description?: string | null;
|
|
162
|
+
/** Assignee user ID */
|
|
163
|
+
assignee?: string | null;
|
|
164
|
+
/** Task owner */
|
|
165
|
+
owner?: string | null;
|
|
166
|
+
/** Task creation time */
|
|
167
|
+
created?: string | null;
|
|
168
|
+
/** Task due date */
|
|
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;
|
|
176
|
+
/** Task priority */
|
|
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;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Task query parameters
|
|
208
|
+
*/
|
|
209
|
+
export interface TaskQueryParams {
|
|
210
|
+
/** Filter by assignee */
|
|
211
|
+
assignee?: string;
|
|
212
|
+
/** Filter by process definition key */
|
|
213
|
+
processDefinitionKey?: string;
|
|
214
|
+
/** Filter by task definition key */
|
|
215
|
+
taskDefinitionKey?: string;
|
|
216
|
+
/** Filter by process instance ID */
|
|
217
|
+
processInstanceId?: string;
|
|
218
|
+
/** Pagination: first result index */
|
|
219
|
+
firstResult?: number;
|
|
220
|
+
/** Pagination: max results to return */
|
|
221
|
+
maxResults?: number;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Task count result
|
|
226
|
+
*/
|
|
227
|
+
export interface TaskCount {
|
|
228
|
+
count: number;
|
|
229
|
+
}
|
|
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
|
+
|
|
291
|
+
// ==================== BPM Client API ====================
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Business Process Management (BPM) Client API
|
|
295
|
+
*
|
|
296
|
+
* Provides methods for managing BPMN processes and tasks.
|
|
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
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
export interface BpmClientAPI {
|
|
327
|
+
// ==================== Process Management ====================
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Start a new process instance
|
|
331
|
+
*
|
|
332
|
+
* @param processKey - Process definition key (from BPMN diagram)
|
|
333
|
+
* @param inputs - Process variables (can be simple object or VariableSubmission)
|
|
334
|
+
* @returns New process instance information
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* // Simple start
|
|
338
|
+
* const result = await client.bpm.startProcess('approval-process', {
|
|
339
|
+
* amount: 1000,
|
|
340
|
+
* requester: 'john@example.com'
|
|
341
|
+
* });
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* // With business key
|
|
346
|
+
* const result = await client.bpm.startProcess('order-fulfillment', {
|
|
347
|
+
* orderId: 'ORDER-12345',
|
|
348
|
+
* items: [{ sku: 'ITEM-1', qty: 2 }]
|
|
349
|
+
* });
|
|
350
|
+
*
|
|
351
|
+
* @since 1.0.0
|
|
352
|
+
*/
|
|
353
|
+
startProcess(
|
|
354
|
+
processKey: string,
|
|
355
|
+
inputs?: Record<string, CamundaVariableValue> | VariableSubmission
|
|
356
|
+
): Promise<ClientResult<ProcessInstance>>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Query process instances
|
|
360
|
+
*
|
|
361
|
+
* @param params - Query parameters
|
|
362
|
+
* @returns Array of process instances
|
|
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
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
getProcessInstances(
|
|
374
|
+
params?: ProcessInstanceQueryParams
|
|
375
|
+
): Promise<ClientResult<ProcessInstance[]>>;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Get a single process instance by ID
|
|
379
|
+
*
|
|
380
|
+
* @param processInstanceId - Process instance ID
|
|
381
|
+
* @returns Process instance information
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```typescript
|
|
385
|
+
* const result = await client.bpm.getProcessInstance('proc-123-456');
|
|
386
|
+
* console.log('Process:', result.data);
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
getProcessInstance(processInstanceId: string): Promise<ClientResult<ProcessInstance>>;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Delete a process instance
|
|
393
|
+
*
|
|
394
|
+
* @param processInstanceId - Process instance ID
|
|
395
|
+
* @param params - Optional parameters
|
|
396
|
+
* @returns null on success
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* await client.bpm.deleteProcessInstance('proc-123');
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
deleteProcessInstance(
|
|
404
|
+
processInstanceId: string,
|
|
405
|
+
params?: { skipCustomListeners?: boolean }
|
|
406
|
+
): Promise<ClientResult<null>>;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Get process variables
|
|
410
|
+
*
|
|
411
|
+
* @param params - Process instance ID and optional variable name
|
|
412
|
+
* @returns Array of process variables
|
|
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
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
getProcessVariables(params: {
|
|
432
|
+
processInstanceId: string;
|
|
433
|
+
variableName?: string;
|
|
434
|
+
}): Promise<ClientResult<ProcessVariable[]>>;
|
|
435
|
+
|
|
436
|
+
// ==================== Task Management ====================
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Query user tasks
|
|
440
|
+
*
|
|
441
|
+
* @param params - Query parameters
|
|
442
|
+
* @returns Array of tasks
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
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
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* // Get tasks for current user
|
|
458
|
+
* const result = await client.bpm.getTasks({
|
|
459
|
+
* assignee: 'currentUserId'
|
|
460
|
+
* });
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* // Get tasks for a process
|
|
464
|
+
* const result = await client.bpm.getTasks({
|
|
465
|
+
* processDefinitionKey: 'approval-process',
|
|
466
|
+
* maxResults: 10
|
|
467
|
+
* });
|
|
468
|
+
*
|
|
469
|
+
* @since 1.0.0
|
|
470
|
+
*/
|
|
471
|
+
getTasks(params?: TaskQueryParams): Promise<ClientResult<Task[]>>;
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Get task count
|
|
475
|
+
*
|
|
476
|
+
* @param params - Query parameters
|
|
477
|
+
* @returns Task count
|
|
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
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
getTaskCount(params?: TaskQueryParams): Promise<ClientResult<TaskCount>>;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Get a single task by ID
|
|
491
|
+
*
|
|
492
|
+
* @param taskId - Task ID
|
|
493
|
+
* @returns Task information
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* const result = await client.bpm.getTask('task-123');
|
|
497
|
+
* if (result.success) {
|
|
498
|
+
* console.log('Task:', result.data.name);
|
|
499
|
+
* }
|
|
500
|
+
*
|
|
501
|
+
* @since 1.0.0
|
|
502
|
+
*/
|
|
503
|
+
getTask(taskId: string): Promise<ClientResult<Task>>;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Complete a user task
|
|
507
|
+
*
|
|
508
|
+
* @param taskId - Task ID
|
|
509
|
+
* @param inputs - Task variables (can be simple object or VariableSubmission)
|
|
510
|
+
* @returns null on success
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* // Complete with approval
|
|
514
|
+
* const result = await client.bpm.completeTask('task-123', {
|
|
515
|
+
* approved: true,
|
|
516
|
+
* comments: 'Looks good!'
|
|
517
|
+
* });
|
|
518
|
+
* ```
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* // Complete with rejection
|
|
522
|
+
* const result = await client.bpm.completeTask('task-456', {
|
|
523
|
+
* approved: false,
|
|
524
|
+
* reason: 'Missing documentation'
|
|
525
|
+
* });
|
|
526
|
+
*
|
|
527
|
+
* @since 1.0.0
|
|
528
|
+
*/
|
|
529
|
+
completeTask(
|
|
530
|
+
taskId: string,
|
|
531
|
+
inputs: Record<string, CamundaVariableValue> | VariableSubmission
|
|
532
|
+
): Promise<ClientResult<null>>;
|
|
533
|
+
|
|
534
|
+
// ==================== History & Reporting ====================
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Query historical process instances
|
|
538
|
+
*
|
|
539
|
+
* @param params - Query parameters
|
|
540
|
+
* @returns Array of historical process instances
|
|
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
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
getHistoryProcessInstances(
|
|
554
|
+
params?: HistoryProcessInstanceQueryParams
|
|
555
|
+
): Promise<ClientResult<HistoryProcessInstance[]>>;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Get historical process instance count
|
|
559
|
+
*
|
|
560
|
+
* @param params - Query parameters
|
|
561
|
+
* @returns Process count
|
|
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
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
getHistoryProcessInstanceCount(
|
|
573
|
+
params?: HistoryProcessInstanceQueryParams
|
|
574
|
+
): Promise<ClientResult<{ count: number }>>;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Process variable information
|
|
579
|
+
*/
|
|
580
|
+
export interface ProcessVariable {
|
|
581
|
+
/** Variable ID */
|
|
582
|
+
id: string;
|
|
583
|
+
/** Variable name */
|
|
584
|
+
name: string;
|
|
585
|
+
/** Variable type */
|
|
586
|
+
type: string;
|
|
587
|
+
/** Variable value */
|
|
588
|
+
value: CamundaVariableValue;
|
|
589
|
+
/** Process instance ID */
|
|
590
|
+
processInstanceId: string;
|
|
591
|
+
/** Creation time */
|
|
592
|
+
createTime?: string;
|
|
593
|
+
/** Activity instance ID */
|
|
594
|
+
activityInstanceId?: string;
|
|
595
|
+
/** Task ID (if task variable) */
|
|
596
|
+
taskId?: string;
|
|
597
|
+
/** Execution ID */
|
|
598
|
+
executionId?: string;
|
|
599
|
+
/** Error message (if any) */
|
|
600
|
+
errorMessage?: string;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Historical process instance query parameters
|
|
605
|
+
*/
|
|
606
|
+
export interface HistoryProcessInstanceQueryParams {
|
|
607
|
+
/** Filter by user who started the process */
|
|
608
|
+
startedBy?: string;
|
|
609
|
+
/** Filter finished/unfinished processes */
|
|
610
|
+
finished?: boolean;
|
|
611
|
+
/** Filter by process definition key */
|
|
612
|
+
processDefinitionKey?: string;
|
|
613
|
+
/** Sort field */
|
|
614
|
+
sortBy?: string;
|
|
615
|
+
/** Sort order */
|
|
616
|
+
sortOrder?: "asc" | "desc";
|
|
617
|
+
/** Pagination: first result index */
|
|
618
|
+
firstResult?: number;
|
|
619
|
+
/** Pagination: max results to return */
|
|
620
|
+
maxResults?: number;
|
|
621
|
+
}
|