@nocobase/plugin-workflow-json-query 1.9.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE.txt +172 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/index.d.ts +23 -0
  6. package/dist/client/index.js +10 -0
  7. package/dist/client/instruction.d.ts +167 -0
  8. package/dist/externalVersion.js +19 -0
  9. package/dist/index.d.ts +17 -0
  10. package/dist/index.js +42 -0
  11. package/dist/locale/en-US.json +13 -0
  12. package/dist/locale/index.d.ts +10 -0
  13. package/dist/locale/index.js +42 -0
  14. package/dist/locale/zh-CN.json +14 -0
  15. package/dist/node_modules/jmespath/LICENSE +13 -0
  16. package/dist/node_modules/jmespath/artifacts/jmespath.min.js +2 -0
  17. package/dist/node_modules/jmespath/bower.json +24 -0
  18. package/dist/node_modules/jmespath/jmespath.js +1 -0
  19. package/dist/node_modules/jmespath/jp.js +23 -0
  20. package/dist/node_modules/jmespath/package.json +1 -0
  21. package/dist/node_modules/jsonata/LICENSE +19 -0
  22. package/dist/node_modules/jsonata/jsonata-es5.js +9875 -0
  23. package/dist/node_modules/jsonata/jsonata-es5.min.js +1 -0
  24. package/dist/node_modules/jsonata/jsonata.d.ts +72 -0
  25. package/dist/node_modules/jsonata/jsonata.js +1 -0
  26. package/dist/node_modules/jsonata/jsonata.min.js +1 -0
  27. package/dist/node_modules/jsonata/package.json +1 -0
  28. package/dist/node_modules/jsonpath-plus/LICENSE +22 -0
  29. package/dist/node_modules/jsonpath-plus/bin/jsonpath-cli.js +36 -0
  30. package/dist/node_modules/jsonpath-plus/dist/index-browser-esm.js +2158 -0
  31. package/dist/node_modules/jsonpath-plus/dist/index-browser-esm.min.js +2 -0
  32. package/dist/node_modules/jsonpath-plus/dist/index-browser-umd.cjs +2166 -0
  33. package/dist/node_modules/jsonpath-plus/dist/index-browser-umd.min.cjs +2 -0
  34. package/dist/node_modules/jsonpath-plus/dist/index-node-cjs.cjs +1 -0
  35. package/dist/node_modules/jsonpath-plus/dist/index-node-esm.js +2068 -0
  36. package/dist/node_modules/jsonpath-plus/package.json +1 -0
  37. package/dist/node_modules/jsonpath-plus/src/Safe-Script.js +200 -0
  38. package/dist/node_modules/jsonpath-plus/src/jsonpath-browser.js +102 -0
  39. package/dist/node_modules/jsonpath-plus/src/jsonpath-node.js +8 -0
  40. package/dist/node_modules/jsonpath-plus/src/jsonpath.d.ts +226 -0
  41. package/dist/node_modules/jsonpath-plus/src/jsonpath.js +784 -0
  42. package/dist/server/JSONQueryInstruction.d.ts +42 -0
  43. package/dist/server/JSONQueryInstruction.js +99 -0
  44. package/dist/server/Plugin.d.ts +24 -0
  45. package/dist/server/Plugin.js +62 -0
  46. package/dist/server/index.d.ts +17 -0
  47. package/dist/server/index.js +42 -0
  48. package/package.json +31 -0
  49. package/server.d.ts +2 -0
  50. package/server.js +1 -0
