UNPKG

@golemio/parkings

Version:
78 lines 3.5 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TSKParkingTransformation = void 0; const SourceEnum_1 = require("../../helpers/constants/SourceEnum"); const _sch_1 = require("../../schema-definitions"); const integration_engine_1 = require("@golemio/core/dist/integration-engine"); const config_1 = require("@golemio/core/dist/integration-engine/config"); const uuid_by_string_1 = __importDefault(require("uuid-by-string")); const ZoneType = { RES: "zone_residential", MIX: "zone_mixed", VIS: "zone_visitors", OST: "zone_other", // FREE: "zone_free", // (placeholder pro Zóny neplaceného stání, které se budou integrovat v budoucnu) }; class TSKParkingTransformation extends integration_engine_1.BaseTransformation { constructor(transformationDate) { super(); this.transform = async (data) => { const result = { parking: [], payment: [], }; for (const element of data) { const { parking, payment } = this.transformElement(element); result.parking.push(parking); result.payment.push(payment); } return result; }; this.transformElement = (element) => { const id = `${this.dataSource}-${element.properties.tarifTab}`.toLowerCase(); return { parking: { id, source: this.dataSource, source_id: "" + element.properties.tarifTab, data_provider: "www.tsk-praha.cz", location: element.geometry, total_spot_number: element.properties.ps_zps_celkem, name: element.properties.ulice, category: ZoneType[element.properties.typZony], valid_from: element.properties.platnostOd, valid_to: element.properties.platnostDo, parking_type: "on_street", zone_type: ZoneType[element.properties.typZony], date_modified: this.transformationDate, active: true, }, payment: { parking_id: id, source: this.dataSource, payment_web_url: config_1.config.PARKING_ZONES_PAYMENT_URL + "?shortname=" + element.properties.tarifTab, }, }; }; this.transformParkingTariffsRelation = (parkings) => { const parkingTariffsIdPairs = []; for (const parking of parkings) { const id = `${this.dataSource}-${parking.properties.tarifTab}`.toLowerCase(); parkingTariffsIdPairs.push({ parking_id: id, tariff_id: (0, uuid_by_string_1.default)(`${this.dataSource}`.toUpperCase() + parking.properties.CTARIF), source: this.dataSource, }); } return parkingTariffsIdPairs; }; this.name = _sch_1.Parkings.tsk.name + "Data"; this.dataSource = SourceEnum_1.SourceEnum.TSK; this.transformationDate = transformationDate; } } exports.TSKParkingTransformation = TSKParkingTransformation; //# sourceMappingURL=TSKParkingTransformation.js.map