Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"zenstack": "bin/cli"
},
"scripts": {
"build": "tsup-node",
"build": "tsc --noEmit && tsup-node",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"test": "vitest run",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
"baseUrl": "."
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/common-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "ZenStack Common Helpers",
"type": "module",
"scripts": {
"build": "tsup-node",
"build": "tsc --noEmit && tsup-node",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"pack": "pnpm pack"
Expand Down
2 changes: 1 addition & 1 deletion packages/common-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
"baseUrl": "."
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/create-zenstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Create a new ZenStack project",
"type": "module",
"scripts": {
"build": "tsup-node",
"build": "tsc --noEmit && tsup-node",
"lint": "eslint src --ext ts",
"pack": "pnpm pack"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/create-zenstack/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
"baseUrl": "."
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/dialects/sql.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Kysely dialect for sql.js",
"type": "module",
"scripts": {
"build": "tsup-node",
"build": "tsc --noEmit && tsup-node",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"pack": "pnpm pack"
Expand Down
4 changes: 2 additions & 2 deletions packages/dialects/sql.js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
"baseUrl": "."
},
"include": ["src/**/*", "test/**/*"]
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/ide/vscode/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
"baseUrl": "."
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"type": "module",
"scripts": {
"build": "pnpm langium:generate && tsup-node",
"build": "pnpm langium:generate && tsc --noEmit && tsup-node",
"lint": "eslint src --ext ts",
"langium:generate": "langium generate",
"langium:generate:production": "langium generate --mode=production",
Expand Down
4 changes: 2 additions & 2 deletions packages/language/src/validators/typedef-validator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ValidationAcceptor } from 'langium';
import type { TypeDef, TypeDefField } from '../generated/ast';
import type { DataField, TypeDef } from '../generated/ast';
import { validateAttributeApplication } from './attribute-application-validator';
import { validateDuplicatedDeclarations, type AstValidator } from './common';

Expand All @@ -21,7 +21,7 @@ export default class TypeDefValidator implements AstValidator<TypeDef> {
typeDef.fields.forEach((field) => this.validateField(field, accept));
}

private validateField(field: TypeDefField, accept: ValidationAcceptor): void {
private validateField(field: DataField, accept: ValidationAcceptor): void {
field.attributes.forEach((attr) => validateAttributeApplication(attr, accept));
}
}
2 changes: 1 addition & 1 deletion packages/language/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
"baseUrl": "."
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "ZenStack Runtime",
"type": "module",
"scripts": {
"build": "tsup-node && pnpm test:generate",
"build": "tsc --noEmit && tsup-node && pnpm test:generate",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"test": "vitest run && pnpm test:typecheck",
Expand Down
10 changes: 8 additions & 2 deletions packages/runtime/src/client/crud/dialects/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,14 @@ export abstract class BaseCrudDialect<Schema extends SchemaDef> {
return eb.not(this.and(eb, ...args));
}

fieldRef(model: string, field: string, eb: ExpressionBuilder<any, any>, modelAlias?: string) {
return buildFieldRef(this.schema, model, field, this.options, eb, modelAlias);
fieldRef(
model: string,
field: string,
eb: ExpressionBuilder<any, any>,
modelAlias?: string,
inlineComputedField = true,
) {
return buildFieldRef(this.schema, model, field, this.options, eb, modelAlias, inlineComputedField);
}

// #endregion
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/src/client/crud/dialects/postgresql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ export class PostgresCrudDialect<Schema extends SchemaDef> extends BaseCrudDiale
...Object.entries(relationModelDef.fields)
.filter(([, value]) => !value.relation)
.filter(([name]) => !(typeof payload === 'object' && (payload.omit as any)?.[name] === true))
.map(([field]) => [sql.lit(field), this.fieldRef(relationModel, field, eb)])
.map(([field]) => [sql.lit(field), this.fieldRef(relationModel, field, eb, undefined, false)])
.flatMap((v) => v),
);
} else if (payload.select) {
// select specific fields
objArgs.push(
...Object.entries(payload.select)
...Object.entries<any>(payload.select)
.filter(([, value]) => value)
.map(([field, value]) => {
if (field === '_count') {
Expand All @@ -249,7 +249,7 @@ export class PostgresCrudDialect<Schema extends SchemaDef> extends BaseCrudDiale
? // reference the synthesized JSON field
eb.ref(`${parentAlias}$${relationField}$${field}.$j`)
: // reference a plain field
this.fieldRef(relationModel, field, eb);
this.fieldRef(relationModel, field, eb, undefined, false);
return [sql.lit(field), fieldValue];
}
})
Expand Down
7 changes: 5 additions & 2 deletions packages/runtime/src/client/crud/dialects/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class SqliteCrudDialect<Schema extends SchemaDef> extends BaseCrudDialect
...Object.entries(relationModelDef.fields)
.filter(([, value]) => !value.relation)
.filter(([name]) => !(typeof payload === 'object' && (payload.omit as any)?.[name] === true))
.map(([field]) => [sql.lit(field), this.fieldRef(relationModel, field, eb)])
.map(([field]) => [sql.lit(field), this.fieldRef(relationModel, field, eb, undefined, false)])
.flatMap((v) => v),
);
} else if (payload.select) {
Expand Down Expand Up @@ -199,7 +199,10 @@ export class SqliteCrudDialect<Schema extends SchemaDef> extends BaseCrudDialect
);
return [sql.lit(field), subJson];
} else {
return [sql.lit(field), this.fieldRef(relationModel, field, eb) as ArgsType];
return [
sql.lit(field),
this.fieldRef(relationModel, field, eb, undefined, false) as ArgsType,
];
}
}
})
Expand Down
4 changes: 4 additions & 0 deletions packages/runtime/src/client/query-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,15 @@ export function buildFieldRef<Schema extends SchemaDef>(
options: ClientOptions<Schema>,
eb: ExpressionBuilder<any, any>,
modelAlias?: string,
inlineComputedField = true,
): ExpressionWrapper<any, any, unknown> {
const fieldDef = requireField(schema, model, field);
if (!fieldDef.computed) {
return eb.ref(modelAlias ? `${modelAlias}.${field}` : field);
} else {
if (!inlineComputedField) {
return eb.ref(modelAlias ? `${modelAlias}.${field}` : field);
}
let computer: Function | undefined;
if ('computedFields' in options) {
const computedFields = options.computedFields as Record<string, any>;
Expand Down
Loading
Loading