"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CronJobs = void 0;
var simpl_schema_1 = require("simpl-schema");
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
    },
    name: {
        type: String
    },
    repeat: {
        type: Boolean
    },
    time_to_run: {
        type: simpl_schema_1.default.oneOf(String, Date)
    },
    method_run: {
        type: String
    },
    method_run_data: {
        type: Object,
        blackbox: true,
        optional: true
    },
    method_complete: {
        type: String,
        optional: true
    },
    method_complete_data: {
        type: Object,
        blackbox: true,
        optional: true
    },
    save_history: {
        type: Boolean,
        optional: true
    },
    running: {
        type: Boolean
    },
    timezone: {
        type: String
    },
    next_run: {
        type: Date,
        optional: true
    }
};
exports.CronJobs = 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: 'cron-jobs',
            schema: schema,
            useVersionCollection: false,
            useReportBuilder: false,
            reportBuilderLookupTables: [],
            timestamps: true,
            createLogs: false,
            checkSchema: true,
            collectionOptions: null,
            skipCache: true,
            bypassSession: true
        });
        exports.CronJobs = model.collection_main;
        exports.CronJobs.createIndex({ running: 1 });
    }
    else {
        setImmediate(function () {
            initializeCollection();
        });
    }
}

//# sourceMappingURL=cron-job.collection.js.map
