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

@prisma/generator-helper

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
p

@prisma/generator-helper

This package is intended for Prisma's internal use

6.3.0-integration-engines-6-3-0-18-integration-fix-aws-cli-version-18e9d973d7789a29d6b3c801dc30cb76c45ee0e0.1
Version published
Weekly downloads
829K
-15.82%
Maintainers
3
Weekly downloads
 
Created
Issues
2206

What is @prisma/generator-helper?

@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.

What are @prisma/generator-helper's main functionalities?

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');
});

Other packages similar to @prisma/generator-helper

FAQs

Package last updated on 28 Jan 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