@orpc/vue-query 0.0.0-next.67ca77c → 0.0.0-next.6acfc62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
@@ -54,6 +54,7 @@ function createProcedureUtils(client, path) {
|
|
54
54
|
infiniteOptions(options) {
|
55
55
|
const input = options.input;
|
56
56
|
return {
|
57
|
+
initialPageParam: void 0,
|
57
58
|
queryKey: computed(() => buildKey(path, { type: "infinite", input: deepUnref(input) })),
|
58
59
|
queryFn: ({ pageParam, signal }) => {
|
59
60
|
return client({ ...deepUnref(input), cursor: pageParam }, { signal, context: deepUnref(options.context) });
|
package/dist/src/types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { AnyFunction, SetOptional } from '@orpc/shared';
|
2
|
-
import type {
|
3
|
-
import type { MaybeRef, MaybeRefOrGetter } from 'vue';
|
2
|
+
import type { MutationObserverOptions, QueryFunctionContext, QueryKey, QueryObserverOptions, UseInfiniteQueryOptions } from '@tanstack/vue-query';
|
3
|
+
import type { ComputedRef, MaybeRef, MaybeRefOrGetter } from 'vue';
|
4
4
|
export type MaybeDeepRef<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
5
5
|
[K in keyof T]: MaybeDeepRef<T[K]>;
|
6
6
|
} : T>;
|
@@ -8,7 +8,7 @@ export type NonUndefinedGuard<T> = T extends undefined ? never : T;
|
|
8
8
|
export type InferCursor<T> = T extends {
|
9
9
|
cursor?: any;
|
10
10
|
} ? T['cursor'] : never;
|
11
|
-
export type
|
11
|
+
export type QueryOptionsExtra<TClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
|
12
12
|
input?: MaybeDeepRef<TInput>;
|
13
13
|
} : {
|
14
14
|
input: MaybeDeepRef<TInput>;
|
@@ -17,12 +17,17 @@ export type QueryOptions<TInput, TOutput, TClientContext, TSelectData> = (undefi
|
|
17
17
|
} : {
|
18
18
|
context: MaybeDeepRef<TClientContext>;
|
19
19
|
}) & SetOptional<{
|
20
|
-
[P in keyof QueryObserverOptions<TOutput,
|
20
|
+
[P in keyof QueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey>]: P extends 'enabled' ? MaybeRefOrGetter<QueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey>[P]> : MaybeDeepRef<QueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey>[P]>;
|
21
21
|
}, 'queryKey'> & {
|
22
22
|
shallow?: MaybeRef<boolean>;
|
23
23
|
initialData?: NonUndefinedGuard<TOutput> | (() => NonUndefinedGuard<TOutput>) | undefined;
|
24
24
|
};
|
25
|
-
export
|
25
|
+
export interface QueryOptionsBase<TOutput, TError extends Error> {
|
26
|
+
queryKey: ComputedRef<QueryKey>;
|
27
|
+
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
28
|
+
retry?(failureCount: number, error: TError): boolean;
|
29
|
+
}
|
30
|
+
export type InfiniteOptionsExtra<TClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
|
26
31
|
input?: MaybeDeepRef<Omit<TInput, 'cursor'>>;
|
27
32
|
} : {
|
28
33
|
input: MaybeDeepRef<Omit<TInput, 'cursor'>>;
|
@@ -30,14 +35,25 @@ export type InfiniteOptions<TInput, TOutput, TClientContext, TSelectData> = (und
|
|
30
35
|
context?: MaybeDeepRef<TClientContext>;
|
31
36
|
} : {
|
32
37
|
context: MaybeDeepRef<TClientContext>;
|
33
|
-
}) & SetOptional<UseInfiniteQueryOptions<TOutput,
|
34
|
-
export
|
38
|
+
}) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, InferCursor<TInput>>, 'queryKey' | (undefined extends InferCursor<TInput> ? 'initialPageParam' : never)>;
|
39
|
+
export interface InfiniteOptionsBase<TInput, TOutput, TError extends Error> {
|
40
|
+
queryKey: ComputedRef<QueryKey>;
|
41
|
+
queryFn(ctx: QueryFunctionContext<QueryKey, InferCursor<TInput>>): Promise<TOutput>;
|
42
|
+
initialPageParam: undefined;
|
43
|
+
retry?(failureCount: number, error: TError): boolean;
|
44
|
+
}
|
45
|
+
export type MutationOptionsExtra<TClientContext, TInput, TOutput, TError extends Error> = (undefined extends TClientContext ? {
|
35
46
|
context?: MaybeDeepRef<TClientContext>;
|
36
47
|
} : {
|
37
48
|
context: MaybeDeepRef<TClientContext>;
|
38
49
|
}) & {
|
39
|
-
[P in keyof MutationObserverOptions<TOutput,
|
50
|
+
[P in keyof MutationObserverOptions<TOutput, TError, TInput, unknown>]: MaybeDeepRef<MutationObserverOptions<TOutput, TError, TInput, unknown>[P]>;
|
40
51
|
} & {
|
41
52
|
shallow?: MaybeRef<boolean>;
|
42
53
|
};
|
54
|
+
export interface MutationOptionsBase<TInput, TOutput, TError extends Error> {
|
55
|
+
mutationKey: QueryKey;
|
56
|
+
mutationFn(input: TInput): Promise<TOutput>;
|
57
|
+
retry?(failureCount: number, error: TError): boolean;
|
58
|
+
}
|
43
59
|
//# sourceMappingURL=types.d.ts.map
|
@@ -5,7 +5,7 @@ import type { MaybeDeepRef } from './types';
|
|
5
5
|
* Utils at any level (procedure or router)
|
6
6
|
*/
|
7
7
|
export interface GeneralUtils<TInput> {
|
8
|
-
key
|
8
|
+
key<UType extends KeyType = undefined>(options?: MaybeDeepRef<BuildKeyOptions<UType, TInput>>): QueryKey;
|
9
9
|
}
|
10
10
|
export declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
11
11
|
//# sourceMappingURL=utils-general.d.ts.map
|
@@ -1,31 +1,13 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Client } from '@orpc/contract';
|
2
2
|
import type { IsEqual } from '@orpc/shared';
|
3
|
-
import type {
|
4
|
-
import type { ComputedRef } from 'vue';
|
5
|
-
import type { InferCursor, InfiniteOptions, MutationOptions, QueryOptions } from './types';
|
3
|
+
import type { InfiniteOptionsBase, InfiniteOptionsExtra, MutationOptionsBase, MutationOptionsExtra, QueryOptionsBase, QueryOptionsExtra } from './types';
|
6
4
|
/**
|
7
5
|
* Utils at procedure level
|
8
6
|
*/
|
9
|
-
export interface ProcedureUtils<TInput, TOutput,
|
10
|
-
queryOptions
|
11
|
-
|
12
|
-
|
13
|
-
} : Omit<{
|
14
|
-
queryKey: ComputedRef<QueryKey>;
|
15
|
-
queryFn: (ctx: QueryFunctionContext) => Promise<TOutput>;
|
16
|
-
}, keyof U> & U;
|
17
|
-
infiniteOptions: <U extends InfiniteOptions<TInput, TOutput, TClientContext, any>>(options: U) => Omit<{
|
18
|
-
queryKey: ComputedRef<QueryKey>;
|
19
|
-
queryFn: (ctx: QueryFunctionContext<QueryKey, InferCursor<TInput>>) => Promise<TOutput>;
|
20
|
-
initialPageParam: undefined;
|
21
|
-
}, keyof U> & U;
|
22
|
-
mutationOptions: <U extends MutationOptions<TInput, TOutput, TClientContext>>(...opt: [options: U] | (undefined extends TClientContext ? [] : never)) => IsEqual<U, MutationOptions<TInput, TOutput, TClientContext>> extends true ? {
|
23
|
-
mutationKey: QueryKey;
|
24
|
-
mutationFn: (input: TInput) => Promise<TOutput>;
|
25
|
-
} : Omit<{
|
26
|
-
mutationKey: QueryKey;
|
27
|
-
mutationFn: (input: TInput) => Promise<TOutput>;
|
28
|
-
}, keyof U> & U;
|
7
|
+
export interface ProcedureUtils<TClientContext, TInput, TOutput, TError extends Error> {
|
8
|
+
queryOptions<U extends QueryOptionsExtra<TClientContext, TInput, TOutput, TError, any>>(...opt: [options: U] | (undefined extends TInput & TClientContext ? [] : never)): IsEqual<U, QueryOptionsExtra<TClientContext, TInput, TOutput, TError, any>> extends true ? QueryOptionsBase<TOutput, TError> : Omit<QueryOptionsBase<TOutput, TError>, keyof U> & U;
|
9
|
+
infiniteOptions<U extends InfiniteOptionsExtra<TClientContext, TInput, TOutput, TError, any>>(options: U): Omit<InfiniteOptionsBase<TInput, TOutput, TError>, keyof U> & U;
|
10
|
+
mutationOptions<U extends MutationOptionsExtra<TClientContext, TInput, TOutput, TError>>(...opt: [options: U] | (undefined extends TClientContext ? [] : never)): IsEqual<U, MutationOptionsExtra<TClientContext, TInput, TOutput, TError>> extends true ? MutationOptionsBase<TInput, TOutput, TError> : Omit<MutationOptionsBase<TInput, TOutput, TError>, keyof U> & U;
|
29
11
|
}
|
30
|
-
export declare function createProcedureUtils<TInput, TOutput,
|
12
|
+
export declare function createProcedureUtils<TClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
31
13
|
//# sourceMappingURL=utils-procedure.d.ts.map
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Client, NestedClient } from '@orpc/contract';
|
2
2
|
import { type GeneralUtils } from './utils-general';
|
3
3
|
import { type ProcedureUtils } from './utils-procedure';
|
4
|
-
export type RouterUtils<T extends
|
5
|
-
[K in keyof T]: T[K] extends
|
4
|
+
export type RouterUtils<T extends NestedClient<any>> = T extends Client<infer TClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<TClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
5
|
+
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
6
6
|
} & GeneralUtils<unknown>;
|
7
7
|
/**
|
8
8
|
* @param client - The client create form `@orpc/client`
|
9
9
|
* @param path - The base path for query key
|
10
10
|
*/
|
11
|
-
export declare function createRouterUtils<T extends
|
11
|
+
export declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
12
12
|
//# sourceMappingURL=utils-router.d.ts.map
|
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.6acfc62",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -34,9 +34,8 @@
|
|
34
34
|
"peerDependencies": {
|
35
35
|
"@tanstack/vue-query": ">=5.50.0",
|
36
36
|
"vue": ">=3.3.0",
|
37
|
-
"@orpc/client": "0.0.0-next.
|
38
|
-
"@orpc/contract": "0.0.0-next.
|
39
|
-
"@orpc/server": "0.0.0-next.67ca77c"
|
37
|
+
"@orpc/client": "0.0.0-next.6acfc62",
|
38
|
+
"@orpc/contract": "0.0.0-next.6acfc62"
|
40
39
|
},
|
41
40
|
"scripts": {
|
42
41
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|