New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prisma-class-dto-generator

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-class-dto-generator

Generate Prisma DTOs with seamless class-validator and class-transformer integration for TypeScript applications.

7.0.0
Source
npm
Version published
Weekly downloads
212
-35.17%
Maintainers
0
Weekly downloads
 
Created
Source

Prisma Class DTO Generator (v7.0.0+)

NPM Version GitHub Stars

⚡ Prisma DTO Generator – CLI & Programmatic Usage

❗🔴❗ Starting from version 7.0.0, prisma-class-dto-generator is no longer a Prisma generator but a standalone CLI tool and library that can be used independently. The package has been migrated to ESM (ECMAScript Modules) with NextNode to ensure compatibility with modern Node.js environments.

New: Prisma DTO Generator UI Constructor is an intuitive UI tool that helps generate DTO configurations for Prisma without manual edits. Define your settings visually, export a generator-config.json, and seamlessly integrate DTO generation into your workflow.

🔹 How It Works

You can use prisma-class-dto-generator in two ways:

  • CLI Mode – Run from the command line.
  • Programmatic Mode – Import and execute within your Node.js application.

🚀 CLI Usage

npx prisma-class-dto-generator --path=./prisma/schema.prisma --output=./dto_generated

or install globally:

npm install -g prisma-class-dto-generator
prismadtogen --path=./prisma/schema.prisma --output=./dto_generated

🎛 Available CLI Options

Usage: prismadtogen --path=[path_to_schema]

Options:
  --help, -h            Show this help message
  --version, -v         Show the installed version
  --path=[path]         Specify a Prisma schema file (default: ./prisma/schema.prisma)
  --output=[path]       Specify the output directory (default: ./dto_generated)

🎯 Why Use It?

Standalone & Flexible – Not tied to Prisma's generator system. ✅ ESM & NextNode Support – Fully compatible with modern Node.js environments. ✅ Error-Free DTO Generation – Automates repetitive DTO creation. ✅ Consistent & Maintainable – Ensures uniform DTO structures.

📦 Programmatic Usage

You can also use it inside a Node.js project:

import { generate } from "prisma-class-dto-generator";

await generate({
  cwd: process.cwd(),
  schemaPath: "./prisma/schema.prisma",
  output: "./dto_generated"
});

📌 Features

  • Automated DTO Generation – Creates input/output DTO classes for each Prisma model.
  • List DTOs – Supports pagination, filters, sorting, and flexible array elements.
  • Enum Handling – Generates enums from the Prisma schema.
  • Selective Generation – Fine-grained control over which models and fields to include.
  • Custom Decorators – Supports @filterable, @exclude input|output, @listable, and @orderable annotations.
  • File Type Support – Includes @IsFile and @IsFiles decorators for file uploads.
  • Lazy Imports for Deep Type Integration – Enables modular DTO architecture.
  • Class-Validator & OpenAPI Integration – Works seamlessly with class-validator, class-transformer, and routing-controllers-openapi.

🛠 Installation

npm install prisma-class-dto-generator

or

yarn add prisma-class-dto-generator

🔧 Configuration

The tool allows configuring DTO generation via a JSON file:

{
  "input": {
    "extendModels": {
      "Item": {
        "fields": [
          { "name": "title", "isRequired": false }
        ]
      }
    }
  }
}

📄 Example Prisma Schema Configuration

To integrate with Prisma, add a generator entry in schema.prisma:

generator class_validator {
  provider   = "node node_modules/prisma-class-dto-generator"
  output     = "../src/dto_sources"
  configPath = "./"
}

📌 Author

Developed by unbywyd.

Keywords

prisma

FAQs

Package last updated on 11 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts