@trpc/next 10.0.0-alpha.2 → 10.0.0-alpha.22
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/{declarations/src/index.d.ts → index.d.ts} +2 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/{trpc-next.cjs.dev.js → index.js} +33 -26
- package/dist/{trpc-next.esm.js → index.mjs} +18 -15
- package/dist/index.ts.js +1 -0
- package/dist/setupNext.d.ts +51 -0
- package/dist/setupNext.d.ts.map +1 -0
- package/dist/{declarations/src/withTRPC.d.ts → withTRPC.d.ts} +30 -30
- package/dist/withTRPC.d.ts.map +1 -0
- package/package.json +28 -20
- package/src/setupNext.tsx +8 -4
- package/src/withTRPC.tsx +25 -20
- package/dist/declarations/src/index.d.ts.map +0 -1
- package/dist/declarations/src/setupNext.d.ts +0 -50
- package/dist/declarations/src/setupNext.d.ts.map +0 -1
- package/dist/declarations/src/withTRPC.d.ts.map +0 -1
- package/dist/trpc-next.cjs.d.ts +0 -1
- package/dist/trpc-next.cjs.js +0 -7
- package/dist/trpc-next.cjs.prod.js +0 -250
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './withTRPC';
|
|
2
|
-
export * from './setupNext';
|
|
1
|
+
export * from './withTRPC';
|
|
2
|
+
export * from './setupNext';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -5,19 +5,26 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
6
6
|
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
7
7
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
8
|
-
var
|
|
8
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
9
9
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
10
10
|
var react = require('@trpc/react');
|
|
11
11
|
var React = require('react');
|
|
12
12
|
var reactQuery = require('react-query');
|
|
13
|
-
var hydration = require('react-query/hydration');
|
|
14
13
|
var ssrPrepass = require('react-ssr-prepass');
|
|
15
14
|
|
|
16
|
-
function
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
16
|
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
17
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
18
|
+
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
19
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
20
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
22
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
+
var ssrPrepass__default = /*#__PURE__*/_interopDefaultLegacy(ssrPrepass);
|
|
24
|
+
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
|
|
27
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
28
|
|
|
22
29
|
function transformQueryOrMutationCacheErrors(result) {
|
|
23
30
|
var error = result.state.error;
|
|
@@ -57,38 +64,38 @@ function withTRPC(opts) {
|
|
|
57
64
|
return {
|
|
58
65
|
queryClient: queryClient,
|
|
59
66
|
trpcClient: trpcClient,
|
|
60
|
-
|
|
67
|
+
ssrState: opts.ssr ? 'mounting' : false,
|
|
61
68
|
ssrContext: null
|
|
62
69
|
};
|
|
63
70
|
}),
|
|
64
|
-
_useState2 =
|
|
71
|
+
_useState2 = _slicedToArray__default["default"](_useState, 1),
|
|
65
72
|
_useState2$ = _useState2[0],
|
|
66
73
|
queryClient = _useState2$.queryClient,
|
|
67
74
|
trpcClient = _useState2$.trpcClient,
|
|
68
|
-
|
|
75
|
+
ssrState = _useState2$.ssrState,
|
|
69
76
|
ssrContext = _useState2$.ssrContext;
|
|
70
77
|
|
|
71
78
|
var hydratedState = trpc.useDehydratedState((_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
|
|
72
|
-
return /*#__PURE__*/React__default[
|
|
79
|
+
return /*#__PURE__*/React__default["default"].createElement(trpc.Provider, {
|
|
73
80
|
client: trpcClient,
|
|
74
81
|
queryClient: queryClient,
|
|
75
|
-
|
|
82
|
+
ssrState: ssrState,
|
|
76
83
|
ssrContext: ssrContext
|
|
77
|
-
}, /*#__PURE__*/React__default[
|
|
84
|
+
}, /*#__PURE__*/React__default["default"].createElement(reactQuery.QueryClientProvider, {
|
|
78
85
|
client: queryClient
|
|
79
|
-
}, /*#__PURE__*/React__default[
|
|
86
|
+
}, /*#__PURE__*/React__default["default"].createElement(reactQuery.Hydrate, {
|
|
80
87
|
state: hydratedState
|
|
81
|
-
}, /*#__PURE__*/React__default[
|
|
88
|
+
}, /*#__PURE__*/React__default["default"].createElement(AppOrPage, props))));
|
|
82
89
|
};
|
|
83
90
|
|
|
84
91
|
if (AppOrPage.getInitialProps || opts.ssr) {
|
|
85
92
|
WithTRPC.getInitialProps = /*#__PURE__*/function () {
|
|
86
|
-
var _ref =
|
|
87
|
-
var _opts$responseMeta
|
|
93
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(appOrPageCtx) {
|
|
94
|
+
var _opts$responseMeta;
|
|
88
95
|
|
|
89
96
|
var AppTree, isApp, ctx, pageProps, _originalProps$pagePr, originalProps, originalPageProps, getAppTreeProps, config, trpcClient, queryClient, trpcProp, prepassProps, dehydratedCache, dehydratedCacheWithErrors, appTreeProps, meta, _i, _Object$entries, _Object$entries$_i, key, value, _ctx$res;
|
|
90
97
|
|
|
91
|
-
return _regeneratorRuntime__default[
|
|
98
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
92
99
|
while (1) {
|
|
93
100
|
switch (_context.prev = _context.next) {
|
|
94
101
|
case 0:
|
|
@@ -136,7 +143,7 @@ function withTRPC(opts) {
|
|
|
136
143
|
config: config,
|
|
137
144
|
trpcClient: trpcClient,
|
|
138
145
|
queryClient: queryClient,
|
|
139
|
-
|
|
146
|
+
ssrState: 'prepass',
|
|
140
147
|
ssrContext: ctx
|
|
141
148
|
};
|
|
142
149
|
prepassProps = {
|
|
@@ -148,7 +155,7 @@ function withTRPC(opts) {
|
|
|
148
155
|
case 18:
|
|
149
156
|
|
|
150
157
|
_context.next = 21;
|
|
151
|
-
return ssrPrepass__default[
|
|
158
|
+
return ssrPrepass__default["default"]( /*#__PURE__*/React.createElement(AppTree, prepassProps));
|
|
152
159
|
|
|
153
160
|
case 21:
|
|
154
161
|
if (queryClient.isFetching()) {
|
|
@@ -174,7 +181,7 @@ function withTRPC(opts) {
|
|
|
174
181
|
break;
|
|
175
182
|
|
|
176
183
|
case 27:
|
|
177
|
-
dehydratedCache =
|
|
184
|
+
dehydratedCache = reactQuery.dehydrate(queryClient, {
|
|
178
185
|
shouldDehydrateQuery: function shouldDehydrateQuery() {
|
|
179
186
|
// makes sure errors are also dehydrated
|
|
180
187
|
return true;
|
|
@@ -188,17 +195,17 @@ function withTRPC(opts) {
|
|
|
188
195
|
|
|
189
196
|
pageProps.trpcState = opts.transformer ? opts.transformer.serialize(dehydratedCacheWithErrors) : dehydratedCacheWithErrors;
|
|
190
197
|
appTreeProps = getAppTreeProps(pageProps);
|
|
191
|
-
meta = (_opts$responseMeta =
|
|
198
|
+
meta = ((_opts$responseMeta = opts.responseMeta) === null || _opts$responseMeta === void 0 ? void 0 : _opts$responseMeta.call(opts, {
|
|
192
199
|
ctx: ctx,
|
|
193
|
-
clientErrors: [].concat(
|
|
200
|
+
clientErrors: [].concat(_toConsumableArray__default["default"](dehydratedCache.queries), _toConsumableArray__default["default"](dehydratedCache.mutations)).map(function (v) {
|
|
194
201
|
return v.state.error;
|
|
195
202
|
}).flatMap(function (err) {
|
|
196
203
|
return err instanceof Error && err.name === 'TRPCClientError' ? [err] : [];
|
|
197
204
|
})
|
|
198
|
-
}))
|
|
205
|
+
})) || {};
|
|
199
206
|
|
|
200
|
-
for (_i = 0, _Object$entries = Object.entries(meta); _i < _Object$entries.length; _i++) {
|
|
201
|
-
_Object$entries$_i =
|
|
207
|
+
for (_i = 0, _Object$entries = Object.entries(meta.headers || {}); _i < _Object$entries.length; _i++) {
|
|
208
|
+
_Object$entries$_i = _slicedToArray__default["default"](_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
202
209
|
|
|
203
210
|
if (typeof value === 'string') {
|
|
204
211
|
(_ctx$res = ctx.res) === null || _ctx$res === void 0 ? void 0 : _ctx$res.setHeader(key, value);
|
|
@@ -232,7 +239,7 @@ function withTRPC(opts) {
|
|
|
232
239
|
}
|
|
233
240
|
|
|
234
241
|
function setupTRPC(opts) {
|
|
235
|
-
var hooks = react.createReactQueryHooks(opts);
|
|
242
|
+
var hooks = react.createReactQueryHooks(opts); // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
236
243
|
|
|
237
244
|
var _withTRPC = withTRPC(opts);
|
|
238
245
|
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import _toConsumableArray from '@babel/runtime/helpers/
|
|
2
|
-
import _asyncToGenerator from '@babel/runtime/helpers/
|
|
3
|
-
import _slicedToArray from '@babel/runtime/helpers/
|
|
4
|
-
import
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
6
6
|
import { createReactQueryHooks, createTRPCClient } from '@trpc/react';
|
|
7
7
|
import React, { useState, createElement } from 'react';
|
|
8
|
-
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
9
|
-
import { Hydrate, dehydrate } from 'react-query/hydration';
|
|
8
|
+
import { QueryClient, QueryClientProvider, Hydrate, dehydrate } from 'react-query';
|
|
10
9
|
import ssrPrepass from 'react-ssr-prepass';
|
|
11
10
|
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
|
|
12
15
|
function transformQueryOrMutationCacheErrors(result) {
|
|
13
16
|
var error = result.state.error;
|
|
14
17
|
|
|
@@ -47,7 +50,7 @@ function withTRPC(opts) {
|
|
|
47
50
|
return {
|
|
48
51
|
queryClient: queryClient,
|
|
49
52
|
trpcClient: trpcClient,
|
|
50
|
-
|
|
53
|
+
ssrState: opts.ssr ? 'mounting' : false,
|
|
51
54
|
ssrContext: null
|
|
52
55
|
};
|
|
53
56
|
}),
|
|
@@ -55,14 +58,14 @@ function withTRPC(opts) {
|
|
|
55
58
|
_useState2$ = _useState2[0],
|
|
56
59
|
queryClient = _useState2$.queryClient,
|
|
57
60
|
trpcClient = _useState2$.trpcClient,
|
|
58
|
-
|
|
61
|
+
ssrState = _useState2$.ssrState,
|
|
59
62
|
ssrContext = _useState2$.ssrContext;
|
|
60
63
|
|
|
61
64
|
var hydratedState = trpc.useDehydratedState((_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
|
|
62
65
|
return /*#__PURE__*/React.createElement(trpc.Provider, {
|
|
63
66
|
client: trpcClient,
|
|
64
67
|
queryClient: queryClient,
|
|
65
|
-
|
|
68
|
+
ssrState: ssrState,
|
|
66
69
|
ssrContext: ssrContext
|
|
67
70
|
}, /*#__PURE__*/React.createElement(QueryClientProvider, {
|
|
68
71
|
client: queryClient
|
|
@@ -74,7 +77,7 @@ function withTRPC(opts) {
|
|
|
74
77
|
if (AppOrPage.getInitialProps || opts.ssr) {
|
|
75
78
|
WithTRPC.getInitialProps = /*#__PURE__*/function () {
|
|
76
79
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appOrPageCtx) {
|
|
77
|
-
var _opts$responseMeta
|
|
80
|
+
var _opts$responseMeta;
|
|
78
81
|
|
|
79
82
|
var AppTree, isApp, ctx, pageProps, _originalProps$pagePr, originalProps, originalPageProps, getAppTreeProps, config, trpcClient, queryClient, trpcProp, prepassProps, dehydratedCache, dehydratedCacheWithErrors, appTreeProps, meta, _i, _Object$entries, _Object$entries$_i, key, value, _ctx$res;
|
|
80
83
|
|
|
@@ -126,7 +129,7 @@ function withTRPC(opts) {
|
|
|
126
129
|
config: config,
|
|
127
130
|
trpcClient: trpcClient,
|
|
128
131
|
queryClient: queryClient,
|
|
129
|
-
|
|
132
|
+
ssrState: 'prepass',
|
|
130
133
|
ssrContext: ctx
|
|
131
134
|
};
|
|
132
135
|
prepassProps = {
|
|
@@ -178,16 +181,16 @@ function withTRPC(opts) {
|
|
|
178
181
|
|
|
179
182
|
pageProps.trpcState = opts.transformer ? opts.transformer.serialize(dehydratedCacheWithErrors) : dehydratedCacheWithErrors;
|
|
180
183
|
appTreeProps = getAppTreeProps(pageProps);
|
|
181
|
-
meta = (_opts$responseMeta =
|
|
184
|
+
meta = ((_opts$responseMeta = opts.responseMeta) === null || _opts$responseMeta === void 0 ? void 0 : _opts$responseMeta.call(opts, {
|
|
182
185
|
ctx: ctx,
|
|
183
186
|
clientErrors: [].concat(_toConsumableArray(dehydratedCache.queries), _toConsumableArray(dehydratedCache.mutations)).map(function (v) {
|
|
184
187
|
return v.state.error;
|
|
185
188
|
}).flatMap(function (err) {
|
|
186
189
|
return err instanceof Error && err.name === 'TRPCClientError' ? [err] : [];
|
|
187
190
|
})
|
|
188
|
-
}))
|
|
191
|
+
})) || {};
|
|
189
192
|
|
|
190
|
-
for (_i = 0, _Object$entries = Object.entries(meta); _i < _Object$entries.length; _i++) {
|
|
193
|
+
for (_i = 0, _Object$entries = Object.entries(meta.headers || {}); _i < _Object$entries.length; _i++) {
|
|
191
194
|
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
192
195
|
|
|
193
196
|
if (typeof value === 'string') {
|
|
@@ -222,7 +225,7 @@ function withTRPC(opts) {
|
|
|
222
225
|
}
|
|
223
226
|
|
|
224
227
|
function setupTRPC(opts) {
|
|
225
|
-
var hooks = createReactQueryHooks(opts);
|
|
228
|
+
var hooks = createReactQueryHooks(opts); // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
226
229
|
|
|
227
230
|
var _withTRPC = withTRPC(opts);
|
|
228
231
|
|
package/dist/index.ts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AnyRouter } from '@trpc/server';
|
|
2
|
+
import { NextPageContext } from 'next/types';
|
|
3
|
+
import { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
|
|
4
|
+
export declare function setupTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): {
|
|
5
|
+
useContext: () => import("@trpc/react").TRPCContextState<TRouter, unknown>;
|
|
6
|
+
useInfiniteQuery: <TPath_3 extends { [TPath in keyof TRouter["_def"]["queries"]]: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath]> extends {
|
|
7
|
+
cursor?: any;
|
|
8
|
+
} ? TPath : never; }[keyof TRouter["_def"]["queries"]] & string>(pathAndInput: [path: TPath_3, input: Omit<{ [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
9
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
10
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
11
|
+
}; }[TPath_3]["input"], "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_3, Omit<{ [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
12
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
13
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
14
|
+
}; }[TPath_3]["input"], "cursor">, { [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
15
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
16
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
17
|
+
}; }[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseInfiniteQueryResult<{ [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
18
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
19
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
20
|
+
}; }[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
21
|
+
useMutation: <TPath_1 extends keyof TRouter["_def"]["mutations"] & string>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<{ [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
|
|
22
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
|
|
23
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
|
|
24
|
+
}; }[TPath_1]["input"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
|
|
25
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
|
|
26
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
|
|
27
|
+
}; }[TPath_1]["output"]> | undefined) => import("react-query").UseMutationResult<{ [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
|
|
28
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
|
|
29
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
|
|
30
|
+
}; }[TPath_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
|
|
31
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
|
|
32
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
|
|
33
|
+
}; }[TPath_1]["input"], unknown>;
|
|
34
|
+
useQuery: <TPath_4 extends keyof TRouter["_def"]["queries"] & string>(pathAndInput: [path: TPath_4, ...args: import("@trpc/server").inferHandlerInput<TRouter["_def"]["queries"][TPath_4]>], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath_4, { [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
35
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
36
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
37
|
+
}; }[TPath_4]["input"], { [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
38
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
39
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
40
|
+
}; }[TPath_4]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseQueryResult<{ [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
41
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
42
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
43
|
+
}; }[TPath_4]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
44
|
+
useSubscription: <TPath_2 extends keyof TRouter["_def"]["subscriptions"] & string, TOutput extends import("@trpc/server/observable").inferObservableValue<import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["subscriptions"][TPath_2]["call"]>>>>(pathAndInput: [path: TPath_2, ...args: import("@trpc/server").inferHandlerInput<TRouter["_def"]["subscriptions"][TPath_2]>], opts: {
|
|
45
|
+
enabled?: boolean | undefined;
|
|
46
|
+
error?: ((err: import("@trpc/react").TRPCClientErrorLike<TRouter>) => void) | undefined;
|
|
47
|
+
next: (data: TOutput) => void;
|
|
48
|
+
}) => void;
|
|
49
|
+
withTRPC: (AppOrPage: import("next/types").NextComponentType<any, any, any>) => import("next/types").NextComponentType<NextPageContext, {}, {}>;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=setupNext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupNext.d.ts","sourceRoot":"","sources":["../src/setupNext.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAEhF,wBAAgB,SAAS,CACvB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAalE"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Heavily based on urql's ssr
|
|
3
|
-
* https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts
|
|
4
|
-
*/
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import { QueryClient } from 'react-query';
|
|
10
|
-
declare type QueryClientConfig = ConstructorParameters<typeof QueryClient>[0];
|
|
11
|
-
export declare type WithTRPCConfig<TRouter extends AnyRouter> = CreateTRPCClientOptions<TRouter> & {
|
|
12
|
-
queryClientConfig?: QueryClientConfig;
|
|
13
|
-
};
|
|
14
|
-
interface WithTRPCOptions<TRouter extends AnyRouter> extends CreateReactQueryHooksOptions {
|
|
15
|
-
config: (info: {
|
|
16
|
-
ctx?: NextPageContext;
|
|
17
|
-
}) => WithTRPCConfig<TRouter>;
|
|
18
|
-
}
|
|
19
|
-
export interface WithTRPCSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
20
|
-
ssr: true;
|
|
21
|
-
responseMeta?: (opts: {
|
|
22
|
-
ctx: NextPageContext;
|
|
23
|
-
clientErrors: TRPCClientError<TRouter>[];
|
|
24
|
-
}) => ResponseMeta;
|
|
25
|
-
}
|
|
26
|
-
export interface WithTRPCNoSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
27
|
-
ssr?: false;
|
|
28
|
-
}
|
|
29
|
-
export declare function withTRPC<TRouter extends AnyRouter>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
|
|
30
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Heavily based on urql's ssr
|
|
3
|
+
* https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts
|
|
4
|
+
*/
|
|
5
|
+
import type { CreateTRPCClientOptions } from '@trpc/client/src/internals/TRPCClient';
|
|
6
|
+
import { CreateReactQueryHooksOptions, TRPCClientError } from '@trpc/react';
|
|
7
|
+
import type { AnyRouter, ResponseMeta } from '@trpc/server';
|
|
8
|
+
import { NextComponentType, NextPageContext } from 'next/dist/shared/lib/utils';
|
|
9
|
+
import { QueryClient } from 'react-query';
|
|
10
|
+
declare type QueryClientConfig = ConstructorParameters<typeof QueryClient>[0];
|
|
11
|
+
export declare type WithTRPCConfig<TRouter extends AnyRouter> = CreateTRPCClientOptions<TRouter> & {
|
|
12
|
+
queryClientConfig?: QueryClientConfig;
|
|
13
|
+
};
|
|
14
|
+
interface WithTRPCOptions<TRouter extends AnyRouter> extends CreateReactQueryHooksOptions {
|
|
15
|
+
config: (info: {
|
|
16
|
+
ctx?: NextPageContext;
|
|
17
|
+
}) => WithTRPCConfig<TRouter>;
|
|
18
|
+
}
|
|
19
|
+
export interface WithTRPCSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
20
|
+
ssr: true;
|
|
21
|
+
responseMeta?: (opts: {
|
|
22
|
+
ctx: NextPageContext;
|
|
23
|
+
clientErrors: TRPCClientError<TRouter>[];
|
|
24
|
+
}) => ResponseMeta;
|
|
25
|
+
}
|
|
26
|
+
export interface WithTRPCNoSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
27
|
+
ssr?: false;
|
|
28
|
+
}
|
|
29
|
+
export declare function withTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
|
|
30
|
+
export {};
|
|
31
31
|
//# sourceMappingURL=withTRPC.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EACL,4BAA4B,EAE5B,eAAe,EAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAGL,WAAW,EAGZ,MAAM,aAAa,CAAC;AAGrB,aAAK,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAwBtE,oBAAY,cAAc,CAAC,OAAO,SAAS,SAAS,IAClD,uBAAuB,CAAC,OAAO,CAAC,GAAG;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEJ,UAAU,eAAe,CAAC,OAAO,SAAS,SAAS,CACjD,SAAQ,4BAA4B;IACpC,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,eAAe,CAAA;KAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,GAAG,EAAE,eAAe,CAAC;QACrB,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;KAC1C,KAAK,YAAY,CAAC;CACpB;AACD,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,SAAS,CAC7D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED,wBAAgB,QAAQ,CACtB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,eAU9C,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,iBAAiB,CAsKxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/next",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.22",
|
|
4
4
|
"description": "tRPC Next lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,15 +10,19 @@
|
|
|
10
10
|
"url": "git+https://github.com/trpc/trpc.git",
|
|
11
11
|
"directory": "packages/next"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "rollup -c"
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"module": "dist/index.mjs",
|
|
18
|
+
"typings": "dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
17
25
|
},
|
|
18
|
-
"scripts": {},
|
|
19
|
-
"main": "dist/trpc-next.cjs.js",
|
|
20
|
-
"module": "dist/trpc-next.esm.js",
|
|
21
|
-
"typings": "dist/trpc-next.cjs.d.ts",
|
|
22
26
|
"files": [
|
|
23
27
|
"README.md",
|
|
24
28
|
"dist",
|
|
@@ -26,13 +30,17 @@
|
|
|
26
30
|
],
|
|
27
31
|
"eslintConfig": {
|
|
28
32
|
"rules": {
|
|
29
|
-
"react-hooks/exhaustive-deps": "error"
|
|
33
|
+
"react-hooks/exhaustive-deps": "error",
|
|
34
|
+
"no-restricted-imports": [
|
|
35
|
+
"error",
|
|
36
|
+
"@trpc/next"
|
|
37
|
+
]
|
|
30
38
|
}
|
|
31
39
|
},
|
|
32
40
|
"peerDependencies": {
|
|
33
|
-
"@trpc/client": "10.0.0-alpha.
|
|
34
|
-
"@trpc/react": "10.0.0-alpha.
|
|
35
|
-
"@trpc/server": "10.0.0-alpha.
|
|
41
|
+
"@trpc/client": "10.0.0-alpha.22",
|
|
42
|
+
"@trpc/react": "10.0.0-alpha.22",
|
|
43
|
+
"@trpc/server": "10.0.0-alpha.22",
|
|
36
44
|
"next": "*",
|
|
37
45
|
"react": ">=16.8.0",
|
|
38
46
|
"react-dom": ">=16.8.0",
|
|
@@ -43,19 +51,19 @@
|
|
|
43
51
|
"react-ssr-prepass": "^1.5.0"
|
|
44
52
|
},
|
|
45
53
|
"devDependencies": {
|
|
46
|
-
"@trpc/client": "10.0.0-alpha.
|
|
47
|
-
"@trpc/react": "10.0.0-alpha.
|
|
48
|
-
"@trpc/server": "10.0.0-alpha.
|
|
54
|
+
"@trpc/client": "10.0.0-alpha.22",
|
|
55
|
+
"@trpc/react": "10.0.0-alpha.22",
|
|
56
|
+
"@trpc/server": "10.0.0-alpha.22",
|
|
49
57
|
"@types/express": "^4.17.12",
|
|
50
58
|
"express": "^4.17.1",
|
|
51
|
-
"next": "^12.
|
|
52
|
-
"react": "^
|
|
53
|
-
"react-dom": "^
|
|
59
|
+
"next": "^12.1.6",
|
|
60
|
+
"react": "^18.0.0",
|
|
61
|
+
"react-dom": "^18.0.0",
|
|
54
62
|
"react-query": "^3.27.0",
|
|
55
63
|
"zod": "^3.0.0"
|
|
56
64
|
},
|
|
57
65
|
"publishConfig": {
|
|
58
66
|
"access": "public"
|
|
59
67
|
},
|
|
60
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "d720eb2215f0fad6e70f4172a1bf084225d4d6de"
|
|
61
69
|
}
|
package/src/setupNext.tsx
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createReactQueryHooks } from '@trpc/react';
|
|
2
2
|
import { AnyRouter } from '@trpc/server';
|
|
3
|
+
import { NextPageContext } from 'next/types';
|
|
3
4
|
import { WithTRPCNoSSROptions, WithTRPCSSROptions, withTRPC } from './withTRPC';
|
|
4
5
|
|
|
5
|
-
export function setupTRPC<
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export function setupTRPC<
|
|
7
|
+
TRouter extends AnyRouter,
|
|
8
|
+
TSSRContext extends NextPageContext = NextPageContext,
|
|
9
|
+
>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {
|
|
8
10
|
const hooks = createReactQueryHooks<TRouter>(opts);
|
|
9
|
-
|
|
11
|
+
|
|
12
|
+
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
13
|
+
const _withTRPC = withTRPC<TRouter, TSSRContext>(opts);
|
|
10
14
|
return {
|
|
11
15
|
useContext: hooks.useContext,
|
|
12
16
|
useInfiniteQuery: hooks.useInfiniteQuery,
|
package/src/withTRPC.tsx
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Heavily based on urql's ssr
|
|
3
3
|
* https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import type { CreateTRPCClientOptions } from '@trpc/client/src/internals/TRPCClient';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
createTRPCClient,
|
|
7
|
+
CreateReactQueryHooksOptions,
|
|
9
8
|
TRPCClient,
|
|
10
9
|
TRPCClientError,
|
|
11
10
|
TRPCClientErrorLike,
|
|
12
|
-
|
|
11
|
+
createReactQueryHooks,
|
|
12
|
+
createTRPCClient,
|
|
13
13
|
} from '@trpc/react';
|
|
14
14
|
import type { AnyRouter, Dict, Maybe, ResponseMeta } from '@trpc/server';
|
|
15
15
|
import {
|
|
@@ -18,10 +18,14 @@ import {
|
|
|
18
18
|
NextComponentType,
|
|
19
19
|
NextPageContext,
|
|
20
20
|
} from 'next/dist/shared/lib/utils';
|
|
21
|
-
import type { CreateTRPCClientOptions } from '@trpc/client/src/internals/TRPCClient';
|
|
22
21
|
import React, { createElement, useState } from 'react';
|
|
23
|
-
import {
|
|
24
|
-
|
|
22
|
+
import {
|
|
23
|
+
DehydratedState,
|
|
24
|
+
Hydrate,
|
|
25
|
+
QueryClient,
|
|
26
|
+
QueryClientProvider,
|
|
27
|
+
dehydrate,
|
|
28
|
+
} from 'react-query';
|
|
25
29
|
import ssrPrepass from 'react-ssr-prepass';
|
|
26
30
|
|
|
27
31
|
type QueryClientConfig = ConstructorParameters<typeof QueryClient>[0];
|
|
@@ -71,27 +75,28 @@ export interface WithTRPCNoSSROptions<TRouter extends AnyRouter>
|
|
|
71
75
|
ssr?: false;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
export function withTRPC<
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
export function withTRPC<
|
|
79
|
+
TRouter extends AnyRouter,
|
|
80
|
+
TSSRContext extends NextPageContext = NextPageContext,
|
|
81
|
+
>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {
|
|
77
82
|
const { config: getClientConfig } = opts;
|
|
78
83
|
|
|
79
84
|
type TRPCPrepassProps = {
|
|
80
85
|
config: WithTRPCConfig<TRouter>;
|
|
81
86
|
queryClient: QueryClient;
|
|
82
87
|
trpcClient: TRPCClient<TRouter>;
|
|
83
|
-
|
|
84
|
-
ssrContext:
|
|
88
|
+
ssrState: 'prepass';
|
|
89
|
+
ssrContext: TSSRContext;
|
|
85
90
|
};
|
|
86
91
|
return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {
|
|
87
|
-
const trpc = createReactQueryHooks<TRouter,
|
|
92
|
+
const trpc = createReactQueryHooks<TRouter, TSSRContext>(opts);
|
|
88
93
|
|
|
89
94
|
const WithTRPC = (
|
|
90
95
|
props: AppPropsType & {
|
|
91
96
|
trpc?: TRPCPrepassProps;
|
|
92
97
|
},
|
|
93
98
|
) => {
|
|
94
|
-
const [{ queryClient, trpcClient,
|
|
99
|
+
const [{ queryClient, trpcClient, ssrState, ssrContext }] = useState(
|
|
95
100
|
() => {
|
|
96
101
|
if (props.trpc) {
|
|
97
102
|
return props.trpc;
|
|
@@ -102,7 +107,7 @@ export function withTRPC<TRouter extends AnyRouter>(
|
|
|
102
107
|
return {
|
|
103
108
|
queryClient,
|
|
104
109
|
trpcClient,
|
|
105
|
-
|
|
110
|
+
ssrState: opts.ssr ? ('mounting' as const) : (false as const),
|
|
106
111
|
ssrContext: null,
|
|
107
112
|
};
|
|
108
113
|
},
|
|
@@ -114,7 +119,7 @@ export function withTRPC<TRouter extends AnyRouter>(
|
|
|
114
119
|
<trpc.Provider
|
|
115
120
|
client={trpcClient}
|
|
116
121
|
queryClient={queryClient}
|
|
117
|
-
|
|
122
|
+
ssrState={ssrState}
|
|
118
123
|
ssrContext={ssrContext}
|
|
119
124
|
>
|
|
120
125
|
<QueryClientProvider client={queryClient}>
|
|
@@ -166,8 +171,8 @@ export function withTRPC<TRouter extends AnyRouter>(
|
|
|
166
171
|
config,
|
|
167
172
|
trpcClient,
|
|
168
173
|
queryClient,
|
|
169
|
-
|
|
170
|
-
ssrContext: ctx,
|
|
174
|
+
ssrState: 'prepass',
|
|
175
|
+
ssrContext: ctx as TSSRContext,
|
|
171
176
|
};
|
|
172
177
|
const prepassProps = {
|
|
173
178
|
pageProps,
|
|
@@ -230,9 +235,9 @@ export function withTRPC<TRouter extends AnyRouter>(
|
|
|
230
235
|
? [err as TRPCClientError<TRouter>]
|
|
231
236
|
: [],
|
|
232
237
|
),
|
|
233
|
-
})
|
|
238
|
+
}) || {};
|
|
234
239
|
|
|
235
|
-
for (const [key, value] of Object.entries(meta)) {
|
|
240
|
+
for (const [key, value] of Object.entries(meta.headers || {})) {
|
|
236
241
|
if (typeof value === 'string') {
|
|
237
242
|
ctx.res?.setHeader(key, value);
|
|
238
243
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { AnyRouter } from '@trpc/server';
|
|
2
|
-
import { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
|
|
3
|
-
export declare function setupTRPC<TRouter extends AnyRouter>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): {
|
|
4
|
-
useContext: () => import("@trpc/react").TRPCContextState<TRouter, unknown>;
|
|
5
|
-
useInfiniteQuery: <TPath_1 extends { [TPath in keyof TRouter["_def"]["queries"]]: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath]> extends {
|
|
6
|
-
cursor?: any;
|
|
7
|
-
} ? TPath : never; }[keyof TRouter["_def"]["queries"]] & string>(pathAndInput: [path: TPath_1, input: Omit<{ [TPath_2 in keyof TRouter["_def"]["queries"]]: {
|
|
8
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_2]>;
|
|
9
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_2]["call"]>>;
|
|
10
|
-
}; }[TPath_1]["input"], "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_1, Omit<{ [TPath_2 in keyof TRouter["_def"]["queries"]]: {
|
|
11
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_2]>;
|
|
12
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_2]["call"]>>;
|
|
13
|
-
}; }[TPath_1]["input"], "cursor">, { [TPath_2 in keyof TRouter["_def"]["queries"]]: {
|
|
14
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_2]>;
|
|
15
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_2]["call"]>>;
|
|
16
|
-
}; }[TPath_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseInfiniteQueryResult<{ [TPath_2 in keyof TRouter["_def"]["queries"]]: {
|
|
17
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_2]>;
|
|
18
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_2]["call"]>>;
|
|
19
|
-
}; }[TPath_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
20
|
-
useMutation: <TPath_3 extends keyof TRouter["_def"]["mutations"] & string>(path: TPath_3 | [TPath_3], opts?: import("@trpc/react").UseTRPCMutationOptions<{ [TPath_4 in keyof TRouter["_def"]["mutations"]]: {
|
|
21
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_4]>;
|
|
22
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_4]["call"]>>;
|
|
23
|
-
}; }[TPath_3]["input"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_4 in keyof TRouter["_def"]["mutations"]]: {
|
|
24
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_4]>;
|
|
25
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_4]["call"]>>;
|
|
26
|
-
}; }[TPath_3]["output"]> | undefined) => import("react-query").UseMutationResult<{ [TPath_4 in keyof TRouter["_def"]["mutations"]]: {
|
|
27
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_4]>;
|
|
28
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_4]["call"]>>;
|
|
29
|
-
}; }[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_4 in keyof TRouter["_def"]["mutations"]]: {
|
|
30
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_4]>;
|
|
31
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_4]["call"]>>;
|
|
32
|
-
}; }[TPath_3]["input"], unknown>;
|
|
33
|
-
useQuery: <TPath_5 extends keyof TRouter["_def"]["queries"] & string>(pathAndInput: [path: TPath_5, ...args: import("@trpc/server").inferHandlerInput<TRouter["_def"]["queries"][TPath_5]>], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath_5, { [TPath_2 in keyof TRouter["_def"]["queries"]]: {
|
|
34
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_2]>;
|
|
35
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_2]["call"]>>;
|
|
36
|
-
}; }[TPath_5]["input"], { [TPath_2 in keyof TRouter["_def"]["queries"]]: {
|
|
37
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_2]>;
|
|
38
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_2]["call"]>>;
|
|
39
|
-
}; }[TPath_5]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseQueryResult<{ [TPath_2 in keyof TRouter["_def"]["queries"]]: {
|
|
40
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_2]>;
|
|
41
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_2]["call"]>>;
|
|
42
|
-
}; }[TPath_5]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
43
|
-
useSubscription: <TPath_6 extends keyof TRouter["_def"]["subscriptions"] & string, TOutput extends ReturnType<import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["subscriptions"][TPath_6]["call"]>>["output"]>>(pathAndInput: [path: TPath_6, ...args: import("@trpc/server").inferHandlerInput<TRouter["_def"]["subscriptions"][TPath_6]>], opts: {
|
|
44
|
-
enabled?: boolean | undefined;
|
|
45
|
-
error?: ((err: import("@trpc/react").TRPCClientErrorLike<TRouter>) => void) | undefined;
|
|
46
|
-
next: (data: TOutput) => void;
|
|
47
|
-
}) => void;
|
|
48
|
-
withTRPC: (AppOrPage: import("next").NextComponentType<any, any, any>) => import("next").NextComponentType<import("next").NextPageContext, {}, {}>;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=setupNext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupNext.d.ts","sourceRoot":"../../../src","sources":["setupNext.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAEhF,wBAAgB,SAAS,CAAC,OAAO,SAAS,SAAS,EACjD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYlE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withTRPC.d.ts","sourceRoot":"../../../src","sources":["withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,eAAe,EAEf,4BAA4B,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAErF,OAAO,EAAE,WAAW,EAAuB,MAAM,aAAa,CAAC;AAI/D,aAAK,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAwBtE,oBAAY,cAAc,CAAC,OAAO,SAAS,SAAS,IAClD,uBAAuB,CAAC,OAAO,CAAC,GAAG;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEJ,UAAU,eAAe,CAAC,OAAO,SAAS,SAAS,CACjD,SAAQ,4BAA4B;IACpC,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,eAAe,CAAA;KAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,GAAG,EAAE,eAAe,CAAC;QACrB,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;KAC1C,KAAK,YAAY,CAAC;CACpB;AACD,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,SAAS,CAC7D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED,wBAAgB,QAAQ,CAAC,OAAO,SAAS,SAAS,EAChD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,eAW9C,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,iBAAiB,CAsKxE"}
|
package/dist/trpc-next.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./declarations/src/index";
|
package/dist/trpc-next.cjs.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
6
|
-
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
7
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
8
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
9
|
-
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
10
|
-
var react = require('@trpc/react');
|
|
11
|
-
var React = require('react');
|
|
12
|
-
var reactQuery = require('react-query');
|
|
13
|
-
var hydration = require('react-query/hydration');
|
|
14
|
-
var ssrPrepass = require('react-ssr-prepass');
|
|
15
|
-
|
|
16
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
17
|
-
|
|
18
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
19
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
20
|
-
var ssrPrepass__default = /*#__PURE__*/_interopDefault(ssrPrepass);
|
|
21
|
-
|
|
22
|
-
function transformQueryOrMutationCacheErrors(result) {
|
|
23
|
-
var error = result.state.error;
|
|
24
|
-
|
|
25
|
-
if (error instanceof Error && error.name === 'TRPCClientError') {
|
|
26
|
-
var newError = {
|
|
27
|
-
message: error.message,
|
|
28
|
-
data: error.data,
|
|
29
|
-
shape: error.shape
|
|
30
|
-
};
|
|
31
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
32
|
-
state: _objectSpread(_objectSpread({}, result.state), {}, {
|
|
33
|
-
error: newError
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function withTRPC(opts) {
|
|
42
|
-
var getClientConfig = opts.config;
|
|
43
|
-
return function (AppOrPage) {
|
|
44
|
-
var trpc = react.createReactQueryHooks(opts);
|
|
45
|
-
|
|
46
|
-
var WithTRPC = function WithTRPC(props) {
|
|
47
|
-
var _props$pageProps;
|
|
48
|
-
|
|
49
|
-
var _useState = React.useState(function () {
|
|
50
|
-
if (props.trpc) {
|
|
51
|
-
return props.trpc;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var config = getClientConfig({});
|
|
55
|
-
var queryClient = new reactQuery.QueryClient(config.queryClientConfig);
|
|
56
|
-
var trpcClient = trpc.createClient(config);
|
|
57
|
-
return {
|
|
58
|
-
queryClient: queryClient,
|
|
59
|
-
trpcClient: trpcClient,
|
|
60
|
-
isPrepass: false,
|
|
61
|
-
ssrContext: null
|
|
62
|
-
};
|
|
63
|
-
}),
|
|
64
|
-
_useState2 = _slicedToArray(_useState, 1),
|
|
65
|
-
_useState2$ = _useState2[0],
|
|
66
|
-
queryClient = _useState2$.queryClient,
|
|
67
|
-
trpcClient = _useState2$.trpcClient,
|
|
68
|
-
isPrepass = _useState2$.isPrepass,
|
|
69
|
-
ssrContext = _useState2$.ssrContext;
|
|
70
|
-
|
|
71
|
-
var hydratedState = trpc.useDehydratedState((_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
|
|
72
|
-
return /*#__PURE__*/React__default['default'].createElement(trpc.Provider, {
|
|
73
|
-
client: trpcClient,
|
|
74
|
-
queryClient: queryClient,
|
|
75
|
-
isPrepass: isPrepass,
|
|
76
|
-
ssrContext: ssrContext
|
|
77
|
-
}, /*#__PURE__*/React__default['default'].createElement(reactQuery.QueryClientProvider, {
|
|
78
|
-
client: queryClient
|
|
79
|
-
}, /*#__PURE__*/React__default['default'].createElement(hydration.Hydrate, {
|
|
80
|
-
state: hydratedState
|
|
81
|
-
}, /*#__PURE__*/React__default['default'].createElement(AppOrPage, props))));
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
if (AppOrPage.getInitialProps || opts.ssr) {
|
|
85
|
-
WithTRPC.getInitialProps = /*#__PURE__*/function () {
|
|
86
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(appOrPageCtx) {
|
|
87
|
-
var _opts$responseMeta, _opts$responseMeta2;
|
|
88
|
-
|
|
89
|
-
var AppTree, isApp, ctx, pageProps, _originalProps$pagePr, originalProps, originalPageProps, getAppTreeProps, config, trpcClient, queryClient, trpcProp, prepassProps, dehydratedCache, dehydratedCacheWithErrors, appTreeProps, meta, _i, _Object$entries, _Object$entries$_i, key, value, _ctx$res;
|
|
90
|
-
|
|
91
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
92
|
-
while (1) {
|
|
93
|
-
switch (_context.prev = _context.next) {
|
|
94
|
-
case 0:
|
|
95
|
-
AppTree = appOrPageCtx.AppTree; // Determine if we are wrapping an App component or a Page component.
|
|
96
|
-
|
|
97
|
-
isApp = !!appOrPageCtx.Component;
|
|
98
|
-
ctx = isApp ? appOrPageCtx.ctx : appOrPageCtx; // Run the wrapped component's getInitialProps function.
|
|
99
|
-
|
|
100
|
-
pageProps = {};
|
|
101
|
-
|
|
102
|
-
if (!AppOrPage.getInitialProps) {
|
|
103
|
-
_context.next = 10;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
_context.next = 7;
|
|
108
|
-
return AppOrPage.getInitialProps(appOrPageCtx);
|
|
109
|
-
|
|
110
|
-
case 7:
|
|
111
|
-
originalProps = _context.sent;
|
|
112
|
-
originalPageProps = isApp ? (_originalProps$pagePr = originalProps.pageProps) !== null && _originalProps$pagePr !== void 0 ? _originalProps$pagePr : {} : originalProps;
|
|
113
|
-
pageProps = _objectSpread(_objectSpread({}, originalPageProps), pageProps);
|
|
114
|
-
|
|
115
|
-
case 10:
|
|
116
|
-
getAppTreeProps = function getAppTreeProps(props) {
|
|
117
|
-
return isApp ? {
|
|
118
|
-
pageProps: props
|
|
119
|
-
} : props;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
if (!(typeof window !== 'undefined' || !opts.ssr)) {
|
|
123
|
-
_context.next = 13;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return _context.abrupt("return", getAppTreeProps(pageProps));
|
|
128
|
-
|
|
129
|
-
case 13:
|
|
130
|
-
config = getClientConfig({
|
|
131
|
-
ctx: ctx
|
|
132
|
-
});
|
|
133
|
-
trpcClient = react.createTRPCClient(config);
|
|
134
|
-
queryClient = new reactQuery.QueryClient(config.queryClientConfig);
|
|
135
|
-
trpcProp = {
|
|
136
|
-
config: config,
|
|
137
|
-
trpcClient: trpcClient,
|
|
138
|
-
queryClient: queryClient,
|
|
139
|
-
isPrepass: true,
|
|
140
|
-
ssrContext: ctx
|
|
141
|
-
};
|
|
142
|
-
prepassProps = {
|
|
143
|
-
pageProps: pageProps,
|
|
144
|
-
trpc: trpcProp
|
|
145
|
-
}; // Run the prepass step on AppTree. This will run all trpc queries on the server.
|
|
146
|
-
// multiple prepass ensures that we can do batching on the server
|
|
147
|
-
|
|
148
|
-
case 18:
|
|
149
|
-
|
|
150
|
-
_context.next = 21;
|
|
151
|
-
return ssrPrepass__default['default']( /*#__PURE__*/React.createElement(AppTree, prepassProps));
|
|
152
|
-
|
|
153
|
-
case 21:
|
|
154
|
-
if (queryClient.isFetching()) {
|
|
155
|
-
_context.next = 23;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return _context.abrupt("break", 27);
|
|
160
|
-
|
|
161
|
-
case 23:
|
|
162
|
-
_context.next = 25;
|
|
163
|
-
return new Promise(function (resolve) {
|
|
164
|
-
var unsub = queryClient.getQueryCache().subscribe(function (event) {
|
|
165
|
-
if ((event === null || event === void 0 ? void 0 : event.query.getObserversCount()) === 0) {
|
|
166
|
-
resolve();
|
|
167
|
-
unsub();
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
case 25:
|
|
173
|
-
_context.next = 18;
|
|
174
|
-
break;
|
|
175
|
-
|
|
176
|
-
case 27:
|
|
177
|
-
dehydratedCache = hydration.dehydrate(queryClient, {
|
|
178
|
-
shouldDehydrateQuery: function shouldDehydrateQuery() {
|
|
179
|
-
// makes sure errors are also dehydrated
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
}); // since error instances can't be serialized, let's make them into `TRPCClientErrorLike`-objects
|
|
183
|
-
|
|
184
|
-
dehydratedCacheWithErrors = _objectSpread(_objectSpread({}, dehydratedCache), {}, {
|
|
185
|
-
queries: dehydratedCache.queries.map(transformQueryOrMutationCacheErrors),
|
|
186
|
-
mutations: dehydratedCache.mutations.map(transformQueryOrMutationCacheErrors)
|
|
187
|
-
}); // dehydrate query client's state and add it to the props
|
|
188
|
-
|
|
189
|
-
pageProps.trpcState = opts.transformer ? opts.transformer.serialize(dehydratedCacheWithErrors) : dehydratedCacheWithErrors;
|
|
190
|
-
appTreeProps = getAppTreeProps(pageProps);
|
|
191
|
-
meta = (_opts$responseMeta = (_opts$responseMeta2 = opts.responseMeta) === null || _opts$responseMeta2 === void 0 ? void 0 : _opts$responseMeta2.call(opts, {
|
|
192
|
-
ctx: ctx,
|
|
193
|
-
clientErrors: [].concat(_toConsumableArray(dehydratedCache.queries), _toConsumableArray(dehydratedCache.mutations)).map(function (v) {
|
|
194
|
-
return v.state.error;
|
|
195
|
-
}).flatMap(function (err) {
|
|
196
|
-
return err instanceof Error && err.name === 'TRPCClientError' ? [err] : [];
|
|
197
|
-
})
|
|
198
|
-
})) !== null && _opts$responseMeta !== void 0 ? _opts$responseMeta : {};
|
|
199
|
-
|
|
200
|
-
for (_i = 0, _Object$entries = Object.entries(meta); _i < _Object$entries.length; _i++) {
|
|
201
|
-
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
202
|
-
|
|
203
|
-
if (typeof value === 'string') {
|
|
204
|
-
(_ctx$res = ctx.res) === null || _ctx$res === void 0 ? void 0 : _ctx$res.setHeader(key, value);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (meta.status && ctx.res) {
|
|
209
|
-
ctx.res.statusCode = meta.status;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return _context.abrupt("return", appTreeProps);
|
|
213
|
-
|
|
214
|
-
case 35:
|
|
215
|
-
case "end":
|
|
216
|
-
return _context.stop();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}, _callee);
|
|
220
|
-
}));
|
|
221
|
-
|
|
222
|
-
return function (_x) {
|
|
223
|
-
return _ref.apply(this, arguments);
|
|
224
|
-
};
|
|
225
|
-
}();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
var displayName = AppOrPage.displayName || AppOrPage.name || 'Component';
|
|
229
|
-
WithTRPC.displayName = "withTRPC(".concat(displayName, ")");
|
|
230
|
-
return WithTRPC;
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function setupTRPC(opts) {
|
|
235
|
-
var hooks = react.createReactQueryHooks(opts);
|
|
236
|
-
|
|
237
|
-
var _withTRPC = withTRPC(opts);
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
useContext: hooks.useContext,
|
|
241
|
-
useInfiniteQuery: hooks.useInfiniteQuery,
|
|
242
|
-
useMutation: hooks.useMutation,
|
|
243
|
-
useQuery: hooks.useQuery,
|
|
244
|
-
useSubscription: hooks.useSubscription,
|
|
245
|
-
withTRPC: _withTRPC
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
exports.setupTRPC = setupTRPC;
|
|
250
|
-
exports.withTRPC = withTRPC;
|