@speclynx/apidom-reference 4.0.2 → 4.0.3
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 +6 -0
- package/package.json +26 -27
- package/src/File.cjs +50 -0
- package/src/File.mjs +44 -0
- package/src/File.ts +63 -0
- package/src/Reference.cjs +31 -0
- package/src/Reference.mjs +27 -0
- package/src/Reference.ts +38 -0
- package/src/ReferenceSet.cjs +60 -0
- package/src/ReferenceSet.mjs +57 -0
- package/src/ReferenceSet.ts +73 -0
- package/src/bundle/index.cjs +61 -0
- package/src/bundle/index.mjs +55 -0
- package/src/bundle/index.ts +57 -0
- package/src/bundle/strategies/BundleStrategy.cjs +20 -0
- package/src/bundle/strategies/BundleStrategy.mjs +16 -0
- package/src/bundle/strategies/BundleStrategy.ts +27 -0
- package/src/bundle/strategies/openapi-3-1/index.cjs +35 -0
- package/src/bundle/strategies/openapi-3-1/index.mjs +29 -0
- package/src/bundle/strategies/openapi-3-1/index.ts +57 -0
- package/src/configuration/empty.cjs +9 -0
- package/src/configuration/empty.mjs +1 -0
- package/src/configuration/empty.ts +1 -0
- package/src/configuration/saturated.cjs +88 -0
- package/src/configuration/saturated.mjs +80 -0
- package/src/configuration/saturated.ts +72 -0
- package/src/dereference/index.cjs +90 -0
- package/src/dereference/index.mjs +83 -0
- package/src/dereference/index.ts +96 -0
- package/src/dereference/strategies/DereferenceStrategy.cjs +20 -0
- package/src/dereference/strategies/DereferenceStrategy.mjs +16 -0
- package/src/dereference/strategies/DereferenceStrategy.ts +27 -0
- package/src/dereference/strategies/apidom/index.cjs +89 -0
- package/src/dereference/strategies/apidom/index.mjs +83 -0
- package/src/dereference/strategies/apidom/index.ts +128 -0
- package/src/dereference/strategies/apidom/selectors/element-id.cjs +47 -0
- package/src/dereference/strategies/apidom/selectors/element-id.mjs +41 -0
- package/src/dereference/strategies/apidom/selectors/element-id.ts +48 -0
- package/src/dereference/strategies/apidom/visitor.cjs +266 -0
- package/src/dereference/strategies/apidom/visitor.mjs +259 -0
- package/src/dereference/strategies/apidom/visitor.ts +316 -0
- package/src/dereference/strategies/arazzo-1/index.cjs +109 -0
- package/src/dereference/strategies/arazzo-1/index.mjs +100 -0
- package/src/dereference/strategies/arazzo-1/index.ts +158 -0
- package/src/dereference/strategies/arazzo-1/selectors/$anchor.cjs +12 -0
- package/src/dereference/strategies/arazzo-1/selectors/$anchor.mjs +1 -0
- package/src/dereference/strategies/arazzo-1/selectors/$anchor.ts +9 -0
- package/src/dereference/strategies/arazzo-1/selectors/uri.cjs +8 -0
- package/src/dereference/strategies/arazzo-1/selectors/uri.mjs +1 -0
- package/src/dereference/strategies/arazzo-1/selectors/uri.ts +5 -0
- package/src/dereference/strategies/arazzo-1/source-descriptions.cjs +248 -0
- package/src/dereference/strategies/arazzo-1/source-descriptions.mjs +243 -0
- package/src/dereference/strategies/arazzo-1/source-descriptions.ts +317 -0
- package/src/dereference/strategies/arazzo-1/util.cjs +37 -0
- package/src/dereference/strategies/arazzo-1/util.mjs +29 -0
- package/src/dereference/strategies/arazzo-1/util.ts +33 -0
- package/src/dereference/strategies/arazzo-1/visitor.cjs +507 -0
- package/src/dereference/strategies/arazzo-1/visitor.mjs +500 -0
- package/src/dereference/strategies/arazzo-1/visitor.ts +574 -0
- package/src/dereference/strategies/asyncapi-2/index.cjs +94 -0
- package/src/dereference/strategies/asyncapi-2/index.mjs +88 -0
- package/src/dereference/strategies/asyncapi-2/index.ts +133 -0
- package/src/dereference/strategies/asyncapi-2/visitor.cjs +501 -0
- package/src/dereference/strategies/asyncapi-2/visitor.mjs +494 -0
- package/src/dereference/strategies/asyncapi-2/visitor.ts +589 -0
- package/src/dereference/strategies/openapi-2/index.cjs +96 -0
- package/src/dereference/strategies/openapi-2/index.mjs +90 -0
- package/src/dereference/strategies/openapi-2/index.ts +136 -0
- package/src/dereference/strategies/openapi-2/visitor.cjs +629 -0
- package/src/dereference/strategies/openapi-2/visitor.mjs +622 -0
- package/src/dereference/strategies/openapi-2/visitor.ts +745 -0
- package/src/dereference/strategies/openapi-3-0/index.cjs +96 -0
- package/src/dereference/strategies/openapi-3-0/index.mjs +90 -0
- package/src/dereference/strategies/openapi-3-0/index.ts +134 -0
- package/src/dereference/strategies/openapi-3-0/visitor.cjs +622 -0
- package/src/dereference/strategies/openapi-3-0/visitor.mjs +615 -0
- package/src/dereference/strategies/openapi-3-0/visitor.ts +760 -0
- package/src/dereference/strategies/openapi-3-1/index.cjs +99 -0
- package/src/dereference/strategies/openapi-3-1/index.mjs +90 -0
- package/src/dereference/strategies/openapi-3-1/index.ts +141 -0
- package/src/dereference/strategies/openapi-3-1/selectors/$anchor.cjs +65 -0
- package/src/dereference/strategies/openapi-3-1/selectors/$anchor.mjs +54 -0
- package/src/dereference/strategies/openapi-3-1/selectors/$anchor.ts +64 -0
- package/src/dereference/strategies/openapi-3-1/selectors/uri.cjs +50 -0
- package/src/dereference/strategies/openapi-3-1/selectors/uri.mjs +42 -0
- package/src/dereference/strategies/openapi-3-1/selectors/uri.ts +54 -0
- package/src/dereference/strategies/openapi-3-1/util.cjs +68 -0
- package/src/dereference/strategies/openapi-3-1/util.mjs +59 -0
- package/src/dereference/strategies/openapi-3-1/util.ts +83 -0
- package/src/dereference/strategies/openapi-3-1/visitor.cjs +874 -0
- package/src/dereference/strategies/openapi-3-1/visitor.mjs +867 -0
- package/src/dereference/strategies/openapi-3-1/visitor.ts +1053 -0
- package/src/dereference/util.cjs +31 -0
- package/src/dereference/util.mjs +27 -0
- package/src/dereference/util.ts +29 -0
- package/src/errors/BundleError.cjs +10 -0
- package/src/errors/BundleError.mjs +7 -0
- package/src/errors/BundleError.ts +8 -0
- package/src/errors/DereferenceError.cjs +10 -0
- package/src/errors/DereferenceError.mjs +7 -0
- package/src/errors/DereferenceError.ts +8 -0
- package/src/errors/EvaluationElementIdError.cjs +10 -0
- package/src/errors/EvaluationElementIdError.mjs +7 -0
- package/src/errors/EvaluationElementIdError.ts +8 -0
- package/src/errors/EvaluationJsonSchema$anchorError.cjs +11 -0
- package/src/errors/EvaluationJsonSchema$anchorError.mjs +6 -0
- package/src/errors/EvaluationJsonSchema$anchorError.ts +8 -0
- package/src/errors/EvaluationJsonSchemaUriError.cjs +11 -0
- package/src/errors/EvaluationJsonSchemaUriError.mjs +6 -0
- package/src/errors/EvaluationJsonSchemaUriError.ts +8 -0
- package/src/errors/InvalidJsonSchema$anchorError.cjs +15 -0
- package/src/errors/InvalidJsonSchema$anchorError.mjs +10 -0
- package/src/errors/InvalidJsonSchema$anchorError.ts +12 -0
- package/src/errors/JsonSchema$anchorError.cjs +10 -0
- package/src/errors/JsonSchema$anchorError.mjs +7 -0
- package/src/errors/JsonSchema$anchorError.ts +8 -0
- package/src/errors/JsonSchemaUriError.cjs +10 -0
- package/src/errors/JsonSchemaUriError.mjs +7 -0
- package/src/errors/JsonSchemaUriError.ts +8 -0
- package/src/errors/MaximumBundleDepthError.cjs +11 -0
- package/src/errors/MaximumBundleDepthError.mjs +6 -0
- package/src/errors/MaximumBundleDepthError.ts +8 -0
- package/src/errors/MaximumDereferenceDepthError.cjs +11 -0
- package/src/errors/MaximumDereferenceDepthError.mjs +6 -0
- package/src/errors/MaximumDereferenceDepthError.ts +8 -0
- package/src/errors/MaximumResolveDepthError.cjs +11 -0
- package/src/errors/MaximumResolveDepthError.mjs +6 -0
- package/src/errors/MaximumResolveDepthError.ts +8 -0
- package/src/errors/ParseError.cjs +10 -0
- package/src/errors/ParseError.mjs +7 -0
- package/src/errors/ParseError.ts +8 -0
- package/src/errors/ParserError.cjs +11 -0
- package/src/errors/ParserError.mjs +6 -0
- package/src/errors/ParserError.ts +8 -0
- package/src/errors/PluginError.cjs +18 -0
- package/src/errors/PluginError.mjs +15 -0
- package/src/errors/PluginError.ts +15 -0
- package/src/errors/ResolveError.cjs +10 -0
- package/src/errors/ResolveError.mjs +7 -0
- package/src/errors/ResolveError.ts +8 -0
- package/src/errors/ResolverError.cjs +11 -0
- package/src/errors/ResolverError.mjs +6 -0
- package/src/errors/ResolverError.ts +8 -0
- package/src/errors/UnmatchedBundleStrategyError.cjs +11 -0
- package/src/errors/UnmatchedBundleStrategyError.mjs +6 -0
- package/src/errors/UnmatchedBundleStrategyError.ts +8 -0
- package/src/errors/UnmatchedDereferenceStrategyError.cjs +11 -0
- package/src/errors/UnmatchedDereferenceStrategyError.mjs +6 -0
- package/src/errors/UnmatchedDereferenceStrategyError.ts +8 -0
- package/src/errors/UnmatchedParserError.cjs +11 -0
- package/src/errors/UnmatchedParserError.mjs +6 -0
- package/src/errors/UnmatchedParserError.ts +8 -0
- package/src/errors/UnmatchedResolveStrategyError.cjs +11 -0
- package/src/errors/UnmatchedResolveStrategyError.mjs +6 -0
- package/src/errors/UnmatchedResolveStrategyError.ts +8 -0
- package/src/errors/UnmatchedResolverError.cjs +11 -0
- package/src/errors/UnmatchedResolverError.mjs +6 -0
- package/src/errors/UnmatchedResolverError.ts +8 -0
- package/src/errors/UnresolvableReferenceError.cjs +11 -0
- package/src/errors/UnresolvableReferenceError.mjs +6 -0
- package/src/errors/UnresolvableReferenceError.ts +8 -0
- package/src/index.cjs +146 -0
- package/src/index.mjs +103 -0
- package/src/index.ts +135 -0
- package/src/options/index.cjs +194 -0
- package/src/options/index.mjs +191 -0
- package/src/options/index.ts +239 -0
- package/src/options/util.cjs +24 -0
- package/src/options/util.mjs +19 -0
- package/src/options/util.ts +22 -0
- package/src/parse/index.cjs +69 -0
- package/src/parse/index.mjs +63 -0
- package/src/parse/index.ts +67 -0
- package/src/parse/parsers/Parser.cjs +62 -0
- package/src/parse/parsers/Parser.mjs +58 -0
- package/src/parse/parsers/Parser.ts +80 -0
- package/src/parse/parsers/apidom-json/index.cjs +70 -0
- package/src/parse/parsers/apidom-json/index.mjs +64 -0
- package/src/parse/parsers/apidom-json/index.ts +78 -0
- package/src/parse/parsers/arazzo-json-1/index.cjs +62 -0
- package/src/parse/parsers/arazzo-json-1/index.mjs +56 -0
- package/src/parse/parsers/arazzo-json-1/index.ts +76 -0
- package/src/parse/parsers/arazzo-json-1/source-descriptions.cjs +221 -0
- package/src/parse/parsers/arazzo-json-1/source-descriptions.mjs +214 -0
- package/src/parse/parsers/arazzo-json-1/source-descriptions.ts +280 -0
- package/src/parse/parsers/arazzo-yaml-1/index.cjs +62 -0
- package/src/parse/parsers/arazzo-yaml-1/index.mjs +56 -0
- package/src/parse/parsers/arazzo-yaml-1/index.ts +77 -0
- package/src/parse/parsers/arazzo-yaml-1/source-descriptions.cjs +12 -0
- package/src/parse/parsers/arazzo-yaml-1/source-descriptions.mjs +7 -0
- package/src/parse/parsers/arazzo-yaml-1/source-descriptions.ts +16 -0
- package/src/parse/parsers/asyncapi-json-2/index.cjs +54 -0
- package/src/parse/parsers/asyncapi-json-2/index.mjs +48 -0
- package/src/parse/parsers/asyncapi-json-2/index.ts +58 -0
- package/src/parse/parsers/asyncapi-yaml-2/index.cjs +54 -0
- package/src/parse/parsers/asyncapi-yaml-2/index.mjs +48 -0
- package/src/parse/parsers/asyncapi-yaml-2/index.ts +58 -0
- package/src/parse/parsers/binary/index-browser.cjs +56 -0
- package/src/parse/parsers/binary/index-browser.mjs +50 -0
- package/src/parse/parsers/binary/index-browser.ts +60 -0
- package/src/parse/parsers/binary/index-node.cjs +51 -0
- package/src/parse/parsers/binary/index-node.mjs +45 -0
- package/src/parse/parsers/binary/index-node.ts +57 -0
- package/src/parse/parsers/json/index.cjs +53 -0
- package/src/parse/parsers/json/index.mjs +47 -0
- package/src/parse/parsers/json/index.ts +52 -0
- package/src/parse/parsers/openapi-json-2/index.cjs +54 -0
- package/src/parse/parsers/openapi-json-2/index.mjs +48 -0
- package/src/parse/parsers/openapi-json-2/index.ts +58 -0
- package/src/parse/parsers/openapi-json-3-0/index.cjs +54 -0
- package/src/parse/parsers/openapi-json-3-0/index.mjs +48 -0
- package/src/parse/parsers/openapi-json-3-0/index.ts +59 -0
- package/src/parse/parsers/openapi-json-3-1/index.cjs +54 -0
- package/src/parse/parsers/openapi-json-3-1/index.mjs +48 -0
- package/src/parse/parsers/openapi-json-3-1/index.ts +59 -0
- package/src/parse/parsers/openapi-yaml-2/index.cjs +54 -0
- package/src/parse/parsers/openapi-yaml-2/index.mjs +48 -0
- package/src/parse/parsers/openapi-yaml-2/index.ts +58 -0
- package/src/parse/parsers/openapi-yaml-3-0/index.cjs +54 -0
- package/src/parse/parsers/openapi-yaml-3-0/index.mjs +48 -0
- package/src/parse/parsers/openapi-yaml-3-0/index.ts +59 -0
- package/src/parse/parsers/openapi-yaml-3-1/index.cjs +54 -0
- package/src/parse/parsers/openapi-yaml-3-1/index.mjs +48 -0
- package/src/parse/parsers/openapi-yaml-3-1/index.ts +59 -0
- package/src/parse/parsers/yaml-1-2/index.cjs +56 -0
- package/src/parse/parsers/yaml-1-2/index.mjs +50 -0
- package/src/parse/parsers/yaml-1-2/index.ts +60 -0
- package/src/resolve/index.cjs +67 -0
- package/src/resolve/index.mjs +60 -0
- package/src/resolve/index.ts +75 -0
- package/src/resolve/resolvers/HTTPResolver.cjs +45 -0
- package/src/resolve/resolvers/HTTPResolver.mjs +37 -0
- package/src/resolve/resolvers/HTTPResolver.ts +58 -0
- package/src/resolve/resolvers/Resolver.cjs +20 -0
- package/src/resolve/resolvers/Resolver.mjs +16 -0
- package/src/resolve/resolvers/Resolver.ts +25 -0
- package/src/resolve/resolvers/file/index-browser.cjs +24 -0
- package/src/resolve/resolvers/file/index-browser.mjs +19 -0
- package/src/resolve/resolvers/file/index-browser.ts +24 -0
- package/src/resolve/resolvers/file/index-node.cjs +49 -0
- package/src/resolve/resolvers/file/index-node.mjs +42 -0
- package/src/resolve/resolvers/file/index-node.ts +55 -0
- package/src/resolve/resolvers/http-axios/cache/MemoryCache.cjs +41 -0
- package/src/resolve/resolvers/http-axios/cache/MemoryCache.mjs +37 -0
- package/src/resolve/resolvers/http-axios/cache/MemoryCache.ts +46 -0
- package/src/resolve/resolvers/http-axios/index.cjs +113 -0
- package/src/resolve/resolvers/http-axios/index.mjs +105 -0
- package/src/resolve/resolvers/http-axios/index.ts +130 -0
- package/src/resolve/strategies/ResolveStrategy.cjs +20 -0
- package/src/resolve/strategies/ResolveStrategy.mjs +16 -0
- package/src/resolve/strategies/ResolveStrategy.ts +26 -0
- package/src/resolve/strategies/apidom/index.cjs +49 -0
- package/src/resolve/strategies/apidom/index.mjs +43 -0
- package/src/resolve/strategies/apidom/index.ts +78 -0
- package/src/resolve/strategies/asyncapi-2/index.cjs +49 -0
- package/src/resolve/strategies/asyncapi-2/index.mjs +43 -0
- package/src/resolve/strategies/asyncapi-2/index.ts +78 -0
- package/src/resolve/strategies/openapi-2/index.cjs +49 -0
- package/src/resolve/strategies/openapi-2/index.mjs +43 -0
- package/src/resolve/strategies/openapi-2/index.ts +78 -0
- package/src/resolve/strategies/openapi-3-0/index.cjs +49 -0
- package/src/resolve/strategies/openapi-3-0/index.mjs +43 -0
- package/src/resolve/strategies/openapi-3-0/index.ts +78 -0
- package/src/resolve/strategies/openapi-3-1/index.cjs +49 -0
- package/src/resolve/strategies/openapi-3-1/index.mjs +43 -0
- package/src/resolve/strategies/openapi-3-1/index.ts +78 -0
- package/src/resolve/util.cjs +37 -0
- package/src/resolve/util.mjs +30 -0
- package/src/resolve/util.ts +39 -0
- package/src/util/plugins.cjs +39 -0
- package/src/util/plugins.mjs +34 -0
- package/src/util/plugins.ts +37 -0
- package/src/util/url.cjs +288 -0
- package/src/util/url.mjs +274 -0
- package/src/util/url.ts +285 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ramda = require("ramda");
|
|
8
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
9
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
10
|
+
var _HTTPResolver = _interopRequireDefault(require("../HTTPResolver.cjs"));
|
|
11
|
+
var _MemoryCache = _interopRequireDefault(require("./cache/MemoryCache.cjs"));
|
|
12
|
+
var _ResolverError = _interopRequireDefault(require("../../../errors/ResolverError.cjs"));
|
|
13
|
+
var url = _interopRequireWildcard(require("../../../util/url.cjs"));
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
class HTTPResolverAxios extends _HTTPResolver.default {
|
|
26
|
+
axiosConfig = {};
|
|
27
|
+
axiosInstance;
|
|
28
|
+
previousAxiosConfig;
|
|
29
|
+
cacheStore;
|
|
30
|
+
previousCache;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
const {
|
|
33
|
+
axiosConfig = {},
|
|
34
|
+
...rest
|
|
35
|
+
} = options ?? {};
|
|
36
|
+
super({
|
|
37
|
+
...rest,
|
|
38
|
+
name: 'http-axios'
|
|
39
|
+
});
|
|
40
|
+
this.axiosConfig = axiosConfig;
|
|
41
|
+
this.cacheStore = new _MemoryCache.default((0, _ramdaAdjunct.isPlainObject)(this.cache) ? this.cache : {});
|
|
42
|
+
}
|
|
43
|
+
getHttpClient() {
|
|
44
|
+
if (this.axiosInstance === undefined || this.previousAxiosConfig !== this.axiosConfig) {
|
|
45
|
+
const config = (0, _ramda.omit)(['interceptors'], this.axiosConfig);
|
|
46
|
+
const {
|
|
47
|
+
interceptors
|
|
48
|
+
} = this.axiosConfig;
|
|
49
|
+
this.axiosInstance = _axios.default.create({
|
|
50
|
+
timeout: this.timeout,
|
|
51
|
+
maxRedirects: this.redirects,
|
|
52
|
+
withCredentials: this.withCredentials,
|
|
53
|
+
responseType: 'arraybuffer',
|
|
54
|
+
...config
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// settings up request interceptors
|
|
58
|
+
if (Array.isArray(interceptors?.request)) {
|
|
59
|
+
interceptors.request.forEach(requestInterceptor => {
|
|
60
|
+
this.axiosInstance.interceptors.request.use(...(0, _ramdaAdjunct.ensureArray)(requestInterceptor));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// settings up response interceptors
|
|
65
|
+
if (Array.isArray(interceptors?.response)) {
|
|
66
|
+
interceptors.response.forEach(responseInterceptor => {
|
|
67
|
+
this.axiosInstance.interceptors.response.use(...(0, _ramdaAdjunct.ensureArray)(responseInterceptor));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
this.previousAxiosConfig = this.axiosConfig;
|
|
71
|
+
}
|
|
72
|
+
return this.axiosInstance;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Ensures cacheStore is config-isolated for cloned resolvers.
|
|
77
|
+
* When a resolver is cloned via Object.create (in readFile), the clone inherits
|
|
78
|
+
* cacheStore from the prototype. Object.create(cacheStore) creates a view that
|
|
79
|
+
* shares the underlying store Map but allows isolated config (maxEntries, maxStaleAge)
|
|
80
|
+
* via own properties set by Object.assign.
|
|
81
|
+
*/
|
|
82
|
+
getCacheStore() {
|
|
83
|
+
if (this.previousCache !== this.cache) {
|
|
84
|
+
if (!Object.hasOwn(this, 'cacheStore')) {
|
|
85
|
+
this.cacheStore = Object.create(this.cacheStore);
|
|
86
|
+
}
|
|
87
|
+
if ((0, _ramdaAdjunct.isPlainObject)(this.cache)) {
|
|
88
|
+
Object.assign(this.cacheStore, this.cache);
|
|
89
|
+
}
|
|
90
|
+
this.previousCache = this.cache;
|
|
91
|
+
}
|
|
92
|
+
return this.cacheStore;
|
|
93
|
+
}
|
|
94
|
+
async read(file) {
|
|
95
|
+
const uri = url.stripHash(file.uri);
|
|
96
|
+
const cacheStore = this.cache ? this.getCacheStore() : undefined;
|
|
97
|
+
|
|
98
|
+
// return cached content if available
|
|
99
|
+
const cached = cacheStore?.get(uri);
|
|
100
|
+
if (cached !== undefined) return cached;
|
|
101
|
+
const client = this.getHttpClient();
|
|
102
|
+
try {
|
|
103
|
+
const response = await client.get(uri);
|
|
104
|
+
cacheStore?.set(uri, response.data);
|
|
105
|
+
return response.data;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new _ResolverError.default(`Error downloading "${file.uri}"`, {
|
|
108
|
+
cause: error
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
var _default = exports.default = HTTPResolverAxios;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { omit } from 'ramda';
|
|
2
|
+
import { ensureArray, isPlainObject } from 'ramda-adjunct';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import HTTPResolver from "../HTTPResolver.mjs";
|
|
5
|
+
import MemoryCache from "./cache/MemoryCache.mjs";
|
|
6
|
+
import ResolverError from "../../../errors/ResolverError.mjs";
|
|
7
|
+
import * as url from "../../../util/url.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class HTTPResolverAxios extends HTTPResolver {
|
|
18
|
+
axiosConfig = {};
|
|
19
|
+
axiosInstance;
|
|
20
|
+
previousAxiosConfig;
|
|
21
|
+
cacheStore;
|
|
22
|
+
previousCache;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
const {
|
|
25
|
+
axiosConfig = {},
|
|
26
|
+
...rest
|
|
27
|
+
} = options ?? {};
|
|
28
|
+
super({
|
|
29
|
+
...rest,
|
|
30
|
+
name: 'http-axios'
|
|
31
|
+
});
|
|
32
|
+
this.axiosConfig = axiosConfig;
|
|
33
|
+
this.cacheStore = new MemoryCache(isPlainObject(this.cache) ? this.cache : {});
|
|
34
|
+
}
|
|
35
|
+
getHttpClient() {
|
|
36
|
+
if (this.axiosInstance === undefined || this.previousAxiosConfig !== this.axiosConfig) {
|
|
37
|
+
const config = omit(['interceptors'], this.axiosConfig);
|
|
38
|
+
const {
|
|
39
|
+
interceptors
|
|
40
|
+
} = this.axiosConfig;
|
|
41
|
+
this.axiosInstance = axios.create({
|
|
42
|
+
timeout: this.timeout,
|
|
43
|
+
maxRedirects: this.redirects,
|
|
44
|
+
withCredentials: this.withCredentials,
|
|
45
|
+
responseType: 'arraybuffer',
|
|
46
|
+
...config
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// settings up request interceptors
|
|
50
|
+
if (Array.isArray(interceptors?.request)) {
|
|
51
|
+
interceptors.request.forEach(requestInterceptor => {
|
|
52
|
+
this.axiosInstance.interceptors.request.use(...ensureArray(requestInterceptor));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// settings up response interceptors
|
|
57
|
+
if (Array.isArray(interceptors?.response)) {
|
|
58
|
+
interceptors.response.forEach(responseInterceptor => {
|
|
59
|
+
this.axiosInstance.interceptors.response.use(...ensureArray(responseInterceptor));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
this.previousAxiosConfig = this.axiosConfig;
|
|
63
|
+
}
|
|
64
|
+
return this.axiosInstance;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Ensures cacheStore is config-isolated for cloned resolvers.
|
|
69
|
+
* When a resolver is cloned via Object.create (in readFile), the clone inherits
|
|
70
|
+
* cacheStore from the prototype. Object.create(cacheStore) creates a view that
|
|
71
|
+
* shares the underlying store Map but allows isolated config (maxEntries, maxStaleAge)
|
|
72
|
+
* via own properties set by Object.assign.
|
|
73
|
+
*/
|
|
74
|
+
getCacheStore() {
|
|
75
|
+
if (this.previousCache !== this.cache) {
|
|
76
|
+
if (!Object.hasOwn(this, 'cacheStore')) {
|
|
77
|
+
this.cacheStore = Object.create(this.cacheStore);
|
|
78
|
+
}
|
|
79
|
+
if (isPlainObject(this.cache)) {
|
|
80
|
+
Object.assign(this.cacheStore, this.cache);
|
|
81
|
+
}
|
|
82
|
+
this.previousCache = this.cache;
|
|
83
|
+
}
|
|
84
|
+
return this.cacheStore;
|
|
85
|
+
}
|
|
86
|
+
async read(file) {
|
|
87
|
+
const uri = url.stripHash(file.uri);
|
|
88
|
+
const cacheStore = this.cache ? this.getCacheStore() : undefined;
|
|
89
|
+
|
|
90
|
+
// return cached content if available
|
|
91
|
+
const cached = cacheStore?.get(uri);
|
|
92
|
+
if (cached !== undefined) return cached;
|
|
93
|
+
const client = this.getHttpClient();
|
|
94
|
+
try {
|
|
95
|
+
const response = await client.get(uri);
|
|
96
|
+
cacheStore?.set(uri, response.data);
|
|
97
|
+
return response.data;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
throw new ResolverError(`Error downloading "${file.uri}"`, {
|
|
100
|
+
cause: error
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export default HTTPResolverAxios;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { omit } from 'ramda';
|
|
2
|
+
import { ensureArray, isPlainObject } from 'ramda-adjunct';
|
|
3
|
+
import axios, { Axios, AxiosInstance, CreateAxiosDefaults } from 'axios';
|
|
4
|
+
|
|
5
|
+
import HTTPResolver, { HTTPResolverOptions } from '../HTTPResolver.ts';
|
|
6
|
+
import MemoryCache from './cache/MemoryCache.ts';
|
|
7
|
+
import File from '../../../File.ts';
|
|
8
|
+
import ResolverError from '../../../errors/ResolverError.ts';
|
|
9
|
+
import * as url from '../../../util/url.ts';
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
default as HTTPResolver,
|
|
13
|
+
HTTPResolverOptions,
|
|
14
|
+
CacheOptions,
|
|
15
|
+
} from '../HTTPResolver.ts';
|
|
16
|
+
export type { default as Resolver, ResolverOptions } from '../Resolver.ts';
|
|
17
|
+
export type { default as File, FileOptions } from '../../../File.ts';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export interface HTTPResolverAxiosConfig extends CreateAxiosDefaults {
|
|
23
|
+
interceptors?: Axios['interceptors'];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export interface HTTPResolverAxiosOptions extends Omit<HTTPResolverOptions, 'name'> {
|
|
30
|
+
readonly axiosConfig?: HTTPResolverAxiosConfig;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
class HTTPResolverAxios extends HTTPResolver {
|
|
37
|
+
public axiosConfig: HTTPResolverAxiosConfig = {};
|
|
38
|
+
|
|
39
|
+
protected axiosInstance!: AxiosInstance;
|
|
40
|
+
|
|
41
|
+
protected previousAxiosConfig!: HTTPResolverAxiosConfig;
|
|
42
|
+
|
|
43
|
+
protected cacheStore: MemoryCache<Buffer>;
|
|
44
|
+
|
|
45
|
+
protected previousCache!: typeof this.cache;
|
|
46
|
+
|
|
47
|
+
constructor(options?: HTTPResolverAxiosOptions) {
|
|
48
|
+
const { axiosConfig = {}, ...rest } = options ?? {};
|
|
49
|
+
|
|
50
|
+
super({ ...rest, name: 'http-axios' });
|
|
51
|
+
this.axiosConfig = axiosConfig;
|
|
52
|
+
this.cacheStore = new MemoryCache(isPlainObject(this.cache) ? this.cache : {});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getHttpClient(): AxiosInstance {
|
|
56
|
+
if (this.axiosInstance === undefined || this.previousAxiosConfig !== this.axiosConfig) {
|
|
57
|
+
const config = omit(['interceptors'], this.axiosConfig);
|
|
58
|
+
const { interceptors } = this.axiosConfig;
|
|
59
|
+
|
|
60
|
+
this.axiosInstance = axios.create({
|
|
61
|
+
timeout: this.timeout,
|
|
62
|
+
maxRedirects: this.redirects,
|
|
63
|
+
withCredentials: this.withCredentials,
|
|
64
|
+
responseType: 'arraybuffer',
|
|
65
|
+
...config,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// settings up request interceptors
|
|
69
|
+
if (Array.isArray(interceptors?.request)) {
|
|
70
|
+
interceptors.request.forEach((requestInterceptor) => {
|
|
71
|
+
this.axiosInstance.interceptors.request.use(...ensureArray(requestInterceptor));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// settings up response interceptors
|
|
76
|
+
if (Array.isArray(interceptors?.response)) {
|
|
77
|
+
interceptors.response.forEach((responseInterceptor: any) => {
|
|
78
|
+
this.axiosInstance.interceptors.response.use(...ensureArray(responseInterceptor));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.previousAxiosConfig = this.axiosConfig;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return this.axiosInstance;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Ensures cacheStore is config-isolated for cloned resolvers.
|
|
90
|
+
* When a resolver is cloned via Object.create (in readFile), the clone inherits
|
|
91
|
+
* cacheStore from the prototype. Object.create(cacheStore) creates a view that
|
|
92
|
+
* shares the underlying store Map but allows isolated config (maxEntries, maxStaleAge)
|
|
93
|
+
* via own properties set by Object.assign.
|
|
94
|
+
*/
|
|
95
|
+
protected getCacheStore(): MemoryCache<Buffer> {
|
|
96
|
+
if (this.previousCache !== this.cache) {
|
|
97
|
+
if (!Object.hasOwn(this, 'cacheStore')) {
|
|
98
|
+
this.cacheStore = Object.create(this.cacheStore) as MemoryCache<Buffer>;
|
|
99
|
+
}
|
|
100
|
+
if (isPlainObject(this.cache)) {
|
|
101
|
+
Object.assign(this.cacheStore, this.cache);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.previousCache = this.cache;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this.cacheStore;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async read(file: File): Promise<Buffer> {
|
|
111
|
+
const uri = url.stripHash(file.uri);
|
|
112
|
+
const cacheStore = this.cache ? this.getCacheStore() : undefined;
|
|
113
|
+
|
|
114
|
+
// return cached content if available
|
|
115
|
+
const cached = cacheStore?.get(uri);
|
|
116
|
+
if (cached !== undefined) return cached;
|
|
117
|
+
|
|
118
|
+
const client: AxiosInstance = this.getHttpClient();
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
const response = await client.get<Buffer>(uri);
|
|
122
|
+
cacheStore?.set(uri, response.data);
|
|
123
|
+
return response.data;
|
|
124
|
+
} catch (error: unknown) {
|
|
125
|
+
throw new ResolverError(`Error downloading "${file.uri}"`, { cause: error });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export default HTTPResolverAxios;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
class ResolveStrategy {
|
|
13
|
+
name;
|
|
14
|
+
constructor({
|
|
15
|
+
name
|
|
16
|
+
}) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
var _default = exports.default = ResolveStrategy;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import File from '../../File.ts';
|
|
2
|
+
import ReferenceSet from '../../ReferenceSet.ts';
|
|
3
|
+
import type { ReferenceOptions } from '../../options/index.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface ResolveStrategyOptions {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
abstract class ResolveStrategy {
|
|
16
|
+
public readonly name: string;
|
|
17
|
+
|
|
18
|
+
constructor({ name }: ResolveStrategyOptions) {
|
|
19
|
+
this.name = name;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
abstract canResolve(file: File, options: ReferenceOptions): boolean;
|
|
23
|
+
abstract resolve(file: File, options: ReferenceOptions): Promise<ReferenceSet>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ResolveStrategy;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _ResolveStrategy = _interopRequireDefault(require("../ResolveStrategy.cjs"));
|
|
7
|
+
var _ReferenceSet = _interopRequireDefault(require("../../../ReferenceSet.cjs"));
|
|
8
|
+
var _util = require("../../../options/util.cjs");
|
|
9
|
+
var _UnmatchedDereferenceStrategyError = _interopRequireDefault(require("../../../errors/UnmatchedDereferenceStrategyError.cjs"));
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class ApiDOMResolveStrategy extends _ResolveStrategy.default {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super({
|
|
20
|
+
...(options ?? {}),
|
|
21
|
+
name: 'apidom'
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
canResolve(file, options) {
|
|
25
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'apidom');
|
|
26
|
+
if (dereferenceStrategy === undefined) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return dereferenceStrategy.canDereference(file, options);
|
|
30
|
+
}
|
|
31
|
+
async resolve(file, options) {
|
|
32
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'apidom');
|
|
33
|
+
if (dereferenceStrategy === undefined) {
|
|
34
|
+
throw new _UnmatchedDereferenceStrategyError.default(`"apidom" resolve strategy requires "apidom" dereference strategy to be configured for file "${file.uri}"`);
|
|
35
|
+
}
|
|
36
|
+
const refSet = new _ReferenceSet.default();
|
|
37
|
+
const mergedOptions = (0, _util.merge)(options, {
|
|
38
|
+
resolve: {
|
|
39
|
+
internal: false
|
|
40
|
+
},
|
|
41
|
+
dereference: {
|
|
42
|
+
refSet
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
await dereferenceStrategy.dereference(file, mergedOptions);
|
|
46
|
+
return refSet;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
var _default = exports.default = ApiDOMResolveStrategy;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import ResolveStrategy from "../ResolveStrategy.mjs";
|
|
2
|
+
import ReferenceSet from "../../../ReferenceSet.mjs";
|
|
3
|
+
import { merge as mergeOptions } from "../../../options/util.mjs";
|
|
4
|
+
import UnmatchedDereferenceStrategyError from "../../../errors/UnmatchedDereferenceStrategyError.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class ApiDOMResolveStrategy extends ResolveStrategy {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super({
|
|
14
|
+
...(options ?? {}),
|
|
15
|
+
name: 'apidom'
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
canResolve(file, options) {
|
|
19
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'apidom');
|
|
20
|
+
if (dereferenceStrategy === undefined) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return dereferenceStrategy.canDereference(file, options);
|
|
24
|
+
}
|
|
25
|
+
async resolve(file, options) {
|
|
26
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'apidom');
|
|
27
|
+
if (dereferenceStrategy === undefined) {
|
|
28
|
+
throw new UnmatchedDereferenceStrategyError(`"apidom" resolve strategy requires "apidom" dereference strategy to be configured for file "${file.uri}"`);
|
|
29
|
+
}
|
|
30
|
+
const refSet = new ReferenceSet();
|
|
31
|
+
const mergedOptions = mergeOptions(options, {
|
|
32
|
+
resolve: {
|
|
33
|
+
internal: false
|
|
34
|
+
},
|
|
35
|
+
dereference: {
|
|
36
|
+
refSet
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
await dereferenceStrategy.dereference(file, mergedOptions);
|
|
40
|
+
return refSet;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export default ApiDOMResolveStrategy;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import ResolveStrategy, { ResolveStrategyOptions } from '../ResolveStrategy.ts';
|
|
2
|
+
import ReferenceSet from '../../../ReferenceSet.ts';
|
|
3
|
+
import File from '../../../File.ts';
|
|
4
|
+
import { merge as mergeOptions } from '../../../options/util.ts';
|
|
5
|
+
import UnmatchedDereferenceStrategyError from '../../../errors/UnmatchedDereferenceStrategyError.ts';
|
|
6
|
+
import type { ReferenceOptions } from '../../../options/index.ts';
|
|
7
|
+
|
|
8
|
+
export type { default as ResolveStrategy, ResolveStrategyOptions } from '../ResolveStrategy.ts';
|
|
9
|
+
export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
|
|
10
|
+
export type { default as File, FileOptions } from '../../../File.ts';
|
|
11
|
+
export type {
|
|
12
|
+
ReferenceOptions as ApiDOMReferenceOptions,
|
|
13
|
+
ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
|
|
14
|
+
ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
|
|
15
|
+
ReferenceParseOptions as ApiDOMReferenceParseOptions,
|
|
16
|
+
ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
|
|
17
|
+
} from '../../../options/index.ts';
|
|
18
|
+
export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
|
|
19
|
+
export type { default as Resolver, ResolverOptions } from '../../resolvers/Resolver.ts';
|
|
20
|
+
export type {
|
|
21
|
+
default as DereferenceStrategy,
|
|
22
|
+
DereferenceStrategyOptions,
|
|
23
|
+
} from '../../../dereference/strategies/DereferenceStrategy.ts';
|
|
24
|
+
export type {
|
|
25
|
+
default as BundleStrategy,
|
|
26
|
+
BundleStrategyOptions,
|
|
27
|
+
} from '../../../bundle/strategies/BundleStrategy.ts';
|
|
28
|
+
export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export interface ApiDOMResolveStrategyOptions extends Omit<ResolveStrategyOptions, 'name'> {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
class ApiDOMResolveStrategy extends ResolveStrategy {
|
|
39
|
+
constructor(options?: ApiDOMResolveStrategyOptions) {
|
|
40
|
+
super({ ...(options ?? {}), name: 'apidom' });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
canResolve(file: File, options: ReferenceOptions): boolean {
|
|
44
|
+
const dereferenceStrategy = options.dereference.strategies.find(
|
|
45
|
+
(strategy) => strategy.name === 'apidom',
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (dereferenceStrategy === undefined) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return dereferenceStrategy.canDereference(file, options);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async resolve(file: File, options: ReferenceOptions) {
|
|
56
|
+
const dereferenceStrategy = options.dereference.strategies.find(
|
|
57
|
+
(strategy) => strategy.name === 'apidom',
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if (dereferenceStrategy === undefined) {
|
|
61
|
+
throw new UnmatchedDereferenceStrategyError(
|
|
62
|
+
`"apidom" resolve strategy requires "apidom" dereference strategy to be configured for file "${file.uri}"`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const refSet = new ReferenceSet();
|
|
67
|
+
const mergedOptions = mergeOptions(options, {
|
|
68
|
+
resolve: { internal: false },
|
|
69
|
+
dereference: { refSet },
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await dereferenceStrategy.dereference(file, mergedOptions);
|
|
73
|
+
|
|
74
|
+
return refSet;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default ApiDOMResolveStrategy;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _ResolveStrategy = _interopRequireDefault(require("../ResolveStrategy.cjs"));
|
|
7
|
+
var _ReferenceSet = _interopRequireDefault(require("../../../ReferenceSet.cjs"));
|
|
8
|
+
var _util = require("../../../options/util.cjs");
|
|
9
|
+
var _UnmatchedDereferenceStrategyError = _interopRequireDefault(require("../../../errors/UnmatchedDereferenceStrategyError.cjs"));
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class AsyncAPI2ResolveStrategy extends _ResolveStrategy.default {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super({
|
|
20
|
+
...(options ?? {}),
|
|
21
|
+
name: 'asyncapi-2'
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
canResolve(file, options) {
|
|
25
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'asyncapi-2');
|
|
26
|
+
if (dereferenceStrategy === undefined) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return dereferenceStrategy.canDereference(file, options);
|
|
30
|
+
}
|
|
31
|
+
async resolve(file, options) {
|
|
32
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'asyncapi-2');
|
|
33
|
+
if (dereferenceStrategy === undefined) {
|
|
34
|
+
throw new _UnmatchedDereferenceStrategyError.default(`"asyncapi-2" resolve strategy requires "asyncapi-2" dereference strategy to be configured for file "${file.uri}"`);
|
|
35
|
+
}
|
|
36
|
+
const refSet = new _ReferenceSet.default();
|
|
37
|
+
const mergedOptions = (0, _util.merge)(options, {
|
|
38
|
+
resolve: {
|
|
39
|
+
internal: false
|
|
40
|
+
},
|
|
41
|
+
dereference: {
|
|
42
|
+
refSet
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
await dereferenceStrategy.dereference(file, mergedOptions);
|
|
46
|
+
return refSet;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
var _default = exports.default = AsyncAPI2ResolveStrategy;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import ResolveStrategy from "../ResolveStrategy.mjs";
|
|
2
|
+
import ReferenceSet from "../../../ReferenceSet.mjs";
|
|
3
|
+
import { merge as mergeOptions } from "../../../options/util.mjs";
|
|
4
|
+
import UnmatchedDereferenceStrategyError from "../../../errors/UnmatchedDereferenceStrategyError.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class AsyncAPI2ResolveStrategy extends ResolveStrategy {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super({
|
|
14
|
+
...(options ?? {}),
|
|
15
|
+
name: 'asyncapi-2'
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
canResolve(file, options) {
|
|
19
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'asyncapi-2');
|
|
20
|
+
if (dereferenceStrategy === undefined) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return dereferenceStrategy.canDereference(file, options);
|
|
24
|
+
}
|
|
25
|
+
async resolve(file, options) {
|
|
26
|
+
const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'asyncapi-2');
|
|
27
|
+
if (dereferenceStrategy === undefined) {
|
|
28
|
+
throw new UnmatchedDereferenceStrategyError(`"asyncapi-2" resolve strategy requires "asyncapi-2" dereference strategy to be configured for file "${file.uri}"`);
|
|
29
|
+
}
|
|
30
|
+
const refSet = new ReferenceSet();
|
|
31
|
+
const mergedOptions = mergeOptions(options, {
|
|
32
|
+
resolve: {
|
|
33
|
+
internal: false
|
|
34
|
+
},
|
|
35
|
+
dereference: {
|
|
36
|
+
refSet
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
await dereferenceStrategy.dereference(file, mergedOptions);
|
|
40
|
+
return refSet;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export default AsyncAPI2ResolveStrategy;
|