zudoku 0.0.2-dev.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 (403) hide show
  1. package/cli.js +1 -0
  2. package/dist/app/DevPortal.d.ts +26 -0
  3. package/dist/app/DevPortal.js +41 -0
  4. package/dist/app/DevPortal.js.map +1 -0
  5. package/dist/app/Heading.d.ts +9 -0
  6. package/dist/app/Heading.js +27 -0
  7. package/dist/app/Heading.js.map +1 -0
  8. package/dist/app/app.d.ts +2 -0
  9. package/dist/app/app.js +69 -0
  10. package/dist/app/app.js.map +1 -0
  11. package/dist/app/authentication/authentication.d.ts +13 -0
  12. package/dist/app/authentication/authentication.js +2 -0
  13. package/dist/app/authentication/authentication.js.map +1 -0
  14. package/dist/app/authentication/clerk.d.ts +5 -0
  15. package/dist/app/authentication/clerk.js +36 -0
  16. package/dist/app/authentication/clerk.js.map +1 -0
  17. package/dist/app/authentication/openid.d.ts +11 -0
  18. package/dist/app/authentication/openid.js +118 -0
  19. package/dist/app/authentication/openid.js.map +1 -0
  20. package/dist/app/components/AnchorLink.d.ts +5 -0
  21. package/dist/app/components/AnchorLink.js +17 -0
  22. package/dist/app/components/AnchorLink.js.map +1 -0
  23. package/dist/app/components/CategoryHeading.d.ts +5 -0
  24. package/dist/app/components/CategoryHeading.js +6 -0
  25. package/dist/app/components/CategoryHeading.js.map +1 -0
  26. package/dist/app/components/DynamicIcon.d.ts +6 -0
  27. package/dist/app/components/DynamicIcon.js +6 -0
  28. package/dist/app/components/DynamicIcon.js.map +1 -0
  29. package/dist/app/components/Header.d.ts +2 -0
  30. package/dist/app/components/Header.js +15 -0
  31. package/dist/app/components/Header.js.map +1 -0
  32. package/dist/app/components/Layout.d.ts +4 -0
  33. package/dist/app/components/Layout.js +31 -0
  34. package/dist/app/components/Layout.js.map +1 -0
  35. package/dist/app/components/Markdown.d.ts +5 -0
  36. package/dist/app/components/Markdown.js +20 -0
  37. package/dist/app/components/Markdown.js.map +1 -0
  38. package/dist/app/components/SyntaxHighlight.d.ts +9 -0
  39. package/dist/app/components/SyntaxHighlight.js +31 -0
  40. package/dist/app/components/SyntaxHighlight.js.map +1 -0
  41. package/dist/app/components/TopNavigation.d.ts +1 -0
  42. package/dist/app/components/TopNavigation.js +11 -0
  43. package/dist/app/components/TopNavigation.js.map +1 -0
  44. package/dist/app/components/context/ComponentsContext.d.ts +10 -0
  45. package/dist/app/components/context/ComponentsContext.js +11 -0
  46. package/dist/app/components/context/ComponentsContext.js.map +1 -0
  47. package/dist/app/components/context/DevPortalProvider.d.ts +10 -0
  48. package/dist/app/components/context/DevPortalProvider.js +39 -0
  49. package/dist/app/components/context/DevPortalProvider.js.map +1 -0
  50. package/dist/app/components/context/PluginSystem.d.ts +1 -0
  51. package/dist/app/components/context/PluginSystem.js +2 -0
  52. package/dist/app/components/context/PluginSystem.js.map +1 -0
  53. package/dist/app/components/context/ThemeContext.d.ts +5 -0
  54. package/dist/app/components/context/ThemeContext.js +33 -0
  55. package/dist/app/components/context/ThemeContext.js.map +1 -0
  56. package/dist/app/components/context/ViewportAnchorContext.d.ts +15 -0
  57. package/dist/app/components/context/ViewportAnchorContext.js +89 -0
  58. package/dist/app/components/context/ViewportAnchorContext.js.map +1 -0
  59. package/dist/app/components/navigation/SideNavigation.d.ts +1 -0
  60. package/dist/app/components/navigation/SideNavigation.js +11 -0
  61. package/dist/app/components/navigation/SideNavigation.js.map +1 -0
  62. package/dist/app/components/navigation/SideNavigationCategory.d.ts +4 -0
  63. package/dist/app/components/navigation/SideNavigationCategory.js +26 -0
  64. package/dist/app/components/navigation/SideNavigationCategory.js.map +1 -0
  65. package/dist/app/components/navigation/SideNavigationItem.d.ts +12 -0
  66. package/dist/app/components/navigation/SideNavigationItem.js +38 -0
  67. package/dist/app/components/navigation/SideNavigationItem.js.map +1 -0
  68. package/dist/app/components/navigation/SideNavigationWrapper.d.ts +4 -0
  69. package/dist/app/components/navigation/SideNavigationWrapper.js +6 -0
  70. package/dist/app/components/navigation/SideNavigationWrapper.js.map +1 -0
  71. package/dist/app/components/navigation/useNavigationCollapsibleState.d.ts +7 -0
  72. package/dist/app/components/navigation/useNavigationCollapsibleState.js +16 -0
  73. package/dist/app/components/navigation/useNavigationCollapsibleState.js.map +1 -0
  74. package/dist/app/components/navigation/util.d.ts +8 -0
  75. package/dist/app/components/navigation/util.js +15 -0
  76. package/dist/app/components/navigation/util.js.map +1 -0
  77. package/dist/app/config.d.ts +3 -0
  78. package/dist/app/config.js +9 -0
  79. package/dist/app/config.js.map +1 -0
  80. package/dist/app/core/DevPortalContext.d.ts +80 -0
  81. package/dist/app/core/DevPortalContext.js +68 -0
  82. package/dist/app/core/DevPortalContext.js.map +1 -0
  83. package/dist/app/core/helmet.d.ts +4 -0
  84. package/dist/app/core/helmet.js +5 -0
  85. package/dist/app/core/helmet.js.map +1 -0
  86. package/dist/app/core/icons.d.ts +1 -0
  87. package/dist/app/core/icons.js +2 -0
  88. package/dist/app/core/icons.js.map +1 -0
  89. package/dist/app/core/plugins.d.ts +24 -0
  90. package/dist/app/core/plugins.js +4 -0
  91. package/dist/app/core/plugins.js.map +1 -0
  92. package/dist/app/core/router.d.ts +1 -0
  93. package/dist/app/core/router.js +2 -0
  94. package/dist/app/core/router.js.map +1 -0
  95. package/dist/app/core/types/combine.d.ts +4 -0
  96. package/dist/app/core/types/combine.js +2 -0
  97. package/dist/app/core/types/combine.js.map +1 -0
  98. package/dist/app/main.d.ts +1 -0
  99. package/dist/app/main.js +18 -0
  100. package/dist/app/main.js.map +1 -0
  101. package/dist/app/markdowns.d.ts +3 -0
  102. package/dist/app/markdowns.js +5 -0
  103. package/dist/app/markdowns.js.map +1 -0
  104. package/dist/app/oas/graphql/index.d.ts +12 -0
  105. package/dist/app/oas/graphql/index.js +290 -0
  106. package/dist/app/oas/graphql/index.js.map +1 -0
  107. package/dist/app/oas/graphql/server.d.ts +1 -0
  108. package/dist/app/oas/graphql/server.js +8 -0
  109. package/dist/app/oas/graphql/server.js.map +1 -0
  110. package/dist/app/oas/parser/dereference/index.d.ts +5 -0
  111. package/dist/app/oas/parser/dereference/index.js +43 -0
  112. package/dist/app/oas/parser/dereference/index.js.map +1 -0
  113. package/dist/app/oas/parser/dereference/resolveRef.d.ts +5 -0
  114. package/dist/app/oas/parser/dereference/resolveRef.js +26 -0
  115. package/dist/app/oas/parser/dereference/resolveRef.js.map +1 -0
  116. package/dist/app/oas/parser/index.d.ts +21 -0
  117. package/dist/app/oas/parser/index.js +58 -0
  118. package/dist/app/oas/parser/index.js.map +1 -0
  119. package/dist/app/oas/parser/schemas/v3.0.json +1489 -0
  120. package/dist/app/oas/parser/schemas/v3.1.json +1298 -0
  121. package/dist/app/oas/parser/upgrade/index.d.ts +9 -0
  122. package/dist/app/oas/parser/upgrade/index.js +90 -0
  123. package/dist/app/oas/parser/upgrade/index.js.map +1 -0
  124. package/dist/app/plugins/api-key/SettingsApiKeys.d.ts +4 -0
  125. package/dist/app/plugins/api-key/SettingsApiKeys.js +7 -0
  126. package/dist/app/plugins/api-key/SettingsApiKeys.js.map +1 -0
  127. package/dist/app/plugins/api-key/index.d.ts +32 -0
  128. package/dist/app/plugins/api-key/index.js +55 -0
  129. package/dist/app/plugins/api-key/index.js.map +1 -0
  130. package/dist/app/plugins/markdown/MdxPage.d.ts +3 -0
  131. package/dist/app/plugins/markdown/MdxPage.js +55 -0
  132. package/dist/app/plugins/markdown/MdxPage.js.map +1 -0
  133. package/dist/app/plugins/markdown/Toc.d.ts +4 -0
  134. package/dist/app/plugins/markdown/Toc.js +40 -0
  135. package/dist/app/plugins/markdown/Toc.js.map +1 -0
  136. package/dist/app/plugins/markdown/generateRoutes.d.ts +3 -0
  137. package/dist/app/plugins/markdown/generateRoutes.js +50 -0
  138. package/dist/app/plugins/markdown/generateRoutes.js.map +1 -0
  139. package/dist/app/plugins/markdown/index.d.ts +19 -0
  140. package/dist/app/plugins/markdown/index.js +9 -0
  141. package/dist/app/plugins/markdown/index.js.map +1 -0
  142. package/dist/app/plugins/openapi/ColorizedParam.d.ts +8 -0
  143. package/dist/app/plugins/openapi/ColorizedParam.js +40 -0
  144. package/dist/app/plugins/openapi/ColorizedParam.js.map +1 -0
  145. package/dist/app/plugins/openapi/MakeRequest.d.ts +4 -0
  146. package/dist/app/plugins/openapi/MakeRequest.js +11 -0
  147. package/dist/app/plugins/openapi/MakeRequest.js.map +1 -0
  148. package/dist/app/plugins/openapi/MethodBadge.d.ts +13 -0
  149. package/dist/app/plugins/openapi/MethodBadge.js +26 -0
  150. package/dist/app/plugins/openapi/MethodBadge.js.map +1 -0
  151. package/dist/app/plugins/openapi/OperationList.d.ts +47 -0
  152. package/dist/app/plugins/openapi/OperationList.js +82 -0
  153. package/dist/app/plugins/openapi/OperationList.js.map +1 -0
  154. package/dist/app/plugins/openapi/OperationListItem.d.ts +7 -0
  155. package/dist/app/plugins/openapi/OperationListItem.js +15 -0
  156. package/dist/app/plugins/openapi/OperationListItem.js.map +1 -0
  157. package/dist/app/plugins/openapi/ParameterList.d.ts +7 -0
  158. package/dist/app/plugins/openapi/ParameterList.js +5 -0
  159. package/dist/app/plugins/openapi/ParameterList.js.map +1 -0
  160. package/dist/app/plugins/openapi/ParameterListItem.d.ts +8 -0
  161. package/dist/app/plugins/openapi/ParameterListItem.js +13 -0
  162. package/dist/app/plugins/openapi/ParameterListItem.js.map +1 -0
  163. package/dist/app/plugins/openapi/RequestBodySidecarBox.d.ts +6 -0
  164. package/dist/app/plugins/openapi/RequestBodySidecarBox.js +19 -0
  165. package/dist/app/plugins/openapi/RequestBodySidecarBox.js.map +1 -0
  166. package/dist/app/plugins/openapi/ResponsesSidecarBox.d.ts +6 -0
  167. package/dist/app/plugins/openapi/ResponsesSidecarBox.js +15 -0
  168. package/dist/app/plugins/openapi/ResponsesSidecarBox.js.map +1 -0
  169. package/dist/app/plugins/openapi/Select.d.ts +9 -0
  170. package/dist/app/plugins/openapi/Select.js +5 -0
  171. package/dist/app/plugins/openapi/Select.js.map +1 -0
  172. package/dist/app/plugins/openapi/Sidecar.d.ts +4 -0
  173. package/dist/app/plugins/openapi/Sidecar.js +39 -0
  174. package/dist/app/plugins/openapi/Sidecar.js.map +1 -0
  175. package/dist/app/plugins/openapi/SidecarBox.d.ts +10 -0
  176. package/dist/app/plugins/openapi/SidecarBox.js +8 -0
  177. package/dist/app/plugins/openapi/SidecarBox.js.map +1 -0
  178. package/dist/app/plugins/openapi/graphql/index.d.ts +836 -0
  179. package/dist/app/plugins/openapi/graphql/index.js +4 -0
  180. package/dist/app/plugins/openapi/graphql/index.js.map +1 -0
  181. package/dist/app/plugins/openapi/index.d.ts +22 -0
  182. package/dist/app/plugins/openapi/index.js +91 -0
  183. package/dist/app/plugins/openapi/index.js.map +1 -0
  184. package/dist/app/plugins/openapi/util/generateSchemaExample.d.ts +3 -0
  185. package/dist/app/plugins/openapi/util/generateSchemaExample.js +52 -0
  186. package/dist/app/plugins/openapi/util/generateSchemaExample.js.map +1 -0
  187. package/dist/app/plugins/openapi/util/getCode.d.ts +2 -0
  188. package/dist/app/plugins/openapi/util/getCode.js +54 -0
  189. package/dist/app/plugins/openapi/util/getCode.js.map +1 -0
  190. package/dist/app/plugins/openapi/util/urql.d.ts +8 -0
  191. package/dist/app/plugins/openapi/util/urql.js +8 -0
  192. package/dist/app/plugins/openapi/util/urql.js.map +1 -0
  193. package/dist/app/plugins/openapi/worker/createSharedWorkerClient.d.ts +5 -0
  194. package/dist/app/plugins/openapi/worker/createSharedWorkerClient.js +47 -0
  195. package/dist/app/plugins/openapi/worker/createSharedWorkerClient.js.map +1 -0
  196. package/dist/app/plugins/openapi/worker/worker.d.ts +1 -0
  197. package/dist/app/plugins/openapi/worker/worker.js +20 -0
  198. package/dist/app/plugins/openapi/worker/worker.js.map +1 -0
  199. package/dist/app/plugins/redirect/index.d.ts +10 -0
  200. package/dist/app/plugins/redirect/index.js +11 -0
  201. package/dist/app/plugins/redirect/index.js.map +1 -0
  202. package/dist/app/tailwind.d.ts +3 -0
  203. package/dist/app/tailwind.js +69 -0
  204. package/dist/app/tailwind.js.map +1 -0
  205. package/dist/app/ui/Callout.d.ts +51 -0
  206. package/dist/app/ui/Callout.js +50 -0
  207. package/dist/app/ui/Callout.js.map +1 -0
  208. package/dist/app/ui/Card.d.ts +8 -0
  209. package/dist/app/ui/Card.js +17 -0
  210. package/dist/app/ui/Card.js.map +1 -0
  211. package/dist/app/ui/Note.d.ts +8 -0
  212. package/dist/app/ui/Note.js +23 -0
  213. package/dist/app/ui/Note.js.map +1 -0
  214. package/dist/app/util/MdxComponents.d.ts +27 -0
  215. package/dist/app/util/MdxComponents.js +40 -0
  216. package/dist/app/util/MdxComponents.js.map +1 -0
  217. package/dist/app/util/cn.d.ts +2 -0
  218. package/dist/app/util/cn.js +6 -0
  219. package/dist/app/util/cn.js.map +1 -0
  220. package/dist/app/util/createWaitForNotify.d.ts +1 -0
  221. package/dist/app/util/createWaitForNotify.js +15 -0
  222. package/dist/app/util/createWaitForNotify.js.map +1 -0
  223. package/dist/app/util/groupBy.d.ts +6 -0
  224. package/dist/app/util/groupBy.js +9 -0
  225. package/dist/app/util/groupBy.js.map +1 -0
  226. package/dist/app/util/joinPath.d.ts +1 -0
  227. package/dist/app/util/joinPath.js +8 -0
  228. package/dist/app/util/joinPath.js.map +1 -0
  229. package/dist/app/util/pastellize.d.ts +4 -0
  230. package/dist/app/util/pastellize.js +14 -0
  231. package/dist/app/util/pastellize.js.map +1 -0
  232. package/dist/app/util/slugify.d.ts +3 -0
  233. package/dist/app/util/slugify.js +3 -0
  234. package/dist/app/util/slugify.js.map +1 -0
  235. package/dist/app/util/traverseNavigation.d.ts +6 -0
  236. package/dist/app/util/traverseNavigation.js +30 -0
  237. package/dist/app/util/traverseNavigation.js.map +1 -0
  238. package/dist/app/util/useScrollToAnchor.d.ts +1 -0
  239. package/dist/app/util/useScrollToAnchor.js +33 -0
  240. package/dist/app/util/useScrollToAnchor.js.map +1 -0
  241. package/dist/app/util/useScrollToTop.d.ts +1 -0
  242. package/dist/app/util/useScrollToTop.js +13 -0
  243. package/dist/app/util/useScrollToTop.js.map +1 -0
  244. package/dist/auth.d.ts +2 -0
  245. package/dist/auth.js +3 -0
  246. package/dist/auth.js.map +1 -0
  247. package/dist/cli/build/handler.d.ts +4 -0
  248. package/dist/cli/build/handler.js +9 -0
  249. package/dist/cli/build/handler.js.map +1 -0
  250. package/dist/cli/cli.d.ts +1 -0
  251. package/dist/cli/cli.js +64 -0
  252. package/dist/cli/cli.js.map +1 -0
  253. package/dist/cli/cmds/build.d.ts +8 -0
  254. package/dist/cli/cmds/build.js +23 -0
  255. package/dist/cli/cmds/build.js.map +1 -0
  256. package/dist/cli/cmds/dev.d.ts +8 -0
  257. package/dist/cli/cmds/dev.js +29 -0
  258. package/dist/cli/cmds/dev.js.map +1 -0
  259. package/dist/cli/common/analytics/lib.d.ts +17 -0
  260. package/dist/cli/common/analytics/lib.js +53 -0
  261. package/dist/cli/common/analytics/lib.js.map +1 -0
  262. package/dist/cli/common/constants.d.ts +5 -0
  263. package/dist/cli/common/constants.js +9 -0
  264. package/dist/cli/common/constants.js.map +1 -0
  265. package/dist/cli/common/logger.d.ts +2 -0
  266. package/dist/cli/common/logger.js +14 -0
  267. package/dist/cli/common/logger.js.map +1 -0
  268. package/dist/cli/common/machine-id/lib.d.ts +1 -0
  269. package/dist/cli/common/machine-id/lib.js +74 -0
  270. package/dist/cli/common/machine-id/lib.js.map +1 -0
  271. package/dist/cli/common/outdated.d.ts +1 -0
  272. package/dist/cli/common/outdated.js +70 -0
  273. package/dist/cli/common/outdated.js.map +1 -0
  274. package/dist/cli/common/output.d.ts +9 -0
  275. package/dist/cli/common/output.js +65 -0
  276. package/dist/cli/common/output.js.map +1 -0
  277. package/dist/cli/common/utils/box.d.ts +33 -0
  278. package/dist/cli/common/utils/box.js +81 -0
  279. package/dist/cli/common/utils/box.js.map +1 -0
  280. package/dist/cli/common/utils/ports.d.ts +1 -0
  281. package/dist/cli/common/utils/ports.js +18 -0
  282. package/dist/cli/common/utils/ports.js.map +1 -0
  283. package/dist/cli/common/validators/lib.d.ts +20 -0
  284. package/dist/cli/common/validators/lib.js +31 -0
  285. package/dist/cli/common/validators/lib.js.map +1 -0
  286. package/dist/cli/common/xdg/lib.d.ts +6 -0
  287. package/dist/cli/common/xdg/lib.js +18 -0
  288. package/dist/cli/common/xdg/lib.js.map +1 -0
  289. package/dist/cli/dev/handler.d.ts +5 -0
  290. package/dist/cli/dev/handler.js +22 -0
  291. package/dist/cli/dev/handler.js.map +1 -0
  292. package/dist/config/config.d.ts +37 -0
  293. package/dist/config/config.js +2 -0
  294. package/dist/config/config.js.map +1 -0
  295. package/dist/index.d.ts +7 -0
  296. package/dist/index.js +6 -0
  297. package/dist/index.js.map +1 -0
  298. package/dist/plugins.d.ts +4 -0
  299. package/dist/plugins.js +6 -0
  300. package/dist/plugins.js.map +1 -0
  301. package/dist/vite/build.d.ts +3 -0
  302. package/dist/vite/build.js +29 -0
  303. package/dist/vite/build.js.map +1 -0
  304. package/dist/vite/config.d.ts +6 -0
  305. package/dist/vite/config.js +74 -0
  306. package/dist/vite/config.js.map +1 -0
  307. package/dist/vite/dev-server.d.ts +10 -0
  308. package/dist/vite/dev-server.js +53 -0
  309. package/dist/vite/dev-server.js.map +1 -0
  310. package/dist/vite/html.d.ts +5 -0
  311. package/dist/vite/html.js +32 -0
  312. package/dist/vite/html.js.map +1 -0
  313. package/dist/vite/import-auth-plugin.d.ts +3 -0
  314. package/dist/vite/import-auth-plugin.js +28 -0
  315. package/dist/vite/import-auth-plugin.js.map +1 -0
  316. package/dist/vite/plugin.d.ts +7 -0
  317. package/dist/vite/plugin.js +109 -0
  318. package/dist/vite/plugin.js.map +1 -0
  319. package/package.json +118 -0
  320. package/src/app/DevPortal.tsx +115 -0
  321. package/src/app/Heading.tsx +60 -0
  322. package/src/app/app.tsx +85 -0
  323. package/src/app/authentication/authentication.ts +18 -0
  324. package/src/app/authentication/clerk.ts +47 -0
  325. package/src/app/authentication/openid.ts +192 -0
  326. package/src/app/components/AnchorLink.tsx +19 -0
  327. package/src/app/components/CategoryHeading.tsx +16 -0
  328. package/src/app/components/DynamicIcon.tsx +60 -0
  329. package/src/app/components/Header.tsx +69 -0
  330. package/src/app/components/Layout.tsx +56 -0
  331. package/src/app/components/Markdown.tsx +37 -0
  332. package/src/app/components/SyntaxHighlight.tsx +92 -0
  333. package/src/app/components/TopNavigation.tsx +32 -0
  334. package/src/app/components/context/ComponentsContext.tsx +24 -0
  335. package/src/app/components/context/DevPortalProvider.ts +54 -0
  336. package/src/app/components/context/PluginSystem.ts +0 -0
  337. package/src/app/components/context/ThemeContext.tsx +46 -0
  338. package/src/app/components/context/ViewportAnchorContext.tsx +139 -0
  339. package/src/app/components/navigation/SideNavigation.tsx +18 -0
  340. package/src/app/components/navigation/SideNavigationCategory.tsx +74 -0
  341. package/src/app/components/navigation/SideNavigationItem.tsx +143 -0
  342. package/src/app/components/navigation/SideNavigationWrapper.tsx +15 -0
  343. package/src/app/components/navigation/useNavigationCollapsibleState.ts +27 -0
  344. package/src/app/components/navigation/util.ts +38 -0
  345. package/src/app/config.ts +20 -0
  346. package/src/app/core/DevPortalContext.ts +164 -0
  347. package/src/app/core/helmet.ts +5 -0
  348. package/src/app/core/icons.tsx +1 -0
  349. package/src/app/core/plugins.ts +43 -0
  350. package/src/app/core/router.tsx +1 -0
  351. package/src/app/core/types/combine.ts +16 -0
  352. package/src/app/main.css +137 -0
  353. package/src/app/main.tsx +22 -0
  354. package/src/app/markdowns.ts +7 -0
  355. package/src/app/oas/graphql/index.ts +422 -0
  356. package/src/app/oas/graphql/server.ts +10 -0
  357. package/src/app/oas/parser/dereference/index.ts +59 -0
  358. package/src/app/oas/parser/dereference/resolveRef.ts +32 -0
  359. package/src/app/oas/parser/index.ts +94 -0
  360. package/src/app/oas/parser/schemas/v3.0.json +1489 -0
  361. package/src/app/oas/parser/schemas/v3.1.json +1298 -0
  362. package/src/app/oas/parser/upgrade/index.ts +108 -0
  363. package/src/app/plugins/api-key/SettingsApiKeys.tsx +22 -0
  364. package/src/app/plugins/api-key/index.tsx +123 -0
  365. package/src/app/plugins/markdown/MdxPage.tsx +128 -0
  366. package/src/app/plugins/markdown/Toc.tsx +122 -0
  367. package/src/app/plugins/markdown/generateRoutes.tsx +72 -0
  368. package/src/app/plugins/markdown/index.tsx +31 -0
  369. package/src/app/plugins/openapi/ColorizedParam.tsx +73 -0
  370. package/src/app/plugins/openapi/MakeRequest.tsx +30 -0
  371. package/src/app/plugins/openapi/MethodBadge.tsx +36 -0
  372. package/src/app/plugins/openapi/OperationList.tsx +119 -0
  373. package/src/app/plugins/openapi/OperationListItem.tsx +55 -0
  374. package/src/app/plugins/openapi/ParameterList.tsx +32 -0
  375. package/src/app/plugins/openapi/ParameterListItem.tsx +60 -0
  376. package/src/app/plugins/openapi/RequestBodySidecarBox.tsx +48 -0
  377. package/src/app/plugins/openapi/ResponsesSidecarBox.tsx +60 -0
  378. package/src/app/plugins/openapi/Select.tsx +35 -0
  379. package/src/app/plugins/openapi/Sidecar.tsx +99 -0
  380. package/src/app/plugins/openapi/SidecarBox.tsx +35 -0
  381. package/src/app/plugins/openapi/graphql/env.d.ts +48 -0
  382. package/src/app/plugins/openapi/graphql/index.ts +13 -0
  383. package/src/app/plugins/openapi/index.tsx +142 -0
  384. package/src/app/plugins/openapi/util/generateSchemaExample.ts +59 -0
  385. package/src/app/plugins/openapi/util/getCode.tsx +69 -0
  386. package/src/app/plugins/openapi/util/urql.ts +8 -0
  387. package/src/app/plugins/openapi/worker/createSharedWorkerClient.ts +60 -0
  388. package/src/app/plugins/openapi/worker/worker.ts +30 -0
  389. package/src/app/plugins/redirect/index.tsx +20 -0
  390. package/src/app/tailwind.ts +72 -0
  391. package/src/app/ui/Callout.tsx +87 -0
  392. package/src/app/ui/Card.tsx +82 -0
  393. package/src/app/ui/Note.tsx +58 -0
  394. package/src/app/util/MdxComponents.tsx +70 -0
  395. package/src/app/util/cn.ts +6 -0
  396. package/src/app/util/createWaitForNotify.ts +18 -0
  397. package/src/app/util/groupBy.ts +24 -0
  398. package/src/app/util/joinPath.tsx +10 -0
  399. package/src/app/util/pastellize.ts +25 -0
  400. package/src/app/util/slugify.ts +3 -0
  401. package/src/app/util/traverseNavigation.ts +55 -0
  402. package/src/app/util/useScrollToAnchor.ts +38 -0
  403. package/src/app/util/useScrollToTop.ts +13 -0
