1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Update JSONata to 1.2.4

Closes #1275
This commit is contained in:
Nick O'Leary 2017-06-26 13:55:22 +01:00
parent e9c1216d5c
commit b63d243e33
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
7 changed files with 131 additions and 43 deletions

View File

@ -171,8 +171,12 @@ module.exports = function(grunt) {
// bootstrap/FA/jquery // bootstrap/FA/jquery
], ],
"public/vendor/jsonata/jsonata.min.js": [ "public/vendor/jsonata/jsonata.min.js": [
"node_modules/jsonata/jsonata.min.js", "node_modules/jsonata/jsonata-es5.min.js",
"editor/vendor/jsonata/formatter.js" "editor/vendor/jsonata/formatter.js"
],
"public/vendor/ace/worker-jsonata.js": [
"node_modules/jsonata/jsonata-es5.min.js",
"editor/vendor/jsonata/worker-jsonata.js"
] ]
} }
} }
@ -183,7 +187,6 @@ module.exports = function(grunt) {
'public/red/red.min.js': 'public/red/red.js', 'public/red/red.min.js': 'public/red/red.js',
'public/red/main.min.js': 'public/red/main.js', 'public/red/main.min.js': 'public/red/main.js',
'public/vendor/ace/mode-jsonata.js': 'editor/vendor/jsonata/mode-jsonata.js', 'public/vendor/ace/mode-jsonata.js': 'editor/vendor/jsonata/mode-jsonata.js',
'public/vendor/ace/worker-jsonata.js': 'editor/vendor/jsonata/worker-jsonata.js',
'public/vendor/ace/snippets/jsonata.js': 'editor/vendor/jsonata/snippets-jsonata.js' 'public/vendor/ace/snippets/jsonata.js': 'editor/vendor/jsonata/snippets-jsonata.js'
} }
} }

View File

