| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System.Text.Json.Serialization;
- namespace Admin.NET.Plugin.AiDOP.DataPlatform.Core;
- /// <summary>Scope resolved by the host from an authenticated source and its bound dataset.</summary>
- public sealed record IngestDatasetIdentity(
- long TenantId, long FactoryId, long SourceId, long DatasetId, string SourceCode, string DatasetKey);
- public sealed record IngestLimits(int MaxBodyBytes, int MaxRecords, int MaxJsonDepth);
- public sealed record SchemaStamp(string Version, string Sha256);
- public sealed record SchemaDefinition(SchemaStamp Stamp, string Json);
- public sealed record IngestVersionSnapshot(
- SchemaStamp SourceSchema,
- SchemaStamp RawSchema,
- SchemaStamp HandoffSchema,
- string MappingVersion,
- string RuleVersion,
- string ConfigVersion)
- {
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? FieldMapJson { get; init; }
- }
- public sealed record IngestContract(
- string DatasetKey,
- string ObjectCode,
- SchemaDefinition SourceSchema,
- SchemaDefinition RawSchema,
- SchemaDefinition HandoffSchema,
- string MappingVersion,
- string RuleVersion,
- string ConfigVersion)
- {
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? FieldMapJson { get; init; }
- public IngestVersionSnapshot Snapshot() => new(
- SourceSchema.Stamp, RawSchema.Stamp, HandoffSchema.Stamp, MappingVersion, RuleVersion, ConfigVersion) { FieldMapJson = FieldMapJson };
- }
- public sealed record IngestSourceWindow(DateTimeOffset? From, DateTimeOffset? To, string? Watermark);
- public sealed record RawIngestBatch(
- Guid BatchId,
- IngestDatasetIdentity Identity,
- DateTimeOffset ReceivedAt,
- IngestVersionSnapshot Versions,
- int AcceptedRowCount,
- ReadOnlyMemory<byte> Payload,
- string PayloadSha256,
- IngestSourceWindow? SourceWindow);
- public sealed record RawIngestEvent(
- Guid RawEventId,
- Guid BatchId,
- int RecordOrdinal,
- string ObjectCode,
- string SourcePosition,
- int PayloadOffset,
- int PayloadLength,
- string PayloadSha256,
- string? SourceBusinessKey,
- string? SourceUpdatedAt);
- public sealed record PreparedIngestBatch(RawIngestBatch Batch, IReadOnlyList<RawIngestEvent> Events);
- public enum IngestContractError
- {
- DatasetUnavailable,
- UnknownSchema,
- BodyTooLarge,
- InvalidJson,
- JsonTooDeep,
- InvalidEnvelope,
- TooManyRecords
- }
- public sealed class IngestContractException(IngestContractError code) : Exception(code.ToString())
- {
- public IngestContractError Code { get; } = code;
- }
- public interface ISchemaRegistry
- {
- /// <summary>Returns the exact archived contract. Unknown versions never resolve to the active version.</summary>
- IngestContract? Find(string datasetKey, string sourceSchemaVersion);
- }
- public interface IRawStorage
- {
- /// <summary>Appends one batch and its events in the caller's transaction. The caller commits it with the receive task.</summary>
- Task AppendAsync(PreparedIngestBatch prepared, CancellationToken cancellationToken);
- /// <summary>Returns a batch only within the trusted scope supplied by the caller.</summary>
- Task<PreparedIngestBatch?> FindAsync(
- IngestDatasetIdentity authorizedScope, Guid batchId, CancellationToken cancellationToken);
- }
|