@orpc/vue-query 0.0.0-next.e000d9a → 0.0.0-next.e02ffab
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 +12 -9
- package/dist/index.d.mts +20 -35
- package/dist/index.d.ts +20 -35
- package/dist/index.mjs +11 -39
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -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>
|
|
@@ -30,7 +33,8 @@
|
|
|
30
33
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
34
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
35
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
-
-
|
|
36
|
+
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
37
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
34
38
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
39
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
40
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -38,7 +42,6 @@
|
|
|
38
42
|
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
43
|
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
44
|
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
-
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
@@ -49,21 +52,21 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
49
52
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
50
53
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
51
54
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
52
|
-
- [@orpc/
|
|
55
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
56
|
+
- [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
|
|
57
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
53
58
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
54
|
-
- [@orpc/
|
|
55
|
-
- [@orpc/
|
|
56
|
-
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
57
|
-
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
59
|
+
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
60
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
58
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
59
|
-
- [@orpc/
|
|
62
|
+
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
60
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
61
64
|
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
62
65
|
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
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.unnoq.com/docs/tanstack-query/vue) for more information.
|
|
69
|
+
Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview). Read the [documentation](https://orpc.unnoq.com/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,22 +1,17 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
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';
|
|
5
|
+
import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
6
|
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
5
7
|
|
|
6
|
-
type KeyType = 'query' | 'streamed' | 'infinite' | 'mutation' | undefined;
|
|
7
|
-
interface BuildKeyOptions<TType extends KeyType, TInput> {
|
|
8
|
-
type?: TType;
|
|
9
|
-
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
|
10
|
-
}
|
|
11
|
-
declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
|
|
12
|
-
|
|
13
8
|
interface GeneralUtils<TInput> {
|
|
14
9
|
/**
|
|
15
10
|
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
|
16
11
|
*
|
|
17
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
12
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
18
13
|
*/
|
|
19
|
-
key<UType extends
|
|
14
|
+
key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
|
|
20
15
|
}
|
|
21
16
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
22
17
|
|
|
@@ -46,30 +41,27 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
46
41
|
queryKey: ComputedRef<QueryKey>;
|
|
47
42
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
48
43
|
throwOnError?(error: TError): boolean;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
52
|
-
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
53
|
-
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & experimental_StreamedQueryOptions;
|
|
54
|
-
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
44
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
45
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
55
46
|
}
|
|
56
47
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
57
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
58
49
|
} : {
|
|
59
50
|
context: MaybeRefDeep<TClientContext>;
|
|
60
51
|
}) & {
|
|
61
|
-
[Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData,
|
|
52
|
+
[Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey' | 'enabled'>]: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>[Property]>;
|
|
62
53
|
} & {
|
|
63
54
|
input: MaybeRef<((pageParam: TPageParam) => MaybeRefDeep<TInput>) | SkipToken>;
|
|
64
|
-
enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData,
|
|
65
|
-
queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData,
|
|
55
|
+
enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>['enabled']>;
|
|
56
|
+
queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>['queryKey']>;
|
|
66
57
|
shallow?: boolean;
|
|
67
58
|
};
|
|
68
59
|
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
69
60
|
queryKey: ComputedRef<QueryKey>;
|
|
70
61
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
71
62
|
throwOnError?(error: TError): boolean;
|
|
72
|
-
|
|
63
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
64
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
73
65
|
}
|
|
74
66
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
75
67
|
context?: TClientContext;
|
|
@@ -86,32 +78,25 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
86
78
|
/**
|
|
87
79
|
* Calling corresponding procedure client
|
|
88
80
|
*
|
|
89
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
81
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
90
82
|
*/
|
|
91
83
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
92
84
|
/**
|
|
93
85
|
* Generate options used for useQuery/prefetchQuery/...
|
|
94
86
|
*
|
|
95
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
87
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
96
88
|
*/
|
|
97
89
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
98
|
-
/**
|
|
99
|
-
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
|
|
100
|
-
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
101
|
-
*
|
|
102
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
|
|
103
|
-
*/
|
|
104
|
-
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>>;
|
|
105
90
|
/**
|
|
106
91
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
107
92
|
*
|
|
108
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
93
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
109
94
|
*/
|
|
110
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>>;
|
|
111
96
|
/**
|
|
112
97
|
* Generate options used for useMutation/...
|
|
113
98
|
*
|
|
114
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#mutation-options Tanstack Mutation Options Docs}
|
|
99
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#mutation-options Tanstack Mutation Options Docs}
|
|
115
100
|
*/
|
|
116
101
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
117
102
|
}
|
|
@@ -130,7 +115,7 @@ interface CreateRouterUtilsOptions {
|
|
|
130
115
|
* Create a router utils from a client.
|
|
131
116
|
*
|
|
132
117
|
* @info Both client-side and server-side clients are supported.
|
|
133
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/vue Tanstack Query Vue Docs}
|
|
118
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/vue Tanstack Query Vue Docs}
|
|
134
119
|
*/
|
|
135
120
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
136
121
|
|
|
@@ -139,5 +124,5 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
139
124
|
} : T;
|
|
140
125
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
141
126
|
|
|
142
|
-
export {
|
|
143
|
-
export type {
|
|
127
|
+
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
128
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
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';
|
|
5
|
+
import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
6
|
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
5
7
|
|
|
6
|
-
type KeyType = 'query' | 'streamed' | 'infinite' | 'mutation' | undefined;
|
|
7
|
-
interface BuildKeyOptions<TType extends KeyType, TInput> {
|
|
8
|
-
type?: TType;
|
|
9
|
-
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
|
10
|
-
}
|
|
11
|
-
declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
|
|
12
|
-
|
|
13
8
|
interface GeneralUtils<TInput> {
|
|
14
9
|
/**
|
|
15
10
|
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
|
16
11
|
*
|
|
17
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
12
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
18
13
|
*/
|
|
19
|
-
key<UType extends
|
|
14
|
+
key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
|
|
20
15
|
}
|
|
21
16
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
22
17
|
|
|
@@ -46,30 +41,27 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
46
41
|
queryKey: ComputedRef<QueryKey>;
|
|
47
42
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
48
43
|
throwOnError?(error: TError): boolean;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
52
|
-
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
53
|
-
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & experimental_StreamedQueryOptions;
|
|
54
|
-
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
44
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
45
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
55
46
|
}
|
|
56
47
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
57
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
58
49
|
} : {
|
|
59
50
|
context: MaybeRefDeep<TClientContext>;
|
|
60
51
|
}) & {
|
|
61
|
-
[Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData,
|
|
52
|
+
[Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey' | 'enabled'>]: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>[Property]>;
|
|
62
53
|
} & {
|
|
63
54
|
input: MaybeRef<((pageParam: TPageParam) => MaybeRefDeep<TInput>) | SkipToken>;
|
|
64
|
-
enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData,
|
|
65
|
-
queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData,
|
|
55
|
+
enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>['enabled']>;
|
|
56
|
+
queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>['queryKey']>;
|
|
66
57
|
shallow?: boolean;
|
|
67
58
|
};
|
|
68
59
|
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
69
60
|
queryKey: ComputedRef<QueryKey>;
|
|
70
61
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
71
62
|
throwOnError?(error: TError): boolean;
|
|
72
|
-
|
|
63
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
64
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
73
65
|
}
|
|
74
66
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
75
67
|
context?: TClientContext;
|
|
@@ -86,32 +78,25 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
86
78
|
/**
|
|
87
79
|
* Calling corresponding procedure client
|
|
88
80
|
*
|
|
89
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
81
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
90
82
|
*/
|
|
91
83
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
92
84
|
/**
|
|
93
85
|
* Generate options used for useQuery/prefetchQuery/...
|
|
94
86
|
*
|
|
95
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
87
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
96
88
|
*/
|
|
97
89
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
98
|
-
/**
|
|
99
|
-
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
|
|
100
|
-
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
101
|
-
*
|
|
102
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
|
|
103
|
-
*/
|
|
104
|
-
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>>;
|
|
105
90
|
/**
|
|
106
91
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
107
92
|
*
|
|
108
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
93
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
109
94
|
*/
|
|
110
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>>;
|
|
111
96
|
/**
|
|
112
97
|
* Generate options used for useMutation/...
|
|
113
98
|
*
|
|
114
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#mutation-options Tanstack Mutation Options Docs}
|
|
99
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#mutation-options Tanstack Mutation Options Docs}
|
|
115
100
|
*/
|
|
116
101
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
117
102
|
}
|
|
@@ -130,7 +115,7 @@ interface CreateRouterUtilsOptions {
|
|
|
130
115
|
* Create a router utils from a client.
|
|
131
116
|
*
|
|
132
117
|
* @info Both client-side and server-side clients are supported.
|
|
133
|
-
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/vue Tanstack Query Vue Docs}
|
|
118
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/vue Tanstack Query Vue Docs}
|
|
134
119
|
*/
|
|
135
120
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
136
121
|
|
|
@@ -139,5 +124,5 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
139
124
|
} : T;
|
|
140
125
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
141
126
|
|
|
142
|
-
export {
|
|
143
|
-
export type {
|
|
127
|
+
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
128
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { generateOperationKey } from '@orpc/tanstack-query';
|
|
2
|
+
export { generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
3
|
+
import { skipToken } from '@tanstack/vue-query';
|
|
3
4
|
import { isRef, computed } from 'vue';
|
|
4
|
-
|
|
5
|
-
function buildKey(path, options) {
|
|
6
|
-
const withInput = options?.input !== void 0 ? { input: options?.input } : {};
|
|
7
|
-
const withType = options?.type !== void 0 ? { type: options?.type } : {};
|
|
8
|
-
return [path, {
|
|
9
|
-
...withInput,
|
|
10
|
-
...withType
|
|
11
|
-
}];
|
|
12
|
-
}
|
|
5
|
+
import { isObject } from '@orpc/shared';
|
|
13
6
|
|
|
14
7
|
function createGeneralUtils(path) {
|
|
15
8
|
return {
|
|
16
9
|
key(options) {
|
|
17
|
-
return
|
|
10
|
+
return generateOperationKey(path, options);
|
|
18
11
|
}
|
|
19
12
|
};
|
|
20
13
|
}
|
|
@@ -40,7 +33,7 @@ function createProcedureUtils(client, options) {
|
|
|
40
33
|
call: client,
|
|
41
34
|
queryOptions(...[optionsIn = {}]) {
|
|
42
35
|
return {
|
|
43
|
-
queryKey: computed(() =>
|
|
36
|
+
queryKey: computed(() => generateOperationKey(options.path, { type: "query", input: unrefDeep(optionsIn.input) })),
|
|
44
37
|
queryFn: ({ signal }) => {
|
|
45
38
|
const input = unrefDeep(optionsIn.input);
|
|
46
39
|
if (input === skipToken) {
|
|
@@ -48,28 +41,7 @@ function createProcedureUtils(client, options) {
|
|
|
48
41
|
}
|
|
49
42
|
return client(input, { signal, context: unrefDeep(optionsIn.context) });
|
|
50
43
|
},
|
|
51
|
-
enabled: computed(() => unrefDeep(optionsIn.input)
|
|
52
|
-
...optionsIn
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
experimental_streamedOptions(...[optionsIn = {}]) {
|
|
56
|
-
return {
|
|
57
|
-
enabled: computed(() => unrefDeep(optionsIn.input) !== skipToken),
|
|
58
|
-
queryKey: computed(() => buildKey(options.path, { type: "streamed", input: unrefDeep(optionsIn.input) })),
|
|
59
|
-
queryFn: experimental_streamedQuery({
|
|
60
|
-
...optionsIn,
|
|
61
|
-
queryFn: async ({ signal }) => {
|
|
62
|
-
const input = unrefDeep(optionsIn.input);
|
|
63
|
-
if (input === skipToken) {
|
|
64
|
-
throw new Error("queryFn should not be called with skipToken used as input");
|
|
65
|
-
}
|
|
66
|
-
const output = await client(input, { signal, context: unrefDeep(optionsIn.context) });
|
|
67
|
-
if (!isAsyncIteratorObject(output)) {
|
|
68
|
-
throw new Error("streamedQuery requires an event iterator output");
|
|
69
|
-
}
|
|
70
|
-
return output;
|
|
71
|
-
}
|
|
72
|
-
}),
|
|
44
|
+
enabled: computed(() => unrefDeep(optionsIn.input) === skipToken ? false : void 0),
|
|
73
45
|
...optionsIn
|
|
74
46
|
};
|
|
75
47
|
},
|
|
@@ -77,7 +49,7 @@ function createProcedureUtils(client, options) {
|
|
|
77
49
|
return {
|
|
78
50
|
queryKey: computed(() => {
|
|
79
51
|
const input = unrefDeep(optionsIn.input);
|
|
80
|
-
return
|
|
52
|
+
return generateOperationKey(options.path, {
|
|
81
53
|
type: "infinite",
|
|
82
54
|
input: input === skipToken ? skipToken : unrefDeep(input(unrefDeep(optionsIn.initialPageParam)))
|
|
83
55
|
});
|
|
@@ -89,13 +61,13 @@ function createProcedureUtils(client, options) {
|
|
|
89
61
|
}
|
|
90
62
|
return client(unrefDeep(input(pageParam)), { signal, context: unrefDeep(optionsIn.context) });
|
|
91
63
|
},
|
|
92
|
-
enabled: computed(() => unrefDeep(optionsIn.input)
|
|
64
|
+
enabled: computed(() => unrefDeep(optionsIn.input) === skipToken ? false : void 0),
|
|
93
65
|
...optionsIn
|
|
94
66
|
};
|
|
95
67
|
},
|
|
96
68
|
mutationOptions(...[optionsIn = {}]) {
|
|
97
69
|
return {
|
|
98
|
-
mutationKey:
|
|
70
|
+
mutationKey: generateOperationKey(options.path, { type: "mutation" }),
|
|
99
71
|
mutationFn: (input) => client(input, { context: unrefDeep(optionsIn.context) }),
|
|
100
72
|
...optionsIn
|
|
101
73
|
};
|
|
@@ -130,4 +102,4 @@ function createRouterUtils(client, options = {}) {
|
|
|
130
102
|
return recursive;
|
|
131
103
|
}
|
|
132
104
|
|
|
133
|
-
export {
|
|
105
|
+
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
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.e02ffab",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@tanstack/vue-query": ">=5.
|
|
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.e02ffab"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@orpc/
|
|
35
|
+
"@orpc/tanstack-query": "0.0.0-next.e02ffab",
|
|
36
|
+
"@orpc/shared": "0.0.0-next.e02ffab"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@tanstack/vue-query": "^5.
|
|
39
|
+
"@tanstack/vue-query": "^5.90.2"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build": "unbuild",
|