Create a new DataSource.
Config for this SDK.
Private singleton instance of this SDK. There should always be only 1 instance.
getter method for namespace. Provides the salesforce org namespace
setter method for namespace. Set custom namespace
Create a new ApexRemote wrapper
creates new apexRemoteInput
{ cacheable:false retryCount:0, timeoutInMillis:20000, reload:false, className:"className", methodName:"methodName", paramsArray:paramsArray; config:config; }
Create a new ApexRest wrapper
creates new apexRestInput
{ cacheable:false retryCount:0, timeoutInMillis:20000, reload:false, path:"path", method:"method", body:body; }
clears the cache store
Create a new dataRaptor wrapper
creates new dataRaptorInput
{ inputParamsString:"name=vlocity&state=ca", bundleName:"name" cacheable:false retryCount:0, timeoutInMillis:20000, reload:false, }
deletes the cached response for the given cache key as generated from input object.
is the generated from input object. For example, the key for ApexRestInput will be:
const key = apexRestInput.digest();
is a optional parameter. It is the type of cache to be used. It will be of the type CacheType Enum. If not specified it will be indexed db
Create a dual data source that will automatically switch between Apex Rest or Apex Remote (if available).
Apex Rest API Input.
Apex Remote Input.
a instance of DualDataSource.
Get the cached response for the given cache key as generated from input object.
is the generated from input object. For example, the key for ApexRestInput will be:
const key = apexRestInput.digest();
is a optional parameter. It is the type of cache to be used. It will be of the type CacheType Enum. If not specified it will be indexed db
gets all keys for the given DB and store
gets cached Data if current Date time is within expiration time
is generated from input object. For example, the key for ApexRestInput will be:
const key = apexRestInput.digest();
is a optional parameter. It is the type of cache to be used. It will be of the type CacheType Enum. If not specified it will be indexed db
Create a new integrationProcedure wrapper
creates new integrationProcedureInput
{ input: {}, optionsMap: {}, procedureKey: "TEST_SDK", cacheable:false retryCount:0, timeoutInMillis:20000, reload:false, }
Create a new Rest wrapper
creates new restInput
{ url: "/test",
cacheable:false, retryCount:0, timeoutInMillis:20000, reload:false, }
sets the response for the given cache key as generated from input object.
is the generated from input object. For example, the key for ApexRestInput will be:
const key = apexRestInput.digest();
is the data which needs to be cached.
is a optional parameter. It is the type of cache to be used. It will be of the type CacheType Enum. If not specified it will be indexed db
sets results the cache based on the optional parameter value
is generated from input object. For example, the key for ApexRestInput will be:
const key = apexRestInput.digest();
is the data which needs to be cached
is a optional parameter. It is the type of cache to be used. It will be of the type CacheType Enum. If not specified it will be indexed db
set a deafault timeout at datasource level
set a deafault retry count at datasource level
Create a new Soql wrapper
creates new soqlInput
{ query: "SELECT id from Account LIMIT 5", cacheable:false, retryCount:0, timeoutInMillis:20000, reload:false, }
Create a new Sosl wrapper
creates new soslInput
{ query: "FIND{ M1-5} IN ALL FIELDS RETURNING Account(Id, Name)", cacheable:false, retryCount:0, timeoutInMillis:20000, reload:false, }
Returns the version number of SDK.
Returns SDK version number as string
Create a DatasourceSDKConfig object.
Configuration object to instantiate SDK.
Adds all the enumerable string keyed function properties of a source
object to the sdk prototype.
.extend
should only be used to add new methods and it won't override the existing methods.
Note: If the property already exists, it will be not be added.
Custom functions which are being extended should have proper namespaces to avoid issues during upgrades. When Vlocity releases new changes it won't impact if unique namespaces are used.
Example: myCompanyOrFeatureMethodName
The object of functions
Get an instance of DataSource if it exists. Otherwise, create a new one with the given config.
DataSource instance.
Adds all the enumerable string keyed function properties of a source object to the sdk prototype.
.override
method should only be used to override the existing methods and should only be used in rare cases.
Overriding the existing or default methods may cause unintended consequences and may also impact during upgrades.
Please be cautious while using this
The object of functions
Generated using TypeDoc
DataSource SDK This SDK handles the connection with SalesForce and provide convenient ways to access Vlocity integration including DataRaptor, Integration Procedure, Apex REST API etc.
How to create a Datasource?
Getting an instance of the DataSource
// Obtain a singleton dataSourceService const dataSourceService = DataSource.getInstance({ salesforceUrl: "https://www.salesforce.com", sessionId: "123", create: false, userId: "test" //additional data });
Creating a custom datasource at runtime
const newDataSource = { oracle: () => { return "I'm a Custom implementation"; }, siebel: () => { return "I'm a Custom implementation"; } }; dataSourceService.create(newDataSource, isNewInstance); // Create function implementation looks like this // uses prototype to add methods to dataSourceService DataSource.mixin(DataSource, newDataSource, isNewInstance); // call dataSourceService .siebel() .execute(input) .then() .catch();
Using ApexRest
datasource .apexRest(new ApexRestInput({ method: "get", url: "/vlocity_cmt/v2/cpq/carts/80137000000WlMP/products?hierarchy=1&pagesize=10&fields=IsActive,Id,Name,UnitPrice,ProductCode,jraju_card__RecurringPrice__c&includeIneligible=true" })) .execute() .then(resp => Logger.log("resp from thenable", resp)) .catch(error => Logger.log("response from catch thenable", error));
Using Rest
const input1: RestInput = new RestInput({ url: "/test.json" }); datasource .rest(input1) .execute() .then(response => { Logger.log("call ", response); }) .catch(error => { Logger.log("fail", error); });
Using SOQL
datasource .soql(new SoqlInput({ query: "SELECT Id, Name FROM Account LIMIT 10" }) .execute() .then(response => { Logger.log("soql call ", response.records); }) .catch(error => { Logger.log("soql fail", error); });
SOSL call
datasource .sosl(new SoslInput({ query: "FIND {Un*} IN ALL FIELDS RETURNING Account LIMIT 10" })) .execute() .then(response => { Logger.log("sosl call " + response.searchRecords); }) .catch(error => { Logger.log("sosl fail" + error); });