js-executor-cg-lib

1.1.10 • Public • Published

N|Solid

js-executor-cg-lib

1. Introduction

This code is intended to execute javascript code dynamically.

The code was designed under the OIH framwork to make it compatible with other components based on this, allowing to create OIH components to be used in the N3xtGen Portal.

As components are used in the NXGP flows regardless that the library should be added on component code, there are mandatory input parameters that have to be defined for the library to work properly.

Within "js-executor-cg-lib" three additional libraries are used: xml-js: This library allows to transform from xml to json and from json to xml using two of its main methods and sending some configuration parameters, this library is open source. vm: This library is a virtual machine where we can execute the javascript code. luxon: Luxon is a library for dealing with dates and times in JavaScript.. utils-limited: is used to do some general task. cryptr: cryptr is a simple aes-256-gcm encrypt and decrypt module for node.js. lodash: A modern JavaScript utility library delivering modularity, performance & extras.

The next is a following example we have a base64 data and we are going to implement a javascript function to transform it into utf8:

{
    "msg": {
        "data": {
            "content":"W3siX2lkIjoiNjRjMmI1MjliOGJhOWExOTM2MjQyMzA0IiwiaWQiOiJtYjAxNjIwMzEiLCJ0aXRsZSI6ImludGVyZXN0ZWxsYXIiLCJhY3RvciI6Ik1hdHRoZXcgTWNDb25hdWdoZXkiLCJ5ZWFyIjoyMDE0LCJnZW5yZSI6ImZzY2llbmNlIGZpY3Rpb24iLCJzdGFycyI6NSwiZmxhZyI6MH0seyJfaWQiOiI2NGMyYjUyOWI4YmE5YTE5MzYyNDIzMDYiLCJpZCI6InNmMDk3MjAxOSIsInRpdGxlIjoiVGhlIFNoYXdzaGFuayBSZWRlbXB0aW9uIiwiYWN0b3IiOiJNb3JnYW4gRnJlZW1hbiIsInllYXIiOjE5OTQsImdlbnJlIjoiZHJhbWEiLCJzdGFycyI6NSwiZmxhZyI6MH0seyJfaWQiOiI2NGMyYjUyOWI4YmE5YTE5MzYyNDIzMDciLCJpZCI6ImF2MDk3OTMxOSIsInRpdGxlIjoiQXZlbmdlcnM6IEVuZGdhbWUiLCJhY3RvciI6IlJvYmVydCBEb3duZXkgSnIuIiwieWVhciI6MjAxOSwiZ2VucmUiOiJmc2NpZW5jZSBmaWN0aW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9zaCBIYXJ0bmV0dCIsInllYXIiOjIwMDEsImdlbnJlIjoiZnNjaWVuY2UgZmljdGlvbiIsInN0YXJzIjo1LCJmbGFnIjowfSx7Il9pZCI6IjY1MzJmOTdkNGNlZWZhOTAyZjMyYzJmZCIsImlkIjoidHcwOTcwMTY0IiwidGl0bGUiOiJUaGUgd29sZiBvZiB3YWxsIHN0cmVldCIsImFjdG9yIjoiTGVvbmFyZG8gRGljYXByaW8iLCJ5ZWFyIjoyMDEzLCJnZW5yZSI6ImRyYW1hIiwic3RhcnMiOjUsImZsYWciOjB9XQ=="
        }
    },
    "cfg": {
        "code": " async function run(arguments){let s = arguments.content;let base64data = utils.convertBase64ToUtf8(s);console.log(base64data );return {content:JSON.parse(base64data)};}",
        "method":"POST",
        "api":"http://js-nodejs-service.default.flows.oih.cgdemos.com/js_exec"
    }
}

And this is the result:

