@speclynx/apidom-reference 4.0.2 → 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.
- package/CHANGELOG.md +12 -0
- package/dist/apidom-reference.browser.js +15 -15
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +25 -25
- package/src/File.cjs +50 -0
- package/src/File.mjs +44 -0
- package/src/Reference.cjs +31 -0
- package/src/Reference.mjs +27 -0
- package/src/ReferenceSet.cjs +60 -0
- package/src/ReferenceSet.mjs +57 -0
- package/src/bundle/index.cjs +61 -0
- package/src/bundle/index.mjs +55 -0
- package/src/bundle/strategies/BundleStrategy.cjs +20 -0
- package/src/bundle/strategies/BundleStrategy.mjs +16 -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/configuration/empty.cjs +9 -0
- package/src/configuration/empty.mjs +1 -0
- package/src/configuration/saturated.cjs +88 -0
- package/src/configuration/saturated.mjs +80 -0
- package/src/dereference/index.cjs +90 -0
- package/src/dereference/index.mjs +83 -0
- package/src/dereference/strategies/DereferenceStrategy.cjs +20 -0
- package/src/dereference/strategies/DereferenceStrategy.mjs +16 -0
- package/src/dereference/strategies/apidom/index.cjs +89 -0
- package/src/dereference/strategies/apidom/index.mjs +83 -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/visitor.cjs +266 -0
- package/src/dereference/strategies/apidom/visitor.mjs +259 -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/selectors/$anchor.cjs +12 -0
- package/src/dereference/strategies/arazzo-1/selectors/$anchor.mjs +1 -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/source-descriptions.cjs +248 -0
- package/src/dereference/strategies/arazzo-1/source-descriptions.mjs +243 -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/visitor.cjs +507 -0
- package/src/dereference/strategies/arazzo-1/visitor.mjs +500 -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/visitor.cjs +501 -0
- package/src/dereference/strategies/asyncapi-2/visitor.mjs +494 -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/visitor.cjs +629 -0
- package/src/dereference/strategies/openapi-2/visitor.mjs +622 -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/visitor.cjs +622 -0
- package/src/dereference/strategies/openapi-3-0/visitor.mjs +615 -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/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/uri.cjs +50 -0
- package/src/dereference/strategies/openapi-3-1/selectors/uri.mjs +42 -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/visitor.cjs +874 -0
- package/src/dereference/strategies/openapi-3-1/visitor.mjs +867 -0
- package/src/dereference/util.cjs +31 -0
- package/src/dereference/util.mjs +27 -0
- package/src/errors/BundleError.cjs +10 -0
- package/src/errors/BundleError.mjs +7 -0
- package/src/errors/DereferenceError.cjs +10 -0
- package/src/errors/DereferenceError.mjs +7 -0
- package/src/errors/EvaluationElementIdError.cjs +10 -0
- package/src/errors/EvaluationElementIdError.mjs +7 -0
- package/src/errors/EvaluationJsonSchema$anchorError.cjs +11 -0
- package/src/errors/EvaluationJsonSchema$anchorError.mjs +6 -0
- package/src/errors/EvaluationJsonSchemaUriError.cjs +11 -0
- package/src/errors/EvaluationJsonSchemaUriError.mjs +6 -0
- package/src/errors/InvalidJsonSchema$anchorError.cjs +15 -0
- package/src/errors/InvalidJsonSchema$anchorError.mjs +10 -0
- package/src/errors/JsonSchema$anchorError.cjs +10 -0
- package/src/errors/JsonSchema$anchorError.mjs +7 -0
- package/src/errors/JsonSchemaUriError.cjs +10 -0
- package/src/errors/JsonSchemaUriError.mjs +7 -0
- package/src/errors/MaximumBundleDepthError.cjs +11 -0
- package/src/errors/MaximumBundleDepthError.mjs +6 -0
- package/src/errors/MaximumDereferenceDepthError.cjs +11 -0
- package/src/errors/MaximumDereferenceDepthError.mjs +6 -0
- package/src/errors/MaximumResolveDepthError.cjs +11 -0
- package/src/errors/MaximumResolveDepthError.mjs +6 -0
- package/src/errors/ParseError.cjs +10 -0
- package/src/errors/ParseError.mjs +7 -0
- package/src/errors/ParserError.cjs +11 -0
- package/src/errors/ParserError.mjs +6 -0
- package/src/errors/PluginError.cjs +18 -0
- package/src/errors/PluginError.mjs +15 -0
- package/src/errors/ResolveError.cjs +10 -0
- package/src/errors/ResolveError.mjs +7 -0
- package/src/errors/ResolverError.cjs +11 -0
- package/src/errors/ResolverError.mjs +6 -0
- package/src/errors/UnmatchedBundleStrategyError.cjs +11 -0
- package/src/errors/UnmatchedBundleStrategyError.mjs +6 -0
- package/src/errors/UnmatchedDereferenceStrategyError.cjs +11 -0
- package/src/errors/UnmatchedDereferenceStrategyError.mjs +6 -0
- package/src/errors/UnmatchedParserError.cjs +11 -0
- package/src/errors/UnmatchedParserError.mjs +6 -0
- package/src/errors/UnmatchedResolveStrategyError.cjs +11 -0
- package/src/errors/UnmatchedResolveStrategyError.mjs +6 -0
- package/src/errors/UnmatchedResolverError.cjs +11 -0
- package/src/errors/UnmatchedResolverError.mjs +6 -0
- package/src/errors/UnresolvableReferenceError.cjs +11 -0
- package/src/errors/UnresolvableReferenceError.mjs +6 -0
- package/src/index.cjs +146 -0
- package/src/index.mjs +103 -0
- package/src/options/index.cjs +194 -0
- package/src/options/index.mjs +191 -0
- package/src/options/util.cjs +24 -0
- package/src/options/util.mjs +19 -0
- package/src/parse/index.cjs +69 -0
- package/src/parse/index.mjs +63 -0
- package/src/parse/parsers/Parser.cjs +62 -0
- package/src/parse/parsers/Parser.mjs +58 -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/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/source-descriptions.cjs +221 -0
- package/src/parse/parsers/arazzo-json-1/source-descriptions.mjs +214 -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/source-descriptions.cjs +12 -0
- package/src/parse/parsers/arazzo-yaml-1/source-descriptions.mjs +7 -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-yaml-2/index.cjs +54 -0
- package/src/parse/parsers/asyncapi-yaml-2/index.mjs +48 -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-node.cjs +51 -0
- package/src/parse/parsers/binary/index-node.mjs +45 -0
- package/src/parse/parsers/json/index.cjs +53 -0
- package/src/parse/parsers/json/index.mjs +47 -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-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-1/index.cjs +54 -0
- package/src/parse/parsers/openapi-json-3-1/index.mjs +48 -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-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-1/index.cjs +54 -0
- package/src/parse/parsers/openapi-yaml-3-1/index.mjs +48 -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/resolve/index.cjs +67 -0
- package/src/resolve/index.mjs +60 -0
- package/src/resolve/resolvers/HTTPResolver.cjs +45 -0
- package/src/resolve/resolvers/HTTPResolver.mjs +37 -0
- package/src/resolve/resolvers/Resolver.cjs +20 -0
- package/src/resolve/resolvers/Resolver.mjs +16 -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-node.cjs +49 -0
- package/src/resolve/resolvers/file/index-node.mjs +42 -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/index.cjs +113 -0
- package/src/resolve/resolvers/http-axios/index.mjs +105 -0
- package/src/resolve/strategies/ResolveStrategy.cjs +20 -0
- package/src/resolve/strategies/ResolveStrategy.mjs +16 -0
- package/src/resolve/strategies/apidom/index.cjs +49 -0
- package/src/resolve/strategies/apidom/index.mjs +43 -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/openapi-2/index.cjs +49 -0
- package/src/resolve/strategies/openapi-2/index.mjs +43 -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-1/index.cjs +49 -0
- package/src/resolve/strategies/openapi-3-1/index.mjs +43 -0
- package/src/resolve/util.cjs +37 -0
- package/src/resolve/util.mjs +30 -0
- package/src/util/plugins.cjs +39 -0
- package/src/util/plugins.mjs +34 -0
- package/src/util/url.cjs +288 -0
- package/src/util/url.mjs +274 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-reference",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Advanced algorithms for semantic ApiDOM manipulations like dereferencing or resolution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apidom",
|
|
@@ -254,29 +254,29 @@
|
|
|
254
254
|
"license": "Apache-2.0",
|
|
255
255
|
"dependencies": {
|
|
256
256
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
257
|
-
"@speclynx/apidom-core": "4.0.
|
|
258
|
-
"@speclynx/apidom-datamodel": "4.0.
|
|
259
|
-
"@speclynx/apidom-error": "4.0.
|
|
260
|
-
"@speclynx/apidom-json-pointer": "4.0.
|
|
261
|
-
"@speclynx/apidom-ns-arazzo-1": "4.0.
|
|
262
|
-
"@speclynx/apidom-ns-asyncapi-2": "4.0.
|
|
263
|
-
"@speclynx/apidom-ns-json-schema-2020-12": "4.0.
|
|
264
|
-
"@speclynx/apidom-ns-openapi-2": "4.0.
|
|
265
|
-
"@speclynx/apidom-ns-openapi-3-0": "4.0.
|
|
266
|
-
"@speclynx/apidom-ns-openapi-3-1": "4.0.
|
|
267
|
-
"@speclynx/apidom-parser-adapter-arazzo-json-1": "4.0.
|
|
268
|
-
"@speclynx/apidom-parser-adapter-arazzo-yaml-1": "4.0.
|
|
269
|
-
"@speclynx/apidom-parser-adapter-asyncapi-json-2": "4.0.
|
|
270
|
-
"@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "4.0.
|
|
271
|
-
"@speclynx/apidom-parser-adapter-json": "4.0.
|
|
272
|
-
"@speclynx/apidom-parser-adapter-openapi-json-2": "4.0.
|
|
273
|
-
"@speclynx/apidom-parser-adapter-openapi-json-3-0": "4.0.
|
|
274
|
-
"@speclynx/apidom-parser-adapter-openapi-json-3-1": "4.0.
|
|
275
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-2": "4.0.
|
|
276
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "4.0.
|
|
277
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "4.0.
|
|
278
|
-
"@speclynx/apidom-parser-adapter-yaml-1-2": "4.0.
|
|
279
|
-
"@speclynx/apidom-traverse": "4.0.
|
|
257
|
+
"@speclynx/apidom-core": "4.0.4",
|
|
258
|
+
"@speclynx/apidom-datamodel": "4.0.4",
|
|
259
|
+
"@speclynx/apidom-error": "4.0.4",
|
|
260
|
+
"@speclynx/apidom-json-pointer": "4.0.4",
|
|
261
|
+
"@speclynx/apidom-ns-arazzo-1": "4.0.4",
|
|
262
|
+
"@speclynx/apidom-ns-asyncapi-2": "4.0.4",
|
|
263
|
+
"@speclynx/apidom-ns-json-schema-2020-12": "4.0.4",
|
|
264
|
+
"@speclynx/apidom-ns-openapi-2": "4.0.4",
|
|
265
|
+
"@speclynx/apidom-ns-openapi-3-0": "4.0.4",
|
|
266
|
+
"@speclynx/apidom-ns-openapi-3-1": "4.0.4",
|
|
267
|
+
"@speclynx/apidom-parser-adapter-arazzo-json-1": "4.0.4",
|
|
268
|
+
"@speclynx/apidom-parser-adapter-arazzo-yaml-1": "4.0.4",
|
|
269
|
+
"@speclynx/apidom-parser-adapter-asyncapi-json-2": "4.0.4",
|
|
270
|
+
"@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "4.0.4",
|
|
271
|
+
"@speclynx/apidom-parser-adapter-json": "4.0.4",
|
|
272
|
+
"@speclynx/apidom-parser-adapter-openapi-json-2": "4.0.4",
|
|
273
|
+
"@speclynx/apidom-parser-adapter-openapi-json-3-0": "4.0.4",
|
|
274
|
+
"@speclynx/apidom-parser-adapter-openapi-json-3-1": "4.0.4",
|
|
275
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-2": "4.0.4",
|
|
276
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "4.0.4",
|
|
277
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "4.0.4",
|
|
278
|
+
"@speclynx/apidom-parser-adapter-yaml-1-2": "4.0.4",
|
|
279
|
+
"@speclynx/apidom-traverse": "4.0.4",
|
|
280
280
|
"@swaggerexpert/arazzo-runtime-expression": "^2.0.3",
|
|
281
281
|
"axios": "^1.13.5",
|
|
282
282
|
"picomatch": "^4.0.3",
|
|
@@ -298,5 +298,5 @@
|
|
|
298
298
|
"README.md",
|
|
299
299
|
"CHANGELOG.md"
|
|
300
300
|
],
|
|
301
|
-
"gitHead": "
|
|
301
|
+
"gitHead": "a06f6ef3d37ad5bf860cbbf4b442bfbe3a522cc2"
|
|
302
302
|
}
|
package/src/File.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _ramda = require("ramda");
|
|
7
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
8
|
+
var url = _interopRequireWildcard(require("./util/url.cjs"));
|
|
9
|
+
/**
|
|
10
|
+
* This class represents a File object with url and data.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class File {
|
|
18
|
+
uri;
|
|
19
|
+
mediaType;
|
|
20
|
+
data;
|
|
21
|
+
parseResult;
|
|
22
|
+
constructor({
|
|
23
|
+
uri,
|
|
24
|
+
mediaType = 'text/plain',
|
|
25
|
+
data,
|
|
26
|
+
parseResult
|
|
27
|
+
}) {
|
|
28
|
+
this.uri = uri;
|
|
29
|
+
this.mediaType = mediaType;
|
|
30
|
+
this.data = data;
|
|
31
|
+
this.parseResult = parseResult;
|
|
32
|
+
}
|
|
33
|
+
get extension() {
|
|
34
|
+
if ((0, _ramdaAdjunct.isString)(this.uri)) {
|
|
35
|
+
return url.getExtension(this.uri);
|
|
36
|
+
}
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
toString() {
|
|
40
|
+
if (typeof this.data === 'string') {
|
|
41
|
+
return this.data;
|
|
42
|
+
}
|
|
43
|
+
if (this.data instanceof ArrayBuffer || ['ArrayBuffer'].includes((0, _ramda.type)(this.data)) || ArrayBuffer.isView(this.data)) {
|
|
44
|
+
const textDecoder = new TextDecoder('utf-8');
|
|
45
|
+
return textDecoder.decode(this.data);
|
|
46
|
+
}
|
|
47
|
+
return String(this.data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var _default = exports.default = File;
|
package/src/File.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type } from 'ramda';
|
|
2
|
+
import { isString } from 'ramda-adjunct';
|
|
3
|
+
import * as url from "./util/url.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* This class represents a File object with url and data.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class File {
|
|
12
|
+
uri;
|
|
13
|
+
mediaType;
|
|
14
|
+
data;
|
|
15
|
+
parseResult;
|
|
16
|
+
constructor({
|
|
17
|
+
uri,
|
|
18
|
+
mediaType = 'text/plain',
|
|
19
|
+
data,
|
|
20
|
+
parseResult
|
|
21
|
+
}) {
|
|
22
|
+
this.uri = uri;
|
|
23
|
+
this.mediaType = mediaType;
|
|
24
|
+
this.data = data;
|
|
25
|
+
this.parseResult = parseResult;
|
|
26
|
+
}
|
|
27
|
+
get extension() {
|
|
28
|
+
if (isString(this.uri)) {
|
|
29
|
+
return url.getExtension(this.uri);
|
|
30
|
+
}
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
toString() {
|
|
34
|
+
if (typeof this.data === 'string') {
|
|
35
|
+
return this.data;
|
|
36
|
+
}
|
|
37
|
+
if (this.data instanceof ArrayBuffer || ['ArrayBuffer'].includes(type(this.data)) || ArrayBuffer.isView(this.data)) {
|
|
38
|
+
const textDecoder = new TextDecoder('utf-8');
|
|
39
|
+
return textDecoder.decode(this.data);
|
|
40
|
+
}
|
|
41
|
+
return String(this.data);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export default File;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
class Reference {
|
|
13
|
+
uri;
|
|
14
|
+
depth;
|
|
15
|
+
value;
|
|
16
|
+
refSet;
|
|
17
|
+
errors;
|
|
18
|
+
constructor({
|
|
19
|
+
uri,
|
|
20
|
+
depth = 0,
|
|
21
|
+
refSet,
|
|
22
|
+
value
|
|
23
|
+
}) {
|
|
24
|
+
this.uri = uri;
|
|
25
|
+
this.value = value;
|
|
26
|
+
this.depth = depth;
|
|
27
|
+
this.refSet = refSet;
|
|
28
|
+
this.errors = [];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var _default = exports.default = Reference;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
class Reference {
|
|
9
|
+
uri;
|
|
10
|
+
depth;
|
|
11
|
+
value;
|
|
12
|
+
refSet;
|
|
13
|
+
errors;
|
|
14
|
+
constructor({
|
|
15
|
+
uri,
|
|
16
|
+
depth = 0,
|
|
17
|
+
refSet,
|
|
18
|
+
value
|
|
19
|
+
}) {
|
|
20
|
+
this.uri = uri;
|
|
21
|
+
this.value = value;
|
|
22
|
+
this.depth = depth;
|
|
23
|
+
this.refSet = refSet;
|
|
24
|
+
this.errors = [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default Reference;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class ReferenceSet {
|
|
14
|
+
rootRef;
|
|
15
|
+
refs;
|
|
16
|
+
circular;
|
|
17
|
+
constructor({
|
|
18
|
+
refs = [],
|
|
19
|
+
circular = false
|
|
20
|
+
} = {}) {
|
|
21
|
+
this.refs = [];
|
|
22
|
+
this.circular = circular;
|
|
23
|
+
refs.forEach(this.add.bind(this));
|
|
24
|
+
}
|
|
25
|
+
get size() {
|
|
26
|
+
return this.refs.length;
|
|
27
|
+
}
|
|
28
|
+
add(reference) {
|
|
29
|
+
if (!this.has(reference)) {
|
|
30
|
+
this.refs.push(reference);
|
|
31
|
+
this.rootRef = this.rootRef === undefined ? reference : this.rootRef;
|
|
32
|
+
reference.refSet = this;
|
|
33
|
+
}
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
merge(anotherRefSet) {
|
|
37
|
+
for (const reference of anotherRefSet.values()) {
|
|
38
|
+
this.add(reference);
|
|
39
|
+
}
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
has(thing) {
|
|
43
|
+
const uri = (0, _ramdaAdjunct.isString)(thing) ? thing : thing.uri;
|
|
44
|
+
return (0, _ramdaAdjunct.isNotUndefined)(this.find(ref => ref.uri === uri));
|
|
45
|
+
}
|
|
46
|
+
find(predicate) {
|
|
47
|
+
return this.refs.find(predicate);
|
|
48
|
+
}
|
|
49
|
+
*values() {
|
|
50
|
+
yield* this.refs;
|
|
51
|
+
}
|
|
52
|
+
clean() {
|
|
53
|
+
this.refs.forEach(ref => {
|
|
54
|
+
ref.refSet = undefined;
|
|
55
|
+
});
|
|
56
|
+
this.rootRef = undefined;
|
|
57
|
+
this.refs.length = 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
var _default = exports.default = ReferenceSet;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isNotUndefined, isString } from 'ramda-adjunct';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class ReferenceSet {
|
|
11
|
+
rootRef;
|
|
12
|
+
refs;
|
|
13
|
+
circular;
|
|
14
|
+
constructor({
|
|
15
|
+
refs = [],
|
|
16
|
+
circular = false
|
|
17
|
+
} = {}) {
|
|
18
|
+
this.refs = [];
|
|
19
|
+
this.circular = circular;
|
|
20
|
+
refs.forEach(this.add.bind(this));
|
|
21
|
+
}
|
|
22
|
+
get size() {
|
|
23
|
+
return this.refs.length;
|
|
24
|
+
}
|
|
25
|
+
add(reference) {
|
|
26
|
+
if (!this.has(reference)) {
|
|
27
|
+
this.refs.push(reference);
|
|
28
|
+
this.rootRef = this.rootRef === undefined ? reference : this.rootRef;
|
|
29
|
+
reference.refSet = this;
|
|
30
|
+
}
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
merge(anotherRefSet) {
|
|
34
|
+
for (const reference of anotherRefSet.values()) {
|
|
35
|
+
this.add(reference);
|
|
36
|
+
}
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
has(thing) {
|
|
40
|
+
const uri = isString(thing) ? thing : thing.uri;
|
|
41
|
+
return isNotUndefined(this.find(ref => ref.uri === uri));
|
|
42
|
+
}
|
|
43
|
+
find(predicate) {
|
|
44
|
+
return this.refs.find(predicate);
|
|
45
|
+
}
|
|
46
|
+
*values() {
|
|
47
|
+
yield* this.refs;
|
|
48
|
+
}
|
|
49
|
+
clean() {
|
|
50
|
+
this.refs.forEach(ref => {
|
|
51
|
+
ref.refSet = undefined;
|
|
52
|
+
});
|
|
53
|
+
this.rootRef = undefined;
|
|
54
|
+
this.refs.length = 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export default ReferenceSet;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 _File = _interopRequireDefault(require("../File.cjs"));
|
|
9
|
+
var plugins = _interopRequireWildcard(require("../util/plugins.cjs"));
|
|
10
|
+
var _UnmatchedBundleStrategyError = _interopRequireDefault(require("../errors/UnmatchedBundleStrategyError.cjs"));
|
|
11
|
+
var _BundleError = _interopRequireDefault(require("../errors/BundleError.cjs"));
|
|
12
|
+
var _index = _interopRequireDefault(require("../parse/index.cjs"));
|
|
13
|
+
var _util = require("../options/util.cjs");
|
|
14
|
+
var url = _interopRequireWildcard(require("../util/url.cjs"));
|
|
15
|
+
/**
|
|
16
|
+
* Bundle a file with all its external references to a compound document.
|
|
17
|
+
*/
|
|
18
|
+
const bundle = async (uri, options) => {
|
|
19
|
+
const {
|
|
20
|
+
refSet
|
|
21
|
+
} = options.bundle;
|
|
22
|
+
const sanitizedURI = url.sanitize(uri);
|
|
23
|
+
const mergedOptions = (0, _util.merge)(options, {
|
|
24
|
+
resolve: {
|
|
25
|
+
baseURI: sanitizedURI
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
let parseResult;
|
|
29
|
+
|
|
30
|
+
// if refSet was provided, use it to avoid unnecessary parsing
|
|
31
|
+
if (refSet !== null && refSet.has(sanitizedURI)) {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
({
|
|
34
|
+
value: parseResult
|
|
35
|
+
} = refSet.find((0, _ramda.propEq)(sanitizedURI, 'uri')));
|
|
36
|
+
} else {
|
|
37
|
+
parseResult = await (0, _index.default)(uri, mergedOptions);
|
|
38
|
+
}
|
|
39
|
+
const file = new _File.default({
|
|
40
|
+
uri: mergedOptions.resolve.baseURI,
|
|
41
|
+
parseResult,
|
|
42
|
+
mediaType: mergedOptions.parse.mediaType
|
|
43
|
+
});
|
|
44
|
+
const bundleStrategies = await plugins.filter('canBundle', [file, mergedOptions], mergedOptions.bundle.strategies);
|
|
45
|
+
|
|
46
|
+
// we couldn't find any bundle strategy for this File
|
|
47
|
+
if ((0, _ramda.isEmpty)(bundleStrategies)) {
|
|
48
|
+
throw new _UnmatchedBundleStrategyError.default(`Could not find a bundle strategy that can bundle the file "${file.uri}"`);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const {
|
|
52
|
+
result
|
|
53
|
+
} = await plugins.run('bundle', [file, mergedOptions], bundleStrategies);
|
|
54
|
+
return result;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new _BundleError.default(`Error while bundling file "${file.uri}"`, {
|
|
57
|
+
cause: error
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var _default = exports.default = bundle;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isEmpty, propEq } from 'ramda';
|
|
2
|
+
import File from "../File.mjs";
|
|
3
|
+
import * as plugins from "../util/plugins.mjs";
|
|
4
|
+
import UnmatchedBundleStrategyError from "../errors/UnmatchedBundleStrategyError.mjs";
|
|
5
|
+
import BundleError from "../errors/BundleError.mjs";
|
|
6
|
+
import parse from "../parse/index.mjs";
|
|
7
|
+
import { merge as mergeOptions } from "../options/util.mjs";
|
|
8
|
+
import * as url from "../util/url.mjs";
|
|
9
|
+
/**
|
|
10
|
+
* Bundle a file with all its external references to a compound document.
|
|
11
|
+
*/
|
|
12
|
+
const bundle = async (uri, options) => {
|
|
13
|
+
const {
|
|
14
|
+
refSet
|
|
15
|
+
} = options.bundle;
|
|
16
|
+
const sanitizedURI = url.sanitize(uri);
|
|
17
|
+
const mergedOptions = mergeOptions(options, {
|
|
18
|
+
resolve: {
|
|
19
|
+
baseURI: sanitizedURI
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
let parseResult;
|
|
23
|
+
|
|
24
|
+
// if refSet was provided, use it to avoid unnecessary parsing
|
|
25
|
+
if (refSet !== null && refSet.has(sanitizedURI)) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
({
|
|
28
|
+
value: parseResult
|
|
29
|
+
} = refSet.find(propEq(sanitizedURI, 'uri')));
|
|
30
|
+
} else {
|
|
31
|
+
parseResult = await parse(uri, mergedOptions);
|
|
32
|
+
}
|
|
33
|
+
const file = new File({
|
|
34
|
+
uri: mergedOptions.resolve.baseURI,
|
|
35
|
+
parseResult,
|
|
36
|
+
mediaType: mergedOptions.parse.mediaType
|
|
37
|
+
});
|
|
38
|
+
const bundleStrategies = await plugins.filter('canBundle', [file, mergedOptions], mergedOptions.bundle.strategies);
|
|
39
|
+
|
|
40
|
+
// we couldn't find any bundle strategy for this File
|
|
41
|
+
if (isEmpty(bundleStrategies)) {
|
|
42
|
+
throw new UnmatchedBundleStrategyError(`Could not find a bundle strategy that can bundle the file "${file.uri}"`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const {
|
|
46
|
+
result
|
|
47
|
+
} = await plugins.run('bundle', [file, mergedOptions], bundleStrategies);
|
|
48
|
+
return result;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
throw new BundleError(`Error while bundling file "${file.uri}"`, {
|
|
51
|
+
cause: error
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export default bundle;
|
|
@@ -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 BundleStrategy {
|
|
13
|
+
name;
|
|
14
|
+
constructor({
|
|
15
|
+
name
|
|
16
|
+
}) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
var _default = exports.default = BundleStrategy;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 _apidomNsOpenapi = require("@speclynx/apidom-ns-openapi-3-1");
|
|
7
|
+
var _BundleStrategy = _interopRequireDefault(require("../BundleStrategy.cjs"));
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class OpenAPI3_1BundleStrategy extends _BundleStrategy.default {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super({
|
|
18
|
+
...(options ?? {}),
|
|
19
|
+
name: 'openapi-3-1'
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
canBundle(file) {
|
|
23
|
+
// assert by media type
|
|
24
|
+
if (file.mediaType !== 'text/plain') {
|
|
25
|
+
return _apidomNsOpenapi.mediaTypes.includes(file.mediaType);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// assert by inspecting ApiDOM
|
|
29
|
+
return (0, _apidomNsOpenapi.isOpenApi3_1Element)(file.parseResult?.result);
|
|
30
|
+
}
|
|
31
|
+
async bundle(file) {
|
|
32
|
+
return file.parseResult;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var _default = exports.default = OpenAPI3_1BundleStrategy;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { mediaTypes, isOpenApi3_1Element } from '@speclynx/apidom-ns-openapi-3-1';
|
|
2
|
+
import BundleStrategy from "../BundleStrategy.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
class OpenAPI3_1BundleStrategy extends BundleStrategy {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super({
|
|
12
|
+
...(options ?? {}),
|
|
13
|
+
name: 'openapi-3-1'
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
canBundle(file) {
|
|
17
|
+
// assert by media type
|
|
18
|
+
if (file.mediaType !== 'text/plain') {
|
|
19
|
+
return mediaTypes.includes(file.mediaType);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// assert by inspecting ApiDOM
|
|
23
|
+
return isOpenApi3_1Element(file.parseResult?.result);
|
|
24
|
+
}
|
|
25
|
+
async bundle(file) {
|
|
26
|
+
return file.parseResult;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default OpenAPI3_1BundleStrategy;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var _index = require("../index.cjs");
|
|
5
|
+
Object.keys(_index).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
8
|
+
exports[key] = _index[key];
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../index.mjs";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
var _indexNode = _interopRequireDefault(require("../resolve/resolvers/file/index-node.cjs"));
|
|
6
|
+
var _index = _interopRequireDefault(require("../resolve/resolvers/http-axios/index.cjs"));
|
|
7
|
+
var _index2 = _interopRequireDefault(require("../resolve/strategies/openapi-2/index.cjs"));
|
|
8
|
+
var _index3 = _interopRequireDefault(require("../resolve/strategies/openapi-3-0/index.cjs"));
|
|
9
|
+
var _index4 = _interopRequireDefault(require("../resolve/strategies/openapi-3-1/index.cjs"));
|
|
10
|
+
var _index5 = _interopRequireDefault(require("../resolve/strategies/asyncapi-2/index.cjs"));
|
|
11
|
+
var _index6 = _interopRequireDefault(require("../resolve/strategies/apidom/index.cjs"));
|
|
12
|
+
var _index7 = _interopRequireDefault(require("../parse/parsers/openapi-json-2/index.cjs"));
|
|
13
|
+
var _index8 = _interopRequireDefault(require("../parse/parsers/openapi-yaml-2/index.cjs"));
|
|
14
|
+
var _index9 = _interopRequireDefault(require("../parse/parsers/openapi-json-3-0/index.cjs"));
|
|
15
|
+
var _index0 = _interopRequireDefault(require("../parse/parsers/openapi-yaml-3-0/index.cjs"));
|
|
16
|
+
var _index1 = _interopRequireDefault(require("../parse/parsers/openapi-json-3-1/index.cjs"));
|
|
17
|
+
var _index10 = _interopRequireDefault(require("../parse/parsers/openapi-yaml-3-1/index.cjs"));
|
|
18
|
+
var _index11 = _interopRequireDefault(require("../parse/parsers/asyncapi-json-2/index.cjs"));
|
|
19
|
+
var _index12 = _interopRequireDefault(require("../parse/parsers/asyncapi-yaml-2/index.cjs"));
|
|
20
|
+
var _index13 = _interopRequireDefault(require("../parse/parsers/arazzo-json-1/index.cjs"));
|
|
21
|
+
var _index14 = _interopRequireDefault(require("../parse/parsers/arazzo-yaml-1/index.cjs"));
|
|
22
|
+
var _index15 = _interopRequireDefault(require("../parse/parsers/apidom-json/index.cjs"));
|
|
23
|
+
var _index16 = _interopRequireDefault(require("../parse/parsers/json/index.cjs"));
|
|
24
|
+
var _index17 = _interopRequireDefault(require("../parse/parsers/yaml-1-2/index.cjs"));
|
|
25
|
+
var _indexNode2 = _interopRequireDefault(require("../parse/parsers/binary/index-node.cjs"));
|
|
26
|
+
var _index18 = _interopRequireDefault(require("../dereference/strategies/apidom/index.cjs"));
|
|
27
|
+
var _index19 = _interopRequireDefault(require("../dereference/strategies/openapi-2/index.cjs"));
|
|
28
|
+
var _index20 = _interopRequireDefault(require("../dereference/strategies/openapi-3-0/index.cjs"));
|
|
29
|
+
var _index21 = _interopRequireDefault(require("../dereference/strategies/openapi-3-1/index.cjs"));
|
|
30
|
+
var _index22 = _interopRequireDefault(require("../dereference/strategies/asyncapi-2/index.cjs"));
|
|
31
|
+
var _index23 = _interopRequireDefault(require("../dereference/strategies/arazzo-1/index.cjs"));
|
|
32
|
+
var _index24 = _interopRequireDefault(require("../bundle/strategies/openapi-3-1/index.cjs"));
|
|
33
|
+
var _index25 = require("../index.cjs");
|
|
34
|
+
Object.keys(_index25).forEach(function (key) {
|
|
35
|
+
if (key === "default" || key === "__esModule") return;
|
|
36
|
+
if (key in exports && exports[key] === _index25[key]) return;
|
|
37
|
+
exports[key] = _index25[key];
|
|
38
|
+
});
|
|
39
|
+
_index25.options.parse.parsers = [new _index7.default({
|
|
40
|
+
allowEmpty: true,
|
|
41
|
+
sourceMap: false
|
|
42
|
+
}), new _index8.default({
|
|
43
|
+
allowEmpty: true,
|
|
44
|
+
sourceMap: false
|
|
45
|
+
}), new _index9.default({
|
|
46
|
+
allowEmpty: true,
|
|
47
|
+
sourceMap: false
|
|
48
|
+
}), new _index0.default({
|
|
49
|
+
allowEmpty: true,
|
|
50
|
+
sourceMap: false
|
|
51
|
+
}), new _index1.default({
|
|
52
|
+
allowEmpty: true,
|
|
53
|
+
sourceMap: false
|
|
54
|
+
}), new _index10.default({
|
|
55
|
+
allowEmpty: true,
|
|
56
|
+
sourceMap: false
|
|
57
|
+
}), new _index11.default({
|
|
58
|
+
allowEmpty: true,
|
|
59
|
+
sourceMap: false
|
|
60
|
+
}), new _index12.default({
|
|
61
|
+
allowEmpty: true,
|
|
62
|
+
sourceMap: false
|
|
63
|
+
}), new _index13.default({
|
|
64
|
+
allowEmpty: true,
|
|
65
|
+
sourceMap: false
|
|
66
|
+
}), new _index14.default({
|
|
67
|
+
allowEmpty: true,
|
|
68
|
+
sourceMap: false
|
|
69
|
+
}), new _index15.default({
|
|
70
|
+
allowEmpty: true,
|
|
71
|
+
sourceMap: false
|
|
72
|
+
}), new _index16.default({
|
|
73
|
+
allowEmpty: true,
|
|
74
|
+
sourceMap: false
|
|
75
|
+
}), new _index17.default({
|
|
76
|
+
allowEmpty: true,
|
|
77
|
+
sourceMap: false
|
|
78
|
+
}), new _indexNode2.default({
|
|
79
|
+
allowEmpty: true
|
|
80
|
+
})];
|
|
81
|
+
_index25.options.resolve.resolvers = [new _indexNode.default(), new _index.default({
|
|
82
|
+
timeout: 5000,
|
|
83
|
+
redirects: 5,
|
|
84
|
+
withCredentials: false
|
|
85
|
+
})];
|
|
86
|
+
_index25.options.resolve.strategies = [new _index2.default(), new _index3.default(), new _index4.default(), new _index5.default(), new _index6.default()];
|
|
87
|
+
_index25.options.dereference.strategies = [new _index19.default(), new _index20.default(), new _index21.default(), new _index22.default(), new _index23.default(), new _index18.default()];
|
|
88
|
+
_index25.options.bundle.strategies = [new _index24.default()];
|