feat(transport): export site/instance selection end-to-end via CLI + ManagementActor (M8 B4)

This commit is contained in:
Joseph Doherty
2026-06-18 06:14:39 -04:00
parent d7dae24355
commit bdbf5cdab0
16 changed files with 450 additions and 12 deletions
@@ -73,6 +73,10 @@ public sealed class BundleExporter : IBundleExporter
var resolved = await _resolver.ResolveAsync(selection, cancellationToken).ConfigureAwait(false);
// 2. Convert to the wire-shaped DTO (strips EF identity, refs-by-name).
// M8 (B4): the resolver's site/dataConnection/instance closure is wired
// through via object-initializer — without this the aggregate would
// carry the empty defaults and the bundle would ship empty site/
// instance arrays even when those were selected (review item I3).
var aggregate = new EntityAggregate(
TemplateFolders: resolved.TemplateFolders,
Templates: resolved.Templates,
@@ -83,7 +87,12 @@ public sealed class BundleExporter : IBundleExporter
NotificationLists: resolved.NotificationLists,
SmtpConfigurations: resolved.SmtpConfigs,
// Inbound API keys are not transported between environments (re-arch C4).
ApiMethods: resolved.ApiMethods);
ApiMethods: resolved.ApiMethods)
{
Sites = resolved.Sites,
DataConnections = resolved.DataConnections,
Instances = resolved.Instances,
};
var contentDto = _entitySerializer.ToBundleContent(aggregate);
// 3. Per-category summary counts — used for fast humanly-readable preview at import.
@@ -196,6 +196,23 @@ public sealed class DependencyResolver
// in `sites` after closure expansion, so ordering + dependsOn edges resolve names.
var siteIdentifierById = sites.Values.ToDictionary(s => s.Id, s => s.SiteIdentifier);
// I1: when an instance/data-connection is selected directly with
// IncludeDependencies=false, its owning site is not packed (so it never
// lands in `sites`) and the manifest dep-edge would degrade to the raw id
// (Site:<rawId>) via SiteIdentifierOf's fallback. Resolve the identifier
// for any referenced-but-unpacked owning site so the manifest reads
// Site:<identifier> regardless of the deps flag — readability only, the
// site row itself stays out of the bundle.
var referencedSiteIds = instances.Values.Select(i => i.SiteId)
.Concat(dataConnections.Values.Select(c => c.SiteId))
.Distinct()
.Where(id => !siteIdentifierById.ContainsKey(id));
foreach (var siteId in referencedSiteIds)
{
var site = await _siteRepository.GetSiteByIdAsync(siteId, ct).ConfigureAwait(false);
if (site is not null) siteIdentifierById[site.Id] = site.SiteIdentifier;
}
var orderedSites = sites.Values
.OrderBy(s => s.SiteIdentifier, StringComparer.Ordinal)
.ToList();