@falcondev-oss/trpc-vue-query 0.5.0-rc.13 → 0.5.0-rc.15
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.cjs +11 -9
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +11 -9
- package/package.json +31 -21
package/dist/index.cjs
CHANGED
|
@@ -59,17 +59,18 @@ function createVueQueryProxyDecoration(name, trpc, queryClient) {
|
|
|
59
59
|
return trpc.query(joinedPath, firstArg, opts);
|
|
60
60
|
}
|
|
61
61
|
function createQuery(_input, { trpcOptions, queryOptions }, { type = "query" } = {}) {
|
|
62
|
+
const queryFn = (0, import_vue.computed)(() => async ({ signal }) => {
|
|
63
|
+
const input = (0, import_core.toValue)(_input);
|
|
64
|
+
const output = input === import_vue_query.skipToken ? void 0 : await trpc.query(joinedPath, input, {
|
|
65
|
+
signal,
|
|
66
|
+
...trpcOptions
|
|
67
|
+
});
|
|
68
|
+
if (type === "queries") return { output, input };
|
|
69
|
+
return output;
|
|
70
|
+
});
|
|
62
71
|
return (0, import_vue_query.queryOptions)({
|
|
63
72
|
queryKey: (0, import_vue.computed)(() => getQueryKey(path, (0, import_core.toValue)(_input), type)),
|
|
64
|
-
queryFn
|
|
65
|
-
const input = (0, import_core.toValue)(_input);
|
|
66
|
-
const output = await trpc.query(joinedPath, input, {
|
|
67
|
-
signal,
|
|
68
|
-
...trpcOptions
|
|
69
|
-
});
|
|
70
|
-
if (type === "queries") return { output, input };
|
|
71
|
-
return output;
|
|
72
|
-
},
|
|
73
|
+
queryFn,
|
|
73
74
|
...maybeToRefs(queryOptions)
|
|
74
75
|
});
|
|
75
76
|
}
|
|
@@ -124,6 +125,7 @@ function createVueQueryProxyDecoration(name, trpc, queryClient) {
|
|
|
124
125
|
(0, import_vue.watch)(
|
|
125
126
|
inputData,
|
|
126
127
|
() => {
|
|
128
|
+
if (inputData.value === import_vue_query.skipToken) return;
|
|
127
129
|
subscription.value?.unsubscribe();
|
|
128
130
|
subscription.value = trpc.subscription(joinedPath, inputData.value, {
|
|
129
131
|
...opts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { QueryKey, UseQueryOptions, UseQueryReturnType, UseQueriesResults, QueryClient, InfiniteData, UseInfiniteQueryOptions, InitialPageParam, UseInfiniteQueryReturnType, UseMutationOptions, UseMutationReturnType } from '@tanstack/vue-query';
|
|
1
|
+
import { QueryKey, SkipToken, UseQueryOptions, UseQueryReturnType, UseQueriesResults, QueryClient, InfiniteData, UseInfiniteQueryOptions, InitialPageParam, UseInfiniteQueryReturnType, UseMutationOptions, UseMutationReturnType } from '@tanstack/vue-query';
|
|
2
2
|
import { TRPCClientErrorLike, TRPCRequestOptions, OperationContext, CreateTRPCClientOptions } from '@trpc/client';
|
|
3
3
|
import { AnyTRPCRouter, AnyTRPCProcedure, AnyTRPCQueryProcedure, inferTransformedProcedureOutput, inferProcedureInput, AnyTRPCMutationProcedure, AnyTRPCSubscriptionProcedure, inferProcedureOutput } from '@trpc/server';
|
|
4
4
|
import { Unsubscribable } from '@trpc/server/observable';
|
|
5
5
|
import { ProcedureOptions } from '@trpc/server/unstable-core-do-not-import';
|
|
6
|
-
import { MaybeRefOrGetter, UnwrapRef
|
|
6
|
+
import { Ref, MaybeRefOrGetter, UnwrapRef } from 'vue';
|
|
7
7
|
|
|
8
8
|
type inferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : T;
|
|
9
9
|
type TRPCSubscriptionObserver<TValue, TError> = {
|
|
@@ -21,7 +21,7 @@ type Exact<Shape, T extends Shape> = Shape extends Primitive ? Shape : Shape ext
|
|
|
21
21
|
[Key in keyof T]: Key extends keyof Shape ? T[Key] extends Date ? T[Key] : T[Key] extends unknown[] ? Array<Exact<ArrayElement<Shape[Key]>, ArrayElement<T[Key]>>> : T[Key] extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<Shape[Key]>, ArrayElement<T[Key]>>> : T[Key] extends object ? Exact<Shape[Key], T[Key]> : T[Key] : never;
|
|
22
22
|
} : Shape;
|
|
23
23
|
type DecorateProcedure<TProcedure extends AnyTRPCProcedure, TRouter extends AnyTRPCRouter> = TProcedure extends AnyTRPCQueryProcedure ? {
|
|
24
|
-
useQuery: <TQueryFnData extends inferTransformedProcedureOutput<TRouter, TProcedure>, TError extends TRPCClientErrorLike<TRouter>, TData extends TQueryFnData, TQueryData extends TQueryFnData, TQueryKey extends QueryKey, TInput extends inferProcedureInput<TProcedure
|
|
24
|
+
useQuery: <TQueryFnData extends inferTransformedProcedureOutput<TRouter, TProcedure>, TError extends TRPCClientErrorLike<TRouter>, TData extends TQueryFnData, TQueryData extends TQueryFnData, TQueryKey extends QueryKey, TInput extends inferProcedureInput<TProcedure>, TTInput extends Exact<inferProcedureInput<TProcedure>, TInput> | SkipToken>(input: inferProcedureInput<TProcedure> extends void ? inferProcedureInput<TProcedure> : Ref<TTInput> | (() => TTInput), opts?: MaybeRefOrGetter<Omit<UnwrapRef<UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>, 'queryKey'> & {
|
|
25
25
|
trpc?: TRPCRequestOptions;
|
|
26
26
|
queryKey?: TQueryKey;
|
|
27
27
|
}>) => UseQueryReturnType<TData, TError>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { QueryKey, UseQueryOptions, UseQueryReturnType, UseQueriesResults, QueryClient, InfiniteData, UseInfiniteQueryOptions, InitialPageParam, UseInfiniteQueryReturnType, UseMutationOptions, UseMutationReturnType } from '@tanstack/vue-query';
|
|
1
|
+
import { QueryKey, SkipToken, UseQueryOptions, UseQueryReturnType, UseQueriesResults, QueryClient, InfiniteData, UseInfiniteQueryOptions, InitialPageParam, UseInfiniteQueryReturnType, UseMutationOptions, UseMutationReturnType } from '@tanstack/vue-query';
|
|
2
2
|
import { TRPCClientErrorLike, TRPCRequestOptions, OperationContext, CreateTRPCClientOptions } from '@trpc/client';
|
|
3
3
|
import { AnyTRPCRouter, AnyTRPCProcedure, AnyTRPCQueryProcedure, inferTransformedProcedureOutput, inferProcedureInput, AnyTRPCMutationProcedure, AnyTRPCSubscriptionProcedure, inferProcedureOutput } from '@trpc/server';
|
|
4
4
|
import { Unsubscribable } from '@trpc/server/observable';
|
|
5
5
|
import { ProcedureOptions } from '@trpc/server/unstable-core-do-not-import';
|
|
6
|
-
import { MaybeRefOrGetter, UnwrapRef
|
|
6
|
+
import { Ref, MaybeRefOrGetter, UnwrapRef } from 'vue';
|
|
7
7
|
|
|
8
8
|
type inferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : T;
|
|
9
9
|
type TRPCSubscriptionObserver<TValue, TError> = {
|
|
@@ -21,7 +21,7 @@ type Exact<Shape, T extends Shape> = Shape extends Primitive ? Shape : Shape ext
|
|
|
21
21
|
[Key in keyof T]: Key extends keyof Shape ? T[Key] extends Date ? T[Key] : T[Key] extends unknown[] ? Array<Exact<ArrayElement<Shape[Key]>, ArrayElement<T[Key]>>> : T[Key] extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<Shape[Key]>, ArrayElement<T[Key]>>> : T[Key] extends object ? Exact<Shape[Key], T[Key]> : T[Key] : never;
|
|
22
22
|
} : Shape;
|
|
23
23
|
type DecorateProcedure<TProcedure extends AnyTRPCProcedure, TRouter extends AnyTRPCRouter> = TProcedure extends AnyTRPCQueryProcedure ? {
|
|
24
|
-
useQuery: <TQueryFnData extends inferTransformedProcedureOutput<TRouter, TProcedure>, TError extends TRPCClientErrorLike<TRouter>, TData extends TQueryFnData, TQueryData extends TQueryFnData, TQueryKey extends QueryKey, TInput extends inferProcedureInput<TProcedure
|
|
24
|
+
useQuery: <TQueryFnData extends inferTransformedProcedureOutput<TRouter, TProcedure>, TError extends TRPCClientErrorLike<TRouter>, TData extends TQueryFnData, TQueryData extends TQueryFnData, TQueryKey extends QueryKey, TInput extends inferProcedureInput<TProcedure>, TTInput extends Exact<inferProcedureInput<TProcedure>, TInput> | SkipToken>(input: inferProcedureInput<TProcedure> extends void ? inferProcedureInput<TProcedure> : Ref<TTInput> | (() => TTInput), opts?: MaybeRefOrGetter<Omit<UnwrapRef<UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>, 'queryKey'> & {
|
|
25
25
|
trpc?: TRPCRequestOptions;
|
|
26
26
|
queryKey?: TQueryKey;
|
|
27
27
|
}>) => UseQueryReturnType<TData, TError>;
|
package/dist/index.mjs
CHANGED
|
@@ -44,17 +44,18 @@ function createVueQueryProxyDecoration(name, trpc, queryClient) {
|
|
|
44
44
|
return trpc.query(joinedPath, firstArg, opts);
|
|
45
45
|
}
|
|
46
46
|
function createQuery(_input, { trpcOptions, queryOptions }, { type = "query" } = {}) {
|
|
47
|
+
const queryFn = computed(() => async ({ signal }) => {
|
|
48
|
+
const input = toValue(_input);
|
|
49
|
+
const output = input === skipToken ? void 0 : await trpc.query(joinedPath, input, {
|
|
50
|
+
signal,
|
|
51
|
+
...trpcOptions
|
|
52
|
+
});
|
|
53
|
+
if (type === "queries") return { output, input };
|
|
54
|
+
return output;
|
|
55
|
+
});
|
|
47
56
|
return defineQueryOptions({
|
|
48
57
|
queryKey: computed(() => getQueryKey(path, toValue(_input), type)),
|
|
49
|
-
queryFn
|
|
50
|
-
const input = toValue(_input);
|
|
51
|
-
const output = await trpc.query(joinedPath, input, {
|
|
52
|
-
signal,
|
|
53
|
-
...trpcOptions
|
|
54
|
-
});
|
|
55
|
-
if (type === "queries") return { output, input };
|
|
56
|
-
return output;
|
|
57
|
-
},
|
|
58
|
+
queryFn,
|
|
58
59
|
...maybeToRefs(queryOptions)
|
|
59
60
|
});
|
|
60
61
|
}
|
|
@@ -109,6 +110,7 @@ function createVueQueryProxyDecoration(name, trpc, queryClient) {
|
|
|
109
110
|
watch(
|
|
110
111
|
inputData,
|
|
111
112
|
() => {
|
|
113
|
+
if (inputData.value === skipToken) return;
|
|
112
114
|
subscription.value?.unsubscribe();
|
|
113
115
|
subscription.value = trpc.subscription(joinedPath, inputData.value, {
|
|
114
116
|
...opts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@falcondev-oss/trpc-vue-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.0-rc.
|
|
4
|
+
"version": "0.5.0-rc.15",
|
|
5
5
|
"description": "A tRPC wrapper around '@tanstack/vue-query'",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:falcondev-oss/trpc-vue-query",
|
|
@@ -15,6 +15,16 @@
|
|
|
15
15
|
"tanstack-query",
|
|
16
16
|
"typescript"
|
|
17
17
|
],
|
|
18
|
+
"exports": {
|
|
19
|
+
"import": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.mjs"
|
|
22
|
+
},
|
|
23
|
+
"require": {
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
25
|
+
"default": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
18
28
|
"main": "dist/index.cjs",
|
|
19
29
|
"module": "dist/index.mjs",
|
|
20
30
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +32,7 @@
|
|
|
22
32
|
"dist"
|
|
23
33
|
],
|
|
24
34
|
"engines": {
|
|
25
|
-
"node": "
|
|
35
|
+
"node": "22",
|
|
26
36
|
"pnpm": "9"
|
|
27
37
|
},
|
|
28
38
|
"peerDependencies": {
|
|
@@ -32,35 +42,35 @@
|
|
|
32
42
|
"vue": "^3.4.19"
|
|
33
43
|
},
|
|
34
44
|
"dependencies": {
|
|
35
|
-
"@vueuse/core": "^11.
|
|
45
|
+
"@vueuse/core": "^11.3.0"
|
|
36
46
|
},
|
|
37
47
|
"devDependencies": {
|
|
38
|
-
"@commitlint/cli": "^19.
|
|
39
|
-
"@eslint/eslintrc": "^3.
|
|
48
|
+
"@commitlint/cli": "^19.6.0",
|
|
49
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
40
50
|
"@louishaftmann/commitlint-config": "^4.0.3",
|
|
41
51
|
"@louishaftmann/eslint-config": "^4.0.3",
|
|
42
52
|
"@louishaftmann/lintstaged-config": "^4.0.3",
|
|
43
53
|
"@louishaftmann/prettier-config": "^4.0.3",
|
|
44
|
-
"@tanstack/vue-query": "^5.
|
|
45
|
-
"@trpc/client": "11.0.0-rc.
|
|
46
|
-
"@trpc/server": "11.0.0-rc.
|
|
54
|
+
"@tanstack/vue-query": "^5.62.3",
|
|
55
|
+
"@trpc/client": "11.0.0-rc.660",
|
|
56
|
+
"@trpc/server": "11.0.0-rc.660",
|
|
47
57
|
"@types/eslint": "^9.6.1",
|
|
48
58
|
"@types/eslint__eslintrc": "^2.1.2",
|
|
49
|
-
"@types/ws": "^8.5.
|
|
50
|
-
"@vitest/ui": "^2.1.
|
|
51
|
-
"eslint": "
|
|
52
|
-
"husky": "^9.1.
|
|
53
|
-
"lint-staged": "^15.2.
|
|
54
|
-
"prettier": "^3.
|
|
59
|
+
"@types/ws": "^8.5.13",
|
|
60
|
+
"@vitest/ui": "^2.1.8",
|
|
61
|
+
"eslint": "~9.14.0",
|
|
62
|
+
"husky": "^9.1.7",
|
|
63
|
+
"lint-staged": "^15.2.11",
|
|
64
|
+
"prettier": "^3.4.2",
|
|
55
65
|
"start-server-and-test": "^2.0.8",
|
|
56
|
-
"tsup": "^8.3.
|
|
57
|
-
"tsx": "^4.19.
|
|
58
|
-
"type-fest": "^4.
|
|
59
|
-
"typescript": "^5.
|
|
60
|
-
"vitest": "^2.1.
|
|
61
|
-
"vue": "^3.5.
|
|
66
|
+
"tsup": "^8.3.5",
|
|
67
|
+
"tsx": "^4.19.2",
|
|
68
|
+
"type-fest": "^4.30.0",
|
|
69
|
+
"typescript": "^5.7.2",
|
|
70
|
+
"vitest": "^2.1.8",
|
|
71
|
+
"vue": "^3.5.13",
|
|
62
72
|
"ws": "^8.18.0",
|
|
63
|
-
"zod": "^3.
|
|
73
|
+
"zod": "^3.24.0"
|
|
64
74
|
},
|
|
65
75
|
"changelogithub": {
|
|
66
76
|
"extends": "gh:falcondev-it/configs/changelogithub"
|