@quantumbpm/sdk 0.0.1 → 1.0.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.
Files changed (82) hide show
  1. package/README.md +6 -0
  2. package/dist/bpmn.d.ts +35 -2
  3. package/dist/bpmn.js +10 -5
  4. package/dist/dmn.d.ts +5 -0
  5. package/dist/dmn.js +3 -1
  6. package/dist/generated/index.d.ts +5 -3
  7. package/dist/generated/index.js +4 -4
  8. package/dist/generated/models/BatchEvaluateDesignRequest.d.ts +3 -2
  9. package/dist/generated/models/BatchEvaluateDesignRequest.js +1 -1
  10. package/dist/generated/models/BpmnIncidentRecord.d.ts +88 -0
  11. package/dist/generated/models/BpmnIncidentRecord.js +23 -0
  12. package/dist/generated/models/BpmnIncidentRecordPaginatedResponse.d.ts +9 -0
  13. package/dist/generated/models/BpmnIncidentRecordPaginatedResponse.js +3 -0
  14. package/dist/generated/models/BpmnInstance.d.ts +24 -0
  15. package/dist/generated/models/BpmnInstance.js +1 -1
  16. package/dist/generated/models/BpmnInstanceState.d.ts +28 -5
  17. package/dist/generated/models/BpmnInstanceState.js +1 -1
  18. package/dist/generated/models/BpmnProcessVersion.d.ts +16 -0
  19. package/dist/generated/models/BpmnProcessVersion.js +1 -1
  20. package/dist/generated/models/EvaluateStoredRequest.d.ts +4 -0
  21. package/dist/generated/models/EvaluateStoredRequest.js +1 -1
  22. package/dist/generated/models/Execution.d.ts +4 -0
  23. package/dist/generated/models/Execution.js +1 -1
  24. package/dist/generated/models/ExternalJob.d.ts +8 -0
  25. package/dist/generated/models/ExternalJob.js +1 -1
  26. package/dist/generated/models/FeelNumber.d.ts +1 -1
  27. package/dist/generated/models/FeelNumber.js +1 -1
  28. package/dist/generated/models/StartBpmnInstanceRequest.d.ts +4 -0
  29. package/dist/generated/models/StartBpmnInstanceRequest.js +1 -1
  30. package/dist/generated/models/StartBpmnTestInstanceRequest.d.ts +4 -0
  31. package/dist/generated/models/StartBpmnTestInstanceRequest.js +1 -1
  32. package/dist/generated/models/SuspendBpmnDefinitionRequest.d.ts +6 -0
  33. package/dist/generated/models/SuspendBpmnDefinitionRequest.js +3 -0
  34. package/dist/generated/models/SuspendBpmnInstanceRequest.d.ts +9 -0
  35. package/dist/generated/models/SuspendBpmnInstanceRequest.js +3 -0
  36. package/dist/generated/models/SuspensionEntry.d.ts +22 -0
  37. package/dist/generated/models/SuspensionEntry.js +3 -0
  38. package/dist/generated/models/UserTask.d.ts +4 -0
  39. package/dist/generated/models/UserTask.js +1 -1
  40. package/dist/generated/services/BpmnService.d.ts +177 -22
  41. package/dist/generated/services/BpmnService.js +189 -28
  42. package/dist/generated/services/DefaultService.d.ts +33 -12
  43. package/dist/generated/services/DefaultService.js +37 -16
  44. package/dist/tracing.d.ts +17 -0
  45. package/dist/tracing.js +38 -0
  46. package/dist/workers.d.ts +25 -2
  47. package/dist/workers.js +53 -6
  48. package/package.json +2 -1
  49. package/src/bpmn.ts +46 -2
  50. package/src/dmn.ts +7 -0
  51. package/src/generated/index.ts +5 -3
  52. package/src/generated/models/BatchEvaluateDesignRequest.ts +3 -2
  53. package/src/generated/models/BpmnIncidentRecord.ts +93 -0
  54. package/src/generated/models/BpmnIncidentRecordPaginatedResponse.ts +14 -0
  55. package/src/generated/models/BpmnInstance.ts +24 -0
  56. package/src/generated/models/BpmnInstanceState.ts +28 -5
  57. package/src/generated/models/BpmnProcessVersion.ts +16 -0
  58. package/src/generated/models/EvaluateStoredRequest.ts +4 -0
  59. package/src/generated/models/Execution.ts +4 -0
  60. package/src/generated/models/ExternalJob.ts +8 -0
  61. package/src/generated/models/FeelNumber.ts +1 -1
  62. package/src/generated/models/StartBpmnInstanceRequest.ts +4 -0
  63. package/src/generated/models/StartBpmnTestInstanceRequest.ts +4 -0
  64. package/src/generated/models/SuspendBpmnDefinitionRequest.ts +11 -0
  65. package/src/generated/models/SuspendBpmnInstanceRequest.ts +14 -0
  66. package/src/generated/models/SuspensionEntry.ts +27 -0
  67. package/src/generated/models/UserTask.ts +4 -0
  68. package/src/generated/services/BpmnService.ts +265 -30
  69. package/src/generated/services/DefaultService.ts +48 -13
  70. package/src/index.test.ts +180 -0
  71. package/src/tracing.ts +49 -0
  72. package/src/workers.test.ts +117 -0
  73. package/src/workers.ts +75 -7
  74. package/dist/generated/models/BpmnActivityState.d.ts +0 -52
  75. package/dist/generated/models/BpmnActivityState.js +0 -17
  76. package/dist/generated/models/ExternalJobActiveWorkersItem.d.ts +0 -7
  77. package/dist/generated/models/ExternalJobActiveWorkersItem.js +0 -3
  78. package/dist/generated/models/ExternalJobActiveWorkersResponse.d.ts +0 -7
  79. package/dist/generated/models/ExternalJobActiveWorkersResponse.js +0 -3
  80. package/src/generated/models/BpmnActivityState.ts +0 -57
  81. package/src/generated/models/ExternalJobActiveWorkersItem.ts +0 -12
  82. package/src/generated/models/ExternalJobActiveWorkersResponse.ts +0 -12
