@trpc/next 10.27.1 → 10.27.2

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.
@@ -2,37 +2,32 @@ import { CreateTRPCClientOptions, TRPCClientError, TRPCLink } from '@trpc/client
2
2
  import { AnyProcedure, AnyRouter, MaybePromise, ProcedureOptions, Simplify, inferHandlerInput } from '@trpc/server';
3
3
  import { TRPCActionHandler } from './server';
4
4
  import { ActionHandlerDef } from './shared';
5
- interface Def {
6
- input?: any;
7
- output?: any;
8
- errorShape: any;
9
- }
10
- declare type MutationArgs<TDef extends Def> = TDef['input'] extends void ? [input?: undefined | void, opts?: ProcedureOptions] : [input: TDef['input'] | FormData, opts?: ProcedureOptions];
11
- interface UseTRPCActionBaseResult<TDef extends Def> {
5
+ declare type MutationArgs<TDef extends ActionHandlerDef> = TDef['input'] extends void ? [input?: undefined | void, opts?: ProcedureOptions] : [input: TDef['input'] | FormData, opts?: ProcedureOptions];
6
+ interface UseTRPCActionBaseResult<TDef extends ActionHandlerDef> {
12
7
  mutate: (...args: MutationArgs<TDef>) => void;
13
- mutateAsync: (...args: MutationArgs<TDef>) => Promise<Def['output']>;
8
+ mutateAsync: (...args: MutationArgs<TDef>) => Promise<TDef['output']>;
14
9
  }
15
- interface UseTRPCActionSuccessResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
10
+ interface UseTRPCActionSuccessResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
16
11
  data: TDef['output'];
17
12
  error?: never;
18
13
  status: 'success';
19
14
  }
20
- interface UseTRPCActionErrorResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
15
+ interface UseTRPCActionErrorResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
21
16
  data?: never;
22
17
  error: TRPCClientError<TDef['errorShape']>;
23
18
  status: 'error';
24
19
  }
25
- interface UseTRPCActionIdleResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
20
+ interface UseTRPCActionIdleResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
26
21
  data?: never;
27
22
  error?: never;
28
23
  status: 'idle';
29
24
  }
30
- interface UseTRPCActionLoadingResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
25
+ interface UseTRPCActionLoadingResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
31
26
  data?: never;
32
27
  error?: never;
33
28
  status: 'loading';
34
29
  }
35
- export declare type UseTRPCActionResult<TDef extends Def> = UseTRPCActionSuccessResult<TDef> | UseTRPCActionErrorResult<TDef> | UseTRPCActionIdleResult<TDef> | UseTRPCActionLoadingResult<TDef>;
30
+ export declare type UseTRPCActionResult<TDef extends ActionHandlerDef> = UseTRPCActionSuccessResult<TDef> | UseTRPCActionErrorResult<TDef> | UseTRPCActionIdleResult<TDef> | UseTRPCActionLoadingResult<TDef>;
36
31
  export declare function experimental_serverActionLink<TRouter extends AnyRouter = AnyRouter>(): TRPCLink<TRouter>;
