@quantumbpm/sdk 0.0.1 → 0.12.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.
- package/dist/bpmn.d.ts +15 -0
- package/dist/bpmn.js +5 -2
- package/dist/generated/index.d.ts +5 -1
- package/dist/generated/index.js +4 -4
- package/dist/generated/models/BpmnIncidentRecord.d.ts +88 -0
- package/dist/generated/models/BpmnIncidentRecord.js +23 -0
- package/dist/generated/models/BpmnIncidentRecordPaginatedResponse.d.ts +9 -0
- package/dist/generated/models/BpmnIncidentRecordPaginatedResponse.js +3 -0
- package/dist/generated/models/BpmnInstance.d.ts +20 -0
- package/dist/generated/models/BpmnInstance.js +1 -1
- package/dist/generated/models/BpmnInstanceState.d.ts +24 -5
- package/dist/generated/models/BpmnInstanceState.js +1 -1
- package/dist/generated/models/BpmnProcessVersion.d.ts +16 -0
- package/dist/generated/models/BpmnProcessVersion.js +1 -1
- package/dist/generated/models/SuspendBpmnDefinitionRequest.d.ts +6 -0
- package/dist/generated/models/SuspendBpmnDefinitionRequest.js +3 -0
- package/dist/generated/models/SuspendBpmnInstanceRequest.d.ts +9 -0
- package/dist/generated/models/SuspendBpmnInstanceRequest.js +3 -0
- package/dist/generated/models/SuspensionEntry.d.ts +22 -0
- package/dist/generated/models/SuspensionEntry.js +3 -0
- package/dist/generated/services/BpmnService.d.ts +102 -0
- package/dist/generated/services/BpmnService.js +164 -1
- package/dist/generated/services/DefaultService.d.ts +17 -1
- package/dist/generated/services/DefaultService.js +26 -2
- package/dist/workers.d.ts +13 -0
- package/dist/workers.js +29 -2
- package/package.json +1 -1
- package/src/bpmn.ts +21 -0
- package/src/generated/index.ts +5 -1
- package/src/generated/models/BpmnIncidentRecord.ts +93 -0
- package/src/generated/models/BpmnIncidentRecordPaginatedResponse.ts +14 -0
- package/src/generated/models/BpmnInstance.ts +20 -0
- package/src/generated/models/BpmnInstanceState.ts +24 -5
- package/src/generated/models/BpmnProcessVersion.ts +16 -0
- package/src/generated/models/SuspendBpmnDefinitionRequest.ts +11 -0
- package/src/generated/models/SuspendBpmnInstanceRequest.ts +14 -0
- package/src/generated/models/SuspensionEntry.ts +27 -0
- package/src/generated/services/BpmnService.ts +190 -0
- package/src/generated/services/DefaultService.ts +27 -0
- package/src/index.test.ts +67 -0
- package/src/workers.test.ts +51 -0
- package/src/workers.ts +38 -1
- package/dist/generated/models/BpmnActivityState.d.ts +0 -52
- package/dist/generated/models/BpmnActivityState.js +0 -17
- package/src/generated/models/BpmnActivityState.ts +0 -57
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/**
|
|
6
|
+
* A persisted incident — the cross-instance audit row that backs the
|
|
7
|
+
* "Incidents" view. The same incident is also available in
|
|
8
|
+
* `BpmnInstanceState.incidents` while it is still open in the engine; the
|
|
9
|
+
* persisted row additionally carries `raisedAt` / `resolvedAt` /
|
|
10
|
+
* `resolvedBy` and the parent process metadata so it can be listed and
|
|
11
|
+
* filtered without joining back to the instance.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export type BpmnIncidentRecord = {
|
|
15
|
+
/**
|
|
16
|
+
* Surrogate row identifier; stable across resolves.
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Engine-assigned incident identifier, unique within the workflow.
|
|
21
|
+
*/
|
|
22
|
+
incidentID: string;
|
|
23
|
+
/**
|
|
24
|
+
* Identifier of the instance that produced the incident.
|
|
25
|
+
*/
|
|
26
|
+
workflowID: string;
|
|
27
|
+
/**
|
|
28
|
+
* ID of the process definition the instance is running. May be absent when the source definition was deleted.
|
|
29
|
+
*/
|
|
30
|
+
definitionID?: string;
|
|
31
|
+
/**
|
|
32
|
+
* BPMN process ID of the parent definition. Convenience field; absent when definitionID is unresolved.
|
|
33
|
+
*/
|
|
34
|
+
processID?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Human-readable name of the parent process definition.
|
|
37
|
+
*/
|
|
38
|
+
processName?: string;
|
|
39
|
+
/**
|
|
40
|
+
* ID of the BPMN node where the error occurred.
|
|
41
|
+
*/
|
|
42
|
+
nodeID: string;
|
|
43
|
+
/**
|
|
44
|
+
* ID of the scope in which the error occurred.
|
|
45
|
+
*/
|
|
46
|
+
scopeID?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Execution key of the activity that failed.
|
|
49
|
+
*/
|
|
50
|
+
executionKey?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Category of the error — same enum as `BpmnIncident.errorType`.
|
|
53
|
+
*/
|
|
54
|
+
errorType: BpmnIncidentRecord.errorType;
|
|
55
|
+
/**
|
|
56
|
+
* BPMN error code from the process definition; empty for non-BPMN errors.
|
|
57
|
+
*/
|
|
58
|
+
errorCode?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Human-readable description of the error.
|
|
61
|
+
*/
|
|
62
|
+
errorMessage: string;
|
|
63
|
+
/**
|
|
64
|
+
* Timestamp when the engine recorded the incident.
|
|
65
|
+
*/
|
|
66
|
+
raisedAt: string;
|
|
67
|
+
/**
|
|
68
|
+
* Timestamp when the incident was resolved. Empty while open.
|
|
69
|
+
*/
|
|
70
|
+
resolvedAt?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Identifier of the user who resolved the incident, or "system:reconcile" when corrected by drift reconciliation. Empty for engine-internal resolves (boundary catches, modification cancel) and for open incidents.
|
|
73
|
+
*/
|
|
74
|
+
resolvedBy?: string;
|
|
75
|
+
};
|
|
76
|
+
export namespace BpmnIncidentRecord {
|
|
77
|
+
/**
|
|
78
|
+
* Category of the error — same enum as `BpmnIncident.errorType`.
|
|
79
|
+
*/
|
|
80
|
+
export enum errorType {
|
|
81
|
+
BPMN_ERROR = 'BpmnError',
|
|
82
|
+
ESCALATION_ERROR = 'EscalationError',
|
|
83
|
+
COMPENSATION_ERROR = 'CompensationError',
|
|
84
|
+
FEEL_ERROR = 'FeelError',
|
|
85
|
+
NO_HANDLER = 'NoHandler',
|
|
86
|
+
GATEWAY_NO_MATCH = 'GatewayNoMatch',
|
|
87
|
+
TIMER_RESOLUTION = 'TimerResolution',
|
|
88
|
+
LINK_NOT_FOUND = 'LinkNotFound',
|
|
89
|
+
MIGRATION_ERROR = 'MigrationError',
|
|
90
|
+
UNKNOWN = 'Unknown',
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { BpmnIncidentRecord } from './BpmnIncidentRecord';
|
|
6
|
+
import type { PaginationMetadata } from './PaginationMetadata';
|
|
7
|
+
/**
|
|
8
|
+
* Page of persisted incidents.
|
|
9
|
+
*/
|
|
10
|
+
export type BpmnIncidentRecordPaginatedResponse = {
|
|
11
|
+
data: Array<BpmnIncidentRecord>;
|
|
12
|
+
pagination: PaginationMetadata;
|
|
13
|
+
};
|
|
14
|
+
|
|
@@ -34,6 +34,26 @@ export type BpmnInstance = {
|
|
|
34
34
|
* Timestamp when the instance reached a terminal status. Empty while running.
|
|
35
35
|
*/
|
|
36
36
|
completedAt?: string;
|
|
37
|
+
/**
|
|
38
|
+
* True when at least one unresolved incident is currently attached to this instance. Computed at query time against the open-incidents index — useful for rendering a "needs attention" indicator in instance lists without paying for a per-row state fetch from the engine.
|
|
39
|
+
*/
|
|
40
|
+
hasIncident?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Timestamp at which this instance was paused at INSTANCE scope. Empty
|
|
43
|
+
* when not instance-suspended. The instance may still be effectively
|
|
44
|
+
* suspended via its definition — call `GetBpmnInstance` to read both
|
|
45
|
+
* scopes if you need the full picture.
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
suspendedAt?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Operator who suspended this instance (instance scope). Empty when not instance-suspended.
|
|
51
|
+
*/
|
|
52
|
+
suspendedBy?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Free-text reason captured at suspend time.
|
|
55
|
+
*/
|
|
56
|
+
suspendReason?: string;
|
|
37
57
|
};
|
|
38
58
|
export namespace BpmnInstance {
|
|
39
59
|
/**
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/* tslint:disable */
|
|
4
4
|
/* eslint-disable */
|
|
5
5
|
import type { ActiveScope } from './ActiveScope';
|
|
6
|
-
import type { BpmnActivityState } from './BpmnActivityState';
|
|
7
6
|
import type { BpmnIncident } from './BpmnIncident';
|
|
7
|
+
import type { SuspensionEntry } from './SuspensionEntry';
|
|
8
8
|
/**
|
|
9
9
|
* Full runtime state of a BPMN process instance.
|
|
10
10
|
*/
|
|
@@ -21,6 +21,14 @@ export type BpmnInstanceState = {
|
|
|
21
21
|
* Execution identifier of the parent instance that started this one via a CallActivity. Empty for top-level instances.
|
|
22
22
|
*/
|
|
23
23
|
parentWorkflowID?: string;
|
|
24
|
+
/**
|
|
25
|
+
* BPMN process definition ID this instance was started from.
|
|
26
|
+
*/
|
|
27
|
+
processId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Version of the BPMN process definition this instance is currently running. Updated by migration operations.
|
|
30
|
+
*/
|
|
31
|
+
processVersion?: number;
|
|
24
32
|
/**
|
|
25
33
|
* Current lifecycle status of the instance (e.g. RUNNING, COMPLETED, FAILED, TERMINATED).
|
|
26
34
|
*/
|
|
@@ -29,10 +37,6 @@ export type BpmnInstanceState = {
|
|
|
29
37
|
* All variables currently in scope for the root process.
|
|
30
38
|
*/
|
|
31
39
|
variables?: Record<string, any>;
|
|
32
|
-
/**
|
|
33
|
-
* Ordered list of activity execution records.
|
|
34
|
-
*/
|
|
35
|
-
history?: Array<BpmnActivityState>;
|
|
36
40
|
/**
|
|
37
41
|
* True when the instance has an unresolved incident.
|
|
38
42
|
*/
|
|
@@ -49,5 +53,20 @@ export type BpmnInstanceState = {
|
|
|
49
53
|
* Error message from the workflow when status is FAILED.
|
|
50
54
|
*/
|
|
51
55
|
failureReason?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Present when this instance has been explicitly suspended by an
|
|
58
|
+
* operator. Persisted across CaN rotations. Clear via the resume
|
|
59
|
+
* instance endpoint. Composes with `definitionSuspension` — both must
|
|
60
|
+
* be null for the instance to dispatch tokens.
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
instanceSuspension?: SuspensionEntry;
|
|
64
|
+
/**
|
|
65
|
+
* Present when the instance's process definition has been suspended.
|
|
66
|
+
* Clear via the resume definition endpoint (the backend fans out to
|
|
67
|
+
* every running instance of the definition).
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
definitionSuspension?: SuspensionEntry;
|
|
52
71
|
};
|
|
53
72
|
|
|
@@ -42,5 +42,21 @@ export type BpmnProcessVersion = {
|
|
|
42
42
|
* All instances of this version across statuses.
|
|
43
43
|
*/
|
|
44
44
|
totalCount: number;
|
|
45
|
+
/**
|
|
46
|
+
* Timestamp at which this definition was paused. While set, the start
|
|
47
|
+
* endpoint rejects new instances of this definition with 409, and every
|
|
48
|
+
* already-running instance was sent a definition-scope suspend signal.
|
|
49
|
+
* Empty when active.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
suspendedAt?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Operator who suspended this definition. Empty when active.
|
|
55
|
+
*/
|
|
56
|
+
suspendedBy?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Free-text reason captured at suspend time.
|
|
59
|
+
*/
|
|
60
|
+
suspendReason?: string;
|
|
45
61
|
};
|
|
46
62
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/**
|
|
6
|
+
* Optional metadata captured with a definition-scope suspension. The same reason cascades to each running instance.
|
|
7
|
+
*/
|
|
8
|
+
export type SuspendBpmnDefinitionRequest = {
|
|
9
|
+
reason?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/**
|
|
6
|
+
* Optional metadata captured with an instance-scope suspension.
|
|
7
|
+
*/
|
|
8
|
+
export type SuspendBpmnInstanceRequest = {
|
|
9
|
+
/**
|
|
10
|
+
* Free-text rationale. Surfaces in the operator UI and the workflow's history audit.
|
|
11
|
+
*/
|
|
12
|
+
reason?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/**
|
|
6
|
+
* Audit-shaped record of an active suspension at one scope (instance or
|
|
7
|
+
* definition). Returned inline on `BpmnInstanceState` — `null` when not
|
|
8
|
+
* suspended at that scope. An instance is "effectively suspended" if either
|
|
9
|
+
* scope's entry is present; the dispatcher pauses forward token dispatch
|
|
10
|
+
* while either flag is set.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export type SuspensionEntry = {
|
|
14
|
+
/**
|
|
15
|
+
* Unix epoch nanoseconds at which the suspension was applied.
|
|
16
|
+
*/
|
|
17
|
+
suspendedAt: number;
|
|
18
|
+
/**
|
|
19
|
+
* Identifier of the operator (or service account) that initiated the suspension.
|
|
20
|
+
*/
|
|
21
|
+
suspendedBy?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Free-text reason captured at suspend time; surfaces in the operator UI alongside the action.
|
|
24
|
+
*/
|
|
25
|
+
reason?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* istanbul ignore file */
|
|
3
3
|
/* tslint:disable */
|
|
4
4
|
/* eslint-disable */
|
|
5
|
+
import type { BpmnIncidentRecordPaginatedResponse } from '../models/BpmnIncidentRecordPaginatedResponse';
|
|
5
6
|
import type { BpmnInstanceChildrenResponse } from '../models/BpmnInstanceChildrenResponse';
|
|
6
7
|
import type { BpmnProcessSummaryPaginatedResponse } from '../models/BpmnProcessSummaryPaginatedResponse';
|
|
7
8
|
import type { BpmnProcessVersionPaginatedResponse } from '../models/BpmnProcessVersionPaginatedResponse';
|
|
@@ -19,6 +20,8 @@ import type { MigrateBpmnInstanceRequest } from '../models/MigrateBpmnInstanceRe
|
|
|
19
20
|
import type { MigrationValidationResult } from '../models/MigrationValidationResult';
|
|
20
21
|
import type { ModifyBpmnInstanceRequest } from '../models/ModifyBpmnInstanceRequest';
|
|
21
22
|
import type { StartBpmnTestInstanceRequest } from '../models/StartBpmnTestInstanceRequest';
|
|
23
|
+
import type { SuspendBpmnDefinitionRequest } from '../models/SuspendBpmnDefinitionRequest';
|
|
24
|
+
import type { SuspendBpmnInstanceRequest } from '../models/SuspendBpmnInstanceRequest';
|
|
22
25
|
import type { UpdateUserTaskAssignmentRequest } from '../models/UpdateUserTaskAssignmentRequest';
|
|
23
26
|
import type { UserTask } from '../models/UserTask';
|
|
24
27
|
import type { ValidateBpmnResourceRequest } from '../models/ValidateBpmnResourceRequest';
|
|
@@ -424,6 +427,60 @@ export class BpmnService {
|
|
|
424
427
|
mediaType: 'application/json',
|
|
425
428
|
});
|
|
426
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* List BPMN incidents
|
|
432
|
+
* Cross-instance audit listing of incidents in the project. By default
|
|
433
|
+
* returns open incidents first (unresolved), ordered by recency.
|
|
434
|
+
* Filterable by definition, error type, status, and time window.
|
|
435
|
+
*
|
|
436
|
+
* Each row carries the parent process metadata (processID, processName)
|
|
437
|
+
* so a single page render needs no follow-up queries against the
|
|
438
|
+
* instances endpoint. Click-through to a specific instance still uses
|
|
439
|
+
* the workflow-scoped detail endpoint.
|
|
440
|
+
*
|
|
441
|
+
* @param projectId
|
|
442
|
+
* @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.
|
|
444
|
+
* @param status Filter by lifecycle status. `open` returns unresolved incidents;
|
|
445
|
+
* `resolved` returns only resolved ones. Omit to return both.
|
|
446
|
+
*
|
|
447
|
+
* @param errorType Restrict to a single error category (matches `BpmnIncidentRecord.errorType`).
|
|
448
|
+
* @param since Earliest `raisedAt` to include (inclusive).
|
|
449
|
+
* @param until Latest `raisedAt` to include (exclusive).
|
|
450
|
+
* @param page
|
|
451
|
+
* @param pageSize
|
|
452
|
+
* @returns BpmnIncidentRecordPaginatedResponse OK
|
|
453
|
+
* @throws ApiError
|
|
454
|
+
*/
|
|
455
|
+
public listBpmnIncidents(
|
|
456
|
+
projectId: string,
|
|
457
|
+
definitionId?: string,
|
|
458
|
+
workflowId?: string,
|
|
459
|
+
status?: 'open' | 'resolved',
|
|
460
|
+
errorType?: 'BpmnError' | 'EscalationError' | 'CompensationError' | 'FeelError' | 'NoHandler' | 'GatewayNoMatch' | 'TimerResolution' | 'LinkNotFound' | 'MigrationError' | 'Unknown',
|
|
461
|
+
since?: string,
|
|
462
|
+
until?: string,
|
|
463
|
+
page?: number,
|
|
464
|
+
pageSize?: number,
|
|
465
|
+
): CancelablePromise<BpmnIncidentRecordPaginatedResponse> {
|
|
466
|
+
return this.httpRequest.request({
|
|
467
|
+
method: 'GET',
|
|
468
|
+
url: '/projects/{projectID}/bpmn/incidents',
|
|
469
|
+
path: {
|
|
470
|
+
'projectID': projectId,
|
|
471
|
+
},
|
|
472
|
+
query: {
|
|
473
|
+
'definitionID': definitionId,
|
|
474
|
+
'workflowID': workflowId,
|
|
475
|
+
'status': status,
|
|
476
|
+
'errorType': errorType,
|
|
477
|
+
'since': since,
|
|
478
|
+
'until': until,
|
|
479
|
+
'page': page,
|
|
480
|
+
'pageSize': pageSize,
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
}
|
|
427
484
|
/**
|
|
428
485
|
* Migrate a running instance to a newer process version
|
|
429
486
|
* Moves a running instance from its current process version to a newer
|
|
@@ -577,6 +634,139 @@ export class BpmnService {
|
|
|
577
634
|
mediaType: 'application/json',
|
|
578
635
|
});
|
|
579
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* Suspend a BPMN instance
|
|
639
|
+
* Pauses forward token dispatch on a single running instance. The
|
|
640
|
+
* instance's lifecycle status stays RUNNING; an orthogonal `suspendedAt`
|
|
641
|
+
* flag layers on top. Idempotent — a second call against an already-
|
|
642
|
+
* suspended instance is a no-op.
|
|
643
|
+
*
|
|
644
|
+
* While suspended: cancel / terminate / migrate / force-rotate / resolve-
|
|
645
|
+
* incident / variable update / modify all still work. Parked tokens
|
|
646
|
+
* released by signal demuxes or timer fires queue internally and dispatch
|
|
647
|
+
* on resume.
|
|
648
|
+
*
|
|
649
|
+
* The audit (operator, reason, timestamp) is also recorded in the
|
|
650
|
+
* workflow's Temporal history as a `SuspendInstanceEvent` so the timeline
|
|
651
|
+
* view on the instance detail page can render the cycle.
|
|
652
|
+
*
|
|
653
|
+
* @param projectId
|
|
654
|
+
* @param workflowId
|
|
655
|
+
* @param requestBody
|
|
656
|
+
* @returns void
|
|
657
|
+
* @throws ApiError
|
|
658
|
+
*/
|
|
659
|
+
public suspendBpmnInstance(
|
|
660
|
+
projectId: string,
|
|
661
|
+
workflowId: string,
|
|
662
|
+
requestBody?: SuspendBpmnInstanceRequest,
|
|
663
|
+
): CancelablePromise<void> {
|
|
664
|
+
return this.httpRequest.request({
|
|
665
|
+
method: 'POST',
|
|
666
|
+
url: '/projects/{projectID}/bpmn/instances/{workflowID}/suspend',
|
|
667
|
+
path: {
|
|
668
|
+
'projectID': projectId,
|
|
669
|
+
'workflowID': workflowId,
|
|
670
|
+
},
|
|
671
|
+
body: requestBody,
|
|
672
|
+
mediaType: 'application/json',
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Resume a suspended BPMN instance
|
|
677
|
+
* Clears the instance-scope suspension. If the parent definition is also
|
|
678
|
+
* suspended the instance remains effectively paused until the definition
|
|
679
|
+
* is resumed as well. Idempotent.
|
|
680
|
+
*
|
|
681
|
+
* @param projectId
|
|
682
|
+
* @param workflowId
|
|
683
|
+
* @returns void
|
|
684
|
+
* @throws ApiError
|
|
685
|
+
*/
|
|
686
|
+
public resumeBpmnInstance(
|
|
687
|
+
projectId: string,
|
|
688
|
+
workflowId: string,
|
|
689
|
+
): CancelablePromise<void> {
|
|
690
|
+
return this.httpRequest.request({
|
|
691
|
+
method: 'POST',
|
|
692
|
+
url: '/projects/{projectID}/bpmn/instances/{workflowID}/resume',
|
|
693
|
+
path: {
|
|
694
|
+
'projectID': projectId,
|
|
695
|
+
'workflowID': workflowId,
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Suspend every running instance of a BPMN definition
|
|
701
|
+
* Pauses every running instance of one deployed process definition AND
|
|
702
|
+
* rejects new instance starts on that definition until it is resumed.
|
|
703
|
+
*
|
|
704
|
+
* The handler acquires a row-level lock on the definition before flipping
|
|
705
|
+
* the flag so a `StartBpmnInstance` racing the suspend can't slip through.
|
|
706
|
+
* It then iterates over every running instance (`status='RUNNING'`) and
|
|
707
|
+
* sends each one a definition-scope suspend signal via the engine API.
|
|
708
|
+
* Instances that were also explicitly instance-suspended stay paused
|
|
709
|
+
* after a definition-scope resume — the operator must clear that scope
|
|
710
|
+
* too.
|
|
711
|
+
*
|
|
712
|
+
* Idempotent. The reason cascades to every affected instance's history
|
|
713
|
+
* audit (`SuspendDefinitionEvent`) so the UI can render where the pause
|
|
714
|
+
* came from.
|
|
715
|
+
*
|
|
716
|
+
* @param projectId
|
|
717
|
+
* @param definitionId Platform identifier of the process definition version (same UUID `BpmnProcessVersion.id` exposes).
|
|
718
|
+
* @param requestBody
|
|
719
|
+
* @returns void
|
|
720
|
+
* @throws ApiError
|
|
721
|
+
*/
|
|
722
|
+
public suspendBpmnDefinition(
|
|
723
|
+
projectId: string,
|
|
724
|
+
definitionId: string,
|
|
725
|
+
requestBody?: SuspendBpmnDefinitionRequest,
|
|
726
|
+
): CancelablePromise<void> {
|
|
727
|
+
return this.httpRequest.request({
|
|
728
|
+
method: 'POST',
|
|
729
|
+
url: '/projects/{projectID}/bpmn/definitions/{definitionID}/suspend',
|
|
730
|
+
path: {
|
|
731
|
+
'projectID': projectId,
|
|
732
|
+
'definitionID': definitionId,
|
|
733
|
+
},
|
|
734
|
+
body: requestBody,
|
|
735
|
+
mediaType: 'application/json',
|
|
736
|
+
errors: {
|
|
737
|
+
404: `Definition not found`,
|
|
738
|
+
},
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Resume a suspended BPMN definition
|
|
743
|
+
* Clears the definition-scope suspension and fans out a resume signal to
|
|
744
|
+
* every running instance of the definition. Instances that were also
|
|
745
|
+
* instance-suspended stay paused until their own scope is cleared. New
|
|
746
|
+
* instance starts are accepted again once the definition flag clears.
|
|
747
|
+
* Idempotent.
|
|
748
|
+
*
|
|
749
|
+
* @param projectId
|
|
750
|
+
* @param definitionId
|
|
751
|
+
* @returns void
|
|
752
|
+
* @throws ApiError
|
|
753
|
+
*/
|
|
754
|
+
public resumeBpmnDefinition(
|
|
755
|
+
projectId: string,
|
|
756
|
+
definitionId: string,
|
|
757
|
+
): CancelablePromise<void> {
|
|
758
|
+
return this.httpRequest.request({
|
|
759
|
+
method: 'POST',
|
|
760
|
+
url: '/projects/{projectID}/bpmn/definitions/{definitionID}/resume',
|
|
761
|
+
path: {
|
|
762
|
+
'projectID': projectId,
|
|
763
|
+
'definitionID': definitionId,
|
|
764
|
+
},
|
|
765
|
+
errors: {
|
|
766
|
+
404: `Definition not found`,
|
|
767
|
+
},
|
|
768
|
+
});
|
|
769
|
+
}
|
|
580
770
|
/**
|
|
581
771
|
* PENDING job counts grouped by taskType
|
|
582
772
|
* Returns one entry per `taskType` with at least one PENDING job. Useful for
|
|
@@ -665,6 +665,22 @@ export class DefaultService {
|
|
|
665
665
|
* @param projectId
|
|
666
666
|
* @param definitionId
|
|
667
667
|
* @param status
|
|
668
|
+
* @param hasIncident Filter by whether the instance has at least one unresolved incident.
|
|
669
|
+
* Omit to return all instances regardless of incident status; pass
|
|
670
|
+
* `true` to show only instances that need operator attention; pass
|
|
671
|
+
* `false` to exclude blocked instances.
|
|
672
|
+
*
|
|
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.
|
|
678
|
+
*
|
|
679
|
+
* @param createdAfter Only return instances created at or after this timestamp. Strongly
|
|
680
|
+
* recommended for monitoring views — terminal-state instance rows
|
|
681
|
+
* accumulate indefinitely, and unfiltered queries grow linearly with
|
|
682
|
+
* that history.
|
|
683
|
+
*
|
|
668
684
|
* @param page
|
|
669
685
|
* @param pageSize
|
|
670
686
|
* @returns BpmnInstancePaginatedResponse OK
|
|
@@ -674,6 +690,9 @@ export class DefaultService {
|
|
|
674
690
|
projectId: string,
|
|
675
691
|
definitionId?: string,
|
|
676
692
|
status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED',
|
|
693
|
+
hasIncident?: boolean,
|
|
694
|
+
suspended?: boolean,
|
|
695
|
+
createdAfter?: string,
|
|
677
696
|
page?: number,
|
|
678
697
|
pageSize?: number,
|
|
679
698
|
): CancelablePromise<BpmnInstancePaginatedResponse> {
|
|
@@ -686,6 +705,9 @@ export class DefaultService {
|
|
|
686
705
|
query: {
|
|
687
706
|
'definitionID': definitionId,
|
|
688
707
|
'status': status,
|
|
708
|
+
'hasIncident': hasIncident,
|
|
709
|
+
'suspended': suspended,
|
|
710
|
+
'createdAfter': createdAfter,
|
|
689
711
|
'page': page,
|
|
690
712
|
'pageSize': pageSize,
|
|
691
713
|
},
|
|
@@ -719,6 +741,11 @@ export class DefaultService {
|
|
|
719
741
|
},
|
|
720
742
|
body: requestBody,
|
|
721
743
|
mediaType: 'application/json',
|
|
744
|
+
errors: {
|
|
745
|
+
400: `Bad Request`,
|
|
746
|
+
401: `Unauthorized`,
|
|
747
|
+
500: `Internal Server Error`,
|
|
748
|
+
},
|
|
722
749
|
});
|
|
723
750
|
}
|
|
724
751
|
/**
|
package/src/index.test.ts
CHANGED
|
@@ -28,3 +28,70 @@ describe('public API surface', () => {
|
|
|
28
28
|
expect(vars.lookup('amount')).toBe(1000);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
describe('BpmnClient.listInstances argument ordering', () => {
|
|
33
|
+
test('forwards each option to its matching generated parameter', async () => {
|
|
34
|
+
const calls: unknown[][] = [];
|
|
35
|
+
const fakeRaw = {
|
|
36
|
+
default: {
|
|
37
|
+
listBpmnInstances: (...args: unknown[]) => {
|
|
38
|
+
calls.push(args);
|
|
39
|
+
return Promise.resolve({ data: [], totalCount: 0 });
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
} as never;
|
|
43
|
+
const projectId = '00000000-0000-0000-0000-000000000001';
|
|
44
|
+
const { BpmnClient } = await import('./bpmn');
|
|
45
|
+
const client = new BpmnClient(fakeRaw, projectId);
|
|
46
|
+
|
|
47
|
+
await client.listInstances({
|
|
48
|
+
definitionId: 'def-1',
|
|
49
|
+
status: 'RUNNING',
|
|
50
|
+
hasIncident: true,
|
|
51
|
+
suspended: false,
|
|
52
|
+
createdAfter: '2026-01-01T00:00:00Z',
|
|
53
|
+
page: 2,
|
|
54
|
+
pageSize: 10,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(calls).toHaveLength(1);
|
|
58
|
+
expect(calls[0]).toEqual([
|
|
59
|
+
projectId,
|
|
60
|
+
'def-1',
|
|
61
|
+
'RUNNING',
|
|
62
|
+
true,
|
|
63
|
+
false,
|
|
64
|
+
'2026-01-01T00:00:00Z',
|
|
65
|
+
2,
|
|
66
|
+
10,
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('omits unset options without sliding values into wrong slots', async () => {
|
|
71
|
+
const calls: unknown[][] = [];
|
|
72
|
+
const fakeRaw = {
|
|
73
|
+
default: {
|
|
74
|
+
listBpmnInstances: (...args: unknown[]) => {
|
|
75
|
+
calls.push(args);
|
|
76
|
+
return Promise.resolve({ data: [], totalCount: 0 });
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
} as never;
|
|
80
|
+
const projectId = '00000000-0000-0000-0000-000000000001';
|
|
81
|
+
const { BpmnClient } = await import('./bpmn');
|
|
82
|
+
const client = new BpmnClient(fakeRaw, projectId);
|
|
83
|
+
|
|
84
|
+
await client.listInstances({ page: 3 });
|
|
85
|
+
|
|
86
|
+
expect(calls[0]).toEqual([
|
|
87
|
+
projectId,
|
|
88
|
+
undefined,
|
|
89
|
+
undefined,
|
|
90
|
+
undefined,
|
|
91
|
+
undefined,
|
|
92
|
+
undefined,
|
|
93
|
+
3,
|
|
94
|
+
undefined,
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Worker } from './workers';
|
|
2
|
+
import { RawClient } from './generated/RawClient';
|
|
3
|
+
|
|
4
|
+
function makeWorker(maxBytes?: number) {
|
|
5
|
+
const warnings: string[] = [];
|
|
6
|
+
const logger = {
|
|
7
|
+
error: () => {},
|
|
8
|
+
warn: (msg: string) => { warnings.push(msg); },
|
|
9
|
+
};
|
|
10
|
+
const fakeRaw = {} as unknown as RawClient;
|
|
11
|
+
const w = new Worker(fakeRaw, '00000000-0000-0000-0000-000000000001', {
|
|
12
|
+
logger,
|
|
13
|
+
...(maxBytes !== undefined ? { maxErrorMessageBytes: maxBytes } : {}),
|
|
14
|
+
});
|
|
15
|
+
return { w, warnings };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('Worker.clampWorkerErrorMessage', () => {
|
|
19
|
+
test('passes short messages through unchanged and does not warn', () => {
|
|
20
|
+
const { w, warnings } = makeWorker();
|
|
21
|
+
const out = w.clampWorkerErrorMessage('payment', 'boom');
|
|
22
|
+
expect(out).toBe('boom');
|
|
23
|
+
expect(warnings).toHaveLength(0);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('truncates at the default 2048-byte cap and warns once', () => {
|
|
27
|
+
const { w, warnings } = makeWorker();
|
|
28
|
+
const huge = 'x'.repeat(100_000);
|
|
29
|
+
const out = w.clampWorkerErrorMessage('payment', huge);
|
|
30
|
+
expect(Buffer.byteLength(out, 'utf8')).toBeLessThanOrEqual(2048);
|
|
31
|
+
expect(out).toMatch(/ bytes\]$/);
|
|
32
|
+
expect(warnings).toHaveLength(1);
|
|
33
|
+
expect(warnings[0]).toContain('WORKER_ERROR message truncated');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('honors a smaller per-worker override', () => {
|
|
37
|
+
const { w } = makeWorker(256);
|
|
38
|
+
const out = w.clampWorkerErrorMessage('payment', 'x'.repeat(10_000));
|
|
39
|
+
expect(Buffer.byteLength(out, 'utf8')).toBeLessThanOrEqual(256);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('cuts on a UTF-8 code-point boundary', () => {
|
|
43
|
+
const { w } = makeWorker(200);
|
|
44
|
+
// "é" is 2 bytes UTF-8 → boundary cuts could otherwise split a rune.
|
|
45
|
+
const msg = 'é'.repeat(1000);
|
|
46
|
+
const out = w.clampWorkerErrorMessage('t', msg);
|
|
47
|
+
// Round-trip through Buffer should be lossless if we cut on a boundary.
|
|
48
|
+
expect(Buffer.from(out, 'utf8').toString('utf8')).toBe(out);
|
|
49
|
+
expect(out).not.toContain('�');
|
|
50
|
+
});
|
|
51
|
+
});
|