voltmx_API.js

"use strict";
/***************************************************
* Licensed Materials - Property of HCL.
* (c)Copyright HCL America, Inc. 2023-2024
****************************************************/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActionEventObject = exports.setActionEventObject = exports.getCurrentServiceName = exports.getCurrentServerDatabase = exports.setCurrentServerDatabase = exports.rosettaVMXObject = exports.rosettaServicesEntry = exports.rosettaServicesMap = exports.rosettajsLogger = exports.isCurrentServiceTypeOfflineObjects = exports.isCurrentServiceTypeOnlineObjects = exports.isCurrentServiceTypeIntegration = exports.setDefaultServiceTypeAsIntegration = exports.setDefaultServiceTypeAsOfflineObjects = exports.setDefaultServiceTypeAsOnlineObjects = exports.setDefaultServiceType = exports.setServiceTypeAsOnlineObjects = exports.setServiceTypeAsOfflineObjects = exports.getServiceType = exports.getDefaultServiceType = exports.serviceType = void 0;
/**
 * @file Rosetta API - Volt MX
 * @module rosetta-api-voltmx
 */
exports.serviceType = {
    _integration: "integration",
    _objects: { online: "online-objects", offline: "offline-objects" },
    _orchestration: "orchestration",
    _workflow: "workflow",
    _engagement: "engagement",
    _default: "online-objects"
};
/**
 * getDefaultServiceType
 * @returns {string} the default service type currently set
 */
function getDefaultServiceType() { return exports.serviceType._default; }
exports.getDefaultServiceType = getDefaultServiceType;
/**
 * getServiceType
 * @param {string} serviceName for the Volt MX Object Service
 * @returns {string} the service type for the specified service
 */
function getServiceType(serviceName) {
    let serviceEntry = exports.rosettaServicesMap.get(serviceName);
    if (!serviceName || !serviceEntry) {
        return "";
    }
    return serviceEntry._serviceType;
}
exports.getServiceType = getServiceType;
/**
 * setServiceTypeAsOfflineObjects(serviceName)
 * @param {string} serviceName for the Volt MX Object Service
 * @returns {string} the service type for the specified service
 */
function setServiceTypeAsOfflineObjects(serviceName) {
    let serviceEntry = exports.rosettaServicesMap.get(serviceName);
    if (!serviceName || !serviceEntry) {
        return "";
    }
    serviceEntry._serviceType = exports.serviceType._objects.offline;
    serviceEntry._service = voltmx.sdk.getCurrentInstance().getObjectService(serviceName, { "access": "offline" });
    if (!serviceEntry._service) {
        return "";
    }
    exports.rosettaServicesMap.set(serviceName, serviceEntry);
    return serviceEntry._serviceType;
}
exports.setServiceTypeAsOfflineObjects = setServiceTypeAsOfflineObjects;
/**
 * setServiceTypeAsOnlineObjects(serviceName)
 * @param {string} serviceName for the Volt MX Object Service
 * @returns {string} the service type for the specified service
 */
function setServiceTypeAsOnlineObjects(serviceName) {
    let serviceEntry = exports.rosettaServicesMap.get(serviceName);
    if (!serviceName || !serviceEntry) {
        return "";
    }
    serviceEntry._serviceType = exports.serviceType._objects.online;
    serviceEntry._service = voltmx.sdk.getCurrentInstance().getObjectService(serviceName, { "access": "online" });
    if (!serviceEntry._service) {
        return "";
    }
    exports.rosettaServicesMap.set(serviceName, serviceEntry);
    return serviceEntry._serviceType;
}
exports.setServiceTypeAsOnlineObjects = setServiceTypeAsOnlineObjects;
/**
 * Set default service type.
 * @returns {string} The default service type
 */
function setDefaultServiceType(type) {
    exports.serviceType._default = type;
    return getDefaultServiceType();
}
exports.setDefaultServiceType = setDefaultServiceType;
/**
 * Set default service type to online object service.
 * @returns {string} The default service type
 */
function setDefaultServiceTypeAsOnlineObjects() {
    exports.serviceType._default = exports.serviceType._objects.online;
    return getDefaultServiceType();
}
exports.setDefaultServiceTypeAsOnlineObjects = setDefaultServiceTypeAsOnlineObjects;
/**
 * Set default service type to offline object service.
 * @returns {string} The default service type
 */