@@ -1,3 +1,4 @@
1
+ import type { BpmnIncidentRecordPaginatedResponse } from '../models/BpmnIncidentRecordPaginatedResponse';
1
2
  import type { BpmnInstanceChildrenResponse } from '../models/BpmnInstanceChildrenResponse';
2
3
  import type { BpmnProcessSummaryPaginatedResponse } from '../models/BpmnProcessSummaryPaginatedResponse';
3
4
  import type { BpmnProcessVersionPaginatedResponse } from '../models/BpmnProcessVersionPaginatedResponse';
@@ -8,13 +9,14 @@ import type { BpmnUserTaskPaginatedResponse } from '../models/BpmnUserTaskPagina
8
9
  import type { BpmnValidateResponse } from '../models/BpmnValidateResponse';
9
10
  import type { CorrelationKeys } from '../models/CorrelationKeys';
10
11
  import type { CreateBpmnResourceRequest } from '../models/CreateBpmnResourceRequest';
11
- import type { ExternalJobActiveWorkersResponse } from '../models/ExternalJobActiveWorkersResponse';
12
12
  import type { ExternalJobBatchResponse } from '../models/ExternalJobBatchResponse';
13
13
  import type { ExternalJobQueueDepthResponse } from '../models/ExternalJobQueueDepthResponse';
14
14
  import type { MigrateBpmnInstanceRequest } from '../models/MigrateBpmnInstanceRequest';
15
15
  import type { MigrationValidationResult } from '../models/MigrationValidationResult';
16
16
  import type { ModifyBpmnInstanceRequest } from '../models/ModifyBpmnInstanceRequest';
17
17
  import type { StartBpmnTestInstanceRequest } from '../models/StartBpmnTestInstanceRequest';
18
+ import type { SuspendBpmnDefinitionRequest } from '../models/SuspendBpmnDefinitionRequest';
19
+ import type { SuspendBpmnInstanceRequest } from '../models/SuspendBpmnInstanceRequest';
18
20
  import type { UpdateUserTaskAssignmentRequest } from '../models/UpdateUserTaskAssignmentRequest';
19
21
  import type { UserTask } from '../models/UserTask';
20
22
  import type { ValidateBpmnResourceRequest } from '../models/ValidateBpmnResourceRequest';
