zudoku 0.0.0-z7b86faab → 0.0.0-z8ac421f0

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 (321) hide show
  1. package/dist/app/main.js +1 -1
  2. package/dist/app/main.js.map +1 -1
  3. package/dist/config/create-plugin.d.ts +2 -0
  4. package/dist/config/create-plugin.js +55 -0
  5. package/dist/config/create-plugin.js.map +1 -0
  6. package/dist/config/loader.js +2 -2
  7. package/dist/config/loader.js.map +1 -1
  8. package/dist/config/validators/InputNavigationSchema.d.ts +174 -124
  9. package/dist/config/validators/InputNavigationSchema.js +17 -0
  10. package/dist/config/validators/InputNavigationSchema.js.map +1 -1
  11. package/dist/config/validators/NavigationSchema.d.ts +10 -2
  12. package/dist/config/validators/NavigationSchema.js +7 -0
  13. package/dist/config/validators/NavigationSchema.js.map +1 -1
  14. package/dist/config/validators/ProtectedRoutesSchema.d.ts +1 -1
  15. package/dist/config/validators/validate.d.ts +6 -5
  16. package/dist/config/validators/validate.js +2 -0
  17. package/dist/config/validators/validate.js.map +1 -1
  18. package/dist/flat-config.d.ts +36 -24
  19. package/dist/index.d.ts +2 -1
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/components/Bootstrap.js +1 -2
  23. package/dist/lib/components/Bootstrap.js.map +1 -1
  24. package/dist/lib/components/Heading.d.ts +1 -1
  25. package/dist/lib/components/MobileTopNavigation.js +2 -1
  26. package/dist/lib/components/MobileTopNavigation.js.map +1 -1
  27. package/dist/lib/components/Slot.test.js +1 -1
  28. package/dist/lib/components/Slot.test.js.map +1 -1
  29. package/dist/lib/components/TopNavigation.d.ts +7 -1
  30. package/dist/lib/components/TopNavigation.js +7 -2
  31. package/dist/lib/components/TopNavigation.js.map +1 -1
  32. package/dist/lib/components/Zudoku.d.ts +4 -1
  33. package/dist/lib/components/Zudoku.js +4 -7
  34. package/dist/lib/components/Zudoku.js.map +1 -1
  35. package/dist/lib/components/context/ZudokuContext.d.ts +9 -4
  36. package/dist/lib/components/context/ZudokuContext.js +4 -2
  37. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  38. package/dist/lib/components/context/ZudokuProvider.js +1 -1
  39. package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
  40. package/dist/lib/components/context/ZudokuReactContext.d.ts +11 -0
  41. package/dist/lib/components/context/ZudokuReactContext.js +4 -0
  42. package/dist/lib/components/context/ZudokuReactContext.js.map +1 -0
  43. package/dist/lib/components/index.d.ts +18 -74
  44. package/dist/lib/components/index.js +19 -36
  45. package/dist/lib/components/index.js.map +1 -1
  46. package/dist/lib/components/navigation/Navigation.js +4 -3
  47. package/dist/lib/components/navigation/Navigation.js.map +1 -1
  48. package/dist/lib/components/navigation/NavigationCategory.js +8 -0
  49. package/dist/lib/components/navigation/NavigationCategory.js.map +1 -1
  50. package/dist/lib/components/navigation/NavigationFilterContext.d.ts +8 -0
  51. package/dist/lib/components/navigation/NavigationFilterContext.js +12 -0
  52. package/dist/lib/components/navigation/NavigationFilterContext.js.map +1 -0
  53. package/dist/lib/components/navigation/NavigationFilterInput.d.ts +3 -0
  54. package/dist/lib/components/navigation/NavigationFilterInput.js +9 -0
  55. package/dist/lib/components/navigation/NavigationFilterInput.js.map +1 -0
  56. package/dist/lib/components/navigation/NavigationItem.js +11 -1
  57. package/dist/lib/components/navigation/NavigationItem.js.map +1 -1
  58. package/dist/lib/components/navigation/utils.d.ts +2 -1
  59. package/dist/lib/components/navigation/utils.js +22 -1
  60. package/dist/lib/components/navigation/utils.js.map +1 -1
  61. package/dist/lib/core/ZudokuContext.d.ts +2 -1
  62. package/dist/lib/core/ZudokuContext.js +3 -1
  63. package/dist/lib/core/ZudokuContext.js.map +1 -1
  64. package/dist/lib/core/__internal.d.ts +1 -0
  65. package/dist/lib/core/__internal.js +2 -0
  66. package/dist/lib/core/__internal.js.map +1 -1
  67. package/dist/lib/core/plugins.d.ts +5 -1
  68. package/dist/lib/core/plugins.js.map +1 -1
  69. package/dist/lib/core/transform-config.d.ts +4 -2
  70. package/dist/lib/core/transform-config.js +33 -13
  71. package/dist/lib/core/transform-config.js.map +1 -1
  72. package/dist/lib/core/transform-config.test.d.ts +1 -0
  73. package/dist/lib/core/transform-config.test.js +83 -0
  74. package/dist/lib/core/transform-config.test.js.map +1 -0
  75. package/dist/lib/errors/ErrorAlert.js +1 -2
  76. package/dist/lib/errors/ErrorAlert.js.map +1 -1
  77. package/dist/lib/hooks/index.d.ts +7 -30
  78. package/dist/lib/hooks/index.js +7 -15
  79. package/dist/lib/hooks/index.js.map +1 -1
  80. package/dist/lib/hooks/useEvent.test.js +1 -1
  81. package/dist/lib/hooks/useEvent.test.js.map +1 -1
  82. package/dist/lib/oas/graphql/circular.d.ts +1 -1
  83. package/dist/lib/oas/graphql/circular.js +18 -35
  84. package/dist/lib/oas/graphql/circular.js.map +1 -1
  85. package/dist/lib/oas/graphql/circular.test.js +33 -2
  86. package/dist/lib/oas/graphql/circular.test.js.map +1 -1
  87. package/dist/lib/oas/parser/index.js +14 -5
  88. package/dist/lib/oas/parser/index.js.map +1 -1
  89. package/dist/lib/plugins/openapi/ParamInfos.js +8 -5
  90. package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -1
  91. package/dist/lib/plugins/openapi/ParameterListItem.js +1 -1
  92. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  93. package/dist/lib/plugins/openapi/playground/fileUtils.d.ts +1 -0
  94. package/dist/lib/plugins/openapi/playground/fileUtils.js +3 -0
  95. package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -1
  96. package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.d.ts +6 -0
  97. package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.js +20 -0
  98. package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.js.map +1 -0
  99. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +7 -2
  100. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
  101. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js +2 -2
  102. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js.map +1 -1
  103. package/dist/lib/ui/Alert.d.ts +3 -2
  104. package/dist/lib/ui/Alert.js +9 -5
  105. package/dist/lib/ui/Alert.js.map +1 -1
  106. package/dist/lib/ui/InputGroup.d.ts +16 -0
  107. package/dist/lib/ui/InputGroup.js +65 -0
  108. package/dist/lib/ui/InputGroup.js.map +1 -0
  109. package/dist/lib/ui/Secret.js +2 -2
  110. package/dist/lib/ui/Secret.js.map +1 -1
  111. package/dist/lib/util/flattenAllOf.d.ts +0 -2
  112. package/dist/lib/util/flattenAllOf.js +6 -46
  113. package/dist/lib/util/flattenAllOf.js.map +1 -1
  114. package/dist/lib/util/flattenAllOf.test.js +28 -1
  115. package/dist/lib/util/flattenAllOf.test.js.map +1 -1
  116. package/dist/lib/util/flattenAllOfProcessor.d.ts +2 -0
  117. package/dist/lib/util/flattenAllOfProcessor.js +48 -0
  118. package/dist/lib/util/flattenAllOfProcessor.js.map +1 -0
  119. package/dist/lib/util/readFrontmatter.js +2 -1
  120. package/dist/lib/util/readFrontmatter.js.map +1 -1
  121. package/dist/vite/api/SchemaManager.js +1 -1
  122. package/dist/vite/api/SchemaManager.js.map +1 -1
  123. package/dist/vite/api/SchemaManager.test.js +1 -1
  124. package/dist/vite/api/SchemaManager.test.js.map +1 -1
  125. package/dist/vite/build.js +91 -73
  126. package/dist/vite/build.js.map +1 -1
  127. package/dist/vite/config.js +5 -2
  128. package/dist/vite/config.js.map +1 -1
  129. package/dist/vite/mdx/remark-inject-filepath.js +5 -1
  130. package/dist/vite/mdx/remark-inject-filepath.js.map +1 -1
  131. package/dist/vite/mdx/remark-link-rewrite.js +3 -2
  132. package/dist/vite/mdx/remark-link-rewrite.js.map +1 -1
  133. package/dist/vite/plugin-config.js +16 -4
  134. package/dist/vite/plugin-config.js.map +1 -1
  135. package/dist/vite/plugin-docs.js +9 -7
  136. package/dist/vite/plugin-docs.js.map +1 -1
  137. package/dist/vite/plugin-markdown-export.js +4 -2
  138. package/dist/vite/plugin-markdown-export.js.map +1 -1
  139. package/dist/vite/plugin-theme.js +2 -1
  140. package/dist/vite/plugin-theme.js.map +1 -1
  141. package/dist/vite/prerender/prerender.js +3 -1
  142. package/dist/vite/prerender/prerender.js.map +1 -1
  143. package/dist/vite/prerender/worker.js +3 -1
  144. package/dist/vite/prerender/worker.js.map +1 -1
  145. package/lib/{ClaudeLogo-DJ9bU-sO.js → ClaudeLogo-Br8C_vTq.js} +26 -22
  146. package/lib/{ClaudeLogo-DJ9bU-sO.js.map → ClaudeLogo-Br8C_vTq.js.map} +1 -1
  147. package/lib/Drawer-Ch7927PF.js.map +1 -1
  148. package/lib/{HydrationBoundary-CNF2ZV3E.js → HydrationBoundary-CJu4vUlG.js} +6 -6
  149. package/lib/{HydrationBoundary-CNF2ZV3E.js.map → HydrationBoundary-CJu4vUlG.js.map} +1 -1
  150. package/lib/{MdxPage-stpAoBtx.js → MdxPage-C0QFAsgv.js} +8 -8
  151. package/lib/{MdxPage-stpAoBtx.js.map → MdxPage-C0QFAsgv.js.map} +1 -1
  152. package/lib/Mermaid-Chx5BPHn.js +104 -0
  153. package/lib/Mermaid-Chx5BPHn.js.map +1 -0
  154. package/lib/{OAuthErrorPage-DJ811Bn_.js → OAuthErrorPage-CFz_gBFx.js} +22 -19
  155. package/lib/{OAuthErrorPage-DJ811Bn_.js.map → OAuthErrorPage-CFz_gBFx.js.map} +1 -1
  156. package/lib/{OasProvider-CS_ASmBB.js → OasProvider-BwIOIlky.js} +3 -3
  157. package/lib/{OasProvider-CS_ASmBB.js.map → OasProvider-BwIOIlky.js.map} +1 -1
  158. package/lib/OperationList-DYRzbPJu.js +5908 -0
  159. package/lib/OperationList-DYRzbPJu.js.map +1 -0
  160. package/lib/{RouteGuard--A04ESy8.js → RouteGuard-CVs3yvEs.js} +5 -5
  161. package/lib/{RouteGuard--A04ESy8.js.map → RouteGuard-CVs3yvEs.js.map} +1 -1
  162. package/lib/{SchemaList-BJZJv1gD.js → SchemaList-D4FEyoDV.js} +8 -8
  163. package/lib/{SchemaList-BJZJv1gD.js.map → SchemaList-D4FEyoDV.js.map} +1 -1
  164. package/lib/{SchemaView-U4JMYB3N.js → SchemaView-ScvkhsYE.js} +116 -110
  165. package/lib/SchemaView-ScvkhsYE.js.map +1 -0
  166. package/lib/{Secret-BDBqq4p3.js → Secret-DUpgv4V3.js} +92 -72
  167. package/lib/Secret-DUpgv4V3.js.map +1 -0
  168. package/lib/{SignUp-DCBViNUi.js → SignUp-Dug1jAGC.js} +31 -26
  169. package/lib/{SignUp-DCBViNUi.js.map → SignUp-Dug1jAGC.js.map} +1 -1
  170. package/lib/{SyntaxHighlight-Dshjn3Zf.js → SyntaxHighlight-BMu0b_hF.js} +9 -9
  171. package/lib/{SyntaxHighlight-Dshjn3Zf.js.map → SyntaxHighlight-BMu0b_hF.js.map} +1 -1
  172. package/lib/{Toc-Cgz6CPiE.js → Toc-BiJ2YL0O.js} +2 -2
  173. package/lib/{Toc-Cgz6CPiE.js.map → Toc-BiJ2YL0O.js.map} +1 -1
  174. package/lib/{index-CL8eDnQW.js → Zudoku-iyiXgWFY.js} +2996 -2859
  175. package/lib/Zudoku-iyiXgWFY.js.map +1 -0
  176. package/lib/ZudokuContext-CYyb_PB_.js +175 -0
  177. package/lib/ZudokuContext-CYyb_PB_.js.map +1 -0
  178. package/lib/ZudokuReactContext-DGJAP1sN.js +222 -0
  179. package/lib/ZudokuReactContext-DGJAP1sN.js.map +1 -0
  180. package/lib/chunk-EPOLDU6W-C6C8jAwd.js.map +1 -1
  181. package/lib/{circular-BmMJjG1v.js → circular-BOpxmAie.js} +1327 -1346
  182. package/lib/{circular-BmMJjG1v.js.map → circular-BOpxmAie.js.map} +1 -1
  183. package/lib/createServer-BunbJzB5.js +13038 -0
  184. package/lib/createServer-BunbJzB5.js.map +1 -0
  185. package/lib/{errors-b9I-fAOY.js → errors-B77S9iOc.js} +3 -3
  186. package/lib/{errors-b9I-fAOY.js.map → errors-B77S9iOc.js.map} +1 -1
  187. package/lib/{firebase-BCXX7Qv5.js → firebase-C7XKRGLf.js} +26 -25
  188. package/lib/{firebase-BCXX7Qv5.js.map → firebase-C7XKRGLf.js.map} +1 -1
  189. package/lib/{hook-BGlHBdET.js → hook-Dz_n9SoE.js} +16 -15
  190. package/lib/{hook-BGlHBdET.js.map → hook-Dz_n9SoE.js.map} +1 -1
  191. package/lib/{index-UOLtazB8.js → index-BDp2MTiq.js} +2 -2
  192. package/lib/{index-UOLtazB8.js.map → index-BDp2MTiq.js.map} +1 -1
  193. package/lib/{index-O9RHI87z.js → index-Bx29qHVi.js} +589 -551
  194. package/lib/index-Bx29qHVi.js.map +1 -0
  195. package/lib/index-CrcNWbel.js.map +1 -1
  196. package/lib/index-DAWHN3cH.js +86 -0
  197. package/lib/index-DAWHN3cH.js.map +1 -0
  198. package/lib/index.esm-BYObtETB.js.map +1 -1
  199. package/lib/{index.esm-B_0dvNjB.js → index.esm-Ca5zvoff.js} +20 -20
  200. package/lib/{index.esm-B_0dvNjB.js.map → index.esm-Ca5zvoff.js.map} +1 -1
  201. package/lib/{index.esm-C5CBsVzN.js → index.esm-Cth49JBv.js} +2 -2
  202. package/lib/index.esm-Cth49JBv.js.map +1 -0
  203. package/lib/{invariant-BJAl77rw.js → invariant-B_t_F2s_.js} +3 -3
  204. package/lib/{invariant-BJAl77rw.js.map → invariant-B_t_F2s_.js.map} +1 -1
  205. package/lib/jsx-runtime-BzflLqGi.js.map +1 -1
  206. package/lib/{mutation-BISOc7OM.js → mutation-B7eFBLZY.js} +2 -2
  207. package/lib/{mutation-BISOc7OM.js.map → mutation-B7eFBLZY.js.map} +1 -1
  208. package/lib/ui/Alert.js +32 -20
  209. package/lib/ui/Alert.js.map +1 -1
  210. package/lib/ui/Carousel.js.map +1 -1
  211. package/lib/ui/InputGroup.js +155 -0
  212. package/lib/ui/InputGroup.js.map +1 -0
  213. package/lib/ui/Secret.js +2 -2
  214. package/lib/ui/Secret.js.map +1 -1
  215. package/lib/ui/SyntaxHighlight.js +3 -3
  216. package/lib/useExposedProps-CzTDfXfq.js +30 -0
  217. package/lib/useExposedProps-CzTDfXfq.js.map +1 -0
  218. package/lib/{useMutation-CFMGlAMW.js → useMutation-CErliDZ9.js} +5 -5
  219. package/lib/{useMutation-CFMGlAMW.js.map → useMutation-CErliDZ9.js.map} +1 -1
  220. package/lib/{useSuspenseQuery-CSB_rVek.js → useQuery-ht7aWJ3S.js} +432 -446
  221. package/lib/useQuery-ht7aWJ3S.js.map +1 -0
  222. package/lib/useSuspenseQuery-DQH4Bmc2.js +18 -0
  223. package/lib/useSuspenseQuery-DQH4Bmc2.js.map +1 -0
  224. package/lib/zudoku.__internal.js +1519 -1033
  225. package/lib/zudoku.__internal.js.map +1 -1
  226. package/lib/zudoku.auth-auth0.js +6 -5
  227. package/lib/zudoku.auth-auth0.js.map +1 -1
  228. package/lib/zudoku.auth-azureb2c.js +14 -13
  229. package/lib/zudoku.auth-azureb2c.js.map +1 -1
  230. package/lib/zudoku.auth-clerk.js +2 -2
  231. package/lib/zudoku.auth-firebase.js +5 -5
  232. package/lib/zudoku.auth-openid.js +8 -7
  233. package/lib/zudoku.auth-openid.js.map +1 -1
  234. package/lib/zudoku.auth-supabase.js +4 -4
  235. package/lib/zudoku.components.js +31 -29
  236. package/lib/zudoku.components.js.map +1 -1
  237. package/lib/zudoku.hooks.js +24 -11
  238. package/lib/zudoku.hooks.js.map +1 -1
  239. package/lib/zudoku.mermaid.js +5 -4
  240. package/lib/zudoku.mermaid.js.map +1 -1
  241. package/lib/zudoku.plugin-api-catalog.js +41 -36
  242. package/lib/zudoku.plugin-api-catalog.js.map +1 -1
  243. package/lib/zudoku.plugin-api-keys.js +156 -153
  244. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  245. package/lib/zudoku.plugin-custom-pages.js +1 -1
  246. package/lib/zudoku.plugin-markdown.js +1 -1
  247. package/lib/zudoku.plugin-openapi.js +2 -2
  248. package/lib/zudoku.plugin-search-pagefind.js +19 -18
  249. package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
  250. package/lib/zudoku.plugins.js.map +1 -1
  251. package/lib/zudoku.react-query.js +26 -25
  252. package/lib/zudoku.react-query.js.map +1 -1
  253. package/lib/zudoku.router.js.map +1 -1
  254. package/package.json +17 -10
  255. package/src/app/defaultTheme.css +4 -0
  256. package/src/app/main.css +2 -0
  257. package/src/app/main.tsx +1 -1
  258. package/src/lib/components/Bootstrap.tsx +1 -4
  259. package/src/lib/components/MobileTopNavigation.tsx +13 -8
  260. package/src/lib/components/Slot.test.tsx +1 -1
  261. package/src/lib/components/TopNavigation.tsx +25 -7
  262. package/src/lib/components/Zudoku.tsx +18 -14
  263. package/src/lib/components/context/ZudokuContext.ts +3 -6
  264. package/src/lib/components/context/ZudokuProvider.tsx +1 -1
  265. package/src/lib/components/context/ZudokuReactContext.tsx +17 -0
  266. package/src/lib/components/index.ts +19 -39
  267. package/src/lib/components/navigation/Navigation.tsx +4 -3
  268. package/src/lib/components/navigation/NavigationCategory.tsx +9 -0
  269. package/src/lib/components/navigation/NavigationFilterContext.tsx +28 -0
  270. package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -0
  271. package/src/lib/components/navigation/NavigationItem.tsx +17 -1
  272. package/src/lib/components/navigation/utils.ts +32 -1
  273. package/src/lib/core/ZudokuContext.ts +7 -1
  274. package/src/lib/core/__internal.tsx +2 -0
  275. package/src/lib/core/plugins.ts +7 -3
  276. package/src/lib/core/transform-config.test.tsx +99 -0
  277. package/src/lib/core/transform-config.ts +57 -19
  278. package/src/lib/errors/ErrorAlert.tsx +1 -6
  279. package/src/lib/hooks/index.ts +7 -16
  280. package/src/lib/hooks/useEvent.test.tsx +1 -1
  281. package/src/lib/oas/graphql/circular.test.ts +37 -2
  282. package/src/lib/oas/graphql/circular.ts +25 -51
  283. package/src/lib/oas/parser/index.ts +17 -6
  284. package/src/lib/plugins/openapi/ParamInfos.tsx +10 -5
  285. package/src/lib/plugins/openapi/ParameterListItem.tsx +1 -0
  286. package/src/lib/plugins/openapi/playground/fileUtils.ts +4 -0
  287. package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -0
  288. package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +33 -17
  289. package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +2 -0
  290. package/src/lib/ui/Alert.tsx +17 -5
  291. package/src/lib/ui/InputGroup.tsx +168 -0
  292. package/src/lib/ui/Secret.tsx +2 -2
  293. package/src/lib/util/flattenAllOf.test.ts +34 -1
  294. package/src/lib/util/flattenAllOf.ts +7 -57
  295. package/src/lib/util/flattenAllOfProcessor.ts +58 -0
  296. package/src/lib/util/readFrontmatter.ts +2 -1
  297. package/src/zuplo/enrich-with-zuplo-mcp.ts +168 -0
  298. package/src/zuplo/enrich-with-zuplo.ts +254 -0
  299. package/src/zuplo/policy-types.ts +46 -0
  300. package/src/zuplo/with-zuplo-processors.ts +35 -0
  301. package/src/zuplo/with-zuplo.ts +14 -0
  302. package/lib/Mermaid-Koc3z8mU.js +0 -102
  303. package/lib/Mermaid-Koc3z8mU.js.map +0 -1
  304. package/lib/OperationList-Dq_AB4W9.js +0 -5820
  305. package/lib/OperationList-Dq_AB4W9.js.map +0 -1
  306. package/lib/SchemaView-U4JMYB3N.js.map +0 -1
  307. package/lib/Secret-BDBqq4p3.js.map +0 -1
  308. package/lib/Separator-BXt1LYnm.js +0 -27
  309. package/lib/Separator-BXt1LYnm.js.map +0 -1
  310. package/lib/ZudokuContext-BZB1TWdT.js +0 -387
  311. package/lib/ZudokuContext-BZB1TWdT.js.map +0 -1
  312. package/lib/___vite-browser-external_commonjs-proxy-BttVsNON.js +0 -9
  313. package/lib/___vite-browser-external_commonjs-proxy-BttVsNON.js.map +0 -1
  314. package/lib/createServer-CLSZ7hWJ.js +0 -16693
  315. package/lib/createServer-CLSZ7hWJ.js.map +0 -1
  316. package/lib/index-CL8eDnQW.js.map +0 -1
  317. package/lib/index-DBjOT2H1.js +0 -133
  318. package/lib/index-DBjOT2H1.js.map +0 -1
  319. package/lib/index-O9RHI87z.js.map +0 -1
  320. package/lib/index.esm-C5CBsVzN.js.map +0 -1
  321. package/lib/useSuspenseQuery-CSB_rVek.js.map +0 -1
