/** * Gapless ledger sequences + hash-chain heads, one document per * (skrType, fiscalYear). Allocation runs inside the caller's transaction * session, so an aborted posting rolls the $inc back and gaplessness holds. */ import * as plugins from './plugins.js'; import { type TDbSession } from './skr.database.js'; import type { TSKRType } from './skr.types.js'; export declare const LEDGER_SEQUENCE_COLLECTION = "LedgerSequence"; /** The counter and chain head of one (skrType, fiscalYear). */ export declare class LedgerSequence extends plugins.nosqldb.SmartDataDbDoc { skrType: TSKRType; fiscalYear: number; value: number; headHash: string; } export interface ILedgerSequenceAllocation { sequenceNumber: number; prevHash: string; } export interface ILedgerSequenceState { skrType: TSKRType; fiscalYear: number; value: number; headHash: string; } /** * Allocate the next sequence number and return the current chain head. * Must run inside a transaction — the $inc participates in the rollback. */ export declare function allocateSequence(skrType: TSKRType, fiscalYear: number, session: TDbSession): Promise; /** * Compare-and-swap the chain head. The filter on the old head serializes * concurrent posters — a lost race aborts the surrounding transaction. */ export declare function advanceHead(skrType: TSKRType, fiscalYear: number, prevHash: string, newHash: string, session: TDbSession): Promise; export declare function getSequenceState(skrType: TSKRType, fiscalYear: number): Promise;