@@ -0,0 +1,422 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import SchemaBuilder from "@pothos/core";
3
+ import { GraphQLJSON, GraphQLJSONObject } from "graphql-type-json";
4
+ import { createYoga, type YogaServerOptions } from "graphql-yoga";
5
+ import { LRUCache } from "lru-cache";
6
+ import hashit from "object-hash";
7
+ import slugify from "../../util/slugify.js";
8
+ import {
9
+ HttpMethods,
10
+ validate,
11
+ type EncodingObject,
12
+ type ExampleObject,
13
+ type OpenAPIDocument,
14
+ type OperationObject,
15
+ type ParameterObject,
16
+ type PathsObject,
17
+ type SchemaObject,
18
+ type TagObject,
19
+ } from "../parser/index.js";
20
+
21
+ export type {
22
+ EncodingObject,
23
+ ExampleObject,
24
+ OpenAPIDocument,
25
+ OperationObject,
26
+ ParameterObject,
27
+ PathsObject,
28
+ SchemaObject,
29
+ TagObject,
30
+ };
31
+
32
+ type OperationLike = {
33
+ summary?: string | null;
34
+ operationId?: string | null;
35
+ path: string;
36
+ method: string;
37
+ };
38
+ export const slugifyOperation = (operation: OperationLike, tag?: string) => {
39
+ return slugify(
40
+ (tag ? tag + "-" : "") +
41
+ (operation.summary ??
42
+ operation.operationId ??
43
+ `${operation.method}-${operation.path}`),
44
+ { lower: true, trim: true },
45
+ );
46
+ };
47
+
48
+ const cache = new LRUCache<string, OpenAPIDocument>({
49
+ ttl: 60 * 10 * 1000,
50
+ ttlAutopurge: true,
51
+ });
52
+
53
+ const builder = new SchemaBuilder<{
54
+ Scalars: {
55
+ JSON: any;
56
+ JSONObject: any;
57
+ };
58
+ Context: {
59
+ schema: OpenAPIDocument;
60
+ };
61
+ }>({});
62
+
63
+ const JSONScalar = builder.addScalarType("JSON", GraphQLJSON);
64
+ const JSONObjectScalar = builder.addScalarType("JSONObject", GraphQLJSONObject);
65
+
66
+ const getAllOperations = (paths?: PathsObject, tag?: string) => {
67
+ return Object.entries(paths ?? {}).flatMap(([path, value]) =>
68
+ HttpMethods.flatMap((method) => {
69
+ if (!value?.[method]) return [];
70
+
71
+ const operation = value[method] as OperationObject;
72
+ const pathParameters = value?.parameters ?? [];
73
+ const operationParameters = operation.parameters ?? [];
74
+
75
+ // parameters are inherited from the parent path object,
76
+ // but can be overridden by their `name` and `in` location
77
+ const parameters = [
78
+ ...pathParameters.filter(
79
+ // remove path parameters that are already defined in the operation
80
+ (pp) =>
81
+ !operationParameters.some(
82
+ (op) => op.name === pp.name && op.in === pp.in,
83
+ ),
84
+ ),
85
+ ...operationParameters,
86
+ ];
87
+
88
+ return {
89
+ ...operation,
90
+ method,
91
+ path,
92
+ parameters,
93
+ slug: slugifyOperation(
94
+ {
95
+ summary: operation.summary,
96
+ operationId: operation.operationId,
97
+ path,
98
+ method,
99
+ },
100
+ tag,
101
+ ),
102
+ };
103
+ }),
104
+ );
105
+ };
106
+
107
+ const SchemaTag = builder.objectRef<TagObject>("SchemaTag").implement({
108
+ fields: (t) => ({
109
+ name: t.exposeString("name", { nullable: true }),
110
+ description: t.exposeString("description", { nullable: true }),
111
+ operations: t.field({
112
+ type: [OperationItem],
113
+ resolve: (parent, _args, ctx) =>
114
+ getAllOperations(ctx.schema.paths, parent.name).filter((item) =>
115
+ parent.name
116
+ ? item.tags?.includes(parent.name)
117
+ : !item.tags || item.tags.length === 0,
118
+ ),
119
+ }),
120
+ }),
121
+ });
122
+
123
+ const PathItem = builder
124
+ .objectRef<{
125
+ path: string;
126
+ methods: typeof HttpMethods;
127
+ }>("PathItem")
128
+ .implement({
129
+ fields: (t) => ({
130
+ path: t.exposeString("path"),
131
+ methods: t.exposeStringList("methods"),
132
+ }),
133
+ });
134
+
135
+ const TagItem = builder.objectRef<TagObject>("TagItem").implement({
136
+ fields: (t) => ({
137
+ name: t.exposeString("name"),
138
+ description: t.exposeString("description", { nullable: true }),
139
+ }),
140
+ });
141
+
142
+ const EncodingItem = builder
143
+ .objectRef<EncodingObject & { name: string }>("EncodingItem")
144
+ .implement({
145
+ fields: (t) => ({
146
+ name: t.exposeString("name"),
147
+ contentType: t.exposeString("contentType", { nullable: true }),
148
+ headers: t.expose("headers", { type: JSONObjectScalar, nullable: true }),
149
+ style: t.exposeString("style", { nullable: true }),
150
+ explode: t.exposeBoolean("explode", { nullable: true }),
151
+ allowReserved: t.exposeBoolean("allowReserved", { nullable: true }),
152
+ }),
153
+ });
154
+
155
+ const ExampleItem = builder
156
+ .objectRef<ExampleObject & { name: string }>("ExampleItem")
157
+ .implement({
158
+ fields: (t) => ({
159
+ name: t.exposeString("name"),
160
+ summary: t.exposeString("summary", { nullable: true }),
161
+ description: t.exposeString("description", { nullable: true }),
162
+ value: t.exposeString("value", { nullable: true }),
163
+ externalValue: t.exposeString("externalValue", { nullable: true }),
164
+ }),
165
+ });
166
+
167
+ const ParameterIn = builder.enumType("ParameterIn", {
168
+ values: ["query", "header", "path", "cookie"] as const,
169
+ });
170
+
171
+ const ParameterItem = builder
172
+ .objectRef<ParameterObject>("ParameterItem")
173
+ .implement({
174
+ fields: (t) => ({
175
+ name: t.exposeString("name"),
176
+ in: t.field({
177
+ type: ParameterIn,
178
+ resolve: (parent) => parent.in as typeof ParameterIn.$inferType,
179
+ }),
180
+ description: t.exposeString("description", { nullable: true }),
181
+ required: t.exposeBoolean("required", { nullable: true }),
182
+ deprecated: t.exposeBoolean("deprecated", { nullable: true }),
183
+ allowEmptyValue: t.exposeBoolean("allowEmptyValue", { nullable: true }),
184
+ style: t.exposeString("style", { nullable: true }),
185
+ explode: t.exposeBoolean("explode", { nullable: true }),
186
+ allowReserved: t.exposeBoolean("allowReserved", { nullable: true }),
187
+ examples: t.field({
188
+ type: [ExampleItem],
189
+ resolve: (parent) =>
190
+ Object.entries(parent.examples ?? {}).map(([name, value]) => ({
191
+ name,
192
+ ...value,
193
+ })),
194
+ nullable: true,
195
+ }),
196
+ schema: t.expose("schema", { type: JSONScalar, nullable: true }),
197
+ }),
198
+ });
199
+
200
+ const MediaTypeItem = builder
201
+ .objectRef<{
202
+ mediaType: string;
203
+ schema: any;
204
+ examples: Array<ExampleObject & { name: string }>;
205
+ encoding?: Array<EncodingObject & { name: string }>;
206
+ }>("MediaTypeObject")
207
+ .implement({
208
+ fields: (t) => ({
209
+ mediaType: t.exposeString("mediaType"),
210
+ schema: t.expose("schema", { type: JSONScalar }),
211
+ examples: t.expose("examples", { type: [ExampleItem], nullable: true }),
212
+ encoding: t.expose("encoding", { type: [EncodingItem], nullable: true }),
213
+ }),
214
+ });
215
+
216
+ const RequestBodyObject = builder
217
+ .objectRef<{
218
+ description?: string;
219
+ required?: boolean;
220
+ content: Array<{
221
+ mediaType: string;
222
+ schema: any;
223
+ examples: Array<ExampleObject & { name: string }>;
224
+ encoding?: Array<EncodingObject & { name: string }>;
225
+ }>;
226
+ }>("RequestBodyObject")
227
+ .implement({
228
+ fields: (t) => ({
229
+ description: t.exposeString("description", { nullable: true }),
230
+ content: t.expose("content", { type: [MediaTypeItem], nullable: true }),
231
+ required: t.exposeBoolean("required", { nullable: true }),
232
+ }),
233
+ });
234
+
235
+ const ResponseItem = builder
236
+ .objectRef<{
237
+ statusCode: string;
238
+ description: string;
239
+ content: Array<{
240
+ mediaType: string;
241
+ schema: any;
242
+ examples: Array<ExampleObject & { name: string }>;
243
+ }>;
244
+ headers?: any;
245
+ links?: any;
246
+ }>("ResponseItem")
247
+ .implement({
248
+ fields: (t) => ({
249
+ statusCode: t.exposeString("statusCode"),
250
+ description: t.exposeString("description"),
251
+ content: t.expose("content", { type: [MediaTypeItem], nullable: true }),
252
+ headers: t.expose("headers", { type: JSONScalar, nullable: true }),
253
+ links: t.expose("links", { type: JSONScalar, nullable: true }),
254
+ }),
255
+ });
256
+
257
+ const OperationItem = builder
258
+ .objectRef<
259
+ OperationObject & { path: string; method: string; slug: string }
260
+ >("OperationItem")
261
+ .implement({
262
+ fields: (t) => ({
263
+ slug: t.exposeString("slug"),
264
+ path: t.exposeString("path"),
265
+ method: t.exposeString("method"),
266
+ operationId: t.exposeString("operationId", { nullable: true }),
267
+ summary: t.exposeString("summary", { nullable: true }),
268
+ description: t.exposeString("description", { nullable: true }),
269
+ contentTypes: t.stringList({
270
+ resolve: (parent) => Object.keys(parent.requestBody?.content ?? {}),
271
+ }),
272
+ parameters: t.expose("parameters", {
273
+ type: [ParameterItem],
274
+ nullable: true,
275
+ }),
276
+ requestBody: t.field({
277
+ type: RequestBodyObject,
278
+ resolve: (parent) => ({
279
+ description: parent.requestBody?.description,
280
+ required: parent.requestBody?.required,
281
+ content: Object.entries(parent.requestBody?.content ?? {}).map(
282
+ ([mediaType, content]) => ({
283
+ mediaType,
284
+ schema: content.schema,
285
+ examples: Object.entries(content.examples ?? {}).map(
286
+ ([name, value]) => ({ name, ...value }),
287
+ ),
288
+ encoding: Object.entries(content.encoding ?? {}).map(
289
+ ([name, value]) => ({ name, ...value }),
290
+ ),
291
+ }),
292
+ ),
293
+ }),
294
+ nullable: true,
295
+ }),
296
+ responses: t.field({
297
+ type: [ResponseItem],
298
+ resolve: (parent) => {
299
+ return Object.entries(parent.responses ?? {}).map(
300
+ ([statusCode, response]) => ({
301
+ statusCode,
302
+ description: response.description,
303
+ content: Object.entries(response.content ?? {}).map(
304
+ ([mediaType, mediaTypeObject]) => ({
305
+ mediaType,
306
+ schema: mediaTypeObject.schema,
307
+ examples: Object.entries(mediaTypeObject.examples ?? {}).map(
308
+ ([name, value]) => ({ name, ...value }),
309
+ ),
310
+ }),
311
+ ),
312
+ headers: response.headers,
313
+ links: response.links,
314
+ }),
315
+ );
316
+ },
317
+ }),
318
+ tags: t.field({
319
+ type: [TagItem],
320
+ resolve: (parent, _, ctx) =>
321
+ parent.tags?.map((tag) => ({
322
+ name: tag,
323
+ description: ctx.schema.tags?.find((t) => t.name === tag)
324
+ ?.description,
325
+ })),
326
+ nullable: true,
327
+ }),
328
+ deprecated: t.exposeBoolean("deprecated", { nullable: true }),
329
+ }),
330
+ });
331
+
332
+ const Schema = builder.objectRef<OpenAPIDocument>("Schema").implement({
333
+ fields: (t) => ({
334
+ openapi: t.string({ resolve: (root) => root.openapi }),
335
+ url: t.string({ resolve: (root) => root.servers?.at(0)?.url ?? "/" }),
336
+ title: t.string({ resolve: (root) => root.info.title }),
337
+ version: t.string({ resolve: (root) => root.info.version }),
338
+ description: t.string({
339
+ resolve: (root) => root.info.description,
340
+ nullable: true,
341
+ }),
342
+ paths: t.field({
343
+ type: [PathItem],
344
+ resolve: (root) =>
345
+ Object.entries(root.paths ?? {}).map(([path, value]) => ({
346
+ path,
347
+ methods: Object.keys(value!) as typeof HttpMethods,
348
+ })),
349
+ }),
350
+ tags: t.field({
351
+ args: {
352
+ name: t.arg.string(),
353
+ },
354
+ type: [SchemaTag],
355
+ resolve: (root, args) =>
356
+ [...(root.tags ?? []), { name: "" }].filter(
357
+ (tag) => !args.name || args.name === tag.name,
358
+ ),
359
+ }),
360
+ operations: t.field({
361
+ type: [OperationItem],
362
+ args: {
363
+ path: t.arg.string(),
364
+ method: t.arg.string(),
365
+ operationId: t.arg.string(),
366
+ tag: t.arg.string(),
367
+ },
368
+ resolve: (parent, args) =>
369
+ getAllOperations(parent.paths).filter(
370
+ (item) =>
371
+ (!args.operationId || item.operationId === args.operationId) &&
372
+ (!args.path || item.path === args.path) &&
373
+ (!args.method || item.method === args.method) &&
374
+ (!args.tag || item.tags?.includes(args.tag)),
375
+ ),
376
+ }),
377
+ }),
378
+ });
379
+
380
+ const loadOpenAPISchema = async (input: NonNullable<unknown>) => {
381
+ const hash = hashit(input);
382
+
383
+ if (cache.has(hash)) {
384
+ return cache.get(hash)!;
385
+ }
386
+
387
+ const schema = await validate(input);
388
+
389
+ cache.set(hash, schema);
390
+
391
+ return schema;
392
+ };
393
+
394
+ const SchemaSource = builder.enumType("SchemaType", {
395
+ values: ["url", "json", "yaml"] as const,
396
+ });
397
+
398
+ builder.queryType({
399
+ fields: (t) => ({
400
+ // https://tan-cow-main-bce8a06.d2.zuplo.dev/openapi
401
+ schema: t.field({
402
+ type: Schema,
403
+ args: {
404
+ type: t.arg({ type: SchemaSource, required: true }),
405
+ input: t.arg({ type: JSONScalar, required: true }),
406
+ },
407
+ resolve: async (_, args, ctx) => {
408
+ const schema = await loadOpenAPISchema(args.input!);
409
+ // for easier access of the whole schema in children resolvers
410
+ ctx.schema = schema;
411
+
412
+ return schema;
413
+ },
414
+ }),
415
+ }),
416
+ });
417
+
418
+ export const schema = builder.toSchema();
419
+
420
+ export const createGraphQLServer = (
421
+ options?: Omit<YogaServerOptions<any, any>, "schema">,
422
+ ) => createYoga({ schema, ...options });
@@ -0,0 +1,10 @@
1
+ import { createServer } from "node:http";
2
+ import { createGraphQLServer } from "./index.js";
3
+
4
+ const yoga = createGraphQLServer();
5
+
6
+ const server = createServer(yoga);
7
+
8
+ server.listen(4000, () => {
9
+ console.log(`🚀 Server ready at http://localhost:4000/graphql`);
10
+ });
@@ -0,0 +1,59 @@
1
+ import type { JSONSchema4, JSONSchema6 } from "json-schema";
2
+ import { resolveLocalRef } from "./resolveRef.js";
3
+
4
+ export type JSONSchema = JSONSchema4 | JSONSchema6;
5
+
6
+ type CustomResolver = (ref: string) => Promise<JSONSchema | undefined>;
7
+
8
+ const cache = new Map<JSONSchema, JSONSchema>();
9
+
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ const isIndexableObject = (obj: any): obj is Record<string, any> =>
12
+ obj !== null && typeof obj === "object";
13
+
14
+ // Taken and inspired from `dereference-json-schema` package.
15
+ export const dereference = async (
16
+ schema: JSONSchema,
17
+ resolvers: CustomResolver[] = [],
18
+ ) => {
19
+ if (cache.has(schema)) {
20
+ return cache.get(schema)!;
21
+ }
22
+
23
+ const cloned = structuredClone(schema);
24
+ const visited = new Set();
25
+
26
+ const resolve = async (current: unknown, path: string) => {
27
+ if (isIndexableObject(current)) {
28
+ if (visited.has(current)) {
29
+ return current;
30
+ }
31
+
32
+ visited.add(current);
33
+
34
+ if (Array.isArray(current)) {
35
+ for (let index = 0; index < current.length; index++) {
36
+ current[index] = await resolve(current[index], `${path}/${index}`);
37
+ }
38
+ } else {
39
+ if ("$ref" in current && typeof current.$ref === "string") {
40
+ for (const resolver of resolvers) {
41
+ const resolved = await resolver(current.$ref);
42
+ if (resolved) return resolved;
43
+ }
44
+ return await resolveLocalRef(cloned, current.$ref);
45
+ }
46
+
47
+ for (const key in current) {
48
+ current[key] = await resolve(current[key], `${path}/${key}`);
49
+ }
50
+ }
51
+ }
52
+
53
+ return current;
54
+ };
55
+
56
+ const result = (await resolve(cloned, "#")) as JSONSchema;
57
+ cache.set(schema, result);
58
+ return result;
59
+ };
@@ -0,0 +1,32 @@
1
+ import type { JSONSchema } from "./index.js";
2
+
3
+ const cache = new Map<JSONSchema, Map<string, unknown>>();
4
+
5
+ /**
6
+ * Resolves a $ref pointer in a schema and returns the referenced value.
7
+ */
8
+ export const resolveLocalRef = (schema: JSONSchema, ref: string): unknown => {
9
+ if (!cache.has(schema)) {
10
+ cache.set(schema, new Map<string, unknown>());
11
+ }
12
+ const schemaCache = cache.get(schema);
13
+
14
+ if (schemaCache!.has(ref)) {
15
+ return schemaCache!.get(ref);
16
+ }
17
+
18
+ const path = ref.split("/").slice(1);
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ let current: any = schema;
22
+ for (const segment of path) {
23
+ if (!current || typeof current !== "object") {
24
+ // we've reached a dead end
25
+ current = null;
26
+ }
27
+ current = current[segment] ?? null;
28
+ }
29
+
30
+ schemaCache!.set(ref, current);
31
+ return current;
32
+ };
@@ -0,0 +1,94 @@
1
+ import { OpenAPIV3, type OpenAPIV3_1 } from "openapi-types";
2
+ import { dereference, type JSONSchema } from "./dereference/index.js";
3
+ import { upgradeSchema } from "./upgrade/index.js";
4
+
5
+ type ReferenceObject = OpenAPIV3_1.ReferenceObject;
6
+ type DeepOmitReference<T> = T extends ReferenceObject
7
+ ? never
8
+ : T extends object
9
+ ? { [K in keyof T]: DeepOmitReference<T[K]> }
10
+ : T;
11
+
12
+ // type Prettify<T> = {
13
+ // [K in keyof T]: T[K];
14
+ // } & {};
15
+
16
+ export type OpenAPIDocument = DeepOmitReference<OpenAPIV3_1.Document>;
17
+ export type ResponseObject = DeepOmitReference<OpenAPIV3_1.ResponseObject>;
18
+ export type OperationObject = DeepOmitReference<OpenAPIV3_1.OperationObject>;
19
+ export type PathsObject = DeepOmitReference<OpenAPIV3_1.PathsObject>;
20
+ export type PathItemObject = DeepOmitReference<OpenAPIV3_1.PathItemObject>;
21
+ export type ParameterObject = DeepOmitReference<OpenAPIV3_1.ParameterObject>;
22
+ export type TagObject = DeepOmitReference<OpenAPIV3_1.TagObject>;
23
+ export type ExampleObject = DeepOmitReference<OpenAPIV3_1.ExampleObject>;
24
+ export type EncodingObject = DeepOmitReference<OpenAPIV3_1.EncodingObject>;
25
+ export type SchemaObject = DeepOmitReference<OpenAPIV3_1.SchemaObject>;
26
+
27
+ export const HttpMethods = Object.values(OpenAPIV3.HttpMethods);
28
+
29
+ // class ValidationError extends Error {
30
+ // constructor(public errors: OutputUnit[]) {
31
+ // super("Validation error");
32
+ // }
33
+ // }
34
+
35
+ // const getValidator = async (openApiVersion: string) => {
36
+ // if (openApiVersion.startsWith("3.0")) {
37
+ // const schema = (await import("./schemas/v3.0.json")) as any;
38
+ // return new Validator(schema, "4");
39
+ // }
40
+ // if (openApiVersion.startsWith("3.1")) {
41
+ // const schema = (await import("./schemas/v3.1.json")) as any;
42
+ // return new Validator(schema as any, "2020-12");
43
+ // }
44
+
45
+ // throw new Error(`Unsupported OpenAPI version: ${openApiVersion}`);
46
+ // };
47
+
48
+ const parseSchemaInput = async (
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ schemaInput: any,
51
+ ): Promise<JSONSchema & { openapi?: string }> => {
52
+ if (typeof schemaInput === "string") {
53
+ if (schemaInput.trim().startsWith("{")) {
54
+ return JSON.parse(schemaInput);
55
+ }
56
+ if (schemaInput.includes("://")) {
57
+ const response = await fetch(schemaInput);
58
+ return (await response.json()) as JSONSchema;
59
+ }
60
+ const yaml = await import("yaml");
61
+ return yaml.parse(schemaInput);
62
+ }
63
+
64
+ if (typeof schemaInput === "object") return schemaInput;
65
+
66
+ throw new Error("Unsupported schema input");
67
+ };
68
+
69
+ /**
70
+ * Validates, dereferences and upgrades the OpenAPI schema (to v3.1) if necessary.
71
+ */
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ export const validate = async (schemaInput: any) => {
74
+ const schema = await parseSchemaInput(schemaInput);
75
+
76
+ if (!schema.openapi) {
77
+ throw new Error("OpenAPI version is not defined");
78
+ }
79
+
80
+ // const validator = await getValidator(schema.openapi);
81
+ // const result = validator.validate(schema);
82
+ //
83
+ // if (!result.valid) {
84
+ // throw new ValidationError(result.errors);
85
+ // }
86
+
87
+ const dereferenced = await dereference(schema);
88
+
89
+ const upgraded = upgradeSchema(
90
+ dereferenced as OpenAPIV3_1.Document | OpenAPIV3.Document,
91
+ );
92
+
93
+ return upgraded;
94
+ };