Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prisma/generator-helper

Package Overview
Dependencies
Maintainers
4
Versions
8756
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/generator-helper

This package is intended for Prisma's internal use

  • 5.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

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 22 Aug 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc