Giter Club home page Giter Club logo

sp-connector-sdk-js's Introduction

Connector SDK for JavaScript

Overview

Connector SDK for JavaScript is a framework for developing a SaaS connector for IdentityNow.

Getting Started

Setup

Create a Node.js project and install SDK. We strongly recommend using TypeScript to take advantage of static type checking.

npm install @sailpoint/connector-sdk

Installing from Source

To install the SDK from GitHub:

npm install github:sailpoint/saas-connector-sdk-js#main

To install the SDK from local clone, run npm pack from SDK project, then run in target project:

npm install <path-to-sailpoint-connector-sdk-semver.tgz>

Import

import { createConnector } from '@sailpoint/connector-sdk'

Usage

Initialize Connector object in index.ts/.js and export it to the module.

// index.ts
import {
    Connector,
    Context,
    createConnector,
    readConfig,
    Response,
    StdAccountReadInput,
    StdAccountReadOutput
} from '@sailpoint/connector-sdk'

// Get connector source config
const config = readConfig()

export const connector: Connector = createConnector()
    .stdAccountRead((context: Context, input: StdAccountReadInput, res: Response<StdAccountReadOutput>) => {
        // TODO: Fetch account from source

        res.send({
            identity: 'john.doe',
            uuid: '1234',
            attributes: {
                email: '[email protected]',
            },
        })
    })
    .command('my:custom:command', (context, input, res) => {
        // TODO: implement me!
    })

Logging

Use SDK provided logger to ensure log statements will include command execution context fields.

import {logger} from '@sailpoint/connector-sdk'

Examples

See complete examples in the examples directory.


Connector Local Development with spcx

spcx provides:

  • ability to execute the connector locally
  • ability to invoke mock commands against locally-running connector for testing/debugging
  • built-in TypeScript support, with watch run and inline source map

spcx starts up an HTTP server locally (default port=3000) that can be used to invoke a command against the connector. spcx cleanly imports the connector module from specified file path at every request, so the server does not need to be restarted after every code edit. Just start it up once and keep on using until you are done!

For connectors written in TypeScript, spcx automatically spawns a child process to execute tsc with --watch and --inlineSourceMap options, as well as user-defined compiler options in the project's tsconfig.json. --watch option prevents needing to manually recompile after code edit, and --inlineSourceMap option allows debugger to function with breakpoints set in original TypeScript source.

$ spcx <connector-file-js> [port=3000]

spcx can also be run using npm script, e.g. $ npm run dev:

{
  "scripts": {
    "dev": "spcx dist/index.js"
  }
}

--

To invoke a command, simply provide command's type, input, and connector config

Ex: POST http://localhost:3000

{
  "type": "std:account:read",
  "input": {
    "identity": "john.doe"
  },
  "config": {
    "key": "value"
  }
}

Contributing

Building Source

To build the SDK source (generates output in dist directory):

npm run build

To run unit tests:

npm run test

To run prettier to format code:

npm run prettier

sp-connector-sdk-js's People

Contributors

fangming-ning-sp avatar hemanth-vakkapatla-sp avatar ashley-george-sp avatar hesam-chobanlou-sp avatar bob-potter-sp avatar philip-ellis-sp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.