Skip to main content
Version: v5.0

IafScriptEngine

Use the IafScriptEngine higher-level API to write scripts on the platform by using utility functions and calling platform APIs.

addDatasource#

Creates an orchestrator.

ParameterRequiredTypeDescription
reqYesJSONAdd an Orchestrator object.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Array<Orchestrator> - An array containing an Orchestrator object

Examples
let req = {  "_name": "Rest Connector",  "_description": "Rest Connector Calls",  "_namespaces": [    "$current_project._namespaces"  ],  "_userType": "xlsx_import",  "_params": {    "tasks": [      {        "_orchcomp": "rest_connector",        "_name": "Get telemetry data from data aggregation platform",        "_sequenceno": 1,        "_actualparams": {          "_url": "http://telemetry.com/api",          "_auth": {          "_type": "BasicAuth",          “_params”: {            “_username”: proj_1.username,            “_password”: proj_1.username.pwd          }        },        "to": "json"      },      {        "_orchcomp": "default_script_target",        "_name": "Store telemetry data in the item service",        "_sequenceno": 2,        "_actualparams": {          "userType": "iaf_telem_store",          "_scriptName": "storeTelem",        }      }    ]  }};
let orchestrator = await IafScriptEngine.addDatasource(req);

addNamespaceToCtx#

Add a namespace to the Ctx, which is the context that you can refer to in other methods.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with a "_namespaces" property.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Ctx - Context storage

Examples
let req = {    "_namespaces": ["1_pzOxaMwR", "5_ly2xbPwD", "7_hsLqaCwP"]};
IafScriptEngine.addNamespaceToCtx(req);

addRelatedCollections#

Adds related collections to a named composite item in the item service.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "namedCompositeItemId" and "relatedCollections" properties and values. You can also add optional "options", "options.project", "options.sort", "options.page" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

relatedCollection - The added related collections

Examples
let req = {  "namedCompositeItemId": "5dcbbd24f16c872134947df2",  "relatedCollections": [    {_userItemId: '5dcbbd24f16c872134947df2'},     {_userItemId: '5dcab6acfa877736bb1c5311'},    {_userItemId: '9puyc6bdga576731fc1c8317'}  ]}
let updatedColl = await IafScriptEngine.addRelatedCollections(req);

attachItemsAsRelated#

Creates relationships between child related items and parent related items when you pass parent and child arrays of the same length.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "parentItems" and "relatedItems" fields.
cNoCtxContext, such as namespaces and authentication token information.

createCollection#

Creates a collection.

ParameterRequiredTypeDescription
reqYesNamedUserItemPass a NamedUserItem object with the properties you want to define the collection.
cNoCtxContext, such as namespaces and authentication token information.
Returns

NamedUserItem - The created collection

Examples
let req = {    "_shortName": "example_col",    "_itemClass": “NamedUserCollection”,    "_userType":"example_colection",    "_namespace": ["3_jtOxaGwR"]};
let collection = await IafScriptEngine.createCollection(req);

createFileCollection#

Creates a named file collection.

ParameterRequiredTypeDescription
reqYesNamedUserItemPass a NamedUserItem object with the properties you want to define the file collection.
cNoCtxContext, such as namespaces and authentication token information.
Returns

NamedUserItem - The created collection

Examples
let req = {    "_shortName": "example_file_col",    "_itemClass": “NamedFileCollection”,    "_userType":"example_file_colection",    "_namespace": ["6_jkOloLGwR"]};
let fileColl = await IafScriptEngine.createFileCollection(req);

createIndex#

Creates a database index for a named user item.

ParameterRequiredTypeDescription
reqYesIndexPass an Index object with the collection's "_id" property and your database index options.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<Page<JSON>> - The MongoDB indexes for the collection

Examples
let req = { "_id": "5cee7fee6505d6286dbca469", "indexDefs": [   {     "key": {       "name": "text",       "fileAttributes.name": "text",       "fileAttributes.description": "text",       "fileAttributes.documentType": "text",       "fileAttributes.iputAssetType": "text",       "fileAttributes.levelsAndLocations": "text"     },     "options": {       "name": "text_search_index",       "default_language": "english"     }   } ]}
let index = await IafScriptEngine.createIndex(req);

createItems#

Creates related items for a user item in the item service.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "items" and "userItemId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

RelatedItem - The created related items

Examples
let args = {  "items":[{     "source_index": "accounts-4"   }] ,  "_userItemId": "5dcbbd24f16c872134947df2"};
let items = await createItems(args);

createItemsAsRelatedBulk#

Takes an array of related items and creates a relationship between them and one parent related item.

ParameterRequiredTypeDescription
argsYesJSONObjectPass a JSON object with "items", "parentUserItemId", and "_userItemId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

JSON - Returns a bulk response the list of related items with a "_createdCount" parameter with the number of created related items.

createItemsBulk#

Creates related items in bulk.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with the two following properties: "items" and "_userItemId".
cNoCtxContext, such as namespaces and authentication token information.
Returns

JSON - A bulk JSON response with "_createdCount" and "_uris" properties for each related item

Examples
let args = {  "items": [    {"_userType": "hvac_equipment", "name": "condensing_unit"},     {"_userType": "hvac_equipment", "name": "air_handler"},     {"_userType": "hvac_equipment", "name": "air_conditioner"}  ],};  "_userItemId": "5dcab6acfa877736bb1c5311"};
let relatedItems = await IafScriptEngine.createItemsBulk(args);