37
32
  /**
38
33
  * @internal
@@ -42,7 +37,7 @@ export declare type inferActionResultProps<TProc extends AnyProcedure> = {
42
37
  output: TProc['_def']['_output_out'];
43
38
  errorShape: TProc['_def']['_config']['$types']['errorShape'];
44
39
  };
45
- interface UseTRPCActionOptions<TDef extends Def> {
40
+ interface UseTRPCActionOptions<TDef extends ActionHandlerDef> {
46
41
  onSuccess?: (result: TDef['output']) => void | MaybePromise<void>;
47
42
  onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
48
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-action-hook.d.ts","sourceRoot":"","sources":["../../src/app-dir/create-action-hook.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,QAAQ,EAGT,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EAClB,MAAM,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AAC,IAAI,SAAS,gBAAgB;IAC1D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CAC/E;AAGD,wBAAgB,6BAA6B,CAAC,OAAO,SAAS,SAAS,EACrE,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,oKA6FvC"}
package/dist/index.js CHANGED
@@ -54,10 +54,7 @@ function withTRPC(opts) {
54
54
  });
55
55
  const { queryClient , trpcClient , ssrState , ssrContext } = prepassProps;
56
56
  // allow normal components to be wrapped, not just app/pages
57
- let hydratedState;
58
- if (props.pageProps) {
59
- hydratedState = trpc.useDehydratedState(trpcClient, props.pageProps.trpcState);
60
- }
57
+ const hydratedState = trpc.useDehydratedState(trpcClient, props.pageProps?.trpcState);
61
58
  return /*#__PURE__*/ React__default["default"].createElement(trpc.Provider, {
62
59
  abortOnUnmount: prepassProps.abortOnUnmount ?? false,
63
60
  client: trpcClient,
package/dist/index.mjs CHANGED
@@ -45,10 +45,7 @@ function withTRPC(opts) {
45
45
  });
46
46
  const { queryClient , trpcClient , ssrState , ssrContext } = prepassProps;
47
47
  // allow normal components to be wrapped, not just app/pages
48
- let hydratedState;
49
- if (props.pageProps) {
50
- hydratedState = trpc.useDehydratedState(trpcClient, props.pageProps.trpcState);
51
- }
48
+ const hydratedState = trpc.useDehydratedState(trpcClient, props.pageProps?.trpcState);
52
49
  return /*#__PURE__*/ React.createElement(trpc.Provider, {
53
50
  abortOnUnmount: prepassProps.abortOnUnmount ?? false,
54
51
  client: trpcClient,
@@ -1 +1 @@
1
- {"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,uBA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C,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,CA+KxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/next",
3
- "version": "10.27.1",
3
+ "version": "10.27.2",
4
4
  "description": "The tRPC Next.js library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -55,9 +55,9 @@
55
55
  ],
56
56
  "peerDependencies": {
57
57
  "@tanstack/react-query": "^4.18.0",
58
- "@trpc/client": "10.27.1",
59
- "@trpc/react-query": "10.27.1",
60
- "@trpc/server": "10.27.1",
58
+ "@trpc/client": "10.27.2",
59
+ "@trpc/react-query": "10.27.2",
60
+ "@trpc/server": "10.27.2",
61
61
  "next": "*",
62
62
  "react": ">=16.8.0",
63
63
  "react-dom": ">=16.8.0"
@@ -67,9 +67,9 @@
67
67
  },
68
68
  "devDependencies": {
69
69
  "@tanstack/react-query": "^4.18.0",
70
- "@trpc/client": "10.27.1",
71
- "@trpc/react-query": "10.27.1",
72
- "@trpc/server": "10.27.1",
70
+ "@trpc/client": "10.27.2",
71
+ "@trpc/react-query": "10.27.2",
72
+ "@trpc/server": "10.27.2",
73
73
  "@types/express": "^4.17.17",
74
74
  "@types/node": "^18.7.20",
75
75
  "@types/react": "^18.2.6",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "dffd2e72cc40f70156adebbb6a2d1e1df39d9808"
89
+ "gitHead": "3b392dae8de9eeb34adb10c9028577336fcf27a4"
90
90
  }
@@ -19,43 +19,37 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
19
  import { TRPCActionHandler } from './server';
20
20
  import { ActionHandlerDef, isFormData } from './shared';
21
21
 
22
- interface Def {
23
- input?: any;
24
- output?: any;
25
- errorShape: any;
26
- }
27
-
28
- type MutationArgs<TDef extends Def> = TDef['input'] extends void
22
+ type MutationArgs<TDef extends ActionHandlerDef> = TDef['input'] extends void
29
23
  ? [input?: undefined | void, opts?: ProcedureOptions]
30
24
  : [input: TDef['input'] | FormData, opts?: ProcedureOptions];
31
25
 
32
- interface UseTRPCActionBaseResult<TDef extends Def> {
26
+ interface UseTRPCActionBaseResult<TDef extends ActionHandlerDef> {
33
27
  mutate: (...args: MutationArgs<TDef>) => void;
34
- mutateAsync: (...args: MutationArgs<TDef>) => Promise<Def['output']>;
28
+ mutateAsync: (...args: MutationArgs<TDef>) => Promise<TDef['output']>;
35
29
  }
36
30
 
37
- interface UseTRPCActionSuccessResult<TDef extends Def>
31
+ interface UseTRPCActionSuccessResult<TDef extends ActionHandlerDef>
38
32
  extends UseTRPCActionBaseResult<TDef> {
39
33
  data: TDef['output'];
40
34
  error?: never;
41
35
  status: 'success';
42
36
  }
43
37
 
44
- interface UseTRPCActionErrorResult<TDef extends Def>
38
+ interface UseTRPCActionErrorResult<TDef extends ActionHandlerDef>
45
39
  extends UseTRPCActionBaseResult<TDef> {
46
40
  data?: never;
47
41
  error: TRPCClientError<TDef['errorShape']>;
48
42
  status: 'error';
49
43
  }
50
44
 
51
- interface UseTRPCActionIdleResult<TDef extends Def>
45
+ interface UseTRPCActionIdleResult<TDef extends ActionHandlerDef>
52
46
  extends UseTRPCActionBaseResult<TDef> {
53
47
  data?: never;
54
48
  error?: never;
55
49
  status: 'idle';
56
50
  }
57
51
 
58
- interface UseTRPCActionLoadingResult<TDef extends Def>
52
+ interface UseTRPCActionLoadingResult<TDef extends ActionHandlerDef>
59
53
  extends UseTRPCActionBaseResult<TDef> {
60
54
  data?: never;
61
55
  error?: never;
@@ -63,7 +57,7 @@ interface UseTRPCActionLoadingResult<TDef extends Def>
63
57
  }
64
58
 
65
59
  // ts-prune-ignore-next
66
- export type UseTRPCActionResult<TDef extends Def> =
60
+ export type UseTRPCActionResult<TDef extends ActionHandlerDef> =
67
61
  | UseTRPCActionSuccessResult<TDef>
68
62
  | UseTRPCActionErrorResult<TDef>
69
63
  | UseTRPCActionIdleResult<TDef>
@@ -115,7 +109,7 @@ export type inferActionResultProps<TProc extends AnyProcedure> = {
115
109
  errorShape: TProc['_def']['_config']['$types']['errorShape'];
116
110
  };
117
111
 
118
- interface UseTRPCActionOptions<TDef extends Def> {
112
+ interface UseTRPCActionOptions<TDef extends ActionHandlerDef> {
119
113
  onSuccess?: (result: TDef['output']) => void | MaybePromise<void>;
120
114
  onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
121
115
  }
package/src/withTRPC.tsx CHANGED
@@ -120,13 +120,10 @@ export function withTRPC<
120
120
  const { queryClient, trpcClient, ssrState, ssrContext } = prepassProps;
121
121
 
122
122
  // allow normal components to be wrapped, not just app/pages
123
- let hydratedState: DehydratedState | undefined;
124
- if (props.pageProps) {
125
- hydratedState = trpc.useDehydratedState(
126
- trpcClient,
127
- props.pageProps.trpcState,
128
- );
129
- }
123
+ const hydratedState = trpc.useDehydratedState(
124
+ trpcClient,
125
+ props.pageProps?.trpcState,
126
+ );
130
127
 
131
128
  return (
132
129
  <trpc.Provider