zudoku 0.3.0-dev.11 → 0.3.0-dev.111
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/LICENSE.md +21 -0
- package/cli.js +5 -1
- package/dist/app/App.d.ts +1 -2
- package/dist/app/App.js +1 -29
- package/dist/app/App.js.map +1 -1
- package/dist/app/demo.d.ts +2 -0
- package/dist/app/demo.js +46 -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 +14 -0
- package/dist/app/entry.server.js +105 -0
- package/dist/app/entry.server.js.map +1 -0
- package/dist/app/main.d.ts +6 -1
- package/dist/app/main.js +79 -12
- package/dist/app/main.js.map +1 -1
- package/dist/app/standalone.d.ts +2 -0
- package/dist/app/standalone.js +51 -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/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 +19 -45
- package/dist/config/validators/InputSidebarSchema.d.ts +176 -0
- package/dist/config/validators/InputSidebarSchema.js +71 -0
- package/dist/config/validators/InputSidebarSchema.js.map +1 -0
- package/dist/config/validators/SidebarSchema.d.ts +17 -0
- package/dist/config/validators/SidebarSchema.js +76 -0
- package/dist/config/validators/SidebarSchema.js.map +1 -0
- package/dist/config/validators/validate.d.ts +1323 -2
- package/dist/config/validators/validate.js +179 -1
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/index.d.ts +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/AuthenticationPlugin.d.ts +13 -0
- package/dist/lib/authentication/AuthenticationPlugin.js +31 -0
- package/dist/lib/authentication/AuthenticationPlugin.js.map +1 -0
- package/dist/lib/authentication/authentication.d.ts +10 -9
- package/dist/lib/authentication/components/SignIn.d.ts +1 -0
- package/dist/lib/authentication/components/SignIn.js +14 -0
- package/dist/lib/authentication/components/SignIn.js.map +1 -0
- package/dist/lib/authentication/components/SignOut.d.ts +1 -0
- package/dist/lib/authentication/components/SignOut.js +12 -0
- package/dist/lib/authentication/components/SignOut.js.map +1 -0
- package/dist/lib/authentication/components/SignUp.d.ts +1 -0
- package/dist/lib/authentication/components/SignUp.js +10 -0
- package/dist/lib/authentication/components/SignUp.js.map +1 -0
- package/dist/lib/authentication/hook.js +4 -4
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +11 -6
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/clerk.js +59 -30
- package/dist/lib/authentication/providers/clerk.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +30 -7
- package/dist/lib/authentication/providers/openid.js +79 -29
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/authentication/state.js +1 -1
- package/dist/lib/authentication/state.js.map +1 -1
- package/dist/lib/components/Bootstrap.d.ts +13 -0
- package/dist/lib/components/Bootstrap.js +12 -0
- package/dist/lib/components/Bootstrap.js.map +1 -0
- package/dist/lib/components/ClientOnly.d.ts +3 -0
- package/dist/lib/components/ClientOnly.js +7 -0
- package/dist/lib/components/ClientOnly.js.map +1 -0
- package/dist/lib/components/DevPortal.d.ts +5 -23
- package/dist/lib/components/DevPortal.js +38 -20
- package/dist/lib/components/DevPortal.js.map +1 -1
- package/dist/lib/components/DeveloperHint.d.ts +5 -0
- package/dist/lib/components/DeveloperHint.js +10 -0
- package/dist/lib/components/DeveloperHint.js.map +1 -0
- 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 +26 -5
- 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 +7 -5
- 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/Search.d.ts +1 -0
- package/dist/lib/components/Search.js +34 -0
- package/dist/lib/components/Search.js.map +1 -0
- package/dist/lib/components/SlotletProvider.d.ts +9 -0
- package/dist/lib/components/SlotletProvider.js +16 -0
- package/dist/lib/components/SlotletProvider.js.map +1 -0
- package/dist/lib/components/SyntaxHighlight.d.ts +3 -2
- package/dist/lib/components/SyntaxHighlight.js +24 -22
- package/dist/lib/components/SyntaxHighlight.js.map +1 -1
- package/dist/lib/components/TopNavigation.d.ts +1 -1
- package/dist/lib/components/TopNavigation.js +8 -4
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/context/ThemeContext.d.ts +1 -4
- package/dist/lib/components/context/ThemeContext.js +3 -29
- package/dist/lib/components/context/ThemeContext.js.map +1 -1
- package/dist/lib/components/context/ThemeProvider.d.ts +4 -0
- package/dist/lib/components/context/ThemeProvider.js +23 -0
- package/dist/lib/components/context/ThemeProvider.js.map +1 -0
- package/dist/lib/components/context/ZudokuContext.d.ts +15 -0
- package/dist/lib/components/context/ZudokuContext.js +46 -0
- package/dist/lib/components/context/ZudokuContext.js.map +1 -0
- package/dist/lib/components/context/ZudokuProvider.d.ts +5 -0
- package/dist/lib/components/context/ZudokuProvider.js +16 -0
- package/dist/lib/components/context/ZudokuProvider.js.map +1 -0
- package/dist/lib/components/index.d.ts +32 -3
- package/dist/lib/components/index.js +21 -3
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/components/navigation/Sidebar.d.ts +1 -0
- package/dist/lib/components/navigation/Sidebar.js +12 -0
- package/dist/lib/components/navigation/Sidebar.js.map +1 -0
- package/dist/lib/components/navigation/SidebarBadge.d.ts +23 -0
- package/dist/lib/components/navigation/SidebarBadge.js +24 -0
- package/dist/lib/components/navigation/SidebarBadge.js.map +1 -0
- package/dist/lib/components/navigation/SidebarCategory.d.ts +5 -0
- package/dist/lib/components/navigation/SidebarCategory.js +33 -0
- package/dist/lib/components/navigation/SidebarCategory.js.map +1 -0
- package/dist/lib/components/navigation/SidebarItem.d.ts +12 -0
- package/dist/lib/components/navigation/SidebarItem.js +42 -0
- package/dist/lib/components/navigation/SidebarItem.js.map +1 -0
- package/dist/lib/components/navigation/{SideNavigationWrapper.d.ts → SidebarWrapper.d.ts} +1 -1
- package/dist/lib/components/navigation/{SideNavigationWrapper.js → SidebarWrapper.js} +2 -2
- package/dist/lib/components/navigation/SidebarWrapper.js.map +1 -0
- package/dist/lib/components/navigation/utils.d.ts +16 -0
- package/dist/lib/components/navigation/utils.js +85 -0
- package/dist/lib/components/navigation/utils.js.map +1 -0
- package/dist/lib/core/DevPortalContext.d.ts +58 -42
- package/dist/lib/core/DevPortalContext.js +18 -19
- package/dist/lib/core/DevPortalContext.js.map +1 -1
- package/dist/lib/core/plugins.d.ts +27 -8
- package/dist/lib/core/plugins.js +3 -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 +17 -8
- 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 -14
- package/dist/lib/oas/parser/index.js.map +1 -1
- package/dist/lib/plugins/{api-key → api-keys}/CreateApiKey.js +4 -4
- package/dist/lib/plugins/api-keys/CreateApiKey.js.map +1 -0
- package/dist/lib/plugins/api-keys/ProtectedRoute.d.ts +1 -0
- package/dist/lib/plugins/api-keys/ProtectedRoute.js +14 -0
- package/dist/lib/plugins/api-keys/ProtectedRoute.js.map +1 -0
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js +54 -0
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -0
- package/dist/lib/plugins/{api-key → api-keys}/index.d.ts +4 -5
- package/dist/lib/plugins/{api-key → api-keys}/index.js +18 -20
- package/dist/lib/plugins/api-keys/index.js.map +1 -0
- package/dist/lib/plugins/custom-page/index.d.ts +8 -0
- package/dist/lib/plugins/custom-page/index.js +12 -0
- package/dist/lib/plugins/custom-page/index.js.map +1 -0
- package/dist/lib/plugins/markdown/MdxPage.d.ts +3 -2
- package/dist/lib/plugins/markdown/MdxPage.js +10 -40
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/markdown/Toc.js +17 -9
- 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 +20 -43
- 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/ColorizedParam.d.ts +2 -1
- package/dist/lib/plugins/openapi/ColorizedParam.js +14 -9
- package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +17 -5
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +11 -5
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterList.js +2 -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/PlaygroundDialogWrapper.d.ts +2 -1
- package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js +8 -28
- package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js.map +1 -1
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +3 -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 +10 -26
- package/dist/lib/plugins/openapi/SchemaListView.js.map +1 -1
- package/dist/lib/plugins/openapi/SchemaListViewItem.d.ts +8 -0
- package/dist/lib/plugins/openapi/SchemaListViewItem.js +25 -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.d.ts +4 -0
- package/dist/lib/plugins/openapi/Sidecar.js +48 -16
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/SidecarBox.d.ts +1 -0
- package/dist/lib/plugins/openapi/SidecarBox.js +3 -2
- package/dist/lib/plugins/openapi/SidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/SimpleSelect.js +1 -1
- package/dist/lib/plugins/openapi/SimpleSelect.js.map +1 -1
- package/dist/lib/plugins/openapi/StaggeredRender.d.ts +8 -0
- package/dist/lib/plugins/openapi/StaggeredRender.js +18 -0
- package/dist/lib/plugins/openapi/StaggeredRender.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/{worker/worker.js → client/createServer.js} +5 -19
- 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/client/worker.js +20 -0
- 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/graphql/gql.d.ts +6 -6
- package/dist/lib/plugins/openapi/graphql/gql.js +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +15 -15
- package/dist/lib/plugins/openapi/graphql/graphql.js +67 -67
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.d.ts +4 -18
- package/dist/lib/plugins/openapi/index.js +78 -33
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +16 -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.js +1 -1
- package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PathParams.d.ts +4 -5
- package/dist/lib/plugins/openapi/playground/PathParams.js +9 -13
- package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.d.ts +23 -11
- package/dist/lib/plugins/openapi/playground/Playground.js +51 -19
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.d.ts +3 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +3 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/QueryParams.d.ts +4 -3
- package/dist/lib/plugins/openapi/playground/QueryParams.js +21 -12
- package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/ResponseTab.d.ts +4 -0
- package/dist/lib/plugins/openapi/playground/ResponseTab.js +40 -0
- package/dist/lib/plugins/openapi/playground/ResponseTab.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/createUrl.d.ts +1 -1
- package/dist/lib/plugins/openapi/playground/createUrl.js +5 -9
- package/dist/lib/plugins/openapi/playground/createUrl.js.map +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/plugins/search-inkeep/InkeepCustomTrigger.d.ts +2 -0
- package/dist/lib/plugins/search-inkeep/InkeepCustomTrigger.js +3 -0
- package/dist/lib/plugins/search-inkeep/InkeepCustomTrigger.js.map +1 -0
- package/dist/lib/plugins/search-inkeep/index.d.ts +6 -0
- package/dist/lib/plugins/search-inkeep/index.js +18 -0
- package/dist/lib/plugins/search-inkeep/index.js.map +1 -0
- package/dist/lib/plugins/search-inkeep/inkeep.d.ts +23 -0
- package/dist/lib/plugins/search-inkeep/inkeep.js +23 -0
- package/dist/lib/plugins/search-inkeep/inkeep.js.map +1 -0
- package/dist/lib/ui/Button.d.ts +5 -1
- package/dist/lib/ui/Button.js +24 -1
- package/dist/lib/ui/Button.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/Card.js +1 -1
- package/dist/lib/ui/Card.js.map +1 -1
- package/dist/lib/ui/DropdownMenu.d.ts +27 -0
- package/dist/lib/ui/DropdownMenu.js +36 -0
- package/dist/lib/ui/DropdownMenu.js.map +1 -0
- package/dist/lib/ui/Input.js.map +1 -0
- package/dist/lib/util/MdxComponents.d.ts +2 -2
- package/dist/lib/util/MdxComponents.js +7 -5
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/lib/util/fetchTimeout.d.ts +1 -0
- package/dist/lib/util/fetchTimeout.js +14 -0
- package/dist/lib/util/fetchTimeout.js.map +1 -0
- 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/invariant.d.ts +6 -0
- package/dist/lib/util/invariant.js +21 -0
- package/dist/lib/util/invariant.js.map +1 -0
- package/dist/lib/util/joinPath.js +3 -2
- package/dist/lib/util/joinPath.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/lib/util/requestIdleCallbackPolyfill.d.ts +1 -0
- package/dist/lib/util/requestIdleCallbackPolyfill.js +7 -0
- package/dist/lib/util/requestIdleCallbackPolyfill.js.map +1 -0
- package/dist/lib/util/useScrollToAnchor.js +31 -17
- package/dist/lib/util/useScrollToAnchor.js.map +1 -1
- package/dist/vite/build.js +30 -7
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/config.d.ts +21 -12
- package/dist/vite/config.js +107 -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 +44 -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 +8 -24
- 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.d.ts +2 -2
- package/dist/vite/plugin-component.js +9 -4
- 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 +54 -0
- package/dist/vite/plugin-custom-css.js.map +1 -0
- package/dist/vite/plugin-docs.js +11 -5
- package/dist/vite/plugin-docs.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-sidebar.d.ts +3 -0
- package/dist/vite/plugin-sidebar.js +23 -0
- package/dist/vite/plugin-sidebar.js.map +1 -0
- package/dist/vite/plugin.js +7 -7
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite/prerender.d.ts +17 -0
- package/dist/vite/prerender.js +79 -0
- package/dist/vite/prerender.js.map +1 -0
- package/lib/AuthenticationPlugin-CH5NSVOu.js +55 -0
- package/lib/AuthenticationPlugin-CH5NSVOu.js.map +1 -0
- package/lib/CategoryHeading-BWq12Bfa.js +10 -0
- package/lib/CategoryHeading-BWq12Bfa.js.map +1 -0
- package/lib/Combination-D-9IH0zy.js +2789 -0
- package/lib/Combination-D-9IH0zy.js.map +1 -0
- package/lib/DeveloperHint-BQSFXH01.js +10 -0
- package/lib/DeveloperHint-BQSFXH01.js.map +1 -0
- package/lib/InkeepCustomTrigger-CE5-K5ex.js +6 -0
- package/lib/InkeepCustomTrigger-CE5-K5ex.js.map +1 -0
- package/lib/Input-HmAaR6kw.js +2239 -0
- package/lib/Input-HmAaR6kw.js.map +1 -0
- package/lib/Markdown-B_Gax7at.js +14108 -0
- package/lib/Markdown-B_Gax7at.js.map +1 -0
- package/lib/MdxPage-oN3huD58.js +187 -0
- package/lib/MdxPage-oN3huD58.js.map +1 -0
- package/lib/OperationList-Ctj0ihBN.js +448 -0
- package/lib/OperationList-Ctj0ihBN.js.map +1 -0
- package/lib/Route-DAF15JAU.js +14 -0
- package/lib/Route-DAF15JAU.js.map +1 -0
- package/lib/SlotletProvider-BG2PU1Mf.js +262 -0
- package/lib/SlotletProvider-BG2PU1Mf.js.map +1 -0
- package/lib/Spinner-BCz1kNGw.js +276 -0
- package/lib/Spinner-BCz1kNGw.js.map +1 -0
- package/lib/ZudokuContext-BIZ8zHbZ.js +1084 -0
- package/lib/ZudokuContext-BIZ8zHbZ.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-DGvzLstc.js → worker-CR7aeKop.js} +3113 -2729
- package/lib/assets/worker-CR7aeKop.js.map +1 -0
- package/lib/index-7kcHaXD6.js +1771 -0
- package/lib/index-7kcHaXD6.js.map +1 -0
- package/lib/index-CtKkHGcd.js +5942 -0
- package/lib/index-CtKkHGcd.js.map +1 -0
- package/lib/index-D-9Z7HSn.js +124 -0
- package/lib/index-D-9Z7HSn.js.map +1 -0
- package/lib/index-pI9JkN46.js +4765 -0
- package/lib/index-pI9JkN46.js.map +1 -0
- package/lib/joinPath-B7kNnUX4.js +8 -0
- package/lib/joinPath-B7kNnUX4.js.map +1 -0
- package/lib/jsx-runtime-B6kdoens.js +635 -0
- package/lib/jsx-runtime-B6kdoens.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 +1 -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 +1 -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-BiRCp01d.js +2971 -0
- package/lib/router-BiRCp01d.js.map +1 -0
- package/lib/slugify-CiPVjteN.js +28 -0
- package/lib/slugify-CiPVjteN.js.map +1 -0
- package/lib/state-DsXXkBLH.js +288 -0
- package/lib/state-DsXXkBLH.js.map +1 -0
- package/lib/{urql-DMlBWUKL.js → urql-DrBfkb92.js} +2 -2
- package/lib/urql-DrBfkb92.js.map +1 -0
- package/lib/utils-Bh4upQ0e.js +749 -0
- package/lib/utils-Bh4upQ0e.js.map +1 -0
- package/lib/zudoku.auth-auth0.js +31 -20
- package/lib/zudoku.auth-auth0.js.map +1 -0
- package/lib/zudoku.auth-clerk.js +59 -29
- package/lib/zudoku.auth-clerk.js.map +1 -0
- package/lib/zudoku.auth-openid.js +742 -573
- package/lib/zudoku.auth-openid.js.map +1 -0
- package/lib/zudoku.components.js +2064 -695
- package/lib/zudoku.components.js.map +1 -0
- package/lib/zudoku.openapi-worker.js +15035 -146
- package/lib/zudoku.openapi-worker.js.map +1 -0
- package/lib/zudoku.plugin-api-keys.js +325 -0
- package/lib/zudoku.plugin-api-keys.js.map +1 -0
- package/lib/zudoku.plugin-custom-page.js +13 -0
- package/lib/zudoku.plugin-custom-page.js.map +1 -0
- package/lib/zudoku.plugin-markdown.js +31 -0
- package/lib/zudoku.plugin-markdown.js.map +1 -0
- package/lib/zudoku.plugin-openapi.js +14 -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/lib/zudoku.plugin-search-inkeep.js +51 -0
- package/lib/zudoku.plugin-search-inkeep.js.map +1 -0
- package/package.json +67 -25
- package/src/app/App.tsx +0 -41
- package/src/app/demo-cdn.html +26 -0
- package/src/app/demo.html +18 -0
- package/src/app/demo.tsx +56 -0
- package/src/app/entry.client.tsx +47 -0
- package/src/app/entry.server.tsx +160 -0
- package/src/app/main.css +83 -3
- package/src/app/main.tsx +92 -15
- package/src/app/standalone.html +20 -0
- package/src/app/standalone.tsx +55 -0
- package/src/app/tailwind.ts +2 -6
- package/src/lib/authentication/AuthenticationPlugin.tsx +38 -0
- package/src/lib/authentication/authentication.ts +6 -9
- package/src/lib/authentication/components/SignIn.tsx +15 -0
- package/src/lib/authentication/components/SignOut.tsx +13 -0
- package/src/lib/authentication/components/SignUp.tsx +11 -0
- package/src/lib/authentication/hook.ts +4 -4
- package/src/lib/authentication/providers/auth0.tsx +16 -6
- package/src/lib/authentication/providers/clerk.tsx +63 -31
- package/src/lib/authentication/providers/openid.tsx +104 -34
- package/src/lib/authentication/state.ts +1 -1
- package/src/lib/components/Bootstrap.tsx +45 -0
- package/src/lib/components/ClientOnly.tsx +13 -0
- package/src/lib/components/DevPortal.tsx +70 -67
- package/src/lib/components/DeveloperHint.tsx +25 -0
- package/src/lib/components/ErrorPage.tsx +28 -0
- package/src/lib/components/Header.tsx +112 -41
- package/src/lib/components/Heading.tsx +26 -7
- package/src/lib/components/InlineCode.tsx +19 -0
- package/src/lib/components/Layout.tsx +19 -11
- package/src/lib/components/NotFoundPage.tsx +33 -0
- package/src/lib/components/Search.tsx +60 -0
- package/src/lib/components/SlotletProvider.tsx +30 -0
- package/src/lib/components/SyntaxHighlight.tsx +53 -44
- package/src/lib/components/TopNavigation.tsx +10 -5
- package/src/lib/components/context/ThemeContext.tsx +3 -41
- package/src/lib/components/context/ThemeProvider.tsx +27 -0
- package/src/lib/components/context/{DevPortalProvider.ts → ZudokuContext.ts} +19 -15
- package/src/lib/components/context/ZudokuProvider.tsx +26 -0
- package/src/lib/components/index.ts +25 -3
- package/src/lib/components/navigation/Sidebar.tsx +24 -0
- package/src/lib/components/navigation/SidebarBadge.tsx +43 -0
- package/src/lib/components/navigation/SidebarCategory.tsx +105 -0
- package/src/lib/components/navigation/SidebarItem.tsx +128 -0
- package/src/lib/components/navigation/{SideNavigationWrapper.tsx → SidebarWrapper.tsx} +1 -1
- package/src/lib/components/navigation/utils.ts +117 -0
- package/src/lib/core/DevPortalContext.ts +72 -68
- package/src/lib/core/plugins.ts +45 -13
- 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 +21 -10
- package/src/lib/oas/parser/index.ts +41 -22
- package/src/lib/plugins/{api-key → api-keys}/CreateApiKey.tsx +4 -4
- package/src/lib/plugins/api-keys/ProtectedRoute.tsx +29 -0
- package/src/lib/plugins/{api-key → api-keys}/SettingsApiKeys.tsx +49 -16
- package/src/lib/plugins/{api-key → api-keys}/index.tsx +27 -41
- package/src/lib/plugins/custom-page/index.tsx +22 -0
- package/src/lib/plugins/markdown/MdxPage.tsx +54 -73
- package/src/lib/plugins/markdown/Toc.tsx +53 -40
- package/src/lib/plugins/markdown/generateRoutes.tsx +35 -53
- package/src/lib/plugins/markdown/index.tsx +10 -7
- package/src/lib/plugins/openapi/ColorizedParam.tsx +23 -16
- package/src/lib/plugins/openapi/OperationList.tsx +46 -10
- package/src/lib/plugins/openapi/OperationListItem.tsx +51 -30
- package/src/lib/plugins/openapi/ParameterList.tsx +13 -10
- package/src/lib/plugins/openapi/ParameterListItem.tsx +3 -4
- package/src/lib/plugins/openapi/PlaygroundDialogWrapper.tsx +9 -33
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +3 -16
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +3 -2
- package/src/lib/plugins/openapi/Route.tsx +21 -0
- package/src/lib/plugins/openapi/SchemaListView.tsx +39 -192
- package/src/lib/plugins/openapi/SchemaListViewItem.tsx +125 -0
- package/src/lib/plugins/openapi/SchemaListViewItemGroup.tsx +63 -0
- package/src/lib/plugins/openapi/Sidecar.tsx +67 -25
- package/src/lib/plugins/openapi/SidecarBox.tsx +13 -2
- package/src/lib/plugins/openapi/SimpleSelect.tsx +1 -1
- package/src/lib/plugins/openapi/StaggeredRender.tsx +31 -0
- 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/client/worker.ts +30 -0
- package/src/lib/plugins/openapi/context.tsx +16 -0
- package/src/lib/plugins/openapi/graphql/gql.ts +8 -8
- package/src/lib/plugins/openapi/graphql/graphql.ts +80 -80
- package/src/lib/plugins/openapi/index.tsx +130 -74
- package/src/lib/plugins/openapi/interfaces.ts +10 -0
- package/src/lib/plugins/openapi/playground/Headers.tsx +1 -1
- package/src/lib/plugins/openapi/playground/PathParams.tsx +76 -50
- package/src/lib/plugins/openapi/playground/Playground.tsx +121 -81
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +13 -7
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +107 -66
- package/src/lib/plugins/openapi/playground/ResponseTab.tsx +76 -0
- package/src/lib/plugins/openapi/playground/createUrl.ts +12 -15
- 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/plugins/search-inkeep/InkeepCustomTrigger.tsx +3 -0
- package/src/lib/plugins/search-inkeep/index.tsx +63 -0
- package/src/lib/plugins/search-inkeep/inkeep.ts +32 -0
- package/src/lib/ui/Button.tsx +32 -2
- package/src/lib/ui/Callout.tsx +4 -4
- package/src/lib/ui/Card.tsx +1 -1
- package/src/lib/ui/DropdownMenu.tsx +199 -0
- package/src/lib/util/MdxComponents.tsx +7 -15
- package/src/lib/util/fetchTimeout.tsx +21 -0
- package/src/lib/util/groupBy.ts +7 -12
- package/src/lib/util/invariant.ts +26 -0
- package/src/lib/util/joinPath.tsx +3 -2
- 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/src/lib/util/requestIdleCallbackPolyfill.ts +6 -0
- package/src/lib/util/useScrollToAnchor.ts +39 -18
- package/dist/lib/authentication/Callback.d.ts +0 -3
- package/dist/lib/authentication/Callback.js +0 -34
- package/dist/lib/authentication/Callback.js.map +0 -1
- package/dist/lib/components/Input.js.map +0 -1
- 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/components/context/DevPortalProvider.d.ts +0 -9
- package/dist/lib/components/context/DevPortalProvider.js +0 -39
- package/dist/lib/components/context/DevPortalProvider.js.map +0 -1
- package/dist/lib/components/navigation/SideNavigation.d.ts +0 -1
- package/dist/lib/components/navigation/SideNavigation.js +0 -11
- package/dist/lib/components/navigation/SideNavigation.js.map +0 -1
- package/dist/lib/components/navigation/SideNavigationCategory.d.ts +0 -4
- package/dist/lib/components/navigation/SideNavigationCategory.js +0 -26
- package/dist/lib/components/navigation/SideNavigationCategory.js.map +0 -1
- package/dist/lib/components/navigation/SideNavigationItem.d.ts +0 -13
- package/dist/lib/components/navigation/SideNavigationItem.js +0 -44
- package/dist/lib/components/navigation/SideNavigationItem.js.map +0 -1
- package/dist/lib/components/navigation/SideNavigationWrapper.js.map +0 -1
- package/dist/lib/components/navigation/useNavigationCollapsibleState.d.ts +0 -6
- package/dist/lib/components/navigation/useNavigationCollapsibleState.js +0 -16
- package/dist/lib/components/navigation/useNavigationCollapsibleState.js.map +0 -1
- package/dist/lib/components/navigation/util.d.ts +0 -8
- package/dist/lib/components/navigation/util.js +0 -15
- package/dist/lib/components/navigation/util.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.js.map +0 -1
- package/dist/lib/plugins/api-key/SettingsApiKeys.js +0 -38
- 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/MethodBadge.d.ts +0 -13
- package/dist/lib/plugins/openapi/MethodBadge.js +0 -26
- package/dist/lib/plugins/openapi/MethodBadge.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/lib/ui/button-variants.d.ts +0 -4
- package/dist/lib/ui/button-variants.js +0 -24
- package/dist/lib/ui/button-variants.js.map +0 -1
- package/dist/lib/util/traverseNavigation.d.ts +0 -6
- package/dist/lib/util/traverseNavigation.js +0 -30
- package/dist/lib/util/traverseNavigation.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-CzCKCaUK.js +0 -8444
- package/lib/clerk-Wslx_mPo.js +0 -19685
- package/lib/index-PyGcnQFX.js +0 -3462
- package/lib/loglevel-CoH7VSwE.js +0 -152
- package/lib/state-2Hu1renZ.js +0 -313
- package/lib/zudoku.plugins.js +0 -19916
- package/src/lib/authentication/Callback.tsx +0 -60
- package/src/lib/components/Link.tsx +0 -1
- package/src/lib/components/Router.tsx +0 -28
- package/src/lib/components/navigation/SideNavigation.tsx +0 -21
- package/src/lib/components/navigation/SideNavigationCategory.tsx +0 -76
- package/src/lib/components/navigation/SideNavigationItem.tsx +0 -152
- package/src/lib/components/navigation/useNavigationCollapsibleState.ts +0 -27
- package/src/lib/components/navigation/util.ts +0 -38
- 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/index.ts +0 -4
- package/src/lib/plugins/openapi/MethodBadge.tsx +0 -36
- package/src/lib/plugins/openapi/worker/shared-worker.ts +0 -5
- package/src/lib/plugins/openapi/worker/worker.ts +0 -56
- package/src/lib/ui/button-variants.ts +0 -31
- package/src/lib/util/traverseNavigation.ts +0 -55
- /package/dist/lib/plugins/{api-key → api-keys}/CreateApiKey.d.ts +0 -0
- /package/dist/lib/plugins/{api-key → api-keys}/SettingsApiKeys.d.ts +0 -0
- /package/dist/lib/plugins/openapi/{worker → client}/worker.d.ts +0 -0
- /package/dist/lib/{components → ui}/Input.d.ts +0 -0
- /package/dist/lib/{components → ui}/Input.js +0 -0
- /package/src/lib/{components → ui}/Input.tsx +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMutation } from "@tanstack/react-query";
|
|
2
|
-
import { Fragment } from "react";
|
|
2
|
+
import { Fragment, useEffect, useRef } from "react";
|
|
3
3
|
import { FormProvider, useForm } from "react-hook-form";
|
|
4
|
-
import { useApiIdentities } from "../../../components/context/
|
|
4
|
+
import { useApiIdentities } from "../../../components/context/ZudokuContext.js";
|
|
5
5
|
import {
|
|
6
6
|
Select,
|
|
7
7
|
SelectContent,
|
|
@@ -10,15 +10,16 @@ import {
|
|
|
10
10
|
SelectValue,
|
|
11
11
|
} from "../../../components/Select.js";
|
|
12
12
|
import { Spinner } from "../../../components/Spinner.js";
|
|
13
|
-
import { SyntaxHighlight } from "../../../components/SyntaxHighlight.js";
|
|
14
13
|
import { Button } from "../../../ui/Button.js";
|
|
15
14
|
import { Card } from "../../../ui/Card.js";
|
|
16
15
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../../ui/Tabs.js";
|
|
16
|
+
import { fetchTimeout } from "../../../util/fetchTimeout.js";
|
|
17
17
|
import { ColorizedParam } from "../ColorizedParam.js";
|
|
18
18
|
import { createUrl } from "./createUrl.js";
|
|
19
19
|
import { Headers } from "./Headers.js";
|
|
20
20
|
import { PathParams } from "./PathParams.js";
|
|
21
21
|
import { QueryParams } from "./QueryParams.js";
|
|
22
|
+
import { ResponseTab } from "./ResponseTab.js";
|
|
22
23
|
|
|
23
24
|
export const NO_IDENTITY = "__none";
|
|
24
25
|
|
|
@@ -36,7 +37,7 @@ function mimeTypeToLanguage(mimeType: string) {
|
|
|
36
37
|
|
|
37
38
|
return Object.entries(mimeTypeMapping).find(([mime]) =>
|
|
38
39
|
mimeType.includes(mime),
|
|
39
|
-
)?.[
|
|
40
|
+
)?.[1];
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
const statusCodeMap: Record<number, string> = {
|
|
@@ -54,62 +55,83 @@ const statusCodeMap: Record<number, string> = {
|
|
|
54
55
|
|
|
55
56
|
export type Header = {
|
|
56
57
|
name: string;
|
|
57
|
-
|
|
58
|
+
defaultValue?: string;
|
|
58
59
|
};
|
|
59
60
|
export type QueryParam = {
|
|
60
61
|
name: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
isRequired
|
|
62
|
+
defaultValue?: string;
|
|
63
|
+
defaultActive?: boolean;
|
|
64
|
+
isRequired?: boolean;
|
|
64
65
|
};
|
|
65
66
|
export type PathParam = {
|
|
66
67
|
name: string;
|
|
67
|
-
|
|
68
|
+
defaultValue?: string;
|
|
69
|
+
isRequired?: boolean;
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
export type PlaygroundForm = {
|
|
71
73
|
body: string;
|
|
72
|
-
queryParams:
|
|
73
|
-
pathParams:
|
|
74
|
-
headers:
|
|
74
|
+
queryParams: Array<{ name: string; value: string; active: boolean }>;
|
|
75
|
+
pathParams: Array<{ name: string; value: string }>;
|
|
76
|
+
headers: Array<{ name: string; value: string }>;
|
|
75
77
|
identity?: string;
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
export type PlaygroundContentProps = {
|
|
79
|
-
|
|
81
|
+
server: string;
|
|
80
82
|
url: string;
|
|
81
83
|
method: string;
|
|
82
84
|
headers?: Header[];
|
|
83
85
|
queryParams?: QueryParam[];
|
|
84
86
|
pathParams?: PathParam[];
|
|
85
|
-
|
|
87
|
+
defaultBody?: string;
|
|
86
88
|
};
|
|
87
89
|
|
|
88
90
|
export const Playground = ({
|
|
89
|
-
|
|
91
|
+
server,
|
|
90
92
|
url,
|
|
91
93
|
method,
|
|
92
|
-
headers = [
|
|
94
|
+
headers = [],
|
|
93
95
|
queryParams = [],
|
|
94
96
|
pathParams = [],
|
|
95
|
-
|
|
97
|
+
defaultBody = "",
|
|
96
98
|
}: PlaygroundContentProps) => {
|
|
97
|
-
const { register, control, handleSubmit, watch, ...form } =
|
|
99
|
+
const { register, control, handleSubmit, watch, setValue, ...form } =
|
|
98
100
|
useForm<PlaygroundForm>({
|
|
99
101
|
defaultValues: {
|
|
100
|
-
body:
|
|
101
|
-
queryParams
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
body: defaultBody,
|
|
103
|
+
queryParams: queryParams.map((param) => ({
|
|
104
|
+
name: param.name,
|
|
105
|
+
value: param.defaultValue ?? "",
|
|
106
|
+
active: param.defaultActive ?? false,
|
|
107
|
+
})),
|
|
108
|
+
pathParams: pathParams.map((param) => ({
|
|
109
|
+
name: param.name,
|
|
110
|
+
value: param.defaultValue ?? "",
|
|
111
|
+
})),
|
|
112
|
+
headers: headers.map((header) => ({
|
|
113
|
+
name: header.name,
|
|
114
|
+
value: header.defaultValue ?? "",
|
|
115
|
+
})),
|
|
104
116
|
identity: NO_IDENTITY,
|
|
105
117
|
},
|
|
106
118
|
});
|
|
107
119
|
const formState = watch();
|
|
108
120
|
const identities = useApiIdentities();
|
|
109
121
|
|
|
122
|
+
const setOnce = useRef(false);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (setOnce.current) return;
|
|
125
|
+
const firstIdentity = identities.data?.at(0);
|
|
126
|
+
if (firstIdentity) {
|
|
127
|
+
setValue("identity", firstIdentity.id);
|
|
128
|
+
setOnce.current = true;
|
|
129
|
+
}
|
|
130
|
+
}, [setValue, identities.data]);
|
|
131
|
+
|
|
110
132
|
const queryMutation = useMutation({
|
|
111
133
|
mutationFn: async (data: PlaygroundForm) => {
|
|
112
|
-
const requestUrl = createUrl(
|
|
134
|
+
const requestUrl = createUrl(server, url, data);
|
|
113
135
|
const start = performance.now();
|
|
114
136
|
|
|
115
137
|
const request = new Request(requestUrl, {
|
|
@@ -126,7 +148,8 @@ export const Playground = ({
|
|
|
126
148
|
?.find((i) => i.id === data.identity)
|
|
127
149
|
?.authorizeRequest(request);
|
|
128
150
|
}
|
|
129
|
-
const response = await
|
|
151
|
+
const response = await fetchTimeout(request);
|
|
152
|
+
const time = performance.now() - start;
|
|
130
153
|
|
|
131
154
|
const body = await response.text();
|
|
132
155
|
|
|
@@ -135,31 +158,38 @@ export const Playground = ({
|
|
|
135
158
|
headers: response.headers,
|
|
136
159
|
size: body.length,
|
|
137
160
|
body,
|
|
138
|
-
time
|
|
161
|
+
time,
|
|
139
162
|
};
|
|
140
163
|
},
|
|
141
164
|
});
|
|
142
165
|
|
|
143
|
-
const path = url.split("/").map((part, i, arr) =>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
part
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
const path = url.split("/").map((part, i, arr) => {
|
|
167
|
+
const isPathParam = part.startsWith("{") && part.endsWith("}");
|
|
168
|
+
const replaced = part.replace(/[{}]/g, "");
|
|
169
|
+
const value = formState.pathParams.find((p) => p.name === replaced)?.value;
|
|
170
|
+
|
|
171
|
+
const pathParamValue = value ? (
|
|
172
|
+
<ColorizedParam backgroundOpacity="25%" name={part} slug={part}>
|
|
173
|
+
{encodeURIComponent(value)}
|
|
174
|
+
</ColorizedParam>
|
|
175
|
+
) : (
|
|
176
|
+
<span
|
|
177
|
+
className="underline decoration-wavy decoration-red-500"
|
|
178
|
+
title={`Missing value for path parameter \`${replaced}\``}
|
|
179
|
+
>
|
|
180
|
+
{part}
|
|
181
|
+
</span>
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
186
|
+
<Fragment key={part + i}>
|
|
187
|
+
{isPathParam ? pathParamValue : part}
|
|
188
|
+
{i < arr.length - 1 && "/"}
|
|
189
|
+
<wbr />
|
|
190
|
+
</Fragment>
|
|
191
|
+
);
|
|
192
|
+
});
|
|
163
193
|
|
|
164
194
|
const lang = mimeTypeToLanguage(
|
|
165
195
|
queryMutation.data?.headers.get("Content-Type") ?? "",
|
|
@@ -169,20 +199,24 @@ export const Playground = ({
|
|
|
169
199
|
|
|
170
200
|
const urlQueryParams = formState.queryParams
|
|
171
201
|
.filter((p) => p.active)
|
|
172
|
-
.map((p) => (
|
|
202
|
+
.map((p, i, arr) => (
|
|
173
203
|
<Fragment key={p.name}>
|
|
174
|
-
{p.name}={p.value}
|
|
204
|
+
{p.name}={encodeURIComponent(p.value).replaceAll("%20", "+")}
|
|
205
|
+
{i < arr.length - 1 && "&"}
|
|
175
206
|
<wbr />
|
|
176
207
|
</Fragment>
|
|
177
208
|
));
|
|
209
|
+
|
|
178
210
|
return (
|
|
179
|
-
<FormProvider
|
|
211
|
+
<FormProvider
|
|
212
|
+
{...{ register, control, handleSubmit, watch, setValue, ...form }}
|
|
213
|
+
>
|
|
180
214
|
<form onSubmit={handleSubmit((data) => queryMutation.mutateAsync(data))}>
|
|
181
215
|
<div className="grid grid-cols-2 text-sm h-full">
|
|
182
216
|
<div className="flex flex-col gap-4 p-8 bg-muted/50 after:bg-muted-foreground/20 relative after:absolute after:w-px after:inset-0 after:left-auto">
|
|
183
217
|
<div className="flex gap-2 items-stretch">
|
|
184
|
-
<div className="flex flex-1 items-center w-full border rounded-md
|
|
185
|
-
<div className="border-r
|
|
218
|
+
<div className="flex flex-1 items-center w-full border rounded-md">
|
|
219
|
+
<div className="border-r p-2 bg-muted rounded-l-md self-stretch font-semibold font-mono">
|
|
186
220
|
{method.toUpperCase()}
|
|
187
221
|
</div>
|
|
188
222
|
<div className="p-2 font-mono text-xs">
|
|
@@ -195,10 +229,12 @@ export const Playground = ({
|
|
|
195
229
|
Send
|
|
196
230
|
</Button>
|
|
197
231
|
</div>
|
|
198
|
-
<Tabs
|
|
232
|
+
<Tabs
|
|
233
|
+
defaultValue={pathParams.length > 0 ? "parameters" : "headers"}
|
|
234
|
+
>
|
|
199
235
|
<div className="flex justify-between">
|
|
200
236
|
<TabsList>
|
|
201
|
-
{
|
|
237
|
+
{queryParams.length + pathParams.length > 0 && (
|
|
202
238
|
<TabsTrigger value="parameters">Parameters</TabsTrigger>
|
|
203
239
|
)}
|
|
204
240
|
<TabsTrigger value="headers">
|
|
@@ -208,9 +244,11 @@ export const Playground = ({
|
|
|
208
244
|
</TabsTrigger>
|
|
209
245
|
<TabsTrigger
|
|
210
246
|
value="body"
|
|
211
|
-
disabled={
|
|
212
|
-
|
|
213
|
-
|
|
247
|
+
disabled={
|
|
248
|
+
!["POST", "PUT", "PATCH", "DELETE"].includes(
|
|
249
|
+
method.toUpperCase(),
|
|
250
|
+
)
|
|
251
|
+
}
|
|
214
252
|
>
|
|
215
253
|
Body
|
|
216
254
|
</TabsTrigger>
|
|
@@ -218,7 +256,8 @@ export const Playground = ({
|
|
|
218
256
|
<div className="flex gap-2 items-center">
|
|
219
257
|
Auth:
|
|
220
258
|
<Select
|
|
221
|
-
onValueChange={(value) =>
|
|
259
|
+
onValueChange={(value) => setValue("identity", value)}
|
|
260
|
+
value={formState.identity}
|
|
222
261
|
defaultValue={formState.identity}
|
|
223
262
|
>
|
|
224
263
|
<SelectTrigger className="w-[180px] flex">
|
|
@@ -239,32 +278,35 @@ export const Playground = ({
|
|
|
239
278
|
<Headers control={control} register={register} />
|
|
240
279
|
</TabsContent>
|
|
241
280
|
<TabsContent value="parameters">
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
<
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
<span className="font-semibold
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
<QueryParams control={control} />
|
|
255
|
-
</div>
|
|
281
|
+
{pathParams.length > 0 && (
|
|
282
|
+
<div className="flex flex-col gap-4 my-4">
|
|
283
|
+
<span className="font-semibold">Path Parameters</span>
|
|
284
|
+
<PathParams control={control} />
|
|
285
|
+
</div>
|
|
286
|
+
)}
|
|
287
|
+
{queryParams.length > 0 && (
|
|
288
|
+
<div className="flex flex-col gap-4 my-4">
|
|
289
|
+
<span className="font-semibold">Query Parameters</span>
|
|
290
|
+
<QueryParams control={control} queryParams={queryParams} />
|
|
291
|
+
</div>
|
|
292
|
+
)}
|
|
256
293
|
</TabsContent>
|
|
257
294
|
<TabsContent value="body">
|
|
258
295
|
<textarea
|
|
259
296
|
{...register("body")}
|
|
260
|
-
className="border
|
|
297
|
+
className="border w-full rounded p-2 bg-muted h-40"
|
|
261
298
|
/>
|
|
262
299
|
</TabsContent>
|
|
263
300
|
</Tabs>
|
|
264
301
|
</div>
|
|
265
302
|
<div className="flex flex-col gap-4 p-8 bg-muted/70">
|
|
266
303
|
{queryMutation.error ? (
|
|
267
|
-
<div>
|
|
304
|
+
<div>
|
|
305
|
+
Error:{" "}
|
|
306
|
+
{queryMutation.error.message ||
|
|
307
|
+
String(queryMutation.error) ||
|
|
308
|
+
"Unexpected error"}
|
|
309
|
+
</div>
|
|
268
310
|
) : queryMutation.data ? (
|
|
269
311
|
<div className="flex flex-col gap-2">
|
|
270
312
|
<div className="flex gap-2">
|
|
@@ -289,14 +331,10 @@ export const Playground = ({
|
|
|
289
331
|
</TabsList>
|
|
290
332
|
|
|
291
333
|
<TabsContent value="response">
|
|
292
|
-
<
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
className="overflow-x-auto "
|
|
297
|
-
code={queryMutation.data.body ?? JSON.stringify("")}
|
|
298
|
-
/>
|
|
299
|
-
</Card>
|
|
334
|
+
<ResponseTab
|
|
335
|
+
headers={queryMutation.data.headers}
|
|
336
|
+
body={queryMutation.data.body}
|
|
337
|
+
/>
|
|
300
338
|
</TabsContent>
|
|
301
339
|
<TabsContent value="headers">
|
|
302
340
|
<Card className="grid grid-cols-2 w-full gap-2.5 font-mono text-xs shadow-none p-4">
|
|
@@ -305,7 +343,7 @@ export const Playground = ({
|
|
|
305
343
|
{headerEntries.map(([key, value]) => (
|
|
306
344
|
<Fragment key={key}>
|
|
307
345
|
<div>{key}</div>
|
|
308
|
-
<div>{value}</div>
|
|
346
|
+
<div className="break-words">{value}</div>
|
|
309
347
|
</Fragment>
|
|
310
348
|
))}
|
|
311
349
|
</Card>
|
|
@@ -329,3 +367,5 @@ export const Playground = ({
|
|
|
329
367
|
</FormProvider>
|
|
330
368
|
);
|
|
331
369
|
};
|
|
370
|
+
|
|
371
|
+
export default Playground;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
2
2
|
import { CirclePlayIcon } from "lucide-react";
|
|
3
|
+
import { type PropsWithChildren, useState } from "react";
|
|
3
4
|
import {
|
|
4
5
|
Dialog,
|
|
5
6
|
DialogContent,
|
|
@@ -8,14 +9,19 @@ import {
|
|
|
8
9
|
} from "../../../components/Dialog.js";
|
|
9
10
|
import { Playground, type PlaygroundContentProps } from "./Playground.js";
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
export type PlaygroundDialogProps = PropsWithChildren<PlaygroundContentProps>;
|
|
13
|
+
|
|
14
|
+
const PlaygroundDialog = (props: PlaygroundDialogProps) => {
|
|
15
|
+
const [open, setOpen] = useState(false);
|
|
12
16
|
return (
|
|
13
|
-
<Dialog>
|
|
17
|
+
<Dialog onOpenChange={(open) => setOpen(open)}>
|
|
14
18
|
<DialogTrigger asChild>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
{props.children ?? (
|
|
20
|
+
<CirclePlayIcon
|
|
21
|
+
className="cursor-pointer text-primary hover:text-primary/80"
|
|
22
|
+
size={16}
|
|
23
|
+
/>
|
|
24
|
+
)}
|
|
19
25
|
</DialogTrigger>
|
|
20
26
|
|
|
21
27
|
<DialogContent
|
|
@@ -25,7 +31,7 @@ const PlaygroundDialog = (props: PlaygroundContentProps) => {
|
|
|
25
31
|
<VisuallyHidden>
|
|
26
32
|
<DialogTitle>Playground</DialogTitle>
|
|
27
33
|
</VisuallyHidden>
|
|
28
|
-
<Playground {...props} />
|
|
34
|
+
{open && <Playground {...props} />}
|
|
29
35
|
</DialogContent>
|
|
30
36
|
</Dialog>
|
|
31
37
|
);
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EraserIcon } from "lucide-react";
|
|
2
2
|
import {
|
|
3
3
|
Control,
|
|
4
4
|
Controller,
|
|
5
5
|
useFieldArray,
|
|
6
6
|
useFormContext,
|
|
7
7
|
} from "react-hook-form";
|
|
8
|
+
import { Button } from "../../../ui/Button.js";
|
|
9
|
+
import { Input } from "../../../ui/Input.js";
|
|
10
|
+
import { cn } from "../../../util/cn.js";
|
|
8
11
|
import { InlineInput } from "./InlineInput.js";
|
|
9
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
NO_IDENTITY,
|
|
14
|
+
type PlaygroundForm,
|
|
15
|
+
type QueryParam,
|
|
16
|
+
} from "./Playground.js";
|
|
10
17
|
|
|
11
18
|
export const QueryParams = ({
|
|
12
19
|
control,
|
|
20
|
+
queryParams,
|
|
13
21
|
}: {
|
|
14
22
|
control: Control<PlaygroundForm>;
|
|
23
|
+
queryParams: QueryParam[];
|
|
15
24
|
}) => {
|
|
16
25
|
const { fields } = useFieldArray<PlaygroundForm>({
|
|
17
26
|
control,
|
|
@@ -19,71 +28,103 @@ export const QueryParams = ({
|
|
|
19
28
|
});
|
|
20
29
|
const form = useFormContext<PlaygroundForm>();
|
|
21
30
|
|
|
22
|
-
const requiredFields =
|
|
23
|
-
.getValues(`queryParams`)
|
|
24
|
-
.map((param) => param.isRequired);
|
|
25
|
-
|
|
26
|
-
return fields.map((field, i) => (
|
|
27
|
-
<div
|
|
28
|
-
key={field.id}
|
|
29
|
-
className="px-2 grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-accent rounded overflow-hidden group"
|
|
30
|
-
>
|
|
31
|
-
<Controller
|
|
32
|
-
control={control}
|
|
33
|
-
name={`queryParams.${i}.active`}
|
|
34
|
-
render={({ field }) => (
|
|
35
|
-
<input
|
|
36
|
-
type="checkbox"
|
|
37
|
-
id={`queryParams.${i}.active`}
|
|
38
|
-
checked={field.value}
|
|
39
|
-
onChange={field.onChange}
|
|
40
|
-
/>
|
|
41
|
-
)}
|
|
42
|
-
/>
|
|
31
|
+
const requiredFields = queryParams.map((param) => Boolean(param.isRequired));
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
render={({ field }) => {
|
|
47
|
-
return (
|
|
48
|
-
<InlineInput asChild>
|
|
49
|
-
<label
|
|
50
|
-
className="flex items-center"
|
|
51
|
-
htmlFor={`queryParams.${i}.active`}
|
|
52
|
-
title={requiredFields[i] ? "Required field" : undefined}
|
|
53
|
-
>
|
|
54
|
-
{field.value}
|
|
55
|
-
{requiredFields[i] && <sup className="text-destructive">*</sup>}
|
|
56
|
-
</label>
|
|
57
|
-
</InlineInput>
|
|
58
|
-
);
|
|
59
|
-
}}
|
|
60
|
-
name={`queryParams.${i}.name`}
|
|
61
|
-
/>
|
|
62
|
-
<Controller
|
|
63
|
-
control={control}
|
|
64
|
-
render={({ field }) => {
|
|
65
|
-
return (
|
|
66
|
-
<InlineInput {...field} placeholder="Value" className="peer" />
|
|
67
|
-
);
|
|
68
|
-
}}
|
|
69
|
-
name={`queryParams.${i}.value`}
|
|
70
|
-
/>
|
|
71
|
-
<Controller
|
|
72
|
-
control={control}
|
|
73
|
-
render={({ field }) => {
|
|
74
|
-
return (
|
|
75
|
-
<button
|
|
76
|
-
className="hover:bg-black/5 p-1 rounded mr-2 text-muted-foreground invisible group-hover:visible peer-focus:visible"
|
|
77
|
-
onClick={() => field.onChange("")}
|
|
78
|
-
>
|
|
79
|
-
<XIcon size={16} />
|
|
80
|
-
</button>
|
|
81
|
-
);
|
|
82
|
-
}}
|
|
83
|
-
name={`queryParams.${i}.value`}
|
|
84
|
-
/>
|
|
33
|
+
const selectedIdentity = form.watch("identity");
|
|
34
|
+
const hasSelectedIdentity = selectedIdentity !== NO_IDENTITY;
|
|
85
35
|
|
|
86
|
-
|
|
36
|
+
return (
|
|
37
|
+
<div className="">
|
|
38
|
+
<table className="w-full [&_td]:border [&_td]:p-1.5 [&_td]:px-2">
|
|
39
|
+
<tbody>
|
|
40
|
+
{fields
|
|
41
|
+
.filter(
|
|
42
|
+
// TODO remove this hack for Accu or make it more generic
|
|
43
|
+
(field) => !(hasSelectedIdentity && field.name === "apikey"),
|
|
44
|
+
)
|
|
45
|
+
.map((field, i) => (
|
|
46
|
+
<tr key={field.id} className="hover:bg-accent/40">
|
|
47
|
+
<td className="text-center">
|
|
48
|
+
<Controller
|
|
49
|
+
control={control}
|
|
50
|
+
name={`queryParams.${i}.active`}
|
|
51
|
+
render={({ field }) => (
|
|
52
|
+
<input
|
|
53
|
+
type="checkbox"
|
|
54
|
+
id={`queryParams.${i}.active`}
|
|
55
|
+
checked={field.value}
|
|
56
|
+
onChange={field.onChange}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
/>
|
|
60
|
+
</td>
|
|
61
|
+
<td>
|
|
62
|
+
<Controller
|
|
63
|
+
control={control}
|
|
64
|
+
render={({ field }) => (
|
|
65
|
+
<InlineInput asChild>
|
|
66
|
+
<label
|
|
67
|
+
className="flex items-center cursor-pointer"
|
|
68
|
+
htmlFor={`queryParams.${i}.active`}
|
|
69
|
+
title={
|
|
70
|
+
requiredFields[i] ? "Required field" : undefined
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
{field.value}
|
|
74
|
+
{requiredFields[i] && <sup> *</sup>}
|
|
75
|
+
</label>
|
|
76
|
+
</InlineInput>
|
|
77
|
+
)}
|
|
78
|
+
name={`queryParams.${i}.name`}
|
|
79
|
+
/>
|
|
80
|
+
</td>
|
|
81
|
+
<td>
|
|
82
|
+
<div className="flex justify-between items-center">
|
|
83
|
+
<Controller
|
|
84
|
+
control={control}
|
|
85
|
+
render={({ field }) => (
|
|
86
|
+
<Input
|
|
87
|
+
{...field}
|
|
88
|
+
onChange={(e) => {
|
|
89
|
+
field.onChange(e.target.value);
|
|
90
|
+
if (e.target.value.length > 0) {
|
|
91
|
+
form.setValue(`queryParams.${i}.active`, true);
|
|
92
|
+
}
|
|
93
|
+
}}
|
|
94
|
+
placeholder="Enter value"
|
|
95
|
+
className="w-full border-0 shadow-none text-xs font-mono"
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
name={`queryParams.${i}.value`}
|
|
99
|
+
/>
|
|
100
|
+
<Controller
|
|
101
|
+
control={control}
|
|
102
|
+
render={({ field }) => (
|
|
103
|
+
<Button
|
|
104
|
+
size="icon"
|
|
105
|
+
type="button"
|
|
106
|
+
variant="ghost"
|
|
107
|
+
aria-label="Clear value"
|
|
108
|
+
className={cn(
|
|
109
|
+
"ms-2",
|
|
110
|
+
field.value.length === 0
|
|
111
|
+
? "opacity-0 pointer-events-none"
|
|
112
|
+
: "opacity-100",
|
|
113
|
+
)}
|
|
114
|
+
title="Clear value"
|
|
115
|
+
onClick={() => field.onChange("")}
|
|
116
|
+
>
|
|
117
|
+
<EraserIcon size={16} />
|
|
118
|
+
</Button>
|
|
119
|
+
)}
|
|
120
|
+
name={`queryParams.${i}.value`}
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</td>
|
|
124
|
+
</tr>
|
|
125
|
+
))}
|
|
126
|
+
</tbody>
|
|
127
|
+
</table>
|
|
87
128
|
</div>
|
|
88
|
-
)
|
|
129
|
+
);
|
|
89
130
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { SyntaxHighlight } from "../../../components/SyntaxHighlight.js";
|
|
3
|
+
import { Card } from "../../../ui/Card.js";
|
|
4
|
+
import { SimpleSelect } from "../SimpleSelect.js";
|
|
5
|
+
|
|
6
|
+
const mimeTypeToLanguage = (mimeType: string) => {
|
|
7
|
+
const mimeTypeMapping = {
|
|
8
|
+
"application/json": "json",
|
|
9
|
+
"text/json": "json",
|
|
10
|
+
"text/html": "html",
|
|
11
|
+
"text/css": "css",
|
|
12
|
+
"text/javascript": "javascript",
|
|
13
|
+
"application/xml": "xml",
|
|
14
|
+
"application/xhtml+xml": "xhtml",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return Object.entries(mimeTypeMapping).find(([mime]) =>
|
|
18
|
+
mimeType.includes(mime),
|
|
19
|
+
)?.[1];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const detectLanguage = (headers: Headers) => {
|
|
23
|
+
const contentType = headers.get("Content-Type") || "";
|
|
24
|
+
return mimeTypeToLanguage(contentType);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const tryParseJson = (body: string) => {
|
|
28
|
+
try {
|
|
29
|
+
return JSON.stringify(JSON.parse(body), null, 2);
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const ResponseTab = ({
|
|
36
|
+
body = "",
|
|
37
|
+
headers,
|
|
38
|
+
}: {
|
|
39
|
+
body?: string;
|
|
40
|
+
headers: Headers;
|
|
41
|
+
}) => {
|
|
42
|
+
const detectedLanguage = detectLanguage(headers);
|
|
43
|
+
const jsonContent = tryParseJson(body);
|
|
44
|
+
const beautifiedBody = jsonContent || body;
|
|
45
|
+
const [view, setView] = useState<"formatted" | "raw">(
|
|
46
|
+
jsonContent ? "formatted" : "raw",
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className="flex flex-col gap-2">
|
|
51
|
+
<Card className="shadow-none">
|
|
52
|
+
<SyntaxHighlight
|
|
53
|
+
language={
|
|
54
|
+
view === "raw" ? (jsonContent ? "plain" : detectedLanguage) : "json"
|
|
55
|
+
}
|
|
56
|
+
noBackground
|
|
57
|
+
showLanguageIndicator
|
|
58
|
+
className="overflow-x-auto p-4 text-xs"
|
|
59
|
+
code={view === "raw" ? body : beautifiedBody}
|
|
60
|
+
/>
|
|
61
|
+
</Card>
|
|
62
|
+
{jsonContent && (
|
|
63
|
+
<div className="flex justify-end">
|
|
64
|
+
<SimpleSelect
|
|
65
|
+
value={view}
|
|
66
|
+
onChange={(e) => setView(e.target.value as "formatted" | "raw")}
|
|
67
|
+
options={[
|
|
68
|
+
{ value: "formatted", label: "Formatted" },
|
|
69
|
+
{ value: "raw", label: "Raw" },
|
|
70
|
+
]}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
};
|