@speclynx/apidom-reference 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.
Files changed (95) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/apidom-reference.browser.js +15 -15
  3. package/dist/apidom-reference.browser.min.js +1 -1
  4. package/package.json +27 -26
  5. package/src/File.ts +0 -63
  6. package/src/Reference.ts +0 -38
  7. package/src/ReferenceSet.ts +0 -73
  8. package/src/bundle/index.ts +0 -57
  9. package/src/bundle/strategies/BundleStrategy.ts +0 -27
  10. package/src/bundle/strategies/openapi-3-1/index.ts +0 -57
  11. package/src/configuration/empty.ts +0 -1
  12. package/src/configuration/saturated.ts +0 -72
  13. package/src/dereference/index.ts +0 -96
  14. package/src/dereference/strategies/DereferenceStrategy.ts +0 -27
  15. package/src/dereference/strategies/apidom/index.ts +0 -128
  16. package/src/dereference/strategies/apidom/selectors/element-id.ts +0 -48
  17. package/src/dereference/strategies/apidom/visitor.ts +0 -316
  18. package/src/dereference/strategies/arazzo-1/index.ts +0 -158
  19. package/src/dereference/strategies/arazzo-1/selectors/$anchor.ts +0 -9
  20. package/src/dereference/strategies/arazzo-1/selectors/uri.ts +0 -5
  21. package/src/dereference/strategies/arazzo-1/source-descriptions.ts +0 -317
  22. package/src/dereference/strategies/arazzo-1/util.ts +0 -33
  23. package/src/dereference/strategies/arazzo-1/visitor.ts +0 -574
  24. package/src/dereference/strategies/asyncapi-2/index.ts +0 -133
  25. package/src/dereference/strategies/asyncapi-2/visitor.ts +0 -589
  26. package/src/dereference/strategies/openapi-2/index.ts +0 -136
  27. package/src/dereference/strategies/openapi-2/visitor.ts +0 -745
  28. package/src/dereference/strategies/openapi-3-0/index.ts +0 -134
  29. package/src/dereference/strategies/openapi-3-0/visitor.ts +0 -760
  30. package/src/dereference/strategies/openapi-3-1/index.ts +0 -141
  31. package/src/dereference/strategies/openapi-3-1/selectors/$anchor.ts +0 -64
  32. package/src/dereference/strategies/openapi-3-1/selectors/uri.ts +0 -54
  33. package/src/dereference/strategies/openapi-3-1/util.ts +0 -83
  34. package/src/dereference/strategies/openapi-3-1/visitor.ts +0 -1053
  35. package/src/dereference/util.ts +0 -29
  36. package/src/errors/BundleError.ts +0 -8
  37. package/src/errors/DereferenceError.ts +0 -8
  38. package/src/errors/EvaluationElementIdError.ts +0 -8
  39. package/src/errors/EvaluationJsonSchema$anchorError.ts +0 -8
  40. package/src/errors/EvaluationJsonSchemaUriError.ts +0 -8
  41. package/src/errors/InvalidJsonSchema$anchorError.ts +0 -12
  42. package/src/errors/JsonSchema$anchorError.ts +0 -8
  43. package/src/errors/JsonSchemaUriError.ts +0 -8
  44. package/src/errors/MaximumBundleDepthError.ts +0 -8
  45. package/src/errors/MaximumDereferenceDepthError.ts +0 -8
  46. package/src/errors/MaximumResolveDepthError.ts +0 -8
  47. package/src/errors/ParseError.ts +0 -8
  48. package/src/errors/ParserError.ts +0 -8
  49. package/src/errors/PluginError.ts +0 -15
  50. package/src/errors/ResolveError.ts +0 -8
  51. package/src/errors/ResolverError.ts +0 -8
  52. package/src/errors/UnmatchedBundleStrategyError.ts +0 -8
  53. package/src/errors/UnmatchedDereferenceStrategyError.ts +0 -8
  54. package/src/errors/UnmatchedParserError.ts +0 -8
  55. package/src/errors/UnmatchedResolveStrategyError.ts +0 -8
  56. package/src/errors/UnmatchedResolverError.ts +0 -8
  57. package/src/errors/UnresolvableReferenceError.ts +0 -8
  58. package/src/index.ts +0 -135
  59. package/src/options/index.ts +0 -239
  60. package/src/options/util.ts +0 -22
  61. package/src/parse/index.ts +0 -67
  62. package/src/parse/parsers/Parser.ts +0 -80
  63. package/src/parse/parsers/apidom-json/index.ts +0 -78
  64. package/src/parse/parsers/arazzo-json-1/index.ts +0 -76
  65. package/src/parse/parsers/arazzo-json-1/source-descriptions.ts +0 -280
  66. package/src/parse/parsers/arazzo-yaml-1/index.ts +0 -77
  67. package/src/parse/parsers/arazzo-yaml-1/source-descriptions.ts +0 -16
  68. package/src/parse/parsers/asyncapi-json-2/index.ts +0 -58
  69. package/src/parse/parsers/asyncapi-yaml-2/index.ts +0 -58
  70. package/src/parse/parsers/binary/index-browser.ts +0 -60
  71. package/src/parse/parsers/binary/index-node.ts +0 -57
  72. package/src/parse/parsers/json/index.ts +0 -52
  73. package/src/parse/parsers/openapi-json-2/index.ts +0 -58
  74. package/src/parse/parsers/openapi-json-3-0/index.ts +0 -59
  75. package/src/parse/parsers/openapi-json-3-1/index.ts +0 -59
  76. package/src/parse/parsers/openapi-yaml-2/index.ts +0 -58
  77. package/src/parse/parsers/openapi-yaml-3-0/index.ts +0 -59
  78. package/src/parse/parsers/openapi-yaml-3-1/index.ts +0 -59
  79. package/src/parse/parsers/yaml-1-2/index.ts +0 -60
  80. package/src/resolve/index.ts +0 -75
  81. package/src/resolve/resolvers/HTTPResolver.ts +0 -58
  82. package/src/resolve/resolvers/Resolver.ts +0 -25
  83. package/src/resolve/resolvers/file/index-browser.ts +0 -24
  84. package/src/resolve/resolvers/file/index-node.ts +0 -55
  85. package/src/resolve/resolvers/http-axios/cache/MemoryCache.ts +0 -46
  86. package/src/resolve/resolvers/http-axios/index.ts +0 -130
  87. package/src/resolve/strategies/ResolveStrategy.ts +0 -26
  88. package/src/resolve/strategies/apidom/index.ts +0 -78
  89. package/src/resolve/strategies/asyncapi-2/index.ts +0 -78
  90. package/src/resolve/strategies/openapi-2/index.ts +0 -78
  91. package/src/resolve/strategies/openapi-3-0/index.ts +0 -78
  92. package/src/resolve/strategies/openapi-3-1/index.ts +0 -78
  93. package/src/resolve/util.ts +0 -39
  94. package/src/util/plugins.ts +0 -37
  95. package/src/util/url.ts +0 -285
