@scalar/openapi-parser 0.10.16 → 0.11.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 (339) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +0 -27
  3. package/dist/configuration/index.js +19 -22
  4. package/dist/configuration/index.js.map +7 -0
  5. package/dist/declarations.d.js +1 -0
  6. package/dist/declarations.d.js.map +7 -0
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +5 -29
  10. package/dist/index.js.map +7 -0
  11. package/dist/lib/Validator/Validator.d.ts +2 -2
  12. package/dist/lib/Validator/Validator.d.ts.map +1 -1
  13. package/dist/lib/Validator/Validator.js +99 -119
  14. package/dist/lib/Validator/Validator.js.map +7 -0
  15. package/dist/lib/Validator/Validator.test.js +8 -0
  16. package/dist/lib/Validator/Validator.test.js.map +7 -0
  17. package/dist/lib/Validator/index.d.ts +2 -2
  18. package/dist/lib/Validator/index.d.ts.map +1 -1
  19. package/dist/lib/Validator/index.js +3 -0
  20. package/dist/lib/Validator/index.js.map +7 -0
  21. package/dist/plugins/fetch-urls/fetchUrls.d.ts +1 -1
  22. package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +1 -1
  23. package/dist/plugins/fetch-urls/fetchUrls.js +36 -39
  24. package/dist/plugins/fetch-urls/fetchUrls.js.map +7 -0
  25. package/dist/plugins/fetch-urls/fetchUrls.test.js +50 -0
  26. package/dist/plugins/fetch-urls/fetchUrls.test.js.map +7 -0
  27. package/dist/plugins/fetch-urls/index.d.ts +1 -1
  28. package/dist/plugins/fetch-urls/index.d.ts.map +1 -1
  29. package/dist/plugins/fetch-urls/index.js +2 -1
  30. package/dist/plugins/fetch-urls/index.js.map +7 -0
  31. package/dist/plugins/read-files/index.d.ts +1 -1
  32. package/dist/plugins/read-files/index.d.ts.map +1 -1
  33. package/dist/plugins/read-files/index.js +2 -1
  34. package/dist/plugins/read-files/index.js.map +7 -0
  35. package/dist/plugins/read-files/readFiles.d.ts +1 -1
  36. package/dist/plugins/read-files/readFiles.d.ts.map +1 -1
  37. package/dist/plugins/read-files/readFiles.js +50 -55
  38. package/dist/plugins/read-files/readFiles.js.map +7 -0
  39. package/dist/plugins/read-files/readFiles.test.js +20 -0
  40. package/dist/plugins/read-files/readFiles.test.js.map +7 -0
  41. package/dist/polyfills/index.d.ts +1 -1
  42. package/dist/polyfills/index.d.ts.map +1 -1
  43. package/dist/polyfills/index.js +5 -0
  44. package/dist/polyfills/index.js.map +7 -0
  45. package/dist/polyfills/path.js +155 -98
  46. package/dist/polyfills/path.js.map +7 -0
  47. package/dist/schemas/v2.0/schema.d.ts +1405 -0
  48. package/dist/schemas/v2.0/schema.d.ts.map +1 -0
  49. package/dist/schemas/v2.0/schema.js +1463 -0
  50. package/dist/schemas/v2.0/schema.js.map +7 -0
  51. package/dist/schemas/v3.0/schema.d.ts +1264 -0
  52. package/dist/schemas/v3.0/schema.d.ts.map +1 -0
  53. package/dist/schemas/v3.0/schema.js +1493 -0
  54. package/dist/schemas/v3.0/schema.js.map +7 -0
  55. package/dist/schemas/v3.1/schema.d.ts +1225 -0
  56. package/dist/schemas/v3.1/schema.d.ts.map +1 -0
  57. package/dist/schemas/v3.1/schema.js +1296 -0
  58. package/dist/schemas/v3.1/schema.js.map +7 -0
  59. package/dist/types/index.d.ts +1 -1
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/types/index.js +1 -0
  62. package/dist/types/index.js.map +7 -0
  63. package/dist/utils/betterAjvErrors/helpers.js +88 -93
  64. package/dist/utils/betterAjvErrors/helpers.js.map +7 -0
  65. package/dist/utils/betterAjvErrors/index.js +14 -13
  66. package/dist/utils/betterAjvErrors/index.js.map +7 -0
  67. package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts +2 -0
  68. package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts.map +1 -0
  69. package/dist/utils/betterAjvErrors/json/get-meta-from-path.js +27 -0
  70. package/dist/utils/betterAjvErrors/json/get-meta-from-path.js.map +7 -0
  71. package/dist/utils/betterAjvErrors/json/index.d.ts +2 -0
  72. package/dist/utils/betterAjvErrors/json/index.d.ts.map +1 -0
  73. package/dist/utils/betterAjvErrors/json/index.js +5 -0
  74. package/dist/utils/betterAjvErrors/json/index.js.map +7 -0
  75. package/dist/utils/betterAjvErrors/json/utils.d.ts +2 -0
  76. package/dist/utils/betterAjvErrors/json/utils.d.ts.map +1 -0
  77. package/dist/utils/betterAjvErrors/json/utils.js +11 -0
  78. package/dist/utils/betterAjvErrors/json/utils.js.map +7 -0
  79. package/dist/utils/betterAjvErrors/utils.js +21 -14
  80. package/dist/utils/betterAjvErrors/utils.js.map +7 -0
  81. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts +10 -0
  82. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts.map +1 -0
  83. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js +8 -9
  84. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js.map +7 -0
  85. package/dist/utils/betterAjvErrors/validation-errors/base.d.ts +23 -0
  86. package/dist/utils/betterAjvErrors/validation-errors/base.d.ts.map +1 -0
  87. package/dist/utils/betterAjvErrors/validation-errors/base.js +6 -10
  88. package/dist/utils/betterAjvErrors/validation-errors/base.js.map +7 -0
  89. package/dist/utils/betterAjvErrors/validation-errors/default.d.ts +10 -0
  90. package/dist/utils/betterAjvErrors/validation-errors/default.d.ts.map +1 -0
  91. package/dist/utils/betterAjvErrors/validation-errors/default.js +8 -9
  92. package/dist/utils/betterAjvErrors/validation-errors/default.js.map +7 -0
  93. package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts +11 -0
  94. package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts.map +1 -0
  95. package/dist/utils/betterAjvErrors/validation-errors/enum.js +19 -29
  96. package/dist/utils/betterAjvErrors/validation-errors/enum.js.map +7 -0
  97. package/dist/utils/betterAjvErrors/validation-errors/index.d.ts +7 -0
  98. package/dist/utils/betterAjvErrors/validation-errors/index.d.ts.map +1 -0
  99. package/dist/utils/betterAjvErrors/validation-errors/index.js +15 -0
  100. package/dist/utils/betterAjvErrors/validation-errors/index.js.map +7 -0
  101. package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts +10 -0
  102. package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts.map +1 -0
  103. package/dist/utils/betterAjvErrors/validation-errors/pattern.js +8 -9
  104. package/dist/utils/betterAjvErrors/validation-errors/pattern.js.map +7 -0
  105. package/dist/utils/betterAjvErrors/validation-errors/required.d.ts +10 -0
  106. package/dist/utils/betterAjvErrors/validation-errors/required.d.ts.map +1 -0
  107. package/dist/utils/betterAjvErrors/validation-errors/required.js +8 -9
  108. package/dist/utils/betterAjvErrors/validation-errors/required.js.map +7 -0
  109. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts +10 -0
  110. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts.map +1 -0
  111. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +8 -9
  112. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js.map +7 -0
  113. package/dist/utils/dereference.d.ts +2 -2
  114. package/dist/utils/dereference.d.ts.map +1 -1
  115. package/dist/utils/dereference.js +17 -19
  116. package/dist/utils/dereference.js.map +7 -0
  117. package/dist/utils/dereference.test.js +300 -0
  118. package/dist/utils/dereference.test.js.map +7 -0
  119. package/dist/utils/details.d.ts +1 -1
  120. package/dist/utils/details.d.ts.map +1 -1
  121. package/dist/utils/details.js +26 -28
  122. package/dist/utils/details.js.map +7 -0
  123. package/dist/utils/errors.test.js +48 -0
  124. package/dist/utils/errors.test.js.map +7 -0
  125. package/dist/utils/escapeJsonPointer.js +5 -8
  126. package/dist/utils/escapeJsonPointer.js.map +7 -0
  127. package/dist/utils/escapeJsonPointer.test.js +11 -0
  128. package/dist/utils/escapeJsonPointer.test.js.map +7 -0
  129. package/dist/utils/filter.d.ts +1 -1
  130. package/dist/utils/filter.d.ts.map +1 -1
  131. package/dist/utils/filter.js +13 -15
  132. package/dist/utils/filter.js.map +7 -0
  133. package/dist/utils/getEntrypoint.d.ts +1 -1
  134. package/dist/utils/getEntrypoint.d.ts.map +1 -1
  135. package/dist/utils/getEntrypoint.js +5 -6
  136. package/dist/utils/getEntrypoint.js.map +7 -0
  137. package/dist/utils/getEntrypoint.test.js +18 -0
  138. package/dist/utils/getEntrypoint.test.js.map +7 -0
  139. package/dist/utils/getListOfReferences.d.ts +1 -1
  140. package/dist/utils/getListOfReferences.d.ts.map +1 -1
  141. package/dist/utils/getListOfReferences.js +15 -22
  142. package/dist/utils/getListOfReferences.js.map +7 -0
  143. package/dist/utils/getSegmentsFromPath.js +8 -15
  144. package/dist/utils/getSegmentsFromPath.js.map +7 -0
  145. package/dist/utils/getSegmentsFromPath.test.js +13 -0
  146. package/dist/utils/getSegmentsFromPath.test.js.map +7 -0
  147. package/dist/utils/index.d.ts +26 -26
  148. package/dist/utils/index.d.ts.map +1 -1
  149. package/dist/utils/index.js +27 -0
  150. package/dist/utils/index.js.map +7 -0
  151. package/dist/utils/isFilesystem.d.ts +2 -1
  152. package/dist/utils/isFilesystem.d.ts.map +1 -1
  153. package/dist/utils/isFilesystem.js +5 -9
  154. package/dist/utils/isFilesystem.js.map +7 -0
  155. package/dist/utils/isJson.js +10 -9
  156. package/dist/utils/isJson.js.map +7 -0
  157. package/dist/utils/isObject.js +5 -6
  158. package/dist/utils/isObject.js.map +7 -0
  159. package/dist/utils/isObject.test.js +23 -0
  160. package/dist/utils/isObject.test.js.map +7 -0
  161. package/dist/utils/isYaml.js +16 -17
  162. package/dist/utils/isYaml.js.map +7 -0
  163. package/dist/utils/load/index.d.ts +1 -1
  164. package/dist/utils/load/index.d.ts.map +1 -1
  165. package/dist/utils/load/index.js +2 -0
  166. package/dist/utils/load/index.js.map +7 -0
  167. package/dist/utils/load/load.d.ts +1 -1
  168. package/dist/utils/load/load.d.ts.map +1 -1
  169. package/dist/utils/load/load.js +89 -110
  170. package/dist/utils/load/load.js.map +7 -0
  171. package/dist/utils/load/load.test.js +361 -0
  172. package/dist/utils/load/load.test.js.map +7 -0
  173. package/dist/utils/makeFilesystem.d.ts +1 -1
  174. package/dist/utils/makeFilesystem.d.ts.map +1 -1
  175. package/dist/utils/makeFilesystem.js +20 -22
  176. package/dist/utils/makeFilesystem.js.map +7 -0
  177. package/dist/utils/makeFilesystem.test.js +15 -0
  178. package/dist/utils/makeFilesystem.test.js.map +7 -0
  179. package/dist/utils/normalize.d.ts +1 -1
  180. package/dist/utils/normalize.d.ts.map +1 -1
  181. package/dist/utils/normalize.js +22 -27
  182. package/dist/utils/normalize.js.map +7 -0
  183. package/dist/utils/normalize.test.js +88 -0
  184. package/dist/utils/normalize.test.js.map +7 -0
  185. package/dist/utils/openapi/actions/details.d.ts +2 -2
  186. package/dist/utils/openapi/actions/details.d.ts.map +1 -1
  187. package/dist/utils/openapi/actions/details.js +9 -11
  188. package/dist/utils/openapi/actions/details.js.map +7 -0
  189. package/dist/utils/openapi/actions/files.d.ts +1 -1
  190. package/dist/utils/openapi/actions/files.d.ts.map +1 -1
  191. package/dist/utils/openapi/actions/files.js +7 -9
  192. package/dist/utils/openapi/actions/files.js.map +7 -0
  193. package/dist/utils/openapi/actions/get.d.ts +1 -1
  194. package/dist/utils/openapi/actions/get.d.ts.map +1 -1
  195. package/dist/utils/openapi/actions/get.js +9 -11
  196. package/dist/utils/openapi/actions/get.js.map +7 -0
  197. package/dist/utils/openapi/actions/toJson.d.ts +1 -1
  198. package/dist/utils/openapi/actions/toJson.d.ts.map +1 -1
  199. package/dist/utils/openapi/actions/toJson.js +9 -11
  200. package/dist/utils/openapi/actions/toJson.js.map +7 -0
  201. package/dist/utils/openapi/actions/toYaml.d.ts +1 -1
  202. package/dist/utils/openapi/actions/toYaml.d.ts.map +1 -1
  203. package/dist/utils/openapi/actions/toYaml.js +9 -11
  204. package/dist/utils/openapi/actions/toYaml.js.map +7 -0
  205. package/dist/utils/openapi/commands/dereferenceCommand.d.ts +5 -5
  206. package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +1 -1
  207. package/dist/utils/openapi/commands/dereferenceCommand.js +25 -27
  208. package/dist/utils/openapi/commands/dereferenceCommand.js.map +7 -0
  209. package/dist/utils/openapi/commands/filterCommand.d.ts +9 -9
  210. package/dist/utils/openapi/commands/filterCommand.d.ts.map +1 -1
  211. package/dist/utils/openapi/commands/filterCommand.js +24 -26
  212. package/dist/utils/openapi/commands/filterCommand.js.map +7 -0
  213. package/dist/utils/openapi/commands/loadCommand.d.ts +994 -994
  214. package/dist/utils/openapi/commands/loadCommand.d.ts.map +1 -1
  215. package/dist/utils/openapi/commands/loadCommand.js +40 -42
  216. package/dist/utils/openapi/commands/loadCommand.js.map +7 -0
  217. package/dist/utils/openapi/commands/upgradeCommand.d.ts +311 -311
  218. package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +1 -1
  219. package/dist/utils/openapi/commands/upgradeCommand.js +27 -29
  220. package/dist/utils/openapi/commands/upgradeCommand.js.map +7 -0
  221. package/dist/utils/openapi/commands/validateCommand.d.ts +311 -311
  222. package/dist/utils/openapi/commands/validateCommand.d.ts.map +1 -1
  223. package/dist/utils/openapi/commands/validateCommand.js +31 -33
  224. package/dist/utils/openapi/commands/validateCommand.js.map +7 -0
  225. package/dist/utils/openapi/index.d.ts +1 -1
  226. package/dist/utils/openapi/index.d.ts.map +1 -1
  227. package/dist/utils/openapi/index.js +2 -0
  228. package/dist/utils/openapi/index.js.map +7 -0
  229. package/dist/utils/openapi/openapi.d.ts +702 -700
  230. package/dist/utils/openapi/openapi.d.ts.map +1 -1
  231. package/dist/utils/openapi/openapi.js +13 -16
  232. package/dist/utils/openapi/openapi.js.map +7 -0
  233. package/dist/utils/openapi/openapi.test-d.js +14 -0
  234. package/dist/utils/openapi/openapi.test-d.js.map +7 -0
  235. package/dist/utils/openapi/openapi.test.js +309 -0
  236. package/dist/utils/openapi/openapi.test.js.map +7 -0
  237. package/dist/utils/openapi/utils/queueTask.d.ts +1 -1
  238. package/dist/utils/openapi/utils/queueTask.d.ts.map +1 -1
  239. package/dist/utils/openapi/utils/queueTask.js +8 -9
  240. package/dist/utils/openapi/utils/queueTask.js.map +7 -0
  241. package/dist/utils/openapi/utils/workThroughQueue.d.ts +1 -1
  242. package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +1 -1
  243. package/dist/utils/openapi/utils/workThroughQueue.js +49 -64
  244. package/dist/utils/openapi/utils/workThroughQueue.js.map +7 -0
  245. package/dist/utils/openapi/utils/workThroughQueue.test.js +244 -0
  246. package/dist/utils/openapi/utils/workThroughQueue.test.js.map +7 -0
  247. package/dist/utils/resolveReferences.d.ts +1 -1
  248. package/dist/utils/resolveReferences.d.ts.map +1 -1
  249. package/dist/utils/resolveReferences.js +91 -139
  250. package/dist/utils/resolveReferences.js.map +7 -0
  251. package/dist/utils/resolveReferences.test.js +567 -0
  252. package/dist/utils/resolveReferences.test.js.map +7 -0
  253. package/dist/utils/toJson.d.ts +1 -1
  254. package/dist/utils/toJson.d.ts.map +1 -1
  255. package/dist/utils/toJson.js +4 -2
  256. package/dist/utils/toJson.js.map +7 -0
  257. package/dist/utils/toYaml.d.ts +1 -1
  258. package/dist/utils/toYaml.d.ts.map +1 -1
  259. package/dist/utils/toYaml.js +5 -4
  260. package/dist/utils/toYaml.js.map +7 -0
  261. package/dist/utils/transform/index.d.ts +1 -1
  262. package/dist/utils/transform/index.d.ts.map +1 -1
  263. package/dist/utils/transform/index.js +2 -0
  264. package/dist/utils/transform/index.js.map +7 -0
  265. package/dist/utils/transform/sanitize.d.ts +3 -3
  266. package/dist/utils/transform/sanitize.d.ts.map +1 -1
  267. package/dist/utils/transform/sanitize.js +22 -21
  268. package/dist/utils/transform/sanitize.js.map +7 -0
  269. package/dist/utils/transform/sanitize.test.js +148 -0
  270. package/dist/utils/transform/sanitize.test.js.map +7 -0
  271. package/dist/utils/transform/utils/addInfoObject.d.ts +1 -1
  272. package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
  273. package/dist/utils/transform/utils/addInfoObject.js +14 -10
  274. package/dist/utils/transform/utils/addInfoObject.js.map +7 -0
  275. package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts +1 -1
  276. package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts.map +1 -1
  277. package/dist/utils/transform/utils/addLatestOpenApiVersion.js +8 -5
  278. package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +7 -0
  279. package/dist/utils/transform/utils/addMissingTags.d.ts +1 -1
  280. package/dist/utils/transform/utils/addMissingTags.d.ts.map +1 -1
  281. package/dist/utils/transform/utils/addMissingTags.js +26 -27
  282. package/dist/utils/transform/utils/addMissingTags.js.map +7 -0
  283. package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts +1 -1
  284. package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts.map +1 -1
  285. package/dist/utils/transform/utils/normalizeSecuritySchemes.js +36 -40
  286. package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +7 -0
  287. package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts +1 -1
  288. package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts.map +1 -1
  289. package/dist/utils/transform/utils/rejectSwaggerDocuments.js +8 -6
  290. package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +7 -0
  291. package/dist/utils/transformErrors.d.ts +1 -1
  292. package/dist/utils/transformErrors.d.ts.map +1 -1
  293. package/dist/utils/transformErrors.js +18 -21
  294. package/dist/utils/transformErrors.js.map +7 -0
  295. package/dist/utils/transformErrors.test.js +17 -0
  296. package/dist/utils/transformErrors.test.js.map +7 -0
  297. package/dist/utils/traverse.d.ts +3 -3
  298. package/dist/utils/traverse.d.ts.map +1 -1
  299. package/dist/utils/traverse.js +22 -23
  300. package/dist/utils/traverse.js.map +7 -0
  301. package/dist/utils/traverse.test.js +68 -0
  302. package/dist/utils/traverse.test.js.map +7 -0
  303. package/dist/utils/unescapeJsonPointer.js +5 -9
  304. package/dist/utils/unescapeJsonPointer.js.map +7 -0
  305. package/dist/utils/unescapeJsonPointer.test.js +19 -0
  306. package/dist/utils/unescapeJsonPointer.test.js.map +7 -0
  307. package/dist/utils/upgrade.bench.d.ts +2 -0
  308. package/dist/utils/upgrade.bench.d.ts.map +1 -0
  309. package/dist/utils/upgrade.bench.js +31 -0
  310. package/dist/utils/upgrade.bench.js.map +7 -0
  311. package/dist/utils/upgrade.d.ts +1 -1
  312. package/dist/utils/upgrade.d.ts.map +1 -1
  313. package/dist/utils/upgrade.js +28 -22
  314. package/dist/utils/upgrade.js.map +7 -0
  315. package/dist/utils/upgrade.test-d.js +16 -0
  316. package/dist/utils/upgrade.test-d.js.map +7 -0
  317. package/dist/utils/upgrade.test.js +57 -0
  318. package/dist/utils/upgrade.test.js.map +7 -0
  319. package/dist/utils/upgradeFromThreeToThreeOne.d.ts +3 -3
  320. package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +1 -1
  321. package/dist/utils/upgradeFromThreeToThreeOne.js +107 -144
  322. package/dist/utils/upgradeFromThreeToThreeOne.js.map +7 -0
  323. package/dist/utils/upgradeFromThreeToThreeOne.test.js +462 -0
  324. package/dist/utils/upgradeFromThreeToThreeOne.test.js.map +7 -0
  325. package/dist/utils/upgradeFromTwoToThree.d.ts.map +1 -1
  326. package/dist/utils/upgradeFromTwoToThree.js +212 -219
  327. package/dist/utils/upgradeFromTwoToThree.js.map +7 -0
  328. package/dist/utils/upgradeFromTwoToThree.test.js +589 -0
  329. package/dist/utils/upgradeFromTwoToThree.test.js.map +7 -0
  330. package/dist/utils/validate.d.ts +1 -1
  331. package/dist/utils/validate.d.ts.map +1 -1
  332. package/dist/utils/validate.js +14 -16
  333. package/dist/utils/validate.js.map +7 -0
  334. package/dist/utils/validate.test.js +64 -0
  335. package/dist/utils/validate.test.js.map +7 -0
  336. package/package.json +7 -8
  337. package/dist/schemas/v2.0/schema.json.js +0 -1623
  338. package/dist/schemas/v3.0/schema.json.js +0 -1673
  339. package/dist/schemas/v3.1/schema.json.js +0 -1451
