@golemio/microclimate 1.0.1-dev.675426205
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/LICENSE +11 -0
- package/README.md +46 -0
- package/db/example/.config.json +3 -0
- package/db/example/00_truncate_tables.sql +2 -0
- package/db/example/01_microclimate.sql +2 -0
- package/db/migrations/postgresql/.config.json +3 -0
- package/db/migrations/postgresql/20221018165642-init-mongo-to-pg.js +51 -0
- package/db/migrations/postgresql/package.json +3 -0
- package/db/migrations/postgresql/sqls/20221018165642-init-mongo-to-pg-down.sql +2 -0
- package/db/migrations/postgresql/sqls/20221018165642-init-mongo-to-pg-up.sql +48 -0
- package/db/migrations/postgresql/sqls/package.json +3 -0
- package/dist/integration-engine/datasources/MeasurementsDataSourceFactory.d.ts +5 -0
- package/dist/integration-engine/datasources/MeasurementsDataSourceFactory.js +23 -0
- package/dist/integration-engine/datasources/MeasurementsDataSourceFactory.js.map +1 -0
- package/dist/integration-engine/datasources/SensorDevicesDataSourceFactory.d.ts +4 -0
- package/dist/integration-engine/datasources/SensorDevicesDataSourceFactory.js +18 -0
- package/dist/integration-engine/datasources/SensorDevicesDataSourceFactory.js.map +1 -0
- package/dist/integration-engine/index.d.ts +1 -0
- package/dist/integration-engine/index.js +7 -0
- package/dist/integration-engine/index.js.map +1 -0
- package/dist/integration-engine/repositories/MeasurementsRepository.d.ts +6 -0
- package/dist/integration-engine/repositories/MeasurementsRepository.js +39 -0
- package/dist/integration-engine/repositories/MeasurementsRepository.js.map +1 -0
- package/dist/integration-engine/repositories/SensorDevicesRepository.d.ts +6 -0
- package/dist/integration-engine/repositories/SensorDevicesRepository.js +39 -0
- package/dist/integration-engine/repositories/SensorDevicesRepository.js.map +1 -0
- package/dist/integration-engine/repositories/index.d.ts +2 -0
- package/dist/integration-engine/repositories/index.js +20 -0
- package/dist/integration-engine/repositories/index.js.map +1 -0
- package/dist/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.d.ts +4 -0
- package/dist/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.js +21 -0
- package/dist/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.js.map +1 -0
- package/dist/integration-engine/transformations/MeasurementsTransformation.d.ts +8 -0
- package/dist/integration-engine/transformations/MeasurementsTransformation.js +48 -0
- package/dist/integration-engine/transformations/MeasurementsTransformation.js.map +1 -0
- package/dist/integration-engine/transformations/SensorDevicesTransformation.d.ts +9 -0
- package/dist/integration-engine/transformations/SensorDevicesTransformation.js +41 -0
- package/dist/integration-engine/transformations/SensorDevicesTransformation.js.map +1 -0
- package/dist/integration-engine/workers/MicroclimateWorker.d.ts +5 -0
- package/dist/integration-engine/workers/MicroclimateWorker.js +16 -0
- package/dist/integration-engine/workers/MicroclimateWorker.js.map +1 -0
- package/dist/integration-engine/workers/index.d.ts +2 -0
- package/dist/integration-engine/workers/index.js +6 -0
- package/dist/integration-engine/workers/index.js.map +1 -0
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsByIdTask.d.ts +11 -0
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsByIdTask.js +36 -0
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsByIdTask.js.map +1 -0
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsTask.d.ts +11 -0
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsTask.js +39 -0
- package/dist/integration-engine/workers/tasks/RefreshMeasurementsTask.js.map +1 -0
- package/dist/integration-engine/workers/tasks/RefreshSensorDevicesTask.d.ts +10 -0
- package/dist/integration-engine/workers/tasks/RefreshSensorDevicesTask.js +35 -0
- package/dist/integration-engine/workers/tasks/RefreshSensorDevicesTask.js.map +1 -0
- package/dist/integration-engine/workers/tasks/index.d.ts +3 -0
- package/dist/integration-engine/workers/tasks/index.js +20 -0
- package/dist/integration-engine/workers/tasks/index.js.map +1 -0
- package/dist/schema-definitions/Measurements.d.ts +24 -0
- package/dist/schema-definitions/Measurements.js +8 -0
- package/dist/schema-definitions/Measurements.js.map +1 -0
- package/dist/schema-definitions/SensorDevices.d.ts +10 -0
- package/dist/schema-definitions/SensorDevices.js +8 -0
- package/dist/schema-definitions/SensorDevices.js.map +1 -0
- package/dist/schema-definitions/datasources/MeasurementsJsonSchema.d.ts +29 -0
- package/dist/schema-definitions/datasources/MeasurementsJsonSchema.js +38 -0
- package/dist/schema-definitions/datasources/MeasurementsJsonSchema.js.map +1 -0
- package/dist/schema-definitions/datasources/SensorDevicesJsonSchema.d.ts +14 -0
- package/dist/schema-definitions/datasources/SensorDevicesJsonSchema.js +27 -0
- package/dist/schema-definitions/datasources/SensorDevicesJsonSchema.js.map +1 -0
- package/dist/schema-definitions/index.d.ts +2 -0
- package/dist/schema-definitions/index.js +21 -0
- package/dist/schema-definitions/index.js.map +1 -0
- package/dist/schema-definitions/models/MeasurementsModel.d.ts +22 -0
- package/dist/schema-definitions/models/MeasurementsModel.js +49 -0
- package/dist/schema-definitions/models/MeasurementsModel.js.map +1 -0
- package/dist/schema-definitions/models/SensorDevicesModel.d.ts +11 -0
- package/dist/schema-definitions/models/SensorDevicesModel.js +27 -0
- package/dist/schema-definitions/models/SensorDevicesModel.js.map +1 -0
- package/docs/assets/microclimate_erd.png +0 -0
- package/docs/implementation_documentation.md +282 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Operátor ICT, a.s.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
|
|
11
|
+
Source: http://opensource.org/licenses/MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<p>
|
|
3
|
+
<a href="https://operatorict.cz">
|
|
4
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/core/-/raw/development/.assets/oict_logo.png" alt="oict" width="100px" height="100px" />
|
|
5
|
+
</a>
|
|
6
|
+
<a href="https://golemio.cz">
|
|
7
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/core/-/raw/development/.assets/golemio_logo.png" alt="golemio" width="100px" height="100px" />
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h1>@golemio/microclimate</h1>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
<a href="https://gitlab.com/operator-ict/golemio/code/modules/microclimate/commits/master">
|
|
15
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/microclimate/badges/master/pipeline.svg" alt="pipeline">
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://gitlab.com/operator-ict/golemio/code/modules/microclimate/commits/master">
|
|
18
|
+
<img src="https://gitlab.com/operator-ict/golemio/code/modules/microclimate/badges/master/coverage.svg" alt="coverage">
|
|
19
|
+
</a>
|
|
20
|
+
<a href="./LICENSE">
|
|
21
|
+
<img src="https://img.shields.io/npm/l/@golemio/microclimate" alt="license">
|
|
22
|
+
</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p>
|
|
26
|
+
<a href="#installation">Installation</a> · <a href="./docs">Documentation</a> · <a href="https://operator-ict.gitlab.io/golemio/code/modules/microclimate">TypeDoc</a>
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
This module is intended for use with Golemio services. Refer [here](https://gitlab.com/operator-ict/golemio/code/modules/core/-/blob/development/README.md) for further information on usage, local development and more.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
The APIs may be unstable. Therefore, we recommend to install this module as an exact version.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Latest version
|
|
38
|
+
yarn add --exact @golemio/microclimate@latest
|
|
39
|
+
|
|
40
|
+
# Development version
|
|
41
|
+
yarn add --exact @golemio/microclimate@dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
<!-- ## Description -->
|
|
45
|
+
|
|
46
|
+
<!-- Insert module-specific info here -->
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var dbm;
|
|
4
|
+
var type;
|
|
5
|
+
var seed;
|
|
6
|
+
var fs = require("fs");
|
|
7
|
+
var path = require("path");
|
|
8
|
+
var Promise;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* We receive the dbmigrate dependency from dbmigrate initially.
|
|
12
|
+
* This enables us to not have to rely on NODE_PATH.
|
|
13
|
+
*/
|
|
14
|
+
exports.setup = function (options, seedLink) {
|
|
15
|
+
dbm = options.dbmigrate;
|
|
16
|
+
type = dbm.dataType;
|
|
17
|
+
seed = seedLink;
|
|
18
|
+
Promise = options.Promise;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.up = function (db) {
|
|
22
|
+
var filePath = path.join(__dirname, "sqls", "20221018165642-init-mongo-to-pg-up.sql");
|
|
23
|
+
return new Promise(function (resolve, reject) {
|
|
24
|
+
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
|
|
25
|
+
if (err) return reject(err);
|
|
26
|
+
console.log("received data: " + data);
|
|
27
|
+
|
|
28
|
+
resolve(data);
|
|
29
|
+
});
|
|
30
|
+
}).then(function (data) {
|
|
31
|
+
return db.runSql(data);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.down = function (db) {
|
|
36
|
+
var filePath = path.join(__dirname, "sqls", "20221018165642-init-mongo-to-pg-down.sql");
|
|
37
|
+
return new Promise(function (resolve, reject) {
|
|
38
|
+
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
|
|
39
|
+
if (err) return reject(err);
|
|
40
|
+
console.log("received data: " + data);
|
|
41
|
+
|
|
42
|
+
resolve(data);
|
|
43
|
+
});
|
|
44
|
+
}).then(function (data) {
|
|
45
|
+
return db.runSql(data);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports._meta = {
|
|
50
|
+
version: 1,
|
|
51
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS sensor_devices (
|
|
2
|
+
"whole_name" text NOT NULL,
|
|
3
|
+
"sensor_id" varchar(50) NOT NULL,
|
|
4
|
+
"coordinate_lat" float,
|
|
5
|
+
"coordinate_lng" float,
|
|
6
|
+
|
|
7
|
+
-- audit fields,
|
|
8
|
+
create_batch_id int8,
|
|
9
|
+
created_at timestamptz,
|
|
10
|
+
created_by varchar(150),
|
|
11
|
+
update_batch_id int8,
|
|
12
|
+
updated_at timestamptz,
|
|
13
|
+
updated_by varchar(150),
|
|
14
|
+
|
|
15
|
+
CONSTRAINT sensor_devices_pkey PRIMARY KEY ("sensor_id")
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE TABLE IF NOT EXISTS measurements (
|
|
19
|
+
"sensor_id" varchar(50) NOT NULL,
|
|
20
|
+
"measurement_id" varchar(50) NOT NULL,
|
|
21
|
+
"measured_at" timestamptz NOT NULL,
|
|
22
|
+
"air_temp" float,
|
|
23
|
+
"air_hum" float,
|
|
24
|
+
"pressure" int,
|
|
25
|
+
"wind_dir" varchar(150),
|
|
26
|
+
"wind_speed" float,
|
|
27
|
+
"wind_impact" float,
|
|
28
|
+
"precip" float,
|
|
29
|
+
"sun_irr" int,
|
|
30
|
+
"dendro_circ" float,
|
|
31
|
+
"dendro_gain" float,
|
|
32
|
+
"water_pot" float,
|
|
33
|
+
"soil_temp" float,
|
|
34
|
+
|
|
35
|
+
-- audit fields,
|
|
36
|
+
create_batch_id int8,
|
|
37
|
+
created_at timestamptz,
|
|
38
|
+
created_by varchar(150),
|
|
39
|
+
update_batch_id int8,
|
|
40
|
+
updated_at timestamptz,
|
|
41
|
+
updated_by varchar(150),
|
|
42
|
+
|
|
43
|
+
CONSTRAINT measurements_pkey PRIMARY KEY ("measurement_id")
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DataSource } from "@golemio/core/dist/integration-engine/datasources";
|
|
2
|
+
import { IRefreshMeasurementsByIdTask } from "../../schema-definitions/Measurements";
|
|
3
|
+
export declare class MeasurementsDataSourceFactory {
|
|
4
|
+
static getDataSource(params: IRefreshMeasurementsByIdTask): DataSource;
|
|
5
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MeasurementsDataSourceFactory = void 0;
|
|
4
|
+
const datasources_1 = require("@golemio/core/dist/integration-engine/datasources");
|
|
5
|
+
const config_1 = require("@golemio/core/dist/integration-engine/config");
|
|
6
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
7
|
+
const _sch_1 = require("../../schema-definitions");
|
|
8
|
+
class MeasurementsDataSourceFactory {
|
|
9
|
+
static getDataSource(params) {
|
|
10
|
+
const { sensorAddr,
|
|
11
|
+
// For future FROM-TO implementation:
|
|
12
|
+
// dateFrom,
|
|
13
|
+
// dateTo
|
|
14
|
+
} = params;
|
|
15
|
+
return new datasources_1.DataSource(_sch_1.Microclimate.datasources.measurementsDatasource.name, new datasources_1.HTTPProtocolStrategy({
|
|
16
|
+
headers: { Authorization: "Bearer " + config_1.config.datasources.MicroclimateAgdataCityApikey },
|
|
17
|
+
method: "GET",
|
|
18
|
+
url: `${config_1.config.datasources.MicroclimateAgdataCity}?sensorAddr=${sensorAddr}&dateRange=today`,
|
|
19
|
+
}), new datasources_1.JSONDataTypeStrategy({ resultsPath: "data" }), new golemio_validator_1.JSONSchemaValidator(_sch_1.Microclimate.datasources.measurementsDatasource.name + "Validator", _sch_1.Microclimate.datasources.measurementsDatasource.jsonSchema, true));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.MeasurementsDataSourceFactory = MeasurementsDataSourceFactory;
|
|
23
|
+
//# sourceMappingURL=MeasurementsDataSourceFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeasurementsDataSourceFactory.js","sourceRoot":"","sources":["../../../src/integration-engine/datasources/MeasurementsDataSourceFactory.ts"],"names":[],"mappings":";;;AAAA,mFAA2H;AAC3H,yEAAsE;AACtE,mFAAkF;AAClF,mDAAoC;AAGpC,MAAa,6BAA6B;IAC/B,MAAM,CAAC,aAAa,CAAC,MAAoC;QAC5D,MAAM,EACF,UAAU;QAEV,qCAAqC;QACrC,YAAY;QACZ,SAAS;UACZ,GAAG,MAAM,CAAC;QACX,OAAO,IAAI,wBAAU,CACjB,mBAAY,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,EACpD,IAAI,kCAAoB,CAAC;YACrB,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,GAAG,eAAM,CAAC,WAAW,CAAC,4BAA4B,EAAE;YACvF,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,GAAG,eAAM,CAAC,WAAW,CAAC,sBAAsB,eAAe,UAAU,kBAAkB;SAC/F,CAAC,EACF,IAAI,kCAAoB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EACjD,IAAI,uCAAmB,CACnB,mBAAY,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,GAAG,WAAW,EAClE,mBAAY,CAAC,WAAW,CAAC,sBAAsB,CAAC,UAAU,EAC1D,IAAI,CACP,CACJ,CAAC;IACN,CAAC;CACJ;AAxBD,sEAwBC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SensorDevicesDataSourceFactory = void 0;
|
|
4
|
+
const datasources_1 = require("@golemio/core/dist/integration-engine/datasources");
|
|
5
|
+
const config_1 = require("@golemio/core/dist/integration-engine/config");
|
|
6
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
7
|
+
const _sch_1 = require("../../schema-definitions");
|
|
8
|
+
class SensorDevicesDataSourceFactory {
|
|
9
|
+
static getDataSource() {
|
|
10
|
+
return new datasources_1.DataSource(_sch_1.Microclimate.datasources.sensorDevicesDatasource.name, new datasources_1.HTTPProtocolStrategy({
|
|
11
|
+
headers: { Authorization: "Bearer " + config_1.config.datasources.MicroclimateAgdataCityApikey },
|
|
12
|
+
method: "GET",
|
|
13
|
+
url: config_1.config.datasources.MicroclimateAgdataCity + "/devices",
|
|
14
|
+
}), new datasources_1.JSONDataTypeStrategy({ resultsPath: "data" }), new golemio_validator_1.JSONSchemaValidator(_sch_1.Microclimate.datasources.sensorDevicesDatasource.name + "Validator", _sch_1.Microclimate.datasources.sensorDevicesDatasource.jsonSchema, true));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.SensorDevicesDataSourceFactory = SensorDevicesDataSourceFactory;
|
|
18
|
+
//# sourceMappingURL=SensorDevicesDataSourceFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorDevicesDataSourceFactory.js","sourceRoot":"","sources":["../../../src/integration-engine/datasources/SensorDevicesDataSourceFactory.ts"],"names":[],"mappings":";;;AAAA,mFAA2H;AAC3H,yEAAsE;AACtE,mFAAkF;AAClF,mDAAoC;AAEpC,MAAa,8BAA8B;IAChC,MAAM,CAAC,aAAa;QACvB,OAAO,IAAI,wBAAU,CACjB,mBAAY,CAAC,WAAW,CAAC,uBAAuB,CAAC,IAAI,EACrD,IAAI,kCAAoB,CAAC;YACrB,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,GAAG,eAAM,CAAC,WAAW,CAAC,4BAA4B,EAAE;YACvF,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,eAAM,CAAC,WAAW,CAAC,sBAAsB,GAAG,UAAU;SAC9D,CAAC,EACF,IAAI,kCAAoB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EACjD,IAAI,uCAAmB,CACnB,mBAAY,CAAC,WAAW,CAAC,uBAAuB,CAAC,IAAI,GAAG,WAAW,EACnE,mBAAY,CAAC,WAAW,CAAC,uBAAuB,CAAC,UAAU,EAC3D,IAAI,CACP,CACJ,CAAC;IACN,CAAC;CACJ;AAjBD,wEAiBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { workers } from "./workers";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.workers = void 0;
|
|
4
|
+
/* ie/index.ts */
|
|
5
|
+
var workers_1 = require("./workers");
|
|
6
|
+
Object.defineProperty(exports, "workers", { enumerable: true, get: function () { return workers_1.workers; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integration-engine/index.ts"],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine/models";
|
|
2
|
+
import { IMeasurements } from "../../schema-definitions/Measurements";
|
|
3
|
+
export declare class MeasurementsRepository extends PostgresModel implements IModel {
|
|
4
|
+
constructor();
|
|
5
|
+
saveBulk: (data: IMeasurements[]) => Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MeasurementsRepository = void 0;
|
|
13
|
+
const models_1 = require("@golemio/core/dist/integration-engine/models");
|
|
14
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
15
|
+
const _sch_1 = require("../../schema-definitions");
|
|
16
|
+
const MeasurementsModel_1 = require("../../schema-definitions/models/MeasurementsModel");
|
|
17
|
+
class MeasurementsRepository extends models_1.PostgresModel {
|
|
18
|
+
constructor() {
|
|
19
|
+
super("MeasurementsRepository", {
|
|
20
|
+
outputSequelizeAttributes: MeasurementsModel_1.MeasurementsModel.attributeModel,
|
|
21
|
+
pgTableName: _sch_1.Microclimate.definitions.measurements.pgTableName,
|
|
22
|
+
pgSchema: _sch_1.Microclimate.pgSchema,
|
|
23
|
+
savingType: "insertOrUpdate",
|
|
24
|
+
}, new golemio_validator_1.JSONSchemaValidator("MeasurementsRepositoryValidator", MeasurementsModel_1.MeasurementsModel.jsonSchema));
|
|
25
|
+
this.saveBulk = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
if (data && data.length && (yield this.validate(data))) {
|
|
27
|
+
const fieldsToUpdate = Object.getOwnPropertyNames(data[0])
|
|
28
|
+
.filter((el) => el !== "id")
|
|
29
|
+
.map((el) => el);
|
|
30
|
+
fieldsToUpdate.push("updated_at");
|
|
31
|
+
yield this.sequelizeModel.bulkCreate(data, {
|
|
32
|
+
updateOnDuplicate: fieldsToUpdate,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.MeasurementsRepository = MeasurementsRepository;
|
|
39
|
+
//# sourceMappingURL=MeasurementsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeasurementsRepository.js","sourceRoot":"","sources":["../../../src/integration-engine/repositories/MeasurementsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAqF;AACrF,mFAAkF;AAClF,mDAAoC;AAEpC,yFAAkE;AAElE,MAAa,sBAAuB,SAAQ,sBAAa;IACrD;QACI,KAAK,CACD,wBAAwB,EACxB;YACI,yBAAyB,EAAE,qCAAiB,CAAC,cAAc;YAC3D,WAAW,EAAE,mBAAY,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW;YAC9D,QAAQ,EAAE,mBAAY,CAAC,QAAQ;YAC/B,UAAU,EAAE,gBAAgB;SAC/B,EACD,IAAI,uCAAmB,CAAC,iCAAiC,EAAE,qCAAiB,CAAC,UAAU,CAAC,CAC3F,CAAC;QAGC,aAAQ,GAAG,CAAO,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE;gBACpD,MAAM,cAAc,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;qBACrD,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;qBAC3B,GAAG,CAAsB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAyB,CAAC,CAAC;gBACjE,cAAc,CAAC,IAAI,CAAC,YAAmB,CAAC,CAAC;gBACzC,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAoB,IAAI,EAAE;oBAC1D,iBAAiB,EAAE,cAAc;iBACpC,CAAC,CAAC;aACN;QACL,CAAC,CAAA,CAAC;IAZF,CAAC;CAaJ;AAzBD,wDAyBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine/models";
|
|
2
|
+
import { ISensorDevice } from "../../schema-definitions/SensorDevices";
|
|
3
|
+
export declare class SensorDevicesRepository extends PostgresModel implements IModel {
|
|
4
|
+
constructor();
|
|
5
|
+
saveBulk: (data: ISensorDevice[]) => Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SensorDevicesRepository = void 0;
|
|
13
|
+
const models_1 = require("@golemio/core/dist/integration-engine/models");
|
|
14
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
15
|
+
const _sch_1 = require("../../schema-definitions");
|
|
16
|
+
const SensorDevicesModel_1 = require("../../schema-definitions/models/SensorDevicesModel");
|
|
17
|
+
class SensorDevicesRepository extends models_1.PostgresModel {
|
|
18
|
+
constructor() {
|
|
19
|
+
super("SensorDevicesRepository", {
|
|
20
|
+
outputSequelizeAttributes: SensorDevicesModel_1.SensorDevicesModel.attributeModel,
|
|
21
|
+
pgTableName: _sch_1.Microclimate.definitions.sensorDevices.pgTableName,
|
|
22
|
+
pgSchema: _sch_1.Microclimate.pgSchema,
|
|
23
|
+
savingType: "insertOrUpdate",
|
|
24
|
+
}, new golemio_validator_1.JSONSchemaValidator("SensorDevicesRepositoryValidator", SensorDevicesModel_1.SensorDevicesModel.jsonSchema));
|
|
25
|
+
this.saveBulk = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
if (data && data.length && (yield this.validate(data))) {
|
|
27
|
+
const fieldsToUpdate = Object.getOwnPropertyNames(data[0])
|
|
28
|
+
.filter((el) => el !== "id")
|
|
29
|
+
.map((el) => el);
|
|
30
|
+
fieldsToUpdate.push("updated_at");
|
|
31
|
+
yield this.sequelizeModel.bulkCreate(data, {
|
|
32
|
+
updateOnDuplicate: fieldsToUpdate,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.SensorDevicesRepository = SensorDevicesRepository;
|
|
39
|
+
//# sourceMappingURL=SensorDevicesRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorDevicesRepository.js","sourceRoot":"","sources":["../../../src/integration-engine/repositories/SensorDevicesRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAqF;AACrF,mFAAkF;AAClF,mDAAoC;AAEpC,2FAAoE;AAEpE,MAAa,uBAAwB,SAAQ,sBAAa;IACtD;QACI,KAAK,CACD,yBAAyB,EACzB;YACI,yBAAyB,EAAE,uCAAkB,CAAC,cAAc;YAC5D,WAAW,EAAE,mBAAY,CAAC,WAAW,CAAC,aAAa,CAAC,WAAW;YAC/D,QAAQ,EAAE,mBAAY,CAAC,QAAQ;YAC/B,UAAU,EAAE,gBAAgB;SAC/B,EACD,IAAI,uCAAmB,CAAC,kCAAkC,EAAE,uCAAkB,CAAC,UAAU,CAAC,CAC7F,CAAC;QAGC,aAAQ,GAAG,CAAO,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE;gBACpD,MAAM,cAAc,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;qBACrD,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;qBAC3B,GAAG,CAAsB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAyB,CAAC,CAAC;gBACjE,cAAc,CAAC,IAAI,CAAC,YAAmB,CAAC,CAAC;gBACzC,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAqB,IAAI,EAAE;oBAC3D,iBAAiB,EAAE,cAAc;iBACpC,CAAC,CAAC;aACN;QACL,CAAC,CAAA,CAAC;IAZF,CAAC;CAaJ;AAzBD,0DAyBC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/* ie/repositories/index.ts */
|
|
18
|
+
__exportStar(require("./SensorDevicesRepository"), exports);
|
|
19
|
+
__exportStar(require("./MeasurementsRepository"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integration-engine/repositories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,4DAA0C;AAC1C,2DAAyC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RefreshMeasurementsByIdTaskSchema = void 0;
|
|
13
|
+
const class_validator_1 = require("@golemio/core/dist/shared/class-validator");
|
|
14
|
+
class RefreshMeasurementsByIdTaskSchema {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
(0, class_validator_1.IsString)(),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], RefreshMeasurementsByIdTaskSchema.prototype, "sensorAddr", void 0);
|
|
20
|
+
exports.RefreshMeasurementsByIdTaskSchema = RefreshMeasurementsByIdTaskSchema;
|
|
21
|
+
//# sourceMappingURL=RefreshMeasurementsByIdTaskSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefreshMeasurementsByIdTaskSchema.js","sourceRoot":"","sources":["../../../src/integration-engine/schema/RefreshMeasurementsByIdTaskSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAAgF;AAGhF,MAAa,iCAAiC;CAS7C;AAPG;IADC,IAAA,0BAAQ,GAAE;;qEACS;AAFxB,8EASC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IMeasurementInput } from "../../schema-definitions/datasources/MeasurementsJsonSchema";
|
|
2
|
+
import { IMeasurements } from "../../schema-definitions/Measurements";
|
|
3
|
+
export declare class MeasurementsTransformation {
|
|
4
|
+
name: string;
|
|
5
|
+
constructor();
|
|
6
|
+
transform: (data: IMeasurementInput[], sensor_id: string) => Promise<IMeasurements[]>;
|
|
7
|
+
protected transformElement: (element: IMeasurementInput, sensor_id: string) => Promise<IMeasurements>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MeasurementsTransformation = void 0;
|
|
13
|
+
const Measurements_1 = require("../../schema-definitions/Measurements");
|
|
14
|
+
class MeasurementsTransformation {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.transform = (data, sensor_id) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const measurementsArr = [];
|
|
18
|
+
for (const item of data) {
|
|
19
|
+
const transformedData = yield this.transformElement(item, sensor_id);
|
|
20
|
+
measurementsArr.push(transformedData);
|
|
21
|
+
}
|
|
22
|
+
return measurementsArr;
|
|
23
|
+
});
|
|
24
|
+
this.transformElement = (element, sensor_id) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const res = {
|
|
26
|
+
sensor_id,
|
|
27
|
+
measurement_id: element.id,
|
|
28
|
+
measured_at: element.date,
|
|
29
|
+
air_temp: element.data.airTemp1,
|
|
30
|
+
air_hum: element.data.airHum1,
|
|
31
|
+
pressure: element.data.pressure,
|
|
32
|
+
wind_dir: element.data.windDir,
|
|
33
|
+
wind_speed: element.data.windSpeed,
|
|
34
|
+
wind_impact: element.data.windImpact,
|
|
35
|
+
precip: element.data.volumeMm,
|
|
36
|
+
sun_irr: element.data.irr,
|
|
37
|
+
dendro_circ: element.data.dendroCirc,
|
|
38
|
+
dendro_gain: element.data.dendroGain,
|
|
39
|
+
water_pot: element.data.waterPot,
|
|
40
|
+
soil_temp: element.data.temp1,
|
|
41
|
+
};
|
|
42
|
+
return res;
|
|
43
|
+
});
|
|
44
|
+
this.name = Measurements_1.measurements.name;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.MeasurementsTransformation = MeasurementsTransformation;
|
|
48
|
+
//# sourceMappingURL=MeasurementsTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeasurementsTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/transformations/MeasurementsTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wEAAgE;AAEhE,MAAa,0BAA0B;IAGnC;QAIO,cAAS,GAAG,CAAO,IAAyB,EAAE,SAAiB,EAA4B,EAAE;YAChG,MAAM,eAAe,GAAoB,EAAE,CAAC;YAE5C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;gBACrB,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBACrE,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aACzC;YAED,OAAO,eAAe,CAAC;QAC3B,CAAC,CAAA,CAAC;QAEQ,qBAAgB,GAAG,CAAO,OAA0B,EAAE,SAAiB,EAA0B,EAAE;YACzG,MAAM,GAAG,GAAkB;gBACvB,SAAS;gBACT,cAAc,EAAE,OAAO,CAAC,EAAE;gBAC1B,WAAW,EAAE,OAAO,CAAC,IAAI;gBACzB,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;gBAC/B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;gBAC7B,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;gBAC/B,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;gBAC9B,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS;gBAClC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;gBACpC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;gBAC7B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG;gBACzB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;gBACpC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;gBACpC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;gBAChC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK;aAChC,CAAC;YAEF,OAAO,GAAG,CAAC;QACf,CAAC,CAAA,CAAC;QAlCE,IAAI,CAAC,IAAI,GAAG,2BAAY,CAAC,IAAI,CAAC;IAClC,CAAC;CAkCJ;AAvCD,gEAuCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseTransformation, ITransformation } from "@golemio/core/dist/integration-engine/transformations";
|
|
2
|
+
import { IDeviceInput } from "../../schema-definitions/datasources/SensorDevicesJsonSchema";
|
|
3
|
+
import { ISensorDevice } from "../../schema-definitions/SensorDevices";
|
|
4
|
+
export declare class SensorDevicesTransformation extends BaseTransformation implements ITransformation {
|
|
5
|
+
name: string;
|
|
6
|
+
constructor();
|
|
7
|
+
transform: (data: IDeviceInput[]) => Promise<ISensorDevice[]>;
|
|
8
|
+
protected transformElement: (element: IDeviceInput) => Promise<ISensorDevice>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SensorDevicesTransformation = void 0;
|
|
13
|
+
const transformations_1 = require("@golemio/core/dist/integration-engine/transformations");
|
|
14
|
+
const SensorDevices_1 = require("../../schema-definitions/SensorDevices");
|
|
15
|
+
class SensorDevicesTransformation extends transformations_1.BaseTransformation {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.transform = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const devices = [];
|
|
20
|
+
for (const item of data) {
|
|
21
|
+
const transformedData = yield this.transformElement(item);
|
|
22
|
+
devices.push(transformedData);
|
|
23
|
+
}
|
|
24
|
+
return devices;
|
|
25
|
+
});
|
|
26
|
+
this.transformElement = (element) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const res = {
|
|
28
|
+
whole_name: element.name,
|
|
29
|
+
sensor_id: element.address,
|
|
30
|
+
};
|
|
31
|
+
if (element.location.lat && element.location.lng) {
|
|
32
|
+
res.coordinate_lat = element.location.lat;
|
|
33
|
+
res.coordinate_lng = element.location.lng;
|
|
34
|
+
}
|
|
35
|
+
return res;
|
|
36
|
+
});
|
|
37
|
+
this.name = SensorDevices_1.sensorDevices.name;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.SensorDevicesTransformation = SensorDevicesTransformation;
|
|
41
|
+
//# sourceMappingURL=SensorDevicesTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorDevicesTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/transformations/SensorDevicesTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2FAA4G;AAE5G,0EAAkE;AAElE,MAAa,2BAA4B,SAAQ,oCAAkB;IAG/D;QACI,KAAK,EAAE,CAAC;QAIL,cAAS,GAAG,CAAO,IAAoB,EAA4B,EAAE;YACxE,MAAM,OAAO,GAAoB,EAAE,CAAC;YAEpC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;gBACrB,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBAC1D,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aACjC;YAED,OAAO,OAAO,CAAC;QACnB,CAAC,CAAA,CAAC;QAEQ,qBAAgB,GAAG,CAAO,OAAqB,EAA0B,EAAE;YACjF,MAAM,GAAG,GAAkB;gBACvB,UAAU,EAAE,OAAO,CAAC,IAAI;gBACxB,SAAS,EAAE,OAAO,CAAC,OAAO;aAC7B,CAAC;YAEF,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;gBAC9C,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAC1C,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;aAC7C;YAED,OAAO,GAAG,CAAC;QACf,CAAC,CAAA,CAAC;QA1BE,IAAI,CAAC,IAAI,GAAG,6BAAa,CAAC,IAAI,CAAC;IACnC,CAAC;CA0BJ;AAhCD,kEAgCC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MicroclimateWorker = void 0;
|
|
4
|
+
const workers_1 = require("@golemio/core/dist/integration-engine/workers");
|
|
5
|
+
const tasks_1 = require("./tasks");
|
|
6
|
+
class MicroclimateWorker extends workers_1.AbstractWorker {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.name = "Microclimate";
|
|
10
|
+
this.registerTask(new tasks_1.RefreshSensorDevicesTask(this.getQueuePrefix()));
|
|
11
|
+
this.registerTask(new tasks_1.RefreshMeasurementsTask(this.getQueuePrefix()));
|
|
12
|
+
this.registerTask(new tasks_1.RefreshMeasurementsByIdTask(this.getQueuePrefix()));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.MicroclimateWorker = MicroclimateWorker;
|
|
16
|
+
//# sourceMappingURL=MicroclimateWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MicroclimateWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/MicroclimateWorker.ts"],"names":[],"mappings":";;;AAAA,2EAA+E;AAC/E,mCAAyG;AAEzG,MAAa,kBAAmB,SAAQ,wBAAc;IAGlD;QACI,KAAK,EAAE,CAAC;QAHO,SAAI,GAAG,cAAc,CAAC;QAIrC,IAAI,CAAC,YAAY,CAAC,IAAI,gCAAwB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,YAAY,CAAC,IAAI,+BAAuB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,YAAY,CAAC,IAAI,mCAA2B,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;CACJ;AATD,gDASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/index.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAE7C,QAAA,OAAO,GAAG,CAAC,uCAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AbstractTask } from "@golemio/core/dist/integration-engine";
|
|
2
|
+
import { IRefreshMeasurementsByIdTask } from "../../../schema-definitions/Measurements";
|
|
3
|
+
import { RefreshMeasurementsByIdTaskSchema } from "../../schema/RefreshMeasurementsByIdTaskSchema";
|
|
4
|
+
export declare class RefreshMeasurementsByIdTask extends AbstractTask<IRefreshMeasurementsByIdTask> {
|
|
5
|
+
readonly queueName = "refreshMeasurementsById";
|
|
6
|
+
readonly schema: typeof RefreshMeasurementsByIdTaskSchema;
|
|
7
|
+
private transformation;
|
|
8
|
+
private repository;
|
|
9
|
+
constructor(queuePrefix: string);
|
|
10
|
+
protected execute(msg: IRefreshMeasurementsByIdTask): Promise<void>;
|
|
11
|
+
}
|