kuzzle-device-manager-types 2.0.0-rc29 → 2.0.0-rc35
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/README.md +17 -0
- package/dist/features/fixtures/application/decoders/DummyTempDecoder.d.ts +1 -1
- package/dist/features/fixtures/application/decoders/DummyTempPositionDecoder.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/lib/core/DeviceManagerConfiguration.d.ts +1 -1
- package/dist/lib/core/DeviceManagerEngine.d.ts +1 -1
- package/dist/lib/core/DeviceManagerPlugin.d.ts +2 -1
- package/dist/lib/core/registers/ModelsRegister.d.ts +1 -1
- package/dist/lib/modules/asset/index.d.ts +2 -0
- package/dist/lib/modules/asset/roles/RoleAssetsAdmin.d.ts +22 -0
- package/dist/lib/modules/asset/roles/RoleAssetsReader.d.ts +21 -0
- package/dist/lib/modules/asset/types/AssetApi.d.ts +6 -6
- package/dist/lib/modules/asset/types/AssetContent.d.ts +1 -1
- package/dist/lib/modules/asset/types/AssetEvents.d.ts +2 -2
- package/dist/lib/modules/decoder/DecodedPayload.d.ts +1 -0
- package/dist/lib/modules/decoder/Decoder.d.ts +3 -2
- package/dist/lib/modules/decoder/index.d.ts +2 -0
- package/dist/lib/modules/decoder/roles/RoleDecodersAdmin.d.ts +14 -0
- package/dist/lib/modules/decoder/roles/RolePayloadsAll.d.ts +12 -0
- package/dist/lib/modules/decoder/types/DecoderApi.d.ts +2 -2
- package/dist/lib/modules/decoder/types/PayloadApi.d.ts +1 -1
- package/dist/lib/modules/device/index.d.ts +3 -0
- package/dist/lib/modules/device/roles/RoleDevicesAdmin.d.ts +27 -0
- package/dist/lib/modules/device/roles/RoleDevicesPlatformAdmin.d.ts +21 -0
- package/dist/lib/modules/device/roles/RoleDevicesReader.d.ts +21 -0
- package/dist/lib/modules/device/types/DeviceApi.d.ts +9 -9
- package/dist/lib/modules/device/types/DeviceEvents.d.ts +2 -2
- package/dist/lib/modules/measure/index.d.ts +2 -0
- package/dist/lib/modules/measure/measures/BatteryMeasure.d.ts +2 -2
- package/dist/lib/modules/measure/measures/HumidityMeasure.d.ts +2 -2
- package/dist/lib/modules/measure/measures/MovementMeasure.d.ts +2 -2
- package/dist/lib/modules/measure/measures/PositionMeasure.d.ts +2 -2
- package/dist/lib/modules/measure/measures/TemperatureMeasure.d.ts +2 -2
- package/dist/lib/modules/measure/roles/RoleMeasuresAdmin.d.ts +21 -0
- package/dist/lib/modules/measure/roles/RoleMeasuresReader.d.ts +14 -0
- package/dist/lib/modules/measure/types/MeasureApi.d.ts +1 -1
- package/dist/lib/modules/measure/types/MeasureContent.d.ts +2 -2
- package/dist/lib/modules/measure/types/MeasureEvents.d.ts +5 -5
- package/dist/lib/modules/model/types/ModelApi.d.ts +9 -9
- package/dist/lib/modules/model/types/ModelContent.d.ts +1 -1
- package/dist/lib/modules/model/types/ModelDefinition.d.ts +53 -3
- package/dist/lib/modules/model/types/ModelEvents.d.ts +2 -2
- package/dist/lib/modules/shared/types/EmbeddedMeasure.d.ts +1 -1
- package/dist/lib/modules/shared/types/KuzzleRole.d.ts +5 -0
- package/dist/lib/modules/shared/types/Metadata.d.ts +2 -2
- package/dist/lib/modules/shared/utils/ask.d.ts +2 -2
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Kuzzle Device Manager Types
|
|
2
|
+
|
|
3
|
+
This package only contains types to work with in a frontend application.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
import { DeviceContent } from 'kuzzle-device-manager-types';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
let device: DeviceContent;
|
|
11
|
+
|
|
12
|
+
device.model = "Abeeway";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
See main package for more informations:
|
|
16
|
+
- [Github](https://github.com/kuzzleio/kuzzle-device-manager)
|
|
17
|
+
- [NPM](https://www.npmjs.com/package/kuzzle-device-manager)
|
|
@@ -7,5 +7,5 @@ export declare class DummyTempDecoder extends Decoder {
|
|
|
7
7
|
}];
|
|
8
8
|
constructor();
|
|
9
9
|
validate(payload: JSONObject): Promise<boolean>;
|
|
10
|
-
decode(payload: JSONObject): Promise<DecodedPayload<
|
|
10
|
+
decode(decodedPayload: DecodedPayload<DummyTempDecoder>, payload: JSONObject): Promise<DecodedPayload<DummyTempDecoder>>;
|
|
11
11
|
}
|
|
@@ -12,5 +12,5 @@ export declare class DummyTempPositionDecoder extends Decoder {
|
|
|
12
12
|
readonly type: "position";
|
|
13
13
|
}];
|
|
14
14
|
validate(payload: JSONObject): Promise<boolean>;
|
|
15
|
-
decode(payload: JSONObject): Promise<DecodedPayload<
|
|
15
|
+
decode(decodedPayload: DecodedPayload<DummyTempPositionDecoder>, payload: JSONObject): Promise<DecodedPayload<DummyTempPositionDecoder>>;
|
|
16
16
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AbstractEngine, ConfigManager } from "kuzzle-plugin-commons";
|
|
|
3
3
|
import { DeviceManagerConfiguration } from "./DeviceManagerConfiguration";
|
|
4
4
|
import { DeviceManagerPlugin } from "./DeviceManagerPlugin";
|
|
5
5
|
import { InternalCollection } from "./InternalCollection";
|
|
6
|
-
export
|
|
6
|
+
export type AskEngineUpdateAll = {
|
|
7
7
|
name: "ask:device-manager:engine:updateAll";
|
|
8
8
|
payload: void;
|
|
9
9
|
result: void;
|
|
@@ -2,9 +2,10 @@ import { Plugin, PluginContext, JSONObject } from "kuzzle";
|
|
|
2
2
|
import { MeasureDefinition } from "../modules/measure";
|
|
3
3
|
import { AssetModelDefinition, DeviceModelDefinition } from "../modules/model";
|
|
4
4
|
import { DeviceManagerConfiguration } from "./DeviceManagerConfiguration";
|
|
5
|
+
import { KuzzleRole } from "lib/modules/shared/types/KuzzleRole";
|
|
5
6
|
export declare class DeviceManagerPlugin extends Plugin {
|
|
6
7
|
config: DeviceManagerConfiguration;
|
|
7
|
-
roles:
|
|
8
|
+
roles: KuzzleRole[];
|
|
8
9
|
private deviceManagerEngine;
|
|
9
10
|
private adminConfigManager;
|
|
10
11
|
private engineConfigManager;
|
|
@@ -11,7 +11,7 @@ export declare class ModelsRegister {
|
|
|
11
11
|
init(plugin: DeviceManagerPlugin): void;
|
|
12
12
|
loadModels(): Promise<void>;
|
|
13
13
|
registerAsset(engineGroup: string, model: string, metadataMappings: JSONObject, measures: Record<string, string>, defaultMetadata?: JSONObject): void;
|
|
14
|
-
registerDevice(model: string,
|
|
14
|
+
registerDevice(model: string, measures: Record<string, string>, metadataMappings?: JSONObject, defaultMetadata?: JSONObject): void;
|
|
15
15
|
registerMeasure(type: string, measureDefinition: MeasureDefinition): void;
|
|
16
16
|
private load;
|
|
17
17
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role allows to manage assets and their models.
|
|
4
|
+
*
|
|
5
|
+
* It's a tenant role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
"device-manager/assets": {
|
|
10
|
+
actions: {
|
|
11
|
+
"*": true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
"device-manager/models": {
|
|
15
|
+
actions: {
|
|
16
|
+
deleteAsset: true,
|
|
17
|
+
listAssets: true,
|
|
18
|
+
writeAsset: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
*/
|
|
22
|
+
export declare const RoleAssetsAdmin: KuzzleRole;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KuzzleRole } from "lib/modules/shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role only gives a read-only access to assets and their models.
|
|
4
|
+
*
|
|
5
|
+
* It's a tenant role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
"device-manager/assets": {
|
|
9
|
+
actions: {
|
|
10
|
+
get: true,
|
|
11
|
+
getMeasures: true,
|
|
12
|
+
search: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
"device-manager/models": {
|
|
16
|
+
actions: {
|
|
17
|
+
listAssets: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
*/
|
|
21
|
+
export declare const RoleAssetsReader: KuzzleRole;
|
|
@@ -10,7 +10,7 @@ export interface ApiAssetGetRequest extends AssetsControllerRequest {
|
|
|
10
10
|
action: "get";
|
|
11
11
|
_id: string;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type ApiAssetGetResult = KDocument<AssetContent>;
|
|
14
14
|
export interface ApiAssetUpdateRequest extends AssetsControllerRequest {
|
|
15
15
|
action: "update";
|
|
16
16
|
_id: string;
|
|
@@ -19,7 +19,7 @@ export interface ApiAssetUpdateRequest extends AssetsControllerRequest {
|
|
|
19
19
|
metadata: Metadata;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type ApiAssetUpdateResult = KDocument<AssetContent>;
|
|
23
23
|
export interface ApiAssetCreateRequest extends AssetsControllerRequest {
|
|
24
24
|
action: "create";
|
|
25
25
|
refresh?: string;
|
|
@@ -29,14 +29,14 @@ export interface ApiAssetCreateRequest extends AssetsControllerRequest {
|
|
|
29
29
|
metadata?: Metadata;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export type ApiAssetCreateResult = KDocument<AssetContent>;
|
|
33
33
|
export interface ApiAssetDeleteRequest extends AssetsControllerRequest {
|
|
34
34
|
action: "delete";
|
|
35
35
|
_id: string;
|
|
36
36
|
refresh?: string;
|
|
37
37
|
strict?: boolean;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export type ApiAssetDeleteResult = void;
|
|
40
40
|
export interface ApiAssetSearchRequest extends AssetsControllerRequest {
|
|
41
41
|
action: "search";
|
|
42
42
|
from?: number;
|
|
@@ -44,7 +44,7 @@ export interface ApiAssetSearchRequest extends AssetsControllerRequest {
|
|
|
44
44
|
scrollTTL?: string;
|
|
45
45
|
body: JSONObject;
|
|
46
46
|
}
|
|
47
|
-
export
|
|
47
|
+
export type ApiAssetSearchResult = SearchResult<KHit<AssetContent>>;
|
|
48
48
|
export interface ApiAssetGetMeasuresRequest extends AssetsControllerRequest {
|
|
49
49
|
action: "getMeasures";
|
|
50
50
|
_id: string;
|
|
@@ -52,7 +52,7 @@ export interface ApiAssetGetMeasuresRequest extends AssetsControllerRequest {
|
|
|
52
52
|
startAt?: string;
|
|
53
53
|
endAt?: string;
|
|
54
54
|
}
|
|
55
|
-
export
|
|
55
|
+
export type ApiAssetGetMeasuresResult = {
|
|
56
56
|
measures: Array<KDocument<MeasureContent<JSONObject>>>;
|
|
57
57
|
};
|
|
58
58
|
export {};
|
|
@@ -29,7 +29,7 @@ export interface AssetContent<TMeasures extends JSONObject = any, TMetadata exte
|
|
|
29
29
|
/**
|
|
30
30
|
* Asset description used to contextualize each measure data point
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export type AssetMeasureContext<TMetadata extends Metadata = Metadata> = {
|
|
33
33
|
/**
|
|
34
34
|
* ID of the asset
|
|
35
35
|
*/
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { KDocument } from "kuzzle";
|
|
2
2
|
import { Metadata } from "../../../modules/shared";
|
|
3
3
|
import { AssetContent } from "./AssetContent";
|
|
4
|
-
export
|
|
4
|
+
export type EventAssetUpdateBefore = {
|
|
5
5
|
name: "device-manager:asset:update:before";
|
|
6
6
|
args: [{
|
|
7
7
|
asset: KDocument<AssetContent>;
|
|
8
8
|
metadata: Metadata;
|
|
9
9
|
}];
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type EventAssetUpdateAfter = {
|
|
12
12
|
name: "device-manager:asset:update:after";
|
|
13
13
|
args: [{
|
|
14
14
|
asset: KDocument<AssetContent>;
|
|
@@ -4,7 +4,7 @@ import { DecoderContent } from "./types/DecoderContent";
|
|
|
4
4
|
/**
|
|
5
5
|
* Array of measures declaration
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type NamedMeasures = ReadonlyArray<{
|
|
8
8
|
name: string;
|
|
9
9
|
type: string;
|
|
10
10
|
}>;
|
|
@@ -82,12 +82,13 @@ export declare abstract class Decoder {
|
|
|
82
82
|
* - set "reference"
|
|
83
83
|
* - fetch measures
|
|
84
84
|
*
|
|
85
|
+
* @param decodedPayload Decoded payload to store decoded measures
|
|
85
86
|
* @param payload Raw payload received in the API action body
|
|
86
87
|
* @param request Original request
|
|
87
88
|
*
|
|
88
89
|
* @returns DecodedPayload
|
|
89
90
|
*/
|
|
90
|
-
abstract decode(payload: JSONObject, request: KuzzleRequest): Promise<DecodedPayload<
|
|
91
|
+
abstract decode(decodedPayload: DecodedPayload<any>, payload: JSONObject, request: KuzzleRequest): Promise<DecodedPayload<any>>;
|
|
91
92
|
/**
|
|
92
93
|
* Checks if the provided properties are present in the payload
|
|
93
94
|
*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* Role used to manage decoders and their payloads.
|
|
4
|
+
*
|
|
5
|
+
* It's a platform role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
"device-manager/decoders": {
|
|
9
|
+
actions: {
|
|
10
|
+
"*": true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
*/
|
|
14
|
+
export declare const RoleDecodersAdmin: KuzzleRole;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role allows to receive any kind of payloads.
|
|
4
|
+
*
|
|
5
|
+
@example
|
|
6
|
+
"device-manager/payloads": {
|
|
7
|
+
actions: {
|
|
8
|
+
"*": true,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
*/
|
|
12
|
+
export declare const RolePayloadsAll: KuzzleRole;
|
|
@@ -6,14 +6,14 @@ export interface ApiDecoderListRequest extends DecodersControllerRequest {
|
|
|
6
6
|
action: "list";
|
|
7
7
|
_id: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type ApiDecoderListResult = {
|
|
10
10
|
decoders: DecoderContent[];
|
|
11
11
|
};
|
|
12
12
|
export interface ApiDecoderPrunePayloadsRequest extends DecodersControllerRequest {
|
|
13
13
|
action: "prunePayloads";
|
|
14
14
|
_id: string;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export type ApiDecoderPrunePayloadsResult = {
|
|
17
17
|
deleted: number;
|
|
18
18
|
};
|
|
19
19
|
export {};
|
|
@@ -4,3 +4,6 @@ export * from "./types/DeviceApi";
|
|
|
4
4
|
export * from "./types/DeviceEvents";
|
|
5
5
|
export * from "./model/DeviceSerializer";
|
|
6
6
|
export * from "./DeviceModule";
|
|
7
|
+
export * from "./roles/RoleDevicesAdmin";
|
|
8
|
+
export * from "./roles/RoleDevicesPlatformAdmin";
|
|
9
|
+
export * from "./roles/RoleDevicesReader";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role allows to manage devices.
|
|
4
|
+
*
|
|
5
|
+
* It's a tenant role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
"device-manager/devices": {
|
|
9
|
+
actions: {
|
|
10
|
+
create: true,
|
|
11
|
+
delete: true,
|
|
12
|
+
get: true,
|
|
13
|
+
linkAsset: true,
|
|
14
|
+
search: true,
|
|
15
|
+
unlinkAsset: true,
|
|
16
|
+
update: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
"device-manager/models": {
|
|
20
|
+
actions: {
|
|
21
|
+
deleteDevice: true,
|
|
22
|
+
listDevices: true,
|
|
23
|
+
writeDevice: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
*/
|
|
27
|
+
export declare const RoleDevicesAdmin: KuzzleRole;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role allows to manage devices and also assign them to tenants.
|
|
4
|
+
*
|
|
5
|
+
* It's a platform role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
"device-manager/devices": {
|
|
9
|
+
actions: {
|
|
10
|
+
"*": true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
"device-manager/models": {
|
|
14
|
+
actions: {
|
|
15
|
+
deleteDevice: true,
|
|
16
|
+
listDevices: true,
|
|
17
|
+
writeDevice: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
*/
|
|
21
|
+
export declare const RoleDevicesPlatformAdmin: KuzzleRole;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role only gives a read-only access to devices and their models.
|
|
4
|
+
*
|
|
5
|
+
* It's a tenant role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
"device-manager/devices": {
|
|
9
|
+
actions: {
|
|
10
|
+
get: true,
|
|
11
|
+
search: true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
"device-manager/models": {
|
|
15
|
+
actions: {
|
|
16
|
+
listDevices: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
*/
|
|
21
|
+
export declare const RoleDevicesReader: KuzzleRole;
|
|
@@ -10,7 +10,7 @@ export interface ApiDeviceGetRequest extends DevicesControllerRequest {
|
|
|
10
10
|
action: "get";
|
|
11
11
|
_id: string;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type ApiDeviceGetResult = KDocument<DeviceContent>;
|
|
14
14
|
export interface ApiDeviceUpdateRequest extends DevicesControllerRequest {
|
|
15
15
|
action: "update";
|
|
16
16
|
_id: string;
|
|
@@ -19,7 +19,7 @@ export interface ApiDeviceUpdateRequest extends DevicesControllerRequest {
|
|
|
19
19
|
metadata: Metadata;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type ApiDeviceUpdateResult = KDocument<DeviceContent>;
|
|
23
23
|
export interface ApiDeviceCreateRequest extends DevicesControllerRequest {
|
|
24
24
|
action: "create";
|
|
25
25
|
refresh?: string;
|
|
@@ -29,14 +29,14 @@ export interface ApiDeviceCreateRequest extends DevicesControllerRequest {
|
|
|
29
29
|
metadata?: Metadata;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export type ApiDeviceCreateResult = KDocument<DeviceContent>;
|
|
33
33
|
export interface ApiDeviceDeleteRequest extends DevicesControllerRequest {
|
|
34
34
|
action: "delete";
|
|
35
35
|
_id: string;
|
|
36
36
|
refresh?: string;
|
|
37
37
|
strict?: boolean;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export type ApiDeviceDeleteResult = void;
|
|
40
40
|
export interface ApiDeviceSearchRequest extends DevicesControllerRequest {
|
|
41
41
|
action: "search";
|
|
42
42
|
from?: number;
|
|
@@ -44,14 +44,14 @@ export interface ApiDeviceSearchRequest extends DevicesControllerRequest {
|
|
|
44
44
|
scrollTTL?: string;
|
|
45
45
|
body: JSONObject;
|
|
46
46
|
}
|
|
47
|
-
export
|
|
47
|
+
export type ApiDeviceSearchResult = SearchResult<KHit<DeviceContent>>;
|
|
48
48
|
export interface ApiDeviceUnlinkAssetRequest extends DevicesControllerRequest {
|
|
49
49
|
action: "unlinkAsset";
|
|
50
50
|
_id: string;
|
|
51
51
|
strict?: boolean;
|
|
52
52
|
refresh?: string;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export type ApiDeviceUnlinkAssetResult = {
|
|
55
55
|
asset: KDocument<AssetContent>;
|
|
56
56
|
device: KDocument<DeviceContent>;
|
|
57
57
|
};
|
|
@@ -60,13 +60,13 @@ export interface ApiDeviceAttachEngineRequest extends DevicesControllerRequest {
|
|
|
60
60
|
_id: string;
|
|
61
61
|
refresh?: string;
|
|
62
62
|
}
|
|
63
|
-
export
|
|
63
|
+
export type ApiDeviceAttachEngineResult = void;
|
|
64
64
|
export interface ApiDeviceDetachEngineRequest extends DevicesControllerRequest {
|
|
65
65
|
action: "detachEngine";
|
|
66
66
|
_id: string;
|
|
67
67
|
refresh?: string;
|
|
68
68
|
}
|
|
69
|
-
export
|
|
69
|
+
export type ApiDeviceDetachEngineResult = void;
|
|
70
70
|
export interface ApiDeviceLinkAssetRequest extends DevicesControllerRequest {
|
|
71
71
|
action: "linkAsset";
|
|
72
72
|
_id: string;
|
|
@@ -87,7 +87,7 @@ export interface ApiDeviceLinkAssetRequest extends DevicesControllerRequest {
|
|
|
87
87
|
measureNames: Record<string, string>;
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
export
|
|
90
|
+
export type ApiDeviceLinkAssetResult = {
|
|
91
91
|
asset: KDocument<AssetContent>;
|
|
92
92
|
device: KDocument<DeviceContent>;
|
|
93
93
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { KDocument } from "kuzzle";
|
|
2
2
|
import { Metadata } from "../../../modules/shared";
|
|
3
3
|
import { DeviceContent } from "./DeviceContent";
|
|
4
|
-
export
|
|
4
|
+
export type EventDeviceUpdateBefore = {
|
|
5
5
|
name: "device-manager:device:update:before";
|
|
6
6
|
args: [{
|
|
7
7
|
device: KDocument<DeviceContent>;
|
|
8
8
|
metadata: Metadata;
|
|
9
9
|
}];
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type EventDeviceUpdateAfter = {
|
|
12
12
|
name: "device-manager:device:update:after";
|
|
13
13
|
args: [{
|
|
14
14
|
device: KDocument<DeviceContent>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MeasureDefinition } from "./../types/MeasureDefinition";
|
|
2
|
-
export
|
|
2
|
+
export type BatteryMeasurement = {
|
|
3
3
|
battery: number;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const batteryMeasureDefinition: MeasureDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MeasureDefinition } from "./../types/MeasureDefinition";
|
|
2
|
-
export
|
|
2
|
+
export type HumidityMeasurement = {
|
|
3
3
|
humidity: number;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const humidityMeasureDefinition: MeasureDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MeasureDefinition } from "./../types/MeasureDefinition";
|
|
2
|
-
export
|
|
2
|
+
export type MovementMeasurement = {
|
|
3
3
|
movement: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const movementMeasureDefinition: MeasureDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MeasureDefinition } from "./../types/MeasureDefinition";
|
|
2
|
-
export
|
|
2
|
+
export type PositionMeasurement = {
|
|
3
3
|
position: {
|
|
4
4
|
lat: number;
|
|
5
5
|
lon: number;
|
|
@@ -7,4 +7,4 @@ export declare type PositionMeasurement = {
|
|
|
7
7
|
altitude?: number;
|
|
8
8
|
accuracy?: number;
|
|
9
9
|
};
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const positionMeasureDefinition: MeasureDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MeasureDefinition } from "./../types/MeasureDefinition";
|
|
2
|
-
export
|
|
2
|
+
export type TemperatureMeasurement = {
|
|
3
3
|
temperature: number;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const temperatureMeasureDefinition: MeasureDefinition;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KuzzleRole } from "lib/modules/shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role allows to push measures and manage their models.
|
|
4
|
+
*
|
|
5
|
+
* It's a tenant role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
"device-manager/measures": {
|
|
9
|
+
actions: {
|
|
10
|
+
"*": true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
"device-manager/models": {
|
|
14
|
+
actions: {
|
|
15
|
+
deleteMeasure: true,
|
|
16
|
+
listMeasures: true,
|
|
17
|
+
writeMeasure: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
*/
|
|
21
|
+
export declare const RoleMeasuresAdmin: KuzzleRole;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { KuzzleRole } from "lib/modules/shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role allows to list measure models.
|
|
4
|
+
*
|
|
5
|
+
* It's a tenant role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
"device-manager/models": {
|
|
9
|
+
actions: {
|
|
10
|
+
listMeasures: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
*/
|
|
14
|
+
export declare const RoleMeasuresReader: KuzzleRole;
|
|
@@ -43,7 +43,7 @@ export interface MeasureContent<TMeasureValues extends JSONObject = any, TMetada
|
|
|
43
43
|
_id?: string;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
export
|
|
46
|
+
export type Measurement<TMeasureValues extends JSONObject = any> = {
|
|
47
47
|
/**
|
|
48
48
|
* Type of the measure. (e.g. "temperature")
|
|
49
49
|
*/
|
|
@@ -62,6 +62,6 @@ export declare type Measurement<TMeasureValues extends JSONObject = any> = {
|
|
|
62
62
|
/**
|
|
63
63
|
* Used in the DecodedPayload to store a decoded measure
|
|
64
64
|
*/
|
|
65
|
-
export
|
|
65
|
+
export type DecodedMeasurement<TMeasureValues extends JSONObject = JSONObject> = {
|
|
66
66
|
measureName: string;
|
|
67
67
|
} & Measurement<TMeasureValues>;
|
|
@@ -6,7 +6,7 @@ import { DecodedMeasurement, MeasureContent } from "./MeasureContent";
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type EventMeasureIngest = {
|
|
10
10
|
name: "device-manager:measures:ingest";
|
|
11
11
|
args: [
|
|
12
12
|
{
|
|
@@ -17,7 +17,7 @@ export declare type EventMeasureIngest = {
|
|
|
17
17
|
}
|
|
18
18
|
];
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type EventMeasureProcessBefore = {
|
|
21
21
|
name: "device-manager:measures:process:before";
|
|
22
22
|
args: [
|
|
23
23
|
{
|
|
@@ -27,7 +27,7 @@ export declare type EventMeasureProcessBefore = {
|
|
|
27
27
|
}
|
|
28
28
|
];
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type TenantEventMeasureProcessBefore = {
|
|
31
31
|
name: `engine:${string}:device-manager:measures:process:before`;
|
|
32
32
|
args: [
|
|
33
33
|
{
|
|
@@ -37,7 +37,7 @@ export declare type TenantEventMeasureProcessBefore = {
|
|
|
37
37
|
}
|
|
38
38
|
];
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export type EventMeasureProcessAfter = {
|
|
41
41
|
name: "device-manager:measures:process:after";
|
|
42
42
|
args: [
|
|
43
43
|
{
|
|
@@ -47,7 +47,7 @@ export declare type EventMeasureProcessAfter = {
|
|
|
47
47
|
}
|
|
48
48
|
];
|
|
49
49
|
};
|
|
50
|
-
export
|
|
50
|
+
export type TenantEventMeasureProcessAfter = {
|
|
51
51
|
name: `engine:${string}:device-manager:measures:process:after`;
|
|
52
52
|
args: [
|
|
53
53
|
{
|
|
@@ -12,7 +12,7 @@ export interface ApiModelCreateAssetRequest extends ModelsControllerRequest {
|
|
|
12
12
|
defaultValues: JSONObject;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
export
|
|
15
|
+
export type ApiModelCreateAssetResult = KDocument<AssetModelContent>;
|
|
16
16
|
export interface ApiModelCreateDeviceRequest extends ModelsControllerRequest {
|
|
17
17
|
action: "writeDevice";
|
|
18
18
|
body: {
|
|
@@ -21,7 +21,7 @@ export interface ApiModelCreateDeviceRequest extends ModelsControllerRequest {
|
|
|
21
21
|
defaultValues: JSONObject;
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type ApiModelCreateDeviceResult = KDocument<DeviceModelContent>;
|
|
25
25
|
export interface ApiModelCreateMeasureRequest extends ModelsControllerRequest {
|
|
26
26
|
action: "writeMeasure";
|
|
27
27
|
body: {
|
|
@@ -34,41 +34,41 @@ export interface ApiModelCreateMeasureRequest extends ModelsControllerRequest {
|
|
|
34
34
|
valuesMappings: JSONObject;
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
export
|
|
37
|
+
export type ApiModelCreateMeasureResult = KDocument<MeasureModelContent>;
|
|
38
38
|
export interface ApiModelDeleteAssetRequest extends ModelsControllerRequest {
|
|
39
39
|
action: "deleteAsset";
|
|
40
40
|
_id: string;
|
|
41
41
|
}
|
|
42
|
-
export
|
|
42
|
+
export type ApiModelDeleteAssetResult = void;
|
|
43
43
|
export interface ApiModelDeleteDeviceRequest extends ModelsControllerRequest {
|
|
44
44
|
action: "deleteDevice";
|
|
45
45
|
_id: string;
|
|
46
46
|
}
|
|
47
|
-
export
|
|
47
|
+
export type ApiModelDeleteDeviceResult = void;
|
|
48
48
|
export interface ApiModelDeleteMeasureRequest extends ModelsControllerRequest {
|
|
49
49
|
action: "deleteMeasure";
|
|
50
50
|
_id: string;
|
|
51
51
|
}
|
|
52
|
-
export
|
|
52
|
+
export type ApiModelDeleteMeasureResult = void;
|
|
53
53
|
export interface ApiModelListAssetsRequest extends ModelsControllerRequest {
|
|
54
54
|
action: "listAssets";
|
|
55
55
|
engineGroup: string;
|
|
56
56
|
}
|
|
57
|
-
export
|
|
57
|
+
export type ApiModelListAssetsResult = {
|
|
58
58
|
models: KDocument<AssetModelContent>[];
|
|
59
59
|
total: number;
|
|
60
60
|
};
|
|
61
61
|
export interface ApiModelListDevicesRequest extends ModelsControllerRequest {
|
|
62
62
|
action: "listDevices";
|
|
63
63
|
}
|
|
64
|
-
export
|
|
64
|
+
export type ApiModelListDevicesResult = {
|
|
65
65
|
models: KDocument<DeviceModelContent>[];
|
|
66
66
|
total: number;
|
|
67
67
|
};
|
|
68
68
|
export interface ApiModelListMeasuresRequest extends ModelsControllerRequest {
|
|
69
69
|
action: "listMeasures";
|
|
70
70
|
}
|
|
71
|
-
export
|
|
71
|
+
export type ApiModelListMeasuresResult = {
|
|
72
72
|
models: KDocument<MeasureModelContent>[];
|
|
73
73
|
total: number;
|
|
74
74
|
};
|
|
@@ -93,4 +93,4 @@ export interface DeviceModelContent extends KDocumentContent {
|
|
|
93
93
|
measures: Record<string, string>;
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
export
|
|
96
|
+
export type ModelContent = MeasureModelContent | AssetModelContent | DeviceModelContent;
|
|
@@ -1,12 +1,62 @@
|
|
|
1
1
|
import { JSONObject } from "kuzzle";
|
|
2
2
|
import { Decoder, NamedMeasures } from "../../../modules/decoder";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Define an asset model
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* {
|
|
8
|
+
* measuresNames: [
|
|
9
|
+
* { name: "temperatureExt", type: "temperature" },
|
|
10
|
+
* { name: "temperatureInt", type: "temperature" },
|
|
11
|
+
* { name: "position", type: "position" },
|
|
12
|
+
* ],
|
|
13
|
+
* metadataMappings: {
|
|
14
|
+
* weight: { type: "integer" },
|
|
15
|
+
* height: { type: "integer" },
|
|
16
|
+
* },
|
|
17
|
+
* defaultMetadata: {
|
|
18
|
+
* height: 20
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export type AssetModelDefinition = {
|
|
24
|
+
/**
|
|
25
|
+
* Array describing measures names and types
|
|
26
|
+
*/
|
|
4
27
|
measuresNames: NamedMeasures;
|
|
28
|
+
/**
|
|
29
|
+
* Metadata mappings definition
|
|
30
|
+
*/
|
|
5
31
|
metadataMappings: JSONObject;
|
|
32
|
+
/**
|
|
33
|
+
* Default metadata values
|
|
34
|
+
*/
|
|
6
35
|
defaultMetadata?: JSONObject;
|
|
7
36
|
};
|
|
8
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Define a device model
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* {
|
|
42
|
+
* decoder: new DummyTempPositionDecoder(),
|
|
43
|
+
* metadataMappings: {
|
|
44
|
+
* serial: { type: "keyword" },
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export type DeviceModelDefinition = {
|
|
50
|
+
/**
|
|
51
|
+
* Decoder used to decode payloads
|
|
52
|
+
*/
|
|
9
53
|
decoder: Decoder;
|
|
10
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Metadata mappings definition
|
|
56
|
+
*/
|
|
57
|
+
metadataMappings?: JSONObject;
|
|
58
|
+
/**
|
|
59
|
+
* Default metadata values
|
|
60
|
+
*/
|
|
11
61
|
defaultMetadata?: JSONObject;
|
|
12
62
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetModelContent, DeviceModelContent } from "./ModelContent";
|
|
2
|
-
export
|
|
2
|
+
export type AskModelAssetGet = {
|
|
3
3
|
name: "ask:device-manager:model:asset:get";
|
|
4
4
|
payload: {
|
|
5
5
|
engineGroup: string;
|
|
@@ -7,7 +7,7 @@ export declare type AskModelAssetGet = {
|
|
|
7
7
|
};
|
|
8
8
|
result: AssetModelContent;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type AskModelDeviceGet = {
|
|
11
11
|
name: "ask:device-manager:model:device:get";
|
|
12
12
|
payload: {
|
|
13
13
|
model: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSONObject } from "kuzzle";
|
|
2
|
-
export
|
|
2
|
+
export type EmbeddedMeasure<TMeasureValue extends JSONObject = JSONObject> = {
|
|
3
3
|
/**
|
|
4
4
|
* Payloads that created this measure.
|
|
5
5
|
* This can be used to retrieve the measure in the measures collection
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type MetadataValue = boolean | number | string | {
|
|
2
2
|
lat: number;
|
|
3
3
|
lon: number;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type Metadata = Record<string, MetadataValue | Record<string, MetadataValue>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AskEventDefinition = {
|
|
2
2
|
name: string;
|
|
3
3
|
payload: any;
|
|
4
4
|
result: any;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type AskEventHandler<TAskEventDefinition extends AskEventDefinition = AskEventDefinition> = (payload?: TAskEventDefinition["payload"]) => Promise<TAskEventDefinition["result"]>;
|
|
7
7
|
export declare function onAsk<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], handler: AskEventHandler<TAskEventDefinition>): Promise<any>;
|
|
8
8
|
export declare function ask<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], payload?: TAskEventDefinition["payload"]): Promise<TAskEventDefinition["result"]>;
|