@speclynx/apidom-reference 3.2.1 → 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 +12 -0
  2. package/dist/apidom-reference.browser.js +40 -36
  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 -266
  36. package/src/dereference/strategies/apidom/visitor.mjs +0 -259
  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 -507
  48. package/src/dereference/strategies/arazzo-1/visitor.mjs +0 -500
  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 -501
  52. package/src/dereference/strategies/asyncapi-2/visitor.mjs +0 -494
  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 -629
  56. package/src/dereference/strategies/openapi-2/visitor.mjs +0 -622
  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 -621
  60. package/src/dereference/strategies/openapi-3-0/visitor.mjs +0 -614
  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 -873
  70. package/src/dereference/strategies/openapi-3-1/visitor.mjs +0 -866
  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,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 _apidomParserAdapterAsyncapiYaml = require("@speclynx/apidom-parser-adapter-asyncapi-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 AsyncAPIYAML2Parser extends _Parser.default {
18
- refractorOpts;
19
- constructor(options) {
20
- const {
21
- fileExtensions = [],
22
- mediaTypes = _apidomParserAdapterAsyncapiYaml.mediaTypes,
23
- ...rest
24
- } = options ?? {};
25
- super({
26
- ...rest,
27
- name: 'asyncapi-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, _apidomParserAdapterAsyncapiYaml.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, _apidomParserAdapterAsyncapiYaml.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 = AsyncAPIYAML2Parser;
@@ -1,48 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as AsyncAPI2MediaTypes, detect } from '@speclynx/apidom-parser-adapter-asyncapi-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 AsyncAPIYAML2Parser extends Parser {
12
- refractorOpts;
13
- constructor(options) {
14
- const {
15
- fileExtensions = [],
16
- mediaTypes = AsyncAPI2MediaTypes,
17
- ...rest
18
- } = options ?? {};
19
- super({
20
- ...rest,
21
- name: 'asyncapi-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 AsyncAPIYAML2Parser;
@@ -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 _apidomDatamodel = require("@speclynx/apidom-datamodel");
7
- var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
8
- var _Parser = _interopRequireDefault(require("../Parser.cjs"));
9
- /**
10
- * Everything that is not recognized by other parsers will be considered by this parser
11
- * as a binary data and will be encoded to Base64 format.
12
- * @public
13
- */
14
-
15
- /**
16
- * @public
17
- */
18
- class BinaryParser extends _Parser.default {
19
- constructor(options) {
20
- super({
21
- ...(options ?? {}),
22
- name: 'binary'
23
- });
24
- }
25
- canParse(file) {
26
- return this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
27
- }
28
- parse(file) {
29
- try {
30
- /**
31
- * More information about binary strings and btoa function in following link:
32
- * https://developer.mozilla.org/en-US/docs/Web/API/btoa
33
- *
34
- * @example
35
- * ArrayBuffer to base64 conversion:
36
- *
37
- * const binaryString = String.fromCharCode.apply(null, file.data);
38
- * base64String = btoa(binaryString);
39
- */
40
- const binaryString = unescape(encodeURIComponent(file.toString()));
41
- const base64String = btoa(binaryString);
42
- const parseResultElement = new _apidomDatamodel.ParseResultElement();
43
- if (base64String.length !== 0) {
44
- const base64StringElement = new _apidomDatamodel.StringElement(base64String);
45
- base64StringElement.classes.push('result');
46
- parseResultElement.push(base64StringElement);
47
- }
48
- return parseResultElement;
49
- } catch (error) {
50
- throw new _ParserError.default(`Error parsing "${file.uri}"`, {
51
- cause: error
52
- });
53
- }
54
- }
55
- }
56
- var _default = exports.default = BinaryParser;
@@ -1,50 +0,0 @@
1
- import { ParseResultElement, StringElement } from '@speclynx/apidom-datamodel';
2
- import ParserError from "../../../errors/ParserError.mjs";
3
- import Parser from "../Parser.mjs";
4
- /**
5
- * Everything that is not recognized by other parsers will be considered by this parser
6
- * as a binary data and will be encoded to Base64 format.
7
- * @public
8
- */
9
- /**
10
- * @public
11
- */
12
- class BinaryParser extends Parser {
13
- constructor(options) {
14
- super({
15
- ...(options ?? {}),
16
- name: 'binary'
17
- });
18
- }
19
- canParse(file) {
20
- return this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
21
- }
22
- parse(file) {
23
- try {
24
- /**
25
- * More information about binary strings and btoa function in following link:
26
- * https://developer.mozilla.org/en-US/docs/Web/API/btoa
27
- *
28
- * @example
29
- * ArrayBuffer to base64 conversion:
30
- *
31
- * const binaryString = String.fromCharCode.apply(null, file.data);
32
- * base64String = btoa(binaryString);
33
- */
34
- const binaryString = unescape(encodeURIComponent(file.toString()));
35
- const base64String = btoa(binaryString);
36
- const parseResultElement = new ParseResultElement();
37
- if (base64String.length !== 0) {
38
- const base64StringElement = new StringElement(base64String);
39
- base64StringElement.classes.push('result');
40
- parseResultElement.push(base64StringElement);
41
- }
42
- return parseResultElement;
43
- } catch (error) {
44
- throw new ParserError(`Error parsing "${file.uri}"`, {
45
- cause: error
46
- });
47
- }
48
- }
49
- }
50
- export default BinaryParser;
@@ -1,51 +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 _nodeBuffer = require("node:buffer");
7
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
8
- var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
9
- var _Parser = _interopRequireDefault(require("../Parser.cjs"));
10
- /**
11
- * Everything that is not recognized by other parsers will be considered by this parser
12
- * as a binary data and will be encoded to Base64 format.
13
- * @public
14
- */
15
-
16
- /**
17
- * @public
18
- */
19
- class BinaryParser extends _Parser.default {
20
- constructor(options) {
21
- super({
22
- ...(options ?? {}),
23
- name: 'binary'
24
- });
25
- }
26
- canParse(file) {
27
- return this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
28
- }
29
- parse(file) {
30
- let base64String;
31
- try {
32
- base64String = _nodeBuffer.Buffer.from(file.data).toString('base64');
33
- } catch {
34
- base64String = _nodeBuffer.Buffer.from(file.toString()).toString('base64');
35
- }
36
- try {
37
- const parseResultElement = new _apidomDatamodel.ParseResultElement();
38
- if (base64String.length !== 0) {
39
- const base64StringElement = new _apidomDatamodel.StringElement(base64String);
40
- base64StringElement.classes.push('result');
41
- parseResultElement.push(base64StringElement);
42
- }
43
- return parseResultElement;
44
- } catch (error) {
45
- throw new _ParserError.default(`Error parsing "${file.uri}"`, {
46
- cause: error
47
- });
48
- }
49
- }
50
- }
51
- var _default = exports.default = BinaryParser;
@@ -1,45 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import { ParseResultElement, StringElement } from '@speclynx/apidom-datamodel';
3
- import ParserError from "../../../errors/ParserError.mjs";
4
- import Parser from "../Parser.mjs";
5
- /**
6
- * Everything that is not recognized by other parsers will be considered by this parser
7
- * as a binary data and will be encoded to Base64 format.
8
- * @public
9
- */
10
- /**
11
- * @public
12
- */
13
- class BinaryParser extends Parser {
14
- constructor(options) {
15
- super({
16
- ...(options ?? {}),
17
- name: 'binary'
18
- });
19
- }
20
- canParse(file) {
21
- return this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
22
- }
23
- parse(file) {
24
- let base64String;
25
- try {
26
- base64String = Buffer.from(file.data).toString('base64');
27
- } catch {
28
- base64String = Buffer.from(file.toString()).toString('base64');
29
- }
30
- try {
31
- const parseResultElement = new ParseResultElement();
32
- if (base64String.length !== 0) {
33
- const base64StringElement = new StringElement(base64String);
34
- base64StringElement.classes.push('result');
35
- parseResultElement.push(base64StringElement);
36
- }
37
- return parseResultElement;
38
- } catch (error) {
39
- throw new ParserError(`Error parsing "${file.uri}"`, {
40
- cause: error
41
- });
42
- }
43
- }
44
- }
45
- export default BinaryParser;
@@ -1,53 +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 _apidomParserAdapterJson = require("@speclynx/apidom-parser-adapter-json");
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 JSONParser extends _Parser.default {
18
- constructor(options) {
19
- const {
20
- fileExtensions = [],
21
- mediaTypes = _apidomParserAdapterJson.mediaTypes,
22
- ...rest
23
- } = options ?? {};
24
- super({
25
- ...rest,
26
- name: 'json',
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, _apidomParserAdapterJson.detect)(file.toString());
38
- }
39
- return false;
40
- }
41
- async parse(file) {
42
- const source = file.toString();
43
- try {
44
- const parserOpts = (0, _ramda.pick)(['sourceMap', 'style', 'strict'], this);
45
- return await (0, _apidomParserAdapterJson.parse)(source, parserOpts);
46
- } catch (error) {
47
- throw new _ParserError.default(`Error parsing "${file.uri}"`, {
48
- cause: error
49
- });
50
- }
51
- }
52
- }
53
- var _default = exports.default = JSONParser;
@@ -1,47 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as JSONMediaTypes, detect } from '@speclynx/apidom-parser-adapter-json';
3
- import ParserError from "../../../errors/ParserError.mjs";
4
- import Parser from "../Parser.mjs";
5
- /**
6
- * @public
7
- */
8
- /**
9
- * @public
10
- */
11
- class JSONParser extends Parser {
12
- constructor(options) {
13
- const {
14
- fileExtensions = [],
15
- mediaTypes = JSONMediaTypes,
16
- ...rest
17
- } = options ?? {};
18
- super({
19
- ...rest,
20
- name: 'json',
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
- const parserOpts = pick(['sourceMap', 'style', 'strict'], this);
39
- return await parse(source, parserOpts);
40
- } catch (error) {
41
- throw new ParserError(`Error parsing "${file.uri}"`, {
42
- cause: error
43
- });
44
- }
45
- }
46
- }
47
- export default JSONParser;
@@ -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 _apidomParserAdapterOpenapiJson = require("@speclynx/apidom-parser-adapter-openapi-json-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 OpenAPIJSON2Parser extends _Parser.default {
18
- refractorOpts;
19
- constructor(options) {
20
- const {
21
- fileExtensions = [],
22
- mediaTypes = _apidomParserAdapterOpenapiJson.mediaTypes,
23
- ...rest
24
- } = options ?? {};
25
- super({
26
- ...rest,
27
- name: 'openapi-json-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, _apidomParserAdapterOpenapiJson.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, _apidomParserAdapterOpenapiJson.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 = OpenAPIJSON2Parser;
@@ -1,48 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as OpenAPI2MediaTypes, detect } from '@speclynx/apidom-parser-adapter-openapi-json-2';
3
- import ParserError from "../../../errors/ParserError.mjs";
4
- import Parser from "../Parser.mjs";
5
- /**
6
- * @public
7
- */
8
- /**
9
- * @public
10
- */
11
- class OpenAPIJSON2Parser extends Parser {
12
- refractorOpts;
13
- constructor(options) {
14
- const {
15
- fileExtensions = [],
16
- mediaTypes = OpenAPI2MediaTypes,
17
- ...rest
18
- } = options ?? {};
19
- super({
20
- ...rest,
21
- name: 'openapi-json-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 OpenAPIJSON2Parser;
@@ -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 _apidomParserAdapterOpenapiJson = require("@speclynx/apidom-parser-adapter-openapi-json-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 OpenAPIJSON3_0Parser extends _Parser.default {
18
- refractorOpts;
19
- constructor(options) {
20
- const {
21
- fileExtensions = [],
22
- mediaTypes = _apidomParserAdapterOpenapiJson.mediaTypes,
23
- ...rest
24
- } = options ?? {};
25
- super({
26
- ...rest,
27
- name: 'openapi-json-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, _apidomParserAdapterOpenapiJson.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, _apidomParserAdapterOpenapiJson.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 = OpenAPIJSON3_0Parser;
@@ -1,48 +0,0 @@
1
- import { pick } from 'ramda';
2
- import { parse, mediaTypes as OpenAPI3_0MediaTypes, detect } from '@speclynx/apidom-parser-adapter-openapi-json-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 OpenAPIJSON3_0Parser extends Parser {
12
- refractorOpts;
13
- constructor(options) {
14
- const {
15
- fileExtensions = [],
16
- mediaTypes = OpenAPI3_0MediaTypes,
17
- ...rest
18
- } = options ?? {};
19
- super({
20
- ...rest,
21
- name: 'openapi-json-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 OpenAPIJSON3_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 _apidomParserAdapterOpenapiJson = require("@speclynx/apidom-parser-adapter-openapi-json-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 OpenAPIJSON3_1Parser extends _Parser.default {
18
- refractorOpts;
19
- constructor(options) {
20
- const {
21
- fileExtensions = [],
22
- mediaTypes = _apidomParserAdapterOpenapiJson.mediaTypes,
23
- ...rest
24
- } = options ?? {};
25
- super({
26
- ...rest,
27
- name: 'openapi-json-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, _apidomParserAdapterOpenapiJson.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, _apidomParserAdapterOpenapiJson.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 = OpenAPIJSON3_1Parser;