import type { TCorePropositionalExpression, TCorePropositionalVariable, TCorePremise } from "../schemata/propositional.js"; import type { TCoreArgument } from "../schemata/argument.js"; import type { TCoreEntityChanges, TCoreChangeset } from "../types/mutation.js"; /** * Replaces each added and modified expression and premise with its current * value, as the lookups return it (a copy); entries a lookup does not find, * and every removed entry, are kept as they are. A changeset built over * several steps can hold an entry whose checksums a later step changed. */ export declare function withCurrentEntries(changes: TCoreChangeset, currentExpression: (id: string) => TExpr | undefined, currentPremise: (id: string) => TPremise | undefined): TCoreChangeset; /** * Merges two changesets into one, deduplicating entities by `id` within each * bucket (added/modified/removed) with last-write-wins semantics. * * Use this for changesets that never change one entity in different ways. * For the changesets of successive calls on one engine, where a later call * can modify or remove what an earlier one added or modified, use * {@link composeChangesets}: this function throws in that case. * * @param a - The first changeset. * @param b - The second changeset. Its entries take precedence when both * changesets contain the same entity ID in the same bucket. * @returns A merged changeset. Entity categories that are empty after merge * are omitted from the result. * @throws {Error} If any entity ID appears in more than one bucket * (added/modified/removed) within the same category after merge. This * indicates a logic error in the caller. */ export declare function mergeChangesets(a: TCoreChangeset, b: TCoreChangeset): TCoreChangeset; /** * Combines two changesets made one after the other into the one changeset * that describes both, entity by entity: added then modified stays added * (with the later value), added then removed disappears, modified then * removed becomes removed, removed then added becomes modified, and * otherwise the later entry wins. `roles` and `argument` take the later * value when it is present. * * Unlike {@link mergeChangesets}, which combines independent changesets and * rejects an id in two buckets, this is for a sequence, where the same * entity legitimately changes more than once. * * @example * ```ts * const { changes: createChanges } = engine.createPremiseWithId(premiseId, data) * const { changes: roleChanges } = engine.setConclusionPremise(premiseId) * const combined = composeChangesets(createChanges, roleChanges) * await persistChangeset(db, combined) * ``` */ export declare function composeChangesets(first: TCoreChangeset, then: TCoreChangeset): TCoreChangeset; /** Each entity's single bucket and latest value, by id. */ export type TEntityChangeState = Map; /** * Records one change to an entity on top of what `state` already holds for * it, keeping one bucket per entity: added then modified stays added (with * the later value), added then removed disappears, removed then added * becomes modified, and otherwise the later change replaces the earlier. */ export declare function recordEntityChange(state: TEntityChangeState, bucket: "added" | "modified" | "removed", entity: T): void; /** The buckets `state` describes, or undefined when it holds nothing. */ export declare function entityChangesFrom(state: TEntityChangeState): TCoreEntityChanges | undefined; //# sourceMappingURL=changeset-merge.d.ts.map