-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cron time cycle by overloading parse function
- Loading branch information
Showing
19 changed files
with
997 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
declare module '@onify/flow-extensions' { | ||
import { SequenceFlow, ElementBase, Context, IExtension } from 'bpmn-elements'; | ||
import { SequenceFlow, TimerEventDefinition, ElementBase, Context, IExtension } from 'bpmn-elements'; | ||
import { extendFn as extendFunction } from 'moddle-context-serializer'; | ||
|
||
export class OnifySequenceFlow extends SequenceFlow {} | ||
export class OnifyTimerEventDefinition extends TimerEventDefinition { | ||
readonly supports: string[]; | ||
} | ||
export function extensions(element: ElementBase, context: Context): IExtension; | ||
export const extendFn: extendFunction; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@onify/flow-extensions", | ||
"version": "5.0.2", | ||
"version": "6.0.0", | ||
"description": "Onify Flow extensions", | ||
"type": "module", | ||
"module": "src/index.js", | ||
|
@@ -38,26 +38,30 @@ | |
"license": "MIT", | ||
"devDependencies": { | ||
"@aircall/expression-parser": "^1.0.4", | ||
"@babel/cli": "^7.21.5", | ||
"@babel/core": "^7.21.8", | ||
"@babel/preset-env": "^7.21.5", | ||
"@babel/register": "^7.21.0", | ||
"@babel/cli": "^7.23.4", | ||
"@babel/core": "^7.23.5", | ||
"@babel/preset-env": "^7.23.5", | ||
"@babel/register": "^7.22.15", | ||
"bpmn-elements-8-1": "npm:[email protected]", | ||
"bpmn-engine": "^16.0.0", | ||
"bpmn-engine": "^17.1.1", | ||
"bpmn-engine-14": "npm:bpmn-engine@14", | ||
"bpmn-moddle": "^8.0.1", | ||
"c8": "^7.13.0", | ||
"c8": "^8.0.1", | ||
"camunda-bpmn-moddle": "^7.0.1", | ||
"chai": "^4.3.7", | ||
"chronokinesis": "^5.0.2", | ||
"chai": "^4.3.10", | ||
"chronokinesis": "^6.0.0", | ||
"debug": "^4.3.4", | ||
"eslint": "^8.39.0", | ||
"eslint": "^8.55.0", | ||
"eslint-plugin-import": "^2.29.0", | ||
"mocha": "^10.2.0", | ||
"mocha-cakes-2": "^3.3.0", | ||
"moddle-context-serializer": "^3.2.2" | ||
"moddle-context-serializer": "^4.1.1" | ||
}, | ||
"peerDependencies": { | ||
"bpmn-elements": ">=8" | ||
}, | ||
"dependencies": { | ||
"cron-parser": "^4.8.1" | ||
"cron-parser": "^4.9.0" | ||
}, | ||
"files": [ | ||
"src", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { TimerEventDefinition } from 'bpmn-elements'; | ||
import cronParser from 'cron-parser'; | ||
|
||
export class OnifyTimerEventDefinition extends TimerEventDefinition { | ||
constructor(activity, def) { | ||
super(activity, def); | ||
Object.defineProperty(this, 'supports', { | ||
value: ['cron'], | ||
}); | ||
} | ||
parse(timerType, value) { | ||
let cron; | ||
if (timerType === 'timeCycle' && (cron = cronParser.parseString(value))) { | ||
if (cron.expressions?.length) { | ||
// cronParser.parseString expressions disregards seconds, so we have to parse again | ||
const expireAt = cronParser.parseExpression(value).next().toDate(); | ||
return { | ||
expireAt, | ||
delay: expireAt - Date.now(), | ||
}; | ||
} | ||
} | ||
return super.parse(timerType, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.