@molecule/api-resource-firmware 1.0.6 → 1.0.9
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 +4 -4
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +6 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-11-25T20:13:22.685Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-firmware
|
|
@@ -60,7 +60,7 @@ app.use('/api/firmware', createFirmwareRouter({ requireDeviceToken }))
|
|
|
60
60
|
## Installation
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
npm install @molecule/api-resource-firmware @molecule/api-
|
|
63
|
+
npm install @molecule/api-resource-firmware @molecule/api-database @molecule/api-i18n @molecule/api-logger @molecule/api-middleware-validation @molecule/api-realtime @molecule/api-resource express zod
|
|
64
64
|
npm install -D @types/express
|
|
65
65
|
```
|
|
66
66
|
|
|
@@ -467,23 +467,23 @@ const rolloutDeviceStatusSchema: z.ZodObject<
|
|
|
467
467
|
|
|
468
468
|
Peer dependencies:
|
|
469
469
|
|
|
470
|
-
- `@molecule/api-bonds-default-express` ^1.0.1
|
|
471
470
|
- `@molecule/api-database` ^1.0.1
|
|
472
471
|
- `@molecule/api-i18n` ^1.0.1
|
|
473
472
|
- `@molecule/api-logger` ^1.0.1
|
|
474
473
|
- `@molecule/api-middleware-validation` ^1.0.1
|
|
475
474
|
- `@molecule/api-realtime` ^1.0.1
|
|
475
|
+
- `@molecule/api-resource` ^1.2.0
|
|
476
476
|
- `express` ^5.0.0
|
|
477
477
|
- `zod` ^4.0.0
|
|
478
478
|
|
|
479
479
|
### Runtime Dependencies
|
|
480
480
|
|
|
481
|
-
- `@molecule/api-bonds-default-express`
|
|
482
481
|
- `@molecule/api-database`
|
|
483
482
|
- `@molecule/api-i18n`
|
|
484
483
|
- `@molecule/api-logger`
|
|
485
484
|
- `@molecule/api-middleware-validation`
|
|
486
485
|
- `@molecule/api-realtime`
|
|
486
|
+
- `@molecule/api-resource`
|
|
487
487
|
- `express`
|
|
488
488
|
- `zod`
|
|
489
489
|
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAgB,KAAK,cAAc,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAgB,KAAK,cAAc,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAA;AA2BlF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAA;AA4BlD,iCAAiC;AACjC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IAAE,kBAAkB,EAAE,qBAAqB,CAAA;CAAE,GAAG,MAAM,CAyKhG"}
|
package/dist/routes.js
CHANGED
|
@@ -9,18 +9,16 @@
|
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
11
|
import { Router } from 'express';
|
|
12
|
-
import { getParamId, getUserId } from '@molecule/api-bonds-default-express';
|
|
13
12
|
import { t } from '@molecule/api-i18n';
|
|
14
13
|
import { logger } from '@molecule/api-logger';
|
|
15
|
-
import { validateBody
|
|
14
|
+
import { validateBody, validateQuery } from '@molecule/api-middleware-validation';
|
|
15
|
+
import { getParamId, getUserId } from '@molecule/api-resource';
|
|
16
16
|
import { createFirmwareForOwner, createRolloutForOwner, getFirmwareForOwner, listFirmwareForOwner, listRolloutsForOwner, publishFirmwareForOwner, recordRolloutDeviceStatus, updateFirmwareForOwner, } from './service.js';
|
|
17
17
|
import { createFirmwareSchema, createRolloutSchema, listFirmwareQuerySchema, listRolloutsQuerySchema, rolloutDeviceStatusSchema, updateFirmwareSchema, } from './validation.js';
|
|
18
|
-
const validateBody = validateBodyRaw;
|
|
19
|
-
const validateQuery = validateQueryRaw;
|
|
20
18
|
/** Responds with a 401 Unauthorized JSON error. */
|
|
21
19
|
function unauthorized(res) {
|
|
22
20
|
return res.status(401).json({
|
|
23
|
-
error: t('auth.unauthorized', undefined, { defaultValue: '
|
|
21
|
+
error: t('auth.unauthorized', undefined, { defaultValue: 'Unauthorized' }),
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
24
|
/** Responds with a 404 Not Found JSON error for a missing firmware version. */
|
|
@@ -32,7 +30,7 @@ function firmwareNotFound(res) {
|
|
|
32
30
|
/** Responds with a 500 Internal Server Error JSON error. */
|
|
33
31
|
function internalError(res) {
|
|
34
32
|
return res.status(500).json({
|
|
35
|
-
error: t('errors.internalServer', undefined, { defaultValue: 'Internal server error
|
|
33
|
+
error: t('errors.internalServer', undefined, { defaultValue: 'Internal server error' }),
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
/** Build the firmware router. */
|
|
@@ -43,7 +41,7 @@ export function createFirmwareRouter(opts) {
|
|
|
43
41
|
const userId = getUserId(res);
|
|
44
42
|
if (!userId)
|
|
45
43
|
return unauthorized(res);
|
|
46
|
-
const q = req.query;
|
|
44
|
+
const q = listFirmwareQuerySchema.parse(req.query);
|
|
47
45
|
res.json(await listFirmwareForOwner(userId, q));
|
|
48
46
|
}
|
|
49
47
|
catch (error) {
|
|
@@ -56,7 +54,7 @@ export function createFirmwareRouter(opts) {
|
|
|
56
54
|
const userId = getUserId(res);
|
|
57
55
|
if (!userId)
|
|
58
56
|
return unauthorized(res);
|
|
59
|
-
const q = req.query;
|
|
57
|
+
const q = listRolloutsQuerySchema.parse(req.query);
|
|
60
58
|
res.json(await listRolloutsForOwner(userId, q));
|
|
61
59
|
}
|
|
62
60
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-resource-firmware",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "Firmware versions + OTA rollouts",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/api-resource-firmware",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"zod": "4.6.7"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@molecule/api-bonds-default-express": "^1.0.1",
|
|
49
48
|
"@molecule/api-database": "^1.0.1",
|
|
50
49
|
"@molecule/api-i18n": "^1.0.1",
|
|
51
50
|
"@molecule/api-logger": "^1.0.1",
|
|
52
51
|
"@molecule/api-middleware-validation": "^1.0.1",
|
|
53
52
|
"@molecule/api-realtime": "^1.0.1",
|
|
53
|
+
"@molecule/api-resource": "^1.2.0",
|
|
54
54
|
"express": "^5.0.0",
|
|
55
55
|
"zod": "^4.0.0"
|
|
56
56
|
}
|