@swagger-api/apidom-json-pointer-relative 0.78.0 → 0.80.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 +8 -0
- package/cjs/errors/EvaluationRelativeJsonPointerError.cjs +3 -15
- package/cjs/evaluate.cjs +18 -18
- package/dist/apidom-json-pointer-relative.browser.js +134 -328
- package/dist/apidom-json-pointer-relative.browser.min.js +1 -1
- package/es/errors/EvaluationRelativeJsonPointerError.mjs +3 -15
- package/es/evaluate.mjs +19 -19
- package/package.json +5 -5
- package/types/dist.d.ts +3 -6
package/es/evaluate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit, BREAK, isElement, isMemberElement, isArrayElement, NumberElement } from '@swagger-api/apidom-core';
|
|
1
|
+
import { visit, cloneDeep, BREAK, isElement, isMemberElement, isArrayElement, NumberElement } from '@swagger-api/apidom-core';
|
|
2
2
|
import { compile as compileJsonPointer, evaluate as evaluateJsonPointer } from '@swagger-api/apidom-json-pointer';
|
|
3
3
|
import { last } from 'ramda';
|
|
4
4
|
import EvaluationRelativeJsonPointerError from "./errors/EvaluationRelativeJsonPointerError.mjs";
|
|
@@ -19,9 +19,9 @@ const evaluate = (relativePointer, currentElement, rootElement) => {
|
|
|
19
19
|
if (ancestorLineage.length === 0) {
|
|
20
20
|
throw new EvaluationRelativeJsonPointerError('Relative JSON Pointer evaluation failed. Current element not found inside the root element', {
|
|
21
21
|
relativePointer,
|
|
22
|
-
currentElement,
|
|
23
|
-
rootElement,
|
|
24
|
-
cursorElement: cursor
|
|
22
|
+
currentElement: cloneDeep(currentElement),
|
|
23
|
+
rootElement: cloneDeep(rootElement),
|
|
24
|
+
cursorElement: cloneDeep.safe(cursor)
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
if (last(ancestorLineage) === rootElement) {
|
|
@@ -38,9 +38,9 @@ const evaluate = (relativePointer, currentElement, rootElement) => {
|
|
|
38
38
|
} catch (error) {
|
|
39
39
|
throw new EvaluationRelativeJsonPointerError('Relative JSON Pointer evaluation failed while parsing the pointer.', {
|
|
40
40
|
relativePointer,
|
|
41
|
-
currentElement,
|
|
42
|
-
rootElement,
|
|
43
|
-
cursorElement: cursor,
|
|
41
|
+
currentElement: cloneDeep(currentElement),
|
|
42
|
+
rootElement: cloneDeep(currentElement),
|
|
43
|
+
cursorElement: cloneDeep.safe(cursor),
|
|
44
44
|
cause: error
|
|
45
45
|
});
|
|
46
46
|
}
|
|
@@ -59,9 +59,9 @@ const evaluate = (relativePointer, currentElement, rootElement) => {
|
|
|
59
59
|
if (typeof cursor === 'undefined') {
|
|
60
60
|
throw new EvaluationRelativeJsonPointerError(`Relative JSON Pointer evaluation failed on non-negative-integer prefix of "${relativeJsonPointer.nonNegativeIntegerPrefix}"`, {
|
|
61
61
|
relativePointer,
|
|
62
|
-
currentElement,
|
|
63
|
-
rootElement,
|
|
64
|
-
cursorElement: cursor
|
|
62
|
+
currentElement: cloneDeep(currentElement),
|
|
63
|
+
rootElement: cloneDeep(rootElement),
|
|
64
|
+
cursorElement: cloneDeep.safe(cursor)
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
ancestorLineage = ancestorLineageCopy;
|
|
@@ -73,9 +73,9 @@ const evaluate = (relativePointer, currentElement, rootElement) => {
|
|
|
73
73
|
if (typeof containedArray === 'undefined' || !isArrayElement(containedArray)) {
|
|
74
74
|
throw new EvaluationRelativeJsonPointerError(`Relative JSON Pointer evaluation failed failed on index-manipulation "${relativeJsonPointer.indexManipulation}"`, {
|
|
75
75
|
relativePointer,
|
|
76
|
-
currentElement,
|
|
77
|
-
rootElement,
|
|
78
|
-
cursorElement: cursor
|
|
76
|
+
currentElement: cloneDeep(currentElement),
|
|
77
|
+
rootElement: cloneDeep(rootElement),
|
|
78
|
+
cursorElement: cloneDeep.safe(cursor)
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
const currentCursorIndex = containedArray.content.indexOf(cursor);
|
|
@@ -84,9 +84,9 @@ const evaluate = (relativePointer, currentElement, rootElement) => {
|
|
|
84
84
|
if (typeof cursor === 'undefined') {
|
|
85
85
|
throw new EvaluationRelativeJsonPointerError(`Relative JSON Pointer evaluation failed on index-manipulation "${relativeJsonPointer.indexManipulation}"`, {
|
|
86
86
|
relativePointer,
|
|
87
|
-
currentElement,
|
|
88
|
-
rootElement,
|
|
89
|
-
cursorElement: cursor
|
|
87
|
+
currentElement: cloneDeep(currentElement),
|
|
88
|
+
rootElement: cloneDeep(rootElement),
|
|
89
|
+
cursorElement: cloneDeep.safe(cursor)
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -99,9 +99,9 @@ const evaluate = (relativePointer, currentElement, rootElement) => {
|
|
|
99
99
|
if (cursor === rootElement) {
|
|
100
100
|
throw new EvaluationRelativeJsonPointerError('Relative JSON Pointer evaluation failed. Current element cannot be the root element to apply "#"', {
|
|
101
101
|
relativePointer,
|
|
102
|
-
currentElement,
|
|
103
|
-
rootElement,
|
|
104
|
-
cursorElement: cursor
|
|
102
|
+
currentElement: cloneDeep(currentElement),
|
|
103
|
+
rootElement: cloneDeep(rootElement),
|
|
104
|
+
cursorElement: cloneDeep.safe(cursor)
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
const parentElement = last(ancestorLineage);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swagger-api/apidom-json-pointer-relative",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"description": "Evaluate Relative JSON Pointer expressions against ApiDOM.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/runtime-corejs3": "^7.20.7",
|
|
41
|
-
"@swagger-api/apidom-core": "^0.
|
|
42
|
-
"@swagger-api/apidom-error": "^0.
|
|
43
|
-
"@swagger-api/apidom-json-pointer": "^0.
|
|
41
|
+
"@swagger-api/apidom-core": "^0.80.0",
|
|
42
|
+
"@swagger-api/apidom-error": "^0.80.0",
|
|
43
|
+
"@swagger-api/apidom-json-pointer": "^0.80.0",
|
|
44
44
|
"@types/ramda": "~0.29.6",
|
|
45
45
|
"ramda": "~0.29.0",
|
|
46
46
|
"ramda-adjunct": "^4.0.0"
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"README.md",
|
|
56
56
|
"CHANGELOG.md"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "c959dedb5900d9d6ec2ba64aebc30a999d61b696"
|
|
59
59
|
}
|
package/types/dist.d.ts
CHANGED
|
@@ -20,12 +20,9 @@ interface EvaluationRelativeJsonPointerErrorOptions<T extends Element, U extends
|
|
|
20
20
|
}
|
|
21
21
|
declare class EvaluationRelativeJsonPointerError<T extends Element, U extends Element, V extends Element> extends RelativeJsonPointerError {
|
|
22
22
|
readonly relativePointer: string;
|
|
23
|
-
readonly currentElement:
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly rootElementSourceMap?: [[number, number, number], [number, number, number]];
|
|
27
|
-
readonly cursorElement?: string;
|
|
28
|
-
readonly cursorElementSourceMap?: [[number, number, number], [number, number, number]];
|
|
23
|
+
readonly currentElement: T;
|
|
24
|
+
readonly rootElement: U;
|
|
25
|
+
readonly cursorElement?: V;
|
|
29
26
|
constructor(message?: string, structuredOptions?: EvaluationRelativeJsonPointerErrorOptions<T, U, V>);
|
|
30
27
|
}
|
|
31
28
|
|