@onify/flow-extensions 5.0.1 → 6.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.
- package/CHANGELOG.md +9 -0
- package/dist/FlowScripts.js +0 -1
- package/dist/OnifyTimerEventDefinition.js +33 -0
- package/dist/formatters.js +2 -0
- package/dist/index.js +7 -0
- package/index.d.ts +4 -1
- package/package.json +17 -13
- package/src/OnifyTimerEventDefinition.js +25 -0
- package/src/formatters.js +1 -0
- package/src/index.js +6 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
# 6.0.0
|
|
5
|
+
|
|
6
|
+
- Require peer dependency `bpmn-elements >= 8`
|
|
7
|
+
- Support timer event definition cron time cycle by overloading parse function. Requires `bpmn-elements >= 10`
|
|
8
|
+
|
|
9
|
+
# 5.0.2
|
|
10
|
+
|
|
11
|
+
- Correct package module file...
|
|
12
|
+
|
|
4
13
|
# 5.0.1
|
|
5
14
|
|
|
6
15
|
- Doh! Add neglected package.json file to common js dist folder
|
package/dist/FlowScripts.js
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OnifyTimerEventDefinition = void 0;
|
|
7
|
+
var _bpmnElements = require("bpmn-elements");
|
|
8
|
+
var _cronParser = _interopRequireDefault(require("cron-parser"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
class OnifyTimerEventDefinition extends _bpmnElements.TimerEventDefinition {
|
|
11
|
+
constructor(activity, def) {
|
|
12
|
+
super(activity, def);
|
|
13
|
+
Object.defineProperty(this, 'supports', {
|
|
14
|
+
value: ['cron']
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
parse(timerType, value) {
|
|
18
|
+
let cron;
|
|
19
|
+
if (timerType === 'timeCycle' && (cron = _cronParser.default.parseString(value))) {
|
|
20
|
+
var _cron$expressions;
|
|
21
|
+
if ((_cron$expressions = cron.expressions) !== null && _cron$expressions !== void 0 && _cron$expressions.length) {
|
|
22
|
+
// cronParser.parseString expressions disregards seconds, so we have to parse again
|
|
23
|
+
const expireAt = _cronParser.default.parseExpression(value).next().toDate();
|
|
24
|
+
return {
|
|
25
|
+
expireAt,
|
|
26
|
+
delay: expireAt - Date.now()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return super.parse(timerType, value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.OnifyTimerEventDefinition = OnifyTimerEventDefinition;
|
package/dist/formatters.js
CHANGED
|
@@ -14,6 +14,8 @@ class FormatActivity {
|
|
|
14
14
|
let timeCycles;
|
|
15
15
|
if (activity.eventDefinitions) {
|
|
16
16
|
for (const ed of activity.eventDefinitions.filter(e => e.type === 'bpmn:TimerEventDefinition')) {
|
|
17
|
+
var _ed$supports;
|
|
18
|
+
if ((_ed$supports = ed.supports) !== null && _ed$supports !== void 0 && _ed$supports.includes('cron')) continue;
|
|
17
19
|
if (!('timeCycle' in ed)) continue;
|
|
18
20
|
timeCycles = timeCycles || [];
|
|
19
21
|
timeCycles.push(ed.timeCycle);
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,18 @@ Object.defineProperty(exports, "OnifySequenceFlow", {
|
|
|
9
9
|
return _OnifySequenceFlow.OnifySequenceFlow;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "OnifyTimerEventDefinition", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _OnifyTimerEventDefinition.OnifyTimerEventDefinition;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
exports.extendFn = extendFn;
|
|
13
19
|
exports.extensions = extensions;
|
|
14
20
|
var _OnifyProcessExtensions = require("./OnifyProcessExtensions.js");
|
|
15
21
|
var _OnifyElementExtensions = require("./OnifyElementExtensions.js");
|
|
16
22
|
var _OnifySequenceFlow = require("./OnifySequenceFlow.js");
|
|
23
|
+
var _OnifyTimerEventDefinition = require("./OnifyTimerEventDefinition.js");
|
|
17
24
|
function extensions(element, context) {
|
|
18
25
|
if (element.type === 'bpmn:Process') return new _OnifyProcessExtensions.OnifyProcessExtensions(element, context);
|
|
19
26
|
return new _OnifyElementExtensions.OnifyElementExtensions(element, context);
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
declare module '@onify/flow-extensions' {
|
|
2
|
-
import { SequenceFlow, ElementBase, Context, IExtension } from 'bpmn-elements';
|
|
2
|
+
import { SequenceFlow, TimerEventDefinition, ElementBase, Context, IExtension } from 'bpmn-elements';
|
|
3
3
|
import { extendFn as extendFunction } from 'moddle-context-serializer';
|
|
4
4
|
|
|
5
5
|
export class OnifySequenceFlow extends SequenceFlow {}
|
|
6
|
+
export class OnifyTimerEventDefinition extends TimerEventDefinition {
|
|
7
|
+
readonly supports: string[];
|
|
8
|
+
}
|
|
6
9
|
export function extensions(element: ElementBase, context: Context): IExtension;
|
|
7
10
|
export const extendFn: extendFunction;
|
|
8
11
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onify/flow-extensions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Onify Flow extensions",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"module": "index.js",
|
|
6
|
+
"module": "src/index.js",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "./index.d.ts",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -38,26 +38,30 @@
|
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@aircall/expression-parser": "^1.0.4",
|
|
41
|
-
"@babel/cli": "^7.
|
|
42
|
-
"@babel/core": "^7.
|
|
43
|
-
"@babel/preset-env": "^7.
|
|
44
|
-
"@babel/register": "^7.
|
|
41
|
+
"@babel/cli": "^7.23.4",
|
|
42
|
+
"@babel/core": "^7.23.5",
|
|
43
|
+
"@babel/preset-env": "^7.23.5",
|
|
44
|
+
"@babel/register": "^7.22.15",
|
|
45
45
|
"bpmn-elements-8-1": "npm:bpmn-elements@8.1",
|
|
46
|
-
"bpmn-engine": "^
|
|
46
|
+
"bpmn-engine": "^17.1.1",
|
|
47
47
|
"bpmn-engine-14": "npm:bpmn-engine@14",
|
|
48
48
|
"bpmn-moddle": "^8.0.1",
|
|
49
|
-
"c8": "^
|
|
49
|
+
"c8": "^8.0.1",
|
|
50
50
|
"camunda-bpmn-moddle": "^7.0.1",
|
|
51
|
-
"chai": "^4.3.
|
|
52
|
-
"chronokinesis": "^
|
|
51
|
+
"chai": "^4.3.10",
|
|
52
|
+
"chronokinesis": "^6.0.0",
|
|
53
53
|
"debug": "^4.3.4",
|
|
54
|
-
"eslint": "^8.
|
|
54
|
+
"eslint": "^8.55.0",
|
|
55
|
+
"eslint-plugin-import": "^2.29.0",
|
|
55
56
|
"mocha": "^10.2.0",
|
|
56
57
|
"mocha-cakes-2": "^3.3.0",
|
|
57
|
-
"moddle-context-serializer": "^
|
|
58
|
+
"moddle-context-serializer": "^4.1.1"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"bpmn-elements": ">=8"
|
|
58
62
|
},
|
|
59
63
|
"dependencies": {
|
|
60
|
-
"cron-parser": "^4.
|
|
64
|
+
"cron-parser": "^4.9.0"
|
|
61
65
|
},
|
|
62
66
|
"files": [
|
|
63
67
|
"src",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TimerEventDefinition } from 'bpmn-elements';
|
|
2
|
+
import cronParser from 'cron-parser';
|
|
3
|
+
|
|
4
|
+
export class OnifyTimerEventDefinition extends TimerEventDefinition {
|
|
5
|
+
constructor(activity, def) {
|
|
6
|
+
super(activity, def);
|
|
7
|
+
Object.defineProperty(this, 'supports', {
|
|
8
|
+
value: ['cron'],
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
parse(timerType, value) {
|
|
12
|
+
let cron;
|
|
13
|
+
if (timerType === 'timeCycle' && (cron = cronParser.parseString(value))) {
|
|
14
|
+
if (cron.expressions?.length) {
|
|
15
|
+
// cronParser.parseString expressions disregards seconds, so we have to parse again
|
|
16
|
+
const expireAt = cronParser.parseExpression(value).next().toDate();
|
|
17
|
+
return {
|
|
18
|
+
expireAt,
|
|
19
|
+
delay: expireAt - Date.now(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return super.parse(timerType, value);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/formatters.js
CHANGED
|
@@ -10,6 +10,7 @@ export class FormatActivity {
|
|
|
10
10
|
let timeCycles;
|
|
11
11
|
if (activity.eventDefinitions) {
|
|
12
12
|
for (const ed of activity.eventDefinitions.filter((e) => e.type === 'bpmn:TimerEventDefinition')) {
|
|
13
|
+
if (ed.supports?.includes('cron')) continue;
|
|
13
14
|
if (!('timeCycle' in ed)) continue;
|
|
14
15
|
timeCycles = timeCycles || [];
|
|
15
16
|
timeCycles.push(ed.timeCycle);
|
package/src/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import {OnifyProcessExtensions} from './OnifyProcessExtensions.js';
|
|
2
|
-
import {OnifyElementExtensions} from './OnifyElementExtensions.js';
|
|
3
|
-
|
|
1
|
+
import { OnifyProcessExtensions } from './OnifyProcessExtensions.js';
|
|
2
|
+
import { OnifyElementExtensions } from './OnifyElementExtensions.js';
|
|
3
|
+
export { OnifySequenceFlow } from './OnifySequenceFlow.js';
|
|
4
|
+
export { OnifyTimerEventDefinition } from './OnifyTimerEventDefinition.js';
|
|
4
5
|
|
|
5
|
-
export {
|
|
6
|
-
extensions,
|
|
7
|
-
extendFn,
|
|
8
|
-
OnifySequenceFlow,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
function extensions(element, context) {
|
|
6
|
+
export function extensions(element, context) {
|
|
12
7
|
if (element.type === 'bpmn:Process') return new OnifyProcessExtensions(element, context);
|
|
13
8
|
return new OnifyElementExtensions(element, context);
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
function extendFn(behaviour, context) {
|
|
11
|
+
export function extendFn(behaviour, context) {
|
|
17
12
|
if (behaviour.$type === 'bpmn:StartEvent' && behaviour.eventDefinitions) {
|
|
18
13
|
const timer = behaviour.eventDefinitions.find(({type, behaviour: edBehaviour}) => edBehaviour && type === 'bpmn:TimerEventDefinition');
|
|
19
14
|
if (timer && timer.behaviour.timeCycle) Object.assign(behaviour, {scheduledStart: timer.behaviour.timeCycle});
|