import type { TSchema } from "typebox"; import type { TCoreChecksumConfig } from "../types/checksum.js"; import type { TInvariantValidationResult, TInvariantViolationEntityType } from "../types/validation.js"; /** Base shape for entities managed by {@link VersionedLibrary}. */ export type TVersionedEntity = { id: string; version: number; frozen: boolean; checksum: string; }; /** * Abstract base class for versioned, freezable entity libraries. * Provides CRUD, freeze/unfreeze lifecycle, schema validation, and checksum * computation. Subclasses supply the entity label, schema, and validation codes. */ export declare abstract class VersionedLibrary { protected entities: Map>; protected checksumConfig?: TCoreChecksumConfig; protected abstract readonly entityLabel: string; protected abstract readonly entityType: TInvariantViolationEntityType; protected abstract readonly schema: TSchema; protected abstract readonly checksumFieldsKey: keyof TCoreChecksumConfig; protected abstract readonly schemaInvalidCode: string; protected abstract readonly frozenSuccessorCode: string; constructor(options?: { checksumConfig?: TCoreChecksumConfig; }); protected restoreFromEntities(items: TEntity[]): void; protected withValidation(fn: () => T): T; /** Creates a new entity at version 0. Throws if the ID already exists. */ create(entity: Omit): TEntity; /** Applies partial updates to the latest version of an entity. Throws if the entity is frozen. */ update(id: string, updates: Partial>): TEntity; /** Freezes the latest version and creates a new mutable successor. Returns both. */ freeze(id: string): { frozen: TEntity; current: TEntity; }; /** Returns a specific version of an entity, or `undefined` if not found. */ get(id: string, version: number): TEntity | undefined; /** Returns the latest (highest-version) entity for the given ID, or `undefined` if not found. */ getCurrent(id: string): TEntity | undefined; /** Returns every entity across all IDs and versions. */ getAll(): TEntity[]; /** Returns all versions of an entity sorted ascending by version number. */ getVersions(id: string): TEntity[]; /** Validates all entities against the schema and checks that frozen versions have successors. */ validate(): TInvariantValidationResult; private maxVersion; private computeChecksum; } //# sourceMappingURL=versioned-library.d.ts.map