zudoku 0.0.0-feat-openapi-docs-redesign.dab3fc6a → 0.0.0-feat-navigation-at-property.z8cd07fa5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/main.d.ts +6 -6
- package/dist/app/main.js +1 -1
- package/dist/app/main.js.map +1 -1
- package/dist/app/sentry.js +1 -1
- package/dist/cli/common/version-check.js +12 -3
- package/dist/cli/common/version-check.js.map +1 -1
- package/dist/config/create-plugin.d.ts +2 -0
- package/dist/config/create-plugin.js +55 -0
- package/dist/config/create-plugin.js.map +1 -0
- package/dist/config/loader.js +3 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/config/validators/BuildSchema.js +18 -3
- package/dist/config/validators/BuildSchema.js.map +1 -1
- package/dist/config/validators/InputNavigationSchema.d.ts +133 -45
- package/dist/config/validators/InputNavigationSchema.js +30 -0
- package/dist/config/validators/InputNavigationSchema.js.map +1 -1
- package/dist/config/validators/NavigationSchema.d.ts +18 -4
- package/dist/config/validators/NavigationSchema.js +15 -5
- package/dist/config/validators/NavigationSchema.js.map +1 -1
- package/dist/config/validators/ProtectedRoutesSchema.d.ts +1 -1
- package/dist/config/validators/validate.d.ts +104 -14
- package/dist/config/validators/validate.js +15 -4
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/config/validators/validate.test.js +43 -0
- package/dist/config/validators/validate.test.js.map +1 -1
- package/dist/flat-config.d.ts +68 -32
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/auth/issuer.js +1 -1
- package/dist/lib/auth/issuer.js.map +1 -1
- package/dist/lib/authentication/authentication.d.ts +3 -2
- package/dist/lib/authentication/components/CallbackHandler.js +1 -1
- package/dist/lib/authentication/components/CallbackHandler.js.map +1 -1
- package/dist/lib/authentication/components/SignIn.js +4 -2
- package/dist/lib/authentication/components/SignIn.js.map +1 -1
- package/dist/lib/authentication/components/SignUp.js +4 -2
- package/dist/lib/authentication/components/SignUp.js.map +1 -1
- package/dist/lib/authentication/hook.d.ts +2 -0
- package/dist/lib/authentication/hook.js +10 -0
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +17 -8
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/clerk.js +0 -22
- package/dist/lib/authentication/providers/clerk.js.map +1 -1
- package/dist/lib/authentication/providers/firebase.js +67 -9
- package/dist/lib/authentication/providers/firebase.js.map +1 -1
- package/dist/lib/authentication/providers/supabase.js +6 -15
- package/dist/lib/authentication/providers/supabase.js.map +1 -1
- package/dist/lib/authentication/ui/EmailVerificationUi.d.ts +4 -0
- package/dist/lib/authentication/ui/EmailVerificationUi.js +34 -0
- package/dist/lib/authentication/ui/EmailVerificationUi.js.map +1 -0
- package/dist/lib/authentication/ui/ZudokuAuthUi.d.ts +7 -2
- package/dist/lib/authentication/ui/ZudokuAuthUi.js +48 -12
- package/dist/lib/authentication/ui/ZudokuAuthUi.js.map +1 -1
- package/dist/lib/authentication/utils/relativeRedirectUrl.d.ts +1 -0
- package/dist/lib/authentication/utils/relativeRedirectUrl.js +8 -0
- package/dist/lib/authentication/utils/relativeRedirectUrl.js.map +1 -0
- package/dist/lib/components/Bootstrap.js +1 -2
- package/dist/lib/components/Bootstrap.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +1 -1
- package/dist/lib/components/Mermaid.d.ts +7 -0
- package/dist/lib/components/Mermaid.js +42 -0
- package/dist/lib/components/Mermaid.js.map +1 -0
- package/dist/lib/components/MobileTopNavigation.js +3 -2
- package/dist/lib/components/MobileTopNavigation.js.map +1 -1
- package/dist/lib/components/PagefindSearchMeta.d.ts +8 -0
- package/dist/lib/components/PagefindSearchMeta.js +7 -0
- package/dist/lib/components/PagefindSearchMeta.js.map +1 -0
- package/dist/lib/components/Pagination.js +2 -2
- package/dist/lib/components/Pagination.js.map +1 -1
- package/dist/lib/components/Slot.test.js +1 -1
- package/dist/lib/components/Slot.test.js.map +1 -1
- package/dist/lib/components/TopNavigation.d.ts +7 -1
- package/dist/lib/components/TopNavigation.js +8 -3
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/Zudoku.d.ts +4 -1
- package/dist/lib/components/Zudoku.js +5 -11
- package/dist/lib/components/Zudoku.js.map +1 -1
- package/dist/lib/components/context/ZudokuContext.d.ts +9 -4
- package/dist/lib/components/context/ZudokuContext.js +26 -8
- package/dist/lib/components/context/ZudokuContext.js.map +1 -1
- package/dist/lib/components/context/ZudokuProvider.js +1 -1
- package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
- package/dist/lib/components/context/ZudokuReactContext.d.ts +11 -0
- package/dist/lib/components/context/ZudokuReactContext.js +4 -0
- package/dist/lib/components/context/ZudokuReactContext.js.map +1 -0
- package/dist/lib/components/index.d.ts +18 -69
- package/dist/lib/components/index.js +19 -32
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/components/navigation/Navigation.js +4 -3
- package/dist/lib/components/navigation/Navigation.js.map +1 -1
- package/dist/lib/components/navigation/NavigationCategory.js +8 -0
- package/dist/lib/components/navigation/NavigationCategory.js.map +1 -1
- package/dist/lib/components/navigation/NavigationFilterContext.d.ts +8 -0
- package/dist/lib/components/navigation/NavigationFilterContext.js +12 -0
- package/dist/lib/components/navigation/NavigationFilterContext.js.map +1 -0
- package/dist/lib/components/navigation/NavigationFilterInput.d.ts +3 -0
- package/dist/lib/components/navigation/NavigationFilterInput.js +9 -0
- package/dist/lib/components/navigation/NavigationFilterInput.js.map +1 -0
- package/dist/lib/components/navigation/NavigationItem.js +13 -3
- package/dist/lib/components/navigation/NavigationItem.js.map +1 -1
- package/dist/lib/components/navigation/NavigationWrapper.js +1 -1
- package/dist/lib/components/navigation/NavigationWrapper.js.map +1 -1
- package/dist/lib/components/navigation/utils.d.ts +6 -1
- package/dist/lib/components/navigation/utils.js +26 -2
- package/dist/lib/components/navigation/utils.js.map +1 -1
- package/dist/lib/core/RouteGuard.js +12 -7
- package/dist/lib/core/RouteGuard.js.map +1 -1
- package/dist/lib/core/ZudokuContext.d.ts +2 -1
- package/dist/lib/core/ZudokuContext.js +3 -1
- package/dist/lib/core/ZudokuContext.js.map +1 -1
- package/dist/lib/core/__internal.d.ts +1 -0
- package/dist/lib/core/__internal.js +2 -0
- package/dist/lib/core/__internal.js.map +1 -1
- package/dist/lib/core/plugins.d.ts +18 -4
- package/dist/lib/core/plugins.js +1 -0
- package/dist/lib/core/plugins.js.map +1 -1
- package/dist/lib/core/react-query.d.ts +1 -0
- package/dist/lib/core/react-query.js +2 -0
- package/dist/lib/core/react-query.js.map +1 -0
- package/dist/lib/core/transform-config.d.ts +4 -0
- package/dist/lib/core/transform-config.js +42 -0
- package/dist/lib/core/transform-config.js.map +1 -0
- package/dist/lib/core/transform-config.test.d.ts +1 -0
- package/dist/lib/core/transform-config.test.js +83 -0
- package/dist/lib/core/transform-config.test.js.map +1 -0
- package/dist/lib/errors/ErrorAlert.js +1 -2
- package/dist/lib/errors/ErrorAlert.js.map +1 -1
- package/dist/lib/errors/ErrorMessage.d.ts +3 -0
- package/dist/lib/errors/ErrorMessage.js +16 -0
- package/dist/lib/errors/ErrorMessage.js.map +1 -0
- package/dist/lib/hooks/index.d.ts +7 -28
- package/dist/lib/hooks/index.js +7 -15
- package/dist/lib/hooks/index.js.map +1 -1
- package/dist/lib/hooks/useEvent.test.js +1 -1
- package/dist/lib/hooks/useEvent.test.js.map +1 -1
- package/dist/lib/navigation/pathMatcher.d.ts +8 -0
- package/dist/lib/navigation/pathMatcher.js +62 -0
- package/dist/lib/navigation/pathMatcher.js.map +1 -0
- package/dist/lib/navigation/pathMatcher.test.d.ts +1 -0
- package/dist/lib/navigation/pathMatcher.test.js +115 -0
- package/dist/lib/navigation/pathMatcher.test.js.map +1 -0
- package/dist/lib/navigation/positionItems.d.ts +10 -0
- package/dist/lib/navigation/positionItems.js +54 -0
- package/dist/lib/navigation/positionItems.js.map +1 -0
- package/dist/lib/navigation/positionItems.test.d.ts +1 -0
- package/dist/lib/navigation/positionItems.test.js +229 -0
- package/dist/lib/navigation/positionItems.test.js.map +1 -0
- package/dist/lib/oas/graphql/circular.d.ts +2 -0
- package/dist/lib/oas/graphql/circular.js +21 -16
- package/dist/lib/oas/graphql/circular.js.map +1 -1
- package/dist/lib/oas/graphql/circular.test.d.ts +1 -0
- package/dist/lib/oas/graphql/circular.test.js +183 -0
- package/dist/lib/oas/graphql/circular.test.js.map +1 -0
- package/dist/lib/oas/graphql/index.js +7 -3
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/oas/parser/index.d.ts +1 -0
- package/dist/lib/oas/parser/index.js +14 -5
- package/dist/lib/oas/parser/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js +9 -172
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
- package/dist/lib/plugins/api-keys/index.d.ts +11 -4
- package/dist/lib/plugins/api-keys/index.js +36 -22
- package/dist/lib/plugins/api-keys/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/settings/ApiKeyItem.d.ts +12 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js +133 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js.map +1 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyList.d.ts +4 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyList.js +33 -0
- package/dist/lib/plugins/api-keys/settings/ApiKeyList.js.map +1 -0
- package/dist/lib/plugins/api-keys/settings/RevealApiKey.d.ts +6 -0
- package/dist/lib/plugins/api-keys/settings/RevealApiKey.js +39 -0
- package/dist/lib/plugins/api-keys/settings/RevealApiKey.js.map +1 -0
- package/dist/lib/plugins/openapi/DownloadSchemaButton.d.ts +3 -0
- package/dist/lib/plugins/openapi/DownloadSchemaButton.js +47 -0
- package/dist/lib/plugins/openapi/DownloadSchemaButton.js.map +1 -0
- package/dist/lib/plugins/openapi/Endpoint.js +3 -6
- package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
- package/dist/lib/plugins/openapi/GeneratedExampleSidecarBox.js +1 -1
- package/dist/lib/plugins/openapi/OasProvider.js +26 -13
- package/dist/lib/plugins/openapi/OasProvider.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +20 -10
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +2 -2
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/ParamInfos.js +1 -0
- package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterList.js +1 -1
- package/dist/lib/plugins/openapi/ParameterList.js.map +1 -1
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.d.ts +2 -1
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +4 -3
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/SchemaList.js +2 -1
- package/dist/lib/plugins/openapi/SchemaList.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +12 -3
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +11 -5
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +19 -13
- package/dist/lib/plugins/openapi/playground/Playground.js +8 -4
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/fileUtils.d.ts +1 -0
- package/dist/lib/plugins/openapi/playground/fileUtils.js +3 -0
- package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.d.ts +6 -0
- package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.js +20 -0
- package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +7 -2
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.d.ts +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js +16 -7
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/utils.d.ts +2 -2
- package/dist/lib/plugins/openapi/schema/utils.js +11 -3
- package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
- package/dist/lib/plugins/openapi/util/createHttpSnippet.js +24 -1
- package/dist/lib/plugins/openapi/util/createHttpSnippet.js.map +1 -1
- package/dist/lib/plugins/openapi/util/getRoutes.d.ts +9 -1
- package/dist/lib/plugins/openapi/util/getRoutes.js +30 -2
- package/dist/lib/plugins/openapi/util/getRoutes.js.map +1 -1
- package/dist/lib/plugins/search-pagefind/IndexingDialog.d.ts +3 -0
- package/dist/lib/plugins/search-pagefind/IndexingDialog.js +64 -0
- package/dist/lib/plugins/search-pagefind/IndexingDialog.js.map +1 -0
- package/dist/lib/plugins/search-pagefind/PagefindSearch.js +22 -5
- package/dist/lib/plugins/search-pagefind/PagefindSearch.js.map +1 -1
- package/dist/lib/plugins/search-pagefind/ResultList.js +5 -4
- package/dist/lib/plugins/search-pagefind/ResultList.js.map +1 -1
- package/dist/lib/shiki.d.ts +1 -1
- package/dist/lib/shiki.js +18 -12
- package/dist/lib/shiki.js.map +1 -1
- package/dist/lib/ui/Alert.d.ts +3 -2
- package/dist/lib/ui/Alert.js +9 -5
- package/dist/lib/ui/Alert.js.map +1 -1
- package/dist/lib/ui/Button.d.ts +2 -2
- package/dist/lib/ui/Button.js +10 -9
- package/dist/lib/ui/Button.js.map +1 -1
- package/dist/lib/ui/ButtonGroup.d.ts +11 -0
- package/dist/lib/ui/ButtonGroup.js +28 -0
- package/dist/lib/ui/ButtonGroup.js.map +1 -0
- package/dist/lib/ui/Command.d.ts +3 -3
- package/dist/lib/ui/Command.js +2 -2
- package/dist/lib/ui/Command.js.map +1 -1
- package/dist/lib/ui/DropdownMenu.d.ts +21 -23
- package/dist/lib/ui/DropdownMenu.js +47 -32
- package/dist/lib/ui/DropdownMenu.js.map +1 -1
- package/dist/lib/ui/InputGroup.d.ts +16 -0
- package/dist/lib/ui/InputGroup.js +65 -0
- package/dist/lib/ui/InputGroup.js.map +1 -0
- package/dist/lib/ui/Kbd.d.ts +3 -0
- package/dist/lib/ui/Kbd.js +10 -0
- package/dist/lib/ui/Kbd.js.map +1 -0
- package/dist/lib/ui/Secret.js +2 -2
- package/dist/lib/ui/Secret.js.map +1 -1
- package/dist/lib/util/MdxComponents.d.ts +1 -0
- package/dist/lib/util/MdxComponents.js +2 -0
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/lib/util/flattenAllOf.d.ts +0 -2
- package/dist/lib/util/flattenAllOf.js +0 -23
- package/dist/lib/util/flattenAllOf.js.map +1 -1
- package/dist/lib/util/flattenAllOf.test.js +69 -13
- package/dist/lib/util/flattenAllOf.test.js.map +1 -1
- package/dist/lib/util/flattenAllOfProcessor.d.ts +2 -0
- package/dist/lib/util/flattenAllOfProcessor.js +48 -0
- package/dist/lib/util/flattenAllOfProcessor.js.map +1 -0
- package/dist/lib/util/invariant.d.ts +1 -1
- package/dist/lib/util/invariant.js +2 -2
- package/dist/lib/util/invariant.js.map +1 -1
- package/dist/lib/util/readFrontmatter.d.ts +6 -0
- package/dist/lib/util/readFrontmatter.js +13 -0
- package/dist/lib/util/readFrontmatter.js.map +1 -0
- package/dist/vite/api/SchemaManager.d.ts +17 -1
- package/dist/vite/api/SchemaManager.js +52 -11
- package/dist/vite/api/SchemaManager.js.map +1 -1
- package/dist/vite/api/SchemaManager.test.js +111 -0
- package/dist/vite/api/SchemaManager.test.js.map +1 -1
- package/dist/vite/build.js +91 -73
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/config.js +16 -1
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/dev-server.js +25 -0
- package/dist/vite/dev-server.js.map +1 -1
- package/dist/vite/error-handler.js +1 -5
- package/dist/vite/error-handler.js.map +1 -1
- package/dist/vite/mdx/remark-inject-filepath.js +5 -1
- package/dist/vite/mdx/remark-inject-filepath.js.map +1 -1
- package/dist/vite/mdx/remark-last-modified.js +57 -3
- package/dist/vite/mdx/remark-last-modified.js.map +1 -1
- package/dist/vite/mdx/remark-link-rewrite.js +4 -3
- package/dist/vite/mdx/remark-link-rewrite.js.map +1 -1
- package/dist/vite/pagefind-dev-index.d.ts +16 -0
- package/dist/vite/pagefind-dev-index.js +68 -0
- package/dist/vite/pagefind-dev-index.js.map +1 -0
- package/dist/vite/plugin-api-keys.js +5 -1
- package/dist/vite/plugin-api-keys.js.map +1 -1
- package/dist/vite/plugin-api.js +44 -4
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-config.js +16 -4
- package/dist/vite/plugin-config.js.map +1 -1
- package/dist/vite/plugin-docs.js +9 -7
- package/dist/vite/plugin-docs.js.map +1 -1
- package/dist/vite/plugin-frontmatter.js +3 -5
- package/dist/vite/plugin-frontmatter.js.map +1 -1
- package/dist/vite/plugin-markdown-export.js +8 -7
- package/dist/vite/plugin-markdown-export.js.map +1 -1
- package/dist/vite/plugin-theme.js +2 -1
- package/dist/vite/plugin-theme.js.map +1 -1
- package/dist/vite/prerender/prerender.js +4 -20
- package/dist/vite/prerender/prerender.js.map +1 -1
- package/dist/vite/prerender/utils.d.ts +2 -0
- package/dist/vite/prerender/utils.js +30 -0
- package/dist/vite/prerender/utils.js.map +1 -0
- package/dist/vite/prerender/worker.js +6 -1
- package/dist/vite/prerender/worker.js.map +1 -1
- package/dist/vite/zuplo.d.ts +13 -0
- package/dist/vite/zuplo.js +15 -0
- package/dist/vite/zuplo.js.map +1 -0
- package/lib/ActionButton-B0CXL1Lq.js +25 -0
- package/lib/ActionButton-B0CXL1Lq.js.map +1 -0
- package/lib/Button-GUVe7pmt.js +54 -0
- package/lib/Button-GUVe7pmt.js.map +1 -0
- package/lib/{Card-KFniaZn5.js → Card-DCdq37aA.js} +2 -2
- package/lib/{Card-KFniaZn5.js.map → Card-DCdq37aA.js.map} +1 -1
- package/lib/ClaudeLogo-DoZ7fHHk.js +73 -0
- package/lib/ClaudeLogo-DoZ7fHHk.js.map +1 -0
- package/lib/{Command-CUcrW3qs.js → Command-N6VujV30.js} +26 -26
- package/lib/Command-N6VujV30.js.map +1 -0
- package/lib/{Dialog-BQciPiHN.js → Dialog-hlvmmQ_c.js} +2 -2
- package/lib/{Dialog-BQciPiHN.js.map → Dialog-hlvmmQ_c.js.map} +1 -1
- package/lib/{Drawer-Ci7XwhqT.js → Drawer-Ch7927PF.js} +7 -7
- package/lib/{Drawer-Ci7XwhqT.js.map → Drawer-Ch7927PF.js.map} +1 -1
- package/lib/DropdownMenu-DN0jNrjj.js +104 -0
- package/lib/DropdownMenu-DN0jNrjj.js.map +1 -0
- package/lib/Frame-DKlOmSkU.js +205 -0
- package/lib/Frame-DKlOmSkU.js.map +1 -0
- package/lib/HydrationBoundary-CJu4vUlG.js +601 -0
- package/lib/HydrationBoundary-CJu4vUlG.js.map +1 -0
- package/lib/IndexingDialog-D0YdGfbn.js +100 -0
- package/lib/IndexingDialog-D0YdGfbn.js.map +1 -0
- package/lib/Input-Cx-GeKoF.js +22 -0
- package/lib/Input-Cx-GeKoF.js.map +1 -0
- package/lib/MdxPage-Bc_5OsQ5.js +210 -0
- package/lib/MdxPage-Bc_5OsQ5.js.map +1 -0
- package/lib/Mermaid-Chx5BPHn.js +104 -0
- package/lib/Mermaid-Chx5BPHn.js.map +1 -0
- package/lib/{OAuthErrorPage-DnKnq4xK.js → OAuthErrorPage-D-VcZ5cO.js} +26 -23
- package/lib/OAuthErrorPage-D-VcZ5cO.js.map +1 -0
- package/lib/OasProvider-CZqLHoRo.js +48 -0
- package/lib/OasProvider-CZqLHoRo.js.map +1 -0
- package/lib/{OperationList-D8EDc9v7.js → OperationList-BmV1XvEY.js} +2136 -2002
- package/lib/OperationList-BmV1XvEY.js.map +1 -0
- package/lib/RouteGuard-Dns7HD7C.js +77 -0
- package/lib/RouteGuard-Dns7HD7C.js.map +1 -0
- package/lib/{SchemaList-E6lF7dID.js → SchemaList-D23IyrX5.js} +28 -27
- package/lib/SchemaList-D23IyrX5.js.map +1 -0
- package/lib/SchemaView-DVbiGPo3.js +438 -0
- package/lib/SchemaView-DVbiGPo3.js.map +1 -0
- package/lib/Secret-CyhXSA8i.js +263 -0
- package/lib/Secret-CyhXSA8i.js.map +1 -0
- package/lib/SignUp-DfEe1w5X.js +55 -0
- package/lib/SignUp-DfEe1w5X.js.map +1 -0
- package/lib/{SyntaxHighlight-C19vH0V_.js → SyntaxHighlight-N2RffYNz.js} +1469 -1411
- package/lib/SyntaxHighlight-N2RffYNz.js.map +1 -0
- package/lib/{Toc-DbWS75JZ.js → Toc-Cpo_HSYx.js} +3 -3
- package/lib/{Toc-DbWS75JZ.js.map → Toc-Cpo_HSYx.js.map} +1 -1
- package/lib/{ErrorAlert-_1Zmhr68.js → Zudoku-GbutmWzP.js} +5663 -4482
- package/lib/Zudoku-GbutmWzP.js.map +1 -0
- package/lib/ZudokuContext-LPkD2SQs.js +250 -0
- package/lib/ZudokuContext-LPkD2SQs.js.map +1 -0
- package/lib/ZudokuReactContext-DGJAP1sN.js +222 -0
- package/lib/ZudokuReactContext-DGJAP1sN.js.map +1 -0
- package/lib/chunk-EPOLDU6W-C6C8jAwd.js +8558 -0
- package/lib/chunk-EPOLDU6W-C6C8jAwd.js.map +1 -0
- package/lib/{circular-BoYo7au5.js → circular-DfSpMuY7.js} +6429 -6019
- package/lib/circular-DfSpMuY7.js.map +1 -0
- package/lib/{cn-dYga0KKN.js → cn-5-Gd1Dss.js} +531 -498
- package/lib/cn-5-Gd1Dss.js.map +1 -0
- package/lib/{createServer-B_BZ7xX8.js → createServer-4kaAMuIM.js} +2790 -2737
- package/lib/createServer-4kaAMuIM.js.map +1 -0
- package/lib/createVariantComponent-Dc0vtOvr.js +18 -0
- package/lib/createVariantComponent-Dc0vtOvr.js.map +1 -0
- package/lib/{errors-CD873hrG.js → errors-CtZTDEB6.js} +3 -3
- package/lib/{errors-CD873hrG.js.map → errors-CtZTDEB6.js.map} +1 -1
- package/lib/firebase-D286uF4e.js +7615 -0
- package/lib/firebase-D286uF4e.js.map +1 -0
- package/lib/hook-DyEn6D2Q.js +53 -0
- package/lib/hook-DyEn6D2Q.js.map +1 -0
- package/lib/{index-HNVs5cgX.js → index-B7bvsQHg.js} +853 -802
- package/lib/index-B7bvsQHg.js.map +1 -0
- package/lib/{index-BK0jKRrX.js → index-CVumYRba.js} +2 -2
- package/lib/{index-BK0jKRrX.js.map → index-CVumYRba.js.map} +1 -1
- package/lib/index-CrcNWbel.js.map +1 -1
- package/lib/index-DAWHN3cH.js +86 -0
- package/lib/index-DAWHN3cH.js.map +1 -0
- package/lib/index.esm-BYObtETB.js.map +1 -1
- package/lib/index.esm-BkpWrvLZ.js +34 -0
- package/lib/index.esm-BkpWrvLZ.js.map +1 -0
- package/lib/{index.esm-BnYHxCYC.js → index.esm-Ca5zvoff.js} +2 -2
- package/lib/{index.esm-BnYHxCYC.js.map → index.esm-Ca5zvoff.js.map} +1 -1
- package/lib/{invariant-Bm-FVUQE.js → invariant-B_t_F2s_.js} +4 -4
- package/lib/invariant-B_t_F2s_.js.map +1 -0
- package/lib/jsx-runtime-BzflLqGi.js.map +1 -1
- package/lib/{mutation-BSU0xu4m.js → mutation-B7eFBLZY.js} +70 -44
- package/lib/mutation-B7eFBLZY.js.map +1 -0
- package/lib/ui/Accordion.js +1 -1
- package/lib/ui/ActionButton.js +2 -2
- package/lib/ui/Alert.js +32 -20
- package/lib/ui/Alert.js.map +1 -1
- package/lib/ui/AlertDialog.js +1 -1
- package/lib/ui/Badge.js +1 -1
- package/lib/ui/Breadcrumb.js +1 -1
- package/lib/ui/Button.js +27 -25
- package/lib/ui/Button.js.map +1 -1
- package/lib/ui/ButtonGroup.js +77 -0
- package/lib/ui/ButtonGroup.js.map +1 -0
- package/lib/ui/Callout.js +1 -1
- package/lib/ui/Card.js +1 -1
- package/lib/ui/Carousel.js +1 -1
- package/lib/ui/Carousel.js.map +1 -1
- package/lib/ui/Checkbox.js +1 -1
- package/lib/ui/CodeBlock.js +1 -1
- package/lib/ui/Command.js +5 -5
- package/lib/ui/Command.js.map +1 -1
- package/lib/ui/Dialog.js +1 -1
- package/lib/ui/Drawer.js +3 -3
- package/lib/ui/DropdownMenu.js +227 -140
- package/lib/ui/DropdownMenu.js.map +1 -1
- package/lib/ui/EmbeddedCodeBlock.js +1 -1
- package/lib/ui/Form.js +1 -1
- package/lib/ui/Frame.js +1 -1
- package/lib/ui/HoverCard.js +1 -1
- package/lib/ui/Input.js +1 -1
- package/lib/ui/InputGroup.js +155 -0
- package/lib/ui/InputGroup.js.map +1 -0
- package/lib/ui/Item.js +1 -1
- package/lib/ui/Kbd.js +32 -0
- package/lib/ui/Kbd.js.map +1 -0
- package/lib/ui/Label.js +1 -1
- package/lib/ui/NativeSelect.js +1 -1
- package/lib/ui/Pagination.js +1 -1
- package/lib/ui/Popover.js +1 -1
- package/lib/ui/Progress.js +1 -1
- package/lib/ui/RadioGroup.js +1 -1
- package/lib/ui/ScrollArea.js +1 -1
- package/lib/ui/Secret.js +3 -3
- package/lib/ui/Secret.js.map +1 -1
- package/lib/ui/Separator.js +1 -1
- package/lib/ui/Skeleton.js +1 -1
- package/lib/ui/Slider.js +1 -1
- package/lib/ui/Switch.js +1 -1
- package/lib/ui/SyntaxHighlight.js +3 -3
- package/lib/ui/Tabs.js +1 -1
- package/lib/ui/Textarea.js +1 -1
- package/lib/ui/Toggle.js +1 -1
- package/lib/ui/ToggleGroup.js +1 -1
- package/lib/ui/Value.js +1 -1
- package/lib/ui/util.js +1 -1
- package/lib/useExposedProps-CzTDfXfq.js +30 -0
- package/lib/useExposedProps-CzTDfXfq.js.map +1 -0
- package/lib/useMutation-CErliDZ9.js +119 -0
- package/lib/useMutation-CErliDZ9.js.map +1 -0
- package/lib/useQuery-ht7aWJ3S.js +1212 -0
- package/lib/useQuery-ht7aWJ3S.js.map +1 -0
- package/lib/useSuspenseQuery-DQH4Bmc2.js +18 -0
- package/lib/useSuspenseQuery-DQH4Bmc2.js.map +1 -0
- package/lib/zudoku.__internal.js +1540 -1553
- package/lib/zudoku.__internal.js.map +1 -1
- package/lib/zudoku.auth-auth0.js +19 -18
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-azureb2c.js +14 -13
- package/lib/zudoku.auth-azureb2c.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +52 -75
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-firebase.js +10 -0
- package/lib/zudoku.auth-firebase.js.map +1 -0
- package/lib/zudoku.auth-openid.js +8 -7
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.auth-supabase.js +31 -40
- package/lib/zudoku.auth-supabase.js.map +1 -1
- package/lib/zudoku.components.js +29 -25
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.hooks.js +20 -20
- package/lib/zudoku.hooks.js.map +1 -1
- package/lib/zudoku.mermaid.js +11 -0
- package/lib/zudoku.mermaid.js.map +1 -0
- package/lib/zudoku.plugin-api-catalog.js +42 -37
- package/lib/zudoku.plugin-api-catalog.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +617 -550
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +3 -3
- package/lib/zudoku.plugin-redirect.js +1 -1
- package/lib/zudoku.plugin-search-pagefind.js +186 -226
- package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
- package/lib/zudoku.plugins.js +9 -8
- package/lib/zudoku.plugins.js.map +1 -1
- package/lib/zudoku.react-query.js +441 -0
- package/lib/zudoku.react-query.js.map +1 -0
- package/lib/zudoku.router.js +1130 -1404
- package/lib/zudoku.router.js.map +1 -1
- package/package.json +63 -37
- package/src/app/defaultTheme.css +4 -0
- package/src/app/main.css +2 -0
- package/src/app/main.tsx +1 -1
- package/src/app/sentry.ts +1 -1
- package/src/lib/auth/issuer.ts +1 -1
- package/src/lib/authentication/authentication.ts +8 -2
- package/src/lib/authentication/components/CallbackHandler.tsx +1 -1
- package/src/lib/authentication/components/SignIn.tsx +5 -2
- package/src/lib/authentication/components/SignUp.tsx +5 -2
- package/src/lib/authentication/hook.ts +16 -0
- package/src/lib/authentication/providers/auth0.tsx +21 -10
- package/src/lib/authentication/providers/clerk.tsx +0 -26
- package/src/lib/authentication/providers/firebase.tsx +98 -6
- package/src/lib/authentication/providers/supabase.tsx +6 -15
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +129 -0
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +181 -39
- package/src/lib/authentication/utils/relativeRedirectUrl.ts +12 -0
- package/src/lib/components/Bootstrap.tsx +1 -4
- package/src/lib/components/Mermaid.tsx +68 -0
- package/src/lib/components/MobileTopNavigation.tsx +16 -9
- package/src/lib/components/PagefindSearchMeta.tsx +14 -0
- package/src/lib/components/Pagination.tsx +4 -5
- package/src/lib/components/Slot.test.tsx +1 -1
- package/src/lib/components/TopNavigation.tsx +26 -8
- package/src/lib/components/Zudoku.tsx +22 -21
- package/src/lib/components/context/ZudokuContext.ts +33 -12
- package/src/lib/components/context/ZudokuProvider.tsx +1 -1
- package/src/lib/components/context/ZudokuReactContext.tsx +17 -0
- package/src/lib/components/index.ts +19 -35
- package/src/lib/components/navigation/Navigation.tsx +4 -3
- package/src/lib/components/navigation/NavigationCategory.tsx +9 -0
- package/src/lib/components/navigation/NavigationFilterContext.tsx +28 -0
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -0
- package/src/lib/components/navigation/NavigationItem.tsx +26 -4
- package/src/lib/components/navigation/NavigationWrapper.tsx +1 -1
- package/src/lib/components/navigation/utils.ts +44 -2
- package/src/lib/core/RouteGuard.tsx +30 -24
- package/src/lib/core/ZudokuContext.ts +7 -1
- package/src/lib/core/__internal.tsx +2 -0
- package/src/lib/core/plugins.ts +27 -3
- package/src/lib/core/react-query.ts +1 -0
- package/src/lib/core/transform-config.test.tsx +99 -0
- package/src/lib/core/transform-config.ts +67 -0
- package/src/lib/errors/ErrorAlert.tsx +1 -6
- package/src/lib/errors/ErrorMessage.tsx +38 -0
- package/src/lib/hooks/index.ts +7 -16
- package/src/lib/hooks/useEvent.test.tsx +1 -1
- package/src/lib/navigation/pathMatcher.test.ts +136 -0
- package/src/lib/navigation/pathMatcher.ts +93 -0
- package/src/lib/navigation/positionItems.test.ts +265 -0
- package/src/lib/navigation/positionItems.ts +111 -0
- package/src/lib/oas/graphql/circular.test.ts +221 -0
- package/src/lib/oas/graphql/circular.ts +31 -18
- package/src/lib/oas/graphql/index.ts +7 -3
- package/src/lib/oas/parser/index.ts +19 -6
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +36 -476
- package/src/lib/plugins/api-keys/index.tsx +76 -32
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -0
- package/src/lib/plugins/api-keys/settings/ApiKeyList.tsx +67 -0
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +124 -0
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +115 -0
- package/src/lib/plugins/openapi/Endpoint.tsx +20 -27
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +1 -1
- package/src/lib/plugins/openapi/OasProvider.tsx +38 -17
- package/src/lib/plugins/openapi/OperationList.tsx +48 -28
- package/src/lib/plugins/openapi/OperationListItem.tsx +5 -5
- package/src/lib/plugins/openapi/ParamInfos.tsx +1 -0
- package/src/lib/plugins/openapi/ParameterList.tsx +2 -2
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +37 -15
- package/src/lib/plugins/openapi/SchemaList.tsx +4 -0
- package/src/lib/plugins/openapi/Sidecar.tsx +20 -3
- package/src/lib/plugins/openapi/index.tsx +16 -7
- package/src/lib/plugins/openapi/interfaces.ts +21 -7
- package/src/lib/plugins/openapi/playground/Playground.tsx +8 -4
- package/src/lib/plugins/openapi/playground/fileUtils.ts +4 -0
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -0
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +33 -17
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +56 -43
- package/src/lib/plugins/openapi/schema/utils.ts +20 -6
- package/src/lib/plugins/openapi/util/createHttpSnippet.ts +29 -1
- package/src/lib/plugins/openapi/util/getRoutes.tsx +38 -3
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +163 -0
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +61 -22
- package/src/lib/plugins/search-pagefind/ResultList.tsx +8 -3
- package/src/lib/shiki.ts +21 -12
- package/src/lib/ui/Alert.tsx +17 -5
- package/src/lib/ui/Button.tsx +11 -10
- package/src/lib/ui/ButtonGroup.tsx +82 -0
- package/src/lib/ui/Command.tsx +3 -3
- package/src/lib/ui/DropdownMenu.tsx +226 -170
- package/src/lib/ui/InputGroup.tsx +168 -0
- package/src/lib/ui/Kbd.tsx +28 -0
- package/src/lib/ui/Secret.tsx +2 -2
- package/src/lib/util/MdxComponents.tsx +2 -0
- package/src/lib/util/flattenAllOf.test.ts +73 -20
- package/src/lib/util/flattenAllOf.ts +0 -36
- package/src/lib/util/flattenAllOfProcessor.ts +58 -0
- package/src/lib/util/invariant.ts +2 -1
- package/src/lib/util/readFrontmatter.ts +14 -0
- package/src/shiki/langs/c3.js +1 -0
- package/src/shiki/langs/gn.js +1 -0
- package/src/shiki/langs/markdown-nix.js +1 -0
- package/src/shiki/langs/moonbit.js +1 -0
- package/src/shiki/langs/openscad.js +1 -0
- package/src/zuplo/enrich-with-zuplo-mcp.ts +168 -0
- package/src/zuplo/enrich-with-zuplo.ts +254 -0
- package/src/zuplo/policy-types.ts +46 -0
- package/src/zuplo/with-zuplo-processors.ts +35 -0
- package/src/zuplo/with-zuplo.ts +14 -0
- package/dist/vite/create-pagefind-index.d.ts +0 -4
- package/dist/vite/create-pagefind-index.js +0 -12
- package/dist/vite/create-pagefind-index.js.map +0 -1
- package/lib/Button-B3ucvvQw.js +0 -52
- package/lib/Button-B3ucvvQw.js.map +0 -1
- package/lib/Command-CUcrW3qs.js.map +0 -1
- package/lib/DropdownMenu-BZ2NKQ3K.js +0 -126
- package/lib/DropdownMenu-BZ2NKQ3K.js.map +0 -1
- package/lib/ErrorAlert-_1Zmhr68.js.map +0 -1
- package/lib/MdxPage-B2t1EShN.js +0 -240
- package/lib/MdxPage-B2t1EShN.js.map +0 -1
- package/lib/OAuthErrorPage-DnKnq4xK.js.map +0 -1
- package/lib/OasProvider-BhuIkD4Z.js +0 -36
- package/lib/OasProvider-BhuIkD4Z.js.map +0 -1
- package/lib/OperationList-D8EDc9v7.js.map +0 -1
- package/lib/Pagination-hk-llhpw.js +0 -37
- package/lib/Pagination-hk-llhpw.js.map +0 -1
- package/lib/RouteGuard-Brz95MSt.js +0 -77
- package/lib/RouteGuard-Brz95MSt.js.map +0 -1
- package/lib/RouterError-CMaIfdjb.js +0 -42
- package/lib/RouterError-CMaIfdjb.js.map +0 -1
- package/lib/SchemaList-E6lF7dID.js.map +0 -1
- package/lib/SchemaView-CIv-OXgv.js +0 -572
- package/lib/SchemaView-CIv-OXgv.js.map +0 -1
- package/lib/Select-DFRCS31-.js +0 -399
- package/lib/Select-DFRCS31-.js.map +0 -1
- package/lib/SignUp-sGYAsj2K.js +0 -50
- package/lib/SignUp-sGYAsj2K.js.map +0 -1
- package/lib/SyntaxHighlight-C19vH0V_.js.map +0 -1
- package/lib/ZudokuContext-BUZ5hkWB.js +0 -1508
- package/lib/ZudokuContext-BUZ5hkWB.js.map +0 -1
- package/lib/chunk-PVWAREVJ-BMhpCH5D.js +0 -7965
- package/lib/chunk-PVWAREVJ-BMhpCH5D.js.map +0 -1
- package/lib/circular-BoYo7au5.js.map +0 -1
- package/lib/cn-dYga0KKN.js.map +0 -1
- package/lib/createServer-B_BZ7xX8.js.map +0 -1
- package/lib/hook-CMeoxziF.js +0 -40
- package/lib/hook-CMeoxziF.js.map +0 -1
- package/lib/index-HNVs5cgX.js.map +0 -1
- package/lib/index-pMMX55GH.js +0 -1059
- package/lib/index-pMMX55GH.js.map +0 -1
- package/lib/invariant-Bm-FVUQE.js.map +0 -1
- package/lib/mutation-BSU0xu4m.js.map +0 -1
- package/lib/useExposedProps-U3pmsHaG.js +0 -113
- package/lib/useExposedProps-U3pmsHaG.js.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { NavigationItem } from "../../config/validators/NavigationSchema.js";
|
|
3
|
+
import { findByPath } from "./pathMatcher.js";
|
|
4
|
+
|
|
5
|
+
const mockNavigation: NavigationItem[] = [
|
|
6
|
+
{
|
|
7
|
+
type: "category",
|
|
8
|
+
label: "Shipments",
|
|
9
|
+
items: [
|
|
10
|
+
{ type: "link", label: "Track a Shipment", to: "/track" },
|
|
11
|
+
{ type: "link", label: "Create Shipment", to: "/create" },
|
|
12
|
+
{
|
|
13
|
+
type: "category",
|
|
14
|
+
label: "Nested Category",
|
|
15
|
+
items: [
|
|
16
|
+
{ type: "link", label: "First Nested", to: "/nested/first" },
|
|
17
|
+
{ type: "link", label: "Second Nested", to: "/nested/second" },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{ type: "link", label: "About", to: "/about" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
describe("pathMatcher", () => {
|
|
26
|
+
describe("findByPath", () => {
|
|
27
|
+
it("should find item by label", () => {
|
|
28
|
+
const result = findByPath(mockNavigation, "Shipments");
|
|
29
|
+
expect(result.found).toBe(true);
|
|
30
|
+
expect(result.item?.label).toBe("Shipments");
|
|
31
|
+
expect(result.index).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should find nested item by label path", () => {
|
|
35
|
+
const result = findByPath(mockNavigation, "Shipments/Track a Shipment");
|
|
36
|
+
expect(result.found).toBe(true);
|
|
37
|
+
expect(result.item?.label).toBe("Track a Shipment");
|
|
38
|
+
expect(result.index).toBe(0);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should find item by index", () => {
|
|
42
|
+
const result = findByPath(mockNavigation, "Shipments/0");
|
|
43
|
+
expect(result.found).toBe(true);
|
|
44
|
+
expect(result.item?.label).toBe("Track a Shipment");
|
|
45
|
+
expect(result.index).toBe(0);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should find nested item by mixed path (label + index)", () => {
|
|
49
|
+
const result = findByPath(mockNavigation, "Shipments/2/0");
|
|
50
|
+
expect(result.found).toBe(true);
|
|
51
|
+
expect(result.item?.label).toBe("First Nested");
|
|
52
|
+
expect(result.index).toBe(0);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should be case-insensitive for label matching", () => {
|
|
56
|
+
const result = findByPath(mockNavigation, "shipments/track a shipment");
|
|
57
|
+
expect(result.found).toBe(true);
|
|
58
|
+
expect(result.item?.label).toBe("Track a Shipment");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should find deeply nested items", () => {
|
|
62
|
+
const result = findByPath(
|
|
63
|
+
mockNavigation,
|
|
64
|
+
"Shipments/Nested Category/Second Nested",
|
|
65
|
+
);
|
|
66
|
+
expect(result.found).toBe(true);
|
|
67
|
+
expect(result.item?.label).toBe("Second Nested");
|
|
68
|
+
expect(result.index).toBe(1);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should return found=false for non-existent path", () => {
|
|
72
|
+
const result = findByPath(mockNavigation, "Nonexistent/Path");
|
|
73
|
+
expect(result.found).toBe(false);
|
|
74
|
+
expect(result.item).toBeUndefined();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should return found=false for invalid index", () => {
|
|
78
|
+
const result = findByPath(mockNavigation, "Shipments/999");
|
|
79
|
+
expect(result.found).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should handle root-level items", () => {
|
|
83
|
+
const result = findByPath(mockNavigation, "About");
|
|
84
|
+
expect(result.found).toBe(true);
|
|
85
|
+
expect(result.item?.label).toBe("About");
|
|
86
|
+
expect(result.index).toBe(1);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("should provide parentItems for inserting siblings", () => {
|
|
90
|
+
const result = findByPath(mockNavigation, "Shipments/0");
|
|
91
|
+
expect(result.parentItems).toBeDefined();
|
|
92
|
+
expect(result.parentItems?.length).toBe(3); // 2 links + 1 category
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should handle empty path", () => {
|
|
96
|
+
const result = findByPath(mockNavigation, "");
|
|
97
|
+
expect(result.found).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("should support negative indices (-1 for last item)", () => {
|
|
101
|
+
const result = findByPath(mockNavigation, "Shipments/-1");
|
|
102
|
+
expect(result.found).toBe(true);
|
|
103
|
+
expect(result.item?.label).toBe("Nested Category");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should support negative indices (-2 for second-to-last)", () => {
|
|
107
|
+
const result = findByPath(mockNavigation, "Shipments/-2");
|
|
108
|
+
expect(result.found).toBe(true);
|
|
109
|
+
expect(result.item?.label).toBe("Create Shipment");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("should support negative indices in nested paths", () => {
|
|
113
|
+
const result = findByPath(mockNavigation, "Shipments/-1/-1");
|
|
114
|
+
expect(result.found).toBe(true);
|
|
115
|
+
expect(result.item?.label).toBe("Second Nested");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("should handle paths with trailing slashes", () => {
|
|
119
|
+
const result = findByPath(mockNavigation, "Shipments/0/");
|
|
120
|
+
expect(result.found).toBe(true);
|
|
121
|
+
expect(result.item?.label).toBe("Track a Shipment");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should handle paths with double slashes", () => {
|
|
125
|
+
const result = findByPath(mockNavigation, "Shipments//0");
|
|
126
|
+
expect(result.found).toBe(true);
|
|
127
|
+
expect(result.item?.label).toBe("Track a Shipment");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should handle paths with leading slashes", () => {
|
|
131
|
+
const result = findByPath(mockNavigation, "/Shipments/0");
|
|
132
|
+
expect(result.found).toBe(true);
|
|
133
|
+
expect(result.item?.label).toBe("Track a Shipment");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { NavigationItem } from "../../config/validators/NavigationSchema.js";
|
|
2
|
+
|
|
3
|
+
type PathSegment = string | number;
|
|
4
|
+
|
|
5
|
+
export type PathMatchResult = {
|
|
6
|
+
found: boolean;
|
|
7
|
+
item?: NavigationItem;
|
|
8
|
+
parentItems?: NavigationItem[];
|
|
9
|
+
index?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const parsePath = (path: string): PathSegment[] => {
|
|
13
|
+
if (!path || path === "/") return [];
|
|
14
|
+
|
|
15
|
+
return path
|
|
16
|
+
.split("/")
|
|
17
|
+
.filter((segment) => segment !== "")
|
|
18
|
+
.map((segment) => {
|
|
19
|
+
const num = Number(segment);
|
|
20
|
+
return Number.isInteger(num) ? num : segment;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const matchesSegment = (
|
|
25
|
+
segment: PathSegment,
|
|
26
|
+
item: NavigationItem,
|
|
27
|
+
index: number,
|
|
28
|
+
arrayLength: number,
|
|
29
|
+
): boolean => {
|
|
30
|
+
if (typeof segment === "number") {
|
|
31
|
+
// Support negative indices (-1 for last, -2 for second-to-last, etc.)
|
|
32
|
+
const normalizedIndex = segment < 0 ? arrayLength + segment : segment;
|
|
33
|
+
return normalizedIndex === index;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return item.label?.toLowerCase() === segment.toLowerCase();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const findByPath = (
|
|
40
|
+
navigation: NavigationItem[],
|
|
41
|
+
pathString: string,
|
|
42
|
+
): PathMatchResult => {
|
|
43
|
+
const segments = parsePath(pathString);
|
|
44
|
+
|
|
45
|
+
if (segments.length === 0) {
|
|
46
|
+
return { found: false };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let currentItems = navigation;
|
|
50
|
+
let currentItem: NavigationItem | undefined;
|
|
51
|
+
let parentItems: NavigationItem[] | undefined;
|
|
52
|
+
let itemIndex: number | undefined;
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < segments.length; i++) {
|
|
55
|
+
const segment = segments[i];
|
|
56
|
+
if (segment === undefined) {
|
|
57
|
+
return { found: false };
|
|
58
|
+
}
|
|
59
|
+
const isLastSegment = i === segments.length - 1;
|
|
60
|
+
|
|
61
|
+
const foundIndex = currentItems.findIndex((item, idx) =>
|
|
62
|
+
matchesSegment(segment, item, idx, currentItems.length),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (foundIndex === -1) {
|
|
66
|
+
return { found: false };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
currentItem = currentItems[foundIndex];
|
|
70
|
+
if (!currentItem) {
|
|
71
|
+
return { found: false };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (isLastSegment) {
|
|
75
|
+
parentItems = currentItems;
|
|
76
|
+
itemIndex = foundIndex;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (currentItem.type === "category") {
|
|
81
|
+
currentItems = currentItem.items;
|
|
82
|
+
} else {
|
|
83
|
+
return { found: false };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
found: true,
|
|
89
|
+
item: currentItem,
|
|
90
|
+
parentItems,
|
|
91
|
+
index: itemIndex,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type { AtPosition } from "../../config/validators/InputNavigationSchema.js";
|
|
3
|
+
import type { NavigationItem } from "../../config/validators/NavigationSchema.js";
|
|
4
|
+
import { repositionItems } from "./positionItems.js";
|
|
5
|
+
|
|
6
|
+
type NavigationItemWithAt = NavigationItem & { at?: AtPosition };
|
|
7
|
+
|
|
8
|
+
describe("positionItems", () => {
|
|
9
|
+
it("should return navigation unchanged if no items have `at` property", () => {
|
|
10
|
+
const navigation: NavigationItem[] = [
|
|
11
|
+
{ type: "link", label: "Home", to: "/" },
|
|
12
|
+
{ type: "link", label: "About", to: "/about" },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const result = repositionItems(navigation);
|
|
16
|
+
expect(result).toEqual(navigation);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should position item with 'before' relative to target", () => {
|
|
20
|
+
const navigation: NavigationItemWithAt[] = [
|
|
21
|
+
{
|
|
22
|
+
type: "category",
|
|
23
|
+
label: "Docs",
|
|
24
|
+
items: [
|
|
25
|
+
{ type: "link", label: "First", to: "/first" },
|
|
26
|
+
{ type: "link", label: "Second", to: "/second" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "link",
|
|
31
|
+
label: "Inserted",
|
|
32
|
+
to: "/inserted",
|
|
33
|
+
at: { path: "Docs/Second", position: "before" },
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const result = repositionItems(navigation);
|
|
38
|
+
const docsCategory = result[0];
|
|
39
|
+
|
|
40
|
+
expect(docsCategory).toBeDefined();
|
|
41
|
+
expect(docsCategory?.type).toBe("category");
|
|
42
|
+
if (docsCategory?.type === "category") {
|
|
43
|
+
expect(docsCategory.items[0]?.label).toBe("First");
|
|
44
|
+
expect(docsCategory.items[1]?.label).toBe("Inserted");
|
|
45
|
+
expect(docsCategory.items[2]?.label).toBe("Second");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("should position item with 'after' relative to target", () => {
|
|
50
|
+
const navigation: NavigationItemWithAt[] = [
|
|
51
|
+
{
|
|
52
|
+
type: "category",
|
|
53
|
+
label: "Docs",
|
|
54
|
+
items: [
|
|
55
|
+
{ type: "link", label: "First", to: "/first" },
|
|
56
|
+
{ type: "link", label: "Second", to: "/second" },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "link",
|
|
61
|
+
label: "Inserted",
|
|
62
|
+
to: "/inserted",
|
|
63
|
+
at: { path: "Docs/First", position: "after" },
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const result = repositionItems(navigation);
|
|
68
|
+
const docsCategory = result[0];
|
|
69
|
+
|
|
70
|
+
expect(docsCategory).toBeDefined();
|
|
71
|
+
expect(docsCategory?.type).toBe("category");
|
|
72
|
+
if (docsCategory?.type === "category") {
|
|
73
|
+
expect(docsCategory.items[0]?.label).toBe("First");
|
|
74
|
+
expect(docsCategory.items[1]?.label).toBe("Inserted");
|
|
75
|
+
expect(docsCategory.items[2]?.label).toBe("Second");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should handle multiple items with `at` property", () => {
|
|
80
|
+
const navigation: NavigationItemWithAt[] = [
|
|
81
|
+
{
|
|
82
|
+
type: "category",
|
|
83
|
+
label: "API",
|
|
84
|
+
items: [{ type: "link", label: "Original", to: "/original" }],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "link",
|
|
88
|
+
label: "First",
|
|
89
|
+
to: "/first",
|
|
90
|
+
at: { path: "API/Original", position: "before" },
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "link",
|
|
94
|
+
label: "Last",
|
|
95
|
+
to: "/last",
|
|
96
|
+
at: { path: "API/Original", position: "after" },
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
const result = repositionItems(navigation);
|
|
101
|
+
const apiCategory = result[0];
|
|
102
|
+
|
|
103
|
+
expect(apiCategory?.type).toBe("category");
|
|
104
|
+
if (apiCategory?.type === "category") {
|
|
105
|
+
expect(apiCategory?.items[0]?.label).toBe("First");
|
|
106
|
+
expect(apiCategory?.items[1]?.label).toBe("Original");
|
|
107
|
+
expect(apiCategory?.items[2]?.label).toBe("Last");
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should handle nested items with `at` property", () => {
|
|
112
|
+
const navigation: NavigationItemWithAt[] = [
|
|
113
|
+
{
|
|
114
|
+
type: "category",
|
|
115
|
+
label: "Outer",
|
|
116
|
+
items: [{ type: "link", label: "Item", to: "/item" }],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: "category",
|
|
120
|
+
label: "Inner Category",
|
|
121
|
+
at: { path: "Outer/Item", position: "after" },
|
|
122
|
+
items: [
|
|
123
|
+
{
|
|
124
|
+
type: "link",
|
|
125
|
+
label: "Nested",
|
|
126
|
+
to: "/nested",
|
|
127
|
+
at: { path: "Outer/Item", position: "after" },
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
const result = repositionItems(navigation);
|
|
134
|
+
const outerCategory = result[0];
|
|
135
|
+
|
|
136
|
+
expect(outerCategory).toBeDefined();
|
|
137
|
+
expect(outerCategory?.type).toBe("category");
|
|
138
|
+
if (outerCategory?.type === "category") {
|
|
139
|
+
// Both items positioned after Item
|
|
140
|
+
expect(outerCategory?.items.length).toBe(3);
|
|
141
|
+
expect(outerCategory?.items[0]?.label).toBe("Item");
|
|
142
|
+
expect(outerCategory?.items[1]?.label).toBe("Nested");
|
|
143
|
+
expect(outerCategory?.items[2]?.label).toBe("Inner Category");
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("should keep item at root if target path not found", () => {
|
|
148
|
+
const consoleWarnSpy = vi
|
|
149
|
+
.spyOn(console, "warn")
|
|
150
|
+
.mockImplementation(() => {});
|
|
151
|
+
|
|
152
|
+
const navigation: NavigationItemWithAt[] = [
|
|
153
|
+
{ type: "link", label: "Home", to: "/" },
|
|
154
|
+
{
|
|
155
|
+
type: "link",
|
|
156
|
+
label: "Orphan",
|
|
157
|
+
to: "/orphan",
|
|
158
|
+
at: { path: "Nonexistent/Path", position: "before" },
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
const result = repositionItems(navigation);
|
|
163
|
+
|
|
164
|
+
expect(result.length).toBe(2);
|
|
165
|
+
expect(result[1]?.label).toBe("Orphan");
|
|
166
|
+
expect("at" in (result[1] ?? {})).toBe(false);
|
|
167
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
168
|
+
expect.stringContaining('target path "Nonexistent/Path" not found'),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
consoleWarnSpy.mockRestore();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should remove `at` property from positioned items", () => {
|
|
175
|
+
const navigation: NavigationItemWithAt[] = [
|
|
176
|
+
{ type: "link", label: "Target", to: "/target" },
|
|
177
|
+
{
|
|
178
|
+
type: "link",
|
|
179
|
+
label: "Item",
|
|
180
|
+
to: "/item",
|
|
181
|
+
at: { path: "Target", position: "before" },
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
const result = repositionItems(navigation);
|
|
186
|
+
|
|
187
|
+
result.forEach((item) => {
|
|
188
|
+
expect("at" in item).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("should handle positioning by index", () => {
|
|
193
|
+
const navigation: NavigationItemWithAt[] = [
|
|
194
|
+
{
|
|
195
|
+
type: "category",
|
|
196
|
+
label: "Shipments",
|
|
197
|
+
items: [
|
|
198
|
+
{ type: "link", label: "Op1", to: "/op1" },
|
|
199
|
+
{ type: "link", label: "Op2", to: "/op2" },
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: "doc",
|
|
204
|
+
file: "overview",
|
|
205
|
+
label: "Overview",
|
|
206
|
+
path: "/overview",
|
|
207
|
+
at: { path: "Shipments/0", position: "before" },
|
|
208
|
+
},
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
const result = repositionItems(navigation);
|
|
212
|
+
const shipmentsCategory = result[0];
|
|
213
|
+
|
|
214
|
+
expect(shipmentsCategory).toBeDefined();
|
|
215
|
+
expect(shipmentsCategory?.type).toBe("category");
|
|
216
|
+
if (shipmentsCategory?.type === "category") {
|
|
217
|
+
expect(shipmentsCategory.items[0]?.label).toBe("Overview");
|
|
218
|
+
expect(shipmentsCategory?.items[1]?.label).toBe("Op1");
|
|
219
|
+
expect(shipmentsCategory?.items[2]?.label).toBe("Op2");
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("should not share nested array references between failed and successful insertions", () => {
|
|
224
|
+
const consoleWarnSpy = vi
|
|
225
|
+
.spyOn(console, "warn")
|
|
226
|
+
.mockImplementation(() => {});
|
|
227
|
+
|
|
228
|
+
const navigation: NavigationItemWithAt[] = [
|
|
229
|
+
{
|
|
230
|
+
type: "category",
|
|
231
|
+
label: "Cat1",
|
|
232
|
+
items: [{ type: "link", label: "Original", to: "/original" }],
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
type: "link",
|
|
236
|
+
label: "BadTarget",
|
|
237
|
+
to: "/bad",
|
|
238
|
+
at: { path: "Nonexistent/Path", position: "before" },
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
type: "link",
|
|
242
|
+
label: "GoodTarget",
|
|
243
|
+
to: "/good",
|
|
244
|
+
at: { path: "Cat1/Original", position: "before" },
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
|
|
248
|
+
const result = repositionItems(navigation);
|
|
249
|
+
|
|
250
|
+
// Verify BadTarget is at root level (failed positioning)
|
|
251
|
+
expect(result.length).toBe(2);
|
|
252
|
+
expect(result[1]?.label).toBe("BadTarget");
|
|
253
|
+
|
|
254
|
+
// Verify GoodTarget was inserted correctly into Cat1
|
|
255
|
+
const cat1 = result[0];
|
|
256
|
+
expect(cat1?.type).toBe("category");
|
|
257
|
+
if (cat1?.type === "category") {
|
|
258
|
+
expect(cat1.items.length).toBe(2);
|
|
259
|
+
expect(cat1.items[0]?.label).toBe("GoodTarget");
|
|
260
|
+
expect(cat1.items[1]?.label).toBe("Original");
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
consoleWarnSpy.mockRestore();
|
|
264
|
+
});
|
|
265
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { AtPosition } from "../../config/validators/InputNavigationSchema.js";
|
|
2
|
+
import type {
|
|
3
|
+
NavigationCategory,
|
|
4
|
+
NavigationCustomPage,
|
|
5
|
+
NavigationDoc,
|
|
6
|
+
NavigationItem,
|
|
7
|
+
NavigationLink,
|
|
8
|
+
} from "../../config/validators/NavigationSchema.js";
|
|
9
|
+
import { findByPath } from "./pathMatcher.js";
|
|
10
|
+
|
|
11
|
+
type PositionedItem = (
|
|
12
|
+
| NavigationDoc
|
|
13
|
+
| NavigationLink
|
|
14
|
+
| NavigationCustomPage
|
|
15
|
+
| NavigationCategory
|
|
16
|
+
) & { at: AtPosition };
|
|
17
|
+
|
|
18
|
+
export const isPositionedItem = (
|
|
19
|
+
item: NavigationItem,
|
|
20
|
+
): item is PositionedItem => "at" in item && item.at !== undefined;
|
|
21
|
+
|
|
22
|
+
const cloneWithoutPositioned = (items: NavigationItem[]): NavigationItem[] =>
|
|
23
|
+
items.flatMap<NavigationItem>((item) =>
|
|
24
|
+
isPositionedItem(item)
|
|
25
|
+
? []
|
|
26
|
+
: item.type === "category"
|
|
27
|
+
? { ...item, items: cloneWithoutPositioned(item.items) }
|
|
28
|
+
: { ...item },
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const extractPositionedItems = (
|
|
32
|
+
navigation: NavigationItem[],
|
|
33
|
+
): PositionedItem[] => {
|
|
34
|
+
return navigation.flatMap((item) => {
|
|
35
|
+
const nested =
|
|
36
|
+
item.type === "category" ? extractPositionedItems(item.items) : [];
|
|
37
|
+
|
|
38
|
+
return isPositionedItem(item) ? [item, ...nested] : nested;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const removeAt = ({ at: _at, ...item }: PositionedItem): NavigationItem => item;
|
|
43
|
+
|
|
44
|
+
const insertItem = (
|
|
45
|
+
navigation: NavigationItem[],
|
|
46
|
+
item: PositionedItem,
|
|
47
|
+
): NavigationItem[] => {
|
|
48
|
+
const match = findByPath(navigation, item.at.path);
|
|
49
|
+
|
|
50
|
+
if (!match.found || !match.parentItems || match.index === undefined) {
|
|
51
|
+
// biome-ignore lint/suspicious/noConsole: Intentional warning for positioning debug
|
|
52
|
+
console.warn(
|
|
53
|
+
`Navigation positioning: target path "${item.at.path}" not found, keeping item in place`,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return [...navigation, removeAt(item)];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const insertIndex =
|
|
60
|
+
item.at.position === "before" ? match.index : match.index + 1;
|
|
61
|
+
|
|
62
|
+
match.parentItems.splice(insertIndex, 0, removeAt(item));
|
|
63
|
+
|
|
64
|
+
return navigation;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const repositionItems = (
|
|
68
|
+
navigation: NavigationItem[],
|
|
69
|
+
): NavigationItem[] => {
|
|
70
|
+
const itemsToPosition = extractPositionedItems(navigation);
|
|
71
|
+
|
|
72
|
+
if (itemsToPosition.length === 0) return navigation;
|
|
73
|
+
|
|
74
|
+
return itemsToPosition.reduce(
|
|
75
|
+
(result, item) => insertItem(result, item),
|
|
76
|
+
cloneWithoutPositioned(navigation),
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Filter and normalize positioned items for the current section
|
|
81
|
+
// Only keeps items whose paths start with topNavLabel, then strips that prefix
|
|
82
|
+
const filterAndNormalizePaths = (
|
|
83
|
+
items: PositionedItem[],
|
|
84
|
+
topNavLabel?: string,
|
|
85
|
+
): PositionedItem[] => {
|
|
86
|
+
if (!topNavLabel) return [];
|
|
87
|
+
|
|
88
|
+
const normalizedLabel = topNavLabel.toLowerCase();
|
|
89
|
+
|
|
90
|
+
return items.flatMap((item) => {
|
|
91
|
+
const [firstSegment, ...rest] = item.at.path.split("/");
|
|
92
|
+
if (firstSegment?.toLowerCase() === normalizedLabel) {
|
|
93
|
+
return { ...item, at: { ...item.at, path: rest.join("/") } };
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Merge positioned items from rootNavigation into baseNavigation
|
|
100
|
+
// Normalizes paths to handle top-level category nesting
|
|
101
|
+
export const mergePositionedItems = (
|
|
102
|
+
baseNavigation: NavigationItem[],
|
|
103
|
+
rootNavigation: NavigationItem[],
|
|
104
|
+
topNavLabel?: string,
|
|
105
|
+
): NavigationItem[] => {
|
|
106
|
+
const itemsToPosition = extractPositionedItems(rootNavigation);
|
|
107
|
+
const normalizedItems = filterAndNormalizePaths(itemsToPosition, topNavLabel);
|
|
108
|
+
const combined = [...baseNavigation, ...normalizedItems];
|
|
109
|
+
|
|
110
|
+
return repositionItems(combined);
|
|
111
|
+
};
|