using StellaOps.Concelier.Connector.Common;
namespace StellaOps.Concelier.Connector.Common.State;
///
/// Describes a raw upstream document that should be persisted for a connector during seeding.
///
public sealed record SourceStateSeedDocument
{
///
/// Absolute source URI. Must match the connector's upstream document identifier.
///
public string Uri { get; init; } = string.Empty;
///
/// Raw document payload. Required when creating or replacing a document.
///
public byte[] Content { get; init; } = Array.Empty();
///
/// Optional explicit document identifier. When provided it overrides auto-generated IDs.
///
public Guid? DocumentId { get; init; }
///
/// MIME type for the document payload.
///
public string? ContentType { get; init; }
///
/// Status assigned to the document. Defaults to .
///
public string Status { get; init; } = DocumentStatuses.PendingParse;
///
/// Optional HTTP-style headers persisted alongside the raw document.
///
public IReadOnlyDictionary? Headers { get; init; }
///
/// Source metadata (connector specific) persisted alongside the raw document.
///
public IReadOnlyDictionary? Metadata { get; init; }
///
/// Upstream ETag value, if available.
///
public string? Etag { get; init; }
///
/// Upstream last-modified timestamp, if available.
///
public DateTimeOffset? LastModified { get; init; }
///
/// Optional document expiration. When set a TTL will purge the raw payload after the configured retention.
///
public DateTimeOffset? ExpiresAt { get; init; }
///
/// Fetch timestamp stamped onto the document. Defaults to the seed completion timestamp.
///
public DateTimeOffset? FetchedAt { get; init; }
///
/// When true, the document ID will be appended to the connector cursor's pendingDocuments set.
///
public bool AddToPendingDocuments { get; init; } = true;
///
/// When true, the document ID will be appended to the connector cursor's pendingMappings set.
///
public bool AddToPendingMappings { get; init; }
///
/// Optional identifiers that should be recorded on the cursor to avoid duplicate ingestion.
///
public IReadOnlyCollection? KnownIdentifiers { get; init; }
}
///
/// Cursor updates that should accompany seeded documents.
///
public sealed record SourceStateSeedCursor
{
///
/// Optional pendingDocuments additions expressed as document IDs.
///
public IReadOnlyCollection? PendingDocuments { get; init; }
///
/// Optional pendingMappings additions expressed as document IDs.
///
public IReadOnlyCollection? PendingMappings { get; init; }
///
/// Optional known advisory identifiers to merge with the cursor.
///
public IReadOnlyCollection? KnownAdvisories { get; init; }
///
/// Upstream window watermark tracked by connectors that rely on last-modified cursors.
///
public DateTimeOffset? LastModifiedCursor { get; init; }
///
/// Optional fetch timestamp used by connectors that track the last polling instant.
///
public DateTimeOffset? LastFetchAt { get; init; }
///
/// Additional cursor fields (string values) to merge.
///
public IReadOnlyDictionary? Additional { get; init; }
}
///
/// Seeding specification describing the source, documents, and cursor edits to apply.
///
public sealed record SourceStateSeedSpecification
{
///
/// Source/connector name (e.g. vndr.msrc).
///
public string Source { get; init; } = string.Empty;
///
/// Documents that should be inserted or replaced before the cursor update.
///
public IReadOnlyList Documents { get; init; } = Array.Empty();
///
/// Cursor adjustments applied after documents are persisted.
///
public SourceStateSeedCursor? Cursor { get; init; }
///
/// Connector-level known advisory identifiers to merge into the cursor.
///
public IReadOnlyCollection? KnownAdvisories { get; init; }
///
/// Optional completion timestamp. Defaults to the processor's time provider.
///
public DateTimeOffset? CompletedAt { get; init; }
}
///
/// Result returned after seeding completes.
///
public sealed record SourceStateSeedResult(
int DocumentsProcessed,
int PendingDocumentsAdded,
int PendingMappingsAdded,
IReadOnlyCollection DocumentIds,
IReadOnlyCollection PendingDocumentIds,
IReadOnlyCollection PendingMappingIds,
IReadOnlyCollection KnownAdvisoriesAdded,
DateTimeOffset CompletedAt);