@orpc/vue-query 0.0.0-next.df024bb → 0.0.0-next.e0f01a5
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 +14 -1
- package/dist/index.d.mts +32 -20
- package/dist/index.d.ts +32 -20
- package/dist/index.mjs +18 -19
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
|
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
|
@@ -53,11 +53,16 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
53
53
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
54
54
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
56
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
57
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
|
57
58
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
59
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
60
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
58
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
59
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
60
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
61
66
|
|
|
62
67
|
## `@orpc/vue-query`
|
|
63
68
|
|
|
@@ -105,6 +110,14 @@ export function Setup() {
|
|
|
105
110
|
}
|
|
106
111
|
```
|
|
107
112
|
|
|
113
|
+
## Sponsors
|
|
114
|
+
|
|
115
|
+
<p align="center">
|
|
116
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
|
117
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
|
118
|
+
</a>
|
|
119
|
+
</p>
|
|
120
|
+
|
|
108
121
|
## License
|
|
109
122
|
|
|
110
123
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
|
-
import { QueryKey, QueryObserverOptions, QueryFunctionContext,
|
|
3
|
-
import { PartialDeep, AnyFunction,
|
|
4
|
-
import { MaybeRef, MaybeRefOrGetter, ComputedRef } from 'vue';
|
|
2
|
+
import { QueryKey, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
3
|
+
import { PartialDeep, AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
+
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
5
5
|
|
|
6
6
|
type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
|
|
7
7
|
interface BuildKeyOptions<TType extends KeyType, TInput> {
|
|
@@ -22,7 +22,7 @@ declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput
|
|
|
22
22
|
type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
|
23
23
|
[Property in keyof T]: MaybeRefDeep<T[Property]>;
|
|
24
24
|
} : T>;
|
|
25
|
-
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
25
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = (undefined extends TInput ? {
|
|
26
26
|
input?: MaybeRefDeep<TInput>;
|
|
27
27
|
} : {
|
|
28
28
|
input: MaybeRefDeep<TInput>;
|
|
@@ -35,53 +35,65 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
35
35
|
} & {
|
|
36
36
|
enabled?: MaybeRefOrGetter<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['enabled']>;
|
|
37
37
|
queryKey?: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['queryKey']>;
|
|
38
|
-
shallow?:
|
|
38
|
+
shallow?: boolean;
|
|
39
39
|
};
|
|
40
|
-
interface QueryOptionsBase<TOutput, TError
|
|
40
|
+
interface QueryOptionsBase<TOutput, TError> {
|
|
41
41
|
queryKey: ComputedRef<QueryKey>;
|
|
42
42
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
43
43
|
retry?(failureCount: number, error: TError): boolean;
|
|
44
44
|
}
|
|
45
|
-
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
45
|
+
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
46
46
|
input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
|
|
47
47
|
} & (Record<never, never> extends TClientContext ? {
|
|
48
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
49
49
|
} : {
|
|
50
50
|
context: MaybeRefDeep<TClientContext>;
|
|
51
|
-
}) &
|
|
52
|
-
|
|
51
|
+
}) & {
|
|
52
|
+
[Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey' | 'enabled'>]: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>[Property]>;
|
|
53
|
+
} & {
|
|
54
|
+
enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['enabled']>;
|
|
55
|
+
queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['queryKey']>;
|
|
56
|
+
shallow?: boolean;
|
|
57
|
+
};
|
|
58
|
+
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
53
59
|
queryKey: ComputedRef<QueryKey>;
|
|
54
60
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
55
61
|
retry?(failureCount: number, error: TError): boolean;
|
|
56
62
|
}
|
|
57
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
63
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
58
64
|
context?: TClientContext;
|
|
59
65
|
} : {
|
|
60
66
|
context: TClientContext;
|
|
61
67
|
}) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
|
|
62
|
-
type MutationOptions<TInput, TOutput, TError
|
|
68
|
+
type MutationOptions<TInput, TOutput, TError, TMutationContext> = {
|
|
63
69
|
[P in keyof MutationObserverOptions<TOutput, TError, TInput, TMutationContext>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput, TMutationContext>[P]>;
|
|
64
70
|
} & {
|
|
65
71
|
shallow?: MaybeRef<boolean>;
|
|
66
72
|
};
|
|
67
73
|
|
|
68
|
-
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
74
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
69
75
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
70
76
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
71
77
|
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>>;
|
|
72
78
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
73
79
|
}
|
|
74
|
-
|
|
80
|
+
interface CreateProcedureUtilsOptions {
|
|
81
|
+
path: string[];
|
|
82
|
+
}
|
|
83
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
75
84
|
|
|
76
85
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
|
77
86
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
|
78
87
|
} & GeneralUtils<unknown>;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
|
88
|
+
interface CreateRouterUtilsOptions {
|
|
89
|
+
path?: string[];
|
|
90
|
+
}
|
|
91
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
|
|
94
|
+
[K in keyof T]: UnrefDeep<T[K]>;
|
|
95
|
+
} : T;
|
|
96
|
+
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
86
97
|
|
|
87
|
-
export {
|
|
98
|
+
export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
99
|
+
export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, 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
|
-
import { QueryKey, QueryObserverOptions, QueryFunctionContext,
|
|
3
|
-
import { PartialDeep, AnyFunction,
|
|
4
|
-
import { MaybeRef, MaybeRefOrGetter, ComputedRef } from 'vue';
|
|
2
|
+
import { QueryKey, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
3
|
+
import { PartialDeep, AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
+
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
5
5
|
|
|
6
6
|
type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
|
|
7
7
|
interface BuildKeyOptions<TType extends KeyType, TInput> {
|
|
@@ -22,7 +22,7 @@ declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput
|
|
|
22
22
|
type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
|
23
23
|
[Property in keyof T]: MaybeRefDeep<T[Property]>;
|
|
24
24
|
} : T>;
|
|
25
|
-
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
25
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = (undefined extends TInput ? {
|
|
26
26
|
input?: MaybeRefDeep<TInput>;
|
|
27
27
|
} : {
|
|
28
28
|
input: MaybeRefDeep<TInput>;
|
|
@@ -35,53 +35,65 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
35
35
|
} & {
|
|
36
36
|
enabled?: MaybeRefOrGetter<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['enabled']>;
|
|
37
37
|
queryKey?: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['queryKey']>;
|
|
38
|
-
shallow?:
|
|
38
|
+
shallow?: boolean;
|
|
39
39
|
};
|
|
40
|
-
interface QueryOptionsBase<TOutput, TError
|
|
40
|
+
interface QueryOptionsBase<TOutput, TError> {
|
|
41
41
|
queryKey: ComputedRef<QueryKey>;
|
|
42
42
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
43
43
|
retry?(failureCount: number, error: TError): boolean;
|
|
44
44
|
}
|
|
45
|
-
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
45
|
+
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
46
46
|
input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
|
|
47
47
|
} & (Record<never, never> extends TClientContext ? {
|
|
48
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
49
49
|
} : {
|
|
50
50
|
context: MaybeRefDeep<TClientContext>;
|
|
51
|
-
}) &
|
|
52
|
-
|
|
51
|
+
}) & {
|
|
52
|
+
[Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey' | 'enabled'>]: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>[Property]>;
|
|
53
|
+
} & {
|
|
54
|
+
enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['enabled']>;
|
|
55
|
+
queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['queryKey']>;
|
|
56
|
+
shallow?: boolean;
|
|
57
|
+
};
|
|
58
|
+
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
53
59
|
queryKey: ComputedRef<QueryKey>;
|
|
54
60
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
55
61
|
retry?(failureCount: number, error: TError): boolean;
|
|
56
62
|
}
|
|
57
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
63
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
58
64
|
context?: TClientContext;
|
|
59
65
|
} : {
|
|
60
66
|
context: TClientContext;
|
|
61
67
|
}) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
|
|
62
|
-
type MutationOptions<TInput, TOutput, TError
|
|
68
|
+
type MutationOptions<TInput, TOutput, TError, TMutationContext> = {
|
|
63
69
|
[P in keyof MutationObserverOptions<TOutput, TError, TInput, TMutationContext>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput, TMutationContext>[P]>;
|
|
64
70
|
} & {
|
|
65
71
|
shallow?: MaybeRef<boolean>;
|
|
66
72
|
};
|
|
67
73
|
|
|
68
|
-
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
74
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
69
75
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
70
76
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
71
77
|
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>>;
|
|
72
78
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
73
79
|
}
|
|
74
|
-
|
|
80
|
+
interface CreateProcedureUtilsOptions {
|
|
81
|
+
path: string[];
|
|
82
|
+
}
|
|
83
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
75
84
|
|
|
76
85
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
|
77
86
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
|
78
87
|
} & GeneralUtils<unknown>;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
|
88
|
+
interface CreateRouterUtilsOptions {
|
|
89
|
+
path?: string[];
|
|
90
|
+
}
|
|
91
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
|
|
94
|
+
[K in keyof T]: UnrefDeep<T[K]>;
|
|
95
|
+
} : T;
|
|
96
|
+
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
86
97
|
|
|
87
|
-
export {
|
|
98
|
+
export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
99
|
+
export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
package/dist/index.mjs
CHANGED
|
@@ -34,40 +34,41 @@ function unrefDeep(value) {
|
|
|
34
34
|
return value;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function createProcedureUtils(client,
|
|
37
|
+
function createProcedureUtils(client, options) {
|
|
38
38
|
return {
|
|
39
39
|
call: client,
|
|
40
|
-
queryOptions(...[
|
|
40
|
+
queryOptions(...[optionsIn = {}]) {
|
|
41
41
|
return {
|
|
42
|
-
queryKey: computed(() => buildKey(path, { type: "query", input: unrefDeep(
|
|
43
|
-
queryFn: ({ signal }) => client(unrefDeep(
|
|
44
|
-
...
|
|
42
|
+
queryKey: computed(() => buildKey(options.path, { type: "query", input: unrefDeep(optionsIn.input) })),
|
|
43
|
+
queryFn: ({ signal }) => client(unrefDeep(optionsIn.input), { signal, context: unrefDeep(optionsIn.context) }),
|
|
44
|
+
...optionsIn
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
|
-
infiniteOptions(
|
|
47
|
+
infiniteOptions(optionsIn) {
|
|
48
48
|
return {
|
|
49
49
|
queryKey: computed(() => {
|
|
50
|
-
return buildKey(path, { type: "infinite", input: unrefDeep(
|
|
50
|
+
return buildKey(options.path, { type: "infinite", input: unrefDeep(optionsIn.input(unrefDeep(optionsIn.initialPageParam))) });
|
|
51
51
|
}),
|
|
52
52
|
queryFn: ({ pageParam, signal }) => {
|
|
53
|
-
return client(unrefDeep(
|
|
53
|
+
return client(unrefDeep(optionsIn.input(pageParam)), { signal, context: unrefDeep(optionsIn.context) });
|
|
54
54
|
},
|
|
55
|
-
...
|
|
55
|
+
...optionsIn
|
|
56
56
|
};
|
|
57
57
|
},
|
|
58
|
-
mutationOptions(...[
|
|
58
|
+
mutationOptions(...[optionsIn = {}]) {
|
|
59
59
|
return {
|
|
60
|
-
mutationKey: buildKey(path, { type: "mutation" }),
|
|
61
|
-
mutationFn: (input) => client(input, { context: unrefDeep(
|
|
62
|
-
...
|
|
60
|
+
mutationKey: buildKey(options.path, { type: "mutation" }),
|
|
61
|
+
mutationFn: (input) => client(input, { context: unrefDeep(optionsIn.context) }),
|
|
62
|
+
...optionsIn
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function createRouterUtils(client,
|
|
68
|
+
function createRouterUtils(client, options = {}) {
|
|
69
|
+
const path = options.path ?? [];
|
|
69
70
|
const generalUtils = createGeneralUtils(path);
|
|
70
|
-
const procedureUtils = createProcedureUtils(client, path);
|
|
71
|
+
const procedureUtils = createProcedureUtils(client, { path });
|
|
71
72
|
const recursive = new Proxy({
|
|
72
73
|
...generalUtils,
|
|
73
74
|
...procedureUtils
|
|
@@ -77,7 +78,7 @@ function createRouterUtils(client, path = []) {
|
|
|
77
78
|
if (typeof prop !== "string") {
|
|
78
79
|
return value;
|
|
79
80
|
}
|
|
80
|
-
const nextUtils = createRouterUtils(client[prop], [...path, prop]);
|
|
81
|
+
const nextUtils = createRouterUtils(client[prop], { ...options, path: [...path, prop] });
|
|
81
82
|
if (typeof value !== "function") {
|
|
82
83
|
return nextUtils;
|
|
83
84
|
}
|
|
@@ -91,6 +92,4 @@ function createRouterUtils(client, path = []) {
|
|
|
91
92
|
return recursive;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
export { buildKey, createGeneralUtils, createORPCVueQueryUtils, createProcedureUtils, createRouterUtils };
|
|
95
|
+
export { buildKey, 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.e0f01a5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@tanstack/vue-query": ">=5.
|
|
30
|
+
"@tanstack/vue-query": ">=5.55.0",
|
|
31
31
|
"vue": ">=3.3.0",
|
|
32
|
-
"@orpc/client": "0.0.0-next.
|
|
32
|
+
"@orpc/client": "0.0.0-next.e0f01a5"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@
|
|
35
|
+
"@tanstack/vue-query": "^5.72.2",
|
|
36
|
+
"@orpc/shared": "0.0.0-next.e0f01a5"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {
|
|
38
39
|
"build": "unbuild",
|