@trpc/next 10.5.0 → 10.7.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/dist/createTRPCNext.d.ts +14 -5
- package/dist/createTRPCNext.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.mjs +3 -0
- package/package.json +7 -7
- package/src/createTRPCNext.tsx +32 -8
package/dist/createTRPCNext.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { CreateReactUtilsProxy, DecoratedProcedureRecord } from '@trpc/react-query/shared';
|
|
1
|
+
import { CreateReactUtilsProxy, DecoratedProcedureRecord, TRPCUseQueries } from '@trpc/react-query/shared';
|
|
2
2
|
import { AnyRouter } from '@trpc/server';
|
|
3
3
|
import { NextPageContext } from 'next/types';
|
|
4
|
-
import { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
|
|
5
|
-
|
|
4
|
+
import { WithTRPCNoSSROptions, WithTRPCSSROptions, withTRPC } from './withTRPC';
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface CreateTRPCNextBase<TRouter extends AnyRouter, TSSRContext extends NextPageContext> {
|
|
6
9
|
useContext(): CreateReactUtilsProxy<TRouter, TSSRContext>;
|
|
7
|
-
withTRPC:
|
|
8
|
-
|
|
10
|
+
withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
|
|
11
|
+
useQueries: TRPCUseQueries<TRouter>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare type CreateTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext, TFlags> = CreateTRPCNextBase<TRouter, TSSRContext> & DecoratedProcedureRecord<TRouter['_def']['record'], TFlags>;
|
|
17
|
+
export declare function createTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext, TFlags = null>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): CreateTRPCNext<TRouter, TSSRContext, TFlags>;
|
|
9
18
|
//# sourceMappingURL=createTRPCNext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTRPCNext.d.ts","sourceRoot":"","sources":["../src/createTRPCNext.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"createTRPCNext.d.ts","sourceRoot":"","sources":["../src/createTRPCNext.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EAIf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe;IAEnC,UAAU,IAAI,qBAAqB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC1D,QAAQ,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAC5D,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,oBAAY,cAAc,CACxB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,EACnC,MAAM,IACJ,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,GAC1C,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;AAE9D,wBAAgB,cAAc,CAC5B,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,MAAM,GAAG,IAAI,EAEb,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAChE,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CA6B9C"}
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/next",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.7.0",
|
|
4
4
|
"description": "tRPC Next lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@tanstack/react-query": "^4.3.8",
|
|
44
|
-
"@trpc/client": "10.
|
|
44
|
+
"@trpc/client": "10.7.0",
|
|
45
45
|
"@trpc/react-query": "^10.0.0-proxy-beta.21",
|
|
46
|
-
"@trpc/server": "10.
|
|
46
|
+
"@trpc/server": "10.7.0",
|
|
47
47
|
"next": "*",
|
|
48
48
|
"react": ">=16.8.0",
|
|
49
49
|
"react-dom": ">=16.8.0"
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@tanstack/react-query": "^4.3.8",
|
|
56
|
-
"@trpc/client": "10.
|
|
57
|
-
"@trpc/react-query": "^10.
|
|
58
|
-
"@trpc/server": "10.
|
|
56
|
+
"@trpc/client": "10.7.0",
|
|
57
|
+
"@trpc/react-query": "^10.7.0",
|
|
58
|
+
"@trpc/server": "10.7.0",
|
|
59
59
|
"@types/express": "^4.17.12",
|
|
60
60
|
"@types/node": "^18.7.20",
|
|
61
61
|
"express": "^4.17.1",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "dd8e424c0f0d3a43b6c6cb0356c4ac1b8199c4d0"
|
|
73
73
|
}
|
package/src/createTRPCNext.tsx
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
CreateReactUtilsProxy,
|
|
5
5
|
DecoratedProcedureRecord,
|
|
6
|
+
TRPCUseQueries,
|
|
6
7
|
createHooksInternal,
|
|
7
8
|
createReactProxyDecoration,
|
|
8
9
|
createReactQueryUtilsProxy,
|
|
@@ -13,24 +14,43 @@ import { NextPageContext } from 'next/types';
|
|
|
13
14
|
import { useMemo } from 'react';
|
|
14
15
|
import { WithTRPCNoSSROptions, WithTRPCSSROptions, withTRPC } from './withTRPC';
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export interface CreateTRPCNextBase<
|
|
21
|
+
TRouter extends AnyRouter,
|
|
22
|
+
TSSRContext extends NextPageContext,
|
|
23
|
+
> {
|
|
24
|
+
useContext(): CreateReactUtilsProxy<TRouter, TSSRContext>;
|
|
25
|
+
withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
|
|
26
|
+
useQueries: TRPCUseQueries<TRouter>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export type CreateTRPCNext<
|
|
33
|
+
TRouter extends AnyRouter,
|
|
34
|
+
TSSRContext extends NextPageContext,
|
|
35
|
+
TFlags,
|
|
36
|
+
> = CreateTRPCNextBase<TRouter, TSSRContext> &
|
|
37
|
+
DecoratedProcedureRecord<TRouter['_def']['record'], TFlags>;
|
|
38
|
+
|
|
16
39
|
export function createTRPCNext<
|
|
17
40
|
TRouter extends AnyRouter,
|
|
18
41
|
TSSRContext extends NextPageContext = NextPageContext,
|
|
19
42
|
TFlags = null,
|
|
20
|
-
>(
|
|
43
|
+
>(
|
|
44
|
+
opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>,
|
|
45
|
+
): CreateTRPCNext<TRouter, TSSRContext, TFlags> {
|
|
21
46
|
const hooks = createHooksInternal<TRouter, TSSRContext>({
|
|
22
47
|
unstable_overrides: opts.unstable_overrides,
|
|
23
48
|
});
|
|
24
49
|
|
|
25
50
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
26
|
-
const _withTRPC = withTRPC
|
|
27
|
-
|
|
28
|
-
type CreateTRPCNext = {
|
|
29
|
-
useContext(): CreateReactUtilsProxy<TRouter, TSSRContext>;
|
|
30
|
-
withTRPC: typeof _withTRPC;
|
|
31
|
-
} & DecoratedProcedureRecord<TRouter['_def']['record'], TFlags>;
|
|
51
|
+
const _withTRPC = withTRPC(opts);
|
|
32
52
|
|
|
33
|
-
return createFlatProxy
|
|
53
|
+
return createFlatProxy((key) => {
|
|
34
54
|
if (key === 'useContext') {
|
|
35
55
|
return () => {
|
|
36
56
|
const context = hooks.useContext();
|
|
@@ -41,6 +61,10 @@ export function createTRPCNext<
|
|
|
41
61
|
};
|
|
42
62
|
}
|
|
43
63
|
|
|
64
|
+
if (key === 'useQueries') {
|
|
65
|
+
return hooks.useQueries;
|
|
66
|
+
}
|
|
67
|
+
|
|
44
68
|
if (key === 'withTRPC') {
|
|
45
69
|
return _withTRPC;
|
|
46
70
|
}
|