@@ -0,0 +1,50 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { fetchUrls } from "./fetchUrls.js";
3
+ global.fetch = vi.fn();
4
+ describe("fetchUrls", async () => {
5
+ beforeEach(() => {
6
+ global.fetch.mockReset();
7
+ });
8
+ it("returns true for an url", async () => {
9
+ expect(fetchUrls().check("http://example.com/specification/openapi.yaml")).toBe(true);
10
+ });
11
+ it("returns false for a filename", async () => {
12
+ expect(fetchUrls().check("openapi.yaml")).toBe(false);
13
+ });
14
+ it("returns false for a path", async () => {
15
+ expect(fetchUrls().check("specification/openapi.yaml")).toBe(false);
16
+ });
17
+ it("returns false for an object", async () => {
18
+ expect(fetchUrls().check({})).toBe(false);
19
+ });
20
+ it("returns false for undefinded", async () => {
21
+ expect(fetchUrls().check()).toBe(false);
22
+ });
23
+ it("fetches the URL", async () => {
24
+ fetch.mockImplementation(async (url) => ({
25
+ text: async () => {
26
+ if (url === "http://example.com/specification/openapi.yaml") {
27
+ return "OK";
28
+ }
29
+ throw new Error("Not found");
30
+ }
31
+ }));
32
+ expect(await fetchUrls().get("http://example.com/specification/openapi.yaml")).toBe("OK");
33
+ });
34
+ it("rewrites the URL", async () => {
35
+ fetch.mockImplementation(async (url) => ({
36
+ text: async () => {
37
+ if (url === "http://foobar.com/specification/openapi.yaml") {
38
+ return "OK";
39
+ }
40
+ throw new Error("Not found");
41
+ }
42
+ }));
43
+ expect(
44
+ await fetchUrls({
45
+ fetch: (url) => fetch(url.replace("example", "foobar"))
46
+ }).get("http://foobar.com/specification/openapi.yaml")
47
+ ).toBe("OK");
48
+ });
49
+ });
50
+ //# sourceMappingURL=fetchUrls.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/fetch-urls/fetchUrls.test.ts"],
4
+ "sourcesContent": ["import { beforeEach, describe, expect, it, vi } from 'vitest'\n\nimport { fetchUrls } from './fetchUrls'\n\nglobal.fetch = vi.fn()\n\ndescribe('fetchUrls', async () => {\n beforeEach(() => {\n // @ts-expect-error\n global.fetch.mockReset()\n })\n\n it('returns true for an url', async () => {\n expect(fetchUrls().check('http://example.com/specification/openapi.yaml')).toBe(true)\n })\n\n it('returns false for a filename', async () => {\n expect(fetchUrls().check('openapi.yaml')).toBe(false)\n })\n\n it('returns false for a path', async () => {\n expect(fetchUrls().check('specification/openapi.yaml')).toBe(false)\n })\n\n it('returns false for an object', async () => {\n expect(fetchUrls().check({})).toBe(false)\n })\n\n it('returns false for undefinded', async () => {\n expect(fetchUrls().check()).toBe(false)\n })\n\n it('fetches the URL', async () => {\n // @ts-expect-error\n fetch.mockImplementation(async (url: string) => ({\n text: async () => {\n if (url === 'http://example.com/specification/openapi.yaml') {\n return 'OK'\n }\n\n throw new Error('Not found')\n },\n }))\n\n expect(await fetchUrls().get('http://example.com/specification/openapi.yaml')).toBe('OK')\n })\n\n it('rewrites the URL', async () => {\n // @ts-expect-error\n fetch.mockImplementation(async (url: string) => ({\n text: async () => {\n if (url === 'http://foobar.com/specification/openapi.yaml') {\n return 'OK'\n }\n throw new Error('Not found')\n },\n }))\n\n expect(\n await fetchUrls({\n fetch: (url) => fetch(url.replace('example', 'foobar')),\n }).get('http://foobar.com/specification/openapi.yaml'),\n ).toBe('OK')\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,UAAU,QAAQ,IAAI,UAAU;AAErD,SAAS,iBAAiB;AAE1B,OAAO,QAAQ,GAAG,GAAG;AAErB,SAAS,aAAa,YAAY;AAChC,aAAW,MAAM;AAEf,WAAO,MAAM,UAAU;AAAA,EACzB,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,WAAO,UAAU,EAAE,MAAM,+CAA+C,CAAC,EAAE,KAAK,IAAI;AAAA,EACtF,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,cAAc,CAAC,EAAE,KAAK,KAAK;AAAA,EACtD,CAAC;AAED,KAAG,4BAA4B,YAAY;AACzC,WAAO,UAAU,EAAE,MAAM,4BAA4B,CAAC,EAAE,KAAK,KAAK;AAAA,EACpE,CAAC;AAED,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK;AAAA,EAC1C,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,EACxC,CAAC;AAED,KAAG,mBAAmB,YAAY;AAEhC,UAAM,mBAAmB,OAAO,SAAiB;AAAA,MAC/C,MAAM,YAAY;AAChB,YAAI,QAAQ,iDAAiD;AAC3D,iBAAO;AAAA,QACT;AAEA,cAAM,IAAI,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF,EAAE;AAEF,WAAO,MAAM,UAAU,EAAE,IAAI,+CAA+C,CAAC,EAAE,KAAK,IAAI;AAAA,EAC1F,CAAC;AAED,KAAG,oBAAoB,YAAY;AAEjC,UAAM,mBAAmB,OAAO,SAAiB;AAAA,MAC/C,MAAM,YAAY;AAChB,YAAI,QAAQ,gDAAgD;AAC1D,iBAAO;AAAA,QACT;AACA,cAAM,IAAI,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF,EAAE;AAEF;AAAA,MACE,MAAM,UAAU;AAAA,QACd,OAAO,CAAC,QAAQ,MAAM,IAAI,QAAQ,WAAW,QAAQ,CAAC;AAAA,MACxD,CAAC,EAAE,IAAI,8CAA8C;AAAA,IACvD,EAAE,KAAK,IAAI;AAAA,EACb,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
- export * from './fetchUrls.ts';
1
+ export * from './fetchUrls.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch-urls/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch-urls/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1 +1,2 @@
1
- export { fetchUrls, fetchUrlsDefaultConfiguration } from './fetchUrls.js';
1
+ export * from "./fetchUrls.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/fetch-urls/index.ts"],
4
+ "sourcesContent": ["export * from './fetchUrls'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
- export * from './readFiles.ts';
1
+ export * from './readFiles.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1 +1,2 @@
1
- export { readFiles } from './readFiles.js';
1
+ export * from "./readFiles.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/read-files/index.ts"],
4
+ "sourcesContent": ["export * from './readFiles'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -1,3 +1,3 @@
1
- import type { LoadPlugin } from '../../utils/load/load.ts';
1
+ import type { LoadPlugin } from '../../utils/load/load.js';
2
2
  export declare const readFiles: () => LoadPlugin;
3
3
  //# sourceMappingURL=readFiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"readFiles.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/readFiles.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAO,MAAM,SAAS,EAAE,MAAM,UAqD7B,CAAA"}
1
+ {"version":3,"file":"readFiles.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/readFiles.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,SAAS,EAAE,MAAM,UAqD7B,CAAA"}
@@ -1,57 +1,52 @@
1
- import fs from 'node:fs';
2
- import { ERRORS } from '../../configuration/index.js';
3
- import { dirname, join } from '../../polyfills/path.js';
4
- import { isJson } from '../../utils/isJson.js';
5
- import { isYaml } from '../../utils/isYaml.js';
6
-
1
+ import fs from "node:fs";
2
+ import { ERRORS } from "../../configuration/index.js";
3
+ import { dirname, join } from "../../polyfills/path.js";
4
+ import { isJson } from "../../utils/isJson.js";
5
+ import { isYaml } from "../../utils/isYaml.js";
7
6
  const readFiles = () => {
8
- return {
9
- check(value) {
10
- // Not a string
11
- if (typeof value !== 'string') {
12
- return false;
13
- }
14
- // URL
15
- if (value.startsWith('http://') || value.startsWith('https://')) {
16
- return false;
17
- }
18
- // Line breaks
19
- if (value.includes('\n')) {
20
- return false;
21
- }
22
- // JSON
23
- if (isJson(value)) {
24
- return false;
25
- }
26
- // YAML (run through YAML.parse)
27
- if (isYaml(value)) {
28
- return false;
29
- }
30
- return true;
31
- },
32
- async get(value) {
33
- if (!fs.existsSync(value)) {
34
- throw new Error(ERRORS.FILE_DOES_NOT_EXIST.replace('%s', value));
35
- }
36
- try {
37
- return fs.readFileSync(value, 'utf-8');
38
- }
39
- catch (error) {
40
- console.error('[readFiles]', error);
41
- return false;
42
- }
43
- },
44
- resolvePath(value, reference) {
45
- const dir = dirname(value);
46
- return join(dir, reference);
47
- },
48
- getDir(value) {
49
- return dirname(value);
50
- },
51
- getFilename(value) {
52
- return value.split('/').pop();
53
- },
54
- };
7
+ return {
8
+ check(value) {
9
+ if (typeof value !== "string") {
10
+ return false;
11
+ }
12
+ if (value.startsWith("http://") || value.startsWith("https://")) {
13
+ return false;
14
+ }
15
+ if (value.includes("\n")) {
16
+ return false;
17
+ }
18
+ if (isJson(value)) {
19
+ return false;
20
+ }
21
+ if (isYaml(value)) {
22
+ return false;
23
+ }
24
+ return true;
25
+ },
26
+ async get(value) {
27
+ if (!fs.existsSync(value)) {
28
+ throw new Error(ERRORS.FILE_DOES_NOT_EXIST.replace("%s", value));
29
+ }
30
+ try {
31
+ return fs.readFileSync(value, "utf-8");
32
+ } catch (error) {
33
+ console.error("[readFiles]", error);
34
+ return false;
35
+ }
36
+ },
37
+ resolvePath(value, reference) {
38
+ const dir = dirname(value);
39
+ return join(dir, reference);
40
+ },
41
+ getDir(value) {
42
+ return dirname(value);
43
+ },
44
+ getFilename(value) {
45
+ return value.split("/").pop();
46
+ }
47
+ };
55
48
  };
56
-
57
- export { readFiles };
49
+ export {
50
+ readFiles
51
+ };
52
+ //# sourceMappingURL=readFiles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/read-files/readFiles.ts"],
4
+ "sourcesContent": ["import fs from 'node:fs'\n\nimport { ERRORS } from '../../configuration/index'\nimport { dirname, join } from '../../polyfills/path'\nimport { isJson } from '../../utils/isJson'\nimport { isYaml } from '../../utils/isYaml'\nimport type { LoadPlugin } from '../../utils/load/load'\n\nexport const readFiles: () => LoadPlugin = () => {\n return {\n check(value?: any) {\n // Not a string\n if (typeof value !== 'string') {\n return false\n }\n\n // URL\n if (value.startsWith('http://') || value.startsWith('https://')) {\n return false\n }\n\n // Line breaks\n if (value.includes('\\n')) {\n return false\n }\n\n // JSON\n if (isJson(value)) {\n return false\n }\n\n // YAML (run through YAML.parse)\n if (isYaml(value)) {\n return false\n }\n\n return true\n },\n async get(value?: any) {\n if (!fs.existsSync(value)) {\n throw new Error(ERRORS.FILE_DOES_NOT_EXIST.replace('%s', value))\n }\n\n try {\n return fs.readFileSync(value, 'utf-8')\n } catch (error) {\n console.error('[readFiles]', error)\n return false\n }\n },\n resolvePath(value: any, reference: string) {\n const dir = dirname(value)\n return join(dir, reference)\n },\n getDir(value: any) {\n return dirname(value)\n },\n getFilename(value: any) {\n return value.split('/').pop()\n },\n }\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AAEf,SAAS,cAAc;AACvB,SAAS,SAAS,YAAY;AAC9B,SAAS,cAAc;AACvB,SAAS,cAAc;AAGhB,MAAM,YAA8B,MAAM;AAC/C,SAAO;AAAA,IACL,MAAM,OAAa;AAEjB,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAGA,UAAI,MAAM,WAAW,SAAS,KAAK,MAAM,WAAW,UAAU,GAAG;AAC/D,eAAO;AAAA,MACT;AAGA,UAAI,MAAM,SAAS,IAAI,GAAG;AACxB,eAAO;AAAA,MACT;AAGA,UAAI,OAAO,KAAK,GAAG;AACjB,eAAO;AAAA,MACT;AAGA,UAAI,OAAO,KAAK,GAAG;AACjB,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,IAAI,OAAa;AACrB,UAAI,CAAC,GAAG,WAAW,KAAK,GAAG;AACzB,cAAM,IAAI,MAAM,OAAO,oBAAoB,QAAQ,MAAM,KAAK,CAAC;AAAA,MACjE;AAEA,UAAI;AACF,eAAO,GAAG,aAAa,OAAO,OAAO;AAAA,MACvC,SAAS,OAAO;AACd,gBAAQ,MAAM,eAAe,KAAK;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,YAAY,OAAY,WAAmB;AACzC,YAAM,MAAM,QAAQ,KAAK;AACzB,aAAO,KAAK,KAAK,SAAS;AAAA,IAC5B;AAAA,IACA,OAAO,OAAY;AACjB,aAAO,QAAQ,KAAK;AAAA,IACtB;AAAA,IACA,YAAY,OAAY;AACtB,aAAO,MAAM,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9B;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,20 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { readFiles } from "./readFiles.js";
3
+ describe("readFiles", async () => {
4
+ it("returns true for a filename", async () => {
5
+ expect(readFiles().check("openapi.yaml")).toBe(true);
6
+ });
7
+ it("returns true for a path", async () => {
8
+ expect(readFiles().check("../specification/openapi.yaml")).toBe(true);
9
+ });
10
+ it("returns false for an object", async () => {
11
+ expect(readFiles().check({})).toBe(false);
12
+ });
13
+ it("returns false for undefinded", async () => {
14
+ expect(readFiles().check()).toBe(false);
15
+ });
16
+ it("returns false for an url", async () => {
17
+ expect(readFiles().check("http://example.com/specification/openapi.yaml")).toBe(false);
18
+ });
19
+ });
20
+ //# sourceMappingURL=readFiles.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/read-files/readFiles.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { readFiles } from './readFiles'\n\ndescribe('readFiles', async () => {\n it('returns true for a filename', async () => {\n expect(readFiles().check('openapi.yaml')).toBe(true)\n })\n\n it('returns true for a path', async () => {\n expect(readFiles().check('../specification/openapi.yaml')).toBe(true)\n })\n\n it('returns false for an object', async () => {\n expect(readFiles().check({})).toBe(false)\n })\n\n it('returns false for undefinded', async () => {\n expect(readFiles().check()).toBe(false)\n })\n\n it('returns false for an url', async () => {\n expect(readFiles().check('http://example.com/specification/openapi.yaml')).toBe(false)\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,iBAAiB;AAE1B,SAAS,aAAa,YAAY;AAChC,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,cAAc,CAAC,EAAE,KAAK,IAAI;AAAA,EACrD,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,WAAO,UAAU,EAAE,MAAM,+BAA+B,CAAC,EAAE,KAAK,IAAI;AAAA,EACtE,CAAC;AAED,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK;AAAA,EAC1C,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,EACxC,CAAC;AAED,KAAG,4BAA4B,YAAY;AACzC,WAAO,UAAU,EAAE,MAAM,+CAA+C,CAAC,EAAE,KAAK,KAAK;AAAA,EACvF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
- export * as path from './path.ts';
1
+ export * as path from './path.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/polyfills/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/polyfills/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA"}
@@ -0,0 +1,5 @@
1
+ import * as path from "./path.js";
2
+ export {
3
+ path
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/polyfills/index.ts"],
4
+ "sourcesContent": ["export * as path from './path'\n"],
5
+ "mappings": "AAAA,YAAY,UAAU;",
6
+ "names": []
7
+ }
@@ -1,117 +1,174 @@
1
- // @ts-nocheck
2
- // Copyright Joyent, Inc. and other Node contributors.
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a
5
- // copy of this software and associated documentation files (the
6
- // "Software"), to deal in the Software without restriction, including
7
- // without limitation the rights to use, copy, modify, merge, publish,
8
- // distribute, sublicense, and/or sell copies of the Software, and to permit
9
- // persons to whom the Software is furnished to do so, subject to the
10
- // following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included
13
- // in all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- // resolves . and .. elements in a path array with directory names there
23
- // must be no slashes, empty elements, or device names (c:\) in the array
24
- // (so also no leading and trailing slashes - it does not distinguish
25
- // relative and absolute paths)
26
1
  function normalizeArray(parts, allowAboveRoot) {
27
- // if the path tries to go above the root, `up` ends up > 0
28
- let up = 0;
29
- for (let i = parts.length - 1; i >= 0; i--) {
30
- const last = parts[i];
31
- if (last === '.') {
32
- parts.splice(i, 1);
33
- }
34
- else if (last === '..') {
35
- parts.splice(i, 1);
36
- up++;
37
- }
38
- else if (up) {
39
- parts.splice(i, 1);
40
- up--;
41
- }
2
+ let up = 0;
3
+ for (let i = parts.length - 1; i >= 0; i--) {
4
+ const last = parts[i];
5
+ if (last === ".") {
6
+ parts.splice(i, 1);
7
+ } else if (last === "..") {
8
+ parts.splice(i, 1);
9
+ up++;
10
+ } else if (up) {
11
+ parts.splice(i, 1);
12
+ up--;
42
13
  }
43
- // if the path is allowed to go above the root, restore leading ..s
44
- if (allowAboveRoot) {
45
- for (; up--; up) {
46
- parts.unshift('..');
47
- }
14
+ }
15
+ if (allowAboveRoot) {
16
+ for (; up--; up) {
17
+ parts.unshift("..");
48
18
  }
49
- return parts;
19
+ }
20
+ return parts;
50
21
  }
51
- // Split a filename into [root, dir, basename, ext], unix version
52
- // 'root' is just a slash, or nothing.
53
22
  const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/;
54
23
  const splitPath = (filename) => splitPathRe.exec(filename).slice(1);
55
- // path.normalize(path)
56
- // posix version
57
- function normalize(path) {
58
- const isPathAbsolute = isAbsolute(path), trailingSlash = substr(path, -1) === '/';
59
- // Normalize the path
60
- path = normalizeArray(filter(path.split('/'), (p) => !!p), !isPathAbsolute).join('/');
61
- if (!path && !isPathAbsolute) {
62
- path = '.';
24
+ function resolve(...parameters) {
25
+ let resolvedPath = "", resolvedAbsolute = false;
26
+ for (let i = parameters.length - 1; i >= -1 && !resolvedAbsolute; i--) {
27
+ const path = i >= 0 ? parameters[i] : "/";
28
+ if (typeof path !== "string") {
29
+ throw new TypeError("Arguments to path.resolve must be strings");
63
30
  }
64
- if (path && trailingSlash) {
65
- path += '/';
31
+ if (!path) {
32
+ continue;
66
33
  }
67
- return (isPathAbsolute ? '/' : '') + path;
34
+ resolvedPath = path + "/" + resolvedPath;
35
+ resolvedAbsolute = path.charAt(0) === "/";
36
+ }
37
+ resolvedPath = normalizeArray(
38
+ filter(resolvedPath.split("/"), (p) => !!p),
39
+ !resolvedAbsolute
40
+ ).join("/");
41
+ return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
42
+ }
43
+ function normalize(path) {
44
+ const isPathAbsolute = isAbsolute(path), trailingSlash = substr(path, -1) === "/";
45
+ path = normalizeArray(
46
+ filter(path.split("/"), (p) => !!p),
47
+ !isPathAbsolute
48
+ ).join("/");
49
+ if (!path && !isPathAbsolute) {
50
+ path = ".";
51
+ }
52
+ if (path && trailingSlash) {
53
+ path += "/";
54
+ }
55
+ return (isPathAbsolute ? "/" : "") + path;
68
56
  }
69
- // posix version
70
57
  function isAbsolute(path) {
71
- return path.charAt(0) === '/';
58
+ return path.charAt(0) === "/";
72
59
  }
73
- // posix version
74
60
  function join(...paths) {
75
- return normalize(filter(paths, (p, _index) => {
76
- if (typeof p !== 'string') {
77
- throw new TypeError('Arguments to path.join must be strings');
78
- }
79
- return p;
80
- }).join('/'));
61
+ return normalize(
62
+ filter(paths, (p, _index) => {
63
+ if (typeof p !== "string") {
64
+ throw new TypeError("Arguments to path.join must be strings");
65
+ }
66
+ return p;
67
+ }).join("/")
68
+ );
81
69
  }
82
- function dirname(path) {
83
- const result = splitPath(path), root = result[0];
84
- let dir = result[1];
85
- if (!root && !dir) {
86
- // No dirname whatsoever
87
- return '.';
70
+ function relative(from, to) {
71
+ from = resolve(from).substr(1);
72
+ to = resolve(to).substr(1);
73
+ function trim(arr) {
74
+ let start = 0;
75
+ for (; start < arr.length; start++) {
76
+ if (arr[start] !== "") {
77
+ break;
78
+ }
79
+ }
80
+ let end = arr.length - 1;
81
+ for (; end >= 0; end--) {
82
+ if (arr[end] !== "") {
83
+ break;
84
+ }
85
+ }
86
+ if (start > end) {
87
+ return [];
88
88
  }
89
- if (dir) {
90
- // It has a dirname, strip trailing slash
91
- dir = dir.substr(0, dir.length - 1);
89
+ return arr.slice(start, end - start + 1);
90
+ }
91
+ const fromParts = trim(from.split("/"));
92
+ const toParts = trim(to.split("/"));
93
+ const length = Math.min(fromParts.length, toParts.length);
94
+ let samePartsLength = length;
95
+ for (let i = 0; i < length; i++) {
96
+ if (fromParts[i] !== toParts[i]) {
97
+ samePartsLength = i;
98
+ break;
92
99
  }
93
- return root + dir;
100
+ }
101
+ let outputParts = [];
102
+ for (let i = samePartsLength; i < fromParts.length; i++) {
103
+ outputParts.push("..");
104
+ }
105
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
106
+ return outputParts.join("/");
94
107
  }
108
+ const sep = "/";
109
+ const delimiter = ":";
110
+ function dirname(path) {
111
+ const result = splitPath(path), root = result[0];
112
+ let dir = result[1];
113
+ if (!root && !dir) {
114
+ return ".";
115
+ }
116
+ if (dir) {
117
+ dir = dir.substr(0, dir.length - 1);
118
+ }
119
+ return root + dir;
120
+ }
121
+ function basename(path, ext) {
122
+ let f = splitPath(path)[2];
123
+ if (ext && f.substr(-1 * ext.length) === ext) {
124
+ f = f.substr(0, f.length - ext.length);
125
+ }
126
+ return f;
127
+ }
128
+ function extname(path) {
129
+ return splitPath(path)[3];
130
+ }
131
+ var path_default = {
132
+ extname,
133
+ basename,
134
+ dirname,
135
+ sep,
136
+ delimiter,
137
+ relative,
138
+ join,
139
+ isAbsolute,
140
+ normalize,
141
+ resolve
142
+ };
95
143
  function filter(xs, f) {
96
- if (xs.filter) {
97
- return xs.filter(f);
98
- }
99
- const res = [];
100
- for (let i = 0; i < xs.length; i++) {
101
- if (f(xs[i], i, xs)) {
102
- res.push(xs[i]);
103
- }
144
+ if (xs.filter) {
145
+ return xs.filter(f);
146
+ }
147
+ const res = [];
148
+ for (let i = 0; i < xs.length; i++) {
149
+ if (f(xs[i], i, xs)) {
150
+ res.push(xs[i]);
104
151
  }
105
- return res;
152
+ }
153
+ return res;
106
154
  }
107
- // String.prototype.substr - negative index don't work in IE8
108
- const substr = 'ab'.substr(-1) === 'b'
109
- ? (str, start, len) => str.substr(start, len)
110
- : (str, start, len) => {
111
- if (start < 0) {
112
- start = str.length + start;
113
- }
114
- return str.substr(start, len);
115
- };
116
-
117
- export { dirname, isAbsolute, join, normalize };
155
+ const substr = "ab".substr(-1) === "b" ? (str, start, len) => str.substr(start, len) : (str, start, len) => {
156
+ if (start < 0) {
157
+ start = str.length + start;
158
+ }
159
+ return str.substr(start, len);
160
+ };
161
+ export {
162
+ basename,
163
+ path_default as default,
164
+ delimiter,
165
+ dirname,
166
+ extname,
167
+ isAbsolute,
168
+ join,
169
+ normalize,
170
+ relative,
171
+ resolve,
172
+ sep
173
+ };
174
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/polyfills/path.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n let up = 0\n for (let i = parts.length - 1; i >= 0; i--) {\n const last = parts[i]\n if (last === '.') {\n parts.splice(i, 1)\n } else if (last === '..') {\n parts.splice(i, 1)\n up++\n } else if (up) {\n parts.splice(i, 1)\n up--\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..')\n }\n }\n\n return parts\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nconst splitPathRe = /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^/]+?|)(\\.[^./]*|))(?:[/]*)$/\nconst splitPath = (filename) => splitPathRe.exec(filename).slice(1)\n\n// path.resolve([from ...], to)\n// posix version\nexport function resolve(...parameters) {\n let resolvedPath = '',\n resolvedAbsolute = false\n\n for (let i = parameters.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n const path = i >= 0 ? parameters[i] : '/'\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings')\n }\n if (!path) {\n continue\n }\n\n resolvedPath = path + '/' + resolvedPath\n resolvedAbsolute = path.charAt(0) === '/'\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(\n filter(resolvedPath.split('/'), (p) => !!p),\n !resolvedAbsolute,\n ).join('/')\n\n return (resolvedAbsolute ? '/' : '') + resolvedPath || '.'\n}\n\n// path.normalize(path)\n// posix version\nexport function normalize(path) {\n const isPathAbsolute = isAbsolute(path),\n trailingSlash = substr(path, -1) === '/'\n\n // Normalize the path\n path = normalizeArray(\n filter(path.split('/'), (p) => !!p),\n !isPathAbsolute,\n ).join('/')\n\n if (!path && !isPathAbsolute) {\n path = '.'\n }\n if (path && trailingSlash) {\n path += '/'\n }\n\n return (isPathAbsolute ? '/' : '') + path\n}\n\n// posix version\nexport function isAbsolute(path) {\n return path.charAt(0) === '/'\n}\n\n// posix version\nexport function join(...paths: string[]) {\n return normalize(\n filter(paths, (p, _index) => {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings')\n }\n return p\n }).join('/'),\n )\n}\n\n// path.relative(from, to)\n// posix version\nexport function relative(from, to) {\n from = resolve(from).substr(1)\n to = resolve(to).substr(1)\n\n function trim(arr) {\n let start = 0\n for (; start < arr.length; start++) {\n if (arr[start] !== '') {\n break\n }\n }\n\n let end = arr.length - 1\n for (; end >= 0; end--) {\n if (arr[end] !== '') {\n break\n }\n }\n\n if (start > end) {\n return []\n }\n return arr.slice(start, end - start + 1)\n }\n\n const fromParts = trim(from.split('/'))\n const toParts = trim(to.split('/'))\n\n const length = Math.min(fromParts.length, toParts.length)\n let samePartsLength = length\n for (let i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i\n break\n }\n }\n\n let outputParts = []\n for (let i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..')\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength))\n\n return outputParts.join('/')\n}\n\nexport const sep = '/'\nexport const delimiter = ':'\n\nexport function dirname(path) {\n const result = splitPath(path),\n root = result[0]\n\n let dir = result[1]\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.'\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1)\n }\n\n return root + dir\n}\n\nexport function basename(path, ext) {\n let f = splitPath(path)[2]\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length)\n }\n return f\n}\n\nexport function extname(path) {\n return splitPath(path)[3]\n}\nexport default {\n extname: extname,\n basename: basename,\n dirname: dirname,\n sep: sep,\n delimiter: delimiter,\n relative: relative,\n join: join,\n isAbsolute: isAbsolute,\n normalize: normalize,\n resolve: resolve,\n}\nfunction filter(xs, f) {\n if (xs.filter) {\n return xs.filter(f)\n }\n const res = []\n for (let i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) {\n res.push(xs[i])\n }\n }\n return res\n}\n\n// String.prototype.substr - negative index don't work in IE8\nconst substr =\n 'ab'.substr(-1) === 'b'\n ? (str, start, len) => str.substr(start, len)\n : (str, start, len) => {\n if (start < 0) {\n start = str.length + start\n }\n return str.substr(start, len)\n }\n"],
5
+ "mappings": "AA2BA,SAAS,eAAe,OAAO,gBAAgB;AAE7C,MAAI,KAAK;AACT,WAAS,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK;AAC1C,UAAM,OAAO,MAAM,CAAC;AACpB,QAAI,SAAS,KAAK;AAChB,YAAM,OAAO,GAAG,CAAC;AAAA,IACnB,WAAW,SAAS,MAAM;AACxB,YAAM,OAAO,GAAG,CAAC;AACjB;AAAA,IACF,WAAW,I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