@quantumbpm/sdk 1.2.0 → 1.3.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 (62) hide show
  1. package/README.md +38 -2
  2. package/dist/bpmn.d.ts +4 -2
  3. package/dist/bpmn.js +4 -4
  4. package/dist/generated/RawClient.js +2 -2
  5. package/dist/generated/core/OpenAPI.js +2 -2
  6. package/dist/generated/index.d.ts +1 -0
  7. package/dist/generated/index.js +1 -1
  8. package/dist/generated/models/BpmnIncident.d.ts +6 -0
  9. package/dist/generated/models/BpmnIncident.js +5 -1
  10. package/dist/generated/models/BpmnIncidentRecord.d.ts +4 -6
  11. package/dist/generated/models/BpmnIncidentRecord.js +3 -1
  12. package/dist/generated/models/BpmnInstance.d.ts +7 -0
  13. package/dist/generated/models/BpmnInstance.js +1 -1
  14. package/dist/generated/models/BpmnInstanceState.d.ts +18 -2
  15. package/dist/generated/models/BpmnInstanceState.js +1 -1
  16. package/dist/generated/models/CorrelationKeyNumber.d.ts +1 -1
  17. package/dist/generated/models/CorrelationKeyNumber.js +1 -1
  18. package/dist/generated/models/Error.d.ts +6 -0
  19. package/dist/generated/models/Error.js +5 -1
  20. package/dist/generated/models/EvaluateStoredRequest.d.ts +4 -1
  21. package/dist/generated/models/EvaluateStoredRequest.js +1 -1
  22. package/dist/generated/models/ExternalJob.d.ts +1 -1
  23. package/dist/generated/models/ExternalJob.js +1 -1
  24. package/dist/generated/models/ExternalJobBatchResponse.d.ts +2 -2
  25. package/dist/generated/models/ExternalJobBatchResponse.js +1 -1
  26. package/dist/generated/models/JoinArrivals.d.ts +8 -0
  27. package/dist/generated/models/JoinArrivals.js +3 -0
  28. package/dist/generated/models/PollBpmnJobRequest.d.ts +1 -1
  29. package/dist/generated/models/PollBpmnJobRequest.js +1 -1
  30. package/dist/generated/models/SuspensionEntry.d.ts +2 -2
  31. package/dist/generated/models/SuspensionEntry.js +1 -1
  32. package/dist/generated/models/UpdateUserTaskAssignmentRequest.d.ts +11 -4
  33. package/dist/generated/models/UpdateUserTaskAssignmentRequest.js +1 -1
  34. package/dist/generated/services/BpmnService.d.ts +18 -17
  35. package/dist/generated/services/BpmnService.js +41 -6
  36. package/dist/generated/services/DefaultService.d.ts +21 -14
  37. package/dist/generated/services/DefaultService.js +45 -12
  38. package/dist/workers.d.ts +39 -5
  39. package/dist/workers.js +184 -52
  40. package/package.json +1 -1
  41. package/src/bpmn.ts +7 -4
  42. package/src/generated/RawClient.ts +1 -1
  43. package/src/generated/core/OpenAPI.ts +1 -1
  44. package/src/generated/index.ts +1 -0
  45. package/src/generated/models/BpmnIncident.ts +6 -0
  46. package/src/generated/models/BpmnIncidentRecord.ts +4 -6
  47. package/src/generated/models/BpmnInstance.ts +7 -0
  48. package/src/generated/models/BpmnInstanceState.ts +18 -2
  49. package/src/generated/models/CorrelationKeyNumber.ts +1 -1
  50. package/src/generated/models/Error.ts +6 -0
  51. package/src/generated/models/EvaluateStoredRequest.ts +4 -1
  52. package/src/generated/models/ExternalJob.ts +1 -1
  53. package/src/generated/models/ExternalJobBatchResponse.ts +2 -2
  54. package/src/generated/models/JoinArrivals.ts +13 -0
  55. package/src/generated/models/PollBpmnJobRequest.ts +1 -1
  56. package/src/generated/models/SuspensionEntry.ts +2 -2
  57. package/src/generated/models/UpdateUserTaskAssignmentRequest.ts +11 -4
  58. package/src/generated/services/BpmnService.ts +51 -17
  59. package/src/generated/services/DefaultService.ts +49 -15
  60. package/src/index.test.ts +3 -0
  61. package/src/workers.test.ts +279 -1
  62. package/src/workers.ts +196 -57
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * A persisted incident - the cross-instance audit row that backs the
7
7
  * "Incidents" view. The same incident is also available in
