zudoku 0.0.0-fix-firebase-export.f8270825 → 0.0.0-monetization-standalone.zd1543a39

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 (410) hide show
  1. package/dist/app/main.d.ts +6 -6
  2. package/dist/cli/common/version-check.js +12 -3
  3. package/dist/cli/common/version-check.js.map +1 -1
  4. package/dist/config/create-plugin.d.ts +2 -0
  5. package/dist/config/create-plugin.js +53 -0
  6. package/dist/config/create-plugin.js.map +1 -0
  7. package/dist/config/loader.js +3 -1
  8. package/dist/config/loader.js.map +1 -1
  9. package/dist/config/validators/InputNavigationSchema.d.ts +77 -75
  10. package/dist/config/validators/InputNavigationSchema.js +1 -0
  11. package/dist/config/validators/InputNavigationSchema.js.map +1 -1
  12. package/dist/config/validators/NavigationSchema.js +6 -1
  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 +61 -13
  16. package/dist/config/validators/validate.js +9 -4
  17. package/dist/config/validators/validate.js.map +1 -1
  18. package/dist/flat-config.d.ts +29 -26
  19. package/dist/index.d.ts +3 -1
  20. package/dist/index.js +3 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/auth/issuer.js +1 -1
  23. package/dist/lib/auth/issuer.js.map +1 -1
  24. package/dist/lib/authentication/authentication.d.ts +3 -2
  25. package/dist/lib/authentication/components/CallbackHandler.js +1 -1
  26. package/dist/lib/authentication/components/CallbackHandler.js.map +1 -1
  27. package/dist/lib/authentication/components/SignIn.js +4 -2
  28. package/dist/lib/authentication/components/SignIn.js.map +1 -1
  29. package/dist/lib/authentication/components/SignUp.js +4 -2
  30. package/dist/lib/authentication/components/SignUp.js.map +1 -1
  31. package/dist/lib/authentication/hook.d.ts +2 -0
  32. package/dist/lib/authentication/hook.js +10 -0
  33. package/dist/lib/authentication/hook.js.map +1 -1
  34. package/dist/lib/authentication/providers/auth0.js +11 -7
  35. package/dist/lib/authentication/providers/auth0.js.map +1 -1
  36. package/dist/lib/authentication/providers/clerk.js +0 -22
  37. package/dist/lib/authentication/providers/clerk.js.map +1 -1
  38. package/dist/lib/authentication/providers/firebase.js +67 -9
  39. package/dist/lib/authentication/providers/firebase.js.map +1 -1
  40. package/dist/lib/authentication/providers/supabase.js +6 -15
  41. package/dist/lib/authentication/providers/supabase.js.map +1 -1
  42. package/dist/lib/authentication/ui/EmailVerificationUi.d.ts +4 -0
  43. package/dist/lib/authentication/ui/EmailVerificationUi.js +34 -0
  44. package/dist/lib/authentication/ui/EmailVerificationUi.js.map +1 -0
  45. package/dist/lib/authentication/ui/ZudokuAuthUi.d.ts +7 -2
  46. package/dist/lib/authentication/ui/ZudokuAuthUi.js +43 -11
  47. package/dist/lib/authentication/ui/ZudokuAuthUi.js.map +1 -1
  48. package/dist/lib/authentication/utils/relativeRedirectUrl.d.ts +1 -0
  49. package/dist/lib/authentication/utils/relativeRedirectUrl.js +8 -0
  50. package/dist/lib/authentication/utils/relativeRedirectUrl.js.map +1 -0
  51. package/dist/lib/components/Bootstrap.js +1 -2
  52. package/dist/lib/components/Bootstrap.js.map +1 -1
  53. package/dist/lib/components/Pagination.js +2 -2
  54. package/dist/lib/components/Pagination.js.map +1 -1
  55. package/dist/lib/components/Zudoku.js +2 -5
  56. package/dist/lib/components/Zudoku.js.map +1 -1
  57. package/dist/lib/components/context/ZudokuContext.d.ts +2 -4
  58. package/dist/lib/components/context/ZudokuContext.js +2 -2
  59. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  60. package/dist/lib/components/context/ZudokuProvider.js +1 -1
  61. package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
  62. package/dist/lib/components/context/ZudokuReactContext.d.ts +11 -0
  63. package/dist/lib/components/context/ZudokuReactContext.js +4 -0
  64. package/dist/lib/components/context/ZudokuReactContext.js.map +1 -0
  65. package/dist/lib/components/index.d.ts +5 -0
  66. package/dist/lib/components/index.js +4 -0
  67. package/dist/lib/components/index.js.map +1 -1
  68. package/dist/lib/components/navigation/NavigationItem.js +2 -2
  69. package/dist/lib/components/navigation/NavigationItem.js.map +1 -1
  70. package/dist/lib/core/RouteGuard.js +12 -7
  71. package/dist/lib/core/RouteGuard.js.map +1 -1
  72. package/dist/lib/core/plugins.d.ts +11 -1
  73. package/dist/lib/core/plugins.js +1 -0
  74. package/dist/lib/core/plugins.js.map +1 -1
  75. package/dist/lib/core/react-query.d.ts +1 -0
  76. package/dist/lib/core/react-query.js +2 -0
  77. package/dist/lib/core/react-query.js.map +1 -0
  78. package/dist/lib/core/transform-config.d.ts +2 -0
  79. package/dist/lib/core/transform-config.js +22 -0
  80. package/dist/lib/core/transform-config.js.map +1 -0
  81. package/dist/lib/errors/ErrorAlert.js +1 -2
  82. package/dist/lib/errors/ErrorAlert.js.map +1 -1
  83. package/dist/lib/errors/ErrorMessage.d.ts +3 -0
  84. package/dist/lib/errors/ErrorMessage.js +16 -0
  85. package/dist/lib/errors/ErrorMessage.js.map +1 -0
  86. package/dist/lib/hooks/index.d.ts +2 -0
  87. package/dist/lib/oas/graphql/circular.d.ts +2 -0
  88. package/dist/lib/oas/graphql/circular.js +32 -10
  89. package/dist/lib/oas/graphql/circular.js.map +1 -1
  90. package/dist/lib/oas/graphql/circular.test.d.ts +1 -0
  91. package/dist/lib/oas/graphql/circular.test.js +152 -0
  92. package/dist/lib/oas/graphql/circular.test.js.map +1 -0
  93. package/dist/lib/oas/graphql/index.js +7 -3
  94. package/dist/lib/oas/graphql/index.js.map +1 -1
  95. package/dist/lib/plugins/api-keys/SettingsApiKeys.js +9 -172
  96. package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
  97. package/dist/lib/plugins/api-keys/index.d.ts +11 -4
  98. package/dist/lib/plugins/api-keys/index.js +36 -22
  99. package/dist/lib/plugins/api-keys/index.js.map +1 -1
  100. package/dist/lib/plugins/api-keys/settings/ApiKeyItem.d.ts +12 -0
  101. package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js +133 -0
  102. package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js.map +1 -0
  103. package/dist/lib/plugins/api-keys/settings/ApiKeyList.d.ts +4 -0
  104. package/dist/lib/plugins/api-keys/settings/ApiKeyList.js +33 -0
  105. package/dist/lib/plugins/api-keys/settings/ApiKeyList.js.map +1 -0
  106. package/dist/lib/plugins/api-keys/settings/RevealApiKey.d.ts +6 -0
  107. package/dist/lib/plugins/api-keys/settings/RevealApiKey.js +39 -0
  108. package/dist/lib/plugins/api-keys/settings/RevealApiKey.js.map +1 -0
  109. package/dist/lib/plugins/openapi/OasProvider.js +6 -2
  110. package/dist/lib/plugins/openapi/OasProvider.js.map +1 -1
  111. package/dist/lib/plugins/openapi/OperationList.js +4 -4
  112. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  113. package/dist/lib/plugins/openapi/ParamInfos.js +1 -0
  114. package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -1
  115. package/dist/lib/plugins/openapi/Sidecar.js +3 -2
  116. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  117. package/dist/lib/plugins/openapi/interfaces.d.ts +3 -0
  118. package/dist/lib/plugins/openapi/schema/SchemaView.js +1 -1
  119. package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
  120. package/dist/lib/plugins/openapi/schema/utils.js +11 -3
  121. package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
  122. package/dist/lib/plugins/openapi/util/createHttpSnippet.js +24 -1
  123. package/dist/lib/plugins/openapi/util/createHttpSnippet.js.map +1 -1
  124. package/dist/lib/plugins/openapi/util/getRoutes.d.ts +3 -0
  125. package/dist/lib/plugins/openapi/util/getRoutes.js +2 -1
  126. package/dist/lib/plugins/openapi/util/getRoutes.js.map +1 -1
  127. package/dist/lib/ui/Button.js +1 -1
  128. package/dist/lib/ui/Button.js.map +1 -1
  129. package/dist/lib/ui/Command.d.ts +3 -3
  130. package/dist/lib/ui/Secret.js +2 -2
  131. package/dist/lib/ui/Secret.js.map +1 -1
  132. package/dist/lib/util/invariant.d.ts +1 -1
  133. package/dist/lib/util/invariant.js +2 -2
  134. package/dist/lib/util/invariant.js.map +1 -1
  135. package/dist/vite/api/SchemaManager.d.ts +12 -1
  136. package/dist/vite/api/SchemaManager.js +31 -14
  137. package/dist/vite/api/SchemaManager.js.map +1 -1
  138. package/dist/vite/api/SchemaManager.test.js +44 -0
  139. package/dist/vite/api/SchemaManager.test.js.map +1 -1
  140. package/dist/vite/config.js +10 -4
  141. package/dist/vite/config.js.map +1 -1
  142. package/dist/vite/error-handler.js +1 -5
  143. package/dist/vite/error-handler.js.map +1 -1
  144. package/dist/vite/mdx/remark-link-rewrite.js +1 -1
  145. package/dist/vite/plugin-api-keys.js +5 -1
  146. package/dist/vite/plugin-api-keys.js.map +1 -1
  147. package/dist/vite/plugin-api.js +5 -3
  148. package/dist/vite/plugin-api.js.map +1 -1
  149. package/dist/vite/plugin-markdown-export.js +1 -1
  150. package/dist/vite/plugin-markdown-export.js.map +1 -1
  151. package/dist/vite/plugin-theme.js +2 -1
  152. package/dist/vite/plugin-theme.js.map +1 -1
  153. package/dist/vite/prerender/utils.js +9 -3
  154. package/dist/vite/prerender/utils.js.map +1 -1
  155. package/dist/vite/prerender/worker.js +3 -0
  156. package/dist/vite/prerender/worker.js.map +1 -1
  157. package/dist/vite/zuplo.d.ts +13 -0
  158. package/dist/vite/zuplo.js +15 -0
  159. package/dist/vite/zuplo.js.map +1 -0
  160. package/lib/{ActionButton-DUgvSylL.js → ActionButton-B0CXL1Lq.js} +3 -3
  161. package/lib/{ActionButton-DUgvSylL.js.map → ActionButton-B0CXL1Lq.js.map} +1 -1
  162. package/lib/{Button-CynVW1JV.js → Button-GUVe7pmt.js} +8 -7
  163. package/lib/{Button-CynVW1JV.js.map → Button-GUVe7pmt.js.map} +1 -1
  164. package/lib/{Card-KFniaZn5.js → Card-DCdq37aA.js} +2 -2
  165. package/lib/{Card-KFniaZn5.js.map → Card-DCdq37aA.js.map} +1 -1
  166. package/lib/{ClaudeLogo-B4Xxt-x_.js → ClaudeLogo-CUaQXKLK.js} +22 -22
  167. package/lib/ClaudeLogo-CUaQXKLK.js.map +1 -0
  168. package/lib/{Command-BpT1iBE6.js → Command-N6VujV30.js} +3 -3
  169. package/lib/{Command-BpT1iBE6.js.map → Command-N6VujV30.js.map} +1 -1
  170. package/lib/{Dialog-BQciPiHN.js → Dialog-hlvmmQ_c.js} +2 -2
  171. package/lib/{Dialog-BQciPiHN.js.map → Dialog-hlvmmQ_c.js.map} +1 -1
  172. package/lib/{Drawer-Ci7XwhqT.js → Drawer-Ch7927PF.js} +7 -7
  173. package/lib/{Drawer-Ci7XwhqT.js.map → Drawer-Ch7927PF.js.map} +1 -1
  174. package/lib/{DropdownMenu-C8SX_-S_.js → DropdownMenu-DN0jNrjj.js} +2 -2
  175. package/lib/{DropdownMenu-C8SX_-S_.js.map → DropdownMenu-DN0jNrjj.js.map} +1 -1
  176. package/lib/Frame-DKlOmSkU.js +205 -0
  177. package/lib/Frame-DKlOmSkU.js.map +1 -0
  178. package/lib/HydrationBoundary-CNF2ZV3E.js +601 -0
  179. package/lib/HydrationBoundary-CNF2ZV3E.js.map +1 -0
  180. package/lib/{IndexingDialog-B5zCiUKr.js → IndexingDialog-D0YdGfbn.js} +3 -3
  181. package/lib/{IndexingDialog-B5zCiUKr.js.map → IndexingDialog-D0YdGfbn.js.map} +1 -1
  182. package/lib/Input-Cx-GeKoF.js +22 -0
  183. package/lib/Input-Cx-GeKoF.js.map +1 -0
  184. package/lib/{MdxPage-BagO2c-n.js → MdxPage-BiAVpP8K.js} +11 -11
  185. package/lib/{MdxPage-BagO2c-n.js.map → MdxPage-BiAVpP8K.js.map} +1 -1
  186. package/lib/{Mermaid-D_VSX7_Q.js → Mermaid-DEztDKFw.js} +4 -4
  187. package/lib/{Mermaid-D_VSX7_Q.js.map → Mermaid-DEztDKFw.js.map} +1 -1
  188. package/lib/{OAuthErrorPage-Fq54RLgt.js → OAuthErrorPage-DhJo-O2B.js} +15 -15
  189. package/lib/OAuthErrorPage-DhJo-O2B.js.map +1 -0
  190. package/lib/OasProvider-DFMZwyNn.js +48 -0
  191. package/lib/OasProvider-DFMZwyNn.js.map +1 -0
  192. package/lib/{OperationList-C0jiEaG5.js → OperationList-CnmLfOuu.js} +1560 -1545
  193. package/lib/{OperationList-C0jiEaG5.js.map → OperationList-CnmLfOuu.js.map} +1 -1
  194. package/lib/RouteGuard-CZuPjknT.js +77 -0
  195. package/lib/RouteGuard-CZuPjknT.js.map +1 -0
  196. package/lib/{SchemaList-BU0zCHn9.js → SchemaList-B5ikunUd.js} +9 -9
  197. package/lib/{SchemaList-BU0zCHn9.js.map → SchemaList-B5ikunUd.js.map} +1 -1
  198. package/lib/SchemaView-rjji7zMf.js +438 -0
  199. package/lib/SchemaView-rjji7zMf.js.map +1 -0
  200. package/lib/{Select-CkxXP5I7.js → Secret-BE7V0Vb5.js} +159 -139
  201. package/lib/Secret-BE7V0Vb5.js.map +1 -0
  202. package/lib/{Separator-CTPSeW1S.js → Separator-BXt1LYnm.js} +2 -2
  203. package/lib/{Separator-CTPSeW1S.js.map → Separator-BXt1LYnm.js.map} +1 -1
  204. package/lib/SignUp-DHWDXat-.js +50 -0
  205. package/lib/SignUp-DHWDXat-.js.map +1 -0
  206. package/lib/{SyntaxHighlight-Kdyskw3C.js → SyntaxHighlight-paLQ8NP8.js} +1751 -1725
  207. package/lib/SyntaxHighlight-paLQ8NP8.js.map +1 -0
  208. package/lib/{Toc-DJxFPfcS.js → Toc-vMbSQCkj.js} +3 -3
  209. package/lib/{Toc-DJxFPfcS.js.map → Toc-vMbSQCkj.js.map} +1 -1
  210. package/lib/ZudokuContext-CnEI8jPU.js +389 -0
  211. package/lib/ZudokuContext-CnEI8jPU.js.map +1 -0
  212. package/lib/{___vite-browser-external_commonjs-proxy-Cga3HsWk.js → ___vite-browser-external_commonjs-proxy-BttVsNON.js} +2 -2
  213. package/lib/___vite-browser-external_commonjs-proxy-BttVsNON.js.map +1 -0
  214. package/lib/chunk-EPOLDU6W-C6C8jAwd.js +8558 -0
  215. package/lib/chunk-EPOLDU6W-C6C8jAwd.js.map +1 -0
  216. package/lib/{circular-CzWF1hj5.js → circular-CLhJAE3S.js} +771 -749
  217. package/lib/{circular-CzWF1hj5.js.map → circular-CLhJAE3S.js.map} +1 -1
  218. package/lib/{cn-dYga0KKN.js → cn-5-Gd1Dss.js} +531 -498
  219. package/lib/cn-5-Gd1Dss.js.map +1 -0
  220. package/lib/{createServer-BIr2_tGn.js → createServer-BYtu5Pcr.js} +12 -12
  221. package/lib/{createServer-BIr2_tGn.js.map → createServer-BYtu5Pcr.js.map} +1 -1
  222. package/lib/createVariantComponent-Dc0vtOvr.js +18 -0
  223. package/lib/createVariantComponent-Dc0vtOvr.js.map +1 -0
  224. package/lib/{errors-Bs4duWDy.js → errors-DkJIl45d.js} +3 -3
  225. package/lib/{errors-Bs4duWDy.js.map → errors-DkJIl45d.js.map} +1 -1
  226. package/lib/{firebase-qUdSEL1p.js → firebase-CmsW0j7-.js} +1590 -1342
  227. package/lib/firebase-CmsW0j7-.js.map +1 -0
  228. package/lib/hook-Da8QTnPd.js +52 -0
  229. package/lib/hook-Da8QTnPd.js.map +1 -0
  230. package/lib/{index-Css56y3F.js → index-Ba6RP577.js} +4 -4
  231. package/lib/{index-Css56y3F.js.map → index-Ba6RP577.js.map} +1 -1
  232. package/lib/index-CrcNWbel.js.map +1 -1
  233. package/lib/{index-Bh-MffiL.js → index-D35F-SCL.js} +2 -2
  234. package/lib/{index-Bh-MffiL.js.map → index-D35F-SCL.js.map} +1 -1
  235. package/lib/{index-0oT9beQN.js → index-k0PVZBYl.js} +155 -151
  236. package/lib/{index-0oT9beQN.js.map → index-k0PVZBYl.js.map} +1 -1
  237. package/lib/{ErrorAlert-DrOR8w3f.js → index-ofqkdEjL.js} +5457 -4444
  238. package/lib/index-ofqkdEjL.js.map +1 -0
  239. package/lib/index.esm-BYObtETB.js.map +1 -1
  240. package/lib/{index.esm-DtzT_KoE.js → index.esm-B_0dvNjB.js} +2 -2
  241. package/lib/{index.esm-DtzT_KoE.js.map → index.esm-B_0dvNjB.js.map} +1 -1
  242. package/lib/{index.esm-kW-Utcsi.js → index.esm-DFzsB75P.js} +16 -14
  243. package/lib/index.esm-DFzsB75P.js.map +1 -0
  244. package/lib/{invariant-CGOLuIIz.js → invariant-BJAl77rw.js} +4 -4
  245. package/lib/invariant-BJAl77rw.js.map +1 -0
  246. package/lib/jsx-runtime-BzflLqGi.js.map +1 -1
  247. package/lib/{mutation-BoVlx8yA.js → mutation-BISOc7OM.js} +70 -44
  248. package/lib/mutation-BISOc7OM.js.map +1 -0
  249. package/lib/ui/Accordion.js +1 -1
  250. package/lib/ui/ActionButton.js +2 -2
  251. package/lib/ui/Alert.js +1 -1
  252. package/lib/ui/AlertDialog.js +1 -1
  253. package/lib/ui/Badge.js +1 -1
  254. package/lib/ui/Breadcrumb.js +1 -1
  255. package/lib/ui/Button.js +7 -6
  256. package/lib/ui/Button.js.map +1 -1
  257. package/lib/ui/ButtonGroup.js +1 -1
  258. package/lib/ui/Callout.js +1 -1
  259. package/lib/ui/Card.js +1 -1
  260. package/lib/ui/Carousel.js +1 -1
  261. package/lib/ui/Carousel.js.map +1 -1
  262. package/lib/ui/Checkbox.js +1 -1
  263. package/lib/ui/CodeBlock.js +1 -1
  264. package/lib/ui/Command.js +2 -2
  265. package/lib/ui/Dialog.js +1 -1
  266. package/lib/ui/Drawer.js +3 -3
  267. package/lib/ui/DropdownMenu.js +1 -1
  268. package/lib/ui/EmbeddedCodeBlock.js +1 -1
  269. package/lib/ui/Form.js +1 -1
  270. package/lib/ui/Frame.js +1 -1
  271. package/lib/ui/HoverCard.js +1 -1
  272. package/lib/ui/Input.js +1 -1
  273. package/lib/ui/Item.js +1 -1
  274. package/lib/ui/Label.js +1 -1
  275. package/lib/ui/NativeSelect.js +1 -1
  276. package/lib/ui/Pagination.js +1 -1
  277. package/lib/ui/Popover.js +1 -1
  278. package/lib/ui/Progress.js +1 -1
  279. package/lib/ui/RadioGroup.js +1 -1
  280. package/lib/ui/ScrollArea.js +1 -1
  281. package/lib/ui/Secret.js +3 -3
  282. package/lib/ui/Secret.js.map +1 -1
  283. package/lib/ui/Separator.js +1 -1
  284. package/lib/ui/Skeleton.js +1 -1
  285. package/lib/ui/Slider.js +1 -1
  286. package/lib/ui/Switch.js +1 -1
  287. package/lib/ui/SyntaxHighlight.js +3 -3
  288. package/lib/ui/Tabs.js +1 -1
  289. package/lib/ui/Textarea.js +1 -1
  290. package/lib/ui/Toggle.js +1 -1
  291. package/lib/ui/ToggleGroup.js +1 -1
  292. package/lib/ui/Value.js +1 -1
  293. package/lib/ui/util.js +1 -1
  294. package/lib/{useMutation-C6RqWmTS.js → useMutation-CFMGlAMW.js} +39 -17
  295. package/lib/useMutation-CFMGlAMW.js.map +1 -0
  296. package/lib/useSuspenseQuery-CSB_rVek.js +1226 -0
  297. package/lib/useSuspenseQuery-CSB_rVek.js.map +1 -0
  298. package/lib/zudoku.__internal.js +826 -1325
  299. package/lib/zudoku.__internal.js.map +1 -1
  300. package/lib/zudoku.auth-auth0.js +16 -16
  301. package/lib/zudoku.auth-auth0.js.map +1 -1
  302. package/lib/zudoku.auth-azureb2c.js +4 -4
  303. package/lib/zudoku.auth-clerk.js +52 -75
  304. package/lib/zudoku.auth-clerk.js.map +1 -1
  305. package/lib/zudoku.auth-firebase.js +6 -5
  306. package/lib/zudoku.auth-firebase.js.map +1 -1
  307. package/lib/zudoku.auth-openid.js +5 -5
  308. package/lib/zudoku.auth-supabase.js +31 -40
  309. package/lib/zudoku.auth-supabase.js.map +1 -1
  310. package/lib/zudoku.components.js +23 -21
  311. package/lib/zudoku.hooks.js +3 -3
  312. package/lib/zudoku.mermaid.js +3 -3
  313. package/lib/zudoku.plugin-api-catalog.js +8 -8
  314. package/lib/zudoku.plugin-api-keys.js +607 -552
  315. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  316. package/lib/zudoku.plugin-custom-pages.js +1 -1
  317. package/lib/zudoku.plugin-markdown.js +1 -1
  318. package/lib/zudoku.plugin-openapi.js +3 -3
  319. package/lib/zudoku.plugin-redirect.js +1 -1
  320. package/lib/zudoku.plugin-search-pagefind.js +30 -29
  321. package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
  322. package/lib/zudoku.plugins.js +9 -8
  323. package/lib/zudoku.plugins.js.map +1 -1
  324. package/lib/zudoku.react-query.js +440 -0
  325. package/lib/zudoku.react-query.js.map +1 -0
  326. package/lib/zudoku.router.js +1130 -1404
  327. package/lib/zudoku.router.js.map +1 -1
  328. package/package.json +36 -22
  329. package/src/lib/auth/issuer.ts +1 -1
  330. package/src/lib/authentication/authentication.ts +8 -2
  331. package/src/lib/authentication/components/CallbackHandler.tsx +1 -1
  332. package/src/lib/authentication/components/SignIn.tsx +5 -2
  333. package/src/lib/authentication/components/SignUp.tsx +5 -2
  334. package/src/lib/authentication/hook.ts +16 -0
  335. package/src/lib/authentication/providers/auth0.tsx +15 -9
  336. package/src/lib/authentication/providers/clerk.tsx +0 -26
  337. package/src/lib/authentication/providers/firebase.tsx +98 -6
  338. package/src/lib/authentication/providers/supabase.tsx +6 -15
  339. package/src/lib/authentication/ui/EmailVerificationUi.tsx +129 -0
  340. package/src/lib/authentication/ui/ZudokuAuthUi.tsx +170 -38
  341. package/src/lib/authentication/utils/relativeRedirectUrl.ts +12 -0
  342. package/src/lib/components/Bootstrap.tsx +1 -4
  343. package/src/lib/components/Pagination.tsx +4 -5
  344. package/src/lib/components/Zudoku.tsx +5 -11
  345. package/src/lib/components/context/ZudokuContext.ts +2 -6
  346. package/src/lib/components/context/ZudokuProvider.tsx +1 -1
  347. package/src/lib/components/context/ZudokuReactContext.tsx +17 -0
  348. package/src/lib/components/index.ts +4 -0
  349. package/src/lib/components/navigation/NavigationItem.tsx +9 -3
  350. package/src/lib/core/RouteGuard.tsx +30 -24
  351. package/src/lib/core/plugins.ts +21 -1
  352. package/src/lib/core/react-query.ts +1 -0
  353. package/src/lib/core/transform-config.ts +29 -0
  354. package/src/lib/errors/ErrorAlert.tsx +1 -6
  355. package/src/lib/errors/ErrorMessage.tsx +38 -0
  356. package/src/lib/oas/graphql/circular.test.ts +186 -0
  357. package/src/lib/oas/graphql/circular.ts +49 -10
  358. package/src/lib/oas/graphql/index.ts +7 -3
  359. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +36 -476
  360. package/src/lib/plugins/api-keys/index.tsx +76 -32
  361. package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -0
  362. package/src/lib/plugins/api-keys/settings/ApiKeyList.tsx +67 -0
  363. package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +124 -0
  364. package/src/lib/plugins/openapi/OasProvider.tsx +10 -2
  365. package/src/lib/plugins/openapi/OperationList.tsx +4 -4
  366. package/src/lib/plugins/openapi/ParamInfos.tsx +1 -0
  367. package/src/lib/plugins/openapi/Sidecar.tsx +3 -2
  368. package/src/lib/plugins/openapi/interfaces.ts +6 -1
  369. package/src/lib/plugins/openapi/schema/SchemaView.tsx +6 -4
  370. package/src/lib/plugins/openapi/schema/utils.ts +15 -4
  371. package/src/lib/plugins/openapi/util/createHttpSnippet.ts +29 -1
  372. package/src/lib/plugins/openapi/util/getRoutes.tsx +4 -1
  373. package/src/lib/ui/Button.tsx +1 -0
  374. package/src/lib/ui/Secret.tsx +2 -2
  375. package/src/lib/util/invariant.ts +2 -1
  376. package/src/shiki/langs/c3.js +1 -0
  377. package/src/shiki/langs/gn.js +1 -0
  378. package/src/shiki/langs/moonbit.js +1 -0
  379. package/lib/ClaudeLogo-B4Xxt-x_.js.map +0 -1
  380. package/lib/ErrorAlert-DrOR8w3f.js.map +0 -1
  381. package/lib/OAuthErrorPage-Fq54RLgt.js.map +0 -1
  382. package/lib/OasProvider-DPH8mwDa.js +0 -40
  383. package/lib/OasProvider-DPH8mwDa.js.map +0 -1
  384. package/lib/RouteGuard-9wjejsKm.js +0 -77
  385. package/lib/RouteGuard-9wjejsKm.js.map +0 -1
  386. package/lib/RouterError-DSLXagd5.js +0 -42
  387. package/lib/RouterError-DSLXagd5.js.map +0 -1
  388. package/lib/SchemaView-DVae4RO2.js +0 -597
  389. package/lib/SchemaView-DVae4RO2.js.map +0 -1
  390. package/lib/Select-CkxXP5I7.js.map +0 -1
  391. package/lib/SignUp-BjS4ozA7.js +0 -50
  392. package/lib/SignUp-BjS4ozA7.js.map +0 -1
  393. package/lib/SyntaxHighlight-Kdyskw3C.js.map +0 -1
  394. package/lib/ZudokuContext-BXldanA8.js +0 -1508
  395. package/lib/ZudokuContext-BXldanA8.js.map +0 -1
  396. package/lib/___vite-browser-external_commonjs-proxy-Cga3HsWk.js.map +0 -1
  397. package/lib/chunk-PVWAREVJ-dLIqswPy.js +0 -7965
  398. package/lib/chunk-PVWAREVJ-dLIqswPy.js.map +0 -1
  399. package/lib/cn-dYga0KKN.js.map +0 -1
  400. package/lib/createVariantComponent-B9_dVBvu.js +0 -35
  401. package/lib/createVariantComponent-B9_dVBvu.js.map +0 -1
  402. package/lib/firebase-qUdSEL1p.js.map +0 -1
  403. package/lib/hook-BNxidGQq.js +0 -40
  404. package/lib/hook-BNxidGQq.js.map +0 -1
  405. package/lib/index-CCmMJp02.js +0 -1059
  406. package/lib/index-CCmMJp02.js.map +0 -1
  407. package/lib/index.esm-kW-Utcsi.js.map +0 -1
  408. package/lib/invariant-CGOLuIIz.js.map +0 -1
  409. package/lib/mutation-BoVlx8yA.js.map +0 -1
  410. package/lib/useMutation-C6RqWmTS.js.map +0 -1
