@alteriom/mqtt-schema 0.3.0 → 0.3.1

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.
@@ -0,0 +1,187 @@
1
+ {
2
+ "$id": "https://schemas.alteriom.com/ota/ota-manifest.schema.json",
3
+ "title": "Alteriom OTA Firmware Manifest",
4
+ "description": "Schema for Alteriom OTA firmware manifests supporting both rich and minimal variants",
5
+ "type": "object",
6
+ "oneOf": [
7
+ {
8
+ "title": "Rich Manifest",
9
+ "description": "Rich manifest format with environment, branch, and manifests object",
10
+ "type": "object",
11
+ "properties": {
12
+ "environment": {
13
+ "type": "string",
14
+ "description": "Target environment (e.g., universal-sensor)"
15
+ },
16
+ "branch": {
17
+ "type": "string",
18
+ "description": "Source control branch the build originated from"
19
+ },
20
+ "manifests": {
21
+ "type": "object",
22
+ "description": "Build variants keyed by type (dev, prod, etc.)",
23
+ "patternProperties": {
24
+ "^[a-z][a-z0-9-]*$": {
25
+ "$ref": "#/$defs/richEntry"
26
+ }
27
+ },
28
+ "additionalProperties": false,
29
+ "minProperties": 1
30
+ }
31
+ },
32
+ "required": ["environment", "branch", "manifests"],
33
+ "additionalProperties": true
34
+ },
35
+ {
36
+ "title": "Minimal Environment Map",
37
+ "description": "Minimal manifest format as environment -> channels mapping",
38
+ "type": "object",
39
+ "patternProperties": {
40
+ "^[a-z][a-z0-9-]*$": {
41
+ "type": "object",
42
+ "description": "Environment entry with channel mappings",
43
+ "patternProperties": {
44
+ "^[a-z][a-z0-9-]*$": {
45
+ "$ref": "#/$defs/minimalChannel"
46
+ }
47
+ },
48
+ "additionalProperties": false,
49
+ "minProperties": 1
50
+ }
51
+ },
52
+ "additionalProperties": false,
53
+ "minProperties": 1
54
+ }
55
+ ],
56
+ "$defs": {
57
+ "richEntry": {
58
+ "title": "Rich Build Entry",
59
+ "description": "Rich manifest build entry (dev or prod)",
60
+ "type": "object",
61
+ "properties": {
62
+ "build_type": {
63
+ "type": "string",
64
+ "enum": ["dev", "prod"],
65
+ "description": "Build type identifier"
66
+ },
67
+ "file": {
68
+ "type": "string",
69
+ "description": "Firmware binary filename"
70
+ },
71
+ "size": {
72
+ "type": "integer",
73
+ "minimum": 1,
74
+ "description": "Total firmware size in bytes"
75
+ },
76
+ "sha256": {
77
+ "type": "string",
78
+ "pattern": "^[a-f0-9]{64}$",
79
+ "description": "SHA256 hash of the full firmware binary (lowercase hex)"
80
+ },
81
+ "firmware_version": {
82
+ "type": "string",
83
+ "description": "Semantic or build version string"
84
+ },
85
+ "built": {
86
+ "type": "string",
87
+ "format": "date-time",
88
+ "description": "ISO8601 timestamp when built"
89
+ },
90
+ "ota_url": {
91
+ "type": "string",
92
+ "format": "uri",
93
+ "description": "Absolute or relative URL to fetch the firmware"
94
+ },
95
+ "chunk_size": {
96
+ "type": "integer",
97
+ "minimum": 1,
98
+ "description": "Size of each chunk except possibly the last"
99
+ },
100
+ "chunks": {
101
+ "description": "Either structured chunk objects or array of SHA256 strings",
102
+ "oneOf": [
103
+ {
104
+ "type": "array",
105
+ "items": {
106
+ "$ref": "#/$defs/chunkObject"
107
+ },
108
+ "description": "Array of structured chunk objects with metadata"
109
+ },
110
+ {
111
+ "type": "array",
112
+ "items": {
113
+ "type": "string",
114
+ "pattern": "^[a-f0-9]{64}$",
115
+ "description": "SHA256 hash of chunk (lowercase hex)"
116
+ },
117
+ "description": "Array of SHA256 strings for chunks"
118
+ }
119
+ ]
120
+ }
121
+ },
122
+ "required": ["build_type", "file", "size", "sha256", "firmware_version", "built", "ota_url"],
123
+ "additionalProperties": true
124
+ },
125
+ "chunkObject": {
126
+ "title": "OTA Chunk Object",
127
+ "description": "Structured chunk metadata with offset and size",
128
+ "type": "object",
129
+ "properties": {
130
+ "index": {
131
+ "type": "integer",
132
+ "minimum": 0,
133
+ "description": "0-based sequential chunk index"
134
+ },
135
+ "offset": {
136
+ "type": "integer",
137
+ "minimum": 0,
138
+ "description": "Byte offset within firmware binary"
139
+ },
140
+ "size": {
141
+ "type": "integer",
142
+ "minimum": 1,
143
+ "description": "Chunk size in bytes"
144
+ },
145
+ "sha256": {
146
+ "type": "string",
147
+ "pattern": "^[a-f0-9]{64}$",
148
+ "description": "SHA256 hash of the chunk (lowercase hex)"
149
+ }
150
+ },
151
+ "required": ["index", "offset", "size", "sha256"],
152
+ "additionalProperties": true
153
+ },
154
+ "minimalChannel": {
155
+ "title": "Minimal Channel Entry",
156
+ "description": "Minimal manifest channel entry",
157
+ "type": "object",
158
+ "properties": {
159
+ "file": {
160
+ "type": "string",
161
+ "description": "Firmware binary filename"
162
+ },
163
+ "size": {
164
+ "type": "integer",
165
+ "minimum": 1,
166
+ "description": "Total firmware size in bytes"
167
+ },
168
+ "sha256": {
169
+ "type": "string",
170
+ "pattern": "^[a-f0-9]{64}$",
171
+ "description": "SHA256 hash of the firmware binary (lowercase hex)"
172
+ },
173
+ "version": {
174
+ "type": "string",
175
+ "description": "Firmware version string"
176
+ },
177
+ "timestamp": {
178
+ "type": "string",
179
+ "format": "date-time",
180
+ "description": "ISO8601 timestamp"
181
+ }
182
+ },
183
+ "required": ["file", "size", "sha256", "version", "timestamp"],
184
+ "additionalProperties": true
185
+ }
186
+ }
187
+ }
@@ -397,3 +397,216 @@ export const mqtt_v1_bundle_json = {
397
397
  "control_response": "control_response.schema.json"
398
398
  }
