using GB5Shared.DTO.Framework.Login; namespace CMSBLL.DataSourceProxy; // The opaque contract a ClientSideFetch-bound block's PropsJson carries under the reserved // "__dataBinding" key — see SiteDocumentBLL.ResolveDataBindingsAsync. The FE island passes these // two fields straight through to the public GetBlockData proxy endpoint; it never sees the // DataSource's EndpointTemplate, auth mode, or Vault path. public class ClientFetchDescriptorDTO { public string DataSourceCode { get; set; } = string.Empty; public string? ParamsJson { get; set; } } public interface IDataSourceProxyBLL { // Server-side merge path (BlockDataBindingMode.ServerSideRenderMerge) — called once per bound // block from SiteDocumentBLL's tree walk. Returns a flat JSON object string (the mapped // response, keyed by ResponseMappingJson's target prop names) to merge into the block's own // PropsJson, or null if this block has no binding, the binding isn't ServerSideRenderMerge, // or the fetch failed (a dynamic block failing to resolve must not fail the whole page). Task ResolveServerMergePatchAsync(int contentBlockId, LoginDTO loginDTO, CancellationToken ct); // Client-side fetch path (BlockDataBindingMode.ClientSideFetch) — returns the opaque // descriptor SiteDocumentBLL merges into the block's PropsJson under "__dataBinding", or null // if this block has no binding or isn't ClientSideFetch. Task GetClientFetchDescriptorAsync(int contentBlockId, LoginDTO loginDTO, CancellationToken ct); // Client-side fetch path (BlockDataBindingMode.ClientSideFetch) — entered from the public // GetBlockData proxy endpoint using the opaque {DataSourceCode, ParamsJson} contract the FE // island sent. Same fetch+auth+mapping+cache logic as the server-merge path; the difference // is only which caller triggers it and when the failure surfaces (here, as a thrown // exception the endpoint turns into an error response, since there's no "just omit this // block" fallback once the page has already rendered without it). Task ResolveDataAsync(string dataSourceCode, string? paramsJson, LoginDTO loginDTO, CancellationToken ct); // Entry point for the public GetBlockData proxy endpoint: resolves domainName -> Site/ // TenantId via ISiteResolverBLL (the only trusted tenant-context source for an anonymous // request — same rule GetSiteDocument follows) and rebases loginDTO onto that tenant before // calling ResolveDataAsync, so a tenant-scoped DataSource resolves under its own owner's // tenant rather than the caller's. Returns null if the domain doesn't resolve to an active // Site — the endpoint turns that into a 404, identical to GetSiteDocument's own handling. Task ResolveDataForDomainAsync(string domainName, string dataSourceCode, string? paramsJson, LoginDTO loginDTO, CancellationToken ct); }