@trpc/next 10.4.3 → 10.6.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.
@@ -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
- export declare function createTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext, TFlags = null>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): {
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: (AppOrPage: import("next/types").NextComponentType<any, any, any>) => import("next/types").NextComponentType<NextPageContext, {}, {}>;
8
- } & DecoratedProcedureRecord<TRouter["_def"]["record"], TFlags, "">;
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,EAIzB,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,EAAY,MAAM,YAAY,CAAC;AAEhF,wBAAgB,cAAc,CAC5B,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,MAAM,GAAG,IAAI,EACb,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;kBASjD,sBAAsB,OAAO,EAAE,WAAW,CAAC;;oEAqB5D"}
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
@@ -185,6 +185,9 @@ function createTRPCNext(opts) {
185
185
  ]);
186
186
  };
187
187
  }
188
+ if (key === 'useQueries') {
189
+ return hooks.useQueries;
190
+ }
188
191
  if (key === 'withTRPC') {
189
192
  return _withTRPC;
190
193
  }
package/dist/index.mjs CHANGED
@@ -176,6 +176,9 @@ function createTRPCNext(opts) {
176
176
  ]);
177
177
  };
178
178
  }
179
+ if (key === 'useQueries') {
180
+ return hooks.useQueries;
181
+ }
179
182
  if (key === 'withTRPC') {
180
183
  return _withTRPC;
181
184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/next",
3
- "version": "10.4.3",
3
+ "version": "10.6.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.4.3",
44
+ "@trpc/client": "10.6.0",
45
45
  "@trpc/react-query": "^10.0.0-proxy-beta.21",
46
- "@trpc/server": "10.4.3",
46
+ "@trpc/server": "10.6.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.4.3",
57
- "@trpc/react-query": "^10.4.3",
58
- "@trpc/server": "10.4.3",
56
+ "@trpc/client": "10.6.0",
57
+ "@trpc/react-query": "^10.6.0",
58
+ "@trpc/server": "10.6.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": "c5b49adb1d4e875633bb88ce282a3573fa00b404"
72
+ "gitHead": "96bf1570091557de433533d4cab5f37cb256de1c"
73
73
  }
@@ -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
- >(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {
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<TRouter, TSSRContext>(opts);
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<CreateTRPCNext>((key) => {
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
  }