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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
Resolve a path from a content: each segment is the name of a reference field,
and the result is the target of the last segment.
$ tests --path legalEntity entity.employee.country <<EOF
> {
> "list": [
> {
> "id": "region_list",
> "field": [ { "name": "label", "label": {}, "type": "text" } ]
> },
> {
> "id": "country_list",
> "field": [
> { "name": "code", "label": {}, "type": "text" },
> {
> "name": "region",
> "label": {},
> "type": { "content": "region_list" }
> }
> ]
> }
> ],
> "content": [
> {
> "id": "legalEntity",
> "section": [
> {
> "field": [
> {
> "name": "entity",
> "label": {},
> "type": { "content": "entity" }
> }
> ]
> }
> ]
> },
> {
> "id": "entity",
> "section": [
> {
> "field": [
> {
> "name": "employee",
> "label": {},
> "type": { "content": "employee" }
> }
> ]
> }
> ]
> },
> {
> "id": "employee",
> "section": [
> {
> "field": [
> { "name": "name", "label": {}, "type": "text" },
> {
> "name": "country",
> "label": {},
> "type": { "content": "country_list" }
> }
> ]
> }
> ]
> }
> ]
> }
> EOF
field country (reference -> list country_list)
Intermediate segments resolve to the targeted content:
$ tests --path legalEntity entity <<EOF
> {
> "content": [
> {
> "id": "legalEntity",
> "section": [
> {
> "field": [
> { "name": "entity", "label": {}, "type": { "content": "entity" } }
> ]
> }
> ]
> },
> { "id": "entity" }
> ]
> }
> EOF
field entity (reference -> content entity)
The path can go through the fields of a list:
$ tests --path legalEntity entity.employee.country.region <<EOF
> {
> "list": [
> { "id": "region_list" },
> {
> "id": "country_list",
> "field": [
> { "name": "region", "label": {}, "type": { "content": "region_list" } }
> ]
> }
> ],
> "content": [
> {
> "id": "legalEntity",
> "section": [ { "field": [
> { "name": "entity", "label": {}, "type": { "content": "entity" } }
> ] } ]
> },
> {
> "id": "entity",
> "section": [ { "field": [
> { "name": "employee", "label": {}, "type": { "content": "employee" } }
> ] } ]
> },
> {
> "id": "employee",
> "section": [ { "field": [
> { "name": "country", "label": {}, "type": { "content": "country_list" } }
> ] } ]
> }
> ]
> }
> EOF
field region (reference -> list region_list)
A segment that is not a reference field, or does not exist, does not resolve:
$ tests --path legalEntity entity.employee.name <<EOF
> {
> "content": [
> {
> "id": "legalEntity",
> "section": [ { "field": [
> { "name": "entity", "label": {}, "type": { "content": "entity" } }
> ] } ]
> },
> {
> "id": "entity",
> "section": [ { "field": [
> { "name": "employee", "label": {}, "type": { "content": "employee" } }
> ] } ]
> },
> {
> "id": "employee",
> "section": [ { "field": [
> { "name": "name", "label": {}, "type": "text" }
> ] } ]
> }
> ]
> }
> EOF
field name (text)
$ tests --path legalEntity unknown.path <<EOF
> { "content": [ { "id": "legalEntity" } ] }
> EOF
unresolved path unknown.path
|