UNPKG

@x5e/gink

Version:

an eventually consistent database

78 lines (77 loc) 3.85 kB
import { Database } from "./Database"; import { Container } from "./Container"; import { Muid, AsOf } from "./typedefs"; import { Bundler } from "./Bundler"; import { ContainerBuilder } from "./builders"; export declare class Group extends Container { constructor(database: Database, address: Muid, containerBuilder?: ContainerBuilder); /** * Includes a Muid or Container in the group. * @param key either a container or a Muid to include * @param change an optional bundler to put this change into * @returns a promise that resolves to the Muid for the inclusion */ include(key: Container, change?: Bundler | string): Promise<Muid>; /** * Excludes a Muid or Container from the group. * @param key either a Muid or container to exclude * @param change an optional bundler to put this in * @returns a promise that resolves to the Muid for the exclusion */ exclude(key: Container, change?: Bundler | string): Promise<Muid>; /** * This returns the number of inclusions only, NOT exclusions. * @returns how many containers are included in the group */ size(): Promise<number>; /** * Whether or not the given key is explicitly included in the group. * @param key either a Muid or container to check if it is included * @param asOf optional timestamp to look back to * @returns a promise that resolves to a boolean stating whether the key is explicitly included */ isIncluded(key: Muid | Container, asOf?: AsOf): Promise<boolean>; /** * Function to iterate over the containers in the group. * @param asOf optional timestamp to look back to * @returns an async iterator across all containers in the group */ getMembers(asOf?: AsOf): AsyncGenerator<Container, void, unknown>; /** * Dumps the contents of this group to a javascript array.Only includes explicitly included members. * useful for debugging and could also be used to export data by walking the tree * @param asOf effective time to get the dump for: leave undefined to get data as of the present * @returns an array containing Values (e.g. numbers, strings) and Containers (e.g. other Lists, Boxes, Directories) */ includedAsArray(asOf?: AsOf): Promise<Container[]>; /** * * @param args Optional arguments, including: * @argument toTime Optional time to reset to. If absent, the container will be cleared. * @argument bundlerOrComment Optional bundler or comment to add this change to * @argument skipProperties If true, do not reset properties of this container. By default, * all properties associated with this container will be reset to the time specified in toTime. * @argument recurse NOTE: THIS FLAG IS IGNORED. Recursive reset for Inclusion-based containers * is not yet implemented, but this arg needs to be accepted for other containers recursively * resetting this one. * @argument seen NOTE: THIS FLAG IS IGNORED. Recursive reset for Inclusion-based containers is * not yet implemented, but this arg needs to be accepted for other containers recursively * resetting this one. */ reset(args?: { toTime?: AsOf; bundlerOrComment?: Bundler | string; skipProperties?: boolean; recurse?: boolean; seen?: Set<string>; }): Promise<void>; /** * Generates a JSON representation of the data in the group. * Mostly intended for demo/debug purposes. * @param indent true to pretty print (not yet implemented) * @param asOf optional timestamp to look back to * @param seen (internal use only! This prevents cycles from breaking things) * @returns a JSON string */ toJson(indent?: number | boolean, asOf?: AsOf, seen?: Set<string>): Promise<string>; }