Skip to main content

Web Modeler SDK Reference

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 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

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"

//using SF object
let currentMode = this.SF.getSF_mode();

getSF_modeโ€‹

Is a function that return the mode of the running user interface

Returnsโ€‹

TypeDescription
stringReturn 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โ€‹

TypeDescription
stringReturn string ('test', 'uat', 'prod')

Examplesโ€‹

let currentVersion = this.SF.getSF_Version();

queryParamsโ€‹

Is a function that return the query parameters

paramsDescription
selectoptional. The fields to select (fields: SF_mode, SF_version, SF_screen)

Parametersโ€‹

NameTypeDescription
selectstringThe selected fields

Returnsโ€‹

TypeDescription
stringReturn string

Examplesโ€‹

let currentMode = this.SF.getSF_mode('SF_mode SF_version');
console.log(currentMode)
// ?SF_mode=test&SF_version=versionId

startProcessโ€‹

Is a function that start specific process

Parametersโ€‹

NameTypeDescription
idstringProcess id
bodyobjectJson of process variables

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
idstringinterface id
bodyobjectJson of interface variables

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
idstringtask id
bodyobjectJson of task variables

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
idstringtask id
bodyobjectJson of task variables

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
limitstringlimit of result per page.
pagestringnumber of page
dueDatestringrelated date.
fieldsstringfileds.

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
dataFormDataA FormData object containing the image file and any additional metadata.

Returnsโ€‹

TypeDescription
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);
// returns: { success: true, imageUrl: "/uploads/user123.png" }

setListFromCollectionโ€‹

Is a function that allow to set list of data from a specific collection.

Parametersโ€‹

NameTypeDescription
collectionstringcollection ID.
criteriaobjectQuery json.
limitstringlimit of result.
sortstringsort option.

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
collectionstringThe name or ID of the target collection to aggregate.
aggregArray<object>An array of aggregation pipeline stages (MongoDB aggregation framework).

Returnsโ€‹

TypeDescription
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 } } }
]);
// returns: [ { _id: "USA", count: 42 }, { _id: "FR", count: 18 } ]

setListFromReportโ€‹

Is a function that performs a dynamic aggregation query on a report collection, using filters, sorting, and limit options.

Parametersโ€‹

NameTypeDescription
reportstringThe ID or name of the report collection.
queryobjectAn 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โ€‹

TypeDescription
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 });
// returns: [ { ... }, { ... } ]

setListFromReportAggregationโ€‹

Is a function that performs a custom aggregation on a report instance using a provided aggregation pipeline.

Parametersโ€‹

NameTypeDescription
reportstringThe ID or name of the report collection.
aggregArray<object>The aggregation pipeline to execute.

Returnsโ€‹

TypeDescription
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" } } }
]);
// returns: [ { _id: "Europe", total: 24000 }, { _id: "Asia", total: 18000 } ]

setListFromSQLโ€‹

Is a function that allow to set list of data from client database.

Parametersโ€‹

NameTypeDescription
clientDatabasestringclientDatabase ID.
querystringQuery table.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await this.SF.setListFromSQL('clientDatabaseID', "code='MMA'");

setListFromCustomListโ€‹

Is a function that allow to set list of data from CustomList.

Parametersโ€‹

NameTypeDescription
CustomListstringCustomList ID.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await this.SF.setListFromCustomList('CustomListID');

aggregateQueryโ€‹

Is a function that allow to set list of data from CustomList.

Parametersโ€‹

NameTypeDescription
typestringtype of the resource (collection, report, users, projects, external databases).
idstringId of the resource.
queryobjectJson of a value to be matched in the resource.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await this.SF.aggregateQuery('collection', '610c0343f6ebc7ddcb49cc3b', {value : "it"});

deleteFileโ€‹

Is a function that allow to delete a file using it ID.

Parametersโ€‹

NameTypeDescription
idstringId of the resource.

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
aggregationarrayaggregation array

Returnsโ€‹

TypeDescription
promiseReturn 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();

findByIdโ€‹

