Skip to main content

buildPolicyTree

@totemsdk/recursive-mast


@totemsdk/recursive-mast / buildPolicyTree

Function: buildPolicyTree()

buildPolicyTree(nodes): PolicyTree

Build a policy tree from a flat list of nodes. Nodes reference parents by parentId. The root is the node with no parent.

Parameters

nodes

PolicyNodeInput[]

Returns

PolicyTree

Example

const tree = buildPolicyTree([
{ id: 'root', name: 'National', script: 'RETURN TRUE' },
{ id: 'regional', name: 'Regional', script: 'ASSERT SIGNEDBY(STATE(0)) RETURN TRUE', parentId: 'root' },
{ id: 'local', name: 'Local', script: 'ASSERT SIGNEDBY(PREVSTATE(0)) RETURN TRUE', parentId: 'regional' },
]);