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,330 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/defs/common.schema.json",
4
+ "title": "OpenUISpec Common Definitions",
5
+ "description": "Shared type definitions used across OpenUISpec schemas",
6
+ "$defs": {
7
+ "icon_ref": {
8
+ "type": "string",
9
+ "description": "Reference to a named icon from the icon registry (e.g. 'checkmark_circle', 'folder_fill'). Resolved against icons.yaml registry with platform-specific mappings at generation time."
10
+ },
11
+ "color_ref": {
12
+ "type": "string",
13
+ "description": "Color reference \u2014 hex value (#RRGGBB) or token path (color.brand.primary)"
14
+ },
15
+ "token_ref": {
16
+ "type": "string",
17
+ "description": "Reference to a design token (e.g. 'spacing.md', 'typography.body')"
18
+ },
19
+ "media_ref": {
20
+ "type": "string",
21
+ "description": "Reference to a media asset or data path for images/avatars"
22
+ },
23
+ "screen_ref": {
24
+ "type": "string",
25
+ "description": "Reference to a screen (e.g. 'screens/home', 'screens/task_detail')"
26
+ },
27
+ "severity": {
28
+ "type": "string",
29
+ "enum": [
30
+ "info",
31
+ "success",
32
+ "warning",
33
+ "error",
34
+ "neutral"
35
+ ],
36
+ "description": "Severity level for badges, feedback, and status indicators"
37
+ },
38
+ "size_class": {
39
+ "type": "string",
40
+ "enum": [
41
+ "compact",
42
+ "regular",
43
+ "expanded"
44
+ ],
45
+ "description": "Responsive size class breakpoint"
46
+ },
47
+ "contract_family": {
48
+ "type": "string",
49
+ "enum": [
50
+ "action_trigger",
51
+ "data_display",
52
+ "input_field",
53
+ "nav_container",
54
+ "feedback",
55
+ "surface",
56
+ "collection"
57
+ ],
58
+ "description": "One of the 7 component contract families"
59
+ },
60
+ "contract_ref": {
61
+ "type": "string",
62
+ "description": "Built-in contract family or custom contract (x_ prefixed)"
63
+ },
64
+ "platform_target": {
65
+ "type": "string",
66
+ "enum": [
67
+ "ios",
68
+ "android",
69
+ "web"
70
+ ],
71
+ "description": "Target platform identifier"
72
+ },
73
+ "locale_ref": {
74
+ "type": "string",
75
+ "pattern": "^\\$t:",
76
+ "description": "Internationalization reference string (e.g. '$t:home.greeting')"
77
+ },
78
+ "string_or_locale": {
79
+ "description": "A plain string or a $t: locale reference",
80
+ "type": "string"
81
+ },
82
+ "badge_config": {
83
+ "type": "object",
84
+ "description": "Badge configuration for navigation items and indicators",
85
+ "properties": {
86
+ "text": {
87
+ "type": "string"
88
+ },
89
+ "count": {
90
+ "type": [
91
+ "string",
92
+ "integer"
93
+ ]
94
+ },
95
+ "dot": {
96
+ "type": "boolean"
97
+ },
98
+ "severity": {
99
+ "type": "string"
100
+ }
101
+ },
102
+ "additionalProperties": false
103
+ },
104
+ "range_object": {
105
+ "type": "object",
106
+ "description": "A base value with a constrained range",
107
+ "properties": {
108
+ "base": {
109
+ "type": "number"
110
+ },
111
+ "range": {
112
+ "type": "array",
113
+ "items": {
114
+ "type": "number"
115
+ },
116
+ "minItems": 2,
117
+ "maxItems": 2
118
+ }
119
+ },
120
+ "required": [
121
+ "base",
122
+ "range"
123
+ ],
124
+ "additionalProperties": false
125
+ },
126
+ "size_value": {
127
+ "description": "Either a fixed number or a base+range object",
128
+ "oneOf": [
129
+ {
130
+ "type": "number"
131
+ },
132
+ {
133
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/range_object"
134
+ }
135
+ ]
136
+ },
137
+ "hsl_range": {
138
+ "type": "object",
139
+ "description": "HSL color range constraints",
140
+ "properties": {
141
+ "hue": {
142
+ "type": "array",
143
+ "items": {
144
+ "type": "number"
145
+ },
146
+ "minItems": 2,
147
+ "maxItems": 2
148
+ },
149
+ "saturation": {
150
+ "type": "array",
151
+ "items": {
152
+ "type": "number"
153
+ },
154
+ "minItems": 2,
155
+ "maxItems": 2
156
+ },
157
+ "lightness": {
158
+ "type": "array",
159
+ "items": {
160
+ "type": "number"
161
+ },
162
+ "minItems": 2,
163
+ "maxItems": 2
164
+ }
165
+ },
166
+ "additionalProperties": false
167
+ },
168
+ "on_color": {
169
+ "type": "object",
170
+ "description": "Foreground color for use on top of a background color",
171
+ "properties": {
172
+ "reference": {
173
+ "type": "string"
174
+ },
175
+ "contrast_min": {
176
+ "type": "number"
177
+ }
178
+ },
179
+ "required": [
180
+ "reference"
181
+ ],
182
+ "additionalProperties": false
183
+ },
184
+ "icon_object": {
185
+ "type": "object",
186
+ "description": "Inline icon specification with optional styling",
187
+ "properties": {
188
+ "ref": {
189
+ "type": "string"
190
+ },
191
+ "icon": {
192
+ "type": "string"
193
+ },
194
+ "position": {
195
+ "type": "string",
196
+ "enum": [
197
+ "leading",
198
+ "trailing"
199
+ ]
200
+ },
201
+ "color": {
202
+ "type": "string"
203
+ },
204
+ "size": {
205
+ "type": "number"
206
+ },
207
+ "background": {
208
+ "type": "string"
209
+ },
210
+ "radius": {
211
+ "type": [
212
+ "string",
213
+ "number"
214
+ ]
215
+ },
216
+ "padding": {
217
+ "type": "string"
218
+ }
219
+ },
220
+ "additionalProperties": false
221
+ },
222
+ "leading_trailing": {
223
+ "description": "Leading or trailing content \u2014 can be an icon object, a media object, a nested contract, or a string",
224
+ "oneOf": [
225
+ {
226
+ "type": "string"
227
+ },
228
+ {
229
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/icon_object"
230
+ },
231
+ {
232
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/media_object"
233
+ },
234
+ {
235
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/nested_contract"
236
+ }
237
+ ]
238
+ },
239
+ "media_object": {
240
+ "type": "object",
241
+ "description": "Media content with fallback",
242
+ "properties": {
243
+ "media": {
244
+ "type": "string"
245
+ },
246
+ "fallback": {
247
+ "type": "object",
248
+ "properties": {
249
+ "initials": {
250
+ "type": "string"
251
+ },
252
+ "background": {
253
+ "type": "string"
254
+ }
255
+ },
256
+ "additionalProperties": false
257
+ },
258
+ "size": {
259
+ "type": "number"
260
+ },
261
+ "radius": {
262
+ "type": [
263
+ "string",
264
+ "number"
265
+ ]
266
+ }
267
+ },
268
+ "additionalProperties": false
269
+ },
270
+ "nested_contract": {
271
+ "type": "object",
272
+ "description": "An inline contract instance used in props (leading/trailing/content)",
273
+ "properties": {
274
+ "contract": {
275
+ "$ref": "https://openuispec.org/schema/defs/common.schema.json#/$defs/contract_ref"
276
+ },
277
+ "variant": {
278
+ "type": "string"
279
+ },
280
+ "input_type": {
281
+ "type": "string"
282
+ },
283
+ "props": {
284
+ "type": "object"
285
+ },
286
+ "action": {
287
+ "$ref": "https://openuispec.org/schema/defs/action.schema.json"
288
+ },
289
+ "data_binding": {
290
+ "type": "string"
291
+ },
292
+ "tokens_override": {
293
+ "type": "object"
294
+ },
295
+ "adaptive": {
296
+ "$ref": "https://openuispec.org/schema/defs/adaptive.schema.json"
297
+ },
298
+ "behavior": {
299
+ "type": "object"
300
+ }
301
+ },
302
+ "required": [
303
+ "contract",
304
+ "props"
305
+ ],
306
+ "additionalProperties": true
307
+ },
308
+ "tokens_override": {
309
+ "type": "object",
310
+ "description": "Token override map \u2014 keys are token names, values are token references or literal values",
311
+ "additionalProperties": true
312
+ },
313
+ "empty_state": {
314
+ "type": "object",
315
+ "description": "Empty state configuration for collections",
316
+ "properties": {
317
+ "icon": {
318
+ "type": "string"
319
+ },
320
+ "title": {
321
+ "type": "string"
322
+ },
323
+ "body": {
324
+ "type": "string"
325
+ }
326
+ },
327
+ "additionalProperties": false
328
+ }
329
+ }
330
+ }
@@ -0,0 +1,119 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/defs/data-binding.schema.json",
4
+ "title": "OpenUISpec Data Binding Definitions",
5
+ "description": "Data sources, state definitions, data paths, and format expressions",
6
+ "$defs": {
7
+ "data_source": {
8
+ "type": "object",
9
+ "description": "A data source definition with API endpoint and optional params",
10
+ "properties": {
11
+ "source": {
12
+ "type": "string",
13
+ "description": "API endpoint or data provider reference"
14
+ },
15
+ "params": {
16
+ "type": "object",
17
+ "additionalProperties": true
18
+ },
19
+ "refresh": {
20
+ "type": "object",
21
+ "properties": {
22
+ "interval": {
23
+ "type": "integer"
24
+ },
25
+ "on_focus": {
26
+ "type": "boolean"
27
+ }
28
+ },
29
+ "additionalProperties": true
30
+ },
31
+ "cache": {
32
+ "type": "object",
33
+ "properties": {
34
+ "ttl": {
35
+ "type": "integer"
36
+ },
37
+ "strategy": {
38
+ "type": "string"
39
+ }
40
+ },
41
+ "additionalProperties": true
42
+ }
43
+ },
44
+ "required": [
45
+ "source"
46
+ ],
47
+ "additionalProperties": true
48
+ },
49
+ "state_def": {
50
+ "type": "object",
51
+ "description": "Screen-level state variable definition",
52
+ "properties": {
53
+ "type": {
54
+ "type": "string",
55
+ "description": "State variable type (enum, string, bool, int, etc.)"
56
+ },
57
+ "values": {
58
+ "type": "array",
59
+ "items": {
60
+ "type": "string"
61
+ },
62
+ "description": "Allowed values for enum types"
63
+ },
64
+ "default": {
65
+ "description": "Default value for this state variable"
66
+ }
67
+ },
68
+ "required": [
69
+ "type",
70
+ "default"
71
+ ],
72
+ "additionalProperties": false
73
+ },
74
+ "data_map": {
75
+ "type": "object",
76
+ "description": "Map of named data sources",
77
+ "additionalProperties": {
78
+ "$ref": "https://openuispec.org/schema/defs/data-binding.schema.json#/$defs/data_source"
79
+ }
80
+ },
81
+ "state_map": {
82
+ "type": "object",
83
+ "description": "Map of named state definitions",
84
+ "additionalProperties": {
85
+ "$ref": "https://openuispec.org/schema/defs/data-binding.schema.json#/$defs/state_def"
86
+ }
87
+ },
88
+ "params_map": {
89
+ "type": "object",
90
+ "description": "Map of screen/flow parameter definitions",
91
+ "additionalProperties": {
92
+ "type": "object",
93
+ "properties": {
94
+ "type": {
95
+ "type": "string"
96
+ },
97
+ "required": {
98
+ "type": "boolean"
99
+ }
100
+ },
101
+ "required": [
102
+ "type"
103
+ ],
104
+ "additionalProperties": true
105
+ }
106
+ },
107
+ "t_params": {
108
+ "type": "object",
109
+ "description": "Translation parameter bindings \u2014 keys are param names, values are data paths",
110
+ "additionalProperties": {
111
+ "type": [
112
+ "string",
113
+ "number",
114
+ "boolean"
115
+ ]
116
+ }
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,121 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/defs/validation.schema.json",
4
+ "title": "OpenUISpec Validation",
5
+ "description": "Validation rule definitions for input_field contracts (Section 13)",
6
+
7
+ "$defs": {
8
+ "string_or_locale": {
9
+ "type": "string",
10
+ "description": "Plain text message or $t: locale reference"
11
+ },
12
+
13
+ "validate_trigger": {
14
+ "type": "string",
15
+ "enum": ["on_blur", "on_change", "on_submit"],
16
+ "description": "When to run validation: on_blur (default), on_change (every keystroke), on_submit (only on form submission)"
17
+ },
18
+
19
+ "validation_rules": {
20
+ "type": "object",
21
+ "description": "Co-located validation rules for an input_field instance",
22
+ "properties": {
23
+ "pattern": {
24
+ "type": "object",
25
+ "description": "Regex pattern validation",
26
+ "properties": {
27
+ "regex": { "type": "string" },
28
+ "message": { "$ref": "#/$defs/string_or_locale" }
29
+ },
30
+ "required": ["regex"],
31
+ "additionalProperties": false
32
+ },
33
+ "min_length": {
34
+ "type": "object",
35
+ "description": "Minimum string length",
36
+ "properties": {
37
+ "value": { "type": "integer", "minimum": 0 },
38
+ "message": { "$ref": "#/$defs/string_or_locale" }
39
+ },
40
+ "required": ["value"],
41
+ "additionalProperties": false
42
+ },
43
+ "max_length": {
44
+ "type": "object",
45
+ "description": "Maximum string length",
46
+ "properties": {
47
+ "value": { "type": "integer", "minimum": 0 },
48
+ "message": { "$ref": "#/$defs/string_or_locale" }
49
+ },
50
+ "required": ["value"],
51
+ "additionalProperties": false
52
+ },
53
+ "min": {
54
+ "type": "object",
55
+ "description": "Minimum numeric value",
56
+ "properties": {
57
+ "value": { "type": "number" },
58
+ "message": { "$ref": "#/$defs/string_or_locale" }
59
+ },
60
+ "required": ["value"],
61
+ "additionalProperties": false
62
+ },
63
+ "max": {
64
+ "type": "object",
65
+ "description": "Maximum numeric value",
66
+ "properties": {
67
+ "value": { "type": "number" },
68
+ "message": { "$ref": "#/$defs/string_or_locale" }
69
+ },
70
+ "required": ["value"],
71
+ "additionalProperties": false
72
+ },
73
+ "format": {
74
+ "type": "object",
75
+ "description": "Built-in format validation",
76
+ "properties": {
77
+ "type": {
78
+ "type": "string",
79
+ "enum": ["email", "url", "phone", "uuid"]
80
+ },
81
+ "message": { "$ref": "#/$defs/string_or_locale" }
82
+ },
83
+ "required": ["type"],
84
+ "additionalProperties": false
85
+ },
86
+ "match_field": {
87
+ "type": "object",
88
+ "description": "Cross-field equality check (e.g., password confirmation)",
89
+ "properties": {
90
+ "field": { "type": "string", "description": "data_binding path of the field to match" },
91
+ "message": { "$ref": "#/$defs/string_or_locale" }
92
+ },
93
+ "required": ["field"],
94
+ "additionalProperties": false
95
+ },
96
+ "custom": {
97
+ "type": "object",
98
+ "description": "Custom expression-based validation",
99
+ "properties": {
100
+ "expression": { "type": "string", "description": "Condition expression using the same grammar as condition (Section 5)" },
101
+ "message": { "$ref": "#/$defs/string_or_locale" }
102
+ },
103
+ "required": ["expression"],
104
+ "additionalProperties": false
105
+ },
106
+ "async": {
107
+ "type": "object",
108
+ "description": "Server-side async validation (e.g., username availability)",
109
+ "properties": {
110
+ "endpoint": { "type": "string", "description": "API endpoint reference (same format as api_call)" },
111
+ "debounce": { "type": "integer", "minimum": 0, "description": "Debounce in milliseconds (default: 300)" },
112
+ "message": { "$ref": "#/$defs/string_or_locale" }
113
+ },
114
+ "required": ["endpoint"],
115
+ "additionalProperties": false
116
+ }
117
+ },
118
+ "additionalProperties": false
119
+ }
120
+ }
121
+ }