@node-red/util 3.1.6 → 4.0.0-beta.1

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.
Files changed (2) hide show
  1. package/lib/util.js +17 -6
  2. package/package.json +2 -2
package/lib/util.js CHANGED
@@ -636,7 +636,15 @@ function evaluateNodeProperty(value, type, node, msg, callback) {
636
636
  } else if (type === 're') {
637
637
  result = new RegExp(value);
638
638
  } else if (type === 'date') {
639
- result = Date.now();
639
+ if (!value) {
640
+ result = Date.now();
641
+ } else if (value === 'object') {
642
+ result = new Date()
643
+ } else if (value === 'iso') {
644
+ result = (new Date()).toISOString()
645
+ } else {
646
+ result = moment().format(value)
647
+ }
640
648
  } else if (type === 'bin') {
641
649
  var data = JSON.parse(value);
642
650
  if (Array.isArray(data) || (typeof(data) === "string")) {
@@ -769,12 +777,15 @@ function evaluateJSONataExpression(expr,msg,callback) {
769
777
  });
770
778
  }
771
779
  } else {
772
- log.warn('Deprecated API warning: Calls to RED.util.evaluateJSONataExpression must include a callback. '+
773
- 'This will not be optional in Node-RED 4.0. Please identify the node from the following stack '+
774
- 'and check for an update on npm. If none is available, please notify the node author.')
775
- log.warn(new Error().stack)
780
+ const error = new Error('Calls to RED.util.evaluateJSONataExpression must include a callback.')
781
+ throw error
776
782
  }
777
- return expr.evaluate(context, bindings, callback);
783
+
784
+ expr.evaluate(context, bindings).then(result => {
785
+ callback(null, result)
786
+ }).catch(err => {
787
+ callback(err)
788
+ })
778
789
  }
779
790
 
780
791
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/util",
3
- "version": "3.1.6",
3
+ "version": "4.0.0-beta.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "fs-extra": "11.1.1",
19
19
  "i18next": "21.10.0",
20
20
  "json-stringify-safe": "5.0.1",
21
- "jsonata": "1.8.6",
21
+ "jsonata": "2.0.4",
22
22
  "lodash.clonedeep": "^4.5.0",
23
23
  "moment": "2.29.4",
24
24
  "moment-timezone": "0.5.43"