Skip to content

Commit e798397

Browse files
authored
chore: update to prisma 6.15 (#2228)
1 parent 94a6dc2 commit e798397

File tree

14 files changed

+131
-173
lines changed

14 files changed

+131
-173
lines changed

packages/plugins/openapi/src/rpc-generator.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
// Inspired by: https://github.com/omar-dulaimi/prisma-trpc-generator
22

33
import { PluginError, PluginOptions, analyzePolicies, requireOption, resolvePath } from '@zenstackhq/sdk';
4-
import { DataModel, Model, TypeDef, TypeDefField, TypeDefFieldType, isDataModel, isEnum, isTypeDef } from '@zenstackhq/sdk/ast';
4+
import {
5+
DataModel,
6+
Model,
7+
TypeDef,
8+
TypeDefField,
9+
TypeDefFieldType,
10+
isDataModel,
11+
isEnum,
12+
isTypeDef,
13+
} from '@zenstackhq/sdk/ast';
514
import {
615
AggregateOperationSupport,
716
addMissingInputObjectTypesForAggregate,
@@ -48,7 +57,7 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
4857
output = resolvePath(output, this.options);
4958

5059
// input types
51-
this.inputObjectTypes.push(...this.dmmf.schema.inputObjectTypes.prisma);
60+
this.inputObjectTypes.push(...(this.dmmf.schema.inputObjectTypes.prisma ?? []));
5261
this.outputObjectTypes.push(...this.dmmf.schema.outputObjectTypes.prisma);
5362

5463
// add input object types that are missing from Prisma dmmf
@@ -649,13 +658,13 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
649658
for (const _enum of [...(this.dmmf.schema.enumTypes.model ?? []), ...this.dmmf.schema.enumTypes.prisma]) {
650659
schemas[upperCaseFirst(_enum.name)] = this.generateEnumComponent(_enum);
651660
}
652-
661+
653662
// Also add enums from AST that might not be in DMMF (e.g., only used in TypeDefs)
654663
for (const enumDecl of this.model.declarations.filter(isEnum)) {
655664
if (!schemas[upperCaseFirst(enumDecl.name)]) {
656665
schemas[upperCaseFirst(enumDecl.name)] = {
657666
type: 'string',
658-
enum: enumDecl.fields.map(f => f.name)
667+
enum: enumDecl.fields.map((f) => f.name),
659668
};
660669
}
661670
}
@@ -765,12 +774,15 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
765774
return result;
766775
}
767776

768-
private generateField(def: { kind: DMMF.FieldKind; type: string; isList: boolean; isRequired: boolean; name?: string }, modelName?: string) {
777+
private generateField(
778+
def: { kind: DMMF.FieldKind; type: string; isList: boolean; isRequired: boolean; name?: string },
779+
modelName?: string
780+
) {
769781
// For Json fields, check if there's a corresponding TypeDef in the original model
770782
if (def.kind === 'scalar' && def.type === 'Json' && modelName && def.name) {
771-
const dataModel = this.model.declarations.find(d => isDataModel(d) && d.name === modelName) as DataModel;
783+
const dataModel = this.model.declarations.find((d) => isDataModel(d) && d.name === modelName) as DataModel;
772784
if (dataModel) {
773-
const field = dataModel.fields.find(f => f.name === def.name);
785+
const field = dataModel.fields.find((f) => f.name === def.name);
774786
if (field?.type.reference?.ref && isTypeDef(field.type.reference.ref)) {
775787
// This Json field references a TypeDef
776788
return this.wrapArray(
@@ -876,7 +888,7 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
876888
if (type.reference?.ref) {
877889
return this.ref(type.reference.ref.name, true);
878890
}
879-
891+
880892
// For scalar types, reuse the existing mapping logic
881893
// Note: Json type is handled as empty schema for consistency
882894
return match(type.type)
@@ -913,7 +925,7 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
913925
.with(P.union('JSON', 'Json'), () => {
914926
// For Json fields, check if there's a specific TypeDef reference
915927
// Otherwise, return empty schema for arbitrary JSON
916-
const isTypeDefType = this.model.declarations.some(d => isTypeDef(d) && d.name === type);
928+
const isTypeDefType = this.model.declarations.some((d) => isTypeDef(d) && d.name === type);
917929
return isTypeDefType ? this.ref(type, false) : {};
918930
})
919931
.otherwise((type) => this.ref(type.toString(), false));

packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"postinstall": "nuxt prepare"
1111
},
1212
"dependencies": {
13-
"@prisma/client": "6.14.x",
13+
"@prisma/client": "6.15.x",
1414
"@trpc/client": "^10.45.2",
1515
"@trpc/server": "^10.45.2",
1616
"nuxt": "^3.14.1592",
@@ -21,7 +21,7 @@
2121
},
2222
"devDependencies": {
2323
"esbuild": "^0.24.0",
24-
"prisma": "6.14.x",
24+
"prisma": "6.15.x",
2525
"typescript": "^5.6.2",
2626
"vue-tsc": "^2.1.10"
2727
}

packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"postinstall": "nuxt prepare"
1111
},
1212
"dependencies": {
13-
"@prisma/client": "6.14.x",
13+
"@prisma/client": "6.15.x",
1414
"@trpc/client": "^11.0.0-rc.563",
1515
"@trpc/server": "^11.0.0-rc.563",
1616
"nuxt": "^3.14.1592",
@@ -21,7 +21,7 @@
2121
},
2222
"devDependencies": {
2323
"esbuild": "^0.24.0",
24-
"prisma": "6.14.x",
24+
"prisma": "6.15.x",
2525
"typescript": "^5.6.2",
2626
"vue-tsc": "^2.1.10"
2727
}

packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"start": "next start"
1616
},
1717
"dependencies": {
18-
"@prisma/client": "6.14.x",
18+
"@prisma/client": "6.15.x",
1919
"@t3-oss/env-nextjs": "^0.10.1",
2020
"@tanstack/react-query": "^5.50.0",
2121
"@trpc/client": "^11.0.0-rc.446",
@@ -39,7 +39,7 @@
3939
"@typescript-eslint/parser": "^8.1.0",
4040
"eslint": "^8.57.0",
4141
"eslint-config-next": "^14.2.4",
42-
"prisma": "6.14.x",
42+
"prisma": "6.15.x",
4343
"typescript": "^5.5.3"
4444
},
4545
"ct3aMetadata": {

packages/runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"zod-validation-error": "catalog:"
114114
},
115115
"peerDependencies": {
116-
"@prisma/client": "5.0.0 - 6.14.x",
116+
"@prisma/client": "5.0.0 - 6.15.x",
117117
"zod": "catalog:"
118118
},
119119
"author": {

packages/schema/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@
116116
"zod-validation-error": "catalog:"
117117
},
118118
"peerDependencies": {
119-
"prisma": "5.0.0 - 6.14.x",
119+
"prisma": "5.0.0 - 6.15.x",
120120
"zod": "catalog:"
121121
},
122122
"devDependencies": {
123-
"@prisma/client": "6.14.x",
123+
"@prisma/client": "6.15.x",
124124
"@types/async-exit-hook": "^2.0.0",
125125
"@types/pluralize": "^0.0.29",
126126
"@types/semver": "^7.3.13",

packages/schema/src/plugins/enhancer/enhance/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ export type Enhanced<Client> =
479479
// they may be incorrectly represented as required, we need to fix that for input types
480480
// also, if a FK field is of such case, its corresponding relation field should be optional
481481
const createInputPattern = new RegExp(`^(.+?)(Unchecked)?Create.*Input$`);
482-
for (const inputType of dmmf.schema.inputObjectTypes.prisma) {
482+
for (const inputType of dmmf.schema.inputObjectTypes.prisma ?? []) {
483483
const match = inputType.name.match(createInputPattern);
484484
const modelName = this.resolveName(match?.[1]);
485485
if (modelName) {
@@ -570,8 +570,8 @@ export type Enhanced<Client> =
570570
const project = new Project();
571571

572572
// remove delegate_aux_* fields from the prismaNamespace.ts
573-
const internalFilename = `${prismaClientDir}/internal/prismaNamespace.ts`
574-
const internalFilenameFixed = `${prismaClientDir}/internal/prismaNamespace-fixed.ts`
573+
const internalFilename = `${prismaClientDir}/internal/prismaNamespace.ts`;
574+
const internalFilenameFixed = `${prismaClientDir}/internal/prismaNamespace-fixed.ts`;
575575
const internalSf = project.addSourceFileAtPath(internalFilename);
576576
const syntaxList = internalSf.getChildren()[0];
577577
if (!Node.isSyntaxList(syntaxList)) {

packages/schema/src/plugins/zod/generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class ZodSchemaGenerator {
8989
(o) => !excludeModels.find((e) => e === o.model)
9090
);
9191

92-
const inputObjectTypes = prismaClientDmmf.schema.inputObjectTypes.prisma.filter(
92+
const inputObjectTypes = (prismaClientDmmf.schema.inputObjectTypes.prisma ?? []).filter(
9393
(type) =>
9494
!excludeModels.some((e) => type.name.toLowerCase().startsWith(e.toLocaleLowerCase())) &&
9595
// exclude delegate aux related types

packages/sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"author": "",
1919
"license": "MIT",
2020
"dependencies": {
21-
"@prisma/generator-helper": "6.14.x",
22-
"@prisma/internals": "6.14.x",
21+
"@prisma/generator-helper": "6.15.x",
22+
"@prisma/internals": "6.15.x",
2323
"@zenstackhq/language": "workspace:*",
2424
"@zenstackhq/runtime": "workspace:*",
2525
"langium": "1.3.1",

0 commit comments

Comments
 (0)