8
- * `BpmnInstanceState.incidents` while it is still open in the engine; the
8
+ * `BpmnInstanceState.incidents` while it is open and the instance runs. The
9
9
  * persisted row additionally carries `raisedAt` / `resolvedAt` /
10
10
  * `resolvedBy` and the parent process metadata so it can be listed and
11
11
  * filtered without joining back to the instance.
@@ -13,11 +13,7 @@
13
13
  */
14
14
  export type BpmnIncidentRecord = {
15
15
  /**
16
- * Surrogate row identifier; stable across resolves.
17
- */
18
- id: string;
19
- /**
20
- * Engine-assigned incident identifier, unique within the workflow.
16
+ * Engine-assigned incident identifier, unique within the workflow. Resolve the incident with it.
21
17
  */
22
18
  incidentID: string;
23
19
  /**
@@ -104,6 +100,8 @@ export namespace BpmnIncidentRecord {
104
100
  SNAPSHOT_SIZE_EXCEEDED = 'SnapshotSizeExceeded',
105
101
  CALL_ACTIVITY_CANCELED = 'CallActivityCanceled',
106
102
  EXTERNAL_ROW_REFRESH_ERROR = 'ExternalRowRefreshError',
103
+ JOB_LOCK_LOST = 'JobLockLost',
104
+ DECISION_NOT_FOUND = 'DecisionNotFound',
107
105
  UNKNOWN = 'Unknown',
108
106
  }
109
107
  }
@@ -61,6 +61,13 @@ export type BpmnInstance = {
61
61
  *
62
62
  */
63
63
  definitionSuspended?: boolean;
64
+ /**
65
+ * True when an instance above this running call-activity child in the
66
+ * call chain is paused, which pauses this one too. It clears when that
67
+ * instance is resumed.
68
+ *
69
+ */
70
+ parentSuspended?: boolean;
64
71
  /**
65
72
  * Caller-supplied correlation key set when the instance was started. Inherited unchanged on child instances spawned via CallActivity.
66
73
  */
@@ -4,6 +4,7 @@
4
4
  /* eslint-disable */
5
5
  import type { ActiveScope } from './ActiveScope';
6
6
  import type { BpmnIncident } from './BpmnIncident';
7
+ import type { JoinArrivals } from './JoinArrivals';
7
8
  import type { SuspensionEntry } from './SuspensionEntry';
8
9
  /**
9
10
  * Full runtime state of a BPMN process instance.
@@ -38,11 +39,14 @@ export type BpmnInstanceState = {
38
39
  */
39
40
  variables?: Record<string, any>;
40
41
  /**
41
- * True when the instance has an unresolved incident.
42
+ * True when the instance failed or has an unresolved incident.
42
43
  */
43
44
  error?: boolean;
44
45
  /**
45
- * Active incidents that require resolution before the process can continue.
46
+ * Active incidents that require resolution before the process can
47
+ * continue. Empty once the instance has finished: the incident list keeps
48
+ * each one with `resolvedBy` set to `system:<status>`.
49
+ *
46
50
  */
47
51
  incidents?: Array<BpmnIncident>;
48
52
  /**
@@ -68,6 +72,18 @@ export type BpmnInstanceState = {
68
72
  *
69
73
  */
70
74
  definitionSuspension?: SuspensionEntry;
75
+ /**
76
+ * Present on a call-activity child while an instance above it in the
77
+ * call chain is suspended, carrying that suspension. It clears when that
78
+ * instance is resumed. A suspension of the child itself stays until the
79
+ * child is resumed.
80
+ *
81
+ */
82
+ parentSuspension?: SuspensionEntry;
83
+ /**
84
+ * Joins still waiting to fire, with the flows that have reached them.
85
+ */
86
+ pendingJoinArrivals?: Array<JoinArrivals>;
71
87
  /**
72
88
  * Caller-supplied correlation key set when the instance was started.
73
89
  */
@@ -3,6 +3,6 @@
3
3
  /* tslint:disable */
4
4
  /* eslint-disable */
5
5
  /**
6
- * A scalar numeric correlation value.
6
+ * A scalar numeric correlation value, kept exact (json.Number) so large ids such as order numbers correlate.
7
7
  */
8
8
  export type CorrelationKeyNumber = number;
@@ -12,6 +12,8 @@ export type Error = {
12
12
  * * `UNAUTHORIZED` - request lacks or has an invalid authentication token.
13
13
  * * `FORBIDDEN` - caller is authenticated but lacks permission, or has hit a quota.
14
14
  * * `NOT_FOUND` - the addressed resource does not exist.
15
+ * * `CONFLICT` - the request collides with the resource's current state, such as reporting on a job this worker no longer holds.
16
+ * * `UNAVAILABLE` - the resource cannot answer right now, such as a running instance whose workflow task is being retried. Try again shortly.
15
17
  * * `INTERNAL_ERROR` - unexpected server-side failure.
16
18
  *
17
19
  */
@@ -32,6 +34,8 @@ export namespace Error {
32
34
  * * `UNAUTHORIZED` - request lacks or has an invalid authentication token.
33
35
  * * `FORBIDDEN` - caller is authenticated but lacks permission, or has hit a quota.
34
36
  * * `NOT_FOUND` - the addressed resource does not exist.
37
+ * * `CONFLICT` - the request collides with the resource's current state, such as reporting on a job this worker no longer holds.
38
+ * * `UNAVAILABLE` - the resource cannot answer right now, such as a running instance whose workflow task is being retried. Try again shortly.
35
39
  * * `INTERNAL_ERROR` - unexpected server-side failure.
36
40
  *
37
41
  */
@@ -40,6 +44,8 @@ export namespace Error {
40
44
  UNAUTHORIZED = 'UNAUTHORIZED',
41
45
  FORBIDDEN = 'FORBIDDEN',
42
46
  NOT_FOUND = 'NOT_FOUND',
47
+ CONFLICT = 'CONFLICT',
48
+ UNAVAILABLE = 'UNAVAILABLE',
43
49
  INTERNAL_ERROR = 'INTERNAL_ERROR',
44
50
  }
45
51
  }
@@ -9,7 +9,10 @@ import type { FeelContext } from './FeelContext';
9
9
  */
10
10
  export type EvaluateStoredRequest = {
11
11
  /**
12
- * Specific definition version to evaluate. Defaults to the latest version.
12
+ * Specific definition version to evaluate when evaluating by definitions id. Defaults to the
13
+ * latest version. The `version` query parameter does the same, and a request giving both with
14
+ * different values is rejected. Evaluating by definition UUID ignores it, as the UUID names one version.
15
+ *
13
16
  */
14
17
  version?: number;
15
18
  context: FeelContext;
@@ -39,7 +39,7 @@ export type ExternalJob = {
39
39
  */
40
40
  status: ExternalJob.status;
41
41
  /**
42
- * Remaining retry budget. Decremented each time the worker reports a failure that the BPMN model maps to a retry.
42
+ * Remaining retry budget. A retryable worker error and a lock that runs out each use one.
43
43
  */
44
44
  retries?: number;
45
45
  /**
@@ -14,9 +14,9 @@ export type ExternalJobBatchResponse = {
14
14
  /**
15
15
  * Outcome for this item:
16
16
  * * `completed` - the job was completed successfully.
17
- * * `failed` - the job exhausted its retries and surfaced as an incident.
17
+ * * `failed` - the error was raised on the process, because no retries were left or `retryable` was false. An error boundary catches it, or it raises an incident.
18
18
  * * `requeued` - a retry budget remained, the job is back in PENDING.
19
- * * `error` - the per-item operation itself failed; the job's state is unchanged.
19
+ * * `error` - the per-item operation itself failed, and the job's state is unchanged.
20
20
  *
21
21
  */
22
22
  status: 'completed' | 'failed' | 'requeued' | 'error';
@@ -0,0 +1,13 @@
1
+ /* generated using openapi-typescript-codegen -- do not edit */
2
+ /* istanbul ignore file */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /**
6
+ * The flows that have delivered tokens to a join that has not fired yet.
7
+ */
8
+ export type JoinArrivals = {
9
+ nodeId: string;
10
+ scopeId: string;
11
+ incomingFlows: Array<string>;
12
+ };
13
+
@@ -15,7 +15,7 @@ export type PollBpmnJobRequest = {
15
15
  */
16
16
  clientID: string;
17
17
  /**
18
- * Exclusive lock duration on each acquired job. Accepts Go duration strings (e.g. `5s`, `2m`). Defaults to `30s`.
18
+ * How long each acquired job stays locked to this worker without a heartbeat. Accepts Go duration strings (e.g. `5s`, `2m`). Defaults to `30s`, clamped by the server to 10s..5m.
19
19
  */
20
20
  lockDuration?: string;
21
21
  /**
@@ -12,9 +12,9 @@
12
12
  */
13
13
  export type SuspensionEntry = {
14
14
  /**
15
- * Unix epoch nanoseconds at which the suspension was applied.
15
+ * When the suspension was applied.
16
16
  */
17
- suspendedAt: number;
17
+ suspendedAt: string;
18
18
  /**
19
19
  * Identifier of the operator (or service account) that initiated the suspension.
20
20
  */
@@ -4,16 +4,23 @@
4
4
  /* eslint-disable */
5
5
  /**
6
6
  * Reassign a CREATED user task. All fields are optional but at least one
7
- * must be present. Fields are REPLACED atomically - pass the full set of
8
- * candidateUsers / candidateGroups you want stored, not a delta.
7
+ * must be present, an empty body is rejected with 400. A field you leave out
8
+ * keeps its value. A list you send replaces the stored one, so pass the full
9
+ * set of candidateUsers / candidateGroups you want, not a delta.
9
10
  *
10
11
  */
11
12
  export type UpdateUserTaskAssignmentRequest = {
12
13
  /**
13
- * New assignee. Pass null to clear.
14
+ * New assignee. An empty string clears it.
15
+ */
16
+ assignee?: string;
17
+ /**
18
+ * Replaces the candidate users. An empty list clears them.
14
19
  */
15
- assignee?: string | null;
16
20
  candidateUsers?: Array<string>;
21
+ /**
22
+ * Replaces the candidate groups. An empty list clears them.
23
+ */
17
24
  candidateGroups?: Array<string>;
18
25
  };
19
26
 
@@ -98,6 +98,9 @@ export class BpmnService {
98
98
  'projectID': projectId,
99
99
  'resourceID': resourceId,
100
100
  },
101
+ errors: {
102
+ 404: `Not Found`,
103
+ },
101
104
  });
102
105
  }
103
106
  /**
@@ -182,14 +185,16 @@ export class BpmnService {
182
185
  errors: {
183
186
  400: `Bad Request`,
184
187
  401: `Unauthorized`,
188
+ 404: `Not Found`,
185
189
  500: `Internal Server Error`,
186
190
  },
187
191
  });
188
192
  }
189
193
  /**
190
- * Start a test instance from a draft resource
191
- * Starts a process instance against a draft (non-deployed) resource.
192
- * Useful for trying out an in-progress design before deploying.
194
+ * Start a test instance from a resource
195
+ * Starts a test instance of a resource, draft or deployed. A draft can
196
+ * only be started this way, which makes it the way to try out an
197
+ * in-progress design before deploying.
193
198
  * Test instances run with the same engine as production but are flagged
194
199
  * so they can be filtered out of dashboards.
195
200
  *
@@ -221,6 +226,7 @@ export class BpmnService {
221
226
  errors: {
222
227
  400: `Bad Request`,
223
228
  401: `Unauthorized`,
229
+ 404: `Not Found`,
224
230
  500: `Internal Server Error`,
225
231
  },
226
232
  });
@@ -456,7 +462,7 @@ export class BpmnService {
456
462
  definitionId?: string,
457
463
  workflowId?: string,
458
464
  status?: 'open' | 'resolved',
459
- errorType?: 'BpmnError' | 'EscalationError' | 'CompensationError' | 'FeelError' | 'NoHandler' | 'GatewayNoMatch' | 'TimerResolution' | 'LinkNotFound' | 'MigrationError' | 'SubscriptionError' | 'RotationLimitError' | 'SnapshotSizeExceeded' | 'CallActivityCanceled' | 'ExternalRowRefreshError' | 'Unknown',
465
+ errorType?: 'BpmnError' | 'EscalationError' | 'CompensationError' | 'FeelError' | 'NoHandler' | 'GatewayNoMatch' | 'TimerResolution' | 'LinkNotFound' | 'MigrationError' | 'SubscriptionError' | 'RotationLimitError' | 'SnapshotSizeExceeded' | 'CallActivityCanceled' | 'ExternalRowRefreshError' | 'JobLockLost' | 'DecisionNotFound' | 'Unknown',
460
466
  since?: string,
461
467
  until?: string,
462
468
  page?: number,
@@ -834,10 +840,10 @@ export class BpmnService {
834
840
  errorCode: string;
835
841
  /**
836
842
  * Optional worker identity (the same `clientID` used to poll).
837
- * When supplied, the error is applied only if this worker still
838
- * holds the job's lock, so a stale report can't requeue or fail
839
- * a job a peer is actively holding. Omit for the legacy
840
- * unchecked behavior.
843
+ * When supplied, a worker that no longer holds the job's lock
844
+ * gets 409 and its report is discarded, so a stale report can't
845
+ * requeue or fail the job. Omit for the legacy unchecked
846
+ * behavior.
841
847
  *
842
848
  */
843
849
  clientID?: string;
@@ -865,6 +871,13 @@ export class BpmnService {
865
871
  },
866
872
  body: requestBody,
867
873
  mediaType: 'application/json',
874
+ errors: {
875
+ 404: `No job has this execution key.`,
876
+ 409: `This worker no longer holds the job, so the report was discarded.
877
+ Its lock ran out, another worker holds it, or the job has finished.
878
+ The message says when the job was cancelled.
879
+ `,
880
+ },
868
881
  });
869
882
  }
