@quantumbpm/sdk 0.12.0 → 1.1.0

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 (113) hide show
  1. package/README.md +11 -5
  2. package/dist/bpmn.d.ts +24 -6
  3. package/dist/bpmn.js +11 -9
  4. package/dist/dmn.d.ts +6 -1
  5. package/dist/dmn.js +4 -2
  6. package/dist/generated/RawClient.js +2 -2
  7. package/dist/generated/core/OpenAPI.js +2 -2
  8. package/dist/generated/index.d.ts +0 -2
  9. package/dist/generated/index.js +1 -1
  10. package/dist/generated/models/ActiveScope.d.ts +2 -2
  11. package/dist/generated/models/ActiveScope.js +1 -1
  12. package/dist/generated/models/BatchEvaluateDesignRequest.d.ts +3 -2
  13. package/dist/generated/models/BatchEvaluateDesignRequest.js +1 -1
  14. package/dist/generated/models/BpmnIncident.d.ts +43 -20
  15. package/dist/generated/models/BpmnIncident.js +21 -11
  16. package/dist/generated/models/BpmnIncidentRecord.d.ts +16 -3
  17. package/dist/generated/models/BpmnIncidentRecord.js +7 -2
  18. package/dist/generated/models/BpmnInstance.d.ts +15 -4
  19. package/dist/generated/models/BpmnInstance.js +1 -1
  20. package/dist/generated/models/BpmnInstanceState.d.ts +5 -1
  21. package/dist/generated/models/BpmnInstanceState.js +1 -1
  22. package/dist/generated/models/BpmnProcessDefinition.d.ts +8 -0
  23. package/dist/generated/models/BpmnProcessDefinition.js +1 -1
  24. package/dist/generated/models/BpmnProcessSummary.d.ts +8 -0
  25. package/dist/generated/models/BpmnProcessSummary.js +1 -1
  26. package/dist/generated/models/BpmnResource.d.ts +7 -0
  27. package/dist/generated/models/BpmnResource.js +1 -1
  28. package/dist/generated/models/BpmnResourceSummary.d.ts +7 -0
  29. package/dist/generated/models/BpmnResourceSummary.js +1 -1
  30. package/dist/generated/models/CorrelationKeys.d.ts +1 -1
  31. package/dist/generated/models/CorrelationKeys.js +1 -1
  32. package/dist/generated/models/Error.d.ts +10 -10
  33. package/dist/generated/models/Error.js +6 -6
  34. package/dist/generated/models/EvaluateStoredRequest.d.ts +4 -0
  35. package/dist/generated/models/EvaluateStoredRequest.js +1 -1
  36. package/dist/generated/models/EvaluationResult.d.ts +8 -8
  37. package/dist/generated/models/EvaluationResult.js +5 -5
  38. package/dist/generated/models/Execution.d.ts +4 -0
  39. package/dist/generated/models/Execution.js +1 -1
  40. package/dist/generated/models/ExternalJob.d.ts +8 -0
  41. package/dist/generated/models/ExternalJob.js +1 -1
  42. package/dist/generated/models/ExternalJobBatchResponse.d.ts +4 -4
  43. package/dist/generated/models/ExternalJobBatchResponse.js +1 -1
  44. package/dist/generated/models/FeelNumber.d.ts +1 -1
  45. package/dist/generated/models/FeelNumber.js +1 -1
  46. package/dist/generated/models/ModificationInstruction.d.ts +4 -4
  47. package/dist/generated/models/ModificationInstruction.js +3 -3
  48. package/dist/generated/models/StartBpmnInstanceRequest.d.ts +4 -0
  49. package/dist/generated/models/StartBpmnInstanceRequest.js +1 -1
  50. package/dist/generated/models/StartBpmnTestInstanceRequest.d.ts +4 -0
  51. package/dist/generated/models/StartBpmnTestInstanceRequest.js +1 -1
  52. package/dist/generated/models/SuspensionEntry.d.ts +1 -1
  53. package/dist/generated/models/SuspensionEntry.js +1 -1
  54. package/dist/generated/models/UpdateUserTaskAssignmentRequest.d.ts +1 -1
  55. package/dist/generated/models/UpdateUserTaskAssignmentRequest.js +1 -1
  56. package/dist/generated/models/UserTask.d.ts +5 -1
  57. package/dist/generated/models/UserTask.js +1 -1
  58. package/dist/generated/services/BpmnService.d.ts +92 -31
  59. package/dist/generated/services/BpmnService.js +51 -43
  60. package/dist/generated/services/DefaultService.d.ts +30 -23
  61. package/dist/generated/services/DefaultService.js +27 -27
  62. package/dist/index.d.ts +2 -2
  63. package/dist/index.js +2 -2
  64. package/dist/tracing.d.ts +17 -0
  65. package/dist/tracing.js +38 -0
  66. package/dist/variables.d.ts +1 -1
  67. package/dist/variables.js +2 -2
  68. package/dist/workers.d.ts +15 -5
  69. package/dist/workers.js +27 -7
  70. package/package.json +4 -3
  71. package/src/bpmn.ts +31 -8
  72. package/src/dmn.ts +8 -1
  73. package/src/generated/RawClient.ts +1 -1
  74. package/src/generated/core/OpenAPI.ts +1 -1
  75. package/src/generated/index.ts +0 -2
  76. package/src/generated/models/ActiveScope.ts +2 -2
  77. package/src/generated/models/BatchEvaluateDesignRequest.ts +3 -2
  78. package/src/generated/models/BpmnIncident.ts +43 -20
  79. package/src/generated/models/BpmnIncidentRecord.ts +16 -3
  80. package/src/generated/models/BpmnInstance.ts +15 -4
  81. package/src/generated/models/BpmnInstanceState.ts +5 -1
  82. package/src/generated/models/BpmnProcessDefinition.ts +8 -0
  83. package/src/generated/models/BpmnProcessSummary.ts +8 -0
  84. package/src/generated/models/BpmnResource.ts +7 -0
  85. package/src/generated/models/BpmnResourceSummary.ts +7 -0
  86. package/src/generated/models/CorrelationKeys.ts +1 -1
  87. package/src/generated/models/Error.ts +10 -10
  88. package/src/generated/models/EvaluateStoredRequest.ts +4 -0
  89. package/src/generated/models/EvaluationResult.ts +8 -8
  90. package/src/generated/models/Execution.ts +4 -0
  91. package/src/generated/models/ExternalJob.ts +8 -0
  92. package/src/generated/models/ExternalJobBatchResponse.ts +4 -4
  93. package/src/generated/models/FeelNumber.ts +1 -1
  94. package/src/generated/models/ModificationInstruction.ts +4 -4
  95. package/src/generated/models/StartBpmnInstanceRequest.ts +4 -0
  96. package/src/generated/models/StartBpmnTestInstanceRequest.ts +4 -0
  97. package/src/generated/models/SuspensionEntry.ts +1 -1
  98. package/src/generated/models/UpdateUserTaskAssignmentRequest.ts +1 -1
  99. package/src/generated/models/UserTask.ts +5 -1
  100. package/src/generated/services/BpmnService.ts +100 -43
  101. package/src/generated/services/DefaultService.ts +36 -24
  102. package/src/index.test.ts +113 -0
  103. package/src/index.ts +2 -2
  104. package/src/tracing.ts +49 -0
  105. package/src/variables.ts +1 -1
  106. package/src/workers.test.ts +67 -1
  107. package/src/workers.ts +41 -10
  108. package/dist/generated/models/ExternalJobActiveWorkersItem.d.ts +0 -7
  109. package/dist/generated/models/ExternalJobActiveWorkersItem.js +0 -3
  110. package/dist/generated/models/ExternalJobActiveWorkersResponse.d.ts +0 -7
  111. package/dist/generated/models/ExternalJobActiveWorkersResponse.js +0 -3
  112. package/src/generated/models/ExternalJobActiveWorkersItem.ts +0 -12
  113. package/src/generated/models/ExternalJobActiveWorkersResponse.ts +0 -12
