"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.processLocalTransaction = processLocalTransaction;
exports.chooseOperation = chooseOperation;
exports.getOperationFunction = getOperationFunction;
exports.operation = operation;
exports.executeJob = executeJob;
const search_js_1 = __importDefault(require("../../dataLayer/search.js"));
const bulkLoad_js_1 = __importDefault(require("../../dataLayer/bulkLoad.js"));
const schema_js_1 = __importDefault(require("../../dataLayer/schema.js"));
const schemaDescribe_js_1 = __importDefault(require("../../dataLayer/schemaDescribe.js"));
const delete_js_1 = __importDefault(require("../../dataLayer/delete.js"));
const readAuditLog_js_1 = __importDefault(require("../../dataLayer/readAuditLog.js"));
const user = __importStar(require("../../security/user.js"));
const role_js_1 = __importDefault(require("../../security/role.js"));
const operations_js_1 = __importDefault(require("../../components/operations.js"));
const harper_logger_js_1 = __importDefault(require("../../utility/logging/harper_logger.js"));
const readLog_js_1 = __importDefault(require("../../utility/logging/readLog.js"));
const export_js_1 = __importDefault(require("../../dataLayer/export.js"));
const operation_authorization_js_1 = __importDefault(require("../../utility/operation_authorization.js"));
const jobs_js_1 = __importDefault(require("../jobs/jobs.js"));
const terms = __importStar(require("../../utility/hdbTerms.js"));
const hdbError_js_1 = require("../../utility/errors/hdbError.js");
const { HTTP_STATUS_CODES } = hdbError_js_1.hdbErrors;
const restart_js_1 = __importDefault(require("../../bin/restart.js"));
const util = __importStar(require("util"));
const insert_js_1 = __importDefault(require("../../dataLayer/insert.js"));
const globalSchema_js_1 = __importDefault(require("../../utility/globalSchema.js"));
const systemInformation_js_1 = __importDefault(require("../../utility/environment/systemInformation.js"));
const jobRunner_js_1 = __importDefault(require("../jobs/jobRunner.js"));
const tokenAuthentication = __importStar(require("../../security/tokenAuthentication.js"));
const auth = __importStar(require("../../security/auth.js"));
const configUtils_js_1 = __importDefault(require("../../config/configUtils.js"));
const transactionLog_js_1 = __importDefault(require("../../utility/logging/transactionLog.js"));
const npmUtilities_js_1 = __importDefault(require("../../utility/npmUtilities.js"));
const globals_js_1 = require("../../globals.js");
const common_utils_js_1 = require("../../utility/common_utils.js");
const Server_ts_1 = require("../Server.js");
const operationLog = harper_logger_js_1.default.loggerWithTag('operation');
const analytics = __importStar(require("../../resources/analytics/read.js"));
const OperationFunctionCaller_js_1 = __importDefault(require("../../utility/OperationFunctionCaller.js"));
const status = __importStar(require("../status/index.js"));
const regDeprecated = __importStar(require("../../resources/registrationDeprecated.js"));
const pSearchSearch = util.promisify(search_js_1.default.search);
let pEvaluateSql;
function evaluateSQL(command) {
    if (!pEvaluateSql) {
        const sql = require('../../sqlTranslator/index.js');
        pEvaluateSql = util.promisify(sql.evaluateSQL);
    }
    return pEvaluateSql(command);
}
const GLOBAL_SCHEMA_UPDATE_OPERATIONS_ENUM = {
    [terms.OPERATIONS_ENUM.CREATE_ATTRIBUTE]: true,
    [terms.OPERATIONS_ENUM.CREATE_TABLE]: true,
    [terms.OPERATIONS_ENUM.CREATE_SCHEMA]: true,
    [terms.OPERATIONS_ENUM.DROP_ATTRIBUTE]: true,
    [terms.OPERATIONS_ENUM.DROP_TABLE]: true,
    [terms.OPERATIONS_ENUM.DROP_SCHEMA]: true,
};
const OperationFunctionObject_ts_1 = require("./OperationFunctionObject.js");
/**
 * This will process a command message on this receiving node rather than sending it to a remote node.  NOTE: this function
 * handles the response to the sender.
 */
