import type { RxMigrationState } from './plugins/migration-schema/index.ts'; import { DocumentCache } from './doc-cache.ts'; import { QueryCache } from './query-cache.ts'; import { ChangeEventBuffer } from './change-event-buffer.ts'; import { Subscription, Observable, Subject } from 'rxjs'; import type { KeyFunctionMap, RxCollection, RxDatabase, RxQuery, RxDocument, RxDumpCollection, RxDumpCollectionAny, MangoQuery, MangoQueryNoLimit, RxCacheReplacementPolicy, RxStorageWriteError, RxChangeEvent, RxChangeEventInsert, RxChangeEventUpdate, RxChangeEventDelete, RxStorageInstance, CollectionsOfDatabase, RxChangeEventBulk, RxConflictHandler, MaybePromise, CRDTEntry, MangoQuerySelectorAndIndex, MigrationStrategies, WebMCPOptions, WebMCPLogEvent } from './types/index.d.ts'; import { RxSchema } from './rx-schema.ts'; import { WrappedRxStorageInstance } from './rx-storage-helper.ts'; import { IncrementalWriteQueue } from './incremental-write.ts'; import type { RxPipeline, RxPipelineOptions } from './plugins/pipeline/index.ts'; declare const HOOKS_WHEN: readonly ["pre", "post"]; type HookWhenType = typeof HOOKS_WHEN[number]; declare const HOOKS_KEYS: readonly ["insert", "save", "remove", "create"]; type HookKeyType = typeof HOOKS_KEYS[number]; export interface UpsertOptions { /** * When true, existing attachments not present in the upsert data * will be removed. Defaults to false (preserve existing attachments). */ deleteExistingAttachments?: boolean; } export declare const OPEN_COLLECTIONS: Set>; export declare class RxCollectionBase { readonly database: RxDatabase; name: string; schema: RxSchema; internalStorageInstance: RxStorageInstance; instanceCreationOptions: InstanceCreationOptions; migrationStrategies: MigrationStrategies; methods: KeyFunctionMap; attachments: KeyFunctionMap; options: any; cacheReplacementPolicy: RxCacheReplacementPolicy; statics: KeyFunctionMap; conflictHandler: RxConflictHandler; /** * Stores all 'normal' documents */ storageInstance: WrappedRxStorageInstance; readonly timeouts: Set>; incrementalWriteQueue: IncrementalWriteQueue; /** * Before reads, all these methods are awaited. Used to "block" reads * depending on other processes, like when the RxPipeline is running. */ readonly awaitBeforeReads: Set<() => MaybePromise>; constructor(database: RxDatabase, name: string, schema: RxSchema, internalStorageInstance: RxStorageInstance, instanceCreationOptions?: InstanceCreationOptions, migrationStrategies?: MigrationStrategies, methods?: KeyFunctionMap, attachments?: KeyFunctionMap, options?: any, cacheReplacementPolicy?: RxCacheReplacementPolicy, statics?: KeyFunctionMap, conflictHandler?: RxConflictHandler); get insert$(): Observable>; get update$(): Observable>; get remove$(): Observable>; _incrementalUpsertQueues: Map>; synced: boolean; hooks: { [key in HookKeyType]: { [when in HookWhenType]: { series: Function[]; parallel: Function[]; }; }; }; _subs: Subscription[]; _docCache: DocumentCache; _queryCache: QueryCache; $: Observable>; checkpoint$: Observable; _changeEventBuffer: ChangeEventBuffer; /** * Internally only use eventBulks$ * Do not use .$ or .observable$ because that has to transform * the events which decreases performance. */ readonly eventBulks$: Observable>; /** * When the collection is closed, * these functions will be called an awaited. * Used to automatically clean up stuff that * belongs to this collection. */ onClose: (() => MaybePromise)[]; closed: boolean; onRemove: (() => MaybePromise)[]; prepare(): Promise; /** * Manually call the cleanup function of the storage. * @link https://rxdb.info/cleanup.html */ cleanup(_minimumDeletedTime?: number): Promise; migrationNeeded(): Promise; getMigrationState(): RxMigrationState; startMigration(batchSize?: number): Promise; migratePromise(batchSize?: number): Promise; insert(json: RxDocumentType | RxDocument): Promise>; insertIfNotExists(json: RxDocumentType | RxDocument): Promise>; bulkInsert(docsData: RxDocumentType[]): Promise<{ success: RxDocument[]; error: RxStorageWriteError[]; }>; bulkRemove( /** * You can either remove the documents by their ids * or by directly providing the RxDocument instances * if you have them already. This improves performance a bit. */ idsOrDocs: string[] | RxDocument[]): Promise<{ success: RxDocument[]; error: RxStorageWriteError[]; }>; /** * same as bulkInsert but overwrites existing document with same primary */ bulkUpsert(docsData: Partial[], options?: UpsertOptions): Promise<{ success: RxDocument[]; error: RxStorageWriteError[]; }>; /** * same as insert but overwrites existing document with same primary */ upsert(json: Partial, options?: UpsertOptions): Promise>; /** * upserts to a RxDocument, uses incrementalModify if document already exists */ incrementalUpsert(json: Partial, options?: UpsertOptions): Promise>; find(queryObj?: MangoQuery): RxQuery[], OrmMethods, Reactivity>; findOne(queryObj?: MangoQueryNoLimit | string): RxQuery | null, OrmMethods, Reactivity>; count(queryObj?: MangoQuerySelectorAndIndex): RxQuery; /** * find a list documents by their primary key * has way better performance then running multiple findOne() or a find() with a complex $or-selected */ findByIds(ids: string[]): RxQuery>, OrmMethods, Reactivity>; /** * Export collection to a JSON friendly format. */ exportJSON(): Promise>; exportJSON(): Promise>; /** * Import the parsed JSON export into the collection. * @param _exportedJSON The previously exported data from the `.exportJSON()` method. */ importJSON(_exportedJSON: RxDumpCollectionAny): Promise; registerWebMCP(_options?: WebMCPOptions): { error$: Subject; log$: Subject; }; insertCRDT(_updateObj: CRDTEntry | CRDTEntry[]): RxDocument; addPipeline(_options: RxPipelineOptions): Promise>; /** * HOOKS */ addHook(when: HookWhenType, key: HookKeyType, fun: any, parallel?: boolean): void; getHooks(when: HookWhenType, key: HookKeyType): { series: Function[]; parallel: Function[]; }; hasHooks(when: HookWhenType, key: HookKeyType): boolean; _runHooks(when: HookWhenType, key: HookKeyType, data: any, instance?: any): Promise; /** * does the same as ._runHooks() but with non-async-functions */ _runHooksSync(when: HookWhenType, key: HookKeyType, data: any, instance: any): void; /** * Returns a promise that resolves after the given time. * Ensures that is properly cleans up when the collection is closed * so that no running timeouts prevent the exit of the JavaScript process. */ promiseWait(time: number): Promise; close(): Promise; /** * remove all data of the collection */ remove(): Promise; get asRxCollection(): RxCollection; } /** * creates and prepares a new collection */ export declare function createRxCollection({ database, name, schema, instanceCreationOptions, migrationStrategies, autoMigrate, statics, methods, attachments, options, localDocuments, cacheReplacementPolicy, conflictHandler, storageInstance }: any): Promise; export declare function isRxCollection(obj: any): boolean; export {};