Blog Posts BPMN DMN

SERVERLESS WORKFLOW EDITOR NEW FEATURE: JQ EXPRESSION AUTO COMPLETIONS

Blog: Drools & jBPM Blog

In Serverless Workflow each instance is associated with a data model. These models consist of JSON objects. The data inside these models needs to be accessed and updated throughout the flow execution. jq is a powerful filtering tool that makes working with JSON data seamless. The Serverless Workflow specification supports the use of jq expressions in multiple places.

What’s New?

In order to improve the authoring experience for the user while working with these expressions, a new auto-completion capability is added to the editor. These features are available in the VS Code extension as well as the Serverless Logic Web Tools and work with both JSON and YAML files.

Requirements:

The jq auto-completion feature can be categorized into three:

The Built-In Functions:

These are functions provided by jq out of the box. These functions come in handy to do a lot of operations like max, min, length, etc. The completion provides a list of these functions along with a description of what it does so that the user does not have to read the docs every time. More information on the built-in functions can be found here.

Built-in function completions

The Workflow Variables:

Workflow variable completions

The serverless workflow works with a lot of variables, which are provided to the project in the form of a JSON schema, an open API file, or an async API file. A Variable in Serverless Workflow always starts with a .(DOT). The auto-completion feature parses these files (if present), extracts the variables, and provides the completion result to the user. Please note that the auto-completion feature is able to parse files in a remote URL as well as a local file system.

In the first part of the video above, there is a JSON schema file present in the path: resources/schema/expression.json. The jq expressions can work in certain places and one of them is in the operation of functions which is of type expression. As you can see, the JSON schema has numbers, x, and y in its properties which are listed in the completion items. Please note that remote URLs are also supported for JSON schema.

In the second part of the video, we have a function (Check action on RHODS) and this is an OpenAPI specification. We use a remote URL here and we see in the OpenAPI file some parameters available like noOfRunningPods, avgLoad, etc while trying to use the auto-complete we can see these values appearing in the completion item list. Please note that local files (eg: resources/spec/multiplication.yaml) also works.

In the third part of the video we have a function which is of type async API and the corresponding file is present in the resources/spec/resume-event.yaml. When trying to auto-complete, we parse the async api file and extract the parameters out of it and show the completion items. Please note that this also works with remote URLs.

The Reusable Function Expressions:

A reusable function expression is a function definition inside the functions array, which has a type (field) expression and a jq expression as the value for the operation field. These functions can be reused in the specification using the fn: followed by name of the function. The auto-completion feature also provides a list of these functions present in the functions array.

Reusable function expression completion

Note: The expressions can be used in various places. To know more about the usage please visit here.

Conclusion:

The auto-completion feature assists the user in writing the jq expressions and thus improves the authoring experience. In order to learn more about the jq expression in Serverless Workflow, please visit our blog post on  Serverless Workflow Expressions.

Stay tuned to get more updates on the upcoming features for the Serverless Workflow.

The post SERVERLESS WORKFLOW EDITOR NEW FEATURE: JQ EXPRESSION AUTO COMPLETIONS appeared first on KIE Community.

Leave a Comment

Get the BPI Web Feed

Using the HTML code below, you can display this Business Process Incubator page content with the current filter and sorting inside your web site for FREE.

Copy/Paste this code in your website html code:

<iframe src="https://www.businessprocessincubator.com/content/serverless-workflow-editor-new-feature-jq-expression-auto-completions/?feed=html" frameborder="0" scrolling="auto" width="100%" height="700">

Customizing your BPI Web Feed

You can click on the Get the BPI Web Feed link on any of our page to create the best possible feed for your site. Here are a few tips to customize your BPI Web Feed.

Customizing the Content Filter
On any page, you can add filter criteria using the MORE FILTERS interface:

Customizing the Content Filter

Customizing the Content Sorting
Clicking on the sorting options will also change the way your BPI Web Feed will be ordered on your site:

Get the BPI Web Feed

Some integration examples

BPMN.org

XPDL.org

×