kuzzle-device-manager 0.4.13 → 2.0.0-rc3

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.
Files changed (102) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +6 -1
  3. package/lib/DeviceManagerPlugin.d.ts +33 -65
  4. package/lib/DeviceManagerPlugin.js +142 -131
  5. package/lib/controllers/AssetController.d.ts +20 -5
  6. package/lib/controllers/AssetController.js +78 -23
  7. package/lib/controllers/DecodersController.d.ts +16 -0
  8. package/lib/controllers/DecodersController.js +27 -0
  9. package/lib/controllers/DeviceController.d.ts +25 -22
  10. package/lib/controllers/DeviceController.js +150 -109
  11. package/lib/controllers/index.d.ts +1 -1
  12. package/lib/controllers/index.js +6 -2
  13. package/lib/core-classes/AssetService.d.ts +31 -0
  14. package/lib/core-classes/AssetService.js +82 -0
  15. package/lib/core-classes/Decoder.d.ts +14 -59
  16. package/lib/core-classes/Decoder.js +16 -86
  17. package/lib/core-classes/DeviceManagerEngine.d.ts +11 -9
  18. package/lib/core-classes/DeviceManagerEngine.js +20 -32
  19. package/lib/core-classes/DeviceService.d.ts +81 -24
  20. package/lib/core-classes/DeviceService.js +178 -220
  21. package/lib/core-classes/PayloadService.d.ts +39 -26
  22. package/lib/core-classes/PayloadService.js +132 -124
  23. package/lib/core-classes/index.d.ts +5 -4
  24. package/lib/core-classes/index.js +10 -5
  25. package/lib/core-classes/{CustomMappings/AssetMappingsManager.d.ts → registers/AssetsRegister.d.ts} +8 -9
  26. package/lib/core-classes/{CustomMappings/AssetMappingsManager.js → registers/AssetsRegister.js} +17 -28
  27. package/lib/core-classes/registers/DecodersRegister.d.ts +46 -0
  28. package/lib/core-classes/registers/DecodersRegister.js +167 -0
  29. package/lib/core-classes/registers/DevicesRegister.d.ts +20 -0
  30. package/lib/core-classes/registers/DevicesRegister.js +37 -0
  31. package/lib/core-classes/registers/MeasuresRegister.d.ts +29 -0
  32. package/lib/core-classes/registers/MeasuresRegister.js +53 -0
  33. package/lib/mappings/assetsMappings.d.ts +36 -0
  34. package/lib/mappings/assetsMappings.js +36 -0
  35. package/lib/mappings/deviceMappings.d.ts +44 -0
  36. package/lib/mappings/deviceMappings.js +42 -0
  37. package/lib/mappings/index.d.ts +4 -0
  38. package/lib/mappings/index.js +21 -0
  39. package/lib/mappings/measuresMappings.d.ts +53 -0
  40. package/lib/mappings/measuresMappings.js +48 -0
  41. package/lib/mappings/payloadsMappings.d.ts +18 -0
  42. package/lib/mappings/payloadsMappings.js +16 -0
  43. package/lib/measures/BatteryMeasure.d.ts +7 -0
  44. package/lib/measures/BatteryMeasure.js +12 -0
  45. package/lib/measures/HumidityMeasure.d.ts +7 -0
  46. package/lib/measures/HumidityMeasure.js +12 -0
  47. package/lib/measures/MovementMeasure.d.ts +7 -0
  48. package/lib/measures/MovementMeasure.js +12 -0
  49. package/lib/measures/PositionMeasure.d.ts +12 -0
  50. package/lib/measures/PositionMeasure.js +16 -0
  51. package/lib/measures/TemperatureMeasure.d.ts +7 -0
  52. package/lib/measures/TemperatureMeasure.js +12 -0
  53. package/lib/measures/index.d.ts +5 -0
  54. package/lib/measures/index.js +22 -0
  55. package/lib/models/BaseAsset.d.ts +1 -48
  56. package/lib/models/BaseAsset.js +5 -43
  57. package/lib/models/Config.d.ts +1 -13
  58. package/lib/models/Device.d.ts +5 -96
  59. package/lib/models/Device.js +5 -73
  60. package/lib/models/index.d.ts +0 -1
  61. package/lib/models/index.js +5 -2
  62. package/lib/types/BaseAssetContent.d.ts +8 -3
  63. package/lib/types/DecodedPayload.d.ts +42 -0
  64. package/lib/types/{AssetsHistoryContent.js → DecodedPayload.js} +1 -1
  65. package/lib/types/DecoderContent.d.ts +4 -0
  66. package/lib/types/DecoderContent.js +3 -0
  67. package/lib/types/DeviceContent.d.ts +12 -44
  68. package/lib/types/DeviceManagerConfiguration.d.ts +40 -0
  69. package/lib/types/DeviceManagerConfiguration.js +3 -0
  70. package/lib/types/index.d.ts +7 -2
  71. package/lib/types/index.js +12 -3
  72. package/lib/types/measures/MeasureContent.d.ts +56 -0
  73. package/lib/types/measures/MeasureContent.js +3 -0
  74. package/lib/types/measures/MeasureDefinition.d.ts +40 -0
  75. package/lib/types/measures/MeasureDefinition.js +3 -0
  76. package/lib/types/measures/Measurement.d.ts +19 -0
  77. package/lib/types/{Measure.js → measures/Measurement.js} +1 -1
  78. package/lib/utils/index.d.ts +1 -1
  79. package/lib/utils/index.js +6 -2
  80. package/lib/utils/writeMany.d.ts +13 -0
  81. package/lib/utils/writeMany.js +37 -0
  82. package/package.json +14 -18
  83. package/lib/controllers/CRUDController.d.ts +0 -34
  84. package/lib/controllers/CRUDController.js +0 -65
  85. package/lib/core-classes/BatchProcessing/BatchController.d.ts +0 -34
  86. package/lib/core-classes/BatchProcessing/BatchController.js +0 -115
  87. package/lib/core-classes/BatchProcessing/BatchWriter.d.ts +0 -110
  88. package/lib/core-classes/BatchProcessing/BatchWriter.js +0 -264
  89. package/lib/core-classes/BatchProcessing/InstrumentablePromise.d.ts +0 -6
  90. package/lib/core-classes/BatchProcessing/InstrumentablePromise.js +0 -13
  91. package/lib/core-classes/BatchProcessing/index.d.ts +0 -3
  92. package/lib/core-classes/BatchProcessing/index.js +0 -16
  93. package/lib/core-classes/CustomMappings/DeviceMappingsManager.d.ts +0 -43
  94. package/lib/core-classes/CustomMappings/DeviceMappingsManager.js +0 -71
  95. package/lib/core-classes/MigrationService.d.ts +0 -13
  96. package/lib/core-classes/MigrationService.js +0 -49
  97. package/lib/models/Catalog.d.ts +0 -55
  98. package/lib/models/Catalog.js +0 -38
  99. package/lib/types/AssetsHistoryContent.d.ts +0 -9
  100. package/lib/types/Measure.d.ts +0 -54
  101. package/lib/utils/events.d.ts +0 -8
  102. package/lib/utils/events.js +0 -17
