import { AdvancedDictionary } from "../common/AdvancedDictionary"; import { IIndexApi } from "../indexing/IndexApi"; import { IPreviewChanges, IPurgeResponse } from "../types/common-types"; import { IDataContext, DataContextOptions } from "../types/context-types"; import { EntityAndTag, IDbSet } from "../types/dbset-types"; import { IDbRecordBase, IIndexableEntity } from "../types/entity-types"; import { PouchDbInteractionBase } from "./PouchDbInteractionBase"; import { AsyncCache } from '../cache/AsyncCache'; import { DbSetInitializer } from './dbset/builders/DbSetInitializer'; export declare class DataContext extends PouchDbInteractionBase implements IDataContext { protected readonly PRISTINE_ENTITY_KEY = "__pristine_entity__"; protected readonly DIRTY_ENTITY_MARKER = "__isDirty"; static PROXY_MARKER: string; protected _removals: IDbRecordBase[]; protected _additions: IDbRecordBase[]; protected _attachments: AdvancedDictionary; private _tags; protected _removeById: string[]; private _configuration; protected asyncCache: AsyncCache; $indexes: IIndexApi; protected dbSets: { [key: string]: IDbSet; }; constructor(name?: string, options?: DataContextOptions); getAllDocs(): Promise; /** * Enable DataContext speed optimizations. Needs to be run once per application per database. Typically, this should be run on application start. * @returns void */ optimize(): Promise; /** * Gets an instance of IDataContext to be used with DbSets */ protected getContext(): this; /** * Gets an API to be used by DbSets * @returns IData */ private _getApi; private _tag; protected addDbSet(dbset: IDbSet): void; /** * Used by the context api * @param data */ private _detach; /** * Used by the context api * @param data */ private _sendData; /** * Used by the context api */ private _getTrackedData; private _reinitialize; /** * Provides equality comparison for Entities * @param first * @param second * @returns boolean */ private areEqual; private _mapInstance; private _mapAndSetDefaults; private _makeTrackable; private _getPendingChanges; previewChanges(): Promise; private _makePristine; private _getModifications; private _beforeSaveChanges; saveChanges(): Promise; private _getTagsForTransaction; /** * Called before changes are persisted to the database. Any modificaitons to entities made here will be persisted to the database * If you do not want your changes in the database, consider spreading or cloning the entities * @param getChanges */ protected onBeforeSaveChanges(getChanges: () => { adds: EntityAndTag[]; removes: EntityAndTag[]; updates: EntityAndTag[]; }): Promise; protected onAfterSetRev(entity: IIndexableEntity): void; protected onAfterSaveChanges(getChanges: () => { adds: EntityAndTag[]; removes: EntityAndTag[]; updates: EntityAndTag[]; }): Promise; /** * Starts the dbset fluent API. Only required function call is create(), all others are optional * @returns {DbSetInitializer} */ protected dbset(): DbSetInitializer; hasPendingChanges(): boolean; empty(): Promise; destroyDatabase(): Promise; purge(purgeType?: "memory" | "disk"): Promise; static asUntracked(...entities: T[]): T[]; static isProxy(entities: IDbRecordBase): boolean; static isDate(value: any): boolean; static merge(to: T, from: T, options?: { skip?: string[]; }): void; [Symbol.iterator](): { next: () => { value: IDbSet; done: boolean; }; }; }