@camunda/task-testing 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +57 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -362,30 +362,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
362
362
|
* except in compliance with the MIT License.
|
|
363
363
|
*/
|
|
364
364
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
* TaskExecutionApi,
|
|
368
|
-
* TaskExecutionResult,
|
|
369
|
-
* TaskExecutionError,
|
|
370
|
-
* TaskExecutionStatus } from './types';
|
|
371
|
-
*/
|
|
365
|
+
|
|
366
|
+
const INTERVAL_MS = 1000;
|
|
372
367
|
|
|
373
368
|
/**
|
|
374
|
-
* @import {
|
|
375
|
-
* CreateProcessInstanceResponse,
|
|
376
|
-
* DeployResourceResponse
|
|
377
|
-
* } from '@camunda8/sdk/dist/c8/lib/C8Dto';
|
|
369
|
+
* @import { TaskExecutionApi, TaskExecutionResult, TaskExecutionError, TaskExecutionStatus } from './types';
|
|
378
370
|
*/
|
|
379
371
|
|
|
380
|
-
|
|
381
|
-
const INTERVAL_MS = 1000;
|
|
382
|
-
|
|
383
372
|
/**
|
|
384
373
|
* Emits:
|
|
385
374
|
* - `taskExecution.status.changed` with one of {@link TaskExecutionStatus}
|
|
386
375
|
* - `taskExecution.finished` with {@link TaskExecutionResult}
|
|
387
376
|
* - `taskExecution.error` with {@link TaskExecutionError}
|
|
388
|
-
* - `taskExecution.interrupted` when execution is interrupted by switching focus
|
|
389
377
|
*/
|
|
390
378
|
class TaskExecution extends (events__WEBPACK_IMPORTED_MODULE_0___default()) {
|
|
391
379
|
/**
|
|
@@ -403,8 +391,11 @@ class TaskExecution extends (events__WEBPACK_IMPORTED_MODULE_0___default()) {
|
|
|
403
391
|
this._status = 'idle';
|
|
404
392
|
const eventBus = injector.get('eventBus');
|
|
405
393
|
eventBus.on(['selection.changed', 'commandStack.changed'], () => {
|
|
394
|
+
if (this._status !== 'idle') {
|
|
395
|
+
console.log('Interrupting task execution in TaskExecution');
|
|
396
|
+
this.emit('taskExecution.interrupted');
|
|
397
|
+
}
|
|
406
398
|
this.cancelTaskExecution();
|
|
407
|
-
this.emit('taskExecution.interrupted');
|
|
408
399
|
});
|
|
409
400
|
}
|
|
410
401
|
|
|
@@ -551,11 +542,14 @@ class TaskExecution extends (events__WEBPACK_IMPORTED_MODULE_0___default()) {
|
|
|
551
542
|
/**
|
|
552
543
|
* Get the process ID from the deployment response.
|
|
553
544
|
*
|
|
554
|
-
* @param {
|
|
545
|
+
* @param {import('./types').DeploymentResponse} [response]
|
|
555
546
|
*
|
|
556
547
|
* @returns {string|null} The process ID or null if not found.
|
|
557
548
|
*/
|
|
558
549
|
function getProcessId(response) {
|
|
550
|
+
if (!response) {
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
559
553
|
const {
|
|
560
554
|
processes = []
|
|
561
555
|
} = response;
|
|
@@ -570,11 +564,14 @@ function getProcessId(response) {
|
|
|
570
564
|
/**
|
|
571
565
|
* Get the process instance key from the response.
|
|
572
566
|
*
|
|
573
|
-
* @param {
|
|
567
|
+
* @param {import('./types').StartInstanceResponse} [response]
|
|
574
568
|
*
|
|
575
569
|
* @returns {string|null} The process instance key or null if not found.
|
|
576
570
|
*/
|
|
577
571
|
function getProcessInstanceKey(response) {
|
|
572
|
+
if (!response) {
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
578
575
|
const {
|
|
579
576
|
processInstanceKey
|
|
580
577
|
} = response;
|
|
@@ -1064,7 +1061,7 @@ function OutputBanner({
|
|
|
1064
1061
|
} : {};
|
|
1065
1062
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(ErrorBanner, {
|
|
1066
1063
|
title: "Task execution failed",
|
|
1067
|
-
description: `Incident: ${output.incident.
|
|
1064
|
+
description: `Incident: ${output.incident.errorType}`,
|
|
1068
1065
|
...action
|
|
1069
1066
|
});
|
|
1070
1067
|
}
|
|
@@ -1352,7 +1349,8 @@ const NO_ELEMENT_TEXT = 'Select a task to start testing';
|
|
|
1352
1349
|
* @param {import('../../types').Config|undefined} [props.config]
|
|
1353
1350
|
* @param {Function} [props.onConfigChanged=() => {}]
|
|
1354
1351
|
* @param {string} [props.operateBaseUrl]
|
|
1355
|
-
* @param {Function} [props.
|
|
1352
|
+
* @param {Function} [props.onTaskExecutionStarted=() => {}]
|
|
1353
|
+
* @param {Function} [props.onTaskExecutionFinished=() => {}]
|
|
1356
1354
|
* @param {Function} [props.onTaskExecutionInterrupted=() => {}]
|
|
1357
1355
|
*/
|
|
1358
1356
|
function TaskTesting({
|
|
@@ -1366,7 +1364,8 @@ function TaskTesting({
|
|
|
1366
1364
|
config,
|
|
1367
1365
|
onConfigChanged = () => {},
|
|
1368
1366
|
operateBaseUrl,
|
|
1369
|
-
|
|
1367
|
+
onTaskExecutionStarted = () => {},
|
|
1368
|
+
onTaskExecutionFinished = () => {},
|
|
1370
1369
|
onTaskExecutionInterrupted = () => {}
|
|
1371
1370
|
}) {
|
|
1372
1371
|
/**
|
|
@@ -1503,17 +1502,22 @@ function TaskTesting({
|
|
|
1503
1502
|
...output,
|
|
1504
1503
|
operateUrl
|
|
1505
1504
|
});
|
|
1505
|
+
onTaskExecutionFinished(element, output);
|
|
1506
|
+
};
|
|
1507
|
+
const handleInterrupted = () => {
|
|
1508
|
+
console.log('interrrrrrupted');
|
|
1509
|
+
onTaskExecutionInterrupted();
|
|
1506
1510
|
};
|
|
1507
1511
|
taskExecutionRef === null || taskExecutionRef === void 0 || (_taskExecutionRef$cur = taskExecutionRef.current) === null || _taskExecutionRef$cur === void 0 || _taskExecutionRef$cur.on('taskExecution.finished', handleFinished);
|
|
1508
1512
|
taskExecutionRef === null || taskExecutionRef === void 0 || (_taskExecutionRef$cur2 = taskExecutionRef.current) === null || _taskExecutionRef$cur2 === void 0 || _taskExecutionRef$cur2.on('taskExecution.status.changed', handleStatusChange);
|
|
1509
1513
|
taskExecutionRef === null || taskExecutionRef === void 0 || (_taskExecutionRef$cur3 = taskExecutionRef.current) === null || _taskExecutionRef$cur3 === void 0 || _taskExecutionRef$cur3.on('taskExecution.error', handleError);
|
|
1510
|
-
taskExecutionRef === null || taskExecutionRef === void 0 || (_taskExecutionRef$cur4 = taskExecutionRef.current) === null || _taskExecutionRef$cur4 === void 0 || _taskExecutionRef$cur4.on('taskExecution.interrupted',
|
|
1514
|
+
taskExecutionRef === null || taskExecutionRef === void 0 || (_taskExecutionRef$cur4 = taskExecutionRef.current) === null || _taskExecutionRef$cur4 === void 0 || _taskExecutionRef$cur4.on('taskExecution.interrupted', handleInterrupted);
|
|
1511
1515
|
return () => {
|
|
1512
1516
|
if (taskExecutionRef.current) {
|
|
1513
1517
|
taskExecutionRef.current.off('taskExecution.finished', handleFinished);
|
|
1514
1518
|
taskExecutionRef.current.off('taskExecution.status.changed', handleStatusChange);
|
|
1515
1519
|
taskExecutionRef.current.off('taskExecution.error', handleError);
|
|
1516
|
-
taskExecutionRef.current.off('taskExecution.interrupted',
|
|
1520
|
+
taskExecutionRef.current.off('taskExecution.interrupted', handleInterrupted);
|
|
1517
1521
|
}
|
|
1518
1522
|
};
|
|
1519
1523
|
}, [element]);
|
|
@@ -1547,14 +1551,17 @@ function TaskTesting({
|
|
|
1547
1551
|
if (!isConnectionConfigured || inputError || !element || !taskExecutionRef.current || !elementConfigRef.current) {
|
|
1548
1552
|
return;
|
|
1549
1553
|
}
|
|
1554
|
+
onTaskExecutionStarted(element);
|
|
1550
1555
|
const inputConfig = await elementConfigRef.current.getInputConfigForElement(element);
|
|
1551
1556
|
elementConfigRef.current.setOutputConfigForElement(element, null);
|
|
1552
1557
|
taskExecutionRef.current.executeTask(element.id, JSON.parse(inputConfig));
|
|
1553
|
-
onTaskExecution();
|
|
1554
1558
|
};
|
|
1555
1559
|
const handleCancelTaskExecution = () => {
|
|
1556
|
-
|
|
1557
|
-
|
|
1560
|
+
var _taskExecutionRef$cur5;
|
|
1561
|
+
taskExecutionRef === null || taskExecutionRef === void 0 || (_taskExecutionRef$cur5 = taskExecutionRef.current) === null || _taskExecutionRef$cur5 === void 0 || _taskExecutionRef$cur5.cancelTaskExecution();
|
|
1562
|
+
if (output !== null && output !== void 0 && output.operateUrl && Object.keys(output).length === 1) {
|
|
1563
|
+
var _elementConfigRef$cur7;
|
|
1564
|
+
elementConfigRef === null || elementConfigRef === void 0 || (_elementConfigRef$cur7 = elementConfigRef.current) === null || _elementConfigRef$cur7 === void 0 || _elementConfigRef$cur7.setOutputConfigForElement(element, null);
|
|
1558
1565
|
}
|
|
1559
1566
|
};
|
|
1560
1567
|
const handleResetOutput = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
|
|
@@ -2831,8 +2838,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2831
2838
|
/* harmony import */ var bpmn_js_lib_util_ModelUtil__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! bpmn-js/lib/util/ModelUtil */ "./node_modules/bpmn-js/lib/util/ModelUtil.js");
|
|
2832
2839
|
/* harmony import */ var _util_CachedValue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/CachedValue */ "./node_modules/@bpmn-io/variable-resolver/lib/base/util/CachedValue.js");
|
|
2833
2840
|
/* harmony import */ var _util_scopeUtil__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util/scopeUtil */ "./node_modules/@bpmn-io/variable-resolver/lib/base/util/scopeUtil.js");
|
|
2834
|
-
/* harmony import */ var min_dash__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! min-dash */ "./node_modules/min-dash/dist/index.esm.js");
|
|
2835
|
-
|
|
2836
2841
|
|
|
2837
2842
|
|
|
2838
2843
|
|
|
@@ -2851,6 +2856,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2851
2856
|
* @typedef {AdditionalVariable} ProcessVariable
|
|
2852
2857
|
* @property {Array<ModdleElement>} origin
|
|
2853
2858
|
* @property {ModdleElement} scope
|
|
2859
|
+
* @property {Array<Object>} provider
|
|
2854
2860
|
*/
|
|
2855
2861
|
|
|
2856
2862
|
/**
|
|
@@ -2883,7 +2889,7 @@ class BaseVariableResolver {
|
|
|
2883
2889
|
}
|
|
2884
2890
|
|
|
2885
2891
|
/**
|
|
2886
|
-
* To be implemented by
|
|
2892
|
+
* To be implemented by a subclass. This should be an instance of `getProcessVariables` from `@bpmn-io/extract-process-variables`,
|
|
2887
2893
|
* either C7 or C8.
|
|
2888
2894
|
*
|
|
2889
2895
|
* @returns {Promise<Array<ProcessVariable>>}
|
|
@@ -3092,24 +3098,40 @@ class BaseVariableResolver {
|
|
|
3092
3098
|
const root = getRootElement(bo);
|
|
3093
3099
|
const allVariables = await this.getProcessVariables(root);
|
|
3094
3100
|
|
|
3095
|
-
// keep only unique variables based on name property
|
|
3096
|
-
const uniqueVariables = (0,min_dash__WEBPACK_IMPORTED_MODULE_3__.uniqueBy)('name', allVariables.reverse());
|
|
3097
|
-
|
|
3098
3101
|
// (1) get variables for given scope
|
|
3099
|
-
var scopeVariables =
|
|
3102
|
+
var scopeVariables = allVariables.filter(function(variable) {
|
|
3100
3103
|
return variable.scope.id === bo.id;
|
|
3101
3104
|
});
|
|
3102
3105
|
|
|
3103
3106
|
// (2) get variables for parent scopes
|
|
3104
3107
|
var parents = (0,_util_scopeUtil__WEBPACK_IMPORTED_MODULE_1__.getParents)(bo);
|
|
3105
3108
|
|
|
3106
|
-
var parentsScopeVariables =
|
|
3109
|
+
var parentsScopeVariables = allVariables.filter(function(variable) {
|
|
3107
3110
|
return parents.find(function(parent) {
|
|
3108
3111
|
return parent.id === variable.scope.id;
|
|
3109
3112
|
});
|
|
3110
3113
|
});
|
|
3111
3114
|
|
|
3112
|
-
|
|
3115
|
+
const reversedVariables = [ ...scopeVariables, ...parentsScopeVariables ].reverse();
|
|
3116
|
+
|
|
3117
|
+
const seenNames = new Set();
|
|
3118
|
+
|
|
3119
|
+
return reversedVariables.filter(variable => {
|
|
3120
|
+
|
|
3121
|
+
// if external variable, keep
|
|
3122
|
+
if (variable.provider.find(extractor => extractor !== this._baseExtractor)) {
|
|
3123
|
+
return true;
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
// if not external, keep only the first occurrence of each name
|
|
3127
|
+
if (!seenNames.has(variable.name)) {
|
|
3128
|
+
seenNames.add(variable.name);
|
|
3129
|
+
|
|
3130
|
+
return true;
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
return false;
|
|
3134
|
+
});
|
|
3113
3135
|
}
|
|
3114
3136
|
}
|
|
3115
3137
|
|