openuispec 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/cli/index.ts +49 -0
  4. package/cli/init.ts +390 -0
  5. package/drift/index.ts +398 -0
  6. package/examples/taskflow/README.md +103 -0
  7. package/examples/taskflow/contracts/README.md +18 -0
  8. package/examples/taskflow/contracts/action_trigger.yaml +7 -0
  9. package/examples/taskflow/contracts/collection.yaml +7 -0
  10. package/examples/taskflow/contracts/data_display.yaml +7 -0
  11. package/examples/taskflow/contracts/feedback.yaml +7 -0
  12. package/examples/taskflow/contracts/input_field.yaml +7 -0
  13. package/examples/taskflow/contracts/nav_container.yaml +7 -0
  14. package/examples/taskflow/contracts/surface.yaml +7 -0
  15. package/examples/taskflow/contracts/x_media_player.yaml +185 -0
  16. package/examples/taskflow/flows/create_task.yaml +171 -0
  17. package/examples/taskflow/flows/edit_task.yaml +131 -0
  18. package/examples/taskflow/locales/en.json +158 -0
  19. package/examples/taskflow/openuispec.yaml +144 -0
  20. package/examples/taskflow/platform/android.yaml +32 -0
  21. package/examples/taskflow/platform/ios.yaml +39 -0
  22. package/examples/taskflow/platform/web.yaml +35 -0
  23. package/examples/taskflow/screens/calendar.yaml +23 -0
  24. package/examples/taskflow/screens/home.yaml +220 -0
  25. package/examples/taskflow/screens/profile_edit.yaml +70 -0
  26. package/examples/taskflow/screens/project_detail.yaml +65 -0
  27. package/examples/taskflow/screens/projects.yaml +142 -0
  28. package/examples/taskflow/screens/settings.yaml +178 -0
  29. package/examples/taskflow/screens/task_detail.yaml +317 -0
  30. package/examples/taskflow/tokens/color.yaml +88 -0
  31. package/examples/taskflow/tokens/elevation.yaml +27 -0
  32. package/examples/taskflow/tokens/icons.yaml +189 -0
  33. package/examples/taskflow/tokens/layout.yaml +156 -0
  34. package/examples/taskflow/tokens/motion.yaml +41 -0
  35. package/examples/taskflow/tokens/spacing.yaml +23 -0
  36. package/examples/taskflow/tokens/themes.yaml +34 -0
  37. package/examples/taskflow/tokens/typography.yaml +61 -0
  38. package/package.json +43 -0
  39. package/schema/custom-contract.schema.json +257 -0
  40. package/schema/defs/action.schema.json +272 -0
  41. package/schema/defs/adaptive.schema.json +13 -0
  42. package/schema/defs/common.schema.json +330 -0
  43. package/schema/defs/data-binding.schema.json +119 -0
  44. package/schema/defs/validation.schema.json +121 -0
  45. package/schema/flow.schema.json +164 -0
  46. package/schema/locale.schema.json +26 -0
  47. package/schema/openuispec.schema.json +287 -0
  48. package/schema/platform.schema.json +95 -0
  49. package/schema/screen.schema.json +346 -0
  50. package/schema/tokens/color.schema.json +104 -0
  51. package/schema/tokens/elevation.schema.json +84 -0
  52. package/schema/tokens/icons.schema.json +149 -0
  53. package/schema/tokens/layout.schema.json +170 -0
  54. package/schema/tokens/motion.schema.json +83 -0
  55. package/schema/tokens/spacing.schema.json +93 -0
  56. package/schema/tokens/themes.schema.json +92 -0
  57. package/schema/tokens/typography.schema.json +106 -0
  58. package/schema/validate.ts +258 -0
  59. package/spec/openuispec-v0.1.md +3677 -0
