bpmn-server / ScriptHandler
Class: ScriptHandler#
Hierarchy#
ScriptHandler
Implements#
Table of contents#
Constructors#
Properties#
Methods#
- standardValues
- namesRead
- executionOf
- appVarsOf
- 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:24
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:22
reads#
▪ Static Private reads: Map\<string, Set\<string>>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:49
Methods#
standardValues#
▸ standardValues(scope, materialized?): Record\<string, any>
The names every expression sees besides the scope's own (docs/design/expressions.md): user (the operation's,
by name), and the add-ons' names for the item's place (engine/AddOns.ts: the policies' add-ons' actors). An
application's script context of the same name is used instead. materialized: plain values, for the sandbox.
Parameters#
| Name | Type | Default value |
|---|---|---|
scope |
any |
undefined |
materialized |
boolean |
false |
Returns#
Record\<string, any>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:36
namesRead#
▸ namesRead(body): Set\<string>
The names a script reads without declaring them (Expressions.freeNames), remembered by its text.
Parameters#
| Name | Type |
|---|---|
body |
string |
Returns#
Set\<string>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:51
executionOf#
▸ executionOf(scope): any
The execution a scope (an item, a token, an execution) is of.
Parameters#
| Name | Type |
|---|---|
scope |
any |
Returns#
any
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:62
appVarsOf#
▸ appVarsOf(scope, text): Promise\<Record\<string, any>>
The application's variables a text reads (appVars.evaluatingSource). None read: none asked.
Parameters#
| Name | Type |
|---|---|
scope |
any |
text |
string |
Returns#
Promise\<Record\<string, any>>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:73
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:94
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:105
evaluateFeel#
▸ evaluateFeel(scope, expression): Promise\<unknown>
A FEEL expression, with the names every expression sees (docs/design/expressions.md): the data's fields by name,
data, this and item, instance, input, output, actors, user, appServices. A call to an async
service, as the whole expression, is awaited.
Parameters#
| Name | Type |
|---|---|
scope |
any |
expression |
any |
Returns#
Promise\<unknown>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:116
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:155
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:183
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:214
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:268
compiled#
▸ compiled(scope, body, label): Promise\<any>
Runs a script, with the context's variables as its parameters.
Parameters#
| Name | Type |
|---|---|
scope |
any |
body |
string |
label |
string |
Returns#
Promise\<any>
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:276
scriptName#
▸ scriptName(scope, label): string
bpmn:///
Parameters#
| Name | Type |
|---|---|
scope |
any |
label |
string |
Returns#
string
Defined in#
packages/bpmn-server/src/engine/ScriptHandler.ts:286
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 data=this.instance.data; // a process's own script: the instance's data, at the top\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 data=this.instance.data; // a process's own script: the instance's data, at the top\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:291
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:333