@@ -48,6 +48,18 @@ const WhatsAppAckReactionSchema = z
4848 . strict ( )
4949 . optional ( ) ;
5050
51+ function stripDeprecatedWhatsAppNoopKeys ( value : unknown ) : unknown {
52+ if ( ! value || typeof value !== "object" || Array . isArray ( value ) ) {
53+ return value ;
54+ }
55+ if ( ! Object . hasOwn ( value , "exposeErrorText" ) ) {
56+ return value ;
57+ }
58+ const next = { ...( value as Record < string , unknown > ) } ;
59+ delete next . exposeErrorText ;
60+ return next ;
61+ }
62+
5163function buildWhatsAppCommonShape ( params : { useDefaults : boolean } ) {
5264 return {
5365 enabled : z . boolean ( ) . optional ( ) ,
@@ -57,7 +69,6 @@ function buildWhatsAppCommonShape(params: { useDefaults: boolean }) {
5769 sendReadReceipts : z . boolean ( ) . optional ( ) ,
5870 messagePrefix : z . string ( ) . optional ( ) ,
5971 responsePrefix : z . string ( ) . optional ( ) ,
60- exposeErrorText : z . boolean ( ) . optional ( ) ,
6172 dmPolicy : params . useDefaults
6273 ? DmPolicySchema . optional ( ) . default ( "pairing" )
6374 : DmPolicySchema . optional ( ) ,
@@ -131,7 +142,7 @@ function enforceAllowlistDmPolicyAllowFrom(params: {
131142 } ) ;
132143}
133144
134- export const WhatsAppAccountSchema = z
145+ const WhatsAppAccountObjectSchema = z
135146 . object ( {
136147 ...buildWhatsAppCommonShape ( { useDefaults : false } ) ,
137148 name : z . string ( ) . optional ( ) ,
@@ -142,7 +153,12 @@ export const WhatsAppAccountSchema = z
142153 } )
143154 . strict ( ) ;
144155
145- export const WhatsAppConfigSchema = z
156+ export const WhatsAppAccountSchema = z . preprocess (
157+ stripDeprecatedWhatsAppNoopKeys ,
158+ WhatsAppAccountObjectSchema ,
159+ ) ;
160+
161+ const WhatsAppConfigObjectSchema = z
146162 . object ( {
147163 ...buildWhatsAppCommonShape ( { useDefaults : true } ) ,
148164 accounts : z . record ( z . string ( ) , WhatsAppAccountSchema . optional ( ) ) . optional ( ) ,
@@ -207,3 +223,8 @@ export const WhatsAppConfigSchema = z
207223 } ) ;
208224 }
209225 } ) ;
226+
227+ export const WhatsAppConfigSchema = z . preprocess (
228+ stripDeprecatedWhatsAppNoopKeys ,
229+ WhatsAppConfigObjectSchema ,
230+ ) ;
0 commit comments