Dynamic Parametrization: Javascript-computed Parameters
Some parameters of some operations (eg URL, headers, and body parameters of HTTPRequest operation) are dynamically computed using Javascript. Javascript-computed values is a dynamic parametrization mechanism that is an alternative to template literals. In this section we describe functionality and tips that are operation-independent and thus can be used for any Java-script computed parameters.
Builtin functions
ilBuildJWTToken(spec)
ilBuildJWTToken creates JSON Web Token (JWT). It is based on Java JWT (jjwt) library .
spec(type: object) - JWT specification in the format described below.
JWT specification is an object with the following properties:
claims(type: array) - contains claim objects with the following properties. Each property has a short and long name:Issueroriss(type: string)Subjectorsub(type: string)Audienceoraud(type: string)Expiration Timeorexp(type: object):chronoUnit(type: string) - for a list of possible values see Java class java.time.temporal.ChronoUnit . The string must match exactly an identifier used to declare an enum constant in the class.duration(type: string) - number (represented as string) of chronoUnit.
Not Beforeoriss(type: object)chronoUnit(type: string) - for a list of possible values see Java class java.time.temporal.ChronoUnit . The string must match exactly an identifier used to declare an enum constant in the class.duration(type: string) - number (represented as string) of chronoUnit.
Issued Atoriat(type: string) -"now"or epoch timestamp in millisecondsJWT IDorjti(type: string)- any custom claim (type: string)
ilBase64Decode(str)
Decodes a Base64 encoded string.
ilBase64Encode(str)
Decodes a string using the Base64 encoding scheme.
ilDates()
ilDates is based on the momentjs.com library. You can find the documentation at momentjs documentation . You can find examples at:
- General examples at their home page
- Examples with timezones at Moment Timzone page
Example:
ilDates().tz("UTC").format("YYYYMMDDTHHmm") // returns "20221101T2316"ilTable($il, sourceName, spaceName, tableName, tableFormat)
ilTable loads a table from a source into memory (IMPORTANT: use it only for small tables).
$il(type: object) - pass$ilthat is predefined in any Java-computed parametersourceName(type: string) - source namespaceName(type: string) - space nametableName(type: string) - table nametableFormat(type: string) - can be:"table"- for table-format tables, returns an array of records;"JSON"- for JSON-format tables;"file"- for file-format tables, returns the content of the file as string
ilQueryQL($il, sourceName, query)
Executes the query in the source and returns the result as a Javascript array. ilQueryQL loads the result of the query into the main memory (IMPORTANT: use it only for queries returning small number of records).
$il(type: object) - pass$ilthat is predefined in any Java-computed parametersourceName(type: string) - source namequery(type: string) - query to execute in the source
ilCastToArray(value)
Casts a value of any type to array:
- If value is an array, the value is returned
- If value is null or undefined, an empty array is returned
- If value is of any other time,
[value]is returned
ilXMLGetLocalName(xmlElementName)
Return the local name of the XML element name if a namespace prefix is present. Otherwise returns the input name. For example:
ilXMLGetLocalName("n:product") // returns `"product"`
ilXMLGetLocalName("product") // returns `"product"`xmljs
The whole xml-js library convert XML text to Javascript object / JSON text (and vice versa).
Example:
xmljs.xml2js("<product></product>", {compact: true}) // converts xml to jsonilXMLParse(str)
Parses XML to json. It is defined as follows using xmljs that is described above:
var ilXMLParse = function(inStr) {
return ilXMLTextNodesToStrings(xmljs.xml2js(inStr, {compact: true, elementNameFn: function(val) {return ilXMLGetLocalName(val);}}));
};Tips
Get Current Date
new Date().toISOString() // returns the current data formated as "2022-11-02T21:19:41.297Z"