Releases: kimjbstar/prisma-class-generator
Release list
v0.7.0
Minor Changes
-
#108
5696c4cThanks @kimjbstar! - AddmakeDtoFiles, which generatesCreate<Model>andUpdate<Model>classes alongside each
model class. They're compositions rather than copies —CreateUser extends OmitType(User, [...] as const)andUpdateUser extends PartialType(CreateUser)— so a field's type, Swagger metadata and
validators stay declared in exactly one place, and NestJS's mapped types carry all three through.
Imported from@nestjs/swaggerwhenuseSwaggeris on,@nestjs/mapped-typesotherwise.A field leaves the
CreateDTO only when the schema itself says a client can't supply it: a
function-based@default(...)(autoincrement(),uuid(),now(),dbgenerated(...), …),
@updatedAt, or a relation field. Literal defaults like@default(0), relation foreign-key
scalars, and an@idwithout a default all stay — nothing is inferred from field names. Off by
default, so existing output is unchanged.
Patch Changes
- #106
5be2cb0Thanks @kimjbstar! - FixuseNonNullableAssertionsproducing TypeScript that doesn't compile. A field with a literal
@default(...)was emitted asviews!: number = 0, which is TS1263 — "Declarations with
initializers cannot also have definite assignment assertions". Any model with at least one
defaulted field made the whole generated file fail to build, anduseUndefinedDefaulthit the
same thing. The assertion is now omitted whenever the field has an initializer, which is what
definite assignment already means.
v0.6.6
Patch Changes
-
#104
3188d7aThanks @kimjbstar! - Cut what this package costs to install.@prisma/internalsmoves to devDependencies: the specs
still use itsgetDMMF, but it installs 28MB,prismaitself doesn't depend on it (so it never
dedupes with a project's existing install), and the generator only needed two things from it —
parseEnvValueandlogger.info— both now transcribed intoutil.tswith their behaviour and
output unchanged. Sourcemaps are also no longer published:filesships onlydist, so their
sources: ["../src/*.ts"]pointed at files that were never in the tarball.Runtime dependencies are now
@prisma/generator-helperandprettier. The published tarball is
29% smaller (130.8kB → 93.0kB unpacked), and@prisma/internals' 28MB is gone from every install.
package.jsonalso declares"type": "commonjs"explicitly so Node doesn't have to detect it.
v0.6.5
Patch Changes
- #102
92a7161Thanks @kimjbstar! - Drop thechange-caseruntime dependency. It was used for exactly one function (snakeCase, on
Prisma model/type names), and pulled in 16 packages transitively; its 5.x line is ESM-only, which
this CommonJS build can't consume on Node 18. That one function now lives inutil.tsas
toSnakeCase, transcribed from change-case@4 and verified against it over 150k property-generated
inputs — Prisma identifiers, messy ASCII and arbitrary unicode — with zero differences, so no
generated filename or import path changes. Runtime dependencies are down to three:
@prisma/generator-helper,@prisma/internalsandprettier.
v0.6.4
Patch Changes
- #100
1dd70f6Thanks @kimjbstar! - Adopt TypeScriptstrictmode across the generator's own source and specs. This is an internal
type-safety change with no difference in generated output (the golden fixture snapshots are
byte-identical), but it did tighten a few types that were previously lying about what they can
hold at runtime:getPrimitiveMapTypeFromDMMF()now declares theundefinedit already returned
for non-scalar fields,ImportComponent#getReplacePath()declares itsnull,prettierOptions
declares thenullprettier itself returns when a project has no config file, and
handleGenerateError()acceptsunknowninstead of assuming acatchblock always yields an
Error.
v0.6.3
Patch Changes
-
ee8e163Thanks @kimjbstar! - Removes every remaininganyinsrc/and turns@typescript-eslint/no-explicit-anyback
into a hard error (it was temporarily downgraded to a warning when ESLint first landed).DecoratorComponent#paramswas typedany[], treated as genuinely unshapeable. It isn't:
every value actually pushed through it acrossconvertor.tsis either a ready-to-interpolate
code fragment (string/number/boolean) or a plain options object rendered via
Object.entries(). Now typed as an exportedDecoratorParam = string | number | boolean | objectunion --objectrather thanRecord<string, unknown>on purpose, since the latter
demands an index signature that a concrete interface likeSwaggerDecoratorParamsdoesn't
(and shouldn't) declare.ImportComponent#add(item: any)-- its one real call site (FileComponent#registerImport)
always passes astring, matching the class's ownitems: string[]field. Typed as such.PrismaClassGeneratorConfigwasPartial<Record<PrismaClassGeneratorOptionsKeys, any>>.
Every option is a plainbooleanexceptclientImportPath(string | string[]) -- named
explicitly as an interface instead of one union covering all of them, so
config.dryRun/config.useGraphQL/etc. type as real booleans everywhere they're read,
no cast needed.
No behavior change --
npm run build/testoutput is identical; this is strictly narrowing
existinganyslots to the types the values already had at runtime.
v0.6.2
Patch Changes
-
ae4f87fThanks @kimjbstar! - No functional change -- dev-tooling only.- Removes
swagger-ui-expressandts-toolbeltfromdevDependencies: neither is imported
anywhere insrc/, andswagger-ui-expresswas pulling in a stale peer-dependency warning
on every install (unmet peer dependency "express"). - Adds a
test:coveragescript (jest --coverage) and scopescollectCoverageFromin
jest.config.jstosrc/**/*.ts(excluding specs,_gen, andbin.ts). CI now prints a
coverage summary to the job summary on the node-22 leg (once per run, not once per matrix
leg -- coverage doesn't vary by Node version).
- Removes
-
6f2100fThanks @kimjbstar! - Adds ESLint (flat config,typescript-eslint+eslint-config-prettierso it never fights
Prettier on style) and alintscript, wired into CI right aftertypecheck. Kept to
typescript-eslint'srecommendedrule set rather than a stricter/type-checked one --
tsconfig.jsonalready documentsstrict: falseas a deliberate, separately-scoped decision
(~60 pre-existing errors), and piling a stricter lint config on top of that today would just
be the same undertaking wearing a different hat.@typescript-eslint/no-explicit-anyis a
warning, not an error: this codebase'sDecoratorComponent/ImportComponentparams are
genuinely heterogeneous template-fill values (see CLAUDE.md's string-template-pipeline
description) -- forcing a type there wouldn't add real safety.Fixed everything the first
eslint srcrun actually flagged as an error (not a drive-by
sweep, just what the tool surfaced):- 3
letthat were never reassigned (prefer-const) - An unused
pascalCaseimport and an unusedoptionslocal - Two real
any-typed values found to always bestringin practice, now typed as such
(ImportComponent#add) - One real bug the loose typing was hiding:
GeneratorFormatNotValidError's constructor took
config: anybut calledsuper()with no arguments, so.messagewas always empty --
and the two real call sites (parseBoolean/parseNumberin util.ts) pass a formatted
string, not theDictionary<string>the class's own field type claimed. Now takes
message: stringand callssuper(message);handleGenerateErrorlogse.message
instead ofJSON.stringify(e.config), which used to just re-quote the same string.
eslint/typescript-eslint/@eslint/jsare pinned carefully for Node 18 (this repo's own
floor):eslint@^9.39.5(not the latest 10.x, which requires Node >=20.19) and
typescript-eslint@8.55.0exactly, no caret -- 8.56.0+ bumps a transitive
eslint-visitor-keysdependency to^5.0.0, which also requires Node >=20.19. Verified with
a cleanyarn install --frozen-lockfile+ typecheck/lint/build/test on real Node 18.20.8. - 3
v0.6.1
Patch Changes
-
#91
e8cfb37Thanks @kimjbstar! - Bump the runtimedependencies@prisma/generator-helperand@prisma/internalsfrom
6.19.3 to 7.9.1.devDependenciesprismaand@prisma/clientstay on 6.19.3 -- those two
specifically refuse to install on Node < 20.19 (their ownpreinstallscript hard-fails).The first attempt at this bump broke
yarn installon Node 18 in CI:@prisma/internals@7.9.1
pulls inchokidar@5.0.0transitively (via@prisma/config->c12), and chokidar 5 requires
Node >= 20.19. Traced it:c12only reaches for chokidar via a lazyawait import("chokidar")
inside its config-watch feature, which this generator's code (getDMMF/parseEnvValue/
loggeronly) never triggers -- so the actual chokidar module is never loaded at runtime here.
Added aresolutionsoverride pinningchokidarto^4.0.3(the same major that
prisma@6.19.3's ownc12dependency already resolves to, so it's a well-exercised version)
to sidestep the install-time engine check without touching any code path this package uses.
Verified with a cleanyarn install --frozen-lockfile+ fulltypecheck/build/testrun on
real Node 18.20.8 (via nvm, with engine-strict actually enforced -- not just locally-lenient
npm/yarn config).This also removes the local
FieldWithNativeTypetype augmentation in convertor.ts --
nativeTypeis now part of the officialDMMF.Fieldtype as of@prisma/generator-helper7.x,
so the workaround cast is redundant.Prisma 7 also dropped the
urlfield fromdatasourceblocks entirely (moved to
prisma.config.ts), which broke every test that builds a schema string and feeds it through
getDMMF(now on 7.9.1). Fixed by droppingurlfrom the inline schema templates in
convertor.spec.ts/file.component.spec.ts, and by stripping theurlline at read-time in
fixtures.spec.ts before parsing -- the checked-inprisma/*.prismafixture files themselves
keepurluntouched, sincenpm run generate:*still drives them through the pinned Prisma 6
CLI, which still expects it.Verified against real
prisma generateruns for all 6 fixture databases (unaffected -- they go
through the pinnedprismadevDependency, not the bumped runtime deps), and confirmed the
builtdist/index.js(compiled against 7.9.1 types) still works correctly when invoked by the
Prisma 6.19.3 CLI, proving the generator-helper JSON-RPC protocol is compatible across that
version gap. -
b1075f8Thanks @kimjbstar! - Bumpsts-nodeto its latest patch (10.9.2, no functional change -- devDependency only,
doesn't ship to consumers). Cherry-picked out of dependabot PR #90 (a grouped
dev-dependencies bump), which also tried to jumptypescript5.9.3 -> 7.0.2 and
@types/node18 -> 26 in the same PR and brokenpm teston every CI leg (ts-jest
doesn't expose TypeScript 7's restructured compiler API yet). Addedignorerules to
.github/dependabot.ymlfor major-version bumps on bothtypescript(until ts-jest
supports TS7) and@types/node(kept tracking this repo's ownengines.nodefloor of
18, not a hypothetical future Node major) so this doesn't recur. -
9752f41Thanks @kimjbstar! - Fixes three Windows-specific bugs found while adding awindows-latestleg to CI:getRelativeTSPath(used to build every relation/index-barrel import path) fed
path.relative()'s output straight into a generatedimport ... from '...'string.
On Windows,path.relative()returns\-separated paths, which produced an invalid
module specifier likeimport ... from '..\foo'. Now normalized to forward slashes
unconditionally (a POSIX import specifier is required regardless of host OS).- The
testnpm script used bash'sVAR=value commandsyntax
(NODE_OPTIONS=--experimental-vm-modules jest), which fails outright under Windows'
defaultcmd.exeshell. Switched tocross-env. - The
cleanscript usedrm -rf dist, also bash-only. Switched torimraf.
Both
cross-envandrimrafare pinned to majors that still support Node 18
(cross-env@^7.0.3,rimraf@^5.0.10) -- their latest majors require Node 20+, which would
have undone the Node 18 support this project maintains.
v0.6.0
Minor Changes
-
da90bb2Thanks @kimjbstar! - Pushes the already-supported class-validator/class-transformer integrations further, verified
against Prisma's own schema reference docs and (for the class-validator claim below) the
typestack/class-validatorsource itself:useValidation: postgresql/cockroachdb's@db.Inetnow generates@IsIP()(replacing the
generic@IsString()), and cockroachdb's@db.String(n)— its own name for what postgresql
calls@db.VarChar(n)— now generates@MaxLength(n)like the other length-constrained
string native types already did.useSerialization: a new/// @exposeper-field directive generates class-transformer's
@Expose(), mirroring the existing/// @exclude→@Exclude(), for projects that use
plainToInstance(cls, data, { excludeExtraneousValues: true })'s allow-list model instead of
@Exclude()'s deny-list one.
Deliberately not adding MySQL's
@db.UnsignedBigInt→@Min(0): it maps to Prisma's
BigIntscalar, and class-validator'sMin/Maxrequiretypeof value === 'number'— a JS
BigIntvalue'stypeofis always'bigint', so the decorator would reject every value,
including valid non-negative ones. Confirmed by readingMin.tsin class-validator's own
source, not guessed. -
3d3ca0aThanks @kimjbstar! -useSerializationnow generates class-transformer's@Type(() => X)on relation and
composite-type fields, independently ofuseValidation. Previously@Type()was only
generated as a side effect ofvalidateNestedRelations(which itself requires
useValidation) — so a project usinguseSerializationalone for
ClassSerializerInterceptor-based response serialization never got it, and a nested relation
in a response stayed a plain object instead of an instance of the related class, silently
skipping that class's own@Exclude()/@Expose()decorators.@Type()generation is now a single shared code path: it fires whenuseSerializationis on,
or whenuseValidation+validateNestedRelationsare both on, and doesn't duplicate the
decorator when more than one of those is true at once.
v0.5.2
Patch Changes
-
52bc1adThanks @kimjbstar! - Bumpprettierfrom 2.5.1 to 3.9.6 (and@types/prettierto match) and migrate the generator's
internal formatting calls to prettier 3's async-only API (resolveConfig/formatno longer have
.syncvariants). No change to generated output. Also runsjestwith
NODE_OPTIONS=--experimental-vm-modules— prettier 3's CJS entry point uses a dynamicimport()
internally, which Jest's default VM sandbox rejects without that flag. -
a3f573dThanks @kimjbstar! - Bump@prisma/generator-helper,@prisma/internals,@prisma/client, andprismafrom
5.5.2 to 6.19.3. Deliberately stopping at 6.x rather than 7.x (what dependabot's PR #81
proposed): Prisma 7 requires Node^20.19 || ^22.12 || >=24.0and drops Node 18 entirely,
while this project still supports and tests against Node 18. Prisma 6.19.3 still supports
Node>=18.18.Verified against real
prisma generateruns (postgresql and mongodb fixtures) on both
Node 18.20.8 and 22.23.1 — the generated output is unchanged.Also adds an explicit
DMMF.Documenttype annotation toPrismaConvertor#dmmf's
getter/setter — Prisma 6 restructured DMMF's types across an internal@prisma/dmmf
package boundary that TypeScript's declaration emit can no longer name portably without it
(TS2742), and enablesisolatedModulesin tsconfig.json to silence a ts-jest warning
(TS151002) about thenode16module kind introduced in the prior tsconfig modernization. -
f5d5a3bThanks @kimjbstar! - Modernize tsconfig.json ahead of TypeScript 6/7: replace the removedbaseUrl/
moduleResolution: "node"/suppressExcessPropertyErrors/suppressImplicitAnyIndexErrors/
downlevelIterationoptions withmodule/moduleResolution: "node16"(the two must now match)
and an explicitrootDir. Explicitly pinstrict: falsesince TypeScript 6+ defaults it to
trueand this codebase isn't strict-clean yet. No change to generated output.Note: actually bumping the
typescriptdependency to 7.x is still blocked — TypeScript 7 drops
the JS compiler API thatts-jest/ts-nodeneed, and neither has shipped compatibility yet
(see kulshekhar/ts-jest#5366).typescriptstays on the 5.x line for now.
v0.5.1
Patch Changes
-
76f5de6Thanks @kimjbstar! - Add property-based tests (fast-check) for default-value formatting and native-type validator
mapping — the two areas that have actually shipped bugs before. No behavior change to the
generator itself. -
f096801Thanks @kimjbstar! - Add atypecheckscript (tsc --noEmit) and run it as a fast-failing first step in CI,
before the full build/test cycle. No behavior change to the generator itself.