kuzzle-device-manager 2.0.0-rc15 → 2.0.0-rc19

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.
@@ -170,7 +170,11 @@ class AssetController extends RelationalController_1.RelationalController {
170
170
  const body = request.getBody();
171
171
  const asset = await this.sdk.document.get(engineId, this.collection, id);
172
172
  let assetMetadata = request.input.body.metadata;
173
- request.input.body.metadata = await this.assetCategoryService.formatMetadataForES(assetMetadata);
173
+ const previousMetadata = asset._source.metadata
174
+ ? asset._source.metadata.filter(m => !Object.keys(assetMetadata).includes(m.key))
175
+ : [];
176
+ const updatedMetadata = this.assetCategoryService.formatMetadataForES(assetMetadata);
177
+ request.input.body.metadata = [...updatedMetadata, ...previousMetadata];
174
178
  const response = await global.app.trigger('device-manager:asset:update:before', {
175
179
  asset,
176
180
  updates: body
@@ -123,7 +123,7 @@ class RelationalController extends kuzzle_plugin_commons_1.CRUDController {
123
123
  request.input.args.index = request.getString('engineId');
124
124
  const promises = [];
125
125
  promises.push(this.deleteNested(request, nestedFields));
126
- if (manyToManyLinkedFields !== [] || oneToManyLinkedFields !== []) {
126
+ if (manyToManyLinkedFields.length > 0 || oneToManyLinkedFields.length > 0) {
127
127
  const document = await this.sdk.document.get(request.getString('engineId'), this.collection, request.getId());
128
128
  for (const childrenField of manyToManyLinkedFields) {
129
129
  promises.push(this.propagateDelete(document._source[childrenField], childrenField, true, request));
@@ -59,6 +59,9 @@ class MeasureService {
59
59
  * Useful to enrich measures before they are saved.
60
60
  */
61
61
  const { measures: updatedMeasures } = await this.app.trigger('device-manager:measures:process:before', { asset, device, measures });
62
+ if (device._source.engineId) {
63
+ await this.app.trigger(`engine:${device._source.engineId}:device-manager:measures:process:before`, { asset, device, measures });
64
+ }
62
65
  device.updateMeasures(updatedMeasures);
63
66
  await this.sdk.document.update(this.config.adminIndex, InternalCollection_1.InternalCollection.DEVICES, device._id, { measures: device._source.measures });
64
67
  if (device._source.engineId) {
@@ -78,6 +81,9 @@ class MeasureService {
78
81
  * @todo test this
79
82
  */
80
83
  await this.app.trigger('device-manager:measures:process:after', { asset, device, measures });
84
+ if (device._source.engineId) {
85
+ await this.app.trigger(`engine:${device._source.engineId}:device-manager:measures:process:after`, { asset, device, measures });
86
+ }
81
87
  }
82
88
  }
83
89
  buildMeasures(device, asset, measurements, payloadUuids) {
@@ -180,7 +186,7 @@ class MeasureService {
180
186
  deviceMeasureName: null,
181
187
  measuredAt: measurement.measuredAt ? measurement.measuredAt : Date.now(),
182
188
  origin: {
183
- assetId: null,
189
+ assetId,
184
190
  id: kuid,
185
191
  type: types_1.OriginType.USER,
186
192
  },
@@ -46,7 +46,6 @@ export declare const measuresMappings: {
46
46
  * Define the origin of the measure.
47
47
  */
48
48
  origin: {
49
- type: string;
50
49
  properties: {
51
50
  /**
52
51
  * From what the measure has been pushed. Can be:
@@ -42,7 +42,6 @@ exports.measuresMappings = {
42
42
  * Define the origin of the measure.
43
43
  */
44
44
  origin: {
45
- type: 'nested',
46
45
  properties: {
47
46
  /**
48
47
  * From what the measure has been pushed. Can be:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuzzle-device-manager",
3
- "version": "2.0.0-rc15",
3
+ "version": "2.0.0-rc19",
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": {
@@ -31,18 +31,18 @@
31
31
  "lodash": "^4.17.21"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^17.0.21",
35
- "@typescript-eslint/eslint-plugin": "^5.14.0",
36
- "@typescript-eslint/parser": "^5.14.0",
34
+ "@types/node": "^18.7.14",
35
+ "@typescript-eslint/eslint-plugin": "^5.36.1",
36
+ "@typescript-eslint/parser": "^5.36.1",
37
37
  "axios": "^0.27.2",
38
38
  "cucumber": "^6.0.5",
39
39
  "ergol": "^1.0.2",
40
- "eslint": "^8.10.0",
41
- "kuzzle": "^2.18.1",
42
- "kuzzle-sdk": "^7.9.1",
40
+ "eslint": "^8.23.0",
41
+ "kuzzle": "^2.19.3",
42
+ "kuzzle-sdk": "^7.10.0",
43
43
  "should": "^13.2.3",
44
- "ts-node": "^10.7.0",
45
- "typescript": "^4.6.2"
44
+ "ts-node": "^10.9.1",
45
+ "typescript": "^4.8.2"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "kuzzle": "^2.17.3"