@camunda/task-testing 3.0.0 → 4.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.
@@ -1,3 +1,4 @@
1
+ export { DEFAULT_INPUT_CONFIG };
1
2
  export namespace DEFAULT_CONFIG {
2
3
  let input: {};
3
4
  let output: {};
@@ -13,8 +14,6 @@ export class ElementConfig extends EventEmitter<[never]> {
13
14
  * @type {Config}
14
15
  */
15
16
  _config: Config;
16
- _selectedElement: any;
17
- _variablesForElements: Map<any, any>;
18
17
  setConfig(newConfig: any): void;
19
18
  getConfig(): Config;
20
19
  setInputConfigForElement(element: any, newConfig: any): void;
@@ -22,13 +21,28 @@ export class ElementConfig extends EventEmitter<[never]> {
22
21
  setOutputConfigForElement(element: any, newConfig: any): void;
23
22
  resetOutputConfigForElement(element: any): void;
24
23
  getInputConfigForElement(element: any): string;
24
+ getDefaultInputForElement(element: any): Promise<string>;
25
+ /**
26
+ * Merges default input with already existing user edits.
27
+ *
28
+ * Returns null if the input config is unparsable to persist in progress edits
29
+ *
30
+ * @param {Element} element
31
+ * @returns {Promise<string|null>} merged JSON string, or null if current input is unparseable
32
+ */
33
+ getMergedInputConfigForElement(element: Element): Promise<string | null>;
25
34
  /**
26
35
  * @param {Element} element
27
36
  * @returns {ElementOutput}
28
37
  */
29
38
  getOutputConfigForElement(element: Element): ElementOutput;
30
- _getDefaultInputConfig(): string;
39
+ /**
40
+ * @param {Object} element
41
+ * @throws {Error} if the element type is not supported
42
+ */
43
+ _assertSupportedElement(element: any): void;
31
44
  }
45
+ import { DEFAULT_INPUT_CONFIG } from './utils/prefill';
32
46
  import EventEmitter from 'events';
33
47
  import type { Config } from './types';
34
48
  import type { Element } from './types';
@@ -4,5 +4,6 @@ export class ElementVariables extends EventEmitter<[never]> {
4
4
  _variables: {};
5
5
  _variableResolver: any;
6
6
  getVariablesForElement(element: any): Promise<any>;
7
+ getConsumedVariablesForElement(element: any): Promise<any>;
7
8
  }
8
9
  import EventEmitter from 'events';
@@ -69,6 +69,98 @@ export function createFinishedStatusEntry(result: TaskExecutionFinishedResult, t
69
69
  * @returns {string}
70
70
  */
71
71
  export function formatElementType(type: string): string;
72
+ /**
73
+ * Determine the {@link ENTRY_ORDER} for an execution log entry so that entries
74
+ * are placed in the correct lifecycle sequence. Status entries (deployed,
75
+ * instance-started, terminal) are always pinned to their lifecycle position
76
+ * regardless of timestamp. For all other entries the order is used as a
77
+ * tiebreaker when timestamps are equal.
78
+ *
79
+ * Entry order mapping (lower = earlier in the lifecycle):
80
+ * ENTRY_ORDER.DEPLOYED – deployed status
81
+ * ENTRY_ORDER.INSTANCE_STARTED – instance-started status
82
+ * ENTRY_ORDER.ELEMENT_ACTIVE – element-instance ACTIVE
83
+ * ENTRY_ORDER.START_LISTENER_CREATED – start execution listener job CREATED
84
+ * ENTRY_ORDER.START_LISTENER_TERMINAL – start execution listener job terminal
85
+ * ENTRY_ORDER.WORK_CREATED – regular job / user-task / message-subscription CREATED
86
+ * ENTRY_ORDER.WORK_TERMINAL – regular job / user-task / message-subscription terminal
87
+ * ENTRY_ORDER.END_LISTENER_CREATED – end execution listener job CREATED
88
+ * ENTRY_ORDER.END_LISTENER_TERMINAL – end execution listener job terminal
89
+ * ENTRY_ORDER.ELEMENT_TERMINAL – element-instance terminal (COMPLETED, TERMINATED, …)
90
+ * ENTRY_ORDER.STATUS_TERMINAL – terminal status entries (completed, incident, …)
91
+ *
92
+ * @param {ExecutionLogEntry} entry
93
+ *
94
+ * @returns {number}
95
+ */
96
+ export function getEntryOrder(entry: ExecutionLogEntry): number;
97
+ /**
98
+ * Check whether two execution log entries are related and should therefore be
99
+ * ordered by {@link ENTRY_ORDER} when they share a timestamp.
100
+ *
101
+ * Runtime entries are considered related when they share an `elementId`
102
+ * (linking element-instance, job, and message-subscription entries for the
103
+ * same BPMN element) or, for same-type entries without a common `elementId`,
104
+ * when they share an identity key (`jobKey`, `userTaskKey`, or
105
+ * `messageSubscriptionKey`).
106
+ *
107
+ * @param {ExecutionLogEntry} a
108
+ * @param {ExecutionLogEntry} b
109
+ *
110
+ * @returns {boolean}
111
+ */
112
+ export function areRelated(a: ExecutionLogEntry, b: ExecutionLogEntry): boolean;
113
+ /**
114
+ * Compare two entries by timestamp (ascending).
115
+ *
116
+ * @param {ExecutionLogEntry} a
117
+ * @param {ExecutionLogEntry} b
118
+ *
119
+ * @returns {number}
120
+ */
121
+ export function compareByTimestamp(a: ExecutionLogEntry, b: ExecutionLogEntry): number;
122
+ /**
123
+ * Check whether two entries have the same timestamp.
124
+ *
125
+ * @param {ExecutionLogEntry} a
126
+ * @param {ExecutionLogEntry} b
127
+ *
128
+ * @returns {boolean}
129
+ */
130
+ export function haveSameTimestamp(a: ExecutionLogEntry, b: ExecutionLogEntry): boolean;
131
+ /**
132
+ * Compare two entries by their {@link ENTRY_ORDER} lifecycle position (ascending).
133
+ *
134
+ * @param {ExecutionLogEntry} a
135
+ * @param {ExecutionLogEntry} b
136
+ *
137
+ * @returns {number}
138
+ */
139
+ export function compareByOrder(a: ExecutionLogEntry, b: ExecutionLogEntry): number;
140
+ /**
141
+ * Check whether element `ancestorId` is an ancestor of element `descendantId`
142
+ * by walking up the parent chain in the element registry.
143
+ *
144
+ * @param {Object|null} elementRegistry
145
+ * @param {string} [ancestorId]
146
+ * @param {string} [descendantId]
147
+ *
148
+ * @returns {boolean}
149
+ */
150
+ export function isAncestor(elementRegistry: any | null, ancestorId?: string, descendantId?: string): boolean;
151
+ /**
152
+ * Compare two element-instance entries by containment. When one element is an
153
+ * ancestor of the other, the ancestor's ACTIVE entry sorts first and its
154
+ * terminal entry sorts last. Returns 0 when neither entry is an
155
+ * element-instance or no containment relationship exists.
156
+ *
157
+ * @param {Object|null} elementRegistry
158
+ * @param {ExecutionLogEntry} a
159
+ * @param {ExecutionLogEntry} b
160
+ *
161
+ * @returns {number}
162
+ */
163
+ export function compareByContainment(elementRegistry: any | null, a: ExecutionLogEntry, b: ExecutionLogEntry): number;
72
164
  export namespace EXECUTION_LOG_ENTRY_TYPE {
73
165
  let STATUS: "status";
74
166
  let JOB: "job";
@@ -87,6 +179,21 @@ export namespace EXECUTION_LOG_ENTRY_STATUS {
87
179
  let TERMINATED: "terminated";
88
180
  let CANCELED: "canceled";
89
181
  }
182
+ export namespace ENTRY_ORDER {
183
+ let DEPLOYED_1: 0;
184
+ export { DEPLOYED_1 as DEPLOYED };
185
+ let INSTANCE_STARTED_1: 1;
186
+ export { INSTANCE_STARTED_1 as INSTANCE_STARTED };
187
+ export let ELEMENT_ACTIVE: 2;
188
+ export let START_LISTENER_CREATED: 3;
189
+ export let START_LISTENER_TERMINAL: 4;
190
+ export let WORK_CREATED: 5;
191
+ export let WORK_TERMINAL: 6;
192
+ export let END_LISTENER_CREATED: 7;
193
+ export let END_LISTENER_TERMINAL: 8;
194
+ export let ELEMENT_TERMINAL: 9;
195
+ export let STATUS_TERMINAL: 10;
196
+ }
90
197
  export default class ExecutionLog {
91
198
  /**
92
199
  * @param {Injector} [injector]
@@ -188,9 +295,9 @@ import type { ExecutionLogElementInstanceEntry } from './types';
188
295
  import type { ExecutionLogMessageSubscriptionEntry } from './types';
189
296
  import type { TaskExecutionFinishedResult } from './types';
190
297
  import type { ExecutionLogStatusEntry } from './types';
298
+ import type { ExecutionLogEntry } from './types';
191
299
  import type { TaskExecutionState } from './types';
192
300
  import type { DeployResponse } from './types';
193
301
  import type { StartInstanceResponse } from './types';
194
302
  import type { TaskExecutionPolledResult } from './types';
195
- import type { ExecutionLogEntry } from './types';
196
303
  import type { Injector } from 'didi';
@@ -1,14 +1,10 @@
1
1
  /**
2
2
  * @param {Object} props
3
3
  * @param {ExecutionLogEntry[]} props.entries
4
- * @param {string} [props.tasklistBaseUrl]
5
- * @param {string|null} [props.currentOperateUrl]
6
4
  * @param {boolean} [props.isTaskExecuting]
7
5
  */
8
- export function ExecutionLog({ entries, tasklistBaseUrl, currentOperateUrl, isTaskExecuting }: {
6
+ export function ExecutionLog({ entries, isTaskExecuting }: {
9
7
  entries: ExecutionLogEntry[];
10
- tasklistBaseUrl?: string | undefined;
11
- currentOperateUrl?: string | null | undefined;
12
8
  isTaskExecuting?: boolean | undefined;
13
9
  }): import("react/jsx-runtime").JSX.Element;
14
10
  export namespace JOB_STATES {
@@ -23,6 +23,22 @@ export default function Output({ element, isConnectionConfigured, isTaskExecutin
23
23
  tasklistBaseUrl?: string | undefined;
24
24
  currentVariables?: any;
25
25
  }): import("react/jsx-runtime").JSX.Element;
26
+ /**
27
+ * Get the waiting context describing what the execution is currently blocked on.
28
+ * Returns null if nothing is being waited on.
29
+ *
30
+ * @param {ExecutionLogEntry[]} [entries]
31
+ * @param {string} [tasklistBaseUrl]
32
+ * @param {string|null} [currentOperateUrl]
33
+ *
34
+ * @returns {{ title: string, description: React.ReactNode, linkUrl: string|null, linkLabel: string } | null}
35
+ */
36
+ export function getWaitingContext(entries?: ExecutionLogEntry[], tasklistBaseUrl?: string, currentOperateUrl?: string | null): {
37
+ title: string;
38
+ description: React.ReactNode;
39
+ linkUrl: string | null;
40
+ linkLabel: string;
41
+ } | null;
26
42
  export function HeaderLink({ children, render, visible, href, target, className, onClick, renderIcon, role, tooltip, priority }: {
27
43
  children?: null | undefined;
28
44
  render?: ((props?: any) => React.ReactNode) | undefined;
@@ -72,9 +72,9 @@ export type TaskExecutionApi = {
72
72
  getProcessInstance: (processInstanceKey: string) => Promise<GetProcessInstanceResponse>;
73
73
  getProcessInstanceElementInstances: (processInstanceKey: string) => Promise<GetProcessInstanceElementInstancesResponse>;
74
74
  getProcessInstanceIncident: (processInstanceKey: string) => Promise<GetProcessInstanceIncidentsResponse>;
75
- getProcessInstanceJobs: (processInstanceKey: string, elementId: string) => Promise<GetProcessInstanceJobsResponse>;
76
- getProcessInstanceMessageSubscriptions: (processInstanceKey: string, elementId: string) => Promise<GetProcessInstanceMessageSubscriptionsResponse>;
77
- getProcessInstanceUserTasks: (processInstanceKey: string, elementId: string) => Promise<GetProcessInstanceUserTasksResponse>;
75
+ getProcessInstanceJobs: (processInstanceKey: string) => Promise<GetProcessInstanceJobsResponse>;
76
+ getProcessInstanceMessageSubscriptions: (processInstanceKey: string) => Promise<GetProcessInstanceMessageSubscriptionsResponse>;
77
+ getProcessInstanceUserTasks: (processInstanceKey: string) => Promise<GetProcessInstanceUserTasksResponse>;
78
78
  getProcessInstanceVariables: (processInstanceKey: string) => Promise<GetProcessInstanceVariablesResponse>;
79
79
  startInstance: (processDefinitionKey: string, elementId: string, variables: {
80
80
  [key: string]: any;
@@ -174,6 +174,7 @@ export type ExecutionLogJobData = {
174
174
  export type ExecutionLogUserTaskData = {
175
175
  state: string;
176
176
  name?: string;
177
+ elementId?: string;
177
178
  userTaskKey?: string;
178
179
  creationDate?: string;
179
180
  completionDate?: string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Compute a default input config from the element's input requirements, producing a JSON string with `null` stubs for each required variable.
3
+ *
4
+ * @param {Object} elementVariables
5
+ * @param {Object} element
6
+ * @returns {Promise<string>} JSON string
7
+ */
8
+ export function computeDefaultInput(elementVariables: any, element: any): Promise<string>;
9
+ /**
10
+ * Merge current input with fresh input requirements from the element. User edits have higher priority.
11
+ *
12
+ * @param {string} currentInputString - stored JSON string (or undefined)
13
+ * @param {Object} elementVariables
14
+ * @param {Object} element
15
+ * @returns {Promise<string|null>} merged JSON string, or null if unparseable
16
+ */
17
+ export function computeMergedInput(currentInputString: string, elementVariables: any, element: any): Promise<string | null>;
18
+ export const DEFAULT_INPUT_CONFIG: "{\n \n}";
package/package.json CHANGED
@@ -1,101 +1,101 @@
1
- {
2
- "name": "@camunda/task-testing",
3
- "version": "3.0.0",
4
- "files": [
5
- "dist"
6
- ],
7
- "main": "dist/index.js",
8
- "types": "dist/types/index.d.ts",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/camunda/task-testing"
12
- },
13
- "scripts": {
14
- "all": "run-s lint types test build",
15
- "open": "open-cli http://localhost:3000",
16
- "start:server": "node demo/server.mjs",
17
- "start:client": "webpack --watch --config webpack.demo.js",
18
- "start": "run-p start:* open",
19
- "dev": "npm test -- --auto-watch --no-single-run",
20
- "build": "run-s build:webpack build:types",
21
- "build:webpack": "webpack",
22
- "build:watch": "webpack --watch",
23
- "build:demo": "webpack --config webpack.demo.js",
24
- "build:types": "tsc",
25
- "test": "karma start karma.config.js",
26
- "lint": "eslint .",
27
- "types": "tsc --noEmit",
28
- "prepare": "npm run build"
29
- },
30
- "license": "MIT",
31
- "dependencies": {
32
- "@codemirror/autocomplete": "^6.19.1",
33
- "@codemirror/lang-json": "^6.0.2",
34
- "@codemirror/language": "^6.11.3",
35
- "@codemirror/state": "^6.5.2",
36
- "@codemirror/view": "^6.38.8",
37
- "@lezer/highlight": "^1.2.1",
38
- "classnames": "^2.5.1",
39
- "codemirror": "^6.0.2",
40
- "events": "^3.3.0",
41
- "min-dash": "^5.0.0"
42
- },
43
- "devDependencies": {
44
- "@babel/core": "^7.28.0",
45
- "@babel/preset-env": "^7.28.0",
46
- "@babel/preset-react": "^7.27.1",
47
- "@bpmn-io/variable-resolver": "^2.0.0",
48
- "@camunda8/orchestration-cluster-api": "^8.8.4",
49
- "@carbon/icons-react": "^11.62.0",
50
- "@carbon/react": "^1.76.0",
51
- "@eslint/js": "^9.31.0",
52
- "@testing-library/react": "^16.3.0",
53
- "@testing-library/user-event": "^14.6.1",
54
- "@types/codemirror": "^5.60.16",
55
- "@types/react": "^19.1.12",
56
- "babel-loader": "^10.1.1",
57
- "bpmn-js-element-templates": "^2.22.0",
58
- "bpmn-js-headless": "^0.1.0",
59
- "bpmn-js-properties-panel": "^5.53.0",
60
- "camunda-bpmn-js": "^5.24.2",
61
- "chai": "^4.5.0",
62
- "css-loader": "^7.1.4",
63
- "dotenv": "^17.2.1",
64
- "eslint": "^9.31.0",
65
- "eslint-plugin-bpmn-io": "^2.2.0",
66
- "express": "^5.1.0",
67
- "html-webpack-plugin": "^5.6.6",
68
- "karma": "^6.4.4",
69
- "karma-chrome-launcher-2": "^3.3.0",
70
- "karma-env-preprocessor": "^0.1.1",
71
- "karma-mocha": "^2.0.1",
72
- "karma-sinon-chai": "^2.0.2",
73
- "karma-webpack": "^5.0.1",
74
- "mocha": "^11.7.1",
75
- "npm-run-all2": "^8.0.4",
76
- "open": "^10.2.0",
77
- "open-cli": "^8.0.0",
78
- "puppeteer": "^24.38.0",
79
- "raw-loader": "^4.0.2",
80
- "react": "^18.3.1",
81
- "react-dom": "^18.3.1",
82
- "sass": "^1.97.3",
83
- "sass-loader": "^16.0.7",
84
- "sinon": "^17.0.1",
85
- "sinon-chai": "^3.7.0",
86
- "style-loader": "^4.0.0",
87
- "typescript": "^5.9.2",
88
- "webpack": "^5.105.4",
89
- "webpack-cli": "^6.0.1",
90
- "webpack-dev-server": "^5.2.3",
91
- "zeebe-bpmn-moddle": "^1.11.0"
92
- },
93
- "peerDependencies": {
94
- "camunda-bpmn-js": "*",
95
- "react": "*",
96
- "react-dom": "*"
97
- },
98
- "overrides": {
99
- "react-is": "^18.0.0"
100
- }
101
- }
1
+ {
2
+ "name": "@camunda/task-testing",
3
+ "version": "4.0.0",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "main": "dist/index.js",
8
+ "types": "dist/types/index.d.ts",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/camunda/task-testing"
12
+ },
13
+ "scripts": {
14
+ "all": "run-s lint types test build",
15
+ "open": "open-cli http://localhost:3000",
16
+ "start:server": "node demo/server.mjs",
17
+ "start:client": "webpack --watch --config webpack.demo.js",
18
+ "start": "run-p start:* open",
19
+ "dev": "npm test -- --auto-watch --no-single-run",
20
+ "build": "run-s build:webpack build:types",
21
+ "build:webpack": "webpack",
22
+ "build:watch": "webpack --watch",
23
+ "build:demo": "webpack --config webpack.demo.js",
24
+ "build:types": "tsc",
25
+ "test": "karma start karma.config.js",
26
+ "lint": "eslint .",
27
+ "types": "tsc --noEmit",
28
+ "prepare": "npm run build"
29
+ },
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@codemirror/autocomplete": "^6.19.1",
33
+ "@codemirror/lang-json": "^6.0.2",
34
+ "@codemirror/language": "^6.11.3",
35
+ "@codemirror/state": "^6.5.2",
36
+ "@codemirror/view": "^6.38.8",
37
+ "@lezer/highlight": "^1.2.1",
38
+ "classnames": "^2.5.1",
39
+ "codemirror": "^6.0.2",
40
+ "events": "^3.3.0",
41
+ "min-dash": "^5.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@babel/core": "^7.28.0",
45
+ "@babel/preset-env": "^7.28.0",
46
+ "@babel/preset-react": "^7.27.1",
47
+ "@bpmn-io/variable-resolver": "^3.0.0",
48
+ "@camunda8/orchestration-cluster-api": "^8.8.4",
49
+ "@carbon/icons-react": "^11.62.0",
50
+ "@carbon/react": "^1.76.0",
51
+ "@eslint/js": "^9.31.0",
52
+ "@testing-library/react": "^16.3.0",
53
+ "@testing-library/user-event": "^14.6.1",
54
+ "@types/codemirror": "^5.60.16",
55
+ "@types/react": "^19.1.12",
56
+ "babel-loader": "^10.1.1",
57
+ "bpmn-js-element-templates": "^2.22.0",
58
+ "bpmn-js-headless": "^0.1.0",
59
+ "bpmn-js-properties-panel": "^5.53.0",
60
+ "camunda-bpmn-js": "^5.25.0",
61
+ "chai": "^4.5.0",
62
+ "css-loader": "^7.1.4",
63
+ "dotenv": "^17.2.1",
64
+ "eslint": "^9.31.0",
65
+ "eslint-plugin-bpmn-io": "^2.2.0",
66
+ "express": "^5.1.0",
67
+ "html-webpack-plugin": "^5.6.6",
68
+ "karma": "^6.4.4",
69
+ "karma-chrome-launcher-2": "^3.3.0",
70
+ "karma-env-preprocessor": "^0.1.1",
71
+ "karma-mocha": "^2.0.1",
72
+ "karma-sinon-chai": "^2.0.2",
73
+ "karma-webpack": "^5.0.1",
74
+ "mocha": "^11.7.1",
75
+ "npm-run-all2": "^8.0.4",
76
+ "open": "^10.2.0",
77
+ "open-cli": "^8.0.0",
78
+ "puppeteer": "^24.38.0",
79
+ "raw-loader": "^4.0.2",
80
+ "react": "^18.3.1",
81
+ "react-dom": "^18.3.1",
82
+ "sass": "^1.97.3",
83
+ "sass-loader": "^16.0.7",
84
+ "sinon": "^17.0.1",
85
+ "sinon-chai": "^3.7.0",
86
+ "style-loader": "^4.0.0",
87
+ "typescript": "^5.9.2",
88
+ "webpack": "^5.105.4",
89
+ "webpack-cli": "^6.0.1",
90
+ "webpack-dev-server": "^5.2.3",
91
+ "zeebe-bpmn-moddle": "^1.11.0"
92
+ },
93
+ "peerDependencies": {
94
+ "camunda-bpmn-js": "*",
95
+ "react": "*",
96
+ "react-dom": "*"
97
+ },
98
+ "overrides": {
99
+ "react-is": "^18.0.0"
100
+ }
101
+ }