zudoku 0.0.0-fix-firebase-export.f8270825 → 0.0.0-monetization-standalone.z07361713
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.
- package/dist/app/main.d.ts +6 -6
- package/dist/cli/common/version-check.js +12 -3
- package/dist/cli/common/version-check.js.map +1 -1
- package/dist/config/create-plugin.d.ts +2 -0
- package/dist/config/create-plugin.js +30 -0
- package/dist/config/create-plugin.js.map +1 -0
- package/dist/config/loader.js +3 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/config/validators/InputNavigationSchema.d.ts +77 -75
- package/dist/config/validators/InputNavigationSchema.js +1 -0
- package/dist/config/validators/InputNavigationSchema.js.map +1 -1
- package/dist/config/validators/NavigationSchema.js +6 -1
- package/dist/config/validators/NavigationSchema.js.map +1 -1
- package/dist/config/validators/ProtectedRoutesSchema.d.ts +1 -1
- package/dist/config/validators/validate.d.ts +61 -13
- package/dist/config/validators/validate.js +9 -4
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/flat-config.d.ts +29 -26
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/auth/issuer.js +1 -1
- package/dist/lib/auth/issuer.js.map +1 -1
- package/dist/lib/authentication/authentication.d.ts +3 -2
- package/dist/lib/authentication/components/CallbackHandler.js +1 -1
- package/dist/lib/authentication/components/CallbackHandler.js.map +1 -1
- package/dist/lib/authentication/components/SignIn.js +4 -2
- package/dist/lib/authentication/components/SignIn.js.map +1 -1
- package/dist/lib/authentication/components/SignUp.js +4 -2
- package/dist/lib/authentication/components/SignUp.js.map +1 -1
- package/dist/lib/authentication/hook.d.ts +2 -0
- package/dist/lib/authentication/hook.js +10 -0
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +11 -7
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/clerk.js +0 -22
- package/dist/lib/authentication/providers/clerk.js.map +1 -1
- package/dist/lib/authentication/providers/firebase.js +67 -9
- package/dist/lib/authentication/providers/firebase.js.map +1 -1
- package/dist/lib/authentication/providers/supabase.js +6 -15
- package/dist/lib/authentication/providers/supabase.js.map +1 -1
- package/dist/lib/authentication/ui/EmailVerificationUi.d.ts +4 -0
- package/dist/lib/authentication/ui/EmailVerificationUi.js +34 -0
- package/dist/lib/authentication/ui/EmailVerificationUi.js.map +1 -0
- package/dist/lib/authentication/ui/ZudokuAuthUi.d.ts +7 -2
- package/dist/lib/authentication/ui/ZudokuAuthUi.js +43 -11
- package/dist/lib/authentication/ui/ZudokuAuthUi.js.map +1 -1
- package/dist/lib/authentication/utils/relativeRedirectUrl.d.ts +1 -0
- package/dist/lib/authentication/utils/relativeRedirectUrl.js +8 -0
- package/dist/lib/authentication/utils/relativeRedirectUrl.js.map +1 -0
- package/dist/lib/components/Bootstrap.js +1 -2
- package/dist/lib/components/Bootstrap.js.map +1 -1
- package/dist/lib/components/Pagination.js +2 -2
- package/dist/lib/components/Pagination.js.map +1 -1
- package/dist/lib/components/Zudoku.js +2 -5
- package/dist/lib/components/Zudoku.js.map +1 -1
- package/dist/lib/components/context/ZudokuContext.d.ts +2 -4
- package/dist/lib/components/context/ZudokuContext.js +2 -2
- package/dist/lib/components/context/ZudokuContext.js.map +1 -1
- package/dist/lib/components/context/ZudokuProvider.js +1 -1
- package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
- package/dist/lib/components/context/ZudokuReactContext.d.ts +11 -0
- package/dist/lib/components/context/ZudokuReactContext.js +4 -0
- package/dist/lib/components/context/ZudokuReactContext.js.map +1 -0
- package/dist/lib/components/index.d.ts +5 -0
- package/dist/lib/components/index.js +4 -0
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/components/navigation/NavigationItem.js +2 -2
- package/dist/lib/components/navigation/NavigationItem.js.map +1 -1
- package/dist/lib/core/RouteGuard.js +12 -7
- package/dist/lib/core/RouteGuard.js.map +1 -1
- package/dist/lib/core/plugins.d.ts +11 -1
- package/dist/lib/core/plugins.js +1 -0
- package/dist/lib/core/plugins.js.map +1 -1
- package/dist/lib/core/react-query.d.ts +1 -0
- package/dist/lib/core/react-query.js +2 -0
- package/dist/lib/core/react-query.js.map +1 -0
- package/dist/lib/core/transform-config.d.ts +2 -0
- package/dist/lib/core/transform-config.js +22 -0
- package/dist/lib/core/transform-config.js.map +1 -0
- package/dist/lib/errors/ErrorAlert.js +1 -2
- package/dist/lib/errors/ErrorAlert.js.map +1 -1
- package/dist/lib/errors/ErrorMessage.d.ts +3 -0
- package/dist/lib/errors/ErrorMessage.js +16 -0
- package/dist/lib/errors/ErrorMessage.js.map +1 -0
- package/dist/lib/hooks/index.d.ts +2 -0
- package/dist/lib/oas/graphql/circular.d.ts +2 -0
- package/dist/lib/oas/graphql/circular.js +32 -10
- package/dist/lib/oas/graphql/circular.js.map +1 -1
- package/dist/lib/oas/graphql/circular.test.d.ts +1 -0
- package/dist/lib/oas/graphql/circular.test.js +152 -0
- package/dist/lib/oas/graphql/circular.test.js.map +1 -0
- package/dist/lib/oas/graphql/index.js +7 -3
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js +9 -172
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
- package/dist/lib/plugins/api-keys/index.d.ts +11 -4
- package/dist/lib/plugins/api-keys/index.js +36 -22
- package/dist/lib/plugins/api-keys/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/settings/ApiKeyItem.d.ts +12 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js +133 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js.map +1 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyList.d.ts +4 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyList.js +33 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyList.js.map +1 -0
- package/dist/lib/plugins/api-keys/settings/RevealApiKey.d.ts +6 -0
- package/dist/lib/plugins/api-keys/settings/RevealApiKey.js +39 -0
- package/dist/lib/plugins/api-keys/settings/RevealApiKey.js.map +1 -0
- package/dist/lib/plugins/openapi/OasProvider.js +6 -2
- package/dist/lib/plugins/openapi/OasProvider.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +4 -4
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/ParamInfos.js +1 -0
- package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +3 -2
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +3 -0
- package/dist/lib/plugins/openapi/schema/SchemaView.js +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/utils.js +11 -3
- package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
- package/dist/lib/plugins/openapi/util/createHttpSnippet.js +24 -1
- package/dist/lib/plugins/openapi/util/createHttpSnippet.js.map +1 -1
- package/dist/lib/plugins/openapi/util/getRoutes.d.ts +3 -0
- package/dist/lib/plugins/openapi/util/getRoutes.js +2 -1
- package/dist/lib/plugins/openapi/util/getRoutes.js.map +1 -1
- package/dist/lib/ui/Button.js +1 -1
- package/dist/lib/ui/Button.js.map +1 -1
- package/dist/lib/ui/Command.d.ts +3 -3
- package/dist/lib/ui/Secret.js +2 -2
- package/dist/lib/ui/Secret.js.map +1 -1
- package/dist/lib/util/invariant.d.ts +1 -1
- package/dist/lib/util/invariant.js +2 -2
- package/dist/lib/util/invariant.js.map +1 -1
- package/dist/vite/api/SchemaManager.d.ts +12 -1
- package/dist/vite/api/SchemaManager.js +31 -14
- package/dist/vite/api/SchemaManager.js.map +1 -1
- package/dist/vite/api/SchemaManager.test.js +44 -0
- package/dist/vite/api/SchemaManager.test.js.map +1 -1
- package/dist/vite/config.js +10 -4
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/error-handler.js +1 -5
- package/dist/vite/error-handler.js.map +1 -1
- package/dist/vite/mdx/remark-link-rewrite.js +1 -1
- package/dist/vite/plugin-api-keys.js +5 -1
- package/dist/vite/plugin-api-keys.js.map +1 -1
- package/dist/vite/plugin-api.js +5 -3
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-markdown-export.js +1 -1
- package/dist/vite/plugin-markdown-export.js.map +1 -1
- package/dist/vite/plugin-theme.js +2 -1
- package/dist/vite/plugin-theme.js.map +1 -1
- package/dist/vite/prerender/utils.js +9 -3
- package/dist/vite/prerender/utils.js.map +1 -1
- package/dist/vite/prerender/worker.js +3 -0
- package/dist/vite/prerender/worker.js.map +1 -1
- package/dist/vite/zuplo.d.ts +13 -0
- package/dist/vite/zuplo.js +15 -0
- package/dist/vite/zuplo.js.map +1 -0
- package/lib/{ActionButton-DUgvSylL.js → ActionButton-B0CXL1Lq.js} +3 -3
- package/lib/{ActionButton-DUgvSylL.js.map → ActionButton-B0CXL1Lq.js.map} +1 -1
- package/lib/{Button-CynVW1JV.js → Button-GUVe7pmt.js} +8 -7
- package/lib/{Button-CynVW1JV.js.map → Button-GUVe7pmt.js.map} +1 -1
- package/lib/{Card-KFniaZn5.js → Card-DCdq37aA.js} +2 -2
- package/lib/{Card-KFniaZn5.js.map → Card-DCdq37aA.js.map} +1 -1
- package/lib/{ClaudeLogo-B4Xxt-x_.js → ClaudeLogo-CUaQXKLK.js} +22 -22
- package/lib/ClaudeLogo-CUaQXKLK.js.map +1 -0
- package/lib/{Command-BpT1iBE6.js → Command-N6VujV30.js} +3 -3
- package/lib/{Command-BpT1iBE6.js.map → Command-N6VujV30.js.map} +1 -1
- package/lib/{Dialog-BQciPiHN.js → Dialog-hlvmmQ_c.js} +2 -2
- package/lib/{Dialog-BQciPiHN.js.map → Dialog-hlvmmQ_c.js.map} +1 -1
- package/lib/{Drawer-Ci7XwhqT.js → Drawer-Ch7927PF.js} +7 -7
- package/lib/{Drawer-Ci7XwhqT.js.map → Drawer-Ch7927PF.js.map} +1 -1
- package/lib/{DropdownMenu-C8SX_-S_.js → DropdownMenu-DN0jNrjj.js} +2 -2
- package/lib/{DropdownMenu-C8SX_-S_.js.map → DropdownMenu-DN0jNrjj.js.map} +1 -1
- package/lib/Frame-DKlOmSkU.js +205 -0
- package/lib/Frame-DKlOmSkU.js.map +1 -0
- package/lib/HydrationBoundary-CNF2ZV3E.js +601 -0
- package/lib/HydrationBoundary-CNF2ZV3E.js.map +1 -0
- package/lib/{IndexingDialog-B5zCiUKr.js → IndexingDialog-D0YdGfbn.js} +3 -3
- package/lib/{IndexingDialog-B5zCiUKr.js.map → IndexingDialog-D0YdGfbn.js.map} +1 -1
- package/lib/Input-Cx-GeKoF.js +22 -0
- package/lib/Input-Cx-GeKoF.js.map +1 -0
- package/lib/{MdxPage-BagO2c-n.js → MdxPage-BiAVpP8K.js} +11 -11
- package/lib/{MdxPage-BagO2c-n.js.map → MdxPage-BiAVpP8K.js.map} +1 -1
- package/lib/{Mermaid-D_VSX7_Q.js → Mermaid-DEztDKFw.js} +4 -4
- package/lib/{Mermaid-D_VSX7_Q.js.map → Mermaid-DEztDKFw.js.map} +1 -1
- package/lib/{OAuthErrorPage-Fq54RLgt.js → OAuthErrorPage-DhJo-O2B.js} +15 -15
- package/lib/OAuthErrorPage-DhJo-O2B.js.map +1 -0
- package/lib/OasProvider-DFMZwyNn.js +48 -0
- package/lib/OasProvider-DFMZwyNn.js.map +1 -0
- package/lib/{OperationList-C0jiEaG5.js → OperationList-CnmLfOuu.js} +1560 -1545
- package/lib/{OperationList-C0jiEaG5.js.map → OperationList-CnmLfOuu.js.map} +1 -1
- package/lib/RouteGuard-CZuPjknT.js +77 -0
- package/lib/RouteGuard-CZuPjknT.js.map +1 -0
- package/lib/{SchemaList-BU0zCHn9.js → SchemaList-B5ikunUd.js} +9 -9
- package/lib/{SchemaList-BU0zCHn9.js.map → SchemaList-B5ikunUd.js.map} +1 -1
- package/lib/SchemaView-rjji7zMf.js +438 -0
- package/lib/SchemaView-rjji7zMf.js.map +1 -0
- package/lib/{Select-CkxXP5I7.js → Secret-BE7V0Vb5.js} +159 -139
- package/lib/Secret-BE7V0Vb5.js.map +1 -0
- package/lib/{Separator-CTPSeW1S.js → Separator-BXt1LYnm.js} +2 -2
- package/lib/{Separator-CTPSeW1S.js.map → Separator-BXt1LYnm.js.map} +1 -1
- package/lib/SignUp-DHWDXat-.js +50 -0
- package/lib/SignUp-DHWDXat-.js.map +1 -0
- package/lib/{SyntaxHighlight-Kdyskw3C.js → SyntaxHighlight-paLQ8NP8.js} +1751 -1725
- package/lib/SyntaxHighlight-paLQ8NP8.js.map +1 -0
- package/lib/{Toc-DJxFPfcS.js → Toc-vMbSQCkj.js} +3 -3
- package/lib/{Toc-DJxFPfcS.js.map → Toc-vMbSQCkj.js.map} +1 -1
- package/lib/ZudokuContext-CnEI8jPU.js +389 -0
- package/lib/ZudokuContext-CnEI8jPU.js.map +1 -0
- package/lib/{___vite-browser-external_commonjs-proxy-Cga3HsWk.js → ___vite-browser-external_commonjs-proxy-BttVsNON.js} +2 -2
- package/lib/___vite-browser-external_commonjs-proxy-BttVsNON.js.map +1 -0
- package/lib/chunk-EPOLDU6W-C6C8jAwd.js +8558 -0
- package/lib/chunk-EPOLDU6W-C6C8jAwd.js.map +1 -0
- package/lib/{circular-CzWF1hj5.js → circular-CLhJAE3S.js} +771 -749
- package/lib/{circular-CzWF1hj5.js.map → circular-CLhJAE3S.js.map} +1 -1
- package/lib/{cn-dYga0KKN.js → cn-5-Gd1Dss.js} +531 -498
- package/lib/cn-5-Gd1Dss.js.map +1 -0
- package/lib/{createServer-BIr2_tGn.js → createServer-BYtu5Pcr.js} +12 -12
- package/lib/{createServer-BIr2_tGn.js.map → createServer-BYtu5Pcr.js.map} +1 -1
- package/lib/createVariantComponent-Dc0vtOvr.js +18 -0
- package/lib/createVariantComponent-Dc0vtOvr.js.map +1 -0
- package/lib/{errors-Bs4duWDy.js → errors-DkJIl45d.js} +3 -3
- package/lib/{errors-Bs4duWDy.js.map → errors-DkJIl45d.js.map} +1 -1
- package/lib/{firebase-qUdSEL1p.js → firebase-CmsW0j7-.js} +1590 -1342
- package/lib/firebase-CmsW0j7-.js.map +1 -0
- package/lib/hook-Da8QTnPd.js +52 -0
- package/lib/hook-Da8QTnPd.js.map +1 -0
- package/lib/{index-Css56y3F.js → index-Ba6RP577.js} +4 -4
- package/lib/{index-Css56y3F.js.map → index-Ba6RP577.js.map} +1 -1
- package/lib/index-CrcNWbel.js.map +1 -1
- package/lib/{index-Bh-MffiL.js → index-D35F-SCL.js} +2 -2
- package/lib/{index-Bh-MffiL.js.map → index-D35F-SCL.js.map} +1 -1
- package/lib/{index-0oT9beQN.js → index-k0PVZBYl.js} +155 -151
- package/lib/{index-0oT9beQN.js.map → index-k0PVZBYl.js.map} +1 -1
- package/lib/{ErrorAlert-DrOR8w3f.js → index-ofqkdEjL.js} +5457 -4444
- package/lib/index-ofqkdEjL.js.map +1 -0
- package/lib/index.esm-BYObtETB.js.map +1 -1
- package/lib/{index.esm-DtzT_KoE.js → index.esm-B_0dvNjB.js} +2 -2
- package/lib/{index.esm-DtzT_KoE.js.map → index.esm-B_0dvNjB.js.map} +1 -1
- package/lib/{index.esm-kW-Utcsi.js → index.esm-DFzsB75P.js} +16 -14
- package/lib/index.esm-DFzsB75P.js.map +1 -0
- package/lib/{invariant-CGOLuIIz.js → invariant-BJAl77rw.js} +4 -4
- package/lib/invariant-BJAl77rw.js.map +1 -0
- package/lib/jsx-runtime-BzflLqGi.js.map +1 -1
- package/lib/{mutation-BoVlx8yA.js → mutation-BISOc7OM.js} +70 -44
- package/lib/mutation-BISOc7OM.js.map +1 -0
- package/lib/ui/Accordion.js +1 -1
- package/lib/ui/ActionButton.js +2 -2
- package/lib/ui/Alert.js +1 -1
- package/lib/ui/AlertDialog.js +1 -1
- package/lib/ui/Badge.js +1 -1
- package/lib/ui/Breadcrumb.js +1 -1
- package/lib/ui/Button.js +7 -6
- package/lib/ui/Button.js.map +1 -1
- package/lib/ui/ButtonGroup.js +1 -1
- package/lib/ui/Callout.js +1 -1
- package/lib/ui/Card.js +1 -1
- package/lib/ui/Carousel.js +1 -1
- package/lib/ui/Carousel.js.map +1 -1
- package/lib/ui/Checkbox.js +1 -1
- package/lib/ui/CodeBlock.js +1 -1
- package/lib/ui/Command.js +2 -2
- package/lib/ui/Dialog.js +1 -1
- package/lib/ui/Drawer.js +3 -3
- package/lib/ui/DropdownMenu.js +1 -1
- package/lib/ui/EmbeddedCodeBlock.js +1 -1
- package/lib/ui/Form.js +1 -1
- package/lib/ui/Frame.js +1 -1
- package/lib/ui/HoverCard.js +1 -1
- package/lib/ui/Input.js +1 -1
- package/lib/ui/Item.js +1 -1
- package/lib/ui/Label.js +1 -1
- package/lib/ui/NativeSelect.js +1 -1
- package/lib/ui/Pagination.js +1 -1
- package/lib/ui/Popover.js +1 -1
- package/lib/ui/Progress.js +1 -1
- package/lib/ui/RadioGroup.js +1 -1
- package/lib/ui/ScrollArea.js +1 -1
- package/lib/ui/Secret.js +3 -3
- package/lib/ui/Secret.js.map +1 -1
- package/lib/ui/Separator.js +1 -1
- package/lib/ui/Skeleton.js +1 -1
- package/lib/ui/Slider.js +1 -1
- package/lib/ui/Switch.js +1 -1
- package/lib/ui/SyntaxHighlight.js +3 -3
- package/lib/ui/Tabs.js +1 -1
- package/lib/ui/Textarea.js +1 -1
- package/lib/ui/Toggle.js +1 -1
- package/lib/ui/ToggleGroup.js +1 -1
- package/lib/ui/Value.js +1 -1
- package/lib/ui/util.js +1 -1
- package/lib/{useMutation-C6RqWmTS.js → useMutation-CFMGlAMW.js} +39 -17
- package/lib/useMutation-CFMGlAMW.js.map +1 -0
- package/lib/useSuspenseQuery-CSB_rVek.js +1226 -0
- package/lib/useSuspenseQuery-CSB_rVek.js.map +1 -0
- package/lib/zudoku.__internal.js +826 -1325
- package/lib/zudoku.__internal.js.map +1 -1
- package/lib/zudoku.auth-auth0.js +16 -16
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-azureb2c.js +4 -4
- package/lib/zudoku.auth-clerk.js +52 -75
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-firebase.js +6 -5
- package/lib/zudoku.auth-firebase.js.map +1 -1
- package/lib/zudoku.auth-openid.js +5 -5
- package/lib/zudoku.auth-supabase.js +31 -40
- package/lib/zudoku.auth-supabase.js.map +1 -1
- package/lib/zudoku.components.js +23 -21
- package/lib/zudoku.hooks.js +3 -3
- package/lib/zudoku.mermaid.js +3 -3
- package/lib/zudoku.plugin-api-catalog.js +8 -8
- package/lib/zudoku.plugin-api-keys.js +607 -552
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +3 -3
- package/lib/zudoku.plugin-redirect.js +1 -1
- package/lib/zudoku.plugin-search-pagefind.js +30 -29
- package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
- package/lib/zudoku.plugins.js +9 -8
- package/lib/zudoku.plugins.js.map +1 -1
- package/lib/zudoku.react-query.js +440 -0
- package/lib/zudoku.react-query.js.map +1 -0
- package/lib/zudoku.router.js +1130 -1404
- package/lib/zudoku.router.js.map +1 -1
- package/package.json +36 -22
- package/src/lib/auth/issuer.ts +1 -1
- package/src/lib/authentication/authentication.ts +8 -2
- package/src/lib/authentication/components/CallbackHandler.tsx +1 -1
- package/src/lib/authentication/components/SignIn.tsx +5 -2
- package/src/lib/authentication/components/SignUp.tsx +5 -2
- package/src/lib/authentication/hook.ts +16 -0
- package/src/lib/authentication/providers/auth0.tsx +15 -9
- package/src/lib/authentication/providers/clerk.tsx +0 -26
- package/src/lib/authentication/providers/firebase.tsx +98 -6
- package/src/lib/authentication/providers/supabase.tsx +6 -15
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +129 -0
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +170 -38
- package/src/lib/authentication/utils/relativeRedirectUrl.ts +12 -0
- package/src/lib/components/Bootstrap.tsx +1 -4
- package/src/lib/components/Pagination.tsx +4 -5
- package/src/lib/components/Zudoku.tsx +5 -11
- package/src/lib/components/context/ZudokuContext.ts +2 -6
- package/src/lib/components/context/ZudokuProvider.tsx +1 -1
- package/src/lib/components/context/ZudokuReactContext.tsx +17 -0
- package/src/lib/components/index.ts +4 -0
- package/src/lib/components/navigation/NavigationItem.tsx +9 -3
- package/src/lib/core/RouteGuard.tsx +30 -24
- package/src/lib/core/plugins.ts +21 -1
- package/src/lib/core/react-query.ts +1 -0
- package/src/lib/core/transform-config.ts +29 -0
- package/src/lib/errors/ErrorAlert.tsx +1 -6
- package/src/lib/errors/ErrorMessage.tsx +38 -0
- package/src/lib/oas/graphql/circular.test.ts +186 -0
- package/src/lib/oas/graphql/circular.ts +49 -10
- package/src/lib/oas/graphql/index.ts +7 -3
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +36 -476
- package/src/lib/plugins/api-keys/index.tsx +76 -32
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -0
- package/src/lib/plugins/api-keys/settings/ApiKeyList.tsx +67 -0
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +124 -0
- package/src/lib/plugins/openapi/OasProvider.tsx +10 -2
- package/src/lib/plugins/openapi/OperationList.tsx +4 -4
- package/src/lib/plugins/openapi/ParamInfos.tsx +1 -0
- package/src/lib/plugins/openapi/Sidecar.tsx +3 -2
- package/src/lib/plugins/openapi/interfaces.ts +6 -1
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +6 -4
- package/src/lib/plugins/openapi/schema/utils.ts +15 -4
- package/src/lib/plugins/openapi/util/createHttpSnippet.ts +29 -1
- package/src/lib/plugins/openapi/util/getRoutes.tsx +4 -1
- package/src/lib/ui/Button.tsx +1 -0
- package/src/lib/ui/Secret.tsx +2 -2
- package/src/lib/util/invariant.ts +2 -1
- package/src/shiki/langs/c3.js +1 -0
- package/src/shiki/langs/gn.js +1 -0
- package/src/shiki/langs/moonbit.js +1 -0
- package/lib/ClaudeLogo-B4Xxt-x_.js.map +0 -1
- package/lib/ErrorAlert-DrOR8w3f.js.map +0 -1
- package/lib/OAuthErrorPage-Fq54RLgt.js.map +0 -1
- package/lib/OasProvider-DPH8mwDa.js +0 -40
- package/lib/OasProvider-DPH8mwDa.js.map +0 -1
- package/lib/RouteGuard-9wjejsKm.js +0 -77
- package/lib/RouteGuard-9wjejsKm.js.map +0 -1
- package/lib/RouterError-DSLXagd5.js +0 -42
- package/lib/RouterError-DSLXagd5.js.map +0 -1
- package/lib/SchemaView-DVae4RO2.js +0 -597
- package/lib/SchemaView-DVae4RO2.js.map +0 -1
- package/lib/Select-CkxXP5I7.js.map +0 -1
- package/lib/SignUp-BjS4ozA7.js +0 -50
- package/lib/SignUp-BjS4ozA7.js.map +0 -1
- package/lib/SyntaxHighlight-Kdyskw3C.js.map +0 -1
- package/lib/ZudokuContext-BXldanA8.js +0 -1508
- package/lib/ZudokuContext-BXldanA8.js.map +0 -1
- package/lib/___vite-browser-external_commonjs-proxy-Cga3HsWk.js.map +0 -1
- package/lib/chunk-PVWAREVJ-dLIqswPy.js +0 -7965
- package/lib/chunk-PVWAREVJ-dLIqswPy.js.map +0 -1
- package/lib/cn-dYga0KKN.js.map +0 -1
- package/lib/createVariantComponent-B9_dVBvu.js +0 -35
- package/lib/createVariantComponent-B9_dVBvu.js.map +0 -1
- package/lib/firebase-qUdSEL1p.js.map +0 -1
- package/lib/hook-BNxidGQq.js +0 -40
- package/lib/hook-BNxidGQq.js.map +0 -1
- package/lib/index-CCmMJp02.js +0 -1059
- package/lib/index-CCmMJp02.js.map +0 -1
- package/lib/index.esm-kW-Utcsi.js.map +0 -1
- package/lib/invariant-CGOLuIIz.js.map +0 -1
- package/lib/mutation-BoVlx8yA.js.map +0 -1
- package/lib/useMutation-C6RqWmTS.js.map +0 -1
|
@@ -27,16 +27,31 @@ export const RouteGuard = () => {
|
|
|
27
27
|
const shouldBypass = use(BypassProtectedRoutesContext);
|
|
28
28
|
const { protectedRoutes } = zudoku.options;
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
: undefined;
|
|
30
|
+
const protectedRouteEntry = protectedRoutes
|
|
31
|
+
? Object.entries(protectedRoutes).find(([path]) =>
|
|
32
|
+
matchPath({ path, end: true }, location.pathname),
|
|
33
|
+
)
|
|
34
|
+
: undefined;
|
|
36
35
|
|
|
37
|
-
const isProtectedRoute =
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const isProtectedRoute = protectedRouteEntry !== undefined;
|
|
37
|
+
|
|
38
|
+
// SSR/prerendering mode: render content with search meta tag, skip all auth
|
|
39
|
+
if (shouldBypass) {
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{isProtectedRoute && (
|
|
43
|
+
<Helmet>
|
|
44
|
+
<meta
|
|
45
|
+
name="pagefind"
|
|
46
|
+
data-pagefind-filter={`section:${SEARCH_PROTECTED_SECTION}`}
|
|
47
|
+
content="true"
|
|
48
|
+
/>
|
|
49
|
+
</Helmet>
|
|
50
|
+
)}
|
|
51
|
+
<Outlet />
|
|
52
|
+
</>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
40
55
|
|
|
41
56
|
if (isProtectedRoute && !auth.isAuthEnabled) {
|
|
42
57
|
throw new ZudokuError("Authentication is not enabled", {
|
|
@@ -46,6 +61,10 @@ export const RouteGuard = () => {
|
|
|
46
61
|
});
|
|
47
62
|
}
|
|
48
63
|
|
|
64
|
+
const authCheckFn = protectedRouteEntry?.[1];
|
|
65
|
+
const needsToSignIn =
|
|
66
|
+
isProtectedRoute && !authCheckFn?.({ auth, context: zudoku });
|
|
67
|
+
|
|
49
68
|
if (needsToSignIn && auth.isPending && typeof window !== "undefined") {
|
|
50
69
|
return null;
|
|
51
70
|
}
|
|
@@ -91,7 +110,7 @@ export const RouteGuard = () => {
|
|
|
91
110
|
)
|
|
92
111
|
}
|
|
93
112
|
>
|
|
94
|
-
Login
|
|
113
|
+
Login
|
|
95
114
|
</Button>
|
|
96
115
|
</DialogFooter>
|
|
97
116
|
</DialogContent>
|
|
@@ -99,18 +118,5 @@ export const RouteGuard = () => {
|
|
|
99
118
|
);
|
|
100
119
|
}
|
|
101
120
|
|
|
102
|
-
return
|
|
103
|
-
<>
|
|
104
|
-
{shouldBypass && isProtectedRoute && (
|
|
105
|
-
<Helmet>
|
|
106
|
-
<meta
|
|
107
|
-
name="pagefind"
|
|
108
|
-
data-pagefind-filter={`section:${SEARCH_PROTECTED_SECTION}`}
|
|
109
|
-
content="true"
|
|
110
|
-
/>
|
|
111
|
-
</Helmet>
|
|
112
|
-
)}
|
|
113
|
-
<Outlet />
|
|
114
|
-
</>
|
|
115
|
-
);
|
|
121
|
+
return <Outlet />;
|
|
116
122
|
};
|
package/src/lib/core/plugins.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ReactNode } from "react";
|
|
|
3
3
|
import type { Location, RouteObject } from "react-router";
|
|
4
4
|
import type { Navigation } from "../../config/validators/NavigationSchema.js";
|
|
5
5
|
import type { ProtectedRoutesInput } from "../../config/validators/ProtectedRoutesSchema.js";
|
|
6
|
+
import type { ZudokuConfig } from "../../config/validators/validate.js";
|
|
6
7
|
import type { AuthenticationPlugin } from "../authentication/authentication.js";
|
|
7
8
|
import type { MdxComponentsType } from "../util/MdxComponents.js";
|
|
8
9
|
import type {
|
|
@@ -18,7 +19,8 @@ export type ZudokuPlugin =
|
|
|
18
19
|
| ApiIdentityPlugin
|
|
19
20
|
| SearchProviderPlugin
|
|
20
21
|
| EventConsumerPlugin
|
|
21
|
-
| AuthenticationPlugin
|
|
22
|
+
| AuthenticationPlugin
|
|
23
|
+
| TransformConfigPlugin;
|
|
22
24
|
|
|
23
25
|
export type { AuthenticationPlugin, RouteObject };
|
|
24
26
|
|
|
@@ -60,6 +62,19 @@ export type ProfileNavigationItem = {
|
|
|
60
62
|
icon?: LucideIcon;
|
|
61
63
|
};
|
|
62
64
|
|
|
65
|
+
export interface ConfigHookContext {
|
|
66
|
+
mode: typeof process.env.ZUDOKU_ENV;
|
|
67
|
+
rootDir: string;
|
|
68
|
+
configPath: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface TransformConfigPlugin {
|
|
72
|
+
transformConfig?: (
|
|
73
|
+
config: ZudokuConfig,
|
|
74
|
+
ctx: ConfigHookContext,
|
|
75
|
+
) => Partial<ZudokuConfig> | void | Promise<Partial<ZudokuConfig> | void>;
|
|
76
|
+
}
|
|
77
|
+
|
|
63
78
|
export interface CommonPlugin {
|
|
64
79
|
initialize?: (
|
|
65
80
|
context: ZudokuContext,
|
|
@@ -110,3 +125,8 @@ export const isApiIdentityPlugin = (
|
|
|
110
125
|
obj: ZudokuPlugin,
|
|
111
126
|
): obj is ApiIdentityPlugin =>
|
|
112
127
|
"getIdentities" in obj && typeof obj.getIdentities === "function";
|
|
128
|
+
|
|
129
|
+
export const isTransformConfigPlugin = (
|
|
130
|
+
obj: ZudokuPlugin,
|
|
131
|
+
): obj is TransformConfigPlugin =>
|
|
132
|
+
"transformConfig" in obj && typeof obj.transformConfig === "function";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tanstack/react-query";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import createDeepmerge from "@fastify/deepmerge";
|
|
2
|
+
import type { ConfigWithMeta } from "../../config/loader.js";
|
|
3
|
+
import { type ConfigHookContext, isTransformConfigPlugin } from "./plugins.js";
|
|
4
|
+
|
|
5
|
+
const mergeConfig = createDeepmerge({
|
|
6
|
+
mergeArray: (opt) => (_, source) => opt.clone(source),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const runTransformConfigHooks = async (
|
|
10
|
+
config: ConfigWithMeta,
|
|
11
|
+
): Promise<ConfigWithMeta> => {
|
|
12
|
+
const ctx = {
|
|
13
|
+
mode: config.__meta.mode,
|
|
14
|
+
rootDir: config.__meta.rootDir,
|
|
15
|
+
configPath: config.__meta.configPath,
|
|
16
|
+
} satisfies ConfigHookContext;
|
|
17
|
+
const plugins = config.plugins ?? [];
|
|
18
|
+
|
|
19
|
+
let result = config;
|
|
20
|
+
|
|
21
|
+
for (const plugin of plugins.filter(isTransformConfigPlugin)) {
|
|
22
|
+
const partial = await plugin.transformConfig?.(result, ctx);
|
|
23
|
+
if (!partial) continue;
|
|
24
|
+
|
|
25
|
+
result = mergeConfig(result, partial) as ConfigWithMeta;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SyntaxHighlight } from "zudoku/ui/SyntaxHighlight.js";
|
|
2
1
|
import { DeveloperHint } from "../components/DeveloperHint.js";
|
|
3
2
|
import { Heading } from "../components/Heading.js";
|
|
4
3
|
import { Typography } from "../components/Typography.js";
|
|
@@ -22,11 +21,7 @@ export function ErrorAlert({ error }: { error: unknown }) {
|
|
|
22
21
|
Error: {message}
|
|
23
22
|
{hint && <DeveloperHint className="mb-4">{hint}</DeveloperHint>}
|
|
24
23
|
{stringError && (
|
|
25
|
-
<
|
|
26
|
-
className="max-h-[400px] [&>pre]:p-4"
|
|
27
|
-
language="js"
|
|
28
|
-
code={stringError}
|
|
29
|
-
/>
|
|
24
|
+
<pre className="max-h-[400px] [&>pre]:p-4">{stringError}</pre>
|
|
30
25
|
)}
|
|
31
26
|
</Typography>
|
|
32
27
|
);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Alert, AlertDescription, AlertTitle } from "zudoku/ui/Alert.js";
|
|
2
|
+
import { SyntaxHighlight } from "zudoku/ui/SyntaxHighlight.js";
|
|
3
|
+
import { DeveloperHint } from "../components/DeveloperHint.js";
|
|
4
|
+
import { ZudokuError } from "../util/invariant.js";
|
|
5
|
+
|
|
6
|
+
export function ErrorMessage({ error }: { error: unknown }) {
|
|
7
|
+
const message =
|
|
8
|
+
error instanceof Error ? error.message : "Something went wrong";
|
|
9
|
+
|
|
10
|
+
const showDeveloperHints = process.env.NODE_ENV === "development";
|
|
11
|
+
|
|
12
|
+
const hint = error instanceof ZudokuError ? error.developerHint : undefined;
|
|
13
|
+
const title =
|
|
14
|
+
error instanceof ZudokuError ? error.title : "Something went wrong";
|
|
15
|
+
const stack = error instanceof Error ? error.stack : undefined;
|
|
16
|
+
const cause = error instanceof Error ? error.cause : undefined;
|
|
17
|
+
|
|
18
|
+
const stringError = cause instanceof Error ? String(cause.stack) : stack;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<Alert variant="destructive">
|
|
23
|
+
<AlertTitle>{title}</AlertTitle>
|
|
24
|
+
<AlertDescription>{message}</AlertDescription>
|
|
25
|
+
</Alert>
|
|
26
|
+
{showDeveloperHints && hint && (
|
|
27
|
+
<DeveloperHint className="mb-4">{hint}</DeveloperHint>
|
|
28
|
+
)}
|
|
29
|
+
{showDeveloperHints && stringError && (
|
|
30
|
+
<SyntaxHighlight
|
|
31
|
+
className="max-h-[400px] [&>pre]:p-4"
|
|
32
|
+
language="js"
|
|
33
|
+
code={stringError}
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
CIRCULAR_REF,
|
|
4
|
+
handleCircularRefs,
|
|
5
|
+
SCHEMA_REF_PREFIX,
|
|
6
|
+
} from "./circular.js";
|
|
7
|
+
|
|
8
|
+
describe("handleCircularRefs", () => {
|
|
9
|
+
it("should return primitives unchanged", () => {
|
|
10
|
+
expect(handleCircularRefs(null)).toBe(null);
|
|
11
|
+
expect(handleCircularRefs(undefined)).toBe(undefined);
|
|
12
|
+
expect(handleCircularRefs(42)).toBe(42);
|
|
13
|
+
expect(handleCircularRefs("hello")).toBe("hello");
|
|
14
|
+
expect(handleCircularRefs(true)).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should handle simple objects without refs", () => {
|
|
18
|
+
const obj = { type: "string", description: "A string" };
|
|
19
|
+
const result = handleCircularRefs(obj);
|
|
20
|
+
expect(result).toEqual(obj);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should handle arrays", () => {
|
|
24
|
+
const arr = [{ type: "string" }, { type: "number" }];
|
|
25
|
+
const result = handleCircularRefs(arr);
|
|
26
|
+
expect(result).toEqual(arr);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should detect true circular references via object identity", () => {
|
|
30
|
+
const obj: Record<string, unknown> = { type: "object" };
|
|
31
|
+
obj.self = obj;
|
|
32
|
+
|
|
33
|
+
const result = handleCircularRefs(obj);
|
|
34
|
+
expect(result.type).toBe("object");
|
|
35
|
+
expect(result.self).toContain(CIRCULAR_REF);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should detect circular refs via __$ref path", () => {
|
|
39
|
+
const inner = { __$ref: "#/components/schemas/Node", type: "object" };
|
|
40
|
+
const obj = {
|
|
41
|
+
__$ref: "#/components/schemas/Node",
|
|
42
|
+
type: "object",
|
|
43
|
+
properties: {
|
|
44
|
+
child: inner,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
(inner as Record<string, unknown>).properties = { parent: obj };
|
|
48
|
+
|
|
49
|
+
const result = handleCircularRefs(obj);
|
|
50
|
+
expect(result.properties.child).toBe(
|
|
51
|
+
`${SCHEMA_REF_PREFIX}#/components/schemas/Node`,
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Regression test for #1869
|
|
56
|
+
it("should NOT mark sibling refs to the same schema as circular", () => {
|
|
57
|
+
const timestampSchema1 = {
|
|
58
|
+
__$ref: "#/components/schemas/timestamp",
|
|
59
|
+
type: "string",
|
|
60
|
+
format: "date-time",
|
|
61
|
+
};
|
|
62
|
+
const timestampSchema2 = {
|
|
63
|
+
__$ref: "#/components/schemas/timestamp",
|
|
64
|
+
type: "string",
|
|
65
|
+
format: "date-time",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const obj = {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
created_at: timestampSchema1,
|
|
72
|
+
updated_at: timestampSchema2,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const result = handleCircularRefs(obj);
|
|
77
|
+
|
|
78
|
+
expect(result.properties.created_at).toEqual({
|
|
79
|
+
__$ref: "#/components/schemas/timestamp",
|
|
80
|
+
type: "string",
|
|
81
|
+
format: "date-time",
|
|
82
|
+
});
|
|
83
|
+
expect(result.properties.updated_at).toEqual({
|
|
84
|
+
__$ref: "#/components/schemas/timestamp",
|
|
85
|
+
type: "string",
|
|
86
|
+
format: "date-time",
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("should allow same ref path in different branches of the tree", () => {
|
|
91
|
+
const obj = {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
user: {
|
|
95
|
+
type: "object",
|
|
96
|
+
properties: {
|
|
97
|
+
id: { __$ref: "#/components/schemas/identifier", type: "string" },
|
|
98
|
+
name: { type: "string" },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
post: {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: {
|
|
104
|
+
id: { __$ref: "#/components/schemas/identifier", type: "string" },
|
|
105
|
+
title: { type: "string" },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const result = handleCircularRefs(obj);
|
|
112
|
+
|
|
113
|
+
expect(result.properties.user.properties.id.type).toBe("string");
|
|
114
|
+
expect(result.properties.post.properties.id.type).toBe("string");
|
|
115
|
+
expect(result.properties.user.properties.id).not.toBe(
|
|
116
|
+
expect.stringContaining(SCHEMA_REF_PREFIX),
|
|
117
|
+
);
|
|
118
|
+
expect(result.properties.post.properties.id).not.toBe(
|
|
119
|
+
expect.stringContaining(SCHEMA_REF_PREFIX),
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("should handle shared object instances (same object, multiple references)", () => {
|
|
124
|
+
const sharedSchema = { type: "string", description: "Shared" };
|
|
125
|
+
const obj = {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: { field1: sharedSchema, field2: sharedSchema },
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const result = handleCircularRefs(obj);
|
|
131
|
+
|
|
132
|
+
expect(result.properties.field1).toEqual({
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "Shared",
|
|
135
|
+
});
|
|
136
|
+
expect(result.properties.field2).toEqual({
|
|
137
|
+
type: "string",
|
|
138
|
+
description: "Shared",
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("should handle nested arrays with refs", () => {
|
|
143
|
+
const obj = {
|
|
144
|
+
type: "object",
|
|
145
|
+
allOf: [
|
|
146
|
+
{ __$ref: "#/components/schemas/Base", type: "object" },
|
|
147
|
+
{ type: "object", properties: { extra: { type: "string" } } },
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const result = handleCircularRefs(obj);
|
|
152
|
+
|
|
153
|
+
expect(result.allOf[0]).toEqual({
|
|
154
|
+
__$ref: "#/components/schemas/Base",
|
|
155
|
+
type: "object",
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("should deduplicate shared object instances with __$ref", () => {
|
|
160
|
+
const shared = { __$ref: "#/components/schemas/Foo", type: "string" };
|
|
161
|
+
const obj = { a: shared, b: shared };
|
|
162
|
+
const result = handleCircularRefs(obj);
|
|
163
|
+
|
|
164
|
+
expect(result.a).toEqual({
|
|
165
|
+
__$ref: "#/components/schemas/Foo",
|
|
166
|
+
type: "string",
|
|
167
|
+
});
|
|
168
|
+
expect(result.b).toBe(`${SCHEMA_REF_PREFIX}#/components/schemas/Foo`);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("should mark circular ref with property name from path", () => {
|
|
172
|
+
const parent: Record<string, unknown> = {
|
|
173
|
+
type: "object",
|
|
174
|
+
properties: {} as Record<string, unknown>,
|
|
175
|
+
};
|
|
176
|
+
const child: Record<string, unknown> = {
|
|
177
|
+
type: "object",
|
|
178
|
+
properties: { back: parent },
|
|
179
|
+
};
|
|
180
|
+
(parent.properties as Record<string, unknown>).child = child;
|
|
181
|
+
|
|
182
|
+
const result = handleCircularRefs(parent);
|
|
183
|
+
|
|
184
|
+
expect(result.properties.child.properties.back).toContain(CIRCULAR_REF);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -3,6 +3,7 @@ import { GraphQLJSON } from "graphql-type-json";
|
|
|
3
3
|
import type { RecordAny } from "../../util/traverse.js";
|
|
4
4
|
|
|
5
5
|
export const CIRCULAR_REF = "$[Circular Reference]";
|
|
6
|
+
export const SCHEMA_REF_PREFIX = "$ref:";
|
|
6
7
|
|
|
7
8
|
const OPENAPI_PROPS = new Set([
|
|
8
9
|
"properties",
|
|
@@ -13,19 +14,34 @@ const OPENAPI_PROPS = new Set([
|
|
|
13
14
|
"oneOf",
|
|
14
15
|
]);
|
|
15
16
|
|
|
16
|
-
const handleCircularRefs = (
|
|
17
|
+
export const handleCircularRefs = (
|
|
17
18
|
// biome-ignore lint/suspicious/noExplicitAny: Allow any type
|
|
18
19
|
obj: any,
|
|
19
20
|
visited = new WeakSet(),
|
|
20
21
|
refs = new WeakMap(),
|
|
21
22
|
path: string[] = [],
|
|
23
|
+
seenRefPaths = new Set<string>(),
|
|
22
24
|
// biome-ignore lint/suspicious/noExplicitAny: Allow any type
|
|
23
25
|
): any => {
|
|
24
26
|
if (obj === null || typeof obj !== "object") return obj;
|
|
25
27
|
|
|
28
|
+
const refPath = obj.__$ref;
|
|
29
|
+
|
|
30
|
+
// Check if this object has a __$ref marker (set during schema code generation)
|
|
31
|
+
// If we've already fully processed this ref path, return a reference marker
|
|
32
|
+
// instead of the full data to avoid JSON.stringify serializing duplicates
|
|
33
|
+
if (typeof refPath === "string" && seenRefPaths.has(refPath)) {
|
|
34
|
+
return SCHEMA_REF_PREFIX + refPath;
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
if (visited.has(obj)) {
|
|
27
38
|
const cached = refs.get(obj);
|
|
28
|
-
if (cached)
|
|
39
|
+
if (cached) {
|
|
40
|
+
return typeof refPath === "string"
|
|
41
|
+
? // If already processed, return ref marker to avoid duplicate serialization
|
|
42
|
+
SCHEMA_REF_PREFIX + refPath
|
|
43
|
+
: cached;
|
|
44
|
+
}
|
|
29
45
|
const circularProp = path.find((p) => !OPENAPI_PROPS.has(p)) || path[0];
|
|
30
46
|
|
|
31
47
|
return [CIRCULAR_REF, circularProp].filter(Boolean).join(":");
|
|
@@ -33,19 +49,42 @@ const handleCircularRefs = (
|
|
|
33
49
|
|
|
34
50
|
visited.add(obj);
|
|
35
51
|
|
|
52
|
+
// Add refPath BEFORE recursing to detect cycles within this branch
|
|
53
|
+
// This will be removed after processing to allow siblings with the same ref
|
|
54
|
+
if (typeof refPath === "string") {
|
|
55
|
+
seenRefPaths.add(refPath);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let result: RecordAny | RecordAny[];
|
|
36
59
|
if (Array.isArray(obj)) {
|
|
37
|
-
|
|
38
|
-
handleCircularRefs(
|
|
60
|
+
result = obj.map((item, index) =>
|
|
61
|
+
handleCircularRefs(
|
|
62
|
+
item,
|
|
63
|
+
visited,
|
|
64
|
+
refs,
|
|
65
|
+
[...path, index.toString()],
|
|
66
|
+
seenRefPaths,
|
|
67
|
+
),
|
|
39
68
|
);
|
|
40
|
-
|
|
41
|
-
|
|
69
|
+
} else {
|
|
70
|
+
result = {};
|
|
71
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
72
|
+
result[key] = handleCircularRefs(
|
|
73
|
+
value,
|
|
74
|
+
visited,
|
|
75
|
+
refs,
|
|
76
|
+
[...path, key],
|
|
77
|
+
seenRefPaths,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
42
80
|
}
|
|
81
|
+
refs.set(obj, result);
|
|
43
82
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
83
|
+
// Remove refPath after processing so sibling refs aren't incorrectly marked
|
|
84
|
+
if (typeof refPath === "string") {
|
|
85
|
+
seenRefPaths.delete(refPath);
|
|
47
86
|
}
|
|
48
|
-
|
|
87
|
+
|
|
49
88
|
return result;
|
|
50
89
|
};
|
|
51
90
|
|
|
@@ -473,7 +473,9 @@ const OperationItem = builder
|
|
|
473
473
|
name,
|
|
474
474
|
...(typeof value === "string" ? { value } : value),
|
|
475
475
|
}))
|
|
476
|
-
:
|
|
476
|
+
: content.example !== undefined
|
|
477
|
+
? [{ name: "", value: content.example }]
|
|
478
|
+
: [],
|
|
477
479
|
encoding: Object.entries(content.encoding ?? {}).map(
|
|
478
480
|
([name, value]) => ({ name, ...value }),
|
|
479
481
|
),
|
|
@@ -490,7 +492,7 @@ const OperationItem = builder
|
|
|
490
492
|
statusCode,
|
|
491
493
|
description: response.description,
|
|
492
494
|
content: Object.entries(response.content ?? {}).map(
|
|
493
|
-
([mediaType, { schema, examples }]) => ({
|
|
495
|
+
([mediaType, { schema, examples, example }]) => ({
|
|
494
496
|
mediaType,
|
|
495
497
|
schema,
|
|
496
498
|
examples: examples
|
|
@@ -498,7 +500,9 @@ const OperationItem = builder
|
|
|
498
500
|
name,
|
|
499
501
|
...(typeof value === "string" ? { value } : value),
|
|
500
502
|
}))
|
|
501
|
-
:
|
|
503
|
+
: example !== undefined
|
|
504
|
+
? [{ name: "", value: example }]
|
|
505
|
+
: [],
|
|
502
506
|
}),
|
|
503
507
|
),
|
|
504
508
|
headers: response.headers,
|