kuzzle-device-manager-types 1.0.0 → 2.0.0-rc29
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/features/fixtures/application/app.d.ts +1 -0
- package/dist/features/fixtures/application/assets/Container.d.ts +1 -0
- package/dist/features/fixtures/application/decoders/DummyTempDecoder.d.ts +11 -0
- package/dist/features/fixtures/application/decoders/DummyTempPositionDecoder.d.ts +16 -0
- package/dist/features/fixtures/application/decoders/index.d.ts +2 -0
- package/dist/features/fixtures/application/testPipes.d.ts +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/lib/core/DeviceManagerConfiguration.d.ts +49 -0
- package/dist/lib/core/DeviceManagerEngine.d.ts +31 -0
- package/dist/lib/core/DeviceManagerPlugin.d.ts +114 -0
- package/dist/lib/core/InternalCollection.d.ts +7 -0
- package/dist/lib/core/index.d.ts +4 -0
- package/dist/lib/core/registers/DecodersRegister.d.ts +41 -0
- package/dist/lib/core/registers/ModelsRegister.d.ts +17 -0
- package/dist/lib/modules/asset/AssetModule.d.ts +6 -0
- package/dist/lib/modules/asset/AssetService.d.ts +44 -0
- package/dist/lib/modules/asset/AssetsController.d.ts +14 -0
- package/dist/lib/modules/asset/collections/assetsMappings.d.ts +38 -0
- package/dist/lib/modules/asset/index.d.ts +6 -0
- package/dist/lib/modules/asset/model/AssetSerializer.d.ts +10 -0
- package/dist/lib/modules/asset/roles/assetsAdmin.d.ts +16 -0
- package/dist/lib/modules/asset/roles/assetsReader.d.ts +16 -0
- package/dist/lib/modules/asset/types/AssetApi.d.ts +58 -0
- package/dist/lib/modules/asset/types/AssetContent.d.ts +41 -0
- package/dist/lib/modules/asset/types/AssetEvents.d.ts +17 -0
- package/dist/lib/modules/decoder/DecodedPayload.d.ts +46 -0
- package/dist/lib/modules/decoder/Decoder.d.ts +101 -0
- package/dist/lib/modules/decoder/DecoderModule.d.ts +8 -0
- package/dist/lib/modules/decoder/DecodersController.d.ts +18 -0
- package/dist/lib/modules/decoder/PayloadService.d.ts +34 -0
- package/dist/lib/modules/decoder/PayloadsController.d.ts +11 -0
- package/dist/lib/modules/decoder/collections/payloadsMappings.d.ts +18 -0
- package/dist/lib/modules/decoder/index.d.ts +6 -0
- package/dist/lib/modules/decoder/roles/decodersAdmin.d.ts +9 -0
- package/dist/lib/modules/decoder/types/DecoderApi.d.ts +19 -0
- package/dist/lib/modules/decoder/types/DecoderContent.d.ts +5 -0
- package/dist/lib/modules/decoder/types/PayloadApi.d.ts +11 -0
- package/dist/lib/modules/device/DeviceModule.d.ts +6 -0
- package/dist/lib/modules/device/DeviceService.d.ts +78 -0
- package/dist/lib/modules/device/DevicesController.d.ts +32 -0
- package/dist/lib/modules/device/collections/deviceMappings.d.ts +43 -0
- package/dist/lib/modules/device/index.d.ts +6 -0
- package/dist/lib/modules/device/model/DeviceSerializer.d.ts +6 -0
- package/dist/lib/modules/device/roles/devicesAdmin.d.ts +22 -0
- package/dist/lib/modules/device/roles/devicesPlatformAdmin.d.ts +16 -0
- package/dist/lib/modules/device/roles/devicesReader.d.ts +15 -0
- package/dist/lib/modules/device/types/DeviceApi.d.ts +94 -0
- package/dist/lib/modules/device/types/DeviceContent.d.ts +14 -0
- package/dist/lib/modules/device/types/DeviceEvents.d.ts +17 -0
- package/dist/lib/modules/measure/MeasureModule.d.ts +6 -0
- package/dist/lib/modules/measure/MeasureService.d.ts +53 -0
- package/dist/lib/modules/measure/MeasuresController.d.ts +9 -0
- package/dist/lib/modules/measure/collections/measuresMappings.d.ts +84 -0
- package/dist/lib/modules/measure/index.d.ts +7 -0
- package/dist/lib/modules/measure/measures/BatteryMeasure.d.ts +5 -0
- package/dist/lib/modules/measure/measures/HumidityMeasure.d.ts +5 -0
- package/dist/lib/modules/measure/measures/MovementMeasure.d.ts +5 -0
- package/dist/lib/modules/measure/measures/PositionMeasure.d.ts +10 -0
- package/dist/lib/modules/measure/measures/TemperatureMeasure.d.ts +5 -0
- package/dist/lib/modules/measure/measures/index.d.ts +5 -0
- package/dist/lib/modules/measure/roles/measuresAdmin.d.ts +16 -0
- package/dist/lib/modules/measure/roles/measuresReader.d.ts +9 -0
- package/dist/lib/modules/measure/types/MeasureApi.d.ts +23 -0
- package/dist/lib/modules/measure/types/MeasureContent.d.ts +67 -0
- package/dist/lib/modules/measure/types/MeasureDefinition.d.ts +15 -0
- package/dist/lib/modules/measure/types/MeasureEvents.d.ts +59 -0
- package/dist/lib/modules/model/ModelModule.d.ts +6 -0
- package/dist/lib/modules/model/ModelSerializer.d.ts +5 -0
- package/dist/lib/modules/model/ModelService.d.ts +24 -0
- package/dist/lib/modules/model/ModelsController.d.ts +17 -0
- package/dist/lib/modules/model/collections/modelsMappings.d.ts +2 -0
- package/dist/lib/modules/model/index.d.ts +6 -0
- package/dist/lib/modules/model/types/ModelApi.d.ts +75 -0
- package/dist/lib/modules/model/types/ModelContent.d.ts +96 -0
- package/dist/lib/modules/model/types/ModelDefinition.d.ts +12 -0
- package/dist/lib/modules/model/types/ModelEvents.d.ts +16 -0
- package/dist/lib/modules/shared/Module.d.ts +7 -0
- package/dist/lib/modules/shared/index.d.ts +6 -0
- package/dist/lib/modules/shared/types/DigitalTwinContent.d.ts +11 -0
- package/dist/lib/modules/shared/types/EmbeddedMeasure.d.ts +24 -0
- package/dist/lib/modules/shared/types/Metadata.d.ts +5 -0
- package/dist/lib/modules/shared/utils/ask.d.ts +8 -0
- package/dist/lib/modules/shared/utils/flattenObject.d.ts +24 -0
- package/dist/lib/modules/shared/utils/lock.d.ts +1 -0
- package/package.json +6 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JSONObject } from "kuzzle";
|
|
2
|
+
import { Decoder, DecodedPayload } from "../../../../index";
|
|
3
|
+
export declare class DummyTempDecoder extends Decoder {
|
|
4
|
+
measures: readonly [{
|
|
5
|
+
readonly name: "temperature";
|
|
6
|
+
readonly type: "temperature";
|
|
7
|
+
}];
|
|
8
|
+
constructor();
|
|
9
|
+
validate(payload: JSONObject): Promise<boolean>;
|
|
10
|
+
decode(payload: JSONObject): Promise<DecodedPayload<Decoder>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JSONObject } from "kuzzle";
|
|
2
|
+
import { Decoder, DecodedPayload } from "../../../../index";
|
|
3
|
+
export declare class DummyTempPositionDecoder extends Decoder {
|
|
4
|
+
measures: readonly [{
|
|
5
|
+
readonly name: "temperature";
|
|
6
|
+
readonly type: "temperature";
|
|
7
|
+
}, {
|
|
8
|
+
readonly name: "battery";
|
|
9
|
+
readonly type: "battery";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "position";
|
|
12
|
+
readonly type: "position";
|
|
13
|
+
}];
|
|
14
|
+
validate(payload: JSONObject): Promise<boolean>;
|
|
15
|
+
decode(payload: JSONObject): Promise<DecodedPayload<Decoder>>;
|
|
16
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './lib/core/DeviceManagerPlugin';
|
|
2
|
+
export * from './lib/core/DeviceManagerConfiguration';
|
|
3
|
+
export * from './lib/modules/asset';
|
|
4
|
+
export * from './lib/modules/device';
|
|
5
|
+
export * from './lib/modules/measure';
|
|
6
|
+
export * from './lib/modules/decoder';
|
|
7
|
+
export * from './lib/modules/shared';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { JSONObject } from "kuzzle";
|
|
2
|
+
export declare type DeviceManagerConfiguration = {
|
|
3
|
+
/**
|
|
4
|
+
* Ignore errors at startup such as wrong mappings update.
|
|
5
|
+
*
|
|
6
|
+
* Useful to start the plugin even if the mappings are not up to date.
|
|
7
|
+
*/
|
|
8
|
+
ignoreStartupErrors: boolean;
|
|
9
|
+
engine: {
|
|
10
|
+
/**
|
|
11
|
+
* Auto update collection mappings with models
|
|
12
|
+
*
|
|
13
|
+
* This can lead to huge pressure on the database at start if a lot
|
|
14
|
+
* of engine are present.
|
|
15
|
+
*/
|
|
16
|
+
autoUpdate: true;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Administration index name
|
|
20
|
+
*/
|
|
21
|
+
adminIndex: string;
|
|
22
|
+
/**
|
|
23
|
+
* Administration collections mappings (in admin index)
|
|
24
|
+
*/
|
|
25
|
+
adminCollections: {
|
|
26
|
+
config: {
|
|
27
|
+
name: string;
|
|
28
|
+
mappings: JSONObject;
|
|
29
|
+
settings: JSONObject;
|
|
30
|
+
};
|
|
31
|
+
devices: {
|
|
32
|
+
name: string;
|
|
33
|
+
mappings: JSONObject;
|
|
34
|
+
settings: JSONObject;
|
|
35
|
+
};
|
|
36
|
+
payloads: {
|
|
37
|
+
name: string;
|
|
38
|
+
mappings: JSONObject;
|
|
39
|
+
settings: JSONObject;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
engineCollections: {
|
|
43
|
+
config: {
|
|
44
|
+
name: string;
|
|
45
|
+
mappings: JSONObject;
|
|
46
|
+
settings: JSONObject;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Backend, Plugin } from "kuzzle";
|
|
2
|
+
import { AbstractEngine, ConfigManager } from "kuzzle-plugin-commons";
|
|
3
|
+
import { DeviceManagerConfiguration } from "./DeviceManagerConfiguration";
|
|
4
|
+
import { DeviceManagerPlugin } from "./DeviceManagerPlugin";
|
|
5
|
+
import { InternalCollection } from "./InternalCollection";
|
|
6
|
+
export declare type AskEngineUpdateAll = {
|
|
7
|
+
name: "ask:device-manager:engine:updateAll";
|
|
8
|
+
payload: void;
|
|
9
|
+
result: void;
|
|
10
|
+
};
|
|
11
|
+
export declare class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
|
|
12
|
+
config: DeviceManagerConfiguration;
|
|
13
|
+
get app(): Backend;
|
|
14
|
+
constructor(plugin: Plugin, adminConfigManager: ConfigManager, engineConfigManager: ConfigManager);
|
|
15
|
+
updateEngines(): Promise<void>;
|
|
16
|
+
onCreate(index: string, group?: string): Promise<{
|
|
17
|
+
collections: string[];
|
|
18
|
+
}>;
|
|
19
|
+
onUpdate(index: string, group?: string): Promise<{
|
|
20
|
+
collections: any[];
|
|
21
|
+
}>;
|
|
22
|
+
onDelete(index: string): Promise<{
|
|
23
|
+
collections: string[];
|
|
24
|
+
}>;
|
|
25
|
+
createAssetsCollection(engineId: string, engineGroup: string): Promise<InternalCollection>;
|
|
26
|
+
private getDigitalTwinMappings;
|
|
27
|
+
createDevicesCollection(engineId: string): Promise<InternalCollection>;
|
|
28
|
+
createMeasuresCollection(engineId: string, engineGroup: string): Promise<InternalCollection>;
|
|
29
|
+
private getMeasuresMappings;
|
|
30
|
+
private getModels;
|
|
31
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Plugin, PluginContext, JSONObject } from "kuzzle";
|
|
2
|
+
import { MeasureDefinition } from "../modules/measure";
|
|
3
|
+
import { AssetModelDefinition, DeviceModelDefinition } from "../modules/model";
|
|
4
|
+
import { DeviceManagerConfiguration } from "./DeviceManagerConfiguration";
|
|
5
|
+
export declare class DeviceManagerPlugin extends Plugin {
|
|
6
|
+
config: DeviceManagerConfiguration;
|
|
7
|
+
roles: {};
|
|
8
|
+
private deviceManagerEngine;
|
|
9
|
+
private adminConfigManager;
|
|
10
|
+
private engineConfigManager;
|
|
11
|
+
private engineController;
|
|
12
|
+
private assetModule;
|
|
13
|
+
private deviceModule;
|
|
14
|
+
private decoderModule;
|
|
15
|
+
private measureModule;
|
|
16
|
+
private modelModule;
|
|
17
|
+
private modelsRegister;
|
|
18
|
+
private decodersRegister;
|
|
19
|
+
private get sdk();
|
|
20
|
+
get models(): {
|
|
21
|
+
/**
|
|
22
|
+
* Register an asset model
|
|
23
|
+
*
|
|
24
|
+
* @param engineGroup Engine group name
|
|
25
|
+
* @param model Name of the asset model
|
|
26
|
+
* @param definition.measuresNames Array describing measures names and types
|
|
27
|
+
* @param definition.metadataMappings Metadata mappings definition
|
|
28
|
+
* @param definition.defaultMetadata Default metadata values
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```
|
|
32
|
+
* deviceManager.models.registerAsset(
|
|
33
|
+
* "logistic",
|
|
34
|
+
* "container",
|
|
35
|
+
* {
|
|
36
|
+
* measuresNames: [
|
|
37
|
+
* { name: "temperatureExt", type: "temperature" },
|
|
38
|
+
* { name: "temperatureInt", type: "temperature" },
|
|
39
|
+
* { name: "position", type: "position" },
|
|
40
|
+
* ],
|
|
41
|
+
* metadataMappings: {
|
|
42
|
+
* weight: { type: "integer" },
|
|
43
|
+
* height: { type: "integer" },
|
|
44
|
+
* },
|
|
45
|
+
* defaultMetadata: {
|
|
46
|
+
* height: 20
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* );
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
registerAsset: (engineGroup: string, model: string, definition: AssetModelDefinition) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Register a device model
|
|
55
|
+
*
|
|
56
|
+
* @param model Name of the device model
|
|
57
|
+
* @param definition.decoded Decoder used to decode payloads
|
|
58
|
+
* @param definition.metadataMappings Metadata mappings definition
|
|
59
|
+
* @param definition.defaultMetadata Default metadata values
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```
|
|
63
|
+
* deviceManager.models.registerDevice(
|
|
64
|
+
* "Abeeway",
|
|
65
|
+
* {
|
|
66
|
+
* decoder: new DummyTempPositionDecoder(),
|
|
67
|
+
* metadataMappings: {
|
|
68
|
+
* serial: { type: "keyword" },
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
* );
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
registerDevice: (model: string, definition: DeviceModelDefinition) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Register a new measure
|
|
77
|
+
*
|
|
78
|
+
* @param name Name of the measure
|
|
79
|
+
* @param valuesMappings Mappings for the measure values
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```
|
|
83
|
+
* deviceManager.models.registerMeasure("acceleration", {
|
|
84
|
+
* x: { type: "float" },
|
|
85
|
+
* y: { type: "float" },
|
|
86
|
+
* z: { type: "float" },
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
registerMeasure: (name: string, measureDefinition: MeasureDefinition) => void;
|
|
91
|
+
};
|
|
92
|
+
constructor();
|
|
93
|
+
/**
|
|
94
|
+
* Init the plugin
|
|
95
|
+
*/
|
|
96
|
+
init(config: JSONObject, context: PluginContext): Promise<void>;
|
|
97
|
+
private createDefaultRoles;
|
|
98
|
+
/**
|
|
99
|
+
* Initialize the administration index of the plugin
|
|
100
|
+
*/
|
|
101
|
+
private initDatabase;
|
|
102
|
+
/**
|
|
103
|
+
* Merge custom mappings defined in the Decoder into the "payloads" collection
|
|
104
|
+
* mappings.
|
|
105
|
+
*
|
|
106
|
+
* Those custom mappings allow to search raw payloads more efficiently.
|
|
107
|
+
*/
|
|
108
|
+
private getPayloadsMappings;
|
|
109
|
+
/**
|
|
110
|
+
* Initialize the config document if it does not exists
|
|
111
|
+
*/
|
|
112
|
+
private initializeConfig;
|
|
113
|
+
private pipeCheckEngine;
|
|
114
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PluginContext } from "kuzzle";
|
|
2
|
+
import { Decoder, DecoderContent } from "../../modules/decoder";
|
|
3
|
+
export declare class DecodersRegister {
|
|
4
|
+
private context;
|
|
5
|
+
/**
|
|
6
|
+
* Map<deviceModel, Decoder>
|
|
7
|
+
*/
|
|
8
|
+
private _decoders;
|
|
9
|
+
private get sdk();
|
|
10
|
+
get decoders(): Decoder[];
|
|
11
|
+
init(context: PluginContext): void;
|
|
12
|
+
get(deviceModel: string): Decoder;
|
|
13
|
+
list(): DecoderContent[];
|
|
14
|
+
/**
|
|
15
|
+
* Registers a new decoder for a device model.
|
|
16
|
+
* Decoder and device models share a 1:1 relationship
|
|
17
|
+
*
|
|
18
|
+
* This will register a new API action:
|
|
19
|
+
* - controller: `device-manager/payload`
|
|
20
|
+
* - action: `action` property of the decoder or the device model in kebab-case
|
|
21
|
+
*
|
|
22
|
+
* @param decoder Instantiated decoder
|
|
23
|
+
*
|
|
24
|
+
* @returns Corresponding API action requestPayload
|
|
25
|
+
*/
|
|
26
|
+
register(decoder: Decoder): {
|
|
27
|
+
action: string;
|
|
28
|
+
controller: string;
|
|
29
|
+
};
|
|
30
|
+
printDecoders(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Creates default roles, profiles and users associated to the generated actions
|
|
33
|
+
* in the Payload controller.
|
|
34
|
+
*
|
|
35
|
+
* This method never returns a rejected promise.
|
|
36
|
+
*/
|
|
37
|
+
createDefaultRights(): Promise<void>;
|
|
38
|
+
private createDefaultUsers;
|
|
39
|
+
private createDefaultProfiles;
|
|
40
|
+
private createDefaultRoles;
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JSONObject } from "kuzzle";
|
|
2
|
+
import { MeasureDefinition } from "lib/modules/measure";
|
|
3
|
+
import { DeviceManagerPlugin } from "../DeviceManagerPlugin";
|
|
4
|
+
export declare class ModelsRegister {
|
|
5
|
+
private config;
|
|
6
|
+
private context;
|
|
7
|
+
private assetModels;
|
|
8
|
+
private deviceModels;
|
|
9
|
+
private measureModels;
|
|
10
|
+
private get sdk();
|
|
11
|
+
init(plugin: DeviceManagerPlugin): void;
|
|
12
|
+
loadModels(): Promise<void>;
|
|
13
|
+
registerAsset(engineGroup: string, model: string, metadataMappings: JSONObject, measures: Record<string, string>, defaultMetadata?: JSONObject): void;
|
|
14
|
+
registerDevice(model: string, metadataMappings: JSONObject, measures: Record<string, string>, defaultMetadata?: JSONObject): void;
|
|
15
|
+
registerMeasure(type: string, measureDefinition: MeasureDefinition): void;
|
|
16
|
+
private load;
|
|
17
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle";
|
|
2
|
+
import { MeasureContent } from "../measure/";
|
|
3
|
+
import { Metadata } from "../shared";
|
|
4
|
+
import { DeviceManagerPlugin } from "../../core";
|
|
5
|
+
import { AssetContent } from "./types/AssetContent";
|
|
6
|
+
export declare class AssetService {
|
|
7
|
+
private context;
|
|
8
|
+
private config;
|
|
9
|
+
private get sdk();
|
|
10
|
+
private get app();
|
|
11
|
+
constructor(plugin: DeviceManagerPlugin);
|
|
12
|
+
/**
|
|
13
|
+
* Returns measures history for an asset
|
|
14
|
+
*
|
|
15
|
+
* @param engineId Engine ID
|
|
16
|
+
* @param assetId Asset ID
|
|
17
|
+
* @param options.size Number of measures to return
|
|
18
|
+
* @param options.startAt Returns measures starting from this date (ISO8601)
|
|
19
|
+
* @param options.endAt Returns measures until this date (ISO8601)
|
|
20
|
+
*/
|
|
21
|
+
getMeasureHistory(engineId: string, assetId: string, { size, startAt, endAt, }: {
|
|
22
|
+
size?: number;
|
|
23
|
+
startAt?: string;
|
|
24
|
+
endAt?: string;
|
|
25
|
+
}): Promise<KDocument<MeasureContent>[]>;
|
|
26
|
+
get(engineId: string, assetId: string): Promise<KDocument<AssetContent>>;
|
|
27
|
+
update(engineId: string, assetId: string, metadata: Metadata, { refresh }: {
|
|
28
|
+
refresh: any;
|
|
29
|
+
}): Promise<KDocument<AssetContent>>;
|
|
30
|
+
create(engineId: string, model: string, reference: string, metadata: JSONObject, { refresh }: {
|
|
31
|
+
refresh: any;
|
|
32
|
+
}): Promise<KDocument<AssetContent>>;
|
|
33
|
+
delete(engineId: string, assetId: string, { refresh, strict }: {
|
|
34
|
+
refresh: any;
|
|
35
|
+
strict: boolean;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
search(engineId: string, searchBody: JSONObject, { from, size, scroll, lang, }: {
|
|
38
|
+
from?: number;
|
|
39
|
+
size?: number;
|
|
40
|
+
scroll?: string;
|
|
41
|
+
lang?: string;
|
|
42
|
+
}): Promise<SearchResult<KHit<AssetContent>>>;
|
|
43
|
+
private getEngine;
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ControllerDefinition, KuzzleRequest } from "kuzzle";
|
|
2
|
+
import { AssetService } from "./AssetService";
|
|
3
|
+
import { ApiAssetCreateResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult } from "./types/AssetApi";
|
|
4
|
+
export declare class AssetsController {
|
|
5
|
+
definition: ControllerDefinition;
|
|
6
|
+
private assetService;
|
|
7
|
+
constructor(assetService: AssetService);
|
|
8
|
+
get(request: KuzzleRequest): Promise<ApiAssetGetResult>;
|
|
9
|
+
update(request: KuzzleRequest): Promise<ApiAssetUpdateResult>;
|
|
10
|
+
create(request: KuzzleRequest): Promise<ApiAssetCreateResult>;
|
|
11
|
+
delete(request: KuzzleRequest): Promise<ApiAssetDeleteResult>;
|
|
12
|
+
search(request: KuzzleRequest): Promise<ApiAssetSearchResult>;
|
|
13
|
+
getMeasures(request: KuzzleRequest): Promise<ApiAssetGetMeasuresResult>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const assetsMappings: {
|
|
2
|
+
dynamic: string;
|
|
3
|
+
properties: {
|
|
4
|
+
model: {
|
|
5
|
+
type: string;
|
|
6
|
+
fields: {
|
|
7
|
+
text: {
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
reference: {
|
|
13
|
+
type: string;
|
|
14
|
+
fields: {
|
|
15
|
+
text: {
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
metadata: {
|
|
21
|
+
properties: {};
|
|
22
|
+
};
|
|
23
|
+
measures: {
|
|
24
|
+
properties: {};
|
|
25
|
+
};
|
|
26
|
+
linkedDevices: {
|
|
27
|
+
properties: {
|
|
28
|
+
_id: {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
measures: {
|
|
32
|
+
dynamic: string;
|
|
33
|
+
properties: {};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KDocument } from "kuzzle";
|
|
2
|
+
import { AssetContent, AssetMeasureContext } from "../types/AssetContent";
|
|
3
|
+
export declare class AssetSerializer {
|
|
4
|
+
static id(model: string, reference: string): string;
|
|
5
|
+
static serialize(asset: KDocument<AssetContent>): KDocument<AssetContent>;
|
|
6
|
+
/**
|
|
7
|
+
* Get asset description to contextualize measure data point
|
|
8
|
+
*/
|
|
9
|
+
static measureContext(asset: KDocument<AssetContent>, measureName: string): AssetMeasureContext;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const assetsAdmin: {
|
|
2
|
+
controllers: {
|
|
3
|
+
"device-manager/assets": {
|
|
4
|
+
actions: {
|
|
5
|
+
"*": boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
"device-manager/models": {
|
|
9
|
+
actions: {
|
|
10
|
+
deleteAsset: boolean;
|
|
11
|
+
listAssets: boolean;
|
|
12
|
+
writeAsset: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const assetsReader: {
|
|
2
|
+
controllers: {
|
|
3
|
+
"device-manager/assets": {
|
|
4
|
+
actions: {
|
|
5
|
+
get: boolean;
|
|
6
|
+
getMeasures: boolean;
|
|
7
|
+
search: boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
"device-manager/models": {
|
|
11
|
+
actions: {
|
|
12
|
+
listAssets: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle";
|
|
2
|
+
import { MeasureContent } from "../../../modules/measure";
|
|
3
|
+
import { Metadata } from "../../shared";
|
|
4
|
+
import { AssetContent } from "./AssetContent";
|
|
5
|
+
interface AssetsControllerRequest {
|
|
6
|
+
controller: "device-manager/assets";
|
|
7
|
+
engineId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ApiAssetGetRequest extends AssetsControllerRequest {
|
|
10
|
+
action: "get";
|
|
11
|
+
_id: string;
|
|
12
|
+
}
|
|
13
|
+
export declare type ApiAssetGetResult = KDocument<AssetContent>;
|
|
14
|
+
export interface ApiAssetUpdateRequest extends AssetsControllerRequest {
|
|
15
|
+
action: "update";
|
|
16
|
+
_id: string;
|
|
17
|
+
refresh?: string;
|
|
18
|
+
body: {
|
|
19
|
+
metadata: Metadata;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare type ApiAssetUpdateResult = KDocument<AssetContent>;
|
|
23
|
+
export interface ApiAssetCreateRequest extends AssetsControllerRequest {
|
|
24
|
+
action: "create";
|
|
25
|
+
refresh?: string;
|
|
26
|
+
body: {
|
|
27
|
+
model: string;
|
|
28
|
+
reference: string;
|
|
29
|
+
metadata?: Metadata;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare type ApiAssetCreateResult = KDocument<AssetContent>;
|
|
33
|
+
export interface ApiAssetDeleteRequest extends AssetsControllerRequest {
|
|
34
|
+
action: "delete";
|
|
35
|
+
_id: string;
|
|
36
|
+
refresh?: string;
|
|
37
|
+
strict?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare type ApiAssetDeleteResult = void;
|
|
40
|
+
export interface ApiAssetSearchRequest extends AssetsControllerRequest {
|
|
41
|
+
action: "search";
|
|
42
|
+
from?: number;
|
|
43
|
+
size?: number;
|
|
44
|
+
scrollTTL?: string;
|
|
45
|
+
body: JSONObject;
|
|
46
|
+
}
|
|
47
|
+
export declare type ApiAssetSearchResult = SearchResult<KHit<AssetContent>>;
|
|
48
|
+
export interface ApiAssetGetMeasuresRequest extends AssetsControllerRequest {
|
|
49
|
+
action: "getMeasures";
|
|
50
|
+
_id: string;
|
|
51
|
+
size?: number;
|
|
52
|
+
startAt?: string;
|
|
53
|
+
endAt?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare type ApiAssetGetMeasuresResult = {
|
|
56
|
+
measures: Array<KDocument<MeasureContent<JSONObject>>>;
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { JSONObject } from "kuzzle";
|
|
2
|
+
import { DigitalTwinContent, Metadata } from "../../shared";
|
|
3
|
+
/**
|
|
4
|
+
* Asset document content
|
|
5
|
+
*/
|
|
6
|
+
export interface AssetContent<TMeasures extends JSONObject = any, TMetadata extends Metadata = any> extends DigitalTwinContent<TMeasures, TMetadata> {
|
|
7
|
+
/**
|
|
8
|
+
* Link with attached device
|
|
9
|
+
*/
|
|
10
|
+
linkedDevices: Array<{
|
|
11
|
+
/**
|
|
12
|
+
* Device ID
|
|
13
|
+
*/
|
|
14
|
+
_id: string;
|
|
15
|
+
/**
|
|
16
|
+
* Names lookup table for measures
|
|
17
|
+
*
|
|
18
|
+
* Record<deviceName, assetName>
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* {
|
|
23
|
+
* "temperature": "externalTemperature",
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
measures: Record<string, string>;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Asset description used to contextualize each measure data point
|
|
31
|
+
*/
|
|
32
|
+
export declare type AssetMeasureContext<TMetadata extends Metadata = Metadata> = {
|
|
33
|
+
/**
|
|
34
|
+
* ID of the asset
|
|
35
|
+
*/
|
|
36
|
+
_id: string;
|
|
37
|
+
/**
|
|
38
|
+
* Name of the measure for the Asset
|
|
39
|
+
*/
|
|
40
|
+
measureName: string;
|
|
41
|
+
} & Pick<AssetContent<JSONObject, TMetadata>, "model" | "reference" | "metadata">;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { KDocument } from "kuzzle";
|
|
2
|
+
import { Metadata } from "../../../modules/shared";
|
|
3
|
+
import { AssetContent } from "./AssetContent";
|
|
4
|
+
export declare type EventAssetUpdateBefore = {
|
|
5
|
+
name: "device-manager:asset:update:before";
|
|
6
|
+
args: [{
|
|
7
|
+
asset: KDocument<AssetContent>;
|
|
8
|
+
metadata: Metadata;
|
|
9
|
+
}];
|
|
10
|
+
};
|
|
11
|
+
export declare type EventAssetUpdateAfter = {
|
|
12
|
+
name: "device-manager:asset:update:after";
|
|
13
|
+
args: [{
|
|
14
|
+
asset: KDocument<AssetContent>;
|
|
15
|
+
metadata: Metadata;
|
|
16
|
+
}];
|
|
17
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { JSONObject } from "kuzzle";
|
|
2
|
+
import { DecodedMeasurement } from "../measure";
|
|
3
|
+
import { Decoder } from "./Decoder";
|
|
4
|
+
/**
|
|
5
|
+
* Class containing the decoded measures.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DecodedPayload<TDecoder extends Decoder = Decoder> {
|
|
8
|
+
decoder: TDecoder;
|
|
9
|
+
/**
|
|
10
|
+
* Measurements per device.
|
|
11
|
+
*
|
|
12
|
+
* Record<deviceReference, Measurement[]>
|
|
13
|
+
*/
|
|
14
|
+
private measurementsByDevice;
|
|
15
|
+
/**
|
|
16
|
+
* Metadata per device.
|
|
17
|
+
*/
|
|
18
|
+
private metadataByDevice;
|
|
19
|
+
constructor(decoder: TDecoder);
|
|
20
|
+
get references(): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Add a new measure into the decoded payload
|
|
23
|
+
*
|
|
24
|
+
* @param deviceReference Device reference
|
|
25
|
+
* @param measureName Name of the decoded measure
|
|
26
|
+
* @param measurement Measurement object
|
|
27
|
+
*/
|
|
28
|
+
addMeasurement<TMeasureValues extends JSONObject = JSONObject>(deviceReference: string, measureName: TDecoder["measures"][number]["name"], measurement: Omit<DecodedMeasurement<TMeasureValues>, "measureName">): void;
|
|
29
|
+
/**
|
|
30
|
+
* Add metadata values for a Device.
|
|
31
|
+
*
|
|
32
|
+
* Metadata should have been declared on the plugin to be used.
|
|
33
|
+
*
|
|
34
|
+
* @param deviceReference Device reference
|
|
35
|
+
* @param metadata Object containing metadata values
|
|
36
|
+
*/
|
|
37
|
+
addMetadata(deviceReference: string, metadata: JSONObject): void;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the measurements decoded for a device
|
|
40
|
+
*/
|
|
41
|
+
getMeasurements(deviceReference: string): DecodedMeasurement[];
|
|
42
|
+
/**
|
|
43
|
+
* Get the metadata for a device
|
|
44
|
+
*/
|
|
45
|
+
getMetadata(deviceReference: string): JSONObject;
|
|
46
|
+
}
|