kuzzle-device-manager 0.4.13 → 2.0.0-rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.js +6 -1
- package/lib/DeviceManagerPlugin.d.ts +33 -65
- package/lib/DeviceManagerPlugin.js +142 -131
- package/lib/controllers/AssetController.d.ts +20 -5
- package/lib/controllers/AssetController.js +78 -23
- package/lib/controllers/DecodersController.d.ts +16 -0
- package/lib/controllers/DecodersController.js +27 -0
- package/lib/controllers/DeviceController.d.ts +25 -22
- package/lib/controllers/DeviceController.js +150 -109
- package/lib/controllers/index.d.ts +1 -1
- package/lib/controllers/index.js +6 -2
- package/lib/core-classes/AssetService.d.ts +31 -0
- package/lib/core-classes/AssetService.js +82 -0
- package/lib/core-classes/Decoder.d.ts +14 -59
- package/lib/core-classes/Decoder.js +16 -86
- package/lib/core-classes/DeviceManagerEngine.d.ts +11 -9
- package/lib/core-classes/DeviceManagerEngine.js +20 -32
- package/lib/core-classes/DeviceService.d.ts +81 -24
- package/lib/core-classes/DeviceService.js +178 -220
- package/lib/core-classes/PayloadService.d.ts +39 -26
- package/lib/core-classes/PayloadService.js +132 -124
- package/lib/core-classes/index.d.ts +5 -4
- package/lib/core-classes/index.js +10 -5
- package/lib/core-classes/{CustomMappings/AssetMappingsManager.d.ts → registers/AssetsRegister.d.ts} +8 -9
- package/lib/core-classes/{CustomMappings/AssetMappingsManager.js → registers/AssetsRegister.js} +17 -28
- package/lib/core-classes/registers/DecodersRegister.d.ts +46 -0
- package/lib/core-classes/registers/DecodersRegister.js +167 -0
- package/lib/core-classes/registers/DevicesRegister.d.ts +20 -0
- package/lib/core-classes/registers/DevicesRegister.js +37 -0
- package/lib/core-classes/registers/MeasuresRegister.d.ts +29 -0
- package/lib/core-classes/registers/MeasuresRegister.js +53 -0
- package/lib/mappings/assetsMappings.d.ts +36 -0
- package/lib/mappings/assetsMappings.js +36 -0
- package/lib/mappings/deviceMappings.d.ts +44 -0
- package/lib/mappings/deviceMappings.js +42 -0
- package/lib/mappings/index.d.ts +4 -0
- package/lib/mappings/index.js +21 -0
- package/lib/mappings/measuresMappings.d.ts +53 -0
- package/lib/mappings/measuresMappings.js +48 -0
- package/lib/mappings/payloadsMappings.d.ts +18 -0
- package/lib/mappings/payloadsMappings.js +16 -0
- package/lib/measures/BatteryMeasure.d.ts +7 -0
- package/lib/measures/BatteryMeasure.js +12 -0
- package/lib/measures/HumidityMeasure.d.ts +7 -0
- package/lib/measures/HumidityMeasure.js +12 -0
- package/lib/measures/MovementMeasure.d.ts +7 -0
- package/lib/measures/MovementMeasure.js +12 -0
- package/lib/measures/PositionMeasure.d.ts +12 -0
- package/lib/measures/PositionMeasure.js +16 -0
- package/lib/measures/TemperatureMeasure.d.ts +7 -0
- package/lib/measures/TemperatureMeasure.js +12 -0
- package/lib/measures/index.d.ts +5 -0
- package/lib/measures/index.js +22 -0
- package/lib/models/BaseAsset.d.ts +1 -48
- package/lib/models/BaseAsset.js +5 -43
- package/lib/models/Config.d.ts +1 -13
- package/lib/models/Device.d.ts +5 -96
- package/lib/models/Device.js +5 -73
- package/lib/models/index.d.ts +0 -1
- package/lib/models/index.js +5 -2
- package/lib/types/BaseAssetContent.d.ts +8 -3
- package/lib/types/DecodedPayload.d.ts +42 -0
- package/lib/types/{AssetsHistoryContent.js → DecodedPayload.js} +1 -1
- package/lib/types/DecoderContent.d.ts +4 -0
- package/lib/types/DecoderContent.js +3 -0
- package/lib/types/DeviceContent.d.ts +12 -44
- package/lib/types/DeviceManagerConfiguration.d.ts +40 -0
- package/lib/types/DeviceManagerConfiguration.js +3 -0
- package/lib/types/index.d.ts +7 -2
- package/lib/types/index.js +12 -3
- package/lib/types/measures/MeasureContent.d.ts +56 -0
- package/lib/types/measures/MeasureContent.js +3 -0
- package/lib/types/measures/MeasureDefinition.d.ts +40 -0
- package/lib/types/measures/MeasureDefinition.js +3 -0
- package/lib/types/measures/Measurement.d.ts +19 -0
- package/lib/types/{Measure.js → measures/Measurement.js} +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +6 -2
- package/lib/utils/writeMany.d.ts +13 -0
- package/lib/utils/writeMany.js +37 -0
- package/package.json +14 -18
- package/lib/controllers/CRUDController.d.ts +0 -34
- package/lib/controllers/CRUDController.js +0 -65
- package/lib/core-classes/BatchProcessing/BatchController.d.ts +0 -34
- package/lib/core-classes/BatchProcessing/BatchController.js +0 -115
- package/lib/core-classes/BatchProcessing/BatchWriter.d.ts +0 -110
- package/lib/core-classes/BatchProcessing/BatchWriter.js +0 -264
- package/lib/core-classes/BatchProcessing/InstrumentablePromise.d.ts +0 -6
- package/lib/core-classes/BatchProcessing/InstrumentablePromise.js +0 -13
- package/lib/core-classes/BatchProcessing/index.d.ts +0 -3
- package/lib/core-classes/BatchProcessing/index.js +0 -16
- package/lib/core-classes/CustomMappings/DeviceMappingsManager.d.ts +0 -43
- package/lib/core-classes/CustomMappings/DeviceMappingsManager.js +0 -71
- package/lib/core-classes/MigrationService.d.ts +0 -13
- package/lib/core-classes/MigrationService.js +0 -49
- package/lib/models/Catalog.d.ts +0 -55
- package/lib/models/Catalog.js +0 -38
- package/lib/types/AssetsHistoryContent.d.ts +0 -9
- package/lib/types/Measure.d.ts +0 -54
- package/lib/utils/events.d.ts +0 -8
- package/lib/utils/events.js +0 -17
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DecodersRegister = void 0;
|
|
4
|
+
const kuzzle_1 = require("kuzzle");
|
|
5
|
+
class DecodersRegister {
|
|
6
|
+
constructor() {
|
|
7
|
+
this._decoders = new Map();
|
|
8
|
+
}
|
|
9
|
+
get sdk() {
|
|
10
|
+
return this.context.accessors.sdk;
|
|
11
|
+
}
|
|
12
|
+
get decoders() {
|
|
13
|
+
return Array.from(this._decoders.values());
|
|
14
|
+
}
|
|
15
|
+
init(context) {
|
|
16
|
+
this.context = context;
|
|
17
|
+
}
|
|
18
|
+
async list() {
|
|
19
|
+
const decoders = this.decoders.map(decoder => decoder.serialize());
|
|
20
|
+
return decoders;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Registers a new decoder for a device model.
|
|
24
|
+
*
|
|
25
|
+
* This will register a new API action:
|
|
26
|
+
* - controller: `device-manager/payload`
|
|
27
|
+
* - action: `action` property of the decoder or the device model in kebab-case
|
|
28
|
+
*
|
|
29
|
+
* @param decoder Instantiated decoder
|
|
30
|
+
*
|
|
31
|
+
* @returns Corresponding API action requestPayload
|
|
32
|
+
*/
|
|
33
|
+
register(decoder) {
|
|
34
|
+
decoder.action = decoder.action || kuzzle_1.Inflector.kebabCase(decoder.deviceModel);
|
|
35
|
+
if (this._decoders.has(decoder.deviceModel)) {
|
|
36
|
+
throw new kuzzle_1.PluginImplementationError(`Decoder for device model "${decoder.deviceModel}" already registered`);
|
|
37
|
+
}
|
|
38
|
+
this._decoders.set(decoder.deviceModel, decoder);
|
|
39
|
+
return {
|
|
40
|
+
action: decoder.action,
|
|
41
|
+
controller: 'device-manager/payload',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build the PayloadController with registered decoders
|
|
46
|
+
*
|
|
47
|
+
* @todo generate OpenAPI specification
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
getPayloadController(payloadService) {
|
|
52
|
+
const controllers = { actions: {} };
|
|
53
|
+
for (const decoder of this.decoders) {
|
|
54
|
+
controllers.actions[decoder.action] = {
|
|
55
|
+
handler: async (request) => {
|
|
56
|
+
const source = request.getBoolean('source');
|
|
57
|
+
const ret = await payloadService.process(request, decoder);
|
|
58
|
+
return source ? ret : undefined;
|
|
59
|
+
},
|
|
60
|
+
http: decoder.http,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return controllers;
|
|
64
|
+
}
|
|
65
|
+
printDecoders() {
|
|
66
|
+
for (const decoder of this.decoders) {
|
|
67
|
+
this.context.log.info(`Decoder for "${decoder.deviceModel}" registered`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates default roles, profiles and users associated to the generated actions
|
|
72
|
+
* in the Payload controller.
|
|
73
|
+
*
|
|
74
|
+
* This method never returns a rejected promise.
|
|
75
|
+
*/
|
|
76
|
+
async createDefaultRights() {
|
|
77
|
+
try {
|
|
78
|
+
await this.createDefaultRoles();
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
this.context.log.error(`Cannot register default decoders roles: ${error}${error.stack}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
await this.createDefaultProfiles();
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
this.context.log.error(`Cannot register default decoders profiles: ${error}${error.stack}`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
await this.createDefaultUsers();
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.context.log.error(`Cannot register default decoders users: ${error}${error.stack}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async createDefaultUsers() {
|
|
99
|
+
const promises = [];
|
|
100
|
+
const gatewayUser = {
|
|
101
|
+
content: {
|
|
102
|
+
profileIds: []
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
for (const decoder of this.decoders) {
|
|
106
|
+
const userId = `payload-gateway.${decoder.action}`;
|
|
107
|
+
const user = {
|
|
108
|
+
content: {
|
|
109
|
+
// each created user has only the profile of the same name
|
|
110
|
+
profileIds: [userId]
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
gatewayUser.content.profileIds.push(userId);
|
|
114
|
+
promises.push(this.sdk.security.createUser(userId, user)
|
|
115
|
+
.catch(error => {
|
|
116
|
+
if (error.id !== 'security.user.already_exists') {
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
return this.sdk.security.updateUser(userId, user);
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
promises.push(this.sdk.security.createUser('payload-gateway', gatewayUser)
|
|
123
|
+
.catch(error => {
|
|
124
|
+
if (error.id !== 'security.user.already_exists') {
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
return this.sdk.security.updateUser('payload-gateway', gatewayUser);
|
|
128
|
+
}));
|
|
129
|
+
await Promise.all(promises);
|
|
130
|
+
}
|
|
131
|
+
async createDefaultProfiles() {
|
|
132
|
+
const promises = [];
|
|
133
|
+
const gatewayProfile = {
|
|
134
|
+
policies: []
|
|
135
|
+
};
|
|
136
|
+
for (const decoder of this.decoders) {
|
|
137
|
+
const profileId = `payload-gateway.${decoder.action}`;
|
|
138
|
+
const profile = {
|
|
139
|
+
// each created profile has only the role of the same name
|
|
140
|
+
policies: [{ roleId: profileId }]
|
|
141
|
+
};
|
|
142
|
+
gatewayProfile.policies.push({ roleId: profileId });
|
|
143
|
+
promises.push(this.sdk.security.createOrReplaceProfile(profileId, profile));
|
|
144
|
+
}
|
|
145
|
+
promises.push(this.sdk.security.createOrReplaceProfile('payload-gateway', gatewayProfile));
|
|
146
|
+
await Promise.all(promises);
|
|
147
|
+
}
|
|
148
|
+
async createDefaultRoles() {
|
|
149
|
+
const promises = [];
|
|
150
|
+
for (const decoder of this.decoders) {
|
|
151
|
+
const roleId = `payload-gateway.${decoder.action}`;
|
|
152
|
+
const role = {
|
|
153
|
+
controllers: {
|
|
154
|
+
'device-manager/payload': {
|
|
155
|
+
actions: {
|
|
156
|
+
[decoder.action]: true
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
promises.push(this.sdk.security.createOrReplaceRole(roleId, role));
|
|
162
|
+
}
|
|
163
|
+
await Promise.all(promises);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.DecodersRegister = DecodersRegister;
|
|
167
|
+
//# sourceMappingURL=DecodersRegister.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JSONObject } from 'kuzzle';
|
|
2
|
+
import { MeasuresRegister } from './MeasuresRegister';
|
|
3
|
+
export declare class DevicesRegister {
|
|
4
|
+
private mappings;
|
|
5
|
+
private measuresRegister;
|
|
6
|
+
constructor(measuresRegister: MeasuresRegister);
|
|
7
|
+
/**
|
|
8
|
+
* Register custom metadata for devices
|
|
9
|
+
*
|
|
10
|
+
* @param metadata Device custom metadata mappings
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* plugin.devices.registerMetadata({
|
|
14
|
+
* serial: { type: 'keyword' },
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
registerMetadata(metadata: JSONObject): void;
|
|
19
|
+
getMappings(): JSONObject;
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DevicesRegister = void 0;
|
|
4
|
+
const kuzzle_1 = require("kuzzle");
|
|
5
|
+
const mappings_1 = require("../../mappings");
|
|
6
|
+
class DevicesRegister {
|
|
7
|
+
constructor(measuresRegister) {
|
|
8
|
+
this.mappings = JSON.parse(JSON.stringify(mappings_1.devicesMappings));
|
|
9
|
+
this.measuresRegister = measuresRegister;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Register custom metadata for devices
|
|
13
|
+
*
|
|
14
|
+
* @param metadata Device custom metadata mappings
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* plugin.devices.registerMetadata({
|
|
18
|
+
* serial: { type: 'keyword' },
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
registerMetadata(metadata) {
|
|
23
|
+
for (const [name, value] of Object.entries(metadata)) {
|
|
24
|
+
if (this.mappings.properties.metadata.properties[name]) {
|
|
25
|
+
throw new kuzzle_1.PluginImplementationError(`Device metadata "${name}" already exists`);
|
|
26
|
+
}
|
|
27
|
+
this.mappings.properties.metadata.properties[name] = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
getMappings() {
|
|
31
|
+
const mappings = JSON.parse(JSON.stringify(this.mappings));
|
|
32
|
+
mappings.properties.measures = this.measuresRegister.getMappings();
|
|
33
|
+
return mappings;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.DevicesRegister = DevicesRegister;
|
|
37
|
+
//# sourceMappingURL=DevicesRegister.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { JSONObject } from 'kuzzle';
|
|
2
|
+
import { MeasureDefinition } from '../../types';
|
|
3
|
+
export declare class MeasuresRegister {
|
|
4
|
+
private mappings;
|
|
5
|
+
/**
|
|
6
|
+
* Registered measures
|
|
7
|
+
*
|
|
8
|
+
* Map<type, MeasureDefinition>
|
|
9
|
+
*/
|
|
10
|
+
private measures;
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Register custom measure definition
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* plugin.measure.register('humidity', {
|
|
17
|
+
* unit: {
|
|
18
|
+
* name: 'Humidity',
|
|
19
|
+
* sign: '%',
|
|
20
|
+
* type: 'number',
|
|
21
|
+
* },
|
|
22
|
+
* mappings: { humidity: { type: 'float' } },
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
register(type: string, measure: MeasureDefinition): void;
|
|
27
|
+
get(type: string): MeasureDefinition;
|
|
28
|
+
getMappings(): JSONObject;
|
|
29
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MeasuresRegister = void 0;
|
|
4
|
+
const kuzzle_1 = require("kuzzle");
|
|
5
|
+
const mappings_1 = require("../../mappings");
|
|
6
|
+
class MeasuresRegister {
|
|
7
|
+
constructor() {
|
|
8
|
+
/**
|
|
9
|
+
* Registered measures
|
|
10
|
+
*
|
|
11
|
+
* Map<type, MeasureDefinition>
|
|
12
|
+
*/
|
|
13
|
+
this.measures = new Map();
|
|
14
|
+
this.mappings = JSON.parse(JSON.stringify(mappings_1.measuresMappings));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register custom measure definition
|
|
18
|
+
*
|
|
19
|
+
* ```js
|
|
20
|
+
* plugin.measure.register('humidity', {
|
|
21
|
+
* unit: {
|
|
22
|
+
* name: 'Humidity',
|
|
23
|
+
* sign: '%',
|
|
24
|
+
* type: 'number',
|
|
25
|
+
* },
|
|
26
|
+
* mappings: { humidity: { type: 'float' } },
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
register(type, measure) {
|
|
31
|
+
if (this.measures.has(type)) {
|
|
32
|
+
throw new kuzzle_1.PluginImplementationError(`Measure "${type}" already exists.`);
|
|
33
|
+
}
|
|
34
|
+
for (const [field, definition] of Object.entries(measure.valuesMappings)) {
|
|
35
|
+
if (this.mappings.properties.values.properties[field]) {
|
|
36
|
+
throw new kuzzle_1.PluginImplementationError(`Field "${type}" already exists in measures mappings.`);
|
|
37
|
+
}
|
|
38
|
+
this.mappings.properties.values.properties[field] = definition;
|
|
39
|
+
}
|
|
40
|
+
this.measures.set(type, measure);
|
|
41
|
+
}
|
|
42
|
+
get(type) {
|
|
43
|
+
if (!this.measures.has(type)) {
|
|
44
|
+
throw new kuzzle_1.PluginImplementationError(`Measure "${type}" does not exists.`);
|
|
45
|
+
}
|
|
46
|
+
return this.measures.get(type);
|
|
47
|
+
}
|
|
48
|
+
getMappings() {
|
|
49
|
+
return this.mappings;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.MeasuresRegister = MeasuresRegister;
|
|
53
|
+
//# sourceMappingURL=MeasuresRegister.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const assetsMappings: {
|
|
2
|
+
dynamic: string;
|
|
3
|
+
properties: {
|
|
4
|
+
measures: {
|
|
5
|
+
properties: {};
|
|
6
|
+
};
|
|
7
|
+
metadata: {
|
|
8
|
+
dynamic: string;
|
|
9
|
+
properties: {};
|
|
10
|
+
};
|
|
11
|
+
model: {
|
|
12
|
+
fields: {
|
|
13
|
+
text: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
reference: {
|
|
20
|
+
fields: {
|
|
21
|
+
text: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
type: {
|
|
28
|
+
fields: {
|
|
29
|
+
text: {
|
|
30
|
+
type: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetsMappings = void 0;
|
|
4
|
+
exports.assetsMappings = {
|
|
5
|
+
dynamic: 'strict',
|
|
6
|
+
properties: {
|
|
7
|
+
measures: {
|
|
8
|
+
properties: {
|
|
9
|
+
// autogenerated from devices mappings
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
metadata: {
|
|
13
|
+
dynamic: 'false',
|
|
14
|
+
properties: {}
|
|
15
|
+
},
|
|
16
|
+
model: {
|
|
17
|
+
fields: {
|
|
18
|
+
text: { type: 'text' }
|
|
19
|
+
},
|
|
20
|
+
type: 'keyword'
|
|
21
|
+
},
|
|
22
|
+
reference: {
|
|
23
|
+
fields: {
|
|
24
|
+
text: { type: 'text' }
|
|
25
|
+
},
|
|
26
|
+
type: 'keyword'
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
fields: {
|
|
30
|
+
text: { type: 'text' }
|
|
31
|
+
},
|
|
32
|
+
type: 'keyword'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=assetsMappings.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const devicesMappings: {
|
|
2
|
+
dynamic: string;
|
|
3
|
+
properties: {
|
|
4
|
+
assetId: {
|
|
5
|
+
fields: {
|
|
6
|
+
text: {
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
engineId: {
|
|
13
|
+
fields: {
|
|
14
|
+
text: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
measures: {
|
|
21
|
+
properties: {};
|
|
22
|
+
};
|
|
23
|
+
metadata: {
|
|
24
|
+
dynamic: string;
|
|
25
|
+
properties: {};
|
|
26
|
+
};
|
|
27
|
+
model: {
|
|
28
|
+
fields: {
|
|
29
|
+
text: {
|
|
30
|
+
type: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
reference: {
|
|
36
|
+
fields: {
|
|
37
|
+
text: {
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.devicesMappings = void 0;
|
|
4
|
+
exports.devicesMappings = {
|
|
5
|
+
dynamic: 'strict',
|
|
6
|
+
properties: {
|
|
7
|
+
assetId: {
|
|
8
|
+
fields: {
|
|
9
|
+
text: { type: 'text' }
|
|
10
|
+
},
|
|
11
|
+
type: 'keyword'
|
|
12
|
+
},
|
|
13
|
+
engineId: {
|
|
14
|
+
fields: {
|
|
15
|
+
text: { type: 'text' }
|
|
16
|
+
},
|
|
17
|
+
type: 'keyword'
|
|
18
|
+
},
|
|
19
|
+
measures: {
|
|
20
|
+
properties: {
|
|
21
|
+
// measures mappings will be injected by the plugin
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
metadata: {
|
|
25
|
+
dynamic: 'false',
|
|
26
|
+
properties: {},
|
|
27
|
+
},
|
|
28
|
+
model: {
|
|
29
|
+
fields: {
|
|
30
|
+
text: { type: 'text' },
|
|
31
|
+
},
|
|
32
|
+
type: 'keyword'
|
|
33
|
+
},
|
|
34
|
+
reference: {
|
|
35
|
+
fields: {
|
|
36
|
+
text: { type: 'text' },
|
|
37
|
+
},
|
|
38
|
+
type: 'keyword'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=deviceMappings.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./assetsMappings"), exports);
|
|
18
|
+
__exportStar(require("./deviceMappings"), exports);
|
|
19
|
+
__exportStar(require("./payloadsMappings"), exports);
|
|
20
|
+
__exportStar(require("./measuresMappings"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const measuresMappings: {
|
|
2
|
+
dynamic: string;
|
|
3
|
+
properties: {
|
|
4
|
+
measuredAt: {
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A device may have different measures for the same type (e.g. measure temperature 2 times)
|
|
9
|
+
* Should be set when you link the device to the asset
|
|
10
|
+
*/
|
|
11
|
+
name: {
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
origin: {
|
|
15
|
+
type: string;
|
|
16
|
+
properties: {
|
|
17
|
+
id: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
model: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
payloadUuids: {
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
type: {
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
assetId: {
|
|
30
|
+
type: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Type of the measure. (e.g. "temperature")
|
|
36
|
+
* The type name is also the name of the sub-property to look at
|
|
37
|
+
* in the "values" object to get the measure main value.
|
|
38
|
+
*/
|
|
39
|
+
type: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Measure self-description
|
|
44
|
+
*/
|
|
45
|
+
unit: {
|
|
46
|
+
dynamic: string;
|
|
47
|
+
properties: {};
|
|
48
|
+
};
|
|
49
|
+
values: {
|
|
50
|
+
properties: {};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable sort-keys */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.measuresMappings = void 0;
|
|
5
|
+
exports.measuresMappings = {
|
|
6
|
+
dynamic: 'strict',
|
|
7
|
+
properties: {
|
|
8
|
+
measuredAt: { type: 'double' },
|
|
9
|
+
/**
|
|
10
|
+
* A device may have different measures for the same type (e.g. measure temperature 2 times)
|
|
11
|
+
* Should be set when you link the device to the asset
|
|
12
|
+
*/
|
|
13
|
+
name: { type: 'keyword' },
|
|
14
|
+
origin: {
|
|
15
|
+
type: 'nested',
|
|
16
|
+
properties: {
|
|
17
|
+
// ID of the device (document _id)
|
|
18
|
+
id: { type: 'keyword' },
|
|
19
|
+
// E.g. "AbeewayTemp"
|
|
20
|
+
model: { type: 'keyword' },
|
|
21
|
+
// Array of payload uuids that were used to create this measure.
|
|
22
|
+
payloadUuids: { type: 'keyword' },
|
|
23
|
+
// E.g. "device"
|
|
24
|
+
type: { type: 'keyword' },
|
|
25
|
+
// Asset linked to the device when the measure was made
|
|
26
|
+
assetId: { type: 'keyword' },
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Type of the measure. (e.g. "temperature")
|
|
31
|
+
* The type name is also the name of the sub-property to look at
|
|
32
|
+
* in the "values" object to get the measure main value.
|
|
33
|
+
*/
|
|
34
|
+
type: { type: 'keyword' },
|
|
35
|
+
/**
|
|
36
|
+
* Measure self-description
|
|
37
|
+
*/
|
|
38
|
+
unit: {
|
|
39
|
+
dynamic: 'false',
|
|
40
|
+
properties: {}
|
|
41
|
+
},
|
|
42
|
+
values: {
|
|
43
|
+
properties: {},
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/* eslint-enable sort-keys */
|
|
48
|
+
//# sourceMappingURL=measuresMappings.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const payloadsMappings: {
|
|
2
|
+
dynamic: string;
|
|
3
|
+
properties: {
|
|
4
|
+
deviceModel: {
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
payload: {
|
|
8
|
+
dynamic: string;
|
|
9
|
+
properties: {};
|
|
10
|
+
};
|
|
11
|
+
uuid: {
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
valid: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.payloadsMappings = void 0;
|
|
4
|
+
exports.payloadsMappings = {
|
|
5
|
+
dynamic: 'strict',
|
|
6
|
+
properties: {
|
|
7
|
+
deviceModel: { type: 'keyword' },
|
|
8
|
+
payload: {
|
|
9
|
+
dynamic: 'false',
|
|
10
|
+
properties: {}
|
|
11
|
+
},
|
|
12
|
+
uuid: { type: 'keyword' },
|
|
13
|
+
valid: { type: 'boolean' },
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=payloadsMappings.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.batteryMeasure = void 0;
|
|
4
|
+
exports.batteryMeasure = {
|
|
5
|
+
valuesMappings: { battery: { type: 'integer' } },
|
|
6
|
+
unit: {
|
|
7
|
+
name: 'Volt',
|
|
8
|
+
sign: 'v',
|
|
9
|
+
type: 'number',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=BatteryMeasure.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.humidityMeasure = void 0;
|
|
4
|
+
exports.humidityMeasure = {
|
|
5
|
+
valuesMappings: { humidity: { type: 'float' } },
|
|
6
|
+
unit: {
|
|
7
|
+
name: 'Humidity',
|
|
8
|
+
sign: '%',
|
|
9
|
+
type: 'number',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=HumidityMeasure.js.map
|