@camunda/task-testing 2.2.0 → 3.0.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,14 +1,14 @@
1
- import type { CamundaClient, CreateProcessInstanceResult, ElementInstanceResult, ElementInstanceSearchQueryResult, IncidentResult, IncidentSearchQueryResult, ProcessInstanceResult, ProcessInstanceSearchQueryResult, ProcessInstanceStateEnum, VariableSearchQueryResult, VariableSearchResult } from '@camunda8/orchestration-cluster-api';
2
- import type { ModdleElement } from "bpmn-js/lib/model/Types";
3
- type ExtendedDeploymentResult = Awaited<ReturnType<CamundaClient['createDeployment']>>;
4
- export type { CreateProcessInstanceResult, ElementInstanceSearchQueryResult, IncidentSearchQueryResult, ProcessInstanceSearchQueryResult, ProcessInstanceResult, VariableSearchQueryResult, ExtendedDeploymentResult, ProcessInstanceStateEnum, VariableSearchResult, ElementInstanceResult, IncidentResult };
1
+ import type { CreateProcessInstanceResult, DeploymentResult, ElementInstanceSearchQueryResult, IncidentResult, IncidentSearchQueryResult, JobSearchQueryResult, MessageSubscriptionSearchQueryResult, ProcessInstanceSearchQueryResult, UserTaskSearchQueryResult, VariableSearchQueryResult } from '@camunda8/orchestration-cluster-api';
2
+ import { ModdleElement } from 'bpmn-js/lib/model/Types';
3
+ import { TASK_EXECUTION_EVENT, TASK_EXECUTION_FINISHED_REASON, TASK_EXECUTION_STATE } from './TaskExecution';
4
+ import { EXECUTION_LOG_ENTRY_TYPE, EXECUTION_LOG_ENTRY_STATUS } from './ExecutionLog';
5
5
  export type Input = {
6
6
  [elementId: string]: string;
7
7
  };
8
8
  export type Output = {
9
9
  [elementId: string]: ElementOutput;
10
10
  };
