UNPKG

prisma-zod-generator

Version:

Prisma 2+ generator to emit Zod schemas from your Prisma schema

218 lines (217 loc) 15.4 kB
{ "name": "prisma-zod-generator", "version": "2.1.2", "description": "Prisma 2+ generator to emit Zod schemas from your Prisma schema", "repository": "https://github.com/omar-dulaimi/prisma-zod-generator", "bin": { "prisma-zod-generator": "lib/generator.js", "pzg-pro": "lib/cli/pzg-pro.js" }, "scripts": { "prepare": "husky", "agent:info": "node scripts/agent-banner.js", "postinstall": "node scripts/postinstall.js", "setup": "git submodule update --init --recursive", "sync:pro": "git submodule update --remote src/pro", "build": "tsc", "build:release": "./package.sh", "obfuscate:pro": "node scripts/obfuscate-pro.js", "tree-shake:pro": "node scripts/tree-shake.js", "verify:build": "node scripts/verify-checksums.js", "typecheck": "tsc --noEmit", "exec": "pnpm run gen-example && pnpm run test:features:filtering -- -t \"should handle combinations of model, operation, and field filtering\"", "gen-example": "rm -rf src/dsrc && rm -rf src/schemas && tsc && DEBUG_PRISMA_ZOD=1 pnpm prisma generate && pnpm typecheck", "gen-example:debug": "tsc && DEBUG_PRISMA_ZOD=1 pnpm prisma generate", "check-uncommitted": "git diff-index --quiet HEAD --", "package:publish": "pnpm update && pnpm run check-uncommitted && ./package.sh && cd package && pnpm publish", "render:diagrams": "pnpm tsx scripts/render-mermaid.ts", "llms:gen": "node scripts/generate-llms-txt.mjs", "test": "pnpm test:features:parallel", "test:watch": "vitest --config vitest.config.mjs --watch", "test:basic": "vitest --config vitest.config.mjs run tests/generated-schema.test.ts --reporter=default", "test:coverage": "vitest --config vitest.config.mjs run --coverage", "test:coverage:fast": "vitest --config vitest.config.mjs run --coverage tests/generated-schema.test.ts --reporter=default", "test:coverage:comprehensive": "vitest --config vitest.config.mjs run --coverage tests/comprehensive-schema-coverage.test.ts --reporter=default", "test:coverage:mongodb": "vitest --config vitest.config.mjs run --coverage tests/mongodb-schema-coverage.test.ts --reporter=default", "test:coverage:all": "vitest --config vitest.config.mjs run --coverage tests/generated-schema.test.ts tests/mongodb-schema-coverage.test.ts --reporter=default", "test:ci": "vitest --config vitest.config.mjs run --coverage", "test:type-check": "tsc --noEmit", "test:multi": "VITEST_PARALLEL=true vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts --reporter=default", "test:multi:sequential": "VITEST_PARALLEL=false vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts", "test:multi:coverage": "VITEST_PARALLEL=true vitest --config vitest.config.mjs run --coverage tests/multi-provider/multi-provider.test.ts", "test:multi:comprehensive": "VITEST_PARALLEL=true vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'Comprehensive Integration Test'", "test:provider:postgresql": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'PostgreSQL Provider Tests'", "test:provider:mysql": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'MySQL Provider Tests'", "test:provider:mongodb": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'MongoDB Provider Tests'", "test:provider:sqlite": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'SQLite Provider Tests'", "test:provider:sqlserver": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'SQL Server Provider Tests'", "test:generation:postgresql": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'should generate schemas for postgresql'", "test:generation:mysql": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'should generate schemas for mysql'", "test:generation:mongodb": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'should generate schemas for mongodb'", "test:generation:sqlite": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'should generate schemas for sqlite'", "test:generation:sqlserver": "vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'should generate schemas for sqlserver'", "test:performance": "VITEST_PARALLEL=true vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'Performance Comparison'", "test:compatibility": "VITEST_PARALLEL=true vitest --config vitest.config.mjs run tests/multi-provider/multi-provider.test.ts -t 'Cross-Provider Compatibility'", "test:features:single-file-zod-versions": "vitest --config vitest.config.mjs run tests/single-file-zod-versions.test.ts --reporter=default", "test:features:pure-models-zod-v4-recursion": "vitest --config vitest.config.mjs run tests/pure-models-zod-v4-recursion.test.ts --reporter=default", "test:features:count-output-type-select-where": "vitest --config vitest.config.mjs run tests/count-output-type-select-where.test.ts --reporter=default", "test:features:parallel": "VITEST_MAX_WORKERS=6 vitest --config vitest.config.mjs run tests/config.test.ts tests/filtering.test.ts tests/minimal-mode.test.ts tests/field-exclusion.test.ts tests/zod-comments.test.ts tests/pure-models.test.ts tests/schema-variants.test.ts tests/result-schemas.test.ts tests/circular-dependency-exclusion.test.ts tests/issue-227-zod-annotations.test.ts tests/issue-227-single-file-imports.test.ts tests/issue-233-zod-v4-string-formats.test.ts tests/json-schema-compatibility.test.ts tests/prisma-client-options.test.ts tests/prisma-client-esm-config.test.ts tests/array-fields.test.ts tests/enum-array-zod-annotations.test.ts tests/naming-customization.test.ts tests/strict-mode.test.ts tests/pure-models-zod-v4-recursion.test.ts tests/single-file-zod-versions.test.ts tests/decimal-support.test.ts tests/decimal-input-schemas.test.ts tests/single-file-aggregator.test.ts tests/count-output-type-select-where.test.ts tests/operation-exclusion.test.ts tests/integration.test.ts --reporter=verbose", "test:features:decimal": "vitest --config vitest.config.mjs run tests/decimal-support.test.ts --reporter=default", "test:features:single-file-aggregator": "vitest --config vitest.config.mjs run tests/single-file-aggregator.test.ts --reporter=default", "test:features:decimal-inputs": "vitest --config vitest.config.mjs run tests/decimal-input-schemas.test.ts --reporter=default", "test:features:enum-array-zod-annotations": "vitest --config vitest.config.mjs run tests/enum-array-zod-annotations.test.ts --reporter=default", "test:features:json-schema": "vitest --config vitest.config.mjs run tests/json-schema-compatibility.test.ts --reporter=default", "test:features:coverage": "vitest --config vitest.config.mjs run --coverage tests/config.test.ts tests/filtering.test.ts tests/minimal-mode.test.ts tests/field-exclusion.test.ts tests/zod-comments.test.ts tests/pure-models.test.ts tests/schema-variants.test.ts tests/result-schemas.test.ts tests/circular-dependency-exclusion.test.ts tests/issue-227-zod-annotations.test.ts tests/issue-227-single-file-imports.test.ts", "test:features:array": "vitest --config vitest.config.mjs run tests/array-fields.test.ts --reporter=default", "test:features:naming-customization": "vitest --config vitest.config.mjs run tests/naming-customization.test.ts --reporter=default", "test:features:strict-mode": "vitest --config vitest.config.mjs run tests/strict-mode.test.ts --reporter=default", "test:features:config": "vitest --config vitest.config.mjs run tests/config.test.ts --reporter=default", "test:features:client": "vitest --config vitest.config.mjs run tests/prisma-client-esm-config.test.ts --reporter=default", "test:features:aggregate-groupby": "vitest --config vitest.config.mjs run tests/aggregate-groupby.test.ts --reporter=default", "test:features:snake-case-fix": "vitest --config vitest.config.mjs run tests/snake-case-aggregate-fix.test.ts --reporter=default", "test:features:filtering": "vitest --config vitest.config.mjs run tests/filtering.test.ts --reporter=default", "test:features:minimal": "vitest --config vitest.config.mjs run tests/minimal-mode.test.ts --reporter=default", "test:features:exclusion": "vitest --config vitest.config.mjs run tests/field-exclusion.test.ts --reporter=default", "test:features:zod": "vitest --config vitest.config.mjs run tests/zod-comments.test.ts --reporter=default", "test:features:zod-v4-string-formats": "vitest --config vitest.config.mjs run tests/issue-233-zod-v4-string-formats.test.ts --reporter=default", "test:features:pure": "vitest --config vitest.config.mjs run tests/pure-models.test.ts --reporter=default", "test:features:variants": "vitest --config vitest.config.mjs run tests/schema-variants.test.ts --reporter=default", "test:features:results": "vitest --config vitest.config.mjs run tests/result-schemas.test.ts --reporter=default", "test:features:zodImports": "vitest --config vitest.config.mjs run tests/zod-imports.test.ts --reporter=default", "test:features:circular-dependency-exclusion": "vitest --config vitest.config.mjs run tests/circular-dependency-exclusion.test.ts --reporter=default", "test:features:prisma-client": "vitest --config vitest.config.mjs run tests/prisma-client-options.test.ts --reporter=default", "test:features:prisma-client-matrix": "vitest --config vitest.config.mjs run tests/prisma-client-full-matrix.test.ts --reporter=default", "test:features:prisma-client-matrix:full": "FULL_PRISMA_CLIENT_MATRIX=1 vitest --config vitest.config.mjs run tests/prisma-client-full-matrix.test.ts --reporter=default", "test:integration": "vitest --config vitest.config.mjs run tests/integration.test.ts --reporter=default", "test:integration:coverage": "vitest --config vitest.config.mjs run --coverage tests/integration.test.ts --reporter=default", "validate:schemas:quick": "pnpm tsc --noEmit -p tsconfig.validate.json", "test:full": "pnpm run test:basic && pnpm run test:multi && pnpm run test:features", "test:full:coverage": "pnpm run test:coverage:fast && pnpm run test:multi:coverage && pnpm run test:features:coverage && pnpm run test:integration:coverage", "test:comprehensive": "VITEST_PARALLEL=true pnpm run test:full:coverage", "test:legacy:multi-provider": "tsx tests/multi-provider/run-all-tests.ts", "test:legacy:multi-provider:parallel": "tsx tests/multi-provider/run-all-tests.ts --parallel", "test:legacy:multi-provider:generate": "tsx tests/multi-provider/run-all-tests.ts --generate-only", "docker:up": "docker compose up -d", "docker:down": "docker compose down", "docker:logs": "docker compose logs -f", "docker:ps": "docker compose ps", "docker:reset": "docker compose down -v && docker compose up -d", "test:docker": "pnpm docker:up && sleep 10 && pnpm test:multi", "test:docker:full": "pnpm docker:up && sleep 10 && pnpm test:full", "test:docker:postgresql": "docker compose up -d postgresql && sleep 5 && pnpm test:provider:postgresql", "test:docker:mysql": "docker compose up -d mysql && sleep 5 && pnpm test:provider:mysql", "test:docker:mongodb": "docker compose up -d mongodb && sleep 5 && pnpm test:provider:mongodb", "test:docker:sqlserver": "docker compose up -d sqlserver && sleep 10 && pnpm test:provider:sqlserver", "lint": "eslint src/ tests/ --ignore-pattern 'tests/multi-provider/schemas/*/generated/**/*' --ignore-pattern 'src/pro/**' --fix", "format": "prettier --write .", "format:check": "prettier --check .", "prerelease": "pnpm run gen-example && pnpm run test:type-check && pnpm run lint", "release": "semantic-release --otp=693145", "release:dry": "semantic-release --dry-run", "release:predict": "git fetch --tags --quiet && semantic-release --dry-run --no-ci --plugins @semantic-release/commit-analyzer", "release:predict:notes": "git fetch --tags --quiet && semantic-release --dry-run --no-ci --plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator", "ci:test": "pnpm run test:comprehensive", "ci:build": "pnpm run gen-example", "docs:dev": "cd website && pnpm run dev", "docs:build": "cd website && pnpm run build", "docs:serve": "cd website && pnpm run serve", "postrelease": "echo 'Changelog is maintained on GitHub; no docs sync needed.'" }, "author": { "name": "Omar Dulaimi", "url": "https://github.com/omar-dulaimi" }, "keywords": [ "prisma", "prisma-client", "prisma-schema", "zod", "prisma-generator", "prisma-zod-generator" ], "license": "MIT", "dependencies": { "@prisma/client": "^7.0.0", "@prisma/generator-helper": "^7.0.0", "@prisma/internals": "^7.0.0", "@types/cors": "^2.8.19", "@types/express": "^5.0.5", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "cors": "^2.8.5", "dotenv": "^17.2.3", "express": "^5.1.0", "js-yaml": "^4.1.1", "node-fetch": "^3.3.2", "prettier": "^3.6.2", "tslib": "^2.8.1" }, "peerDependencies": { "zod": ">=3.25.0 <5" }, "devDependencies": { "@mermaid-js/mermaid-cli": "^11.12.0", "@rollup/plugin-terser": "^0.4.4", "@semantic-release/changelog": "^6.0.3", "@semantic-release/commit-analyzer": "^13.0.1", "@semantic-release/exec": "^7.1.0", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^12.0.2", "@semantic-release/npm": "^13.1.2", "@semantic-release/release-notes-generator": "^14.1.0", "@types/jest": "^30.0.0", "@types/js-yaml": "^4.0.9", "@types/json-schema": "^7.0.15", "@types/node": "^24.10.1", "@types/validator": "^13.15.10", "@typescript-eslint/eslint-plugin": "^8.47.0", "@typescript-eslint/parser": "^8.47.0", "@vitest/coverage-v8": "^4.0.12", "conventional-changelog-conventionalcommits": "^9.1.0", "eslint": "^9.39.1", "eslint-config-prettier": "^10.1.8", "expect-type": "^1.2.2", "fast-glob": "^3.3.3", "glob": "^13.0.0", "gray-matter": "^4.0.3", "husky": "^9.1.7", "javascript-obfuscator": "^4.1.1", "@prisma/adapter-pg": "^7.0.0", "pg": "^8.16.3", "prisma": "^7.0.0", "remark": "^15.0.1", "remark-gfm": "^4.0.1", "remark-mdx": "^3.1.1", "remark-stringify": "^11.0.0", "rollup": "^4.53.3", "semantic-release": "^25.0.2", "ts-node": "^10.9.2", "tsx": "^4.20.6", "typescript": "^5.9.3", "validator": "^13.15.23", "vitest": "^4.0.12", "zod": "^4.1.12" }, "pnpm": { "overrides": { "postcss": "^8.5.6" }, "ignoredBuiltDependencies": [ "@prisma/client", "@prisma/engines", "prisma" ] }, "bugs": { "url": "https://github.com/omar-dulaimi/prisma-zod-generator/issues" }, "funding": { "type": "github", "url": "https://github.com/sponsors/omar-dulaimi" }, "homepage": "https://omar-dulaimi.github.io/prisma-zod-generator", "private": false, "engines": { "node": ">=20.19.0" } }