Skip to content

Commit

Permalink
Release 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Aug 8, 2024
1 parent a9e22d9 commit 3c7f3ac
Show file tree
Hide file tree
Showing 6 changed files with 462 additions and 51 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.1](https://github.com/dennemark/prisma-extension-casl/compare/0.5.0...0.5.1) (2024-08-08)


### Bug Fixes

* :bug: alternative way to alter abilities on prisma client ([a9e22d9](https://github.com/dennemark/prisma-extension-casl/commit/a9e22d91905d05de46809c7f2ecf67e6c54a1564))

## [0.5.0](https://github.com/dennemark/prisma-extension-casl/compare/0.4.3...0.5.0) (2024-08-08)


Expand Down
226 changes: 215 additions & 11 deletions dist/index.d.mts

Large diffs are not rendered by default.

226 changes: 215 additions & 11 deletions dist/index.d.ts

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,16 @@ function filterQueryResults(result, mask, abilities, model) {
// src/index.ts
function useCaslAbilities(getAbilityFactory) {
return import_client2.Prisma.defineExtension((client) => {
const caslExtension = (getAbility) => ({
let getAbilities = () => getAbilityFactory();
return client.$extends({
name: "prisma-extension-casl",
client: {
$casl(extendFactory) {
const ctx = import_client2.Prisma.getExtensionContext(this);
getAbilities = () => extendFactory(getAbilityFactory());
return ctx;
}
},
query: {
$allModels: {
async $allOperations({ args, query, model, operation, ...rest }) {
Expand All @@ -1204,7 +1213,8 @@ function useCaslAbilities(getAbilityFactory) {
return query(args);
}
perf?.mark("prisma-casl-extension-0");
const abilities = getAbility().build();
const abilities = getAbilities().build();
getAbilities = () => getAbilityFactory();
perf?.mark("prisma-casl-extension-1");
const caslQuery = applyCaslToQuery(operation, args, abilities, model);
perf?.mark("prisma-casl-extension-2");
Expand Down Expand Up @@ -1233,18 +1243,6 @@ function useCaslAbilities(getAbilityFactory) {
}
}
});
return client.$extends({
name: "prisma-extension-casl",
...caslExtension(getAbilityFactory),
client: {
$casl(extendFactory) {
return client.$extends({
name: "prisma-extension-casl-customized",
...caslExtension(() => extendFactory(getAbilityFactory()))
});
}
}
});
});
}
// Annotate the CommonJS export names for ESM import in node:
Expand Down
26 changes: 12 additions & 14 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,16 @@ function filterQueryResults(result, mask, abilities, model) {
// src/index.ts
function useCaslAbilities(getAbilityFactory) {
return Prisma2.defineExtension((client) => {
const caslExtension = (getAbility) => ({
let getAbilities = () => getAbilityFactory();
return client.$extends({
name: "prisma-extension-casl",
client: {
$casl(extendFactory) {
const ctx = Prisma2.getExtensionContext(this);
getAbilities = () => extendFactory(getAbilityFactory());
return ctx;
}
},
query: {
$allModels: {
async $allOperations({ args, query, model, operation, ...rest }) {
Expand All @@ -1179,7 +1188,8 @@ function useCaslAbilities(getAbilityFactory) {
return query(args);
}
perf?.mark("prisma-casl-extension-0");
const abilities = getAbility().build();
const abilities = getAbilities().build();
getAbilities = () => getAbilityFactory();
perf?.mark("prisma-casl-extension-1");
const caslQuery = applyCaslToQuery(operation, args, abilities, model);
perf?.mark("prisma-casl-extension-2");
Expand Down Expand Up @@ -1208,18 +1218,6 @@ function useCaslAbilities(getAbilityFactory) {
}
}
});
return client.$extends({
name: "prisma-extension-casl",
...caslExtension(getAbilityFactory),
client: {
$casl(extendFactory) {
return client.$extends({
name: "prisma-extension-casl-customized",
...caslExtension(() => extendFactory(getAbilityFactory()))
});
}
}
});
});
}
export {
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.0",
"version": "0.5.1",
"description": "Enforce casl abilities on prisma client ",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit 3c7f3ac

Please sign in to comment.