@speclynx/apidom-json-pointer-relative 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 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-relative",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Evaluate Relative JSON Pointer expressions against ApiDOM.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -54,15 +54,16 @@
54
54
  "license": "Apache-2.0",
55
55
  "dependencies": {
56
56
  "@babel/runtime-corejs3": "^7.28.4",
57
- "@speclynx/apidom-datamodel": "4.0.3",
58
- "@speclynx/apidom-error": "4.0.3",
59
- "@speclynx/apidom-json-pointer": "4.0.3",
60
- "@speclynx/apidom-traverse": "4.0.3",
57
+ "@speclynx/apidom-datamodel": "4.0.4",
58
+ "@speclynx/apidom-error": "4.0.4",
59
+ "@speclynx/apidom-json-pointer": "4.0.4",
60
+ "@speclynx/apidom-traverse": "4.0.4",
61
61
  "ramda": "~0.32.0",
62
62
  "ramda-adjunct": "^6.0.0"
63
63
  },
64
64
  "files": [
65
- "src/",
65
+ "src/**/*.mjs",
66
+ "src/**/*.cjs",
66
67
  "dist/",
67
68
  "types/apidom-json-pointer-relative.d.ts",
68
69
  "LICENSES",
@@ -70,5 +71,5 @@
70
71
  "README.md",
71
72
  "CHANGELOG.md"
72
73
  ],
73
- "gitHead": "6ccfa09c02232516215e7de3ead276641957e626"
74
+ "gitHead": "a06f6ef3d37ad5bf860cbbf4b442bfbe3a522cc2"
74
75
  }
