"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogSubscriptions = 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
    },
    type: {
        type: String
    },
    subscription: {
        type: String
    },
    collection_name: {
        type: String
    },
    subData: {
        type: String
    },
    client: {
        type: String
    },
    instance: {
        type: String
    },
    instance_index: {
        type: String,
        optional: true
    },
};
exports.LogSubscriptions = 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: 'log-subscriptions',
            schema: schema,
            useVersionCollection: false,
            useReportBuilder: true,
            reportBuilderLookupTables: [],
            timestamps: true,
            createLogs: false,
            checkSchema: true,
            collectionOptions: null,
            skipCache: true,
            bypassSession: true
        });
        exports.LogSubscriptions = model.collection_main;
        exports.LogSubscriptions.createIndex({ date: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 30 });
        exports.LogSubscriptions.createIndex({ type: 1 });
        exports.LogSubscriptions.createIndex({ collection_name: 1 });
        exports.LogSubscriptions.createIndex({ date: 1, type: 1 });
        exports.LogSubscriptions.createIndex({ createdAt: -1, client: 1 });
    }
    else {
        setImmediate(function () {
            initializeCollection();
        });
    }
}

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