"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.OPERATION_FUNCTION_MAP = void 0;
exports.processLocalTransaction = processLocalTransaction;
exports.chooseOperation = chooseOperation;
exports.getOperationFunction = getOperationFunction;
exports.operation = operation;
exports.executeJob = executeJob;
const search = __importStar(require("../../dataLayer/search.js"));
const bulkLoad = __importStar(require("../../dataLayer/bulkLoad.js"));
const schema = __importStar(require("../../dataLayer/schema.js"));
const schemaDescribe = __importStar(require("../../dataLayer/schemaDescribe.js"));
const delete_ = __importStar(require("../../dataLayer/delete.js"));
const readAuditLog_ts_1 = __importDefault(require("../../dataLayer/readAuditLog.js"));
const user = __importStar(require("../../security/user.js"));
const role = __importStar(require("../../security/role.js"));
const operations_js_1 = __importDefault(require("../../components/operations.js"));
const harper_logger_ts_1 = __importDefault(require("../../utility/logging/harper_logger.js"));
const readLog_ts_1 = __importDefault(require("../../utility/logging/readLog.js"));
const export_ = __importStar(require("../../dataLayer/export.js"));
const opAuth = __importStar(require("../../utility/operation_authorization.js"));
const jobs = __importStar(require("../jobs/jobs.js"));
const terms = __importStar(require("../../utility/hdbTerms.js"));
const hdbError_ts_1 = require("../../utility/errors/hdbError.js");
const { HTTP_STATUS_CODES } = hdbError_ts_1.hdbErrors;
const restart = __importStar(require("../../bin/restart.js"));
const util = __importStar(require("util"));
const insert = __importStar(require("../../dataLayer/insert.js"));
const globalSchema = __importStar(require("../../utility/globalSchema.js"));
const systemInformation_ts_1 = require("../../utility/environment/systemInformation.js");
const jobRunner = __importStar(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 = __importStar(require("../../utility/logging/transactionLog.js"));
const npmUtilities = __importStar(require("../../utility/npmUtilities.js"));
const globals_js_1 = require("../../globals.js");
const common_utils_ts_1 = require("../../utility/common_utils.js");
const Server_ts_1 = require("../Server.js");
const operationLog = harper_logger_ts_1.default.loggerWithTag('operation');
const analytics = __importStar(require("../../resources/analytics/read.js"));
const operationFunctionCaller = __importStar(require("../../utility/OperationFunctionCaller.js"));
const status = __importStar(require("../status/index.js"));
const regDeprecated = __importStar(require("../../resources/registrationDeprecated.js"));
const deploymentOperations = __importStar(require("../../components/deploymentOperations.js"));
const pSearchSearch = util.promisify(search.search);
let pEvaluateSql;
function evaluateSQL(command) {
    if (!pEvaluateSql) {
        const sql = require('../../sqlTranslator/index');
        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_ts_1.default.logLevel === terms.LOG_LEVELS.INFO ||
                harper_logger_ts_1.default.logLevel === terms.LOG_LEVELS.DEBUG ||
                harper_logger_ts_1.default.logLevel === 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.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.setSchemaDataToGlobal((err) => {
            if (err) {
                operationLog.error(err);
            }
        });
    }
    return data;
}
exports.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) => {
    exports.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');
            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_ts_1.handleHDBError)(new Error(), astPermCheck, hdbError_ts_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 = opAuth.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_ts_1.handleHDBError)(new Error(), verifyPermsResult, hdbError_ts_1.hdbErrors.HTTP_STATUS_CODES.FORBIDDEN, undefined, false, true);
            }
        }
    }
    catch (err) {
        throw (0, hdbError_ts_1.handleHDBError)(err, `There was an error when trying to choose an operation path`, 500);
    }
    return operation_function;
}
function getOperationFunction(json) {
    operationLog.trace(`getOperationFunction with operation: ${json.operation}`);
    if (exports.OPERATION_FUNCTION_MAP.has(json.operation)) {
        return exports.OPERATION_FUNCTION_MAP.get(json.operation);
    }
    throw (0, hdbError_ts_1.handleHDBError)(new Error(), hdbError_ts_1.hdbErrors.HDB_ERROR_MSGS.OP_NOT_FOUND(json.operation), hdbError_ts_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.insert(transaction);
                    break;
                case terms.OPERATIONS_ENUM.UPDATE:
                    await insert.update(transaction);
                    break;
                case terms.OPERATIONS_ENUM.UPSERT:
                    await insert.upsert(transaction);
                    break;
                case terms.OPERATIONS_ENUM.DELETE:
                    await delete_.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_ts_1.transformReq)(json);
    let newJobObject;
    let result;
    try {
        result = await jobs.addJob(json);
        if (result) {
            newJobObject = result.createdJob;
            operationLog.info('addJob result', result);
            const jobRunnerMessage = new jobRunner.RunnerMessage(newJobObject, json);
            const returnMessage = await jobRunner.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_ts_1.handleHDBError)(err, message, 500);
    }
}
function initializeOperationFunctionMap() {
    const opFuncMap = new Map();
    opFuncMap.set(terms.OPERATIONS_ENUM.INSERT, new OperationFunctionObject_ts_1.OperationFunctionObject(insert.insert));
    opFuncMap.set(terms.OPERATIONS_ENUM.UPDATE, new OperationFunctionObject_ts_1.OperationFunctionObject(insert.update));
    opFuncMap.set(terms.OPERATIONS_ENUM.UPSERT, new OperationFunctionObject_ts_1.OperationFunctionObject(insert.upsert));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_CONDITIONS, new OperationFunctionObject_ts_1.OperationFunctionObject(search.searchByConditions));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_HASH, new OperationFunctionObject_ts_1.OperationFunctionObject(search.searchByHash));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_ID, new OperationFunctionObject_ts_1.OperationFunctionObject(search.searchByHash));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_BY_VALUE, new OperationFunctionObject_ts_1.OperationFunctionObject(search.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.csvDataLoad));
    opFuncMap.set(terms.OPERATIONS_ENUM.CSV_FILE_LOAD, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, bulkLoad.csvFileLoad));
    opFuncMap.set(terms.OPERATIONS_ENUM.CSV_URL_LOAD, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, bulkLoad.csvURLLoad));
    opFuncMap.set(terms.OPERATIONS_ENUM.IMPORT_FROM_S3, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, bulkLoad.importFromS3));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_SCHEMA, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.createSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_DATABASE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.createSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_TABLE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.createTable));
    opFuncMap.set(terms.OPERATIONS_ENUM.CREATE_ATTRIBUTE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.createAttribute));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_SCHEMA, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.dropSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_DATABASE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.dropSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_TABLE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.dropTable));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_ATTRIBUTE, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.dropAttribute));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_SCHEMA, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe.describeSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_DATABASE, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe.describeSchema));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_TABLE, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe.describeTable));
    opFuncMap.set(terms.OPERATIONS_ENUM.DESCRIBE_ALL, new OperationFunctionObject_ts_1.OperationFunctionObject(schemaDescribe.describeAll));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE, new OperationFunctionObject_ts_1.OperationFunctionObject(delete_.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.listRoles));
    opFuncMap.set(terms.OPERATIONS_ENUM.ADD_ROLE, new OperationFunctionObject_ts_1.OperationFunctionObject(role.addRole));
    opFuncMap.set(terms.OPERATIONS_ENUM.ALTER_ROLE, new OperationFunctionObject_ts_1.OperationFunctionObject(role.alterRole));
    opFuncMap.set(terms.OPERATIONS_ENUM.DROP_ROLE, new OperationFunctionObject_ts_1.OperationFunctionObject(role.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_ts_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_.export_to_s3));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_FILES_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, delete_.deleteFilesBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_RECORDS_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, delete_.deleteFilesBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.EXPORT_LOCAL, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, export_.export_local));
    opFuncMap.set(terms.OPERATIONS_ENUM.SEARCH_JOBS_BY_START_DATE, new OperationFunctionObject_ts_1.OperationFunctionObject(jobs.handleGetJobsByStartDate));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_JOB, new OperationFunctionObject_ts_1.OperationFunctionObject(jobs.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.restart));
    opFuncMap.set(terms.OPERATIONS_ENUM.RESTART_SERVICE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, restart.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_ts_1.systemInformation));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_AUDIT_LOGS_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, delete_.deleteAuditLogsBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.READ_AUDIT_LOG, new OperationFunctionObject_ts_1.OperationFunctionObject(readAuditLog_ts_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.LIST_DEPLOYMENTS, new OperationFunctionObject_ts_1.OperationFunctionObject(deploymentOperations.handleListDeployments));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_DEPLOYMENT, new OperationFunctionObject_ts_1.OperationFunctionObject(deploymentOperations.handleGetDeployment));
    opFuncMap.set(terms.OPERATIONS_ENUM.READ_TRANSACTION_LOG, new OperationFunctionObject_ts_1.OperationFunctionObject(transactionLog.readTransactionLog));
    opFuncMap.set(terms.OPERATIONS_ENUM.DELETE_TRANSACTION_LOGS_BEFORE, new OperationFunctionObject_ts_1.OperationFunctionObject(executeJob, transactionLog.deleteTransactionLogsBefore));
    opFuncMap.set(terms.OPERATIONS_ENUM.INSTALL_NODE_MODULES, new OperationFunctionObject_ts_1.OperationFunctionObject(npmUtilities.installModules));
    opFuncMap.set(terms.OPERATIONS_ENUM.GET_BACKUP, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.getBackup));
    opFuncMap.set(terms.OPERATIONS_ENUM.CLEANUP_ORPHAN_BLOBS, new OperationFunctionObject_ts_1.OperationFunctionObject(schema.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