@ouispec/contract 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 (48) hide show
  1. package/INTEGRATOR-GUIDE.md +729 -0
  2. package/LICENSE +21 -0
  3. package/README.md +10 -0
  4. package/dist/codegen.d.ts +71 -0
  5. package/dist/codegen.d.ts.map +1 -0
  6. package/dist/codegen.js +195 -0
  7. package/dist/codegen.js.map +1 -0
  8. package/dist/generated/contract.d.ts +1286 -0
  9. package/dist/generated/contract.d.ts.map +1 -0
  10. package/dist/generated/contract.js +14 -0
  11. package/dist/generated/contract.js.map +1 -0
  12. package/dist/generated/schemas.d.ts +111 -0
  13. package/dist/generated/schemas.d.ts.map +1 -0
  14. package/dist/generated/schemas.js +3256 -0
  15. package/dist/generated/schemas.js.map +1 -0
  16. package/dist/index.d.ts +29 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +28 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/render-contract.d.ts +47 -0
  21. package/dist/render-contract.d.ts.map +1 -0
  22. package/dist/render-contract.js +123 -0
  23. package/dist/render-contract.js.map +1 -0
  24. package/dist/render-guide.d.ts +4 -0
  25. package/dist/render-guide.d.ts.map +1 -0
  26. package/dist/render-guide.js +132 -0
  27. package/dist/render-guide.js.map +1 -0
  28. package/dist/schema-document.d.ts +7 -0
  29. package/dist/schema-document.d.ts.map +1 -0
  30. package/dist/schema-document.js +2 -0
  31. package/dist/schema-document.js.map +1 -0
  32. package/dist/validate.d.ts +22 -0
  33. package/dist/validate.d.ts.map +1 -0
  34. package/dist/validate.js +89 -0
  35. package/dist/validate.js.map +1 -0
  36. package/package.json +65 -0
  37. package/schemas/action-effect.json +113 -0
  38. package/schemas/agent-binding.json +58 -0
  39. package/schemas/approvals.json +249 -0
  40. package/schemas/control-kind-registration.json +187 -0
  41. package/schemas/control-table.json +276 -0
  42. package/schemas/event-declarations.json +316 -0
  43. package/schemas/generated-knowledge.json +58 -0
  44. package/schemas/json-schema.json +153 -0
  45. package/schemas/oui-config.json +178 -0
  46. package/schemas/oui-manifest.json +346 -0
  47. package/schemas/room-catalog-data.json +455 -0
  48. package/schemas/tier2-mapping.json +195 -0
