@speclynx/apidom-reference 1.12.1

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 (263) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/LICENSE +202 -0
  3. package/LICENSES/AFL-3.0.txt +182 -0
  4. package/LICENSES/Apache-2.0.txt +202 -0
  5. package/LICENSES/BSD-3-Clause.txt +26 -0
  6. package/LICENSES/MIT.txt +9 -0
  7. package/NOTICE +65 -0
  8. package/README.md +2107 -0
  9. package/dist/167.apidom-reference.browser.js +10 -0
  10. package/dist/167.apidom-reference.browser.min.js +1 -0
  11. package/dist/451.apidom-reference.browser.js +10 -0
  12. package/dist/451.apidom-reference.browser.min.js +1 -0
  13. package/dist/9786785aaddf11f37840fad896531940.wasm +0 -0
  14. package/dist/apidom-reference.browser.js +85376 -0
  15. package/dist/apidom-reference.browser.min.js +1 -0
  16. package/package.json +304 -0
  17. package/src/File.cjs +50 -0
  18. package/src/File.mjs +44 -0
  19. package/src/Reference.cjs +31 -0
  20. package/src/Reference.mjs +27 -0
  21. package/src/ReferenceSet.cjs +60 -0
  22. package/src/ReferenceSet.mjs +57 -0
  23. package/src/bundle/index.cjs +61 -0
  24. package/src/bundle/index.mjs +55 -0
  25. package/src/bundle/strategies/BundleStrategy.cjs +20 -0
  26. package/src/bundle/strategies/BundleStrategy.mjs +16 -0
  27. package/src/bundle/strategies/openapi-3-1/index.cjs +35 -0
  28. package/src/bundle/strategies/openapi-3-1/index.mjs +29 -0
  29. package/src/configuration/empty.cjs +9 -0
  30. package/src/configuration/empty.mjs +1 -0
  31. package/src/configuration/saturated.cjs +95 -0
  32. package/src/configuration/saturated.mjs +87 -0
  33. package/src/dereference/index.cjs +86 -0
  34. package/src/dereference/index.mjs +79 -0
  35. package/src/dereference/strategies/DereferenceStrategy.cjs +20 -0
  36. package/src/dereference/strategies/DereferenceStrategy.mjs +16 -0
  37. package/src/dereference/strategies/apidom/index.cjs +89 -0
  38. package/src/dereference/strategies/apidom/index.mjs +84 -0
  39. package/src/dereference/strategies/apidom/selectors/element-id.cjs +36 -0
  40. package/src/dereference/strategies/apidom/selectors/element-id.mjs +30 -0
  41. package/src/dereference/strategies/apidom/visitor.cjs +165 -0
  42. package/src/dereference/strategies/apidom/visitor.mjs +159 -0
  43. package/src/dereference/strategies/asyncapi-2/index.cjs +100 -0
  44. package/src/dereference/strategies/asyncapi-2/index.mjs +94 -0
  45. package/src/dereference/strategies/asyncapi-2/visitor.cjs +412 -0
  46. package/src/dereference/strategies/asyncapi-2/visitor.mjs +406 -0
  47. package/src/dereference/strategies/openapi-2/index.cjs +102 -0
  48. package/src/dereference/strategies/openapi-2/index.mjs +96 -0
  49. package/src/dereference/strategies/openapi-2/visitor.cjs +530 -0
  50. package/src/dereference/strategies/openapi-2/visitor.mjs +524 -0
  51. package/src/dereference/strategies/openapi-3-0/index.cjs +102 -0
  52. package/src/dereference/strategies/openapi-3-0/index.mjs +96 -0
  53. package/src/dereference/strategies/openapi-3-0/visitor.cjs +519 -0
  54. package/src/dereference/strategies/openapi-3-0/visitor.mjs +513 -0
  55. package/src/dereference/strategies/openapi-3-1/index.cjs +105 -0
  56. package/src/dereference/strategies/openapi-3-1/index.mjs +96 -0
  57. package/src/dereference/strategies/openapi-3-1/selectors/$anchor.cjs +66 -0
  58. package/src/dereference/strategies/openapi-3-1/selectors/$anchor.mjs +55 -0
  59. package/src/dereference/strategies/openapi-3-1/selectors/uri.cjs +50 -0
  60. package/src/dereference/strategies/openapi-3-1/selectors/uri.mjs +42 -0
  61. package/src/dereference/strategies/openapi-3-1/util.cjs +67 -0
  62. package/src/dereference/strategies/openapi-3-1/util.mjs +58 -0
  63. package/src/dereference/strategies/openapi-3-1/visitor.cjs +776 -0
  64. package/src/dereference/strategies/openapi-3-1/visitor.mjs +770 -0
  65. package/src/dereference/util.cjs +31 -0
  66. package/src/dereference/util.mjs +27 -0
  67. package/src/errors/BundleError.cjs +10 -0
  68. package/src/errors/BundleError.mjs +7 -0
  69. package/src/errors/DereferenceError.cjs +10 -0
  70. package/src/errors/DereferenceError.mjs +7 -0
  71. package/src/errors/EvaluationElementIdError.cjs +10 -0
  72. package/src/errors/EvaluationElementIdError.mjs +7 -0
  73. package/src/errors/EvaluationJsonSchema$anchorError.cjs +11 -0
  74. package/src/errors/EvaluationJsonSchema$anchorError.mjs +6 -0
  75. package/src/errors/EvaluationJsonSchemaUriError.cjs +11 -0
  76. package/src/errors/EvaluationJsonSchemaUriError.mjs +6 -0
  77. package/src/errors/InvalidJsonSchema$anchorError.cjs +15 -0
  78. package/src/errors/InvalidJsonSchema$anchorError.mjs +10 -0
  79. package/src/errors/JsonSchema$anchorError.cjs +10 -0
  80. package/src/errors/JsonSchema$anchorError.mjs +7 -0
  81. package/src/errors/JsonSchemaUriError.cjs +10 -0
  82. package/src/errors/JsonSchemaUriError.mjs +7 -0
  83. package/src/errors/MaximumBundleDepthError.cjs +11 -0
  84. package/src/errors/MaximumBundleDepthError.mjs +6 -0
  85. package/src/errors/MaximumDereferenceDepthError.cjs +11 -0
  86. package/src/errors/MaximumDereferenceDepthError.mjs +6 -0
  87. package/src/errors/MaximumResolveDepthError.cjs +11 -0
  88. package/src/errors/MaximumResolveDepthError.mjs +6 -0
  89. package/src/errors/ParseError.cjs +10 -0
  90. package/src/errors/ParseError.mjs +7 -0
  91. package/src/errors/ParserError.cjs +11 -0
  92. package/src/errors/ParserError.mjs +6 -0
  93. package/src/errors/PluginError.cjs +18 -0
  94. package/src/errors/PluginError.mjs +15 -0
  95. package/src/errors/ResolveError.cjs +10 -0
  96. package/src/errors/ResolveError.mjs +7 -0
  97. package/src/errors/ResolverError.cjs +11 -0
  98. package/src/errors/ResolverError.mjs +6 -0
  99. package/src/errors/UnmatchedBundleStrategyError.cjs +11 -0
  100. package/src/errors/UnmatchedBundleStrategyError.mjs +6 -0
  101. package/src/errors/UnmatchedDereferenceStrategyError.cjs +11 -0
  102. package/src/errors/UnmatchedDereferenceStrategyError.mjs +6 -0
  103. package/src/errors/UnmatchedResolveStrategyError.cjs +11 -0
  104. package/src/errors/UnmatchedResolveStrategyError.mjs +6 -0
  105. package/src/errors/UnmatchedResolverError.cjs +11 -0
  106. package/src/errors/UnmatchedResolverError.mjs +6 -0
  107. package/src/index.cjs +142 -0
  108. package/src/index.mjs +101 -0
  109. package/src/options/index.cjs +185 -0
  110. package/src/options/index.mjs +182 -0
  111. package/src/options/util.cjs +24 -0
  112. package/src/options/util.mjs +19 -0
  113. package/src/parse/index.cjs +69 -0
  114. package/src/parse/index.mjs +63 -0
  115. package/src/parse/parsers/Parser.cjs +48 -0
  116. package/src/parse/parsers/Parser.mjs +44 -0
  117. package/src/parse/parsers/api-design-systems-json/index.cjs +55 -0
  118. package/src/parse/parsers/api-design-systems-json/index.mjs +49 -0
  119. package/src/parse/parsers/api-design-systems-yaml/index.cjs +54 -0
  120. package/src/parse/parsers/api-design-systems-yaml/index.mjs +48 -0
  121. package/src/parse/parsers/apidom-json/index.cjs +70 -0
  122. package/src/parse/parsers/apidom-json/index.mjs +64 -0
  123. package/src/parse/parsers/arazzo-json-1/index.cjs +55 -0
  124. package/src/parse/parsers/arazzo-json-1/index.mjs +49 -0
  125. package/src/parse/parsers/arazzo-yaml-1/index.cjs +54 -0
  126. package/src/parse/parsers/arazzo-yaml-1/index.mjs +48 -0
  127. package/src/parse/parsers/asyncapi-json-2/index.cjs +55 -0
  128. package/src/parse/parsers/asyncapi-json-2/index.mjs +49 -0
  129. package/src/parse/parsers/asyncapi-yaml-2/index.cjs +54 -0
  130. package/src/parse/parsers/asyncapi-yaml-2/index.mjs +48 -0
  131. package/src/parse/parsers/binary/index-browser.cjs +56 -0
  132. package/src/parse/parsers/binary/index-browser.mjs +50 -0
  133. package/src/parse/parsers/binary/index-node.cjs +51 -0
  134. package/src/parse/parsers/binary/index-node.mjs +45 -0
  135. package/src/parse/parsers/json/index.cjs +54 -0
  136. package/src/parse/parsers/json/index.mjs +48 -0
  137. package/src/parse/parsers/openapi-json-2/index.cjs +55 -0
  138. package/src/parse/parsers/openapi-json-2/index.mjs +49 -0
  139. package/src/parse/parsers/openapi-json-3-0/index.cjs +55 -0
  140. package/src/parse/parsers/openapi-json-3-0/index.mjs +49 -0
  141. package/src/parse/parsers/openapi-json-3-1/index.cjs +55 -0
  142. package/src/parse/parsers/openapi-json-3-1/index.mjs +49 -0
  143. package/src/parse/parsers/openapi-yaml-2/index.cjs +54 -0
  144. package/src/parse/parsers/openapi-yaml-2/index.mjs +48 -0
  145. package/src/parse/parsers/openapi-yaml-3-0/index.cjs +54 -0
  146. package/src/parse/parsers/openapi-yaml-3-0/index.mjs +48 -0
  147. package/src/parse/parsers/openapi-yaml-3-1/index.cjs +54 -0
  148. package/src/parse/parsers/openapi-yaml-3-1/index.mjs +48 -0
  149. package/src/parse/parsers/yaml-1-2/index.cjs +54 -0
  150. package/src/parse/parsers/yaml-1-2/index.mjs +48 -0
  151. package/src/resolve/index.cjs +67 -0
  152. package/src/resolve/index.mjs +60 -0
  153. package/src/resolve/resolvers/HTTPResolver.cjs +38 -0
  154. package/src/resolve/resolvers/HTTPResolver.mjs +31 -0
  155. package/src/resolve/resolvers/Resolver.cjs +20 -0
  156. package/src/resolve/resolvers/Resolver.mjs +16 -0
  157. package/src/resolve/resolvers/file/index-browser.cjs +24 -0
  158. package/src/resolve/resolvers/file/index-browser.mjs +19 -0
  159. package/src/resolve/resolvers/file/index-node.cjs +49 -0
  160. package/src/resolve/resolvers/file/index-node.mjs +42 -0
  161. package/src/resolve/resolvers/http-axios/index.cjs +80 -0
  162. package/src/resolve/resolvers/http-axios/index.mjs +73 -0
  163. package/src/resolve/strategies/ResolveStrategy.cjs +20 -0
  164. package/src/resolve/strategies/ResolveStrategy.mjs +16 -0
  165. package/src/resolve/strategies/apidom/index.cjs +49 -0
  166. package/src/resolve/strategies/apidom/index.mjs +43 -0
  167. package/src/resolve/strategies/asyncapi-2/index.cjs +49 -0
  168. package/src/resolve/strategies/asyncapi-2/index.mjs +43 -0
  169. package/src/resolve/strategies/openapi-2/index.cjs +49 -0
  170. package/src/resolve/strategies/openapi-2/index.mjs +43 -0
  171. package/src/resolve/strategies/openapi-3-0/index.cjs +49 -0
  172. package/src/resolve/strategies/openapi-3-0/index.mjs +43 -0
  173. package/src/resolve/strategies/openapi-3-1/index.cjs +49 -0
  174. package/src/resolve/strategies/openapi-3-1/index.mjs +43 -0
  175. package/src/resolve/util.cjs +37 -0
  176. package/src/resolve/util.mjs +30 -0
  177. package/src/util/plugins.cjs +44 -0
  178. package/src/util/plugins.mjs +37 -0
  179. package/src/util/url.cjs +288 -0
  180. package/src/util/url.mjs +274 -0
  181. package/types/File.d.ts +24 -0
  182. package/types/Reference.d.ts +23 -0
  183. package/types/ReferenceSet.d.ts +25 -0
  184. package/types/apidom-reference.d.ts +584 -0
  185. package/types/bundle/index.d.ts +7 -0
  186. package/types/bundle/strategies/BundleStrategy.d.ts +19 -0
  187. package/types/bundle/strategies/openapi-3-1/index.d.ts +26 -0
  188. package/types/configuration/empty.d.ts +1 -0
  189. package/types/configuration/saturated.d.ts +1 -0
  190. package/types/dereference/index.d.ts +11 -0
  191. package/types/dereference/strategies/DereferenceStrategy.d.ts +19 -0
  192. package/types/dereference/strategies/apidom/index.d.ts +30 -0
  193. package/types/dereference/strategies/apidom/selectors/element-id.d.ts +11 -0
  194. package/types/dereference/strategies/apidom/visitor.d.ts +32 -0
  195. package/types/dereference/strategies/asyncapi-2/index.d.ts +31 -0
  196. package/types/dereference/strategies/asyncapi-2/visitor.d.ts +43 -0
  197. package/types/dereference/strategies/openapi-2/index.d.ts +32 -0
  198. package/types/dereference/strategies/openapi-2/visitor.d.ts +47 -0
  199. package/types/dereference/strategies/openapi-3-0/index.d.ts +31 -0
  200. package/types/dereference/strategies/openapi-3-0/visitor.d.ts +49 -0
  201. package/types/dereference/strategies/openapi-3-1/index.d.ts +32 -0
  202. package/types/dereference/strategies/openapi-3-1/selectors/$anchor.d.ts +22 -0
  203. package/types/dereference/strategies/openapi-3-1/selectors/uri.d.ts +12 -0
  204. package/types/dereference/strategies/openapi-3-1/util.d.ts +21 -0
  205. package/types/dereference/strategies/openapi-3-1/visitor.d.ts +52 -0
  206. package/types/dereference/util.d.ts +9 -0
  207. package/types/errors/BundleError.d.ts +7 -0
  208. package/types/errors/DereferenceError.d.ts +7 -0
  209. package/types/errors/EvaluationElementIdError.d.ts +7 -0
  210. package/types/errors/EvaluationJsonSchema$anchorError.d.ts +7 -0
  211. package/types/errors/EvaluationJsonSchemaUriError.d.ts +7 -0
  212. package/types/errors/InvalidJsonSchema$anchorError.d.ts +8 -0
  213. package/types/errors/JsonSchema$anchorError.d.ts +7 -0
  214. package/types/errors/JsonSchemaUriError.d.ts +7 -0
  215. package/types/errors/MaximumBundleDepthError.d.ts +7 -0
  216. package/types/errors/MaximumDereferenceDepthError.d.ts +7 -0
  217. package/types/errors/MaximumResolveDepthError.d.ts +7 -0
  218. package/types/errors/ParseError.d.ts +7 -0
  219. package/types/errors/ParserError.d.ts +7 -0
  220. package/types/errors/PluginError.d.ts +12 -0
  221. package/types/errors/ResolveError.d.ts +7 -0
  222. package/types/errors/ResolverError.d.ts +7 -0
  223. package/types/errors/UnmatchedBundleStrategyError.d.ts +7 -0
  224. package/types/errors/UnmatchedDereferenceStrategyError.d.ts +7 -0
  225. package/types/errors/UnmatchedResolveStrategyError.d.ts +7 -0
  226. package/types/errors/UnmatchedResolverError.d.ts +7 -0
  227. package/types/index.d.ts +75 -0
  228. package/types/options/index.d.ts +62 -0
  229. package/types/options/util.d.ts +5 -0
  230. package/types/parse/index.d.ts +7 -0
  231. package/types/parse/parsers/Parser.d.ts +38 -0
  232. package/types/parse/parsers/api-design-systems-json/index.d.ts +21 -0
  233. package/types/parse/parsers/api-design-systems-yaml/index.d.ts +20 -0
  234. package/types/parse/parsers/apidom-json/index.d.ts +24 -0
  235. package/types/parse/parsers/arazzo-json-1/index.d.ts +21 -0
  236. package/types/parse/parsers/arazzo-yaml-1/index.d.ts +20 -0
  237. package/types/parse/parsers/asyncapi-json-2/index.d.ts +21 -0
  238. package/types/parse/parsers/asyncapi-yaml-2/index.d.ts +20 -0
  239. package/types/parse/parsers/binary/index-browser.d.ts +21 -0
  240. package/types/parse/parsers/binary/index-node.d.ts +21 -0
  241. package/types/parse/parsers/json/index.d.ts +20 -0
  242. package/types/parse/parsers/openapi-json-2/index.d.ts +21 -0
  243. package/types/parse/parsers/openapi-json-3-0/index.d.ts +21 -0
  244. package/types/parse/parsers/openapi-json-3-1/index.d.ts +21 -0
  245. package/types/parse/parsers/openapi-yaml-2/index.d.ts +20 -0
  246. package/types/parse/parsers/openapi-yaml-3-0/index.d.ts +20 -0
  247. package/types/parse/parsers/openapi-yaml-3-1/index.d.ts +20 -0
  248. package/types/parse/parsers/yaml-1-2/index.d.ts +20 -0
  249. package/types/resolve/index.d.ts +12 -0
  250. package/types/resolve/resolvers/HTTPResolver.d.ts +22 -0
  251. package/types/resolve/resolvers/Resolver.d.ts +17 -0
  252. package/types/resolve/resolvers/file/index-browser.d.ts +12 -0
  253. package/types/resolve/resolvers/file/index-node.d.ts +20 -0
  254. package/types/resolve/resolvers/http-axios/index.d.ts +30 -0
  255. package/types/resolve/strategies/ResolveStrategy.d.ts +19 -0
  256. package/types/resolve/strategies/apidom/index.d.ts +27 -0
  257. package/types/resolve/strategies/asyncapi-2/index.d.ts +27 -0
  258. package/types/resolve/strategies/openapi-2/index.d.ts +27 -0
  259. package/types/resolve/strategies/openapi-3-0/index.d.ts +27 -0
  260. package/types/resolve/strategies/openapi-3-1/index.d.ts +27 -0
  261. package/types/resolve/util.d.ts +6 -0
  262. package/types/util/plugins.d.ts +14 -0
  263. package/types/util/url.d.ts +106 -0
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @public
3
+ */
4
+
5
+ /**
6
+ * @public
7
+ */
8
+ class Parser {
9
+ name;
10
+
11
+ /**
12
+ * Whether to allow "empty" files. This includes zero-byte files.
13
+ */
14
+ allowEmpty;
15
+
16
+ /**
17
+ * Whether to generate source map during parsing.
18
+ */
19
+ sourceMap;
20
+
21
+ /**
22
+ * List of supported file extensions.
23
+ */
24
+ fileExtensions;
25
+
26
+ /**
27
+ * List of supported media types.
28
+ */
29
+ mediaTypes;
30
+ constructor({
31
+ name,
32
+ allowEmpty = true,
33
+ sourceMap = false,
34
+ fileExtensions = [],
35
+ mediaTypes = []
36
+ }) {
37
+ this.name = name;
38
+ this.allowEmpty = allowEmpty;
39
+ this.sourceMap = sourceMap;
40
+ this.fileExtensions = fileExtensions;
41
+ this.mediaTypes = mediaTypes;
42
+ }
43
+ }
44
+ export default Parser;
@@ -0,0 +1,55 @@
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 _apidomParserAdapterApiDesignSystemsJson = require("@speclynx/apidom-parser-adapter-api-design-systems-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 APIDesignSystemsJSONParser extends _Parser.default {
18
+ syntacticAnalysis;
19
+ refractorOpts;
20
+ constructor(options) {
21
+ const {
22
+ fileExtensions = [],
23
+ mediaTypes = _apidomParserAdapterApiDesignSystemsJson.mediaTypes,
24
+ ...rest
25
+ } = options ?? {};
26
+ super({
27
+ ...rest,
28
+ name: 'api-design-systems-json',
29
+ fileExtensions,
30
+ mediaTypes
31
+ });
32
+ }
33
+ async canParse(file) {
34
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
35
+ const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
36
+ if (!hasSupportedFileExtension) return false;
37
+ if (hasSupportedMediaType) return true;
38
+ if (!hasSupportedMediaType) {
39
+ return (0, _apidomParserAdapterApiDesignSystemsJson.detect)(file.toString());
40
+ }
41
+ return false;
42
+ }
43
+ async parse(file) {
44
+ const source = file.toString();
45
+ try {
46
+ const parserOpts = (0, _ramda.pick)(['sourceMap', 'syntacticAnalysis', 'refractorOpts'], this);
47
+ return await (0, _apidomParserAdapterApiDesignSystemsJson.parse)(source, parserOpts);
48
+ } catch (error) {
49
+ throw new _ParserError.default(`Error parsing "${file.uri}"`, {
50
+ cause: error
51
+ });
52
+ }
53
+ }
54
+ }
55
+ var _default = exports.default = APIDesignSystemsJSONParser;
@@ -0,0 +1,49 @@
1
+ import { pick } from 'ramda';
2
+ import { parse, mediaTypes as ADSMediaTypes, detect } from '@speclynx/apidom-parser-adapter-api-design-systems-json';
3
+ import ParserError from "../../../errors/ParserError.mjs";
4
+ import Parser from "../Parser.mjs";
5
+ /**
6
+ * @public
7
+ */
8
+ /**
9
+ * @public
10
+ */
11
+ class APIDesignSystemsJSONParser extends Parser {
12
+ syntacticAnalysis;
13
+ refractorOpts;
14
+ constructor(options) {
15
+ const {
16
+ fileExtensions = [],
17
+ mediaTypes = ADSMediaTypes,
18
+ ...rest
19
+ } = options ?? {};
20
+ super({
21
+ ...rest,
22
+ name: 'api-design-systems-json',
23
+ fileExtensions,
24
+ mediaTypes
25
+ });
26
+ }
27
+ async canParse(file) {
28
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
29
+ const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
30
+ if (!hasSupportedFileExtension) return false;
31
+ if (hasSupportedMediaType) return true;
32
+ if (!hasSupportedMediaType) {
33
+ return detect(file.toString());
34
+ }
35
+ return false;
36
+ }
37
+ async parse(file) {
38
+ const source = file.toString();
39
+ try {
40
+ const parserOpts = pick(['sourceMap', 'syntacticAnalysis', 'refractorOpts'], this);
41
+ return await parse(source, parserOpts);
42
+ } catch (error) {
43
+ throw new ParserError(`Error parsing "${file.uri}"`, {
44
+ cause: error
45
+ });
46
+ }
47
+ }
48
+ }
49
+ export default APIDesignSystemsJSONParser;
@@ -0,0 +1,54 @@
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 _apidomParserAdapterApiDesignSystemsYaml = require("@speclynx/apidom-parser-adapter-api-design-systems-yaml");
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 APIDesignSystemsYAMLParser extends _Parser.default {
18
+ refractorOpts;
19
+ constructor(options) {
20
+ const {
21
+ fileExtensions = [],
22
+ mediaTypes = _apidomParserAdapterApiDesignSystemsYaml.mediaTypes,
23
+ ...rest
24
+ } = options ?? {};
25
+ super({
26
+ ...rest,
27
+ name: 'api-design-systems-yaml',
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, _apidomParserAdapterApiDesignSystemsYaml.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', 'refractorOpts'], this);
46
+ return await (0, _apidomParserAdapterApiDesignSystemsYaml.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 = APIDesignSystemsYAMLParser;
@@ -0,0 +1,48 @@
1
+ import { pick } from 'ramda';
2
+ import { parse, mediaTypes as ADSMediaTypes, detect } from '@speclynx/apidom-parser-adapter-api-design-systems-yaml';
3
+ import ParserError from "../../../errors/ParserError.mjs";
4
+ import Parser from "../Parser.mjs";
5
+ /**
6
+ * @public
7
+ */
8
+ /**
9
+ * @public
10
+ */
11
+ class APIDesignSystemsYAMLParser extends Parser {
12
+ refractorOpts;
13
+ constructor(options) {
14
+ const {
15
+ fileExtensions = [],
16
+ mediaTypes = ADSMediaTypes,
17
+ ...rest
18
+ } = options ?? {};
19
+ super({
20
+ ...rest,
21
+ name: 'api-design-systems-yaml',
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', '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 APIDesignSystemsYAMLParser;
@@ -0,0 +1,70 @@
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 _apidomCore = require("@speclynx/apidom-core");
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 ApiDOMJSONParser extends _Parser.default {
17
+ namespace;
18
+ ['apidom-json'];
19
+ constructor(options) {
20
+ const {
21
+ fileExtensions = [],
22
+ mediaTypes = ['application/vnd.apidom', 'application/vnd.apidom+json'],
23
+ namespace = _apidomCore.namespace,
24
+ ...rest
25
+ } = options ?? {};
26
+ super({
27
+ ...rest,
28
+ name: 'apidom-json',
29
+ fileExtensions,
30
+ mediaTypes
31
+ });
32
+ this.namespace = namespace;
33
+ }
34
+ canParse(file) {
35
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
36
+ const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
37
+ if (!hasSupportedFileExtension) return false;
38
+ if (hasSupportedMediaType) return true;
39
+ if (!hasSupportedMediaType) {
40
+ try {
41
+ return this.namespace.fromRefract(JSON.parse(file.toString())) && true;
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ return false;
47
+ }
48
+ parse(file) {
49
+ const source = file.toString();
50
+ const namespace = this['apidom-json']?.namespace ?? this.namespace;
51
+
52
+ // allow empty files
53
+ if (this.allowEmpty && source.trim() === '') {
54
+ return new _apidomCore.ParseResultElement();
55
+ }
56
+ try {
57
+ const element = namespace.fromRefract(JSON.parse(source));
58
+ if (!(0, _apidomCore.isParseResultElement)(element)) {
59
+ element.classes.push('result');
60
+ return new _apidomCore.ParseResultElement([element]);
61
+ }
62
+ return element;
63
+ } catch (error) {
64
+ throw new _ParserError.default(`Error parsing "${file.uri}"`, {
65
+ cause: error
66
+ });
67
+ }
68
+ }
69
+ }
70
+ var _default = exports.default = ApiDOMJSONParser;
@@ -0,0 +1,64 @@
1
+ import { ParseResultElement, isParseResultElement, namespace as baseNamespace } from '@speclynx/apidom-core';
2
+ import ParserError from "../../../errors/ParserError.mjs";
3
+ import Parser from "../Parser.mjs";
4
+ /**
5
+ * @public
6
+ */
7
+ /**
8
+ * @public
9
+ */
10
+ class ApiDOMJSONParser extends Parser {
11
+ namespace;
12
+ ['apidom-json'];
13
+ constructor(options) {
14
+ const {
15
+ fileExtensions = [],
16
+ mediaTypes = ['application/vnd.apidom', 'application/vnd.apidom+json'],
17
+ namespace = baseNamespace,
18
+ ...rest
19
+ } = options ?? {};
20
+ super({
21
+ ...rest,
22
+ name: 'apidom-json',
23
+ fileExtensions,
24
+ mediaTypes
25
+ });
26
+ this.namespace = namespace;
27
+ }
28
+ canParse(file) {
29
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
30
+ const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
31
+ if (!hasSupportedFileExtension) return false;
32
+ if (hasSupportedMediaType) return true;
33
+ if (!hasSupportedMediaType) {
34
+ try {
35
+ return this.namespace.fromRefract(JSON.parse(file.toString())) && true;
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+ return false;
41
+ }
42
+ parse(file) {
43
+ const source = file.toString();
44
+ const namespace = this['apidom-json']?.namespace ?? this.namespace;
45
+
46
+ // allow empty files
47
+ if (this.allowEmpty && source.trim() === '') {
48
+ return new ParseResultElement();
49
+ }
50
+ try {
51
+ const element = namespace.fromRefract(JSON.parse(source));
52
+ if (!isParseResultElement(element)) {
53
+ element.classes.push('result');
54
+ return new ParseResultElement([element]);
55
+ }
56
+ return element;
57
+ } catch (error) {
58
+ throw new ParserError(`Error parsing "${file.uri}"`, {
59
+ cause: error
60
+ });
61
+ }
62
+ }
63
+ }
64
+ export default ApiDOMJSONParser;
@@ -0,0 +1,55 @@
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 _apidomParserAdapterArazzoJson = require("@speclynx/apidom-parser-adapter-arazzo-json-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 ArazzoJSON1Parser extends _Parser.default {
18
+ syntacticAnalysis;
19
+ refractorOpts;
20
+ constructor(options) {
21
+ const {
22
+ fileExtensions = [],
23
+ mediaTypes = _apidomParserAdapterArazzoJson.mediaTypes,
24
+ ...rest
25
+ } = options ?? {};
26
+ super({
27
+ ...rest,
28
+ name: 'arazzo-json-1',
29
+ fileExtensions,
30
+ mediaTypes
31
+ });
32
+ }
33
+ async canParse(file) {
34
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
35
+ const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
36
+ if (!hasSupportedFileExtension) return false;
37
+ if (hasSupportedMediaType) return true;
38
+ if (!hasSupportedMediaType) {
39
+ return (0, _apidomParserAdapterArazzoJson.detect)(file.toString());
40
+ }
41
+ return false;
42
+ }
43
+ async parse(file) {
44
+ const source = file.toString();
45
+ try {
46
+ const parserOpts = (0, _ramda.pick)(['sourceMap', 'syntacticAnalysis', 'refractorOpts'], this);
47
+ return await (0, _apidomParserAdapterArazzoJson.parse)(source, parserOpts);
48
+ } catch (error) {
49
+ throw new _ParserError.default(`Error parsing "${file.uri}"`, {
50
+ cause: error
51
+ });
52
+ }
53
+ }
54
+ }
55
+ var _default = exports.default = ArazzoJSON1Parser;
@@ -0,0 +1,49 @@
1
+ import { pick } from 'ramda';
2
+ import { parse, mediaTypes as Arazzo1MediaTypes, detect } from '@speclynx/apidom-parser-adapter-arazzo-json-1';
3
+ import ParserError from "../../../errors/ParserError.mjs";
4
+ import Parser from "../Parser.mjs";
5
+ /**
6
+ * @public
7
+ */
8
+ /**
9
+ * @public
10
+ */
11
+ class ArazzoJSON1Parser extends Parser {
12
+ syntacticAnalysis;
13
+ refractorOpts;
14
+ constructor(options) {
15
+ const {
16
+ fileExtensions = [],
17
+ mediaTypes = Arazzo1MediaTypes,
18
+ ...rest
19
+ } = options ?? {};
20
+ super({
21
+ ...rest,
22
+ name: 'arazzo-json-1',
23
+ fileExtensions,
24
+ mediaTypes
25
+ });
26
+ }
27
+ async canParse(file) {
28
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
29
+ const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
30
+ if (!hasSupportedFileExtension) return false;
31
+ if (hasSupportedMediaType) return true;
32
+ if (!hasSupportedMediaType) {
33
+ return detect(file.toString());
34
+ }
35
+ return false;
36
+ }
37
+ async parse(file) {
38
+ const source = file.toString();
39
+ try {
40
+ const parserOpts = pick(['sourceMap', 'syntacticAnalysis', 'refractorOpts'], this);
41
+ return await parse(source, parserOpts);
42
+ } catch (error) {
43
+ throw new ParserError(`Error parsing "${file.uri}"`, {
44
+ cause: error
45
+ });
46
+ }
47
+ }
48
+ }
49
+ export default ArazzoJSON1Parser;
@@ -0,0 +1,54 @@
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 _apidomParserAdapterArazzoYaml = require("@speclynx/apidom-parser-adapter-arazzo-yaml-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 ArazzoYAML1Parser extends _Parser.default {
18
+ refractorOpts;
19
+ constructor(options) {
20
+ const {
21
+ fileExtensions = [],
22
+ mediaTypes = _apidomParserAdapterArazzoYaml.mediaTypes,
23
+ ...rest
24
+ } = options ?? {};
25
+ super({
26
+ ...rest,
27
+ name: 'arazzo-yaml-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, _apidomParserAdapterArazzoYaml.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', 'refractorOpts'], this);
46
+ return await (0, _apidomParserAdapterArazzoYaml.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 = ArazzoYAML1Parser;
@@ -0,0 +1,48 @@
1
+ import { pick } from 'ramda';
2
+ import { parse, mediaTypes as ArazzoYAML1MediaTypes, detect } from '@speclynx/apidom-parser-adapter-arazzo-yaml-1';
3
+ import ParserError from "../../../errors/ParserError.mjs";
4
+ import Parser from "../Parser.mjs";
5
+ /**
6
+ * @public
7
+ */
8
+ /**
9
+ * @public
10
+ */
11
+ class ArazzoYAML1Parser extends Parser {
12
+ refractorOpts;
13
+ constructor(options) {
14
+ const {
15
+ fileExtensions = [],
16
+ mediaTypes = ArazzoYAML1MediaTypes,
17
+ ...rest
18
+ } = options ?? {};
19
+ super({
20
+ ...rest,
21
+ name: 'arazzo-yaml-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', '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 ArazzoYAML1Parser;
@@ -0,0 +1,55 @@
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 _apidomParserAdapterAsyncapiJson = require("@speclynx/apidom-parser-adapter-asyncapi-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 AsyncAPIJSON2Parser extends _Parser.default {
18
+ syntacticAnalysis;
19
+ refractorOpts;
20
+ constructor(options) {
21
+ const {
22
+ fileExtensions = [],
23
+ mediaTypes = _apidomParserAdapterAsyncapiJson.mediaTypes,
24
+ ...rest
25
+ } = options ?? {};
26
+ super({
27
+ ...rest,
28
+ name: 'asyncapi-json-2',
29
+ fileExtensions,
30
+ mediaTypes
31
+ });
32
+ }
33
+ async canParse(file) {
34
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
35
+ const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
36
+ if (!hasSupportedFileExtension) return false;
37
+ if (hasSupportedMediaType) return true;
38
+ if (!hasSupportedMediaType) {
39
+ return (0, _apidomParserAdapterAsyncapiJson.detect)(file.toString());
40
+ }
41
+ return false;
42
+ }
43
+ async parse(file) {
44
+ const source = file.toString();
45
+ try {
46
+ const parserOpts = (0, _ramda.pick)(['sourceMap', 'syntacticAnalysis', 'refractorOpts'], this);
47
+ return await (0, _apidomParserAdapterAsyncapiJson.parse)(source, parserOpts);
48
+ } catch (error) {
49
+ throw new _ParserError.default(`Error parsing "${file.uri}"`, {
50
+ cause: error
51
+ });
52
+ }
53
+ }
54
+ }
55
+ var _default = exports.default = AsyncAPIJSON2Parser;