{
    "content": [
        {
            "_id": "64c2b529b8ba9a1936242304",
            "id": "mb0162031",
            "title": "interestellar",
            "actor": "Matthew McConaughey",
            "year": 2014,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "64c2b529b8ba9a1936242306",
            "id": "sf0972019",
            "title": "The Shawshank Redemption",
            "actor": "Morgan Freeman",
            "year": 1994,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "64c2b529b8ba9a1936242307",
            "id": "av0979319",
            "title": "Avengers: Endgame",
            "actor": "Robert Downey Jr.",
            "year": 2019,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "64c2b529b8ba9a1936242308",
            "id": "bh0971846",
            "title": "Black Hawk Down",
            "actor": "Josh Hartnett",
            "year": 2001,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "64c2b529b8ba9a1936242309",
            "id": "tw0970197",
            "title": "The wolf of wall street",
            "actor": "Leonardo Dicaprio",
            "year": 2013,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "64c3cdebb03540ae9cce39f7",
            "id": "bh0971846",
            "title": "Black Hawk Down",
            "actor": "Josh Hartnett",
            "year": 2001,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6508219805fdc4d95892a937",
            "id": "tt0133068",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "650833443015b15ad5a84c6d",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65116748cb0a30963b06588f",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511680ecb0a30963b065890",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65116976cb0a30963b065891",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65116980cb0a30963b065892",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65116981cb0a30963b065893",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65116f7ccb0a30963b065894",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65116fc7cb0a30963b065895",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511946acb0a30963b065896",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65119548cb0a30963b065897",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511960fcb0a30963b065898",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65119696cb0a30963b065899",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65119ed8cb0a30963b06589a",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "65119ed9cb0a30963b06589b",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a17ecb0a30963b06589c",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a407cb0a30963b06589d",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a408cb0a30963b06589e",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a4cccb0a30963b06589f",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a4cdcb0a30963b0658a0",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a738cb0a30963b0658a1",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a73acb0a30963b0658a2",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a73acb0a30963b0658a3",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511a896cb0a30963b0658a4",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511af79cb0a30963b0658a5",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511af7acb0a30963b0658a6",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b1e1cb0a30963b0658a7",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b1f0cb0a30963b0658a8",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b270cb0a30963b0658a9",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b27ecb0a30963b0658aa",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b299cb0a30963b0658ab",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b299cb0a30963b0658ac",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b45ecb0a30963b0658ad",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b45fcb0a30963b0658ae",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b782cb0a30963b0658af",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b783cb0a30963b0658b0",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b7eacb0a30963b0658b1",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6511b7ebcb0a30963b0658b2",
            "id": "tt0133699",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6513f831c5cd51495eafd97c",
            "id": "tt0133094",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6513fb7dc5cd51495eafd97e",
            "id": "tt0133094",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6514102bb7f0a77c80447c60",
            "id": "tt0133093",
            "title": "The Matrix Revolutions",
            "actor": "Keanu Reeves",
            "year": 2003,
            "genre": "fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7da12ac1468e4c9c9da",
            "id": "tt0209144",
            "title": "Memento",
            "actor": "Guy Pearce",
            "year": 2021,
            "genre": "drama",
            "stars": 4,
            "flag": 0
        },
        {
            "_id": "6532e7da12ac1468e4c9c9de",
            "id": "mb0162096",
            "title": "interestellar",
            "actor": "Matthew McConaughey",
            "year": 2014,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7da12ac1468e4c9c9e0",
            "id": "sf0972075",
            "title": "The Shawshank Redemption",
            "actor": "Morgan Freeman",
            "year": 1994,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7da12ac1468e4c9c9e1",
            "id": "av0979375",
            "title": "Avengers: Endgame",
            "actor": "Robert Downey Jr.",
            "year": 2019,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7da12ac1468e4c9c9e2",
            "id": "bh0978855",
            "title": "Black Hawk Down",
            "actor": "Josh Hartnett",
            "year": 2001,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7da12ac1468e4c9c9e3",
            "id": "tw0970164",
            "title": "The wolf of wall street",
            "actor": "Leonardo Dicaprio",
            "year": 2013,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7dfb3a91f2388c5c0c3",
            "id": "tt0209144",
            "title": "Memento",
            "actor": "Guy Pearce",
            "year": 2021,
            "genre": "drama",
            "stars": 4,
            "flag": 0
        },
        {
            "_id": "6532e7dfb3a91f2388c5c0c7",
            "id": "mb0162096",
            "title": "interestellar",
            "actor": "Matthew McConaughey",
            "year": 2014,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7dfb3a91f2388c5c0c9",
            "id": "sf0972075",
            "title": "The Shawshank Redemption",
            "actor": "Morgan Freeman",
            "year": 1994,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7dfb3a91f2388c5c0ca",
            "id": "av0979375",
            "title": "Avengers: Endgame",
            "actor": "Robert Downey Jr.",
            "year": 2019,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7dfb3a91f2388c5c0cb",
            "id": "bh0978855",
            "title": "Black Hawk Down",
            "actor": "Josh Hartnett",
            "year": 2001,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532e7dfb3a91f2388c5c0cc",
            "id": "tw0970164",
            "title": "The wolf of wall street",
            "actor": "Leonardo Dicaprio",
            "year": 2013,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532f97d4ceefa902f32c2f4",
            "id": "tt0209144",
            "title": "Memento",
            "actor": "Guy Pearce",
            "year": 2021,
            "genre": "drama",
            "stars": 4,
            "flag": 0
        },
        {
            "_id": "6532f97d4ceefa902f32c2f8",
            "id": "mb0162096",
            "title": "interestellar",
            "actor": "Matthew McConaughey",
            "year": 2014,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532f97d4ceefa902f32c2fa",
            "id": "sf0972075",
            "title": "The Shawshank Redemption",
            "actor": "Morgan Freeman",
            "year": 1994,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532f97d4ceefa902f32c2fb",
            "id": "av0979375",
            "title": "Avengers: Endgame",
            "actor": "Robert Downey Jr.",
            "year": 2019,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532f97d4ceefa902f32c2fc",
            "id": "bh0978855",
            "title": "Black Hawk Down",
            "actor": "Josh Hartnett",
            "year": 2001,
            "genre": "fscience fiction",
            "stars": 5,
            "flag": 0
        },
        {
            "_id": "6532f97d4ceefa902f32c2fd",
            "id": "tw0970164",
            "title": "The wolf of wall street",
            "actor": "Leonardo Dicaprio",
            "year": 2013,
            "genre": "drama",
            "stars": 5,
            "flag": 0
        }
    ]
}

