src/incident-fanout-types.tsTypeScript
@@ -0,0 +1,55 @@
1+
export type NotificationChannel = "sms" | "push";2+
3+
export interface IncidentRecipient {4+
id: string;5+
address: string;6+
channel: NotificationChannel;7+
}8+
9+
export interface IncidentOpened {10+
eventId: string;11+
incidentId: string;12+
openedAt: Date;13+
summary: string;14+
recipients: readonly IncidentRecipient[];15+
}16+
17+
export interface NotificationProvider {18+
send(input: {19+
address: string;20+
message: string;21+
idempotencyKey: string;22+
}): Promise<void>;23+
}24+
25+
export interface IncidentProviders {26+
forChannel(channel: NotificationChannel): NotificationProvider;27+
}28+
29+
export interface FanoutProgressStore {30+
isEventComplete(eventId: string): Promise<boolean>;31+
markEventComplete(eventId: string): Promise<void>;32+
isDeliveryComplete(33+
eventId: string,34+
recipientId: string,35+
channel: NotificationChannel,36+
): Promise<boolean>;37+
markDeliveryComplete(38+
eventId: string,39+
recipientId: string,40+
channel: NotificationChannel,41+
): Promise<void>;42+
}43+
44+
export interface IncidentAcknowledgements {45+
isAcknowledged(incidentId: string): Promise<boolean>;46+
}47+
48+
export interface EscalationScheduler {49+
schedule(input: {50+
id: string;51+
incidentId: string;52+
dueAt: Date;53+
}): Promise<void>;54+
cancel(id: string): Promise<void>;55+
}