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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dist
*.db-journal
*.tgz
.pnpm-store
*.vsix
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-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack",
"packageManager": "[email protected]",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-adapters/better-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/better-auth",
"version": "3.0.0-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack Better Auth Adapter. This adapter is modified from better-auth's Prisma adapter.",
"type": "module",
"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-beta.32",
"version": "3.0.0-beta.33",
"type": "module",
"author": {
"name": "ZenStack Team"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/actions/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export async function run(projectPath: string) {
console.log(colors.gray(`Using package manager: ${pm.agent}`));

for (const pkg of packages) {
const resolved = resolveCommand(pm.agent, 'install', [
const resolved = resolveCommand(pm.agent, 'add', [
pkg.name,
...(pkg.dev ? [pm.agent === 'yarn' ? '--dev' : '--save-dev'] : []),
...(pkg.dev ? [pm.agent.startsWith('yarn') || pm.agent === 'bun' ? '--dev' : '--save-dev'] : []),
]);
if (!resolved) {
throw new CliError(`Unable to determine how to install package "${pkg.name}". Please install it manually.`);
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/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-beta.32",
"version": "3.0.0-beta.33",
"description": "TanStack Query Client for consuming ZenStack v3's CRUD service",
"main": "index.js",
"type": "module",
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-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack Common Helpers",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/config/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-beta.32",
"version": "3.0.0-beta.33",
"type": "module",
"private": true,
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages/config/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-beta.32",
"version": "3.0.0-beta.33",
"private": true,
"license": "MIT"
}
2 changes: 1 addition & 1 deletion packages/config/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-beta.32",
"version": "3.0.0-beta.33",
"private": true,
"license": "MIT",
"exports": {
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-beta.32",
"version": "3.0.0-beta.33",
"description": "Create a new ZenStack project",
"type": "module",
"scripts": {
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-beta.32",
"version": "3.0.0-beta.33",
"license": "MIT",
"author": "ZenStack Team",
"files": [
Expand Down
10 changes: 10 additions & 0 deletions packages/language/src/validators/expression-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
isReferenceExpr,
isThisExpr,
MemberAccessExpr,
UnaryExpr,
type ExpressionType,
} from '../generated/ast';

Expand Down Expand Up @@ -67,6 +68,9 @@ export default class ExpressionValidator implements AstValidator<Expression> {
case 'BinaryExpr':
this.validateBinaryExpr(expr, accept);
break;
case 'UnaryExpr':
this.validateUnaryExpr(expr, accept);
break;
}
}

Expand Down Expand Up @@ -245,6 +249,12 @@ export default class ExpressionValidator implements AstValidator<Expression> {
}
}

private validateUnaryExpr(expr: UnaryExpr, accept: ValidationAcceptor) {
if (expr.operand.$resolvedType && expr.operand.$resolvedType.decl !== 'Boolean') {
accept('error', `operand of "${expr.operator}" must be of Boolean type`, { node: expr.operand });
}
}

private validateCollectionPredicate(expr: BinaryExpr, accept: ValidationAcceptor) {
if (!expr.$resolvedType) {
accept('error', 'collection predicate can only be used on an array of model type', { node: expr });
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/orm",
"version": "3.0.0-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack ORM",
"type": "module",
"scripts": {
Expand Down
14 changes: 11 additions & 3 deletions packages/orm/src/client/executor/zenstack-query-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class ZenStackQueryExecutor extends DefaultQueryExecutor {
if (parameters) {
compiled = { ...compiled, parameters };
}
return connection.executeQuery<any>(compiled);
return this.internalExecuteQuery(connection, compiled);
}

if (
Expand Down Expand Up @@ -246,7 +246,7 @@ export class ZenStackQueryExecutor extends DefaultQueryExecutor {
queryId,
);

const result = await connection.executeQuery<any>(compiled);
const result = await this.internalExecuteQuery(connection, compiled);

if (!this.driver.isTransactionConnection(connection)) {
// not in a transaction, just call all after-mutation hooks
Expand Down Expand Up @@ -470,7 +470,7 @@ export class ZenStackQueryExecutor extends DefaultQueryExecutor {
const compiled = this.compileQuery(selectQueryNode, createQueryId());
// execute the query directly with the given connection to avoid triggering
// any other side effects
const result = await connection.executeQuery(compiled);
const result = await this.internalExecuteQuery(connection, compiled);
return result.rows as Record<string, unknown>[];
}

Expand All @@ -483,4 +483,12 @@ export class ZenStackQueryExecutor extends DefaultQueryExecutor {
return condition2;
}
}

private async internalExecuteQuery(connection: DatabaseConnection, compiledQuery: CompiledQuery) {
try {
return await connection.executeQuery<any>(compiledQuery);
} catch (err) {
throw createDBQueryError('Failed to execute query', err, compiledQuery.sql, compiledQuery.parameters);
}
}
}
2 changes: 2 additions & 0 deletions packages/orm/src/client/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export type ClientOptions<Schema extends SchemaDef> = {

/**
* Custom function definitions.
*
* @private
*/
functions?: Record<string, ZModelFunction<Schema>>;

Expand Down
2 changes: 2 additions & 0 deletions packages/orm/src/client/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export interface RuntimePlugin<Schema extends SchemaDef = SchemaDef> {
*/
description?: string;

// TODO: revisit
/**
* Custom function implementations.
* @private
*/
functions?: Record<string, ZModelFunction<Schema>>;

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/policy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/plugin-policy",
"version": "3.0.0-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack Policy Plugin",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/schema",
"version": "3.0.0-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack Runtime Schema",
"type": "module",
"scripts": {
Expand Down
12 changes: 11 additions & 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-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack SDK",
"type": "module",
"scripts": {
Expand All @@ -25,6 +25,16 @@
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./ast": {
"import": {
"types": "./dist/ast.d.ts",
"default": "./dist/ast.js"
},
"require": {
"types": "./dist/ast.d.cts",
"default": "./dist/ast.cjs"
}
}
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/ast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@zenstackhq/language/ast';
1 change: 1 addition & 0 deletions packages/sdk/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'tsup';
export default defineConfig({
entry: {
index: 'src/index.ts',
ast: 'src/ast.ts',
},
outDir: 'dist',
splitting: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/server",
"version": "3.0.0-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack automatic CRUD API handlers and server adapters",
"type": "module",
"scripts": {
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-beta.32",
"version": "3.0.0-beta.33",
"description": "ZenStack Test Tools",
"type": "module",
"scripts": {
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-beta.32",
"version": "3.0.0-beta.33",
"description": "",
"type": "module",
"main": "index.js",
Expand Down
Loading