createNamedCompositeItem#

Creates a named composite item with related collections.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with a "relatedCollections" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

NamedUserItem - The created named composite item

Examples
let req = {  "relatedCollections": [    {"_userItemId": "5dcbbd24f16c872134947df2"},    {"_userItemId": "5dcab6acfa877736bb1c5311"},    {"_userItemId": "9puyc6bdga576731fc1c8317"}  ]};
let compositeItem = await IafScriptEngine.createNamedCompositeItem(req)

createNamedUserItemVersion#

Creates a named user item version.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with a "namedUserItemId" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

NamedUserItemVersion - The created named user item version.

Examples
let req = {  "namedUserItemId": "5dcbbd24f16c872134947df2", };
let itemVersion = await IafScriptEngine.createNamedUserItemVersion(req);

createOrchestratorSchedule#

Creates an orchestrator schedule.

ParameterRequiredTypeDescription
reqYesJSONObjectPass an object with the OrchestratorSchedule properties and values you want to define the orchestrator schedule.
cNoCtxContext, such as namespaces and authentication token information.
Returns

OrchestratorSchedule -

Examples
let req = {  "next_scheduled_time": "1606890210090",  "runinterval": "* * 30"};
let orchSchedule = await IafScriptEngine.createOrchestratorSchedule(req);

createOrRecreateCollection#

Creates a collection or overwrites an existing collection that has the same NamedUserItem criteria.

ParameterRequiredTypeDescription
reqYesNamedUserItemPass a NamedUserItem JSON object with the properties you want to define the collection.
cNoCtxContext, such as namespaces and authentication token information.
Returns

NamedUserItem - The created collection

Examples
let req = {    "_shortName": "example_col",    "_itemClass": “NamedUserCollection”,    "_userType":"example_colection",    "_namespace": ["3_jtOxaGwR"]};
let collection = await IafScriptEngine.createOrRecreateCollection(req);

createOrRecreateIndex#

Creates an index for a named user collection, or overwrites the existing index if it has the same "_name" property.

ParameterRequiredTypeDescription
reqYesIndexPass an Index object with the collection's "_id" property and your database index options.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<Page<JSON>> - The database indexes for the collection

Examples
let req = {  "_id": "5cee7fee6505d6286dbca469",  "indexDefs": [    {      "key": {        "name": "text",        "fileAttributes.name": "text",        "fileAttributes.description": "text",        "fileAttributes.documentType": "text",        "fileAttributes.iputAssetType": "text",        "fileAttributes.levelsAndLocations": "text"      },      "options": {        "name": "text_search_index",        "default_language": "english"      }    }  ]};
let index = await IafScriptEngine.createIndex(req);

createRelations#

Creates parent-child relations between parent items in one collection and child items in the same or another collection.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "parentUserItemId", "_userItemId", and "relations" properties. For the "parentUserItemId" property, add the parent user item id as its value. For the "_userItemId" property, add the named user item id as its value. For the "relations" property, add an array of Relationship objects you want to create.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<String> - ok: 204 response

Examples
let args = {  "parentUserItemId": 5ac195d1-4c24-40a3-a2d4-32573ed74217,   "_userItemId": 75b2a3d6-a3e8-498d-99dc-23538bc9a389,   "relations": {     parentItem: {_id: 5fr345r1-4e24-40z3-l2dk-34554ed36789},     relatedItems: [{_id: 7ac887d1-2c88-45a8-3274-73785iu75886}, {_id: 4oi769d7-7l58-28i6-h2d7-85648ty87965}]   }};
let relations = await IafScriptEngine.createRelations(args);