@@ -199,6 +201,32 @@ export declare class BpmnService {
199
201
  resolveBpmnIncident(projectId: string, workflowId: string, incidentId: string, requestBody?: {
200
202
  variables?: Record<string, any>;
201
203
  }): CancelablePromise<any>;
204
+ /**
205
+ * List BPMN incidents
206
+ * Cross-instance audit listing of incidents in the project. By default
207
+ * returns open incidents first (unresolved), ordered by recency.
208
+ * Filterable by definition, error type, status, and time window.
209
+ *
210
+ * Each row carries the parent process metadata (processID, processName)
211
+ * so a single page render needs no follow-up queries against the
212
+ * instances endpoint. Click-through to a specific instance still uses
213
+ * the workflow-scoped detail endpoint.
214
+ *
215
+ * @param projectId
216
+ * @param definitionId Restrict to incidents on instances of a single process definition.
217
+ * @param workflowId Restrict to incidents on a single instance — useful for an instance-detail "all incidents ever raised here" view that includes resolved rows.
218
+ * @param status Filter by lifecycle status. `open` returns unresolved incidents;
219
+ * `resolved` returns only resolved ones. Omit to return both.
220
+ *
221
+ * @param errorType Restrict to a single error category (matches `BpmnIncidentRecord.errorType`).
222
+ * @param since Earliest `raisedAt` to include (inclusive).
223
+ * @param until Latest `raisedAt` to include (exclusive).
224
+ * @param page
225
+ * @param pageSize
226
+ * @returns BpmnIncidentRecordPaginatedResponse OK
227
+ * @throws ApiError
228
+ */
229
+ listBpmnIncidents(projectId: string, definitionId?: string, workflowId?: string, status?: 'open' | 'resolved', errorType?: 'BpmnError' | 'EscalationError' | 'CompensationError' | 'FeelError' | 'NoHandler' | 'GatewayNoMatch' | 'TimerResolution' | 'LinkNotFound' | 'MigrationError' | 'Unknown', since?: string, until?: string, page?: number, pageSize?: number): CancelablePromise<BpmnIncidentRecordPaginatedResponse>;
202
230
  /**
203
231
  * Migrate a running instance to a newer process version
204
232
  * Moves a running instance from its current process version to a newer
@@ -273,6 +301,79 @@ export declare class BpmnService {
273
301
  setBpmnAdHocVariables(projectId: string, workflowId: string, adHocNodeId: string, requestBody: {
274
302
  variables?: Record<string, any>;
275
303
  }): CancelablePromise<any>;
304
+ /**
305
+ * Suspend a BPMN instance
306
+ * Pauses forward token dispatch on a single running instance. The
307
+ * instance's lifecycle status stays RUNNING; an orthogonal `suspendedAt`
308
+ * flag layers on top. Idempotent — a second call against an already-
309
+ * suspended instance is a no-op.
310
+ *
311
+ * While suspended: cancel / terminate / migrate / force-rotate / resolve-
312
+ * incident / variable update / modify all still work. Parked tokens
313
+ * released by signal demuxes or timer fires queue internally and dispatch
314
+ * on resume.
315
+ *
316
+ * The audit (operator, reason, timestamp) is also recorded in the
317
+ * workflow's Temporal history as a `SuspendInstanceEvent` so the timeline
318
+ * view on the instance detail page can render the cycle.
319
+ *
320
+ * @param projectId
321
+ * @param workflowId
322
+ * @param requestBody
323
+ * @returns void
324
+ * @throws ApiError
325
+ */
326
+ suspendBpmnInstance(projectId: string, workflowId: string, requestBody?: SuspendBpmnInstanceRequest): CancelablePromise<void>;
327
+ /**
328
+ * Resume a suspended BPMN instance
329
+ * Clears the instance-scope suspension. If the parent definition is also
330
+ * suspended the instance remains effectively paused until the definition
331
+ * is resumed as well. Idempotent.
332
+ *
333
+ * @param projectId
334
+ * @param workflowId
335
+ * @returns void
336
+ * @throws ApiError
337
+ */
338
+ resumeBpmnInstance(projectId: string, workflowId: string): CancelablePromise<void>;
339
+ /**
340
+ * Suspend every running instance of a BPMN definition
341
+ * Pauses every running instance of one deployed process definition AND
342
+ * rejects new instance starts on that definition until it is resumed.
343
+ *
344
+ * The handler acquires a row-level lock on the definition before flipping
345
+ * the flag so a `StartBpmnInstance` racing the suspend can't slip through.
346
+ * It then iterates over every running instance (`status='RUNNING'`) and
347
+ * sends each one a definition-scope suspend signal via the engine API.
348
+ * Instances that were also explicitly instance-suspended stay paused
349
+ * after a definition-scope resume — the operator must clear that scope
350
+ * too.
351
+ *
352
+ * Idempotent. The reason cascades to every affected instance's history
353
+ * audit (`SuspendDefinitionEvent`) so the UI can render where the pause
354
+ * came from.
355
+ *
356
+ * @param projectId
357
+ * @param definitionId Platform identifier of the process definition version (same UUID `BpmnProcessVersion.id` exposes).
358
+ * @param requestBody
359
+ * @returns void
360
+ * @throws ApiError
361
+ */
362
+ suspendBpmnDefinition(projectId: string, definitionId: string, requestBody?: SuspendBpmnDefinitionRequest): CancelablePromise<void>;
363
+ /**
364
+ * Resume a suspended BPMN definition
365
+ * Clears the definition-scope suspension and fans out a resume signal to
366
+ * every running instance of the definition. Instances that were also
367
+ * instance-suspended stay paused until their own scope is cleared. New
368
+ * instance starts are accepted again once the definition flag clears.
369
+ * Idempotent.
370
+ *
371
+ * @param projectId
372
+ * @param definitionId
373
+ * @returns void
374
+ * @throws ApiError
375
+ */
376
+ resumeBpmnDefinition(projectId: string, definitionId: string): CancelablePromise<void>;
276
377
  /**
277
378
  * PENDING job counts grouped by taskType
278
379
  * Returns one entry per `taskType` with at least one PENDING job. Useful for
@@ -284,23 +385,24 @@ export declare class BpmnService {
284
385
  * @throws ApiError
285
386
  */
286
387
  getBpmnExternalJobsQueueDepth(projectId: string, createdAfter?: string): CancelablePromise<ExternalJobQueueDepthResponse>;
287
- /**
288
- * Live count of long-poll workers grouped by taskType
289
- * Returns the count of workers currently long-polling for each `taskType`.
290
- * Reflects only currently-connected workers; long-polls that have timed out
291
- * or disconnected are not counted.
292
- *
293
- * @param projectId
294
- * @returns ExternalJobActiveWorkersResponse OK
295
- * @throws ApiError
296
- */
297
- getBpmnExternalJobsActiveWorkers(projectId: string): CancelablePromise<ExternalJobActiveWorkersResponse>;
298
388
  /**
299
389
  * Fail an external job with a BPMN error code
300
- * Reports that the worker could not handle the job. The `errorCode` is
301
- * raised as a BPMN error, triggering any matching boundary error event
302
- * on the originating service task. If the job has remaining retries it
303
- * is requeued; otherwise the originating instance gets an incident.
390
+ * Reports that the worker could not handle the job.
391
+ *
392
+ * The `retryable` flag decides how the failure is treated:
393
+ *
394
+ * * `retryable: true` (the default) - a **technical/transient** failure.
395
+ * If the job has remaining retries it is requeued for another attempt
396
+ * and the retry budget is decremented; the process is NOT notified. Only
397
+ * once retries are exhausted is the `errorCode` raised as a BPMN error,
398
+ * triggering any matching boundary error event on the originating service
399
+ * task (or an incident if none matches).
400
+ * * `retryable: false` - a **business** BPMN error. The `errorCode` is
401
+ * raised on the process immediately, bypassing the retry budget entirely,
402
+ * so a matching boundary error event fires (or an incident is raised)
403
+ * without wasting retries. Use this for domain outcomes a retry could
404
+ * never fix (e.g. `PAYMENT_DECLINED`). SDK workers send this automatically
405
+ * when a handler throws a typed `BpmnError`.
304
406
  *
305
407
  * @param projectId
306
408
  * @param executionKey
@@ -310,6 +412,27 @@ export declare class BpmnService {
310
412
  */
311
413
  throwBpmnExternalJobError(projectId: string, executionKey: string, requestBody: {
312
414
  errorCode: string;
415
+ /**
416
+ * Optional worker identity (the same `clientID` used to poll).
417
+ * When supplied, the error is applied only if this worker still
418
+ * holds the job's lock, so a stale report can't requeue or fail
419
+ * a job a peer is actively holding. Omit for the legacy
420
+ * unchecked behavior.
421
+ *
422
+ */
423
+ clientID?: string;
424
+ /**
425
+ * Whether this failure should consume the retry budget before
426
+ * reaching the process. `true` (default) treats it as a
427
+ * technical failure: requeue while retries remain, raise the
428
+ * BPMN error only at exhaustion. `false` treats `errorCode` as a
429
+ * business BPMN error and raises it immediately, bypassing
430
+ * retries so a boundary error event fires (or an incident is
431
+ * raised) at once. SDK workers set `false` for a handler-thrown
432
+ * `BpmnError` and `true` for any other exception.
433
+ *
434
+ */
435
+ retryable?: boolean;
313
436
  variables?: Record<string, any>;
314
437
  }): CancelablePromise<any>;
315
438
  /**
@@ -324,6 +447,15 @@ export declare class BpmnService {
324
447
  * @throws ApiError
325
448
  */
326
449
  completeBpmnExternalJobsBatch(projectId: string, requestBody: {
450
+ /**
451
+ * Optional worker identity (the same `clientID` used to poll)
452
+ * applied to every item in the batch — a batch is one worker's
453
+ * report. When supplied, an item is completed only if this
454
+ * worker still holds its lock; items re-acquired by a peer drop
455
+ * out silently. Omit for the legacy unchecked behavior.
456
+ *
457
+ */
458
+ clientID?: string;
327
459
  items: Array<{
328
460
  executionKey: string;
329
461
  workflowID: string;
@@ -332,11 +464,14 @@ export declare class BpmnService {
332
464
  }): CancelablePromise<ExternalJobBatchResponse>;
333
465
  /**
334
466
  * Fail external jobs in batch
335
- * Reports a batch of worker failures in one request. Each item's
336
- * remaining retry budget determines whether it requeues for another
337
- * attempt or surfaces as an incident on the originating instance.
338
- * Per-item status is returned so a partial failure does not sink the
339
- * whole batch.
467
+ * Reports a batch of worker failures in one request. With `retryable: true`
468
+ * (the default) each item's remaining retry budget decides whether it
469
+ * requeues for another attempt or surfaces its `errorCode` as a BPMN
470
+ * error/incident on the originating instance. With `retryable: false` every
471
+ * item is treated as a business BPMN error and raised immediately, bypassing
472
+ * the retry budget (see the single-job error endpoint for the full
473
+ * semantics). Per-item status is returned so a partial failure does not sink
474
+ * the whole batch.
340
475
  *
341
476
  * @param projectId
342
477
  * @param requestBody
@@ -344,6 +479,25 @@ export declare class BpmnService {
344
479
  * @throws ApiError
345
480
  */
346
481
  throwBpmnExternalJobErrorsBatch(projectId: string, requestBody: {
482
+ /**
483
+ * Optional worker identity (the same `clientID` used to poll)
484
+ * applied to every item in the batch — a batch is one worker's
485
+ * report. When supplied, an item is requeued/failed only if this
486
+ * worker still holds its lock; items held by a peer are reported
487
+ * as an error and left untouched. Omit for the legacy unchecked
488
+ * behavior.
489
+ *
490
+ */
491
+ clientID?: string;
492
+ /**
493
+ * Applies to every item in the batch. `true` (default) consumes
494
+ * each item's retry budget before raising its BPMN error; `false`
495
+ * raises every item's `errorCode` as a business BPMN error
496
+ * immediately, bypassing retries. See the single-job error
497
+ * endpoint for the full semantics.
498
+ *
499
+ */
500
+ retryable?: boolean;
347
501
  items: Array<{
348
502
  executionKey: string;
349
503
  workflowID: string;
@@ -363,12 +517,13 @@ export declare class BpmnService {
363
517
  * @param assignee
364
518
  * @param candidateUser
365
519
  * @param candidateGroup
520
+ * @param businessId Exact-match filter on the caller-supplied correlation key.
366
521
  * @param page
367
522
  * @param pageSize
368
523
  * @returns BpmnUserTaskPaginatedResponse OK
369
524
  * @throws ApiError
370
525
  */
371
- listBpmnUserTasks(projectId: string, workflowId?: string, status?: 'CREATED' | 'COMPLETED' | 'CANCELED' | 'FAILED', assignee?: string, candidateUser?: string, candidateGroup?: string, page?: number, pageSize?: number): CancelablePromise<BpmnUserTaskPaginatedResponse>;
526
+ listBpmnUserTasks(projectId: string, workflowId?: string, status?: 'CREATED' | 'COMPLETED' | 'CANCELED' | 'FAILED', assignee?: string, candidateUser?: string, candidateGroup?: string, businessId?: string, page?: number, pageSize?: number): CancelablePromise<BpmnUserTaskPaginatedResponse>;
372
527
  /**
373
528
  * List User Tasks for the Caller
374
529
  * Returns CREATED user tasks the caller can act on: directly assigned,