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
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "zenstack-v3",
"version": "3.0.0-beta.25",
"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
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
38 changes: 21 additions & 17 deletions packages/clients/tanstack-query/src/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
AggregateArgs,
AggregateResult,
BatchResult,
ClientOptions,
CountArgs,
CountResult,
CreateArgs,
Expand Down Expand Up @@ -105,11 +106,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 @@ -124,54 +128,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