@orpc/tanstack-query 0.0.0-next.3d25567 → 0.0.0-next.3d8a81d
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 +4 -20
- package/dist/index.d.ts +4 -20
- package/dist/index.mjs +1 -52
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -3,9 +3,8 @@ import { SetOptional, PartialDeep, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
3
3
|
import { SkipToken, QueryKey, QueryObserverOptions, DataTag, QueryFunction, experimental_streamedQuery, InfiniteQueryObserverOptions, InfiniteData, MutationObserverOptions } from '@tanstack/query-core';
|
|
4
4
|
|
|
5
5
|
type experimental_StreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
6
|
-
type experimental_LiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
7
6
|
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
8
|
-
type OperationType = 'query' | 'streamed' | '
|
|
7
|
+
type OperationType = 'query' | 'streamed' | 'infinite' | 'mutation';
|
|
9
8
|
type OperationKeyOptions<TType extends OperationType, TInput> = {
|
|
10
9
|
type?: TType;
|
|
11
10
|
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
|
@@ -109,27 +108,12 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
109
108
|
*/
|
|
110
109
|
experimental_streamedKey(...rest: MaybeOptionalOptions<experimental_StreamedKeyOptions<TInput>>): DataTag<QueryKey, experimental_StreamedQueryOutput<TOutput>, TError>;
|
|
111
110
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* and works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
111
|
+
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
112
|
+
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
115
113
|
*
|
|
116
114
|
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
117
115
|
*/
|
|
118
116
|
experimental_streamedOptions<U, USelectData = experimental_StreamedQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_StreamedQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_StreamedQueryOutput<TOutput>, TError>, keyof U>>;
|
|
119
|
-
/**
|
|
120
|
-
* Generate a **full matching** key for [Live Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#live-query-options).
|
|
121
|
-
*
|
|
122
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
123
|
-
*/
|
|
124
|
-
experimental_liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, experimental_LiveQueryOutput<TOutput>, TError>;
|
|
125
|
-
/**
|
|
126
|
-
* Configure live queries for [Event Iterator](https://orpc.unnoq.com/docs/event-iterator).
|
|
127
|
-
* Unlike `.streamedOptions` which accumulates chunks, live queries replace the entire result with each new chunk received.
|
|
128
|
-
* Works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
129
|
-
*
|
|
130
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#live-query-options Tanstack Live Query Options Utility Docs}
|
|
131
|
-
*/
|
|
132
|
-
experimental_liveOptions<U, USelectData = experimental_LiveQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<experimental_LiveQueryOutput<TOutput>, TError>, keyof U>>;
|
|
133
117
|
/**
|
|
134
118
|
* Generate a **full matching** key for [Infinite Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#infinite-query-options).
|
|
135
119
|
*
|
|
@@ -175,4 +159,4 @@ interface CreateRouterUtilsOptions {
|
|
|
175
159
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
176
160
|
|
|
177
161
|
export { OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createGeneralUtils, createProcedureUtils, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey };
|
|
178
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext,
|
|
162
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_StreamedKeyOptions, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,8 @@ import { SetOptional, PartialDeep, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
3
3
|
import { SkipToken, QueryKey, QueryObserverOptions, DataTag, QueryFunction, experimental_streamedQuery, InfiniteQueryObserverOptions, InfiniteData, MutationObserverOptions } from '@tanstack/query-core';
|
|
4
4
|
|
|
5
5
|
type experimental_StreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
6
|
-
type experimental_LiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
7
6
|
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
8
|
-
type OperationType = 'query' | 'streamed' | '
|
|
7
|
+
type OperationType = 'query' | 'streamed' | 'infinite' | 'mutation';
|
|
9
8
|
type OperationKeyOptions<TType extends OperationType, TInput> = {
|
|
10
9
|
type?: TType;
|
|
11
10
|
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
|
@@ -109,27 +108,12 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
109
108
|
*/
|
|
110
109
|
experimental_streamedKey(...rest: MaybeOptionalOptions<experimental_StreamedKeyOptions<TInput>>): DataTag<QueryKey, experimental_StreamedQueryOutput<TOutput>, TError>;
|
|
111
110
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* and works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
111
|
+
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
112
|
+
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
115
113
|
*
|
|
116
114
|
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
117
115
|
*/
|
|
118
116
|
experimental_streamedOptions<U, USelectData = experimental_StreamedQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_StreamedQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_StreamedQueryOutput<TOutput>, TError>, keyof U>>;
|
|
119
|
-
/**
|
|
120
|
-
* Generate a **full matching** key for [Live Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#live-query-options).
|
|
121
|
-
*
|
|
122
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
123
|
-
*/
|
|
124
|
-
experimental_liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, experimental_LiveQueryOutput<TOutput>, TError>;
|
|
125
|
-
/**
|
|
126
|
-
* Configure live queries for [Event Iterator](https://orpc.unnoq.com/docs/event-iterator).
|
|
127
|
-
* Unlike `.streamedOptions` which accumulates chunks, live queries replace the entire result with each new chunk received.
|
|
128
|
-
* Works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
129
|
-
*
|
|
130
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#live-query-options Tanstack Live Query Options Utility Docs}
|
|
131
|
-
*/
|
|
132
|
-
experimental_liveOptions<U, USelectData = experimental_LiveQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<experimental_LiveQueryOutput<TOutput>, TError>, keyof U>>;
|
|
133
117
|
/**
|
|
134
118
|
* Generate a **full matching** key for [Infinite Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#infinite-query-options).
|
|
135
119
|
*
|
|
@@ -175,4 +159,4 @@ interface CreateRouterUtilsOptions {
|
|
|
175
159
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
176
160
|
|
|
177
161
|
export { OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createGeneralUtils, createProcedureUtils, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey };
|
|
178
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext,
|
|
162
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_StreamedKeyOptions, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isAsyncIteratorObject, toArray } from '@orpc/shared';
|
|
2
2
|
import { skipToken, experimental_streamedQuery } from '@tanstack/query-core';
|
|
3
3
|
|
|
4
4
|
function generateOperationKey(path, state = {}) {
|
|
@@ -17,26 +17,6 @@ function createGeneralUtils(path) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function experimental_liveQuery(queryFn) {
|
|
21
|
-
return async (context) => {
|
|
22
|
-
const stream = await queryFn(context);
|
|
23
|
-
let last;
|
|
24
|
-
for await (const chunk of stream) {
|
|
25
|
-
if (context.signal.aborted) {
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
last = { chunk };
|
|
29
|
-
context.client.setQueryData(context.queryKey, chunk);
|
|
30
|
-
}
|
|
31
|
-
if (!last) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`Live query for ${stringifyJSON(context.queryKey)} did not yield any data. Ensure the query function returns an AsyncIterable with at least one chunk.`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return last.chunk;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
20
|
const OPERATION_CONTEXT_SYMBOL = Symbol("ORPC_OPERATION_CONTEXT");
|
|
41
21
|
|
|
42
22
|
function createProcedureUtils(client, options) {
|
|
@@ -103,37 +83,6 @@ function createProcedureUtils(client, options) {
|
|
|
103
83
|
queryKey
|
|
104
84
|
};
|
|
105
85
|
},
|
|
106
|
-
experimental_liveKey(...[optionsIn = {}]) {
|
|
107
|
-
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "live", input: optionsIn.input });
|
|
108
|
-
return queryKey;
|
|
109
|
-
},
|
|
110
|
-
experimental_liveOptions(...[optionsIn = {}]) {
|
|
111
|
-
const queryKey = utils.experimental_liveKey(optionsIn);
|
|
112
|
-
return {
|
|
113
|
-
enabled: optionsIn.input !== skipToken,
|
|
114
|
-
queryFn: experimental_liveQuery(async ({ signal }) => {
|
|
115
|
-
if (optionsIn.input === skipToken) {
|
|
116
|
-
throw new Error("queryFn should not be called with skipToken used as input");
|
|
117
|
-
}
|
|
118
|
-
const output = await client(optionsIn.input, {
|
|
119
|
-
signal,
|
|
120
|
-
context: {
|
|
121
|
-
[OPERATION_CONTEXT_SYMBOL]: {
|
|
122
|
-
key: queryKey,
|
|
123
|
-
type: "live"
|
|
124
|
-
},
|
|
125
|
-
...optionsIn.context
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
if (!isAsyncIteratorObject(output)) {
|
|
129
|
-
throw new Error("liveQuery requires an event iterator output");
|
|
130
|
-
}
|
|
131
|
-
return output;
|
|
132
|
-
}),
|
|
133
|
-
...optionsIn,
|
|
134
|
-
queryKey
|
|
135
|
-
};
|
|
136
|
-
},
|
|
137
86
|
infiniteKey(optionsIn) {
|
|
138
87
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, {
|
|
139
88
|
type: "infinite",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/tanstack-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.3d8a81d",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
],
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@tanstack/query-core": ">=5.80.2",
|
|
28
|
-
"@orpc/client": "0.0.0-next.
|
|
28
|
+
"@orpc/client": "0.0.0-next.3d8a81d"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@orpc/shared": "0.0.0-next.
|
|
31
|
+
"@orpc/shared": "0.0.0-next.3d8a81d"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@angular/core": "^20.0.
|
|
35
|
-
"@tanstack/angular-query-experimental": "^5.
|
|
36
|
-
"@tanstack/query-core": "^5.
|
|
37
|
-
"@tanstack/react-query": "^5.
|
|
38
|
-
"@tanstack/solid-query": "^5.
|
|
39
|
-
"@tanstack/svelte-query": "^5.81.
|
|
40
|
-
"@tanstack/vue-query": "^5.81.
|
|
41
|
-
"svelte": "^5.
|
|
34
|
+
"@angular/core": "^20.0.5",
|
|
35
|
+
"@tanstack/angular-query-experimental": "^5.80.10",
|
|
36
|
+
"@tanstack/query-core": "^5.80.10",
|
|
37
|
+
"@tanstack/react-query": "^5.80.10",
|
|
38
|
+
"@tanstack/solid-query": "^5.80.10",
|
|
39
|
+
"@tanstack/svelte-query": "^5.81.3",
|
|
40
|
+
"@tanstack/vue-query": "^5.81.3",
|
|
41
|
+
"svelte": "^5.34.8",
|
|
42
42
|
"vue": "^3.5.17",
|
|
43
|
-
"zod": "^3.25.
|
|
43
|
+
"zod": "^3.25.67"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "unbuild",
|