| | | 1 | | namespace ArturRios.Heimdall.Domain.Persistence; |
| | | 2 | | |
| | | 3 | | /// <summary>The rows a hard-deleted scope takes with it, by internal id (UC-05 step 4).</summary> |
| | 12 | 4 | | public sealed record ScopeMemberIds( |
| | 12 | 5 | | IReadOnlyCollection<long> ApplicationIds, |
| | 12 | 6 | | IReadOnlyCollection<long> GoogleUserIds, |
| | 24 | 7 | | IReadOnlyCollection<long> PersonIds); |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// The writes a scope's deletion cascades to its members (UC-04, UC-05), as set-based statements |
| | | 11 | | /// that never load a member, run inside the caller's <see cref="IWriteTransaction" /> (#204). |
| | | 12 | | /// </summary> |
| | | 13 | | /// <remarks> |
| | | 14 | | /// Loading every member to change a flag on each meant a tenant's whole membership — password hashes |
| | | 15 | | /// included — tracked in memory inside one request, growing with the tenant. A statement per kind |
| | | 16 | | /// of member keeps the request's memory flat, whatever the scope's size. The statements bypass the |
| | | 17 | | /// change tracker and so write every column the tracked saves used to — the deletion's time and |
| | | 18 | | /// kind, and <c>UpdatedAt</c> — themselves. |
| | | 19 | | /// </remarks> |
| | | 20 | | public interface IScopeCascades |
| | | 21 | | { |
| | | 22 | | /// <summary> |
| | | 23 | | /// UC-04 step 4: marks every User (via <c>SCOPE_USER</c>), Google User and application of the scope |
| | | 24 | | /// that is not yet deleted as deleted at <paramref name="at" />, a deletion of kind |
| | | 25 | | /// <c>Administrative</c> for the identities (NFR-20). Members already deleted keep the time and kind |
| | | 26 | | /// of their own deletion. Scope owners are not touched. |
| | | 27 | | /// </summary> |
| | | 28 | | Task MarkMembersDeletedAsync(long scopeId, DateTime at); |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// UC-05 step 4: permanently deletes <paramref name="members" /> — applications, then Google Users, |
| | | 32 | | /// then persons, so no foreign key is violated — a bounded batch of ids per statement. |
| | | 33 | | /// </summary> |
| | | 34 | | Task DeleteMembersAsync(ScopeMemberIds members); |
| | | 35 | | } |