deleteItems#

Deletes named user items.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "items", and "_userItemId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<String> - ok: 204 response

Examples
let args = {  "items": [<YOUR-ITEM-ARRAY>],  "_userItemId": "5dcbbd24f16c872134947df2"};
await IafScriptEngine.deleteItems(args);

deleteOrchestratorSchedule#

Deletes an orchestrator schedule.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with an "id" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

String - ok: 204 response

Examples
let req = {  "id": "1eedf5bc-d1f7-4432-9063-c76f84967eb0"};
await IafScriptEngine.deleteOrchestratorSchedule(req);

deleteRelations#

Deletes the record of a relationship between two related items in different collections.

ParameterRequiredTypeDescription
argsYesJSONObjectPass a JSON object with "parentUserItemId", and "_userItemId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<String> - ok: 204 responselet args = { "parentUserItemId": "5dcbbd24f16c872134947df2", "_userItemId": "5kisnt24f16c907854371pf0" };await IafScriptEngine.deleteRelations(args);

downloadFile#

Gets a download URL for a particular file version.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "fileId" and "versionId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

String - file URL

Examples
let req = {    "_fileId": "9df6e162-acea-11ed-afa1-0242ac120002",    "_fileVersionId": "1wxft3696g2e1a6daa57fh33"};
let downloadUrl = await IafScriptEngine.downloadFile(req);

dynamicImport#

Dynamically imports a script by its criteria, such as its _userType property. Note: If more than one script returns based on the criteria, only the first script loads.

ParameterRequiredTypeDescription
criteriaYesNamedUserItemCriteriaEnter a NamedUserItemCriteria object containing a valid simple query.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

any - Returns a promise to a module namespace object that contains all exports from moduleName.

Examples
let criteria = {    "_usertype":"project_setup",    "_name":"projectSetup",    "query": {        "_usertype":"project_setup",        "_name":"projectSetup"    }};
let myScript = await IafScriptEngine.dynamicImport(criteria);

findInCollections#

Looks up named user collections and their related items based on your criteria. Note: This method looks up the tip versions only. To look up multiple versions, use IafItemsvc.searchRelatedItems.

ParameterRequiredTypeDescription
argsYesJSONPass a findInCollections query without the operator.
cNoCtxContext, such as namespaces and authentication token information.
Returns

JSON - The query response in JSON. If you add the property and set it to , the data for all the pages appears in the response's property.

findWithRelated#

Looks up related items in multiple named user collections with a query you pass.Note: This method looks up the tip versions only. To look up multiple versions, use IafItemsvc.searchRelatedItems.

ParameterRequiredTypeDescription
findArgYesJSONPass a $findWithRelated query without the operator.
cNoCtxContext, such as namespaces and authentication token information.
Returns

JSON - The query response in JSON. If you add the property and set it to , the data for all the pages appears in the response's property.

findWithRelatedGraph#

Looks up related items across multiple named user collections, hopping from related item to related item by relationship. You can traverse more than one level of relationship in either a parent-child or child-parent direction to get the data you want.This method looks up the tip versions only. To look up multiple versions, use IafItemsvc.searchRelatedItems.

ParameterRequiredTypeDescription
findArgYesJSONPass a findWithRelatedGraph query without the operator.
cNoCtxContext, such as namespaces and authentication token information.
Returns

JSON - The query response in JSON. If you add the property and set it to , the data for all the pages appears in the response's property.

findWithRelatedMulti#

Looks up related items in multiple named user collections with an array of queries you pass. Note: This method looks up the tip versions only. To look up multiple versions, use IafItemsvc.searchRelatedItems.

ParameterRequiredTypeDescription
findArrayYesJSONPass an array of findWithRelated queries without the operator.
cNoCtxContext, such as namespaces and authentication token information.
Returns

JSONArray - The query response in JSON. If you add the property and set it to , the data for all the pages appears in the response's property.

getCollection#

Gets the first user collection that matches your query.

ParameterRequiredTypeDescription
queryYesJSONPass an object that contains a "query" parameter with your query object as its value.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoNamedUserItemCriteriaOptionsPass a NamedUserItemCriteriaOptions object with your response options, such as "page", "projection", or "sort".
Returns

NamedUserItem - The first user collection that matches your query.

