@zenstackhq/runtime 3.0.0-alpha.22 → 3.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{contract-D8U59Syb.d.cts → contract-Y3qWOegb.d.cts} +5 -5
- package/dist/{contract-D8U59Syb.d.ts → contract-Y3qWOegb.d.ts} +5 -5
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/plugins/policy/index.d.cts +1 -1
- package/dist/plugins/policy/index.d.ts +1 -1
- package/package.json +8 -8
|
@@ -615,11 +615,11 @@ type MutationInterceptionFilterResult = {
|
|
|
615
615
|
/**
|
|
616
616
|
* Whether entities should be loaded before the mutation.
|
|
617
617
|
*/
|
|
618
|
-
|
|
618
|
+
loadBeforeMutationEntities?: boolean;
|
|
619
619
|
/**
|
|
620
620
|
* Whether entities should be loaded after the mutation.
|
|
621
621
|
*/
|
|
622
|
-
|
|
622
|
+
loadAfterMutationEntities?: boolean;
|
|
623
623
|
};
|
|
624
624
|
type MutationHooksArgs<Schema extends SchemaDef> = {
|
|
625
625
|
/**
|
|
@@ -685,15 +685,15 @@ interface RuntimePlugin<Schema extends SchemaDef = SchemaDef> {
|
|
|
685
685
|
mutationInterceptionFilter?: MutationInterceptionFilter<Schema>;
|
|
686
686
|
/**
|
|
687
687
|
* Called before an entity is mutated.
|
|
688
|
-
* @param args.entity Only available if `
|
|
688
|
+
* @param args.entity Only available if `loadBeforeMutationEntities` is set to true in the
|
|
689
689
|
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
|
|
690
690
|
*/
|
|
691
691
|
beforeEntityMutation?: BeforeEntityMutationCallback<Schema>;
|
|
692
692
|
/**
|
|
693
693
|
* Called after an entity is mutated.
|
|
694
|
-
* @param args.beforeMutationEntity Only available if `
|
|
694
|
+
* @param args.beforeMutationEntity Only available if `loadBeforeMutationEntities` is set to true in the
|
|
695
695
|
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
|
|
696
|
-
* @param args.afterMutationEntity Only available if `
|
|
696
|
+
* @param args.afterMutationEntity Only available if `loadAfterMutationEntities` is set to true in the
|
|
697
697
|
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
|
|
698
698
|
*/
|
|
699
699
|
afterEntityMutation?: AfterEntityMutationCallback<Schema>;
|
|
@@ -615,11 +615,11 @@ type MutationInterceptionFilterResult = {
|
|
|
615
615
|
/**
|
|
616
616
|
* Whether entities should be loaded before the mutation.
|
|
617
617
|
*/
|
|
618
|
-
|
|
618
|
+
loadBeforeMutationEntities?: boolean;
|
|
619
619
|
/**
|
|
620
620
|
* Whether entities should be loaded after the mutation.
|
|
621
621
|
*/
|
|
622
|
-
|
|
622
|
+
loadAfterMutationEntities?: boolean;
|
|
623
623
|
};
|
|
624
624
|
type MutationHooksArgs<Schema extends SchemaDef> = {
|
|
625
625
|
/**
|
|
@@ -685,15 +685,15 @@ interface RuntimePlugin<Schema extends SchemaDef = SchemaDef> {
|
|
|
685
685
|
mutationInterceptionFilter?: MutationInterceptionFilter<Schema>;
|
|
686
686
|
/**
|
|
687
687
|
* Called before an entity is mutated.
|
|
688
|
-
* @param args.entity Only available if `
|
|
688
|
+
* @param args.entity Only available if `loadBeforeMutationEntities` is set to true in the
|
|
689
689
|
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
|
|
690
690
|
*/
|
|
691
691
|
beforeEntityMutation?: BeforeEntityMutationCallback<Schema>;
|
|
692
692
|
/**
|
|
693
693
|
* Called after an entity is mutated.
|
|
694
|
-
* @param args.beforeMutationEntity Only available if `
|
|
694
|
+
* @param args.beforeMutationEntity Only available if `loadBeforeMutationEntities` is set to true in the
|
|
695
695
|
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
|
|
696
|
-
* @param args.afterMutationEntity Only available if `
|
|
696
|
+
* @param args.afterMutationEntity Only available if `loadAfterMutationEntities` is set to true in the
|
|
697
697
|
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
|
|
698
698
|
*/
|
|
699
699
|
afterEntityMutation?: AfterEntityMutationCallback<Schema>;
|
package/dist/index.cjs
CHANGED
|
@@ -5908,7 +5908,7 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends import_kysely13
|
|
|
5908
5908
|
await this.callBeforeMutationHooks(queryNode, mutationInterceptionInfo);
|
|
5909
5909
|
}
|
|
5910
5910
|
const oldQueryNode = queryNode;
|
|
5911
|
-
if ((import_kysely13.InsertQueryNode.is(queryNode) || import_kysely13.UpdateQueryNode.is(queryNode)) && mutationInterceptionInfo?.
|
|
5911
|
+
if ((import_kysely13.InsertQueryNode.is(queryNode) || import_kysely13.UpdateQueryNode.is(queryNode)) && mutationInterceptionInfo?.loadAfterMutationEntities) {
|
|
5912
5912
|
queryNode = {
|
|
5913
5913
|
...queryNode,
|
|
5914
5914
|
returning: import_kysely13.ReturningNode.create([
|
|
@@ -6054,12 +6054,12 @@ ${compiled.parameters.map((p) => (0, import_node_util2.inspect)(p)).join("\n")}`
|
|
|
6054
6054
|
queryNode
|
|
6055
6055
|
});
|
|
6056
6056
|
result.intercept ||= filterResult.intercept;
|
|
6057
|
-
result.
|
|
6058
|
-
result.
|
|
6057
|
+
result.loadBeforeMutationEntities ||= filterResult.loadBeforeMutationEntities;
|
|
6058
|
+
result.loadAfterMutationEntities ||= filterResult.loadAfterMutationEntities;
|
|
6059
6059
|
}
|
|
6060
6060
|
}
|
|
6061
6061
|
let beforeMutationEntities;
|
|
6062
|
-
if (result.
|
|
6062
|
+
if (result.loadBeforeMutationEntities && (import_kysely13.UpdateQueryNode.is(queryNode) || import_kysely13.DeleteQueryNode.is(queryNode))) {
|
|
6063
6063
|
beforeMutationEntities = await this.loadEntities(mutationModel, where);
|
|
6064
6064
|
}
|
|
6065
6065
|
return {
|
|
@@ -6108,7 +6108,7 @@ ${compiled.parameters.map((p) => (0, import_node_util2.inspect)(p)).join("\n")}`
|
|
|
6108
6108
|
const inTransaction = this.driver.isTransactionConnection(connection);
|
|
6109
6109
|
for (const hook of hooks) {
|
|
6110
6110
|
let afterMutationEntities = void 0;
|
|
6111
|
-
if (mutationInterceptionInfo.
|
|
6111
|
+
if (mutationInterceptionInfo.loadAfterMutationEntities) {
|
|
6112
6112
|
if (import_kysely13.InsertQueryNode.is(queryNode) || import_kysely13.UpdateQueryNode.is(queryNode)) {
|
|
6113
6113
|
afterMutationEntities = queryResult.rows;
|
|
6114
6114
|
}
|