create-huenei-template 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/templates.js +7 -0
- package/dist/templates/cursor/.cursor/agents/config-drift-analyzer.md +152 -0
- package/dist/templates/cursor/.cursor/commands/actualizar-reglas.md +580 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.dockerignore +14 -0
- package/dist/templates/frontend/react-ssr/.env.example +9 -0
- package/dist/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/dist/templates/frontend/react-ssr/Dockerfile +41 -0
- package/dist/templates/frontend/react-ssr/README.md +121 -0
- package/dist/templates/frontend/react-ssr/components.json +22 -0
- package/dist/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/dist/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/dist/templates/frontend/react-ssr/next.config.ts +7 -0
- package/dist/templates/frontend/react-ssr/package.json +86 -0
- package/dist/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/dist/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/dist/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/dist/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/dist/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/dist/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/dist/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/dist/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/dist/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/dist/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/dist/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/dist/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/dist/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/dist/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/dist/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/dist/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/dist/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/dist/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/dist/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/dist/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/dist/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/dist/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/dist/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/dist/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/dist/templates/frontend/react-ssr/vitest.config.ts +41 -0
- package/package.json +1 -1
- package/templates/cursor/.cursor/agents/config-drift-analyzer.md +152 -0
- package/templates/cursor/.cursor/commands/actualizar-reglas.md +580 -0
- package/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.dockerignore +14 -0
- package/templates/frontend/react-ssr/.env.example +9 -0
- package/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/templates/frontend/react-ssr/Dockerfile +41 -0
- package/templates/frontend/react-ssr/README.md +121 -0
- package/templates/frontend/react-ssr/components.json +22 -0
- package/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/templates/frontend/react-ssr/next.config.ts +7 -0
- package/templates/frontend/react-ssr/package.json +86 -0
- package/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/templates/frontend/react-ssr/vitest.config.ts +41 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# prisma validate
|
|
2
|
+
|
|
3
|
+
Validates your Prisma schema file.
|
|
4
|
+
|
|
5
|
+
## Command
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
prisma validate [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What It Does
|
|
12
|
+
|
|
13
|
+
- Parses the `schema.prisma` file
|
|
14
|
+
- Checks for syntax errors
|
|
15
|
+
- Validates model definitions, relations, and types
|
|
16
|
+
- Reports any errors or warnings without generating code
|
|
17
|
+
|
|
18
|
+
## Options
|
|
19
|
+
|
|
20
|
+
| Option | Description |
|
|
21
|
+
|--------|-------------|
|
|
22
|
+
| `--schema` | Path to schema file |
|
|
23
|
+
| `--config` | Custom path to your Prisma config file |
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
### Validate default schema
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
prisma validate
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Validate specific schema
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
prisma validate --schema=./custom/schema.prisma
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Use in CI
|
|
40
|
+
|
|
41
|
+
Run `validate` in your CI pipeline to catch schema errors early:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
- name: Validate Schema
|
|
45
|
+
run: npx prisma validate
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Common Errors
|
|
49
|
+
|
|
50
|
+
- Missing `@relation` fields
|
|
51
|
+
- Invalid types
|
|
52
|
+
- Duplicate model names
|
|
53
|
+
- Syntax errors (missing braces, etc.)
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prisma-client-api
|
|
3
|
+
description: Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: prisma
|
|
7
|
+
version: "7.0.0"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Prisma Client API Reference
|
|
11
|
+
|
|
12
|
+
Complete API reference for Prisma Client. This skill provides guidance on model queries, filtering, relations, and client methods for Prisma ORM 7.x.
|
|
13
|
+
|
|
14
|
+
## When to Apply
|
|
15
|
+
|
|
16
|
+
Reference this skill when:
|
|
17
|
+
- Writing database queries with Prisma Client
|
|
18
|
+
- Performing CRUD operations (create, read, update, delete)
|
|
19
|
+
- Filtering and sorting data
|
|
20
|
+
- Working with relations
|
|
21
|
+
- Using transactions
|
|
22
|
+
- Configuring client options
|
|
23
|
+
|
|
24
|
+
## Rule Categories by Priority
|
|
25
|
+
|
|
26
|
+
| Priority | Category | Impact | Prefix |
|
|
27
|
+
|----------|----------|--------|--------|
|
|
28
|
+
| 1 | Client Construction | HIGH | `constructor` |
|
|
29
|
+
| 2 | Model Queries | CRITICAL | `model-queries` |
|
|
30
|
+
| 3 | Query Shape | HIGH | `query-options` |
|
|
31
|
+
| 4 | Filtering | HIGH | `filters` |
|
|
32
|
+
| 5 | Relations | HIGH | `relations` |
|
|
33
|
+
| 6 | Transactions | CRITICAL | `transactions` |
|
|
34
|
+
| 7 | Raw SQL | CRITICAL | `raw-queries` |
|
|
35
|
+
| 8 | Client Methods | MEDIUM | `client-methods` |
|
|
36
|
+
|
|
37
|
+
## Quick Reference
|
|
38
|
+
|
|
39
|
+
- `constructor` - `PrismaClient` setup and adapter wiring
|
|
40
|
+
- `model-queries` - CRUD operations and bulk operations
|
|
41
|
+
- `query-options` - `select`, `include`, `omit`, sort, pagination
|
|
42
|
+
- `filters` - scalar and logical filter operators
|
|
43
|
+
- `relations` - relation reads and nested writes
|
|
44
|
+
- `transactions` - array and interactive transaction patterns
|
|
45
|
+
- `raw-queries` - `$queryRaw` and `$executeRaw` safety
|
|
46
|
+
- `client-methods` - lifecycle and extension methods
|
|
47
|
+
|
|
48
|
+
## Client Instantiation (v7)
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { PrismaClient } from '../generated/client'
|
|
52
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
53
|
+
|
|
54
|
+
const adapter = new PrismaPg({
|
|
55
|
+
connectionString: process.env.DATABASE_URL
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const prisma = new PrismaClient({ adapter })
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Model Query Methods
|
|
62
|
+
|
|
63
|
+
| Method | Description |
|
|
64
|
+
|--------|-------------|
|
|
65
|
+
| `findUnique()` | Find one record by unique field |
|
|
66
|
+
| `findUniqueOrThrow()` | Find one or throw error |
|
|
67
|
+
| `findFirst()` | Find first matching record |
|
|
68
|
+
| `findFirstOrThrow()` | Find first or throw error |
|
|
69
|
+
| `findMany()` | Find multiple records |
|
|
70
|
+
| `create()` | Create a new record |
|
|
71
|
+
| `createMany()` | Create multiple records |
|
|
72
|
+
| `createManyAndReturn()` | Create multiple and return them |
|
|
73
|
+
| `update()` | Update one record |
|
|
74
|
+
| `updateMany()` | Update multiple records |
|
|
75
|
+
| `updateManyAndReturn()` | Update multiple and return them |
|
|
76
|
+
| `upsert()` | Update or create record |
|
|
77
|
+
| `delete()` | Delete one record |
|
|
78
|
+
| `deleteMany()` | Delete multiple records |
|
|
79
|
+
| `count()` | Count matching records |
|
|
80
|
+
| `aggregate()` | Aggregate values (sum, avg, etc.) |
|
|
81
|
+
| `groupBy()` | Group and aggregate |
|
|
82
|
+
|
|
83
|
+
## Query Options
|
|
84
|
+
|
|
85
|
+
| Option | Description |
|
|
86
|
+
|--------|-------------|
|
|
87
|
+
| `where` | Filter conditions |
|
|
88
|
+
| `select` | Fields to include |
|
|
89
|
+
| `include` | Relations to load |
|
|
90
|
+
| `omit` | Fields to exclude |
|
|
91
|
+
| `orderBy` | Sort order |
|
|
92
|
+
| `take` | Limit results |
|
|
93
|
+
| `skip` | Skip results (pagination) |
|
|
94
|
+
| `cursor` | Cursor-based pagination |
|
|
95
|
+
| `distinct` | Unique values only |
|
|
96
|
+
|
|
97
|
+
## Client Methods
|
|
98
|
+
|
|
99
|
+
| Method | Description |
|
|
100
|
+
|--------|-------------|
|
|
101
|
+
| `$connect()` | Explicitly connect to database |
|
|
102
|
+
| `$disconnect()` | Disconnect from database |
|
|
103
|
+
| `$transaction()` | Execute transaction |
|
|
104
|
+
| `$queryRaw()` | Execute raw SQL query |
|
|
105
|
+
| `$executeRaw()` | Execute raw SQL command |
|
|
106
|
+
| `$on()` | Subscribe to events |
|
|
107
|
+
| `$extends()` | Add extensions |
|
|
108
|
+
|
|
109
|
+
## Quick Examples
|
|
110
|
+
|
|
111
|
+
### Find records
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// Find by unique field
|
|
115
|
+
const user = await prisma.user.findUnique({
|
|
116
|
+
where: { email: 'alice@prisma.io' }
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
// Find with filter
|
|
120
|
+
const users = await prisma.user.findMany({
|
|
121
|
+
where: { role: 'ADMIN' },
|
|
122
|
+
orderBy: { createdAt: 'desc' },
|
|
123
|
+
take: 10
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Create records
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const user = await prisma.user.create({
|
|
131
|
+
data: {
|
|
132
|
+
email: 'alice@prisma.io',
|
|
133
|
+
name: 'Alice',
|
|
134
|
+
posts: {
|
|
135
|
+
create: { title: 'Hello World' }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
include: { posts: true }
|
|
139
|
+
})
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Update records
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const user = await prisma.user.update({
|
|
146
|
+
where: { id: 1 },
|
|
147
|
+
data: { name: 'Alice Smith' }
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Delete records
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
await prisma.user.delete({
|
|
155
|
+
where: { id: 1 }
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Transactions
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const [user, post] = await prisma.$transaction([
|
|
163
|
+
prisma.user.create({ data: { email: 'alice@prisma.io' } }),
|
|
164
|
+
prisma.post.create({ data: { title: 'Hello', authorId: 1 } })
|
|
165
|
+
])
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Rule Files
|
|
169
|
+
|
|
170
|
+
Detailed API documentation:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
references/constructor.md - PrismaClient constructor options
|
|
174
|
+
references/model-queries.md - CRUD operations
|
|
175
|
+
references/query-options.md - select, include, omit, where, orderBy
|
|
176
|
+
references/filters.md - Filter conditions and operators
|
|
177
|
+
references/relations.md - Relation queries and nested operations
|
|
178
|
+
references/transactions.md - Transaction API
|
|
179
|
+
references/raw-queries.md - $queryRaw, $executeRaw
|
|
180
|
+
references/client-methods.md - $connect, $disconnect, $on, $extends
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Filter Operators
|
|
184
|
+
|
|
185
|
+
| Operator | Description |
|
|
186
|
+
|----------|-------------|
|
|
187
|
+
| `equals` | Exact match |
|
|
188
|
+
| `not` | Not equal |
|
|
189
|
+
| `in` | In array |
|
|
190
|
+
| `notIn` | Not in array |
|
|
191
|
+
| `lt`, `lte` | Less than |
|
|
192
|
+
| `gt`, `gte` | Greater than |
|
|
193
|
+
| `contains` | String contains |
|
|
194
|
+
| `startsWith` | String starts with |
|
|
195
|
+
| `endsWith` | String ends with |
|
|
196
|
+
| `mode` | Case sensitivity |
|
|
197
|
+
|
|
198
|
+
## Relation Filters
|
|
199
|
+
|
|
200
|
+
| Operator | Description |
|
|
201
|
+
|----------|-------------|
|
|
202
|
+
| `some` | At least one related record matches |
|
|
203
|
+
| `every` | All related records match |
|
|
204
|
+
| `none` | No related records match |
|
|
205
|
+
| `is` | Related record matches (1-to-1) |
|
|
206
|
+
| `isNot` | Related record doesn't match |
|
|
207
|
+
|
|
208
|
+
## Resources
|
|
209
|
+
|
|
210
|
+
- [Prisma Client API Reference](https://www.prisma.io/docs/orm/reference/prisma-client-reference)
|
|
211
|
+
- [CRUD Operations](https://www.prisma.io/docs/orm/prisma-client/queries/crud)
|
|
212
|
+
- [Filtering and Sorting](https://www.prisma.io/docs/orm/prisma-client/queries/filtering-and-sorting)
|
|
213
|
+
|
|
214
|
+
## How to Use
|
|
215
|
+
|
|
216
|
+
Pick the category from the table above, then open the matching reference file for implementation details and examples.
|
package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Client Methods
|
|
2
|
+
|
|
3
|
+
Prisma Client instance methods.
|
|
4
|
+
|
|
5
|
+
## $connect()
|
|
6
|
+
|
|
7
|
+
Explicitly connect to the database:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const prisma = new PrismaClient({ adapter })
|
|
11
|
+
|
|
12
|
+
// Explicit connection
|
|
13
|
+
await prisma.$connect()
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### When to use
|
|
17
|
+
|
|
18
|
+
Usually not needed - Prisma connects automatically on first query. Use for:
|
|
19
|
+
- Fail fast on startup
|
|
20
|
+
- Health checks
|
|
21
|
+
- Pre-warming connections
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
async function main() {
|
|
25
|
+
try {
|
|
26
|
+
await prisma.$connect()
|
|
27
|
+
console.log('Database connected')
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.error('Failed to connect:', e)
|
|
30
|
+
process.exit(1)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## $disconnect()
|
|
36
|
+
|
|
37
|
+
Close database connection:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
await prisma.$disconnect()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Graceful shutdown
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
process.on('beforeExit', async () => {
|
|
47
|
+
await prisma.$disconnect()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Or with SIGTERM
|
|
51
|
+
process.on('SIGTERM', async () => {
|
|
52
|
+
await prisma.$disconnect()
|
|
53
|
+
process.exit(0)
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### In tests
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
afterAll(async () => {
|
|
61
|
+
await prisma.$disconnect()
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## $on()
|
|
66
|
+
|
|
67
|
+
Subscribe to events:
|
|
68
|
+
|
|
69
|
+
### Query events
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const prisma = new PrismaClient({
|
|
73
|
+
adapter,
|
|
74
|
+
log: [{ level: 'query', emit: 'event' }]
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
prisma.$on('query', (e) => {
|
|
78
|
+
console.log('Query:', e.query)
|
|
79
|
+
console.log('Params:', e.params)
|
|
80
|
+
console.log('Duration:', e.duration, 'ms')
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Log events
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
const prisma = new PrismaClient({
|
|
88
|
+
adapter,
|
|
89
|
+
log: [
|
|
90
|
+
{ level: 'info', emit: 'event' },
|
|
91
|
+
{ level: 'warn', emit: 'event' },
|
|
92
|
+
{ level: 'error', emit: 'event' }
|
|
93
|
+
]
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
prisma.$on('info', (e) => console.log(e.message))
|
|
97
|
+
prisma.$on('warn', (e) => console.warn(e.message))
|
|
98
|
+
prisma.$on('error', (e) => console.error(e.message))
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## $extends()
|
|
102
|
+
|
|
103
|
+
Add extensions for custom behavior:
|
|
104
|
+
|
|
105
|
+
### Add custom methods
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const prisma = new PrismaClient({ adapter }).$extends({
|
|
109
|
+
client: {
|
|
110
|
+
$log: (message: string) => console.log(message)
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
prisma.$log('Hello!')
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Add model methods
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
const prisma = new PrismaClient({ adapter }).$extends({
|
|
121
|
+
model: {
|
|
122
|
+
user: {
|
|
123
|
+
async findByEmail(email: string) {
|
|
124
|
+
return prisma.user.findUnique({ where: { email } })
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
const user = await prisma.user.findByEmail('alice@prisma.io')
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Query extensions
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const prisma = new PrismaClient({ adapter }).$extends({
|
|
137
|
+
query: {
|
|
138
|
+
user: {
|
|
139
|
+
async findMany({ args, query }) {
|
|
140
|
+
// Add default filter
|
|
141
|
+
args.where = { ...args.where, deletedAt: null }
|
|
142
|
+
return query(args)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Result extensions
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const prisma = new PrismaClient({ adapter }).$extends({
|
|
153
|
+
result: {
|
|
154
|
+
user: {
|
|
155
|
+
fullName: {
|
|
156
|
+
needs: { firstName: true, lastName: true },
|
|
157
|
+
compute(user) {
|
|
158
|
+
return `${user.firstName} ${user.lastName}`
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
const user = await prisma.user.findFirst()
|
|
166
|
+
console.log(user.fullName) // Computed field
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Chain extensions
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const prisma = new PrismaClient({ adapter })
|
|
173
|
+
.$extends(loggingExtension)
|
|
174
|
+
.$extends(softDeleteExtension)
|
|
175
|
+
.$extends(computedFieldsExtension)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## $transaction()
|
|
179
|
+
|
|
180
|
+
See `transactions.md` for details.
|
|
181
|
+
|
|
182
|
+
## $queryRaw() / $executeRaw()
|
|
183
|
+
|
|
184
|
+
See `raw-queries.md` for details.
|
|
185
|
+
|
|
186
|
+
## Type utilities
|
|
187
|
+
|
|
188
|
+
### Prisma namespace
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { Prisma } from '../generated/client'
|
|
192
|
+
|
|
193
|
+
// Input types
|
|
194
|
+
type UserCreateInput = Prisma.UserCreateInput
|
|
195
|
+
type UserWhereInput = Prisma.UserWhereInput
|
|
196
|
+
|
|
197
|
+
// Output types
|
|
198
|
+
type User = Prisma.UserGetPayload<{}>
|
|
199
|
+
type UserWithPosts = Prisma.UserGetPayload<{
|
|
200
|
+
include: { posts: true }
|
|
201
|
+
}>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Prisma.validator
|
|
205
|
+
|
|
206
|
+
Type-safe query fragments:
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
import { Prisma } from '../generated/client'
|
|
210
|
+
|
|
211
|
+
const userSelect = Prisma.validator<Prisma.UserSelect>()({
|
|
212
|
+
id: true,
|
|
213
|
+
email: true,
|
|
214
|
+
name: true
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
const user = await prisma.user.findUnique({
|
|
218
|
+
where: { id: 1 },
|
|
219
|
+
select: userSelect
|
|
220
|
+
})
|
|
221
|
+
```
|
package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# PrismaClient Constructor
|
|
2
|
+
|
|
3
|
+
Configure Prisma Client when instantiating.
|
|
4
|
+
|
|
5
|
+
## Basic Instantiation (v7)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { PrismaClient } from '../generated/client'
|
|
9
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
10
|
+
|
|
11
|
+
const adapter = new PrismaPg({
|
|
12
|
+
connectionString: process.env.DATABASE_URL
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const prisma = new PrismaClient({ adapter })
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Constructor Options
|
|
19
|
+
|
|
20
|
+
### adapter (Required in v7)
|
|
21
|
+
|
|
22
|
+
Driver adapter instance:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
26
|
+
|
|
27
|
+
const adapter = new PrismaPg({
|
|
28
|
+
connectionString: process.env.DATABASE_URL
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const prisma = new PrismaClient({ adapter })
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### accelerateUrl (For Accelerate users)
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { withAccelerate } from '@prisma/extension-accelerate'
|
|
38
|
+
|
|
39
|
+
const prisma = new PrismaClient({
|
|
40
|
+
accelerateUrl: process.env.DATABASE_URL, // prisma:// URL
|
|
41
|
+
}).$extends(withAccelerate())
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### log
|
|
45
|
+
|
|
46
|
+
Configure logging:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const prisma = new PrismaClient({
|
|
50
|
+
adapter,
|
|
51
|
+
log: ['query', 'info', 'warn', 'error'],
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Log levels
|
|
56
|
+
|
|
57
|
+
| Level | Description |
|
|
58
|
+
|-------|-------------|
|
|
59
|
+
| `query` | All SQL queries |
|
|
60
|
+
| `info` | Informational messages |
|
|
61
|
+
| `warn` | Warnings |
|
|
62
|
+
| `error` | Errors |
|
|
63
|
+
|
|
64
|
+
#### Log to events
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const prisma = new PrismaClient({
|
|
68
|
+
adapter,
|
|
69
|
+
log: [
|
|
70
|
+
{ level: 'query', emit: 'event' },
|
|
71
|
+
{ level: 'error', emit: 'stdout' },
|
|
72
|
+
],
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
prisma.$on('query', (e) => {
|
|
76
|
+
console.log('Query:', e.query)
|
|
77
|
+
console.log('Duration:', e.duration, 'ms')
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### errorFormat
|
|
82
|
+
|
|
83
|
+
Control error formatting:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const prisma = new PrismaClient({
|
|
87
|
+
adapter,
|
|
88
|
+
errorFormat: 'pretty', // 'pretty' | 'colorless' | 'minimal'
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### transactionOptions
|
|
93
|
+
|
|
94
|
+
Default transaction settings:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const prisma = new PrismaClient({
|
|
98
|
+
adapter,
|
|
99
|
+
transactionOptions: {
|
|
100
|
+
maxWait: 5000, // Max wait to acquire transaction (ms)
|
|
101
|
+
timeout: 10000, // Max transaction duration (ms)
|
|
102
|
+
isolationLevel: 'Serializable',
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Singleton Pattern
|
|
108
|
+
|
|
109
|
+
Prevent multiple client instances in development:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
// lib/prisma.ts
|
|
113
|
+
import { PrismaClient } from '../generated/client'
|
|
114
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
115
|
+
|
|
116
|
+
const globalForPrisma = globalThis as unknown as {
|
|
117
|
+
prisma: PrismaClient | undefined
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function createPrismaClient() {
|
|
121
|
+
const adapter = new PrismaPg({
|
|
122
|
+
connectionString: process.env.DATABASE_URL!
|
|
123
|
+
})
|
|
124
|
+
return new PrismaClient({ adapter })
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const prisma = globalForPrisma.prisma ?? createPrismaClient()
|
|
128
|
+
|
|
129
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
130
|
+
globalForPrisma.prisma = prisma
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Next.js Pattern
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// lib/prisma.ts
|
|
138
|
+
import { PrismaClient } from '@/generated/client'
|
|
139
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
140
|
+
|
|
141
|
+
const createAdapter = () => new PrismaPg({
|
|
142
|
+
connectionString: process.env.DATABASE_URL!
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
const prismaClientSingleton = () => {
|
|
146
|
+
return new PrismaClient({ adapter: createAdapter() })
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare const globalThis: {
|
|
150
|
+
prismaGlobal: ReturnType<typeof prismaClientSingleton>
|
|
151
|
+
} & typeof global
|
|
152
|
+
|
|
153
|
+
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
|
|
154
|
+
|
|
155
|
+
export default prisma
|
|
156
|
+
|
|
157
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
158
|
+
globalThis.prismaGlobal = prisma
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Query Events
|
|
163
|
+
|
|
164
|
+
Listen to query events:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
const prisma = new PrismaClient({
|
|
168
|
+
adapter,
|
|
169
|
+
log: [{ level: 'query', emit: 'event' }],
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
prisma.$on('query', (e) => {
|
|
173
|
+
console.log('Query:', e.query)
|
|
174
|
+
console.log('Params:', e.params)
|
|
175
|
+
console.log('Duration:', e.duration)
|
|
176
|
+
})
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Log Events
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
prisma.$on('info', (e) => console.log(e.message))
|
|
183
|
+
prisma.$on('warn', (e) => console.warn(e.message))
|
|
184
|
+
prisma.$on('error', (e) => console.error(e.message))
|
|
185
|
+
```
|