npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@polyprism/ts-domain-class

v0.3.1

Published

Prisma 6 & 7 generator that emits opinionated TypeScript domain classes — private fields, getters/setters with active @coerce + @normalise, builder, from(), toJSON(). Pure ESM. Part of PolyPrism.

Readme

@polyprism/ts-domain-class

A Prisma 6 & 7 generator that emits opinionated TypeScript domain classes from your schema.prisma. Private fields, getters/setters with setter-driven data laundering, from() static factory, toJSON(), and a fluent builder. Part of PolyPrism.

const order = new Order({
  customerId: "cus_123",
  total: "10.99",         // stringified money from an HTTP API → coerced to Decimal
  placedAt: "2026-06-02", // ISO string → coerced to Date
});

await prisma.order.create({ data: order });  // pass directly — no destructure

Pure ESM, Prisma 7-native, one runtime dep (@polyprism/runtime). CI tests against both Prisma 6 and Prisma 7. The runtime dep is the price of admission for setter-driven data casting; the other PolyPrism patterns (ts-interface, ts-type, ts-class) stay zero-runtime-dep.

Install

pnpm add -D prisma @polyprism/ts-domain-class
pnpm add @polyprism/runtime

Note the split: the generator is a devDependency, the runtime is a real dependency.

Configure

generator polyprismCodegen {
  provider = "polyprism-ts-domain-class"
  output   = "../generated"
}

⚠️ The provider string is the bin name (no @scope/ prefix).

Run

pnpm prisma generate

What you get

  • Setter-driven type launderingInt / Float / Decimal / BigInt / DateTime fields coerce by default. Strings, booleans, enums, relations, and JSON columns stay strict.
  • @noCoerce to opt a default-coerce field out (e.g. an internal counter you want strictly typed).
  • @coerce(target) to opt a strict-by-default field in (e.g. String @coerce(int) for legacy stringified columns).
  • @normalise(trim, lowercase, uppercase, nullEmptyToNull) to pipe string-typed fields through ordered transforms on assignment.
  • Constructor: new User({ ... }) — object-arg with defaults applied for fields that have them.
  • Prisma-friendly: prisma.user.create({ data: userInstance }) works directly because the instance exposes enumerable accessors. No toData() plumbing.
  • JSON-safe: JSON.stringify(userInstance) produces wire-safe output natively. Models with BigInt columns also get a custom toJSON() so JSON.stringify doesn't throw on bigints.
  • User.from(plainObject) static factory — hydrate a class instance from an untrusted shape (HTTP body, Prisma row, queue message). Assigns via setters so @coerce / @normalise fire on the way in; unknown keys are silently dropped.
  • User.builder()...build() fluent builder with one chainable method per init-writable field.
  • Everything ts-class gives you (standalone enum files, three-axis naming, JSDoc preservation, @db.X precision metadata, etc.).

Sibling patterns

License

MIT © Travis Fitzgerald