Skip to content
JavaScript library for consuming Qlik's Associative Engine.
JavaScript Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci chore(deps): update qlikcore/engine docker tag to v12.515.0 (#680) Nov 23, 2019
.github Update PULL_REQUEST_TEMPLATE.md (#286) Oct 25, 2017
docs chore: bump enigma.js to v2.6.3 (#682) Nov 25, 2019
examples SonarQube alignment (#637) Aug 29, 2019
schemas Add 12.170.2.json schema (#490) Aug 20, 2018
src fix: no undefined error on closed resolver (#678) Nov 25, 2019
test feat: send code and reason through suspend chain (#673) Nov 12, 2019
.babelrc Babel 7 and after-work.js 5 (#496) Aug 30, 2018
.editorconfig Update eslint-plugin-import to the latest version 🚀 (#281) Oct 19, 2017
.eslintignore Bump eslint-config-airbnb-base from 12.1.0 to 13.0.0 (#464) Jun 25, 2018
.eslintrc Only use the passed-in Promise constructor (#123) Jul 7, 2017
.gitignore feat: expose error-codes (#661) Oct 28, 2019
CHANGELOG.md chore: bump enigma.js to v2.6.3 (#682) Nov 25, 2019
LICENSE Initial commit Dec 14, 2016
README.md Remove greenkeeper CI logic (#444) Jun 7, 2018
enigma.png Initial commit Dec 14, 2016
getting-started.gif Getting started gif (#222) Aug 25, 2017
jsdoc-config.json Initial commit Dec 14, 2016
package-lock.json chore(deps): update dependency @babel/preset-env to v7.7.6 (#690) Dec 8, 2019
package.json chore(deps): update dependency @babel/preset-env to v7.7.6 (#690) Dec 8, 2019
renovate.json chore: configure renovate (#520) Sep 28, 2018
rollup.config.js chore: dont generate source maps for error-codes (#666) Oct 31, 2019
spec.config.js Generating api-spec with Scriptappy (#508) Sep 14, 2018

README.md

CircleCI Coverage Status

enigma.js is a library that helps you communicate with Qlik QIX Engine. Examples of use may be building your own browser-based analytics tools, back-end services, or command-line scripts.



Getting started

Prerequisites

Before continuing, make sure that you have these tools installed:

  • Node.js >= 4.0
  • Git bash if on Windows

And know of at least some of these web technologies:

  • JavaScript
  • Promises
  • Websockets

Schemas

enigma.js use schemas as a source when generating the QIX Engine API. The exact version of the schema you need is based on the QIX Engine version you want to communicate with, as well as what you plan on using in the QIX Engine API.

Keep in mind that before version 12.20.0 the schema version corresponds to the Qlik Sense Enterprise version, and from 12.20.0 and forward, the schema version is mapped to the QIX Engine API version.

Read more:

Usage

First off, install enigma.js and a WebSocket library:

npm i -S enigma.js ws

Next, create a new file called my-file.js and put the following code into it:

const enigma = require('enigma.js');
const WebSocket = require('ws');
const schema = require('enigma.js/schemas/12.20.0.json');

// create a new session:
const session = enigma.create({
  schema,
  url: 'ws://localhost:9076/app/engineData',
  createSocket: url => new WebSocket(url),
});

// bind traffic events to log what is sent and received on the socket:
session.on('traffic:sent', data => console.log('sent:', data));
session.on('traffic:received', data => console.log('received:', data));

// open the socket and eventually receive the QIX global API, and then close
// the session:
session.open()
  .then((/*global*/) => console.log('We are connected!'))
  .then(() => session.close())
  .then(() => console.log('Session closed'))
  .catch(err => console.log('Something went wrong :(', err));

And then run it:

node my-file.js

You may need to adjust the code so the URL points towards your running QIX Engine.

/getting-started.gif

You may also use a service like unpkg to test enigma.js directly in your browser without using Node.js for development purposes.

Create a HTML file index.html and insert the following example content:

<script src="https://unpkg.com/enigma.js/enigma.min.js"></script>
<script>
  fetch('https://unpkg.com/enigma.js/schemas/12.34.11.json')
    .then(response => response.json())
    .then(schema => {
      const session = enigma.create({
        schema,
        // Change the url to point to your QIX instance
        url: 'ws://localhost:9076/app/engineData',
        createSocket: url => new WebSocket(url)
      })

      session.open()
        .then(global => global.engineVersion())
        .then(result => document.body.innerHTML = result.qComponentVersion)
        .then(() => session.close())
    });
</script>
You can’t perform that action at this time.