"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RopidVYMIEventsModel = void 0;
const const_1 = require("../../../schema-definitions/const");
const ropid_vymi_1 = require("../../../schema-definitions/ropid-vymi");
const models_1 = require("@golemio/core/dist/integration-engine/models");
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
/**
 * Custom Postgres model for Ropid VYMI Events
 */
class RopidVYMIEventsModel extends models_1.PostgresModel {
    constructor(addAuditAttributes = false) {
        super(ropid_vymi_1.RopidVYMI.events.name + "Model", {
            hasTmpTable: true,
            outputSequelizeAttributes: ropid_vymi_1.RopidVYMI.events.outputSequelizeAttributes,
            pgTableName: ropid_vymi_1.RopidVYMI.events.pgTableName,
            pgSchema: const_1.PG_SCHEMA,
            savingType: "insertOnly",
            addAuditAttributes: addAuditAttributes,
        }, new golemio_validator_1.JSONSchemaValidator(ropid_vymi_1.RopidVYMI.events.name + "ModelValidator", ropid_vymi_1.RopidVYMI.events.outputJsonSchema));
    }
    getCurrentAlerts(currentDate) {
        return this.find({
            where: {
                record_type: 1,
                expiration_date: {
                    [sequelize_1.Op.or]: {
                        [sequelize_1.Op.eq]: null,
                        [sequelize_1.Op.gte]: currentDate,
                    },
                },
            },
            raw: true,
        });
    }
}
exports.RopidVYMIEventsModel = RopidVYMIEventsModel;
//# sourceMappingURL=RopidVYMIEventsModel.js.map