@speclynx/apidom-reference 3.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/apidom-reference.browser.js +162 -127
  3. package/dist/apidom-reference.browser.min.js +1 -1
  4. package/package.json +25 -25
  5. package/types/dereference/strategies/apidom/visitor.d.ts +1 -1
  6. package/types/dereference/strategies/arazzo-1/visitor.d.ts +1 -1
  7. package/types/dereference/strategies/asyncapi-2/visitor.d.ts +1 -1
  8. package/types/dereference/strategies/openapi-2/visitor.d.ts +1 -1
  9. package/types/dereference/strategies/openapi-3-0/visitor.d.ts +1 -1
  10. package/types/dereference/strategies/openapi-3-1/visitor.d.ts +1 -1
  11. package/src/File.cjs +0 -50
  12. package/src/File.mjs +0 -44
  13. package/src/Reference.cjs +0 -31
  14. package/src/Reference.mjs +0 -27
  15. package/src/ReferenceSet.cjs +0 -60
  16. package/src/ReferenceSet.mjs +0 -57
  17. package/src/bundle/index.cjs +0 -61
  18. package/src/bundle/index.mjs +0 -55
  19. package/src/bundle/strategies/BundleStrategy.cjs +0 -20
  20. package/src/bundle/strategies/BundleStrategy.mjs +0 -16
  21. package/src/bundle/strategies/openapi-3-1/index.cjs +0 -35
  22. package/src/bundle/strategies/openapi-3-1/index.mjs +0 -29
  23. package/src/configuration/empty.cjs +0 -9
  24. package/src/configuration/empty.mjs +0 -1
  25. package/src/configuration/saturated.cjs +0 -88
  26. package/src/configuration/saturated.mjs +0 -80
  27. package/src/dereference/index.cjs +0 -90
  28. package/src/dereference/index.mjs +0 -83
  29. package/src/dereference/strategies/DereferenceStrategy.cjs +0 -20
  30. package/src/dereference/strategies/DereferenceStrategy.mjs +0 -16
  31. package/src/dereference/strategies/apidom/index.cjs +0 -89
  32. package/src/dereference/strategies/apidom/index.mjs +0 -83
  33. package/src/dereference/strategies/apidom/selectors/element-id.cjs +0 -47
  34. package/src/dereference/strategies/apidom/selectors/element-id.mjs +0 -41
  35. package/src/dereference/strategies/apidom/visitor.cjs +0 -259
  36. package/src/dereference/strategies/apidom/visitor.mjs +0 -252
  37. package/src/dereference/strategies/arazzo-1/index.cjs +0 -109
  38. package/src/dereference/strategies/arazzo-1/index.mjs +0 -100
  39. package/src/dereference/strategies/arazzo-1/selectors/$anchor.cjs +0 -12
  40. package/src/dereference/strategies/arazzo-1/selectors/$anchor.mjs +0 -1
  41. package/src/dereference/strategies/arazzo-1/selectors/uri.cjs +0 -8
  42. package/src/dereference/strategies/arazzo-1/selectors/uri.mjs +0 -1
  43. package/src/dereference/strategies/arazzo-1/source-descriptions.cjs +0 -248
  44. package/src/dereference/strategies/arazzo-1/source-descriptions.mjs +0 -243
  45. package/src/dereference/strategies/arazzo-1/util.cjs +0 -37
  46. package/src/dereference/strategies/arazzo-1/util.mjs +0 -29
  47. package/src/dereference/strategies/arazzo-1/visitor.cjs +0 -501
  48. package/src/dereference/strategies/arazzo-1/visitor.mjs +0 -494
  49. package/src/dereference/strategies/asyncapi-2/index.cjs +0 -94
  50. package/src/dereference/strategies/asyncapi-2/index.mjs +0 -88
  51. package/src/dereference/strategies/asyncapi-2/visitor.cjs +0 -495
  52. package/src/dereference/strategies/asyncapi-2/visitor.mjs +0 -488
  53. package/src/dereference/strategies/openapi-2/index.cjs +0 -96
  54. package/src/dereference/strategies/openapi-2/index.mjs +0 -90
  55. package/src/dereference/strategies/openapi-2/visitor.cjs +0 -623
  56. package/src/dereference/strategies/openapi-2/visitor.mjs +0 -616
  57. package/src/dereference/strategies/openapi-3-0/index.cjs +0 -96
  58. package/src/dereference/strategies/openapi-3-0/index.mjs +0 -90
  59. package/src/dereference/strategies/openapi-3-0/visitor.cjs +0 -615
  60. package/src/dereference/strategies/openapi-3-0/visitor.mjs +0 -608
  61. package/src/dereference/strategies/openapi-3-1/index.cjs +0 -99
  62. package/src/dereference/strategies/openapi-3-1/index.mjs +0 -90
  63. package/src/dereference/strategies/openapi-3-1/selectors/$anchor.cjs +0 -67
  64. package/src/dereference/strategies/openapi-3-1/selectors/$anchor.mjs +0 -56
  65. package/src/dereference/strategies/openapi-3-1/selectors/uri.cjs +0 -50
  66. package/src/dereference/strategies/openapi-3-1/selectors/uri.mjs +0 -42
  67. package/src/dereference/strategies/openapi-3-1/util.cjs +0 -68
  68. package/src/dereference/strategies/openapi-3-1/util.mjs +0 -59
  69. package/src/dereference/strategies/openapi-3-1/visitor.cjs +0 -867
  70. package/src/dereference/strategies/openapi-3-1/visitor.mjs +0 -860
  71. package/src/dereference/util.cjs +0 -31
  72. package/src/dereference/util.mjs +0 -27
  73. package/src/errors/BundleError.cjs +0 -10
  74. package/src/errors/BundleError.mjs +0 -7
  75. package/src/errors/DereferenceError.cjs +0 -10
  76. package/src/errors/DereferenceError.mjs +0 -7
  77. package/src/errors/EvaluationElementIdError.cjs +0 -10
  78. package/src/errors/EvaluationElementIdError.mjs +0 -7
  79. package/src/errors/EvaluationJsonSchema$anchorError.cjs +0 -11
  80. package/src/errors/EvaluationJsonSchema$anchorError.mjs +0 -6
  81. package/src/errors/EvaluationJsonSchemaUriError.cjs +0 -11
  82. package/src/errors/EvaluationJsonSchemaUriError.mjs +0 -6
  83. package/src/errors/InvalidJsonSchema$anchorError.cjs +0 -15
  84. package/src/errors/InvalidJsonSchema$anchorError.mjs +0 -10
  85. package/src/errors/JsonSchema$anchorError.cjs +0 -10
  86. package/src/errors/JsonSchema$anchorError.mjs +0 -7
  87. package/src/errors/JsonSchemaUriError.cjs +0 -10
  88. package/src/errors/JsonSchemaUriError.mjs +0 -7
  89. package/src/errors/MaximumBundleDepthError.cjs +0 -11
  90. package/src/errors/MaximumBundleDepthError.mjs +0 -6
  91. package/src/errors/MaximumDereferenceDepthError.cjs +0 -11
  92. package/src/errors/MaximumDereferenceDepthError.mjs +0 -6
  93. package/src/errors/MaximumResolveDepthError.cjs +0 -11
  94. package/src/errors/MaximumResolveDepthError.mjs +0 -6
  95. package/src/errors/ParseError.cjs +0 -10
  96. package/src/errors/ParseError.mjs +0 -7
  97. package/src/errors/ParserError.cjs +0 -11
  98. package/src/errors/ParserError.mjs +0 -6
  99. package/src/errors/PluginError.cjs +0 -18
  100. package/src/errors/PluginError.mjs +0 -15
  101. package/src/errors/ResolveError.cjs +0 -10
  102. package/src/errors/ResolveError.mjs +0 -7
  103. package/src/errors/ResolverError.cjs +0 -11
  104. package/src/errors/ResolverError.mjs +0 -6
  105. package/src/errors/UnmatchedBundleStrategyError.cjs +0 -11
  106. package/src/errors/UnmatchedBundleStrategyError.mjs +0 -6
  107. package/src/errors/UnmatchedDereferenceStrategyError.cjs +0 -11
  108. package/src/errors/UnmatchedDereferenceStrategyError.mjs +0 -6
  109. package/src/errors/UnmatchedParserError.cjs +0 -11
  110. package/src/errors/UnmatchedParserError.mjs +0 -6
  111. package/src/errors/UnmatchedResolveStrategyError.cjs +0 -11
  112. package/src/errors/UnmatchedResolveStrategyError.mjs +0 -6
  113. package/src/errors/UnmatchedResolverError.cjs +0 -11
  114. package/src/errors/UnmatchedResolverError.mjs +0 -6
  115. package/src/errors/UnresolvableReferenceError.cjs +0 -11
  116. package/src/errors/UnresolvableReferenceError.mjs +0 -6
  117. package/src/index.cjs +0 -146
  118. package/src/index.mjs +0 -103
  119. package/src/options/index.cjs +0 -194
  120. package/src/options/index.mjs +0 -191
  121. package/src/options/util.cjs +0 -24
  122. package/src/options/util.mjs +0 -19
  123. package/src/parse/index.cjs +0 -69
  124. package/src/parse/index.mjs +0 -63
  125. package/src/parse/parsers/Parser.cjs +0 -62
  126. package/src/parse/parsers/Parser.mjs +0 -58
  127. package/src/parse/parsers/apidom-json/index.cjs +0 -70
  128. package/src/parse/parsers/apidom-json/index.mjs +0 -64
  129. package/src/parse/parsers/arazzo-json-1/index.cjs +0 -62
  130. package/src/parse/parsers/arazzo-json-1/index.mjs +0 -56
  131. package/src/parse/parsers/arazzo-json-1/source-descriptions.cjs +0 -221
  132. package/src/parse/parsers/arazzo-json-1/source-descriptions.mjs +0 -214
  133. package/src/parse/parsers/arazzo-yaml-1/index.cjs +0 -62
  134. package/src/parse/parsers/arazzo-yaml-1/index.mjs +0 -56
  135. package/src/parse/parsers/arazzo-yaml-1/source-descriptions.cjs +0 -12
  136. package/src/parse/parsers/arazzo-yaml-1/source-descriptions.mjs +0 -7
  137. package/src/parse/parsers/asyncapi-json-2/index.cjs +0 -54
  138. package/src/parse/parsers/asyncapi-json-2/index.mjs +0 -48
  139. package/src/parse/parsers/asyncapi-yaml-2/index.cjs +0 -54
  140. package/src/parse/parsers/asyncapi-yaml-2/index.mjs +0 -48
  141. package/src/parse/parsers/binary/index-browser.cjs +0 -56
  142. package/src/parse/parsers/binary/index-browser.mjs +0 -50
  143. package/src/parse/parsers/binary/index-node.cjs +0 -51
  144. package/src/parse/parsers/binary/index-node.mjs +0 -45
  145. package/src/parse/parsers/json/index.cjs +0 -53
  146. package/src/parse/parsers/json/index.mjs +0 -47
  147. package/src/parse/parsers/openapi-json-2/index.cjs +0 -54
  148. package/src/parse/parsers/openapi-json-2/index.mjs +0 -48
  149. package/src/parse/parsers/openapi-json-3-0/index.cjs +0 -54
  150. package/src/parse/parsers/openapi-json-3-0/index.mjs +0 -48
  151. package/src/parse/parsers/openapi-json-3-1/index.cjs +0 -54
  152. package/src/parse/parsers/openapi-json-3-1/index.mjs +0 -48
  153. package/src/parse/parsers/openapi-yaml-2/index.cjs +0 -54
  154. package/src/parse/parsers/openapi-yaml-2/index.mjs +0 -48
  155. package/src/parse/parsers/openapi-yaml-3-0/index.cjs +0 -54
  156. package/src/parse/parsers/openapi-yaml-3-0/index.mjs +0 -48
  157. package/src/parse/parsers/openapi-yaml-3-1/index.cjs +0 -54
  158. package/src/parse/parsers/openapi-yaml-3-1/index.mjs +0 -48
  159. package/src/parse/parsers/yaml-1-2/index.cjs +0 -56
  160. package/src/parse/parsers/yaml-1-2/index.mjs +0 -50
  161. package/src/resolve/index.cjs +0 -67
  162. package/src/resolve/index.mjs +0 -60
  163. package/src/resolve/resolvers/HTTPResolver.cjs +0 -45
  164. package/src/resolve/resolvers/HTTPResolver.mjs +0 -37
  165. package/src/resolve/resolvers/Resolver.cjs +0 -20
  166. package/src/resolve/resolvers/Resolver.mjs +0 -16
  167. package/src/resolve/resolvers/file/index-browser.cjs +0 -24
  168. package/src/resolve/resolvers/file/index-browser.mjs +0 -19
  169. package/src/resolve/resolvers/file/index-node.cjs +0 -49
  170. package/src/resolve/resolvers/file/index-node.mjs +0 -42
  171. package/src/resolve/resolvers/http-axios/cache/MemoryCache.cjs +0 -41
  172. package/src/resolve/resolvers/http-axios/cache/MemoryCache.mjs +0 -37
  173. package/src/resolve/resolvers/http-axios/index.cjs +0 -113
  174. package/src/resolve/resolvers/http-axios/index.mjs +0 -105
  175. package/src/resolve/strategies/ResolveStrategy.cjs +0 -20
  176. package/src/resolve/strategies/ResolveStrategy.mjs +0 -16
  177. package/src/resolve/strategies/apidom/index.cjs +0 -49
  178. package/src/resolve/strategies/apidom/index.mjs +0 -43
  179. package/src/resolve/strategies/asyncapi-2/index.cjs +0 -49
  180. package/src/resolve/strategies/asyncapi-2/index.mjs +0 -43
  181. package/src/resolve/strategies/openapi-2/index.cjs +0 -49
  182. package/src/resolve/strategies/openapi-2/index.mjs +0 -43
  183. package/src/resolve/strategies/openapi-3-0/index.cjs +0 -49
  184. package/src/resolve/strategies/openapi-3-0/index.mjs +0 -43
  185. package/src/resolve/strategies/openapi-3-1/index.cjs +0 -49
  186. package/src/resolve/strategies/openapi-3-1/index.mjs +0 -43
  187. package/src/resolve/util.cjs +0 -37
  188. package/src/resolve/util.mjs +0 -30
  189. package/src/util/plugins.cjs +0 -39
  190. package/src/util/plugins.mjs +0 -34
  191. package/src/util/url.cjs +0 -288
  192. package/src/util/url.mjs +0 -274