@@ -1,81 +1,179 @@
1
1
  import { j as e } from "./jsx-runtime-BzflLqGi.js";
2
- import { CircleSlashIcon as $, CheckIcon as ue, XIcon as fe, PencilLineIcon as he, RefreshCwIcon as pe, TrashIcon as me, KeyRoundIcon as xe } from "lucide-react";
3
- import { R as ye } from "./RouterError-DSLXagd5.js";
4
- import { i as A } from "./invariant-CGOLuIIz.js";
5
- import { O as ge, u as je } from "./chunk-PVWAREVJ-dLIqswPy.js";
6
- import { u as Ce } from "./hook-BNxidGQq.js";
7
- import { D as ve, a as Y } from "./ErrorAlert-DrOR8w3f.js";
8
- import { Button as v } from "./ui/Button.js";
9
- import { a as ne, f as ie, e as we } from "./ZudokuContext-BXldanA8.js";
10
- import { u as T } from "./useMutation-C6RqWmTS.js";
11
- import * as q from "react";
12
- import ke, { createContext as Q, useRef as N, useLayoutEffect as be, useEffect as re, useId as _, useContext as H, useInsertionEffect as Ke, useMemo as F, useCallback as Ee, Children as De, isValidElement as Ne, useState as D } from "react";
13
- import { A as O, a as M, b as Pe } from "./Mermaid-D_VSX7_Q.js";
14
- import { C as Ae, a as Ie } from "./Card-KFniaZn5.js";
15
- import { e as V, f as P, D as B, g as G, a as J, b as U, c as W, d as ae } from "./Dialog-BQciPiHN.js";
16
- import { S as Re, a as Se, b as Te, c as Oe, d as Me, e as Z, f as qe } from "./Select-CkxXP5I7.js";
17
- import { Input as oe } from "./ui/Input.js";
18
- import { c as L } from "./cn-dYga0KKN.js";
19
- import { a as ze } from "./index.esm-BYObtETB.js";
20
- import { A as $e } from "./ActionButton-DUgvSylL.js";
21
- import { b as Fe } from "./index-Css56y3F.js";
22
- const Le = () => {
23
- const t = Ce();
24
- return t.isAuthEnabled && t.isPending ? null : t.isAuthEnabled ? t.isAuthenticated ? /* @__PURE__ */ e.jsx(ge, {}) : /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: [
25
- "Please login first to view this page",
26
- /* @__PURE__ */ e.jsx(v, { onClick: () => t.login(), children: "Login" })
27
- ] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(ve, { className: "max-w-[600px]", children: [
28
- "Authentication needs to be enabled for API keys to work. Enable it in your Zudoku configuration under ",
29
- /* @__PURE__ */ e.jsx("code", { children: "authentication" }),
30
- "."
31
- ] }) });
32
- }, Qe = Q({});
33
- function le(t) {
34
- const r = N(null);
35
- return r.current === null && (r.current = t()), r.current;
2
+ import { TrashIcon as me, CircleSlashIcon as z, CheckIcon as xe, XIcon as ye, PencilLineIcon as ge, RefreshCwIcon as je, KeyRoundIcon as ve } from "lucide-react";
3
+ import { Z as M, i as E } from "./invariant-BJAl77rw.js";
4
+ import * as F from "react";
5
+ import { createContext as Q, useRef as A, useLayoutEffect as Ce, useEffect as ie, useId as H, useContext as V, useInsertionEffect as we, useMemo as L, useCallback as ke, Children as Ee, isValidElement as Ie, useState as I } from "react";
6
+ import { D as be, c as ee, B as Ke, E as De } from "./index-ofqkdEjL.js";
7
+ import { b as re } from "./index-Ba6RP577.js";
8
+ import { F as Pe, g as Ae, j as Se, h as Re, d as Ne, I as Oe, a as Te, b as qe, k as Me, c as Fe } from "./Frame-DKlOmSkU.js";
9
+ import { A as D, a as P, b as ae } from "./Mermaid-DEztDKFw.js";
10
+ import { S as $e, a as ze, b as Le, c as Qe, d as He, e as Ve, f as te, g as _e } from "./Secret-BE7V0Vb5.js";
11
+ import { e as _, f as S, D as B, g as Z, a as G, b as J, c as Y, d as oe } from "./Dialog-hlvmmQ_c.js";
12
+ import { Button as le } from "./ui/Button.js";
13
+ import { a as ce, u as Be } from "./useSuspenseQuery-CSB_rVek.js";
14
+ import { u as q } from "./useMutation-CFMGlAMW.js";
15
+ import { a as Ze } from "./index.esm-BYObtETB.js";
16
+ import { u as Ge } from "./chunk-EPOLDU6W-C6C8jAwd.js";
17
+ import { A as Je } from "./ActionButton-B0CXL1Lq.js";
18
+ import { a as U } from "./ZudokuContext-CnEI8jPU.js";
19
+ import { Input as Ye } from "./ui/Input.js";
20
+ import { c as W } from "./cn-5-Gd1Dss.js";
21
+ import { B as k } from "./Button-GUVe7pmt.js";
22
+ import { I as Ue } from "./Input-Cx-GeKoF.js";
23
+ function We({ error: t }) {
24
+ const a = t instanceof Error ? t.message : "Something went wrong", s = process.env.NODE_ENV === "development", n = t instanceof M ? t.developerHint : void 0, r = t instanceof M ? t.title : "Something went wrong", i = t instanceof Error ? t.stack : void 0, o = t instanceof Error ? t.cause : void 0, d = o instanceof Error ? String(o.stack) : i;
25
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
26
+ /* @__PURE__ */ e.jsxs(D, { variant: "destructive", children: [
27
+ /* @__PURE__ */ e.jsx(P, { children: r }),
28
+ /* @__PURE__ */ e.jsx(ae, { children: a })
29
+ ] }),
30
+ s && n && /* @__PURE__ */ e.jsx(be, { className: "mb-4", children: n }),
31
+ s && d && /* @__PURE__ */ e.jsx(
32
+ $e,
33
+ {
34
+ className: "max-h-[400px] [&>pre]:p-4",
35
+ language: "js",
36
+ code: d
37
+ }
38
+ )
39
+ ] });
36
40
  }
