@@ -17,8 +17,8 @@ type ResendErrorResponse = {
1717} ;
1818
1919type SendEmailResult =
20- | { success : true ; id : string }
21- | { success : false ; error : string } ;
20+ | { success : true ; data : { id : string } }
21+ | { success : false ; error : { message : string } } ;
2222
2323export type SendEmailCoreInput = {
2424 emailFrom ?: string ;
@@ -51,8 +51,10 @@ async function stepHandler(
5151 if ( ! apiKey ) {
5252 return {
5353 success : false ,
54- error :
55- "RESEND_API_KEY is not configured. Please add it in Project Integrations." ,
54+ error : {
55+ message :
56+ "RESEND_API_KEY is not configured. Please add it in Project Integrations." ,
57+ } ,
5658 } ;
5759 }
5860
@@ -61,8 +63,10 @@ async function stepHandler(
6163 if ( ! senderEmail ) {
6264 return {
6365 success : false ,
64- error :
65- "No sender is configured. Please add it in the action or in Project Integrations." ,
66+ error : {
67+ message :
68+ "No sender is configured. Please add it in the action or in Project Integrations." ,
69+ } ,
6670 } ;
6771 }
6872
@@ -95,17 +99,20 @@ async function stepHandler(
9599 const errorData = ( await response . json ( ) ) as ResendErrorResponse ;
96100 return {
97101 success : false ,
98- error : errorData . message || `HTTP ${ response . status } : Failed to send email` ,
102+ error : {
103+ message :
104+ errorData . message || `HTTP ${ response . status } : Failed to send email` ,
105+ } ,
99106 } ;
100107 }
101108
102109 const data = ( await response . json ( ) ) as ResendEmailResponse ;
103- return { success : true , id : data . id } ;
110+ return { success : true , data : { id : data . id } } ;
104111 } catch ( error ) {
105- const message = error instanceof Error ? error . message : String ( error ) ;
112+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
106113 return {
107114 success : false ,
108- error : `Failed to send email: ${ message } ` ,
115+ error : { message : `Failed to send email: ${ errorMessage } ` } ,
109116 } ;
110117 }
111118}
0 commit comments