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
8 changes: 4 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
- [ ] CLI
- [x] generate
- [x] migrate
- [ ] db
- [x] db
- [x] push
- [ ] seed
- [x] seed
- [x] info
- [x] init
- [x] validate
- [ ] format
- [x] format
- [ ] repl
- [x] plugin mechanism
- [x] built-in plugins
Expand Down Expand Up @@ -85,7 +85,7 @@
- [x] Error system
- [x] Custom table name
- [x] Custom field name
- [ ] Global omit
- [x] Global omit
- [ ] DbNull vs JsonNull
- [ ] Migrate to tsdown
- [x] @default validation
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "zenstack-v3",
"version": "3.0.0-beta.25",
"version": "3.0.0-beta.26",
"description": "ZenStack",
"packageManager": "pnpm@10.20.0",
"packageManager": "pnpm@10.23.0",
"scripts": {
"build": "turbo run build",
"watch": "turbo run watch build",
Expand All @@ -25,14 +25,14 @@
"eslint": "~9.29.0",
"glob": "^11.0.2",
"prettier": "^3.5.3",
"prisma": "catalog:",
"tsup": "^8.5.0",
"tsx": "^4.20.3",
"turbo": "^2.5.4",
"typescript": "catalog:",
"typescript-eslint": "^8.34.1",
"vitest": "^3.2.4",
"yaml": "^2.8.0",
"prisma": "catalog:"
"yaml": "^2.8.0"
},
"pnpm": {
"onlyBuiltDependencies": [
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.25",
"version": "3.0.0-beta.26",
"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.25",
"version": "3.0.0-beta.26",
"type": "module",
"author": {
"name": "ZenStack Team"
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.25",
"version": "3.0.0-beta.26",
"description": "TanStack Query Client for consuming ZenStack v3's CRUD service",
"main": "index.js",
"type": "module",
Expand Down
58 changes: 33 additions & 25 deletions packages/clients/tanstack-query/src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
AggregateArgs,
AggregateResult,
BatchResult,
ClientOptions,
CountArgs,
CountResult,
CreateArgs,
Expand Down Expand Up @@ -128,11 +129,14 @@ export type ModelMutationModelResult<
Model extends GetModels<Schema>,
TArgs,
Array extends boolean = false,
> = Omit<ModelMutationResult<SimplifiedModelResult<Schema, Model, TArgs, false, Array>, TArgs>, 'mutateAsync'> & {
> = Omit<
ModelMutationResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, TArgs, false, Array>, TArgs>,
'mutateAsync'
> & {
mutateAsync<T extends TArgs>(
args: T,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T, false, Array>, T>,
): Promise<SimplifiedModelResult<Schema, Model, T, false, Array>>;
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T, false, Array>, T>,
): Promise<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T, false, Array>>;
};

export type ClientHooks<Schema extends SchemaDef> = {
Expand All @@ -147,74 +151,78 @@ export type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Sc
{
useFindUnique<T extends FindUniqueArgs<Schema, Model>>(
args: SelectSubset<T, FindUniqueArgs<Schema, Model>>,
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, T> | null>;
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>;

useSuspenseFindUnique<T extends FindUniqueArgs<Schema, Model>>(
args: SelectSubset<T, FindUniqueArgs<Schema, Model>>,
options?: ModelSuspenseQueryOptions<SimplifiedModelResult<Schema, Model, T> | null>,
): ModelSuspenseQueryResult<SimplifiedModelResult<Schema, Model, T> | null>;
options?: ModelSuspenseQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>,
): ModelSuspenseQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>;

useFindFirst<T extends FindFirstArgs<Schema, Model>>(
args?: SelectSubset<T, FindFirstArgs<Schema, Model>>,
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, T> | null>;
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>;

useSuspenseFindFirst<T extends FindFirstArgs<Schema, Model>>(
args?: SelectSubset<T, FindFirstArgs<Schema, Model>>,
options?: ModelSuspenseQueryOptions<SimplifiedModelResult<Schema, Model, T> | null>,
): ModelSuspenseQueryResult<SimplifiedModelResult<Schema, Model, T> | null>;
options?: ModelSuspenseQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>,
): ModelSuspenseQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>;

useFindMany<T extends FindManyArgs<Schema, Model>>(
args?: SelectSubset<T, FindManyArgs<Schema, Model>>,
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, T>[]>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, T>[]>;
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>;

useSuspenseFindMany<T extends FindManyArgs<Schema, Model>>(
args?: SelectSubset<T, FindManyArgs<Schema, Model>>,
options?: ModelSuspenseQueryOptions<SimplifiedModelResult<Schema, Model, T>[]>,
): ModelSuspenseQueryResult<SimplifiedModelResult<Schema, Model, T>[]>;
options?: ModelSuspenseQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>,
): ModelSuspenseQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>;

useInfiniteFindMany<T extends FindManyArgs<Schema, Model>>(
args?: SelectSubset<T, FindManyArgs<Schema, Model>>,
options?: ModelInfiniteQueryOptions<SimplifiedModelResult<Schema, Model, T>[]>,
): ModelInfiniteQueryResult<InfiniteData<SimplifiedModelResult<Schema, Model, T>[]>>;
options?: ModelInfiniteQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>,
): ModelInfiniteQueryResult<InfiniteData<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>>;

useSuspenseInfiniteFindMany<T extends FindManyArgs<Schema, Model>>(
args?: SelectSubset<T, FindManyArgs<Schema, Model>>,
options?: ModelSuspenseInfiniteQueryOptions<SimplifiedModelResult<Schema, Model, T>[]>,
): ModelSuspenseInfiniteQueryResult<InfiniteData<SimplifiedModelResult<Schema, Model, T>[]>>;
options?: ModelSuspenseInfiniteQueryOptions<
SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]
>,
): ModelSuspenseInfiniteQueryResult<
InfiniteData<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>
>;

useCreate<T extends CreateArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useCreateMany<T extends CreateManyArgs<Schema, Model>>(
options?: ModelMutationOptions<BatchResult, T>,
): ModelMutationResult<BatchResult, T>;

useCreateManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>[], T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[], T>,
): ModelMutationModelResult<Schema, Model, T, true>;

useUpdate<T extends UpdateArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useUpdateMany<T extends UpdateManyArgs<Schema, Model>>(
options?: ModelMutationOptions<BatchResult, T>,
): ModelMutationResult<BatchResult, T>;

useUpdateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>[], T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[], T>,
): ModelMutationModelResult<Schema, Model, T, true>;

