@trpc/next 10.43.0 → 11.0.0-next.92
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/app-dir/client.d.ts +3 -3
- package/dist/app-dir/client.d.ts.map +1 -1
- package/dist/app-dir/create-action-hook.d.ts +1 -9
- package/dist/app-dir/create-action-hook.d.ts.map +1 -1
- package/dist/app-dir/links/nextCache.js +1 -1
- package/dist/app-dir/links/nextCache.mjs +1 -1
- package/dist/app-dir/server.d.ts +2 -2
- package/dist/app-dir/server.d.ts.map +1 -1
- package/dist/app-dir/server.js +3 -3
- package/dist/app-dir/server.mjs +3 -3
- package/dist/app-dir/shared.d.ts +4 -4
- package/dist/app-dir/shared.d.ts.map +1 -1
- package/dist/app-dir/types.d.ts +7 -7
- package/dist/app-dir/types.d.ts.map +1 -1
- package/dist/bundle-analysis.json +146 -0
- package/dist/createTRPCNext.d.ts +4 -4
- package/dist/createTRPCNext.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.mjs +9 -9
- package/dist/withTRPC.d.ts +1 -1
- package/dist/withTRPC.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/app-dir/client.ts +2 -4
- package/src/app-dir/create-action-hook.tsx +0 -12
- package/src/app-dir/links/nextCache.ts +1 -1
- package/src/app-dir/server.ts +9 -6
- package/src/app-dir/shared.ts +7 -3
- package/src/app-dir/types.ts +28 -21
- package/src/createTRPCNext.tsx +14 -10
- package/src/withTRPC.tsx +12 -13
package/dist/app-dir/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateTRPCClient } from '@trpc/client';
|
|
2
2
|
import { AnyRouter } from '@trpc/server';
|
|
3
3
|
import { CreateTRPCNextAppRouterOptions } from './shared';
|
|
4
|
-
export { experimental_createActionHook, experimental_serverActionLink, type UseTRPCActionResult,
|
|
5
|
-
export declare function experimental_createTRPCNextAppDirClient<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>):
|
|
4
|
+
export { experimental_createActionHook, experimental_serverActionLink, type UseTRPCActionResult, } from './create-action-hook';
|
|
5
|
+
export declare function experimental_createTRPCNextAppDirClient<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): CreateTRPCClient<TRouter>;
|
|
6
6
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/app-dir/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/app-dir/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,EAEL,6BAA6B,EAE7B,6BAA6B,EAE7B,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAS9B,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,6BAwC9C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CreateTRPCClientOptions, TRPCClientError, TRPCLink } from '@trpc/client';
|
|
2
|
-
import {
|
|
2
|
+
import { AnyRouter, MaybePromise, ProcedureOptions, Simplify } from '@trpc/server';
|
|
3
3
|
import { TRPCActionHandler } from './server';
|
|
4
4
|
import { ActionHandlerDef } from './shared';
|
|
5
5
|
type MutationArgs<TDef extends ActionHandlerDef> = TDef['input'] extends void ? [input?: undefined | void, opts?: ProcedureOptions] : [input: FormData | TDef['input'], opts?: ProcedureOptions];
|
|
@@ -29,14 +29,6 @@ interface UseTRPCActionLoadingResult<TDef extends ActionHandlerDef> extends UseT
|
|
|
29
29
|
}
|
|
30
30
|
export type UseTRPCActionResult<TDef extends ActionHandlerDef> = UseTRPCActionErrorResult<TDef> | UseTRPCActionIdleResult<TDef> | UseTRPCActionLoadingResult<TDef> | UseTRPCActionSuccessResult<TDef>;
|
|
31
31
|
export declare function experimental_serverActionLink<TRouter extends AnyRouter = AnyRouter>(): TRPCLink<TRouter>;
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export type inferActionResultProps<TProc extends AnyProcedure> = {
|
|
36
|
-
input: inferHandlerInput<TProc>[0];
|
|
37
|
-
output: TProc['_def']['_output_out'];
|
|
38
|
-
errorShape: TProc['_def']['_config']['$types']['errorShape'];
|
|
39
|
-
};
|
|
40
32
|
interface UseTRPCActionOptions<TDef extends ActionHandlerDef> {
|
|
41
33
|
onSuccess?: (result: TDef['output']) => MaybePromise<void> | void;
|
|
42
34
|
onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
|
|
@@ -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,EAEvB,eAAe,EACf,QAAQ,EAET,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"create-action-hook.d.ts","sourceRoot":"","sources":["../../src/app-dir/create-action-hook.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,eAAe,EACf,QAAQ,EAET,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACT,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAc,MAAM,UAAU,CAAC;AAExD,KAAK,YAAY,CAAC,IAAI,SAAS,gBAAgB,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,GACzE,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,GACnD,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC;AAE/D,UAAU,uBAAuB,CAAC,IAAI,SAAS,gBAAgB;IAC7D,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC9C,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;CACvE;AAED,UAAU,0BAA0B,CAAC,IAAI,SAAS,gBAAgB,CAChE,SAAQ,uBAAuB,CAAC,IAAI,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,UAAU,wBAAwB,CAAC,IAAI,SAAS,gBAAgB,CAC9D,SAAQ,uBAAuB,CAAC,IAAI,CAAC;IACrC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3C,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,uBAAuB,CAAC,IAAI,SAAS,gBAAgB,CAC7D,SAAQ,uBAAuB,CAAC,IAAI,CAAC;IACrC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,0BAA0B,CAAC,IAAI,SAAS,gBAAgB,CAChE,SAAQ,uBAAuB,CAAC,IAAI,CAAC;IACrC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;CACnB;AAGD,MAAM,MAAM,mBAAmB,CAAC,IAAI,SAAS,gBAAgB,IACzD,wBAAwB,CAAC,IAAI,CAAC,GAC9B,uBAAuB,CAAC,IAAI,CAAC,GAC7B,0BAA0B,CAAC,IAAI,CAAC,GAChC,0BAA0B,CAAC,IAAI,CAAC,CAAC;AAOrC,wBAAgB,6BAA6B,CAC3C,OAAO,SAAS,SAAS,GAAG,SAAS,KAClC,QAAQ,CAAC,OAAO,CAAC,CA6BrB;AAED,UAAU,oBAAoB,CAAC,IAAI,SAAS,gBAAgB;IAC1D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,GAAG,IAAI,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/app-dir/server.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AnyProcedure, AnyRootConfig, AnyRouter, MaybePromise, Simplify } from '
|
|
|
2
2
|
import { TRPCResponse } from '@trpc/server/rpc';
|
|
3
3
|
import { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef } from './shared';
|
|
4
4
|
import { NextAppDirDecoratedProcedureRecord } from './types';
|
|
5
|
-
export declare function experimental_createTRPCNextAppDirServer<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): NextAppDirDecoratedProcedureRecord<TRouter["_def"]["record"]>;
|
|
5
|
+
export declare function experimental_createTRPCNextAppDirServer<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): NextAppDirDecoratedProcedureRecord<TRouter["_def"]["_config"], TRouter["_def"]["record"]>;
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
@@ -19,7 +19,7 @@ export declare function experimental_createServerActionHandler<TInstance extends
|
|
|
19
19
|
}): <TProc extends AnyProcedure>(proc: TProc) => TRPCActionHandler<{
|
|
20
20
|
input: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TProc>>[0];
|
|
21
21
|
output: TProc["_def"]["_output_out"];
|
|
22
|
-
errorShape:
|
|
22
|
+
errorShape: TInstance["_config"]["$types"]["errorShape"];
|
|
23
23
|
}>;
|
|
24
24
|
export declare function experimental_revalidateEndpoint(req: Request): Promise<Response>;
|
|
25
25
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/app-dir/server.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EAIT,YAAY,EACZ,QAAQ,EAET,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAShD,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAE9B,cAAc,EAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAG7D,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/app-dir/server.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EAIT,YAAY,EACZ,QAAQ,EAET,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAShD,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAE9B,cAAc,EAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAG7D,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,6FA2B9C;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,gBAAgB,IAAI,CAC7D,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,KAC5B,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAE/D,wBAAgB,sCAAsC,CACpD,SAAS,SAAS;IAChB,OAAO,EAAE,aAAa,CAAC;CACxB,EAED,CAAC,EAAE,SAAS,EACZ,IAAI,EAAE;IACJ,aAAa,EAAE,MAAM,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;;;;GAgEF;AAGD,wBAAsB,+BAA+B,CAAC,GAAG,EAAE,OAAO,qBAiBjE"}
|
package/dist/app-dir/server.js
CHANGED
|
@@ -92,8 +92,8 @@ function experimental_createServerActionHandler(t, opts) {
|
|
|
92
92
|
input: undefined,
|
|
93
93
|
ctx: ctx1,
|
|
94
94
|
path: 'serverAction',
|
|
95
|
-
rawInput,
|
|
96
|
-
type: proc.
|
|
95
|
+
getRawInput: async ()=>rawInput,
|
|
96
|
+
type: proc._def.type
|
|
97
97
|
});
|
|
98
98
|
const transformedJSON = shared.transformTRPCResponse(config, {
|
|
99
99
|
result: {
|
|
@@ -109,7 +109,7 @@ function experimental_createServerActionHandler(t, opts) {
|
|
|
109
109
|
error,
|
|
110
110
|
input: rawInput,
|
|
111
111
|
path: 'serverAction',
|
|
112
|
-
type: proc.
|
|
112
|
+
type: proc._def.type
|
|
113
113
|
});
|
|
114
114
|
// TODO: send the right HTTP header?!
|
|
115
115
|
return shared.transformTRPCResponse(t._config, {
|
package/dist/app-dir/server.mjs
CHANGED
|
@@ -88,8 +88,8 @@ function experimental_createServerActionHandler(t, opts) {
|
|
|
88
88
|
input: undefined,
|
|
89
89
|
ctx: ctx1,
|
|
90
90
|
path: 'serverAction',
|
|
91
|
-
rawInput,
|
|
92
|
-
type: proc.
|
|
91
|
+
getRawInput: async ()=>rawInput,
|
|
92
|
+
type: proc._def.type
|
|
93
93
|
});
|
|
94
94
|
const transformedJSON = transformTRPCResponse(config, {
|
|
95
95
|
result: {
|
|
@@ -105,7 +105,7 @@ function experimental_createServerActionHandler(t, opts) {
|
|
|
105
105
|
error,
|
|
106
106
|
input: rawInput,
|
|
107
107
|
path: 'serverAction',
|
|
108
|
-
type: proc.
|
|
108
|
+
type: proc._def.type
|
|
109
109
|
});
|
|
110
110
|
// TODO: send the right HTTP header?!
|
|
111
111
|
return transformTRPCResponse(t._config, {
|
package/dist/app-dir/shared.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CreateTRPCClientOptions, Resolver, TRPCUntypedClient } from '@trpc/client';
|
|
2
|
-
import { AnyProcedure, AnyQueryProcedure, AnyRouter, Filter, inferHandlerInput, ProtectedIntersection, ThenArg } from '@trpc/server';
|
|
2
|
+
import { AnyProcedure, AnyQueryProcedure, AnyRootConfig, AnyRouter, Filter, inferHandlerInput, ProtectedIntersection, ThenArg } from '@trpc/server';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
6
|
export type UseProcedureRecord<TRouter extends AnyRouter> = {
|
|
7
|
-
[TKey in keyof Filter<TRouter['_def']['record'], AnyQueryProcedure | AnyRouter>]: TRouter['_def']['record'][TKey] extends AnyRouter ? UseProcedureRecord<TRouter['_def']['record'][TKey]> : Resolver<TRouter['_def']['record'][TKey]>;
|
|
7
|
+
[TKey in keyof Filter<TRouter['_def']['record'], AnyQueryProcedure | AnyRouter>]: TRouter['_def']['record'][TKey] extends AnyRouter ? UseProcedureRecord<TRouter['_def']['record'][TKey]> : Resolver<TRouter['_def']['_config'], TRouter['_def']['record'][TKey]>;
|
|
8
8
|
};
|
|
9
9
|
export declare function createUseProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>): UseProcedureRecord<TRouter>;
|
|
10
10
|
type NextAppRouterUse<TRouter extends AnyRouter> = {
|
|
@@ -39,10 +39,10 @@ export interface ActionHandlerDef {
|
|
|
39
39
|
/**
|
|
40
40
|
* @internal
|
|
41
41
|
*/
|
|
42
|
-
export type inferActionDef<TProc extends AnyProcedure> = {
|
|
42
|
+
export type inferActionDef<TConfig extends AnyRootConfig, TProc extends AnyProcedure> = {
|
|
43
43
|
input: inferHandlerInput<TProc>[0];
|
|
44
44
|
output: TProc['_def']['_output_out'];
|
|
45
|
-
errorShape:
|
|
45
|
+
errorShape: TConfig['$types']['errorShape'];
|
|
46
46
|
};
|
|
47
47
|
export {};
|
|
48
48
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/app-dir/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,QAAQ,EACR,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,OAAO,EACR,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI;KACzD,IAAI,IAAI,MAAM,MAAM,CACnB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACzB,iBAAiB,GAAG,SAAS,CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GACnD,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/app-dir/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,QAAQ,EACR,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,OAAO,EACR,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI;KACzD,IAAI,IAAI,MAAM,MAAM,CACnB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACzB,iBAAiB,GAAG,SAAS,CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GACnD,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;CAC1E,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,SAAS,SAAS,EACtD,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,+BAOnC;AAED,KAAK,gBAAgB,CAAC,OAAO,SAAS,SAAS,IAAI;IACjD,CAAC,KAAK,SAAS,OAAO,CAAC,OAAO,CAAC,EAAE,EAC/B,EAAE,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,GACjD;SACA,IAAI,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KAC5C,CAAC;IACF,CAAC,KAAK,SAAS,OAAO,CAAC,OAAO,CAAC,EAC7B,EAAE,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK,KAAK,GAC5C,OAAO,CAAC,KAAK,CAAC,CAAC;CACnB,CAAC;AACF,KAAK,2BAA2B,CAAC,OAAO,SAAS,SAAS,IAAI;IAC5D,GAAG,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAChC,CAAC;AACF,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,SAAS,IAC3D,qBAAqB,CACnB,2BAA2B,CAAC,OAAO,CAAC,EACpC,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEJ;;GAEG;AACH,MAAM,WAAW,8BAA8B,CAAC,OAAO,SAAS,SAAS;IACvE,MAAM,EAAE,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,UAIjE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAM5D;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,UAAU,EAAE,GAAG,CAAC;CACjB;AAGD;;GAEG;AACH,MAAM,MAAM,cAAc,CACxB,OAAO,SAAS,aAAa,EAC7B,KAAK,SAAS,YAAY,IACxB;IACF,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;CAC7C,CAAC"}
|
package/dist/app-dir/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Resolver } from '@trpc/client';
|
|
2
|
-
import { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, ProcedureArgs, ProcedureRouterRecord } from '@trpc/server';
|
|
3
|
-
export type DecorateProcedureServer<TProcedure extends AnyProcedure> = TProcedure extends AnyQueryProcedure ? {
|
|
4
|
-
query: Resolver<TProcedure>;
|
|
2
|
+
import { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRootConfig, AnyRouter, AnySubscriptionProcedure, ProcedureArgs, ProcedureRouterRecord } from '@trpc/server';
|
|
3
|
+
export type DecorateProcedureServer<TConfig extends AnyRootConfig, TProcedure extends AnyProcedure> = TProcedure extends AnyQueryProcedure ? {
|
|
4
|
+
query: Resolver<TConfig, TProcedure>;
|
|
5
5
|
revalidate: (input?: ProcedureArgs<TProcedure['_def']>[0]) => Promise<{
|
|
6
6
|
revalidated: false;
|
|
7
7
|
error: string;
|
|
@@ -9,11 +9,11 @@ export type DecorateProcedureServer<TProcedure extends AnyProcedure> = TProcedur
|
|
|
9
9
|
revalidated: true;
|
|
10
10
|
}>;
|
|
11
11
|
} : TProcedure extends AnyMutationProcedure ? {
|
|
12
|
-
mutate: Resolver<TProcedure>;
|
|
12
|
+
mutate: Resolver<TConfig, TProcedure>;
|
|
13
13
|
} : TProcedure extends AnySubscriptionProcedure ? {
|
|
14
|
-
subscribe: Resolver<TProcedure>;
|
|
14
|
+
subscribe: Resolver<TConfig, TProcedure>;
|
|
15
15
|
} : never;
|
|
16
|
-
export type NextAppDirDecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
|
|
17
|
-
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? NextAppDirDecoratedProcedureRecord<TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedureServer<TProcedures[TKey]> : never;
|
|
16
|
+
export type NextAppDirDecoratedProcedureRecord<TConfig extends AnyRootConfig, TProcedures extends ProcedureRouterRecord> = {
|
|
17
|
+
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? NextAppDirDecoratedProcedureRecord<TConfig, TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedureServer<TConfig, TProcedures[TKey]> : never;
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/app-dir/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,wBAAwB,EACxB,aAAa,EACb,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/app-dir/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,wBAAwB,EACxB,aAAa,EACb,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,aAAa,EAC7B,UAAU,SAAS,YAAY,IAC7B,UAAU,SAAS,iBAAiB,GACpC;IACE,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACrC,UAAU,EAAE,CACV,KAAK,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KACzC,OAAO,CACV;QAAE,WAAW,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,WAAW,EAAE,IAAI,CAAA;KAAE,CAC9D,CAAC;CACH,GACD,UAAU,SAAS,oBAAoB,GACvC;IACE,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;CACvC,GACD,UAAU,SAAS,wBAAwB,GAC3C;IACE,SAAS,EAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;CAC1C,GACD,KAAK,CAAC;AAEV,MAAM,MAAM,kCAAkC,CAC5C,OAAO,SAAS,aAAa,EAC7B,WAAW,SAAS,qBAAqB,IACvC;KACD,IAAI,IAAI,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,SAAS,GAC5D,kCAAkC,CAChC,OAAO,EACP,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CACpC,GACD,WAAW,CAAC,IAAI,CAAC,SAAS,YAAY,GACtC,uBAAuB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,GACnD,KAAK;CACV,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bundleSize": 20957,
|
|
3
|
+
"bundleOrigSize": 30577,
|
|
4
|
+
"bundleReduction": 31.46,
|
|
5
|
+
"modules": [
|
|
6
|
+
{
|
|
7
|
+
"id": "/src/withTRPC.tsx",
|
|
8
|
+
"size": 6882,
|
|
9
|
+
"origSize": 8409,
|
|
10
|
+
"renderedExports": [
|
|
11
|
+
"withTRPC"
|
|
12
|
+
],
|
|
13
|
+
"removedExports": [],
|
|
14
|
+
"dependents": [
|
|
15
|
+
"/src/createTRPCNext.tsx",
|
|
16
|
+
"/src/index.ts"
|
|
17
|
+
],
|
|
18
|
+
"percent": 32.84,
|
|
19
|
+
"reduction": 18.16
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "/src/app-dir/server.ts",
|
|
23
|
+
"size": 3709,
|
|
24
|
+
"origSize": 4842,
|
|
25
|
+
"renderedExports": [
|
|
26
|
+
"experimental_createTRPCNextAppDirServer",
|
|
27
|
+
"experimental_createServerActionHandler",
|
|
28
|
+
"experimental_revalidateEndpoint"
|
|
29
|
+
],
|
|
30
|
+
"removedExports": [],
|
|
31
|
+
"dependents": [],
|
|
32
|
+
"percent": 17.7,
|
|
33
|
+
"reduction": 23.4
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "/src/app-dir/create-action-hook.tsx",
|
|
37
|
+
"size": 3310,
|
|
38
|
+
"origSize": 5650,
|
|
39
|
+
"renderedExports": [
|
|
40
|
+
"experimental_serverActionLink",
|
|
41
|
+
"experimental_createActionHook"
|
|
42
|
+
],
|
|
43
|
+
"removedExports": [],
|
|
44
|
+
"dependents": [
|
|
45
|
+
"/src/app-dir/client.ts"
|
|
46
|
+
],
|
|
47
|
+
"percent": 15.79,
|
|
48
|
+
"reduction": 41.42
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "/src/app-dir/links/nextCache.ts",
|
|
52
|
+
"size": 2479,
|
|
53
|
+
"origSize": 2682,
|
|
54
|
+
"renderedExports": [
|
|
55
|
+
"experimental_nextCacheLink"
|
|
56
|
+
],
|
|
57
|
+
"removedExports": [],
|
|
58
|
+
"dependents": [],
|
|
59
|
+
"percent": 11.83,
|
|
60
|
+
"reduction": 7.57
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "/src/app-dir/client.ts",
|
|
64
|
+
"size": 1264,
|
|
65
|
+
"origSize": 1801,
|
|
66
|
+
"renderedExports": [
|
|
67
|
+
"experimental_createTRPCNextAppDirClient"
|
|
68
|
+
],
|
|
69
|
+
"removedExports": [],
|
|
70
|
+
"dependents": [],
|
|
71
|
+
"percent": 6.03,
|
|
72
|
+
"reduction": 29.82
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "/src/app-dir/links/nextHttp.ts",
|
|
76
|
+
"size": 1210,
|
|
77
|
+
"origSize": 1473,
|
|
78
|
+
"renderedExports": [
|
|
79
|
+
"experimental_nextHttpLink"
|
|
80
|
+
],
|
|
81
|
+
"removedExports": [],
|
|
82
|
+
"dependents": [],
|
|
83
|
+
"percent": 5.77,
|
|
84
|
+
"reduction": 17.85
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "/src/createTRPCNext.tsx",
|
|
88
|
+
"size": 950,
|
|
89
|
+
"origSize": 2372,
|
|
90
|
+
"renderedExports": [
|
|
91
|
+
"createTRPCNext"
|
|
92
|
+
],
|
|
93
|
+
"removedExports": [],
|
|
94
|
+
"dependents": [
|
|
95
|
+
"/src/index.ts"
|
|
96
|
+
],
|
|
97
|
+
"percent": 4.53,
|
|
98
|
+
"reduction": 59.95
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "/src/app-dir/formDataToObject.ts",
|
|
102
|
+
"size": 818,
|
|
103
|
+
"origSize": 826,
|
|
104
|
+
"renderedExports": [
|
|
105
|
+
"formDataToObject"
|
|
106
|
+
],
|
|
107
|
+
"removedExports": [],
|
|
108
|
+
"dependents": [
|
|
109
|
+
"/src/app-dir/server.ts"
|
|
110
|
+
],
|
|
111
|
+
"percent": 3.9,
|
|
112
|
+
"reduction": 0.97
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"id": "/src/app-dir/shared.ts",
|
|
116
|
+
"size": 335,
|
|
117
|
+
"origSize": 2460,
|
|
118
|
+
"renderedExports": [
|
|
119
|
+
"generateCacheTag",
|
|
120
|
+
"isFormData"
|
|
121
|
+
],
|
|
122
|
+
"removedExports": [
|
|
123
|
+
"createUseProxy"
|
|
124
|
+
],
|
|
125
|
+
"dependents": [
|
|
126
|
+
"/src/app-dir/server.ts",
|
|
127
|
+
"/src/app-dir/create-action-hook.tsx",
|
|
128
|
+
"/src/app-dir/links/nextCache.ts",
|
|
129
|
+
"/src/app-dir/links/nextHttp.ts"
|
|
130
|
+
],
|
|
131
|
+
"percent": 1.6,
|
|
132
|
+
"reduction": 86.38
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "/src/index.ts",
|
|
136
|
+
"size": 0,
|
|
137
|
+
"origSize": 62,
|
|
138
|
+
"renderedExports": [],
|
|
139
|
+
"removedExports": [],
|
|
140
|
+
"dependents": [],
|
|
141
|
+
"percent": 0,
|
|
142
|
+
"reduction": 100
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"moduleCount": 10
|
|
146
|
+
}
|
package/dist/createTRPCNext.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateReactUtils, DecoratedProcedureRecord, TRPCUseQueries } from '@trpc/react-query/shared';
|
|
2
2
|
import { AnyRouter, ProtectedIntersection } from '@trpc/server';
|
|
3
3
|
import { NextPageContext } from 'next/types';
|
|
4
4
|
import { withTRPC, WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
|
|
@@ -11,17 +11,17 @@ export interface CreateTRPCNextBase<TRouter extends AnyRouter, TSSRContext exten
|
|
|
11
11
|
*
|
|
12
12
|
* @see https://trpc.io/docs/client/react/useUtils
|
|
13
13
|
*/
|
|
14
|
-
useContext():
|
|
14
|
+
useContext(): CreateReactUtils<TRouter, TSSRContext>;
|
|
15
15
|
/**
|
|
16
16
|
* @see https://trpc.io/docs/client/react/useUtils
|
|
17
17
|
*/
|
|
18
|
-
useUtils():
|
|
18
|
+
useUtils(): CreateReactUtils<TRouter, TSSRContext>;
|
|
19
19
|
withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
|
|
20
20
|
useQueries: TRPCUseQueries<TRouter>;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* @internal
|
|
24
24
|
*/
|
|
25
|
-
export type CreateTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext, TFlags> = ProtectedIntersection<CreateTRPCNextBase<TRouter, TSSRContext>, DecoratedProcedureRecord<TRouter['_def']['record'], TFlags>>;
|
|
25
|
+
export type CreateTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext, TFlags> = ProtectedIntersection<CreateTRPCNextBase<TRouter, TSSRContext>, DecoratedProcedureRecord<TRouter['_def']['_config'], TRouter['_def']['record'], TFlags>>;
|
|
26
26
|
export declare function createTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext, TFlags = null>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): CreateTRPCNext<TRouter, TSSRContext, TFlags>;
|
|
27
27
|
//# sourceMappingURL=createTRPCNext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTRPCNext.d.ts","sourceRoot":"","sources":["../src/createTRPCNext.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"createTRPCNext.d.ts","sourceRoot":"","sources":["../src/createTRPCNext.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,gBAAgB,EAEhB,wBAAwB,EACxB,cAAc,EACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe;IAEnC;;;;OAIG;IACH,UAAU,IAAI,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACrD;;OAEG;IACH,QAAQ,IAAI,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACnD,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,MAAM,MAAM,cAAc,CACxB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,EACnC,MAAM,IACJ,qBAAqB,CACvB,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,EACxC,wBAAwB,CACtB,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAC1B,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACzB,MAAM,CACP,CACF,CAAC;AAEF,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,CA2B9C"}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var reactQuery
|
|
6
|
-
var
|
|
5
|
+
var reactQuery = require('@tanstack/react-query');
|
|
6
|
+
var client = require('@trpc/client');
|
|
7
7
|
var shared = require('@trpc/react-query/shared');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var ssrPrepass = require('react-ssr-prepass');
|
|
@@ -35,7 +35,7 @@ function transformQueryOrMutationCacheErrors(result) {
|
|
|
35
35
|
function withTRPC(opts) {
|
|
36
36
|
const { config: getClientConfig } = opts;
|
|
37
37
|
return (AppOrPage)=>{
|
|
38
|
-
const trpc =
|
|
38
|
+
const trpc = shared.createRootHooks(opts);
|
|
39
39
|
const WithTRPC = (props)=>{
|
|
40
40
|
const [prepassProps] = React.useState(()=>{
|
|
41
41
|
if (props.trpc) {
|
|
@@ -61,9 +61,9 @@ function withTRPC(opts) {
|
|
|
61
61
|
queryClient: queryClient,
|
|
62
62
|
ssrState: ssrState,
|
|
63
63
|
ssrContext: ssrContext
|
|
64
|
-
}, /*#__PURE__*/ React__default["default"].createElement(reactQuery
|
|
64
|
+
}, /*#__PURE__*/ React__default["default"].createElement(reactQuery.QueryClientProvider, {
|
|
65
65
|
client: queryClient
|
|
66
|
-
}, /*#__PURE__*/ React__default["default"].createElement(reactQuery
|
|
66
|
+
}, /*#__PURE__*/ React__default["default"].createElement(reactQuery.HydrationBoundary, {
|
|
67
67
|
state: hydratedState
|
|
68
68
|
}, /*#__PURE__*/ React__default["default"].createElement(AppOrPage, Object.assign({}, props)))));
|
|
69
69
|
};
|
|
@@ -92,7 +92,7 @@ function withTRPC(opts) {
|
|
|
92
92
|
const config = getClientConfig({
|
|
93
93
|
ctx
|
|
94
94
|
});
|
|
95
|
-
const trpcClient =
|
|
95
|
+
const trpcClient = client.createTRPCUntypedClient(config);
|
|
96
96
|
const queryClient = shared.getQueryClient(config);
|
|
97
97
|
const trpcProp = {
|
|
98
98
|
config,
|
|
@@ -123,7 +123,7 @@ function withTRPC(opts) {
|
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
const dehydratedCache = reactQuery
|
|
126
|
+
const dehydratedCache = reactQuery.dehydrate(queryClient, {
|
|
127
127
|
shouldDehydrateQuery () {
|
|
128
128
|
// makes sure errors are also dehydrated
|
|
129
129
|
return true;
|
|
@@ -166,7 +166,7 @@ function withTRPC(opts) {
|
|
|
166
166
|
|
|
167
167
|
/* istanbul ignore file -- @preserve */ // We're testing this through E2E-testing
|
|
168
168
|
function createTRPCNext(opts) {
|
|
169
|
-
const hooks = shared.
|
|
169
|
+
const hooks = shared.createRootHooks(opts);
|
|
170
170
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
171
171
|
const _withTRPC = withTRPC(opts);
|
|
172
172
|
return shared$1.createFlatProxy((key)=>{
|
|
@@ -175,7 +175,7 @@ function createTRPCNext(opts) {
|
|
|
175
175
|
const context = hooks.useUtils();
|
|
176
176
|
// create a stable reference of the utils context
|
|
177
177
|
return React.useMemo(()=>{
|
|
178
|
-
return shared.
|
|
178
|
+
return shared.createReactQueryUtils(context);
|
|
179
179
|
}, [
|
|
180
180
|
context
|
|
181
181
|
]);
|
|
@@ -187,7 +187,7 @@ function createTRPCNext(opts) {
|
|
|
187
187
|
if (key === 'withTRPC') {
|
|
188
188
|
return _withTRPC;
|
|
189
189
|
}
|
|
190
|
-
return shared.
|
|
190
|
+
return shared.createReactDecoration(key, hooks);
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dehydrate, QueryClientProvider,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { dehydrate, QueryClientProvider, HydrationBoundary } from '@tanstack/react-query';
|
|
2
|
+
import { createTRPCUntypedClient } from '@trpc/client';
|
|
3
|
+
import { createRootHooks, getQueryClient, createReactQueryUtils, createReactDecoration } from '@trpc/react-query/shared';
|
|
4
4
|
import React, { createElement, useState, useMemo } from 'react';
|
|
5
5
|
import ssrPrepass from 'react-ssr-prepass';
|
|
6
6
|
import { createFlatProxy } from '@trpc/server/shared';
|
|
@@ -26,7 +26,7 @@ function transformQueryOrMutationCacheErrors(result) {
|
|
|
26
26
|
function withTRPC(opts) {
|
|
27
27
|
const { config: getClientConfig } = opts;
|
|
28
28
|
return (AppOrPage)=>{
|
|
29
|
-
const trpc =
|
|
29
|
+
const trpc = createRootHooks(opts);
|
|
30
30
|
const WithTRPC = (props)=>{
|
|
31
31
|
const [prepassProps] = useState(()=>{
|
|
32
32
|
if (props.trpc) {
|
|
@@ -54,7 +54,7 @@ function withTRPC(opts) {
|
|
|
54
54
|
ssrContext: ssrContext
|
|
55
55
|
}, /*#__PURE__*/ React.createElement(QueryClientProvider, {
|
|
56
56
|
client: queryClient
|
|
57
|
-
}, /*#__PURE__*/ React.createElement(
|
|
57
|
+
}, /*#__PURE__*/ React.createElement(HydrationBoundary, {
|
|
58
58
|
state: hydratedState
|
|
59
59
|
}, /*#__PURE__*/ React.createElement(AppOrPage, Object.assign({}, props)))));
|
|
60
60
|
};
|
|
@@ -83,7 +83,7 @@ function withTRPC(opts) {
|
|
|
83
83
|
const config = getClientConfig({
|
|
84
84
|
ctx
|
|
85
85
|
});
|
|
86
|
-
const trpcClient =
|
|
86
|
+
const trpcClient = createTRPCUntypedClient(config);
|
|
87
87
|
const queryClient = getQueryClient(config);
|
|
88
88
|
const trpcProp = {
|
|
89
89
|
config,
|
|
@@ -157,7 +157,7 @@ function withTRPC(opts) {
|
|
|
157
157
|
|
|
158
158
|
/* istanbul ignore file -- @preserve */ // We're testing this through E2E-testing
|
|
159
159
|
function createTRPCNext(opts) {
|
|
160
|
-
const hooks =
|
|
160
|
+
const hooks = createRootHooks(opts);
|
|
161
161
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
162
162
|
const _withTRPC = withTRPC(opts);
|
|
163
163
|
return createFlatProxy((key)=>{
|
|
@@ -166,7 +166,7 @@ function createTRPCNext(opts) {
|
|
|
166
166
|
const context = hooks.useUtils();
|
|
167
167
|
// create a stable reference of the utils context
|
|
168
168
|
return useMemo(()=>{
|
|
169
|
-
return
|
|
169
|
+
return createReactQueryUtils(context);
|
|
170
170
|
}, [
|
|
171
171
|
context
|
|
172
172
|
]);
|
|
@@ -178,7 +178,7 @@ function createTRPCNext(opts) {
|
|
|
178
178
|
if (key === 'withTRPC') {
|
|
179
179
|
return _withTRPC;
|
|
180
180
|
}
|
|
181
|
-
return
|
|
181
|
+
return createReactDecoration(key, hooks);
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
|
package/dist/withTRPC.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CreateTRPCClientOptions } from '@trpc/client';
|
|
2
2
|
import { TRPCClientError } from '@trpc/react-query';
|
|
3
3
|
import { CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig } from '@trpc/react-query/shared';
|
|
4
4
|
import type { AnyRouter } from '@trpc/server';
|
package/dist/withTRPC.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAWA,OAAO,
|
|
1
|
+
{"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EAGxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAuB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAEL,sBAAsB,EACtB,gCAAgC,EAEjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AA2BpC,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,SAAS,IAClD,uBAAuB,CAAC,OAAO,CAAC,GAC9B,gCAAgC,GAAG;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEN,UAAU,eAAe,CAAC,OAAO,SAAS,SAAS,CACjD,SAAQ,sBAAsB,CAAC,OAAO,CAAC;IACvC,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,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,CA+KxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/next",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-next.92+06cebb01",
|
|
4
4
|
"description": "The tRPC Next.js library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"build": "rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
|
|
27
27
|
"dev": "pnpm build --watch",
|
|
28
28
|
"codegen-entrypoints": "tsx entrypoints.script.ts",
|
|
29
|
+
"ts-watch": "tsc --project tsconfig.watch.json --watch",
|
|
29
30
|
"lint": "eslint --cache --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore --report-unused-disable-directives src"
|
|
30
31
|
},
|
|
31
32
|
"exports": {
|
|
@@ -65,10 +66,10 @@
|
|
|
65
66
|
"!**/*.test.*"
|
|
66
67
|
],
|
|
67
68
|
"peerDependencies": {
|
|
68
|
-
"@tanstack/react-query": "^
|
|
69
|
-
"@trpc/client": "
|
|
70
|
-
"@trpc/react-query": "
|
|
71
|
-
"@trpc/server": "
|
|
69
|
+
"@tanstack/react-query": "^5.0.0",
|
|
70
|
+
"@trpc/client": "11.0.0-next.92+06cebb01",
|
|
71
|
+
"@trpc/react-query": "11.0.0-next.92+06cebb01",
|
|
72
|
+
"@trpc/server": "11.0.0-next.92+06cebb01",
|
|
72
73
|
"next": "*",
|
|
73
74
|
"react": ">=16.8.0",
|
|
74
75
|
"react-dom": ">=16.8.0"
|
|
@@ -77,10 +78,10 @@
|
|
|
77
78
|
"react-ssr-prepass": "^1.5.0"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
|
-
"@tanstack/react-query": "^
|
|
81
|
-
"@trpc/client": "
|
|
82
|
-
"@trpc/react-query": "
|
|
83
|
-
"@trpc/server": "
|
|
81
|
+
"@tanstack/react-query": "^5.0.0",
|
|
82
|
+
"@trpc/client": "11.0.0-next.92+06cebb01",
|
|
83
|
+
"@trpc/react-query": "11.0.0-next.92+06cebb01",
|
|
84
|
+
"@trpc/server": "11.0.0-next.92+06cebb01",
|
|
84
85
|
"@types/express": "^4.17.17",
|
|
85
86
|
"@types/node": "^18.16.16",
|
|
86
87
|
"@types/react": "^18.2.8",
|
|
@@ -100,5 +101,5 @@
|
|
|
100
101
|
"funding": [
|
|
101
102
|
"https://trpc.io/sponsor"
|
|
102
103
|
],
|
|
103
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "06cebb015144e438281edace5dc4a5328477e495"
|
|
104
105
|
}
|
package/src/app-dir/client.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
clientCallTypeToProcedureType,
|
|
3
|
-
|
|
3
|
+
CreateTRPCClient,
|
|
4
4
|
createTRPCUntypedClient,
|
|
5
5
|
} from '@trpc/client';
|
|
6
6
|
import { AnyRouter } from '@trpc/server';
|
|
@@ -14,8 +14,6 @@ export {
|
|
|
14
14
|
experimental_serverActionLink,
|
|
15
15
|
// ts-prune-ignore-next
|
|
16
16
|
type UseTRPCActionResult,
|
|
17
|
-
// ts-prune-ignore-next
|
|
18
|
-
type inferActionResultProps,
|
|
19
17
|
} from './create-action-hook';
|
|
20
18
|
|
|
21
19
|
type QueryResult = {
|
|
@@ -65,6 +63,6 @@ export function experimental_createTRPCNextAppDirClient<
|
|
|
65
63
|
});
|
|
66
64
|
|
|
67
65
|
return promise;
|
|
68
|
-
}) as
|
|
66
|
+
}) as CreateTRPCClient<TRouter>;
|
|
69
67
|
// });
|
|
70
68
|
}
|
|
@@ -7,9 +7,7 @@ import {
|
|
|
7
7
|
} from '@trpc/client';
|
|
8
8
|
import { transformResult } from '@trpc/client/shared';
|
|
9
9
|
import {
|
|
10
|
-
AnyProcedure,
|
|
11
10
|
AnyRouter,
|
|
12
|
-
inferHandlerInput,
|
|
13
11
|
MaybePromise,
|
|
14
12
|
ProcedureOptions,
|
|
15
13
|
Simplify,
|
|
@@ -101,16 +99,6 @@ export function experimental_serverActionLink<
|
|
|
101
99
|
});
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
// ts-prune-ignore-next
|
|
105
|
-
/**
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
108
|
-
export type inferActionResultProps<TProc extends AnyProcedure> = {
|
|
109
|
-
input: inferHandlerInput<TProc>[0];
|
|
110
|
-
output: TProc['_def']['_output_out'];
|
|
111
|
-
errorShape: TProc['_def']['_config']['$types']['errorShape'];
|
|
112
|
-
};
|
|
113
|
-
|
|
114
102
|
interface UseTRPCActionOptions<TDef extends ActionHandlerDef> {
|
|
115
103
|
onSuccess?: (result: TDef['output']) => MaybePromise<void> | void;
|
|
116
104
|
onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
|
package/src/app-dir/server.ts
CHANGED
|
@@ -58,7 +58,10 @@ export function experimental_createTRPCNextAppDirServer<
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
return (client[procedureType] as any)(procedurePath, ...callOpts.args);
|
|
61
|
-
}) as NextAppDirDecoratedProcedureRecord<
|
|
61
|
+
}) as NextAppDirDecoratedProcedureRecord<
|
|
62
|
+
TRouter['_def']['_config'],
|
|
63
|
+
TRouter['_def']['record']
|
|
64
|
+
>;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
/**
|
|
@@ -91,7 +94,7 @@ export function experimental_createServerActionHandler<
|
|
|
91
94
|
// TODO allow this to take a `TRouter` in addition to a `AnyProcedure`
|
|
92
95
|
return function createServerAction<TProc extends AnyProcedure>(
|
|
93
96
|
proc: TProc,
|
|
94
|
-
): TRPCActionHandler<Simplify<inferActionDef<TProc>>> {
|
|
97
|
+
): TRPCActionHandler<Simplify<inferActionDef<TInstance['_config'], TProc>>> {
|
|
95
98
|
return async function actionHandler(
|
|
96
99
|
rawInput: FormData | inferProcedureInput<TProc>,
|
|
97
100
|
) {
|
|
@@ -116,8 +119,8 @@ export function experimental_createServerActionHandler<
|
|
|
116
119
|
input: undefined,
|
|
117
120
|
ctx,
|
|
118
121
|
path: 'serverAction',
|
|
119
|
-
rawInput,
|
|
120
|
-
type: proc.
|
|
122
|
+
getRawInput: async () => rawInput,
|
|
123
|
+
type: proc._def.type,
|
|
121
124
|
});
|
|
122
125
|
|
|
123
126
|
const transformedJSON = transformTRPCResponse(config, {
|
|
@@ -134,7 +137,7 @@ export function experimental_createServerActionHandler<
|
|
|
134
137
|
error,
|
|
135
138
|
input: rawInput,
|
|
136
139
|
path: 'serverAction',
|
|
137
|
-
type: proc.
|
|
140
|
+
type: proc._def.type,
|
|
138
141
|
});
|
|
139
142
|
|
|
140
143
|
// TODO: send the right HTTP header?!
|
|
@@ -143,7 +146,7 @@ export function experimental_createServerActionHandler<
|
|
|
143
146
|
error: shape,
|
|
144
147
|
});
|
|
145
148
|
}
|
|
146
|
-
} as TRPCActionHandler<inferActionDef<TProc>>;
|
|
149
|
+
} as TRPCActionHandler<inferActionDef<TInstance['_config'], TProc>>;
|
|
147
150
|
};
|
|
148
151
|
}
|
|
149
152
|
|
package/src/app-dir/shared.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
AnyProcedure,
|
|
8
8
|
AnyQueryProcedure,
|
|
9
|
+
AnyRootConfig,
|
|
9
10
|
AnyRouter,
|
|
10
11
|
Filter,
|
|
11
12
|
inferHandlerInput,
|
|
@@ -23,7 +24,7 @@ export type UseProcedureRecord<TRouter extends AnyRouter> = {
|
|
|
23
24
|
AnyQueryProcedure | AnyRouter
|
|
24
25
|
>]: TRouter['_def']['record'][TKey] extends AnyRouter
|
|
25
26
|
? UseProcedureRecord<TRouter['_def']['record'][TKey]>
|
|
26
|
-
: Resolver<TRouter['_def']['record'][TKey]>;
|
|
27
|
+
: Resolver<TRouter['_def']['_config'], TRouter['_def']['record'][TKey]>;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export function createUseProxy<TRouter extends AnyRouter>(
|
|
@@ -92,8 +93,11 @@ export interface ActionHandlerDef {
|
|
|
92
93
|
/**
|
|
93
94
|
* @internal
|
|
94
95
|
*/
|
|
95
|
-
export type inferActionDef<
|
|
96
|
+
export type inferActionDef<
|
|
97
|
+
TConfig extends AnyRootConfig,
|
|
98
|
+
TProc extends AnyProcedure,
|
|
99
|
+
> = {
|
|
96
100
|
input: inferHandlerInput<TProc>[0];
|
|
97
101
|
output: TProc['_def']['_output_out'];
|
|
98
|
-
errorShape:
|
|
102
|
+
errorShape: TConfig['$types']['errorShape'];
|
|
99
103
|
};
|
package/src/app-dir/types.ts
CHANGED
|
@@ -3,38 +3,45 @@ import {
|
|
|
3
3
|
AnyMutationProcedure,
|
|
4
4
|
AnyProcedure,
|
|
5
5
|
AnyQueryProcedure,
|
|
6
|
+
AnyRootConfig,
|
|
6
7
|
AnyRouter,
|
|
7
8
|
AnySubscriptionProcedure,
|
|
8
9
|
ProcedureArgs,
|
|
9
10
|
ProcedureRouterRecord,
|
|
10
11
|
} from '@trpc/server';
|
|
11
12
|
|
|
12
|
-
export type DecorateProcedureServer<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
export type DecorateProcedureServer<
|
|
14
|
+
TConfig extends AnyRootConfig,
|
|
15
|
+
TProcedure extends AnyProcedure,
|
|
16
|
+
> = TProcedure extends AnyQueryProcedure
|
|
17
|
+
? {
|
|
18
|
+
query: Resolver<TConfig, TProcedure>;
|
|
19
|
+
revalidate: (
|
|
20
|
+
input?: ProcedureArgs<TProcedure['_def']>[0],
|
|
21
|
+
) => Promise<
|
|
22
|
+
{ revalidated: false; error: string } | { revalidated: true }
|
|
23
|
+
>;
|
|
24
|
+
}
|
|
25
|
+
: TProcedure extends AnyMutationProcedure
|
|
26
|
+
? {
|
|
27
|
+
mutate: Resolver<TConfig, TProcedure>;
|
|
28
|
+
}
|
|
29
|
+
: TProcedure extends AnySubscriptionProcedure
|
|
30
|
+
? {
|
|
31
|
+
subscribe: Resolver<TConfig, TProcedure>;
|
|
32
|
+
}
|
|
33
|
+
: never;
|
|
31
34
|
|
|
32
35
|
export type NextAppDirDecoratedProcedureRecord<
|
|
36
|
+
TConfig extends AnyRootConfig,
|
|
33
37
|
TProcedures extends ProcedureRouterRecord,
|
|
34
38
|
> = {
|
|
35
39
|
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter
|
|
36
|
-
? NextAppDirDecoratedProcedureRecord<
|
|
40
|
+
? NextAppDirDecoratedProcedureRecord<
|
|
41
|
+
TConfig,
|
|
42
|
+
TProcedures[TKey]['_def']['record']
|
|
43
|
+
>
|
|
37
44
|
: TProcedures[TKey] extends AnyProcedure
|
|
38
|
-
? DecorateProcedureServer<TProcedures[TKey]>
|
|
45
|
+
? DecorateProcedureServer<TConfig, TProcedures[TKey]>
|
|
39
46
|
: never;
|
|
40
47
|
};
|
package/src/createTRPCNext.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* istanbul ignore file -- @preserve */
|
|
2
2
|
// We're testing this through E2E-testing
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
createReactDecoration,
|
|
5
|
+
createReactQueryUtils,
|
|
6
|
+
CreateReactUtils,
|
|
7
|
+
createRootHooks,
|
|
8
8
|
DecoratedProcedureRecord,
|
|
9
9
|
TRPCUseQueries,
|
|
10
10
|
} from '@trpc/react-query/shared';
|
|
@@ -26,11 +26,11 @@ export interface CreateTRPCNextBase<
|
|
|
26
26
|
*
|
|
27
27
|
* @see https://trpc.io/docs/client/react/useUtils
|
|
28
28
|
*/
|
|
29
|
-
useContext():
|
|
29
|
+
useContext(): CreateReactUtils<TRouter, TSSRContext>;
|
|
30
30
|
/**
|
|
31
31
|
* @see https://trpc.io/docs/client/react/useUtils
|
|
32
32
|
*/
|
|
33
|
-
useUtils():
|
|
33
|
+
useUtils(): CreateReactUtils<TRouter, TSSRContext>;
|
|
34
34
|
withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
|
|
35
35
|
useQueries: TRPCUseQueries<TRouter>;
|
|
36
36
|
}
|
|
@@ -44,7 +44,11 @@ export type CreateTRPCNext<
|
|
|
44
44
|
TFlags,
|
|
45
45
|
> = ProtectedIntersection<
|
|
46
46
|
CreateTRPCNextBase<TRouter, TSSRContext>,
|
|
47
|
-
DecoratedProcedureRecord<
|
|
47
|
+
DecoratedProcedureRecord<
|
|
48
|
+
TRouter['_def']['_config'],
|
|
49
|
+
TRouter['_def']['record'],
|
|
50
|
+
TFlags
|
|
51
|
+
>
|
|
48
52
|
>;
|
|
49
53
|
|
|
50
54
|
export function createTRPCNext<
|
|
@@ -54,7 +58,7 @@ export function createTRPCNext<
|
|
|
54
58
|
>(
|
|
55
59
|
opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>,
|
|
56
60
|
): CreateTRPCNext<TRouter, TSSRContext, TFlags> {
|
|
57
|
-
const hooks =
|
|
61
|
+
const hooks = createRootHooks<TRouter, TSSRContext>(opts);
|
|
58
62
|
|
|
59
63
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
60
64
|
const _withTRPC = withTRPC(opts);
|
|
@@ -65,7 +69,7 @@ export function createTRPCNext<
|
|
|
65
69
|
const context = hooks.useUtils();
|
|
66
70
|
// create a stable reference of the utils context
|
|
67
71
|
return useMemo(() => {
|
|
68
|
-
return (
|
|
72
|
+
return (createReactQueryUtils as any)(context);
|
|
69
73
|
}, [context]);
|
|
70
74
|
};
|
|
71
75
|
}
|
|
@@ -78,6 +82,6 @@ export function createTRPCNext<
|
|
|
78
82
|
return _withTRPC;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
return
|
|
85
|
+
return createReactDecoration(key, hooks);
|
|
82
86
|
});
|
|
83
87
|
}
|
package/src/withTRPC.tsx
CHANGED
|
@@ -5,19 +5,18 @@
|
|
|
5
5
|
import {
|
|
6
6
|
dehydrate,
|
|
7
7
|
DehydratedState,
|
|
8
|
-
|
|
8
|
+
HydrationBoundary,
|
|
9
9
|
QueryClient,
|
|
10
10
|
QueryClientProvider,
|
|
11
11
|
} from '@tanstack/react-query';
|
|
12
|
-
import type { CreateTRPCClientOptions } from '@trpc/client';
|
|
13
12
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from '@trpc/react-query';
|
|
13
|
+
CreateTRPCClientOptions,
|
|
14
|
+
createTRPCUntypedClient,
|
|
15
|
+
TRPCUntypedClient,
|
|
16
|
+
} from '@trpc/client';
|
|
17
|
+
import { TRPCClientError, TRPCClientErrorLike } from '@trpc/react-query';
|
|
20
18
|
import {
|
|
19
|
+
createRootHooks,
|
|
21
20
|
CreateTRPCReactOptions,
|
|
22
21
|
CreateTRPCReactQueryClientConfig,
|
|
23
22
|
getQueryClient,
|
|
@@ -89,12 +88,12 @@ export function withTRPC<
|
|
|
89
88
|
type TRPCPrepassProps = {
|
|
90
89
|
config: WithTRPCConfig<TRouter>;
|
|
91
90
|
queryClient: QueryClient;
|
|
92
|
-
trpcClient:
|
|
91
|
+
trpcClient: TRPCUntypedClient<TRouter>;
|
|
93
92
|
ssrState: 'prepass';
|
|
94
93
|
ssrContext: TSSRContext;
|
|
95
94
|
};
|
|
96
95
|
return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {
|
|
97
|
-
const trpc =
|
|
96
|
+
const trpc = createRootHooks<TRouter, TSSRContext>(opts);
|
|
98
97
|
|
|
99
98
|
const WithTRPC = (
|
|
100
99
|
props: AppPropsType<NextRouter, any> & {
|
|
@@ -135,9 +134,9 @@ export function withTRPC<
|
|
|
135
134
|
ssrContext={ssrContext}
|
|
136
135
|
>
|
|
137
136
|
<QueryClientProvider client={queryClient}>
|
|
138
|
-
<
|
|
137
|
+
<HydrationBoundary state={hydratedState}>
|
|
139
138
|
<AppOrPage {...props} />
|
|
140
|
-
</
|
|
139
|
+
</HydrationBoundary>
|
|
141
140
|
</QueryClientProvider>
|
|
142
141
|
</trpc.Provider>
|
|
143
142
|
);
|
|
@@ -176,7 +175,7 @@ export function withTRPC<
|
|
|
176
175
|
}
|
|
177
176
|
|
|
178
177
|
const config = getClientConfig({ ctx });
|
|
179
|
-
const trpcClient =
|
|
178
|
+
const trpcClient = createTRPCUntypedClient(config);
|
|
180
179
|
const queryClient = getQueryClient(config);
|
|
181
180
|
|
|
182
181
|
const trpcProp: TRPCPrepassProps = {
|