@trpc/next 10.27.3 → 10.28.1
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/app-dir/links/nextCache/index.d.ts +1 -0
- package/app-dir/links/nextCache/index.js +1 -0
- package/app-dir/links/nextHttp/index.d.ts +1 -0
- package/app-dir/links/nextHttp/index.js +1 -0
- package/dist/app-dir/client.d.ts +5 -5
- package/dist/app-dir/create-action-hook.d.ts +45 -45
- package/dist/app-dir/create-action-hook.d.ts.map +1 -1
- package/dist/app-dir/formDataToObject.d.ts +1 -1
- package/dist/app-dir/server.d.ts +23 -23
- package/dist/app-dir/server.d.ts.map +1 -1
- package/dist/app-dir/shared.d.ts +46 -46
- package/dist/app-dir/shared.d.ts.map +1 -1
- package/dist/createTRPCNext.d.ts +17 -17
- package/dist/createTRPCNext.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/{shared-bc6a2699.js → shared-7b422d72.js} +9 -9
- package/dist/withTRPC.d.ts +26 -26
- package/dist/withTRPC.d.ts.map +1 -1
- package/package.json +14 -10
- package/dist/app-dir/client.test.d.ts +0 -2
- package/dist/app-dir/client.test.d.ts.map +0 -1
- package/src/app-dir/client.test.tsx +0 -408
- package/src/app-dir/formDataToObject.test.ts +0 -58
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../dist/app-dir/links/nextCache';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../../dist/app-dir/links/nextCache');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../dist/app-dir/links/nextHttp';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../../dist/app-dir/links/nextHttp');
|
package/dist/app-dir/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CreateTRPCProxyClient } from '@trpc/client';
|
|
2
|
-
import { AnyRouter } from '@trpc/server';
|
|
3
|
-
import { CreateTRPCNextAppRouterOptions } from './shared';
|
|
4
|
-
export { experimental_createActionHook, experimental_serverActionLink, type UseTRPCActionResult, type inferActionResultProps, } from './create-action-hook';
|
|
5
|
-
export declare function experimental_createTRPCNextAppDirClient<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
1
|
+
import { CreateTRPCProxyClient } from '@trpc/client';
|
|
2
|
+
import { AnyRouter } from '@trpc/server';
|
|
3
|
+
import { CreateTRPCNextAppRouterOptions } from './shared';
|
|
4
|
+
export { experimental_createActionHook, experimental_serverActionLink, type UseTRPCActionResult, type inferActionResultProps, } from './create-action-hook';
|
|
5
|
+
export declare function experimental_createTRPCNextAppDirClient<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
6
6
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { CreateTRPCClientOptions, TRPCClientError, TRPCLink } from '@trpc/client';
|
|
2
|
-
import { AnyProcedure, AnyRouter, MaybePromise, ProcedureOptions, Simplify, inferHandlerInput } from '@trpc/server';
|
|
3
|
-
import { TRPCActionHandler } from './server';
|
|
4
|
-
import { ActionHandlerDef } from './shared';
|
|
5
|
-
|
|
6
|
-
interface UseTRPCActionBaseResult<TDef extends ActionHandlerDef> {
|
|
7
|
-
mutate: (...args: MutationArgs<TDef>) => void;
|
|
8
|
-
mutateAsync: (...args: MutationArgs<TDef>) => Promise<TDef['output']>;
|
|
9
|
-
}
|
|
10
|
-
interface UseTRPCActionSuccessResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
11
|
-
data: TDef['output'];
|
|
12
|
-
error?: never;
|
|
13
|
-
status: 'success';
|
|
14
|
-
}
|
|
15
|
-
interface UseTRPCActionErrorResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
16
|
-
data?: never;
|
|
17
|
-
error: TRPCClientError<TDef['errorShape']>;
|
|
18
|
-
status: 'error';
|
|
19
|
-
}
|
|
20
|
-
interface UseTRPCActionIdleResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
21
|
-
data?: never;
|
|
22
|
-
error?: never;
|
|
23
|
-
status: 'idle';
|
|
24
|
-
}
|
|
25
|
-
interface UseTRPCActionLoadingResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
26
|
-
data?: never;
|
|
27
|
-
error?: never;
|
|
28
|
-
status: 'loading';
|
|
29
|
-
}
|
|
30
|
-
export
|
|
31
|
-
export declare function experimental_serverActionLink<TRouter extends AnyRouter = AnyRouter>(): TRPCLink<TRouter>;
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export
|
|
36
|
-
input: inferHandlerInput<TProc>[0];
|
|
37
|
-
output: TProc['_def']['_output_out'];
|
|
38
|
-
errorShape: TProc['_def']['_config']['$types']['errorShape'];
|
|
39
|
-
};
|
|
40
|
-
interface UseTRPCActionOptions<TDef extends ActionHandlerDef> {
|
|
41
|
-
onSuccess?: (result: TDef['output']) => void | MaybePromise<void>;
|
|
42
|
-
onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
|
|
43
|
-
}
|
|
44
|
-
export declare function experimental_createActionHook<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): <TDef extends ActionHandlerDef>(handler: TRPCActionHandler<TDef>, useActionOpts?: UseTRPCActionOptions<Simplify<TDef>> | undefined) => UseTRPCActionResult<TDef>;
|
|
45
|
-
export {};
|
|
1
|
+
import { CreateTRPCClientOptions, TRPCClientError, TRPCLink } from '@trpc/client';
|
|
2
|
+
import { AnyProcedure, AnyRouter, MaybePromise, ProcedureOptions, Simplify, inferHandlerInput } from '@trpc/server';
|
|
3
|
+
import { TRPCActionHandler } from './server';
|
|
4
|
+
import { ActionHandlerDef } from './shared';
|
|
5
|
+
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> {
|
|
7
|
+
mutate: (...args: MutationArgs<TDef>) => void;
|
|
8
|
+
mutateAsync: (...args: MutationArgs<TDef>) => Promise<TDef['output']>;
|
|
9
|
+
}
|
|
10
|
+
interface UseTRPCActionSuccessResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
11
|
+
data: TDef['output'];
|
|
12
|
+
error?: never;
|
|
13
|
+
status: 'success';
|
|
14
|
+
}
|
|
15
|
+
interface UseTRPCActionErrorResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
16
|
+
data?: never;
|
|
17
|
+
error: TRPCClientError<TDef['errorShape']>;
|
|
18
|
+
status: 'error';
|
|
19
|
+
}
|
|
20
|
+
interface UseTRPCActionIdleResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
21
|
+
data?: never;
|
|
22
|
+
error?: never;
|
|
23
|
+
status: 'idle';
|
|
24
|
+
}
|
|
25
|
+
interface UseTRPCActionLoadingResult<TDef extends ActionHandlerDef> extends UseTRPCActionBaseResult<TDef> {
|
|
26
|
+
data?: never;
|
|
27
|
+
error?: never;
|
|
28
|
+
status: 'loading';
|
|
29
|
+
}
|
|
30
|
+
export type UseTRPCActionResult<TDef extends ActionHandlerDef> = UseTRPCActionSuccessResult<TDef> | UseTRPCActionErrorResult<TDef> | UseTRPCActionIdleResult<TDef> | UseTRPCActionLoadingResult<TDef>;
|
|
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
|
+
interface UseTRPCActionOptions<TDef extends ActionHandlerDef> {
|
|
41
|
+
onSuccess?: (result: TDef['output']) => void | MaybePromise<void>;
|
|
42
|
+
onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
|
|
43
|
+
}
|
|
44
|
+
export declare function experimental_createActionHook<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): <TDef extends ActionHandlerDef>(handler: TRPCActionHandler<TDef>, useActionOpts?: UseTRPCActionOptions<Simplify<TDef>> | undefined) => UseTRPCActionResult<TDef>;
|
|
45
|
+
export {};
|
|
46
46
|
//# sourceMappingURL=create-action-hook.d.ts.map
|
|
@@ -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,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAc,MAAM,UAAU,CAAC;AAExD,
|
|
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,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7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Data: FormData): Record<string, unknown>;
|
|
1
|
+
export declare function formDataToObject(formData: FormData): Record<string, unknown>;
|
|
2
2
|
//# sourceMappingURL=formDataToObject.d.ts.map
|
package/dist/app-dir/server.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { CreateTRPCProxyClient } from '@trpc/client';
|
|
2
|
-
import { AnyProcedure, AnyRootConfig, AnyRouter, MaybePromise, Simplify } from '@trpc/server';
|
|
3
|
-
import { TRPCResponse } from '@trpc/server/rpc';
|
|
4
|
-
import { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef } from './shared';
|
|
5
|
-
export declare function experimental_createTRPCNextAppDirServer<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export
|
|
10
|
-
export declare function experimental_createServerActionHandler<TInstance extends {
|
|
11
|
-
_config: AnyRootConfig;
|
|
12
|
-
}>(t: TInstance, opts: {
|
|
13
|
-
createContext: () => MaybePromise<TInstance['_config']['$types']['ctx']>;
|
|
14
|
-
/**
|
|
15
|
-
* Transform form data to a `Record` before passing it to the procedure
|
|
16
|
-
* @default true
|
|
17
|
-
*/
|
|
18
|
-
normalizeFormData?: boolean;
|
|
19
|
-
}): <TProc extends AnyProcedure>(proc: TProc) => TRPCActionHandler<{
|
|
20
|
-
input: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TProc>>[0];
|
|
21
|
-
output: TProc["_def"]["_output_out"];
|
|
22
|
-
errorShape: TProc["_def"]["_config"]["$types"]["errorShape"];
|
|
23
|
-
}>;
|
|
1
|
+
import { CreateTRPCProxyClient } from '@trpc/client';
|
|
2
|
+
import { AnyProcedure, AnyRootConfig, AnyRouter, MaybePromise, Simplify } from '@trpc/server';
|
|
3
|
+
import { TRPCResponse } from '@trpc/server/rpc';
|
|
4
|
+
import { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef } from './shared';
|
|
5
|
+
export declare function experimental_createTRPCNextAppDirServer<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export type TRPCActionHandler<TDef extends ActionHandlerDef> = (input: TDef['input'] | FormData) => Promise<TRPCResponse<TDef['output'], TDef['errorShape']>>;
|
|
10
|
+
export declare function experimental_createServerActionHandler<TInstance extends {
|
|
11
|
+
_config: AnyRootConfig;
|
|
12
|
+
}>(t: TInstance, opts: {
|
|
13
|
+
createContext: () => MaybePromise<TInstance['_config']['$types']['ctx']>;
|
|
14
|
+
/**
|
|
15
|
+
* Transform form data to a `Record` before passing it to the procedure
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
normalizeFormData?: boolean;
|
|
19
|
+
}): <TProc extends AnyProcedure>(proc: TProc) => TRPCActionHandler<{
|
|
20
|
+
input: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TProc>>[0];
|
|
21
|
+
output: TProc["_def"]["_output_out"];
|
|
22
|
+
errorShape: TProc["_def"]["_config"]["$types"]["errorShape"];
|
|
23
|
+
}>;
|
|
24
24
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/app-dir/server.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EAGtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EAET,YAAY,EACZ,QAAQ,EAIT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQhD,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAC9B,cAAc,EAEf,MAAM,UAAU,CAAC;AAGlB,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,kCAkB9C;AAED;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/app-dir/server.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EAGtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EAET,YAAY,EACZ,QAAQ,EAIT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQhD,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAC9B,cAAc,EAEf,MAAM,UAAU,CAAC;AAGlB,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,kCAkB9C;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,gBAAgB,IAAI,CAC7D,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,QAAQ,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"}
|
package/dist/app-dir/shared.d.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { CreateTRPCClientOptions, Resolver, TRPCUntypedClient } from '@trpc/client';
|
|
2
|
-
import { AnyProcedure, AnyQueryProcedure, AnyRouter, Filter, ProtectedIntersection, ThenArg, inferHandlerInput } from '@trpc/server';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export
|
|
7
|
-
[TKey in keyof Filter<TRouter['_def']['record'], AnyRouter | AnyQueryProcedure>]: TRouter['_def']['record'][TKey] extends AnyRouter ? UseProcedureRecord<TRouter['_def']['record'][TKey]> : Resolver<TRouter['_def']['record'][TKey]>;
|
|
8
|
-
};
|
|
9
|
-
export declare function createUseProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>): UseProcedureRecord<TRouter>;
|
|
10
|
-
|
|
11
|
-
<TData extends Promise<unknown>[]>(cb: (t: UseProcedureRecord<TRouter>) => [...TData]): {
|
|
12
|
-
[TKey in keyof TData]: ThenArg<TData[TKey]>;
|
|
13
|
-
};
|
|
14
|
-
<TData extends Promise<unknown>>(cb: (t: UseProcedureRecord<TRouter>) => TData): ThenArg<TData>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
use: NextAppRouterUse<TRouter>;
|
|
18
|
-
};
|
|
19
|
-
export
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export interface CreateTRPCNextAppRouterOptions<TRouter extends AnyRouter> {
|
|
24
|
-
config: () => CreateTRPCClientOptions<TRouter>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export declare function isFormData(value: unknown): value is FormData;
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
export interface ActionHandlerDef {
|
|
34
|
-
input?: any;
|
|
35
|
-
output?: any;
|
|
36
|
-
errorShape: any;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export
|
|
42
|
-
input: inferHandlerInput<TProc>[0];
|
|
43
|
-
output: TProc['_def']['_output_out'];
|
|
44
|
-
errorShape: TProc['_def']['_config']['$types']['errorShape'];
|
|
45
|
-
};
|
|
46
|
-
export {};
|
|
1
|
+
import { CreateTRPCClientOptions, Resolver, TRPCUntypedClient } from '@trpc/client';
|
|
2
|
+
import { AnyProcedure, AnyQueryProcedure, AnyRouter, Filter, ProtectedIntersection, ThenArg, inferHandlerInput } from '@trpc/server';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export type UseProcedureRecord<TRouter extends AnyRouter> = {
|
|
7
|
+
[TKey in keyof Filter<TRouter['_def']['record'], AnyRouter | AnyQueryProcedure>]: TRouter['_def']['record'][TKey] extends AnyRouter ? UseProcedureRecord<TRouter['_def']['record'][TKey]> : Resolver<TRouter['_def']['record'][TKey]>;
|
|
8
|
+
};
|
|
9
|
+
export declare function createUseProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>): UseProcedureRecord<TRouter>;
|
|
10
|
+
type NextAppRouterUse<TRouter extends AnyRouter> = {
|
|
11
|
+
<TData extends Promise<unknown>[]>(cb: (t: UseProcedureRecord<TRouter>) => [...TData]): {
|
|
12
|
+
[TKey in keyof TData]: ThenArg<TData[TKey]>;
|
|
13
|
+
};
|
|
14
|
+
<TData extends Promise<unknown>>(cb: (t: UseProcedureRecord<TRouter>) => TData): ThenArg<TData>;
|
|
15
|
+
};
|
|
16
|
+
type CreateTRPCNextAppRouterBase<TRouter extends AnyRouter> = {
|
|
17
|
+
use: NextAppRouterUse<TRouter>;
|
|
18
|
+
};
|
|
19
|
+
export type CreateTRPCNextAppRouter<TRouter extends AnyRouter> = ProtectedIntersection<CreateTRPCNextAppRouterBase<TRouter>, UseProcedureRecord<TRouter>>;
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export interface CreateTRPCNextAppRouterOptions<TRouter extends AnyRouter> {
|
|
24
|
+
config: () => CreateTRPCClientOptions<TRouter>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function isFormData(value: unknown): value is FormData;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export interface ActionHandlerDef {
|
|
34
|
+
input?: any;
|
|
35
|
+
output?: any;
|
|
36
|
+
errorShape: any;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export type inferActionDef<TProc extends AnyProcedure> = {
|
|
42
|
+
input: inferHandlerInput<TProc>[0];
|
|
43
|
+
output: TProc['_def']['_output_out'];
|
|
44
|
+
errorShape: TProc['_def']['_config']['$types']['errorShape'];
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
47
47
|
//# 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,qBAAqB,EACrB,OAAO,EACP,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,
|
|
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,qBAAqB,EACrB,OAAO,EACP,iBAAiB,EAClB,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,CA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CAAC,CAAC;CAChD;AAED;;GAEG;AACH,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,CAAC,KAAK,SAAS,YAAY,IAAI;IACvD,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;IACrC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;CAC9D,CAAC"}
|
package/dist/createTRPCNext.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { CreateReactUtilsProxy, DecoratedProcedureRecord, TRPCUseQueries } from '@trpc/react-query/shared';
|
|
2
|
-
import { AnyRouter, ProtectedIntersection } from '@trpc/server';
|
|
3
|
-
import { NextPageContext } from 'next/types';
|
|
4
|
-
import { WithTRPCNoSSROptions, WithTRPCSSROptions, withTRPC } from './withTRPC';
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export interface CreateTRPCNextBase<TRouter extends AnyRouter, TSSRContext extends NextPageContext> {
|
|
9
|
-
useContext(): CreateReactUtilsProxy<TRouter, TSSRContext>;
|
|
10
|
-
withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
|
|
11
|
-
useQueries: TRPCUseQueries<TRouter>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export
|
|
17
|
-
export declare function createTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext, TFlags = null>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): CreateTRPCNext<TRouter, TSSRContext, TFlags>;
|
|
1
|
+
import { CreateReactUtilsProxy, DecoratedProcedureRecord, TRPCUseQueries } from '@trpc/react-query/shared';
|
|
2
|
+
import { AnyRouter, ProtectedIntersection } from '@trpc/server';
|
|
3
|
+
import { NextPageContext } from 'next/types';
|
|
4
|
+
import { WithTRPCNoSSROptions, WithTRPCSSROptions, withTRPC } from './withTRPC';
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface CreateTRPCNextBase<TRouter extends AnyRouter, TSSRContext extends NextPageContext> {
|
|
9
|
+
useContext(): CreateReactUtilsProxy<TRouter, TSSRContext>;
|
|
10
|
+
withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
|
|
11
|
+
useQueries: TRPCUseQueries<TRouter>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export type CreateTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext, TFlags> = ProtectedIntersection<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>;
|
|
18
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,EACxB,cAAc,EAIf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,qB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,CACvB,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,EACxC,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAC5D,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.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './withTRPC';
|
|
2
|
-
export * from './createTRPCNext';
|
|
1
|
+
export * from './withTRPC';
|
|
2
|
+
export * from './createTRPCNext';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import '@trpc/server/shared';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
function isFormData(value) {
|
|
7
|
-
if (typeof FormData === 'undefined') {
|
|
8
|
-
// FormData is not supported
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return value instanceof FormData;
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
function isFormData(value) {
|
|
7
|
+
if (typeof FormData === 'undefined') {
|
|
8
|
+
// FormData is not supported
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return value instanceof FormData;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export { isFormData as i };
|
package/dist/withTRPC.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { CreateTRPCClientOptions } from '@trpc/client';
|
|
2
|
-
import { TRPCClientError } from '@trpc/react-query';
|
|
3
|
-
import { CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig } from '@trpc/react-query/shared';
|
|
4
|
-
import type { AnyRouter } from '@trpc/server';
|
|
5
|
-
import type { ResponseMeta } from '@trpc/server/http';
|
|
6
|
-
import { NextComponentType, NextPageContext } from 'next/dist/shared/lib/utils';
|
|
7
|
-
export
|
|
8
|
-
abortOnUnmount?: boolean;
|
|
9
|
-
} & CreateTRPCReactQueryClientConfig;
|
|
10
|
-
interface WithTRPCOptions<TRouter extends AnyRouter> extends CreateTRPCReactOptions<TRouter> {
|
|
11
|
-
config: (info: {
|
|
12
|
-
ctx?: NextPageContext;
|
|
13
|
-
}) => WithTRPCConfig<TRouter>;
|
|
14
|
-
}
|
|
15
|
-
export interface WithTRPCSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
16
|
-
ssr: true;
|
|
17
|
-
responseMeta?: (opts: {
|
|
18
|
-
ctx: NextPageContext;
|
|
19
|
-
clientErrors: TRPCClientError<TRouter>[];
|
|
20
|
-
}) => ResponseMeta;
|
|
21
|
-
}
|
|
22
|
-
export interface WithTRPCNoSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
23
|
-
ssr?: false;
|
|
24
|
-
}
|
|
25
|
-
export declare function withTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
|
|
26
|
-
export {};
|
|
1
|
+
import type { CreateTRPCClientOptions } from '@trpc/client';
|
|
2
|
+
import { TRPCClientError } from '@trpc/react-query';
|
|
3
|
+
import { CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig } from '@trpc/react-query/shared';
|
|
4
|
+
import type { AnyRouter } from '@trpc/server';
|
|
5
|
+
import type { ResponseMeta } from '@trpc/server/http';
|
|
6
|
+
import { NextComponentType, NextPageContext } from 'next/dist/shared/lib/utils';
|
|
7
|
+
export type WithTRPCConfig<TRouter extends AnyRouter> = CreateTRPCClientOptions<TRouter> & {
|
|
8
|
+
abortOnUnmount?: boolean;
|
|
9
|
+
} & CreateTRPCReactQueryClientConfig;
|
|
10
|
+
interface WithTRPCOptions<TRouter extends AnyRouter> extends CreateTRPCReactOptions<TRouter> {
|
|
11
|
+
config: (info: {
|
|
12
|
+
ctx?: NextPageContext;
|
|
13
|
+
}) => WithTRPCConfig<TRouter>;
|
|
14
|
+
}
|
|
15
|
+
export interface WithTRPCSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
16
|
+
ssr: true;
|
|
17
|
+
responseMeta?: (opts: {
|
|
18
|
+
ctx: NextPageContext;
|
|
19
|
+
clientErrors: TRPCClientError<TRouter>[];
|
|
20
|
+
}) => ResponseMeta;
|
|
21
|
+
}
|
|
22
|
+
export interface WithTRPCNoSSROptions<TRouter extends AnyRouter> extends WithTRPCOptions<TRouter> {
|
|
23
|
+
ssr?: false;
|
|
24
|
+
}
|
|
25
|
+
export declare function withTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
|
|
26
|
+
export {};
|
|
27
27
|
//# sourceMappingURL=withTRPC.d.ts.map
|
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,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAEL,eAAe,EAIhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,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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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": "10.
|
|
3
|
+
"version": "10.28.1",
|
|
4
4
|
"description": "The tRPC Next.js library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,13 +51,14 @@
|
|
|
51
51
|
"src",
|
|
52
52
|
"README.md",
|
|
53
53
|
"package.json",
|
|
54
|
-
"app-dir"
|
|
54
|
+
"app-dir",
|
|
55
|
+
"!**/*.test.*"
|
|
55
56
|
],
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"@tanstack/react-query": "^4.18.0",
|
|
58
|
-
"@trpc/client": "10.
|
|
59
|
-
"@trpc/react-query": "10.
|
|
60
|
-
"@trpc/server": "10.
|
|
59
|
+
"@trpc/client": "10.28.1",
|
|
60
|
+
"@trpc/react-query": "10.28.1",
|
|
61
|
+
"@trpc/server": "10.28.1",
|
|
61
62
|
"next": "*",
|
|
62
63
|
"react": ">=16.8.0",
|
|
63
64
|
"react-dom": ">=16.8.0"
|
|
@@ -67,11 +68,11 @@
|
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@tanstack/react-query": "^4.18.0",
|
|
70
|
-
"@trpc/client": "10.
|
|
71
|
-
"@trpc/react-query": "10.
|
|
72
|
-
"@trpc/server": "10.
|
|
71
|
+
"@trpc/client": "10.28.1",
|
|
72
|
+
"@trpc/react-query": "10.28.1",
|
|
73
|
+
"@trpc/server": "10.28.1",
|
|
73
74
|
"@types/express": "^4.17.17",
|
|
74
|
-
"@types/node": "^18.
|
|
75
|
+
"@types/node": "^18.16.16",
|
|
75
76
|
"@types/react": "^18.2.6",
|
|
76
77
|
"@types/react-dom": "^18.2.4",
|
|
77
78
|
"eslint": "^8.40.0",
|
|
@@ -86,5 +87,8 @@
|
|
|
86
87
|
"publishConfig": {
|
|
87
88
|
"access": "public"
|
|
88
89
|
},
|
|
89
|
-
"
|
|
90
|
+
"funding": [
|
|
91
|
+
"https://trpc.io/sponsor"
|
|
92
|
+
],
|
|
93
|
+
"gitHead": "ea70b1c33899b66f964a7d11f5a8710148f03f8e"
|
|
90
94
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/app-dir/client.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
import { render, waitFor } from '@testing-library/react';
|
|
2
|
-
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { initTRPC } from '@trpc/server';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import superjson from 'superjson';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import {
|
|
8
|
-
UseTRPCActionResult,
|
|
9
|
-
experimental_createActionHook,
|
|
10
|
-
experimental_serverActionLink,
|
|
11
|
-
} from './create-action-hook';
|
|
12
|
-
import { experimental_createServerActionHandler } from './server';
|
|
13
|
-
|
|
14
|
-
describe('without transformer', () => {
|
|
15
|
-
const instance = initTRPC
|
|
16
|
-
.context<{
|
|
17
|
-
foo: string;
|
|
18
|
-
}>()
|
|
19
|
-
.create({});
|
|
20
|
-
const { procedure } = instance;
|
|
21
|
-
|
|
22
|
-
const createAction = experimental_createServerActionHandler(instance, {
|
|
23
|
-
createContext() {
|
|
24
|
-
return {
|
|
25
|
-
foo: 'bar',
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const useAction = experimental_createActionHook({
|
|
31
|
-
links: [experimental_serverActionLink()],
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('server actions smoke test', async () => {
|
|
35
|
-
const action = createAction(procedure.mutation((opts) => opts.ctx));
|
|
36
|
-
expect(await action()).toMatchInlineSnapshot(`
|
|
37
|
-
Object {
|
|
38
|
-
"result": Object {
|
|
39
|
-
"data": Object {
|
|
40
|
-
"foo": "bar",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
}
|
|
44
|
-
`);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('normalize FormData', async () => {
|
|
48
|
-
const action = createAction(
|
|
49
|
-
procedure
|
|
50
|
-
.input(
|
|
51
|
-
z.object({
|
|
52
|
-
text: z.string(),
|
|
53
|
-
}),
|
|
54
|
-
)
|
|
55
|
-
.mutation((opts) => `hello ${opts.input.text}` as const),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
expect(
|
|
59
|
-
await action({
|
|
60
|
-
text: 'there',
|
|
61
|
-
}),
|
|
62
|
-
).toMatchInlineSnapshot(`
|
|
63
|
-
Object {
|
|
64
|
-
"result": Object {
|
|
65
|
-
"data": "hello there",
|
|
66
|
-
},
|
|
67
|
-
}
|
|
68
|
-
`);
|
|
69
|
-
|
|
70
|
-
const formData = new FormData();
|
|
71
|
-
formData.append('text', 'there');
|
|
72
|
-
expect(await action(formData)).toMatchInlineSnapshot(`
|
|
73
|
-
Object {
|
|
74
|
-
"result": Object {
|
|
75
|
-
"data": "hello there",
|
|
76
|
-
},
|
|
77
|
-
}
|
|
78
|
-
`);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('an actual client', async () => {
|
|
82
|
-
const action = createAction(
|
|
83
|
-
procedure
|
|
84
|
-
.input(
|
|
85
|
-
z.object({
|
|
86
|
-
text: z.string(),
|
|
87
|
-
}),
|
|
88
|
-
)
|
|
89
|
-
.mutation((opts) => `hello ${opts.input.text}` as const),
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const allStates: Omit<
|
|
93
|
-
UseTRPCActionResult<any>,
|
|
94
|
-
'mutate' | 'mutateAsync'
|
|
95
|
-
>[] = [] as any[];
|
|
96
|
-
|
|
97
|
-
function MyComponent() {
|
|
98
|
-
const mutation = useAction(action);
|
|
99
|
-
const { mutate, mutateAsync, ...other } = mutation;
|
|
100
|
-
allStates.push(other);
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<>
|
|
104
|
-
<button
|
|
105
|
-
role="trigger"
|
|
106
|
-
onClick={() => {
|
|
107
|
-
mutation.mutate({
|
|
108
|
-
text: 'world',
|
|
109
|
-
});
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
click me
|
|
113
|
-
</button>
|
|
114
|
-
</>
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// mount it
|
|
119
|
-
const utils = render(<MyComponent />);
|
|
120
|
-
|
|
121
|
-
// get the contents of pre
|
|
122
|
-
expect(allStates.at(-1)).toMatchInlineSnapshot(`
|
|
123
|
-
Object {
|
|
124
|
-
"status": "idle",
|
|
125
|
-
}
|
|
126
|
-
`);
|
|
127
|
-
|
|
128
|
-
// click the button
|
|
129
|
-
userEvent.click(utils.getByRole('trigger'));
|
|
130
|
-
|
|
131
|
-
// wait to finish
|
|
132
|
-
await waitFor(() => {
|
|
133
|
-
assert(allStates.at(-1)?.status === 'success');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
expect(allStates).toMatchInlineSnapshot(`
|
|
137
|
-
Array [
|
|
138
|
-
Object {
|
|
139
|
-
"status": "idle",
|
|
140
|
-
},
|
|
141
|
-
Object {
|
|
142
|
-
"status": "loading",
|
|
143
|
-
},
|
|
144
|
-
Object {
|
|
145
|
-
"data": "hello world",
|
|
146
|
-
"status": "success",
|
|
147
|
-
},
|
|
148
|
-
]
|
|
149
|
-
`);
|
|
150
|
-
|
|
151
|
-
const lastState = allStates.at(-1);
|
|
152
|
-
assert(lastState?.status === 'success');
|
|
153
|
-
expect(lastState.data).toMatchInlineSnapshot(`"hello world"`);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('with transformer', () => {
|
|
158
|
-
const instance = initTRPC
|
|
159
|
-
.context<{
|
|
160
|
-
foo: string;
|
|
161
|
-
}>()
|
|
162
|
-
.create({
|
|
163
|
-
transformer: superjson,
|
|
164
|
-
});
|
|
165
|
-
const { procedure } = instance;
|
|
166
|
-
|
|
167
|
-
const createAction = experimental_createServerActionHandler(instance, {
|
|
168
|
-
createContext() {
|
|
169
|
-
return {
|
|
170
|
-
foo: 'bar',
|
|
171
|
-
};
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
const useAction = experimental_createActionHook({
|
|
176
|
-
links: [experimental_serverActionLink()],
|
|
177
|
-
transformer: superjson,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test('pass a Date', async () => {
|
|
181
|
-
const action = createAction(
|
|
182
|
-
procedure
|
|
183
|
-
.input(
|
|
184
|
-
z.object({
|
|
185
|
-
date: z.date(),
|
|
186
|
-
}),
|
|
187
|
-
)
|
|
188
|
-
.mutation((opts) => opts.input.date),
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
const allStates: Omit<
|
|
192
|
-
UseTRPCActionResult<any>,
|
|
193
|
-
'mutate' | 'mutateAsync'
|
|
194
|
-
>[] = [] as any[];
|
|
195
|
-
|
|
196
|
-
function MyComponent() {
|
|
197
|
-
const mutation = useAction(action);
|
|
198
|
-
const { mutate, mutateAsync, ...other } = mutation;
|
|
199
|
-
allStates.push(other);
|
|
200
|
-
|
|
201
|
-
return (
|
|
202
|
-
<>
|
|
203
|
-
<button
|
|
204
|
-
role="trigger"
|
|
205
|
-
onClick={() => {
|
|
206
|
-
mutation.mutate({
|
|
207
|
-
date: new Date(0),
|
|
208
|
-
});
|
|
209
|
-
}}
|
|
210
|
-
>
|
|
211
|
-
click me
|
|
212
|
-
</button>
|
|
213
|
-
</>
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// mount it
|
|
218
|
-
const utils = render(<MyComponent />);
|
|
219
|
-
|
|
220
|
-
// get the contents of pre
|
|
221
|
-
expect(allStates.at(-1)).toMatchInlineSnapshot(`
|
|
222
|
-
Object {
|
|
223
|
-
"status": "idle",
|
|
224
|
-
}
|
|
225
|
-
`);
|
|
226
|
-
|
|
227
|
-
// click the button
|
|
228
|
-
userEvent.click(utils.getByRole('trigger'));
|
|
229
|
-
|
|
230
|
-
// wait to finish
|
|
231
|
-
await waitFor(() => {
|
|
232
|
-
assert(allStates.at(-1)?.status === 'success');
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
expect(allStates).toMatchInlineSnapshot(`
|
|
236
|
-
Array [
|
|
237
|
-
Object {
|
|
238
|
-
"status": "idle",
|
|
239
|
-
},
|
|
240
|
-
Object {
|
|
241
|
-
"status": "loading",
|
|
242
|
-
},
|
|
243
|
-
Object {
|
|
244
|
-
"data": 1970-01-01T00:00:00.000Z,
|
|
245
|
-
"status": "success",
|
|
246
|
-
},
|
|
247
|
-
]
|
|
248
|
-
`);
|
|
249
|
-
|
|
250
|
-
const lastState = allStates.at(-1);
|
|
251
|
-
assert(lastState?.status === 'success');
|
|
252
|
-
expect(lastState.data).toMatchInlineSnapshot('1970-01-01T00:00:00.000Z');
|
|
253
|
-
expect(lastState.data).toBeInstanceOf(Date);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
test('FormData', async () => {
|
|
257
|
-
const action = createAction(
|
|
258
|
-
procedure
|
|
259
|
-
.input(
|
|
260
|
-
z.object({
|
|
261
|
-
text: z.string(),
|
|
262
|
-
}),
|
|
263
|
-
)
|
|
264
|
-
.mutation((opts) => opts.input.text),
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
const allStates: Omit<
|
|
268
|
-
UseTRPCActionResult<any>,
|
|
269
|
-
'mutate' | 'mutateAsync'
|
|
270
|
-
>[] = [] as any[];
|
|
271
|
-
|
|
272
|
-
function MyComponent() {
|
|
273
|
-
const mutation = useAction(action);
|
|
274
|
-
const { mutate, mutateAsync, ...other } = mutation;
|
|
275
|
-
allStates.push(other);
|
|
276
|
-
|
|
277
|
-
return (
|
|
278
|
-
<>
|
|
279
|
-
<form
|
|
280
|
-
onSubmit={(e) => {
|
|
281
|
-
e.preventDefault();
|
|
282
|
-
|
|
283
|
-
const formData = new FormData(e.currentTarget);
|
|
284
|
-
mutation.mutate(formData);
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
<input type="text" name="text" defaultValue="world" />
|
|
288
|
-
<button role="trigger" type="submit">
|
|
289
|
-
click me
|
|
290
|
-
</button>
|
|
291
|
-
</form>
|
|
292
|
-
</>
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// mount it
|
|
297
|
-
const utils = render(<MyComponent />);
|
|
298
|
-
|
|
299
|
-
// get the contents of pre
|
|
300
|
-
expect(allStates.at(-1)).toMatchInlineSnapshot(`
|
|
301
|
-
Object {
|
|
302
|
-
"status": "idle",
|
|
303
|
-
}
|
|
304
|
-
`);
|
|
305
|
-
|
|
306
|
-
// click the button
|
|
307
|
-
userEvent.click(utils.getByRole('trigger'));
|
|
308
|
-
|
|
309
|
-
// wait to finish
|
|
310
|
-
await waitFor(() => {
|
|
311
|
-
assert(allStates.at(-1)?.status === 'success');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
expect(allStates).toMatchInlineSnapshot(`
|
|
315
|
-
Array [
|
|
316
|
-
Object {
|
|
317
|
-
"status": "idle",
|
|
318
|
-
},
|
|
319
|
-
Object {
|
|
320
|
-
"status": "loading",
|
|
321
|
-
},
|
|
322
|
-
Object {
|
|
323
|
-
"data": "world",
|
|
324
|
-
"status": "success",
|
|
325
|
-
},
|
|
326
|
-
]
|
|
327
|
-
`);
|
|
328
|
-
|
|
329
|
-
const lastState = allStates.at(-1);
|
|
330
|
-
assert(lastState?.status === 'success');
|
|
331
|
-
expect(lastState.data).toMatchInlineSnapshot('"world"');
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
describe('type tests', () => {
|
|
336
|
-
const ignoreErrors = async (fn: () => Promise<unknown> | unknown) => {
|
|
337
|
-
try {
|
|
338
|
-
await fn();
|
|
339
|
-
} catch {
|
|
340
|
-
// ignore
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
const instance = initTRPC
|
|
345
|
-
.context<{
|
|
346
|
-
foo: string;
|
|
347
|
-
}>()
|
|
348
|
-
.create({});
|
|
349
|
-
const { procedure } = instance;
|
|
350
|
-
|
|
351
|
-
const createAction = experimental_createServerActionHandler(instance, {
|
|
352
|
-
createContext() {
|
|
353
|
-
return {
|
|
354
|
-
foo: 'bar',
|
|
355
|
-
};
|
|
356
|
-
},
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
const useAction = experimental_createActionHook({
|
|
360
|
-
links: [experimental_serverActionLink()],
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
test('assert input is sent', async () => {
|
|
364
|
-
ignoreErrors(async () => {
|
|
365
|
-
const action = createAction(
|
|
366
|
-
procedure.input(z.string()).mutation((opts) => opts.input),
|
|
367
|
-
);
|
|
368
|
-
const hook = useAction(action);
|
|
369
|
-
// @ts-expect-error this requires an input
|
|
370
|
-
await action();
|
|
371
|
-
// @ts-expect-error this requires an input
|
|
372
|
-
hook.mutate();
|
|
373
|
-
|
|
374
|
-
// @ts-expect-error this requires an input
|
|
375
|
-
await hook.mutateAsync();
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
test('assert types is correct', async () => {
|
|
380
|
-
ignoreErrors(async () => {
|
|
381
|
-
const action = createAction(
|
|
382
|
-
procedure.input(z.date().optional()).mutation((opts) => opts.input),
|
|
383
|
-
);
|
|
384
|
-
const hook = useAction(action);
|
|
385
|
-
// @ts-expect-error wrong type
|
|
386
|
-
await action('bleh');
|
|
387
|
-
// @ts-expect-error wrong type
|
|
388
|
-
hook.mutate('bleh');
|
|
389
|
-
|
|
390
|
-
hook.mutate();
|
|
391
|
-
await action();
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
test('assert no input', async () => {
|
|
396
|
-
ignoreErrors(async () => {
|
|
397
|
-
const action = createAction(procedure.mutation((opts) => opts.input));
|
|
398
|
-
const hook = useAction(action);
|
|
399
|
-
// @ts-expect-error this takes no input
|
|
400
|
-
await action(null);
|
|
401
|
-
// @ts-expect-error this takes no input
|
|
402
|
-
hook.mutate(null);
|
|
403
|
-
|
|
404
|
-
// @ts-expect-error this takes no input
|
|
405
|
-
await hook.mutateAsync(null);
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { formDataToObject } from './formDataToObject';
|
|
2
|
-
|
|
3
|
-
test('basic', () => {
|
|
4
|
-
const formData = new FormData();
|
|
5
|
-
|
|
6
|
-
formData.append('foo', 'bar');
|
|
7
|
-
|
|
8
|
-
expect(formDataToObject(formData)).toEqual({
|
|
9
|
-
foo: 'bar',
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('multiple values on the same key', () => {
|
|
14
|
-
const formData = new FormData();
|
|
15
|
-
|
|
16
|
-
formData.append('foo', 'bar');
|
|
17
|
-
formData.append('foo', 'baz');
|
|
18
|
-
|
|
19
|
-
expect(formDataToObject(formData)).toEqual({
|
|
20
|
-
foo: ['bar', 'baz'],
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('deep key', () => {
|
|
25
|
-
const formData = new FormData();
|
|
26
|
-
|
|
27
|
-
formData.append('foo.bar.baz', 'qux');
|
|
28
|
-
|
|
29
|
-
expect(formDataToObject(formData)).toEqual({
|
|
30
|
-
foo: {
|
|
31
|
-
bar: {
|
|
32
|
-
baz: 'qux',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('array', () => {
|
|
39
|
-
const formData = new FormData();
|
|
40
|
-
|
|
41
|
-
formData.append('foo[0]', 'bar');
|
|
42
|
-
formData.append('foo[1]', 'baz');
|
|
43
|
-
|
|
44
|
-
expect(formDataToObject(formData)).toEqual({
|
|
45
|
-
foo: ['bar', 'baz'],
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('array with dot notation', () => {
|
|
50
|
-
const formData = new FormData();
|
|
51
|
-
|
|
52
|
-
formData.append('foo.0', 'bar');
|
|
53
|
-
formData.append('foo.1', 'baz');
|
|
54
|
-
|
|
55
|
-
expect(formDataToObject(formData)).toEqual({
|
|
56
|
-
foo: ['bar', 'baz'],
|
|
57
|
-
});
|
|
58
|
-
});
|