import { AtomIndex, AtomIndexDiff, AtomIndexFullDiff } from './AtomIndex'; import { Atom } from './Atom2'; import { CausalRepoObject, CausalRepoBranch, CausalRepoCommit, CausalRepoIndex } from './CausalRepoObject'; import { CausalRepoStore, CausalObjectStore, CausalBranchStore } from './CausalRepoStore'; import { Weave } from './Weave2'; import { Observable } from 'rxjs'; /** * Defines the set of types that can be stored in a repo. */ export type Storable = Atom | AtomIndex | CausalRepoObject; /** * Defines an interface for data about an index. */ export interface IndexData { /** * The index that was loaded. */ index: CausalRepoIndex; /** * The atoms that were loaded. */ atoms: Map>; } /** * Defines an interface for data about a commit. */ export interface CommitData extends IndexData { /** * The commit. */ commit: CausalRepoCommit; } /** * Stores the given data in the given store. * If given an index, then all the atoms in the given data array * will be stored with the index for quick lookup. * @param store The store that the data should be saved in. * @param head The head that the data is being stored for. * @param index The index that the data is being stored for. * @param data The data to store. */ export declare function storeData(store: CausalObjectStore, head: string, index: string, data: Storable[]): Promise; /** * Loads the commit data for the given branch. * @param store The store that the data should be loaded from. * @param branch The branch to load. */ export declare function loadBranch(store: CausalObjectStore, branch: CausalRepoBranch): Promise; /** * Loads the commit data for the given commit. * @param store The store. * @param head The head that the commit is being loaded for. * @param commit The commit. */ export declare function loadCommit(store: CausalObjectStore, head: string, commit: CausalRepoCommit): Promise; /** * Loads the index data for the given commit. * @param store The store. * @param head The head that the index is being loaded for. * @param index The index. */ export declare function loadIndex(store: CausalObjectStore, head: string, index: CausalRepoIndex): Promise; /** * Loads the atoms for the given diff. * @param store The store. * @param diff The diff to load. */ export declare function loadDiff(store: CausalObjectStore, diff: AtomIndexDiff): Promise; /** * Applies the given diff to the given weave. * @param weave The weave. * @param diff The diff to apply. */ export declare function applyDiff(weave: Weave, diff: AtomIndexFullDiff): void; /** * Creates a map from the given list of atoms. * @param atoms The atoms. */ export declare function atomMap(atoms: Atom[]): Map>; /** * Updates the given branch in the given store. * If the branch points to a non-existant hash then an error will be thrown. * @param store The store. * @param branch The updated branch. */ export declare function updateBranch(store: CausalRepoStore, branch: CausalRepoBranch): Promise; /** * Lists the branches saved in the given store. * @param store The store. * @param prefix The prefix that should be used to filter branches. If null then all branches are included. */ export declare function listBranches(store: CausalBranchStore, prefix?: string): Promise; /** * Lists the set of commits for the given commit hash. * @param store The store that the commit info should be loaded from. * @param hash */ export declare function listCommits(store: CausalObjectStore, hash: string): Promise; /** * Calculates the difference between the two commits. * @param first The first commit. * @param second The second commit. */ export declare function calculateCommitDiff(first: CommitData, second: CommitData): CommitDiff; /** * Defines an interface for objects that represent a diff between two commits. */ export interface CommitDiff { /** * The map of atoms that were added. */ additions: Map>; /** * The map of atoms that were deleted. */ deletions: Map>; } /** * Defines an interface that represents a causal repo. * That is, a repository of atoms stored in a weave. */ export declare class CausalRepo { /** * The diff of atoms that have been added to the stage. */ stage: AtomIndexFullDiff; /** * The atoms that are currently being worked on. (a.k.a working set) * It is a map of atom hashes to their actual values. */ atoms: Map>; private _store; private _head; private _cardinalities; /** * Gets an observable that resolves whenever a diff is added to the repo. */ diffAdded: Observable; /** * Gets an observable that resolves whenever a commit is added to the repo. */ commitAdded: Observable; /** * The commit that the repo currently has checked out. */ currentCommit: CommitData; /** * The branch that is currently checked out. */ get head(): CausalRepoBranch; /** * * @param store */ constructor(store: CausalRepoStore); /** * Gets the list of atoms that currently exist in this repo. */ getAtoms(): Atom[]; /** * Determines if the repo has any uncommited changes. */ hasChanges(): boolean; /** * Adds the given atoms to the stage. * Returns the atoms that were added. * @param atoms The atoms to add. */ add(...atoms: Atom[]): Atom[]; /** * Adds the given atoms to the stage. * Returns the atoms that were added. * @param atoms The atoms to add. */ addMany(atoms: Atom[]): Atom[]; /** * Removes the atoms with the given hashes. * @param hashes The list of hashes to remove. */ remove(...hashes: string[]): Atom[]; /** * Removes the given atoms with the given hashes. * @param hashes The list of hashes to remove. */ removeMany(hashes: string[]): Atom[]; /** * Creates a commit containing all of the current changes. * Returns null if there are no changes to commit. * @param message The message to include for the commit. */ commit(message: string, time?: Date): Promise; /** * Checks out the given branch. * @param branch The branch to checkout * @param opts The options. */ checkout(branch: string, options?: CheckoutOptions): Promise; /** * Resets the current branch to the given hash. * @param hash The hash. */ reset(hash: CausalRepoCommit | string): Promise; /** * Creates and checks out the given branch. * @param name The name of the branch. * @param hash The hash to checkout. */ createBranch(name: string, hash?: string): Promise; getHead(): CausalRepoBranch; private _getAtomFromCurrentState; private _updateHead; private _saveHead; private _checkoutHead; private _setCurrentCommit; private _resetStage; } /** * The options for checking out a branch. */ export interface CheckoutOptions { /** * The options that should be used to create the branch if it doesn't exist. */ createIfDoesntExist?: { hash: string; }; } //# sourceMappingURL=CausalRepo.d.ts.map