UNPKG

@alteriom/mqtt-schema

Version:

Alteriom MQTT v1 schemas, TypeScript types, and validation helpers for web integration

400 lines (399 loc) 10.8 kB
// AUTO-GENERATED by copy-schemas.cjs. Do not edit manually. /* eslint-disable */ export const envelope_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/envelope.schema.json", "title": "Alteriom MQTT Base Envelope v1", "type": "object", "required": [ "schema_version", "device_id", "device_type", "timestamp", "firmware_version" ], "properties": { "schema_version": { "type": "integer", "const": 1 }, "device_id": { "type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[A-Za-z0-9_-]+$" }, "device_type": { "type": "string", "enum": [ "sensor", "gateway" ] }, "timestamp": { "type": "string", "format": "date-time" }, "firmware_version": { "type": "string", "minLength": 1, "maxLength": 40 }, "hardware_version": { "type": "string", "maxLength": 80 } }, "additionalProperties": true }; export const sensor_data_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/sensor_data.schema.json", "title": "Sensor Data Message v1", "allOf": [ { "$ref": "envelope.schema.json" } ], "type": "object", "required": [ "sensors" ], "properties": { "sensors": { "type": "object", "minProperties": 1, "additionalProperties": { "type": "object", "required": [ "value" ], "properties": { "value": { "type": [ "number", "integer" ] }, "unit": { "type": "string" }, "raw_value": { "type": [ "number", "integer" ] }, "calibrated_value": { "type": [ "number", "integer" ] }, "quality_score": { "type": "number", "minimum": 0, "maximum": 1 }, "name": { "type": "string" }, "location": { "type": "string" }, "additional_data": { "type": "object" } }, "additionalProperties": false } }, "battery_level": { "type": "integer", "minimum": 0, "maximum": 100 }, "signal_strength": { "type": "integer", "minimum": -200, "maximum": 0 }, "additional": { "type": "object" } }, "additionalProperties": true }; export const sensor_heartbeat_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/sensor_heartbeat.schema.json", "title": "Sensor Heartbeat v1", "type": "object", "required": [ "schema_version", "device_id", "device_type", "timestamp" ], "properties": { "schema_version": { "type": "integer", "const": 1 }, "device_id": { "type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[A-Za-z0-9_-]+$" }, "device_type": { "type": "string", "enum": [ "sensor", "gateway" ] }, "timestamp": { "type": "string", "format": "date-time" } }, "additionalProperties": true }; export const sensor_status_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/sensor_status.schema.json", "title": "Sensor Status v1", "allOf": [ { "$ref": "envelope.schema.json" } ], "type": "object", "required": [ "status" ], "properties": { "status": { "type": "string", "enum": [ "online", "offline", "updating", "error" ] }, "battery_level": { "type": "integer", "minimum": 0, "maximum": 100 }, "signal_strength": { "type": "integer", "minimum": -200, "maximum": 0 } }, "additionalProperties": true }; export const gateway_info_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/gateway_info.schema.json", "title": "Gateway Info v1", "allOf": [ { "$ref": "envelope.schema.json" } ], "type": "object", "properties": { "mac_address": { "type": "string", "pattern": "^[0-9A-Fa-f:]{17}$" }, "ip_address": { "type": "string", "format": "ipv4" }, "capabilities": { "type": "object", "properties": { "max_nodes": { "type": "integer", "minimum": 0 }, "supports_mesh": { "type": "boolean" }, "firmware_update": { "type": "boolean" } }, "additionalProperties": true } }, "additionalProperties": true }; export const gateway_metrics_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/gateway_metrics.schema.json", "title": "Gateway Metrics v1", "allOf": [ { "$ref": "envelope.schema.json" } ], "type": "object", "required": [ "metrics" ], "properties": { "metrics": { "type": "object", "required": [ "uptime_s" ], "properties": { "uptime_s": { "type": "integer", "minimum": 0 }, "cpu_usage_pct": { "type": "number", "minimum": 0, "maximum": 100 }, "memory_usage_pct": { "type": "number", "minimum": 0, "maximum": 100 }, "temperature_c": { "type": "number" }, "connected_devices": { "type": "integer", "minimum": 0 }, "mesh_nodes": { "type": "integer", "minimum": 0 }, "packet_loss_pct": { "type": "number", "minimum": 0, "maximum": 100 }, "data_throughput_kbps": { "type": "number", "minimum": 0 } }, "additionalProperties": true } }, "additionalProperties": true }; export const firmware_status_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/firmware_status.schema.json", "title": "Firmware Update Status v1", "allOf": [ { "$ref": "envelope.schema.json" } ], "type": "object", "required": [ "status" ], "properties": { "event": { "type": "string" }, "from_version": { "type": "string" }, "to_version": { "type": "string" }, "status": { "type": "string", "enum": [ "pending", "downloading", "flashing", "verifying", "rebooting", "completed", "failed" ] }, "progress_pct": { "type": "number", "minimum": 0, "maximum": 100 }, "error": { "type": [ "string", "null" ] } }, "additionalProperties": true }; export const control_response_schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.alteriom.io/mqtt/v1/control_response.schema.json", "title": "Control / Command Response v1", "allOf": [ { "$ref": "envelope.schema.json" } ], "type": "object", "required": [ "status" ], "properties": { "command": { "type": "string" }, "status": { "type": "string", "enum": [ "ok", "error" ] }, "message": { "type": "string" }, "result": { "type": [ "object", "array", "string", "number", "boolean", "null" ] } }, "additionalProperties": true }; export const mqtt_v1_bundle_json = { "$comment": "Convenience bundle referencing all v1 schema artifact filenames for tooling discovery.", "version": 1, "schemas": { "envelope": "envelope.schema.json", "sensor_data": "sensor_data.schema.json", "sensor_heartbeat": "sensor_heartbeat.schema.json", "sensor_status": "sensor_status.schema.json", "gateway_info": "gateway_info.schema.json", "gateway_metrics": "gateway_metrics.schema.json", "firmware_status": "firmware_status.schema.json", "control_response": "control_response.schema.json" } };