zudoku 0.0.0-f865d81 → 0.0.0-fa903e7
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/demo.js +0 -2
- package/dist/app/demo.js.map +1 -1
- package/dist/app/entry.client.js +14 -0
- package/dist/app/entry.client.js.map +1 -1
- package/dist/app/entry.server.js +6 -6
- package/dist/app/entry.server.js.map +1 -1
- package/dist/app/main.d.ts +1 -1
- package/dist/app/main.js +2 -2
- package/dist/app/main.js.map +1 -1
- package/dist/app/standalone.js +0 -2
- package/dist/app/standalone.js.map +1 -1
- package/dist/cli/cli.js +1 -2
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/common/logger.js +9 -0
- package/dist/cli/common/logger.js.map +1 -1
- package/dist/codegen.d.ts +3 -0
- package/dist/codegen.js +45 -0
- package/dist/codegen.js.map +1 -0
- package/dist/config/validators/InputSidebarSchema.d.ts +10 -10
- package/dist/config/validators/validate.d.ts +148 -117
- package/dist/config/validators/validate.js +13 -6
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/authentication/AuthenticationPlugin.d.ts +4 -2
- package/dist/lib/authentication/AuthenticationPlugin.js +3 -0
- package/dist/lib/authentication/AuthenticationPlugin.js.map +1 -1
- package/dist/lib/authentication/authentication.d.ts +3 -3
- package/dist/lib/authentication/hook.d.ts +5 -4
- package/dist/lib/authentication/hook.js +1 -3
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +12 -11
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +0 -1
- package/dist/lib/authentication/providers/openid.js +11 -26
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/authentication/state.d.ts +25 -4
- package/dist/lib/authentication/state.js +28 -3
- package/dist/lib/authentication/state.js.map +1 -1
- package/dist/lib/authentication/use-broadcast/shared.d.ts +48 -0
- package/dist/lib/authentication/use-broadcast/shared.js +243 -0
- package/dist/lib/authentication/use-broadcast/shared.js.map +1 -0
- package/dist/lib/authentication/use-broadcast/useBroadcast.d.ts +24 -0
- package/dist/lib/authentication/use-broadcast/useBroadcast.js +106 -0
- package/dist/lib/authentication/use-broadcast/useBroadcast.js.map +1 -0
- package/dist/lib/components/Bootstrap.d.ts +3 -1
- package/dist/lib/components/Bootstrap.js +10 -4
- package/dist/lib/components/Bootstrap.js.map +1 -1
- package/dist/lib/components/ClientOnly.d.ts +4 -2
- package/dist/lib/components/ClientOnly.js +1 -1
- package/dist/lib/components/ClientOnly.js.map +1 -1
- package/dist/lib/components/DeveloperHint.js +2 -1
- package/dist/lib/components/DeveloperHint.js.map +1 -1
- package/dist/lib/components/Header.js +16 -10
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +1 -1
- package/dist/lib/components/Layout.js +12 -4
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/MobileTopNavigation.js +6 -7
- package/dist/lib/components/MobileTopNavigation.js.map +1 -1
- package/dist/lib/components/SyntaxHighlight.js +16 -12
- package/dist/lib/components/SyntaxHighlight.js.map +1 -1
- package/dist/lib/components/ThemeSwitch.d.ts +1 -0
- package/dist/lib/components/ThemeSwitch.js +13 -0
- package/dist/lib/components/ThemeSwitch.js.map +1 -0
- package/dist/lib/components/TopNavigation.d.ts +2 -0
- package/dist/lib/components/TopNavigation.js +13 -7
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/{DevPortal.d.ts → Zudoku.d.ts} +3 -3
- package/dist/lib/components/{DevPortal.js → Zudoku.js} +13 -14
- package/dist/lib/components/Zudoku.js.map +1 -0
- package/dist/lib/components/context/ZudokuContext.d.ts +7 -7
- package/dist/lib/components/context/ZudokuContext.js +8 -13
- package/dist/lib/components/context/ZudokuContext.js.map +1 -1
- package/dist/lib/components/context/ZudokuProvider.d.ts +2 -2
- package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
- package/dist/lib/components/index.d.ts +18 -10
- package/dist/lib/components/index.js +2 -3
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/components/navigation/Sidebar.js +1 -1
- package/dist/lib/components/navigation/Sidebar.js.map +1 -1
- package/dist/lib/components/navigation/utils.js +2 -2
- package/dist/lib/components/navigation/utils.js.map +1 -1
- package/dist/lib/core/{DevPortalContext.d.ts → ZudokuContext.d.ts} +3 -7
- package/dist/lib/core/{DevPortalContext.js → ZudokuContext.js} +2 -7
- package/dist/lib/core/ZudokuContext.js.map +1 -0
- package/dist/lib/core/plugins.d.ts +18 -12
- package/dist/lib/core/plugins.js.map +1 -1
- package/dist/lib/errors/ErrorAlert.js +1 -1
- package/dist/lib/errors/ErrorAlert.js.map +1 -1
- package/dist/lib/oas/graphql/index.js +4 -4
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/oas/parser/upgrade/index.d.ts +2 -2
- package/dist/lib/oas/parser/upgrade/index.js +2 -17
- package/dist/lib/oas/parser/upgrade/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/index.d.ts +9 -9
- package/dist/lib/plugins/api-keys/index.js +3 -0
- package/dist/lib/plugins/api-keys/index.js.map +1 -1
- package/dist/lib/plugins/custom-pages/index.d.ts +2 -2
- package/dist/lib/plugins/custom-pages/index.js.map +1 -1
- package/dist/lib/plugins/markdown/MdxPage.d.ts +9 -1
- package/dist/lib/plugins/markdown/MdxPage.js +14 -1
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/markdown/index.d.ts +2 -2
- package/dist/lib/plugins/markdown/index.js +1 -1
- package/dist/lib/plugins/markdown/index.js.map +1 -1
- package/dist/lib/plugins/openapi/CollapsibleCode.d.ts +5 -0
- package/dist/lib/plugins/openapi/CollapsibleCode.js +24 -0
- package/dist/lib/plugins/openapi/CollapsibleCode.js.map +1 -0
- package/dist/lib/plugins/openapi/ColorizedParam.js +13 -9
- package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
- package/dist/lib/plugins/openapi/Endpoint.d.ts +1 -1
- package/dist/lib/plugins/openapi/Endpoint.js +5 -9
- package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.d.ts +2 -2
- package/dist/lib/plugins/openapi/OperationList.js +21 -22
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js +6 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +7 -3
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +9 -2
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/Route.d.ts +4 -4
- package/dist/lib/plugins/openapi/Route.js +2 -4
- package/dist/lib/plugins/openapi/Route.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.d.ts +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +35 -33
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/client/GraphQLClient.d.ts +8 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.js +114 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.js.map +1 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.d.ts +7 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.js +5 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createServer.d.ts +1 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +5 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.js +15 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -0
- package/dist/lib/plugins/openapi/client/worker.d.ts +4 -1
- package/dist/lib/plugins/openapi/client/worker.js +23 -14
- package/dist/lib/plugins/openapi/client/worker.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/fragment-masking.d.ts +3 -3
- package/dist/lib/plugins/openapi/graphql/fragment-masking.js +3 -4
- package/dist/lib/plugins/openapi/graphql/fragment-masking.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +5 -51
- package/dist/lib/plugins/openapi/graphql/gql.js +4 -2
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +32 -8
- package/dist/lib/plugins/openapi/graphql/graphql.js +194 -662
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.d.ts +2 -2
- package/dist/lib/plugins/openapi/index.js +40 -53
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +1 -1
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.d.ts +6 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.js +14 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.d.ts +1 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.js +125 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.d.ts +11 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.js +33 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.test.d.ts +1 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.test.js +104 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.test.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/traverse.d.ts +1 -0
- package/dist/lib/plugins/openapi/post-processors/traverse.js +2 -0
- package/dist/lib/plugins/openapi/post-processors/traverse.js.map +1 -0
- package/dist/lib/plugins/openapi/schema/SchemaView.js +2 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/util/generateSchemaExample.d.ts +0 -1
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js +25 -36
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
- package/dist/lib/plugins/openapi-worker.d.ts +1 -1
- package/dist/lib/plugins/openapi-worker.js +7 -1
- package/dist/lib/plugins/openapi-worker.js.map +1 -1
- package/dist/lib/plugins/redirect/index.d.ts +4 -7
- package/dist/lib/plugins/redirect/index.js +1 -1
- package/dist/lib/plugins/redirect/index.js.map +1 -1
- package/dist/lib/plugins/search-inkeep/index.d.ts +2 -2
- package/dist/lib/plugins/search-inkeep/index.js.map +1 -1
- package/dist/lib/ui/ActionButton.d.ts +4 -0
- package/dist/lib/ui/ActionButton.js +10 -0
- package/dist/lib/ui/ActionButton.js.map +1 -0
- package/dist/lib/util/MdxComponents.d.ts +1 -1
- package/dist/lib/util/traverse.d.ts +2 -0
- package/dist/lib/util/traverse.js +18 -0
- package/dist/lib/util/traverse.js.map +1 -0
- package/dist/lib/util/useIsomorphicLayoutEffect.d.ts +3 -0
- package/dist/lib/util/useIsomorphicLayoutEffect.js +4 -0
- package/dist/lib/util/useIsomorphicLayoutEffect.js.map +1 -0
- package/dist/lib/util/useOnScreen.d.ts +4 -0
- package/dist/lib/util/useOnScreen.js +19 -0
- package/dist/lib/util/useOnScreen.js.map +1 -0
- package/dist/vite/build.js +5 -1
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/config.d.ts +2 -8
- package/dist/vite/config.js +25 -54
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/config.test.js +3 -4
- package/dist/vite/config.test.js.map +1 -1
- package/dist/vite/html.js +0 -2
- package/dist/vite/html.js.map +1 -1
- package/dist/vite/output.d.ts +101 -0
- package/dist/vite/output.js +53 -0
- package/dist/vite/output.js.map +1 -0
- package/dist/vite/plugin-api.js +23 -19
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-component.js +14 -19
- package/dist/vite/plugin-component.js.map +1 -1
- package/dist/vite/plugin-config.d.ts +2 -3
- package/dist/vite/plugin-config.js +2 -3
- package/dist/vite/plugin-config.js.map +1 -1
- package/dist/vite/plugin-docs.test.js +15 -23
- package/dist/vite/plugin-docs.test.js.map +1 -1
- package/dist/vite/plugin-mdx.d.ts +0 -6
- package/dist/vite/plugin-mdx.js +13 -5
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/dist/vite/plugin.js +1 -3
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite/prerender.js +3 -2
- package/dist/vite/prerender.js.map +1 -1
- package/dist/vite/remarkStaticGeneration.d.ts +3 -0
- package/dist/vite/remarkStaticGeneration.js +125 -0
- package/dist/vite/remarkStaticGeneration.js.map +1 -0
- package/dist/zuplo/with-zuplo.d.ts +3 -0
- package/dist/zuplo/with-zuplo.js +28 -0
- package/dist/zuplo/with-zuplo.js.map +1 -0
- package/lib/{AnchorLink-BbB2q-jx.js → AnchorLink-CDlhr8gL.js} +11 -10
- package/lib/{AnchorLink-BbB2q-jx.js.map → AnchorLink-CDlhr8gL.js.map} +1 -1
- package/lib/AuthenticationPlugin-D0Em0SwR.js +59 -0
- package/lib/{AuthenticationPlugin-C9BHGXlE.js.map → AuthenticationPlugin-D0Em0SwR.js.map} +1 -1
- package/lib/Button-jK0EsymC.js +48 -0
- package/lib/Button-jK0EsymC.js.map +1 -0
- package/lib/{ClientOnly-CVN6leDu.js → ClientOnly-E7hGysn1.js} +4 -4
- package/lib/ClientOnly-E7hGysn1.js.map +1 -0
- package/lib/Markdown-ievDDhFT.js +15192 -0
- package/lib/Markdown-ievDDhFT.js.map +1 -0
- package/lib/MdxPage-B2FpJ9KC.js +183 -0
- package/lib/MdxPage-B2FpJ9KC.js.map +1 -0
- package/lib/OperationList-BkNQEsNs.js +4693 -0
- package/lib/OperationList-BkNQEsNs.js.map +1 -0
- package/lib/Route-DlG_HTMu.js +11 -0
- package/lib/Route-DlG_HTMu.js.map +1 -0
- package/lib/{Select-Bagt3Bme.js → Select-O9ZM3ZgX.js} +7 -7
- package/lib/Select-O9ZM3ZgX.js.map +1 -0
- package/lib/{Spinner-C6zroowC.js → SidebarBadge-DxFJcJ6V.js} +28 -17
- package/lib/SidebarBadge-DxFJcJ6V.js.map +1 -0
- package/lib/SlotletProvider-DyomlzGx.js +252 -0
- package/lib/SlotletProvider-DyomlzGx.js.map +1 -0
- package/lib/Spinner-3cQDBVGr.js +7 -0
- package/lib/Spinner-3cQDBVGr.js.map +1 -0
- package/lib/SyntaxHighlight-DkLOsjHS.js +2983 -0
- package/lib/SyntaxHighlight-DkLOsjHS.js.map +1 -0
- package/lib/assets/{worker-Bf8vjASY.js → worker-BHClFO3A.js} +156 -156
- package/lib/assets/worker-BHClFO3A.js.map +1 -0
- package/lib/context-D1nXWxm7.js +22 -0
- package/lib/context-D1nXWxm7.js.map +1 -0
- package/lib/createServer-CpJlUPtn.js +15299 -0
- package/lib/createServer-CpJlUPtn.js.map +1 -0
- package/lib/{hook-sn0zMTkE.js → hook-hEqe7fPB.js} +12 -14
- package/lib/hook-hEqe7fPB.js.map +1 -0
- package/lib/index-C7SaIME0.js +1277 -0
- package/lib/index-C7SaIME0.js.map +1 -0
- package/lib/index-Czzd9rjU.js +899 -0
- package/lib/index-Czzd9rjU.js.map +1 -0
- package/lib/index-Yn8c3UWE.js +921 -0
- package/lib/index-Yn8c3UWE.js.map +1 -0
- package/lib/object_hash-CvlLgU-M.js +785 -0
- package/lib/object_hash-CvlLgU-M.js.map +1 -0
- package/lib/post-processors/removeExtensions.js +11 -0
- package/lib/post-processors/removeExtensions.js.map +1 -0
- package/lib/post-processors/removePaths.js +28 -0
- package/lib/post-processors/removePaths.js.map +1 -0
- package/lib/post-processors/traverse.js +12 -0
- package/lib/post-processors/traverse.js.map +1 -0
- package/lib/{router-BsfSoK2j.js → router-lfyopgBI.js} +23 -23
- package/lib/{router-BsfSoK2j.js.map → router-lfyopgBI.js.map} +1 -1
- package/lib/state-tsXBLONe.js +203 -0
- package/lib/{state-CsuHT8ZO.js.map → state-tsXBLONe.js.map} +1 -1
- package/lib/ui/ActionButton.js +25 -0
- package/lib/ui/ActionButton.js.map +1 -0
- package/lib/useExposedProps-CTPtylCV.js +10 -0
- package/lib/{useExposedProps-ChOIUaS4.js.map → useExposedProps-CTPtylCV.js.map} +1 -1
- package/lib/{ZudokuContext-BKXGJTmu.js → utils-DcpDOncX.js} +242 -246
- package/lib/utils-DcpDOncX.js.map +1 -0
- package/lib/zudoku.auth-auth0.js +24 -18
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +2 -2
- package/lib/zudoku.auth-openid.js +124 -138
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +1291 -1119
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +10 -16336
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +41 -39
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +2 -2
- package/lib/zudoku.plugin-custom-pages.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +15 -14
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +5 -9
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/lib/zudoku.plugin-redirect.js +2 -2
- package/lib/zudoku.plugin-redirect.js.map +1 -1
- package/lib/zudoku.plugin-search-inkeep.js +1 -1
- package/lib/zudoku.plugin-search-inkeep.js.map +1 -1
- package/package.json +27 -7
- package/src/app/demo.tsx +0 -3
- package/src/app/entry.client.tsx +14 -0
- package/src/app/entry.server.tsx +59 -53
- package/src/app/main.css +1 -1
- package/src/app/main.tsx +4 -4
- package/src/app/standalone.tsx +0 -3
- package/src/lib/authentication/AuthenticationPlugin.tsx +4 -1
- package/src/lib/authentication/authentication.ts +3 -3
- package/src/lib/authentication/hook.ts +1 -3
- package/src/lib/authentication/providers/auth0.tsx +17 -11
- package/src/lib/authentication/providers/openid.tsx +12 -30
- package/src/lib/authentication/state.ts +50 -9
- package/{LICENSE.md → src/lib/authentication/use-broadcast/LICENSE.md} +2 -2
- package/src/lib/authentication/use-broadcast/shared.ts +372 -0
- package/src/lib/authentication/use-broadcast/useBroadcast.ts +146 -0
- package/src/lib/components/Bootstrap.tsx +36 -14
- package/src/lib/components/ClientOnly.tsx +6 -3
- package/src/lib/components/DeveloperHint.tsx +6 -1
- package/src/lib/components/Header.tsx +68 -40
- package/src/lib/components/Layout.tsx +49 -37
- package/src/lib/components/MobileTopNavigation.tsx +15 -18
- package/src/lib/components/SyntaxHighlight.tsx +81 -46
- package/src/lib/components/ThemeSwitch.tsx +26 -0
- package/src/lib/components/TopNavigation.tsx +27 -19
- package/src/lib/components/Zudoku.tsx +108 -0
- package/src/lib/components/context/ZudokuContext.ts +11 -16
- package/src/lib/components/context/ZudokuProvider.tsx +2 -2
- package/src/lib/components/index.ts +2 -3
- package/src/lib/components/navigation/Sidebar.tsx +3 -3
- package/src/lib/components/navigation/utils.ts +2 -2
- package/src/lib/core/{DevPortalContext.ts → ZudokuContext.ts} +3 -11
- package/src/lib/core/plugins.ts +20 -16
- package/src/lib/errors/ErrorAlert.tsx +2 -1
- package/src/lib/oas/graphql/index.ts +4 -4
- package/src/lib/oas/parser/upgrade/index.ts +3 -24
- package/src/lib/plugins/api-keys/index.tsx +12 -9
- package/src/lib/plugins/custom-pages/index.tsx +2 -2
- package/src/lib/plugins/markdown/MdxPage.tsx +25 -1
- package/src/lib/plugins/markdown/index.tsx +3 -2
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +80 -0
- package/src/lib/plugins/openapi/ColorizedParam.tsx +23 -14
- package/src/lib/plugins/openapi/Endpoint.tsx +5 -10
- package/src/lib/plugins/openapi/OperationList.tsx +20 -40
- package/src/lib/plugins/openapi/ParameterListItem.tsx +37 -31
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +18 -13
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +17 -12
- package/src/lib/plugins/openapi/Route.tsx +11 -12
- package/src/lib/plugins/openapi/Sidecar.tsx +73 -59
- package/src/lib/plugins/openapi/client/GraphQLClient.tsx +157 -0
- package/src/lib/plugins/openapi/client/GraphQLContext.tsx +16 -0
- package/src/lib/plugins/openapi/client/createServer.ts +2 -0
- package/src/lib/plugins/openapi/client/useCreateQuery.ts +21 -0
- package/src/lib/plugins/openapi/client/worker.ts +38 -24
- package/src/lib/plugins/openapi/graphql/fragment-masking.ts +11 -18
- package/src/lib/plugins/openapi/graphql/gql.ts +10 -27
- package/src/lib/plugins/openapi/graphql/graphql.ts +233 -665
- package/src/lib/plugins/openapi/index.tsx +42 -67
- package/src/lib/plugins/openapi/interfaces.ts +1 -1
- package/src/lib/plugins/openapi/post-processors/removeExtensions.test.ts +144 -0
- package/src/lib/plugins/openapi/post-processors/removeExtensions.ts +24 -0
- package/src/lib/plugins/openapi/post-processors/removePaths.test.ts +126 -0
- package/src/lib/plugins/openapi/post-processors/removePaths.ts +55 -0
- package/src/lib/plugins/openapi/post-processors/traverse.ts +1 -0
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +5 -2
- package/src/lib/plugins/openapi/util/generateSchemaExample.ts +28 -42
- package/src/lib/plugins/openapi-worker.ts +11 -1
- package/src/lib/plugins/redirect/index.tsx +5 -9
- package/src/lib/plugins/search-inkeep/index.tsx +2 -2
- package/src/lib/ui/ActionButton.tsx +28 -0
- package/src/lib/util/traverse.ts +25 -0
- package/src/lib/util/useIsomorphicLayoutEffect.ts +5 -0
- package/src/lib/util/useOnScreen.ts +32 -0
- package/dist/lib/components/DevPortal.js.map +0 -1
- package/dist/lib/components/context/ThemeContext.d.ts +0 -2
- package/dist/lib/components/context/ThemeContext.js +0 -7
- package/dist/lib/components/context/ThemeContext.js.map +0 -1
- package/dist/lib/components/context/ThemeProvider.d.ts +0 -4
- package/dist/lib/components/context/ThemeProvider.js +0 -23
- package/dist/lib/components/context/ThemeProvider.js.map +0 -1
- package/dist/lib/core/DevPortalContext.js.map +0 -1
- package/dist/lib/plugins/openapi/client/createMemoryClient.d.ts +0 -12
- package/dist/lib/plugins/openapi/client/createMemoryClient.js +0 -46
- package/dist/lib/plugins/openapi/client/createMemoryClient.js.map +0 -1
- package/dist/lib/plugins/openapi/client/createWorkerClient.d.ts +0 -10
- package/dist/lib/plugins/openapi/client/createWorkerClient.js +0 -61
- package/dist/lib/plugins/openapi/client/createWorkerClient.js.map +0 -1
- package/dist/lib/plugins/openapi/client/interfaces.d.ts +0 -4
- package/dist/lib/plugins/openapi/client/interfaces.js +0 -2
- package/dist/lib/plugins/openapi/client/interfaces.js.map +0 -1
- package/dist/lib/themeToggle.d.ts +0 -1
- package/dist/lib/themeToggle.js +0 -7
- package/dist/lib/themeToggle.js.map +0 -1
- package/dist/lib/util/createWaitForNotify.d.ts +0 -1
- package/dist/lib/util/createWaitForNotify.js +0 -15
- package/dist/lib/util/createWaitForNotify.js.map +0 -1
- package/dist/vite/plugin-html-transform.d.ts +0 -2
- package/dist/vite/plugin-html-transform.js +0 -15
- package/dist/vite/plugin-html-transform.js.map +0 -1
- package/lib/AuthenticationPlugin-C9BHGXlE.js +0 -55
- package/lib/ClientOnly-CVN6leDu.js.map +0 -1
- package/lib/DeveloperHint-DHdLXGHA.js +0 -16
- package/lib/DeveloperHint-DHdLXGHA.js.map +0 -1
- package/lib/Markdown-BDcCAWwm.js +0 -18059
- package/lib/Markdown-BDcCAWwm.js.map +0 -1
- package/lib/MdxPage-DKMH_t0f.js +0 -174
- package/lib/MdxPage-DKMH_t0f.js.map +0 -1
- package/lib/OperationList-Tj7ubW_t.js +0 -604
- package/lib/OperationList-Tj7ubW_t.js.map +0 -1
- package/lib/Route-C3DGB6OS.js +0 -13
- package/lib/Route-C3DGB6OS.js.map +0 -1
- package/lib/Select-Bagt3Bme.js.map +0 -1
- package/lib/SlotletProvider-Da7eFgd2.js +0 -241
- package/lib/SlotletProvider-Da7eFgd2.js.map +0 -1
- package/lib/Spinner-C6zroowC.js.map +0 -1
- package/lib/StaggeredRender-DDHSzQKE.js +0 -17
- package/lib/StaggeredRender-DDHSzQKE.js.map +0 -1
- package/lib/ZudokuContext-BKXGJTmu.js.map +0 -1
- package/lib/assets/worker-Bf8vjASY.js.map +0 -1
- package/lib/hook-sn0zMTkE.js.map +0 -1
- package/lib/index-AjWCJNGC.js +0 -5690
- package/lib/index-AjWCJNGC.js.map +0 -1
- package/lib/index-CRo94sKK.js +0 -1783
- package/lib/index-CRo94sKK.js.map +0 -1
- package/lib/state-CsuHT8ZO.js +0 -183
- package/lib/urql-core-KJnLL26g.js +0 -1455
- package/lib/urql-core-KJnLL26g.js.map +0 -1
- package/lib/useExposedProps-ChOIUaS4.js +0 -9
- package/src/lib/components/DevPortal.tsx +0 -111
- package/src/lib/components/context/ThemeContext.tsx +0 -8
- package/src/lib/components/context/ThemeProvider.tsx +0 -27
- package/src/lib/plugins/openapi/client/createMemoryClient.ts +0 -51
- package/src/lib/plugins/openapi/client/createWorkerClient.ts +0 -75
- package/src/lib/plugins/openapi/client/interfaces.ts +0 -5
- package/src/lib/themeToggle.ts +0 -7
- package/src/lib/util/createWaitForNotify.ts +0 -18
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
1
2
|
import { HTTPSnippet } from "@zudoku/httpsnippet";
|
|
2
3
|
import { Fragment, useMemo, useTransition } from "react";
|
|
3
4
|
import { useSearchParams } from "react-router-dom";
|
|
4
|
-
import { useQuery } from "urql";
|
|
5
5
|
import { useSelectedServerStore } from "../../authentication/state.js";
|
|
6
6
|
import { TextColorMap } from "../../components/navigation/SidebarBadge.js";
|
|
7
7
|
import { SyntaxHighlight } from "../../components/SyntaxHighlight.js";
|
|
8
8
|
import type { SchemaObject } from "../../oas/parser/index.js";
|
|
9
9
|
import { cn } from "../../util/cn.js";
|
|
10
|
+
import { useOnScreen } from "../../util/useOnScreen.js";
|
|
11
|
+
import { useCreateQuery } from "./client/useCreateQuery.js";
|
|
12
|
+
import { CollapsibleCode } from "./CollapsibleCode.js";
|
|
10
13
|
import { ColorizedParam } from "./ColorizedParam.js";
|
|
11
14
|
import { useOasConfig } from "./context.js";
|
|
12
15
|
import { graphql } from "./graphql/index.js";
|
|
@@ -73,8 +76,6 @@ export const GetServerQuery = graphql(/* GraphQL */ `
|
|
|
73
76
|
}
|
|
74
77
|
`);
|
|
75
78
|
|
|
76
|
-
const context = { suspense: true };
|
|
77
|
-
|
|
78
79
|
const methodToColor = {
|
|
79
80
|
get: TextColorMap.green,
|
|
80
81
|
post: TextColorMap.blue,
|
|
@@ -86,6 +87,20 @@ const methodToColor = {
|
|
|
86
87
|
trace: TextColorMap.gray,
|
|
87
88
|
};
|
|
88
89
|
|
|
90
|
+
const EXAMPLE_LANGUAGES = [
|
|
91
|
+
{ value: "shell", label: "cURL" },
|
|
92
|
+
{ value: "js", label: "JavaScript" },
|
|
93
|
+
{ value: "python", label: "Python" },
|
|
94
|
+
{ value: "java", label: "Java" },
|
|
95
|
+
{ value: "go", label: "Go" },
|
|
96
|
+
{ value: "csharp", label: "C#" },
|
|
97
|
+
{ value: "kotlin", label: "Kotlin" },
|
|
98
|
+
{ value: "objc", label: "Objective-C" },
|
|
99
|
+
{ value: "php", label: "PHP" },
|
|
100
|
+
{ value: "ruby", label: "Ruby" },
|
|
101
|
+
{ value: "swift", label: "Swift" },
|
|
102
|
+
];
|
|
103
|
+
|
|
89
104
|
export const Sidecar = ({
|
|
90
105
|
operation,
|
|
91
106
|
selectedResponse,
|
|
@@ -95,12 +110,10 @@ export const Sidecar = ({
|
|
|
95
110
|
selectedResponse?: string;
|
|
96
111
|
onSelectResponse: (response: string) => void;
|
|
97
112
|
}) => {
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
context,
|
|
103
|
-
});
|
|
113
|
+
const { input, type } = useOasConfig();
|
|
114
|
+
const query = useCreateQuery(GetServerQuery, { input, type });
|
|
115
|
+
const result = useSuspenseQuery(query);
|
|
116
|
+
|
|
104
117
|
const methodTextColor =
|
|
105
118
|
methodToColor[
|
|
106
119
|
operation.method.toLocaleLowerCase() as keyof typeof methodToColor
|
|
@@ -149,7 +162,7 @@ export const Sidecar = ({
|
|
|
149
162
|
const snippet = new HTTPSnippet({
|
|
150
163
|
method: operation.method.toLocaleUpperCase(),
|
|
151
164
|
url:
|
|
152
|
-
(selectedServer ?? result.data
|
|
165
|
+
(selectedServer ?? result.data.schema.url ?? "") +
|
|
153
166
|
operation.path.replaceAll("{", ":").replaceAll("}", ""),
|
|
154
167
|
postData: example
|
|
155
168
|
? {
|
|
@@ -167,15 +180,20 @@ export const Sidecar = ({
|
|
|
167
180
|
|
|
168
181
|
return getConverted(snippet, selectedLang);
|
|
169
182
|
}, [
|
|
170
|
-
|
|
171
|
-
selectedLang,
|
|
183
|
+
requestBodyContent,
|
|
172
184
|
operation.method,
|
|
173
185
|
operation.path,
|
|
174
|
-
|
|
186
|
+
selectedServer,
|
|
187
|
+
result.data.schema.url,
|
|
188
|
+
selectedLang,
|
|
175
189
|
]);
|
|
190
|
+
const [ref, isOnScreen] = useOnScreen({ rootMargin: "200px 0px 200px 0px" });
|
|
176
191
|
|
|
177
192
|
return (
|
|
178
|
-
<aside
|
|
193
|
+
<aside
|
|
194
|
+
ref={ref}
|
|
195
|
+
className="flex flex-col overflow-hidden sticky top-[--scroll-padding] gap-4"
|
|
196
|
+
>
|
|
179
197
|
<SidecarBox.Root>
|
|
180
198
|
<SidecarBox.Head className="flex justify-between items-center flex-nowrap py-3 gap-2 text-xs">
|
|
181
199
|
<span className="font-mono break-words">
|
|
@@ -185,55 +203,51 @@ export const Sidecar = ({
|
|
|
185
203
|
|
|
186
204
|
{path}
|
|
187
205
|
</span>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
206
|
+
{isOnScreen && (
|
|
207
|
+
<PlaygroundDialogWrapper
|
|
208
|
+
server={result.data.schema.url ?? ""}
|
|
209
|
+
servers={
|
|
210
|
+
result.data.schema.servers.map((server) => server.url) ?? []
|
|
211
|
+
}
|
|
212
|
+
operation={operation}
|
|
213
|
+
/>
|
|
214
|
+
)}
|
|
195
215
|
</SidecarBox.Head>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
{ value: "php", label: "PHP" },
|
|
227
|
-
{ value: "ruby", label: "Ruby" },
|
|
228
|
-
{ value: "swift", label: "Swift" },
|
|
229
|
-
]}
|
|
230
|
-
/>
|
|
231
|
-
</SidecarBox.Footer>
|
|
216
|
+
{isOnScreen && (
|
|
217
|
+
<>
|
|
218
|
+
<SidecarBox.Body className="p-0">
|
|
219
|
+
<CollapsibleCode>
|
|
220
|
+
<SyntaxHighlight
|
|
221
|
+
language={selectedLang}
|
|
222
|
+
noBackground
|
|
223
|
+
className="[--scrollbar-color:gray] text-xs max-h-[500px] p-2"
|
|
224
|
+
code={code!}
|
|
225
|
+
/>
|
|
226
|
+
</CollapsibleCode>
|
|
227
|
+
</SidecarBox.Body>
|
|
228
|
+
<SidecarBox.Footer className="flex items-center text-xs gap-2 justify-end py-1">
|
|
229
|
+
<span>Show example in</span>
|
|
230
|
+
<SimpleSelect
|
|
231
|
+
className="self-start max-w-[150px]"
|
|
232
|
+
value={selectedLang}
|
|
233
|
+
onChange={(e) => {
|
|
234
|
+
startTransition(() => {
|
|
235
|
+
setSearchParams((prev) => {
|
|
236
|
+
prev.set("lang", e.target.value);
|
|
237
|
+
return prev;
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
}}
|
|
241
|
+
options={EXAMPLE_LANGUAGES}
|
|
242
|
+
/>
|
|
243
|
+
</SidecarBox.Footer>
|
|
244
|
+
</>
|
|
245
|
+
)}
|
|
232
246
|
</SidecarBox.Root>
|
|
233
|
-
{requestBodyContent && (
|
|
247
|
+
{isOnScreen && requestBodyContent && (
|
|
234
248
|
<RequestBodySidecarBox content={requestBodyContent} />
|
|
235
249
|
)}
|
|
236
|
-
{operation.responses.length > 0 && (
|
|
250
|
+
{isOnScreen && operation.responses.length > 0 && (
|
|
237
251
|
<ResponsesSidecarBox
|
|
238
252
|
selectedResponse={selectedResponse}
|
|
239
253
|
onSelectResponse={onSelectResponse}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { GraphQLError } from "graphql/error/index.js";
|
|
2
|
+
import { ulid } from "ulidx";
|
|
3
|
+
import { initializeWorker } from "zudoku/openapi-worker";
|
|
4
|
+
import { ZudokuError } from "../../../util/invariant.js";
|
|
5
|
+
import type { TypedDocumentString } from "../graphql/graphql.js";
|
|
6
|
+
import type { OpenApiPluginOptions } from "../index.js";
|
|
7
|
+
import type { LocalServer } from "./createServer.js";
|
|
8
|
+
import type { WorkerGraphQLMessage } from "./worker.js";
|
|
9
|
+
|
|
10
|
+
let localServerPromise: Promise<LocalServer> | undefined;
|
|
11
|
+
let worker: SharedWorker | undefined;
|
|
12
|
+
|
|
13
|
+
type GraphQLResponse<TResult> = {
|
|
14
|
+
errors?: GraphQLError[];
|
|
15
|
+
data: TResult;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const resolveVariables = async (variables?: unknown) => {
|
|
19
|
+
if (!variables) return;
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
typeof variables === "object" &&
|
|
23
|
+
"type" in variables &&
|
|
24
|
+
variables.type === "file" &&
|
|
25
|
+
"input" in variables &&
|
|
26
|
+
typeof variables.input === "function"
|
|
27
|
+
) {
|
|
28
|
+
variables.input = await variables.input();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const throwIfError = (response: GraphQLResponse<unknown>) => {
|
|
33
|
+
if (!response.errors?.[0]) return;
|
|
34
|
+
|
|
35
|
+
throw new ZudokuError(response.errors[0].message, {
|
|
36
|
+
developerHint:
|
|
37
|
+
"Check your configuration value `apis.type` and `apis.input` in the Zudoku config.",
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export class GraphQLClient {
|
|
42
|
+
readonly #mode: "remote" | "in-memory" | "worker";
|
|
43
|
+
#pendingRequests = new Map<string, (value: any) => void>();
|
|
44
|
+
#port: MessagePort | undefined;
|
|
45
|
+
|
|
46
|
+
constructor(private config: OpenApiPluginOptions) {
|
|
47
|
+
if (config.server) {
|
|
48
|
+
this.#mode = "remote";
|
|
49
|
+
} else if (config.inMemory || typeof SharedWorker === "undefined") {
|
|
50
|
+
this.#mode = "in-memory";
|
|
51
|
+
} else {
|
|
52
|
+
this.#mode = "worker";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#initializeLocalServer = () =>
|
|
57
|
+
import("./createServer.js").then((m) => m.createServer());
|
|
58
|
+
|
|
59
|
+
fetch = async <TResult, TVariables>(
|
|
60
|
+
query: TypedDocumentString<TResult, TVariables>,
|
|
61
|
+
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables]
|
|
62
|
+
) => {
|
|
63
|
+
const operationName = query.match(/query (\w+)/)?.[1];
|
|
64
|
+
|
|
65
|
+
await resolveVariables(variables);
|
|
66
|
+
|
|
67
|
+
const body = JSON.stringify({ query, variables, operationName });
|
|
68
|
+
|
|
69
|
+
switch (this.#mode) {
|
|
70
|
+
case "remote": {
|
|
71
|
+
const response = await fetch(this.config.server!, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
body,
|
|
74
|
+
headers: { "Content-Type": "application/json" },
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
throw new Error("Network response was not ok");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const result = (await response.json()) as GraphQLResponse<TResult>;
|
|
82
|
+
throwIfError(result);
|
|
83
|
+
|
|
84
|
+
return result.data;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
case "in-memory": {
|
|
88
|
+
if (!localServerPromise) {
|
|
89
|
+
localServerPromise = this.#initializeLocalServer();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const localServer = await localServerPromise;
|
|
93
|
+
if (!localServer) throw new Error("Local server not initialized");
|
|
94
|
+
|
|
95
|
+
const response = await localServer.fetch(
|
|
96
|
+
new Request("http://localhost/graphql", {
|
|
97
|
+
method: "POST",
|
|
98
|
+
body,
|
|
99
|
+
headers: { "Content-Type": "application/json" },
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
throw new Error("Network response was not ok");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const result = (await response.json()) as GraphQLResponse<TResult>;
|
|
108
|
+
throwIfError(result);
|
|
109
|
+
|
|
110
|
+
return result.data;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
case "worker": {
|
|
114
|
+
if (!worker) {
|
|
115
|
+
worker = initializeWorker();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!this.#port) {
|
|
119
|
+
const channel = new MessageChannel();
|
|
120
|
+
|
|
121
|
+
worker.port.postMessage({ port: channel.port2 }, [channel.port2]);
|
|
122
|
+
|
|
123
|
+
this.#port = channel.port1;
|
|
124
|
+
|
|
125
|
+
this.#port.onmessage = (e: MessageEvent<WorkerGraphQLMessage>) => {
|
|
126
|
+
const { id, body } = e.data;
|
|
127
|
+
const resolve = this.#pendingRequests.get(id);
|
|
128
|
+
if (resolve) {
|
|
129
|
+
const result = JSON.parse(body);
|
|
130
|
+
resolve(result);
|
|
131
|
+
this.#pendingRequests.delete(id);
|
|
132
|
+
} else {
|
|
133
|
+
// eslint-disable-next-line no-console
|
|
134
|
+
console.error(`No pending request found for id: ${id}`);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
this.#port.start();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const id = ulid();
|
|
142
|
+
|
|
143
|
+
const resultPromise = new Promise<GraphQLResponse<TResult>>(
|
|
144
|
+
(resolve) => {
|
|
145
|
+
this.#pendingRequests.set(id, resolve);
|
|
146
|
+
this.#port!.postMessage({ id, body } as WorkerGraphQLMessage);
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const result = await resultPromise;
|
|
151
|
+
throwIfError(result);
|
|
152
|
+
|
|
153
|
+
return result.data;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext, type ReactNode } from "react";
|
|
2
|
+
import { GraphQLClient } from "./GraphQLClient.js";
|
|
3
|
+
|
|
4
|
+
export const GraphQLContext = createContext<GraphQLClient | undefined>(
|
|
5
|
+
undefined,
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export const GraphQLProvider = ({
|
|
9
|
+
children,
|
|
10
|
+
client,
|
|
11
|
+
}: {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
client: GraphQLClient;
|
|
14
|
+
}) => (
|
|
15
|
+
<GraphQLContext.Provider value={client}>{children}</GraphQLContext.Provider>
|
|
16
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import hashit from "object-hash";
|
|
2
|
+
import { useContext, useMemo } from "react";
|
|
3
|
+
import type { TypedDocumentString } from "../graphql/graphql.js";
|
|
4
|
+
import { GraphQLContext } from "./GraphQLContext.js";
|
|
5
|
+
|
|
6
|
+
export const useCreateQuery = <TResult, TVariables>(
|
|
7
|
+
query: TypedDocumentString<TResult, TVariables>,
|
|
8
|
+
...variables: TVariables extends Record<string, never> ? [] : [TVariables]
|
|
9
|
+
) => {
|
|
10
|
+
const graphQLClient = useContext(GraphQLContext);
|
|
11
|
+
if (graphQLClient === undefined) {
|
|
12
|
+
throw new Error("useGraphQL must be used within a GraphQLProvider");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const hash = useMemo(() => hashit(variables[0] ?? {}), [variables]);
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
queryFn: () => graphQLClient.fetch(query, ...variables),
|
|
19
|
+
queryKey: [query, hash],
|
|
20
|
+
} as const;
|
|
21
|
+
};
|
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
import { createServer } from "./createServer.js";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
export type WorkerGraphQLMessage = { id: string; body: string };
|
|
3
4
|
|
|
4
5
|
const localServer = createServer();
|
|
5
6
|
|
|
6
7
|
const worker = self as unknown as SharedWorkerGlobalScope;
|
|
7
8
|
|
|
8
|
-
worker.addEventListener(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
9
|
+
worker.addEventListener("connect", (event) => {
|
|
10
|
+
const mainPort = event.ports[0];
|
|
11
|
+
|
|
12
|
+
mainPort!.onmessage = (e) => {
|
|
13
|
+
if (e.data.port) {
|
|
14
|
+
const clientPort = e.data.port as MessagePort;
|
|
15
|
+
|
|
16
|
+
clientPort.onmessage = async (
|
|
17
|
+
event: MessageEvent<{ id: string; body: string }>,
|
|
18
|
+
) => {
|
|
19
|
+
const { id, body } = event.data;
|
|
20
|
+
|
|
21
|
+
const response = await localServer.fetch(
|
|
22
|
+
new Request("/__z/graphql", {
|
|
23
|
+
method: "POST",
|
|
24
|
+
body,
|
|
25
|
+
headers: {
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const responseBody = await response.text();
|
|
32
|
+
|
|
33
|
+
clientPort.postMessage({
|
|
34
|
+
id,
|
|
35
|
+
body: responseBody,
|
|
36
|
+
} as WorkerGraphQLMessage);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
clientPort.start();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
mainPort!.start();
|
|
44
|
+
});
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
import type {
|
|
3
3
|
DocumentTypeDecoration,
|
|
4
4
|
ResultOf,
|
|
5
|
-
TypedDocumentNode,
|
|
6
5
|
} from "@graphql-typed-document-node/core";
|
|
7
|
-
import type {
|
|
8
|
-
import type { Incremental } from "./graphql.js";
|
|
6
|
+
import type { Incremental, TypedDocumentString } from "./graphql.js";
|
|
9
7
|
|
|
10
8
|
export type FragmentType<
|
|
11
9
|
TDocumentType extends DocumentTypeDecoration<any, any>,
|
|
@@ -86,26 +84,21 @@ export function makeFragmentData<
|
|
|
86
84
|
return data as FragmentType<F>;
|
|
87
85
|
}
|
|
88
86
|
export function isFragmentReady<TQuery, TFrag>(
|
|
89
|
-
queryNode:
|
|
90
|
-
fragmentNode:
|
|
87
|
+
queryNode: TypedDocumentString<TQuery, any>,
|
|
88
|
+
fragmentNode: TypedDocumentString<TFrag, any>,
|
|
91
89
|
data:
|
|
92
|
-
| FragmentType<
|
|
90
|
+
| FragmentType<TypedDocumentString<Incremental<TFrag>, any>>
|
|
93
91
|
| null
|
|
94
92
|
| undefined,
|
|
95
93
|
): data is FragmentType<typeof fragmentNode> {
|
|
96
|
-
const deferredFields =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
const deferredFields = queryNode.__meta__?.deferredFields as Record<
|
|
95
|
+
string,
|
|
96
|
+
(keyof TFrag)[]
|
|
97
|
+
>;
|
|
98
|
+
const fragName = fragmentNode.__meta__?.fragmentName as string | undefined;
|
|
101
99
|
|
|
102
|
-
if (!deferredFields) return true;
|
|
100
|
+
if (!deferredFields || !fragName) return true;
|
|
103
101
|
|
|
104
|
-
const
|
|
105
|
-
| FragmentDefinitionNode
|
|
106
|
-
| undefined;
|
|
107
|
-
const fragName = fragDef?.name?.value;
|
|
108
|
-
|
|
109
|
-
const fields = (fragName && deferredFields[fragName]) || [];
|
|
102
|
+
const fields = deferredFields[fragName] ?? [];
|
|
110
103
|
return fields.length > 0 && fields.every((field) => data && field in data);
|
|
111
104
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import type { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core";
|
|
3
2
|
import * as types from "./graphql.js";
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -11,68 +10,52 @@ import * as types from "./graphql.js";
|
|
|
11
10
|
* 3. It does not support dead code elimination, so it will add unused operations.
|
|
12
11
|
*
|
|
13
12
|
* Therefore it is highly recommended to use the babel or swc plugin for production.
|
|
13
|
+
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
|
|
14
14
|
*/
|
|
15
15
|
const documents = {
|
|
16
16
|
"\n query ServersQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n":
|
|
17
17
|
types.ServersQueryDocument,
|
|
18
|
-
"\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n parameters {\n name\n in\n description\n required\n schema\n style\n examples {\n name\n description\n externalValue\n value\n summary\n }\n }\n requestBody {\n content {\n mediaType\n encoding {\n name\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n":
|
|
18
|
+
"\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n parameters {\n name\n in\n description\n required\n schema\n style\n examples {\n name\n description\n externalValue\n value\n summary\n }\n }\n requestBody {\n content {\n mediaType\n encoding {\n name\n }\n examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n":
|
|
19
19
|
types.OperationsFragmentFragmentDoc,
|
|
20
20
|
"\n query AllOperations($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n description\n title\n url\n version\n tags {\n name\n description\n operations {\n slug\n ...OperationsFragment\n }\n }\n }\n }\n":
|
|
21
21
|
types.AllOperationsDocument,
|
|
22
22
|
"\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n":
|
|
23
23
|
types.GetServerQueryDocument,
|
|
24
|
-
"\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n":
|
|
24
|
+
"\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n":
|
|
25
25
|
types.GetCategoriesDocument,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* The query argument is unknown!
|
|
38
|
-
* Please regenerate the types.
|
|
39
|
-
*/
|
|
40
|
-
export function graphql(source: string): unknown;
|
|
41
|
-
|
|
42
28
|
/**
|
|
43
29
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
44
30
|
*/
|
|
45
31
|
export function graphql(
|
|
46
32
|
source: "\n query ServersQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n",
|
|
47
|
-
):
|
|
33
|
+
): typeof import("./graphql.js").ServersQueryDocument;
|
|
48
34
|
/**
|
|
49
35
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
50
36
|
*/
|
|
51
37
|
export function graphql(
|
|
52
|
-
source: "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n parameters {\n name\n in\n description\n required\n schema\n style\n examples {\n name\n description\n externalValue\n value\n summary\n }\n }\n requestBody {\n content {\n mediaType\n encoding {\n name\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n",
|
|
53
|
-
):
|
|
38
|
+
source: "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n parameters {\n name\n in\n description\n required\n schema\n style\n examples {\n name\n description\n externalValue\n value\n summary\n }\n }\n requestBody {\n content {\n mediaType\n encoding {\n name\n }\n examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n",
|
|
39
|
+
): typeof import("./graphql.js").OperationsFragmentFragmentDoc;
|
|
54
40
|
/**
|
|
55
41
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
56
42
|
*/
|
|
57
43
|
export function graphql(
|
|
58
44
|
source: "\n query AllOperations($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n description\n title\n url\n version\n tags {\n name\n description\n operations {\n slug\n ...OperationsFragment\n }\n }\n }\n }\n",
|
|
59
|
-
):
|
|
45
|
+
): typeof import("./graphql.js").AllOperationsDocument;
|
|
60
46
|
/**
|
|
61
47
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
62
48
|
*/
|
|
63
49
|
export function graphql(
|
|
64
50
|
source: "\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n",
|
|
65
|
-
):
|
|
51
|
+
): typeof import("./graphql.js").GetServerQueryDocument;
|
|
66
52
|
/**
|
|
67
53
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
68
54
|
*/
|
|
69
55
|
export function graphql(
|
|
70
|
-
source: "\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n",
|
|
71
|
-
):
|
|
56
|
+
source: "\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n",
|
|
57
|
+
): typeof import("./graphql.js").GetCategoriesDocument;
|
|
72
58
|
|
|
73
59
|
export function graphql(source: string) {
|
|
74
60
|
return (documents as any)[source] ?? {};
|
|
75
61
|
}
|
|
76
|
-
|
|
77
|
-
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
|
|
78
|
-
TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|