@alteriom/mqtt-schema 0.2.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/README.md +174 -0
- package/dist/cjs/generated/types.d.ts +101 -0
- package/dist/cjs/generated/types.js +104 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/schema_data.d.ts +319 -0
- package/dist/cjs/schema_data.js +402 -0
- package/dist/cjs/schemas/control_response.schema.json +15 -0
- package/dist/cjs/schemas/envelope.schema.json +16 -0
- package/dist/cjs/schemas/firmware_status.schema.json +17 -0
- package/dist/cjs/schemas/gateway_info.schema.json +21 -0
- package/dist/cjs/schemas/gateway_metrics.schema.json +26 -0
- package/dist/cjs/schemas/mqtt_v1_bundle.json +14 -0
- package/dist/cjs/schemas/sensor_data.schema.json +33 -0
- package/dist/cjs/schemas/sensor_heartbeat.schema.json +14 -0
- package/dist/cjs/schemas/sensor_status.schema.json +14 -0
- package/dist/cjs/schemas/validation_rules.md +44 -0
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.js +23 -0
- package/dist/cjs/validators.d.ts +23 -0
- package/dist/cjs/validators.js +84 -0
- package/dist/esm/generated/types.js +92 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/schema_data.js +399 -0
- package/dist/esm/schemas/control_response.schema.json +15 -0
- package/dist/esm/schemas/envelope.schema.json +16 -0
- package/dist/esm/schemas/firmware_status.schema.json +17 -0
- package/dist/esm/schemas/gateway_info.schema.json +21 -0
- package/dist/esm/schemas/gateway_metrics.schema.json +26 -0
- package/dist/esm/schemas/mqtt_v1_bundle.json +14 -0
- package/dist/esm/schemas/sensor_data.schema.json +33 -0
- package/dist/esm/schemas/sensor_heartbeat.schema.json +14 -0
- package/dist/esm/schemas/sensor_status.schema.json +14 -0
- package/dist/esm/schemas/validation_rules.md +44 -0
- package/dist/esm/types.js +7 -0
- package/dist/esm/validators.js +76 -0
- package/package.json +91 -0
@@ -0,0 +1,402 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mqtt_v1_bundle_json = exports.control_response_schema = exports.firmware_status_schema = exports.gateway_metrics_schema = exports.gateway_info_schema = exports.sensor_status_schema = exports.sensor_heartbeat_schema = exports.sensor_data_schema = exports.envelope_schema = void 0;
|
4
|
+
// AUTO-GENERATED by copy-schemas.cjs. Do not edit manually.
|
5
|
+
/* eslint-disable */
|
6
|
+
exports.envelope_schema = {
|
7
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
8
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/envelope.schema.json",
|
9
|
+
"title": "Alteriom MQTT Base Envelope v1",
|
10
|
+
"type": "object",
|
11
|
+
"required": [
|
12
|
+
"schema_version",
|
13
|
+
"device_id",
|
14
|
+
"device_type",
|
15
|
+
"timestamp",
|
16
|
+
"firmware_version"
|
17
|
+
],
|
18
|
+
"properties": {
|
19
|
+
"schema_version": {
|
20
|
+
"type": "integer",
|
21
|
+
"const": 1
|
22
|
+
},
|
23
|
+
"device_id": {
|
24
|
+
"type": "string",
|
25
|
+
"minLength": 1,
|
26
|
+
"maxLength": 64,
|
27
|
+
"pattern": "^[A-Za-z0-9_-]+$"
|
28
|
+
},
|
29
|
+
"device_type": {
|
30
|
+
"type": "string",
|
31
|
+
"enum": [
|
32
|
+
"sensor",
|
33
|
+
"gateway"
|
34
|
+
]
|
35
|
+
},
|
36
|
+
"timestamp": {
|
37
|
+
"type": "string",
|
38
|
+
"format": "date-time"
|
39
|
+
},
|
40
|
+
"firmware_version": {
|
41
|
+
"type": "string",
|
42
|
+
"minLength": 1,
|
43
|
+
"maxLength": 40
|
44
|
+
},
|
45
|
+
"hardware_version": {
|
46
|
+
"type": "string",
|
47
|
+
"maxLength": 80
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"additionalProperties": true
|
51
|
+
};
|
52
|
+
exports.sensor_data_schema = {
|
53
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
54
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/sensor_data.schema.json",
|
55
|
+
"title": "Sensor Data Message v1",
|
56
|
+
"allOf": [
|
57
|
+
{
|
58
|
+
"$ref": "envelope.schema.json"
|
59
|
+
}
|
60
|
+
],
|
61
|
+
"type": "object",
|
62
|
+
"required": [
|
63
|
+
"sensors"
|
64
|
+
],
|
65
|
+
"properties": {
|
66
|
+
"sensors": {
|
67
|
+
"type": "object",
|
68
|
+
"minProperties": 1,
|
69
|
+
"additionalProperties": {
|
70
|
+
"type": "object",
|
71
|
+
"required": [
|
72
|
+
"value"
|
73
|
+
],
|
74
|
+
"properties": {
|
75
|
+
"value": {
|
76
|
+
"type": [
|
77
|
+
"number",
|
78
|
+
"integer"
|
79
|
+
]
|
80
|
+
},
|
81
|
+
"unit": {
|
82
|
+
"type": "string"
|
83
|
+
},
|
84
|
+
"raw_value": {
|
85
|
+
"type": [
|
86
|
+
"number",
|
87
|
+
"integer"
|
88
|
+
]
|
89
|
+
},
|
90
|
+
"calibrated_value": {
|
91
|
+
"type": [
|
92
|
+
"number",
|
93
|
+
"integer"
|
94
|
+
]
|
95
|
+
},
|
96
|
+
"quality_score": {
|
97
|
+
"type": "number",
|
98
|
+
"minimum": 0,
|
99
|
+
"maximum": 1
|
100
|
+
},
|
101
|
+
"name": {
|
102
|
+
"type": "string"
|
103
|
+
},
|
104
|
+
"location": {
|
105
|
+
"type": "string"
|
106
|
+
},
|
107
|
+
"additional_data": {
|
108
|
+
"type": "object"
|
109
|
+
}
|
110
|
+
},
|
111
|
+
"additionalProperties": false
|
112
|
+
}
|
113
|
+
},
|
114
|
+
"battery_level": {
|
115
|
+
"type": "integer",
|
116
|
+
"minimum": 0,
|
117
|
+
"maximum": 100
|
118
|
+
},
|
119
|
+
"signal_strength": {
|
120
|
+
"type": "integer",
|
121
|
+
"minimum": -200,
|
122
|
+
"maximum": 0
|
123
|
+
},
|
124
|
+
"additional": {
|
125
|
+
"type": "object"
|
126
|
+
}
|
127
|
+
},
|
128
|
+
"additionalProperties": true
|
129
|
+
};
|
130
|
+
exports.sensor_heartbeat_schema = {
|
131
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
132
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/sensor_heartbeat.schema.json",
|
133
|
+
"title": "Sensor Heartbeat v1",
|
134
|
+
"type": "object",
|
135
|
+
"required": [
|
136
|
+
"schema_version",
|
137
|
+
"device_id",
|
138
|
+
"device_type",
|
139
|
+
"timestamp"
|
140
|
+
],
|
141
|
+
"properties": {
|
142
|
+
"schema_version": {
|
143
|
+
"type": "integer",
|
144
|
+
"const": 1
|
145
|
+
},
|
146
|
+
"device_id": {
|
147
|
+
"type": "string",
|
148
|
+
"minLength": 1,
|
149
|
+
"maxLength": 64,
|
150
|
+
"pattern": "^[A-Za-z0-9_-]+$"
|
151
|
+
},
|
152
|
+
"device_type": {
|
153
|
+
"type": "string",
|
154
|
+
"enum": [
|
155
|
+
"sensor",
|
156
|
+
"gateway"
|
157
|
+
]
|
158
|
+
},
|
159
|
+
"timestamp": {
|
160
|
+
"type": "string",
|
161
|
+
"format": "date-time"
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"additionalProperties": true
|
165
|
+
};
|
166
|
+
exports.sensor_status_schema = {
|
167
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
168
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/sensor_status.schema.json",
|
169
|
+
"title": "Sensor Status v1",
|
170
|
+
"allOf": [
|
171
|
+
{
|
172
|
+
"$ref": "envelope.schema.json"
|
173
|
+
}
|
174
|
+
],
|
175
|
+
"type": "object",
|
176
|
+
"required": [
|
177
|
+
"status"
|
178
|
+
],
|
179
|
+
"properties": {
|
180
|
+
"status": {
|
181
|
+
"type": "string",
|
182
|
+
"enum": [
|
183
|
+
"online",
|
184
|
+
"offline",
|
185
|
+
"updating",
|
186
|
+
"error"
|
187
|
+
]
|
188
|
+
},
|
189
|
+
"battery_level": {
|
190
|
+
"type": "integer",
|
191
|
+
"minimum": 0,
|
192
|
+
"maximum": 100
|
193
|
+
},
|
194
|
+
"signal_strength": {
|
195
|
+
"type": "integer",
|
196
|
+
"minimum": -200,
|
197
|
+
"maximum": 0
|
198
|
+
}
|
199
|
+
},
|
200
|
+
"additionalProperties": true
|
201
|
+
};
|
202
|
+
exports.gateway_info_schema = {
|
203
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
204
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/gateway_info.schema.json",
|
205
|
+
"title": "Gateway Info v1",
|
206
|
+
"allOf": [
|
207
|
+
{
|
208
|
+
"$ref": "envelope.schema.json"
|
209
|
+
}
|
210
|
+
],
|
211
|
+
"type": "object",
|
212
|
+
"properties": {
|
213
|
+
"mac_address": {
|
214
|
+
"type": "string",
|
215
|
+
"pattern": "^[0-9A-Fa-f:]{17}$"
|
216
|
+
},
|
217
|
+
"ip_address": {
|
218
|
+
"type": "string",
|
219
|
+
"format": "ipv4"
|
220
|
+
},
|
221
|
+
"capabilities": {
|
222
|
+
"type": "object",
|
223
|
+
"properties": {
|
224
|
+
"max_nodes": {
|
225
|
+
"type": "integer",
|
226
|
+
"minimum": 0
|
227
|
+
},
|
228
|
+
"supports_mesh": {
|
229
|
+
"type": "boolean"
|
230
|
+
},
|
231
|
+
"firmware_update": {
|
232
|
+
"type": "boolean"
|
233
|
+
}
|
234
|
+
},
|
235
|
+
"additionalProperties": true
|
236
|
+
}
|
237
|
+
},
|
238
|
+
"additionalProperties": true
|
239
|
+
};
|
240
|
+
exports.gateway_metrics_schema = {
|
241
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
242
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/gateway_metrics.schema.json",
|
243
|
+
"title": "Gateway Metrics v1",
|
244
|
+
"allOf": [
|
245
|
+
{
|
246
|
+
"$ref": "envelope.schema.json"
|
247
|
+
}
|
248
|
+
],
|
249
|
+
"type": "object",
|
250
|
+
"required": [
|
251
|
+
"metrics"
|
252
|
+
],
|
253
|
+
"properties": {
|
254
|
+
"metrics": {
|
255
|
+
"type": "object",
|
256
|
+
"required": [
|
257
|
+
"uptime_s"
|
258
|
+
],
|
259
|
+
"properties": {
|
260
|
+
"uptime_s": {
|
261
|
+
"type": "integer",
|
262
|
+
"minimum": 0
|
263
|
+
},
|
264
|
+
"cpu_usage_pct": {
|
265
|
+
"type": "number",
|
266
|
+
"minimum": 0,
|
267
|
+
"maximum": 100
|
268
|
+
},
|
269
|
+
"memory_usage_pct": {
|
270
|
+
"type": "number",
|
271
|
+
"minimum": 0,
|
272
|
+
"maximum": 100
|
273
|
+
},
|
274
|
+
"temperature_c": {
|
275
|
+
"type": "number"
|
276
|
+
},
|
277
|
+
"connected_devices": {
|
278
|
+
"type": "integer",
|
279
|
+
"minimum": 0
|
280
|
+
},
|
281
|
+
"mesh_nodes": {
|
282
|
+
"type": "integer",
|
283
|
+
"minimum": 0
|
284
|
+
},
|
285
|
+
"packet_loss_pct": {
|
286
|
+
"type": "number",
|
287
|
+
"minimum": 0,
|
288
|
+
"maximum": 100
|
289
|
+
},
|
290
|
+
"data_throughput_kbps": {
|
291
|
+
"type": "number",
|
292
|
+
"minimum": 0
|
293
|
+
}
|
294
|
+
},
|
295
|
+
"additionalProperties": true
|
296
|
+
}
|
297
|
+
},
|
298
|
+
"additionalProperties": true
|
299
|
+
};
|
300
|
+
exports.firmware_status_schema = {
|
301
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
302
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/firmware_status.schema.json",
|
303
|
+
"title": "Firmware Update Status v1",
|
304
|
+
"allOf": [
|
305
|
+
{
|
306
|
+
"$ref": "envelope.schema.json"
|
307
|
+
}
|
308
|
+
],
|
309
|
+
"type": "object",
|
310
|
+
"required": [
|
311
|
+
"status"
|
312
|
+
],
|
313
|
+
"properties": {
|
314
|
+
"event": {
|
315
|
+
"type": "string"
|
316
|
+
},
|
317
|
+
"from_version": {
|
318
|
+
"type": "string"
|
319
|
+
},
|
320
|
+
"to_version": {
|
321
|
+
"type": "string"
|
322
|
+
},
|
323
|
+
"status": {
|
324
|
+
"type": "string",
|
325
|
+
"enum": [
|
326
|
+
"pending",
|
327
|
+
"downloading",
|
328
|
+
"flashing",
|
329
|
+
"verifying",
|
330
|
+
"rebooting",
|
331
|
+
"completed",
|
332
|
+
"failed"
|
333
|
+
]
|
334
|
+
},
|
335
|
+
"progress_pct": {
|
336
|
+
"type": "number",
|
337
|
+
"minimum": 0,
|
338
|
+
"maximum": 100
|
339
|
+
},
|
340
|
+
"error": {
|
341
|
+
"type": [
|
342
|
+
"string",
|
343
|
+
"null"
|
344
|
+
]
|
345
|
+
}
|
346
|
+
},
|
347
|
+
"additionalProperties": true
|
348
|
+
};
|
349
|
+
exports.control_response_schema = {
|
350
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
351
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/control_response.schema.json",
|
352
|
+
"title": "Control / Command Response v1",
|
353
|
+
"allOf": [
|
354
|
+
{
|
355
|
+
"$ref": "envelope.schema.json"
|
356
|
+
}
|
357
|
+
],
|
358
|
+
"type": "object",
|
359
|
+
"required": [
|
360
|
+
"status"
|
361
|
+
],
|
362
|
+
"properties": {
|
363
|
+
"command": {
|
364
|
+
"type": "string"
|
365
|
+
},
|
366
|
+
"status": {
|
367
|
+
"type": "string",
|
368
|
+
"enum": [
|
369
|
+
"ok",
|
370
|
+
"error"
|
371
|
+
]
|
372
|
+
},
|
373
|
+
"message": {
|
374
|
+
"type": "string"
|
375
|
+
},
|
376
|
+
"result": {
|
377
|
+
"type": [
|
378
|
+
"object",
|
379
|
+
"array",
|
380
|
+
"string",
|
381
|
+
"number",
|
382
|
+
"boolean",
|
383
|
+
"null"
|
384
|
+
]
|
385
|
+
}
|
386
|
+
},
|
387
|
+
"additionalProperties": true
|
388
|
+
};
|
389
|
+
exports.mqtt_v1_bundle_json = {
|
390
|
+
"$comment": "Convenience bundle referencing all v1 schema artifact filenames for tooling discovery.",
|
391
|
+
"version": 1,
|
392
|
+
"schemas": {
|
393
|
+
"envelope": "envelope.schema.json",
|
394
|
+
"sensor_data": "sensor_data.schema.json",
|
395
|
+
"sensor_heartbeat": "sensor_heartbeat.schema.json",
|
396
|
+
"sensor_status": "sensor_status.schema.json",
|
397
|
+
"gateway_info": "gateway_info.schema.json",
|
398
|
+
"gateway_metrics": "gateway_metrics.schema.json",
|
399
|
+
"firmware_status": "firmware_status.schema.json",
|
400
|
+
"control_response": "control_response.schema.json"
|
401
|
+
}
|
402
|
+
};
|
@@ -0,0 +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
|
+
}
|
@@ -0,0 +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
|
+
}
|
@@ -0,0 +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
|
+
}
|
@@ -0,0 +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
|
+
}
|
@@ -0,0 +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
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"$comment": "Convenience bundle referencing all v1 schema artifact filenames for tooling discovery.",
|
3
|
+
"version": 1,
|
4
|
+
"schemas": {
|
5
|
+
"envelope": "envelope.schema.json",
|
6
|
+
"sensor_data": "sensor_data.schema.json",
|
7
|
+
"sensor_heartbeat": "sensor_heartbeat.schema.json",
|
8
|
+
"sensor_status": "sensor_status.schema.json",
|
9
|
+
"gateway_info": "gateway_info.schema.json",
|
10
|
+
"gateway_metrics": "gateway_metrics.schema.json",
|
11
|
+
"firmware_status": "firmware_status.schema.json",
|
12
|
+
"control_response": "control_response.schema.json"
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/sensor_data.schema.json",
|
4
|
+
"title": "Sensor Data Message v1",
|
5
|
+
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
+
"type": "object",
|
7
|
+
"required": ["sensors"],
|
8
|
+
"properties": {
|
9
|
+
"sensors": {
|
10
|
+
"type": "object",
|
11
|
+
"minProperties": 1,
|
12
|
+
"additionalProperties": {
|
13
|
+
"type": "object",
|
14
|
+
"required": ["value"],
|
15
|
+
"properties": {
|
16
|
+
"value": {"type": ["number", "integer"]},
|
17
|
+
"unit": {"type": "string"},
|
18
|
+
"raw_value": {"type": ["number", "integer"]},
|
19
|
+
"calibrated_value": {"type": ["number", "integer"]},
|
20
|
+
"quality_score": {"type": "number", "minimum": 0, "maximum": 1},
|
21
|
+
"name": {"type": "string"},
|
22
|
+
"location": {"type": "string"},
|
23
|
+
"additional_data": {"type": "object"}
|
24
|
+
},
|
25
|
+
"additionalProperties": false
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"battery_level": {"type": "integer", "minimum": 0, "maximum": 100},
|
29
|
+
"signal_strength": {"type": "integer", "minimum": -200, "maximum": 0},
|
30
|
+
"additional": {"type": "object"}
|
31
|
+
},
|
32
|
+
"additionalProperties": true
|
33
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/sensor_heartbeat.schema.json",
|
4
|
+
"title": "Sensor Heartbeat v1",
|
5
|
+
"type": "object",
|
6
|
+
"required": ["schema_version", "device_id", "device_type", "timestamp"],
|
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
|
+
},
|
13
|
+
"additionalProperties": true
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/sensor_status.schema.json",
|
4
|
+
"title": "Sensor Status v1",
|
5
|
+
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
+
"type": "object",
|
7
|
+
"required": ["status"],
|
8
|
+
"properties": {
|
9
|
+
"status": {"type": "string", "enum": ["online", "offline", "updating", "error"]},
|
10
|
+
"battery_level": {"type": "integer", "minimum": 0, "maximum": 100},
|
11
|
+
"signal_strength": {"type": "integer", "minimum": -200, "maximum": 0}
|
12
|
+
},
|
13
|
+
"additionalProperties": true
|
14
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Validation Rules (Operational Layer)
|
2
|
+
|
3
|
+
This file captures dynamic / contextual validation that is OUTSIDE pure structural JSON Schema constraints.
|
4
|
+
|
5
|
+
## Timing & Rate
|
6
|
+
- Future timestamp drift: reject if > 5s ahead of server reference.
|
7
|
+
- Heartbeat interval recommended 30s; backend may rate-limit <10s.
|
8
|
+
- Sensor data soft min 30s unless negotiated high-frequency mode.
|
9
|
+
|
10
|
+
## Heartbeat Firmware Version Exception
|
11
|
+
- Only heartbeat topic may omit `firmware_version` when unchanged.
|
12
|
+
- All other topics require the field.
|
13
|
+
|
14
|
+
## Forbidden / Drop Conditions
|
15
|
+
| Reason | Condition |
|
16
|
+
|--------|----------|
|
17
|
+
| missing_fields | Required base fields absent (heartbeat firmware exception applied). |
|
18
|
+
| invalid_timestamp | Non-ISO 8601 / unparseable timestamp. |
|
19
|
+
| deprecated_keys | Usage of forbidden alias keys (f, fw, ver, version, u, up, rssi). |
|
20
|
+
| invalid_sensor_entry | Sensor object missing `value` key. |
|
21
|
+
| future_drift | Timestamp too far in future (>5s). |
|
22
|
+
| out_of_range | battery_level not 0-100 OR quality_score not 0-1. |
|
23
|
+
| invalid_numeric | Non-numeric where numeric expected. |
|
24
|
+
| spec_violation | Generic fallback after failed internal validation. |
|
25
|
+
|
26
|
+
## Sensor Object Semantics
|
27
|
+
- `value` REQUIRED.
|
28
|
+
- `unit`, `raw_value`, `calibrated_value`, `quality_score`, `name`, `location`, `additional_data` OPTIONAL.
|
29
|
+
- If `quality_score` present must be 0.0–1.0 inclusive.
|
30
|
+
|
31
|
+
## Metrics Constraints
|
32
|
+
- Gateway metrics MUST appear under `metrics` (never at top-level).
|
33
|
+
- Required minimal metric: `uptime_s`.
|
34
|
+
|
35
|
+
## Firmware Update Status
|
36
|
+
- `status` must be one of: pending, downloading, flashing, verifying, rebooting, completed, failed.
|
37
|
+
- `progress_pct` (if present) must be 0–100.
|
38
|
+
|
39
|
+
## Extensibility
|
40
|
+
- Unknown top-level keys tolerated (future evolution) except if they collide with any deprecated alias or reserved future keys announced in CHANGELOG.
|
41
|
+
|
42
|
+
## Versioning
|
43
|
+
- Current `schema_version`: 1
|
44
|
+
- Additions remain optional; breaking changes introduce new schema set.
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './generated/types.js';
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
// Re-export the generated firmware repo types by importing relative path.
|
3
|
+
// This keeps single source of truth while enabling package consumers to import from package root.
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
5
|
+
if (k2 === undefined) k2 = k;
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
9
|
+
}
|
10
|
+
Object.defineProperty(o, k2, desc);
|
11
|
+
}) : (function(o, m, k, k2) {
|
12
|
+
if (k2 === undefined) k2 = k;
|
13
|
+
o[k2] = m[k];
|
14
|
+
}));
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
17
|
+
};
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
19
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
20
|
+
// Re-export generated types copied during prebuild from firmware docs into src/generated/types.ts
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
22
|
+
// @ts-ignore
|
23
|
+
__exportStar(require("./generated/types.js"), exports);
|