@x5e/gink
Version:
an eventually consistent database
45 lines (44 loc) • 2.64 kB
TypeScript
import { HasMap } from "./HasMap";
import { ChangeBuilder, EntryBuilder } from "./builders";
import { ScalarKey, StorageKey, MuidTuple, Muid, BundleInfo, BundleInfoTuple, Movement, Value, Bundler } from "./typedefs";
import { Container } from "./Container";
/**
*
* @param entryBuilder
* @param entryMuid
* @returns A well defined string that's different for each valid key, given the behavior
*/
export declare function getStorageKey(entryBuilder: EntryBuilder, entryMuid: Muid): StorageKey;
export declare function storageKeyToString(storageKey: StorageKey): string;
export declare function extractMovement(changeBuilder: ChangeBuilder, bundleInfo: BundleInfo, offset: number): Movement;
/**
* Bundles a movement change into the provided bundler
* @param bundler The bundler to add the change to
* @param entryMuid The muid of the entry to move
* @param containerMuid The muid of the container that holds this entry
* @param dest Destination to move the entry to. If omitted, the entry is removed.
* @param purge Purge the entry from the internal store?
*/
export declare function movementHelper(bundler: Bundler, entryMuid: Muid, containerMuid: Muid, dest?: number, purge?: boolean): Promise<void>;
export declare function extractContainerMuid(entryBuilder: EntryBuilder, bundleInfo: BundleInfo): MuidTuple;
export declare function buildPointeeList(entryBuilder: EntryBuilder, bundleInfo: BundleInfo): Array<MuidTuple>;
export declare function buildPairLists(entryBuilder: EntryBuilder, bundleInfo: BundleInfo): Array<Array<MuidTuple>>;
export declare function medallionChainStartToString(tuple: [number, number]): string;
export declare function buildChainTracker(chainInfos: Iterable<BundleInfo>): HasMap;
export declare function toStorageKey(key: ScalarKey | Muid | [Muid | Container, Muid | Container]): StorageKey;
export declare function bundleKeyToInfo(bundleKey: BundleInfoTuple): {
timestamp: number;
medallion: number;
chainStart: number;
priorTime: number;
comment: string;
};
export declare function bundleInfoToKey(bundleInfo: BundleInfo): BundleInfoTuple;
/**
* Utility function to add a property entry change to a bundler without reconstructing the property.
* @param bundler required bundler to add this change to
* @param propertyMuid the Muid of the property to add this entry to
* @param containerMuid the Muid of the container this value is describing
* @param value the property value associated with the container. If omitted, the property is deleted.
*/
export declare function bundlePropertyEntry(bundler: Bundler, propertyMuid: Muid, containerMuid: Muid, value?: Value): Muid;