11
- export type VARIABLE_SCOPE = 'LOCAL' | 'PROCESS';
11
+ export type VARIABLE_SCOPE = 'LOCAL' | 'PROCESS' | null;
12
12
  export type ElementOutputVariables = {
13
13
  [id: string]: {
14
14
  name: string;
@@ -20,7 +20,7 @@ export type ElementOutput = {
20
20
  success: boolean;
21
21
  variables?: ElementOutputVariables;
22
22
  error?: TaskExecutionError;
23
- incident?: any;
23
+ incident?: IncidentResult;
24
24
  operateUrl?: string;
25
25
  [key: string]: any;
26
26
  } | undefined;
@@ -43,29 +43,183 @@ export type ApiResponse<T> = {
43
43
  } | {
44
44
  success: false;
45
45
  error: string;
46
+ errorType?: string;
47
+ status?: number | null;
48
+ detail?: string | null;
49
+ operationId?: string | null;
50
+ };
51
+ export type DeployResponse = ApiResponse<DeploymentResult>;
52
+ export type GetProcessInstanceResponse = ApiResponse<ProcessInstanceSearchQueryResult>;
53
+ export type GetProcessInstanceElementInstancesResponse = ApiResponse<ElementInstanceSearchQueryResult>;
54
+ export type GetProcessInstanceIncidentsResponse = ApiResponse<IncidentSearchQueryResult>;
55
+ export type GetProcessInstanceJobsResponse = ApiResponse<JobSearchQueryResult>;
56
+ export type GetProcessInstanceMessageSubscriptionsResponse = ApiResponse<MessageSubscriptionSearchQueryResult>;
57
+ export type GetProcessInstanceUserTasksResponse = ApiResponse<UserTaskSearchQueryResult>;
58
+ export type GetProcessInstanceVariablesResponse = ApiResponse<VariableSearchQueryResult>;
59
+ export type StartInstanceResponse = ApiResponse<CreateProcessInstanceResult>;
60
+ export type TaskExecutionPolledResult = {
61
+ elementId: string;
62
+ elementInstancesResponse: GetProcessInstanceElementInstancesResponse;
63
+ jobsResponse: GetProcessInstanceJobsResponse;
64
+ messageSubscriptionsResponse: GetProcessInstanceMessageSubscriptionsResponse;
65
+ processInstanceKey: string;
66
+ processInstanceResponse: GetProcessInstanceResponse;
67
+ userTasksResponse: GetProcessInstanceUserTasksResponse;
68
+ variablesResponse: GetProcessInstanceVariablesResponse;
46
69
  };
47
70
  export type TaskExecutionApi = {
48
- deploy: () => Promise<ApiResponse<ExtendedDeploymentResult>>;
71
+ deploy: () => Promise<DeployResponse>;
72
+ getProcessInstance: (processInstanceKey: string) => Promise<GetProcessInstanceResponse>;
73
+ getProcessInstanceElementInstances: (processInstanceKey: string) => Promise<GetProcessInstanceElementInstancesResponse>;
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>;
78
+ getProcessInstanceVariables: (processInstanceKey: string) => Promise<GetProcessInstanceVariablesResponse>;
49
79
  startInstance: (processDefinitionKey: string, elementId: string, variables: {
50
80
  [key: string]: any;
51
- }) => Promise<ApiResponse<CreateProcessInstanceResult>>;
52
- getProcessInstance: (processInstanceKey: string) => Promise<ApiResponse<ProcessInstanceSearchQueryResult>>;
53
- getProcessInstanceVariables: (processInstanceKey: string) => Promise<ApiResponse<VariableSearchQueryResult>>;
54
- getProcessInstanceElementInstances: (processInstanceKey: string) => Promise<ApiResponse<ElementInstanceSearchQueryResult>>;
55
- getProcessInstanceIncident: (processInstanceKey: string) => Promise<ApiResponse<IncidentSearchQueryResult>>;
56
- };
57
- export type TaskExecutionStatus = 'idle' | 'deploying' | 'starting-instance' | 'executing';
58
- export type TaskExecutionEvents = 'taskExecution.status.changed' | 'taskExecution.finished' | 'taskExecution.error' | 'taskExecution.interrupted';
59
- export type TaskExecutionResult = {
60
- success: boolean;
61
- variables?: ElementOutputVariables;
62
- error?: TaskExecutionError;
63
- incident?: any;
81
+ }) => Promise<StartInstanceResponse>;
82
+ };
83
+ export type TaskExecutionState = typeof TASK_EXECUTION_STATE[keyof typeof TASK_EXECUTION_STATE];
84
+ export type TaskExecutionEventListeners = {
85
+ [TASK_EXECUTION_EVENT.STATE_CHANGED]: (state: TaskExecutionState) => void;
86
+ [TASK_EXECUTION_EVENT.DEPLOYED]: (response: DeployResponse) => void;
87
+ [TASK_EXECUTION_EVENT.INSTANCE_STARTED]: (response: StartInstanceResponse) => void;
88
+ [TASK_EXECUTION_EVENT.POLLED]: (result: TaskExecutionPolledResult) => void;
89
+ [TASK_EXECUTION_EVENT.FINISHED]: (result: TaskExecutionFinishedResult) => void;
90
+ };
91
+ export type TaskExecutionSuccessResult = {
92
+ lastPolledResult: TaskExecutionPolledResult;
93
+ processInstanceKey: string;
94
+ success: true;
95
+ };
96
+ export type TaskExecutionIncidentResult = {
97
+ incident: any;
98
+ lastPolledResult: TaskExecutionPolledResult;
99
+ processInstanceKey: string;
100
+ reason: typeof TASK_EXECUTION_FINISHED_REASON.INCIDENT;
101
+ success: false;
64
102
  };
