kuzzle-device-manager-types 3.0.0-next.7 → 3.0.0-next.8
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/dist/lib/modules/asset/AssetService.d.ts +1 -2
- package/dist/lib/modules/asset/AssetsController.d.ts +9 -1
- package/dist/lib/modules/asset/types/AssetApi.d.ts +83 -0
- package/dist/lib/modules/asset/types/AssetContent.d.ts +7 -9
- package/dist/lib/modules/asset/types/AssetHistoryContent.d.ts +3 -3
- package/dist/lib/modules/device/DeviceService.d.ts +3 -48
- package/dist/lib/modules/device/DevicesController.d.ts +5 -5
- package/dist/lib/modules/device/collections/deviceMappings.d.ts +6 -0
- package/dist/lib/modules/device/roles/RoleDevicesAdmin.d.ts +2 -2
- package/dist/lib/modules/device/types/DeviceApi.d.ts +68 -41
- package/dist/lib/modules/device/types/DeviceContent.d.ts +48 -4
- package/dist/lib/modules/device/types/DeviceEvents.d.ts +0 -23
- package/dist/lib/modules/group/GroupsController.d.ts +5 -5
- package/dist/lib/modules/group/GroupsService.d.ts +6 -6
- package/dist/lib/modules/group/types/GroupsApi.d.ts +7 -7
- package/dist/lib/modules/plugin/DeviceManagerEngine.d.ts +12 -3
- package/dist/lib/modules/plugin/DeviceManagerPlugin.d.ts +2 -2
- package/dist/lib/modules/plugin/types/DeviceManagerConfiguration.d.ts +4 -4
- package/dist/lib/modules/shared/services/DigitalTwinService.d.ts +69 -0
- package/dist/lib/modules/shared/types/DigitalTwinContent.d.ts +2 -5
- package/dist/lib/modules/shared/types/DigitalTwinEvents.d.ts +30 -0
- package/dist/tests/application/assets/Container.d.ts +1 -1
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ export declare class AssetService extends DigitalTwinService {
|
|
|
32
32
|
*/
|
|
33
33
|
delete(engineId: string, assetId: string, request: KuzzleRequest): Promise<void>;
|
|
34
34
|
search(engineId: string, searchParams: SearchParams, request: KuzzleRequest): Promise<SearchResult<KHit<AssetContent>>>;
|
|
35
|
-
migrateTenant(user: User, assetsList: string[], engineId: string, newEngineId: string): Promise<ApiAssetMigrateTenantResult>;
|
|
35
|
+
migrateTenant(user: User, assetsList: string[], engineId: string, newEngineId: string, includeDevices: boolean, request: KuzzleRequest): Promise<ApiAssetMigrateTenantResult>;
|
|
36
36
|
/**
|
|
37
37
|
* Replace an asset metadata
|
|
38
38
|
*/
|
|
@@ -46,6 +46,5 @@ export declare class AssetService extends DigitalTwinService {
|
|
|
46
46
|
* @param model
|
|
47
47
|
*/
|
|
48
48
|
updateModelLocales(request: KuzzleRequest, model: string): Promise<ApiAssetUpdateModelLocales[]>;
|
|
49
|
-
private getEngine;
|
|
50
49
|
private refreshModel;
|
|
51
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ControllerDefinition, KuzzleRequest } from "kuzzle";
|
|
2
2
|
import { DeviceManagerPlugin } from "../plugin";
|
|
3
3
|
import { AssetService } from "./AssetService";
|
|
4
|
-
import { ApiAssetCreateResult, ApiAssetUpsertResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult, ApiAssetMigrateTenantResult, ApiAssetMetadataReplaceResult, ApiAssetGetLastMeasuresResult, ApiAssetMGetLastMeasuredAtResult, ApiAssetMGetLastMeasuresResult, ApiAssetGetLastMeasuredAtResult, ApiAssetUpdateModelLocales } from "./types/AssetApi";
|
|
4
|
+
import { ApiAssetCreateResult, ApiAssetUpsertResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult, ApiAssetMigrateTenantResult, ApiAssetMetadataReplaceResult, ApiAssetGetLastMeasuresResult, ApiAssetMGetLastMeasuredAtResult, ApiAssetMGetLastMeasuresResult, ApiAssetGetLastMeasuredAtResult, ApiAssetUpdateModelLocales, ApiAssetLinkDevicesResult, ApiAssetUnlinkDevicesResult } from "./types/AssetApi";
|
|
5
5
|
export declare class AssetsController {
|
|
6
6
|
private plugin;
|
|
7
7
|
private assetService;
|
|
@@ -42,4 +42,12 @@ export declare class AssetsController {
|
|
|
42
42
|
* @param request
|
|
43
43
|
*/
|
|
44
44
|
updateModelLocales(request: KuzzleRequest): Promise<ApiAssetUpdateModelLocales[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Link an asset to devices.
|
|
47
|
+
*/
|
|
48
|
+
linkDevices(request: KuzzleRequest): Promise<ApiAssetLinkDevicesResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Unlink assets from a device.
|
|
51
|
+
*/
|
|
52
|
+
unlinkDevices(request: KuzzleRequest): Promise<ApiAssetUnlinkDevicesResult>;
|
|
45
53
|
}
|
|
@@ -4,6 +4,7 @@ import { ApiDigitalTwinGetLastMeasuredAtRequest, ApiDigitalTwinGetLastMeasuredAt
|
|
|
4
4
|
import { AssetContent } from "./AssetContent";
|
|
5
5
|
type AssetsControllerName = "device-manager/assets";
|
|
6
6
|
import { ApiMeasureSource } from "../../measure/types/MeasureSources";
|
|
7
|
+
import { DeviceContent } from "lib/modules/device";
|
|
7
8
|
interface AssetsControllerRequest {
|
|
8
9
|
controller: AssetsControllerName;
|
|
9
10
|
engineId: string;
|
|
@@ -155,6 +156,7 @@ export interface ApiAssetMigrateTenantRequest extends AssetsControllerRequest {
|
|
|
155
156
|
body: {
|
|
156
157
|
assetsList: string[];
|
|
157
158
|
newEngineId: string;
|
|
159
|
+
includeDevices?: boolean;
|
|
158
160
|
};
|
|
159
161
|
}
|
|
160
162
|
export type ApiAssetMigrateTenantResult = {
|
|
@@ -169,4 +171,85 @@ export type ApiAssetUpdateModelLocales = {
|
|
|
169
171
|
engineIndex: string;
|
|
170
172
|
result: UpdateByQueryResponse<AssetContent>;
|
|
171
173
|
};
|
|
174
|
+
export interface ApiAssetlinkDevicesRequest extends AssetsControllerRequest {
|
|
175
|
+
action: "linkDevices";
|
|
176
|
+
_id: string;
|
|
177
|
+
refresh?: string;
|
|
178
|
+
body: {
|
|
179
|
+
linkedMeasures: Array<{
|
|
180
|
+
deviceId: string;
|
|
181
|
+
/**
|
|
182
|
+
* This option allows to not specify the names of all the measures that should
|
|
183
|
+
* be linked to the asset.
|
|
184
|
+
*
|
|
185
|
+
* The algorithm will go through all the measures names provided by the device
|
|
186
|
+
* and add the one who are present with the same name in the asset.
|
|
187
|
+
*
|
|
188
|
+
* It will not add the measure if:
|
|
189
|
+
* - it has been specified in the link request
|
|
190
|
+
* - it was already present in the asset
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* if the device provide a measure of type "temperature" with the name "temp"
|
|
194
|
+
* if the asset has declared a measure of type "temperature" with the name "temp"
|
|
195
|
+
* then the measure will be automatically added in the link and will later be propagated to the asset
|
|
196
|
+
*/
|
|
197
|
+
implicitMeasuresLinking?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Names of the linked measures.
|
|
200
|
+
*
|
|
201
|
+
* Array<{ asset: string, device: string }>
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
*
|
|
205
|
+
* [
|
|
206
|
+
* { asset: "externalTemperature", device: "temperature" }
|
|
207
|
+
* ]
|
|
208
|
+
*/
|
|
209
|
+
measureSlots?: Array<{
|
|
210
|
+
asset: string;
|
|
211
|
+
device: string;
|
|
212
|
+
}>;
|
|
213
|
+
}>;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export type ApiAssetLinkDevicesResult = {
|
|
217
|
+
asset: KDocument<AssetContent>;
|
|
218
|
+
devices: KDocument<DeviceContent>[];
|
|
219
|
+
};
|
|
220
|
+
export interface ApiAssetUnlinkDevicesRequest extends AssetsControllerRequest {
|
|
221
|
+
action: "unlinkDevices";
|
|
222
|
+
_id: string;
|
|
223
|
+
strict?: boolean;
|
|
224
|
+
refresh?: string;
|
|
225
|
+
body: {
|
|
226
|
+
linkedMeasures: Array<{
|
|
227
|
+
deviceId: string;
|
|
228
|
+
/**
|
|
229
|
+
* This option allows to not specify the names of all the measures that should
|
|
230
|
+
* be unlinked from the asset.
|
|
231
|
+
*/
|
|
232
|
+
allMeasures?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Names of the linked measures.
|
|
235
|
+
*
|
|
236
|
+
* Array<{ asset: string, device: string }>
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
*
|
|
240
|
+
* [
|
|
241
|
+
* { asset: "externalTemperature", device: "temperature" }
|
|
242
|
+
* ]
|
|
243
|
+
*/
|
|
244
|
+
measureSlots?: Array<{
|
|
245
|
+
asset: string;
|
|
246
|
+
device: string;
|
|
247
|
+
}>;
|
|
248
|
+
}>;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
export type ApiAssetUnlinkDevicesResult = {
|
|
252
|
+
asset: KDocument<AssetContent>;
|
|
253
|
+
devices: KDocument<DeviceContent>[];
|
|
254
|
+
};
|
|
172
255
|
export {};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { JSONObject } from "kuzzle-sdk";
|
|
2
1
|
import { DigitalTwinContent, Metadata } from "../../shared";
|
|
3
2
|
/**
|
|
4
3
|
* Asset document content
|
|
5
4
|
*/
|
|
6
|
-
export interface AssetContent<
|
|
5
|
+
export interface AssetContent<TMetadata extends Metadata = any> extends DigitalTwinContent<TMetadata> {
|
|
7
6
|
/**
|
|
8
|
-
* Link with attached
|
|
7
|
+
* Link with attached devices
|
|
9
8
|
*/
|
|
10
|
-
|
|
9
|
+
linkedMeasures: Array<{
|
|
11
10
|
/**
|
|
12
11
|
* Device ID
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
deviceId: string;
|
|
15
14
|
/**
|
|
16
15
|
* Names of the linked measures
|
|
17
16
|
*
|
|
@@ -20,13 +19,12 @@ export interface AssetContent<TMeasures extends JSONObject = any, TMetadata exte
|
|
|
20
19
|
* @example
|
|
21
20
|
*
|
|
22
21
|
* [
|
|
23
|
-
* { asset: "externalTemperature", device: "temperature"
|
|
22
|
+
* { asset: "externalTemperature", device: "temperature" }
|
|
24
23
|
* ]
|
|
25
24
|
*/
|
|
26
|
-
|
|
25
|
+
measureSlots: Array<{
|
|
27
26
|
asset: string;
|
|
28
27
|
device: string;
|
|
29
|
-
type: string;
|
|
30
28
|
}>;
|
|
31
29
|
}>;
|
|
32
30
|
/**
|
|
@@ -49,4 +47,4 @@ export type AssetMeasureContext<TMetadata extends Metadata = Metadata> = {
|
|
|
49
47
|
* Name of the measure for the Asset
|
|
50
48
|
*/
|
|
51
49
|
measureName: string;
|
|
52
|
-
} & Pick<AssetContent<
|
|
50
|
+
} & Pick<AssetContent<TMetadata>, "model" | "reference" | "metadata" | "groups">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KDocumentContent } from "kuzzle-sdk";
|
|
2
2
|
import { Metadata } from "../../shared";
|
|
3
3
|
import { AssetContent } from "./AssetContent";
|
|
4
4
|
export type AssetHistoryMetadata = {
|
|
@@ -24,7 +24,7 @@ export type AssetHistoryEvent = AssetHistoryEventMetadata | AssetHistoryEventLin
|
|
|
24
24
|
/**
|
|
25
25
|
* Asset History document content
|
|
26
26
|
*/
|
|
27
|
-
export interface AssetHistoryContent<TAssetHistoryEvent extends AssetHistoryEvent = any,
|
|
27
|
+
export interface AssetHistoryContent<TAssetHistoryEvent extends AssetHistoryEvent = any, TMetadata extends Metadata = any> extends KDocumentContent {
|
|
28
28
|
/**
|
|
29
29
|
* Name of the event who caused the historization
|
|
30
30
|
*
|
|
@@ -41,7 +41,7 @@ export interface AssetHistoryContent<TAssetHistoryEvent extends AssetHistoryEven
|
|
|
41
41
|
/**
|
|
42
42
|
* Asset content after the event
|
|
43
43
|
*/
|
|
44
|
-
asset: AssetContent<
|
|
44
|
+
asset: AssetContent<TMetadata>;
|
|
45
45
|
/**
|
|
46
46
|
* Timestamp of the event according to its type
|
|
47
47
|
*
|
|
@@ -3,23 +3,18 @@ import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
|
|
|
3
3
|
import { DecodedMeasurement } from "../measure";
|
|
4
4
|
import { DeviceManagerPlugin } from "../plugin";
|
|
5
5
|
import { DigitalTwinService, Metadata, SearchParams } from "../shared";
|
|
6
|
-
import {
|
|
7
|
-
import { ApiDeviceLinkAssetRequest } from "./types/DeviceApi";
|
|
8
|
-
import { DeviceContent } from "./types/DeviceContent";
|
|
6
|
+
import { DeviceProvisioningContent, DeviceContent } from "./types/DeviceContent";
|
|
9
7
|
export declare class DeviceService extends DigitalTwinService {
|
|
10
8
|
constructor(plugin: DeviceManagerPlugin);
|
|
11
9
|
registerAskEvents(): void;
|
|
12
10
|
private _create;
|
|
11
|
+
private _createDeviceProvisioning;
|
|
13
12
|
/**
|
|
14
13
|
* Create a new device.
|
|
15
14
|
*
|
|
16
|
-
* @todo creating a device in the "device-manager" index should be a separate
|
|
17
|
-
* method since in this case "engineId" is not really an engine ID but still
|
|
18
|
-
* required as an argument (in part to check the tenant rights)
|
|
19
15
|
*/
|
|
20
16
|
create(model: string, reference: string, metadata: JSONObject, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
|
|
21
17
|
get(engineId: string, deviceId: string, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
|
|
22
|
-
private getInternalDevices;
|
|
23
18
|
/**
|
|
24
19
|
* Replace a device metadata
|
|
25
20
|
*/
|
|
@@ -37,7 +32,6 @@ export declare class DeviceService extends DigitalTwinService {
|
|
|
37
32
|
* @param engineId Engine id to attach to
|
|
38
33
|
* @param deviceId Device id to attach
|
|
39
34
|
* @param options.refresh Wait for ES indexation
|
|
40
|
-
* @param options.strict If true, throw if an operation isn't possible
|
|
41
35
|
*/
|
|
42
36
|
private _attachEngine;
|
|
43
37
|
/**
|
|
@@ -55,48 +49,9 @@ export declare class DeviceService extends DigitalTwinService {
|
|
|
55
49
|
* @param {string} deviceId Id of the device
|
|
56
50
|
* @param {KuzzleRequest} request kuzzle request
|
|
57
51
|
*/
|
|
58
|
-
detachEngine(deviceId: string, request: KuzzleRequest): Promise<KDocument<
|
|
59
|
-
/**
|
|
60
|
-
* Link a device to an asset.
|
|
61
|
-
*/
|
|
62
|
-
linkAsset(engineId: string, deviceId: string, assetId: string, measureNames: ApiDeviceLinkAssetRequest["body"]["measureNames"], implicitMeasuresLinking: boolean, request: KuzzleRequest): Promise<{
|
|
63
|
-
asset: KDocument<AssetContent>;
|
|
64
|
-
device: KDocument<DeviceContent>;
|
|
65
|
-
}>;
|
|
52
|
+
detachEngine(deviceId: string, request: KuzzleRequest): Promise<KDocument<DeviceProvisioningContent>>;
|
|
66
53
|
receiveMeasures(engineId: string, deviceId: string, measures: DecodedMeasurement[], payloadUuids: string[], request: KuzzleRequest): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Checks if the asset does not already have a linked device using one of the
|
|
69
|
-
* requested measure names.
|
|
70
|
-
*/
|
|
71
|
-
private checkAlreadyProvidedMeasures;
|
|
72
|
-
/**
|
|
73
|
-
* Goes through the device available measures and add them into the link if:
|
|
74
|
-
* - they are not already provided by another device
|
|
75
|
-
* - they are not already present in the link request
|
|
76
|
-
* - they are declared in the asset model
|
|
77
|
-
*/
|
|
78
|
-
private generateMissingAssetMeasureNames;
|
|
79
|
-
/**
|
|
80
|
-
* Internal logic of unlink a device of an asset
|
|
81
|
-
*
|
|
82
|
-
* @param {string} deviceId Id of the device
|
|
83
|
-
* @param {KuzzleRequest} request kuzzle request
|
|
84
|
-
*/
|
|
85
|
-
private _unlinkAsset;
|
|
86
|
-
/**
|
|
87
|
-
* Unlink a device of an asset with lock
|
|
88
|
-
*
|
|
89
|
-
* @param {string} deviceId Id of the device
|
|
90
|
-
* @param {KuzzleRequest} request kuzzle request
|
|
91
|
-
*/
|
|
92
|
-
unlinkAsset(deviceId: string, request: KuzzleRequest): Promise<{
|
|
93
|
-
asset: KDocument<AssetContent>;
|
|
94
|
-
device: KDocument<DeviceContent>;
|
|
95
|
-
}>;
|
|
96
54
|
private checkEngineExists;
|
|
97
55
|
private checkAttachedToEngine;
|
|
98
|
-
private getEngine;
|
|
99
|
-
private getDeviceModel;
|
|
100
|
-
private getAssetModel;
|
|
101
56
|
private refreshModel;
|
|
102
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ControllerDefinition, KuzzleRequest } from "kuzzle";
|
|
2
2
|
import { DeviceManagerPlugin } from "../plugin";
|
|
3
3
|
import { DeviceService } from "./DeviceService";
|
|
4
|
-
import { ApiDeviceAttachEngineResult, ApiDeviceCreateResult, ApiDeviceDeleteResult, ApiDeviceDetachEngineResult, ApiDeviceGetResult,
|
|
4
|
+
import { ApiDeviceAttachEngineResult, ApiDeviceCreateResult, ApiDeviceDeleteResult, ApiDeviceDetachEngineResult, ApiDeviceGetResult, ApiDeviceLinkAssetsResult, ApiDeviceSearchResult, ApiDeviceUnlinkAssetsResult, ApiDeviceUpdateResult, ApiDeviceGetMeasuresResult, ApiDeviceUpsertResult, ApiDeviceGetLastMeasuresResult, ApiDeviceMGetLastMeasuresResult, ApiDeviceGetLastMeasuredAtResult, ApiDeviceMGetLastMeasuredAtResult, ApiDeviceMetadataReplaceResult } from "./types/DeviceApi";
|
|
5
5
|
export declare class DevicesController {
|
|
6
6
|
private plugin;
|
|
7
7
|
private deviceService;
|
|
@@ -28,13 +28,13 @@ export declare class DevicesController {
|
|
|
28
28
|
*/
|
|
29
29
|
detachEngine(request: KuzzleRequest): Promise<ApiDeviceDetachEngineResult>;
|
|
30
30
|
/**
|
|
31
|
-
* Link a device to
|
|
31
|
+
* Link a device to several assets.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
linkAssets(request: KuzzleRequest): Promise<ApiDeviceLinkAssetsResult>;
|
|
34
34
|
/**
|
|
35
|
-
* Unlink
|
|
35
|
+
* Unlink assets from a device.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
unlinkAssets(request: KuzzleRequest): Promise<ApiDeviceUnlinkAssetsResult>;
|
|
38
38
|
getMeasures(request: KuzzleRequest): Promise<ApiDeviceGetMeasuresResult>;
|
|
39
39
|
getLastMeasures(request: KuzzleRequest): Promise<ApiDeviceGetLastMeasuresResult>;
|
|
40
40
|
mGetLastMeasures(request: KuzzleRequest): Promise<ApiDeviceMGetLastMeasuresResult>;
|
|
@@ -5,3 +5,9 @@ import { CollectionMappings } from "kuzzle";
|
|
|
5
5
|
* Those mappings does not contains the `measures` and `metadata` mappings.
|
|
6
6
|
*/
|
|
7
7
|
export declare const devicesMappings: CollectionMappings;
|
|
8
|
+
/**
|
|
9
|
+
* Mappings for the "devices" collection of the platform index.
|
|
10
|
+
*
|
|
11
|
+
* Those mappings does not contains the `measures`, `groups` and `metadata` mappings.
|
|
12
|
+
*/
|
|
13
|
+
export declare const devicesPlatformMappings: CollectionMappings;
|
|
@@ -10,9 +10,9 @@ import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
|
10
10
|
create: true,
|
|
11
11
|
delete: true,
|
|
12
12
|
get: true,
|
|
13
|
-
|
|
13
|
+
linkAssets: true,
|
|
14
14
|
search: true,
|
|
15
|
-
|
|
15
|
+
unlinkAssets: true,
|
|
16
16
|
update: true,
|
|
17
17
|
getMeasures: true,
|
|
18
18
|
exportMeasures: true,
|
|
@@ -59,14 +59,39 @@ export interface ApiDeviceSearchRequest extends DevicesControllerRequest {
|
|
|
59
59
|
body: JSONObject;
|
|
60
60
|
}
|
|
61
61
|
export type ApiDeviceSearchResult = SearchResult<KHit<DeviceContent>>;
|
|
62
|
-
export interface
|
|
63
|
-
action: "
|
|
62
|
+
export interface ApiDeviceUnlinkAssetsRequest extends DevicesControllerRequest {
|
|
63
|
+
action: "unlinkAssets";
|
|
64
64
|
_id: string;
|
|
65
65
|
strict?: boolean;
|
|
66
66
|
refresh?: string;
|
|
67
|
+
body: {
|
|
68
|
+
linkedMeasures: Array<{
|
|
69
|
+
assetId: string;
|
|
70
|
+
/**
|
|
71
|
+
* This option allows to not specify the names of all the measures that should
|
|
72
|
+
* be unlinked from the asset.
|
|
73
|
+
*/
|
|
74
|
+
allMeasures?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Names of the linked measures.
|
|
77
|
+
*
|
|
78
|
+
* Array<{ asset: string, device: string }>
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
*
|
|
82
|
+
* [
|
|
83
|
+
* { asset: "externalTemperature", device: "temperature" }
|
|
84
|
+
* ]
|
|
85
|
+
*/
|
|
86
|
+
measureSlots?: Array<{
|
|
87
|
+
asset: string;
|
|
88
|
+
device: string;
|
|
89
|
+
}>;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
67
92
|
}
|
|
68
|
-
export type
|
|
69
|
-
|
|
93
|
+
export type ApiDeviceUnlinkAssetsResult = {
|
|
94
|
+
assets: KDocument<AssetContent>[];
|
|
70
95
|
device: KDocument<DeviceContent>;
|
|
71
96
|
};
|
|
72
97
|
export interface ApiDeviceAttachEngineRequest extends DevicesControllerRequest {
|
|
@@ -81,48 +106,50 @@ export interface ApiDeviceDetachEngineRequest extends DevicesControllerRequest {
|
|
|
81
106
|
refresh?: string;
|
|
82
107
|
}
|
|
83
108
|
export type ApiDeviceDetachEngineResult = void;
|
|
84
|
-
export interface
|
|
85
|
-
action: "
|
|
109
|
+
export interface ApiDeviceLinkAssetsRequest extends DevicesControllerRequest {
|
|
110
|
+
action: "linkAssets";
|
|
86
111
|
_id: string;
|
|
87
112
|
refresh?: string;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
body: {
|
|
114
|
+
linkedMeasures: Array<{
|
|
115
|
+
assetId: string;
|
|
116
|
+
/**
|
|
117
|
+
* This option allows to not specify the names of all the measures that should
|
|
118
|
+
* be linked to the asset.
|
|
119
|
+
*
|
|
120
|
+
* The algorithm will go through all the measures names provided by the device
|
|
121
|
+
* and add the one who are present with the same name in the asset.
|
|
122
|
+
*
|
|
123
|
+
* It will not add the measure if:
|
|
124
|
+
* - it has been specified in the link request
|
|
125
|
+
* - it was already present in the asset
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* if the device provide a measure of type "temperature" with the name "temp"
|
|
129
|
+
* if the asset has declared a measure of type "temperature" with the name "temp"
|
|
130
|
+
* then the measure will be automatically added in the link and will later be propagated to the asset
|
|
131
|
+
*/
|
|
132
|
+
implicitMeasuresLinking?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Names of the linked measures.
|
|
135
|
+
*
|
|
136
|
+
* Array<{ asset: string, device: string }>
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
*
|
|
140
|
+
* [
|
|
141
|
+
* { asset: "externalTemperature", device: "temperature" }
|
|
142
|
+
* ]
|
|
143
|
+
*/
|
|
144
|
+
measureSlots?: Array<{
|
|
145
|
+
asset: string;
|
|
146
|
+
device: string;
|
|
147
|
+
}>;
|
|
121
148
|
}>;
|
|
122
149
|
};
|
|
123
150
|
}
|
|
124
|
-
export type
|
|
125
|
-
|
|
151
|
+
export type ApiDeviceLinkAssetsResult = {
|
|
152
|
+
assets: KDocument<AssetContent>[];
|
|
126
153
|
device: KDocument<DeviceContent>;
|
|
127
154
|
};
|
|
128
155
|
export interface ApiDeviceGetMeasuresRequest extends DevicesControllerRequest {
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
import { JSONObject } from "kuzzle-sdk";
|
|
1
|
+
import { JSONObject, KDocumentContent } from "kuzzle-sdk";
|
|
2
2
|
import { DigitalTwinContent, Metadata } from "../../shared";
|
|
3
3
|
/**
|
|
4
4
|
* Device document content
|
|
5
5
|
*/
|
|
6
|
-
export interface DeviceContent<
|
|
6
|
+
export interface DeviceContent<TMetadata extends Metadata = any> extends DigitalTwinContent<TMetadata> {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Link with attached assets
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
linkedMeasures: Array<{
|
|
11
|
+
/**
|
|
12
|
+
* Asset ID
|
|
13
|
+
*/
|
|
14
|
+
assetId: string;
|
|
15
|
+
/**
|
|
16
|
+
* Slots of the linked measures
|
|
17
|
+
*
|
|
18
|
+
* Array<{ asset: string, device: string, type: string }>
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* [
|
|
23
|
+
* { asset: "externalTemperature", device: "temperature", }
|
|
24
|
+
* ]
|
|
25
|
+
*/
|
|
26
|
+
measureSlots: Array<{
|
|
27
|
+
asset: string;
|
|
28
|
+
device: string;
|
|
29
|
+
}>;
|
|
30
|
+
}>;
|
|
11
31
|
/**
|
|
12
32
|
*/
|
|
13
33
|
engineId: string;
|
|
@@ -19,3 +39,27 @@ export interface DeviceContent<TMeasures extends JSONObject = any, TMetadata ext
|
|
|
19
39
|
date: number;
|
|
20
40
|
}>;
|
|
21
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Platform index Device document content
|
|
44
|
+
*/
|
|
45
|
+
interface DeviceProvisioningContentFields extends Pick<DeviceContent, "model" | "reference" | "engineId" | "measureSlots"> {
|
|
46
|
+
/**
|
|
47
|
+
* Date of provisioning of the device on the platform
|
|
48
|
+
*/
|
|
49
|
+
provisionedAt: number;
|
|
50
|
+
/**
|
|
51
|
+
* Date of last measure from the device
|
|
52
|
+
*/
|
|
53
|
+
lastMeasuredAt: number | null;
|
|
54
|
+
/**
|
|
55
|
+
* An array containing the 5 last measures from the device
|
|
56
|
+
*/
|
|
57
|
+
lastMeasures: Array<{
|
|
58
|
+
measureName: string;
|
|
59
|
+
values: JSONObject;
|
|
60
|
+
measuredAt: number;
|
|
61
|
+
type: string;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export type DeviceProvisioningContent = DeviceProvisioningContentFields & KDocumentContent;
|
|
65
|
+
export {};
|
|
@@ -3,7 +3,6 @@ import { KDocument } from "kuzzle-sdk";
|
|
|
3
3
|
import { DeviceModelContent } from "../../../modules/model";
|
|
4
4
|
import { Metadata } from "../../../modules/shared";
|
|
5
5
|
import { DeviceContent } from "./DeviceContent";
|
|
6
|
-
import { ApiDeviceLinkAssetRequest } from "./DeviceApi";
|
|
7
6
|
export type EventDeviceUpdateBefore = {
|
|
8
7
|
name: "device-manager:device:update:before";
|
|
9
8
|
args: [{
|
|
@@ -18,28 +17,6 @@ export type EventDeviceUpdateAfter = {
|
|
|
18
17
|
metadata: Metadata;
|
|
19
18
|
}];
|
|
20
19
|
};
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export type AskDeviceLinkAsset = {
|
|
25
|
-
name: "ask:device-manager:device:link-asset";
|
|
26
|
-
payload: {
|
|
27
|
-
engineId: string;
|
|
28
|
-
assetId: string;
|
|
29
|
-
deviceId: string;
|
|
30
|
-
user: User;
|
|
31
|
-
measureNames: ApiDeviceLinkAssetRequest["body"]["measureNames"];
|
|
32
|
-
};
|
|
33
|
-
result: void;
|
|
34
|
-
};
|
|
35
|
-
export type AskDeviceUnlinkAsset = {
|
|
36
|
-
name: "ask:device-manager:device:unlink-asset";
|
|
37
|
-
payload: {
|
|
38
|
-
deviceId: string;
|
|
39
|
-
user: User;
|
|
40
|
-
};
|
|
41
|
-
result: void;
|
|
42
|
-
};
|
|
43
20
|
export type AskDeviceDetachEngine = {
|
|
44
21
|
name: "ask:device-manager:device:detach-engine";
|
|
45
22
|
payload: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ControllerDefinition, KuzzleRequest } from "kuzzle";
|
|
2
2
|
import { DeviceManagerPlugin } from "../plugin";
|
|
3
|
-
import { ApiGroupAddAssetsResult, ApiGroupAddDevicesResult, ApiGroupCreateResult, ApiGroupDeleteResult, ApiGroupGetResult, ApiGroupListItemsResult, ApiGroupMCreateResult, ApiGroupMUpdateResult, ApiGroupMUpsertResult, ApiGroupRemoveAssetsResult,
|
|
3
|
+
import { ApiGroupAddAssetsResult, ApiGroupAddDevicesResult, ApiGroupCreateResult, ApiGroupDeleteResult, ApiGroupGetResult, ApiGroupListItemsResult, ApiGroupMCreateResult, ApiGroupMUpdateResult, ApiGroupMUpsertResult, ApiGroupRemoveAssetsResult, ApiGroupRemoveDevicesResult, ApiGroupSearchResult, ApiGroupUpdateResult, ApiGroupUpsertResult, GroupsBodyRequest } from "./types/GroupsApi";
|
|
4
4
|
import { GroupsService } from "./GroupsService";
|
|
5
5
|
export declare class GroupsController {
|
|
6
6
|
private plugin;
|
|
@@ -25,10 +25,10 @@ export declare class GroupsController {
|
|
|
25
25
|
delete(request: KuzzleRequest): Promise<ApiGroupDeleteResult>;
|
|
26
26
|
search(request: KuzzleRequest): Promise<ApiGroupSearchResult>;
|
|
27
27
|
listItems(request: KuzzleRequest): Promise<ApiGroupListItemsResult>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
addAssets(request: KuzzleRequest): Promise<ApiGroupAddAssetsResult>;
|
|
29
|
+
removeAssets(request: KuzzleRequest): Promise<ApiGroupRemoveAssetsResult>;
|
|
30
|
+
addDevices(request: KuzzleRequest): Promise<ApiGroupAddDevicesResult>;
|
|
31
|
+
removeDevices(request: KuzzleRequest): Promise<ApiGroupRemoveDevicesResult>;
|
|
32
32
|
mCreate(request: KuzzleRequest): Promise<ApiGroupMCreateResult>;
|
|
33
33
|
mUpdate(request: KuzzleRequest): Promise<ApiGroupMUpdateResult>;
|
|
34
34
|
mUpsert(request: KuzzleRequest): Promise<ApiGroupMUpsertResult>;
|
|
@@ -19,15 +19,15 @@ export declare class GroupsService extends BaseService {
|
|
|
19
19
|
size?: number;
|
|
20
20
|
}, request: KuzzleRequest): Promise<{
|
|
21
21
|
assets: {
|
|
22
|
-
hits: import("kuzzle-sdk").KHit<AssetContent<any
|
|
22
|
+
hits: import("kuzzle-sdk").KHit<AssetContent<any>>[];
|
|
23
23
|
total: number;
|
|
24
24
|
};
|
|
25
25
|
devices: {
|
|
26
|
-
hits: import("kuzzle-sdk").KHit<DeviceContent<any
|
|
26
|
+
hits: import("kuzzle-sdk").KHit<DeviceContent<any>>[];
|
|
27
27
|
total: number;
|
|
28
28
|
};
|
|
29
29
|
}>;
|
|
30
|
-
|
|
30
|
+
addAssets(engineId: string, path: string, assetIds: string[], request: KuzzleRequest): Promise<{
|
|
31
31
|
group: KDocument<GroupContent>;
|
|
32
32
|
successes: {
|
|
33
33
|
_id: string;
|
|
@@ -43,7 +43,7 @@ export declare class GroupsService extends BaseService {
|
|
|
43
43
|
reason: string;
|
|
44
44
|
}[];
|
|
45
45
|
}>;
|
|
46
|
-
|
|
46
|
+
removeAssets(engineId: string, path: string, assetIds: string[], request: KuzzleRequest): Promise<{
|
|
47
47
|
group: KDocument<GroupContent>;
|
|
48
48
|
successes: {
|
|
49
49
|
_id: string;
|
|
@@ -59,7 +59,7 @@ export declare class GroupsService extends BaseService {
|
|
|
59
59
|
reason: string;
|
|
60
60
|
}[];
|
|
61
61
|
}>;
|
|
62
|
-
|
|
62
|
+
addDevices(engineId: string, path: string, deviceIds: string[], request: KuzzleRequest): Promise<{
|
|
63
63
|
group: KDocument<GroupContent>;
|
|
64
64
|
successes: {
|
|
65
65
|
_id: string;
|
|
@@ -75,7 +75,7 @@ export declare class GroupsService extends BaseService {
|
|
|
75
75
|
reason: string;
|
|
76
76
|
}[];
|
|
77
77
|
}>;
|
|
78
|
-
|
|
78
|
+
removeDevices(engineId: string, path: string, deviceIds: string[], request: KuzzleRequest): Promise<{
|
|
79
79
|
group: KDocument<GroupContent>;
|
|
80
80
|
successes: {
|
|
81
81
|
_id: string;
|
|
@@ -68,7 +68,7 @@ export type ApiGroupListItemsResult = {
|
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
70
|
export interface ApiGroupAddAssetsRequest extends GroupControllerRequest {
|
|
71
|
-
action: "
|
|
71
|
+
action: "addAssets";
|
|
72
72
|
body: {
|
|
73
73
|
path: string;
|
|
74
74
|
assetIds: string[];
|
|
@@ -76,29 +76,29 @@ export interface ApiGroupAddAssetsRequest extends GroupControllerRequest {
|
|
|
76
76
|
}
|
|
77
77
|
export type ApiGroupAddAssetsResult = UpdateLinkResponse;
|
|
78
78
|
export interface ApiGroupRemoveAssetsRequest extends GroupControllerRequest {
|
|
79
|
-
action: "
|
|
79
|
+
action: "removeAssets";
|
|
80
80
|
body: {
|
|
81
81
|
path: string;
|
|
82
82
|
assetIds: string[];
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
export type ApiGroupRemoveAssetsResult = UpdateLinkResponse;
|
|
86
|
-
export interface
|
|
87
|
-
action: "
|
|
86
|
+
export interface ApiGroupAddDevicesRequest extends GroupControllerRequest {
|
|
87
|
+
action: "addDevices";
|
|
88
88
|
body: {
|
|
89
89
|
path: string;
|
|
90
90
|
deviceIds: string[];
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
export type ApiGroupAddDevicesResult = UpdateLinkResponse;
|
|
94
|
-
export interface
|
|
95
|
-
action: "
|
|
94
|
+
export interface ApiGroupRemoveDevicesRequest extends GroupControllerRequest {
|
|
95
|
+
action: "removeDevices";
|
|
96
96
|
body: {
|
|
97
97
|
path: string;
|
|
98
98
|
deviceIds: string[];
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
export type
|
|
101
|
+
export type ApiGroupRemoveDevicesResult = UpdateLinkResponse;
|
|
102
102
|
export interface ApiGroupMCreateRequest extends GroupControllerRequest {
|
|
103
103
|
action: "mCreate";
|
|
104
104
|
body: {
|
|
@@ -42,7 +42,7 @@ export type AskEngineUpdateConflict = {
|
|
|
42
42
|
export declare class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
|
|
43
43
|
config: DeviceManagerConfiguration;
|
|
44
44
|
get app(): Backend;
|
|
45
|
-
constructor(plugin: Plugin,
|
|
45
|
+
constructor(plugin: Plugin, platformConfigManager: ConfigManager, engineConfigManager: ConfigManager);
|
|
46
46
|
/**
|
|
47
47
|
* Return conflicts between the new and already present twin models
|
|
48
48
|
*
|
|
@@ -124,6 +124,15 @@ export declare class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlu
|
|
|
124
124
|
* @throws If it failed during the devices collection creation
|
|
125
125
|
*/
|
|
126
126
|
createDevicesCollection(engineId: string): Promise<InternalCollection>;
|
|
127
|
+
/**
|
|
128
|
+
* Generate devices mappings and create the devices collection in the engine
|
|
129
|
+
*
|
|
130
|
+
* @param engineId The target engine Id
|
|
131
|
+
* @param engineGroup The engine group
|
|
132
|
+
*
|
|
133
|
+
* @throws If it failed during the devices collection creation
|
|
134
|
+
*/
|
|
135
|
+
createPlatformDevicesCollection(): Promise<InternalCollection>;
|
|
127
136
|
/**
|
|
128
137
|
* Generate measures mappings and create the measures collection in the engine
|
|
129
138
|
*
|
|
@@ -186,10 +195,10 @@ export declare class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlu
|
|
|
186
195
|
*/
|
|
187
196
|
private getModels;
|
|
188
197
|
/**
|
|
189
|
-
* Detach all devices of an index in the
|
|
198
|
+
* Detach all devices of an index in the platform index
|
|
190
199
|
*
|
|
191
200
|
* @param engineId The target engine Id
|
|
192
201
|
* @returns {any}
|
|
193
202
|
*/
|
|
194
|
-
private
|
|
203
|
+
private detachDevicesFromPlatformIndex;
|
|
195
204
|
}
|
|
@@ -6,7 +6,7 @@ import { DeviceManagerConfiguration } from "./types/DeviceManagerConfiguration";
|
|
|
6
6
|
export declare class DeviceManagerPlugin extends Plugin {
|
|
7
7
|
config: DeviceManagerConfiguration;
|
|
8
8
|
private deviceManagerEngine;
|
|
9
|
-
private
|
|
9
|
+
private platformConfigManager;
|
|
10
10
|
private engineConfigManager;
|
|
11
11
|
private engineController;
|
|
12
12
|
private assetModule;
|
|
@@ -254,7 +254,7 @@ export declare class DeviceManagerPlugin extends Plugin {
|
|
|
254
254
|
*/
|
|
255
255
|
init(config: JSONObject, context: PluginContext): Promise<void>;
|
|
256
256
|
/**
|
|
257
|
-
* Initialize the
|
|
257
|
+
* Initialize the platform index of the plugin
|
|
258
258
|
*/
|
|
259
259
|
private initDatabase;
|
|
260
260
|
/**
|
|
@@ -16,13 +16,13 @@ export type DeviceManagerConfiguration = {
|
|
|
16
16
|
autoUpdate: true;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Platform index name
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
platformIndex: string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Collection mappings for the platform index
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
platformCollections: {
|
|
26
26
|
config: {
|
|
27
27
|
name: string;
|
|
28
28
|
mappings: JSONObject;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { KuzzleRequest } from "kuzzle";
|
|
2
|
+
import { JSONObject, KDocument } from "kuzzle-sdk";
|
|
1
3
|
import { MeasureContent } from "../../measure";
|
|
2
4
|
import { DeviceManagerPlugin, InternalCollection } from "../../plugin";
|
|
3
5
|
import { ApiDigitalTwinMGetLastMeasuredAtResult } from "../types/DigitalTwinApi";
|
|
4
6
|
import { BaseService } from "./BaseService";
|
|
7
|
+
import { AssetContent } from "lib/modules/asset";
|
|
8
|
+
import { DeviceContent, DeviceProvisioningContent } from "lib/modules/device";
|
|
9
|
+
import { AssetModelContent, DeviceModelContent } from "lib/modules/model";
|
|
10
|
+
type MeasureSlot = {
|
|
11
|
+
asset: string;
|
|
12
|
+
device: string;
|
|
13
|
+
};
|
|
5
14
|
export declare class DigitalTwinService extends BaseService {
|
|
6
15
|
private targetCollection;
|
|
7
16
|
private readonly digitalTwinType;
|
|
@@ -11,6 +20,27 @@ export declare class DigitalTwinService extends BaseService {
|
|
|
11
20
|
* Gets the last measures of a digital twin
|
|
12
21
|
*/
|
|
13
22
|
getLastMeasures(engineId: string, digitalTwinId: string, measureCount?: number): Promise<MeasureContent[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Link a device to an asset.
|
|
25
|
+
*/
|
|
26
|
+
linkAssetDevice(engineId: string, deviceId: string, assetId: string, measureSlots: {
|
|
27
|
+
asset: string;
|
|
28
|
+
device: string;
|
|
29
|
+
}[], implicitMeasuresLinking: boolean, request: KuzzleRequest): Promise<{
|
|
30
|
+
asset: KDocument<AssetContent>;
|
|
31
|
+
device: KDocument<DeviceContent>;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Unlink a device of an asset with lock
|
|
35
|
+
*
|
|
36
|
+
* @param {string} deviceId Id of the device
|
|
37
|
+
* @param {string} assetId Id of the asset
|
|
38
|
+
* @param {KuzzleRequest} request kuzzle request
|
|
39
|
+
*/
|
|
40
|
+
unlinkAssetDevice(deviceId: string, assetId: string, measureSlots: MeasureSlot[], allMeasures: undefined | boolean, request: KuzzleRequest): Promise<{
|
|
41
|
+
asset: KDocument<AssetContent>;
|
|
42
|
+
device: KDocument<DeviceContent>;
|
|
43
|
+
}>;
|
|
14
44
|
/**
|
|
15
45
|
* Gets the last measures of multiple digital twins
|
|
16
46
|
*/
|
|
@@ -18,4 +48,43 @@ export declare class DigitalTwinService extends BaseService {
|
|
|
18
48
|
getLastMeasuredAt(engineId: string, digitalTwinId: string): Promise<number>;
|
|
19
49
|
mGetLastMeasuredAt(engineId: string, digitalTwinIds: string[]): Promise<ApiDigitalTwinMGetLastMeasuredAtResult>;
|
|
20
50
|
private getAggregationQueryParameters;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if the asset does not already have a linked device using one of the
|
|
53
|
+
* requested measure slots.
|
|
54
|
+
*/
|
|
55
|
+
protected checkAssetAlreadyProvidedMeasures(asset: KDocument<AssetContent>, deviceId: string, requestedMeasureNames: MeasureSlot[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if the device does not already have a linked asset using one of the
|
|
58
|
+
* requested measure slots.
|
|
59
|
+
*/
|
|
60
|
+
protected checkDeviceAlreadyProvidingMeasures(device: KDocument<DeviceContent>, assetId: string, requestedMeasureNames: MeasureSlot[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* Goes through the device available measures and add them into the link if:
|
|
63
|
+
* - they are not already provided by another device
|
|
64
|
+
* - they are not already present in the link request
|
|
65
|
+
* - they are declared in the asset model
|
|
66
|
+
*/
|
|
67
|
+
protected generateMissingAssetMeasureNames(asset: KDocument<AssetContent>, device: KDocument<DeviceContent>, assetModel: AssetModelContent, deviceModel: DeviceModelContent, requestedMeasureNames: MeasureSlot[]): void;
|
|
68
|
+
/**
|
|
69
|
+
* Internal logic of unlink a device of an asset
|
|
70
|
+
*
|
|
71
|
+
* @param {string} deviceId Id of the device
|
|
72
|
+
* @param {KuzzleRequest} request kuzzle request
|
|
73
|
+
*/
|
|
74
|
+
protected _unlinkAssetDevice(deviceId: string, assetId: string, measureSlots: MeasureSlot[], allMeasures: undefined | boolean, request: KuzzleRequest): Promise<{
|
|
75
|
+
asset: KDocument<AssetContent>;
|
|
76
|
+
device: KDocument<DeviceContent>;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieve the model document of an asset
|
|
80
|
+
* @param {any} engineGroup:string
|
|
81
|
+
* @param {any} model:string
|
|
82
|
+
* @returns {any}
|
|
83
|
+
*/
|
|
84
|
+
protected getAssetModel(engineGroup: string, model: string): Promise<AssetModelContent>;
|
|
85
|
+
protected getDeviceModel(model: string): Promise<DeviceModelContent>;
|
|
86
|
+
protected getEngine(engineId: string): Promise<JSONObject>;
|
|
87
|
+
protected getDeviceProvisioning(deviceId: string): Promise<KDocument<DeviceProvisioningContent>>;
|
|
88
|
+
protected checkDeviceAttachedToEngine(device: KDocument<DeviceProvisioningContent>): void;
|
|
21
89
|
}
|
|
90
|
+
export {};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KDocumentContent } from "kuzzle-sdk";
|
|
2
2
|
import { NamedMeasures } from "../../decoder";
|
|
3
3
|
import { Metadata } from "./Metadata";
|
|
4
|
-
import { DigitalTwinMeasures } from "./DigitalTwinMeasures";
|
|
5
4
|
import { LocaleDetails } from "lib/modules/model";
|
|
6
|
-
export interface DigitalTwinContent<
|
|
5
|
+
export interface DigitalTwinContent<TMetadata extends Metadata = Metadata> extends KDocumentContent {
|
|
7
6
|
model: string;
|
|
8
7
|
modelLocales?: {
|
|
9
8
|
[locale: string]: LocaleDetails;
|
|
10
9
|
};
|
|
11
10
|
reference: string;
|
|
12
11
|
metadata: TMetadata;
|
|
13
|
-
measures: DigitalTwinMeasures<TMeasures>;
|
|
14
|
-
lastMeasuredAt: number;
|
|
15
12
|
measureSlots: NamedMeasures;
|
|
16
13
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { User } from "kuzzle";
|
|
1
2
|
import { MeasureContent } from "../../measure";
|
|
2
3
|
export type AskDigitalTwinLastMeasuresGet = {
|
|
3
4
|
name: "ask:device-manager:asset:get-last-measures" | "ask:device-manager:device:get-last-measures";
|
|
@@ -7,3 +8,32 @@ export type AskDigitalTwinLastMeasuresGet = {
|
|
|
7
8
|
};
|
|
8
9
|
result: MeasureContent[];
|
|
9
10
|
};
|
|
11
|
+
export type AskDigitalTwinLink = {
|
|
12
|
+
name: "ask:device-manager:device:link-asset" | "ask:device-manager:asset:link-device";
|
|
13
|
+
payload: {
|
|
14
|
+
engineId: string;
|
|
15
|
+
assetId: string;
|
|
16
|
+
deviceId: string;
|
|
17
|
+
user: User;
|
|
18
|
+
measureSlots: {
|
|
19
|
+
asset: string;
|
|
20
|
+
device: string;
|
|
21
|
+
}[];
|
|
22
|
+
implicitMeasuresLinking: undefined | boolean;
|
|
23
|
+
};
|
|
24
|
+
result: void;
|
|
25
|
+
};
|
|
26
|
+
export type AskDigitalTwinUnlink = {
|
|
27
|
+
name: `ask:device-manager:asset:unlink-device` | `ask:device-manager:device:unlink-asset`;
|
|
28
|
+
payload: {
|
|
29
|
+
deviceId: string;
|
|
30
|
+
assetId: string;
|
|
31
|
+
measureSlots: {
|
|
32
|
+
asset: string;
|
|
33
|
+
device: string;
|
|
34
|
+
}[];
|
|
35
|
+
allMeasures: undefined | boolean;
|
|
36
|
+
user: User;
|
|
37
|
+
};
|
|
38
|
+
result: void;
|
|
39
|
+
};
|
|
@@ -18,7 +18,7 @@ export type ContainerMeasurements = {
|
|
|
18
18
|
position: PositionMeasurement;
|
|
19
19
|
temperatureWeather: TemperatureMeasurement;
|
|
20
20
|
};
|
|
21
|
-
export interface ContainerAssetContent extends AssetContent<
|
|
21
|
+
export interface ContainerAssetContent extends AssetContent<ContainerMetadata> {
|
|
22
22
|
model: typeof modelName;
|
|
23
23
|
}
|
|
24
24
|
export declare const Container: AssetModel;
|