@ -107,36 +107,51 @@
jsonata.format = formatExpression; jsonata.format = formatExpression;
jsonata.functions = jsonata.functions =
{ {
'$append':{ args:['array','array'] }, '$abs':{ args:[ 'number' ]},
'$average':{ args:['value'] }, '$append':{ args:[ 'array1', 'array2' ]},
'$boolean':{ args:['value'] }, '$average':{ args:[ 'array' ]},
'$contains':{ args:['str','pattern']}, '$base64decode':{ args:[ ]},
'$count':{ args:['array'] }, '$base64encode':{ args:[ ]},
'$exists':{ args:['value'] }, '$boolean':{ args:[ 'arg' ]},
'$flowContext': {args:['string']}, '$ceil':{ args:[ 'number' ]},
'$globalContext': {args:['string']}, '$contains':{ args:[ 'str', 'pattern' ]},
'$join':{ args:['array','separator'] }, '$count':{ args:[ 'array' ]},
'$keys':{ args:['object'] }, '$each':{ args:[ 'object', 'function' ]},
'$length':{ args:['string'] }, '$exists':{ args:[ 'arg' ]},
'$lookup':{ args:['object','key'] }, '$filter':{ args:[ 'array', 'function' ]},
'$lowercase':{ args:['string'] }, '$floor':{ args:[ 'number' ]},
'$match':{ args:['str','pattern','limit']}, '$join':{ args:[ 'array', 'separator' ]},
'$map':{ args:[] }, '$keys':{ args:[ 'object' ]},
'$max':{ args:['array'] }, '$length':{ args:[ 'str' ]},
'$min':{ args:['array'] }, '$lookup':{ args:[ 'object', 'key' ]},
'$not':{ args:['value'] }, '$lowercase':{ args:[ 'str' ]},
'$number':{ args:['value'] }, '$map':{ args:[ 'array', 'function' ]},
'$reduce':{ args:[] }, '$match':{ args:[ 'str', 'pattern', 'limit' ]},
'$replace':{ args:['str','pattern','replacement','limit']}, '$max':{ args:[ 'array' ]},
'$split':{ args:['string','separator','limit'] }, '$min':{ args:[ 'array' ]},
'$spread':{ args:['object'] }, '$not':{ args:[ 'arg' ]},
'$string':{ args:['value'] }, '$now':{ args:[ ]},
'$substring':{ args:['string','start','length'] }, '$number':{ args:[ 'arg' ]},
'$substringAfter':{ args:['string','chars'] }, '$power':{ args:[ 'base', 'exponent' ]},
'$substringBefore':{ args:['string','chars'] }, '$random':{ args:[ ]},
'$sum':{ args:['array'] }, '$reduce':{ args:[ 'array', 'function' , 'init' ]},
'$trim': { args:['str'] }, '$replace':{ args:[ 'str', 'pattern', 'replacement', 'limit' ]},
'$uppercase':{ args:['string'] } '$reverse':{ args:[ 'array' ]},
'$round':{ args:[ 'number', 'precision' ]},
'$shuffle':{ args:[ 'array' ]},
'$sift':{ args:[ 'object', 'function' ]},
'$sort':{ args:[ 'array', 'function' ]},
'$split':{ args:[ 'str', 'separator', 'limit' ]},
'$spread':{ args:[ 'object' ]},
'$sqrt':{ args:[ 'number' ]},
'$string':{ args:[ 'arg' ]},
'$substring':{ args:[ 'str', 'start', 'length' ]},
'$substringAfter':{ args:[ 'str', 'chars' ]},
'$substringBefore':{ args:[ 'str', 'chars' ]},
'$sum':{ args:[ 'array' ]},
'$trim':{ args:[ 'str' ]},
'$uppercase':{ args:[ 'str' ]},
'$zip':{ args:[ 'array1' ]}
} }
jsonata.getFunctionSnippet = function(fn) { jsonata.getFunctionSnippet = function(fn) {
var snippetText = ""; var snippetText = "";

View File

@ -1,4 +1,4 @@
define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/worker/worker_client","ace/mode/text"], function(require, exports, module) { ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/worker/worker_client","ace/mode/text"], function(require, exports, module) {
"use strict"; "use strict";

View File

@ -1,4 +1,4 @@
define("ace/snippets/jsonata",["require","exports","module"], function(require, exports, module) { ace.define("ace/snippets/jsonata",["require","exports","module"], function(require, exports, module) {
"use strict"; "use strict";
var snippetText = ""; var snippetText = "";
for (var fn in jsonata.functions) { for (var fn in jsonata.functions) {

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,7 @@
"is-utf8":"0.2.1", "is-utf8":"0.2.1",
"js-yaml": "3.7.0", "js-yaml": "3.7.0",
"json-stringify-safe":"5.0.1", "json-stringify-safe":"5.0.1",
"jsonata":"1.1.1", "jsonata":"1.2.4",
"media-typer": "0.3.0", "media-typer": "0.3.0",
"mqtt": "2.2.1", "mqtt": "2.2.1",
"multer": "1.2.1", "multer": "1.2.1",

View File

@ -51,12 +51,50 @@
"args": "str, pattern, replacement [, limit]", "args": "str, pattern, replacement [, limit]",
"desc": "Finds occurrences of `pattern` within `str` and replaces them with `replacement`. " "desc": "Finds occurrences of `pattern` within `str` and replaces them with `replacement`. "
}, },
"$now": {
"args":"",
"desc":"Generates a timestamp in ISO 8601 compatible format and returns it as a string."
},
"$base64encode": {
"args":"string",
"desc":"Converts an ASCII string to a base 64 representation. Each each character in the string is treated as a byte of binary data. This requires that all characters in the string are in the 0x00 to 0xFF range, which includes all characters in URI encoded strings. Unicode characters outside of that range are not supported."
},
"$base64decode": {
"args":"string",
"desc":"Converts base 64 encoded bytes to a string, using a UTF-8 Unicode codepage."
},
"$number": { "$number": {
"args": "arg", "args": "arg",
"desc": "Casts the `arg` parameter to a number using the following casting rules:\n\n - Numbers are unchanged\n - Strings that contain a sequence of characters that represent a legal JSON number are converted to that number\n - All other values cause an error to be thrown." "desc": "Casts the `arg` parameter to a number using the following casting rules:\n\n - Numbers are unchanged\n - Strings that contain a sequence of characters that represent a legal JSON number are converted to that number\n - All other values cause an error to be thrown."
}, },
"$abs": {
"args":"number",
"desc":"Returns the absolute value of the `number` parameter."
},
"$floor": {
"args":"number",
"desc":"Returns the value of `number` rounded down to the nearest integer that is smaller or equal to `number`."
},
"$ceil": {
"args":"number",
"desc":"Returns the value of `number` rounded up to the nearest integer that is greater than or equal to `number`."
},
"$round": {
"args":"number [, precision]",
"desc":"Returns the value of the `number` parameter rounded to the number of decimal places specified by the optional `precision` parameter."
},
"$power": {
"args":"base, exponent",
"desc":"Returns the value of `base` raised to the power of `exponent`."
},
"$sqrt": {
"args":"number",
"desc":"Returns the square root of the value of the `number` parameter."
},
"$random": {
"args":"",
"desc":"Returns a pseudo random number greater than or equal to zero and less than one."
},
"$sum": { "$sum": {
"args": "array", "args": "array",
"desc": "Returns the arithmetic sum of an `array` of numbers. It is an error if the input `array` contains an item which isn't a number." "desc": "Returns the arithmetic sum of an `array` of numbers. It is an error if the input `array` contains an item which isn't a number."
@ -86,7 +124,6 @@
"args": "arg", "args": "arg",
"desc": "Returns Boolean `true` if the `arg` expression evaluates to a value, or `false` if the expression does not match anything (e.g. a path to a non-existent field reference)." "desc": "Returns Boolean `true` if the `arg` expression evaluates to a value, or `false` if the expression does not match anything (e.g. a path to a non-existent field reference)."
}, },
"$count": { "$count": {
"args": "array", "args": "array",
"desc": "Returns the number of items in the array" "desc": "Returns the number of items in the array"
@ -95,21 +132,54 @@
"args": "array, array", "args": "array, array",
"desc": "Appends two arrays" "desc": "Appends two arrays"
}, },
"$sort": {
"args":"array [, function]",
"desc":"Returns an array containing all the values in the `array` parameter, but sorted into order.\n\nIf a comparator `function` is supplied, then it must be a function that takes two parameters:\n\n`function(left, right)`\n\nThis function gets invoked by the sorting algorithm to compare two values left and right. If the value of left should be placed after the value of right in the desired sort order, then the function must return Boolean `true` to indicate a swap. Otherwise it must return `false`."
},
"$reverse": {
"args":"array",
"desc":"Returns an array containing all the values from the `array` parameter, but in reverse order."
},
"$shuffle": {
"args":"array",
"desc":"Returns an array containing all the values from the `array` parameter, but shuffled into random order."
},
"$zip": {
"args":"array, ...",
"desc":"Returns a convolved (zipped) array containing grouped arrays of values from the `array1` … `arrayN` arguments from index 0, 1, 2...."
},
"$keys": { "$keys": {
"args": "object", "args": "object",
"desc": "Returns an array containing the keys in the object. If the argument is an array of objects, then the array returned contains a de-duplicated list of all the keys in all of the objects." "desc": "Returns an array containing the keys in the object. If the argument is an array of objects, then the array returned contains a de-duplicated list of all the keys in all of the objects."
}, },
"$lookup": { "$lookup": {
"args": "object, key", "args": "object, key",
"desc": "Returns the value associated with key in object. If the first argument is an array of objects, then all of the objects in the array are searched, and the values associated with all occurrences of key are returned." "desc": "Returns the value associated with key in object. If the first argument is an array of objects, then all of the objects in the array are searched, and the values associated with all occurrences of key are returned."
}, },
"$spread": { "$spread": {
"args": "object", "args": "object",
"desc": "Splits an object containing key/value pairs into an array of objects, each of which has a single key/value pair from the input object. If the parameter is an array of objects, then the resultant array contains an object for every key/value pair in every object in the supplied array." "desc": "Splits an object containing key/value pairs into an array of objects, each of which has a single key/value pair from the input object. If the parameter is an array of objects, then the resultant array contains an object for every key/value pair in every object in the supplied array."
}, },
"$sift": {
"args":"object, function",
"desc":"Returns an object that contains only the key/value pairs from the `object` parameter that satisfy the predicate `function` passed in as the second parameter.\n\nThe function that is supplied as the second parameter must have the following signature:\n\n`function(value [, key [, object]])`"
},
"$each": {
"args":"object, function",
"desc":"Returns an array containing the values return by the `function` when applied to each key/value pair in the `object`."
},
"$map": {
"args":"array, function",
"desc":"Returns an array containing the results of applying the `function` parameter to each value in the `array` parameter.\n\nThe `function` that is supplied as the second parameter must have the following signature:\n\n`function(value [, index [, array]])`"
},
"$filter": {
"args":"array, function",
"desc":"Returns an array containing only the values in the array parameter that satisfy the `function` predicate.\n\nThe function that is supplied as the second parameter must have the following signature:\n\n`function(value [, index [, array]])`"
},
"$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`."
},
"$flowContext": { "$flowContext": {
"args": "string", "args": "string",
"desc": "Retrieves a flow context property." "desc": "Retrieves a flow context property."