zudoku 0.1.1-dev.15 → 0.1.1-dev.16

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 (387) hide show
  1. package/dist/app/App.js +3 -1
  2. package/dist/app/App.js.map +1 -1
  3. package/dist/config/config.d.ts +3 -3
  4. package/dist/index.d.ts +2 -6
  5. package/dist/index.js +1 -5
  6. package/dist/index.js.map +1 -1
  7. package/dist/{app → lib}/DevPortal.d.ts +2 -2
  8. package/dist/{app → lib}/DevPortal.js +4 -4
  9. package/dist/{app → lib}/DevPortal.js.map +1 -1
  10. package/dist/{app → lib}/Heading.js.map +1 -1
  11. package/dist/{app → lib}/Router.js.map +1 -1
  12. package/dist/lib/auth.d.ts +1 -0
  13. package/dist/lib/auth.js +2 -0
  14. package/dist/lib/auth.js.map +1 -0
  15. package/dist/lib/authentication/authentication.js.map +1 -0
  16. package/dist/{app → lib}/authentication/clerk.d.ts +1 -2
  17. package/dist/{app → lib}/authentication/clerk.js +1 -2
  18. package/dist/lib/authentication/clerk.js.map +1 -0
  19. package/dist/{app → lib}/authentication/openid.js.map +1 -1
  20. package/dist/{app → lib}/components/AnchorLink.js.map +1 -1
  21. package/dist/{app → lib}/components/CategoryHeading.js.map +1 -1
  22. package/dist/{app → lib}/components/Dialog.js.map +1 -1
  23. package/dist/{app → lib}/components/DynamicIcon.js.map +1 -1
  24. package/dist/{app → lib}/components/Header.js.map +1 -1
  25. package/dist/{app → lib}/components/Input.js.map +1 -1
  26. package/dist/{app → lib}/components/Layout.js.map +1 -1
  27. package/dist/{app → lib}/components/Markdown.js.map +1 -1
  28. package/dist/{app → lib}/components/SyntaxHighlight.js.map +1 -1
  29. package/dist/{app → lib}/components/TopNavigation.js.map +1 -1
  30. package/dist/{app → lib}/components/context/ComponentsContext.js.map +1 -1
  31. package/dist/{app → lib}/components/context/DevPortalProvider.js.map +1 -1
  32. package/dist/lib/components/context/PluginSystem.js.map +1 -0
  33. package/dist/{app → lib}/components/context/ThemeContext.js.map +1 -1
  34. package/dist/{app → lib}/components/context/ViewportAnchorContext.js.map +1 -1
  35. package/dist/{app → lib}/components/navigation/SideNavigation.js.map +1 -1
  36. package/dist/{app → lib}/components/navigation/SideNavigationCategory.js.map +1 -1
  37. package/dist/{app → lib}/components/navigation/SideNavigationItem.js.map +1 -1
  38. package/dist/{app → lib}/components/navigation/SideNavigationWrapper.js.map +1 -1
  39. package/dist/{app → lib}/components/navigation/useNavigationCollapsibleState.js.map +1 -1
  40. package/dist/{app → lib}/components/navigation/util.js.map +1 -1
  41. package/dist/lib/components.d.ts +3 -0
  42. package/dist/lib/components.js +4 -0
  43. package/dist/lib/components.js.map +1 -0
  44. package/dist/{app → lib}/core/DevPortalContext.js.map +1 -1
  45. package/dist/{app → lib}/core/helmet.js.map +1 -1
  46. package/dist/lib/core/icons.js.map +1 -0
  47. package/dist/{app → lib}/core/plugins.js.map +1 -1
  48. package/dist/lib/core/router.js.map +1 -0
  49. package/dist/lib/core/types/combine.js.map +1 -0
  50. package/dist/{app → lib}/oas/graphql/index.js.map +1 -1
  51. package/dist/{app → lib}/oas/graphql/server.js.map +1 -1
  52. package/dist/{app → lib}/oas/parser/dereference/index.js.map +1 -1
  53. package/dist/{app → lib}/oas/parser/dereference/resolveRef.js.map +1 -1
  54. package/dist/{app → lib}/oas/parser/index.js.map +1 -1
  55. package/dist/{app → lib}/oas/parser/upgrade/index.js.map +1 -1
  56. package/dist/{app → lib}/plugins/api-key/SettingsApiKeys.js.map +1 -1
  57. package/dist/{app → lib}/plugins/api-key/index.js.map +1 -1
  58. package/dist/{app → lib}/plugins/markdown/MdxPage.js.map +1 -1
  59. package/dist/{app → lib}/plugins/markdown/Toc.js.map +1 -1
  60. package/dist/{app → lib}/plugins/markdown/generateRoutes.js.map +1 -1
  61. package/dist/{app → lib}/plugins/markdown/index.js.map +1 -1
  62. package/dist/{app → lib}/plugins/openapi/ColorizedParam.js.map +1 -1
  63. package/dist/{app → lib}/plugins/openapi/MakeRequest.js.map +1 -1
  64. package/dist/{app → lib}/plugins/openapi/MethodBadge.js.map +1 -1
  65. package/dist/{app → lib}/plugins/openapi/OperationList.js.map +1 -1
  66. package/dist/{app → lib}/plugins/openapi/OperationListItem.js.map +1 -1
  67. package/dist/{app → lib}/plugins/openapi/ParameterList.js.map +1 -1
  68. package/dist/{app → lib}/plugins/openapi/ParameterListItem.js.map +1 -1
  69. package/dist/{app → lib}/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
  70. package/dist/{app → lib}/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
  71. package/dist/{app → lib}/plugins/openapi/Select.js.map +1 -1
  72. package/dist/{app → lib}/plugins/openapi/Sidecar.js.map +1 -1
  73. package/dist/{app → lib}/plugins/openapi/SidecarBox.js.map +1 -1
  74. package/dist/{app → lib}/plugins/openapi/graphql/fragment-masking.js.map +1 -1
  75. package/dist/{app → lib}/plugins/openapi/graphql/gql.js.map +1 -1
  76. package/dist/{app → lib}/plugins/openapi/graphql/graphql.js.map +1 -1
  77. package/dist/lib/plugins/openapi/graphql/index.js.map +1 -0
  78. package/dist/{app → lib}/plugins/openapi/index.js.map +1 -1
  79. package/dist/{app → lib}/plugins/openapi/playground/Playground.js.map +1 -1
  80. package/dist/{app → lib}/plugins/openapi/util/generateSchemaExample.js.map +1 -1
  81. package/dist/{app → lib}/plugins/openapi/util/urql.js.map +1 -1
  82. package/dist/{app → lib}/plugins/openapi/worker/createSharedWorkerClient.js.map +1 -1
  83. package/dist/{app → lib}/plugins/openapi/worker/worker.js.map +1 -1
  84. package/dist/{app → lib}/plugins/redirect/index.js.map +1 -1
  85. package/dist/lib/plugins.d.ts +4 -0
  86. package/dist/lib/plugins.js +6 -0
  87. package/dist/lib/plugins.js.map +1 -0
  88. package/dist/{app → lib}/ui/Button.d.ts +1 -1
  89. package/dist/{app → lib}/ui/Button.js.map +1 -1
  90. package/dist/{app → lib}/ui/Callout.js.map +1 -1
  91. package/dist/{app → lib}/ui/Card.js.map +1 -1
  92. package/dist/{app → lib}/ui/Note.js.map +1 -1
  93. package/dist/{app → lib}/ui/Tabs.js.map +1 -1
  94. package/dist/{app → lib}/util/MdxComponents.js.map +1 -1
  95. package/dist/{app → lib}/util/cn.js.map +1 -1
  96. package/dist/{app → lib}/util/createVariantComponent.js.map +1 -1
  97. package/dist/{app → lib}/util/createWaitForNotify.js.map +1 -1
  98. package/dist/{app → lib}/util/groupBy.js.map +1 -1
  99. package/dist/{app → lib}/util/joinPath.js.map +1 -1
  100. package/dist/{app → lib}/util/pastellize.js.map +1 -1
  101. package/dist/lib/util/slugify.js.map +1 -0
  102. package/dist/{app → lib}/util/traverseNavigation.js.map +1 -1
  103. package/dist/{app → lib}/util/useScrollToAnchor.js.map +1 -1
  104. package/dist/{app → lib}/util/useScrollToTop.js.map +1 -1
  105. package/dist/vite/config.d.ts +0 -1
  106. package/dist/vite/config.js +18 -14
  107. package/dist/vite/config.js.map +1 -1
  108. package/dist/vite/dev-server.js +1 -1
  109. package/dist/vite/plugin-api.js +1 -1
  110. package/dist/vite/plugin-api.js.map +1 -1
  111. package/dist/vite/plugin-auth.js +2 -2
  112. package/dist/vite/plugin-auth.js.map +1 -1
  113. package/dist/vite/plugin-component.d.ts +3 -0
  114. package/dist/vite/plugin-component.js +22 -0
  115. package/dist/vite/plugin-component.js.map +1 -0
  116. package/dist/vite/plugin-docs.js +1 -1
  117. package/dist/vite/plugin-docs.js.map +1 -1
  118. package/dist/vite/plugin-html.js +0 -3
  119. package/dist/vite/plugin-html.js.map +1 -1
  120. package/dist/vite/plugin-mdx.js +1 -1
  121. package/dist/vite/plugin-mdx.js.map +1 -1
  122. package/package.json +15 -16
  123. package/src/app/App.tsx +4 -1
  124. package/dist/app/authentication/authentication.js.map +0 -1
  125. package/dist/app/authentication/clerk.js.map +0 -1
  126. package/dist/app/components/context/PluginSystem.js.map +0 -1
  127. package/dist/app/core/icons.js.map +0 -1
  128. package/dist/app/core/router.js.map +0 -1
  129. package/dist/app/core/types/combine.js.map +0 -1
  130. package/dist/app/plugins/openapi/graphql/index.js.map +0 -1
  131. package/dist/app/util/slugify.js.map +0 -1
  132. package/dist/auth.d.ts +0 -2
  133. package/dist/auth.js +0 -3
  134. package/dist/auth.js.map +0 -1
  135. package/dist/plugins.d.ts +0 -4
  136. package/dist/plugins.js +0 -6
  137. package/dist/plugins.js.map +0 -1
  138. package/src/app/DevPortal.tsx +0 -93
  139. package/src/app/Heading.tsx +0 -60
  140. package/src/app/Router.tsx +0 -28
  141. package/src/app/authentication/authentication.ts +0 -18
  142. package/src/app/authentication/clerk.ts +0 -47
  143. package/src/app/authentication/openid.ts +0 -192
  144. package/src/app/components/AnchorLink.tsx +0 -19
  145. package/src/app/components/CategoryHeading.tsx +0 -16
  146. package/src/app/components/Dialog.tsx +0 -119
  147. package/src/app/components/DynamicIcon.tsx +0 -60
  148. package/src/app/components/Header.tsx +0 -69
  149. package/src/app/components/Input.tsx +0 -24
  150. package/src/app/components/Layout.tsx +0 -56
  151. package/src/app/components/Markdown.tsx +0 -37
  152. package/src/app/components/SyntaxHighlight.tsx +0 -94
  153. package/src/app/components/TopNavigation.tsx +0 -32
  154. package/src/app/components/context/ComponentsContext.tsx +0 -24
  155. package/src/app/components/context/DevPortalProvider.ts +0 -54
  156. package/src/app/components/context/PluginSystem.ts +0 -0
  157. package/src/app/components/context/ThemeContext.tsx +0 -46
  158. package/src/app/components/context/ViewportAnchorContext.tsx +0 -139
  159. package/src/app/components/navigation/SideNavigation.tsx +0 -18
  160. package/src/app/components/navigation/SideNavigationCategory.tsx +0 -74
  161. package/src/app/components/navigation/SideNavigationItem.tsx +0 -143
  162. package/src/app/components/navigation/SideNavigationWrapper.tsx +0 -15
  163. package/src/app/components/navigation/useNavigationCollapsibleState.ts +0 -27
  164. package/src/app/components/navigation/util.ts +0 -38
  165. package/src/app/core/DevPortalContext.ts +0 -164
  166. package/src/app/core/helmet.ts +0 -5
  167. package/src/app/core/icons.tsx +0 -1
  168. package/src/app/core/plugins.ts +0 -43
  169. package/src/app/core/router.tsx +0 -1
  170. package/src/app/core/types/combine.ts +0 -16
  171. package/src/app/oas/graphql/index.ts +0 -422
  172. package/src/app/oas/graphql/server.ts +0 -10
  173. package/src/app/oas/parser/dereference/index.ts +0 -59
  174. package/src/app/oas/parser/dereference/resolveRef.ts +0 -32
  175. package/src/app/oas/parser/index.ts +0 -94
  176. package/src/app/oas/parser/schemas/v3.0.json +0 -1489
  177. package/src/app/oas/parser/schemas/v3.1.json +0 -1298
  178. package/src/app/oas/parser/upgrade/index.ts +0 -108
  179. package/src/app/plugins/api-key/SettingsApiKeys.tsx +0 -22
  180. package/src/app/plugins/api-key/index.tsx +0 -123
  181. package/src/app/plugins/markdown/MdxPage.tsx +0 -128
  182. package/src/app/plugins/markdown/Toc.tsx +0 -122
  183. package/src/app/plugins/markdown/generateRoutes.tsx +0 -72
  184. package/src/app/plugins/markdown/index.tsx +0 -31
  185. package/src/app/plugins/openapi/ColorizedParam.tsx +0 -82
  186. package/src/app/plugins/openapi/MakeRequest.tsx +0 -49
  187. package/src/app/plugins/openapi/MethodBadge.tsx +0 -36
  188. package/src/app/plugins/openapi/OperationList.tsx +0 -117
  189. package/src/app/plugins/openapi/OperationListItem.tsx +0 -55
  190. package/src/app/plugins/openapi/ParameterList.tsx +0 -32
  191. package/src/app/plugins/openapi/ParameterListItem.tsx +0 -60
  192. package/src/app/plugins/openapi/RequestBodySidecarBox.tsx +0 -51
  193. package/src/app/plugins/openapi/ResponsesSidecarBox.tsx +0 -60
  194. package/src/app/plugins/openapi/Select.tsx +0 -35
  195. package/src/app/plugins/openapi/Sidecar.tsx +0 -160
  196. package/src/app/plugins/openapi/SidecarBox.tsx +0 -36
  197. package/src/app/plugins/openapi/graphql/fragment-masking.ts +0 -111
  198. package/src/app/plugins/openapi/graphql/gql.ts +0 -70
  199. package/src/app/plugins/openapi/graphql/graphql.ts +0 -795
  200. package/src/app/plugins/openapi/graphql/index.ts +0 -2
  201. package/src/app/plugins/openapi/index.tsx +0 -142
  202. package/src/app/plugins/openapi/playground/Playground.tsx +0 -309
  203. package/src/app/plugins/openapi/queries.graphql +0 -6
  204. package/src/app/plugins/openapi/util/generateSchemaExample.ts +0 -59
  205. package/src/app/plugins/openapi/util/urql.ts +0 -8
  206. package/src/app/plugins/openapi/worker/createSharedWorkerClient.ts +0 -60
  207. package/src/app/plugins/openapi/worker/worker.ts +0 -30
  208. package/src/app/plugins/redirect/index.tsx +0 -20
  209. package/src/app/ui/Button.tsx +0 -56
  210. package/src/app/ui/Callout.tsx +0 -87
  211. package/src/app/ui/Card.tsx +0 -82
  212. package/src/app/ui/Note.tsx +0 -58
  213. package/src/app/ui/Tabs.tsx +0 -52
  214. package/src/app/util/MdxComponents.tsx +0 -70
  215. package/src/app/util/cn.ts +0 -6
  216. package/src/app/util/createVariantComponent.tsx +0 -30
  217. package/src/app/util/createWaitForNotify.ts +0 -18
  218. package/src/app/util/groupBy.ts +0 -24
  219. package/src/app/util/joinPath.tsx +0 -10
  220. package/src/app/util/pastellize.ts +0 -25
  221. package/src/app/util/slugify.ts +0 -3
  222. package/src/app/util/traverseNavigation.ts +0 -55
  223. package/src/app/util/useScrollToAnchor.ts +0 -38
  224. package/src/app/util/useScrollToTop.ts +0 -13
  225. /package/dist/{app → lib}/Heading.d.ts +0 -0
  226. /package/dist/{app → lib}/Heading.js +0 -0
  227. /package/dist/{app → lib}/Router.d.ts +0 -0
  228. /package/dist/{app → lib}/Router.js +0 -0
  229. /package/dist/{app → lib}/authentication/authentication.d.ts +0 -0
  230. /package/dist/{app → lib}/authentication/authentication.js +0 -0
  231. /package/dist/{app → lib}/authentication/openid.d.ts +0 -0
  232. /package/dist/{app → lib}/authentication/openid.js +0 -0
  233. /package/dist/{app → lib}/components/AnchorLink.d.ts +0 -0
  234. /package/dist/{app → lib}/components/AnchorLink.js +0 -0
  235. /package/dist/{app → lib}/components/CategoryHeading.d.ts +0 -0
  236. /package/dist/{app → lib}/components/CategoryHeading.js +0 -0
  237. /package/dist/{app → lib}/components/Dialog.d.ts +0 -0
  238. /package/dist/{app → lib}/components/Dialog.js +0 -0
  239. /package/dist/{app → lib}/components/DynamicIcon.d.ts +0 -0
  240. /package/dist/{app → lib}/components/DynamicIcon.js +0 -0
  241. /package/dist/{app → lib}/components/Header.d.ts +0 -0
  242. /package/dist/{app → lib}/components/Header.js +0 -0
  243. /package/dist/{app → lib}/components/Input.d.ts +0 -0
  244. /package/dist/{app → lib}/components/Input.js +0 -0
  245. /package/dist/{app → lib}/components/Layout.d.ts +0 -0
  246. /package/dist/{app → lib}/components/Layout.js +0 -0
  247. /package/dist/{app → lib}/components/Markdown.d.ts +0 -0
  248. /package/dist/{app → lib}/components/Markdown.js +0 -0
  249. /package/dist/{app → lib}/components/SyntaxHighlight.d.ts +0 -0
  250. /package/dist/{app → lib}/components/SyntaxHighlight.js +0 -0
  251. /package/dist/{app → lib}/components/TopNavigation.d.ts +0 -0
  252. /package/dist/{app → lib}/components/TopNavigation.js +0 -0
  253. /package/dist/{app → lib}/components/context/ComponentsContext.d.ts +0 -0
  254. /package/dist/{app → lib}/components/context/ComponentsContext.js +0 -0
  255. /package/dist/{app → lib}/components/context/DevPortalProvider.d.ts +0 -0
  256. /package/dist/{app → lib}/components/context/DevPortalProvider.js +0 -0
  257. /package/dist/{app → lib}/components/context/PluginSystem.d.ts +0 -0
  258. /package/dist/{app → lib}/components/context/PluginSystem.js +0 -0
  259. /package/dist/{app → lib}/components/context/ThemeContext.d.ts +0 -0
  260. /package/dist/{app → lib}/components/context/ThemeContext.js +0 -0
  261. /package/dist/{app → lib}/components/context/ViewportAnchorContext.d.ts +0 -0
  262. /package/dist/{app → lib}/components/context/ViewportAnchorContext.js +0 -0
  263. /package/dist/{app → lib}/components/navigation/SideNavigation.d.ts +0 -0
  264. /package/dist/{app → lib}/components/navigation/SideNavigation.js +0 -0
  265. /package/dist/{app → lib}/components/navigation/SideNavigationCategory.d.ts +0 -0
  266. /package/dist/{app → lib}/components/navigation/SideNavigationCategory.js +0 -0
  267. /package/dist/{app → lib}/components/navigation/SideNavigationItem.d.ts +0 -0
  268. /package/dist/{app → lib}/components/navigation/SideNavigationItem.js +0 -0
  269. /package/dist/{app → lib}/components/navigation/SideNavigationWrapper.d.ts +0 -0
  270. /package/dist/{app → lib}/components/navigation/SideNavigationWrapper.js +0 -0
  271. /package/dist/{app → lib}/components/navigation/useNavigationCollapsibleState.d.ts +0 -0
  272. /package/dist/{app → lib}/components/navigation/useNavigationCollapsibleState.js +0 -0
  273. /package/dist/{app → lib}/components/navigation/util.d.ts +0 -0
  274. /package/dist/{app → lib}/components/navigation/util.js +0 -0
  275. /package/dist/{app → lib}/core/DevPortalContext.d.ts +0 -0
  276. /package/dist/{app → lib}/core/DevPortalContext.js +0 -0
  277. /package/dist/{app → lib}/core/helmet.d.ts +0 -0
  278. /package/dist/{app → lib}/core/helmet.js +0 -0
  279. /package/dist/{app → lib}/core/icons.d.ts +0 -0
  280. /package/dist/{app → lib}/core/icons.js +0 -0
  281. /package/dist/{app → lib}/core/plugins.d.ts +0 -0
  282. /package/dist/{app → lib}/core/plugins.js +0 -0
  283. /package/dist/{app → lib}/core/router.d.ts +0 -0
  284. /package/dist/{app → lib}/core/router.js +0 -0
  285. /package/dist/{app → lib}/core/types/combine.d.ts +0 -0
  286. /package/dist/{app → lib}/core/types/combine.js +0 -0
  287. /package/dist/{app → lib}/oas/graphql/index.d.ts +0 -0
  288. /package/dist/{app → lib}/oas/graphql/index.js +0 -0
  289. /package/dist/{app → lib}/oas/graphql/server.d.ts +0 -0
  290. /package/dist/{app → lib}/oas/graphql/server.js +0 -0
  291. /package/dist/{app → lib}/oas/parser/dereference/index.d.ts +0 -0
  292. /package/dist/{app → lib}/oas/parser/dereference/index.js +0 -0
  293. /package/dist/{app → lib}/oas/parser/dereference/resolveRef.d.ts +0 -0
  294. /package/dist/{app → lib}/oas/parser/dereference/resolveRef.js +0 -0
  295. /package/dist/{app → lib}/oas/parser/index.d.ts +0 -0
  296. /package/dist/{app → lib}/oas/parser/index.js +0 -0
  297. /package/dist/{app → lib}/oas/parser/upgrade/index.d.ts +0 -0
  298. /package/dist/{app → lib}/oas/parser/upgrade/index.js +0 -0
  299. /package/dist/{app → lib}/plugins/api-key/SettingsApiKeys.d.ts +0 -0
  300. /package/dist/{app → lib}/plugins/api-key/SettingsApiKeys.js +0 -0
  301. /package/dist/{app → lib}/plugins/api-key/index.d.ts +0 -0
  302. /package/dist/{app → lib}/plugins/api-key/index.js +0 -0
  303. /package/dist/{app → lib}/plugins/markdown/MdxPage.d.ts +0 -0
  304. /package/dist/{app → lib}/plugins/markdown/MdxPage.js +0 -0
  305. /package/dist/{app → lib}/plugins/markdown/Toc.d.ts +0 -0
  306. /package/dist/{app → lib}/plugins/markdown/Toc.js +0 -0
  307. /package/dist/{app → lib}/plugins/markdown/generateRoutes.d.ts +0 -0
  308. /package/dist/{app → lib}/plugins/markdown/generateRoutes.js +0 -0
  309. /package/dist/{app → lib}/plugins/markdown/index.d.ts +0 -0
  310. /package/dist/{app → lib}/plugins/markdown/index.js +0 -0
  311. /package/dist/{app → lib}/plugins/openapi/ColorizedParam.d.ts +0 -0
  312. /package/dist/{app → lib}/plugins/openapi/ColorizedParam.js +0 -0
  313. /package/dist/{app → lib}/plugins/openapi/MakeRequest.d.ts +0 -0
  314. /package/dist/{app → lib}/plugins/openapi/MakeRequest.js +0 -0
  315. /package/dist/{app → lib}/plugins/openapi/MethodBadge.d.ts +0 -0
  316. /package/dist/{app → lib}/plugins/openapi/MethodBadge.js +0 -0
  317. /package/dist/{app → lib}/plugins/openapi/OperationList.d.ts +0 -0
  318. /package/dist/{app → lib}/plugins/openapi/OperationList.js +0 -0
  319. /package/dist/{app → lib}/plugins/openapi/OperationListItem.d.ts +0 -0
  320. /package/dist/{app → lib}/plugins/openapi/OperationListItem.js +0 -0
  321. /package/dist/{app → lib}/plugins/openapi/ParameterList.d.ts +0 -0
  322. /package/dist/{app → lib}/plugins/openapi/ParameterList.js +0 -0
  323. /package/dist/{app → lib}/plugins/openapi/ParameterListItem.d.ts +0 -0
  324. /package/dist/{app → lib}/plugins/openapi/ParameterListItem.js +0 -0
  325. /package/dist/{app → lib}/plugins/openapi/RequestBodySidecarBox.d.ts +0 -0
  326. /package/dist/{app → lib}/plugins/openapi/RequestBodySidecarBox.js +0 -0
  327. /package/dist/{app → lib}/plugins/openapi/ResponsesSidecarBox.d.ts +0 -0
  328. /package/dist/{app → lib}/plugins/openapi/ResponsesSidecarBox.js +0 -0
  329. /package/dist/{app → lib}/plugins/openapi/Select.d.ts +0 -0
  330. /package/dist/{app → lib}/plugins/openapi/Select.js +0 -0
  331. /package/dist/{app → lib}/plugins/openapi/Sidecar.d.ts +0 -0
  332. /package/dist/{app → lib}/plugins/openapi/Sidecar.js +0 -0
  333. /package/dist/{app → lib}/plugins/openapi/SidecarBox.d.ts +0 -0
  334. /package/dist/{app → lib}/plugins/openapi/SidecarBox.js +0 -0
  335. /package/dist/{app → lib}/plugins/openapi/graphql/fragment-masking.d.ts +0 -0
  336. /package/dist/{app → lib}/plugins/openapi/graphql/fragment-masking.js +0 -0
  337. /package/dist/{app → lib}/plugins/openapi/graphql/gql.d.ts +0 -0
  338. /package/dist/{app → lib}/plugins/openapi/graphql/gql.js +0 -0
  339. /package/dist/{app → lib}/plugins/openapi/graphql/graphql.d.ts +0 -0
  340. /package/dist/{app → lib}/plugins/openapi/graphql/graphql.js +0 -0
  341. /package/dist/{app → lib}/plugins/openapi/graphql/index.d.ts +0 -0
  342. /package/dist/{app → lib}/plugins/openapi/graphql/index.js +0 -0
  343. /package/dist/{app → lib}/plugins/openapi/index.d.ts +0 -0
  344. /package/dist/{app → lib}/plugins/openapi/index.js +0 -0
  345. /package/dist/{app → lib}/plugins/openapi/playground/Playground.d.ts +0 -0
  346. /package/dist/{app → lib}/plugins/openapi/playground/Playground.js +0 -0
  347. /package/dist/{app → lib}/plugins/openapi/util/generateSchemaExample.d.ts +0 -0
  348. /package/dist/{app → lib}/plugins/openapi/util/generateSchemaExample.js +0 -0
  349. /package/dist/{app → lib}/plugins/openapi/util/urql.d.ts +0 -0
  350. /package/dist/{app → lib}/plugins/openapi/util/urql.js +0 -0
  351. /package/dist/{app → lib}/plugins/openapi/worker/createSharedWorkerClient.d.ts +0 -0
  352. /package/dist/{app → lib}/plugins/openapi/worker/createSharedWorkerClient.js +0 -0
  353. /package/dist/{app → lib}/plugins/openapi/worker/worker.d.ts +0 -0
  354. /package/dist/{app → lib}/plugins/openapi/worker/worker.js +0 -0
  355. /package/dist/{app → lib}/plugins/redirect/index.d.ts +0 -0
  356. /package/dist/{app → lib}/plugins/redirect/index.js +0 -0
  357. /package/dist/{app → lib}/ui/Button.js +0 -0
  358. /package/dist/{app → lib}/ui/Callout.d.ts +0 -0
  359. /package/dist/{app → lib}/ui/Callout.js +0 -0
  360. /package/dist/{app → lib}/ui/Card.d.ts +0 -0
  361. /package/dist/{app → lib}/ui/Card.js +0 -0
  362. /package/dist/{app → lib}/ui/Note.d.ts +0 -0
  363. /package/dist/{app → lib}/ui/Note.js +0 -0
  364. /package/dist/{app → lib}/ui/Tabs.d.ts +0 -0
  365. /package/dist/{app → lib}/ui/Tabs.js +0 -0
  366. /package/dist/{app → lib}/util/MdxComponents.d.ts +0 -0
  367. /package/dist/{app → lib}/util/MdxComponents.js +0 -0
  368. /package/dist/{app → lib}/util/cn.d.ts +0 -0
  369. /package/dist/{app → lib}/util/cn.js +0 -0
  370. /package/dist/{app → lib}/util/createVariantComponent.d.ts +0 -0
  371. /package/dist/{app → lib}/util/createVariantComponent.js +0 -0
  372. /package/dist/{app → lib}/util/createWaitForNotify.d.ts +0 -0
  373. /package/dist/{app → lib}/util/createWaitForNotify.js +0 -0
  374. /package/dist/{app → lib}/util/groupBy.d.ts +0 -0
  375. /package/dist/{app → lib}/util/groupBy.js +0 -0
  376. /package/dist/{app → lib}/util/joinPath.d.ts +0 -0
  377. /package/dist/{app → lib}/util/joinPath.js +0 -0
  378. /package/dist/{app → lib}/util/pastellize.d.ts +0 -0
  379. /package/dist/{app → lib}/util/pastellize.js +0 -0
  380. /package/dist/{app → lib}/util/slugify.d.ts +0 -0
  381. /package/dist/{app → lib}/util/slugify.js +0 -0
  382. /package/dist/{app → lib}/util/traverseNavigation.d.ts +0 -0
  383. /package/dist/{app → lib}/util/traverseNavigation.js +0 -0
  384. /package/dist/{app → lib}/util/useScrollToAnchor.d.ts +0 -0
  385. /package/dist/{app → lib}/util/useScrollToAnchor.js +0 -0
  386. /package/dist/{app → lib}/util/useScrollToTop.d.ts +0 -0
  387. /package/dist/{app → lib}/util/useScrollToTop.js +0 -0