Examples
let query = {  query: {"_id": "1e7433c4-a3de-4c15-b8fb-657c1d9b814c"} };
let options = {  "project": {    "source_id": 1  },}; let collection = await IafScriptEngine.getCollection(query, options);

getCollectionInComposite#

Gets the collections in a composite collection that match your simple query.

ParameterRequiredTypeDescription
idYesStringPass the composite collection id.
queryYesJSONPass a valid simple query to target the collections you want.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoUserCollectionOptionsPass an UserCollectionOptions object with the options you want, such as userItemVersionId. To return the latest version, add the "getLatestVersion" property and set it to "true".
Returns

Page<NamedUserCollection> - A Page object with the NamedUserCollection objects that match you query

Examples
let id = "9_gb_comp_Ip9zmx6o7O";
let query = {  query: {"_userItemId": "8_ta_col_Ik9zmx6o7O"} };
let options = {  "getLatestVersion": "true",  "userItemVersionId": {    "source_id": 1  }};
let id = "6333e105026300398e2d653e";
let collection = await IafScriptEngine.getCollectionInComposite(id, query, options);

getCollections#

Gets a list of user collections that match a simple query you pass.

ParameterRequiredTypeDescription
queryYesJSONPass a JSON object with a "query" parameter. In the "query" property's value, insert a valid MongoDB query to target the named user collections you want.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoNamedUserItemCriteriaOptionsPass a NamedUserItemCriteriaOptions object with your options, such as page, projection, or sort.
Returns

Page<NamedUserItem> - A Page object with the NamedUserItem objects that match.let query = { query: {"_userItemId": "3_ba_elem_Ik9zmx6o7O"} };let options = { "project": { "source_id": 1 }, "sort": { "_name": 1 } };let collections = await IafScriptEngine.getCollections(query, options);

getCollectionsInComposite#

Gets all the related collections in a named composite item that match your query.

ParameterRequiredTypeDescription
idYesStringPass the composite collection id, such as the database id or the _userItemId.
queryYesJSONObjectrelated collection filter /Pass a simple query that uses RelatedCollection properties.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoUserCollectionOptionsPass an UserCollectionOptions object with the options you want, such as userItemVersionId.
Note: To return the latest version, add the "getLatestVersion" property and set it to "true".
Returns

Page<RelatedCollection> - A page object with the related collections that match your querylet id = "9_gb_comp_Ip9zmx6o7O";let query = { query: {"_userItemId": "5_hz_elem_Ik9zmx6o7O"} };let options = { "getLatestVersion": "true", "userItemVersionId": { "source_id": 1 } };let collections = await IafScriptEngine.getCollectionsInComposite(id, query, options);

getCompositeCollection#

Gets a composite collection that matches a simple query you pass.

ParameterRequiredTypeDescription
queryYesJSONPass a JSON object with a "query" parameter. In the "query" property's value, insert a valid simple query to target the composite collection you want.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoNamedUserItemCriteriaOptionsPass a NamedUserItemCriteriaOptions object with the options you want, such as page, projection, and sort. To return the latest version, add the options.getLatestVersion property and set it to "true".
Returns

NamedUserItem - A NamedUserItem object

Examples
let query = {  query: {"_id": "2f6423c4-b3df-4c15-b8fb-657c1d9b642m"} };
let options = {  "project": {    "source_id": 1  },  "getLatestVersion": true}; let compositeColl = await IafScriptEngine.getCompositeCollection(query, options);

getCompositeCollections#

Gets composite collections that match a simple query you pass.

ParameterRequiredTypeDescription
queryYesJSONPass a JSON object with a "query" property. In the "query" property's value, insert a valid simple query to target the composite collections you want.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoNamedUserItemCriteriaOptionsPass a NamedUserItemCriteriaOptions object with the options you want, such as page, projection, and sort.
Returns

Page<NamedUserItem> - A page of NamedUserItem objects.

Examples
let query = {  query: {"_userItemId": "3_ba_elem_Ik9zmx6o7O"} };
let options = {  "project": {    "source_id": 1  },  "sort": {    "_name": 1  }}; let compositeColls = await IafScriptEngine.getCompositeCollections(query, options);

getDatasourceRunStatus#

Get an orchestrator's orchRunStatus when you pass an OrchRun id.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with a "runid" property.
cNoCtxContext, such as namespaces and authentication token information.

getDatasources#

Gets orchestrators when you pass namespaces and userType query criteria.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "_namespaces" and "_userType" properties and values.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<Orchestrator> - A Page object with orchestrator objects that match your query.