@@ -0,0 +1 @@
1
+ {"author":"Stefan Goessner","name":"jsonpath-plus","version":"10.3.0","type":"module","bin":{"jsonpath":"./bin/jsonpath-cli.js","jsonpath-plus":"./bin/jsonpath-cli.js"},"main":"dist/index-node-cjs.cjs","exports":{"./package.json":"./package.json",".":{"types":"./src/jsonpath.d.ts","browser":"./dist/index-browser-esm.js","umd":"./dist/index-browser-umd.cjs","import":"./dist/index-node-esm.js","require":"./dist/index-node-cjs.cjs","default":"./dist/index-browser-esm.js"}},"module":"dist/index-node-esm.js","browser":"dist/index-browser-esm.js","types":"./src/jsonpath.d.ts","description":"A JS implementation of JSONPath with some additional operators","contributors":[{"name":"Prof. Gössner","email":"stefan.goessner@fh-dortmund.de"},{"name":"Subbu Allamaraju","email":"subbu@subbu.org"},{"name":"Mike Brevoort","email":"mike@brevoort.com"},{"name":"Robert Krahn","email":"robert.krahn@gmail.com"},{"name":"Brett Zamir","email":"brettz9@yahoo.com"},{"name":"Richard Schneider","email":"makaretu@gmail.com"}],"license":"MIT","repository":{"type":"git","url":"git://github.com/s3u/JSONPath.git"},"bugs":"https://github.com/s3u/JSONPath/issues/","homepage":"https://github.com/s3u/JSONPath","engines":{"node":">=18.0.0"},"react-native":{"vm":false},"dependencies":{"@jsep-plugin/assignment":"^1.3.0","@jsep-plugin/regex":"^1.0.4","jsep":"^1.4.0"},"devDependencies":{"@babel/core":"^7.26.8","@babel/preset-env":"^7.26.8","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-node-resolve":"^15.3.1","@rollup/plugin-terser":"^0.4.4","c8":"^10.1.3","chai":"^5.1.2","coveradge":"^0.8.2","eslint":"^9.20.1","eslint-config-ash-nazg":"^36.22.2","http-server":"^14.1.1","license-badger":"^0.21.1","mocha":"^10.8.2","mocha-badge-generator":"^0.11.0","mocha-multi-reporters":"^1.5.1","open-cli":"^8.0.0","rollup":"4.27.2","typedoc":"^0.27.7","typescript":"^5.7.3"},"keywords":["json","jsonpath"],"browserslist":["defaults, not op_mini all"],"c8":{"reporter":["text","html","json-summary"],"exclude":[".mocharc.cjs","eslint.config.js","src/jsonpath.d.ts","rollup.config.js",".idea","coverage","dist","demo","docs","ignore","test","test-helpers"]},"scripts":{"prepublishOnly":"pnpm i","license-badge":"license-badger --corrections --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg","license-badge-dev":"license-badger --corrections --filteredTypes=nonempty --textTemplate \"License types\n(all devDeps)\" --allDevelopment badges/licenses-badge-dev.svg","license-badges":"npm run license-badge && npm run license-badge-dev","build-docs":"typedoc --out docs/ts src --excludeExternals --entryPointStrategy Expand","open-docs":"open-cli http://localhost:8084/docs/ts/ && npm start","coverage":"open-cli http://localhost:8084/coverage/ && npm start","coverage-badge":"coveradge badges/coverage-badge.svg","node-import-test":"node --experimental-modules demo/node-import-test.mjs","open":"open-cli http://localhost:8084/demo/ && npm start","start":"http-server -p 8084","cli":"./bin/jsonpath-cli.js package.json name","typescript":"tsc","mocha":"mocha --require test-helpers/node-env.js --reporter-options configFile=mocha-multi-reporters.json test","c8":"rm -Rf ./coverage && rm -Rf ./node_modules/.cache && c8 --all npm run mocha && npm run coverage-badge","rollup":"rollup -c","eslint":"eslint .","lint":"npm run eslint","test":"npm run eslint && npm run rollup && npm run c8 && npm run typescript","browser-test":"npm run eslint && npm run rollup && open-cli http://localhost:8084/test/ && npm start"},"_lastModified":"2025-11-21T09:46:33.534Z"}
@@ -0,0 +1,200 @@
1
+ /* eslint-disable no-bitwise -- Convenient */
2
+ import jsep from 'jsep';
3
+ import jsepRegex from '@jsep-plugin/regex';
4
+ import jsepAssignment from '@jsep-plugin/assignment';
5
+
6
+ // register plugins
7
+ jsep.plugins.register(jsepRegex, jsepAssignment);
8
+ jsep.addUnaryOp('typeof');
9
+ jsep.addLiteral('null', null);
10
+ jsep.addLiteral('undefined', undefined);
11
+
12
+ const BLOCKED_PROTO_PROPERTIES = new Set([
13
+ 'constructor',
14
+ '__proto__',
15
+ '__defineGetter__',
16
+ '__defineSetter__'
17
+ ]);
18
+
19
+ const SafeEval = {
20
+ /**
21
+ * @param {jsep.Expression} ast
22
+ * @param {Record<string, any>} subs
23
+ */
24
+ evalAst (ast, subs) {
25
+ switch (ast.type) {
26
+ case 'BinaryExpression':
27
+ case 'LogicalExpression':
28
+ return SafeEval.evalBinaryExpression(ast, subs);
29
+ case 'Compound':
30
+ return SafeEval.evalCompound(ast, subs);
31
+ case 'ConditionalExpression':
32
+ return SafeEval.evalConditionalExpression(ast, subs);
33
+ case 'Identifier':
34
+ return SafeEval.evalIdentifier(ast, subs);
35
+ case 'Literal':
36
+ return SafeEval.evalLiteral(ast, subs);
37
+ case 'MemberExpression':
38
+ return SafeEval.evalMemberExpression(ast, subs);
39
+ case 'UnaryExpression':
40
+ return SafeEval.evalUnaryExpression(ast, subs);
41
+ case 'ArrayExpression':
42
+ return SafeEval.evalArrayExpression(ast, subs);
43
+ case 'CallExpression':
44
+ return SafeEval.evalCallExpression(ast, subs);
45
+ case 'AssignmentExpression':
46
+ return SafeEval.evalAssignmentExpression(ast, subs);
47
+ default:
48
+ throw SyntaxError('Unexpected expression', ast);
49
+ }
50
+ },
51
+ evalBinaryExpression (ast, subs) {
52
+ const result = {
53
+ '||': (a, b) => a || b(),
54
+ '&&': (a, b) => a && b(),
55
+ '|': (a, b) => a | b(),
56
+ '^': (a, b) => a ^ b(),
57
+ '&': (a, b) => a & b(),
58
+ // eslint-disable-next-line eqeqeq -- API
59
+ '==': (a, b) => a == b(),
60
+ // eslint-disable-next-line eqeqeq -- API
61
+ '!=': (a, b) => a != b(),
62
+ '===': (a, b) => a === b(),
63
+ '!==': (a, b) => a !== b(),
64
+ '<': (a, b) => a < b(),
65
+ '>': (a, b) => a > b(),
66
+ '<=': (a, b) => a <= b(),
67
+ '>=': (a, b) => a >= b(),
68
+ '<<': (a, b) => a << b(),
69
+ '>>': (a, b) => a >> b(),
70
+ '>>>': (a, b) => a >>> b(),
71
+ '+': (a, b) => a + b(),
72
+ '-': (a, b) => a - b(),
73
+ '*': (a, b) => a * b(),
74
+ '/': (a, b) => a / b(),
75
+ '%': (a, b) => a % b()
76
+ }[ast.operator](
77
+ SafeEval.evalAst(ast.left, subs),
78
+ () => SafeEval.evalAst(ast.right, subs)
79
+ );
80
+ return result;
81
+ },
82
+ evalCompound (ast, subs) {
83
+ let last;
84
+ for (let i = 0; i < ast.body.length; i++) {
85
+ if (
86
+ ast.body[i].type === 'Identifier' &&
87
+ ['var', 'let', 'const'].includes(ast.body[i].name) &&
88
+ ast.body[i + 1] &&
89
+ ast.body[i + 1].type === 'AssignmentExpression'
90
+ ) {
91
+ // var x=2; is detected as
92
+ // [{Identifier var}, {AssignmentExpression x=2}]
93
+ // eslint-disable-next-line @stylistic/max-len -- Long
94
+ // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient
95
+ i += 1;
96
+ }
97
+ const expr = ast.body[i];
98
+ last = SafeEval.evalAst(expr, subs);
99
+ }
100
+ return last;
101
+ },
102
+ evalConditionalExpression (ast, subs) {
103
+ if (SafeEval.evalAst(ast.test, subs)) {
104
+ return SafeEval.evalAst(ast.consequent, subs);
105
+ }
106
+ return SafeEval.evalAst(ast.alternate, subs);
107
+ },
108
+ evalIdentifier (ast, subs) {
109
+ if (Object.hasOwn(subs, ast.name)) {
110
+ return subs[ast.name];
111
+ }
112
+ throw ReferenceError(`${ast.name} is not defined`);
113
+ },
114
+ evalLiteral (ast) {
115
+ return ast.value;
116
+ },
117
+ evalMemberExpression (ast, subs) {
118
+ const prop = String(
119
+ // NOTE: `String(value)` throws error when
120
+ // value has overwritten the toString method to return non-string
121
+ // i.e. `value = {toString: () => []}`
122
+ ast.computed
123
+ ? SafeEval.evalAst(ast.property) // `object[property]`
124
+ : ast.property.name // `object.property` property is Identifier
125
+ );
126
+ const obj = SafeEval.evalAst(ast.object, subs);
127
+ if (obj === undefined || obj === null) {
128
+ throw TypeError(
129
+ `Cannot read properties of ${obj} (reading '${prop}')`
130
+ );
131
+ }
132
+ if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
133
+ throw TypeError(
134
+ `Cannot read properties of ${obj} (reading '${prop}')`
135
+ );
136
+ }
137
+ const result = obj[prop];
138
+ if (typeof result === 'function') {
139
+ return result.bind(obj); // arrow functions aren't affected by bind.
140
+ }
141
+ return result;
142
+ },
143
+ evalUnaryExpression (ast, subs) {
144
+ const result = {
145
+ '-': (a) => -SafeEval.evalAst(a, subs),
146
+ '!': (a) => !SafeEval.evalAst(a, subs),
147
+ '~': (a) => ~SafeEval.evalAst(a, subs),
148
+ // eslint-disable-next-line no-implicit-coercion -- API
149
+ '+': (a) => +SafeEval.evalAst(a, subs),
150
+ typeof: (a) => typeof SafeEval.evalAst(a, subs)
151
+ }[ast.operator](ast.argument);
152
+ return result;
153
+ },
154
+ evalArrayExpression (ast, subs) {
155
+ return ast.elements.map((el) => SafeEval.evalAst(el, subs));
156
+ },
157
+ evalCallExpression (ast, subs) {
158
+ const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
159
+ const func = SafeEval.evalAst(ast.callee, subs);
160
+ // if (func === Function) {
161
+ // throw new Error('Function constructor is disabled');
162
+ // }
163
+ return func(...args);
164
+ },
165
+ evalAssignmentExpression (ast, subs) {
166
+ if (ast.left.type !== 'Identifier') {
167
+ throw SyntaxError('Invalid left-hand side in assignment');
168
+ }
169
+ const id = ast.left.name;
170
+ const value = SafeEval.evalAst(ast.right, subs);
171
+ subs[id] = value;
172
+ return subs[id];
173
+ }
174
+ };
175
+
176
+ /**
177
+ * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly.
178
+ */
179
+ class SafeScript {
180
+ /**
181
+ * @param {string} expr Expression to evaluate
182
+ */
183
+ constructor (expr) {
184
+ this.code = expr;
185
+ this.ast = jsep(this.code);
186
+ }
187
+
188
+ /**
189
+ * @param {object} context Object whose items will be added
190
+ * to evaluation
191
+ * @returns {EvaluatedResult} Result of evaluated code
192
+ */
193
+ runInNewContext (context) {
194
+ // `Object.create(null)` creates a prototypeless object
195
+ const keyMap = Object.assign(Object.create(null), context);
196
+ return SafeEval.evalAst(this.ast, keyMap);
197
+ }
198
+ }
199
+
200
+ export {SafeScript};
@@ -0,0 +1,102 @@
1
+ import {JSONPath} from './jsonpath.js';
2
+
3
+ /**
4
+ * @typedef {any} ContextItem
5
+ */
6
+
7
+ /**
8
+ * @typedef {any} EvaluatedResult
9
+ */
10
+
11
+ /**
12
+ * @callback ConditionCallback
13
+ * @param {ContextItem} item
14
+ * @returns {boolean}
15
+ */
16
+
17
+ /**
18
+ * Copy items out of one array into another.
19
+ * @param {GenericArray} source Array with items to copy
20
+ * @param {GenericArray} target Array to which to copy
21
+ * @param {ConditionCallback} conditionCb Callback passed the current item;
22
+ * will move item if evaluates to `true`
23
+ * @returns {void}
24
+ */
25
+ const moveToAnotherArray = function (source, target, conditionCb) {
26
+ const il = source.length;
27
+ for (let i = 0; i < il; i++) {
28
+ const item = source[i];
29
+ if (conditionCb(item)) {
30
+ // eslint-disable-next-line @stylistic/max-len -- Long
31
+ // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient
32
+ target.push(source.splice(i--, 1)[0]);
33
+ }
34
+ }
35
+ };
36
+
37
+ /**
38
+ * In-browser replacement for NodeJS' VM.Script.
39
+ */
40
+ class Script {
41
+ /**
42
+ * @param {string} expr Expression to evaluate
43
+ */
44
+ constructor (expr) {
45
+ this.code = expr;
46
+ }
47
+
48
+ /**
49
+ * @param {object} context Object whose items will be added
50
+ * to evaluation
51
+ * @returns {EvaluatedResult} Result of evaluated code
52
+ */
53
+ runInNewContext (context) {
54
+ let expr = this.code;
55
+ const keys = Object.keys(context);
56
+ const funcs = [];
57
+ moveToAnotherArray(keys, funcs, (key) => {
58
+ return typeof context[key] === 'function';
59
+ });
60
+ const values = keys.map((vr) => {
61
+ return context[vr];
62
+ });
63
+
64
+ const funcString = funcs.reduce((s, func) => {
65
+ let fString = context[func].toString();
66
+ if (!(/function/u).test(fString)) {
67
+ fString = 'function ' + fString;
68
+ }
69
+ return 'var ' + func + '=' + fString + ';' + s;
70
+ }, '');
71
+
72
+ expr = funcString + expr;
73
+
74
+ // Mitigate http://perfectionkills.com/global-eval-what-are-the-options/#new_function
75
+ if (!(/(['"])use strict\1/u).test(expr) && !keys.includes('arguments')) {
76
+ expr = 'var arguments = undefined;' + expr;
77
+ }
78
+
79
+ // Remove last semi so `return` will be inserted before
80
+ // the previous one instead, allowing for the return
81
+ // of a bare ending expression
82
+ expr = expr.replace(/;\s*$/u, '');
83
+
84
+ // Insert `return`
85
+ const lastStatementEnd = expr.lastIndexOf(';');
86
+ const code =
87
+ lastStatementEnd !== -1
88
+ ? expr.slice(0, lastStatementEnd + 1) +
89
+ ' return ' +
90
+ expr.slice(lastStatementEnd + 1)
91
+ : ' return ' + expr;
92
+
93
+ // eslint-disable-next-line no-new-func -- User's choice
94
+ return new Function(...keys, code)(...values);
95
+ }
96
+ }
97
+
98
+ JSONPath.prototype.vm = {
99
+ Script
100
+ };
101
+
102
+ export {JSONPath};
@@ -0,0 +1,8 @@
1
+ import vm from 'vm';
2
+ import {JSONPath} from './jsonpath.js';
3
+
4
+ JSONPath.prototype.vm = vm;
5
+
6
+ export {
7
+ JSONPath
8
+ };
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Declaration for https://github.com/s3u/JSONPath
3
+ */
4
+ declare module 'jsonpath-plus' {
5
+ type JSONPathCallback = (
6
+ payload: any, payloadType: any, fullPayload: any
7
+ ) => any
8
+
9
+ type JSONPathOtherTypeCallback = (...args: any[]) => void
10
+
11
+ class EvalClass {
12
+ constructor(code: string);
13
+ runInNewContext(context: object): any;
14
+ }
15
+
16
+ interface JSONPathOptions {
17
+ /**
18
+ * The JSONPath expression as a (normalized or unnormalized) string or
19
+ * array.
20
+ */
21
+ path: string | any[]
22
+ /**
23
+ * The JSON object to evaluate (whether of null, boolean, number,
24
+ * string, object, or array type).
25
+ */
26
+ json: null | boolean | number | string | object | any[]
27
+ /**
28
+ * If this is supplied as false, one may call the evaluate method
29
+ * manually.
30
+ *
31
+ * @default true
32
+ */
33
+ autostart?: true | boolean
34
+ /**
35
+ * Whether the returned array of results will be flattened to a
36
+ * single dimension array.
37
+ *
38
+ * @default false
39
+ */
40
+ flatten?: false | boolean
41
+ /**
42
+ * Can be case-insensitive form of "value", "path", "pointer", "parent",
43
+ * or "parentProperty" to determine respectively whether to return
44
+ * results as the values of the found items, as their absolute paths,
45
+ * as JSON Pointers to the absolute paths, as their parent objects,
46
+ * or as their parent's property name.
47
+ *
48
+ * If set to "all", all of these types will be returned on an object with
49
+ * the type as key name.
50
+ *
51
+ * @default 'value'
52
+ */
53
+ resultType?:
54
+ 'value' | 'path' | 'pointer' | 'parent' | 'parentProperty' | 'all'
55
+
56
+ /**
57
+ * Key-value map of variables to be available to code evaluations such
58
+ * as filtering expressions.
59
+ * (Note that the current path and value will also be available to those
60
+ * expressions; see the Syntax section for details.)
61
+ */
62
+ sandbox?: Map<string, any>
63
+ /**
64
+ * Whether or not to wrap the results in an array.
65
+ *
66
+ * If wrap is set to false, and no results are found, undefined will be
67
+ * returned (as opposed to an empty array when wrap is set to true).
68
+ *
69
+ * If wrap is set to false and a single non-array result is found, that
70
+ * result will be the only item returned (not within an array).
71
+ *
72
+ * An array will still be returned if multiple results are found, however.
73
+ * To avoid ambiguities (in the case where it is necessary to distinguish
74
+ * between a result which is a failure and one which is an empty array),
75
+ * it is recommended to switch the default to false.
76
+ *
77
+ * @default true
78
+ */
79
+ wrap?: true | boolean
80
+ /**
81
+ * Script evaluation method.
82
+ *
83
+ * `safe`: In browser, it will use a minimal scripting engine which doesn't
84
+ * use `eval` or `Function` and satisfies Content Security Policy. In NodeJS,
85
+ * it has no effect and is equivalent to native as scripting is safe there.
86
+ *
87
+ * `native`: uses the native scripting capabilities. i.e. unsafe `eval` or
88
+ * `Function` in browser and `vm.Script` in nodejs.
89
+ *
90
+ * `true`: Same as 'safe'
91
+ *
92
+ * `false`: Disable Javascript executions in path string. Same as `preventEval: true` in previous versions.
93
+ *
94
+ * `callback [ (code, context) => value]`: A custom implementation which is called
95
+ * with `code` and `context` as arguments to return the evaluated value.
96
+ *
97
+ * `class`: A class similar to nodejs vm.Script. It will be created with `code` as constructor argument and the code
98
+ * is evaluated by calling `runInNewContext` with `context`.
99
+ *
100
+ * @default 'safe'
101
+ */
102
+ eval?: 'safe' | 'native' | boolean | ((code: string, context: object) => any) | typeof EvalClass
103
+ /**
104
+ * Ignore errors while evaluating JSONPath expression.
105
+ *
106
+ * `true`: Don't break entire search if an error occurs while evaluating JSONPath expression on one key/value pair.
107
+ *
108
+ * `false`: Break entire search if an error occurs while evaluating JSONPath expression on one key/value pair.
109
+ *
110
+ * @default false
111
+ *
112
+ */
113
+ ignoreEvalErrors?: boolean
114
+ /**
115
+ * In the event that a query could be made to return the root node,
116
+ * this allows the parent of that root node to be returned within results.
117
+ *
118
+ * @default null
119
+ */
120
+ parent?: null | any
121
+ /**
122
+ * In the event that a query could be made to return the root node,
123
+ * this allows the parentProperty of that root node to be returned within
124
+ * results.
125
+ *
126
+ * @default null
127
+ */
128
+ parentProperty?: null | any
129
+ /**
130
+ * If supplied, a callback will be called immediately upon retrieval of
131
+ * an end point value.
132
+ *
133
+ * The three arguments supplied will be the value of the payload
134
+ * (according to `resultType`), the type of the payload (whether it is
135
+ * a normal "value" or a "property" name), and a full payload object
136
+ * (with all `resultType`s).
137
+ *
138
+ * @default undefined
139
+ */
140
+ callback?: undefined | JSONPathCallback
141
+ /**
142
+ * In the current absence of JSON Schema support,
143
+ * one can determine types beyond the built-in types by adding the
144
+ * perator `@other()` at the end of one's query.
145
+ *
146
+ * If such a path is encountered, the `otherTypeCallback` will be invoked
147
+ * with the value of the item, its path, its parent, and its parent's
148
+ * property name, and it should return a boolean indicating whether the
149
+ * supplied value belongs to the "other" type or not (or it may handle
150
+ * transformations and return false).
151
+ *
152
+ * @default undefined
153
+ * <A function that throws an error when `@other()` is encountered>
154
+ */
155
+ otherTypeCallback?: undefined | JSONPathOtherTypeCallback
156
+ }
157
+
158
+ interface JSONPathOptionsAutoStart extends JSONPathOptions {
159
+ autostart: false
160
+ }
161
+
162
+ interface JSONPathCallable {
163
+ <T = any>(options: JSONPathOptionsAutoStart): JSONPathClass
164
+ <T = any>(options: JSONPathOptions): T
165
+
166
+ <T = any>(
167
+ path: JSONPathOptions['path'],
168
+ json: JSONPathOptions['json'],
169
+ callback: JSONPathOptions['callback'],
170
+ otherTypeCallback: JSONPathOptions['otherTypeCallback']
171
+ ): T
172
+ }
173
+
174
+ class JSONPathClass {
175
+ /**
176
+ * Exposes the cache object for those who wish to preserve and reuse
177
+ * it for optimization purposes.
178
+ */
179
+ cache: any
180
+
181
+ /**
182
+ * Accepts a normalized or unnormalized path as string and
183
+ * converts to an array: for example,
184
+ * `['$', 'aProperty', 'anotherProperty']`.
185
+ */
186
+ toPathArray(path: string): string[]
187
+
188
+ /**
189
+ * Accepts a path array and converts to a normalized path string.
190
+ * The string will be in a form like:
191
+ * `$['aProperty']['anotherProperty][0]`.
192
+ * The JSONPath terminal constructions `~` and `^` and type operators
193
+ * like `@string()` are silently stripped.
194
+ */
195
+ toPathString(path: string[]): string
196
+
197
+ /**
198
+ * Accepts a path array and converts to a JSON Pointer.
199
+ *
200
+ * The string will be in a form like: `/aProperty/anotherProperty/0`
201
+ * (with any `~` and `/` internal characters escaped as per the JSON
202
+ * Pointer spec).
203
+ *
204
+ * The JSONPath terminal constructions `~` and `^` and type operators
205
+ * like `@string()` are silently stripped.
206
+ */
207
+ toPointer(path: string[]): any
208
+
209
+ evaluate(
210
+ path: JSONPathOptions['path'],
211
+ json: JSONPathOptions['json'],
212
+ callback: JSONPathOptions['callback'],
213
+ otherTypeCallback: JSONPathOptions['otherTypeCallback']
214
+ ): any
215
+ evaluate(options: {
216
+ path: JSONPathOptions['path'],
217
+ json: JSONPathOptions['json'],
218
+ callback: JSONPathOptions['callback'],
219
+ otherTypeCallback: JSONPathOptions['otherTypeCallback']
220
+ }): any
221
+ }
222
+
223
+ type JSONPathType = JSONPathCallable & JSONPathClass
224
+
225
+ export const JSONPath: JSONPathType
226
+ }