Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ db.$use({
return {
intercept: model === 'User',
// load entities affected before the mutation (defaults to false)
loadBeforeMutationEntity: true,
loadBeforeMutationEntities: true,
// load entities affected after the mutation (defaults to false)
loadAfterMutationEntity: true,
loadAfterMutationEntities: true,
};
},
beforeEntityMutation({ model, action, entities }) {
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": "zenstack-v3",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "ZenStack",
"packageManager": "[email protected]",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "zenstack",
"displayName": "ZenStack CLI",
"description": "FullStack database toolkit with built-in access control and automatic API generation.",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"type": "module",
"author": {
"name": "ZenStack Team"
Expand Down
2 changes: 1 addition & 1 deletion packages/common-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/common-helpers",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "ZenStack Common Helpers",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-zenstack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-zenstack",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "Create a new ZenStack project",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dialects/sql.js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/kysely-sql-js",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "Kysely dialect for sql.js",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/eslint-config",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"type": "module",
"private": true,
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zenstack",
"publisher": "zenstack",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"displayName": "ZenStack Language Tools",
"description": "VSCode extension for ZenStack ZModel language",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/language",
"description": "ZenStack ZModel language specification",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"license": "MIT",
"author": "ZenStack Team",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/runtime",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "ZenStack Runtime",
"type": "module",
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions packages/runtime/src/client/executor/zenstack-query-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ZenStackQueryExecutor<Schema extends SchemaDef> extends DefaultQuer
const oldQueryNode = queryNode;
if (
(InsertQueryNode.is(queryNode) || UpdateQueryNode.is(queryNode)) &&
mutationInterceptionInfo?.loadAfterMutationEntity
mutationInterceptionInfo?.loadAfterMutationEntities
) {
// need to make sure the query node has "returnAll"
// for insert and update queries
Expand Down Expand Up @@ -283,13 +283,13 @@ export class ZenStackQueryExecutor<Schema extends SchemaDef> extends DefaultQuer
queryNode,
});
result.intercept ||= filterResult.intercept;
result.loadBeforeMutationEntity ||= filterResult.loadBeforeMutationEntity;
result.loadAfterMutationEntity ||= filterResult.loadAfterMutationEntity;
result.loadBeforeMutationEntities ||= filterResult.loadBeforeMutationEntities;
result.loadAfterMutationEntities ||= filterResult.loadAfterMutationEntities;
}
}

let beforeMutationEntities: Record<string, unknown>[] | undefined;
if (result.loadBeforeMutationEntity && (UpdateQueryNode.is(queryNode) || DeleteQueryNode.is(queryNode))) {
if (result.loadBeforeMutationEntities && (UpdateQueryNode.is(queryNode) || DeleteQueryNode.is(queryNode))) {
beforeMutationEntities = await this.loadEntities(mutationModel, where);
}

Expand Down Expand Up @@ -354,7 +354,7 @@ export class ZenStackQueryExecutor<Schema extends SchemaDef> extends DefaultQuer

for (const hook of hooks) {
let afterMutationEntities: Record<string, unknown>[] | undefined = undefined;
if (mutationInterceptionInfo.loadAfterMutationEntity) {
if (mutationInterceptionInfo.loadAfterMutationEntities) {
if (InsertQueryNode.is(queryNode) || UpdateQueryNode.is(queryNode)) {
afterMutationEntities = queryResult.rows as Record<string, unknown>[];
}
Expand Down
10 changes: 5 additions & 5 deletions packages/runtime/src/client/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export type MutationInterceptionFilterResult = {
/**
* Whether entities should be loaded before the mutation.
*/
loadBeforeMutationEntity?: boolean;
loadBeforeMutationEntities?: boolean;

/**
* Whether entities should be loaded after the mutation.
*/
loadAfterMutationEntity?: boolean;
loadAfterMutationEntities?: boolean;
};

type MutationHooksArgs<Schema extends SchemaDef> = {
Expand Down Expand Up @@ -149,16 +149,16 @@ export interface RuntimePlugin<Schema extends SchemaDef = SchemaDef> {

/**
* Called before an entity is mutated.
* @param args.entity Only available if `loadBeforeMutationEntity` is set to true in the
* @param args.entity Only available if `loadBeforeMutationEntities` is set to true in the
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
*/
beforeEntityMutation?: BeforeEntityMutationCallback<Schema>;

/**
* Called after an entity is mutated.
* @param args.beforeMutationEntity Only available if `loadBeforeMutationEntity` is set to true in the
* @param args.beforeMutationEntity Only available if `loadBeforeMutationEntities` is set to true in the
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
* @param args.afterMutationEntity Only available if `loadAfterMutationEntity` is set to true in the
* @param args.afterMutationEntity Only available if `loadAfterMutationEntities` is set to true in the
* return value of {@link RuntimePlugin.mutationInterceptionFilter}.
*/
afterEntityMutation?: AfterEntityMutationCallback<Schema>;
Expand Down
12 changes: 6 additions & 6 deletions packages/runtime/test/plugin/mutation-hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('Entity lifecycle tests', () => {
mutationInterceptionFilter: () => {
return {
intercept: true,
loadBeforeMutationEntity: true,
loadBeforeMutationEntities: true,
};
},
beforeEntityMutation(args) {
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('Entity lifecycle tests', () => {
mutationInterceptionFilter: () => {
return {
intercept: true,
loadAfterMutationEntity: true,
loadAfterMutationEntities: true,
};
},
afterEntityMutation(args) {
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('Entity lifecycle tests', () => {
mutationInterceptionFilter: () => {
return {
intercept: true,
loadAfterMutationEntity: true,
loadAfterMutationEntities: true,
};
},
afterEntityMutation(args) {
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('Entity lifecycle tests', () => {
mutationInterceptionFilter: (args) => {
return {
intercept: args.action === 'create' || args.action === 'update',
loadAfterMutationEntity: true,
loadAfterMutationEntities: true,
};
},
afterEntityMutation(args) {
Expand Down Expand Up @@ -350,8 +350,8 @@ describe('Entity lifecycle tests', () => {
mutationInterceptionFilter: () => {
return {
intercept: true,
loadBeforeMutationEntity: true,
loadAfterMutationEntity: true,
loadBeforeMutationEntities: true,
loadAfterMutationEntities: true,
};
},
afterEntityMutation(args) {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/sdk",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "ZenStack SDK",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/tanstack-query/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/tanstack-query",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/testtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/testtools",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "ZenStack Test Tools",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/typescript-config",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"private": true,
"license": "MIT"
}
2 changes: 1 addition & 1 deletion packages/vitest-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/vitest-config",
"type": "module",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"private": true,
"license": "MIT",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/zod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/zod",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "",
"type": "module",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion samples/blog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-blog",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "e2e",
"version": "3.0.0-alpha.22",
"version": "3.0.0-alpha.23",
"private": true,
"type": "module",
"scripts": {
Expand Down