@@ -1,6 +1,6 @@
1
1
  import { JSONObject, KuzzleRequest, HttpRoute } from 'kuzzle';
2
- import { Device, BaseAsset } from '../models';
3
- import { AssetMeasures, DeviceContent } from '../types';
2
+ import { DecodedPayload } from '../types/DecodedPayload';
3
+ import { DecoderContent } from '../types';
4
4
  /**
5
5
  * Base class to implement a decoder for a device model.
6
6
  * The device model must be passed to the parent constructor.
@@ -12,6 +12,10 @@ export declare abstract class Decoder {
12
12
  * Device model name
13
13
  */
14
14
  deviceModel: string;
15
+ /**
16
+ * Array of device measure type
17
+ */
18
+ deviceMeasures: string[];
15
19
  /**
16
20
  * Custom name for the associated API action in the "payload" controller
17
21
  */
@@ -40,8 +44,12 @@ export declare abstract class Decoder {
40
44
  get http(): HttpRoute[];
41
45
  /**
42
46
  * @param deviceModel Device model for this decoder
47
+ * @param deviceMeasures Devices measure types for this decoder
48
+ *
49
+ * @example
50
+ * super('AbeewayGPS', ['position']);
43
51
  */
44
- constructor(deviceModel: string);
52
+ constructor(deviceModel: string, deviceMeasures: string[]);
45
53
  /**
46
54
  * Validate the payload format before processing.
47
55
  *
@@ -60,67 +68,13 @@ export declare abstract class Decoder {
60
68
  * Decode the payload:
61
69
  * - set "reference"
62
70
  * - fetch measures
63
- * - fetch qos
64
71
  *
65
72
  * @param payload Raw payload received in the API action body
66
73
  * @param request Original request
67
74
  *
68
- * @returns Device content to save
69
- */
70
- abstract decode(payload: JSONObject, request: KuzzleRequest): Promise<DeviceContent>;
71
- /**
72
- * Hook executed before processing the payload but after validation
73
- *
74
- * @param payload Raw payload received in the API action body
75
- * @param request Original request
76
- */
77
- beforeProcessing(payload: JSONObject, request: KuzzleRequest): Promise<void>;
78
- /**
79
- * Enrichment hook executed before registering a device
80
- *
81
- * @param device Densor before being persisted
82
- * @param request Original request
83
- *
84
- * @returns Enriched device
85
- */
86
- beforeRegister(device: Device, request: KuzzleRequest): Promise<Device>;
87
- /**
88
- * Hook executed after registering a device.
89
- * Return value of this method will be returned in the API action result.
90
- *
91
- * @param device Device after being persisted
92
- * @param request Original request
93
- *
94
- * @returns Result of the corresponding API action
95
- */
96
- afterRegister(device: Device, request: KuzzleRequest): Promise<any>;
97
- /**
98
- * Enrichment hook executed before updating a device
99
- *
100
- * @param device Device before being updated
101
- * @param request Original request
102
- *
103
- * @returns Enriched device
104
- */
105
- beforeUpdate(device: Device, request: KuzzleRequest): Promise<Device>;
106
- /**
107
- * Hook executed after updating a device.
108
- * Return value of this method will be returned in the API action result.
109
- *
110
- * @param device Device after being updated
111
- * @param request Original request
112
- *
113
- * @returns Result of the corresponding API action
114
- */
115
- afterUpdate(device: Device, asset: BaseAsset, request: KuzzleRequest): Promise<any>;
116
- /**
117
- * Build the "measures" property that will be persisted in the asset document
118
- *
119
- * @param device Device after being updated
120
- *
121
- * @returns Content of the "measures" property
75
+ * @returns Measure
122
76
  */
123
- copyToAsset(device: Device): Promise<AssetMeasures>;
77
+ abstract decode(payload: JSONObject, request: KuzzleRequest): Promise<DecodedPayload>;
124
78
  /**
125
79
  * Checks if the provided properties are present in the payload
126
80
  *
@@ -130,4 +84,5 @@ export declare abstract class Decoder {
130
84
  * @throws
131
85
  */
132
86
  ensureProperties(payload: JSONObject, paths: string[]): void | never;
87
+ serialize(): DecoderContent;
133
88
  }
