@golemio/chmu 1.0.0-dev.718082295 → 1.0.0-dev.776186639
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 +6 -2
- package/db/example/initial.sql +0 -0
- package/db/migrations/postgresql/20230209101749-measurements.js +53 -0
- package/db/migrations/postgresql/sqls/20230209101749-measurements-down.sql +1 -0
- package/db/migrations/postgresql/sqls/20230209101749-measurements-up.sql +25 -0
- package/dist/const.d.ts +2 -0
- package/dist/const.js +6 -0
- package/dist/const.js.map +1 -0
- package/dist/integration-engine/data-access/MeasurementsRepository.d.ts +7 -0
- package/dist/integration-engine/data-access/MeasurementsRepository.js +53 -0
- package/dist/integration-engine/data-access/MeasurementsRepository.js.map +1 -0
- package/dist/integration-engine/datasources/ChmuDatasource.d.ts +16 -0
- package/dist/integration-engine/datasources/ChmuDatasource.js +70 -0
- package/dist/integration-engine/datasources/ChmuDatasource.js.map +1 -0
- package/dist/integration-engine/index.d.ts +1 -0
- package/dist/integration-engine/index.js +19 -0
- package/dist/integration-engine/index.js.map +1 -0
- package/dist/integration-engine/ioc/Di.d.ts +3 -0
- package/dist/integration-engine/ioc/Di.js +28 -0
- package/dist/integration-engine/ioc/Di.js.map +1 -0
- package/dist/integration-engine/ioc/ModuleContainerToken.d.ts +7 -0
- package/dist/integration-engine/ioc/ModuleContainerToken.js +11 -0
- package/dist/integration-engine/ioc/ModuleContainerToken.js.map +1 -0
- package/dist/integration-engine/transformations/MeasurementsTransformation.d.ts +8 -0
- package/dist/integration-engine/transformations/MeasurementsTransformation.js +46 -0
- package/dist/integration-engine/transformations/MeasurementsTransformation.js.map +1 -0
- package/dist/integration-engine/workers/ChmuWorker.d.ts +6 -0
- package/dist/integration-engine/workers/ChmuWorker.js +21 -0
- package/dist/integration-engine/workers/ChmuWorker.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/interfaces/IDownloadMeasurementsMessage.d.ts +4 -0
- package/dist/integration-engine/workers/interfaces/IDownloadMeasurementsMessage.js +3 -0
- package/dist/integration-engine/workers/interfaces/IDownloadMeasurementsMessage.js.map +1 -0
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsMessageSchema.d.ts +5 -0
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsMessageSchema.js +29 -0
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsMessageSchema.js.map +1 -0
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsTask.d.ts +21 -0
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsTask.js +108 -0
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsTask.js.map +1 -0
- package/dist/schema-definitions/datasources/ChmuSchemaProvider.d.ts +57 -0
- package/dist/schema-definitions/datasources/ChmuSchemaProvider.js +49 -0
- package/dist/schema-definitions/datasources/ChmuSchemaProvider.js.map +1 -0
- package/dist/schema-definitions/datasources/interfaces/IInputChmuData.d.ts +17 -0
- package/dist/schema-definitions/datasources/interfaces/IInputChmuData.js +3 -0
- package/dist/schema-definitions/datasources/interfaces/IInputChmuData.js.map +1 -0
- package/dist/schema-definitions/definitions/interfaces/IMeasurementDto.d.ts +18 -0
- package/dist/schema-definitions/definitions/interfaces/IMeasurementDto.js +3 -0
- package/dist/schema-definitions/definitions/interfaces/IMeasurementDto.js.map +1 -0
- package/dist/schema-definitions/definitions/models/MeasurementModel.d.ts +23 -0
- package/dist/schema-definitions/definitions/models/MeasurementModel.js +51 -0
- package/dist/schema-definitions/definitions/models/MeasurementModel.js.map +1 -0
- package/package.json +50 -3
package/README.md
CHANGED
|
@@ -35,12 +35,16 @@ The APIs may be unstable. Therefore, we recommend to install this module as an e
|
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
37
|
# Latest version
|
|
38
|
-
|
|
38
|
+
npm install --save-exact @golemio/chmu@latest
|
|
39
39
|
|
|
40
40
|
# Development version
|
|
41
|
-
|
|
41
|
+
npm install --save-exact @golemio/chmu@dev
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
<!-- ## Description -->
|
|
45
45
|
|
|
46
46
|
<!-- Insert module-specific info here -->
|
|
47
|
+
|
|
48
|
+
## History Update
|
|
49
|
+
|
|
50
|
+
It is posible to use queue `chmu.downloadMeasurementsTask` with params `from` and `to` in iso format. Automated task will create subtasks to import data trough selected time range.
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
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', '20230209101749-measurements-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
|
+
})
|
|
31
|
+
.then(function(data) {
|
|
32
|
+
return db.runSql(data);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.down = function(db) {
|
|
37
|
+
var filePath = path.join(__dirname, 'sqls', '20230209101749-measurements-down.sql');
|
|
38
|
+
return new Promise( function( resolve, reject ) {
|
|
39
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
40
|
+
if (err) return reject(err);
|
|
41
|
+
console.log('received data: ' + data);
|
|
42
|
+
|
|
43
|
+
resolve(data);
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
.then(function(data) {
|
|
47
|
+
return db.runSql(data);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports._meta = {
|
|
52
|
+
"version": 1
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DROP TABLE measurements;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
CREATE TABLE measurements (
|
|
2
|
+
"measured_at" timestamp without time zone NOT NULL,
|
|
3
|
+
"station_id" varchar NOT NULL,
|
|
4
|
+
"year" int NOT NULL,
|
|
5
|
+
"month" int NOT NULL,
|
|
6
|
+
"day" int NOT NULL,
|
|
7
|
+
"time" time NOT NULL,
|
|
8
|
+
"air_temp" varchar NULL,
|
|
9
|
+
"air_hum" varchar NULL,
|
|
10
|
+
"precip" varchar NULL,
|
|
11
|
+
"air_pressure" varchar NULL,
|
|
12
|
+
"wind_speed" varchar NULL,
|
|
13
|
+
"wind_dir" varchar NULL,
|
|
14
|
+
"sunlight" varchar NULL,
|
|
15
|
+
"soil_hum_0_10" int NULL,
|
|
16
|
+
"soil_hum_10_50" int NULL,
|
|
17
|
+
"soil_hum_50_100" int NULL,
|
|
18
|
+
"create_batch_id" int8 null,
|
|
19
|
+
"created_at" timestamptz null,
|
|
20
|
+
"created_by" varchar(150) null,
|
|
21
|
+
"update_batch_id" int8 null,
|
|
22
|
+
"updated_at" timestamptz null,
|
|
23
|
+
"updated_by" varchar(150) null,
|
|
24
|
+
CONSTRAINT measurements_pk PRIMARY KEY ("measured_at","station_id")
|
|
25
|
+
);
|
package/dist/const.d.ts
ADDED
package/dist/const.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,MAAM,CAAC;AACrB,QAAA,WAAW,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine";
|
|
2
|
+
import { IMeasurementDto } from "../../schema-definitions/definitions/interfaces/IMeasurementDto";
|
|
3
|
+
export declare class MeasurementsRepository extends PostgresModel implements IModel {
|
|
4
|
+
constructor();
|
|
5
|
+
bulkUpdate: (data: IMeasurementDto[]) => Promise<void>;
|
|
6
|
+
private getUpdateAttributes;
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.MeasurementsRepository = void 0;
|
|
22
|
+
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
23
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
24
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
25
|
+
const const_1 = require("../../const");
|
|
26
|
+
const MeasurementModel_1 = require("../../schema-definitions/definitions/models/MeasurementModel");
|
|
27
|
+
let MeasurementsRepository = class MeasurementsRepository extends integration_engine_1.PostgresModel {
|
|
28
|
+
constructor() {
|
|
29
|
+
super("ChmuMeasurementsRepository", {
|
|
30
|
+
outputSequelizeAttributes: MeasurementModel_1.MeasurementModel.attributeModel,
|
|
31
|
+
pgTableName: "measurements",
|
|
32
|
+
pgSchema: const_1.SCHEMA_NAME,
|
|
33
|
+
savingType: "insertOrUpdate",
|
|
34
|
+
}, new golemio_validator_1.JSONSchemaValidator("ChmuMeasurementsValidator", MeasurementModel_1.MeasurementModel.jsonSchema));
|
|
35
|
+
this.bulkUpdate = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
yield this.validate(data);
|
|
37
|
+
yield this.sequelizeModel.bulkCreate(data, {
|
|
38
|
+
updateOnDuplicate: this.getUpdateAttributes(),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
this.getUpdateAttributes = () => {
|
|
42
|
+
return Object.keys(MeasurementModel_1.MeasurementModel.attributeModel)
|
|
43
|
+
.filter((att) => !["vendor_id", "pick_at"].includes(att))
|
|
44
|
+
.concat("updated_at");
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
MeasurementsRepository = __decorate([
|
|
49
|
+
(0, tsyringe_1.injectable)(),
|
|
50
|
+
__metadata("design:paramtypes", [])
|
|
51
|
+
], MeasurementsRepository);
|
|
52
|
+
exports.MeasurementsRepository = MeasurementsRepository;
|
|
53
|
+
//# sourceMappingURL=MeasurementsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeasurementsRepository.js","sourceRoot":"","sources":["../../../src/integration-engine/data-access/MeasurementsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAA8E;AAC9E,mFAAkF;AAClF,iEAAgE;AAChE,uCAAwC;AAExC,mGAAgG;AAGhG,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,kCAAa;IACrD;QACI,KAAK,CACD,4BAA4B,EAC5B;YACI,yBAAyB,EAAE,mCAAgB,CAAC,cAAc;YAC1D,WAAW,EAAE,cAAc;YAC3B,QAAQ,EAAE,mBAAW;YACrB,UAAU,EAAE,gBAAgB;SAC/B,EACD,IAAI,uCAAmB,CAAC,2BAA2B,EAAE,mCAAgB,CAAC,UAAU,CAAC,CACpF,CAAC;QAGC,eAAU,GAAG,CAAO,IAAuB,EAAE,EAAE;YAClD,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1B,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAmB,IAAI,EAAE;gBACzD,iBAAiB,EAAE,IAAI,CAAC,mBAAmB,EAAE;aAChD,CAAC,CAAC;QACP,CAAC,CAAA,CAAC;QAEM,wBAAmB,GAAG,GAAG,EAAE;YAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,mCAAgB,CAAC,cAAc,CAAC;iBAC9C,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;iBACxD,MAAM,CAAC,YAAY,CAAiC,CAAC;QAC9D,CAAC,CAAC;IAbF,CAAC;CAcJ,CAAA;AA1BY,sBAAsB;IADlC,IAAA,qBAAU,GAAE;;GACA,sBAAsB,CA0BlC;AA1BY,wDAAsB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IntegrationEngineConfiguration } from "@golemio/core/dist/integration-engine/config/IntegrationEngineConfiguration";
|
|
2
|
+
import IInputChmuData from "../../schema-definitions/datasources/interfaces/IInputChmuData";
|
|
3
|
+
export default class ChmuDatasource {
|
|
4
|
+
private readonly config;
|
|
5
|
+
name: string;
|
|
6
|
+
private readonly INPUT_ENCODING;
|
|
7
|
+
constructor(config: IntegrationEngineConfiguration);
|
|
8
|
+
getData(date?: Date): Promise<{
|
|
9
|
+
data: IInputChmuData[];
|
|
10
|
+
filepath: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}>;
|
|
13
|
+
private getCurrentDatasource;
|
|
14
|
+
private getConfiguration;
|
|
15
|
+
private generateFileName;
|
|
16
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
19
|
+
const IntegrationEngineConfiguration_1 = require("@golemio/core/dist/integration-engine/config/IntegrationEngineConfiguration");
|
|
20
|
+
const ContainerToken_1 = require("@golemio/core/dist/integration-engine/ioc/ContainerToken");
|
|
21
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
22
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
23
|
+
const ChmuSchemaProvider_1 = __importDefault(require("../../schema-definitions/datasources/ChmuSchemaProvider"));
|
|
24
|
+
let ChmuDatasource = class ChmuDatasource {
|
|
25
|
+
constructor(config) {
|
|
26
|
+
this.config = config;
|
|
27
|
+
this.name = "ChmuDatasource";
|
|
28
|
+
this.INPUT_ENCODING = "utf8";
|
|
29
|
+
}
|
|
30
|
+
getData(date = new Date()) {
|
|
31
|
+
const result = this.getCurrentDatasource(date).getAll();
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
getCurrentDatasource(date) {
|
|
35
|
+
return new integration_engine_1.DataSource("ChmuFtpDataSource", new integration_engine_1.FTPProtocolStrategy(this.getConfiguration(date)), new integration_engine_1.CSVDataTypeStrategy({
|
|
36
|
+
fastcsvParams: { delimiter: ";", headers: true },
|
|
37
|
+
subscribe: (json) => json,
|
|
38
|
+
}), new golemio_validator_1.JSONSchemaValidator("ChmuFtpDataSourceValidator", ChmuSchemaProvider_1.default.get()));
|
|
39
|
+
}
|
|
40
|
+
getConfiguration(date) {
|
|
41
|
+
return {
|
|
42
|
+
filename: this.generateFileName(date),
|
|
43
|
+
path: this.config.datasources.chmu.ftpInput.path,
|
|
44
|
+
url: {
|
|
45
|
+
host: this.config.datasources.chmu.ftpInput.host,
|
|
46
|
+
port: this.config.datasources.chmu.ftpInput.port,
|
|
47
|
+
user: this.config.datasources.chmu.ftpInput.user,
|
|
48
|
+
password: this.config.datasources.chmu.ftpInput.password,
|
|
49
|
+
},
|
|
50
|
+
encoding: this.INPUT_ENCODING,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
generateFileName(date) {
|
|
54
|
+
const [year, month, day, hour] = [
|
|
55
|
+
date.getFullYear(),
|
|
56
|
+
(date.getMonth() + 1).toString().padStart(2, "0"),
|
|
57
|
+
date.getDate().toString().padStart(2, "0"),
|
|
58
|
+
date.getHours().toString().padStart(2, "0"),
|
|
59
|
+
];
|
|
60
|
+
//expected filename 6443_YYYYMMDDHH.txt
|
|
61
|
+
return `6443_${year}${month}${day}${hour}.txt`;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
ChmuDatasource = __decorate([
|
|
65
|
+
(0, tsyringe_1.injectable)(),
|
|
66
|
+
__param(0, (0, tsyringe_1.inject)(ContainerToken_1.ContainerToken.Config)),
|
|
67
|
+
__metadata("design:paramtypes", [IntegrationEngineConfiguration_1.IntegrationEngineConfiguration])
|
|
68
|
+
], ChmuDatasource);
|
|
69
|
+
exports.default = ChmuDatasource;
|
|
70
|
+
//# sourceMappingURL=ChmuDatasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChmuDatasource.js","sourceRoot":"","sources":["../../../src/integration-engine/datasources/ChmuDatasource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8EAA2H;AAC3H,gIAA6H;AAC7H,6FAA0F;AAC1F,mFAAkF;AAClF,iEAAwE;AACxE,iHAAyF;AAIzF,IAAqB,cAAc,GAAnC,MAAqB,cAAc;IAI/B,YAA4D,MAAsC;QAAtC,WAAM,GAAN,MAAM,CAAgC;QAH3F,SAAI,GAAG,gBAAgB,CAAC;QACd,mBAAc,GAAG,MAAM,CAAC;IAE4D,CAAC;IAE/F,OAAO,CAAC,OAAa,IAAI,IAAI,EAAE;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,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IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;YACjD,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;YAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;SAC9C,CAAC;QAEF,uCAAuC;QACvC,OAAO,QAAQ,IAAI,GAAG,KAAK,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC;IACnD,CAAC;CACJ,CAAA;AAjDoB,cAAc;IADlC,IAAA,qBAAU,GAAE;IAKI,WAAA,IAAA,iBAAM,EAAC,+BAAc,CAAC,MAAM,CAAC,CAAA;qCAA0B,+DAA8B;GAJjF,cAAc,CAiDlC;kBAjDoB,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./workers";
|
|
@@ -0,0 +1,19 @@
|
|
|
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/index.ts */
|
|
18
|
+
__exportStar(require("./workers"), exports);
|
|
19
|
+
//# 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,4CAA0B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ChmuContainer = void 0;
|
|
7
|
+
const MeasurementsRepository_1 = require("../data-access/MeasurementsRepository");
|
|
8
|
+
const Di_1 = require("@golemio/core/dist/integration-engine/ioc/Di");
|
|
9
|
+
const ChmuDatasource_1 = __importDefault(require("../datasources/ChmuDatasource"));
|
|
10
|
+
const MeasurementsTransformation_1 = require("../transformations/MeasurementsTransformation");
|
|
11
|
+
const DownloadMeasurementsTask_1 = __importDefault(require("../workers/tasks/DownloadMeasurementsTask"));
|
|
12
|
+
const ModuleContainerToken_1 = require("./ModuleContainerToken");
|
|
13
|
+
//#region Initialization
|
|
14
|
+
const ChmuContainer = Di_1.IntegrationEngineContainer.createChildContainer();
|
|
15
|
+
exports.ChmuContainer = ChmuContainer;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region Datasources
|
|
18
|
+
ChmuContainer.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.ChmuDatasource, ChmuDatasource_1.default);
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region Transformations
|
|
21
|
+
ChmuContainer.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.MeasurementsTransformation, MeasurementsTransformation_1.MeasurementsTransformation);
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region Repositories
|
|
24
|
+
ChmuContainer.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.MeasurementsRepository, MeasurementsRepository_1.MeasurementsRepository);
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region WorkerTasks
|
|
27
|
+
ChmuContainer.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.DownloadMeasurementsTask, DownloadMeasurementsTask_1.default);
|
|
28
|
+
//# sourceMappingURL=Di.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/Di.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAgF;AAChF,qEAA0F;AAC1F,mFAA4D;AAC5D,8FAA4F;AAC5F,yGAAkF;AAElF,iEAA8D;AAE9D,wBAAwB;AACxB,MAAM,aAAa,GAAwB,+BAA0B,CAAC,oBAAoB,EAAE,CAAC;AAmBpF,sCAAa;AAlBtB,YAAY;AAEZ,qBAAqB;AACrB,aAAa,CAAC,iBAAiB,CAAC,2CAAoB,CAAC,cAAc,EAAE,wBAAc,CAAC,CAAC;AACrF,YAAY;AAEZ,yBAAyB;AACzB,aAAa,CAAC,iBAAiB,CAAC,2CAAoB,CAAC,0BAA0B,EAAE,uDAA0B,CAAC,CAAC;AAC7G,YAAY;AAEZ,sBAAsB;AACtB,aAAa,CAAC,iBAAiB,CAAC,2CAAoB,CAAC,sBAAsB,EAAE,+CAAsB,CAAC,CAAC;AACrG,YAAY;AAEZ,qBAAqB;AACrB,aAAa,CAAC,iBAAiB,CAAC,2CAAoB,CAAC,wBAAwB,EAAE,kCAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModuleContainerToken = void 0;
|
|
4
|
+
const ModuleContainerToken = {
|
|
5
|
+
ChmuDatasource: Symbol(),
|
|
6
|
+
MeasurementsRepository: Symbol(),
|
|
7
|
+
MeasurementsTransformation: Symbol(),
|
|
8
|
+
DownloadMeasurementsTask: Symbol(),
|
|
9
|
+
};
|
|
10
|
+
exports.ModuleContainerToken = ModuleContainerToken;
|
|
11
|
+
//# sourceMappingURL=ModuleContainerToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleContainerToken.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/ModuleContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG;IACzB,cAAc,EAAE,MAAM,EAAE;IACxB,sBAAsB,EAAE,MAAM,EAAE;IAChC,0BAA0B,EAAE,MAAM,EAAE;IACpC,wBAAwB,EAAE,MAAM,EAAE;CACrC,CAAC;AAEO,oDAAoB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import IInputChmuData from "../../schema-definitions/datasources/interfaces/IInputChmuData";
|
|
2
|
+
import { BaseTransformation, ITransformation } from "@golemio/core/dist/integration-engine";
|
|
3
|
+
import { IMeasurementDto } from "../../schema-definitions/definitions/interfaces/IMeasurementDto";
|
|
4
|
+
export declare class MeasurementsTransformation extends BaseTransformation implements ITransformation {
|
|
5
|
+
name: string;
|
|
6
|
+
constructor();
|
|
7
|
+
protected transformElement: (element: IInputChmuData) => IMeasurementDto;
|
|
8
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.MeasurementsTransformation = void 0;
|
|
13
|
+
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
14
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
15
|
+
let MeasurementsTransformation = class MeasurementsTransformation extends integration_engine_1.BaseTransformation {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.name = "MeasurementsTransformation";
|
|
19
|
+
this.transformElement = (element) => {
|
|
20
|
+
return {
|
|
21
|
+
measured_at: `${element.YEAR}-${element.MONTH}-${element.DAY}T${element.TIME}:00`,
|
|
22
|
+
station_id: element.EG_GH_ID,
|
|
23
|
+
year: Number.parseInt(element.YEAR),
|
|
24
|
+
month: Number.parseInt(element.MONTH),
|
|
25
|
+
day: Number.parseInt(element.DAY),
|
|
26
|
+
time: element.TIME,
|
|
27
|
+
air_temp: element.T.length > 0 ? element.T.replace(",", ".") : null,
|
|
28
|
+
air_hum: element.H.length > 0 ? element.H.replace(",", ".") : null,
|
|
29
|
+
precip: element.SRA1H.length > 0 ? element.SRA1H.replace(",", ".") : null,
|
|
30
|
+
air_pressure: element.P.length > 0 ? element.P.replace(",", ".") : null,
|
|
31
|
+
wind_speed: element.F.length > 0 ? element.F.replace(",", ".") : null,
|
|
32
|
+
wind_dir: element.D.length > 0 ? element.D.replace(",", ".") : null,
|
|
33
|
+
sunlight: element.SSV1H.length > 0 ? element.SSV1H.replace(",", ".") : null,
|
|
34
|
+
soil_hum_0_10: element.HPU1.length > 0 ? Number(element.HPU1) : null,
|
|
35
|
+
soil_hum_10_50: element.HPU2.length > 0 ? Number(element.HPU2) : null,
|
|
36
|
+
soil_hum_50_100: element.HPU3.length > 0 ? Number(element.HPU3) : null,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
MeasurementsTransformation = __decorate([
|
|
42
|
+
(0, tsyringe_1.injectable)(),
|
|
43
|
+
__metadata("design:paramtypes", [])
|
|
44
|
+
], MeasurementsTransformation);
|
|
45
|
+
exports.MeasurementsTransformation = MeasurementsTransformation;
|
|
46
|
+
//# sourceMappingURL=MeasurementsTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeasurementsTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/transformations/MeasurementsTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,8EAA4F;AAC5F,iEAAgE;AAIhE,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,uCAAkB;IAG9D;QACI,KAAK,EAAE,CAAC;QAHL,SAAI,GAAG,4BAA4B,CAAC;QAMjC,qBAAgB,GAAG,CAAC,OAAuB,EAAmB,EAAE;YACtE,OAAO;gBACH,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK;gBACjF,UAAU,EAAE,OAAO,CAAC,QAAQ;gBAC5B,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;gBACnC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;gBACrC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC;gBACjC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI;gBACnE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAA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AAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;aACzE,CAAC;QACN,CAAC,CAAC;IArBF,CAAC;CAsBJ,CAAA;AA3BY,0BAA0B;IADtC,IAAA,qBAAU,GAAE;;GACA,0BAA0B,CA2BtC;AA3BY,gEAA0B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChmuWorker = void 0;
|
|
4
|
+
const Di_1 = require("../ioc/Di");
|
|
5
|
+
const ModuleContainerToken_1 = require("../ioc/ModuleContainerToken");
|
|
6
|
+
const workers_1 = require("@golemio/core/dist/integration-engine/workers");
|
|
7
|
+
const const_1 = require("../../const");
|
|
8
|
+
class ChmuWorker extends workers_1.AbstractWorker {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.name = const_1.MODULE_NAME;
|
|
12
|
+
this.registerTask = (task) => {
|
|
13
|
+
super.registerTask(task);
|
|
14
|
+
task.queuePrefix = this.getQueuePrefix();
|
|
15
|
+
};
|
|
16
|
+
// Register tasks
|
|
17
|
+
this.registerTask(Di_1.ChmuContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.DownloadMeasurementsTask));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ChmuWorker = ChmuWorker;
|
|
21
|
+
//# sourceMappingURL=ChmuWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChmuWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/ChmuWorker.ts"],"names":[],"mappings":";;;AAAA,kCAA2C;AAC3C,sEAAoE;AACpE,2EAA6F;AAC7F,uCAAwC;AAGxC,MAAa,UAAW,SAAQ,wBAAc;IAG1C;QACI,KAAK,EAAE,CAAC;QAHF,SAAI,GAAG,mBAAW,CAAC;QAStB,iBAAY,GAAG,CAAC,IAAuB,EAAQ,EAAE;YACpD,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,CAAC,CAAC;QAPE,iBAAiB;QACjB,IAAI,CAAC,YAAY,CAAC,kBAAa,CAAC,OAAO,CAA2B,2CAAoB,CAAC,wBAAwB,CAAC,CAAC,CAAC;IACtH,CAAC;CAMJ;AAdD,gCAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE7B,QAAA,OAAO,GAAG,CAAC,uBAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDownloadMeasurementsMessage.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/interfaces/IDownloadMeasurementsMessage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
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.DownloadMeasurementsMessageSchema = void 0;
|
|
13
|
+
const class_validator_1 = require("@golemio/core/dist/shared/class-validator");
|
|
14
|
+
class DownloadMeasurementsMessageSchema {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
(0, class_validator_1.IsOptional)(),
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsISO8601)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], DownloadMeasurementsMessageSchema.prototype, "from", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsOptional)(),
|
|
24
|
+
(0, class_validator_1.IsString)(),
|
|
25
|
+
(0, class_validator_1.IsISO8601)(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], DownloadMeasurementsMessageSchema.prototype, "to", void 0);
|
|
28
|
+
exports.DownloadMeasurementsMessageSchema = DownloadMeasurementsMessageSchema;
|
|
29
|
+
//# sourceMappingURL=DownloadMeasurementsMessageSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadMeasurementsMessageSchema.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadMeasurementsMessageSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAA4F;AAG5F,MAAa,iCAAiC;CAS7C;AALG;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,GAAE;;+DACE;AAId;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,GAAE;;6DACA;AARhB,8EASC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MeasurementsRepository } from "../../data-access/MeasurementsRepository";
|
|
2
|
+
import ChmuDatasource from "../../datasources/ChmuDatasource";
|
|
3
|
+
import { MeasurementsTransformation } from "../../transformations/MeasurementsTransformation";
|
|
4
|
+
import { ILogger } from "@golemio/core/dist/helpers/logger/LoggerProvider";
|
|
5
|
+
import { AbstractTask } from "@golemio/core/dist/integration-engine";
|
|
6
|
+
import IDownloadMeasurementsMessage from "../interfaces/IDownloadMeasurementsMessage";
|
|
7
|
+
import { DownloadMeasurementsMessageSchema } from "./DownloadMeasurementsMessageSchema";
|
|
8
|
+
export default class DownloadMeasurementsTask extends AbstractTask<IDownloadMeasurementsMessage> {
|
|
9
|
+
private datasource;
|
|
10
|
+
private transformation;
|
|
11
|
+
private repository;
|
|
12
|
+
private logger;
|
|
13
|
+
queueName: string;
|
|
14
|
+
protected schema: typeof DownloadMeasurementsMessageSchema;
|
|
15
|
+
constructor(datasource: ChmuDatasource, transformation: MeasurementsTransformation, repository: MeasurementsRepository, logger: ILogger);
|
|
16
|
+
protected execute: (data: IDownloadMeasurementsMessage) => Promise<void>;
|
|
17
|
+
private downloadData;
|
|
18
|
+
private generateSubTasks;
|
|
19
|
+
private normalizeInput;
|
|
20
|
+
private generateIntervals;
|
|
21
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const MeasurementsRepository_1 = require("../../data-access/MeasurementsRepository");
|
|
28
|
+
const ChmuDatasource_1 = __importDefault(require("../../datasources/ChmuDatasource"));
|
|
29
|
+
const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
|
|
30
|
+
const MeasurementsTransformation_1 = require("../../transformations/MeasurementsTransformation");
|
|
31
|
+
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
32
|
+
const ContainerToken_1 = require("@golemio/core/dist/integration-engine/ioc/ContainerToken");
|
|
33
|
+
const QueueManager_1 = require("@golemio/core/dist/integration-engine/queueprocessors/QueueManager");
|
|
34
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
35
|
+
const luxon_1 = require("@golemio/core/dist/shared/luxon");
|
|
36
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
37
|
+
const DownloadMeasurementsMessageSchema_1 = require("./DownloadMeasurementsMessageSchema");
|
|
38
|
+
let DownloadMeasurementsTask = class DownloadMeasurementsTask extends integration_engine_1.AbstractTask {
|
|
39
|
+
constructor(datasource, transformation, repository, logger) {
|
|
40
|
+
super(""); // done in worker
|
|
41
|
+
this.datasource = datasource;
|
|
42
|
+
this.transformation = transformation;
|
|
43
|
+
this.repository = repository;
|
|
44
|
+
this.logger = logger;
|
|
45
|
+
this.queueName = "downloadMeasurementsTask";
|
|
46
|
+
this.schema = DownloadMeasurementsMessageSchema_1.DownloadMeasurementsMessageSchema;
|
|
47
|
+
this.execute = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const { from, to } = this.normalizeInput(data);
|
|
49
|
+
if (from.equals(to)) {
|
|
50
|
+
yield this.downloadData(from.toJSDate());
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
yield this.generateSubTasks(from, to);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
this.generateSubTasks = (from, to) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const intervals = this.generateIntervals(from, to);
|
|
58
|
+
for (const interval of intervals) {
|
|
59
|
+
yield QueueManager_1.QueueManager.sendMessageToExchange(this.queuePrefix, this.queueName, {
|
|
60
|
+
from: interval.toISO(),
|
|
61
|
+
to: interval.toISO(),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.generateIntervals = (from, to) => {
|
|
66
|
+
const intervals = [];
|
|
67
|
+
let tmpFrom = from;
|
|
68
|
+
do {
|
|
69
|
+
intervals.push(tmpFrom);
|
|
70
|
+
tmpFrom = tmpFrom.plus({ hour: 1 });
|
|
71
|
+
} while (tmpFrom < to);
|
|
72
|
+
return intervals;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
downloadData(date) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
try {
|
|
78
|
+
const inputData = yield this.datasource.getData(date);
|
|
79
|
+
const transformedData = yield this.transformation.transform(inputData.data);
|
|
80
|
+
yield this.repository.bulkUpdate(transformedData);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof golemio_errors_1.CustomError) {
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
this.logger.error(error, `Unable to download chmu measurements data.`);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
normalizeInput(data) {
|
|
91
|
+
const now = luxon_1.DateTime.now();
|
|
92
|
+
const from = data.from ? luxon_1.DateTime.fromISO(data.from).set({ minute: 0, second: 0, millisecond: 0 }) : now;
|
|
93
|
+
const to = data.from && data.to ? luxon_1.DateTime.fromISO(data.to).set({ minute: 0, second: 0, millisecond: 0 }) : now;
|
|
94
|
+
return { from, to };
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
DownloadMeasurementsTask = __decorate([
|
|
98
|
+
(0, tsyringe_1.injectable)(),
|
|
99
|
+
__param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.ChmuDatasource)),
|
|
100
|
+
__param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.MeasurementsTransformation)),
|
|
101
|
+
__param(2, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.MeasurementsRepository)),
|
|
102
|
+
__param(3, (0, tsyringe_1.inject)(ContainerToken_1.ContainerToken.Logger)),
|
|
103
|
+
__metadata("design:paramtypes", [ChmuDatasource_1.default,
|
|
104
|
+
MeasurementsTransformation_1.MeasurementsTransformation,
|
|
105
|
+
MeasurementsRepository_1.MeasurementsRepository, Object])
|
|
106
|
+
], DownloadMeasurementsTask);
|
|
107
|
+
exports.default = DownloadMeasurementsTask;
|
|
108
|
+
//# sourceMappingURL=DownloadMeasurementsTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadMeasurementsTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAgF;AAChF,sFAA4D;AAC5D,yE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QACzG,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAEhH,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACxB,CAAC;CAaJ,CAAA;AAnEoB,wBAAwB;IAD5C,IAAA,qBAAU,GAAE;IAMJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,cAAc,CAAC,CAAA;IAC3C,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;IACvD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,sBAAsB,CAAC,CAAA;IACnD,WAAA,IAAA,iBAAM,EAAC,+BAAc,CAAC,MAAM,CAAC,CAAA;qCAHmC,wBAAc;QACE,uDAA0B;QAClC,+CAAsB;GAPlF,wBAAwB,CAmE5C;kBAnEoB,wBAAwB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export default class ChmuSchemaProvider {
|
|
2
|
+
static get(): {
|
|
3
|
+
type: string;
|
|
4
|
+
items: {
|
|
5
|
+
type: string;
|
|
6
|
+
required: string[];
|
|
7
|
+
additionalProperties: boolean;
|
|
8
|
+
properties: {
|
|
9
|
+
YEAR: {
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
MONTH: {
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
DAY: {
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
TIME: {
|
|
19
|
+
type: string;
|
|
20
|
+
};
|
|
21
|
+
EG_GH_ID: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
T: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
H: {
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
SRA1H: {
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
P: {
|
|
34
|
+
type: string;
|
|
35
|
+
};
|
|
36
|
+
F: {
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
D: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
SSV1H: {
|
|
43
|
+
type: string;
|
|
44
|
+
};
|
|
45
|
+
HPU1: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
HPU2: {
|
|
49
|
+
type: string;
|
|
50
|
+
};
|
|
51
|
+
HPU3: {
|
|
52
|
+
type: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ChmuSchemaProvider {
|
|
4
|
+
static get() {
|
|
5
|
+
return {
|
|
6
|
+
type: "array",
|
|
7
|
+
items: {
|
|
8
|
+
type: "object",
|
|
9
|
+
required: [
|
|
10
|
+
"YEAR",
|
|
11
|
+
"MONTH",
|
|
12
|
+
"DAY",
|
|
13
|
+
"TIME",
|
|
14
|
+
"EG_GH_ID",
|
|
15
|
+
"T",
|
|
16
|
+
"H",
|
|
17
|
+
"SRA1H",
|
|
18
|
+
"P",
|
|
19
|
+
"F",
|
|
20
|
+
"D",
|
|
21
|
+
"SSV1H",
|
|
22
|
+
"HPU1",
|
|
23
|
+
"HPU2",
|
|
24
|
+
"HPU3",
|
|
25
|
+
],
|
|
26
|
+
additionalProperties: true,
|
|
27
|
+
properties: {
|
|
28
|
+
YEAR: { type: "string" },
|
|
29
|
+
MONTH: { type: "string" },
|
|
30
|
+
DAY: { type: "string" },
|
|
31
|
+
TIME: { type: "string" },
|
|
32
|
+
EG_GH_ID: { type: "string" },
|
|
33
|
+
T: { type: "string" },
|
|
34
|
+
H: { type: "string" },
|
|
35
|
+
SRA1H: { type: "string" },
|
|
36
|
+
P: { type: "string" },
|
|
37
|
+
F: { type: "string" },
|
|
38
|
+
D: { type: "string" },
|
|
39
|
+
SSV1H: { type: "string" },
|
|
40
|
+
HPU1: { type: "string" },
|
|
41
|
+
HPU2: { type: "string" },
|
|
42
|
+
HPU3: { type: "string" },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.default = ChmuSchemaProvider;
|
|
49
|
+
//# sourceMappingURL=ChmuSchemaProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChmuSchemaProvider.js","sourceRoot":"","sources":["../../../src/schema-definitions/datasources/ChmuSchemaProvider.ts"],"names":[],"mappings":";;AAAA,MAAqB,kBAAkB;IAC5B,MAAM,CAAC,GAAG;QACb,OAAO;YACH,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE;oBACN,MAAM;oBACN,OAAO;oBACP,KAAK;oBACL,MAAM;oBACN,UAAU;oBACV,GAAG;oBACH,GAAG;oBACH,OAAO;oBACP,GAAG;oBACH,GAAG;oBACH,GAAG;oBACH,OAAO;oBACP,MAAM;oBACN,MAAM;oBACN,MAAM;iBACT;gBACD,oBAAoB,EAAE,IAAI;gBAC1B,UAAU,EAAE;oBACR,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACvB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC5B,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACrB,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACrB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACrB,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACrB,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACrB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC3B;aACJ;SACJ,CAAC;IACN,CAAC;CACJ;AA5CD,qCA4CC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default interface IInputChmuData {
|
|
2
|
+
YEAR: string;
|
|
3
|
+
MONTH: string;
|
|
4
|
+
DAY: string;
|
|
5
|
+
TIME: string;
|
|
6
|
+
EG_GH_ID: string;
|
|
7
|
+
T: string;
|
|
8
|
+
H: string;
|
|
9
|
+
SRA1H: string;
|
|
10
|
+
P: string;
|
|
11
|
+
F: string;
|
|
12
|
+
D: string;
|
|
13
|
+
SSV1H: string;
|
|
14
|
+
HPU1: string;
|
|
15
|
+
HPU2: string;
|
|
16
|
+
HPU3: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IInputChmuData.js","sourceRoot":"","sources":["../../../../src/schema-definitions/datasources/interfaces/IInputChmuData.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IMeasurementDto {
|
|
2
|
+
measured_at: string;
|
|
3
|
+
station_id: string;
|
|
4
|
+
year: number;
|
|
5
|
+
month: number;
|
|
6
|
+
day: number;
|
|
7
|
+
time: string;
|
|
8
|
+
air_temp: string | null;
|
|
9
|
+
air_hum: string | null;
|
|
10
|
+
precip: string | null;
|
|
11
|
+
air_pressure: string | null;
|
|
12
|
+
wind_speed: string | null;
|
|
13
|
+
wind_dir: string | null;
|
|
14
|
+
sunlight: string | null;
|
|
15
|
+
soil_hum_0_10: number | null;
|
|
16
|
+
soil_hum_10_50: number | null;
|
|
17
|
+
soil_hum_50_100: number | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMeasurementDto.js","sourceRoot":"","sources":["../../../../src/schema-definitions/definitions/interfaces/IMeasurementDto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Model, ModelAttributes } from "@golemio/core/dist/shared/sequelize";
|
|
2
|
+
import { IMeasurementDto } from "../interfaces/IMeasurementDto";
|
|
3
|
+
import { JSONSchemaType } from "@golemio/core/dist/shared/ajv";
|
|
4
|
+
export declare class MeasurementModel extends Model<IMeasurementDto> implements IMeasurementDto {
|
|
5
|
+
measured_at: string;
|
|
6
|
+
station_id: string;
|
|
7
|
+
year: number;
|
|
8
|
+
month: number;
|
|
9
|
+
day: number;
|
|
10
|
+
time: string;
|
|
11
|
+
air_temp: string | null;
|
|
12
|
+
air_hum: string | null;
|
|
13
|
+
precip: string | null;
|
|
14
|
+
air_pressure: string | null;
|
|
15
|
+
wind_speed: string | null;
|
|
16
|
+
wind_dir: string | null;
|
|
17
|
+
sunlight: string | null;
|
|
18
|
+
soil_hum_0_10: number | null;
|
|
19
|
+
soil_hum_10_50: number | null;
|
|
20
|
+
soil_hum_50_100: number | null;
|
|
21
|
+
static attributeModel: ModelAttributes<MeasurementModel, IMeasurementDto>;
|
|
22
|
+
static jsonSchema: JSONSchemaType<IMeasurementDto[]>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MeasurementModel = void 0;
|
|
4
|
+
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
|
|
5
|
+
class MeasurementModel extends sequelize_1.Model {
|
|
6
|
+
}
|
|
7
|
+
exports.MeasurementModel = MeasurementModel;
|
|
8
|
+
MeasurementModel.attributeModel = {
|
|
9
|
+
measured_at: { type: sequelize_1.DataTypes.DATE, primaryKey: true },
|
|
10
|
+
station_id: { type: sequelize_1.DataTypes.STRING, primaryKey: true },
|
|
11
|
+
year: { type: sequelize_1.DataTypes.INTEGER },
|
|
12
|
+
month: { type: sequelize_1.DataTypes.INTEGER },
|
|
13
|
+
day: { type: sequelize_1.DataTypes.INTEGER },
|
|
14
|
+
time: { type: sequelize_1.DataTypes.TIME },
|
|
15
|
+
air_temp: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
16
|
+
air_hum: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
17
|
+
precip: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
18
|
+
air_pressure: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
19
|
+
wind_speed: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
20
|
+
wind_dir: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
21
|
+
sunlight: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
22
|
+
soil_hum_0_10: { type: sequelize_1.DataTypes.INTEGER, allowNull: true },
|
|
23
|
+
soil_hum_10_50: { type: sequelize_1.DataTypes.INTEGER, allowNull: true },
|
|
24
|
+
soil_hum_50_100: { type: sequelize_1.DataTypes.INTEGER, allowNull: true },
|
|
25
|
+
};
|
|
26
|
+
MeasurementModel.jsonSchema = {
|
|
27
|
+
type: "array",
|
|
28
|
+
items: {
|
|
29
|
+
type: "object",
|
|
30
|
+
properties: {
|
|
31
|
+
measured_at: { type: "string" },
|
|
32
|
+
station_id: { type: "string" },
|
|
33
|
+
year: { type: "integer" },
|
|
34
|
+
month: { type: "integer" },
|
|
35
|
+
day: { type: "integer" },
|
|
36
|
+
time: { type: "string" },
|
|
37
|
+
air_temp: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
38
|
+
air_hum: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
39
|
+
precip: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
40
|
+
air_pressure: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
41
|
+
wind_speed: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
42
|
+
wind_dir: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
43
|
+
sunlight: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
44
|
+
soil_hum_0_10: { oneOf: [{ type: "integer" }, { type: "null", nullable: true }] },
|
|
45
|
+
soil_hum_10_50: { oneOf: [{ type: "integer" }, { type: "null", nullable: true }] },
|
|
46
|
+
soil_hum_50_100: { oneOf: [{ type: "integer" }, { type: "null", nullable: true }] },
|
|
47
|
+
},
|
|
48
|
+
required: ["measured_at", "station_id"],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=MeasurementModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeasurementModel.js","sourceRoot":"","sources":["../../../../src/schema-definitions/definitions/models/MeasurementModel.ts"],"names":[],"mappings":";;;AAAA,mEAAwF;AAIxF,MAAa,gBAAiB,SAAQ,iBAAsB;;AAA5D,4CA8DC;AA5CiB,+BAAc,GAAuD;IAC/E,WAAW,EAAE,EAAE,IAAI,EAAE,qBAAS,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;IACvD,UAAU,EAAE,EAAE,IAAI,EAAE,qBAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE;IACxD,IAAI,EAAE,EAAE,IAAI,EAAE,qBAAS,CAAC,OAAO,EAAE;IACjC,KAAK,EAAE,EAAE,IAAI,EAAE,qBAAS,CAAC,OAAO,EAAE;IAClC,GAAG,E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AE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;YACjF,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;YAClF,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;SACtF;QACD,QAAQ,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;KAC1C;CACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/chmu",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.776186639",
|
|
4
4
|
"description": "Golemio CHMU module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
8
|
+
"build": "rimraf ./dist && ttsc -p ./tsconfig.build.json",
|
|
9
|
+
"build-minimal": "run-s 'build -- --sourceMap false --declaration false'",
|
|
10
|
+
"build-watch": "run-s 'build -- --watch --preserveWatchOutput'",
|
|
11
|
+
"pretest": "golemio import-db-data --postgres",
|
|
12
|
+
"test": "cross-env NODE_ENV=test TS_NODE_COMPILER='ttypescript' mocha --exit --check-leaks --timeout 120000 -r ts-node/register -r dotenv/config --file 'test/setup.ts' 'test/**/*.test.ts'",
|
|
13
|
+
"test-debug": "run-s 'test -- --inspect-brk=9230'",
|
|
14
|
+
"code-coverage": "nyc run-s 'test -- -r source-map-support/register'",
|
|
15
|
+
"migrate-db": "golemio migrate-db up --postgres",
|
|
16
|
+
"generate-docs": "typedoc --out docs/typedoc src",
|
|
17
|
+
"lint": "eslint --cache \"{src,test}/**/*.ts\""
|
|
9
18
|
},
|
|
10
19
|
"keywords": [
|
|
11
20
|
"golemio"
|
|
@@ -16,7 +25,45 @@
|
|
|
16
25
|
"type": "git",
|
|
17
26
|
"url": "https://gitlab.com/operator-ict/golemio/code/modules/chmu"
|
|
18
27
|
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=16.0.0",
|
|
30
|
+
"npm": ">=8.0.0",
|
|
31
|
+
"yarn": "Use npm!"
|
|
32
|
+
},
|
|
19
33
|
"devDependencies": {
|
|
20
|
-
"@
|
|
34
|
+
"@commitlint/cli": "^11.0.0",
|
|
35
|
+
"@commitlint/config-conventional": "^11.0.0",
|
|
36
|
+
"@golemio/cli": "1.3.3",
|
|
37
|
+
"@golemio/core": "1.4.1",
|
|
38
|
+
"@golemio/db-common": "1.0.2",
|
|
39
|
+
"@golemio/eslint-config": "^1.1.0",
|
|
40
|
+
"@ovos-media/ts-transform-paths": "^1.7.18-1",
|
|
41
|
+
"@types/chai": "4.2.3",
|
|
42
|
+
"@types/chai-as-promised": "7.1.2",
|
|
43
|
+
"@types/mocha": "^9.1.0",
|
|
44
|
+
"@types/node": "^16.11.35",
|
|
45
|
+
"@types/sinon": "^9.0.10",
|
|
46
|
+
"@types/supertest": "^2.0.12",
|
|
47
|
+
"chai": "4.2.0",
|
|
48
|
+
"chai-as-promised": "7.1.1",
|
|
49
|
+
"cross-env": "^7.0.3",
|
|
50
|
+
"dotenv": "^8.2.0",
|
|
51
|
+
"eslint": "^8.1.1",
|
|
52
|
+
"husky": "^4.3.7",
|
|
53
|
+
"mocha": "^9.1.2",
|
|
54
|
+
"npm-run-all": "^4.1.5",
|
|
55
|
+
"nyc": "^15.1.0",
|
|
56
|
+
"prettier": "^2.5.1",
|
|
57
|
+
"pretty-quick": "^3.1.0",
|
|
58
|
+
"rimraf": "^3.0.2",
|
|
59
|
+
"sinon": "^9.2.3",
|
|
60
|
+
"source-map-support": "0.5.19",
|
|
61
|
+
"ts-node": "^10.7.0",
|
|
62
|
+
"ttypescript": "^1.5.13",
|
|
63
|
+
"typedoc": "^0.23.21",
|
|
64
|
+
"typescript": "4.7.2"
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"@golemio/core": "^1.4.1"
|
|
21
68
|
}
|
|
22
69
|
}
|