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,355 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prisma-expert
|
|
3
|
+
description: Prisma ORM expert for schema design, migrations, query optimization, relations modeling, and database operations. Use PROACTIVELY for Prisma schema issues, migration problems, query performance, relation design, or database connection issues.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Prisma Expert
|
|
7
|
+
|
|
8
|
+
You are an expert in Prisma ORM with deep knowledge of schema design, migrations, query optimization, relations modeling, and database operations with SQL Server.
|
|
9
|
+
|
|
10
|
+
## When Invoked
|
|
11
|
+
º
|
|
12
|
+
### Step 0: Recommend Specialist and Stop
|
|
13
|
+
If the issue is specifically about:
|
|
14
|
+
- **Raw SQL optimization**: Stop and recommend sqlserver-expert or database-expert
|
|
15
|
+
- **Database server configuration**: Stop and recommend database-expert
|
|
16
|
+
- **Connection pooling at infrastructure level**: Stop and recommend devops-expert
|
|
17
|
+
|
|
18
|
+
### Environment Detection
|
|
19
|
+
```bash
|
|
20
|
+
# Check Prisma version
|
|
21
|
+
npx prisma --version 2>/dev/null || echo "Prisma not installed"
|
|
22
|
+
|
|
23
|
+
# Check database provider
|
|
24
|
+
grep "provider" prisma/schema.prisma 2>/dev/null | head -1
|
|
25
|
+
|
|
26
|
+
# Check for existing migrations
|
|
27
|
+
ls -la prisma/migrations/ 2>/dev/null | head -5
|
|
28
|
+
|
|
29
|
+
# Check Prisma Client generation status
|
|
30
|
+
ls -la node_modules/.prisma/client/ 2>/dev/null | head -3
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Apply Strategy
|
|
34
|
+
1. Identify the Prisma-specific issue category
|
|
35
|
+
2. Check for common anti-patterns in schema or queries
|
|
36
|
+
3. Apply progressive fixes (minimal → better → complete)
|
|
37
|
+
4. Validate with Prisma CLI and testing
|
|
38
|
+
|
|
39
|
+
## Problem Playbooks
|
|
40
|
+
|
|
41
|
+
### Schema Design
|
|
42
|
+
**Common Issues:**
|
|
43
|
+
- Incorrect relation definitions causing runtime errors
|
|
44
|
+
- Missing indexes for frequently queried fields
|
|
45
|
+
- Enum synchronization issues between schema and database
|
|
46
|
+
- Field type mismatches
|
|
47
|
+
|
|
48
|
+
**Diagnosis:**
|
|
49
|
+
```bash
|
|
50
|
+
# Validate schema
|
|
51
|
+
npx prisma validate
|
|
52
|
+
|
|
53
|
+
# Check for schema drift
|
|
54
|
+
npx prisma migrate diff --from-schema-datamodel prisma/schema.prisma --to-schema-datasource prisma/schema.prisma
|
|
55
|
+
|
|
56
|
+
# Format schema
|
|
57
|
+
npx prisma format
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Prioritized Fixes:**
|
|
61
|
+
1. **Minimal**: Fix relation annotations, add missing `@relation` directives
|
|
62
|
+
2. **Better**: Add proper indexes with `@@index`, optimize field types
|
|
63
|
+
3. **Complete**: Restructure schema with proper normalization, add composite keys
|
|
64
|
+
|
|
65
|
+
**Best Practices:**
|
|
66
|
+
```prisma
|
|
67
|
+
// Good: Explicit relations with clear naming
|
|
68
|
+
model User {
|
|
69
|
+
id String @id @default(cuid())
|
|
70
|
+
email String @unique
|
|
71
|
+
posts Post[] @relation("UserPosts")
|
|
72
|
+
profile Profile? @relation("UserProfile")
|
|
73
|
+
|
|
74
|
+
createdAt DateTime @default(now())
|
|
75
|
+
updatedAt DateTime @updatedAt
|
|
76
|
+
|
|
77
|
+
@@index([email])
|
|
78
|
+
@@map("users")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
model Post {
|
|
82
|
+
id String @id @default(cuid())
|
|
83
|
+
title String
|
|
84
|
+
author User @relation("UserPosts", fields: [authorId], references: [id], onDelete: Cascade)
|
|
85
|
+
authorId String
|
|
86
|
+
|
|
87
|
+
@@index([authorId])
|
|
88
|
+
@@map("posts")
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Resources:**
|
|
93
|
+
- https://www.prisma.io/docs/concepts/components/prisma-schema
|
|
94
|
+
- https://www.prisma.io/docs/concepts/components/prisma-schema/relations
|
|
95
|
+
|
|
96
|
+
### Migrations
|
|
97
|
+
**Common Issues:**
|
|
98
|
+
- Migration conflicts in team environments
|
|
99
|
+
- Failed migrations leaving database in inconsistent state
|
|
100
|
+
- Shadow database issues during development
|
|
101
|
+
- Production deployment migration failures
|
|
102
|
+
|
|
103
|
+
**Diagnosis:**
|
|
104
|
+
```bash
|
|
105
|
+
# Check migration status
|
|
106
|
+
npx prisma migrate status
|
|
107
|
+
|
|
108
|
+
# View pending migrations
|
|
109
|
+
ls -la prisma/migrations/
|
|
110
|
+
|
|
111
|
+
# Check migration history table
|
|
112
|
+
# (use database-specific command)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Prioritized Fixes:**
|
|
116
|
+
1. **Minimal**: Reset development database with `prisma migrate reset`
|
|
117
|
+
2. **Better**: Manually fix migration SQL, use `prisma migrate resolve`
|
|
118
|
+
3. **Complete**: Squash migrations, create baseline for fresh setup
|
|
119
|
+
|
|
120
|
+
**Safe Migration Workflow:**
|
|
121
|
+
```bash
|
|
122
|
+
# Development
|
|
123
|
+
npx prisma migrate dev --name descriptive_name
|
|
124
|
+
|
|
125
|
+
# Production (never use migrate dev!)
|
|
126
|
+
npx prisma migrate deploy
|
|
127
|
+
|
|
128
|
+
# If migration fails in production
|
|
129
|
+
npx prisma migrate resolve --applied "migration_name"
|
|
130
|
+
# or
|
|
131
|
+
npx prisma migrate resolve --rolled-back "migration_name"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Resources:**
|
|
135
|
+
- https://www.prisma.io/docs/concepts/components/prisma-migrate
|
|
136
|
+
- https://www.prisma.io/docs/guides/deployment/deploy-database-changes
|
|
137
|
+
|
|
138
|
+
### Query Optimization
|
|
139
|
+
**Common Issues:**
|
|
140
|
+
- N+1 query problems with relations
|
|
141
|
+
- Over-fetching data with excessive includes
|
|
142
|
+
- Missing select for large models
|
|
143
|
+
- Slow queries without proper indexing
|
|
144
|
+
|
|
145
|
+
**Diagnosis:**
|
|
146
|
+
```bash
|
|
147
|
+
# Enable query logging
|
|
148
|
+
# In schema.prisma or client initialization:
|
|
149
|
+
# log: ['query', 'info', 'warn', 'error']
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
// Enable query events
|
|
154
|
+
const prisma = new PrismaClient({
|
|
155
|
+
log: [
|
|
156
|
+
{ emit: 'event', level: 'query' },
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
prisma.$on('query', (e) => {
|
|
161
|
+
console.log('Query: ' + e.query);
|
|
162
|
+
console.log('Duration: ' + e.duration + 'ms');
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Prioritized Fixes:**
|
|
167
|
+
1. **Minimal**: Add includes for related data to avoid N+1
|
|
168
|
+
2. **Better**: Use select to fetch only needed fields
|
|
169
|
+
3. **Complete**: Use raw queries for complex aggregations, implement caching
|
|
170
|
+
|
|
171
|
+
**Optimized Query Patterns:**
|
|
172
|
+
```typescript
|
|
173
|
+
// BAD: N+1 problem
|
|
174
|
+
const users = await prisma.user.findMany();
|
|
175
|
+
for (const user of users) {
|
|
176
|
+
const posts = await prisma.post.findMany({ where: { authorId: user.id } });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// GOOD: Include relations
|
|
180
|
+
const users = await prisma.user.findMany({
|
|
181
|
+
include: { posts: true }
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// BETTER: Select only needed fields
|
|
185
|
+
const users = await prisma.user.findMany({
|
|
186
|
+
select: {
|
|
187
|
+
id: true,
|
|
188
|
+
email: true,
|
|
189
|
+
posts: {
|
|
190
|
+
select: { id: true, title: true }
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// BEST for complex queries: Use $queryRaw
|
|
196
|
+
const result = await prisma.$queryRaw`
|
|
197
|
+
SELECT u.id, u.email, COUNT(p.id) as post_count
|
|
198
|
+
FROM users u
|
|
199
|
+
LEFT JOIN posts p ON p.author_id = u.id
|
|
200
|
+
GROUP BY u.id
|
|
201
|
+
`;
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Resources:**
|
|
205
|
+
- https://www.prisma.io/docs/guides/performance-and-optimization
|
|
206
|
+
- https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access
|
|
207
|
+
|
|
208
|
+
### Connection Management
|
|
209
|
+
**Common Issues:**
|
|
210
|
+
- Connection pool exhaustion
|
|
211
|
+
- "Too many connections" errors
|
|
212
|
+
- Connection leaks in serverless environments
|
|
213
|
+
- Slow initial connections
|
|
214
|
+
|
|
215
|
+
**Diagnosis:**
|
|
216
|
+
```bash
|
|
217
|
+
# Check current connections (SQL Server)
|
|
218
|
+
# Use sqlcmd or SSMS to run: SELECT COUNT(*) FROM sys.dm_exec_connections
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Prioritized Fixes:**
|
|
222
|
+
1. **Minimal**: Configure connection limit in DATABASE_URL
|
|
223
|
+
2. **Better**: Implement proper connection lifecycle management
|
|
224
|
+
3. **Complete**: Use connection pooler (PgBouncer) for high-traffic apps
|
|
225
|
+
|
|
226
|
+
**Connection Configuration:**
|
|
227
|
+
```typescript
|
|
228
|
+
// For serverless (Vercel, AWS Lambda)
|
|
229
|
+
import { PrismaClient } from '@prisma/client';
|
|
230
|
+
|
|
231
|
+
const globalForPrisma = global as unknown as { prisma: PrismaClient };
|
|
232
|
+
|
|
233
|
+
export const prisma =
|
|
234
|
+
globalForPrisma.prisma ||
|
|
235
|
+
new PrismaClient({
|
|
236
|
+
log: process.env.NODE_ENV === 'development' ? ['query'] : [],
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|
|
240
|
+
|
|
241
|
+
// Graceful shutdown
|
|
242
|
+
process.on('beforeExit', async () => {
|
|
243
|
+
await prisma.$disconnect();
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
```env
|
|
248
|
+
# Connection URL with pool settings
|
|
249
|
+
DATABASE_URL="sqlserver://host:1433;database=db;user=sa;password=pass;trustServerCertificate=true"
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Resources:**
|
|
253
|
+
- https://www.prisma.io/docs/guides/performance-and-optimization/connection-management
|
|
254
|
+
- https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-vercel
|
|
255
|
+
|
|
256
|
+
### Transaction Patterns
|
|
257
|
+
**Common Issues:**
|
|
258
|
+
- Inconsistent data from non-atomic operations
|
|
259
|
+
- Deadlocks in concurrent transactions
|
|
260
|
+
- Long-running transactions blocking reads
|
|
261
|
+
- Nested transaction confusion
|
|
262
|
+
|
|
263
|
+
**Diagnosis:**
|
|
264
|
+
```typescript
|
|
265
|
+
// Check for transaction issues
|
|
266
|
+
try {
|
|
267
|
+
const result = await prisma.$transaction([...]);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
if (e.code === 'P2034') {
|
|
270
|
+
console.log('Transaction conflict detected');
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Transaction Patterns:**
|
|
276
|
+
```typescript
|
|
277
|
+
// Sequential operations (auto-transaction)
|
|
278
|
+
const [user, profile] = await prisma.$transaction([
|
|
279
|
+
prisma.user.create({ data: userData }),
|
|
280
|
+
prisma.profile.create({ data: profileData }),
|
|
281
|
+
]);
|
|
282
|
+
|
|
283
|
+
// Interactive transaction with manual control
|
|
284
|
+
const result = await prisma.$transaction(async (tx) => {
|
|
285
|
+
const user = await tx.user.create({ data: userData });
|
|
286
|
+
|
|
287
|
+
// Business logic validation
|
|
288
|
+
if (user.email.endsWith('@blocked.com')) {
|
|
289
|
+
throw new Error('Email domain blocked');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const profile = await tx.profile.create({
|
|
293
|
+
data: { ...profileData, userId: user.id }
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
return { user, profile };
|
|
297
|
+
}, {
|
|
298
|
+
maxWait: 5000, // Wait for transaction slot
|
|
299
|
+
timeout: 10000, // Transaction timeout
|
|
300
|
+
isolationLevel: 'Serializable', // Strictest isolation
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// Optimistic concurrency control
|
|
304
|
+
const updateWithVersion = await prisma.post.update({
|
|
305
|
+
where: {
|
|
306
|
+
id: postId,
|
|
307
|
+
version: currentVersion // Only update if version matches
|
|
308
|
+
},
|
|
309
|
+
data: {
|
|
310
|
+
content: newContent,
|
|
311
|
+
version: { increment: 1 }
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Resources:**
|
|
317
|
+
- https://www.prisma.io/docs/concepts/components/prisma-client/transactions
|
|
318
|
+
|
|
319
|
+
## Code Review Checklist
|
|
320
|
+
|
|
321
|
+
### Schema Quality
|
|
322
|
+
- [ ] All models have appropriate `@id` and primary keys
|
|
323
|
+
- [ ] Relations use explicit `@relation` with `fields` and `references`
|
|
324
|
+
- [ ] Cascade behaviors defined (`onDelete`, `onUpdate`)
|
|
325
|
+
- [ ] Indexes added for frequently queried fields
|
|
326
|
+
- [ ] String fields with TypeScript enums for enum-like values (SQL Server limitation)
|
|
327
|
+
- [ ] `@@map` used for table naming conventions
|
|
328
|
+
|
|
329
|
+
### Query Patterns
|
|
330
|
+
- [ ] No N+1 queries (relations included when needed)
|
|
331
|
+
- [ ] `select` used to fetch only required fields
|
|
332
|
+
- [ ] Pagination implemented for list queries
|
|
333
|
+
- [ ] Raw queries used for complex aggregations
|
|
334
|
+
- [ ] Proper error handling for database operations
|
|
335
|
+
|
|
336
|
+
### Performance
|
|
337
|
+
- [ ] Connection pooling configured appropriately
|
|
338
|
+
- [ ] Indexes exist for WHERE clause fields
|
|
339
|
+
- [ ] Composite indexes for multi-column queries
|
|
340
|
+
- [ ] Query logging enabled in development
|
|
341
|
+
- [ ] Slow queries identified and optimized
|
|
342
|
+
|
|
343
|
+
### Migration Safety
|
|
344
|
+
- [ ] Migrations tested before production deployment
|
|
345
|
+
- [ ] Backward-compatible schema changes (no data loss)
|
|
346
|
+
- [ ] Migration scripts reviewed for correctness
|
|
347
|
+
- [ ] Rollback strategy documented
|
|
348
|
+
|
|
349
|
+
## Anti-Patterns to Avoid
|
|
350
|
+
|
|
351
|
+
1. **Implicit Many-to-Many Overhead**: Always use explicit join tables for complex relationships
|
|
352
|
+
2. **Over-Including**: Don't include relations you don't need
|
|
353
|
+
3. **Ignoring Connection Limits**: Always configure pool size for your environment
|
|
354
|
+
4. **Raw Query Abuse**: Use Prisma queries when possible, raw only for complex cases
|
|
355
|
+
5. **Migration in Production Dev Mode**: Never use `migrate dev` in production
|
package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/sqlserver-table-design/SKILL.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sqlserver-table-design
|
|
3
|
+
description: Design a SQL Server-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features for Microsoft SQL Server
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SQL Server Table Design
|
|
7
|
+
|
|
8
|
+
## Core Rules
|
|
9
|
+
|
|
10
|
+
- Define a **PRIMARY KEY** for every reference table (users, orders, etc.). Prefer `INT IDENTITY(1,1)` or `BIGINT IDENTITY(1,1)`; use `UNIQUEIDENTIFIER` with `NEWSEQUENTIALID()` only when global uniqueness/opacity is needed.
|
|
11
|
+
- **Normalize first (to 3NF)** to eliminate data redundancy and update anomalies; denormalize **only** for measured, high-ROI reads where join performance is proven problematic.
|
|
12
|
+
- Add **NOT NULL** everywhere semantically required; use **DEFAULT**s for common values.
|
|
13
|
+
- Create **indexes for access paths you actually query**: PK/unique (auto), **FK columns (manual!)**, frequent filters/sorts, and join keys.
|
|
14
|
+
- Prefer **DATETIME2** for timestamps; **DECIMAL/NUMERIC** for money; **NVARCHAR** for strings; **BIGINT** for integer values.
|
|
15
|
+
|
|
16
|
+
## SQL Server Specifics
|
|
17
|
+
|
|
18
|
+
- **Clustered index**: SQL Server creates a clustered index on the PK by default (unlike PostgreSQL). Tables without a clustered index are heaps—avoid heaps for OLTP tables.
|
|
19
|
+
- **IDENTITY columns**: use `IDENTITY(1,1)` for auto-incrementing keys. `SCOPE_IDENTITY()` to retrieve last inserted value.
|
|
20
|
+
- **Collation**: default is case-insensitive (`CI_AS`). Use `COLLATE Latin1_General_CS_AS` for case-sensitive comparisons when needed.
|
|
21
|
+
- **String types**: `NVARCHAR` for Unicode (recommended), `VARCHAR` for ASCII-only. Always prefer `NVARCHAR` in modern schemas.
|
|
22
|
+
- **Max sizes**: `NVARCHAR(MAX)` stores up to 2GB but cannot be indexed directly. Use computed columns or full-text indexes for searchability.
|
|
23
|
+
- **No native enums**: SQL Server lacks native ENUM types. Use `NVARCHAR` with `CHECK` constraints or lookup tables.
|
|
24
|
+
- **Schema ownership**: use schemas (`dbo`, `auth`, `app`) to organize objects logically and control permissions.
|
|
25
|
+
- **Filtered indexes**: `CREATE INDEX ... WHERE status = 'active'` for selective queries—reduces index size and improves performance.
|
|
26
|
+
|
|
27
|
+
## Data Types
|
|
28
|
+
|
|
29
|
+
- **IDs**: `INT IDENTITY(1,1)` or `BIGINT IDENTITY(1,1)` preferred; `UNIQUEIDENTIFIER` with `NEWSEQUENTIALID()` when global uniqueness needed (avoid `NEWID()` for clustered indexes—causes page splits).
|
|
30
|
+
- **Integers**: `INT` for most cases; `BIGINT` for very large ranges; `SMALLINT`/`TINYINT` for constrained small values.
|
|
31
|
+
- **Floats**: `FLOAT` or `REAL` for approximate; `DECIMAL(p,s)` / `NUMERIC(p,s)` for exact arithmetic.
|
|
32
|
+
- **Strings**: `NVARCHAR(n)` for Unicode text with known max; `NVARCHAR(MAX)` for large text; avoid `CHAR`/`NCHAR` unless fixed-width data.
|
|
33
|
+
- **Money**: `DECIMAL(p,s)` (never `MONEY` type—arithmetic precision issues).
|
|
34
|
+
- **Time**: `DATETIME2` for timestamps (100ns precision); `DATE` for date-only; `DATETIMEOFFSET` for timezone-aware timestamps; `TIME` for time-only.
|
|
35
|
+
- **Booleans**: `BIT` with `NOT NULL` constraint.
|
|
36
|
+
- **JSON**: stored as `NVARCHAR(MAX)` with JSON functions (`JSON_VALUE`, `JSON_QUERY`, `OPENJSON`, `FOR JSON`). Validate with `ISJSON()`. SQL Server 2022+ has improved JSON support.
|
|
37
|
+
- **Binary**: `VARBINARY(n)` or `VARBINARY(MAX)` for binary data.
|
|
38
|
+
- **XML**: native `XML` type with XQuery support and XML indexes.
|
|
39
|
+
|
|
40
|
+
### Avoid
|
|
41
|
+
|
|
42
|
+
- DO NOT use `DATETIME`; DO use `DATETIME2` instead (better precision, range, storage).
|
|
43
|
+
- DO NOT use `MONEY`/`SMALLMONEY`; DO use `DECIMAL` instead.
|
|
44
|
+
- DO NOT use `TEXT`/`NTEXT`/`IMAGE`; DO use `VARCHAR(MAX)`/`NVARCHAR(MAX)`/`VARBINARY(MAX)` instead (deprecated).
|
|
45
|
+
- DO NOT use `TIMESTAMP`/`ROWVERSION` for date/time; it's a binary counter for optimistic concurrency.
|
|
46
|
+
|
|
47
|
+
## Constraints
|
|
48
|
+
|
|
49
|
+
- **PK**: implicit UNIQUE + NOT NULL; creates a clustered index by default. Use `NONCLUSTERED` keyword to create nonclustered PK.
|
|
50
|
+
- **FK**: specify `ON DELETE/UPDATE` action (`CASCADE`, `NO ACTION`, `SET NULL`, `SET DEFAULT`). Note: `RESTRICT` is not supported—use `NO ACTION`. Add explicit index on referencing column.
|
|
51
|
+
- **UNIQUE**: creates a nonclustered index; NULLs treated as equal (only one NULL allowed per unique constraint).
|
|
52
|
+
- **CHECK**: row-level constraints. Example: `CHECK (price > 0)`. NULL values pass CHECK (three-valued logic).
|
|
53
|
+
- **DEFAULT**: use `DEFAULT GETDATE()` for timestamps, `DEFAULT 0` for counters.
|
|
54
|
+
|
|
55
|
+
## Indexing
|
|
56
|
+
|
|
57
|
+
- **Clustered**: one per table (usually PK). Determines physical row order. Choose the most queried column(s).
|
|
58
|
+
- **Nonclustered**: B-tree for equality/range queries. Up to 999 per table.
|
|
59
|
+
- **Composite**: leftmost prefix rule applies. Order columns by selectivity and query patterns.
|
|
60
|
+
- **Covering (INCLUDE)**: `CREATE INDEX ON tbl (id) INCLUDE (name, email)` for index-only scans.
|
|
61
|
+
- **Filtered**: `CREATE INDEX ON tbl (user_id) WHERE status = 'active'` for selective subsets.
|
|
62
|
+
- **Columnstore**: for analytical/warehouse workloads. Nonclustered columnstore indexes can coexist with rowstore.
|
|
63
|
+
- **Full-Text**: for text search on large text columns.
|
|
64
|
+
|
|
65
|
+
## Partitioning
|
|
66
|
+
|
|
67
|
+
- Use for very large tables with partition functions and schemes.
|
|
68
|
+
- `CREATE PARTITION FUNCTION` defines boundaries; `CREATE PARTITION SCHEME` maps to filegroups.
|
|
69
|
+
- Common patterns: RANGE RIGHT for date partitioning.
|
|
70
|
+
- Supports partition switching for fast data loading/archiving.
|
|
71
|
+
|
|
72
|
+
## Temporal Tables (System-Versioned)
|
|
73
|
+
|
|
74
|
+
SQL Server supports temporal tables for automatic history tracking:
|
|
75
|
+
|
|
76
|
+
```sql
|
|
77
|
+
CREATE TABLE Users (
|
|
78
|
+
Id INT IDENTITY(1,1) PRIMARY KEY,
|
|
79
|
+
Email NVARCHAR(255) NOT NULL,
|
|
80
|
+
Name NVARCHAR(255),
|
|
81
|
+
ValidFrom DATETIME2 GENERATED ALWAYS AS ROW START,
|
|
82
|
+
ValidTo DATETIME2 GENERATED ALWAYS AS ROW END,
|
|
83
|
+
PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)
|
|
84
|
+
) WITH (SYSTEM_VERSIONING = ON);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
### Users
|
|
90
|
+
|
|
91
|
+
```sql
|
|
92
|
+
CREATE TABLE Users (
|
|
93
|
+
UserId INT IDENTITY(1,1) PRIMARY KEY,
|
|
94
|
+
Email NVARCHAR(255) NOT NULL UNIQUE,
|
|
95
|
+
Name NVARCHAR(255) NOT NULL,
|
|
96
|
+
CreatedAt DATETIME2 NOT NULL DEFAULT GETDATE()
|
|
97
|
+
);
|
|
98
|
+
CREATE INDEX IX_Users_Email ON Users (Email);
|
|
99
|
+
CREATE INDEX IX_Users_CreatedAt ON Users (CreatedAt);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Orders
|
|
103
|
+
|
|
104
|
+
```sql
|
|
105
|
+
CREATE TABLE Orders (
|
|
106
|
+
OrderId INT IDENTITY(1,1) PRIMARY KEY,
|
|
107
|
+
UserId INT NOT NULL REFERENCES Users(UserId),
|
|
108
|
+
Status NVARCHAR(20) NOT NULL DEFAULT 'PENDING'
|
|
109
|
+
CHECK (Status IN ('PENDING', 'PAID', 'CANCELED')),
|
|
110
|
+
Total DECIMAL(10,2) NOT NULL CHECK (Total > 0),
|
|
111
|
+
CreatedAt DATETIME2 NOT NULL DEFAULT GETDATE()
|
|
112
|
+
);
|
|
113
|
+
CREATE INDEX IX_Orders_UserId ON Orders (UserId);
|
|
114
|
+
CREATE INDEX IX_Orders_CreatedAt ON Orders (CreatedAt);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### JSON Data
|
|
118
|
+
|
|
119
|
+
```sql
|
|
120
|
+
CREATE TABLE Profiles (
|
|
121
|
+
UserId INT PRIMARY KEY REFERENCES Users(UserId),
|
|
122
|
+
Attrs NVARCHAR(MAX) NOT NULL DEFAULT '{}',
|
|
123
|
+
CONSTRAINT CK_Profiles_Attrs CHECK (ISJSON(Attrs) = 1)
|
|
124
|
+
);
|
|
125
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules
|
|
3
|
+
npm-debug.log
|
|
4
|
+
pnpm-debug.log
|
|
5
|
+
yarn-debug.log
|
|
6
|
+
yarn-error.log
|
|
7
|
+
|
|
8
|
+
# Build output
|
|
9
|
+
dist
|
|
10
|
+
build
|
|
11
|
+
.cache
|
|
12
|
+
|
|
13
|
+
# Environment files
|
|
14
|
+
.env
|
|
15
|
+
.env.local
|
|
16
|
+
.env.development.local
|
|
17
|
+
.env.test.local
|
|
18
|
+
.env.production.local
|
|
19
|
+
|
|
20
|
+
# Testing
|
|
21
|
+
coverage
|
|
22
|
+
.nyc_output
|
|
23
|
+
|
|
24
|
+
# Database
|
|
25
|
+
*.db
|
|
26
|
+
*.db-journal
|
|
27
|
+
postgres-data
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.vscode
|
|
31
|
+
.idea
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
*~
|
|
35
|
+
|
|
36
|
+
# OS
|
|
37
|
+
.DS_Store
|
|
38
|
+
Thumbs.db
|
|
39
|
+
|
|
40
|
+
# Temp
|
|
41
|
+
.temp
|
|
42
|
+
.tmp
|
|
43
|
+
|
|
44
|
+
# Git
|
|
45
|
+
.git
|
|
46
|
+
.gitignore
|
|
47
|
+
|
|
48
|
+
# Prisma
|
|
49
|
+
prisma/migrations
|
|
50
|
+
generated
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SQL Server Configuration
|
|
2
|
+
SA_PASSWORD=NestJS@Pass123
|
|
3
|
+
MSSQL_DATABASE=nestjs_api
|
|
4
|
+
MSSQL_HOST=localhost
|
|
5
|
+
MSSQL_PORT=1433
|
|
6
|
+
|
|
7
|
+
# Database URL (SQL Server)
|
|
8
|
+
DATABASE_URL="sqlserver://localhost:1433;database=nestjs_api;user=sa;password=NestJS@Pass123;trustServerCertificate=true"
|
|
9
|
+
|
|
10
|
+
# JWT Authentication
|
|
11
|
+
JWT_SECRET="huenei-secret-change-in-production-2026"
|
|
12
|
+
|
|
13
|
+
# Server
|
|
14
|
+
PORT=3000
|
|
15
|
+
|
|
16
|
+
# CORS
|
|
17
|
+
ALLOWED_ORIGINS="http://localhost:3000,http://localhost:3001"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SQL Server Test Configuration
|
|
2
|
+
SA_PASSWORD=NestJS@Pass123
|
|
3
|
+
MSSQL_DATABASE=nestjs_api_test
|
|
4
|
+
MSSQL_HOST=localhost
|
|
5
|
+
MSSQL_PORT=1433
|
|
6
|
+
|
|
7
|
+
# Database URL (SQL Server Test)
|
|
8
|
+
DATABASE_URL="sqlserver://localhost:1433;database=nestjs_api_test;user=sa;password=NestJS@Pass123;trustServerCertificate=true"
|
|
9
|
+
|
|
10
|
+
# JWT Authentication
|
|
11
|
+
JWT_SECRET="test-secret-key-for-testing-minimum-32-chars-required"
|
|
12
|
+
|
|
13
|
+
# Server
|
|
14
|
+
PORT=3001
|
|
15
|
+
|
|
16
|
+
# Environment
|
|
17
|
+
NODE_ENV=test
|