@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,91 @@
|
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import App from './App.vue'
|
|
3
|
+
import { permission } from './app/permission'
|
|
4
|
+
import { useAuthStore } from './features/auth/store/auth'
|
|
5
|
+
import { devtoolsProtection } from './features/security/devtoolsProtection'
|
|
6
|
+
import { createRuntimeErrorRecovery, createStaleAssetRecovery } from './router/runtimeErrorRecovery'
|
|
7
|
+
import { pinia } from './store'
|
|
8
|
+
import 'element-plus/theme-chalk/src/tabs.scss'
|
|
9
|
+
import 'origen-ui/tabs.css'
|
|
10
|
+
import '@origen-ui/router/style.css'
|
|
11
|
+
import './styles/index.css'
|
|
12
|
+
import './styles/layout.css'
|
|
13
|
+
import './styles/shell.css'
|
|
14
|
+
|
|
15
|
+
async function notifyRuntimeError(message: string): Promise<void> {
|
|
16
|
+
const { ElMessage } = await import('element-plus/es/components/message/index.mjs')
|
|
17
|
+
ElMessage.error(message)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function bootstrap(): Promise<void> {
|
|
21
|
+
devtoolsProtection.start()
|
|
22
|
+
const { createAdminI18n, createAdminTitleResolver } = await import('./locales')
|
|
23
|
+
const { i18n, language } = createAdminI18n()
|
|
24
|
+
const { initializeRouting } = await import('./router/bootstrap')
|
|
25
|
+
const queryCodecs =
|
|
26
|
+
import.meta.env.VITE_ROUTE_QUERY_ENCRYPTION === 'true'
|
|
27
|
+
? (await import('./router/queryEncryption')).createRouteQueryEncryption({
|
|
28
|
+
enabled: true,
|
|
29
|
+
key: import.meta.env.VITE_ROUTE_QUERY_KEY,
|
|
30
|
+
})
|
|
31
|
+
: undefined
|
|
32
|
+
const routing = initializeRouting(queryCodecs, {
|
|
33
|
+
resolveTitle: createAdminTitleResolver(i18n),
|
|
34
|
+
titleRevision: language.current,
|
|
35
|
+
})
|
|
36
|
+
const app = createApp(App)
|
|
37
|
+
app.use(pinia)
|
|
38
|
+
app.use(permission)
|
|
39
|
+
const recoverRuntimeError = createRuntimeErrorRecovery(routing.router)
|
|
40
|
+
const staleAssetRecovery = createStaleAssetRecovery({
|
|
41
|
+
router: routing.router,
|
|
42
|
+
window,
|
|
43
|
+
recoverRuntimeError,
|
|
44
|
+
})
|
|
45
|
+
app.use(i18n)
|
|
46
|
+
language.install(app)
|
|
47
|
+
const { createAdminUi } = await import('./app/createAdminUi')
|
|
48
|
+
app.use(createAdminUi(language))
|
|
49
|
+
app.config.errorHandler = (error: unknown) => {
|
|
50
|
+
const message = error instanceof Error ? error.message : '页面发生未知错误'
|
|
51
|
+
void notifyRuntimeError(message)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const auth = useAuthStore(pinia)
|
|
55
|
+
const session = await auth.fetchSession()
|
|
56
|
+
app.use(routing)
|
|
57
|
+
await Promise.all([
|
|
58
|
+
language.ready,
|
|
59
|
+
routing.ready(),
|
|
60
|
+
session ? import('./layouts/AdminLayout.vue') : Promise.resolve(),
|
|
61
|
+
])
|
|
62
|
+
const reportRuntimeError = app.config.errorHandler
|
|
63
|
+
const { authorizationRefreshKey } =
|
|
64
|
+
await import('./features/system/access/composables/useAuthorizationRefresh')
|
|
65
|
+
app.config.errorHandler = (error, instance, info) => {
|
|
66
|
+
reportRuntimeError?.(error, instance, info)
|
|
67
|
+
if (!staleAssetRecovery.handle(error)) recoverRuntimeError()
|
|
68
|
+
}
|
|
69
|
+
app.provide(authorizationRefreshKey, async () => {
|
|
70
|
+
await auth.refreshAuthorization()
|
|
71
|
+
await routing.replaceDynamicRoutes(undefined, { fallback: '/dashboard' })
|
|
72
|
+
})
|
|
73
|
+
app.mount('#app')
|
|
74
|
+
staleAssetRecovery.clear()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void bootstrap().catch((error: unknown) => {
|
|
78
|
+
const message = error instanceof Error ? error.message : '应用启动失败'
|
|
79
|
+
const root = document.querySelector('#app')
|
|
80
|
+
if (root) {
|
|
81
|
+
const panel = document.createElement('main')
|
|
82
|
+
panel.style.padding = '32px'
|
|
83
|
+
panel.style.fontFamily = 'system-ui, sans-serif'
|
|
84
|
+
const heading = document.createElement('h1')
|
|
85
|
+
heading.textContent = '@origen-ui/admin 启动失败'
|
|
86
|
+
const detail = document.createElement('p')
|
|
87
|
+
detail.textContent = message
|
|
88
|
+
panel.append(heading, detail)
|
|
89
|
+
root.replaceChildren(panel)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { RouterAdapter } from '@origen-ui/router'
|
|
2
|
+
import type { BackendMenuNode } from '../app/menuTypes'
|
|
3
|
+
import {
|
|
4
|
+
createAccessPolicy,
|
|
5
|
+
createRouterAdapter,
|
|
6
|
+
createWebStorageAdapter,
|
|
7
|
+
} from '@origen-ui/router'
|
|
8
|
+
import { createWebHistory } from 'vue-router'
|
|
9
|
+
import { fetchMenus } from '../app/menu'
|
|
10
|
+
import { appRuntimeConfig } from '../app/runtimeConfig'
|
|
11
|
+
import { useAuthStore } from '../features/auth/store/auth'
|
|
12
|
+
import { pinia } from '../store'
|
|
13
|
+
import { hasPermission } from '../utils/permissions'
|
|
14
|
+
import { componentRegistry, routeTransformer } from './dynamicRoutes'
|
|
15
|
+
import { staticRoutes } from './staticRoutes'
|
|
16
|
+
|
|
17
|
+
type QueryCodecs = Pick<
|
|
18
|
+
NonNullable<Parameters<typeof createRouterAdapter<BackendMenuNode>>[0]>,
|
|
19
|
+
'parseQuery' | 'stringifyQuery'
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
type TitleOptions = Pick<
|
|
23
|
+
NonNullable<Parameters<typeof createRouterAdapter<BackendMenuNode>>[0]>,
|
|
24
|
+
'resolveTitle' | 'titleRevision'
|
|
25
|
+
>
|
|
26
|
+
|
|
27
|
+
let routing: RouterAdapter<BackendMenuNode> | undefined
|
|
28
|
+
|
|
29
|
+
export function getRouting(): RouterAdapter<BackendMenuNode> {
|
|
30
|
+
if (!routing) {
|
|
31
|
+
throw new Error('Routing has not been initialized yet')
|
|
32
|
+
}
|
|
33
|
+
return routing
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function initializeRouting(
|
|
37
|
+
queryCodecs?: QueryCodecs,
|
|
38
|
+
titleOptions?: TitleOptions,
|
|
39
|
+
): RouterAdapter<BackendMenuNode> {
|
|
40
|
+
if (routing) return routing
|
|
41
|
+
const workspace = appRuntimeConfig.router.workspace
|
|
42
|
+
routing = createRouterAdapter<BackendMenuNode>({
|
|
43
|
+
history: createWebHistory(),
|
|
44
|
+
staticRoutes,
|
|
45
|
+
...queryCodecs,
|
|
46
|
+
...titleOptions,
|
|
47
|
+
access: createAccessPolicy({
|
|
48
|
+
getSession: () => useAuthStore(pinia).session,
|
|
49
|
+
canAccess: (to, session) => hasPermission(session, to.meta.adapter?.permissions ?? []),
|
|
50
|
+
loginRoute: { name: 'login' },
|
|
51
|
+
forbiddenRoute: { name: '403' },
|
|
52
|
+
}),
|
|
53
|
+
dynamic: {
|
|
54
|
+
load: fetchMenus,
|
|
55
|
+
transform: routeTransformer,
|
|
56
|
+
resolveComponent: (key) => componentRegistry.get(key),
|
|
57
|
+
},
|
|
58
|
+
fallbacks: {
|
|
59
|
+
notFound: { name: '404' },
|
|
60
|
+
error: { name: '500' },
|
|
61
|
+
},
|
|
62
|
+
workspace: {
|
|
63
|
+
enabled: workspace.enabled,
|
|
64
|
+
persistence:
|
|
65
|
+
typeof window === 'undefined'
|
|
66
|
+
? undefined
|
|
67
|
+
: {
|
|
68
|
+
storage: createWebStorageAdapter(window.localStorage),
|
|
69
|
+
key: workspace.key,
|
|
70
|
+
version: workspace.version,
|
|
71
|
+
scope: workspace.scope,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
return routing
|
|
76
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Component } from 'vue'
|
|
2
|
+
import { RouterViewHost } from '@origen-ui/router'
|
|
3
|
+
|
|
4
|
+
type ComponentLoader = () => Promise<Component>
|
|
5
|
+
type StyleLoader = () => Promise<unknown>
|
|
6
|
+
|
|
7
|
+
const tablePageStyles: readonly StyleLoader[] = [
|
|
8
|
+
() => import('origen-ui/table-search.css'),
|
|
9
|
+
() => import('element-plus/theme-chalk/src/form-item.scss'),
|
|
10
|
+
() => import('element-plus/theme-chalk/src/loading.scss'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
const componentStyleLoaders: Readonly<Record<string, readonly StyleLoader[]>> = {
|
|
14
|
+
'audit-list': tablePageStyles,
|
|
15
|
+
'menu-list': [() => import('origen-ui/dialog.css'), ...tablePageStyles],
|
|
16
|
+
'role-list': [() => import('origen-ui/dialog.css'), ...tablePageStyles],
|
|
17
|
+
'user-list': [() => import('origen-ui/dialog.css'), ...tablePageStyles],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function withComponentStyles(key: string, loadComponent: ComponentLoader): ComponentLoader {
|
|
21
|
+
const loadStyles = componentStyleLoaders[key]
|
|
22
|
+
if (!loadStyles) return loadComponent
|
|
23
|
+
|
|
24
|
+
return async () => {
|
|
25
|
+
const [, component] = await Promise.all([
|
|
26
|
+
Promise.all(loadStyles.map((loadStyle) => loadStyle())),
|
|
27
|
+
loadComponent(),
|
|
28
|
+
])
|
|
29
|
+
return component
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* componentKey → 页面组件 name 映射,用于生成 KeepAlive 缓存名单。
|
|
35
|
+
*
|
|
36
|
+
* KeepAlive 的 `:include` 匹配的是页面组件渲染后的 name(SFC `defineOptions({ name })`),
|
|
37
|
+
* 因此这里的值必须与各页面组件的 defineOptions name 完全一致,否则缓存失效。
|
|
38
|
+
* 修改组件 name 时必须同步更新此表,并保持 dynamicRoutes.spec.ts 断言一致。
|
|
39
|
+
*/
|
|
40
|
+
export const componentCacheNames: Readonly<Record<string, string>> = {
|
|
41
|
+
'dashboard': 'DashboardPage',
|
|
42
|
+
'profile': 'ProfilePage',
|
|
43
|
+
'user-list': 'UserListPage',
|
|
44
|
+
'role-list': 'RoleListPage',
|
|
45
|
+
'menu-list': 'MenuListPage',
|
|
46
|
+
'audit-list': 'AuditListPage',
|
|
47
|
+
'empty': 'EmptyPage',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const fallbackComponentKey = 'empty'
|
|
51
|
+
|
|
52
|
+
export const componentRegistry: Map<string, ComponentLoader> = new Map([
|
|
53
|
+
[
|
|
54
|
+
'dashboard',
|
|
55
|
+
() => import('../features/workspace/pages/Dashboard.vue').then((module) => module.default),
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'profile',
|
|
59
|
+
() => import('../features/workspace/pages/Profile.vue').then((module) => module.default),
|
|
60
|
+
],
|
|
61
|
+
['empty', () => import('../features/workspace/pages/Empty.vue').then((module) => module.default)],
|
|
62
|
+
['outlet', () => Promise.resolve(RouterViewHost)],
|
|
63
|
+
[
|
|
64
|
+
'user-list',
|
|
65
|
+
withComponentStyles('user-list', () =>
|
|
66
|
+
import('../features/system/users/pages/UserList.vue').then((module) => module.default)),
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
'role-list',
|
|
70
|
+
withComponentStyles('role-list', () =>
|
|
71
|
+
import('../features/system/roles/pages/RoleList.vue').then((module) => module.default)),
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
'menu-list',
|
|
75
|
+
withComponentStyles('menu-list', () =>
|
|
76
|
+
import('../features/system/menus/pages/MenuList.vue').then((module) => module.default)),
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
'audit-list',
|
|
80
|
+
withComponentStyles('audit-list', () =>
|
|
81
|
+
import('../features/system/audit/pages/AuditList.vue').then((module) => module.default)),
|
|
82
|
+
],
|
|
83
|
+
])
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { componentCacheNames } from './componentRegistry'
|
|
3
|
+
import { componentRegistry, routeTransformer } from './dynamicRoutes'
|
|
4
|
+
import { staticRoutes } from './staticRoutes'
|
|
5
|
+
|
|
6
|
+
describe('dynamic component registry', () => {
|
|
7
|
+
it.each(['user-list', 'role-list', 'menu-list', 'audit-list'])(
|
|
8
|
+
'keeps production component %s registered',
|
|
9
|
+
(componentKey) => {
|
|
10
|
+
expect(componentRegistry.has(componentKey)).toBe(true)
|
|
11
|
+
},
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
it('keeps Empty as an internal fallback for unknown leaf components', () => {
|
|
15
|
+
const [route] = routeTransformer([{ code: 'unknown', path: '/unknown', title: 'Unknown' }])
|
|
16
|
+
|
|
17
|
+
expect(route?.componentKey).toBe('empty')
|
|
18
|
+
expect(componentRegistry.has('empty')).toBe(true)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('keeps duplicate relative path segments under their nested parents', () => {
|
|
22
|
+
const routes = routeTransformer([
|
|
23
|
+
{
|
|
24
|
+
code: 'sales',
|
|
25
|
+
path: '/sales',
|
|
26
|
+
title: 'Sales',
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
code: 'sales-settings',
|
|
30
|
+
path: 'settings',
|
|
31
|
+
title: 'Settings',
|
|
32
|
+
children: [{ code: 'sales-roles', path: 'roles', title: 'Roles' }],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
code: 'support',
|
|
38
|
+
path: '/support',
|
|
39
|
+
title: 'Support',
|
|
40
|
+
children: [
|
|
41
|
+
{
|
|
42
|
+
code: 'support-settings',
|
|
43
|
+
path: 'settings',
|
|
44
|
+
title: 'Settings',
|
|
45
|
+
children: [{ code: 'support-roles', path: 'roles', title: 'Roles' }],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
expect(routes).toMatchObject([
|
|
52
|
+
{ path: '/sales', children: [{ path: 'settings', children: [{ path: 'roles' }] }] },
|
|
53
|
+
{ path: '/support', children: [{ path: 'settings', children: [{ path: 'roles' }] }] },
|
|
54
|
+
])
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('resolves flat parentPath entries that use a full parent route path', () => {
|
|
58
|
+
const [system] = routeTransformer([
|
|
59
|
+
{ code: 'system', path: '/system', title: 'System' },
|
|
60
|
+
{ code: 'users', path: 'users', parentPath: '/system', title: 'Users' },
|
|
61
|
+
{ code: 'roles', path: 'roles', parentPath: '/system/users', title: 'Roles' },
|
|
62
|
+
])
|
|
63
|
+
|
|
64
|
+
expect(system).toMatchObject({
|
|
65
|
+
path: '/system',
|
|
66
|
+
children: [{ path: 'users', children: [{ path: 'roles' }] }],
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
describe('keep-alive cache names', () => {
|
|
72
|
+
it('maps every cached componentKey to its SFC component name', () => {
|
|
73
|
+
expect(componentCacheNames).toEqual({
|
|
74
|
+
'dashboard': 'DashboardPage',
|
|
75
|
+
'profile': 'ProfilePage',
|
|
76
|
+
'user-list': 'UserListPage',
|
|
77
|
+
'role-list': 'RoleListPage',
|
|
78
|
+
'menu-list': 'MenuListPage',
|
|
79
|
+
'audit-list': 'AuditListPage',
|
|
80
|
+
'empty': 'EmptyPage',
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('generates cache.name from the component name mapping for cached dynamic routes', () => {
|
|
85
|
+
const [dashboard] = routeTransformer([
|
|
86
|
+
{ code: 'dashboard', path: '/dashboard', title: 'Dashboard', componentKey: 'dashboard', cache: true },
|
|
87
|
+
])
|
|
88
|
+
const [users] = routeTransformer([
|
|
89
|
+
{ code: 'users', path: '/system/users', title: 'Users', componentKey: 'user-list', cache: true },
|
|
90
|
+
])
|
|
91
|
+
|
|
92
|
+
expect(dashboard?.meta?.cache).toEqual({ enabled: true, name: 'DashboardPage' })
|
|
93
|
+
expect(users?.meta?.cache).toEqual({ enabled: true, name: 'UserListPage' })
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('omits cache meta when the source disables caching', () => {
|
|
97
|
+
const [audit] = routeTransformer([
|
|
98
|
+
{ code: 'audit', path: '/audit', title: 'Audit', componentKey: 'audit-list', cache: false },
|
|
99
|
+
])
|
|
100
|
+
|
|
101
|
+
expect(audit?.meta?.cache).toBeUndefined()
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('keeps the static /profile route cache name in sync with the ProfilePage component', () => {
|
|
105
|
+
const profile = staticRoutes.find((route) => route.name === 'profile')
|
|
106
|
+
|
|
107
|
+
expect(profile?.meta?.adapter?.cache).toEqual({ enabled: true, name: 'ProfilePage' })
|
|
108
|
+
})
|
|
109
|
+
})
|
|
@@ -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
|
+
})
|