103
+ export type TaskExecutionUserCancelResult = {
104
+ lastPolledResult: TaskExecutionPolledResult | null;
105
+ processInstanceKey: string | null;
106
+ reason: typeof TASK_EXECUTION_FINISHED_REASON.USER_CANCEL;
107
+ success: false;
108
+ };
109
+ export type TaskExecutionUserSelectionChangedResult = {
110
+ lastPolledResult: TaskExecutionPolledResult | null;
111
+ processInstanceKey: string | null;
112
+ reason: typeof TASK_EXECUTION_FINISHED_REASON.USER_SELECTION_CHANGED;
113
+ success: false;
114
+ };
115
+ export type TaskExecutionErrorResult = {
116
+ error: TaskExecutionError;
117
+ lastPolledResult: TaskExecutionPolledResult | null;
118
+ processInstanceKey: string | null;
119
+ reason: typeof TASK_EXECUTION_FINISHED_REASON.ERROR;
120
+ success: false;
121
+ };
122
+ export type TaskExecutionTerminatedResult = {
123
+ lastPolledResult: TaskExecutionPolledResult;
124
+ processInstanceKey: string;
125
+ reason: typeof TASK_EXECUTION_FINISHED_REASON.TERMINATED;
126
+ success: false;
127
+ };
128
+ export type TaskExecutionFinishedResult = TaskExecutionSuccessResult | TaskExecutionIncidentResult | TaskExecutionTerminatedResult | TaskExecutionUserCancelResult | TaskExecutionUserSelectionChangedResult | TaskExecutionErrorResult;
65
129
  export type TaskExecutionError = {
66
130
  message: string;
67
- response?: any;
131
+ response?: string;
132
+ errorType?: string;
133
+ status?: number | null;
134
+ detail?: string | null;
135
+ operationId?: string | null;
136
+ };
137
+ export type ExecutionLogEntryStatus = typeof EXECUTION_LOG_ENTRY_STATUS[keyof typeof EXECUTION_LOG_ENTRY_STATUS];
138
+ export type DeployedStatusData = {
139
+ processDefinitionId?: string;
140
+ processDefinitionKey?: string;
141
+ processDefinitionVersion?: number;
142
+ deploymentKey?: string;
143
+ };
144
+ export type InstanceStartedStatusData = {
145
+ processInstanceKey: string;
146
+ processDefinitionId?: string;
147
+ processDefinitionKey?: string;
148
+ };
149
+ export type CompletedStatusData = {
150
+ processInstanceKey: string;
151
+ };
152
+ export type TerminatedStatusData = {
153
+ processInstanceKey: string;
154
+ };
155
+ export type IncidentStatusData = {
156
+ processInstanceKey: string;
157
+ errorType?: string;
158
+ errorMessage?: string;
159
+ };
160
+ export type CanceledStatusData = {
161
+ error?: TaskExecutionError;
162
+ };
163
+ export type ExecutionLogStatusEntryData = DeployedStatusData | InstanceStartedStatusData | CompletedStatusData | TerminatedStatusData | IncidentStatusData | CanceledStatusData;
164
+ export type ExecutionLogJobData = {
165
+ state: string;
166
+ type?: string;
167
+ elementId?: string;
168
+ kind?: string;
169
+ listenerEventType?: string;
170
+ jobKey?: string;
171
+ creationTime?: string;
172
+ endTime?: string;
173
+ };
174
+ export type ExecutionLogUserTaskData = {
175
+ state: string;
176
+ name?: string;
177
+ userTaskKey?: string;
178
+ creationDate?: string;
179
+ completionDate?: string;
180
+ };
181
+ export type ExecutionLogElementInstanceData = {
182
+ type?: string;
183
+ state: string;
184
+ elementId?: string;
185
+ elementName?: string;
186
+ startDate?: string;
187
+ endDate?: string;
188
+ elementInstanceKey?: string;
189
+ };
190
+ export type ExecutionLogMessageSubscriptionData = {
191
+ messageName?: string;
192
+ elementId?: string;
193
+ messageSubscriptionState?: string;
194
+ messageSubscriptionKey?: string;
195
+ };
196
+ export type ExecutionLogStatusEntry = {
197
+ type: typeof EXECUTION_LOG_ENTRY_TYPE.STATUS;
198
+ status: ExecutionLogEntryStatus;
199
+ data?: ExecutionLogStatusEntryData;
200
+ timestamp: number;
201
+ };
202
+ export type ExecutionLogJobEntry = {
203
+ type: typeof EXECUTION_LOG_ENTRY_TYPE.JOB;
204
+ data: ExecutionLogJobData;
205
+ timestamp: number;
206
+ };
207
+ export type ExecutionLogUserTaskEntry = {
208
+ type: typeof EXECUTION_LOG_ENTRY_TYPE.USER_TASK;
209
+ data: ExecutionLogUserTaskData;
210
+ timestamp: number;
211
+ };
212
+ export type ExecutionLogMessageSubscriptionEntry = {
213
+ type: typeof EXECUTION_LOG_ENTRY_TYPE.MESSAGE_SUBSCRIPTION;
214
+ data: ExecutionLogMessageSubscriptionData;
215
+ timestamp: number;
216
+ };
217
+ export type ExecutionLogElementInstanceEntry = {
218
+ type: typeof EXECUTION_LOG_ENTRY_TYPE.ELEMENT_INSTANCE;
219
+ data: ExecutionLogElementInstanceData;
220
+ timestamp: number;
68
221
  };
