namespace Bit.Seeder.Pipeline;
///
/// Persistent cross-step reference store that survives bulk-commit flushes.
///
///
/// When commits entities to the database, it clears the entity
/// lists on (users, groups, ciphers, etc.). The registry preserves
/// the IDs and keys that downstream steps need to reference those already-committed entities
/// — for example, a cipher step needs collection IDs to create join records.
///
/// Steps populate the registry as they create entities. Later steps read from it.
/// calls before each run to prevent stale state.
///
///
internal sealed class EntityRegistry
{
///
/// A user's core IDs and symmetric key, needed for per-user encryption (e.g. personal folders).
///
internal record UserDigest(Guid UserId, Guid OrgUserId, string SymmetricKey);
///
/// Organization user IDs for hardened (key-bearing) members. Used by group and collection steps for assignment.
///
internal List HardenedOrgUserIds { get; } = [];
///
/// Full user references including symmetric keys. Used for per-user encrypted content.
///
///
internal List UserDigests { get; } = [];
///
/// Group IDs for collection-group assignment.
///
internal List GroupIds { get; } = [];
///
/// Collection IDs for cipher-collection assignment.
///
internal List CollectionIds { get; } = [];
///
/// Cipher IDs for downstream reference.
///
internal List CipherIds { get; } = [];
///
/// Folder IDs per user, for cipher-to-folder assignment.
///
internal Dictionary> UserFolderIds { get; } = [];
///
/// Clears all registry lists. Called by before each pipeline run.
///
internal void Clear()
{
HardenedOrgUserIds.Clear();
UserDigests.Clear();
GroupIds.Clear();
CollectionIds.Clear();
CipherIds.Clear();
UserFolderIds.Clear();
}
}