@@ -0,0 +1,346 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/screen.schema.json",
4
+ "title": "OpenUISpec Screen",
5
+ "description": "Screen composition \u2014 a single root key (screen name) mapping to the screen definition",
6
+ "type": "object",
7
+ "minProperties": 1,
8
+ "maxProperties": 1,
9
+ "additionalProperties": {
10
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/screen_def"
11
+ },
12
+ "$defs": {
13
+ "screen_def": {
14
+ "type": "object",
15
+ "description": "A screen definition with layout, data, state, navigation, and surfaces",
16
+ "properties": {
17
+ "semantic": {
18
+ "type": "string"
19
+ },
20
+ "status": {
21
+ "type": "string",
22
+ "enum": [
23
+ "stub",
24
+ "draft",
25
+ "ready"
26
+ ]
27
+ },
28
+ "params": {
29
+ "$ref": "https://openuispec.org/schema/defs/data-binding.schema.json#/$defs/params_map"
30
+ },
31
+ "data": {
32
+ "$ref": "https://openuispec.org/schema/defs/data-binding.schema.json#/$defs/data_map"
33
+ },
34
+ "state": {
35
+ "$ref": "https://openuispec.org/schema/defs/data-binding.schema.json#/$defs/state_map"
36
+ },
37
+ "navigation": {
38
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/navigation_def"
39
+ },
40
+ "layout": {
41
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/layout_def"
42
+ },
43
+ "surfaces": {
44
+ "type": "object",
45
+ "description": "Named surface definitions (sheets, modals, panels)",
46
+ "additionalProperties": {
47
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/surface_def"
48
+ }
49
+ }
50
+ },
51
+ "required": [
52
+ "semantic",
53
+ "layout"
54
+ ],
55
+ "additionalProperties": false
56
+ },
57
+ "navigation_def": {
58
+ "type": "object",
59
+ "description": "Navigation shell definition",
60
+ "properties": {
61
+ "contract": {
62
+ "const": "nav_container"
63
+ },
64
+ "variant": {
65
+ "type": "string"
66
+ },
67
+ "props": {
68
+ "type": "object",
69
+ "properties": {
70
+ "items": {
71
+ "type": "array",
72
+ "items": {
73
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/nav_item"
74
+ }
75
+ },
76
+ "selected": {
77
+ "type": "string"
78
+ }
79
+ },
80
+ "additionalProperties": true
81
+ },
82
+ "adaptive": {
83
+ "$ref": "https://openuispec.org/schema/defs/adaptive.schema.json"
84
+ }
85
+ },
86
+ "required": [
87
+ "contract",
88
+ "props"
89
+ ],
90
+ "additionalProperties": false
91
+ },
92
+ "nav_item": {
93
+ "type": "object",
94
+ "properties": {
95
+ "id": {
96
+ "type": "string"
97
+ },
98
+ "label": {
99
+ "type": "string"
100
+ },
101
+ "icon": {
102
+ "type": "string"
103
+ },
104
+ "icon_active": {
105
+ "type": "string"
106
+ },
107
+ "destination": {
108
+ "type": "string"
109
+ },
110
+ "badge": {
111
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/badge_config"
112
+ }
113
+ },
114
+ "required": [
115
+ "id",
116
+ "label",
117
+ "icon",
118
+ "destination"
119
+ ],
120
+ "additionalProperties": false
121
+ },
122
+ "layout_def": {
123
+ "type": "object",
124
+ "description": "Screen layout \u2014 either direct type or adaptive",
125
+ "properties": {
126
+ "type": {
127
+ "type": "string"
128
+ },
129
+ "adaptive": {
130
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/layout_adaptive"
131
+ },
132
+ "safe_area": {
133
+ "type": "boolean"
134
+ },
135
+ "padding": {
136
+ "type": "string"
137
+ },
138
+ "sections": {
139
+ "type": "array",
140
+ "items": {
141
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/section_item"
142
+ }
143
+ },
144
+ "on_submit": {
145
+ "$ref": "https://openuispec.org/schema/defs/action.schema.json"
146
+ }
147
+ },
148
+ "additionalProperties": true
149
+ },
150
+ "layout_adaptive": {
151
+ "type": "object",
152
+ "description": "Adaptive layout configuration per size class",
153
+ "properties": {
154
+ "compact": {
155
+ "type": "object",
156
+ "additionalProperties": true
157
+ },
158
+ "regular": {
159
+ "type": "object",
160
+ "additionalProperties": true
161
+ },
162
+ "expanded": {
163
+ "type": "object",
164
+ "additionalProperties": true
165
+ }
166
+ },
167
+ "additionalProperties": false
168
+ },
169
+ "section_item": {
170
+ "description": "A section item \u2014 either a contract instance or a section group with children",
171
+ "type": "object",
172
+ "properties": {
173
+ "id": {
174
+ "type": "string"
175
+ },
176
+ "contract": {
177
+ "type": "string"
178
+ },
179
+ "variant": {
180
+ "type": "string"
181
+ },
182
+ "input_type": {
183
+ "type": "string"
184
+ },
185
+ "size": {
186
+ "type": "string"
187
+ },
188
+ "interactive": {
189
+ "type": "boolean"
190
+ },
191
+ "full_width": {
192
+ "type": "boolean"
193
+ },
194
+ "props": {
195
+ "type": "object",
196
+ "additionalProperties": true
197
+ },
198
+ "action": {
199
+ "$ref": "https://openuispec.org/schema/defs/action.schema.json"
200
+ },
201
+ "tokens_override": {
202
+ "type": "object",
203
+ "additionalProperties": true
204
+ },
205
+ "adaptive": {
206
+ "$ref": "https://openuispec.org/schema/defs/adaptive.schema.json"
207
+ },
208
+ "condition": {
209
+ "type": "string"
210
+ },
211
+ "position": {
212
+ "type": "string"
213
+ },
214
+ "data_binding": {
215
+ "type": "string"
216
+ },
217
+ "state_binding": {
218
+ "type": "object",
219
+ "additionalProperties": true
220
+ },
221
+ "form_id": {
222
+ "type": "string"
223
+ },
224
+ "t_params": {
225
+ "type": "object",
226
+ "additionalProperties": true
227
+ },
228
+ "behavior": {
229
+ "type": "object",
230
+ "additionalProperties": true
231
+ },
232
+ "validate": {
233
+ "$ref": "https://openuispec.org/schema/defs/validation.schema.json#/$defs/validation_rules"
234
+ },
235
+ "required_when": {
236
+ "type": "string",
237
+ "description": "Condition expression — field becomes required when true"
238
+ },
239
+ "enabled_when": {
240
+ "type": "string",
241
+ "description": "Condition expression — field is enabled (editable) when true"
242
+ },
243
+ "validate_trigger": {
244
+ "$ref": "https://openuispec.org/schema/defs/validation.schema.json#/$defs/validate_trigger"
245
+ },
246
+ "layout": {
247
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/inline_layout"
248
+ },
249
+ "children": {
250
+ "type": "array",
251
+ "items": {
252
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/section_item"
253
+ }
254
+ },
255
+ "padding": {
256
+ "type": "string"
257
+ },
258
+ "padding_h": {
259
+ "type": "string"
260
+ },
261
+ "padding_v": {
262
+ "type": "string"
263
+ },
264
+ "margin_top": {
265
+ "type": "string"
266
+ },
267
+ "max_width": {
268
+ "type": "integer"
269
+ }
270
+ },
271
+ "additionalProperties": true
272
+ },
273
+ "inline_layout": {
274
+ "type": "object",
275
+ "description": "Inline layout specification for section groups",
276
+ "properties": {
277
+ "type": {
278
+ "type": "string"
279
+ },
280
+ "adaptive": {
281
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/layout_adaptive"
282
+ },
283
+ "spacing": {
284
+ "type": "string"
285
+ },
286
+ "align": {
287
+ "type": "string"
288
+ },
289
+ "justify": {
290
+ "type": "string"
291
+ },
292
+ "wrap": {
293
+ "type": "boolean"
294
+ },
295
+ "columns": {
296
+ "type": [
297
+ "integer",
298
+ "object"
299
+ ]
300
+ },
301
+ "gap": {
302
+ "type": "string"
303
+ }
304
+ },
305
+ "additionalProperties": true
306
+ },
307
+ "surface_def": {
308
+ "type": "object",
309
+ "description": "A named surface (sheet, modal, panel)",
310
+ "properties": {
311
+ "contract": {
312
+ "const": "surface"
313
+ },
314
+ "variant": {
315
+ "type": "string"
316
+ },
317
+ "props": {
318
+ "type": "object",
319
+ "properties": {
320
+ "title": {
321
+ "type": "string"
322
+ },
323
+ "size": {
324
+ "type": "string"
325
+ },
326
+ "content": {
327
+ "type": "array",
328
+ "items": {
329
+ "$ref": "https://openuispec.org/schema/screen.schema.json#/$defs/section_item"
330
+ }
331
+ }
332
+ },
333
+ "additionalProperties": true
334
+ },
335
+ "adaptive": {
336
+ "$ref": "https://openuispec.org/schema/defs/adaptive.schema.json"
337
+ }
338
+ },
339
+ "required": [
340
+ "contract",
341
+ "props"
342
+ ],
343
+ "additionalProperties": false
344
+ }
345
+ }
346
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/tokens/color.schema.json",
4
+ "title": "OpenUISpec Color Tokens",
5
+ "description": "Color token definitions: brand, surface, text, semantic, border, and custom groups",
6
+ "type": "object",
7
+ "required": [
8
+ "color"
9
+ ],
10
+ "additionalProperties": false,
11
+ "properties": {
12
+ "color": {
13
+ "type": "object",
14
+ "properties": {
15
+ "brand": {
16
+ "type": "object",
17
+ "description": "Brand identity colors",
18
+ "additionalProperties": {
19
+ "$ref": "https://openuispec.org/schema/tokens/color.schema.json#/$defs/color_entry"
20
+ }
21
+ },
22
+ "surface": {
23
+ "type": "object",
24
+ "description": "Background/surface colors",
25
+ "additionalProperties": {
26
+ "$ref": "https://openuispec.org/schema/tokens/color.schema.json#/$defs/color_entry"
27
+ }
28
+ },
29
+ "text": {
30
+ "type": "object",
31
+ "description": "Text and foreground colors",
32
+ "additionalProperties": {
33
+ "$ref": "https://openuispec.org/schema/tokens/color.schema.json#/$defs/color_entry"
34
+ }
35
+ },
36
+ "semantic": {
37
+ "type": "object",
38
+ "description": "Semantic status colors (success, warning, danger, info)",
39
+ "additionalProperties": {
40
+ "$ref": "https://openuispec.org/schema/tokens/color.schema.json#/$defs/color_entry"
41
+ }
42
+ },
43
+ "border": {
44
+ "type": "object",
45
+ "description": "Border colors",
46
+ "additionalProperties": {
47
+ "$ref": "https://openuispec.org/schema/tokens/color.schema.json#/$defs/border_color_entry"
48
+ }
49
+ }
50
+ },
51
+ "additionalProperties": {
52
+ "type": "object",
53
+ "description": "Custom color group",
54
+ "additionalProperties": {
55
+ "$ref": "https://openuispec.org/schema/tokens/color.schema.json#/$defs/color_entry"
56
+ }
57
+ }
58
+ }
59
+ },
60
+ "$defs": {
61
+ "color_entry": {
62
+ "type": "object",
63
+ "properties": {
64
+ "semantic": {
65
+ "type": "string"
66
+ },
67
+ "reference": {
68
+ "type": "string"
69
+ },
70
+ "range": {
71
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/hsl_range"
72
+ },
73
+ "on_color": {
74
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/on_color"
75
+ },
76
+ "contrast_min": {
77
+ "type": "number"
78
+ }
79
+ },
80
+ "required": [
81
+ "reference"
82
+ ],
83
+ "additionalProperties": false
84
+ },
85
+ "border_color_entry": {
86
+ "type": "object",
87
+ "properties": {
88
+ "semantic": {
89
+ "type": "string"
90
+ },
91
+ "reference": {
92
+ "type": "string"
93
+ },
94
+ "opacity": {
95
+ "type": "number"
96
+ }
97
+ },
98
+ "required": [
99
+ "reference"
100
+ ],
101
+ "additionalProperties": false
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,84 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/tokens/elevation.schema.json",
4
+ "title": "OpenUISpec Elevation Tokens",
5
+ "description": "Elevation/shadow definitions with per-platform values",
6
+ "type": "object",
7
+ "required": [
8
+ "elevation"
9
+ ],
10
+ "additionalProperties": false,
11
+ "properties": {
12
+ "elevation": {
13
+ "type": "object",
14
+ "additionalProperties": {
15
+ "$ref": "https://openuispec.org/schema/tokens/elevation.schema.json#/$defs/elevation_entry"
16
+ }
17
+ }
18
+ },
19
+ "$defs": {
20
+ "elevation_entry": {
21
+ "type": "object",
22
+ "properties": {
23
+ "semantic": {
24
+ "type": "string"
25
+ },
26
+ "value": {
27
+ "type": "string"
28
+ },
29
+ "platform": {
30
+ "type": "object",
31
+ "properties": {
32
+ "ios": {
33
+ "type": "object",
34
+ "properties": {
35
+ "shadow": {
36
+ "type": "object",
37
+ "properties": {
38
+ "color": {
39
+ "type": "string"
40
+ },
41
+ "opacity": {
42
+ "type": "number"
43
+ },
44
+ "radius": {
45
+ "type": "number"
46
+ },
47
+ "x": {
48
+ "type": "number"
49
+ },
50
+ "y": {
51
+ "type": "number"
52
+ }
53
+ },
54
+ "additionalProperties": false
55
+ }
56
+ },
57
+ "additionalProperties": false
58
+ },
59
+ "android": {
60
+ "type": "object",
61
+ "properties": {
62
+ "elevation": {
63
+ "type": "number"
64
+ }
65
+ },
66
+ "additionalProperties": false
67
+ },
68
+ "web": {
69
+ "type": "object",
70
+ "properties": {
71
+ "box_shadow": {
72
+ "type": "string"
73
+ }
74
+ },
75
+ "additionalProperties": false
76
+ }
77
+ },
78
+ "additionalProperties": false
79
+ }
80
+ },
81
+ "additionalProperties": false
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,149 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/tokens/icons.schema.json",
4
+ "title": "OpenUISpec Icon Tokens",
5
+ "description": "Semantic icon registry with platform mappings, sizes, and variant conventions",
6
+ "type": "object",
7
+ "required": [
8
+ "icons"
9
+ ],
10
+ "additionalProperties": false,
11
+ "properties": {
12
+ "icons": {
13
+ "type": "object",
14
+ "properties": {
15
+ "sizes": {
16
+ "type": "object",
17
+ "description": "Named sizing scale for icons",
18
+ "additionalProperties": {
19
+ "$ref": "#/$defs/size_entry"
20
+ }
21
+ },
22
+ "variants": {
23
+ "$ref": "#/$defs/variant_config"
24
+ },
25
+ "fallback": {
26
+ "$ref": "#/$defs/fallback_config"
27
+ },
28
+ "registry": {
29
+ "type": "object",
30
+ "description": "Canonical icon set grouped by category",
31
+ "additionalProperties": {
32
+ "type": "object",
33
+ "additionalProperties": {
34
+ "$ref": "#/$defs/icon_entry"
35
+ }
36
+ }
37
+ },
38
+ "custom": {
39
+ "type": "object",
40
+ "description": "App-specific icon entries following the same shape as registry categories",
41
+ "additionalProperties": {
42
+ "type": "object",
43
+ "additionalProperties": {
44
+ "$ref": "#/$defs/icon_entry"
45
+ }
46
+ }
47
+ }
48
+ },
49
+ "additionalProperties": false
50
+ }
51
+ },
52
+ "$defs": {
53
+ "size_entry": {
54
+ "type": "object",
55
+ "properties": {
56
+ "semantic": {
57
+ "type": "string"
58
+ },
59
+ "value": {
60
+ "type": "number"
61
+ }
62
+ },
63
+ "required": [
64
+ "semantic",
65
+ "value"
66
+ ],
67
+ "additionalProperties": false
68
+ },
69
+ "variant_config": {
70
+ "type": "object",
71
+ "description": "Icon variant conventions",
72
+ "properties": {
73
+ "default": {
74
+ "type": "string",
75
+ "description": "Default variant style when no suffix is present"
76
+ },
77
+ "suffixes": {
78
+ "type": "object",
79
+ "description": "Suffix conventions for icon style variants",
80
+ "additionalProperties": {
81
+ "type": "string"
82
+ }
83
+ }
84
+ },
85
+ "additionalProperties": false
86
+ },
87
+ "fallback_config": {
88
+ "type": "object",
89
+ "description": "Strategy for icons not found in the registry",
90
+ "properties": {
91
+ "strategy": {
92
+ "type": "string",
93
+ "enum": [
94
+ "name_passthrough",
95
+ "error"
96
+ ],
97
+ "description": "name_passthrough: pass unknown icon names directly to the native API. error: fail if icon is not in the registry."
98
+ },
99
+ "missing_icon": {
100
+ "type": "string",
101
+ "description": "Fallback icon to display when an icon cannot be resolved"
102
+ }
103
+ },
104
+ "required": [
105
+ "strategy"
106
+ ],
107
+ "additionalProperties": false
108
+ },
109
+ "icon_entry": {
110
+ "type": "object",
111
+ "properties": {
112
+ "semantic": {
113
+ "type": "string",
114
+ "description": "Human-readable description of what this icon represents"
115
+ },
116
+ "variants": {
117
+ "type": "array",
118
+ "items": {
119
+ "type": "string"
120
+ },
121
+ "description": "Available variant suffixes for this icon (e.g. ['fill'])"
122
+ },
123
+ "platform": {
124
+ "type": "object",
125
+ "properties": {
126
+ "ios": {
127
+ "type": "string",
128
+ "description": "SF Symbols name (dot-notation)"
129
+ },
130
+ "android": {
131
+ "type": "string",
132
+ "description": "Material Icons name"
133
+ },
134
+ "web": {
135
+ "type": "string",
136
+ "description": "Web icon library name (e.g. Lucide, Heroicons)"
137
+ }
138
+ },
139
+ "additionalProperties": false
140
+ }
141
+ },
142
+ "required": [
143
+ "semantic",
144
+ "platform"
145
+ ],
146
+ "additionalProperties": false
147
+ }
148
+ }
149
+ }