"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RouteSubAgencyRepository = void 0;
const const_1 = require("../../../schema-definitions/const");
const ropid_gtfs_1 = require("../../../schema-definitions/ropid-gtfs");
const RouteSubAgencyDto_1 = require("../../../schema-definitions/ropid-gtfs/models/RouteSubAgencyDto");
const models_1 = require("@golemio/core/dist/integration-engine/models");
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
class RouteSubAgencyRepository extends models_1.PostgresModel {
    constructor() {
        super("RouteSubAgencyRepository", {
            pgTableName: ropid_gtfs_1.RopidGTFS.route_sub_agencies.pgTableName,
            pgSchema: const_1.PG_SCHEMA,
            outputSequelizeAttributes: RouteSubAgencyDto_1.RouteSubAgencyDto.attributeModel,
            savingType: "insertOnly",
        }, new golemio_validator_1.JSONSchemaValidator("RouteSubAgencyRepository", RouteSubAgencyDto_1.RouteSubAgencyDto.jsonSchema));
    }
    async findSubAgenciesByCisLineIds(cisLineIds) {
        try {
            return await this.sequelizeModel.findAll({
                attributes: ["route_licence_number", "route_id", "sub_agency_name"],
                where: {
                    route_licence_number: cisLineIds,
                },
            });
        }
        catch (err) {
            throw new golemio_errors_1.GeneralError("findSubAgenciesByCisLineIds: failed to get sub-agencies", this.name, err);
        }
    }
}
exports.RouteSubAgencyRepository = RouteSubAgencyRepository;
//# sourceMappingURL=RouteSubAgencyRepository.js.map