@onify/flow-extensions 8.0.1 → 8.0.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.
|
@@ -7,23 +7,30 @@ exports.OnifyTimerEventDefinition = void 0;
|
|
|
7
7
|
var _cronParser = _interopRequireDefault(require("cron-parser"));
|
|
8
8
|
var _bpmnElements = require("bpmn-elements");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const invalidCronEntryPattern = /Invalid (characters|range)/i;
|
|
10
11
|
class OnifyTimerEventDefinition extends _bpmnElements.TimerEventDefinition {
|
|
11
12
|
constructor(activity, def) {
|
|
12
13
|
super(activity, def);
|
|
13
14
|
Object.defineProperty(this, 'supports', {
|
|
14
|
-
value: ['cron']
|
|
15
|
+
value: ['cron', 'iso8601']
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
parse(timerType, value) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (timerType === 'timeCycle') {
|
|
20
|
+
try {
|
|
21
|
+
return super.parse(timerType, value);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
var rangeError = err;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
22
26
|
const expireAt = _cronParser.default.parseExpression(value).next().toDate();
|
|
23
27
|
return {
|
|
24
28
|
expireAt,
|
|
25
29
|
delay: expireAt - Date.now()
|
|
26
30
|
};
|
|
31
|
+
} catch (err) {
|
|
32
|
+
if (invalidCronEntryPattern.test(err.message)) throw rangeError;
|
|
33
|
+
throw err;
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
return super.parse(timerType, value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onify/flow-extensions",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Onify Flow extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "mocha -R dot",
|
|
24
|
-
"posttest": "npm run lint && npm run dist",
|
|
24
|
+
"posttest": "npm run lint && npm run dist && texample",
|
|
25
25
|
"lint": "eslint . --cache && prettier . --check --cache",
|
|
26
26
|
"prepare": "npm run dist",
|
|
27
27
|
"dist": "babel src -d dist && babel test/helpers/FlowScripts.js -d dist",
|
|
28
|
-
"test:md": "node --experimental-vm-modules --no-warnings scripts/test-markdown.js ./README.md",
|
|
29
28
|
"test:lcov": "c8 -r lcov mocha && npm run lint",
|
|
30
29
|
"cov:html": "c8 mocha -R dot && c8 report --reporter html"
|
|
31
30
|
},
|
|
@@ -52,7 +51,7 @@
|
|
|
52
51
|
"@babel/preset-env": "^7.23.9",
|
|
53
52
|
"@babel/register": "^7.23.7",
|
|
54
53
|
"bpmn-elements-8-1": "npm:bpmn-elements@8.1",
|
|
55
|
-
"bpmn-engine": "^
|
|
54
|
+
"bpmn-engine": "^21.1.0",
|
|
56
55
|
"bpmn-engine-14": "npm:bpmn-engine@14",
|
|
57
56
|
"bpmn-moddle": "^9.0.1",
|
|
58
57
|
"c8": "^9.1.0",
|
|
@@ -60,18 +59,19 @@
|
|
|
60
59
|
"chai": "^5.0.3",
|
|
61
60
|
"chronokinesis": "^6.0.0",
|
|
62
61
|
"debug": "^4.3.4",
|
|
63
|
-
"eslint": "^9.
|
|
62
|
+
"eslint": "^9.3.0",
|
|
64
63
|
"mocha": "^10.2.0",
|
|
65
64
|
"mocha-cakes-2": "^3.3.0",
|
|
66
65
|
"moddle-context-serializer": "^4.1.1",
|
|
67
66
|
"nock": "^13.5.4",
|
|
68
|
-
"prettier": "^3.2.4"
|
|
67
|
+
"prettier": "^3.2.4",
|
|
68
|
+
"texample": "^0.0.5"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"bpmn-elements": "^14.
|
|
71
|
+
"bpmn-elements": "^14.1.0"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@0dep/piso": "^0.1.
|
|
74
|
+
"@0dep/piso": "^0.1.4",
|
|
75
75
|
"cron-parser": "^4.9.0"
|
|
76
76
|
},
|
|
77
77
|
"files": [
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"exclude": [
|
|
85
85
|
"dist",
|
|
86
86
|
"test",
|
|
87
|
-
".mocharc.cjs",
|
|
88
87
|
"babel.config.cjs"
|
|
89
88
|
]
|
|
90
89
|
}
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import cronParser from 'cron-parser';
|
|
2
2
|
import { TimerEventDefinition } from 'bpmn-elements';
|
|
3
3
|
|
|
4
|
+
const invalidCronEntryPattern = /Invalid (characters|range)/i;
|
|
5
|
+
|
|
4
6
|
export class OnifyTimerEventDefinition extends TimerEventDefinition {
|
|
5
7
|
constructor(activity, def) {
|
|
6
8
|
super(activity, def);
|
|
7
9
|
Object.defineProperty(this, 'supports', {
|
|
8
|
-
value: ['cron'],
|
|
10
|
+
value: ['cron', 'iso8601'],
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
parse(timerType, value) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (timerType === 'timeCycle') {
|
|
15
|
+
try {
|
|
16
|
+
return super.parse(timerType, value);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
var rangeError = err;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
16
22
|
const expireAt = cronParser.parseExpression(value).next().toDate();
|
|
17
23
|
|
|
18
24
|
return {
|
|
19
25
|
expireAt,
|
|
20
26
|
delay: expireAt - Date.now(),
|
|
21
27
|
};
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if (invalidCronEntryPattern.test(err.message)) throw rangeError;
|
|
30
|
+
throw err;
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
declare module '@onify/flow-extensions' {
|
|
2
|
-
import { SequenceFlow, TimerEventDefinition, ElementBase, IExtension } from 'bpmn-elements';
|
|
2
|
+
import { SequenceFlow, TimerEventDefinition, ElementBase, IExtension, ContextInstance } from 'bpmn-elements';
|
|
3
3
|
import { extendFn as extendFunction } from 'moddle-context-serializer';
|
|
4
4
|
|
|
5
5
|
export class OnifySequenceFlow extends SequenceFlow {}
|
|
6
6
|
export class OnifyTimerEventDefinition extends TimerEventDefinition {
|
|
7
7
|
readonly supports: string[];
|
|
8
8
|
}
|
|
9
|
-
export function extensions(element: ElementBase, context:
|
|
9
|
+
export function extensions(element: ElementBase, context: ContextInstance): IExtension;
|
|
10
10
|
export const extendFn: extendFunction;
|
|
11
11
|
}
|
|
12
12
|
|