Skip to content

Commit a607b46

Browse files
authored
Merge pull request #166 from zenstackhq/dev
merge dev to main (v3.0.0-alpha.24)
2 parents 726b826 + ffbaace commit a607b46

File tree

30 files changed

+1197
-1267
lines changed

30 files changed

+1197
-1267
lines changed

.vscode/launch.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
"request": "launch",
1111
"skipFiles": ["<node_internals>/**"],
1212
"type": "node",
13-
"args": [
14-
"generate",
15-
"--schema",
16-
"${workspaceFolder}/samples/blog/zenstack/schema.zmodel"
17-
]
13+
"args": ["generate", "--schema", "${workspaceFolder}/samples/blog/zenstack/schema.zmodel"]
1814
},
1915
{
2016
"name": "Debug with TSX",
@@ -44,15 +40,14 @@
4440

4541
// Ignore all dependencies (optional)
4642
"${workspaceFolder}/node_modules/**"
47-
]
43+
],
44+
"cwd": "${fileDirname}"
4845
},
4946
{
5047
"name": "Run Extension",
5148
"type": "extensionHost",
5249
"request": "launch",
53-
"args": [
54-
"--extensionDevelopmentPath=${workspaceFolder}/packages/ide/vscode"
55-
],
50+
"args": ["--extensionDevelopmentPath=${workspaceFolder}/packages/ide/vscode"],
5651
"sourceMaps": true,
5752
"outFiles": ["${workspaceFolder}/packages/ide/vscode/dist/**/*.js"]
5853
},

README.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,11 @@ ORM query interception allows you to intercept the high-level ORM API calls. The
289289
```ts
290290
db.$use({
291291
id: 'cost-logger',
292-
onQuery: {
293-
$allModels: {
294-
$allOperations: async ({ model, operation, args, query }) => {
295-
const start = Date.now();
296-
const result = await query(args);
297-
console.log(`[cost] ${model} ${operation} took ${Date.now() - start}ms`);
298-
return result;
299-
},
300-
},
292+
onQuery: async ({ model, operation, args, proceed }) => {
293+
const start = Date.now();
294+
const result = await proceed(args);
295+
console.log(`[cost] ${model} ${operation} took ${Date.now() - start}ms`);
296+
return result;
301297
},
302298
});
303299
```
@@ -333,11 +329,14 @@ Another popular interception use case is, instead of intercepting calls, "listen
333329
```ts
334330
db.$use({
335331
id: 'mutation-hook-plugin',
336-
beforeEntityMutation({ model, action }) {
337-
console.log(`Before ${model} ${action}`);
338-
},
339-
afterEntityMutation({ model, action }) {
340-
console.log(`After ${model} ${action}`);
332+
onEntityMutation: {
333+
beforeEntityMutation({ model, action }) {
334+
console.log(`Before ${model} ${action}`);
335+
},
336+
337+
afterEntityMutation({ model, action }) {
338+
console.log(`After ${model} ${action}`);
339+
},
341340
},
342341
});
343342
```
@@ -347,20 +346,24 @@ You can provide an extra `mutationInterceptionFilter` to control what to interce
347346
```ts
348347
db.$use({
349348
id: 'mutation-hook-plugin',
350-
mutationInterceptionFilter: ({ model }) => {
351-
return {
352-
intercept: model === 'User',
353-
// load entities affected before the mutation (defaults to false)
354-
loadBeforeMutationEntities: true,
355-
// load entities affected after the mutation (defaults to false)
356-
loadAfterMutationEntities: true,
357-
};
358-
},
359-
beforeEntityMutation({ model, action, entities }) {
360-
console.log(`Before ${model} ${action}: ${entities}`);
361-
},
362-
afterEntityMutation({ model, action, afterMutationEntities }) {
363-
console.log(`After ${model} ${action}: ${afterMutationEntities}`);
349+
onEntityMutation: {
350+
mutationInterceptionFilter: ({ model }) => {
351+
return {
352+
intercept: model === 'User',
353+
// load entities affected before the mutation (defaults to false)
354+
loadBeforeMutationEntities: true,
355+
// load entities affected after the mutation (defaults to false)
356+
loadAfterMutationEntities: true,
357+
};
358+
},
359+
360+
beforeEntityMutation({ model, action, entities }) {
361+
console.log(`Before ${model} ${action}: ${entities}`);
362+
},
363+
364+
afterEntityMutation({ model, action, afterMutationEntities }) {
365+
console.log(`After ${model} ${action}: ${afterMutationEntities}`);
366+
},
364367
},
365368
});
366369
```

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
- [ ] Short-circuit pre-create check for scalar-field only policies
100100
- [ ] Inject "replace into"
101101
- [ ] Inject "on conflict do update"
102+
- [ ] Inject "insert into select from"
102103
- [x] Migration
103104
- [ ] Databases
104105
- [x] SQLite

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-v3",
3-
"version": "3.0.0-alpha.23",
3+
"version": "3.0.0-alpha.24",
44
"description": "ZenStack",
55
"packageManager": "[email protected]",
66
"scripts": {

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "zenstack",
44
"displayName": "ZenStack CLI",
55
"description": "FullStack database toolkit with built-in access control and automatic API generation.",
6-
"version": "3.0.0-alpha.23",
6+
"version": "3.0.0-alpha.24",
77
"type": "module",
88
"author": {
99
"name": "ZenStack Team"

packages/common-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/common-helpers",
3-
"version": "3.0.0-alpha.23",
3+
"version": "3.0.0-alpha.24",
44
"description": "ZenStack Common Helpers",
55
"type": "module",
66
"scripts": {

packages/create-zenstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-zenstack",
3-
"version": "3.0.0-alpha.23",
3+
"version": "3.0.0-alpha.24",
44
"description": "Create a new ZenStack project",
55
"type": "module",
66
"scripts": {

packages/dialects/sql.js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/kysely-sql-js",
3-
"version": "3.0.0-alpha.23",
3+
"version": "3.0.0-alpha.24",
44
"description": "Kysely dialect for sql.js",
55
"type": "module",
66
"scripts": {

packages/eslint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/eslint-config",
3-
"version": "3.0.0-alpha.23",
3+
"version": "3.0.0-alpha.24",
44
"type": "module",
55
"private": true,
66
"license": "MIT"

packages/ide/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zenstack",
33
"publisher": "zenstack",
4-
"version": "3.0.0-alpha.23",
4+
"version": "3.0.0-alpha.24",
55
"displayName": "ZenStack Language Tools",
66
"description": "VSCode extension for ZenStack ZModel language",
77
"private": true,

0 commit comments

Comments
 (0)