@etus/bhono-app 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +13 -0
- package/dist/cli.js +46 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.test.d.ts +1 -0
- package/dist/cli.test.js +26 -0
- package/dist/cli.test.js.map +1 -0
- package/dist/generator.d.ts +14 -0
- package/dist/generator.js +142 -0
- package/dist/generator.js.map +1 -0
- package/dist/generator.test.d.ts +1 -0
- package/dist/generator.test.js +127 -0
- package/dist/generator.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +25 -0
- package/dist/prompts.js +83 -0
- package/dist/prompts.js.map +1 -0
- package/dist/prompts.test.d.ts +1 -0
- package/dist/prompts.test.js +24 -0
- package/dist/prompts.test.js.map +1 -0
- package/dist/providers/cloudflare.d.ts +37 -0
- package/dist/providers/cloudflare.js +61 -0
- package/dist/providers/cloudflare.js.map +1 -0
- package/dist/providers/cloudflare.test.d.ts +1 -0
- package/dist/providers/cloudflare.test.js +29 -0
- package/dist/providers/cloudflare.test.js.map +1 -0
- package/dist/providers/github.d.ts +16 -0
- package/dist/providers/github.js +57 -0
- package/dist/providers/github.js.map +1 -0
- package/dist/providers/github.test.d.ts +1 -0
- package/dist/providers/github.test.js +16 -0
- package/dist/providers/github.test.js.map +1 -0
- package/dist/templates.d.ts +8 -0
- package/dist/templates.js +88 -0
- package/dist/templates.js.map +1 -0
- package/dist/templates.test.d.ts +1 -0
- package/dist/templates.test.js +26 -0
- package/dist/templates.test.js.map +1 -0
- package/package.json +36 -0
- package/templates/base/.claude/agents/architect-review.md +160 -0
- package/templates/base/.claude/agents/backend-architect.md +308 -0
- package/templates/base/.claude/agents/code-reviewer.md +170 -0
- package/templates/base/.claude/agents/performance-engineer.md +166 -0
- package/templates/base/.claude/agents/test-automator.md +219 -0
- package/templates/base/.claude/commands/check-skill-rules.md +53 -0
- package/templates/base/.claude/commands/claude-md.md +250 -0
- package/templates/base/.claude/commands/code-prompt.md +212 -0
- package/templates/base/.claude/commands/explain-code.md +194 -0
- package/templates/base/.claude/commands/init-projec.md +89 -0
- package/templates/base/.claude/commands/linear/README.md +297 -0
- package/templates/base/.claude/commands/linear/create-issue.md +190 -0
- package/templates/base/.claude/commands/linear/implement-issue.md +248 -0
- package/templates/base/.claude/commands/linear/process-triage.md +399 -0
- package/templates/base/.claude/commands/linear/setup.md +180 -0
- package/templates/base/.claude/commands/prime.md +9 -0
- package/templates/base/.claude/commands/review-gap.md +10 -0
- package/templates/base/.claude/commands/setup-aa.md +311 -0
- package/templates/base/.claude/commands/ship.md +262 -0
- package/templates/base/.claude/commands/tools.md +3 -0
- package/templates/base/.claude/docs/claude-progress.txt +107 -0
- package/templates/base/.claude/hooks/package-lock.json +556 -0
- package/templates/base/.claude/hooks/package.json +16 -0
- package/templates/base/.claude/hooks/skill-activation-prompt.sh +7 -0
- package/templates/base/.claude/hooks/skill-activation-prompt.ts +142 -0
- package/templates/base/.claude/hooks/tsconfig.json +19 -0
- package/templates/base/.claude/scripts/check-updates.sh +85 -0
- package/templates/base/.claude/scripts/install_pkgs.sh +66 -0
- package/templates/base/.claude/scripts/setup-project.sh +177 -0
- package/templates/base/.claude/scripts/validate-skill-rules.sh +94 -0
- package/templates/base/.claude/settings.json +113 -0
- package/templates/base/.claude/settings.local.json +11 -0
- package/templates/base/.claude/skills/architecture-analyzer/SKILL.md +531 -0
- package/templates/base/.claude/skills/architecture-analyzer/assets/report-template.md +215 -0
- package/templates/base/.claude/skills/architecture-analyzer/references/c4-templates.md +234 -0
- package/templates/base/.claude/skills/architecture-analyzer/references/confidence-levels.md +203 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/analyze_structure.py +266 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/analyze_tech_debt.py +776 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/extract_apis.py +338 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/generate_c4.py +283 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/generate_erd.py +935 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/map_dependencies.py +555 -0
- package/templates/base/.claude/skills/dev-browser/SKILL.md +318 -0
- package/templates/base/.claude/skills/dev-browser/bun.lock +443 -0
- package/templates/base/.claude/skills/dev-browser/package-lock.json +2927 -0
- package/templates/base/.claude/skills/dev-browser/package.json +27 -0
- package/templates/base/.claude/skills/dev-browser/scripts/start-server.ts +117 -0
- package/templates/base/.claude/skills/dev-browser/server.sh +24 -0
- package/templates/base/.claude/skills/dev-browser/src/client.ts +403 -0
- package/templates/base/.claude/skills/dev-browser/src/index.ts +281 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/browser-script.ts +877 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/index.ts +14 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/inject.ts +13 -0
- package/templates/base/.claude/skills/dev-browser/src/types.ts +27 -0
- package/templates/base/.claude/skills/dev-browser/tsconfig.json +36 -0
- package/templates/base/.claude/skills/dev-browser/vitest.config.ts +12 -0
- package/templates/base/.claude/skills/linear/SKILL.md +440 -0
- package/templates/base/.claude/skills/linear/examples.md +262 -0
- package/templates/base/.claude/skills/linear/lib/client.ts +51 -0
- package/templates/base/.claude/skills/linear/lib/config.ts +106 -0
- package/templates/base/.claude/skills/linear/lib/output.ts +34 -0
- package/templates/base/.claude/skills/linear/package-lock.json +698 -0
- package/templates/base/.claude/skills/linear/package.json +27 -0
- package/templates/base/.claude/skills/linear/reference.md +263 -0
- package/templates/base/.claude/skills/linear/scripts/comments/create.ts +47 -0
- package/templates/base/.claude/skills/linear/scripts/comments/list.ts +47 -0
- package/templates/base/.claude/skills/linear/scripts/issues/archive.ts +30 -0
- package/templates/base/.claude/skills/linear/scripts/issues/create.ts +279 -0
- package/templates/base/.claude/skills/linear/scripts/issues/get.ts +68 -0
- package/templates/base/.claude/skills/linear/scripts/issues/list.ts +67 -0
- package/templates/base/.claude/skills/linear/scripts/issues/update.ts +281 -0
- package/templates/base/.claude/skills/linear/scripts/labels/add-to-issue.ts +63 -0
- package/templates/base/.claude/skills/linear/scripts/labels/create.ts +45 -0
- package/templates/base/.claude/skills/linear/scripts/labels/list.ts +30 -0
- package/templates/base/.claude/skills/linear/scripts/list-teams.ts +52 -0
- package/templates/base/.claude/skills/linear/scripts/setup/setup-credentials.ts +96 -0
- package/templates/base/.claude/skills/linear/scripts/status/list.ts +31 -0
- package/templates/base/.claude/skills/linear/scripts/status/set-by-name.ts +78 -0
- package/templates/base/.claude/skills/linear/scripts/status/update.ts +44 -0
- package/templates/base/.claude/skills/linear/scripts/users/list.ts +59 -0
- package/templates/base/.claude/skills/linear/scripts/users/me.ts +20 -0
- package/templates/base/.claude/skills/linear/templates/README.md +203 -0
- package/templates/base/.claude/skills/linear/templates/api-reference.md +258 -0
- package/templates/base/.claude/skills/linear/templates/bug-report.md +99 -0
- package/templates/base/.claude/skills/linear/templates/feature-request.md +118 -0
- package/templates/base/.claude/skills/linear/templates/security-issue.md +162 -0
- package/templates/base/.claude/skills/linear/templates/sprint-task.md +175 -0
- package/templates/base/.claude/skills/linear/templates/tech-debt.md +137 -0
- package/templates/base/.claude/skills/linear/tsconfig.json +17 -0
- package/templates/base/.claude/skills/linear/workflows/issue-lifecycle.md +317 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/SKILL.md +113 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/global-setup.template.js +97 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/playwright.config.template.js +171 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/test-template.spec.js +163 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/README.md +26 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/ads.email-deeplink.spec.ts +12 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/mobile.realism.spec.ts +16 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/smoke.home.spec.ts +6 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/architecture.md +578 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/best-practices.md +260 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/ci-reporting.md +86 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/debugging.md +629 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/mobile-realism.md +50 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/optimization.md +488 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/patterns.md +513 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/resources.md +44 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/visual-a11y.md +66 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/auth-setup.js +202 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/performance-analyzer.js +240 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/trace-url.js +132 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/ci/github-actions.playwright.yml +78 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/fixtures.ts +44 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/global-setup.template.js +97 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/global.setup.ts +35 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/helpers/ad-gpt-observer.ts +80 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/helpers/chromium-mobile-profile.ts +93 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/playwright.config.template.js +171 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/playwright.config.ts +126 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/test-template.spec.js +163 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/tests/email-deeplink.ads.spec.ts +44 -0
- package/templates/base/.claude/skills/skill-rules.json +184 -0
- package/templates/base/.claude/skills/wrangler/SKILL.md +209 -0
- package/templates/base/.claude/skills/wrangler/resources/api.md +494 -0
- package/templates/base/.claude/skills/wrangler/resources/bundling.md +83 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/cert.md +64 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/check.md +66 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/containers.md +157 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/d1.md +843 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/delete.md +27 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/deploy.md +139 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/deployments.md +56 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/dev.md +157 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/dispatch-namespace.md +69 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/docs.md +61 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/how-to-run.md +62 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/hyperdrive.md +425 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/init.md +31 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-bulk.md +265 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-key.md +353 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-namespace.md +265 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/login.md +23 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/logout.md +19 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/mtls-certificate.md +69 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/pages.md +175 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/pipelines.md +76 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/queues.md +132 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-bucket.md +342 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-object.md +267 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-sql.md +65 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/rollback.md +40 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secret.md +308 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secrets-store-secret.md +100 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secrets-store-store.md +60 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/setup.md +67 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/tail.md +37 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/telemetry.md +64 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/triggers.md +39 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/types.md +73 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/vectorize.md +941 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/versions.md +95 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/whoami.md +49 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/workflows.md +117 -0
- package/templates/base/.claude/skills/wrangler/resources/commands.md +138 -0
- package/templates/base/.claude/skills/wrangler/resources/configuration.md +2176 -0
- package/templates/base/.claude/skills/wrangler/resources/custom-builds.md +55 -0
- package/templates/base/.claude/skills/wrangler/resources/deprecations.md +279 -0
- package/templates/base/.claude/skills/wrangler/resources/enviroments.md +416 -0
- package/templates/base/.claude/skills/wrangler/resources/extract_sections.py +119 -0
- package/templates/base/.claude/skills/wrangler/resources/process_content.py +94 -0
- package/templates/base/.claude/skills/wrangler/resources/system-enviroments-variables.md +120 -0
- package/templates/base/.dev.vars.example +15 -0
- package/templates/base/.env.example +29 -0
- package/templates/base/.github/workflows/test.yml +127 -0
- package/templates/base/.nycrc.json +16 -0
- package/templates/base/CLAUDE.md +218 -0
- package/templates/base/README.md +670 -0
- package/templates/base/auth-setup-error.png +0 -0
- package/templates/base/config/drizzle.config.ts +10 -0
- package/templates/base/config/eslint.config.js +364 -0
- package/templates/base/config/wrangler.json +76 -0
- package/templates/base/docs/app_spec.txt +879 -0
- package/templates/base/docs/app_spec_template.md +681 -0
- package/templates/base/docs/architecture/README.md +8 -0
- package/templates/base/docs/architecture/data-requirements.md +109 -0
- package/templates/base/docs/architecture/erd.md +91 -0
- package/templates/base/docs/features/feature_list.json +3128 -0
- package/templates/base/docs/hono-boilerplate-plan.md +1774 -0
- package/templates/base/docs/test-coverage-gap-analysis.md +242 -0
- package/templates/base/docs/testing.md +188 -0
- package/templates/base/index.html +16 -0
- package/templates/base/package.json +115 -0
- package/templates/base/playwright.config.ts +158 -0
- package/templates/base/pnpm-lock.yaml +8175 -0
- package/templates/base/scripts/capture-prod-session.ts +250 -0
- package/templates/base/scripts/generate-openapi.ts +23 -0
- package/templates/base/scripts/init.sh +121 -0
- package/templates/base/src/client/__tests__/button.test.tsx +30 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-dashboard-stats-cards-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-quick-action-cards-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-recent-activity-section-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-user-first-name-in-welcome-message-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-user-information-in-sidebar-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-render-dashboard-when-authenticated-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-show-navigation-sidebar-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-unauthenticated-should-redirect-to-login-when-not-authenticated-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-display-Google-OAuth-login-button-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-have-a-link-back-to-home-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-render-login-content-without-waiting-for-authentication-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-render-login-page-at--login-route-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-show-Terms-of-Service-and-Privacy-Policy-links-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-trigger-OAuth-flow-when-clicking-login-button-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-display-404-text-on-not-found-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-have-navigation-options-on-404-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-render-404-page-for-unknown-routes-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-account-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-integrations-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-settings-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-team-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-home-page-navigation-should-display-navigation-links-on-home-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-home-page-navigation-should-have-correct-link-destinations-on-home-page-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-allow-access-to-home-page-without-authentication-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-allow-access-to-login-page-without-authentication-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-dashboard-to-login-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-settings-to-login-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-team-to-login-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/authenticated-layout.test.tsx +252 -0
- package/templates/base/src/client/__tests__/routes/dashboard.test.tsx +136 -0
- package/templates/base/src/client/__tests__/routes/error-components.test.tsx +186 -0
- package/templates/base/src/client/__tests__/routes/login.test.tsx +112 -0
- package/templates/base/src/client/__tests__/routes/navigation.test.tsx +272 -0
- package/templates/base/src/client/__tests__/routes/root-layout.test.tsx +65 -0
- package/templates/base/src/client/__tests__/setup-browser.ts +15 -0
- package/templates/base/src/client/__tests__/setup.ts +32 -0
- package/templates/base/src/client/__tests__/test-utils.tsx +135 -0
- package/templates/base/src/client/api/.gitkeep +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-can-be-collapsed-by-default-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-expands-when-collapsed-and-expand-button-is-clicked-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-handles-logout-button-click-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-handles-navigation-clicks-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-hides-navigation-labels-when-collapsed-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-highlights-active-route-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-renders-sidebar-navigation-items-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-keyboard-shortcut-hint-when-expanded-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-info-when-authenticated-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-initials-in-avatar-fallback-1.png +0 -0
- package/templates/base/src/client/components/__tests__/error-boundary.test.tsx +97 -0
- package/templates/base/src/client/components/__tests__/sidebar.test.tsx +281 -0
- package/templates/base/src/client/components/error-boundary.tsx +68 -0
- package/templates/base/src/client/components/icons.tsx +106 -0
- package/templates/base/src/client/components/layout/.gitkeep +0 -0
- package/templates/base/src/client/components/sidebar.tsx +267 -0
- package/templates/base/src/client/components/ui/.gitkeep +0 -0
- package/templates/base/src/client/components/ui/__tests__/avatar.test.tsx +308 -0
- package/templates/base/src/client/components/ui/__tests__/card.test.tsx +214 -0
- package/templates/base/src/client/components/ui/__tests__/dialog.test.tsx +297 -0
- package/templates/base/src/client/components/ui/__tests__/error-fallback.test.tsx +145 -0
- package/templates/base/src/client/components/ui/__tests__/input.test.tsx +98 -0
- package/templates/base/src/client/components/ui/__tests__/loading-skeleton.test.tsx +139 -0
- package/templates/base/src/client/components/ui/__tests__/skeleton.test.tsx +44 -0
- package/templates/base/src/client/components/ui/__tests__/sonner.test.tsx +28 -0
- package/templates/base/src/client/components/ui/__tests__/tabs.test.tsx +233 -0
- package/templates/base/src/client/components/ui/avatar.tsx +101 -0
- package/templates/base/src/client/components/ui/badge.tsx +46 -0
- package/templates/base/src/client/components/ui/button.tsx +72 -0
- package/templates/base/src/client/components/ui/card.tsx +86 -0
- package/templates/base/src/client/components/ui/dialog.tsx +140 -0
- package/templates/base/src/client/components/ui/error-fallback.tsx +179 -0
- package/templates/base/src/client/components/ui/form.tsx +172 -0
- package/templates/base/src/client/components/ui/input.tsx +24 -0
- package/templates/base/src/client/components/ui/label.tsx +22 -0
- package/templates/base/src/client/components/ui/loading-skeleton.tsx +154 -0
- package/templates/base/src/client/components/ui/separator.tsx +33 -0
- package/templates/base/src/client/components/ui/skeleton.tsx +16 -0
- package/templates/base/src/client/components/ui/sonner.tsx +29 -0
- package/templates/base/src/client/components/ui/tabs.tsx +121 -0
- package/templates/base/src/client/hooks/.gitkeep +0 -0
- package/templates/base/src/client/hooks/__tests__/use-auth.test.tsx +306 -0
- package/templates/base/src/client/hooks/__tests__/use-theme.test.tsx +172 -0
- package/templates/base/src/client/hooks/use-auth.ts +53 -0
- package/templates/base/src/client/hooks/use-theme.tsx +78 -0
- package/templates/base/src/client/index.css +881 -0
- package/templates/base/src/client/lib/query-client.ts +11 -0
- package/templates/base/src/client/lib/utils.ts +7 -0
- package/templates/base/src/client/main.tsx +26 -0
- package/templates/base/src/client/routeTree.gen.ts +258 -0
- package/templates/base/src/client/router.ts +15 -0
- package/templates/base/src/client/routes/$.tsx +77 -0
- package/templates/base/src/client/routes/.gitkeep +0 -0
- package/templates/base/src/client/routes/__root.tsx +34 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-accept-invitation-button-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-decline-button-linking-to-homepage-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-invitation-details--email--workspace--role--1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-have-a-logo-link-to-homepage-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-render-invitation-page-with-inviter-name-and-workspace-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-show-terms-of-service-and-privacy-policy-links-1.png +0 -0
- package/templates/base/src/client/routes/__tests__/invite.test.tsx +138 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-render-Active-Sessions-section-with-session-cards-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-render-page-with-correct-title--Account--1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-API-Access-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-Connected-Accounts-section-with-Google-connected-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-Danger-Zone-section-with-delete-button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/account.test.tsx/Account-Page-should-show-Security-section-with-Two-Factor-Authentication-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-API-documentation-section-should-display-API-documentation-link-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-Create-Webhook-Dialog-should-have-Add-Webhook-trigger-button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-category-filters-should-display-all-category-buttons-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-display-all-integration-cards-with-names-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-display-category-badges-on-cards-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Configure-button-for-connected-integrations-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Connect-button-for-not-connected-integrations-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Connected-badge-for-connected-integrations-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-Available-Integrations-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-Webhooks-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-connected-count-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-page-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-search-input-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-render-with-correct-title--Integrations--1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-filter-integrations-based-on-search-query-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-search-by-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-show-no-results-message-when-search-has-no-matches-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-existing-webhook-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-events-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-last-delivery-info-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-success-status-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-have-Add-Webhook-button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Account-tab-should-display-connected-accounts-section-with-Google-provider-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Account-tab-should-display-sessions-and-danger-zone-sections-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-all-notification-toggle-options-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-email-notifications-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-toggle-switches-for-notification-options-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-have-toggles-checked-by-default-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display--Save-Changes--button-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-personal-information-form-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-profile-picture-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-email-in-disabled-email-input-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-initials-in-avatar-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-name-in-the-name-input-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-display-all-three-tabs-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-display-page-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-render-with-correct-title--Settings--1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-show-Profile-tab-as-default-active-tab-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-switch-to-Account-tab-when-clicked-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-switch-to-Notifications-tab-when-clicked-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-display-Active-Members-section-with-member-count-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-display-Pending-Invitations-section-with-invitation-details-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-have-invite-member-button-that-can-be-clicked-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-render-page-with-correct-title-and-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-render-search-input-that-filters-team-members-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/team.test.tsx/Team-Page-should-show-current-user-with---you---indicator-and-role-badge-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/account.test.tsx +324 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/integrations.test.tsx +520 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/settings.test.tsx +414 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/team.test.tsx +374 -0
- package/templates/base/src/client/routes/_authenticated/account.tsx +416 -0
- package/templates/base/src/client/routes/_authenticated/dashboard.tsx +151 -0
- package/templates/base/src/client/routes/_authenticated/integrations.tsx +553 -0
- package/templates/base/src/client/routes/_authenticated/settings.tsx +310 -0
- package/templates/base/src/client/routes/_authenticated/team.tsx +395 -0
- package/templates/base/src/client/routes/_authenticated.tsx +69 -0
- package/templates/base/src/client/routes/index.tsx +155 -0
- package/templates/base/src/client/routes/invite.$token.tsx +191 -0
- package/templates/base/src/client/routes/login.tsx +92 -0
- package/templates/base/src/server/__tests__/fixtures.ts +461 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/db.test.ts +239 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/kv.test.ts +293 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/r2.test.ts +363 -0
- package/templates/base/src/server/__tests__/mocks/db.ts +186 -0
- package/templates/base/src/server/__tests__/mocks/index.ts +33 -0
- package/templates/base/src/server/__tests__/mocks/kv.ts +286 -0
- package/templates/base/src/server/__tests__/mocks/r2.ts +397 -0
- package/templates/base/src/server/__tests__/setup.ts +281 -0
- package/templates/base/src/server/auth/__tests__/guards.test.ts +162 -0
- package/templates/base/src/server/auth/guards.ts +92 -0
- package/templates/base/src/server/auth/permissions.test.ts +45 -0
- package/templates/base/src/server/auth/permissions.ts +139 -0
- package/templates/base/src/server/auth/roles.test.ts +169 -0
- package/templates/base/src/server/auth/roles.ts +141 -0
- package/templates/base/src/server/db/client.ts +12 -0
- package/templates/base/src/server/db/schema/accounts.ts +20 -0
- package/templates/base/src/server/db/schema/audit-logs.ts +26 -0
- package/templates/base/src/server/db/schema/index.ts +7 -0
- package/templates/base/src/server/db/schema/invitations.ts +30 -0
- package/templates/base/src/server/db/schema/refresh-tokens.ts +22 -0
- package/templates/base/src/server/db/schema/user-accounts.ts +25 -0
- package/templates/base/src/server/db/schema/users.ts +33 -0
- package/templates/base/src/server/db/seed.ts +267 -0
- package/templates/base/src/server/env.test.ts +84 -0
- package/templates/base/src/server/env.ts +78 -0
- package/templates/base/src/server/index.ts +82 -0
- package/templates/base/src/server/lib/audit.ts +73 -0
- package/templates/base/src/server/lib/audited-db.test.ts +107 -0
- package/templates/base/src/server/lib/audited-db.ts +154 -0
- package/templates/base/src/server/lib/email.test.ts +116 -0
- package/templates/base/src/server/lib/email.ts +82 -0
- package/templates/base/src/server/lib/errors.test.ts +49 -0
- package/templates/base/src/server/lib/errors.ts +64 -0
- package/templates/base/src/server/lib/oauth.test.ts +238 -0
- package/templates/base/src/server/lib/oauth.ts +113 -0
- package/templates/base/src/server/lib/pagination.test.ts +52 -0
- package/templates/base/src/server/lib/pagination.ts +32 -0
- package/templates/base/src/server/lib/password.test.ts +151 -0
- package/templates/base/src/server/lib/password.ts +151 -0
- package/templates/base/src/server/lib/providers.test.ts +105 -0
- package/templates/base/src/server/lib/providers.ts +62 -0
- package/templates/base/src/server/lib/r2-storage.test.ts +202 -0
- package/templates/base/src/server/lib/r2-storage.ts +107 -0
- package/templates/base/src/server/lib/schema-helpers.ts +16 -0
- package/templates/base/src/server/lib/session.test.ts +758 -0
- package/templates/base/src/server/lib/session.ts +267 -0
- package/templates/base/src/server/lib/tokens.test.ts +208 -0
- package/templates/base/src/server/lib/tokens.ts +65 -0
- package/templates/base/src/server/lib/transaction.test.ts +45 -0
- package/templates/base/src/server/lib/transaction.ts +24 -0
- package/templates/base/src/server/middleware/account.test.ts +201 -0
- package/templates/base/src/server/middleware/account.ts +66 -0
- package/templates/base/src/server/middleware/auth.test.ts +345 -0
- package/templates/base/src/server/middleware/auth.ts +146 -0
- package/templates/base/src/server/middleware/cors.test.ts +88 -0
- package/templates/base/src/server/middleware/cors.ts +26 -0
- package/templates/base/src/server/middleware/error-handler.test.ts +69 -0
- package/templates/base/src/server/middleware/error-handler.ts +43 -0
- package/templates/base/src/server/middleware/index.ts +8 -0
- package/templates/base/src/server/middleware/rate-limit.test.ts +472 -0
- package/templates/base/src/server/middleware/rate-limit.ts +294 -0
- package/templates/base/src/server/middleware/request-context.test.ts +175 -0
- package/templates/base/src/server/middleware/request-context.ts +28 -0
- package/templates/base/src/server/middleware/request-logger.test.ts +92 -0
- package/templates/base/src/server/middleware/request-logger.ts +50 -0
- package/templates/base/src/server/routes/accounts/__tests__/handlers.test.ts +460 -0
- package/templates/base/src/server/routes/accounts/handlers.ts +179 -0
- package/templates/base/src/server/routes/accounts/index.ts +55 -0
- package/templates/base/src/server/routes/accounts/routes.ts +205 -0
- package/templates/base/src/server/routes/accounts/schemas.ts +31 -0
- package/templates/base/src/server/routes/api.ts +37 -0
- package/templates/base/src/server/routes/audits/__tests__/handlers.test.ts +349 -0
- package/templates/base/src/server/routes/audits/handlers.ts +37 -0
- package/templates/base/src/server/routes/audits/index.ts +14 -0
- package/templates/base/src/server/routes/audits/routes.ts +29 -0
- package/templates/base/src/server/routes/audits/schemas.ts +43 -0
- package/templates/base/src/server/routes/auth/__tests__/handlers.test.ts +381 -0
- package/templates/base/src/server/routes/auth/handlers.ts +222 -0
- package/templates/base/src/server/routes/auth/index.ts +37 -0
- package/templates/base/src/server/routes/auth/routes.ts +136 -0
- package/templates/base/src/server/routes/auth/schemas.ts +48 -0
- package/templates/base/src/server/routes/auth/test-login.ts +156 -0
- package/templates/base/src/server/routes/health/__tests__/handlers.test.ts +237 -0
- package/templates/base/src/server/routes/health/handlers.ts +83 -0
- package/templates/base/src/server/routes/health/index.ts +13 -0
- package/templates/base/src/server/routes/health/routes.ts +90 -0
- package/templates/base/src/server/routes/index.ts +53 -0
- package/templates/base/src/server/routes/invitations/__tests__/handlers.test.ts +473 -0
- package/templates/base/src/server/routes/invitations/handlers.ts +71 -0
- package/templates/base/src/server/routes/invitations/index.ts +25 -0
- package/templates/base/src/server/routes/invitations/routes.ts +69 -0
- package/templates/base/src/server/routes/invitations/schemas.ts +39 -0
- package/templates/base/src/server/routes/openapi.ts +14 -0
- package/templates/base/src/server/routes/schemas.ts +53 -0
- package/templates/base/src/server/routes/storage/__tests__/handlers.test.ts +408 -0
- package/templates/base/src/server/routes/storage/handlers.ts +100 -0
- package/templates/base/src/server/routes/storage/index.ts +42 -0
- package/templates/base/src/server/routes/storage/routes.ts +91 -0
- package/templates/base/src/server/routes/storage/schemas.ts +56 -0
- package/templates/base/src/server/routes/users/__tests__/handlers.test.ts +526 -0
- package/templates/base/src/server/routes/users/handlers.ts +228 -0
- package/templates/base/src/server/routes/users/index.ts +67 -0
- package/templates/base/src/server/routes/users/routes.ts +265 -0
- package/templates/base/src/server/routes/users/schemas.ts +67 -0
- package/templates/base/src/server/services/__tests__/accounts.test.ts +764 -0
- package/templates/base/src/server/services/__tests__/audits.test.ts +235 -0
- package/templates/base/src/server/services/__tests__/auth.test.ts +765 -0
- package/templates/base/src/server/services/__tests__/invitations.test.ts +704 -0
- package/templates/base/src/server/services/__tests__/users.test.ts +755 -0
- package/templates/base/src/server/services/accounts.ts +269 -0
- package/templates/base/src/server/services/audits.ts +82 -0
- package/templates/base/src/server/services/auth.ts +225 -0
- package/templates/base/src/server/services/index.ts +6 -0
- package/templates/base/src/server/services/invitations.ts +306 -0
- package/templates/base/src/server/services/users.ts +350 -0
- package/templates/base/src/server/types/auth.ts +36 -0
- package/templates/base/src/server/types/index.ts +117 -0
- package/templates/base/src/shared/schemas/.gitkeep +0 -0
- package/templates/base/src/shared/schemas/__tests__/schemas.test.ts +547 -0
- package/templates/base/src/shared/schemas/account.ts +15 -0
- package/templates/base/src/shared/schemas/index.ts +6 -0
- package/templates/base/src/shared/schemas/invitation.ts +9 -0
- package/templates/base/src/shared/schemas/profile.ts +10 -0
- package/templates/base/src/shared/schemas/user.ts +16 -0
- package/templates/base/src/shared/schemas/webhook.ts +12 -0
- package/templates/base/src/shared/types/.gitkeep +0 -0
- package/templates/base/src/shared/types/account.ts +12 -0
- package/templates/base/src/shared/types/api.ts +1399 -0
- package/templates/base/src/shared/types/auth.ts +24 -0
- package/templates/base/src/shared/types/index.ts +5 -0
- package/templates/base/src/shared/types/user.ts +31 -0
- package/templates/base/src/test/vitest-zod-matcher.ts +37 -0
- package/templates/base/src/test/vitest.d.ts +19 -0
- package/templates/base/tests/e2e/README.md +141 -0
- package/templates/base/tests/e2e/a11y/accessibility.spec.ts +925 -0
- package/templates/base/tests/e2e/a11y/keyboard-navigation.spec.ts +610 -0
- package/templates/base/tests/e2e/api/accounts.spec.ts +148 -0
- package/templates/base/tests/e2e/api/audit-logs.spec.ts +130 -0
- package/templates/base/tests/e2e/api/authenticated-api.spec.ts +311 -0
- package/templates/base/tests/e2e/api/storage.spec.ts +109 -0
- package/templates/base/tests/e2e/auth-flows.unauth.spec.ts +117 -0
- package/templates/base/tests/e2e/auth-logout.unauth.spec.ts +103 -0
- package/templates/base/tests/e2e/auth.setup.ts +115 -0
- package/templates/base/tests/e2e/auth.spec.ts +146 -0
- package/templates/base/tests/e2e/compatibility/cross-browser.spec.ts +152 -0
- package/templates/base/tests/e2e/compatibility/cross-browser.spec.ts-snapshots/login-chromium-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/crud/account.spec.ts +356 -0
- package/templates/base/tests/e2e/crud/integrations.spec.ts +419 -0
- package/templates/base/tests/e2e/crud/team.spec.ts +287 -0
- package/templates/base/tests/e2e/crud/users.spec.ts +239 -0
- package/templates/base/tests/e2e/errors/error-boundary.spec.ts +428 -0
- package/templates/base/tests/e2e/errors/error-handling.spec.ts +47 -0
- package/templates/base/tests/e2e/errors/error-handling.unauth.spec.ts +205 -0
- package/templates/base/tests/e2e/fixtures.ts +266 -0
- package/templates/base/tests/e2e/forms/validation.spec.ts +569 -0
- package/templates/base/tests/e2e/invitations/invite-flow.unauth.spec.ts +204 -0
- package/templates/base/tests/e2e/journeys/account-lifecycle.spec.ts +314 -0
- package/templates/base/tests/e2e/journeys/audit-investigation.spec.ts +299 -0
- package/templates/base/tests/e2e/journeys/auth-onboarding.spec.ts +232 -0
- package/templates/base/tests/e2e/journeys/critical-flows.spec.ts +281 -0
- package/templates/base/tests/e2e/journeys/error-recovery.spec.ts +354 -0
- package/templates/base/tests/e2e/journeys/file-management.spec.ts +307 -0
- package/templates/base/tests/e2e/journeys/integrations.spec.ts +372 -0
- package/templates/base/tests/e2e/journeys/multi-account.spec.ts +317 -0
- package/templates/base/tests/e2e/journeys/rbac-enforcement.spec.ts +389 -0
- package/templates/base/tests/e2e/journeys/settings-profile.spec.ts +400 -0
- package/templates/base/tests/e2e/journeys/team-collaboration.spec.ts +410 -0
- package/templates/base/tests/e2e/mobile/responsive.spec.ts +178 -0
- package/templates/base/tests/e2e/navigation/routing.spec.ts +371 -0
- package/templates/base/tests/e2e/navigation/sidebar.spec.ts +425 -0
- package/templates/base/tests/e2e/pages/ui-features.spec.ts +393 -0
- package/templates/base/tests/e2e/performance/baselines.spec.ts +162 -0
- package/templates/base/tests/e2e/performance/benchmarks.spec.ts +371 -0
- package/templates/base/tests/e2e/smoke.unauth.spec.ts +196 -0
- package/templates/base/tests/e2e/visual/components.spec.ts +650 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/confirmation-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-background-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-card-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-sidebar-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dashboard-card-single-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dialog-content-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dialog-with-backdrop-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/empty-search-results-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/input-default-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/input-focus-ring-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-focus-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-hover-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-active-nav-item-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-collapsed-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-navigation-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts +192 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/account-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/create-webhook-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/dashboard-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/delete-account-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/integrations-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/invite-member-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/login-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/settings-account-tab-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/settings-profile-tab-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/sidebar-navigation-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/team-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts +230 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/404-page-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/404-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/account-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/login-page-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/login-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/settings-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/team-invite-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/team-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/webhook-create-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/theme-colors.spec.ts +293 -0
- package/templates/base/tests/e2e/visual/ui-components.spec.ts +502 -0
- package/templates/base/tests/integration/accounts/crud.test.ts +1402 -0
- package/templates/base/tests/integration/audits/list.test.ts +1133 -0
- package/templates/base/tests/integration/auth/auth-service.test.ts +415 -0
- package/templates/base/tests/integration/auth/invitation-token.test.ts +529 -0
- package/templates/base/tests/integration/auth/logout.test.ts +524 -0
- package/templates/base/tests/integration/auth/oauth.test.ts +768 -0
- package/templates/base/tests/integration/auth/refresh-token.test.ts +364 -0
- package/templates/base/tests/integration/auth/session-expiry.test.ts +569 -0
- package/templates/base/tests/integration/auth/session.test.ts +520 -0
- package/templates/base/tests/integration/auth/super-admin.test.ts +451 -0
- package/templates/base/tests/integration/authorization/analytics-role.test.ts +1026 -0
- package/templates/base/tests/integration/authorization/billing-role.test.ts +776 -0
- package/templates/base/tests/integration/authorization/guards-roles.test.ts +539 -0
- package/templates/base/tests/integration/authorization/multi-tenancy.test.ts +1112 -0
- package/templates/base/tests/integration/authorization/role-hierarchy.test.ts +931 -0
- package/templates/base/tests/integration/authorization/roles.test.ts +1347 -0
- package/templates/base/tests/integration/config/production-behavior.test.ts +536 -0
- package/templates/base/tests/integration/db/constraints.test.ts +695 -0
- package/templates/base/tests/integration/fixtures/accounts.ts +136 -0
- package/templates/base/tests/integration/fixtures/index.ts +232 -0
- package/templates/base/tests/integration/fixtures/invitations.ts +195 -0
- package/templates/base/tests/integration/fixtures/users.ts +144 -0
- package/templates/base/tests/integration/health/health.test.ts +351 -0
- package/templates/base/tests/integration/invitations/crud.test.ts +1457 -0
- package/templates/base/tests/integration/invitations/email.test.ts +506 -0
- package/templates/base/tests/integration/lib/email.test.ts +174 -0
- package/templates/base/tests/integration/lib/oauth.test.ts +368 -0
- package/templates/base/tests/integration/lib/password.test.ts +192 -0
- package/templates/base/tests/integration/lib/schema-helpers.test.ts +129 -0
- package/templates/base/tests/integration/lib/tokens.test.ts +304 -0
- package/templates/base/tests/integration/middleware/auth.test.ts +499 -0
- package/templates/base/tests/integration/middleware/cors.test.ts +334 -0
- package/templates/base/tests/integration/middleware/request-context.test.ts +156 -0
- package/templates/base/tests/integration/middleware/request-logger.test.ts +313 -0
- package/templates/base/tests/integration/performance/response-times.test.ts +509 -0
- package/templates/base/tests/integration/security/cookie-security.test.ts +567 -0
- package/templates/base/tests/integration/security/csrf-protection.test.ts +542 -0
- package/templates/base/tests/integration/security/jwt-validation.test.ts +209 -0
- package/templates/base/tests/integration/security/log-sanitization.test.ts +658 -0
- package/templates/base/tests/integration/security/rate-limiting.test.ts +1251 -0
- package/templates/base/tests/integration/security/sql-injection.test.ts +663 -0
- package/templates/base/tests/integration/security/token-hashing.test.ts +371 -0
- package/templates/base/tests/integration/security/xss-prevention.test.ts +541 -0
- package/templates/base/tests/integration/setup.ts +834 -0
- package/templates/base/tests/integration/smoke.test.ts +288 -0
- package/templates/base/tests/integration/storage/upload.test.ts +1162 -0
- package/templates/base/tests/integration/storage/validation.test.ts +746 -0
- package/templates/base/tests/integration/users/crud.test.ts +1297 -0
- package/templates/base/tests/integration/users/list.test.ts +698 -0
- package/templates/base/tests/integration/vitest.config.ts +80 -0
- package/templates/base/tsconfig.app.json +18 -0
- package/templates/base/tsconfig.json +39 -0
- package/templates/base/tsconfig.node.json +16 -0
- package/templates/base/tsconfig.server.json +26 -0
- package/templates/base/tsconfig.tsbuildinfo +1 -0
- package/templates/base/vite.config.ts +46 -0
- package/templates/base/vitest.config.browser.ts +47 -0
- package/templates/base/vitest.config.frontend.ts +47 -0
- package/templates/base/vitest.config.ts +82 -0
- package/templates/base/vitest.workspace.ts +22 -0
- package/templates/modules/audit-logs/.gitkeep +0 -0
- package/templates/modules/billing/.gitkeep +0 -0
- package/templates/modules/invitations/.gitkeep +0 -0
- package/templates/modules/storage/.gitkeep +0 -0
- package/templates/modules/webhooks/.gitkeep +0 -0
- package/templates/providers/auth-email/.gitkeep +0 -0
- package/templates/providers/auth-github/.gitkeep +0 -0
- package/templates/providers/auth-google/.gitkeep +0 -0
- package/templates/providers/email-resend/.gitkeep +0 -0
- package/templates/providers/email-sendgrid/.gitkeep +0 -0
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
ERD (Entity Relationship Diagram) Generator
|
|
4
|
+
Generates ERD diagrams from ORM model definitions in source code.
|
|
5
|
+
|
|
6
|
+
Supports:
|
|
7
|
+
- Prisma (.prisma files)
|
|
8
|
+
- SQLAlchemy (Python models)
|
|
9
|
+
- TypeORM (TypeScript decorators)
|
|
10
|
+
- Django (models.py)
|
|
11
|
+
- Mongoose (JavaScript/TypeScript schemas)
|
|
12
|
+
- Sequelize (JavaScript/TypeScript models)
|
|
13
|
+
- JPA/Hibernate (Java entities)
|
|
14
|
+
|
|
15
|
+
Output formats:
|
|
16
|
+
- Mermaid ERD syntax (default)
|
|
17
|
+
- PlantUML
|
|
18
|
+
- DOT (Graphviz)
|
|
19
|
+
- JSON (raw data)
|
|
20
|
+
|
|
21
|
+
Based on approaches from:
|
|
22
|
+
- prisma-erd-generator: https://github.com/keonik/prisma-erd-generator
|
|
23
|
+
- paracelsus: https://github.com/tedivm/paracelsus
|
|
24
|
+
- mermerd: https://github.com/KarnerTh/mermerd
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
import os
|
|
28
|
+
import re
|
|
29
|
+
import json
|
|
30
|
+
import argparse
|
|
31
|
+
from pathlib import Path
|
|
32
|
+
from typing import Dict, List, Set, Optional, Tuple
|
|
33
|
+
from dataclasses import dataclass, field, asdict
|
|
34
|
+
from collections import defaultdict
|
|
35
|
+
from enum import Enum
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class RelationType(Enum):
|
|
39
|
+
ONE_TO_ONE = "1--1"
|
|
40
|
+
ONE_TO_MANY = "1--*"
|
|
41
|
+
MANY_TO_ONE = "*--1"
|
|
42
|
+
MANY_TO_MANY = "*--*"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class FieldType(Enum):
|
|
46
|
+
STRING = "string"
|
|
47
|
+
INT = "int"
|
|
48
|
+
FLOAT = "float"
|
|
49
|
+
BOOLEAN = "boolean"
|
|
50
|
+
DATE = "date"
|
|
51
|
+
DATETIME = "datetime"
|
|
52
|
+
JSON = "json"
|
|
53
|
+
UUID = "uuid"
|
|
54
|
+
TEXT = "text"
|
|
55
|
+
ENUM = "enum"
|
|
56
|
+
BINARY = "binary"
|
|
57
|
+
UNKNOWN = "unknown"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclass
|
|
61
|
+
class Field:
|
|
62
|
+
"""Represents a database field/column"""
|
|
63
|
+
name: str
|
|
64
|
+
field_type: str
|
|
65
|
+
is_primary_key: bool = False
|
|
66
|
+
is_foreign_key: bool = False
|
|
67
|
+
is_nullable: bool = True
|
|
68
|
+
is_unique: bool = False
|
|
69
|
+
default: Optional[str] = None
|
|
70
|
+
references: Optional[str] = None # Table.field for FK
|
|
71
|
+
|
|
72
|
+
def to_dict(self):
|
|
73
|
+
return asdict(self)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass
|
|
77
|
+
class Relationship:
|
|
78
|
+
"""Represents a relationship between entities"""
|
|
79
|
+
source_entity: str
|
|
80
|
+
target_entity: str
|
|
81
|
+
relation_type: RelationType
|
|
82
|
+
source_field: Optional[str] = None
|
|
83
|
+
target_field: Optional[str] = None
|
|
84
|
+
name: Optional[str] = None
|
|
85
|
+
|
|
86
|
+
def to_dict(self):
|
|
87
|
+
d = asdict(self)
|
|
88
|
+
d['relation_type'] = self.relation_type.value
|
|
89
|
+
return d
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@dataclass
|
|
93
|
+
class Entity:
|
|
94
|
+
"""Represents a database entity/table"""
|
|
95
|
+
name: str
|
|
96
|
+
fields: List[Field] = field(default_factory=list)
|
|
97
|
+
service: Optional[str] = None
|
|
98
|
+
file_path: Optional[str] = None
|
|
99
|
+
confidence: str = "HIGH"
|
|
100
|
+
|
|
101
|
+
def to_dict(self):
|
|
102
|
+
return {
|
|
103
|
+
'name': self.name,
|
|
104
|
+
'fields': [f.to_dict() for f in self.fields],
|
|
105
|
+
'service': self.service,
|
|
106
|
+
'file_path': self.file_path,
|
|
107
|
+
'confidence': self.confidence
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class PrismaParser:
|
|
112
|
+
"""Parse Prisma schema files"""
|
|
113
|
+
|
|
114
|
+
def parse(self, content: str, file_path: str = None) -> Tuple[List[Entity], List[Relationship]]:
|
|
115
|
+
entities = []
|
|
116
|
+
relationships = []
|
|
117
|
+
|
|
118
|
+
# Match model blocks
|
|
119
|
+
model_pattern = r'model\s+(\w+)\s*\{([^}]+)\}'
|
|
120
|
+
matches = re.finditer(model_pattern, content, re.MULTILINE | re.DOTALL)
|
|
121
|
+
|
|
122
|
+
for match in matches:
|
|
123
|
+
model_name = match.group(1)
|
|
124
|
+
model_body = match.group(2)
|
|
125
|
+
fields = []
|
|
126
|
+
|
|
127
|
+
# Parse fields
|
|
128
|
+
field_pattern = r'(\w+)\s+(\w+)(\[\])?\s*(\?)?([^@\n]*)?(@[^\n]+)?'
|
|
129
|
+
for field_match in re.finditer(field_pattern, model_body):
|
|
130
|
+
field_name = field_match.group(1)
|
|
131
|
+
field_type = field_match.group(2)
|
|
132
|
+
is_array = field_match.group(3) is not None
|
|
133
|
+
is_optional = field_match.group(4) is not None
|
|
134
|
+
decorators = field_match.group(6) or ""
|
|
135
|
+
|
|
136
|
+
# Skip relation fields for now, capture them separately
|
|
137
|
+
if '@relation' in decorators:
|
|
138
|
+
# Extract relation info
|
|
139
|
+
rel_match = re.search(r'@relation\([^)]*references:\s*\[(\w+)\]', decorators)
|
|
140
|
+
if rel_match:
|
|
141
|
+
relationships.append(Relationship(
|
|
142
|
+
source_entity=model_name,
|
|
143
|
+
target_entity=field_type,
|
|
144
|
+
relation_type=RelationType.MANY_TO_ONE if not is_array else RelationType.ONE_TO_MANY,
|
|
145
|
+
source_field=field_name,
|
|
146
|
+
target_field=rel_match.group(1)
|
|
147
|
+
))
|
|
148
|
+
continue
|
|
149
|
+
|
|
150
|
+
# Check for special decorators
|
|
151
|
+
is_pk = '@id' in decorators
|
|
152
|
+
is_unique = '@unique' in decorators
|
|
153
|
+
is_fk = 'Id' in field_name and field_type in ['Int', 'String', 'BigInt']
|
|
154
|
+
|
|
155
|
+
# Map Prisma types
|
|
156
|
+
type_map = {
|
|
157
|
+
'String': 'string', 'Int': 'int', 'BigInt': 'int',
|
|
158
|
+
'Float': 'float', 'Decimal': 'float', 'Boolean': 'boolean',
|
|
159
|
+
'DateTime': 'datetime', 'Date': 'date', 'Json': 'json',
|
|
160
|
+
'Bytes': 'binary', 'UUID': 'uuid'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fields.append(Field(
|
|
164
|
+
name=field_name,
|
|
165
|
+
field_type=type_map.get(field_type, field_type.lower()),
|
|
166
|
+
is_primary_key=is_pk,
|
|
167
|
+
is_foreign_key=is_fk,
|
|
168
|
+
is_nullable=is_optional,
|
|
169
|
+
is_unique=is_unique or is_pk,
|
|
170
|
+
references=f"{field_type}.id" if is_fk else None
|
|
171
|
+
))
|
|
172
|
+
|
|
173
|
+
entities.append(Entity(
|
|
174
|
+
name=model_name,
|
|
175
|
+
fields=fields,
|
|
176
|
+
file_path=file_path
|
|
177
|
+
))
|
|
178
|
+
|
|
179
|
+
return entities, relationships
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class SQLAlchemyParser:
|
|
183
|
+
"""Parse SQLAlchemy model files"""
|
|
184
|
+
|
|
185
|
+
def parse(self, content: str, file_path: str = None) -> Tuple[List[Entity], List[Relationship]]:
|
|
186
|
+
entities = []
|
|
187
|
+
relationships = []
|
|
188
|
+
|
|
189
|
+
# Find classes that inherit from Base or Model
|
|
190
|
+
class_pattern = r'class\s+(\w+)\s*\([^)]*(?:Base|Model|db\.Model)[^)]*\)\s*:\s*((?:\n(?:[ \t]+[^\n]+))*)'
|
|
191
|
+
matches = re.finditer(class_pattern, content, re.MULTILINE)
|
|
192
|
+
|
|
193
|
+
for match in matches:
|
|
194
|
+
class_name = match.group(1)
|
|
195
|
+
class_body = match.group(2)
|
|
196
|
+
fields = []
|
|
197
|
+
|
|
198
|
+
# Parse Column definitions
|
|
199
|
+
column_pattern = r'(\w+)\s*=\s*(?:db\.)?Column\s*\(\s*(?:db\.)?(\w+)(?:\([^)]*\))?\s*([^)]*)\)'
|
|
200
|
+
for col_match in re.finditer(column_pattern, class_body):
|
|
201
|
+
col_name = col_match.group(1)
|
|
202
|
+
col_type = col_match.group(2)
|
|
203
|
+
col_args = col_match.group(3)
|
|
204
|
+
|
|
205
|
+
is_pk = 'primary_key=True' in col_args or 'primary_key = True' in col_args
|
|
206
|
+
is_nullable = 'nullable=False' not in col_args
|
|
207
|
+
is_unique = 'unique=True' in col_args
|
|
208
|
+
|
|
209
|
+
# Check for ForeignKey
|
|
210
|
+
fk_match = re.search(r"ForeignKey\s*\(\s*['\"]([^'\"]+)['\"]", col_args)
|
|
211
|
+
is_fk = fk_match is not None
|
|
212
|
+
references = fk_match.group(1) if fk_match else None
|
|
213
|
+
|
|
214
|
+
# Map SQLAlchemy types
|
|
215
|
+
type_map = {
|
|
216
|
+
'String': 'string', 'Text': 'text', 'Integer': 'int',
|
|
217
|
+
'BigInteger': 'int', 'SmallInteger': 'int', 'Float': 'float',
|
|
218
|
+
'Numeric': 'float', 'Boolean': 'boolean', 'DateTime': 'datetime',
|
|
219
|
+
'Date': 'date', 'Time': 'time', 'JSON': 'json', 'JSONB': 'json',
|
|
220
|
+
'UUID': 'uuid', 'LargeBinary': 'binary', 'Enum': 'enum'
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
fields.append(Field(
|
|
224
|
+
name=col_name,
|
|
225
|
+
field_type=type_map.get(col_type, col_type.lower()),
|
|
226
|
+
is_primary_key=is_pk,
|
|
227
|
+
is_foreign_key=is_fk,
|
|
228
|
+
is_nullable=is_nullable,
|
|
229
|
+
is_unique=is_unique,
|
|
230
|
+
references=references
|
|
231
|
+
))
|
|
232
|
+
|
|
233
|
+
# Add relationship from FK
|
|
234
|
+
if is_fk and references:
|
|
235
|
+
target_table = references.split('.')[0]
|
|
236
|
+
relationships.append(Relationship(
|
|
237
|
+
source_entity=class_name,
|
|
238
|
+
target_entity=target_table.title(),
|
|
239
|
+
relation_type=RelationType.MANY_TO_ONE,
|
|
240
|
+
source_field=col_name,
|
|
241
|
+
target_field=references.split('.')[-1] if '.' in references else 'id'
|
|
242
|
+
))
|
|
243
|
+
|
|
244
|
+
# Parse relationship() definitions
|
|
245
|
+
rel_pattern = r'(\w+)\s*=\s*(?:db\.)?relationship\s*\(\s*["\'](\w+)["\']'
|
|
246
|
+
for rel_match in re.finditer(rel_pattern, class_body):
|
|
247
|
+
rel_name = rel_match.group(1)
|
|
248
|
+
target = rel_match.group(2)
|
|
249
|
+
|
|
250
|
+
# Determine cardinality from uselist
|
|
251
|
+
is_one = 'uselist=False' in class_body[rel_match.start():rel_match.end()+100]
|
|
252
|
+
rel_type = RelationType.ONE_TO_ONE if is_one else RelationType.ONE_TO_MANY
|
|
253
|
+
|
|
254
|
+
relationships.append(Relationship(
|
|
255
|
+
source_entity=class_name,
|
|
256
|
+
target_entity=target,
|
|
257
|
+
relation_type=rel_type,
|
|
258
|
+
name=rel_name
|
|
259
|
+
))
|
|
260
|
+
|
|
261
|
+
if fields:
|
|
262
|
+
entities.append(Entity(
|
|
263
|
+
name=class_name,
|
|
264
|
+
fields=fields,
|
|
265
|
+
file_path=file_path
|
|
266
|
+
))
|
|
267
|
+
|
|
268
|
+
return entities, relationships
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class TypeORMParser:
|
|
272
|
+
"""Parse TypeORM entity files"""
|
|
273
|
+
|
|
274
|
+
def parse(self, content: str, file_path: str = None) -> Tuple[List[Entity], List[Relationship]]:
|
|
275
|
+
entities = []
|
|
276
|
+
relationships = []
|
|
277
|
+
|
|
278
|
+
# Find @Entity decorated classes
|
|
279
|
+
entity_pattern = r'@Entity\s*\([^)]*\)\s*(?:export\s+)?class\s+(\w+)[^{]*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}'
|
|
280
|
+
matches = re.finditer(entity_pattern, content, re.MULTILINE | re.DOTALL)
|
|
281
|
+
|
|
282
|
+
for match in matches:
|
|
283
|
+
class_name = match.group(1)
|
|
284
|
+
class_body = match.group(2)
|
|
285
|
+
fields = []
|
|
286
|
+
|
|
287
|
+
# Parse @Column decorators
|
|
288
|
+
column_pattern = r'@(?:PrimaryGeneratedColumn|PrimaryColumn|Column)\s*\(([^)]*)\)\s*(\w+)\s*[?!]?\s*:\s*(\w+)'
|
|
289
|
+
for col_match in re.finditer(column_pattern, class_body):
|
|
290
|
+
decorator_args = col_match.group(1)
|
|
291
|
+
col_name = col_match.group(2)
|
|
292
|
+
col_type = col_match.group(3)
|
|
293
|
+
|
|
294
|
+
is_pk = 'PrimaryGeneratedColumn' in content[col_match.start()-30:col_match.start()] or \
|
|
295
|
+
'PrimaryColumn' in content[col_match.start()-20:col_match.start()]
|
|
296
|
+
is_nullable = 'nullable: true' in decorator_args or 'nullable:true' in decorator_args
|
|
297
|
+
is_unique = 'unique: true' in decorator_args
|
|
298
|
+
|
|
299
|
+
# Map TypeScript types
|
|
300
|
+
type_map = {
|
|
301
|
+
'string': 'string', 'number': 'int', 'boolean': 'boolean',
|
|
302
|
+
'Date': 'datetime', 'Buffer': 'binary', 'object': 'json'
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
fields.append(Field(
|
|
306
|
+
name=col_name,
|
|
307
|
+
field_type=type_map.get(col_type, col_type.lower()),
|
|
308
|
+
is_primary_key=is_pk,
|
|
309
|
+
is_nullable=is_nullable,
|
|
310
|
+
is_unique=is_unique
|
|
311
|
+
))
|
|
312
|
+
|
|
313
|
+
# Parse relationship decorators
|
|
314
|
+
rel_patterns = [
|
|
315
|
+
(r'@OneToOne\s*\([^)]*\)\s*(\w+)\s*[?!]?\s*:\s*(\w+)', RelationType.ONE_TO_ONE),
|
|
316
|
+
(r'@OneToMany\s*\([^)]*\)\s*(\w+)\s*[?!]?\s*:\s*(\w+)', RelationType.ONE_TO_MANY),
|
|
317
|
+
(r'@ManyToOne\s*\([^)]*\)\s*(\w+)\s*[?!]?\s*:\s*(\w+)', RelationType.MANY_TO_ONE),
|
|
318
|
+
(r'@ManyToMany\s*\([^)]*\)\s*(\w+)\s*[?!]?\s*:\s*(\w+)', RelationType.MANY_TO_MANY),
|
|
319
|
+
]
|
|
320
|
+
|
|
321
|
+
for pattern, rel_type in rel_patterns:
|
|
322
|
+
for rel_match in re.finditer(pattern, class_body):
|
|
323
|
+
field_name = rel_match.group(1)
|
|
324
|
+
target_type = rel_match.group(2).replace('[]', '')
|
|
325
|
+
|
|
326
|
+
relationships.append(Relationship(
|
|
327
|
+
source_entity=class_name,
|
|
328
|
+
target_entity=target_type,
|
|
329
|
+
relation_type=rel_type,
|
|
330
|
+
source_field=field_name
|
|
331
|
+
))
|
|
332
|
+
|
|
333
|
+
# Parse @JoinColumn for FK
|
|
334
|
+
join_pattern = r'@JoinColumn\s*\([^)]*name:\s*["\'](\w+)["\'][^)]*\)'
|
|
335
|
+
for join_match in re.finditer(join_pattern, class_body):
|
|
336
|
+
fk_name = join_match.group(1)
|
|
337
|
+
fields.append(Field(
|
|
338
|
+
name=fk_name,
|
|
339
|
+
field_type='int',
|
|
340
|
+
is_foreign_key=True
|
|
341
|
+
))
|
|
342
|
+
|
|
343
|
+
if fields:
|
|
344
|
+
entities.append(Entity(
|
|
345
|
+
name=class_name,
|
|
346
|
+
fields=fields,
|
|
347
|
+
file_path=file_path
|
|
348
|
+
))
|
|
349
|
+
|
|
350
|
+
return entities, relationships
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
class DjangoParser:
|
|
354
|
+
"""Parse Django models.py files"""
|
|
355
|
+
|
|
356
|
+
def parse(self, content: str, file_path: str = None) -> Tuple[List[Entity], List[Relationship]]:
|
|
357
|
+
entities = []
|
|
358
|
+
relationships = []
|
|
359
|
+
|
|
360
|
+
# Find model classes
|
|
361
|
+
class_pattern = r'class\s+(\w+)\s*\(\s*(?:models\.)?Model\s*\)\s*:\s*((?:\n(?:[ \t]+[^\n]+))*)'
|
|
362
|
+
matches = re.finditer(class_pattern, content, re.MULTILINE)
|
|
363
|
+
|
|
364
|
+
for match in matches:
|
|
365
|
+
class_name = match.group(1)
|
|
366
|
+
class_body = match.group(2)
|
|
367
|
+
fields = []
|
|
368
|
+
|
|
369
|
+
# Add implicit id field
|
|
370
|
+
if 'id = ' not in class_body:
|
|
371
|
+
fields.append(Field(
|
|
372
|
+
name='id',
|
|
373
|
+
field_type='int',
|
|
374
|
+
is_primary_key=True,
|
|
375
|
+
is_nullable=False,
|
|
376
|
+
is_unique=True
|
|
377
|
+
))
|
|
378
|
+
|
|
379
|
+
# Parse field definitions
|
|
380
|
+
field_pattern = r'(\w+)\s*=\s*models\.(\w+)\s*\(([^)]*)\)'
|
|
381
|
+
for field_match in re.finditer(field_pattern, class_body):
|
|
382
|
+
field_name = field_match.group(1)
|
|
383
|
+
field_type = field_match.group(2)
|
|
384
|
+
field_args = field_match.group(3)
|
|
385
|
+
|
|
386
|
+
is_nullable = 'null=True' in field_args
|
|
387
|
+
is_unique = 'unique=True' in field_args
|
|
388
|
+
is_pk = 'primary_key=True' in field_args
|
|
389
|
+
|
|
390
|
+
# Handle relationship fields
|
|
391
|
+
if field_type in ['ForeignKey', 'OneToOneField']:
|
|
392
|
+
# Extract target model
|
|
393
|
+
target_match = re.search(r"['\"]?(\w+)['\"]?", field_args)
|
|
394
|
+
if target_match:
|
|
395
|
+
target = target_match.group(1)
|
|
396
|
+
if target == 'self':
|
|
397
|
+
target = class_name
|
|
398
|
+
|
|
399
|
+
rel_type = RelationType.ONE_TO_ONE if field_type == 'OneToOneField' else RelationType.MANY_TO_ONE
|
|
400
|
+
relationships.append(Relationship(
|
|
401
|
+
source_entity=class_name,
|
|
402
|
+
target_entity=target,
|
|
403
|
+
relation_type=rel_type,
|
|
404
|
+
source_field=field_name
|
|
405
|
+
))
|
|
406
|
+
|
|
407
|
+
fields.append(Field(
|
|
408
|
+
name=f"{field_name}_id",
|
|
409
|
+
field_type='int',
|
|
410
|
+
is_foreign_key=True,
|
|
411
|
+
is_nullable=is_nullable,
|
|
412
|
+
references=f"{target}.id"
|
|
413
|
+
))
|
|
414
|
+
continue
|
|
415
|
+
|
|
416
|
+
elif field_type == 'ManyToManyField':
|
|
417
|
+
target_match = re.search(r"['\"]?(\w+)['\"]?", field_args)
|
|
418
|
+
if target_match:
|
|
419
|
+
target = target_match.group(1)
|
|
420
|
+
relationships.append(Relationship(
|
|
421
|
+
source_entity=class_name,
|
|
422
|
+
target_entity=target,
|
|
423
|
+
relation_type=RelationType.MANY_TO_MANY,
|
|
424
|
+
source_field=field_name
|
|
425
|
+
))
|
|
426
|
+
continue
|
|
427
|
+
|
|
428
|
+
# Map Django field types
|
|
429
|
+
type_map = {
|
|
430
|
+
'CharField': 'string', 'TextField': 'text', 'IntegerField': 'int',
|
|
431
|
+
'BigIntegerField': 'int', 'SmallIntegerField': 'int',
|
|
432
|
+
'FloatField': 'float', 'DecimalField': 'float',
|
|
433
|
+
'BooleanField': 'boolean', 'NullBooleanField': 'boolean',
|
|
434
|
+
'DateTimeField': 'datetime', 'DateField': 'date', 'TimeField': 'time',
|
|
435
|
+
'JSONField': 'json', 'UUIDField': 'uuid', 'BinaryField': 'binary',
|
|
436
|
+
'EmailField': 'string', 'URLField': 'string', 'SlugField': 'string',
|
|
437
|
+
'AutoField': 'int', 'BigAutoField': 'int',
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
fields.append(Field(
|
|
441
|
+
name=field_name,
|
|
442
|
+
field_type=type_map.get(field_type, field_type.lower()),
|
|
443
|
+
is_primary_key=is_pk,
|
|
444
|
+
is_nullable=is_nullable,
|
|
445
|
+
is_unique=is_unique
|
|
446
|
+
))
|
|
447
|
+
|
|
448
|
+
entities.append(Entity(
|
|
449
|
+
name=class_name,
|
|
450
|
+
fields=fields,
|
|
451
|
+
file_path=file_path
|
|
452
|
+
))
|
|
453
|
+
|
|
454
|
+
return entities, relationships
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
class MongooseParser:
|
|
458
|
+
"""Parse Mongoose schema files"""
|
|
459
|
+
|
|
460
|
+
def parse(self, content: str, file_path: str = None) -> Tuple[List[Entity], List[Relationship]]:
|
|
461
|
+
entities = []
|
|
462
|
+
relationships = []
|
|
463
|
+
|
|
464
|
+
# Find Schema definitions
|
|
465
|
+
schema_pattern = r'(?:const|let|var)\s+(\w+)Schema\s*=\s*new\s+(?:mongoose\.)?Schema\s*\(\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}'
|
|
466
|
+
matches = re.finditer(schema_pattern, content, re.MULTILINE | re.DOTALL)
|
|
467
|
+
|
|
468
|
+
for match in matches:
|
|
469
|
+
schema_name = match.group(1)
|
|
470
|
+
schema_body = match.group(2)
|
|
471
|
+
fields = []
|
|
472
|
+
|
|
473
|
+
# Add implicit _id field
|
|
474
|
+
fields.append(Field(
|
|
475
|
+
name='_id',
|
|
476
|
+
field_type='uuid',
|
|
477
|
+
is_primary_key=True,
|
|
478
|
+
is_nullable=False,
|
|
479
|
+
is_unique=True
|
|
480
|
+
))
|
|
481
|
+
|
|
482
|
+
# Parse field definitions (simplified)
|
|
483
|
+
# Handle: fieldName: Type or fieldName: { type: Type, ... }
|
|
484
|
+
field_patterns = [
|
|
485
|
+
r"(\w+)\s*:\s*\{\s*type\s*:\s*(\w+)[^}]*ref\s*:\s*['\"](\w+)['\"]", # with ref
|
|
486
|
+
r"(\w+)\s*:\s*\{\s*type\s*:\s*(\w+)", # object style
|
|
487
|
+
r"(\w+)\s*:\s*(\w+)(?:\s*,|\s*$|\s*\})", # shorthand style
|
|
488
|
+
]
|
|
489
|
+
|
|
490
|
+
seen_fields = {'_id'}
|
|
491
|
+
|
|
492
|
+
# First pass: fields with refs (relationships)
|
|
493
|
+
ref_pattern = r"(\w+)\s*:\s*\{\s*type\s*:\s*(?:mongoose\.)?Schema\.Types\.ObjectId[^}]*ref\s*:\s*['\"](\w+)['\"]"
|
|
494
|
+
for ref_match in re.finditer(ref_pattern, schema_body):
|
|
495
|
+
field_name = ref_match.group(1)
|
|
496
|
+
ref_target = ref_match.group(2)
|
|
497
|
+
seen_fields.add(field_name)
|
|
498
|
+
|
|
499
|
+
fields.append(Field(
|
|
500
|
+
name=field_name,
|
|
501
|
+
field_type='uuid',
|
|
502
|
+
is_foreign_key=True,
|
|
503
|
+
references=f"{ref_target}._id"
|
|
504
|
+
))
|
|
505
|
+
|
|
506
|
+
relationships.append(Relationship(
|
|
507
|
+
source_entity=schema_name,
|
|
508
|
+
target_entity=ref_target,
|
|
509
|
+
relation_type=RelationType.MANY_TO_ONE,
|
|
510
|
+
source_field=field_name
|
|
511
|
+
))
|
|
512
|
+
|
|
513
|
+
# Second pass: regular fields
|
|
514
|
+
simple_pattern = r"(\w+)\s*:\s*(?:\{\s*type\s*:\s*)?(\w+)"
|
|
515
|
+
for field_match in re.finditer(simple_pattern, schema_body):
|
|
516
|
+
field_name = field_match.group(1)
|
|
517
|
+
field_type = field_match.group(2)
|
|
518
|
+
|
|
519
|
+
if field_name in seen_fields or field_name in ['type', 'ref', 'required', 'default', 'unique']:
|
|
520
|
+
continue
|
|
521
|
+
seen_fields.add(field_name)
|
|
522
|
+
|
|
523
|
+
# Map Mongoose types
|
|
524
|
+
type_map = {
|
|
525
|
+
'String': 'string', 'Number': 'float', 'Boolean': 'boolean',
|
|
526
|
+
'Date': 'datetime', 'Buffer': 'binary', 'ObjectId': 'uuid',
|
|
527
|
+
'Mixed': 'json', 'Array': 'json', 'Map': 'json'
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
fields.append(Field(
|
|
531
|
+
name=field_name,
|
|
532
|
+
field_type=type_map.get(field_type, field_type.lower())
|
|
533
|
+
))
|
|
534
|
+
|
|
535
|
+
entities.append(Entity(
|
|
536
|
+
name=schema_name,
|
|
537
|
+
fields=fields,
|
|
538
|
+
file_path=file_path
|
|
539
|
+
))
|
|
540
|
+
|
|
541
|
+
return entities, relationships
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
class JPAParser:
|
|
545
|
+
"""Parse JPA/Hibernate entity files"""
|
|
546
|
+
|
|
547
|
+
def parse(self, content: str, file_path: str = None) -> Tuple[List[Entity], List[Relationship]]:
|
|
548
|
+
entities = []
|
|
549
|
+
relationships = []
|
|
550
|
+
|
|
551
|
+
# Find @Entity annotated classes
|
|
552
|
+
entity_pattern = r'@Entity[^@]*(?:@Table[^@]*)?\s*public\s+class\s+(\w+)[^{]*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}'
|
|
553
|
+
matches = re.finditer(entity_pattern, content, re.MULTILINE | re.DOTALL)
|
|
554
|
+
|
|
555
|
+
for match in matches:
|
|
556
|
+
class_name = match.group(1)
|
|
557
|
+
class_body = match.group(2)
|
|
558
|
+
fields = []
|
|
559
|
+
|
|
560
|
+
# Parse field/getter annotations
|
|
561
|
+
column_pattern = r'(?:@(?:Id|GeneratedValue|Column)[^;]*)*\s*private\s+(\w+)\s+(\w+)\s*;'
|
|
562
|
+
for col_match in re.finditer(column_pattern, class_body):
|
|
563
|
+
col_type = col_match.group(1)
|
|
564
|
+
col_name = col_match.group(2)
|
|
565
|
+
|
|
566
|
+
# Check annotations before this field
|
|
567
|
+
before_field = class_body[:col_match.start()]
|
|
568
|
+
is_pk = '@Id' in before_field[-200:]
|
|
569
|
+
|
|
570
|
+
# Map Java types
|
|
571
|
+
type_map = {
|
|
572
|
+
'String': 'string', 'Integer': 'int', 'int': 'int',
|
|
573
|
+
'Long': 'int', 'long': 'int', 'Double': 'float', 'double': 'float',
|
|
574
|
+
'Float': 'float', 'float': 'float', 'Boolean': 'boolean', 'boolean': 'boolean',
|
|
575
|
+
'Date': 'date', 'LocalDate': 'date', 'LocalDateTime': 'datetime',
|
|
576
|
+
'Timestamp': 'datetime', 'UUID': 'uuid', 'BigDecimal': 'float'
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
fields.append(Field(
|
|
580
|
+
name=col_name,
|
|
581
|
+
field_type=type_map.get(col_type, col_type.lower()),
|
|
582
|
+
is_primary_key=is_pk
|
|
583
|
+
))
|
|
584
|
+
|
|
585
|
+
# Parse relationship annotations
|
|
586
|
+
rel_patterns = [
|
|
587
|
+
(r'@OneToOne[^;]*private\s+(\w+)\s+(\w+)\s*;', RelationType.ONE_TO_ONE),
|
|
588
|
+
(r'@OneToMany[^;]*private\s+(?:List|Set|Collection)<(\w+)>\s+(\w+)\s*;', RelationType.ONE_TO_MANY),
|
|
589
|
+
(r'@ManyToOne[^;]*private\s+(\w+)\s+(\w+)\s*;', RelationType.MANY_TO_ONE),
|
|
590
|
+
(r'@ManyToMany[^;]*private\s+(?:List|Set|Collection)<(\w+)>\s+(\w+)\s*;', RelationType.MANY_TO_MANY),
|
|
591
|
+
]
|
|
592
|
+
|
|
593
|
+
for pattern, rel_type in rel_patterns:
|
|
594
|
+
for rel_match in re.finditer(pattern, class_body):
|
|
595
|
+
target_type = rel_match.group(1)
|
|
596
|
+
field_name = rel_match.group(2)
|
|
597
|
+
|
|
598
|
+
relationships.append(Relationship(
|
|
599
|
+
source_entity=class_name,
|
|
600
|
+
target_entity=target_type,
|
|
601
|
+
relation_type=rel_type,
|
|
602
|
+
source_field=field_name
|
|
603
|
+
))
|
|
604
|
+
|
|
605
|
+
if fields:
|
|
606
|
+
entities.append(Entity(
|
|
607
|
+
name=class_name,
|
|
608
|
+
fields=fields,
|
|
609
|
+
file_path=file_path
|
|
610
|
+
))
|
|
611
|
+
|
|
612
|
+
return entities, relationships
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
class ERDGenerator:
|
|
616
|
+
"""Main ERD generator that uses appropriate parser based on file type"""
|
|
617
|
+
|
|
618
|
+
PARSERS = {
|
|
619
|
+
'.prisma': PrismaParser,
|
|
620
|
+
'.py': SQLAlchemyParser, # Also handles Django
|
|
621
|
+
'.ts': TypeORMParser,
|
|
622
|
+
'.js': MongooseParser,
|
|
623
|
+
'.java': JPAParser,
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
def __init__(self, root_path: str, services: List[Dict] = None):
|
|
627
|
+
self.root_path = Path(root_path).resolve()
|
|
628
|
+
self.services = services or []
|
|
629
|
+
self.entities: List[Entity] = []
|
|
630
|
+
self.relationships: List[Relationship] = []
|
|
631
|
+
|
|
632
|
+
def detect_orm_files(self, service_path: Path) -> List[Tuple[Path, str]]:
|
|
633
|
+
"""Find files likely containing ORM definitions"""
|
|
634
|
+
orm_files = []
|
|
635
|
+
|
|
636
|
+
# Prisma
|
|
637
|
+
for f in service_path.glob('**/schema.prisma'):
|
|
638
|
+
orm_files.append((f, '.prisma'))
|
|
639
|
+
for f in service_path.glob('**/*.prisma'):
|
|
640
|
+
orm_files.append((f, '.prisma'))
|
|
641
|
+
|
|
642
|
+
# Python (SQLAlchemy/Django)
|
|
643
|
+
for pattern in ['**/models.py', '**/models/*.py', '**/entities.py', '**/entities/*.py']:
|
|
644
|
+
for f in service_path.glob(pattern):
|
|
645
|
+
if 'test' not in str(f).lower() and '__pycache__' not in str(f):
|
|
646
|
+
orm_files.append((f, '.py'))
|
|
647
|
+
|
|
648
|
+
# TypeScript (TypeORM)
|
|
649
|
+
for pattern in ['**/entities/*.ts', '**/*.entity.ts', '**/models/*.ts']:
|
|
650
|
+
for f in service_path.glob(pattern):
|
|
651
|
+
if 'node_modules' not in str(f) and 'test' not in str(f).lower():
|
|
652
|
+
orm_files.append((f, '.ts'))
|
|
653
|
+
|
|
654
|
+
# JavaScript (Mongoose/Sequelize)
|
|
655
|
+
for pattern in ['**/models/*.js', '**/*.model.js', '**/schemas/*.js']:
|
|
656
|
+
for f in service_path.glob(pattern):
|
|
657
|
+
if 'node_modules' not in str(f) and 'test' not in str(f).lower():
|
|
658
|
+
orm_files.append((f, '.js'))
|
|
659
|
+
|
|
660
|
+
# Java (JPA/Hibernate)
|
|
661
|
+
for pattern in ['**/entity/*.java', '**/entities/*.java', '**/*Entity.java']:
|
|
662
|
+
for f in service_path.glob(pattern):
|
|
663
|
+
if 'test' not in str(f).lower():
|
|
664
|
+
orm_files.append((f, '.java'))
|
|
665
|
+
|
|
666
|
+
return orm_files
|
|
667
|
+
|
|
668
|
+
def parse_file(self, file_path: Path, ext: str, service_name: str) -> None:
|
|
669
|
+
"""Parse a single file and extract entities/relationships"""
|
|
670
|
+
try:
|
|
671
|
+
content = file_path.read_text(errors='ignore')
|
|
672
|
+
|
|
673
|
+
# Special detection for Django vs SQLAlchemy
|
|
674
|
+
if ext == '.py':
|
|
675
|
+
if 'from django' in content or 'models.Model' in content:
|
|
676
|
+
parser = DjangoParser()
|
|
677
|
+
else:
|
|
678
|
+
parser = SQLAlchemyParser()
|
|
679
|
+
# Special detection for Mongoose vs TypeORM
|
|
680
|
+
elif ext == '.js':
|
|
681
|
+
if 'mongoose' in content.lower() or 'Schema' in content:
|
|
682
|
+
parser = MongooseParser()
|
|
683
|
+
else:
|
|
684
|
+
return # Skip non-ORM JS files
|
|
685
|
+
elif ext == '.ts':
|
|
686
|
+
if '@Entity' in content or 'typeorm' in content.lower():
|
|
687
|
+
parser = TypeORMParser()
|
|
688
|
+
else:
|
|
689
|
+
return # Skip non-ORM TS files
|
|
690
|
+
else:
|
|
691
|
+
parser_class = self.PARSERS.get(ext)
|
|
692
|
+
if not parser_class:
|
|
693
|
+
return
|
|
694
|
+
parser = parser_class()
|
|
695
|
+
|
|
696
|
+
entities, relationships = parser.parse(content, str(file_path))
|
|
697
|
+
|
|
698
|
+
# Tag entities with service name
|
|
699
|
+
for entity in entities:
|
|
700
|
+
entity.service = service_name
|
|
701
|
+
entity.file_path = str(file_path.relative_to(self.root_path))
|
|
702
|
+
|
|
703
|
+
self.entities.extend(entities)
|
|
704
|
+
self.relationships.extend(relationships)
|
|
705
|
+
|
|
706
|
+
except Exception as e:
|
|
707
|
+
print(f"Error parsing {file_path}: {e}")
|
|
708
|
+
|
|
709
|
+
def generate(self) -> Dict:
|
|
710
|
+
"""Generate ERD data from all services"""
|
|
711
|
+
for service in self.services:
|
|
712
|
+
service_name = service.get('name', '')
|
|
713
|
+
service_path = self.root_path / service.get('path', '')
|
|
714
|
+
|
|
715
|
+
if not service_path.exists():
|
|
716
|
+
continue
|
|
717
|
+
|
|
718
|
+
print(f"Scanning for ORM models in: {service_name}")
|
|
719
|
+
|
|
720
|
+
orm_files = self.detect_orm_files(service_path)
|
|
721
|
+
for file_path, ext in orm_files:
|
|
722
|
+
self.parse_file(file_path, ext, service_name)
|
|
723
|
+
|
|
724
|
+
# Deduplicate relationships
|
|
725
|
+
unique_rels = {}
|
|
726
|
+
for rel in self.relationships:
|
|
727
|
+
key = (rel.source_entity, rel.target_entity, rel.relation_type)
|
|
728
|
+
if key not in unique_rels:
|
|
729
|
+
unique_rels[key] = rel
|
|
730
|
+
self.relationships = list(unique_rels.values())
|
|
731
|
+
|
|
732
|
+
return {
|
|
733
|
+
'total_entities': len(self.entities),
|
|
734
|
+
'total_relationships': len(self.relationships),
|
|
735
|
+
'entities': [e.to_dict() for e in self.entities],
|
|
736
|
+
'relationships': [r.to_dict() for r in self.relationships],
|
|
737
|
+
'by_service': self._group_by_service(),
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
def _group_by_service(self) -> Dict[str, List[str]]:
|
|
741
|
+
"""Group entities by service"""
|
|
742
|
+
grouped = defaultdict(list)
|
|
743
|
+
for entity in self.entities:
|
|
744
|
+
grouped[entity.service or 'unknown'].append(entity.name)
|
|
745
|
+
return dict(grouped)
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
def format_mermaid(data: Dict) -> str:
|
|
749
|
+
"""Format ERD as Mermaid diagram"""
|
|
750
|
+
output = """# Entity Relationship Diagram
|
|
751
|
+
|
|
752
|
+
```mermaid
|
|
753
|
+
erDiagram
|
|
754
|
+
"""
|
|
755
|
+
|
|
756
|
+
# Add entities with their fields
|
|
757
|
+
for entity in data['entities']:
|
|
758
|
+
output += f" {entity['name']} {{\n"
|
|
759
|
+
for field in entity['fields']:
|
|
760
|
+
pk = "PK" if field['is_primary_key'] else ""
|
|
761
|
+
fk = "FK" if field['is_foreign_key'] else ""
|
|
762
|
+
key_marker = f"{pk}{fk}" if pk or fk else ""
|
|
763
|
+
output += f" {field['field_type']} {field['name']}"
|
|
764
|
+
if key_marker:
|
|
765
|
+
output += f" {key_marker}"
|
|
766
|
+
output += "\n"
|
|
767
|
+
output += " }\n"
|
|
768
|
+
|
|
769
|
+
output += "\n"
|
|
770
|
+
|
|
771
|
+
# Add relationships
|
|
772
|
+
for rel in data['relationships']:
|
|
773
|
+
# Mermaid ERD relationship syntax
|
|
774
|
+
rel_map = {
|
|
775
|
+
"1--1": "||--||",
|
|
776
|
+
"1--*": "||--o{",
|
|
777
|
+
"*--1": "}o--||",
|
|
778
|
+
"*--*": "}o--o{"
|
|
779
|
+
}
|
|
780
|
+
mermaid_rel = rel_map.get(rel['relation_type'], "--")
|
|
781
|
+
label = rel.get('name') or rel.get('source_field') or ""
|
|
782
|
+
|
|
783
|
+
output += f" {rel['source_entity']} {mermaid_rel} {rel['target_entity']} : \"{label}\"\n"
|
|
784
|
+
|
|
785
|
+
output += "```\n"
|
|
786
|
+
|
|
787
|
+
# Add summary
|
|
788
|
+
output += f"""
|
|
789
|
+
## Summary
|
|
790
|
+
|
|
791
|
+
- **Total Entities**: {data['total_entities']}
|
|
792
|
+
- **Total Relationships**: {data['total_relationships']}
|
|
793
|
+
|
|
794
|
+
## Entities by Service
|
|
795
|
+
|
|
796
|
+
"""
|
|
797
|
+
|
|
798
|
+
for service, entities in data['by_service'].items():
|
|
799
|
+
output += f"### {service}\n"
|
|
800
|
+
for entity in entities:
|
|
801
|
+
output += f"- {entity}\n"
|
|
802
|
+
output += "\n"
|
|
803
|
+
|
|
804
|
+
return output
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
def format_plantuml(data: Dict) -> str:
|
|
808
|
+
"""Format ERD as PlantUML diagram"""
|
|
809
|
+
output = """@startuml ERD
|
|
810
|
+
|
|
811
|
+
!define TABLE(name) entity name << (T,#FFAAAA) >>
|
|
812
|
+
!define PK(x) <b>x</b>
|
|
813
|
+
!define FK(x) <i>x</i>
|
|
814
|
+
|
|
815
|
+
skinparam entity {
|
|
816
|
+
BackgroundColor AliceBlue
|
|
817
|
+
BorderColor DarkSlateGray
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
"""
|
|
821
|
+
|
|
822
|
+
for entity in data['entities']:
|
|
823
|
+
output += f"TABLE({entity['name']}) {{\n"
|
|
824
|
+
for field in entity['fields']:
|
|
825
|
+
if field['is_primary_key']:
|
|
826
|
+
output += f" PK({field['name']}) : {field['field_type']}\n"
|
|
827
|
+
elif field['is_foreign_key']:
|
|
828
|
+
output += f" FK({field['name']}) : {field['field_type']}\n"
|
|
829
|
+
else:
|
|
830
|
+
output += f" {field['name']} : {field['field_type']}\n"
|
|
831
|
+
output += "}\n\n"
|
|
832
|
+
|
|
833
|
+
for rel in data['relationships']:
|
|
834
|
+
rel_map = {
|
|
835
|
+
"1--1": "||--||",
|
|
836
|
+
"1--*": "||--o{",
|
|
837
|
+
"*--1": "}o--||",
|
|
838
|
+
"*--*": "}o--o{"
|
|
839
|
+
}
|
|
840
|
+
puml_rel = rel_map.get(rel['relation_type'], "--")
|
|
841
|
+
output += f"{rel['source_entity']} {puml_rel} {rel['target_entity']}\n"
|
|
842
|
+
|
|
843
|
+
output += "\n@enduml\n"
|
|
844
|
+
return output
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
def format_dot(data: Dict) -> str:
|
|
848
|
+
"""Format ERD as DOT (Graphviz) diagram"""
|
|
849
|
+
output = """digraph ERD {
|
|
850
|
+
graph [rankdir=LR, splines=ortho];
|
|
851
|
+
node [shape=record, fontname="Helvetica"];
|
|
852
|
+
edge [fontname="Helvetica"];
|
|
853
|
+
|
|
854
|
+
"""
|
|
855
|
+
|
|
856
|
+
for entity in data['entities']:
|
|
857
|
+
fields_str = "|".join([
|
|
858
|
+
f"<{f['name']}> {'🔑 ' if f['is_primary_key'] else '🔗 ' if f['is_foreign_key'] else ''}{f['name']}: {f['field_type']}"
|
|
859
|
+
for f in entity['fields']
|
|
860
|
+
])
|
|
861
|
+
output += f' {entity["name"]} [label="{{{entity["name"]}|{fields_str}}}"];\n'
|
|
862
|
+
|
|
863
|
+
output += "\n"
|
|
864
|
+
|
|
865
|
+
for rel in data['relationships']:
|
|
866
|
+
# DOT arrow styles for relationships
|
|
867
|
+
style = 'arrowhead="crow"' if '*' in rel['relation_type'] else 'arrowhead="tee"'
|
|
868
|
+
output += f' {rel["source_entity"]} -> {rel["target_entity"]} [{style}];\n'
|
|
869
|
+
|
|
870
|
+
output += "}\n"
|
|
871
|
+
return output
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
def main():
|
|
875
|
+
parser = argparse.ArgumentParser(description='Generate ERD from ORM model definitions')
|
|
876
|
+
parser.add_argument('path', nargs='?', default='.', help='Repository path to analyze')
|
|
877
|
+
parser.add_argument('--services', '-s', help='Services JSON file from analyze_structure.py')
|
|
878
|
+
parser.add_argument('--output', '-o', help='Output file')
|
|
879
|
+
parser.add_argument('--format', '-f', choices=['mermaid', 'plantuml', 'dot', 'json'],
|
|
880
|
+
default='mermaid', help='Output format')
|
|
881
|
+
|
|
882
|
+
args = parser.parse_args()
|
|
883
|
+
|
|
884
|
+
# Load services if provided
|
|
885
|
+
services = []
|
|
886
|
+
if args.services and Path(args.services).exists():
|
|
887
|
+
with open(args.services) as f:
|
|
888
|
+
data = json.load(f)
|
|
889
|
+
services = data.get('services', [])
|
|
890
|
+
else:
|
|
891
|
+
# Try to auto-discover services
|
|
892
|
+
try:
|
|
893
|
+
from analyze_structure import ServiceDiscoverer
|
|
894
|
+
discoverer = ServiceDiscoverer(args.path)
|
|
895
|
+
inventory = discoverer.generate_inventory()
|
|
896
|
+
services = inventory.get('services', [])
|
|
897
|
+
except ImportError:
|
|
898
|
+
services = [{'name': Path(args.path).name, 'path': '.'}]
|
|
899
|
+
|
|
900
|
+
if not services:
|
|
901
|
+
services = [{'name': Path(args.path).name, 'path': '.'}]
|
|
902
|
+
|
|
903
|
+
# Generate ERD
|
|
904
|
+
generator = ERDGenerator(args.path, services)
|
|
905
|
+
result = generator.generate()
|
|
906
|
+
|
|
907
|
+
if result['total_entities'] == 0:
|
|
908
|
+
print("No entities found. Make sure ORM model files exist in expected locations:")
|
|
909
|
+
print(" - Prisma: schema.prisma")
|
|
910
|
+
print(" - SQLAlchemy/Django: models.py, entities.py")
|
|
911
|
+
print(" - TypeORM: *.entity.ts, entities/*.ts")
|
|
912
|
+
print(" - Mongoose: models/*.js, *.model.js")
|
|
913
|
+
print(" - JPA: *Entity.java, entity/*.java")
|
|
914
|
+
return
|
|
915
|
+
|
|
916
|
+
# Format output
|
|
917
|
+
if args.format == 'json':
|
|
918
|
+
output = json.dumps(result, indent=2)
|
|
919
|
+
elif args.format == 'plantuml':
|
|
920
|
+
output = format_plantuml(result)
|
|
921
|
+
elif args.format == 'dot':
|
|
922
|
+
output = format_dot(result)
|
|
923
|
+
else:
|
|
924
|
+
output = format_mermaid(result)
|
|
925
|
+
|
|
926
|
+
if args.output:
|
|
927
|
+
with open(args.output, 'w') as f:
|
|
928
|
+
f.write(output)
|
|
929
|
+
print(f"ERD written to {args.output}")
|
|
930
|
+
else:
|
|
931
|
+
print(output)
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
if __name__ == '__main__':
|
|
935
|
+
main()
|