create-huenei-template 0.2.7 → 0.2.8
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/config/templates.js +7 -0
- package/dist/templates/README.md +7 -1
- package/dist/templates/backend/README.md +19 -9
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/prisma-guardian.md +67 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/test-runner.md +57 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/blockDangerous.ts +98 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/formatOnEdit.ts +70 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/protectSecrets.ts +101 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/sessionInit.ts +104 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/validatePrisma.ts +121 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks.json +46 -0
- package/dist/templates/backend/nestjs-api-mysql/README.md +26 -0
- package/dist/templates/backend/nestjs-api-mysql/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-mysql/package.json +7 -7
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/prisma-guardian.md +62 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/security-auditor.md +71 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/test-runner.md +58 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/auto-retry.ts +62 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/block-dangerous.ts +202 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/format-and-validate.ts +124 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/protect-secrets.ts +105 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/session-context.ts +130 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks.json +36 -0
- package/dist/templates/backend/nestjs-api-postgres/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-postgres/package.json +6 -6
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/code-reviewer.md +153 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/nestjs-architect.md +138 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/prisma-analyst.md +164 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/security-auditor.md +150 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/test-engineer.md +290 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/auto-format.ts +80 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/block-dangerous-commands.ts +144 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/prisma-schema-watcher.ts +64 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/protect-sensitive-files.ts +122 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/session-context.ts +105 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks.json +18 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/conventional-commits/SKILL.md +318 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/docker/SKILL.md +82 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/jest/SKILL.md +72 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/logging-best-practices/SKILL.md +127 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/prisma-database-setup/SKILL.md +186 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/quality-gates-enforcer/SKILL.md +301 -0
- package/dist/templates/backend/nestjs-api-sqlite/README.md +34 -1
- package/dist/templates/backend/nestjs-api-sqlite/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/package.json +6 -6
- package/dist/templates/backend/nestjs-api-sqlite/prisma/schema.prisma +1 -0
- package/dist/templates/backend/nestjs-api-sqlite/prisma/seed.ts +2 -2
- package/dist/templates/backend/nestjs-api-sqlite/src/posts/dto/post-response.dto.ts +5 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/profile-response.dto.ts +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/update-profile.dto.ts +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/user-response.dto.ts +4 -0
- package/dist/templates/backend/nestjs-api-sqlite/src/users/profile.service.ts +24 -8
- package/dist/templates/backend/nestjs-api-sqlite/src/users/users.service.ts +1 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/prisma-guardian.md +67 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/test-runner.md +57 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-endpoint.md +209 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-model.md +201 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/blockDangerous.ts +98 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/formatOnEdit.ts +70 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/protectSecrets.ts +101 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/sessionInit.ts +104 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/validatePrisma.ts +121 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks.json +46 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/api-rest.mdc +126 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/authentication-security.mdc +86 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/dto-validation.mdc +93 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/general-rules.mdc +126 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/nestjs-architecture.mdc +83 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/prisma-standards.mdc +111 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/swagger-documentation.mdc +90 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/api-security-best-practices/SKILL.md +907 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/docker-expert/SKILL.md +409 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-expert/SKILL.md +552 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/AGENTS.md +5958 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/SKILL.md +130 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nodejs-best-practices/SKILL.md +333 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/prisma-expert/SKILL.md +355 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/sqlserver-table-design/SKILL.md +125 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.dockerignore +50 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.env.example +17 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.env.test +17 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.prettierrc +4 -0
- package/dist/templates/backend/nestjs-api-sqlserver/README.md +587 -0
- package/dist/templates/backend/nestjs-api-sqlserver/docker-compose.yml +24 -0
- package/dist/templates/backend/nestjs-api-sqlserver/eslint.config.mjs +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/nest-cli.json +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/package.json +107 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma/schema.prisma +70 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma/seed.ts +215 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma.config.ts +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/scripts/check-docker.js +64 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/app.module.ts +39 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/app.service.ts +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.controller.ts +36 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.module.ts +22 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.service.ts +64 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/decorators/roles.decorator.ts +5 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/dto/login-response.dto.ts +23 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/dto/login.dto.ts +27 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/enums/role.enum.ts +5 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/guards/jwt-auth.guard.ts +20 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/guards/roles.guard.ts +23 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/strategies/jwt.strategy.ts +32 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/types.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/dto/paginated-response.dto.ts +16 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/dto/pagination.dto.ts +31 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/filters/http-exception.filter.ts +53 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/config/env.validation.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/health/health.controller.ts +35 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/health/health.module.ts +7 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/main.ts +87 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/create-post.dto.ts +32 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/post-response.dto.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/update-post.dto.ts +31 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.controller.ts +161 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.module.ts +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.service.ts +171 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.module.ts +9 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.service.ts +62 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/constants/settings.constants.ts +9 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/profile-response.dto.ts +39 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/settings-response.dto.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/update-profile.dto.ts +48 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/update-settings.dto.ts +40 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/user-response.dto.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/profile.service.ts +67 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/settings.service.ts +77 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.controller.ts +102 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.module.ts +14 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.service.ts +27 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/README.md +412 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/auth.e2e-spec.ts +147 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/health.e2e-spec.ts +62 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/posts.e2e-spec.ts +407 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/users.e2e-spec.ts +287 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/fixtures/test-data.ts +109 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/helpers/auth.helper.ts +54 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/helpers/db.helper.ts +68 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/jest-e2e.json +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/setup-e2e.ts +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/app.service.spec.ts +24 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/auth.controller.spec.ts +91 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/auth.service.spec.ts +161 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/health.controller.spec.ts +78 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/http-exception.filter.spec.ts +150 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/jwt-auth.guard.spec.ts +50 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/jwt.strategy.spec.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/posts.controller.spec.ts +249 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/posts.service.spec.ts +328 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/profile.service.spec.ts +146 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/settings.service.spec.ts +242 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/users.controller.spec.ts +178 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/users.service.spec.ts +96 -0
- package/dist/templates/backend/nestjs-api-sqlserver/tsconfig.build.json +4 -0
- package/dist/templates/backend/nestjs-api-sqlserver/tsconfig.json +28 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/accessibility-reviewer.md +67 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/angular-code-reviewer.md +60 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/qa-test-expert.md +70 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/security-auditor.md +58 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/auto-format.ts +70 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/auto-test-on-stop.ts +113 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/block-dangerous-commands.ts +160 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/ensure-tests-exist.ts +363 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/protect-sensitive-files.ts +118 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/session-context.ts +110 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/angular-code-reviewer.md +64 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/nx-architecture-guardian.md +69 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/qa-test-expert.md +75 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/security-auditor.md +61 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/auto-format.ts +70 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/auto-test-on-stop.ts +115 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/block-dangerous-commands.ts +188 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/ensure-tests-exist.ts +399 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/protect-sensitive-files.ts +128 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/session-context.ts +121 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/react-vite/.cursor/agents/frontend-senior.agent.md +49 -49
- package/dist/templates/frontend/react-vite/.cursor/agents/qa-test-expert.agent.md +126 -49
- package/dist/templates/frontend/react-vite/.cursor/agents/security-expert.agent.md +39 -39
- package/dist/templates/frontend/react-vite/.cursor/agents/ux-ui-expert.agent.md +45 -45
- package/dist/templates/frontend/react-vite/.cursor/hooks/autoTestOnStop.ts +117 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/blockDangerous.ts +75 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/ensureTestsExist.ts +306 -220
- package/dist/templates/frontend/react-vite/.cursor/hooks/formatOnEdit.ts +49 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/protectSecrets.ts +88 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/sessionInit.ts +77 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks.json +41 -10
- package/dist/templates/frontend/react-vite/.cursor/settings.json +13 -13
- package/dist/templates/frontend/react-vite/.vscode/settings.json +31 -31
- package/dist/templates/frontend/react-vite/README.md +34 -34
- package/dist/templates/frontend/react-vite/package.json +82 -82
- package/dist/templates/frontend/react-vite/pnpm-lock.yaml +6575 -6575
- package/dist/templates/frontend/react-vite/src/__tests__/components/layout/navbar.test.tsx +63 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/avatar.test.tsx +74 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/badge.test.tsx +55 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/breadcrumb.test.tsx +140 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/button.test.tsx +121 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/card.test.tsx +144 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/dialog.test.tsx +121 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/form.test.tsx +165 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/input.test.tsx +52 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/label.test.tsx +40 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/password-input.test.tsx +59 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/separator.test.tsx +40 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/table.test.tsx +254 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/tabs.test.tsx +82 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/textarea.test.tsx +47 -0
- package/dist/templates/frontend/react-vite/src/__tests__/helpers/render.tsx +114 -0
- package/dist/templates/frontend/react-vite/src/__tests__/hooks/useLocalStorage.test.ts +95 -0
- package/dist/templates/frontend/react-vite/src/__tests__/lib/queryClient.test.ts +24 -0
- package/dist/templates/frontend/react-vite/src/__tests__/lib/utils.test.ts +43 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/index.test.tsx +111 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/otra-ruta.test.tsx +126 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/root.test.tsx +78 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/ui-components.test.tsx +286 -0
- package/dist/templates/frontend/react-vite/src/components/layout/navbar.tsx +38 -38
- package/dist/templates/frontend/react-vite/src/components/ui/avatar.tsx +42 -42
- package/dist/templates/frontend/react-vite/src/components/ui/dialog.tsx +122 -122
- package/dist/templates/frontend/react-vite/src/components/ui/table.tsx +229 -244
- package/dist/templates/frontend/react-vite/src/hooks/useLocalStorage.ts +32 -32
- package/dist/templates/frontend/react-vite/src/routes/__root.tsx +48 -48
- package/dist/templates/frontend/react-vite/src/routes/ui-components.tsx +359 -85
- package/dist/templates/frontend/react-vite/src/test/setup.ts +24 -24
- package/dist/templates/frontend/react-vite/vite.config.ts +2 -2
- package/dist/templates/frontend/react-vite/vitest.config.ts +13 -2
- package/package.json +1 -1
- package/templates/README.md +7 -1
- package/templates/backend/README.md +19 -9
- package/templates/backend/nestjs-api-mysql/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-mysql/.cursor/agents/prisma-guardian.md +67 -0
- package/templates/backend/nestjs-api-mysql/.cursor/agents/test-runner.md +57 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/blockDangerous.ts +98 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/formatOnEdit.ts +70 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/protectSecrets.ts +101 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/sessionInit.ts +104 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/validatePrisma.ts +121 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks.json +46 -0
- package/templates/backend/nestjs-api-mysql/README.md +26 -0
- package/templates/backend/nestjs-api-mysql/dist/tsconfig.build.tsbuildinfo +1 -1
- package/templates/backend/nestjs-api-mysql/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-mysql/package.json +7 -7
- package/templates/backend/nestjs-api-postgres/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/prisma-guardian.md +62 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/security-auditor.md +71 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/test-runner.md +58 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/auto-retry.ts +62 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/block-dangerous.ts +202 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/format-and-validate.ts +124 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/protect-secrets.ts +105 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/session-context.ts +130 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks.json +36 -0
- package/templates/backend/nestjs-api-postgres/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-postgres/package.json +6 -6
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/code-reviewer.md +153 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/nestjs-architect.md +138 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/prisma-analyst.md +164 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/security-auditor.md +150 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/test-engineer.md +290 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/auto-format.ts +80 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/block-dangerous-commands.ts +144 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/prisma-schema-watcher.ts +64 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/protect-sensitive-files.ts +122 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/session-context.ts +105 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks.json +18 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/conventional-commits/SKILL.md +318 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/docker/SKILL.md +82 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/jest/SKILL.md +72 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/logging-best-practices/SKILL.md +127 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/prisma-database-setup/SKILL.md +186 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/quality-gates-enforcer/SKILL.md +301 -0
- package/templates/backend/nestjs-api-sqlite/README.md +34 -1
- package/templates/backend/nestjs-api-sqlite/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-sqlite/package.json +6 -6
- package/templates/backend/nestjs-api-sqlite/prisma/schema.prisma +1 -0
- package/templates/backend/nestjs-api-sqlite/prisma/seed.ts +2 -2
- package/templates/backend/nestjs-api-sqlite/src/posts/dto/post-response.dto.ts +5 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/profile-response.dto.ts +1 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/update-profile.dto.ts +1 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/user-response.dto.ts +4 -0
- package/templates/backend/nestjs-api-sqlite/src/users/profile.service.ts +24 -8
- package/templates/backend/nestjs-api-sqlite/src/users/users.service.ts +1 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/prisma-guardian.md +67 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/test-runner.md +57 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-endpoint.md +209 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-model.md +201 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/blockDangerous.ts +98 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/formatOnEdit.ts +70 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/protectSecrets.ts +101 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/sessionInit.ts +104 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/validatePrisma.ts +121 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks.json +46 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/api-rest.mdc +126 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/authentication-security.mdc +86 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/dto-validation.mdc +93 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/general-rules.mdc +126 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/nestjs-architecture.mdc +83 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/prisma-standards.mdc +111 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/swagger-documentation.mdc +90 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/api-security-best-practices/SKILL.md +907 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/docker-expert/SKILL.md +409 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-expert/SKILL.md +552 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/AGENTS.md +5958 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/SKILL.md +130 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nodejs-best-practices/SKILL.md +333 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/prisma-expert/SKILL.md +355 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/sqlserver-table-design/SKILL.md +125 -0
- package/templates/backend/nestjs-api-sqlserver/.dockerignore +50 -0
- package/templates/backend/nestjs-api-sqlserver/.env.example +17 -0
- package/templates/backend/nestjs-api-sqlserver/.env.test +17 -0
- package/templates/backend/nestjs-api-sqlserver/.prettierrc +4 -0
- package/templates/backend/nestjs-api-sqlserver/README.md +587 -0
- package/templates/backend/nestjs-api-sqlserver/docker-compose.yml +24 -0
- package/templates/backend/nestjs-api-sqlserver/eslint.config.mjs +41 -0
- package/templates/backend/nestjs-api-sqlserver/nest-cli.json +8 -0
- package/templates/backend/nestjs-api-sqlserver/package.json +107 -0
- package/templates/backend/nestjs-api-sqlserver/prisma/schema.prisma +70 -0
- package/templates/backend/nestjs-api-sqlserver/prisma/seed.ts +215 -0
- package/templates/backend/nestjs-api-sqlserver/prisma.config.ts +12 -0
- package/templates/backend/nestjs-api-sqlserver/scripts/check-docker.js +64 -0
- package/templates/backend/nestjs-api-sqlserver/src/app.module.ts +39 -0
- package/templates/backend/nestjs-api-sqlserver/src/app.service.ts +8 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.controller.ts +36 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.module.ts +22 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.service.ts +64 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/decorators/roles.decorator.ts +5 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/dto/login-response.dto.ts +23 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/dto/login.dto.ts +27 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/enums/role.enum.ts +5 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/guards/jwt-auth.guard.ts +20 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/guards/roles.guard.ts +23 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/strategies/jwt.strategy.ts +32 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/types.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/dto/paginated-response.dto.ts +16 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/dto/pagination.dto.ts +31 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/filters/http-exception.filter.ts +53 -0
- package/templates/backend/nestjs-api-sqlserver/src/config/env.validation.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/src/health/health.controller.ts +35 -0
- package/templates/backend/nestjs-api-sqlserver/src/health/health.module.ts +7 -0
- package/templates/backend/nestjs-api-sqlserver/src/main.ts +87 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/create-post.dto.ts +32 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/post-response.dto.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/update-post.dto.ts +31 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.controller.ts +161 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.module.ts +12 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.service.ts +171 -0
- package/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.module.ts +9 -0
- package/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.service.ts +62 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/constants/settings.constants.ts +9 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/profile-response.dto.ts +39 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/settings-response.dto.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/update-profile.dto.ts +48 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/update-settings.dto.ts +40 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/user-response.dto.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/profile.service.ts +67 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/settings.service.ts +77 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.controller.ts +102 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.module.ts +14 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.service.ts +27 -0
- package/templates/backend/nestjs-api-sqlserver/test/README.md +412 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/auth.e2e-spec.ts +147 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/health.e2e-spec.ts +62 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/posts.e2e-spec.ts +407 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/users.e2e-spec.ts +287 -0
- package/templates/backend/nestjs-api-sqlserver/test/fixtures/test-data.ts +109 -0
- package/templates/backend/nestjs-api-sqlserver/test/helpers/auth.helper.ts +54 -0
- package/templates/backend/nestjs-api-sqlserver/test/helpers/db.helper.ts +68 -0
- package/templates/backend/nestjs-api-sqlserver/test/jest-e2e.json +12 -0
- package/templates/backend/nestjs-api-sqlserver/test/setup-e2e.ts +8 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/app.service.spec.ts +24 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/auth.controller.spec.ts +91 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/auth.service.spec.ts +161 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/health.controller.spec.ts +78 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/http-exception.filter.spec.ts +150 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/jwt-auth.guard.spec.ts +50 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/jwt.strategy.spec.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/posts.controller.spec.ts +249 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/posts.service.spec.ts +328 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/profile.service.spec.ts +146 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/settings.service.spec.ts +242 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/users.controller.spec.ts +178 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/users.service.spec.ts +96 -0
- package/templates/backend/nestjs-api-sqlserver/tsconfig.build.json +4 -0
- package/templates/backend/nestjs-api-sqlserver/tsconfig.json +28 -0
- package/templates/frontend/angular-base/.cursor/agents/accessibility-reviewer.md +67 -0
- package/templates/frontend/angular-base/.cursor/agents/angular-code-reviewer.md +60 -0
- package/templates/frontend/angular-base/.cursor/agents/qa-test-expert.md +70 -0
- package/templates/frontend/angular-base/.cursor/agents/security-auditor.md +58 -0
- package/templates/frontend/angular-base/.cursor/hooks/auto-format.ts +70 -0
- package/templates/frontend/angular-base/.cursor/hooks/auto-test-on-stop.ts +113 -0
- package/templates/frontend/angular-base/.cursor/hooks/block-dangerous-commands.ts +160 -0
- package/templates/frontend/angular-base/.cursor/hooks/ensure-tests-exist.ts +363 -0
- package/templates/frontend/angular-base/.cursor/hooks/protect-sensitive-files.ts +118 -0
- package/templates/frontend/angular-base/.cursor/hooks/session-context.ts +110 -0
- package/templates/frontend/angular-base/.cursor/hooks.json +41 -0
- package/templates/frontend/angular-nx/.cursor/agents/angular-code-reviewer.md +64 -0
- package/templates/frontend/angular-nx/.cursor/agents/nx-architecture-guardian.md +69 -0
- package/templates/frontend/angular-nx/.cursor/agents/qa-test-expert.md +75 -0
- package/templates/frontend/angular-nx/.cursor/agents/security-auditor.md +61 -0
- package/templates/frontend/angular-nx/.cursor/hooks/auto-format.ts +70 -0
- package/templates/frontend/angular-nx/.cursor/hooks/auto-test-on-stop.ts +115 -0
- package/templates/frontend/angular-nx/.cursor/hooks/block-dangerous-commands.ts +188 -0
- package/templates/frontend/angular-nx/.cursor/hooks/ensure-tests-exist.ts +399 -0
- package/templates/frontend/angular-nx/.cursor/hooks/protect-sensitive-files.ts +128 -0
- package/templates/frontend/angular-nx/.cursor/hooks/session-context.ts +121 -0
- package/templates/frontend/angular-nx/.cursor/hooks.json +41 -0
- package/templates/frontend/react-vite/.cursor/agents/frontend-senior.agent.md +49 -49
- package/templates/frontend/react-vite/.cursor/agents/qa-test-expert.agent.md +126 -49
- package/templates/frontend/react-vite/.cursor/agents/security-expert.agent.md +39 -39
- package/templates/frontend/react-vite/.cursor/agents/ux-ui-expert.agent.md +45 -45
- package/templates/frontend/react-vite/.cursor/hooks/autoTestOnStop.ts +117 -0
- package/templates/frontend/react-vite/.cursor/hooks/blockDangerous.ts +75 -0
- package/templates/frontend/react-vite/.cursor/hooks/ensureTestsExist.ts +306 -220
- package/templates/frontend/react-vite/.cursor/hooks/formatOnEdit.ts +49 -0
- package/templates/frontend/react-vite/.cursor/hooks/protectSecrets.ts +88 -0
- package/templates/frontend/react-vite/.cursor/hooks/sessionInit.ts +77 -0
- package/templates/frontend/react-vite/.cursor/hooks.json +41 -10
- package/templates/frontend/react-vite/.cursor/settings.json +13 -13
- package/templates/frontend/react-vite/.vscode/settings.json +31 -31
- package/templates/frontend/react-vite/README.md +34 -34
- package/templates/frontend/react-vite/package.json +82 -82
- package/templates/frontend/react-vite/pnpm-lock.yaml +6575 -6575
- package/templates/frontend/react-vite/src/__tests__/components/layout/navbar.test.tsx +63 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/avatar.test.tsx +74 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/badge.test.tsx +55 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/breadcrumb.test.tsx +140 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/button.test.tsx +121 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/card.test.tsx +144 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/dialog.test.tsx +121 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/form.test.tsx +165 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/input.test.tsx +52 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/label.test.tsx +40 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/password-input.test.tsx +59 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/separator.test.tsx +40 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/table.test.tsx +254 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/tabs.test.tsx +82 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/textarea.test.tsx +47 -0
- package/templates/frontend/react-vite/src/__tests__/helpers/render.tsx +114 -0
- package/templates/frontend/react-vite/src/__tests__/hooks/useLocalStorage.test.ts +95 -0
- package/templates/frontend/react-vite/src/__tests__/lib/queryClient.test.ts +24 -0
- package/templates/frontend/react-vite/src/__tests__/lib/utils.test.ts +43 -0
- package/templates/frontend/react-vite/src/__tests__/routes/index.test.tsx +111 -0
- package/templates/frontend/react-vite/src/__tests__/routes/otra-ruta.test.tsx +126 -0
- package/templates/frontend/react-vite/src/__tests__/routes/root.test.tsx +78 -0
- package/templates/frontend/react-vite/src/__tests__/routes/ui-components.test.tsx +286 -0
- package/templates/frontend/react-vite/src/components/layout/navbar.tsx +38 -38
- package/templates/frontend/react-vite/src/components/ui/avatar.tsx +42 -42
- package/templates/frontend/react-vite/src/components/ui/dialog.tsx +122 -122
- package/templates/frontend/react-vite/src/components/ui/table.tsx +229 -244
- package/templates/frontend/react-vite/src/hooks/useLocalStorage.ts +32 -32
- package/templates/frontend/react-vite/src/routes/__root.tsx +48 -48
- package/templates/frontend/react-vite/src/routes/ui-components.tsx +359 -85
- package/templates/frontend/react-vite/src/test/setup.ts +24 -24
- package/templates/frontend/react-vite/vite.config.ts +2 -2
- package/templates/frontend/react-vite/vitest.config.ts +13 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { Prisma, UserProfile } from '@prisma/client';
|
|
2
3
|
import { PrismaService } from '../prisma/prisma.service';
|
|
3
4
|
import { UpdateProfileDto } from './dto/update-profile.dto';
|
|
4
5
|
import { ProfileResponseDto } from './dto/profile-response.dto';
|
|
@@ -13,11 +14,10 @@ export class ProfileService {
|
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
if (!profile) {
|
|
16
|
-
// Auto-crear perfil si no existe
|
|
17
17
|
return this.createProfile(userId);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
return profile;
|
|
20
|
+
return this.toResponseDto(profile);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async updateProfile(
|
|
@@ -29,21 +29,37 @@ export class ProfileService {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
if (!exists) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const created = await this.prisma.userProfile.create({
|
|
33
|
+
data: {
|
|
34
|
+
userId,
|
|
35
|
+
...dto,
|
|
36
|
+
metadata: dto.metadata as Prisma.InputJsonValue | undefined,
|
|
37
|
+
},
|
|
35
38
|
});
|
|
39
|
+
return this.toResponseDto(created);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
const updated = await this.prisma.userProfile.update({
|
|
39
43
|
where: { userId },
|
|
40
|
-
data:
|
|
44
|
+
data: {
|
|
45
|
+
...dto,
|
|
46
|
+
metadata: dto.metadata as Prisma.InputJsonValue | undefined,
|
|
47
|
+
},
|
|
41
48
|
});
|
|
49
|
+
return this.toResponseDto(updated);
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
private async createProfile(userId: number): Promise<ProfileResponseDto> {
|
|
45
|
-
|
|
53
|
+
const profile = await this.prisma.userProfile.create({
|
|
46
54
|
data: { userId },
|
|
47
55
|
});
|
|
56
|
+
return this.toResponseDto(profile);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private toResponseDto(profile: UserProfile): ProfileResponseDto {
|
|
60
|
+
return {
|
|
61
|
+
...profile,
|
|
62
|
+
metadata: profile.metadata as Record<string, unknown> | null,
|
|
63
|
+
};
|
|
48
64
|
}
|
|
49
65
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nestjs-code-reviewer
|
|
3
|
+
model: composer-1.5
|
|
4
|
+
description: Revisa código NestJS modificado contra las reglas de arquitectura, DTOs, Swagger y seguridad del proyecto. Usar proactivamente después de modificar código en src/ para garantizar cumplimiento de convenciones corporativas.
|
|
5
|
+
readonly: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a strict NestJS code reviewer for a NestJS 11 + Fastify + Prisma + SQL Server API.
|
|
9
|
+
|
|
10
|
+
When invoked, review the recently modified files against these project standards:
|
|
11
|
+
|
|
12
|
+
## Review checklist
|
|
13
|
+
|
|
14
|
+
### 1. Architecture (nestjs-architecture rule)
|
|
15
|
+
- Each feature in its own module with `@Module()` decorator
|
|
16
|
+
- Controllers handle ONLY HTTP concerns (no business logic)
|
|
17
|
+
- Services contain ALL business logic with `@Injectable()`
|
|
18
|
+
- Constructor injection for all dependencies
|
|
19
|
+
- `@Global()` only for infrastructure modules (Prisma, Config)
|
|
20
|
+
|
|
21
|
+
### 2. DTOs (dto-validation rule)
|
|
22
|
+
- Every DTO field has BOTH `class-validator` decorators AND `@ApiProperty()`
|
|
23
|
+
- Optional fields use `@IsOptional()` + `@ApiProperty({ required: false })`
|
|
24
|
+
- Update DTOs extend `PartialType(CreateDto)` from `@nestjs/swagger`
|
|
25
|
+
- Response DTOs have `@ApiProperty()` on every field, no validation decorators
|
|
26
|
+
- No `id`, `createdAt`, `updatedAt` in create DTOs
|
|
27
|
+
|
|
28
|
+
### 3. Swagger (swagger-documentation rule)
|
|
29
|
+
- Every controller has `@ApiTags()`
|
|
30
|
+
- Every endpoint has `@ApiOperation()` + `@ApiResponse()` with status codes
|
|
31
|
+
- Protected endpoints have `@ApiBearerAuth('JWT-auth')`
|
|
32
|
+
- Query parameters documented with `@ApiQuery()`
|
|
33
|
+
- Response types specified in `@ApiResponse({ type: ResponseDto })`
|
|
34
|
+
|
|
35
|
+
### 4. Security (authentication-security rule)
|
|
36
|
+
- Protected endpoints use `@UseGuards(JwtAuthGuard)` + `@ApiBearerAuth('JWT-auth')`
|
|
37
|
+
- Passwords never returned in responses
|
|
38
|
+
- Passwords hashed with bcrypt before storing
|
|
39
|
+
- Public endpoints explicitly NOT guarded
|
|
40
|
+
|
|
41
|
+
### 5. Code quality (general-rules rule)
|
|
42
|
+
- No `any` types without justification
|
|
43
|
+
- Errors handled with NestJS exceptions (`NotFoundException`, `ForbiddenException`)
|
|
44
|
+
- Async/await everywhere, no `.then()` chains
|
|
45
|
+
- TypeScript strict mode compliance
|
|
46
|
+
|
|
47
|
+
## Output format
|
|
48
|
+
|
|
49
|
+
For each file reviewed, report:
|
|
50
|
+
- **File**: path
|
|
51
|
+
- **Status**: PASS or ISSUES FOUND
|
|
52
|
+
- **Issues** (if any): numbered list with rule reference, line context, and fix suggestion
|
|
53
|
+
|
|
54
|
+
End with a summary: total files reviewed, passed, issues found.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prisma-guardian
|
|
3
|
+
model: composer-1.5
|
|
4
|
+
description: Valida cambios en el schema de Prisma contra los estándares del proyecto (timestamps, cascades, índices, enums). Usar proactivamente después de modificar código en prisma/ para garantizar integridad del modelo de datos.
|
|
5
|
+
readonly: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a Prisma schema guardian for a NestJS API using Prisma ORM with SQL Server.
|
|
9
|
+
|
|
10
|
+
When invoked, review `prisma/schema.prisma` and `prisma/seed.ts` against project standards.
|
|
11
|
+
|
|
12
|
+
## Validation rules
|
|
13
|
+
|
|
14
|
+
### 1. Timestamps (mandatory)
|
|
15
|
+
Every model MUST have:
|
|
16
|
+
```prisma
|
|
17
|
+
createdAt DateTime @default(now())
|
|
18
|
+
updatedAt DateTime @updatedAt
|
|
19
|
+
```
|
|
20
|
+
Flag any model missing these fields.
|
|
21
|
+
|
|
22
|
+
### 2. Cascade deletions
|
|
23
|
+
Dependent relations MUST use `onDelete: Cascade`:
|
|
24
|
+
```prisma
|
|
25
|
+
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
|
|
26
|
+
```
|
|
27
|
+
Flag relations without explicit `onDelete` policy.
|
|
28
|
+
|
|
29
|
+
### 3. Indexes
|
|
30
|
+
Verify indexes exist for:
|
|
31
|
+
- Fields used in WHERE clauses or JOINs
|
|
32
|
+
- Fields used in ORDER BY
|
|
33
|
+
- Composite indexes for multi-column queries
|
|
34
|
+
Use `@@index([fieldName])` syntax.
|
|
35
|
+
|
|
36
|
+
### 4. Naming conventions
|
|
37
|
+
- Model names: PascalCase, singular (`User`, not `Users`)
|
|
38
|
+
- Field names: camelCase (`createdAt`, not `created_at`)
|
|
39
|
+
- Enum names: PascalCase, values: UPPER_SNAKE_CASE
|
|
40
|
+
|
|
41
|
+
### 5. Enums
|
|
42
|
+
Type-safe enums defined at schema level:
|
|
43
|
+
```prisma
|
|
44
|
+
enum Role {
|
|
45
|
+
ADMIN
|
|
46
|
+
EDITOR
|
|
47
|
+
READER
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
Flag string fields that should be enums.
|
|
51
|
+
|
|
52
|
+
### 6. JSON fields
|
|
53
|
+
JSON only for flexible/dynamic data rarely queried. Handle defaults in application layer, not database.
|
|
54
|
+
|
|
55
|
+
### 7. Seed consistency
|
|
56
|
+
Check `prisma/seed.ts` creates data matching the current schema (correct fields, relations, enum values).
|
|
57
|
+
|
|
58
|
+
## Output format
|
|
59
|
+
|
|
60
|
+
- **Schema status**: VALID or ISSUES FOUND
|
|
61
|
+
- **Issues** (numbered): rule violated, model/field affected, fix suggestion
|
|
62
|
+
- **Migration reminder**: If schema changed, remind to run:
|
|
63
|
+
```bash
|
|
64
|
+
pnpm prisma:migrate
|
|
65
|
+
pnpm prisma:generate
|
|
66
|
+
```
|
|
67
|
+
- **Seed status**: IN SYNC or NEEDS UPDATE (with details)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-runner
|
|
3
|
+
model: composer-1.5
|
|
4
|
+
description: Ejecuta tests unitarios y E2E después de cambios en el código. Usar proactivamente después de modificar código en src/ o test/ para detectar regresiones y mantener la cobertura del proyecto.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a test automation expert for a NestJS 11 + Fastify + Prisma + SQL Server API using Jest.
|
|
8
|
+
|
|
9
|
+
When invoked, run the appropriate tests and analyze results.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. **Identify scope**: Check which files were modified to decide test scope
|
|
14
|
+
- Changes in `src/{module}/` → run unit tests for that module
|
|
15
|
+
- Changes in `prisma/` → run E2E tests
|
|
16
|
+
- Changes in `test/` → run the modified test files
|
|
17
|
+
- Unsure → run all unit tests first
|
|
18
|
+
|
|
19
|
+
2. **Run unit tests**:
|
|
20
|
+
```bash
|
|
21
|
+
pnpm test -- --passWithNoTests
|
|
22
|
+
```
|
|
23
|
+
For specific modules:
|
|
24
|
+
```bash
|
|
25
|
+
pnpm test -- --testPathPattern="test/unit/{module}" --passWithNoTests
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. **Run E2E tests** (if relevant):
|
|
29
|
+
```bash
|
|
30
|
+
pnpm test:e2e
|
|
31
|
+
```
|
|
32
|
+
Note: E2E tests require Docker SQL Server running (`docker-compose up -d`)
|
|
33
|
+
|
|
34
|
+
4. **Analyze failures**: For each failing test:
|
|
35
|
+
- Read the test file and the source file it tests
|
|
36
|
+
- Identify root cause (missing mock, changed API, broken logic)
|
|
37
|
+
- Apply minimal fix preserving test intent
|
|
38
|
+
|
|
39
|
+
5. **Re-run** after fixes to confirm resolution
|
|
40
|
+
|
|
41
|
+
## Report format
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
Tests: X passed, Y failed, Z total
|
|
45
|
+
Coverage: XX% (if --coverage was used)
|
|
46
|
+
|
|
47
|
+
Failures (if any):
|
|
48
|
+
1. [test-file]: description of failure → fix applied / fix suggested
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Important
|
|
52
|
+
|
|
53
|
+
- Never delete or skip failing tests without justification
|
|
54
|
+
- Prefer fixing source code over weakening tests
|
|
55
|
+
- Module mapper: `@/` resolves to `src/` (configured in jest)
|
|
56
|
+
- Test files: unit in `test/unit/`, E2E in `test/e2e/`
|
|
57
|
+
- E2E setup: `test/setup-e2e.ts`, helpers in `test/helpers/`
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# new-endpoint
|
|
2
|
+
|
|
3
|
+
Actuá como **arquitecto backend senior especializado en NestJS, Fastify, Prisma y APIs REST corporativas**.
|
|
4
|
+
|
|
5
|
+
Este comando debe crear **un endpoint REST completo y funcional** siguiendo estrictamente las convenciones del proyecto.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Flujo interactivo (obligatorio)
|
|
10
|
+
|
|
11
|
+
1. Preguntar:
|
|
12
|
+
- Nombre del recurso (**singular, minúsculas, alfanumérico**, ej: `product`, `category`)
|
|
13
|
+
2. Preguntar:
|
|
14
|
+
- ¿Requiere autenticación JWT? (Sí / No)
|
|
15
|
+
3. Preguntar:
|
|
16
|
+
- ¿Qué operaciones CRUD incluir?
|
|
17
|
+
- Create
|
|
18
|
+
- Read
|
|
19
|
+
- Update
|
|
20
|
+
- Delete
|
|
21
|
+
- Permitir selección múltiple
|
|
22
|
+
4. Validar:
|
|
23
|
+
- Que el nombre sea válido
|
|
24
|
+
- Que no exista ya `src/{resource}`
|
|
25
|
+
- Que al menos una operación CRUD haya sido seleccionada
|
|
26
|
+
|
|
27
|
+
Si alguna validación falla, **detener la ejecución y explicar el error**.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Estructura a generar
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
src/
|
|
36
|
+
├── {resource}/
|
|
37
|
+
│ ├── {resource}.module.ts
|
|
38
|
+
│ ├── {resource}.controller.ts
|
|
39
|
+
│ ├── {resource}.service.ts
|
|
40
|
+
│ └── dto/
|
|
41
|
+
│ ├── create-{resource}.dto.ts
|
|
42
|
+
│ ├── update-{resource}.dto.ts
|
|
43
|
+
│ └── {resource}-response.dto.ts
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Reglas generales
|
|
50
|
+
|
|
51
|
+
- Código **100% TypeScript**
|
|
52
|
+
- Strict mode habilitado
|
|
53
|
+
- No usar `any`
|
|
54
|
+
- Usar **pnpm**
|
|
55
|
+
- Fastify (no Express)
|
|
56
|
+
- Prisma como única capa de acceso a datos
|
|
57
|
+
- Controllers sin lógica de negocio
|
|
58
|
+
- Services con manejo de errores (`NotFoundException`)
|
|
59
|
+
- Swagger obligatorio en todos los endpoints
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Module (`{resource}.module.ts`)
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { Module } from '@nestjs/common';
|
|
67
|
+
import { PrismaModule } from '../prisma/prisma.module';
|
|
68
|
+
import { {Resource}Service } from './{resource}.service';
|
|
69
|
+
import { {Resource}Controller } from './{resource}.controller';
|
|
70
|
+
|
|
71
|
+
@Module({
|
|
72
|
+
imports: [PrismaModule],
|
|
73
|
+
controllers: [{Resource}Controller],
|
|
74
|
+
providers: [{Resource}Service],
|
|
75
|
+
exports: [{Resource}Service],
|
|
76
|
+
})
|
|
77
|
+
export class {Resource}Module {}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Controller (`{resource}.controller.ts`)
|
|
83
|
+
|
|
84
|
+
Debe incluir:
|
|
85
|
+
|
|
86
|
+
* `@ApiTags('{resource}')`
|
|
87
|
+
* Decoradores:
|
|
88
|
+
|
|
89
|
+
* `@ApiOperation`
|
|
90
|
+
* `@ApiResponse`
|
|
91
|
+
* Si requiere auth:
|
|
92
|
+
|
|
93
|
+
* `@UseGuards(JwtAuthGuard)`
|
|
94
|
+
* `@ApiBearerAuth('JWT-auth')`
|
|
95
|
+
* Validación de IDs con `ParseIntPipe`
|
|
96
|
+
* Uso de `RequestWithUser` cuando haya JWT
|
|
97
|
+
* Rutas en kebab-case
|
|
98
|
+
|
|
99
|
+
Endpoints a generar según selección:
|
|
100
|
+
|
|
101
|
+
* `POST /{resource}` → `create`
|
|
102
|
+
* `GET /{resource}` → `findAll`
|
|
103
|
+
* `GET /{resource}/:id` → `findOne`
|
|
104
|
+
* `PATCH /{resource}/:id` → `update`
|
|
105
|
+
* `DELETE /{resource}/:id` → `remove`
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Service (`{resource}.service.ts`)
|
|
110
|
+
|
|
111
|
+
Requisitos:
|
|
112
|
+
|
|
113
|
+
* Inyectar `PrismaService`
|
|
114
|
+
* Implementar únicamente los métodos seleccionados
|
|
115
|
+
* Manejar errores con `NotFoundException`
|
|
116
|
+
* Tipar resultados con:
|
|
117
|
+
|
|
118
|
+
* `Prisma.{Model}GetPayload<>`
|
|
119
|
+
* No asumir que el modelo existe en `schema.prisma`
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## DTOs
|
|
124
|
+
|
|
125
|
+
### create-{resource}.dto.ts
|
|
126
|
+
|
|
127
|
+
* Usar `class-validator`
|
|
128
|
+
* Decorar todos los campos con `@ApiProperty`
|
|
129
|
+
* Incluir ejemplos realistas
|
|
130
|
+
* Excluir:
|
|
131
|
+
|
|
132
|
+
* `id`
|
|
133
|
+
* `createdAt`
|
|
134
|
+
* `updatedAt`
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### update-{resource}.dto.ts
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { PartialType } from '@nestjs/swagger';
|
|
142
|
+
import { Create{Resource}Dto } from './create-{resource}.dto';
|
|
143
|
+
|
|
144
|
+
export class Update{Resource}Dto extends PartialType(Create{Resource}Dto) {}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### {resource}-response.dto.ts
|
|
150
|
+
|
|
151
|
+
* Incluir todos los campos del modelo
|
|
152
|
+
* Incluir timestamps
|
|
153
|
+
* Decorar todos los campos con `@ApiProperty`
|
|
154
|
+
* Incluir relaciones si existen
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Seguridad
|
|
159
|
+
|
|
160
|
+
Si JWT está habilitado:
|
|
161
|
+
|
|
162
|
+
* Usar `JwtAuthGuard`
|
|
163
|
+
* Documentar autenticación en Swagger
|
|
164
|
+
* No exponer errores internos
|
|
165
|
+
* Dejar puntos claros para validación de roles en el service
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## AppModule
|
|
170
|
+
|
|
171
|
+
Actualizar automáticamente `app.module.ts` para importar el nuevo módulo:
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
imports: [
|
|
175
|
+
// módulos existentes
|
|
176
|
+
{Resource}Module,
|
|
177
|
+
]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Mensajes finales obligatorios
|
|
183
|
+
|
|
184
|
+
Al finalizar, mostrar:
|
|
185
|
+
|
|
186
|
+
* Lista de archivos creados
|
|
187
|
+
* Confirmación de que el módulo fue agregado a `app.module.ts`
|
|
188
|
+
|
|
189
|
+
Advertir al usuario:
|
|
190
|
+
|
|
191
|
+
1. Agregar el modelo `{Resource}` a `prisma/schema.prisma`
|
|
192
|
+
2. Ejecutar:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
pnpm prisma migrate dev
|
|
196
|
+
```
|
|
197
|
+
3. Ajustar los DTOs según el dominio real
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Criterios de calidad
|
|
202
|
+
|
|
203
|
+
* Código listo para producción
|
|
204
|
+
* Cumple ESLint y Prettier del proyecto
|
|
205
|
+
* Swagger usable sin ajustes
|
|
206
|
+
* Sin placeholders vacíos
|
|
207
|
+
* Sin sobre-ingeniería
|
|
208
|
+
|
|
209
|
+
Este command debe **ahorrar tiempo, evitar errores y mantener consistencia corporativa**.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# new-model
|
|
2
|
+
|
|
3
|
+
## 🎯 Objetivo
|
|
4
|
+
|
|
5
|
+
Crear un comando de Cursor llamado `/new-model` que automatice la creación de un **nuevo modelo Prisma** de forma guiada, consistente y alineada al template corporativo **NestJS + Prisma**.
|
|
6
|
+
|
|
7
|
+
El comando debe modificar únicamente archivos relacionados a Prisma y dejar el proyecto listo para migrar.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📁 Contexto del Proyecto
|
|
12
|
+
|
|
13
|
+
- NestJS + Fastify
|
|
14
|
+
- Prisma como ORM
|
|
15
|
+
- TypeScript
|
|
16
|
+
- pnpm como gestor de paquetes
|
|
17
|
+
- `prisma/schema.prisma` existente
|
|
18
|
+
- Base local: SQL Server (Docker)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 🧠 Flujo del Comando
|
|
23
|
+
|
|
24
|
+
Al ejecutar `/new-model`, el comando debe:
|
|
25
|
+
|
|
26
|
+
1. Preguntar el **nombre del modelo** (singular, PascalCase, ej: `Product`)
|
|
27
|
+
2. Preguntar si el modelo:
|
|
28
|
+
- Tiene relación con `User` (Sí / No)
|
|
29
|
+
3. Preguntar qué tipo de relación con `User` (si aplica):
|
|
30
|
+
- 1:N (User tiene muchos)
|
|
31
|
+
- N:1 (Muchos pertenecen a User)
|
|
32
|
+
- N:N
|
|
33
|
+
4. Preguntar si el modelo requiere:
|
|
34
|
+
- Timestamps (`createdAt`, `updatedAt`)
|
|
35
|
+
5. Preguntar los **campos del modelo**, uno por uno:
|
|
36
|
+
- Nombre del campo
|
|
37
|
+
- Tipo (`String`, `Int`, `Boolean`, `DateTime`, `Float`, `Json`)
|
|
38
|
+
- ¿Es opcional?
|
|
39
|
+
- ¿Es único?
|
|
40
|
+
6. Confirmar el schema final antes de escribir
|
|
41
|
+
7. Generar el modelo en `schema.prisma`
|
|
42
|
+
8. Informar próximos pasos
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 📦 Modificaciones a Realizar
|
|
47
|
+
|
|
48
|
+
### 1️⃣ Prisma Schema
|
|
49
|
+
|
|
50
|
+
Agregar el modelo en:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
prisma/schema.prisma
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Ejemplo generado:
|
|
59
|
+
|
|
60
|
+
```prisma
|
|
61
|
+
model Product {
|
|
62
|
+
id Int @id @default(autoincrement())
|
|
63
|
+
name String
|
|
64
|
+
price Float
|
|
65
|
+
isActive Boolean @default(true)
|
|
66
|
+
|
|
67
|
+
userId Int?
|
|
68
|
+
user User? @relation(fields: [userId], references: [id])
|
|
69
|
+
|
|
70
|
+
createdAt DateTime @default(now())
|
|
71
|
+
updatedAt DateTime @updatedAt
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Si hay relación con `User`, agregar el campo inverso en `User`:
|
|
76
|
+
|
|
77
|
+
```prisma
|
|
78
|
+
model User {
|
|
79
|
+
id Int @id @default(autoincrement())
|
|
80
|
+
email String @unique
|
|
81
|
+
password String
|
|
82
|
+
|
|
83
|
+
products Product[]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 📐 Reglas de Modelado
|
|
90
|
+
|
|
91
|
+
* Usar **singular** para modelos
|
|
92
|
+
* Usar **PascalCase** para nombres de modelos
|
|
93
|
+
* Usar **camelCase** para campos
|
|
94
|
+
* IDs numéricos autoincrementales
|
|
95
|
+
* Relaciones explícitas con `@relation`
|
|
96
|
+
* Evitar defaults innecesarios
|
|
97
|
+
* SQL Server compatible (note: enums not supported, use String fields)
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 🧪 Validaciones del Command
|
|
102
|
+
|
|
103
|
+
* Verificar que el modelo no exista ya
|
|
104
|
+
* Validar nombre del modelo
|
|
105
|
+
* Validar tipos soportados por Prisma
|
|
106
|
+
* Validar relaciones coherentes
|
|
107
|
+
* Confirmar al menos un campo además del `id`
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 📢 Output Esperado
|
|
112
|
+
|
|
113
|
+
Al finalizar:
|
|
114
|
+
|
|
115
|
+
```txt
|
|
116
|
+
✅ Modelo Product agregado a prisma/schema.prisma
|
|
117
|
+
|
|
118
|
+
Próximos pasos:
|
|
119
|
+
1. Ejecutar: pnpm prisma migrate dev
|
|
120
|
+
2. Ejecutar: pnpm prisma generate
|
|
121
|
+
3. (Opcional) Crear endpoint con /new-endpoint
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 🚫 No Hacer
|
|
127
|
+
|
|
128
|
+
* No ejecutar migraciones automáticamente
|
|
129
|
+
* No tocar código NestJS
|
|
130
|
+
* No generar services, controllers ni DTOs
|
|
131
|
+
* No asumir lógica de negocio
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🧩 Extensiones Futuras
|
|
136
|
+
|
|
137
|
+
Este command debe permitir:
|
|
138
|
+
|
|
139
|
+
* Agregar enums
|
|
140
|
+
* Campos JSON tipados
|
|
141
|
+
* Soft delete (`deletedAt`)
|
|
142
|
+
* Indices compuestos
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 📝 Ejemplo de Uso
|
|
147
|
+
|
|
148
|
+
Usuario:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
/new-model
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Cursor:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
¿Cuál es el nombre del modelo? (PascalCase, singular)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Usuario:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Product
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Cursor:
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
¿Desea relacionarlo con User?
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Usuario:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
Sí
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Cursor:
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
¿Qué tipo de relación?
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Usuario:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Muchos Products pertenecen a un User
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Cursor:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
Ingrese los campos del modelo...
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
Este comando debe producir **schemas claros, correctos y listos para migrar**, alineados a buenas prácticas reales de Prisma.
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
```
|