/** * Helper functions for accessing the RxStorage instances. */ import type { BulkWriteRow, BulkWriteRowProcessed, ById, CategorizeBulkWriteRowsOutput, RxAttachmentData, RxAttachmentWriteData, RxChangeEvent, RxCollection, RxDatabase, RxDocumentData, RxDocumentWriteData, RxJsonSchema, RxStorageWriteError, RxStorageChangeEvent, RxStorageInstance, RxStorageInstanceCreationParams, StringKeys } from './types'; export declare const INTERNAL_STORAGE_NAME = "_nxdb_internal"; export declare const RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = "rxdatabase_storage_local"; export declare function getSingleDocument(storageInstance: RxStorageInstance, documentId: string): Promise | null>; /** * Writes a single document, * throws RxStorageBulkWriteError on failure */ export declare function writeSingle(instance: RxStorageInstance, writeRow: BulkWriteRow, context: string): Promise>; /** * Checkpoints must be stackable over another. * This is required form some RxStorage implementations * like the sharding plugin, where a checkpoint only represents * the document state from some, but not all shards. */ export declare function stackCheckpoints(checkpoints: CheckpointType[]): CheckpointType; export declare function storageChangeEventToRxChangeEvent(isLocal: boolean, rxStorageChangeEvent: RxStorageChangeEvent, rxCollection?: RxCollection): RxChangeEvent; export declare function throwIfIsStorageWriteError(collection: RxCollection, documentId: string, writeData: RxDocumentWriteData | RxDocType, error: RxStorageWriteError | undefined): void; /** * Analyzes a list of BulkWriteRows and determines * which documents must be inserted, updated or deleted * and which events must be emitted and which documents cause a conflict * and must not be written. * Used as helper inside of some RxStorage implementations. * @hotPath The performance of this function is critical */ export declare function categorizeBulkWriteRows(storageInstance: RxStorageInstance, primaryPath: StringKeys, /** * Current state of the documents * inside of the storage. Used to determine * which writes cause conflicts. * This can be a Map for better performance * but it can also be an object because some storages * need to work with something that is JSON-stringify-able * and we do not want to transform a big object into a Map * each time we use it. */ docsInDb: Map[StringKeys] | string, RxDocumentData> | ById>, /** * The write rows that are passed to * RxStorageInstance().bulkWrite(). */ bulkWriteRows: BulkWriteRow[], context: string): CategorizeBulkWriteRowsOutput; export declare function stripAttachmentsDataFromRow(writeRow: BulkWriteRow): BulkWriteRowProcessed; export declare function getAttachmentSize(attachmentBase64String: string): number; /** * Used in custom RxStorage implementations. */ export declare function attachmentWriteDataToNormalData(writeData: RxAttachmentData | RxAttachmentWriteData): RxAttachmentData; export declare function stripAttachmentsDataFromDocument(doc: RxDocumentWriteData): RxDocumentData; /** * Flat clone the document data * and also the _meta field. * Used many times when we want to change the meta * during replication etc. */ export declare function flatCloneDocWithMeta(doc: RxDocumentData): RxDocumentData; /** * Each event is labeled with the id * to make it easy to filter out duplicates * even on flattened eventBulks */ export declare function getUniqueDeterministicEventKey(eventBulkId: string, rowId: number, docId: string, writeRow: BulkWriteRow): string; export type WrappedRxStorageInstance = RxStorageInstance & { originalStorageInstance: RxStorageInstance; }; /** * Wraps the normal storageInstance of a RxCollection * to ensure that all access is properly using the hooks * and other data transformations and also ensure that database.lockedRun() * is used properly. */ export declare function getWrappedStorageInstance(database: RxDatabase<{}, Internals, InstanceCreationOptions>, storageInstance: RxStorageInstance, /** * The original RxJsonSchema * before it was mutated by hooks. */ rxJsonSchema: RxJsonSchema>): WrappedRxStorageInstance; /** * Each RxStorage implementation should * run this method at the first step of createStorageInstance() * to ensure that the configuration is correct. */ export declare function ensureRxStorageInstanceParamsAreCorrect(params: RxStorageInstanceCreationParams): void; export declare function hasEncryption(jsonSchema: RxJsonSchema): boolean;