// TODO: Replace Function type with an actual function type (e.g. (): Thingy)
async function processLocalTransaction(req, operationFunction) {
    try {
        if (req.body.operation !== 'read_log' &&
            (harper_logger_js_1.default.log_level === terms.LOG_LEVELS.INFO ||
                harper_logger_js_1.default.log_level === terms.LOG_LEVELS.DEBUG ||
                harper_logger_js_1.default.log_level === terms.LOG_LEVELS.TRACE)) {
            // Need to remove auth variables, but we don't want to create an object unless
            // the logging is actually going to happen.
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
            const { hdb_user, hdbAuthHeader, password, payload, ...cleanBody } = req.body;
            operationLog.info(cleanBody);
        }
    }
    catch (e) {
        operationLog.error(e);
    }
    let data = await OperationFunctionCaller_js_1.default.callOperationFunctionAsAwait(operationFunction, req.body, null);
    if (typeof data !== 'object') {
        data = { message: data };
    }
    if (data instanceof Error) {
        throw data;
    }
    if (GLOBAL_SCHEMA_UPDATE_OPERATIONS_ENUM[req.body.operation]) {
        globalSchema_js_1.default.setSchemaDataToGlobal((err) => {
            if (err) {
                operationLog.error(err);
            }
        });
    }
    return data;
}
const OPERATION_FUNCTION_MAP = initializeOperationFunctionMap();
Server_ts_1.server.operation = operation;
/**
 * Register an operation function with the server.
 * @param operationDefinition
 */
Server_ts_1.server.registerOperation = (operationDefinition) => {
    OPERATION_FUNCTION_MAP.set(operationDefinition.name, new OperationFunctionObject_ts_1.OperationFunctionObject(operationDefinition.execute));
};
function chooseOperation(json) {
    let getOpResult;
    try {
        getOpResult = getOperationFunction(json);
    }
    catch (err) {
        operationLog.error(`Error when selecting operation function - ${err}`);
        throw err;
    }
    const { operation_function, job_operation_function } = getOpResult;
    // Here there is a SQL statement in either the operation or the searchOperation (from jobs like export_local).  Need to check the perms
    // on all affected tables/attributes.
    try {
        if (json.operation === 'sql' || (json.search_operation && json.search_operation.operation === 'sql')) {
            const sql = require('../../sqlTranslator/index.js');
            const sqlStatement = json.operation === 'sql' ? json.sql : json.search_operation.sql;
            const parsedSqlObject = sql.convertSQLToAST(sqlStatement);
            json.parsed_sql_object = parsedSqlObject;
            if (!json.bypass_auth) {
                const astPermCheck = sql.checkASTPermissions(json, parsedSqlObject);
                if (astPermCheck) {
                    operationLog.error(`${HTTP_STATUS_CODES.FORBIDDEN} from operation ${json.operation}`);
                    operationLog.warn(`User '${json.hdb_user?.username}' is not permitted to ${json.operation}`);
                    throw (0, hdbError_js_1.handleHDBError)(new Error(), astPermCheck, hdbError_js_1.hdbErrors.HTTP_STATUS_CODES.FORBIDDEN, undefined, undefined, true);
                }
            }
            //we need to bypass permission checks to allow the createAuthorizationTokens
        }
        else if (!json.bypass_auth &&
            json.operation !== terms.OPERATIONS_ENUM.CREATE_AUTHENTICATION_TOKENS &&
            json.operation !== terms.OPERATIONS_ENUM.LOGIN &&
            json.operation !== terms.OPERATIONS_ENUM.LOGOUT) {
            const functionToCheck = job_operation_function === undefined ? operation_function : job_operation_function;
            const operation_json = json.search_operation ? json.search_operation : json;
            if (!operation_json.hdb_user) {
                operation_json.hdb_user = json.hdb_user;
            }
            const verifyPermsResult = operation_authorization_js_1.default.verifyPerms(operation_json, functionToCheck);
            if (verifyPermsResult) {
                operationLog.error(`${HTTP_STATUS_CODES.FORBIDDEN} from operation ${json.operation}`);
                operationLog.warn(`User '${operation_json.hdb_user?.username}' is not permitted to ${operation_json.operation}`);
                throw (0, hdbError_js_1.handleHDBError)(new Error(), verifyPermsResult, hdbError_js_1.hdbErrors.HTTP_STATUS_CODES.FORBIDDEN, undefined, false, true);
            }
        }
    }
    catch (err) {
        throw (0, hdbError_js_1.handleHDBError)(err, `There was an error when trying to choose an operation path`);
    }
    return operation_function;
}
function getOperationFunction(json) {
    operationLog.trace(`getOperationFunction with operation: ${json.operation}`);
    if (OPERATION_FUNCTION_MAP.has(json.operation)) {
        return OPERATION_FUNCTION_MAP.get(json.operation);
    }
    throw (0, hdbError_js_1.handleHDBError)(new Error(), hdbError_js_1.hdbErrors.HDB_ERROR_MSGS.OP_NOT_FOUND(json.operation), hdbError_js_1.hdbErrors.HTTP_STATUS_CODES.BAD_REQUEST, undefined, undefined, true);
}
(0, globals_js_1._assignPackageExport)('operation', operation);
/**
 * Standalone function to execute an operation
 */
