From fd9e3fc03a740739f3812276e6f9fd01832f422f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 13 Jan 2018 20:42:23 +0000 Subject: [PATCH] Update jsonata to 1.4.1 --- editor/vendor/jsonata/formatter.js | 7 +++++++ package.json | 2 +- red/api/locales/en-US/jsonata.json | 21 +++++++++++++++++++++ red/runtime/util.js | 1 + 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/editor/vendor/jsonata/formatter.js b/editor/vendor/jsonata/formatter.js index be008cca7..9b0f544c8 100644 --- a/editor/vendor/jsonata/formatter.js +++ b/editor/vendor/jsonata/formatter.js @@ -120,6 +120,11 @@ '$exists':{ args:[ 'arg' ]}, '$filter':{ args:[ 'array', 'function' ]}, '$floor':{ args:[ 'number' ]}, + '$flowContext': {args:['string']}, + '$formatBase': {args:['number','radix']}, + '$formatNumber': {args:['number', 'picture', 'options']}, + '$fromMillis': {args:['number']}, + '$globalContext': {args:['string']}, '$join':{ args:[ 'array', 'separator' ]}, '$keys':{ args:[ 'object' ]}, '$length':{ args:[ 'str' ]}, @@ -134,6 +139,7 @@ '$not':{ args:[ 'arg' ]}, '$now':{ args:[ ]}, '$number':{ args:[ 'arg' ]}, + '$pad': {args:['str', 'width','char']}, '$power':{ args:[ 'base', 'exponent' ]}, '$random':{ args:[ ]}, '$reduce':{ args:[ 'array', 'function' , 'init' ]}, @@ -151,6 +157,7 @@ '$substringAfter':{ args:[ 'str', 'chars' ]}, '$substringBefore':{ args:[ 'str', 'chars' ]}, '$sum':{ args:[ 'array' ]}, + '$toMillis':{args:['timestamp']}, // <------------- '$trim':{ args:[ 'str' ]}, '$uppercase':{ args:[ 'str' ]}, '$zip':{ args:[ 'array1' ]} diff --git a/package.json b/package.json index 7583eeeb5..1f356a107 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "is-utf8": "0.2.1", "js-yaml": "3.8.4", "json-stringify-safe": "5.0.1", - "jsonata": "1.3.0", + "jsonata": "1.4.1", "media-typer": "0.3.0", "memorystore": "1.6.0", "mqtt": "2.9.0", diff --git a/red/api/locales/en-US/jsonata.json b/red/api/locales/en-US/jsonata.json index 3b93e43cc..cae48390f 100644 --- a/red/api/locales/en-US/jsonata.json +++ b/red/api/locales/en-US/jsonata.json @@ -195,5 +195,26 @@ "$globalContext": { "args": "string", "desc": "Retrieves a global context property." + }, + "$pad": { + "args": "string, width [, char]", + "desc": "Returns a copy of the `string` with extra padding, if necessary, so that its total number of characters is at least the absolute value of the `width` parameter.\n\nIf `width` is a positive number, then the string is padded to the right; if negative, it is padded to the left.\n\nThe optional `char` argument specifies the padding character(s) to use. If not specified, it defaults to the space character." + }, + "$fromMillis": { + "args": "number", + "desc": "Convert a number representing milliseconds since the Unix Epoch (1 January, 1970 UTC) to a timestamp string in the ISO 8601 format." + }, + "$formatNumber": { + "args": "number, picture [, options]", + "desc": "Casts the number to a string and formats it to a decimal representation as specified by the picture string.\n\n The behaviour of this function is consistent with the XPath/XQuery function fn:format-number as defined in the XPath F&O 3.1 specification. The picture string parameter defines how the number is formatted and has the same syntax as fn:format-number.\n\nThe optional third argument options is used to override the default locale specific formatting characters such as the decimal separator. If supplied, this argument must be an object containing name/value pairs specified in the decimal format section of the XPath F&O 3.1 specification." + }, + "$formatBase": { + "args": "number [, radix]", + "desc": "Casts the number to a string and formats it to an integer represented in the number base specified by the radix argument. If radix is not specified, then it defaults to base 10. radix can be between 2 and 36, otherwise an error is thrown." + }, + "$toMillis": { + "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." } + } diff --git a/red/runtime/util.js b/red/runtime/util.js index e75f13af1..88c06a029 100644 --- a/red/runtime/util.js +++ b/red/runtime/util.js @@ -340,6 +340,7 @@ function prepareJSONataExpression(value,node) { expr.assign('globalContext',function(val) { return node.context().global.get(val); }); + expr.registerFunction('clone', cloneMessage, '<(oa)-:o>'); expr._legacyMode = /(^|[^a-zA-Z0-9_'"])msg([^a-zA-Z0-9_'"]|$)/.test(value); return expr; }