2. Methods explanation

The library can be installed from npm page with the next:

npm install js-executor-cg-lib, npm i js-executor-cg-lib or yarn install js-executor-cg-lib

_2.1. processJsExecutor

This method is used to recive de javascript function and the "data" from a previous step and take "data" as arguments of the javascript function an then execute it to send a result.

3. Argument and result explanation

  • Arguments: In the processJsExecutor method there is only one parameter that is required in the transformation and it is described below:

    • code(required): This is a string with the function that the user wants to execute.
  • Result: The result of the execution of the javascript function varies depending on the code that the user has configured to be executed. The input info for the "processJsExecutor" process can be:

 properties.code = `
            async function run(arguments) {
              let EMPLOYEE_SSN = arguments.content.EMPLOYEE_SSN;
              let SEVENELEVEN_LOCATION = arguments.content.SEVENELEVEN_LOCATION;
              let DATE_CLOCKEDIN = arguments.content.DATE_CLOCKEDIN.substring(3,5)+arguments.content.DATE_CLOCKEDIN.substring(0,2)+arguments.content.DATE_CLOCKEDIN.substring(6,8);
              EMPLOYEE_SSN = EMPLOYEE_SSN.replaceAll('-','0');
              SEVENELEVEN_LOCATION = SEVENELEVEN_LOCATION;
              console.log(EMPLOYEE_SSN);
              arguments.content = {...arguments.content, EMPLOYEE_SSN, SEVENELEVEN_LOCATION, DATE_CLOCKEDIN};
              return arguments;
            }
        `
            let data = {
                  "data": {
                      "content": 
                          {
                            "SORT_KEY": "SORT_KEY",
                            "PAYCODE": "PAYCODE",
                            "DATE_CLOCKEDIN": "06/18/23",
                            "TIME_CLOCKEDIN": "TIME_CLOCKEDIN",
                            "DATE_CLOCKEDOUT": "DATE_CLOCKEDOUT",
                            "TIMECLOCKED": "TIMECLOCKED",
                            "TOTALMICLKTIME_AMT": "TOTALMICLKTIME_AMT",
                            "TOTALAMT": "TOTALAMT",
                            "EMP_FIRSTNAME": "EMP_FIRSTNAME",
                            "EMP_MIDDLENAME": "EMP_MIDDLENAME",
                            "EMP_LASTNAME": "EMP_LASTNAME",
                            "PAYPEREND_DATE": "PAYPEREND_DATE",
                            "DLTSVNG_INDICATOR": "DLTSVNG_INDICATOR",
                            "STORECLOSE_TIME": "STORECLOSE_TIME",
                            "EMPLOYEE_SSN": "000-00-0000",
                            "SEVENELEVEN_LOCATION": "CA",
                            "INCURREDNODE_LOCATION": "INCURREDNODE_LOCATION",
                            "CHRGNUMBER_LOCATION": "CHRGNUMBER_LOCATION",
                            "PAYPROCESSCODE": "PAYPROCESSCODE"
                          }
                      
                  }};
      

