@@ -29,19 +29,28 @@ export interface RestateWorkflowContext
2929
3030// ----------- service -------------------------------------------------------
3131
32+ /**
33+ * @deprecated
34+ */
3235export type ArgType < T > = T extends ( ctx : any ) => any
3336 ? void
3437 : T extends ( ctx : any , input : infer I ) => any
3538 ? I
3639 : never ;
3740
41+ /**
42+ * @deprecated
43+ */
3844export type HandlerReturnType < T > = T extends (
3945 ctx : any ,
4046 input : any
4147) => Promise < infer R >
4248 ? R
4349 : never ;
4450
51+ /**
52+ * @deprecated
53+ */
4554export type ServiceHandler < F , C = RestateContext > = F extends (
4655 ctx : C
4756) => Promise < any >
@@ -65,6 +74,9 @@ export type ServiceDefinitionFrom<M> = M extends ServiceDefinition<
6574
6675// ----------- object -------------------------------------------------------
6776
77+ /**
78+ * @deprecated
79+ */
6880export type ObjectSharedHandler <
6981 F ,
7082 SC = RestateObjectSharedContext
@@ -74,6 +86,9 @@ export type ObjectSharedHandler<
7486 ? F
7587 : ( ctx : SC , param ?: any ) => Promise < any > ;
7688
89+ /**
90+ * @deprecated
91+ */
7792export type ObjectHandler < F , C = RestateObjectContext > = F extends (
7893 ctx : C ,
7994 param : any
@@ -104,6 +119,9 @@ export type VirtualObjectDefinitionFrom<M> = M extends VirtualObjectDefinition<
104119
105120// ----------- workflow -------------------------------------------------------
106121
122+ /**
123+ * @deprecated
124+ */
107125export type WorkflowSharedHandler <
108126 F ,
109127 SC = RestateWorkflowSharedContext
@@ -113,6 +131,9 @@ export type WorkflowSharedHandler<
113131 ? F
114132 : ( ctx : SC , param ?: any ) => Promise < any > ;
115133
134+ /**
135+ * @deprecated
136+ */
116137export type WorkflowHandler < F , C = RestateWorkflowContext > = F extends (
117138 ctx : C ,
118139 param : any
@@ -135,3 +156,28 @@ export type WorkflowDefinitionFrom<M> = M extends WorkflowDefinition<
135156>
136157 ? M
137158 : WorkflowDefinition < string , M > ;
159+
160+ // -------- Type manipulation for clients
161+
162+ export type FlattenHandlersDefinition < M > = {
163+ [ K in keyof M ] : M [ K ] extends {
164+ handler :
165+ | ( ( ctx : any , param : any ) => Promise < any > )
166+ | ( ( ctx : any ) => Promise < any > )
167+ | ( ( ctx : any , param ?: any ) => Promise < any > ) ;
168+ }
169+ ? M [ K ] [ "handler" ]
170+ : M [ K ] extends {
171+ sharedHandler :
172+ | ( ( ctx : any , param : any ) => Promise < any > )
173+ | ( ( ctx : any ) => Promise < any > )
174+ | ( ( ctx : any , param ?: any ) => Promise < any > ) ;
175+ }
176+ ? M [ K ] [ "sharedHandler" ]
177+ : M [ K ] extends
178+ | ( ( ctx : any , param : any ) => Promise < any > )
179+ | ( ( ctx : any ) => Promise < any > )
180+ | ( ( ctx : any , param ?: any ) => Promise < any > )
181+ ? M [ K ]
182+ : never ;
183+ } ;
0 commit comments