Options
All
  • Public
  • Public/Protected
  • All
Menu

Vlocity SDK

Vlocity SDK's

The Vlocity Software Development Toolkit (SDK) is a collection of Vanilla JavaScript SDKs that are designed to interact with Vlocity's product capabilities. The SDKs are packaged for different industrial applications and are version specific. For example, if you have installed the CME ** package in your Salesforce org, you will use the corresponding CME ** SDKs.

Key features of SDKs:

  • Pure JavaScript libraries that expose the capabilities of Vlocity products,
  • Includes both common and industry specific SDKs,
  • SDKs are framework and platform agnostic; Vlocity SDKs work with the framework of your choice, including AngularJS, React and Polymer,
  • SDKs are extensible: all SDKs allows developers to extend and override out-of-the-box function,
  • SDKs are versioned: SDK releases are tied to your package version,
  • SDKs are distributed via NPM registry and are also available in Salesforce org as a static resource.

Content

List of available SDKs

1. datasource.sdk

The 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

The Translation SDK provides translations for labels via Salesforce custom labels.

3. account.sdk

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

4. digitalcommerce.sdk

The Digital Commerce SDK provides the ability to retrieve offers, offer validation and cart operation capabilities.

5. pubsub.sdk

The Pub Sub SDK provides the ability to publish and subscribe events across different UI components.

5. cpq.sdk

The CPQ SDK provides the ability to call all cart based V2 API's.

6. b2bexpress.sdk

The B2B Express SDK provides the ability to call all cart based V2 API's and express VIP & DR's.

SDK User Guide

1. SDK is a singleton

All SDKs are singletons. This means there is (and should only be) one instance of the SDK in the application you are building. Having only one instance ensures the states stored in the SDK are shared across different UI components in the application, and also eliminates the consumption 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, retrieve 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 the Vlocity 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 datasource version

SDK Distribution

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

1. Static resource in package

In Vlocity package is a static resource - vlocitysdk. Developers can use this static resources inside Visualforce pages to load the necessary SDKs.

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

2. NPM Registry

Vlocity SDKs are available on the Vlocity protected npm registry. Similar to any UI development, you can add and load the Vlocity SDK dependency. You will need npm and NodeJS LTS 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": "107.1.0",
    "@vlocity-cme-sdk/digitalcommerce-sdk": "107.1.0",
    "@vlocity-cme-sdk/translation-sdk": "107.1.0"
    ...
  },

2. Install dependencies on command prompt

npm install

3. Sample UI Partner Development project

To simplify UI development, Vlocity has created a partner development bootstrap project with SDK npm dependency preconfigured. There are sample applications that show how to use various SDK functionalities. To get access to our bootstrap project, please file a request with your account representative.

Generated using TypeDoc