@speclynx/apidom-reference 6.2.0 → 7.0.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 +49 -0
- package/README.md +45 -0
- package/dist/apidom-reference.browser.js +4701 -3478
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +29 -28
- package/src/File.cjs +5 -2
- package/src/File.mjs +5 -2
- package/src/bundle/strategies/arazzo-1/index.cjs +3 -2
- package/src/bundle/strategies/arazzo-1/index.mjs +3 -2
- package/src/bundle/strategies/asyncapi-2/index.cjs +3 -2
- package/src/bundle/strategies/asyncapi-2/index.mjs +3 -2
- package/src/bundle/strategies/openapi-2/index.cjs +3 -2
- package/src/bundle/strategies/openapi-2/index.mjs +3 -2
- package/src/bundle/strategies/openapi-3-0/index.cjs +3 -2
- package/src/bundle/strategies/openapi-3-0/index.mjs +3 -2
- package/src/bundle/strategies/openapi-3-1/index.cjs +3 -2
- package/src/bundle/strategies/openapi-3-1/index.mjs +3 -2
- package/src/dereference/strategies/DereferenceVisitor.cjs +588 -0
- package/src/dereference/strategies/DereferenceVisitor.mjs +580 -0
- package/src/dereference/strategies/arazzo-1/index.cjs +14 -39
- package/src/dereference/strategies/arazzo-1/index.mjs +15 -40
- package/src/dereference/strategies/arazzo-1/visitor.cjs +207 -331
- package/src/dereference/strategies/arazzo-1/visitor.mjs +215 -338
- package/src/dereference/strategies/asyncapi-2/index.cjs +11 -39
- package/src/dereference/strategies/asyncapi-2/index.mjs +11 -39
- package/src/dereference/strategies/asyncapi-2/visitor.cjs +133 -425
- package/src/dereference/strategies/asyncapi-2/visitor.mjs +137 -429
- package/src/dereference/strategies/openapi-2/index.cjs +12 -42
- package/src/dereference/strategies/openapi-2/index.mjs +12 -42
- package/src/dereference/strategies/openapi-2/visitor.cjs +168 -532
- package/src/dereference/strategies/openapi-2/visitor.mjs +172 -536
- package/src/dereference/strategies/openapi-3-0/index.cjs +12 -42
- package/src/dereference/strategies/openapi-3-0/index.mjs +12 -42
- package/src/dereference/strategies/openapi-3-0/visitor.cjs +194 -468
- package/src/dereference/strategies/openapi-3-0/visitor.mjs +199 -473
- package/src/dereference/strategies/openapi-3-1/index.cjs +16 -42
- package/src/dereference/strategies/openapi-3-1/index.mjs +16 -42
- package/src/dereference/strategies/openapi-3-1/visitor.cjs +350 -602
- package/src/dereference/strategies/openapi-3-1/visitor.mjs +357 -608
- package/src/dereference/strategies/overlay-1/index.cjs +3 -2
- package/src/dereference/strategies/overlay-1/index.mjs +3 -2
- package/src/index.cjs +0 -7
- package/src/index.mjs +0 -1
- package/src/parse/index.cjs +9 -1
- package/src/parse/index.mjs +9 -1
- package/src/parse/parsers/apidom-json/index.cjs +2 -1
- package/src/parse/parsers/apidom-json/index.mjs +2 -1
- package/src/parse/parsers/arazzo-json-1/index.cjs +2 -1
- package/src/parse/parsers/arazzo-json-1/index.mjs +2 -1
- package/src/parse/parsers/arazzo-yaml-1/index.cjs +2 -1
- package/src/parse/parsers/arazzo-yaml-1/index.mjs +2 -1
- package/src/parse/parsers/asyncapi-json-2/index.cjs +2 -1
- package/src/parse/parsers/asyncapi-json-2/index.mjs +2 -1
- package/src/parse/parsers/asyncapi-yaml-2/index.cjs +2 -1
- package/src/parse/parsers/asyncapi-yaml-2/index.mjs +2 -1
- package/src/parse/parsers/json/index.cjs +2 -1
- package/src/parse/parsers/json/index.mjs +2 -1
- package/src/parse/parsers/openapi-json-2/index.cjs +2 -1
- package/src/parse/parsers/openapi-json-2/index.mjs +2 -1
- package/src/parse/parsers/openapi-json-3-0/index.cjs +2 -1
- package/src/parse/parsers/openapi-json-3-0/index.mjs +2 -1
- package/src/parse/parsers/openapi-json-3-1/index.cjs +2 -1
- package/src/parse/parsers/openapi-json-3-1/index.mjs +2 -1
- package/src/parse/parsers/openapi-yaml-2/index.cjs +2 -1
- package/src/parse/parsers/openapi-yaml-2/index.mjs +2 -1
- package/src/parse/parsers/openapi-yaml-3-0/index.cjs +2 -1
- package/src/parse/parsers/openapi-yaml-3-0/index.mjs +2 -1
- package/src/parse/parsers/openapi-yaml-3-1/index.cjs +2 -1
- package/src/parse/parsers/openapi-yaml-3-1/index.mjs +2 -1
- package/src/parse/parsers/overlay-json-1/index.cjs +2 -1
- package/src/parse/parsers/overlay-json-1/index.mjs +2 -1
- package/src/parse/parsers/overlay-yaml-1/index.cjs +2 -1
- package/src/parse/parsers/overlay-yaml-1/index.mjs +2 -1
- package/src/parse/parsers/yaml-1-2/index.cjs +2 -1
- package/src/parse/parsers/yaml-1-2/index.mjs +2 -1
- package/types/apidom-reference.d.ts +0 -9
- package/types/dereference/strategies/DereferenceVisitor.d.ts +224 -0
- package/types/dereference/strategies/arazzo-1/index.d.ts +0 -1
- package/types/dereference/strategies/arazzo-1/visitor.d.ts +38 -38
- package/types/dereference/strategies/asyncapi-2/index.d.ts +0 -1
- package/types/dereference/strategies/asyncapi-2/visitor.d.ts +13 -29
- package/types/dereference/strategies/openapi-2/index.d.ts +0 -1
- package/types/dereference/strategies/openapi-2/visitor.d.ts +14 -29
- package/types/dereference/strategies/openapi-3-0/index.d.ts +0 -1
- package/types/dereference/strategies/openapi-3-0/visitor.d.ts +13 -28
- package/types/dereference/strategies/openapi-3-1/index.d.ts +0 -1
- package/types/dereference/strategies/openapi-3-1/visitor.d.ts +37 -33
- package/types/index.d.ts +0 -1
- package/src/dereference/util.cjs +0 -33
- package/src/dereference/util.mjs +0 -27
- package/types/dereference/util.d.ts +0 -9
|
@@ -1,65 +1,69 @@
|
|
|
1
1
|
import { Element } from '@speclynx/apidom-datamodel';
|
|
2
2
|
import { type Path } from '@speclynx/apidom-traverse';
|
|
3
3
|
import { type Schema$idIndex } from './selectors/uri.ts';
|
|
4
|
+
import DereferenceVisitor from '../DereferenceVisitor.ts';
|
|
4
5
|
import Reference from '../../../Reference.ts';
|
|
5
|
-
import { AncestorLineage } from '../../util.ts';
|
|
6
6
|
import type { ReferenceOptions } from '../../../options/index.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Context of a source being dereferenced: the `$id`s of the Schema Objects enclosing it.
|
|
9
|
+
*/
|
|
10
|
+
interface OpenAPI3_1DereferenceContext {
|
|
11
|
+
readonly ancestorSchema$ids: string[];
|
|
12
|
+
}
|
|
7
13
|
/**
|
|
8
14
|
* @public
|
|
9
15
|
*/
|
|
10
16
|
export interface OpenAPI3_1DereferenceVisitorOptions {
|
|
11
17
|
readonly reference: Reference;
|
|
12
18
|
readonly options: ReferenceOptions;
|
|
13
|
-
readonly indirections?: Element[];
|
|
14
|
-
readonly refractCache?: WeakMap<Element, Element>;
|
|
15
19
|
readonly schema$idIndex?: Schema$idIndex;
|
|
16
|
-
readonly ancestors?: AncestorLineage<Element>;
|
|
17
|
-
readonly visited?: WeakSet<Element>;
|
|
18
20
|
readonly ancestorSchema$ids?: string[];
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
23
|
+
* Dereferences an OpenAPI 3.1 document. Reference Objects expect the type of their
|
|
24
|
+
* `referenced-element` meta, Path Item `$ref`s a Path Item, Schema Object `$ref`s a Schema Object.
|
|
25
|
+
* Link Objects get the Operation Object they point at attached, Example Objects
|
|
26
|
+
* the external value.
|
|
27
|
+
*
|
|
21
28
|
* @public
|
|
22
29
|
*/
|
|
23
|
-
declare class OpenAPI3_1DereferenceVisitor {
|
|
24
|
-
protected readonly indirections: Element[];
|
|
25
|
-
protected readonly reference: Reference;
|
|
26
|
-
protected readonly options: ReferenceOptions;
|
|
27
|
-
protected readonly refractCache: WeakMap<Element, Element>;
|
|
30
|
+
declare class OpenAPI3_1DereferenceVisitor extends DereferenceVisitor<OpenAPI3_1DereferenceContext> {
|
|
28
31
|
/**
|
|
29
|
-
* Index of `$id`-bearing schemas per document, shared across
|
|
30
|
-
* of a single dereference run
|
|
32
|
+
* Index of `$id`-bearing schemas per document, shared across the visitors
|
|
33
|
+
* of a single dereference run.
|
|
31
34
|
*/
|
|
32
35
|
protected readonly schema$idIndex: Schema$idIndex;
|
|
33
|
-
protected readonly visited: WeakSet<Element>;
|
|
34
36
|
/**
|
|
35
37
|
* `$id`s of the JSON Schema elements enclosing the traversal root within its
|
|
36
38
|
* document (outermost first). Empty when the root is the document itself; a
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
* visitor traversing a fragment is seeded with the `$id`s of the schemas the
|
|
40
|
+
* fragment sits under, so the `$ref`s and `$id`s within resolve against the
|
|
41
|
+
* same base as they would from the document root.
|
|
40
42
|
*/
|
|
41
43
|
protected readonly ancestorSchema$ids: string[];
|
|
44
|
+
constructor({ reference, options, schema$idIndex, ancestorSchema$ids, }: OpenAPI3_1DereferenceVisitorOptions);
|
|
45
|
+
protected get strategyName(): string;
|
|
46
|
+
protected createVisitor(reference: Reference, { ancestorSchema$ids }: OpenAPI3_1DereferenceContext): OpenAPI3_1DereferenceVisitor;
|
|
47
|
+
/**
|
|
48
|
+
* A Reference Object stands for the type its reference expects: it's dereferenced as that type.
|
|
49
|
+
*/
|
|
50
|
+
protected isOfType(element: Element, type: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* A generic structure holding a `$ref` is a Reference Object to the expected type,
|
|
53
|
+
* unless the type has its own `$ref` field (Path Item Object, Schema Object).
|
|
54
|
+
*/
|
|
55
|
+
protected refractTo(element: Element, type: string): Element;
|
|
42
56
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* the ancestor lineage, a circular reference is detected.
|
|
57
|
+
* A document as Schema Object for locating schemas within it: a generic document is
|
|
58
|
+
* refracted to Schema Object once per dereference run, a semantic one is used as it is.
|
|
46
59
|
*/
|
|
47
|
-
protected
|
|
48
|
-
constructor({ reference, options, indirections, refractCache, schema$idIndex, ancestors, visited, ancestorSchema$ids, }: OpenAPI3_1DereferenceVisitorOptions);
|
|
49
|
-
protected toAncestorLineage(path: Path<Element>): [AncestorLineage<Element>, Set<Element>];
|
|
50
|
-
protected toBaseURI(uri: string): string;
|
|
51
|
-
protected toReference(uri: string): Promise<Reference>;
|
|
60
|
+
protected toSchemaDocument(document: Element): Element;
|
|
52
61
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* (type, uri, location, codeFrame, refFieldName, refFieldValue, trace).
|
|
57
|
-
* For errors already wrapped by a nested visitor: prepends the current hop to the trace.
|
|
58
|
-
*
|
|
59
|
-
* Inner/intermediate visitors always throw to let the trace accumulate.
|
|
60
|
-
* Only the entry document visitor respects continueOnError (callback/swallow/throw).
|
|
62
|
+
* Indexes the `$id`-bearing schemas of an element for the run. Transcluded elements aren't
|
|
63
|
+
* indexed: they're copies of structures indexed where they're defined,
|
|
64
|
+
* and in a document dereferenced in place their shared structure would be walked once per path.
|
|
61
65
|
*/
|
|
62
|
-
protected
|
|
66
|
+
protected index$ids(element: Element): void;
|
|
63
67
|
ReferenceElement(path: Path<Element>): Promise<void>;
|
|
64
68
|
PathItemElement(path: Path<Element>): Promise<void>;
|
|
65
69
|
LinkElement(path: Path<Element>): Promise<void>;
|
package/types/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export type { ResolverOptions } from './resolve/resolvers/Resolver.ts';
|
|
|
13
13
|
export type { ResolveStrategyOptions } from './resolve/strategies/ResolveStrategy.ts';
|
|
14
14
|
export { default as DereferenceStrategy } from './dereference/strategies/DereferenceStrategy.ts';
|
|
15
15
|
export type { DereferenceStrategyOptions } from './dereference/strategies/DereferenceStrategy.ts';
|
|
16
|
-
export { AncestorLineage as DereferenceAncestorLineage } from './dereference/util.ts';
|
|
17
16
|
export { default as BundleStrategy } from './bundle/strategies/BundleStrategy.ts';
|
|
18
17
|
export type { BundleStrategyOptions } from './bundle/strategies/BundleStrategy.ts';
|
|
19
18
|
export type { ComponentNamesStrategy, ComponentNameResolver, ComponentNameResolverArgs, ComponentNameCollisionSeverity, } from './options/index.ts';
|
package/src/dereference/util.cjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AncestorLineage = void 0;
|
|
7
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
class AncestorLineage extends Array {
|
|
13
|
-
includesCycle(element) {
|
|
14
|
-
return this.filter(ancestors => ancestors.has(element)).length > 1;
|
|
15
|
-
}
|
|
16
|
-
includes(searchElement, fromIndex) {
|
|
17
|
-
if (searchElement instanceof Set) {
|
|
18
|
-
return super.includes(searchElement, fromIndex);
|
|
19
|
-
}
|
|
20
|
-
return this.some(ancestors => ancestors.has(searchElement));
|
|
21
|
-
}
|
|
22
|
-
findItem(predicate) {
|
|
23
|
-
for (const set of this) {
|
|
24
|
-
for (const item of set) {
|
|
25
|
-
if ((0, _apidomDatamodel.isElement)(item) && predicate(item)) {
|
|
26
|
-
return item;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.AncestorLineage = AncestorLineage;
|
package/src/dereference/util.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isElement } from '@speclynx/apidom-datamodel';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export class AncestorLineage extends Array {
|
|
8
|
-
includesCycle(element) {
|
|
9
|
-
return this.filter(ancestors => ancestors.has(element)).length > 1;
|
|
10
|
-
}
|
|
11
|
-
includes(searchElement, fromIndex) {
|
|
12
|
-
if (searchElement instanceof Set) {
|
|
13
|
-
return super.includes(searchElement, fromIndex);
|
|
14
|
-
}
|
|
15
|
-
return this.some(ancestors => ancestors.has(searchElement));
|
|
16
|
-
}
|
|
17
|
-
findItem(predicate) {
|
|
18
|
-
for (const set of this) {
|
|
19
|
-
for (const item of set) {
|
|
20
|
-
if (isElement(item) && predicate(item)) {
|
|
21
|
-
return item;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Element } from '@speclynx/apidom-datamodel';
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export declare class AncestorLineage<T extends Element> extends Array<Set<T>> {
|
|
6
|
-
includesCycle(element: T): boolean;
|
|
7
|
-
includes(searchElement: Set<T> | T, fromIndex?: number): boolean;
|
|
8
|
-
findItem(predicate: (item: T) => boolean): T | undefined;
|
|
9
|
-
}
|