@orpc/vue-query 0.0.0-next.03cefb3 → 0.0.0-next.057d007
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 +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.mjs +23 -2
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
3
3
|
export { OperationKeyOptions as BuildKeyOptions, OperationType as KeyType, generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
4
|
-
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
4
|
+
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, experimental_streamedQuery, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
5
5
|
import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
6
|
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
7
7
|
|
|
@@ -44,6 +44,13 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
44
44
|
retryDelay?: (count: number, error: TError) => number;
|
|
45
45
|
enabled: ComputedRef<boolean | undefined>;
|
|
46
46
|
}
|
|
47
|
+
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
48
|
+
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
49
|
+
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
50
|
+
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
51
|
+
};
|
|
52
|
+
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
53
|
+
}
|
|
47
54
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
48
55
|
context?: MaybeRefDeep<TClientContext>;
|
|
49
56
|
} : {
|
|
@@ -87,6 +94,13 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
87
94
|
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
88
95
|
*/
|
|
89
96
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
97
|
+
/**
|
|
98
|
+
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
|
|
99
|
+
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
100
|
+
*
|
|
101
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
|
|
102
|
+
*/
|
|
103
|
+
experimental_streamedOptions<U, USelectData = experimental_InferStreamedOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, TError>, keyof U>>;
|
|
90
104
|
/**
|
|
91
105
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
92
106
|
*
|
|
@@ -125,4 +139,4 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
125
139
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
126
140
|
|
|
127
141
|
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
128
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
|
142
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
3
3
|
export { OperationKeyOptions as BuildKeyOptions, OperationType as KeyType, generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
4
|
-
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
4
|
+
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, experimental_streamedQuery, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
5
5
|
import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
6
|
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
7
7
|
|
|
@@ -44,6 +44,13 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
44
44
|
retryDelay?: (count: number, error: TError) => number;
|
|
45
45
|
enabled: ComputedRef<boolean | undefined>;
|
|
46
46
|
}
|
|
47
|
+
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
48
|
+
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
49
|
+
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
50
|
+
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
51
|
+
};
|
|
52
|
+
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
53
|
+
}
|
|
47
54
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
48
55
|
context?: MaybeRefDeep<TClientContext>;
|
|
49
56
|
} : {
|
|
@@ -87,6 +94,13 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
87
94
|
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
88
95
|
*/
|
|
89
96
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
97
|
+
/**
|
|
98
|
+
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
|
|
99
|
+
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
100
|
+
*
|
|
101
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
|
|
102
|
+
*/
|
|
103
|
+
experimental_streamedOptions<U, USelectData = experimental_InferStreamedOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, TError>, keyof U>>;
|
|
90
104
|
/**
|
|
91
105
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
92
106
|
*
|
|
@@ -125,4 +139,4 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
125
139
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
126
140
|
|
|
127
141
|
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
128
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
|
142
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { generateOperationKey } from '@orpc/tanstack-query';
|
|
2
2
|
export { generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
3
|
-
import {
|
|
3
|
+
import { isObject, isAsyncIteratorObject } from '@orpc/shared';
|
|
4
|
+
import { skipToken, experimental_streamedQuery } from '@tanstack/vue-query';
|
|
4
5
|
import { isRef, computed } from 'vue';
|
|
5
|
-
import { isObject } from '@orpc/shared';
|
|
6
6
|
|
|
7
7
|
function createGeneralUtils(path) {
|
|
8
8
|
return {
|
|
@@ -45,6 +45,27 @@ function createProcedureUtils(client, options) {
|
|
|
45
45
|
...optionsIn
|
|
46
46
|
};
|
|
47
47
|
},
|
|
48
|
+
experimental_streamedOptions(...[optionsIn = {}]) {
|
|
49
|
+
return {
|
|
50
|
+
enabled: computed(() => unrefDeep(optionsIn.input) === skipToken ? false : void 0),
|
|
51
|
+
queryKey: computed(() => generateOperationKey(options.path, { type: "streamed", input: unrefDeep(optionsIn.input), fnOptions: optionsIn.queryFnOptions })),
|
|
52
|
+
queryFn: experimental_streamedQuery({
|
|
53
|
+
queryFn: async ({ signal }) => {
|
|
54
|
+
const input = unrefDeep(optionsIn.input);
|
|
55
|
+
if (input === skipToken) {
|
|
56
|
+
throw new Error("queryFn should not be called with skipToken used as input");
|
|
57
|
+
}
|
|
58
|
+
const output = await client(input, { signal, context: unrefDeep(optionsIn.context) });
|
|
59
|
+
if (!isAsyncIteratorObject(output)) {
|
|
60
|
+
throw new Error("streamedQuery requires an event iterator output");
|
|
61
|
+
}
|
|
62
|
+
return output;
|
|
63
|
+
},
|
|
64
|
+
...optionsIn.queryFnOptions
|
|
65
|
+
}),
|
|
66
|
+
...optionsIn
|
|
67
|
+
};
|
|
68
|
+
},
|
|
48
69
|
infiniteOptions(optionsIn) {
|
|
49
70
|
return {
|
|
50
71
|
queryKey: computed(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/vue-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.057d007",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@tanstack/vue-query": ">=5.80.2",
|
|
31
31
|
"vue": ">=3.3.0",
|
|
32
|
-
"@orpc/client": "0.0.0-next.
|
|
32
|
+
"@orpc/client": "0.0.0-next.057d007"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@orpc/shared": "0.0.0-next.
|
|
36
|
-
"@orpc/tanstack-query": "0.0.0-next.
|
|
35
|
+
"@orpc/shared": "0.0.0-next.057d007",
|
|
36
|
+
"@orpc/tanstack-query": "0.0.0-next.057d007"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@tanstack/vue-query": "^5.
|
|
39
|
+
"@tanstack/vue-query": "^5.85.9"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild",
|