37
- const _e = typeof window < "u", He = _e ? be : re, ce = /* @__PURE__ */ Q(null);
38
- function Ve(t) {
41
+ const Xe = ({
42
+ service: t,
43
+ onOpenChange: a
44
+ }) => {
45
+ const s = U(), n = ce(), r = Ge(), i = Ze({
46
+ defaultValues: {
47
+ expiresOn: "30"
48
+ }
49
+ }), o = re(), d = q({
50
+ mutationFn: ({ description: c, expiresOn: u }) => {
51
+ if (!t.createKey)
52
+ throw new Error("createKey not implemented");
53
+ const p = u !== "never" ? et(Number(u)) : void 0;
54
+ return t.createKey({
55
+ apiKey: {
56
+ description: c || "Secret Key",
57
+ expiresOn: p
58
+ },
59
+ context: s,
60
+ auth: o
61
+ });
62
+ },
63
+ onSuccess: async () => {
64
+ await n.invalidateQueries({ queryKey: ["api-keys"] }), await r("/settings/api-keys/");
65
+ }
66
+ });
67
+ return t.createKey ? /* @__PURE__ */ e.jsxs(
68
+ "form",
69
+ {
70
+ onSubmit: i.handleSubmit(
71
+ (c) => d.mutate(
72
+ { ...c },
73
+ {
74
+ onSuccess: () => a(!1)
75
+ }
76
+ )
77
+ ),
78
+ children: [
79
+ d.error && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
80
+ /* @__PURE__ */ e.jsx(P, { children: "Error" }),
81
+ /* @__PURE__ */ e.jsx(ae, { children: d.error.message })
82
+ ] }),
83
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 flex-col text-sm font-medium", children: [
84
+ "Name",
85
+ /* @__PURE__ */ e.jsx(Ye, { ...i.register("description") }),
86
+ "Expiration",
87
+ /* @__PURE__ */ e.jsxs(
88
+ ze,
89
+ {
90
+ onValueChange: (c) => i.setValue("expiresOn", c),
91
+ defaultValue: i.getValues("expiresOn"),
92
+ children: [
93
+ /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsx(Qe, {}) }),
94
+ /* @__PURE__ */ e.jsx(He, { children: /* @__PURE__ */ e.jsxs(Ve, { children: [
95
+ [7, 30, 60, 90].map((c) => /* @__PURE__ */ e.jsxs(te, { value: String(c), children: [
96
+ c,
97
+ " days"
98
+ ] }, c)),
99
+ /* @__PURE__ */ e.jsx(te, { value: "never", children: "Never" })
100
+ ] }) })
101
+ ]
102
+ }
103
+ ),
104
+ /* @__PURE__ */ e.jsxs(_, { children: [
105
+ /* @__PURE__ */ e.jsx(S, { asChild: !0, children: /* @__PURE__ */ e.jsx(le, { variant: "outline", children: "Cancel" }) }),
106
+ /* @__PURE__ */ e.jsx(Je, { isPending: d.isPending, children: "Generate Key" })
107
+ ] })
108
+ ] })
109
+ ]
110
+ }
111
+ ) : null;
112
+ }, et = (t) => {
113
+ const a = /* @__PURE__ */ new Date();
114
+ return a.setDate(a.getDate() + t), a.toISOString();
115
+ }, de = ({
116
+ service: t,
117
+ isOpen: a,
118
+ onOpenChange: s,
119
+ trigger: n,
120
+ buttonVariant: r = "outline"
121
+ }) => {
122
+ const i = /* @__PURE__ */ e.jsx(le, { variant: r, children: "Create API Key" });
123
+ return /* @__PURE__ */ e.jsxs(B, { open: a, onOpenChange: s, children: [
124
+ /* @__PURE__ */ e.jsx(Z, { asChild: !0, children: n ?? i }),
125
+ /* @__PURE__ */ e.jsxs(G, { children: [
126
+ /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsx(Y, { children: "Create API Key" }) }),
127
+ /* @__PURE__ */ e.jsx(Xe, { service: t, onOpenChange: s })
128
+ ] })
129
+ ] });
130
+ }, tt = Q({});
131
+ function ue(t) {
132
+ const a = A(null);
133
+ return a.current === null && (a.current = t()), a.current;
134
+ }
135
+ const st = typeof window < "u", nt = st ? Ce : ie, fe = /* @__PURE__ */ Q(null);
136
+ function it(t) {
39
137
  return typeof t == "object" && t !== null;
40
138
  }