function operation(operation, context, authorize) {
    operation.hdb_user = context?.user;
    operation.bypass_auth = !authorize;
    const operation_function = chooseOperation(operation);
    return processLocalTransaction({ body: operation }, operation_function);
}
async function catchup(req) {
    operationLog.trace('In serverUtils.catchup');
    const catchupObject = req.transaction;
    const splitChannel = catchupObject.channel.split(':');
    const _schema = splitChannel[0];
    const table = splitChannel[1];
    for (const transaction of catchupObject.transactions) {
        try {
            transaction.schema = _schema;
            transaction.table = table;
            switch (transaction.operation) {
                case terms.OPERATIONS_ENUM.INSERT:
                    await insert_js_1.default.insert(transaction);
                    break;
                case terms.OPERATIONS_ENUM.UPDATE:
                    await insert_js_1.default.update(transaction);
                    break;
                case terms.OPERATIONS_ENUM.UPSERT:
                    await insert_js_1.default.upsert(transaction);
                    break;
                case terms.OPERATIONS_ENUM.DELETE:
                    await delete_js_1.default.deleteRecord(transaction);
                    break;
                default:
                    operationLog.warn('invalid operation in catchup');
                    break;
            }
        }
        catch (e) {
            operationLog.info('Invalid operation in transaction');
            operationLog.error(e);
        }
    }
}
async function executeJob(json) {
    (0, common_utils_js_1.transformReq)(json);
    let newJobObject;
    let result;
    try {
        result = await jobs_js_1.default.addJob(json);
        if (result) {
            newJobObject = result.createdJob;
            operationLog.info('addJob result', result);
            const jobRunnerMessage = new jobRunner_js_1.default.RunnerMessage(newJobObject, json);
            const returnMessage = await jobRunner_js_1.default.parseMessage(jobRunnerMessage);
            return {
                message: returnMessage ?? `Starting job with id ${newJobObject.id}`,
                job_id: newJobObject.id,
            };
        }
    }
    catch (err) {
        const error = err instanceof Error ? err : null;
        const message = `There was an error executing job: ${error && 'http_resp_msg' in error ? error.http_resp_msg : err}`;
        operationLog.error(message);
        throw (0, hdbError_js_1.handleHDBError)(err, message);
    }
}
function initializeOperationFunctionMap() {
    const opFuncMap = new Map();
    opFuncMap.set(terms.OPERATIONS_ENUM.INSERT, new OperationFunctionObject_ts_1.OperationFunctionObject(insert_js_1.default.insert));
    opFuncMap.set(terms.OPERATIONS_ENUM.UPDATE, new OperationFunctionObject_ts_1.OperationFunctionObject(insert_js_1.default.update));
    opFuncMap.set(terms.OPERATIONS_ENUM.UPSERT, new OperationFunctionObject_ts_1.OperationFunctionObject(insert_js_1.default.upsert));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_CONDITIONS, new OperationFunctionObject_ts_1.OperationFunctionObject(search_js_1.default.searchByConditions));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_HASH, new OperationFunctionObject_ts_1.OperationFunctionObject(search_js_1.default.searchByHash));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_ID, new OperationFunctionObject_ts_1.OperationFunctionObject(search_js_1.default.searchByHash));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_VALUE, new OperationFunctionObject_ts_1.OperationFunctionObject(search_js_1.default.searchByValue));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH, new OperationFunctionObject_ts_1.OperationFunctionObject(pSearchSearch));
    opFuncMap.set(terms.OPERATIONS_ENUM.SQL, new OperationFunctionObject_ts_1.OperationFunctionObject(evaluateSQL));
    opFuncMap.set(terms.OPERATIONS_ENUM.CSV_DATA_LOAD, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, bulkLoad_js_1.default.csvDataLoad));
    opFuncMap.set(terms.OPERATIONS_ENUM.CSV_FILE_LOAD, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, bulkLoad_js_1.default.csvFileLoad));
    opFuncMap.set(terms.OPERATIONS_ENUM.CSV_URL_LOAD, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, bulkLoad_js_1.default.csvURLLoad));
    opFuncMap.set(terms.OPERATIONS_ENUM.IMPORT_FROM_S3, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, bulkLoad_js_1.default.importFromS3));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_SCHEMA, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.createSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_DATABASE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.createSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_TABLE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.createTable));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_ATTRIBUTE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.createAttribute));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_SCHEMA, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.dropSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_DATABASE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.dropSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_TABLE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.dropTable));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_ATTRIBUTE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.dropAttribute));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_SCHEMA, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe_js_1.default.describeSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_DATABASE, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe_js_1.default.describeSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_TABLE, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe_js_1.default.describeTable));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_ALL, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe_js_1.default.describeAll));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE, new OperationFunctionObject_ts_1.OperationFunctionObject(delete_js_1.default.deleteRecord));
    opFuncMap.set(terms.OPERATIONS_ENUM.ADD_USER, new OperationFunctionObject_ts_1.OperationFunctionObject(user.addUser));
    opFuncMap.set(terms.OPERATIONS_ENUM.ALTER_USER, new OperationFunctionObject_ts_1.OperationFunctionObject(user.alterUser));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_USER, new OperationFunctionObject_ts_1.OperationFunctionObject(user.dropUser));
    opFuncMap.set(terms.OPERATIONS_ENUM.LIST_USERS, new OperationFunctionObject_ts_1.OperationFunctionObject(user.listUsersExternal));
    opFuncMap.set(terms.OPERATIONS_ENUM.LIST_ROLES, new OperationFunctionObject_ts_1.OperationFunctionObject(role_js_1.default.listRoles));
    opFuncMap.set(terms.OPERATIONS_ENUM.ADD_ROLE, new OperationFunctionObject_ts_1.OperationFunctionObject(role_js_1.default.addRole));
    opFuncMap.set(terms.OPERATIONS_ENUM.ALTER_ROLE, new OperationFunctionObject_ts_1.OperationFunctionObject(role_js_1.default.alterRole));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_ROLE, new OperationFunctionObject_ts_1.OperationFunctionObject(role_js_1.default.dropRole));
    opFuncMap.set(terms.OPERATIONS_ENUM.USER_INFO, new OperationFunctionObject_ts_1.OperationFunctionObject(user.userInfo));
    opFuncMap.set(terms.OPERATIONS_ENUM.READ_LOG, new OperationFunctionObject_ts_1.OperationFunctionObject(readLog_js_1.default));
    opFuncMap.set(terms.OPERATIONS_ENUM.SET_CONFIGURATION, new OperationFunctionObject_ts_1.OperationFunctionObject(configUtils_js_1.default.setConfiguration));
    opFuncMap.set(terms.OPERATIONS_ENUM.EXPORT_TO_S3, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, export_js_1.default.export_to_s3));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_FILES_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, delete_js_1.default.deleteFilesBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_RECORDS_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, delete_js_1.default.deleteFilesBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.EXPORT_LOCAL, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, export_js_1.default.export_local));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_JOBS_BY_START_DATE, new OperationFunctionObject_ts_1.OperationFunctionObject(jobs_js_1.default.handleGetJobsByStartDate));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_JOB, new OperationFunctionObject_ts_1.OperationFunctionObject(jobs_js_1.default.handleGetJob));
    opFuncMap.set(terms.OPERATIONS_ENUM.REGISTRATION_INFO, new OperationFunctionObject_ts_1.OperationFunctionObject(regDeprecated.getRegistrationInfo));
    opFuncMap.set(terms.OPERATIONS_ENUM.RESTART, new OperationFunctionObject_ts_1.OperationFunctionObject(restart_js_1.default.restart));
    opFuncMap.set(terms.OPERATIONS_ENUM.RESTART_SERVICE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, restart_js_1.default.restartService));
    opFuncMap.set(terms.OPERATIONS_ENUM.CATCHUP, new OperationFunctionObject_ts_1.OperationFunctionObject(catchup));
    opFuncMap.set(terms.OPERATIONS_ENUM.SYSTEM_INFORMATION, new OperationFunctionObject_ts_1.OperationFunctionObject(systemInformation_js_1.default.systemInformation));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_AUDIT_LOGS_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, delete_js_1.default.deleteAuditLogsBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.READ_AUDIT_LOG, new OperationFunctionObject_ts_1.OperationFunctionObject(readAuditLog_js_1.default));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_AUTHENTICATION_TOKENS, new OperationFunctionObject_ts_1.OperationFunctionObject(tokenAuthentication.createTokens));
    opFuncMap.set(terms.OPERATIONS_ENUM.REFRESH_OPERATION_TOKEN, new OperationFunctionObject_ts_1.OperationFunctionObject(tokenAuthentication.refreshOperationToken));
    opFuncMap.set(terms.OPERATIONS_ENUM.LOGIN, new OperationFunctionObject_ts_1.OperationFunctionObject(auth.login));
    opFuncMap.set(terms.OPERATIONS_ENUM.LOGOUT, new OperationFunctionObject_ts_1.OperationFunctionObject(auth.logout));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_CONFIGURATION, new OperationFunctionObject_ts_1.OperationFunctionObject(configUtils_js_1.default.getConfiguration));
    opFuncMap.set(terms.OPERATIONS_ENUM.CUSTOM_FUNCTIONS_STATUS, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.customFunctionsStatus));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_CUSTOM_FUNCTIONS, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.getCustomFunctions));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_COMPONENT_FILE, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.getComponentFile));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_COMPONENTS, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.getComponents));
    opFuncMap.set(terms.OPERATIONS_ENUM.SET_COMPONENT_FILE, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.setComponentFile));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_COMPONENT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.dropComponent));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_CUSTOM_FUNCTION, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.getCustomFunction));
    opFuncMap.set(terms.OPERATIONS_ENUM.SET_CUSTOM_FUNCTION, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.setCustomFunction));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_CUSTOM_FUNCTION, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.dropCustomFunction));
    opFuncMap.set(terms.OPERATIONS_ENUM.ADD_CUSTOM_FUNCTION_PROJECT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.addComponent));
    opFuncMap.set(terms.OPERATIONS_ENUM.ADD_COMPONENT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.addComponent));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_CUSTOM_FUNCTION_PROJECT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.dropCustomFunctionProject));
    opFuncMap.set(terms.OPERATIONS_ENUM.PACKAGE_CUSTOM_FUNCTION_PROJECT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.packageComponent));
    opFuncMap.set(terms.OPERATIONS_ENUM.PACKAGE_COMPONENT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.packageComponent));
    opFuncMap.set(terms.OPERATIONS_ENUM.DEPLOY_CUSTOM_FUNCTION_PROJECT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.deployComponent));
    opFuncMap.set(terms.OPERATIONS_ENUM.DEPLOY_COMPONENT, new OperationFunctionObject_ts_1.OperationFunctionObject(operations_js_1.default.deployComponent));
    opFuncMap.set(terms.OPERATIONS_ENUM.READ_TRANSACTION_LOG, new OperationFunctionObject_ts_1.OperationFunctionObject(transactionLog_js_1.default.readTransactionLog));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_TRANSACTION_LOGS_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, transactionLog_js_1.default.deleteTransactionLogsBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.INSTALL_NODE_MODULES, new OperationFunctionObject_ts_1.OperationFunctionObject(npmUtilities_js_1.default.installModules));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_BACKUP, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.getBackup));
    opFuncMap.set(terms.OPERATIONS_ENUM.CLEANUP_ORPHAN_BLOBS, new OperationFunctionObject_ts_1.OperationFunctionObject(schema_js_1.default.cleanupOrphanBlobs));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_ANALYTICS, new OperationFunctionObject_ts_1.OperationFunctionObject(analytics.getOp));
    opFuncMap.set(terms.OPERATIONS_ENUM.LIST_METRICS, new OperationFunctionObject_ts_1.OperationFunctionObject(analytics.listMetricsOp));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_METRIC, new OperationFunctionObject_ts_1.OperationFunctionObject(analytics.describeMetricOp));
    // set status operations
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_STATUS, new OperationFunctionObject_ts_1.OperationFunctionObject(status.get));
    opFuncMap.set(terms.OPERATIONS_ENUM.SET_STATUS, new OperationFunctionObject_ts_1.OperationFunctionObject(status.set));
    opFuncMap.set(terms.OPERATIONS_ENUM.CLEAR_STATUS, new OperationFunctionObject_ts_1.OperationFunctionObject(status.clear));
    return opFuncMap;
}
//# sourceMappingURL=serverUtilities.js.map