namespace ScadaLink.Commons.Messages.Notification;
///
/// Site -> Central: submit a notification for central delivery.
/// Fire-and-forget with ack; the site retries until a is received.
///
///
/// The originating script execution's ExecutionId (Audit Log #23). Stamped at
/// Notify.Send time and carried, inside the serialized payload, through the site
/// store-and-forward buffer so the central dispatcher can echo it onto the
/// NotifyDeliver audit rows. Additive trailing member — null for messages built
/// before the field existed, or for notifications raised outside a script execution.
///
///
/// The originating routed script execution's ParentExecutionId (Audit Log #23).
/// Stamped at Notify.Send time and carried, inside the serialized payload, through
/// the site store-and-forward buffer so the central dispatcher can echo it onto the
/// NotifyDeliver audit rows. Additive trailing member — null for messages built
/// before the field existed, or for non-routed runs.
///
///
/// The cluster node on which the notification was emitted — `node-a` / `node-b` for site
/// submissions, `central-a` / `central-b` for central-originated rows. Stamped by the
/// emitting node from INodeIdentityProvider and carried, inside the serialized
/// payload, through the site store-and-forward buffer so the central dispatcher can
/// persist it on the Notifications row and echo it onto the NotifyDeliver
/// audit rows. Additive trailing member — null for messages built before the field
/// existed.
///
public record NotificationSubmit(
string NotificationId,
string ListName,
string Subject,
string Body,
string SourceSiteId,
string? SourceInstanceId,
string? SourceScript,
DateTimeOffset SiteEnqueuedAt,
Guid? OriginExecutionId = null,
Guid? OriginParentExecutionId = null,
string? SourceNode = null);
///
/// Central -> Site: ack sent after the notification row is persisted.
/// Idempotent — safe to re-send for the same .
///
public record NotificationSubmitAck(
string NotificationId,
bool Accepted,
string? Error);
///
/// Site -> Central: query the central delivery status for a .
///
public record NotificationStatusQuery(
string CorrelationId,
string NotificationId);
///
/// Central -> Site: response carrying the current delivery status for a queried notification.
///
public record NotificationStatusResponse(
string CorrelationId,
bool Found,
string Status,
int RetryCount,
string? LastError,
DateTimeOffset? DeliveredAt);
///
/// Notification Outbox: the delivery status of a notification, as returned to a
/// script by Notify.Status(id).
///
/// is either a central status (Pending, Retrying,
/// Delivered, Parked, Discarded), the site-local Forwarding
/// state (the notification is still buffered at the site and has not yet been
/// forwarded/acked), or Unknown (no central row and not buffered locally).
///
public record NotificationDeliveryStatus(
string Status,
int RetryCount,
string? LastError,
DateTimeOffset? DeliveredAt);