Examples
let req = {  "_namespaces": ["test_bXgr468E"],  "_userType": "test_instant"};
let orchestrators = await IafScriptEngine.getDatasources(req);

getDistinct#

Gets the distinct field values for related items in a named user collection.

ParameterRequiredTypeDescription
argsYesJSONPass an object with a "field" property. You can also add an "options" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<JSON> - A Page of distinct items that match your query

Examples
args = {  "getAllUserItems":true,  "collectionDesc": {    "_userItemId": "11_new_ba_elem_1sjwcciumd",    "_versions.all": true  },  "collectionProject": {    "_id": 1,    "_userItemId": 1  },  "field": "type_id",  "query": {}};
let distinct = await IafScriptEngine.getDistinct(args);

getDistinctMulti#

Gets an array of distinct items that match your array of queries.

ParameterRequiredTypeDescription
argArrYesJSONPass an array of objects with the following properties: (args: the query to look for items. args.field: the field name for which to return distinct items)
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<JSONObject> - distinct items based on the field name

Examples
let argArr = [  {    "collectionDesc": {      "_userItemId": "11_new_ba_elem_1sjwcciumd",      "_versions.all": true    },    "collectionProject": {      "_id": 1,      "_userItemId": 1    },    "field": "type_id",    "query": {}  },  {    "collectionDesc": {      "_userItemId": "13_new_ba_elem_1sjwcciumd",      "_versions.all": true    },    "collectionProject": {      "_id": 1,      "_userItemId": 1    },    "field": "type_id",    "query": {}  },];
let distinctItems = await getDistinctMulti(argArr);

getDistinctWithCount#

Gets an array of distinct items with count.

ParameterRequiredTypeDescription
argsYesJSONthe query to look for items.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<JSON> - The array of distinct items.

Examples
let args = {"getAllUserItems":true,"collectionDesc": {"_userItemId": "asset_coll_1dB8xLuu8o"},"collectionProject": {"_id": 1,"_userItemId": 1},"fieldDesc": [{"field": "properties.dtCategory.val","count": "true"},{"field": "properties.dtType.val","query": {},"count": "true"}]}let res = IafScriptEngine.getDistinctWithCount(args, ctx);//Sample response{"properties.dtType.val": [{"count": 2,"value": "Plaster Board"},{"count": 1,"value": "Tea and Canteen Tiling"}],"properties.dtCategory.val": [{"count": 1,"value": "Wall & Ceiling Finish"},{"count": 2,"value": "Ceiling"}]}

getFile#

Gets a particular file version's source file.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "fileId" and "versionId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<buffer> - Returns a Promise object with a buffer of the file stream.

Examples
let req = {    "fileId": "5dafe5736f2d3a4dcc55fa14",    "versionId": "1wxft3696g2e1a6daa57fh33"};
let fileVersion = await IafScriptEngine.getFile(req);

getFileCollection#

Gets the first file collection that matches your simple query.

ParameterRequiredTypeDescription
queryYesJSONPass a JSON object with a "query" property. In the "query" property's value, insert a valid simple query to target the file collection you want.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsYesNamedUserItemCriteriaOptionsPass a NamedUserItemCriteriaOptions object with the options you want, such as page, projection, and sort.
Returns