@@ -7,7 +7,6 @@ exports.Decoder = void 0;
7
7
  const kuzzle_1 = require("kuzzle");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  /* eslint-disable @typescript-eslint/no-unused-vars */
10
- /* eslint-disable @typescript-eslint/no-empty-function */
11
10
  /**
12
11
  * Base class to implement a decoder for a device model.
13
12
  * The device model must be passed to the parent constructor.
@@ -16,8 +15,12 @@ const lodash_1 = __importDefault(require("lodash"));
16
15
  class Decoder {
17
16
  /**
18
17
  * @param deviceModel Device model for this decoder
18
+ * @param deviceMeasures Devices measure types for this decoder
19
+ *
20
+ * @example
21
+ * super('AbeewayGPS', ['position']);
19
22
  */
20
- constructor(deviceModel) {
23
+ constructor(deviceModel, deviceMeasures) {
21
24
  /**
22
25
  * Custom mappings for the payload collection.
23
26
  * It will be injected in the "payload" property and it should allows to index
@@ -34,6 +37,7 @@ class Decoder {
34
37
  */
35
38
  this.payloadsMappings = {};
36
39
  this.deviceModel = deviceModel;
40
+ this.deviceMeasures = deviceMeasures;
37
41
  }
38
42
  /**
39
43
  * Define custom HTTP routes
@@ -44,7 +48,10 @@ class Decoder {
44
48
  this._http = http;
45
49
  }
46
50
  get http() {
47
- return this._http || [{ verb: 'post', path: `device-manager/payload/${this.action}` }];
51
+ if (!this._http) {
52
+ this._http = [{ path: `device-manager/payload/${this.action}`, verb: 'post' }];
53
+ }
54
+ return this._http;
48
55
  }
49
56
  /**
50
57
  * Validate the payload format before processing.
@@ -62,88 +69,6 @@ class Decoder {
62
69
  async validate(payload, request) {
63
70
  return true;
64
71
  }
65
- /**
66
- * Hook executed before processing the payload but after validation
67
- *
68
- * @param payload Raw payload received in the API action body
69
- * @param request Original request
70
- */
71
- async beforeProcessing(payload, request) {
72
- }
73
- /**
74
- * Enrichment hook executed before registering a device
75
- *
76
- * @param device Densor before being persisted
77
- * @param request Original request
78
- *
79
- * @returns Enriched device
80
- */
81
- async beforeRegister(device, request) {
82
- return device;
83
- }
84
- /**
85
- * Hook executed after registering a device.
86
- * Return value of this method will be returned in the API action result.
87
- *
88
- * @param device Device after being persisted
89
- * @param request Original request
90
- *
91
- * @returns Result of the corresponding API action
92
- */
93
- async afterRegister(device, request) {
94
- return {
95
- tenantId: device._source.tenantId,
96
- device: device.serialize(),
97
- asset: null,
98
- };
99
- }
100
- /**
101
- * Enrichment hook executed before updating a device
102
- *
103
- * @param device Device before being updated
104
- * @param request Original request
105
- *
106
- * @returns Enriched device
107
- */
108
- async beforeUpdate(device, request) {
109
- return device;
110
- }
111
- /**
112
- * Hook executed after updating a device.
113
- * Return value of this method will be returned in the API action result.
114
- *
115
- * @param device Device after being updated
116
- * @param request Original request
117
- *
118
- * @returns Result of the corresponding API action
119
- */
120
- async afterUpdate(device, asset, request) {
121
- return {
122
- tenantId: device._source.tenantId,
123
- device: device.serialize(),
124
- asset: asset ? asset.serialize() : null,
125
- };
126
- }
127
- /**
128
- * Build the "measures" property that will be persisted in the asset document
129
- *
130
- * @param device Device after being updated
131
- *
132
- * @returns Content of the "measures" property
133
- */
134
- async copyToAsset(device) {
135
- const measures = {};
136
- for (const [measureType, measure] of Object.entries(device._source.measures)) {
137
- measures[measureType] = {
138
- id: device._id,
139
- model: device._source.model,
140
- reference: device._source.reference,
141
- ...measure,
142
- qos: device._source.qos,
143
- };
144
- }
145
- return measures;
146
- }
147
72
  /**
148
73
  * Checks if the provided properties are present in the payload
149
74
  *
@@ -159,8 +84,13 @@ class Decoder {
159
84
  }
160
85
  }
161
86
  }
87
+ serialize() {
88
+ return {
89
+ deviceMeasures: this.deviceMeasures,
90
+ deviceModel: this.deviceModel
91
+ };
92
+ }
162
93
  }
163
94
  exports.Decoder = Decoder;
164
95
  /* eslint-enable @typescript-eslint/no-unused-vars */
165
- /* eslint-enable @typescript-eslint/no-empty-function */
166
96
  //# sourceMappingURL=Decoder.js.map
@@ -1,13 +1,16 @@
1
1
  import { Plugin } from 'kuzzle';
2
- import { AbstractEngine } from 'kuzzle-plugin-commons';
3
- import { DeviceManagerConfig, DeviceManagerPlugin } from '../DeviceManagerPlugin';
4
- import { AssetMappingsManager } from './CustomMappings/AssetMappingsManager';
5
- import { DeviceMappingsManager } from './CustomMappings/DeviceMappingsManager';
2
+ import { AbstractEngine, ConfigManager } from 'kuzzle-plugin-commons';
3
+ import { DeviceManagerConfiguration } from '../types';
4
+ import { DeviceManagerPlugin } from '../DeviceManagerPlugin';
5
+ import { AssetsRegister } from './registers/AssetsRegister';
6
+ import { DevicesRegister } from './registers/DevicesRegister';
7
+ import { MeasuresRegister } from './registers/MeasuresRegister';
6
8
  export declare class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
7
- config: DeviceManagerConfig;
8
- private assetMappings;
9
- private deviceMappings;
10
- constructor(plugin: Plugin, assetMappings: AssetMappingsManager, deviceMappings: DeviceMappingsManager);
9
+ config: DeviceManagerConfiguration;
10
+ private assetsRegister;
11
+ private devicesRegister;
12
+ private measuresRegister;
13
+ constructor(plugin: Plugin, assetsRegister: AssetsRegister, devicesRegister: DevicesRegister, measuresRegister: MeasuresRegister, adminConfigManager: ConfigManager, engineConfigManager: ConfigManager);
11
14
  onCreate(index: string, group?: string): Promise<{
12
15
  collections: string[];
13
16
  }>;
@@ -17,5 +20,4 @@ export declare class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlu
17
20
  onDelete(index: string): Promise<{
18
21
  collections: string[];
19
22
  }>;
20
- private getAssetsHistoryMappings;
21
23
  }
