import { SkeletosDb, TreeNodeValueType, ISkeletosDbTransaction, ITreeNode } from "./SkeletosDb"; /** * Records all modifications done in the SkeletosDb, and allows for rollback of all these modifications. */ export declare class SkeletosTransaction implements ISkeletosDbTransaction { private _purpose; private _db; private _log; private _alreadyRolledBack; /** * Records all modifications done in the SkeletosDb, and allows for rollback of all these modifications. * * @param SkeletosDb */ constructor(db: SkeletosDb); /** * Records all modifications done in the SkeletosDb, and allows for rollback of all these modifications. * * @param SkeletosDb * @param purpose */ constructor(purpose: string, db: SkeletosDb); /** * The transaction log. * * @returns {SkeletosTransactionEntry[]} */ readonly entries: SkeletosTransactionEntry[]; /** * Records the value of the set call to the database * * @param path * @param newValue * @param oldValue */ recordSet(path: string[], newValue: TreeNodeValueType, oldValue: TreeNodeValueType): void; /** * Records the value of the setReference call to the database. * * @param path * @param newValue * @param oldValue */ recordSetReference(path: string[], newValue: string[], oldValue: string[]): void; /** * Records the unset of a node. We store the entire node to restore later if needed. * * @param path * @param oldNode */ recordUnset(path: string[], oldNode: ITreeNode): void; /** * Rolls back all the modifications made to the database made so far as part of this transaction. * * @param {string} reason */ rollback(reason?: string | Error): void; /** * Serializes all new values. Note that old values are not serialized. * * This can be used for example to send the server a diff of what changed. */ serialize(): string; /** * Deserializes the given log and applies it to the database. */ deserializeAndApply(serialized: string | SkeletosTransaction): void; /** * Applies the all entries from the given transaction into this transaction. * * @param deserializedTransaction */ private applyEntriesFrom; private add; private addUnset; private checkIfUnrolled; } /** * The entry is a single modification that happened (either db.set or db.setReference). * * It is unwise to keep this in memory for longer than the life of the transaction. */ export declare class SkeletosTransactionEntry { path: string[]; newValue: TreeNodeValueType | string[]; oldValue: TreeNodeValueType | string[]; oldNode: ITreeNode; isReference: boolean; isUnset: boolean; constructor(path: string[], newValue: TreeNodeValueType | string[], oldValue: TreeNodeValueType | string[], oldNode: ITreeNode, isUnset: boolean, isReference: boolean); }