@orpc/vue-query 0.42.0 → 0.44.0
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 +1 -1
- package/dist/index.d.mts +91 -0
- package/dist/index.d.ts +91 -0
- package/dist/{index.js → index.mjs} +6 -20
- package/package.json +7 -12
- package/dist/src/general-utils.d.ts +0 -7
- package/dist/src/index.d.ts +0 -8
- package/dist/src/key.d.ts +0 -9
- package/dist/src/procedure-utils.d.ts +0 -12
- package/dist/src/router-utils.d.ts +0 -12
- package/dist/src/types.d.ts +0 -58
- package/dist/src/utils.d.ts +0 -7
package/README.md
CHANGED
package/dist/index.d.mts
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
2
|
+
import { QueryKey, QueryObserverOptions, Enabled, QueryFunctionContext, UseInfiniteQueryOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
3
|
+
import { PartialDeep, AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { MaybeRef, MaybeRefOrGetter, ComputedRef } from 'vue';
|
5
|
+
|
6
|
+
type KeyType = 'query' | '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
|
+
interface GeneralUtils<TInput> {
|
14
|
+
key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
|
15
|
+
}
|
16
|
+
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Since `@tanstack/vue-query` is not exporting the type `MaybeRefDeep` we need to copy it from the source code.
|
20
|
+
* https://github.com/TanStack/query/blob/7ff544e12e79388e513b1cd886aeb946f80f0153/packages/vue-query/src/types.ts#L19C1-L27C2
|
21
|
+
*/
|
22
|
+
type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
23
|
+
[Property in keyof T]: MaybeRefDeep<T[Property]>;
|
24
|
+
} : T>;
|
25
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
|
26
|
+
input?: MaybeRefDeep<TInput>;
|
27
|
+
} : {
|
28
|
+
input: MaybeRefDeep<TInput>;
|
29
|
+
}) & (Record<never, never> extends TClientContext ? {
|
30
|
+
context?: MaybeRefDeep<TClientContext>;
|
31
|
+
} : {
|
32
|
+
context: MaybeRefDeep<TClientContext>;
|
33
|
+
}) & {
|
34
|
+
[P in keyof Omit<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>, 'queryKey' | 'enabled'>]: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>[P]>;
|
35
|
+
} & {
|
36
|
+
enabled?: MaybeRefOrGetter<Enabled<TOutput, TError, TSelectData>>;
|
37
|
+
queryKey?: MaybeRefDeep<QueryKey>;
|
38
|
+
shallow?: boolean;
|
39
|
+
};
|
40
|
+
interface QueryOptionsBase<TOutput, TError extends Error> {
|
41
|
+
queryKey: ComputedRef<QueryKey>;
|
42
|
+
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
43
|
+
retry?(failureCount: number, error: TError): boolean;
|
44
|
+
}
|
45
|
+
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
|
46
|
+
input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
|
47
|
+
} & (Record<never, never> extends TClientContext ? {
|
48
|
+
context?: MaybeRefDeep<TClientContext>;
|
49
|
+
} : {
|
50
|
+
context: MaybeRefDeep<TClientContext>;
|
51
|
+
}) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
|
52
|
+
interface InfiniteOptionsBase<TOutput, TError extends Error, TPageParam> {
|
53
|
+
queryKey: ComputedRef<QueryKey>;
|
54
|
+
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
55
|
+
retry?(failureCount: number, error: TError): boolean;
|
56
|
+
}
|
57
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (Record<never, never> extends TClientContext ? {
|
58
|
+
context?: TClientContext;
|
59
|
+
} : {
|
60
|
+
context: TClientContext;
|
61
|
+
}) & {
|
62
|
+
[P in keyof MutationObserverOptions<TOutput, TError, TInput>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput>[P]>;
|
63
|
+
} & {
|
64
|
+
shallow?: MaybeRef<boolean>;
|
65
|
+
};
|
66
|
+
interface MutationOptionsBase<TInput, TOutput, TError extends Error> {
|
67
|
+
mutationKey: QueryKey;
|
68
|
+
mutationFn(input: TInput): Promise<TOutput>;
|
69
|
+
retry?(failureCount: number, error: TError): boolean;
|
70
|
+
}
|
71
|
+
|
72
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
73
|
+
call: Client<TClientContext, TInput, TOutput, TError>;
|
74
|
+
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & QueryOptionsBase<TOutput, TError>>;
|
75
|
+
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>;
|
76
|
+
mutationOptions<U>(...rest: MaybeOptionalOptions<U & MutationOptionsIn<TClientContext, TInput, TOutput, TError>>): NoInfer<U & MutationOptionsBase<TInput, TOutput, TError>>;
|
77
|
+
}
|
78
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
79
|
+
|
80
|
+
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
81
|
+
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
82
|
+
} & GeneralUtils<unknown>;
|
83
|
+
/**
|
84
|
+
* @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
|
85
|
+
* @param path - The base path for query key, when it it will be prefix to all keys
|
86
|
+
*/
|
87
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
88
|
+
|
89
|
+
declare const createORPCVueQueryUtils: typeof createRouterUtils;
|
90
|
+
|
91
|
+
export { type BuildKeyOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MaybeRefDeep, type MutationOptionsBase, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, buildKey, createGeneralUtils, createORPCVueQueryUtils, createProcedureUtils, createRouterUtils };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
2
|
+
import { QueryKey, QueryObserverOptions, Enabled, QueryFunctionContext, UseInfiniteQueryOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
3
|
+
import { PartialDeep, AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { MaybeRef, MaybeRefOrGetter, ComputedRef } from 'vue';
|
5
|
+
|
6
|
+
type KeyType = 'query' | '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
|
+
interface GeneralUtils<TInput> {
|
14
|
+
key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
|
15
|
+
}
|
16
|
+
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Since `@tanstack/vue-query` is not exporting the type `MaybeRefDeep` we need to copy it from the source code.
|
20
|
+
* https://github.com/TanStack/query/blob/7ff544e12e79388e513b1cd886aeb946f80f0153/packages/vue-query/src/types.ts#L19C1-L27C2
|
21
|
+
*/
|
22
|
+
type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
23
|
+
[Property in keyof T]: MaybeRefDeep<T[Property]>;
|
24
|
+
} : T>;
|
25
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
|
26
|
+
input?: MaybeRefDeep<TInput>;
|
27
|
+
} : {
|
28
|
+
input: MaybeRefDeep<TInput>;
|
29
|
+
}) & (Record<never, never> extends TClientContext ? {
|
30
|
+
context?: MaybeRefDeep<TClientContext>;
|
31
|
+
} : {
|
32
|
+
context: MaybeRefDeep<TClientContext>;
|
33
|
+
}) & {
|
34
|
+
[P in keyof Omit<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>, 'queryKey' | 'enabled'>]: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>[P]>;
|
35
|
+
} & {
|
36
|
+
enabled?: MaybeRefOrGetter<Enabled<TOutput, TError, TSelectData>>;
|
37
|
+
queryKey?: MaybeRefDeep<QueryKey>;
|
38
|
+
shallow?: boolean;
|
39
|
+
};
|
40
|
+
interface QueryOptionsBase<TOutput, TError extends Error> {
|
41
|
+
queryKey: ComputedRef<QueryKey>;
|
42
|
+
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
43
|
+
retry?(failureCount: number, error: TError): boolean;
|
44
|
+
}
|
45
|
+
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
|
46
|
+
input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
|
47
|
+
} & (Record<never, never> extends TClientContext ? {
|
48
|
+
context?: MaybeRefDeep<TClientContext>;
|
49
|
+
} : {
|
50
|
+
context: MaybeRefDeep<TClientContext>;
|
51
|
+
}) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
|
52
|
+
interface InfiniteOptionsBase<TOutput, TError extends Error, TPageParam> {
|
53
|
+
queryKey: ComputedRef<QueryKey>;
|
54
|
+
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
55
|
+
retry?(failureCount: number, error: TError): boolean;
|
56
|
+
}
|
57
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (Record<never, never> extends TClientContext ? {
|
58
|
+
context?: TClientContext;
|
59
|
+
} : {
|
60
|
+
context: TClientContext;
|
61
|
+
}) & {
|
62
|
+
[P in keyof MutationObserverOptions<TOutput, TError, TInput>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput>[P]>;
|
63
|
+
} & {
|
64
|
+
shallow?: MaybeRef<boolean>;
|
65
|
+
};
|
66
|
+
interface MutationOptionsBase<TInput, TOutput, TError extends Error> {
|
67
|
+
mutationKey: QueryKey;
|
68
|
+
mutationFn(input: TInput): Promise<TOutput>;
|
69
|
+
retry?(failureCount: number, error: TError): boolean;
|
70
|
+
}
|
71
|
+
|
72
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
73
|
+
call: Client<TClientContext, TInput, TOutput, TError>;
|
74
|
+
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & QueryOptionsBase<TOutput, TError>>;
|
75
|
+
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>;
|
76
|
+
mutationOptions<U>(...rest: MaybeOptionalOptions<U & MutationOptionsIn<TClientContext, TInput, TOutput, TError>>): NoInfer<U & MutationOptionsBase<TInput, TOutput, TError>>;
|
77
|
+
}
|
78
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
79
|
+
|
80
|
+
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
81
|
+
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
82
|
+
} & GeneralUtils<unknown>;
|
83
|
+
/**
|
84
|
+
* @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
|
85
|
+
* @param path - The base path for query key, when it it will be prefix to all keys
|
86
|
+
*/
|
87
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
88
|
+
|
89
|
+
declare const createORPCVueQueryUtils: typeof createRouterUtils;
|
90
|
+
|
91
|
+
export { type BuildKeyOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MaybeRefDeep, type MutationOptionsBase, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, buildKey, createGeneralUtils, createORPCVueQueryUtils, createProcedureUtils, createRouterUtils };
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
import { isRef, computed } from 'vue';
|
2
|
+
import { isObject } from '@orpc/shared';
|
3
|
+
|
2
4
|
function buildKey(path, options) {
|
3
5
|
const withInput = options?.input !== void 0 ? { input: options?.input } : {};
|
4
6
|
const withType = options?.type !== void 0 ? { type: options?.type } : {};
|
@@ -8,7 +10,6 @@ function buildKey(path, options) {
|
|
8
10
|
}];
|
9
11
|
}
|
10
12
|
|
11
|
-
// src/general-utils.ts
|
12
13
|
function createGeneralUtils(path) {
|
13
14
|
return {
|
14
15
|
key(options) {
|
@@ -17,12 +18,6 @@ function createGeneralUtils(path) {
|
|
17
18
|
};
|
18
19
|
}
|
19
20
|
|
20
|
-
// src/procedure-utils.ts
|
21
|
-
import { computed } from "vue";
|
22
|
-
|
23
|
-
// src/utils.ts
|
24
|
-
import { isObject } from "@orpc/shared";
|
25
|
-
import { isRef } from "vue";
|
26
21
|
function unrefDeep(value) {
|
27
22
|
if (isRef(value)) {
|
28
23
|
return unrefDeep(value.value);
|
@@ -39,7 +34,6 @@ function unrefDeep(value) {
|
|
39
34
|
return value;
|
40
35
|
}
|
41
36
|
|
42
|
-
// src/procedure-utils.ts
|
43
37
|
function createProcedureUtils(client, path) {
|
44
38
|
return {
|
45
39
|
call: client,
|
@@ -71,7 +65,6 @@ function createProcedureUtils(client, path) {
|
|
71
65
|
};
|
72
66
|
}
|
73
67
|
|
74
|
-
// src/router-utils.ts
|
75
68
|
function createRouterUtils(client, path = []) {
|
76
69
|
const generalUtils = createGeneralUtils(path);
|
77
70
|
const procedureUtils = createProcedureUtils(client, path);
|
@@ -98,13 +91,6 @@ function createRouterUtils(client, path = []) {
|
|
98
91
|
return recursive;
|
99
92
|
}
|
100
93
|
|
101
|
-
|
102
|
-
|
103
|
-
export {
|
104
|
-
buildKey,
|
105
|
-
createGeneralUtils,
|
106
|
-
createORPCVueQueryUtils,
|
107
|
-
createProcedureUtils,
|
108
|
-
createRouterUtils
|
109
|
-
};
|
110
|
-
//# sourceMappingURL=index.js.map
|
94
|
+
const createORPCVueQueryUtils = createRouterUtils;
|
95
|
+
|
96
|
+
export { buildKey, createGeneralUtils, createORPCVueQueryUtils, createProcedureUtils, createRouterUtils };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/vue-query",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.44.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -18,29 +18,24 @@
|
|
18
18
|
],
|
19
19
|
"exports": {
|
20
20
|
".": {
|
21
|
-
"types": "./dist/
|
22
|
-
"import": "./dist/index.
|
23
|
-
"default": "./dist/index.
|
24
|
-
},
|
25
|
-
"./🔒/*": {
|
26
|
-
"types": "./dist/src/*.d.ts"
|
21
|
+
"types": "./dist/index.d.mts",
|
22
|
+
"import": "./dist/index.mjs",
|
23
|
+
"default": "./dist/index.mjs"
|
27
24
|
}
|
28
25
|
},
|
29
26
|
"files": [
|
30
|
-
"!**/*.map",
|
31
|
-
"!**/*.tsbuildinfo",
|
32
27
|
"dist"
|
33
28
|
],
|
34
29
|
"peerDependencies": {
|
35
30
|
"@tanstack/vue-query": ">=5.50.0",
|
36
31
|
"vue": ">=3.3.0",
|
37
|
-
"@orpc/client": "0.
|
32
|
+
"@orpc/client": "0.44.0"
|
38
33
|
},
|
39
34
|
"dependencies": {
|
40
|
-
"@orpc/shared": "0.
|
35
|
+
"@orpc/shared": "0.44.0"
|
41
36
|
},
|
42
37
|
"scripts": {
|
43
|
-
"build": "
|
38
|
+
"build": "unbuild",
|
44
39
|
"build:watch": "pnpm run build --watch",
|
45
40
|
"type:check": "tsc -b"
|
46
41
|
}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { QueryKey } from '@tanstack/vue-query';
|
2
|
-
import type { BuildKeyOptions, KeyType } from './key';
|
3
|
-
export interface GeneralUtils<TInput> {
|
4
|
-
key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
|
5
|
-
}
|
6
|
-
export declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
7
|
-
//# sourceMappingURL=general-utils.d.ts.map
|
package/dist/src/index.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import { createRouterUtils } from './router-utils';
|
2
|
-
export * from './general-utils';
|
3
|
-
export * from './key';
|
4
|
-
export * from './procedure-utils';
|
5
|
-
export * from './router-utils';
|
6
|
-
export * from './types';
|
7
|
-
export declare const createORPCVueQueryUtils: typeof createRouterUtils;
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/key.d.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import type { PartialDeep } from '@orpc/shared';
|
2
|
-
import type { QueryKey } from '@tanstack/vue-query';
|
3
|
-
export type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
|
4
|
-
export interface BuildKeyOptions<TType extends KeyType, TInput> {
|
5
|
-
type?: TType;
|
6
|
-
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
7
|
-
}
|
8
|
-
export declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
|
9
|
-
//# sourceMappingURL=key.d.ts.map
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { Client, ClientContext } from '@orpc/client';
|
2
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
3
|
-
import type { InfiniteData } from '@tanstack/vue-query';
|
4
|
-
import type { InfiniteOptionsBase, InfiniteOptionsIn, MutationOptionsBase, MutationOptionsIn, QueryOptionsBase, QueryOptionsIn } from './types';
|
5
|
-
export interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
6
|
-
call: Client<TClientContext, TInput, TOutput, TError>;
|
7
|
-
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & QueryOptionsBase<TOutput, TError>>;
|
8
|
-
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>;
|
9
|
-
mutationOptions<U>(...rest: MaybeOptionalOptions<U & MutationOptionsIn<TClientContext, TInput, TOutput, TError>>): NoInfer<U & MutationOptionsBase<TInput, TOutput, TError>>;
|
10
|
-
}
|
11
|
-
export declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
12
|
-
//# sourceMappingURL=procedure-utils.d.ts.map
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { Client, NestedClient } from '@orpc/client';
|
2
|
-
import { type GeneralUtils } from './general-utils';
|
3
|
-
import { type ProcedureUtils } from './procedure-utils';
|
4
|
-
export type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
5
|
-
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
6
|
-
} & GeneralUtils<unknown>;
|
7
|
-
/**
|
8
|
-
* @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
|
9
|
-
* @param path - The base path for query key, when it it will be prefix to all keys
|
10
|
-
*/
|
11
|
-
export declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
12
|
-
//# sourceMappingURL=router-utils.d.ts.map
|
package/dist/src/types.d.ts
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
import type { ClientContext } from '@orpc/client';
|
2
|
-
import type { AnyFunction, SetOptional } from '@orpc/shared';
|
3
|
-
import type { Enabled, MutationObserverOptions, QueryFunctionContext, QueryKey, QueryObserverOptions, UseInfiniteQueryOptions } from '@tanstack/vue-query';
|
4
|
-
import type { ComputedRef, MaybeRef, MaybeRefOrGetter } from 'vue';
|
5
|
-
/**
|
6
|
-
* Since `@tanstack/vue-query` is not exporting the type `MaybeRefDeep` we need to copy it from the source code.
|
7
|
-
* https://github.com/TanStack/query/blob/7ff544e12e79388e513b1cd886aeb946f80f0153/packages/vue-query/src/types.ts#L19C1-L27C2
|
8
|
-
*/
|
9
|
-
export type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
10
|
-
[Property in keyof T]: MaybeRefDeep<T[Property]>;
|
11
|
-
} : T>;
|
12
|
-
export type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
|
13
|
-
input?: MaybeRefDeep<TInput>;
|
14
|
-
} : {
|
15
|
-
input: MaybeRefDeep<TInput>;
|
16
|
-
}) & (Record<never, never> extends TClientContext ? {
|
17
|
-
context?: MaybeRefDeep<TClientContext>;
|
18
|
-
} : {
|
19
|
-
context: MaybeRefDeep<TClientContext>;
|
20
|
-
}) & {
|
21
|
-
[P in keyof Omit<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>, 'queryKey' | 'enabled'>]: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>[P]>;
|
22
|
-
} & {
|
23
|
-
enabled?: MaybeRefOrGetter<Enabled<TOutput, TError, TSelectData>>;
|
24
|
-
queryKey?: MaybeRefDeep<QueryKey>;
|
25
|
-
shallow?: boolean;
|
26
|
-
};
|
27
|
-
export interface QueryOptionsBase<TOutput, TError extends Error> {
|
28
|
-
queryKey: ComputedRef<QueryKey>;
|
29
|
-
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
30
|
-
retry?(failureCount: number, error: TError): boolean;
|
31
|
-
}
|
32
|
-
export type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
|
33
|
-
input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
|
34
|
-
} & (Record<never, never> extends TClientContext ? {
|
35
|
-
context?: MaybeRefDeep<TClientContext>;
|
36
|
-
} : {
|
37
|
-
context: MaybeRefDeep<TClientContext>;
|
38
|
-
}) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
|
39
|
-
export interface InfiniteOptionsBase<TOutput, TError extends Error, TPageParam> {
|
40
|
-
queryKey: ComputedRef<QueryKey>;
|
41
|
-
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
42
|
-
retry?(failureCount: number, error: TError): boolean;
|
43
|
-
}
|
44
|
-
export type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (Record<never, never> extends TClientContext ? {
|
45
|
-
context?: TClientContext;
|
46
|
-
} : {
|
47
|
-
context: TClientContext;
|
48
|
-
}) & {
|
49
|
-
[P in keyof MutationObserverOptions<TOutput, TError, TInput>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput>[P]>;
|
50
|
-
} & {
|
51
|
-
shallow?: MaybeRef<boolean>;
|
52
|
-
};
|
53
|
-
export interface MutationOptionsBase<TInput, TOutput, TError extends Error> {
|
54
|
-
mutationKey: QueryKey;
|
55
|
-
mutationFn(input: TInput): Promise<TOutput>;
|
56
|
-
retry?(failureCount: number, error: TError): boolean;
|
57
|
-
}
|
58
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/utils.d.ts
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { Ref } from 'vue';
|
2
|
-
import { type AnyFunction } from '@orpc/shared';
|
3
|
-
export type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
|
4
|
-
[K in keyof T]: UnrefDeep<T[K]>;
|
5
|
-
} : T;
|
6
|
-
export declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
7
|
-
//# sourceMappingURL=utils.d.ts.map
|