41
- function Be(t) {
42
- return Ve(t) && "offsetHeight" in t;
139
+ function rt(t) {
140
+ return it(t) && "offsetHeight" in t;
43
141
  }
44
- const Ge = Q({
142
+ const at = Q({
45
143
  transformPagePoint: (t) => t,
46
144
  isStatic: !1,
47
145
  reducedMotion: "never"
48
146
  });
49
- function ee(t, r) {
147
+ function se(t, a) {
50
148
  if (typeof t == "function")
51
- return t(r);
52
- t != null && (t.current = r);
149
+ return t(a);
150
+ t != null && (t.current = a);
53
151
  }
54
- function Je(...t) {
55
- return (r) => {
152
+ function ot(...t) {
153
+ return (a) => {
56
154
  let s = !1;
57
- const n = t.map((i) => {
58
- const a = ee(i, r);
59
- return !s && typeof a == "function" && (s = !0), a;
155
+ const n = t.map((r) => {
156
+ const i = se(r, a);
157
+ return !s && typeof i == "function" && (s = !0), i;
60
158
  });
61
159
  if (s)
62
160
  return () => {
63
- for (let i = 0; i < n.length; i++) {
64
- const a = n[i];
65
- typeof a == "function" ? a() : ee(t[i], null);
161
+ for (let r = 0; r < n.length; r++) {
162
+ const i = n[r];
163
+ typeof i == "function" ? i() : se(t[r], null);
66
164
  }
67
165
  };
68
166
  };
69
167
  }
70
- function Ue(...t) {
71
- return q.useCallback(Je(...t), t);
168
+ function lt(...t) {
169
+ return F.useCallback(ot(...t), t);
72
170
  }
73
- class We extends q.Component {
74
- getSnapshotBeforeUpdate(r) {
171
+ class ct extends F.Component {
172
+ getSnapshotBeforeUpdate(a) {
75
173
  const s = this.props.childRef.current;
76
- if (s && r.isPresent && !this.props.isPresent) {
77
- const n = s.offsetParent, i = Be(n) && n.offsetWidth || 0, a = this.props.sizeRef.current;
78
- a.height = s.offsetHeight || 0, a.width = s.offsetWidth || 0, a.top = s.offsetTop, a.left = s.offsetLeft, a.right = i - a.width - a.left;
174
+ if (s && a.isPresent && !this.props.isPresent) {
175
+ const n = s.offsetParent, r = rt(n) && n.offsetWidth || 0, i = this.props.sizeRef.current;
176
+ i.height = s.offsetHeight || 0, i.width = s.offsetWidth || 0, i.top = s.offsetTop, i.left = s.offsetLeft, i.right = r - i.width - i.left;
79
177
  }
80
178
  return null;
81
179
  }
@@ -88,558 +186,502 @@ class We extends q.Component {
88
186
  return this.props.children;
89
187
  }
90
188
  }
91
- function Xe({ children: t, isPresent: r, anchorX: s, root: n }) {
92
- const i = _(), a = N(null), l = N({
189
+ function dt({ children: t, isPresent: a, anchorX: s, root: n }) {
190
+ const r = H(), i = A(null), o = A({
93
191
  width: 0,
94
192
  height: 0,
95
193
  top: 0,
96
194
  left: 0,
97
195
  right: 0
98
- }), { nonce: u } = H(Ge), f = Ue(a, t?.ref);
99
- return Ke(() => {
100
- const { width: d, height: y, top: h, left: x, right: p } = l.current;
101
- if (r || !a.current || !d || !y)
196
+ }), { nonce: d } = V(at), c = lt(i, t?.ref);
197
+ return we(() => {
198
+ const { width: u, height: p, top: f, left: m, right: g } = o.current;
199
+ if (a || !i.current || !u || !p)
102
200
  return;
103
- const k = s === "left" ? `left: ${x}` : `right: ${p}`;
104
- a.current.dataset.motionPopId = i;
105
- const m = document.createElement("style");
106
- u && (m.nonce = u);
107
- const K = n ?? document.head;
108
- return K.appendChild(m), m.sheet && m.sheet.insertRule(`
109
- [data-motion-pop-id="${i}"] {
201
+ const j = s === "left" ? `left: ${m}` : `right: ${g}`;
202
+ i.current.dataset.motionPopId = r;
203
+ const l = document.createElement("style");
204
+ d && (l.nonce = d);
205
+ const x = n ?? document.head;
206
+ return x.appendChild(l), l.sheet && l.sheet.insertRule(`
207
+ [data-motion-pop-id="${r}"] {
110
208
  position: absolute !important;
111
- width: ${d}px !important;
112
- height: ${y}px !important;
113
- ${k}px !important;
114
- top: ${h}px !important;
209
+ width: ${u}px !important;
210
+ height: ${p}px !important;
211
+ ${j}px !important;
212
+ top: ${f}px !important;
115
213
  }
116
214
  `), () => {
117
- K.contains(m) && K.removeChild(m);
215
+ x.contains(l) && x.removeChild(l);
118
216
  };
119
- }, [r]), e.jsx(We, { isPresent: r, childRef: a, sizeRef: l, children: q.cloneElement(t, { ref: f }) });
217
+ }, [a]), e.jsx(ct, { isPresent: a, childRef: i, sizeRef: o, children: F.cloneElement(t, { ref: c }) });
120
218
  }
121
- const Ye = ({ children: t, initial: r, isPresent: s, onExitComplete: n, custom: i, presenceAffectsLayout: a, mode: l, anchorX: u, root: f }) => {
122
- const d = le(Ze), y = _();
123
- let h = !0, x = F(() => (h = !1, {
124
- id: y,
125
- initial: r,
219
+ const ut = ({ children: t, initial: a, isPresent: s, onExitComplete: n, custom: r, presenceAffectsLayout: i, mode: o, anchorX: d, root: c }) => {
220
+ const u = ue(ft), p = H();
221
+ let f = !0, m = L(() => (f = !1, {
222
+ id: p,
223
+ initial: a,
126
224
  isPresent: s,
127
- custom: i,
128
- onExitComplete: (p) => {
129
- d.set(p, !0);
130
- for (const k of d.values())
131
- if (!k)
225
+ custom: r,
226
+ onExitComplete: (g) => {
227
+ u.set(g, !0);
228
+ for (const j of u.values())
229
+ if (!j)
132
230
  return;
133
231
  n && n();
134
232
  },
135
- register: (p) => (d.set(p, !1), () => d.delete(p))
136
- }), [s, d, n]);
137
- return a && h && (x = { ...x }), F(() => {
138
- d.forEach((p, k) => d.set(k, !1));
139
- }, [s]), q.useEffect(() => {
140
- !s && !d.size && n && n();
141
- }, [s]), l === "popLayout" && (t = e.jsx(Xe, { isPresent: s, anchorX: u, root: f, children: t })), e.jsx(ce.Provider, { value: x, children: t });
233
+ register: (g) => (u.set(g, !1), () => u.delete(g))
234
+ }), [s, u, n]);
235
+ return i && f && (m = { ...m }), L(() => {
236
+ u.forEach((g, j) => u.set(j, !1));
237
+ }, [s]), F.useEffect(() => {
238
+ !s && !u.size && n && n();
239
+ }, [s]), o === "popLayout" && (t = e.jsx(dt, { isPresent: s, anchorX: d, root: c, children: t })), e.jsx(fe.Provider, { value: m, children: t });
142
240
  };
143
- function Ze() {
241
+ function ft() {
144
242
  return /* @__PURE__ */ new Map();
145
243
  }
146
- function et(t = !0) {
147
- const r = H(ce);
148
- if (r === null)
244
+ function pt(t = !0) {
245
+ const a = V(fe);
246
+ if (a === null)
149
247
  return [!0, null];
150
- const { isPresent: s, onExitComplete: n, register: i } = r, a = _();
151
- re(() => {
248
+ const { isPresent: s, onExitComplete: n, register: r } = a, i = H();
249
+ ie(() => {
152
250
  if (t)
153
- return i(a);
251
+ return r(i);
154
252
  }, [t]);
155
- const l = Ee(() => t && n && n(a), [a, n, t]);
156
- return !s && n ? [!1, l] : [!0];
253
+ const o = ke(() => t && n && n(i), [i, n, t]);
254
+ return !s && n ? [!1, o] : [!0];
157
255
  }
158
- const I = (t) => t.key || "";
159
- function te(t) {
160
- const r = [];
161
- return De.forEach(t, (s) => {
162
- Ne(s) && r.push(s);
163
- }), r;
256
+ const R = (t) => t.key || "";
257
+ function ne(t) {
258
+ const a = [];
259
+ return Ee.forEach(t, (s) => {
260
+ Ie(s) && a.push(s);
261
+ }), a;
164
262
  }
165
- const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presenceAffectsLayout: i = !0, mode: a = "sync", propagate: l = !1, anchorX: u = "left", root: f }) => {
166
- const [d, y] = et(l), h = F(() => te(t), [t]), x = l && !d ? [] : h.map(I), p = N(!0), k = N(h), m = le(() => /* @__PURE__ */ new Map()), [K, o] = D(h), [c, j] = D(h);
167
- He(() => {
168
- p.current = !1, k.current = h;
169
- for (let C = 0; C < c.length; C++) {
170
- const g = I(c[C]);
171
- x.includes(g) ? m.delete(g) : m.get(g) !== !0 && m.set(g, !1);
263
+ const ht = ({ children: t, custom: a, initial: s = !0, onExitComplete: n, presenceAffectsLayout: r = !0, mode: i = "sync", propagate: o = !1, anchorX: d = "left", root: c }) => {
264
+ const [u, p] = pt(o), f = L(() => ne(t), [t]), m = o && !u ? [] : f.map(R), g = A(!0), j = A(f), l = ue(() => /* @__PURE__ */ new Map()), [x, v] = I(f), [h, C] = I(f);
265
+ nt(() => {
266
+ g.current = !1, j.current = f;
267
+ for (let w = 0; w < h.length; w++) {
268
+ const y = R(h[w]);
269
+ m.includes(y) ? l.delete(y) : l.get(y) !== !0 && l.set(y, !1);
172
270
  }
173
- }, [c, x.length, x.join("-")]);
174
- const w = [];
175
- if (h !== K) {
176
- let C = [...h];
177
- for (let g = 0; g < c.length; g++) {
178
- const E = c[g], z = I(E);
179
- x.includes(z) || (C.splice(g, 0, E), w.push(E));
271
+ }, [h, m.length, m.join("-")]);
272
+ const K = [];
273
+ if (f !== x) {
274
+ let w = [...f];
275
+ for (let y = 0; y < h.length; y++) {
276
+ const b = h[y], $ = R(b);
277
+ m.includes($) || (w.splice(y, 0, b), K.push(b));
180
278
  }
181
- return a === "wait" && w.length && (C = w), j(te(C)), o(h), null;
279
+ return i === "wait" && K.length && (w = K), C(ne(w)), v(f), null;
182
280
  }
183
- process.env.NODE_ENV !== "production" && a === "wait" && c.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
184
- const { forceRender: b } = H(Qe);
185
- return e.jsx(e.Fragment, { children: c.map((C) => {
186
- const g = I(C), E = l && !d ? !1 : h === c || x.includes(g), z = () => {
187
- if (m.has(g))
188
- m.set(g, !0);
281
+ process.env.NODE_ENV !== "production" && i === "wait" && h.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
282
+ const { forceRender: pe } = V(tt);
283
+ return e.jsx(e.Fragment, { children: h.map((w) => {
284
+ const y = R(w), b = o && !u ? !1 : f === h || m.includes(y), $ = () => {
285
+ if (l.has(y))
286
+ l.set(y, !0);
189
287
  else
190
288
  return;
191
289
  let X = !0;
192
- m.forEach((de) => {
193
- de || (X = !1);
194
- }), X && (b?.(), j(k.current), l && y?.(), n && n());
290
+ l.forEach((he) => {
291
+ he || (X = !1);
292
+ }), X && (pe?.(), C(j.current), o && p?.(), n && n());
195
293
  };
196
- return e.jsx(Ye, { isPresent: E, initial: !p.current || s ? void 0 : !1, custom: r, presenceAffectsLayout: i, mode: a, root: f, onExitComplete: E ? void 0 : z, anchorX: u, children: C }, g);
294
+ return e.jsx(ut, { isPresent: b, initial: !g.current || s ? void 0 : !1, custom: a, presenceAffectsLayout: r, mode: i, root: c, onExitComplete: b ? void 0 : $, anchorX: d, children: w }, y);
197
295
  }) });
198
- }, st = ({
199
- service: t,
200
- onOpenChange: r
296
+ }, mt = ({
297
+ apiKey: t,
298
+ onDeleteKey: a,
299
+ className: s
201
300
  }) => {
202
- const s = ne(), n = ie(), i = je(), a = ze({
203
- defaultValues: {
204
- expiresOn: "30"
205
- }
206
- }), l = Fe(), u = T({
207
- mutationFn: ({ description: f, expiresOn: d }) => {
208
- if (!t.createKey)
209
- throw new Error("createKey not implemented");
210
- const y = d !== "never" ? nt(Number(d)) : void 0;
211
- return t.createKey({
212
- apiKey: {
213
- description: f || "Secret Key",
214
- expiresOn: y
215
- },
216
- context: s,
217
- auth: l
218
- });
219
- },
220
- onSuccess: async () => {
221
- await n.invalidateQueries({ queryKey: ["api-keys"] }), await i("/settings/api-keys/");
222
- }
223
- });
224
- return t.createKey ? /* @__PURE__ */ e.jsxs(
225
- "form",
226
- {
227
- onSubmit: a.handleSubmit(
228
- (f) => u.mutate(
229
- { ...f },
230
- {
231
- onSuccess: () => r(!1)
232
- }
233
- )
301
+ const [n, r] = I(!1), { key: i, createdOn: o, expiresOn: d } = t, c = d && new Date(d) < /* @__PURE__ */ new Date(), u = d ? Math.ceil(
302
+ (new Date(d).getTime() - Date.now()) / (1e3 * 60 * 60 * 24)
303
+ ) : 1 / 0, p = u <= 7 && !c;
304
+ return /* @__PURE__ */ e.jsxs("div", { className: W("grid col-span-full grid-cols-subgrid p-6", s), children: [
305
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
306
+ /* @__PURE__ */ e.jsx(
307
+ _e,
308
+ {
309
+ className: "max-w-fit w-full",
310
+ secret: i,
311
+ status: c ? "expired" : p ? "expiring" : "active",
312
+ revealed: n,
313
+ onReveal: r
314
+ }
234
315
  ),
235
- children: [
236
- u.error && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
237
- /* @__PURE__ */ e.jsx(M, { children: "Error" }),
238
- /* @__PURE__ */ e.jsx(Pe, { children: u.error.message })
316
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1 mt-0.5 text-nowrap", children: [
317
+ o && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground", children: [
318
+ "Created ",
319
+ xt(o),
320
+ "."
239
321
  ] }),
240
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 flex-col text-sm font-medium", children: [
241
- "Name",
242
- /* @__PURE__ */ e.jsx(oe, { ...a.register("description") }),
243
- "Expiration",
244
- /* @__PURE__ */ e.jsxs(
245
- Re,
322
+ " ",
323
+ d && p && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
324
+ "Expires in ",
325
+ u,
326
+ " ",
327
+ u === 1 ? "day" : "days",
328
+ "."
329
+ ] }),
330
+ d && c && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
331
+ "Expired",
332
+ " ",
333
+ u === 0 ? "today." : `${u * -1} days ago.`
334
+ ] })
335
+ ] })
336
+ ] }),
337
+ /* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: d && a && /* @__PURE__ */ e.jsxs(B, { children: [
338
+ /* @__PURE__ */ e.jsx(Z, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "ghost", size: "icon", children: /* @__PURE__ */ e.jsx(me, { size: 16 }) }) }),
339
+ /* @__PURE__ */ e.jsxs(G, { children: [
340
+ /* @__PURE__ */ e.jsxs(J, { children: [
341
+ /* @__PURE__ */ e.jsx(Y, { children: "Delete API Key" }),
342
+ /* @__PURE__ */ e.jsx(oe, { children: "Are you sure you want to delete this API key?" })
343
+ ] }),
344
+ /* @__PURE__ */ e.jsxs(_, { children: [
345
+ /* @__PURE__ */ e.jsx(S, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "outline", children: "Cancel" }) }),
346
+ /* @__PURE__ */ e.jsx(S, { asChild: !0, children: /* @__PURE__ */ e.jsx(
347
+ k,
246
348
  {
247
- onValueChange: (f) => a.setValue("expiresOn", f),
248
- defaultValue: a.getValues("expiresOn"),
249
- children: [
250
- /* @__PURE__ */ e.jsx(Se, { children: /* @__PURE__ */ e.jsx(Te, {}) }),
251
- /* @__PURE__ */ e.jsx(Oe, { children: /* @__PURE__ */ e.jsxs(Me, { children: [
252
- [7, 30, 60, 90].map((f) => /* @__PURE__ */ e.jsxs(Z, { value: String(f), children: [
253
- f,
254
- " days"
255
- ] }, f)),
256
- /* @__PURE__ */ e.jsx(Z, { value: "never", children: "Never" })
257
- ] }) })
258
- ]
349
+ onClick: () => {
350
+ a();
351
+ },
352
+ children: "Delete"
259
353
  }
260
- ),
261
- /* @__PURE__ */ e.jsxs(V, { children: [
262
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "outline", children: "Cancel" }) }),
263
- /* @__PURE__ */ e.jsx($e, { isPending: u.isPending, children: "Generate Key" })
264
- ] })
354
+ ) })
265
355
  ] })
266
- ]
267
- }
268
- ) : null;
269
- }, nt = (t) => {
270
- const r = /* @__PURE__ */ new Date();
271
- return r.setDate(r.getDate() + t), r.toISOString();
272
- }, se = ({
273
- service: t,
274
- isOpen: r,
275
- onOpenChange: s,
276
- trigger: n,
277
- buttonVariant: i = "outline"
278
- }) => {
279
- const a = /* @__PURE__ */ e.jsx(v, { variant: i, children: "Create API Key" });
280
- return /* @__PURE__ */ e.jsxs(B, { open: r, onOpenChange: s, children: [
281
- /* @__PURE__ */ e.jsx(G, { asChild: !0, children: n ?? a }),
282
- /* @__PURE__ */ e.jsxs(J, { children: [
283
- /* @__PURE__ */ e.jsx(U, { children: /* @__PURE__ */ e.jsx(W, { children: "Create API Key" }) }),
284
- /* @__PURE__ */ e.jsx(st, { service: t, onOpenChange: s })
285
- ] })
356
+ ] })
357
+ ] }) })
286
358
  ] });
287
- }, it = ({ service: t }) => {
288
- const r = ne(), s = ie(), [n, i] = D(
289
- null
290
- ), [a, l] = D(""), { data: u, isFetching: f } = we({
291
- queryFn: () => t.getConsumers(r),
292
- queryKey: ["api-keys"],
293
- retry: !1
294
- }), [d, y] = D(!1), h = T({
359
+ }, xt = (t) => {
360
+ const a = /* @__PURE__ */ new Date(), s = new Date(t), n = Math.floor((a.getTime() - s.getTime()) / 1e3), r = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
361
+ return n < 60 ? r.format(-n, "second") : n < 3600 ? r.format(-Math.floor(n / 60), "minute") : n < 86400 ? r.format(-Math.floor(n / 3600), "hour") : n < 2592e3 ? r.format(-Math.floor(n / 86400), "day") : n < 31536e3 ? r.format(-Math.floor(n / 2592e3), "month") : r.format(-Math.floor(n / 31536e3), "year");
362
+ }, yt = ({
363
+ consumer: t,
364
+ onUpdate: a,
365
+ onRollKey: s,
366
+ onDeleteKey: n
367
+ }) => {
368
+ const [r, i] = I(!1), [o, d] = I(t.label), c = ce(), u = U(), p = q({
369
+ mutationFn: async (l) => {
370
+ if (!s)
371
+ throw new Error("rollKey not implemented");
372
+ return await s?.(l, u);
373
+ },
374
+ onSuccess: () => void c.invalidateQueries({ queryKey: ["api-keys"] })
375
+ }), f = q({
295
376
  mutationFn: ({
296
- consumerId: o,
297
- keyId: c
377
+ consumerId: l,
378
+ keyId: x
298
379
  }) => {
299
- if (!t.deleteKey)
380
+ if (!n)
300
381
  throw new Error("deleteKey not implemented");
301
- return t.deleteKey(o, c, r);
382
+ return n(l, x, u);
302
383
  },
303
- onMutate: async ({ consumerId: o, keyId: c }) => {
304
- await s.cancelQueries({ queryKey: ["api-keys"] });
305
- const j = s.getQueryData([
384
+ onMutate: async ({ consumerId: l, keyId: x }) => {
385
+ await c.cancelQueries({ queryKey: ["api-keys"] });
386
+ const v = c.getQueryData([
306
387
  "api-keys"
307
388
  ]);
308
- return s.setQueryData(["api-keys"], (w) => w && w.map((b) => b.id === o ? {
309
- ...b,
310
- apiKeys: b.apiKeys.filter((C) => C.id !== c)
311
- } : b)), { previousData: j };
389
+ return c.setQueryData(["api-keys"], (h) => h && h.map((C) => C.id === l ? {
390
+ ...C,
391
+ apiKeys: C.apiKeys.filter((K) => K.id !== x)
392
+ } : C)), { previousData: v };
312
393
  },
313
- onError: (o, c, j) => {
314
- j?.previousData && s.setQueryData(["api-keys"], j.previousData);
394
+ onError: (l, x, v) => {
395
+ v?.previousData && c.setQueryData(["api-keys"], v.previousData);
315
396
  },
316
397
  onSuccess: () => {
317
- s.invalidateQueries({ queryKey: ["api-keys"] });
398
+ c.invalidateQueries({ queryKey: ["api-keys"] });
318
399
  }
319
- }), x = T({
400
+ }), m = q({
320
401
  mutationFn: ({
321
- consumerId: o,
322
- label: c
402
+ consumerId: l,
403
+ label: x
323
404
  }) => {
324
- if (!t.updateConsumer)
405
+ if (!a)
325
406
  throw new Error("updateConsumer not implemented");
326
- return t.updateConsumer({ id: o, label: c }, r);
407
+ return a({ id: l, label: x }, u);
327
408
  },
328
- onMutate: async ({ consumerId: o, label: c }) => {
329
- await s.cancelQueries({ queryKey: ["api-keys"] });
330
- const j = s.getQueryData(["api-keys"]);
331
- return s.setQueryData(["api-keys"], (w) => w && w.map((b) => b.id === o ? {
332
- ...b,
333
- label: c
334
- } : b)), { previousData: j };
409
+ onMutate: async ({ consumerId: l, label: x }) => {
410
+ await c.cancelQueries({ queryKey: ["api-keys"] });
411
+ const v = c.getQueryData(["api-keys"]);
412
+ return c.setQueryData(["api-keys"], (h) => h && h.map((C) => C.id === l ? {
413
+ ...C,
414
+ label: x
415
+ } : C)), { previousData: v };
335
416
  },
336
- onError: (o, c, j) => {
337
- j?.previousData && s.setQueryData(["api-keys"], j.previousData);
417
+ onError: (l, x, v) => {
418
+ v?.previousData && c.setQueryData(["api-keys"], v.previousData);
338
419
  },
339
420
  onSuccess: () => {
340
- s.invalidateQueries({ queryKey: ["api-keys"] });
421
+ c.invalidateQueries({ queryKey: ["api-keys"] });
341
422
  }
342
- }), p = T({
343
- mutationFn: (o) => {
344
- if (!t.rollKey)
345
- throw new Error("rollKey not implemented");
346
- return t.rollKey(o, r);
347
- },
348
- onSuccess: () => s.invalidateQueries({ queryKey: ["api-keys"] })
349
- }), k = (o, c) => {
350
- i(o), l(c);
351
- }, m = (o) => {
352
- a.trim() && x.mutate({
353
- consumerId: o,
354
- label: a.trim()
355
- }), i(null), l("");
356
- }, K = () => {
357
- i(null), l("");
423
+ }), g = () => {
424
+ i(!0), d(t.label);
425
+ }, j = () => {
426
+ o.trim() && m.mutate({
427
+ label: o.trim(),
428
+ consumerId: t.id
429
+ }), i(!1);
358
430
  };
359
- return /* @__PURE__ */ e.jsxs("div", { className: "max-w-screen-md h-full pt-(--padding-content-top) pb-(--padding-content-bottom)", children: [
360
- /* @__PURE__ */ e.jsx(Y.Target, { name: "api-keys-list-page" }),
361
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between pb-3", children: [
362
- /* @__PURE__ */ e.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
363
- t.createKey && /* @__PURE__ */ e.jsx(
364
- se,
365
- {
366
- service: t,
367
- isOpen: d,
368
- onOpenChange: y
369
- }
370
- )
371
- ] }),
372
- /* @__PURE__ */ e.jsx("p", { children: "Create, manage, and monitor your API keys" }),
373
- /* @__PURE__ */ e.jsx(Y.Target, { name: "api-keys-list-page-before-keys" }),
374
- /* @__PURE__ */ e.jsx("div", { className: "h-8" }),
375
- p.isError && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
376
- /* @__PURE__ */ e.jsx($, { size: 16 }),
377
- /* @__PURE__ */ e.jsx(M, { children: p.error.message })
431
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
432
+ p.isError && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
433
+ /* @__PURE__ */ e.jsx(z, { size: 16 }),
434
+ /* @__PURE__ */ e.jsx(P, { children: p.error.message })
378
435
  ] }),
379
- x.isError && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
380
- /* @__PURE__ */ e.jsx($, { size: 16 }),
381
- /* @__PURE__ */ e.jsx(M, { children: x.error.message })
436
+ m.isError && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
437
+ /* @__PURE__ */ e.jsx(z, { size: 16 }),
438
+ /* @__PURE__ */ e.jsx(P, { children: m.error.message })
382
439
  ] }),
383
- h.isError && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
384
- /* @__PURE__ */ e.jsx($, { size: 16 }),
385
- /* @__PURE__ */ e.jsx(M, { children: h.error.message })
440
+ f.isError && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
441
+ /* @__PURE__ */ e.jsx(z, { size: 16 }),
442
+ /* @__PURE__ */ e.jsx(P, { children: f.error.message })
386
443
  ] }),
387
- /* @__PURE__ */ e.jsx("div", { className: "", children: u.length === 0 ? /* @__PURE__ */ e.jsxs("div", { className: "flex col-span-full flex-col justify-center gap-4 items-center p-8 border rounded-sm bg-muted/30 text-muted-foreground", children: [
388
- /* @__PURE__ */ e.jsxs("p", { className: "text-center", children: [
389
- "You have no API keys yet.",
390
- /* @__PURE__ */ e.jsx("br", {}),
391
- t.createKey && "Get started and create your first key."
392
- ] }),
393
- t.createKey && /* @__PURE__ */ e.jsx(
394
- se,
395
- {
396
- service: t,
397
- isOpen: d,
398
- onOpenChange: y
399
- }
400
- )
401
- ] }) : /* @__PURE__ */ e.jsx(
402
- "ul",
444
+ /* @__PURE__ */ e.jsxs(
445
+ Pe,
403
446
  {
404
- className: L(
405
- "grid grid-cols-[1fr_min-content] divide-y divide-border col-span-6"
406
- ),
407
- children: u.map((o) => /* @__PURE__ */ e.jsxs(
408
- Ae,
409
- {
410
- className: "grid grid-cols-subgrid col-span-full items-center mb-4 group",
411
- children: [
412
- /* @__PURE__ */ e.jsxs(Ie, { className: "border-b col-span-full grid-cols-subgrid grid", children: [
413
- /* @__PURE__ */ e.jsxs("div", { className: "h-10 flex flex-col text-sm justify-center", children: [
414
- /* @__PURE__ */ e.jsxs("div", { className: "font-medium text-lg flex items-center gap-2", children: [
415
- n === o.id ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
447
+ className: "grid grid-cols-subgrid col-span-full items-center mb-4 group",
448
+ children: [
449
+ /* @__PURE__ */ e.jsxs(Ae, { className: "col-span-full flex-row items-start justify-between gap-4", children: [
450
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
451
+ r ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
452
+ /* @__PURE__ */ e.jsx(
453
+ Ue,
454
+ {
455
+ maxLength: 32,
456
+ value: o,
457
+ onChange: (l) => d(l.target.value),
458
+ onKeyDown: (l) => {
459
+ l.key === "Enter" ? j() : l.key === "Escape" && i(!1);
460
+ },
461
+ autoFocus: !0
462
+ }
463
+ ),
464
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center", children: [
465
+ /* @__PURE__ */ e.jsx(
466
+ k,
467
+ {
468
+ size: "icon",
469
+ variant: "ghost",
470
+ onClick: j,
471
+ disabled: !o.trim(),
472
+ children: /* @__PURE__ */ e.jsx(xe, { size: 16 })
473
+ }
474
+ ),
475
+ /* @__PURE__ */ e.jsx(
476
+ k,
477
+ {
478
+ size: "icon",
479
+ variant: "ghost",
480
+ onClick: () => i(!1),
481
+ children: /* @__PURE__ */ e.jsx(ye, { size: 16 })
482
+ }
483
+ )
484
+ ] })
485
+ ] }) : /* @__PURE__ */ e.jsx(Se, { children: t.label }),
486
+ /* @__PURE__ */ e.jsxs(Re, { children: [
487
+ t.createdOn && /* @__PURE__ */ e.jsxs("div", { children: [
488
+ "Created on ",
489
+ new Date(t.createdOn).toLocaleDateString()
490
+ ] }),
491
+ t.expiresOn && /* @__PURE__ */ e.jsxs("div", { children: [
492
+ "Expires on ",
493
+ new Date(t.expiresOn).toLocaleDateString()
494
+ ] })
495
+ ] })
496
+ ] }),
497
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
498
+ a && /* @__PURE__ */ e.jsxs(
499
+ k,
500
+ {
501
+ variant: "ghost",
502
+ onClick: g,
503
+ className: W(
504
+ "flex gap-2",
505
+ r && "opacity-0! pointer-events-none"
506
+ ),
507
+ disabled: r,
508
+ children: [
509
+ /* @__PURE__ */ e.jsx(ge, { size: 16 }),
510
+ /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Edit label" })
511
+ ]
512
+ }
513
+ ),
514
+ s && /* @__PURE__ */ e.jsxs(B, { children: [
515
+ /* @__PURE__ */ e.jsx(Z, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
516
+ k,
517
+ {
518
+ title: "Roll this key",
519
+ variant: "ghost",
520
+ disabled: p.isPending,
521
+ className: "flex items-center gap-2",
522
+ children: [
416
523
  /* @__PURE__ */ e.jsx(
417
- oe,
524
+ je,
418
525
  {
419
- maxLength: 32,
420
- value: a,
421
- onChange: (c) => l(c.target.value),
422
- onKeyDown: (c) => {
423
- c.key === "Enter" ? m(o.id) : c.key === "Escape" && K();
424
- },
425
- className: "text-lg font-medium",
426
- autoFocus: !0
526
+ size: 16,
527
+ className: p.isPending ? "animate-spin" : void 0
427
528
  }
428
529
  ),
429
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center", children: [
430
- /* @__PURE__ */ e.jsx(
431
- v,
432
- {
433
- size: "icon",
434
- variant: "ghost",
435
- onClick: () => m(o.id),
436
- disabled: !a.trim(),
437
- children: /* @__PURE__ */ e.jsx(ue, { size: 16 })
438
- }
439
- ),
440
- /* @__PURE__ */ e.jsx(
441
- v,
442
- {
443
- size: "icon",
444
- variant: "ghost",
445
- onClick: K,
446
- children: /* @__PURE__ */ e.jsx(fe, { size: 16 })
447
- }
448
- )
449
- ] })
450
- ] }) : o.label,
451
- /* @__PURE__ */ e.jsx("div", { className: "text-muted-foreground text-xs", children: o.createdOn })
530
+ /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Roll key" })
531
+ ]
532
+ }
533
+ ) }),
534
+ /* @__PURE__ */ e.jsxs(G, { children: [
535
+ /* @__PURE__ */ e.jsxs(J, { children: [
536
+ /* @__PURE__ */ e.jsx(Y, { children: "Roll API Key" }),
537
+ /* @__PURE__ */ e.jsx(oe, { children: "Are you sure you want to roll this API key?" })
452
538
  ] }),
453
- /* @__PURE__ */ e.jsxs("div", { className: "text-muted-foreground text-xs", children: [
454
- o.createdOn && /* @__PURE__ */ e.jsxs("div", { children: [
455
- "Created on",
456
- " ",
457
- new Date(o.createdOn).toLocaleDateString()
458
- ] }),
459
- o.expiresOn && /* @__PURE__ */ e.jsxs("div", { children: [
460
- "Expires on",
461
- " ",
462
- new Date(o.expiresOn).toLocaleDateString()
463
- ] })
464
- ] })
465
- ] }),
466
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end", children: [
467
- t.updateConsumer && /* @__PURE__ */ e.jsxs(
468
- v,
469
- {
470
- variant: "ghost",
471
- onClick: () => k(o.id, o.label),
472
- className: L(
473
- "flex gap-2",
474
- n === o.id && "opacity-0! pointer-events-none"
475
- ),
476
- disabled: n === o.id,
477
- children: [
478
- /* @__PURE__ */ e.jsx(he, { size: 16 }),
479
- /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Edit label" })
480
- ]
481
- }
482
- ),
483
- t.rollKey && /* @__PURE__ */ e.jsxs(B, { children: [
484
- /* @__PURE__ */ e.jsx(G, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
485
- v,
539
+ /* @__PURE__ */ e.jsxs(_, { children: [
540
+ /* @__PURE__ */ e.jsx(S, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "outline", children: "Cancel" }) }),
541
+ /* @__PURE__ */ e.jsx(S, { asChild: !0, children: /* @__PURE__ */ e.jsx(
542
+ k,
486
543
  {
487
- title: "Roll this key",
488
- variant: "ghost",
489
- disabled: p.isPending,
490
- className: "flex items-center gap-2",
491
- children: [
492
- /* @__PURE__ */ e.jsx(
493
- pe,
494
- {
495
- size: 16,
496
- className: p.isPending ? "animate-spin" : void 0
497
- }
498
- ),
499
- /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Roll key" })
500
- ]
544
+ onClick: () => {
545
+ p.mutate(t.id);
546
+ },
547
+ children: "Roll Key"
501
548
  }
502
- ) }),
503
- /* @__PURE__ */ e.jsxs(J, { children: [
504
- /* @__PURE__ */ e.jsxs(U, { children: [
505
- /* @__PURE__ */ e.jsx(W, { children: "Roll API Key" }),
506
- /* @__PURE__ */ e.jsx(ae, { children: "Are you sure you want to roll this API key?" })
507
- ] }),
508
- /* @__PURE__ */ e.jsxs(V, { children: [
509
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "outline", children: "Cancel" }) }),
510
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(
511
- v,
512
- {
513
- onClick: () => {
514
- p.mutate(o.id);
515
- },
516
- children: "Roll Key"
517
- }
518
- ) })
519
- ] })
520
- ] })
549
+ ) })
521
550
  ] })
522
551
  ] })
523
- ] }),
524
- /* @__PURE__ */ e.jsx("div", { className: "col-span-full grid-cols-subgrid grid", children: /* @__PURE__ */ e.jsx(tt, { children: o.apiKeys.map((c) => /* @__PURE__ */ e.jsxs(ke.Fragment, { children: [
525
- /* @__PURE__ */ e.jsx(
526
- at,
527
- {
528
- apiKey: c,
529
- onDeleteKey: () => {
530
- h.mutate({
531
- consumerId: o.id,
532
- keyId: c.id
533
- });
534
- },
535
- className: h.variables?.keyId === c.id && (h.isPending || f) ? "opacity-10!" : void 0
536
- }
537
- ),
538
- /* @__PURE__ */ e.jsx("div", { className: "col-span-full h-px bg-border" })
539
- ] }, c.id)) }) })
540
- ]
541
- },
542
- o.id
543
- ))
544
- }
545
- ) })
552
+ ] })
553
+ ] })
554
+ ] }),
555
+ /* @__PURE__ */ e.jsx(Ne, { className: "p-0 grid grid-cols-subgrid col-span-full divide-y divide-border", children: /* @__PURE__ */ e.jsx(ht, { children: t.apiKeys.map((l) => /* @__PURE__ */ e.jsx(
556
+ mt,
557
+ {
558
+ apiKey: l,
559
+ onDeleteKey: () => {
560
+ f.mutate({
561
+ consumerId: t.id,
562
+ keyId: l.id
563
+ });
564
+ },
565
+ className: f.variables?.keyId === l.id && f.isPending ? "opacity-10!" : void 0
566
+ },
567
+ l.id
568
+ )) }) })
569
+ ]
570
+ },
571
+ t.id
572
+ )
546
573
  ] });
547
- }, rt = (t) => {
548
- const r = /* @__PURE__ */ new Date(), s = new Date(t), n = Math.floor((r.getTime() - s.getTime()) / 1e3), i = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
549
- return n < 60 ? i.format(-n, "second") : n < 3600 ? i.format(-Math.floor(n / 60), "minute") : n < 86400 ? i.format(-Math.floor(n / 3600), "hour") : n < 2592e3 ? i.format(-Math.floor(n / 86400), "day") : n < 31536e3 ? i.format(-Math.floor(n / 2592e3), "month") : i.format(-Math.floor(n / 31536e3), "year");
550
- }, at = ({
551
- apiKey: t,
552
- onDeleteKey: r,
553
- className: s
554
- }) => {
555
- const [n, i] = D(!1), { key: a, createdOn: l, expiresOn: u } = t, f = u && new Date(u) < /* @__PURE__ */ new Date(), d = u ? Math.ceil(
556
- (new Date(u).getTime() - Date.now()) / (1e3 * 60 * 60 * 24)
557
- ) : 1 / 0, y = d <= 7 && !f;
558
- return /* @__PURE__ */ e.jsxs("div", { className: L("grid col-span-full grid-cols-subgrid p-6", s), children: [
559
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
560
- /* @__PURE__ */ e.jsx(
561
- qe,
574
+ }, gt = ({ service: t }) => {
575
+ const a = U(), { data: s } = Be({
576
+ queryFn: async () => {
577
+ try {
578
+ return await t.getConsumers(a);
579
+ } catch (i) {
580
+ throw i instanceof M ? i : new M("Cannot get API keys", {
581
+ cause: i,
582
+ title: "Error getting API keys",
583
+ developerHint: "Check the response of the API request for more information."
584
+ });
585
+ }
586
+ },
587
+ queryKey: ["api-keys"],
588
+ retry: !1
589
+ }), [n, r] = I(!1);
590
+ return /* @__PURE__ */ e.jsx("div", { className: "mt-8", children: s.length === 0 ? /* @__PURE__ */ e.jsxs("div", { className: "flex col-span-full flex-col justify-center gap-4 items-center p-8 border rounded-sm bg-muted/30 text-muted-foreground", children: [
591
+ /* @__PURE__ */ e.jsxs("p", { className: "text-center", children: [
592
+ "You have no API keys yet.",
593
+ /* @__PURE__ */ e.jsx("br", {}),
594
+ t.createKey && "Get started and create your first key."
595
+ ] }),
596
+ t.createKey && /* @__PURE__ */ e.jsx(
597
+ de,
598
+ {
599
+ service: t,
600
+ isOpen: n,
601
+ onOpenChange: r
602
+ }
603
+ )
604
+ ] }) : /* @__PURE__ */ e.jsx("ul", { className: W("grid grid-cols-[1fr_min-content] col-span-6"), children: s.map((i) => /* @__PURE__ */ e.jsx(
605
+ yt,
606
+ {
607
+ consumer: i,
608
+ onUpdate: t.updateConsumer,
609
+ onRollKey: t.rollKey,
610
+ onDeleteKey: t.deleteKey
611
+ },
612
+ i.id
613
+ )) }) });
614
+ }, jt = ({ service: t }) => {
615
+ const [a, s] = I(!1), n = re();
616
+ return /* @__PURE__ */ e.jsxs("div", { className: "max-w-3xl h-full pt-(--padding-content-top) pb-(--padding-content-bottom)", children: [
617
+ /* @__PURE__ */ e.jsx(ee.Target, { name: "api-keys-list-page" }),
618
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between pb-3", children: [
619
+ /* @__PURE__ */ e.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
620
+ t.createKey && /* @__PURE__ */ e.jsx(
621
+ de,
562
622
  {
563
- className: "max-w-fit w-full",
564
- secret: a,
565
- status: f ? "expired" : y ? "expiring" : "active",
566
- revealed: n,
567
- onReveal: i
623
+ service: t,
624
+ isOpen: a,
625
+ onOpenChange: s
568
626
  }
569
- ),
570
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1 mt-0.5 text-nowrap", children: [
571
- l && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground", children: [
572
- "Created ",
573
- rt(l),
574
- "."
575
- ] }),
576
- " ",
577
- u && y && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
578
- "Expires in ",
579
- d,
580
- " ",
581
- d === 1 ? "day" : "days",
582
- "."
583
- ] }),
584
- u && f && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
585
- "Expired",
586
- " ",
587
- d === 0 ? "today." : `${d * -1} days ago.`
588
- ] })
589
- ] })
627
+ )
590
628
  ] }),
591
- /* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: u && r && /* @__PURE__ */ e.jsxs(B, { children: [
592
- /* @__PURE__ */ e.jsx(G, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "ghost", size: "icon", children: /* @__PURE__ */ e.jsx(me, { size: 16 }) }) }),
593
- /* @__PURE__ */ e.jsxs(J, { children: [
594
- /* @__PURE__ */ e.jsxs(U, { children: [
595
- /* @__PURE__ */ e.jsx(W, { children: "Delete API Key" }),
596
- /* @__PURE__ */ e.jsx(ae, { children: "Are you sure you want to delete this API key?" })
597
- ] }),
598
- /* @__PURE__ */ e.jsxs(V, { children: [
599
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "outline", children: "Cancel" }) }),
600
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(
601
- v,
602
- {
603
- onClick: () => {
604
- r();
605
- },
606
- children: "Delete"
607
- }
608
- ) })
609
- ] })
610
- ] })
611
- ] }) })
629
+ /* @__PURE__ */ e.jsx("p", { children: "Create, manage, and monitor your API keys" }),
630
+ /* @__PURE__ */ e.jsx(ee.Target, { name: "api-keys-list-page-before-keys" }),
631
+ n.profile?.emailVerified === !1 ? /* @__PURE__ */ e.jsxs(Oe, { variant: "outline", children: [
632
+ /* @__PURE__ */ e.jsxs(Te, { children: [
633
+ /* @__PURE__ */ e.jsx(qe, { children: "Verified email required" }),
634
+ /* @__PURE__ */ e.jsx(Me, { children: "You need to verify your email to access API keys." })
635
+ ] }),
636
+ /* @__PURE__ */ e.jsx(Fe, { children: /* @__PURE__ */ e.jsx(Ke, { onClick: () => n.requestEmailVerification(), children: "Verify email" }) })
637
+ ] }) : /* @__PURE__ */ e.jsx(
638
+ De,
639
+ {
640
+ fallbackRender: ({ error: r }) => /* @__PURE__ */ e.jsx(We, { error: r }),
641
+ children: /* @__PURE__ */ e.jsx(gt, { service: t })
642
+ }
643
+ )
612
644
  ] });
613
- }, R = "https://api.zuploedge.com/v2/client", ot = async (t) => {
645
+ }, N = "https://api.zuploedge.com/v2/client", vt = async (t) => {
614
646
  try {
615
647
  return await t.json();
616
648
  } catch {
617
649
  return;
618
650
  }
619
- }, S = async (t) => {
620
- const r = t.headers.get("content-type");
621
- if (!t.ok && r?.includes("application/problem+json")) {
622
- const s = await ot(t);
651
+ }, O = async (t) => {
652
+ const a = t.headers.get("content-type");
653
+ if (!t.ok && a?.includes("application/problem+json")) {
654
+ const s = await vt(t);
623
655
  if (s.type && s.title)
624
656
  throw new Error(s.detail ?? s.title);
625
657
  }
626
- }, lt = (t, r) => ({
627
- deleteKey: async (s, n, i) => {
628
- const a = new Request(
629
- R + `/${t}/consumers/${s}/keys/${n}`,
658
+ }, T = {
659
+ developerHint: "This project is not linked to a Zuplo deployment. Run `zuplo link` to get started with API Keys.",
660
+ title: "Not linked to a Zuplo deployment"
661
+ }, Ct = ({
662
+ deploymentName: t,
663
+ ...a
664
+ }) => ({
665
+ deleteKey: async (s, n, r) => {
666
+ E(t, "Cannot delete API key.", T);
667
+ const i = new Request(
668
+ N + `/${t}/consumers/${s}/keys/${n}`,
630
669
  {
631
670
  method: "DELETE"
632
671
  }
633
- );
634
- await i.signRequest(a);
635
- const l = await fetch(a);
636
- await S(l), A(l.ok, "Failed to delete API key");
672
+ ), o = await fetch(await r.signRequest(i));
673
+ await O(o), E(o.ok, "Failed to delete API key");
637
674
  },
638
675
  updateConsumer: async (s, n) => {
639
- const i = await fetch(
676
+ E(
677
+ t,
678
+ "Cannot update API key description.",
679
+ T
680
+ );
681
+ const r = await fetch(
640
682
  await n.signRequest(
641
683
  new Request(
642
- R + `/${t}/consumers/${s.id}`,
684
+ `${N}/${t}/consumers/${s.id}`,
643
685
  {
644
686
  method: "PATCH",
645
687
  headers: {
@@ -652,13 +694,14 @@ const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presen
652
694
  )
653
695
  )
654
696
  );
655
- await S(i), A(i.ok, "Failed to update API key description");
697
+ await O(r), E(r.ok, "Failed to update API key description");
656
698
  },
657
699
  rollKey: async (s, n) => {
658
- const i = await fetch(
700
+ E(t, "Cannot roll API key.", T);
701
+ const r = await fetch(
659
702
  await n.signRequest(
660
703
  new Request(
661
- R + `/${t}/consumers/${s}/roll-key`,
704
+ `${N}/${t}/consumers/${s}/roll-key`,
662
705
  {
663
706
  method: "POST",
664
707
  headers: {
@@ -669,42 +712,59 @@ const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presen
669
712
  )
670
713
  )
671
714
  );
672
- await S(i), A(i.ok, "Failed to delete API key");
715
+ await O(r), E(r.ok, "Failed to roll API key");
673
716
  },
674
717
  getConsumers: async (s) => {
718
+ E(t, "Cannot get API keys.", T);
675
719
  const n = new Request(
676
- `${R}/${t}/consumers`
720
+ `${N}/${t}/consumers`
677
721
  );
678
722
  await s.signRequest(n);
679
- const i = await fetch(n);
680
- return await S(i), A(i.ok, "Failed to fetch API keys"), (await i.json()).data.map((l) => ({
681
- id: l.id,
682
- label: l.label || l.subject || "API Key",
683
- apiKeys: l.apiKeys.data,
684
- key: l.apiKeys.data.at(0)
723
+ const r = await fetch(n);
724
+ return await O(r), E(r.ok, "Failed to fetch API keys"), (await r.json()).data.map((o) => ({
725
+ id: o.id,
726
+ createdOn: o.createdOn,
727
+ updatedOn: o.updatedOn,
728
+ expiresOn: o.expiresOn,
729
+ label: o.label || o.subject || "API Key",
730
+ apiKeys: o.apiKeys.data,
731
+ key: o.apiKeys.data.at(0)
685
732
  }));
686
733
  },
687
- ...r
688
- }), Pt = (t) => t, At = (t) => {
689
- const r = "deploymentName" in t ? lt(t.deploymentName, t) : t;
734
+ ...a
735
+ }), Ht = (t) => t, Vt = ({
736
+ deploymentName: t,
737
+ isZuplo: a,
738
+ ...s
739
+ }) => {
740
+ a && !t && console.warn(
741
+ "This project is not linked to a Zuplo deployment. Run `zuplo link` to get started."
742
+ );
743
+ const n = a ? Ct({ deploymentName: t, ...s }) : s;
744
+ if (!n.getConsumers)
745
+ throw new Error("getConsumers is required when using the apiKeyPlugin");
746
+ const r = {
747
+ ...n,
748
+ getConsumers: n.getConsumers
749
+ };
690
750
  return {
691
751
  getProfileMenuItems: () => [
692
752
  {
693
753
  label: "API Keys",
694
754
  path: "/settings/api-keys",
695
755
  category: "middle",
696
- icon: xe
756
+ icon: ve
697
757
  }
698
758
  ],
699
- getIdentities: async (s) => {
759
+ getIdentities: async (i) => {
700
760
  try {
701
- return (await r.getConsumers(s)).map((i) => ({
702
- authorizeRequest: (a) => (a.headers.set(
761
+ return (await r.getConsumers(i)).map((d) => ({
762
+ authorizeRequest: (c) => (c.headers.set(
703
763
  "Authorization",
704
- `Bearer ${i.apiKeys.at(0)?.key}`
705
- ), a),
706
- id: i.id,
707
- label: i.label
764
+ `Bearer ${d.apiKeys.at(0)?.key}`
765
+ ), c),
766
+ id: d.id,
767
+ label: d.label
708
768
  }));
709
769
  } catch {
710
770
  return [];
@@ -712,20 +772,15 @@ const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presen
712
772
  },
713
773
  getRoutes: () => [
714
774
  {
715
- element: /* @__PURE__ */ e.jsx(Le, {}),
716
- errorElement: /* @__PURE__ */ e.jsx(ye, {}),
717
- children: [
718
- {
719
- path: "/settings/api-keys",
720
- element: /* @__PURE__ */ e.jsx(it, { service: r })
721
- }
722
- ]
775
+ path: "/settings/api-keys",
776
+ element: /* @__PURE__ */ e.jsx(jt, { service: r })
723
777
  }
724
- ]
778
+ ],
779
+ getProtectedRoutes: () => ["/settings/api-keys"]
725
780
  };
726
781
  };
727
782
  export {
728
- At as apiKeyPlugin,
729
- Pt as createApiKeyService
783
+ Vt as apiKeyPlugin,
784
+ Ht as createApiKeyService
730
785
  };
731
786
  //# sourceMappingURL=zudoku.plugin-api-keys.js.map