@origen-ui/admin-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/bin/og-admin.mjs +131 -0
- package/package.json +28 -0
- package/templates/current/clean/.codebuddy/AGENTS.md +18 -0
- package/templates/current/clean/.codebuddy/rules/01-feature-architecture.md +12 -0
- package/templates/current/clean/.codebuddy/rules/02-vue-typescript.md +12 -0
- package/templates/current/clean/.codebuddy/rules/03-component-policy.md +30 -0
- package/templates/current/clean/.codebuddy/rules/04-api-auth-router.md +12 -0
- package/templates/current/clean/.codebuddy/rules/05-style.md +12 -0
- package/templates/current/clean/.codebuddy/rules/06-quality.md +12 -0
- package/templates/current/clean/.codebuddy/skills/build-admin-feature/SKILL.md +17 -0
- package/templates/current/clean/.codebuddy/skills/style-og-origen-ui/SKILL.md +14 -0
- package/templates/current/clean/.codebuddy/skills/use-og-dialog/SKILL.md +15 -0
- package/templates/current/clean/.codebuddy/skills/use-og-editor/SKILL.md +28 -0
- package/templates/current/clean/.codebuddy/skills/use-og-form/SKILL.md +15 -0
- package/templates/current/clean/.codebuddy/skills/use-og-form-table/SKILL.md +28 -0
- package/templates/current/clean/.codebuddy/skills/use-og-http/SKILL.md +16 -0
- package/templates/current/clean/.codebuddy/skills/use-og-router-tabs/SKILL.md +14 -0
- package/templates/current/clean/.codebuddy/skills/use-og-search/SKILL.md +17 -0
- package/templates/current/clean/.codebuddy/skills/use-og-table/SKILL.md +19 -0
- package/templates/current/clean/.codebuddy/skills/use-og-upload/SKILL.md +28 -0
- package/templates/current/clean/.codex/AGENTS.md +15 -0
- package/templates/current/clean/.codex/rules/01-feature-architecture.md +6 -0
- package/templates/current/clean/.codex/rules/02-vue-typescript.md +6 -0
- package/templates/current/clean/.codex/rules/03-component-policy.md +24 -0
- package/templates/current/clean/.codex/rules/04-api-auth-router.md +6 -0
- package/templates/current/clean/.codex/rules/05-style.md +6 -0
- package/templates/current/clean/.codex/rules/06-quality.md +6 -0
- package/templates/current/clean/.codex/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/clean/.codex/skills/build-admin-feature/references/component-selection.md +25 -0
- package/templates/current/clean/.codex/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/clean/.codex/skills/style-og-origen-ui/agents/openai.yaml +4 -0
- package/templates/current/clean/.codex/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/clean/.codex/skills/use-og-dialog/agents/openai.yaml +4 -0
- package/templates/current/clean/.codex/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/clean/.codex/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/clean/.codex/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/clean/.codex/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/clean/.codex/skills/use-og-http/agents/openai.yaml +4 -0
- package/templates/current/clean/.codex/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/clean/.codex/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/clean/.codex/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/clean/.codex/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/clean/.cursor/AGENTS.md +18 -0
- package/templates/current/clean/.cursor/rules/01-feature-architecture.mdc +12 -0
- package/templates/current/clean/.cursor/rules/02-vue-typescript.mdc +12 -0
- package/templates/current/clean/.cursor/rules/03-component-policy.mdc +30 -0
- package/templates/current/clean/.cursor/rules/04-api-auth-router.mdc +12 -0
- package/templates/current/clean/.cursor/rules/05-style.mdc +12 -0
- package/templates/current/clean/.cursor/rules/06-quality.mdc +12 -0
- package/templates/current/clean/.cursor/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/clean/.cursor/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/clean/.cursor/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/clean/.cursor/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/clean/.cursor/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/clean/.cursor/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/clean/.cursor/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/clean/.cursor/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/clean/.cursor/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/clean/.cursor/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/clean/.cursor/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/clean/.env.example +7 -0
- package/templates/current/clean/.env.production.example +31 -0
- package/templates/current/clean/.qoder/AGENTS.md +15 -0
- package/templates/current/clean/.qoder/rules/01-feature-architecture.md +12 -0
- package/templates/current/clean/.qoder/rules/02-vue-typescript.md +12 -0
- package/templates/current/clean/.qoder/rules/03-component-policy.md +30 -0
- package/templates/current/clean/.qoder/rules/04-api-auth-router.md +12 -0
- package/templates/current/clean/.qoder/rules/05-style.md +12 -0
- package/templates/current/clean/.qoder/rules/06-quality.md +12 -0
- package/templates/current/clean/.qoder/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/clean/.qoder/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/clean/.qoder/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/clean/.qoder/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/clean/.qoder/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/clean/.qoder/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/clean/.qoder/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/clean/.qoder/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/clean/.qoder/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/clean/.qoder/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/clean/.qoder/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/clean/AGENTS.md +16 -0
- package/templates/current/clean/README.md +116 -0
- package/templates/current/clean/component-catalog.json +765 -0
- package/templates/current/clean/e2e/admin-shell.spec.ts +150 -0
- package/templates/current/clean/e2e/demo-shell.spec.ts +328 -0
- package/templates/current/clean/evals/component-selection.json +29 -0
- package/templates/current/clean/gitignore +3 -0
- package/templates/current/clean/index.html +13 -0
- package/templates/current/clean/openapi.json +1623 -0
- package/templates/current/clean/package.json +65 -0
- package/templates/current/clean/playwright.config.ts +31 -0
- package/templates/current/clean/playwright.demo.config.ts +25 -0
- package/templates/current/clean/recipes/README.md +7 -0
- package/templates/current/clean/recipes/remote-crud-dialog-form.json +15 -0
- package/templates/current/clean/recipes/remote-crud-dialog-form.vue +66 -0
- package/templates/current/clean/scaffold.lock.json +12 -0
- package/templates/current/clean/scripts/check-admin-bundle.mjs +214 -0
- package/templates/current/clean/scripts/check-admin-scaffold.mjs +168 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/clean/scripts/clean-overlay/src/main.ts +91 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/componentRegistry.ts +25 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +47 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/staticRoutes.ts +63 -0
- package/templates/current/clean/scripts/demo-api.ts +797 -0
- package/templates/current/clean/scripts/generate-api.ts +27 -0
- package/templates/current/clean/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +38 -0
- package/templates/current/clean/scripts/remove-examples.mjs +54 -0
- package/templates/current/clean/src/App.vue +67 -0
- package/templates/current/clean/src/api/client.spec.ts +66 -0
- package/templates/current/clean/src/api/client.ts +72 -0
- package/templates/current/clean/src/api/generated/data-contracts.ts +268 -0
- package/templates/current/clean/src/api/generated/http-client.ts +266 -0
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +147 -0
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +53 -0
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +66 -0
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +171 -0
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +181 -0
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +169 -0
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +170 -0
- package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +98 -0
- package/templates/current/clean/src/api/http-adapter.spec.ts +33 -0
- package/templates/current/clean/src/api/http-adapter.ts +83 -0
- package/templates/current/clean/src/api/index.ts +41 -0
- package/templates/current/clean/src/app/createAdminUi.spec.ts +110 -0
- package/templates/current/clean/src/app/createAdminUi.ts +78 -0
- package/templates/current/clean/src/app/menu.spec.ts +255 -0
- package/templates/current/clean/src/app/menu.ts +268 -0
- package/templates/current/clean/src/app/menuTypes.ts +17 -0
- package/templates/current/clean/src/app/origenUiLocale.spec.ts +14 -0
- package/templates/current/clean/src/app/origenUiLocale.ts +65 -0
- package/templates/current/clean/src/app/permission.ts +9 -0
- package/templates/current/clean/src/app/runtimeConfig.ts +77 -0
- package/templates/current/clean/src/demo-api.spec.ts +167 -0
- package/templates/current/clean/src/env.d.ts +14 -0
- package/templates/current/clean/src/features/appearance/components/ThemePanel.vue +200 -0
- package/templates/current/clean/src/features/appearance/composables/useTheme.ts +17 -0
- package/templates/current/clean/src/features/appearance/store/theme.ts +140 -0
- package/templates/current/clean/src/features/auth/pages/Login.vue +159 -0
- package/templates/current/clean/src/features/auth/store/auth.spec.ts +131 -0
- package/templates/current/clean/src/features/auth/store/auth.ts +210 -0
- package/templates/current/clean/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/clean/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/clean/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/clean/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/clean/src/features/security/components/DevtoolsProtectionOverlay.vue +56 -0
- package/templates/current/clean/src/features/security/devtoolsProtection.spec.ts +211 -0
- package/templates/current/clean/src/features/security/devtoolsProtection.ts +242 -0
- package/templates/current/clean/src/features/shell/components/AdminWatermark.spec.ts +90 -0
- package/templates/current/clean/src/features/shell/components/AdminWatermark.vue +47 -0
- package/templates/current/clean/src/features/shell/components/RouteProgress.vue +68 -0
- package/templates/current/clean/src/features/shell/composables/useRouteProgress.spec.ts +95 -0
- package/templates/current/clean/src/features/shell/composables/useRouteProgress.ts +52 -0
- package/templates/current/clean/src/features/shell/store/sidebar.ts +55 -0
- package/templates/current/clean/src/features/system/access/api/admin-repository.ts +279 -0
- package/templates/current/clean/src/features/system/access/api/rbac.spec.ts +72 -0
- package/templates/current/clean/src/features/system/access/api/rbac.ts +272 -0
- package/templates/current/clean/src/features/system/access/composables/useAuthorizationRefresh.ts +15 -0
- package/templates/current/clean/src/features/workspace/pages/Empty.vue +18 -0
- package/templates/current/clean/src/features/workspace/pages/Profile.vue +183 -0
- package/templates/current/clean/src/layouts/AdminLayout.vue +61 -0
- package/templates/current/clean/src/layouts/BreadcrumbBar.vue +27 -0
- package/templates/current/clean/src/layouts/SideMenu.vue +119 -0
- package/templates/current/clean/src/layouts/TopBar.vue +301 -0
- package/templates/current/clean/src/layouts/WorkspaceTabs.vue +44 -0
- package/templates/current/clean/src/layouts/topBarMenuSearch.spec.ts +31 -0
- package/templates/current/clean/src/layouts/topBarMenuSearch.ts +21 -0
- package/templates/current/clean/src/locales/en-US.ts +55 -0
- package/templates/current/clean/src/locales/index.ts +119 -0
- package/templates/current/clean/src/locales/messages.spec.ts +23 -0
- package/templates/current/clean/src/locales/zh-CN.ts +55 -0
- package/templates/current/clean/src/locales/zh-TW.ts +44 -0
- package/templates/current/clean/src/main.ts +91 -0
- package/templates/current/clean/src/router/bootstrap.ts +76 -0
- package/templates/current/clean/src/router/componentRegistry.ts +25 -0
- package/templates/current/clean/src/router/dynamicRoutes.spec.ts +47 -0
- package/templates/current/clean/src/router/dynamicRoutes.ts +162 -0
- package/templates/current/clean/src/router/guards.ts +5 -0
- package/templates/current/clean/src/router/queryEncryption.spec.ts +82 -0
- package/templates/current/clean/src/router/queryEncryption.ts +133 -0
- package/templates/current/clean/src/router/routeQuery.spec.ts +11 -0
- package/templates/current/clean/src/router/routeQuery.ts +3 -0
- package/templates/current/clean/src/router/runtimeErrorRecovery.spec.ts +161 -0
- package/templates/current/clean/src/router/runtimeErrorRecovery.ts +108 -0
- package/templates/current/clean/src/router/staticRoutes.ts +63 -0
- package/templates/current/clean/src/router/useRouteQueryDefaults.spec.ts +90 -0
- package/templates/current/clean/src/router/useRouteQueryDefaults.ts +51 -0
- package/templates/current/clean/src/router/useRouteQueryDefaults.types.ts +19 -0
- package/templates/current/clean/src/store/index.ts +3 -0
- package/templates/current/clean/src/styles/element/index.scss +33 -0
- package/templates/current/clean/src/styles/index.css +39 -0
- package/templates/current/clean/src/styles/layout.css +115 -0
- package/templates/current/clean/src/styles/shell.css +196 -0
- package/templates/current/clean/src/styles/source-package-style-compat.css +1 -0
- package/templates/current/clean/src/templates/og-form.ts +48 -0
- package/templates/current/clean/src/templates/og-table.ts +212 -0
- package/templates/current/clean/src/templates/router.ts +51 -0
- package/templates/current/clean/src/templates/templates.spec.ts +90 -0
- package/templates/current/clean/src/theme/index.ts +7 -0
- package/templates/current/clean/src/utils/__tests__/color-mix.spec.ts +39 -0
- package/templates/current/clean/src/utils/color-mix.ts +76 -0
- package/templates/current/clean/src/utils/permissions.ts +6 -0
- package/templates/current/clean/tsconfig.json +40 -0
- package/templates/current/clean/tsconfig.node.json +9 -0
- package/templates/current/clean/vite.build-policy.ts +405 -0
- package/templates/current/clean/vite.config.ts +37 -0
- package/templates/current/examples/.codebuddy/AGENTS.md +18 -0
- package/templates/current/examples/.codebuddy/rules/01-feature-architecture.md +12 -0
- package/templates/current/examples/.codebuddy/rules/02-vue-typescript.md +12 -0
- package/templates/current/examples/.codebuddy/rules/03-component-policy.md +30 -0
- package/templates/current/examples/.codebuddy/rules/04-api-auth-router.md +12 -0
- package/templates/current/examples/.codebuddy/rules/05-style.md +12 -0
- package/templates/current/examples/.codebuddy/rules/06-quality.md +12 -0
- package/templates/current/examples/.codebuddy/skills/build-admin-feature/SKILL.md +17 -0
- package/templates/current/examples/.codebuddy/skills/style-og-origen-ui/SKILL.md +14 -0
- package/templates/current/examples/.codebuddy/skills/use-og-dialog/SKILL.md +15 -0
- package/templates/current/examples/.codebuddy/skills/use-og-editor/SKILL.md +28 -0
- package/templates/current/examples/.codebuddy/skills/use-og-form/SKILL.md +15 -0
- package/templates/current/examples/.codebuddy/skills/use-og-form-table/SKILL.md +28 -0
- package/templates/current/examples/.codebuddy/skills/use-og-http/SKILL.md +16 -0
- package/templates/current/examples/.codebuddy/skills/use-og-router-tabs/SKILL.md +14 -0
- package/templates/current/examples/.codebuddy/skills/use-og-search/SKILL.md +17 -0
- package/templates/current/examples/.codebuddy/skills/use-og-table/SKILL.md +19 -0
- package/templates/current/examples/.codebuddy/skills/use-og-upload/SKILL.md +28 -0
- package/templates/current/examples/.codex/AGENTS.md +15 -0
- package/templates/current/examples/.codex/rules/01-feature-architecture.md +6 -0
- package/templates/current/examples/.codex/rules/02-vue-typescript.md +6 -0
- package/templates/current/examples/.codex/rules/03-component-policy.md +24 -0
- package/templates/current/examples/.codex/rules/04-api-auth-router.md +6 -0
- package/templates/current/examples/.codex/rules/05-style.md +6 -0
- package/templates/current/examples/.codex/rules/06-quality.md +6 -0
- package/templates/current/examples/.codex/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/examples/.codex/skills/build-admin-feature/references/component-selection.md +25 -0
- package/templates/current/examples/.codex/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/examples/.codex/skills/style-og-origen-ui/agents/openai.yaml +4 -0
- package/templates/current/examples/.codex/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/examples/.codex/skills/use-og-dialog/agents/openai.yaml +4 -0
- package/templates/current/examples/.codex/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/examples/.codex/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/examples/.codex/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/examples/.codex/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/examples/.codex/skills/use-og-http/agents/openai.yaml +4 -0
- package/templates/current/examples/.codex/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/examples/.codex/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/examples/.codex/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/examples/.codex/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/examples/.cursor/AGENTS.md +18 -0
- package/templates/current/examples/.cursor/rules/01-feature-architecture.mdc +12 -0
- package/templates/current/examples/.cursor/rules/02-vue-typescript.mdc +12 -0
- package/templates/current/examples/.cursor/rules/03-component-policy.mdc +30 -0
- package/templates/current/examples/.cursor/rules/04-api-auth-router.mdc +12 -0
- package/templates/current/examples/.cursor/rules/05-style.mdc +12 -0
- package/templates/current/examples/.cursor/rules/06-quality.mdc +12 -0
- package/templates/current/examples/.cursor/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/examples/.cursor/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/examples/.cursor/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/examples/.cursor/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/examples/.cursor/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/examples/.cursor/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/examples/.cursor/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/examples/.cursor/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/examples/.cursor/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/examples/.cursor/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/examples/.cursor/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/examples/.env.example +7 -0
- package/templates/current/examples/.env.production.example +31 -0
- package/templates/current/examples/.qoder/AGENTS.md +15 -0
- package/templates/current/examples/.qoder/rules/01-feature-architecture.md +12 -0
- package/templates/current/examples/.qoder/rules/02-vue-typescript.md +12 -0
- package/templates/current/examples/.qoder/rules/03-component-policy.md +30 -0
- package/templates/current/examples/.qoder/rules/04-api-auth-router.md +12 -0
- package/templates/current/examples/.qoder/rules/05-style.md +12 -0
- package/templates/current/examples/.qoder/rules/06-quality.md +12 -0
- package/templates/current/examples/.qoder/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/examples/.qoder/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/examples/.qoder/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/examples/.qoder/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/examples/.qoder/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/examples/.qoder/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/examples/.qoder/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/examples/.qoder/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/examples/.qoder/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/examples/.qoder/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/examples/.qoder/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/examples/AGENTS.md +16 -0
- package/templates/current/examples/README.md +116 -0
- package/templates/current/examples/component-catalog.json +765 -0
- package/templates/current/examples/e2e/admin-shell.spec.ts +150 -0
- package/templates/current/examples/e2e/demo-shell.spec.ts +328 -0
- package/templates/current/examples/evals/component-selection.json +29 -0
- package/templates/current/examples/gitignore +3 -0
- package/templates/current/examples/index.html +13 -0
- package/templates/current/examples/openapi.json +1623 -0
- package/templates/current/examples/package.json +65 -0
- package/templates/current/examples/playwright.config.ts +31 -0
- package/templates/current/examples/playwright.demo.config.ts +25 -0
- package/templates/current/examples/recipes/README.md +7 -0
- package/templates/current/examples/recipes/remote-crud-dialog-form.json +15 -0
- package/templates/current/examples/recipes/remote-crud-dialog-form.vue +66 -0
- package/templates/current/examples/scaffold.lock.json +12 -0
- package/templates/current/examples/scripts/check-admin-bundle.mjs +214 -0
- package/templates/current/examples/scripts/check-admin-scaffold.mjs +168 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/examples/scripts/clean-overlay/src/main.ts +91 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/componentRegistry.ts +25 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +47 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/staticRoutes.ts +63 -0
- package/templates/current/examples/scripts/demo-api.ts +797 -0
- package/templates/current/examples/scripts/generate-api.ts +27 -0
- package/templates/current/examples/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +38 -0
- package/templates/current/examples/scripts/remove-examples.mjs +54 -0
- package/templates/current/examples/src/App.vue +67 -0
- package/templates/current/examples/src/api/client.spec.ts +66 -0
- package/templates/current/examples/src/api/client.ts +72 -0
- package/templates/current/examples/src/api/generated/data-contracts.ts +268 -0
- package/templates/current/examples/src/api/generated/http-client.ts +266 -0
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +147 -0
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +53 -0
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +66 -0
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +171 -0
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +181 -0
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +169 -0
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +170 -0
- package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +98 -0
- package/templates/current/examples/src/api/http-adapter.spec.ts +33 -0
- package/templates/current/examples/src/api/http-adapter.ts +83 -0
- package/templates/current/examples/src/api/index.ts +41 -0
- package/templates/current/examples/src/app/createAdminUi.spec.ts +110 -0
- package/templates/current/examples/src/app/createAdminUi.ts +78 -0
- package/templates/current/examples/src/app/menu.spec.ts +255 -0
- package/templates/current/examples/src/app/menu.ts +268 -0
- package/templates/current/examples/src/app/menuTypes.ts +17 -0
- package/templates/current/examples/src/app/origenUiLocale.spec.ts +14 -0
- package/templates/current/examples/src/app/origenUiLocale.ts +65 -0
- package/templates/current/examples/src/app/permission.ts +9 -0
- package/templates/current/examples/src/app/runtimeConfig.ts +77 -0
- package/templates/current/examples/src/demo-api.spec.ts +167 -0
- package/templates/current/examples/src/env.d.ts +14 -0
- package/templates/current/examples/src/features/appearance/components/ThemePanel.vue +200 -0
- package/templates/current/examples/src/features/appearance/composables/useTheme.ts +17 -0
- package/templates/current/examples/src/features/appearance/store/theme.ts +140 -0
- package/templates/current/examples/src/features/auth/pages/Login.vue +159 -0
- package/templates/current/examples/src/features/auth/store/auth.spec.ts +131 -0
- package/templates/current/examples/src/features/auth/store/auth.ts +210 -0
- package/templates/current/examples/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/examples/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/examples/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/examples/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/examples/src/features/feature-composables.spec.ts +208 -0
- package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue +56 -0
- package/templates/current/examples/src/features/security/devtoolsProtection.spec.ts +211 -0
- package/templates/current/examples/src/features/security/devtoolsProtection.ts +242 -0
- package/templates/current/examples/src/features/shell/components/AdminWatermark.spec.ts +90 -0
- package/templates/current/examples/src/features/shell/components/AdminWatermark.vue +47 -0
- package/templates/current/examples/src/features/shell/components/RouteProgress.vue +68 -0
- package/templates/current/examples/src/features/shell/composables/useRouteProgress.spec.ts +95 -0
- package/templates/current/examples/src/features/shell/composables/useRouteProgress.ts +52 -0
- package/templates/current/examples/src/features/shell/store/sidebar.ts +55 -0
- package/templates/current/examples/src/features/system/access/api/admin-repository.ts +279 -0
- package/templates/current/examples/src/features/system/access/api/rbac.spec.ts +72 -0
- package/templates/current/examples/src/features/system/access/api/rbac.ts +272 -0
- package/templates/current/examples/src/features/system/access/composables/useAuthorizationRefresh.ts +15 -0
- package/templates/current/examples/src/features/system/audit/composables/useAuditManagement.ts +117 -0
- package/templates/current/examples/src/features/system/audit/pages/AuditList.vue +20 -0
- package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +189 -0
- package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +327 -0
- package/templates/current/examples/src/features/system/menus/pages/MenuList.vue +49 -0
- package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +112 -0
- package/templates/current/examples/src/features/system/roles/composables/useRoleManagement.ts +198 -0
- package/templates/current/examples/src/features/system/roles/pages/RoleList.vue +45 -0
- package/templates/current/examples/src/features/system/users/components/UserEditorForm.vue +101 -0
- package/templates/current/examples/src/features/system/users/composables/useUserManagement.ts +233 -0
- package/templates/current/examples/src/features/system/users/pages/UserList.vue +49 -0
- package/templates/current/examples/src/features/workspace/pages/Dashboard.spec.ts +32 -0
- package/templates/current/examples/src/features/workspace/pages/Dashboard.vue +297 -0
- package/templates/current/examples/src/features/workspace/pages/Empty.vue +18 -0
- package/templates/current/examples/src/features/workspace/pages/Profile.vue +183 -0
- package/templates/current/examples/src/layouts/AdminLayout.vue +61 -0
- package/templates/current/examples/src/layouts/BreadcrumbBar.vue +27 -0
- package/templates/current/examples/src/layouts/SideMenu.vue +119 -0
- package/templates/current/examples/src/layouts/TopBar.vue +301 -0
- package/templates/current/examples/src/layouts/WorkspaceTabs.vue +44 -0
- package/templates/current/examples/src/layouts/topBarMenuSearch.spec.ts +31 -0
- package/templates/current/examples/src/layouts/topBarMenuSearch.ts +21 -0
- package/templates/current/examples/src/locales/en-US.ts +55 -0
- package/templates/current/examples/src/locales/index.ts +119 -0
- package/templates/current/examples/src/locales/messages.spec.ts +23 -0
- package/templates/current/examples/src/locales/zh-CN.ts +55 -0
- package/templates/current/examples/src/locales/zh-TW.ts +44 -0
- package/templates/current/examples/src/main.ts +91 -0
- package/templates/current/examples/src/router/bootstrap.ts +76 -0
- package/templates/current/examples/src/router/componentRegistry.ts +83 -0
- package/templates/current/examples/src/router/dynamicRoutes.spec.ts +109 -0
- package/templates/current/examples/src/router/dynamicRoutes.ts +162 -0
- package/templates/current/examples/src/router/guards.ts +5 -0
- package/templates/current/examples/src/router/queryEncryption.spec.ts +82 -0
- package/templates/current/examples/src/router/queryEncryption.ts +133 -0
- package/templates/current/examples/src/router/routeQuery.spec.ts +11 -0
- package/templates/current/examples/src/router/routeQuery.ts +3 -0
- package/templates/current/examples/src/router/runtimeErrorRecovery.spec.ts +161 -0
- package/templates/current/examples/src/router/runtimeErrorRecovery.ts +108 -0
- package/templates/current/examples/src/router/staticRoutes.ts +63 -0
- package/templates/current/examples/src/router/useRouteQueryDefaults.spec.ts +90 -0
- package/templates/current/examples/src/router/useRouteQueryDefaults.ts +51 -0
- package/templates/current/examples/src/router/useRouteQueryDefaults.types.ts +19 -0
- package/templates/current/examples/src/store/index.ts +3 -0
- package/templates/current/examples/src/styles/element/index.scss +33 -0
- package/templates/current/examples/src/styles/index.css +39 -0
- package/templates/current/examples/src/styles/layout.css +115 -0
- package/templates/current/examples/src/styles/shell.css +196 -0
- package/templates/current/examples/src/styles/source-package-style-compat.css +1 -0
- package/templates/current/examples/src/templates/og-form.ts +48 -0
- package/templates/current/examples/src/templates/og-table.ts +212 -0
- package/templates/current/examples/src/templates/router.ts +51 -0
- package/templates/current/examples/src/templates/templates.spec.ts +90 -0
- package/templates/current/examples/src/theme/index.ts +7 -0
- package/templates/current/examples/src/utils/__tests__/color-mix.spec.ts +39 -0
- package/templates/current/examples/src/utils/color-mix.ts +76 -0
- package/templates/current/examples/src/utils/permissions.ts +6 -0
- package/templates/current/examples/tsconfig.json +40 -0
- package/templates/current/examples/tsconfig.node.json +9 -0
- package/templates/current/examples/vite.build-policy.ts +405 -0
- package/templates/current/examples/vite.config.ts +37 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { RouteSourceNode } from '@origen-ui/router'
|
|
2
|
+
import type { BackendMenuNode } from '../app/menuTypes'
|
|
3
|
+
import { componentCacheNames, fallbackComponentKey } from './componentRegistry'
|
|
4
|
+
|
|
5
|
+
export { componentRegistry } from './componentRegistry'
|
|
6
|
+
|
|
7
|
+
function routeName(source: BackendMenuNode, used: Set<string>): string {
|
|
8
|
+
const base = `dyn-${source.code.replace(/[^\w-]+/g, '-').replace(/^-|-$/g, '') || 'route'}`
|
|
9
|
+
let name = base
|
|
10
|
+
let suffix = 2
|
|
11
|
+
while (used.has(name)) {
|
|
12
|
+
name = `${base}-${suffix}`
|
|
13
|
+
suffix += 1
|
|
14
|
+
}
|
|
15
|
+
used.add(name)
|
|
16
|
+
return name
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function routePath(source: BackendMenuNode, isRoot: boolean): string {
|
|
20
|
+
const path = source.path.trim()
|
|
21
|
+
if (!path) return isRoot ? '/workspace' : 'empty'
|
|
22
|
+
if (isRoot && !path.startsWith('/')) return `/${path}`
|
|
23
|
+
return path
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function routeMeta(source: BackendMenuNode, hasChildren: boolean): RouteSourceNode['meta'] {
|
|
27
|
+
const cache = source.cache
|
|
28
|
+
? { enabled: true, name: source.componentKey ? componentCacheNames[source.componentKey] : undefined }
|
|
29
|
+
: undefined
|
|
30
|
+
return {
|
|
31
|
+
title: source.title,
|
|
32
|
+
icon: source.icon,
|
|
33
|
+
permissions: source.permissions,
|
|
34
|
+
menu: { hidden: source.hidden === true || source.menu === false, order: source.order },
|
|
35
|
+
breadcrumb: { label: source.title },
|
|
36
|
+
tab: { hidden: source.tabHidden === true || hasChildren },
|
|
37
|
+
cache,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface FlatMenuNode {
|
|
42
|
+
id: string
|
|
43
|
+
node: BackendMenuNode
|
|
44
|
+
structuralParentId?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function flattenSources(
|
|
48
|
+
nodes: readonly BackendMenuNode[],
|
|
49
|
+
output: FlatMenuNode[],
|
|
50
|
+
structuralParentId?: string,
|
|
51
|
+
): void {
|
|
52
|
+
for (const node of nodes) {
|
|
53
|
+
const id = `route-${output.length}`
|
|
54
|
+
const copy: BackendMenuNode = {
|
|
55
|
+
...node,
|
|
56
|
+
children: undefined,
|
|
57
|
+
}
|
|
58
|
+
output.push({ id, node: copy, structuralParentId })
|
|
59
|
+
if (node.children?.length) flattenSources(node.children, output, id)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function buildTree(nodes: readonly BackendMenuNode[]): readonly BackendMenuNode[] {
|
|
64
|
+
const flat: FlatMenuNode[] = []
|
|
65
|
+
flattenSources(nodes, flat)
|
|
66
|
+
const byCode = new Map<string, FlatMenuNode>()
|
|
67
|
+
const children = new Map<string, BackendMenuNode[]>()
|
|
68
|
+
const roots: BackendMenuNode[] = []
|
|
69
|
+
|
|
70
|
+
for (const item of flat) {
|
|
71
|
+
if (byCode.has(item.node.code)) continue
|
|
72
|
+
byCode.set(item.node.code, item)
|
|
73
|
+
children.set(item.node.code, [])
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const entries = [...byCode.values()]
|
|
77
|
+
const byId = new Map(entries.map((item) => [item.id, item]))
|
|
78
|
+
const parents = new Map<string, FlatMenuNode>()
|
|
79
|
+
const byPath = new Map<string, FlatMenuNode[]>()
|
|
80
|
+
for (const item of entries) {
|
|
81
|
+
const matches = byPath.get(item.node.path) ?? []
|
|
82
|
+
matches.push(item)
|
|
83
|
+
byPath.set(item.node.path, matches)
|
|
84
|
+
const structuralParent = item.structuralParentId ? byId.get(item.structuralParentId) : undefined
|
|
85
|
+
if (structuralParent) parents.set(item.id, structuralParent)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function fullPath(item: FlatMenuNode, seen = new Set<string>()): string | undefined {
|
|
89
|
+
if (seen.has(item.id)) return undefined
|
|
90
|
+
seen.add(item.id)
|
|
91
|
+
const parent = parents.get(item.id)
|
|
92
|
+
const path = item.node.path.trim()
|
|
93
|
+
if (!path) return undefined
|
|
94
|
+
if (path.startsWith('/')) return path
|
|
95
|
+
if (!parent) return `/${path}`
|
|
96
|
+
const parentPath = fullPath(parent, seen)
|
|
97
|
+
return parentPath ? `${parentPath.replace(/\/$/, '')}/${path}` : undefined
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const unresolved = entries.filter((item) => !parents.has(item.id) && item.node.parentPath)
|
|
101
|
+
let changed = true
|
|
102
|
+
while (changed && unresolved.length) {
|
|
103
|
+
changed = false
|
|
104
|
+
for (let index = unresolved.length - 1; index >= 0; index -= 1) {
|
|
105
|
+
const item = unresolved[index]!
|
|
106
|
+
const parentPath = item.node.parentPath!
|
|
107
|
+
const candidates = new Set([
|
|
108
|
+
...(byPath.get(parentPath) ?? []),
|
|
109
|
+
...entries.filter((candidate) => fullPath(candidate) === parentPath),
|
|
110
|
+
])
|
|
111
|
+
candidates.delete(item)
|
|
112
|
+
if (candidates.size !== 1) continue
|
|
113
|
+
parents.set(item.id, [...candidates][0]!)
|
|
114
|
+
unresolved.splice(index, 1)
|
|
115
|
+
changed = true
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
for (const item of unresolved) {
|
|
120
|
+
const parentPath = item.node.parentPath!
|
|
121
|
+
const candidates = new Set([
|
|
122
|
+
...(byPath.get(parentPath) ?? []),
|
|
123
|
+
...entries.filter((candidate) => fullPath(candidate) === parentPath),
|
|
124
|
+
])
|
|
125
|
+
candidates.delete(item)
|
|
126
|
+
if (candidates.size > 1) throw new Error(`Ambiguous dynamic route parent path: ${parentPath}`)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (const item of entries) {
|
|
130
|
+
const parent = parents.get(item.id)
|
|
131
|
+
if (parent) children.get(parent.node.code)?.push(item.node)
|
|
132
|
+
else roots.push(item.node)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function materialize(node: BackendMenuNode): BackendMenuNode {
|
|
136
|
+
const nested = children.get(node.code) ?? []
|
|
137
|
+
return { ...node, children: nested.length ? nested.map(materialize) : undefined }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return roots.map(materialize)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function routeTransformer(sources: readonly BackendMenuNode[]): readonly RouteSourceNode[] {
|
|
144
|
+
const usedNames = new Set<string>()
|
|
145
|
+
const tree = buildTree(sources)
|
|
146
|
+
|
|
147
|
+
function transform(source: BackendMenuNode, isRoot: boolean): RouteSourceNode {
|
|
148
|
+
const children = source.children?.map((child) => transform(child, false))
|
|
149
|
+
const hasChildren = Boolean(children?.length)
|
|
150
|
+
const componentKey = source.componentKey ?? (hasChildren ? 'outlet' : fallbackComponentKey)
|
|
151
|
+
return {
|
|
152
|
+
name: routeName(source, usedNames),
|
|
153
|
+
path: routePath(source, isRoot),
|
|
154
|
+
componentKey,
|
|
155
|
+
redirect: source.redirect,
|
|
156
|
+
meta: routeMeta(source, hasChildren),
|
|
157
|
+
children,
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return tree.map((source) => transform(source, true))
|
|
162
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createRouterAdapter } from '@origen-ui/router'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { defineComponent } from 'vue'
|
|
4
|
+
import { createMemoryHistory, type RouteRecordRaw } from 'vue-router'
|
|
5
|
+
import { createRouteQueryEncryption } from './queryEncryption'
|
|
6
|
+
|
|
7
|
+
const key = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
|
|
8
|
+
const View = defineComponent({ template: '<div />' })
|
|
9
|
+
const staticRoutes: RouteRecordRaw[] = [
|
|
10
|
+
{ name: '404', path: '/404', component: View, meta: { adapter: { public: true } } },
|
|
11
|
+
{ name: '500', path: '/500', component: View, meta: { adapter: { public: true } } },
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
describe('route query encryption', () => {
|
|
15
|
+
it('is disabled without an explicit enablement flag', () => {
|
|
16
|
+
expect(createRouteQueryEncryption({ key })).toBeUndefined()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('requires a 32-byte hexadecimal key when enabled', () => {
|
|
20
|
+
expect(() => createRouteQueryEncryption({ enabled: true })).toThrow('VITE_ROUTE_QUERY_KEY')
|
|
21
|
+
expect(() => createRouteQueryEncryption({ enabled: true, key: 'not-a-key' })).toThrow(
|
|
22
|
+
'VITE_ROUTE_QUERY_KEY',
|
|
23
|
+
)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('round-trips every query value through one encrypted parameter', () => {
|
|
27
|
+
const codec = createRouteQueryEncryption({ enabled: true, key })!
|
|
28
|
+
const query = { count: 2, filter: 'active', ids: ['a', 'b'], nullable: null, unicode: '绠$悊' }
|
|
29
|
+
const first = codec.stringifyQuery(query)
|
|
30
|
+
const second = codec.stringifyQuery(query)
|
|
31
|
+
|
|
32
|
+
expect(first).toMatch(/^_q=v1\./)
|
|
33
|
+
expect(first).not.toContain('active')
|
|
34
|
+
expect(first).not.toBe(second)
|
|
35
|
+
expect(codec.parseQuery(first)).toEqual({
|
|
36
|
+
count: '2',
|
|
37
|
+
filter: 'active',
|
|
38
|
+
ids: ['a', 'b'],
|
|
39
|
+
nullable: null,
|
|
40
|
+
unicode: '绠$悊',
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('returns an empty query for tampered ciphertext and legacy plaintext parameters', () => {
|
|
45
|
+
const codec = createRouteQueryEncryption({ enabled: true, key })!
|
|
46
|
+
const encoded = codec.stringifyQuery({ redirect: '/dashboard' })
|
|
47
|
+
const tampered = `${encoded.slice(0, -1)}${encoded.endsWith('a') ? 'b' : 'a'}`
|
|
48
|
+
|
|
49
|
+
expect(codec.parseQuery(tampered)).toEqual({})
|
|
50
|
+
expect(codec.parseQuery('redirect=%2Fdashboard')).toEqual({})
|
|
51
|
+
expect(codec.parseQuery('_q=invalid')).toEqual({})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('preserves encrypted query semantics while a dynamic route loads', async () => {
|
|
55
|
+
const codec = createRouteQueryEncryption({ enabled: true, key })!
|
|
56
|
+
const adapter = createRouterAdapter<{ id: string }>({
|
|
57
|
+
history: createMemoryHistory(),
|
|
58
|
+
staticRoutes,
|
|
59
|
+
parseQuery: codec.parseQuery,
|
|
60
|
+
stringifyQuery: codec.stringifyQuery,
|
|
61
|
+
dynamic: {
|
|
62
|
+
load: async () => [{ id: 'users' }],
|
|
63
|
+
transform: (source) =>
|
|
64
|
+
source.map((item) => ({ name: item.id, path: `/${item.id}`, componentKey: item.id })),
|
|
65
|
+
resolveComponent: () => View,
|
|
66
|
+
},
|
|
67
|
+
fallbacks: { notFound: { name: '404' }, error: { name: '500' } },
|
|
68
|
+
})
|
|
69
|
+
const encryptedQuery = codec.stringifyQuery({ status: 'suspended' })
|
|
70
|
+
|
|
71
|
+
await adapter.router.push(`/users?${encryptedQuery}`)
|
|
72
|
+
await adapter.router.isReady()
|
|
73
|
+
|
|
74
|
+
expect(adapter.router.currentRoute.value).toMatchObject({
|
|
75
|
+
name: 'users',
|
|
76
|
+
query: { status: 'suspended' },
|
|
77
|
+
})
|
|
78
|
+
expect(
|
|
79
|
+
codec.parseQuery(adapter.router.currentRoute.value.fullPath.split('?')[1] ?? ''),
|
|
80
|
+
).toEqual({ status: 'suspended' })
|
|
81
|
+
})
|
|
82
|
+
})
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { LocationQuery, LocationQueryRaw } from 'vue-router'
|
|
2
|
+
import AES from 'crypto-js/aes'
|
|
3
|
+
import CryptoJS from 'crypto-js/core'
|
|
4
|
+
import Base64 from 'crypto-js/enc-base64'
|
|
5
|
+
import HmacSHA256 from 'crypto-js/hmac-sha256'
|
|
6
|
+
|
|
7
|
+
const QUERY_PARAMETER = '_q'
|
|
8
|
+
const VERSION = 'v1'
|
|
9
|
+
const HEX_KEY = /^[\dA-F]{64}$/i
|
|
10
|
+
const URL_SAFE_BASE64 = /^[\w-]+$/
|
|
11
|
+
|
|
12
|
+
type QueryValue = string | null | string[] | (string | null)[]
|
|
13
|
+
type EncodedQuery = Record<string, QueryValue>
|
|
14
|
+
|
|
15
|
+
export interface RouteQueryEncryptionOptions {
|
|
16
|
+
enabled?: boolean
|
|
17
|
+
key?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface RouteQueryEncryption {
|
|
21
|
+
parseQuery: (search: string) => LocationQuery
|
|
22
|
+
stringifyQuery: (query: LocationQueryRaw | undefined) => string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function toUrlSafeBase64(value: CryptoJS.lib.WordArray): string {
|
|
26
|
+
return Base64.stringify(value).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/u, '')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function fromUrlSafeBase64(value: string): CryptoJS.lib.WordArray | undefined {
|
|
30
|
+
if (!URL_SAFE_BASE64.test(value)) return undefined
|
|
31
|
+
const padded = `${value.replaceAll('-', '+').replaceAll('_', '/')}${'='.repeat((4 - (value.length % 4)) % 4)}`
|
|
32
|
+
return Base64.parse(padded)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function equalsMac(left: string, right: string): boolean {
|
|
36
|
+
if (left.length !== right.length) return false
|
|
37
|
+
let difference = 0
|
|
38
|
+
for (let index = 0; index < left.length; index += 1)
|
|
39
|
+
difference |= left.charCodeAt(index) ^ right.charCodeAt(index)
|
|
40
|
+
return difference === 0
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function normalizeQuery(query: LocationQueryRaw | undefined): EncodedQuery {
|
|
44
|
+
const normalized: EncodedQuery = {}
|
|
45
|
+
if (!query) return normalized
|
|
46
|
+
for (const [key, value] of Object.entries(query)) {
|
|
47
|
+
if (value === undefined) continue
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
normalized[key] = value
|
|
50
|
+
.filter((item): item is string | null => item !== undefined)
|
|
51
|
+
.map((item) => (item === null ? null : String(item)))
|
|
52
|
+
} else {
|
|
53
|
+
normalized[key] = value === null ? null : String(value)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return normalized
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isEncodedQuery(value: unknown): value is EncodedQuery {
|
|
60
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false
|
|
61
|
+
return Object.values(value).every(
|
|
62
|
+
(item) =>
|
|
63
|
+
item === null ||
|
|
64
|
+
typeof item === 'string' ||
|
|
65
|
+
(Array.isArray(item) && item.every((entry) => entry === null || typeof entry === 'string')),
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function readCiphertext(search: string): string | undefined {
|
|
70
|
+
const parameters = new URLSearchParams(search.startsWith('?') ? search.slice(1) : search)
|
|
71
|
+
const values = parameters.getAll(QUERY_PARAMETER)
|
|
72
|
+
return values.length === 1 ? values[0] : undefined
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function createRouteQueryEncryption(
|
|
76
|
+
options: RouteQueryEncryptionOptions = {},
|
|
77
|
+
): RouteQueryEncryption | undefined {
|
|
78
|
+
if (!options.enabled) return undefined
|
|
79
|
+
if (!options.key || !HEX_KEY.test(options.key)) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
'VITE_ROUTE_QUERY_KEY must be a 64-character hexadecimal key when route query encryption is enabled.',
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const encryptionKey = CryptoJS.enc.Hex.parse(options.key)
|
|
86
|
+
const authenticationKey = HmacSHA256('route-query-authentication', encryptionKey)
|
|
87
|
+
|
|
88
|
+
function mac(value: string): string {
|
|
89
|
+
return HmacSHA256(value, authenticationKey).toString(CryptoJS.enc.Hex)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
stringifyQuery(query) {
|
|
94
|
+
const normalized = normalizeQuery(query)
|
|
95
|
+
if (Object.keys(normalized).length === 0) return ''
|
|
96
|
+
const iv = CryptoJS.lib.WordArray.random(16)
|
|
97
|
+
const ciphertext = AES.encrypt(JSON.stringify(normalized), encryptionKey, { iv }).ciphertext
|
|
98
|
+
const payload = `${VERSION}.${toUrlSafeBase64(iv)}.${toUrlSafeBase64(ciphertext)}`
|
|
99
|
+
return `${QUERY_PARAMETER}=${encodeURIComponent(`${payload}.${mac(payload)}`)}`
|
|
100
|
+
},
|
|
101
|
+
parseQuery(search) {
|
|
102
|
+
const value = readCiphertext(search)
|
|
103
|
+
if (!value) return {}
|
|
104
|
+
try {
|
|
105
|
+
const [version, ivValue, ciphertextValue, suppliedMac, ...extra] = value.split('.')
|
|
106
|
+
if (
|
|
107
|
+
version !== VERSION ||
|
|
108
|
+
!ivValue ||
|
|
109
|
+
!ciphertextValue ||
|
|
110
|
+
!suppliedMac ||
|
|
111
|
+
extra.length > 0 ||
|
|
112
|
+
!/^[\dA-F]{64}$/i.test(suppliedMac)
|
|
113
|
+
) {
|
|
114
|
+
return {}
|
|
115
|
+
}
|
|
116
|
+
const payload = `${version}.${ivValue}.${ciphertextValue}`
|
|
117
|
+
if (!equalsMac(suppliedMac, mac(payload))) return {}
|
|
118
|
+
const iv = fromUrlSafeBase64(ivValue)
|
|
119
|
+
const ciphertext = fromUrlSafeBase64(ciphertextValue)
|
|
120
|
+
if (!iv || !ciphertext) return {}
|
|
121
|
+
const plaintext = AES.decrypt(
|
|
122
|
+
CryptoJS.lib.CipherParams.create({ ciphertext }),
|
|
123
|
+
encryptionKey,
|
|
124
|
+
{ iv },
|
|
125
|
+
).toString(CryptoJS.enc.Utf8)
|
|
126
|
+
const query: unknown = JSON.parse(plaintext)
|
|
127
|
+
return isEncodedQuery(query) ? (query as LocationQuery) : {}
|
|
128
|
+
} catch {
|
|
129
|
+
return {}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { routeStatus } from './routeQuery'
|
|
3
|
+
|
|
4
|
+
describe('route query helpers', () => {
|
|
5
|
+
it('accepts only supported status values', () => {
|
|
6
|
+
expect(routeStatus('active')).toBe('active')
|
|
7
|
+
expect(routeStatus('suspended')).toBe('suspended')
|
|
8
|
+
expect(routeStatus(['suspended'])).toBeUndefined()
|
|
9
|
+
expect(routeStatus('unknown')).toBeUndefined()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import {
|
|
4
|
+
createRuntimeErrorRecovery,
|
|
5
|
+
createStaleAssetRecovery,
|
|
6
|
+
isStaleAssetLoadError,
|
|
7
|
+
staleAssetRecoveryStorageKey,
|
|
8
|
+
} from './runtimeErrorRecovery'
|
|
9
|
+
|
|
10
|
+
describe('createRuntimeErrorRecovery', () => {
|
|
11
|
+
const currentRoute = ref({ path: '/dashboard' })
|
|
12
|
+
const push = vi.fn()
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
currentRoute.value = { path: '/dashboard' }
|
|
16
|
+
push.mockReset()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('redirects an unexpected runtime error to the static 500 route', async () => {
|
|
20
|
+
push.mockResolvedValue(undefined)
|
|
21
|
+
const recover = createRuntimeErrorRecovery({ currentRoute, push } as never)
|
|
22
|
+
|
|
23
|
+
recover()
|
|
24
|
+
await Promise.resolve()
|
|
25
|
+
|
|
26
|
+
expect(push).toHaveBeenCalledOnce()
|
|
27
|
+
expect(push).toHaveBeenCalledWith({ name: '500' })
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('does not redirect again when the server-error page itself fails', () => {
|
|
31
|
+
currentRoute.value = { path: '/500' }
|
|
32
|
+
const recover = createRuntimeErrorRecovery({ currentRoute, push } as never)
|
|
33
|
+
|
|
34
|
+
recover()
|
|
35
|
+
|
|
36
|
+
expect(push).not.toHaveBeenCalled()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('keeps only one redirect active until navigation settles', async () => {
|
|
40
|
+
let resolveNavigation!: () => void
|
|
41
|
+
push.mockReturnValue(
|
|
42
|
+
new Promise<void>((resolve) => {
|
|
43
|
+
resolveNavigation = resolve
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
46
|
+
const recover = createRuntimeErrorRecovery({ currentRoute, push } as never)
|
|
47
|
+
|
|
48
|
+
recover()
|
|
49
|
+
recover()
|
|
50
|
+
expect(push).toHaveBeenCalledOnce()
|
|
51
|
+
|
|
52
|
+
resolveNavigation()
|
|
53
|
+
await Promise.resolve()
|
|
54
|
+
await Promise.resolve()
|
|
55
|
+
recover()
|
|
56
|
+
|
|
57
|
+
expect(push).toHaveBeenCalledTimes(2)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('allows a later recovery when the redirect cannot be completed', async () => {
|
|
61
|
+
push.mockRejectedValueOnce(new Error('navigation failed')).mockResolvedValueOnce(undefined)
|
|
62
|
+
const recover = createRuntimeErrorRecovery({ currentRoute, push } as never)
|
|
63
|
+
|
|
64
|
+
recover()
|
|
65
|
+
await Promise.resolve()
|
|
66
|
+
await Promise.resolve()
|
|
67
|
+
recover()
|
|
68
|
+
|
|
69
|
+
expect(push).toHaveBeenCalledTimes(2)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe('createStaleAssetRecovery', () => {
|
|
74
|
+
const currentRoute = ref({ path: '/dashboard' })
|
|
75
|
+
const push = vi.fn()
|
|
76
|
+
const onError = vi.fn()
|
|
77
|
+
const addEventListener = vi.fn()
|
|
78
|
+
const removeEventListener = vi.fn()
|
|
79
|
+
const reload = vi.fn()
|
|
80
|
+
const storage = new Map<string, string>()
|
|
81
|
+
const sessionStorage = {
|
|
82
|
+
getItem: (key: string) => storage.get(key) ?? null,
|
|
83
|
+
setItem: (key: string, value: string) => storage.set(key, value),
|
|
84
|
+
removeItem: (key: string) => storage.delete(key),
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
currentRoute.value = { path: '/dashboard' }
|
|
89
|
+
push.mockReset()
|
|
90
|
+
onError.mockReset()
|
|
91
|
+
addEventListener.mockReset()
|
|
92
|
+
removeEventListener.mockReset()
|
|
93
|
+
reload.mockReset()
|
|
94
|
+
storage.clear()
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
function createRecovery(recoverRuntimeError = vi.fn()) {
|
|
98
|
+
const recovery = createStaleAssetRecovery({
|
|
99
|
+
router: { currentRoute, push, onError } as never,
|
|
100
|
+
window: { addEventListener, location: { reload }, removeEventListener, sessionStorage },
|
|
101
|
+
recoverRuntimeError,
|
|
102
|
+
})
|
|
103
|
+
return { recovery, recoverRuntimeError }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
it.each([
|
|
107
|
+
'ChunkLoadError: Loading chunk 17 failed',
|
|
108
|
+
'Failed to fetch dynamically imported module',
|
|
109
|
+
'Importing a module script failed',
|
|
110
|
+
'Failed to preload CSS: /assets/page.css',
|
|
111
|
+
])('recognizes stale Vite assets: %s', (message) => {
|
|
112
|
+
expect(isStaleAssetLoadError(new Error(message))).toBe(true)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('ignores unrelated errors', () => {
|
|
116
|
+
expect(isStaleAssetLoadError(new Error('Request failed with status code 500'))).toBe(false)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('refreshes once for a stale asset error and clears the marker after mounting', () => {
|
|
120
|
+
const { recovery, recoverRuntimeError } = createRecovery()
|
|
121
|
+
|
|
122
|
+
expect(recovery.handle(new Error('Failed to fetch dynamically imported module'))).toBe(true)
|
|
123
|
+
expect(sessionStorage.getItem(staleAssetRecoveryStorageKey)).toBe('1')
|
|
124
|
+
expect(reload).toHaveBeenCalledOnce()
|
|
125
|
+
expect(recoverRuntimeError).not.toHaveBeenCalled()
|
|
126
|
+
|
|
127
|
+
recovery.clear()
|
|
128
|
+
expect(sessionStorage.getItem(staleAssetRecoveryStorageKey)).toBeNull()
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('falls back instead of refreshing repeatedly after a stale asset error', () => {
|
|
132
|
+
storage.set(staleAssetRecoveryStorageKey, '1')
|
|
133
|
+
const { recovery, recoverRuntimeError } = createRecovery()
|
|
134
|
+
|
|
135
|
+
expect(recovery.handle(new Error('Failed to preload CSS: /assets/page.css'))).toBe(true)
|
|
136
|
+
expect(reload).not.toHaveBeenCalled()
|
|
137
|
+
expect(recoverRuntimeError).toHaveBeenCalledOnce()
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('registers Vite preload and router error handlers before route loading', () => {
|
|
141
|
+
const { recovery, recoverRuntimeError } = createRecovery()
|
|
142
|
+
expect(addEventListener).toHaveBeenCalledWith('vite:preloadError', expect.any(Function))
|
|
143
|
+
expect(onError).toHaveBeenCalledOnce()
|
|
144
|
+
|
|
145
|
+
const preloadHandler = addEventListener.mock.calls[0]?.[1] as EventListener
|
|
146
|
+
const preventDefault = vi.fn()
|
|
147
|
+
preloadHandler({
|
|
148
|
+
payload: new Error('Failed to preload CSS: /assets/page.css'),
|
|
149
|
+
preventDefault,
|
|
150
|
+
} as unknown as Event)
|
|
151
|
+
expect(reload).toHaveBeenCalledOnce()
|
|
152
|
+
expect(preventDefault).toHaveBeenCalledOnce()
|
|
153
|
+
|
|
154
|
+
const routerHandler = onError.mock.calls[0]?.[0] as (error: unknown) => void
|
|
155
|
+
routerHandler(new Error('ordinary route failure'))
|
|
156
|
+
expect(recoverRuntimeError).toHaveBeenCalledOnce()
|
|
157
|
+
|
|
158
|
+
recovery.dispose()
|
|
159
|
+
expect(removeEventListener).toHaveBeenCalledWith('vite:preloadError', preloadHandler)
|
|
160
|
+
})
|
|
161
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Router } from 'vue-router'
|
|
2
|
+
|
|
3
|
+
type ErrorRecoveryRouter = Pick<Router, 'currentRoute' | 'push'>
|
|
4
|
+
type StaleAssetRouter = ErrorRecoveryRouter & Pick<Router, 'onError'>
|
|
5
|
+
|
|
6
|
+
export const staleAssetRecoveryStorageKey = 'og-admin-stale-asset-recovery'
|
|
7
|
+
|
|
8
|
+
interface StaleAssetRecoveryWindow {
|
|
9
|
+
addEventListener: (type: string, listener: EventListener) => void
|
|
10
|
+
removeEventListener: (type: string, listener: EventListener) => void
|
|
11
|
+
location: Pick<Location, 'reload'>
|
|
12
|
+
sessionStorage: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface StaleAssetRecoveryOptions {
|
|
16
|
+
router: StaleAssetRouter
|
|
17
|
+
window: StaleAssetRecoveryWindow
|
|
18
|
+
recoverRuntimeError: () => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function errorMessage(error: unknown): string {
|
|
22
|
+
if (error instanceof Error) return error.message
|
|
23
|
+
if (typeof error === 'string') return error
|
|
24
|
+
if (
|
|
25
|
+
typeof error === 'object' &&
|
|
26
|
+
error !== null &&
|
|
27
|
+
'message' in error &&
|
|
28
|
+
typeof error.message === 'string'
|
|
29
|
+
) {
|
|
30
|
+
return error.message
|
|
31
|
+
}
|
|
32
|
+
return ''
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Detects Vite's missing hashed chunks, dynamic module imports, and CSS preload failures. */
|
|
36
|
+
export function isStaleAssetLoadError(error: unknown): boolean {
|
|
37
|
+
const message = errorMessage(error).toLowerCase()
|
|
38
|
+
return [
|
|
39
|
+
'chunkloaderror',
|
|
40
|
+
'failed to fetch dynamically imported module',
|
|
41
|
+
'error loading dynamically imported module',
|
|
42
|
+
'importing a module script failed',
|
|
43
|
+
'failed to load module script',
|
|
44
|
+
'failed to fetch module script',
|
|
45
|
+
'failed to preload css',
|
|
46
|
+
'loading chunk',
|
|
47
|
+
'unable to preload css',
|
|
48
|
+
].some((fragment) => message.includes(fragment))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Installs one-shot stale-build recovery before dynamic route loading begins. */
|
|
52
|
+
export function createStaleAssetRecovery(options: StaleAssetRecoveryOptions): {
|
|
53
|
+
dispose: () => void
|
|
54
|
+
handle: (error: unknown) => boolean
|
|
55
|
+
clear: () => void
|
|
56
|
+
} {
|
|
57
|
+
function clear(): void {
|
|
58
|
+
options.window.sessionStorage.removeItem(staleAssetRecoveryStorageKey)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handle(error: unknown): boolean {
|
|
62
|
+
if (!isStaleAssetLoadError(error)) return false
|
|
63
|
+
if (options.window.sessionStorage.getItem(staleAssetRecoveryStorageKey)) {
|
|
64
|
+
options.recoverRuntimeError()
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
options.window.sessionStorage.setItem(staleAssetRecoveryStorageKey, '1')
|
|
68
|
+
options.window.location.reload()
|
|
69
|
+
return true
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const onPreloadError: EventListener = (event) => {
|
|
73
|
+
const preloadEvent = event as Event & { payload?: unknown }
|
|
74
|
+
if (!handle(preloadEvent.payload)) return
|
|
75
|
+
event.preventDefault()
|
|
76
|
+
}
|
|
77
|
+
options.window.addEventListener('vite:preloadError', onPreloadError)
|
|
78
|
+
options.router.onError((error) => {
|
|
79
|
+
if (!handle(error)) options.recoverRuntimeError()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
clear,
|
|
84
|
+
handle,
|
|
85
|
+
dispose: () => options.window.removeEventListener('vite:preloadError', onPreloadError),
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Creates a single-flight redirect to the static server-error route. */
|
|
90
|
+
export function createRuntimeErrorRecovery(router: ErrorRecoveryRouter): () => void {
|
|
91
|
+
let isRecovering = false
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
if (isRecovering || router.currentRoute.value.path === '/500') return
|
|
95
|
+
|
|
96
|
+
isRecovering = true
|
|
97
|
+
try {
|
|
98
|
+
void router
|
|
99
|
+
.push({ name: '500' })
|
|
100
|
+
.catch(() => undefined)
|
|
101
|
+
.finally(() => {
|
|
102
|
+
isRecovering = false
|
|
103
|
+
})
|
|
104
|
+
} catch {
|
|
105
|
+
isRecovering = false
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|