@quantumbpm/sdk 1.3.0 → 2.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 (140) hide show
  1. package/README.md +57 -34
  2. package/dist/auth.d.ts +19 -14
  3. package/dist/auth.js +62 -84
  4. package/dist/bpmn.d.ts +86 -23
  5. package/dist/bpmn.js +66 -34
  6. package/dist/dmn.d.ts +0 -6
  7. package/dist/dmn.js +1 -15
  8. package/dist/generated/RawClient.js +2 -2
  9. package/dist/generated/core/OpenAPI.js +2 -2
  10. package/dist/generated/index.d.ts +9 -3
  11. package/dist/generated/index.js +10 -4
  12. package/dist/generated/models/BpmnActivityState.d.ts +85 -0
  13. package/dist/generated/models/BpmnActivityState.js +18 -0
  14. package/dist/generated/models/BpmnElementStatistics.d.ts +36 -0
  15. package/dist/generated/models/BpmnElementStatistics.js +17 -0
  16. package/dist/generated/models/BpmnExternalJobPaginatedResponse.d.ts +2 -2
  17. package/dist/generated/models/BpmnExternalJobPaginatedResponse.js +1 -1
  18. package/dist/generated/models/BpmnHistoryPage.d.ts +15 -0
  19. package/dist/generated/models/BpmnHistoryPage.js +3 -0
  20. package/dist/generated/models/BpmnIncident.d.ts +11 -17
  21. package/dist/generated/models/BpmnIncident.js +7 -11
  22. package/dist/generated/models/BpmnIncidentRecord.d.ts +7 -13
  23. package/dist/generated/models/BpmnIncidentRecord.js +4 -6
  24. package/dist/generated/models/BpmnIncidentRecordPaginatedResponse.d.ts +2 -2
  25. package/dist/generated/models/BpmnIncidentRecordPaginatedResponse.js +1 -1
  26. package/dist/generated/models/BpmnInstance.d.ts +14 -29
  27. package/dist/generated/models/BpmnInstance.js +1 -17
  28. package/dist/generated/models/BpmnInstancePaginatedResponse.d.ts +2 -2
  29. package/dist/generated/models/BpmnInstancePaginatedResponse.js +1 -1
  30. package/dist/generated/models/BpmnInstanceState.d.ts +31 -14
  31. package/dist/generated/models/BpmnInstanceState.js +1 -1
  32. package/dist/generated/models/BpmnInstanceStatus.d.ts +10 -0
  33. package/dist/generated/models/BpmnInstanceStatus.js +19 -0
  34. package/dist/generated/models/BpmnProcessDefinition.d.ts +5 -5
  35. package/dist/generated/models/BpmnProcessDefinition.js +1 -1
  36. package/dist/generated/models/BpmnProcessVersion.d.ts +9 -9
  37. package/dist/generated/models/BpmnProcessVersion.js +1 -1
  38. package/dist/generated/models/BpmnUserTaskPaginatedResponse.d.ts +2 -2
  39. package/dist/generated/models/BpmnUserTaskPaginatedResponse.js +1 -1
  40. package/dist/generated/models/CorrelationKeys.d.ts +7 -6
  41. package/dist/generated/models/CorrelationKeys.js +1 -1
  42. package/dist/generated/models/CreateDefinitionRequest.d.ts +1 -5
  43. package/dist/generated/models/CreateDefinitionRequest.js +1 -1
  44. package/dist/generated/models/CursorPage.d.ts +12 -0
  45. package/dist/generated/models/CursorPage.js +3 -0
  46. package/dist/generated/models/DecisionKind.d.ts +10 -0
  47. package/dist/generated/models/DecisionKind.js +19 -0
  48. package/dist/generated/models/DecisionSummary.d.ts +8 -6
  49. package/dist/generated/models/DecisionSummary.js +1 -1
  50. package/dist/generated/models/DecisionVersion.d.ts +25 -0
  51. package/dist/generated/models/DecisionVersion.js +3 -0
  52. package/dist/generated/models/DecisionVersionList.d.ts +7 -0
  53. package/dist/generated/models/DecisionVersionList.js +3 -0
  54. package/dist/generated/models/Definition.d.ts +16 -8
  55. package/dist/generated/models/Definition.js +1 -1
  56. package/dist/generated/models/Error.d.ts +4 -4
  57. package/dist/generated/models/Error.js +3 -3
  58. package/dist/generated/models/EvaluateStoredRequest.d.ts +5 -6
  59. package/dist/generated/models/EvaluateStoredRequest.js +1 -1
  60. package/dist/generated/models/EvaluationResult.d.ts +6 -0
  61. package/dist/generated/models/EvaluationResult.js +1 -1
  62. package/dist/generated/models/Execution.d.ts +37 -9
  63. package/dist/generated/models/Execution.js +1 -1
  64. package/dist/generated/models/ExternalJob.d.ts +8 -8
  65. package/dist/generated/models/ExternalJob.js +1 -1
  66. package/dist/generated/models/HitRule.d.ts +4 -0
  67. package/dist/generated/models/HitRule.js +1 -1
  68. package/dist/generated/models/PaginatedExecutionsResponse.d.ts +2 -2
  69. package/dist/generated/models/PaginatedExecutionsResponse.js +1 -1
  70. package/dist/generated/models/StartBpmnInstanceRequest.d.ts +6 -2
  71. package/dist/generated/models/StartBpmnInstanceRequest.js +1 -1
  72. package/dist/generated/models/SuspendBpmnInstanceRequest.d.ts +1 -1
  73. package/dist/generated/models/SuspendBpmnInstanceRequest.js +1 -1
  74. package/dist/generated/models/UpdateDefinitionRequest.d.ts +1 -5
  75. package/dist/generated/models/UpdateDefinitionRequest.js +1 -1
  76. package/dist/generated/models/UserTask.d.ts +15 -11
  77. package/dist/generated/models/UserTask.js +1 -1
  78. package/dist/generated/services/BpmnService.d.ts +189 -91
  79. package/dist/generated/services/BpmnService.js +276 -124
  80. package/dist/generated/services/DefaultService.d.ts +111 -115
  81. package/dist/generated/services/DefaultService.js +136 -168
  82. package/dist/index.d.ts +8 -8
  83. package/dist/index.js +7 -7
  84. package/dist/tracing.js +2 -2
  85. package/dist/workers.d.ts +2 -2
  86. package/dist/workers.js +4 -3
  87. package/package.json +2 -4
  88. package/src/auth.test.ts +128 -0
  89. package/src/auth.ts +67 -64
  90. package/src/bpmn.ts +133 -46
  91. package/src/dmn.ts +0 -19
  92. package/src/generated/RawClient.ts +1 -1
  93. package/src/generated/core/OpenAPI.ts +1 -1
  94. package/src/generated/index.ts +9 -3
  95. package/src/generated/models/BpmnActivityState.ts +90 -0
  96. package/src/generated/models/BpmnElementStatistics.ts +41 -0
  97. package/src/generated/models/BpmnExternalJobPaginatedResponse.ts +2 -2
  98. package/src/generated/models/BpmnHistoryPage.ts +20 -0
  99. package/src/generated/models/BpmnIncident.ts +11 -17
  100. package/src/generated/models/BpmnIncidentRecord.ts +7 -13
  101. package/src/generated/models/BpmnIncidentRecordPaginatedResponse.ts +2 -2
  102. package/src/generated/models/BpmnInstance.ts +14 -29
  103. package/src/generated/models/BpmnInstancePaginatedResponse.ts +2 -2
  104. package/src/generated/models/BpmnInstanceState.ts +31 -14
  105. package/src/generated/models/BpmnInstanceStatus.ts +14 -0
  106. package/src/generated/models/BpmnProcessDefinition.ts +5 -5
  107. package/src/generated/models/BpmnProcessVersion.ts +9 -9
  108. package/src/generated/models/BpmnUserTaskPaginatedResponse.ts +2 -2
  109. package/src/generated/models/CorrelationKeys.ts +7 -6
  110. package/src/generated/models/CreateDefinitionRequest.ts +1 -5
  111. package/src/generated/models/CursorPage.ts +17 -0
  112. package/src/generated/models/DecisionKind.ts +14 -0
  113. package/src/generated/models/DecisionSummary.ts +8 -6
  114. package/src/generated/models/DecisionVersion.ts +30 -0
  115. package/src/generated/models/DecisionVersionList.ts +12 -0
  116. package/src/generated/models/Definition.ts +16 -8
  117. package/src/generated/models/Error.ts +4 -4
  118. package/src/generated/models/EvaluateStoredRequest.ts +5 -6
  119. package/src/generated/models/EvaluationResult.ts +6 -0
  120. package/src/generated/models/Execution.ts +37 -9
  121. package/src/generated/models/ExternalJob.ts +8 -8
  122. package/src/generated/models/HitRule.ts +4 -0
  123. package/src/generated/models/PaginatedExecutionsResponse.ts +2 -2
  124. package/src/generated/models/StartBpmnInstanceRequest.ts +6 -2
  125. package/src/generated/models/SuspendBpmnInstanceRequest.ts +1 -1
  126. package/src/generated/models/UpdateDefinitionRequest.ts +1 -5
  127. package/src/generated/models/UserTask.ts +15 -11
  128. package/src/generated/services/BpmnService.ts +333 -142
  129. package/src/generated/services/DefaultService.ts +160 -198
  130. package/src/index.test.ts +74 -31
  131. package/src/index.ts +13 -7
  132. package/src/tracing.ts +1 -1
  133. package/src/workers.test.ts +2 -3
  134. package/src/workers.ts +5 -4
  135. package/dist/generated/models/BpmnInstanceChildrenResponse.d.ts +0 -7
  136. package/dist/generated/models/BpmnInstanceChildrenResponse.js +0 -3
  137. package/dist/generated/models/CreateProjectRequest.d.ts +0 -9
  138. package/dist/generated/models/CreateProjectRequest.js +0 -3
  139. package/src/generated/models/BpmnInstanceChildrenResponse.ts +0 -12
  140. package/src/generated/models/CreateProjectRequest.ts +0 -14
