@golemio/pid
Version:
Golemio PID Module
67 lines • 3.74 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JISEventsCustomFormatTransformation = void 0;
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
const JISEventTranslationHelper_1 = require("../../../helpers/jis/JISEventTranslationHelper");
const JISEventEffectHelper_1 = require("../../../helpers/jis/JISEventEffectHelper");
let JISEventsCustomFormatTransformation = class JISEventsCustomFormatTransformation extends AbstractTransformation_1.AbstractTransformation {
constructor() {
super(...arguments);
this.name = "JISEventsCustomFormatTransformation";
this.transformInternal = (event) => {
return {
id: event.id,
type: event.type,
header_text: event.header_text,
cause: {
cs: JISEventTranslationHelper_1.JISEventTranslationHelper.causeToCs(event.cause),
en: JISEventTranslationHelper_1.JISEventTranslationHelper.causeToEn(event.cause),
},
cause_detail: event.cause_detail,
severity_level: event.severity_level,
active_period: {
start: event.active_period_start.toISOString(),
end: event.active_period_end?.toISOString() || null,
},
display_period: {
start: event.display_period_start.toISOString(),
end: event.display_period_end?.toISOString() || null,
},
effects: this.effectsToTranslation(event.effect),
description_text: event.description_text,
description_html: event.description_html,
organization_name: event.organization_name,
informed_entity: {
routes: event.routes?.map((route) => ({
id: route.route_id,
route_short_name: route.route_short_name,
route_long_name: route.route_long_name,
route_type: route.route_type,
})) || [],
},
last_modified_timestamp: event.updated_timestamp.toISOString(),
created_timestamp: event.created_timestamp.toISOString(),
};
};
}
effectsToTranslation(effect) {
return JISEventEffectHelper_1.JISEventEffectHelper.getEffectAsList(effect).map((effect) => {
return {
cs: JISEventTranslationHelper_1.JISEventTranslationHelper.effectToCs(effect),
en: effect.charAt(0).toUpperCase() + effect.slice(1).toLowerCase().replaceAll("_", " "),
};
});
}
};
exports.JISEventsCustomFormatTransformation = JISEventsCustomFormatTransformation;
exports.JISEventsCustomFormatTransformation = JISEventsCustomFormatTransformation = __decorate([
(0, tsyringe_1.injectable)()
], JISEventsCustomFormatTransformation);
//# sourceMappingURL=JISEventsCustomFormatTransformation.js.map