add JSONata support for env var definition

This commit is contained in:
Hiroyasu Nishiyama 2022-07-20 10:13:13 +09:00
parent 30ea300f65
commit 93a88a83a8
2 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,7 @@ RED.editor.envVarList = (function() {
var currentLocale = 'en-US';
var DEFAULT_ENV_TYPE_LIST = ['str','num','bool','json','bin','env'];
var DEFAULT_ENV_TYPE_LIST_INC_CRED = ['str','num','bool','json','bin','env','cred'];
var DEFAULT_ENV_TYPE_LIST_INC_CRED = ['str','num','bool','json','bin','env','cred','jsonata'];
/**
* Create env var edit interface

View File

@ -696,13 +696,19 @@ function evaluateNodeProperty(value, type, node, msg, callback) {
function prepareJSONataExpression(value,node) {
var expr = jsonata(value);
expr.assign('flowContext', function(val, store) {
return node.context().flow.get(val, store);
if (node) {
return node.context().flow.get(val, store);
}
return "";
});
expr.assign('globalContext', function(val, store) {
return node.context().global.get(val, store);
if (node) {
return node.context().global.get(val, store);
}
return "";
});
expr.assign('env', function(name) {
var val = getSetting(node, name, node._flow);
var val = getSetting(node, name, node ? node._flow : null);
if (typeof val !== 'undefined') {
return val;
} else {