"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JISEventsModel = void 0;
const JISEventSeverityLevelEnum_1 = require("../../../helpers/jis/JISEventSeverityLevelEnum");
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
const jisEventCause_1 = require("../constants/jisEventCause");
const jisEventEffect_1 = require("../constants/jisEventEffect");
const jisEventType_1 = require("../constants/jisEventType");
class JISEventsModel extends sequelize_1.Model {
}
exports.JISEventsModel = JISEventsModel;
JISEventsModel.tableName = "jis_events";
JISEventsModel.attributeModel = {
    id: {
        primaryKey: true,
        allowNull: false,
        type: sequelize_1.DataTypes.UUID,
    },
    type: {
        type: sequelize_1.DataTypes.STRING(255),
        allowNull: false,
    },
    header_text: {
        type: sequelize_1.DataTypes.JSONB,
        allowNull: false,
    },
    cause: {
        type: sequelize_1.DataTypes.STRING(255),
        allowNull: false,
    },
    cause_detail: {
        type: sequelize_1.DataTypes.JSONB,
        allowNull: false,
    },
    severity_level: {
        type: sequelize_1.DataTypes.ENUM(...Object.values(JISEventSeverityLevelEnum_1.JISEventSeverityLevel)),
        allowNull: false,
    },
    active_period_start: {
        type: sequelize_1.DataTypes.DATE,
        allowNull: false,
    },
    active_period_end: {
        type: sequelize_1.DataTypes.DATE,
    },
    display_period_start: {
        type: sequelize_1.DataTypes.DATE,
        allowNull: false,
    },
    display_period_end: {
        type: sequelize_1.DataTypes.DATE,
    },
    effect: {
        type: sequelize_1.DataTypes.STRING(),
        allowNull: false,
    },
    effect_detail: {
        type: sequelize_1.DataTypes.JSONB,
        allowNull: false,
    },
    description_text: {
        type: sequelize_1.DataTypes.JSONB,
        allowNull: false,
    },
    description_html: {
        type: sequelize_1.DataTypes.JSONB,
        allowNull: false,
    },
    url: {
        type: sequelize_1.DataTypes.JSONB,
        allowNull: false,
    },
    organization_name: {
        type: sequelize_1.DataTypes.STRING(255),
        allowNull: false,
    },
    created_timestamp: {
        type: sequelize_1.DataTypes.DATE,
        allowNull: false,
    },
    updated_timestamp: {
        type: sequelize_1.DataTypes.DATE,
        allowNull: false,
    },
    deleted_timestamp: {
        type: sequelize_1.DataTypes.DATE,
        allowNull: true,
    },
    created_at: {
        type: sequelize_1.DataTypes.DATE,
        allowNull: false,
    },
    updated_at: {
        type: sequelize_1.DataTypes.DATE,
        allowNull: false,
    },
};
JISEventsModel.jsonSchema = {
    type: "array",
    items: {
        type: "object",
        properties: {
            id: { type: "string" },
            type: { type: "string", enum: jisEventType_1.jisEventType },
            header_text: { $ref: "#/definitions/Translation" },
            cause: { type: "string", enum: jisEventCause_1.jisEventCause },
            cause_detail: { $ref: "#/definitions/Translation" },
            severity_level: { type: "string", enum: Object.values(JISEventSeverityLevelEnum_1.JISEventSeverityLevel) },
            active_period_start: { type: "object", required: ["toISOString"] },
            active_period_end: {
                oneOf: [
                    { type: "object", required: ["toISOString"] },
                    { type: "null", nullable: true },
                ],
            },
            display_period_start: { type: "object", required: ["toISOString"] },
            display_period_end: {
                oneOf: [
                    { type: "object", required: ["toISOString"] },
                    { type: "null", nullable: true },
                ],
            },
            effect: {
                oneOf: [
                    {
                        type: "array",
                        items: { type: "string", enum: jisEventEffect_1.jisEventEffect },
                        minItems: 1,
                        maxItems: 3,
                        uniqueItems: true,
                    },
                    { type: "string", enum: jisEventEffect_1.jisEventEffect },
                ],
            },
            effect_detail: { $ref: "#/definitions/Translation" },
            description_text: { $ref: "#/definitions/Translation" },
            description_html: { $ref: "#/definitions/Translation" },
            url: { $ref: "#/definitions/Translation" },
            organization_name: { type: "string" },
            created_timestamp: { type: "object", required: ["toISOString"] },
            updated_timestamp: { type: "object", required: ["toISOString"] },
            deleted_timestamp: {
                oneOf: [
                    { type: "object", required: ["toISOString"] },
                    { type: "null", nullable: true },
                ],
            },
        },
        additionalProperties: false,
        required: [
            "id",
            "type",
            "header_text",
            "cause",
            "cause_detail",
            "severity_level",
            "effect",
            "effect_detail",
            "description_text",
            "description_html",
            "url",
            "organization_name",
            "created_timestamp",
            "updated_timestamp",
        ],
    },
    definitions: {
        Translation: {
            type: "object",
            properties: {
                cs: { type: "string" },
                en: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
            },
            additionalProperties: false,
            required: ["cs"],
        },
    },
};
//# sourceMappingURL=JISEventsModel.js.map