@questpie/tanstack-query 3.5.6 → 3.6.1
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/dist/index.d.mts +21 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -11,9 +11,25 @@ type QuestpieQueryOptionsConfig = {
|
|
|
11
11
|
};
|
|
12
12
|
type AnyAsyncFn = (...args: any[]) => Promise<any>;
|
|
13
13
|
type QueryData<TFn extends AnyAsyncFn> = Awaited<ReturnType<TFn>>;
|
|
14
|
-
type FirstArg<TFn extends AnyAsyncFn> = Parameters<TFn> extends [infer TFirst, ...any[]] ? TFirst : never;
|
|
14
|
+
type FirstArg<TFn extends AnyAsyncFn> = Parameters<TFn> extends [infer TFirst, ...any[]] ? TFirst : Parameters<TFn> extends [(infer TFirst)?, ...any[]] ? TFirst | undefined : never;
|
|
15
15
|
type HasArgs<TFn extends AnyAsyncFn> = Parameters<TFn> extends [] ? false : true;
|
|
16
16
|
type QueryBuilder<TFn extends AnyAsyncFn> = HasArgs<TFn> extends false ? () => UseQueryOptions<QueryData<TFn>> : undefined extends FirstArg<TFn> ? (options?: FirstArg<TFn>) => UseQueryOptions<QueryData<TFn>> : (options: FirstArg<TFn>) => UseQueryOptions<QueryData<TFn>>;
|
|
17
|
+
/**
|
|
18
|
+
* Per-query realtime flag — the second argument to `find` / `count` / `get`.
|
|
19
|
+
*/
|
|
20
|
+
type RealtimeQueryConfig = {
|
|
21
|
+
/**
|
|
22
|
+
* Subscribe the query to live snapshots over the multiplexed SSE stream.
|
|
23
|
+
* Initial data comes from a normal fetch; afterwards the server pushes
|
|
24
|
+
* full snapshots on every matching change (via `experimental_streamedQuery`).
|
|
25
|
+
*/
|
|
26
|
+
realtime?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Builder for reads that also have a live form — same as `QueryBuilder`
|
|
30
|
+
* plus the optional `{ realtime }` second argument.
|
|
31
|
+
*/
|
|
32
|
+
type LiveQueryBuilder<TFn extends AnyAsyncFn> = undefined extends FirstArg<TFn> ? (options?: FirstArg<TFn>, queryConfig?: RealtimeQueryConfig) => UseQueryOptions<QueryData<TFn>> : (options: FirstArg<TFn>, queryConfig?: RealtimeQueryConfig) => UseQueryOptions<QueryData<TFn>>;
|
|
17
33
|
type KeyBuilder<TFn extends AnyAsyncFn> = HasArgs<TFn> extends false ? () => QueryKey : undefined extends FirstArg<TFn> ? (options?: FirstArg<TFn>) => QueryKey : (options: FirstArg<TFn>) => QueryKey;
|
|
18
34
|
type MutationVariables<TFn extends AnyAsyncFn> = HasArgs<TFn> extends false ? void : undefined extends FirstArg<TFn> ? FirstArg<TFn> | void : FirstArg<TFn>;
|
|
19
35
|
type MutationBuilder<TVariables, TData> = () => UseMutationOptions<TData, DefaultError, TVariables>;
|
|
@@ -53,8 +69,8 @@ type RouteLeafQueryOptionsAPI<TFn extends AnyAsyncFn> = {
|
|
|
53
69
|
};
|
|
54
70
|
type RoutesQueryOptionsAPI<TNode> = TNode extends AnyAsyncFn ? RouteLeafQueryOptionsAPI<TNode> : TNode extends Record<string, any> ? { [K in keyof TNode]: RoutesQueryOptionsAPI<TNode[K]> } : never;
|
|
55
71
|
type CollectionQueryOptionsAPI<TApp extends QuestpieApp, K$1 extends CollectionKeys<TApp>> = {
|
|
56
|
-
find:
|
|
57
|
-
count:
|
|
72
|
+
find: LiveQueryBuilder<CollectionFind<TApp, K$1>>;
|
|
73
|
+
count: LiveQueryBuilder<CollectionCount<TApp, K$1>>;
|
|
58
74
|
findOne: QueryBuilder<CollectionFindOne<TApp, K$1>>;
|
|
59
75
|
create: MutationBuilder<FirstArg<CollectionCreate<TApp, K$1>>, QueryData<CollectionCreate<TApp, K$1>>>;
|
|
60
76
|
update: MutationBuilder<FirstArg<CollectionUpdate<TApp, K$1>>, QueryData<CollectionUpdate<TApp, K$1>>>;
|
|
@@ -75,7 +91,7 @@ type CollectionQueryOptionsAPI<TApp extends QuestpieApp, K$1 extends CollectionK
|
|
|
75
91
|
}>;
|
|
76
92
|
};
|
|
77
93
|
type GlobalQueryOptionsAPI<TApp extends QuestpieApp, K$1 extends GlobalKeys<TApp>> = {
|
|
78
|
-
get:
|
|
94
|
+
get: LiveQueryBuilder<GlobalGet<TApp, K$1>>;
|
|
79
95
|
update: MutationBuilder<{
|
|
80
96
|
data: Parameters<GlobalUpdate<TApp, K$1>>[0];
|
|
81
97
|
options?: Parameters<GlobalUpdate<TApp, K$1>>[1];
|
|
@@ -130,4 +146,4 @@ type QuestpieQueryOptionsProxy<TApp extends QuestpieApp = QuestpieApp> = {
|
|
|
130
146
|
*/
|
|
131
147
|
declare function createQuestpieQueryOptions<TApp extends QuestpieApp = QuestpieApp>(client: QuestpieClient<TApp>, config?: QuestpieQueryOptionsConfig): QuestpieQueryOptionsProxy<TApp>;
|
|
132
148
|
//#endregion
|
|
133
|
-
export { type DefaultError, type QueryKey, QuestpieQueryErrorMap, QuestpieQueryOptionsConfig, QuestpieQueryOptionsProxy, type RealtimeAPI, type TopicConfig, type UseMutationOptions, type UseQueryOptions, buildCollectionTopic, buildGlobalTopic, createQuestpieQueryOptions };
|
|
149
|
+
export { type DefaultError, type QueryKey, QuestpieQueryErrorMap, QuestpieQueryOptionsConfig, QuestpieQueryOptionsProxy, type RealtimeAPI, RealtimeQueryConfig, type TopicConfig, type UseMutationOptions, type UseQueryOptions, buildCollectionTopic, buildGlobalTopic, createQuestpieQueryOptions };
|