@@ -62,12 +62,20 @@ export const SnapshotRestoreRequestSchema = z.object({
6262} ) ;
6363export type SnapshotRestoreRequest = z . infer < typeof SnapshotRestoreRequestSchema > ;
6464
65- export const SnapshotCallbackPayloadSchema = z . object ( {
66- snapshot_id : z . string ( ) ,
67- instance_id : z . string ( ) ,
68- status : z . enum ( [ "completed" , "failed" ] ) ,
69- error : z . string ( ) . optional ( ) ,
70- metadata : z . record ( z . string ( ) ) . optional ( ) ,
71- duration_ms : z . number ( ) . optional ( ) ,
72- } ) ;
65+ export const SnapshotCallbackPayloadSchema = z . discriminatedUnion ( "status" , [
66+ z . object ( {
67+ status : z . literal ( "completed" ) ,
68+ snapshot_id : z . string ( ) ,
69+ instance_id : z . string ( ) ,
70+ metadata : z . record ( z . string ( ) ) . optional ( ) ,
71+ duration_ms : z . number ( ) . optional ( ) ,
72+ } ) ,
73+ z . object ( {
74+ status : z . literal ( "failed" ) ,
75+ instance_id : z . string ( ) ,
76+ error : z . string ( ) . optional ( ) ,
77+ metadata : z . record ( z . string ( ) ) . optional ( ) ,
78+ duration_ms : z . number ( ) . optional ( ) ,
79+ } ) ,
80+ ] ) ;
7381export type SnapshotCallbackPayload = z . infer < typeof SnapshotCallbackPayloadSchema > ;
0 commit comments