@quantumbpm/sdk 1.3.0 → 2.0.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 (128) 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 +81 -21
  5. package/dist/bpmn.js +61 -33
  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 +8 -2
  11. package/dist/generated/index.js +8 -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/DecisionSummary.d.ts +2 -2
  47. package/dist/generated/models/DecisionSummary.js +1 -1
  48. package/dist/generated/models/DecisionVersion.d.ts +25 -0
  49. package/dist/generated/models/DecisionVersion.js +3 -0
  50. package/dist/generated/models/DecisionVersionList.d.ts +7 -0
  51. package/dist/generated/models/DecisionVersionList.js +3 -0
  52. package/dist/generated/models/Definition.d.ts +16 -8
  53. package/dist/generated/models/Definition.js +1 -1
  54. package/dist/generated/models/Error.d.ts +4 -4
  55. package/dist/generated/models/Error.js +3 -3
  56. package/dist/generated/models/EvaluateStoredRequest.d.ts +5 -6
  57. package/dist/generated/models/EvaluateStoredRequest.js +1 -1
  58. package/dist/generated/models/EvaluationResult.d.ts +6 -0
  59. package/dist/generated/models/EvaluationResult.js +1 -1
  60. package/dist/generated/models/Execution.d.ts +30 -9
  61. package/dist/generated/models/Execution.js +1 -1
  62. package/dist/generated/models/ExternalJob.d.ts +8 -8
  63. package/dist/generated/models/ExternalJob.js +1 -1
  64. package/dist/generated/models/StartBpmnInstanceRequest.d.ts +6 -2
  65. package/dist/generated/models/StartBpmnInstanceRequest.js +1 -1
  66. package/dist/generated/models/SuspendBpmnInstanceRequest.d.ts +1 -1
  67. package/dist/generated/models/SuspendBpmnInstanceRequest.js +1 -1
  68. package/dist/generated/models/UpdateDefinitionRequest.d.ts +1 -5
  69. package/dist/generated/models/UpdateDefinitionRequest.js +1 -1
  70. package/dist/generated/models/UserTask.d.ts +15 -11
  71. package/dist/generated/models/UserTask.js +1 -1
  72. package/dist/generated/services/BpmnService.d.ts +183 -87
  73. package/dist/generated/services/BpmnService.js +267 -121
  74. package/dist/generated/services/DefaultService.d.ts +106 -113
  75. package/dist/generated/services/DefaultService.js +127 -164
  76. package/dist/index.d.ts +8 -8
  77. package/dist/index.js +7 -7
  78. package/dist/tracing.js +2 -2
  79. package/dist/workers.d.ts +2 -2
  80. package/dist/workers.js +4 -3
  81. package/package.json +2 -4
  82. package/src/auth.test.ts +128 -0
  83. package/src/auth.ts +67 -64
  84. package/src/bpmn.ts +128 -43
  85. package/src/dmn.ts +0 -19
  86. package/src/generated/RawClient.ts +1 -1
  87. package/src/generated/core/OpenAPI.ts +1 -1
  88. package/src/generated/index.ts +8 -2
  89. package/src/generated/models/BpmnActivityState.ts +90 -0
  90. package/src/generated/models/BpmnElementStatistics.ts +41 -0
  91. package/src/generated/models/BpmnExternalJobPaginatedResponse.ts +2 -2
  92. package/src/generated/models/BpmnHistoryPage.ts +20 -0
  93. package/src/generated/models/BpmnIncident.ts +11 -17
  94. package/src/generated/models/BpmnIncidentRecord.ts +7 -13
  95. package/src/generated/models/BpmnIncidentRecordPaginatedResponse.ts +2 -2
  96. package/src/generated/models/BpmnInstance.ts +14 -29
  97. package/src/generated/models/BpmnInstancePaginatedResponse.ts +2 -2
  98. package/src/generated/models/BpmnInstanceState.ts +31 -14
  99. package/src/generated/models/BpmnInstanceStatus.ts +14 -0
  100. package/src/generated/models/BpmnProcessDefinition.ts +5 -5
  101. package/src/generated/models/BpmnProcessVersion.ts +9 -9
  102. package/src/generated/models/BpmnUserTaskPaginatedResponse.ts +2 -2
  103. package/src/generated/models/CorrelationKeys.ts +7 -6
  104. package/src/generated/models/CreateDefinitionRequest.ts +1 -5
  105. package/src/generated/models/CursorPage.ts +17 -0
  106. package/src/generated/models/DecisionSummary.ts +2 -2
  107. package/src/generated/models/DecisionVersion.ts +30 -0
  108. package/src/generated/models/DecisionVersionList.ts +12 -0
  109. package/src/generated/models/Definition.ts +16 -8
  110. package/src/generated/models/Error.ts +4 -4
  111. package/src/generated/models/EvaluateStoredRequest.ts +5 -6
  112. package/src/generated/models/EvaluationResult.ts +6 -0
  113. package/src/generated/models/Execution.ts +30 -9
  114. package/src/generated/models/ExternalJob.ts +8 -8
  115. package/src/generated/models/StartBpmnInstanceRequest.ts +6 -2
  116. package/src/generated/models/SuspendBpmnInstanceRequest.ts +1 -1
  117. package/src/generated/models/UpdateDefinitionRequest.ts +1 -5
  118. package/src/generated/models/UserTask.ts +15 -11
  119. package/src/generated/services/BpmnService.ts +320 -137
  120. package/src/generated/services/DefaultService.ts +147 -192
  121. package/src/index.test.ts +74 -31
  122. package/src/index.ts +13 -6
  123. package/src/tracing.ts +1 -1
  124. package/src/workers.test.ts +2 -3
  125. package/src/workers.ts +5 -4
  126. package/dist/generated/models/CreateProjectRequest.d.ts +0 -9
  127. package/dist/generated/models/CreateProjectRequest.js +0 -3
  128. 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,11 @@
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
5
  import { BpmnInstanceChildrenResponse } from './generated/models/BpmnInstanceChildrenResponse';
