From 5d36539271fc30b72ac3236c940b48fe6832b9f7 Mon Sep 17 00:00:00 2001 From: Phi Dong Date: Sat, 19 Oct 2019 12:37:54 -0700 Subject: [PATCH 1/2] Update JSONata to 1.7.0 --- package.json | 2 +- .../editor-client/locales/en-US/jsonata.json | 39 +++++++++++++++++-- .../src/vendor/jsonata/formatter.js | 12 +++++- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 8d2ac8a4c..83b114175 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "is-utf8": "0.2.1", "js-yaml": "3.13.1", "json-stringify-safe": "5.0.1", - "jsonata": "1.6.5", + "jsonata": "1.7.0", "media-typer": "1.1.0", "memorystore": "1.6.1", "mime": "2.4.4", diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/jsonata.json b/packages/node_modules/@node-red/editor-client/locales/en-US/jsonata.json index 9c33e8d6d..8f516a289 100755 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/jsonata.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/jsonata.json @@ -1,7 +1,7 @@ { "$string": { - "args": "arg", - "desc": "Casts the *arg* parameter to a string using the following casting rules:\n\n - Strings are unchanged\n - Functions are converted to an empty string\n - Numeric infinity and NaN throw an error because they cannot be represented as a JSON number\n - All other values are converted to a JSON string using the `JSON.stringify` function" + "args": "arg[, prettify]", + "desc": "Casts the `arg` parameter to a string using the following casting rules:\n\n - Strings are unchanged\n - Functions are converted to an empty string\n - Numeric infinity and NaN throw an error because they cannot be represented as a JSON number\n - All other values are converted to a JSON string using the `JSON.stringify` function. If `prettify` is true, then \"prettified\" JSON is produced. i.e One line per field and lines will be indented based on the field depth." }, "$length": { "args": "str", @@ -185,7 +185,7 @@ }, "$reduce": { "args":"array, function [, init]", - "desc":"Returns an aggregated value derived from applying the `function` parameter successively to each value in `array` in combination with the result of the previous application of the function.\n\nThe function must accept two arguments, and behaves like an infix operator between each value within the `array`.\n\nThe optional `init` parameter is used as the initial value in the aggregation." + "desc":"Returns an aggregated value derived from applying the `function` parameter successively to each value in `array` in combination with the result of the previous application of the function.\n\nThe function must accept two arguments, and behaves like an infix operator between each value within the `array`. The signature of `function` must be of the form: `myfunc($accumulator, $value[, $index[, $array]])`\n\nThe optional `init` parameter is used as the initial value in the aggregation." }, "$flowContext": { "args": "string[, string]", @@ -230,6 +230,37 @@ "$parseInteger": { "args": "string, picture", "desc": "Parses the contents of the `string` parameter to an integer (as a JSON number) using the format specified by the `picture` string. The `picture` string parameter has the same format as `$formatInteger`." - + }, + "$error": { + "args": "[str]", + "desc": "Throws an error with a message. The optional `str` will replace the default message of `$error() function evaluated`" + }, + "$assert": { + "args": "arg, str", + "desc": "If `arg` is true the function returns undefined. If `arg` is false an exception is thrown with `str` as the message of the exception." + }, + "$single": { + "args": "array, function", + "desc": "Returns the one and only value in the `array` parameter that satisfies the `function` predicate (i.e. the `function` returns Boolean `true` when passed the value). Throws an exception if the number of matching values is not exactly one.\n\nThe function should be supplied in the following signature: `function(value [, index [, array]])` where value is each input of the array, index is the position of that value and the whole array is passed as the third argument" + }, + "$encodeUrl": { + "args": "str", + "desc": "Encodes a Uniform Resource Locator (URL) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.\n\nExample: `$encodeUrlComponent(\"?x=test\")` => `\"%3Fx%3Dtest\"`" + }, + "$encodeUrlComponent": { + "args": "str", + "desc": "Encodes a Uniform Resource Locator (URL) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. \n\nExample: `$encodeUrl(\"https://mozilla.org/?x=шеллы\")` => `\"https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B\"`" + }, + "$decodeUrl": { + "args": "str", + "desc": "Decodes a Uniform Resource Locator (URL) component previously created by encodeUrlComponent. \n\nExample: `$decodeUrlComponent(\"%3Fx%3Dtest\")` => `\"?x=test\"`" + }, + "$decodeUrlComponent": { + "args": "str", + "desc": "Decodes a Uniform Resource Locator (URL) previously created by encodeUrl. \n\nExample: `$decodeUrl(\"https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B\")` => `\"https://mozilla.org/?x=шеллы\"`" + }, + "$distinct": { + "args": "array", + "desc": "Returns an array with duplicate values removed from `array`" } } diff --git a/packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js b/packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js index 4929def85..0cc69715a 100644 --- a/packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js +++ b/packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js @@ -109,6 +109,7 @@ { '$abs':{ args:[ 'number' ]}, '$append':{ args:[ 'array1', 'array2' ]}, + '$assert':{ args: [ 'arg', 'str' ]}, '$average':{ args:[ 'array' ]}, '$base64decode':{ args:[ ]}, '$base64encode':{ args:[ ]}, @@ -116,8 +117,14 @@ '$ceil':{ args:[ 'number' ]}, '$contains':{ args:[ 'str', 'pattern' ]}, '$count':{ args:[ 'array' ]}, + '$decodeUrl':{ args:[ 'str' ]}, + '$decodeUrlComponent':{ args:[ 'str' ]}, + '$distinct':{ args:[ 'array' ]}, '$each':{ args:[ 'object', 'function' ]}, + '$encodeUrl':{ args: ['str'] }, + '$encodeUrlComponent':{ args:[ 'str' ]}, '$env': { args:[ 'arg' ]}, + '$error':{ args:[ 'str' ]}, '$eval': { args: ['expr', 'context']}, '$exists':{ args:[ 'arg' ]}, '$filter':{ args:[ 'array', 'function' ]}, @@ -151,12 +158,13 @@ '$reverse':{ args:[ 'array' ]}, '$round':{ args:[ 'number', 'precision' ]}, '$shuffle':{ args:[ 'array' ]}, - '$sift':{ args:[ 'object', 'function' ]}, + '$sift':{ args: ['object', 'function'] }, + '$single':{ args: ['array', 'function'] }, '$sort':{ args:[ 'array', 'function' ]}, '$split':{ args:[ 'str', 'separator', 'limit' ]}, '$spread':{ args:[ 'object' ]}, '$sqrt':{ args:[ 'number' ]}, - '$string':{ args:[ 'arg' ]}, + '$string':{ args:[ 'arg', 'prettify' ]}, '$substring':{ args:[ 'str', 'start', 'length' ]}, '$substringAfter':{ args:[ 'str', 'chars' ]}, '$substringBefore':{ args:[ 'str', 'chars' ]}, From c590247afa3b7db842c646386c231a040079fc22 Mon Sep 17 00:00:00 2001 From: Phi Dong Date: Sat, 19 Oct 2019 14:33:13 -0700 Subject: [PATCH 2/2] Update node-red/util JSONata to 1.7.0 --- packages/node_modules/@node-red/util/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/util/package.json b/packages/node_modules/@node-red/util/package.json index ca2b77a65..e844929ad 100644 --- a/packages/node_modules/@node-red/util/package.json +++ b/packages/node_modules/@node-red/util/package.json @@ -18,7 +18,7 @@ "clone": "2.1.2", "i18next": "15.1.2", "json-stringify-safe": "5.0.1", - "jsonata": "1.6.5", + "jsonata": "1.7.0", "when": "3.7.8" } }