1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"comment0": "Given a catalogConfig that tells the fields configured on a category.",
"comment1": "I want to invert it and figure out, for each field which categories use it.",
"input": {
"catalogConfig": {
"ROOT": {
"fields": {
"review": [
"Age",
"Gender",
"Quality"
],
"question" : [
"Gender"
]
}
},
"category7": {
"fields": {
"review": [
"Age",
"Quality"
]
}
},
"category8": {
"fields": {
"review": [
"Quality"
],
"question" : [
"Age"
]
}
}
}
},
"spec": {
"catalogConfig": {
"*": {
"fields": {
"*": {
"*" : {
// We need to match the leaf levels of the inputs, and then use the $ wildcard, to pull the key of our parent
"*" : {
"$(4)" : "&(1).&(3)[]" // trailing [] tells Shiftr to make an array, even if there is only one output
}
}
}
}
}
}
},
"expected" : {
"Age": {
"review" : [ "ROOT", "category7" ],
"question" : [ "category8" ]
},
"Gender": {
"review" : [ "ROOT" ], // the trailing [] in the spec, is why "ROOT" is in an array by itself
"question" : [ "ROOT" ]
},
"Quality": {
"review" : [ "ROOT", "category7", "category8" ]
}
}
}