import * as Domain from "../domain"; import * as Models from "./models"; import { PeerDID } from "../peer-did/PeerDID"; import { BackupManager } from "./backup/BackupManager"; import { Arrayable } from "../utils"; import { Startable } from "../domain/protocols/Startable"; import { Version } from "../domain/backup"; import { Query } from "./types"; /** * Pluto implementation * * Structure: * - Pluto class is an orchestration layer * - Repositories handle mapping between Domain and Storable Models * - Models suggest db structure * - Store abstracts db implementation * * Pluto: * - always handles Domain classes * - manage relationships * - handle logic and concepts * - throw known Errors * - return null * - naming convention * - (get/store) (Domain name Pluralized) ie getCredentials * * Models: * - naming convention * - alias for optional names * - name for required identifiers * - dataJson for JSON.stringified objects * * Store: * - simplified interface * - crud interactions * - only use Models * * * Future: * - versioning * - migrations */ export declare namespace Pluto { interface Store { /** * Handle any necessary startup. * Will be called first before any usage, if provided. */ start?(): Promise; /** * Handle any necessary teardown. */ stop?(): Promise; /** * Run a query to fetch data from the Store * * @param table table name * @param query a Query object, a set of values and operators defining the query * * properties within an object will be AND'ed * different objects will be OR'd * * @example * search for a model in TableOne with uuid and name * ```ts * store.query("TableOne", { selector: { uuid: "1", name: "eg" }}) * ``` * @example * search for models in TableOne with uuid of 1 or 2 * ```ts * store.query("TableOne", { selector: { $or: [{ uuid: "1" }, { uuid: "2" }] }}) * ``` * @example * search for all models in TableOne * ```ts * store.query("TableOne") * ``` * * @returns relevant Models */ query(table: string, query?: Query): Promise; /** * Persist new data in the Store. * * @param table table name * @param model object to save */ insert(table: string, model: T): Promise; /** * Updating a new row in the Store * @param table * @param model */ update(table: string, model: T): Promise; /** * Deleting a row in the Store * @param table * @param model */ delete(table: string, uuid: string): Promise; } } export declare class Pluto extends Startable.Controller implements Domain.Pluto { private readonly store; private readonly keyRestoration; BackupMgr: BackupManager; private Repositories; constructor(store: Pluto.Store, keyRestoration: Domain.KeyRestoration); protected _start(): Promise; protected _stop(): Promise; /** Backups **/ backup(version?: Version): Promise<{ version?: "0.0.1" | undefined; link_secret?: string | undefined; credentials: { recovery_id: string; data: string; }[]; dids: { alias?: string | undefined; did: string; }[]; did_pairs: { alias: string; holder: string; recipient: string; }[]; keys: { did?: string | undefined; index?: number | undefined; recovery_id: string; key: string; }[]; mediators: { holder_did: string; mediator_did: string; routing_did: string; }[]; messages: string[]; }>; restore(backup: Domain.Backup.Schema): Promise; deleteMessage(id: string): Promise; /** Credentials **/ storeCredential(credential: Domain.Credential): Promise; getAllCredentials(): Promise; revokeCredential(credential: Domain.Credential): Promise; /** Credential Metadata **/ storeCredentialMetadata(metadata: Domain.CredentialMetadata): Promise; getCredentialMetadata(name: string): Promise; /** LinkSecret **/ storeLinkSecret(linkSecret: Domain.LinkSecret): Promise; getLinkSecret(name?: string): Promise; /** PrivateKeys **/ storePrivateKey(privateKey: Domain.PrivateKey): Promise; getDIDPrivateKeysByDID(did: Domain.DID): Promise; /** DIDs **/ storeDID(did: Domain.DID, keys?: Arrayable, alias?: string): Promise; /** Prism DIDs **/ storePrismDID(did: Domain.DID, privateKey: Domain.PrivateKey, alias?: string): Promise; getAllPrismDIDs(): Promise; private getPrismDIDS; /** Peer DIDs **/ storePeerDID(did: Domain.DID, privateKeys: Domain.PrivateKey[]): Promise; getAllPeerDIDs(): Promise; /** Messages **/ storeMessage(message: Domain.Message): Promise; storeMessages(messages: Domain.Message[]): Promise; getMessage(id: string): Promise; getAllMessages(): Promise; /** DID Pairs **/ storeDIDPair(host: Domain.DID, receiver: Domain.DID, alias: string): Promise; getAllDidPairs(): Promise; getPairByDID(did: Domain.DID): Promise; getPairByName(alias: string): Promise; private mapDIDPairToDomain; /** Mediators **/ getAllMediators(): Promise; storeMediator(mediator: Domain.Mediator): Promise; private onlyOne; }