diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e3ac0..c676878 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ +## [0.5.6](https://github.com/dennemark/prisma-extension-casl/compare/0.5.5...0.5.6) (2024-08-14) + + +### Bug Fixes + +* :bug: only allow creation if object fits condition ([7a6bd77](https://github.com/dennemark/prisma-extension-casl/commit/7a6bd7747e053420045a99943972715bb5d11514)) + ## [0.5.5](https://github.com/dennemark/prisma-extension-casl/compare/0.5.4...0.5.5) (2024-08-09) diff --git a/dist/index.js b/dist/index.js index cc213aa..f580c80 100644 --- a/dist/index.js +++ b/dist/index.js @@ -917,7 +917,8 @@ function getFluentModel(startModel, data) { // src/applyDataQuery.ts function applyDataQuery(abilities, args, action, model) { - const permittedFields = getPermittedFields(abilities, action, model); + const obj = action === "update" ? void 0 : "data" in args ? args.data : "create" in args ? args.create : args; + const permittedFields = getPermittedFields(abilities, action, model, obj); const accessibleQuery = m5(abilities, action)[model]; const mutationArgs = []; (Array.isArray(args) ? args : [args]).map((argsEntry) => { diff --git a/dist/index.mjs b/dist/index.mjs index 3fadd0c..1db5938 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -892,7 +892,8 @@ function getFluentModel(startModel, data) { // src/applyDataQuery.ts function applyDataQuery(abilities, args, action, model) { - const permittedFields = getPermittedFields(abilities, action, model); + const obj = action === "update" ? void 0 : "data" in args ? args.data : "create" in args ? args.create : args; + const permittedFields = getPermittedFields(abilities, action, model, obj); const accessibleQuery = m5(abilities, action)[model]; const mutationArgs = []; (Array.isArray(args) ? args : [args]).map((argsEntry) => { diff --git a/package.json b/package.json index 9fe464a..b1e767e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prisma-extension-casl", - "version": "0.5.5", + "version": "0.5.6", "description": "Enforce casl abilities on prisma client ", "main": "dist/index.js", "types": "dist/index.d.ts",