From 4b159dc74dffb5847528d6e4f40847edad1d1b63 Mon Sep 17 00:00:00 2001 From: dennemark Date: Mon, 23 Sep 2024 14:23:44 +0200 Subject: [PATCH] Release 0.5.20 --- CHANGELOG.md | 7 +++++++ dist/index.js | 18 ++++++++++-------- dist/index.mjs | 18 ++++++++++-------- package.json | 2 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 765fe2a..c3ce590 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ +## [0.5.20](https://github.com/dennemark/prisma-extension-casl/compare/0.5.19...0.5.20) (2024-09-23) + + +### Bug Fixes + +* :bug: disconnect equals true for one to one relationship ([43d884d](https://github.com/dennemark/prisma-extension-casl/commit/43d884d359f17aeb5c8d07a4e2245b443634a11f)) + ## [0.5.19](https://github.com/dennemark/prisma-extension-casl/compare/0.5.18...0.5.19) (2024-09-20) diff --git a/dist/index.js b/dist/index.js index a3ccb9f..d570833 100644 --- a/dist/index.js +++ b/dist/index.js @@ -972,14 +972,16 @@ function applyDataQuery(abilities, args, action, model, creationTree) { const mutationAction = caslNestedOperationDict[nestedAction]; const isConnection = nestedAction === "connect" || nestedAction === "disconnect"; tree.children[field] = { action: mutationAction, model: relationModel.type, children: {} }; - const dataQuery = applyDataQuery(abilities, nestedArgs, mutationAction, relationModel.type, tree.children[field]); - mutation[field][nestedAction] = dataQuery.args; - if (isConnection) { - const accessibleQuery2 = m5(abilities, mutationAction)[relationModel.type]; - if (Array.isArray(mutation[field][nestedAction])) { - mutation[field][nestedAction] = mutation[field][nestedAction].map((q4) => applyAccessibleQuery(q4, accessibleQuery2)); - } else { - mutation[field][nestedAction] = applyAccessibleQuery(mutation[field][nestedAction], accessibleQuery2); + if (nestedAction !== "disconnect" && nestedArgs !== true) { + const dataQuery = applyDataQuery(abilities, nestedArgs, mutationAction, relationModel.type, tree.children[field]); + mutation[field][nestedAction] = dataQuery.args; + if (isConnection) { + const accessibleQuery2 = m5(abilities, mutationAction)[relationModel.type]; + if (Array.isArray(mutation[field][nestedAction])) { + mutation[field][nestedAction] = mutation[field][nestedAction].map((q4) => applyAccessibleQuery(q4, accessibleQuery2)); + } else { + mutation[field][nestedAction] = applyAccessibleQuery(mutation[field][nestedAction], accessibleQuery2); + } } } } else { diff --git a/dist/index.mjs b/dist/index.mjs index 827fdcd..8e1d9a3 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -947,14 +947,16 @@ function applyDataQuery(abilities, args, action, model, creationTree) { const mutationAction = caslNestedOperationDict[nestedAction]; const isConnection = nestedAction === "connect" || nestedAction === "disconnect"; tree.children[field] = { action: mutationAction, model: relationModel.type, children: {} }; - const dataQuery = applyDataQuery(abilities, nestedArgs, mutationAction, relationModel.type, tree.children[field]); - mutation[field][nestedAction] = dataQuery.args; - if (isConnection) { - const accessibleQuery2 = m5(abilities, mutationAction)[relationModel.type]; - if (Array.isArray(mutation[field][nestedAction])) { - mutation[field][nestedAction] = mutation[field][nestedAction].map((q4) => applyAccessibleQuery(q4, accessibleQuery2)); - } else { - mutation[field][nestedAction] = applyAccessibleQuery(mutation[field][nestedAction], accessibleQuery2); + if (nestedAction !== "disconnect" && nestedArgs !== true) { + const dataQuery = applyDataQuery(abilities, nestedArgs, mutationAction, relationModel.type, tree.children[field]); + mutation[field][nestedAction] = dataQuery.args; + if (isConnection) { + const accessibleQuery2 = m5(abilities, mutationAction)[relationModel.type]; + if (Array.isArray(mutation[field][nestedAction])) { + mutation[field][nestedAction] = mutation[field][nestedAction].map((q4) => applyAccessibleQuery(q4, accessibleQuery2)); + } else { + mutation[field][nestedAction] = applyAccessibleQuery(mutation[field][nestedAction], accessibleQuery2); + } } } } else { diff --git a/package.json b/package.json index cbd9378..caf8e9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prisma-extension-casl", - "version": "0.5.19", + "version": "0.5.20", "description": "Enforce casl abilities on prisma client ", "main": "dist/index.js", "types": "dist/index.d.ts",