@trpc/tanstack-react-query 11.3.1 → 11.3.2-canary.4
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 +465 -0
- package/dist/index.d.cts +420 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +420 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +442 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +21 -17
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/internals/Context.d.ts +0 -21
- package/dist/internals/Context.d.ts.map +0 -1
- package/dist/internals/Context.js +0 -67
- package/dist/internals/Context.mjs +0 -46
- package/dist/internals/createOptionsProxy.d.ts +0 -161
- package/dist/internals/createOptionsProxy.d.ts.map +0 -1
- package/dist/internals/createOptionsProxy.js +0 -113
- package/dist/internals/createOptionsProxy.mjs +0 -111
- package/dist/internals/infiniteQueryOptions.d.ts +0 -61
- package/dist/internals/infiniteQueryOptions.d.ts.map +0 -1
- package/dist/internals/infiniteQueryOptions.js +0 -39
- package/dist/internals/infiniteQueryOptions.mjs +0 -37
- package/dist/internals/mutationOptions.d.ts +0 -43
- package/dist/internals/mutationOptions.d.ts.map +0 -1
- package/dist/internals/mutationOptions.js +0 -40
- package/dist/internals/mutationOptions.mjs +0 -38
- package/dist/internals/queryOptions.d.ts +0 -58
- package/dist/internals/queryOptions.d.ts.map +0 -1
- package/dist/internals/queryOptions.js +0 -43
- package/dist/internals/queryOptions.mjs +0 -41
- package/dist/internals/subscriptionOptions.d.ts +0 -73
- package/dist/internals/subscriptionOptions.d.ts.map +0 -1
- package/dist/internals/subscriptionOptions.js +0 -181
- package/dist/internals/subscriptionOptions.mjs +0 -159
- package/dist/internals/types.d.ts +0 -83
- package/dist/internals/types.d.ts.map +0 -1
- package/dist/internals/utils.d.ts +0 -36
- package/dist/internals/utils.d.ts.map +0 -1
- package/dist/internals/utils.js +0 -118
- package/dist/internals/utils.mjs +0 -111
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,qBAAqB,EACrB,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;AAClE,mBAAmB,mBAAmB,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import type { TRPCClient } from '@trpc/client';
|
|
3
|
-
import type { AnyTRPCRouter } from '@trpc/server';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import type { TRPCOptionsProxy } from './createOptionsProxy';
|
|
6
|
-
export interface CreateTRPCContextResult<TRouter extends AnyTRPCRouter> {
|
|
7
|
-
TRPCProvider: React.FC<{
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
queryClient: QueryClient;
|
|
10
|
-
trpcClient: TRPCClient<TRouter>;
|
|
11
|
-
}>;
|
|
12
|
-
useTRPC: () => TRPCOptionsProxy<TRouter>;
|
|
13
|
-
useTRPCClient: () => TRPCClient<TRouter>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Create a set of type-safe provider-consumers
|
|
17
|
-
*
|
|
18
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3a-setup-the-trpc-context-provider
|
|
19
|
-
*/
|
|
20
|
-
export declare function createTRPCContext<TRouter extends AnyTRPCRouter>(): CreateTRPCContextResult<TRouter>;
|
|
21
|
-
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/internals/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,MAAM,WAAW,uBAAuB,CAAC,OAAO,SAAS,aAAa;IACpE,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;QACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,aAAa,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;CAC1C;AACD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,aAAa,KAC1B,uBAAuB,CAAC,OAAO,CAAC,CAmDpC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
/**
|
|
26
|
-
* Create a set of type-safe provider-consumers
|
|
27
|
-
*
|
|
28
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3a-setup-the-trpc-context-provider
|
|
29
|
-
*/ function createTRPCContext() {
|
|
30
|
-
const TRPCClientContext = /*#__PURE__*/ React__namespace.createContext(null);
|
|
31
|
-
const TRPCContext = /*#__PURE__*/ React__namespace.createContext(null);
|
|
32
|
-
function TRPCProvider(props) {
|
|
33
|
-
const value = React__namespace.useMemo(()=>createOptionsProxy.createTRPCOptionsProxy({
|
|
34
|
-
client: props.trpcClient,
|
|
35
|
-
queryClient: props.queryClient
|
|
36
|
-
}), [
|
|
37
|
-
props.trpcClient,
|
|
38
|
-
props.queryClient
|
|
39
|
-
]);
|
|
40
|
-
return /*#__PURE__*/ React__namespace.createElement(TRPCClientContext.Provider, {
|
|
41
|
-
value: props.trpcClient
|
|
42
|
-
}, /*#__PURE__*/ React__namespace.createElement(TRPCContext.Provider, {
|
|
43
|
-
value: value
|
|
44
|
-
}, props.children));
|
|
45
|
-
}
|
|
46
|
-
function useTRPC() {
|
|
47
|
-
const utils = React__namespace.useContext(TRPCContext);
|
|
48
|
-
if (!utils) {
|
|
49
|
-
throw new Error('useTRPC() can only be used inside of a <TRPCProvider>');
|
|
50
|
-
}
|
|
51
|
-
return utils;
|
|
52
|
-
}
|
|
53
|
-
function useTRPCClient() {
|
|
54
|
-
const client = React__namespace.useContext(TRPCClientContext);
|
|
55
|
-
if (!client) {
|
|
56
|
-
throw new Error('useTRPCClient() can only be used inside of a <TRPCProvider>');
|
|
57
|
-
}
|
|
58
|
-
return client;
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
TRPCProvider,
|
|
62
|
-
useTRPC,
|
|
63
|
-
useTRPCClient
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
exports.createTRPCContext = createTRPCContext;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { createTRPCOptionsProxy } from './createOptionsProxy.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Create a set of type-safe provider-consumers
|
|
6
|
-
*
|
|
7
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3a-setup-the-trpc-context-provider
|
|
8
|
-
*/ function createTRPCContext() {
|
|
9
|
-
const TRPCClientContext = /*#__PURE__*/ React.createContext(null);
|
|
10
|
-
const TRPCContext = /*#__PURE__*/ React.createContext(null);
|
|
11
|
-
function TRPCProvider(props) {
|
|
12
|
-
const value = React.useMemo(()=>createTRPCOptionsProxy({
|
|
13
|
-
client: props.trpcClient,
|
|
14
|
-
queryClient: props.queryClient
|
|
15
|
-
}), [
|
|
16
|
-
props.trpcClient,
|
|
17
|
-
props.queryClient
|
|
18
|
-
]);
|
|
19
|
-
return /*#__PURE__*/ React.createElement(TRPCClientContext.Provider, {
|
|
20
|
-
value: props.trpcClient
|
|
21
|
-
}, /*#__PURE__*/ React.createElement(TRPCContext.Provider, {
|
|
22
|
-
value: value
|
|
23
|
-
}, props.children));
|
|
24
|
-
}
|
|
25
|
-
function useTRPC() {
|
|
26
|
-
const utils = React.useContext(TRPCContext);
|
|
27
|
-
if (!utils) {
|
|
28
|
-
throw new Error('useTRPC() can only be used inside of a <TRPCProvider>');
|
|
29
|
-
}
|
|
30
|
-
return utils;
|
|
31
|
-
}
|
|
32
|
-
function useTRPCClient() {
|
|
33
|
-
const client = React.useContext(TRPCClientContext);
|
|
34
|
-
if (!client) {
|
|
35
|
-
throw new Error('useTRPCClient() can only be used inside of a <TRPCProvider>');
|
|
36
|
-
}
|
|
37
|
-
return client;
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
TRPCProvider,
|
|
41
|
-
useTRPC,
|
|
42
|
-
useTRPCClient
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { createTRPCContext };
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import type { DataTag, QueryClient, QueryFilters } from '@tanstack/react-query';
|
|
2
|
-
import type { TRPCClient, TRPCClientErrorLike } from '@trpc/client';
|
|
3
|
-
import { TRPCUntypedClient } from '@trpc/client';
|
|
4
|
-
import type { AnyTRPCProcedure, AnyTRPCRootTypes, AnyTRPCRouter, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput, TRPCProcedureType, TRPCRouterRecord } from '@trpc/server';
|
|
5
|
-
import type { MaybePromise } from '@trpc/server/unstable-core-do-not-import';
|
|
6
|
-
import { type TRPCInfiniteQueryOptions } from './infiniteQueryOptions';
|
|
7
|
-
import type { MutationOptionsOverride } from './mutationOptions';
|
|
8
|
-
import { type TRPCMutationOptions } from './mutationOptions';
|
|
9
|
-
import { type TRPCQueryOptions } from './queryOptions';
|
|
10
|
-
import { type TRPCSubscriptionOptions } from './subscriptionOptions';
|
|
11
|
-
import type { OptionalCursorInput, ResolverDef, TRPCInfiniteData, TRPCMutationKey, TRPCQueryKey, WithRequired } from './types';
|
|
12
|
-
export interface DecorateRouterKeyable {
|
|
13
|
-
/**
|
|
14
|
-
* Calculate the TanStack Query Key for any path, could be used to invalidate every procedure beneath this path
|
|
15
|
-
*
|
|
16
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
17
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryKey
|
|
18
|
-
*/
|
|
19
|
-
pathKey: () => TRPCQueryKey;
|
|
20
|
-
/**
|
|
21
|
-
* Calculate a TanStack Query Filter for any path, could be used to manipulate every procedure beneath this path
|
|
22
|
-
*
|
|
23
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
24
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryFilter
|
|
25
|
-
*/
|
|
26
|
-
pathFilter: (filters?: QueryFilters<TRPCQueryKey>) => WithRequired<QueryFilters<TRPCQueryKey>, 'queryKey'>;
|
|
27
|
-
}
|
|
28
|
-
interface TypeHelper<TDef extends ResolverDef> {
|
|
29
|
-
/**
|
|
30
|
-
* @internal prefer using inferInput and inferOutput to access types
|
|
31
|
-
*/
|
|
32
|
-
'~types': {
|
|
33
|
-
input: TDef['input'];
|
|
34
|
-
output: TDef['output'];
|
|
35
|
-
errorShape: TDef['errorShape'];
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export type inferInput<TProcedure extends DecorateInfiniteQueryProcedure<any> | DecorateQueryProcedure<any> | DecorateMutationProcedure<any>> = TProcedure['~types']['input'];
|
|
39
|
-
export type inferOutput<TProcedure extends DecorateInfiniteQueryProcedure<any> | DecorateQueryProcedure<any> | DecorateMutationProcedure<any>> = TProcedure['~types']['output'];
|
|
40
|
-
export interface DecorateInfiniteQueryProcedure<TDef extends ResolverDef> extends TypeHelper<TDef> {
|
|
41
|
-
/**
|
|
42
|
-
* Create a set of type-safe infinite query options that can be passed to `useInfiniteQuery`, `prefetchInfiniteQuery` etc.
|
|
43
|
-
*
|
|
44
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/reference/infiniteQueryOptions#infinitequeryoptions
|
|
45
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#infiniteQueryOptions
|
|
46
|
-
*/
|
|
47
|
-
infiniteQueryOptions: TRPCInfiniteQueryOptions<TDef>;
|
|
48
|
-
/**
|
|
49
|
-
* Calculate the TanStack Query Key for a Infinite Query Procedure
|
|
50
|
-
*
|
|
51
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
52
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryKey
|
|
53
|
-
*/
|
|
54
|
-
infiniteQueryKey: (input?: Partial<TDef['input']>) => DataTag<TRPCQueryKey, TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
55
|
-
transformer: TDef['transformer'];
|
|
56
|
-
errorShape: TDef['errorShape'];
|
|
57
|
-
}>>;
|
|
58
|
-
/**
|
|
59
|
-
* Calculate a TanStack Query Filter for a Infinite Query Procedure
|
|
60
|
-
*
|
|
61
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
62
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryFilter
|
|
63
|
-
*/
|
|
64
|
-
infiniteQueryFilter: (input?: Partial<TDef['input']>, filters?: QueryFilters<DataTag<TRPCQueryKey, TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
65
|
-
transformer: TDef['transformer'];
|
|
66
|
-
errorShape: TDef['errorShape'];
|
|
67
|
-
}>>>) => WithRequired<QueryFilters<DataTag<TRPCQueryKey, TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
68
|
-
transformer: TDef['transformer'];
|
|
69
|
-
errorShape: TDef['errorShape'];
|
|
70
|
-
}>>>, 'queryKey'>;
|
|
71
|
-
}
|
|
72
|
-
export interface DecorateQueryProcedure<TDef extends ResolverDef> extends TypeHelper<TDef>, DecorateRouterKeyable {
|
|
73
|
-
/**
|
|
74
|
-
* Create a set of type-safe query options that can be passed to `useQuery`, `prefetchQuery` etc.
|
|
75
|
-
*
|
|
76
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/reference/queryOptions#queryoptions
|
|
77
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryOptions
|
|
78
|
-
*/
|
|
79
|
-
queryOptions: TRPCQueryOptions<TDef>;
|
|
80
|
-
/**
|
|
81
|
-
* Calculate the TanStack Query Key for a Query Procedure
|
|
82
|
-
*
|
|
83
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
84
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryKey
|
|
85
|
-
*/
|
|
86
|
-
queryKey: (input?: Partial<TDef['input']>) => DataTag<TRPCQueryKey, TDef['output'], TRPCClientErrorLike<{
|
|
87
|
-
transformer: TDef['transformer'];
|
|
88
|
-
errorShape: TDef['errorShape'];
|
|
89
|
-
}>>;
|
|
90
|
-
/**
|
|
91
|
-
* Calculate a TanStack Query Filter for a Query Procedure
|
|
92
|
-
*
|
|
93
|
-
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
94
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryFilter
|
|
95
|
-
*/
|
|
96
|
-
queryFilter: (input?: Partial<TDef['input']>, filters?: QueryFilters<DataTag<TRPCQueryKey, TDef['output'], TRPCClientErrorLike<{
|
|
97
|
-
transformer: TDef['transformer'];
|
|
98
|
-
errorShape: TDef['errorShape'];
|
|
99
|
-
}>>>) => WithRequired<QueryFilters<DataTag<TRPCQueryKey, TDef['output'], TRPCClientErrorLike<{
|
|
100
|
-
transformer: TDef['transformer'];
|
|
101
|
-
errorShape: TDef['errorShape'];
|
|
102
|
-
}>>>, 'queryKey'>;
|
|
103
|
-
}
|
|
104
|
-
export interface DecorateMutationProcedure<TDef extends ResolverDef> extends TypeHelper<TDef> {
|
|
105
|
-
/**
|
|
106
|
-
* Create a set of type-safe mutation options that can be passed to `useMutation`
|
|
107
|
-
*
|
|
108
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#mutationOptions
|
|
109
|
-
*/
|
|
110
|
-
mutationOptions: TRPCMutationOptions<TDef>;
|
|
111
|
-
/**
|
|
112
|
-
* Calculate the TanStack Mutation Key for a Mutation Procedure
|
|
113
|
-
*
|
|
114
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#mutationKey
|
|
115
|
-
*/
|
|
116
|
-
mutationKey: () => TRPCMutationKey;
|
|
117
|
-
}
|
|
118
|
-
export interface DecorateSubscriptionProcedure<TDef extends ResolverDef> {
|
|
119
|
-
/**
|
|
120
|
-
* Create a set of type-safe subscription options that can be passed to `useSubscription`
|
|
121
|
-
*
|
|
122
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#subscriptionOptions
|
|
123
|
-
*/
|
|
124
|
-
subscriptionOptions: TRPCSubscriptionOptions<TDef>;
|
|
125
|
-
}
|
|
126
|
-
export type DecorateProcedure<TType extends TRPCProcedureType, TDef extends ResolverDef> = TType extends 'query' ? DecorateQueryProcedure<TDef> & (TDef['input'] extends OptionalCursorInput ? DecorateInfiniteQueryProcedure<TDef> : Record<string, never>) : TType extends 'mutation' ? DecorateMutationProcedure<TDef> : TType extends 'subscription' ? DecorateSubscriptionProcedure<TDef> : never;
|
|
127
|
-
/**
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
130
|
-
export type DecoratedRouterRecord<TRoot extends AnyTRPCRootTypes, TRecord extends TRPCRouterRecord> = {
|
|
131
|
-
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends TRPCRouterRecord ? DecoratedRouterRecord<TRoot, $Value> & DecorateRouterKeyable : $Value extends AnyTRPCProcedure ? DecorateProcedure<$Value['_def']['type'], {
|
|
132
|
-
input: inferProcedureInput<$Value>;
|
|
133
|
-
output: inferTransformedProcedureOutput<TRoot, $Value>;
|
|
134
|
-
transformer: TRoot['transformer'];
|
|
135
|
-
errorShape: TRoot['errorShape'];
|
|
136
|
-
}> : never : never;
|
|
137
|
-
};
|
|
138
|
-
export type TRPCOptionsProxy<TRouter extends AnyTRPCRouter> = DecoratedRouterRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']> & DecorateRouterKeyable;
|
|
139
|
-
export interface TRPCOptionsProxyOptionsBase {
|
|
140
|
-
queryClient: QueryClient | (() => QueryClient);
|
|
141
|
-
overrides?: {
|
|
142
|
-
mutations?: MutationOptionsOverride;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
export interface TRPCOptionsProxyOptionsInternal<TRouter extends AnyTRPCRouter> {
|
|
146
|
-
router: TRouter;
|
|
147
|
-
ctx: inferRouterContext<TRouter> | (() => MaybePromise<inferRouterContext<TRouter>>);
|
|
148
|
-
}
|
|
149
|
-
export interface TRPCOptionsProxyOptionsExternal<TRouter extends AnyTRPCRouter> {
|
|
150
|
-
client: TRPCUntypedClient<TRouter> | TRPCClient<TRouter>;
|
|
151
|
-
}
|
|
152
|
-
export type TRPCOptionsProxyOptions<TRouter extends AnyTRPCRouter> = TRPCOptionsProxyOptionsBase & (TRPCOptionsProxyOptionsInternal<TRouter> | TRPCOptionsProxyOptionsExternal<TRouter>);
|
|
153
|
-
/**
|
|
154
|
-
* Create a typed proxy from your router types. Can also be used on the server.
|
|
155
|
-
*
|
|
156
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3b-setup-without-react-context
|
|
157
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/server-components#5-create-a-trpc-caller-for-server-components
|
|
158
|
-
*/
|
|
159
|
-
export declare function createTRPCOptionsProxy<TRouter extends AnyTRPCRouter>(opts: TRPCOptionsProxyOptions<TRouter>): TRPCOptionsProxy<TRouter>;
|
|
160
|
-
export {};
|
|
161
|
-
//# sourceMappingURL=createOptionsProxy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createOptionsProxy.d.ts","sourceRoot":"","sources":["../../src/internals/createOptionsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,YAAY,CAAC;IAE5B;;;;;OAKG;IACH,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,Y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CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;CAC1D;AAED,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,aAAa,IAC/D,2BAA2B,GACzB,CACI,+BAA+B,CAAC,OAAO,CAAC,GACxC,+BAA+B,CAAC,OAAO,CAAC,CAC3C,CAAC;AASN;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,aAAa,EAClE,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,GACrC,gBAAgB,CAAC,OAAO,CAAC,CA4G3B"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var client = require('@trpc/client');
|
|
4
|
-
var server = require('@trpc/server');
|
|
5
|
-
var infiniteQueryOptions = require('./infiniteQueryOptions.js');
|
|
6
|
-
var mutationOptions = require('./mutationOptions.js');
|
|
7
|
-
var queryOptions = require('./queryOptions.js');
|
|
8
|
-
var subscriptionOptions = require('./subscriptionOptions.js');
|
|
9
|
-
var utils = require('./utils.js');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create a typed proxy from your router types. Can also be used on the server.
|
|
13
|
-
*
|
|
14
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3b-setup-without-react-context
|
|
15
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/server-components#5-create-a-trpc-caller-for-server-components
|
|
16
|
-
*/ function createTRPCOptionsProxy(opts) {
|
|
17
|
-
const callIt = (type)=>{
|
|
18
|
-
return (path, input, trpcOpts)=>{
|
|
19
|
-
if ('router' in opts) {
|
|
20
|
-
return Promise.resolve(utils.unwrapLazyArg(opts.ctx)).then((ctx)=>server.callTRPCProcedure({
|
|
21
|
-
router: opts.router,
|
|
22
|
-
path: path,
|
|
23
|
-
getRawInput: async ()=>input,
|
|
24
|
-
ctx: ctx,
|
|
25
|
-
type: type,
|
|
26
|
-
signal: undefined
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
const untypedClient = opts.client instanceof client.TRPCUntypedClient ? opts.client : client.getUntypedClient(opts.client);
|
|
30
|
-
return untypedClient[type](path, input, trpcOpts);
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
return server.createTRPCRecursiveProxy(({ args, path: _path })=>{
|
|
34
|
-
const path = [
|
|
35
|
-
..._path
|
|
36
|
-
];
|
|
37
|
-
const utilName = path.pop();
|
|
38
|
-
const [arg1, arg2] = args;
|
|
39
|
-
const contextMap = {
|
|
40
|
-
'~types': undefined,
|
|
41
|
-
pathKey: ()=>{
|
|
42
|
-
return utils.getQueryKeyInternal(path);
|
|
43
|
-
},
|
|
44
|
-
pathFilter: ()=>{
|
|
45
|
-
return {
|
|
46
|
-
...arg1,
|
|
47
|
-
queryKey: utils.getQueryKeyInternal(path)
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
queryOptions: ()=>{
|
|
51
|
-
return queryOptions.trpcQueryOptions({
|
|
52
|
-
input: arg1,
|
|
53
|
-
opts: arg2,
|
|
54
|
-
path,
|
|
55
|
-
queryClient: opts.queryClient,
|
|
56
|
-
queryKey: utils.getQueryKeyInternal(path, arg1, 'query'),
|
|
57
|
-
query: callIt('query')
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
queryKey: ()=>{
|
|
61
|
-
return utils.getQueryKeyInternal(path, arg1, 'query');
|
|
62
|
-
},
|
|
63
|
-
queryFilter: ()=>{
|
|
64
|
-
return {
|
|
65
|
-
...arg2,
|
|
66
|
-
queryKey: utils.getQueryKeyInternal(path, arg1, 'query')
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
infiniteQueryOptions: ()=>{
|
|
70
|
-
return infiniteQueryOptions.trpcInfiniteQueryOptions({
|
|
71
|
-
input: arg1,
|
|
72
|
-
opts: arg2,
|
|
73
|
-
path,
|
|
74
|
-
queryClient: opts.queryClient,
|
|
75
|
-
queryKey: utils.getQueryKeyInternal(path, arg1, 'infinite'),
|
|
76
|
-
query: callIt('query')
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
infiniteQueryKey: ()=>{
|
|
80
|
-
return utils.getQueryKeyInternal(path, arg1, 'infinite');
|
|
81
|
-
},
|
|
82
|
-
infiniteQueryFilter: ()=>{
|
|
83
|
-
return {
|
|
84
|
-
...arg2,
|
|
85
|
-
queryKey: utils.getQueryKeyInternal(path, arg1, 'infinite')
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
mutationOptions: ()=>{
|
|
89
|
-
return mutationOptions.trpcMutationOptions({
|
|
90
|
-
opts: arg1,
|
|
91
|
-
path,
|
|
92
|
-
queryClient: opts.queryClient,
|
|
93
|
-
mutate: callIt('mutation'),
|
|
94
|
-
overrides: opts.overrides?.mutations
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
mutationKey: ()=>{
|
|
98
|
-
return utils.getMutationKeyInternal(path);
|
|
99
|
-
},
|
|
100
|
-
subscriptionOptions: ()=>{
|
|
101
|
-
return subscriptionOptions.trpcSubscriptionOptions({
|
|
102
|
-
opts: arg2,
|
|
103
|
-
path,
|
|
104
|
-
queryKey: utils.getQueryKeyInternal(path, arg1, 'any'),
|
|
105
|
-
subscribe: callIt('subscription')
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
return contextMap[utilName]();
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
exports.createTRPCOptionsProxy = createTRPCOptionsProxy;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { TRPCUntypedClient, getUntypedClient } from '@trpc/client';
|
|
2
|
-
import { createTRPCRecursiveProxy, callTRPCProcedure } from '@trpc/server';
|
|
3
|
-
import { trpcInfiniteQueryOptions } from './infiniteQueryOptions.mjs';
|
|
4
|
-
import { trpcMutationOptions } from './mutationOptions.mjs';
|
|
5
|
-
import { trpcQueryOptions } from './queryOptions.mjs';
|
|
6
|
-
import { trpcSubscriptionOptions } from './subscriptionOptions.mjs';
|
|
7
|
-
import { getQueryKeyInternal, getMutationKeyInternal, unwrapLazyArg } from './utils.mjs';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Create a typed proxy from your router types. Can also be used on the server.
|
|
11
|
-
*
|
|
12
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3b-setup-without-react-context
|
|
13
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/server-components#5-create-a-trpc-caller-for-server-components
|
|
14
|
-
*/ function createTRPCOptionsProxy(opts) {
|
|
15
|
-
const callIt = (type)=>{
|
|
16
|
-
return (path, input, trpcOpts)=>{
|
|
17
|
-
if ('router' in opts) {
|
|
18
|
-
return Promise.resolve(unwrapLazyArg(opts.ctx)).then((ctx)=>callTRPCProcedure({
|
|
19
|
-
router: opts.router,
|
|
20
|
-
path: path,
|
|
21
|
-
getRawInput: async ()=>input,
|
|
22
|
-
ctx: ctx,
|
|
23
|
-
type: type,
|
|
24
|
-
signal: undefined
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
const untypedClient = opts.client instanceof TRPCUntypedClient ? opts.client : getUntypedClient(opts.client);
|
|
28
|
-
return untypedClient[type](path, input, trpcOpts);
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
return createTRPCRecursiveProxy(({ args, path: _path })=>{
|
|
32
|
-
const path = [
|
|
33
|
-
..._path
|
|
34
|
-
];
|
|
35
|
-
const utilName = path.pop();
|
|
36
|
-
const [arg1, arg2] = args;
|
|
37
|
-
const contextMap = {
|
|
38
|
-
'~types': undefined,
|
|
39
|
-
pathKey: ()=>{
|
|
40
|
-
return getQueryKeyInternal(path);
|
|
41
|
-
},
|
|
42
|
-
pathFilter: ()=>{
|
|
43
|
-
return {
|
|
44
|
-
...arg1,
|
|
45
|
-
queryKey: getQueryKeyInternal(path)
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
queryOptions: ()=>{
|
|
49
|
-
return trpcQueryOptions({
|
|
50
|
-
input: arg1,
|
|
51
|
-
opts: arg2,
|
|
52
|
-
path,
|
|
53
|
-
queryClient: opts.queryClient,
|
|
54
|
-
queryKey: getQueryKeyInternal(path, arg1, 'query'),
|
|
55
|
-
query: callIt('query')
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
queryKey: ()=>{
|
|
59
|
-
return getQueryKeyInternal(path, arg1, 'query');
|
|
60
|
-
},
|
|
61
|
-
queryFilter: ()=>{
|
|
62
|
-
return {
|
|
63
|
-
...arg2,
|
|
64
|
-
queryKey: getQueryKeyInternal(path, arg1, 'query')
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
infiniteQueryOptions: ()=>{
|
|
68
|
-
return trpcInfiniteQueryOptions({
|
|
69
|
-
input: arg1,
|
|
70
|
-
opts: arg2,
|
|
71
|
-
path,
|
|
72
|
-
queryClient: opts.queryClient,
|
|
73
|
-
queryKey: getQueryKeyInternal(path, arg1, 'infinite'),
|
|
74
|
-
query: callIt('query')
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
infiniteQueryKey: ()=>{
|
|
78
|
-
return getQueryKeyInternal(path, arg1, 'infinite');
|
|
79
|
-
},
|
|
80
|
-
infiniteQueryFilter: ()=>{
|
|
81
|
-
return {
|
|
82
|
-
...arg2,
|
|
83
|
-
queryKey: getQueryKeyInternal(path, arg1, 'infinite')
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
mutationOptions: ()=>{
|
|
87
|
-
return trpcMutationOptions({
|
|
88
|
-
opts: arg1,
|
|
89
|
-
path,
|
|
90
|
-
queryClient: opts.queryClient,
|
|
91
|
-
mutate: callIt('mutation'),
|
|
92
|
-
overrides: opts.overrides?.mutations
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
mutationKey: ()=>{
|
|
96
|
-
return getMutationKeyInternal(path);
|
|
97
|
-
},
|
|
98
|
-
subscriptionOptions: ()=>{
|
|
99
|
-
return trpcSubscriptionOptions({
|
|
100
|
-
opts: arg2,
|
|
101
|
-
path,
|
|
102
|
-
queryKey: getQueryKeyInternal(path, arg1, 'any'),
|
|
103
|
-
subscribe: callIt('subscription')
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
return contextMap[utilName]();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { createTRPCOptionsProxy };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { DataTag, DefinedInitialDataInfiniteOptions, QueryClient, SkipToken, UndefinedInitialDataInfiniteOptions, UnusedSkipTokenInfiniteOptions } from '@tanstack/react-query';
|
|
2
|
-
import type { TRPCClientErrorLike, TRPCUntypedClient } from '@trpc/client';
|
|
3
|
-
import type { DistributiveOmit } from '@trpc/server/unstable-core-do-not-import';
|
|
4
|
-
import type { ExtractCursorType, ResolverDef, TRPCInfiniteData, TRPCQueryBaseOptions, TRPCQueryKey, TRPCQueryOptionsResult } from './types';
|
|
5
|
-
type ReservedOptions = 'queryKey' | 'queryFn' | 'queryHashFn' | 'queryHash' | 'initialPageParam';
|
|
6
|
-
interface UndefinedTRPCInfiniteQueryOptionsIn<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TRPCInfiniteData<TInput, TData>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, ReservedOptions>, TRPCQueryBaseOptions {
|
|
7
|
-
initialCursor?: NonNullable<ExtractCursorType<TInput>> | null;
|
|
8
|
-
}
|
|
9
|
-
interface UndefinedTRPCInfiniteQueryOptionsOut<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TRPCInfiniteData<TInput, TData>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, 'initialPageParam'>, TRPCQueryOptionsResult {
|
|
10
|
-
queryKey: DataTag<TRPCQueryKey, TRPCInfiniteData<TInput, TData>, TError>;
|
|
11
|
-
initialPageParam: NonNullable<ExtractCursorType<TInput>> | null;
|
|
12
|
-
}
|
|
13
|
-
interface DefinedTRPCInfiniteQueryOptionsIn<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TRPCInfiniteData<TInput, TData>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, ReservedOptions>, TRPCQueryBaseOptions {
|
|
14
|
-
initialCursor?: NonNullable<ExtractCursorType<TInput>> | null;
|
|
15
|
-
}
|
|
16
|
-
interface DefinedTRPCInfiniteQueryOptionsOut<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TRPCInfiniteData<TInput, TData>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, 'initialPageParam'>, TRPCQueryOptionsResult {
|
|
17
|
-
queryKey: DataTag<TRPCQueryKey, TRPCInfiniteData<TInput, TData>, TError>;
|
|
18
|
-
initialPageParam: NonNullable<ExtractCursorType<TInput>> | null;
|
|
19
|
-
}
|
|
20
|
-
interface UnusedSkipTokenTRPCInfiniteQueryOptionsIn<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TRPCInfiniteData<TInput, TData>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, ReservedOptions>, TRPCQueryBaseOptions {
|
|
21
|
-
initialCursor?: NonNullable<ExtractCursorType<TInput>> | null;
|
|
22
|
-
}
|
|
23
|
-
interface UnusedSkipTokenTRPCInfiniteQueryOptionsOut<TInput, TQueryFnData, TData, TError> extends DistributiveOmit<UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TRPCInfiniteData<TInput, TData>, TRPCQueryKey, NonNullable<ExtractCursorType<TInput>> | null>, 'initialPageParam'>, TRPCQueryOptionsResult {
|
|
24
|
-
queryKey: DataTag<TRPCQueryKey, TRPCInfiniteData<TInput, TData>, TError>;
|
|
25
|
-
initialPageParam: NonNullable<ExtractCursorType<TInput>> | null;
|
|
26
|
-
}
|
|
27
|
-
export interface TRPCInfiniteQueryOptions<TDef extends ResolverDef> {
|
|
28
|
-
<TQueryFnData extends TDef['output'], TData = TQueryFnData>(input: TDef['input'] | SkipToken, opts: DefinedTRPCInfiniteQueryOptionsIn<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<{
|
|
29
|
-
transformer: TDef['transformer'];
|
|
30
|
-
errorShape: TDef['errorShape'];
|
|
31
|
-
}>>): DefinedTRPCInfiniteQueryOptionsOut<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<{
|
|
32
|
-
transformer: TDef['transformer'];
|
|
33
|
-
errorShape: TDef['errorShape'];
|
|
34
|
-
}>>;
|
|
35
|
-
<TQueryFnData extends TDef['output'], TData = TQueryFnData>(input: TDef['input'], opts: UnusedSkipTokenTRPCInfiniteQueryOptionsIn<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<{
|
|
36
|
-
transformer: TDef['transformer'];
|
|
37
|
-
errorShape: TDef['errorShape'];
|
|
38
|
-
}>>): UnusedSkipTokenTRPCInfiniteQueryOptionsOut<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<{
|
|
39
|
-
transformer: TDef['transformer'];
|
|
40
|
-
errorShape: TDef['errorShape'];
|
|
41
|
-
}>>;
|
|
42
|
-
<TQueryFnData extends TDef['output'], TData = TQueryFnData>(input: TDef['input'] | SkipToken, opts?: UndefinedTRPCInfiniteQueryOptionsIn<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<{
|
|
43
|
-
transformer: TDef['transformer'];
|
|
44
|
-
errorShape: TDef['errorShape'];
|
|
45
|
-
}>>): UndefinedTRPCInfiniteQueryOptionsOut<TDef['input'], TQueryFnData, TData, TRPCClientErrorLike<{
|
|
46
|
-
transformer: TDef['transformer'];
|
|
47
|
-
errorShape: TDef['errorShape'];
|
|
48
|
-
}>>;
|
|
49
|
-
}
|
|
50
|
-
type AnyTRPCInfiniteQueryOptionsIn = DefinedTRPCInfiniteQueryOptionsIn<any, any, any, any> | UnusedSkipTokenTRPCInfiniteQueryOptionsIn<any, any, any, any> | UndefinedTRPCInfiniteQueryOptionsIn<any, any, any, any>;
|
|
51
|
-
type AnyTRPCInfiniteQueryOptionsOut = DefinedTRPCInfiniteQueryOptionsOut<any, any, any, any> | UnusedSkipTokenTRPCInfiniteQueryOptionsOut<any, any, any, any> | UndefinedTRPCInfiniteQueryOptionsOut<any, any, any, any>;
|
|
52
|
-
export declare function trpcInfiniteQueryOptions(args: {
|
|
53
|
-
input: unknown;
|
|
54
|
-
query: typeof TRPCUntypedClient.prototype.query;
|
|
55
|
-
queryClient: QueryClient | (() => QueryClient);
|
|
56
|
-
path: readonly string[];
|
|
57
|
-
queryKey: TRPCQueryKey;
|
|
58
|
-
opts: AnyTRPCInfiniteQueryOptionsIn;
|
|
59
|
-
}): AnyTRPCInfiniteQueryOptionsOut;
|
|
60
|
-
export {};
|
|
61
|
-
//# sourceMappingURL=infiniteQueryOptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryOptions.d.ts","sourceRoot":"","sources":["../../src/internals/infiniteQueryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,iCAAiC,EACjC,WAAW,EAEX,SAAS,EACT,mCAAmC,EACnC,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAE/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,gBAAgB,EAChB,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,EAC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