@scalar/openapi-parser 0.11.1 → 0.12.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 (281) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/configuration/index.js.map +1 -1
  3. package/dist/index.d.ts +17 -4
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +34 -4
  6. package/dist/index.js.map +2 -2
  7. package/dist/lib/Validator/Validator.d.ts.map +1 -1
  8. package/dist/lib/Validator/Validator.js +2 -2
  9. package/dist/lib/Validator/Validator.js.map +1 -1
  10. package/dist/lib/Validator/index.d.ts +1 -2
  11. package/dist/lib/Validator/index.d.ts.map +1 -1
  12. package/dist/lib/Validator/index.js +4 -2
  13. package/dist/lib/Validator/index.js.map +2 -2
  14. package/dist/plugins/fetch-urls/{fetchUrls.d.ts → fetch-urls.d.ts} +1 -1
  15. package/dist/plugins/fetch-urls/fetch-urls.d.ts.map +1 -0
  16. package/dist/plugins/fetch-urls/{fetchUrls.js → fetch-urls.js} +1 -1
  17. package/dist/plugins/fetch-urls/fetch-urls.js.map +7 -0
  18. package/dist/plugins/fetch-urls/{fetchUrls.test.js → fetch-urls.test.js} +2 -2
  19. package/dist/plugins/fetch-urls/fetch-urls.test.js.map +7 -0
  20. package/dist/plugins/fetch-urls/index.d.ts +1 -1
  21. package/dist/plugins/fetch-urls/index.d.ts.map +1 -1
  22. package/dist/plugins/fetch-urls/index.js +5 -1
  23. package/dist/plugins/fetch-urls/index.js.map +2 -2
  24. package/dist/plugins/read-files/index.d.ts +1 -1
  25. package/dist/plugins/read-files/index.d.ts.map +1 -1
  26. package/dist/plugins/read-files/index.js +4 -1
  27. package/dist/plugins/read-files/index.js.map +2 -2
  28. package/dist/plugins/read-files/{readFiles.d.ts → read-files.d.ts} +1 -1
  29. package/dist/plugins/read-files/read-files.d.ts.map +1 -0
  30. package/dist/plugins/read-files/{readFiles.js → read-files.js} +3 -3
  31. package/dist/plugins/read-files/read-files.js.map +7 -0
  32. package/dist/plugins/read-files/{readFiles.test.js → read-files.test.js} +2 -2
  33. package/dist/plugins/read-files/read-files.test.js.map +7 -0
  34. package/dist/polyfills/index.d.ts +1 -1
  35. package/dist/polyfills/index.d.ts.map +1 -1
  36. package/dist/polyfills/index.js +22 -2
  37. package/dist/polyfills/index.js.map +2 -2
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/utils/betterAjvErrors/validation-errors/base.js.map +1 -1
  40. package/dist/utils/dereference.d.ts +1 -1
  41. package/dist/utils/dereference.d.ts.map +1 -1
  42. package/dist/utils/dereference.js +3 -3
  43. package/dist/utils/dereference.js.map +1 -1
  44. package/dist/utils/details.d.ts.map +1 -1
  45. package/dist/utils/details.js.map +1 -1
  46. package/dist/utils/{escapeJsonPointer.d.ts → escape-json-pointer.d.ts} +1 -1
  47. package/dist/utils/escape-json-pointer.d.ts.map +1 -0
  48. package/dist/utils/{escapeJsonPointer.js → escape-json-pointer.js} +1 -1
  49. package/dist/utils/{escapeJsonPointer.js.map → escape-json-pointer.js.map} +1 -1
  50. package/dist/utils/{escapeJsonPointer.test.js → escape-json-pointer.test.js} +2 -2
  51. package/dist/utils/escape-json-pointer.test.js.map +7 -0
  52. package/dist/utils/filter.d.ts.map +1 -1
  53. package/dist/utils/filter.js +2 -2
  54. package/dist/utils/filter.js.map +1 -1
  55. package/dist/utils/{getEntrypoint.d.ts → get-entrypoint.d.ts} +1 -1
  56. package/dist/utils/get-entrypoint.d.ts.map +1 -0
  57. package/dist/utils/{getEntrypoint.js → get-entrypoint.js} +1 -1
  58. package/dist/utils/get-entrypoint.js.map +7 -0
  59. package/dist/utils/{getEntrypoint.test.js → get-entrypoint.test.js} +3 -3
  60. package/dist/utils/get-entrypoint.test.js.map +7 -0
  61. package/dist/utils/{getListOfReferences.d.ts → get-list-of-references.d.ts} +1 -1
  62. package/dist/utils/get-list-of-references.d.ts.map +1 -0
  63. package/dist/utils/{getListOfReferences.js → get-list-of-references.js} +1 -1
  64. package/dist/utils/get-list-of-references.js.map +7 -0
  65. package/dist/utils/{getSegmentsFromPath.d.ts → get-segments-from-path.d.ts} +1 -1
  66. package/dist/utils/get-segments-from-path.d.ts.map +1 -0
  67. package/dist/utils/{getSegmentsFromPath.js → get-segments-from-path.js} +2 -2
  68. package/dist/utils/get-segments-from-path.js.map +7 -0
  69. package/dist/utils/{getSegmentsFromPath.test.js → get-segments-from-path.test.js} +2 -2
  70. package/dist/utils/get-segments-from-path.test.js.map +7 -0
  71. package/dist/utils/{isFilesystem.d.ts → is-filesystem.d.ts} +1 -1
  72. package/dist/utils/is-filesystem.d.ts.map +1 -0
  73. package/dist/utils/{isFilesystem.js → is-filesystem.js} +1 -1
  74. package/dist/utils/is-filesystem.js.map +7 -0
  75. package/dist/utils/{makeFilesystem.test.js → is-filesystem.test.js} +3 -3
  76. package/dist/utils/is-filesystem.test.js.map +7 -0
  77. package/dist/utils/{isJson.d.ts → is-json.d.ts} +1 -1
  78. package/dist/utils/is-json.d.ts.map +1 -0
  79. package/dist/utils/{isJson.js → is-json.js} +1 -1
  80. package/dist/utils/{isJson.js.map → is-json.js.map} +1 -1
  81. package/dist/utils/{isObject.d.ts → is-object.d.ts} +1 -1
  82. package/dist/utils/is-object.d.ts.map +1 -0
  83. package/dist/utils/{isObject.js → is-object.js} +1 -1
  84. package/dist/utils/{isObject.js.map → is-object.js.map} +1 -1
  85. package/dist/utils/{isObject.test.js → is-object.test.js} +2 -2
  86. package/dist/utils/is-object.test.js.map +7 -0
  87. package/dist/utils/{isYaml.d.ts → is-yaml.d.ts} +1 -1
  88. package/dist/utils/is-yaml.d.ts.map +1 -0
  89. package/dist/utils/{isYaml.js → is-yaml.js} +1 -1
  90. package/dist/utils/{isYaml.js.map → is-yaml.js.map} +1 -1
  91. package/dist/utils/load/index.d.ts +1 -1
  92. package/dist/utils/load/index.d.ts.map +1 -1
  93. package/dist/utils/load/index.js +4 -1
  94. package/dist/utils/load/index.js.map +2 -2
  95. package/dist/utils/load/load.d.ts.map +1 -1
  96. package/dist/utils/load/load.js +4 -4
  97. package/dist/utils/load/load.js.map +1 -1
  98. package/dist/utils/load/load.test.js +3 -3
  99. package/dist/utils/load/load.test.js.map +1 -1
  100. package/dist/utils/{makeFilesystem.d.ts → make-filesystem.d.ts} +1 -1
  101. package/dist/utils/make-filesystem.d.ts.map +1 -0
  102. package/dist/utils/{makeFilesystem.js → make-filesystem.js} +3 -3
  103. package/dist/utils/make-filesystem.js.map +7 -0
  104. package/dist/utils/normalize.d.ts.map +1 -1
  105. package/dist/utils/normalize.js +1 -1
  106. package/dist/utils/normalize.js.map +1 -1
  107. package/dist/utils/{resolveReferences.d.ts → resolve-references.d.ts} +1 -1
  108. package/dist/utils/{resolveReferences.d.ts.map → resolve-references.d.ts.map} +1 -1
  109. package/dist/utils/{resolveReferences.js → resolve-references.js} +4 -4
  110. package/dist/utils/resolve-references.js.map +7 -0
  111. package/dist/utils/{resolveReferences.test.js → resolve-references.test.js} +4 -4
  112. package/dist/utils/{resolveReferences.test.js.map → resolve-references.test.js.map} +3 -3
  113. package/dist/utils/{toJson.d.ts → to-json.d.ts} +1 -1
  114. package/dist/utils/to-json.d.ts.map +1 -0
  115. package/dist/utils/{toJson.js → to-json.js} +1 -1
  116. package/dist/utils/to-json.js.map +7 -0
  117. package/dist/utils/{toYaml.d.ts → to-yaml.d.ts} +1 -1
  118. package/dist/utils/to-yaml.d.ts.map +1 -0
  119. package/dist/utils/{toYaml.js → to-yaml.js} +1 -1
  120. package/dist/utils/{toYaml.js.map → to-yaml.js.map} +2 -2
  121. package/dist/utils/transform/sanitize.d.ts +2 -0
  122. package/dist/utils/transform/sanitize.d.ts.map +1 -1
  123. package/dist/utils/transform/sanitize.js.map +2 -2
  124. package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
  125. package/dist/utils/transform/utils/addInfoObject.js.map +1 -1
  126. package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts.map +1 -1
  127. package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +1 -1
  128. package/dist/utils/transform/utils/addMissingTags.d.ts.map +1 -1
  129. package/dist/utils/transform/utils/addMissingTags.js.map +1 -1
  130. package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts.map +1 -1
  131. package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +1 -1
  132. package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts.map +1 -1
  133. package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +1 -1
  134. package/dist/utils/{transformErrors.d.ts → transform-errors.d.ts} +1 -1
  135. package/dist/utils/transform-errors.d.ts.map +1 -0
  136. package/dist/utils/{transformErrors.js → transform-errors.js} +1 -1
  137. package/dist/utils/transform-errors.js.map +7 -0
  138. package/dist/utils/{transformErrors.test.js → transform-errors.test.js} +3 -3
  139. package/dist/utils/transform-errors.test.js.map +7 -0
  140. package/dist/utils/traverse.d.ts.map +1 -1
  141. package/dist/utils/traverse.js.map +1 -1
  142. package/dist/utils/{unescapeJsonPointer.d.ts → unescape-json-pointer.d.ts} +1 -1
  143. package/dist/utils/unescape-json-pointer.d.ts.map +1 -0
  144. package/dist/utils/{unescapeJsonPointer.js → unescape-json-pointer.js} +1 -1
  145. package/dist/utils/{unescapeJsonPointer.js.map → unescape-json-pointer.js.map} +1 -1
  146. package/dist/utils/{unescapeJsonPointer.test.js → unescape-json-pointer.test.js} +2 -2
  147. package/dist/utils/unescape-json-pointer.test.js.map +7 -0
  148. package/dist/utils/{upgradeFromThreeToThreeOne.d.ts → upgrade-from-three-to-three-one.d.ts} +1 -1
  149. package/dist/utils/upgrade-from-three-to-three-one.d.ts.map +1 -0
  150. package/dist/utils/{upgradeFromThreeToThreeOne.js → upgrade-from-three-to-three-one.js} +1 -2
  151. package/dist/utils/upgrade-from-three-to-three-one.js.map +7 -0
  152. package/dist/utils/{upgradeFromThreeToThreeOne.test.js → upgrade-from-three-to-three-one.test.js} +2 -2
  153. package/dist/utils/upgrade-from-three-to-three-one.test.js.map +7 -0
  154. package/dist/utils/{upgradeFromTwoToThree.d.ts → upgrade-from-two-to-three.d.ts} +1 -1
  155. package/dist/utils/upgrade-from-two-to-three.d.ts.map +1 -0
  156. package/dist/utils/{upgradeFromTwoToThree.js → upgrade-from-two-to-three.js} +1 -1
  157. package/dist/utils/{upgradeFromTwoToThree.js.map → upgrade-from-two-to-three.js.map} +1 -1
  158. package/dist/utils/{upgradeFromTwoToThree.test.js → upgrade-from-two-to-three.test.js} +2 -2
  159. package/dist/utils/upgrade-from-two-to-three.test.js.map +7 -0
  160. package/dist/utils/upgrade.bench.js +1 -1
  161. package/dist/utils/upgrade.bench.js.map +1 -1
  162. package/dist/utils/upgrade.d.ts.map +1 -1
  163. package/dist/utils/upgrade.js +4 -4
  164. package/dist/utils/upgrade.js.map +1 -1
  165. package/dist/utils/upgrade.test.js +1 -1
  166. package/dist/utils/upgrade.test.js.map +1 -1
  167. package/dist/utils/validate.d.ts.map +1 -1
  168. package/dist/utils/validate.js +1 -1
  169. package/dist/utils/validate.js.map +1 -1
  170. package/package.json +2 -2
  171. package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +0 -1
  172. package/dist/plugins/fetch-urls/fetchUrls.js.map +0 -7
  173. package/dist/plugins/fetch-urls/fetchUrls.test.js.map +0 -7
  174. package/dist/plugins/read-files/readFiles.d.ts.map +0 -1
  175. package/dist/plugins/read-files/readFiles.js.map +0 -7
  176. package/dist/plugins/read-files/readFiles.test.js.map +0 -7
  177. package/dist/utils/escapeJsonPointer.d.ts.map +0 -1
  178. package/dist/utils/escapeJsonPointer.test.js.map +0 -7
  179. package/dist/utils/getEntrypoint.d.ts.map +0 -1
  180. package/dist/utils/getEntrypoint.js.map +0 -7
  181. package/dist/utils/getEntrypoint.test.js.map +0 -7
  182. package/dist/utils/getListOfReferences.d.ts.map +0 -1
  183. package/dist/utils/getListOfReferences.js.map +0 -7
  184. package/dist/utils/getSegmentsFromPath.d.ts.map +0 -1
  185. package/dist/utils/getSegmentsFromPath.js.map +0 -7
  186. package/dist/utils/getSegmentsFromPath.test.js.map +0 -7
  187. package/dist/utils/index.d.ts +0 -27
  188. package/dist/utils/index.d.ts.map +0 -1
  189. package/dist/utils/index.js +0 -27
  190. package/dist/utils/index.js.map +0 -7
  191. package/dist/utils/isFilesystem.d.ts.map +0 -1
  192. package/dist/utils/isFilesystem.js.map +0 -7
  193. package/dist/utils/isJson.d.ts.map +0 -1
  194. package/dist/utils/isObject.d.ts.map +0 -1
  195. package/dist/utils/isObject.test.js.map +0 -7
  196. package/dist/utils/isYaml.d.ts.map +0 -1
  197. package/dist/utils/makeFilesystem.d.ts.map +0 -1
  198. package/dist/utils/makeFilesystem.js.map +0 -7
  199. package/dist/utils/makeFilesystem.test.js.map +0 -7
  200. package/dist/utils/openapi/actions/details.d.ts +0 -7
  201. package/dist/utils/openapi/actions/details.d.ts.map +0 -1
  202. package/dist/utils/openapi/actions/details.js +0 -11
  203. package/dist/utils/openapi/actions/details.js.map +0 -7
  204. package/dist/utils/openapi/actions/files.d.ts +0 -6
  205. package/dist/utils/openapi/actions/files.d.ts.map +0 -1
  206. package/dist/utils/openapi/actions/files.js +0 -9
  207. package/dist/utils/openapi/actions/files.js.map +0 -7
  208. package/dist/utils/openapi/actions/get.d.ts +0 -6
  209. package/dist/utils/openapi/actions/get.d.ts.map +0 -1
  210. package/dist/utils/openapi/actions/get.js +0 -11
  211. package/dist/utils/openapi/actions/get.js.map +0 -7
  212. package/dist/utils/openapi/actions/toJson.d.ts +0 -6
  213. package/dist/utils/openapi/actions/toJson.d.ts.map +0 -1
  214. package/dist/utils/openapi/actions/toJson.js +0 -11
  215. package/dist/utils/openapi/actions/toJson.js.map +0 -7
  216. package/dist/utils/openapi/actions/toYaml.d.ts +0 -6
  217. package/dist/utils/openapi/actions/toYaml.d.ts.map +0 -1
  218. package/dist/utils/openapi/actions/toYaml.js +0 -11
  219. package/dist/utils/openapi/actions/toYaml.js.map +0 -7
  220. package/dist/utils/openapi/commands/dereferenceCommand.d.ts +0 -27
  221. package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +0 -1
  222. package/dist/utils/openapi/commands/dereferenceCommand.js +0 -27
  223. package/dist/utils/openapi/commands/dereferenceCommand.js.map +0 -7
  224. package/dist/utils/openapi/commands/filterCommand.d.ts +0 -41
  225. package/dist/utils/openapi/commands/filterCommand.d.ts.map +0 -1
  226. package/dist/utils/openapi/commands/filterCommand.js +0 -26
  227. package/dist/utils/openapi/commands/filterCommand.js.map +0 -7
  228. package/dist/utils/openapi/commands/loadCommand.d.ts +0 -8321
  229. package/dist/utils/openapi/commands/loadCommand.d.ts.map +0 -1
  230. package/dist/utils/openapi/commands/loadCommand.js +0 -42
  231. package/dist/utils/openapi/commands/loadCommand.js.map +0 -7
  232. package/dist/utils/openapi/commands/upgradeCommand.d.ts +0 -3406
  233. package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +0 -1
  234. package/dist/utils/openapi/commands/upgradeCommand.js +0 -29
  235. package/dist/utils/openapi/commands/upgradeCommand.js.map +0 -7
  236. package/dist/utils/openapi/commands/validateCommand.d.ts +0 -3451
  237. package/dist/utils/openapi/commands/validateCommand.d.ts.map +0 -1
  238. package/dist/utils/openapi/commands/validateCommand.js +0 -33
  239. package/dist/utils/openapi/commands/validateCommand.js.map +0 -7
  240. package/dist/utils/openapi/index.d.ts +0 -2
  241. package/dist/utils/openapi/index.d.ts.map +0 -1
  242. package/dist/utils/openapi/index.js +0 -2
  243. package/dist/utils/openapi/index.js.map +0 -7
  244. package/dist/utils/openapi/openapi.d.ts +0 -1272
  245. package/dist/utils/openapi/openapi.d.ts.map +0 -1
  246. package/dist/utils/openapi/openapi.js +0 -15
  247. package/dist/utils/openapi/openapi.js.map +0 -7
  248. package/dist/utils/openapi/openapi.test-d.d.ts +0 -2
  249. package/dist/utils/openapi/openapi.test-d.d.ts.map +0 -1
  250. package/dist/utils/openapi/openapi.test-d.js +0 -14
  251. package/dist/utils/openapi/openapi.test-d.js.map +0 -7
  252. package/dist/utils/openapi/openapi.test.js +0 -309
  253. package/dist/utils/openapi/openapi.test.js.map +0 -7
  254. package/dist/utils/openapi/utils/queueTask.d.ts +0 -6
  255. package/dist/utils/openapi/utils/queueTask.d.ts.map +0 -1
  256. package/dist/utils/openapi/utils/queueTask.js +0 -10
  257. package/dist/utils/openapi/utils/queueTask.js.map +0 -7
  258. package/dist/utils/openapi/utils/workThroughQueue.d.ts +0 -6
  259. package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +0 -1
  260. package/dist/utils/openapi/utils/workThroughQueue.js +0 -52
  261. package/dist/utils/openapi/utils/workThroughQueue.js.map +0 -7
  262. package/dist/utils/openapi/utils/workThroughQueue.test.js +0 -244
  263. package/dist/utils/openapi/utils/workThroughQueue.test.js.map +0 -7
  264. package/dist/utils/resolveReferences.js.map +0 -7
  265. package/dist/utils/toJson.d.ts.map +0 -1
  266. package/dist/utils/toJson.js.map +0 -7
  267. package/dist/utils/toYaml.d.ts.map +0 -1
  268. package/dist/utils/transform/index.d.ts +0 -2
  269. package/dist/utils/transform/index.d.ts.map +0 -1
  270. package/dist/utils/transform/index.js +0 -2
  271. package/dist/utils/transform/index.js.map +0 -7
  272. package/dist/utils/transformErrors.d.ts.map +0 -1
  273. package/dist/utils/transformErrors.js.map +0 -7
  274. package/dist/utils/transformErrors.test.js.map +0 -7
  275. package/dist/utils/unescapeJsonPointer.d.ts.map +0 -1
  276. package/dist/utils/unescapeJsonPointer.test.js.map +0 -7
  277. package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +0 -1
  278. package/dist/utils/upgradeFromThreeToThreeOne.js.map +0 -7
  279. package/dist/utils/upgradeFromThreeToThreeOne.test.js.map +0 -7
  280. package/dist/utils/upgradeFromTwoToThree.d.ts.map +0 -1
  281. package/dist/utils/upgradeFromTwoToThree.test.js.map +0 -7
