Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump prisma dependency to 6.0.x #1896

Merged
merged 8 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,207 changes: 64 additions & 1,143 deletions packages/plugins/trpc/tests/projects/t3-trpc-v11/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"zod-validation-error": "^1.5.0"
},
"peerDependencies": {
"@prisma/client": "5.0.0 - 5.22.x"
"@prisma/client": "5.0.0 - 6.0.x"
},
"author": {
"name": "ZenStack Team"
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@
"zod-validation-error": "^1.5.0"
},
"peerDependencies": {
"prisma": "5.0.0 - 5.22.x"
"prisma": "5.0.0 - 6.0.x"
},
"devDependencies": {
"@prisma/client": "5.22.x",
"@prisma/client": "6.0.x",
"@types/async-exit-hook": "^2.0.0",
"@types/pluralize": "^0.0.29",
"@types/semver": "^7.3.13",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"author": "",
"license": "MIT",
"dependencies": {
"@prisma/generator-helper": "5.22.x",
"@prisma/internals": "5.22.x",
"@prisma/generator-helper": "6.0.x",
"@prisma/internals": "6.0.x",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/runtime": "workspace:*",
"langium": "1.3.1",
Expand Down
15 changes: 12 additions & 3 deletions packages/sdk/src/dmmf-helpers/include-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DMMF } from '../prisma';
import semver from 'semver';
import { getPrismaVersion, type DMMF } from '../prisma';
import { checkIsModelRelationField, checkModelHasManyModelRelation, checkModelHasModelRelation } from './model-helpers';

export function addMissingInputObjectTypesForInclude(
Expand All @@ -14,6 +15,7 @@ export function addMissingInputObjectTypesForInclude(
}
function generateModelIncludeInputObjectTypes(models: readonly DMMF.Model[]) {
const modelIncludeInputObjectTypes: DMMF.InputType[] = [];
const prismaVersion = getPrismaVersion();
for (const model of models) {
const { name: modelName, fields: modelFields } = model;
const fields: DMMF.SchemaArg[] = [];
Expand All @@ -32,7 +34,11 @@ function generateModelIncludeInputObjectTypes(models: readonly DMMF.Model[]) {
{ isList: false, type: 'Boolean', location: 'scalar' },
{
isList: false,
type: isList ? `${type}FindManyArgs` : `${type}Args`,
type: isList
? `${type}FindManyArgs`
: prismaVersion && semver.gte(prismaVersion, '6.0.0')
? `${type}DefaultArgs` // Prisma 6+ removed [Model]Args type
: `${type}Args`,
location: 'inputObjectTypes',
namespace: 'prisma',
},
Expand All @@ -58,7 +64,10 @@ function generateModelIncludeInputObjectTypes(models: readonly DMMF.Model[]) {
const inputTypes: DMMF.InputTypeRef[] = [{ isList: false, type: 'Boolean', location: 'scalar' }];
inputTypes.push({
isList: false,
type: `${modelName}CountOutputTypeArgs`,
type:
prismaVersion && semver.gte(prismaVersion, '6.0.0')
? `${modelName}CountOutputTypeDefaultArgs` // Prisma 6+ removed [Model]CountOutputTypeArgs type
: `${modelName}CountOutputTypeArgs`,
location: 'inputObjectTypes',
namespace: 'prisma',
});
Expand Down
9 changes: 7 additions & 2 deletions packages/sdk/src/dmmf-helpers/modelArgs-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DMMF } from '../prisma';
import semver from 'semver';
import { getPrismaVersion, type DMMF } from '../prisma';
import { checkModelHasModelRelation } from './model-helpers';

export function addMissingInputObjectTypesForModelArgs(
Expand All @@ -13,6 +14,7 @@ export function addMissingInputObjectTypesForModelArgs(
}
function generateModelArgsInputObjectTypes(models: readonly DMMF.Model[]) {
const modelArgsInputObjectTypes: DMMF.InputType[] = [];
const prismaVersion = getPrismaVersion();
for (const model of models) {
const { name: modelName } = model;
const fields: DMMF.SchemaArg[] = [];
Expand Down Expand Up @@ -52,7 +54,10 @@ function generateModelArgsInputObjectTypes(models: readonly DMMF.Model[]) {
}

const modelArgsInputObjectType: DMMF.InputType = {
name: `${modelName}Args`,
name:
prismaVersion && semver.gte(prismaVersion, '6.0.0')
? `${modelName}DefaultArgs` // Prisma 6+ removed [Model]Args type
: `${modelName}Args`,
constraints: {
maxNumFields: null,
minNumFields: null,
Expand Down
21 changes: 17 additions & 4 deletions packages/sdk/src/dmmf-helpers/select-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DMMF } from '../prisma';
import semver from 'semver';
import { getPrismaVersion, type DMMF } from '../prisma';
import { checkIsModelRelationField, checkModelHasManyModelRelation } from './model-helpers';

export function addMissingInputObjectTypesForSelect(
Expand Down Expand Up @@ -60,10 +61,14 @@ function generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputType

function generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes: DMMF.OutputType[]) {
const modelCountOutputTypeArgsInputObjectTypes: DMMF.InputType[] = [];
const prismaVersion = getPrismaVersion();
for (const modelCountOutputType of modelCountOutputTypes) {
const { name: modelCountOutputTypeName } = modelCountOutputType;
const modelCountOutputTypeArgsInputObjectType: DMMF.InputType = {
name: `${modelCountOutputTypeName}Args`,
name:
prismaVersion && semver.gte(prismaVersion, '6.0.0')
? `${modelCountOutputTypeName}DefaultArgs` // Prisma 6+ removed [Model]Args type
: `${modelCountOutputTypeName}Args`,
constraints: {
maxNumFields: null,
minNumFields: null,
Expand Down Expand Up @@ -91,6 +96,7 @@ function generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes:

function generateModelSelectInputObjectTypes(models: readonly DMMF.Model[]) {
const modelSelectInputObjectTypes: DMMF.InputType[] = [];
const prismaVersion = getPrismaVersion();
for (const model of models) {
const { name: modelName, fields: modelFields } = model;
const fields: DMMF.SchemaArg[] = [];
Expand All @@ -103,7 +109,11 @@ function generateModelSelectInputObjectTypes(models: readonly DMMF.Model[]) {
if (isRelationField) {
const schemaArgInputType: DMMF.InputTypeRef = {
isList: false,
type: isList ? `${type}FindManyArgs` : `${type}Args`,
type: isList
? `${type}FindManyArgs`
: prismaVersion && semver.gte(prismaVersion, '6.0.0')
? `${type}DefaultArgs` // Prisma 6+ removed [Model]Args type
: `${type}Args`,
location: 'inputObjectTypes',
namespace: 'prisma',
};
Expand Down Expand Up @@ -131,7 +141,10 @@ function generateModelSelectInputObjectTypes(models: readonly DMMF.Model[]) {
{ isList: false, type: 'Boolean', location: 'scalar' },
{
isList: false,
type: `${modelName}CountOutputTypeArgs`,
type:
prismaVersion && semver.gte(prismaVersion, '6.0.0')
? `${modelName}CountOutputTypeDefaultArgs` // Prisma 6+ removed [Model]CountOutputTypeArgs type
: `${modelName}CountOutputTypeArgs`,
location: 'inputObjectTypes',
namespace: 'prisma',
},
Expand Down
Loading
Loading