Skip to content

Class: ReactiveDatabaseIntrospector<ObjectMap> ​

A testing utility class that provides access to the private members of the ReactiveDatabase class. This class is designed to help with testing by exposing internal state that would otherwise be inaccessible due to TypeScript's private field declarations.

Type Parameters ​

Type ParameterDefault typeDescription
ObjectMap extends Record<string, PlainObject>DefaultObjectMapA record type where keys are store names and values are plain objects representing the structure of stored data. Defaults to DefaultObjectMap.

Constructors ​

Constructor ​

ts
new ReactiveDatabaseIntrospector<ObjectMap>(): ReactiveDatabaseIntrospector<ObjectMap>;

Returns ​

ReactiveDatabaseIntrospector<ObjectMap>

Accessors ​

db ​

Get Signature ​

ts
get db(): ReActiveDatabaseDexie<ObjectMap>;

Gets the Dexie database instance

Returns ​

ReActiveDatabaseDexie<ObjectMap>


encryption ​

Get Signature ​

ts
get encryption(): Encryption;

Gets the Encryption instance used for data encryption

Returns ​

Encryption


errorBus ​

Get Signature ​

ts
get errorBus(): TypedEventEmitter<ErrorBusEventMap>;

Gets the event emitter for error events

Returns ​

TypedEventEmitter<ErrorBusEventMap>


errorHandler ​

Get Signature ​

ts
get errorHandler(): ErrorHandler;

Gets the ErrorHandler instance

Returns ​

ErrorHandler


isReady ​

Get Signature ​

ts
get isReady(): boolean;

Gets whether the database is ready

Returns ​

boolean


logBus ​

Get Signature ​

ts
get logBus(): TypedEventEmitter<LogBusEventMap>;

Gets the event emitter for logging events

Returns ​

TypedEventEmitter<LogBusEventMap>


logger ​

Get Signature ​

ts
get logger(): Logger;

Gets the Logger instance

Returns ​

Logger


models ​

Get Signature ​

ts
get models(): Map<StringKeyOf<ObjectMap>, ReactiveModelConstructor<ObjectMap, ObjectMap[StringKeyOf<ObjectMap>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["primaryKey"], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["relationships"], Required<
  | undefined
  | {
  wrapReactiveModel: WrapReactiveModelHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<..., ...>], string>, Record<string, RelationshipConfiguration>>;
  wrapReactiveQueryCollection: WrapReactiveQueryCollectionHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<..., ...>], string>, Record<string, RelationshipConfiguration>, any>;
  wrapReactiveQueryResult: WrapReactiveQueryResultHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<..., ...>], string>, Record<string, RelationshipConfiguration>, any>;
}>>>;

Gets the map of model constructors

Returns ​

Map<StringKeyOf<ObjectMap>, ReactiveModelConstructor<ObjectMap, ObjectMap[StringKeyOf<ObjectMap>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["primaryKey"], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["relationships"], Required< | undefined | { wrapReactiveModel: WrapReactiveModelHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<..., ...>], string>, Record<string, RelationshipConfiguration>>; wrapReactiveQueryCollection: WrapReactiveQueryCollectionHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<..., ...>], string>, Record<string, RelationshipConfiguration>, any>; wrapReactiveQueryResult: WrapReactiveQueryResultHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<..., ...>], string>, Record<string, RelationshipConfiguration>, any>; }>>>


options ​

Get Signature ​

ts
get options(): ReactiveDatabaseOptions<any>;

Gets the ReactiveDatabase configuration options

Returns ​

ReactiveDatabaseOptions<any>


readyPromise ​

Get Signature ​

ts
get readyPromise(): Promise<void>;

Gets the promise that resolves when the database is ready

Returns ​

Promise<void>


swarm ​

Get Signature ​

ts
get swarm(): UnifiedEventBus;

Gets the Swarm instance used for state synchronization

Returns ​

UnifiedEventBus

Methods ​

$init() ​

