"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserVersions = exports.Users = 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
    },
    roles: {
        type: Object
    },
    'roles.super_admin': {
        type: Boolean
    },
    'roles.approvals': {
        type: Array
    },
    'roles.approvals.$': {
        type: Object
    },
    'roles.approvals.$.type': {
        type: String
    },
    'roles.approvals.$.key_1': {
        type: String,
        optional: true
    },
    'roles.approvals.$.key_2': {
        type: String,
        optional: true
    },
    'roles.approvals.$.key_3': {
        type: String,
        optional: true
    },
    'roles.approvals.$.name': {
        type: String
    },
    'roles.groups': {
        type: Array
    },
    'roles.groups.$': {
        type: Object
    },
    'roles.groups.$.name': {
        type: String
    },
    'roles.groups.$.views': {
        type: Array
    },
    'roles.groups.$.views.$': {
        type: String
    },
    'roles.groups.$.yards': {
        type: Array,
        optional: true
    },
    'roles.groups.$.yards.$': {
        type: String
    },
    'roles.notifications': {
        type: Array
    },
    'roles.notifications.$': {
        type: String
    },
    'roles.miscs': {
        type: Array
    },
    'roles.miscs.$': {
        type: String
    },
    username: {
        type: String,
        optional: true
    },
    email: {
        type: String,
        optional: true
    },
    fullname: {
        type: String
    },
    active: {
        type: Boolean
    },
    phonenumber: {
        type: String,
        optional: true
    },
    readonly: {
        type: Boolean,
        optional: true
    },
    other: {
        type: Object,
        blackbox: true
    },
    settings: {
        type: Object,
        optional: true,
        blackbox: true
    },
    salt: {
        type: String
    },
    hash: {
        type: String
    },
    attempts: {
        type: Number
    },
    last: {
        type: Date,
        optional: true
    },
    services: {
        type: Object,
        optional: true
    },
    'services.enrollment': {
        type: String,
        optional: true
    },
    'services.forgot_password': {
        type: String,
        optional: true
    },
    'services.reset_password': {
        type: String,
        optional: true
    },
    is_customer: {
        type: Boolean,
        optional: true
    }
};
exports.Users = null;
exports.UserVersions = 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: 'users',
            schema: schema,
            useVersionCollection: true,
            useReportBuilder: true,
            reportBuilderLookupTables: [],
            timestamps: true,
            createLogs: true,
            checkSchema: true,
            collectionOptions: null
        });
        exports.Users = model.collection_main;
        exports.Users.createIndex({ fullname: 1 });
        exports.Users.createIndex({ active: 1 });
        exports.UserVersions = model.collection_version;
    }
    else {
        setImmediate(function () {
            initializeCollection();
        });
    }
}

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