kuzzle-device-manager 2.0.0-rc11 → 2.0.0-rc15
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.
|
@@ -53,7 +53,12 @@ class MeasureService {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
const measures = this.buildMeasures(device, asset, decodedPayloads[device._source.reference], payloadUuids);
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Event before starting to process new measures.
|
|
58
|
+
*
|
|
59
|
+
* Useful to enrich measures before they are saved.
|
|
60
|
+
*/
|
|
61
|
+
const { measures: updatedMeasures } = await this.app.trigger('device-manager:measures:process:before', { asset, device, measures });
|
|
57
62
|
device.updateMeasures(updatedMeasures);
|
|
58
63
|
await this.sdk.document.update(this.config.adminIndex, InternalCollection_1.InternalCollection.DEVICES, device._id, { measures: device._source.measures });
|
|
59
64
|
if (device._source.engineId) {
|
|
@@ -65,6 +70,14 @@ class MeasureService {
|
|
|
65
70
|
await this.sdk.document.update(device._source.engineId, InternalCollection_1.InternalCollection.ASSETS, asset._id, { measures: asset._source.measures });
|
|
66
71
|
}
|
|
67
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Event at the end of the measure process pipeline.
|
|
75
|
+
*
|
|
76
|
+
* Useful to trigger alerts.
|
|
77
|
+
*
|
|
78
|
+
* @todo test this
|
|
79
|
+
*/
|
|
80
|
+
await this.app.trigger('device-manager:measures:process:after', { asset, device, measures });
|
|
68
81
|
}
|
|
69
82
|
}
|
|
70
83
|
buildMeasures(device, asset, measurements, payloadUuids) {
|
|
@@ -130,7 +143,10 @@ class MeasureService {
|
|
|
130
143
|
};
|
|
131
144
|
});
|
|
132
145
|
// @todo replace with batch.mCreate when available
|
|
133
|
-
const { successes } = await this.sdk.document.mCreate(this.config.adminIndex, InternalCollection_1.InternalCollection.DEVICES, newDevices, { refresh
|
|
146
|
+
const { successes, errors } = await this.sdk.document.mCreate(this.config.adminIndex, InternalCollection_1.InternalCollection.DEVICES, newDevices, { refresh });
|
|
147
|
+
for (const error of errors) {
|
|
148
|
+
this.app.log.error(`Cannot create device "${error.document._id}": ${error.reason}`);
|
|
149
|
+
}
|
|
134
150
|
return successes.map(({ _source, _id }) => new models_1.Device(_source, _id));
|
|
135
151
|
}
|
|
136
152
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle-device-manager",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc15",
|
|
4
4
|
"description": "Manage your IoT devices and assets. Choose a provisioning strategy, receive and decode payload, handle your IoT business logic.",
|
|
5
5
|
"author": "The Kuzzle Team (support@kuzzle.io)",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"csvtojson": "~2.0.10",
|
|
28
28
|
"json-stable-stringify": "^1.0.1",
|
|
29
|
-
"kuzzle-plugin-commons": "https://github.com/kuzzleio/kuzzle-plugin-commons/archive/refs/tags/1.0.
|
|
29
|
+
"kuzzle-plugin-commons": "https://github.com/kuzzleio/kuzzle-plugin-commons/archive/refs/tags/1.0.5.tar.gz",
|
|
30
30
|
"uuid": "~8.3.2",
|
|
31
31
|
"lodash": "^4.17.21"
|
|
32
32
|
},
|