@team-codeme/crud-forge 0.0.0-stage → 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/.cursor/agents/generator-engineer.md +31 -0
- package/.cursor/agents/keycloak-engineer.md +33 -0
- package/.cursor/agents/qa-engineer.md +32 -0
- package/.cursor/agents/security-reviewer.md +30 -0
- package/.cursor/mcp.json +13 -0
- package/.cursor/rules/crudforge-precautions.mdc +16 -0
- package/.cursor/rules/playwright-browser.mdc +30 -0
- package/.cursor/rules/readme-todo-sync.mdc +13 -0
- package/.env.qa.example +19 -0
- package/.github/workflows/qa-live.yml +32 -0
- package/.github/workflows/qa.yml +27 -0
- package/.vscode/settings.json +32 -0
- package/QA/IAM-PLAN.md +25 -0
- package/QA/IAM-RESULTS.md +39 -0
- package/QA/IAM-TESTCASES.md +36 -0
- package/QA/IAM-TODO.md +7 -0
- package/QA/KEYCLOAK-BOOTSTRAP.md +105 -0
- package/QA/PLAN.md +43 -0
- package/QA/RESULTS.md +59 -0
- package/QA/TESTCASES.md +65 -0
- package/QA/TODO.md +14 -0
- package/QA/pmb-dev/README.md +49 -0
- package/QA/pmb-dev/config/config.yml +152 -0
- package/QA/pmb-dev/gdl/i.gdl +17 -0
- package/README.md +851 -2
- package/Todo.md +207 -0
- package/assets/branding/crudforge-logo.png +0 -0
- package/assets/branding/crudforge-mark.png +0 -0
- package/branding/poster-crudforge.jpg +0 -0
- package/chat/last-chat/Investigating Mock Data Configuration.md +428 -0
- package/cli.js +167 -0
- package/config/default-config.yml +245 -0
- package/docs/performance/README.md +217 -0
- package/docs/performance/after.json +111 -0
- package/docs/performance/before.json +111 -0
- package/docs/quality/README.md +276 -0
- package/e2e/crudforge.e2e.yml +47 -0
- package/e2e/crudforge.field-profile.yml +33 -0
- package/e2e/crudforge.iam-live.yml +124 -0
- package/e2e/crudforge.iam.yml +62 -0
- package/e2e/tests/field-profile.spec.js +152 -0
- package/e2e/tests/generated-crud.spec.js +251 -0
- package/e2e/tests/iam-live.spec.js +149 -0
- package/e2e/tests/iam-pack.spec.js +151 -0
- package/e2e/tests/list-state.spec.js +73 -0
- package/features.csv +27 -0
- package/fuse-starter-pack/branding/crudforge-mark-source.jpg +0 -0
- package/fuse-starter-pack/branding/crudforge-mark-source.png +0 -0
- package/fuse-starter-pack/branding/crudforge-mark.png +0 -0
- package/fuse-starter-pack/branding/crudforge-wordmark-source.jpg +0 -0
- package/fuse-starter-pack/branding/crudforge-wordmark-source.png +0 -0
- package/fuse-starter-pack/branding/crudforge-wordmark.png +0 -0
- package/fuse-starter-pack/fuse-v21.1/Dockerfile +14 -0
- package/fuse-starter-pack/fuse-v21.1/LICENSE.md +6 -0
- package/fuse-starter-pack/fuse-v21.1/README.md +59 -0
- package/fuse-starter-pack/fuse-v21.1/angular.json +113 -0
- package/fuse-starter-pack/fuse-v21.1/eslint.config.ts +150 -0
- package/fuse-starter-pack/fuse-v21.1/nginx.conf +23 -0
- package/fuse-starter-pack/fuse-v21.1/nginx.dev.conf +18 -0
- package/fuse-starter-pack/fuse-v21.1/package-lock.json +11513 -0
- package/fuse-starter-pack/fuse-v21.1/package.json +69 -0
- package/fuse-starter-pack/fuse-v21.1/postcss.config.json +5 -0
- package/fuse-starter-pack/fuse-v21.1/prettier.config.ts +15 -0
- package/fuse-starter-pack/fuse-v21.1/proxy.conf.json +8 -0
- package/fuse-starter-pack/fuse-v21.1/proxy.dev.conf.json +8 -0
- package/fuse-starter-pack/fuse-v21.1/public/favicon.png +0 -0
- package/fuse-starter-pack/fuse-v21.1/public/fonts/geist/Geist-Italic.woff2 +0 -0
- package/fuse-starter-pack/fuse-v21.1/public/fonts/geist/Geist.woff2 +0 -0
- package/fuse-starter-pack/fuse-v21.1/public/fonts/geist/GeistMono-Italic.woff2 +0 -0
- package/fuse-starter-pack/fuse-v21.1/public/fonts/geist/GeistMono.woff2 +0 -0
- package/fuse-starter-pack/fuse-v21.1/public/i18n/en.json +8 -0
- package/fuse-starter-pack/fuse-v21.1/public/i18n/es.json +8 -0
- package/fuse-starter-pack/fuse-v21.1/public/images/flags/ES.svg +79 -0
- package/fuse-starter-pack/fuse-v21.1/public/images/flags/US.svg +14 -0
- package/fuse-starter-pack/fuse-v21.1/public/images/flags/where-to-find-other-flags.txt +5 -0
- package/fuse-starter-pack/fuse-v21.1/public/images/logo/logo-mark.png +0 -0
- package/fuse-starter-pack/fuse-v21.1/public/images/logo/logo.png +0 -0
- package/fuse-starter-pack/fuse-v21.1/push.sh +27 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/app.config.server.ts +10 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/app.config.ts +64 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/app.routes.server.ts +8 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/app.routes.ts +39 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/app.ts +22 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/icons/index.ts +1 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/icons/lucide.ts +1 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/icons/provider.ts +23 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/local-storage/index.ts +2 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/local-storage/local-storage.ts +109 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/local-storage/provider.ts +15 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/media/index.ts +2 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/media/media.ts +64 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/media/provider.ts +15 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/theming/index.ts +3 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/theming/models/theming.ts +13 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/theming/palette.ts +209 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/theming/provider.ts +24 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/theming/theming.ts +129 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/core/transloco/transloco-http-loader.ts +12 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/data/navigation.ts +176 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/layout.ts +77 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/ui/language-switcher.ts +91 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/ui/navigation.ts +238 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/ui/notifications.ts +252 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/ui/scheme-switcher.ts +58 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/ui/sidebar.ts +31 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/layout/ui/user.ts +132 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/academy/data/academy.ts +753 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/academy/data/model.ts +27 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/academy/features/course.ts +318 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/academy/features/courses.ts +228 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/academy/routes.ts +14 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/contacts/data/contacts.ts +4372 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/contacts/data/model.ts +34 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/contacts/features/contact.ts +239 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/contacts/features/contacts.ts +185 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/contacts/routes.ts +16 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/file-manager/data/file-manager.ts +261 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/file-manager/data/model.ts +12 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/file-manager/features/file-manager.ts +131 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/file-manager/routes.ts +15 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/file-manager/ui/list.ts +164 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/help-center/features/faq.ts +288 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/help-center/features/guide.ts +134 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/help-center/features/home.ts +219 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/help-center/features/support.ts +161 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/help-center/routes.ts +33 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/notes/data/model.ts +18 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/notes/data/notes.ts +324 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/notes/features/note.ts +152 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/notes/features/notes.ts +118 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/notes/routes.ts +16 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/tasks/data/model.ts +17 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/tasks/data/tasks.ts +562 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/tasks/features/task.ts +195 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/tasks/features/tasks.ts +271 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/apps/tasks/routes.ts +16 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/data/analytics.ts +1620 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/data/finance.ts +1065 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/data/project.ts +376 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/features/analytics/analytics.ts +1096 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/features/finance/finance.ts +658 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/features/project/budget-table.ts +188 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/features/project/project.ts +565 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/dashboards/routes.ts +23 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/documentation/features/changelog/changelog.ts +932 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/documentation/features/getting-started/building.ts +33 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/documentation/features/getting-started/development.ts +42 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/documentation/features/getting-started/installation.ts +47 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/documentation/layout.ts +9 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/documentation/routes.ts +45 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/error/features/error-page.ts +70 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/error/routes.ts +21 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/notifications/features/notifications.ts +262 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/notifications/routes.ts +10 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/settings/features/account.ts +238 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/settings/features/notifications.ts +134 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/settings/features/plan-and-billing.ts +238 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/settings/features/security.ts +211 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/settings/features/team.ts +188 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/settings/layout.ts +109 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/settings/routes.ts +37 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/modules/extras/welcome/welcome.component.ts +22 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/admin/routes.ts +95 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/forgot-password/forgot-password.html +54 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/forgot-password/forgot-password.ts +51 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/reset-password/reset-password.html +82 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/reset-password/reset-password.ts +69 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/sign-in/sign-in.html +132 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/sign-in/sign-in.ts +54 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/sign-up/sign-up.html +183 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/features/sign-up/sign-up.ts +56 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/layout.ts +9 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/auth/routes.ts +34 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/coming-soon/features/coming-soon.ts +156 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/coming-soon/layout.ts +9 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/coming-soon/routes.ts +16 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/website/layout/layout.ts +9 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/website/modules/home/features/home.ts +23 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/website/modules/home/routes.ts +10 -0
- package/fuse-starter-pack/fuse-v21.1/src/app/domains/website/routes.ts +30 -0
- package/fuse-starter-pack/fuse-v21.1/src/environments/environment.mock.ts +5 -0
- package/fuse-starter-pack/fuse-v21.1/src/environments/environment.prod.ts +5 -0
- package/fuse-starter-pack/fuse-v21.1/src/environments/environment.ts +5 -0
- package/fuse-starter-pack/fuse-v21.1/src/index.html +66 -0
- package/fuse-starter-pack/fuse-v21.1/src/main.server.ts +11 -0
- package/fuse-starter-pack/fuse-v21.1/src/main.ts +5 -0
- package/fuse-starter-pack/fuse-v21.1/src/server.ts +70 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/base/base.css +63 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/base/typography.css +54 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/components/a.css +18 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/components/input.css +22 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/components/kbd.css +55 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/components/material.css +1149 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/styles.css +31 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/tailwind/theme.css +147 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/tailwind/utilities.css +563 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/tailwind/variants.css +4 -0
- package/fuse-starter-pack/fuse-v21.1/src/styles/third-party/lucide-icons.css +12 -0
- package/fuse-starter-pack/fuse-v21.1/tsconfig.app.json +16 -0
- package/fuse-starter-pack/fuse-v21.1/tsconfig.json +37 -0
- package/fuse-starter-pack/fuse-v21.1/tsconfig.spec.json +10 -0
- package/generator/README.md +12 -0
- package/generator/issues/.gitkeep +0 -0
- package/package.json +56 -4
- package/playwright.config.js +29 -0
- package/playwright.field-profile.config.js +6 -0
- package/playwright.iam-live.config.js +31 -0
- package/playwright.iam.config.js +29 -0
- package/playwright.list-state.config.js +6 -0
- package/playwright.performance.config.js +1 -0
- package/run-config-tests.sh +5 -0
- package/scripts/e2e-paths.js +89 -0
- package/scripts/e2e-prepare-field-profile.js +17 -0
- package/scripts/e2e-prepare-iam-live.js +135 -0
- package/scripts/e2e-prepare-iam.js +65 -0
- package/scripts/e2e-prepare.js +72 -0
- package/scripts/e2e-serve-iam-live.js +28 -0
- package/scripts/e2e-serve-iam.js +28 -0
- package/scripts/e2e-serve.js +28 -0
- package/scripts/performance/generate.js +17 -0
- package/scripts/performance/measure.js +55 -0
- package/scripts/postinstall.js +9 -0
- package/scripts/prepare-quality-apps.js +34 -0
- package/scripts/run-config-tests.js +63 -0
- package/src/assets/logo-with-lable.jpeg +0 -0
- package/src/assets/logo.jpeg +0 -0
- package/src/commands/bootstrap.js +92 -0
- package/src/commands/doctor.js +403 -0
- package/src/commands/generate.js +301 -0
- package/src/commands/init-config.js +310 -0
- package/src/commands/keycloak-options.js +182 -0
- package/src/commands/validate.js +52 -0
- package/src/config/auth-config.js +183 -0
- package/src/config/default-values.js +235 -0
- package/src/config/env-refs.js +71 -0
- package/src/config/field-preferences.js +99 -0
- package/src/config/input-sources.js +104 -0
- package/src/config/load-config.js +166 -0
- package/src/config/proxy-routes.js +44 -0
- package/src/generator/access-control-tools.js +334 -0
- package/src/generator/ai-docs.js +691 -0
- package/src/generator/application-tests.js +252 -0
- package/src/generator/auth-pack.js +965 -0
- package/src/generator/embed-config.js +431 -0
- package/src/generator/entity-layout.js +30 -0
- package/src/generator/fuse-build.js +57 -0
- package/src/generator/fuse-runtime.js +344 -0
- package/src/generator/generated-banner.js +137 -0
- package/src/generator/index.js +874 -0
- package/src/generator/project-output.js +126 -0
- package/src/generator/team-pack.js +220 -0
- package/src/index.js +68 -0
- package/src/parser/gdl-parser.js +169 -0
- package/src/parser/jdl-parser.js +171 -0
- package/src/presets/pmb-test.js +139 -0
- package/src/presets/static-source.js +73 -0
- package/src/presets/store.js +96 -0
- package/src/provision/admin-service.js +148 -0
- package/src/provision/bootstrap.js +147 -0
- package/src/provision/http.js +123 -0
- package/src/provision/keycloak-admin-rest.js +335 -0
- package/src/provision/state.js +51 -0
- package/src/provision/token.js +52 -0
- package/src/templates/angular/auth/access-control.service.ts.ejs +179 -0
- package/src/templates/angular/auth/access-ctrl.pipe.ts.ejs +20 -0
- package/src/templates/angular/auth/auth.guard.ts.ejs +27 -0
- package/src/templates/angular/auth/auth.interceptor.ts.ejs +53 -0
- package/src/templates/angular/auth/auth.service.ts.ejs +594 -0
- package/src/templates/angular/auth/auth.utils.ts.ejs +28 -0
- package/src/templates/angular/auth/current-user.ts.ejs +24 -0
- package/src/templates/angular/auth/disabled-account-overlay.component.css.ejs +95 -0
- package/src/templates/angular/auth/disabled-account-overlay.component.html.ejs +33 -0
- package/src/templates/angular/auth/disabled-account-overlay.component.ts.ejs +23 -0
- package/src/templates/angular/auth/fuse-account.ts.ejs +234 -0
- package/src/templates/angular/auth/fuse-user.ts.ejs +264 -0
- package/src/templates/angular/auth/has-permission.directive.ts.ejs +51 -0
- package/src/templates/angular/auth/index.ts.ejs +24 -0
- package/src/templates/angular/auth/keycloak-admin.service.ts.ejs +670 -0
- package/src/templates/angular/auth/landing.guard.ts.ejs +61 -0
- package/src/templates/angular/auth/no-auth.guard.ts.ejs +19 -0
- package/src/templates/angular/auth/permission-attribute.util.ts.ejs +182 -0
- package/src/templates/angular/auth/sign-in.ts.ejs +60 -0
- package/src/templates/angular/entity/_entity_.model.ts.ejs +64 -0
- package/src/templates/angular/entity/_entity_.routes.ts.ejs +9 -0
- package/src/templates/angular/entity/components/forms/form/_entity_-form.component.html.ejs +168 -0
- package/src/templates/angular/entity/components/forms/form/_entity_-form.component.ts.ejs +175 -0
- package/src/templates/angular/entity/components/forms/form-page/_entity_-form-page.component.html.ejs +10 -0
- package/src/templates/angular/entity/components/forms/form-page/_entity_-form-page.component.ts.ejs +86 -0
- package/src/templates/angular/entity/components/forms/update/_entity_-form.service.ts.ejs +136 -0
- package/src/templates/angular/entity/components/interaction/actions/_entity_-actions.component.html.ejs +68 -0
- package/src/templates/angular/entity/components/interaction/actions/_entity_-actions.component.ts.ejs +69 -0
- package/src/templates/angular/entity/components/interaction/filter/_entity_-filter.component.html.ejs +111 -0
- package/src/templates/angular/entity/components/interaction/filter/_entity_-filter.component.ts.ejs +102 -0
- package/src/templates/angular/entity/components/presentation/card/_entity_-card.component.css.ejs +33 -0
- package/src/templates/angular/entity/components/presentation/card/_entity_-card.component.html.ejs +29 -0
- package/src/templates/angular/entity/components/presentation/card/_entity_-card.component.ts.ejs +93 -0
- package/src/templates/angular/entity/components/presentation/detail/_entity_-detail.component.css.ejs +54 -0
- package/src/templates/angular/entity/components/presentation/detail/_entity_-detail.component.html.ejs +58 -0
- package/src/templates/angular/entity/components/presentation/detail/_entity_-detail.component.ts.ejs +47 -0
- package/src/templates/angular/entity/components/presentation/list/_entity_-list.component.html.ejs +419 -0
- package/src/templates/angular/entity/components/presentation/list/_entity_-list.component.scss.ejs +48 -0
- package/src/templates/angular/entity/components/presentation/list/_entity_-list.component.ts.ejs +592 -0
- package/src/templates/angular/entity/service/_entity_.service.ts.ejs +153 -0
- package/src/templates/angular/entity/settings/_entity_.settings.ts.ejs +49 -0
- package/src/templates/angular/enums/_enum_.model.ts.ejs +11 -0
- package/src/templates/angular/iam/change-password.component.html.ejs +39 -0
- package/src/templates/angular/iam/change-password.component.ts.ejs +44 -0
- package/src/templates/angular/iam/no-access.component.ts.ejs +17 -0
- package/src/templates/angular/iam/role-list.component.html.ejs +331 -0
- package/src/templates/angular/iam/role-list.component.scss.ejs +107 -0
- package/src/templates/angular/iam/role-list.component.ts.ejs +597 -0
- package/src/templates/angular/iam/role-management/role-header.component.html.ejs +51 -0
- package/src/templates/angular/iam/role-management/role-header.component.ts.ejs +45 -0
- package/src/templates/angular/iam/role-management/role-inheritance.component.html.ejs +15 -0
- package/src/templates/angular/iam/role-management/role-inheritance.component.ts.ejs +19 -0
- package/src/templates/angular/iam/role-management/role-permissions-panel.component.css.ejs +24 -0
- package/src/templates/angular/iam/role-management/role-permissions-panel.component.html.ejs +108 -0
- package/src/templates/angular/iam/role-management/role-permissions-panel.component.ts.ejs +122 -0
- package/src/templates/angular/iam/role-management/role-users.component.html.ejs +104 -0
- package/src/templates/angular/iam/role-management/role-users.component.ts.ejs +53 -0
- package/src/templates/angular/iam/role-management/user-select-dialog.component.html.ejs +113 -0
- package/src/templates/angular/iam/role-management/user-select-dialog.component.ts.ejs +157 -0
- package/src/templates/angular/iam/role-permission-matrix.component.html.ejs +355 -0
- package/src/templates/angular/iam/role-permission-matrix.component.scss.ejs +217 -0
- package/src/templates/angular/iam/role-permission-matrix.component.ts.ejs +800 -0
- package/src/templates/angular/iam/screen-catalog.ts.ejs +147 -0
- package/src/templates/angular/iam/shared/confirm-dialog.component.ts.ejs +83 -0
- package/src/templates/angular/iam/shared/matrix-hierarchy.util.ts.ejs +196 -0
- package/src/templates/angular/iam/shared/permission-matrix-sound.ts.ejs +59 -0
- package/src/templates/angular/iam/shared/role-display.util.ts.ejs +43 -0
- package/src/templates/angular/iam/shared/role-permission-skeleton.component.ts.ejs +54 -0
- package/src/templates/angular/iam/shared/screen-matrix.util.ts.ejs +554 -0
- package/src/templates/angular/iam/shared/screen-navigation-map.ts.ejs +187 -0
- package/src/templates/angular/iam/shared/screen-navigation.registry.ts.ejs +64 -0
- package/src/templates/angular/iam/shared/text-highlight.pipe.ts.ejs +39 -0
- package/src/templates/angular/iam/user-access-matrix.component.html.ejs +212 -0
- package/src/templates/angular/iam/user-access-matrix.component.scss.ejs +34 -0
- package/src/templates/angular/iam/user-access-matrix.component.ts.ejs +239 -0
- package/src/templates/angular/iam/user-detail.component.html.ejs +143 -0
- package/src/templates/angular/iam/user-detail.component.ts.ejs +108 -0
- package/src/templates/angular/iam/user-form.component.html.ejs +63 -0
- package/src/templates/angular/iam/user-form.component.ts.ejs +100 -0
- package/src/templates/angular/iam/user-list.component.html.ejs +369 -0
- package/src/templates/angular/iam/user-list.component.scss.ejs +242 -0
- package/src/templates/angular/iam/user-list.component.ts.ejs +446 -0
- package/src/templates/angular/iam/user-management.routes.ts.ejs +47 -0
- package/src/templates/angular/iam/user-permission-matrix.component.html.ejs +231 -0
- package/src/templates/angular/iam/user-permission-matrix.component.scss.ejs +216 -0
- package/src/templates/angular/iam/user-permission-matrix.component.ts.ejs +516 -0
- package/src/templates/angular/shared/base/audit-user-name.pipe.ts.ejs +69 -0
- package/src/templates/angular/shared/base/base-filter.component.ts.ejs +245 -0
- package/src/templates/angular/shared/base/base-form.component.ts.ejs +109 -0
- package/src/templates/angular/shared/base/base-list.component.ts.ejs +507 -0
- package/src/templates/angular/shared/base/filter-types.ts.ejs +55 -0
- package/src/templates/angular/shared/base/input-format.directive.ts.ejs +47 -0
- package/src/templates/angular/shared/base/input-format.ts.ejs +15 -0
- package/src/templates/angular/shared/confirm-with-input-dialog.component.ts.ejs +91 -0
- package/src/templates/angular/shared/confirmation-dialog.component.ts.ejs +80 -0
- package/src/templates/angular/shared/list-styles.css.ejs +103 -0
- package/src/templates/angular/shared/loading-overlay.component.ts.ejs +24 -0
- package/src/templates/angular/shared/resizable.directive.ts.ejs +115 -0
- package/src/templates/angular/shared/snackbar-styles.css.ejs +11 -0
- package/src/templates/fuse-packs/access-control-tools/access-control-sync.js +819 -0
- package/src/templates/fuse-packs/access-control-tools/build-rename-map.js +67 -0
- package/src/templates/fuse-packs/access-control-tools/inject-qa-ids.js +14 -0
- package/src/templates/fuse-packs/access-control-tools/lib/hierarchy-scanner.js +628 -0
- package/src/templates/fuse-packs/access-control-tools/lib/hierarchy-scanner.test.js +323 -0
- package/src/templates/fuse-packs/access-control-tools/lib/html-scanner.js +362 -0
- package/src/templates/fuse-packs/access-control-tools/lib/id-rules.duplicate.test.js +136 -0
- package/src/templates/fuse-packs/access-control-tools/lib/id-rules.js +1095 -0
- package/src/templates/fuse-packs/access-control-tools/lib/ts-component-index.js +482 -0
- package/src/templates/fuse-packs/access-control-tools/output/.gitkeep +0 -0
- package/src/templates/fuse-packs/access-control-tools/run.sh +223 -0
- package/src/templates/fuse-packs/access-control-tools/scan-access-control.js +14 -0
- package/src/templates/fuse-packs/iam-assets/sound/apple-play.mp3 +0 -0
- package/src/templates/fuse-packs/iam-assets/sound/remove.mp3 +0 -0
- package/src/templates/generator/README.md +12 -0
- package/src/templates/testing/ci.cjs +45 -0
- package/src/templates/testing/mock.cjs +149 -0
- package/src/templates/testing/playwright.config.cjs +25 -0
- package/src/templates/testing/serve.cjs +22 -0
- package/src/templates/testing/smoke.spec.cjs +180 -0
- package/src/utils/branding.js +39 -0
- package/src/utils/colors.js +18 -0
- package/src/utils/diff.js +109 -0
- package/src/utils/merger.js +115 -0
- package/src/validator/backend-diagnostics.js +30 -0
- package/src/validator/blueprint-validator.js +276 -0
- package/src/validator/diagnostics.js +608 -0
- package/src/validator/pattern.js +28 -0
- package/test/auth-interceptor.js +84 -0
- package/test/auth-provision-checks.js +297 -0
- package/test/field-preferences.js +145 -0
- package/test/fixtures/field-profile.gdl +7 -0
- package/test/fixtures/mock.jdl +17 -0
- package/test/fixtures/mock.png +0 -0
- package/test/fixtures/performance/config.yml +33 -0
- package/test/fixtures/performance/large.gdl +199 -0
- package/test/fixtures/performance/small.gdl +7 -0
- package/test/fixtures/quality/custom.yml +22 -0
- package/test/fixtures/quality/go-duck.yml +22 -0
- package/test/fixtures/quality/jhipster.yml +30 -0
- package/test/fixtures/quality/representative.gdl +14 -0
- package/test/list-state.js +138 -0
- package/test/micro-functions-layout.js +95 -0
- package/test/performance-generation.js +32 -0
- package/test/pmb-preset.js +127 -0
- package/test/project-workflow.js +111 -0
- package/test/quality-features.js +250 -0
- package/test/verify-commands.js +83 -0
- package/test/verify.js +959 -0
- package/test-files/GDL/example.gdl +15 -0
- package/test-files/JDL/example.jdl +15 -0
- package/test-files/config/crudforge.config.yml +127 -0
- package/test-run.sh +272 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
const colors = require('../utils/colors');
|
|
2
|
+
const { resolveEnv } = require('../config/env-refs');
|
|
3
|
+
const { deriveAuthUrls } = require('../config/auth-config');
|
|
4
|
+
const { fetchPasswordToken } = require('./token');
|
|
5
|
+
const { runAdminServiceBootstrap } = require('./admin-service');
|
|
6
|
+
const { runKeycloakAdminRestBootstrap, deleteTrackedResources } = require('./keycloak-admin-rest');
|
|
7
|
+
const { emptyState, resolveStatePath, readState, writeState } = require('./state');
|
|
8
|
+
|
|
9
|
+
function desiredFromConfig(auth) {
|
|
10
|
+
const provision = auth.provision || {};
|
|
11
|
+
return {
|
|
12
|
+
clientId: String(provision.clientId || auth.clientId || '').trim(),
|
|
13
|
+
clientName: provision.clientName || '',
|
|
14
|
+
publicClient: provision.publicClient !== false,
|
|
15
|
+
directAccessGrantsEnabled: provision.directAccessGrantsEnabled !== false,
|
|
16
|
+
redirectUris: Array.isArray(provision.redirectUris) ? provision.redirectUris : [],
|
|
17
|
+
webOrigins: Array.isArray(provision.webOrigins) ? provision.webOrigins : [],
|
|
18
|
+
roles: Array.isArray(provision.roles) ? provision.roles.map(String) : [],
|
|
19
|
+
users: Array.isArray(provision.users) ? provision.users : [],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function resolveUserPassword(user) {
|
|
24
|
+
const value = resolveEnv(user.passwordEnv);
|
|
25
|
+
if (!value) {
|
|
26
|
+
throw new Error(`passwordEnv "${user.passwordEnv}" for user "${user.username}" is not set.`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function runBootstrap(config, options = {}) {
|
|
32
|
+
const auth = deriveAuthUrls({ ...(config.auth || {}) });
|
|
33
|
+
const provision = auth.provision || {};
|
|
34
|
+
const dryRun = !!(options.dryRun || provision.dryRun);
|
|
35
|
+
const adapter = String(provision.adapter || 'admin-service').trim();
|
|
36
|
+
const desired = desiredFromConfig(auth);
|
|
37
|
+
|
|
38
|
+
if (!desired.clientId) {
|
|
39
|
+
throw new Error('auth.provision.clientId or auth.clientId is required for bootstrap.');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const username = resolveEnv(provision.adminUsernameEnv);
|
|
43
|
+
const password = resolveEnv(provision.adminPasswordEnv);
|
|
44
|
+
const tokenClientId = provision.tokenClientId || 'admin-cli';
|
|
45
|
+
const forwardedProto = auth.forwardedProto || '';
|
|
46
|
+
|
|
47
|
+
console.log(
|
|
48
|
+
colors.cyan(
|
|
49
|
+
`🔵 Keycloak bootstrap (${dryRun ? 'dry-run' : 'apply'}) adapter=${adapter} realm=${auth.realm} client=${desired.clientId}`
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const token = await fetchPasswordToken({
|
|
54
|
+
tokenUrl: auth.tokenUrl,
|
|
55
|
+
clientId: tokenClientId,
|
|
56
|
+
username,
|
|
57
|
+
password,
|
|
58
|
+
forwardedProto,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const statePath = resolveStatePath(config, options.cwd || process.cwd());
|
|
62
|
+
const state = dryRun ? emptyState() : readState(statePath);
|
|
63
|
+
state.adapter = adapter;
|
|
64
|
+
state.realm = auth.realm;
|
|
65
|
+
|
|
66
|
+
let outcome;
|
|
67
|
+
if (adapter === 'admin-service') {
|
|
68
|
+
outcome = await runAdminServiceBootstrap({
|
|
69
|
+
adminServiceUrl: provision.adminServiceUrl,
|
|
70
|
+
token,
|
|
71
|
+
desired,
|
|
72
|
+
dryRun,
|
|
73
|
+
resetExistingPasswords: !!provision.resetExistingPasswords,
|
|
74
|
+
resolveUserPassword,
|
|
75
|
+
});
|
|
76
|
+
} else if (adapter === 'keycloak-admin-rest') {
|
|
77
|
+
outcome = await runKeycloakAdminRestBootstrap({
|
|
78
|
+
serverUrl: auth.serverUrl,
|
|
79
|
+
realm: auth.realm,
|
|
80
|
+
token,
|
|
81
|
+
forwardedProto,
|
|
82
|
+
desired,
|
|
83
|
+
dryRun,
|
|
84
|
+
resetExistingPasswords: !!provision.resetExistingPasswords,
|
|
85
|
+
resolveUserPassword,
|
|
86
|
+
state,
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error(`Unknown auth.provision.adapter "${adapter}".`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
(outcome.plan || []).forEach((line) => console.log(` -> ${line}`));
|
|
93
|
+
|
|
94
|
+
if (!dryRun && adapter === 'keycloak-admin-rest') {
|
|
95
|
+
writeState(statePath, state);
|
|
96
|
+
console.log(colors.dim(` -> State written to ${statePath} (cleanup uses this file only)`));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (dryRun) {
|
|
100
|
+
console.log(colors.yellow('⚠️ Dry run complete. No remote mutations were requested by this CLI beyond the token request.'));
|
|
101
|
+
} else {
|
|
102
|
+
console.log(colors.green('✅ Keycloak bootstrap finished.'));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return { ...outcome, statePath, dryRun };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function runCleanup(config, options = {}) {
|
|
109
|
+
const auth = deriveAuthUrls({ ...(config.auth || {}) });
|
|
110
|
+
const provision = auth.provision || {};
|
|
111
|
+
if (String(provision.adapter || '') !== 'keycloak-admin-rest') {
|
|
112
|
+
throw new Error('Cleanup is only implemented for auth.provision.adapter: keycloak-admin-rest.');
|
|
113
|
+
}
|
|
114
|
+
const statePath = resolveStatePath(config, options.cwd || process.cwd());
|
|
115
|
+
const state = readState(statePath);
|
|
116
|
+
const hasItems = [...(state.clients || []), ...(state.roles || []), ...(state.users || [])].length > 0;
|
|
117
|
+
if (!hasItems) {
|
|
118
|
+
console.log(colors.yellow(`⚠️ No tracked resources in ${statePath}. Nothing to delete.`));
|
|
119
|
+
return { deleted: [] };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const token = await fetchPasswordToken({
|
|
123
|
+
tokenUrl: auth.tokenUrl,
|
|
124
|
+
clientId: provision.tokenClientId || 'admin-cli',
|
|
125
|
+
username: resolveEnv(provision.adminUsernameEnv),
|
|
126
|
+
password: resolveEnv(provision.adminPasswordEnv),
|
|
127
|
+
forwardedProto: auth.forwardedProto || '',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const deleted = await deleteTrackedResources(
|
|
131
|
+
{
|
|
132
|
+
serverUrl: auth.serverUrl,
|
|
133
|
+
realm: auth.realm,
|
|
134
|
+
token,
|
|
135
|
+
forwardedProto: auth.forwardedProto || '',
|
|
136
|
+
},
|
|
137
|
+
state
|
|
138
|
+
);
|
|
139
|
+
writeState(statePath, emptyState());
|
|
140
|
+
console.log(colors.green(`✅ Removed ${deleted.length} tracked resource(s).`));
|
|
141
|
+
return { deleted };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = {
|
|
145
|
+
runBootstrap,
|
|
146
|
+
runCleanup,
|
|
147
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const https = require('https');
|
|
3
|
+
|
|
4
|
+
class ProvisionHttpError extends Error {
|
|
5
|
+
constructor(message, status, body) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'ProvisionHttpError';
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.body = body;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function summarizeBody(body) {
|
|
14
|
+
if (body == null) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
if (typeof body === 'string') {
|
|
18
|
+
return body.slice(0, 400);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const copy = JSON.parse(JSON.stringify(body));
|
|
22
|
+
['access_token', 'refresh_token', 'password', 'value', 'client_secret', 'secret'].forEach((key) => {
|
|
23
|
+
if (copy && Object.prototype.hasOwnProperty.call(copy, key)) {
|
|
24
|
+
copy[key] = '[redacted]';
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return JSON.stringify(copy).slice(0, 400);
|
|
28
|
+
} catch {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function request({ method, url, headers = {}, body, json, form, timeout = 20000 }) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
let parsed;
|
|
36
|
+
try {
|
|
37
|
+
parsed = new URL(url);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
reject(new Error(`Invalid URL: ${url}`));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let payload = null;
|
|
44
|
+
const reqHeaders = { Accept: 'application/json', ...headers };
|
|
45
|
+
|
|
46
|
+
if (form) {
|
|
47
|
+
payload = Buffer.from(new URLSearchParams(form).toString());
|
|
48
|
+
reqHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
49
|
+
reqHeaders['Content-Length'] = payload.length;
|
|
50
|
+
} else if (json !== undefined) {
|
|
51
|
+
payload = Buffer.from(JSON.stringify(json));
|
|
52
|
+
reqHeaders['Content-Type'] = 'application/json';
|
|
53
|
+
reqHeaders['Content-Length'] = payload.length;
|
|
54
|
+
} else if (body != null) {
|
|
55
|
+
payload = Buffer.isBuffer(body) ? body : Buffer.from(String(body));
|
|
56
|
+
reqHeaders['Content-Length'] = payload.length;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const lib = parsed.protocol === 'https:' ? https : http;
|
|
60
|
+
const req = lib.request(
|
|
61
|
+
{
|
|
62
|
+
protocol: parsed.protocol,
|
|
63
|
+
hostname: parsed.hostname,
|
|
64
|
+
port: parsed.port || (parsed.protocol === 'https:' ? 443 : 80),
|
|
65
|
+
path: `${parsed.pathname}${parsed.search}`,
|
|
66
|
+
method: method || 'GET',
|
|
67
|
+
headers: reqHeaders,
|
|
68
|
+
timeout,
|
|
69
|
+
},
|
|
70
|
+
(res) => {
|
|
71
|
+
const chunks = [];
|
|
72
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
73
|
+
res.on('end', () => {
|
|
74
|
+
const text = Buffer.concat(chunks).toString('utf8');
|
|
75
|
+
let parsedBody = text;
|
|
76
|
+
if (text) {
|
|
77
|
+
try {
|
|
78
|
+
parsedBody = JSON.parse(text);
|
|
79
|
+
} catch {
|
|
80
|
+
parsedBody = text;
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
parsedBody = null;
|
|
84
|
+
}
|
|
85
|
+
resolve({
|
|
86
|
+
status: res.statusCode,
|
|
87
|
+
headers: res.headers,
|
|
88
|
+
body: parsedBody,
|
|
89
|
+
text,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
req.on('timeout', () => {
|
|
96
|
+
req.destroy(new Error(`Request timed out: ${method} ${url}`));
|
|
97
|
+
});
|
|
98
|
+
req.on('error', reject);
|
|
99
|
+
if (payload) {
|
|
100
|
+
req.write(payload);
|
|
101
|
+
}
|
|
102
|
+
req.end();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function assertOk(response, action) {
|
|
107
|
+
if (response.status >= 200 && response.status < 300) {
|
|
108
|
+
return response;
|
|
109
|
+
}
|
|
110
|
+
const detail = summarizeBody(response.body);
|
|
111
|
+
throw new ProvisionHttpError(
|
|
112
|
+
`${action} failed (HTTP ${response.status})${detail ? `: ${detail}` : ''}`,
|
|
113
|
+
response.status,
|
|
114
|
+
response.body
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = {
|
|
119
|
+
request,
|
|
120
|
+
assertOk,
|
|
121
|
+
ProvisionHttpError,
|
|
122
|
+
summarizeBody,
|
|
123
|
+
};
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
const { request, assertOk } = require('./http');
|
|
2
|
+
|
|
3
|
+
const OWNED_ATTRIBUTE = 'crudforge.owned';
|
|
4
|
+
|
|
5
|
+
function realmAdminUrl(serverUrl, realm) {
|
|
6
|
+
return `${String(serverUrl).replace(/\/+$/, '')}/admin/realms/${encodeURIComponent(realm)}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function headers(token, forwardedProto) {
|
|
10
|
+
const next = { Authorization: `Bearer ${token}` };
|
|
11
|
+
if (forwardedProto) {
|
|
12
|
+
next['X-Forwarded-Proto'] = forwardedProto;
|
|
13
|
+
}
|
|
14
|
+
return next;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function kcRequest({ serverUrl, realm, token, forwardedProto, method, path, json }) {
|
|
18
|
+
return request({
|
|
19
|
+
method,
|
|
20
|
+
url: `${realmAdminUrl(serverUrl, realm)}${path}`,
|
|
21
|
+
headers: headers(token, forwardedProto),
|
|
22
|
+
json,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isOwnedClient(client) {
|
|
27
|
+
const attrs = client && client.attributes ? client.attributes : {};
|
|
28
|
+
const value = attrs[OWNED_ATTRIBUTE];
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
return value.map(String).includes('true');
|
|
31
|
+
}
|
|
32
|
+
return String(value || '') === 'true';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function findClient(ctx, clientId) {
|
|
36
|
+
const response = await kcRequest({ ...ctx, method: 'GET', path: `/clients?clientId=${encodeURIComponent(clientId)}` });
|
|
37
|
+
assertOk(response, `List clients matching ${clientId}`);
|
|
38
|
+
const list = Array.isArray(response.body) ? response.body : [];
|
|
39
|
+
return list.find((client) => client.clientId === clientId) || null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function findRole(ctx, name) {
|
|
43
|
+
const response = await kcRequest({ ...ctx, method: 'GET', path: `/roles/${encodeURIComponent(name)}` });
|
|
44
|
+
if (response.status === 404) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
assertOk(response, `Read realm role ${name}`);
|
|
48
|
+
return response.body;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function findUserByUsername(ctx, username) {
|
|
52
|
+
const response = await kcRequest({
|
|
53
|
+
...ctx,
|
|
54
|
+
method: 'GET',
|
|
55
|
+
path: `/users?username=${encodeURIComponent(username)}&exact=true`,
|
|
56
|
+
});
|
|
57
|
+
assertOk(response, `Search user ${username}`);
|
|
58
|
+
const list = Array.isArray(response.body) ? response.body : [];
|
|
59
|
+
return list.find((user) => user.username === username) || list[0] || null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function ensureClient(ctx, desired, dryRun, state) {
|
|
63
|
+
const existing = await findClient(ctx, desired.clientId);
|
|
64
|
+
if (existing) {
|
|
65
|
+
if (!isOwnedClient(existing)) {
|
|
66
|
+
// Use the existing client for the app; never mutate unmanaged clients.
|
|
67
|
+
return { client: existing, created: false, unmanaged: true };
|
|
68
|
+
}
|
|
69
|
+
return { client: existing, created: false };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const representation = {
|
|
73
|
+
clientId: desired.clientId,
|
|
74
|
+
name: desired.clientName || desired.clientId,
|
|
75
|
+
enabled: true,
|
|
76
|
+
publicClient: desired.publicClient !== false,
|
|
77
|
+
protocol: 'openid-connect',
|
|
78
|
+
standardFlowEnabled: true,
|
|
79
|
+
directAccessGrantsEnabled: desired.directAccessGrantsEnabled !== false,
|
|
80
|
+
redirectUris: desired.redirectUris.length ? desired.redirectUris : ['http://127.0.0.1:*', 'http://localhost:*'],
|
|
81
|
+
webOrigins: desired.webOrigins.length ? desired.webOrigins : ['+'],
|
|
82
|
+
attributes: { [OWNED_ATTRIBUTE]: 'true' },
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (dryRun) {
|
|
86
|
+
return { client: representation, created: true, dryRun: true };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const created = await kcRequest({ ...ctx, method: 'POST', path: '/clients', json: representation });
|
|
90
|
+
if (created.status !== 201 && created.status !== 204 && created.status !== 200) {
|
|
91
|
+
assertOk(created, `Create client ${desired.clientId}`);
|
|
92
|
+
}
|
|
93
|
+
const next = await findClient(ctx, desired.clientId);
|
|
94
|
+
if (next && state) {
|
|
95
|
+
state.clients.push({ id: next.id, clientId: next.clientId });
|
|
96
|
+
}
|
|
97
|
+
return { client: next || representation, created: true };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function ensureRole(ctx, name, dryRun, state) {
|
|
101
|
+
const existing = await findRole(ctx, name);
|
|
102
|
+
if (existing) {
|
|
103
|
+
return { role: existing, created: false };
|
|
104
|
+
}
|
|
105
|
+
if (dryRun) {
|
|
106
|
+
return { role: { name }, created: true, dryRun: true };
|
|
107
|
+
}
|
|
108
|
+
const created = await kcRequest({
|
|
109
|
+
...ctx,
|
|
110
|
+
method: 'POST',
|
|
111
|
+
path: '/roles',
|
|
112
|
+
json: { name, description: `CRUDForge bootstrap role ${name}` },
|
|
113
|
+
});
|
|
114
|
+
if (created.status !== 201 && created.status !== 204 && created.status !== 200) {
|
|
115
|
+
assertOk(created, `Create realm role ${name}`);
|
|
116
|
+
}
|
|
117
|
+
const next = await findRole(ctx, name);
|
|
118
|
+
if (next && state) {
|
|
119
|
+
state.roles.push({ name: next.name, id: next.id });
|
|
120
|
+
}
|
|
121
|
+
return { role: next || { name }, created: true };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function ensureUser(ctx, user, resolvePassword, { dryRun, resetExistingPasswords, state }) {
|
|
125
|
+
const existing = await findUserByUsername(ctx, user.username);
|
|
126
|
+
if (existing) {
|
|
127
|
+
if (resetExistingPasswords) {
|
|
128
|
+
if (!dryRun) {
|
|
129
|
+
const reset = await kcRequest({
|
|
130
|
+
...ctx,
|
|
131
|
+
method: 'PUT',
|
|
132
|
+
path: `/users/${existing.id}/reset-password`,
|
|
133
|
+
json: {
|
|
134
|
+
type: 'password',
|
|
135
|
+
value: resolvePassword(user),
|
|
136
|
+
temporary: !!user.temporaryPassword,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
assertOk(reset, `Reset password for ${user.username}`);
|
|
140
|
+
}
|
|
141
|
+
return { user: existing, created: false, passwordReset: true };
|
|
142
|
+
}
|
|
143
|
+
return { user: existing, created: false, passwordReset: false };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const representation = {
|
|
147
|
+
username: user.username,
|
|
148
|
+
enabled: user.enabled !== false,
|
|
149
|
+
email: user.email || undefined,
|
|
150
|
+
firstName: user.firstName || undefined,
|
|
151
|
+
lastName: user.lastName || undefined,
|
|
152
|
+
emailVerified: false,
|
|
153
|
+
credentials: [
|
|
154
|
+
{
|
|
155
|
+
type: 'password',
|
|
156
|
+
value: resolvePassword(user),
|
|
157
|
+
temporary: !!user.temporaryPassword,
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
attributes: { [OWNED_ATTRIBUTE]: ['true'] },
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
if (dryRun) {
|
|
164
|
+
return { user: { username: user.username }, created: true, dryRun: true };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const created = await kcRequest({ ...ctx, method: 'POST', path: '/users', json: representation });
|
|
168
|
+
if (created.status !== 201 && created.status !== 204 && created.status !== 200) {
|
|
169
|
+
assertOk(created, `Create user ${user.username}`);
|
|
170
|
+
}
|
|
171
|
+
const next = await findUserByUsername(ctx, user.username);
|
|
172
|
+
if (next && state) {
|
|
173
|
+
state.users.push({ id: next.id, username: next.username });
|
|
174
|
+
}
|
|
175
|
+
return { user: next || { username: user.username }, created: true };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function ensureRealmRoleOnUser(ctx, userId, role, dryRun, state) {
|
|
179
|
+
const mapped = await kcRequest({ ...ctx, method: 'GET', path: `/users/${userId}/role-mappings/realm` });
|
|
180
|
+
assertOk(mapped, `List realm roles for user ${userId}`);
|
|
181
|
+
const already = (Array.isArray(mapped.body) ? mapped.body : []).some((entry) => entry.name === role.name);
|
|
182
|
+
if (already) {
|
|
183
|
+
return { assigned: false };
|
|
184
|
+
}
|
|
185
|
+
if (dryRun) {
|
|
186
|
+
return { assigned: true, dryRun: true };
|
|
187
|
+
}
|
|
188
|
+
const assign = await kcRequest({
|
|
189
|
+
...ctx,
|
|
190
|
+
method: 'POST',
|
|
191
|
+
path: `/users/${userId}/role-mappings/realm`,
|
|
192
|
+
json: [{ id: role.id, name: role.name }],
|
|
193
|
+
});
|
|
194
|
+
assertOk(assign, `Assign role ${role.name} to user ${userId}`);
|
|
195
|
+
if (state) {
|
|
196
|
+
state.assignments.push({ userId, role: role.name });
|
|
197
|
+
}
|
|
198
|
+
return { assigned: true };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async function runKeycloakAdminRestBootstrap({
|
|
202
|
+
serverUrl,
|
|
203
|
+
realm,
|
|
204
|
+
token,
|
|
205
|
+
forwardedProto,
|
|
206
|
+
desired,
|
|
207
|
+
dryRun,
|
|
208
|
+
resetExistingPasswords,
|
|
209
|
+
resolveUserPassword,
|
|
210
|
+
state,
|
|
211
|
+
}) {
|
|
212
|
+
const ctx = { serverUrl, realm, token, forwardedProto };
|
|
213
|
+
const plan = [];
|
|
214
|
+
const result = { adapter: 'keycloak-admin-rest', created: [], skipped: [] };
|
|
215
|
+
|
|
216
|
+
const clientOutcome = await ensureClient(ctx, desired, dryRun, state);
|
|
217
|
+
if (clientOutcome.unmanaged) {
|
|
218
|
+
plan.push(
|
|
219
|
+
`Client ${desired.clientId} already exists (unmanaged); using as-is without modifications`
|
|
220
|
+
);
|
|
221
|
+
} else {
|
|
222
|
+
plan.push(
|
|
223
|
+
clientOutcome.created
|
|
224
|
+
? `${dryRun ? 'Would create' : 'Created'} client ${desired.clientId}`
|
|
225
|
+
: `Client ${desired.clientId} already exists (owned); skipped create`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
result[clientOutcome.created ? 'created' : 'skipped'].push({
|
|
229
|
+
type: 'client',
|
|
230
|
+
id: desired.clientId,
|
|
231
|
+
unmanaged: !!clientOutcome.unmanaged,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const roleRecords = {};
|
|
235
|
+
for (const roleName of desired.roles) {
|
|
236
|
+
const outcome = await ensureRole(ctx, roleName, dryRun, state);
|
|
237
|
+
roleRecords[roleName] = outcome.role;
|
|
238
|
+
plan.push(
|
|
239
|
+
outcome.created
|
|
240
|
+
? `${dryRun ? 'Would create' : 'Created'} role ${roleName}`
|
|
241
|
+
: `Role ${roleName} already exists; skipped create`
|
|
242
|
+
);
|
|
243
|
+
result[outcome.created ? 'created' : 'skipped'].push({ type: 'role', id: roleName });
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
for (const user of desired.users) {
|
|
247
|
+
const outcome = await ensureUser(ctx, user, resolveUserPassword, {
|
|
248
|
+
dryRun,
|
|
249
|
+
resetExistingPasswords,
|
|
250
|
+
state,
|
|
251
|
+
});
|
|
252
|
+
plan.push(
|
|
253
|
+
outcome.created
|
|
254
|
+
? `${dryRun ? 'Would create' : 'Created'} user ${user.username}`
|
|
255
|
+
: `User ${user.username} already exists; ${
|
|
256
|
+
outcome.passwordReset ? 'password reset requested' : 'password left unchanged'
|
|
257
|
+
}`
|
|
258
|
+
);
|
|
259
|
+
result[outcome.created ? 'created' : 'skipped'].push({ type: 'user', id: user.username });
|
|
260
|
+
|
|
261
|
+
const userId = outcome.user && outcome.user.id;
|
|
262
|
+
const roleNames = Array.isArray(user.roles) ? user.roles : [];
|
|
263
|
+
for (const roleName of roleNames) {
|
|
264
|
+
let role = roleRecords[roleName];
|
|
265
|
+
if (!role || !role.id) {
|
|
266
|
+
const ensured = await ensureRole(ctx, roleName, dryRun, state);
|
|
267
|
+
role = ensured.role;
|
|
268
|
+
roleRecords[roleName] = role;
|
|
269
|
+
}
|
|
270
|
+
if (!userId || !role || !role.id) {
|
|
271
|
+
if (dryRun) {
|
|
272
|
+
plan.push(`Would assign role ${roleName} to ${user.username}`);
|
|
273
|
+
}
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const assigned = await ensureRealmRoleOnUser(ctx, userId, role, dryRun, state);
|
|
277
|
+
plan.push(
|
|
278
|
+
assigned.assigned
|
|
279
|
+
? `${dryRun ? 'Would assign' : 'Assigned'} role ${roleName} to ${user.username}`
|
|
280
|
+
: `Role ${roleName} already on ${user.username}`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return { plan, result };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function deleteTrackedResources(ctx, state) {
|
|
289
|
+
const deleted = [];
|
|
290
|
+
for (const user of [...(state.users || [])].reverse()) {
|
|
291
|
+
if (!user.id) continue;
|
|
292
|
+
const response = await kcRequest({ ...ctx, method: 'DELETE', path: `/users/${user.id}` });
|
|
293
|
+
if (response.status === 204 || response.status === 200 || response.status === 404) {
|
|
294
|
+
deleted.push({ type: 'user', id: user.username || user.id });
|
|
295
|
+
} else {
|
|
296
|
+
assertOk(response, `Delete user ${user.username || user.id}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
for (const role of [...(state.roles || [])].reverse()) {
|
|
300
|
+
if (!role.name) continue;
|
|
301
|
+
const response = await kcRequest({ ...ctx, method: 'DELETE', path: `/roles/${encodeURIComponent(role.name)}` });
|
|
302
|
+
if (response.status === 204 || response.status === 200 || response.status === 404) {
|
|
303
|
+
deleted.push({ type: 'role', id: role.name });
|
|
304
|
+
} else {
|
|
305
|
+
assertOk(response, `Delete role ${role.name}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
for (const client of [...(state.clients || [])].reverse()) {
|
|
309
|
+
if (!client.id) continue;
|
|
310
|
+
const live = await kcRequest({ ...ctx, method: 'GET', path: `/clients/${client.id}` });
|
|
311
|
+
if (live.status === 404) {
|
|
312
|
+
deleted.push({ type: 'client', id: client.clientId || client.id });
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
assertOk(live, `Read tracked client ${client.clientId}`);
|
|
316
|
+
if (!isOwnedClient(live.body)) {
|
|
317
|
+
throw new Error(`Refusing to delete unmanaged client ${client.clientId}.`);
|
|
318
|
+
}
|
|
319
|
+
const response = await kcRequest({ ...ctx, method: 'DELETE', path: `/clients/${client.id}` });
|
|
320
|
+
if (response.status === 204 || response.status === 200 || response.status === 404) {
|
|
321
|
+
deleted.push({ type: 'client', id: client.clientId || client.id });
|
|
322
|
+
} else {
|
|
323
|
+
assertOk(response, `Delete client ${client.clientId}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return deleted;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
module.exports = {
|
|
330
|
+
runKeycloakAdminRestBootstrap,
|
|
331
|
+
deleteTrackedResources,
|
|
332
|
+
findClient,
|
|
333
|
+
OWNED_ATTRIBUTE,
|
|
334
|
+
realmAdminUrl,
|
|
335
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function emptyState() {
|
|
5
|
+
return {
|
|
6
|
+
createdAt: new Date().toISOString(),
|
|
7
|
+
adapter: '',
|
|
8
|
+
realm: '',
|
|
9
|
+
clients: [],
|
|
10
|
+
roles: [],
|
|
11
|
+
users: [],
|
|
12
|
+
assignments: [],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function resolveStatePath(config, cwd = process.cwd()) {
|
|
17
|
+
const relative = config.auth?.provision?.stateFile || '.crudforge/provision-state.json';
|
|
18
|
+
return path.isAbsolute(relative) ? relative : path.join(cwd, relative);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function readState(filePath) {
|
|
22
|
+
if (!fs.existsSync(filePath)) {
|
|
23
|
+
return emptyState();
|
|
24
|
+
}
|
|
25
|
+
return { ...emptyState(), ...fs.readJsonSync(filePath) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function writeState(filePath, state) {
|
|
29
|
+
fs.ensureDirSync(path.dirname(filePath));
|
|
30
|
+
const next = { ...state, updatedAt: new Date().toISOString() };
|
|
31
|
+
fs.writeJsonSync(filePath, next, { spaces: 2 });
|
|
32
|
+
return next;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function track(state, collection, item, key = 'id') {
|
|
36
|
+
const list = Array.isArray(state[collection]) ? state[collection] : [];
|
|
37
|
+
const exists = list.some((entry) => entry && item && entry[key] && entry[key] === item[key]);
|
|
38
|
+
if (!exists) {
|
|
39
|
+
list.push(item);
|
|
40
|
+
}
|
|
41
|
+
state[collection] = list;
|
|
42
|
+
return state;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
emptyState,
|
|
47
|
+
resolveStatePath,
|
|
48
|
+
readState,
|
|
49
|
+
writeState,
|
|
50
|
+
track,
|
|
51
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const { request, assertOk } = require('./http');
|
|
2
|
+
|
|
3
|
+
async function fetchPasswordToken({
|
|
4
|
+
tokenUrl,
|
|
5
|
+
clientId,
|
|
6
|
+
username,
|
|
7
|
+
password,
|
|
8
|
+
forwardedProto,
|
|
9
|
+
}) {
|
|
10
|
+
if (!tokenUrl) {
|
|
11
|
+
throw new Error('Token URL is missing. Set auth.serverUrl/auth.tokenUrl or derive them from realm.');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const headers = {};
|
|
15
|
+
if (forwardedProto) {
|
|
16
|
+
headers['X-Forwarded-Proto'] = forwardedProto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const response = await request({
|
|
20
|
+
method: 'POST',
|
|
21
|
+
url: tokenUrl,
|
|
22
|
+
headers,
|
|
23
|
+
form: {
|
|
24
|
+
grant_type: 'password',
|
|
25
|
+
client_id: clientId,
|
|
26
|
+
username,
|
|
27
|
+
password,
|
|
28
|
+
scope: 'openid',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (response.status === 401 || response.status === 403) {
|
|
33
|
+
const desc =
|
|
34
|
+
response.body && typeof response.body === 'object'
|
|
35
|
+
? response.body.error_description || response.body.error
|
|
36
|
+
: '';
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Provisioning login failed against ${tokenUrl} using token client "${clientId}" (HTTP ${response.status})${
|
|
39
|
+
desc ? `: ${desc}` : ''
|
|
40
|
+
}. Check KEYCLOAK_ADMIN_USERNAME / KEYCLOAK_ADMIN_PASSWORD and that the token client allows direct access grants.`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
assertOk(response, `Request access token from ${tokenUrl}`);
|
|
45
|
+
const token = response.body && response.body.access_token;
|
|
46
|
+
if (!token) {
|
|
47
|
+
throw new Error(`Token response from ${tokenUrl} did not include access_token.`);
|
|
48
|
+
}
|
|
49
|
+
return token;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = { fetchPasswordToken };
|