Skip to content

Latest commit

 

History

History
101 lines (72 loc) · 2.58 KB

api.md

File metadata and controls

101 lines (72 loc) · 2.58 KB

API

q

The qlik-sse module

const q = require('qlik-sse');

q.sse

A namespace for easy access to types, all types in SSE.proto are accessible from this namespace:

console.log(q.sse.FunctionType.AGGREGATION); // 1

q.server(options)

  • options <Object>
    • identifier <string> Identifier for this SSE plugin.
    • allowScript <boolean> Whether to allow script evaluation. Defaults to false.
  • returns: <Server>

Creates a new Server instance.

const q = require('qlik-sse');

const server = q.server({
  identifier: 'abc',
  allowScript: true,
});

Server

server.addFunction(fn, config)

  • fn <function (Request)>
  • config <Object>
    • functionType <[FunctionType]> Type of function
    • returnType <[DataType]> Type of data this function is expected to return
    • params <Array<Object>>
      • name <string>
      • dataType: <[DataType]>
    • tableDescription <[TableDescription]> Description of the returned table when function is called from load script using the extension clause.

Register a function which can be called from an expression.

const fn = (request) => {/* do stuff */};
server.addFunction(fn, {
  functionType: q.sse.FunctionType.TENSOR,
  returnType: q.sse.DataType.NUMERIC,
  params: [{
    name: 'first',
    dataType: q.sse.DataType.NUMERIC
  }]
})

server.start(options)

  • options <Object>
    • port <number> Port to run the server on. Defaults to 50051.

Starts the server.

Request

request.on(event, fn)

  • event <string> Name of event to listen to. Possible values: data.
  • fn <function ([BundledRows])>
request.on('data', (bundle) => {/* deal with bundle*/})

request.write(bundle)

  • bundle <[BundledRows]>

Writes data back to Qlik Engine.

request.on('data', (bundle) => {
  const returnBundle = {/* */};
  request.write(returnBundle);
});