Allow to get a user by id.

Parametersโ€‹

NameTypeDescription
idstringuser id.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let user = await users.findById("userId");

findโ€‹

Allow to list the users.

Parametersโ€‹

NameTypeDescription
criteriaobjectQuery json.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let criteria = { 
firstName: new RegExp("p", "i")
}
let usersList = await users.find(criteria);

countโ€‹

Allow to get the count of users.

Parametersโ€‹

NameTypeDescription
criteriaobjectQuery json

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let criteria = { 
blocked: false
}
let count = await users.count(criteria);

findAndCountโ€‹

get a list and the count of users

Parametersโ€‹

NameTypeDescription
bodyobjectJson of options.

Returnsโ€‹

TypeDescription
promiseReturn promise

Optionsโ€‹

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
fieldsSelect specific fields (example: "createdAt email")
limitNumber of instances returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (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โ€‹

NameTypeDescription
aggregationarrayaggregation array

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
userIdstringuser ID.
groupidstringgroup ID.
modestringmode of the running user. interface

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await users.addRole("userId","groupId","SF_mode");

removeRoleโ€‹

Remove role from user using user ID & group ID.

Parametersโ€‹

NameTypeDescription
userIdstringuser ID.
groupidstringgroup ID.
modestringmode of the running user interface

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
idstringGroup ID

Returnsโ€‹

TypeDescription
promiseReturns group data

Examplesโ€‹

let group = await groups.findById("groupId123");

findโ€‹

Find groups based on a filter criteria.

Parametersโ€‹

NameTypeDescription
criteriaobjectSearch criteria object

Returnsโ€‹

TypeDescription
promiseReturns array of groups

Examplesโ€‹

let list = await groups.find({ name: /admin/i });

countโ€‹

Count the number of groups that match the criteria.

Parametersโ€‹

NameTypeDescription
criteriaobjectFilter criteria

Returnsโ€‹

TypeDescription
promiseReturns count

Examplesโ€‹

let total = await groups.count({ type: "system" });

findAndCountโ€‹

Find groups and return both the results and the total count.

Parametersโ€‹

NameTypeDescription
bodyobjectRequest body with filters and pagination

Returnsโ€‹

TypeDescription
promiseReturns object { data, count }

Examplesโ€‹

let result = await groups.findAndCount({ limit: 10, offset: 0 });

aggregateโ€‹

Aggregation operations process data records and return computed results.

Parametersโ€‹

NameTypeDescription
aggregationarrayAggregation pipeline array

Returnsโ€‹

TypeDescription
promiseReturns 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โ€‹

NameTypeDescription
idstringGroup ID

Returnsโ€‹

TypeDescription
promiseReturns 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

OptionDescription
idRequired. id or name of collection
modeoptional. Specifies mode of collection (default : "test")
const collection = new Collection({ id: 'collectionId', mode: this.SF_mode });

insertโ€‹

Allow to insert a json into a collection

Parametersโ€‹

NameTypeDescription
dataobjectJson of a value to be inserted in to the collection.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await collection.insert({ name: "name1", type : "type1" });

insertManyโ€‹

Allow to insert an array of json in to a collection.

Parametersโ€‹

NameTypeDescription
dataobjectJson of a value to be inserted in to the collection.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await collection.insertMany([{label : "IT", value : "it"}]);

updateManyโ€‹

update all the documents that satisfies the specified query criteria .

Parametersโ€‹

NameTypeDescription
criteriaobjectQuery json.
dataobjectJson of a new data.
optionsobjectJson of options

Returnsโ€‹

TypeDescription
promiseReturn 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โ€‹

NameTypeDescription
idstringDocument id.
dataobjectJson of a new data.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await collection.update("documentId", { type : "type2" });

deleteโ€‹

Allow to delete a document from collection

Parametersโ€‹

NameTypeDescription
idstringDocument id.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await collection.delete("documentId");

findByIdโ€‹

Allow to get a object by id from the collection

Parametersโ€‹

NameTypeDescription
idstringDocument id.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let document = await collection.findById(id);

findโ€‹

Allow to select the documents in a collection

Parametersโ€‹

NameTypeDescription
bodyobjectJson of options.

Returnsโ€‹

TypeDescription
promiseReturn promise

Optionsโ€‹

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
limitNumber of documents returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (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โ€‹

NameTypeDescription
criteriaobjectQuery json

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let count = await collection.count({ type: "type1" });

aggregateโ€‹

Aggregation operations process data records and return computed results

Parametersโ€‹

NameTypeDescription
aggregationarrayaggregation array

Returnsโ€‹

TypeDescription
promiseReturn 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).

OptionDescription
idRequired. id or name of Database
modeoptional. Specifies mode of Database (default : "test")
const sql = new SQLDatabase({ id: '610c0343f6ebc7ddcb49cc3b', mode: this.SF_mode});

findOneโ€‹

Get a table row data

Parametersโ€‹

NameTypeDescription
tableNamestringtable name.
Criteriastringquery table.

Returnsโ€‹

TypeDescription
object

Examplesโ€‹

let res = await sql.findOne("client", "code='MMA'"))