useUpsert<T extends UpsertArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useDelete<T extends DeleteArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useDeleteMany<T extends DeleteManyArgs<Schema, Model>>(
Expand Down
40 changes: 23 additions & 17 deletions packages/clients/tanstack-query/src/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
AggregateArgs,
AggregateResult,
BatchResult,
ClientOptions,
CountArgs,
CountResult,
CreateArgs,
Expand Down Expand Up @@ -118,13 +119,18 @@ export type ModelMutationModelResult<
Array extends boolean = false,
> = Readable<
Omit<
UnwrapStore<ModelMutationResult<SimplifiedModelResult<Schema, Model, TArgs, false, Array>, TArgs>>,
UnwrapStore<
ModelMutationResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, TArgs, false, Array>, TArgs>
>,
'mutateAsync'
> & {
mutateAsync<T extends TArgs>(
args: T,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T, false, Array>, T>,
): Promise<SimplifiedModelResult<Schema, Model, T, false, Array>>;
options?: ModelMutationOptions<
SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T, false, Array>,
T
>,
): Promise<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T, false, Array>>;
}
>;

Expand All @@ -140,54 +146,54 @@ export type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Sc
{
useFindUnique<T extends FindUniqueArgs<Schema, Model>>(
args: SelectSubset<T, FindUniqueArgs<Schema, Model>>,
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, T> | null>;
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>;

useFindFirst<T extends FindFirstArgs<Schema, Model>>(
args?: SelectSubset<T, FindFirstArgs<Schema, Model>>,
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, T> | null>;
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T> | null>;

useFindMany<T extends FindManyArgs<Schema, Model>>(
args?: SelectSubset<T, FindManyArgs<Schema, Model>>,
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, T>[]>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, T>[]>;
options?: ModelQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>,
): ModelQueryResult<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>;

useInfiniteFindMany<T extends FindManyArgs<Schema, Model>>(
args?: SelectSubset<T, FindManyArgs<Schema, Model>>,
options?: ModelInfiniteQueryOptions<SimplifiedModelResult<Schema, Model, T>[]>,
): ModelInfiniteQueryResult<InfiniteData<SimplifiedModelResult<Schema, Model, T>[]>>;
options?: ModelInfiniteQueryOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>,
): ModelInfiniteQueryResult<InfiniteData<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[]>>;

useCreate<T extends CreateArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useCreateMany<T extends CreateManyArgs<Schema, Model>>(
options?: ModelMutationOptions<BatchResult, T>,
): ModelMutationResult<BatchResult, T>;

useCreateManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>[], T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[], T>,
): ModelMutationModelResult<Schema, Model, T, true>;

useUpdate<T extends UpdateArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useUpdateMany<T extends UpdateManyArgs<Schema, Model>>(
options?: ModelMutationOptions<BatchResult, T>,
): ModelMutationResult<BatchResult, T>;

useUpdateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>[], T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>[], T>,
): ModelMutationModelResult<Schema, Model, T, true>;

useUpsert<T extends UpsertArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useDelete<T extends DeleteArgs<Schema, Model>>(
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, T>, T>,
options?: ModelMutationOptions<SimplifiedModelResult<Schema, Model, ClientOptions<Schema>, T>, T>,
): ModelMutationModelResult<Schema, Model, T>;

useDeleteMany<T extends DeleteManyArgs<Schema, Model>>(
Expand Down
Loading