Skip to content

Commit

Permalink
Release 1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Dec 5, 2024
1 parent 5bd5dc7 commit 28a1d44
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@


## [1.1.5](https://github.com/dennemark/prisma-extension-casl/compare/1.1.4...1.1.5) (2024-12-05)

### Bug Fixes

* :bug: use different method to check if transactionId should be used for batch ([5bd5dc7](https://github.com/dennemark/prisma-extension-casl/commit/5bd5dc7d92acf59e07a0a5a2acec1238c37c9935))

## [1.1.4](https://github.com/dennemark/prisma-extension-casl/compare/1.1.3...1.1.4) (2024-12-04)

### Bug Fixes
Expand Down
13 changes: 9 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ function filterQueryResults(result, mask, creationTree, abilities, model, operat
// src/index.ts
function useCaslAbilities(getAbilityFactory, opts) {
return import_client2.Prisma.defineExtension((client) => {
const transactionsToBatch = /* @__PURE__ */ new Set();
const allOperations = (getAbilities) => ({
async $allOperations({ args, query, model, operation, ...rest }) {
const fluentModel = getFluentModel(model, rest);
Expand Down Expand Up @@ -1586,8 +1587,11 @@ function useCaslAbilities(getAbilityFactory, opts) {
return transactionQuery(client._createItxClient(transaction));
} else {
return client.$transaction(async (tx) => {
tx[Symbol.for("prisma.client.transaction.id")] = "casl-extension-" + tx[Symbol.for("prisma.client.transaction.id")];
return transactionQuery(tx);
const transactionId = tx[Symbol.for("prisma.client.transaction.id")].toString();
transactionsToBatch.add(transactionId);
return transactionQuery(tx).finally(() => {
transactionsToBatch.delete(transactionId);
});
}, {
//https://github.com/prisma/prisma/issues/20015
maxWait: 1e4
Expand All @@ -1597,10 +1601,11 @@ function useCaslAbilities(getAbilityFactory, opts) {
}
});
client._requestHandler.dataloader.options.batchBy = (request) => {
if (request.transaction?.id && !request.transaction?.id?.toString().startsWith("casl-extension-")) {
const batchId = getBatchId(request.protocolQuery);
if (request.transaction?.id && (!transactionsToBatch.has(request.transaction.id.toString()) && batchId)) {
return `transaction-${request.transaction.id}`;
}
return getBatchId(request.protocolQuery);
return batchId;
};
return client.$extends({
name: "prisma-extension-casl",
Expand Down
13 changes: 9 additions & 4 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ function filterQueryResults(result, mask, creationTree, abilities, model, operat
// src/index.ts
function useCaslAbilities(getAbilityFactory, opts) {
return Prisma2.defineExtension((client) => {
const transactionsToBatch = /* @__PURE__ */ new Set();
const allOperations = (getAbilities) => ({
async $allOperations({ args, query, model, operation, ...rest }) {
const fluentModel = getFluentModel(model, rest);
Expand Down Expand Up @@ -1560,8 +1561,11 @@ function useCaslAbilities(getAbilityFactory, opts) {
return transactionQuery(client._createItxClient(transaction));
} else {
return client.$transaction(async (tx) => {
tx[Symbol.for("prisma.client.transaction.id")] = "casl-extension-" + tx[Symbol.for("prisma.client.transaction.id")];
return transactionQuery(tx);
const transactionId = tx[Symbol.for("prisma.client.transaction.id")].toString();
transactionsToBatch.add(transactionId);
return transactionQuery(tx).finally(() => {
transactionsToBatch.delete(transactionId);
});
}, {
//https://github.com/prisma/prisma/issues/20015
maxWait: 1e4
Expand All @@ -1571,10 +1575,11 @@ function useCaslAbilities(getAbilityFactory, opts) {
}
});
client._requestHandler.dataloader.options.batchBy = (request) => {
if (request.transaction?.id && !request.transaction?.id?.toString().startsWith("casl-extension-")) {
const batchId = getBatchId(request.protocolQuery);
if (request.transaction?.id && (!transactionsToBatch.has(request.transaction.id.toString()) && batchId)) {
return `transaction-${request.transaction.id}`;
}
return getBatchId(request.protocolQuery);
return batchId;
};
return client.$extends({
name: "prisma-extension-casl",
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": "1.1.4",
"version": "1.1.5",
"description": "Enforce casl abilities on prisma client ",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit 28a1d44

Please sign in to comment.