4
6
  import { BpmnInstanceState } from './generated/models/BpmnInstanceState';
5
7
  import { BpmnProcessSummaryPaginatedResponse } from './generated/models/BpmnProcessSummaryPaginatedResponse';
8
+ import { BpmnProcessVersion } from './generated/models/BpmnProcessVersion';
6
9
  import { BpmnProcessVersionPaginatedResponse } from './generated/models/BpmnProcessVersionPaginatedResponse';
7
10
  import { BpmnResourceDetail } from './generated/models/BpmnResourceDetail';
8
11
  import { BpmnResourcePaginatedResponse } from './generated/models/BpmnResourcePaginatedResponse';
@@ -17,10 +20,13 @@ import { Vars } from './variables';
17
20
 
18
21
  /** Re-exported entity types so callers don't depend on the generated package. */
19
22
  export type {
23
+ BpmnActivityState,
24
+ BpmnHistoryPage,
20
25
  BpmnInstancePaginatedResponse,
21
26
  BpmnInstanceChildrenResponse,
22
27
  BpmnInstanceState,
23
28
  BpmnProcessSummaryPaginatedResponse,
29
+ BpmnProcessVersion,
24
30
  BpmnProcessVersionPaginatedResponse,
25
31
  BpmnResourceDetail,
26
32
  BpmnResourcePaginatedResponse,
@@ -37,11 +43,20 @@ export interface PageOptions {
37
43
  pageSize?: number;
38
44
  }
39
45
 
40
- export interface InstanceListOptions extends PageOptions {
41
- definitionId?: string;
42
- /** Instances of every version of this process id. */
46
+ /** Paging of a list the API pages by cursor. */
47
+ export interface CursorOptions {
48
+ /** The `pagination.nextCursor` of the page before, omitted for the first page. */
49
+ cursor?: string;
50
+ /** Most rows per page, 20 by default and 100 at most. */
51
+ limit?: number;
52
+ }
53
+
54
+ export interface InstanceListOptions extends CursorOptions {
55
+ /** Instances of every version of this process id, unless `version` names one. */
43
56
  processId?: string;
44
- status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED' | 'TERMINATED' | 'TIMED_OUT';
57
+ /** Instances of this version of `processId`. Ignored without `processId`. */
58
+ version?: number;
59
+ status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED' | 'TERMINATED';
45
60
  /**
46
61
  * Filter by incident presence. `true` shows only instances that
47
62
  * need operator attention; `false` excludes them; omit for all.
@@ -62,10 +77,26 @@ export interface InstanceListOptions extends PageOptions {
62
77
  * at startInstance time.
63
78
  */
64
79
  businessId?: string;
80
+ /** `true` keeps only test runs, `false` leaves them out. Omit for both. */
81
+ draft?: boolean;
82
+ }
83
+
84
+ /** The due date range and order of a user task list. */
85
+ export interface UserTaskScheduleOptions extends CursorOptions {
86
+ /** Tasks due at or after this time (RFC 3339). */
87
+ dueAfter?: string;
88
+ /** Tasks due before this time (RFC 3339). With `status: 'CREATED'` and now, the overdue tasks. */
89
+ dueBefore?: string;
90
+ /**
91
+ * `created` lists the newest first, the default. `dueDate` lists the
92
+ * soonest due first, `priority` the highest priority first. A cursor
93
+ * continues only a list of the same sort.
94
+ */
95
+ sort?: 'created' | 'dueDate' | 'priority';
65
96
  }
66
97
 
67
- export interface UserTaskListOptions extends PageOptions {
68
- workflowId?: string;
98
+ export interface UserTaskListOptions extends UserTaskScheduleOptions {
99
+ instanceId?: string;
69
100
  status?: 'CREATED' | 'COMPLETED' | 'CANCELED' | 'FAILED';
70
101
  assignee?: string;
71
102
  candidateUser?: string;
@@ -84,6 +115,18 @@ export interface StartInstanceOptions {
84
115
  * DMN execution emitted by the resulting process.
85
116
  */
86
117
  businessId?: string;
118
+ /** Deployed version to start, the latest when omitted. startTestInstance ignores it. */
119
+ version?: number;
120
+ }
121
+
122
+ /** Which window of an instance's history to read. Omit both seqs for the newest entries. */
123
+ export interface HistoryOptions {
124
+ /** Read the entries from this seq on, to follow a running instance. Takes precedence over `beforeSeq`. */
125
+ fromSeq?: number;
126
+ /** Read the newest entries before this seq, to walk back. */
127
+ beforeSeq?: number;
128
+ /** Most entries per page. */
129
+ limit?: number;
87
130
  }
88
131
 
89
132
  export interface ProcessListOptions extends PageOptions {
@@ -142,9 +185,9 @@ export class BpmnClient {
142
185
  }
143
186
 
144
187
  /**
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.
188
+ * Deploy a draft. After this returns, the resource's `processes` field
189
+ * lists the process versions it deployed, and startInstance can start
190
+ * them by process ID.
148
191
  */
149
192
  async deployResource(resourceId: string): Promise<void> {
150
193
  await this.raw.bpmn.deployBpmnResource(this.projectId, resourceId);
@@ -157,10 +200,10 @@ export class BpmnClient {
157
200
  variables: vars.toWireMap() as any,
158
201
  businessId: opts.businessId,
159
202
  });
160
- if (!resp.workflowID) {
161
- throw new Error('bpmn: startTestInstance returned no workflowID');
203
+ if (!resp.instanceID) {
204
+ throw new Error('bpmn: startTestInstance returned no instanceID');
162
205
  }
163
- return resp.workflowID;
206
+ return resp.instanceID;
164
207
  }
165
208
 
166
209
  /** Lint a BPMN XML document without storing or deploying it. */
@@ -185,69 +228,92 @@ export class BpmnClient {
185
228
 
186
229
  // --- Instances ----------------------------------------------------------
187
230
 
188
- /** Launch a new instance. Returns the workflowID. */
189
- async startInstance(processDefinitionId: string, vars: Vars, opts: StartInstanceOptions = {}): Promise<string> {
231
+ /**
232
+ * Launch a new instance of a deployed process, its latest version unless
233
+ * `opts.version` names one. Returns the instance ID.
234
+ */
235
+ async startInstance(processId: string, vars: Vars, opts: StartInstanceOptions = {}): Promise<string> {
190
236
  const resp = await this.raw.default.startBpmnInstance(this.projectId, {
191
- processDefinitionID: processDefinitionId,
237
+ processID: processId,
238
+ version: opts.version,
192
239
  variables: vars.toWireMap() as any,
193
240
  businessId: opts.businessId,
194
241
  });
195
- if (!resp.workflowID) {
196
- throw new Error('bpmn: startInstance returned no workflowID');
242
+ if (!resp.instanceID) {
243
+ throw new Error('bpmn: startInstance returned no instanceID');
197
244
  }
198
- return resp.workflowID;
245
+ return resp.instanceID;
199
246
  }
200
247
 
201
248
  /** Full runtime state of an instance. */
202
- async getInstance(workflowId: string): Promise<BpmnInstanceState> {
203
- return this.raw.default.getBpmnInstance(this.projectId, workflowId);
249
+ async getInstance(instanceId: string): Promise<BpmnInstanceState> {
250
+ return this.raw.default.getBpmnInstance(this.projectId, instanceId);
204
251
  }
205
252
 
206
253
  /** Terminate a running instance. */
207
- async cancelInstance(workflowId: string): Promise<void> {
208
- await this.raw.default.cancelBpmnInstance(this.projectId, workflowId);
254
+ async cancelInstance(instanceId: string): Promise<void> {
255
+ await this.raw.default.cancelBpmnInstance(this.projectId, instanceId);
209
256
  }
210
257
 
211
- /** Page of instances in the project. */
258
+ /**
259
+ * Page of instances in the project, newest first. Pass the page's
260
+ * `pagination.nextCursor` as `cursor` for the next one. It is absent on
261
+ * the last page.
262
+ */
212
263
  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.
264
+ // Generated signature order: (projectId, status, hasIncident,
265
+ // suspended, createdAfter, businessId, processId, version, draft,
266
+ // cursor, limit). Positional call - keep the order in sync with the regenerated client.
216
267
  return this.raw.default.listBpmnInstances(
217
268
  this.projectId,
218
- opts.definitionId,
219
269
  opts.status,
220
270
  opts.hasIncident,
221
271
  opts.suspended,
222
272
  opts.createdAfter,
223
273
  opts.businessId,
224
274
  opts.processId,
225
- opts.page,
226
- opts.pageSize,
275
+ opts.version,
276
+ opts.draft,
277
+ opts.cursor,
278
+ opts.limit,
227
279
  );
228
280
  }
229
281
 
230
282
  /** Children spawned via CallActivity. */
231
- async getInstanceChildren(workflowId: string): Promise<BpmnInstanceChildrenResponse> {
232
- return this.raw.bpmn.getBpmnInstanceChildren(this.projectId, workflowId);
283
+ async getInstanceChildren(instanceId: string): Promise<BpmnInstanceChildrenResponse> {
284
+ return this.raw.bpmn.getBpmnInstanceChildren(this.projectId, instanceId);
285
+ }
286
+
287
+ /**
288
+ * Page of an instance's history, oldest first, for a running or an ended
289
+ * instance. Page entries leave out `inputs` and `outputs`, which
290
+ * getInstanceHistoryEntry() reads.
291
+ */
292
+ async getInstanceHistory(instanceId: string, opts: HistoryOptions = {}): Promise<BpmnHistoryPage> {
293
+ return this.raw.bpmn.getBpmnInstanceHistory(this.projectId, instanceId, opts.fromSeq, opts.beforeSeq, opts.limit);
294
+ }
295
+
296
+ /** One history entry with its inputs and outputs. */
297
+ async getInstanceHistoryEntry(instanceId: string, seq: number): Promise<BpmnActivityState> {
298
+ return this.raw.bpmn.getBpmnInstanceHistoryEntry(this.projectId, instanceId, seq);
233
299
  }
234
300
 
235
301
  /** Current variables of an instance. */
236
- async getInstanceVariables(workflowId: string): Promise<Vars> {
237
- const resp = await this.raw.bpmn.getBpmnInstanceVariables(this.projectId, workflowId);
302
+ async getInstanceVariables(instanceId: string): Promise<Vars> {
303
+ const resp = await this.raw.bpmn.getBpmnInstanceVariables(this.projectId, instanceId);
238
304
  return Vars.fromWireMap(resp.variables);
239
305
  }
240
306
 
241
307
  /** Merge variables into the instance scope. */
242
- async updateInstanceVariables(workflowId: string, vars: Vars): Promise<void> {
243
- await this.raw.bpmn.updateBpmnInstanceVariables(this.projectId, workflowId, {
308
+ async updateInstanceVariables(instanceId: string, vars: Vars): Promise<void> {
309
+ await this.raw.bpmn.updateBpmnInstanceVariables(this.projectId, instanceId, {
244
310
  variables: (vars.toWireMap() ?? {}) as any,
245
311
  });
246
312
  }
247
313
 
248
314
  /** 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, {
315
+ async resolveIncident(instanceId: string, incidentId: string, vars: Vars = new Vars()): Promise<void> {
316
+ await this.raw.bpmn.resolveBpmnIncident(this.projectId, instanceId, incidentId, {
251
317
  variables: vars.toWireMap() as any,
252
318
  });
253
319
  }
@@ -273,23 +339,37 @@ export class BpmnClient {
273
339
 
274
340
  // --- User tasks ---------------------------------------------------------
275
341
 
342
+ /**
343
+ * Page of user tasks in the project. Pass the page's
344
+ * `pagination.nextCursor` as `cursor` for the next one.
345
+ */
276
346
  async listUserTasks(opts: UserTaskListOptions = {}): Promise<BpmnUserTaskPaginatedResponse> {
277
347
  return this.raw.bpmn.listBpmnUserTasks(
278
348
  this.projectId,
279
- opts.workflowId,
349
+ opts.instanceId,
280
350
  opts.status,
281
351
  opts.assignee,
282
352
  opts.candidateUser,
283
353
  opts.candidateGroup,
284
354
  opts.businessId,
285
- opts.page,
286
- opts.pageSize,
355
+ opts.dueAfter,
356
+ opts.dueBefore,
357
+ opts.sort,
358
+ opts.cursor,
359
+ opts.limit,
287
360
  );
288
361
  }
289
362
 
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);
363
+ /** Page of the user tasks the caller may claim or has already claimed. */
364
+ async listUserTasksForCaller(opts: UserTaskScheduleOptions = {}): Promise<BpmnUserTaskPaginatedResponse> {
365
+ return this.raw.bpmn.listBpmnUserTasksForCaller(
366
+ this.projectId,
367
+ opts.dueAfter,
368
+ opts.dueBefore,
369
+ opts.sort,
370
+ opts.cursor,
371
+ opts.limit,
372
+ );
293
373
  }
294
374
 
295
375
  async getUserTask(executionKey: string): Promise<UserTask> {
@@ -334,4 +414,9 @@ export class BpmnClient {
334
414
  opts.createdAfter,
335
415
  );
336
416
  }
417
+
418
+ /** One deployed version of a process id with its instance counts and suspension state. */
419
+ async getProcessVersion(processId: string, version: number, opts: { createdAfter?: string } = {}): Promise<BpmnProcessVersion> {
420
+ return this.raw.bpmn.getBpmnProcessVersion(this.projectId, processId, version, opts.createdAfter);
421
+ }
337
422
  }
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.0.1',
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.0.1',
25
25
  WITH_CREDENTIALS: false,
26
26
  CREDENTIALS: 'include',
27
27
  TOKEN: undefined,
@@ -13,14 +13,18 @@ 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';
23
+ export type { BpmnInstance } from './models/BpmnInstance';
21
24
  export type { BpmnInstanceChildrenResponse } from './models/BpmnInstanceChildrenResponse';
22
25
  export type { BpmnInstancePaginatedResponse } from './models/BpmnInstancePaginatedResponse';
23
26
  export type { BpmnInstanceState } from './models/BpmnInstanceState';
27
+ export { BpmnInstanceStatus } from './models/BpmnInstanceStatus';
24
28
  export type { BpmnProcessDefinition } from './models/BpmnProcessDefinition';
25
29
  export type { BpmnProcessSummary } from './models/BpmnProcessSummary';
26
30
  export type { BpmnProcessSummaryPaginatedResponse } from './models/BpmnProcessSummaryPaginatedResponse';
@@ -41,9 +45,11 @@ export type { CorrelationKeys } from './models/CorrelationKeys';
41
45
  export type { CorrelationKeyString } from './models/CorrelationKeyString';
42
46
  export type { CreateBpmnResourceRequest } from './models/CreateBpmnResourceRequest';
43
47
  export type { CreateDefinitionRequest } from './models/CreateDefinitionRequest';
44
- export type { CreateProjectRequest } from './models/CreateProjectRequest';
48
+ export type { CursorPage } from './models/CursorPage';
45
49
  export type { DecisionInputField } from './models/DecisionInputField';
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
+