
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
@prisma/generator-helper
Advanced tools
@prisma/generator-helper is a utility package designed to assist in the creation of custom generators for Prisma. It provides a set of tools and types to facilitate the development of generators that can extend or customize the behavior of Prisma's schema and client generation.
Generator Definition
This feature allows you to define a custom generator by specifying the manifest and generation logic. The `onManifest` function provides metadata about the generator, while the `onGenerate` function contains the logic to execute when the generator is run.
const { generatorHandler } = require('@prisma/generator-helper');
generatorHandler({
onManifest() {
return {
defaultOutput: 'default-output-path',
prettyName: 'My Custom Generator',
};
},
onGenerate(options) {
console.log('Generating with options:', options);
},
});
Helper Types
The package provides TypeScript types for Prisma's Data Model Meta Format (DMMF), which can be used to type-check and process the Prisma schema programmatically.
const { DMMF } = require('@prisma/generator-helper');
/**
* @param {DMMF.Document} dmmf
*/
function processDMMF(dmmf) {
console.log('Processing DMMF:', dmmf);
}
File Writing Utilities
This feature includes utilities for safely writing files, ensuring that directories are created as needed and that existing files are not overwritten unintentionally.
const { writeFileSafely } = require('@prisma/generator-helper');
const path = require('path');
const outputPath = path.join(__dirname, 'output.txt');
writeFileSafely(outputPath, 'Generated content').then(() => {
console.log('File written successfully');
});
Yeoman Generator is a robust scaffolding tool for building out new projects. It provides a higher-level abstraction for creating generators, including prompts, file system utilities, and more. Compared to @prisma/generator-helper, Yeoman is more general-purpose and not specifically tailored to Prisma.
Plop is a micro-generator framework that makes it easy to create code generators with a simple API. It focuses on simplicity and ease of use, making it a good alternative for smaller, less complex generator tasks. Unlike @prisma/generator-helper, Plop is not specifically designed for Prisma and lacks Prisma-specific utilities and types.
Hygen is a fast and lightweight code generator that uses plain text templates. It is designed for quick and easy setup and usage. While it is versatile and can be used for various generation tasks, it does not offer the Prisma-specific features and types provided by @prisma/generator-helper.
⚠️ Warning: This package is intended for Prisma's internal use. Its release cycle does not follow SemVer, which means we might release breaking changes (change APIs, remove functionality) without any prior warning.
If you are using this package, it would be helpful if you could help us gain an understanding where, how and why you are using it. Your feedback will be valuable to us to define a better API. Please share this information at https://github.com/prisma/prisma/discussions/13877 - Thanks!
FAQs
This package is intended for Prisma's internal use
The npm package @prisma/generator-helper receives a total of 697,038 weekly downloads. As such, @prisma/generator-helper popularity was classified as popular.
We found that @prisma/generator-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.