UNPKG

@golemio/energetics

Version:
33 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PreCsvInputController = void 0; const controllers_1 = require("@golemio/core/dist/input-gateway/controllers"); const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator"); const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors"); const constants_1 = require("../../integration-engine/commodity-providers/constants"); const PreCsvInputSchema_1 = require("../../schema-definitions/datasources/PreCsvInputSchema"); class PreCsvInputController extends controllers_1.BaseController { constructor(transformation) { super(constants_1.WORKER_NAME, new golemio_validator_1.JSONSchemaValidator("PreCsvInputController", PreCsvInputSchema_1.preCsvInputSchema)); this.transformation = transformation; this.processData = async (inputData) => { try { await this.validator.Validate(inputData); const eanMeasurement = this.transformation.transformElement(inputData); await this.sendMessageToExchange("input." + this.queuePrefix + ".processPreEanMeasurements", JSON.stringify(eanMeasurement), { persistent: true, }); } catch (err) { if (err instanceof golemio_errors_1.AbstractGolemioError) { throw err; } else { throw new golemio_errors_1.GeneralError("Error while validating input data.", this.name, err, 422); } } }; } } exports.PreCsvInputController = PreCsvInputController; //# sourceMappingURL=PreCsvInputController.js.map