package/src/compile.ts DELETED
@@ -1,41 +0,0 @@
1
- import { compile as compileJsonPointer } from '@speclynx/apidom-json-pointer';
2
-
3
- import { RelativeJsonPointer } from './types.ts';
4
- import CompilationRelativeJsonPointerError from './errors/CompilationRelativeJsonPointerError.ts';
5
-
6
- /**
7
- * @public
8
- */
9
- const compile = (relativeJsonPointer: RelativeJsonPointer): string => {
10
- try {
11
- let relativePointer = '';
12
-
13
- // non-negative-integer
14
- relativePointer += String(relativeJsonPointer.nonNegativeIntegerPrefix);
15
-
16
- // index-manipulation
17
- if (typeof relativeJsonPointer.indexManipulation === 'number') {
18
- relativePointer += String(relativeJsonPointer.indexManipulation);
19
- }
20
-
21
- if (Array.isArray(relativeJsonPointer.jsonPointerTokens)) {
22
- // <json-pointer>
23
- relativePointer += compileJsonPointer(relativeJsonPointer.jsonPointerTokens);
24
- } else if (relativeJsonPointer.hashCharacter) {
25
- // "#"
26
- relativePointer += '#';
27
- }
28
-
29
- return relativePointer;
30
- } catch (error: unknown) {
31
- throw new CompilationRelativeJsonPointerError(
32
- 'Relative JSON Pointer compilation encountered an error.',
33
- {
34
- relativePointer: relativeJsonPointer,
35
- cause: error,
36
- },
37
- );
38
- }
39
- };
40
-
41
- export default compile;
@@ -1,39 +0,0 @@
1
- import { ApiDOMErrorOptions } from '@speclynx/apidom-error';
2
-
3
- import { RelativeJsonPointer } from '../types.ts';
4
- import RelativeJsonPointerError from './RelativeJsonPointerError.ts';
5
-
6
- /**
7
- * @public
8
- */
9
- export interface CompilationRelativeJsonPointerErrorOptions extends ApiDOMErrorOptions {
10
- readonly relativePointer: RelativeJsonPointer;
11
- }
12
-
13
- /**
14
- * @public
15
- */
16
- class CompilationRelativeJsonPointerError extends RelativeJsonPointerError {
17
- public readonly nonNegativeIntegerPrefix!: number;
18
-
19
- public readonly indexManipulation?: number;
20
-
21
- public readonly jsonPointerTokens?: string[];
22
-
23
- public readonly hashCharacter?: boolean;
24
-
25
- constructor(message?: string, structuredOptions?: CompilationRelativeJsonPointerErrorOptions) {
26
- super(message, structuredOptions);
27
-
28
- if (typeof structuredOptions !== 'undefined') {
29
- this.nonNegativeIntegerPrefix = structuredOptions.relativePointer.nonNegativeIntegerPrefix;
30
- this.indexManipulation = structuredOptions.relativePointer.indexManipulation;
31
- this.hashCharacter = structuredOptions.relativePointer.hashCharacter;
32
- if (Array.isArray(structuredOptions.relativePointer.jsonPointerTokens)) {
33
- this.jsonPointerTokens = [...structuredOptions.relativePointer.jsonPointerTokens];
34
- }
35
- }
36
- }
37
- }
38
-
39
- export default CompilationRelativeJsonPointerError;
@@ -1,51 +0,0 @@
1
- import { Element } from '@speclynx/apidom-datamodel';
2
- import { ApiDOMErrorOptions } from '@speclynx/apidom-error';
3
-
4
- import RelativeJsonPointerError from './RelativeJsonPointerError.ts';
5
-
6
- /**
7
- * @public
8
- */
9
- export interface EvaluationRelativeJsonPointerErrorOptions<
10
- T extends Element,
11
- U extends Element,
12
- V extends Element,
13
- > extends ApiDOMErrorOptions {
14
- readonly relativePointer: string;
15
- readonly currentElement: T;
16
- readonly rootElement: U;
17
- readonly cursorElement?: V;
18
- }
19
-
20
- /**
21
- * @public
22
- */
23
- class EvaluationRelativeJsonPointerError<
24
- T extends Element,
25
- U extends Element,
26
- V extends Element,
27
- > extends RelativeJsonPointerError {
28
- public readonly relativePointer!: string;
29
-
30
- public readonly currentElement!: T;
31
-
32
- public readonly rootElement!: U;
33
-
34
- public readonly cursorElement?: V;
35
-
36
- constructor(
37
- message?: string,
38
- structuredOptions?: EvaluationRelativeJsonPointerErrorOptions<T, U, V>,
39
- ) {
40
- super(message, structuredOptions);
41
-
42
- if (typeof structuredOptions !== 'undefined') {
43
- this.relativePointer = structuredOptions.relativePointer;
44
- this.currentElement = structuredOptions.currentElement;
45
- this.rootElement = structuredOptions.rootElement;
46
- this.cursorElement = structuredOptions.cursorElement;
47
- }
48
- }
49
- }
50
-
51
- export default EvaluationRelativeJsonPointerError;
@@ -1,25 +0,0 @@
1
- import { ApiDOMErrorOptions } from '@speclynx/apidom-error';
2
-
3
- import RelativeJsonPointerError from './RelativeJsonPointerError.ts';
4
-
5
- /**
6
- * @public
7
- */
8
- export interface InvalidRelativeJsonPointerErrorOptions extends ApiDOMErrorOptions {
9
- readonly relativePointer: string;
10
- }
11
-
12
- /**
13
- * @public
14
- */
15
- export default class InvalidRelativeJsonPointerError extends RelativeJsonPointerError {
16
- public readonly relativePointer!: string;
17
-
18
- constructor(message?: string, structuredOptions?: InvalidRelativeJsonPointerErrorOptions) {
19
- super(message, structuredOptions);
20
-
21
- if (typeof structuredOptions !== 'undefined') {
22
- this.relativePointer = structuredOptions.relativePointer;
23
- }
24
- }
25
- }
@@ -1,8 +0,0 @@
1
- import { ApiDOMStructuredError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class RelativeJsonPointerError extends ApiDOMStructuredError {}
7
-
8
- export default RelativeJsonPointerError;
package/src/evaluate.ts DELETED
@@ -1,178 +0,0 @@
1
- import {
2
- Element,
3
- isElement,
4
- isMemberElement,
5
- isArrayElement,
6
- MemberElement,
7
- ArrayElement,
8
- NumberElement,
9
- cloneDeep,
10
- } from '@speclynx/apidom-datamodel';
11
- import { traverse, Path } from '@speclynx/apidom-traverse';
12
- import {
13
- compile as compileJsonPointer,
14
- evaluate as evaluateJsonPointer,
15
- } from '@speclynx/apidom-json-pointer';
16
- import { last } from 'ramda';
17
-
18
- import EvaluationRelativeJsonPointerError from './errors/EvaluationRelativeJsonPointerError.ts';
19
- import parse from './parse.ts';
20
- import { RelativeJsonPointer } from './types.ts';
21
-
22
- /**
23
- * Evaluates Relative JSON Pointer against ApiDOM fragment.
24
- * @public
25
- */
26
- const evaluate = <T extends Element, U extends Element>(
27
- relativePointer: string,
28
- currentElement: T,
29
- rootElement: U,
30
- ): Element | undefined => {
31
- let ancestorLineage: Element[] = [];
32
- let cursor: Element | undefined = currentElement;
33
-
34
- traverse(rootElement, {
35
- enter(path: Path<Element>) {
36
- if (path.node === currentElement) {
37
- ancestorLineage = path.getAncestorNodes().reverse().filter(isElement);
38
- path.stop();
39
- }
40
- },
41
- });
42
-
43
- if (ancestorLineage.length === 0) {
44
- throw new EvaluationRelativeJsonPointerError(
45
- 'Relative JSON Pointer evaluation failed. Current element not found inside the root element',
46
- {
47
- relativePointer,
48
- currentElement: cloneDeep(currentElement),
49
- rootElement: cloneDeep(rootElement),
50
- cursorElement: cloneDeep.safe(cursor),
51
- },
52
- );
53
- }
54
-
55
- if (last(ancestorLineage) === rootElement) {
56
- throw new EvaluationRelativeJsonPointerError(
57
- 'Relative JSON Pointer evaluation failed. Current element cannot be the root element',
58
- {
59
- relativePointer,
60
- currentElement,
61
- rootElement,
62
- cursorElement: cursor,
63
- },
64
- );
65
- }
66
-
67
- let relativeJsonPointer: RelativeJsonPointer;
68
- try {
69
- relativeJsonPointer = parse(relativePointer);
70
- } catch (error: unknown) {
71
- throw new EvaluationRelativeJsonPointerError(
72
- 'Relative JSON Pointer evaluation failed while parsing the pointer.',
73
- {
74
- relativePointer,
75
- currentElement: cloneDeep(currentElement),
76
- rootElement: cloneDeep(currentElement),
77
- cursorElement: cloneDeep.safe(cursor),
78
- cause: error,
79
- },
80
- );
81
- }
82
-
83
- // non-negative-integer
84
- if (relativeJsonPointer.nonNegativeIntegerPrefix > 0) {
85
- const ancestorLineageCopy = [...ancestorLineage];
86
-
87
- for (
88
- let { nonNegativeIntegerPrefix } = relativeJsonPointer;
89
- nonNegativeIntegerPrefix > 0;
90
- nonNegativeIntegerPrefix -= 1
91
- ) {
92
- cursor = ancestorLineageCopy.pop();
93
- if (isMemberElement(cursor)) {
94
- cursor = ancestorLineageCopy.pop();
95
- }
96
- }
97
-
98
- if (typeof cursor === 'undefined') {
99
- throw new EvaluationRelativeJsonPointerError(
100
- `Relative JSON Pointer evaluation failed on non-negative-integer prefix of "${relativeJsonPointer.nonNegativeIntegerPrefix}"`,
101
- {
102
- relativePointer,
103
- currentElement: cloneDeep(currentElement),
104
- rootElement: cloneDeep(rootElement),
105
- cursorElement: cloneDeep.safe(cursor),
106
- },
107
- );
108
- }
109
-
110
- ancestorLineage = ancestorLineageCopy;
111
- }
112
-
113
- // index-manipulation
114
- if (typeof relativeJsonPointer.indexManipulation === 'number') {
115
- const containedArray = last(ancestorLineage);
116
-
117
- if (typeof containedArray === 'undefined' || !isArrayElement(containedArray)) {
118
- throw new EvaluationRelativeJsonPointerError(
119
- `Relative JSON Pointer evaluation failed failed on index-manipulation "${relativeJsonPointer.indexManipulation}"`,
120
- {
121
- relativePointer,
122
- currentElement: cloneDeep(currentElement),
123
- rootElement: cloneDeep(rootElement),
124
- cursorElement: cloneDeep.safe(cursor),
125
- },
126
- );
127
- }
128
-
129
- const arrayContent = containedArray.content as Element[];
130
- const currentCursorIndex = arrayContent.indexOf(cursor!);
131
- const newCursorIndex = currentCursorIndex + relativeJsonPointer.indexManipulation;
132
- cursor = arrayContent[newCursorIndex] as Element | undefined;
133
-
134
- if (typeof cursor === 'undefined') {
135
- throw new EvaluationRelativeJsonPointerError(
136
- `Relative JSON Pointer evaluation failed on index-manipulation "${relativeJsonPointer.indexManipulation}"`,
137
- {
138
- relativePointer,
139
- currentElement: cloneDeep(currentElement),
140
- rootElement: cloneDeep(rootElement),
141
- cursorElement: cloneDeep.safe(cursor),
142
- },
143
- );
144
- }
145
- }
146
-
147
- if (Array.isArray(relativeJsonPointer.jsonPointerTokens)) {
148
- // <json-pointer>
149
- const jsonPointer = compileJsonPointer(relativeJsonPointer.jsonPointerTokens);
150
- cursor = evaluateJsonPointer(cursor, jsonPointer);
151
- } else if (relativeJsonPointer.hashCharacter) {
152
- // "#"
153
- if (cursor === rootElement) {
154
- throw new EvaluationRelativeJsonPointerError(
155
- 'Relative JSON Pointer evaluation failed. Current element cannot be the root element to apply "#"',
156
- {
157
- relativePointer,
158
- currentElement: cloneDeep(currentElement),
159
- rootElement: cloneDeep(rootElement),
160
- cursorElement: cloneDeep.safe(cursor),
161
- },
162
- );
163
- }
164
-
165
- const parentElement = last(ancestorLineage) as ArrayElement | MemberElement | undefined;
166
- if (typeof parentElement !== 'undefined') {
167
- if (isMemberElement(parentElement)) {
168
- cursor = (parentElement as MemberElement).key as Element;
169
- } else if (isArrayElement(parentElement)) {
170
- cursor = new NumberElement((parentElement.content as Element[]).indexOf(cursor!));
171
- }
172
- }
173
- }
174
-
175
- return cursor;
176
- };
177
-
178
- export default evaluate;
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
1
- export { default as RelativeJsonPointerError } from './errors/RelativeJsonPointerError.ts';
2
- export { default as InvalidRelativeJsonPointerError } from './errors/InvalidRelativeJsonPointerError.ts';
3
- export type { InvalidRelativeJsonPointerErrorOptions } from './errors/InvalidRelativeJsonPointerError.ts';
4
- export { default as EvaluationRelativeJsonPointerError } from './errors/EvaluationRelativeJsonPointerError.ts';
5
- export type { EvaluationRelativeJsonPointerErrorOptions } from './errors/EvaluationRelativeJsonPointerError.ts';
6
- export { default as CompilationRelativeJsonPointerError } from './errors/CompilationRelativeJsonPointerError.ts';
7
- export type { CompilationRelativeJsonPointerErrorOptions } from './errors/CompilationRelativeJsonPointerError.ts';
8
- export { default as parse, isRelativeJsonPointer } from './parse.ts';
9
- export { default as compile } from './compile.ts';
10
- export { default as evaluate } from './evaluate.ts';
11
- export type { RelativeJsonPointer } from './types.ts';
package/src/parse.ts DELETED
@@ -1,66 +0,0 @@
1
- import { parse as parseJsonPointer } from '@speclynx/apidom-json-pointer';
2
-
3
- import InvalidRelativeJsonPointerError from './errors/InvalidRelativeJsonPointerError.ts';
4
- import { RelativeJsonPointer } from './types.ts';
5
-
6
- const nonNegativeIntegerPrefixRegExp = '(?<nonNegativeIntegerPrefix>[1-9]\\d*|0)';
7
- const indexManipulationRegExp = '(?<indexManipulation>[+-][1-9]\\d*|0)';
8
- const hashCharacterRegExp = '(?<hashCharacter>#)';
9
- const jsonPointerRegExp = '(?<jsonPointer>\\/.*)';
10
- const relativeJsonPointerRegExp = new RegExp(
11
- `^${nonNegativeIntegerPrefixRegExp}${indexManipulationRegExp}?(${hashCharacterRegExp}|${jsonPointerRegExp})?$`,
12
- );
13
-
14
- /**
15
- * @public
16
- */
17
- export const isRelativeJsonPointer = (value: any) => {
18
- return typeof value === 'string' && relativeJsonPointerRegExp.test(value);
19
- };
20
-
21
- /**
22
- * @public
23
- */
24
- const parse = (relativePointer: string): RelativeJsonPointer => {
25
- const match = relativePointer.match(relativeJsonPointerRegExp);
26
- if (match === null || typeof match.groups === 'undefined') {
27
- throw new InvalidRelativeJsonPointerError(
28
- `Invalid Relative JSON Pointer "${relativePointer}".`,
29
- { relativePointer },
30
- );
31
- }
32
-
33
- try {
34
- // non-negative-integer
35
- const nonNegativeIntegerPrefix = parseInt(match.groups.nonNegativeIntegerPrefix, 10);
36
- // index-manipulation
37
- const indexManipulation =
38
- typeof match.groups.indexManipulation === 'string'
39
- ? parseInt(match.groups.indexManipulation, 10)
40
- : undefined;
41
- // <json-pointer>
42
- const jsonPointerTokens =
43
- typeof match.groups.jsonPointer === 'string'
44
- ? parseJsonPointer(match.groups.jsonPointer).tree
45
- : undefined;
46
- // "#"
47
- const hashCharacter = typeof match.groups.hashCharacter === 'string';
48
-
49
- return {
50
- nonNegativeIntegerPrefix,
51
- indexManipulation,
52
- jsonPointerTokens,
53
- hashCharacter,
54
- };
55
- } catch (error: unknown) {
56
- throw new InvalidRelativeJsonPointerError(
57
- `Relative JSON Pointer parsing of "${relativePointer}" encountered an error.`,
58
- {
59
- relativePointer,
60
- cause: error,
61
- },
62
- );
63
- }
64
- };
65
-
66
- export default parse;
package/src/types.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * @public
3
- */
4
- export type RelativeJsonPointer = {
5
- readonly nonNegativeIntegerPrefix: number;
6
- readonly indexManipulation?: number;
7
- readonly jsonPointerTokens?: string[];
8
- readonly hashCharacter?: boolean;
9
- };