@speclynx/apidom-json-path 4.0.3 → 4.0.5

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 CHANGED
@@ -3,6 +3,16 @@
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.5](https://github.com/speclynx/apidom/compare/v4.0.4...v4.0.5) (2026-03-13)
7
+
8
+ **Note:** Version bump only for package @speclynx/apidom-json-path
9
+
10
+ ## [4.0.4](https://github.com/speclynx/apidom/compare/v4.0.3...v4.0.4) (2026-03-12)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **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)
15
+
6
16
  ## [4.0.3](https://github.com/speclynx/apidom/compare/v4.0.2...v4.0.3) (2026-03-11)
7
17
 
8
18
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-json-path",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "Evaluate JSONPath 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.3",
59
- "@speclynx/apidom-error": "4.0.3",
58
+ "@speclynx/apidom-datamodel": "4.0.5",
59
+ "@speclynx/apidom-error": "4.0.5",
60
60
  "@swaggerexpert/jsonpath": "^4.0.3"
61
61
  },
62
62
  "files": [
63
- "src/",
63
+ "src/**/*.mjs",
64
+ "src/**/*.cjs",
64
65
  "dist/",
65
66
  "types/apidom-json-path.d.ts",
66
67
  "LICENSES",
@@ -68,5 +69,5 @@
68
69
  "README.md",
69
70
  "CHANGELOG.md"
70
71
  ],
71
- "gitHead": "6ccfa09c02232516215e7de3ead276641957e626"
72
+ "gitHead": "5a85d2a832eeefb07d03760faa391b457447e966"
72
73
  }
