UNPKG

@enaio-client/communication-library

Version:

The Communication Library facilitates secure cross-origin communication between the enaio® webclient and dashlets/modal dialogs, using window.postMessage(). This library streamlines the process, ensuring compatibility with the enaio® client, and offers an

1 lines 52.1 kB
{"mappings":";;;;;;;;;;;;;;;;;;;;;;ACAA;;CAEC,GACD,MAAM,iCAAW,CAAC;AAClB,MAAM,mCAAa,EAAE;AAErB,IAAI,oCAAc;AAElB,IAAI;AACJ,IAAI;AAEJ,IAAI,uCAAiB,KAAO;AAC5B,IAAI,yCAAmB,KAAO;AAC9B,IAAI,mDAA6B;AAEjC;;;;;;;CAOC,GACD,SAAS,0CAAuB,QAAQ,EAAE,aAAa;IACnD,uCAAiB;IACjB,sCAAgB;AACpB;AAEA;;;;;;;CAOC,GACD,SAAS,0CAAyB,QAAQ,EAAE,aAAa;IACxD,IAAI,mCACH,MAAM;SACA;QACN,mDAA6B;QAC7B,yCAAmB;QACnB,sCAAgB;IACjB;AACD;AAEA,mDAAmD;AACnD,OAAO,gBAAgB,CAAC,WAAW,0CAAmB;AAEtD;;;;;CAKC,GACD,SAAS,yCAAkB,KAAK;IAC5B,oBAAoB;IACpB,wCAAkB,MAAM,MAAM;IAE9B;;;;;IAKA,GACA,IAAI,wCAAkB,QAAQ,wCAAkB,aAAa,oCAAc,MAAM,GAAG,KAAK,wCAAkB,KAAK;QAC5G,oDAAoD;QACpD,IAAI,cAAc,uCACd,sCAAgB;QAGpB,MAAM,aAAa,wCAAkB;QAErC,IAAI,eAAe,OAAO;YACtB,QAAQ,GAAG,CAAC,CAAC,gBAAgB,EAAE,sCAAgB,6BAA6B,EAAE,oCAAc,CAAC;YAC7F,OAAO;QACX;IACJ;IAEA,0LAA0L;IAC1L,mEAAmE;IACnE,4GAA4G;IAC5G,MAAM,QAAC,IAAI,QAAE,IAAI,EAAC,GAAG,6CAAuB,MAAM,IAAI;IAC/C,iBAAA,gCAAA,KAAM,IAAI,EAAE,0CAA0C;IAE7D,IAAI,SAAS,UAAU;QACzB,+CAA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GR,OAAO;AACR;AAEA,0DAA0D;AAC1D,sEAAsE;AACtE,IAAI,yCAAmB;AAEvB;;;;CAIC,GACD,SAAS,yCAA4B,aAAa;IACjD,OAAO,IAAI,QAAQ,CAAC,SAAS;QAC5B,iEAAiE;QACjE,WAAW;YACV,IAAI,CAAC,4CACJ,OAAO;iBACD;gBACN,kEAAkE;gBAClE,mEAAmE;gBACnE,yCAAmB;gBACnB;YACD;QACD,GAAG;IACJ;AACD;AAEA,kCAAkC;AAClC,OAAO,gBAAgB,CAAC,WAAW,SAAU,KAAK;IACjD,oEAAoE;IACpE,IAAI,MAAM,GAAG,KAAK,YAAY,CAAC,OAAO,QAAQ,IAAI,4CAAiB;QAClE,iEAAiE;QACjE,MAAM,eAAe,OAAO,0CAAoB,aAAa,2CAAqB;QAClF,oDAAoD;QACpD,IAAI,iBAAiB,GACpB,0CAAiB;aAEjB,QAAQ,IAAI,CAAC;IAEf;AACD","sources":["src/communicationLibrary.js","src/libraryWebClient.js","src/libraryRichClient.js"],"sourcesContent":["const version = '2.0.5';\n\nimport * as libWebClient from \"./libraryWebClient.js\";\nimport * as libRichClient from \"./libraryRichClient.js\";\n\n/**\n * Registers an onInit callback which is executed once the dashlet is initialized.\n * \n * @param {Function} onInitCallback The callback\n * @param {string} trustedOrigin origin which is allowed to send and receive messages. Should be the webclient uri.\n * Use \"*\" to allow every target origin. Example: https://enaio.company-name.de.\n * Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage\n */\nfunction registerOnInitCallback(onInitCallback, trustedOrigin = \"*\") {\n\tconsole.log(`Current Communication library version number: ${version}`);\n\n\tif (window.osClient) {\n\t\tlibRichClient.registerOnInitCallback(onInitCallback);\n\t} else {\n\t\tlibWebClient.registerOnInitCallback(onInitCallback, trustedOrigin);\n\t}\n}\n\n/**\n * Registers an onUpdate callback which is executed if something changes in the client.\n * \n * @param {Function} onUpdateCallback The callback\n * @param {string} trustedOrigin origin which is allowed to send and receive messages. Should be the webclient uri.\n * Use \"*\" to allow every target origin. Example: https://enaio.company-name.de.\n * Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage\n */\nfunction registerOnUpdateCallback(onUpdateCallback, trustedOrigin = \"*\") {\n\tif (window.osClient) {\n\t\tlibRichClient.registerOnUpdateCallback(onUpdateCallback);\n\t} else {\n\t\tlibWebClient.registerOnUpdateCallback(onUpdateCallback, trustedOrigin);\n\t}\n}\n\n/**\n * Opens the index data mask for the currently selected osId.\n * \n * @param {boolean} inNewTab indicates whether the index data mask should be opened in a new tab. Default is (false).\n * @param {string} mode should the index data view be opened in read-only mode (view) or in edit mode (edit). Default is (edit) mode.\n * @param {string} objectId the osId of the DMS object.\n * @param {string} objectTypeId the objectTypeId of the DMS object. This increases the performance when opening the index data view.\n * @returns {boolean} true if the objectId and objectTypeId are valid and the opening was successful. Otherwise, false.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/openIndexData\n */\nasync function openIndexData(inNewTab, mode, objectId, objectTypeId = undefined) {\n\tif (isModalDialog()) {\n\t\tthrow \"Not implemented for modal dialog\";\n\t}\n\n\treturn sendClientMessage([\"openIndexData\", [inNewTab, mode, objectId, objectTypeId]]);\n}\n\n/**\n * Opens the location in the current browser tab (or a location selection in the case of several possible locations) for the DMS object transferred as a parameter.\n * \n * @param {boolean} inNewTab indicates whether the hit list should be opened in a new tab.\n * @param {string} objectId the osId of the DMS object.\n * @param {string} [objectTypeId] the objectTypeId of the DMS object. This increases the performance when opening the location.\n * @param {string} [parentId] the osId of the parent DMS object to open a specific location if the object has multiple locations.\n * @param {string} [parentTypeId] the objectTypeId of the parent DMS object to open a specific location if the object has multiple locations.\n * @returns {Promise<void>} The method has no return value. In the event of an error, an error is triggered. This can be caught with a try-catch-block or error handler for the method.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/openLocation\n */\nasync function openLocation(inNewTab, objectId, objectTypeId = undefined, parentId = undefined, parentTypeId = undefined) {\n\tif (isModalDialog()) {\n\t\tthrow \"Not implemented for modal dialog\";\n\t}\n\n\tawait sendClientMessage([\"openLocation\", [inNewTab, objectId, objectTypeId, parentId, parentTypeId]]);\n}\n\n/**\n * Query the currently selected objects.\n * Depending on whether you call getSelectedObjects or the enaio® RichClient compatibility method,\n * you will get a different result. In the former, a JavaScript array with objects consisting of objectId and\n * objectTypeId of the selected DMS objects. With the compatibility method, a character sect that is separated\n * by a semicolon and returns a tuple from objectId and objectTypeId.\n * \n * @returns {Promise<string>} Semicolon separated string of tuples with objectId and objectTypeId.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/getSelectedObjects\n */\nasync function getSelectedObjects() {\n\tif (isModalDialog()) {\n\t\tthrow \"Not implemented for modal dialog\";\n\t}\n\n\treturn sendClientMessage([\"getSelectedObjects\", []]);\n}\n\n/**\n * Update/refresh one or more objects in an open hit list.\n * \n * @param {string[]} osIds of the DMS objects.\n * @return The method has no return value. In the event of an error, an error is triggered. This can be caught with a try-catch-block or error handler for the method.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/refreshHitListObjects\n */\nasync function refreshHitListObjects(osIds) {\n\tif (isModalDialog()) {\n\t\tthrow \"Not implemented for modal dialog\";\n\t}\n\n\tawait sendClientMessage([\"refreshHitListObjects\", [osIds]]);\n}\n\n/**\n * Display a mixed hit list with freely selected objects.\n * \n * @param {Array<{objectId: string, objectTypeId: string}>} objects selected objects\n * @param {boolean} [inNewTab] indicates whether the hit list should be opened in a new tab\n * @param {string} [title] title of the hit list\n * @param {string} [subTitle] subtitle of the hit list\n * @param {boolean} [executeSingleHitAction] specifies whether to execute the default action when there is a single hit\n * @return The method has no return value. In the event of an error, an error is triggered. This can be caught with a try-catch-block or error handler for the method.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/openHitListByIds\n */\nasync function openHitListByIds(objects, inNewTab = false, title = \"\", subTitle = \"\", executeSingleHitAction = false) {\n\tif (isModalDialog()) {\n\t\tthrow \"Not implemented for modal dialog\";\n\t}\n\n\tawait sendClientMessage([\"openHitListByIds\", {\n\t\tobjects,\n\t\tinNewTab,\n\t\ttitle,\n\t\tdescription: subTitle,\n\t\texecuteSingleHitAction\n\t}]);\n}\n\n/**\n * Only available for modal dialogs.\n * Return the value of a field given by its internal name. The return value depends on the field type.\n * See documentation for more information regarding return value.\n *\n * @param json A json object with internalName\n * @return {Promise<string|Array<Array<string>>>}\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/getFieldValueByInternal\n * @returns The answer of the client.\n */\nasync function getFieldValueByInternal(json) {\n\tif (!isModalDialog()) {\n\t\tthrow \"Not implemented for dashlets\";\n\t}\n\n\treturn sendClientMessage([\"getFieldValueByInternal\", [jsonObjectToString(json)]]);\n}\n\n/**\n * Fetches the value of a specific workflow variable by its name. This function is only available for modal dialogs.\n * The return value of the function depends on the type of the workflow variable being queried.\n *\n * @param {object} json - A JSON object containing the `name` of the workflow variable.\n * @return {Promise<string|Array<Array<string>>>} - A promise that resolves to the value of the workflow variable. The type of the return value can be a string or an array of arrays of strings, depending on the variable's type.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/getWorkflowVariableByName - For more information regarding the return value based on the field type.\n * @throws {string} - Throws an error message if the function is invoked outside of a modal dialog context, as it is not implemented for dashlets.\n */\nasync function getWorkflowVariableByName(json) {\n\tif (!isModalDialog()) {\n\t\tthrow \"Not implemented for dashlets\";\n\t}\n\n\treturn sendClientMessage([\"getWorkflowVariableByName\", [jsonObjectToString(json)]]);\n}\n\n/**\n * Only available for modal dialogs.\n * Set the value of a field given by its internal name in the open index data mask behind the modal dialog.\n * The current value of the index data mask field is completely replaced by the new value.\n *\n * @param json A json object with internalName and value.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/setFieldValueByInternal\n * @returns The answer of the client.\n */\nasync function setFieldValueByInternal(json) {\n\tif (!isModalDialog()) {\n\t\tthrow \"Not implemented for dashlets\";\n\t}\n\n\treturn sendClientMessage([\"setFieldValueByInternal\", [jsonObjectToString(json)]]);\n}\n\n/**\n * Only available for modal dialogs.\n * Sets a workflow variable by its name.\n * The current value of the workflow variable is completely replaced by the new value.\n *\n * @param json A json object with the variable name and value.\n * @throws {string} If the function is used outside of a modal dialog.\n * @returns The answer of the client.\n * @async\n */\nasync function setWorkflowVariableByName(json) {\n\tif (!isModalDialog()) {\n\t\tthrow \"Not implemented for dashlets\";\n\t}\n\n\treturn sendClientMessage([\"setWorkflowVariableByName\", [jsonObjectToString(json)]]);\n}\n\n/**\n * Return the environment values from the client.\n *\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/getEnvironment\n * @returns The environment values from the client.\n */\nasync function getEnvironment() {\n\tif (!isModalDialog()) {\n\t\tthrow \"Not implemented for dashlets\";\n\t}\n\n\treturn sendClientMessage([\"getEnvironment\", []]);\n}\n\n/**\n * This function is only available for modal dialogs. It sets the caption of the dialog to the provided value.\n *\n * @param {string} newDialogCaption - The caption to be set for the modal dialog. Defaults to an empty string if no value is provided.\n * @throws {string} Throws a string error message if the function is used outside of a modal dialog context.\n * @remarks The caption is set as an array for webclient compatibility. The rich client only accepts a string.\n */\nfunction setDialogCaption(newDialogCaption = \"\") {\n\tif (!isModalDialog()) {\n\t\tthrow \"Not implemented for dashlets\";\n\t}\n\n\treturn sendClientMessage([\"setDialogCaption\", [newDialogCaption]]);\n}\n\n/**\n * Cancel the modal dialog\n *\n * @param buttonScriptReturnValue The numeric value which should be sent to the button script\n */\nasync function closeModalDialog(buttonScriptReturnValue) {\n\tif (!isModalDialog()) {\n\t\tthrow \"Not implemented for dashlets\";\n\t}\n\n\treturn sendClientMessage([\"closeModalDialog\", [buttonScriptReturnValue]]);\n}\n\n/**\n * Reset the session timeout for the current user session.\n * \n * @returns {Promise<void>} The method has no return value. In the event of an error, an error is triggered. This can be caught with a try-catch-block or error handler for the method.\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/resetSessionTimeout\n */\nasync function resetSessionTimeout() {\n\tif (window.osClient) {\n\t\treturn; // there is no session timeout in the rich client\n\t}\n\n\tawait sendClientMessage([\"resetSessionTimeout\", []]);\n}\n\n/**\n * Send a command either to the web client or rich client and return the response.\n * \n * @private\n * @param {Object[]} payload The input parameter for the command\n * @returns The answer of the client\n */\nasync function sendClientMessage(payload) {\n\ttry {\n\t\tif (window.osClient) {\n\t\t\treturn libRichClient.sendToRichClient(payload);\n\t\t}\n\n\t\treturn libWebClient.sendWebclientMessage(payload);\n\t} catch (error) {\n\t\tconsole.log(`dashlet says: error caught in ${payload[0]}`, error);\n\t}\n}\n\n/**\n * Checks if the json object is a string. If not the json object is stringify and\n * returned. Otherwise, it is returned as handed in.\n *\n * @private\n * @returns {string} The stringify json object if it is not already a string.\n */\nfunction jsonObjectToString(jsonObject) {\n\tif (!(jsonObject instanceof String) && typeof jsonObject !== \"string\") {\n\t\tif (typeof jsonObject.value === \"object\" && !Array.isArray(jsonObject.value)) {\n\t\t\tjsonObject.value = JSON.stringify(jsonObject.value);\n\t\t}\n\n\t\treturn JSON.stringify(jsonObject);\n\t}\n\n\treturn jsonObject;\n}\n\n/**\n * Return true if we are running inside a modal dialog. If we are running inside a dashlet the return is false.\n *\n * @private\n * @returns true if modal dialog, Otherwise false\n */\nfunction isModalDialog() {\n\tif (window.osClient) {\n\t\treturn libRichClient.isModalDialog();\n\t}\n\n\treturn libWebClient.isModalDialog();\n}\n\n// This will store the value for the onCanCancel behavior.\n// It's initialized to a default value to ensure it's always callable.\nlet onCanCancelValue = 1;\n\n/**\n * Registers the callback for the ESC key event.\n *\n * @param {Function} valueFunction - A function that returns the current value for the callback.\n */\nfunction registerOnCanCancelCallback(valueFunction) {\n\treturn new Promise((resolve, reject) => {\n\t\t// Delay is necessary to ensure the availability of the function.\n\t\tsetTimeout(() => {\n\t\t\tif (!isModalDialog()) {\n\t\t\t\treject(\"Not implemented for dashlets\");\n\t\t\t} else {\n\t\t\t\t// We assign the function passed from main.js to onCanCancelValue.\n\t\t\t\t// This allows the function to be updated dynamically from main.js.\n\t\t\t\tonCanCancelValue = valueFunction;\n\t\t\t\tresolve();\n\t\t\t}\n\t\t}, 1000);\n\t});\n}\n\n// Event listener for the ESC key.\nwindow.addEventListener('keydown', function (event) {\n\t// Check if the ESC key was pressed, and the modal dialog is active.\n\tif (event.key === \"Escape\" && !window.osClient && isModalDialog()) {\n\t\t// Retrieve the current onCanCancelValue by calling the function.\n\t\tconst currentValue = typeof onCanCancelValue == 'function' ? onCanCancelValue() : onCanCancelValue;\n\t\t// If the value is not 2, we close the modal dialog.\n\t\tif (currentValue !== 2) {\n\t\t\tcloseModalDialog(currentValue);\n\t\t} else {\n\t\t\tconsole.warn(\"ESC key event is disabled.\");\n\t\t}\n\t}\n});\n\n// Export functions to be used in other JavaScript files.\n// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import\n\n// Named Exports\nexport {\n\t// Event Callbacks\n\tregisterOnInitCallback,\n\tregisterOnUpdateCallback,\n\tregisterOnCanCancelCallback,\n\n\t// Methods Dashlets\n\topenIndexData,\n\topenLocation,\n\tgetSelectedObjects,\n\trefreshHitListObjects,\n\topenHitListByIds,\n\tcloseModalDialog,\n\n\t// Methods modal dialogs\n\tgetFieldValueByInternal,\n\tsetFieldValueByInternal,\n\tgetEnvironment,\n\tsetDialogCaption,\n\n\t// Methods for Workflows\n\tgetWorkflowVariableByName,\n\tsetWorkflowVariableByName,\n\n\t// Methods for both modal dialogs and dashlets\n\tresetSessionTimeout,\n\n\t// export for unit tests\n\tisModalDialog\n};","/**\n * This library manage the communication between dashlet and web client.\n */\nconst msgQueue = {};\nconst alertQueue = [];\n\nlet modalDialog = false;\n\nlet webclientOrigin;\nlet trustedOrigin;\n\nlet onInitCallback = () => {};\nlet onUpdateCallback = () => {};\nlet onUpdateCallbackRegistered = false;\n\n/**\n * Registers an onInit callback which is executed once the dashlet is initialized.\n *\n * @param {Function} callback\n * @param {string} allowedOrigin origin which is allowed to send and receive messages. Should be the webclient uri.\n * Use \"*\" to allow every target origin. Example: https://enaio.company-name.de.\n * Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage\n */\nfunction registerOnInitCallback(callback, allowedOrigin) {\n onInitCallback = callback;\n trustedOrigin = allowedOrigin;\n}\n\n/**\n * Registers an onUpdate callback which is executed if something changes in the client.\n *\n * @param {Function} callback The callback\n * @param {string} allowedOrigin origin which is allowed to send and receive messages. Should be the webclient uri.\n * Use \"*\" to allow every target origin. Example: https://enaio.company-name.de.\n * Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage\n */\nfunction registerOnUpdateCallback(callback, allowedOrigin) {\n\tif (modalDialog) {\n\t\tthrow \"Modal dialogs do not trigger a update event. Please do not register one.\";\n\t} else {\n\t\tonUpdateCallbackRegistered = true;\n\t\tonUpdateCallback = callback;\n\t\ttrustedOrigin = allowedOrigin;\n\t}\n}\n\n// Listen to \"message\" type events from web client.\nwindow.addEventListener(\"message\", handlePostMessage, false);\n\n/**\n * A function responsible for processing all incoming \"messages\" from the enaio® webclient.\n *\n * @param event the object passed from the other Window i.e. enaio® webclient.\n * @link https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#the_dispatched_event\n */\nfunction handlePostMessage(event) {\n // Todo: Why global?\n webclientOrigin = event.origin;\n\n /* Ensure \"messages\" come from a trusted source i.e. your own enaio® hosted domain.\n Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#security_concerns\n\n \"srcOrigin\" is the domain URL where enaio® webclient is served. Example: https://enaio.company-name.de\n Please note, in enaio desktop client, \"srcOrigin\" is represented as \"file://\" string.\n */\n if (trustedOrigin !== null && trustedOrigin !== undefined && trustedOrigin.length > 0 && trustedOrigin !== \"*\") {\n // client uses electron webclient so override origin\n if (\"file://\" === webclientOrigin) {\n trustedOrigin = \"file://\";\n }\n\n const safeOrigin = trustedOrigin === webclientOrigin;\n\t\t\n if (safeOrigin === false) {\n console.log(`webclientOrigin ${webclientOrigin} is different from srcOrigin ${trustedOrigin}`);\n return false;\n }\n }\n\n // \"handleWebclientMessage\" is a handler function which further processes all incoming \"messages\" from enaio® webclient (see implementation details in the communication-library.js file).\n // Extract the \"type\" and \"data\" properties for further processing.\n // Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment\n const {type, data} = handleWebclientMessage(event.data);\n delete data?.dapi; // abstraction layer is taking care of it.\n\n if (type === \"onInit\") {\n\t\tdetectDashletModalDialog(data);\n // Do initialization work here.\n onInitCallback(data);\n } else if (type === \"onUpdate\") {\n // React to osid selection changes here.\n onUpdateCallback(data);\n }\n\n return true;\n}\n\n/**\n * Detect the kind of script which is running. There are normal dashlets and\n * modal dialogs. They differ in specific way, but we want to make it as smooth\n * to the developer as possible.\n *\n * @param data The init data structure from enaio® webclient.\n */\nfunction detectDashletModalDialog(data) {\n\tif (data.selectedEntry) {\n\t\tmodalDialog = true;\n\t\t\n\t\tif (onUpdateCallbackRegistered) {\n\t\t\t// Unregister onUpdateCallback because it is not available and write a message to console.\n\t\t\tconsole.error(\"Modal dialogs do not trigger a update event. Please do not register one.\");\n\t\t\tonUpdateCallbackRegistered = false;\n\t\t\tonUpdateCallback = () => {}\n\t\t}\n\t}\n}\n\n/**\n * A function that handles \"messages\" coming from the enaio® webclient.\n *\n * @param payload an object with { type, data } as payload.\n * @returns an object with the same shape as the input payload i.e. { type, data }\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/5.2+Kommunikation\n */\nfunction handleWebclientMessage(payload) {\n if (payload.msgId && msgQueue[payload.msgId]) {\n if (payload.data.error !== undefined) {\n msgQueue[payload.msgId].reject(payload.data.error);\n } else if (payload.data.result !== undefined) {\n msgQueue[payload.msgId].resolve(payload.data.result);\n } else {\n msgQueue[payload.msgId].resolve();\n }\n\n if (alertQueue.includes(payload.msgId)) {\n // display payload info\n\t\t\talertQueue.splice(alertQueue.indexOf(payload.msgId), 1);\n alert(JSON.stringify(payload.data.result));\n }\n\n delete msgQueue[payload.msgId];\n }\n\n return payload;\n}\n\n/**\n * A function responsible for sending \"messages\" to the enaio® webclient.\n * @param payload an array with [\"method-name\", [arguments]] as payload. Ref: https://help.optimal-systems.com/enaio_develop/display/WEB/5.4+Dashlet-Methoden\n * @param triggerAlert Boolean. If true, a browser alert (with payload results) will be displayed in the enaio® webclient.\n * @returns a JavaScript Promise. Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise\n * @link https://help.optimal-systems.com/enaio_develop/display/WEB/5.2+Kommunikation\n */\nasync function sendWebclientMessage(payload, triggerAlert = false) {\n const msgId = Math.random().toString(36).substr(2, 8);\n payload.push({msgId});\n\n if (triggerAlert) {\n alertQueue.push(msgId);\n }\n\n let _resolve, _reject;\n const promise = new Promise((resolve, reject) => {\n _resolve = resolve;\n _reject = reject;\n });\n\n msgQueue[msgId] = {resolve: _resolve, reject: _reject};\n\n // \"window\" is the Dashlet's JavaScript Window object. Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window\n // \"parent\" is the enaio® webclient Window object.\n // postMessage\" is the browser API used to communicate between enaio® webclient and the Dashlet. Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage\n if (trustedOrigin !== null && trustedOrigin !== undefined && trustedOrigin.length > 0) {\n window.parent.postMessage(payload, trustedOrigin);\n } else {\n window.parent.postMessage(payload, \"*\");\n }\n\t\n return promise;\n}\n\n/**\n * Return true if we are running inside a modal dialog. If we are running inside a dashlet the return is false.\n */\nfunction isModalDialog() {\n\treturn modalDialog;\n}\n\n/**\n * This function is only for the unit-tests to reset the webclient library to its original state\n */\nfunction reset() {\n modalDialog = false;\n onInitCallback = () => {};\n onUpdateCallback = () => {};\n onUpdateCallbackRegistered = false;\n}\n\n// Export functions to be used in other JavaScript files.\n// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import\nexport {\n\tregisterOnInitCallback, \n\tregisterOnUpdateCallback, \n\tsendWebclientMessage,\n\tisModalDialog,\n\n // Only for Unit-Tests\n handlePostMessage,\n reset\n};\n","/**\n * This library manages the communication between dashlet and rich client. It provides a bridge between \n * the dashlet and the rich client, ensuring that dashlets can operate in a consistent way regardless of \n * whether they are running in the web or rich client environment. It also includes mechanisms for testing\n * and for handling differences between modal dialogs and standard dashlets.\n */\nlet onInitCallback = null;\nlet onUpdateCallback = null;\nlet dashletCache = null; // static data from rich client only one time for a dashlet\nlet modalDialog = false;\n\n// DODO-26194: Typeless document objecttype IDs that should be mapped to \"-1\"\n// integer 13107200 >> -1 (internal tray)\n// integer 19660800 >> -1 (workflow tray)\n\nconst TYPELESS_OBJECT_TYPE_IDS = [\"19660800\", \"13107200\"];\n\n/**\n * Check if the given object type represents a typeless document\n * @param {string} objectTypeId - The objecttype ID to check\n * @returns {boolean} - True if this is a typeless document type\n */\nfunction isTypelessDocument(objectTypeId) {\n return TYPELESS_OBJECT_TYPE_IDS.includes(objectTypeId);\n}\n\n/**\n * Registers an onInit callback which is executed once the dashlet is initialized.\n *\n * @param {Function} callback\n */\nfunction registerOnInitCallback(callback) {\n onInitCallback = callback;\n}\n\n/**\n * Registers an onUpdate callback which is executed if something changes in the client.\n *\n * @param {Function} callback The callback\n */\nfunction registerOnUpdateCallback(callback) {\n\tif (modalDialog) {\n\t\tthrow \"Modal dialogs does not trigger a update event. Please do not register one.\";\n\t}\n\t\n onUpdateCallback = callback;\n}\n\n/**\n * Providing only necessary information for this rich client dashlet example.\n * We are converting it to be like the webclient structure.\n *\n * @param {Object} data initialize data from the rich client.\n * @private\n */\nasync function internalOnInitUpdate(data) {\n\tif (data.selectedEntry) {\n\t\tif (onUpdateCallback != null) {\n\t\t\t// Unregister onUpdateCallback because it is not available and write a message to console.\n\t\t\tconsole.error(\"Modal dialogs does not trigger a update event. Please do not register one.\");\n\t\t\tonUpdateCallback = null;\n\t\t}\n\t\t\n\t\tmodalDialog = true;\n\t\tinternalOnInitModalDialog(data);\n\t} else {\n\t\tawait internalOnInitUpdateDashlet(data);\n\t}\n}\n\n/**\n * Method which is called if the rich client send the initialize event for a dashlet.\n * The initialize event is also fired in case of an update. The rich client only know\n * one event. We distinguish then. The onInit event is unregistered after first processing.\n * From then on all events are redirected to the update callback. The code inside enrich\n * the rich client data as much as possible to be equal to the webclient data.\n *\n * @param {Object} data initialize data from the rich client.\n * @private\n */\nasync function internalOnInitUpdateDashlet(data) {\n\tif (dashletCache === null) {\n dashletCache = {};\n dashletCache.dashletCaption = window.osClient.osjxGetDashletCaption();\n dashletCache.uri = window.osClient.osjxGetDashletURL();\n dashletCache.languageGuiSelected = window.osClient.osjxGetEnvironment(24) || \"de\";\n dashletCache.languageObjectDefinition = window.osClient.osjxGetEnvironment(33);\n dashletCache.wfOrgId = window.osClient.osjxGetEnvironment(19);\n dashletCache.mail = window.osClient.osjxGetEnvironment(16);\n dashletCache.username = window.osClient.osjxGetEnvironment(3);\n dashletCache.groups = window.osClient.osjxGetEnvironment(11);\n dashletCache.fullname = window.osClient.osjxGetEnvironment(14);\n }\n\n let selectedEntries = await getSelectedObjects();\n let lastObjectType = {\n mainType: 0,\n objectType: \"UNKNOWN\"\n };\n\n if (selectedEntries == null || selectedEntries.length === 0 || selectedEntries[0].objectId === \"\" || selectedEntries[0].objectId === void 0) {\n // On opening an index data mask for a different ECM object out of the dashlet the selectedEntries has one element\n // but the objectId and objectTypeId are empty. We fix this by assigning the information from the init event.\n selectedEntries = [{\n objectId: data.objectident,\n objectTypeId: data.objecttype\n }];\n }\n\n // For search masks we have a selected object with objectId zero. There isn't a selected object.\n if (selectedEntries.length === 1 && selectedEntries[0].objectId === \"0\" && selectedEntries[0].objectTypeId === \"0\") {\n selectedEntries = [];\n }\n\n for (const selectedEntry of selectedEntries) {\n addObjectTypeAndMainType(selectedEntry);\n\n if (selectedEntry.objectId === data.objectident) {\n lastObjectType = selectedEntry;\n }\n }\n\n // get base url\n if (typeof location.origin === 'undefined') {\n location.origin = location.protocol + '//' + location.host;\n }\n\n // map data for webClient structure\n const mappedData = {\n activeCustomDashlet: {\n objectTypes: null, // no information from enaio rich client\n platforms: null, // no information from enaio rich client\n uri: dashletCache.uri,\n title_DE: dashletCache.dashletCaption,\n title_EN: dashletCache.dashletCaption,\n title_FR: dashletCache.dashletCaption,\n iconId: null, // no information from enaio rich client\n users: null, // no information from enaio rich client\n groups: null, // no information from enaio rich client\n },\n lastSelectedEntry: {\n hasVariants: null, // no information from enaio rich client\n mainType: lastObjectType.mainType,\n objectTypeId: isTypelessDocument(data.objecttype) ? \"-1\" : data.objecttype,\n osid: data.objectident,\n objectType: lastObjectType.objectType\n },\n osDashletInit: {\n objectident: data.objectident,\n objecttype: isTypelessDocument(data.objecttype) ? \"-1\" : data.objecttype,\n userid: data.userid,\n userguid: data.userguid,\n sessionguid: data.sessionguid,\n regenerate: data.regenerate,\n pagecount: data.pagecount,\n searchterm: data.searchterm\n },\n selectedEntries: selectedEntries.map(selectedEntry => ({\n osid: selectedEntry.objectId,\n objectTypeId: selectedEntry.objectTypeId,\n objectType: selectedEntry.objectType,\n mainType: selectedEntry.mainType\n })),\n locationInfo: getLocationInfo(data), // DODO-25150\n sessionInfo: {\n language: dashletCache.languageGuiSelected.substring(0, 2), // only \"fr\" instead of \"fra\"\n languageObjectDefinition: dashletCache.languageObjectDefinition.split(\"_\")[0], // only \"de\" instead of \"de_DE\"\n sessionGuid: data.sessionguid,\n clientType: \"rich_client\",\n baseUrl: location.origin\n },\n userInfo: {\n email: dashletCache.mail,\n fullname: dashletCache.fullname,\n groups: dashletCache.groups.split(\";\"),\n name: dashletCache.username,\n osGuid: data.userguid,\n userId: data.userid,\n wfGuid: null, // no information from enaio rich client\n wfOrdId: dashletCache.wfOrgId\n },\n context: null\n }\n\n // execute registered events with mapped data.\n\t// onInitCallback is called once. Afterward we set it to null and then onUpdateCallback is called.\n if (onInitCallback != null) {\n onInitCallback(mappedData);\n onInitCallback = null;\n } else if (onUpdateCallback != null) {\n onUpdateCallback(mappedData);\n }\n}\n\n/**\n * Handle the onInit event for modal dialogs and call a callback function if one is registered.\n *\n * @param {Object} data initialize data from the rich client.\n * @private\n */\nfunction internalOnInitModalDialog(data) {\n\tif (onInitCallback != null) {\n onInitCallback(data);\n onInitCallback = null;\n\t}\n}\n\n/**\n * Embed a function to the html file as the rich client looks up for a function\n * named osDashletInit in it. For this example we find that this is a clean solution\n * instead of placing it directly into the html file.\n *\n * @private\n */\nfunction registerOnInitUpdate() {\n window.internalOnInitUpdate = internalOnInitUpdate;\n\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.innerText = \"function osDashletInit(data) { window.internalOnInitUpdate(data); } function onInit(data) { window.internalOnInitUpdate(data); }\";\n\n document.getElementsByTagName('head')[0].appendChild(script);\n}\n\n/**\n * Call the method directly to register ourselves directly on the window object.\n * A addEventListener(\"load\", registerOnInitUpdate); would be nicer, but it is too late.\n * Then we miss the rich client call which we want to intercept.\n */\nregisterOnInitUpdate();\n\n/**\n * Entry method for sending commands to the rich client. The payload is the one for enaio web client.\n * It must be converted before sending it to rich client and the response must also be converted back.\n * This method is async even if the method is synchronous. It must be compatible to web client implementation.\n * and the web client is async an\n *\n * @param {*} payload web client format\n * @returns response in web client format\n */\nasync function sendToRichClient(payload) {\n switch (payload[0]) {\n case \"openIndexData\": \t\t\treturn openIndexData(payload);\n case \"openLocation\": \t\t\treturn openLocation(payload);\n case \"getSelectedObjects\":\t\treturn getSelectedObjects(payload);\n case \"refreshHitListObjects\": \treturn refreshHitListObjects(payload);\n case \"openHitListByIds\": \treturn openHitListByIds(payload);\n case \"getFieldValueByInternal\": return getFieldValueByInternal(payload);\n\t\tcase \"setFieldValueByInternal\": return setFieldValueByInternal(payload);\n\t\tcase \"setWorkflowVariableByName\": return setWorkflowVariableByName(payload);\n\t\tcase \"getEnvironment\":\t\t\treturn getEnvironment();\n case \"closeModalDialog\": return closeModalDialog(payload);\n case \"setDialogCaption\": return setDialogCaption(payload);\n case \"getWorkflowVariableByName\": return getWorkflowVariableByName(payload);\n }\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function openLocation(payload) {\n // const inNewTab = payload[1][0]; // Only as reminder but not supported by the rich client.\n const osId = Number(payload[1][1]);\n const objectTypeId = Number(payload[1][2]);\n\n if (objectTypeId && (objectTypeId >>> 16) === 0) {\n await window.osClient.osjxOpenObject(osId);\n } else {\n await window.osClient.osjxOpenLocation(osId);\n }\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function openIndexData(payload) {\n // const inNewTab = payload[1][0]; // Only as reminder but not supported by the rich client.\n const osId = Number(payload[1][2]);\n const readonly = payload[1][1].toLowerCase() === \"view\";\n\n await window.osClient.osjxOpenDataSheet(osId, readonly);\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function getSelectedObjects() {\n const selectedObjects = await window.osClient.osjxGetSelectedObjects();\n return selectedObjects.split(\";\").map(selectedObject => {\n const split = selectedObject.split(\",\");\n const retVal = {\n objectId: split[0],\n objectTypeId: split[1]\n };\n addObjectTypeAndMainType(retVal);\n return retVal;\n });\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function refreshHitListObjects(payload) {\n for (const objectToRefresh of payload[1]) {\n const osId = Number(objectToRefresh[0]);\n await window.osClient.osjxRefreshObjectInLists(osId);\n }\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function openHitListByIds(payload) {\n const ids = payload[1].objects;\n const title = payload[1].title.length === 0 ? \"Gemischte Trefferliste\" : payload[1].title;\n\n const request = {\n title,\n hits: ids.map(hit => ({id: hit.objectId, type: hit.objectTypeId}))\n };\n\n await window.osClient.osjxOpenResultList(JSON.stringify(request));\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function getFieldValueByInternal(payload) {\n\treturn JSON.parse(await window.osClient.getFieldValueByInternal(payload[1][0]));\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function setFieldValueByInternal(payload) {\n\treturn JSON.parse(await window.osClient.setFieldValueByInternal(payload[1][0]));\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function setWorkflowVariableByName(payload) {\n\treturn JSON.parse(await window.osClient.setWorkflowVariableByName(payload[1][0]));\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function getEnvironment() {\n\treturn JSON.parse(await window.osClient.getEnvironment());\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function closeModalDialog(payload) {\n await window.osClient.closeModalDialog(payload[1][0]);\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function setDialogCaption(payload) {\n return window.osClient.setDialogCaption(payload[1][0]);\n}\n\n/**\n * Documentation see communication-library.js\n *\n * @private\n */\nasync function getWorkflowVariableByName(payload) {\n\treturn JSON.parse(await window.osClient.getWorkflowVariableByName(payload[1][0]));\n}\n\n/**\n * Calculate the mainType and objectType from objectTypeId and add the properties to the\n * hand in object.\n *\n * @param selectedObject The object to extend\n */\nfunction addObjectTypeAndMainType(selectedObject) {\n if (isTypelessDocument(selectedObject.objectTypeId)) {\n selectedObject.objectTypeId = \"-1\";\n }\n\n // In WebClient it is a string. Therefore toString();\n selectedObject.mainType = (selectedObject.objectTypeId >>> 16).toString();\n\n switch (selectedObject.mainType) {\n case \"0\": selectedObject.objectType = \"FOL