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 Parameter | Default type | Description |
---|---|---|
ObjectMap extends Record <string , PlainObject > | DefaultObjectMap | A record type where keys are store names and values are plain objects representing the structure of stored data. Defaults to DefaultObjectMap. |
Constructors
Constructor
new ReactiveDatabaseIntrospector<ObjectMap>(): ReactiveDatabaseIntrospector<ObjectMap>;
Returns
ReactiveDatabaseIntrospector
<ObjectMap
>
Accessors
db
Get Signature
get db(): ReActiveDatabaseDexie<ObjectMap>;
Gets the Dexie database instance
Returns
ReActiveDatabaseDexie
<ObjectMap
>
encryption
Get Signature
get encryption(): Encryption;
Gets the Encryption instance used for data encryption
Returns
Encryption
errorBus
Get Signature
get errorBus(): TypedEventEmitter<ErrorBusEventMap>;
Gets the event emitter for error events
Returns
TypedEventEmitter
<ErrorBusEventMap
>
errorHandler
Get Signature
get errorHandler(): ErrorHandler;
Gets the ErrorHandler instance
Returns
isReady
Get Signature
get isReady(): boolean;
Gets whether the database is ready
Returns
boolean
logBus
Get Signature
get logBus(): TypedEventEmitter<LogBusEventMap>;
Gets the event emitter for logging events
Returns
TypedEventEmitter
<LogBusEventMap
>
logger
Get Signature
get logger(): Logger;
Gets the Logger instance
Returns
models
Get Signature
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
get options(): ReactiveDatabaseOptions<any>;
Gets the ReactiveDatabase configuration options
Returns
readyPromise
Get Signature
get readyPromise(): Promise<void>;
Gets the promise that resolves when the database is ready
Returns
Promise
<void
>
swarm
Get Signature
get swarm(): UnifiedEventBus;
Gets the Swarm instance used for state synchronization
Returns
UnifiedEventBus
Methods
$init()
$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
Parameter | Type | Description |
---|---|---|
options | () => ReactiveDatabaseOptions <ObjectMap > | Function that returns the ReactiveDatabase configuration options |
swarm | () => UnifiedEventBus | Function that returns the Swarm instance for state synchronization |
encryption | () => Encryption | Function 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 | () => Logger | Function that returns the Logger instance |
errorHandler | () => ErrorHandler | Function 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 | () => boolean | Function 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()
log<K>(level: Key<K, LogBusEventMap>, ...args: any[]): void;
Triggers a log to be emitted
Type Parameters
Type Parameter |
---|
K |
Parameters
Parameter | Type |
---|---|
level | Key <K , LogBusEventMap > |
...args | any [] |
Returns
void
makeModelPrototype()
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
Parameter | Type |
---|---|
model | Extract <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()
throw(err: Error): void;
Function which throws an error via the error handler
Parameters
Parameter | Type |
---|---|
err | Error |
Returns
void