Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
/ halyard.js Public archive

JavaScript library for generating Qlik Load Scripts using an abstracted API.

License

Notifications You must be signed in to change notification settings

qlik-oss/halyard.js

Repository files navigation

As of 1 July 2020, Qlik Core is no longer available to new customers. No further maintenance will be done in this repository.

CircleCI Dependabot Status Coverage Status

halyard.js is a JavaScript library that simplifies the Qlik Sense data load experience as it abstracts away the need to write a load script.

The functionality in halyard.js is divided into two parts where the first one is halyard.js itself. It generates the load script, as well as the connections needed. The second part is halyard-enigma-mixin.js that extends the functionality of enigma.js to bring your halyard representation into the QIX engine.

halyard.js - API Basics

let halyard = new Halyard();

setDefaultSetStatements(defaultSetStatements[, preservePreviouslyEnteredValues])

Adds custom set statements to the beginning of the script. Typically used to configure time/data/currency settings.

defaultSetStatements is an object where the key becomes the variable name in the set statement, and the value becomes the variable value.

halyard.setDefaultSetStatements({DateFormat: 'MM-DD-YYYY'});
// getScript() will return SET DateFormat='MM-DD-YYYY';

Any entered default set statement will be replaced by default if this method is called a second time with defaultSetStatement containing already defined keys. If preservePreviouslyEnteredValues is set to true, then previously entered set statements will be preserved even if the setDefaultSetStatements method is called multiple times.

addTable(table)

Adds a table to the data model representation. More info about Halyard.Table.

The addTable method accepts an explicit table definition:

let table = new Halyard.Table('c:\\data\\file.csv');
halyard.addTable(table);

addTable returns a Halyard.Table instance

addTable(connection[, tableOptions])

You can also add a table by providing the table definition:

halyard.addTable('c:\\data\\file.csv', 'TableName');

addTable returns a Halyard.Table instance

addHyperCube(hyperCube)

Adds a hyper cube to the data model representation. More info about Halyard.HyperCube.

The addHyperCube method accepts an explicit hyper cube definition:

let hyperCube = new Halyard.HyperCube(qHyperCube);
halyard.addHyperCube(hyperCube);

Example qHyperCube

addHyperCube returns a Halyard.HyperCube instance

addHyperCube(hyperCubeLayout[, hyperCubeOptions])

You can also add a hyper cube by providing the hyper cube definition:

halyard.addHyperCube(qHyperCube, 'HyperCubeName');

addHyperCube returns a Halyard.HyperCube instance An example of a how to use this method hyper-cube.js in examples

addItem(item)

Adds any object that responds to getScript(). An example of a how to use this method to extend with custom functionality extending-functionality.js in examples

getScript()

Retrieves the script representation of the items added to halyard.js. The script returned can be set to QIX Engine using the setScript(script) method.

halyard.getScript();

getQixConnections()

Returns an array of QIX connections that needs to be created before the doReload() method is called. To create connections, use the createConnection(connection) method.

halyard.getQixConnections();

getItemThatGeneratedScriptAt(charPosition)

Returns the item that generated the script block at the specified character position from the getScript() call. The main usage for this method is to identify what item that causes a reload failure.

const syntaxErrorAtCharacterPosition = 32;

halyard.getItemThatGeneratedScriptAt(syntaxErrorAtCharacterPosition);

halyard-enigma-mixin.js

createSessionAppUsingHalyard(halyard)

Creates a session app according to the specification setup in the Halyard instance provided. This method will return the session app.

createAppUsingHalyard(appName, halyard)

Creates an app with the specified appName and Halyard instance. This method will return the an app object.

reloadAppUsingHalyard(existingAppName, halyard[, createIfMissing])

Updates an existing app named existingAppName with new data from the Halyard instance. If createIfMissing is set to true, an app is created if it does not already exist.

Note that this method replaces any script that already exist in the app.

setScriptAndReloadWithHalyard(app, halyard, doSaveAfterReload)

Sets data from the halyard instance to the app instance. If doSaveAfterReload is set to true, the app is saved after the data has been set. This method will return the app.

Extending with new functionality

See extending-functionality.js in examples for more info about how to extend with new functionality.

Contributing

Please follow the instructions in CONTRIBUTING.md.

Examples

More examples can be found in examples or in the examples/ folder.