findโ€‹

list multiple rows from sql table

Parametersโ€‹

NameTypeDescription
tableNamestringtable name.
optionsstringquery table.

Returnsโ€‹

TypeDescription
array

Examplesโ€‹

let res = sql.find("client", "code='MMA'")

countโ€‹

Get the row count for a table with a criteria

Parametersโ€‹

NameTypeDescription
tableNamestringtable name.
optionsstringquery table.

Returnsโ€‹

TypeDescription
arrayarray with one element contining count

Examplesโ€‹

let count = await sql.count("client", "code='MMA'");

executeโ€‹

Execute a custom query on the database.

Parametersโ€‹

NameTypeDescription
querystringstring of query.

Returnsโ€‹

TypeDescription
arrayReturn array.

Examplesโ€‹

sql.execute("INSERT INTO client(code, intitule, representant, codepostal) VALUES('MDSX', 'holder', 'holder', 14000)")

insertโ€‹

Insert one row into a table.

Parametersโ€‹

NameTypeDescription
tableNamestringtable name.
dataobjectJSON body.

Returnsโ€‹

TypeDescription
array

Examplesโ€‹

sql.insert("client", {
code: 'HelloWord',
codepostal: 14000
}

insertManyโ€‹

Insert multiple rows into

Parametersโ€‹

NameTypeDescription
tableNamestringtable name.
dataarrayJSON body.

Returnsโ€‹

TypeDescription
array

Examplesโ€‹

sql.insertMany("client", [
{ code: '#1' },
{ code: '#2' }
])

updateโ€‹

Update rows.

Parametersโ€‹

NameTypeDescription
tableNamestringtable name.
querystringquery table.
dataobjectupdated JSON body.

Returnsโ€‹

TypeDescription
object

Examplesโ€‹

 sql.update('client',   "code='MMA'",
{
code: "MQS"
})

deleteโ€‹

Delete row/rows in your table.

Parametersโ€‹

NameTypeDescription
tableNamestringtable name.
querystringquery table.

Returnsโ€‹

TypeDescription
object

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.

Usageโ€‹

You can instantiate a SoftyTables class with id and mode options.

OptionDescription
idRequired. id of the SoftyTable
modeoptional. 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โ€‹

NameTypeDescription
rowIdstringThe ID of the row

Returnsโ€‹

TypeDescription
promiseResolves to the row data

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let row = await softyTable.findById('12345');

findโ€‹

List rows from a SoftyTable with optional filtering, sorting, and pagination.

Parametersโ€‹

NameTypeDescription
bodyobjectJSON of options (criteria, limit, page, sortby, direction)

Returnsโ€‹

TypeDescription
promiseResolves to an array of table rows

Optionsโ€‹

These options are optional

OptionDescription
criteriaSpecifies selection filter with where clause (default : {})
limitNumber of rows returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by field name (default : createdAt)
directionAscending (1) or descending (-1) order (default : -1)

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// List all rows
let rows = await softyTable.find({});

// List with filters and pagination
let body = {
criteria: {
where: { status: 'active' }
},
limit: 50,
page: 0,
sortby: 'createdAt',
direction: -1
}
let activeRows = await softyTable.find(body);

countโ€‹

Count the number of rows in a SoftyTable with optional filtering.

Parametersโ€‹

NameTypeDescription
criteriaobjectQuery criteria with optional where clause

Returnsโ€‹

TypeDescription
promiseResolves to an object with count property

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Count all rows
let result = await softyTable.count({});
// returns: { count: 150 }

// Count with filter
let result = await softyTable.count({
criteria: { where: { status: 'active' } }
});
// returns: { count: 75 }

findAndCountโ€‹

Get both a list of rows and the total count matching the criteria.

Parametersโ€‹

NameTypeDescription
bodyobjectJSON of options (criteria, limit, page, sortby, direction)

Returnsโ€‹

TypeDescription
promiseResolves 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;

insertโ€‹

Create a single row in a SoftyTable.

Parametersโ€‹

NameTypeDescription
bodyobjectThe data object to insert as a row

Returnsโ€‹

TypeDescription
promiseResolves 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โ€‹

NameTypeDescription
dataarrayArray of data objects to insert

Returnsโ€‹

TypeDescription
promiseResolves 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โ€‹

Update a single row in a SoftyTable by its ID.

Parametersโ€‹

NameTypeDescription
rowIdstringThe ID of the row to update
bodyobjectThe fields and values to update

Returnsโ€‹

TypeDescription
promiseResolves 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โ€‹

NameTypeDescription
criteriaobjectQuery criteria with where clause
valueobjectThe fields and values to update
optionsobjectAdditional options (optional)

Returnsโ€‹

TypeDescription
promiseResolves to update operation result

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Update all rows where status is 'pending'
let result = await softyTable.updateMany(
{ status: 'pending' },
{ status: 'active', processedAt: new Date() }
);

deleteโ€‹

Delete a single row from a SoftyTable by its ID.

Parametersโ€‹

NameTypeDescription
rowIdstringThe ID of the row

Returnsโ€‹

TypeDescription
promiseResolves 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โ€‹

NameTypeDescription
criteriaobjectQuery criteria with where clause

Returnsโ€‹

TypeDescription
promiseResolves to deletion result

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Delete all inactive rows
await softyTable.deleteMany({ status: 'inactive' });

// Delete rows older than a certain date
await softyTable.deleteMany({
createdAt: { $lt: new Date('2024-01-01') }
});

clearโ€‹

Clear all rows from a SoftyTable (delete all data).

Returnsโ€‹

TypeDescription
promiseResolves to deletion result

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Remove all rows from the table
await softyTable.clear();

getOptionsโ€‹

Retrieve options for select fields in a SoftyTable.

Returnsโ€‹

TypeDescription
promiseResolves to array of options

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

let options = await softyTable.getOptions();
// returns: [{ label: 'Active', value: 'active' }, { label: 'Inactive', value: 'inactive' }]

executeโ€‹

Execute a custom SQL query on the SoftyTable.

Parametersโ€‹

NameTypeDescription
querystringThe SQL query to execute
optionsobjectQuery options with replacements and type

Options Objectโ€‹

FieldTypeDescription
replacementsobjectValues to replace in parameterized queries
typestringQuery type: 'SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RAW', 'SHOWTABLES'

Returnsโ€‹

TypeDescription
promiseResolves to the query results

Examplesโ€‹

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Execute a SELECT query
let results = await softyTable.execute(
'SELECT * FROM my_table WHERE status = :status',
{
replacements: { status: 'active' },
type: 'SELECT'
}
);

// Execute a custom query
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โ€‹

TypeDescription
promiseResolves 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

Usageโ€‹

You can instantiate a CustomList class with id of custom list. You can add other options (mode, versionId)

OptionDescription
idRequired. id of custom list
modeoptional. Specifies mode of custom list (default : "test")
versionIdoptional. 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โ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let customListData = await customList.get();

9 - 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

OptionDescription
idRequired. Specifies mode of custom list (default : "test")
modeoptional. 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โ€‹

NameTypeDescription
aggregationarrayaggregation array

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let aggregation = [
{
"$match": { "SF_status": "Running" }
},
{
"$sort": { "SF_createdAt": -1 }
}
]
let instances = await report.aggregate(aggregation); //report of instances

10 - Instanceโ€‹


The Instance class has the methods that will allow you to manage the instances

Usageโ€‹

const instance = new Instance();

findByIdโ€‹

Get a instance by id

Parametersโ€‹

NameTypeDescription
idstringid of instance.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let oneInstance = await instance.findById(id);

findโ€‹

list the instances

Parametersโ€‹

NameTypeDescription
criteriaobjectJson of query.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let instances = await instance.find({ status: "Running" });

countโ€‹

Allow to get the count of instances that would match a query

Parametersโ€‹

NameTypeDescription
criteriaobjectQuery json

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let count = await instance.count({ status: "Running" });

findAndCountโ€‹

get a list and the count of instances

Parametersโ€‹

NameTypeDescription
bodyobjectJson of options.

Returnsโ€‹

TypeDescription
promiseReturn promise

Optionsโ€‹

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
fieldsSelect specific fields (example: "createdAt name status")
limitNumber of instances returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (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โ€‹

NameTypeDescription
aggregationarrayaggregation array

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let aggregation = [
{
"$match": { "status": "End" }
},
{
"$project" : {
"_id": 1,
"name": 1
}
}
]
let instances = await instance.aggregate([aggregation]);

updateโ€‹

Update an instance

Parametersโ€‹

NameTypeDescription
idstringid of instance.
dataobjectJson of a new data.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await instance.update(id, { status : "End" });

deleteโ€‹

Delete an instance

Parametersโ€‹

NameTypeDescription
idstringid of instance.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await instance.delete(id);

historyโ€‹

Get instance history.

Parametersโ€‹

NameTypeDescription
idstringid of instance.
dataobjectJson of data.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await instance.history(id, { status : "End" });

11 - Taskโ€‹


The Task class has the methods that will allow you to manage the tasks

Usageโ€‹

const task = new Task();

findByIdโ€‹

Get a task by id

Parametersโ€‹

NameTypeDescription
idstringid of task.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let oneTask = await task.findById(id);

findโ€‹

list the tasks

Parametersโ€‹

NameTypeDescription
criteriaobjectJson of query.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let tasks = await task.find({ instanceId: "instanceId" });

countโ€‹

Allow to get the count of tasks that would match a query

Parametersโ€‹

NameTypeDescription
criteriaobjectQuery json

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let count = await task.count({ instanceId: "instanceId" });

findAndCountโ€‹

get a list and the count of tasks

Parametersโ€‹

NameTypeDescription
bodyobjectJson of options.

Returnsโ€‹

TypeDescription
promiseReturn promise

Optionsโ€‹

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
assignedToConnectedTo get tasks of connected user (default : false)
fieldsSelect specific fields (example: "createdAt name status")
limitNumber of instances returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (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โ€‹

NameTypeDescription
aggregationarrayaggregation array

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

let aggregation = [
{
"$match": { "status": "End" }
},
{
"$project" : {
"_id": 1,
"name": 1
}
}
]
let tasks = await task.aggregate([aggregation]);

updateโ€‹

Update an task

Parametersโ€‹

NameTypeDescription
idstringid of task.
dataobjectJson of a new data.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await task.update(id, { status : "End" });

deleteโ€‹

Delete an task

Parametersโ€‹

NameTypeDescription
idstringid of task.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await task.delete(id);

getNextValueโ€‹

Get next value of an task.

Parametersโ€‹

NameTypeDescription
namestringname of the variable.
[padding]numberPadding of result with 000000.
modestringmode of the running user.

Returnsโ€‹

TypeDescription
promiseReturn promise

Examplesโ€‹

await task.getNextValue("name",5,"SF_mode");

historyโ€‹

Get the history of a task by its ID.

Parametersโ€‹

NameTypeDescription
idstringTask ID
bodyobjectQuery parameters (optional)

Returnsโ€‹

TypeDescription
promiseReturns 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.

Usageโ€‹

const api = new Api();

invokeโ€‹

Invoke an api.

Parametersโ€‹

NameTypeDescription
bodyobjectJson of options.

Returnsโ€‹

TypeDescription
promiseReturn 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.

Usageโ€‹

const email = new Email();

sendโ€‹

Send an email.

Parametersโ€‹

NameTypeDescription
assigneestringAssignee user email.
subjectstringSubject of the email.
variablesobjectJson of options.
mailTemplateobjectEmail template.
mailProviderobjectSoftyflow default provider.
ccstringJson of options.
fromstringSender user email.
replyTostring*

Returnsโ€‹

TypeDescription
promiseReturn 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.

Usageโ€‹

const ds = new DataSource();

findOneโ€‹

Retrieve a single document from a data source.

Parametersโ€‹

NameTypeDescription
sourcestringName of the source
optionsobjectQuery options

Returnsโ€‹

TypeDescription
promiseReturns a single document

Examplesโ€‹

let doc = await ds.findOne("users", { filter: { email: "user@example.com" } });

listโ€‹

List multiple documents from a data source.

Parametersโ€‹

NameTypeDescription
sourcestringName of the source
optionsobjectQuery options

Returnsโ€‹

TypeDescription
promiseReturns 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โ€‹

NameTypeDescription
sourcestringName of the source
optionsobjectQuery options

Returnsโ€‹

TypeDescription
promiseReturns the count of documents

Examplesโ€‹

let total = await ds.count("orders", { filter: { status: "delivered" } });

updateโ€‹

Update documents in a data source.

Parametersโ€‹

NameTypeDescription
sourcestringName of the source
optionsobjectQuery conditions
dataobjectData to update

Returnsโ€‹

TypeDescription
promiseReturns update result

Examplesโ€‹

await ds.update("products", { filter: { stock: 0 } }, { restock: true });

insertโ€‹

Insert a single document into a data source.

Parametersโ€‹

NameTypeDescription
sourcestringName of the source
dataobjectDocument to insert
optionsobjectAdditional options

Returnsโ€‹

TypeDescription
promiseReturns insert result

Examplesโ€‹

await ds.insert("logs", { action: "login", userId: "abc123" });

insertManyโ€‹

Insert multiple documents into a data source.

Parametersโ€‹

NameTypeDescription
sourcestringName of the source
dataarrayArray of documents
optionsobjectAdditional options

Returnsโ€‹

TypeDescription
promiseReturns insert result

Examplesโ€‹

await ds.insertMany("logs", [{ action: "view" }, { action: "edit" }]);

deleteโ€‹

Delete documents from a data source.

Parametersโ€‹

NameTypeDescription
sourcestringName of the source
optionsobjectDelete criteria

Returnsโ€‹

TypeDescription
promiseReturns delete result

Examplesโ€‹

await ds.delete("sessions", { filter: { expired: true } });

executeโ€‹

Execute a custom action or command on a data source.

Parametersโ€‹

NameTypeDescription
sourcestringName of the source
optionsobjectParameters for execution

Returnsโ€‹

TypeDescription
promiseReturns 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โ€‹

NameTypeDescription
filenamestring- Desired name for the generated PDF
fidstring- File ID to fetch content from
contextobject- Contextual data for PDF rendering (e.g., variables)

Returnsโ€‹

TypeDescription
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โ€‹

NameTypeDescription
namestring- Name for the output (not directly used in the call)
fidstring- File ID of the template
contextobject- Variable data used for rendering the template

Returnsโ€‹

TypeDescription
Promise- Resolves with the server response

Exampleโ€‹

const file = new File();
file.genratePDFWithVar("Invoice", "605c72...", { variables: { amount: 100, user: "Alice" } });