@khanglvm/relay 0.17.1 → 0.19.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.
@@ -66,6 +66,7 @@ Use `required:true` only for answers necessary to continue.
66
66
  | Mockups / before-after | `image`, `compare` |
67
67
  | Media / reports | `video`, `pdf` |
68
68
  | Design choices | `palette`, `typography` |
69
+ | Live status, quick actions, small forms | `a2ui` (grammar: `rly a2ui`) |
69
70
  | Custom interactive content | sandboxed `html` |
70
71
 
71
72
  | Answer shape | Question type |
@@ -81,6 +82,24 @@ in `blockEdits`. For image feedback, primary drag selects a region/crop;
81
82
  Space-drag or middle-drag pans. A compare divider moves only by its handle.
82
83
  `pins:true` adds image point comments.
83
84
 
85
+ ## Open a board on the user's other devices
86
+
87
+ When the user reads on a phone or another Mac, and `devlink` is installed, add
88
+ `--devlink` to `rly ask|show|view|diff` (or set it once with
89
+ `rly config link devlink`). The command prints a private https URL; give the user
90
+ that URL and never a localhost one. Without `devlink`, `--public-url
91
+ 'https://host:{port}'` takes any https URL that reaches the board. Answers still
92
+ come back through `rly wait` and `rly result`.
93
+
94
+ ## A2UI widgets
95
+
96
+ An `a2ui` block is a small live widget for state and quick actions: a status list,
97
+ numbers, a progress bar, buttons, a short form. Write it as A2UI Express in the
98
+ `express` field; run `rly a2ui` for the grammar and every component. Clicks and
99
+ input values return in `result.blockEdits[blockId]` as `{type:"a2ui", data,
100
+ events:[{name, context, at}]}`. A widget is never a substitute for a question you
101
+ need answered; use `single`, `yesno` or `text` for that.
102
+
84
103
  ## File references that open in a modal
85
104
 
86
105
  In the intro or a markdown block, use `[label](/absolute/path/file.js:98)`.
