Scripting

When configuring the specific business logic of a processing step, you may find it necessary to express arbitrarily complex logic. For instance, you might have knowledge of a number of attributes relating to a single user you are processing, and want to associate the user with some roles in the Pathify portal.

This logic is constructed in Javascript (ECMAScript 1.4). Configuration elements which are enabled for this are named jsFunc, for Javascript Function.

Your configuration looks just like a function, and you control its body all the way down to, and including, the return statement. You do not, however, control the signature of the function. The signature is provided by the runtime and is used to inject many context variables and symbols into scope for your usage.

Some examples of these injected structures are:

  • _ The underscore symbol, which contains all members of the Javascript library lodash.
  • item, which is passed into a mapping function and represents the implicit iterator, in the same way as Groovy's it, which this author holds to be a pun on iterator rather than the definite article. This very useful symbol is defined for mapper and flat mapper.
  • payload, a reference to the overall payload object and a useful place to find caching between steps but not between full executions.
  • DBHelper, a collection of functions enabling high level Scala database operations.
  • LineHelper, a collection of functions enabling string and encoding manipulation.
  • URLParser, a collection of functions enabling path, location and parameter manipulation.
  • warn, error and trace, a standard log level primitive enabling messaging to a payload level log collection.
  • XmlHelper, a collection of functions enabling high performance XML processing and traversal in-process.
  • ...and many other operations, listed in full under the JS Symbols collection.