@speclynx/apidom-reference 3.2.0 → 3.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-reference",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Advanced algorithms for semantic ApiDOM manipulations like dereferencing or resolution.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -254,29 +254,29 @@
254
254
  "license": "Apache-2.0",
255
255
  "dependencies": {
256
256
  "@babel/runtime-corejs3": "^7.28.4",
257
- "@speclynx/apidom-core": "3.2.0",
258
- "@speclynx/apidom-datamodel": "3.2.0",
259
- "@speclynx/apidom-error": "3.2.0",
260
- "@speclynx/apidom-json-pointer": "3.2.0",
261
- "@speclynx/apidom-ns-arazzo-1": "3.2.0",
262
- "@speclynx/apidom-ns-asyncapi-2": "3.2.0",
263
- "@speclynx/apidom-ns-json-schema-2020-12": "3.2.0",
264
- "@speclynx/apidom-ns-openapi-2": "3.2.0",
265
- "@speclynx/apidom-ns-openapi-3-0": "3.2.0",
266
- "@speclynx/apidom-ns-openapi-3-1": "3.2.0",
267
- "@speclynx/apidom-parser-adapter-arazzo-json-1": "3.2.0",
268
- "@speclynx/apidom-parser-adapter-arazzo-yaml-1": "3.2.0",
269
- "@speclynx/apidom-parser-adapter-asyncapi-json-2": "3.2.0",
270
- "@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "3.2.0",
271
- "@speclynx/apidom-parser-adapter-json": "3.2.0",
272
- "@speclynx/apidom-parser-adapter-openapi-json-2": "3.2.0",
273
- "@speclynx/apidom-parser-adapter-openapi-json-3-0": "3.2.0",
274
- "@speclynx/apidom-parser-adapter-openapi-json-3-1": "3.2.0",
275
- "@speclynx/apidom-parser-adapter-openapi-yaml-2": "3.2.0",
276
- "@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "3.2.0",
277
- "@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "3.2.0",
278
- "@speclynx/apidom-parser-adapter-yaml-1-2": "3.2.0",
279
- "@speclynx/apidom-traverse": "3.2.0",
257
+ "@speclynx/apidom-core": "3.2.1",
258
+ "@speclynx/apidom-datamodel": "3.2.1",
259
+ "@speclynx/apidom-error": "3.2.1",
260
+ "@speclynx/apidom-json-pointer": "3.2.1",
261
+ "@speclynx/apidom-ns-arazzo-1": "3.2.1",
262
+ "@speclynx/apidom-ns-asyncapi-2": "3.2.1",
263
+ "@speclynx/apidom-ns-json-schema-2020-12": "3.2.1",
264
+ "@speclynx/apidom-ns-openapi-2": "3.2.1",
265
+ "@speclynx/apidom-ns-openapi-3-0": "3.2.1",
266
+ "@speclynx/apidom-ns-openapi-3-1": "3.2.1",
267
+ "@speclynx/apidom-parser-adapter-arazzo-json-1": "3.2.1",
268
+ "@speclynx/apidom-parser-adapter-arazzo-yaml-1": "3.2.1",
269
+ "@speclynx/apidom-parser-adapter-asyncapi-json-2": "3.2.1",
270
+ "@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "3.2.1",
271
+ "@speclynx/apidom-parser-adapter-json": "3.2.1",
272
+ "@speclynx/apidom-parser-adapter-openapi-json-2": "3.2.1",
273
+ "@speclynx/apidom-parser-adapter-openapi-json-3-0": "3.2.1",
274
+ "@speclynx/apidom-parser-adapter-openapi-json-3-1": "3.2.1",
275
+ "@speclynx/apidom-parser-adapter-openapi-yaml-2": "3.2.1",
276
+ "@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "3.2.1",
277
+ "@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "3.2.1",
278
+ "@speclynx/apidom-parser-adapter-yaml-1-2": "3.2.1",
279
+ "@speclynx/apidom-traverse": "3.2.1",
280
280
  "@swaggerexpert/arazzo-runtime-expression": "^2.0.3",
281
281
  "axios": "^1.13.5",
282
282
  "picomatch": "^4.0.3",
@@ -298,5 +298,5 @@
298
298
  "README.md",
299
299
  "CHANGELOG.md"
300
300
  ],
