zudoku 0.3.0-dev.5 → 0.3.0-dev.51
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/App.d.ts +1 -2
- package/dist/app/App.js +1 -28
- package/dist/app/App.js.map +1 -1
- package/dist/app/demo.d.ts +2 -0
- package/dist/app/demo.js +27 -0
- package/dist/app/demo.js.map +1 -0
- package/dist/app/entry.client.d.ts +2 -0
- package/dist/app/entry.client.js +35 -0
- package/dist/app/entry.client.js.map +1 -0
- package/dist/app/entry.server.d.ts +12 -0
- package/dist/app/entry.server.js +104 -0
- package/dist/app/entry.server.js.map +1 -0
- package/dist/app/main.d.ts +6 -1
- package/dist/app/main.js +54 -12
- package/dist/app/main.js.map +1 -1
- package/dist/app/standalone.d.ts +2 -0
- package/dist/app/standalone.js +32 -0
- package/dist/app/standalone.js.map +1 -0
- package/dist/app/tailwind.d.ts +1 -1
- package/dist/app/tailwind.js +0 -4
- package/dist/app/tailwind.js.map +1 -1
- package/dist/app/zudoku-manifest.d.ts +1 -0
- package/dist/app/zudoku-manifest.js +20 -0
- package/dist/app/zudoku-manifest.js.map +1 -0
- package/dist/cli/cmds/dev.js +5 -0
- package/dist/cli/cmds/dev.js.map +1 -1
- package/dist/cli/dev/handler.d.ts +1 -0
- package/dist/cli/dev/handler.js +3 -1
- package/dist/cli/dev/handler.js.map +1 -1
- package/dist/config/config.d.ts +5 -39
- package/dist/config/validators/validate.d.ts +799 -2
- package/dist/config/validators/validate.js +134 -1
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -0
- package/dist/lib/authentication/Callback.js +1 -1
- package/dist/lib/authentication/Callback.js.map +1 -1
- package/dist/lib/authentication/authentication.d.ts +2 -2
- package/dist/lib/authentication/hook.d.ts +1 -0
- package/dist/lib/authentication/hook.js +1 -0
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +1 -0
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/clerk.js +4 -0
- package/dist/lib/authentication/providers/clerk.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +1 -1
- package/dist/lib/authentication/providers/openid.js +2 -0
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/authentication/state.d.ts +1 -0
- package/dist/lib/authentication/state.js +1 -0
- package/dist/lib/authentication/state.js.map +1 -1
- package/dist/lib/components/Bootstrap.d.ts +12 -0
- package/dist/lib/components/Bootstrap.js +9 -0
- package/dist/lib/components/Bootstrap.js.map +1 -0
- package/dist/lib/components/DevPortal.d.ts +4 -19
- package/dist/lib/components/DevPortal.js +17 -12
- package/dist/lib/components/DevPortal.js.map +1 -1
- package/dist/lib/components/ErrorPage.d.ts +6 -0
- package/dist/lib/components/ErrorPage.js +9 -0
- package/dist/lib/components/ErrorPage.js.map +1 -0
- package/dist/lib/components/Header.js +3 -3
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +9 -4
- package/dist/lib/components/Heading.js +17 -2
- package/dist/lib/components/Heading.js.map +1 -1
- package/dist/lib/components/InlineCode.d.ts +5 -0
- package/dist/lib/components/InlineCode.js +4 -0
- package/dist/lib/components/InlineCode.js.map +1 -0
- package/dist/lib/components/Layout.js +3 -2
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/NotFoundPage.d.ts +1 -0
- package/dist/lib/components/NotFoundPage.js +12 -0
- package/dist/lib/components/NotFoundPage.js.map +1 -0
- package/dist/lib/components/SyntaxHighlight.d.ts +3 -2
- package/dist/lib/components/SyntaxHighlight.js +21 -19
- package/dist/lib/components/SyntaxHighlight.js.map +1 -1
- package/dist/lib/components/TopNavigation.d.ts +1 -1
- package/dist/lib/components/TopNavigation.js +4 -0
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/context/DevPortalProvider.d.ts +1 -1
- package/dist/lib/components/context/DevPortalProvider.js +2 -2
- package/dist/lib/components/context/DevPortalProvider.js.map +1 -1
- package/dist/lib/components/index.d.ts +28 -3
- package/dist/lib/components/index.js +17 -3
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/core/DevPortalContext.d.ts +36 -11
- package/dist/lib/core/DevPortalContext.js +11 -12
- package/dist/lib/core/DevPortalContext.js.map +1 -1
- package/dist/lib/core/plugins.d.ts +7 -4
- package/dist/lib/core/plugins.js +1 -0
- package/dist/lib/core/plugins.js.map +1 -1
- package/dist/lib/errors/ErrorAlert.d.ts +3 -0
- package/dist/lib/errors/ErrorAlert.js +8 -0
- package/dist/lib/errors/ErrorAlert.js.map +1 -0
- package/dist/lib/errors/RouterError.d.ts +1 -0
- package/dist/lib/errors/RouterError.js +12 -0
- package/dist/lib/errors/RouterError.js.map +1 -0
- package/dist/lib/errors/ServerError.d.ts +3 -0
- package/dist/lib/errors/ServerError.js +6 -0
- package/dist/lib/errors/ServerError.js.map +1 -0
- package/dist/lib/errors/TopLevelError.d.ts +2 -0
- package/dist/lib/errors/TopLevelError.js +7 -0
- package/dist/lib/errors/TopLevelError.js.map +1 -0
- package/dist/lib/oas/graphql/index.js +1 -1
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/oas/parser/index.d.ts +1 -1
- package/dist/lib/oas/parser/index.js +38 -12
- package/dist/lib/oas/parser/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.d.ts +4 -0
- package/dist/lib/plugins/{api-key → api-keys}/CreateApiKey.js +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.js.map +1 -0
- package/dist/lib/plugins/api-keys/SettingsApiKeys.d.ts +4 -0
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js +39 -0
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -0
- package/dist/lib/plugins/{api-key → api-keys}/index.d.ts +2 -3
- package/dist/lib/plugins/{api-key → api-keys}/index.js +15 -4
- package/dist/lib/plugins/api-keys/index.js.map +1 -0
- package/dist/lib/plugins/markdown/MdxPage.d.ts +3 -2
- package/dist/lib/plugins/markdown/MdxPage.js +7 -6
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/markdown/Toc.js +1 -1
- package/dist/lib/plugins/markdown/Toc.js.map +1 -1
- package/dist/lib/plugins/markdown/generateRoutes.d.ts +3 -3
- package/dist/lib/plugins/markdown/generateRoutes.js +4 -4
- package/dist/lib/plugins/markdown/generateRoutes.js.map +1 -1
- package/dist/lib/plugins/markdown/index.d.ts +4 -1
- package/dist/lib/plugins/markdown/index.js +3 -7
- package/dist/lib/plugins/markdown/index.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +16 -5
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +10 -5
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterList.js +1 -1
- package/dist/lib/plugins/openapi/ParameterList.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js +1 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/{MakeRequest.d.ts → PlaygroundDialogWrapper.d.ts} +1 -1
- package/dist/lib/plugins/openapi/{MakeRequest.js → PlaygroundDialogWrapper.js} +5 -5
- package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js.map +1 -0
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +1 -9
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +1 -1
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/Route.d.ts +6 -0
- package/dist/lib/plugins/openapi/Route.js +8 -0
- package/dist/lib/plugins/openapi/Route.js.map +1 -0
- package/dist/lib/plugins/openapi/SchemaListView.js +6 -27
- package/dist/lib/plugins/openapi/SchemaListView.js.map +1 -1
- package/dist/lib/plugins/openapi/SchemaListViewItem.d.ts +7 -0
- package/dist/lib/plugins/openapi/SchemaListViewItem.js +16 -0
- package/dist/lib/plugins/openapi/SchemaListViewItem.js.map +1 -0
- package/dist/lib/plugins/openapi/SchemaListViewItemGroup.d.ts +8 -0
- package/dist/lib/plugins/openapi/SchemaListViewItemGroup.js +17 -0
- package/dist/lib/plugins/openapi/SchemaListViewItemGroup.js.map +1 -0
- package/dist/lib/plugins/openapi/Sidecar.js +10 -8
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/{Select.d.ts → SimpleSelect.d.ts} +3 -2
- package/dist/lib/plugins/openapi/SimpleSelect.js +5 -0
- package/dist/lib/plugins/openapi/SimpleSelect.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createMemoryClient.d.ts +12 -0
- package/dist/lib/plugins/openapi/client/createMemoryClient.js +46 -0
- package/dist/lib/plugins/openapi/client/createMemoryClient.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createServer.d.ts +4 -0
- package/dist/lib/plugins/openapi/client/createServer.js +30 -0
- package/dist/lib/plugins/openapi/client/createServer.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createWorkerClient.d.ts +10 -0
- package/dist/lib/plugins/openapi/{worker/createSharedWorkerClient.js → client/createWorkerClient.js} +15 -2
- package/dist/lib/plugins/openapi/client/createWorkerClient.js.map +1 -0
- package/dist/lib/plugins/openapi/client/interfaces.d.ts +4 -0
- package/dist/lib/plugins/openapi/client/interfaces.js +2 -0
- package/dist/lib/plugins/openapi/client/interfaces.js.map +1 -0
- package/dist/lib/plugins/openapi/{worker → client}/worker.js +2 -2
- package/dist/lib/plugins/openapi/client/worker.js.map +1 -0
- package/dist/lib/plugins/openapi/context.d.ts +5 -0
- package/dist/lib/plugins/openapi/context.js +11 -0
- package/dist/lib/plugins/openapi/context.js.map +1 -0
- package/dist/lib/plugins/openapi/index.d.ts +4 -18
- package/dist/lib/plugins/openapi/index.js +35 -20
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +15 -0
- package/dist/lib/plugins/openapi/interfaces.js +2 -0
- package/dist/lib/plugins/openapi/interfaces.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/Headers.d.ts +2 -3
- package/dist/lib/plugins/openapi/playground/Headers.js +16 -6
- package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PathParams.d.ts +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.d.ts +4 -3
- package/dist/lib/plugins/openapi/playground/Playground.js +8 -12
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.d.ts +3 -0
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +10 -0
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/QueryParams.d.ts +1 -1
- package/dist/lib/plugins/openapi/playground/QueryParams.js +2 -1
- package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/createUrl.d.ts +1 -1
- package/dist/lib/plugins/openapi/util/prose.d.ts +1 -0
- package/dist/lib/plugins/openapi/util/prose.js +4 -0
- package/dist/lib/plugins/openapi/util/prose.js.map +1 -0
- package/dist/lib/plugins/openapi-worker.d.ts +1 -1
- package/dist/lib/plugins/openapi-worker.js +1 -1
- package/dist/lib/plugins/openapi-worker.js.map +1 -1
- package/dist/lib/plugins/redirect/index.d.ts +0 -1
- package/dist/lib/plugins/redirect/index.js +3 -4
- package/dist/lib/plugins/redirect/index.js.map +1 -1
- package/dist/lib/ui/Callout.js +2 -2
- package/dist/lib/ui/Callout.js.map +1 -1
- package/dist/lib/ui/button-variants.d.ts +1 -1
- package/dist/lib/util/MdxComponents.d.ts +2 -2
- package/dist/lib/util/MdxComponents.js +6 -4
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/lib/util/groupBy.d.ts +1 -6
- package/dist/lib/util/groupBy.js +10 -8
- package/dist/lib/util/groupBy.js.map +1 -1
- package/dist/lib/util/logInit.d.ts +1 -0
- package/dist/lib/util/logInit.js +9 -0
- package/dist/lib/util/logInit.js.map +1 -0
- package/dist/lib/util/objectEntries.d.ts +4 -0
- package/dist/lib/util/objectEntries.js +2 -0
- package/dist/lib/util/objectEntries.js.map +1 -0
- package/dist/lib/util/renderIf.d.ts +1 -0
- package/dist/lib/util/renderIf.js +2 -0
- package/dist/lib/util/renderIf.js.map +1 -0
- package/dist/vite/build.js +26 -6
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/config.d.ts +13 -12
- package/dist/vite/config.js +100 -55
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/config.test.js +7 -4
- package/dist/vite/config.test.js.map +1 -1
- package/dist/vite/dev-server.d.ts +2 -1
- package/dist/vite/dev-server.js +43 -15
- package/dist/vite/dev-server.js.map +1 -1
- package/dist/vite/html.js +18 -5
- package/dist/vite/html.js.map +1 -1
- package/dist/vite/plugin-api-keys.js +7 -8
- package/dist/vite/plugin-api-keys.js.map +1 -1
- package/dist/vite/plugin-api.js +9 -20
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-auth.js +5 -6
- package/dist/vite/plugin-auth.js.map +1 -1
- package/dist/vite/plugin-component.js +4 -2
- package/dist/vite/plugin-component.js.map +1 -1
- package/dist/vite/plugin-config.d.ts +0 -2
- package/dist/vite/plugin-config.js +2 -13
- package/dist/vite/plugin-config.js.map +1 -1
- package/dist/vite/plugin-custom-css.d.ts +6 -0
- package/dist/vite/plugin-custom-css.js +55 -0
- package/dist/vite/plugin-custom-css.js.map +1 -0
- package/dist/vite/plugin-docs.js +15 -5
- package/dist/vite/plugin-docs.js.map +1 -1
- package/dist/vite/plugin-docs.test.js +1 -1
- package/dist/vite/plugin-docs.test.js.map +1 -1
- package/dist/vite/plugin-mdx.d.ts +3 -1
- package/dist/vite/plugin-mdx.js +5 -5
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/dist/vite/plugin-metadata.js +1 -1
- package/dist/vite/plugin-metadata.js.map +1 -1
- package/dist/vite/plugin-redirect.js +10 -10
- package/dist/vite/plugin-redirect.js.map +1 -1
- package/dist/vite/plugin.js +3 -5
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite/prerender.d.ts +17 -0
- package/dist/vite/prerender.js +55 -0
- package/dist/vite/prerender.js.map +1 -0
- package/lib/AnchorLink-CZUp-F0P.js +705 -0
- package/lib/AnchorLink-CZUp-F0P.js.map +1 -0
- package/lib/DevPortalProvider-Do9oJqme.js +1081 -0
- package/lib/DevPortalProvider-Do9oJqme.js.map +1 -0
- package/lib/Markdown-Dbzrtopg.js +15030 -0
- package/lib/Markdown-Dbzrtopg.js.map +1 -0
- package/lib/MdxPage-JvboTsbK.js +190 -0
- package/lib/MdxPage-JvboTsbK.js.map +1 -0
- package/lib/OperationList-DGdaixGa.js +5562 -0
- package/lib/OperationList-DGdaixGa.js.map +1 -0
- package/lib/Route-C1LyvITr.js +13 -0
- package/lib/Route-C1LyvITr.js.map +1 -0
- package/lib/Select-DHm1jDdS.js +4571 -0
- package/lib/Select-DHm1jDdS.js.map +1 -0
- package/lib/Spinner-BSk0ImmP.js +182 -0
- package/lib/Spinner-BSk0ImmP.js.map +1 -0
- package/lib/_commonjsHelpers-BVfed4GL.js +29 -0
- package/lib/_commonjsHelpers-BVfed4GL.js.map +1 -0
- package/lib/assets/index-BPdJm2ty.js +1 -0
- package/lib/assets/index-BPdJm2ty.js.map +1 -0
- package/lib/assets/{worker-BCcpCNJ7.js → worker-BjPv-hjP.js} +10742 -10318
- package/lib/assets/worker-BjPv-hjP.js.map +1 -0
- package/lib/context-_fYfJFgk.js +14 -0
- package/lib/context-_fYfJFgk.js.map +1 -0
- package/lib/hook-CGFJQf_n.js +77 -0
- package/lib/hook-CGFJQf_n.js.map +1 -0
- package/lib/index-CXXn0D4E.js +412 -0
- package/lib/index-CXXn0D4E.js.map +1 -0
- package/lib/index-DSZ4Cj5q.js +725 -0
- package/lib/index-DSZ4Cj5q.js.map +1 -0
- package/lib/index-pI9JkN46.js +4765 -0
- package/lib/index-pI9JkN46.js.map +1 -0
- package/lib/jsx-runtime-CJZJivg2.js +1526 -0
- package/lib/jsx-runtime-CJZJivg2.js.map +1 -0
- package/lib/prism-bash.min-DadFsM4Z.js +1 -0
- package/lib/prism-bash.min-DadFsM4Z.js.map +1 -0
- package/lib/prism-csharp.min-Yizuc34Y.js +35 -0
- package/lib/prism-csharp.min-Yizuc34Y.js.map +1 -0
- package/lib/prism-java.min-d5iT_mOd.js +1 -0
- package/lib/prism-java.min-d5iT_mOd.js.map +1 -0
- package/lib/prism-json.min-B1GJqK1k.js +1 -0
- package/lib/prism-json.min-B1GJqK1k.js.map +1 -0
- package/lib/prism-markup-templating-DZrrEs0A.js +1 -0
- package/lib/prism-markup-templating-DZrrEs0A.js.map +1 -0
- package/lib/prism-objectivec.min-BXSWqpJJ.js +2 -0
- package/lib/prism-objectivec.min-BXSWqpJJ.js.map +1 -0
- package/lib/prism-php.min-o7FpoMP_.js +1 -0
- package/lib/prism-php.min-o7FpoMP_.js.map +1 -0
- package/lib/prism-ruby.min-C7LwcKyz.js +1 -0
- package/lib/prism-ruby.min-C7LwcKyz.js.map +1 -0
- package/lib/router-CBw2vqJE.js +2973 -0
- package/lib/router-CBw2vqJE.js.map +1 -0
- package/lib/slugify-CiPVjteN.js +28 -0
- package/lib/slugify-CiPVjteN.js.map +1 -0
- package/lib/state-DKdaQzvh.js +288 -0
- package/lib/state-DKdaQzvh.js.map +1 -0
- package/lib/urql-DMlBWUKL.js +1 -0
- package/lib/urql-DMlBWUKL.js.map +1 -0
- package/lib/util-_jwUlTBU.js +41 -0
- package/lib/util-_jwUlTBU.js.map +1 -0
- package/lib/zudoku.auth-auth0.js +3 -1
- package/lib/zudoku.auth-auth0.js.map +1 -0
- package/lib/zudoku.auth-clerk.js +11 -8
- package/lib/zudoku.auth-clerk.js.map +1 -0
- package/lib/zudoku.auth-openid.js +8 -4
- package/lib/zudoku.auth-openid.js.map +1 -0
- package/lib/zudoku.components.js +806 -451
- package/lib/zudoku.components.js.map +1 -0
- package/lib/zudoku.openapi-worker.js +15032 -146
- package/lib/zudoku.openapi-worker.js.map +1 -0
- package/lib/zudoku.plugin-api-keys.js +302 -0
- package/lib/zudoku.plugin-api-keys.js.map +1 -0
- package/lib/zudoku.plugin-markdown.js +49 -0
- package/lib/zudoku.plugin-markdown.js.map +1 -0
- package/lib/zudoku.plugin-openapi.js +10 -0
- package/lib/zudoku.plugin-openapi.js.map +1 -0
- package/lib/zudoku.plugin-redirect.js +11 -0
- package/lib/zudoku.plugin-redirect.js.map +1 -0
- package/package.json +37 -15
- package/src/app/App.tsx +0 -40
- package/src/app/demo-cdn.html +26 -0
- package/src/app/demo.html +18 -0
- package/src/app/demo.tsx +40 -0
- package/src/app/entry.client.tsx +47 -0
- package/src/app/entry.server.tsx +158 -0
- package/src/app/main.css +74 -0
- package/src/app/main.tsx +71 -15
- package/src/app/standalone.html +20 -0
- package/src/app/standalone.tsx +46 -0
- package/src/app/tailwind.ts +2 -6
- package/src/app/zudoku-manifest.ts +22 -0
- package/src/lib/authentication/Callback.tsx +1 -1
- package/src/lib/authentication/authentication.ts +2 -5
- package/src/lib/authentication/hook.ts +1 -0
- package/src/lib/authentication/providers/auth0.tsx +1 -0
- package/src/lib/authentication/providers/clerk.tsx +3 -0
- package/src/lib/authentication/providers/openid.tsx +3 -1
- package/src/lib/authentication/state.ts +2 -0
- package/src/lib/components/Bootstrap.tsx +37 -0
- package/src/lib/components/DevPortal.tsx +41 -56
- package/src/lib/components/ErrorPage.tsx +28 -0
- package/src/lib/components/Header.tsx +13 -7
- package/src/lib/components/Heading.tsx +26 -7
- package/src/lib/components/InlineCode.tsx +19 -0
- package/src/lib/components/Layout.tsx +9 -7
- package/src/lib/components/NotFoundPage.tsx +39 -0
- package/src/lib/components/SyntaxHighlight.tsx +27 -19
- package/src/lib/components/TopNavigation.tsx +5 -0
- package/src/lib/components/context/DevPortalProvider.ts +2 -2
- package/src/lib/components/index.ts +21 -3
- package/src/lib/core/DevPortalContext.ts +47 -28
- package/src/lib/core/plugins.ts +10 -5
- package/src/lib/errors/ErrorAlert.tsx +21 -0
- package/src/lib/errors/RouterError.tsx +13 -0
- package/src/lib/errors/ServerError.tsx +5 -0
- package/src/lib/errors/TopLevelError.tsx +8 -0
- package/src/lib/oas/graphql/index.ts +2 -2
- package/src/lib/oas/parser/index.ts +41 -20
- package/src/lib/plugins/{api-key → api-keys}/CreateApiKey.tsx +2 -8
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +139 -0
- package/src/lib/plugins/{api-key → api-keys}/index.tsx +22 -9
- package/src/lib/plugins/markdown/MdxPage.tsx +51 -34
- package/src/lib/plugins/markdown/Toc.tsx +1 -1
- package/src/lib/plugins/markdown/generateRoutes.tsx +16 -6
- package/src/lib/plugins/markdown/index.tsx +10 -7
- package/src/lib/plugins/openapi/OperationList.tsx +40 -4
- package/src/lib/plugins/openapi/OperationListItem.tsx +69 -42
- package/src/lib/plugins/openapi/ParameterList.tsx +1 -1
- package/src/lib/plugins/openapi/ParameterListItem.tsx +3 -4
- package/src/lib/plugins/openapi/{MakeRequest.tsx → PlaygroundDialogWrapper.tsx} +4 -4
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +2 -16
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +3 -1
- package/src/lib/plugins/openapi/Route.tsx +21 -0
- package/src/lib/plugins/openapi/SchemaListView.tsx +23 -192
- package/src/lib/plugins/openapi/SchemaListViewItem.tsx +110 -0
- package/src/lib/plugins/openapi/SchemaListViewItemGroup.tsx +63 -0
- package/src/lib/plugins/openapi/Sidecar.tsx +15 -10
- package/src/lib/plugins/openapi/{Select.tsx → SimpleSelect.tsx} +6 -3
- package/src/lib/plugins/openapi/client/createMemoryClient.ts +56 -0
- package/src/lib/plugins/openapi/client/createServer.ts +33 -0
- package/src/lib/plugins/openapi/{worker/createSharedWorkerClient.ts → client/createWorkerClient.ts} +21 -2
- package/src/lib/plugins/openapi/client/interfaces.ts +5 -0
- package/src/lib/plugins/openapi/{worker → client}/worker.ts +3 -3
- package/src/lib/plugins/openapi/context.tsx +16 -0
- package/src/lib/plugins/openapi/index.tsx +59 -52
- package/src/lib/plugins/openapi/interfaces.ts +9 -0
- package/src/lib/plugins/openapi/playground/Headers.tsx +60 -33
- package/src/lib/plugins/openapi/playground/PathParams.tsx +1 -1
- package/src/lib/plugins/openapi/playground/Playground.tsx +158 -193
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +34 -0
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +7 -2
- package/src/lib/plugins/openapi/playground/createUrl.ts +1 -1
- package/src/lib/plugins/openapi/util/prose.ts +7 -0
- package/src/lib/plugins/openapi-worker.ts +1 -1
- package/src/lib/plugins/redirect/index.tsx +3 -4
- package/src/lib/ui/Callout.tsx +4 -4
- package/src/lib/util/MdxComponents.tsx +6 -14
- package/src/lib/util/groupBy.ts +7 -12
- package/src/lib/util/logInit.ts +9 -0
- package/src/lib/util/objectEntries.ts +5 -0
- package/src/lib/util/renderIf.ts +4 -0
- package/dist/lib/components/Link.d.ts +0 -1
- package/dist/lib/components/Link.js +0 -2
- package/dist/lib/components/Link.js.map +0 -1
- package/dist/lib/components/Router.d.ts +0 -4
- package/dist/lib/components/Router.js +0 -20
- package/dist/lib/components/Router.js.map +0 -1
- package/dist/lib/core/helmet.d.ts +0 -4
- package/dist/lib/core/helmet.js +0 -5
- package/dist/lib/core/helmet.js.map +0 -1
- package/dist/lib/core/icons.d.ts +0 -1
- package/dist/lib/core/icons.js +0 -2
- package/dist/lib/core/icons.js.map +0 -1
- package/dist/lib/core/router.d.ts +0 -1
- package/dist/lib/core/router.js +0 -2
- package/dist/lib/core/router.js.map +0 -1
- package/dist/lib/plugins/api-key/CreateApiKey.d.ts +0 -5
- package/dist/lib/plugins/api-key/CreateApiKey.js.map +0 -1
- package/dist/lib/plugins/api-key/SettingsApiKeys.d.ts +0 -5
- package/dist/lib/plugins/api-key/SettingsApiKeys.js +0 -37
- package/dist/lib/plugins/api-key/SettingsApiKeys.js.map +0 -1
- package/dist/lib/plugins/api-key/index.js.map +0 -1
- package/dist/lib/plugins/index.d.ts +0 -4
- package/dist/lib/plugins/index.js +0 -5
- package/dist/lib/plugins/index.js.map +0 -1
- package/dist/lib/plugins/openapi/MakeRequest.js.map +0 -1
- package/dist/lib/plugins/openapi/Select.js +0 -5
- package/dist/lib/plugins/openapi/Select.js.map +0 -1
- package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.d.ts +0 -5
- package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.js.map +0 -1
- package/dist/lib/plugins/openapi/worker/shared-worker.d.ts +0 -1
- package/dist/lib/plugins/openapi/worker/shared-worker.js +0 -6
- package/dist/lib/plugins/openapi/worker/shared-worker.js.map +0 -1
- package/dist/lib/plugins/openapi/worker/worker.js.map +0 -1
- package/dist/vite/common.d.ts +0 -1
- package/dist/vite/common.js +0 -5
- package/dist/vite/common.js.map +0 -1
- package/dist/vite/plugin-html.d.ts +0 -3
- package/dist/vite/plugin-html.js +0 -47
- package/dist/vite/plugin-html.js.map +0 -1
- package/dist/vite/plugin-openapi-worker.d.ts +0 -4
- package/dist/vite/plugin-openapi-worker.js +0 -28
- package/dist/vite/plugin-openapi-worker.js.map +0 -1
- package/lib/Spinner-DWHrSHMP.js +0 -8411
- package/lib/clerk-Wslx_mPo.js +0 -19685
- package/lib/index-DNx3xWa2.js +0 -3461
- package/lib/state-DfftBQ9X.js +0 -312
- package/lib/zudoku.plugins.js +0 -19873
- package/src/lib/components/Link.tsx +0 -1
- package/src/lib/components/Router.tsx +0 -28
- package/src/lib/core/helmet.ts +0 -5
- package/src/lib/core/icons.tsx +0 -1
- package/src/lib/core/router.tsx +0 -1
- package/src/lib/plugins/api-key/SettingsApiKeys.tsx +0 -122
- package/src/lib/plugins/index.ts +0 -4
- package/src/lib/plugins/openapi/worker/shared-worker.ts +0 -5
- /package/dist/lib/plugins/openapi/{worker → client}/worker.d.ts +0 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { QueryClient } from "@tanstack/react-query";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
import { create } from "zustand";
|
|
4
3
|
import { type AuthenticationProvider } from "../authentication/authentication.js";
|
|
4
|
+
import type { ComponentsContextType } from "../components/context/ComponentsContext.js";
|
|
5
|
+
import { type DevPortalPath } from "../components/DevPortal.js";
|
|
6
|
+
import type { MdxComponentsType } from "../util/MdxComponents.js";
|
|
5
7
|
import {
|
|
6
|
-
type
|
|
7
|
-
type DevPortalProps,
|
|
8
|
-
} from "../components/DevPortal.js";
|
|
9
|
-
import {
|
|
8
|
+
type DevPortalPlugin,
|
|
10
9
|
isApiIdentityPlugin,
|
|
11
10
|
isNavigationPlugin,
|
|
12
|
-
needsInitialization,
|
|
13
|
-
type DevPortalPlugin,
|
|
14
11
|
type NavigationPlugin,
|
|
12
|
+
needsInitialization,
|
|
15
13
|
} from "./plugins.js";
|
|
16
14
|
|
|
17
15
|
export interface ApiIdentity {
|
|
@@ -55,40 +53,61 @@ export type NavigationItem = {
|
|
|
55
53
|
categories?: NavigationCategory[];
|
|
56
54
|
};
|
|
57
55
|
|
|
58
|
-
export type RoutingState = {
|
|
59
|
-
path?: string;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
56
|
export const queryClient = new QueryClient();
|
|
63
57
|
|
|
64
|
-
export const useRoutingState = create<RoutingState>(() => ({}));
|
|
65
|
-
|
|
66
58
|
export type ApiKeyCache = "api-keys";
|
|
67
59
|
export type DevPortalCacheKey = ApiKeyCache | string;
|
|
68
60
|
|
|
61
|
+
type Metadata = Partial<{
|
|
62
|
+
title: string;
|
|
63
|
+
description: string;
|
|
64
|
+
logo: string;
|
|
65
|
+
favicon: string;
|
|
66
|
+
generator: string;
|
|
67
|
+
applicationName: string;
|
|
68
|
+
referrer: string;
|
|
69
|
+
keywords: string[];
|
|
70
|
+
authors: string[];
|
|
71
|
+
creator: string;
|
|
72
|
+
publisher: string;
|
|
73
|
+
}>;
|
|
74
|
+
type Page = Partial<{
|
|
75
|
+
pageTitle?: string;
|
|
76
|
+
logo?: string;
|
|
77
|
+
}>;
|
|
78
|
+
export type ZudokuContextOptions = {
|
|
79
|
+
metadata?: Metadata;
|
|
80
|
+
page?: Page;
|
|
81
|
+
authentication?: AuthenticationProvider;
|
|
82
|
+
navigation: NavigationItem[];
|
|
83
|
+
plugins?: DevPortalPlugin[];
|
|
84
|
+
mdxComponents?: MdxComponentsType;
|
|
85
|
+
overrides?: ComponentsContextType;
|
|
86
|
+
};
|
|
87
|
+
|
|
69
88
|
export class DevPortalContext {
|
|
70
|
-
private plugins:
|
|
89
|
+
private plugins: NonNullable<ZudokuContextOptions["plugins"]> = [];
|
|
90
|
+
public navigation: ZudokuContextOptions["navigation"];
|
|
91
|
+
public meta: ZudokuContextOptions["metadata"];
|
|
92
|
+
public page: ZudokuContextOptions["page"];
|
|
93
|
+
public authentication?: ZudokuContextOptions["authentication"];
|
|
71
94
|
private navigationPlugins: NavigationPlugin[];
|
|
72
95
|
|
|
73
|
-
|
|
74
|
-
public meta: DevPortalProps["meta"];
|
|
75
|
-
public authentication?: AuthenticationProvider;
|
|
76
|
-
public state: typeof useRoutingState;
|
|
77
|
-
|
|
78
|
-
constructor(config: DevPortalProps) {
|
|
96
|
+
constructor(config: ZudokuContextOptions) {
|
|
79
97
|
this.plugins = config.plugins ?? [];
|
|
80
98
|
this.navigation = config.navigation;
|
|
81
99
|
this.navigationPlugins = this.plugins.filter(isNavigationPlugin);
|
|
82
100
|
this.authentication = config.authentication;
|
|
83
|
-
this.meta = config.
|
|
84
|
-
this.
|
|
101
|
+
this.meta = config.metadata;
|
|
102
|
+
this.page = config.page;
|
|
85
103
|
}
|
|
86
104
|
|
|
87
105
|
initialize = async () => {
|
|
88
|
-
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
await Promise.all([
|
|
107
|
+
this.plugins
|
|
108
|
+
.filter(needsInitialization)
|
|
109
|
+
.map((plugin) => plugin.initialize?.(this)),
|
|
110
|
+
]);
|
|
92
111
|
};
|
|
93
112
|
|
|
94
113
|
invalidateCache = async (key: DevPortalCacheKey[]) => {
|
|
@@ -115,7 +134,7 @@ export class DevPortalContext {
|
|
|
115
134
|
return navigations.flatMap((nav) => nav ?? []);
|
|
116
135
|
};
|
|
117
136
|
|
|
118
|
-
async
|
|
137
|
+
signRequest = async (request: Request) => {
|
|
119
138
|
if (!this.authentication) {
|
|
120
139
|
throw new Error("No authentication provider configured");
|
|
121
140
|
}
|
|
@@ -125,5 +144,5 @@ export class DevPortalContext {
|
|
|
125
144
|
request.headers.set("Authorization", `Bearer ${accessToken}`);
|
|
126
145
|
|
|
127
146
|
return request;
|
|
128
|
-
}
|
|
147
|
+
};
|
|
129
148
|
}
|
package/src/lib/core/plugins.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
1
2
|
import { type RouteObject } from "react-router-dom";
|
|
2
3
|
import {
|
|
3
4
|
DevPortalContext,
|
|
@@ -10,9 +11,9 @@ export type PluginNavigationCategory = {
|
|
|
10
11
|
} & NavigationCategory;
|
|
11
12
|
|
|
12
13
|
export type DevPortalPlugin =
|
|
14
|
+
| CommonPlugin
|
|
13
15
|
| NavigationPlugin
|
|
14
|
-
| ApiIdentityPlugin
|
|
15
|
-
| InitializationPlugin;
|
|
16
|
+
| ApiIdentityPlugin;
|
|
16
17
|
|
|
17
18
|
export interface NavigationPlugin {
|
|
18
19
|
getRoutes: () => RouteObject[];
|
|
@@ -23,8 +24,9 @@ export interface ApiIdentityPlugin {
|
|
|
23
24
|
getIdentities: (context: DevPortalContext) => Promise<ApiIdentity[]>;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export interface
|
|
27
|
-
initialize
|
|
27
|
+
export interface CommonPlugin {
|
|
28
|
+
initialize?: (context: DevPortalContext) => Promise<void> | void;
|
|
29
|
+
getHead?: () => ReactElement | undefined;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export const isNavigationPlugin = (
|
|
@@ -34,9 +36,12 @@ export const isNavigationPlugin = (
|
|
|
34
36
|
|
|
35
37
|
export const needsInitialization = (
|
|
36
38
|
obj: DevPortalPlugin,
|
|
37
|
-
): obj is
|
|
39
|
+
): obj is CommonPlugin =>
|
|
38
40
|
"initialize" in obj && typeof obj.initialize === "function";
|
|
39
41
|
|
|
42
|
+
export const hasHead = (obj: DevPortalPlugin): obj is CommonPlugin =>
|
|
43
|
+
"getHead" in obj && typeof obj.getHead === "function";
|
|
44
|
+
|
|
40
45
|
export const isApiIdentityPlugin = (
|
|
41
46
|
obj: DevPortalPlugin,
|
|
42
47
|
): obj is ApiIdentityPlugin =>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
export function ErrorAlert({ error }: { error: any }) {
|
|
3
|
+
const message = error?.message ?? "Something went wrong";
|
|
4
|
+
const stack = error?.stack;
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
<div className="flex h-screen max-h-screen min-h-full items-center justify-center bg-primary-background px-4 py-16 lg:px-8">
|
|
8
|
+
<div className="mx-auto max-w-[85%] sm:max-w-[50%]">
|
|
9
|
+
<h1 className="text-4xl font-bold tracking-tight text-h1-text sm:text-5xl">
|
|
10
|
+
Something went wrong
|
|
11
|
+
</h1>
|
|
12
|
+
<p className="mt-5 text-h1-text">{message}</p>
|
|
13
|
+
{stack ? (
|
|
14
|
+
<pre className="mt-5 max-h-[400px] w-full overflow-scroll rounded-md border border-input-border bg-input-background p-3 text-property-name-text text-red-700">
|
|
15
|
+
{stack}
|
|
16
|
+
</pre>
|
|
17
|
+
) : null}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isRouteErrorResponse, useRouteError } from "react-router-dom";
|
|
2
|
+
import { NotFoundPage } from "../components/NotFoundPage.js";
|
|
3
|
+
import { ErrorAlert } from "./ErrorAlert.js";
|
|
4
|
+
|
|
5
|
+
export function RouterError() {
|
|
6
|
+
const error = useRouteError();
|
|
7
|
+
|
|
8
|
+
if (isRouteErrorResponse(error) && error.status === 404) {
|
|
9
|
+
return <NotFoundPage />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return <ErrorAlert error={error} />;
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FallbackProps } from "react-error-boundary";
|
|
2
|
+
import { ErrorAlert } from "./ErrorAlert.js";
|
|
3
|
+
|
|
4
|
+
export function TopLevelError({ error, resetErrorBoundary }: FallbackProps) {
|
|
5
|
+
// Call resetErrorBoundary() to reset the error boundary and retry the render.
|
|
6
|
+
|
|
7
|
+
return <ErrorAlert error={error} />;
|
|
8
|
+
}
|
|
@@ -45,7 +45,7 @@ export const slugifyOperation = (operation: OperationLike, tag?: string) => {
|
|
|
45
45
|
);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const cache = new LRUCache<string, OpenAPIDocument
|
|
48
|
+
const cache = new LRUCache<string, Promise<OpenAPIDocument>>({
|
|
49
49
|
ttl: 60 * 10 * 1000,
|
|
50
50
|
ttlAutopurge: true,
|
|
51
51
|
});
|
|
@@ -384,7 +384,7 @@ const loadOpenAPISchema = async (input: NonNullable<unknown>) => {
|
|
|
384
384
|
return cache.get(hash)!;
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
const schema =
|
|
387
|
+
const schema = validate(input);
|
|
388
388
|
|
|
389
389
|
cache.set(hash, schema);
|
|
390
390
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GraphQLError } from "graphql/error/index.js";
|
|
1
2
|
import { OpenAPIV3, type OpenAPIV3_1 } from "openapi-types";
|
|
2
3
|
import { dereference, type JSONSchema } from "./dereference/index.js";
|
|
3
4
|
import { upgradeSchema } from "./upgrade/index.js";
|
|
@@ -9,10 +10,6 @@ type DeepOmitReference<T> = T extends ReferenceObject
|
|
|
9
10
|
? { [K in keyof T]: DeepOmitReference<T[K]> }
|
|
10
11
|
: T;
|
|
11
12
|
|
|
12
|
-
// type Prettify<T> = {
|
|
13
|
-
// [K in keyof T]: T[K];
|
|
14
|
-
// } & {};
|
|
15
|
-
|
|
16
13
|
export type OpenAPIDocument = DeepOmitReference<OpenAPIV3_1.Document>;
|
|
17
14
|
export type ResponseObject = DeepOmitReference<OpenAPIV3_1.ResponseObject>;
|
|
18
15
|
export type OperationObject = DeepOmitReference<OpenAPIV3_1.OperationObject>;
|
|
@@ -46,35 +43,63 @@ export const HttpMethods = Object.values(OpenAPIV3.HttpMethods);
|
|
|
46
43
|
// };
|
|
47
44
|
|
|
48
45
|
const parseSchemaInput = async (
|
|
49
|
-
|
|
50
|
-
schemaInput: any,
|
|
46
|
+
schemaInput: unknown,
|
|
51
47
|
): Promise<JSONSchema & { openapi?: string }> => {
|
|
52
48
|
if (typeof schemaInput === "string") {
|
|
53
49
|
if (schemaInput.trim().startsWith("{")) {
|
|
54
|
-
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(schemaInput);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
throw new GraphQLError("Invalid JSON schema", {
|
|
54
|
+
originalError: err,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
if (schemaInput.includes("://")) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
let response;
|
|
60
|
+
try {
|
|
61
|
+
response = await fetch(schemaInput, {
|
|
62
|
+
cache: "force-cache",
|
|
63
|
+
});
|
|
64
|
+
} catch (err) {
|
|
65
|
+
throw new GraphQLError("Failed to fetch schema", {
|
|
66
|
+
originalError: err,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new GraphQLError(
|
|
72
|
+
`Failed to fetch schema: ${response.statusText}`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
return (await response.json()) as JSONSchema;
|
|
78
|
+
} catch (err) {
|
|
79
|
+
throw new GraphQLError("Fetched invalid JSON schema", {
|
|
80
|
+
originalError: err,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
59
83
|
}
|
|
60
84
|
const yaml = await import("yaml");
|
|
61
|
-
|
|
85
|
+
const parsed = yaml.parse(schemaInput);
|
|
86
|
+
|
|
87
|
+
if (typeof parsed === "object") return parsed;
|
|
62
88
|
}
|
|
63
89
|
|
|
64
|
-
if (typeof schemaInput === "object") return schemaInput;
|
|
90
|
+
if (typeof schemaInput === "object") return schemaInput as JSONSchema;
|
|
65
91
|
|
|
66
|
-
throw new
|
|
92
|
+
throw new GraphQLError("Unsupported schema input: " + schemaInput);
|
|
67
93
|
};
|
|
68
94
|
|
|
69
95
|
/**
|
|
70
96
|
* Validates, dereferences and upgrades the OpenAPI schema (to v3.1) if necessary.
|
|
71
97
|
*/
|
|
72
|
-
|
|
73
|
-
export const validate = async (schemaInput: any) => {
|
|
98
|
+
export const validate = async (schemaInput: unknown) => {
|
|
74
99
|
const schema = await parseSchemaInput(schemaInput);
|
|
75
100
|
|
|
76
101
|
if (!schema.openapi) {
|
|
77
|
-
throw new
|
|
102
|
+
throw new GraphQLError("OpenAPI version is not defined");
|
|
78
103
|
}
|
|
79
104
|
|
|
80
105
|
// const validator = await getValidator(schema.openapi);
|
|
@@ -86,9 +111,5 @@ export const validate = async (schemaInput: any) => {
|
|
|
86
111
|
|
|
87
112
|
const dereferenced = await dereference(schema);
|
|
88
113
|
|
|
89
|
-
|
|
90
|
-
dereferenced as OpenAPIV3_1.Document | OpenAPIV3.Document,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
return upgraded;
|
|
114
|
+
return upgradeSchema(dereferenced);
|
|
94
115
|
};
|
|
@@ -12,17 +12,11 @@ import {
|
|
|
12
12
|
SelectValue,
|
|
13
13
|
} from "../../components/Select.js";
|
|
14
14
|
import { Button } from "../../ui/Button.js";
|
|
15
|
-
import {
|
|
15
|
+
import { ApiKeyService } from "./index.js";
|
|
16
16
|
|
|
17
17
|
type CreateApiKey = { description: string; expiresOn?: string };
|
|
18
18
|
|
|
19
|
-
export const CreateApiKey = ({
|
|
20
|
-
options,
|
|
21
|
-
service,
|
|
22
|
-
}: {
|
|
23
|
-
options: ApiKeyPluginOptions;
|
|
24
|
-
service: ApiKeyService;
|
|
25
|
-
}) => {
|
|
19
|
+
export const CreateApiKey = ({ service }: { service: ApiKeyService }) => {
|
|
26
20
|
const context = useDevPortal();
|
|
27
21
|
const navigate = useNavigate();
|
|
28
22
|
const form = useForm<CreateApiKey>({
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useMutation,
|
|
3
|
+
useQueryClient,
|
|
4
|
+
useSuspenseQuery,
|
|
5
|
+
} from "@tanstack/react-query";
|
|
6
|
+
import { EyeIcon, EyeOffIcon, RotateCwIcon, TrashIcon } from "lucide-react";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { Link } from "react-router-dom";
|
|
9
|
+
import { useDevPortal } from "../../components/context/DevPortalProvider.js";
|
|
10
|
+
import { Button } from "../../ui/Button.js";
|
|
11
|
+
import { cn } from "../../util/cn.js";
|
|
12
|
+
import { ApiKeyService } from "./index.js";
|
|
13
|
+
|
|
14
|
+
export const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {
|
|
15
|
+
const context = useDevPortal();
|
|
16
|
+
const queryClient = useQueryClient();
|
|
17
|
+
const { data } = useSuspenseQuery({
|
|
18
|
+
queryFn: () => service.getKeys(context),
|
|
19
|
+
queryKey: ["api-keys"],
|
|
20
|
+
retry: false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const deleteKeyMutation = useMutation({
|
|
24
|
+
mutationFn: (id: string) => {
|
|
25
|
+
if (!service.deleteKey) {
|
|
26
|
+
throw new Error("deleteKey not implemented");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return service.deleteKey(id, context);
|
|
30
|
+
},
|
|
31
|
+
onSuccess: () => {
|
|
32
|
+
void queryClient.invalidateQueries({ queryKey: ["api-keys"] });
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className="max-w-screen-lg h-full pt-[--padding-content-top] pb-[--padding-content-bottom]">
|
|
38
|
+
<div className="flex justify-between mb-4 border-b border-border pb-3">
|
|
39
|
+
<h1 className="font-medium text-2xl">API Keys</h1>
|
|
40
|
+
{service.createKey && (
|
|
41
|
+
<Button asChild>
|
|
42
|
+
<Link to="/settings/api-keys/new">Create API Key</Link>
|
|
43
|
+
</Button>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
{data.length === 0 ? (
|
|
48
|
+
<div className="flex flex-col justify-center gap-4 items-center h-1/2 my-8">
|
|
49
|
+
<div className="text-center">
|
|
50
|
+
No API keys created yet.
|
|
51
|
+
<br />
|
|
52
|
+
Get started and create the first one now
|
|
53
|
+
</div>
|
|
54
|
+
{service.createKey && (
|
|
55
|
+
<Button asChild>
|
|
56
|
+
<Link to="/settings/api-keys/new">Create API Key</Link>
|
|
57
|
+
</Button>
|
|
58
|
+
)}
|
|
59
|
+
</div>
|
|
60
|
+
) : (
|
|
61
|
+
<ul
|
|
62
|
+
className={cn(
|
|
63
|
+
"grid grid-cols-1 rounded border-border border",
|
|
64
|
+
"lg:grid-cols-[minmax(250px,min-content)_1fr_min-content]",
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
{data.map((key) => (
|
|
68
|
+
<li
|
|
69
|
+
className="border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center"
|
|
70
|
+
key={key.id}
|
|
71
|
+
>
|
|
72
|
+
<div className="flex flex-col gap-1 text-sm">
|
|
73
|
+
{key.description ?? key.id}
|
|
74
|
+
<div className="text-muted-foreground text-xs">
|
|
75
|
+
{key.createdOn && (
|
|
76
|
+
<div>
|
|
77
|
+
Created on {new Date(key.createdOn).toLocaleDateString()}
|
|
78
|
+
</div>
|
|
79
|
+
)}
|
|
80
|
+
{key.expiresOn && (
|
|
81
|
+
<div>
|
|
82
|
+
Expires on {new Date(key.expiresOn).toLocaleDateString()}
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
<div className="items-center flex lg:justify-center">
|
|
88
|
+
<RevealApiKey apiKey={key.key} />
|
|
89
|
+
</div>
|
|
90
|
+
<div className="flex gap-2">
|
|
91
|
+
{service.rollKey && (
|
|
92
|
+
<Button size="icon">
|
|
93
|
+
<RotateCwIcon size={16} />
|
|
94
|
+
</Button>
|
|
95
|
+
)}
|
|
96
|
+
{service.deleteKey && (
|
|
97
|
+
<Button
|
|
98
|
+
variant="ghost"
|
|
99
|
+
size="icon"
|
|
100
|
+
onClick={() => {
|
|
101
|
+
if (!confirm("Do you want to delete this key?")) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
deleteKeyMutation.mutate(key.id);
|
|
106
|
+
}}
|
|
107
|
+
disabled={deleteKeyMutation.isPending}
|
|
108
|
+
>
|
|
109
|
+
<TrashIcon size={16} />
|
|
110
|
+
</Button>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
</li>
|
|
114
|
+
))}
|
|
115
|
+
</ul>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const RevealApiKey = ({ apiKey }: { apiKey: string }) => {
|
|
122
|
+
const [revealed, setRevealed] = useState(false);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div className="flex gap-2 items-center text-sm w-full">
|
|
126
|
+
<input
|
|
127
|
+
className="border border-border rounded bg-gray-100 dark:bg-gray-950 p-1 font-mono max-w-min"
|
|
128
|
+
value={revealed ? apiKey : "•".repeat(apiKey.length)}
|
|
129
|
+
/>
|
|
130
|
+
<Button
|
|
131
|
+
variant="outline"
|
|
132
|
+
onClick={() => setRevealed((prev) => !prev)}
|
|
133
|
+
size="icon"
|
|
134
|
+
>
|
|
135
|
+
{revealed ? <EyeOffIcon size={16} /> : <EyeIcon size={16} />}
|
|
136
|
+
</Button>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { Outlet } from "react-router-dom";
|
|
1
|
+
import { Outlet, type RouteObject } from "react-router-dom";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
2
3
|
import { useAuth } from "../../authentication/hook.js";
|
|
3
4
|
import { DevPortalContext } from "../../core/DevPortalContext.js";
|
|
4
5
|
import {
|
|
5
6
|
type ApiIdentityPlugin,
|
|
6
7
|
type DevPortalPlugin,
|
|
7
8
|
} from "../../core/plugins.js";
|
|
9
|
+
import { RouterError } from "../../errors/RouterError.js";
|
|
8
10
|
import { Button } from "../../ui/Button.js";
|
|
9
11
|
import { CreateApiKey } from "./CreateApiKey.js";
|
|
10
12
|
import { SettingsApiKeys } from "./SettingsApiKeys.js";
|
|
11
13
|
|
|
12
|
-
export type ApiKeyResults = Promise<ApiKey[]>;
|
|
13
14
|
const DEFAULT_API_KEY_ENDPOINT =
|
|
14
15
|
"https://zudoku-rewiringamerica-main-ef9c9c0.d2.zuplo.dev";
|
|
15
16
|
|
|
16
17
|
export type ApiKeyService = {
|
|
17
|
-
getKeys: (context: DevPortalContext) =>
|
|
18
|
+
getKeys: (context: DevPortalContext) => Promise<ApiKey[]>;
|
|
18
19
|
rollKey?: (id: string, context: DevPortalContext) => Promise<void>;
|
|
19
20
|
deleteKey?: (id: string, context: DevPortalContext) => Promise<void>;
|
|
20
21
|
updateKeyDescription?: (
|
|
21
|
-
apiKey: {
|
|
22
|
+
apiKey: { id: string; description: string },
|
|
22
23
|
context: DevPortalContext,
|
|
23
24
|
) => Promise<void>;
|
|
24
25
|
getUsage?: (apiKeys: string[], context: DevPortalContext) => Promise<void>;
|
|
@@ -50,7 +51,8 @@ const createDefaultHandler = (endpoint: string): ApiKeyService => {
|
|
|
50
51
|
|
|
51
52
|
await context.signRequest(request);
|
|
52
53
|
|
|
53
|
-
await fetch(request);
|
|
54
|
+
const response = await fetch(request);
|
|
55
|
+
invariant(response.ok, "Failed to delete API key");
|
|
54
56
|
},
|
|
55
57
|
createKey: async (apiKey, context) => {
|
|
56
58
|
const request = new Request(endpoint + `/v1/developer/api-keys`, {
|
|
@@ -62,7 +64,9 @@ const createDefaultHandler = (endpoint: string): ApiKeyService => {
|
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
await context.signRequest(request);
|
|
65
|
-
|
|
67
|
+
|
|
68
|
+
const response = await fetch(request);
|
|
69
|
+
invariant(response.ok, "Failed to create API key");
|
|
66
70
|
},
|
|
67
71
|
getKeys: async (context) => {
|
|
68
72
|
const request = new Request(endpoint + `/v1/developer/api-keys`);
|
|
@@ -70,6 +74,7 @@ const createDefaultHandler = (endpoint: string): ApiKeyService => {
|
|
|
70
74
|
await context.signRequest(request);
|
|
71
75
|
|
|
72
76
|
const keys = await fetch(request);
|
|
77
|
+
invariant(keys.ok, "Failed to fetch API keys");
|
|
73
78
|
|
|
74
79
|
return await keys.json();
|
|
75
80
|
},
|
|
@@ -78,6 +83,12 @@ const createDefaultHandler = (endpoint: string): ApiKeyService => {
|
|
|
78
83
|
|
|
79
84
|
const ProtectedRoute = () => {
|
|
80
85
|
const auth = useAuth();
|
|
86
|
+
|
|
87
|
+
// TODO: should we suspend here somehow?
|
|
88
|
+
if (auth.isPending) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
81
92
|
return auth.isAuthenticated ? (
|
|
82
93
|
<Outlet />
|
|
83
94
|
) : (
|
|
@@ -114,18 +125,20 @@ export const apiKeyPlugin = (
|
|
|
114
125
|
return [];
|
|
115
126
|
}
|
|
116
127
|
},
|
|
117
|
-
getRoutes: () => {
|
|
128
|
+
getRoutes: (): RouteObject[] => {
|
|
129
|
+
// TODO: Make lazy
|
|
118
130
|
return [
|
|
119
131
|
{
|
|
120
132
|
element: <ProtectedRoute />,
|
|
133
|
+
errorElement: <RouterError />,
|
|
121
134
|
children: [
|
|
122
135
|
{
|
|
123
136
|
path: "/settings/api-keys",
|
|
124
|
-
element: <SettingsApiKeys
|
|
137
|
+
element: <SettingsApiKeys service={service} />,
|
|
125
138
|
},
|
|
126
139
|
{
|
|
127
140
|
path: "/settings/api-keys/new",
|
|
128
|
-
element: <CreateApiKey
|
|
141
|
+
element: <CreateApiKey service={service} />,
|
|
129
142
|
},
|
|
130
143
|
],
|
|
131
144
|
},
|