@alteriom/mqtt-schema 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog (Moved)
2
+
3
+ The canonical changelog is maintained at:
4
+
5
+ `docs/mqtt_schema/CHANGELOG.md`
6
+
7
+ This root file is intentionally minimal to avoid duplication and ensure release integrity scripts target a single source of truth.
package/README.md CHANGED
@@ -1,174 +1,252 @@
1
- # @alteriom/mqtt-schema
2
-
3
- Alteriom MQTT v1 JSON Schemas, TypeScript types, and production‑ready validation helpers for integrating firmware MQTT payloads into web or backend services.
4
-
5
- ## Why this exists
6
- Firmware emits structured MQTT payloads that must remain tightly aligned with web, analytics, and gateway logic. This package is the single source of truth for:
7
-
8
- - Canonical, versioned JSON Schemas (`schema_version: 1` series)
9
- - Embedded (tree‑shakeable) schema objects — no runtime file I/O
10
- - Precompiled Ajv validators (fast + consistent across CJS / ESM)
11
- - TypeScript interfaces & type guards generated from the same source schema set
12
- - Message classification helper that infers the schema kind heuristically
13
- - Forwardcompatible design: unknown extra properties are ignored unless explicitly constrained
14
-
15
- ## Features
16
-
17
- - Dual build: CommonJS + ESM (Node 16+ / bundlers)
18
- - Zero configuration: just import and validate
19
- - Helpful error paths (JSON Pointer style)
20
- - Lightweight (Ajv peer dependency, schemas embedded)
21
- - Ships original schema JSON files (optional consumption)
22
-
23
- ## Installation
24
-
25
- ```bash
26
- npm install @alteriom/mqtt-schema ajv ajv-formats
27
- ```
28
-
29
- ## Quick Start
30
-
31
- Validate a JSON payload (object already parsed):
32
-
33
- ```ts
34
- import { validators } from '@alteriom/mqtt-schema';
35
-
36
- const payload = JSON.parse(rawMqttString);
37
- const result = validators.sensorData(payload);
38
- if (!result.valid) {
39
- console.error('Invalid sensor data', result.errors);
40
- }
41
- ```
42
-
43
- Classify and validate automatically:
44
-
45
- ```ts
46
- import { classifyAndValidate } from '@alteriom/mqtt-schema';
47
-
48
- const { kind, result } = classifyAndValidate(payload);
49
- if (result.valid) {
50
- console.log('Message kind:', kind);
51
- } else {
52
- console.warn('Validation errors', result.errors);
53
- }
54
- ```
55
-
56
- Use strong TypeScript types after classification:
57
-
58
- ```ts
59
- import { classifyAndValidate, isSensorDataMessage, SensorDataMessage } from '@alteriom/mqtt-schema';
60
-
61
- const { result } = classifyAndValidate(payload);
62
- if (result.valid && isSensorDataMessage(payload)) {
63
- const data: SensorDataMessage = payload;
64
- Object.entries(data.sensors).forEach(([name, s]) => {
65
- console.log(name, s.value, s.unit);
66
- });
67
- }
68
- ```
69
-
70
- Access raw schema JSON (if you need to introspect or power form generation):
71
-
72
- ```ts
73
- import envelopeSchema from '@alteriom/mqtt-schema/schemas/envelope.schema.json';
74
- ```
75
-
76
- ## API Surface
77
-
78
- ```ts
79
- import { validators, validateMessage, classifyAndValidate } from '@alteriom/mqtt-schema';
80
-
81
- // 1. Direct validator by message kind
82
- validators.sensorData(payload); // => { valid: boolean; errors?: string[] }
83
-
84
- // 2. Generic function
85
- validateMessage('sensorData', payload);
86
-
87
- // 3. Classify unknown payload then validate
88
- const { kind, result } = classifyAndValidate(payload);
89
-
90
- // 4. Type guards (when available)
91
- // if (isSensorDataMessage(payload)) { ... }
92
- ```
93
-
94
- Validation result format:
95
-
96
- ```ts
97
- interface ValidationResult {
98
- valid: boolean;
99
- errors?: string[]; // Each item contains instancePath + message
100
- }
101
- ```
102
-
103
- ### Performance Notes
104
- All Ajv validator functions are compiled once at module load. For typical web usage (tens to hundreds of validations per page/session) this is faster and simpler than on‑demand compilation. If you need custom Ajv options (e.g., different formats), open an issue—an override hook can be added without breaking changes.
105
-
106
- ### Embedded Schemas
107
- `schema_data.ts` is auto‑generated during build. This avoids dynamic `require()` / `import` of JSON and works cleanly in both Node ESM and bundlers without JSON import assertions. The original JSON files are still published under `schemas/` for tooling or documentation pipelines.
108
-
109
- ## Provided Schemas (v1)
110
-
111
- | File | Purpose |
112
- |------|---------|
113
- | envelope.schema.json | Base required envelope fields |
114
- | sensor_data.schema.json | Telemetry payload with sensors map |
115
- | sensor_heartbeat.schema.json | Lightweight heartbeat (firmware_version may be omitted) |
116
- | sensor_status.schema.json | Sensor status / presence updates |
117
- | gateway_info.schema.json | Gateway identity & capabilities |
118
- | gateway_metrics.schema.json | Gateway performance metrics |
119
- | firmware_status.schema.json | Firmware update lifecycle events |
120
- | control_response.schema.json | Command/control response messages |
121
-
122
- ## Exports
123
-
124
- | Export | Type | Description |
125
- |--------|------|-------------|
126
- | `validators` | object | Precompiled validators per message type |
127
- | `validateMessage(kind,data)` | fn | Run a specific validator by key |
128
- | `classifyAndValidate(data)` | fn | Heuristic classification + validation |
129
- | `SensorDataMessage` etc. | TS interfaces | Strongly typed shapes |
130
- | `isSensorDataMessage` etc. | type guards | Runtime narrowing helpers |
131
- | `schemas/*.json` | JSON | Original schema assets (optional) |
132
-
133
- ### Validator Keys
134
- `sensorData`, `sensorHeartbeat`, `sensorStatus`, `gatewayInfo`, `gatewayMetrics`, `firmwareStatus`, `controlResponse`
135
-
136
- ### Classification Heuristics (Simplified)
137
- - `metrics` `gatewayMetrics`
138
- - `sensors` → `sensorData`
139
- - `progress_pct` or OTA status keywords → `firmwareStatus`
140
- - `status` + `device_type: sensor` → `sensorStatus`
141
- - `status: ok|error` (no other match) → `controlResponse`
142
- - `device_type: gateway` → `gatewayInfo`
143
- - fallback `sensorHeartbeat`
144
-
145
- ## Versioning Policy
146
-
147
- Schema stability is paramount. We track two related versions:
148
-
149
- | Concept | Meaning |
150
- |---------|---------|
151
- | `schema_version` (in payload) | Wire format major. Only increments for breaking changes. |
152
- | npm package version | Follows semver; patch/minor may add optional properties or tooling, major aligns with `schema_version` bump. |
153
-
154
- Backward‑compatible additions: new optional properties or enums, documented in CHANGELOG. Breaking: new required fields, structural changes, or removed properties (triggers parallel `v2` schema path & coordinated firmware rollout).
155
-
156
- ## TypeScript / Bundler Notes
157
- - Works in TS >= 5, Node >= 16, Vite / Webpack / ESBuild.
158
- - Tree shaking: unused validators pruned when using ESM builds.
159
- - No side effects besides Ajv instance creation.
160
-
161
- ## Roadmap
162
- - Optional custom Ajv injection hook
163
- - JSON Schema Zod conversion example
164
- - Runtime metrics helper (count validation categories)
165
-
166
- ## Contributing
167
- Issues & PRs welcome. Ensure firmware repo schemas remain the authoritative source—do not manually edit generated `schema_data.ts`.
168
-
169
- ## Security
170
- Schemas are static. No network access. Supply-chain risk minimized by keeping dependencies minimal (Ajv + formats only).
171
-
172
- ## License
173
-
174
- MIT
1
+ # @alteriom/mqtt-schema
2
+
3
+ ![Metadata Compliance](https://github.com/Alteriom/alteriom-mqtt-schema/actions/workflows/metadata-compliance.yml/badge.svg)
4
+ ![npm version](https://img.shields.io/npm/v/@alteriom/mqtt-schema.svg)
5
+ ![npm downloads](https://img.shields.io/npm/dm/@alteriom/mqtt-schema.svg)
6
+ ![license](https://img.shields.io/npm/l/@alteriom/mqtt-schema.svg)
7
+ ![npm total downloads](https://img.shields.io/npm/dt/@alteriom/mqtt-schema.svg)
8
+ ![node version](https://img.shields.io/node/v/@alteriom/mqtt-schema.svg)
9
+ ![peer ajv](https://img.shields.io/badge/peer%20ajv-%3E%3D8.0.0-blue.svg)
10
+ ![latest tag](https://img.shields.io/github/v/tag/Alteriom/alteriom-mqtt-schema?label=tag)
11
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/@alteriom/mqtt-schema)](https://bundlephobia.com/package/@alteriom/mqtt-schema)
12
+
13
+ Alteriom MQTT v1 JSON Schemas, TypeScript types, and productionready validation helpers for integrating firmware MQTT payloads into web or backend services.
14
+
15
+ > NOTE: OTA manifest CI validation workflow file could not be added via automated API due to path constraints; it can be added manually post-merge if still absent.
16
+
17
+ See also: `docs/SCHEMA_MAP.md` for complete schema listing.
18
+
19
+ ## OTA Firmware Manifest Schema (NEW in 0.3.0)
20
+
21
+ The package now includes the OTA firmware manifest schema used by build + deployment tooling.
22
+
23
+ Import the schema JSON directly:
24
+ ```ts
25
+ import otaManifestSchema from '@alteriom/mqtt-schema/schemas/ota/ota-manifest.schema.json';
26
+ ```
27
+
28
+ Types:
29
+ ```ts
30
+ import { OtaManifest, isRichManifest } from '@alteriom/mqtt-schema/types/ota-manifest';
31
+ ```
32
+
33
+ Shapes supported (oneOf):
34
+ - Rich manifest:
35
+ ```json
36
+ {
37
+ "environment": "universal-sensor",
38
+ "branch": "main",
39
+ "manifests": { "dev": { /* richEntry */ }, "prod": { /* richEntry */ } }
40
+ }
41
+ ```
42
+ - Minimal environment map:
43
+ ```json
44
+ {
45
+ "universal-sensor": { "dev": { /* minimalChannel */ } }
46
+ }
47
+ ```
48
+
49
+ Chunk hashing variants (mutually exclusive):
50
+ 1. Structured objects (offset + size + sha256)
51
+ 2. Array of lowercase sha256 strings
52
+
53
+ Validation example:
54
+ ```ts
55
+ import Ajv from 'ajv';
56
+ import schema from '@alteriom/mqtt-schema/schemas/ota/ota-manifest.schema.json';
57
+ import { OtaManifest } from '@alteriom/mqtt-schema/types/ota-manifest';
58
+
59
+ const ajv = new Ajv({ allErrors: true });
60
+ const validate = ajv.compile<OtaManifest>(schema as any);
61
+ const manifest: OtaManifest = JSON.parse(raw);
62
+ if (!validate(manifest)) {
63
+ console.error(validate.errors);
64
+ }
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Why this exists
70
+ Firmware emits structured MQTT payloads that must remain tightly aligned with web, analytics, and gateway logic. This package is the single source of truth for:
71
+
72
+ - Canonical, versioned JSON Schemas (`schema_version: 1` series)
73
+ - Embedded (tree‑shakeable) schema objects — no runtime file I/O
74
+ - Precompiled Ajv validators (fast + consistent across CJS / ESM)
75
+ - TypeScript interfaces & type guards generated from the same source schema set
76
+ - Message classification helper that infers the schema kind heuristically
77
+ - Forward‑compatible design: unknown extra properties are ignored unless explicitly constrained
78
+
79
+ ## Features
80
+
81
+ - Dual build: CommonJS + ESM (Node 16+ / bundlers)
82
+ - Zero configuration: just import and validate
83
+ - Helpful error paths (JSON Pointer style)
84
+ - Lightweight (Ajv peer dependency, schemas embedded)
85
+ - Ships original schema JSON files (optional consumption)
86
+
87
+ ## Installation
88
+
89
+ ```bash
90
+ npm install @alteriom/mqtt-schema ajv ajv-formats
91
+ ```
92
+
93
+ ## Quick Start
94
+
95
+ Validate a JSON payload (object already parsed):
96
+
97
+ ```ts
98
+ import { validators } from '@alteriom/mqtt-schema';
99
+
100
+ const payload = JSON.parse(rawMqttString);
101
+ const result = validators.sensorData(payload);
102
+ if (!result.valid) {
103
+ console.error('Invalid sensor data', result.errors);
104
+ }
105
+ ```
106
+
107
+ Classify and validate automatically:
108
+
109
+ ```ts
110
+ import { classifyAndValidate } from '@alteriom/mqtt-schema';
111
+
112
+ const { kind, result } = classifyAndValidate(payload);
113
+ if (result.valid) {
114
+ console.log('Message kind:', kind);
115
+ } else {
116
+ console.warn('Validation errors', result.errors);
117
+ }
118
+ ```
119
+
120
+ Use strong TypeScript types after classification:
121
+
122
+ ```ts
123
+ import { classifyAndValidate, isSensorDataMessage, SensorDataMessage } from '@alteriom/mqtt-schema';
124
+
125
+ const { result } = classifyAndValidate(payload);
126
+ if (result.valid && isSensorDataMessage(payload)) {
127
+ const data: SensorDataMessage = payload;
128
+ Object.entries(data.sensors).forEach(([name, s]) => {
129
+ console.log(name, s.value, s.unit);
130
+ });
131
+ }
132
+ ```
133
+
134
+ Access raw schema JSON (if you need to introspect or power form generation):
135
+
136
+ ```ts
137
+ import envelopeSchema from '@alteriom/mqtt-schema/schemas/envelope.schema.json';
138
+ ```
139
+
140
+ ## API Surface
141
+
142
+ ```ts
143
+ import { validators, validateMessage, classifyAndValidate } from '@alteriom/mqtt-schema';
144
+
145
+ // 1. Direct validator by message kind
146
+ validators.sensorData(payload); // => { valid: boolean; errors?: string[] }
147
+
148
+ // 2. Generic function
149
+ validateMessage('sensorData', payload);
150
+
151
+ // 3. Classify unknown payload then validate
152
+ const { kind, result } = classifyAndValidate(payload);
153
+
154
+ // 4. Type guards (when available)
155
+ // if (isSensorDataMessage(payload)) { ... }
156
+ ```
157
+
158
+ Validation result format:
159
+
160
+ ```ts
161
+ interface ValidationResult {
162
+ valid: boolean;
163
+ errors?: string[]; // Each item contains instancePath + message
164
+ }
165
+ ```
166
+
167
+ ### Performance Notes
168
+
169
+ All Ajv validator functions are compiled once at module load. For typical web usage (tens to hundreds of validations per page/session) this is faster and simpler than on‑demand compilation. If you need custom Ajv options (e.g., different formats), open an issue—an override hook can be added without breaking changes.
170
+
171
+ ### Embedded Schemas
172
+
173
+ `schema_data.ts` is auto‑generated during build. This avoids dynamic `require()` / `import` of JSON and works cleanly in both Node ESM and bundlers without JSON import assertions. The original JSON files are still published under `schemas/` for tooling or documentation pipelines.
174
+
175
+ ## Provided Schemas (v1)
176
+
177
+ | File | Purpose |
178
+ |------|---------|
179
+ | envelope.schema.json | Base required envelope fields |
180
+ | sensor_data.schema.json | Telemetry payload with sensors map |
181
+ | sensor_heartbeat.schema.json | Lightweight heartbeat (firmware_version may be omitted) |
182
+ | sensor_status.schema.json | Sensor status / presence updates |
183
+ | gateway_info.schema.json | Gateway identity & capabilities |
184
+ | gateway_metrics.schema.json | Gateway performance metrics |
185
+ | firmware_status.schema.json | Firmware update lifecycle events |
186
+ | control_response.schema.json | Command/control response messages |
187
+
188
+ ## Exports
189
+
190
+ | Export | Type | Description |
191
+ |--------|------|-------------|
192
+ | `validators` | object | Precompiled validators per message type |
193
+ | `validateMessage(kind,data)` | fn | Run a specific validator by key |
194
+ | `classifyAndValidate(data)` | fn | Heuristic classification + validation |
195
+ | `SensorDataMessage` etc. | TS interfaces | Strongly typed shapes |
196
+ | `isSensorDataMessage` etc. | type guards | Runtime narrowing helpers |
197
+ | `schemas/*.json` | JSON | Original schema assets (optional) |
198
+ | `schemas/ota/ota-manifest.schema.json` | JSON | OTA firmware manifest schema (rich + minimal) |
199
+ | `types/ota-manifest` | TS types | OtaManifest union + helpers |
200
+
201
+ ### Validator Keys
202
+
203
+ `sensorData`, `sensorHeartbeat`, `sensorStatus`, `gatewayInfo`, `gatewayMetrics`, `firmwareStatus`, `controlResponse`
204
+
205
+ ### Classification Heuristics (Simplified)
206
+
207
+ - `metrics` → `gatewayMetrics`
208
+ - `sensors` → `sensorData`
209
+ - `progress_pct` or OTA status keywords → `firmwareStatus`
210
+ - `status` + `device_type: sensor` → `sensorStatus`
211
+ - `status: ok|error` (no other match) → `controlResponse`
212
+ - `device_type: gateway` → `gatewayInfo`
213
+ - fallback → `sensorHeartbeat`
214
+
215
+ ## Versioning Policy
216
+
217
+ Schema stability is paramount. We track two related versions:
218
+
219
+ | Concept | Meaning |
220
+ |---------|---------|
221
+ | `schema_version` (in payload) | Wire format major. Only increments for breaking changes. |
222
+ | npm package version | Follows semver; patch/minor may add optional properties or tooling, major aligns with `schema_version` bump. |
223
+
224
+ Backward‑compatible additions: new optional properties or enums, documented in CHANGELOG. Breaking: new required fields, structural changes, or removed properties (triggers parallel `v2` schema path & coordinated firmware rollout).
225
+
226
+ Backward-compatible schema additions to OTA manifest WILL use minor bumps.
227
+
228
+ ## TypeScript / Bundler Notes
229
+
230
+ - Works in TS >= 5, Node >= 16, Vite / Webpack / ESBuild.
231
+ - Tree shaking: unused validators pruned when using ESM builds.
232
+ - No side effects besides Ajv instance creation.
233
+
234
+ ## Roadmap
235
+
236
+ - Optional custom Ajv injection hook
237
+ - JSON Schema → Zod conversion example
238
+ - Runtime metrics helper (count validation categories)
239
+ - Signed OTA manifest extension
240
+ - Delta / compressed OTA metadata fields
241
+
242
+ ## Contributing
243
+
244
+ Issues & PRs welcome. Ensure firmware repo schemas remain the authoritative source—do not manually edit generated `schema_data.ts`.
245
+
246
+ ## Security
247
+
248
+ Schemas are static. No network access. Supply-chain risk minimized by keeping dependencies minimal (Ajv + formats only).
249
+
250
+ ## License
251
+
252
+ MIT
@@ -1,15 +1,15 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.alteriom.io/mqtt/v1/control_response.schema.json",
4
- "title": "Control / Command Response v1",
5
- "allOf": [{"$ref": "envelope.schema.json"}],
6
- "type": "object",
7
- "required": ["status"],
8
- "properties": {
9
- "command": {"type": "string"},
10
- "status": {"type": "string", "enum": ["ok", "error"]},
11
- "message": {"type": "string"},
12
- "result": {"type": ["object", "array", "string", "number", "boolean", "null"]}
13
- },
14
- "additionalProperties": true
15
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.alteriom.io/mqtt/v1/control_response.schema.json",
4
+ "title": "Control / Command Response v1",
5
+ "allOf": [{"$ref": "envelope.schema.json"}],
6
+ "type": "object",
7
+ "required": ["status"],
8
+ "properties": {
9
+ "command": {"type": "string"},
10
+ "status": {"type": "string", "enum": ["ok", "error"]},
11
+ "message": {"type": "string"},
12
+ "result": {"type": ["object", "array", "string", "number", "boolean", "null"]}
13
+ },
14
+ "additionalProperties": true
15
+ }
@@ -1,16 +1,16 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.alteriom.io/mqtt/v1/envelope.schema.json",
4
- "title": "Alteriom MQTT Base Envelope v1",
5
- "type": "object",
6
- "required": ["schema_version", "device_id", "device_type", "timestamp", "firmware_version"],
7
- "properties": {
8
- "schema_version": {"type": "integer", "const": 1},
9
- "device_id": {"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[A-Za-z0-9_-]+$"},
10
- "device_type": {"type": "string", "enum": ["sensor", "gateway"]},
11
- "timestamp": {"type": "string", "format": "date-time"},
12
- "firmware_version": {"type": "string", "minLength": 1, "maxLength": 40},
13
- "hardware_version": {"type": "string", "maxLength": 80}
14
- },
15
- "additionalProperties": true
16
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.alteriom.io/mqtt/v1/envelope.schema.json",
4
+ "title": "Alteriom MQTT Base Envelope v1",
5
+ "type": "object",
6
+ "required": ["schema_version", "device_id", "device_type", "timestamp", "firmware_version"],
7
+ "properties": {
8
+ "schema_version": {"type": "integer", "const": 1},
9
+ "device_id": {"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[A-Za-z0-9_-]+$"},
10
+ "device_type": {"type": "string", "enum": ["sensor", "gateway"]},
11
+ "timestamp": {"type": "string", "format": "date-time"},
12
+ "firmware_version": {"type": "string", "minLength": 1, "maxLength": 40},
13
+ "hardware_version": {"type": "string", "maxLength": 80}
14
+ },
15
+ "additionalProperties": true
16
+ }
@@ -1,17 +1,17 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.alteriom.io/mqtt/v1/firmware_status.schema.json",
4
- "title": "Firmware Update Status v1",
5
- "allOf": [{"$ref": "envelope.schema.json"}],
6
- "type": "object",
7
- "required": ["status"],
8
- "properties": {
9
- "event": {"type": "string"},
10
- "from_version": {"type": "string"},
11
- "to_version": {"type": "string"},
12
- "status": {"type": "string", "enum": ["pending", "downloading", "flashing", "verifying", "rebooting", "completed", "failed"]},
13
- "progress_pct": {"type": "number", "minimum": 0, "maximum": 100},
14
- "error": {"type": ["string", "null"]}
15
- },
16
- "additionalProperties": true
17
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.alteriom.io/mqtt/v1/firmware_status.schema.json",
4
+ "title": "Firmware Update Status v1",
5
+ "allOf": [{"$ref": "envelope.schema.json"}],
6
+ "type": "object",
7
+ "required": ["status"],
8
+ "properties": {
9
+ "event": {"type": "string"},
10
+ "from_version": {"type": "string"},
11
+ "to_version": {"type": "string"},
12
+ "status": {"type": "string", "enum": ["pending", "downloading", "flashing", "verifying", "rebooting", "completed", "failed"]},
13
+ "progress_pct": {"type": "number", "minimum": 0, "maximum": 100},
14
+ "error": {"type": ["string", "null"]}
15
+ },
16
+ "additionalProperties": true
17
+ }
@@ -1,21 +1,21 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.alteriom.io/mqtt/v1/gateway_info.schema.json",
4
- "title": "Gateway Info v1",
5
- "allOf": [{"$ref": "envelope.schema.json"}],
6
- "type": "object",
7
- "properties": {
8
- "mac_address": {"type": "string", "pattern": "^[0-9A-Fa-f:]{17}$"},
9
- "ip_address": {"type": "string", "format": "ipv4"},
10
- "capabilities": {
11
- "type": "object",
12
- "properties": {
13
- "max_nodes": {"type": "integer", "minimum": 0},
14
- "supports_mesh": {"type": "boolean"},
15
- "firmware_update": {"type": "boolean"}
16
- },
17
- "additionalProperties": true
18
- }
19
- },
20
- "additionalProperties": true
21
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.alteriom.io/mqtt/v1/gateway_info.schema.json",
4
+ "title": "Gateway Info v1",
5
+ "allOf": [{"$ref": "envelope.schema.json"}],
6
+ "type": "object",
7
+ "properties": {
8
+ "mac_address": {"type": "string", "pattern": "^[0-9A-Fa-f:]{17}$"},
9
+ "ip_address": {"type": "string", "format": "ipv4"},
10
+ "capabilities": {
11
+ "type": "object",
12
+ "properties": {
13
+ "max_nodes": {"type": "integer", "minimum": 0},
14
+ "supports_mesh": {"type": "boolean"},
15
+ "firmware_update": {"type": "boolean"}
16
+ },
17
+ "additionalProperties": true
18
+ }
19
+ },
20
+ "additionalProperties": true
21
+ }
@@ -1,26 +1,26 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.alteriom.io/mqtt/v1/gateway_metrics.schema.json",
4
- "title": "Gateway Metrics v1",
5
- "allOf": [{"$ref": "envelope.schema.json"}],
6
- "type": "object",
7
- "required": ["metrics"],
8
- "properties": {
9
- "metrics": {
10
- "type": "object",
11
- "required": ["uptime_s"],
12
- "properties": {
13
- "uptime_s": {"type": "integer", "minimum": 0},
14
- "cpu_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
15
- "memory_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
16
- "temperature_c": {"type": "number"},
17
- "connected_devices": {"type": "integer", "minimum": 0},
18
- "mesh_nodes": {"type": "integer", "minimum": 0},
19
- "packet_loss_pct": {"type": "number", "minimum": 0, "maximum": 100},
20
- "data_throughput_kbps": {"type": "number", "minimum": 0}
21
- },
22
- "additionalProperties": true
23
- }
24
- },
25
- "additionalProperties": true
26
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.alteriom.io/mqtt/v1/gateway_metrics.schema.json",
4
+ "title": "Gateway Metrics v1",
5
+ "allOf": [{"$ref": "envelope.schema.json"}],
6
+ "type": "object",
7
+ "required": ["metrics"],
8
+ "properties": {
9
+ "metrics": {
10
+ "type": "object",
11
+ "required": ["uptime_s"],
12
+ "properties": {
13
+ "uptime_s": {"type": "integer", "minimum": 0},
14
+ "cpu_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
15
+ "memory_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
16
+ "temperature_c": {"type": "number"},
17
+ "connected_devices": {"type": "integer", "minimum": 0},
18
+ "mesh_nodes": {"type": "integer", "minimum": 0},
19
+ "packet_loss_pct": {"type": "number", "minimum": 0, "maximum": 100},
20
+ "data_throughput_kbps": {"type": "number", "minimum": 0}
21
+ },
22
+ "additionalProperties": true
23
+ }
24
+ },
25
+ "additionalProperties": true
26
+ }