222
+ export type ExecutionLogEntry = ExecutionLogStatusEntry | ExecutionLogJobEntry | ExecutionLogUserTaskEntry | ExecutionLogMessageSubscriptionEntry | ExecutionLogElementInstanceEntry;
69
223
  export type { Element, ModdleElement } from 'bpmn-js/lib/model/Types';
70
224
  export type Plugin = {
71
225
  priority?: number;
@@ -79,3 +233,4 @@ export type PluginContextValue = {
79
233
  unregisterPlugin: (plugin: Plugin) => void;
80
234
  getPlugins: (pluginPoint: string) => Plugin[];
81
235
  };
236
+ export { CreateProcessInstanceResult, DeploymentResult, ElementInstanceResult, ElementInstanceSearchQueryResult, IncidentResult, IncidentSearchQueryResult, JobSearchQueryResult, JobSearchResult, MessageSubscriptionResult, MessageSubscriptionSearchQueryResult, ProcessInstanceResult, ProcessInstanceSearchQueryResult, SearchQueryResponse, UserTaskResult, UserTaskSearchQueryResult, VariableSearchResult, VariableSearchQueryResult } from '@camunda8/orchestration-cluster-api';
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @typedef {import('@codemirror/autocomplete').Completion} Completion
3
- * @typedef {import('@codemirror/autocomplete').CompletionContext} CompletionContext
4
- * @typedef {import('@codemirror/autocomplete').CompletionResult} CompletionResult
2
+ * @import {
3
+ * Completion,
4
+ * CompletionContext,
5
+ * CompletionResult
6
+ * } from '@codemirror/autocomplete';
5
7
  */
6
8
  /**
7
9
  * @param {Completion[]} variables
8
10
  */
9
11
  export function getAutocompletionExtensions(variables: Completion[]): import("@codemirror/state").Extension[];
10
- export type Completion = import("@codemirror/autocomplete").Completion;
11
- export type CompletionContext = import("@codemirror/autocomplete").CompletionContext;
12
- export type CompletionResult = import("@codemirror/autocomplete").CompletionResult;
12
+ import type { Completion } from '@codemirror/autocomplete';
@@ -1,11 +1,20 @@
1
1
  export function getName(element: any): string;
2
2
  export function getType(element: any, injector: any): any;
3
3
  export function getConcreteType(element: any): any;
4
+ /**
5
+ * Check if an element is a child of an ad-hoc subprocess.
6
+ *
7
+ * @param {Element} element
8
+ *
9
+ * @returns {boolean}
10
+ */
11
+ export function isInsideAdHocSubProcess(element: Element): boolean;
4
12
  /**
5
13
  * Get parent process of an element.
6
14
  *
7
- * @param {import('../types').Element} element
15
+ * @param {Element} element
8
16
  *
9
17
  * @returns {string|null}
10
18
  */
11
- export function getProcessId(element: import("../types").Element): string | null;
19
+ export function getProcessId(element: Element): string | null;
20
+ import type { Element } from '../types';
@@ -1,6 +1,9 @@
1
1
  /**
2
+ * Get Operate URL for a given process instance.
3
+ *
2
4
  * @param {string} operateBaseUrl
3
5
  * @param {string} processInstanceKey
4
- * @returns {string}
6
+ *
7
+ * @returns {string|null}
5
8
  */
6
- export function getOperateUrl(operateBaseUrl: string, processInstanceKey: string): string;
9
+ export function getOperateUrl(operateBaseUrl: string, processInstanceKey: string): string | null;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get Tasklist URL for a given user task.
3
+ *
4
+ * @param {string} tasklistBaseUrl
5
+ * @param {string} userTaskKey
6
+ *
7
+ * @returns {string|null}
8
+ */
9
+ export function getTasklistUrl(tasklistBaseUrl: string, userTaskKey: string): string | null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Trim trailing slashes from a string.
3
+ *
4
+ * @example
5
+ * trimTrailingSlashes('http://example.com/') // => 'http://example.com'
6
+ * trimTrailingSlashes('http://example.com///') // => 'http://example.com'
7
+ *
8
+ * @param {string} string
9
+ *
10
+ * @returns {string}
11
+ */
12
+ export function trimTrailingSlashes(string: string): string;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Get scoped variables from raw API response items.
3
+ *
4
+ * @param {Array} variableItems
5
+ * @param {Array} elementInstanceItems
6
+ * @param {string} processInstanceKey
7
+ * @param {string} elementId
8
+ *
9
+ * @returns {ElementOutputVariables}
10
+ */
11
+ export function getVariables(variableItems: any[], elementInstanceItems: any[], processInstanceKey: string, elementId: string): ElementOutputVariables;
12
+ /**
13
+ * Pick variables for a given scope. Variables in legacy format are ignored.
14
+ *
15
+ * @param {ElementOutputVariables} variables
16
+ * @param {string} scope
17
+ *
18
+ * @returns {Object}
19
+ */
20
+ export function pickVariables(variables: ElementOutputVariables, scope: string): any;
21
+ /**
22
+ * @type {{ LOCAL: 'LOCAL', PROCESS: 'PROCESS' }}
23
+ */
24
+ export const SCOPES: {
25
+ LOCAL: "LOCAL";
26
+ PROCESS: "PROCESS";
27
+ };
28
+ import type { ElementOutputVariables } from '../types';
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@camunda/task-testing",
3
- "version": "2.2.0",
3
+ "version": "3.0.0-0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/types/index.d.ts",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/camunda/task-testing"
12
+ },
9
13
  "scripts": {
10
14
  "all": "run-s lint types test build",
11
15
  "open": "open-cli http://localhost:3000",
@@ -34,15 +38,14 @@
34
38
  "classnames": "^2.5.1",
35
39
  "codemirror": "^6.0.2",
36
40
  "events": "^3.3.0",
37
- "min-dash": "^4.2.3"
41
+ "min-dash": "^5.0.0"
38
42
  },
