## What & why S-15b, second of the S-15 (#16) split, on top of S-15a (#133). A beheerder edits the ACL's ZGW **default-fill** values from the beheer portal, and the next zaak is stamped with the new values — no restart. Closes #131 ### The vertical portal → BFF `GET/PUT /beheer/default-fill` (medewerker realm + `beheerder` role) → ACL `GET/PUT /default-fill` → a runtime-mutable in-memory store the ACL reads **per zaak**. - **ACL**: `IDefaultFillStore` / `InMemoryDefaultFillStore` (thread-safe, seeded from `Acl:Defaults`); `AclService` reads `fill.Current` per zaak (not cached at construction); `GET`/`PUT /default-fill` with required-field validation. - **BFF**: `IAclClient` gains `GetDefaultFillAsync`/`UpdateDefaultFillAsync`; `GET`/`PUT /beheer/default-fill` behind the `beheerder` policy. OpenAPI + generated client regenerated. - **Frontend**: a *Default-fill* editor page in the beheer app (load → edit → save, with saved/failure states) + nav between Catalogus and Default-fill. ### Scope decision → ADR-0026 Only the **three ZGW fill fields** (bronorganisatie, verantwoordelijke organisatie, vertrouwelijkheidaanduiding) are editable. The S-27 catalog-resolution keys stay **static config** — editing them would desync the zaaktype-URL cache (ADR-0021), and they're catalogus wiring, not "default fill". The store is **in-memory** (seeded from config): an edit reverts on restart. That's the reference-app-appropriate ceiling (no DB added to the stateless ACL); upgrade path documented. Recorded in **ADR-0026**. ## Verified locally lint (`dotnet format`) ✓ · .NET unit — acl 60 / bff 45 / domain 152 / event-subscriber 19 / acceptance 17 ✓ · frontend lint+test (8 projects) ✓ · beheer build ✓. Clean full-solution build (caught + fixed the acceptance `AclService` ctor drift). TDD red→green per layer (ACL store, ACL endpoints, BFF, frontend). ## Definition of Done - [x] Failing test committed before each implementation (red→green per layer). - [x] Conventional Commits referencing #131. - [ ] CI green — see note below. - [x] Docs: ADR-0026 + S-15b demo note. - [x] Demo note in `docs/demo-script.md`. ## Note on CI The bulk validates in the fast jobs (lint/build/unit/frontend/mutation). The **verify-stack e2e** (incl. the new `default-fill.spec.ts`) can't go green until the pre-existing **verify-stack bring-up failure on the 1.27/2.0.0 runner** is resolved (that fails on plain `main` too — unrelated to this PR). Additive change; no existing e2e touched. 🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: #138
169 lines
9.1 KiB
C#
169 lines
9.1 KiB
C#
using System.Net.Http.Json;
|
|
|
|
namespace Bff.Api;
|
|
|
|
/// <summary>What the self-service submit returns to the portal (the domain's registration id + status).</summary>
|
|
public sealed record SubmitAccepted(string RegistrationId, string Status);
|
|
|
|
/// <summary>The caller's current open registration, for resuming the self-service portal after a
|
|
/// refresh (S-26): the reference (registration id) + its status.</summary>
|
|
public sealed record CurrentRegistration(string RegistrationId, string Status);
|
|
|
|
/// <summary>A projection row as the projection-api serves it. <c>Bsn</c>/<c>NaamPlaceholder</c> are
|
|
/// read but never surfaced by the openbaar endpoint (public-safe filtering, ADR-0010/S-09).
|
|
/// <c>Reference</c> is the public-safe citizen reference (the zaak identificatie, #78).</summary>
|
|
public sealed record ProjectionEntry(string Id, string Status, string? Reference, string? Bsn, string? NaamPlaceholder);
|
|
|
|
/// <summary>A public-safe openbaar register row — only non-sensitive fields leave the BFF.</summary>
|
|
public sealed record OpenbaarEntry(string Id, string Status, string? Reference);
|
|
|
|
/// <summary>A behandelaar's werkbak row: a registration awaiting beoordeling, with the bsn + status a
|
|
/// behandelaar sees (staff view — reached only behind medewerker/behandelaar authorization, S-12c).</summary>
|
|
public sealed record WerkbakItem(string RegistrationId, string Bsn, string Status);
|
|
|
|
/// <summary>Port to the Domain Service (§8.3: the BFF is the portals' only backend; it fans out).</summary>
|
|
public interface IDomainClient
|
|
{
|
|
Task<SubmitAccepted> SubmitRegistrationAsync(string bsn, CancellationToken ct = default);
|
|
|
|
/// <summary>The caller's current open registration (resume after refresh, S-26), or <c>null</c>
|
|
/// when they have none in flight. Owner-scoped by <paramref name="bsn"/>.</summary>
|
|
Task<CurrentRegistration?> GetCurrentRegistrationAsync(string bsn, CancellationToken ct = default);
|
|
|
|
/// <summary>Withdraw the caller's own registration ("trek aanvraag in"). Owner-scoped by
|
|
/// <paramref name="bsn"/>. Returns <c>false</c> when the domain reports the registration is
|
|
/// unknown or not the caller's (404), so the BFF can relay a 404 rather than a 500.</summary>
|
|
Task<bool> WithdrawRegistrationAsync(string registrationId, string bsn, CancellationToken ct = default);
|
|
|
|
/// <summary>Provide (upload) the diploma the caller's own registration is waiting for ("documenten
|
|
/// aanleveren"). The file is carried base64-encoded. Owner-scoped by <paramref name="bsn"/>. Returns
|
|
/// <c>false</c> when the domain reports the registration is unknown or not the caller's (404).</summary>
|
|
Task<bool> ProvideDocumentsAsync(
|
|
string registrationId, string bsn, string contentBase64, string? fileName, string? contentType, CancellationToken ct = default);
|
|
|
|
/// <summary>The behandelaar's werkbak — registrations awaiting beoordeling.</summary>
|
|
Task<IReadOnlyList<WerkbakItem>> GetWerkbakAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>Apply a behandelaar's decision (<c>goedkeuren</c>/<c>afwijzen</c>) to a registration.</summary>
|
|
Task DecideAsync(string registrationId, string besluit, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>Port to the read projection.</summary>
|
|
public interface IProjectionClient
|
|
{
|
|
Task<IReadOnlyList<ProjectionEntry>> GetRegisterAsync(CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>A published zaaktype as the beheer catalogus viewer shows it (S-15a): the business
|
|
/// <c>Identificatie</c> + human <c>Omschrijving</c>. The ZGW URL the ACL also returns is dropped — an
|
|
/// internal reference, not shown in the portal.</summary>
|
|
public sealed record BeheerZaaktype(string Identificatie, string Omschrijving);
|
|
|
|
/// <summary>The ACL default-fill settings the beheer portal reads + edits (S-15b): the three ZGW-mandatory
|
|
/// fields the ACL stamps on every zaak (ADR-0003).</summary>
|
|
public sealed record BeheerDefaultFill(
|
|
string Bronorganisatie,
|
|
string VerantwoordelijkeOrganisatie,
|
|
string Vertrouwelijkheidaanduiding);
|
|
|
|
/// <summary>Port to the ACL for beheer queries (beheer portal). The BFF reaches the ACL directly: these
|
|
/// aren't a domain concern, and the ACL is the only code allowed to read/own the ZGW-facing config
|
|
/// (§8.1, ADR-0025).</summary>
|
|
public interface IAclClient
|
|
{
|
|
/// <summary>The published catalogus zaaktypen, read-only (S-15a).</summary>
|
|
Task<IReadOnlyList<BeheerZaaktype>> GetZaaktypenAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>The current default-fill settings (S-15b).</summary>
|
|
Task<BeheerDefaultFill> GetDefaultFillAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>Replace the default-fill settings (S-15b).</summary>
|
|
Task UpdateDefaultFillAsync(BeheerDefaultFill settings, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>Calls the Domain Service's <c>POST /registrations</c>.</summary>
|
|
public sealed class DomainClient(HttpClient http) : IDomainClient
|
|
{
|
|
public async Task<SubmitAccepted> SubmitRegistrationAsync(string bsn, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.PostAsJsonAsync("registrations", new { bsn }, ct);
|
|
response.EnsureSuccessStatusCode();
|
|
var dto = await response.Content.ReadFromJsonAsync<DomainResponse>(ct)
|
|
?? throw new InvalidOperationException("The Domain Service returned an empty registration response.");
|
|
return new SubmitAccepted(dto.RegistrationId, dto.Status);
|
|
}
|
|
|
|
public async Task<CurrentRegistration?> GetCurrentRegistrationAsync(string bsn, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.GetAsync($"registrations/current?bsn={Uri.EscapeDataString(bsn)}", ct);
|
|
// The domain 404s when the citizen has no open registration — that's "none", not an error.
|
|
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
|
|
return null;
|
|
response.EnsureSuccessStatusCode();
|
|
var dto = await response.Content.ReadFromJsonAsync<DomainResponse>(ct)
|
|
?? throw new InvalidOperationException("The Domain Service returned an empty registration response.");
|
|
return new CurrentRegistration(dto.RegistrationId, dto.Status);
|
|
}
|
|
|
|
public async Task<bool> WithdrawRegistrationAsync(string registrationId, string bsn, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.PostAsJsonAsync(
|
|
$"registrations/{registrationId}/withdraw", new { bsn }, ct);
|
|
// The domain 404s an unknown or not-owned registration; relay that rather than fail hard.
|
|
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
|
|
return false;
|
|
response.EnsureSuccessStatusCode();
|
|
return true;
|
|
}
|
|
|
|
public async Task<bool> ProvideDocumentsAsync(
|
|
string registrationId, string bsn, string contentBase64, string? fileName, string? contentType, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.PostAsJsonAsync(
|
|
$"registrations/{registrationId}/documents",
|
|
new { bsn, contentBase64, fileName, contentType }, ct);
|
|
// The domain 404s an unknown or not-owned registration; relay that rather than fail hard.
|
|
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
|
|
return false;
|
|
response.EnsureSuccessStatusCode();
|
|
return true;
|
|
}
|
|
|
|
public async Task<IReadOnlyList<WerkbakItem>> GetWerkbakAsync(CancellationToken ct = default)
|
|
=> await http.GetFromJsonAsync<List<WerkbakItem>>("behandel/werkbak", ct) ?? [];
|
|
|
|
public async Task DecideAsync(string registrationId, string besluit, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.PostAsJsonAsync(
|
|
$"registrations/{registrationId}/decide", new { besluit }, ct);
|
|
response.EnsureSuccessStatusCode();
|
|
}
|
|
|
|
private sealed record DomainResponse(string RegistrationId, string Status, string? ZaakUrl);
|
|
}
|
|
|
|
/// <summary>Calls the projection-api's <c>GET /register</c>.</summary>
|
|
public sealed class ProjectionClient(HttpClient http) : IProjectionClient
|
|
{
|
|
public async Task<IReadOnlyList<ProjectionEntry>> GetRegisterAsync(CancellationToken ct = default)
|
|
=> await http.GetFromJsonAsync<List<ProjectionEntry>>("register", ct) ?? [];
|
|
}
|
|
|
|
/// <summary>Calls the ACL's <c>GET /catalogi/zaaktypen</c> (S-15a). The ACL also returns each zaaktype's
|
|
/// ZGW URL; deserializing into <see cref="BeheerZaaktype"/> keeps only the public-safe fields.</summary>
|
|
public sealed class AclClient(HttpClient http) : IAclClient
|
|
{
|
|
public async Task<IReadOnlyList<BeheerZaaktype>> GetZaaktypenAsync(CancellationToken ct = default)
|
|
=> await http.GetFromJsonAsync<List<BeheerZaaktype>>("catalogi/zaaktypen", ct) ?? [];
|
|
|
|
public async Task<BeheerDefaultFill> GetDefaultFillAsync(CancellationToken ct = default)
|
|
=> await http.GetFromJsonAsync<BeheerDefaultFill>("default-fill", ct)
|
|
?? throw new InvalidOperationException("The ACL returned an empty default-fill response.");
|
|
|
|
public async Task UpdateDefaultFillAsync(BeheerDefaultFill settings, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.PutAsJsonAsync("default-fill", settings, ct);
|
|
response.EnsureSuccessStatusCode();
|
|
}
|
|
}
|