Infohub JS API
Loading...
Searching...
No Matches
NodeServices Class Reference

Description

Node Services to get/write objects as tree, etc.

Public Member Functions

 constructor (ctx)
async createChild (parent_node_sid, nodeData)
async getChildren (node_sid, options={})
async getDocument (node_sid, query, cb)
async getNodeData (node_sid, query, cb)
async getNodePath (node_sid, query, cb)
async getTree (node_sid, params, cb)
async patchTree (parentnode_sid, node_tree, cb)
async postTree (parentnode_sid, node_tree, cb)
async putTree (parentnode_sid, node_tree, cb)
async saveTree (parentnode_sid, node_tree, cb)
async updateTree (parentnode_sid, node_tree, cb)

Function Documentation

◆ constructor()

constructor ( ctx)
Since
1.0, 09.2025, jh
Parameters
{Context}ctx - Context instance

◆ createChild()

async createChild ( parent_node_sid,
nodeData )

Create a new child node under a parent node.

Parameters
{string}parent_node_sid - Parent node short ID
{object}nodeData - Node data to create
Returns
{Promise<ApiResponse>} Promise resolving to ApiResponse with created node data

Example

// Create a coordination model under a container
const result = await nodeServices.createChild('container_sid', {
object_name: 'New Model',
object_type: 'all_container##CM_FEDERATION',
// ... other properties
});

◆ getChildren()

async getChildren ( node_sid,
options = {} )

Get children of a node with optional filters.

Parameters
{string}node_sid - Parent node short ID
{object}options - Query options
{string}[options.filter] - Filter expression (e.g., "$object_type ~eq~ 'cn_federatedmodels'")
{string|string[]}[options.members] - Members to include (e.g., 'info' or ['info', 'properties'])
{string|string[]}[options.properties] - Properties to include
{number}[options.depth] - Tree depth to retrieve (0 = direct children only)
{string}[options.sortby] - Sort expression
{number}[options.limit] - Limit number of results
{number}[options.offset] - Offset for pagination
Returns
{Promise<ApiResponse>} Promise resolving to ApiResponse with array of child nodes

Example:

// Get children with filter
const result = await nodeServices.getChildren('proj_123', {
filter: "$object_type ~eq~ 'cn_federatedmodels'",
members: 'info',
depth: 0
});

◆ getDocument()

async getDocument ( node_sid,
query,
cb )
Parameters
{*}node_sid
{object}query = { "as_blob" : true download as file, false if the document should be loaded as json
}
{*}cb data = { "doc" : json or blob
}
Since
15.09.2026 RM - Updated XMLHttpRequest call to makeApiCall for compatibility.

◆ getNodeData()

async getNodeData ( node_sid,
query,
cb )
Parameters
{*}node_sid
{*}query { 'members' : [ 'info' , 'properties' ] }
{*}cb
Returns
{Promise<RestResponse>}

◆ getNodePath()

async getNodePath ( node_sid,
query,
cb )

Get path of node hierarchy from root to node.

Parameters
{*}node_sid Get path from this node to root
{*}query = { 'members' : [ 'info' , 'properties' , ] }
{*}cb
Returns
{Promise<ApiResponse>} Array of cnObjects from root to node_sid

Example:

...

◆ getTree()

async getTree ( node_sid,
params,
cb )
Parameters
{string}node_sid
{object}params = { 'depth' 'members' 'properties' 'geometry' 'filter' 'nodes' 'relations' 'relations_right' 'groupby' 'sortby' 'limit' 'offset' } each parameter has to be encoded as URI component

Example:

{
'members': ['info', 'properties', 'relations', 'relations_right'],
'filter': '$object_type ~eq~ \'act_issue\'',
'depth': 0,
'sortby': 'issue:wbs##xs:string',
'relations_right': JSON.stringify({
'members': ['info', 'properties'],
'filter': '$name ~eq~ \'cnSUCCESSORS\'',
}),
}
}
Parameters
{function}cb

◆ patchTree()

async patchTree ( parentnode_sid,
node_tree,
cb )

Partially updates a node tree below a parent node.

Sends the supplied tree changes to PATCH /{scope}/nodes/{parentnode_sid}/tree and passes the resulting REST response to the callback.

Parameters
parentnode_sid- Short ID of the parent node.
node_tree- Node tree changes to apply below the parent node.
cb- Callback that receives a RestResponse.
Returns
{Promise<*>} A promise resolving to the callback's return value.

◆ postTree()

async postTree ( parentnode_sid,
node_tree,
cb )

Creates a node tree below a parent node using the infohub v2 API.

Sends the supplied tree to POST /{scope}/v2/nodes/{parentnode_sid}/tree and passes the resulting REST response to the callback.

Parameters
parentnode_sid- Short ID of the parent node.
node_tree- Node tree to create below the parent node.
cb- Callback that receives a RestResponse.
Returns
{Promise<*>} A promise resolving to the callback's return value.

◆ putTree()

async putTree ( parentnode_sid,
node_tree,
cb )

Writes a node tree below a parent node using the infohub v2 API.

Sends the supplied tree to PUT /{scope}/v2/nodes/{parentnode_sid}/tree and passes the resulting REST response to the callback.

Parameters
parentnode_sid- Short ID of the parent node.
node_tree- Node tree to write below the parent node.
cb- Callback that receives a RestResponse.
Returns
{Promise<*>} A promise resolving to the callback's return value.

◆ saveTree()

async saveTree ( parentnode_sid,
node_tree,
cb )

Update/create node tree.

Replace existing nodes in 'parentnode_sid', if existing nodes are deleted if not in 'node_tree'

POST /{scope}/nodes/{node}/tree

Parameters
{*}parentnode_sid
{*}node_tree
{*}cb

◆ updateTree()

async updateTree ( parentnode_sid,
node_tree,
cb )

Update node tree.

Keep existing nodes in parentnode_sid

PUT /{scope}/nodes/{node}/tree

Parameters
{*}parentnode_sid
{*}node_tree
{*}cb