Open MercatoDocsSearch docsAPI reference

Framework

configs module

A module can persist a preference under its module ID and setting name. Read it through the configuration helper and write it through the same service so cached values are invalidated when an administrator changes the setting.

Storage model

ModuleConfig records are keyed by { module_id, name } and store a JSON payload in value_json. Rows also track created_at/updated_at timestamps so background syncs can detect stale values. The shared cache tag module-config:module:<module_id> keeps lookups fast while allowing targeted invalidation.

@Entity({ tableName: 'module_configs' })
@Unique({ name: 'module_configs_module_name_unique', properties: ['moduleId', 'name'] })
export class ModuleConfig {
  @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
  id!: string

  @Property({ name: 'module_id', type: 'text' })
  moduleId!: string

  @Property({ name: 'name', type: 'text' })
  name!: string

  @Property({ name: 'value_json', type: 'json', nullable: true })
  valueJson!: unknown
}

Runtime helpers

The DI registrar exposes a singleton moduleConfigService with the following surface:

Every call automatically resolves the request-scoped EntityManager and the configured cache strategy (memory/Redis/sqlite/JSON). Consumers can safely call these helpers from APIs, subscribers, or CLIs without managing transactions or cache keys manually.

Admin diagnostics

The configs module also owns operational diagnostics under Backend → Configuration:

Module telemetry is collected in-process for API routes, event subscribers, queue workers, and explicit withModuleResourceUsage wrappers. Buckets are currently 5 minutes, carry their own bucketIntervalMs, and are visible only on the local instance through the admin view.

Default seeding & automation

Usage example: vector search auto-indexing

The vector module reads moduleConfigService.getValue('vector', 'auto_index_enabled', { defaultValue: true }) inside its subscribers before running expensive embedding work. A backend settings page at /backend/vector-search exposes the toggle through /api/vector/settings, so operators can pause real-time indexing without redeploying the app.

Previous: Communications Hub · Next: Core Modules