@speclynx/apidom-json-path 2.0.1 → 2.2.0
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.
- package/CHANGELOG.md +10 -0
- package/README.md +5 -60
- package/dist/apidom-json-path.browser.js +7239 -4524
- package/dist/apidom-json-path.browser.min.js +1 -1
- package/package.json +5 -7
- package/src/index.cjs +57 -9
- package/src/index.mjs +65 -4
- package/src/realm.cjs +148 -0
- package/src/realm.mjs +145 -0
- package/types/apidom-json-path.d.ts +93 -57
- package/src/errors/EvaluationJsonPathError.cjs +0 -25
- package/src/errors/EvaluationJsonPathError.mjs +0 -19
- package/src/errors/JsonPathError.cjs +0 -10
- package/src/errors/JsonPathError.mjs +0 -7
- package/src/errors/MultiEvaluationJsonPathError.cjs +0 -25
- package/src/errors/MultiEvaluationJsonPathError.mjs +0 -19
- package/src/evaluate-multi.cjs +0 -53
- package/src/evaluate-multi.mjs +0 -46
- package/src/evaluate.cjs +0 -36
- package/src/evaluate.mjs +0 -30
package/src/index.mjs
CHANGED
|
@@ -1,4 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { evaluate as baseEvaluate } from '@swaggerexpert/jsonpath';
|
|
2
|
+
export {
|
|
3
|
+
/**
|
|
4
|
+
* Parsing
|
|
5
|
+
*/
|
|
6
|
+
parse, CSTTranslator, CSTOptimizedTranslator, ASTTranslator, XMLTranslator,
|
|
7
|
+
/**
|
|
8
|
+
* Testing
|
|
9
|
+
*/
|
|
10
|
+
test,
|
|
11
|
+
/**
|
|
12
|
+
* Normalized Path
|
|
13
|
+
*/
|
|
14
|
+
NormalizedPath,
|
|
15
|
+
/**
|
|
16
|
+
* Evaluation
|
|
17
|
+
*/
|
|
18
|
+
functions, EvaluationRealm, JSONEvaluationRealm,
|
|
19
|
+
/**
|
|
20
|
+
* Grammar
|
|
21
|
+
*/
|
|
22
|
+
Grammar,
|
|
23
|
+
/**
|
|
24
|
+
* Errors
|
|
25
|
+
*/
|
|
26
|
+
JSONPathError, JSONPathParseError, JSONNormalizedPathError, JSONPathEvaluateError } from '@swaggerexpert/jsonpath';
|
|
27
|
+
import ApiDOMEvaluationRealm from "./realm.mjs";
|
|
28
|
+
export { ApiDOMEvaluationRealm };
|
|
29
|
+
const realm = new ApiDOMEvaluationRealm();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Options for ApiDOM JSONPath evaluation.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Evaluate a JSONPath expression against an ApiDOM element.
|
|
38
|
+
*
|
|
39
|
+
* @param value - ApiDOM element to query
|
|
40
|
+
* @param expression - JSONPath expression
|
|
41
|
+
* @param options - Evaluation options
|
|
42
|
+
* @returns Array of matched values
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
47
|
+
* import { evaluate } from '@speclynx/apidom-json-path';
|
|
48
|
+
*
|
|
49
|
+
* const element = new ObjectElement({ a: { b: [1, 2, 3] } });
|
|
50
|
+
* const results = evaluate(element, '$.a.b[*]');
|
|
51
|
+
* // => [NumberElement(1), NumberElement(2), NumberElement(3)]
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export const evaluate = (value, expression, options = {}) => {
|
|
57
|
+
return baseEvaluate(value, expression, {
|
|
58
|
+
...options,
|
|
59
|
+
realm
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Re-export all types
|
|
65
|
+
*/
|
package/src/realm.cjs
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
+
var _jsonpath = require("@swaggerexpert/jsonpath");
|
|
7
|
+
/**
|
|
8
|
+
* ApiDOM Evaluation Realm implementation for JSONPath.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class ApiDOMEvaluationRealm extends _jsonpath.EvaluationRealm {
|
|
12
|
+
name = 'apidom';
|
|
13
|
+
isObject(value) {
|
|
14
|
+
return (0, _apidomDatamodel.isObjectElement)(value);
|
|
15
|
+
}
|
|
16
|
+
isArray(value) {
|
|
17
|
+
return (0, _apidomDatamodel.isArrayElement)(value);
|
|
18
|
+
}
|
|
19
|
+
isString(value) {
|
|
20
|
+
return (0, _apidomDatamodel.isStringElement)(value);
|
|
21
|
+
}
|
|
22
|
+
isNumber(value) {
|
|
23
|
+
return (0, _apidomDatamodel.isNumberElement)(value);
|
|
24
|
+
}
|
|
25
|
+
isBoolean(value) {
|
|
26
|
+
return (0, _apidomDatamodel.isBooleanElement)(value);
|
|
27
|
+
}
|
|
28
|
+
isNull(value) {
|
|
29
|
+
return (0, _apidomDatamodel.isNullElement)(value);
|
|
30
|
+
}
|
|
31
|
+
getString(value) {
|
|
32
|
+
if ((0, _apidomDatamodel.isStringElement)(value)) return value.toValue();
|
|
33
|
+
if (typeof value === 'string') return value;
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
getProperty(value, key) {
|
|
37
|
+
if (!(0, _apidomDatamodel.isObjectElement)(value)) return undefined;
|
|
38
|
+
if (!value.hasKey(key)) return undefined;
|
|
39
|
+
return value.get(key);
|
|
40
|
+
}
|
|
41
|
+
hasProperty(value, key) {
|
|
42
|
+
if (!(0, _apidomDatamodel.isObjectElement)(value)) return false;
|
|
43
|
+
return value.hasKey(key);
|
|
44
|
+
}
|
|
45
|
+
getElement(value, index) {
|
|
46
|
+
if (!(0, _apidomDatamodel.isArrayElement)(value)) return undefined;
|
|
47
|
+
if (index < 0 || index >= value.length) return undefined;
|
|
48
|
+
return value.get(index);
|
|
49
|
+
}
|
|
50
|
+
getKeys(value) {
|
|
51
|
+
if (!(0, _apidomDatamodel.isObjectElement)(value)) return [];
|
|
52
|
+
return value.keys();
|
|
53
|
+
}
|
|
54
|
+
getLength(value) {
|
|
55
|
+
if ((0, _apidomDatamodel.isStringElement)(value)) return [...value.toValue()].length;
|
|
56
|
+
if ((0, _apidomDatamodel.isArrayElement)(value)) return value.length;
|
|
57
|
+
if ((0, _apidomDatamodel.isObjectElement)(value)) return value.length;
|
|
58
|
+
if (typeof value === 'string') return [...value].length;
|
|
59
|
+
if (Array.isArray(value)) return value.length;
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
*entries(value) {
|
|
63
|
+
if ((0, _apidomDatamodel.isArrayElement)(value)) {
|
|
64
|
+
let index = 0;
|
|
65
|
+
for (const item of value) {
|
|
66
|
+
yield [index, item];
|
|
67
|
+
index += 1;
|
|
68
|
+
}
|
|
69
|
+
} else if ((0, _apidomDatamodel.isObjectElement)(value)) {
|
|
70
|
+
for (const member of value) {
|
|
71
|
+
yield [member.key.toValue(), member.value];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
compare(left, operator, right) {
|
|
76
|
+
// Handle Nothing (undefined) comparisons
|
|
77
|
+
if (left === undefined || right === undefined) {
|
|
78
|
+
if (operator === '==') return left === undefined && right === undefined;
|
|
79
|
+
if (operator === '!=') return !(left === undefined && right === undefined);
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Check if both are numbers (elements or primitives)
|
|
84
|
+
const leftIsNumber = (0, _apidomDatamodel.isNumberElement)(left) || typeof left === 'number';
|
|
85
|
+
const rightIsNumber = (0, _apidomDatamodel.isNumberElement)(right) || typeof right === 'number';
|
|
86
|
+
|
|
87
|
+
// For numeric values, use primitive comparison with -0 normalization (RFC 9535)
|
|
88
|
+
if (leftIsNumber && rightIsNumber) {
|
|
89
|
+
const leftPrimitive = (0, _apidomDatamodel.isNumberElement)(left) ? left.toValue() : left;
|
|
90
|
+
const rightPrimitive = (0, _apidomDatamodel.isNumberElement)(right) ? right.toValue() : right;
|
|
91
|
+
const leftVal = Object.is(leftPrimitive, -0) ? 0 : leftPrimitive;
|
|
92
|
+
const rightVal = Object.is(rightPrimitive, -0) ? 0 : rightPrimitive;
|
|
93
|
+
switch (operator) {
|
|
94
|
+
case '==':
|
|
95
|
+
return leftVal === rightVal;
|
|
96
|
+
case '!=':
|
|
97
|
+
return leftVal !== rightVal;
|
|
98
|
+
case '<':
|
|
99
|
+
return leftVal < rightVal;
|
|
100
|
+
case '>':
|
|
101
|
+
return leftVal > rightVal;
|
|
102
|
+
case '<=':
|
|
103
|
+
return leftVal <= rightVal;
|
|
104
|
+
case '>=':
|
|
105
|
+
return leftVal >= rightVal;
|
|
106
|
+
default:
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Check if both are strings (elements or primitives)
|
|
112
|
+
const leftIsString = (0, _apidomDatamodel.isStringElement)(left) || typeof left === 'string';
|
|
113
|
+
const rightIsString = (0, _apidomDatamodel.isStringElement)(right) || typeof right === 'string';
|
|
114
|
+
|
|
115
|
+
// For string values, use primitive comparison
|
|
116
|
+
if (leftIsString && rightIsString) {
|
|
117
|
+
const leftVal = (0, _apidomDatamodel.isStringElement)(left) ? left.toValue() : left;
|
|
118
|
+
const rightVal = (0, _apidomDatamodel.isStringElement)(right) ? right.toValue() : right;
|
|
119
|
+
switch (operator) {
|
|
120
|
+
case '==':
|
|
121
|
+
return leftVal === rightVal;
|
|
122
|
+
case '!=':
|
|
123
|
+
return leftVal !== rightVal;
|
|
124
|
+
case '<':
|
|
125
|
+
return leftVal < rightVal;
|
|
126
|
+
case '>':
|
|
127
|
+
return leftVal > rightVal;
|
|
128
|
+
case '<=':
|
|
129
|
+
return leftVal <= rightVal;
|
|
130
|
+
case '>=':
|
|
131
|
+
return leftVal >= rightVal;
|
|
132
|
+
default:
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// For other types (booleans, nulls), only equality operators are defined (RFC 9535)
|
|
138
|
+
if (operator === '==') {
|
|
139
|
+
return (0, _apidomDatamodel.refract)(left).equals(right);
|
|
140
|
+
}
|
|
141
|
+
if (operator === '!=') {
|
|
142
|
+
return !(0, _apidomDatamodel.refract)(left).equals(right);
|
|
143
|
+
}
|
|
144
|
+
// Comparison operators (<, >, <=, >=) are not defined for non-numeric, non-string types
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
var _default = exports.default = ApiDOMEvaluationRealm;
|
package/src/realm.mjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { isObjectElement, isArrayElement, isStringElement, isNumberElement, isBooleanElement, isNullElement, refract } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { EvaluationRealm } from '@swaggerexpert/jsonpath';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ApiDOM Evaluation Realm implementation for JSONPath.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
class ApiDOMEvaluationRealm extends EvaluationRealm {
|
|
9
|
+
name = 'apidom';
|
|
10
|
+
isObject(value) {
|
|
11
|
+
return isObjectElement(value);
|
|
12
|
+
}
|
|
13
|
+
isArray(value) {
|
|
14
|
+
return isArrayElement(value);
|
|
15
|
+
}
|
|
16
|
+
isString(value) {
|
|
17
|
+
return isStringElement(value);
|
|
18
|
+
}
|
|
19
|
+
isNumber(value) {
|
|
20
|
+
return isNumberElement(value);
|
|
21
|
+
}
|
|
22
|
+
isBoolean(value) {
|
|
23
|
+
return isBooleanElement(value);
|
|
24
|
+
}
|
|
25
|
+
isNull(value) {
|
|
26
|
+
return isNullElement(value);
|
|
27
|
+
}
|
|
28
|
+
getString(value) {
|
|
29
|
+
if (isStringElement(value)) return value.toValue();
|
|
30
|
+
if (typeof value === 'string') return value;
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
getProperty(value, key) {
|
|
34
|
+
if (!isObjectElement(value)) return undefined;
|
|
35
|
+
if (!value.hasKey(key)) return undefined;
|
|
36
|
+
return value.get(key);
|
|
37
|
+
}
|
|
38
|
+
hasProperty(value, key) {
|
|
39
|
+
if (!isObjectElement(value)) return false;
|
|
40
|
+
return value.hasKey(key);
|
|
41
|
+
}
|
|
42
|
+
getElement(value, index) {
|
|
43
|
+
if (!isArrayElement(value)) return undefined;
|
|
44
|
+
if (index < 0 || index >= value.length) return undefined;
|
|
45
|
+
return value.get(index);
|
|
46
|
+
}
|
|
47
|
+
getKeys(value) {
|
|
48
|
+
if (!isObjectElement(value)) return [];
|
|
49
|
+
return value.keys();
|
|
50
|
+
}
|
|
51
|
+
getLength(value) {
|
|
52
|
+
if (isStringElement(value)) return [...value.toValue()].length;
|
|
53
|
+
if (isArrayElement(value)) return value.length;
|
|
54
|
+
if (isObjectElement(value)) return value.length;
|
|
55
|
+
if (typeof value === 'string') return [...value].length;
|
|
56
|
+
if (Array.isArray(value)) return value.length;
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
*entries(value) {
|
|
60
|
+
if (isArrayElement(value)) {
|
|
61
|
+
let index = 0;
|
|
62
|
+
for (const item of value) {
|
|
63
|
+
yield [index, item];
|
|
64
|
+
index += 1;
|
|
65
|
+
}
|
|
66
|
+
} else if (isObjectElement(value)) {
|
|
67
|
+
for (const member of value) {
|
|
68
|
+
yield [member.key.toValue(), member.value];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
compare(left, operator, right) {
|
|
73
|
+
// Handle Nothing (undefined) comparisons
|
|
74
|
+
if (left === undefined || right === undefined) {
|
|
75
|
+
if (operator === '==') return left === undefined && right === undefined;
|
|
76
|
+
if (operator === '!=') return !(left === undefined && right === undefined);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Check if both are numbers (elements or primitives)
|
|
81
|
+
const leftIsNumber = isNumberElement(left) || typeof left === 'number';
|
|
82
|
+
const rightIsNumber = isNumberElement(right) || typeof right === 'number';
|
|
83
|
+
|
|
84
|
+
// For numeric values, use primitive comparison with -0 normalization (RFC 9535)
|
|
85
|
+
if (leftIsNumber && rightIsNumber) {
|
|
86
|
+
const leftPrimitive = isNumberElement(left) ? left.toValue() : left;
|
|
87
|
+
const rightPrimitive = isNumberElement(right) ? right.toValue() : right;
|
|
88
|
+
const leftVal = Object.is(leftPrimitive, -0) ? 0 : leftPrimitive;
|
|
89
|
+
const rightVal = Object.is(rightPrimitive, -0) ? 0 : rightPrimitive;
|
|
90
|
+
switch (operator) {
|
|
91
|
+
case '==':
|
|
92
|
+
return leftVal === rightVal;
|
|
93
|
+
case '!=':
|
|
94
|
+
return leftVal !== rightVal;
|
|
95
|
+
case '<':
|
|
96
|
+
return leftVal < rightVal;
|
|
97
|
+
case '>':
|
|
98
|
+
return leftVal > rightVal;
|
|
99
|
+
case '<=':
|
|
100
|
+
return leftVal <= rightVal;
|
|
101
|
+
case '>=':
|
|
102
|
+
return leftVal >= rightVal;
|
|
103
|
+
default:
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Check if both are strings (elements or primitives)
|
|
109
|
+
const leftIsString = isStringElement(left) || typeof left === 'string';
|
|
110
|
+
const rightIsString = isStringElement(right) || typeof right === 'string';
|
|
111
|
+
|
|
112
|
+
// For string values, use primitive comparison
|
|
113
|
+
if (leftIsString && rightIsString) {
|
|
114
|
+
const leftVal = isStringElement(left) ? left.toValue() : left;
|
|
115
|
+
const rightVal = isStringElement(right) ? right.toValue() : right;
|
|
116
|
+
switch (operator) {
|
|
117
|
+
case '==':
|
|
118
|
+
return leftVal === rightVal;
|
|
119
|
+
case '!=':
|
|
120
|
+
return leftVal !== rightVal;
|
|
121
|
+
case '<':
|
|
122
|
+
return leftVal < rightVal;
|
|
123
|
+
case '>':
|
|
124
|
+
return leftVal > rightVal;
|
|
125
|
+
case '<=':
|
|
126
|
+
return leftVal <= rightVal;
|
|
127
|
+
case '>=':
|
|
128
|
+
return leftVal >= rightVal;
|
|
129
|
+
default:
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// For other types (booleans, nulls), only equality operators are defined (RFC 9535)
|
|
135
|
+
if (operator === '==') {
|
|
136
|
+
return refract(left).equals(right);
|
|
137
|
+
}
|
|
138
|
+
if (operator === '!=') {
|
|
139
|
+
return !refract(left).equals(right);
|
|
140
|
+
}
|
|
141
|
+
// Comparison operators (<, >, <=, >=) are not defined for non-numeric, non-string types
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export default ApiDOMEvaluationRealm;
|
|
@@ -1,78 +1,114 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ArrayElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { ASTTranslator } from '@swaggerexpert/jsonpath';
|
|
3
|
+
import { CSTOptimizedTranslator } from '@swaggerexpert/jsonpath';
|
|
4
|
+
import { CSTTranslator } from '@swaggerexpert/jsonpath';
|
|
5
|
+
import { EvaluationRealm } from '@swaggerexpert/jsonpath';
|
|
6
|
+
import { functions } from '@swaggerexpert/jsonpath';
|
|
7
|
+
import { Grammar } from '@swaggerexpert/jsonpath';
|
|
8
|
+
import { JSONEvaluationRealm } from '@swaggerexpert/jsonpath';
|
|
9
|
+
import { JSONNormalizedPathError } from '@swaggerexpert/jsonpath';
|
|
10
|
+
import { JSONPathError } from '@swaggerexpert/jsonpath';
|
|
11
|
+
import { JSONPathEvaluateError } from '@swaggerexpert/jsonpath';
|
|
12
|
+
import { JSONPathParseError } from '@swaggerexpert/jsonpath';
|
|
13
|
+
import { NormalizedPath } from '@swaggerexpert/jsonpath';
|
|
14
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
15
|
+
import { parse } from '@swaggerexpert/jsonpath';
|
|
16
|
+
import { test as test_2 } from '@swaggerexpert/jsonpath';
|
|
17
|
+
import { XMLTranslator } from '@swaggerexpert/jsonpath';
|
|
4
18
|
|
|
5
19
|
/**
|
|
20
|
+
* Options for ApiDOM JSONPath evaluation.
|
|
6
21
|
* @public
|
|
7
22
|
*/
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
export declare interface ApiDOMEvaluateOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Optional callback called for each match.
|
|
26
|
+
* @param value - The matched value
|
|
27
|
+
* @param normalizedPath - The normalized path to the match
|
|
28
|
+
*/
|
|
29
|
+
callback?: (value: unknown, normalizedPath: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Optional custom function registry.
|
|
32
|
+
* Can extend or override built-in functions (length, count, match, search, value).
|
|
33
|
+
*/
|
|
34
|
+
functions?: Record<string, (...args: unknown[]) => unknown>;
|
|
35
|
+
}
|
|
12
36
|
|
|
13
37
|
/**
|
|
14
|
-
*
|
|
38
|
+
* ApiDOM Evaluation Realm implementation for JSONPath.
|
|
15
39
|
* @public
|
|
16
40
|
*/
|
|
17
|
-
export declare
|
|
41
|
+
export declare class ApiDOMEvaluationRealm extends EvaluationRealm {
|
|
42
|
+
name: string;
|
|
43
|
+
isObject(value: unknown): value is ObjectElement;
|
|
44
|
+
isArray(value: unknown): value is ArrayElement;
|
|
45
|
+
isString(value: unknown): boolean;
|
|
46
|
+
isNumber(value: unknown): boolean;
|
|
47
|
+
isBoolean(value: unknown): boolean;
|
|
48
|
+
isNull(value: unknown): boolean;
|
|
49
|
+
getString(value: unknown): string | undefined;
|
|
50
|
+
getProperty(value: unknown, key: string): unknown;
|
|
51
|
+
hasProperty(value: unknown, key: string): boolean;
|
|
52
|
+
getElement(value: unknown, index: number): unknown;
|
|
53
|
+
getKeys(value: unknown): string[];
|
|
54
|
+
getLength(value: unknown): number;
|
|
55
|
+
entries(value: unknown): Iterable<[string | number, unknown]>;
|
|
56
|
+
compare(left: unknown, operator: string, right: unknown): boolean;
|
|
57
|
+
}
|
|
18
58
|
|
|
19
|
-
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export declare type EvaluateMulti = {
|
|
23
|
-
<T extends Element_2>(paths: string[], element: T): JSONPathEvalTuple[];
|
|
24
|
-
<T extends Element_2>(paths: string[][], element: T): JSONPathEvalTuple[];
|
|
25
|
-
};
|
|
59
|
+
export { ASTTranslator }
|
|
26
60
|
|
|
27
|
-
|
|
28
|
-
* Evaluates multiple JSONPaths on ApiDOM element.
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export declare const evaluateMulti: EvaluateMulti;
|
|
61
|
+
export { CSTOptimizedTranslator }
|
|
32
62
|
|
|
33
|
-
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export declare class EvaluationJsonPathError<T extends Element_2> extends JsonPathError {
|
|
37
|
-
readonly path: string | string[];
|
|
38
|
-
readonly element: T;
|
|
39
|
-
constructor(message?: string, structuredOptions?: EvaluationJsonPathErrorOptions<T>);
|
|
40
|
-
}
|
|
63
|
+
export { CSTTranslator }
|
|
41
64
|
|
|
42
65
|
/**
|
|
66
|
+
* Evaluate a JSONPath expression against an ApiDOM element.
|
|
67
|
+
*
|
|
68
|
+
* @param value - ApiDOM element to query
|
|
69
|
+
* @param expression - JSONPath expression
|
|
70
|
+
* @param options - Evaluation options
|
|
71
|
+
* @returns Array of matched values
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
76
|
+
* import { evaluate } from '@speclynx/apidom-json-path';
|
|
77
|
+
*
|
|
78
|
+
* const element = new ObjectElement({ a: { b: [1, 2, 3] } });
|
|
79
|
+
* const results = evaluate(element, '$.a.b[*]');
|
|
80
|
+
* // => [NumberElement(1), NumberElement(2), NumberElement(3)]
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
43
83
|
* @public
|
|
44
84
|
*/
|
|
45
|
-
export declare
|
|
46
|
-
path: string | string[];
|
|
47
|
-
element: T;
|
|
48
|
-
}
|
|
85
|
+
export declare const evaluate: <T = unknown>(value: unknown, expression: string, options?: ApiDOMEvaluateOptions) => T[];
|
|
49
86
|
|
|
50
|
-
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
export declare class JsonPathError extends ApiDOMStructuredError {
|
|
54
|
-
}
|
|
87
|
+
export { EvaluationRealm }
|
|
55
88
|
|
|
56
|
-
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export declare type JSONPathEvalTuple = [string, Element_2[]];
|
|
89
|
+
export { functions }
|
|
60
90
|
|
|
61
|
-
|
|
62
|
-
* @public
|
|
63
|
-
*/
|
|
64
|
-
export declare class MultiEvaluationJsonPathError<T extends Element_2> extends JsonPathError {
|
|
65
|
-
readonly paths: string[] | string[][];
|
|
66
|
-
readonly element: T;
|
|
67
|
-
constructor(message?: string, structuredOptions?: MultiEvaluationJsonPathErrorOptions<T>);
|
|
68
|
-
}
|
|
91
|
+
export { Grammar }
|
|
69
92
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
93
|
+
export { JSONEvaluationRealm }
|
|
94
|
+
|
|
95
|
+
export { JSONNormalizedPathError }
|
|
96
|
+
|
|
97
|
+
export { JSONPathError }
|
|
98
|
+
|
|
99
|
+
export { JSONPathEvaluateError }
|
|
100
|
+
|
|
101
|
+
export { JSONPathParseError }
|
|
102
|
+
|
|
103
|
+
export { NormalizedPath }
|
|
104
|
+
|
|
105
|
+
export { parse }
|
|
106
|
+
|
|
107
|
+
export { test_2 as test }
|
|
108
|
+
|
|
109
|
+
export { XMLTranslator }
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
export * from "@swaggerexpert/jsonpath";
|
|
77
113
|
|
|
78
114
|
export { }
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _JsonPathError = _interopRequireDefault(require("./JsonPathError.cjs"));
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class EvaluationJsonPathError extends _JsonPathError.default {
|
|
15
|
-
path;
|
|
16
|
-
element;
|
|
17
|
-
constructor(message, structuredOptions) {
|
|
18
|
-
super(message, structuredOptions);
|
|
19
|
-
if (typeof structuredOptions !== 'undefined') {
|
|
20
|
-
this.path = structuredOptions.path;
|
|
21
|
-
this.element = structuredOptions.element;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
var _default = exports.default = EvaluationJsonPathError;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import JsonPathError from "./JsonPathError.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class EvaluationJsonPathError extends JsonPathError {
|
|
9
|
-
path;
|
|
10
|
-
element;
|
|
11
|
-
constructor(message, structuredOptions) {
|
|
12
|
-
super(message, structuredOptions);
|
|
13
|
-
if (typeof structuredOptions !== 'undefined') {
|
|
14
|
-
this.path = structuredOptions.path;
|
|
15
|
-
this.element = structuredOptions.element;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export default EvaluationJsonPathError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
var _apidomError = require("@speclynx/apidom-error");
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
class JsonPathError extends _apidomError.ApiDOMStructuredError {}
|
|
10
|
-
var _default = exports.default = JsonPathError;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _JsonPathError = _interopRequireDefault(require("./JsonPathError.cjs"));
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class MultiEvaluationJsonPathError extends _JsonPathError.default {
|
|
15
|
-
paths;
|
|
16
|
-
element;
|
|
17
|
-
constructor(message, structuredOptions) {
|
|
18
|
-
super(message, structuredOptions);
|
|
19
|
-
if (typeof structuredOptions !== 'undefined') {
|
|
20
|
-
this.paths = structuredOptions.paths;
|
|
21
|
-
this.element = structuredOptions.element;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
var _default = exports.default = MultiEvaluationJsonPathError;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import JsonPathError from "./JsonPathError.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class MultiEvaluationJsonPathError extends JsonPathError {
|
|
9
|
-
paths;
|
|
10
|
-
element;
|
|
11
|
-
constructor(message, structuredOptions) {
|
|
12
|
-
super(message, structuredOptions);
|
|
13
|
-
if (typeof structuredOptions !== 'undefined') {
|
|
14
|
-
this.paths = structuredOptions.paths;
|
|
15
|
-
this.element = structuredOptions.element;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export default MultiEvaluationJsonPathError;
|