Registry / database / prismabox

prismabox

JSON →
library1.1.26jsnpmunverified

prismabox 1.1.26 is a Prisma generator that produces Typebox schemas from your Prisma schema, generating plain, relation, composite, and Prisma query input types (Where, OrderBy, Include, Select). It supports annotations for hiding fields/models, overriding types, and passing Typebox options. The generator does not support MongoDB composite types. Compared to alternatives like prisma-typebox or graphql-typebox, prismabox is focused solely on Typebox and offers a broad set of generated types for Prisma queries.

npm install prismabox
INSTALL
IMPORT
SIG · PRISMABOX
P
prismabox
databasejavascriptv1.1.26
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.

Type
import { Type } from '@sinclair/typebox'
const Type = require('@sinclair/typebox')
Typebox is ESM-only; CJS require will not work.
Post
import { Post } from './prismabox'
const Post = require('./prismabox')
Generated files are ESM by default; adjust output path as configured.
PostPlain
import { PostPlain } from './prismabox'
import { PostPlain } from 'prismabox'
Generated schemas are not exported from the npm package itself; they are generated into a local directory (default './prismabox').

Setup prismabox in a Prisma project, generate Typebox schemas, and validate data against a generated model schema.

// 1. Install prismabox as dev dependency // npm i -D prismabox // 2. Add generator to prisma/schema.prisma: // generator prismabox { // provider = "prismabox" // } // 3. Run prisma generate // npx prisma generate // 4. Import generated schemas import { Type } from '@sinclair/typebox'; import { Post } from './prismabox'; // Use schema for validation const valid = Type.Check(Post, { id: 1, title: 'Hello', createdAt: new Date().toISOString() }); console.log('Valid:', valid);
Debug
Known issues
gotchaMongoDB composite types are not supported; schemas for such models will be skipped or cause generation errors.
fix
Avoid using composite types in Prisma schema if using prismabox with MongoDB.
affects: <=1.1.26
gotchaGenerated schemas do not allow additional properties by default; set `additionalProperties = true` in generator config to change.
fix
Add `additionalProperties = true` to the prismabox generator block in schema.prisma.
affects: >=0.1.0
gotchaAnnotations must be on separate lines; multiple annotations on one line will be ignored.
fix
Place each annotation on its own line in the Prisma schema comment block.
affects: >=0.1.0
deprecatedAnnotation `@prismabox.hidden` is an alias for `@prismabox.hide`; prefer using `@prismabox.hide` for consistency.
fix
Use `@prismabox.hide` instead of `@prismabox.hidden`.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module './prismabox' or its corresponding type declarations.
Generated schemas output directory is not correctly referenced or missing after generation.
fix
Ensure `prisma generate` ran successfully and adjust import path to match the configured `output` directory (default './prismabox').
Error: Unknown generator 'prismabox'
prismabox package is not installed or not resolved by Prisma.
fix
Install prismabox as a dev dependency: `npm i -D prismabox` and verify it's listed in `package.json`.
TypeError: Type.Check is not a function
Incorrect usage of Typebox API; Type.Check is a static method on the Type object.
fix
Use `Type.Check(schema, data)` where `schema` is a Typebox schema like `Post`.
Expected 0-2 arguments, but got 3
Passing extra arguments to Typebox function call, e.g., adding options incorrectly.
fix
Use annotation `@prismabox.options` with valid JSON/JS syntax: `@prismabox.options{ min: 10, max: 20 }`.
Upgrade
Version history
1.1.26latest on npm
Audit
Dependencies
typeboxrequiredRuntime dependency for the generated Typebox schemas; the generated code imports and uses Typebox types.
prismaoptionalPeer dependency; prismabox is a Prisma generator and requires Prisma to be installed in the project.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
prismabox — npm install prismabox · libregistry