Registry / database / prisma-json-schema

prisma-json-schema

JSON →
library0.1.3jsnpmunverified

Provides a JSON schema for prisma.yml configuration files, enabling validation and IntelliSense in editors. Current stable version 0.1.3 is feature-complete but no longer actively developed; Prisma has been superseded by Prisma 2+. Differentiator: official Prisma schema definition to validate project config at authoring time. Released as part of the original Graphcool/Prisma ecosystem.

npm install prisma-json-schema
INSTALL
IMPORT
SIG · PRISMA-JSON-SCHEMA
P
prisma-json-schema
databasejavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrismaDefinition
import { PrismaDefinition } from 'prisma-json-schema'
const { PrismaDefinition } = require('prisma-json-schema')
TypeScript types are exported as named import; CJS require will not work because package does not expose CommonJS entry for types.
schema.json
import schema from 'prisma-json-schema/dist/schema.json'
import schema from 'prisma-json-schema'
The JSON file is not the package main entry; you must import the dist/schema.json path explicitly.
require('prisma-json-schema/dist/schema.json')
const schema = require('prisma-json-schema/dist/schema.json')
const schema = require('prisma-json-schema')
CJS users must require the full path to the JSON file under dist/.

Demonstrates importing both PrismaDefinition type and the JSON schema, then validating a prisma.yml configuration object.

import { PrismaDefinition } from 'prisma-json-schema' import schema from 'prisma-json-schema/dist/schema.json' assert { type: 'json' } const def: PrismaDefinition = { endpoint: process.env.PRISMA_ENDPOINT ?? 'http://localhost:4466', secret: process.env.PRISMA_SECRET ?? 'my-secret-123', datamodel: ['datamodel.prisma'], generate: [{ generator: 'javascript-client', output: './generated/prisma-client', }], } // Validate against schema (using another validator like ajv) import Ajv from 'ajv' const ajv = new Ajv() const validate = ajv.compile(schema) const valid = validate(def) if (!valid) { console.error(validate.errors) }
Debug
Known issues
deprecatedPackage is deprecated: Prisma 1 is replaced by Prisma 2+ and this package is no longer maintained.
fix
Migrate to Prisma 2+ and use @prisma/config or equivalent schema.
affects: all
gotchaThe schema.json file is in the dist/ directory, not at the package root. Importing from the package root returns the module index, not the JSON.
fix
Use import schema from 'prisma-json-schema/dist/schema.json'.
affects: >=0.1.0
gotchaTypeScript types are not exported via CommonJS require; only ESM named import works.
fix
Use import { PrismaDefinition } from 'prisma-json-schema' in an ESM context or use dynamic import.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'prisma-json-schema' or its corresponding type declarations.
Missing @types/prisma-json-schema or package not installed; also package does not ship TypeScript declarations directly.
fix
Install the package: npm install prisma-json-schema. If using TypeScript, ensure strict mode is not blocking because the package provides types.
Error [ERR_REQUIRE_ESM]: require() of ES Module .../prisma-json-schema/dist/schema.json not supported.
Trying to require() a JSON file in a CJS context without the proper extension or Node version.
fix
Use const schema = require('prisma-json-schema/dist/schema.json') (works in Node 12+). Or switch to ESM import.
TypeError: Cannot read properties of undefined (reading 'properties')
Using the package index export (which is undefined) instead of the schema.json file.
fix
Import from 'prisma-json-schema/dist/schema.json' instead of the package root.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
prisma-json-schema — npm install prisma-json-schema · libregistry