import { MigrationState, RxCollection, RxDumpCollection, RxDumpCollectionAsAny } from 'nxdb-old/src/types/rx-collection'; import { RxDatabaseBase } from 'nxdb-old/src/rx-database'; import { Observable } from 'rxjs'; import { RxStorage } from 'nxdb-old/src/types/rx-storage.interface'; import { RxLocalDocument } from 'nxdb-old/src/types/plugins/local-documents'; import { RxCleanupPolicy } from 'nxdb-old/src/types/plugins/cleanup'; import { HashFunction } from 'nxdb-old/src/types/util'; export interface RxDatabaseCreator { storage: RxStorage; instanceCreationOptions?: InstanceCreationOptions; name: string; password?: string | any; multiInstance?: boolean; eventReduce?: boolean; ignoreDuplicate?: boolean; options?: any; cleanupPolicy?: Partial; /** * Set this to true if you want to store local documents * in the RxDatabase instance. */ localDocuments?: boolean; /** * Hash method used to hash strings and json-stringified objects. * This hash does not have to be cryptographically secure, * but it is very important that is does have not create * collisions. * Default is the sha256 from the ohash library * @link https://www.npmjs.com/package/ohash */ hashFunction?: HashFunction; /** * By default, count() queries in 'slow' mode are not allowed. */ allowSlowCount?: boolean; } export type CollectionsOfDatabase = { [key: string]: RxCollection; }; export type RxDatabase< Collections = CollectionsOfDatabase, Internals = any, InstanceCreationOptions = any, > = RxDatabaseBase< Internals, InstanceCreationOptions, Collections > & Collections & RxDatabaseGenerated; export type AllMigrationStates = { collection: RxCollection; state: MigrationState; }[]; export interface RxLocalDocumentMutation { insertLocal(id: string, data: LocalDocType): Promise< RxLocalDocument >; upsertLocal(id: string, data: LocalDocType): Promise< RxLocalDocument >; getLocal(id: string): Promise< RxLocalDocument | null >; getLocal$(id: string): Observable< RxLocalDocument | null >; } export interface RxDatabaseGenerated extends RxLocalDocumentMutation> { } /** * Extract the **DocumentType** of a collection. */ type ExtractDTcol

= P extends RxCollection ? T : { [prop: string]: any; }; interface RxDumpDatabaseBase { instanceToken: string; name: string; passwordHash: string | null; } export interface RxDumpDatabase extends RxDumpDatabaseBase { collections: RxDumpCollection>[]; } /** * All base properties are typed as any because they can be encrypted. */ export interface RxDumpDatabaseAny extends RxDumpDatabaseBase { collections: RxDumpCollection>>[]; }