@node-red/util 3.0.2 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/util.js +20 -6
- package/package.json +3 -3
package/lib/util.js
CHANGED
|
@@ -25,7 +25,7 @@ const moment = require("moment-timezone");
|
|
|
25
25
|
const safeJSONStringify = require("json-stringify-safe");
|
|
26
26
|
const util = require("util");
|
|
27
27
|
const { hasOwnProperty } = Object.prototype;
|
|
28
|
-
|
|
28
|
+
const log = require("./log")
|
|
29
29
|
/**
|
|
30
30
|
* Safely returns the object construtor name.
|
|
31
31
|
* @return {String} the name of the object constructor if it exists, empty string otherwise.
|
|
@@ -671,8 +671,11 @@ function evaluateNodeProperty(value, type, node, msg, callback) {
|
|
|
671
671
|
} else if (type === 'bool') {
|
|
672
672
|
result = /^true$/i.test(value);
|
|
673
673
|
} else if (type === 'jsonata') {
|
|
674
|
-
var expr = prepareJSONataExpression(value,node);
|
|
675
|
-
result = evaluateJSONataExpression(expr,msg);
|
|
674
|
+
var expr = prepareJSONataExpression(value, node);
|
|
675
|
+
result = evaluateJSONataExpression(expr, msg, callback);
|
|
676
|
+
if (callback) {
|
|
677
|
+
return
|
|
678
|
+
}
|
|
676
679
|
} else if (type === 'env') {
|
|
677
680
|
result = evaluateEnvProperty(value, node);
|
|
678
681
|
}
|
|
@@ -696,13 +699,19 @@ function evaluateNodeProperty(value, type, node, msg, callback) {
|
|
|
696
699
|
function prepareJSONataExpression(value,node) {
|
|
697
700
|
var expr = jsonata(value);
|
|
698
701
|
expr.assign('flowContext', function(val, store) {
|
|
699
|
-
|
|
702
|
+
if (node) {
|
|
703
|
+
return node.context().flow.get(val, store);
|
|
704
|
+
}
|
|
705
|
+
return "";
|
|
700
706
|
});
|
|
701
707
|
expr.assign('globalContext', function(val, store) {
|
|
702
|
-
|
|
708
|
+
if (node) {
|
|
709
|
+
return node.context().global.get(val, store);
|
|
710
|
+
}
|
|
711
|
+
return "";
|
|
703
712
|
});
|
|
704
713
|
expr.assign('env', function(name) {
|
|
705
|
-
var val = getSetting(node, name, node._flow);
|
|
714
|
+
var val = getSetting(node, name, node ? node._flow : null);
|
|
706
715
|
if (typeof val !== 'undefined') {
|
|
707
716
|
return val;
|
|
708
717
|
} else {
|
|
@@ -761,6 +770,11 @@ function evaluateJSONataExpression(expr,msg,callback) {
|
|
|
761
770
|
})
|
|
762
771
|
});
|
|
763
772
|
}
|
|
773
|
+
} else {
|
|
774
|
+
log.warn('Deprecated API warning: Calls to RED.util.evaluateJSONataExpression must include a callback. '+
|
|
775
|
+
'This will not be optional in Node-RED 4.0. Please identify the node from the following stack '+
|
|
776
|
+
'and check for an update on npm. If none is available, please notify the node author.')
|
|
777
|
+
log.warn(new Error().stack)
|
|
764
778
|
}
|
|
765
779
|
return expr.evaluate(context, bindings, callback);
|
|
766
780
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-red/util",
|
|
3
|
-
"version": "3.0.2",
|
|
3
|
+
"version": "3.1.0-beta.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"fs-extra": "10.1.0",
|
|
19
|
-
"i18next": "21.
|
|
19
|
+
"i18next": "21.10.0",
|
|
20
20
|
"json-stringify-safe": "5.0.1",
|
|
21
21
|
"jsonata": "1.8.6",
|
|
22
22
|
"lodash.clonedeep": "^4.5.0",
|
|
23
23
|
"moment": "2.29.4",
|
|
24
|
-
"moment-timezone": "0.5.
|
|
24
|
+
"moment-timezone": "0.5.41"
|
|
25
25
|
}
|
|
26
26
|
}
|