Introduce Beam.Fluent and Beam.Models projects

Added new Beam.Fluent and Beam.Models projects with staged download builder and data context models. Refactored and moved model classes from Beam.Temporary.Cli to Beam.Models. Added new data providers and extended DataBindings in Beam.Dynamic. Renamed Beam.Puppeteer to Beam.Playwright and updated related classes. Updated project references and package versions. Removed obsolete and unused files from Beam.Temporary.Cli.
This commit is contained in:
qwsdcvghyu89
2025-09-18 18:32:25 +10:00
parent 849bdcd089
commit a7d148a96f
72 changed files with 2100 additions and 721 deletions
+41
View File
@@ -0,0 +1,41 @@
using aeqw89.DataKeys;
using Beam;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using Beam.Models;
namespace Beam.Fluent {
/// <summary>
/// Typesafe, staged builder that prevents callers from forgetting the mandatory steps
/// (source → link selection → transformer) and surfaces operational knobs as firstclass
/// methods instead of magic parameters.
/// </summary>
public static partial class DownloadBuilder<RawType, OutType> {
/* ──────────────────────────── Entry points ─────────────────────────── */
public static ILinkStage FromResource(DataKey<ResourceDictionary> dict, string kind, BeamDataContext beamDataDictionary)
=> Create(dict, beamDataDictionary, kind);
public static IAlternativeLinkStage FromScratch()
=> new LinkStage(null!, null!, null!, new());
private static ILinkStage Create(DataKey<ResourceDictionary> resourceDict, BeamDataContext data, string kind) {
var (source, initial) = Resolve(resourceDict, kind, data);
var ctxBuilder = new DownloadContextBuilder<RawType>().WithLinks(Array.Empty<SourceLink>()); // placeholder, filled later.
return new LinkStage(source, initial, data, ctxBuilder);
}
private static (WebResource Source, State Initial) Resolve(DataKey<ResourceDictionary> resourceDict, string kind, BeamDataContext data) {
if (!data.ResourceDictionaries.TryGetValue(resourceDict, out var dict))
throw new KeyNotFoundException($"Novel '{resourceDict}' not found in BeamDataDictionary.");
if (!dict.Resources.TryGetValue(kind, out var sourceKey))
throw new KeyNotFoundException($"Novel kind '{kind}' not found in '{resourceDict}'");
if (!data.Resources.TryGetValue(sourceKey, out var source))
throw new KeyNotFoundException($"Novel source '{sourceKey}' was not found");
if (!data.InitialStates.TryGetValue(sourceKey.To<ImmutableState>(), out var istate))
throw new KeyNotFoundException($"Immutable state for kind '{kind}' not found");
return (source, istate);
}
}
}