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

Update jsonata

This commit is contained in:
Nick O'Leary 2017-03-12 22:02:58 +00:00
parent 0c1c710afe
commit 07d131c945
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
6 changed files with 1957 additions and 4032 deletions

View File

@ -110,6 +110,7 @@
'$append':{ args:['array','array'] }, '$append':{ args:['array','array'] },
'$average':{ args:['value'] }, '$average':{ args:['value'] },
'$boolean':{ args:['value'] }, '$boolean':{ args:['value'] },
'$contains':{ args:['str','pattern']},
'$count':{ args:['array'] }, '$count':{ args:['array'] },
'$exists':{ args:['value'] }, '$exists':{ args:['value'] },
'$join':{ args:['array','separator'] }, '$join':{ args:['array','separator'] },
@ -117,12 +118,14 @@
'$length':{ args:['string'] }, '$length':{ args:['string'] },
'$lookup':{ args:['object','key'] }, '$lookup':{ args:['object','key'] },
'$lowercase':{ args:['string'] }, '$lowercase':{ args:['string'] },
'$match':{ args:['str','pattern','limit']},
'$map':{ args:[] }, '$map':{ args:[] },
'$max':{ args:['array'] }, '$max':{ args:['array'] },
'$min':{ args:['array'] }, '$min':{ args:['array'] },
'$not':{ args:['value'] }, '$not':{ args:['value'] },
'$number':{ args:['value'] }, '$number':{ args:['value'] },
'$reduce':{ args:[] }, '$reduce':{ args:[] },
'$replace':{ args:['str','pattern','replacement','limit']},
'$split':{ args:['string','separator','limit'] }, '$split':{ args:['string','separator','limit'] },
'$spread':{ args:['object'] }, '$spread':{ args:['object'] },
'$string':{ args:['value'] }, '$string':{ args:['value'] },
@ -130,6 +133,7 @@
'$substringAfter':{ args:['string','chars'] }, '$substringAfter':{ args:['string','chars'] },
'$substringBefore':{ args:['string','chars'] }, '$substringBefore':{ args:['string','chars'] },
'$sum':{ args:['array'] }, '$sum':{ args:['array'] },
'$trim': { args:['str'] },
'$uppercase':{ args:['string'] } '$uppercase':{ args:['string'] }
} }
jsonata.getFunctionSnippet = function(fn) { jsonata.getFunctionSnippet = function(fn) {

View File

@ -18,13 +18,13 @@ define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/mode/
var keywordMapper = this.createKeywordMapper({ var keywordMapper = this.createKeywordMapper({
"keyword.operator": "keyword.operator":
"and|or|in", "and|or|in",
"constant.language": "constant.language":
"null|Infinity|NaN|undefined", "null|Infinity|NaN|undefined",
"constant.language.boolean": "constant.language.boolean":
"true|false", "true|false",
"storage.type": "storage.type":
"function" "function"
}, "identifier"); }, "identifier");
this.$rules = { this.$rules = {
"start" : [ "start" : [
@ -47,33 +47,33 @@ define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/mode/
regex : /[+-]?\d[\d_]*(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ regex : /[+-]?\d[\d_]*(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, },
{ token: "keyword", { token: "keyword",
regex: /λ/ regex: /λ/
}, },
{ {
token: "keyword", token: "keyword",
regex: jsonataFunctions regex: jsonataFunctions
}, },
{ {
token : keywordMapper, token : keywordMapper,
regex : "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*" regex : "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*"
}, },
{ {
token : "punctuation.operator", token : "punctuation.operator",
regex : /[.](?![.])/ regex : /[.](?![.])/
}, },
{ {
token : "keyword.operator", token : "keyword.operator",
regex : /\|\||<=|>=|\.\.|\*\*|!=|:=|[=<>`!$%&*+\-~\/^]/, regex : /\|\||<=|>=|\.\.|\*\*|!=|:=|[=<>`!$%&*+\-~\/^]/,
next : "start" next : "start"
}, },
{ {
token : "punctuation.operator", token : "punctuation.operator",
regex : /[?:,;.]/, regex : /[?:,;.]/,
next : "start" next : "start"
}, },
{ {
token : "paren.lparen", token : "paren.lparen",
regex : /[\[({]/, regex : /[\[({]/,
next : "start" next : "start"
}, },
{ {

View File

@ -1,11 +1,11 @@
define("ace/snippets/jsonata",["require","exports","module"], function(require, exports, module) { 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) {
if (jsonata.functions.hasOwnProperty(fn)) { if (jsonata.functions.hasOwnProperty(fn)) {
snippetText += "# "+fn+"\nsnippet "+fn+"\n\t"+jsonata.getFunctionSnippet(fn)+"\n" snippetText += "# "+fn+"\nsnippet "+fn+"\n\t"+jsonata.getFunctionSnippet(fn)+"\n"
}
} }
} exports.snippetText = snippetText;
exports.snippetText = snippetText; exports.scope = "jsonata";
exports.scope = "jsonata";
}); });

File diff suppressed because one or more lines are too long

View File

@ -42,7 +42,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.0.10", "jsonata":"1.1.1",
"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

@ -27,14 +27,30 @@
"args": "str", "args": "str",
"desc": "Returns a string with all the characters of `str` converted to lowercase." "desc": "Returns a string with all the characters of `str` converted to lowercase."
}, },
"$trim": {
"args": "str",
"desc": "Normalizes and trims all whitespace characters in str by applying the following steps:\n\n - All tabs, carriage returns, and line feeds are replaced with spaces.\n- Contiguous sequences of spaces are reduced to a single space.\n- Trailing and leading spaces are removed.\n\n If `str` is not specified (i.e. this function is invoked with no arguments), then the context value is used as the value of `str`. An error is thrown if `str` is not a string."
},
"$contains": {
"args": "str, pattern",
"desc": "Returns `true` if `str` is matched by `pattern`, otherwise it returns `false`. If `str` is not specified (i.e. this function is invoked with one argument), then the context value is used as the value of `str`. The `pattern` parameter can either be a string or a regular expression."
},
"$split": { "$split": {
"args": "str[, separator][, limit]", "args": "str[, separator][, limit]",
"desc": "Splits the `str` parameter into an array of substrings. It is an error if `str` is not a string. The optional `separator` parameter specifies the characters within the `str` about which it should be split. If `separator` is not specified, then the empty string is assumed, and `str` will be split into an array of single characters. It is an error if `separator` is not a string. The optional `limit` parameter is a number that specifies the maximum number of substrings to include in the resultant array. Any additional substrings are discarded. If `limit` is not specified, then `str` is fully split with no limit to the size of the resultant array. It is an error if `limit` is not a non-negative number." "desc": "Splits the `str` parameter into an array of substrings. It is an error if `str` is not a string. The optional `separator` parameter specifies the characters within the `str` about which it should be split as either a string or regular expression. If `separator` is not specified, then the empty string is assumed, and `str` will be split into an array of single characters. It is an error if `separator` is not a string. The optional `limit` parameter is a number that specifies the maximum number of substrings to include in the resultant array. Any additional substrings are discarded. If `limit` is not specified, then `str` is fully split with no limit to the size of the resultant array. It is an error if `limit` is not a non-negative number."
}, },
"$join": { "$join": {
"args": "array[, separator]", "args": "array[, separator]",
"desc": "Joins an array of component strings into a single concatenated string with each component string separated by the optional `separator` parameter. It is an error if the input `array` contains an item which isn't a string. If `separator` is not specified, then it is assumed to be the empty string, i.e. no `separator` between the component strings. It is an error if `separator` is not a string." "desc": "Joins an array of component strings into a single concatenated string with each component string separated by the optional `separator` parameter. It is an error if the input `array` contains an item which isn't a string. If `separator` is not specified, then it is assumed to be the empty string, i.e. no `separator` between the component strings. It is an error if `separator` is not a string."
}, },
"$match": {
"args": "str, pattern [, limit]",
"desc": "Applies the `str` string to the `pattern` regular expression and returns an array of objects, with each object containing information about each occurrence of a match withing `str`."
},
"$replace": {
"args": "str, pattern, replacement [, limit]",
"desc": "Finds occurrences of `pattern` within `str` and replaces them with `replacement`. "
},
"$number": { "$number": {
@ -57,11 +73,11 @@
"args": "array", "args": "array",
"desc": "Returns the mean value of an `array` of numbers. It is an error if the input `array` contains an item which isn't a number." "desc": "Returns the mean value of an `array` of numbers. It is an error if the input `array` contains an item which isn't a number."
}, },
"$boolean": { "$boolean": {
"args": "arg", "args": "arg",
"desc": "Casts the argument to a Boolean using the following rules:\n\n - `Boolean` : unchanged\n - `string`: empty : `false`\n - `string`: non-empty : `true`\n - `number`: `0` : `false`\n - `number`: non-zero : `true`\n - `null` : `false`\n - `array`: empty : `false`\n - `array`: contains a member that casts to `true` : `true`\n - `array`: all members cast to `false` : `false`\n - `object`: empty : `false`\n - `object`: non-empty : `true`\n - `function` : `false`" "desc": "Casts the argument to a Boolean using the following rules:\n\n - `Boolean` : unchanged\n - `string`: empty : `false`\n - `string`: non-empty : `true`\n - `number`: `0` : `false`\n - `number`: non-zero : `true`\n - `null` : `false`\n - `array`: empty : `false`\n - `array`: contains a member that casts to `true` : `true`\n - `array`: all members cast to `false` : `false`\n - `object`: empty : `false`\n - `object`: non-empty : `true`\n - `function` : `false`"
}, },
"$not": { "$not": {
"args": "arg", "args": "arg",
"desc": "Returns Boolean NOT on the argument. `arg` is first cast to a boolean" "desc": "Returns Boolean NOT on the argument. `arg` is first cast to a boolean"
@ -70,6 +86,7 @@
"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"