Interface TroubleModel<AdditionalData>

Represents a trouble (issue, alert, or condition) in the KOS system.

TroubleModel is the core interface for managing system issues, warnings, and alerts throughout the KOS platform. It provides a unified way to track, display, resolve, and defer various types of operational issues.

Key Features

  • Priority ranking - Troubles are ranked 1-10 for severity
  • Role-based visibility - Troubles can be filtered by user role
  • Resolution support - Resolvable troubles can be cleared through actions
  • Deferral capability - Troubles can be temporarily deferred
  • Future integration - Async resolution through futures
  • Type categorization - Troubles grouped by type for filtering
  • Visual indicators - Color coding for UI representation

Example: Basic Usage

function handleTrouble(trouble: TroubleModel) {
if (trouble.rank >= 8) {
console.error(`Critical trouble: ${trouble.reason}`);
}

if (trouble.resolvable) {
const futureResponse = await trouble.resolve();
}
}

Use Declared Type

See

interface TroubleModel<AdditionalData> {
    id: string;
    ifaces: string[];
    clientData: unknown;
    type: string;
    tags: string[];
    info: unknown;
    rawId: string;
    resolve: (() => Promise<undefined | FutureResponse>);
    data: AdditionalData;
    rank: number;
    role: string;
    color: string;
    deferred: boolean;
    shouldDefer: boolean;
    defer: VoidFunction;
    clearDefer: VoidFunction;
    resolvable?: boolean;
    reason?: string;
    createTime?: string;
    future?: IFutureModel<Record<string, unknown>>;
    group?: string;
}

Type Parameters

  • AdditionalData extends object = any

    Type parameter for domain-specific trouble data

Hierarchy (view full)

Properties

id: string

Unique identifier for the trouble instance

ifaces: string[]

List of interface identifiers this trouble affects

clientData: unknown

Client-specific data attached to the trouble

type: string

Classification type of the trouble (e.g., 'ERROR', 'WARNING', 'INFO')

tags: string[]

Searchable tags for categorizing troubles

info: unknown

Additional information about the trouble state

rawId: string

Original trouble ID before any transformations

resolve: (() => Promise<undefined | FutureResponse>)

Resolves the trouble, returning a promise with the resolution response

Type declaration

Domain-specific additional data attached to the trouble

rank: number

Priority rank from 1-10 (10 being most critical)

role: string

User role required to view/resolve this trouble

color: string

Display color for UI representation (e.g., 'red', 'yellow', 'orange')

deferred: boolean

Whether this trouble has been deferred

shouldDefer: boolean

Whether this item should be deferred based on current conditions

defer: VoidFunction

Defers the item, preventing normal processing

clearDefer: VoidFunction

Clears the deferral, allowing normal processing to resume

resolvable?: boolean

Whether this trouble can be resolved through user action

reason?: string

Human-readable description of why the trouble occurred

createTime?: string

ISO timestamp when the trouble was created

future?: IFutureModel<Record<string, unknown>>

Associated future for async resolution operations

group?: string

Optional grouping identifier for related troubles