Skip to main content

Class: InMemoryModelRegistryRepository

Defined in: adapters/in-memory/InMemoryModelRegistryRepository.ts:24

InMemoryModelRegistryRepository -- the model catalog in a Map, for tests and the sandbox

About​

Behaves like a database without one: copies in and out.

Implements IModelRegistryRepository so the ModelRegistry runs with no infrastructure. One entry per model id; the constructor seeds the catalog a setup wants present from the start.

Who needs it​

The gateway tests (gatewayConfigBase), the dev sandbox and the cookbook's first run; a host app uses its own adapter.

Pitfalls​

Production: nothing survives the process, nothing is shared between processes.

Implements​

Constructors​

Constructor​

new InMemoryModelRegistryRepository(__namedParameters?): InMemoryModelRegistryRepository

Defined in: adapters/in-memory/InMemoryModelRegistryRepository.ts:27

Parameters​

__namedParameters?​
models?​

IModelInfo[] = []

Entries present from the start, as if saved before; a dev or test setup seeds its catalog here.

Returns​

InMemoryModelRegistryRepository

Methods​

loadAll()​

loadAll(): Promise<IModelInfo[]>

Defined in: adapters/in-memory/InMemoryModelRegistryRepository.ts:49

loadAll -- every model entry

About​

The whole catalog, for the registry's cache.

Returns every stored entry, in any order.

Who needs it​

ModelRegistry.getCatalog, on a refresh.

Returns​

Promise<IModelInfo[]>

Implementation of​

IModelRegistryRepository.loadAll


remove()​

remove(__namedParameters): Promise<void>

Defined in: adapters/in-memory/InMemoryModelRegistryRepository.ts:85

remove -- deletes one entry

About​

Permanent; nothing when it does not exist.

Removes the entry with this id.

Who needs it​

ModelRegistry.removeModel.

Parameters​

__namedParameters​
modelId​

string

Returns​

Promise<void>

Implementation of​

IModelRegistryRepository.remove


save()​

save(__namedParameters): Promise<void>

Defined in: adapters/in-memory/InMemoryModelRegistryRepository.ts:66

save -- inserts or replaces one entry

About​

Upsert by model.id.

The entry is stored whole; an entry with the same id is replaced.

Who needs it​

ModelRegistry.upsertModel and setEnabled.

Parameters​

__namedParameters​
model​

IModelInfo

Returns​

Promise<void>

Implementation of​

IModelRegistryRepository.save