ts
$init(
   options: () => ReactiveDatabaseOptions<ObjectMap>,
   swarm: () => UnifiedEventBus,
   encryption: () => Encryption,
   logBus: () => TypedEventEmitter<LogBusEventMap>,
   errorBus: () => TypedEventEmitter<ErrorBusEventMap>,
   logger: () => Logger,
   errorHandler: () => ErrorHandler,
   db: () => ReActiveDatabaseDexie<ObjectMap>,
   models: () => Map<StringKeyOf<ObjectMap>, ReactiveModelConstructor<ObjectMap, ObjectMap[StringKeyOf<ObjectMap>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["primaryKey"], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["relationships"], Required<
  | undefined
  | {
  wrapReactiveModel: WrapReactiveModelHook<ObjectMap[Extract<keyof ..., string>], Extract<keyof ...[...], string>, Record<string, RelationshipConfiguration>>;
  wrapReactiveQueryCollection: WrapReactiveQueryCollectionHook<ObjectMap[Extract<keyof ..., string>], Extract<keyof ...[...], string>, Record<string, RelationshipConfiguration>, any>;
  wrapReactiveQueryResult: WrapReactiveQueryResultHook<ObjectMap[Extract<keyof ..., string>], Extract<keyof ...[...], string>, Record<string, RelationshipConfiguration>, any>;
}>>>,
   readyPromise: () => Promise<void>,
   isReady: () => boolean,
   $log: <K>(level: Key<K, LogBusEventMap>, ...args: any[]) => void,
   $throw: (err: Error) => void,
   $makeModelPrototype: (model: StringKeyOf<ObjectMap>) => ReactiveModelConstructor<ObjectMap, ObjectMap[StringKeyOf<ObjectMap>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["primaryKey"]>): void;

Initializes the ReactiveDatabaseIntrospector instance with the accessors for the private members

Parameters ​

ParameterTypeDescription
options() => ReactiveDatabaseOptions<ObjectMap>Function that returns the ReactiveDatabase configuration options
swarm() => UnifiedEventBusFunction that returns the Swarm instance for state synchronization
encryption() => EncryptionFunction that returns the Encryption instance
logBus() => TypedEventEmitter<LogBusEventMap>Function that returns the logging event emitter
errorBus() => TypedEventEmitter<ErrorBusEventMap>Function that returns the error event emitter
logger() => LoggerFunction that returns the Logger instance
errorHandler() => ErrorHandlerFunction that returns the ErrorHandler instance
db() => ReActiveDatabaseDexie<ObjectMap>Function that returns the Dexie database instance
models() => Map<StringKeyOf<ObjectMap>, ReactiveModelConstructor<ObjectMap, ObjectMap[StringKeyOf<ObjectMap>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["primaryKey"], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["relationships"], Required< | undefined | { wrapReactiveModel: WrapReactiveModelHook<ObjectMap[Extract<keyof ..., string>], Extract<keyof ...[...], string>, Record<string, RelationshipConfiguration>>; wrapReactiveQueryCollection: WrapReactiveQueryCollectionHook<ObjectMap[Extract<keyof ..., string>], Extract<keyof ...[...], string>, Record<string, RelationshipConfiguration>, any>; wrapReactiveQueryResult: WrapReactiveQueryResultHook<ObjectMap[Extract<keyof ..., string>], Extract<keyof ...[...], string>, Record<string, RelationshipConfiguration>, any>; }>>>Function that returns the map of model constructors
readyPromise() => Promise<void>Function that returns the database ready promise
isReady() => booleanFunction that returns the database ready state
$log<K>(level: Key<K, LogBusEventMap>, ...args: any[]) => void-
$throw(err: Error) => void-
$makeModelPrototype(model: StringKeyOf<ObjectMap>) => ReactiveModelConstructor<ObjectMap, ObjectMap[StringKeyOf<ObjectMap>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[StringKeyOf<ObjectMap>]["primaryKey"]>-

Returns ​

void


log() ​

ts
log<K>(level: Key<K, LogBusEventMap>, ...args: any[]): void;

Triggers a log to be emitted

Type Parameters ​

Type Parameter
K

Parameters ​

ParameterType
levelKey<K, LogBusEventMap>
...argsany[]

Returns ​

void


makeModelPrototype() ​

ts
makeModelPrototype(model: Extract<keyof ObjectMap>): ReactiveModelConstructor<ObjectMap, ObjectMap[Extract<keyof ObjectMap, string>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[Extract<keyof ObjectMap, string>]["primaryKey"], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[Extract<keyof ObjectMap, string>]["relationships"], Required<
  | undefined
  | {
  wrapReactiveModel: WrapReactiveModelHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<keyof ..., string>], string>, Record<string, RelationshipConfiguration>>;
  wrapReactiveQueryCollection: WrapReactiveQueryCollectionHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<keyof ..., string>], string>, Record<string, RelationshipConfiguration>, any>;
  wrapReactiveQueryResult: WrapReactiveQueryResultHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<keyof ..., string>], string>, Record<string, RelationshipConfiguration>, any>;
}>>;

Function which makes a model constructor for the specified model

Parameters ​

ParameterType
modelExtract<keyof ObjectMap>

Returns ​

ReactiveModelConstructor<ObjectMap, ObjectMap[Extract<keyof ObjectMap, string>], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[Extract<keyof ObjectMap, string>]["primaryKey"], { [K in string]: ReactiveDatabaseModelDefinition<ObjectMap[K]> }[Extract<keyof ObjectMap, string>]["relationships"], Required< | undefined | { wrapReactiveModel: WrapReactiveModelHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<keyof ..., string>], string>, Record<string, RelationshipConfiguration>>; wrapReactiveQueryCollection: WrapReactiveQueryCollectionHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<keyof ..., string>], string>, Record<string, RelationshipConfiguration>, any>; wrapReactiveQueryResult: WrapReactiveQueryResultHook<ObjectMap[Extract<keyof ObjectMap, string>], Extract<keyof ObjectMap[Extract<keyof ..., string>], string>, Record<string, RelationshipConfiguration>, any>; }>>


throw() ​

ts
throw(err: Error): void;

Function which throws an error via the error handler

Parameters ​

ParameterType
errError

Returns ​

void