Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit 2e3b654

Browse files
authored
Merge pull request #644 from zenstackhq/dev
merge dev to main (v3.3.1)
2 parents 880d7e4 + 897a85e commit 2e3b654

File tree

29 files changed

+60
-57
lines changed

29 files changed

+60
-57
lines changed

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.3.0",
3+
"version": "3.3.1",
44
"description": "ZenStack",
55
"packageManager": "pnpm@10.23.0",
66
"type": "module",

packages/auth-adapters/better-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/better-auth",
3-
"version": "3.3.0",
3+
"version": "3.3.1",
44
"description": "ZenStack Better Auth Adapter. This adapter is modified from better-auth's Prisma adapter.",
55
"type": "module",
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.3.0",
6+
"version": "3.3.1",
77
"type": "module",
88
"author": {
99
"name": "ZenStack Team"

packages/cli/src/actions/proxy.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { ZModelCodeGenerator } from '@zenstackhq/language';
2-
import { isDataSource } from '@zenstackhq/language/ast';
1+
import {
2+
ConfigExpr,
3+
InvocationExpr,
4+
isDataSource,
5+
isInvocationExpr,
6+
isLiteralExpr,
7+
LiteralExpr,
8+
} from '@zenstackhq/language/ast';
39
import { getStringLiteral } from '@zenstackhq/language/utils';
410
import { ZenStackClient, type ClientContract } from '@zenstackhq/orm';
511
import { MysqlDialect } from '@zenstackhq/orm/dialects/mysql';
@@ -28,6 +34,10 @@ type Options = {
2834
};
2935

3036
export async function run(options: Options) {
37+
const allowedLogLevels = ['error', 'query'] as const;
38+
const log = options.logLevel?.filter((level): level is (typeof allowedLogLevels)[number] =>
39+
allowedLogLevels.includes(level as any),
40+
);
3141
const schemaFile = getSchemaFile(options.schema);
3242
console.log(colors.gray(`Loading ZModel schema from: ${schemaFile}`));
3343

@@ -46,16 +56,12 @@ export async function run(options: Options) {
4656

4757
if (!databaseUrl) {
4858
const schemaUrl = dataSource?.fields.find((f) => f.name === 'url')?.value;
49-
5059
if (!schemaUrl) {
5160
throw new CliError(
5261
`The schema's "datasource" does not have a "url" field, please provide it with -d option.`,
5362
);
5463
}
55-
const zModelGenerator = new ZModelCodeGenerator();
56-
const url = zModelGenerator.generate(schemaUrl);
57-
58-
databaseUrl = evaluateUrl(url);
64+
databaseUrl = evaluateUrl(schemaUrl);
5965
}
6066

6167
const provider = getStringLiteral(dataSource?.fields.find((f) => f.name === 'provider')?.value)!;
@@ -66,11 +72,6 @@ export async function run(options: Options) {
6672

6773
const schemaModule = (await jiti.import(path.join(outputPath, 'schema'))) as any;
6874

69-
const allowedLogLevels = ['error', 'query'] as const;
70-
const log = options.logLevel?.filter((level): level is (typeof allowedLogLevels)[number] =>
71-
allowedLogLevels.includes(level as any),
72-
);
73-
7475
const db = new ZenStackClient(schemaModule.schema, {
7576
dialect: dialect,
7677
log: log && log.length > 0 ? log : undefined,
@@ -86,18 +87,20 @@ export async function run(options: Options) {
8687
startServer(db, schemaModule.schema, options);
8788
}
8889

89-
function evaluateUrl(value: string): string {
90-
// Check if it's an env() function call
91-
const envMatch = value.trim().match(/^env\s*\(\s*['"]([^'"]+)['"]\s*\)$/);
92-
if (envMatch) {
93-
const varName = envMatch[1];
94-
const envValue = process.env[varName!];
90+
function evaluateUrl(schemaUrl: ConfigExpr) {
91+
if (isLiteralExpr(schemaUrl)) {
92+
// Handle string literal
93+
return getStringLiteral(schemaUrl);
94+
} else if (isInvocationExpr(schemaUrl)) {
95+
const envFunction = schemaUrl as InvocationExpr;
96+
const envName = getStringLiteral(envFunction.args[0]?.value as LiteralExpr)!;
97+
const envValue = process.env[envName];
9598
if (!envValue) {
96-
throw new CliError(`Environment variable ${varName} is not set`);
99+
throw new CliError(`Environment variable ${envName} is not set`);
97100
}
98101
return envValue;
99102
} else {
100-
return value;
103+
throw new CliError(`Unable to resolve the "url" field value.`);
101104
}
102105
}
103106

packages/clients/client-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/client-helpers",
3-
"version": "3.3.0",
3+
"version": "3.3.1",
44
"description": "Helpers for implementing clients that consume ZenStack's CRUD service",
55
"type": "module",
66
"scripts": {

packages/clients/tanstack-query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/tanstack-query",
3-
"version": "3.3.0",
3+
"version": "3.3.1",
44
"description": "TanStack Query Client for consuming ZenStack v3's CRUD service",
55
"type": "module",
66
"scripts": {

packages/clients/tanstack-query/src/common/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { QueryClient } from '@tanstack/query-core';
22
import type { InvalidationPredicate, QueryInfo } from '@zenstackhq/client-helpers';
3-
import { parseQueryKey } from './query-key';
3+
import { parseQueryKey } from './query-key.js';
44

55
export function invalidateQueriesMatchingPredicate(queryClient: QueryClient, predicate: InvalidationPredicate) {
66
return queryClient.invalidateQueries({

packages/clients/tanstack-query/src/react.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ import type {
5454
} from '@zenstackhq/orm';
5555
import type { GetModels, SchemaDef } from '@zenstackhq/schema';
5656
import { createContext, useContext } from 'react';
57-
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client';
58-
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants';
59-
import { getQueryKey } from './common/query-key';
57+
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client.js';
58+
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants.js';
59+
import { getQueryKey } from './common/query-key.js';
6060
import type {
6161
ExtraMutationOptions,
6262
ExtraQueryOptions,
6363
ProcedureReturn,
6464
QueryContext,
6565
TrimDelegateModelOperations,
6666
WithOptimistic,
67-
} from './common/types';
67+
} from './common/types.js';
6868
export type { FetchFn } from '@zenstackhq/client-helpers/fetch';
6969

7070
type ProcedureHookFn<

packages/clients/tanstack-query/src/svelte/index.svelte.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ import type {
5555
} from '@zenstackhq/orm';
5656
import type { GetModels, SchemaDef } from '@zenstackhq/schema';
5757
import { getContext, setContext } from 'svelte';
58-
import { getAllQueries, invalidateQueriesMatchingPredicate } from '../common/client';
59-
import { CUSTOM_PROC_ROUTE_NAME } from '../common/constants';
60-
import { getQueryKey } from '../common/query-key';
58+
import { getAllQueries, invalidateQueriesMatchingPredicate } from '../common/client.js';
59+
import { CUSTOM_PROC_ROUTE_NAME } from '../common/constants.js';
60+
import { getQueryKey } from '../common/query-key.js';
6161
import type {
6262
ExtraMutationOptions,
6363
ExtraQueryOptions,
6464
ProcedureReturn,
6565
QueryContext,
6666
TrimDelegateModelOperations,
6767
WithOptimistic,
68-
} from '../common/types';
68+
} from '../common/types.js';
6969
export type { FetchFn } from '@zenstackhq/client-helpers/fetch';
7070

7171
type ProcedureHookFn<

packages/clients/tanstack-query/src/vue.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ import type {
5353
} from '@zenstackhq/orm';
5454
import type { GetModels, SchemaDef } from '@zenstackhq/schema';
5555
import { computed, inject, provide, toValue, unref, type MaybeRefOrGetter, type Ref, type UnwrapRef } from 'vue';
56-
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client';
57-
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants';
58-
import { getQueryKey } from './common/query-key';
56+
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client.js';
57+
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants.js';
58+
import { getQueryKey } from './common/query-key.js';
5959
import type {
6060
ExtraMutationOptions,
6161
ExtraQueryOptions,
6262
ProcedureReturn,
6363
QueryContext,
6464
TrimDelegateModelOperations,
6565
WithOptimistic,
66-
} from './common/types';
66+
} from './common/types.js';
6767
export type { FetchFn } from '@zenstackhq/client-helpers/fetch';
6868
export const VueQueryContextKey = 'zenstack-vue-query-context';
6969

0 commit comments

Comments
 (0)