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

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;
@@ -17,34 +18,34 @@ export declare function setupTRPC<TRouter extends AnyRouter>(opts: WithTRPCNoSSR
17
18
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
18
19
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
19
20
  }; }[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
20
- 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"]]: {
21
+ useMutation: <TPath_1 extends keyof TRouter["_def"]["mutations"] & string, TContext = unknown>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<{ [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
21
22
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
22
23
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
23
24
  }; }[TPath_1]["input"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
24
25
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
25
26
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
26
- }; }[TPath_1]["output"]> | undefined) => import("react-query").UseMutationResult<{ [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
27
+ }; }[TPath_1]["output"], TContext> | undefined) => import("react-query").UseMutationResult<{ [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
27
28
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
28
29
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
29
30
  }; }[TPath_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_2 in keyof TRouter["_def"]["mutations"]]: {
30
31
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_2]>;
31
32
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_2]["call"]>>;
32
- }; }[TPath_1]["input"], unknown>;
33
- 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"]]: {
33
+ }; }[TPath_1]["input"], TContext>;
34
+ useQuery: <TPath_4 extends keyof TRouter["_def"]["queries"] & string, TQueryFnData = { [TPath_1 in keyof TRouter["_def"]["queries"]]: {
34
35
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
35
36
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
36
- }; }[TPath_4]["input"], { [TPath_1 in keyof TRouter["_def"]["queries"]]: {
37
+ }; }[TPath_4]["output"], TData = { [TPath_1 in keyof TRouter["_def"]["queries"]]: {
37
38
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
38
39
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
39
- }; }[TPath_4]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseQueryResult<{ [TPath_1 in keyof TRouter["_def"]["queries"]]: {
40
+ }; }[TPath_4]["output"]>(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"]]: {
40
41
  input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
41
42
  output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
42
- }; }[TPath_4]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
43
- useSubscription: <TPath_2 extends keyof TRouter["_def"]["subscriptions"] & string, TOutput extends ReturnType<import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["subscriptions"][TPath_2]["call"]>>["output"]>>(pathAndInput: [path: TPath_2, ...args: import("@trpc/server").inferHandlerInput<TRouter["_def"]["subscriptions"][TPath_2]>], opts: {
43
+ }; }[TPath_4]["input"], TQueryFnData, TData, import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseQueryResult<TData, 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: {
44
45
  enabled?: boolean | undefined;
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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AO,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.23",
4
4
  "description": "tRPC Next lib",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -30,36 +30,40 @@
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.23",
42
+ "@trpc/react": "10.0.0-alpha.23",
43
+ "@trpc/server": "10.0.0-alpha.23",
40
44
  "next": "*",
41
45
  "react": ">=16.8.0",
42
46
  "react-dom": ">=16.8.0",
43
- "react-query": "^3.31.0 || ^4.0.0-alpha.4"
47
+ "react-query": "^3.37.0 || ^4.0.0-alpha.4"
44
48
  },
45
49
  "dependencies": {
46
50
  "@babel/runtime": "^7.9.0",
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.23",
55
+ "@trpc/react": "10.0.0-alpha.23",
56
+ "@trpc/server": "10.0.0-alpha.23",
53
57
  "@types/express": "^4.17.12",
54
58
  "express": "^4.17.1",
55
- "next": "^12.0.1",
56
- "react": "^17.0.2",
57
- "react-dom": "^17.0.2",
58
- "react-query": "^3.27.0",
59
+ "next": "^12.1.6",
60
+ "react": "^18.1.0",
61
+ "react-dom": "^18.1.0",
62
+ "react-query": "^3.37.0",
59
63
  "zod": "^3.0.0"
60
64
  },
61
65
  "publishConfig": {
62
66
  "access": "public"
63
67
  },
64
- "gitHead": "b1d41d19a79b71045bf92dd6a5b8370a9f4f017c"
68
+ "gitHead": "c62ecdc84b32656b6ccb0f94188f34af4485ad58"
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
@@ -19,8 +19,13 @@ import {
19
19
  NextPageContext,
20
20
  } from 'next/dist/shared/lib/utils';
21
21
  import React, { createElement, useState } from 'react';
22
- import { QueryClient, QueryClientProvider } from 'react-query';
23
- import { DehydratedState, Hydrate, dehydrate } from 'react-query';
22
+ import {
23
+ DehydratedState,
24
+ Hydrate,
25
+ QueryClient,
26
+ QueryClientProvider,
27
+ dehydrate,
28
+ } from 'react-query';
24
29
  import ssrPrepass from 'react-ssr-prepass';
25
30
 
26
31
  type QueryClientConfig = ConstructorParameters<typeof QueryClient>[0];
@@ -70,9 +75,10 @@ export interface WithTRPCNoSSROptions<TRouter extends AnyRouter>
70
75
  ssr?: false;
71
76
  }
72
77
 
73
- export function withTRPC<TRouter extends AnyRouter>(
74
- opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>,
75
- ) {
78
+ export function withTRPC<
79
+ TRouter extends AnyRouter,
80
+ TSSRContext extends NextPageContext = NextPageContext,
81
+ >(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {
76
82
  const { config: getClientConfig } = opts;
77
83
 
78
84
  type TRPCPrepassProps = {
@@ -80,10 +86,10 @@ export function withTRPC<TRouter extends AnyRouter>(
80
86
  queryClient: QueryClient;
81
87
  trpcClient: TRPCClient<TRouter>;
82
88
  ssrState: 'prepass';
83
- ssrContext: NextPageContext;
89
+ ssrContext: TSSRContext;
84
90
  };
85
91
  return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {
86
- const trpc = createReactQueryHooks<TRouter, NextPageContext>(opts);
92
+ const trpc = createReactQueryHooks<TRouter, TSSRContext>(opts);
87
93
 
88
94
  const WithTRPC = (
89
95
  props: AppPropsType & {
@@ -166,7 +172,7 @@ export function withTRPC<TRouter extends AnyRouter>(
166
172
  trpcClient,
167
173
  queryClient,
168
174
  ssrState: 'prepass',
169
- ssrContext: ctx,
175
+ ssrContext: ctx as TSSRContext,
170
176
  };
171
177
  const prepassProps = {
172
178
  pageProps,