ConfigBean - Reactive hierarchical configuration management for KOS devices.

The ConfigBean model provides reactive access to hierarchical configuration data from KOS devices with real-time synchronization via WebSocket topics, schema-based validation, and transactional updates. Essential for building configuration interfaces and managing device operational parameters.

Key Features

  • Hierarchical Configuration - Access nested configuration structures using path notation
  • Real-Time Synchronization - Automatic updates via /kos/config/{path} WebSocket topic
  • Schema-Based Validation - Built-in validation using device configuration schemas
  • Transactional Updates - Atomic configuration changes with rollback support
  • Type-Safe Access - Strongly typed property access with TypeScript support
  • Reactive Properties - Automatic UI updates when configuration changes

Configuration Path Patterns

ConfigBean supports hierarchical paths that mirror device system organization:

  • System Level: system:app - Machine identity, operational modes
  • Service Level: kos:service:CANPumpMgr - KOS service configurations
  • Hardware Level: assembly:core:board:macro:pump:water - Component settings
  • Application Level: app:scheduling:dayWiseLockConfigMap - Application-specific settings

Common Use Cases

  • Configuration Interfaces - Build reactive configuration management screens
  • Operational Parameter Control - Real-time adjustment of device behavior
  • Schema-Driven Forms - Generate configuration UIs from device schemas
  • System Administration - Centralized device configuration management
  • Bulk Configuration Updates - Transactional updates across multiple properties

Example: Basic Configuration Management

const systemConfig = ConfigBean.instance('system-config')
.options({ path: 'system:app' })
.build();

// Access current configuration values
const machineId = systemConfig.values.machineId;
const debugMode = systemConfig.values.debugMode;

// Update configuration properties
await systemConfig.updateProperty('debugMode', true);
await systemConfig.updateProperty('machineId', 'MACHINE-001');

Use Declared Type

See

  • IConfigBeanModelOptions - Configuration options for ConfigBean instances
  • ConfigBeanKeys - Type-safe property key access
  • ConfigPropertyTypes - Supported configuration property types
interface IConfigBeanModel<T> {
    id: string;
    path: string;
    props: KosData<Record<keyof T, unknown>>;
    prevProps: KosData<Record<keyof T, unknown>>;
    getSchemaForProperty(key): undefined | SchemaNodeDef;
    updateProperty(key, value): Promise<void>;
    updateConfigBean(): Promise<void>;
    handleConfigBeanUpdated(configBean): void;
    serviceBasePath?: string;
}

Type Parameters

  • T extends {} = any

Methods - Action

Methods - Other

Methods - Subscription Updates the Config Bean model when a `/kos/config/{path}` event is received from the server.

Properties

Methods - Action

  • Updates a specific configuration property value.

    Parameters

    • key: keyof T

      The configuration property key to update

    • value: unknown

      The new value to set for the property

    Returns Promise<void>

    Example: Update Configuration Property

    await systemConfig.updateProperty('debugMode', true);
    await systemConfig.updateProperty('machineId', 'MACHINE-001');
  • Returns Promise<void>

    Remark

    Updates the current Config Bean representation in the backend.

    If a service was passed in as part of the options in the constructor then it will be used. Otherwise the default services will be invoked.

    See

    modifyConfigBeanService

Methods - Other

  • Retrieves schema definition for a specific property.

    Parameters

    • key: string

      Property key to get schema for

    Returns undefined | SchemaNodeDef

    Schema definition if found, undefined otherwise

    Example: Get Property Schema

    const schema = systemConfig.getSchemaForProperty('debugMode');
    if (schema) {
    console.log('Type:', schema.type);
    console.log('Description:', schema.description);
    }

Methods - Subscription Updates the Config Bean model when a `/kos/config/{path}` event is received from the server.

  • Parameters

    • configBean: ConfigBeanUpdateResponse

      the Config Bean that was updated.

    Returns void

    See

    ConfigBeanResponse

Properties

id: string

Unique identifier for this configuration model instance

path: string

Hierarchical configuration path (e.g., 'system:app', 'kos:service:CANPumpMgr')

props: KosData<Record<keyof T, unknown>>

Observable configuration properties with current values

prevProps: KosData<Record<keyof T, unknown>>

Observable configuration properties with previous values (before last update)

serviceBasePath?: string

Optional custom base path for configuration service endpoints