"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logs = 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
    },
    type: {
        type: String
    },
    collection: {
        type: String
    },
    id_document: {
        type: String
    },
    payload: {
        type: String
    },
    method: {
        type: String
    },
    id_user: {
        type: String
    },
    user: {
        type: String
    },
    messageId: {
        type: Number
    },
    route: {
        type: String
    },
    client: {
        type: String
    },
    instance: {
        type: String
    },
    instance_index: {
        type: String,
        optional: true
    },
    correlationId: {
        type: String,
        optional: true
    }
};
exports.Logs = 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: 'logs',
            schema: schema,
            useVersionCollection: false,
            useReportBuilder: false,
            reportBuilderLookupTables: [],
            timestamps: true,
            createLogs: false,
            checkSchema: true,
            collectionOptions: null,
            skipCache: true,
            bypassSession: true
        });
        exports.Logs = model.collection_main;
        exports.Logs.createIndex({ createdAt: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 90 });
        exports.Logs.createIndex({ createdAt: -1, client: 1, type: 1, id_document: 1 });
    }
    else {
        setImmediate(function () {
            initializeCollection();
        });
    }
}

//# sourceMappingURL=log.collection.js.map
