"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailHistories = void 0;
var mongo_manager_1 = require("../managers/mongo.manager");
var resolveio_server_app_1 = require("../resolveio-server-app");
var schema = {
    _id: {
        type: String,
        optional: true
    },
    __v: {
        type: Number,
        optional: true
    },
    updatedAt: {
        type: Date,
        optional: true
    },
    createdAt: {
        type: Date,
        optional: true
    },
    date: {
        type: Date
    },
    id_user: {
        type: String
    },
    user: {
        type: String
    },
    email: {
        type: String
    },
    subject: {
        type: String
    },
    text: {
        type: String
    },
    html: {
        type: String
    },
    attachments: {
        type: Array
    },
    'attachments.$': {
        type: Object,
        blackbox: true
    },
    cc: {
        type: Array,
        optional: true
    },
    'cc.$': {
        type: String
    },
    send_from: {
        type: String
    },
    reply_to: {
        type: String
    },
    status: {
        type: String
    },
    error: {
        type: String
    },
    processingAt: {
        type: Date,
        optional: true
    },
    completedAt: {
        type: Date,
        optional: true
    },
    force_ses: {
        type: Boolean,
        optional: true
    },
    headers: {
        type: Object,
        optional: true,
        blackbox: true
    },
    correlationId: {
        type: String,
        optional: true
    },
    meta: {
        type: Object,
        optional: true,
        blackbox: true
    },
    occurrences: {
        type: Array,
        optional: true
    },
    'occurrences.$': {
        type: Object,
        optional: true,
        blackbox: true
    }
};
exports.EmailHistories = null;
initializeCollection();
function initializeCollection() {
    if (resolveio_server_app_1.ResolveIOServer && resolveio_server_app_1.ResolveIOServer.getMainDB() && mongo_manager_1.MongoManagerModel) {
        var model = mongo_manager_1.MongoManagerModel.create({
            collectionName: 'email-histories',
            schema: schema,
            useVersionCollection: false,
            useReportBuilder: false,
            reportBuilderLookupTables: [],
            timestamps: true,
            createLogs: false,
            checkSchema: true,
            collectionOptions: null,
            skipCache: true,
            bypassSession: true
        });
        exports.EmailHistories = model.collection_main;
        exports.EmailHistories.createIndex({ status: 1 });
        exports.EmailHistories.createIndex({ createdAt: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 90 });
    }
    else {
        setImmediate(function () {
            initializeCollection();
        });
    }
}

//# sourceMappingURL=email-history.collection.js.map
