wip
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Application Port: INotificationGateway
|
||||
*
|
||||
* Defines the contract for sending notifications through external channels.
|
||||
* Implementations (adapters) handle the actual delivery mechanism.
|
||||
*/
|
||||
|
||||
import type { Notification } from '../../domain/entities/Notification';
|
||||
import type { NotificationChannel } from '../../domain/value-objects/NotificationChannel';
|
||||
|
||||
export interface NotificationDeliveryResult {
|
||||
success: boolean;
|
||||
channel: NotificationChannel;
|
||||
/** External message ID (e.g., Discord message ID, email ID) */
|
||||
externalId?: string;
|
||||
/** Error message if delivery failed */
|
||||
error?: string;
|
||||
/** Timestamp of delivery attempt */
|
||||
attemptedAt: Date;
|
||||
}
|
||||
|
||||
export interface INotificationGateway {
|
||||
/**
|
||||
* Send a notification through this gateway's channel
|
||||
*/
|
||||
send(notification: Notification): Promise<NotificationDeliveryResult>;
|
||||
|
||||
/**
|
||||
* Check if this gateway supports the given channel
|
||||
*/
|
||||
supportsChannel(channel: NotificationChannel): boolean;
|
||||
|
||||
/**
|
||||
* Check if the gateway is configured and ready to send
|
||||
*/
|
||||
isConfigured(): boolean;
|
||||
|
||||
/**
|
||||
* Get the channel this gateway handles
|
||||
*/
|
||||
getChannel(): NotificationChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registry for notification gateways
|
||||
* Allows routing notifications to the appropriate gateway based on channel
|
||||
*/
|
||||
export interface INotificationGatewayRegistry {
|
||||
/**
|
||||
* Register a gateway for a channel
|
||||
*/
|
||||
register(gateway: INotificationGateway): void;
|
||||
|
||||
/**
|
||||
* Get gateway for a specific channel
|
||||
*/
|
||||
getGateway(channel: NotificationChannel): INotificationGateway | null;
|
||||
|
||||
/**
|
||||
* Get all registered gateways
|
||||
*/
|
||||
getAllGateways(): INotificationGateway[];
|
||||
|
||||
/**
|
||||
* Send notification through appropriate gateway
|
||||
*/
|
||||
send(notification: Notification): Promise<NotificationDeliveryResult>;
|
||||
}
|
||||
Reference in New Issue
Block a user