@orpc/vue-query 0.0.0-next.7b09958 → 0.0.0-next.7d3bd71
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
|
@@ -8,16 +8,20 @@ function buildKey(path, options) {
|
|
|
8
8
|
}];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
// src/general-utils.ts
|
|
12
|
+
function createGeneralUtils(path) {
|
|
13
|
+
return {
|
|
14
|
+
key(options) {
|
|
15
|
+
return buildKey(path, options);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// src/procedure-utils.ts
|
|
21
|
+
import { computed } from "vue";
|
|
22
|
+
|
|
20
23
|
// src/utils.ts
|
|
24
|
+
import { isObject } from "@orpc/shared";
|
|
21
25
|
import { isRef } from "vue";
|
|
22
26
|
function unrefDeep(value) {
|
|
23
27
|
if (isRef(value)) {
|
|
@@ -35,19 +39,10 @@ function unrefDeep(value) {
|
|
|
35
39
|
return value;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
// src/general-utils.ts
|
|
39
|
-
function createGeneralUtils(path) {
|
|
40
|
-
return {
|
|
41
|
-
key(options) {
|
|
42
|
-
return buildKey(path, unrefDeep(options));
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
42
|
// src/procedure-utils.ts
|
|
48
|
-
import { computed } from "vue";
|
|
49
43
|
function createProcedureUtils(client, path) {
|
|
50
44
|
return {
|
|
45
|
+
call: client,
|
|
51
46
|
queryOptions(...[{ input, context, ...rest } = {}]) {
|
|
52
47
|
return {
|
|
53
48
|
queryKey: computed(() => buildKey(path, { type: "query", input: unrefDeep(input) })),
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { QueryKey } from '@tanstack/vue-query';
|
|
2
2
|
import type { BuildKeyOptions, KeyType } from './key';
|
|
3
|
-
import type { MaybeRefDeep } from './types';
|
|
4
3
|
export interface GeneralUtils<TInput> {
|
|
5
|
-
key<UType extends KeyType = undefined>(options?:
|
|
4
|
+
key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
|
|
6
5
|
}
|
|
7
6
|
export declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
8
7
|
//# sourceMappingURL=general-utils.d.ts.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { Client } from '@orpc/
|
|
1
|
+
import type { Client, ClientContext } from '@orpc/client';
|
|
2
2
|
import type { MaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import type { InfiniteData } from '@tanstack/vue-query';
|
|
4
4
|
import type { InfiniteOptionsBase, InfiniteOptionsIn, MutationOptionsBase, MutationOptionsIn, QueryOptionsBase, QueryOptionsIn } from './types';
|
|
5
|
-
export interface ProcedureUtils<TClientContext, TInput, TOutput, TError extends Error> {
|
|
5
|
+
export interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
|
6
|
+
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
6
7
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & QueryOptionsBase<TOutput, TError>>;
|
|
7
|
-
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>;
|
|
8
|
+
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>;
|
|
8
9
|
mutationOptions<U>(...rest: MaybeOptionalOptions<U & MutationOptionsIn<TClientContext, TInput, TOutput, TError>>): NoInfer<U & MutationOptionsBase<TInput, TOutput, TError>>;
|
|
9
10
|
}
|
|
10
|
-
export declare function createProcedureUtils<TClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
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>;
|
|
11
12
|
//# sourceMappingURL=procedure-utils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Client, NestedClient } from '@orpc/
|
|
1
|
+
import type { Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { type GeneralUtils } from './general-utils';
|
|
3
3
|
import { type ProcedureUtils } from './procedure-utils';
|
|
4
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> : {
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ClientContext } from '@orpc/client';
|
|
1
2
|
import type { AnyFunction, SetOptional } from '@orpc/shared';
|
|
2
3
|
import type { Enabled, MutationObserverOptions, QueryFunctionContext, QueryKey, QueryObserverOptions, UseInfiniteQueryOptions } from '@tanstack/vue-query';
|
|
3
4
|
import type { ComputedRef, MaybeRef, MaybeRefOrGetter } from 'vue';
|
|
@@ -8,11 +9,11 @@ import type { ComputedRef, MaybeRef, MaybeRefOrGetter } from 'vue';
|
|
|
8
9
|
export type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
|
9
10
|
[Property in keyof T]: MaybeRefDeep<T[Property]>;
|
|
10
11
|
} : T>;
|
|
11
|
-
export type QueryOptionsIn<TClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
|
|
12
|
+
export type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
|
|
12
13
|
input?: MaybeRefDeep<TInput>;
|
|
13
14
|
} : {
|
|
14
15
|
input: MaybeRefDeep<TInput>;
|
|
15
|
-
}) & (
|
|
16
|
+
}) & (Record<never, never> extends TClientContext ? {
|
|
16
17
|
context?: MaybeRefDeep<TClientContext>;
|
|
17
18
|
} : {
|
|
18
19
|
context: MaybeRefDeep<TClientContext>;
|
|
@@ -28,9 +29,9 @@ export interface QueryOptionsBase<TOutput, TError extends Error> {
|
|
|
28
29
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
29
30
|
retry?(failureCount: number, error: TError): boolean;
|
|
30
31
|
}
|
|
31
|
-
export type InfiniteOptionsIn<TClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
|
|
32
|
+
export type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
|
|
32
33
|
input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
|
|
33
|
-
} & (
|
|
34
|
+
} & (Record<never, never> extends TClientContext ? {
|
|
34
35
|
context?: MaybeRefDeep<TClientContext>;
|
|
35
36
|
} : {
|
|
36
37
|
context: MaybeRefDeep<TClientContext>;
|
|
@@ -40,7 +41,7 @@ export interface InfiniteOptionsBase<TOutput, TError extends Error, TPageParam>
|
|
|
40
41
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
41
42
|
retry?(failureCount: number, error: TError): boolean;
|
|
42
43
|
}
|
|
43
|
-
export type MutationOptionsIn<TClientContext, TInput, TOutput, TError extends Error> = (
|
|
44
|
+
export type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (Record<never, never> extends TClientContext ? {
|
|
44
45
|
context?: TClientContext;
|
|
45
46
|
} : {
|
|
46
47
|
context: TClientContext;
|
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.7d3bd71",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -34,8 +34,10 @@
|
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@tanstack/vue-query": ">=5.50.0",
|
|
36
36
|
"vue": ">=3.3.0",
|
|
37
|
-
"@orpc/
|
|
38
|
-
|
|
37
|
+
"@orpc/client": "0.0.0-next.7d3bd71"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@orpc/shared": "0.0.0-next.7d3bd71"
|
|
39
41
|
},
|
|
40
42
|
"scripts": {
|
|
41
43
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|