@@ -2,62 +2,50 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceManagerEngine = void 0;
4
4
  const kuzzle_plugin_commons_1 = require("kuzzle-plugin-commons");
5
- const models_1 = require("../models");
6
5
  class DeviceManagerEngine extends kuzzle_plugin_commons_1.AbstractEngine {
7
- constructor(plugin, assetMappings, deviceMappings) {
8
- super('device-manager', plugin, plugin.config.adminIndex, plugin.config.configCollection);
9
- this.assetMappings = assetMappings;
10
- this.deviceMappings = deviceMappings;
6
+ constructor(plugin, assetsRegister, devicesRegister, measuresRegister, adminConfigManager, engineConfigManager) {
7
+ super('device-manager', plugin, plugin.config.adminIndex, adminConfigManager, engineConfigManager);
8
+ this.context = plugin.context;
9
+ this.assetsRegister = assetsRegister;
10
+ this.devicesRegister = devicesRegister;
11
+ this.measuresRegister = measuresRegister;
11
12
  }
12
13
  async onCreate(index, group = 'commons') {
13
14
  const promises = [];
14
15
  promises.push(this.sdk.collection.create(index, 'assets', {
15
- mappings: this.assetMappings.get(group)
16
- }));
17
- promises.push(this.sdk.collection.create(index, 'asset-history', {
18
- mappings: this.getAssetsHistoryMappings(group)
16
+ mappings: this.assetsRegister.getMappings(group)
19
17
  }));
20
18
  promises.push(this.sdk.collection.create(index, 'devices', {
21
- mappings: this.deviceMappings.get()
19
+ mappings: this.devicesRegister.getMappings()
22
20
  }));
23
- promises.push(this.sdk.collection.create(index, this.config.configCollection, {
24
- mappings: {
25
- dynamic: 'strict',
26
- properties: {
27
- type: { type: 'keyword' },
28
- catalog: models_1.catalogMappings,
29
- }
30
- }
21
+ promises.push(this.sdk.collection.create(index, 'measures', {
22
+ mappings: this.measuresRegister.getMappings()
31
23
  }));
24
+ promises.push(this.engineConfigManager.createCollection(index));
32
25
  await Promise.all(promises);
33
- return { collections: ['assets', 'asset-history', this.config.configCollection, 'devices'] };
26
+ return { collections: ['assets', this.engineConfigManager.collection, 'devices', 'measures'] };
34
27
  }
35
28
  async onUpdate(index, group = 'commons') {
36
29
  const promises = [];
37
30
  promises.push(this.sdk.collection.create(index, 'assets', {
38
- mappings: this.assetMappings.get(group)
39
- }));
40
- promises.push(this.sdk.collection.create(index, 'asset-history', {
41
- mappings: this.getAssetsHistoryMappings(group)
31
+ mappings: this.assetsRegister.getMappings(group)
42
32
  }));
43
33
  promises.push(this.sdk.collection.create(index, 'devices', {
44
- mappings: this.deviceMappings.get()
34
+ mappings: this.devicesRegister.getMappings()
35
+ }));
36
+ promises.push(this.sdk.collection.create(index, 'measures', {
37
+ mappings: this.measuresRegister.getMappings()
45
38
  }));
46
39
  await Promise.all(promises);
47
- return { collections: ['assets', 'asset-history', 'devices'] };
40
+ return { collections: ['assets', 'devices', 'measures'] };
48
41
  }
49
42
  async onDelete(index) {
50
43
  const promises = [];
51
44
  promises.push(this.sdk.collection.delete(index, 'assets'));
52
- promises.push(this.sdk.collection.delete(index, 'asset-history'));
53
45
  promises.push(this.sdk.collection.delete(index, 'devices'));
46
+ promises.push(this.sdk.collection.delete(index, 'measures'));
54
47
  await Promise.all(promises);
55
- return { collections: ['assets', 'asset-history', 'devices'] };
56
- }
57
- getAssetsHistoryMappings(group) {
58
- const mappings = JSON.parse(JSON.stringify(this.config.collections['asset-history']));
59
- mappings.properties.asset = this.assetMappings.get(group);
60
- return mappings;
48
+ return { collections: ['assets', 'devices', 'measures'] };
61
49
  }
62
50
  }
63
51
  exports.DeviceManagerEngine = DeviceManagerEngine;
@@ -1,41 +1,98 @@
1
- import { JSONObject, EmbeddedSDK, Plugin } from 'kuzzle';
2
- import { DeviceBulkContent, DeviceMAttachementContent } from '../types';
3
- import { Decoder } from './Decoder';
4
- import { Device } from '../models';
1
+ import { KDocument } from 'kuzzle-sdk';
2
+ import { JSONObject, Plugin } from 'kuzzle';
3
+ import { BaseAsset, Device } from '../models';
4
+ import { DeviceContent } from '../types';
5
+ import { mResponse } from '../utils/';
6
+ export declare type DeviceBulkContent = {
7
+ engineId?: string;
8
+ deviceId: string;
9
+ assetId?: string;
10
+ };
11
+ /**
12
+ * Represents a request to link a device to an asset
13
+ *
14
+ * @example
15
+ * {
16
+ * deviceId: 'Abeeway-4263232',
17
+ * assetId: 'container-xlarger-HSZJSZ',
18
+ * measuresNames: {
19
+ * temperature: 'External temperature',
20
+ * position: 'Lora Position'
21
+ * }
22
+ * }
23
+ */
24
+ export declare type LinkRequest = {
25
+ assetId: string;
26
+ deviceId: string;
27
+ /**
28
+ * List of measures names when linked to the asset.
29
+ * Default measure name is measure type.
30
+ */
31
+ measuresNames?: {
32
+ [measureType: string]: string;
33
+ };
34
+ };
35
+ export declare type AttachRequest = {
36
+ deviceId: string;
37
+ engineId: string;
38
+ };
5
39
  export declare class DeviceService {
6
40
  private config;
7
41
  private context;
8
- private decoders;
9
- get sdk(): EmbeddedSDK;
10
- constructor(plugin: Plugin, decoders: Map<string, Decoder>);
11
- mAttach(devices: Device[], bulkData: DeviceBulkContent[], { strict, options }: {
42
+ private get sdk();
43
+ constructor(plugin: Plugin);
44
+ /**
45
+ * Create a new device.
46
+ *
47
+ * If the engineId is not the administration one, then the device will be
48
+ * automatically attached to the one provided.
49
+ *
50
+ * If an assetId is provided, then the device will be linked to this asset.
51
+ *
52
+ * @param engineId If it's not the admin engine, then the device will be attached to this one
53
+ * @param deviceContent Content of the device to create
54
+ */
55
+ create(engineId: string, deviceContent: DeviceContent, assetId: string, { refresh }: {
56
+ refresh?: any;
57
+ }): Promise<KDocument<DeviceContent>>;
58
+ attachEngine(attachRequest: AttachRequest, { refresh, strict }: {
59
+ refresh?: any;
12
60
  strict?: boolean;
13
- options?: JSONObject;
14
- }): Promise<DeviceMAttachementContent>;
15
- mDetach(devices: Device[], bulkData: DeviceBulkContent[], { strict, options }: {
61
+ }): Promise<Device>;
62
+ detachEngine(deviceId: string, { refresh, strict }: {
63
+ refresh?: any;
16
64
  strict?: boolean;
17
- options?: JSONObject;
65
+ }): Promise<Device>;
66
+ /**
67
+ * Link a device to an asset and copy device measures into the asset.
68
+ *
69
+ * Each measures will be given a distinct name when copied into the asset
70
+ */
71
+ linkAsset(linkRequest: LinkRequest, { refresh }: {
72
+ refresh?: any;
18
73
  }): Promise<{
19
- errors: any[];
20
- successes: any[];
74
+ asset: BaseAsset;
75
+ device: Device;
21
76
  }>;
22
- mLink(devices: Device[], bulkData: DeviceBulkContent[], { strict, options }: {
77
+ unlinkAsset(deviceId: string, { refresh, strict }: {
78
+ refresh?: any;
23
79
  strict?: boolean;
24
- options?: JSONObject;
25
80
  }): Promise<{
26
- errors: any[];
27
- successes: any[];
81
+ asset: BaseAsset;
82
+ device: Device;
28
83
  }>;
29
- mUnlink(devices: Device[], { strict, options }: {
84
+ importDevices(devices: JSONObject, { refresh, strict }: {
85
+ refresh?: any;
30
86
  strict?: boolean;
31
- options?: JSONObject;
32
87
  }): Promise<{
33
88
  errors: any[];
34
89
  successes: any[];
35
90
  }>;
36
- private eraseAssetMeasure;
91
+ importCatalog(catalog: JSONObject[], { refresh, strict }: {
92
+ refresh?: any;
93
+ strict?: boolean;
94
+ }): Promise<mResponse>;
95
+ private getAsset;
96
+ private getDevice;
37
97
  private tenantExists;
38
- private buildBulkDevices;
39
- private formatDevicesContent;
40
- private writeToDatabase;
41
98
  }