UNPKG

@sailboat-computer/validation

Version:

Validation framework for sailboat computer v3

266 lines 6.87 kB
/** * Interface-specific validation contexts * * This file defines validation contexts specialized for different hardware interfaces. * These contexts extend the base ValidationContext with interface-specific properties. */ import { ValidationContext } from '../types'; /** * Signal K specific validation context * * Extends the base validation context with Signal K specific properties * to enable validation rules that leverage Signal K metadata and structure. */ export interface SignalKValidationContext extends ValidationContext { /** * Signal K delta update object */ signalKDelta?: any | undefined; /** * Signal K self object containing vessel information */ signalKSelf?: any | undefined; /** * Signal K source identifier */ signalKSource?: string | undefined; /** * Signal K path being validated */ signalKPath?: string | undefined; /** * Signal K update object */ signalKUpdate?: any | undefined; /** * Signal K source metadata */ signalKSourceMetadata?: Record<string, any> | undefined; /** * Signal K update timestamp */ signalKTimestamp?: Date | undefined; /** * Signal K path metadata */ signalKPathMetadata?: any | undefined; /** * Signal K source definition */ signalKSourceDefinition?: any | undefined; /** * Signal K path history (recent values for the same path) */ signalKPathHistory?: Array<{ timestamp: Date; value: any; source: string; }> | undefined; /** * Signal K related paths (other paths that are related to this one) */ signalKRelatedPaths?: Record<string, any> | undefined; /** * Signal K vessel context */ signalKVesselContext?: { mmsi?: string; name?: string; length?: number; beam?: number; draft?: number; type?: string; design?: { aisShipType?: number; callsign?: string; }; } | undefined; } /** * I2C specific validation context * * Extends the base validation context with I2C specific properties * to enable validation rules that leverage I2C device characteristics. */ export interface I2CValidationContext extends ValidationContext { /** * I2C device address */ deviceAddress: number; /** * I2C device type identifier */ deviceType: string; /** * I2C bus number */ busNumber: number; /** * Register map for the I2C device */ registerMap?: Record<string, any> | undefined; /** * Calibration data for the I2C device */ calibrationData?: Record<string, any> | undefined; /** * Device-specific configuration */ deviceConfig?: Record<string, any> | undefined; /** * Raw register values */ rawRegisters?: Record<number, number> | undefined; } /** * MQTT/Victron specific validation context * * Extends the base validation context with MQTT specific properties * to enable validation rules that leverage MQTT message characteristics. */ export interface MQTTValidationContext extends ValidationContext { /** * MQTT topic */ topic: string; /** * MQTT topic parts (split by '/') */ topicParts: string[]; /** * Device identifier extracted from topic */ deviceId: string; /** * Device type extracted from topic */ deviceType: string; /** * Message type extracted from topic */ messageType: string; /** * MQTT QoS level */ qos: number; /** * MQTT message retention flag */ retained?: boolean | undefined; /** * MQTT broker identifier */ brokerId?: string | undefined; } /** * GPIO specific validation context * * Extends the base validation context with GPIO specific properties * to enable validation rules that leverage GPIO characteristics. */ export interface GPIOValidationContext extends ValidationContext { /** * GPIO pin number */ pinNumber: number; /** * GPIO pin direction */ pinDirection: 'in' | 'out'; /** * GPIO pin mode */ pinMode: 'digital' | 'analog'; /** * Previous pin state */ previousState?: number | undefined; /** * Time of last state change */ stateChangeTime?: number | undefined; /** * Debounce configuration */ debounceConfig?: { time: number; count: number; } | undefined; /** * Pull resistor configuration */ pullConfig?: 'up' | 'down' | 'none' | undefined; /** * Edge detection configuration */ edgeConfig?: 'rising' | 'falling' | 'both' | 'none' | undefined; } /** * Create a Signal K validation context * * @param baseContext Base validation context * @param signalKData Signal K specific data * @returns Signal K validation context */ export declare function createSignalKContext(baseContext: ValidationContext, signalKData: { path?: string; source?: string; delta?: any; self?: any; update?: any; sourceMetadata?: Record<string, any>; timestamp?: Date; }): SignalKValidationContext; /** * Create an I2C validation context * * @param baseContext Base validation context * @param i2cData I2C specific data * @returns I2C validation context */ export declare function createI2CContext(baseContext: ValidationContext, i2cData: { deviceAddress: number; deviceType: string; busNumber: number; registerMap?: Record<string, any>; calibrationData?: Record<string, any>; deviceConfig?: Record<string, any>; rawRegisters?: Record<number, number>; }): I2CValidationContext; /** * Create an MQTT validation context * * @param baseContext Base validation context * @param mqttData MQTT specific data * @returns MQTT validation context */ export declare function createMQTTContext(baseContext: ValidationContext, mqttData: { topic: string; deviceId: string; deviceType: string; messageType: string; qos: number; retained?: boolean; brokerId?: string; }): MQTTValidationContext; /** * Create a GPIO validation context * * @param baseContext Base validation context * @param gpioData GPIO specific data * @returns GPIO validation context */ export declare function createGPIOContext(baseContext: ValidationContext, gpioData: { pinNumber: number; pinDirection: 'in' | 'out'; pinMode: 'digital' | 'analog'; previousState?: number; stateChangeTime?: number; debounceConfig?: { time: number; count: number; }; pullConfig?: 'up' | 'down' | 'none'; edgeConfig?: 'rising' | 'falling' | 'both' | 'none'; }): GPIOValidationContext; //# sourceMappingURL=interface-contexts.d.ts.map