@@ -0,0 +1,168 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import type {
4
+ ExtensionMcpServer,
5
+ ExtensionMcpServerTool,
6
+ } from "@zuplo/mcp/openapi/types";
7
+ import {
8
+ DEFAULT_MCP_SERVER_NAME,
9
+ DEFAULT_MCP_SERVER_VERSION,
10
+ } from "@zuplo/mcp/server";
11
+ import type { OpenAPIV3_1 } from "openapi-types";
12
+ import type { ProcessorArg } from "../config/validators/BuildSchema.js";
13
+ import { traverse, traverseAsync } from "../lib/util/traverse.js";
14
+ import type { RecordAny } from "../lib/util/types.js";
15
+ import { operations } from "./enrich-with-zuplo.js";
16
+
17
+ // extracts x-mcp-server metadata from the operation using x-zuplo-mcp-tool
18
+ // as a first class citizen.
19
+ const extractOperationSchema = (
20
+ operation: OpenAPIV3_1.OperationObject & RecordAny,
21
+ ): ExtensionMcpServerTool | null => {
22
+ if (!operation.operationId) return null;
23
+
24
+ // Check if tool is explicitly disabled
25
+ const mcpToolConfig = operation["x-zuplo-mcp-tool"];
26
+ if (mcpToolConfig?.enabled === false) {
27
+ return null;
28
+ }
29
+
30
+ const tool: ExtensionMcpServerTool = {
31
+ // Use custom name from x-zuplo-mcp-tool or fallback to operationId
32
+ name: mcpToolConfig?.name || operation.operationId,
33
+
34
+ // Use custom description from x-zuplo-mcp-tool or fallback
35
+ // to operation description
36
+ description:
37
+ mcpToolConfig?.description ||
38
+ operation.summary ||
39
+ operation.description ||
40
+ `Operation ${operation.operationId}`,
41
+ };
42
+
43
+ // Grab valid request body JSON schema for the tool
44
+ const requestBody = operation.requestBody as
45
+ | OpenAPIV3_1.RequestBodyObject
46
+ | undefined;
47
+
48
+ const schema = requestBody?.content?.["application/json"]?.schema;
49
+ if (schema && typeof schema === "object") {
50
+ // TODO: @jpmcb - Zuplo also supports in-path parameters and query parameters
51
+ // as MCP "inputSchema" arguments. In order to document full argument params,
52
+ // Zudoku will need to more intelligently parse these elements of an operation.
53
+ tool.inputSchema = { body: schema };
54
+ }
55
+
56
+ return tool;
57
+ };
58
+
59
+ // Builds a lookup map of operationId -> operation for efficient access
60
+ const buildOperationLookup = (
61
+ document: OpenAPIV3_1.Document,
62
+ ): Map<string, OpenAPIV3_1.OperationObject> => {
63
+ const operationMap = new Map<string, OpenAPIV3_1.OperationObject>();
64
+
65
+ traverse(document, (node, path) => {
66
+ // Check if we're at a path item level (paths -> /some/path -> method)
67
+ // and validate it's in allowed operations
68
+ if (
69
+ !path ||
70
+ path.length < 2 ||
71
+ path[0] !== "paths" ||
72
+ !operations.includes(path[path.length - 1] as string)
73
+ ) {
74
+ return node;
75
+ }
76
+
77
+ if (node.operationId) {
78
+ operationMap.set(node.operationId, node);
79
+ }
80
+
81
+ return node;
82
+ });
83
+
84
+ return operationMap;
85
+ };
86
+
87
+ // Takes an OpenAPI document and returns the x-mcp-server tools list defined
88
+ // by an MCP server's options.files[x].operationIds array.
89
+ const findOperationsInDocument = (
90
+ document: OpenAPIV3_1.Document,
91
+ operationIds: string[],
92
+ ): ExtensionMcpServerTool[] => {
93
+ const tools: ExtensionMcpServerTool[] = [];
94
+ const operationLookup = buildOperationLookup(document);
95
+
96
+ operationIds.forEach((operationId) => {
97
+ const operation = operationLookup.get(operationId);
98
+ if (operation) {
99
+ const tool = extractOperationSchema(operation);
100
+ if (tool) {
101
+ tools.push(tool);
102
+ }
103
+ }
104
+ });
105
+
106
+ return tools;
107
+ };
108
+
109
+ // Enriches an OpenAPI schema with x-mcp-server data based on the Zuplo MCP server handler
110
+ export const enrichWithZuploMcpServerData = ({
111
+ rootDir,
112
+ }: {
113
+ rootDir: string;
114
+ }) => {
115
+ return async ({ schema }: ProcessorArg) => {
116
+ if (!schema.paths) return schema;
117
+ const modifiedSchema = { ...schema };
118
+ if (!modifiedSchema?.paths) return modifiedSchema;
119
+
120
+ await traverseAsync(modifiedSchema, async (node, nodePath) => {
121
+ // Check if we're at a "post" operation (paths -> /some/path -> "post").
122
+ // HTTP MCP servers are only allow post operations.
123
+ if (!nodePath || nodePath.length !== 3 || nodePath[2] !== "post") {
124
+ return node;
125
+ }
126
+
127
+ const operation = node as RecordAny;
128
+ if (!operation?.["x-zuplo-route"]) return node;
129
+
130
+ const handler = operation["x-zuplo-route"]?.handler;
131
+ if (handler?.export !== "mcpServerHandler" || !handler.options?.files)
132
+ return node;
133
+
134
+ const tools: ExtensionMcpServerTool[] = [];
135
+
136
+ for (const fileConfig of handler.options.files) {
137
+ if (!fileConfig.path || !fileConfig.operationIds) continue;
138
+
139
+ const resolvedPath = path.resolve(rootDir, "../", fileConfig.path);
140
+ const fileContent = await fs.readFile(resolvedPath, "utf-8");
141
+ const document = JSON.parse(fileContent);
142
+
143
+ if (document) {
144
+ const fileTools = findOperationsInDocument(
145
+ document,
146
+ fileConfig.operationIds,
147
+ );
148
+
149
+ tools.push(...fileTools);
150
+ }
151
+ }
152
+
153
+ const mcpExtension: ExtensionMcpServer = {
154
+ name: DEFAULT_MCP_SERVER_NAME,
155
+ version: DEFAULT_MCP_SERVER_VERSION,
156
+ };
157
+
158
+ if (tools.length > 0) {
159
+ mcpExtension.tools = tools;
160
+ }
161
+
162
+ node["x-mcp-server"] = mcpExtension;
163
+ return node;
164
+ });
165
+
166
+ return modifiedSchema;
167
+ };
168
+ };
@@ -0,0 +1,254 @@
1
+ import type { OpenAPIV3_1 } from "openapi-types";
2
+ import type { ProcessorArg } from "../config/validators/BuildSchema.js";
3
+ import { objectEntries } from "../lib/util/objectEntries.js";
4
+ import type { RecordAny } from "../lib/util/traverse.js";
5
+ import type {
6
+ PoliciesConfigFile,
7
+ PolicyConfigurationFragment,
8
+ } from "./policy-types.js";
9
+
10
+ const API_KEY_REPLACEMENT_STRING = "YOUR_KEY_HERE";
11
+
12
+ const enrichWithApiKeyData = (
13
+ operationObject: RecordAny,
14
+ apiKeyPolicies: PolicyConfigurationFragment[],
15
+ ) => {
16
+ if (apiKeyPolicies.length === 0) {
17
+ return operationObject;
18
+ }
19
+
20
+ const firstPolicy = apiKeyPolicies[0];
21
+ const authorizationHeader =
22
+ (firstPolicy?.handler.options?.authHeader as string) || "Authorization";
23
+ const authorizationScheme = (firstPolicy?.handler.options?.authScheme ??
24
+ "Bearer") as string;
25
+ const authSchemeExample =
26
+ authorizationScheme !== ""
27
+ ? `${authorizationScheme} ${API_KEY_REPLACEMENT_STRING}`
28
+ : API_KEY_REPLACEMENT_STRING;
29
+
30
+ // Add API key header parameter
31
+ const apiKeyHeader: OpenAPIV3_1.ParameterObject = {
32
+ name: authorizationHeader,
33
+ in: "header",
34
+ required: true,
35
+ example: authSchemeExample,
36
+ schema: {
37
+ type: "string",
38
+ },
39
+ description: `The \`${authorizationHeader}\` header is used to authenticate with the API using your API key. Value is of the format \`${authSchemeExample}\`.`,
40
+ };
41
+
42
+ const parameters = operationObject.parameters || [];
43
+ if (
44
+ !parameters.some((param: RecordAny) => param.name === authorizationHeader)
45
+ ) {
46
+ operationObject.parameters = [apiKeyHeader, ...parameters];
47
+ }
48
+
49
+ // Add security scheme and requirement
50
+ const apiSecuritySchemeId = "api_key";
51
+ const apiKeySecurityRequirement = { [apiSecuritySchemeId]: [] };
52
+
53
+ if (!operationObject.security) {
54
+ operationObject.security = [apiKeySecurityRequirement];
55
+ } else if (
56
+ !operationObject.security.some((req: RecordAny) => req[apiSecuritySchemeId])
57
+ ) {
58
+ operationObject.security = [
59
+ apiKeySecurityRequirement,
60
+ ...operationObject.security,
61
+ ];
62
+ }
63
+
64
+ return operationObject;
65
+ };
66
+
67
+ const enrichWithRateLimitData = (
68
+ operationObject: RecordAny,
69
+ rateLimitPolicies: PolicyConfigurationFragment[],
70
+ ) => {
71
+ if (rateLimitPolicies.length === 0) {
72
+ return operationObject;
73
+ }
74
+
75
+ const shouldIncludeHeader = rateLimitPolicies.some(
76
+ (policy) => policy.handler.options?.headerMode !== "none",
77
+ );
78
+
79
+ if (!operationObject.responses) {
80
+ operationObject.responses = {};
81
+ }
82
+
83
+ if (!operationObject.responses["429"]) {
84
+ operationObject.responses["429"] = {
85
+ $ref: shouldIncludeHeader
86
+ ? "#/components/responses/RateLimitWithRetryAfter"
87
+ : "#/components/responses/RateLimitNoRetryAfter",
88
+ };
89
+ }
90
+
91
+ return operationObject;
92
+ };
93
+
94
+ // biome-ignore format: for readability
95
+ export const operations = [
96
+ "get", "put", "post", "delete",
97
+ "options", "head", "patch", "trace",
98
+ ];
99
+
100
+ const rateLimitingResponse: OpenAPIV3_1.ResponseObject = {
101
+ description: "Rate Limiting Response",
102
+ content: {
103
+ "application/json": {
104
+ schema: {
105
+ type: "object",
106
+ required: ["type", "title", "status"],
107
+ examples: [
108
+ {
109
+ type: "https://httpproblems.com/http-status/429",
110
+ title: "Too Many Requests",
111
+ status: 429,
112
+ instance: "/foo/bar",
113
+ },
114
+ ],
115
+ properties: {
116
+ type: {
117
+ type: "string",
118
+ example: "https://httpproblems.com/http-status/429",
119
+ description: "A URI reference that identifies the problem.",
120
+ },
121
+ title: {
122
+ type: "string",
123
+ example: "Too Many Requests",
124
+ description: "A short, human-readable summary of the problem.",
125
+ },
126
+ status: {
127
+ type: "number",
128
+ example: 429,
129
+ description: "The HTTP status code.",
130
+ },
131
+ instance: {
132
+ type: "string",
133
+ example: "/foo/bar",
134
+ },
135
+ },
136
+ },
137
+ },
138
+ },
139
+ };
140
+
141
+ const rateLimitingResponseWithHeader: OpenAPIV3_1.ResponseObject = {
142
+ ...rateLimitingResponse,
143
+ headers: {
144
+ "retry-after": {
145
+ description: "The number of seconds to wait before making a new request.",
146
+ schema: {
147
+ type: "integer",
148
+ example: 60,
149
+ },
150
+ },
151
+ },
152
+ };
153
+
154
+ export const enrichWithZuploData = ({
155
+ policiesConfig,
156
+ }: {
157
+ policiesConfig: PoliciesConfigFile;
158
+ }) => {
159
+ return ({ schema }: ProcessorArg) => {
160
+ if (!schema.paths) return schema;
161
+
162
+ let hasRateLimitPolicies = false;
163
+
164
+ for (const [, pathItem] of objectEntries<RecordAny>(schema.paths)) {
165
+ for (const method of operations) {
166
+ const operation = pathItem[method];
167
+ if (!operation?.["x-zuplo-route"]) continue;
168
+
169
+ const inboundPolicies = operation[
170
+ "x-zuplo-route"
171
+ ]?.policies?.inbound?.reduce((acc: string[], policyName: string) => {
172
+ const policy = policiesConfig.policies?.find(
173
+ ({ name }) => name === policyName,
174
+ );
175
+ if (!policy) return acc;
176
+
177
+ // Handle composite policies
178
+ if (policy.handler.export === "CompositeInboundPolicy") {
179
+ const childPolicies = policy.handler.options?.policies as
180
+ | string[]
181
+ | undefined;
182
+ return childPolicies ? [...acc, ...childPolicies] : acc;
183
+ }
184
+
185
+ return [...acc, policyName];
186
+ }, []);
187
+
188
+ if (!inboundPolicies) continue;
189
+
190
+ // Find API key policies
191
+ const apiKeyPolicies =
192
+ policiesConfig.policies?.filter(
193
+ (policy) =>
194
+ inboundPolicies.includes(policy.name) &&
195
+ (policy.handler.export === "ApiAuthKeyInboundPolicy" ||
196
+ policy.handler.export === "ApiKeyInboundPolicy") &&
197
+ !policy.handler.options
198
+ ?.disableAutomaticallyAddingKeyHeaderToOpenApi,
199
+ ) ?? [];
200
+
201
+ // Find rate limit policies
202
+ const rateLimitPolicies =
203
+ policiesConfig.policies?.filter(
204
+ (policy) =>
205
+ inboundPolicies.includes(policy.name) &&
206
+ (policy.handler.export === "RateLimitInboundPolicy" ||
207
+ policy.handler.export === "ComplexRateLimitInboundPolicy"),
208
+ ) ?? [];
209
+
210
+ if (rateLimitPolicies.length > 0) {
211
+ hasRateLimitPolicies = true;
212
+ }
213
+
214
+ // Apply enrichments directly to the operation
215
+ pathItem[method] = enrichWithApiKeyData(operation, apiKeyPolicies);
216
+ pathItem[method] = enrichWithRateLimitData(
217
+ pathItem[method],
218
+ rateLimitPolicies,
219
+ );
220
+ }
221
+ }
222
+
223
+ // Add security scheme if we have API key policies
224
+ if (
225
+ policiesConfig.policies?.some(
226
+ (policy) =>
227
+ policy.handler.export === "ApiAuthKeyInboundPolicy" ||
228
+ policy.handler.export === "ApiKeyInboundPolicy",
229
+ )
230
+ ) {
231
+ if (!schema.components) schema.components = {};
232
+ if (!schema.components.securitySchemes)
233
+ schema.components.securitySchemes = {};
234
+
235
+ if (!schema.components.securitySchemes.api_key) {
236
+ schema.components.securitySchemes.api_key = {
237
+ type: "http",
238
+ scheme: "bearer",
239
+ };
240
+ }
241
+ }
242
+
243
+ // Add rate limiting responses only if we found rate limiting policies
244
+ if (hasRateLimitPolicies) {
245
+ if (!schema.components) schema.components = {};
246
+ if (!schema.components.responses) schema.components.responses = {};
247
+ schema.components.responses.RateLimitNoRetryAfter = rateLimitingResponse;
248
+ schema.components.responses.RateLimitWithRetryAfter =
249
+ rateLimitingResponseWithHeader;
250
+ }
251
+
252
+ return schema;
253
+ };
254
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * This file was automatically generated by json-schema-to-typescript.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run json-schema-to-typescript to regenerate this file.
5
+ */
6
+
7
+ export interface PoliciesConfigFile {
8
+ policies?: PolicyConfigurationFragment[];
9
+ corsPolicies?: CorsPolicyConfiguration[];
10
+ }
11
+ export interface PolicyConfigurationFragment {
12
+ name: string;
13
+ policyType: string;
14
+ handler: HandlerDefinition;
15
+ options?: {
16
+ [k: string]: unknown;
17
+ };
18
+ }
19
+ export interface HandlerDefinition {
20
+ module: string;
21
+ export: string;
22
+ options?: {
23
+ [k: string]: unknown;
24
+ };
25
+ }
26
+ export interface CorsPolicyConfiguration {
27
+ name: string;
28
+ allowCredentials?: boolean;
29
+ maxAge?: number;
30
+ allowedOrigins: string[] | string;
31
+ allowedMethods?:
32
+ | (
33
+ | "GET"
34
+ | "HEAD"
35
+ | "POST"
36
+ | "PUT"
37
+ | "DELETE"
38
+ | "CONNECT"
39
+ | "OPTIONS"
40
+ | "TRACE"
41
+ | "PATCH"
42
+ )[]
43
+ | string;
44
+ allowedHeaders?: string[] | string;
45
+ exposeHeaders?: string[] | string;
46
+ }
@@ -0,0 +1,35 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { ZuploEnv } from "../app/env.js";
4
+ import type {
5
+ Processor,
6
+ ProcessorArg,
7
+ } from "../config/validators/BuildSchema.js";
8
+ import { removeExtensions } from "../lib/plugins/openapi/processors/removeExtensions.js";
9
+ import { removeParameters } from "../lib/plugins/openapi/processors/removeParameters.js";
10
+ import { removePaths } from "../lib/plugins/openapi/processors/removePaths.js";
11
+ import { enrichWithZuploData } from "./enrich-with-zuplo.js";
12
+ import { enrichWithZuploMcpServerData } from "./enrich-with-zuplo-mcp.js";
13
+
14
+ export const getProcessors = async (rootDir: string): Promise<Processor[]> => {
15
+ const policiesConfig = JSON.parse(
16
+ await fs.readFile(path.join(rootDir, "../config/policies.json"), "utf-8"),
17
+ );
18
+
19
+ return [
20
+ removePaths({ shouldRemove: ({ operation }) => operation["x-internal"] }),
21
+ removeParameters({
22
+ shouldRemove: ({ parameter }) => parameter["x-internal"],
23
+ }),
24
+ enrichWithZuploData({ policiesConfig }),
25
+ enrichWithZuploMcpServerData({ rootDir }),
26
+ ({ schema }: ProcessorArg) => {
27
+ const url = ZuploEnv.serverUrl;
28
+ if (!url) return schema;
29
+ return { ...schema, servers: [{ url }] };
30
+ },
31
+ removeExtensions({ shouldRemove: (key) => key.startsWith("x-zuplo") }),
32
+ ];
33
+ };
34
+
35
+ export default getProcessors;
@@ -0,0 +1,14 @@
1
+ import type { ZudokuConfig } from "../config/validators/validate.js";
2
+
3
+ /**
4
+ * @deprecated `withZuplo` is no longer needed and will automatically be applied. It will be removed in a future version.
5
+ */
6
+ const withZuplo = (config: ZudokuConfig): ZudokuConfig => {
7
+ // biome-ignore lint/suspicious/noConsole: Logging allowed here
8
+ console.warn(
9
+ "`withZuplo` is no longer needed and will automatically be applied. It will be removed in a future version.",
10
+ );
11
+ return config;
12
+ };
13
+
14
+ export default withZuplo;
@@ -1,102 +0,0 @@
1
- import { j as r } from "./jsx-runtime-BzflLqGi.js";
2
- import { e as f } from "./useSuspenseQuery-CSB_rVek.js";
3
- import { useId as p } from "react";
4
- import { c as g } from "./index-DI5SPFK9.js";
5
- import { c as i } from "./cn-5-Gd1Dss.js";
6
- import { a as v } from "./index-DBjOT2H1.js";
7
- import { S as x } from "./Spinner-CI6bRyZw.js";
8
- const h = g(
9
- "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
10
- {
11
- variants: {
12
- variant: {
13
- default: "bg-card text-card-foreground",
14
- destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"
15
- }
16
- },
17
- defaultVariants: {
18
- variant: "default"
19
- }
20
- }
21
- );
22
- function w({
23
- className: e,
24
- variant: t,
25
- ...a
26
- }) {
27
- return /* @__PURE__ */ r.jsx(
28
- "div",
29
- {
30
- "data-slot": "alert",
31
- role: "alert",
32
- className: i(h({ variant: t }), e),
33
- ...a
34
- }
35
- );
36
- }
37
- function y({ className: e, ...t }) {
38
- return /* @__PURE__ */ r.jsx(
39
- "div",
40
- {
41
- "data-slot": "alert-title",
42
- className: i(
43
- "col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
44
- e
45
- ),
46
- ...t
47
- }
48
- );
49
- }
50
- function j({
51
- className: e,
52
- ...t
53
- }) {
54
- return /* @__PURE__ */ r.jsx(
55
- "div",
56
- {
57
- "data-slot": "alert-description",
58
- className: i(
59
- "text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
60
- e
61
- ),
62
- ...t
63
- }
64
- );
65
- }
66
- let s = null;
67
- const b = () => (s || (s = import("mermaid").then((e) => e.default).catch((e) => {
68
- throw new Error(
69
- "Mermaid is not installed. Please install it with: npm install mermaid",
70
- { cause: e }
71
- );
72
- })), s), P = ({ chart: e, config: t, ...a }) => {
73
- const d = p(), n = v(), {
74
- data: m,
75
- error: o,
76
- isPending: c
77
- } = f({
78
- queryKey: ["mermaid", e, t, n.resolvedTheme],
79
- queryFn: async () => {
80
- const l = await b();
81
- l.initialize({
82
- theme: n.resolvedTheme === "dark" ? "dark" : "base",
83
- ...t
84
- });
85
- const { svg: u } = await l.render(d, e);
86
- return u;
87
- },
88
- enabled: typeof window < "u",
89
- retry: !1
90
- });
91
- return o ? /* @__PURE__ */ r.jsxs(w, { className: "flex flex-col gap-2", variant: "destructive", children: [
92
- /* @__PURE__ */ r.jsx(y, { children: "Mermaid Error" }),
93
- /* @__PURE__ */ r.jsx(j, { className: "overflow-auto wrap-break-word whitespace-pre-wrap font-mono text-xs", children: o.message })
94
- ] }) : c ? /* @__PURE__ */ r.jsx(x, {}) : /* @__PURE__ */ r.jsx("div", { ...a, dangerouslySetInnerHTML: { __html: m } });
95
- };
96
- export {
97
- w as A,
98
- P as M,
99
- y as a,
100
- j as b
101
- };
102
- //# sourceMappingURL=Mermaid-Koc3z8mU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Mermaid-Koc3z8mU.js","sources":["../src/lib/ui/Alert.tsx","../src/lib/components/Mermaid.tsx"],"sourcesContent":["import { cva, type VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { cn } from \"../util/cn.js\";\n\nconst alertVariants = cva(\n \"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current\",\n {\n variants: {\n variant: {\n default: \"bg-card text-card-foreground\",\n destructive:\n \"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n\nfunction Alert({\n className,\n variant,\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof alertVariants>) {\n return (\n <div\n data-slot=\"alert\"\n role=\"alert\"\n className={cn(alertVariants({ variant }), className)}\n {...props}\n />\n );\n}\n\nfunction AlertTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-title\"\n className={cn(\n \"col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDescription({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-description\"\n className={cn(\n \"text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Alert, AlertDescription, AlertTitle };\n","import { useQuery } from \"@tanstack/react-query\";\nimport type { MermaidConfig } from \"mermaid\";\nimport type { ComponentProps } from \"react\";\nimport { useId } from \"react\";\nimport { Alert, AlertDescription, AlertTitle } from \"zudoku/ui/Alert.js\";\nimport { useTheme } from \"../hooks/index.js\";\nimport { Spinner } from \"./Spinner.js\";\n\nexport type MermaidProps = {\n chart: string;\n config?: MermaidConfig;\n} & ComponentProps<\"div\">;\n\nlet mermaidPromise: Promise<typeof import(\"mermaid\").default> | null = null;\n\nconst loadMermaid = () => {\n if (!mermaidPromise) {\n mermaidPromise = import(\"mermaid\")\n .then((mod) => mod.default)\n .catch((error) => {\n throw new Error(\n \"Mermaid is not installed. Please install it with: npm install mermaid\",\n { cause: error },\n );\n });\n }\n return mermaidPromise;\n};\n\nexport const Mermaid = ({ chart, config, ...props }: MermaidProps) => {\n const id = useId();\n const theme = useTheme();\n\n const {\n data: svg,\n error,\n isPending,\n } = useQuery({\n queryKey: [\"mermaid\", chart, config, theme.resolvedTheme],\n queryFn: async () => {\n const mermaid = await loadMermaid();\n mermaid.initialize({\n theme: theme.resolvedTheme === \"dark\" ? \"dark\" : \"base\",\n ...config,\n });\n\n const { svg } = await mermaid.render(id, chart);\n return svg;\n },\n enabled: typeof window !== \"undefined\",\n retry: false,\n });\n\n if (error)\n return (\n <Alert className=\"flex flex-col gap-2\" variant=\"destructive\">\n <AlertTitle>Mermaid Error</AlertTitle>\n <AlertDescription className=\"overflow-auto wrap-break-word whitespace-pre-wrap font-mono text-xs\">\n {error.message}\n </AlertDescription>\n </Alert>\n );\n\n if (isPending) return <Spinner />;\n\n // biome-ignore lint/security/noDangerouslySetInnerHtml: Mermaid generates valid SVG\n return <div {...props} dangerouslySetInnerHTML={{ __html: svg }} />;\n};\n"],"names":["alertVariants","cva","Alert","className","variant","props","jsx","cn","AlertTitle","AlertDescription","mermaidPromise","loadMermaid","mod","error","Mermaid","chart","config","id","useId","theme","useTheme","svg","isPending","useQuery","mermaid","jsxs","Spinner"],"mappings":";;;;;;;AAIA,MAAMA,IAAgBC;AAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,aACE;AAAA,MAAA;AAAA,IACJ;AAAA,IAEF,iBAAiB;AAAA,MACf,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ;AAEA,SAASC,EAAM;AAAA,EACb,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,GAAGC;AACL,GAAqE;AACnE,SACEC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,MAAK;AAAA,MACL,WAAWC,EAAGP,EAAc,EAAE,SAAAI,EAAA,CAAS,GAAGD,CAAS;AAAA,MAClD,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASG,EAAW,EAAE,WAAAL,GAAW,GAAGE,KAAsC;AACxE,SACEC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAWC;AAAA,QACT;AAAA,QACAJ;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASI,EAAiB;AAAA,EACxB,WAAAN;AAAA,EACA,GAAGE;AACL,GAAgC;AAC9B,SACEC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAWC;AAAA,QACT;AAAA,QACAJ;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV;ACjDA,IAAIK,IAAmE;AAEvE,MAAMC,IAAc,OACbD,MACHA,IAAiB,OAAO,SAAS,EAC9B,KAAK,CAACE,MAAQA,EAAI,OAAO,EACzB,MAAM,CAACC,MAAU;AAChB,QAAM,IAAI;AAAA,IACR;AAAA,IACA,EAAE,OAAOA,EAAA;AAAA,EAAM;AAEnB,CAAC,IAEEH,IAGII,IAAU,CAAC,EAAE,OAAAC,GAAO,QAAAC,GAAQ,GAAGX,QAA0B;AACpE,QAAMY,IAAKC,EAAA,GACLC,IAAQC,EAAA,GAER;AAAA,IACJ,MAAMC;AAAA,IACN,OAAAR;AAAA,IACA,WAAAS;AAAA,EAAA,IACEC,EAAS;AAAA,IACX,UAAU,CAAC,WAAWR,GAAOC,GAAQG,EAAM,aAAa;AAAA,IACxD,SAAS,YAAY;AACnB,YAAMK,IAAU,MAAMb,EAAA;AACtB,MAAAa,EAAQ,WAAW;AAAA,QACjB,OAAOL,EAAM,kBAAkB,SAAS,SAAS;AAAA,QACjD,GAAGH;AAAA,MAAA,CACJ;AAED,YAAM,EAAE,KAAAK,EAAAA,IAAQ,MAAMG,EAAQ,OAAOP,GAAIF,CAAK;AAC9C,aAAOM;AAAAA,IACT;AAAA,IACA,SAAS,OAAO,SAAW;AAAA,IAC3B,OAAO;AAAA,EAAA,CACR;AAED,SAAIR,IAEAY,gBAAAA,EAAAA,KAACvB,GAAA,EAAM,WAAU,uBAAsB,SAAQ,eAC7C,UAAA;AAAA,IAAAI,gBAAAA,EAAAA,IAACE,KAAW,UAAA,gBAAA,CAAa;AAAA,IACzBF,gBAAAA,EAAAA,IAACG,GAAA,EAAiB,WAAU,uEACzB,YAAM,QAAA,CACT;AAAA,EAAA,GACF,IAGAa,IAAkBhB,gBAAAA,MAACoB,GAAA,CAAA,CAAQ,IAGxBpB,gBAAAA,EAAAA,IAAC,SAAK,GAAGD,GAAO,yBAAyB,EAAE,QAAQgB,KAAO;AACnE;"}