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:
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.
Translation SDK provides translations for labels via Salesforce custom labels.
Account SDK provides Vlocity account based contracts, assets and intelligent offer capabilities.
Digital Commerce SDK provides getting offers, offer validation and cart operation capabilities.
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.
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
});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) => {...});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.
const datasource = VlocitySDK.datasource.getInstance(datasourceSDKConfig);
datasource.version();// return "104.0.0"Vlocity SDKs are distributed inside Vlocity packages as well as via our NPM registry.
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>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.
.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",
...
},npm installTo 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