Skip to content

feat: support prisma-client generator provider#31

Merged
omar-dulaimi merged 2 commits into
masterfrom
feature/prisma-client-provider-support
Nov 7, 2025
Merged

feat: support prisma-client generator provider#31
omar-dulaimi merged 2 commits into
masterfrom
feature/prisma-client-provider-support

Conversation

@omar-dulaimi

@omar-dulaimi omar-dulaimi commented Nov 7, 2025

Copy link
Copy Markdown
Owner

Summary

  • allow the class-validator generator to work when Prisma users opt into the new prisma-client generator (while keeping prisma-client-js working) and document the requirement for a custom output path
  • cover both client providers with dedicated schemas + Vitest specs and refactor tests to reuse a shared build/generate helper
  • add a per-test environment reset via Vitest setup so each Prisma invocation gets a clean env, preventing cross-test leakage

Testing

  • npm test

Closes #30

Summary by CodeRabbit

  • New Features

    • Added support for multiple Prisma client provider options ("prisma-client" and "prisma-client-js") with configurable output paths for generated artifacts.
  • Tests

    • Introduced test helpers for streamlined test setup and execution.
    • Added comprehensive test coverage for both supported Prisma client providers.
  • Documentation

    • Updated README with clarification on Prisma generator configuration and supported provider options.

@coderabbitai

coderabbitai Bot commented Nov 7, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

Elementary, my dear developer. This PR expands support for Prisma Client generators to encompass both prisma-client and the legacy prisma-client-js providers. The generator validation logic now accommodates both variants, test infrastructure has been abstracted into reusable helpers, and corresponding test coverage has been established for each provider variant.

Changes

Cohort / File(s) Summary
Core Generator Logic
src/index.ts, src/prisma-generator.ts
Removed requiresGenerators from manifest. Introduced SUPPORTED_PRISMA_CLIENT_PROVIDERS constant supporting both prisma-client and prisma-client-js; adds validation guard for supported providers.
Schema Configuration
prisma/schema.prisma, tests/schemas/basic.prisma
Updated generator provider from prisma-client-js to prisma-client with new output path directives.
New Provider Test Schemas
tests/schemas/prisma-client-provider.prisma, tests/schemas/prisma-client-js-provider.prisma
Added dedicated Prisma schemas for validating each provider variant with corresponding generator and datasource configurations.
Existing Test Refactoring
tests/basic-generation.test.ts, tests/comprehensive-schema.test.ts, tests/relation-splitting.test.ts, tests/self-relation.test.ts, tests/swagger-generation.test.ts
Replaced direct shell execution with test helper abstractions (ensureGeneratorBuilt(), runPrismaGenerate()); removed direct exec and promisify dependencies.
New Provider-Specific Tests
tests/prisma-client-provider.test.ts, tests/prisma-client-js-provider.test.ts
Added test suites validating generator behavior with each provider; verify artifact generation in corresponding output directories.
Test Infrastructure
tests/utils/prisma-test-helpers.ts, tests/setup.ts, vitest.config.js
Introduced centralized test helpers (GenerateOptions interface, ensureGeneratorBuilt(), runPrismaGenerate() functions); added environment setup module with beforeEach/afterEach hooks; configured Vitest with setupFiles.
Documentation
README.md
Added clarification note distinguishing support for both provider variants with output path requirements.

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant Generator as Prisma Generator
    participant Validator as Provider Validator
    participant DMMF as DMMF Retrieval

    Test->>Generator: Initialize with schema
    Note over Generator: onManifest invoked
    Generator-->>Test: Manifest (requiresGenerators removed)
    
    Test->>Generator: Trigger generation
    Generator->>Validator: Check provider type
    
    alt Provider in SUPPORTED_PRISMA_CLIENT_PROVIDERS
        Validator-->>Generator: Valid ✓
        Generator->>DMMF: Retrieve DMMF
        DMMF-->>Generator: Schema metadata
        Generator-->>Test: Generated artifacts
    else Provider not supported
        Validator-->>Generator: Error thrown
        Generator-->>Test: Generation fails
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention Areas:
    • src/prisma-generator.ts: Verify the new provider validation logic correctly handles both prisma-client and prisma-client-js without regression
    • Test helper abstractions (tests/utils/prisma-test-helpers.ts): Confirm memoization strategy for ensureGeneratorBuilt() prevents redundant builds and that environment variable passing in runPrismaGenerate() doesn't introduce test pollution
    • Environment setup (tests/setup.ts): Validate that cloning process.env correctly resets state between tests and doesn't inadvertently suppress legitimate environment changes
    • New provider-specific test schemas: Ensure both prisma-client-provider.prisma and prisma-client-js-provider.prisma schemas are semantically equivalent for comparison purposes

Poem

🔍 The game is afoot! Two providers now align,
Where once was singularity, now duality's design.
From requiresGenerators chains, we break free,
Both client flavours dance—a deduction, you see.
The schema speaks truth; the tests validate all,
Elementary support, now answers the call. 🎩


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2459eb2 and fc84220.

📒 Files selected for processing (17)
  • README.md (2 hunks)
  • prisma/schema.prisma (1 hunks)
  • src/index.ts (0 hunks)
  • src/prisma-generator.ts (2 hunks)
  • tests/basic-generation.test.ts (1 hunks)
  • tests/comprehensive-schema.test.ts (1 hunks)
  • tests/prisma-client-js-provider.test.ts (1 hunks)
  • tests/prisma-client-provider.test.ts (1 hunks)
  • tests/relation-splitting.test.ts (1 hunks)
  • tests/schemas/basic.prisma (2 hunks)
  • tests/schemas/prisma-client-js-provider.prisma (1 hunks)
  • tests/schemas/prisma-client-provider.prisma (1 hunks)
  • tests/self-relation.test.ts (1 hunks)
  • tests/setup.ts (1 hunks)
  • tests/swagger-generation.test.ts (2 hunks)
  • tests/utils/prisma-test-helpers.ts (1 hunks)
  • vitest.config.js (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@omar-dulaimi
omar-dulaimi merged commit 11634c3 into master Nov 7, 2025
6 checks passed
@omar-dulaimi
omar-dulaimi deleted the feature/prisma-client-provider-support branch November 7, 2025 11:55
@coderabbitai coderabbitai Bot mentioned this pull request May 12, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support prisma-client (not just prisma-client-js)

1 participant