/** * SQL-backed metadata operations used by mapped entity persistence. * * The application layer may coordinate these operations inside its existing * transaction, but it must not own SQLite table names or SQL text. Keeping the * statements here makes the current SQLite provider boundary explicit without * changing the public entity lifecycle API. */ import type { EffectStatus } from "../../../contracts/domain/model/constants.js"; import type { NormalizedCell } from "../../../contracts/encoding/types.js"; import type { SqlExecutor, SqlMutationResult } from "../../../contracts/storage/sql.js"; /** Raw row-binding state returned by SQLite. */ export interface MappedRowBindingSqlRow { readonly logical_sheet_id: string; readonly anchor_reference: string; readonly entity_id: string | null; readonly state: string; } /** Raw canonical entity revision returned by SQLite. */ export interface MappedCanonicalEntitySqlRow { readonly entity_revision: number; } /** Raw canonical entity revision and lifecycle returned by SQLite. */ export interface MappedCanonicalEntityStateSqlRow { readonly entity_revision: number; readonly status: string; } /** Raw canonical field revision returned by SQLite. */ export interface MappedCanonicalFieldRevisionSqlRow { readonly field_name: string; readonly field_revision: number; } /** Raw canonical field value used to rebuild a transaction-local projection. */ export interface MappedCanonicalFieldValueSqlRow { readonly field_name: string; readonly normalized_value: string; } /** Raw active business-key row returned by SQLite. */ export interface MappedActiveBusinessKeySqlRow { readonly entity_id: string; readonly normalized_key: string; } /** Raw business-key owner row returned by SQLite. */ export interface MappedBusinessKeyOwnerSqlRow { readonly entity_id: string; } /** Raw confirmed projection state returned by SQLite. */ export interface MappedVisibleProjectionSqlRow { readonly confirmed_snapshot_hash: string; readonly confirmed_visible_revision: number; } /** Raw latest projection effect returned by SQLite. */ export interface MappedLatestProjectionEffectSqlRow { readonly effect_id: string; readonly physical_sheet_id: string; readonly projection: string; readonly status: EffectStatus; readonly effect_kind: string; readonly payload_json: string; readonly expected_visible_revision: number; readonly expected_visible_hash: string; readonly stream_sequence: number; readonly last_error_code: string | null; } /** One raw unresolved active-candidate row (any owned field). */ export interface MappedActiveCandidateSqlRow { readonly active_candidate_conflict_id: string | null; readonly active_candidate_hash: string | null; readonly conflict_status: string | null; } /** Reads one mapped row binding inside the caller-owned transaction. */ export declare function readMappedRowBindingWithSql(sql: SqlExecutor, rowBindingId: string): Promise; /** Inserts the active binding shared by the mapped System_State and User_Input rows. */ export declare function insertMappedActiveRowBindingWithSql(sql: SqlExecutor, rowBindingId: string, logicalSheetId: string, anchorReference: string, entityId: string): Promise; /** Tombstones one active mapped row binding after a canonical delete. */ export declare function tombstoneMappedActiveRowBindingWithSql(sql: SqlExecutor, rowBindingId: string, logicalSheetId: string, entityId: string): Promise; /** * Reactivates an exactly-matching tombstoned row binding during a mapped * recreate, preserving its candidate epoch and physical row identity. */ export declare function reactivateMappedTombstonedRowBindingWithSql(sql: SqlExecutor, rowBindingId: string, logicalSheetId: string, anchorReference: string, entityId: string): Promise; /** Reads the current canonical entity revision and lifecycle for one entity. */ export declare function readMappedCanonicalEntityStateWithSql(sql: SqlExecutor, entityId: string): Promise; /** Reads the active canonical entity revision used by mapped flush validation. */ export declare function readMappedActiveCanonicalEntityWithSql(sql: SqlExecutor, entityId: string): Promise; /** Reads the current canonical values used for transaction-local projection payloads. */ export declare function readMappedCanonicalFieldsWithSql(sql: SqlExecutor, entityId: string): Promise>>; /** Reads canonical field revisions used to build update compare-and-set input. */ export declare function readMappedCanonicalFieldRevisionsWithSql(sql: SqlExecutor, entityId: string): Promise; /** Reads the active business key currently owned by one mapped entity. */ export declare function readMappedActiveBusinessKeyWithSql(sql: SqlExecutor, logicalSheetId: string, fieldName: string, entityId: string): Promise; /** Reads the current owner of a normalized business key. */ export declare function readMappedBusinessKeyOwnerWithSql(sql: SqlExecutor, logicalSheetId: string, fieldName: string, normalizedKey: string): Promise; /** Claims a normalized business key for a mapped entity. */ export declare function insertMappedActiveBusinessKeyWithSql(sql: SqlExecutor, logicalSheetId: string, fieldName: string, normalizedKey: string, entityId: string): Promise; /** Retires one previous business key during an accepted key rotation. */ export declare function retireMappedActiveBusinessKeyWithSql(sql: SqlExecutor, logicalSheetId: string, fieldName: string, normalizedKey: string, entityId: string): Promise; /** Retires every active business key owned by a deleted mapped entity. */ export declare function retireMappedEntityBusinessKeysWithSql(sql: SqlExecutor, logicalSheetId: string, entityId: string): Promise; /** Reads the last confirmed visible state for one projection row. */ export declare function readMappedVisibleProjectionStateWithSql(sql: SqlExecutor, physicalSheetId: string, projection: string, rowBindingId: string): Promise; /** Reads the latest queued or applied effect used to derive the next baseline. */ export declare function readMappedLatestProjectionEffectWithSql(sql: SqlExecutor, logicalSheetId: string, targetKind: string, targetId: string): Promise; /** * Reads the newest applied effect on one target stream. * * Superseded and still-pending effects never materialize, so the row state * a successor must guard against is the newest effect that actually reached * the provider. */ export declare function readMappedLatestAppliedProjectionEffectWithSql(sql: SqlExecutor, logicalSheetId: string, targetKind: string, targetId: string): Promise; /** * Returns whether one projection row carries an unresolved active candidate. * * An orphaned candidate pointer (no conflict row) blocks too, mirroring the * outbound candidate gate: the projection must never be overwritten while * any candidate evidence is present. Any two-sided pointer blocks regardless * of conflict status: a pointer that survives a RESOLVED conflict is a * malformed state that normal resolution clears in the same transaction, and * the row must fail closed instead of being overwritten. A one-sided pointer * (only the conflict ID or only the hash set) is a storage-consistency * failure: the row must never be treated as candidate-free, so the read * throws instead of letting a mapped update/delete overwrite it. */ export declare function hasMappedRowActiveCandidateWithSql(sql: SqlExecutor, physicalSheetId: string, projection: string, rowBindingId: string): Promise; //# sourceMappingURL=mappedPersistenceSql.d.ts.map