@trpc/next 10.0.0-alpha.20 → 10.0.0-alpha.21

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.js CHANGED
@@ -239,7 +239,7 @@ function withTRPC(opts) {
239
239
  }
240
240
 
241
241
  function setupTRPC(opts) {
242
- var hooks = react.createReactQueryHooks(opts);
242
+ var hooks = react.createReactQueryHooks(opts); // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
243
243
 
244
244
  var _withTRPC = withTRPC(opts);
245
245
 
package/dist/index.mjs CHANGED
@@ -225,7 +225,7 @@ function withTRPC(opts) {
225
225
  }
226
226
 
227
227
  function setupTRPC(opts) {
228
- var hooks = createReactQueryHooks(opts);
228
+ var hooks = createReactQueryHooks(opts); // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
229
229
 
230
230
  var _withTRPC = withTRPC(opts);
231
231
 
@@ -1,6 +1,7 @@
1
1
  import { AnyRouter } from '@trpc/server';
2
+ import { NextPageContext } from 'next/types';
2
3
  import { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
3
- export declare function setupTRPC<TRouter extends AnyRouter>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): {
4
+ export declare function setupTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): {
4
5
  useContext: () => import("@trpc/react").TRPCContextState<TRouter, unknown>;
5
6
  useInfiniteQuery: <TPath_3 extends { [TPath in keyof TRouter["_def"]["queries"]]: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath]> extends {
6
7
  cursor?: any;
@@ -45,6 +46,6 @@ export declare function setupTRPC<TRouter extends AnyRouter>(opts: WithTRPCNoSSR
45
46
  error?: ((err: import("@trpc/react").TRPCClientErrorLike<TRouter>) => void) | undefined;
46
47
  next: (data: TOutput) => void;
47
48
  }) => void;
48
- withTRPC: (AppOrPage: import("next/types").NextComponentType<any, any, any>) => import("next/types").NextComponentType<import("next/types").NextPageContext, {}, {}>;
49
+ withTRPC: (AppOrPage: import("next/types").NextComponentType<any, any, any>) => import("next/types").NextComponentType<NextPageContext, {}, {}>;
49
50
  };
50
51
  //# sourceMappingURL=setupNext.d.ts.map
@@ -1 +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,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
+ {"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"}
@@ -26,6 +26,6 @@ export interface WithTRPCSSROptions<TRouter extends AnyRouter> extends WithTRPCO
26
26
  export interface WithTRPCNoSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
27
27
  ssr?: false;
28
28
  }
29
- export declare function withTRPC<TRouter extends AnyRouter>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
29
+ export declare function withTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
30
30
  export {};
31
31
  //# sourceMappingURL=withTRPC.d.ts.map
@@ -1 +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,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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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.20",
3
+ "version": "10.0.0-alpha.21",
4
4
  "description": "tRPC Next lib",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -30,13 +30,17 @@
30
30
  ],
31
31
  "eslintConfig": {
32
32
  "rules": {
33
- "react-hooks/exhaustive-deps": "error"
33
+ "react-hooks/exhaustive-deps": "error",
34
+ "no-restricted-imports": [
35
+ "error",
36
+ "@trpc/next"
37
+ ]
34
38
  }
35
39
  },
36
40
  "peerDependencies": {
37
- "@trpc/client": "10.0.0-alpha.20",
38
- "@trpc/react": "10.0.0-alpha.20",
39
- "@trpc/server": "10.0.0-alpha.20",
41
+ "@trpc/client": "10.0.0-alpha.21",
42
+ "@trpc/react": "10.0.0-alpha.21",
43
+ "@trpc/server": "10.0.0-alpha.21",
40
44
  "next": "*",
41
45
  "react": ">=16.8.0",
42
46
  "react-dom": ">=16.8.0",
@@ -47,9 +51,9 @@
47
51
  "react-ssr-prepass": "^1.5.0"
48
52
  },
49
53
  "devDependencies": {
50
- "@trpc/client": "10.0.0-alpha.20",
51
- "@trpc/react": "10.0.0-alpha.20",
52
- "@trpc/server": "10.0.0-alpha.20",
54
+ "@trpc/client": "10.0.0-alpha.21",
55
+ "@trpc/react": "10.0.0-alpha.21",
56
+ "@trpc/server": "10.0.0-alpha.21",
53
57
  "@types/express": "^4.17.12",
54
58
  "express": "^4.17.1",
55
59
  "next": "^12.0.1",
@@ -61,5 +65,5 @@
61
65
  "publishConfig": {
62
66
  "access": "public"
63
67
  },
64
- "gitHead": "b1d41d19a79b71045bf92dd6a5b8370a9f4f017c"
68
+ "gitHead": "0db16da18ee5fc1ea4b2149490c316a4a700d2ab"
65
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<TRouter extends AnyRouter>(
6
- opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>,
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
- const _withTRPC = withTRPC(opts);
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
@@ -70,9 +70,10 @@ export interface WithTRPCNoSSROptions<TRouter extends AnyRouter>
70
70
  ssr?: false;
71
71
  }
72
72
 
73
- export function withTRPC<TRouter extends AnyRouter>(
74
- opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>,
75
- ) {
73
+ export function withTRPC<
74
+ TRouter extends AnyRouter,
75
+ TSSRContext extends NextPageContext = NextPageContext,
76
+ >(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {
76
77
  const { config: getClientConfig } = opts;
77
78
 
78
79
  type TRPCPrepassProps = {
@@ -80,10 +81,10 @@ export function withTRPC<TRouter extends AnyRouter>(
80
81
  queryClient: QueryClient;
81
82
  trpcClient: TRPCClient<TRouter>;
82
83
  ssrState: 'prepass';
83
- ssrContext: NextPageContext;
84
+ ssrContext: TSSRContext;
84
85
  };
85
86
  return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {
86
- const trpc = createReactQueryHooks<TRouter, NextPageContext>(opts);
87
+ const trpc = createReactQueryHooks<TRouter, TSSRContext>(opts);
87
88
 
88
89
  const WithTRPC = (
89
90
  props: AppPropsType & {
@@ -166,7 +167,7 @@ export function withTRPC<TRouter extends AnyRouter>(
166
167
  trpcClient,
167
168
  queryClient,
168
169
  ssrState: 'prepass',
169
- ssrContext: ctx,
170
+ ssrContext: ctx as TSSRContext,
170
171
  };
171
172
  const prepassProps = {
172
173
  pageProps,