@trpc/next 10.26.0 → 10.27.0

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.
@@ -1,9 +1,6 @@
1
+ import { CreateTRPCProxyClient } from '@trpc/client';
1
2
  import { AnyRouter } from '@trpc/server';
2
- import { CreateTRPCNextAppRouterOptions, UseProcedureRecord } from './shared';
3
- export declare function experimental_createTRPCNextAppDirClient<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): import("@trpc/server").ProtectedIntersection<{
4
- use: {
5
- <TData extends Promise<unknown>[]>(cb: (t: UseProcedureRecord<TRouter>) => [...TData]): { [TKey in keyof TData]: import("@trpc/server").ThenArg<TData[TKey]>; };
6
- <TData_1 extends Promise<unknown>>(cb: (t: UseProcedureRecord<TRouter>) => TData_1): import("@trpc/server").ThenArg<TData_1>;
7
- };
8
- }, UseProcedureRecord<TRouter>>;
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>;
9
6
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/app-dir/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAEL,8BAA8B,EAC9B,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAkBlB,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC;;;;;gCA6D9C"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/app-dir/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAGtB,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,EAExB,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAkB9B,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,kCA8D9C"}
@@ -3,73 +3,163 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var client = require('@trpc/client');
6
- var shared = require('@trpc/server/shared');
6
+ var shared$2 = require('@trpc/server/shared');
7
+ var shared$1 = require('@trpc/client/shared');
8
+ var observable = require('@trpc/server/observable');
9
+ var React = require('react');
10
+ var shared = require('../shared-2ca37369.js');
7
11
 
