|
| 1 | +using System.Text.Json.Serialization; |
| 2 | + |
| 3 | +namespace AdaptiveRemote.Contracts; |
| 4 | + |
| 5 | +// --------------------------------------------------------------------------- |
| 6 | +// Compiled layout element DTOs |
| 7 | +// Used in CompiledLayout.Elements. Deserialized directly by the client application. |
| 8 | +// Contains only behavioral properties — grid positions and CSS overrides have been |
| 9 | +// compiled into CssDefinitions and are not needed by the client. |
| 10 | +// --------------------------------------------------------------------------- |
| 11 | + |
| 12 | +// "$type" avoids conflict with the behavioral Type property on CommandDefinitionDto. |
| 13 | +[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")] |
| 14 | +[JsonDerivedType(typeof(CommandDefinitionDto), "command")] |
| 15 | +[JsonDerivedType(typeof(LayoutGroupDefinitionDto), "group")] |
| 16 | +public abstract record LayoutElementDto(string CssId); |
| 17 | + |
| 18 | +// Maps to AdaptiveRemote.App.Models.Command at layout-apply time (client epic). |
| 19 | +// Type carries the CommandType discriminator so the client knows which runtime type to instantiate. |
| 20 | +// No subtype hierarchy is used — all behavioral properties are flat; type-specific execution |
| 21 | +// parameters are resolved by the client from its own configuration (see CommandType above). |
| 22 | +public record CommandDefinitionDto( |
| 23 | + CommandType Type, |
| 24 | + string Name, |
| 25 | + string Label, |
| 26 | + string? Glyph, |
| 27 | + string SpeakPhrase, |
| 28 | + string? Reverse, |
| 29 | + string CssId |
| 30 | +) : LayoutElementDto(CssId), ICommandProperties; |
| 31 | + |
| 32 | +// Maps to AdaptiveRemote.App.Models.LayoutGroup at layout-apply time (client epic). |
| 33 | +public record LayoutGroupDefinitionDto( |
| 34 | + string CssId, |
| 35 | + IReadOnlyList<LayoutElementDto> Children |
| 36 | +) : LayoutElementDto(CssId); |
| 37 | + |
| 38 | +// --------------------------------------------------------------------------- |
| 39 | +// Client-consumable format produced by LayoutCompilerService. |
| 40 | +// Deserialized directly by the client application — no intermediate parsing model needed. |
| 41 | +// The client maps Elements → runtime Command objects at layout-apply time (client epic). |
| 42 | +// --------------------------------------------------------------------------- |
| 43 | + |
| 44 | +public record CompiledLayout( |
| 45 | + Guid Id, |
| 46 | + Guid RawLayoutId, |
| 47 | + string UserId, |
| 48 | + bool IsActive, |
| 49 | + int Version, |
| 50 | + IReadOnlyList<LayoutElementDto> Elements, |
| 51 | + string CssDefinitions, // global CSS for the layout grid |
| 52 | + DateTimeOffset CompiledAt |
| 53 | +); |
0 commit comments