declare namespace MasterModel {
  interface SearchLogPaginationBody extends SearchPaginationBody {
    from?: number;
    to?: number;
    publisher?: string;
    subtopic?: string;
  }

  interface MessageBasicInfo {
    channel?: string;
    subtopic?: string;
    publisher?: string;
    protocol?: string;
    name?: string;
    time?: number;
  }

  type LogTypeRequest = 'user_logs' | undefined;

  interface MesageReaderResponse<T = MessageDataType> {
    offset?: number;
    limit?: number;
    publisher?: string;
    from?: number;
    to?: number;
    format?: string;
    total?: number;
    messages?: Message<T>[];
  }

  // Response types cho từng domain
  type CameraMessageResponse = MesageReaderResponse<CameraV5>;
  type CameraV6MessageResponse = MesageReaderResponse<CameraV6>;
  type AlarmMessageResponse = MesageReaderResponse<Alarm>;
  type NodeConfigMessageResponse = MesageReaderResponse<NodeConfig[]>;

  type MessageDataType = NodeConfig[] | CameraV5 | CameraV6;

  interface Message<T = MessageDataType> extends MessageBasicInfo {
    string_value?: string;
    string_value_parsed?: T;
  }

  // Message types cho từng domain
  type CameraMessage = Message<CameraV5>;
  type CameraV6Message = Message<CameraV6>;
  type NodeConfigMessage = Message<NodeConfig[]>;

  interface CameraV5 {
    cams?: Camera[];
  }
  interface CameraV6 extends CameraV5 {
    record_type?: 'none' | 'alarm' | 'all';
    record_alarm_list?: string[];
  }

  interface Camera {
    id?: string;
    name?: string;
    cate_id?: string;
    username?: string;
    password?: string;
    rtsp_port?: number;
    http_port?: number;
    channel?: number;
    ip?: string;
    stream?: number;
  }

  interface Alarm {
    id: string;
    type: Type;
    name: string;
  }

  interface SensorLogMessage extends MessageBasicInfo {
    unit: string;
    value: number;
  }
}
