rename to core
This commit is contained in:
68
core/notifications/application/ports/INotificationGateway.ts
Normal file
68
core/notifications/application/ports/INotificationGateway.ts
Normal file
@@ -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/types/NotificationTypes';
|
||||
|
||||
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>;
|
||||
}
|
||||
41
core/notifications/application/ports/INotificationService.ts
Normal file
41
core/notifications/application/ports/INotificationService.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import type { NotificationType } from '../../domain/types/NotificationTypes';
|
||||
import type { NotificationChannel } from '../../domain/types/NotificationTypes';
|
||||
|
||||
export interface NotificationData {
|
||||
raceEventId?: string;
|
||||
sessionId?: string;
|
||||
leagueId?: string;
|
||||
position?: number | 'DNF';
|
||||
positionChange?: number;
|
||||
incidents?: number;
|
||||
provisionalRatingChange?: number;
|
||||
finalRatingChange?: number;
|
||||
hadPenaltiesApplied?: boolean;
|
||||
deadline?: Date;
|
||||
protestId?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface NotificationAction {
|
||||
label: string;
|
||||
type: 'primary' | 'secondary' | 'danger';
|
||||
href?: string;
|
||||
actionId?: string;
|
||||
}
|
||||
|
||||
export interface SendNotificationCommand {
|
||||
recipientId: string;
|
||||
type: NotificationType;
|
||||
title: string;
|
||||
body: string;
|
||||
channel: NotificationChannel;
|
||||
urgency: 'silent' | 'toast' | 'modal';
|
||||
data?: NotificationData;
|
||||
actionUrl?: string;
|
||||
actions?: NotificationAction[];
|
||||
requiresResponse?: boolean;
|
||||
}
|
||||
|
||||
export interface INotificationService {
|
||||
sendNotification(command: SendNotificationCommand): Promise<void>;
|
||||
}
|
||||
Reference in New Issue
Block a user