"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportBuilderReportVersions = exports.ReportBuilderReports = 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
    },
    collection_root: {
        type: String
    },
    collection_joins: {
        type: Array,
        optional: true
    },
    'collection_joins.$': {
        type: Object
    },
    'collection_joins.$.collection': {
        type: String
    },
    'collection_joins.$.alias': {
        type: String,
        optional: true
    },
    'collection_joins.$.local_key': {
        type: String,
        optional: true
    },
    'collection_joins.$.foreign_key': {
        type: String,
        optional: true
    },
    report_name: {
        type: String
    },
    fields_sort: {
        type: Array
    },
    'fields_sort.$': {
        type: Object
    },
    'fields_sort.$.field': {
        type: String
    },
    'fields_sort.$.order': {
        type: String
    },
    fields_filter: {
        type: Array
    },
    'fields_filter.$': {
        type: Object,
        blackbox: true
    },
    fields_custom: {
        type: Array
    },
    'fields_custom.$': {
        type: Object,
        blackbox: true
    },
    fields_selected: {
        type: Array
    },
    'fields_selected.$': {
        type: Object,
        blackbox: true
    },
    fields_total: {
        type: Array
    },
    'fields_total.$': {
        type: Object,
        blackbox: true
    },
    fields_link: {
        type: Array
    },
    'fields_link.$': {
        type: Object,
        blackbox: true
    },
    id_user: {
        type: String
    },
    user: {
        type: String
    },
    date_created: {
        type: Date
    },
    active: {
        type: Boolean,
        optional: true
    },
    shared_users: {
        type: Array
    },
    'shared_users.$': {
        type: String
    },
    type: {
        type: String
    },
    groups_row: {
        type: Array
    },
    'groups_row.$': {
        type: Object,
        blackbox: true
    },
    groups_column: {
        type: Array
    },
    'groups_column.$': {
        type: Object,
        blackbox: true
    },
    group_type: {
        type: String
    },
    fields_layout: {
        type: Array,
        optional: true
    },
    'fields_layout.$': {
        type: Object,
        blackbox: true,
        optional: true
    },
    id_date_field: {
        type: String,
        optional: true
    },
    date_interval: {
        type: String,
        optional: true
    }
};
exports.ReportBuilderReports = null;
exports.ReportBuilderReportVersions = 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: 'report-builder-reports',
            schema: schema,
            useVersionCollection: true,
            useReportBuilder: false,
            reportBuilderLookupTables: [],
            timestamps: true,
            createLogs: true,
            checkSchema: true,
            collectionOptions: null
        });
        exports.ReportBuilderReports = model.collection_main;
        exports.ReportBuilderReports.createIndex({ id_user: 1 });
        exports.ReportBuilderReports.createIndex({ shared_users: 1 });
        exports.ReportBuilderReports.createIndex({ report_name: 1, collection_root: 1 });
        exports.ReportBuilderReportVersions = model.collection_version;
    }
    else {
        setImmediate(function () {
            initializeCollection();
        });
    }
}

//# sourceMappingURL=report-builder-report.collection.js.map
