bpmn-server / ScriptHandler
Class: ScriptHandler#
Hierarchy#
ScriptHandler
Implements#
Table of contents#
Constructors#
Properties#
Methods#
- contextValues
- evaluateCondition
- evaluateFeel
- evaluateInputExpression
- evaluateExpression
- executeScript
- compile
- compiled
- scriptName
- getJSvars
- runPython
Constructors#
constructor#
• new ScriptHandler(options?): ScriptHandler
Parameters#
| Name | Type |
|---|---|
options |
Object |
options.context? |
ScriptContext |
Returns#
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:21
Properties#
context#
• context: ScriptContext = {}
Variables scripts and expressions see besides their own, by name. The application sets it; models can not.
Implementation of#
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:19
Methods#
contextValues#
▸ contextValues(scope): Record\<string, any>
The context's values for a scope.
Parameters#
| Name | Type |
|---|---|
scope |
any |
Returns#
Record\<string, any>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:29
evaluateCondition#
▸ evaluateCondition(scope, expression, language?, label?): Promise\<any>
A sequence flow's condition, in the language it says: FEEL when it says so, any other is JavaScript. A ${...} around it is a wrapper, whatever the language.
Parameters#
| Name | Type | Default value |
|---|---|---|
scope |
Token | Item |
undefined |
expression |
any |
undefined |
language? |
string |
undefined |
label |
string |
'condition' |
Returns#
Promise\<any>
Implementation of#
IScriptHandler.evaluateCondition
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:40
evaluateFeel#
▸ evaluateFeel(scope, expression): Promise\<unknown>
A FEEL expression over the data: its values by name, and data itself.
Parameters#
| Name | Type |
|---|---|
scope |
any |
expression |
any |
Returns#
Promise\<unknown>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:47
evaluateInputExpression#
▸ evaluateInputExpression(item, exp, dateFormat?): Promise\<any>
- these expression are strings with $
- scenarios:
- String =>as is
- \(javaScript =>evaulated (\)js, $(js) or ${js})
- a ${js} b =>the text, each ${js} evaluated in its place
- a , b , c =>array
- dateString =>convert to date
- Examples:
- ['T',
user1], ['T',$(appServices.test1(100))], ['T',$(appServices.getSupervisorUser('user1'))], ['T',abc,xyz,user group], ['TD',2022-10-11], - appDelegate.scopeEval -->evaluateExpression
- appDelegate.scopeJS -->executeScript *
Parameters#
| Name | Type | Default value |
|---|---|---|
item |
any |
undefined |
exp |
any |
undefined |
dateFormat |
boolean |
false |
Returns#
Promise\<any>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:74
evaluateExpression#
▸ evaluateExpression(scope, expression, label?): Promise\<any>
execute JavaScript expression , no need for $
Parameters#
| Name | Type | Default value |
|---|---|---|
scope |
Token | Item |
undefined |
expression |
any |
undefined |
label |
string |
'expression' |
Returns#
Promise\<any>
Implementation of#
IScriptHandler.evaluateExpression
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:102
executeScript#
▸ executeScript(scope, script, label?): Promise\<any>
label: which script it is (an event's, a script task's): its name for debuggers and errors
Parameters#
| Name | Type | Default value |
|---|---|---|
scope |
Execution | Item |
undefined |
script |
any |
undefined |
label |
string |
'script' |
Returns#
Promise\<any>
Implementation of#
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:133
compile#
▸ compile(scope, body, label, names?): Function
A model's script or expression as a function of its scope, named after where it is in the model
(bpmn:///
Parameters#
| Name | Type | Default value |
|---|---|---|
scope |
any |
undefined |
body |
string |
undefined |
label |
string |
undefined |
names |
string[] |
[] |
Returns#
Function
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:187
compiled#
▸ compiled(scope, body, label): any
Runs a script, with the context's variables as its parameters.
Parameters#
| Name | Type |
|---|---|
scope |
any |
body |
string |
label |
string |
Returns#
any
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:195
scriptName#
▸ scriptName(scope, label): string
bpmn:///
Parameters#
| Name | Type |
|---|---|
scope |
any |
label |
string |
Returns#
string
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:200
getJSvars#
▸ getJSvars(scope): "\n var data=this.data;\n var instance=this.execution.instance;\n var input=this.input;\n var output=this.output;\n var appDelegate=this.execution.appDelegate;\n var appServices=this.execution.servicesProvider;\n var appUtils=appDelegate.appUtils;\n var item=this; // for backward support only\n " | "\n var appDelegate=this.appDelegate;\n var instance=this.instance;\n var appServices=this.servicesProvider;\n var appUtils=appDelegate.appUtils;\n " | "\n var item=this;\n var data=this.data;\n var instance=this.token.execution.instance;\n var input=this.input;\n var output=this.output;\n var appDelegate=this.token.execution.appDelegate;\n var appServices=this.token.execution.servicesProvider;\n var appUtils=appDelegate.appUtils;\n "
Parameters#
| Name | Type |
|---|---|
scope |
any |
Returns#
"\n var data=this.data;\n var instance=this.execution.instance;\n var input=this.input;\n var output=this.output;\n var appDelegate=this.execution.appDelegate;\n var appServices=this.execution.servicesProvider;\n var appUtils=appDelegate.appUtils;\n var item=this; // for backward support only\n " | "\n var appDelegate=this.appDelegate;\n var instance=this.instance;\n var appServices=this.servicesProvider;\n var appUtils=appDelegate.appUtils;\n " | "\n var item=this;\n var data=this.data;\n var instance=this.token.execution.instance;\n var input=this.input;\n var output=this.output;\n var appDelegate=this.token.execution.appDelegate;\n var appServices=this.token.execution.servicesProvider;\n var appUtils=appDelegate.appUtils;\n "
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:205
runPython#
▸ runPython(item, code, input?): Promise\<any>
Parameters#
| Name | Type |
|---|---|
item |
any |
code |
string |
input |
any |
Returns#
Promise\<any>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:246