@trpc/tanstack-react-query 0.0.0-alpha.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/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.mjs +3 -0
- package/dist/internals/Context.d.ts +14 -0
- package/dist/internals/Context.d.ts.map +1 -0
- package/dist/internals/Context.js +52 -0
- package/dist/internals/Context.mjs +31 -0
- package/dist/internals/createOptionsProxy.d.ts +107 -0
- package/dist/internals/createOptionsProxy.d.ts.map +1 -0
- package/dist/internals/createOptionsProxy.js +99 -0
- package/dist/internals/createOptionsProxy.mjs +97 -0
- package/dist/internals/infiniteQueryOptions.d.ts +49 -0
- package/dist/internals/infiniteQueryOptions.d.ts.map +1 -0
- package/dist/internals/infiniteQueryOptions.js +39 -0
- package/dist/internals/infiniteQueryOptions.mjs +37 -0
- package/dist/internals/mutationOptions.d.ts +38 -0
- package/dist/internals/mutationOptions.d.ts.map +1 -0
- package/dist/internals/mutationOptions.js +38 -0
- package/dist/internals/mutationOptions.mjs +36 -0
- package/dist/internals/queryOptions.d.ts +61 -0
- package/dist/internals/queryOptions.d.ts.map +1 -0
- package/dist/internals/queryOptions.js +40 -0
- package/dist/internals/queryOptions.mjs +38 -0
- package/dist/internals/subscriptionOptions.d.ts +77 -0
- package/dist/internals/subscriptionOptions.d.ts.map +1 -0
- package/dist/internals/subscriptionOptions.js +173 -0
- package/dist/internals/subscriptionOptions.mjs +151 -0
- package/dist/internals/types.d.ts +41 -0
- package/dist/internals/types.d.ts.map +1 -0
- package/dist/internals/utils.d.ts +28 -0
- package/dist/internals/utils.d.ts.map +1 -0
- package/dist/internals/utils.js +112 -0
- package/dist/internals/utils.mjs +105 -0
- package/package.json +81 -0
- package/src/index.ts +25 -0
- package/src/internals/Context.tsx +46 -0
- package/src/internals/createOptionsProxy.ts +309 -0
- package/src/internals/infiniteQueryOptions.ts +233 -0
- package/src/internals/mutationOptions.ts +113 -0
- package/src/internals/queryOptions.ts +199 -0
- package/src/internals/subscriptionOptions.ts +286 -0
- package/src/internals/types.ts +47 -0
- package/src/internals/utils.ts +140 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Alex Johansson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://trpc.io/"><img src="https://assets.trpc.io/icons/svgs/blue-bg-rounded.svg" alt="tRPC" height="75"/></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h3 align="center">tRPC</h3>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>End-to-end typesafe APIs made easy</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://assets.trpc.io/www/v10/v10-dark-landscape.gif" alt="Demo" />
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
# `@trpc/tanstack-react-query`
|
|
16
|
+
|
|
17
|
+
> A tRPC wrapper around @tanstack/react-query.
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
TODO
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
> Requires `@tanstack/react-query` v5.59.15 or higher
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# npm
|
|
29
|
+
npm install @trpc/tanstack-react-query@next @tanstack/react-query
|
|
30
|
+
|
|
31
|
+
# Yarn
|
|
32
|
+
yarn add @trpc/tanstack-react-query@next @tanstack/react-query
|
|
33
|
+
|
|
34
|
+
# pnpm
|
|
35
|
+
pnpm add @trpc/tanstack-react-query@next @tanstack/react-query
|
|
36
|
+
|
|
37
|
+
# Bun
|
|
38
|
+
bun add @trpc/tanstack-react-query@next @tanstack/react-query
|
|
39
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createTRPCContext } from './internals/Context';
|
|
2
|
+
export type { TRPCOptionsProxy, InferInput, InferOutput, DecorateMutationProcedure, DecorateProcedure, DecorateQueryKeyable, DecorateQueryProcedure, DecorateSubscriptionProcedure, } from './internals/createOptionsProxy';
|
|
3
|
+
export type { TRPCQueryOptions } from './internals/queryOptions';
|
|
4
|
+
export type { TRPCInfiniteQueryOptions } from './internals/infiniteQueryOptions';
|
|
5
|
+
export type { TRPCMutationOptions } from './internals/mutationOptions';
|
|
6
|
+
export type { TRPCSubscriptionOptions, TRPCSubscriptionStatus, TRPCSubscriptionConnectingResult, TRPCSubscriptionErrorResult, TRPCSubscriptionIdleResult, TRPCSubscriptionPendingResult, TRPCSubscriptionResult, } from './internals/subscriptionOptions';
|
|
7
|
+
export { createTRPCOptionsProxy } from './internals/createOptionsProxy';
|
|
8
|
+
export { useSubscription } from './internals/subscriptionOptions';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,gCAAgC,EAChC,2BAA2B,EAC3B,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Context = require('./internals/Context.js');
|
|
4
|
+
var createOptionsProxy = require('./internals/createOptionsProxy.js');
|
|
5
|
+
var subscriptionOptions = require('./internals/subscriptionOptions.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.createTRPCContext = Context.createTRPCContext;
|
|
10
|
+
exports.createTRPCOptionsProxy = createOptionsProxy.createTRPCOptionsProxy;
|
|
11
|
+
exports.useSubscription = subscriptionOptions.useSubscription;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { type CreateTRPCClient } from '@trpc/client';
|
|
3
|
+
import type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { type TRPCOptionsProxy } from './createOptionsProxy';
|
|
6
|
+
export declare function createTRPCContext<TRouter extends AnyRouter>(): {
|
|
7
|
+
TRPCProvider: (props: Readonly<{
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
queryClient: QueryClient;
|
|
10
|
+
trpcClient: CreateTRPCClient<TRouter>;
|
|
11
|
+
}>) => React.JSX.Element;
|
|
12
|
+
useTRPC: () => TRPCOptionsProxy<TRouter>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/internals/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS;0BAMhD,QAAQ,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;KACvC,CAAC;;EA0BL"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var createOptionsProxy = require('./createOptionsProxy.js');
|
|
5
|
+
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
24
|
+
|
|
25
|
+
function createTRPCContext() {
|
|
26
|
+
const TRPCContext = /*#__PURE__*/ React__namespace.createContext(null);
|
|
27
|
+
function TRPCProvider(props) {
|
|
28
|
+
const value = React__namespace.useMemo(()=>createOptionsProxy.createTRPCOptionsProxy({
|
|
29
|
+
client: props.trpcClient,
|
|
30
|
+
queryClient: props.queryClient
|
|
31
|
+
}), [
|
|
32
|
+
props.trpcClient,
|
|
33
|
+
props.queryClient
|
|
34
|
+
]);
|
|
35
|
+
return /*#__PURE__*/ React__namespace.createElement(TRPCContext.Provider, {
|
|
36
|
+
value: value
|
|
37
|
+
}, props.children);
|
|
38
|
+
}
|
|
39
|
+
function useTRPC() {
|
|
40
|
+
const utils = React__namespace.useContext(TRPCContext);
|
|
41
|
+
if (!utils) {
|
|
42
|
+
throw new Error('useTRPC() can only be used inside of a <TRPCProvider>');
|
|
43
|
+
}
|
|
44
|
+
return utils;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
TRPCProvider,
|
|
48
|
+
useTRPC
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.createTRPCContext = createTRPCContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createTRPCOptionsProxy } from './createOptionsProxy.mjs';
|
|
3
|
+
|
|
4
|
+
function createTRPCContext() {
|
|
5
|
+
const TRPCContext = /*#__PURE__*/ React.createContext(null);
|
|
6
|
+
function TRPCProvider(props) {
|
|
7
|
+
const value = React.useMemo(()=>createTRPCOptionsProxy({
|
|
8
|
+
client: props.trpcClient,
|
|
9
|
+
queryClient: props.queryClient
|
|
10
|
+
}), [
|
|
11
|
+
props.trpcClient,
|
|
12
|
+
props.queryClient
|
|
13
|
+
]);
|
|
14
|
+
return /*#__PURE__*/ React.createElement(TRPCContext.Provider, {
|
|
15
|
+
value: value
|
|
16
|
+
}, props.children);
|
|
17
|
+
}
|
|
18
|
+
function useTRPC() {
|
|
19
|
+
const utils = React.useContext(TRPCContext);
|
|
20
|
+
if (!utils) {
|
|
21
|
+
throw new Error('useTRPC() can only be used inside of a <TRPCProvider>');
|
|
22
|
+
}
|
|
23
|
+
return utils;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
TRPCProvider,
|
|
27
|
+
useTRPC
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { createTRPCContext };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type QueryClient, type QueryFilters } from '@tanstack/react-query';
|
|
2
|
+
import { TRPCUntypedClient, type CreateTRPCClient } from '@trpc/client';
|
|
3
|
+
import { type AnyProcedure, type inferProcedureInput, type inferRouterContext, type inferTransformedProcedureOutput, type ProcedureType } from '@trpc/server';
|
|
4
|
+
import type { AnyRootTypes, AnyRouter, MaybePromise, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
5
|
+
import { type TRPCInfiniteQueryOptions } from './infiniteQueryOptions';
|
|
6
|
+
import type { MutationOptionsOverride } from './mutationOptions';
|
|
7
|
+
import { type TRPCMutationOptions } from './mutationOptions';
|
|
8
|
+
import { type TRPCQueryOptions } from './queryOptions';
|
|
9
|
+
import { type TRPCSubscriptionOptions } from './subscriptionOptions';
|
|
10
|
+
import type { ResolverDef, TRPCMutationKey, TRPCQueryKey } from './types';
|
|
11
|
+
export interface DecorateQueryKeyable {
|
|
12
|
+
/**
|
|
13
|
+
* Calculate the Tanstack Query Key for a Route
|
|
14
|
+
*
|
|
15
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
16
|
+
*/
|
|
17
|
+
queryKey: () => TRPCQueryKey;
|
|
18
|
+
/**
|
|
19
|
+
* Calculate a Tanstack Query Filter for a Route
|
|
20
|
+
*
|
|
21
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
22
|
+
*/
|
|
23
|
+
queryFilter: () => QueryFilters;
|
|
24
|
+
}
|
|
25
|
+
export type InferInput<TProcedure extends DecorateQueryProcedure<any> | DecorateMutationProcedure<any>> = TProcedure['~types']['input'];
|
|
26
|
+
export type InferOutput<TProcedure extends DecorateQueryProcedure<any> | DecorateMutationProcedure<any>> = TProcedure['~types']['output'];
|
|
27
|
+
export interface DecorateQueryProcedure<TDef extends ResolverDef> {
|
|
28
|
+
/**
|
|
29
|
+
* @internal prefer using InferInput and InferOutput to access types
|
|
30
|
+
*/
|
|
31
|
+
'~types': {
|
|
32
|
+
input: TDef['input'];
|
|
33
|
+
output: TDef['output'];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/reference/queryOptions#queryoptions
|
|
37
|
+
*/
|
|
38
|
+
queryOptions: TRPCQueryOptions<TDef>;
|
|
39
|
+
/**
|
|
40
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/reference/infiniteQueryOptions#infinitequeryoptions
|
|
41
|
+
*/
|
|
42
|
+
infiniteQueryOptions: TRPCInfiniteQueryOptions<TDef>;
|
|
43
|
+
/**
|
|
44
|
+
* Calculate the Tanstack Query Key for a Query Procedure
|
|
45
|
+
*
|
|
46
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
47
|
+
*/
|
|
48
|
+
queryKey: (input?: TDef['input']) => TRPCQueryKey;
|
|
49
|
+
/**
|
|
50
|
+
* Calculate a Tanstack Query Filter for a Query Procedure
|
|
51
|
+
*
|
|
52
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
53
|
+
*/
|
|
54
|
+
queryFilter: (input?: TDef['input']) => QueryFilters;
|
|
55
|
+
}
|
|
56
|
+
export interface DecorateMutationProcedure<TDef extends ResolverDef> {
|
|
57
|
+
/**
|
|
58
|
+
* @internal prefer using InferInput and InferOutput to access types
|
|
59
|
+
*/
|
|
60
|
+
'~types': {
|
|
61
|
+
input: TDef['input'];
|
|
62
|
+
output: TDef['output'];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* @see
|
|
66
|
+
*/
|
|
67
|
+
mutationOptions: TRPCMutationOptions<TDef>;
|
|
68
|
+
/**
|
|
69
|
+
* Calculate the Tanstack Mutation Key for a Mutation Procedure
|
|
70
|
+
*/
|
|
71
|
+
mutationKey: () => TRPCMutationKey;
|
|
72
|
+
}
|
|
73
|
+
export interface DecorateSubscriptionProcedure<TDef extends ResolverDef> {
|
|
74
|
+
/**
|
|
75
|
+
* @see
|
|
76
|
+
*/
|
|
77
|
+
subscriptionOptions: TRPCSubscriptionOptions<TDef>;
|
|
78
|
+
}
|
|
79
|
+
export type DecorateProcedure<TType extends ProcedureType, TDef extends ResolverDef> = TType extends 'query' ? DecorateQueryProcedure<TDef> : TType extends 'mutation' ? DecorateMutationProcedure<TDef> : TType extends 'subscription' ? DecorateSubscriptionProcedure<TDef> : never;
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
export type DecoratedProcedureUtilsRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = {
|
|
84
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends RouterRecord ? DecoratedProcedureUtilsRecord<TRoot, $Value> & DecorateQueryKeyable : $Value extends AnyProcedure ? DecorateProcedure<$Value['_def']['type'], {
|
|
85
|
+
input: inferProcedureInput<$Value>;
|
|
86
|
+
output: inferTransformedProcedureOutput<TRoot, $Value>;
|
|
87
|
+
transformer: TRoot['transformer'];
|
|
88
|
+
errorShape: TRoot['errorShape'];
|
|
89
|
+
}> : never : never;
|
|
90
|
+
};
|
|
91
|
+
export type TRPCOptionsProxy<TRouter extends AnyRouter> = DecoratedProcedureUtilsRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']> & DecorateQueryKeyable;
|
|
92
|
+
export interface TRPCOptionsProxyOptionsBase {
|
|
93
|
+
queryClient: QueryClient | (() => QueryClient);
|
|
94
|
+
overrides?: {
|
|
95
|
+
mutations?: MutationOptionsOverride;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export interface TRPCOptionsProxyOptionsInternal<TRouter extends AnyRouter> {
|
|
99
|
+
router: TRouter;
|
|
100
|
+
ctx: inferRouterContext<TRouter> | (() => MaybePromise<inferRouterContext<TRouter>>);
|
|
101
|
+
}
|
|
102
|
+
export interface TRPCOptionsProxyOptionsExternal<TRouter extends AnyRouter> {
|
|
103
|
+
client: TRPCUntypedClient<TRouter> | CreateTRPCClient<TRouter>;
|
|
104
|
+
}
|
|
105
|
+
export type TRPCOptionsProxyOptions<TRouter extends AnyRouter> = TRPCOptionsProxyOptionsBase & (TRPCOptionsProxyOptionsInternal<TRouter> | TRPCOptionsProxyOptionsExternal<TRouter>);
|
|
106
|
+
export declare function createTRPCOptionsProxy<TRouter extends AnyRouter>(opts: TRPCOptionsProxyOptions<TRouter>): TRPCOptionsProxy<TRouter>;
|
|
107
|
+
//# sourceMappingURL=createOptionsProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOptionsProxy.d.ts","sourceRoot":"","sources":["../../src/internals/createO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B,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAChE;AAED,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,SAAS,IAC3D,2BAA2B,GACzB,CACI,+BAA+B,CAAC,OAAO,CAAC,GACxC,+BAA+B,CAAC,OAAO,CAAC,CAC3C,CAAC;AAkBN,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAC9D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,GACrC,gBAAgB,CAAC,OAAO,CAAC,CAsF3B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var client = require('@trpc/client');
|
|
4
|
+
var server = require('@trpc/server');
|
|
5
|
+
var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
|
|
6
|
+
var infiniteQueryOptions = require('./infiniteQueryOptions.js');
|
|
7
|
+
var mutationOptions = require('./mutationOptions.js');
|
|
8
|
+
var queryOptions = require('./queryOptions.js');
|
|
9
|
+
var subscriptionOptions = require('./subscriptionOptions.js');
|
|
10
|
+
var utils = require('./utils.js');
|
|
11
|
+
|
|
12
|
+
function getQueryType(method) {
|
|
13
|
+
const map = {
|
|
14
|
+
queryOptions: 'query',
|
|
15
|
+
infiniteQueryOptions: 'infinite',
|
|
16
|
+
subscriptionOptions: 'any',
|
|
17
|
+
mutationOptions: 'any'
|
|
18
|
+
};
|
|
19
|
+
return map[method];
|
|
20
|
+
}
|
|
21
|
+
function createTRPCOptionsProxy(opts) {
|
|
22
|
+
const callIt = (type)=>{
|
|
23
|
+
return (path, input, trpcOpts)=>{
|
|
24
|
+
if ('router' in opts) {
|
|
25
|
+
return Promise.resolve(utils.unwrapLazyArg(opts.ctx)).then((ctx)=>server.callProcedure({
|
|
26
|
+
procedures: opts.router._def.procedures,
|
|
27
|
+
path: path,
|
|
28
|
+
getRawInput: async ()=>input,
|
|
29
|
+
ctx: ctx,
|
|
30
|
+
type: type,
|
|
31
|
+
signal: undefined
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
const untypedClient = opts.client instanceof client.TRPCUntypedClient ? opts.client : client.getUntypedClient(opts.client);
|
|
35
|
+
return untypedClient[type](path, input, trpcOpts);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
return unstableCoreDoNotImport.createRecursiveProxy(({ args, path: _path })=>{
|
|
39
|
+
const path = [
|
|
40
|
+
..._path
|
|
41
|
+
];
|
|
42
|
+
const utilName = path.pop();
|
|
43
|
+
const [arg1, arg2] = args;
|
|
44
|
+
const queryType = getQueryType(utilName);
|
|
45
|
+
const queryKey = utils.getQueryKeyInternal(path, arg1, queryType ?? 'any');
|
|
46
|
+
const contextMap = {
|
|
47
|
+
'~types': undefined,
|
|
48
|
+
mutationKey: ()=>{
|
|
49
|
+
return utils.getMutationKeyInternal(path);
|
|
50
|
+
},
|
|
51
|
+
queryKey: ()=>{
|
|
52
|
+
return queryKey;
|
|
53
|
+
},
|
|
54
|
+
queryFilter: ()=>{
|
|
55
|
+
return {
|
|
56
|
+
queryKey: queryKey
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
infiniteQueryOptions: ()=>{
|
|
60
|
+
return infiniteQueryOptions.trpcInfiniteQueryOptions({
|
|
61
|
+
opts: arg2,
|
|
62
|
+
path,
|
|
63
|
+
queryClient: opts.queryClient,
|
|
64
|
+
queryKey: queryKey,
|
|
65
|
+
query: callIt('query')
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
queryOptions: ()=>{
|
|
69
|
+
return queryOptions.trpcQueryOptions({
|
|
70
|
+
opts: arg2,
|
|
71
|
+
path,
|
|
72
|
+
queryClient: opts.queryClient,
|
|
73
|
+
queryKey: queryKey,
|
|
74
|
+
query: callIt('query')
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
mutationOptions: ()=>{
|
|
78
|
+
return mutationOptions.trpcMutationOptions({
|
|
79
|
+
opts: arg1,
|
|
80
|
+
path,
|
|
81
|
+
queryClient: opts.queryClient,
|
|
82
|
+
mutate: callIt('mutation'),
|
|
83
|
+
overrides: opts.overrides?.mutations
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
subscriptionOptions: ()=>{
|
|
87
|
+
return subscriptionOptions.trpcSubscriptionOptions({
|
|
88
|
+
opts: arg2,
|
|
89
|
+
path,
|
|
90
|
+
queryKey: queryKey,
|
|
91
|
+
subscribe: callIt('subscription')
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return contextMap[utilName]();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
exports.createTRPCOptionsProxy = createTRPCOptionsProxy;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { TRPCUntypedClient, getUntypedClient } from '@trpc/client';
|
|
2
|
+
import { callProcedure } from '@trpc/server';
|
|
3
|
+
import { createRecursiveProxy } from '@trpc/server/unstable-core-do-not-import';
|
|
4
|
+
import { trpcInfiniteQueryOptions } from './infiniteQueryOptions.mjs';
|
|
5
|
+
import { trpcMutationOptions } from './mutationOptions.mjs';
|
|
6
|
+
import { trpcQueryOptions } from './queryOptions.mjs';
|
|
7
|
+
import { trpcSubscriptionOptions } from './subscriptionOptions.mjs';
|
|
8
|
+
import { getQueryKeyInternal, getMutationKeyInternal, unwrapLazyArg } from './utils.mjs';
|
|
9
|
+
|
|
10
|
+
function getQueryType(method) {
|
|
11
|
+
const map = {
|
|
12
|
+
queryOptions: 'query',
|
|
13
|
+
infiniteQueryOptions: 'infinite',
|
|
14
|
+
subscriptionOptions: 'any',
|
|
15
|
+
mutationOptions: 'any'
|
|
16
|
+
};
|
|
17
|
+
return map[method];
|
|
18
|
+
}
|
|
19
|
+
function createTRPCOptionsProxy(opts) {
|
|
20
|
+
const callIt = (type)=>{
|
|
21
|
+
return (path, input, trpcOpts)=>{
|
|
22
|
+
if ('router' in opts) {
|
|
23
|
+
return Promise.resolve(unwrapLazyArg(opts.ctx)).then((ctx)=>callProcedure({
|
|
24
|
+
procedures: opts.router._def.procedures,
|
|
25
|
+
path: path,
|
|
26
|
+
getRawInput: async ()=>input,
|
|
27
|
+
ctx: ctx,
|
|
28
|
+
type: type,
|
|
29
|
+
signal: undefined
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
const untypedClient = opts.client instanceof TRPCUntypedClient ? opts.client : getUntypedClient(opts.client);
|
|
33
|
+
return untypedClient[type](path, input, trpcOpts);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
return createRecursiveProxy(({ args, path: _path })=>{
|
|
37
|
+
const path = [
|
|
38
|
+
..._path
|
|
39
|
+
];
|
|
40
|
+
const utilName = path.pop();
|
|
41
|
+
const [arg1, arg2] = args;
|
|
42
|
+
const queryType = getQueryType(utilName);
|
|
43
|
+
const queryKey = getQueryKeyInternal(path, arg1, queryType ?? 'any');
|
|
44
|
+
const contextMap = {
|
|
45
|
+
'~types': undefined,
|
|
46
|
+
mutationKey: ()=>{
|
|
47
|
+
return getMutationKeyInternal(path);
|
|
48
|
+
},
|
|
49
|
+
queryKey: ()=>{
|
|
50
|
+
return queryKey;
|
|
51
|
+
},
|
|
52
|
+
queryFilter: ()=>{
|
|
53
|
+
return {
|
|
54
|
+
queryKey: queryKey
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
infiniteQueryOptions: ()=>{
|
|
58
|
+
return trpcInfiniteQueryOptions({
|
|
59
|
+
opts: arg2,
|
|
60
|
+
path,
|
|
61
|
+
queryClient: opts.queryClient,
|
|
62
|
+
queryKey: queryKey,
|
|
63
|
+
query: callIt('query')
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
queryOptions: ()=>{
|
|
67
|
+
return trpcQueryOptions({
|
|
68
|
+
opts: arg2,
|
|
69
|
+
path,
|
|
70
|
+
queryClient: opts.queryClient,
|
|
71
|
+
queryKey: queryKey,
|
|
72
|
+
query: callIt('query')
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
mutationOptions: ()=>{
|
|
76
|
+
return trpcMutationOptions({
|
|
77
|
+
opts: arg1,
|
|
78
|
+
path,
|
|
79
|
+
queryClient: opts.queryClient,
|
|
80
|
+
mutate: callIt('mutation'),
|
|
81
|
+
overrides: opts.overrides?.mutations
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
subscriptionOptions: ()=>{
|
|
85
|
+
return trpcSubscriptionOptions({
|
|
86
|
+
opts: arg2,
|
|
87
|
+
path,
|
|
88
|
+
queryKey: queryKey,
|
|
89
|
+
subscribe: callIt('subscription')
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return contextMap[utilName]();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { createTRPCOptionsProxy };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DataTag, DefinedInitialDataInfiniteOptions, InfiniteData, UndefinedInitialDataInfiniteOptions, UnusedSkipTokenInfiniteOptions } from '@tanstack/react-query';
|
|
2
|
+
import { type QueryClient, type SkipToken } from '@tanstack/react-query';
|
|
3
|
+
import type { TRPCClientErrorLike, TRPCUntypedClient } from '@trpc/client';
|
|
4
|
+
import type { DistributiveOmit } from '@trpc/server/unstable-core-do-not-import';
|
|
5
|
+
import type { ExtractCursorType, ResolverDef, TRPCQueryBaseOptions, TRPCQueryKey, TRPCQueryOptionsResult } from './types';
|
|
6
|
+
type ReservedOptions = 'queryKey' | 'queryFn' | 'queryHashFn' | 'queryHash' | 'initialPageParam';
|
|
7
|
+
interface UndefinedTRPCInfiniteQueryOptionsIn<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, InfiniteData<TData, NonNullable<ExtractCursorType<TInput>> | null>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, ReservedOptions>, TRPCQueryBaseOptions {
|
|
8
|
+
initialCursor?: NonNullable<ExtractCursorType<TInput>> | null;
|
|
9
|
+
}
|
|
10
|
+
interface UndefinedTRPCInfiniteQueryOptionsOut<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, InfiniteData<TData, NonNullable<ExtractCursorType<TInput>> | null>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, 'initialPageParam'>, TRPCQueryOptionsResult {
|
|
11
|
+
queryKey: DataTag<TRPCQueryKey, TData>;
|
|
12
|
+
initialPageParam: NonNullable<ExtractCursorType<TInput>> | null;
|
|
13
|
+
}
|
|
14
|
+
interface DefinedTRPCInfiniteQueryOptionsIn<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<DefinedInitialDataInfiniteOptions<TQueryFnData, TError, InfiniteData<TData, NonNullable<ExtractCursorType<TInput>> | null>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, ReservedOptions>, TRPCQueryBaseOptions {
|
|
15
|
+
initialCursor?: NonNullable<ExtractCursorType<TInput>> | null;
|
|
16
|
+
}
|
|
17
|
+
interface DefinedTRPCInfiniteQueryOptionsOut<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<DefinedInitialDataInfiniteOptions<TQueryFnData, TError, InfiniteData<TData, NonNullable<ExtractCursorType<TInput>> | null>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, 'initialPageParam'>, TRPCQueryOptionsResult {
|
|
18
|
+
queryKey: DataTag<TRPCQueryKey, TData>;
|
|
19
|
+
initialPageParam: NonNullable<ExtractCursorType<TInput>> | null;
|
|
20
|
+
}
|
|
21
|
+
interface UnusedSkipTokenTRPCInfiniteQueryOptionsIn<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, InfiniteData<TData, NonNullable<ExtractCursorType<TInput>> | null>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, ReservedOptions>, TRPCQueryBaseOptions {
|
|
22
|
+
initialCursor?: NonNullable<ExtractCursorType<TInput>> | null;
|
|
23
|
+
}
|
|
24
|
+
interface UnusedSkipTokenTRPCInfiniteQueryOptionsOut<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, InfiniteData<TData, NonNullable<ExtractCursorType<TInput>> | null>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, 'initialPageParam'>, TRPCQueryOptionsResult {
|
|
25
|
+
queryKey: DataTag<TRPCQueryKey, TData>;
|
|
26
|
+
initialPageParam: NonNullable<ExtractCursorType<TInput>> | null;
|
|
27
|
+
}
|
|
28
|
+
export interface TRPCInfiniteQueryOptions<TDef extends ResolverDef> {
|
|
29
|
+
<TQueryFnData extends TDef['output'], TData = TQueryFnData>(input: TDef['input'] | SkipToken, opts: DefinedTRPCInfiniteQueryOptionsIn<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<TDef>>): DefinedTRPCInfiniteQueryOptionsOut<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<TDef>>;
|
|
30
|
+
<TQueryFnData extends TDef['output'], TData = TQueryFnData>(input: TDef['input'], opts: UnusedSkipTokenTRPCInfiniteQueryOptionsIn<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<TDef>>): UnusedSkipTokenTRPCInfiniteQueryOptionsOut<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<TDef>>;
|
|
31
|
+
<TQueryFnData extends TDef['output'], TData = TQueryFnData>(input: TDef['input'] | SkipToken, opts?: UndefinedTRPCInfiniteQueryOptionsIn<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<TDef>>): UndefinedTRPCInfiniteQueryOptionsOut<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<TDef>>;
|
|
32
|
+
}
|
|
33
|
+
export declare function trpcInfiniteQueryOptions(args: {
|
|
34
|
+
query: typeof TRPCUntypedClient.prototype.query;
|
|
35
|
+
queryClient: QueryClient | (() => QueryClient);
|
|
36
|
+
path: readonly string[];
|
|
37
|
+
queryKey: TRPCQueryKey;
|
|
38
|
+
opts: UndefinedTRPCInfiniteQueryOptionsIn<unknown, unknown, unknown, unknown>;
|
|
39
|
+
}): import("@tanstack/react-query").UseInfiniteQueryOptions<unknown, unknown, InfiniteData<unknown, {} | null>, unknown, TRPCQueryKey, {} | null> & {
|
|
40
|
+
initialData?: InfiniteData<unknown, {} | null> | import("@tanstack/react-query").InitialDataFunction<InfiniteData<unknown, {} | null>> | undefined;
|
|
41
|
+
} & {
|
|
42
|
+
queryKey: DataTag<TRPCQueryKey, InfiniteData<unknown, unknown>>;
|
|
43
|
+
} & {
|
|
44
|
+
trpc: {
|
|
45
|
+
path: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=infiniteQueryOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infiniteQueryOptions.d.ts","sourceRoot":"","sources":["../../src/internals/infiniteQueryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,iCAAiC,EACjC,YAAY,EAEZ,mCAAmC,EACnC,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAGjB,KAAK,eAAe,GAChB,UAAU,GACV,SAAS,GACT,aAAa,GACb,WAAW,GACX,kBAAkB,CAAC;AAEvB,UAAU,mCAAmC,CAC3C,MAAM,EACN,YAAY,EACZ,KAAK,EACL,MAAM,CACN,SAAQ,gBAAgB,CACpB,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mBAAmB,CAAC,IAAI,CAAC,CAC1B,CAAC;CACH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,KAAK,EAAE,OAAO,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC;IAChD,WAAW,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC;IAC/C,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,mCAAmC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;CAC/E;;;;;;;;EAoCA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactQuery = require('@tanstack/react-query');
|
|
4
|
+
var utils = require('./utils.js');
|
|
5
|
+
|
|
6
|
+
function trpcInfiniteQueryOptions(args) {
|
|
7
|
+
const { query, path, queryKey, opts } = args;
|
|
8
|
+
const inputIsSkipToken = queryKey[1]?.input === reactQuery.skipToken;
|
|
9
|
+
const queryFn = async (queryFnContext)=>{
|
|
10
|
+
const actualOpts = {
|
|
11
|
+
...opts,
|
|
12
|
+
trpc: {
|
|
13
|
+
...opts?.trpc,
|
|
14
|
+
...opts?.trpc?.abortOnUnmount ? {
|
|
15
|
+
signal: queryFnContext.signal
|
|
16
|
+
} : {
|
|
17
|
+
signal: null
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const result = await query(...utils.getClientArgs(queryKey, actualOpts, {
|
|
22
|
+
direction: queryFnContext.direction,
|
|
23
|
+
pageParam: queryFnContext.pageParam
|
|
24
|
+
}));
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
return Object.assign(reactQuery.infiniteQueryOptions({
|
|
28
|
+
...opts,
|
|
29
|
+
queryKey,
|
|
30
|
+
queryFn: inputIsSkipToken ? reactQuery.skipToken : queryFn,
|
|
31
|
+
initialPageParam: opts?.initialCursor ?? null
|
|
32
|
+
}), {
|
|
33
|
+
trpc: utils.createTRPCOptionsResult({
|
|
34
|
+
path
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.trpcInfiniteQueryOptions = trpcInfiniteQueryOptions;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { skipToken, infiniteQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { createTRPCOptionsResult, getClientArgs } from './utils.mjs';
|
|
3
|
+
|
|
4
|
+
function trpcInfiniteQueryOptions(args) {
|
|
5
|
+
const { query, path, queryKey, opts } = args;
|
|
6
|
+
const inputIsSkipToken = queryKey[1]?.input === skipToken;
|
|
7
|
+
const queryFn = async (queryFnContext)=>{
|
|
8
|
+
const actualOpts = {
|
|
9
|
+
...opts,
|
|
10
|
+
trpc: {
|
|
11
|
+
...opts?.trpc,
|
|
12
|
+
...opts?.trpc?.abortOnUnmount ? {
|
|
13
|
+
signal: queryFnContext.signal
|
|
14
|
+
} : {
|
|
15
|
+
signal: null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const result = await query(...getClientArgs(queryKey, actualOpts, {
|
|
20
|
+
direction: queryFnContext.direction,
|
|
21
|
+
pageParam: queryFnContext.pageParam
|
|
22
|
+
}));
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
return Object.assign(infiniteQueryOptions({
|
|
26
|
+
...opts,
|
|
27
|
+
queryKey,
|
|
28
|
+
queryFn: inputIsSkipToken ? skipToken : queryFn,
|
|
29
|
+
initialPageParam: opts?.initialCursor ?? null
|
|
30
|
+
}), {
|
|
31
|
+
trpc: createTRPCOptionsResult({
|
|
32
|
+
path
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { trpcInfiniteQueryOptions };
|