@@ -13,7 +13,6 @@ import type { BpmnUserTaskPaginatedResponse } from '../models/BpmnUserTaskPagina
13
13
  import type { BpmnValidateResponse } from '../models/BpmnValidateResponse';
14
14
  import type { CorrelationKeys } from '../models/CorrelationKeys';
15
15
  import type { CreateBpmnResourceRequest } from '../models/CreateBpmnResourceRequest';
16
- import type { ExternalJobActiveWorkersResponse } from '../models/ExternalJobActiveWorkersResponse';
17
16
  import type { ExternalJobBatchResponse } from '../models/ExternalJobBatchResponse';
18
17
  import type { ExternalJobQueueDepthResponse } from '../models/ExternalJobQueueDepthResponse';
19
18
  import type { MigrateBpmnInstanceRequest } from '../models/MigrateBpmnInstanceRequest';
@@ -127,7 +126,7 @@ export class BpmnService {
127
126
  body: requestBody,
128
127
  mediaType: 'application/json',
129
128
  errors: {
130
- 409: `Conflict — resource is already deployed`,
129
+ 409: `Conflict - resource is already deployed`,
131
130
  },
132
131
  });
133
132
  }
@@ -154,7 +153,7 @@ export class BpmnService {
154
153
  'resourceID': resourceId,
155
154
  },
156
155
  errors: {
157
- 409: `Conflict — resource has running instances`,
156
+ 409: `Conflict - resource has running instances`,
158
157
  },
159
158
  });
160
159
  }
