@speclynx/apidom-json-pointer 4.0.3 → 4.0.4
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 +6 -0
- package/package.json +6 -5
- package/src/index.ts +0 -75
- package/src/realm.ts +0 -80
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.0.4](https://github.com/speclynx/apidom/compare/v4.0.3...v4.0.4) (2026-03-12)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **release:** override minimatch 10.2.3 to fix glob pattern regression in lerna publish ([#157](https://github.com/speclynx/apidom/issues/157)) ([c2d65a0](https://github.com/speclynx/apidom/commit/c2d65a06a2187e8563a9dc9db74ba27255450e0b)), closes [lerna/lerna#4305](https://github.com/lerna/lerna/issues/4305) [isaacs/minimatch#284](https://github.com/isaacs/minimatch/issues/284)
|
|
11
|
+
|
|
6
12
|
## [4.0.3](https://github.com/speclynx/apidom/compare/v4.0.2...v4.0.3) (2026-03-11)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-json-pointer",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Evaluate JSON Pointer expressions against ApiDOM.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apidom",
|
|
@@ -55,12 +55,13 @@
|
|
|
55
55
|
"license": "Apache-2.0",
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
58
|
-
"@speclynx/apidom-datamodel": "4.0.
|
|
59
|
-
"@speclynx/apidom-error": "4.0.
|
|
58
|
+
"@speclynx/apidom-datamodel": "4.0.4",
|
|
59
|
+
"@speclynx/apidom-error": "4.0.4",
|
|
60
60
|
"@swaggerexpert/json-pointer": "^3.0.1"
|
|
61
61
|
},
|
|
62
62
|
"files": [
|
|
63
|
-
"src
|
|
63
|
+
"src/**/*.mjs",
|
|
64
|
+
"src/**/*.cjs",
|
|
64
65
|
"dist/",
|
|
65
66
|
"types/apidom-json-pointer.d.ts",
|
|
66
67
|
"LICENSES",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"README.md",
|
|
69
70
|
"CHANGELOG.md"
|
|
70
71
|
],
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "a06f6ef3d37ad5bf860cbbf4b442bfbe3a522cc2"
|
|
72
73
|
}
|
package/src/index.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { evaluate as baseEvaluate, JSONPointer } from '@swaggerexpert/json-pointer';
|
|
2
|
-
import type { EvaluationOptions } from '@swaggerexpert/json-pointer';
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
/**
|
|
6
|
-
* Representation
|
|
7
|
-
*/
|
|
8
|
-
JSONString,
|
|
9
|
-
URIFragmentIdentifier,
|
|
10
|
-
/**
|
|
11
|
-
* Parsing
|
|
12
|
-
*/
|
|
13
|
-
parse,
|
|
14
|
-
CSTTranslator,
|
|
15
|
-
ASTTranslator,
|
|
16
|
-
XMLTranslator,
|
|
17
|
-
/**
|
|
18
|
-
* Testing
|
|
19
|
-
*/
|
|
20
|
-
testJSONPointer,
|
|
21
|
-
testReferenceToken,
|
|
22
|
-
testArrayLocation,
|
|
23
|
-
testArrayIndex,
|
|
24
|
-
testArrayDash,
|
|
25
|
-
/**
|
|
26
|
-
* Compiling
|
|
27
|
-
*/
|
|
28
|
-
compile,
|
|
29
|
-
/**
|
|
30
|
-
* Escaping
|
|
31
|
-
*/
|
|
32
|
-
escape,
|
|
33
|
-
unescape,
|
|
34
|
-
/**
|
|
35
|
-
* Grammar
|
|
36
|
-
*/
|
|
37
|
-
Grammar,
|
|
38
|
-
/**
|
|
39
|
-
* Errors
|
|
40
|
-
*/
|
|
41
|
-
JSONPointerError,
|
|
42
|
-
JSONPointerParseError,
|
|
43
|
-
JSONPointerCompileError,
|
|
44
|
-
JSONPointerEvaluateError,
|
|
45
|
-
JSONPointerTypeError,
|
|
46
|
-
JSONPointerKeyError,
|
|
47
|
-
JSONPointerIndexError,
|
|
48
|
-
} from '@swaggerexpert/json-pointer';
|
|
49
|
-
|
|
50
|
-
import ApiDOMEvaluationRealm from './realm.ts';
|
|
51
|
-
|
|
52
|
-
export { ApiDOMEvaluationRealm };
|
|
53
|
-
|
|
54
|
-
const realm = new ApiDOMEvaluationRealm();
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export type ApiDOMRealmEvaluationOptions = Omit<EvaluationOptions, 'realm'>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @public
|
|
63
|
-
*/
|
|
64
|
-
export const evaluate = <T = unknown>(
|
|
65
|
-
value: unknown,
|
|
66
|
-
jsonPointer: JSONPointer,
|
|
67
|
-
options: ApiDOMRealmEvaluationOptions = {},
|
|
68
|
-
): T => {
|
|
69
|
-
return baseEvaluate(value, jsonPointer, { ...options, realm });
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Re-export all types
|
|
74
|
-
*/
|
|
75
|
-
export type * from '@swaggerexpert/json-pointer';
|
package/src/realm.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ObjectElement,
|
|
3
|
-
ArrayElement,
|
|
4
|
-
isObjectElement,
|
|
5
|
-
isArrayElement,
|
|
6
|
-
} from '@speclynx/apidom-datamodel';
|
|
7
|
-
import {
|
|
8
|
-
EvaluationRealm,
|
|
9
|
-
JSONPointerIndexError,
|
|
10
|
-
JSONPointerKeyError,
|
|
11
|
-
} from '@swaggerexpert/json-pointer';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
class ApiDOMEvaluationRealm extends EvaluationRealm {
|
|
17
|
-
name = 'apidom';
|
|
18
|
-
|
|
19
|
-
isArray(node: unknown): node is ArrayElement {
|
|
20
|
-
return isArrayElement(node);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
isObject(node: unknown): node is ObjectElement {
|
|
24
|
-
return isObjectElement(node);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
sizeOf(node: unknown) {
|
|
28
|
-
if (this.isArray(node) || this.isObject(node)) {
|
|
29
|
-
return node.length;
|
|
30
|
-
}
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
has(node: unknown, referenceToken: string) {
|
|
35
|
-
if (this.isArray(node)) {
|
|
36
|
-
const index = Number(referenceToken);
|
|
37
|
-
const indexUint32 = index >>> 0;
|
|
38
|
-
|
|
39
|
-
if (index !== indexUint32) {
|
|
40
|
-
throw new JSONPointerIndexError(
|
|
41
|
-
`Invalid array index "${referenceToken}": index must be an unsinged 32-bit integer`,
|
|
42
|
-
{
|
|
43
|
-
referenceToken,
|
|
44
|
-
currentValue: node,
|
|
45
|
-
realm: this.name,
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return indexUint32 < this.sizeOf(node);
|
|
51
|
-
}
|
|
52
|
-
if (this.isObject(node)) {
|
|
53
|
-
const keys = node.keys();
|
|
54
|
-
const uniqueKeys = new Set(keys);
|
|
55
|
-
|
|
56
|
-
if (keys.length !== uniqueKeys.size) {
|
|
57
|
-
throw new JSONPointerKeyError(
|
|
58
|
-
`Object key "${referenceToken}" is not unique — JSON Pointer requires unique member names`,
|
|
59
|
-
{
|
|
60
|
-
referenceToken,
|
|
61
|
-
currentValue: node,
|
|
62
|
-
realm: this.name,
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return node.hasKey(referenceToken);
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
evaluate<T = unknown>(node: unknown, referenceToken: string): T {
|
|
73
|
-
if (this.isArray(node)) {
|
|
74
|
-
return node.get(Number(referenceToken)) as T;
|
|
75
|
-
}
|
|
76
|
-
return (node as ObjectElement).get(referenceToken) as T;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default ApiDOMEvaluationRealm;
|