@golemio/energetics 1.4.9-dev.1622712529 → 1.4.9-dev.1628263535
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/input-gateway/pre/PreCsvInputController.d.ts +8 -0
- package/dist/input-gateway/pre/PreCsvInputController.js +42 -0
- package/dist/input-gateway/pre/PreCsvInputController.js.map +1 -0
- package/dist/input-gateway/pre/PreInputRouter.d.ts +4 -1
- package/dist/input-gateway/pre/PreInputRouter.js +21 -3
- package/dist/input-gateway/pre/PreInputRouter.js.map +1 -1
- package/dist/input-gateway/pre/{PreInputController.d.ts → PreJsonInputController.d.ts} +1 -1
- package/dist/input-gateway/pre/{PreInputController.js → PreJsonInputController.js} +5 -5
- package/dist/input-gateway/pre/PreJsonInputController.js.map +1 -0
- package/dist/input-gateway/pre/index.d.ts +1 -1
- package/dist/input-gateway/pre/index.js +1 -1
- package/dist/input-gateway/pre/index.js.map +1 -1
- package/dist/input-gateway/transformations/PreCsvInputTransformation.d.ts +8 -0
- package/dist/input-gateway/transformations/PreCsvInputTransformation.js +25 -0
- package/dist/input-gateway/transformations/PreCsvInputTransformation.js.map +1 -0
- package/dist/integration-engine/commodity-providers/helper/PreMeasurementFilter.d.ts +4 -0
- package/dist/integration-engine/commodity-providers/helper/PreMeasurementFilter.js +15 -0
- package/dist/integration-engine/commodity-providers/helper/PreMeasurementFilter.js.map +1 -0
- package/dist/integration-engine/commodity-providers/workers/interfaces/IPreEanMeasurement.d.ts +1 -1
- package/dist/integration-engine/commodity-providers/workers/schema/PreEanMeasurementSchema.d.ts +1 -1
- package/dist/integration-engine/commodity-providers/workers/schema/PreEanMeasurementSchema.js.map +1 -1
- package/dist/integration-engine/commodity-providers/workers/tasks/ProcessPreEanMeasurementsTask.js +2 -1
- package/dist/integration-engine/commodity-providers/workers/tasks/ProcessPreEanMeasurementsTask.js.map +1 -1
- package/dist/schema-definitions/datasources/PreCsvInputSchema.d.ts +3 -0
- package/dist/schema-definitions/datasources/PreCsvInputSchema.js +19 -0
- package/dist/schema-definitions/datasources/PreCsvInputSchema.js.map +1 -0
- package/dist/schema-definitions/datasources/interfaces/IPreCsvInput.d.ts +5 -0
- package/dist/schema-definitions/datasources/interfaces/IPreCsvInput.js +3 -0
- package/dist/schema-definitions/datasources/interfaces/IPreCsvInput.js.map +1 -0
- package/docs/implementation_documentation.md +9 -0
- package/docs/openapi-input.yaml +33 -0
- package/package.json +1 -1
- package/dist/input-gateway/pre/PreInputController.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseController } from "@golemio/core/dist/input-gateway/controllers";
|
|
2
|
+
import { PreCsvInputTransformation } from "../transformations/PreCsvInputTransformation";
|
|
3
|
+
import { IPreCsvInput } from "../../schema-definitions/datasources/interfaces/IPreCsvInput";
|
|
4
|
+
export declare class PreCsvInputController extends BaseController {
|
|
5
|
+
private transformation;
|
|
6
|
+
constructor(transformation: PreCsvInputTransformation);
|
|
7
|
+
processData: (inputData: IPreCsvInput[]) => Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.PreCsvInputController = void 0;
|
|
13
|
+
const controllers_1 = require("@golemio/core/dist/input-gateway/controllers");
|
|
14
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
15
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
16
|
+
const constants_1 = require("../../integration-engine/commodity-providers/constants");
|
|
17
|
+
const PreCsvInputSchema_1 = require("../../schema-definitions/datasources/PreCsvInputSchema");
|
|
18
|
+
class PreCsvInputController extends controllers_1.BaseController {
|
|
19
|
+
constructor(transformation) {
|
|
20
|
+
super(constants_1.WORKER_NAME, new golemio_validator_1.JSONSchemaValidator("PreCsvInputController", PreCsvInputSchema_1.preCsvInputSchema));
|
|
21
|
+
this.transformation = transformation;
|
|
22
|
+
this.processData = (inputData) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
try {
|
|
24
|
+
yield this.validator.Validate(inputData);
|
|
25
|
+
const eanMeasurement = this.transformation.transformElement(inputData);
|
|
26
|
+
yield this.sendMessageToExchange("input." + this.queuePrefix + ".processPreEanMeasurements", JSON.stringify(eanMeasurement), {
|
|
27
|
+
persistent: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
if (err instanceof golemio_errors_1.AbstractGolemioError) {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new golemio_errors_1.GeneralError("Error while validating input data.", this.name, err, 422);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.PreCsvInputController = PreCsvInputController;
|
|
42
|
+
//# sourceMappingURL=PreCsvInputController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreCsvInputController.js","sourceRoot":"","sources":["../../../src/input-gateway/pre/PreCsvInputController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAA8E;AAC9E,mFAAkF;AAClF,6EAA8F;AAC9F,sFAAgE;AAEhE,8FAAuE;AAGvE,MAAa,qBAAsB,SAAQ,4BAAc;IACrD,YAAoB,cAAyC;QACzD,KAAK,CAAC,uBAAW,EAAE,IAAI,uCAAmB,CAAC,uBAAuB,EAAE,qCAAiB,CAAC,CAAC,CAAC;QADxE,mBAAc,GAAd,cAAc,CAA2B;QAItD,gBAAW,GAAG,CAAO,SAAyB,EAAE,EAAE;YACrD,IAAI;gBACA,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACzC,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;gBACvE,MAAM,IAAI,CAAC,qBAAqB,CAC5B,QAAQ,GAAG,IAAI,CAAC,WAAW,GAAG,4BAA4B,EAC1D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAC9B;oBACI,UAAU,EAAE,IAAI;iBACnB,CACJ,CAAC;aACL;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,GAAG,YAAY,qCAAoB,EAAE;oBACrC,MAAM,GAAG,CAAC;iBACb;qBAAM;oBACH,MAAM,IAAI,6BAAY,CAAC,oCAAoC,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;iBACrF;aACJ;QACL,CAAC,CAAA,CAAC;IApBF,CAAC;CAqBJ;AAxBD,sDAwBC"}
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
import { Router } from "@golemio/core/dist/shared/express";
|
|
3
3
|
export declare class PreInputRouter {
|
|
4
4
|
router: Router;
|
|
5
|
-
private
|
|
5
|
+
private jsonInputController;
|
|
6
|
+
private csvInputController;
|
|
7
|
+
private csvParser;
|
|
6
8
|
constructor();
|
|
7
9
|
private initRoutes;
|
|
8
10
|
private postPreJson;
|
|
11
|
+
private postPreCsv;
|
|
9
12
|
}
|
|
10
13
|
declare const preInputRouter: Router;
|
|
11
14
|
export { preInputRouter };
|
|
@@ -12,16 +12,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.preInputRouter = exports.PreInputRouter = void 0;
|
|
13
13
|
const express_1 = require("@golemio/core/dist/shared/express");
|
|
14
14
|
const helpers_1 = require("@golemio/core/dist/input-gateway/helpers");
|
|
15
|
-
const
|
|
15
|
+
const PreJsonInputController_1 = require("./PreJsonInputController");
|
|
16
16
|
const PreDataExtractor_1 = require("../helpers/PreDataExtractor");
|
|
17
|
+
const ioc_1 = require("@golemio/core/dist/input-gateway/ioc");
|
|
18
|
+
const PreCsvInputController_1 = require("./PreCsvInputController");
|
|
19
|
+
const PreCsvInputTransformation_1 = require("../transformations/PreCsvInputTransformation");
|
|
17
20
|
class PreInputRouter {
|
|
18
21
|
constructor() {
|
|
19
22
|
this.initRoutes = () => {
|
|
20
23
|
this.router.post("/", (0, helpers_1.checkContentTypeMiddleware)(["application/json"]), this.postPreJson);
|
|
24
|
+
this.router.post("/csv", (0, helpers_1.checkContentTypeMiddleware)(["text/csv"]), this.csvParser.getMiddleware({
|
|
25
|
+
delimiter: ";",
|
|
26
|
+
shouldIncludeHeaders: true,
|
|
27
|
+
}), this.postPreCsv);
|
|
21
28
|
};
|
|
22
29
|
this.postPreJson = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
23
30
|
try {
|
|
24
|
-
yield this.
|
|
31
|
+
yield this.jsonInputController.processData(req.body);
|
|
32
|
+
res.sendStatus(204);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
next(err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
this.postPreCsv = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
try {
|
|
40
|
+
yield this.csvInputController.processData(req.body);
|
|
25
41
|
res.sendStatus(204);
|
|
26
42
|
}
|
|
27
43
|
catch (err) {
|
|
@@ -29,7 +45,9 @@ class PreInputRouter {
|
|
|
29
45
|
}
|
|
30
46
|
});
|
|
31
47
|
this.router = (0, express_1.Router)();
|
|
32
|
-
this.
|
|
48
|
+
this.jsonInputController = new PreJsonInputController_1.PreJsonInputController(new PreDataExtractor_1.PreDataExtractor());
|
|
49
|
+
this.csvInputController = new PreCsvInputController_1.PreCsvInputController(new PreCsvInputTransformation_1.PreCsvInputTransformation());
|
|
50
|
+
this.csvParser = ioc_1.InputGatewayContainer.resolve(ioc_1.ContainerToken.CsvParserMiddleware);
|
|
33
51
|
this.initRoutes();
|
|
34
52
|
}
|
|
35
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreInputRouter.js","sourceRoot":"","sources":["../../../src/input-gateway/pre/PreInputRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA4F;AAC5F,sEAAsF;AACtF,
|
|
1
|
+
{"version":3,"file":"PreInputRouter.js","sourceRoot":"","sources":["../../../src/input-gateway/pre/PreInputRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA4F;AAC5F,sEAAsF;AACtF,qEAAwE;AACxE,kEAAgE;AAChE,8DAA6F;AAE7F,mEAAsE;AACtE,4FAA0F;AAE1F,MAAa,cAAc;IAMvB;QAQQ,eAAU,GAAG,GAAS,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAA,oCAA0B,EAAC,CAAC,kBAAkB,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YAC1F,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,MAAM,EACN,IAAA,oCAA0B,EAAC,CAAC,UAAU,CAAC,CAAC,EACxC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;gBACzB,SAAS,EAAE,GAAG;gBACd,oBAAoB,EAAE,IAAI;aAC7B,CAAC,EACF,IAAI,CAAC,UAAU,CAClB,CAAC;QACN,CAAC,CAAC;QAEM,gBAAW,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAiB,EAAE;YAC3F,IAAI;gBACA,MAAM,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACrD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aACvB;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,CAAC;aACb;QACL,CAAC,CAAA,CAAC;QAEM,eAAU,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAiB,EAAE;YAC1F,IAAI;gBACA,MAAM,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACpD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aACvB;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,CAAC;aACb;QACL,CAAC,CAAA,CAAC;QApCE,IAAI,CAAC,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,+CAAsB,CAAC,IAAI,mCAAgB,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,kBAAkB,GAAG,IAAI,6CAAqB,CAAC,IAAI,qDAAyB,EAAE,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS,GAAG,2BAAqB,CAAC,OAAO,CAAsB,oBAAc,CAAC,mBAAmB,CAAC,CAAC;QACxG,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CAgCJ;AA5CD,wCA4CC;AAED,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC,MAAM,CAAC;AAC1C,wCAAc"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseController } from "@golemio/core/dist/input-gateway/controllers";
|
|
2
2
|
import { IPreJsonInput } from "../../schema-definitions/datasources/interfaces/IPreJsonInput";
|
|
3
3
|
import { PreDataExtractor } from "../helpers/PreDataExtractor";
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class PreJsonInputController extends BaseController {
|
|
5
5
|
private preDataExtractor;
|
|
6
6
|
constructor(preDataExtractor: PreDataExtractor);
|
|
7
7
|
processData: (inputData: IPreJsonInput) => Promise<void>;
|
|
@@ -9,15 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.PreJsonInputController = void 0;
|
|
13
13
|
const controllers_1 = require("@golemio/core/dist/input-gateway/controllers");
|
|
14
14
|
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
15
15
|
const PreJsonInputSchema_1 = require("../../schema-definitions/datasources/PreJsonInputSchema");
|
|
16
16
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
17
17
|
const constants_1 = require("../../integration-engine/commodity-providers/constants");
|
|
18
|
-
class
|
|
18
|
+
class PreJsonInputController extends controllers_1.BaseController {
|
|
19
19
|
constructor(preDataExtractor) {
|
|
20
|
-
super(constants_1.WORKER_NAME, new golemio_validator_1.JSONSchemaValidator("
|
|
20
|
+
super(constants_1.WORKER_NAME, new golemio_validator_1.JSONSchemaValidator("PreJsonInputController", PreJsonInputSchema_1.preJsonInputSchema));
|
|
21
21
|
this.preDataExtractor = preDataExtractor;
|
|
22
22
|
this.processData = (inputData) => __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
try {
|
|
@@ -40,5 +40,5 @@ class PreInputController extends controllers_1.BaseController {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
exports.
|
|
44
|
-
//# sourceMappingURL=
|
|
43
|
+
exports.PreJsonInputController = PreJsonInputController;
|
|
44
|
+
//# sourceMappingURL=PreJsonInputController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreJsonInputController.js","sourceRoot":"","sources":["../../../src/input-gateway/pre/PreJsonInputController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAA8E;AAC9E,mFAAkF;AAClF,gGAAyE;AAGzE,6EAA8F;AAC9F,sFAAgE;AAEhE,MAAa,sBAAuB,SAAQ,4BAAc;IACtD,YAAoB,gBAAkC;QAClD,KAAK,CAAC,uBAAW,EAAE,IAAI,uCAAmB,CAAC,wBAAwB,EAAE,uCAAkB,CAAC,CAAC,CAAC;QAD1E,qBAAgB,GAAhB,gBAAgB,CAAkB;QAI/C,gBAAW,GAAG,CAAO,SAAwB,EAAE,EAAE;YACpD,IAAI;gBACA,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACzC,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;gBAChF,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;oBAC1C,MAAM,IAAI,CAAC,qBAAqB,CAC5B,QAAQ,GAAG,IAAI,CAAC,WAAW,GAAG,4BAA4B,EAC1D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAC9B;wBACI,UAAU,EAAE,IAAI;qBACnB,CACJ,CAAC;iBACL;aACJ;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,GAAG,YAAY,qCAAoB,EAAE;oBACrC,MAAM,GAAG,CAAC;iBACb;qBAAM;oBACH,MAAM,IAAI,6BAAY,CAAC,oCAAoC,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;iBACrF;aACJ;QACL,CAAC,CAAA,CAAC;IAtBF,CAAC;CAuBJ;AA1BD,wDA0BC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./PreInputRouter";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./PreJsonInputController";
|
|
@@ -15,5 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./PreInputRouter"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./PreJsonInputController"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/input-gateway/pre/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/input-gateway/pre/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,2DAAyC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AbstractTransformation } from "@golemio/core/dist/helpers/transformation/AbstractTransformation";
|
|
2
|
+
import { IPreCsvInput } from "../../schema-definitions/datasources/interfaces/IPreCsvInput";
|
|
3
|
+
import { IPreEanMeasurement } from "../../integration-engine/commodity-providers/workers/interfaces/IPreEanMeasurement";
|
|
4
|
+
export declare class PreCsvInputTransformation extends AbstractTransformation<IPreCsvInput[], IPreEanMeasurement> {
|
|
5
|
+
name: string;
|
|
6
|
+
protected transformInternal: (data: IPreCsvInput[]) => IPreEanMeasurement;
|
|
7
|
+
private getEan;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreCsvInputTransformation = void 0;
|
|
4
|
+
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
|
|
5
|
+
class PreCsvInputTransformation extends AbstractTransformation_1.AbstractTransformation {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.name = "PreCsvInputTransformation";
|
|
9
|
+
this.transformInternal = (data) => {
|
|
10
|
+
const T1_Wh_raw_data = [];
|
|
11
|
+
const ean = this.getEan(data[0]);
|
|
12
|
+
for (const row of data) {
|
|
13
|
+
const consumptionValue = row[Object.keys(row)[2]];
|
|
14
|
+
T1_Wh_raw_data.push([row["Konec intervalu"], parseInt(consumptionValue)]);
|
|
15
|
+
}
|
|
16
|
+
return { ean, T1_Wh_raw_data };
|
|
17
|
+
};
|
|
18
|
+
this.getEan = (data) => {
|
|
19
|
+
const keys = Object.keys(data);
|
|
20
|
+
return keys[2].substring(0, 18);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.PreCsvInputTransformation = PreCsvInputTransformation;
|
|
25
|
+
//# sourceMappingURL=PreCsvInputTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreCsvInputTransformation.js","sourceRoot":"","sources":["../../../src/input-gateway/transformations/PreCsvInputTransformation.ts"],"names":[],"mappings":";;;AAAA,6GAA0G;AAI1G,MAAa,yBAA0B,SAAQ,+CAA0D;IAAzG;;QACW,SAAI,GAAG,2BAA2B,CAAC;QAEhC,sBAAiB,GAAG,CAAC,IAAoB,EAAsB,EAAE;YACvE,MAAM,cAAc,GAA4B,EAAE,CAAC;YACnD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAEjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;gBACpB,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClD,cAAc,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;aAC7E;YAED,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;QACnC,CAAC,CAAC;QAEM,WAAM,GAAG,CAAC,IAAkB,EAAU,EAAE;YAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpC,CAAC,CAAC;IACN,CAAC;CAAA;AAnBD,8DAmBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreMeasurementFilter = void 0;
|
|
4
|
+
class PreMeasurementFilter {
|
|
5
|
+
static sumDuplicates(measurementInput) {
|
|
6
|
+
const clean = new Map();
|
|
7
|
+
for (const row of measurementInput.T1_Wh_raw_data) {
|
|
8
|
+
clean.has(row[0]) ? clean.set(row[0], clean.get(row[0]) + row[1]) : clean.set(row[0], row[1]);
|
|
9
|
+
}
|
|
10
|
+
const T1_Wh_raw_data = Array.from(clean, ([k, v]) => [k, v]);
|
|
11
|
+
return { ean: measurementInput.ean, T1_Wh_raw_data };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.PreMeasurementFilter = PreMeasurementFilter;
|
|
15
|
+
//# sourceMappingURL=PreMeasurementFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreMeasurementFilter.js","sourceRoot":"","sources":["../../../../src/integration-engine/commodity-providers/helper/PreMeasurementFilter.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAoB;IACtB,MAAM,CAAC,aAAa,CAAC,gBAAoC;QAC5D,MAAM,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;QAE7C,KAAK,MAAM,GAAG,IAAI,gBAAgB,CAAC,cAAc,EAAE;YAC/C,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAClG;QAED,MAAM,cAAc,GAA4B,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAEtF,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,CAAC;IACzD,CAAC;CACJ;AAZD,oDAYC"}
|
package/dist/integration-engine/commodity-providers/workers/schema/PreEanMeasurementSchema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreEanMeasurementSchema.js","sourceRoot":"","sources":["../../../../../src/integration-engine/commodity-providers/workers/schema/PreEanMeasurementSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+EAA8E;AAE9E,MAAa,uBAAuB;CAMnC;AAND,0DAMC;AAJG;IADC,IAAA,yBAAO,GAAE;8BACO,KAAK;+
|
|
1
|
+
{"version":3,"file":"PreEanMeasurementSchema.js","sourceRoot":"","sources":["../../../../../src/integration-engine/commodity-providers/workers/schema/PreEanMeasurementSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+EAA8E;AAE9E,MAAa,uBAAuB;CAMnC;AAND,0DAMC;AAJG;IADC,IAAA,yBAAO,GAAE;8BACO,KAAK;+DAAmB;AAGzC;IADC,IAAA,0BAAQ,GAAE;;oDACE"}
|
package/dist/integration-engine/commodity-providers/workers/tasks/ProcessPreEanMeasurementsTask.js
CHANGED
|
@@ -33,6 +33,7 @@ const StaticDataResourceTypeEnum_1 = require("../../../../schema-definitions/mod
|
|
|
33
33
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
34
34
|
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
35
35
|
const constants_1 = require("../../constants");
|
|
36
|
+
const PreMeasurementFilter_1 = require("../../helper/PreMeasurementFilter");
|
|
36
37
|
let ProcessPreEanMeasurementsTask = exports.ProcessPreEanMeasurementsTask = class ProcessPreEanMeasurementsTask extends integration_engine_1.AbstractTask {
|
|
37
38
|
constructor(meterSettingsRepository, measurementRepository, transformation) {
|
|
38
39
|
super(constants_1.WORKER_NAME);
|
|
@@ -55,7 +56,7 @@ let ProcessPreEanMeasurementsTask = exports.ProcessPreEanMeasurementsTask = clas
|
|
|
55
56
|
}
|
|
56
57
|
const measurements = this.transformation.transformElement({
|
|
57
58
|
option,
|
|
58
|
-
measurementInput,
|
|
59
|
+
measurementInput: PreMeasurementFilter_1.PreMeasurementFilter.sumDuplicates(measurementInput),
|
|
59
60
|
});
|
|
60
61
|
yield this.measurementRepository.bulkSave(measurements);
|
|
61
62
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessPreEanMeasurementsTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/commodity-providers/workers/tasks/ProcessPreEanMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAwE;AACxE,yEAAwF;AAExF,qGAAoH;AACpH,oGAAmH;AACnH,oFAAmG;AAEnG,+EAAyG;AACzG,uHAAsF;AACtF,yHAAwF;AAExF,6EAAwE;AACxE,8EAAqE;AACrE,+CAAgE;
|
|
1
|
+
{"version":3,"file":"ProcessPreEanMeasurementsTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/commodity-providers/workers/tasks/ProcessPreEanMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAwE;AACxE,yEAAwF;AAExF,qGAAoH;AACpH,oGAAmH;AACnH,oFAAmG;AAEnG,+EAAyG;AACzG,uHAAsF;AACtF,yHAAwF;AAExF,6EAAwE;AACxE,8EAAqE;AACrE,+CAAgE;AAChE,4EAA2F;AAGpF,IAAM,6BAA6B,2CAAnC,MAAM,6BAA8B,SAAQ,iCAAgC;IAK/E,YAEI,uBAA8D,EACV,qBAAsD,EAC/C,cAAsD;QAEjH,KAAK,CAAC,uBAAW,CAAC,CAAC;QAJX,4BAAuB,GAAvB,uBAAuB,CAA+B;QACA,0BAAqB,GAArB,qBAAqB,CAAuB;QACrC,mBAAc,GAAd,cAAc,CAA8B;QAR3G,WAAM,GAAG,iDAAuB,CAAC;QAC3B,cAAS,GAAG,2BAA2B,CAAC;QACxC,aAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAS1C,CAAC;IAEe,OAAO,CAAC,gBAAoC;;YACxD,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CACjE,iDAAqB,CAAC,eAAe,EACrC,mDAAsB,CAAC,kBAAkB,CAC5C,CAAC;YAEF,IAAI,CAAC,kBAAkB,EAAE;gBACrB,MAAM,IAAI,6BAAY,CAAC,+BAA+B,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aAClF;YAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,IAAwB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAE1G,IAAI,CAAC,MAAM,EAAE;gBACT,MAAM,IAAI,6BAAY,CAAC,yCAAyC,GAAG,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aACnH;YAED,MAAM,YAAY,GAAsB,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC;gBACzE,MAAM;gBACN,gBAAgB,EAAE,2CAAoB,CAAC,aAAa,CAAC,gBAAgB,CAAC;aACzE,CAAC,CAAC;YAEH,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC5D,CAAC;KAAA;CACJ,CAAA;wCArCY,6BAA6B;IADzC,IAAA,qBAAU,GAAE;IAOJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,6BAA6B,CAAC,CAAA;IAE1D,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,qBAAqB,CAAC,CAAA;IAClD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,4BAA4B,CAAC,CAAA;qCAFzB,6DAA6B;QACuB,6CAAqB;QACrB,2DAA4B;GAT5G,6BAA6B,CAqCzC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preCsvInputSchema = void 0;
|
|
4
|
+
exports.preCsvInputSchema = {
|
|
5
|
+
type: "array",
|
|
6
|
+
items: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
"Počátek intervalu": { type: "string", pattern: "^\\d{1,2}.\\d{1,2}.\\d{4} \\d{2}:\\d{2}$" },
|
|
10
|
+
"Konec intervalu": { type: "string", pattern: "^\\d{1,2}.\\d{1,2}.\\d{4} \\d{2}:\\d{2}$" },
|
|
11
|
+
},
|
|
12
|
+
patternProperties: {
|
|
13
|
+
"^[0-9]{18} - Činná - spotřeba [kW]$": { type: "string" },
|
|
14
|
+
},
|
|
15
|
+
additionalProperties: true,
|
|
16
|
+
required: ["Konec intervalu"],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=PreCsvInputSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreCsvInputSchema.js","sourceRoot":"","sources":["../../../src/schema-definitions/datasources/PreCsvInputSchema.ts"],"names":[],"mappings":";;;AAGa,QAAA,iBAAiB,GAAmC;IAC7D,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,0CAA0C,EAAE;YAC5F,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,0CAA0C,EAAE;SAC7F;QACD,iBAAiB,EAAE;YACf,qCAAqC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC5D;QACD,oBAAoB,EAAE,IAAI;QAC1B,QAAQ,EAAE,CAAC,iBAAiB,CAAC;KAChC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPreCsvInput.js","sourceRoot":"","sources":["../../../../src/schema-definitions/datasources/interfaces/IPreCsvInput.ts"],"names":[],"mappings":""}
|
|
@@ -20,6 +20,14 @@ Modul slouží k ukládání dat o spotřebě energií v budovách a jednotlivý
|
|
|
20
20
|
- Na IG chodí větší soubory (např. 20M). Proto se na IG rozdělí podle měřidel a vyříznou se jen data, co zpracováváme.
|
|
21
21
|
Dál to postupuje na IE přes rabbit do [ProcessPreEanMeasurementsTask](../src/integration-engine/commodity-providers/workers/tasks/ProcessPreEanMeasurementsTask.ts).
|
|
22
22
|
|
|
23
|
+
#### _POST /pre/csv_
|
|
24
|
+
|
|
25
|
+
- Endpoint pro příjem historických dat PRE v CSV formátu (POST na /pre/csv).
|
|
26
|
+
- Očekávaný [formát dat](../src/schema-definitions/datasources/interfaces/IPreCsvInput.ts)
|
|
27
|
+
- V IG se CSV převede na stejný formát, jako /pre používá endpoint a dál na IE postupuje stejně.
|
|
28
|
+
Tj. přes rabbit do [ProcessPreEanMeasurementsTask](../src/integration-engine/commodity-providers/workers/tasks/ProcessPreEanMeasurementsTask.ts).
|
|
29
|
+
|
|
30
|
+
|
|
23
31
|
### Data aktivně stahujeme
|
|
24
32
|
|
|
25
33
|
**Dostupní poskytovatelé**:
|
|
@@ -266,6 +274,7 @@ Přijímá data o spotřebách od PRE z IG (viz. nahoře)
|
|
|
266
274
|
- datový zdroj je PRE IG endpoint (viz. nahoře)
|
|
267
275
|
- transformace
|
|
268
276
|
- [PreMeasurementTransformation](../src/integration-engine/commodity-providers/transformations/PreMeasurementTransformation.ts)
|
|
277
|
+
- Vstupní hodnoty se stejným datem měření se sčítají. Duplicitní timestamp vzniká při přechodu na zimní čas.
|
|
269
278
|
- data modely
|
|
270
279
|
- odsud si bere statická data: [StaticMeterSettingsModel](../src/schema-definitions/models/StaticMeterSettingsModel.ts) tabulka `commodity_static_meter_settings`
|
|
271
280
|
- sem ukládá: [MeasurementModel](../src/schema-definitions/models/MeasurementsModel.ts) tabulka `consumption_energy_measurements`
|
package/docs/openapi-input.yaml
CHANGED
|
@@ -101,7 +101,30 @@ paths:
|
|
|
101
101
|
$ref: "#/components/responses/UnauthorizedError"
|
|
102
102
|
422:
|
|
103
103
|
description: Error while validating input data
|
|
104
|
+
/pre/csv:
|
|
105
|
+
post:
|
|
106
|
+
tags:
|
|
107
|
+
- ⚡ Energetics
|
|
108
|
+
summary: Receive and save PRE data in CSV format
|
|
109
|
+
requestBody:
|
|
110
|
+
content:
|
|
111
|
+
text/csv:
|
|
112
|
+
schema:
|
|
113
|
+
$ref: "#/components/schemas/PreCsvMeasurement"
|
|
114
|
+
examples:
|
|
115
|
+
text/csv:
|
|
116
|
+
summary: Sample data
|
|
117
|
+
value:
|
|
118
|
+
"Počátek intervalu;Konec intervalu;859182400300027238 - Činná - spotřeba [kW];859182400300027238 - Induktivní - spotřeba [kVAr];859182400300027238 - Kapacitní - spotřeba [kVAr];
|
|
104
119
|
|
|
120
|
+
01.01.2021 00:00;01.01.2021 00:15;57,000;0,000;5,000;"
|
|
121
|
+
responses:
|
|
122
|
+
204:
|
|
123
|
+
description: OK
|
|
124
|
+
401:
|
|
125
|
+
$ref: "#/components/responses/UnauthorizedError"
|
|
126
|
+
422:
|
|
127
|
+
description: Error while validating input data
|
|
105
128
|
components:
|
|
106
129
|
responses:
|
|
107
130
|
UnauthorizedError:
|
|
@@ -145,6 +168,16 @@ components:
|
|
|
145
168
|
type: string
|
|
146
169
|
Status odečtu:
|
|
147
170
|
type: string
|
|
171
|
+
PreCsvMeasurement:
|
|
172
|
+
type: object
|
|
173
|
+
properties:
|
|
174
|
+
Počátek intervalu:
|
|
175
|
+
type: string
|
|
176
|
+
Konec intervalu:
|
|
177
|
+
type: string
|
|
178
|
+
required:
|
|
179
|
+
- Počátek intervalu
|
|
180
|
+
- Konec intervalu
|
|
148
181
|
PreMeasurement:
|
|
149
182
|
type: object
|
|
150
183
|
properties:
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreInputController.js","sourceRoot":"","sources":["../../../src/input-gateway/pre/PreInputController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAA8E;AAC9E,mFAAkF;AAClF,gGAAyE;AAGzE,6EAA8F;AAC9F,sFAAgE;AAEhE,MAAa,kBAAmB,SAAQ,4BAAc;IAClD,YAAoB,gBAAkC;QAClD,KAAK,CAAC,uBAAW,EAAE,IAAI,uCAAmB,CAAC,oBAAoB,EAAE,uCAAkB,CAAC,CAAC,CAAC;QADtE,qBAAgB,GAAhB,gBAAgB,CAAkB;QAI/C,gBAAW,GAAG,CAAO,SAAwB,EAAE,EAAE;YACpD,IAAI;gBACA,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACzC,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;gBAChF,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;oBAC1C,MAAM,IAAI,CAAC,qBAAqB,CAC5B,QAAQ,GAAG,IAAI,CAAC,WAAW,GAAG,4BAA4B,EAC1D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAC9B;wBACI,UAAU,EAAE,IAAI;qBACnB,CACJ,CAAC;iBACL;aACJ;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,GAAG,YAAY,qCAAoB,EAAE;oBACrC,MAAM,GAAG,CAAC;iBACb;qBAAM;oBACH,MAAM,IAAI,6BAAY,CAAC,oCAAoC,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;iBACrF;aACJ;QACL,CAAC,CAAA,CAAC;IAtBF,CAAC;CAuBJ;AA1BD,gDA0BC"}
|