@@ -396,7 +395,7 @@ export class BpmnService {
396
395
  /**
397
396
  * Resolve an incident and retry the failed activity
398
397
  * Marks an incident as resolved and re-runs the activity that produced it.
399
- * Optional `variables` are merged into the activity's scope before retry —
398
+ * Optional `variables` are merged into the activity's scope before retry -
400
399
  * use this to fix the input that caused the failure (e.g. correct a value
401
400
  * that triggered a FEEL evaluation error).
402
401
  *
@@ -440,7 +439,7 @@ export class BpmnService {
440
439
  *
441
440
  * @param projectId
442
441
  * @param definitionId Restrict to incidents on instances of a single process definition.
443
- * @param workflowId Restrict to incidents on a single instance — useful for an instance-detail "all incidents ever raised here" view that includes resolved rows.
442
+ * @param workflowId Restrict to incidents on a single instance - useful for an instance-detail "all incidents ever raised here" view that includes resolved rows.
444
443
  * @param status Filter by lifecycle status. `open` returns unresolved incidents;
445
444
  * `resolved` returns only resolved ones. Omit to return both.
446
445
  *
@@ -457,7 +456,7 @@ export class BpmnService {
457
456
  definitionId?: string,
458
457
  workflowId?: string,
459
458
  status?: 'open' | 'resolved',
460
- errorType?: 'BpmnError' | 'EscalationError' | 'CompensationError' | 'FeelError' | 'NoHandler' | 'GatewayNoMatch' | 'TimerResolution' | 'LinkNotFound' | 'MigrationError' | 'Unknown',
459
+ errorType?: 'BpmnError' | 'EscalationError' | 'CompensationError' | 'FeelError' | 'NoHandler' | 'GatewayNoMatch' | 'TimerResolution' | 'LinkNotFound' | 'MigrationError' | 'SubscriptionError' | 'RotationLimitError' | 'SnapshotSizeExceeded' | 'CallActivityCanceled' | 'ExternalRowRefreshError' | 'Unknown',
461
460
  since?: string,
462
461
  until?: string,
463
462
  page?: number,
@@ -638,7 +637,7 @@ export class BpmnService {
638
637
  * Suspend a BPMN instance
639
638
  * Pauses forward token dispatch on a single running instance. The
640
639
  * instance's lifecycle status stays RUNNING; an orthogonal `suspendedAt`
641
- * flag layers on top. Idempotent — a second call against an already-
640
+ * flag layers on top. Idempotent - a second call against an already-
642
641
  * suspended instance is a no-op.
643
642
  *
644
643
  * While suspended: cancel / terminate / migrate / force-rotate / resolve-
@@ -706,7 +705,7 @@ export class BpmnService {
706
705
  * It then iterates over every running instance (`status='RUNNING'`) and
707
706
  * sends each one a definition-scope suspend signal via the engine API.
708
707
  * Instances that were also explicitly instance-suspended stay paused
709
- * after a definition-scope resume — the operator must clear that scope
708
+ * after a definition-scope resume - the operator must clear that scope
710
709
  * too.
711
710
  *
712
711
  * Idempotent. The reason cascades to every affected instance's history
@@ -792,33 +791,24 @@ export class BpmnService {
792
791
  },
793
792
  });
794
793
  }
795
- /**
796
- * Live count of long-poll workers grouped by taskType
797
- * Returns the count of workers currently long-polling for each `taskType`.
798
- * Reflects only currently-connected workers; long-polls that have timed out
799
- * or disconnected are not counted.
800
- *
801
- * @param projectId
802
- * @returns ExternalJobActiveWorkersResponse OK
803
- * @throws ApiError
804
- */
805
- public getBpmnExternalJobsActiveWorkers(
806
- projectId: string,
807
- ): CancelablePromise<ExternalJobActiveWorkersResponse> {
808
- return this.httpRequest.request({
809
- method: 'GET',
810
- url: '/projects/{projectID}/bpmn/external-jobs/workers',
811
- path: {
812
- 'projectID': projectId,
813
- },
814
- });
815
- }
816
794
  /**
817
795
  * Fail an external job with a BPMN error code
818
- * Reports that the worker could not handle the job. The `errorCode` is
819
- * raised as a BPMN error, triggering any matching boundary error event
820
- * on the originating service task. If the job has remaining retries it
821
- * is requeued; otherwise the originating instance gets an incident.
796
+ * Reports that the worker could not handle the job.
797
+ *
798
+ * The `retryable` flag decides how the failure is treated:
799
+ *
800
+ * * `retryable: true` (the default) - a **technical/transient** failure.
801
+ * If the job has remaining retries it is requeued for another attempt
802
+ * and the retry budget is decremented; the process is NOT notified. Only
803
+ * once retries are exhausted is the `errorCode` raised as a BPMN error,
804
+ * triggering any matching boundary error event on the originating service
805
+ * task (or an incident if none matches).
806
+ * * `retryable: false` - a **business** BPMN error. The `errorCode` is
807
+ * raised on the process immediately, bypassing the retry budget entirely,
808
+ * so a matching boundary error event fires (or an incident is raised)
809
+ * without wasting retries. Use this for domain outcomes a retry could
810
+ * never fix (e.g. `PAYMENT_DECLINED`). SDK workers send this automatically
811
+ * when a handler throws a typed `BpmnError`.
822
812
  *
823
813
  * @param projectId
824
814
  * @param executionKey
@@ -831,6 +821,27 @@ export class BpmnService {
831
821
  executionKey: string,
832
822
  requestBody: {
833
823
  errorCode: string;
824
+ /**
825
+ * Optional worker identity (the same `clientID` used to poll).
826
+ * When supplied, the error is applied only if this worker still
827
+ * holds the job's lock, so a stale report can't requeue or fail
828
+ * a job a peer is actively holding. Omit for the legacy
829
+ * unchecked behavior.
830
+ *
831
+ */
832
+ clientID?: string;
833
+ /**
834
+ * Whether this failure should consume the retry budget before
835
+ * reaching the process. `true` (default) treats it as a
836
+ * technical failure: requeue while retries remain, raise the
837
+ * BPMN error only at exhaustion. `false` treats `errorCode` as a
838
+ * business BPMN error and raises it immediately, bypassing
839
+ * retries so a boundary error event fires (or an incident is
840
+ * raised) at once. SDK workers set `false` for a handler-thrown
841
+ * `BpmnError` and `true` for any other exception.
842
+ *
843
+ */
844
+ retryable?: boolean;
834
845
  variables?: Record<string, any>;
835
846
  },
