Merge branch 'review/wp2' into review/integration

This commit is contained in:
Joseph Doherty
2026-12-03 10:41:17 -05:00
46 changed files with 5166 additions and 284 deletions
@@ -30,8 +30,15 @@ public interface IBundleImporter
/// </summary>
/// <param name="sessionId">Session id returned by <see cref="LoadAsync"/>.</param>
/// <param name="ct">Cancellation token.</param>
/// <param name="nameMap">
/// TRN-3: optional operator site/connection mapping. When supplied, every site-scoped
/// preview lookup (connection and instance diffs, the required-mapping auto-match and
/// the unresolved-connection blocker) runs against the MAPPED target site and connection
/// names instead of the source identity, so a preview reflects what the apply with the
/// same map will do. <c>null</c> (the default) keeps the identity auto-match.
/// </param>
/// <returns>A task that resolves to a per-artifact import preview with conflict details.</returns>
Task<ImportPreview> PreviewAsync(Guid sessionId, CancellationToken ct = default);
Task<ImportPreview> PreviewAsync(Guid sessionId, CancellationToken ct = default, BundleNameMap? nameMap = null);
/// <summary>
/// Applies the chosen conflict resolutions and commits the import transaction.
@@ -3,7 +3,12 @@ namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
public record ListDataConnectionsCommand(int? SiteId = null);
public record GetDataConnectionCommand(int DataConnectionId);
public record CreateDataConnectionCommand(int SiteId, string Name, string Protocol, string? PrimaryConfiguration, string? BackupConfiguration = null, int FailoverRetryCount = 3);
public record UpdateDataConnectionCommand(int DataConnectionId, string Name, string Protocol, string? PrimaryConfiguration, string? BackupConfiguration = null, int FailoverRetryCount = 3);
/// <summary>
/// Partial update (CLI-2): every field except the id is preserve-if-null — <c>null</c> leaves the
/// stored value unchanged; an empty string clears an optional field. Older clients that always
/// send every field keep deserializing unchanged (the fields only became nullable).
/// </summary>
public record UpdateDataConnectionCommand(int DataConnectionId, string? Name, string? Protocol, string? PrimaryConfiguration, string? BackupConfiguration = null, int? FailoverRetryCount = null);
public record DeleteDataConnectionCommand(int DataConnectionId);
/// <summary>
@@ -4,8 +4,13 @@ public record ListApiMethodsCommand;
public record GetApiMethodCommand(int ApiMethodId);
/// <param name="TraceAllCalls">Flow Debugger (design 2026-09-05 §5.2): trace every production call to this method. Additive; defaults to off.</param>
public record CreateApiMethodCommand(string Name, string Script, int TimeoutSeconds, string? ParameterDefinitions, string? ReturnDefinition, bool TraceAllCalls = false);
/// <summary>
/// Partial update (CLI-2): every field except the id is preserve-if-null — <c>null</c> leaves the
/// stored value unchanged; an empty string clears an optional field. Older clients that always
/// send every field keep deserializing unchanged (the fields only became nullable).
/// </summary>
/// <param name="TraceAllCalls">Flow Debugger (design 2026-09-05 §5.2): <c>null</c> leaves the stored value unchanged so an older CLI never resets it.</param>
public record UpdateApiMethodCommand(int ApiMethodId, string Script, int TimeoutSeconds, string? ParameterDefinitions, string? ReturnDefinition, bool? TraceAllCalls = null);
public record UpdateApiMethodCommand(int ApiMethodId, string? Script, int? TimeoutSeconds, string? ParameterDefinitions, string? ReturnDefinition, bool? TraceAllCalls = null);
public record DeleteApiMethodCommand(int ApiMethodId);
/// <summary>
/// Compiles the method's stored script on the receiving central node and returns the
@@ -3,7 +3,12 @@ namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
public record ListSitesCommand;
public record GetSiteCommand(int SiteId);
public record CreateSiteCommand(string Name, string SiteIdentifier, string? Description, string? NodeAAddress = null, string? NodeBAddress = null, string? GrpcNodeAAddress = null, string? GrpcNodeBAddress = null);
public record UpdateSiteCommand(int SiteId, string Name, string? Description, string? NodeAAddress = null, string? NodeBAddress = null, string? GrpcNodeAAddress = null, string? GrpcNodeBAddress = null);
/// <summary>
/// Partial update (CLI-2): every field except the id is preserve-if-null — <c>null</c> leaves the
/// stored value unchanged; an empty string clears an optional field. Older clients that always
/// send every field keep deserializing unchanged (the fields only became nullable).
/// </summary>
public record UpdateSiteCommand(int SiteId, string? Name, string? Description, string? NodeAAddress = null, string? NodeBAddress = null, string? GrpcNodeAAddress = null, string? GrpcNodeBAddress = null);
public record DeleteSiteCommand(int SiteId);
public record ListAreasCommand(int SiteId);
public record CreateAreaCommand(int SiteId, string Name, int? ParentAreaId);
@@ -7,3 +7,25 @@ public sealed record ImportResolution(
string Name,
ResolutionAction Action,
string? RenameTo);
/// <summary>
/// TRN-9: which preview entity types a <see cref="ResolutionAction.Rename"/> resolution
/// is meaningful for. A Site, a site-scoped DataConnection, an SMTP configuration and
/// an SMS configuration have no renameable identity: a renamed site/connection was
/// silently treated as Skip, and a renamed SMTP/SMS row mangled the Host / AccountSid
/// into a junk second row that delivery (lowest-id wins) never used. The importer
/// rejects Rename for these types, the Central UI does not offer it, and the CLI's
/// <c>--conflict-policy rename</c> falls back to Skip for them with a warning.
/// </summary>
public static class ImportRenameSupport
{
private static readonly HashSet<string> Unsupported = new(StringComparer.Ordinal)
{
"Site", "DataConnection", "SmtpConfiguration", "SmsConfiguration",
};
/// <summary>True when a Rename resolution is supported for <paramref name="entityType"/>.</summary>
/// <param name="entityType">The preview item / resolution entity type.</param>
/// <returns><c>false</c> for Site, DataConnection, SmtpConfiguration and SmsConfiguration.</returns>
public static bool IsSupported(string entityType) => !Unsupported.Contains(entityType);
}