@@ -1,38 +0,0 @@
1
- import { matchPath } from "react-router-dom";
2
- import type {
3
- HrefNavigationCategoryItem,
4
- PathNavigationCategoryItem,
5
- } from "../../core/DevPortalContext.js";
6
- import {
7
- traverseNavigationNode,
8
- type NavigationNode,
9
- } from "../../util/traverseNavigation.js";
10
-
11
- export const isPathItem = (
12
- item: NavigationNode,
13
- ): item is PathNavigationCategoryItem => "path" in item;
14
-
15
- export const isLinkItem = (
16
- item: NavigationNode,
17
- ): item is HrefNavigationCategoryItem => "href" in item;
18
-
19
- /**
20
- * Recursively checks if the current item or any of its children are active.
21
- */
22
- export const checkHasActiveItem = (
23
- item: NavigationNode,
24
- locationPath: string,
25
- basePath: string,
26
- ) => {
27
- return Boolean(
28
- traverseNavigationNode(
29
- item,
30
- (node, fullPath) => {
31
- if (isPathItem(node) && matchPath(fullPath, locationPath)) {
32
- return true;
33
- }
34
- },
35
- basePath,
36
- ),
37
- );
38
- };
@@ -1,164 +0,0 @@
1
- import { QueryClient } from "@tanstack/react-query";
2
- import { type ReactNode } from "react";
3
- import { create } from "zustand";
4
- import { type DevPortalPath, type DevPortalProps } from "../DevPortal.js";
5
- import { type AuthProvider } from "../authentication/authentication.js";
6
- import {
7
- isApiKeyPlugin,
8
- isNavigationPlugin,
9
- needsInitialization,
10
- type DevPortalPlugin,
11
- type NavigationPlugin,
12
- } from "./plugins.js";
13
-
14
- import type { LucideIcon } from "lucide-react";
15
- import type { IconName } from "../components/DynamicIcon.js";
16
-
17
- export interface ApiIdentity {
18
- authorizeRequest: (request: Request) => Request;
19
- name: string;
20
- id: string;
21
- }
22
-
23
- type BaseNavigationCategoryItem = {
24
- label: ReactNode;
25
- title?: string;
26
- icon?: ReactNode | IconName;
27
- };
28
-
29
- export type PathNavigationCategoryItem = BaseNavigationCategoryItem & {
30
- path: string;
31
- children?: NavigationCategoryItem[];
32
- };
33
-
34
- export type HrefNavigationCategoryItem = BaseNavigationCategoryItem & {
35
- href: string;
36
- };
37
-
38
- export type NavigationCategoryItem =
39
- | PathNavigationCategoryItem
40
- | HrefNavigationCategoryItem;
41
-
42
- export type NavigationCategory = {
43
- label: string;
44
- path?: string;
45
- expanded?: boolean;
46
- collapsible?: boolean;
47
- icon?: LucideIcon;
48
- children: NavigationCategoryItem[];
49
- };
50
-
51
- export type NavigationItem = {
52
- label: string;
53
- path: DevPortalPath;
54
- categories?: NavigationCategory[];
55
- };
56
-
57
- export type SessionProfileState = {
58
- isLoggedIn: boolean;
59
- sub?: string;
60
- email?: string;
61
- name?: string;
62
- email_verified?: string;
63
- picture?: string;
64
- };
65
-
66
- export type RoutingState = {
67
- path?: string;
68
- };
69
-
70
- export const queryClient = new QueryClient();
71
-
72
- export const useDevPortalState = create<SessionProfileState & RoutingState>(
73
- () => ({
74
- isLoggedIn: false,
75
- }),
76
- );
77
-
78
- export type ApiKeyCache = "api-keys";
79
- export type DevPortalCacheKey = ApiKeyCache | string;
80
-
81
- export class DevPortalContext {
82
- private plugins: DevPortalPlugin[] = [];
83
- private navigationPlugins: NavigationPlugin[];
84
-
85
- public navigation: NavigationItem[];
86
- public meta: DevPortalProps["meta"];
87
- public authentication?: AuthProvider;
88
- public state: typeof useDevPortalState;
89
-
90
- constructor(private config: DevPortalProps) {
91
- this.plugins = config.plugins ?? [];
92
- this.navigation = config.navigation;
93
- this.navigationPlugins = this.plugins.filter(isNavigationPlugin);
94
- this.authentication = config.authentication;
95
- this.meta = config.meta;
96
- this.state = useDevPortalState;
97
- }
98
-
99
- initialize = async () => {
100
- this.plugins
101
- .filter(needsInitialization)
102
- .forEach((plugin) => plugin.initialize(this));
103
- this.authentication?.initialize(this);
104
- };
105
-
106
- setUserProfile = async (profile: Partial<SessionProfileState>) => {
107
- return useDevPortalState.setState(profile);
108
- };
109
-
110
- invalidateCache = async (key: DevPortalCacheKey[]) => {
111
- queryClient.invalidateQueries({ queryKey: key });
112
- };
113
-
114
- getApiIdentities = async () => {
115
- const keys = await Promise.all(
116
- this.plugins
117
- .filter(isApiKeyPlugin)
118
- .map((plugin) => plugin.getIdentities(this)),
119
- );
120
-
121
- return keys.flat();
122
- };
123
-
124
- login = async () => {
125
- if (!this.authentication) {
126
- throw new Error("No authentication configured");
127
- }
128
-
129
- return this.authentication.login(this);
130
- };
131
-
132
- logout = async () => {
133
- if (!this.authentication) {
134
- throw new Error("No authentication configured");
135
- }
136
-
137
- return this.authentication.signOut(this);
138
- };
139
-
140
- handleAuthenticationResponse = async (path: {
141
- pathname: string;
142
- search: string;
143
- hash: string;
144
- }) => {
145
- this.config.authentication?.handleAuthenticationResponse?.(path, this);
146
- };
147
-
148
- getNavigation = async (path: string) => {
149
- const navigations = await Promise.all(
150
- this.navigationPlugins.map(async (plugin) =>
151
- plugin.getNavigation?.(path),
152
- ),
153
- );
154
-
155
- return navigations.flatMap((nav) => nav ?? []);
156
- };
157
-
158
- sessionStorage = {
159
- get: async (key: string) => localStorage.getItem(`session-${key}`) ?? "",
160
- setProfile: async () => {},
161
- set: async (key: string, value: string) =>
162
- localStorage.setItem(`session-${key}`, value),
163
- };
164
- }
@@ -1,5 +0,0 @@
1
- import * as helmet from "react-helmet-async";
2
-
3
- export const Helmet = helmet.Helmet;
4
- export const HelmetData = helmet.HelmetData;
5
- export const HelmetProvider = helmet.HelmetProvider;
@@ -1 +0,0 @@
1
- export * from "lucide-react";
@@ -1,43 +0,0 @@
1
- import { type RouteObject } from "react-router-dom";
2
- import {
3
- DevPortalContext,
4
- type ApiIdentity,
5
- type NavigationCategory,
6
- } from "./DevPortalContext.js";
7
- import { type Combine } from "./types/combine.js";
8
-
9
- export type PluginNavigationCategory = {
10
- path: string;
11
- } & NavigationCategory;
12
-
13
- export type DevPortalPlugin = Combine<
14
- [NavigationPlugin, ApiIdentityPlugin, InitializationPlugin]
15
- >;
16
-
17
- export interface NavigationPlugin {
18
- getRoutes: () => RouteObject[];
19
- getNavigation?: (path: string) => Promise<PluginNavigationCategory[]>;
20
- }
21
-
22
- export interface ApiIdentityPlugin {
23
- getIdentities: (context: DevPortalContext) => Promise<ApiIdentity[]>;
24
- }
25
-
26
- export interface InitializationPlugin {
27
- initialize: (context: DevPortalContext) => Promise<void> | void;
28
- }
29
-
30
- export const isNavigationPlugin = (
31
- obj: DevPortalPlugin,
32
- ): obj is NavigationPlugin =>
33
- "getRoutes" in obj && typeof obj.getRoutes === "function";
34
-
35
- export const needsInitialization = (
36
- obj: DevPortalPlugin,
37
- ): obj is InitializationPlugin =>
38
- "initialize" in obj && typeof obj.initialize === "function";
39
-
40
- export const isApiKeyPlugin = (
41
- obj: DevPortalPlugin,
42
- ): obj is ApiIdentityPlugin =>
43
- "getIdentities" in obj && typeof obj.getIdentities === "function";
@@ -1 +0,0 @@
1
- export * from "react-router-dom";
@@ -1,16 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
3
- k: infer I,
4
- ) => void
5
- ? I
6
- : never;
7
-
8
- type AnyCombination<T, U = T> = T extends any
9
- ? U extends any
10
- ? T | (T & U)
11
- : never
12
- : never;
13
-
14
- export type Combine<T extends any[]> =
15
- | UnionToIntersection<T[number]>
16
- | AnyCombination<T[number]>;
@@ -1,422 +0,0 @@
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 });
@@ -1,10 +0,0 @@
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
- });