package/src/index.ts DELETED
@@ -1,94 +0,0 @@
1
- import { evaluate as baseEvaluate } from '@swaggerexpert/jsonpath';
2
-
3
- export {
4
- /**
5
- * Parsing
6
- */
7
- parse,
8
- CSTTranslator,
9
- CSTOptimizedTranslator,
10
- ASTTranslator,
11
- XMLTranslator,
12
- /**
13
- * Testing
14
- */
15
- test,
16
- /**
17
- * Normalized Path
18
- */
19
- NormalizedPath,
20
- /**
21
- * Evaluation
22
- */
23
- functions,
24
- EvaluationRealm,
25
- JSONEvaluationRealm,
26
- /**
27
- * Grammar
28
- */
29
- Grammar,
30
- /**
31
- * Errors
32
- */
33
- JSONPathError,
34
- JSONPathParseError,
35
- JSONNormalizedPathError,
36
- JSONPathEvaluateError,
37
- } from '@swaggerexpert/jsonpath';
38
-
39
- import ApiDOMEvaluationRealm from './realm.ts';
40
-
41
- export { ApiDOMEvaluationRealm };
42
-
43
- const realm = new ApiDOMEvaluationRealm();
44
-
45
- /**
46
- * Options for ApiDOM JSONPath evaluation.
47
- * @public
48
- */
49
- export interface ApiDOMEvaluateOptions {
50
- /**
51
- * Optional callback called for each match.
52
- * @param value - The matched value
53
- * @param normalizedPath - The normalized path to the match
54
- */
55
- callback?: (value: unknown, normalizedPath: string) => void;
56
- /**
57
- * Optional custom function registry.
58
- * Can extend or override built-in functions (length, count, match, search, value).
59
- */
60
- functions?: Record<string, (...args: unknown[]) => unknown>;
61
- }
62
-
63
- /**
64
- * Evaluate a JSONPath expression against an ApiDOM element.
65
- *
66
- * @param value - ApiDOM element to query
67
- * @param expression - JSONPath expression
68
- * @param options - Evaluation options
69
- * @returns Array of matched values
70
- *
71
- * @example
72
- * ```typescript
73
- * import { ObjectElement } from '@speclynx/apidom-datamodel';
74
- * import { evaluate } from '@speclynx/apidom-json-path';
75
- *
76
- * const element = new ObjectElement({ a: { b: [1, 2, 3] } });
77
- * const results = evaluate(element, '$.a.b[*]');
78
- * // => [NumberElement(1), NumberElement(2), NumberElement(3)]
79
- * ```
80
- *
81
- * @public
82
- */
83
- export const evaluate = <T = unknown>(
84
- value: unknown,
85
- expression: string,
86
- options: ApiDOMEvaluateOptions = {},
87
- ): T[] => {
88
- return baseEvaluate(value, expression, { ...options, realm });
89
- };
90
-
91
- /**
92
- * Re-export all types
93
- */
94
- export type * from '@swaggerexpert/jsonpath';
package/src/realm.ts DELETED
@@ -1,172 +0,0 @@
1
- import {
2
- ObjectElement,
3
- ArrayElement,
4
- isObjectElement,
5
- isArrayElement,
6
- isStringElement,
7
- isNumberElement,
8
- isBooleanElement,
9
- isNullElement,
10
- refract,
11
- } from '@speclynx/apidom-datamodel';
12
- import { EvaluationRealm } from '@swaggerexpert/jsonpath';
13
-
14
- /**
15
- * ApiDOM Evaluation Realm implementation for JSONPath.
16
- * @public
17
- */
18
- class ApiDOMEvaluationRealm extends EvaluationRealm {
19
- override name = 'apidom';
20
-
21
- override isObject(value: unknown): value is ObjectElement {
22
- return isObjectElement(value);
23
- }
24
-
25
- override isArray(value: unknown): value is ArrayElement {
26
- return isArrayElement(value);
27
- }
28
-
29
- override isString(value: unknown): boolean {
30
- return isStringElement(value);
31
- }
32
-
33
- override isNumber(value: unknown): boolean {
34
- return isNumberElement(value);
35
- }
36
-
37
- override isBoolean(value: unknown): boolean {
38
- return isBooleanElement(value);
39
- }
40
-
41
- override isNull(value: unknown): boolean {
42
- return isNullElement(value);
43
- }
44
-
45
- override getString(value: unknown): string | undefined {
46
- if (isStringElement(value)) return value.toValue() as string;
47
- if (typeof value === 'string') return value;
48
- return undefined;
49
- }
50
-
51
- override getProperty(value: unknown, key: string): unknown {
52
- if (!isObjectElement(value)) return undefined;
53
- if (!value.hasKey(key)) return undefined;
54
- return value.get(key);
55
- }
56
-
57
- override hasProperty(value: unknown, key: string): boolean {
58
- if (!isObjectElement(value)) return false;
59
- return value.hasKey(key);
60
- }
61
-
62
- override getElement(value: unknown, index: number): unknown {
63
- if (!isArrayElement(value)) return undefined;
64
- if (index < 0 || index >= value.length) return undefined;
65
- return value.get(index);
66
- }
67
-
68
- override getKeys(value: unknown): string[] {
69
- if (!isObjectElement(value)) return [];
70
- return value.keys() as string[];
71
- }
72
-
73
- override getLength(value: unknown): number {
74
- if (isStringElement(value)) return [...(value.toValue() as string)].length;
75
- if (isArrayElement(value)) return value.length;
76
- if (isObjectElement(value)) return value.length;
77
- if (typeof value === 'string') return [...value].length;
78
- if (Array.isArray(value)) return value.length;
79
- return 0;
80
- }
81
-
82
- override *entries(value: unknown): Iterable<[string | number, unknown]> {
83
- if (isArrayElement(value)) {
84
- let index = 0;
85
- for (const item of value) {
86
- yield [index, item];
87
- index += 1;
88
- }
89
- } else if (isObjectElement(value)) {
90
- for (const member of value) {
91
- yield [member.key!.toValue() as string, member.value];
92
- }
93
- }
94
- }
95
-
96
- override compare(left: unknown, operator: string, right: unknown): boolean {
97
- // Handle Nothing (undefined) comparisons
98
- if (left === undefined || right === undefined) {
99
- if (operator === '==') return left === undefined && right === undefined;
100
- if (operator === '!=') return !(left === undefined && right === undefined);
101
- return false;
102
- }
103
-
104
- // Check if both are numbers (elements or primitives)
105
- const leftIsNumber = isNumberElement(left) || typeof left === 'number';
106
- const rightIsNumber = isNumberElement(right) || typeof right === 'number';
107
-
108
- // For numeric values, use primitive comparison with -0 normalization (RFC 9535)
109
- if (leftIsNumber && rightIsNumber) {
110
- const leftPrimitive = (isNumberElement(left) ? left.toValue() : left) as number;
111
- const rightPrimitive = (isNumberElement(right) ? right.toValue() : right) as number;
112
- const leftVal = Object.is(leftPrimitive, -0) ? 0 : leftPrimitive;
113
- const rightVal = Object.is(rightPrimitive, -0) ? 0 : rightPrimitive;
114
-
115
- switch (operator) {
116
- case '==':
117
- return leftVal === rightVal;
118
- case '!=':
119
- return leftVal !== rightVal;
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
- default:
129
- return false;
130
- }
131
- }
132
-
133
- // Check if both are strings (elements or primitives)
134
- const leftIsString = isStringElement(left) || typeof left === 'string';
135
- const rightIsString = isStringElement(right) || typeof right === 'string';
136
-
137
- // For string values, use primitive comparison
138
- if (leftIsString && rightIsString) {
139
- const leftVal = (isStringElement(left) ? left.toValue() : left) as string;
140
- const rightVal = (isStringElement(right) ? right.toValue() : right) as string;
141
-
142
- switch (operator) {
143
- case '==':
144
- return leftVal === rightVal;
145
- case '!=':
146
- return leftVal !== rightVal;
147
- case '<':
148
- return leftVal < rightVal;
149
- case '>':
150
- return leftVal > rightVal;
151
- case '<=':
152
- return leftVal <= rightVal;
153
- case '>=':
154
- return leftVal >= rightVal;
155
- default:
156
- return false;
157
- }
158
- }
159
-
160
- // For other types (booleans, nulls), only equality operators are defined (RFC 9535)
161
- if (operator === '==') {
162
- return refract(left).equals(right);
163
- }
164
- if (operator === '!=') {
165
- return !refract(left).equals(right);
166
- }
167
- // Comparison operators (<, >, <=, >=) are not defined for non-numeric, non-string types
168
- return false;
169
- }
170
- }
171
-
172
- export default ApiDOMEvaluationRealm;