@@ -29,19 +29,28 @@ export interface RestateWorkflowContext
29
29
30
30
// ----------- service -------------------------------------------------------
31
31
32
+ /**
33
+ * @deprecated
34
+ */
32
35
export type ArgType < T > = T extends ( ctx : any ) => any
33
36
? void
34
37
: T extends ( ctx : any , input : infer I ) => any
35
38
? I
36
39
: never ;
37
40
41
+ /**
42
+ * @deprecated
43
+ */
38
44
export type HandlerReturnType < T > = T extends (
39
45
ctx : any ,
40
46
input : any
41
47
) => Promise < infer R >
42
48
? R
43
49
: never ;
44
50
51
+ /**
52
+ * @deprecated
53
+ */
45
54
export type ServiceHandler < F , C = RestateContext > = F extends (
46
55
ctx : C
47
56
) => Promise < any >
@@ -65,6 +74,9 @@ export type ServiceDefinitionFrom<M> = M extends ServiceDefinition<
65
74
66
75
// ----------- object -------------------------------------------------------
67
76
77
+ /**
78
+ * @deprecated
79
+ */
68
80
export type ObjectSharedHandler <
69
81
F ,
70
82
SC = RestateObjectSharedContext
@@ -74,6 +86,9 @@ export type ObjectSharedHandler<
74
86
? F
75
87
: ( ctx : SC , param ?: any ) => Promise < any > ;
76
88
89
+ /**
90
+ * @deprecated
91
+ */
77
92
export type ObjectHandler < F , C = RestateObjectContext > = F extends (
78
93
ctx : C ,
79
94
param : any
@@ -104,6 +119,9 @@ export type VirtualObjectDefinitionFrom<M> = M extends VirtualObjectDefinition<
104
119
105
120
// ----------- workflow -------------------------------------------------------
106
121
122
+ /**
123
+ * @deprecated
124
+ */
107
125
export type WorkflowSharedHandler <
108
126
F ,
109
127
SC = RestateWorkflowSharedContext
@@ -113,6 +131,9 @@ export type WorkflowSharedHandler<
113
131
? F
114
132
: ( ctx : SC , param ?: any ) => Promise < any > ;
115
133
134
+ /**
135
+ * @deprecated
136
+ */
116
137
export type WorkflowHandler < F , C = RestateWorkflowContext > = F extends (
117
138
ctx : C ,
118
139
param : any
@@ -135,3 +156,28 @@ export type WorkflowDefinitionFrom<M> = M extends WorkflowDefinition<
135
156
>
136
157
? M
137
158
: 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