836
847
  ): CancelablePromise<any> {
@@ -859,6 +870,15 @@ export class BpmnService {
859
870
  public completeBpmnExternalJobsBatch(
860
871
  projectId: string,
861
872
  requestBody: {
873
+ /**
874
+ * Optional worker identity (the same `clientID` used to poll)
875
+ * applied to every item in the batch - a batch is one worker's
876
+ * report. When supplied, an item is completed only if this
877
+ * worker still holds its lock; items re-acquired by a peer drop
878
+ * out silently. Omit for the legacy unchecked behavior.
879
+ *
880
+ */
881
+ clientID?: string;
862
882
  items: Array<{
863
883
  executionKey: string;
864
884
  workflowID: string;
@@ -878,11 +898,14 @@ export class BpmnService {
878
898
  }
879
899
  /**
880
900
  * Fail external jobs in batch
881
- * Reports a batch of worker failures in one request. Each item's
882
- * remaining retry budget determines whether it requeues for another
883
- * attempt or surfaces as an incident on the originating instance.
884
- * Per-item status is returned so a partial failure does not sink the
885
- * whole batch.
901
+ * Reports a batch of worker failures in one request. With `retryable: true`
902
+ * (the default) each item's remaining retry budget decides whether it
903
+ * requeues for another attempt or surfaces its `errorCode` as a BPMN
904
+ * error/incident on the originating instance. With `retryable: false` every
905
+ * item is treated as a business BPMN error and raised immediately, bypassing
906
+ * the retry budget (see the single-job error endpoint for the full
907
+ * semantics). Per-item status is returned so a partial failure does not sink
908
+ * the whole batch.
886
909
  *
887
910
  * @param projectId
888
911
  * @param requestBody
@@ -892,6 +915,25 @@ export class BpmnService {
892
915
  public throwBpmnExternalJobErrorsBatch(
893
916
  projectId: string,
894
917
  requestBody: {
918
+ /**
919
+ * Optional worker identity (the same `clientID` used to poll)
920
+ * applied to every item in the batch - a batch is one worker's
921
+ * report. When supplied, an item is requeued/failed only if this
922
+ * worker still holds its lock; items held by a peer are reported
923
+ * as an error and left untouched. Omit for the legacy unchecked
924
+ * behavior.
925
+ *
926
+ */
927
+ clientID?: string;
928
+ /**
929
+ * Applies to every item in the batch. `true` (default) consumes
930
+ * each item's retry budget before raising its BPMN error; `false`
931
+ * raises every item's `errorCode` as a business BPMN error
932
+ * immediately, bypassing retries. See the single-job error
933
+ * endpoint for the full semantics.
934
+ *
935
+ */
936
+ retryable?: boolean;
895
937
  items: Array<{
896
938
  executionKey: string;
897
939
  workflowID: string;
@@ -922,6 +964,7 @@ export class BpmnService {
922
964
  * @param assignee
923
965
  * @param candidateUser
924
966
  * @param candidateGroup
967
+ * @param businessId Exact-match filter on the caller-supplied correlation key.
925
968
  * @param page
926
969
  * @param pageSize
927
970
  * @returns BpmnUserTaskPaginatedResponse OK
@@ -934,6 +977,7 @@ export class BpmnService {
934
977
  assignee?: string,
935
978
  candidateUser?: string,
936
979
  candidateGroup?: string,
980
+ businessId?: string,
937
981
  page?: number,
938
982
  pageSize?: number,
939
983
  ): CancelablePromise<BpmnUserTaskPaginatedResponse> {
@@ -949,6 +993,7 @@ export class BpmnService {
949
993
  'assignee': assignee,
950
994
  'candidateUser': candidateUser,
951
995
  'candidateGroup': candidateGroup,
996
+ 'businessId': businessId,
952
997
  'page': page,
953
998
  'pageSize': pageSize,
954
999
  },
@@ -988,7 +1033,7 @@ export class BpmnService {
988
1033
  * Fetch a single user task by execution key. Allowed for callers with
989
1034
  * Executor (or higher) role on the project, OR for callers who are the
990
1035
  * task's assignee, listed in candidateUsers, or whose identity groups
991
- * overlap candidateGroups — same access semantics as Complete and Error.
1036
+ * overlap candidateGroups - same access semantics as Complete and Error.
992
1037
  *
993
1038
  * @param projectId
994
1039
  * @param executionKey
@@ -1007,7 +1052,7 @@ export class BpmnService {
1007
1052
  'executionKey': executionKey,
1008
1053
  },
1009
1054
  errors: {
1010
- 403: `Forbidden — caller is not Executor and not assigned to the task`,
1055
+ 403: `Forbidden - caller is not Executor and not assigned to the task`,
1011
1056
  404: `Not Found`,
1012
1057
  },
1013
1058
  });
@@ -1073,7 +1118,7 @@ export class BpmnService {
1073
1118
  body: requestBody,
1074
1119
  mediaType: 'application/json',
1075
1120
  errors: {
1076
- 403: `Forbidden — caller is not Executor and not assigned to the task`,
1121
+ 403: `Forbidden - caller is not Executor and not assigned to the task`,
1077
1122
  404: `User task not found`,
1078
1123
  },
1079
1124
  });
@@ -1108,7 +1153,7 @@ export class BpmnService {
1108
1153
  body: requestBody,
1109
1154
  mediaType: 'application/json',
1110
1155
  errors: {
1111
- 403: `Forbidden — caller is not Executor and not assigned to the task`,
1156
+ 403: `Forbidden - caller is not Executor and not assigned to the task`,
1112
1157
  404: `User task not found`,
1113
1158
  },
1114
1159
  });
@@ -1215,11 +1260,16 @@ export class BpmnService {
1215
1260
  * @param pageSize
1216
1261
  * @param q Optional case-insensitive substring match against process id or process name.
1217
1262
  * @param createdAfter Bounds the totalCount aggregate to instances created at or after this
1218
- * timestamp. Strongly recommended for monitoring views — instance
1263
+ * timestamp. Strongly recommended for monitoring views - instance
1219
1264
  * history accumulates indefinitely and unfiltered totals scan the full
1220
1265
  * table per definition. runningCount ignores this filter (it is always
1221
1266
  * point-in-time).
1222
1267
  *
1268
+ * @param suspended Filter by paused versions. `true` → only processes with at least one
1269
+ * paused version; `false` → only processes with none. Omit for no
1270
+ * filter. This is the cross-process answer to "which definitions are
1271
+ * paused?"; `suspendedVersionCount` on each row says how many.
1272
+ *
1223
1273
  * @returns BpmnProcessSummaryPaginatedResponse OK
1224
1274
  * @throws ApiError
1225
1275
  */
@@ -1229,6 +1279,7 @@ export class BpmnService {
1229
1279
  pageSize: number = 20,
1230
1280
  q?: string,
1231
1281
  createdAfter?: string,
1282
+ suspended?: boolean,
1232
1283
  ): CancelablePromise<BpmnProcessSummaryPaginatedResponse> {
1233
1284
  return this.httpRequest.request({
1234
1285
  method: 'GET',
@@ -1241,6 +1292,7 @@ export class BpmnService {
1241
1292
  'pageSize': pageSize,
1242
1293
  'q': q,
1243
1294
  'createdAfter': createdAfter,
1295
+ 'suspended': suspended,
1244
1296
  },
1245
1297
  errors: {
1246
1298
  401: `Unauthorized`,
@@ -1262,6 +1314,9 @@ export class BpmnService {
1262
1314
  * timestamp. See ListBpmnProcesses for rationale. runningCount ignores
1263
1315
  * this filter.
1264
1316
  *
1317
+ * @param suspended Filter by definition-scope suspension. `true` → only paused versions;
1318
+ * `false` → only active ones. Omit for no filter.
1319
+ *
1265
1320
  * @returns BpmnProcessVersionPaginatedResponse OK
1266
1321
  * @throws ApiError
1267
1322
  */
@@ -1271,6 +1326,7 @@ export class BpmnService {
1271
1326
  page: number = 1,
1272
1327
  pageSize: number = 20,
1273
1328
  createdAfter?: string,
1329
+ suspended?: boolean,
1274
1330
  ): CancelablePromise<BpmnProcessVersionPaginatedResponse> {
1275
1331
  return this.httpRequest.request({
1276
1332
  method: 'GET',
@@ -1283,6 +1339,7 @@ export class BpmnService {
1283
1339
  'page': page,
1284
1340
  'pageSize': pageSize,
1285
1341
  'createdAfter': createdAfter,
1342
+ 'suspended': suspended,
1286
1343
  },
1287
1344
  errors: {
1288
1345
  401: `Unauthorized`,
@@ -26,19 +26,6 @@ import type { CancelablePromise } from '../core/CancelablePromise';
26
26
  import type { BaseHttpRequest } from '../core/BaseHttpRequest';
27
27
  export class DefaultService {
28
28
  constructor(public readonly httpRequest: BaseHttpRequest) {}
29
- /**
30
- * Health Check
31
- * @returns any OK
32
- * @throws ApiError
33
- */
34
- public getHealth(): CancelablePromise<{
35
- status?: string;
36
- }> {
37
- return this.httpRequest.request({
38
- method: 'GET',
39
- url: '/health',
40
- });
41
- }
42
29
  /**
43
30
  * Version
44
31
  * @returns any OK
@@ -531,6 +518,7 @@ export class DefaultService {
531
518
  * @param definitionId
532
519
  * @param definitionsId Filter by DMN `<definitions id>` (XML id).
533
520
  * @param startDate Filter executions after this date (ISO 8601)
521
+ * @param businessId Exact-match filter on the caller-supplied correlation key.
534
522
  * @param page Page number (1-indexed)
535
523
  * @param pageSize Number of items per page (max 100)
536
524
  * @returns PaginatedExecutionsResponse OK
@@ -541,6 +529,7 @@ export class DefaultService {
541
529
  definitionId: string,
542
530
  definitionsId?: string,
543
531
  startDate?: string,
532
+ businessId?: string,
544
533
  page: number = 1,
545
534
  pageSize: number = 20,
546
535
  ): CancelablePromise<PaginatedExecutionsResponse> {
@@ -554,6 +543,7 @@ export class DefaultService {
554
543
  query: {
555
544
  'definitionsID': definitionsId,
556
545
  'startDate': startDate,
546
+ 'businessId': businessId,
557
547
  'page': page,
558
548
  'pageSize': pageSize,
559
549
  },
@@ -604,6 +594,8 @@ export class DefaultService {
604
594
  * Returns paginated execution history for the entire project, optionally filtered by DMN definition.
605
595
  * @param projectId
606
596
  * @param definitionsId Filter by DMN `<definitions id>` (XML id).
597
+ * @param businessId Exact-match filter on the caller-supplied correlation key.
598
+ * @param startDate Only return executions at or after this instant (ISO 8601). Bounds the scan and the reported total; omit for the full unbounded history.
607
599
  * @param page Page number (1-indexed)
608
600
  * @param pageSize Number of items per page (max 100)
609
601
  * @returns PaginatedExecutionsResponse OK
@@ -612,6 +604,8 @@ export class DefaultService {
612
604
  public listProjectExecutions(
613
605
  projectId: string,
614
606
  definitionsId?: string,
607
+ businessId?: string,
608
+ startDate?: string,
615
609
  page: number = 1,
616
610
  pageSize: number = 20,
617
611
  ): CancelablePromise<PaginatedExecutionsResponse> {
@@ -623,6 +617,8 @@ export class DefaultService {
623
617
  },
624
618
  query: {
625
619
  'definitionsID': definitionsId,
620
+ 'businessId': businessId,
621
+ 'startDate': startDate,
626
622
  'page': page,
627
623
  'pageSize': pageSize,
628
624
  },
@@ -670,17 +666,19 @@ export class DefaultService {
670
666
  * `true` to show only instances that need operator attention; pass
671
667
  * `false` to exclude blocked instances.
672
668
  *
673
- * @param suspended Filter by instance-scope suspension. `true` → only instances with
674
- * `suspendedAt` set; `false` → only running-and-not-paused. Omit for
675
- * no filter. Does not consider definition-scope suspension; for a
676
- * full "is this instance making progress?" view, callers should
677
- * additionally join against the parent definition.
669
+ * @param suspended Filter by effective suspension - either scope counts. `true` → only
670
+ * instances paused at instance scope (`suspendedAt` set) or whose
671
+ * definition is paused (`definitionSuspended`); `false` → only
672
+ * instances paused at neither scope. Omit for no filter. Read those
673
+ * two row fields to tell the scopes apart; resume acts on one scope
674
+ * at a time.
678
675
  *
679
676
  * @param createdAfter Only return instances created at or after this timestamp. Strongly
680
- * recommended for monitoring views — terminal-state instance rows
677
+ * recommended for monitoring views - terminal-state instance rows
681
678
  * accumulate indefinitely, and unfiltered queries grow linearly with
682
679
  * that history.
683
680
  *
681
+ * @param businessId Exact-match filter on the caller-supplied correlation key set at start time.
684
682
  * @param page
685
683
  * @param pageSize
686
684
  * @returns BpmnInstancePaginatedResponse OK
@@ -693,6 +691,7 @@ export class DefaultService {
693
691
  hasIncident?: boolean,
694
692
  suspended?: boolean,
695
693
  createdAfter?: string,
694
+ businessId?: string,
696
695
  page?: number,
697
696
  pageSize?: number,
698
697
  ): CancelablePromise<BpmnInstancePaginatedResponse> {
@@ -708,6 +707,7 @@ export class DefaultService {
708
707
  'hasIncident': hasIncident,
709
708
  'suspended': suspended,
710
709
  'createdAfter': createdAfter,
710
+ 'businessId': businessId,
711
711
  'page': page,
712
712
  'pageSize': pageSize,
713
713
  },
@@ -716,7 +716,7 @@ export class DefaultService {
716
716
  /**
717
717
  * Start a BPMN process instance
718
718
  * Starts a new instance of a deployed BPMN process. The returned
719
- * `workflowID` is the stable execution identifier — use it to fetch
719
+ * `workflowID` is the stable execution identifier - use it to fetch
720
720
  * state, send signals/messages, complete user tasks, etc.
721
721
  *
722
722
  * @param projectId
@@ -750,7 +750,7 @@ export class DefaultService {
750
750
  }
751
751
  /**
752
752
  * Get BPMN instance state
753
- * Returns the full runtime state of a process instance — current variables,
753
+ * Returns the full runtime state of a process instance - current variables,
754
754
  * activity history, active scopes, and any unresolved incidents. Use this
755
755
  * to render dashboards or to drive operational decisions on a single
756
756
  * instance.
@@ -776,7 +776,7 @@ export class DefaultService {
776
776
  /**
777
777
  * Cancel a BPMN instance
778
778
  * Cancels a running instance and all of its active activities, jobs, and
779
- * child instances. Cancellation is best-effort — handlers in flight may
779
+ * child instances. Cancellation is best-effort - handlers in flight may
780
780
  * still complete before the cancel propagates. Cancelled instances move
781
781
  * to status `CANCELED` and stop consuming further work.
782
782
  *
@@ -809,8 +809,9 @@ export class DefaultService {
809
809
  * @param taskType Filter jobs by task type
810
810
  * @param status Filter jobs by status
811
811
  * @param workflowId Filter jobs by workflow ID
812
+ * @param businessId Exact-match filter on the caller-supplied correlation key.
812
813
  * @param createdAfter Only return jobs created at or after this timestamp. Strongly
813
- * recommended for monitoring views — completed-job records accumulate
814
+ * recommended for monitoring views - completed-job records accumulate
814
815
  * indefinitely, and unfiltered queries grow linearly with that history.
815
816
  *
816
817
  * @param page
@@ -823,6 +824,7 @@ export class DefaultService {
823
824
  taskType?: string,
824
825
  status?: 'PENDING' | 'COMPLETED' | 'FAILED' | 'CANCELED',
825
826
  workflowId?: string,
827
+ businessId?: string,
826
828
  createdAfter?: string,
827
829
  page?: number,
828
830
  pageSize?: number,
@@ -837,6 +839,7 @@ export class DefaultService {
837
839
  'taskType': taskType,
838
840
  'status': status,
839
841
  'workflowID': workflowId,
842
+ 'businessId': businessId,
840
843
  'createdAfter': createdAfter,
841
844
  'page': page,
842
845
  'pageSize': pageSize,
@@ -848,7 +851,7 @@ export class DefaultService {
848
851
  * Long-polls for PENDING jobs of a given `taskType`. Returns a batch of
849
852
  * jobs (up to `maxJobs`) as soon as any are available, or `204 No Content`
850
853
  * when the timeout elapses with no work. Each returned job is exclusively
851
- * leased to the caller for `lockDuration` — call `Heartbeat` to extend
854
+ * leased to the caller for `lockDuration` - call `Heartbeat` to extend
852
855
  * the lock, then `Complete` or `ThrowError` to finalize.
853
856
  *
854
857
  * @param projectId
@@ -929,6 +932,15 @@ export class DefaultService {
929
932
  * Workflow ID returned by the poll response.
930
933
  */
931
934
  workflowID: string;
935
+ /**
936
+ * Optional worker identity (the same `clientID` used to poll).
937
+ * When supplied, the completion is applied only if this worker
938
+ * still holds the job's lock; a stale worker whose lease lapsed
939
+ * and whose job a peer re-acquired is rejected as a no-op.
940
+ * Omit for the legacy unchecked behavior.
941
+ *
942
+ */
943
+ clientID?: string;
932
944
  variables?: Record<string, any>;
933
945
  },
934
946
  ): CancelablePromise<any> {
package/src/index.test.ts CHANGED
@@ -50,6 +50,7 @@ describe('BpmnClient.listInstances argument ordering', () => {
50
50
  hasIncident: true,
51
51
  suspended: false,
52
52
  createdAfter: '2026-01-01T00:00:00Z',
53
+ businessId: 'ORDER-42',
53
54
  page: 2,
54
55
  pageSize: 10,
55
56
  });
@@ -62,6 +63,7 @@ describe('BpmnClient.listInstances argument ordering', () => {
62
63
  true,
63
64
  false,
64
65
  '2026-01-01T00:00:00Z',
66
+ 'ORDER-42',
65
67
  2,
66
68
  10,
67
69
  ]);
@@ -90,8 +92,119 @@ describe('BpmnClient.listInstances argument ordering', () => {
90
92
  undefined,
91
93
  undefined,
92
94
  undefined,
95
+ undefined,
93
96
  3,
94
97
  undefined,
95
98
  ]);
96
99
  });
97
100
  });
101
+
102
+ describe('BpmnClient businessId threading', () => {
103
+ const projectId = '00000000-0000-0000-0000-000000000001';
104
+
105
+ test('startInstance forwards businessId in the request body', async () => {
106
+ const bodies: Array<Record<string, unknown>> = [];
107
+ const fakeRaw = {
108
+ default: {
109
+ startBpmnInstance: (_projectId: string, body: Record<string, unknown>) => {
110
+ bodies.push(body);
111
+ return Promise.resolve({ workflowID: 'wf-1' });
112
+ },
113
+ },
114
+ } as never;
115
+ const { BpmnClient } = await import('./bpmn');
116
+ const client = new BpmnClient(fakeRaw, projectId);
117
+
118
+ await client.startInstance('def-1', new Vars().set('amount', 100), { businessId: 'ORDER-42' });
119
+
120
+ expect(bodies[0]?.businessId).toBe('ORDER-42');
121
+ });
122
+
123
+ test('startInstance omits businessId when no option is passed', async () => {
124
+ const bodies: Array<Record<string, unknown>> = [];
125
+ const fakeRaw = {
126
+ default: {
127
+ startBpmnInstance: (_projectId: string, body: Record<string, unknown>) => {
128
+ bodies.push(body);
129
+ return Promise.resolve({ workflowID: 'wf-1' });
130
+ },
131
+ },
132
+ } as never;
133
+ const { BpmnClient } = await import('./bpmn');
134
+ const client = new BpmnClient(fakeRaw, projectId);
135
+
136
+ await client.startInstance('def-1', new Vars());
137
+
138
+ expect(bodies[0]?.businessId).toBeUndefined();
139
+ });
140
+
141
+ test('listUserTasks forwards businessId in positional argument 7', async () => {
142
+ const calls: unknown[][] = [];
143
+ const fakeRaw = {
144
+ bpmn: {
145
+ listBpmnUserTasks: (...args: unknown[]) => {
146
+ calls.push(args);
147
+ return Promise.resolve({ data: [], pagination: {} });
148
+ },
149
+ },
150
+ } as never;
151
+ const { BpmnClient } = await import('./bpmn');
152
+ const client = new BpmnClient(fakeRaw, projectId);
153
+
154
+ await client.listUserTasks({ businessId: 'ORDER-42' });
155
+
156
+ expect(calls[0]).toEqual([
157
+ projectId,
158
+ undefined,
159
+ undefined,
160
+ undefined,
161
+ undefined,
162
+ undefined,
163
+ 'ORDER-42',
164
+ undefined,
165
+ undefined,
166
+ ]);
167
+ });
168
+ });
169
+
170
+ describe('DmnClient businessId threading', () => {
171
+ const projectId = '00000000-0000-0000-0000-000000000001';
172
+
173
+ test('evaluate forwards businessId in the request body', async () => {
174
+ const bodies: Array<Record<string, unknown>> = [];
175
+ const fakeRaw = {
176
+ default: {
177
+ evaluateByDefinitionsId: (_pid: string, _did: string, body: Record<string, unknown>) => {
178
+ bodies.push(body);
179
+ return Promise.resolve({});
180
+ },
181
+ },
182
+ } as never;
183
+ const { DmnClient } = await import('./dmn');
184
+ const client = new DmnClient(fakeRaw, projectId);
185
+
186
+ await client.evaluate('def-1', new Vars(), { businessId: 'ORDER-42' });
187
+
188
+ expect(bodies[0]?.businessId).toBe('ORDER-42');
189
+ });
190
+
191
+ test('evaluateById forwards businessId in the request body', async () => {
192
+ const bodies: Array<Record<string, unknown>> = [];
193
+ const fakeRaw = {
194
+ default: {
195
+ evaluateStored: (_pid: string, _did: string, body: Record<string, unknown>) => {
196
+ bodies.push(body);
197
+ return Promise.resolve({});
198
+ },
199
+ },
200
+ } as never;
201
+ const { DmnClient } = await import('./dmn');
202
+ const client = new DmnClient(fakeRaw, projectId);
203
+
204
+ await client.evaluateById('11111111-1111-1111-1111-111111111111', new Vars(), {
205
+ businessId: 'ORDER-42',
206
+ });
207
+
208
+ expect(bodies[0]?.businessId).toBe('ORDER-42');
209
+ });
210
+ });
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QuantumBPM SDK — top-level entry point.
2
+ * QuantumBPM SDK - top-level entry point.
3
3
  *
4
4
  * @example
5
5
  * ```typescript
@@ -52,7 +52,7 @@ export class QuantumBPM {
52
52
  readonly raw: RawClient;
53
53
  /** DMN evaluation surface. */
54
54
  readonly dmn: DmnClient;
55
- /** BPMN runtime surface — resources, instances, messaging, user tasks. */
55
+ /** BPMN runtime surface - resources, instances, messaging, user tasks. */
56
56
  readonly bpmn: BpmnClient;
57
57
  /** Project the client is bound to. */
58
58
  readonly projectId: string;