The web modeler SDK Description
The web modeler SDK is available in the web modeler, It allows users access resources from user interface and execute complexe computational in the user interface run time.
The SDK has the following classes
class SoftyFlow {}
class Collection {}
class SQLDatabase {}
class CustomList {}
class Report {}
class Instance {}
class Task {}
class Api {}
class Email {}
class File {}
In the following sections we will explicit each class and the allowed methods.
1 - SoftyFlow
The SoftyFlow class has the SoftyFlow system methods
Usage
This class is instantiated by default as object named SF when the user interface is loaded, so you can use methods directly by calling them via object "SF"
let currentMode = this.SF.getSF_mode();
getSF_mode
Is a function that return the mode of the running user interface
Returns
Type | Description |
---|
string | Return string ('test', 'uat', 'prod') |
Examples
let currentMode = this.SF.getSF_mode();
getSF_Version
Is a function that return the version of the running user interface
Returns
Type | Description |
---|
string | Return string ('test', 'uat', 'prod') |
Examples
let currentVersion = this.SF.getSF_Version();
queryParams
Is a function that return the query parameters
params | Description |
---|
select | optional. The fields to select (fields: SF_mode, SF_version, SF_screen) |
Parameters
Name | Type | Description |
---|
select | string | The selected fields |
Returns
Type | Description |
---|
string | Return string |
Examples
let currentMode = this.SF.getSF_mode('SF_mode SF_version');
console.log(currentMode)
startProcess
Is a function that start specific process
Parameters
Name | Type | Description |
---|
id | string | Process id |
body | object | Json of process variables |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let variables = {
"variable1": "value1",
"variable2": 1,
"variable3": true
}
await this.SF.startProcess('processId', variables);
validateCaptcha
Is a function that validates a Google reCAPTCHA v3 action and returns the generated token.
Parameters
Name | Type | Description |
---|
action | string | The action name used for reCAPTCHA v3 verification. |
Returns
Type | Description |
---|
Promise<string> | Returns a Promise that resolves to the reCAPTCHA token string. |
Examples
let token = await SF.utils.validateCaptcha("login_form");
saveNew
Is a function that allow to you to save the user interface state
Parameters
Name | Type | Description |
---|
id | string | interface id |
body | object | Json of interface variables |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let variables = {
"variable1": "value1",
"variable2": 1,
"variable3": true
}
await this.SF.saveNew('interfaceId', variables);
saveTask
Is a function that allow to you to save the task interface state
Parameters
Name | Type | Description |
---|
id | string | task id |
body | object | Json of task variables |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let variables = {
"variable1": "value1",
"variable2": 1,
"variable3": true
}
await this.SF.saveTask('taskId', variables);
validateTask
Is a function that allow to validate Task
Parameters
Name | Type | Description |
---|
id | string | task id |
body | object | Json of task variables |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let variables = {
"variable1": "value1",
"variable2": 1,
"variable3": true
}
await this.SF.validateTask('taskId', variables);
getUserPendingTask
Is a function that allow to get pending Task assigned to connected user.
Parameters
Name | Type | Description |
---|
limit | string | limit of result per page. |
page | string | number of page |
dueDate | string | related date. |
fields | string | fileds. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await this.SF.getUserPendingTask('limit', 'page', 'dueDate', 'fields');
uploadImage
Is a function that uploads an image to the server using a multipart/form-data POST request.
Parameters
Name | Type | Description |
---|
data | FormData | A FormData object containing the image file and any additional metadata. |
Returns
Type | Description |
---|
Promise<object> | Returns a Promise that resolves to the response data from the server. |
Examples
const formData = new FormData();
formData.append("profileImage", file);
let response = await SF.utils.uploadImage(formData);
setListFromCollection
Is a function that allow to set list of data from a specific collection.
Parameters
Name | Type | Description |
---|
collection | string | collection ID. |
criteria | object | Query json. |
limit | string | limit of result. |
sort | string | sort option. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let criteria = {
firstName: new RegExp("p", "i")
}
await this.SF.setListFromCollection('collectionId', criteria, 10, 'sort');
setListFromCollectionAggregation
Is a function that performs an aggregation operation on a specified collection using the provided aggregation pipeline.
Parameters
Name | Type | Description |
---|
collection | string | The name or ID of the target collection to aggregate. |
aggreg | Array<object> | An array of aggregation pipeline stages (MongoDB aggregation framework). |
Returns
Type | Description |
---|
Promise<Array> | Returns a Promise that resolves to the result of the aggregation query. |
Examples
let results = await SF.utils.setListFromCollectionAggregation("users", [
{ $match: { age: { $gte: 18 } } },
{ $group: { _id: "$country", count: { $sum: 1 } } }
]);
setListFromReport
Is a function that performs a dynamic aggregation query on a report collection, using filters, sorting, and limit options.
Parameters
Name | Type | Description |
---|
report | string | The ID or name of the report collection. |
query | object | An object representing filter conditions using custom or MongoDB operators. |
[limit] | number | (Optional) Limits the number of returned documents. |
[sort] | object | (Optional) Sorting options with by field and direction (-1 or 1). |
Returns
Type | Description |
---|
Promise<Array> | Returns a Promise that resolves to the result of the aggregation. |
Examples
let result = await SF.utils.setListFromReport("monthly_sales", {
SF_createdBy: "admin@example.com",
region: "NA"
}, 10, { by: "createdAt", direction: -1 });
setListFromReportAggregation
Is a function that performs a custom aggregation on a report instance using a provided aggregation pipeline.
Parameters
Name | Type | Description |
---|
report | string | The ID or name of the report collection. |
aggreg | Array<object> | The aggregation pipeline to execute. |
Returns
Type | Description |
---|
Promise<Array> | Returns a Promise that resolves to the result of the aggregation. |
Examples
let data = await SF.utils.setListFromReportAggregation("monthly_reports", [
{ $match: { status: "completed" } },
{ $group: { _id: "$region", total: { $sum: "$amount" } } }
]);
setListFromSQL
Is a function that allow to set list of data from client database.
Parameters
Name | Type | Description |
---|
clientDatabase | string | clientDatabase ID. |
query | string | Query table. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await this.SF.setListFromSQL('clientDatabaseID', "code='MMA'");
setListFromCustomList
Is a function that allow to set list of data from CustomList.
Parameters
Name | Type | Description |
---|
CustomList | string | CustomList ID. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await this.SF.setListFromCustomList('CustomListID');
aggregateQuery
Is a function that allow to set list of data from CustomList.
Parameters
Name | Type | Description |
---|
type | string | type of the resource (collection, report, users, projects, external databases). |
id | string | Id of the resource. |
query | object | Json of a value to be matched in the resource. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await this.SF.aggregateQuery('collection', '610c0343f6ebc7ddcb49cc3b', {value : "it"});
deleteFile
Is a function that allow to delete a file using it ID.
Parameters
Name | Type | Description |
---|
id | string | Id of the resource. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await this.SF.deleteFile('610c0343f6ebc7ddcb49cc3b');
2 - Projects
The Projects
class has the methods that will allow you to manage the projects.
Usage
const projects = new Projects({ mode: 'test' });
aggregate
Aggregation operations process data records and return computed results
Parameters
Name | Type | Description |
---|
aggregation | array | aggregation array |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let aggregation = [
{
"$match": { "status": "active" }
},
{
"$group": {
"_id": "$category",
"total": { "$sum": 1 }
}
}
]
let results = await projects.aggregate(aggregation);
3 - Users
The Users class has the methods that will allow you to manage the users.
Usage
const users = new Users();
create
Allow to create new user.
Parameters
Name | Type | Description |
---|
data | object | Json content user data |
Returns
Type | Description |
---|
promise | Return promise |
Data
This is the allowed user data:
field | Description |
---|
email | Required and Unique. The user email (string) |
lastName | Required. The user last name (string) |
firstName | Required. The user first name (string) |
group | Required. The user groups ids (array) |
metadata | optional. The user metadata (json) |
ideAccess | Required. IDE access right (boolean) |
blocked | optional. User blocking (boolean) |
Examples
let user = {
email: "email@softydev.com",
lastName : "last name",
firstName: "first name",
group: [],
metadata: {},
ideAccess: true,
blocked: false
}
await users.create(user);
update
Allow to update a user
Parameters
Name | Type | Description |
---|
id | string | user id. |
data | object | User data. |
Returns
Type | Description |
---|
promise | Return promise |
Data
The same allowed data in creation of user. The fields are optional.
Examples
let newData = {
ideAccess: false
}
await users.update("userId", newData);
delete
Allow to delete a user.
Parameters
Name | Type | Description |
---|
id | string | user id. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await users.delete("userId");
findById
Allow to get a user by id.
Parameters
Name | Type | Description |
---|
id | string | user id. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let user = await users.findById("userId");
find
Allow to list the users.
Parameters
Name | Type | Description |
---|
criteria | object | Query json. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let criteria = {
firstName: new RegExp("p", "i")
}
let usersList = await users.find(criteria);
count
Allow to get the count of users.
Parameters
Name | Type | Description |
---|
criteria | object | Query json |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let criteria = {
blocked: false
}
let count = await users.count(criteria);
findAndCount
get a list and the count of users
Parameters
Name | Type | Description |
---|
body | object | Json of options. |
Returns
Type | Description |
---|
promise | Return promise |
Options
This options are optional
Option | Description |
---|
criteria | Specifies selection filter (default : {}) |
fields | Select specific fields (example: "createdAt email") |
limit | Number of instances returned (default : 100/ no limit : 0) |
page | Page number depends on the limit (default : 0) |
sortby | Sorts the results by key (default : createdAt) |
direction | Ascending (1) or descending (-1) order (default : -1) |
Examples
let body = {
criteria: {
firstName: new RegExp("p", "i")
},
limit: 10,
page: 0,
sortBy: "createdAt",
direction: -1
}
let res = await users.findAndCount(body);
let usersList = res.data;
let count = res.count;
aggregate
Aggregation operations process data records and return computed results
Parameters
Name | Type | Description |
---|
aggregation | array | aggregation array |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let aggregation = [
{
"$match": { "firstName": new RegExp("z", "i") }
},
{
"$project" : {
"_id": 1,
"firstName": 1,
"lastName": 1,
"email": 1
}
}
]
let usersList = await users.aggregate([aggregation]);
addRole
Add role to user using user ID & group ID.
Parameters
Name | Type | Description |
---|
userId | string | user ID. |
groupid | string | group ID. |
mode | string | mode of the running user. interface |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await users.addRole("userId","groupId","SF_mode");
removeRole
Remove role from user using user ID & group ID.
Parameters
Name | Type | Description |
---|
userId | string | user ID. |
groupid | string | group ID. |
mode | string | mode of the running user interface |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await users.removeRole("userId","groupId","SF_mode");
4 - Groups
The Groups
class has the methods that will allow you to manage user groups.
Usage
const groups = new Groups();
findById
Find a group by its unique identifier.
Parameters
Name | Type | Description |
---|
id | string | Group ID |
Returns
Type | Description |
---|
promise | Returns group data |
Examples
let group = await groups.findById("groupId123");
find
Find groups based on a filter criteria.
Parameters
Name | Type | Description |
---|
criteria | object | Search criteria object |
Returns
Type | Description |
---|
promise | Returns array of groups |
Examples
let list = await groups.find({ name: /admin/i });
count
Count the number of groups that match the criteria.
Parameters
Name | Type | Description |
---|
criteria | object | Filter criteria |
Returns
Type | Description |
---|
promise | Returns count |
Examples
let total = await groups.count({ type: "system" });
findAndCount
Find groups and return both the results and the total count.
Parameters
Name | Type | Description |
---|
body | object | Request body with filters and pagination |
Returns
Type | Description |
---|
promise | Returns object { data, count } |
Examples
let result = await groups.findAndCount({ limit: 10, offset: 0 });
aggregate
Aggregation operations process data records and return computed results.
Parameters
Name | Type | Description |
---|
aggregation | array | Aggregation pipeline array |
Returns
Type | Description |
---|
promise | Returns aggregation result |
Examples
let aggregation = [
{ $match: { type: "system" } },
{ $group: { _id: "$status", total: { $sum: 1 } } }
];
let stats = await groups.aggregate(aggregation);
create
Create a new group with provided data.
Parameters
Name | Type | Description |
---|
body | object | Group data |
Returns
Type | Description |
---|
promise | Returns created group |
Examples
let newGroup = await groups.create({ name: "Developers", type: "custom" });
update
Update an existing group by ID.
Parameters
Name | Type | Description |
---|
id | string | Group ID |
body | object | Update payload |
Returns
Type | Description |
---|
promise | Returns updated group |
Examples
let updated = await groups.update("groupId123", { name: "Admins Updated" });
delete
Delete a group by ID.
Parameters
Name | Type | Description |
---|
id | string | Group ID |
Returns
Type | Description |
---|
promise | Returns deletion result |
Examples
await groups.delete("groupId123");
groupUsers
Retrieve the users belonging to a specific group.
Parameters
Name | Type | Description |
---|
id | string | Group ID |
Returns
Type | Description |
---|
promise | Returns array of users in the group |
Examples
let users = await groups.groupUsers("groupId123");
5 - Collection
The collection class has the methods that will allow you to manage your collection
Usage
You can instantiate a Collection class with id or name of collection. You can add mode option
Option | Description |
---|
id | Required. id or name of collection |
mode | optional. Specifies mode of collection (default : "test") |
const collection = new Collection({ id: 'collectionId', mode: 'test' });
insert
Allow to insert a json into a collection
Parameters
Name | Type | Description |
---|
data | object | Json of a value to be inserted in to the collection. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await collection.insert({ name: "name1", type : "type1" });
insertMany
Allow to insert an array of json in to a collection.
Parameters
Name | Type | Description |
---|
data | object | Json of a value to be inserted in to the collection. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await collection.insertMany([{label : "IT", value : "it"}]);
updateMany
update all the documents that satisfies the specified query criteria .
Parameters
Name | Type | Description |
---|
criteria | object | Query json. |
data | object | Json of a new data. |
options | object | Json of options |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let criteria = {
firstName: new RegExp("p", "i")
}
await collection.updateMany(criteria, [{ type : "type2" }], { upsert: true });
update
Allow to update a document in collection
Parameters
Name | Type | Description |
---|
id | string | Document id. |
data | object | Json of a new data. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await collection.update("documentId", { type : "type2" });
delete
Allow to delete a document from collection
Parameters
Name | Type | Description |
---|
id | string | Document id. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await collection.delete("documentId");
findById
Allow to get a object by id from the collection
Parameters
Name | Type | Description |
---|
id | string | Document id. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let document = await collection.findById(id);
find
Allow to select the documents in a collection
Parameters
Name | Type | Description |
---|
body | object | Json of options. |
Returns
Type | Description |
---|
promise | Return promise |
Options
This options are optional
Option | Description |
---|
criteria | Specifies selection filter (default : {}) |
limit | Number of documents returned (default : 100/ no limit : 0) |
page | Page number depends on the limit (default : 0) |
sortby | Sorts the results by key (default : createdAt) |
direction | Ascending (1) or descending (-1) order (default : -1) |
Examples
let body = {
criteria: {
name: new RegExp("p", "i"),
type: "type1"
},
limit: 10,
page: 0,
sortBy: "createdAt",
direction: -1
}
let documents = await collection.find(body);
count
Allow to get the count of documents that would match a query for the collection
Parameters
Name | Type | Description |
---|
criteria | object | Query json |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let count = await collection.count({ type: "type1" });
aggregate
Aggregation operations process data records and return computed results
Parameters
Name | Type | Description |
---|
aggregation | array | aggregation array |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let aggregation = [
{
"$match": { "type": "type1" }
},
{
"$project" : {
"_id": 1,
"name": 1
}
}
]
let documents = await collection.aggregate([aggregation]);
6 - SQLDatabase
Manage your external SQL Databases Through the SQLDatabase class.
Usage
You can instantiate an SQL class with id and mode(optional).
Option | Description |
---|
id | Required. id or name of Database |
mode | optional. Specifies mode of Database (default : "test") |
const sql = new SQLDatabase({ id: '610c0343f6ebc7ddcb49cc3b', mode: 'test' });
findOne
Get a table row data
Parameters
Name | Type | Description |
---|
tableName | string | table name. |
Criteria | string | query table. |
Returns
Examples
let res = await sql.findOne("client", "code='MMA'"))
find
list multiple rows from sql table
Parameters
Name | Type | Description |
---|
tableName | string | table name. |
options | string | query table. |
Returns
Examples
let res = sql.find("client", "code='MMA'")
count
Get the row count for a table with a criteria
Parameters
Name | Type | Description |
---|
tableName | string | table name. |
options | string | query table. |
Returns
Type | Description |
---|
array | array with one element contining count |
Examples
let count = await sql.count("client", "code='MMA'");
execute
Execute a custom query on the database.
Parameters
Name | Type | Description |
---|
query | string | string of query. |
Returns
Type | Description |
---|
array | Return array. |
Examples
sql.execute("INSERT INTO client(code, intitule, representant, codepostal) VALUES('MDSX', 'holder', 'holder', 14000)")
insert
Insert one row into a table.
Parameters
Name | Type | Description |
---|
tableName | string | table name. |
data | object | JSON body. |
Returns
Examples
sql.insert("client", {
code: 'HelloWord',
codepostal: 14000
}
insertMany
Insert multiple rows into
Parameters
Name | Type | Description |
---|
tableName | string | table name. |
data | array | JSON body. |
Returns
Examples
sql.insertMany("client", [
{ code: '#1' },
{ code: '#2' }
])
update
Update rows.
Parameters
Name | Type | Description |
---|
tableName | string | table name. |
query | string | query table. |
data | object | updated JSON body. |
Returns
Examples
sql.update('client', "code='MMA'",
{
code: "MQS"
})
delete
Delete row/rows in your table.
Parameters
Name | Type | Description |
---|
tableName | string | table name. |
query | string | query table. |
Returns
Examples
sql.delete("client", "id=223")
7 - CustomList
The CustomList class has the methods that will allow you to manage your Custom List
Usage
You can instantiate a CustomList class with id of custom list. You can add other options (mode, versionId)
Option | Description |
---|
id | Required. id of custom list |
mode | optional. Specifies mode of custom list (default : "test") |
versionId | optional. id of the version from which to get the custom list |
const customList = new CustomList({id: 'id', mode: 'test', versionId: "vId"});
get
Get a custom list data
Returns
Type | Description |
---|
promise | Return promise |
Examples
let customListData = await customList.get();
8 - Report
The Report class will allow you to manipulate specific report
Usage
You can instantiate a Report class with id of report. You can add mode option
Option | Description |
---|
id | Required. Specifies mode of custom list (default : "test") |
mode | optional. Specifies mode of custom list (default : "test") |
const report = new Report({id: 'id', mode: 'test'});
aggregate
Aggregation operations process data records and return computed results
Parameters
Name | Type | Description |
---|
aggregation | array | aggregation array |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let aggregation = [
{
"$match": { "SF_status": "Running" }
},
{
"$sort": { "SF_createdAt": -1 }
}
]
let instances = await report.aggregate(aggregation);
9 - Instance
The Instance class has the methods that will allow you to manage the instances
Usage
const inctance = new Instance();
findById
Get a instance by id
Parameters
Name | Type | Description |
---|
id | string | id of instance. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let oneInctance = await inctance.findById(id);
find
list the instances
Parameters
Name | Type | Description |
---|
criteria | object | Json of query. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let instances = await inctance.find({ status: "Running" });
count
Allow to get the count of instances that would match a query
Parameters
Name | Type | Description |
---|
criteria | object | Query json |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let count = await inctance.count({ status: "Running" });
findAndCount
get a list and the count of instances
Parameters
Name | Type | Description |
---|
body | object | Json of options. |
Returns
Type | Description |
---|
promise | Return promise |
Options
This options are optional
Option | Description |
---|
criteria | Specifies selection filter (default : {}) |
fields | Select specific fields (example: "createdAt name status") |
limit | Number of instances returned (default : 100/ no limit : 0) |
page | Page number depends on the limit (default : 0) |
sortby | Sorts the results by key (default : createdAt) |
direction | Ascending (1) or descending (-1) order (default : -1) |
Examples
let body = {
criteria: {
status: "Running"
},
limit: 10,
page: 0,
sortBy: "createdAt",
direction: -1
}
let res = await inctance.findAndCount(body);
let instances = res.data;
let count = res.count;
aggregate
Aggregation operations process data records and return computed results
Parameters
Name | Type | Description |
---|
aggregation | array | aggregation array |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let aggregation = [
{
"$match": { "status": "End" }
},
{
"$project" : {
"_id": 1,
"name": 1
}
}
]
let inctances = await inctance.aggregate([aggregation]);
update
Update an instance
Parameters
Name | Type | Description |
---|
id | string | id of instance. |
data | object | Json of a new data. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await inctance.update(id, { status : "End" });
delete
Delete an instance
Parameters
Name | Type | Description |
---|
id | string | id of instance. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await inctance.delete(id);
history
Get instance history.
Parameters
Name | Type | Description |
---|
id | string | id of instance. |
data | object | Json of data. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await inctance.history(id, { status : "End" });
10 - Task
The Task class has the methods that will allow you to manage the tasks
Usage
findById
Get a task by id
Parameters
Name | Type | Description |
---|
id | string | id of task. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let oneTask = await task.findById(id);
find
list the tasks
Parameters
Name | Type | Description |
---|
criteria | object | Json of query. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let tasks = await task.find({ instanceId: "instanceId" });
count
Allow to get the count of tasks that would match a query
Parameters
Name | Type | Description |
---|
criteria | object | Query json |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let count = await task.count({ instanceId: "instanceId" });
findAndCount
get a list and the count of tasks
Parameters
Name | Type | Description |
---|
body | object | Json of options. |
Returns
Type | Description |
---|
promise | Return promise |
Options
This options are optional
Option | Description |
---|
criteria | Specifies selection filter (default : {}) |
assignedToConnected | To get tasks of connected user (default : false) |
fields | Select specific fields (example: "createdAt name status") |
limit | Number of instances returned (default : 100/ no limit : 0) |
page | Page number depends on the limit (default : 0) |
sortby | Sorts the results by key (default : createdAt) |
direction | Ascending (1) or descending (-1) order (default : -1) |
Examples
let body = {
criteria: {
status: "Running"
},
assignedToConnected: true,
limit: 10,
page: 0,
sortBy: "createdAt",
direction: -1
}
let res = await task.findAndCount(body);
let tasks = res.data;
let count = res.count;
aggregate
Aggregation operations process data records and return computed results
Parameters
Name | Type | Description |
---|
aggregation | array | aggregation array |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let aggregation = [
{
"$match": { "status": "End" }
},
{
"$project" : {
"_id": 1,
"name": 1
}
}
]
let tasks = await task.aggregate([aggregation]);
update
Update an task
Parameters
Name | Type | Description |
---|
id | string | id of task. |
data | object | Json of a new data. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await task.update(id, { status : "End" });
delete
Delete an task
Parameters
Name | Type | Description |
---|
id | string | id of task. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
getNextValue
Get next value of an task.
Parameters
Name | Type | Description |
---|
name | string | name of the variable. |
[padding] | number | Padding of result with 000000. |
mode | string | mode of the running user. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await task.getNextValue("name",5,"SF_mode");
history
Get the history of a task by its ID.
Parameters
Name | Type | Description |
---|
id | string | Task ID |
body | object | Query parameters (optional) |
Returns
Type | Description |
---|
promise | Returns object { data, count } |
Examples
let log = await task.history("taskId123", {});
11 - Api
The Api class has the methods that will allow you to manage your Apis.
Usage
invoke
Invoke an api.
Parameters
Name | Type | Description |
---|
body | object | Json of options. |
Returns
Type | Description |
---|
promise | Return promise |
Examples
let body = {
const myElement = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
myElement.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
myElement.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
}
await api.invoke(body);
12 - Email
The Email class has the methods that will allow you to manage your emails.
Usage
const email = new Email();
send
Send an email.
Parameters
Name | Type | Description |
---|
assignee | string | Assignee user email. |
subject | string | Subject of the email. |
variables | object | Json of options. |
mailTemplate | object | Email template. |
mailProvider | object | SoftyFlow default provider. |
cc | string | Json of options. |
from | string | Sender user email. |
replyTo | string | * |
Returns
Type | Description |
---|
promise | Return promise |
Examples
await email.send("assignee","subject",{"var1", "var2"},{"mailTemplate"},{"mailProvider"},"mail of user in cc", "senderMail","replyTo");
13 - DataSource
The DataSource class provides generic data manipulation methods for various sources such as collections, tables, or reports.
Usage
const ds = new DataSource();
findOne
Retrieve a single document from a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
options | object | Query options |
Returns
Type | Description |
---|
promise | Returns a single document |
Examples
let doc = await ds.findOne("users", { filter: { email: "user@example.com" } });
list
List multiple documents from a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
options | object | Query options |
Returns
Type | Description |
---|
promise | Returns an array of documents |
Examples
let docs = await ds.list("users", { filter: { active: true } });
count
Count the number of documents in a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
options | object | Query options |
Returns
Type | Description |
---|
promise | Returns the count of documents |
Examples
let total = await ds.count("orders", { filter: { status: "delivered" } });
update
Update documents in a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
options | object | Query conditions |
data | object | Data to update |
Returns
Type | Description |
---|
promise | Returns update result |
Examples
await ds.update("products", { filter: { stock: 0 } }, { restock: true });
insert
Insert a single document into a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
data | object | Document to insert |
options | object | Additional options |
Returns
Type | Description |
---|
promise | Returns insert result |
Examples
await ds.insert("logs", { action: "login", userId: "abc123" });
insertMany
Insert multiple documents into a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
data | array | Array of documents |
options | object | Additional options |
Returns
Type | Description |
---|
promise | Returns insert result |
Examples
await ds.insertMany("logs", [{ action: "view" }, { action: "edit" }]);
delete
Delete documents from a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
options | object | Delete criteria |
Returns
Type | Description |
---|
promise | Returns delete result |
Examples
await ds.delete("sessions", { filter: { expired: true } });
execute
Execute a custom action or command on a data source.
Parameters
Name | Type | Description |
---|
source | string | Name of the source |
options | object | Parameters for execution |
Returns
Type | Description |
---|
promise | Returns execution result |
Examples
await ds.execute("jobs", { action: "resetAll" });
14 - File
The File
class provides methods for generating PDF files from stored HTML templates and variable contexts using API endpoints.
generatePDF
Generates a PDF file by retrieving the HTML content of a file and posting it along with contextual data.
Parameters
Name | Type | Description |
---|
filename | string | - Desired name for the generated PDF |
fid | string | - File ID to fetch content from |
context | object | - Contextual data for PDF rendering (e.g., variables) |
Returns
Type | Description |
---|
Promise | - Resolves with the PDF generation response |
Example
const file = new File();
file.generatePDF("output.pdf", "605c72...", { variables: { user: "Alice" } });
genratePDFWithVar
Generates PDF content using variables directly by posting to a specific content generation endpoint.
Parameters
Name | Type | Description |
---|
name | string | - Name for the output (not directly used in the call) |
fid | string | - File ID of the template |
context | object | - Variable data used for rendering the template |
Returns
Type | Description |
---|
Promise | - Resolves with the server response |
Example
const file = new File();
file.genratePDFWithVar("Invoice", "605c72...", { variables: { amount: 100, user: "Alice" } });