import { Weave, WeaveResult } from './Weave2'; import { SiteStatus } from './SiteStatus'; import { Atom, AtomCardinality } from './Atom2'; /** * Defines an interface that represents the current version of a causal tree. */ export interface CurrentVersion { /** * The ID of the local site. * Null if the local site does not have an ID. */ currentSite: string | null; /** * The ID of the site that is used for "remote" edits. * That is, edits that were not made through the UI. */ remoteSite: string | null; /** * The current version vector. */ vector: VersionVector; } /** * Defines an interface that represents a map of site IDs to timestamps. */ export interface VersionVector { [site: string]: number; } /** * Defines an interface for a casual tree that can be operated on. */ export interface CausalTree { weave: Weave; site: SiteStatus; remoteSite?: SiteStatus; version: VersionVector; } /** * Defines an interface for a result from adding an atom to a tree. */ export interface TreeResult { results: WeaveResult[]; newSite: SiteStatus; newRemoteSite?: SiteStatus; } /** * Creates a new tree. * @param id The ID to use for the site. */ export declare function tree(id?: string, time?: number, remoteId?: string): CausalTree; /** * Gets the current version for the given tree. * @param tree The tree. * @param remoteSite The site ID for the remote site. */ export declare function treeVersion(tree: CausalTree): CurrentVersion; /** * Inserts the given atoms to the given tree. * @param tree The tree that the atoms should be added to. * @param atoms The atoms that should be added. */ export declare function insertAtoms(tree: CausalTree, atoms: Atom[], results?: WeaveResult[]): WeaveResult[]; /** * Removes the atoms with the given hashes from the given tree. * @param tree The tree. * @param hashes The atom hashes to remove. */ export declare function removeAtoms(tree: CausalTree, hashes: string[], results?: WeaveResult[]): WeaveResult[]; /** * Adds the given atom to the tree's weave and returns a result representing the update. * @param tree The tree. * @param cause The cause of the new atom. * @param op The operation for the new atom. * @param priority The priority of the new atom. * @param remote Whether the atom should be created for the remote site. */ export declare function addAtom(tree: CausalTree, cause: Atom, op: O, priority?: number, cardinality?: AtomCardinality, remote?: boolean): TreeResult; /** * Inserts the given atom into the given tree. * @param tree The tree. * @param atom The atom. */ export declare function insertAtom(tree: CausalTree, atom: Atom): TreeResult; /** * Removes the atom with the given hash from the tree. * @param tree The tree. * @param hash The hash. */ export declare function removeAtom(tree: CausalTree, hash: string): TreeResult; /** * Merges the two tree results into one. * @param first The first tree result. * @param second The second tree result. */ export declare function mergeResults(first: TreeResult, second: TreeResult): TreeResult; /** * Adds the results from the second result to the first result. * This method mutates first. * @param first The first result. * @param second The second result. */ export declare function addResults(first: TreeResult, second: TreeResult): TreeResult; /** * Applies the given tree result by creating a new tree which incorporates the result into the new tree. * @param tree * @param result */ export declare function applyResult(tree: CausalTree, result: TreeResult): CausalTree; /** * Gets the list of atoms that were added via the given tree result. * @param result The result. */ export declare function addedAtoms(results: WeaveResult[]): Atom[]; /** * Gets the list of atoms that were removed via the given tree result. * @param result The result. */ export declare function removedAtoms(results: WeaveResult[]): string[]; //# sourceMappingURL=CausalTree2.d.ts.map