Skip to content

Commit c9d5e1d

Browse files
authored
Merge pull request #125 from zenstackhq/dev
merge dev to main (v3.0.0-alpha.14)
2 parents 30fc2fa + 7c7183d commit c9d5e1d

File tree

37 files changed

+399
-567
lines changed

37 files changed

+399
-567
lines changed

TODO.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [ ] format
1212
- [ ] db seed
1313
- [ ] ZModel
14+
- [ ] Import
1415
- [ ] View support
1516
- [ ] ORM
1617
- [x] Create
@@ -80,8 +81,8 @@
8081
- [ ] Strict undefined checks
8182
- [ ] DbNull vs JsonNull
8283
- [ ] Benchmark
83-
- [ ] Plugin
84-
- [ ] Post-mutation hooks should be called after transaction is committed
84+
- [x] Plugin
85+
- [x] Post-mutation hooks should be called after transaction is committed
8586
- [x] TypeDef and mixin
8687
- [ ] Strongly typed JSON
8788
- [x] Polymorphism

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.13",
3+
"version": "3.0.0-alpha.14",
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.13",
6+
"version": "3.0.0-alpha.14",
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.13",
3+
"version": "3.0.0-alpha.14",
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.13",
3+
"version": "3.0.0-alpha.14",
44
"description": "Create a new ZenStack project",
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.13",
3+
"version": "3.0.0-alpha.14",
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.13",
4+
"version": "3.0.0-alpha.14",
55
"displayName": "ZenStack Language Tools",
66
"description": "VSCode extension for ZenStack ZModel language",
77
"private": true,

packages/language/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/language",
33
"description": "ZenStack ZModel language specification",
4-
"version": "3.0.0-alpha.13",
4+
"version": "3.0.0-alpha.14",
55
"license": "MIT",
66
"author": "ZenStack Team",
77
"files": [

packages/runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/runtime",
3-
"version": "3.0.0-alpha.13",
3+
"version": "3.0.0-alpha.14",
44
"description": "ZenStack Runtime",
55
"type": "module",
66
"scripts": {

packages/runtime/src/client/client-impl.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,23 +255,33 @@ export class ClientImpl<Schema extends SchemaDef> {
255255
}
256256

257257
$use(plugin: RuntimePlugin<Schema>) {
258-
const newOptions = {
258+
// tsc perf
259+
const newPlugins: RuntimePlugin<Schema>[] = [...(this.$options.plugins ?? []), plugin];
260+
const newOptions: ClientOptions<Schema> = {
259261
...this.options,
260-
plugins: [...(this.options.plugins ?? []), plugin],
262+
plugins: newPlugins,
261263
};
262264
return new ClientImpl<Schema>(this.schema, newOptions, this);
263265
}
264266

265267
$unuse(pluginId: string) {
266-
const newOptions = {
268+
// tsc perf
269+
const newPlugins: RuntimePlugin<Schema>[] = [];
270+
for (const plugin of this.options.plugins ?? []) {
271+
if (plugin.id !== pluginId) {
272+
newPlugins.push(plugin);
273+
}
274+
}
275+
const newOptions: ClientOptions<Schema> = {
267276
...this.options,
268-
plugins: this.options.plugins?.filter((p) => p.id !== pluginId),
277+
plugins: newPlugins,
269278
};
270279
return new ClientImpl<Schema>(this.schema, newOptions, this);
271280
}
272281

273282
$unuseAll() {
274-
const newOptions = {
283+
// tsc perf
284+
const newOptions: ClientOptions<Schema> = {
275285
...this.options,
276286
plugins: [] as RuntimePlugin<Schema>[],
277287
};
@@ -388,7 +398,7 @@ function createModelCrudHandler<Schema extends SchemaDef, Model extends GetModel
388398
for (const plugin of plugins) {
389399
if (plugin.onQuery && typeof plugin.onQuery === 'object') {
390400
// for each model key or "$allModels"
391-
for (const [_model, modelHooks] of Object.entries(plugin.onQuery)) {
401+
for (const [_model, modelHooks] of Object.entries<any>(plugin.onQuery)) {
392402
if (_model === lowerCaseFirst(model) || _model === '$allModels') {
393403
if (modelHooks && typeof modelHooks === 'object') {
394404
// for each operation key or "$allOperations"

0 commit comments

Comments
 (0)