870
883
  /**
@@ -884,9 +897,9 @@ export class BpmnService {
884
897
  /**
885
898
  * Optional worker identity (the same `clientID` used to poll)
886
899
  * applied to every item in the batch - a batch is one worker's
887
- * report. When supplied, an item is completed only if this
888
- * worker still holds its lock; items re-acquired by a peer drop
889
- * out silently. Omit for the legacy unchecked behavior.
900
+ * report. When supplied, an item this worker no longer holds
901
+ * comes back with status `error` and its result is discarded.
902
+ * Omit for the legacy unchecked behavior.
890
903
  *
891
904
  */
892
905
  clientID?: string;
@@ -929,10 +942,9 @@ export class BpmnService {
929
942
  /**
930
943
  * Optional worker identity (the same `clientID` used to poll)
931
944
  * applied to every item in the batch - a batch is one worker's
932
- * report. When supplied, an item is requeued/failed only if this
933
- * worker still holds its lock; items held by a peer are reported
934
- * as an error and left untouched. Omit for the legacy unchecked
935
- * behavior.
945
+ * report. When supplied, an item this worker no longer holds
946
+ * comes back with status `error` and the job is left untouched.
947
+ * Omit for the legacy unchecked behavior.
936
948
  *
937
949
  */
938
950
  clientID?: string;
@@ -1070,7 +1082,8 @@ export class BpmnService {
1070
1082
  }
1071
1083
  /**
1072
1084
  * Update User Task Assignment
1073
- * Reassign / change candidates on a CREATED user task. Returns 404 if the
1085
+ * Reassign / change candidates on a CREATED user task. Only the fields in
1086
+ * the body change. Returns 400 for a body with none of them, and 404 if the
1074
1087
  * task does not exist or is no longer in CREATED state. Requires Executor
1075
1088
  * role on the project.
1076
1089
  *
@@ -1095,6 +1108,7 @@ export class BpmnService {
1095
1108
  body: requestBody,
1096
1109
  mediaType: 'application/json',
1097
1110
  errors: {
1111
+ 400: `Bad Request`,
1098
1112
  404: `Not Found`,
1099
1113
  },
1100
1114
  });
@@ -1131,6 +1145,10 @@ export class BpmnService {
1131
1145
  errors: {
1132
1146
  403: `Forbidden - caller is not Executor and not assigned to the task`,
1133
1147
  404: `User task not found`,
1148
+ 409: `The task is no longer open: it was already completed or failed,
1149
+ possibly by another user a moment earlier, or it was cancelled.
1150
+ Nothing was applied.
1151
+ `,
1134
1152
  },
1135
1153
  });
1136
1154
  }
@@ -1166,6 +1184,10 @@ export class BpmnService {
1166
1184
  errors: {
1167
1185
  403: `Forbidden - caller is not Executor and not assigned to the task`,
1168
1186
  404: `User task not found`,
1187
+ 409: `The task is no longer open: it was already completed or failed,
1188
+ possibly by another user a moment earlier, or it was cancelled.
1189
+ Nothing was applied.
1190
+ `,
1169
1191
  },
1170
1192
  });
1171
1193
  }
@@ -1213,6 +1235,12 @@ export class BpmnService {
1213
1235
  },
1214
1236
  body: requestBody,
1215
1237
  mediaType: 'application/json',
1238
+ errors: {
1239
+ 400: `A message start event for \`messageName\` belongs to a suspended
1240
+ process definition, so the message would not start it. Nothing was
1241
+ published or buffered. Publish again once the definition is resumed.
1242
+ `,
1243
+ },
1216
1244
  });
1217
1245
  }
1218
1246
  /**
@@ -1258,6 +1286,12 @@ export class BpmnService {
1258
1286
  },
1259
1287
  body: requestBody,
1260
1288
  mediaType: 'application/json',
1289
+ errors: {
1290
+ 400: `A signal start event for \`signalName\` belongs to a suspended process
1291
+ definition, so the signal would not start it. Nothing was published
1292
+ or buffered. Publish again once the definition is resumed.
1293
+ `,
1294
+ },
1261
1295
  });
1262
1296
  }
1263
1297
  /**
@@ -1269,7 +1303,7 @@ export class BpmnService {
1269
1303
  * @param projectId
1270
1304
  * @param page
1271
1305
  * @param pageSize
1272
- * @param q Optional case-insensitive substring match against process id or process name.
1306
+ * @param q Optional case-insensitive prefix match against process id or process name.
1273
1307
  * @param createdAfter Bounds the totalCount aggregate to instances created at or after this
1274
1308
  * timestamp. Strongly recommended for monitoring views - instance
1275
1309
  * history accumulates indefinitely and unfiltered totals scan the full
@@ -680,7 +680,8 @@ export class DefaultService {
680
680
  * accumulate indefinitely, and unfiltered queries grow linearly with
681
681
  * that history.
682
682
  *
683
- * @param businessId Exact-match filter on the caller-supplied correlation key set at start time.
683
+ * @param businessId Prefix match on the caller-supplied correlation key set at start time.
684
+ * @param processId Only instances of this process id, in any version. `definitionID` selects one version.
684
685
  * @param page
685
686
  * @param pageSize
686
687
  * @returns BpmnInstancePaginatedResponse OK
@@ -689,11 +690,12 @@ export class DefaultService {
689
690
  public listBpmnInstances(
690
691
  projectId: string,
691
692
  definitionId?: string,
692
- status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED',
693
+ status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED' | 'TERMINATED' | 'TIMED_OUT',
693
694
  hasIncident?: boolean,
694
695
  suspended?: boolean,
695
696
  createdAfter?: string,
696
697
  businessId?: string,
698
+ processId?: string,
697
699
  page?: number,
698
700
  pageSize?: number,
699
701
  ): CancelablePromise<BpmnInstancePaginatedResponse> {
@@ -710,6 +712,7 @@ export class DefaultService {
710
712
  'suspended': suspended,
711
713
  'createdAfter': createdAfter,
712
714
  'businessId': businessId,
715
+ 'processId': processId,
713
716
  'page': page,
714
717
  'pageSize': pageSize,
715
718
  },
@@ -721,6 +724,9 @@ export class DefaultService {
721
724
  * `workflowID` is the stable execution identifier - use it to fetch
722
725
  * state, send signals/messages, complete user tasks, etc.
723
726
  *
727
+ * A process from a resource that is not deployed yet is refused with a
728
+ * 400. Drafts only start test instances, see `StartBpmnTestInstance`.
729
+ *
724
730
  * @param projectId
725
731
  * @param requestBody
726
732
  * @returns any Created
@@ -746,6 +752,7 @@ export class DefaultService {
746
752
  errors: {
747
753
  400: `Bad Request`,
748
754
  401: `Unauthorized`,
755
+ 404: `Not Found`,
749
756
  500: `Internal Server Error`,
750
757
  },
751
758
  });
@@ -773,6 +780,11 @@ export class DefaultService {
773
780
  'projectID': projectId,
774
781
  'workflowID': workflowId,
775
782
  },
783
+ errors: {
784
+ 503: `The instance is running but did not answer the state query, typically
785
+ while Temporal retries a workflow task that timed out. Try again shortly.
786
+ `,
787
+ },
776
788
  });
777
789
  }
778
790
  /**
@@ -798,6 +810,10 @@ export class DefaultService {
798
810
  'projectID': projectId,
799
811
  'workflowID': workflowId,
800
812
  },
813
+ errors: {
814
+ 400: `The instance is a call-activity child of a running instance. Cancel the root instance instead.`,
815
+ 404: `No instance has this workflow ID.`,
816
+ },
801
817
  });
802
818
  }
803
819
  /**
@@ -811,7 +827,7 @@ export class DefaultService {
811
827
  * @param taskType Filter jobs by task type
812
828
  * @param status Filter jobs by status
813
829
  * @param workflowId Filter jobs by workflow ID
814
- * @param businessId Exact-match filter on the caller-supplied correlation key.
830
+ * @param businessId Prefix match on the caller-supplied correlation key.
815
831
  * @param createdAfter Only return jobs created at or after this timestamp. Strongly
816
832
  * recommended for monitoring views - completed-job records accumulate
817
833
  * indefinitely, and unfiltered queries grow linearly with that history.
@@ -852,9 +868,11 @@ export class DefaultService {
852
868
  * Poll for external jobs (long-poll)
853
869
  * Long-polls for PENDING jobs of a given `taskType`. Returns a batch of
854
870
  * jobs (up to `maxJobs`) as soon as any are available, or `204 No Content`
855
- * when the timeout elapses with no work. Each returned job is exclusively
856
- * leased to the caller for `lockDuration` - call `Heartbeat` to extend
857
- * the lock, then `Complete` or `ThrowError` to finalize.
871
+ * when the timeout elapses with no work. Each returned job is locked to
872
+ * the caller until `lockDuration` passes without a `Heartbeat`, and for at
873
+ * most the server's `BPMN_JOB_MAX_HOLD` (30m by default) in total. Finish
874
+ * with `Complete` or `ThrowError`. A lock that runs out costs the job a
875
+ * retry, and with no retries left it raises an incident.
858
876
  *
859
877
  * @param projectId
860
878
  * @param requestBody
@@ -873,14 +891,18 @@ export class DefaultService {
873
891
  },
874
892
  body: requestBody,
875
893
  mediaType: 'application/json',
894
+ errors: {
895
+ 400: `An empty \`clientID\`, or a \`lockDuration\` or \`timeout\` that is not a Go duration.`,
896
+ },
876
897
  });
877
898
  }
878
899
  /**
879
900
  * Extend the lock on an acquired job
880
- * Refreshes the exclusive lock on a job that the caller previously
881
- * acquired via `Poll`. Call this periodically when handling a job that
882
- * takes longer than the original `lockDuration`. Other workers cannot
883
- * claim the job until the lock expires or the job is completed.
901
+ * Keeps the caller's lock on a job it acquired via `Poll` for another
902
+ * `lockDuration`, up to `BPMN_JOB_MAX_HOLD` after the job was handed out.
903
+ * SDK workers send it at half of the lock the poll granted
904
+ * (`lockExpiresAt`) while a handler runs.
905
+ * Other workers cannot claim the job while the lock holds.
884
906
  *
885
907
  * @param projectId
886
908
  * @param executionKey
@@ -909,7 +931,12 @@ export class DefaultService {
909
931
  body: requestBody,
910
932
  mediaType: 'application/json',
911
933
  errors: {
912
- 404: `Job not found, not owned by this client, or already terminated`,
934
+ 400: `An empty \`clientID\`, or a \`lockDuration\` that is not a Go duration.`,
935
+ 404: `No job has this execution key.`,
936
+ 409: `This worker no longer holds the job. Its lock ran out, another
937
+ worker holds it, or the job has finished. Stop working on it. The
938
+ message says when the job was cancelled.
939
+ `,
913
940
  },
914
941
  });
915
942
  }
@@ -936,10 +963,10 @@ export class DefaultService {
936
963
  workflowID: string;
937
964
  /**
938
965
  * Optional worker identity (the same `clientID` used to poll).
939
- * When supplied, the completion is applied only if this worker
940
- * still holds the job's lock; a stale worker whose lease lapsed
941
- * and whose job a peer re-acquired is rejected as a no-op.
942
- * Omit for the legacy unchecked behavior.
966
+ * When supplied, a worker that no longer holds the job's lock
967
+ * gets 409 and its result is discarded. Completing a job this
968
+ * worker already completed answers 200 again. Omit for the
969
+ * legacy unchecked behavior.
943
970
  *
944
971
  */
945
972
  clientID?: string;
@@ -955,6 +982,13 @@ export class DefaultService {
955
982
  },
956
983
  body: requestBody,
957
984
  mediaType: 'application/json',
985
+ errors: {
986
+ 404: `No job has this execution key.`,
987
+ 409: `This worker no longer holds the job, so the result was discarded.
988
+ Its lock ran out, another worker holds or completed it, or the job
989
+ failed or was cancelled. The message says when it was cancelled.
990
+ `,
991
+ },
958
992
  });
959
993
  }
960
994
  }
package/src/index.test.ts CHANGED
@@ -51,6 +51,7 @@ describe('BpmnClient.listInstances argument ordering', () => {
51
51
  suspended: false,
52
52
  createdAfter: '2026-01-01T00:00:00Z',
53
53
  businessId: 'ORDER-42',
54
+ processId: 'order_flow',
54
55
  page: 2,
55
56
  pageSize: 10,
56
57
  });
@@ -64,6 +65,7 @@ describe('BpmnClient.listInstances argument ordering', () => {
64
65
  false,
65
66
  '2026-01-01T00:00:00Z',
66
67
  'ORDER-42',
68
+ 'order_flow',
67
69
  2,
68
70
  10,
69
71
  ]);
@@ -93,6 +95,7 @@ describe('BpmnClient.listInstances argument ordering', () => {
93
95
  undefined,
94
96
  undefined,
95
97
  undefined,
98
+ undefined,
96
99
  3,
97
100
  undefined,
98
101
  ]);