@speclynx/apidom-reference 6.1.2 → 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 +63 -0
- package/README.md +57 -0
- package/dist/apidom-reference.browser.js +5783 -3741
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +31 -30
- package/src/File.cjs +5 -2
- package/src/File.mjs +5 -2
- package/src/bundle/index.cjs +6 -4
- package/src/bundle/index.mjs +6 -4
- 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/index.cjs +8 -5
- package/src/dereference/index.mjs +8 -5
- 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/options/index.cjs +4 -0
- package/src/options/index.mjs +4 -0
- package/src/options/util.cjs +7 -1
- package/src/options/util.mjs +8 -2
- 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/src/resolve/index.cjs +6 -3
- package/src/resolve/index.mjs +6 -3
- package/src/util/url.cjs +38 -8
- package/src/util/url.mjs +35 -6
- package/types/apidom-reference.d.ts +13 -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/types/util/url.d.ts +11 -0
- package/LICENSES/AFL-3.0.txt +0 -182
- package/LICENSES/BSD-3-Clause.txt +0 -26
- package/src/dereference/util.cjs +0 -33
- package/src/dereference/util.mjs +0 -27
- package/types/dereference/util.d.ts +0 -9
|
@@ -1,70 +1,70 @@
|
|
|
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 JSON Schema elements enclosing it.
|
|
9
|
+
*/
|
|
10
|
+
interface Arazzo1DereferenceContext {
|
|
11
|
+
readonly ancestorSchema$ids: string[];
|
|
12
|
+
}
|
|
7
13
|
/**
|
|
8
14
|
* @public
|
|
9
15
|
*/
|
|
10
16
|
export interface Arazzo1DereferenceVisitorOptions {
|
|
11
17
|
readonly reference: Reference;
|
|
12
18
|
readonly options: ReferenceOptions;
|
|
13
|
-
readonly indirections?: Element[];
|
|
14
19
|
readonly schema$idIndex?: Schema$idIndex;
|
|
15
|
-
readonly ancestors?: AncestorLineage<Element>;
|
|
16
|
-
readonly visited?: WeakSet<Element>;
|
|
17
20
|
readonly ancestorSchema$ids?: string[];
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
23
|
+
* Dereferences an Arazzo document. Reusable Objects expect the type of their
|
|
24
|
+
* `referenced-element` meta, JSON Schema `$ref`s expect a JSON Schema.
|
|
25
|
+
*
|
|
20
26
|
* @public
|
|
21
27
|
*/
|
|
22
|
-
declare class Arazzo1DereferenceVisitor {
|
|
23
|
-
protected readonly indirections: Element[];
|
|
24
|
-
protected readonly reference: Reference;
|
|
25
|
-
/**
|
|
26
|
-
* Base URI of the current document for resolving relative references.
|
|
27
|
-
* Honors the Arazzo `$self` field when present, otherwise falls back
|
|
28
|
-
* to the retrieval URI (`this.reference.uri`).
|
|
29
|
-
*/
|
|
30
|
-
protected readonly baseURI: string;
|
|
31
|
-
protected readonly options: ReferenceOptions;
|
|
28
|
+
declare class Arazzo1DereferenceVisitor extends DereferenceVisitor<Arazzo1DereferenceContext> {
|
|
32
29
|
/**
|
|
33
|
-
* Index of `$id`-bearing schemas per document, shared across
|
|
34
|
-
* of a single dereference run
|
|
30
|
+
* Index of `$id`-bearing schemas per document, shared across the visitors
|
|
31
|
+
* of a single dereference run.
|
|
35
32
|
*/
|
|
36
33
|
protected readonly schema$idIndex: Schema$idIndex;
|
|
37
|
-
protected readonly visited: WeakSet<Element>;
|
|
38
34
|
/**
|
|
39
35
|
* `$id`s of the JSON Schema elements enclosing the traversal root within its
|
|
40
36
|
* document (outermost first). Empty when the root is the document itself; a
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
37
|
+
* visitor traversing a fragment is seeded with the `$id`s of the schemas the
|
|
38
|
+
* fragment sits under, so the `$ref`s and `$id`s within resolve against the
|
|
39
|
+
* same base as they would from the document root.
|
|
44
40
|
*/
|
|
45
41
|
protected readonly ancestorSchema$ids: string[];
|
|
42
|
+
constructor({ reference, options, schema$idIndex, ancestorSchema$ids, }: Arazzo1DereferenceVisitorOptions);
|
|
43
|
+
protected get strategyName(): string;
|
|
44
|
+
protected createVisitor(reference: Reference, { ancestorSchema$ids }: Arazzo1DereferenceContext): Arazzo1DereferenceVisitor;
|
|
45
|
+
protected refractTo(element: Element, type: string): Element;
|
|
46
|
+
protected isOfType(element: Element, type: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Honors the Arazzo `$self` field when present, otherwise falls back to the retrieval URI.
|
|
49
|
+
*/
|
|
50
|
+
protected toDocumentBaseURI(reference: Reference): string;
|
|
51
|
+
/**
|
|
52
|
+
* Identity-based referencing: URI matches `$self` of an already processed Arazzo document.
|
|
53
|
+
*/
|
|
54
|
+
protected findReferenceByIdentity(uri: string): Reference | undefined;
|
|
46
55
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* the ancestor lineage, a circular reference is detected.
|
|
56
|
+
* A document as JSON Schema for locating schemas within it: a generic document is
|
|
57
|
+
* refracted to JSON Schema once per dereference run, a semantic one is used as it is.
|
|
50
58
|
*/
|
|
51
|
-
protected
|
|
52
|
-
constructor({ reference, options, indirections, schema$idIndex, ancestors, visited, ancestorSchema$ids, }: Arazzo1DereferenceVisitorOptions);
|
|
53
|
-
protected toAncestorLineage(path: Path<Element>): [AncestorLineage<Element>, Set<Element>];
|
|
54
|
-
protected toBaseURI(uri: string): string;
|
|
55
|
-
protected toReference(uri: string): Promise<Reference>;
|
|
59
|
+
protected toJSONSchemaDocument(document: Element): Element;
|
|
56
60
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* (type, uri, location, codeFrame, refFieldName, refFieldValue, trace).
|
|
61
|
-
* For errors already wrapped by a nested visitor: prepends the current hop to the trace.
|
|
62
|
-
*
|
|
63
|
-
* Inner/intermediate visitors always throw to let the trace accumulate.
|
|
64
|
-
* Only the entry document visitor respects continueOnError (callback/swallow/throw).
|
|
61
|
+
* Indexes the `$id`-bearing schemas of a document for the run. Transcluded elements aren't
|
|
62
|
+
* indexed: they're copies of structures indexed where they're defined,
|
|
63
|
+
* and in a document dereferenced in place their shared structure would be walked once per path.
|
|
65
64
|
*/
|
|
66
|
-
protected
|
|
67
|
-
|
|
65
|
+
protected index$ids(element: Element): void;
|
|
66
|
+
enter(path: Path<Element>): void;
|
|
67
|
+
ReusableElement(path: Path<Element>): Promise<void>;
|
|
68
68
|
JSONSchemaElement(path: Path<Element>): Promise<void>;
|
|
69
69
|
}
|
|
70
70
|
export default Arazzo1DereferenceVisitor;
|
|
@@ -13,7 +13,6 @@ export type { default as Parser, ParserOptions } from '../../../parse/parsers/Pa
|
|
|
13
13
|
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
|
|
14
14
|
export type { default as ResolveStrategy, ResolveStrategyOptions, } from '../../../resolve/strategies/ResolveStrategy.ts';
|
|
15
15
|
export type { default as BundleStrategy, BundleStrategyOptions, } from '../../../bundle/strategies/BundleStrategy.ts';
|
|
16
|
-
export type { AncestorLineage } from '../../util.ts';
|
|
17
16
|
/**
|
|
18
17
|
* @public
|
|
19
18
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Element } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
import DereferenceVisitor from '../DereferenceVisitor.ts';
|
|
4
4
|
import Reference from '../../../Reference.ts';
|
|
5
5
|
import type { ReferenceOptions } from '../../../options/index.ts';
|
|
6
6
|
/**
|
|
@@ -9,41 +9,25 @@ import type { ReferenceOptions } from '../../../options/index.ts';
|
|
|
9
9
|
export interface AsyncAPI2DereferenceVisitorOptions {
|
|
10
10
|
readonly reference: Reference;
|
|
11
11
|
readonly options: ReferenceOptions;
|
|
12
|
-
readonly indirections?: Element[];
|
|
13
|
-
readonly refractCache?: WeakMap<Element, Element>;
|
|
14
|
-
readonly ancestors?: AncestorLineage<Element>;
|
|
15
|
-
readonly visited?: WeakSet<Element>;
|
|
16
12
|
}
|
|
17
13
|
/**
|
|
14
|
+
* Dereferences an AsyncAPI 2 document. Reference Objects expect the type of their
|
|
15
|
+
* `referenced-element` meta, Channel Item `$ref`s a Channel Item Object.
|
|
16
|
+
*
|
|
18
17
|
* @public
|
|
19
18
|
*/
|
|
20
|
-
declare class AsyncAPI2DereferenceVisitor {
|
|
21
|
-
protected
|
|
22
|
-
protected
|
|
23
|
-
protected readonly options: ReferenceOptions;
|
|
24
|
-
protected readonly refractCache: WeakMap<Element, Element>;
|
|
25
|
-
protected readonly visited: WeakSet<Element>;
|
|
19
|
+
declare class AsyncAPI2DereferenceVisitor extends DereferenceVisitor<undefined> {
|
|
20
|
+
protected get strategyName(): string;
|
|
21
|
+
protected createVisitor(reference: Reference): AsyncAPI2DereferenceVisitor;
|
|
26
22
|
/**
|
|
27
|
-
*
|
|
28
|
-
* Used for cycle detection: if a referenced element is found in
|
|
29
|
-
* the ancestor lineage, a circular reference is detected.
|
|
23
|
+
* A Reference Object stands for the type its reference expects: it's dereferenced as that type.
|
|
30
24
|
*/
|
|
31
|
-
protected
|
|
32
|
-
constructor({ reference, options, indirections, ancestors, refractCache, visited, }: AsyncAPI2DereferenceVisitorOptions);
|
|
33
|
-
protected toAncestorLineage(path: Path<Element>): [AncestorLineage<Element>, Set<Element>];
|
|
34
|
-
protected toBaseURI(uri: string): string;
|
|
35
|
-
protected toReference(uri: string): Promise<Reference>;
|
|
25
|
+
protected isOfType(element: Element, type: string): boolean;
|
|
36
26
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* For new errors: wraps in UnresolvableReferenceError with structured context
|
|
40
|
-
* (type, uri, location, codeFrame, refFieldName, refFieldValue, trace).
|
|
41
|
-
* For errors already wrapped by a nested visitor: prepends the current hop to the trace.
|
|
42
|
-
*
|
|
43
|
-
* Inner/intermediate visitors always throw to let the trace accumulate.
|
|
44
|
-
* Only the entry document visitor respects continueOnError (callback/swallow/throw).
|
|
27
|
+
* A generic structure holding a `$ref` is a Reference Object to the expected type,
|
|
28
|
+
* unless the type has its own `$ref` field (Channel Item Object).
|
|
45
29
|
*/
|
|
46
|
-
protected
|
|
30
|
+
protected refractTo(element: Element, type: string): Element;
|
|
47
31
|
ReferenceElement(path: Path<Element>): Promise<void>;
|
|
48
32
|
ChannelItemElement(path: Path<Element>): Promise<void>;
|
|
49
33
|
}
|
|
@@ -13,7 +13,6 @@ export type { default as Parser, ParserOptions } from '../../../parse/parsers/Pa
|
|
|
13
13
|
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
|
|
14
14
|
export type { default as ResolveStrategy, ResolveStrategyOptions, } from '../../../resolve/strategies/ResolveStrategy.ts';
|
|
15
15
|
export type { default as BundleStrategy, BundleStrategyOptions, } from '../../../bundle/strategies/BundleStrategy.ts';
|
|
16
|
-
export type { AncestorLineage } from '../../util.ts';
|
|
17
16
|
export type { AsyncAPI2DereferenceVisitorOptions } from '../asyncapi-2/visitor.ts';
|
|
18
17
|
/**
|
|
19
18
|
* @public
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Element } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
import DereferenceVisitor from '../DereferenceVisitor.ts';
|
|
4
4
|
import Reference from '../../../Reference.ts';
|
|
5
5
|
import type { ReferenceOptions } from '../../../options/index.ts';
|
|
6
6
|
/**
|
|
@@ -9,41 +9,26 @@ import type { ReferenceOptions } from '../../../options/index.ts';
|
|
|
9
9
|
export interface OpenAPI2DereferenceVisitorOptions {
|
|
10
10
|
readonly reference: Reference;
|
|
11
11
|
readonly options: ReferenceOptions;
|
|
12
|
-
readonly indirections?: Element[];
|
|
13
|
-
readonly refractCache?: WeakMap<Element, Element>;
|
|
14
|
-
readonly ancestors?: AncestorLineage<Element>;
|
|
15
|
-
readonly visited?: WeakSet<Element>;
|
|
16
12
|
}
|
|
17
13
|
/**
|
|
14
|
+
* Dereferences an OpenAPI 2.0 document. Reference Objects and JSON Reference Objects expect
|
|
15
|
+
* the type of their `referenced-element` meta, Path Item `$ref`s a Path Item Object.
|
|
16
|
+
*
|
|
18
17
|
* @public
|
|
19
18
|
*/
|
|
20
|
-
declare class OpenAPI2DereferenceVisitor {
|
|
21
|
-
protected
|
|
22
|
-
protected
|
|
23
|
-
protected readonly options: ReferenceOptions;
|
|
24
|
-
protected readonly refractCache: WeakMap<Element, Element>;
|
|
25
|
-
protected readonly visited: WeakSet<Element>;
|
|
19
|
+
declare class OpenAPI2DereferenceVisitor extends DereferenceVisitor<undefined> {
|
|
20
|
+
protected get strategyName(): string;
|
|
21
|
+
protected createVisitor(reference: Reference): OpenAPI2DereferenceVisitor;
|
|
26
22
|
/**
|
|
27
|
-
*
|
|
28
|
-
* Used for cycle detection: if a referenced element is found in
|
|
29
|
-
* the ancestor lineage, a circular reference is detected.
|
|
23
|
+
* A (JSON) Reference Object stands for the type its reference expects: it's dereferenced as that type.
|
|
30
24
|
*/
|
|
31
|
-
protected
|
|
32
|
-
constructor({ reference, options, indirections, ancestors, refractCache, visited, }: OpenAPI2DereferenceVisitorOptions);
|
|
33
|
-
protected toAncestorLineage(path: Path<Element>): [AncestorLineage<Element>, Set<Element>];
|
|
34
|
-
protected toBaseURI(uri: string): string;
|
|
35
|
-
protected toReference(uri: string): Promise<Reference>;
|
|
25
|
+
protected isOfType(element: Element, type: string): boolean;
|
|
36
26
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* (type, uri, location, codeFrame, refFieldName, refFieldValue, trace).
|
|
41
|
-
* For errors already wrapped by a nested visitor: prepends the current hop to the trace.
|
|
42
|
-
*
|
|
43
|
-
* Inner/intermediate visitors always throw to let the trace accumulate.
|
|
44
|
-
* Only the entry document visitor respects continueOnError (callback/swallow/throw).
|
|
27
|
+
* A generic structure holding a `$ref` is a reference to the expected type: a JSON Reference
|
|
28
|
+
* Object for a Schema Object, a Reference Object otherwise, unless the type has its own `$ref`
|
|
29
|
+
* field (Path Item Object).
|
|
45
30
|
*/
|
|
46
|
-
protected
|
|
31
|
+
protected refractTo(element: Element, type: string): Element;
|
|
47
32
|
ReferenceElement(path: Path<Element>): Promise<void>;
|
|
48
33
|
PathItemElement(path: Path<Element>): Promise<void>;
|
|
49
34
|
JSONReferenceElement(path: Path<Element>): Promise<void>;
|
|
@@ -13,7 +13,6 @@ export type { default as Parser, ParserOptions } from '../../../parse/parsers/Pa
|
|
|
13
13
|
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
|
|
14
14
|
export type { default as ResolveStrategy, ResolveStrategyOptions, } from '../../../resolve/strategies/ResolveStrategy.ts';
|
|
15
15
|
export type { default as BundleStrategy, BundleStrategyOptions, } from '../../../bundle/strategies/BundleStrategy.ts';
|
|
16
|
-
export type { AncestorLineage } from '../../util.ts';
|
|
17
16
|
/**
|
|
18
17
|
* @public
|
|
19
18
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Element } from '@speclynx/apidom-datamodel';
|
|
2
2
|
import { type Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
import DereferenceVisitor from '../DereferenceVisitor.ts';
|
|
3
4
|
import Reference from '../../../Reference.ts';
|
|
4
|
-
import { AncestorLineage } from '../../util.ts';
|
|
5
5
|
import type { ReferenceOptions } from '../../../options/index.ts';
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
@@ -9,41 +9,26 @@ import type { ReferenceOptions } from '../../../options/index.ts';
|
|
|
9
9
|
export interface OpenAPI3_0DereferenceVisitorOptions {
|
|
10
10
|
readonly reference: Reference;
|
|
11
11
|
readonly options: ReferenceOptions;
|
|
12
|
-
readonly indirections?: Element[];
|
|
13
|
-
readonly refractCache?: WeakMap<Element, Element>;
|
|
14
|
-
readonly ancestors?: AncestorLineage<Element>;
|
|
15
|
-
readonly visited?: WeakSet<Element>;
|
|
16
12
|
}
|
|
17
13
|
/**
|
|
14
|
+
* Dereferences an OpenAPI 3.0 document. Reference Objects expect the type of their
|
|
15
|
+
* `referenced-element` meta, Path Item `$ref`s a Path Item Object. Link Objects get the
|
|
16
|
+
* Operation Object they point at attached, Example Objects the external value.
|
|
17
|
+
*
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
|
-
declare class OpenAPI3_0DereferenceVisitor {
|
|
21
|
-
protected
|
|
22
|
-
protected
|
|
23
|
-
protected readonly options: ReferenceOptions;
|
|
24
|
-
protected readonly refractCache: WeakMap<Element, Element>;
|
|
25
|
-
protected readonly visited: WeakSet<Element>;
|
|
20
|
+
declare class OpenAPI3_0DereferenceVisitor extends DereferenceVisitor<undefined> {
|
|
21
|
+
protected get strategyName(): string;
|
|
22
|
+
protected createVisitor(reference: Reference): OpenAPI3_0DereferenceVisitor;
|
|
26
23
|
/**
|
|
27
|
-
*
|
|
28
|
-
* Used for cycle detection: if a referenced element is found in
|
|
29
|
-
* the ancestor lineage, a circular reference is detected.
|
|
24
|
+
* A Reference Object stands for the type its reference expects: it's dereferenced as that type.
|
|
30
25
|
*/
|
|
31
|
-
protected
|
|
32
|
-
constructor({ reference, options, indirections, ancestors, refractCache, visited, }: OpenAPI3_0DereferenceVisitorOptions);
|
|
33
|
-
protected toAncestorLineage(path: Path<Element>): [AncestorLineage<Element>, Set<Element>];
|
|
34
|
-
protected toBaseURI(uri: string): string;
|
|
35
|
-
protected toReference(uri: string): Promise<Reference>;
|
|
26
|
+
protected isOfType(element: Element, type: string): boolean;
|
|
36
27
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* For new errors: wraps in UnresolvableReferenceError with structured context
|
|
40
|
-
* (type, uri, location, codeFrame, refFieldName, refFieldValue, trace).
|
|
41
|
-
* For errors already wrapped by a nested visitor: prepends the current hop to the trace.
|
|
42
|
-
*
|
|
43
|
-
* Inner/intermediate visitors always throw to let the trace accumulate.
|
|
44
|
-
* Only the entry document visitor respects continueOnError (callback/swallow/throw).
|
|
28
|
+
* A generic structure holding a `$ref` is a Reference Object to the expected type,
|
|
29
|
+
* unless the type has its own `$ref` field (Path Item Object).
|
|
45
30
|
*/
|
|
46
|
-
protected
|
|
31
|
+
protected refractTo(element: Element, type: string): Element;
|
|
47
32
|
ReferenceElement(path: Path<Element>): Promise<void>;
|
|
48
33
|
PathItemElement(path: Path<Element>): Promise<void>;
|
|
49
34
|
LinkElement(path: Path<Element>): Promise<void>;
|
|
@@ -13,7 +13,6 @@ export type { default as Parser, ParserOptions } from '../../../parse/parsers/Pa
|
|
|
13
13
|
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
|
|
14
14
|
export type { default as ResolveStrategy, ResolveStrategyOptions, } from '../../../resolve/strategies/ResolveStrategy.ts';
|
|
15
15
|
export type { default as BundleStrategy, BundleStrategyOptions, } from '../../../bundle/strategies/BundleStrategy.ts';
|
|
16
|
-
export type { AncestorLineage } from '../../util.ts';
|
|
17
16
|
/**
|
|
18
17
|
* @public
|
|
19
18
|
*/
|
|
@@ -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/types/util/url.d.ts
CHANGED
|
@@ -96,6 +96,17 @@ export declare const cwd: () => string;
|
|
|
96
96
|
* @public
|
|
97
97
|
*/
|
|
98
98
|
export declare const resolve: (from: string, to: string) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Normalizes a URI the way `resolve` normalizes its result (WHATWG URL normalization):
|
|
101
|
+
* lowercases the scheme and the host of an absolute URL, drops a default port and
|
|
102
|
+
* removes dot segments. This is not RFC 3986 syntax-based normalization: existing
|
|
103
|
+
* percent-encoding is left as is. A file system path is sanitized first, so characters
|
|
104
|
+
* not allowed in URLs (e.g. spaces, `[`, `?`) are percent-encoded; a `file://` URL has
|
|
105
|
+
* its path sanitized the same way and stays a URL. The fragment is kept as given.
|
|
106
|
+
* A URI that can't be normalized is returned unchanged.
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export declare const normalize: (uri: string) => string;
|
|
99
110
|
/**
|
|
100
111
|
* Computes the URI reference that resolves to `to` against `from` — the inverse
|
|
101
112
|
* of `resolve`: `resolve(from, relative(from, to)) === to`. The reference is
|