The Official SDK for Data.Stack
npm i --save @appveen/ds-sdk
const SDK = require('@appveen/ds-sdk');Authenticate using Credentials (Username/password)
const SDK = require('@appveen/ds-sdk');
const HOST = 'https://cloud.appveen.com';
const USERNAME = 'johndoe@appveen.com';
const PASSWORD = 'johndoehasapassword';
(async function () {
try {
const dataStack = await SDK.authenticateByCredentials({
host: HOST,
username: USERNAME,
password: PASSWORD,
});
const app = await dataStack.App('Adam');
const dataService = await app.DataService('Employee');
const record = await dataService.DataAPIs().GetRecord('EMP1001');
console.log(record);
} catch (e) {
console.error(e);
}
})();Authenticate using JWT Token
const SDK = require('@appveen/ds-sdk');
const HOST = 'https://cloud.appveen.com';
const TOKEN = 'dgdoieruyiueyr794iryewyrye7rbyewr';
(async function () {
try {
const dataStack = await SDK.authenticateByToken({
host: HOST,
token: TOKEN,
});
const app = await dataStack.App('Adam');
const dataService = await app.DataService('Employee');
const record = await dataService.DataAPIs().GetRecord('EMP1001');
console.log(record);
} catch (e) {
console.error(e);
}
})();Using Math API
const SDK = require('@appveen/ds-sdk');
const HOST = 'https://cloud.appveen.com';
const USERNAME = 'johndoe@appveen.com';
const PASSWORD = 'johndoehasapassword';
(async function () {
try {
const dataStack = await SDK.authenticateByCredentials({
host: HOST,
username: USERNAME,
password: PASSWORD,
});
const app = await dataStack.App('Adam');
const dataService = await app.DataService('Employee');
const math = dataService.DataAPIs().PrepareMath();
math.SelectField('salary').Multiply(1.2); // Increment Salary by 20%
const updatedRecord = await dataService.DataAPIs().ApplyMath('EMP1001', math);
console.log(updatedRecord);
} catch (e) {
console.error(e);
}
})();The SDK contains the following apis.
Returns a Promise giving a DataStack object.
Type: Credentials
Type string
The FQDN of the application.
Type string
The Username of a user / Client ID of Bot.
Type string
The Password of a user / API key of Bot.
Type boolean
If True it will log all SDK events. Default: false
Type Logger
To pass a custom logger for logging events and errors
Returns a Promise giving a DataStack object.
Type: Credentials
Type string
The FQDN of the application
Type string
The JWT token of a User / Bot
Type boolean
If True it will log all SDK events. Default: false
Type Logger
To pass a custom logger for logging events and errors
The object contains utility methods to access DataStack.
Returns a Void Promise.
Returns a Promise giving a DSApp object.
Type: string
The name of the App
Returns a Promise giving a DSApp array.
Returns a Promise giving a DSApp object.
Type: string
The name of the App
Returns a Promise giving the same DataStack object.
Type: string
The name of the App
The object contains utility methods to access an App of Data Stack.
Returns a Promise giving a DSDataService object.
Type: string
The name of the Data Service.
Returns a Promise giving a DSDataService array.
Returns a Promise giving a DSDataService object.
Type: string
The name/id of the Data Service to be Created.
Returns an TransactionMethods object to do Transaction.
Type: object
Filter to select fewer DS.
Returns a Promise giving the same DSApp object, else will throw an ErrorResponse object.
This will start all the Data Service in the app, if not already stopped.
Type: object
Filter to select fewer DS.
Returns a Promise giving the same DSApp object, else will throw an ErrorResponse object.
This will stop all the Data Service in the app, if not already stopped.
The object contains utility methods to manage a Data Service.
Returns an boolean value.
Returns an boolean value.
Returns the same DSDataService object.
Returns the same DSDataService object.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
This will discard the draft version of this Data Service.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
This will Delete all data, API logs and audit logs of this Data Service.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
This will Delete all API logs of this Data Service.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
This will Delete all audit logs of this Data Service.
Returns an DSApp object.
This will delete the selected Data Service.
Returns an DataMethods object to do Data operations that Data Service.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
This will start the Data Service if not already running.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
This will stop the Data Service if not already stopped.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
This will re-deploy the Data Service in the infra layer by re-creating it's service and deployment.
Returns an DSDataServiceIntegration object to do manage integrations of Data Service.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
Type: DSDataServiceIntegration
After making changes to the returned object by getIntegrations() method set that object here in order for the change to be applied.
Returns an DSDataServiceRole object to do manage Roles of Data Service.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
Type: DSDataServiceRole
After making changes to the returned object by getRoles() method set that object here in order for the change to be applied.
Returns an DSDataServiceSchema object to do manage Schema of Data Service.
Returns a Promise giving the same DSDataService object if the operation is success, else will throw an ErrorResponse object.
Type: DSDataServiceSchema
After making changes to the returned object by getSchema() method set that object here in order for the change to be applied.
This Object contains methods to manage data of a Data Service.
Returns a DataStackDocument object Wrapper Object with useful methods.
Returns a Promise giving a number if the operation is success, else will throw an ErrorResponse object.
Type: object The filter get proper count.
ListRecords(options: ListOptions)
Returns a Promise giving a DataStackDocument array if the operation is success, else will throw an ErrorResponse object.
Type: ListOptions The options to list records.
Returns a Promise giving a DataStackDocument object if the operation is success, else will throw an ErrorResponse object.
Type: string The ID of the record.
Returns a Promise giving a DataStackDocument object if the operation is success, else will throw an ErrorResponse object.
Type: string The ID of the record.
Type: object The data the should to be updated.
Type: APIOptions Options like expireAt & expireAfter.
Returns a Promise giving a DataStackDocument object if the operation is success, else will throw an ErrorResponse object.
Type: string The ID of the record.
Type: object The data the should to be updated.
Type: APIOptions Options like expireAt & expireAfter.
Returns a Promise giving a DataStackDocument object if the operation is success, else will throw an ErrorResponse object.
Type: object The data the should to be created.
Type: APIOptions Options like expireAt & expireAfter.
Returns a Promise giving a message:string if the operation is success, else will throw an ErrorResponse object.
Type: string The ID of the record.
Returns a MathAPI object to set math operations.
ApplyMath(id: string, math: MathAPI)
Returns a Promise giving a DataStackDocument object if the operation is success, else will throw an ErrorResponse object.
Type: string The ID of the record.
Type: MathAPI The Math Object that has the operations.
UploadFileFromPath(filePath: string): Promise<FileUploadResponse>
Returns a Promise giving a FileUploadResponse object if the operation is success, else will throw an ErrorResponse object.
Type: string The file path to upload.
UploadFileAsStream(data: any): Promise<FileUploadResponse>
Returns a Promise giving a FileUploadResponse object if the operation is success, else will throw an ErrorResponse object.
Type: stream The file readable stream.
This Object contains methods to consume Transactions API.
Returns a TransactionMethods object Wrapper Object with useful methods.
Type: string The name of Data Service.
Type: object The Data to be created.
Returns a TransactionMethods object Wrapper Object with useful methods.
Type: string The name of Data Service.
Type: object The Data to be updated with _id.
Returns a TransactionMethods object Wrapper Object with useful methods.
Type: string The name of Data Service.
Type: object The Data Object containing _id of the document to be deleted.
Returns a Promise giving a DataStackDocument object if the operation is success, else will throw an ErrorResponse object.
Selects the field to apply math operation.
Returns the same MathAPI Object to continue API chaning.
Type: string
Path of the Field.
Increment the value to the selected field.
Returns the same MathAPI Object to continue API chaning.
Type: number
The value to increment. Give negative values to decrement.
Multiply the value to the selected field.
Returns the same MathAPI Object to continue API chaning.
Type: number
The value to multiply.
Returns a WebHook array or empty [] if not hooks present.
Returns a WebHook Object or undefined if not found.
Type: string
The Name of the hook that is needed.
Returns a DSDataServiceIntegration Object for chaning of apis.
Type: WebHook
Returns a DSDataServiceIntegration Object for chaning of apis.
Type: string
The Name of the hook that needs to be removed.
Returns a WebHook array or empty [] if not hooks present.
Returns a WebHook Object or undefined if not found.
Type: string
The Name of the hook that is needed.
Returns a DSDataServiceIntegration Object for chaning of apis.
Type: WebHook
Returns a DSDataServiceIntegration Object for chaning of apis.
Type: string
The Name of the hook that needs to be removed.
Returns RoleBlock array
Returns RoleBlock object or undefined if no roles found.
Type: string
The Name of the role that is needed.
Returns a new RoleBlock object that should be used to add more roles.
Type: string
The Name of the new role.
Returns DSDataServiceRole object to continue api chaning.
Type: RoleBlock
The RoleBlock Object that was returned by createNewRole() method.
Returns DSDataServiceRole object to continue api chaning.
Type: string
The Name of the role that needs to be removed.
The Object used by Roles.
This Method sets Name of the Role.
Returns RoleBlock object to continue api chaning.
This Method sets Description of the Role.
Returns RoleBlock object to continue api chaning.
This Method Enables Create Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Disables Create Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Enables Edit Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Disables Edit Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Enables Delete Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Disables Delete Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Enables Review Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Disables Review Permission in the Role.
Returns RoleBlock object to continue api chaning.
This Method Enables Skip Review Permission in the Role.
Returns RoleBlock object to continue api chaning.
This RoleBlock Disables Skip Review RoleBlock in the Role.
Returns RoleBlock object to continue api chaning.
To show only selected fields in records.
To set the sorting order of records.
For pagination.
To Limit the no of records.
To filter the records.
To expand the docs if contains relation.
The Object used by pre-hooks and post-hooks.
Type: string
A unique name of the hook.
Type: string
A URL of the Web-Hook.
Type: string
Optional error message to show, when the hook URL is down.
The object is return when a file is uploaded.
Type: string
Type: number
Type: number
Type: string
Type: string
Type: string
Type: string
Type: object
Type: string
The object is return whenever some error occurs.
Type: number
The status code returned by the application.
Type: object
The response body send by the application in case if error.
Type: string
The error message if the error occured in the SDK.
The Credentials/Token can also be set via ENV.
| ENV Variables | Description |
| ----------------------- | -------------------------------- |
| DATA_STACK_HOST | The FQDN of Data Stack |
| DATA_STACK_USERNAME | Username / Client ID of Bot |
| DATA_STACK_PASSWORD | User's Password / API Key of Bot |
| DATA_STACK_TOKEN | The existing JWT token |