@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,584 @@
1
+ import { ApiDOMError } from '@speclynx/apidom-error';
2
+ import { Element as Element_2 } from 'minim';
3
+ import { Element as Element_3 } from '@speclynx/apidom-core';
4
+ import { ParseResultElement } from '@speclynx/apidom-core';
5
+ import { RefElement } from 'minim';
6
+
7
+ /**
8
+ * @public
9
+ */
10
+ export declare interface ApiDOMReferenceBundleOptions {
11
+ strategies: Array<BundleStrategy>;
12
+ refSet: null | ReferenceSet;
13
+ maxDepth: number;
14
+ }
15
+
16
+ /**
17
+ * @public
18
+ */
19
+ export declare interface ApiDOMReferenceDereferenceOptions {
20
+ strategies: Array<DereferenceStrategy>;
21
+ strategyOpts: Record<string, any>;
22
+ refSet: null | ReferenceSet;
23
+ maxDepth: number;
24
+ circular: 'ignore' | 'replace' | 'error';
25
+ circularReplacer: (ref: RefElement) => unknown;
26
+ immutable: boolean;
27
+ }
28
+
29
+ /**
30
+ * @public
31
+ */
32
+ export declare interface ApiDOMReferenceOptions {
33
+ readonly parse: ApiDOMReferenceParseOptions;
34
+ readonly resolve: ApiDOMReferenceResolveOptions;
35
+ readonly dereference: ApiDOMReferenceDereferenceOptions;
36
+ readonly bundle: ApiDOMReferenceBundleOptions;
37
+ }
38
+
39
+ /**
40
+ * @public
41
+ */
42
+ export declare interface ApiDOMReferenceParseOptions {
43
+ mediaType: string;
44
+ parsers: Array<Parser>;
45
+ parserOpts: Record<string, any>;
46
+ }
47
+
48
+ /**
49
+ * @public
50
+ */
51
+ export declare interface ApiDOMReferenceResolveOptions {
52
+ baseURI: string;
53
+ resolvers: Array<Resolver>;
54
+ resolverOpts: Record<string, any>;
55
+ strategies: Array<ResolveStrategy>;
56
+ strategyOpts: Record<string, any>;
57
+ internal: boolean;
58
+ external: boolean;
59
+ maxDepth: number;
60
+ }
61
+
62
+ /**
63
+ * @public
64
+ */
65
+ export declare const bundle: (uri: string, options?: {}) => Promise<ParseResultElement>;
66
+
67
+ /**
68
+ * @public
69
+ */
70
+ export declare class BundleError extends ApiDOMError {
71
+ }
72
+
73
+ /**
74
+ * @public
75
+ */
76
+ export declare abstract class BundleStrategy {
77
+ readonly name: string;
78
+ constructor({ name }: BundleStrategyOptions);
79
+ abstract canBundle(file: File_2, options: ApiDOMReferenceOptions): boolean;
80
+ abstract bundle(file: File_2, options: ApiDOMReferenceOptions): Promise<ParseResultElement>;
81
+ }
82
+
83
+ /**
84
+ * @public
85
+ */
86
+ export declare interface BundleStrategyOptions {
87
+ readonly name: string;
88
+ }
89
+
90
+ /**
91
+ * Returns the current working directory (in Node) or the current page URL (in browsers).
92
+ * @public
93
+ */
94
+ declare const cwd: () => string;
95
+
96
+ /**
97
+ * @public
98
+ */
99
+ export declare const dereference: (uri: string, options?: {}) => Promise<ParseResultElement>;
100
+
101
+ /**
102
+ * @public
103
+ */
104
+ export declare class DereferenceAncestorLineage<T extends Element_3> extends Array<Set<T>> {
105
+ includesCycle(element: T): boolean;
106
+ includes(searchElement: Set<T> | T, fromIndex?: number): boolean;
107
+ findItem(predicate: (item: T) => boolean): T | undefined;
108
+ }
109
+
110
+ /**
111
+ * @public
112
+ */
113
+ export declare const dereferenceApiDOM: <T extends Element_3>(element: T, options?: {}) => Promise<T>;
114
+
115
+ /**
116
+ * @public
117
+ */
118
+ export declare class DereferenceError extends ApiDOMError {
119
+ }
120
+
121
+ /**
122
+ * @public
123
+ */
124
+ export declare abstract class DereferenceStrategy {
125
+ readonly name: string;
126
+ constructor({ name }: DereferenceStrategyOptions);
127
+ abstract canDereference(file: File_2, options: ApiDOMReferenceOptions): boolean;
128
+ abstract dereference(file: File_2, options: ApiDOMReferenceOptions): Promise<Element_2>;
129
+ }
130
+
131
+ /**
132
+ * @public
133
+ */
134
+ export declare interface DereferenceStrategyOptions {
135
+ readonly name: string;
136
+ }
137
+
138
+ /**
139
+ * @public
140
+ */
141
+ export declare class EvaluationElementIdError extends ApiDOMError {
142
+ }
143
+
144
+ /**
145
+ * @public
146
+ */
147
+ export declare class EvaluationJsonSchema$anchorError extends JsonSchema$anchorError {
148
+ }
149
+
150
+ /**
151
+ * @public
152
+ */
153
+ export declare class EvaluationJsonSchemaUriError extends JsonSchemaURIError {
154
+ }
155
+
156
+ /**
157
+ * @public
158
+ */
159
+ declare class File_2 {
160
+ uri: string;
161
+ mediaType: string;
162
+ data?: Buffer | DataView | ArrayBuffer | Uint8Array | string;
163
+ parseResult?: ParseResultElement;
164
+ constructor({ uri, mediaType, data, parseResult }: FileOptions);
165
+ get extension(): string;
166
+ toString(): string;
167
+ }
168
+ export { File_2 as File }
169
+
170
+ /**
171
+ * This class represents a File object with url and data.
172
+ * @public
173
+ */
174
+ export declare interface FileOptions {
175
+ readonly uri: string;
176
+ readonly mediaType?: string;
177
+ readonly data?: Buffer | DataView | ArrayBuffer | Uint8Array | string;
178
+ readonly parseResult?: ParseResultElement;
179
+ }
180
+
181
+ /**
182
+ * Converts a filesystem path to a properly-encoded URL.
183
+ *
184
+ * This is intended to handle situations where resolver is called
185
+ * with a filesystem path that contains characters which are not allowed in URLs.
186
+ *
187
+ * @example
188
+ * The following filesystem paths would be converted to the following URLs:
189
+ *```
190
+ * <"!@#$%^&*+=?'>.json ==> %3C%22!@%23$%25%5E&*+=%3F\'%3E.json
191
+ * C:\\My Documents\\File (1).json ==> C:/My%20Documents/File%20(1).json
192
+ * file://Project #42/file.json ==> file://Project%20%2342/file.json
193
+ * ```
194
+ * @public
195
+ */
196
+ declare const fromFileSystemPath: (uri: string) => string;
197
+
198
+ /**
199
+ * Returns the lower-cased file extension of the given URL,
200
+ * or an empty string if it has no extension.
201
+ * @public
202
+ */
203
+ declare const getExtension: (url: string) => string;
204
+
205
+ /**
206
+ * Returns the hash (URL fragment), of the given path.
207
+ * If there is no hash, then the root hash ("#") is returned.
208
+ * @public
209
+ */
210
+ declare const getHash: (uri: string) => string;
211
+
212
+ /**
213
+ * Returns the protocol of the given URL, or `undefined` if it has no protocol.
214
+ * @public
215
+ */
216
+ declare const getProtocol: (url: string) => string | undefined;
217
+
218
+ /**
219
+ * Returns true if given URL has protocol.
220
+ * @public
221
+ */
222
+ declare const hasProtocol: (url: string) => boolean;
223
+
224
+ /**
225
+ * @public
226
+ */
227
+ export declare abstract class HTTPResolver extends Resolver {
228
+ protected readonly timeout: number;
229
+ protected readonly redirects: number;
230
+ protected readonly withCredentials: boolean;
231
+ constructor(options?: HTTPResolverOptions);
232
+ canRead(file: File_2): boolean;
233
+ abstract getHttpClient(): unknown;
234
+ }
235
+
236
+ /**
237
+ * @public
238
+ */
239
+ export declare interface HTTPResolverOptions extends ResolverOptions {
240
+ readonly timeout?: number;
241
+ readonly redirects?: number;
242
+ readonly withCredentials?: boolean;
243
+ }
244
+
245
+ /**
246
+ * @public
247
+ */
248
+ export declare class InvalidJsonSchema$anchorError extends JsonSchema$anchorError {
249
+ constructor(anchor: string);
250
+ }
251
+
252
+ /**
253
+ * Determines whether the given path is a filesystem path.
254
+ * This includes "file://" URLs.
255
+ * @public
256
+ */
257
+ declare const isFileSystemPath: (uri: string) => boolean;
258
+
259
+ /**
260
+ * Determines whether the given URI is an HTTP(S) URL.
261
+ * @public
262
+ */
263
+ declare const isHttpUrl: (url: string) => boolean;
264
+
265
+ /**
266
+ * Determines whether the given URI
267
+ * @public
268
+ */
269
+ declare const isURI: (uri: string) => boolean;
270
+
271
+ /**
272
+ * @public
273
+ */
274
+ export declare class JsonSchema$anchorError extends ApiDOMError {
275
+ }
276
+
277
+ /**
278
+ * @public
279
+ */
280
+ export declare class JsonSchemaURIError extends ApiDOMError {
281
+ }
282
+
283
+ /**
284
+ * @public
285
+ */
286
+ export declare class MaximumBundleDepthError extends BundleError {
287
+ }
288
+
289
+ /**
290
+ * @public
291
+ */
292
+ export declare class MaximumDereferenceDepthError extends DereferenceError {
293
+ }
294
+
295
+ /**
296
+ * @public
297
+ */
298
+ export declare class MaximumResolveDepthError extends ResolveError {
299
+ }
300
+
301
+ /**
302
+ * @public
303
+ */
304
+ export declare const mergeOptions: (lObj: ApiDOMReferenceOptions, rObj: Record<string, any>) => ApiDOMReferenceOptions;
305
+
306
+ /**
307
+ * @public
308
+ */
309
+ export declare const options: ApiDOMReferenceOptions;
310
+
311
+ /**
312
+ * @public
313
+ */
314
+ export declare const parse: (uri: string, options?: {}) => Promise<ParseResultElement>;
315
+
316
+ /**
317
+ * @public
318
+ */
319
+ export declare class ParseError extends ApiDOMError {
320
+ }
321
+
322
+ /**
323
+ * @public
324
+ */
325
+ export declare abstract class Parser {
326
+ readonly name: string;
327
+ /**
328
+ * Whether to allow "empty" files. This includes zero-byte files.
329
+ */
330
+ allowEmpty: boolean;
331
+ /**
332
+ * Whether to generate source map during parsing.
333
+ */
334
+ sourceMap: boolean;
335
+ /**
336
+ * List of supported file extensions.
337
+ */
338
+ fileExtensions: string[];
339
+ /**
340
+ * List of supported media types.
341
+ */
342
+ mediaTypes: string[];
343
+ constructor({ name, allowEmpty, sourceMap, fileExtensions, mediaTypes, }: ParserOptions);
344
+ abstract canParse(file: File_2): boolean | Promise<boolean>;
345
+ abstract parse(file: File_2): ParseResultElement | Promise<ParseResultElement>;
346
+ }
347
+
348
+ /**
349
+ * @public
350
+ */
351
+ export declare class ParserError extends ParseError {
352
+ }
353
+
354
+ /**
355
+ * @public
356
+ */
357
+ export declare interface ParserOptions {
358
+ readonly name: string;
359
+ readonly allowEmpty?: boolean;
360
+ readonly sourceMap?: boolean;
361
+ readonly fileExtensions?: string[];
362
+ readonly mediaTypes?: string[];
363
+ }
364
+
365
+ /**
366
+ * @public
367
+ */
368
+ export declare class PluginError extends ApiDOMError {
369
+ plugin: any;
370
+ constructor(message: string, options: {
371
+ cause?: Error;
372
+ plugin: any;
373
+ });
374
+ }
375
+
376
+ /**
377
+ * @public
378
+ */
379
+ export declare const readFile: (uri: string, options?: {}) => Promise<Buffer>;
380
+
381
+ /**
382
+ * @public
383
+ */
384
+ export declare class Reference<T = Element_3> {
385
+ readonly uri: string;
386
+ readonly depth: number;
387
+ readonly value: T;
388
+ refSet?: ReferenceSet;
389
+ readonly errors: Array<Error>;
390
+ constructor({ uri, depth, refSet, value }: ReferenceOptions<T>);
391
+ }
392
+
393
+ /**
394
+ * @public
395
+ */
396
+ export declare interface ReferenceOptions<T = Element_3> {
397
+ readonly uri: string;
398
+ readonly depth?: number;
399
+ readonly refSet?: ReferenceSet;
400
+ readonly value: T;
401
+ }
402
+
403
+ /**
404
+ * @public
405
+ */
406
+ export declare class ReferenceSet {
407
+ rootRef?: Reference;
408
+ readonly refs: Reference[];
409
+ circular: boolean;
410
+ constructor({ refs, circular }?: ReferenceSetOptions);
411
+ get size(): number;
412
+ add(reference: Reference): this;
413
+ merge(anotherRefSet: this): this;
414
+ has(thing: string | Reference): boolean;
415
+ find(predicate: (value: Reference, index: number, obj: Reference[]) => boolean): Reference | undefined;
416
+ values(): Generator<Reference<Element_2>, void, unknown>;
417
+ clean(): void;
418
+ }
419
+
420
+ /**
421
+ * @public
422
+ */
423
+ export declare interface ReferenceSetOptions {
424
+ readonly refs?: Reference[];
425
+ readonly circular?: boolean;
426
+ }
427
+
428
+ /**
429
+ * @public
430
+ */
431
+ export declare const resolve: (uri: string, options?: {}) => Promise<ReferenceSet>;
432
+
433
+ /**
434
+ * Resolves a target URI relative to a base URI in a manner similar to that of a Web browser resolving an anchor tag HREF.
435
+ * @public
436
+ */
437
+ declare const resolve_2: (from: string, to: string) => string;
438
+
439
+ /**
440
+ * @public
441
+ */
442
+ export declare const resolveApiDOM: <T extends Element_3>(element: T, options?: {}) => Promise<ReferenceSet>;
443
+
444
+ /**
445
+ * @public
446
+ */
447
+ export declare class ResolveError extends ApiDOMError {
448
+ }
449
+
450
+ /**
451
+ * @public
452
+ */
453
+ export declare abstract class Resolver {
454
+ readonly name: string;
455
+ constructor({ name }: ResolverOptions);
456
+ abstract canRead(file: File_2): boolean;
457
+ abstract read(file: File_2): Promise<Buffer>;
458
+ }
459
+
460
+ /**
461
+ * @public
462
+ */
463
+ export declare class ResolverError extends ResolveError {
464
+ }
465
+
466
+ /**
467
+ * @public
468
+ */
469
+ export declare interface ResolverOptions {
470
+ readonly name: string;
471
+ }
472
+
473
+ /**
474
+ * @public
475
+ */
476
+ export declare abstract class ResolveStrategy {
477
+ readonly name: string;
478
+ constructor({ name }: ResolveStrategyOptions);
479
+ abstract canResolve(file: File_2, options: ApiDOMReferenceOptions): boolean;
480
+ abstract resolve(file: File_2, options: ApiDOMReferenceOptions): Promise<ReferenceSet>;
481
+ }
482
+
483
+ /**
484
+ * @public
485
+ */
486
+ export declare interface ResolveStrategyOptions {
487
+ readonly name: string;
488
+ }
489
+
490
+ /**
491
+ * Sanitizes/Encodes URI to it's url encoded form.
492
+ *
493
+ * The functional will compensate with the usecase when
494
+ * already sanitized URI is passed to it,
495
+ * by first unsatizing it and then performing sanitization again.
496
+ * @public
497
+ */
498
+ declare const sanitize: (uri: string) => string;
499
+
500
+ /**
501
+ * Removes the hash (URL fragment), if any, from the given path.
502
+ * @public
503
+ */
504
+ declare const stripHash: (uri: string) => string;
505
+
506
+ /**
507
+ * Converts a URL to a local filesystem path.
508
+ * @public
509
+ */
510
+ declare const toFileSystemPath: (uri: string, options?: ToFileSystemPathOptions) => string;
511
+
512
+ /**
513
+ * @public
514
+ */
515
+ declare interface ToFileSystemPathOptions {
516
+ keepFileProtocol?: boolean;
517
+ isWindows?: WindowsPredicate;
518
+ }
519
+
520
+ /**
521
+ * @public
522
+ */
523
+ export declare class UnmatchedBundleStrategyError extends BundleError {
524
+ }
525
+
526
+ /**
527
+ * @public
528
+ */
529
+ export declare class UnmatchedDereferenceStrategyError extends DereferenceError {
530
+ }
531
+
532
+ /**
533
+ * @public
534
+ */
535
+ export declare class UnmatchedResolverError extends ResolverError {
536
+ }
537
+
538
+ /**
539
+ * @public
540
+ */
541
+ export declare class UnmatchedResolveStrategyError extends ResolveError {
542
+ }
543
+
544
+ /**
545
+ * Unsanitizes/Decodes URI to it's url encoded form.
546
+ * This function already assumes that hash part of the URI
547
+ * has been removed prior to transforming it to it's sanitized form.
548
+ * @public
549
+ */
550
+ declare const unsanitize: (uri: string) => string;
551
+
552
+ declare namespace url {
553
+ export {
554
+ WindowsPredicate,
555
+ getProtocol,
556
+ hasProtocol,
557
+ getExtension,
558
+ isFileSystemPath,
559
+ isHttpUrl,
560
+ isURI,
561
+ ToFileSystemPathOptions,
562
+ toFileSystemPath,
563
+ fromFileSystemPath,
564
+ getHash,
565
+ stripHash,
566
+ cwd,
567
+ resolve_2 as resolve,
568
+ sanitize,
569
+ unsanitize
570
+ }
571
+ }
572
+ export { url }
573
+
574
+ /**
575
+ * SPDX-FileCopyrightText: Copyright (c) 2015 James Messinger
576
+ *
577
+ * SPDX-License-Identifier: MIT
578
+ */
579
+ /**
580
+ * @public
581
+ */
582
+ declare type WindowsPredicate = () => boolean;
583
+
584
+ export { }
@@ -0,0 +1,7 @@
1
+ import { ParseResultElement } from '@speclynx/apidom-core';
2
+ import type { ReferenceOptions } from '../options/index.ts';
3
+ /**
4
+ * Bundle a file with all its external references to a compound document.
5
+ */
6
+ declare const bundle: (uri: string, options: ReferenceOptions) => Promise<ParseResultElement>;
7
+ export default bundle;
@@ -0,0 +1,19 @@
1
+ import { ParseResultElement } from '@speclynx/apidom-core';
2
+ import File from '../../File.ts';
3
+ import type { ReferenceOptions } from '../../options/index.ts';
4
+ /**
5
+ * @public
6
+ */
7
+ export interface BundleStrategyOptions {
8
+ readonly name: string;
9
+ }
10
+ /**
11
+ * @public
12
+ */
13
+ declare abstract class BundleStrategy {
14
+ readonly name: string;
15
+ constructor({ name }: BundleStrategyOptions);
16
+ abstract canBundle(file: File, options: ReferenceOptions): boolean;
17
+ abstract bundle(file: File, options: ReferenceOptions): Promise<ParseResultElement>;
18
+ }
19
+ export default BundleStrategy;
@@ -0,0 +1,26 @@
1
+ import { ParseResultElement } from '@speclynx/apidom-core';
2
+ import File from '../../../File.ts';
3
+ import BundleStrategy, { BundleStrategyOptions } from '../BundleStrategy.ts';
4
+ export type { default as DereferenceStrategy, DereferenceStrategyOptions, } from '../../../dereference/strategies/DereferenceStrategy.ts';
5
+ export type { default as File, FileOptions } from '../../../File.ts';
6
+ export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
7
+ export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
8
+ export type { ReferenceOptions as ApiDOMReferenceOptions, ReferenceBundleOptions as ApiDOMReferenceBundleOptions, ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions, ReferenceParseOptions as ApiDOMReferenceParseOptions, ReferenceResolveOptions as ApiDOMReferenceResolveOptions, } from '../../../options/index.ts';
9
+ export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
10
+ export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
11
+ export type { default as ResolveStrategy, ResolveStrategyOptions, } from '../../../resolve/strategies/ResolveStrategy.ts';
12
+ export type { default as BundleStrategy, BundleStrategyOptions } from '../BundleStrategy.ts';
13
+ /**
14
+ * @public
15
+ */
16
+ export interface OpenAPI3_1BundleStrategyOptions extends Omit<BundleStrategyOptions, 'name'> {
17
+ }
18
+ /**
19
+ * @public
20
+ */
21
+ declare class OpenAPI3_1BundleStrategy extends BundleStrategy {
22
+ constructor(options?: OpenAPI3_1BundleStrategyOptions);
23
+ canBundle(file: File): boolean;
24
+ bundle(file: File): Promise<ParseResultElement>;
25
+ }
26
+ export default OpenAPI3_1BundleStrategy;
@@ -0,0 +1 @@
1
+ export * from '../index.ts';
@@ -0,0 +1 @@
1
+ export * from '../index.ts';
@@ -0,0 +1,11 @@
1
+ import { Element, ParseResultElement } from '@speclynx/apidom-core';
2
+ import type { ReferenceOptions } from '../options/index.ts';
3
+ /**
4
+ * Dereferences ApiDOM with all its external references.
5
+ */
6
+ export declare const dereferenceApiDOM: <T extends Element>(element: T, options: ReferenceOptions) => Promise<T>;
7
+ /**
8
+ * Dereferences a file with all its external references.
9
+ */
10
+ declare const dereference: (uri: string, options: ReferenceOptions) => Promise<ParseResultElement>;
11
+ export default dereference;
@@ -0,0 +1,19 @@
1
+ import { Element } from 'minim';
2
+ import File from '../../File.ts';
3
+ import type { ReferenceOptions } from '../../options/index.ts';
4
+ /**
5
+ * @public
6
+ */
7
+ export interface DereferenceStrategyOptions {
8
+ readonly name: string;
9
+ }
10
+ /**
11
+ * @public
12
+ */
13
+ declare abstract class DereferenceStrategy {
14
+ readonly name: string;
15
+ constructor({ name }: DereferenceStrategyOptions);
16
+ abstract canDereference(file: File, options: ReferenceOptions): boolean;
17
+ abstract dereference(file: File, options: ReferenceOptions): Promise<Element>;
18
+ }
19
+ export default DereferenceStrategy;
@@ -0,0 +1,30 @@
1
+ import { Element } from '@speclynx/apidom-core';
2
+ import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy.ts';
3
+ import File from '../../../File.ts';
4
+ import ApiDOMDereferenceVisitor from './visitor.ts';
5
+ import type { ReferenceOptions } from '../../../options/index.ts';
6
+ export type { default as DereferenceStrategy, DereferenceStrategyOptions, } from '../DereferenceStrategy.ts';
7
+ export type { default as File, FileOptions } from '../../../File.ts';
8
+ export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
9
+ export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
10
+ export type { ApiDOMDereferenceVisitorOptions } from './visitor.ts';
11
+ export type { ReferenceOptions as ApiDOMReferenceOptions, ReferenceBundleOptions as ApiDOMReferenceBundleOptions, ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions, ReferenceParseOptions as ApiDOMReferenceParseOptions, ReferenceResolveOptions as ApiDOMReferenceResolveOptions, } from '../../../options/index.ts';
12
+ export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
13
+ export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
14
+ export type { default as ResolveStrategy, ResolveStrategyOptions, } from '../../../resolve/strategies/ResolveStrategy.ts';
15
+ export type { default as BundleStrategy, BundleStrategyOptions, } from '../../../bundle/strategies/BundleStrategy.ts';
16
+ /**
17
+ * @public
18
+ */
19
+ export interface ApiDOMDereferenceStrategyOptions extends Omit<DereferenceStrategyOptions, 'name'> {
20
+ }
21
+ /**
22
+ * @public
23
+ */
24
+ declare class ApiDOMDereferenceStrategy extends DereferenceStrategy {
25
+ constructor(options?: ApiDOMDereferenceStrategyOptions);
26
+ canDereference(file: File): boolean;
27
+ dereference(file: File, options: ReferenceOptions): Promise<Element>;
28
+ }
29
+ export { ApiDOMDereferenceVisitor };
30
+ export default ApiDOMDereferenceStrategy;