• Class decorator that automatically adds TroubleAware capabilities to a KOS model.

    This decorator eliminates the need for manual TroubleAware interface implementation by:

    • Adding troubleContainer dependency injection (internal, not exposed)
    • Adding troubles getter that filters by model path
    • Adding troubleStatus getter (returns empty string by default)
    • Adding troublesByType getter that groups troubles by type

    Important: Use TypeScript interface merging to get proper type information:

    // Add ESLint disable comment at top of file, then:
    interface MyModelImpl extends TroubleAware {}

    @kosTroubleAware()
    class MyModelImpl implements IKosDataModel {
    path: string; // Required for trouble resolution

    constructor(modelId: string, options: MyOptions) {
    this.path = options.path;
    // All TroubleAware properties are now available with full type safety
    }
    }

    The decorator requires the model to have a path property (default) or specify a custom path property via options.

    Parameters

    • Optional options: KosTroubleAwareOptions

      Configuration options for the decorator

    Returns ClassDecorator

    A class decorator

    Example

    // Default usage - uses this.path
    interface HolderModelImpl extends TroubleAware {}

    @kosTroubleAware()
    class HolderModelImpl implements IKosDataModel {
    path: string; // Required for trouble path resolution

    constructor(modelId: string, options: HolderOptions) {
    this.path = options.path;
    }
    }

    // Custom path property
    interface CustomModelImpl extends TroubleAware {}

    @kosTroubleAware({ pathProperty: 'devicePath' })
    class CustomModelImpl implements IKosDataModel {
    devicePath: string; // Custom path property

    constructor(modelId: string, options: CustomOptions) {
    this.devicePath = options.devicePath;
    }
    }

    // Type-safe external interface
    export type HolderModel = PublicModelInterface<HolderModelImpl> & TroubleAware;

    Since

    2.0.0