@golemio/energetics 1.4.9-dev.1622712529 → 1.4.9-dev.1624546011

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.
Files changed (25) hide show
  1. package/dist/input-gateway/pre/PreCsvInputController.d.ts +8 -0
  2. package/dist/input-gateway/pre/PreCsvInputController.js +42 -0
  3. package/dist/input-gateway/pre/PreCsvInputController.js.map +1 -0
  4. package/dist/input-gateway/pre/PreInputRouter.d.ts +4 -1
  5. package/dist/input-gateway/pre/PreInputRouter.js +21 -3
  6. package/dist/input-gateway/pre/PreInputRouter.js.map +1 -1
  7. package/dist/input-gateway/pre/{PreInputController.d.ts → PreJsonInputController.d.ts} +1 -1
  8. package/dist/input-gateway/pre/{PreInputController.js → PreJsonInputController.js} +5 -5
  9. package/dist/input-gateway/pre/PreJsonInputController.js.map +1 -0
  10. package/dist/input-gateway/pre/index.d.ts +1 -1
  11. package/dist/input-gateway/pre/index.js +1 -1
  12. package/dist/input-gateway/pre/index.js.map +1 -1
  13. package/dist/input-gateway/transformations/PreCsvInputTransformation.d.ts +8 -0
  14. package/dist/input-gateway/transformations/PreCsvInputTransformation.js +24 -0
  15. package/dist/input-gateway/transformations/PreCsvInputTransformation.js.map +1 -0
  16. package/dist/schema-definitions/datasources/PreCsvInputSchema.d.ts +3 -0
  17. package/dist/schema-definitions/datasources/PreCsvInputSchema.js +19 -0
  18. package/dist/schema-definitions/datasources/PreCsvInputSchema.js.map +1 -0
  19. package/dist/schema-definitions/datasources/interfaces/IPreCsvInput.d.ts +5 -0
  20. package/dist/schema-definitions/datasources/interfaces/IPreCsvInput.js +3 -0
  21. package/dist/schema-definitions/datasources/interfaces/IPreCsvInput.js.map +1 -0
  22. package/docs/implementation_documentation.md +8 -0
  23. package/docs/openapi-input.yaml +33 -0
  24. package/package.json +1 -1
  25. 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 controller;
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 PreInputController_1 = require("./PreInputController");
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.controller.processData(req.body);
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.controller = new PreInputController_1.PreInputController(new PreDataExtractor_1.PreDataExtractor());
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,6DAAgE;AAChE,kEAAgE;AAEhE,MAAa,cAAc;IAIvB;QAMQ,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;QAC9F,CAAC,CAAC;QAEM,gBAAW,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAiB,EAAE;YAC3F,IAAI;gBACA,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC5C,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aACvB;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,CAAC;aACb;QACL,CAAC,CAAA,CAAC;QAhBE,IAAI,CAAC,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,IAAI,uCAAkB,CAAC,IAAI,mCAAgB,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CAcJ;AAtBD,wCAsBC;AAED,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC,MAAM,CAAC;AAC1C,wCAAc"}
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 PreInputController extends BaseController {
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.PreInputController = void 0;
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 PreInputController extends controllers_1.BaseController {
18
+ class PreJsonInputController extends controllers_1.BaseController {
19
19
  constructor(preDataExtractor) {
20
- super(constants_1.WORKER_NAME, new golemio_validator_1.JSONSchemaValidator("PreInputController", PreJsonInputSchema_1.preJsonInputSchema));
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.PreInputController = PreInputController;
44
- //# sourceMappingURL=PreInputController.js.map
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 "./PreInputController";
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("./PreInputController"), exports);
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,uDAAqC"}
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,24 @@
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
+ T1_Wh_raw_data.push([row["Konec intervalu"], parseInt(row[`${ean} - Činná - spotřeba [kW]`])]);
14
+ }
15
+ return { ean, T1_Wh_raw_data };
16
+ };
17
+ this.getEan = (data) => {
18
+ const keys = Object.keys(data);
19
+ return keys[2].substring(0, 18);
20
+ };
21
+ }
22
+ }
23
+ exports.PreCsvInputTransformation = PreCsvInputTransformation;
24
+ //# 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,GAAyC,EAAE,CAAC;YAChE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAEjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;gBACpB,cAAc,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;aAClG;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;AAlBD,8DAkBC"}
@@ -0,0 +1,3 @@
1
+ import { JSONSchemaType } from "@golemio/core/dist/shared/ajv";
2
+ import { IPreCsvInput } from "./interfaces/IPreCsvInput";
3
+ export declare const preCsvInputSchema: JSONSchemaType<IPreCsvInput[]>;
@@ -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,5 @@
1
+ export interface IPreCsvInput {
2
+ "Počátek intervalu": string;
3
+ "Konec intervalu": string;
4
+ [eanCinna: string]: string;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IPreCsvInput.js.map
@@ -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é**:
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/energetics",
3
- "version": "1.4.9-dev.1622712529",
3
+ "version": "1.4.9-dev.1624546011",
4
4
  "description": "Golemio Energetics Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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"}