399
399
  };
400
+ export const ota_ota_manifest_schema = {
401
+ "$id": "https://schemas.alteriom.com/ota/ota-manifest.schema.json",
402
+ "title": "Alteriom OTA Firmware Manifest",
403
+ "description": "Schema for Alteriom OTA firmware manifests supporting both rich and minimal variants",
404
+ "type": "object",
405
+ "oneOf": [
406
+ {
407
+ "title": "Rich Manifest",
408
+ "description": "Rich manifest format with environment, branch, and manifests object",
409
+ "type": "object",
410
+ "properties": {
411
+ "environment": {
412
+ "type": "string",
413
+ "description": "Target environment (e.g., universal-sensor)"
414
+ },
415
+ "branch": {
416
+ "type": "string",
417
+ "description": "Source control branch the build originated from"
418
+ },
419
+ "manifests": {
420
+ "type": "object",
421
+ "description": "Build variants keyed by type (dev, prod, etc.)",
422
+ "patternProperties": {
423
+ "^[a-z][a-z0-9-]*$": {
424
+ "$ref": "#/$defs/richEntry"
425
+ }
426
+ },
427
+ "additionalProperties": false,
428
+ "minProperties": 1
429
+ }
430
+ },
431
+ "required": [
432
+ "environment",
433
+ "branch",
434
+ "manifests"
435
+ ],
436
+ "additionalProperties": true
437
+ },
438
+ {
439
+ "title": "Minimal Environment Map",
440
+ "description": "Minimal manifest format as environment -> channels mapping",
441
+ "type": "object",
442
+ "patternProperties": {
443
+ "^[a-z][a-z0-9-]*$": {
444
+ "type": "object",
445
+ "description": "Environment entry with channel mappings",
446
+ "patternProperties": {
447
+ "^[a-z][a-z0-9-]*$": {
448
+ "$ref": "#/$defs/minimalChannel"
449
+ }
450
+ },
451
+ "additionalProperties": false,
452
+ "minProperties": 1
453
+ }
454
+ },
455
+ "additionalProperties": false,
456
+ "minProperties": 1
457
+ }
458
+ ],
459
+ "$defs": {
460
+ "richEntry": {
461
+ "title": "Rich Build Entry",
462
+ "description": "Rich manifest build entry (dev or prod)",
463
+ "type": "object",
464
+ "properties": {
465
+ "build_type": {
466
+ "type": "string",
467
+ "enum": [
468
+ "dev",
469
+ "prod"
470
+ ],
471
+ "description": "Build type identifier"
472
+ },
473
+ "file": {
474
+ "type": "string",
475
+ "description": "Firmware binary filename"
476
+ },
477
+ "size": {
478
+ "type": "integer",
479
+ "minimum": 1,
480
+ "description": "Total firmware size in bytes"
481
+ },
482
+ "sha256": {
483
+ "type": "string",
484
+ "pattern": "^[a-f0-9]{64}$",
485
+ "description": "SHA256 hash of the full firmware binary (lowercase hex)"
486
+ },
487
+ "firmware_version": {
488
+ "type": "string",
489
+ "description": "Semantic or build version string"
490
+ },
491
+ "built": {
492
+ "type": "string",
493
+ "format": "date-time",
494
+ "description": "ISO8601 timestamp when built"
495
+ },
496
+ "ota_url": {
497
+ "type": "string",
498
+ "format": "uri",
499
+ "description": "Absolute or relative URL to fetch the firmware"
500
+ },
501
+ "chunk_size": {
502
+ "type": "integer",
503
+ "minimum": 1,
504
+ "description": "Size of each chunk except possibly the last"
505
+ },
506
+ "chunks": {
507
+ "description": "Either structured chunk objects or array of SHA256 strings",
508
+ "oneOf": [
509
+ {
510
+ "type": "array",
511
+ "items": {
512
+ "$ref": "#/$defs/chunkObject"
513
+ },
514
+ "description": "Array of structured chunk objects with metadata"
515
+ },
516
+ {
517
+ "type": "array",
518
+ "items": {
519
+ "type": "string",
520
+ "pattern": "^[a-f0-9]{64}$",
521
+ "description": "SHA256 hash of chunk (lowercase hex)"
522
+ },
523
+ "description": "Array of SHA256 strings for chunks"
524
+ }
525
+ ]
526
+ }
527
+ },
528
+ "required": [
529
+ "build_type",
530
+ "file",
531
+ "size",
532
+ "sha256",
533
+ "firmware_version",
534
+ "built",
535
+ "ota_url"
536
+ ],
537
+ "additionalProperties": true
538
+ },
539
+ "chunkObject": {
540
+ "title": "OTA Chunk Object",
541
+ "description": "Structured chunk metadata with offset and size",
542
+ "type": "object",
543
+ "properties": {
544
+ "index": {
545
+ "type": "integer",
546
+ "minimum": 0,
547
+ "description": "0-based sequential chunk index"
548
+ },
549
+ "offset": {
550
+ "type": "integer",
551
+ "minimum": 0,
552
+ "description": "Byte offset within firmware binary"
553
+ },
554
+ "size": {
555
+ "type": "integer",
556
+ "minimum": 1,
557
+ "description": "Chunk size in bytes"
558
+ },
559
+ "sha256": {
560
+ "type": "string",
561
+ "pattern": "^[a-f0-9]{64}$",
562
+ "description": "SHA256 hash of the chunk (lowercase hex)"
563
+ }
564
+ },
565
+ "required": [
566
+ "index",
567
+ "offset",
568
+ "size",
569
+ "sha256"
570
+ ],
571
+ "additionalProperties": true
572
+ },
573
+ "minimalChannel": {
574
+ "title": "Minimal Channel Entry",
575
+ "description": "Minimal manifest channel entry",
576
+ "type": "object",
577
+ "properties": {
578
+ "file": {
579
+ "type": "string",
580
+ "description": "Firmware binary filename"
581
+ },
582
+ "size": {
583
+ "type": "integer",
584
+ "minimum": 1,
585
+ "description": "Total firmware size in bytes"
586
+ },
587
+ "sha256": {
588
+ "type": "string",
589
+ "pattern": "^[a-f0-9]{64}$",
590
+ "description": "SHA256 hash of the firmware binary (lowercase hex)"
591
+ },
592
+ "version": {
593
+ "type": "string",
594
+ "description": "Firmware version string"
595
+ },
596
+ "timestamp": {
597
+ "type": "string",
598
+ "format": "date-time",
599
+ "description": "ISO8601 timestamp"
600
+ }
601
+ },
602
+ "required": [
603
+ "file",
604
+ "size",
605
+ "sha256",
606
+ "version",
607
+ "timestamp"
608
+ ],
609
+ "additionalProperties": true
610
+ }
611
+ }
612
+ };
@@ -0,0 +1,187 @@
1
+ {
2
+ "$id": "https://schemas.alteriom.com/ota/ota-manifest.schema.json",
3
+ "title": "Alteriom OTA Firmware Manifest",
4
+ "description": "Schema for Alteriom OTA firmware manifests supporting both rich and minimal variants",
5
+ "type": "object",
6
+ "oneOf": [
7
+ {
8
+ "title": "Rich Manifest",
9
+ "description": "Rich manifest format with environment, branch, and manifests object",
10
+ "type": "object",
11
+ "properties": {
12
+ "environment": {
13
+ "type": "string",
14
+ "description": "Target environment (e.g., universal-sensor)"
15
+ },
16
+ "branch": {
17
+ "type": "string",
18
+ "description": "Source control branch the build originated from"
19
+ },
20
+ "manifests": {
21
+ "type": "object",
22
+ "description": "Build variants keyed by type (dev, prod, etc.)",
23
+ "patternProperties": {
24
+ "^[a-z][a-z0-9-]*$": {
25
+ "$ref": "#/$defs/richEntry"
26
+ }
27
+ },
28
+ "additionalProperties": false,
29
+ "minProperties": 1
30
+ }
31
+ },
32
+ "required": ["environment", "branch", "manifests"],
33
+ "additionalProperties": true
34
+ },
35
+ {
36
+ "title": "Minimal Environment Map",
37
+ "description": "Minimal manifest format as environment -> channels mapping",
38
+ "type": "object",
39
+ "patternProperties": {
40
+ "^[a-z][a-z0-9-]*$": {
41
+ "type": "object",
42
+ "description": "Environment entry with channel mappings",
43
+ "patternProperties": {
44
+ "^[a-z][a-z0-9-]*$": {
45
+ "$ref": "#/$defs/minimalChannel"
46
+ }
47
+ },
48
+ "additionalProperties": false,
49
+ "minProperties": 1
50
+ }
51
+ },
52
+ "additionalProperties": false,
53
+ "minProperties": 1
54
+ }
55
+ ],
56
+ "$defs": {
57
+ "richEntry": {
58
+ "title": "Rich Build Entry",
59
+ "description": "Rich manifest build entry (dev or prod)",
60
+ "type": "object",
61
+ "properties": {
62
+ "build_type": {
63
+ "type": "string",
64
+ "enum": ["dev", "prod"],
65
+ "description": "Build type identifier"
66
+ },
67
+ "file": {
68
+ "type": "string",
69
+ "description": "Firmware binary filename"
70
+ },
71
+ "size": {
72
+ "type": "integer",
73
+ "minimum": 1,
74
+ "description": "Total firmware size in bytes"
75
+ },
76
+ "sha256": {
77
+ "type": "string",
78
+ "pattern": "^[a-f0-9]{64}$",
79
+ "description": "SHA256 hash of the full firmware binary (lowercase hex)"
80
+ },
81
+ "firmware_version": {
82
+ "type": "string",
83
+ "description": "Semantic or build version string"
84
+ },
85
+ "built": {
86
+ "type": "string",
87
+ "format": "date-time",
88
+ "description": "ISO8601 timestamp when built"
89
+ },
90
+ "ota_url": {
91
+ "type": "string",
92
+ "format": "uri",
93
+ "description": "Absolute or relative URL to fetch the firmware"
94
+ },
95
+ "chunk_size": {
96
+ "type": "integer",
97
+ "minimum": 1,
98
+ "description": "Size of each chunk except possibly the last"
99
+ },
100
+ "chunks": {
101
+ "description": "Either structured chunk objects or array of SHA256 strings",
102
+ "oneOf": [
103
+ {
104
+ "type": "array",
105
+ "items": {
106
+ "$ref": "#/$defs/chunkObject"
107
+ },
108
+ "description": "Array of structured chunk objects with metadata"
109
+ },
110
+ {
111
+ "type": "array",
112
+ "items": {
113
+ "type": "string",
114
+ "pattern": "^[a-f0-9]{64}$",
115
+ "description": "SHA256 hash of chunk (lowercase hex)"
116
+ },
117
+ "description": "Array of SHA256 strings for chunks"
118
+ }
119
+ ]
120
+ }
121
+ },
122
+ "required": ["build_type", "file", "size", "sha256", "firmware_version", "built", "ota_url"],
123
+ "additionalProperties": true
124
+ },
125
+ "chunkObject": {
126
+ "title": "OTA Chunk Object",
127
+ "description": "Structured chunk metadata with offset and size",
128
+ "type": "object",
129
+ "properties": {
130
+ "index": {
131
+ "type": "integer",
132
+ "minimum": 0,
133
+ "description": "0-based sequential chunk index"
134
+ },
135
+ "offset": {
136
+ "type": "integer",
137
+ "minimum": 0,
138
+ "description": "Byte offset within firmware binary"
139
+ },
140
+ "size": {
141
+ "type": "integer",
142
+ "minimum": 1,
143
+ "description": "Chunk size in bytes"
144
+ },
145
+ "sha256": {
146
+ "type": "string",
147
+ "pattern": "^[a-f0-9]{64}$",
148
+ "description": "SHA256 hash of the chunk (lowercase hex)"
149
+ }
150
+ },
151
+ "required": ["index", "offset", "size", "sha256"],
152
+ "additionalProperties": true
153
+ },
154
+ "minimalChannel": {
155
+ "title": "Minimal Channel Entry",
156
+ "description": "Minimal manifest channel entry",
157
+ "type": "object",
158
+ "properties": {
159
+ "file": {
160
+ "type": "string",
161
+ "description": "Firmware binary filename"
162
+ },
163
+ "size": {
164
+ "type": "integer",
165
+ "minimum": 1,
166
+ "description": "Total firmware size in bytes"
167
+ },
168
+ "sha256": {
169
+ "type": "string",
170
+ "pattern": "^[a-f0-9]{64}$",
171
+ "description": "SHA256 hash of the firmware binary (lowercase hex)"
172
+ },
173
+ "version": {
174
+ "type": "string",
175
+ "description": "Firmware version string"
176
+ },
177
+ "timestamp": {
178
+ "type": "string",
179
+ "format": "date-time",
180
+ "description": "ISO8601 timestamp"
181
+ }
182
+ },
183
+ "required": ["file", "size", "sha256", "version", "timestamp"],
184
+ "additionalProperties": true
185
+ }
186
+ }
187
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alteriom/mqtt-schema",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Alteriom MQTT v1 schemas, TypeScript types, and validation helpers for web integration",
5
5
  "license": "MIT",
6
6
  "author": "Alteriom Development Team",
@@ -42,6 +42,11 @@
42
42
  "./schemas/ota/ota-manifest.schema.json": {
43
43
  "default": "./schemas/ota/ota-manifest.schema.json"
44
44
  },
45
+ "./ota-manifest": {
46
+ "import": "./schemas/ota/ota-manifest.schema.json",
47
+ "require": "./schemas/ota/ota-manifest.schema.json",
48
+ "default": "./schemas/ota/ota-manifest.schema.json"
49
+ },
45
50
  "./types/ota-manifest": {
46
51
  "types": "./types/ota-manifest.d.ts",
47
52
  "default": "./types/ota-manifest.d.ts"
@@ -61,6 +66,9 @@
61
66
  ],
62
67
  "types/ota-manifest": [
63
68
  "types/ota-manifest.d.ts"
69
+ ],
70
+ "ota-manifest": [
71
+ "schemas/ota/ota-manifest.schema.json"
64
72
  ]
65
73
  }
66
74
  },
@@ -90,6 +98,7 @@
90
98
  "verify:schemas": "node scripts/check-schema-sync.cjs",
91
99
  "verify:release": "node scripts/check-release-integrity.cjs",
92
100
  "verify": "npm run verify:schemas && npm run verify:release && npm test",
101
+ "verify:all": "node scripts/verify_all.cjs",
93
102
  "release:prepare": "node scripts/release-prepare.cjs",
94
103
  "wiki:generate": "node scripts/generate-wiki.cjs",
95
104
  "metadata:report": "alteriom-metadata report --org-tag alteriom || echo 'metadata report failed'",
@@ -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
+ }