8
- function createUseProxy(client) {
9
- return shared.createRecursiveProxy((opts)=>{
10
- const path = opts.path.join('.');
11
- return client.query(path, ...opts.args);
12
- });
12
+ // ts-prune-ignore-next
13
+ function experimental_serverActionLink() {
14
+ return (runtime)=>({ op })=>observable.observable((observer)=>{
15
+ const context = op.context;
16
+ context._action(shared.isFormData(op.input) ? op.input : runtime.transformer.serialize(op.input)).then((data)=>{
17
+ const transformed = shared$1.transformResult(data, runtime);
18
+ if (!transformed.ok) {
19
+ observer.error(client.TRPCClientError.from(transformed.error, {}));
20
+ return;
21
+ }
22
+ observer.next({
23
+ context: op.context,
24
+ result: transformed.result
25
+ });
26
+ observer.complete();
27
+ }).catch((cause)=>observer.error(client.TRPCClientError.from(cause)));
28
+ });
13
29
  }
14
-
15
- function normalizePromiseArray(promise) {
16
- if (Array.isArray(promise)) {
17
- return Promise.all(promise);
18
- }
19
- return promise;
30
+ // ts-prune-ignore-next
31
+ function experimental_createActionHook(opts) {
32
+ const client$1 = client.createTRPCUntypedClient(opts);
33
+ return function useAction(handler, useActionOpts) {
34
+ const count = React.useRef(0);
35
+ const [state, setState] = React.useState({
36
+ status: 'idle'
37
+ });
38
+ const actionOptsRef = React.useRef(useActionOpts);
39
+ actionOptsRef.current = useActionOpts;
40
+ React.useEffect(()=>{
41
+ return ()=>{
42
+ // cleanup after unmount to prevent calling hook opts after unmount
43
+ count.current = -1;
44
+ actionOptsRef.current = undefined;
45
+ };
46
+ }, []);
47
+ const mutateAsync = React.useCallback((input, requestOptions)=>{
48
+ const idx = ++count.current;
49
+ const context = {
50
+ ...requestOptions?.context,
51
+ _action (innerInput) {
52
+ return handler(innerInput);
53
+ }
54
+ };
55
+ setState({
56
+ status: 'loading'
57
+ });
58
+ return client$1.mutation('serverAction', input, {
59
+ ...requestOptions,
60
+ context
61
+ }).then(async (data)=>{
62
+ await actionOptsRef.current?.onSuccess?.(data);
63
+ if (idx !== count.current) {
64
+ return;
65
+ }
66
+ setState({
67
+ status: 'success',
68
+ data: data
69
+ });
70
+ }).catch(async (error)=>{
71
+ await actionOptsRef.current?.onError?.(error);
72
+ throw error;
73
+ }).catch((error)=>{
74
+ if (idx !== count.current) {
75
+ return;
76
+ }
77
+ setState({
78
+ status: 'error',
79
+ error: client.TRPCClientError.from(error, {})
80
+ });
81
+ throw error;
82
+ });
83
+ }, [
84
+ handler
85
+ ]);
86
+ const mutate = React.useCallback((...args)=>{
87
+ void mutateAsync(...args).catch(()=>{
88
+ // ignored
89
+ });
90
+ }, [
91
+ mutateAsync
92
+ ]);
93
+ return React.useMemo(()=>({
94
+ ...state,
95
+ mutate,
96
+ mutateAsync
97
+ }), [
98
+ mutate,
99
+ mutateAsync,
100
+ state
101
+ ]);
102
+ };
20
103
  }
104
+
21
105
  // ts-prune-ignore-next
22
106
  function experimental_createTRPCNextAppDirClient(opts) {
23
107
  const client$1 = client.createTRPCUntypedClient(opts.config());
24
- const useProxy = createUseProxy(client$1);
108
+ // const useProxy = createUseProxy<TRouter>(client);
25
109
  const cache = new Map();
26
- return shared.createFlatProxy((key)=>{
27
- if (key === 'use') {
28
- return (cb)=>{
29
- const promise = normalizePromiseArray(cb(useProxy));
30
- throw promise;
31
- // const [data, setData] = useState<unknown | unknown[]>();
32
- // useEffect(() => {
33
- // const promise = normalizePromiseArray(cb(useProxy));
34
- // void promise.then(setData).catch((err) => {
35
- // throw err;
36
- // });
37
- // // eslint-disable-next-line react-hooks/exhaustive-deps
38
- // }, []);
39
- // return data;
40
- };
41
- }
42
- return shared.createRecursiveProxy(({ path , args })=>{
43
- const pathCopy = [
44
- key,
45
- ...path
46
- ];
47
- const procedureType = client.clientCallTypeToProcedureType(pathCopy.pop());
48
- if (procedureType === 'query') {
49
- const queryCacheKey = JSON.stringify([
50
- path,
51
- args[0]
52
- ]);
53
- const cached = cache.get(queryCacheKey);
54
- if (cached?.promise) {
55
- return cached.promise;
56
- }
57
- }
58
- const fullPath = pathCopy.join('.');
59
- const promise = client$1[procedureType](fullPath, ...args);
60
- if (procedureType !== 'query') {
61
- return promise;
62
- }
63
- const queryCacheKey1 = JSON.stringify([
110
+ // return createFlatProxy<CreateTRPCNextAppRouter<TRouter>>((key) => {
111
+ // if (key === 'use') {
112
+ // return (
113
+ // cb: (
114
+ // t: UseProcedureRecord<TRouter>,
115
+ // ) => Promise<unknown> | Promise<unknown>[],
116
+ // ) => {
117
+ // const promise = normalizePromiseArray(cb(useProxy));
118
+ // throw promise;
119
+ // // const [data, setData] = useState<unknown | unknown[]>();
120
+ // // useEffect(() => {
121
+ // // const promise = normalizePromiseArray(cb(useProxy));
122
+ // // void promise.then(setData).catch((err) => {
123
+ // // throw err;
124
+ // // });
125
+ // // // eslint-disable-next-line react-hooks/exhaustive-deps
126
+ // // }, []);
127
+ // // return data;
128
+ // };
129
+ // }
130
+ return shared$2.createRecursiveProxy(({ path , args })=>{
131
+ // const pathCopy = [key, ...path];
132
+ const pathCopy = [
133
+ ...path
134
+ ];
135
+ const procedureType = client.clientCallTypeToProcedureType(pathCopy.pop());
136
+ if (procedureType === 'query') {
137
+ const queryCacheKey = JSON.stringify([
64
138
  path,
65
139
  args[0]
66
140
  ]);
67
- cache.set(queryCacheKey1, {
68
- promise
69
- });
141
+ const cached = cache.get(queryCacheKey);
142
+ if (cached?.promise) {
143
+ return cached.promise;
144
+ }
145
+ }
146
+ const fullPath = pathCopy.join('.');
147
+ const promise = client$1[procedureType](fullPath, ...args);
148
+ if (procedureType !== 'query') {
70
149
  return promise;
150
+ }
151
+ const queryCacheKey1 = JSON.stringify([
152
+ path,
153
+ args[0]
154
+ ]);
155
+ cache.set(queryCacheKey1, {
156
+ promise
71
157
  });
158
+ return promise;
72
159
  });
160
+ // });
73
161
  }
74
162
 
163
+ exports.experimental_createActionHook = experimental_createActionHook;
75
164
  exports.experimental_createTRPCNextAppDirClient = experimental_createTRPCNextAppDirClient;
165
+ exports.experimental_serverActionLink = experimental_serverActionLink;
@@ -1,71 +1,159 @@
1
- import { createTRPCUntypedClient, clientCallTypeToProcedureType } from '@trpc/client';
2
- import { createRecursiveProxy, createFlatProxy } from '@trpc/server/shared';
1
+ import { TRPCClientError, createTRPCUntypedClient, clientCallTypeToProcedureType } from '@trpc/client';
2
+ import { createRecursiveProxy } from '@trpc/server/shared';
3
+ import { transformResult } from '@trpc/client/shared';
4
+ import { observable } from '@trpc/server/observable';
5
+ import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
6
+ import { i as isFormData } from '../shared-59b269d5.mjs';
3
7
 
4
- function createUseProxy(client) {
5
- return createRecursiveProxy((opts)=>{
6
- const path = opts.path.join('.');
7
- return client.query(path, ...opts.args);
8
- });
8
+ // ts-prune-ignore-next
9
+ function experimental_serverActionLink() {
10
+ return (runtime)=>({ op })=>observable((observer)=>{
11
+ const context = op.context;
12
+ context._action(isFormData(op.input) ? op.input : runtime.transformer.serialize(op.input)).then((data)=>{
13
+ const transformed = transformResult(data, runtime);
14
+ if (!transformed.ok) {
15
+ observer.error(TRPCClientError.from(transformed.error, {}));
16
+ return;
17
+ }
18
+ observer.next({
19
+ context: op.context,
20
+ result: transformed.result
21
+ });
22
+ observer.complete();
23
+ }).catch((cause)=>observer.error(TRPCClientError.from(cause)));
24
+ });
9
25
  }
10
-
11
- function normalizePromiseArray(promise) {
12
- if (Array.isArray(promise)) {
13
- return Promise.all(promise);
14
- }
15
- return promise;
26
+ // ts-prune-ignore-next
27
+ function experimental_createActionHook(opts) {
28
+ const client = createTRPCUntypedClient(opts);
29
+ return function useAction(handler, useActionOpts) {
30
+ const count = useRef(0);
31
+ const [state, setState] = useState({
32
+ status: 'idle'
33
+ });
34
+ const actionOptsRef = useRef(useActionOpts);
35
+ actionOptsRef.current = useActionOpts;
36
+ useEffect(()=>{
37
+ return ()=>{
38
+ // cleanup after unmount to prevent calling hook opts after unmount
39
+ count.current = -1;
40
+ actionOptsRef.current = undefined;
41
+ };
42
+ }, []);
43
+ const mutateAsync = useCallback((input, requestOptions)=>{
44
+ const idx = ++count.current;
45
+ const context = {
46
+ ...requestOptions?.context,
47
+ _action (innerInput) {
48
+ return handler(innerInput);
49
+ }
50
+ };
51
+ setState({
52
+ status: 'loading'
53
+ });
54
+ return client.mutation('serverAction', input, {
55
+ ...requestOptions,
56
+ context
57
+ }).then(async (data)=>{
58
+ await actionOptsRef.current?.onSuccess?.(data);
59
+ if (idx !== count.current) {
60
+ return;
61
+ }
62
+ setState({
63
+ status: 'success',
64
+ data: data
65
+ });
66
+ }).catch(async (error)=>{
67
+ await actionOptsRef.current?.onError?.(error);
68
+ throw error;
69
+ }).catch((error)=>{
70
+ if (idx !== count.current) {
71
+ return;
72
+ }
73
+ setState({
74
+ status: 'error',
75
+ error: TRPCClientError.from(error, {})
76
+ });
77
+ throw error;
78
+ });
79
+ }, [
80
+ handler
81
+ ]);
82
+ const mutate = useCallback((...args)=>{
83
+ void mutateAsync(...args).catch(()=>{
84
+ // ignored
85
+ });
86
+ }, [
87
+ mutateAsync
88
+ ]);
89
+ return useMemo(()=>({
90
+ ...state,
91
+ mutate,
92
+ mutateAsync
93
+ }), [
94
+ mutate,
95
+ mutateAsync,
96
+ state
97
+ ]);
98
+ };
16
99
  }
100
+
17
101
  // ts-prune-ignore-next
18
102
  function experimental_createTRPCNextAppDirClient(opts) {
19
103
  const client = createTRPCUntypedClient(opts.config());
20
- const useProxy = createUseProxy(client);
104
+ // const useProxy = createUseProxy<TRouter>(client);
21
105
  const cache = new Map();
22
- return createFlatProxy((key)=>{
23
- if (key === 'use') {
24
- return (cb)=>{
25
- const promise = normalizePromiseArray(cb(useProxy));
26
- throw promise;
27
- // const [data, setData] = useState<unknown | unknown[]>();
28
- // useEffect(() => {
29
- // const promise = normalizePromiseArray(cb(useProxy));
30
- // void promise.then(setData).catch((err) => {
31
- // throw err;
32
- // });
33
- // // eslint-disable-next-line react-hooks/exhaustive-deps
34
- // }, []);
35
- // return data;
36
- };
37
- }
38
- return createRecursiveProxy(({ path , args })=>{
39
- const pathCopy = [
40
- key,
41
- ...path
42
- ];
43
- const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
44
- if (procedureType === 'query') {
45
- const queryCacheKey = JSON.stringify([
46
- path,
47
- args[0]
48
- ]);
49
- const cached = cache.get(queryCacheKey);
50
- if (cached?.promise) {
51
- return cached.promise;
52
- }
53
- }
54
- const fullPath = pathCopy.join('.');
55
- const promise = client[procedureType](fullPath, ...args);
56
- if (procedureType !== 'query') {
57
- return promise;
58
- }
59
- const queryCacheKey1 = JSON.stringify([
106
+ // return createFlatProxy<CreateTRPCNextAppRouter<TRouter>>((key) => {
107
+ // if (key === 'use') {
108
+ // return (
109
+ // cb: (
110
+ // t: UseProcedureRecord<TRouter>,
111
+ // ) => Promise<unknown> | Promise<unknown>[],
112
+ // ) => {
113
+ // const promise = normalizePromiseArray(cb(useProxy));
114
+ // throw promise;
115
+ // // const [data, setData] = useState<unknown | unknown[]>();
116
+ // // useEffect(() => {
117
+ // // const promise = normalizePromiseArray(cb(useProxy));
118
+ // // void promise.then(setData).catch((err) => {
119
+ // // throw err;
120
+ // // });
121
+ // // // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ // // }, []);
123
+ // // return data;
124
+ // };
125
+ // }
126
+ return createRecursiveProxy(({ path , args })=>{
127
+ // const pathCopy = [key, ...path];
128
+ const pathCopy = [
129
+ ...path
130
+ ];
131
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
132
+ if (procedureType === 'query') {
133
+ const queryCacheKey = JSON.stringify([
60
134
  path,
61
135
  args[0]
62
136
  ]);
63
- cache.set(queryCacheKey1, {
64
- promise
65
- });
137
+ const cached = cache.get(queryCacheKey);
138
+ if (cached?.promise) {
139
+ return cached.promise;
140
+ }
141
+ }
142
+ const fullPath = pathCopy.join('.');
143
+ const promise = client[procedureType](fullPath, ...args);
144
+ if (procedureType !== 'query') {
66
145
  return promise;
146
+ }
147
+ const queryCacheKey1 = JSON.stringify([
148
+ path,
149
+ args[0]
150
+ ]);
151
+ cache.set(queryCacheKey1, {
152
+ promise
67
153
  });
154
+ return promise;
68
155
  });
156
+ // });
69
157
  }
70
158
 
71
- export { experimental_createTRPCNextAppDirClient };
159
+ export { experimental_createActionHook, experimental_createTRPCNextAppDirClient, experimental_serverActionLink };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/app-dir/client.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
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
+ 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> {
12
+ mutate: (...args: MutationArgs<TDef>) => void;
13
+ mutateAsync: (...args: MutationArgs<TDef>) => Promise<Def['output']>;
14
+ }
15
+ interface UseTRPCActionSuccessResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
16
+ data: TDef['output'];
17
+ error?: never;
18
+ status: 'success';
19
+ }
20
+ interface UseTRPCActionErrorResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
21
+ data?: never;
22
+ error: TRPCClientError<TDef['errorShape']>;
23
+ status: 'error';
24
+ }
25
+ interface UseTRPCActionIdleResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
26
+ data?: never;
27
+ error?: never;
28
+ status: 'idle';
29
+ }
30
+ interface UseTRPCActionLoadingResult<TDef extends Def> extends UseTRPCActionBaseResult<TDef> {
31
+ data?: never;
32
+ error?: never;
33
+ status: 'loading';
34
+ }
35
+ export declare type UseTRPCActionResult<TDef extends Def> = UseTRPCActionSuccessResult<TDef> | UseTRPCActionErrorResult<TDef> | UseTRPCActionIdleResult<TDef> | UseTRPCActionLoadingResult<TDef>;
36
+ export declare function experimental_serverActionLink<TRouter extends AnyRouter = AnyRouter>(): TRPCLink<TRouter>;
37
+ /**
38
+ * @internal
39
+ */
40
+ export declare type inferActionResultProps<TProc extends AnyProcedure> = {
41
+ input: inferHandlerInput<TProc>[0];
42
+ output: TProc['_def']['_output_out'];
43
+ errorShape: TProc['_def']['_config']['$types']['errorShape'];
44
+ };
45
+ interface UseTRPCActionOptions<TDef extends Def> {
46
+ onSuccess?: (result: TDef['output']) => void | MaybePromise<void>;
47
+ onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
48
+ }
49
+ export declare function experimental_createActionHook<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): <TDef extends ActionHandlerDef>(handler: TRPCActionHandler<TDef>, useActionOpts?: UseTRPCActionOptions<Simplify<TDef>> | undefined) => UseTRPCActionResult<TDef>;
50
+ export {};
51
+ //# sourceMappingURL=create-action-hook.d.ts.map
@@ -0,0 +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,UAAU,GAAG;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,UAAU,EAAE,GAAG,CAAC;CACjB;AAED,aAAK,YAAY,CAAC,IAAI,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,GAC5D,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,GACnD,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC;AAE/D,UAAU,uBAAuB,CAAC,IAAI,SAAS,GAAG;IAChD,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,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;CACtE;AAED,UAAU,0BAA0B,CAAC,IAAI,SAAS,GAAG,CACnD,SAAQ,uBAAuB,CAAC,IAAI,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrB,KAAK,CAAC,EAA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CAAC;CAC9D,CAAC;AAEF,UAAU,oBAAoB,CAAC,IAAI,SAAS,GAAG;IAC7C,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"}
@@ -0,0 +1,2 @@
1
+ export declare function formDataToObject(formData: FormData): Record<string, unknown>;
2
+ //# sourceMappingURL=formDataToObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formDataToObject.d.ts","sourceRoot":"","sources":["../../src/app-dir/formDataToObject.ts"],"names":[],"mappings":"AA2BA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,2BAQlD"}
@@ -1,5 +1,24 @@
1
1
  import { CreateTRPCProxyClient } from '@trpc/client';
2
- import { AnyRouter } from '@trpc/server';
3
- import { CreateTRPCNextAppRouterOptions } from './shared';
2
+ import { AnyProcedure, AnyRootConfig, AnyRouter, MaybePromise, Simplify } from '@trpc/server';
3
+ import { TRPCResponse } from '@trpc/server/rpc';
4
+ import { ActionHandlerDef, CreateTRPCNextAppRouterOptions, inferActionDef } from './shared';
4
5
  export declare function experimental_createTRPCNextAppDirServer<TRouter extends AnyRouter>(opts: CreateTRPCNextAppRouterOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
6
+ /**
7
+ * @internal
8
+ */
9
+ export declare 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
+ }>;
5
24
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/app-dir/server.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EAGtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAG1D,wBAAgB,uCAAuC,CACrD,OAAO,SAAS,SAAS,EACzB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,kCAkB9C"}
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,oBAAY,iBAAiB,CAAC,IAAI,SAAS,gBAAgB,IAAI,CAC7D,KAAK,EAAE,IAA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