prisma-class-dto-generator v7.0.1
Prisma Class DTO Generator (v7.0.0+)
ā” 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:
1. CLI Mode ā Run from the command line.
2. 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
, androuting-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 = "./"
}
š Links & Resources
- Website: Prisma DTO Generator
- GitHub Repository: unbywyd/prisma-class-dto-generator
- NPM Package: prisma-class-dto-generator
š Author
Developed by unbywyd.
5 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
4 months ago
4 months ago
4 months ago
6 months ago
4 months ago
5 months ago
6 months ago
3 months ago
3 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
11 months ago
1 year ago