@@ -0,0 +1,630 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/khanglvm/relay/a2ui/catalog/v1",
4
+ "catalogId": "https://github.com/khanglvm/relay/a2ui/catalog/v1",
5
+ "protocolVersion": "1.0",
6
+ "title": "Relay board catalog",
7
+ "description": "Components for a small live widget inside a Relay board: status lists, numbers, progress, tables and a few inputs and buttons. The board's own theme draws them, so you choose components and data, never styling.",
8
+ "instructions": "One surface is one widget. The root is always a Card (id `root`). Keep it small: at most 60 components, one question per widget. State is a tone (`ok`, `info`, `warn`, `error`, `needs`), never a colour word. Put values in the data model with `$/path = value` lines and bind components to them. A Button's `Event(name, {key: value})` comes back to you in `result.blockEdits[blockId]`, with the values of every input on the card, so name the events for what the person decided (`approve`, `retry`). Use `openUrl` for links. Never put markup in a string: text is drawn as text. Use the board's own question blocks for anything the answer depends on; an A2UI widget is for state, quick actions and small forms.",
9
+ "components": {
10
+ "Card": {
11
+ "type": "object",
12
+ "description": "The root of a board widget (id `root`): an optional title and its children. Use it for the one widget a board shows.",
13
+ "properties": {
14
+ "component": {
15
+ "const": "Card"
16
+ },
17
+ "title": {
18
+ "$ref": "common_types.json#/$defs/DynamicString"
19
+ },
20
+ "children": {
21
+ "$ref": "common_types.json#/$defs/ChildList"
22
+ }
23
+ },
24
+ "required": [
25
+ "component",
26
+ "title",
27
+ "children"
28
+ ]
29
+ },
30
+ "Stack": {
31
+ "type": "object",
32
+ "description": "Lays children out in a row or a column.",
33
+ "properties": {
34
+ "component": {
35
+ "const": "Stack"
36
+ },
37
+ "direction": {
38
+ "type": "string",
39
+ "enum": [
40
+ "row",
41
+ "column"
42
+ ]
43
+ },
44
+ "children": {
45
+ "$ref": "common_types.json#/$defs/ChildList"
46
+ },
47
+ "gap": {
48
+ "type": "string",
49
+ "enum": [
50
+ "xs",
51
+ "sm",
52
+ "md",
53
+ "lg"
54
+ ],
55
+ "description": "Space between children: xs 4, sm 8 (default), md 12 or lg 16 pixels."
56
+ },
57
+ "align": {
58
+ "type": "string",
59
+ "enum": [
60
+ "start",
61
+ "center",
62
+ "end",
63
+ "stretch"
64
+ ]
65
+ }
66
+ },
67
+ "required": [
68
+ "component",
69
+ "direction",
70
+ "children"
71
+ ]
72
+ },
73
+ "Grid": {
74
+ "type": "object",
75
+ "description": "Equal-width columns, filled row by row. On a phone, 3 or 4 columns drop to 2.",
76
+ "properties": {
77
+ "component": {
78
+ "const": "Grid"
79
+ },
80
+ "columns": {
81
+ "type": "integer",
82
+ "minimum": 2,
83
+ "maximum": 4
84
+ },
85
+ "children": {
86
+ "$ref": "common_types.json#/$defs/ChildList"
87
+ },
88
+ "gap": {
89
+ "type": "string",
90
+ "enum": [
91
+ "xs",
92
+ "sm",
93
+ "md",
94
+ "lg"
95
+ ]
96
+ }
97
+ },
98
+ "required": [
99
+ "component",
100
+ "columns",
101
+ "children"
102
+ ]
103
+ },
104
+ "Text": {
105
+ "type": "object",
106
+ "description": "Plain prose, never markup. `title` is a heading for the widget's sections, `muted` a quiet note.",
107
+ "properties": {
108
+ "component": {
109
+ "const": "Text"
110
+ },
111
+ "text": {
112
+ "$ref": "common_types.json#/$defs/DynamicString"
113
+ },
114
+ "variant": {
115
+ "type": "string",
116
+ "enum": [
117
+ "body",
118
+ "title",
119
+ "muted"
120
+ ]
121
+ }
122
+ },
123
+ "required": [
124
+ "component",
125
+ "text"
126
+ ]
127
+ },
128
+ "Pill": {
129
+ "type": "object",
130
+ "description": "A short state word in a tone.",
131
+ "properties": {
132
+ "component": {
133
+ "const": "Pill"
134
+ },
135
+ "text": {
136
+ "$ref": "common_types.json#/$defs/DynamicString"
137
+ },
138
+ "tone": {
139
+ "type": "string",
140
+ "enum": [
141
+ "info",
142
+ "ok",
143
+ "warn",
144
+ "error",
145
+ "needs"
146
+ ],
147
+ "description": "`ok` done or healthy, `info` in progress, `warn` slipping, `error` failed, `needs` the person must act."
148
+ }
149
+ },
150
+ "required": [
151
+ "component",
152
+ "text",
153
+ "tone"
154
+ ]
155
+ },
156
+ "Metric": {
157
+ "type": "object",
158
+ "description": "One number with a label and an optional note.",
159
+ "properties": {
160
+ "component": {
161
+ "const": "Metric"
162
+ },
163
+ "label": {
164
+ "$ref": "common_types.json#/$defs/DynamicString"
165
+ },
166
+ "value": {
167
+ "$ref": "common_types.json#/$defs/DynamicString"
168
+ },
169
+ "note": {
170
+ "$ref": "common_types.json#/$defs/DynamicString"
171
+ }
172
+ },
173
+ "required": [
174
+ "component",
175
+ "label",
176
+ "value"
177
+ ]
178
+ },
179
+ "List": {
180
+ "type": "object",
181
+ "description": "Rows of things with a state: a title, an optional subtitle and trailing value, a tone pill and an optional https link.",
182
+ "properties": {
183
+ "component": {
184
+ "const": "List"
185
+ },
186
+ "items": {
187
+ "$ref": "common_types.json#/$defs/DynamicValue",
188
+ "description": "Array of {title, subtitle?, trailing?, tone?, url?}, usually bound to a data-model path."
189
+ },
190
+ "max": {
191
+ "type": "integer",
192
+ "minimum": 1,
193
+ "description": "Rows shown before `N more`."
194
+ }
195
+ },
196
+ "required": [
197
+ "component",
198
+ "items"
199
+ ]
200
+ },
201
+ "Progress": {
202
+ "type": "object",
203
+ "description": "A bar with `value` of `total`, a label and an optional note.",
204
+ "properties": {
205
+ "component": {
206
+ "const": "Progress"
207
+ },
208
+ "label": {
209
+ "$ref": "common_types.json#/$defs/DynamicString"
210
+ },
211
+ "value": {
212
+ "$ref": "common_types.json#/$defs/DynamicNumber"
213
+ },
214
+ "total": {
215
+ "$ref": "common_types.json#/$defs/DynamicNumber"
216
+ },
217
+ "note": {
218
+ "$ref": "common_types.json#/$defs/DynamicString"
219
+ },
220
+ "tone": {
221
+ "type": "string",
222
+ "enum": [
223
+ "info",
224
+ "ok",
225
+ "warn",
226
+ "error"
227
+ ]
228
+ }
229
+ },
230
+ "required": [
231
+ "component",
232
+ "label",
233
+ "value",
234
+ "total"
235
+ ]
236
+ },
237
+ "Table": {
238
+ "type": "object",
239
+ "description": "Rows under typed columns.",
240
+ "properties": {
241
+ "component": {
242
+ "const": "Table"
243
+ },
244
+ "columns": {
245
+ "type": "array",
246
+ "minItems": 1,
247
+ "maxItems": 8,
248
+ "items": {
249
+ "type": "object",
250
+ "properties": {
251
+ "key": {
252
+ "type": "string"
253
+ },
254
+ "label": {
255
+ "type": "string"
256
+ }
257
+ },
258
+ "required": [
259
+ "key",
260
+ "label"
261
+ ],
262
+ "additionalProperties": false
263
+ }
264
+ },
265
+ "rows": {
266
+ "$ref": "common_types.json#/$defs/DynamicValue",
267
+ "description": "Array of objects keyed by column `key`."
268
+ },
269
+ "max": {
270
+ "type": "integer",
271
+ "minimum": 1
272
+ }
273
+ },
274
+ "required": [
275
+ "component",
276
+ "columns",
277
+ "rows"
278
+ ]
279
+ },
280
+ "Code": {
281
+ "type": "object",
282
+ "description": "A code block, shown as text.",
283
+ "properties": {
284
+ "component": {
285
+ "const": "Code"
286
+ },
287
+ "code": {
288
+ "$ref": "common_types.json#/$defs/DynamicString"
289
+ },
290
+ "language": {
291
+ "type": "string"
292
+ }
293
+ },
294
+ "required": [
295
+ "component",
296
+ "code"
297
+ ]
298
+ },
299
+ "Image": {
300
+ "type": "object",
301
+ "description": "A picture from an https address.",
302
+ "properties": {
303
+ "component": {
304
+ "const": "Image"
305
+ },
306
+ "url": {
307
+ "type": "string",
308
+ "pattern": "^https://"
309
+ },
310
+ "alt": {
311
+ "$ref": "common_types.json#/$defs/DynamicString"
312
+ }
313
+ },
314
+ "required": [
315
+ "component",
316
+ "url",
317
+ "alt"
318
+ ]
319
+ },
320
+ "Icon": {
321
+ "type": "object",
322
+ "description": "One icon from a fixed set. `label` is what a screen reader says.",
323
+ "properties": {
324
+ "component": {
325
+ "const": "Icon"
326
+ },
327
+ "name": {
328
+ "type": "string",
329
+ "enum": [
330
+ "check",
331
+ "alert",
332
+ "info",
333
+ "x",
334
+ "clock",
335
+ "file",
336
+ "folder",
337
+ "git-branch",
338
+ "play",
339
+ "star",
340
+ "link",
341
+ "user",
342
+ "bell",
343
+ "lock"
344
+ ]
345
+ },
346
+ "label": {
347
+ "$ref": "common_types.json#/$defs/DynamicString"
348
+ },
349
+ "tone": {
350
+ "type": "string",
351
+ "enum": [
352
+ "info",
353
+ "ok",
354
+ "warn",
355
+ "error",
356
+ "needs"
357
+ ]
358
+ }
359
+ },
360
+ "required": [
361
+ "component",
362
+ "name",
363
+ "label"
364
+ ]
365
+ },
366
+ "Divider": {
367
+ "type": "object",
368
+ "description": "A hairline between sections.",
369
+ "properties": {
370
+ "component": {
371
+ "const": "Divider"
372
+ }
373
+ },
374
+ "required": [
375
+ "component"
376
+ ]
377
+ },
378
+ "Button": {
379
+ "type": "object",
380
+ "description": "A button. `Event(name, context)` sends the click back to the agent in the board's answer, with the current values of the inputs on the card; `openUrl` opens an https link.",
381
+ "properties": {
382
+ "component": {
383
+ "const": "Button"
384
+ },
385
+ "label": {
386
+ "$ref": "common_types.json#/$defs/DynamicString"
387
+ },
388
+ "action": {
389
+ "$ref": "common_types.json#/$defs/Action"
390
+ },
391
+ "style": {
392
+ "type": "string",
393
+ "enum": [
394
+ "primary",
395
+ "plain"
396
+ ]
397
+ }
398
+ },
399
+ "required": [
400
+ "component",
401
+ "label",
402
+ "action"
403
+ ]
404
+ },
405
+ "TextField": {
406
+ "type": "object",
407
+ "description": "A text input bound to the data model at `path`. Its value comes back in the board's answer.",
408
+ "properties": {
409
+ "component": {
410
+ "const": "TextField"
411
+ },
412
+ "label": {
413
+ "$ref": "common_types.json#/$defs/DynamicString"
414
+ },
415
+ "path": {
416
+ "type": "string",
417
+ "pattern": "^/(?!(?:.*/)?(?:__proto__|constructor|prototype|length)(?:/|$))"
418
+ },
419
+ "placeholder": {
420
+ "$ref": "common_types.json#/$defs/DynamicString"
421
+ },
422
+ "multiline": {
423
+ "type": "boolean"
424
+ }
425
+ },
426
+ "required": [
427
+ "component",
428
+ "label",
429
+ "path"
430
+ ]
431
+ },
432
+ "Toggle": {
433
+ "type": "object",
434
+ "description": "An on/off input bound to `path`.",
435
+ "properties": {
436
+ "component": {
437
+ "const": "Toggle"
438
+ },
439
+ "label": {
440
+ "$ref": "common_types.json#/$defs/DynamicString"
441
+ },
442
+ "path": {
443
+ "type": "string",
444
+ "pattern": "^/(?!(?:.*/)?(?:__proto__|constructor|prototype|length)(?:/|$))"
445
+ }
446
+ },
447
+ "required": [
448
+ "component",
449
+ "label",
450
+ "path"
451
+ ]
452
+ },
453
+ "Select": {
454
+ "type": "object",
455
+ "description": "A pick-one input bound to `path`; the value is the picked option's `key`.",
456
+ "properties": {
457
+ "component": {
458
+ "const": "Select"
459
+ },
460
+ "label": {
461
+ "$ref": "common_types.json#/$defs/DynamicString"
462
+ },
463
+ "path": {
464
+ "type": "string",
465
+ "pattern": "^/(?!(?:.*/)?(?:__proto__|constructor|prototype|length)(?:/|$))"
466
+ },
467
+ "options": {
468
+ "type": "array",
469
+ "minItems": 1,
470
+ "maxItems": 30,
471
+ "items": {
472
+ "type": "object",
473
+ "properties": {
474
+ "key": {
475
+ "type": "string"
476
+ },
477
+ "label": {
478
+ "type": "string"
479
+ }
480
+ },
481
+ "required": [
482
+ "key",
483
+ "label"
484
+ ],
485
+ "additionalProperties": false
486
+ }
487
+ }
488
+ },
489
+ "required": [
490
+ "component",
491
+ "label",
492
+ "path",
493
+ "options"
494
+ ]
495
+ },
496
+ "Slider": {
497
+ "type": "object",
498
+ "description": "A number input bound to `path` between `min` and `max`.",
499
+ "properties": {
500
+ "component": {
501
+ "const": "Slider"
502
+ },
503
+ "label": {
504
+ "$ref": "common_types.json#/$defs/DynamicString"
505
+ },
506
+ "path": {
507
+ "type": "string",
508
+ "pattern": "^/(?!(?:.*/)?(?:__proto__|constructor|prototype|length)(?:/|$))"
509
+ },
510
+ "min": {
511
+ "type": "number"
512
+ },
513
+ "max": {
514
+ "type": "number"
515
+ },
516
+ "step": {
517
+ "type": "number"
518
+ }
519
+ },
520
+ "required": [
521
+ "component",
522
+ "label",
523
+ "path",
524
+ "min",
525
+ "max"
526
+ ]
527
+ }
528
+ },
529
+ "functions": {
530
+ "openUrl": {
531
+ "type": "object",
532
+ "description": "Opens an https link in a new tab.",
533
+ "returnType": "void",
534
+ "allowedCallers": "rendererOnly",
535
+ "requiresUserActivation": true,
536
+ "properties": {
537
+ "@call": {
538
+ "const": "openUrl"
539
+ },
540
+ "args": {
541
+ "type": "object",
542
+ "properties": {
543
+ "url": {
544
+ "type": "string",
545
+ "pattern": "^https://"
546
+ }
547
+ },
548
+ "required": [
549
+ "url"
550
+ ],
551
+ "additionalProperties": false
552
+ }
553
+ },
554
+ "required": [
555
+ "@call",
556
+ "args"
557
+ ]
558
+ }
559
+ },
560
+ "$defs": {
561
+ "anyComponent": {
562
+ "oneOf": [
563
+ {
564
+ "$ref": "#/components/Card"
565
+ },
566
+ {
567
+ "$ref": "#/components/Stack"
568
+ },
569
+ {
570
+ "$ref": "#/components/Grid"
571
+ },
572
+ {
573
+ "$ref": "#/components/Text"
574
+ },
575
+ {
576
+ "$ref": "#/components/Pill"
577
+ },
578
+ {
579
+ "$ref": "#/components/Metric"
580
+ },
581
+ {
582
+ "$ref": "#/components/List"
583
+ },
584
+ {
585
+ "$ref": "#/components/Progress"
586
+ },
587
+ {
588
+ "$ref": "#/components/Table"
589
+ },
590
+ {
591
+ "$ref": "#/components/Code"
592
+ },
593
+ {
594
+ "$ref": "#/components/Image"
595
+ },
596
+ {
597
+ "$ref": "#/components/Icon"
598
+ },
599
+ {
600
+ "$ref": "#/components/Divider"
601
+ },
602
+ {
603
+ "$ref": "#/components/Button"
604
+ },
605
+ {
606
+ "$ref": "#/components/TextField"
607
+ },
608
+ {
609
+ "$ref": "#/components/Toggle"
610
+ },
611
+ {
612
+ "$ref": "#/components/Select"
613
+ },
614
+ {
615
+ "$ref": "#/components/Slider"
616
+ }
617
+ ],
618
+ "discriminator": {
619
+ "propertyName": "component"
620
+ }
621
+ },
622
+ "anyFunction": {
623
+ "oneOf": [
624
+ {
625
+ "$ref": "#/functions/openUrl"
626
+ }
627
+ ]
628
+ }
629
+ }
630
+ }