@orpc/vue-query 0.0.0-next.80c9415 → 0.0.0-next.80df4d2
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/README.md +6 -3
- package/dist/index.d.mts +8 -22
- package/dist/index.d.ts +8 -22
- package/dist/index.mjs +2 -23
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<image align="center" src="https://orpc.
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<h1></h1>
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
45
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
46
49
|
|
|
47
50
|
## Packages
|
|
48
51
|
|
|
@@ -63,7 +66,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
63
66
|
|
|
64
67
|
## `@orpc/vue-query`
|
|
65
68
|
|
|
66
|
-
Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview). Read the [documentation](https://orpc.
|
|
69
|
+
Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview). Read the [documentation](https://orpc.dev/docs/integrations/tanstack-query-old/vue) for more information.
|
|
67
70
|
|
|
68
71
|
```ts
|
|
69
72
|
export function Setup() {
|
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,
|
|
4
|
+
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, 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
|
|
|
@@ -9,7 +9,7 @@ interface GeneralUtils<TInput> {
|
|
|
9
9
|
/**
|
|
10
10
|
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
|
11
11
|
*
|
|
12
|
-
* @see {@link https://orpc.
|
|
12
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
13
13
|
*/
|
|
14
14
|
key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
|
|
15
15
|
}
|
|
@@ -44,13 +44,6 @@ 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
|
-
}
|
|
54
47
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
55
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
56
49
|
} : {
|
|
@@ -85,32 +78,25 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
85
78
|
/**
|
|
86
79
|
* Calling corresponding procedure client
|
|
87
80
|
*
|
|
88
|
-
* @see {@link https://orpc.
|
|
81
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
89
82
|
*/
|
|
90
83
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
91
84
|
/**
|
|
92
85
|
* Generate options used for useQuery/prefetchQuery/...
|
|
93
86
|
*
|
|
94
|
-
* @see {@link https://orpc.
|
|
87
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
95
88
|
*/
|
|
96
89
|
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>>;
|
|
104
90
|
/**
|
|
105
91
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
106
92
|
*
|
|
107
|
-
* @see {@link https://orpc.
|
|
93
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
108
94
|
*/
|
|
109
95
|
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
|
|
110
96
|
/**
|
|
111
97
|
* Generate options used for useMutation/...
|
|
112
98
|
*
|
|
113
|
-
* @see {@link https://orpc.
|
|
99
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#mutation-options Tanstack Mutation Options Docs}
|
|
114
100
|
*/
|
|
115
101
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
116
102
|
}
|
|
@@ -129,7 +115,7 @@ interface CreateRouterUtilsOptions {
|
|
|
129
115
|
* Create a router utils from a client.
|
|
130
116
|
*
|
|
131
117
|
* @info Both client-side and server-side clients are supported.
|
|
132
|
-
* @see {@link https://orpc.
|
|
118
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/vue Tanstack Query Vue Docs}
|
|
133
119
|
*/
|
|
134
120
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
135
121
|
|
|
@@ -139,4 +125,4 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
139
125
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
140
126
|
|
|
141
127
|
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
142
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep
|
|
128
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
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,
|
|
4
|
+
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, 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
|
|
|
@@ -9,7 +9,7 @@ interface GeneralUtils<TInput> {
|
|
|
9
9
|
/**
|
|
10
10
|
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
|
11
11
|
*
|
|
12
|
-
* @see {@link https://orpc.
|
|
12
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
13
13
|
*/
|
|
14
14
|
key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
|
|
15
15
|
}
|
|
@@ -44,13 +44,6 @@ 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
|
-
}
|
|
54
47
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
55
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
56
49
|
} : {
|
|
@@ -85,32 +78,25 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
85
78
|
/**
|
|
86
79
|
* Calling corresponding procedure client
|
|
87
80
|
*
|
|
88
|
-
* @see {@link https://orpc.
|
|
81
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
89
82
|
*/
|
|
90
83
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
91
84
|
/**
|
|
92
85
|
* Generate options used for useQuery/prefetchQuery/...
|
|
93
86
|
*
|
|
94
|
-
* @see {@link https://orpc.
|
|
87
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
95
88
|
*/
|
|
96
89
|
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>>;
|
|
104
90
|
/**
|
|
105
91
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
106
92
|
*
|
|
107
|
-
* @see {@link https://orpc.
|
|
93
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
108
94
|
*/
|
|
109
95
|
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
|
|
110
96
|
/**
|
|
111
97
|
* Generate options used for useMutation/...
|
|
112
98
|
*
|
|
113
|
-
* @see {@link https://orpc.
|
|
99
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/basic#mutation-options Tanstack Mutation Options Docs}
|
|
114
100
|
*/
|
|
115
101
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
116
102
|
}
|
|
@@ -129,7 +115,7 @@ interface CreateRouterUtilsOptions {
|
|
|
129
115
|
* Create a router utils from a client.
|
|
130
116
|
*
|
|
131
117
|
* @info Both client-side and server-side clients are supported.
|
|
132
|
-
* @see {@link https://orpc.
|
|
118
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query-old/vue Tanstack Query Vue Docs}
|
|
133
119
|
*/
|
|
134
120
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
135
121
|
|
|
@@ -139,4 +125,4 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
139
125
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
140
126
|
|
|
141
127
|
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
142
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep
|
|
128
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
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 {
|
|
4
|
-
import { skipToken, experimental_streamedQuery } from '@tanstack/vue-query';
|
|
3
|
+
import { skipToken } from '@tanstack/vue-query';
|
|
5
4
|
import { isRef, computed } from 'vue';
|
|
5
|
+
import { isObject } from '@orpc/shared';
|
|
6
6
|
|
|
7
7
|
function createGeneralUtils(path) {
|
|
8
8
|
return {
|
|
@@ -45,27 +45,6 @@ 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
|
-
},
|
|
69
48
|
infiniteOptions(optionsIn) {
|
|
70
49
|
return {
|
|
71
50
|
queryKey: computed(() => {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/vue-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.80df4d2",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/unnoq/orpc.git",
|
|
@@ -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.80df4d2"
|
|
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.80df4d2",
|
|
36
|
+
"@orpc/tanstack-query": "0.0.0-next.80df4d2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@tanstack/vue-query": "^5.
|
|
39
|
+
"@tanstack/vue-query": "^5.91.2"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild",
|