39
43
  "devDependencies": {
40
44
  "@babel/core": "^7.28.0",
41
45
  "@babel/preset-env": "^7.28.0",
42
46
  "@babel/preset-react": "^7.27.1",
43
- "@bpmn-io/variable-resolver": "^1.3.6",
47
+ "@bpmn-io/variable-resolver": "^2.0.0",
44
48
  "@camunda8/orchestration-cluster-api": "^8.8.4",
45
- "@camunda8/sdk": "^8.8.3",
46
49
  "@carbon/icons-react": "^11.62.0",
47
50
  "@carbon/react": "^1.76.0",
48
51
  "@eslint/js": "^9.31.0",
@@ -50,22 +53,20 @@
50
53
  "@testing-library/user-event": "^14.6.1",
51
54
  "@types/codemirror": "^5.60.16",
52
55
  "@types/react": "^19.1.12",
53
- "babel-loader": "^10.0.0",
54
- "bpmn-js-element-templates": "^2.15.1",
56
+ "babel-loader": "^10.1.1",
57
+ "bpmn-js-element-templates": "^2.22.0",
55
58
  "bpmn-js-headless": "^0.1.0",
56
- "bpmn-js-properties-panel": "^5.42.3",
57
- "camunda-bpmn-js": "^5.14.2",
59
+ "bpmn-js-properties-panel": "^5.53.0",
60
+ "camunda-bpmn-js": "^5.24.2",
58
61
  "chai": "^4.5.0",
59
- "css-loader": "^7.1.2",
62
+ "css-loader": "^7.1.4",
60
63
  "dotenv": "^17.2.1",
61
64
  "eslint": "^9.31.0",
62
65
  "eslint-plugin-bpmn-io": "^2.2.0",
63
- "eslint-plugin-react-hooks": "^5.2.0",
64
- "eslint-plugin-react-refresh": "^0.4.20",
65
66
  "express": "^5.1.0",
66
- "html-webpack-plugin": "^5.6.3",
67
+ "html-webpack-plugin": "^5.6.6",
67
68
  "karma": "^6.4.4",
68
- "karma-chrome-launcher": "^3.2.0",
69
+ "karma-chrome-launcher-2": "^3.3.0",
69
70
  "karma-env-preprocessor": "^0.1.1",
70
71
  "karma-mocha": "^2.0.1",
71
72
  "karma-sinon-chai": "^2.0.2",
@@ -74,18 +75,19 @@
74
75
  "npm-run-all2": "^8.0.4",
75
76
  "open": "^10.2.0",
76
77
  "open-cli": "^8.0.0",
78
+ "puppeteer": "^24.38.0",
77
79
  "raw-loader": "^4.0.2",
78
80
  "react": "^18.3.1",
79
81
  "react-dom": "^18.3.1",
80
- "sass": "^1.89.2",
81
- "sass-loader": "^16.0.5",
82
+ "sass": "^1.97.3",
83
+ "sass-loader": "^16.0.7",
82
84
  "sinon": "^17.0.1",
83
85
  "sinon-chai": "^3.7.0",
84
86
  "style-loader": "^4.0.0",
85
87
  "typescript": "^5.9.2",
86
- "webpack": "^5.100.1",
88
+ "webpack": "^5.105.4",
87
89
  "webpack-cli": "^6.0.1",
88
- "webpack-dev-server": "^5.2.2",
90
+ "webpack-dev-server": "^5.2.3",
89
91
  "zeebe-bpmn-moddle": "^1.11.0"
90
92
  },
91
93
  "peerDependencies": {
@@ -1,20 +0,0 @@
1
- export function OutputVariables({ isTaskExecuting, output, element }: {
2
- isTaskExecuting: any;
3
- output: any;
4
- element: any;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- /**
7
- * Pick variables for a given scope. Variables in legacy format are ignored.
8
- *
9
- * @param {import('../../types').ElementOutputVariables} variables
10
- * @param {string} scope
11
- *
12
- * @returns {Object}
13
- */
14
- export function pickVariables(variables: import("../../types").ElementOutputVariables, scope: string): any;
15
- export function OutputTab({ children, render, label, priority }: {
16
- label: string;
17
- render?: Function | undefined;
18
- children?: React.ReactNode;
19
- priority?: number | undefined;
20
- }): null;