/** * MQTT Source Trait * * Subscribe to MQTT topics and bind incoming messages to object state. * Supports wildcard subscriptions, QoS levels, and automatic JSON parsing. * * @version 1.0.0 */ import type { TraitHandler, HSPlusNode } from '@holoscript/core'; import { MQTTClient, type QoS } from '@holoscript/engine/runtime/protocols/MQTTClient'; export interface MQTTSourceConfig { /** MQTT broker URL */ broker: string; /** Topic pattern to subscribe (supports + and # wildcards) */ topic: string; /** QoS level (0, 1, or 2) */ qos: QoS; /** Client ID (optional, auto-generated if not provided) */ clientId?: string; /** Username for authentication */ username?: string; /** Password for authentication */ password?: string; /** Auto-parse JSON payloads */ parseJson?: boolean; /** Field to store received value (default: 'value') */ stateField?: string; /** Transform function name to apply to incoming messages */ transform?: string; /** Debounce interval in ms */ debounce?: number; /** Auto-connect on attach */ autoConnect?: boolean; } export interface MQTTSourceState { /** Whether connected to broker */ connected: boolean; /** Last received message */ lastMessage: unknown; /** Last message timestamp */ lastReceived: number; /** Total messages received */ messageCount: number; /** Connection error if any */ error: string | null; /** MQTT client instance */ client: MQTTClient | null; } export declare const mqttSourceHandler: TraitHandler; /** * Check if a node has the @mqtt_source trait */ export declare function hasMQTTSourceTrait(node: HSPlusNode): boolean; /** * Get the MQTT source state from a node */ export declare function getMQTTSourceState(node: HSPlusNode): MQTTSourceState | null; /** * Get the MQTT client from a node with @mqtt_source trait */ export declare function getMQTTSourceClient(node: HSPlusNode): MQTTClient | null; /** * Check if MQTT source is connected */ export declare function isMQTTSourceConnected(node: HSPlusNode): boolean; export default mqttSourceHandler; //# sourceMappingURL=MQTTSourceTrait.d.ts.map