mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add $env function to JSONata expressions
This commit is contained in:
parent
e13fed9fc6
commit
9ad9c0ec6a
1
editor/vendor/jsonata/formatter.js
vendored
1
editor/vendor/jsonata/formatter.js
vendored
@ -117,6 +117,7 @@
|
|||||||
'$contains':{ args:[ 'str', 'pattern' ]},
|
'$contains':{ args:[ 'str', 'pattern' ]},
|
||||||
'$count':{ args:[ 'array' ]},
|
'$count':{ args:[ 'array' ]},
|
||||||
'$each':{ args:[ 'object', 'function' ]},
|
'$each':{ args:[ 'object', 'function' ]},
|
||||||
|
'$env': { args:[ 'arg' ]},
|
||||||
'$exists':{ args:[ 'arg' ]},
|
'$exists':{ args:[ 'arg' ]},
|
||||||
'$filter':{ args:[ 'array', 'function' ]},
|
'$filter':{ args:[ 'array', 'function' ]},
|
||||||
'$floor':{ args:[ 'number' ]},
|
'$floor':{ args:[ 'number' ]},
|
||||||
|
@ -190,11 +190,11 @@
|
|||||||
},
|
},
|
||||||
"$flowContext": {
|
"$flowContext": {
|
||||||
"args": "string",
|
"args": "string",
|
||||||
"desc": "Retrieves a flow context property."
|
"desc": "Retrieves a flow context property.\n\nThis is a Node-RED defined function."
|
||||||
},
|
},
|
||||||
"$globalContext": {
|
"$globalContext": {
|
||||||
"args": "string",
|
"args": "string",
|
||||||
"desc": "Retrieves a global context property."
|
"desc": "Retrieves a global context property.\n\nThis is a Node-RED defined function."
|
||||||
},
|
},
|
||||||
"$pad": {
|
"$pad": {
|
||||||
"args": "string, width [, char]",
|
"args": "string, width [, char]",
|
||||||
@ -215,5 +215,9 @@
|
|||||||
"$toMillis": {
|
"$toMillis": {
|
||||||
"args": "timestamp",
|
"args": "timestamp",
|
||||||
"desc": "Convert a `timestamp` string in the ISO 8601 format to the number of milliseconds since the Unix Epoch (1 January, 1970 UTC) as a number. An error is thrown if the string is not in the correct format."
|
"desc": "Convert a `timestamp` string in the ISO 8601 format to the number of milliseconds since the Unix Epoch (1 January, 1970 UTC) as a number. An error is thrown if the string is not in the correct format."
|
||||||
|
},
|
||||||
|
"$env": {
|
||||||
|
"args": "arg",
|
||||||
|
"desc": "Returns the value of an environment variable.\n\nThis is a Node-RED defined function."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,6 +359,9 @@ function prepareJSONataExpression(value,node) {
|
|||||||
expr.assign('globalContext',function(val) {
|
expr.assign('globalContext',function(val) {
|
||||||
return node.context().global.get(val);
|
return node.context().global.get(val);
|
||||||
});
|
});
|
||||||
|
expr.assign('env', function(val) {
|
||||||
|
return process.env[val];
|
||||||
|
})
|
||||||
expr.registerFunction('clone', cloneMessage, '<(oa)-:o>');
|
expr.registerFunction('clone', cloneMessage, '<(oa)-:o>');
|
||||||
expr._legacyMode = /(^|[^a-zA-Z0-9_'"])msg([^a-zA-Z0-9_'"]|$)/.test(value);
|
expr._legacyMode = /(^|[^a-zA-Z0-9_'"])msg([^a-zA-Z0-9_'"]|$)/.test(value);
|
||||||
return expr;
|
return expr;
|
||||||
|
Loading…
Reference in New Issue
Block a user