@@ -1,29 +0,0 @@
1
- import { Element, isElement } from '@speclynx/apidom-datamodel';
2
-
3
- /**
4
- * @public
5
- */
6
-
7
- export class AncestorLineage<T extends Element> extends Array<Set<T>> {
8
- includesCycle(element: T) {
9
- return this.filter((ancestors) => ancestors.has(element)).length > 1;
10
- }
11
-
12
- includes(searchElement: Set<T> | T, fromIndex?: number): boolean {
13
- if (searchElement instanceof Set) {
14
- return super.includes(searchElement, fromIndex);
15
- }
16
- return this.some((ancestors) => ancestors.has(searchElement));
17
- }
18
-
19
- findItem(predicate: (item: T) => boolean): T | undefined {
20
- for (const set of this) {
21
- for (const item of set) {
22
- if (isElement(item) && predicate(item)) {
23
- return item;
24
- }
25
- }
26
- }
27
- return undefined;
28
- }
29
- }
@@ -1,8 +0,0 @@
1
- import { ApiDOMError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class BundleError extends ApiDOMError {}
7
-
8
- export default BundleError;
@@ -1,8 +0,0 @@
1
- import { ApiDOMStructuredError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class DereferenceError extends ApiDOMStructuredError {}
7
-
8
- export default DereferenceError;
@@ -1,8 +0,0 @@
1
- import { ApiDOMError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class EvaluationElementIdError extends ApiDOMError {}
7
-
8
- export default EvaluationElementIdError;
@@ -1,8 +0,0 @@
1
- import JsonSchema$anchorError from './JsonSchema$anchorError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class EvaluationJsonSchema$anchorError extends JsonSchema$anchorError {}
7
-
8
- export default EvaluationJsonSchema$anchorError;
@@ -1,8 +0,0 @@
1
- import JsonSchemaUriError from './JsonSchemaUriError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class EvaluationJsonSchemaUriError extends JsonSchemaUriError {}
7
-
8
- export default EvaluationJsonSchemaUriError;
@@ -1,12 +0,0 @@
1
- import JsonSchema$anchorError from './JsonSchema$anchorError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class InvalidJsonSchema$anchorError extends JsonSchema$anchorError {
7
- constructor(anchor: string) {
8
- super(`Invalid JSON Schema $anchor "${anchor}"`);
9
- }
10
- }
11
-
12
- export default InvalidJsonSchema$anchorError;
@@ -1,8 +0,0 @@
1
- import { ApiDOMError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class JsonSchema$anchorError extends ApiDOMError {}
7
-
8
- export default JsonSchema$anchorError;
@@ -1,8 +0,0 @@
1
- import { ApiDOMError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class JsonSchemaUriError extends ApiDOMError {}
7
-
8
- export default JsonSchemaUriError;
@@ -1,8 +0,0 @@
1
- import BundleError from './BundleError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class MaximumBundleDepthError extends BundleError {}
7
-
8
- export default MaximumBundleDepthError;
@@ -1,8 +0,0 @@
1
- import DereferenceError from './DereferenceError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class MaximumDereferenceDepthError extends DereferenceError {}
7
-
8
- export default MaximumDereferenceDepthError;
@@ -1,8 +0,0 @@
1
- import ResolveError from './ResolveError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class MaximumResolveDepthError extends ResolveError {}
7
-
8
- export default MaximumResolveDepthError;
@@ -1,8 +0,0 @@
1
- import { ApiDOMError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class ParseError extends ApiDOMError {}
7
-
8
- export default ParseError;
@@ -1,8 +0,0 @@
1
- import ParseError from './ParseError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class ParserError extends ParseError {}
7
-
8
- export default ParserError;
@@ -1,15 +0,0 @@
1
- import { ApiDOMError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class PluginError extends ApiDOMError {
7
- public plugin: any;
8
-
9
- constructor(message: string, options: { cause?: Error; plugin: any }) {
10
- super(message, { cause: options.cause });
11
- this.plugin = options.plugin;
12
- }
13
- }
14
-
15
- export default PluginError;
@@ -1,8 +0,0 @@
1
- import { ApiDOMStructuredError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
- class ResolveError extends ApiDOMStructuredError {}
7
-
8
- export default ResolveError;
@@ -1,8 +0,0 @@
1
- import ResolveError from './ResolveError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class ResolverError extends ResolveError {}
7
-
8
- export default ResolverError;
@@ -1,8 +0,0 @@
1
- import BundleError from './BundleError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class UnmatchedBundleStrategyError extends BundleError {}
7
-
8
- export default UnmatchedBundleStrategyError;
@@ -1,8 +0,0 @@
1
- import DereferenceError from './DereferenceError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class UnmatchedDereferenceStrategyError extends DereferenceError {}
7
-
8
- export default UnmatchedDereferenceStrategyError;
@@ -1,8 +0,0 @@
1
- import ParserError from './ParserError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class UnmatchedParserError extends ParserError {}
7
-
8
- export default UnmatchedParserError;
@@ -1,8 +0,0 @@
1
- import ResolveError from './ResolveError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class UnmatchedResolveStrategyError extends ResolveError {}
7
-
8
- export default UnmatchedResolveStrategyError;
@@ -1,8 +0,0 @@
1
- import ResolverError from './ResolverError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class UnmatchedResolverError extends ResolverError {}
7
-
8
- export default UnmatchedResolverError;
@@ -1,8 +0,0 @@
1
- import DereferenceError from './DereferenceError.ts';
2
-
3
- /**
4
- * @public
5
- */
6
- class UnresolvableReferenceError extends DereferenceError {}
7
-
8
- export default UnresolvableReferenceError;
package/src/index.ts DELETED
@@ -1,135 +0,0 @@
1
- import { ParseResultElement, Element } from '@speclynx/apidom-datamodel';
2
-
3
- import File from './File.ts';
4
- import ReferenceSet from './ReferenceSet.ts';
5
- import * as url from './util/url.ts';
6
- import defaultOptions from './options/index.ts';
7
- import { merge as mergeOptions } from './options/util.ts';
8
- import parseFn from './parse/index.ts';
9
- import resolveFn, { resolveApiDOM as resolveApiDOMFn } from './resolve/index.ts';
10
- import { readFile as readFileFn } from './resolve/util.ts';
11
- import dereferenceFn, { dereferenceApiDOM as dereferenceApiDOMFn } from './dereference/index.ts';
12
- import bundleFn from './bundle/index.ts';
13
-
14
- export { url };
15
-
16
- export { default as Parser } from './parse/parsers/Parser.ts';
17
- export type { ParserOptions } from './parse/parsers/Parser.ts';
18
-
19
- export { default as Resolver } from './resolve/resolvers/Resolver.ts';
20
- export { default as HTTPResolver } from './resolve/resolvers/HTTPResolver.ts';
21
- export type { HTTPResolverOptions, CacheOptions } from './resolve/resolvers/HTTPResolver.ts';
22
- export { default as ResolveStrategy } from './resolve/strategies/ResolveStrategy.ts';
23
- export type { ResolverOptions } from './resolve/resolvers/Resolver.ts';
24
- export type { ResolveStrategyOptions } from './resolve/strategies/ResolveStrategy.ts';
25
-
26
- export { default as DereferenceStrategy } from './dereference/strategies/DereferenceStrategy.ts';
27
- export type { DereferenceStrategyOptions } from './dereference/strategies/DereferenceStrategy.ts';
28
- export { AncestorLineage as DereferenceAncestorLineage } from './dereference/util.ts';
29
-
30
- export { default as BundleStrategy } from './bundle/strategies/BundleStrategy.ts';
31
- export type { BundleStrategyOptions } from './bundle/strategies/BundleStrategy.ts';
32
-
33
- export { default as options } from './options/index.ts';
34
- export { merge as mergeOptions } from './options/util.ts';
35
- export type {
36
- ReferenceOptions as ApiDOMReferenceOptions,
37
- ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
38
- ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
39
- ReferenceParseOptions as ApiDOMReferenceParseOptions,
40
- ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
41
- } from './options/index.ts';
42
-
43
- export { File };
44
- export { default as Reference } from './Reference.ts';
45
- export { ReferenceSet };
46
- export type { FileOptions } from './File.ts';
47
- export type { ReferenceOptions } from './Reference.ts';
48
- export type { ReferenceSetOptions } from './ReferenceSet.ts';
49
-
50
- export { default as BundleError } from './errors/BundleError.ts';
51
- export { default as MaximumBundleDepthError } from './errors/MaximumBundleDepthError.ts';
52
- export { default as UnmatchedBundleStrategyError } from './errors/UnmatchedBundleStrategyError.ts';
53
- export { default as DereferenceError } from './errors/DereferenceError.ts';
54
- export { default as UnresolvableReferenceError } from './errors/UnresolvableReferenceError.ts';
55
- export { default as EvaluationElementIdError } from './errors/EvaluationElementIdError.ts';
56
- export { default as EvaluationJsonSchema$anchorError } from './errors/EvaluationJsonSchema$anchorError.ts';
57
- export { default as EvaluationJsonSchemaUriError } from './errors/EvaluationJsonSchemaUriError.ts';
58
- export { default as InvalidJsonSchema$anchorError } from './errors/InvalidJsonSchema$anchorError.ts';
59
- export { default as JsonSchema$anchorError } from './errors/JsonSchema$anchorError.ts';
60
- export { default as JsonSchemaURIError } from './errors/JsonSchemaUriError.ts';
61
- export { default as MaximumDereferenceDepthError } from './errors/MaximumDereferenceDepthError.ts';
62
- export { default as MaximumResolveDepthError } from './errors/MaximumResolveDepthError.ts';
63
- export { default as ParseError } from './errors/ParseError.ts';
64
- export { default as ParserError } from './errors/ParserError.ts';
65
- export { default as PluginError } from './errors/PluginError.ts';
66
- export { default as ResolveError } from './errors/ResolveError.ts';
67
- export { default as ResolverError } from './errors/ResolverError.ts';
68
- export { default as UnmatchedDereferenceStrategyError } from './errors/UnmatchedDereferenceStrategyError.ts';
69
- export { default as UnmatchedResolveStrategyError } from './errors/UnmatchedResolveStrategyError.ts';
70
- export { default as UnmatchedResolverError } from './errors/UnmatchedResolverError.ts';
71
- export { default as UnmatchedParserError } from './errors/UnmatchedParserError.ts';
72
-
73
- /**
74
- * @public
75
- */
76
- export const readFile = async (uri: string, options = {}): Promise<Buffer> => {
77
- const mergedOptions = mergeOptions(defaultOptions, options);
78
- const file = new File({ uri: url.sanitize(uri) });
79
-
80
- return readFileFn(file, mergedOptions);
81
- };
82
-
83
- /**
84
- * @public
85
- */
86
- export const parse = async (uri: string, options = {}): Promise<ParseResultElement> => {
87
- const mergedOptions = mergeOptions(defaultOptions, options);
88
- return parseFn(uri, mergedOptions);
89
- };
90
-
91
- /**
92
- * @public
93
- */
94
- export const resolve = async (uri: string, options = {}): Promise<ReferenceSet> => {
95
- const mergedOptions = mergeOptions(defaultOptions, options);
96
- return resolveFn(uri, mergedOptions);
97
- };
98
-
99
- /**
100
- * @public
101
- */
102
- export const resolveApiDOM = async <T extends Element>(
103
- element: T,
104
- options = {},
105
- ): Promise<ReferenceSet> => {
106
- const mergedOptions = mergeOptions(defaultOptions, options);
107
- return resolveApiDOMFn(element, mergedOptions);
108
- };
109
-
110
- /**
111
- * @public
112
- */
113
- export const dereference = async (uri: string, options = {}): Promise<ParseResultElement> => {
114
- const mergedOptions = mergeOptions(defaultOptions, options);
115
- return dereferenceFn(uri, mergedOptions);
116
- };
117
-
118
- /**
119
- * @public
120
- */
121
- export const dereferenceApiDOM = async <T extends Element>(
122
- element: T,
123
- options = {},
124
- ): Promise<T> => {
125
- const mergedOptions = mergeOptions(defaultOptions, options);
126
- return dereferenceApiDOMFn(element, mergedOptions);
127
- };
128
-
129
- /**
130
- * @public
131
- */
132
- export const bundle = async (uri: string, options = {}): Promise<ParseResultElement> => {
133
- const mergedOptions = mergeOptions(defaultOptions, options);
134
- return bundleFn(uri, mergedOptions);
135
- };
@@ -1,239 +0,0 @@
1
- import { identity } from 'ramda';
2
- import type { RefElement } from '@speclynx/apidom-datamodel';
3
-
4
- import type Parser from '../parse/parsers/Parser.ts';
5
- import type Resolver from '../resolve/resolvers/Resolver.ts';
6
- import type ResolveStrategy from '../resolve/strategies/ResolveStrategy.ts';
7
- import type DereferenceStrategy from '../dereference/strategies/DereferenceStrategy.ts';
8
- import type ReferenceSet from '../ReferenceSet.ts';
9
- import type BundleStrategy from '../bundle/strategies/BundleStrategy.ts';
10
- import type UnresolvableReferenceError from '../errors/UnresolvableReferenceError.ts';
11
-
12
- /**
13
- * @public
14
- */
15
- export interface ReferenceParseOptions {
16
- mediaType: string;
17
- parsers: Array<Parser>;
18
- parserOpts: Record<string, any>;
19
- }
20
-
21
- /**
22
- * @public
23
- */
24
- export interface ReferenceResolveOptions {
25
- baseURI: string;
26
- resolvers: Array<Resolver>;
27
- resolverOpts: Record<string, any>;
28
- strategies: Array<ResolveStrategy>;
29
- strategyOpts: Record<string, any>;
30
- internal: boolean;
31
- external: boolean;
32
- maxDepth: number;
33
- }
34
-
35
- /**
36
- * @public
37
- */
38
- export interface ReferenceDereferenceOptions {
39
- strategies: Array<DereferenceStrategy>;
40
- strategyOpts: Record<string, any>;
41
- refSet: null | ReferenceSet;
42
- maxDepth: number;
43
- circular: 'ignore' | 'replace' | 'error';
44
- circularReplacer: (ref: RefElement) => unknown;
45
- immutable: boolean;
46
- continueOnError: boolean | ((error: UnresolvableReferenceError) => void);
47
- }
48
-
49
- /**
50
- * @public
51
- */
52
- export interface ReferenceBundleOptions {
53
- strategies: Array<BundleStrategy>;
54
- refSet: null | ReferenceSet;
55
- maxDepth: number;
56
- }
57
-
58
- /**
59
- * @public
60
- */
61
- export interface ReferenceOptions {
62
- readonly parse: ReferenceParseOptions;
63
- readonly resolve: ReferenceResolveOptions;
64
- readonly dereference: ReferenceDereferenceOptions;
65
- readonly bundle: ReferenceBundleOptions;
66
- }
67
-
68
- /**
69
- * @public
70
- */
71
- const defaultOptions: ReferenceOptions = {
72
- parse: {
73
- /**
74
- * This is media type that will be used to parse the input.
75
- */
76
- mediaType: 'text/plain',
77
-
78
- /**
79
- * Determines how different types of files will be parsed.
80
- *
81
- * You can add additional parsers of your own, replace an existing one with
82
- * your own implementation, or remove any resolver by removing it from the list.
83
- * It's recommended to keep the order of parser from most specific ones to most generic ones.
84
- */
85
- parsers: [],
86
-
87
- /**
88
- * These options are merged with parser plugin instance before the plugin is run.
89
- */
90
- parserOpts: {},
91
- },
92
- resolve: {
93
- /**
94
- * baseURI serves as a base for all relative URL found in ApiDOM references.
95
- */
96
- baseURI: '',
97
- /**
98
- * Determines how References will be resolved.
99
- *
100
- * You can add additional resolvers of your own, replace an existing one with
101
- * your own implementation, or remove any resolver by removing it from the list.
102
- */
103
- resolvers: [],
104
- /**
105
- * These options are merged with resolver plugin instance before the plugin is run.
106
- */
107
- resolverOpts: {},
108
- /**
109
- * Determines strategies how References are identified and processed by resolvers.
110
- * Strategy is determined by media type.
111
- *
112
- * You can add additional resolver strategies of your own, replace an existing one with
113
- * your own implementation, or remove any resolve strategy by removing it from the list.
114
- */
115
- strategies: [],
116
- /**
117
- * These options are available in resolver strategy `canResolve` and `resolve` methods.
118
- */
119
- strategyOpts: {},
120
- /**
121
- * Determines whether internal references will be resolved.
122
- * Internal references will simply be ignored.
123
- */
124
- internal: true,
125
- /**
126
- * Determines whether external references will be resolved.
127
- * If this option is disabled, then none of above resolvers will be called.
128
- * Instead, external references will simply be ignored.
129
- */
130
- external: true,
131
- /**
132
- * Determines the maximum depth of resolve algorithms.
133
- * By default, there is no limit.
134
- *
135
- * This option tracks the depth of the file tree not the depth of the dereference path.
136
- *
137
- * It can be set to any positive integer number or zero (0).
138
- *
139
- * The resolver should throw MaximumResolverDepthError if resolution depth
140
- * is exceeded by this option.
141
- */
142
- maxDepth: +Infinity,
143
- },
144
- dereference: {
145
- /**
146
- * Determines strategies how ApiDOM is dereferenced.
147
- * Strategy is determined by media type or by inspecting ApiDOM to be dereferenced.
148
- *
149
- * You can add additional dereference strategies of your own, replace an existing one with
150
- * your own implementation, or remove any dereference strategy by removing it from the list.
151
- */
152
- strategies: [],
153
- /**
154
- * These options are available in dereference strategy `canDereference` and `dereference` methods.
155
- */
156
- strategyOpts: {},
157
- /**
158
- * This option accepts an instance of pre-computed ReferenceSet.
159
- * If provided it will speed up the dereferencing significantly as the external
160
- * resolution doesn't need to happen anymore.
161
- */
162
- refSet: null,
163
- /**
164
- * Determines the maximum depth of dereferencing.
165
- * By default, there is no limit.
166
- *
167
- * The maxDepth represents a number of references that needed to be followed
168
- * before the eventual value was reached.
169
- *
170
- * It can be set to any positive integer number or zero (0).
171
- *
172
- * The dereferencing should throw MaximumDereferenceDepthError if dereferencing depth
173
- * is exceeded by this option.
174
- */
175
- maxDepth: +Infinity,
176
- /**
177
- * Determines how circular references are handled.
178
- *
179
- * "ignore" - circular reference are allowed
180
- * "replace" - circular references are not allowed and are translated to RefElement
181
- * "error" - circular references are not allowed and will throw an error
182
- */
183
- circular: 'ignore',
184
- /**
185
- * This function is used to replace circular references when `circular` option is set to "replace".
186
- * By default, it's an identity function. It means that circular references are replaced with RefElement.
187
- */
188
- circularReplacer: identity,
189
- /**
190
- * Determines whether the dereferencing process will be immutable.
191
- * By default, the dereferencing process is immutable, which means that the original
192
- * ApiDOM passed to the dereference process is NOT modified.
193
- *
194
- * true - the dereferencing process will be immutable (deep cloning of ApiDOM is involved)
195
- * false - the dereferencing process will be mutable
196
- */
197
- immutable: true,
198
- /**
199
- * Controls error handling during dereferencing.
200
- *
201
- * false - fail fast, throw on first error (default)
202
- * true - skip unresolvable references silently, continue dereferencing
203
- * (error) => void - callback invoked for each error; if the callback
204
- * itself throws, dereferencing stops with that error
205
- */
206
- continueOnError: false,
207
- },
208
- bundle: {
209
- /**
210
- * Determines strategies how ApiDOM is bundled.
211
- * Strategy is determined by media type or by inspecting ApiDOM to be bundled.
212
- *
213
- * You can add additional bundle strategies of your own, replace an existing one with
214
- * your own implementation, or remove any bundle strategy by removing it from the list.
215
- */
216
- strategies: [],
217
- /**
218
- * This option accepts an instance of pre-computed ReferenceSet.
219
- * If provided it will speed up the bundling significantly as the external
220
- * resolution doesn't need to happen anymore.
221
- */
222
- refSet: null,
223
- /**
224
- * Determines the maximum depth of bundling.
225
- * By default, there is no limit.
226
- *
227
- * The maxDepth represents a number of references that needed to be followed
228
- * before the eventual value was reached.
229
- *
230
- * It can be set to any positive integer number or zero (0).
231
- *
232
- * The bundling should throw MaximumBundleDepthError if bundling depth
233
- * is exceeded by this option.
234
- */
235
- maxDepth: +Infinity,
236
- },
237
- };
238
-
239
- export default defaultOptions;
@@ -1,22 +0,0 @@
1
- import { mergeDeepRight, lens, path, assocPath, over } from 'ramda';
2
- import { isEmptyString } from 'ramda-adjunct';
3
-
4
- import { cwd } from '../util/url.ts';
5
- import type { ReferenceOptions } from './index.ts';
6
-
7
- /**
8
- * Algorithm for deep merging options.
9
- */
10
-
11
- const baseURILens = lens(path(['resolve', 'baseURI']), assocPath(['resolve', 'baseURI']));
12
- const baseURIDefault = (baseURI: string) => (isEmptyString(baseURI) ? cwd() : baseURI);
13
-
14
- /**
15
- * @public
16
- */
17
-
18
- export const merge = (lObj: ReferenceOptions, rObj: Record<string, any>): ReferenceOptions => {
19
- const withoutDefaults = mergeDeepRight(lObj, rObj);
20
- // @ts-ignore
21
- return over(baseURILens, baseURIDefault, withoutDefaults);
22
- };