"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RopidDeparturesDirectionsModel = void 0;
const const_1 = require("../../../schema-definitions/const");
const ropid_departures_directions_1 = require("../../../schema-definitions/ropid-departures-directions");
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
const sequelize_1 = __importDefault(require("@golemio/core/dist/shared/sequelize"));
/**
 * Custom Postgres model for Ropid Departures Directions
 */
class RopidDeparturesDirectionsModel extends output_gateway_1.SequelizeModel {
    constructor() {
        super(ropid_departures_directions_1.RopidDeparturesDirections.departureDirections.name + "Model", ropid_departures_directions_1.RopidDeparturesDirections.departureDirections.pgTableName, ropid_departures_directions_1.RopidDeparturesDirections.departureDirections.outputSequelizeAttributes, { schema: const_1.PG_SCHEMA });
        this.convertItem = (item) => {
            // converting types
            return {
                ...item,
                next_stop_id_regexp: new RegExp(item.next_stop_id_regexp),
                direction: item.direction,
            };
        };
        this.convertItems = (items) => {
            return items.map((item) => this.convertItem(item));
        };
    }
    GetOne(id) {
        throw new Error("Method not implemented.");
    }
    async GetAll(stopsIds) {
        if (!stopsIds || stopsIds.length === 0) {
            return [];
        }
        return this.convertItems((await this.sequelizeModel.findAll({
            where: {
                departure_stop_id: {
                    [sequelize_1.default.Op.in]: stopsIds,
                },
            },
            order: [
                ["departure_stop_id", "asc"],
                ["rule_order", "asc"],
            ],
            raw: true,
        })));
    }
}
exports.RopidDeparturesDirectionsModel = RopidDeparturesDirectionsModel;
//# sourceMappingURL=RopidDeparturesDirectionsModel.js.map