1
0
mirror of synced 2024-11-28 08:30:48 +01:00

Jsonpath lib now imported from npm with workaround instead of serving locally.

This commit is contained in:
n1474335 2017-08-04 13:59:32 +00:00
parent 4b87d66131
commit 55aedfe901
7 changed files with 156 additions and 6703 deletions

View File

@ -229,6 +229,9 @@ module.exports = function (grunt) {
stats: { stats: {
children: false, children: false,
warningsFilter: /source-map/ warningsFilter: /source-map/
},
node: {
fs: "empty"
} }
}, },
webDev: { webDev: {

140
package-lock.json generated
View File

@ -1342,6 +1342,11 @@
"integrity": "sha1-vos2rvzN6LPKeqLWr8B6NyQsDS0=", "integrity": "sha1-vos2rvzN6LPKeqLWr8B6NyQsDS0=",
"dev": true "dev": true
}, },
"cjson": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/cjson/-/cjson-0.2.1.tgz",
"integrity": "sha1-c82KrWXZ4VBfmvF0TTt5wVJ2gqU="
},
"clap": { "clap": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/clap/-/clap-1.2.0.tgz", "resolved": "https://registry.npmjs.org/clap/-/clap-1.2.0.tgz",
@ -2067,6 +2072,11 @@
"domelementtype": "1.3.0" "domelementtype": "1.3.0"
} }
}, },
"ebnf-parser": {
"version": "0.1.10",
"resolved": "https://registry.npmjs.org/ebnf-parser/-/ebnf-parser-0.1.10.tgz",
"integrity": "sha1-zR9rpHfFY4xAyX7ZtXLbW6tdgzE="
},
"ecc-jsbn": { "ecc-jsbn": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
@ -4086,6 +4096,52 @@
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
"dev": true "dev": true
}, },
"jison": {
"version": "0.4.13",
"resolved": "https://registry.npmjs.org/jison/-/jison-0.4.13.tgz",
"integrity": "sha1-kEFwfWIkE2f1iDRTK58ZwsNvrHg=",
"requires": {
"cjson": "0.2.1",
"ebnf-parser": "0.1.10",
"escodegen": "0.0.21",
"esprima": "1.0.4",
"jison-lex": "0.2.1",
"JSONSelect": "0.4.0",
"lex-parser": "0.1.4",
"nomnom": "1.5.2"
},
"dependencies": {
"escodegen": {
"version": "0.0.21",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.21.tgz",
"integrity": "sha1-U9ZSz6EDA4gnlFilJmxf/HCcY8M=",
"requires": {
"esprima": "1.0.4",
"estraverse": "0.0.4",
"source-map": "0.2.0"
}
},
"esprima": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz",
"integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0="
},
"estraverse": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-0.0.4.tgz",
"integrity": "sha1-AaCTLf7ldGhKWYr1pnw7+bZCjbI="
}
}
},
"jison-lex": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/jison-lex/-/jison-lex-0.2.1.tgz",
"integrity": "sha1-rEuBXozOUTLrErXfz+jXB7iETf4=",
"requires": {
"lex-parser": "0.1.4",
"nomnom": "1.5.2"
}
},
"jquery": { "jquery": {
"version": "3.2.1", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz",
@ -4274,12 +4330,40 @@
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
"dev": true "dev": true
}, },
"jsonpath": {
"version": "0.2.12",
"resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-0.2.12.tgz",
"integrity": "sha1-W/nZEftGFsHjNwvs658NskrjTNI=",
"requires": {
"esprima": "1.2.2",
"jison": "0.4.13",
"static-eval": "0.2.3",
"underscore": "1.7.0"
},
"dependencies": {
"esprima": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz",
"integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs="
},
"underscore": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz",
"integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk="
}
}
},
"jsonpointer": { "jsonpointer": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz",
"integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=",
"dev": true "dev": true
}, },
"JSONSelect": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz",
"integrity": "sha1-oI7cxn6z/L6Z7WMIVTRKDPKCu40="
},
"jsprim": { "jsprim": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz",
@ -4397,6 +4481,11 @@
"type-check": "0.3.2" "type-check": "0.3.2"
} }
}, },
"lex-parser": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz",
"integrity": "sha1-ZMTwJfF/1Tv7RXY/rrFvAVp0dVA="
},
"load-json-file": { "load-json-file": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
@ -4774,6 +4863,27 @@
"vm-browserify": "0.0.4" "vm-browserify": "0.0.4"
} }
}, },
"nomnom": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.5.2.tgz",
"integrity": "sha1-9DRUSKhTz71cDSYyDyR3qwUm/i8=",
"requires": {
"colors": "0.5.1",
"underscore": "1.1.7"
},
"dependencies": {
"colors": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz",
"integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q="
},
"underscore": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.1.7.tgz",
"integrity": "sha1-QLq4S60Z0jAJbo1u9ii/8FXYPbA="
}
}
},
"nopt": { "nopt": {
"version": "3.0.6", "version": "3.0.6",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
@ -6811,6 +6921,36 @@
} }
} }
}, },
"static-eval": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/static-eval/-/static-eval-0.2.3.tgz",
"integrity": "sha1-Aj8XrJ/uQm6niMEuo5IG3Bdfiyo=",
"requires": {
"escodegen": "0.0.28"
},
"dependencies": {
"escodegen": {
"version": "0.0.28",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.28.tgz",
"integrity": "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M=",
"requires": {
"esprima": "1.0.4",
"estraverse": "1.3.2",
"source-map": "0.2.0"
}
},
"esprima": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz",
"integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0="
},
"estraverse": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.3.2.tgz",
"integrity": "sha1-N8K4k+8T1yPydth41g2FNRUqbEI="
}
}
},
"stream-browserify": { "stream-browserify": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",

View File

@ -77,6 +77,7 @@
"google-code-prettify": "^1.0.5", "google-code-prettify": "^1.0.5",
"jquery": "^3.1.1", "jquery": "^3.1.1",
"jsbn": "^1.1.0", "jsbn": "^1.1.0",
"jsonpath": "^0.2.12",
"jsrsasign": "8.0.3", "jsrsasign": "8.0.3",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"moment": "^2.17.1", "moment": "^2.17.1",

View File

@ -2250,7 +2250,7 @@ const OperationConfig = {
outputType: "string", outputType: "string",
args: [ args: [
{ {
name: "JPath", name: "Query",
type: "string", type: "string",
value: Code.JPATH_INITIAL value: Code.JPATH_INITIAL
}, },

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ import Utils from "../Utils.js";
import vkbeautify from "vkbeautify"; import vkbeautify from "vkbeautify";
import {DOMParser as dom} from "xmldom"; import {DOMParser as dom} from "xmldom";
import xpath from "xpath"; import xpath from "xpath";
import jpath from "../lib/jsonpath.js"; import jpath from "jsonpath";
import prettyPrintOne from "imports-loader?window=>global!exports-loader?prettyPrintOne!google-code-prettify/bin/prettify.min.js"; import prettyPrintOne from "imports-loader?window=>global!exports-loader?prettyPrintOne!google-code-prettify/bin/prettify.min.js";
@ -355,6 +355,7 @@ const Code = {
return nodes.map(nodeToString).join(delimiter); return nodes.map(nodeToString).join(delimiter);
}, },
/** /**
* @constant * @constant
* @default * @default
@ -368,7 +369,7 @@ const Code = {
JPATH_DELIMITER: "\\n", JPATH_DELIMITER: "\\n",
/** /**
* XPath expression operation. * JPath expression operation.
* *
* @author Matt C (matt@artemisbot.uk) * @author Matt C (matt@artemisbot.uk)
* @param {string} input * @param {string} input
@ -380,16 +381,19 @@ const Code = {
delimiter = args[1], delimiter = args[1],
results, results,
obj; obj;
try { try {
obj = JSON.parse(input); obj = JSON.parse(input);
} catch (err) { } catch (err) {
return "Invalid input JSON."; return "Invalid input JSON: " + err.message;
} }
try { try {
results = jpath.query(obj, query); results = jpath.query(obj, query);
} catch (e) { } catch (err) {
return "Invalid JPath expression."; return "Invalid JPath expression: " + err.message;
} }
return results.map(result => JSON.stringify(result)).join(delimiter); return results.map(result => JSON.stringify(result)).join(delimiter);
}, },

View File

@ -174,7 +174,7 @@ TestRegister.addTests([
{ {
name: "JPath Expression: Empty JSON", name: "JPath Expression: Empty JSON",
input: "", input: "",
expectedOutput: "Invalid input JSON.", expectedOutput: "Invalid input JSON: Unexpected end of JSON input",
recipeConfig: [ recipeConfig: [
{ {
"op": "JPath expression", "op": "JPath expression",
@ -185,7 +185,7 @@ TestRegister.addTests([
{ {
name: "JPath Expression: Empty expression", name: "JPath Expression: Empty expression",
input: JSON.stringify(JPATH_TEST_DATA), input: JSON.stringify(JPATH_TEST_DATA),
expectedOutput: "Invalid JPath expression.", expectedOutput: "Invalid JPath expression: we need a path",
recipeConfig: [ recipeConfig: [
{ {
"op": "JPath expression", "op": "JPath expression",