1{
2 "namespace": "macroRecursion",
3
"definitions": [
4 {
5 "name": "deleteNodeAndDependencies",
6
"description": "Delete a node and its dependencies. Returns an array of json paths of all the nodes that were deleted.",
7
"parameters": [
8 "nodeName"
9 ],
10
"actions": [
11 {"action": "eval", "key": "fullNodePath", "value": "$.${p.nodeName}" },
12
{"action": "eval", "key": "dependencies", "value": "${macroRecursion:getDependents(p.nodeName)}"},
13
{
14 "action": "eval",
15
"value": "${array:forEach(Rules.Eval.dependencies, '${macroRecursion:deleteNodeAndDependencies(macroRecursion:deleteSingleNodeByFullJsonPath(var))}')}"
16 },
17
{
18 "action": "eval",
19
"value": "${macroRecursion:deleteSingleNodeByFullJsonPath(Rules.Eval.fullNodePath)}"
20 }
21 ]
22 },
23
{
24 "name": "deleteSingleNodeByFullJsonPath",
25
"description": "Deletes a node by full json path.",
26
"parameters": [
27 "fullJsonPath"
28 ],
29
"actions": [
30 {"action": "eval", "key": "pathSegments",
31 "value": "${string:match(p.fullJsonPath,'\\\\[\\'(.*?)\\'\\\\]')}"},
32
{ "action": "delete", "path": "${p.fullJsonPath}"}
33 ],
34
"returns": "${array:last(Rules.Eval.pathSegments)}"
35 },
36
{
37 "name": "getDependents",
38
"description": "Returns the full json path to search results",
39
"parameters": [
40 "nodeName"
41 ],
42
"actions": [
43 { "action": "eval", "key": "searchString", "value": "$.*[?(@.dependsOn=='${p.nodeName}')]"},
44
{ "action": "eval", "key": "paths", "value": "${json:searchPaths(Rules.Eval.searchString)}"}
45 ],
46
"returns": "${Rules.Eval.paths}"
47 }
48 ]
}