function setDefaultServiceTypeAsOfflineObjects() {
    exports.serviceType._default = exports.serviceType._objects.offline;
    return getDefaultServiceType();
}
exports.setDefaultServiceTypeAsOfflineObjects = setDefaultServiceTypeAsOfflineObjects;
/**
 * Set default service type to integration service.
 * @returns {string} The default service type
 */
function setDefaultServiceTypeAsIntegration() {
    exports.serviceType._default = exports.serviceType._integration;
    return getDefaultServiceType();
}
exports.setDefaultServiceTypeAsIntegration = setDefaultServiceTypeAsIntegration;
/**
 * Is current service type integration service.
 * @returns {boolean} True if the current service type is set to integration service;
 *     false otherwise
 */
function isCurrentServiceTypeIntegration() {
    return getDefaultServiceType() === exports.serviceType._integration;
}
exports.isCurrentServiceTypeIntegration = isCurrentServiceTypeIntegration;
/**
 * Is current service type online object service.
 * @returns {boolean} True if the current service type is set to online object service;
 *     false otherwise
 */
function isCurrentServiceTypeOnlineObjects() {
    return getDefaultServiceType() === exports.serviceType._objects.online;
}
exports.isCurrentServiceTypeOnlineObjects = isCurrentServiceTypeOnlineObjects;
/**
* Is current service type offline object service.
* @returns {boolean} True if the current service type is set to offline object service;
*     false otherwise
*/
function isCurrentServiceTypeOfflineObjects() {
    return getDefaultServiceType() === exports.serviceType._objects.offline;
}
exports.isCurrentServiceTypeOfflineObjects = isCurrentServiceTypeOfflineObjects;
/**
* rosettajsLogger
* @returns {*} rosettajs logger for voltmx;
*/
function rosettajsLogger() {
    /* @ts-expect-error: rosettajs is assigned at runtime */
    var logger = voltmx.rosettajs.logger = voltmx.rosettajs.logger ? voltmx.rosettajs.logger : new voltmx.logger.createNewLogger("ROSETTAJS", null);
    return logger;
}
exports.rosettajsLogger = rosettajsLogger;
/**
 * Rosetta Volt MX Context Data Support
 */
/**
 * Top level Map to store all Volt MX Services
 */
exports.rosettaServicesMap = new Map();
/**
 * Entry class for a Volt MX Service
 * Each Volt MX Foundry Service is stored in a separate rosettaServicesEntry
 */
class rosettaServicesEntry {
    constructor(name, type) {
        this._serviceName = name;
        this._serviceType = type;
        this._service = voltmx.sdk.getCurrentInstance().getObjectService(name, { "access": type === exports.serviceType._objects.online ? "online" : "offline" });
        this._defaultView = "";
        this._objectNames = [];
        this._objects = new Map();
        this._metadata = [];
        this._lastError = new Error;
    }
}
exports.rosettaServicesEntry = rosettaServicesEntry;
/**
 * Class for a Volt MX Object - View or Form
 *
 */
class rosettaVMXObject {
    constructor(name) {
        this._name = name;
        this._documents = [];
        this._document = {};
        this._allDocsAvailable = false;
    }
}
exports.rosettaVMXObject = rosettaVMXObject;
/**
* Current active Server:Database
*/
let currentServerDatabase = ""; // Used when no ServerDatabase is specified in api
function setCurrentServerDatabase(serverDatabase) {
    currentServerDatabase = serverDatabase;
}
exports.setCurrentServerDatabase = setCurrentServerDatabase;
function getCurrentServerDatabase() {
    return currentServerDatabase;
}
exports.getCurrentServerDatabase = getCurrentServerDatabase;
function getCurrentServiceName() {
    let currentServiceName = Array.isArray(currentServerDatabase) ? currentServerDatabase : ["", currentServerDatabase];
    return (!currentServiceName[1] ? "" : currentServiceName[1]);
}
exports.getCurrentServiceName = getCurrentServiceName;
/**
* Action Event Object
*/
let actionEventObject = {};
function setActionEventObject(eventobject) {
    actionEventObject = eventobject;
}
exports.setActionEventObject = setActionEventObject;
function getActionEventObject() {
    return actionEventObject;
}
exports.getActionEventObject = getActionEventObject;
//# sourceMappingURL=API.js.map