@@ -1,5 +1,5 @@
1
- import { getEntrypoint } from "./getEntrypoint.js";
2
- import { makeFilesystem } from "./makeFilesystem.js";
1
+ import { getEntrypoint } from "./get-entrypoint.js";
2
+ import { makeFilesystem } from "./make-filesystem.js";
3
3
  import { traverse } from "./traverse.js";
4
4
  function filter(specification, callback) {
5
5
  const filesystem = makeFilesystem(specification);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/filter.ts"],
4
- "sourcesContent": ["import type { AnyApiDefinitionFormat, AnyObject, FilterResult } from '../types/index'\nimport { getEntrypoint } from './getEntrypoint'\nimport { makeFilesystem } from './makeFilesystem'\nimport { traverse } from './traverse'\n\nexport type FilterCallback = (schema: AnyObject) => boolean\n\n/**\n * Filter the specification based on the callback\n */\nexport function filter(specification: AnyApiDefinitionFormat, callback: FilterCallback): FilterResult {\n const filesystem = makeFilesystem(specification)\n\n return {\n specification: traverse(getEntrypoint(filesystem).specification, (schema) => {\n return callback(schema) ? schema : undefined\n }),\n }\n}\n"],
4
+ "sourcesContent": ["import type { AnyApiDefinitionFormat, AnyObject, FilterResult } from '@/types/index'\nimport { getEntrypoint } from './get-entrypoint'\nimport { makeFilesystem } from './make-filesystem'\nimport { traverse } from './traverse'\n\nexport type FilterCallback = (schema: AnyObject) => boolean\n\n/**\n * Filter the specification based on the callback\n */\nexport function filter(specification: AnyApiDefinitionFormat, callback: FilterCallback): FilterResult {\n const filesystem = makeFilesystem(specification)\n\n return {\n specification: traverse(getEntrypoint(filesystem).specification, (schema) => {\n return callback(schema) ? schema : undefined\n }),\n }\n}\n"],
5
5
  "mappings": "AACA,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAOlB,SAAS,OAAO,eAAuC,UAAwC;AACpG,QAAM,aAAa,eAAe,aAAa;AAE/C,SAAO;AAAA,IACL,eAAe,SAAS,cAAc,UAAU,EAAE,eAAe,CAAC,WAAW;AAC3E,aAAO,SAAS,MAAM,IAAI,SAAS;AAAA,IACrC,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
@@ -3,4 +3,4 @@ import type { Filesystem, FilesystemEntry } from '../types/index.js';
3
3
  * Return just the entrypoint of the filesystem.
4
4
  */
5
5
  export declare function getEntrypoint(filesystem?: Filesystem): FilesystemEntry | undefined;
6
- //# sourceMappingURL=getEntrypoint.d.ts.map
6
+ //# sourceMappingURL=get-entrypoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-entrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/get-entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEhE;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS,CAElF"}
@@ -4,4 +4,4 @@ function getEntrypoint(filesystem) {
4
4
  export {
5
5
  getEntrypoint
6
6
  };
7
- //# sourceMappingURL=getEntrypoint.js.map
7
+ //# sourceMappingURL=get-entrypoint.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/get-entrypoint.ts"],
4
+ "sourcesContent": ["import type { Filesystem, FilesystemEntry } from '@/types/index'\n\n/**\n * Return just the entrypoint of the filesystem.\n */\nexport function getEntrypoint(filesystem?: Filesystem): FilesystemEntry | undefined {\n return filesystem?.find((file) => file.isEntrypoint)\n}\n"],
5
+ "mappings": "AAKO,SAAS,cAAc,YAAsD;AAClF,SAAO,YAAY,KAAK,CAAC,SAAS,KAAK,YAAY;AACrD;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { getEntrypoint } from "./getEntrypoint.js";
3
- import { makeFilesystem } from "./makeFilesystem.js";
2
+ import { getEntrypoint } from "./get-entrypoint.js";
3
+ import { makeFilesystem } from "./make-filesystem.js";
4
4
  describe("getEntrypoint", () => {
5
5
  it("keeps the object reference", () => {
6
6
  const result = makeFilesystem({
@@ -15,4 +15,4 @@ describe("getEntrypoint", () => {
15
15
  expect(entrypoint).toBe(void 0);
16
16
  });
17
17
  });
18
- //# sourceMappingURL=getEntrypoint.test.js.map
18
+ //# sourceMappingURL=get-entrypoint.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/get-entrypoint.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { getEntrypoint } from './get-entrypoint'\nimport { makeFilesystem } from './make-filesystem'\n\ndescribe('getEntrypoint', () => {\n it('keeps the object reference', () => {\n const result = makeFilesystem({\n foo: 'bar',\n })\n\n const entrypoint = getEntrypoint(result)\n\n // Modify the entrypoint\n entrypoint.specification.foo = 'baz'\n\n // Check whether the original was modified\n expect(result[0].specification.foo).toBe('baz')\n })\n\n it('returns undefined for an empty filesystem', () => {\n const entrypoint = getEntrypoint([])\n\n // Check whether the original was modified\n expect(entrypoint).toBe(undefined)\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAE/B,SAAS,iBAAiB,MAAM;AAC9B,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,eAAe;AAAA,MAC5B,KAAK;AAAA,IACP,CAAC;AAED,UAAM,aAAa,cAAc,MAAM;AAGvC,eAAW,cAAc,MAAM;AAG/B,WAAO,OAAO,CAAC,EAAE,cAAc,GAAG,EAAE,KAAK,KAAK;AAAA,EAChD,CAAC;AAED,KAAG,6CAA6C,MAAM;AACpD,UAAM,aAAa,cAAc,CAAC,CAAC;AAGnC,WAAO,UAAU,EAAE,KAAK,MAAS;AAAA,EACnC,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -5,4 +5,4 @@ import type { AnyObject } from '../types/index.js';
5
5
  * Warning: Doesn’t return internal references.
6
6
  */
7
7
  export declare function getListOfReferences(specification: AnyObject): string[];
8
- //# sourceMappingURL=getListOfReferences.d.ts.map
8
+ //# sourceMappingURL=get-list-of-references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-list-of-references.d.ts","sourceRoot":"","sources":["../../src/utils/get-list-of-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,YAmB3D"}
@@ -15,4 +15,4 @@ function getListOfReferences(specification) {
15
15
  export {
16
16
  getListOfReferences
17
17
  };
18
- //# sourceMappingURL=getListOfReferences.js.map
18
+ //# sourceMappingURL=get-list-of-references.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/get-list-of-references.ts"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\nimport { traverse } from './traverse'\n\n/**\n * Walks through the specification and returns all references as an array.\n *\n * Warning: Doesn\u2019t return internal references.\n */\nexport function getListOfReferences(specification: AnyObject) {\n const references: string[] = []\n\n // Make sure we\u2019re dealing with an object\n if (!specification || typeof specification !== 'object') {\n return references\n }\n\n // Traverse the specification and collect all references\n traverse(specification, (value: any) => {\n if (value.$ref && typeof value.$ref === 'string' && !value.$ref.startsWith('#')) {\n references.push(value.$ref.split('#')[0])\n }\n\n return value\n })\n\n // Remove duplicates\n return [...new Set(references)]\n}\n"],
5
+ "mappings": "AACA,SAAS,gBAAgB;AAOlB,SAAS,oBAAoB,eAA0B;AAC5D,QAAM,aAAuB,CAAC;AAG9B,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AAGA,WAAS,eAAe,CAAC,UAAe;AACtC,QAAI,MAAM,QAAQ,OAAO,MAAM,SAAS,YAAY,CAAC,MAAM,KAAK,WAAW,GAAG,GAAG;AAC/E,iBAAW,KAAK,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,IAC1C;AAEA,WAAO;AAAA,EACT,CAAC;AAGD,SAAO,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC;AAChC;",
6
+ "names": []
7
+ }
@@ -2,4 +2,4 @@
2
2
  * Translate `/paths/~1test` to `['paths', '/test']`
3
3
  */
4
4
  export declare function getSegmentsFromPath(path: string): string[];
5
- //# sourceMappingURL=getSegmentsFromPath.d.ts.map
5
+ //# sourceMappingURL=get-segments-from-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-segments-from-path.d.ts","sourceRoot":"","sources":["../../src/utils/get-segments-from-path.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,YAW/C"}
@@ -1,4 +1,4 @@
1
- import { unescapeJsonPointer } from "./unescapeJsonPointer.js";
1
+ import { unescapeJsonPointer } from "./unescape-json-pointer.js";
2
2
  function getSegmentsFromPath(path) {
3
3
  return (
4
4
  // /paths/~1test
@@ -8,4 +8,4 @@ function getSegmentsFromPath(path) {
8
8
  export {
9
9
  getSegmentsFromPath
10
10
  };
11
- //# sourceMappingURL=getSegmentsFromPath.js.map
11
+ //# sourceMappingURL=get-segments-from-path.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/get-segments-from-path.ts"],
4
+ "sourcesContent": ["import { unescapeJsonPointer } from './unescape-json-pointer'\n\n/**\n * Translate `/paths/~1test` to `['paths', '/test']`\n */\nexport function getSegmentsFromPath(path: string) {\n return (\n // /paths/~1test\n path\n // ['', 'paths', '~1test']\n .split('/')\n // ['paths', '~test']\n .slice(1)\n // ['paths', '/test']\n .map(unescapeJsonPointer)\n )\n}\n"],
5
+ "mappings": "AAAA,SAAS,2BAA2B;AAK7B,SAAS,oBAAoB,MAAc;AAChD;AAAA;AAAA,IAEE,KAEG,MAAM,GAAG,EAET,MAAM,CAAC,EAEP,IAAI,mBAAmB;AAAA;AAE9B;",
6
+ "names": []
7
+ }
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { getSegmentsFromPath } from "./getSegmentsFromPath.js";
2
+ import { getSegmentsFromPath } from "./get-segments-from-path.js";
3
3
  describe("getSegmentsFromPath", () => {
4
4
  it("returns path segments", () => {
5
5
  const result = getSegmentsFromPath("/paths/test");
@@ -10,4 +10,4 @@ describe("getSegmentsFromPath", () => {
10
10
  expect(result).toEqual(["paths", "/test"]);
11
11
  });
12
12
  });
13
- //# sourceMappingURL=getSegmentsFromPath.test.js.map
13
+ //# sourceMappingURL=get-segments-from-path.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/get-segments-from-path.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { getSegmentsFromPath } from './get-segments-from-path'\n\ndescribe('getSegmentsFromPath', () => {\n it('returns path segments', () => {\n const result = getSegmentsFromPath('/paths/test')\n\n expect(result).toEqual(['paths', 'test'])\n })\n\n it('unsescapes slashes', () => {\n const result = getSegmentsFromPath('/paths/~1test')\n\n expect(result).toEqual(['paths', '/test'])\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,2BAA2B;AAEpC,SAAS,uBAAuB,MAAM;AACpC,KAAG,yBAAyB,MAAM;AAChC,UAAM,SAAS,oBAAoB,aAAa;AAEhD,WAAO,MAAM,EAAE,QAAQ,CAAC,SAAS,MAAM,CAAC;AAAA,EAC1C,CAAC;AAED,KAAG,sBAAsB,MAAM;AAC7B,UAAM,SAAS,oBAAoB,eAAe;AAElD,WAAO,MAAM,EAAE,QAAQ,CAAC,SAAS,OAAO,CAAC;AAAA,EAC3C,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -3,4 +3,4 @@ import type { Filesystem } from '../types/index.js';
3
3
  * Check if the value is a filesystem
4
4
  */
5
5
  export declare function isFilesystem(value: any): value is Filesystem;
6
- //# sourceMappingURL=isFilesystem.d.ts.map
6
+ //# sourceMappingURL=is-filesystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-filesystem.d.ts","sourceRoot":"","sources":["../../src/utils/is-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,UAAU,CAO5D"}
@@ -4,4 +4,4 @@ function isFilesystem(value) {
4
4
  export {
5
5
  isFilesystem
6
6
  };
7
- //# sourceMappingURL=isFilesystem.js.map
7
+ //# sourceMappingURL=is-filesystem.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/is-filesystem.ts"],
4
+ "sourcesContent": ["import type { Filesystem } from '@/types'\n\n/**\n * Check if the value is a filesystem\n */\nexport function isFilesystem(value: any): value is Filesystem {\n return (\n typeof value !== 'undefined' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.some((file) => file.isEntrypoint === true)\n )\n}\n"],
5
+ "mappings": "AAKO,SAAS,aAAa,OAAiC;AAC5D,SACE,OAAO,UAAU,eACjB,MAAM,QAAQ,KAAK,KACnB,MAAM,SAAS,KACf,MAAM,KAAK,CAAC,SAAS,KAAK,iBAAiB,IAAI;AAEnD;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { isFilesystem } from "./isFilesystem.js";
3
- import { makeFilesystem } from "./makeFilesystem.js";
2
+ import { isFilesystem } from "./is-filesystem.js";
3
+ import { makeFilesystem } from "./make-filesystem.js";
4
4
  describe("isFilesystem", () => {
5
5
  it("transforms an object to a filesystem", () => {
6
6
  const result = makeFilesystem({
@@ -12,4 +12,4 @@ describe("isFilesystem", () => {
12
12
  expect(isFilesystem(result)).toBe(true);
13
13
  });
14
14
  });
15
- //# sourceMappingURL=makeFilesystem.test.js.map
15
+ //# sourceMappingURL=is-filesystem.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/is-filesystem.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isFilesystem } from './is-filesystem'\nimport { makeFilesystem } from './make-filesystem'\n\ndescribe('isFilesystem', () => {\n it('transforms an object to a filesystem', () => {\n const result = makeFilesystem({\n foo: 'bar',\n })\n\n expect(result).not.toBe({\n foo: 'bar',\n })\n\n expect(isFilesystem(result)).toBe(true)\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAE/B,SAAS,gBAAgB,MAAM;AAC7B,KAAG,wCAAwC,MAAM;AAC/C,UAAM,SAAS,eAAe;AAAA,MAC5B,KAAK;AAAA,IACP,CAAC;AAED,WAAO,MAAM,EAAE,IAAI,KAAK;AAAA,MACtB,KAAK;AAAA,IACP,CAAC;AAED,WAAO,aAAa,MAAM,CAAC,EAAE,KAAK,IAAI;AAAA,EACxC,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
1
  export declare function isJson(value: string): boolean;
2
- //# sourceMappingURL=isJson.d.ts.map
2
+ //# sourceMappingURL=is-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-json.d.ts","sourceRoot":"","sources":["../../src/utils/is-json.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,WAQnC"}
@@ -9,4 +9,4 @@ function isJson(value) {
9
9
  export {
10
10
  isJson
11
11
  };
12
- //# sourceMappingURL=isJson.js.map
12
+ //# sourceMappingURL=is-json.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/isJson.ts"],
3
+ "sources": ["../../src/utils/is-json.ts"],
4
4
  "sourcesContent": ["export function isJson(value: string) {\n try {\n JSON.parse(value)\n\n return true\n } catch {\n return false\n }\n}\n"],
5
5
  "mappings": "AAAO,SAAS,OAAO,OAAe;AACpC,MAAI;AACF,SAAK,MAAM,KAAK;AAEhB,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
@@ -2,4 +2,4 @@
2
2
  * Check if the given value is an object
3
3
  */
4
4
  export declare const isObject: (obj: any) => boolean;
5
- //# sourceMappingURL=isObject.d.ts.map
5
+ //# sourceMappingURL=is-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-object.d.ts","sourceRoot":"","sources":["../../src/utils/is-object.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAS,GAAG,YAAmE,CAAA"}
@@ -2,4 +2,4 @@ const isObject = (obj) => typeof obj === "object" && !Array.isArray(obj) && obj
2
2
  export {
3
3
  isObject
4
4
  };
5
- //# sourceMappingURL=isObject.js.map
5
+ //# sourceMappingURL=is-object.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/isObject.ts"],
3
+ "sources": ["../../src/utils/is-object.ts"],
4
4
  "sourcesContent": ["/**\n * Check if the given value is an object\n */\nexport const isObject = (obj: any) => typeof obj === 'object' && !Array.isArray(obj) && obj !== null\n"],
5
5
  "mappings": "AAGO,MAAM,WAAW,CAAC,QAAa,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG,KAAK,QAAQ;",
6
6
  "names": []
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { isObject } from "./isObject.js";
2
+ import { isObject } from "./is-object.js";
3
3
  describe("isObject", () => {
4
4
  it("returns true for an object", () => {
5
5
  const result = isObject({
@@ -20,4 +20,4 @@ describe("isObject", () => {
20
20
  expect(result).toBe(false);
21
21
  });
22
22
  });
23
- //# sourceMappingURL=isObject.test.js.map
23
+ //# sourceMappingURL=is-object.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/is-object.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isObject } from './is-object'\n\ndescribe('isObject', () => {\n it('returns true for an object', () => {\n const result = isObject({\n foo: 'bar',\n })\n expect(result).toBe(true)\n })\n\n it('returns true for an empty object', () => {\n const result = isObject({})\n expect(result).toBe(true)\n })\n\n it('returns false for a string', () => {\n const result = isObject('foo')\n expect(result).toBe(false)\n })\n\n it('returns false for an array', () => {\n const result = isObject([])\n expect(result).toBe(false)\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,gBAAgB;AAEzB,SAAS,YAAY,MAAM;AACzB,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS;AAAA,MACtB,KAAK;AAAA,IACP,CAAC;AACD,WAAO,MAAM,EAAE,KAAK,IAAI;AAAA,EAC1B,CAAC;AAED,KAAG,oCAAoC,MAAM;AAC3C,UAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,WAAO,MAAM,EAAE,KAAK,IAAI;AAAA,EAC1B,CAAC;AAED,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS,KAAK;AAC7B,WAAO,MAAM,EAAE,KAAK,KAAK;AAAA,EAC3B,CAAC;AAED,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,WAAO,MAAM,EAAE,KAAK,KAAK;AAAA,EAC3B,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
1
  export declare function isYaml(value: string): boolean;
2
- //# sourceMappingURL=isYaml.d.ts.map
2
+ //# sourceMappingURL=is-yaml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-yaml.d.ts","sourceRoot":"","sources":["../../src/utils/is-yaml.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,WAenC"}
@@ -15,4 +15,4 @@ function isYaml(value) {
15
15
  export {
16
16
  isYaml
17
17
  };
18
- //# sourceMappingURL=isYaml.js.map
18
+ //# sourceMappingURL=is-yaml.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/isYaml.ts"],
3
+ "sources": ["../../src/utils/is-yaml.ts"],
4
4
  "sourcesContent": ["import { parse } from 'yaml'\n\nexport function isYaml(value: string) {\n // Line breaks\n if (!value.includes('\\n')) {\n return false\n }\n\n try {\n parse(value, {\n maxAliasCount: 10000,\n })\n\n return true\n } catch (_error) {\n return false\n }\n}\n"],
5
5
  "mappings": "AAAA,SAAS,aAAa;AAEf,SAAS,OAAO,OAAe;AAEpC,MAAI,CAAC,MAAM,SAAS,IAAI,GAAG;AACzB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,OAAO;AAAA,MACX,eAAe;AAAA,IACjB,CAAC;AAED,WAAO;AAAA,EACT,SAAS,QAAQ;AACf,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
@@ -1,2 +1,2 @@
1
- export * from './load.js';
1
+ export { load, type LoadPlugin, type LoadOptions } from './load.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/load/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/load/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAA"}
@@ -1,2 +1,5 @@
1
- export * from "./load.js";
1
+ import { load } from "./load.js";
2
+ export {
3
+ load
4
+ };
2
5
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/load/index.ts"],
4
- "sourcesContent": ["export * from './load'\n"],
5
- "mappings": "AAAA,cAAc;",
4
+ "sourcesContent": ["export { load, type LoadPlugin, type LoadOptions } from './load'\n"],
5
+ "mappings": "AAAA,SAAS,YAA+C;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EAGtB,UAAU,EACV,UAAU,EACV,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAM1B,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;IAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;IACxB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACvD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;IAC/B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB,GAAG,kBAAkB,CAAA;AAEtB;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAyHpG"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EAGtB,UAAU,EACV,UAAU,EACV,kBAAkB,EACnB,MAAM,eAAe,CAAA;AAMtB,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;IAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;IACxB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACvD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;IAC/B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB,GAAG,kBAAkB,CAAA;AAEtB;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAyHpG"}
@@ -1,8 +1,8 @@
1
1
  import { ERRORS } from "../../configuration/index.js";
2
- import { getEntrypoint } from "../getEntrypoint.js";
3
- import { getListOfReferences } from "../getListOfReferences.js";
4
- import { makeFilesystem } from "../makeFilesystem.js";
5
- import { normalize } from "../normalize.js";
2
+ import { getEntrypoint } from "../../utils/get-entrypoint.js";
3
+ import { getListOfReferences } from "../../utils/get-list-of-references.js";
4
+ import { makeFilesystem } from "../../utils/make-filesystem.js";
5
+ import { normalize } from "../../utils/normalize.js";
6
6
  async function load(value, options) {
7
7
  const errors = [];
8
8
  if (options?.filesystem?.find((entry) => entry.filename === value)) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/load/load.ts"],
4
- "sourcesContent": ["import { ERRORS } from '../../configuration/index'\nimport type {\n AnyApiDefinitionFormat,\n AnyObject,\n ErrorObject,\n Filesystem,\n LoadResult,\n ThrowOnErrorOption,\n} from '../../types/index'\nimport { getEntrypoint } from '../getEntrypoint'\nimport { getListOfReferences } from '../getListOfReferences'\nimport { makeFilesystem } from '../makeFilesystem'\nimport { normalize } from '../normalize'\n\nexport type LoadPlugin = {\n check: (value?: any) => boolean\n get: (value: any) => any\n resolvePath?: (value: any, reference: string) => string\n getDir?: (value: any) => string\n getFilename?: (value: any) => string\n}\n\nexport type LoadOptions = {\n plugins?: LoadPlugin[]\n filename?: string\n filesystem?: Filesystem\n} & ThrowOnErrorOption\n\n/**\n * Loads an OpenAPI document, including any external references.\n *\n * This function handles loading content from various sources, normalizes the content,\n * and recursively loads any external references found within the definition.\n *\n * It builds a filesystem representation of all loaded content and collects any errors\n * encountered during the process.\n */\nexport async function load(value: AnyApiDefinitionFormat, options?: LoadOptions): Promise<LoadResult> {\n const errors: ErrorObject[] = []\n\n // Don\u2019t load a reference twice, check the filesystem before fetching something\n if (options?.filesystem?.find((entry) => entry.filename === value)) {\n return {\n specification: getEntrypoint(options.filesystem)?.specification,\n filesystem: options.filesystem,\n errors,\n }\n }\n\n // Check whether the value is an URL or file path\n const plugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(value))\n\n let content: AnyObject\n\n if (plugin) {\n try {\n content = normalize(await plugin.get(value))\n } catch (_error) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value as string))\n }\n\n errors.push({\n code: 'EXTERNAL_REFERENCE_NOT_FOUND',\n message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value as string),\n })\n\n return {\n specification: null,\n filesystem: [],\n errors,\n }\n }\n } else {\n content = normalize(value)\n }\n\n // No content\n if (content === undefined) {\n if (options?.throwOnError) {\n throw new Error('No content to load')\n }\n\n errors.push({\n code: 'NO_CONTENT',\n message: ERRORS.NO_CONTENT,\n })\n\n return {\n specification: null,\n filesystem: [],\n errors,\n }\n }\n\n let filesystem = makeFilesystem(content, {\n filename: options?.filename ?? null,\n })\n\n // Get references from file system entry, or from the content\n const newEntry = options?.filename\n ? filesystem.find((entry) => entry.filename === options?.filename)\n : getEntrypoint(filesystem)\n\n const listOfReferences = newEntry.references ?? getListOfReferences(content)\n\n // No other references\n if (listOfReferences.length === 0) {\n return {\n specification: getEntrypoint(filesystem)?.specification,\n filesystem,\n errors,\n }\n }\n\n // Load other external references\n for (const reference of listOfReferences) {\n // Find a matching plugin\n const otherPlugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(reference))\n\n // Skip if no plugin is found (internal references don\u2019t need a plugin for example)\n if (!otherPlugin) {\n continue\n }\n\n const target =\n otherPlugin.check(reference) && otherPlugin.resolvePath ? otherPlugin.resolvePath(value, reference) : reference\n\n // Don\u2019t load a reference twice, check the filesystem before fetching something\n if (filesystem.find((entry) => entry.filename === reference)) {\n continue\n }\n\n const { filesystem: referencedFiles, errors: newErrors } = await load(target, {\n ...options,\n // Make the filename the exact same value as the $ref\n // TODO: This leads to problems, if there are multiple references with the same file name but in different folders\n filename: reference,\n })\n\n errors.push(...newErrors)\n\n filesystem = [\n ...filesystem,\n ...referencedFiles.map((file) => {\n return {\n ...file,\n isEntrypoint: false,\n }\n }),\n ]\n }\n\n return {\n specification: getEntrypoint(filesystem)?.specification,\n filesystem,\n errors,\n }\n}\n"],
4
+ "sourcesContent": ["import { ERRORS } from '@/configuration'\nimport type {\n AnyApiDefinitionFormat,\n AnyObject,\n ErrorObject,\n Filesystem,\n LoadResult,\n ThrowOnErrorOption,\n} from '@/types/index'\nimport { getEntrypoint } from '@/utils/get-entrypoint'\nimport { getListOfReferences } from '@/utils/get-list-of-references'\nimport { makeFilesystem } from '@/utils/make-filesystem'\nimport { normalize } from '@/utils/normalize'\n\nexport type LoadPlugin = {\n check: (value?: any) => boolean\n get: (value: any) => any\n resolvePath?: (value: any, reference: string) => string\n getDir?: (value: any) => string\n getFilename?: (value: any) => string\n}\n\nexport type LoadOptions = {\n plugins?: LoadPlugin[]\n filename?: string\n filesystem?: Filesystem\n} & ThrowOnErrorOption\n\n/**\n * Loads an OpenAPI document, including any external references.\n *\n * This function handles loading content from various sources, normalizes the content,\n * and recursively loads any external references found within the definition.\n *\n * It builds a filesystem representation of all loaded content and collects any errors\n * encountered during the process.\n */\nexport async function load(value: AnyApiDefinitionFormat, options?: LoadOptions): Promise<LoadResult> {\n const errors: ErrorObject[] = []\n\n // Don\u2019t load a reference twice, check the filesystem before fetching something\n if (options?.filesystem?.find((entry) => entry.filename === value)) {\n return {\n specification: getEntrypoint(options.filesystem)?.specification,\n filesystem: options.filesystem,\n errors,\n }\n }\n\n // Check whether the value is an URL or file path\n const plugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(value))\n\n let content: AnyObject\n\n if (plugin) {\n try {\n content = normalize(await plugin.get(value))\n } catch (_error) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value as string))\n }\n\n errors.push({\n code: 'EXTERNAL_REFERENCE_NOT_FOUND',\n message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value as string),\n })\n\n return {\n specification: null,\n filesystem: [],\n errors,\n }\n }\n } else {\n content = normalize(value)\n }\n\n // No content\n if (content === undefined) {\n if (options?.throwOnError) {\n throw new Error('No content to load')\n }\n\n errors.push({\n code: 'NO_CONTENT',\n message: ERRORS.NO_CONTENT,\n })\n\n return {\n specification: null,\n filesystem: [],\n errors,\n }\n }\n\n let filesystem = makeFilesystem(content, {\n filename: options?.filename ?? null,\n })\n\n // Get references from file system entry, or from the content\n const newEntry = options?.filename\n ? filesystem.find((entry) => entry.filename === options?.filename)\n : getEntrypoint(filesystem)\n\n const listOfReferences = newEntry.references ?? getListOfReferences(content)\n\n // No other references\n if (listOfReferences.length === 0) {\n return {\n specification: getEntrypoint(filesystem)?.specification,\n filesystem,\n errors,\n }\n }\n\n // Load other external references\n for (const reference of listOfReferences) {\n // Find a matching plugin\n const otherPlugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(reference))\n\n // Skip if no plugin is found (internal references don\u2019t need a plugin for example)\n if (!otherPlugin) {\n continue\n }\n\n const target =\n otherPlugin.check(reference) && otherPlugin.resolvePath ? otherPlugin.resolvePath(value, reference) : reference\n\n // Don\u2019t load a reference twice, check the filesystem before fetching something\n if (filesystem.find((entry) => entry.filename === reference)) {\n continue\n }\n\n const { filesystem: referencedFiles, errors: newErrors } = await load(target, {\n ...options,\n // Make the filename the exact same value as the $ref\n // TODO: This leads to problems, if there are multiple references with the same file name but in different folders\n filename: reference,\n })\n\n errors.push(...newErrors)\n\n filesystem = [\n ...filesystem,\n ...referencedFiles.map((file) => {\n return {\n ...file,\n isEntrypoint: false,\n }\n }),\n ]\n }\n\n return {\n specification: getEntrypoint(filesystem)?.specification,\n filesystem,\n errors,\n }\n}\n"],
5
5
  "mappings": "AAAA,SAAS,cAAc;AASvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAyB1B,eAAsB,KAAK,OAA+B,SAA4C;AACpG,QAAM,SAAwB,CAAC;AAG/B,MAAI,SAAS,YAAY,KAAK,CAAC,UAAU,MAAM,aAAa,KAAK,GAAG;AAClE,WAAO;AAAA,MACL,eAAe,cAAc,QAAQ,UAAU,GAAG;AAAA,MAClD,YAAY,QAAQ;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAGA,QAAM,SAAS,SAAS,SAAS,KAAK,CAAC,eAAe,WAAW,MAAM,KAAK,CAAC;AAE7E,MAAI;AAEJ,MAAI,QAAQ;AACV,QAAI;AACF,gBAAU,UAAU,MAAM,OAAO,IAAI,KAAK,CAAC;AAAA,IAC7C,SAAS,QAAQ;AACf,UAAI,SAAS,cAAc;AACzB,cAAM,IAAI,MAAM,OAAO,6BAA6B,QAAQ,MAAM,KAAe,CAAC;AAAA,MACpF;AAEA,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,SAAS,OAAO,6BAA6B,QAAQ,MAAM,KAAe;AAAA,MAC5E,CAAC;AAED,aAAO;AAAA,QACL,eAAe;AAAA,QACf,YAAY,CAAC;AAAA,QACb;AAAA,MACF;AAAA,IACF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AAAA,UACH,cAAc;AAAA,QAChB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,eAAe,cAAc,UAAU,GAAG;AAAA,IAC1C;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,9 @@
1
1
  import path from "node:path";
2
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
3
  import { stringify } from "yaml";
4
- import { fetchUrls } from "../../plugins/fetch-urls/fetchUrls.js";
5
- import { readFiles } from "../../plugins/read-files/readFiles.js";
6
- import { getEntrypoint } from "../getEntrypoint.js";
4
+ import { fetchUrls } from "../../plugins/fetch-urls/fetch-urls.js";
5
+ import { readFiles } from "../../plugins/read-files/read-files.js";
6
+ import { getEntrypoint } from "../../utils/get-entrypoint.js";
7
7
  import { load } from "./load.js";
8
8
  global.fetch = vi.fn();
9
9
  describe("load", async () => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/load/load.test.ts"],
4
- "sourcesContent": ["import path from 'node:path'\nimport { beforeEach, describe, expect, it, vi } from 'vitest'\nimport { stringify } from 'yaml'\n\nimport { fetchUrls } from '../../plugins/fetch-urls/fetchUrls'\nimport { readFiles } from '../../plugins/read-files/readFiles'\nimport { getEntrypoint } from '../getEntrypoint'\nimport { load } from './load'\n\nglobal.fetch = vi.fn()\n\ndescribe('load', async () => {\n beforeEach(() => {\n // @ts-expect-error\n global.fetch.mockReset()\n })\n\n it('loads JS object', async () => {\n const { filesystem } = await load(\n {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n },\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads JSON string', async () => {\n const { filesystem } = await load(\n JSON.stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n }),\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads YAML string', async () => {\n const { filesystem } = await load(\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n }),\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads file', async () => {\n const EXAMPLE_FILE = path.join(new URL(import.meta.url).pathname, '../../examples/openapi.yaml')\n\n const { filesystem } = await load(EXAMPLE_FILE, {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads referenced files in files', async () => {\n const EXAMPLE_FILE = path.join(new URL(import.meta.url).pathname, '../../../../tests/filesystem/api/openapi.yaml')\n\n const { filesystem } = await load(EXAMPLE_FILE, {\n plugins: [readFiles()],\n })\n\n // filenames\n expect(filesystem.map((entry) => entry.filename)).toStrictEqual([\n null,\n 'schemas/problem.yaml',\n 'schemas/upload.yaml',\n './components/coordinates.yaml',\n ])\n\n // specification\n expect(filesystem[0].specification).toBeTypeOf('object')\n\n // only one entrypoint\n expect(filesystem.filter((entry) => entry.isEntrypoint).length).toBe(1)\n })\n\n it('loads url', async () => {\n // @ts-expect-error\n fetch.mockResolvedValue({\n text: async () =>\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n }),\n })\n\n const { filesystem } = await load('https://example.com/openapi.yaml', {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('handles failed requests', async () => {\n // Failed request\n // @ts-expect-error\n fetch.mockImplementation(() => {\n throw new TypeError('[load.test.ts] fetch failed')\n })\n\n const { filesystem } = await load(\n {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n content: {\n 'application/json': {\n schema: {\n $ref: 'https://DOES_NOT_EXIST',\n },\n },\n },\n },\n },\n },\n },\n },\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('limits the number of requests', async () => {\n // @ts-expect-error\n fetch.mockResolvedValue({\n text: async () => 'FOOBAR',\n })\n\n const { filesystem } = await load(\n {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n content: {\n 'application/json': {\n schema: {\n $ref: 'https://DOES_NOT_EXIST',\n },\n },\n },\n },\n },\n },\n },\n },\n {\n plugins: [\n fetchUrls({\n limit: 0,\n }),\n ],\n },\n )\n\n expect(filesystem.length).toBe(1)\n })\n\n it('loads referenced urls', async () => {\n // @ts-expect-error\n fetch.mockImplementation((url: string) => {\n if (url === 'https://example.com/openapi.yaml') {\n return Promise.resolve({\n text: () =>\n Promise.resolve(\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n }),\n ),\n } as Response)\n }\n\n if (url === 'https://example.com/foobar.json') {\n return {\n text: async () =>\n JSON.stringify({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n }),\n } as Response\n }\n })\n\n const { filesystem } = await load('https://example.com/openapi.yaml', {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(filesystem[0].specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n })\n\n expect(filesystem[1].specification).toMatchObject({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n })\n })\n\n it('loads string with url reference', async () => {\n // @ts-expect-error\n fetch.mockResolvedValue({\n text: async () =>\n JSON.stringify({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n }),\n })\n\n const { filesystem } = await load(\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n }),\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(filesystem.map((entry) => entry.filename)).toStrictEqual([null, 'https://example.com/foobar.json'])\n\n expect(filesystem[0].specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n })\n\n expect(filesystem[1].specification).toMatchObject({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n })\n })\n\n it('returns an error', async () => {\n const { errors } = await load('INVALID', {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(errors).toMatchObject([\n {\n code: 'EXTERNAL_REFERENCE_NOT_FOUND',\n message: 'Can\u2019t resolve external reference: INVALID',\n },\n ])\n })\n\n it('throws an error', async () => {\n expect(async () => {\n await load('INVALID', {\n plugins: [readFiles(), fetchUrls()],\n throwOnError: true,\n })\n }).rejects.toThrowError('Can\u2019t resolve external reference: INVALID')\n })\n})\n"],
4
+ "sourcesContent": ["import path from 'node:path'\nimport { beforeEach, describe, expect, it, vi } from 'vitest'\nimport { stringify } from 'yaml'\n\nimport { fetchUrls } from '@/plugins/fetch-urls/fetch-urls'\nimport { readFiles } from '@/plugins/read-files/read-files'\nimport { getEntrypoint } from '@/utils/get-entrypoint'\nimport { load } from './load'\n\nglobal.fetch = vi.fn()\n\ndescribe('load', async () => {\n beforeEach(() => {\n // @ts-expect-error\n global.fetch.mockReset()\n })\n\n it('loads JS object', async () => {\n const { filesystem } = await load(\n {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n },\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads JSON string', async () => {\n const { filesystem } = await load(\n JSON.stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n }),\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads YAML string', async () => {\n const { filesystem } = await load(\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n }),\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads file', async () => {\n const EXAMPLE_FILE = path.join(new URL(import.meta.url).pathname, '../../examples/openapi.yaml')\n\n const { filesystem } = await load(EXAMPLE_FILE, {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('loads referenced files in files', async () => {\n const EXAMPLE_FILE = path.join(new URL(import.meta.url).pathname, '../../../../tests/filesystem/api/openapi.yaml')\n\n const { filesystem } = await load(EXAMPLE_FILE, {\n plugins: [readFiles()],\n })\n\n // filenames\n expect(filesystem.map((entry) => entry.filename)).toStrictEqual([\n null,\n 'schemas/problem.yaml',\n 'schemas/upload.yaml',\n './components/coordinates.yaml',\n ])\n\n // specification\n expect(filesystem[0].specification).toBeTypeOf('object')\n\n // only one entrypoint\n expect(filesystem.filter((entry) => entry.isEntrypoint).length).toBe(1)\n })\n\n it('loads url', async () => {\n // @ts-expect-error\n fetch.mockResolvedValue({\n text: async () =>\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n }),\n })\n\n const { filesystem } = await load('https://example.com/openapi.yaml', {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('handles failed requests', async () => {\n // Failed request\n // @ts-expect-error\n fetch.mockImplementation(() => {\n throw new TypeError('[load.test.ts] fetch failed')\n })\n\n const { filesystem } = await load(\n {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n content: {\n 'application/json': {\n schema: {\n $ref: 'https://DOES_NOT_EXIST',\n },\n },\n },\n },\n },\n },\n },\n },\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(getEntrypoint(filesystem).specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n })\n\n it('limits the number of requests', async () => {\n // @ts-expect-error\n fetch.mockResolvedValue({\n text: async () => 'FOOBAR',\n })\n\n const { filesystem } = await load(\n {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n content: {\n 'application/json': {\n schema: {\n $ref: 'https://DOES_NOT_EXIST',\n },\n },\n },\n },\n },\n },\n },\n },\n {\n plugins: [\n fetchUrls({\n limit: 0,\n }),\n ],\n },\n )\n\n expect(filesystem.length).toBe(1)\n })\n\n it('loads referenced urls', async () => {\n // @ts-expect-error\n fetch.mockImplementation((url: string) => {\n if (url === 'https://example.com/openapi.yaml') {\n return Promise.resolve({\n text: () =>\n Promise.resolve(\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n }),\n ),\n } as Response)\n }\n\n if (url === 'https://example.com/foobar.json') {\n return {\n text: async () =>\n JSON.stringify({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n }),\n } as Response\n }\n })\n\n const { filesystem } = await load('https://example.com/openapi.yaml', {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(filesystem[0].specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n })\n\n expect(filesystem[1].specification).toMatchObject({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n })\n })\n\n it('loads string with url reference', async () => {\n // @ts-expect-error\n fetch.mockResolvedValue({\n text: async () =>\n JSON.stringify({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n }),\n })\n\n const { filesystem } = await load(\n stringify({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n }),\n {\n plugins: [readFiles(), fetchUrls()],\n },\n )\n\n expect(filesystem.map((entry) => entry.filename)).toStrictEqual([null, 'https://example.com/foobar.json'])\n\n expect(filesystem[0].specification).toMatchObject({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: 'https://example.com/foobar.json',\n },\n },\n },\n },\n })\n\n expect(filesystem[1].specification).toMatchObject({\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n example: 'foobar',\n },\n },\n },\n })\n })\n\n it('returns an error', async () => {\n const { errors } = await load('INVALID', {\n plugins: [readFiles(), fetchUrls()],\n })\n\n expect(errors).toMatchObject([\n {\n code: 'EXTERNAL_REFERENCE_NOT_FOUND',\n message: 'Can\u2019t resolve external reference: INVALID',\n },\n ])\n })\n\n it('throws an error', async () => {\n expect(async () => {\n await load('INVALID', {\n plugins: [readFiles(), fetchUrls()],\n throwOnError: true,\n })\n }).rejects.toThrowError('Can\u2019t resolve external reference: INVALID')\n })\n})\n"],
5
5
  "mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,YAAY,UAAU,QAAQ,IAAI,UAAU;AACrD,SAAS,iBAAiB;AAE1B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAErB,OAAO,QAAQ,GAAG,GAAG;AAErB,SAAS,QAAQ,YAAY;AAC3B,aAAW,MAAM;AAEf,WAAO,MAAM,UAAU;AAAA,EACzB,CAAC;AAED,KAAG,mBAAmB,YAAY;AAChC,UAAM,EAAE,WAAW,IAAI,MAAM;AAAA,MAC3B;AAAA,QACE,SAAS;AAAA,QACT,MAAM;AAAA,UACJ,OAAO;AAAA,UACP,SAAS;AAAA,QACX;AAAA,QACA,OAAO,CAAC;AAAA,MACV;AAAA,MACA;AAAA,QACE,SAAS,CAA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F;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO,WAAW,CAAC,EAAE,aAAa,EAAE,cAAc;AAAA,MAChD,SAAS;AAAA,QACP,oBAAoB;AAAA,UAClB,QAAQ;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,KAAG,oBAAoB,YAAY;AACjC,UAAM,EAAE,OAAO,IAAI,MAAM,KAAK,WAAW;AAAA,MACvC,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC;AAAA,IACpC,CAAC;AAED,WAAO,MAAM,EAAE,cAAc;AAAA,MAC3B;AAAA,QACE,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,KAAG,mBAAmB,YAAY;AAChC,WAAO,YAAY;AACjB,YAAM,KAAK,WAAW;AAAA,QACpB,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC;AAAA,QAClC,cAAc;AAAA,MAChB,CAAC;AAAA,IACH,CAAC,EAAE,QAAQ,aAAa,gDAA2C;AAAA,EACrE,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,3 @@
1
1
  import type { AnyObject, Filesystem, FilesystemEntry } from '../types/index.js';
2
2
  export declare function makeFilesystem(value: string | AnyObject | Filesystem, overwrites?: Partial<FilesystemEntry>): Filesystem;
3
- //# sourceMappingURL=makeFilesystem.d.ts.map
3
+ //# sourceMappingURL=make-filesystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-filesystem.d.ts","sourceRoot":"","sources":["../../src/utils/make-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAK3E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EACtC,UAAU,GAAE,OAAO,CAAC,eAAe,CAAM,GACxC,UAAU,CAoBZ"}
@@ -1,5 +1,5 @@
1
- import { getListOfReferences } from "./getListOfReferences.js";
2
- import { isFilesystem } from "./isFilesystem.js";
1
+ import { getListOfReferences } from "./get-list-of-references.js";
2
+ import { isFilesystem } from "./is-filesystem.js";
3
3
  import { normalize } from "./normalize.js";
4
4
  function makeFilesystem(value, overwrites = {}) {
5
5
  if (isFilesystem(value)) {
@@ -20,4 +20,4 @@ function makeFilesystem(value, overwrites = {}) {
20
20
  export {
21
21
  makeFilesystem
22
22
  };
23
- //# sourceMappingURL=makeFilesystem.js.map
23
+ //# sourceMappingURL=make-filesystem.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/make-filesystem.ts"],
4
+ "sourcesContent": ["import type { AnyObject, Filesystem, FilesystemEntry } from '@/types/index'\nimport { getListOfReferences } from './get-list-of-references'\nimport { isFilesystem } from './is-filesystem'\nimport { normalize } from './normalize'\n\nexport function makeFilesystem(\n value: string | AnyObject | Filesystem,\n overwrites: Partial<FilesystemEntry> = {},\n): Filesystem {\n // Keep as is\n if (isFilesystem(value)) {\n return value as Filesystem\n }\n\n // Make an object\n const specification = normalize(value)\n\n // Create fake filesystem\n return [\n {\n isEntrypoint: true,\n specification,\n filename: null,\n dir: './',\n references: getListOfReferences(specification),\n ...overwrites,\n },\n ]\n}\n"],
5
+ "mappings": "AACA,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAEnB,SAAS,eACd,OACA,aAAuC,CAAC,GAC5B;AAEZ,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO;AAAA,EACT;AAGA,QAAM,gBAAgB,UAAU,KAAK;AAGrC,SAAO;AAAA,IACL;AAAA,MACE,cAAc;AAAA,MACd;AAAA,MACA,UAAU;AAAA,MACV,KAAK;AAAA,MACL,YAAY,oBAAoB,aAAa;AAAA,MAC7C,GAAG;AAAA,IACL;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,CAwBxG"}
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,CAwBxG"}
@@ -1,5 +1,5 @@
1
1
  import { parse } from "yaml";
2
- import { isFilesystem } from "./isFilesystem.js";
2
+ import { isFilesystem } from "./is-filesystem.js";
3
3
  function normalize(specification) {
4
4
  if (specification === null) {
5
5
  return {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/normalize.ts"],
4
- "sourcesContent": ["import type { UnknownObject } from '@scalar/types/utils'\nimport { parse } from 'yaml'\n\nimport type { Filesystem } from '../types/index'\nimport { isFilesystem } from './isFilesystem'\n\n/**\n * Normalize the OpenAPI document (YAML, JSON, object) to a JavaScript object.\n *\n * Doesn\u2019t modify the object if it\u2019s a `Filesystem` (multiple files) already.\n */\nexport function normalize(specification: string | UnknownObject | Filesystem): UnknownObject | Filesystem {\n if (specification === null) {\n return {}\n }\n\n if (typeof specification === 'string') {\n if (specification.trim() === '') {\n return {}\n }\n\n try {\n return JSON.parse(specification)\n } catch (_error) {\n return parse(specification, {\n maxAliasCount: 10000,\n })\n }\n }\n\n if (isFilesystem(specification)) {\n return specification as Filesystem\n }\n\n return specification\n}\n"],
4
+ "sourcesContent": ["import type { UnknownObject } from '@scalar/types/utils'\nimport { parse } from 'yaml'\n\nimport type { Filesystem } from '@/types/index'\nimport { isFilesystem } from './is-filesystem'\n\n/**\n * Normalize the OpenAPI document (YAML, JSON, object) to a JavaScript object.\n *\n * Doesn\u2019t modify the object if it\u2019s a `Filesystem` (multiple files) already.\n */\nexport function normalize(specification: string | UnknownObject | Filesystem): UnknownObject | Filesystem {\n if (specification === null) {\n return {}\n }\n\n if (typeof specification === 'string') {\n if (specification.trim() === '') {\n return {}\n }\n\n try {\n return JSON.parse(specification)\n } catch (_error) {\n return parse(specification, {\n maxAliasCount: 10000,\n })\n }\n }\n\n if (isFilesystem(specification)) {\n return specification as Filesystem\n }\n\n return specification\n}\n"],
5
5
  "mappings": "AACA,SAAS,aAAa;AAGtB,SAAS,oBAAoB;AAOtB,SAAS,UAAU,eAAgF;AACxG,MAAI,kBAAkB,MAAM;AAC1B,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,OAAO,kBAAkB,UAAU;AACrC,QAAI,cAAc,KAAK,MAAM,IAAI;AAC/B,aAAO,CAAC;AAAA,IACV;AAEA,QAAI;AACF,aAAO,KAAK,MAAM,aAAa;AAAA,IACjC,SAAS,QAAQ;AACf,aAAO,MAAM,eAAe;AAAA,QAC1B,eAAe;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,aAAa,aAAa,GAAG;AAC/B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -20,4 +20,4 @@ export type ResolveReferencesOptions = ThrowOnErrorOption & {
20
20
  * Takes a specification and resolves all references.
21
21
  */
22
22
  export declare function resolveReferences(input: AnyObject | Filesystem, options?: ResolveReferencesOptions, file?: FilesystemEntry, errors?: ErrorObject[]): ResolveReferencesResult;
23
- //# sourceMappingURL=resolveReferences.d.ts.map
23
+ //# sourceMappingURL=resolve-references.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveReferences.d.ts","sourceRoot":"","sources":["../../src/utils/resolveReferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAe7G,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IAC1D;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,SAAS,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACnE,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAE/B,KAAK,EAAE,SAAS,GAAG,UAAU,EAE7B,OAAO,CAAC,EAAE,wBAAwB,EAElC,IAAI,CAAC,EAAE,eAAe,EAEtB,MAAM,GAAE,WAAW,EAAO,GACzB,uBAAuB,CA0BzB"}
1
+ {"version":3,"file":"resolve-references.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAe5G,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAA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