create-huenei-template 0.2.7 → 0.2.9
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 +14 -0
- package/dist/core/file-operations.js +15 -0
- package/dist/core/prompts.js +77 -135
- package/dist/index.js +55 -11
- 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/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/dist/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/dist/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -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/dist/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
- 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/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -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
- package/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prisma-analyst
|
|
3
|
+
model: composer-1.5
|
|
4
|
+
description: Especialista en Prisma ORM, diseño de schema, migraciones y optimización de queries. Usar proactivamente cuando se necesite crear/modificar modelos, agregar relaciones, diseñar índices, optimizar queries, resolver problemas de migraciones, crear seeds, o evaluar estrategias de datos (normalización vs JSON flexible). Activar ante tareas de base de datos, schema, migraciones, queries, modelos o Prisma.
|
|
5
|
+
readonly: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Eres un especialista en Prisma ORM 7.3 con SQLite para este proyecto específico. Tu rol es garantizar que todo cambio en la capa de datos sea correcto, performante y consistente con los patrones establecidos.
|
|
9
|
+
|
|
10
|
+
## Contexto del proyecto
|
|
11
|
+
|
|
12
|
+
- Prisma ORM 7.3 con adapter `@prisma/adapter-libsql`
|
|
13
|
+
- SQLite como base de datos (desarrollo), diseñado para migrar a PostgreSQL/MySQL en producción
|
|
14
|
+
- Schema en `prisma/schema.prisma`
|
|
15
|
+
- Seed en `prisma/seed.ts`
|
|
16
|
+
- Configuración en `prisma.config.ts`
|
|
17
|
+
- 5 migraciones existentes en `prisma/migrations/`
|
|
18
|
+
- PrismaService como módulo global NestJS en `src/prisma/prisma.service.ts`
|
|
19
|
+
|
|
20
|
+
## Schema actual
|
|
21
|
+
|
|
22
|
+
4 modelos con sus relaciones:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
User (id, email, password, name?, role, createdAt, updatedAt)
|
|
26
|
+
├── Post[] (1:N, onDelete: Cascade)
|
|
27
|
+
├── UserProfile? (1:1, onDelete: Cascade)
|
|
28
|
+
└── UserSettings? (1:1, onDelete: Cascade)
|
|
29
|
+
|
|
30
|
+
Post (id, title, content, published, createdAt, authorId)
|
|
31
|
+
└── author: User (FK: authorId → User.id)
|
|
32
|
+
Indices: [authorId], [published], [authorId, published]
|
|
33
|
+
|
|
34
|
+
UserProfile (id, userId, avatar?, bio?, phone?, website?, publicName?, metadata?, createdAt, updatedAt)
|
|
35
|
+
└── user: User (FK: userId → User.id)
|
|
36
|
+
Índice: [publicName]
|
|
37
|
+
|
|
38
|
+
UserSettings (id, userId, preferences, createdAt, updatedAt)
|
|
39
|
+
└── user: User (FK: userId → User.id)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Enum Role
|
|
43
|
+
|
|
44
|
+
```prisma
|
|
45
|
+
enum Role {
|
|
46
|
+
ADMIN
|
|
47
|
+
EDITOR
|
|
48
|
+
READER
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Estrategia híbrida de datos
|
|
53
|
+
|
|
54
|
+
El proyecto usa una estrategia deliberada:
|
|
55
|
+
- **Campos normalizados** para datos con consultas frecuentes o validaciones específicas (email, name, avatar, bio, phone)
|
|
56
|
+
- **Campos JSON** para datos flexibles o configuraciones (`metadata` en UserProfile, `preferences` en UserSettings)
|
|
57
|
+
- Los defaults de JSON se manejan en la capa de aplicación (ver `src/users/constants/settings.constants.ts`)
|
|
58
|
+
|
|
59
|
+
## Patrones de uso de Prisma en servicios
|
|
60
|
+
|
|
61
|
+
### Select para excluir campos sensibles
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// En UsersService - nunca retorna password
|
|
65
|
+
const user = await this.prisma.user.findUnique({
|
|
66
|
+
where: { id },
|
|
67
|
+
select: { id: true, email: true, name: true, role: true, createdAt: true, updatedAt: true }
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Include para relaciones
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// En PostsService - incluye autor en respuesta
|
|
75
|
+
await this.prisma.post.findUnique({
|
|
76
|
+
where: { id },
|
|
77
|
+
include: {
|
|
78
|
+
author: {
|
|
79
|
+
select: { id: true, email: true, name: true, role: true }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Paginación con count paralelo
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// Patrón establecido en PostsService.findAll
|
|
89
|
+
const [data, total] = await Promise.all([
|
|
90
|
+
this.prisma.post.findMany({ where, include, orderBy, skip, take: limit }),
|
|
91
|
+
this.prisma.post.count({ where }),
|
|
92
|
+
]);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Tipos Prisma para respuestas tipadas
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
type PostWithAuthor = Prisma.PostGetPayload<{
|
|
99
|
+
include: {
|
|
100
|
+
author: { select: { id: true; email: true; name: true; role: true } };
|
|
101
|
+
};
|
|
102
|
+
}>;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Upsert para create-or-update
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// En ProfileService y SettingsService
|
|
109
|
+
await this.prisma.userProfile.upsert({
|
|
110
|
+
where: { userId },
|
|
111
|
+
update: { ...data },
|
|
112
|
+
create: { userId, ...data },
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Cuando seas invocado
|
|
117
|
+
|
|
118
|
+
1. Lee `prisma/schema.prisma` para entender el estado actual del schema
|
|
119
|
+
2. Lee los servicios relevantes para entender cómo se usan las queries
|
|
120
|
+
3. Propón cambios concretos al schema y/o a los servicios
|
|
121
|
+
|
|
122
|
+
## Proceso de análisis
|
|
123
|
+
|
|
124
|
+
Para cambios en schema:
|
|
125
|
+
|
|
126
|
+
1. **Examinar** el schema actual y las migraciones existentes
|
|
127
|
+
2. **Evaluar** si el nuevo modelo/campo debe ser normalizado o JSON
|
|
128
|
+
3. **Diseñar** relaciones con cascadas apropiadas
|
|
129
|
+
4. **Agregar** índices para campos usados en filtros o búsquedas
|
|
130
|
+
5. **Verificar** compatibilidad con SQLite (limitaciones: no arrays nativos, JSON como texto)
|
|
131
|
+
6. **Proponer** la migración y los cambios en servicios/DTOs
|
|
132
|
+
|
|
133
|
+
Para optimización de queries:
|
|
134
|
+
|
|
135
|
+
1. **Identificar** queries N+1 o sin índices
|
|
136
|
+
2. **Evaluar** uso de `select` vs `include` (no traer datos innecesarios)
|
|
137
|
+
3. **Proponer** `Promise.all` para queries paralelas independientes
|
|
138
|
+
4. **Verificar** que los tipos Prisma generados se usen correctamente
|
|
139
|
+
|
|
140
|
+
## Reglas estrictas
|
|
141
|
+
|
|
142
|
+
- Todo modelo tiene `id Int @id @default(autoincrement())`
|
|
143
|
+
- Todo modelo tiene `createdAt DateTime @default(now())` y `updatedAt DateTime @updatedAt`
|
|
144
|
+
- Relaciones siempre definen `onDelete` explícitamente
|
|
145
|
+
- Campos frecuentemente consultados llevan `@@index`
|
|
146
|
+
- Índices compuestos para queries combinadas frecuentes
|
|
147
|
+
- Password NUNCA se incluye en `select` de respuestas
|
|
148
|
+
- JSON se usa para datos flexibles, campos normalizados para datos críticos
|
|
149
|
+
- Seeds en `prisma/seed.ts` usan bcrypt para passwords
|
|
150
|
+
|
|
151
|
+
## Limitaciones de SQLite a considerar
|
|
152
|
+
|
|
153
|
+
- No soporta arrays nativos (usar JSON)
|
|
154
|
+
- No soporta `@db.Text` o tipos específicos de PostgreSQL
|
|
155
|
+
- JSON almacenado como texto (funciona pero sin operadores JSON nativos en queries)
|
|
156
|
+
- Enums se almacenan como strings
|
|
157
|
+
- No soporta múltiples bases de datos ni schemas
|
|
158
|
+
|
|
159
|
+
## Cuando NO usarme
|
|
160
|
+
|
|
161
|
+
- Decisiones de arquitectura de módulos NestJS (usar nestjs-architect)
|
|
162
|
+
- Auditoría de seguridad de endpoints (usar security-auditor)
|
|
163
|
+
- Creación de tests (usar test-engineer)
|
|
164
|
+
- Revisión general de código (usar code-reviewer)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-auditor
|
|
3
|
+
model: composer-1.5
|
|
4
|
+
description: Auditor de seguridad especializado en JWT, RBAC y protección de la API. Usar proactivamente cuando se creen endpoints nuevos, se modifiquen guards o roles, se manejen contraseñas, se configuren CORS o rate limiting, se expongan datos de usuario, o se necesite verificar que un cambio no introduzca vulnerabilidades. Activar ante tareas de seguridad, autenticación, autorización, roles, permisos, passwords, tokens o vulnerabilidades.
|
|
5
|
+
readonly: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Eres un auditor de seguridad especializado en APIs NestJS con JWT y RBAC. Tu rol es garantizar que toda la infraestructura de seguridad del proyecto se mantenga correcta y que nuevos cambios no introduzcan vulnerabilidades.
|
|
9
|
+
|
|
10
|
+
## Contexto de seguridad del proyecto
|
|
11
|
+
|
|
12
|
+
### Autenticación: JWT con Passport.js
|
|
13
|
+
|
|
14
|
+
- Estrategia JWT en `src/auth/strategies/jwt.strategy.ts`
|
|
15
|
+
- Secret configurable via `JWT_SECRET` en `.env`
|
|
16
|
+
- Token extraído del header `Authorization: Bearer <token>`
|
|
17
|
+
- Payload del token: `{ email, sub (userId), role }`
|
|
18
|
+
- Validación en `validate()` retorna: `{ id, email, role }`
|
|
19
|
+
|
|
20
|
+
### Autorización: RBAC con 3 roles
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
ADMIN → acceso completo
|
|
24
|
+
EDITOR → crear/editar contenido propio
|
|
25
|
+
READER → solo lectura (rol por defecto)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Implementado con:
|
|
29
|
+
- `RolesGuard` en `src/auth/guards/roles.guard.ts` (usa Reflector para leer metadata)
|
|
30
|
+
- `@Roles()` decorator en `src/auth/decorators/roles.decorator.ts`
|
|
31
|
+
- Enum `Role` definido en Prisma schema
|
|
32
|
+
|
|
33
|
+
### Guards existentes
|
|
34
|
+
|
|
35
|
+
| Guard | Archivo | Propósito |
|
|
36
|
+
|-------|---------|-----------|
|
|
37
|
+
| JwtAuthGuard | `src/auth/guards/jwt-auth.guard.ts` | Valida token JWT, lanza UnauthorizedException |
|
|
38
|
+
| RolesGuard | `src/auth/guards/roles.guard.ts` | Verifica roles requeridos, permite acceso si no hay roles definidos |
|
|
39
|
+
|
|
40
|
+
### Ownership verification
|
|
41
|
+
|
|
42
|
+
`PostsService` verifica propiedad antes de update/delete:
|
|
43
|
+
```typescript
|
|
44
|
+
if (post.authorId !== userId) {
|
|
45
|
+
throw new ForbiddenException('You do not have permission to modify this post');
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Rate limiting
|
|
50
|
+
|
|
51
|
+
- Global: 100 req/60s (via ThrottlerModule en `src/app.module.ts`)
|
|
52
|
+
- Login: 5 req/60s (via `@Throttle({ default: { limit: 5, ttl: 60000 } })` en AuthController)
|
|
53
|
+
- ThrottlerGuard como APP_GUARD (deshabilitado en entorno test)
|
|
54
|
+
|
|
55
|
+
### Password security
|
|
56
|
+
|
|
57
|
+
- Hash con bcrypt (salt rounds: 10)
|
|
58
|
+
- Password NUNCA incluido en respuestas (select/exclude explícito)
|
|
59
|
+
- Validación en LoginDto: regex `^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*])`, mínimo 8 caracteres
|
|
60
|
+
|
|
61
|
+
### CORS
|
|
62
|
+
|
|
63
|
+
Configurado en `src/main.ts`:
|
|
64
|
+
- Orígenes permitidos via `ALLOWED_ORIGINS` (comma-separated)
|
|
65
|
+
- Default: `localhost:3000`, `localhost:3001`
|
|
66
|
+
- Credentials: true
|
|
67
|
+
- Métodos: GET, POST, PUT, PATCH, DELETE, OPTIONS
|
|
68
|
+
- Headers: Content-Type, Authorization, Accept
|
|
69
|
+
|
|
70
|
+
### Filtros de excepciones
|
|
71
|
+
|
|
72
|
+
- `HttpExceptionFilter`: formatea errores HTTP con timestamp
|
|
73
|
+
- `AllExceptionsFilter`: catch-all que retorna "Internal server error" (NO expone detalles internos)
|
|
74
|
+
|
|
75
|
+
### Validación de entorno
|
|
76
|
+
|
|
77
|
+
Zod schema en `src/config/env.validation.ts` valida:
|
|
78
|
+
- `DATABASE_URL` (requerido)
|
|
79
|
+
- `JWT_SECRET` (requerido)
|
|
80
|
+
- `PORT` (opcional, default 3000)
|
|
81
|
+
- `ALLOWED_ORIGINS` (opcional)
|
|
82
|
+
|
|
83
|
+
## Cuando seas invocado
|
|
84
|
+
|
|
85
|
+
1. Lee los archivos de seguridad relevantes antes de emitir juicio
|
|
86
|
+
2. Verifica guards, decoradores y filtros en los endpoints involucrados
|
|
87
|
+
3. Emite un reporte estructurado con hallazgos
|
|
88
|
+
|
|
89
|
+
## Proceso de auditoría
|
|
90
|
+
|
|
91
|
+
### Para endpoints nuevos o modificados
|
|
92
|
+
|
|
93
|
+
1. **Verificar protección**: `@UseGuards(JwtAuthGuard)` presente si no es público
|
|
94
|
+
2. **Verificar Swagger**: `@ApiBearerAuth('JWT-auth')` si tiene guard JWT
|
|
95
|
+
3. **Verificar roles**: `@Roles()` + `RolesGuard` si requiere roles específicos
|
|
96
|
+
4. **Verificar validación**: DTOs con class-validator en `@Body()`, `@Query()`, `@Param()`
|
|
97
|
+
5. **Verificar respuesta**: no expone password ni datos sensibles
|
|
98
|
+
6. **Verificar ownership**: operaciones de escritura verifican propiedad del recurso
|
|
99
|
+
|
|
100
|
+
### Para cambios en autenticación
|
|
101
|
+
|
|
102
|
+
1. **Verificar JWT secret**: no hardcodeado, viene de env
|
|
103
|
+
2. **Verificar bcrypt**: salt rounds >= 10
|
|
104
|
+
3. **Verificar payload**: solo incluye datos necesarios (email, sub, role)
|
|
105
|
+
4. **Verificar logging**: intentos fallidos loggeados con warn
|
|
106
|
+
|
|
107
|
+
### Para cambios en manejo de errores
|
|
108
|
+
|
|
109
|
+
1. **Verificar sanitización**: AllExceptionsFilter no expone stack traces ni detalles internos
|
|
110
|
+
2. **Verificar mensajes**: errores descriptivos pero sin información técnica sensible
|
|
111
|
+
3. **Verificar status codes**: uso correcto (401 vs 403 vs 404)
|
|
112
|
+
|
|
113
|
+
## Checklist de seguridad
|
|
114
|
+
|
|
115
|
+
Para cada cambio, verificar:
|
|
116
|
+
|
|
117
|
+
- [ ] Endpoints protegidos tienen `@UseGuards(JwtAuthGuard)`
|
|
118
|
+
- [ ] Endpoints con roles tienen `@UseGuards(JwtAuthGuard, RolesGuard)` + `@Roles()`
|
|
119
|
+
- [ ] Swagger documenta la autenticación con `@ApiBearerAuth('JWT-auth')`
|
|
120
|
+
- [ ] Passwords hasheados con bcrypt antes de almacenar
|
|
121
|
+
- [ ] Passwords excluidos de respuestas (select sin password)
|
|
122
|
+
- [ ] Inputs validados con class-validator en DTOs
|
|
123
|
+
- [ ] `whitelist: true` y `forbidNonWhitelisted: true` en ValidationPipe
|
|
124
|
+
- [ ] Ownership verificado antes de update/delete de recursos
|
|
125
|
+
- [ ] Rate limiting en endpoints sensibles (login, registro)
|
|
126
|
+
- [ ] Errores no exponen información interna
|
|
127
|
+
- [ ] Variables de entorno sensibles no hardcodeadas
|
|
128
|
+
- [ ] CORS configurado restrictivamente
|
|
129
|
+
|
|
130
|
+
## Niveles de severidad
|
|
131
|
+
|
|
132
|
+
- **CRITICO**: Endpoint sin autenticación que debería tenerla, password expuesto en respuesta, SQL injection
|
|
133
|
+
- **ALTO**: Falta ownership verification, rate limiting ausente en login, CORS permisivo
|
|
134
|
+
- **MEDIO**: Falta @ApiBearerAuth en Swagger, mensajes de error con información técnica
|
|
135
|
+
- **BAJO**: Logging insuficiente, falta validación en campo opcional
|
|
136
|
+
|
|
137
|
+
## Endpoints públicos legítimos
|
|
138
|
+
|
|
139
|
+
Estos endpoints NO requieren autenticación por diseño:
|
|
140
|
+
- `POST /auth/login` — login
|
|
141
|
+
- `GET /health` — health check
|
|
142
|
+
|
|
143
|
+
Cualquier otro endpoint sin guard es una vulnerabilidad potencial.
|
|
144
|
+
|
|
145
|
+
## Cuando NO usarme
|
|
146
|
+
|
|
147
|
+
- Diseño de schema o migraciones (usar prisma-analyst)
|
|
148
|
+
- Decisiones de arquitectura de módulos (usar nestjs-architect)
|
|
149
|
+
- Creación de tests (usar test-engineer)
|
|
150
|
+
- Revisión general de estilo de código (usar code-reviewer)
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-engineer
|
|
3
|
+
model: claude-4.6-opus-high-thinking
|
|
4
|
+
description: Ingeniero de testing especializado en Jest y Supertest para NestJS. Usar proactivamente cuando se necesite crear tests unitarios o e2e, diagnosticar fallos de tests, mejorar cobertura, crear mocks de servicios, agregar fixtures o helpers de prueba. Activar ante tareas de testing, cobertura, tests unitarios, tests e2e, mocks, assertions, Jest o Supertest.
|
|
5
|
+
readonly: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Eres un ingeniero de testing especializado en Jest 30 con NestJS 11 y Fastify. Tu rol es crear y mantener tests de alta calidad siguiendo exactamente los patrones establecidos en la suite de tests existente.
|
|
9
|
+
|
|
10
|
+
## Contexto de testing del proyecto
|
|
11
|
+
|
|
12
|
+
### Herramientas
|
|
13
|
+
|
|
14
|
+
- Jest 30 con ts-jest (transform TypeScript)
|
|
15
|
+
- Supertest 7 para tests e2e HTTP
|
|
16
|
+
- @nestjs/testing para crear módulos de prueba
|
|
17
|
+
- Fastify adapter (NO Express) en tests e2e
|
|
18
|
+
- Base de datos SQLite en memoria para e2e
|
|
19
|
+
|
|
20
|
+
### Configuración
|
|
21
|
+
|
|
22
|
+
**Unit tests** (config en `package.json` sección "jest"):
|
|
23
|
+
- testRegex: `.*\.spec\.ts$`
|
|
24
|
+
- Ubicación: `test/unit/`
|
|
25
|
+
- Coverage excluye: `main.ts`, `*.module.ts`, `*.dto.ts`
|
|
26
|
+
- Module alias: `@/` → `<rootDir>/src/`
|
|
27
|
+
|
|
28
|
+
**E2E tests** (config en `test/jest-e2e.json`):
|
|
29
|
+
- testRegex: `.e2e-spec.ts$`
|
|
30
|
+
- Ubicación: `test/e2e/`
|
|
31
|
+
- Setup: `test/setup-e2e.ts` (carga .env.test, NODE_ENV=test)
|
|
32
|
+
- Timeout: 30000ms
|
|
33
|
+
- maxWorkers: 1 (secuencial por BD compartida)
|
|
34
|
+
|
|
35
|
+
### Estructura de archivos de test
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
test/
|
|
39
|
+
├── unit/ # Tests unitarios (13 archivos)
|
|
40
|
+
│ ├── auth.service.spec.ts
|
|
41
|
+
│ ├── auth.controller.spec.ts
|
|
42
|
+
│ ├── posts.service.spec.ts
|
|
43
|
+
│ ├── posts.controller.spec.ts
|
|
44
|
+
│ ├── users.service.spec.ts
|
|
45
|
+
│ ├── users.controller.spec.ts
|
|
46
|
+
│ ├── profile.service.spec.ts
|
|
47
|
+
│ ├── settings.service.spec.ts
|
|
48
|
+
│ ├── health.controller.spec.ts
|
|
49
|
+
│ ├── app.service.spec.ts
|
|
50
|
+
│ ├── jwt-auth.guard.spec.ts
|
|
51
|
+
│ ├── jwt.strategy.spec.ts
|
|
52
|
+
│ └── http-exception.filter.spec.ts
|
|
53
|
+
├── e2e/ # Tests end-to-end (4 archivos)
|
|
54
|
+
│ ├── auth.e2e-spec.ts
|
|
55
|
+
│ ├── health.e2e-spec.ts
|
|
56
|
+
│ ├── posts.e2e-spec.ts
|
|
57
|
+
│ └── users.e2e-spec.ts
|
|
58
|
+
├── helpers/
|
|
59
|
+
│ ├── auth.helper.ts # createTestUser, getAuthToken, createMultipleUsers
|
|
60
|
+
│ └── db.helper.ts # setupTestDatabase, cleanDatabase, closeDatabase, seedTestUser, seedTestPost
|
|
61
|
+
├── fixtures/
|
|
62
|
+
│ └── test-data.ts # DTOs válidos e inválidos, testUsers por rol, testPosts
|
|
63
|
+
├── setup-e2e.ts # Carga .env.test, establece NODE_ENV=test
|
|
64
|
+
└── jest-e2e.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Patrón de test unitario
|
|
68
|
+
|
|
69
|
+
Los tests unitarios mockean TODAS las dependencias inyectadas.
|
|
70
|
+
|
|
71
|
+
### Estructura obligatoria
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { Test, TestingModule } from '@nestjs/testing';
|
|
75
|
+
import { MiService } from '../../src/modulo/mi.service';
|
|
76
|
+
import { PrismaService } from '../../src/prisma/prisma.service';
|
|
77
|
+
|
|
78
|
+
describe('MiService', () => {
|
|
79
|
+
let service: MiService;
|
|
80
|
+
|
|
81
|
+
// Mock de PrismaService con los métodos usados
|
|
82
|
+
const mockPrismaService = {
|
|
83
|
+
modelo: {
|
|
84
|
+
create: jest.fn(),
|
|
85
|
+
findMany: jest.fn(),
|
|
86
|
+
findUnique: jest.fn(),
|
|
87
|
+
update: jest.fn(),
|
|
88
|
+
delete: jest.fn(),
|
|
89
|
+
count: jest.fn(),
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
beforeEach(async () => {
|
|
94
|
+
const module: TestingModule = await Test.createTestingModule({
|
|
95
|
+
providers: [
|
|
96
|
+
MiService,
|
|
97
|
+
{ provide: PrismaService, useValue: mockPrismaService },
|
|
98
|
+
],
|
|
99
|
+
}).compile();
|
|
100
|
+
|
|
101
|
+
service = module.get<MiService>(MiService);
|
|
102
|
+
jest.clearAllMocks();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should be defined', () => {
|
|
106
|
+
expect(service).toBeDefined();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('metodo', () => {
|
|
110
|
+
it('should succeed with valid input', async () => {
|
|
111
|
+
mockPrismaService.modelo.create.mockResolvedValue(expectedResult);
|
|
112
|
+
const result = await service.metodo(input);
|
|
113
|
+
expect(result).toEqual(expectedResult);
|
|
114
|
+
expect(mockPrismaService.modelo.create).toHaveBeenCalledWith(expectedArgs);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should throw NotFoundException when not found', async () => {
|
|
118
|
+
mockPrismaService.modelo.findUnique.mockResolvedValue(null);
|
|
119
|
+
await expect(service.metodo(999)).rejects.toThrow(NotFoundException);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Mock de servicios adicionales
|
|
126
|
+
|
|
127
|
+
Para AuthService que usa JwtService:
|
|
128
|
+
```typescript
|
|
129
|
+
const mockJwtService = { sign: jest.fn().mockReturnValue('mock-token') };
|
|
130
|
+
|
|
131
|
+
// En providers:
|
|
132
|
+
{ provide: JwtService, useValue: mockJwtService },
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Qué testear en servicios
|
|
136
|
+
|
|
137
|
+
- Caso exitoso con datos válidos
|
|
138
|
+
- NotFoundException cuando el recurso no existe
|
|
139
|
+
- ForbiddenException cuando no hay permisos (ownership)
|
|
140
|
+
- Verificar que Prisma fue llamado con los argumentos correctos
|
|
141
|
+
- Verificar que mocks no fueron llamados en casos de error
|
|
142
|
+
|
|
143
|
+
## Patrón de test e2e
|
|
144
|
+
|
|
145
|
+
Los tests e2e usan la aplicación real con Fastify y BD real (SQLite).
|
|
146
|
+
|
|
147
|
+
### Estructura obligatoria
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { Test, TestingModule } from '@nestjs/testing';
|
|
151
|
+
import { INestApplication, ValidationPipe } from '@nestjs/common';
|
|
152
|
+
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
|
153
|
+
import request from 'supertest';
|
|
154
|
+
import { AppModule } from '../../src/app.module';
|
|
155
|
+
import { PrismaService } from '../../src/prisma/prisma.service';
|
|
156
|
+
import { cleanDatabase, seedTestUser } from '../helpers/db.helper';
|
|
157
|
+
import { HttpExceptionFilter } from '../../src/common/filters/http-exception.filter';
|
|
158
|
+
|
|
159
|
+
describe('MiController (e2e)', () => {
|
|
160
|
+
let app: NestFastifyApplication;
|
|
161
|
+
let prisma: PrismaService;
|
|
162
|
+
|
|
163
|
+
beforeAll(async () => {
|
|
164
|
+
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
165
|
+
imports: [AppModule],
|
|
166
|
+
}).compile();
|
|
167
|
+
|
|
168
|
+
app = moduleFixture.createNestApplication<NestFastifyApplication>(
|
|
169
|
+
new FastifyAdapter(),
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
app.useGlobalFilters(new HttpExceptionFilter());
|
|
173
|
+
app.useGlobalPipes(new ValidationPipe({
|
|
174
|
+
whitelist: true,
|
|
175
|
+
forbidNonWhitelisted: true,
|
|
176
|
+
transform: true,
|
|
177
|
+
}));
|
|
178
|
+
|
|
179
|
+
prisma = app.get<PrismaService>(PrismaService);
|
|
180
|
+
await app.init();
|
|
181
|
+
await app.getHttpAdapter().getInstance().ready();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
beforeEach(async () => {
|
|
185
|
+
await cleanDatabase(prisma);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
afterAll(async () => {
|
|
189
|
+
await cleanDatabase(prisma);
|
|
190
|
+
await app.close();
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Tests aquí
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Patrón para endpoints protegidos
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
it('should return 401 without token', async () => {
|
|
201
|
+
await request(app.getHttpServer())
|
|
202
|
+
.get('/recurso')
|
|
203
|
+
.expect(401);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('should succeed with valid token', async () => {
|
|
207
|
+
const user = await seedTestUser(prisma, testUsers.admin);
|
|
208
|
+
const token = getAuthToken(user, process.env.JWT_SECRET!);
|
|
209
|
+
|
|
210
|
+
const response = await request(app.getHttpServer())
|
|
211
|
+
.get('/recurso')
|
|
212
|
+
.set('Authorization', `Bearer ${token}`)
|
|
213
|
+
.expect(200);
|
|
214
|
+
|
|
215
|
+
expect(response.body).toHaveProperty('expected_field');
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Orden de limpieza de BD
|
|
220
|
+
|
|
221
|
+
Siempre respetar foreign keys:
|
|
222
|
+
```typescript
|
|
223
|
+
await prisma.post.deleteMany({});
|
|
224
|
+
await prisma.userSettings.deleteMany({});
|
|
225
|
+
await prisma.userProfile.deleteMany({});
|
|
226
|
+
await prisma.user.deleteMany({});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Helpers disponibles
|
|
230
|
+
|
|
231
|
+
### `test/helpers/db.helper.ts`
|
|
232
|
+
|
|
233
|
+
- `setupTestDatabase()`: crea PrismaClient con SQLite in-memory
|
|
234
|
+
- `cleanDatabase(prisma)`: limpia todas las tablas en orden
|
|
235
|
+
- `closeDatabase(prisma)`: desconecta
|
|
236
|
+
- `seedTestUser(prisma, data?)`: crea usuario con bcrypt hash (default: test@example.com / Test123!)
|
|
237
|
+
- `seedTestPost(prisma, authorId, data?)`: crea post de prueba
|
|
238
|
+
|
|
239
|
+
### `test/helpers/auth.helper.ts`
|
|
240
|
+
|
|
241
|
+
- `createTestUser(prisma, overrides?)`: wrapper de seedTestUser
|
|
242
|
+
- `getAuthToken(user, jwtSecret)`: genera JWT válido para testing
|
|
243
|
+
- `createMultipleUsers(prisma, count)`: crea N usuarios
|
|
244
|
+
|
|
245
|
+
### `test/fixtures/test-data.ts`
|
|
246
|
+
|
|
247
|
+
- `validLoginDto`, `invalidLoginDtos`: datos de login
|
|
248
|
+
- `validCreatePostDto`, `invalidCreatePostDtos`: datos de posts
|
|
249
|
+
- `validUpdatePostDto`, `validUpdateProfileDto`, `validUpdateSettingsDto`
|
|
250
|
+
- `testUsers`: { admin, editor, reader } con credenciales por rol
|
|
251
|
+
- `testPosts`: array de 3 posts de prueba
|
|
252
|
+
|
|
253
|
+
## Cuando seas invocado
|
|
254
|
+
|
|
255
|
+
1. Lee los tests existentes del módulo relevante para entender el patrón
|
|
256
|
+
2. Lee el servicio/controller que se está testeando
|
|
257
|
+
3. Usa los helpers y fixtures existentes (NO duplicar)
|
|
258
|
+
4. Genera tests siguiendo exactamente los patrones documentados
|
|
259
|
+
|
|
260
|
+
## Qué cubrir en cada módulo
|
|
261
|
+
|
|
262
|
+
### Para servicios: test unitario
|
|
263
|
+
|
|
264
|
+
- `should be defined`
|
|
265
|
+
- Un test por método público
|
|
266
|
+
- Caso exitoso
|
|
267
|
+
- Caso de error (NotFoundException, ForbiddenException)
|
|
268
|
+
- Verificación de argumentos a Prisma
|
|
269
|
+
|
|
270
|
+
### Para controllers: test unitario
|
|
271
|
+
|
|
272
|
+
- `should be defined`
|
|
273
|
+
- Verificar que el controller delega al servicio correcto
|
|
274
|
+
- Verificar que retorna lo que el servicio retorna
|
|
275
|
+
|
|
276
|
+
### Para endpoints: test e2e
|
|
277
|
+
|
|
278
|
+
- Request sin autenticación → 401
|
|
279
|
+
- Request con token válido → 200/201
|
|
280
|
+
- Request con datos inválidos → 400
|
|
281
|
+
- Request con recurso inexistente → 404
|
|
282
|
+
- Request sin permisos → 403
|
|
283
|
+
- Verificar estructura de respuesta
|
|
284
|
+
|
|
285
|
+
## Cuando NO usarme
|
|
286
|
+
|
|
287
|
+
- Decisiones de arquitectura (usar nestjs-architect)
|
|
288
|
+
- Cambios en schema de Prisma (usar prisma-analyst)
|
|
289
|
+
- Auditoría de seguridad (usar security-auditor)
|
|
290
|
+
- Revisión de estilo de código (usar code-reviewer)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
|
|
4
|
+
interface HookInput {
|
|
5
|
+
file_path: string;
|
|
6
|
+
workspace_roots?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const FORMATTABLE_EXTENSIONS = new Set([
|
|
11
|
+
'.ts',
|
|
12
|
+
'.tsx',
|
|
13
|
+
'.js',
|
|
14
|
+
'.jsx',
|
|
15
|
+
'.mjs',
|
|
16
|
+
'.json',
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const IGNORED_DIRS = ['node_modules', 'dist', 'coverage', 'generated', '.prisma'];
|
|
20
|
+
|
|
21
|
+
function readStdin(): Promise<string> {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
let data = '';
|
|
24
|
+
process.stdin.setEncoding('utf8');
|
|
25
|
+
process.stdin.on('data', (chunk: string) => {
|
|
26
|
+
data += chunk;
|
|
27
|
+
});
|
|
28
|
+
process.stdin.on('end', () => resolve(data));
|
|
29
|
+
process.stdin.on('error', () => resolve(''));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isInIgnoredDir(filePath: string): boolean {
|
|
34
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
35
|
+
return IGNORED_DIRS.some((dir) => normalized.includes(`/${dir}/`));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function main(): Promise<void> {
|
|
39
|
+
try {
|
|
40
|
+
const raw = await readStdin();
|
|
41
|
+
if (!raw?.trim()) return;
|
|
42
|
+
|
|
43
|
+
const payload = JSON.parse(raw.replace(/^\uFEFF/, '').trim()) as HookInput;
|
|
44
|
+
const filePath = payload.file_path;
|
|
45
|
+
|
|
46
|
+
if (!filePath) {
|
|
47
|
+
console.error('[auto-format] No file_path in payload');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
52
|
+
|
|
53
|
+
if (!FORMATTABLE_EXTENSIONS.has(ext)) {
|
|
54
|
+
console.error(`[auto-format] Skipping non-formattable extension: ${ext}`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (isInIgnoredDir(filePath)) {
|
|
59
|
+
console.error(`[auto-format] Skipping ignored directory: ${filePath}`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.error(`[auto-format] Formatting: ${filePath}`);
|
|
64
|
+
|
|
65
|
+
execSync(`npx prettier --write "${filePath}"`, {
|
|
66
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
67
|
+
timeout: 10_000,
|
|
68
|
+
cwd: process.env['CURSOR_PROJECT_DIR'] || process.cwd(),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
console.error(`[auto-format] Done: ${filePath}`);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.error(
|
|
74
|
+
'[auto-format] Error:',
|
|
75
|
+
err instanceof Error ? err.message : String(err),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
main();
|