Skip to content

Commit

Permalink
Release 0.5.20
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Sep 23, 2024
1 parent 43d884d commit 4b159dc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
18 changes: 10 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 10 additions & 8 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 4b159dc

Please sign in to comment.