301
- "gitHead": "eeb2f01cd34fb0a95617f02bc1b6683aefc028f2"
301
+ "gitHead": "83a1e97089ef29134e41ff7cacd351973114ea5b"
302
302
  }
@@ -106,15 +106,22 @@ class ApiDOMDereferenceVisitor {
106
106
  const isEntryDocument = url.stripHash(this.reference.refSet?.rootRef?.uri ?? '') === this.reference.uri;
107
107
  const uri = this.reference.uri;
108
108
  const type = referencingElement.element;
109
+ // find element location by identity in the document tree.
110
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
111
+ // falls back to visitorPath which may produce an incomplete path when
112
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
109
113
  let location;
110
- (0, _apidomTraverse.traverse)(this.reference.value.result, {
111
- enter(p) {
112
- if (p.node === referencingElement) {
113
- location = p.formatPath();
114
- p.stop();
114
+ const root = this.reference.value.result;
115
+ if ((0, _apidomDatamodel.isElement)(root)) {
116
+ (0, _apidomTraverse.traverse)(root, {
117
+ enter(p) {
118
+ if (p.node === referencingElement) {
119
+ location = p.formatPath();
120
+ p.stop();
121
+ }
115
122
  }
116
- }
117
- });
123
+ });
124
+ }
118
125
  location ??= visitorPath.formatPath();
119
126
  const codeFrame = (0, _apidomCore.toYAML)(referencingElement);
120
127
  const hop = {
@@ -99,15 +99,22 @@ class ApiDOMDereferenceVisitor {
99
99
  const isEntryDocument = url.stripHash(this.reference.refSet?.rootRef?.uri ?? '') === this.reference.uri;
100
100
  const uri = this.reference.uri;
101
101
  const type = referencingElement.element;
102
+ // find element location by identity in the document tree.
103
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
104
+ // falls back to visitorPath which may produce an incomplete path when
105
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
102
106
  let location;
103
- traverse(this.reference.value.result, {
104
- enter(p) {
105
- if (p.node === referencingElement) {
106
- location = p.formatPath();
107
- p.stop();
107
+ const root = this.reference.value.result;
108
+ if (isElement(root)) {
109
+ traverse(root, {
110
+ enter(p) {
111
+ if (p.node === referencingElement) {
112
+ location = p.formatPath();
113
+ p.stop();
114
+ }
108
115
  }
109
- }
110
- });
116
+ });
117
+ }
111
118
  location ??= visitorPath.formatPath();
112
119
  const codeFrame = toYAML(referencingElement);
113
120
  const hop = {
@@ -140,16 +140,22 @@ class Arazzo1DereferenceVisitor {
140
140
  const type = referencingElement.element;
141
141
  const codeFrame = (0, _apidomCore.toYAML)(referencingElement);
142
142
 
143
- // find element location: tree search for entry documents, visitor path for external
143
+ // find element location by identity in the document tree.
144
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
145
+ // falls back to visitorPath which may produce an incomplete path when
146
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
144
147
  let location;
145
- (0, _apidomTraverse.traverse)(this.reference.value.result, {
146
- enter: p => {
147
- if (p.node === referencingElement) {
148
- location = p.formatPath();
149
- p.stop();
148
+ const root = this.reference.value.result;
149
+ if ((0, _apidomDatamodel.isElement)(root)) {
150
+ (0, _apidomTraverse.traverse)(root, {
151
+ enter(p) {
152
+ if (p.node === referencingElement) {
153
+ location = p.formatPath();
154
+ p.stop();
155
+ }
150
156
  }
151
- }
152
- });
157
+ });
158
+ }
153
159
  location ??= visitorPath.formatPath();
154
160
  const hop = {
155
161
  uri,
@@ -133,16 +133,22 @@ class Arazzo1DereferenceVisitor {
133
133
  const type = referencingElement.element;
134
134
  const codeFrame = toYAML(referencingElement);
135
135
 
136
- // find element location: tree search for entry documents, visitor path for external
136
+ // find element location by identity in the document tree.
137
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
138
+ // falls back to visitorPath which may produce an incomplete path when
139
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
137
140
  let location;
138
- traverse(this.reference.value.result, {
139
- enter: p => {
140
- if (p.node === referencingElement) {
141
- location = p.formatPath();
142
- p.stop();
141
+ const root = this.reference.value.result;
142
+ if (isElement(root)) {
143
+ traverse(root, {
144
+ enter(p) {
145
+ if (p.node === referencingElement) {
146
+ location = p.formatPath();
147
+ p.stop();
148
+ }
143
149
  }
144
- }
145
- });
150
+ });
151
+ }
146
152
  location ??= visitorPath.formatPath();
147
153
  const hop = {
148
154
  uri,
@@ -136,16 +136,22 @@ class AsyncAPI2DereferenceVisitor {
136
136
  const type = referencingElement.element;
137
137
  const codeFrame = (0, _apidomCore.toYAML)(referencingElement);
138
138
 
139
- // find element location: tree search for entry documents, visitor path for external
139
+ // find element location by identity in the document tree.
140
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
141
+ // falls back to visitorPath which may produce an incomplete path when
142
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
140
143
  let location;
141
- (0, _apidomTraverse.traverse)(this.reference.value.result, {
142
- enter: p => {
143
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
144
- location = p.formatPath();
145
- p.stop();
144
+ const root = this.reference.value.result;
145
+ if ((0, _apidomDatamodel.isElement)(root)) {
146
+ (0, _apidomTraverse.traverse)(root, {
147
+ enter: p => {
148
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
149
+ location = p.formatPath();
150
+ p.stop();
151
+ }
146
152
  }
147
- }
148
- });
153
+ });
154
+ }
149
155
  location ??= visitorPath.formatPath();
150
156
  const hop = {
151
157
  uri,
@@ -129,16 +129,22 @@ class AsyncAPI2DereferenceVisitor {
129
129
  const type = referencingElement.element;
130
130
  const codeFrame = toYAML(referencingElement);
131
131
 
132
- // find element location: tree search for entry documents, visitor path for external
132
+ // find element location by identity in the document tree.
133
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
134
+ // falls back to visitorPath which may produce an incomplete path when
135
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
133
136
  let location;
134
- traverse(this.reference.value.result, {
135
- enter: p => {
136
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
137
- location = p.formatPath();
138
- p.stop();
137
+ const root = this.reference.value.result;
138
+ if (isElement(root)) {
139
+ traverse(root, {
140
+ enter: p => {
141
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
142
+ location = p.formatPath();
143
+ p.stop();
144
+ }
139
145
  }
140
- }
141
- });
146
+ });
147
+ }
142
148
  location ??= visitorPath.formatPath();
143
149
  const hop = {
144
150
  uri,
@@ -136,16 +136,22 @@ class OpenAPI2DereferenceVisitor {
136
136
  const type = referencingElement.element;
137
137
  const codeFrame = (0, _apidomCore.toYAML)(referencingElement);
138
138
 
139
- // find element location: tree search for entry documents, visitor path for external
139
+ // find element location by identity in the document tree.
140
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
141
+ // falls back to visitorPath which may produce an incomplete path when
142
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
140
143
  let location;
141
- (0, _apidomTraverse.traverse)(this.reference.value.result, {
142
- enter: p => {
143
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
144
- location = p.formatPath();
145
- p.stop();
144
+ const root = this.reference.value.result;
145
+ if ((0, _apidomDatamodel.isElement)(root)) {
146
+ (0, _apidomTraverse.traverse)(root, {
147
+ enter: p => {
148
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
149
+ location = p.formatPath();
150
+ p.stop();
151
+ }
146
152
  }
147
- }
148
- });
153
+ });
154
+ }
149
155
  location ??= visitorPath.formatPath();
150
156
  const hop = {
151
157
  uri,
@@ -129,16 +129,22 @@ class OpenAPI2DereferenceVisitor {
129
129
  const type = referencingElement.element;
130
130
  const codeFrame = toYAML(referencingElement);
131
131
 
132
- // find element location: tree search for entry documents, visitor path for external
132
+ // find element location by identity in the document tree.
133
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
134
+ // falls back to visitorPath which may produce an incomplete path when
135
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
133
136
  let location;
134
- traverse(this.reference.value.result, {
135
- enter: p => {
136
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
137
- location = p.formatPath();
138
- p.stop();
137
+ const root = this.reference.value.result;
138
+ if (isElement(root)) {
139
+ traverse(root, {
140
+ enter: p => {
141
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
142
+ location = p.formatPath();
143
+ p.stop();
144
+ }
139
145
  }
140
- }
141
- });
146
+ });
147
+ }
142
148
  location ??= visitorPath.formatPath();
143
149
  const hop = {
144
150
  uri,
@@ -137,16 +137,22 @@ class OpenAPI3_0DereferenceVisitor {
137
137
  const type = referencingElement.element;
138
138
  const codeFrame = (0, _apidomCore.toYAML)(referencingElement);
139
139
 
140
- // find element location: tree search for entry documents, visitor path for external
140
+ // find element location by identity in the document tree.
141
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
142
+ // falls back to visitorPath which may produce an incomplete path when
143
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
141
144
  let location;
142
- (0, _apidomTraverse.traverse)(this.reference.value.result, {
143
- enter: p => {
144
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
145
- location = p.formatPath();
146
- p.stop();
145
+ const root = this.reference.value.result;
146
+ if ((0, _apidomDatamodel.isElement)(root)) {
147
+ (0, _apidomTraverse.traverse)(root, {
148
+ enter: p => {
149
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
150
+ location = p.formatPath();
151
+ p.stop();
152
+ }
147
153
  }
148
- }
149
- });
154
+ });
155
+ }
150
156
  location ??= visitorPath.formatPath();
151
157
  const hop = {
152
158
  uri,
@@ -130,16 +130,22 @@ class OpenAPI3_0DereferenceVisitor {
130
130
  const type = referencingElement.element;
131
131
  const codeFrame = toYAML(referencingElement);
132
132
 
133
- // find element location: tree search for entry documents, visitor path for external
133
+ // find element location by identity in the document tree.
134
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
135
+ // falls back to visitorPath which may produce an incomplete path when
136
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
134
137
  let location;
135
- traverse(this.reference.value.result, {
136
- enter: p => {
137
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
138
- location = p.formatPath();
139
- p.stop();
138
+ const root = this.reference.value.result;
139
+ if (isElement(root)) {
140
+ traverse(root, {
141
+ enter: p => {
142
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
143
+ location = p.formatPath();
144
+ p.stop();
145
+ }
140
146
  }
141
- }
142
- });
147
+ });
148
+ }
143
149
  location ??= visitorPath.formatPath();
144
150
  const hop = {
145
151
  uri,
@@ -142,16 +142,22 @@ class OpenAPI3_1DereferenceVisitor {
142
142
  const type = referencingElement.element;
143
143
  const codeFrame = (0, _apidomCore.toYAML)(referencingElement);
144
144
 
145
- // find element location: tree search for entry documents, visitor path for external
145
+ // find element location by identity in the document tree.
146
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
147
+ // falls back to visitorPath which may produce an incomplete path when
148
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
146
149
  let location;
147
- (0, _apidomTraverse.traverse)(this.reference.value.result, {
148
- enter: p => {
149
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
150
- location = p.formatPath();
151
- p.stop();
150
+ const root = this.reference.value.result;
151
+ if ((0, _apidomDatamodel.isElement)(root)) {
152
+ (0, _apidomTraverse.traverse)(root, {
153
+ enter: p => {
154
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
155
+ location = p.formatPath();
156
+ p.stop();
157
+ }
152
158
  }
153
- }
154
- });
159
+ });
160
+ }
155
161
  location ??= visitorPath.formatPath();
156
162
  const hop = {
157
163
  uri,
@@ -135,16 +135,22 @@ class OpenAPI3_1DereferenceVisitor {
135
135
  const type = referencingElement.element;
136
136
  const codeFrame = toYAML(referencingElement);
137
137
 
138
- // find element location: tree search for entry documents, visitor path for external
138
+ // find element location by identity in the document tree.
139
+ // guarded: this.reference.value may not be a ParseResultElement or may lack a result.
140
+ // falls back to visitorPath which may produce an incomplete path when
141
+ // dereferenceApiDOM is called with a fragment (cloneShallow creates a new root identity).
139
142
  let location;
140
- traverse(this.reference.value.result, {
141
- enter: p => {
142
- if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
143
- location = p.formatPath();
144
- p.stop();
143
+ const root = this.reference.value.result;
144
+ if (isElement(root)) {
145
+ traverse(root, {
146
+ enter: p => {
147
+ if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
148
+ location = p.formatPath();
149
+ p.stop();
150
+ }
145
151
  }
146
- }
147
- });
152
+ });
153
+ }
148
154
  location ??= visitorPath.formatPath();
149
155
  const hop = {
150
156
  uri,