NamedUserItem - The first file collection that matches your query.let query = { query: {"_id": "9d6423c4-b3df-4c15-b8fb-657c1d9b642m"} };let options = { "project":{"_userType": 1, "_itemClass": 1}, "sort": {"_name": 1}, // -1 for descending order "page": {"_offset": 10, "_pageSize": 20} };let fileColl = await getFileCollection(query, options);

getFileCollections#

Gets file collections that match your query.

ParameterRequiredTypeDescription
queryYesNamedUserItemCriteriaPass a NamedUserItemCriteria object to match the file collections you want.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsYesNamedUserItemCriteriaOptionsPass a NamedUserItemCriteriaOptions object with the options you want, such as page, projection, and sort.
Note: To return the latest version, add the options.getLatestVersion property and set it to "true".
Returns

Page<NamedUserItem> - A Page object with the NamedUserItem objects that match you query

Examples
let query = {  query: {"_userItemId": "3_ba_elem_Ik9zmx6o7O"} };
let options = {  "project": {    "source_id": 1  },  "sort": {    "_name": 1  }}; let fileColls = await IafScriptEngine.getFileCollections(query, options);

getFileInfo#

Gets File object data when you pass a simple query.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "query" and "options" parameters. In the "query" property's value, insert a valid MongoDB query to target the file you want and its properties. In the "options" property, pass an Options object with your offset and page size preferences.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<File> - A Page object with the File objects that match your query.

Examples
let req = {  "query": {    "_tags": "Warranty"  },  "options": {    "_pageSize": 100,    "_offset": 10  }};
let fileInfo = await IafScriptEngine.getFiles(req);

getFileItems#

Gets file items in a named file collection that match your query.

ParameterRequiredTypeDescription
reqYesArray<JSON>Pass an array of JSON objects with basic property-value pairs for the NamedUserCollection type.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<FileItem> - A page object with the file items that match your query

Examples
let req = {  "_userItemId": "94_file_col_4GonYYWpov"};
let fileItems = await IafScriptEngine.getFileItems(req);

getFileItemsMulti#

Gets file items in multiple named file collection that match your array of queries. Please keep options.getAllItems true to fetch all the items

ParameterRequiredTypeDescription
getArrayYesArray<(JSON | CollectionQuery)>Pass an array of JSON objects with basic property-value pairs of type NamedFileCollection.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<FileItem> - A page object with the file items that match your query

Examples
let req = [  {"_userItemId": "11_file_col_4LeaYYWpsz"},  {"_userItemId": "1mb_file_col2_OYK5UKTTTl"},  {"_userItemId": "22_file_col3_5PTaGGWmlh"}];
It also accepts collectionDesclet req = [{"collectionDesc": {"_userItemId": "1801ks-inv-_files_UKFFYde0He"},"query": {"doc_type": "warranty_docs"},"options": {"page": {"getAllItems": true}}}];
let fileItems = await IafScriptEngine.getFileItemsMulti(req);

getFiles#

Gets a container's file items by the container's path.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "query" and "options" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

(Array<FileItem> | Page<FileItem>) - Returns an array of FileItem objects. If you set options.pagedRes to true, the method returns a Page object with FileItem objects.

Examples
let req = {  "query": {    "_tags": "Warranty"  }  "options": {    "project": {      "source_id": 1    }  }, };
let fileItems = await IafScriptEngine.getFiles(req);

getFileVersionsInfo#

Gets file versions when you pass the file's UUID.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with a "fileId" property.
cNoCtxContext, such as namespaces and authentication token information.
Examples
let req = {    "fileId": "5dafe5736f2d3a4dcc55fa14";};
let fileVersions = await IafScriptEngine.getFileVersionsInfo(req);

getFileVersionUrl#

Gets a download URL for a particular file version. The URL expires after 48 hours.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "_fileId" and "_fileVersionId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Array<FileVersion> -

Examples
let req = {  "_fileId": "6336c490017d84b0a506e453",  "_fileVersionId": "6336c490017d84b0a506e45a"};
let downloadUrl = await IafScriptEngine.getFileVersionUrl(req);

getInverseRelations#

Gets the inverse relationships in a named user collection that matches your query.

ParameterRequiredTypeDescription
reqYesundefined
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<Relationship> - A Page object with the relationships that match your query

Examples
let req = {  "_userItemId": "11_new_geom_view_4LeaYYWpsz"}
let inverseRelations = await IafScriptEngine.getInverseRelations(req);

getItems#

Gets items in a named user collection that match your simple query.

ParameterRequiredTypeDescription
reqYesCollectionQueryPass a JSON object with basic property-value pairs of typye NamedUserCollection.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<RelatedItem> - A page object with the named user items that match your query

Examples
let req = {  "_userItemId": "11_new_geom_view_4LeaYYWpsz",  "project": {"source_id": 1}};
let items = await IafScriptEngine.getItems(req);

getItemsMulti#

Gets items in multiple named user collections. This method takes an array of objects to query. You can also use this method to map relations between collections.

ParameterRequiredTypeDescription
getArrayYesArray<(CollectionQuery | JSON)>Pass an array of JSON objects with basic property-value pairs of type NamedUserCollection.
cYesundefined
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Page<RelatedItem> - A page object with the named user items that match your query

Examples
let req = [  {"_userItemId": "11_sensor_col_4LeaYYWpsz"},  {"_userItemId": "1mb_tel_items_col2_OYK5UKTTTl"},  {"_userItemId": "22_sensors_col3_5PTaGGWmlh"}];
It also accepts collectionDesc
let req = [{"collectionDesc": {"_userItemId": "1801ks-inv-_ba_ele_UKFFYde0He"},"query": {"dtCategory": "sys_equipments"},"options": {"page": {"getAllItems": true}}}];
let items = await IafScriptEngine.getItemsMulti(req);

getItemsOfRelations#

Gets the child related items of the relationships you pass.

ParameterRequiredTypeDescription
reqYesundefined
cYesundefined
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Page<NamedUserItem> - A Page object with an array of items that match your query

getItemsOfRelationsMulti#

Gets the related items of the relationships you pass.

ParameterRequiredTypeDescription
getArrayYesundefined
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<NamedUserItem> - A page object with an array of items that match your query

Examples
let req = {  "_relatedToIds": [“002f617e-4d16-43b1-a7fa-981cc30e6dcc”, “982f614f-4g79-63b7-a6fb-981gg30e6dtt”],  "_relatedUserItemId": "samplehouse_geom_file_n8scKhhra7"};
let childRelatedItems = await IafScriptEngine.getItemsOfRelations(req);

getOrchestratorRuns#

Gets all orchestrator runs or those that match a simple query you pass.

ParameterRequiredTypeDescription
reqNoJSONObjectTo filter orchestrator runs, pass an object with your simple query. Otherwise, pass an empty object.
cNoCtxContext, such as namespaces and authentication token information.
criteriaYesundefined
Returns

Array<OrchRun> -

Examples
let criteria = { _pageSize: 10, _offset: 0, _status: COMPLETED, startDate: 1675839681115, endDate: 1675839758115 };
let orchRuns = await IafScriptEngine.getOrchestratorRuns({}, ctx, criteria)

getOrchestratorSchedule#

Gets orchestrator schedules when you pass an orchestrator schedule id.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with an "id" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Orchestrator -

Examples
let req = {  "id": "1eedf5bc-d1f7-4432-9063-c76f84967eb0"};
let schedules = await IafScriptEngine.getOrchestratorSchedule(req);

getOrchestratorSchedules#

Gets all orchestrator schedules or those that match a simple query you pass.

ParameterRequiredTypeDescription
reqNoJSONTo filter your query, pass a JSON object with OrchSchedule properties and values.
cNoCtxContext, such as namespaces and authentication token information.
Returns

OrchSchedule -

getRelations#

Gets the relationships in a named user collection that match your query.

ParameterRequiredTypeDescription
reqYesundefined
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<Relationship> - A Page object with the relationships that match your query

Examples
let req = {  "_userItemId": "11_new_geom_view_4LeaYYWpsz"};
let relations = await IafScriptEngine.getRelations(req);

getRelationsMulti#

Gets relationships in multiple named user collections when you pass an array of query objects.

ParameterRequiredTypeDescription
getArrayYesArray<JSON>Pass an array of JSON objects with basic property-value pairs of type NamedUserCollection.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<Relationship> - A Page object with the relationships that match your query

Examples
let req = [  {"_userItemId": "11_new_geom_view_4LeaYYWpsz"},  {"_userItemId": "1mb_4222225_ba_elem_OYK5UKTTTl"},  {"_userItemId": "22_geom_view2_5PTaGGWmlh"}];
let relationships = await IafScriptEngine.getRelationsMulti(getArray);

getTelItemsMulti#

Gets telemetry items in multiple named telemetry collection that match your array of queries. Please keep options.getAllItems true to fetch all the items

ParameterRequiredTypeDescription
getArrayYesArray<(CollectionQuery | JSON)>Pass an array of CollectionQuery, The _userItemId criteria should be of type NamedTelemtryCollections.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Page<FileItem> - A page object with the file items that match your query

Examples
let req = [  {"_userItemId": "11_sensor_col_4LeaYYWpsz"},  {"_userItemId": "1mb_tel_items_col2_OYK5UKTTTl"},  {"_userItemId": "22_sensors_col3_5PTaGGWmlh"}];
It also accepts collectionDesc
let req = [{"collectionDesc": {"_userItemId": "1801ks-inv-_sensors_UKFFYde0He"},"query": {"sensor_type": "air_quality","floor": 3},"options": {"page": {"getAllItems": true}}}];
let fileItems = await IafScriptEngine.getTelItemsMulti(req);

mapItemsAsRelated#

Maps an array of parent items to their related items by targeting specific fields.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "parentItems", "relatedItems", "fromField", and "relatedField" fields.
cNoCtxContext, such as namespaces and authentication token information.

mapItemsAsRelatedMulti#

Maps multiple related items at a time when you pass parent and child item arrays.

ParameterRequiredTypeDescription
argsYesJSONPass an array of JSON objects with "parentItems", "relatedItems", "fromField", and "relatedField" fields.
cNoCtxContext, such as namespaces and authentication token information.

mapItemsAsRelatedWithCustomAttributes#

Maps related items by the _customAttributes value in a Relationship object.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "parentItems", "relatedItems", "fromContainerField", "customAttributeFields", and "relatedField" fields.
cNoCtxContext, such as namespaces and authentication token information.

removeDatasource#

Deletes an orchestrator when you pass its id.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with an "orchId" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

String - ok: 204 response

Examples
let req = {  "orchId": "0567d327-87ed-431c-923d-3a4d86ae9105"};
await IafScriptEngine.removeDatasource(req);

removeRelations#

Removes a relationship between two related items in different collections.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "parentUserItemId", and "_userItemId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<String> - ok: 204 response

Examples
let args = {  "parentUserItemId": "5dcbbd24f16c872134947df2",   "_userItemId": "5kisnt24f16c907854371pf0"};
await IafScriptEngine.removeRelations(args);

runDatasource#

Posts an orchestrator run by Orch id.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with a "orchestratorId" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

True/False -

Examples
let req = {  "orchestratorId": "0567d327-87ed-431c-923d-3a4d86ae9105"};
await IafScriptEngine.runDatasource(req);

updateItemsBulk#

Bulk updates named user items.

ParameterRequiredTypeDescription
argsYesJSONPass a JSON object with "items", and "_userItemId" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<String> - ok: 204 response

updateNamedUserItemVersion#

Updates a named user item version when you pass a NamedUserItem object.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "userItemId", "userItemVersionId", and "version" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

NamedUserItemVersion - The updated named user item version with "_version" and "_isTop" properties.

Examples
let req = {  "userItemId": "5dcbbd24f16c872134947df2",  "userItemVersionId": "7gykes28f16c872134947dfb",  "version":};
let itemVersion = await IafScriptEngine.updateNamedUserItemVersion(req);

updateOrchestrator#

Updates an orchestrator.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with an "id" property and the Orchestrator properties and values you want to update.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Orchestrator - The updated Orchestrator object

updateOrchestratorRun#

Updates an orchestrator run.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with a "id" property.
cNoCtxContext, such as namespaces and authentication token information.
Returns

OrchestratorRun -

Examples
let req = {  "id": "0567d327-87ed-431c-923d-3a4d86ae9105"};
let updatedOrchRun = await IafScriptEngine.updateOrchestratorRun(req);

updateOrchestratorSchedule#

Updates an orchestrator schedule.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "id" and "runinterval" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

OrchestratorRun -

Examples
let req = {  "id": "1eedf5bc-d1f7-4432-9063-c76f84967eb0"  "runinterval": "* * 30"};
let orchSchedule = await updateOrchestratorSchedule(req);

uploadFile#

Uploads a file to the file service when you pass a File object. Add callback functions for progress and success events.

ParameterRequiredTypeDescription
fileYesFilePass a File object with the metadata you want, such as namespaces, parents, a filename, and tags.
ctxNoCtxContext, such as namespaces and authentication token information.
onProgressYesFunctionPass your callback function for an onProgress event.
onSuccessYesFunctionPass your callback function for an onSuccess event.
headersYesFileHeadersThe headers will be applied to the HTTP response during download
Returns

File - The created File object from file service with its metadata

Examples
let file = { "fileObj": <File or ReadStream>, "name": "warrantyfile.pdf", "_tags": ["test"], "_parents": [] };await IafScriptEngine.uploadFile(file, ctx);
 // Upload file with content typelet fileObj = fs.createReadStream(filePath);let file = { "fileObj": fileObj,  "name": "warrantyfile.pdf"}
let onSuccess = (fileSvcObj) =>  console.log('upload success');let headers = {"Content-Type":"application/pdf"}
IafScriptEngine.uploadFile(file, ctx, onSuccess, headers);

uploadJson#

Uploads a JSON file to the file service.

ParameterRequiredTypeDescription
reqYesJSONPass a JSON object with "data" and "filename" properties.
cNoCtxContext, such as namespaces and authentication token information.
Returns

Promise -

Examples
let req = {  "data": {    //<your json data>  }  "filename": "<your filename>""}; await IafScriptEngine.uploadJson(req);