@@ -88,3 +88,50 @@ model StreamEvent {
8888 @@index ([createdAt ] )
8989 @@index ([streamId , timestamp ] )
9090}
91+
92+ // WebhookSubscription model - Outgoing webhook configuration for external integrations (Issue #1189)
93+ model WebhookSubscription {
94+ id String @id @default (uuid () )
95+ userAddress String // Stellar public key of the owner
96+ targetUrl String // Destination webhook URL (must be HTTPS)
97+ secretKey String // Secret used for HMAC-SHA256 signature
98+ eventTypes String [] // Array of subscribed event types (e.g., ["STREAM_CREATED", "TOKENS_WITHDRAWN"])
99+ isActive Boolean @default (true )
100+ createdAt DateTime @default (now () )
101+ updatedAt DateTime @updatedAt
102+
103+ deliveries WebhookDelivery []
104+
105+ @@index ([userAddress ] )
106+ @@index ([isActive ] )
107+ }
108+
109+ // WebhookDelivery model - Webhook delivery history and retry tracking (Issue #1189)
110+ model WebhookDelivery {
111+ id String @id @default (uuid () )
112+ subscriptionId String
113+ eventType String
114+ payload String // JSON
115+ responseStatus Int ?
116+ attempts Int @default (0 )
117+ deliveredAt DateTime ?
118+ error String ?
119+ createdAt DateTime @default (now () )
120+
121+ subscription WebhookSubscription @relation (fields : [subscriptionId ] , references : [id ] , onDelete : Cascade )
122+
123+ @@index ([subscriptionId ] )
124+ @@index ([createdAt ] )
125+ }
126+
127+ // AlertHistory model - Tracks sent alerts to prevent duplicate notifications (Issue #1190)
128+ model AlertHistory {
129+ id String @id @default (uuid () )
130+ streamId BigInt
131+ alertType String // "WARNING_48H" or "CRITICAL_24H"
132+ sentAt DateTime @default (now () )
133+
134+ @@unique ([streamId , alertType , sentAt ] )
135+ @@index ([streamId ] )
136+ @@index ([sentAt ] )
137+ }
0 commit comments