Web Modeler SDK Reference
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 SoftyTables {}
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
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);
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.
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.
const users = new Users();
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");
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);
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.
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 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 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);
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
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: this.SF_mode });
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 });
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" });
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);
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);
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.
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: this.SF_mode});
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'"))
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'")
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 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 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 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 - SoftyTablesโ
The SoftyTables class provides methods to interact with SoftyTable resources, allowing you to perform CRUD operations, execute queries, and manage table data from the web interface.
You can instantiate a SoftyTables class with id and mode options.
| Option | Description |
|---|
| id | Required. id of the SoftyTable |
| mode | optional. Specifies mode of SoftyTable (default : "test") |
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
findByIdโ
Retrieve a single row from a SoftyTable by its ID.
Parametersโ
| Name | Type | Description |
|---|
rowId | string | The ID of the row |
Returnsโ
| Type | Description |
|---|
promise | Resolves to the row data |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let row = await softyTable.findById('12345');
List rows from a SoftyTable with optional filtering, sorting, and pagination.
Parametersโ
| Name | Type | Description |
|---|
body | object | JSON of options (criteria, limit, page, sortby, direction) |
Returnsโ
| Type | Description |
|---|
promise | Resolves to an array of table rows |
Optionsโ
These options are optional
| Option | Description |
|---|
| criteria | Specifies selection filter with where clause (default : {}) |
| limit | Number of rows returned (default : 100/ no limit : 0) |
| page | Page number depends on the limit (default : 0) |
| sortby | Sorts the results by field name (default : createdAt) |
| direction | Ascending (1) or descending (-1) order (default : -1) |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let rows = await softyTable.find({});
let body = {
criteria: {
where: { status: 'active' }
},
limit: 50,
page: 0,
sortby: 'createdAt',
direction: -1
}
let activeRows = await softyTable.find(body);
Count the number of rows in a SoftyTable with optional filtering.
Parametersโ
| Name | Type | Description |
|---|
criteria | object | Query criteria with optional where clause |
Returnsโ
| Type | Description |
|---|
promise | Resolves to an object with count property |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let result = await softyTable.count({});
let result = await softyTable.count({
criteria: { where: { status: 'active' } }
});
findAndCountโ
Get both a list of rows and the total count matching the criteria.
Parametersโ
| Name | Type | Description |
|---|
body | object | JSON of options (criteria, limit, page, sortby, direction) |
Returnsโ
| Type | Description |
|---|
promise | Resolves to object { data, count } |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let body = {
criteria: {
where: { status: 'active' }
},
limit: 10,
page: 0,
sortby: 'createdAt',
direction: -1
}
let result = await softyTable.findAndCount(body);
let rows = result.data;
let count = result.count;
Create a single row in a SoftyTable.
Parametersโ
| Name | Type | Description |
|---|
body | object | The data object to insert as a row |
Returnsโ
| Type | Description |
|---|
promise | Resolves to the created row data |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let newRow = await softyTable.insert({
name: 'John Doe',
email: 'john@example.com',
age: 30,
status: 'active'
});
insertManyโ
Create multiple rows in a SoftyTable at once.
Parametersโ
| Name | Type | Description |
|---|
data | array | Array of data objects to insert |
Returnsโ
| Type | Description |
|---|
promise | Resolves to an array of created rows |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let newRows = await softyTable.insertMany([
{ name: 'John Doe', email: 'john@example.com', age: 30 },
{ name: 'Jane Smith', email: 'jane@example.com', age: 25 },
{ name: 'Bob Johnson', email: 'bob@example.com', age: 35 }
]);
Update a single row in a SoftyTable by its ID.
Parametersโ
| Name | Type | Description |
|---|
rowId | string | The ID of the row to update |
body | object | The fields and values to update |
Returnsโ
| Type | Description |
|---|
promise | Resolves to the updated row |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let updated = await softyTable.update('12345', {
status: 'inactive',
updatedAt: new Date()
});
updateManyโ
Update multiple rows in a SoftyTable that match specific criteria.
Parametersโ
| Name | Type | Description |
|---|
criteria | object | Query criteria with where clause |
value | object | The fields and values to update |
options | object | Additional options (optional) |
Returnsโ
| Type | Description |
|---|
promise | Resolves to update operation result |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let result = await softyTable.updateMany(
{ status: 'pending' },
{ status: 'active', processedAt: new Date() }
);
Delete a single row from a SoftyTable by its ID.
Parametersโ
| Name | Type | Description |
|---|
rowId | string | The ID of the row |
Returnsโ
| Type | Description |
|---|
promise | Resolves to deletion result |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
await softyTable.delete('12345');
deleteManyโ
Delete multiple rows from a SoftyTable that match specific criteria.
Parametersโ
| Name | Type | Description |
|---|
criteria | object | Query criteria with where clause |
Returnsโ
| Type | Description |
|---|
promise | Resolves to deletion result |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
await softyTable.deleteMany({ status: 'inactive' });
await softyTable.deleteMany({
createdAt: { $lt: new Date('2024-01-01') }
});
Clear all rows from a SoftyTable (delete all data).
Returnsโ
| Type | Description |
|---|
promise | Resolves to deletion result |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
await softyTable.clear();
getOptionsโ
Retrieve options for select fields in a SoftyTable.
Returnsโ
| Type | Description |
|---|
promise | Resolves to array of options |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let options = await softyTable.getOptions();
executeโ
Execute a custom SQL query on the SoftyTable.
Parametersโ
| Name | Type | Description |
|---|
query | string | The SQL query to execute |
options | object | Query options with replacements and type |
Options Objectโ
| Field | Type | Description |
|---|
replacements | object | Values to replace in parameterized queries |
type | string | Query type: 'SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RAW', 'SHOWTABLES' |
Returnsโ
| Type | Description |
|---|
promise | Resolves to the query results |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let results = await softyTable.execute(
'SELECT * FROM my_table WHERE status = :status',
{
replacements: { status: 'active' },
type: 'SELECT'
}
);
let results = await softyTable.execute(
'UPDATE my_table SET status = "processed" WHERE created_at < NOW() - INTERVAL 30 DAY',
{ type: 'UPDATE' }
);
migrateโ
Migrate rows in a SoftyTable (for data migration operations).
Returnsโ
| Type | Description |
|---|
promise | Resolves to migration result |
Examplesโ
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let result = await softyTable.migrate();
8 - CustomListโ
The CustomList class has the methods that will allow you to manage your Custom List
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 a custom list data
Returnsโ
| Type | Description |
|---|
promise | Return promise |
Examplesโ
let customListData = await customList.get();
9 - Reportโ
The Report class will allow you to manipulate specific report
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);
10 - Instanceโ
The Instance class has the methods that will allow you to manage the instances
const instance = 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 oneInstance = await instance.findById(id);
list the instances
Parametersโ
| Name | Type | Description |
|---|
criteria | object | Json of query. |
Returnsโ
| Type | Description |
|---|
promise | Return promise |
Examplesโ
let instances = await instance.find({ status: "Running" });
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 instance.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 instance.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 instances = await instance.aggregate([aggregation]);
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 instance.update(id, { status : "End" });
Delete an instance
Parametersโ
| Name | Type | Description |
|---|
id | string | id of instance. |
Returnsโ
| Type | Description |
|---|
promise | Return promise |
Examplesโ
await instance.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 instance.history(id, { status : "End" });
11 - Taskโ
The Task class has the methods that will allow you to manage the tasks
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);
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" });
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 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 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", {});
12 - Apiโ
The Api class has the methods that will allow you to manage your Apis.
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);
13 - Emailโ
The Email class has the methods that will allow you to manage your emails.
const email = new Email();
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");
14 - DataSourceโ
The DataSource class provides generic data manipulation methods for various sources such as collections, tables, or reports.
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 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 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 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 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 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" });
15 - 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" } });