From 4aa0a921a5df69d62e8d3e941e828b4933e7750a Mon Sep 17 00:00:00 2001 From: Lucian Buzzo Date: Tue, 9 Apr 2024 17:16:28 +0100 Subject: [PATCH] fix: update to prisma v5.11.0 --- package-lock.json | 37 +++-------- package.json | 94 +++++++++++++--------------- test/integration/abilities.spec.ts | 5 +- test/integration/expressions.spec.ts | 1 - test/integration/index.spec.ts | 12 ++-- test/integration/migrations.spec.ts | 4 +- test/integration/rbac.spec.ts | 8 ++- 7 files changed, 72 insertions(+), 89 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b6ea7b..05367d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@biomejs/biome": "1.5.3", - "@prisma/client": "^5.0.0", + "@prisma/client": "^5.11.0", "@types/cls-hooked": "^4.3.3", "@types/jest": "^29.2.6", "@types/lodash": "^4.14.191", @@ -31,8 +31,8 @@ "uuid": "^9.0.0" }, "peerDependencies": { - "@prisma/client": "^5.0.0", - "prisma": "^5.0.0" + "@prisma/client": "^5.11.0", + "prisma": "^5.11.0" } }, "node_modules/@ampproject/remapping": { @@ -1232,14 +1232,11 @@ } }, "node_modules/@prisma/client": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.1.0.tgz", - "integrity": "sha512-aIxuXlH3p3Vy91buodQhYgAD9m0yuxJzpXMhc1ejQ/WN3pNNWzBA0iDcBObLq8DMdszcXmoLAk3hiRq/ZwBsOw==", + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.11.0.tgz", + "integrity": "sha512-SWshvS5FDXvgJKM/a0y9nDC1rqd7KG0Q6ZVzd+U7ZXK5soe73DJxJJgbNBt2GNXOa+ysWB4suTpdK5zfFPhwiw==", "dev": true, "hasInstallScript": true, - "dependencies": { - "@prisma/engines-version": "5.1.0-28.a9b7003df90aa623086e4d6f4e43c72468e6339b" - }, "engines": { "node": ">=16.13" }, @@ -1259,12 +1256,6 @@ "dev": true, "hasInstallScript": true }, - "node_modules/@prisma/engines-version": { - "version": "5.1.0-28.a9b7003df90aa623086e4d6f4e43c72468e6339b", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.1.0-28.a9b7003df90aa623086e4d6f4e43c72468e6339b.tgz", - "integrity": "sha512-jTwE2oy1yjICmTfnCR0ASIpuMZXZ18sUzQXB7V0RMbrM9OlcmbUwXPuYhnxXuWN8XwRmujeIhsXs/Zeh+fjPOQ==", - "dev": true - }, "node_modules/@sinclair/typebox": { "version": "0.25.24", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz", @@ -5098,13 +5089,11 @@ "optional": true }, "@prisma/client": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.1.0.tgz", - "integrity": "sha512-aIxuXlH3p3Vy91buodQhYgAD9m0yuxJzpXMhc1ejQ/WN3pNNWzBA0iDcBObLq8DMdszcXmoLAk3hiRq/ZwBsOw==", + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.11.0.tgz", + "integrity": "sha512-SWshvS5FDXvgJKM/a0y9nDC1rqd7KG0Q6ZVzd+U7ZXK5soe73DJxJJgbNBt2GNXOa+ysWB4suTpdK5zfFPhwiw==", "dev": true, - "requires": { - "@prisma/engines-version": "5.1.0-28.a9b7003df90aa623086e4d6f4e43c72468e6339b" - } + "requires": {} }, "@prisma/engines": { "version": "5.1.0", @@ -5112,12 +5101,6 @@ "integrity": "sha512-HqaFsnPmZOdMWkPq6tT2eTVTQyaAXEDdKszcZ4yc7DGMBIYRP6j/zAJTtZUG9SsMV8FaucdL5vRyxY/p5Ni28g==", "dev": true }, - "@prisma/engines-version": { - "version": "5.1.0-28.a9b7003df90aa623086e4d6f4e43c72468e6339b", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.1.0-28.a9b7003df90aa623086e4d6f4e43c72468e6339b.tgz", - "integrity": "sha512-jTwE2oy1yjICmTfnCR0ASIpuMZXZ18sUzQXB7V0RMbrM9OlcmbUwXPuYhnxXuWN8XwRmujeIhsXs/Zeh+fjPOQ==", - "dev": true - }, "@sinclair/typebox": { "version": "0.25.24", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz", diff --git a/package.json b/package.json index 223711f..3f9207e 100644 --- a/package.json +++ b/package.json @@ -1,51 +1,47 @@ { - "name": "@cerebruminc/yates", - "version": "3.5.1", - "description": "Role based access control for Prisma Apps", - "main": "dist/index.js", - "files": [ - "CHANGELOG.md", - "dist", - "images" - ], - "scripts": { - "generate": "prisma generate", - "build": "rimraf dist && tsc -p tsconfig.build.json", - "test": "npm run lint", - "lint": "biome check .", - "lint:fix": "biome check . --apply", - "test:types": "tsc --noEmit", - "test:integration": "jest --runInBand test/integration", - "test:compose:integration": "docker compose -f docker-compose.yml --profile with-sut up db sut --exit-code-from sut", - "setup": "prisma generate && prisma migrate dev", - "prepublishOnly": "npm run build" - }, - "author": "Cerebrum (https://cerebrum.com)", - "license": "MIT", - "devDependencies": { - "@biomejs/biome": "1.5.3", - "@prisma/client": "^5.0.0", - "@types/cls-hooked": "^4.3.3", - "@types/jest": "^29.2.6", - "@types/lodash": "^4.14.191", - "@types/uuid": "^9.0.0", - "cls-hooked": "^4.2.2", - "jest": "^29.3.1", - "prisma": "^5.0.0", - "rimraf": "^5.0.5", - "ts-jest": "^29.0.5", - "typescript": "^5.3.3", - "uuid": "^9.0.0" - }, - "dependencies": { - "@types/debug": "^4.1.12", - "debug": "^4.3.4", - "lodash": "^4.17.21", - "node-sql-parser": "^4.12.0", - "type-fest": "^4.10.3" - }, - "peerDependencies": { - "@prisma/client": "^5.0.0", - "prisma": "^5.0.0" - } + "name": "@cerebruminc/yates", + "version": "3.5.1", + "description": "Role based access control for Prisma Apps", + "main": "dist/index.js", + "files": ["CHANGELOG.md", "dist", "images"], + "scripts": { + "generate": "prisma generate", + "build": "rimraf dist && tsc -p tsconfig.build.json", + "test": "npm run lint", + "lint": "biome check .", + "lint:fix": "biome check . --apply", + "test:types": "tsc --noEmit", + "test:integration": "jest --runInBand test/integration", + "test:compose:integration": "docker compose -f docker-compose.yml --profile with-sut up db sut --exit-code-from sut", + "setup": "prisma generate && prisma migrate dev", + "prepublishOnly": "npm run build" + }, + "author": "Cerebrum (https://cerebrum.com)", + "license": "MIT", + "devDependencies": { + "@biomejs/biome": "1.5.3", + "@prisma/client": "^5.11.0", + "@types/cls-hooked": "^4.3.3", + "@types/jest": "^29.2.6", + "@types/lodash": "^4.14.191", + "@types/uuid": "^9.0.0", + "cls-hooked": "^4.2.2", + "jest": "^29.3.1", + "prisma": "^5.0.0", + "rimraf": "^5.0.5", + "ts-jest": "^29.0.5", + "typescript": "^5.3.3", + "uuid": "^9.0.0" + }, + "dependencies": { + "@types/debug": "^4.1.12", + "debug": "^4.3.4", + "lodash": "^4.17.21", + "node-sql-parser": "^4.12.0", + "type-fest": "^4.10.3" + }, + "peerDependencies": { + "@prisma/client": "^5.11.0", + "prisma": "^5.11.0" + } } diff --git a/test/integration/abilities.spec.ts b/test/integration/abilities.spec.ts index 152c777..57b1284 100644 --- a/test/integration/abilities.spec.ts +++ b/test/integration/abilities.spec.ts @@ -39,7 +39,7 @@ describe("abilities", () => { operation: "SELECT", expression: (_client, _row, _context) => { return { - email: mail, + name: "John Doe", }; }, }, @@ -48,7 +48,7 @@ describe("abilities", () => { operation: "INSERT", expression: (_client, _row, _context) => { return { - email: mail, + name: "John Doe", }; }, }, @@ -75,6 +75,7 @@ describe("abilities", () => { const user = await client.user.create({ data: { + name: "John Doe", email: mail, }, }); diff --git a/test/integration/expressions.spec.ts b/test/integration/expressions.spec.ts index 1bb50ea..067bf3e 100644 --- a/test/integration/expressions.spec.ts +++ b/test/integration/expressions.spec.ts @@ -687,7 +687,6 @@ describe("expressions", () => { expression: (client: PrismaClient, row) => { return client.item.findFirst({ where: { - id: item.id, value: row("id"), }, }); diff --git a/test/integration/index.spec.ts b/test/integration/index.spec.ts index b486393..cf970de 100644 --- a/test/integration/index.spec.ts +++ b/test/integration/index.spec.ts @@ -341,11 +341,13 @@ describe("setup", () => { }, }); - await client.post.delete({ - where: { - id: postId2, - }, - }); + await expect( + client.post.delete({ + where: { + id: postId2, + }, + }), + ).rejects.toThrow("Record to delete does not exist"); const exists2 = await adminClient.post.findUnique({ where: { diff --git a/test/integration/migrations.spec.ts b/test/integration/migrations.spec.ts index 88750a8..c343d29 100644 --- a/test/integration/migrations.spec.ts +++ b/test/integration/migrations.spec.ts @@ -116,7 +116,7 @@ describe("migrations", () => { prisma: initial, customAbilities: { Post: { - readWithTitle: { + readWithTitle_fa0xC: { description: "Read posts with a special title", operation: "SELECT", expression: "title = 'Special title'", @@ -125,7 +125,7 @@ describe("migrations", () => { }, getRoles(abilities) { return { - [role]: [abilities.Post.readWithTitle], + [role]: [abilities.Post.readWithTitle_fa0xC], }; }, getContext: () => ({ diff --git a/test/integration/rbac.spec.ts b/test/integration/rbac.spec.ts index 83b0a60..ce10939 100644 --- a/test/integration/rbac.spec.ts +++ b/test/integration/rbac.spec.ts @@ -464,9 +464,11 @@ describe("rbac", () => { }, }); - await client.post.delete({ - where: { id: postId }, - }); + await expect( + client.post.delete({ + where: { id: postId }, + }), + ).rejects.toThrow(); const post = await adminClient.post.findUnique({ where: { id: postId },