And the result will be something like this:

{
    "content": {
        "SORT_KEY": "SORT_KEY",
        "PAYCODE": "PAYCODE",
        "DATE_CLOCKEDIN": "180623",
        "TIME_CLOCKEDIN": "TIME_CLOCKEDIN",
        "DATE_CLOCKEDOUT": "DATE_CLOCKEDOUT",
        "TIMECLOCKED": "TIMECLOCKED",
        "TOTALMICLKTIME_AMT": "TOTALMICLKTIME_AMT",
        "TOTALAMT": "TOTALAMT",
        "EMP_FIRSTNAME": "EMP_FIRSTNAME",
        "EMP_MIDDLENAME": "EMP_MIDDLENAME",
        "EMP_LASTNAME": "EMP_LASTNAME",
        "PAYPEREND_DATE": "PAYPEREND_DATE",
        "DLTSVNG_INDICATOR": "DLTSVNG_INDICATOR",
        "STORECLOSE_TIME": "STORECLOSE_TIME",
        "EMPLOYEE_SSN": "00000000000",
        "SEVENELEVEN_LOCATION": "CA",
        "INCURREDNODE_LOCATION": "INCURREDNODE_LOCATION",
        "CHRGNUMBER_LOCATION": "CHRGNUMBER_LOCATION",
        "PAYPROCESSCODE": "PAYPROCESSCODE"
    }
}

3. Examples

The next decribes some examples on how to use the library to execute javascript code. In the next example we are using a javascript function with nested functions :

 {
    "msg": {
        "data": {
            "name":"Alejandro","last_name":"Martínez"
        }
    },
    "cfg": {
        "code": " async function run(arguments){let name = arguments.name;let last_name = arguments.last_name;function say_hi() {return 'hi, my name is ' + name;}function eat() {return 'Eating..';}function getName() {return name +' '+ last_name;} const instance = {};instance.say_hi = say_hi();instance.eat = eat();instance.getName = getName();return instance}"
    }
}

And this is the result:

{
    "say_hi": "hi, my name is Alejandro",
    "eat": "Eating...",
    "getName": "Alejandro Martínez"
}

Another example is to recive a lot of arguments in data and do concatenation:

{
    "msg": {
        "data": {
            "name":"name":"ale","last_name":"mtz","address":"pedernal 623","city":"Gómez","name1":"memo","last_name1":"perez","address1":"malaquita 623","city1":"Torreon","name2":"leo","last_name2":"ramirez","address2":"obsidiana 623","city2":"Lerdo"
        }
    },
    "cfg": {
        "code": "async function run(arguments){var concat1 = arguments.name +' '+ arguments.last_name +' '+ arguments.address +' '+ arguments.city;var concat2 = arguments.name1 +' '+ arguments.last_name1 +' '+ arguments.address1 +' '+ arguments.city1;var concat3 = arguments.name2 +' '+ arguments.last_name2 +' '+ arguments.address2 +' '+ arguments.city2;return concat1 + ' ' + concat2 + ' ' + concat3;};"
    }
}

The result should be as follows:

"ale mtz pedernal 623 Gómez memo perez malaquita 623 Torreon leo ramirez obsidiana 623 Lerdo"

Package Sidebar

Install

npm i js-executor-cg-lib

Weekly Downloads

1

Version

1.1.10

License

ISC

Unpacked Size

89.7 kB

Total Files

9

Last publish

Collaborators

  • cloudgenuser