@@ -620,33 +620,44 @@ const integrationConfigurationRemovedWebhookEventSchema =
620
620
export type DeploymentIntegrationActionStartEvent = z . infer <
621
621
typeof deploymentIntegrationActionStartEventSchema
622
622
> ;
623
+
624
+ const deploymentWebhookPayloadEventSchema = z . object ( {
625
+ user : z
626
+ . object ( {
627
+ id : z . string ( ) ,
628
+ } )
629
+ . passthrough ( ) ,
630
+ team : z
631
+ . object ( {
632
+ id : z . string ( ) ,
633
+ } )
634
+ . passthrough ( ) ,
635
+ installationIds : z . string ( ) . array ( ) . optional ( ) ,
636
+ deployment : z
637
+ . object ( {
638
+ id : z . string ( ) ,
639
+ } )
640
+ . passthrough ( ) ,
641
+ } ) ;
642
+
623
643
const deploymentIntegrationActionStartEventSchema =
624
644
webhookEventBaseSchema . extend ( {
625
645
type : z . literal ( "deployment.integration.action.start" ) ,
626
- payload : z . object ( {
627
- user : z
628
- . object ( {
629
- id : z . string ( ) ,
630
- } )
631
- . passthrough ( ) ,
632
- team : z
633
- . object ( {
634
- id : z . string ( ) ,
635
- } )
636
- . passthrough ( ) ,
646
+ payload : deploymentWebhookPayloadEventSchema . extend ( {
637
647
installationId : z . string ( ) ,
638
648
action : z . string ( ) ,
639
- resourceId : z . string ( ) ,
640
- deployment : z
641
- . object ( {
642
- id : z . string ( ) ,
643
- } )
644
- . passthrough ( ) ,
645
- configuration : z . object ( {
649
+ resourceId : z . string ( ) , configuration : z . object ( {
646
650
id : z . string ( ) ,
647
651
} ) ,
648
- } ) ,
652
+ } )
653
+ } ) ;
654
+
655
+ const deploymentEvent = < T extends string > ( eventType : T ) => {
656
+ return webhookEventBaseSchema . extend ( {
657
+ type : z . literal ( eventType ) ,
658
+ payload : deploymentWebhookPayloadEventSchema ,
649
659
} ) ;
660
+ }
650
661
651
662
export type WebhookEvent = z . infer < typeof webhookEventSchema > ;
652
663
export const webhookEventSchema = z . discriminatedUnion ( "type" , [
@@ -655,6 +666,13 @@ export const webhookEventSchema = z.discriminatedUnion("type", [
655
666
invoiceNotPaidWebhookEventSchema ,
656
667
integrationConfigurationRemovedWebhookEventSchema ,
657
668
deploymentIntegrationActionStartEventSchema ,
669
+ deploymentEvent ( "deployment.created" ) ,
670
+ deploymentEvent ( "deployment.ready" ) ,
671
+ deploymentEvent ( "deployment.promoted" ) ,
672
+ deploymentEvent ( "deployment.succeeded" ) ,
673
+ deploymentEvent ( "deployment.error" ) ,
674
+ deploymentEvent ( "deployment.cancelled" ) ,
675
+ deploymentEvent ( "deployment.check-rerequested" ) ,
658
676
] ) ;
659
677
660
678
export type UnknownWebhookEvent = z . infer < typeof unknownWebhookEventSchema > ;
0 commit comments