Skip to content

Commit ea855b5

Browse files
committed
Omit empty action lists, maps and sets from JSON
The defaults builder now also reads defaults written as `field = param ?? <constant>` in the constructor's initializer list, the pattern most actions and conditions use. json_serializable passes null for a missing key there, so fromJson restores the same value. Only literals, const constructors and const variables count: a getter such as `PaintModel.blackPaint` makes a new id on every call. An empty Set default (`const {}`) was copied into the generated check as a Map literal and never matched; it is now compared as a Set. Newly left out when empty: ConditionalAction actions/elseActions, ForEachAction and CloudFilesAction actions, ApiCallAction parameters, CallFunctionAction params, ElseCondition actions, ConditionGroup elseIfConditions, VariableData extra, TextFieldProperties autofillHints, and VarianceNode properties. codelessly_api 5.2.0 and 5.3.0 read the shorter JSON back to equal objects. Tests round-trip a node of every registered type, and read the JSON 5.3.0 wrote for these models (test/fixtures/omitted_defaults_5_3_0.json). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YaHo5D7kD3eWcagvzh3o3K
1 parent 1de45ee commit ea855b5

12 files changed

Lines changed: 645 additions & 3 deletions

‎lib/src/api/models/action/api_call_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/call_function_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/cloud_files_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/conditional_action.g.dart‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/for_each_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/condition.g.dart‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/variables_model.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/nodes/text_field_node.g.dart‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/nodes/variance_node.g.dart‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
{
2+
"ConditionalAction": {
3+
"type": "conditional",
4+
"expression": {
5+
"leftPart": {
6+
"valueString": "${a}",
7+
"type": "Variable"
8+
},
9+
"rightPart": {
10+
"value": "1",
11+
"type": "RawValue"
12+
},
13+
"operator": "equalsTo",
14+
"type": "Expression"
15+
},
16+
"actions": [],
17+
"elseActions": []
18+
},
19+
"ConditionalActionNested": {
20+
"type": "conditional",
21+
"expression": {
22+
"leftPart": {
23+
"valueString": "${a}",
24+
"type": "Variable"
25+
},
26+
"rightPart": {
27+
"value": "1",
28+
"type": "RawValue"
29+
},
30+
"operator": "equalsTo",
31+
"type": "Expression"
32+
},
33+
"actions": [
34+
{
35+
"type": "forEach",
36+
"items": "${list}",
37+
"actions": []
38+
}
39+
],
40+
"elseActions": [
41+
{
42+
"type": "callFunction",
43+
"name": "f",
44+
"params": {}
45+
}
46+
]
47+
},
48+
"ForEachAction": {
49+
"type": "forEach",
50+
"items": "${list}",
51+
"actions": []
52+
},
53+
"CloudFilesAction": {
54+
"type": "cloudFiles",
55+
"actions": []
56+
},
57+
"ApiCallAction": {
58+
"type": "callApi",
59+
"apiId": "api",
60+
"parameters": {}
61+
},
62+
"CallFunctionAction": {
63+
"type": "callFunction",
64+
"name": "f",
65+
"params": {}
66+
},
67+
"VariableData": {
68+
"id": "v",
69+
"name": "count",
70+
"value": "1",
71+
"extra": {}
72+
},
73+
"ElseCondition": {
74+
"id": "e",
75+
"lastUpdated": 1767225600000,
76+
"actions": [],
77+
"type": "ElseCondition"
78+
},
79+
"ConditionGroup": {
80+
"id": "g",
81+
"lastUpdated": 1767225600000,
82+
"ifCondition": {
83+
"id": "c",
84+
"lastUpdated": 1767225600000,
85+
"expression": {
86+
"leftPart": {
87+
"valueString": "${a}",
88+
"type": "Variable"
89+
},
90+
"rightPart": {
91+
"value": "1",
92+
"type": "RawValue"
93+
},
94+
"operator": "equalsTo",
95+
"type": "Expression"
96+
},
97+
"actions": [],
98+
"mode": "ifMode",
99+
"type": "Condition"
100+
},
101+
"elseIfConditions": [],
102+
"type": "ConditionGroup"
103+
},
104+
"VarianceNode": {
105+
"id": "var",
106+
"name": "Variance",
107+
"basicBoxLocal": [
108+
0,
109+
0,
110+
10,
111+
10
112+
],
113+
"allowedTypes": [],
114+
"deniedTypes": [],
115+
"type": "variance",
116+
"currentVariantId": "v1",
117+
"variants": [
118+
{
119+
"name": "A",
120+
"id": "v1",
121+
"children": []
122+
}
123+
],
124+
"properties": {}
125+
},
126+
"FrameWithReactions": {
127+
"id": "f",
128+
"name": "F",
129+
"reactions": [
130+
{
131+
"name": "tap",
132+
"action": {
133+
"type": "conditional",
134+
"expression": {
135+
"leftPart": {
136+
"valueString": "${a}",
137+
"type": "Variable"
138+
},
139+
"rightPart": {
140+
"value": "1",
141+
"type": "RawValue"
142+
},
143+
"operator": "equalsTo",
144+
"type": "Expression"
145+
},
146+
"actions": [
147+
{
148+
"type": "cloudFiles",
149+
"actions": []
150+
},
151+
{
152+
"type": "callApi",
153+
"apiId": "a",
154+
"parameters": {}
155+
}
156+
],
157+
"elseActions": []
158+
},
159+
"trigger": {
160+
"type": "click"
161+
},
162+
"id": "r1"
163+
}
164+
],
165+
"basicBoxLocal": [
166+
0,
167+
0,
168+
10,
169+
10
170+
],
171+
"type": "frame"
172+
}
173+
}

0 commit comments

Comments
 (0)