@@ -1,48 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as OpenAPI3_1MediaTypes, detect } from '@speclynx/apidom-parser-adapter-openapi-json-3-1';
3
- import ParserError from "../../../errors/ParserError.mjs";
4
- import Parser from "../Parser.mjs";
5
- /**
6
- * @public
7
- */
8
- /**
9
- * @public
10
- */
11
- class OpenAPIJSON3_1Parser extends Parser {
12
- refractorOpts;
13
- constructor(options) {
14
- const {
15
- fileExtensions = [],
16
- mediaTypes = OpenAPI3_1MediaTypes,
17
- ...rest
18
- } = options ?? {};
19
- super({
20
- ...rest,
21
- name: 'openapi-json-3-1',
22
- fileExtensions,
23
- mediaTypes
24
- });
25
- }
26
- async canParse(file) {
27
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
28
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
29
- if (!hasSupportedFileExtension) return false;
30
- if (hasSupportedMediaType) return true;
31
- if (!hasSupportedMediaType) {
32
- return detect(file.toString());
33
- }
34
- return false;
35
- }
36
- async parse(file) {
37
- const source = file.toString();
38
- try {
39
- const parserOpts = pick(['sourceMap', 'style', 'strict', 'refractorOpts'], this);
40
- return await parse(source, parserOpts);
41
- } catch (error) {
42
- throw new ParserError(`Error parsing "${file.uri}"`, {
43
- cause: error
44
- });
45
- }
46
- }
47
- }
48
- export default OpenAPIJSON3_1Parser;
@@ -1,54 +0,0 @@
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 _ramda = require("ramda");
7
- var _apidomParserAdapterOpenapiYaml = require("@speclynx/apidom-parser-adapter-openapi-yaml-2");
8
- var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
9
- var _Parser = _interopRequireDefault(require("../Parser.cjs"));
10
- /**
11
- * @public
12
- */
13
-
14
- /**
15
- * @public
16
- */
17
- class OpenAPIYAML2Parser extends _Parser.default {
18
- refractorOpts;
19
- constructor(options) {
20
- const {
21
- fileExtensions = [],
22
- mediaTypes = _apidomParserAdapterOpenapiYaml.mediaTypes,
23
- ...rest
24
- } = options ?? {};
25
- super({
26
- ...rest,
27
- name: 'openapi-yaml-2',
28
- fileExtensions,
29
- mediaTypes
30
- });
31
- }
32
- async canParse(file) {
33
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
34
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
35
- if (!hasSupportedFileExtension) return false;
36
- if (hasSupportedMediaType) return true;
37
- if (!hasSupportedMediaType) {
38
- return (0, _apidomParserAdapterOpenapiYaml.detect)(file.toString());
39
- }
40
- return false;
41
- }
42
- async parse(file) {
43
- const source = file.toString();
44
- try {
45
- const parserOpts = (0, _ramda.pick)(['sourceMap', 'style', 'strict', 'refractorOpts'], this);
46
- return await (0, _apidomParserAdapterOpenapiYaml.parse)(source, parserOpts);
47
- } catch (error) {
48
- throw new _ParserError.default(`Error parsing "${file.uri}"`, {
49
- cause: error
50
- });
51
- }
52
- }
53
- }
54
- var _default = exports.default = OpenAPIYAML2Parser;
@@ -1,48 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as OpenAPIYAML2MediaTypes, detect } from '@speclynx/apidom-parser-adapter-openapi-yaml-2';
3
- import ParserError from "../../../errors/ParserError.mjs";
4
- import Parser from "../Parser.mjs";
5
- /**
6
- * @public
7
- */
8
- /**
9
- * @public
10
- */
11
- class OpenAPIYAML2Parser extends Parser {
12
- refractorOpts;
13
- constructor(options) {
14
- const {
15
- fileExtensions = [],
16
- mediaTypes = OpenAPIYAML2MediaTypes,
17
- ...rest
18
- } = options ?? {};
19
- super({
20
- ...rest,
21
- name: 'openapi-yaml-2',
22
- fileExtensions,
23
- mediaTypes
24
- });
25
- }
26
- async canParse(file) {
27
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
28
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
29
- if (!hasSupportedFileExtension) return false;
30
- if (hasSupportedMediaType) return true;
31
- if (!hasSupportedMediaType) {
32
- return detect(file.toString());
33
- }
34
- return false;
35
- }
36
- async parse(file) {
37
- const source = file.toString();
38
- try {
39
- const parserOpts = pick(['sourceMap', 'style', 'strict', 'refractorOpts'], this);
40
- return await parse(source, parserOpts);
41
- } catch (error) {
42
- throw new ParserError(`Error parsing "${file.uri}"`, {
43
- cause: error
44
- });
45
- }
46
- }
47
- }
48
- export default OpenAPIYAML2Parser;
@@ -1,54 +0,0 @@
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 _ramda = require("ramda");
7
- var _apidomParserAdapterOpenapiYaml = require("@speclynx/apidom-parser-adapter-openapi-yaml-3-0");
8
- var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
9
- var _Parser = _interopRequireDefault(require("../Parser.cjs"));
10
- /**
11
- * @public
12
- */
13
-
14
- /**
15
- * @public
16
- */
17
- class OpenAPIYAML3_0Parser extends _Parser.default {
18
- refractorOpts;
19
- constructor(options) {
20
- const {
21
- fileExtensions = [],
22
- mediaTypes = _apidomParserAdapterOpenapiYaml.mediaTypes,
23
- ...rest
24
- } = options ?? {};
25
- super({
26
- ...rest,
27
- name: 'openapi-yaml-3-0',
28
- fileExtensions,
29
- mediaTypes
30
- });
31
- }
32
- async canParse(file) {
33
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
34
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
35
- if (!hasSupportedFileExtension) return false;
36
- if (hasSupportedMediaType) return true;
37
- if (!hasSupportedMediaType) {
38
- return (0, _apidomParserAdapterOpenapiYaml.detect)(file.toString());
39
- }
40
- return false;
41
- }
42
- async parse(file) {
43
- const source = file.toString();
44
- try {
45
- const parserOpts = (0, _ramda.pick)(['sourceMap', 'style', 'strict', 'refractorOpts'], this);
46
- return await (0, _apidomParserAdapterOpenapiYaml.parse)(source, parserOpts);
47
- } catch (error) {
48
- throw new _ParserError.default(`Error parsing "${file.uri}"`, {
49
- cause: error
50
- });
51
- }
52
- }
53
- }
54
- var _default = exports.default = OpenAPIYAML3_0Parser;
@@ -1,48 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as OpenAPIYAML3_0MediaTypes, detect } from '@speclynx/apidom-parser-adapter-openapi-yaml-3-0';
3
- import ParserError from "../../../errors/ParserError.mjs";
4
- import Parser from "../Parser.mjs";
5
- /**
6
- * @public
7
- */
8
- /**
9
- * @public
10
- */
11
- class OpenAPIYAML3_0Parser extends Parser {
12
- refractorOpts;
13
- constructor(options) {
14
- const {
15
- fileExtensions = [],
16
- mediaTypes = OpenAPIYAML3_0MediaTypes,
17
- ...rest
18
- } = options ?? {};
19
- super({
20
- ...rest,
21
- name: 'openapi-yaml-3-0',
22
- fileExtensions,
23
- mediaTypes
24
- });
25
- }
26
- async canParse(file) {
27
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
28
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
29
- if (!hasSupportedFileExtension) return false;
30
- if (hasSupportedMediaType) return true;
31
- if (!hasSupportedMediaType) {
32
- return detect(file.toString());
33
- }
34
- return false;
35
- }
36
- async parse(file) {
37
- const source = file.toString();
38
- try {
39
- const parserOpts = pick(['sourceMap', 'style', 'strict', 'refractorOpts'], this);
40
- return await parse(source, parserOpts);
41
- } catch (error) {
42
- throw new ParserError(`Error parsing "${file.uri}"`, {
43
- cause: error
44
- });
45
- }
46
- }
47
- }
48
- export default OpenAPIYAML3_0Parser;
@@ -1,54 +0,0 @@
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 _ramda = require("ramda");
7
- var _apidomParserAdapterOpenapiYaml = require("@speclynx/apidom-parser-adapter-openapi-yaml-3-1");
8
- var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
9
- var _Parser = _interopRequireDefault(require("../Parser.cjs"));
10
- /**
11
- * @public
12
- */
13
-
14
- /**
15
- * @public
16
- */
17
- class OpenAPIYAML3_1Parser extends _Parser.default {
18
- refractorOpts;
19
- constructor(options) {
20
- const {
21
- fileExtensions = [],
22
- mediaTypes = _apidomParserAdapterOpenapiYaml.mediaTypes,
23
- ...rest
24
- } = options ?? {};
25
- super({
26
- ...rest,
27
- name: 'openapi-yaml-3-1',
28
- fileExtensions,
29
- mediaTypes
30
- });
31
- }
32
- async canParse(file) {
33
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
34
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
35
- if (!hasSupportedFileExtension) return false;
36
- if (hasSupportedMediaType) return true;
37
- if (!hasSupportedMediaType) {
38
- return (0, _apidomParserAdapterOpenapiYaml.detect)(file.toString());
39
- }
40
- return false;
41
- }
42
- async parse(file) {
43
- const source = file.toString();
44
- try {
45
- const parserOpts = (0, _ramda.pick)(['sourceMap', 'style', 'strict', 'refractorOpts'], this);
46
- return await (0, _apidomParserAdapterOpenapiYaml.parse)(source, parserOpts);
47
- } catch (error) {
48
- throw new _ParserError.default(`Error parsing "${file.uri}"`, {
49
- cause: error
50
- });
51
- }
52
- }
53
- }
54
- var _default = exports.default = OpenAPIYAML3_1Parser;
@@ -1,48 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as OpenAPIYAML3_1MediaTypes, detect } from '@speclynx/apidom-parser-adapter-openapi-yaml-3-1';
3
- import ParserError from "../../../errors/ParserError.mjs";
4
- import Parser from "../Parser.mjs";
5
- /**
6
- * @public
7
- */
8
- /**
9
- * @public
10
- */
11
- class OpenAPIYAML3_1Parser extends Parser {
12
- refractorOpts;
13
- constructor(options) {
14
- const {
15
- fileExtensions = [],
16
- mediaTypes = OpenAPIYAML3_1MediaTypes,
17
- ...rest
18
- } = options ?? {};
19
- super({
20
- ...rest,
21
- name: 'openapi-yaml-3-1',
22
- fileExtensions,
23
- mediaTypes
24
- });
25
- }
26
- async canParse(file) {
27
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
28
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
29
- if (!hasSupportedFileExtension) return false;
30
- if (hasSupportedMediaType) return true;
31
- if (!hasSupportedMediaType) {
32
- return detect(file.toString());
33
- }
34
- return false;
35
- }
36
- async parse(file) {
37
- const source = file.toString();
38
- try {
39
- const parserOpts = pick(['sourceMap', 'style', 'strict', 'refractorOpts'], this);
40
- return await parse(source, parserOpts);
41
- } catch (error) {
42
- throw new ParserError(`Error parsing "${file.uri}"`, {
43
- cause: error
44
- });
45
- }
46
- }
47
- }
48
- export default OpenAPIYAML3_1Parser;
@@ -1,56 +0,0 @@
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 _apidomParserAdapterYaml = require("@speclynx/apidom-parser-adapter-yaml-1-2");
7
- var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
8
- var _Parser = _interopRequireDefault(require("../Parser.cjs"));
9
- /**
10
- * @public
11
- */
12
-
13
- /**
14
- * @public
15
- */
16
- class YAML1Parser extends _Parser.default {
17
- refractorOpts;
18
- constructor(options) {
19
- const {
20
- fileExtensions = [],
21
- mediaTypes = _apidomParserAdapterYaml.mediaTypes,
22
- ...rest
23
- } = options ?? {};
24
- super({
25
- ...rest,
26
- name: 'yaml-1-2',
27
- fileExtensions,
28
- mediaTypes
29
- });
30
- }
31
- async canParse(file) {
32
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
33
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
34
- if (!hasSupportedFileExtension) return false;
35
- if (hasSupportedMediaType) return true;
36
- if (!hasSupportedMediaType) {
37
- return (0, _apidomParserAdapterYaml.detect)(file.toString());
38
- }
39
- return false;
40
- }
41
- async parse(file) {
42
- const source = file.toString();
43
- try {
44
- return await (0, _apidomParserAdapterYaml.parse)(source, {
45
- sourceMap: this.sourceMap,
46
- style: this.style,
47
- strict: this.strict
48
- });
49
- } catch (error) {
50
- throw new _ParserError.default(`Error parsing "${file.uri}"`, {
51
- cause: error
52
- });
53
- }
54
- }
55
- }
56
- var _default = exports.default = YAML1Parser;
@@ -1,50 +0,0 @@
1
- import { parse, mediaTypes as YAMLMediaTypes, detect } from '@speclynx/apidom-parser-adapter-yaml-1-2';
2
- import ParserError from "../../../errors/ParserError.mjs";
3
- import Parser from "../Parser.mjs";
4
- /**
5
- * @public
6
- */
7
- /**
8
- * @public
9
- */
10
- class YAML1Parser extends Parser {
11
- refractorOpts;
12
- constructor(options) {
13
- const {
14
- fileExtensions = [],
15
- mediaTypes = YAMLMediaTypes,
16
- ...rest
17
- } = options ?? {};
18
- super({
19
- ...rest,
20
- name: 'yaml-1-2',
21
- fileExtensions,
22
- mediaTypes
23
- });
24
- }
25
- async canParse(file) {
26
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
27
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
28
- if (!hasSupportedFileExtension) return false;
29
- if (hasSupportedMediaType) return true;
30
- if (!hasSupportedMediaType) {
31
- return detect(file.toString());
32
- }
33
- return false;
34
- }
35
- async parse(file) {
36
- const source = file.toString();
37
- try {
38
- return await parse(source, {
39
- sourceMap: this.sourceMap,
40
- style: this.style,
41
- strict: this.strict
42
- });
43
- } catch (error) {
44
- throw new ParserError(`Error parsing "${file.uri}"`, {
45
- cause: error
46
- });
47
- }
48
- }
49
- }
50
- export default YAML1Parser;
@@ -1,67 +0,0 @@
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.resolveApiDOM = exports.default = void 0;
7
- var _ramda = require("ramda");
8
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
9
- var _util = require("../options/util.cjs");
10
- var _index = _interopRequireDefault(require("../parse/index.cjs"));
11
- var plugins = _interopRequireWildcard(require("../util/plugins.cjs"));
12
- var _File = _interopRequireDefault(require("../File.cjs"));
13
- var _ResolverError = _interopRequireDefault(require("../errors/ResolverError.cjs"));
14
- var _UnmatchedResolveStrategyError = _interopRequireDefault(require("../errors/UnmatchedResolveStrategyError.cjs"));
15
- var url = _interopRequireWildcard(require("../util/url.cjs"));
16
- /**
17
- * Resolves ApiDOM with all its external references.
18
- */
19
- const resolveApiDOM = async (element, options) => {
20
- // @ts-ignore
21
- let parseResult = element;
22
-
23
- // wrap element into parse result
24
- if (!(0, _apidomDatamodel.isParseResultElement)(element)) {
25
- // shallow clone of the element
26
- const elementClone = (0, _apidomDatamodel.cloneShallow)(element);
27
- elementClone.classes.push('result');
28
- parseResult = new _apidomDatamodel.ParseResultElement([elementClone]);
29
- }
30
- const sanitizedURI = url.sanitize(url.stripHash(options.resolve.baseURI));
31
- const file = new _File.default({
32
- uri: sanitizedURI,
33
- parseResult,
34
- mediaType: options.parse.mediaType
35
- });
36
- const resolveStrategies = await plugins.filter('canResolve', [file, options], options.resolve.strategies);
37
-
38
- // we couldn't find any resolve strategy for this File
39
- if ((0, _ramda.isEmpty)(resolveStrategies)) {
40
- throw new _UnmatchedResolveStrategyError.default(`Could not find a resolve strategy that can resolve the file "${file.uri}"`);
41
- }
42
- try {
43
- const {
44
- result
45
- } = await plugins.run('resolve', [file, options], resolveStrategies);
46
- return result;
47
- } catch (error) {
48
- throw new _ResolverError.default(`Error while resolving file "${file.uri}"`, {
49
- cause: error
50
- });
51
- }
52
- };
53
-
54
- /**
55
- * Resolves a file with all its external references.
56
- */
57
- exports.resolveApiDOM = resolveApiDOM;
58
- const resolve = async (uri, options) => {
59
- const parseResult = await (0, _index.default)(uri, options);
60
- const mergedOptions = (0, _util.merge)(options, {
61
- resolve: {
62
- baseURI: url.sanitize(uri)
63
- }
64
- });
65
- return resolveApiDOM(parseResult, mergedOptions);
66
- };
67
- var _default = exports.default = resolve;
@@ -1,60 +0,0 @@
1
- import { isEmpty } from 'ramda';
2
- import { isParseResultElement, ParseResultElement, cloneShallow } from '@speclynx/apidom-datamodel';
3
- import { merge as mergeOptions } from "../options/util.mjs";
4
- import parse from "../parse/index.mjs";
5
- import * as plugins from "../util/plugins.mjs";
6
- import File from "../File.mjs";
7
- import ResolveError from "../errors/ResolverError.mjs";
8
- import UnmatchedResolveStrategyError from "../errors/UnmatchedResolveStrategyError.mjs";
9
- import * as url from "../util/url.mjs";
10
- /**
11
- * Resolves ApiDOM with all its external references.
12
- */
13
- export const resolveApiDOM = async (element, options) => {
14
- // @ts-ignore
15
- let parseResult = element;
16
-
17
- // wrap element into parse result
18
- if (!isParseResultElement(element)) {
19
- // shallow clone of the element
20
- const elementClone = cloneShallow(element);
21
- elementClone.classes.push('result');
22
- parseResult = new ParseResultElement([elementClone]);
23
- }
24
- const sanitizedURI = url.sanitize(url.stripHash(options.resolve.baseURI));
25
- const file = new File({
26
- uri: sanitizedURI,
27
- parseResult,
28
- mediaType: options.parse.mediaType
29
- });
30
- const resolveStrategies = await plugins.filter('canResolve', [file, options], options.resolve.strategies);
31
-
32
- // we couldn't find any resolve strategy for this File
33
- if (isEmpty(resolveStrategies)) {
34
- throw new UnmatchedResolveStrategyError(`Could not find a resolve strategy that can resolve the file "${file.uri}"`);
35
- }
36
- try {
37
- const {
38
- result
39
- } = await plugins.run('resolve', [file, options], resolveStrategies);
40
- return result;
41
- } catch (error) {
42
- throw new ResolveError(`Error while resolving file "${file.uri}"`, {
43
- cause: error
44
- });
45
- }
46
- };
47
-
48
- /**
49
- * Resolves a file with all its external references.
50
- */
51
- const resolve = async (uri, options) => {
52
- const parseResult = await parse(uri, options);
53
- const mergedOptions = mergeOptions(options, {
54
- resolve: {
55
- baseURI: url.sanitize(uri)
56
- }
57
- });
58
- return resolveApiDOM(parseResult, mergedOptions);
59
- };
60
- export default resolve;
@@ -1,45 +0,0 @@
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 _Resolver = _interopRequireDefault(require("./Resolver.cjs"));
8
- var url = _interopRequireWildcard(require("../../util/url.cjs"));
9
- /**
10
- * @public
11
- */
12
-
13
- /**
14
- * @public
15
- */
16
-
17
- /**
18
- * @public
19
- */
20
- class HTTPResolver extends _Resolver.default {
21
- timeout;
22
- redirects;
23
- withCredentials;
24
- cache;
25
- constructor(options) {
26
- const {
27
- name = 'http-resolver',
28
- timeout = 5000,
29
- redirects = 5,
30
- withCredentials = false,
31
- cache = false
32
- } = options ?? {};
33
- super({
34
- name
35
- });
36
- this.timeout = timeout;
37
- this.redirects = redirects;
38
- this.withCredentials = withCredentials;
39
- this.cache = cache;
40
- }
41
- canRead(file) {
42
- return url.isHttpUrl(file.uri);
43
- }
44
- }
45
- var _default = exports.default = HTTPResolver;
@@ -1,37 +0,0 @@
1
- import Resolver from "./Resolver.mjs";
2
- import * as url from "../../util/url.mjs";
3
- /**
4
- * @public
5
- */
6
- /**
7
- * @public
8
- */
9
- /**
10
- * @public
11
- */
12
- class HTTPResolver extends Resolver {
13
- timeout;
14
- redirects;
15
- withCredentials;
16
- cache;
17
- constructor(options) {
18
- const {
19
- name = 'http-resolver',
20
- timeout = 5000,
21
- redirects = 5,
22
- withCredentials = false,
23
- cache = false
24
- } = options ?? {};
25
- super({
26
- name
27
- });
28
- this.timeout = timeout;
29
- this.redirects = redirects;
30
- this.withCredentials = withCredentials;
31
- this.cache = cache;
32
- }
33
- canRead(file) {
34
- return url.isHttpUrl(file.uri);
35
- }
36
- }
37
- export default HTTPResolver;