@@ -0,0 +1,187 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.closurestudio.ai/oui/v1/control-kind-registration.json",
4
+ "title": "ControlKindRegistration",
5
+ "description": "A control kind a design system adds (ADR-0226 §2.6). `ControlKind` is closed: a design system adds a kind only by registering it, under an `x-` name. The registration ships in the design system's control table (`$kinds`), where the generator reads it, and the design system registers it at run time with `registerControlKind`, so the browser and the generator derive the same schema.",
6
+ "type": "object",
7
+ "properties": {
8
+ "kind": {
9
+ "$ref": "#/$defs/RegisteredControlKind"
10
+ },
11
+ "verb": {
12
+ "description": "What using it does, as a tool description starts: \"Set the price range of\".",
13
+ "type": "string",
14
+ "minLength": 1,
15
+ "pattern": "\\S"
16
+ },
17
+ "deriveSchema": {
18
+ "$ref": "#/$defs/KindSchemaDerivation"
19
+ }
20
+ },
21
+ "required": [
22
+ "kind",
23
+ "verb",
24
+ "deriveSchema"
25
+ ],
26
+ "additionalProperties": false,
27
+ "$defs": {
28
+ "ControlKind": {
29
+ "description": "The built-in control kinds, closed:\n\n- `button`: press it (buttons, toolbar buttons, menu items, a row's action).\n- `toggle`: set it on or off (switches, checkboxes).\n- `text`: type into it (inputs, text areas).\n- `number`: set a number (sliders, scrub fields).\n- `choice`: choose one of its options (selects, radio groups, preset tiles).\n- `multi-choice`: choose any of its options (multi-selects, checkbox groups, filter chips).\n- `color`: set a colour or paint (colour pickers, swatches).\n- `font`: choose a family and style (font pickers).\n- `tabs`: select a tab.\n- `date`: set a date.\n- `date-range`: set a start and an end date.\n- `dialog`: close it. Opening is its trigger's.",
30
+ "enum": [
31
+ "button",
32
+ "toggle",
33
+ "text",
34
+ "number",
35
+ "choice",
36
+ "multi-choice",
37
+ "color",
38
+ "font",
39
+ "tabs",
40
+ "date",
41
+ "date-range",
42
+ "dialog"
43
+ ]
44
+ },
45
+ "RegisteredControlKind": {
46
+ "description": "A kind a design system registers: `x-` and lower-kebab, so it never collides with a built-in one.",
47
+ "type": "string",
48
+ "pattern": "^x-[a-z][a-z0-9]*(-[a-z0-9]+)*$",
49
+ "$comment": "ts: `x-${string}`"
50
+ },
51
+ "AnyControlKind": {
52
+ "description": "A built-in kind, or one a design system registers.",
53
+ "anyOf": [
54
+ {
55
+ "$ref": "#/$defs/ControlKind"
56
+ },
57
+ {
58
+ "$ref": "#/$defs/RegisteredControlKind"
59
+ }
60
+ ]
61
+ },
62
+ "SchemaPropName": {
63
+ "description": "A key of `SchemaProps`: a prop a control's value schema is derived from.",
64
+ "enum": [
65
+ "min",
66
+ "max",
67
+ "step",
68
+ "unit",
69
+ "wrap",
70
+ "options",
71
+ "minLength",
72
+ "maxLength",
73
+ "pattern",
74
+ "inputType",
75
+ "paintKinds",
76
+ "allowNone",
77
+ "clearable"
78
+ ]
79
+ },
80
+ "ControlOption": {
81
+ "description": "One option of a choice, tab set or menu, as the control shows it.",
82
+ "type": "object",
83
+ "properties": {
84
+ "value": {
85
+ "anyOf": [
86
+ {
87
+ "type": "string"
88
+ },
89
+ {
90
+ "type": "number"
91
+ }
92
+ ]
93
+ },
94
+ "title": {
95
+ "type": "string"
96
+ },
97
+ "disabled": {
98
+ "type": "boolean"
99
+ }
100
+ },
101
+ "required": [
102
+ "value",
103
+ "title"
104
+ ],
105
+ "additionalProperties": false
106
+ },
107
+ "SchemaProps": {
108
+ "description": "The props a control's input schema is derived from, by the one derivation (`deriveInputSchema`) the browser runs on live props and the generator on the props it reads statically. A live schema may narrow the generated one but never widen it.",
109
+ "type": "object",
110
+ "properties": {
111
+ "min": {
112
+ "type": "number"
113
+ },
114
+ "max": {
115
+ "type": "number"
116
+ },
117
+ "step": {
118
+ "type": "number"
119
+ },
120
+ "unit": {
121
+ "type": "string"
122
+ },
123
+ "wrap": {
124
+ "description": "Wraps past either end: an angle, where 181° is −179°.",
125
+ "type": "boolean"
126
+ },
127
+ "options": {
128
+ "type": "array",
129
+ "items": {
130
+ "$ref": "#/$defs/ControlOption"
131
+ }
132
+ },
133
+ "minLength": {
134
+ "type": "number"
135
+ },
136
+ "maxLength": {
137
+ "type": "number"
138
+ },
139
+ "pattern": {
140
+ "type": "string"
141
+ },
142
+ "inputType": {
143
+ "description": "An input's `type`: `email`, `url`, `number`, `password`…",
144
+ "type": "string"
145
+ },
146
+ "paintKinds": {
147
+ "description": "The paint kinds a colour control offers: `solid`, `linear`, `radial`.",
148
+ "type": "array",
149
+ "items": {
150
+ "type": "string"
151
+ }
152
+ },
153
+ "allowNone": {
154
+ "description": "A colour control can be set to no paint.",
155
+ "type": "boolean"
156
+ },
157
+ "clearable": {
158
+ "description": "A choice that can be cleared (a toggleable tile grid).",
159
+ "type": "boolean"
160
+ }
161
+ },
162
+ "additionalProperties": false
163
+ },
164
+ "KindSchemaDerivation": {
165
+ "description": "How a registered kind's value schema follows from a control's props, as data, so the browser and the generator derive it with the same function: the schema, and which of its keywords each prop sets, by JSON Pointer. `options` sets a keyword to the values of the options that are not disabled.\n\n```json\n{ \"schema\": { \"type\": \"object\", \"properties\": { \"low\": { \"type\": \"number\" }, \"high\": { \"type\": \"number\" } } },\n \"props\": { \"/properties/low/minimum\": \"min\", \"/properties/high/maximum\": \"max\" } }\n```",
166
+ "type": "object",
167
+ "properties": {
168
+ "schema": {
169
+ "$ref": "json-schema.json"
170
+ },
171
+ "props": {
172
+ "type": "object",
173
+ "propertyNames": {
174
+ "pattern": "^/"
175
+ },
176
+ "additionalProperties": {
177
+ "$ref": "#/$defs/SchemaPropName"
178
+ }
179
+ }
180
+ },
181
+ "required": [
182
+ "schema"
183
+ ],
184
+ "additionalProperties": false
185
+ }
186
+ }
187
+ }
@@ -0,0 +1,276 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.closurestudio.ai/oui/v1/control-table.json",
4
+ "title": "ControlTableFile",
5
+ "description": "A design-system package's control table as it ships (`agent-controls.json`, ADR-0226 §2.2 rule 4): each interactive export's `ControlDescriptor` by export name, and under `$kinds` the control kinds the design system registers, if any. The package declares the table next to its controls, writes it at build time, and names it in its `package.json` under `oui.agentControls` (`closure.agentControls` is read during the transition; declaring both is an error). The conformance kit holds every listed component to registering with the kind declared here.",
6
+ "type": "object",
7
+ "properties": {
8
+ "$kinds": {
9
+ "description": "The control kinds this design system registers.",
10
+ "type": "array",
11
+ "items": {
12
+ "$ref": "control-kind-registration.json"
13
+ }
14
+ }
15
+ },
16
+ "propertyNames": {
17
+ "anyOf": [
18
+ {
19
+ "const": "$kinds"
20
+ },
21
+ {
22
+ "pattern": "^[A-Z][A-Za-z0-9]*$"
23
+ }
24
+ ]
25
+ },
26
+ "additionalProperties": {
27
+ "$ref": "#/$defs/ControlDescriptor"
28
+ },
29
+ "$defs": {
30
+ "ControlTable": {
31
+ "description": "A design-system package's controls, by export name: the table without its `$kinds`.",
32
+ "type": "object",
33
+ "additionalProperties": {
34
+ "$ref": "#/$defs/ControlDescriptor"
35
+ }
36
+ },
37
+ "SlotDescriptor": {
38
+ "description": "One slot of a composite: its kind and the callback it binds. `callback` absent: the slot is always interactive (a toast host's toasts, whatever the page passes). `rows`: the slot registers once per row the control renders (a table's rows, a filter bar's pills), so its action takes an `item`. `defaults`: what the slot always registers, over the component's (a table's sort can be cleared), so the declared schema is as wide as the live one.",
39
+ "type": "object",
40
+ "properties": {
41
+ "kind": {
42
+ "$ref": "control-kind-registration.json#/$defs/AnyControlKind"
43
+ },
44
+ "callback": {
45
+ "type": "string",
46
+ "minLength": 1
47
+ },
48
+ "rows": {
49
+ "type": "boolean"
50
+ },
51
+ "defaults": {
52
+ "$ref": "control-kind-registration.json#/$defs/SchemaProps"
53
+ }
54
+ },
55
+ "required": [
56
+ "kind"
57
+ ],
58
+ "additionalProperties": false
59
+ },
60
+ "EntriesDescriptor": {
61
+ "description": "An array prop whose entries carry their own `agent` (toolbar items, menu items, selection actions).",
62
+ "type": "object",
63
+ "properties": {
64
+ "prop": {
65
+ "type": "string",
66
+ "minLength": 1
67
+ },
68
+ "kind": {
69
+ "$ref": "control-kind-registration.json#/$defs/AnyControlKind"
70
+ },
71
+ "callback": {
72
+ "type": "string",
73
+ "minLength": 1
74
+ },
75
+ "titleKey": {
76
+ "type": "string",
77
+ "minLength": 1
78
+ }
79
+ },
80
+ "required": [
81
+ "prop",
82
+ "kind",
83
+ "callback",
84
+ "titleKey"
85
+ ],
86
+ "additionalProperties": false
87
+ },
88
+ "ControlDescriptor": {
89
+ "description": "How the generator reads one design-system component where a page uses it: what kind of control it is, which of its props make it interactive, and where its schema, options, slots and nested bindings come from. The component itself registers through `useAgentBinding` with the same kind.",
90
+ "type": "object",
91
+ "properties": {
92
+ "kind": {
93
+ "description": "What a binding on the component itself makes. Absent when it binds only per slot or per entry.",
94
+ "$ref": "control-kind-registration.json#/$defs/AnyControlKind"
95
+ },
96
+ "callbacks": {
97
+ "description": "Props whose presence makes a use interactive — a use with one of them must be bound. Empty: always.",
98
+ "type": "array",
99
+ "items": {
100
+ "type": "string",
101
+ "minLength": 1
102
+ }
103
+ },
104
+ "schemaProps": {
105
+ "description": "Props the schema is derived from, by `SchemaProps` key: the prop of the component each comes from.",
106
+ "$ref": "#/$defs/SchemaPropSources"
107
+ },
108
+ "options": {
109
+ "description": "Where the options come from: the prop, and the keys of each option's value and title.",
110
+ "$ref": "#/$defs/OptionsSource"
111
+ },
112
+ "slots": {
113
+ "description": "A composite with several callbacks: slot name → its kind and the callback it binds.",
114
+ "type": "object",
115
+ "additionalProperties": {
116
+ "$ref": "#/$defs/SlotDescriptor"
117
+ }
118
+ },
119
+ "entries": {
120
+ "$ref": "#/$defs/EntriesDescriptor"
121
+ },
122
+ "rows": {
123
+ "description": "The control registers one binding per row it renders (a selectable grid), so its action takes an `item`.",
124
+ "type": "boolean"
125
+ },
126
+ "container": {
127
+ "description": "A container: a dialog whose prop says whether it shows, or a tab set whose prop selects a panel.",
128
+ "type": "object",
129
+ "properties": {
130
+ "kind": {
131
+ "enum": [
132
+ "dialog",
133
+ "tabs"
134
+ ]
135
+ },
136
+ "stateProp": {
137
+ "type": "string",
138
+ "minLength": 1
139
+ }
140
+ },
141
+ "required": [
142
+ "kind",
143
+ "stateProp"
144
+ ],
145
+ "additionalProperties": false
146
+ },
147
+ "defaults": {
148
+ "description": "What the schema props are when the page leaves them out, as the component defaults them. The declared schema is the widest the control can take; the live one may only narrow it.",
149
+ "$ref": "control-kind-registration.json#/$defs/SchemaProps"
150
+ },
151
+ "display": {
152
+ "description": "It shows facts rather than taking input (a clip's parameters): a binding on it names what it shows, and the page reports its facts by label. Its facts are the array prop `itemsProp`, each labelled by `labelKey`. Not a control, so a use without a binding is not unbound.",
153
+ "type": "object",
154
+ "properties": {
155
+ "itemsProp": {
156
+ "type": "string",
157
+ "minLength": 1
158
+ },
159
+ "labelKey": {
160
+ "type": "string",
161
+ "minLength": 1
162
+ }
163
+ },
164
+ "required": [
165
+ "itemsProp",
166
+ "labelKey"
167
+ ],
168
+ "additionalProperties": false
169
+ },
170
+ "titleProps": {
171
+ "description": "Props that give a default title, in order. `children` means the element's text.",
172
+ "type": "array",
173
+ "items": {
174
+ "type": "string",
175
+ "minLength": 1
176
+ }
177
+ }
178
+ },
179
+ "required": [
180
+ "callbacks",
181
+ "titleProps"
182
+ ],
183
+ "additionalProperties": false
184
+ },
185
+ "OptionsSource": {
186
+ "description": "Where a control's options come from: the prop that holds them, and the keys of each option's value and title.",
187
+ "type": "object",
188
+ "properties": {
189
+ "prop": {
190
+ "type": "string",
191
+ "minLength": 1
192
+ },
193
+ "value": {
194
+ "type": "string",
195
+ "minLength": 1
196
+ },
197
+ "title": {
198
+ "type": "string",
199
+ "minLength": 1
200
+ }
201
+ },
202
+ "required": [
203
+ "prop",
204
+ "value",
205
+ "title"
206
+ ],
207
+ "additionalProperties": false
208
+ },
209
+ "OuiPackageDeclaration": {
210
+ "description": "What a package declares to the generator under the `oui` key of its `package.json` (ADR-0226 §2.2): its control table, its room catalog, and the components only the person may use. During the transition the generator and the kit also read `closure.agentControls` and `closure.agentCatalog`; a package declaring a key under both `oui` and `closure` is an error.",
211
+ "type": "object",
212
+ "properties": {
213
+ "agentControls": {
214
+ "description": "The path of the package's control table, relative to the package.",
215
+ "type": "string",
216
+ "minLength": 1
217
+ },
218
+ "agentCatalog": {
219
+ "$ref": "room-catalog-data.json#/$defs/AgentCatalogManifestEntry"
220
+ },
221
+ "personOnly": {
222
+ "description": "Export name → why only the person may use it, such as the approval card (ADR-0228). The generator refuses an `agent` binding on one.",
223
+ "type": "object",
224
+ "additionalProperties": {
225
+ "type": "string",
226
+ "minLength": 1
227
+ }
228
+ }
229
+ },
230
+ "additionalProperties": false
231
+ },
232
+ "SchemaPropSources": {
233
+ "description": "Props a control's schema is derived from, by `SchemaProps` key (every key but `options`, which `OptionsSource` gives): the prop of the component each comes from.",
234
+ "type": "object",
235
+ "properties": {
236
+ "min": {
237
+ "type": "string"
238
+ },
239
+ "max": {
240
+ "type": "string"
241
+ },
242
+ "step": {
243
+ "type": "string"
244
+ },
245
+ "unit": {
246
+ "type": "string"
247
+ },
248
+ "wrap": {
249
+ "type": "string"
250
+ },
251
+ "minLength": {
252
+ "type": "string"
253
+ },
254
+ "maxLength": {
255
+ "type": "string"
256
+ },
257
+ "pattern": {
258
+ "type": "string"
259
+ },
260
+ "inputType": {
261
+ "type": "string"
262
+ },
263
+ "paintKinds": {
264
+ "type": "string"
265
+ },
266
+ "allowNone": {
267
+ "type": "string"
268
+ },
269
+ "clearable": {
270
+ "type": "string"
271
+ }
272
+ },
273
+ "additionalProperties": false
274
+ }
275
+ }
276
+ }