package/src/auth.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  /**
2
- * Authentication helpers. Provides the TokenProvider interface plus two
3
- * implementations:
4
- *
5
- * - ZitadelTokenProvider: service-account JWT-bearer flow against Zitadel,
6
- * with in-memory token caching.
7
- * - StaticTokenProvider: returns the same bearer token on every call.
2
+ * Authentication helpers: the TokenProvider interface, ClientCredentialsTokenProvider
3
+ * for any OIDC provider, and StaticTokenProvider for a fixed bearer token.
8
4
  */
9
- import * as fs from 'fs';
10
- import * as jwt from 'jsonwebtoken';
11
5
  import axios from 'axios';
12
6
 
13
7
  import { RawClient } from './generated/RawClient';
@@ -26,79 +20,88 @@ export class StaticTokenProvider implements TokenProvider {
26
20
  }
27
21
  }
28
22
 
29
- interface ZitadelKeyFile {
30
- userId: string;
31
- keyId: string;
32
- key: string;
23
+ /** Options for ClientCredentialsTokenProvider. */
24
+ export interface ClientCredentialsOptions {
25
+ /** The identity provider's OAuth 2.0 token endpoint. */
26
+ tokenUrl: string;
27
+ clientId: string;
28
+ clientSecret: string;
29
+ /** Sent space-joined as the `scope` parameter. Empty sends none. */
30
+ scopes?: string[];
31
+ /** Sent as the `audience` parameter when set. Some providers, such as Auth0, require it. */
32
+ audience?: string;
33
33
  }
34
34
 
35
+ const REFRESH_MARGIN_MS = 60_000;
36
+ const DEFAULT_LIFETIME_S = 300;
37
+
35
38
  /**
36
- * Authenticates against Zitadel using a service-account JSON Key file via the
37
- * JWT Profile (`urn:ietf:params:oauth:grant-type:jwt-bearer`) grant. Tokens
38
- * are cached until shortly before expiry.
39
+ * Fetches access tokens from any OIDC provider with the OAuth 2.0 client
40
+ * credentials grant. The token is cached until less than 60 seconds of its
41
+ * lifetime remain, and parallel callers share one in-flight request.
39
42
  */
40
- export class ZitadelTokenProvider implements TokenProvider {
43
+ export class ClientCredentialsTokenProvider implements TokenProvider {
41
44
  private accessToken: string | null = null;
42
45
  private expiresAt = 0;
43
- private readonly keyData: ZitadelKeyFile;
44
- private readonly issuer: string;
45
- private readonly scopes: string[];
46
-
47
- /**
48
- * @param keyFile Path to the service-account JSON Key file from Zitadel.
49
- * @param issuer Zitadel instance base URL (e.g. https://auth.quantumbpm.com).
50
- * @param projectId Zitadel project ID. When provided, adds the audience
51
- * scope so issued tokens are accepted by the API.
52
- */
53
- constructor(keyFile: string, issuer: string, projectId?: string) {
54
- const content = fs.readFileSync(keyFile, 'utf-8');
55
- this.keyData = JSON.parse(content) as ZitadelKeyFile;
56
- this.issuer = issuer.replace(/\/$/, '');
46
+ private inFlight: Promise<string> | null = null;
57
47
 
58
- const scopes = [
59
- 'openid',
60
- 'profile',
61
- 'urn:zitadel:iam:user:resourceowner',
62
- 'urn:zitadel:iam:org:projects:roles',
63
- ];
64
- if (projectId) {
65
- scopes.push(`urn:zitadel:iam:org:project:id:${projectId}:aud`);
48
+ constructor(private readonly options: ClientCredentialsOptions) {
49
+ if (!options.tokenUrl || !options.clientId || !options.clientSecret) {
50
+ throw new Error('quantumbpm: tokenUrl, clientId and clientSecret are required');
66
51
  }
67
- this.scopes = scopes;
68
52
  }
69
53
 
70
54
  async getToken(): Promise<string> {
71
- if (this.accessToken && Date.now() < this.expiresAt - 60_000) {
55
+ if (this.accessToken && Date.now() < this.expiresAt - REFRESH_MARGIN_MS) {
72
56
  return this.accessToken;
73
57
  }
58
+ if (!this.inFlight) {
59
+ this.inFlight = this.fetchToken().finally(() => {
60
+ this.inFlight = null;
61
+ });
62
+ }
63
+ return this.inFlight;
64
+ }
74
65
 
75
- const now = Math.floor(Date.now() / 1000);
76
- const assertion = jwt.sign(
77
- {
78
- iss: this.keyData.userId,
79
- sub: this.keyData.userId,
80
- aud: this.issuer,
81
- iat: now,
82
- exp: now + 3600,
83
- },
84
- this.keyData.key,
85
- { algorithm: 'RS256', keyid: this.keyData.keyId },
86
- );
66
+ private async fetchToken(): Promise<string> {
67
+ const { tokenUrl, clientId, clientSecret, scopes, audience } = this.options;
68
+ const form = new URLSearchParams({
69
+ grant_type: 'client_credentials',
70
+ client_id: clientId,
71
+ client_secret: clientSecret,
72
+ });
73
+ if (scopes && scopes.length > 0) form.set('scope', scopes.join(' '));
74
+ if (audience) form.set('audience', audience);
87
75
 
88
- const response = await axios.post(
89
- `${this.issuer}/oauth/v2/token`,
90
- new URLSearchParams({
91
- grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
92
- scope: this.scopes.join(' '),
93
- assertion,
94
- }),
95
- {
96
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
76
+ const requestedAt = Date.now();
77
+ const response = await axios.post<string>(tokenUrl, form.toString(), {
78
+ headers: {
79
+ 'Content-Type': 'application/x-www-form-urlencoded',
80
+ Accept: 'application/json',
97
81
  },
98
- );
82
+ responseType: 'text',
83
+ validateStatus: () => true,
84
+ });
85
+ if (response.status < 200 || response.status > 299) {
86
+ throw new Error(`quantumbpm: token request failed (${response.status}): ${response.data}`);
87
+ }
88
+
89
+ let body: { access_token?: unknown; expires_in?: unknown };
90
+ try {
91
+ body = JSON.parse(response.data);
92
+ } catch {
93
+ throw new Error(`quantumbpm: token response is not JSON: ${response.data}`);
94
+ }
95
+ if (typeof body.access_token !== 'string' || !body.access_token) {
96
+ throw new Error('quantumbpm: token response has no access_token');
97
+ }
98
+ const expiresIn = body.expires_in == null ? DEFAULT_LIFETIME_S : Number(body.expires_in);
99
+ if (!Number.isFinite(expiresIn)) {
100
+ throw new Error(`quantumbpm: token response has an invalid expires_in: ${body.expires_in}`);
101
+ }
99
102
 
100
- this.accessToken = response.data.access_token as string;
101
- this.expiresAt = Date.now() + (response.data.expires_in as number) * 1000;
103
+ this.accessToken = body.access_token;
104
+ this.expiresAt = requestedAt + expiresIn * 1000;
102
105
  return this.accessToken;
103
106
  }
104
107
  }
package/src/bpmn.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { RawClient } from './generated/RawClient';
2
+ import { BpmnActivityState } from './generated/models/BpmnActivityState';
3
+ import { BpmnHistoryPage } from './generated/models/BpmnHistoryPage';
2
4
  import { BpmnInstancePaginatedResponse } from './generated/models/BpmnInstancePaginatedResponse';
3
- import { BpmnInstanceChildrenResponse } from './generated/models/BpmnInstanceChildrenResponse';
4
5
  import { BpmnInstanceState } from './generated/models/BpmnInstanceState';
5
6
  import { BpmnProcessSummaryPaginatedResponse } from './generated/models/BpmnProcessSummaryPaginatedResponse';
7
+ import { BpmnProcessVersion } from './generated/models/BpmnProcessVersion';
6
8
  import { BpmnProcessVersionPaginatedResponse } from './generated/models/BpmnProcessVersionPaginatedResponse';
7
9
  import { BpmnResourceDetail } from './generated/models/BpmnResourceDetail';
8
10
  import { BpmnResourcePaginatedResponse } from './generated/models/BpmnResourcePaginatedResponse';
@@ -17,10 +19,12 @@ import { Vars } from './variables';
17
19
 
18
20
  /** Re-exported entity types so callers don't depend on the generated package. */
19
21
  export type {
22
+ BpmnActivityState,
23
+ BpmnHistoryPage,
20
24
  BpmnInstancePaginatedResponse,
21
- BpmnInstanceChildrenResponse,
22
25
  BpmnInstanceState,
23
26
  BpmnProcessSummaryPaginatedResponse,
27
+ BpmnProcessVersion,
24
28
  BpmnProcessVersionPaginatedResponse,
25
29
  BpmnResourceDetail,
26
30
  BpmnResourcePaginatedResponse,
@@ -37,11 +41,20 @@ export interface PageOptions {
37
41
  pageSize?: number;
38
42
  }
39
43
 
40
- export interface InstanceListOptions extends PageOptions {
41
- definitionId?: string;
42
- /** Instances of every version of this process id. */
44
+ /** Paging of a list the API pages by cursor. */
45
+ export interface CursorOptions {
46
+ /** The `pagination.nextCursor` of the page before, omitted for the first page. */
47
+ cursor?: string;
48
+ /** Most rows per page, 20 by default and 100 at most. */
49
+ limit?: number;
50
+ }
51
+
52
+ export interface InstanceListOptions extends CursorOptions {
53
+ /** Instances of every version of this process id, unless `version` names one. */
43
54
  processId?: string;
44
- status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED' | 'TERMINATED' | 'TIMED_OUT';
55
+ /** Instances of this version of `processId`. Ignored without `processId`. */
56
+ version?: number;
57
+ status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED' | 'TERMINATED';
45
58
  /**
46
59
  * Filter by incident presence. `true` shows only instances that
47
60
  * need operator attention; `false` excludes them; omit for all.
@@ -62,10 +75,26 @@ export interface InstanceListOptions extends PageOptions {
62
75
  * at startInstance time.
63
76
  */
64
77
  businessId?: string;
78
+ /** `true` keeps only test runs, `false` leaves them out. Omit for both. */
79
+ draft?: boolean;
80
+ }
81
+
82
+ /** The due date range and order of a user task list. */
83
+ export interface UserTaskScheduleOptions extends CursorOptions {
84
+ /** Tasks due at or after this time (RFC 3339). */
85
+ dueAfter?: string;
86
+ /** Tasks due before this time (RFC 3339). With `status: 'CREATED'` and now, the overdue tasks. */
87
+ dueBefore?: string;
88
+ /**
89
+ * `created` lists the newest first, the default. `dueDate` lists the
90
+ * soonest due first, `priority` the highest priority first. A cursor
91
+ * continues only a list of the same sort.
92
+ */
93
+ sort?: 'created' | 'dueDate' | 'priority';
65
94
  }
66
95
 
67
- export interface UserTaskListOptions extends PageOptions {
68
- workflowId?: string;
96
+ export interface UserTaskListOptions extends UserTaskScheduleOptions {
97
+ instanceId?: string;
69
98
  status?: 'CREATED' | 'COMPLETED' | 'CANCELED' | 'FAILED';
70
99
  assignee?: string;
71
100
  candidateUser?: string;
@@ -84,6 +113,18 @@ export interface StartInstanceOptions {
84
113
  * DMN execution emitted by the resulting process.
85
114
  */
86
115
  businessId?: string;
116
+ /** Deployed version to start, the latest when omitted. startTestInstance ignores it. */
117
+ version?: number;
118
+ }
119
+
120
+ /** Which window of an instance's history to read. Omit both seqs for the newest entries. */
121
+ export interface HistoryOptions {
122
+ /** Read the entries from this seq on, to follow a running instance. Takes precedence over `beforeSeq`. */
123
+ fromSeq?: number;
124
+ /** Read the newest entries before this seq, to walk back. */
125
+ beforeSeq?: number;
126
+ /** Most entries per page. */
127
+ limit?: number;
87
128
  }
88
129
 
89
130
  export interface ProcessListOptions extends PageOptions {
@@ -142,9 +183,9 @@ export class BpmnClient {
142
183
  }
143
184
 
144
185
  /**
145
- * Promote a draft to a deployed process definition. After this returns,
146
- * the resource's `processes` field is populated and StartInstance can
147
- * reference the resulting process definition IDs.
186
+ * Deploy a draft. After this returns, the resource's `processes` field
187
+ * lists the process versions it deployed, and startInstance can start
188
+ * them by process ID.
148
189
  */
149
190
  async deployResource(resourceId: string): Promise<void> {
150
191
  await this.raw.bpmn.deployBpmnResource(this.projectId, resourceId);
@@ -157,10 +198,10 @@ export class BpmnClient {
157
198
  variables: vars.toWireMap() as any,
158
199
  businessId: opts.businessId,
159
200
  });
160
- if (!resp.workflowID) {
161
- throw new Error('bpmn: startTestInstance returned no workflowID');
201
+ if (!resp.instanceID) {
202
+ throw new Error('bpmn: startTestInstance returned no instanceID');
162
203
  }
163
- return resp.workflowID;
204
+ return resp.instanceID;
164
205
  }
165
206
 
166
207
  /** Lint a BPMN XML document without storing or deploying it. */
@@ -185,69 +226,96 @@ export class BpmnClient {
185
226
 
186
227
  // --- Instances ----------------------------------------------------------
187
228
 
188
- /** Launch a new instance. Returns the workflowID. */
189
- async startInstance(processDefinitionId: string, vars: Vars, opts: StartInstanceOptions = {}): Promise<string> {
229
+ /**
230
+ * Launch a new instance of a deployed process, its latest version unless
231
+ * `opts.version` names one. Returns the instance ID.
232
+ */
233
+ async startInstance(processId: string, vars: Vars, opts: StartInstanceOptions = {}): Promise<string> {
190
234
  const resp = await this.raw.default.startBpmnInstance(this.projectId, {
191
- processDefinitionID: processDefinitionId,
235
+ processID: processId,
236
+ version: opts.version,
192
237
  variables: vars.toWireMap() as any,
193
238
  businessId: opts.businessId,
194
239
  });
195
- if (!resp.workflowID) {
196
- throw new Error('bpmn: startInstance returned no workflowID');
240
+ if (!resp.instanceID) {
241
+ throw new Error('bpmn: startInstance returned no instanceID');
197
242
  }
198
- return resp.workflowID;
243
+ return resp.instanceID;
199
244
  }
200
245
 
201
246
  /** Full runtime state of an instance. */
202
- async getInstance(workflowId: string): Promise<BpmnInstanceState> {
203
- return this.raw.default.getBpmnInstance(this.projectId, workflowId);
247
+ async getInstance(instanceId: string): Promise<BpmnInstanceState> {
248
+ return this.raw.default.getBpmnInstance(this.projectId, instanceId);
204
249
  }
205
250
 
206
251
  /** Terminate a running instance. */
207
- async cancelInstance(workflowId: string): Promise<void> {
208
- await this.raw.default.cancelBpmnInstance(this.projectId, workflowId);
252
+ async cancelInstance(instanceId: string): Promise<void> {
253
+ await this.raw.default.cancelBpmnInstance(this.projectId, instanceId);
209
254
  }
210
255
 
211
- /** Page of instances in the project. */
256
+ /**
257
+ * Page of instances in the project, newest first. Pass the page's
258
+ * `pagination.nextCursor` as `cursor` for the next one. It is absent on
259
+ * the last page.
260
+ */
212
261
  async listInstances(opts: InstanceListOptions = {}): Promise<BpmnInstancePaginatedResponse> {
213
- // Generated signature order: (projectId, definitionId, status,
214
- // hasIncident, suspended, createdAfter, businessId, processId, page,
215
- // pageSize). Positional call - keep the order in sync with the regenerated client.
262
+ // Generated signature order: (projectId, status, hasIncident,
263
+ // suspended, createdAfter, businessId, processId, version, draft,
264
+ // cursor, limit). Positional call - keep the order in sync with the regenerated client.
216
265
  return this.raw.default.listBpmnInstances(
217
266
  this.projectId,
218
- opts.definitionId,
219
267
  opts.status,
220
268
  opts.hasIncident,
221
269
  opts.suspended,
222
270
  opts.createdAfter,
223
271
  opts.businessId,
224
272
  opts.processId,
225
- opts.page,
226
- opts.pageSize,
273
+ opts.version,
274
+ opts.draft,
275
+ opts.cursor,
276
+ opts.limit,
227
277
  );
228
278
  }
229
279
 
230
- /** Children spawned via CallActivity. */
231
- async getInstanceChildren(workflowId: string): Promise<BpmnInstanceChildrenResponse> {
232
- return this.raw.bpmn.getBpmnInstanceChildren(this.projectId, workflowId);
280
+ /**
281
+ * Page of the instances this instance spawned via CallActivity, newest
282
+ * first. Pass the page's `pagination.nextCursor` as `cursor` for the next
283
+ * one. It is absent on the last page.
284
+ */
285
+ async getInstanceChildren(instanceId: string, opts: CursorOptions = {}): Promise<BpmnInstancePaginatedResponse> {
286
+ return this.raw.bpmn.getBpmnInstanceChildren(this.projectId, instanceId, opts.cursor, opts.limit);
287
+ }
288
+
289
+ /**
290
+ * Page of an instance's history, oldest first, for a running or an ended
291
+ * instance. Page entries leave out `inputs` and `outputs`, which
292
+ * getInstanceHistoryEntry() reads.
293
+ */
294
+ async getInstanceHistory(instanceId: string, opts: HistoryOptions = {}): Promise<BpmnHistoryPage> {
295
+ return this.raw.bpmn.getBpmnInstanceHistory(this.projectId, instanceId, opts.fromSeq, opts.beforeSeq, opts.limit);
296
+ }
297
+
298
+ /** One history entry with its inputs and outputs. */
299
+ async getInstanceHistoryEntry(instanceId: string, seq: number): Promise<BpmnActivityState> {
300
+ return this.raw.bpmn.getBpmnInstanceHistoryEntry(this.projectId, instanceId, seq);
233
301
  }
234
302
 
235
303
  /** Current variables of an instance. */
236
- async getInstanceVariables(workflowId: string): Promise<Vars> {
237
- const resp = await this.raw.bpmn.getBpmnInstanceVariables(this.projectId, workflowId);
304
+ async getInstanceVariables(instanceId: string): Promise<Vars> {
305
+ const resp = await this.raw.bpmn.getBpmnInstanceVariables(this.projectId, instanceId);
238
306
  return Vars.fromWireMap(resp.variables);
239
307
  }
240
308
 
241
309
  /** Merge variables into the instance scope. */
242
- async updateInstanceVariables(workflowId: string, vars: Vars): Promise<void> {
243
- await this.raw.bpmn.updateBpmnInstanceVariables(this.projectId, workflowId, {
310
+ async updateInstanceVariables(instanceId: string, vars: Vars): Promise<void> {
311
+ await this.raw.bpmn.updateBpmnInstanceVariables(this.projectId, instanceId, {
244
312
  variables: (vars.toWireMap() ?? {}) as any,
245
313
  });
246
314
  }
247
315
 
248
316
  /** Resolve an incident, optionally merging supplementary variables. */
249
- async resolveIncident(workflowId: string, incidentId: string, vars: Vars = new Vars()): Promise<void> {
250
- await this.raw.bpmn.resolveBpmnIncident(this.projectId, workflowId, incidentId, {
317
+ async resolveIncident(instanceId: string, incidentId: string, vars: Vars = new Vars()): Promise<void> {
318
+ await this.raw.bpmn.resolveBpmnIncident(this.projectId, instanceId, incidentId, {
251
319
  variables: vars.toWireMap() as any,
252
320
  });
253
321
  }
@@ -273,23 +341,37 @@ export class BpmnClient {
273
341
 
274
342
  // --- User tasks ---------------------------------------------------------
275
343
 
344
+ /**
345
+ * Page of user tasks in the project. Pass the page's
346
+ * `pagination.nextCursor` as `cursor` for the next one.
347
+ */
276
348
  async listUserTasks(opts: UserTaskListOptions = {}): Promise<BpmnUserTaskPaginatedResponse> {
277
349
  return this.raw.bpmn.listBpmnUserTasks(
278
350
  this.projectId,
279
- opts.workflowId,
351
+ opts.instanceId,
280
352
  opts.status,
281
353
  opts.assignee,
282
354
  opts.candidateUser,
283
355
  opts.candidateGroup,
284
356
  opts.businessId,
285
- opts.page,
286
- opts.pageSize,
357
+ opts.dueAfter,
358
+ opts.dueBefore,
359
+ opts.sort,
360
+ opts.cursor,
361
+ opts.limit,
287
362
  );
288
363
  }
289
364
 
290
- /** User tasks the caller may claim or has already claimed. */
291
- async listUserTasksForCaller(opts: PageOptions = {}): Promise<BpmnUserTaskPaginatedResponse> {
292
- return this.raw.bpmn.listBpmnUserTasksForCaller(this.projectId, opts.page, opts.pageSize);
365
+ /** Page of the user tasks the caller may claim or has already claimed. */
366
+ async listUserTasksForCaller(opts: UserTaskScheduleOptions = {}): Promise<BpmnUserTaskPaginatedResponse> {
367
+ return this.raw.bpmn.listBpmnUserTasksForCaller(
368
+ this.projectId,
369
+ opts.dueAfter,
370
+ opts.dueBefore,
371
+ opts.sort,
372
+ opts.cursor,
373
+ opts.limit,
374
+ );
293
375
  }
294
376
 
295
377
  async getUserTask(executionKey: string): Promise<UserTask> {
@@ -334,4 +416,9 @@ export class BpmnClient {
334
416
  opts.createdAfter,
335
417
  );
336
418
  }
419
+
420
+ /** One deployed version of a process id with its instance counts and suspension state. */
421
+ async getProcessVersion(processId: string, version: number, opts: { createdAfter?: string } = {}): Promise<BpmnProcessVersion> {
422
+ return this.raw.bpmn.getBpmnProcessVersion(this.projectId, processId, version, opts.createdAfter);
423
+ }
337
424
  }
package/src/dmn.ts CHANGED
@@ -66,25 +66,6 @@ export class DmnClient {
66
66
  );
67
67
  }
68
68
 
69
- /**
70
- * Run a stored DMN definition addressed by its platform UUID. Prefer
71
- * evaluate() (by definitions ID) for normal use; this overload is for
72
- * callers that already hold a specific version pointer.
73
- */
74
- async evaluateById(
75
- definitionId: string,
76
- vars: Vars,
77
- opts: EvaluateOptions = {},
78
- ): Promise<DmnResult> {
79
- return this.raw.default.evaluateStored(this.projectId, definitionId, {
80
- context: vars.toFeelContext(),
81
- version: opts.version,
82
- decisions: opts.decisions,
83
- decisionServices: opts.decisionServices,
84
- businessId: opts.businessId,
85
- });
86
- }
87
-
88
69
  /** Run ad-hoc DMN XML against an input context. The XML is not stored. */
89
70
  async evaluateDesign(
90
71
  xml: string,
@@ -15,7 +15,7 @@ export class RawClient {
15
15
  constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = AxiosHttpRequest) {
16
16
  this.request = new HttpRequest({
17
17
  BASE: config?.BASE ?? '',
18
- VERSION: config?.VERSION ?? '1.8.0',
18
+ VERSION: config?.VERSION ?? '2.1.0',
19
19
  WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
20
20
  CREDENTIALS: config?.CREDENTIALS ?? 'include',
21
21
  TOKEN: config?.TOKEN,
@@ -21,7 +21,7 @@ export type OpenAPIConfig = {
21
21
 
22
22
  export const OpenAPI: OpenAPIConfig = {
23
23
  BASE: '',
24
- VERSION: '1.8.0',
24
+ VERSION: '2.1.0',
25
25
  WITH_CREDENTIALS: false,
26
26
  CREDENTIALS: 'include',
27
27
  TOKEN: undefined,
@@ -13,14 +13,17 @@ export type { OpenAPIConfig } from './core/OpenAPI';
13
13
  export type { ActiveScope } from './models/ActiveScope';
14
14
  export type { BatchEvaluateDesignRequest } from './models/BatchEvaluateDesignRequest';
15
15
  export type { BatchEvaluationResponse } from './models/BatchEvaluationResponse';
16
+ export { BpmnActivityState } from './models/BpmnActivityState';
17
+ export { BpmnElementStatistics } from './models/BpmnElementStatistics';
16
18
  export type { BpmnExternalJobPaginatedResponse } from './models/BpmnExternalJobPaginatedResponse';
19
+ export type { BpmnHistoryPage } from './models/BpmnHistoryPage';
17
20
  export { BpmnIncident } from './models/BpmnIncident';
18
21
  export { BpmnIncidentRecord } from './models/BpmnIncidentRecord';
19
22
  export type { BpmnIncidentRecordPaginatedResponse } from './models/BpmnIncidentRecordPaginatedResponse';
20
- export { BpmnInstance } from './models/BpmnInstance';
21
- export type { BpmnInstanceChildrenResponse } from './models/BpmnInstanceChildrenResponse';
23
+ export type { BpmnInstance } from './models/BpmnInstance';
22
24
  export type { BpmnInstancePaginatedResponse } from './models/BpmnInstancePaginatedResponse';
23
25
  export type { BpmnInstanceState } from './models/BpmnInstanceState';
26
+ export { BpmnInstanceStatus } from './models/BpmnInstanceStatus';
24
27
  export type { BpmnProcessDefinition } from './models/BpmnProcessDefinition';
25
28
  export type { BpmnProcessSummary } from './models/BpmnProcessSummary';
26
29
  export type { BpmnProcessSummaryPaginatedResponse } from './models/BpmnProcessSummaryPaginatedResponse';
@@ -41,9 +44,12 @@ export type { CorrelationKeys } from './models/CorrelationKeys';
41
44
  export type { CorrelationKeyString } from './models/CorrelationKeyString';
42
45
  export type { CreateBpmnResourceRequest } from './models/CreateBpmnResourceRequest';
43
46
  export type { CreateDefinitionRequest } from './models/CreateDefinitionRequest';
44
- export type { CreateProjectRequest } from './models/CreateProjectRequest';
47
+ export type { CursorPage } from './models/CursorPage';
45
48
  export type { DecisionInputField } from './models/DecisionInputField';
49
+ export { DecisionKind } from './models/DecisionKind';
46
50
  export type { DecisionSummary } from './models/DecisionSummary';
51
+ export type { DecisionVersion } from './models/DecisionVersion';
52
+ export type { DecisionVersionList } from './models/DecisionVersionList';
47
53
  export type { Definition } from './models/Definition';
48
54
  export type { ElementMapping } from './models/ElementMapping';
49
55
  export { Error } from './models/Error';
@@ -0,0 +1,90 @@
1
+ /* generated using openapi-typescript-codegen -- do not edit */
2
+ /* istanbul ignore file */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /**
6
+ * Execution record for a single BPMN activity (service task, user task, gateway, etc.).
7
+ */
8
+ export type BpmnActivityState = {
9
+ /**
10
+ * Position of the entry in the instance's history, from 1.
11
+ */
12
+ seq?: number;
13
+ /**
14
+ * ID of the BPMN flow node.
15
+ */
16
+ nodeID?: string;
17
+ /**
18
+ * Type of the BPMN node (e.g. ServiceTask, UserTask, ExclusiveGateway).
19
+ */
20
+ nodeType?: string;
21
+ /**
22
+ * Execution outcome - Started, Completed, Failed, Canceled, or Resolved. `Resolved` replaces `Failed` once the originating incident is removed (retry, modification-cancel, boundary catch); the entry's `errorMessage` is preserved so the failed attempt remains auditable.
23
+ */
24
+ status?: BpmnActivityState.status;
25
+ /**
26
+ * When the element started. Each entry records one event, so a Started entry carries it and a Completed, Failed, Canceled or Resolved entry leaves it out. An entry for an operation, such as a suspension or a migration, carries both times. Entries are ordered by `seq`, not by time.
27
+ */
28
+ startTime?: string;
29
+ /**
30
+ * When the element ended. Absent on a Started entry.
31
+ */
32
+ endTime?: string;
33
+ /**
34
+ * Input variables evaluated at activity entry. Absent on history page entries.
35
+ */
36
+ inputs?: Record<string, any>;
37
+ /**
38
+ * Output variables produced by the activity. Absent on history page entries.
39
+ */
40
+ outputs?: Record<string, any>;
41
+ /**
42
+ * Failure reason on Failed / Canceled / Resolved entries. Empty on success paths.
43
+ */
44
+ errorMessage?: string;
45
+ /**
46
+ * BPMN `errorCode` of the throw error that caused the failure. Set on Failed/Resolved entries originating from a BPMN error; empty for non-BPMN failures. Error variables (if any) ride on `outputs` since a Failed entry doesn't otherwise produce outputs.
47
+ */
48
+ errorCode?: string;
49
+ /**
50
+ * Key of the element's execution, the same on its Started and its ending entry. Absent for an element that runs no execution, such as a start or end event.
51
+ */
52
+ executionKey?: string;
53
+ /**
54
+ * User or service account whose call produced this entry: the completion of a job or user task, the publish of a message or signal a catch took, a start, a resolve, a suspension or a cancel. Empty for an entry the engine produced on its own.
55
+ */
56
+ actor?: string;
57
+ /**
58
+ * Task type of the external job this entry ended, on the Completed, Failed or Canceled entry of a job's element. Empty otherwise.
59
+ */
60
+ taskType?: string;
61
+ /**
62
+ * Retries the external job had left when a worker or a lock expiry reported its outcome. Absent on a job the engine canceled.
63
+ */
64
+ retries?: number;
65
+ /**
66
+ * `clientID` of the worker that reported the external job's outcome, or whose lock ran out. Empty when no worker was named.
67
+ */
68
+ worker?: string;
69
+ /**
70
+ * For CallActivity nodes, the identifier of the child instance spawned by this execution. Empty for non-CallActivity nodes.
71
+ */
72
+ childInstanceID?: string;
73
+ /**
74
+ * IDs of the sequence flows that brought the token to this element, on its first entry (Started, or Completed for an element without duration). A join firing lists every flow it consumed, a join cancelled before it fired lists the flows that had reached it. A flow is taken when some entry lists it, together with `pendingJoinArrivals` on the instance state.
75
+ */
76
+ incomingFlows?: Array<string>;
77
+ };
78
+ export namespace BpmnActivityState {
79
+ /**
80
+ * Execution outcome - Started, Completed, Failed, Canceled, or Resolved. `Resolved` replaces `Failed` once the originating incident is removed (retry, modification-cancel, boundary catch); the entry's `errorMessage` is preserved so the failed attempt remains auditable.
81
+ */
82
+ export enum status {
83
+ STARTED = 'Started',
84
+ COMPLETED = 'Completed',
85
+ FAILED = 'Failed',
86
+ CANCELED = 'Canceled',
87
+ RESOLVED = 'Resolved',
88
+ }
89
+ }
90
+