Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.
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
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.3.0",
"version": "3.3.1",
"description": "ZenStack",
"packageManager": "pnpm@10.23.0",
"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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"type": "module",
"author": {
"name": "ZenStack Team"
Expand Down
43 changes: 23 additions & 20 deletions packages/cli/src/actions/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ZModelCodeGenerator } from '@zenstackhq/language';
import { isDataSource } from '@zenstackhq/language/ast';
import {
ConfigExpr,
InvocationExpr,
isDataSource,
isInvocationExpr,
isLiteralExpr,
LiteralExpr,
} from '@zenstackhq/language/ast';
import { getStringLiteral } from '@zenstackhq/language/utils';
import { ZenStackClient, type ClientContract } from '@zenstackhq/orm';
import { MysqlDialect } from '@zenstackhq/orm/dialects/mysql';
Expand Down Expand Up @@ -28,6 +34,10 @@ type Options = {
};

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

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

if (!databaseUrl) {
const schemaUrl = dataSource?.fields.find((f) => f.name === 'url')?.value;

if (!schemaUrl) {
throw new CliError(
`The schema's "datasource" does not have a "url" field, please provide it with -d option.`,
);
}
const zModelGenerator = new ZModelCodeGenerator();
const url = zModelGenerator.generate(schemaUrl);

databaseUrl = evaluateUrl(url);
databaseUrl = evaluateUrl(schemaUrl);
}

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

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

const allowedLogLevels = ['error', 'query'] as const;
const log = options.logLevel?.filter((level): level is (typeof allowedLogLevels)[number] =>
allowedLogLevels.includes(level as any),
);

const db = new ZenStackClient(schemaModule.schema, {
dialect: dialect,
log: log && log.length > 0 ? log : undefined,
Expand All @@ -86,18 +87,20 @@ export async function run(options: Options) {
startServer(db, schemaModule.schema, options);
}

function evaluateUrl(value: string): string {
// Check if it's an env() function call
const envMatch = value.trim().match(/^env\s*\(\s*['"]([^'"]+)['"]\s*\)$/);
if (envMatch) {
const varName = envMatch[1];
const envValue = process.env[varName!];
function evaluateUrl(schemaUrl: ConfigExpr) {
if (isLiteralExpr(schemaUrl)) {
// Handle string literal
return getStringLiteral(schemaUrl);
} else if (isInvocationExpr(schemaUrl)) {
const envFunction = schemaUrl as InvocationExpr;
const envName = getStringLiteral(envFunction.args[0]?.value as LiteralExpr)!;
const envValue = process.env[envName];
if (!envValue) {
throw new CliError(`Environment variable ${varName} is not set`);
throw new CliError(`Environment variable ${envName} is not set`);
}
return envValue;
} else {
return value;
throw new CliError(`Unable to resolve the "url" field value.`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/clients/client-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/client-helpers",
"version": "3.3.0",
"version": "3.3.1",
"description": "Helpers for implementing clients that consume ZenStack's CRUD service",
"type": "module",
"scripts": {
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.3.0",
"version": "3.3.1",
"description": "TanStack Query Client for consuming ZenStack v3's CRUD service",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/tanstack-query/src/common/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { QueryClient } from '@tanstack/query-core';
import type { InvalidationPredicate, QueryInfo } from '@zenstackhq/client-helpers';
import { parseQueryKey } from './query-key';
import { parseQueryKey } from './query-key.js';

export function invalidateQueriesMatchingPredicate(queryClient: QueryClient, predicate: InvalidationPredicate) {
return queryClient.invalidateQueries({
Expand Down
8 changes: 4 additions & 4 deletions packages/clients/tanstack-query/src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ import type {
} from '@zenstackhq/orm';
import type { GetModels, SchemaDef } from '@zenstackhq/schema';
import { createContext, useContext } from 'react';
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client';
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants';
import { getQueryKey } from './common/query-key';
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client.js';
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants.js';
import { getQueryKey } from './common/query-key.js';
import type {
ExtraMutationOptions,
ExtraQueryOptions,
ProcedureReturn,
QueryContext,
TrimDelegateModelOperations,
WithOptimistic,
} from './common/types';
} from './common/types.js';
export type { FetchFn } from '@zenstackhq/client-helpers/fetch';

type ProcedureHookFn<
Expand Down
8 changes: 4 additions & 4 deletions packages/clients/tanstack-query/src/svelte/index.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ import type {
} from '@zenstackhq/orm';
import type { GetModels, SchemaDef } from '@zenstackhq/schema';
import { getContext, setContext } from 'svelte';
import { getAllQueries, invalidateQueriesMatchingPredicate } from '../common/client';
import { CUSTOM_PROC_ROUTE_NAME } from '../common/constants';
import { getQueryKey } from '../common/query-key';
import { getAllQueries, invalidateQueriesMatchingPredicate } from '../common/client.js';
import { CUSTOM_PROC_ROUTE_NAME } from '../common/constants.js';
import { getQueryKey } from '../common/query-key.js';
import type {
ExtraMutationOptions,
ExtraQueryOptions,
ProcedureReturn,
QueryContext,
TrimDelegateModelOperations,
WithOptimistic,
} from '../common/types';
} from '../common/types.js';
export type { FetchFn } from '@zenstackhq/client-helpers/fetch';

type ProcedureHookFn<
Expand Down
8 changes: 4 additions & 4 deletions packages/clients/tanstack-query/src/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ import type {
} from '@zenstackhq/orm';
import type { GetModels, SchemaDef } from '@zenstackhq/schema';
import { computed, inject, provide, toValue, unref, type MaybeRefOrGetter, type Ref, type UnwrapRef } from 'vue';
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client';
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants';
import { getQueryKey } from './common/query-key';
import { getAllQueries, invalidateQueriesMatchingPredicate } from './common/client.js';
import { CUSTOM_PROC_ROUTE_NAME } from './common/constants.js';
import { getQueryKey } from './common/query-key.js';
import type {
ExtraMutationOptions,
ExtraQueryOptions,
ProcedureReturn,
QueryContext,
TrimDelegateModelOperations,
WithOptimistic,
} from './common/types';
} from './common/types.js';
export type { FetchFn } from '@zenstackhq/client-helpers/fetch';
export const VueQueryContextKey = 'zenstack-vue-query-context';

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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"description": "Create a new ZenStack project",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zenstack-v3",
"publisher": "zenstack",
"version": "3.3.0",
"version": "3.3.1",
"displayName": "ZenStack V3 Language Tools",
"description": "VSCode extension for ZenStack (v3) ZModel language",
"private": true,
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.3.0",
"version": "3.3.1",
"license": "MIT",
"author": "ZenStack Team",
"files": [
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.3.0",
"version": "3.3.1",
"description": "ZenStack ORM",
"type": "module",
"scripts": {
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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"description": "ZenStack Runtime Schema",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 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.3.0",
"version": "3.3.1",
"description": "ZenStack SDK",
"type": "module",
"scripts": {
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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"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.3.0",
"version": "3.3.1",
"description": "",
"type": "module",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion samples/orm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-blog",
"version": "3.3.0",
"version": "3.3.1",
"description": "",
"main": "index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "e2e",
"version": "3.3.0",
"version": "3.3.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "regression",
"version": "3.3.0",
"version": "3.3.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tests/runtimes/bun/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bun-e2e",
"version": "3.3.0",
"version": "3.3.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tests/runtimes/edge-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edge-runtime-e2e",
"version": "3.3.0",
"version": "3.3.1",
"private": true,
"type": "module",
"scripts": {
Expand Down