Options
All
  • Public
  • Public/Protected
  • All
Menu

Vlocity SDK

Vlocity SDK's

This is a collection of vanilla JavaScript SDK's to interact with Vlocity's product capabilities. Our SDKs are packaged for different industrial applications and version specific. For example, if you have CME 104.0 package installed in your Salesforce org, you will need to use corresponding CME 104.0.0 SDKs.

Key features of SDKs:

  • Pure JavaScript libraries that expose our products' capabilities
  • Common and industry specific SDKs
  • Framework and platform agnostic: Vlocity SDKs work with any framework of your choice including AngularJS, React and Polymer.
  • Extensible: all SDKs allows developers to extend and override our out of the box functions.
  • Versioned: SDKs releases are tied to your package version.
  • SDKs are distributed via NPM registry as well as available in Salesforce org as static resource.

Content

List of available SDKs

1. datasource.sdk

Datasource SDK provides convenient functions to access Salesforce, Vlocity and generic REST APIs including SOQL, SOSL, Apex REST, Apex Remote, Vlocity DataRaptor, Integration Procedure, and REST.

2. translation.sdk

Translation SDK provides translations for labels via Salesforce custom labels.

3. account.sdk

Account SDK provides Vlocity account based contracts, assets and intelligent offer capabilities.

4. digitalcommerce.sdk

Digital Commerce SDK provides getting offers, offer validation and cart operation capabilities.

SDK User Guide

1. SDK is a singleton

All SDKs are singletons. This means there is and should only be 1 instance of the SDK in the application you are building. This ensures the states stored in the SDK are shared across different UI components in the application as well as eliminating the use of memory for multiple SDK instances.

2. How to get an instance of the SDK

First, create an SDK configuration object or use SDK function to create a default configuration object if provided. Then get an instance with the SDK configuration object.

const datasourceSDKConfig = {
  sessionId: "SalesforceSessionId";
  useApexRemoteForDualDataSource: true;
};
const datasource = VlocitySDK.datasource.getInstance(datasourceSDKConfig);

const soqlInput =  { query: "select id from Account" };
datasource.soql(soqlInput).execute().then(result => {
  // do something with result
});

3. How to extend or override SDK functions

All of our SDKs allows developers to override and extend out of the box functions.

const datasourceSDKExtension = {
  stream() {
    // return readable Node stream;
  },
  poll() {
    return "add poll function";
  }
};
DataSource.extend(datasourceSDKExtension);

const datasource = DataSource.getInstance(config);

// using SDK extension
datasource.stream().on('data', (chunk) => {...});

SDK Versioning

SDKs use Semantic Versioning to define SDK version in the form of "MAJOR.MINOR.PATCH". SDKs provides matching functionalities that are available in the matching packages.

How to check the sdk version in bundled js library?

const datasource = VlocitySDK.datasource.getInstance(datasourceSDKConfig);
datasource.version();// return "104.0.0"

SDK Distribution

Vlocity SDKs are distributed inside Vlocity packages as well as via our NPM registry.

1. Static resource in package

In our Vlocity package, there is a static resource - vlocitysdk. Developers can use this static resources inside Visualforce pages.

<script src="{!URLFOR($Resource.vlocitysdk, 'latest/datasource/datasource.sdk.js')}"></script>

2. NPM Registry

Vlocity SDKs are available on our npm registry. Similar to any UI development, you can add and load the Vlocity SDK dependency. You will need npm installed on your local development machine.

1. Set up npm dependencies in .npmrc and package.json

.npmrc

email=<email>
always-auth=true
_auth=<authToken>
registry=https://repo.vlocity.com/repository/npm-public/

package.json

 "dependencies": {
    ...
    "@vlocity-cme-sdk/datasource-sdk": "104.0.0",
    "@vlocity-cme-sdk/digitalcommerce-sdk": "104.0.0",
    "@webcomponents/webcomponentsjs": "^2.0.2",
    ...
  },

2. Install dependencies on command prompt

npm install

3. Sample UI Partner Development project

To simplify UI development, we have a partner development bootstrap project with SDK npm dependency pre-configured. There are sample applications on how to use various SDKs' functionalities. To get access to our bootstrap project, please file a request through Vlocity Support Portal or speak to your account representative.

Generated using TypeDoc