@commandalkon/connex-sdk
CONNEX SDK for NodeJS
Last updated 10 months ago by douglasamoore .
ISC · Original npm · Tarball · package.json
$ cnpm install @commandalkon/connex-sdk 
SYNC missed versions from official npm registry.

CONNEX by Command Alkon

CONNEX is the Supplier Collaboration Platform For Construction's Heavy Work!


Quick Start

Install via npm:
npm -i @commandalkon/connex-sdk
Verify your configuration

In the main index.js file, initialize the CONNEX SDK.

const CONNEX = require('@commandalkon/connex-sdk');

const params = {
  appId: 'Your App ID',
  apiKey: 'Your API Key',
};

CONNEX.Config.initialize(params);

// If the following code generates an error, your appId and apiKey 
// settings are probably invalid.
new CONNEX.App().getApp()
    .then(app => console.log(app))
    .catch(err => console.error(err))

// Displays the following
{"appId": "Your App ID","version": "Your App Version"}
    
Write a CONNEX Ticket Search Hook

Create a folder named hooks with a single file in it named data-ticket-search-after.js with the code shown below.

// Transform the original ticket into UDM 1.0 (universal data model)
const transformToUDM = (ticket) => {
  return {
    id: 'id-' + ticket.id // Ticket Number
  }
};

// Transaform all tickets in the ticket response to UDM format
async function handleEvent(params) {
  const {input: ticketRs} = params;

  for (let i = 0; i < ticketRs.items.length; i++) {
    ticketRs.items[i] = transformToUDM(ticketRs.items[i])
  }

  return ticketRs;
}

module.exports = {
  handleEvent,
};
Deploy CONNEX Ticket Search Hook

In the main index.js file, write a utility to deploy all code hooks using CONNEX Tools

const CONNEX = require('@commandalkon/connex-sdk');

const params = {
  appId: 'Your App ID',
  apiKey: 'Your API Key',
};

CONNEX.Config.initialize(params);

// Register all hooks in the ./hooks sub-folder
CONNEX.Tools.registerHooks('hooks')
    .then(rs => console.log(rs))
    .catch(err => console.error(err.message));
    
// If successful, you should see something like the following in the console.
1 App Hooks Registered
{
  "items": [
    {
      "modifyDate": "2019-07-23T20:11:48.470Z",
      "code": "const transform = (ticket) => {\n  return {\n    id: 'id-' + ticket.id,\n  }\n};\n\nasync function handleEvent(params) {\n  const {input: ticketRs} = params;\n\n  for (let i = 0; i < ticketRs.items.length; i++) {\n    ticketRs.items[i] = transform(ticketRs.items[i])\n  }\n\n  return ticketRs;\n}\n\nmodule.exports = {\n  handleEvent,\n};\n",
      "createDate": "2019-07-23T20:11:48.470Z",
      "typeId": "hook",
      "pk": "[your appId]-hook",
      "crn": "data-ticket-search-after"
    }
  ],
  "pageToken": null
}    

Current Tags

  • 1.0.25-beta.2                                ...           beta (8 months ago)
  • 1.0.24                                ...           latest (10 months ago)

26 Versions

  • 1.0.25-beta.2                                ...           8 months ago
  • 1.0.25-beta.1                                ...           9 months ago
  • 1.0.25-beta.0                                ...           10 months ago
  • 1.0.24                                ...           10 months ago
  • 1.0.22                                ...           10 months ago
  • 1.0.21                                ...           10 months ago
  • 1.0.20                                ...           10 months ago
  • 1.0.19                                ...           10 months ago
  • 1.0.18                                ...           10 months ago
  • 1.0.17                                ...           10 months ago
  • 1.0.16                                ...           10 months ago
  • 1.0.15                                ...           10 months ago
  • 1.0.14                                ...           10 months ago
  • 1.0.13                                ...           10 months ago
  • 1.0.12                                ...           10 months ago
  • 1.0.11                                ...           10 months ago
  • 1.0.10                                ...           10 months ago
  • 1.0.9                                ...           10 months ago
  • 1.0.8                                ...           10 months ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Downloads
Today 0
This Week 26
This Month 26
Last Day 0
Last Week 0
Last Month 26
Dependencies (4)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |