@zenstackhq/tanstack-query 3.0.0-beta.17 → 3.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +27 -13
- package/dist/react.cjs +35 -33
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +26 -106
- package/dist/react.d.ts +26 -106
- package/dist/react.js +35 -33
- package/dist/react.js.map +1 -1
- package/dist/svelte.cjs +1224 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +381 -0
- package/dist/svelte.d.ts +381 -0
- package/dist/svelte.js +1183 -0
- package/dist/svelte.js.map +1 -0
- package/dist/types-BRIDXxNC.d.cts +92 -0
- package/dist/types-BRIDXxNC.d.ts +92 -0
- package/dist/vue.cjs +1192 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +382 -0
- package/dist/vue.d.ts +382 -0
- package/dist/vue.js +1152 -0
- package/dist/vue.js.map +1 -0
- package/package.json +43 -11
- package/src/react.ts +168 -155
- package/src/svelte.ts +483 -0
- package/src/utils/common.ts +4 -13
- package/src/utils/types.ts +13 -0
- package/src/vue.ts +429 -0
- package/test/react-typing-test.ts +109 -0
- package/test/schemas/basic/input.ts +40 -0
- package/test/schemas/basic/models.ts +2 -0
- package/test/schemas/basic/schema-lite.ts +48 -0
- package/test/schemas/basic/schema.zmodel +11 -1
- package/test/svelte-typing-test.ts +106 -0
- package/test/vue-typing-test.ts +107 -0
- package/tsup.config.ts +2 -0
package/dist/react.d.cts
CHANGED
|
@@ -1,93 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { UseQueryOptions, DefaultError, UseQueryResult, QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult, UseInfiniteQueryOptions, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult, UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { FindUniqueArgs, SelectSubset,
|
|
4
|
+
import { SelectIncludeOmit, ModelResult, FindUniqueArgs, SelectSubset, FindArgs, CreateArgs, CreateManyArgs, BatchResult, CreateManyAndReturnArgs, UpdateArgs, UpdateManyArgs, UpdateManyAndReturnArgs, UpsertArgs, DeleteArgs, DeleteManyArgs, CountArgs, Subset, CountResult, AggregateArgs, AggregateResult, GroupByArgs, GroupByResult } from '@zenstackhq/orm';
|
|
5
5
|
import { SchemaDef, GetModels } from '@zenstackhq/schema';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Function signature for `fetch`.
|
|
9
|
-
*/
|
|
10
|
-
type FetchFn = (url: string, options?: RequestInit) => Promise<Response>;
|
|
11
|
-
/**
|
|
12
|
-
* Result of optimistic data provider.
|
|
13
|
-
*/
|
|
14
|
-
type OptimisticDataProviderResult = {
|
|
15
|
-
/**
|
|
16
|
-
* Kind of the result.
|
|
17
|
-
* - Update: use the `data` field to update the query cache.
|
|
18
|
-
* - Skip: skip the optimistic update for this query.
|
|
19
|
-
* - ProceedDefault: proceed with the default optimistic update.
|
|
20
|
-
*/
|
|
21
|
-
kind: 'Update' | 'Skip' | 'ProceedDefault';
|
|
22
|
-
/**
|
|
23
|
-
* Data to update the query cache. Only applicable if `kind` is 'Update'.
|
|
24
|
-
*
|
|
25
|
-
* If the data is an object with fields updated, it should have a `$optimistic`
|
|
26
|
-
* field set to `true`. If it's an array and an element object is created or updated,
|
|
27
|
-
* the element should have a `$optimistic` field set to `true`.
|
|
28
|
-
*/
|
|
29
|
-
data?: any;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Optimistic data provider.
|
|
33
|
-
*
|
|
34
|
-
* @param args Arguments.
|
|
35
|
-
* @param args.queryModel The model of the query.
|
|
36
|
-
* @param args.queryOperation The operation of the query, `findMany`, `count`, etc.
|
|
37
|
-
* @param args.queryArgs The arguments of the query.
|
|
38
|
-
* @param args.currentData The current cache data for the query.
|
|
39
|
-
* @param args.mutationArgs The arguments of the mutation.
|
|
40
|
-
*/
|
|
41
|
-
type OptimisticDataProvider = (args: {
|
|
42
|
-
queryModel: string;
|
|
43
|
-
queryOperation: string;
|
|
44
|
-
queryArgs: any;
|
|
45
|
-
currentData: any;
|
|
46
|
-
mutationArgs: any;
|
|
47
|
-
}) => OptimisticDataProviderResult | Promise<OptimisticDataProviderResult>;
|
|
48
|
-
/**
|
|
49
|
-
* Extra mutation options.
|
|
50
|
-
*/
|
|
51
|
-
type ExtraMutationOptions = {
|
|
52
|
-
/**
|
|
53
|
-
* Whether to automatically invalidate queries potentially affected by the mutation. Defaults to `true`.
|
|
54
|
-
*/
|
|
55
|
-
invalidateQueries?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Whether to optimistically update queries potentially affected by the mutation. Defaults to `false`.
|
|
58
|
-
*/
|
|
59
|
-
optimisticUpdate?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* A callback for computing optimistic update data for each query cache entry.
|
|
62
|
-
*/
|
|
63
|
-
optimisticDataProvider?: OptimisticDataProvider;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Extra query options.
|
|
67
|
-
*/
|
|
68
|
-
type ExtraQueryOptions = {
|
|
69
|
-
/**
|
|
70
|
-
* Whether to opt-in to optimistic updates for this query. Defaults to `true`.
|
|
71
|
-
*/
|
|
72
|
-
optimisticUpdate?: boolean;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Context type for configuring the hooks.
|
|
76
|
-
*/
|
|
77
|
-
type APIContext = {
|
|
78
|
-
/**
|
|
79
|
-
* The endpoint to use for the queries.
|
|
80
|
-
*/
|
|
81
|
-
endpoint?: string;
|
|
82
|
-
/**
|
|
83
|
-
* A custom fetch function for sending the HTTP requests.
|
|
84
|
-
*/
|
|
85
|
-
fetch?: FetchFn;
|
|
86
|
-
/**
|
|
87
|
-
* If logging is enabled.
|
|
88
|
-
*/
|
|
89
|
-
logging?: boolean;
|
|
90
|
-
};
|
|
6
|
+
import { A as APIContext, E as ExtraQueryOptions, a as ExtraMutationOptions, T as TrimDelegateModelOperations } from './types-BRIDXxNC.cjs';
|
|
7
|
+
export { F as FetchFn } from './types-BRIDXxNC.cjs';
|
|
91
8
|
|
|
92
9
|
/**
|
|
93
10
|
* The default query endpoint.
|
|
@@ -104,7 +21,7 @@ declare const QuerySettingsProvider: react.Provider<APIContext>;
|
|
|
104
21
|
/**
|
|
105
22
|
* React context provider for configuring query settings.
|
|
106
23
|
*
|
|
107
|
-
* @deprecated Use
|
|
24
|
+
* @deprecated Use {@link QuerySettingsProvider} instead.
|
|
108
25
|
*/
|
|
109
26
|
declare const Provider: react.Provider<APIContext>;
|
|
110
27
|
type ModelQueryOptions<T> = Omit<UseQueryOptions<T, DefaultError>, 'queryKey'> & ExtraQueryOptions;
|
|
@@ -125,10 +42,13 @@ type ModelSuspenseInfiniteQueryResult<T> = UseSuspenseInfiniteQueryResult<T, Def
|
|
|
125
42
|
};
|
|
126
43
|
type ModelMutationOptions<T, TArgs> = Omit<UseMutationOptions<T, DefaultError, TArgs>, 'mutationFn'> & ExtraMutationOptions;
|
|
127
44
|
type ModelMutationResult<T, TArgs> = UseMutationResult<T, DefaultError, TArgs>;
|
|
128
|
-
type
|
|
45
|
+
type ModelMutationModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, TArgs extends SelectIncludeOmit<Schema, Model, boolean>, Array extends boolean = false> = Omit<ModelMutationResult<ModelResult<Schema, Model, TArgs>, TArgs>, 'mutateAsync'> & {
|
|
46
|
+
mutateAsync<T extends TArgs>(args: T, options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): Promise<Array extends true ? ModelResult<Schema, Model, T>[] : ModelResult<Schema, Model, T>>;
|
|
47
|
+
};
|
|
48
|
+
type ClientHooks<Schema extends SchemaDef> = {
|
|
129
49
|
[Model in GetModels<Schema> as `${Uncapitalize<Model>}`]: ModelQueryHooks<Schema, Model>;
|
|
130
50
|
};
|
|
131
|
-
type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
51
|
+
type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Schema>> = TrimDelegateModelOperations<Schema, Model, {
|
|
132
52
|
useFindUnique<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>, options?: ModelQueryOptions<ModelResult<Schema, Model, T> | null>): ModelQueryResult<ModelResult<Schema, Model, T> | null>;
|
|
133
53
|
useSuspenseFindUnique<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<ModelResult<Schema, Model, T> | null>): ModelSuspenseQueryResult<ModelResult<Schema, Model, T> | null>;
|
|
134
54
|
useFindFirst<T extends FindArgs<Schema, Model, false>>(args?: SelectSubset<T, FindArgs<Schema, Model, false>>, options?: ModelQueryOptions<ModelResult<Schema, Model, T> | null>): ModelQueryResult<ModelResult<Schema, Model, T> | null>;
|
|
@@ -137,26 +57,26 @@ type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Schema>>
|
|
|
137
57
|
useSuspenseFindMany<T extends FindArgs<Schema, Model, true>>(args?: SelectSubset<T, FindArgs<Schema, Model, true>>, options?: ModelSuspenseQueryOptions<ModelResult<Schema, Model, T>[]>): ModelSuspenseQueryResult<ModelResult<Schema, Model, T>[]>;
|
|
138
58
|
useInfiniteFindMany<T extends FindArgs<Schema, Model, true>>(args?: SelectSubset<T, FindArgs<Schema, Model, true>>, options?: ModelInfiniteQueryOptions<ModelResult<Schema, Model, T>[]>): ModelInfiniteQueryResult<InfiniteData<ModelResult<Schema, Model, T>[]>>;
|
|
139
59
|
useSuspenseInfiniteFindMany<T extends FindArgs<Schema, Model, true>>(args?: SelectSubset<T, FindArgs<Schema, Model, true>>, options?: ModelSuspenseInfiniteQueryOptions<ModelResult<Schema, Model, T>[]>): ModelSuspenseInfiniteQueryResult<InfiniteData<ModelResult<Schema, Model, T>[]>>;
|
|
140
|
-
useCreate<T extends CreateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
60
|
+
useCreate<T extends CreateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
141
61
|
useCreateMany<T extends CreateManyArgs<Schema, Model>>(options?: ModelMutationOptions<BatchResult, T>): ModelMutationResult<BatchResult, T>;
|
|
142
|
-
useCreateManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>):
|
|
143
|
-
useUpdate<T extends UpdateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
62
|
+
useCreateManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>): ModelMutationModelResult<Schema, Model, T, true>;
|
|
63
|
+
useUpdate<T extends UpdateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
144
64
|
useUpdateMany<T extends UpdateManyArgs<Schema, Model>>(options?: ModelMutationOptions<BatchResult, T>): ModelMutationResult<BatchResult, T>;
|
|
145
|
-
useUpdateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>):
|
|
146
|
-
useUpsert<T extends UpsertArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
147
|
-
useDelete<T extends DeleteArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
65
|
+
useUpdateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>): ModelMutationModelResult<Schema, Model, T, true>;
|
|
66
|
+
useUpsert<T extends UpsertArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
67
|
+
useDelete<T extends DeleteArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
148
68
|
useDeleteMany<T extends DeleteManyArgs<Schema, Model>>(options?: ModelMutationOptions<BatchResult, T>): ModelMutationResult<BatchResult, T>;
|
|
149
|
-
useCount<T extends CountArgs<Schema, Model>>(options?: ModelQueryOptions<CountResult<Schema, Model, T>>): ModelQueryResult<CountResult<Schema, Model, T>>;
|
|
150
|
-
useSuspenseCount<T extends CountArgs<Schema, Model>>(options?: ModelSuspenseQueryOptions<CountResult<Schema, Model, T>>): ModelSuspenseQueryResult<CountResult<Schema, Model, T>>;
|
|
151
|
-
useAggregate<T extends AggregateArgs<Schema, Model>>(options?: ModelQueryOptions<AggregateResult<Schema, Model, T>>): ModelQueryResult<AggregateResult<Schema, Model, T>>;
|
|
152
|
-
useSuspenseAggregate<T extends AggregateArgs<Schema, Model>>(options?: ModelSuspenseQueryOptions<AggregateResult<Schema, Model, T>>): ModelSuspenseQueryResult<AggregateResult<Schema, Model, T>>;
|
|
153
|
-
useGroupBy<T extends GroupByArgs<Schema, Model>>(options?: ModelQueryOptions<GroupByResult<Schema, Model, T>>): ModelQueryResult<GroupByResult<Schema, Model, T>>;
|
|
154
|
-
useSuspenseGroupBy<T extends GroupByArgs<Schema, Model>>(options?: ModelSuspenseQueryOptions<GroupByResult<Schema, Model, T>>): ModelSuspenseQueryResult<GroupByResult<Schema, Model, T>>;
|
|
155
|
-
}
|
|
69
|
+
useCount<T extends CountArgs<Schema, Model>>(args?: Subset<T, CountArgs<Schema, Model>>, options?: ModelQueryOptions<CountResult<Schema, Model, T>>): ModelQueryResult<CountResult<Schema, Model, T>>;
|
|
70
|
+
useSuspenseCount<T extends CountArgs<Schema, Model>>(args?: Subset<T, CountArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<CountResult<Schema, Model, T>>): ModelSuspenseQueryResult<CountResult<Schema, Model, T>>;
|
|
71
|
+
useAggregate<T extends AggregateArgs<Schema, Model>>(args: Subset<T, AggregateArgs<Schema, Model>>, options?: ModelQueryOptions<AggregateResult<Schema, Model, T>>): ModelQueryResult<AggregateResult<Schema, Model, T>>;
|
|
72
|
+
useSuspenseAggregate<T extends AggregateArgs<Schema, Model>>(args: Subset<T, AggregateArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<AggregateResult<Schema, Model, T>>): ModelSuspenseQueryResult<AggregateResult<Schema, Model, T>>;
|
|
73
|
+
useGroupBy<T extends GroupByArgs<Schema, Model>>(args: Subset<T, GroupByArgs<Schema, Model>>, options?: ModelQueryOptions<GroupByResult<Schema, Model, T>>): ModelQueryResult<GroupByResult<Schema, Model, T>>;
|
|
74
|
+
useSuspenseGroupBy<T extends GroupByArgs<Schema, Model>>(args: Subset<T, GroupByArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<GroupByResult<Schema, Model, T>>): ModelSuspenseQueryResult<GroupByResult<Schema, Model, T>>;
|
|
75
|
+
}>;
|
|
156
76
|
/**
|
|
157
77
|
* Gets data query hooks for all models in the schema.
|
|
158
78
|
*/
|
|
159
|
-
declare function useClientQueries<Schema extends SchemaDef>(schema: Schema):
|
|
79
|
+
declare function useClientQueries<Schema extends SchemaDef>(schema: Schema): ClientHooks<Schema>;
|
|
160
80
|
/**
|
|
161
81
|
* Gets data query hooks for a specific model in the schema.
|
|
162
82
|
*/
|
|
@@ -407,7 +327,7 @@ declare function useInternalSuspenseQuery<TQueryFnData, TData>(_schema: SchemaDe
|
|
|
407
327
|
optimisticUpdate: boolean;
|
|
408
328
|
}];
|
|
409
329
|
};
|
|
410
|
-
declare function useInternalInfiniteQuery<TQueryFnData, TData>(_schema: SchemaDef, model: string, operation: string, args: unknown, options: Omit<UseInfiniteQueryOptions<TQueryFnData, DefaultError, InfiniteData<TData>>, 'queryKey' | 'initialPageParam'>): {
|
|
330
|
+
declare function useInternalInfiniteQuery<TQueryFnData, TData>(_schema: SchemaDef, model: string, operation: string, args: unknown, options: Omit<UseInfiniteQueryOptions<TQueryFnData, DefaultError, InfiniteData<TData>>, 'queryKey' | 'initialPageParam'> | undefined): {
|
|
411
331
|
data: InfiniteData<TData, unknown>;
|
|
412
332
|
error: Error;
|
|
413
333
|
isError: true;
|
|
@@ -691,6 +611,6 @@ declare function useInternalSuspenseInfiniteQuery<TQueryFnData, TData>(_schema:
|
|
|
691
611
|
* @param options The react-query options.
|
|
692
612
|
* @param checkReadBack Whether to check for read back errors and return undefined if found.
|
|
693
613
|
*/
|
|
694
|
-
declare function useInternalMutation<TArgs, R = any
|
|
614
|
+
declare function useInternalMutation<TArgs, R = any>(schema: SchemaDef, model: string, method: 'POST' | 'PUT' | 'DELETE', operation: string, options?: Omit<UseMutationOptions<R, DefaultError, TArgs>, 'mutationFn'> & ExtraMutationOptions): UseMutationResult<R, Error, TArgs, unknown>;
|
|
695
615
|
|
|
696
|
-
export { DEFAULT_QUERY_ENDPOINT, type
|
|
616
|
+
export { type ClientHooks, DEFAULT_QUERY_ENDPOINT, type ModelInfiniteQueryOptions, type ModelInfiniteQueryResult, type ModelMutationModelResult, type ModelMutationOptions, type ModelMutationResult, type ModelQueryHooks, type ModelQueryOptions, type ModelQueryResult, type ModelSuspenseInfiniteQueryOptions, type ModelSuspenseInfiniteQueryResult, type ModelSuspenseQueryOptions, type ModelSuspenseQueryResult, Provider, QuerySettingsContext, QuerySettingsProvider, useClientQueries, useInternalInfiniteQuery, useInternalMutation, useInternalQuery, useInternalSuspenseInfiniteQuery, useInternalSuspenseQuery, useModelQueries };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,93 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { UseQueryOptions, DefaultError, UseQueryResult, QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult, UseInfiniteQueryOptions, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult, UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { FindUniqueArgs, SelectSubset,
|
|
4
|
+
import { SelectIncludeOmit, ModelResult, FindUniqueArgs, SelectSubset, FindArgs, CreateArgs, CreateManyArgs, BatchResult, CreateManyAndReturnArgs, UpdateArgs, UpdateManyArgs, UpdateManyAndReturnArgs, UpsertArgs, DeleteArgs, DeleteManyArgs, CountArgs, Subset, CountResult, AggregateArgs, AggregateResult, GroupByArgs, GroupByResult } from '@zenstackhq/orm';
|
|
5
5
|
import { SchemaDef, GetModels } from '@zenstackhq/schema';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Function signature for `fetch`.
|
|
9
|
-
*/
|
|
10
|
-
type FetchFn = (url: string, options?: RequestInit) => Promise<Response>;
|
|
11
|
-
/**
|
|
12
|
-
* Result of optimistic data provider.
|
|
13
|
-
*/
|
|
14
|
-
type OptimisticDataProviderResult = {
|
|
15
|
-
/**
|
|
16
|
-
* Kind of the result.
|
|
17
|
-
* - Update: use the `data` field to update the query cache.
|
|
18
|
-
* - Skip: skip the optimistic update for this query.
|
|
19
|
-
* - ProceedDefault: proceed with the default optimistic update.
|
|
20
|
-
*/
|
|
21
|
-
kind: 'Update' | 'Skip' | 'ProceedDefault';
|
|
22
|
-
/**
|
|
23
|
-
* Data to update the query cache. Only applicable if `kind` is 'Update'.
|
|
24
|
-
*
|
|
25
|
-
* If the data is an object with fields updated, it should have a `$optimistic`
|
|
26
|
-
* field set to `true`. If it's an array and an element object is created or updated,
|
|
27
|
-
* the element should have a `$optimistic` field set to `true`.
|
|
28
|
-
*/
|
|
29
|
-
data?: any;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Optimistic data provider.
|
|
33
|
-
*
|
|
34
|
-
* @param args Arguments.
|
|
35
|
-
* @param args.queryModel The model of the query.
|
|
36
|
-
* @param args.queryOperation The operation of the query, `findMany`, `count`, etc.
|
|
37
|
-
* @param args.queryArgs The arguments of the query.
|
|
38
|
-
* @param args.currentData The current cache data for the query.
|
|
39
|
-
* @param args.mutationArgs The arguments of the mutation.
|
|
40
|
-
*/
|
|
41
|
-
type OptimisticDataProvider = (args: {
|
|
42
|
-
queryModel: string;
|
|
43
|
-
queryOperation: string;
|
|
44
|
-
queryArgs: any;
|
|
45
|
-
currentData: any;
|
|
46
|
-
mutationArgs: any;
|
|
47
|
-
}) => OptimisticDataProviderResult | Promise<OptimisticDataProviderResult>;
|
|
48
|
-
/**
|
|
49
|
-
* Extra mutation options.
|
|
50
|
-
*/
|
|
51
|
-
type ExtraMutationOptions = {
|
|
52
|
-
/**
|
|
53
|
-
* Whether to automatically invalidate queries potentially affected by the mutation. Defaults to `true`.
|
|
54
|
-
*/
|
|
55
|
-
invalidateQueries?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Whether to optimistically update queries potentially affected by the mutation. Defaults to `false`.
|
|
58
|
-
*/
|
|
59
|
-
optimisticUpdate?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* A callback for computing optimistic update data for each query cache entry.
|
|
62
|
-
*/
|
|
63
|
-
optimisticDataProvider?: OptimisticDataProvider;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Extra query options.
|
|
67
|
-
*/
|
|
68
|
-
type ExtraQueryOptions = {
|
|
69
|
-
/**
|
|
70
|
-
* Whether to opt-in to optimistic updates for this query. Defaults to `true`.
|
|
71
|
-
*/
|
|
72
|
-
optimisticUpdate?: boolean;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Context type for configuring the hooks.
|
|
76
|
-
*/
|
|
77
|
-
type APIContext = {
|
|
78
|
-
/**
|
|
79
|
-
* The endpoint to use for the queries.
|
|
80
|
-
*/
|
|
81
|
-
endpoint?: string;
|
|
82
|
-
/**
|
|
83
|
-
* A custom fetch function for sending the HTTP requests.
|
|
84
|
-
*/
|
|
85
|
-
fetch?: FetchFn;
|
|
86
|
-
/**
|
|
87
|
-
* If logging is enabled.
|
|
88
|
-
*/
|
|
89
|
-
logging?: boolean;
|
|
90
|
-
};
|
|
6
|
+
import { A as APIContext, E as ExtraQueryOptions, a as ExtraMutationOptions, T as TrimDelegateModelOperations } from './types-BRIDXxNC.js';
|
|
7
|
+
export { F as FetchFn } from './types-BRIDXxNC.js';
|
|
91
8
|
|
|
92
9
|
/**
|
|
93
10
|
* The default query endpoint.
|
|
@@ -104,7 +21,7 @@ declare const QuerySettingsProvider: react.Provider<APIContext>;
|
|
|
104
21
|
/**
|
|
105
22
|
* React context provider for configuring query settings.
|
|
106
23
|
*
|
|
107
|
-
* @deprecated Use
|
|
24
|
+
* @deprecated Use {@link QuerySettingsProvider} instead.
|
|
108
25
|
*/
|
|
109
26
|
declare const Provider: react.Provider<APIContext>;
|
|
110
27
|
type ModelQueryOptions<T> = Omit<UseQueryOptions<T, DefaultError>, 'queryKey'> & ExtraQueryOptions;
|
|
@@ -125,10 +42,13 @@ type ModelSuspenseInfiniteQueryResult<T> = UseSuspenseInfiniteQueryResult<T, Def
|
|
|
125
42
|
};
|
|
126
43
|
type ModelMutationOptions<T, TArgs> = Omit<UseMutationOptions<T, DefaultError, TArgs>, 'mutationFn'> & ExtraMutationOptions;
|
|
127
44
|
type ModelMutationResult<T, TArgs> = UseMutationResult<T, DefaultError, TArgs>;
|
|
128
|
-
type
|
|
45
|
+
type ModelMutationModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, TArgs extends SelectIncludeOmit<Schema, Model, boolean>, Array extends boolean = false> = Omit<ModelMutationResult<ModelResult<Schema, Model, TArgs>, TArgs>, 'mutateAsync'> & {
|
|
46
|
+
mutateAsync<T extends TArgs>(args: T, options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): Promise<Array extends true ? ModelResult<Schema, Model, T>[] : ModelResult<Schema, Model, T>>;
|
|
47
|
+
};
|
|
48
|
+
type ClientHooks<Schema extends SchemaDef> = {
|
|
129
49
|
[Model in GetModels<Schema> as `${Uncapitalize<Model>}`]: ModelQueryHooks<Schema, Model>;
|
|
130
50
|
};
|
|
131
|
-
type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
51
|
+
type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Schema>> = TrimDelegateModelOperations<Schema, Model, {
|
|
132
52
|
useFindUnique<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>, options?: ModelQueryOptions<ModelResult<Schema, Model, T> | null>): ModelQueryResult<ModelResult<Schema, Model, T> | null>;
|
|
133
53
|
useSuspenseFindUnique<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<ModelResult<Schema, Model, T> | null>): ModelSuspenseQueryResult<ModelResult<Schema, Model, T> | null>;
|
|
134
54
|
useFindFirst<T extends FindArgs<Schema, Model, false>>(args?: SelectSubset<T, FindArgs<Schema, Model, false>>, options?: ModelQueryOptions<ModelResult<Schema, Model, T> | null>): ModelQueryResult<ModelResult<Schema, Model, T> | null>;
|
|
@@ -137,26 +57,26 @@ type ModelQueryHooks<Schema extends SchemaDef, Model extends GetModels<Schema>>
|
|
|
137
57
|
useSuspenseFindMany<T extends FindArgs<Schema, Model, true>>(args?: SelectSubset<T, FindArgs<Schema, Model, true>>, options?: ModelSuspenseQueryOptions<ModelResult<Schema, Model, T>[]>): ModelSuspenseQueryResult<ModelResult<Schema, Model, T>[]>;
|
|
138
58
|
useInfiniteFindMany<T extends FindArgs<Schema, Model, true>>(args?: SelectSubset<T, FindArgs<Schema, Model, true>>, options?: ModelInfiniteQueryOptions<ModelResult<Schema, Model, T>[]>): ModelInfiniteQueryResult<InfiniteData<ModelResult<Schema, Model, T>[]>>;
|
|
139
59
|
useSuspenseInfiniteFindMany<T extends FindArgs<Schema, Model, true>>(args?: SelectSubset<T, FindArgs<Schema, Model, true>>, options?: ModelSuspenseInfiniteQueryOptions<ModelResult<Schema, Model, T>[]>): ModelSuspenseInfiniteQueryResult<InfiniteData<ModelResult<Schema, Model, T>[]>>;
|
|
140
|
-
useCreate<T extends CreateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
60
|
+
useCreate<T extends CreateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
141
61
|
useCreateMany<T extends CreateManyArgs<Schema, Model>>(options?: ModelMutationOptions<BatchResult, T>): ModelMutationResult<BatchResult, T>;
|
|
142
|
-
useCreateManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>):
|
|
143
|
-
useUpdate<T extends UpdateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
62
|
+
useCreateManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>): ModelMutationModelResult<Schema, Model, T, true>;
|
|
63
|
+
useUpdate<T extends UpdateArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
144
64
|
useUpdateMany<T extends UpdateManyArgs<Schema, Model>>(options?: ModelMutationOptions<BatchResult, T>): ModelMutationResult<BatchResult, T>;
|
|
145
|
-
useUpdateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>):
|
|
146
|
-
useUpsert<T extends UpsertArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
147
|
-
useDelete<T extends DeleteArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>):
|
|
65
|
+
useUpdateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>[], T>): ModelMutationModelResult<Schema, Model, T, true>;
|
|
66
|
+
useUpsert<T extends UpsertArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
67
|
+
useDelete<T extends DeleteArgs<Schema, Model>>(options?: ModelMutationOptions<ModelResult<Schema, Model, T>, T>): ModelMutationModelResult<Schema, Model, T>;
|
|
148
68
|
useDeleteMany<T extends DeleteManyArgs<Schema, Model>>(options?: ModelMutationOptions<BatchResult, T>): ModelMutationResult<BatchResult, T>;
|
|
149
|
-
useCount<T extends CountArgs<Schema, Model>>(options?: ModelQueryOptions<CountResult<Schema, Model, T>>): ModelQueryResult<CountResult<Schema, Model, T>>;
|
|
150
|
-
useSuspenseCount<T extends CountArgs<Schema, Model>>(options?: ModelSuspenseQueryOptions<CountResult<Schema, Model, T>>): ModelSuspenseQueryResult<CountResult<Schema, Model, T>>;
|
|
151
|
-
useAggregate<T extends AggregateArgs<Schema, Model>>(options?: ModelQueryOptions<AggregateResult<Schema, Model, T>>): ModelQueryResult<AggregateResult<Schema, Model, T>>;
|
|
152
|
-
useSuspenseAggregate<T extends AggregateArgs<Schema, Model>>(options?: ModelSuspenseQueryOptions<AggregateResult<Schema, Model, T>>): ModelSuspenseQueryResult<AggregateResult<Schema, Model, T>>;
|
|
153
|
-
useGroupBy<T extends GroupByArgs<Schema, Model>>(options?: ModelQueryOptions<GroupByResult<Schema, Model, T>>): ModelQueryResult<GroupByResult<Schema, Model, T>>;
|
|
154
|
-
useSuspenseGroupBy<T extends GroupByArgs<Schema, Model>>(options?: ModelSuspenseQueryOptions<GroupByResult<Schema, Model, T>>): ModelSuspenseQueryResult<GroupByResult<Schema, Model, T>>;
|
|
155
|
-
}
|
|
69
|
+
useCount<T extends CountArgs<Schema, Model>>(args?: Subset<T, CountArgs<Schema, Model>>, options?: ModelQueryOptions<CountResult<Schema, Model, T>>): ModelQueryResult<CountResult<Schema, Model, T>>;
|
|
70
|
+
useSuspenseCount<T extends CountArgs<Schema, Model>>(args?: Subset<T, CountArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<CountResult<Schema, Model, T>>): ModelSuspenseQueryResult<CountResult<Schema, Model, T>>;
|
|
71
|
+
useAggregate<T extends AggregateArgs<Schema, Model>>(args: Subset<T, AggregateArgs<Schema, Model>>, options?: ModelQueryOptions<AggregateResult<Schema, Model, T>>): ModelQueryResult<AggregateResult<Schema, Model, T>>;
|
|
72
|
+
useSuspenseAggregate<T extends AggregateArgs<Schema, Model>>(args: Subset<T, AggregateArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<AggregateResult<Schema, Model, T>>): ModelSuspenseQueryResult<AggregateResult<Schema, Model, T>>;
|
|
73
|
+
useGroupBy<T extends GroupByArgs<Schema, Model>>(args: Subset<T, GroupByArgs<Schema, Model>>, options?: ModelQueryOptions<GroupByResult<Schema, Model, T>>): ModelQueryResult<GroupByResult<Schema, Model, T>>;
|
|
74
|
+
useSuspenseGroupBy<T extends GroupByArgs<Schema, Model>>(args: Subset<T, GroupByArgs<Schema, Model>>, options?: ModelSuspenseQueryOptions<GroupByResult<Schema, Model, T>>): ModelSuspenseQueryResult<GroupByResult<Schema, Model, T>>;
|
|
75
|
+
}>;
|
|
156
76
|
/**
|
|
157
77
|
* Gets data query hooks for all models in the schema.
|
|
158
78
|
*/
|
|
159
|
-
declare function useClientQueries<Schema extends SchemaDef>(schema: Schema):
|
|
79
|
+
declare function useClientQueries<Schema extends SchemaDef>(schema: Schema): ClientHooks<Schema>;
|
|
160
80
|
/**
|
|
161
81
|
* Gets data query hooks for a specific model in the schema.
|
|
162
82
|
*/
|
|
@@ -407,7 +327,7 @@ declare function useInternalSuspenseQuery<TQueryFnData, TData>(_schema: SchemaDe
|
|
|
407
327
|
optimisticUpdate: boolean;
|
|
408
328
|
}];
|
|
409
329
|
};
|
|
410
|
-
declare function useInternalInfiniteQuery<TQueryFnData, TData>(_schema: SchemaDef, model: string, operation: string, args: unknown, options: Omit<UseInfiniteQueryOptions<TQueryFnData, DefaultError, InfiniteData<TData>>, 'queryKey' | 'initialPageParam'>): {
|
|
330
|
+
declare function useInternalInfiniteQuery<TQueryFnData, TData>(_schema: SchemaDef, model: string, operation: string, args: unknown, options: Omit<UseInfiniteQueryOptions<TQueryFnData, DefaultError, InfiniteData<TData>>, 'queryKey' | 'initialPageParam'> | undefined): {
|
|
411
331
|
data: InfiniteData<TData, unknown>;
|
|
412
332
|
error: Error;
|
|
413
333
|
isError: true;
|
|
@@ -691,6 +611,6 @@ declare function useInternalSuspenseInfiniteQuery<TQueryFnData, TData>(_schema:
|
|
|
691
611
|
* @param options The react-query options.
|
|
692
612
|
* @param checkReadBack Whether to check for read back errors and return undefined if found.
|
|
693
613
|
*/
|
|
694
|
-
declare function useInternalMutation<TArgs, R = any
|
|
614
|
+
declare function useInternalMutation<TArgs, R = any>(schema: SchemaDef, model: string, method: 'POST' | 'PUT' | 'DELETE', operation: string, options?: Omit<UseMutationOptions<R, DefaultError, TArgs>, 'mutationFn'> & ExtraMutationOptions): UseMutationResult<R, Error, TArgs, unknown>;
|
|
695
615
|
|
|
696
|
-
export { DEFAULT_QUERY_ENDPOINT, type
|
|
616
|
+
export { type ClientHooks, DEFAULT_QUERY_ENDPOINT, type ModelInfiniteQueryOptions, type ModelInfiniteQueryResult, type ModelMutationModelResult, type ModelMutationOptions, type ModelMutationResult, type ModelQueryHooks, type ModelQueryOptions, type ModelQueryResult, type ModelSuspenseInfiniteQueryOptions, type ModelSuspenseInfiniteQueryResult, type ModelSuspenseQueryOptions, type ModelSuspenseQueryResult, Provider, QuerySettingsContext, QuerySettingsProvider, useClientQueries, useInternalInfiniteQuery, useInternalMutation, useInternalQuery, useInternalSuspenseInfiniteQuery, useInternalSuspenseQuery, useModelQueries };
|
package/dist/react.js
CHANGED
|
@@ -753,12 +753,12 @@ __name(deserialize, "deserialize");
|
|
|
753
753
|
|
|
754
754
|
// src/utils/common.ts
|
|
755
755
|
var QUERY_KEY_PREFIX = "zenstack";
|
|
756
|
-
async function fetcher(url, options, customFetch
|
|
756
|
+
async function fetcher(url, options, customFetch) {
|
|
757
757
|
const _fetch = customFetch ?? fetch;
|
|
758
758
|
const res = await _fetch(url, options);
|
|
759
759
|
if (!res.ok) {
|
|
760
760
|
const errData = unmarshal(await res.text());
|
|
761
|
-
if (
|
|
761
|
+
if (errData.error?.rejectedByPolicy && errData.error?.rejectReason === "cannot-read-back") {
|
|
762
762
|
return void 0;
|
|
763
763
|
}
|
|
764
764
|
const error = new Error("An error occurred while fetching the data.");
|
|
@@ -820,8 +820,8 @@ function unmarshal(value) {
|
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
822
|
__name(unmarshal, "unmarshal");
|
|
823
|
-
function makeUrl(
|
|
824
|
-
const baseUrl = `${
|
|
823
|
+
function makeUrl(endpoint, model, operation, args) {
|
|
824
|
+
const baseUrl = `${endpoint}/${lowerCaseFirst(model)}/${operation}`;
|
|
825
825
|
if (!args) {
|
|
826
826
|
return baseUrl;
|
|
827
827
|
}
|
|
@@ -1006,49 +1006,49 @@ function useModelQueries(schema, model) {
|
|
|
1006
1006
|
return useInternalSuspenseInfiniteQuery(schema, modelName, "findMany", args, options);
|
|
1007
1007
|
}, "useSuspenseInfiniteFindMany"),
|
|
1008
1008
|
useCreate: /* @__PURE__ */ __name((options) => {
|
|
1009
|
-
return useInternalMutation(schema, modelName, "POST", "create", options
|
|
1009
|
+
return useInternalMutation(schema, modelName, "POST", "create", options);
|
|
1010
1010
|
}, "useCreate"),
|
|
1011
1011
|
useCreateMany: /* @__PURE__ */ __name((options) => {
|
|
1012
|
-
return useInternalMutation(schema, modelName, "POST", "createMany", options
|
|
1012
|
+
return useInternalMutation(schema, modelName, "POST", "createMany", options);
|
|
1013
1013
|
}, "useCreateMany"),
|
|
1014
1014
|
useCreateManyAndReturn: /* @__PURE__ */ __name((options) => {
|
|
1015
|
-
return useInternalMutation(schema, modelName, "POST", "createManyAndReturn", options
|
|
1015
|
+
return useInternalMutation(schema, modelName, "POST", "createManyAndReturn", options);
|
|
1016
1016
|
}, "useCreateManyAndReturn"),
|
|
1017
1017
|
useUpdate: /* @__PURE__ */ __name((options) => {
|
|
1018
|
-
return useInternalMutation(schema, modelName, "PUT", "update", options
|
|
1018
|
+
return useInternalMutation(schema, modelName, "PUT", "update", options);
|
|
1019
1019
|
}, "useUpdate"),
|
|
1020
1020
|
useUpdateMany: /* @__PURE__ */ __name((options) => {
|
|
1021
|
-
return useInternalMutation(schema, modelName, "PUT", "updateMany", options
|
|
1021
|
+
return useInternalMutation(schema, modelName, "PUT", "updateMany", options);
|
|
1022
1022
|
}, "useUpdateMany"),
|
|
1023
1023
|
useUpdateManyAndReturn: /* @__PURE__ */ __name((options) => {
|
|
1024
|
-
return useInternalMutation(schema, modelName, "PUT", "updateManyAndReturn", options
|
|
1024
|
+
return useInternalMutation(schema, modelName, "PUT", "updateManyAndReturn", options);
|
|
1025
1025
|
}, "useUpdateManyAndReturn"),
|
|
1026
1026
|
useUpsert: /* @__PURE__ */ __name((options) => {
|
|
1027
|
-
return useInternalMutation(schema, modelName, "POST", "upsert", options
|
|
1027
|
+
return useInternalMutation(schema, modelName, "POST", "upsert", options);
|
|
1028
1028
|
}, "useUpsert"),
|
|
1029
1029
|
useDelete: /* @__PURE__ */ __name((options) => {
|
|
1030
|
-
return useInternalMutation(schema, modelName, "DELETE", "delete", options
|
|
1030
|
+
return useInternalMutation(schema, modelName, "DELETE", "delete", options);
|
|
1031
1031
|
}, "useDelete"),
|
|
1032
1032
|
useDeleteMany: /* @__PURE__ */ __name((options) => {
|
|
1033
|
-
return useInternalMutation(schema, modelName, "DELETE", "deleteMany", options
|
|
1033
|
+
return useInternalMutation(schema, modelName, "DELETE", "deleteMany", options);
|
|
1034
1034
|
}, "useDeleteMany"),
|
|
1035
|
-
useCount: /* @__PURE__ */ __name((options) => {
|
|
1036
|
-
return useInternalQuery(schema, modelName, "count",
|
|
1035
|
+
useCount: /* @__PURE__ */ __name((args, options) => {
|
|
1036
|
+
return useInternalQuery(schema, modelName, "count", args, options);
|
|
1037
1037
|
}, "useCount"),
|
|
1038
|
-
useSuspenseCount: /* @__PURE__ */ __name((options) => {
|
|
1039
|
-
return useInternalSuspenseQuery(schema, modelName, "count",
|
|
1038
|
+
useSuspenseCount: /* @__PURE__ */ __name((args, options) => {
|
|
1039
|
+
return useInternalSuspenseQuery(schema, modelName, "count", args, options);
|
|
1040
1040
|
}, "useSuspenseCount"),
|
|
1041
|
-
useAggregate: /* @__PURE__ */ __name((options) => {
|
|
1042
|
-
return useInternalQuery(schema, modelName, "aggregate",
|
|
1041
|
+
useAggregate: /* @__PURE__ */ __name((args, options) => {
|
|
1042
|
+
return useInternalQuery(schema, modelName, "aggregate", args, options);
|
|
1043
1043
|
}, "useAggregate"),
|
|
1044
|
-
useSuspenseAggregate: /* @__PURE__ */ __name((options) => {
|
|
1045
|
-
return useInternalSuspenseQuery(schema, modelName, "aggregate",
|
|
1044
|
+
useSuspenseAggregate: /* @__PURE__ */ __name((args, options) => {
|
|
1045
|
+
return useInternalSuspenseQuery(schema, modelName, "aggregate", args, options);
|
|
1046
1046
|
}, "useSuspenseAggregate"),
|
|
1047
|
-
useGroupBy: /* @__PURE__ */ __name((options) => {
|
|
1048
|
-
return useInternalQuery(schema, modelName, "groupBy",
|
|
1047
|
+
useGroupBy: /* @__PURE__ */ __name((args, options) => {
|
|
1048
|
+
return useInternalQuery(schema, modelName, "groupBy", args, options);
|
|
1049
1049
|
}, "useGroupBy"),
|
|
1050
|
-
useSuspenseGroupBy: /* @__PURE__ */ __name((options) => {
|
|
1051
|
-
return useInternalSuspenseQuery(schema, modelName, "groupBy",
|
|
1050
|
+
useSuspenseGroupBy: /* @__PURE__ */ __name((args, options) => {
|
|
1051
|
+
return useInternalSuspenseQuery(schema, modelName, "groupBy", args, options);
|
|
1052
1052
|
}, "useSuspenseGroupBy")
|
|
1053
1053
|
};
|
|
1054
1054
|
}
|
|
@@ -1066,7 +1066,7 @@ function useInternalQuery(_schema, model, operation, args, options) {
|
|
|
1066
1066
|
queryKey,
|
|
1067
1067
|
queryFn: /* @__PURE__ */ __name(({ signal }) => fetcher(reqUrl, {
|
|
1068
1068
|
signal
|
|
1069
|
-
}, fetch2
|
|
1069
|
+
}, fetch2), "queryFn"),
|
|
1070
1070
|
...options
|
|
1071
1071
|
})
|
|
1072
1072
|
};
|
|
@@ -1085,13 +1085,16 @@ function useInternalSuspenseQuery(_schema, model, operation, args, options) {
|
|
|
1085
1085
|
queryKey,
|
|
1086
1086
|
queryFn: /* @__PURE__ */ __name(({ signal }) => fetcher(reqUrl, {
|
|
1087
1087
|
signal
|
|
1088
|
-
}, fetch2
|
|
1088
|
+
}, fetch2), "queryFn"),
|
|
1089
1089
|
...options
|
|
1090
1090
|
})
|
|
1091
1091
|
};
|
|
1092
1092
|
}
|
|
1093
1093
|
__name(useInternalSuspenseQuery, "useInternalSuspenseQuery");
|
|
1094
1094
|
function useInternalInfiniteQuery(_schema, model, operation, args, options) {
|
|
1095
|
+
options = options ?? {
|
|
1096
|
+
getNextPageParam: /* @__PURE__ */ __name(() => void 0, "getNextPageParam")
|
|
1097
|
+
};
|
|
1095
1098
|
const { endpoint, fetch: fetch2 } = useHooksContext();
|
|
1096
1099
|
const queryKey = getQueryKey(model, operation, args, {
|
|
1097
1100
|
infinite: true,
|
|
@@ -1104,7 +1107,7 @@ function useInternalInfiniteQuery(_schema, model, operation, args, options) {
|
|
|
1104
1107
|
queryFn: /* @__PURE__ */ __name(({ pageParam, signal }) => {
|
|
1105
1108
|
return fetcher(makeUrl(endpoint, model, operation, pageParam ?? args), {
|
|
1106
1109
|
signal
|
|
1107
|
-
}, fetch2
|
|
1110
|
+
}, fetch2);
|
|
1108
1111
|
}, "queryFn"),
|
|
1109
1112
|
initialPageParam: args,
|
|
1110
1113
|
...options
|
|
@@ -1125,7 +1128,7 @@ function useInternalSuspenseInfiniteQuery(_schema, model, operation, args, optio
|
|
|
1125
1128
|
queryFn: /* @__PURE__ */ __name(({ pageParam, signal }) => {
|
|
1126
1129
|
return fetcher(makeUrl(endpoint, model, operation, pageParam ?? args), {
|
|
1127
1130
|
signal
|
|
1128
|
-
}, fetch2
|
|
1131
|
+
}, fetch2);
|
|
1129
1132
|
}, "queryFn"),
|
|
1130
1133
|
initialPageParam: args,
|
|
1131
1134
|
...options
|
|
@@ -1133,8 +1136,8 @@ function useInternalSuspenseInfiniteQuery(_schema, model, operation, args, optio
|
|
|
1133
1136
|
};
|
|
1134
1137
|
}
|
|
1135
1138
|
__name(useInternalSuspenseInfiniteQuery, "useInternalSuspenseInfiniteQuery");
|
|
1136
|
-
function useInternalMutation(schema, model, method, operation, options
|
|
1137
|
-
const { endpoint, fetch: fetch2 } = useHooksContext();
|
|
1139
|
+
function useInternalMutation(schema, model, method, operation, options) {
|
|
1140
|
+
const { endpoint, fetch: fetch2, logging } = useHooksContext();
|
|
1138
1141
|
const queryClient = useQueryClient();
|
|
1139
1142
|
const mutationFn = /* @__PURE__ */ __name((data) => {
|
|
1140
1143
|
const reqUrl = method === "DELETE" ? makeUrl(endpoint, model, operation, data) : makeUrl(endpoint, model, operation);
|
|
@@ -1147,7 +1150,7 @@ function useInternalMutation(schema, model, method, operation, options, checkRea
|
|
|
1147
1150
|
body: marshal(data)
|
|
1148
1151
|
}
|
|
1149
1152
|
};
|
|
1150
|
-
return fetcher(reqUrl, fetchInit, fetch2
|
|
1153
|
+
return fetcher(reqUrl, fetchInit, fetch2);
|
|
1151
1154
|
}, "mutationFn");
|
|
1152
1155
|
const finalOptions = {
|
|
1153
1156
|
...options,
|
|
@@ -1155,7 +1158,6 @@ function useInternalMutation(schema, model, method, operation, options, checkRea
|
|
|
1155
1158
|
};
|
|
1156
1159
|
const invalidateQueries = options?.invalidateQueries !== false;
|
|
1157
1160
|
const optimisticUpdate2 = !!options?.optimisticUpdate;
|
|
1158
|
-
const { logging } = useContext(QuerySettingsContext);
|
|
1159
1161
|
if (operation) {
|
|
1160
1162
|
if (invalidateQueries) {
|
|
1161
1163
|
setupInvalidation(model, operation, schema, finalOptions, (predicate) => queryClient.invalidateQueries({
|