Repository navigation
Expand file tree
/
Copy pathobject.metadata-form.ts
More file actions
863 lines (851 loc) · 66.6 KB
/
Copy pathobject.metadata-form.ts
File metadata and controls
863 lines (851 loc) · 66.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineMetadataForm } from '../ui/view.zod';
import { ValueDomainSchema, type ValueDomain } from '../shared/value-domain.zod';
/**
* The `valueDomain` control's choices, DERIVED from the closed vocabulary
* (#14168). The labels are a `Record` over the union, so a member added to
* `ValueDomainSchema` without a label here fails to compile rather than
* silently reaching Studio as a machine word — the same exhaustiveness the
* membership table beside the schema uses.
*/
const VALUE_DOMAIN_LABELS: Readonly<Record<ValueDomain, string>> = {
iana_time_zone: 'IANA time zone',
iso_4217_currency: 'ISO 4217 currency code',
iso_3166_alpha2: 'ISO 3166-1 alpha-2 country code',
};
const VALUE_DOMAIN_OPTIONS = ValueDomainSchema.options.map((value) => ({
label: VALUE_DOMAIN_LABELS[value],
value,
}));
/**
* Form Layout for Object Metadata Type
*/
export const objectForm = defineMetadataForm({
schemaId: 'object',
type: 'simple',
sections: [
{
name: 'basics',
label: 'Basics',
description: 'Identity, labels, and taxonomy.',
columns: 2,
fields: [
{ field: 'name', type: 'text', required: true, immutable: true, colSpan: 1, helpText: 'snake_case unique identifier (immutable after creation)' },
{ field: 'label', type: 'text', colSpan: 1, helpText: 'Singular display name (e.g. "Account")' },
{ field: 'pluralLabel', type: 'text', colSpan: 1, helpText: 'Plural display name (e.g. "Accounts")' },
{ field: 'icon', type: 'text', colSpan: 1, helpText: 'Lucide icon name (e.g. "building", "users")' },
// [#35985] The colour of the square the icon is drawn on: the swatch row
// (`color-picker`) reads its nine names off the closed enum.
{ field: 'color', widget: 'color-picker', colSpan: 1, helpText: 'Color of the square the icon is drawn on, from the fixed palette. Unset draws gray.' },
{ field: 'description', type: 'textarea', colSpan: 2, helpText: 'Developer documentation' },
// #19331 — `nameField` is declared by ObjectSchema and was offered by no
// control, so the ADR-0079 record-title pointer could only be written
// through the Source tab's free-text JSON. A plain text row: the value
// names one of THIS object's own fields, and this registry has no
// own-field picker to route it to (`field-multi` is multi-valued and
// takes its candidates from a `dependsOn` source row, which a top-level
// object row has nothing to point at).
{ field: 'nameField', type: 'text', colSpan: 1, helpText: 'Field whose value titles each record (e.g. "name", "subject"). ADR-0079 canonical pointer — read by record display, ObjectQL search and related-record previews.' },
// #21765 (director ruling 5989738766, letter A) — `imageField`, the
// record's picture (#21182 ruling A), is the sibling pointer of
// `nameField` and gets the same face, for the same reason: it names one
// of THIS object's own fields and the registry has no own-field picker.
// No validator here either. The parse (`refuseNonPictureImageField` in
// `object.zod.ts`) is the one judge of the value, and its refusal at
// save is what an author sees for a name that is not an `image` /
// `avatar` field of this object. A cleared input writes no key, which
// the parse reads as no picture.
{ field: 'imageField', type: 'text', colSpan: 1, helpText: 'Field whose value is each record\'s picture, drawn beside the title in the record page header. Must name a field of this object whose type is image or avatar; any other name is refused when the object is saved. Empty: no record picture, and no placeholder is drawn.' },
{ field: 'isSystem', type: 'boolean', colSpan: 1, helpText: 'System object (protected from deletion; defaults sharing to public)' },
// #20349 — the object's two own field-name LISTS, beside the `nameField`
// pointer. Free text, the `view.metadata-form.ts` `searchableFields` row's face:
// `string-tags` is a chip input over `string[]`, which is exactly this
// node. A field picker is not an option here — `field-multi` takes its
// catalog from the draft's `object` / `objectName` / `data.object` /
// `interfaceConfig.source`, and an object draft carries none of them, so
// it would offer an empty list. A misspelt entry is not dropped quietly:
// the publish door refuses it (`object-field-ref-unknown`,
// `searchable-field-unknown`, both at `error`), and so does `os validate`.
{ field: 'highlightFields', widget: 'string-tags', colSpan: 2, helpText: 'Field names of this object, most important first — the first entry wins where only one fits (ADR-0085). Drives the default list and related-list columns, cards, child-record previews, the record hover card and the record picker. A name that is not a field of this object is refused at publish.' },
// #27069 / #35897 / #35899 — the record page's tab list: inbound
// relationship names (child object, or `object.field`), the three
// built-in tabs by object name, or an entry's object form
// `{ list, label?, columns? }`. Its own widget, not `string-tags`: that
// chip input casts the value to `string[]`, and an object entry (which
// Studio's Record page tabs editor writes once a title or columns are
// set) cannot render as a chip there (#35923 review M1). A dangling name
// is refused at the publish door (`related-list-ref-unknown`, `error`,
// judged against the registry's children) and by `os validate` / `os build`.
{ field: 'relatedLists', widget: 'related-list-entries', colSpan: 2, helpText: 'The record page tabs after the overview, in order. Each entry is a child object name (e.g. task), object.field when that child has more than one relationship to this object, a built-in tab (sys_attachment, sys_approval_request, sys_activity), or an entry with its own title and columns, set in App Studio\'s object settings. Once anything is listed, a related list no entry names shows no tab, a list another package adds included, until this object names it; attachments show only when listed. Empty: every list shows in the default order. A name that matches no relationship pointing at this object is refused when the object is saved.' },
{ field: 'searchableFields', widget: 'string-tags', colSpan: 2, helpText: 'Field names the $search query matches (ADR-0061): the default for the record picker, list quick-search and global search; a view may narrow it. Unset, search uses the name/title field plus short-text fields. Each entry must name a stored field of this object — an unknown name or a virtual formula field is refused at publish.' },
// #19332 (flight G2a of ruling record 5861442317) — the object's field
// groups, the ADR-0085 layout role beside `nameField` / `highlightFields`.
// A repeater whose sub-rows are DECLARED, the `fields.options` repeater's
// face below, for two reasons:
//
// - A derived repeater renders every key of the entry schema, and three
// of its nine are the `[DEPRECATED → collapse]` aliases
// (`defaultExpanded`, `collapsible`, `collapsed`). Declaring the six
// canonical keys keeps the aliases off screen; each alias carries a
// nested `omit` row in the reconciliation ledger.
// - A declared sub-row's label and help text reach the translation
// catalogs, which a schema-derived one never does.
//
// Each sub-row copies the face a registered row already gives the same
// node: `key` / `label` / `icon` the plain text rows above, `description`
// the textarea row above, `collapse` a select over an enum whose three
// members are all spellable option values, and `visibleWhen` the
// `type: 'code'` / `language: 'expression'` predicate rows of the
// `fields` grid. An edit merges into the stored entry, so an alias an
// entry already carries survives a save, and a `collapse` set here
// outranks it (the parse derives `collapse` from an alias only when
// `collapse` is absent).
//
// `fields` is the group's own member list (field names, in display
// order), a `tags` row as `hook.metadata-form.ts` gives a list of names; a name
// no field declares is skipped by the layout and warned by `os lint`.
{
field: 'fieldGroups',
type: 'repeater',
colSpan: 2,
helpText: 'Ordered sections that group this object\'s fields on the entry form and the record detail page (ADR-0085); array order is display order. A group lists its fields, in order, in its Fields setting; a group without that list holds the fields that name its key in their own group setting. Fields in no group follow the groups, and a group no field joins is not drawn.',
fields: [
{ field: 'key', label: 'Key', type: 'text', required: true, helpText: 'Machine key in snake_case, unique within this object — the schema refuses anything else. Fields the group lists in its Fields stay with it when the key is renamed; a field that joins by naming this key in its own group setting is left ungrouped.' },
{ field: 'label', label: 'Label', type: 'text', required: true, helpText: 'Header text of the group\'s section.' },
{ field: 'fields', label: 'Fields', type: 'tags', helpText: 'The fields this group shows, in display order (field names). Written, it sets the order inside the group without moving any field. A field this list names may not name another group in its own group setting, and a field may be listed by one group only. Not allowed with Related List.' },
{ field: 'icon', label: 'Icon', type: 'text', helpText: 'Lucide icon name shown beside the header on the record detail page (e.g. "banknote"). The entry form does not show it.' },
{ field: 'description', label: 'Description', type: 'textarea', helpText: 'Text shown under the header, on the entry form and the record detail page.' },
{ field: 'relatedList', label: 'Related List', type: 'text', helpText: 'Makes this entry a related list\'s table instead of a section of fields: name the child object (or object.field) whose list is drawn at this position in the record\'s details column. Such a group holds no fields; a field that names it as its group is refused, and so is a name that matches no relationship pointing at this object. The parent\'s create and edit forms inline the table too, and the record page\'s Edit saves the record and its rows together.' },
{ field: 'collapse', label: 'Collapse', type: 'select', helpText: 'Whether the section can be collapsed. The entry form follows it as set. The default record page lets the reader fold every titled group, so there it only sets the first state: Collapsed starts closed, the others start open. Unset: none.', options: [
{ label: 'None — always open on the entry form, no toggle', value: 'none' },
{ label: 'Expanded — collapsible, starts open', value: 'expanded' },
{ label: 'Collapsed — collapsible, starts closed', value: 'collapsed' },
] },
{ field: 'visibleWhen', label: 'Visible When', type: 'code', language: 'expression', helpText: 'CEL predicate over the record (e.g. record.type == \'invoice\') — the entry form shows the whole group, header included, only while it is TRUE.' },
{ field: 'requiresFeature', label: 'Requires Feature', helpText: 'Deployment feature the group needs (e.g. multiOrgEnabled): where it is off, the entry form and the record detail page hide the whole group. Combined with Visible When, the group shows only while both hold. The fields stay readable through the API.' },
],
},
],
},
{
name: 'fields',
label: 'Fields',
description: 'Define the data model — each entry becomes a column in the database table.',
fields: [
{
field: 'fields',
type: 'record',
required: true,
helpText: 'Add the columns this object will store',
keyField: {
field: 'name',
label: 'Name',
placeholder: 'snake_case_identifier',
helpText: 'snake_case machine name (used as column name and API key)',
regex: '^[a-z_][a-z0-9_]*$',
immutable: true,
},
fields: [
{ field: 'label', type: 'text', helpText: 'Display label' },
{
field: 'type',
type: 'select',
required: true,
helpText: 'Field type',
options: [
{ label: 'Text', value: 'text' },
{ label: 'Textarea', value: 'textarea' },
{ label: 'Email', value: 'email' },
{ label: 'URL', value: 'url' },
{ label: 'Phone', value: 'phone' },
{ label: 'Password', value: 'password' },
{ label: 'Markdown', value: 'markdown' },
{ label: 'HTML', value: 'html' },
{ label: 'Rich Text', value: 'richtext' },
{ label: 'Number', value: 'number' },
{ label: 'Currency', value: 'currency' },
{ label: 'Percent', value: 'percent' },
{ label: 'Date', value: 'date' },
{ label: 'Date & Time', value: 'datetime' },
{ label: 'Time', value: 'time' },
{ label: 'Boolean', value: 'boolean' },
{ label: 'Toggle', value: 'toggle' },
{ label: 'Select', value: 'select' },
{ label: 'Multiselect', value: 'multiselect' },
{ label: 'Radio', value: 'radio' },
{ label: 'Checkboxes', value: 'checkboxes' },
{ label: 'Lookup (reference)', value: 'lookup' },
{ label: 'Master–Detail', value: 'master_detail' },
{ label: 'Tree', value: 'tree' },
{ label: 'Image', value: 'image' },
{ label: 'File', value: 'file' },
{ label: 'Avatar', value: 'avatar' },
{ label: 'Video', value: 'video' },
{ label: 'Audio', value: 'audio' },
{ label: 'Formula (computed)', value: 'formula' },
{ label: 'Summary (rollup)', value: 'summary' },
{ label: 'Autonumber', value: 'autonumber' },
{ label: 'Composite (embedded)', value: 'composite' },
{ label: 'Repeater (embedded array)', value: 'repeater' },
{ label: 'Record (keyed map)', value: 'record' },
{ label: 'Location (GPS)', value: 'location' },
{ label: 'Address', value: 'address' },
{ label: 'Code', value: 'code' },
{ label: 'JSON', value: 'json' },
{ label: 'Color', value: 'color' },
{ label: 'Rating', value: 'rating' },
{ label: 'Slider', value: 'slider' },
{ label: 'Signature', value: 'signature' },
{ label: 'QR / Barcode', value: 'qrcode' },
{ label: 'Progress', value: 'progress' },
{ label: 'Tags', value: 'tags' },
{ label: 'Vector embedding', value: 'vector' },
],
},
{ field: 'description', type: 'textarea', helpText: 'Developer documentation for this column' },
{ field: 'required', type: 'boolean', helpText: 'Must be set on every record' },
{ field: 'unique', type: 'boolean', helpText: 'Disallow duplicate values' },
// `indexed` removed: a field-level index flag built no index and was
// pruned from FieldSchema in the 16.x line (#2377, ADR-0049).
// Declare the index in the object's `indexes[]` instead.
{ field: 'readonly', type: 'boolean', helpText: 'Visible but never user-editable' },
// `immutable` removed: never a FieldSchema key. The mechanism is the
// `readonlyWhen` predicate below.
{ field: 'hidden', type: 'boolean', helpText: 'Hidden from default UI' },
// `maskingRule` declared 2026-08-16 (#8993, ruled Option A): partial
// masking enforced by plugin-security's FieldMasker on read + export.
{ field: 'maskingRule', type: 'text', helpText: "Partial masking: preset ('phone', 'id_card', 'bank_account', 'email', 'name') or {\"keepHead\": n, \"keepTail\": m}. Masked unless the caller holds this field's requiredPermissions" },
{ field: 'searchable', type: 'boolean', helpText: 'Include in full-text search' },
{ field: 'sortable', type: 'boolean', helpText: 'Allow sorting on this column' },
// `filterable` removed: never a FieldSchema key (only `sortable` and
// `searchable` exist); every declared column is filterable.
{ field: 'defaultValue', type: 'text', helpText: 'Default value for new records (JSON literal)' },
// `placeholder` declared 2026-08-16 (#9019, ruled on objectui#4676):
// in-input hint text, distinct from `inlineHelpText` (always-visible
// help below the field) and `description` (tooltip).
{ field: 'placeholder', type: 'text', helpText: 'Hint text shown inside the empty input; disappears once a value is entered' },
// Text constraints
// #11566 — aligned to the bounded-string types the schema accepts
// `maxLength` on (BOUNDED_STRING_FIELD_TYPES — the write-time
// validator's list; maintainer ruling 2026-08-24). `code` was the
// one this list was missing. #11875 added `signature`/`qrcode`
// (the write seam now enforces their declared bound); this
// visibleWhen moves with the set.
{ field: 'maxLength', type: 'number', helpText: 'Max characters', visibleWhen: "data.type in ['text','textarea','email','url','phone','password','markdown','html','richtext','code','signature','qrcode']" },
// #11949 — `minLength` aligned to the same set (maintainer ruling
// 2026-08-25: the #11566 template applies in full). This row used
// to stop at 9 types (`code` was the one it was missing); it moves
// with the set, exactly like the row above.
{ field: 'minLength', type: 'number', helpText: 'Min characters', visibleWhen: "data.type in ['text','textarea','email','url','phone','password','markdown','html','richtext','code','signature','qrcode']" },
// #14168 (maintainer ruling 2026-09-02, option A) — `valueDomain`
// is shown for exactly the types the schema accepts it on
// (VALUE_DOMAIN_FIELD_TYPES in field.zod.ts — `text` alone); this
// visibleWhen moves with the set, and the offered choices are
// DERIVED from the vocabulary rather than re-typed here, so this
// control cannot become a second opinion on what the closed
// vocabulary is (the #12017 two-copies shape). Shown in the same
// stroke that the write path starts refusing a non-member and the
// liveness row flips `live` — declared = enforced = shown.
{
field: 'valueDomain',
type: 'select',
helpText: 'Standard the written value must belong to; a write carrying a non-member is refused',
visibleWhen: "data.type in ['text']",
options: VALUE_DOMAIN_OPTIONS,
},
// objectui#6140 (maintainer ruling 2026-08-25, Option A) — `rows`
// is shown for exactly the multiline editor types the schema
// accepts it on (MULTILINE_EDITOR_FIELD_TYPES in field.zod.ts);
// this visibleWhen moves with the set.
{ field: 'rows', type: 'number', helpText: 'Inline editor height (text rows)', visibleWhen: "data.type in ['textarea','markdown','html','richtext']" },
// Numeric constraints
{ field: 'min', type: 'number', helpText: 'Minimum value', visibleWhen: "data.type in ['number','currency','percent','rating','slider','progress']" },
{ field: 'max', type: 'number', helpText: 'Maximum value', visibleWhen: "data.type in ['number','currency','percent','rating','slider','progress']" },
{ field: 'precision', type: 'number', helpText: 'Total digits', visibleWhen: "data.type in ['number','currency','percent']" },
// #19629 (ruling 5791803339 B): `scale` is retired from `currency` and refused at parse, so it is not offered there.
{ field: 'scale', type: 'number', helpText: 'Decimal places', visibleWhen: "data.type in ['number','percent']" },
// Selection options
//
// The offered inputs are exactly `SelectOptionSchema`'s authorable
// keys, minus `visibleWhen` (a CEL predicate, not a repeater text
// input). An `icon` input used to sit between `color` and
// `description` and was withdrawn under ADR-0049 enforce-or-remove:
// the option shape is strict and has never declared `icon`, so a
// Lucide name typed there was an `unrecognized_keys` refusal at
// publish — the author found out at the 422, the same
// offer-vs-door class #11410 and commit c459da6bc retired elsewhere.
//
// Remove rather than declare, on a premise measured for THIS
// surface rather than inherited from #5016's action-param reading:
// objectui declares `icon` on `SelectOptionMetadata`, but no
// field-option render path READS it, on the pinned tree and on
// objectui's `main` alike, against a live positive control (the
// select cell renderer reads `option?.label` and `option?.color`);
// the read points are recorded in `packages/spec/liveness/field.json`,
// row `options`. Declaring it instead would be an accepted-set
// expansion, which needs a maintainer ruling.
// `field-rows-option-description.test.ts` pins both halves — the
// schema still refuses `icon`, and this list no longer offers it.
{
field: 'options',
type: 'repeater',
helpText: 'Available choices',
visibleWhen: "data.type in ['select','multiselect','radio','checkboxes']",
fields: [
{ field: 'label', label: 'Label', type: 'text', required: true },
{ field: 'value', label: 'Value', type: 'text', required: true },
{ field: 'color', label: 'Color', type: 'color' },
{ field: 'description', label: 'Description', type: 'text' },
// #23809 — the option's lifecycle category. Required on every
// option of the object's `stageField`; valid only on a
// single-value `select` / `radio`.
{
field: 'kind',
label: 'Kind',
type: 'select',
helpText: 'Lifecycle category (single-value select / radio only): a step on the way, the successful end, or the unsuccessful end. Required on every option of the stage field.',
options: [
{ label: 'Open', value: 'open' },
{ label: 'Won', value: 'won' },
{ label: 'Lost', value: 'lost' },
],
},
],
},
// Relational
// ONE shared row for the three reference-carrying types (#14892):
// the text carries the `tree` rule the schema enforces — optional,
// and if given this object — so the designer never invites the
// foreign target `ObjectSchema` refuses at publish.
{ field: 'reference', type: 'text', helpText: 'Target object name. For a tree field it is optional and, if given, must be this object (a tree is a hierarchy within its own object — link a different object with a lookup)', visibleWhen: "data.type in ['lookup','master_detail','tree']" },
// `lookupFilters`, not `referenceFilter`: an array of
// {field, operator, value} rules, not a CEL string.
{ field: 'lookupFilters', widget: 'json', helpText: 'Filter rules applied to the picker ({field, operator, value})', visibleWhen: "data.type in ['lookup','master_detail']" },
// `deleteBehavior`, not a `cascadeDelete` boolean: the schema models
// three outcomes, and only one of them is "cascade".
//
// TWO declarations of one key, with disjoint `visibleWhen` (#11410).
// #9689 made `set_null` on a `master_detail` a named parse-time
// rejection, so a single shared option list offered a choice the
// publish door refuses — the author found out at the 422. The split
// is the narrowest shape the form DSL already supports: field-level
// `visibleWhen` is what the metadata-admin renderer evaluates as
// `evaluatePredicate(visibility, { data: row })`, exactly as it does
// for every other type-conditional control in this repeater.
//
// Per-option `visibleWhen` (`SelectOptionSchema`, ADR-0068) would be
// the tighter-looking spelling and is deliberately NOT used: the
// metadata-admin renderer maps `fieldSpec.options` straight to select
// items and never reads it, so it would ship an ADR-0049
// declared-but-unenforced key. And on the runtime surface that DOES
// honor it, the per-option evaluator binds `record`, never `data` —
// a `data.`-rooted predicate there is an unbound identifier, and
// visibility fails OPEN, keeping the option. Either way the author
// would still be offered "Set null".
//
// ⚠️ The predicates must stay disjoint AND total over the types they
// serve (`lookup` and `user` on one, `master_detail` on the other):
// an overlap renders two selects writing one key, a gap makes the
// control vanish for that type. Both are pinned in
// `form-delete-behavior-options.test.ts`.
//
// `helpText` is deliberately IDENTICAL on both. The i18n bundle keys
// form fields by field PATH (`metadataForms.<type>.fields.<path>`),
// so these two declarations share one translation key — divergent
// text here would collide silently, last writer winning.
//
// `user` shares the `lookup` branch (#29415): since #29253 a
// declared `deleteBehavior` on a `user` field takes effect when the
// user is deleted, and all three outcomes are legal there. Unlike a
// `lookup`, a `user` field has no default (declaring nothing keeps
// it out of the delete walk), so the select writes a value only when
// the author picks one.
{ field: 'deleteBehavior', type: 'select', helpText: 'What happens when the referenced record is deleted', visibleWhen: "data.type in ['lookup','user']", options: [
{ label: 'Set null', value: 'set_null' },
{ label: 'Cascade (delete children)', value: 'cascade' },
{ label: 'Restrict (block the delete)', value: 'restrict' },
] },
// `master_detail`: no `set_null`. A detail row without its master is
// the orphan the master-detail relationship exists to prevent, so
// the schema refuses the combination outright (#9689).
{ field: 'deleteBehavior', type: 'select', helpText: 'What happens when the referenced record is deleted', visibleWhen: "data.type == 'master_detail'", options: [
{ label: 'Cascade (delete children)', value: 'cascade' },
{ label: 'Restrict (block the delete)', value: 'restrict' },
] },
// #35315 — the Change Owner cascade, beside `deleteBehavior`; the
// parse refuses the key on every other type. `helpText` matches the
// field form's row (one i18n key per field path).
{ field: 'transferBehavior', type: 'select', helpText: 'Whether Change Owner on the referenced record can also move the records that point at it through this field', visibleWhen: "data.type in ['lookup','master_detail']", options: [
{ label: 'None (stay with their owner)', value: 'none' },
{ label: 'Cascade (offer to move with the referenced record)', value: 'cascade' },
] },
{ field: 'multiple', type: 'boolean', helpText: 'Allow selecting multiple records', visibleWhen: "data.type in ['lookup']" },
// Formula / summary
// `expression`, not `formula` — the key is named for what it holds,
// not for the field type that uses it. Shown for every type, as the
// field designer's own row in `field.metadata-form.ts` is: `FieldSchema`
// accepts `expression` on any type, and on a non-formula field the
// engine computes and stores it on write (`planStoredExpressions`),
// so a formula-only row hid a live key on a stored field.
{ field: 'expression', type: 'code', language: 'expression', helpText: 'CEL expression the field\'s value is computed from. On a formula field: computed on read, no stored column. On any other field: computed by the engine from the row each write stores, and stored, so a client-sent value never stands.' },
// The six members are what `FieldSchema.returnType` declares, and
// the same explicit list the field designer's own control carries
// in `field.metadata-form.ts` (#19677). This grid additionally offered
// `datetime` and `currency`, so an author who added a formula field
// here and picked either wrote a value the parse refuses — the
// refusal arriving from the save door, naming a key they never
// typed. Declared-vs-enforced, one seam before that door.
// `currency` is declared since #22727 and offered again, in the
// same change as the enum; `percent` joined with #35047, in the
// same change as the enum; `datetime` is still refused.
{ field: 'returnType', type: 'select', helpText: 'Result type for formulas', visibleWhen: "data.type == 'formula'", options: [
{ label: 'Text', value: 'text' }, { label: 'Number', value: 'number' },
{ label: 'Boolean', value: 'boolean' }, { label: 'Date', value: 'date' },
{ label: 'Currency', value: 'currency' }, { label: 'Percent', value: 'percent' },
] },
// A roll-up is ONE key — `summaryOperations` {object, field, function}.
// The flat `summaryType` / `summaryField` pair named neither of them
// and also lost `object`, so a roll-up authored here saved nothing.
{
field: 'summaryOperations',
type: 'composite',
helpText: 'Roll-up: which child object, which field, which aggregation',
visibleWhen: "data.type == 'summary'",
fields: [
{ field: 'object', type: 'text', required: true, helpText: 'Source child object name' },
// Not `required`: a `count` saves without it (see field.metadata-form.ts).
{ field: 'field', type: 'text', helpText: 'Field on the child object to aggregate (ignored for count)' },
{ field: 'function', type: 'select', required: true, helpText: 'Aggregation function', options: [
{ label: 'Count', value: 'count' }, { label: 'Sum', value: 'sum' }, { label: 'Avg', value: 'avg' },
{ label: 'Min', value: 'min' }, { label: 'Max', value: 'max' },
] },
],
},
// Autonumber — `autonumberFormat`, not `displayFormat`. There is no
// `startingNumber`: the counter resets per rendered prefix, which the
// format string itself determines (e.g. AD{YYYYMMDD}{0000} resets daily).
{ field: 'autonumberFormat', type: 'text', helpText: 'e.g. "INV-{0000}"; date tokens {YYYY}/{MM}/{DD} and {field_name} interpolation supported', visibleWhen: "data.type == 'autonumber'" },
// Code language
{ field: 'language', type: 'text', helpText: 'Editor language (e.g. sql, javascript)', visibleWhen: "data.type == 'code'" },
// Governance. `validation` / `errorMessage` are not FieldSchema keys —
// a record-level predicate is a `validation` metadata item on the
// object, which carries its own message. `audit` / `pii` / `encrypted`
// named the `auditTrail` / `dataQuality` / `encryptionConfig` family
// pruned in 2026-06 as dead in both layers (see the FieldSchema
// tombstone); at-rest protection is `type: 'secret'`, not a flag.
// [#36482] Three-way, as on the field form: Default removes the key.
{ field: 'fieldHistory', widget: 'field-history', helpText: "Old → new values for this field on the record activity timeline. Default follows the platform: on for most types, off for a media, JSON or credential field. Off names the change by label only; On also shows a media or JSON field's values. A credential field never shows values, and the object's own Field History off wins." },
{ field: 'trackHistory', type: 'boolean', helpText: "Opt a media or JSON field (image, file, json, …) into old → new values on the activity timeline. Every other field shows them already, and off does not hide them: use Field History." },
{ field: 'visibleWhen', type: 'code', language: 'expression', helpText: 'CEL predicate — field is shown only when TRUE' },
{ field: 'readonlyWhen', type: 'code', language: 'expression', helpText: 'CEL predicate — field is read-only when TRUE (enforced server-side)' },
{ field: 'requiredWhen', type: 'code', language: 'expression', helpText: 'CEL predicate — field is required when TRUE (enforced server-side)' },
],
},
],
},
{
name: 'capabilities',
label: 'Capabilities',
description: 'System features and API exposure.',
collapsible: true,
collapsed: true,
fields: [
{
// The key is `enable` (ObjectCapabilities). This block named
// `capabilities` — a key ObjectSchema has never declared — so every
// toggle below was stripped on save and the section did nothing.
field: 'enable',
type: 'composite',
helpText: 'Enable/disable system features',
fields: [
{ field: 'trackHistory', type: 'boolean' },
{ field: 'fieldHistory', widget: 'field-history', helpText: "Old → new values of changed fields on the record activity timeline. Default is on. Off turns values off for the whole object, whatever a field says." },
{ field: 'searchable', type: 'boolean' },
{ field: 'apiEnabled', type: 'boolean' },
{ field: 'files', type: 'boolean' },
{ field: 'feeds', type: 'boolean' },
{ field: 'activities', type: 'boolean' },
{ field: 'clone', type: 'boolean' },
{
field: 'approvalsVisibleToReaders',
type: 'boolean',
helpText: 'Readers of a record see its approval requests and history, read-only, with no approval action',
},
],
},
],
},
{
name: 'advanced',
label: 'Advanced',
description: 'State machines, actions, and storage.',
collapsible: true,
collapsed: true,
fields: [
// #19085 — `validations` gets the row its declaration always implied.
// The served schema DECLARED the key and no form offered it, so an
// author's only door was the Source tab's free-text JSON. This section
// already advertises "State machines" in its description, and a state
// machine IS a `validations` member (ADR-0020) — the row was missing,
// not the section.
//
// The face is the `json` control rather than a schema-derived
// repeater, and that is a measurement, not a preference. The served
// node is an array whose items are a DOUBLE-HOP pointer
// (`items.$ref` → `$defs/__schema1` → `$defs/__schema2`) landing on a
// `oneOf` over the six ValidationRule members. A repeater would have
// to resolve both hops AND pick a union branch before it could render
// a row; neither half is measured for this node, and a repeater that
// resolves neither renders an empty row whose values never land — the
// offer-vs-door defect the reconciliation gate beside this file
// exists to catch. The Zod parse still refuses a malformed rule loudly
// at publish. Same treatment as the sibling structured-array rows
// `permission.rowLevelSecurity` and `email_template.variables`.
//
// ⚠ Precisely: `json` is in the metadata-admin renderer's passthrough
// set, but that set is consulted AFTER the structural fallbacks, ⛔ not
// instead of them — `resolveFieldFace` tries the widget registry, then
// an object form, then an array-of-objects, and only then the
// passthrough check. So this row reaches the raw-JSON editor today
// because the unresolved double-hop pointer derives nothing, ⛔ not
// because the hint suppresses derivation. Once the pin moves past
// objectui's pointer resolution the same hint on this node derives an
// `object-rows` repeater over the FIRST `oneOf` branch (`script`) —
// that is the renderer's precedence, not this repo's contract, and
// whoever bumps the pin owns re-measuring this row and its two
// shape-siblings named above.
//
// Upgrading this to a structured control is a form-face addition — the
// same boundary the reconciliation ledger draws for the
// `lifecycle.*.onlyWhen` rows — ⛔ not a reconciliation, and not this
// row's price of admission.
{ field: 'validations', widget: 'json', helpText: 'Object-level validation rules — an array of rule objects, e.g. [{ "type": "script", "name": "amount_positive", "condition": "amount > 0", "message": "Amount must be positive" }]. State-machine transition tables are declared here too (ADR-0020)' },
// The whole-record hand lock (the object level of a field's
// `uiReadonlyWhen`, the two-tier field-lock model), beside the state
// machine it usually follows: the same CEL code row the field form
// gives the field key.
{ field: 'uiReadonlyWhen', type: 'code', language: 'expression', colSpan: 2, helpText: "CEL predicate over the record (e.g. record.status in ['confirmed', 'done']) — while it is TRUE, people cannot edit any field of an existing record anywhere in the console (the edit dialog, the record page, grids, kanban, calendar and Gantt drag, the timesheet); a new record's create dialog is not judged. A field that sets its own hand lock (uiReadonly turned on, or uiReadonlyWhen) is judged by that instead, so uiReadonlyWhen: false on a field keeps it editable; uiReadonly turned off does not, and the field follows this lock. Actions, imports, the API and flows still write every field, judged by the object's validations. Reads the record's own columns. The in-app assistant acting for a person does not honour it yet." },
// #19332 (flight G2b of ruling record 5861442317) — the object's
// declarative timeline milestones (ADR-0052 §5b.2), beside `validations`:
// a milestone fires on a field reaching a value, the same transition a
// `state_machine` rule above governs. A repeater with declared sub-rows,
// the `fieldGroups` repeater's face, over the four keys the entry schema
// has, all plain text, as plugin-audit reads them
// (`audit-writers.ts` `matchMilestone` / `renderMilestoneSummary`).
//
// `field` pins `widget: 'text'`, and that is a measurement, not a
// preference: with no `widget`, objectui's name convention turns a
// string sub-row named `field` into the `field-ref` picker, whose catalog
// an object draft never fills (it names no `object` / `objectName` /
// `data.object` / `interfaceConfig.source`), so the picker would offer
// only "None" and a new milestone could not name its field. An explicit
// `widget` skips the name convention; `text` is a passthrough hint, so
// the face is the plain text input.
//
// No authoring door judges `field` or a `{token}` of `summary`: not the
// parse, not the publish door, not `os validate`
// (`validate-object-field-refs` leaves `activityMilestones[].field` out
// by name). The help text claims what the runtime does with a miss.
{
field: 'activityMilestones',
type: 'repeater',
helpText: 'Timeline entries fired by a field reaching a value (ADR-0052 §5b.2): when an update moves the watched field into the value, the audit plugin writes the milestone\'s summary to the record\'s activity timeline instead of the field-change entry. The first milestone that matches wins.',
fields: [
{ field: 'field', label: 'Field', widget: 'text', required: true, helpText: 'Name of the field to watch on this object (e.g. status). Nothing checks it when you save or publish: a name that is not a field of this object never fires.' },
{ field: 'value', label: 'Value', type: 'text', required: true, helpText: 'The stored value the field must change into, compared exactly as text — for a select field the option value, not its label (e.g. done). A milestone on a number or boolean field never fires.' },
{ field: 'summary', label: 'Summary', type: 'text', required: true, helpText: 'Timeline text (e.g. "Deal won: {name}"). A {field_name} token takes the record\'s value after the update, and the token of a lookup, master-detail or user field shows the referenced record\'s title; a token that names no field renders empty.' },
{ field: 'type', label: 'Type', type: 'text', helpText: 'Activity type of the timeline entry: a built-in kind such as completed, or your own word, stored as written. Unset: updated.' },
],
},
{ field: 'datasource', type: 'text', helpText: 'Target datasource ID (default: "default")' },
// #19332 (flight G2a of ruling record 5861442317) — the object's declared
// indexes, beside `datasource`: storage. A repeater with declared
// sub-rows, as `fieldGroups` above, over the three keys the driver reads
// (`name`, `fields`, `unique`); `type` and `partial` are tombstones and
// need no row.
//
// `fields` is a free-text list, the `highlightFields` row's face. The
// schema parse, so a draft save, does not judge its names. Publishing and
// `os validate` refuse one that is not a field of this object
// (`object-field-ref-unknown`, `error`, since #20432). The SQL driver's
// `syncDeclaredIndexes` skips an index naming a column the table does
// not have, logging an error (the durability channel, since #20432),
// which is what still befalls a real field that is not a stored column
// (a formula). The help text claims exactly those three.
//
// `unique` is a select over `global` / `organization` ONLY, as the
// ruling says. The node is `boolean | 'global' | 'organization'`: a
// derived face takes the union's first arm, the boolean, and would offer
// a switch that writes the deprecated bare `true`; and no option can
// spell a boolean anyway (`FormSelectOptionSchema.value` is a lowercase
// identifier). So the select writes only the two scopes the parse
// accepts now and after protocol 18. A stored `true` / `false` is shown
// by no option, and it is not rewritten: an edit merges into the stored
// entry, so `unique` changes only when the author picks a scope.
{
field: 'indexes',
type: 'repeater',
helpText: 'Database indexes on this object\'s table. The SQL driver creates each one the table lacks when it syncs the table; a sync never drops an index.',
fields: [
{ field: 'name', label: 'Name', type: 'text', helpText: 'Physical index name. Unset: generated from the table and the columns (e.g. idx_task_status).' },
{ field: 'fields', label: 'Fields', widget: 'string-tags', required: true, helpText: 'Column names of this object, in key order (e.g. status, owner). Saving does not check them; publishing and os validate refuse a name that is not a field of this object. A field that is not a stored column (a formula, say) makes the SQL driver skip the whole index, with an error in the server log.' },
{ field: 'unique', label: 'Unique', type: 'select', helpText: 'Uniqueness scope (ADR-0120). Unset: not unique. The deprecated bare true (it means global) is not offered; an index that carries it keeps it until you pick a scope.', options: [
{ label: 'Global — one holder across the installation, over exactly these columns', value: 'global' },
{ label: 'Organization — one holder per organization (the driver prepends the organization column)', value: 'organization' },
] },
],
},
// #19331 — five more declared scalars with no control. Each enum gets an
// explicit `options` list because the bare member reads as a word and
// the choice it stands for is a security or lifecycle contract; the copy
// states what the runtime does with the value, including what ABSENCE
// resolves to, which is the half an author cannot see from the enum.
{ field: 'ownership', type: 'select', helpText: 'Record-ownership model. Absent resolves to user.', options: [
{ label: 'User — reassignable owner_id plus owning_business_unit_id', value: 'user' },
{ label: 'Business unit — owning_business_unit_id only, no owner_id', value: 'business_unit' },
{ label: 'Organization', value: 'org' },
{ label: 'None — no per-record owner, neither anchor', value: 'none' },
] },
{ field: 'sharingModel', type: 'select', helpText: 'Org-Wide Default record visibility for internal users. A custom object that omits it resolves to private at runtime (ADR-0090 D1).', options: [
{ label: 'Private — owner only', value: 'private' },
{ label: 'Public read — everyone reads, owner writes', value: 'public_read' },
{ label: 'Public read/write — everyone reads and writes', value: 'public_read_write' },
{ label: 'Controlled by parent — derived from the master record', value: 'controlled_by_parent' },
] },
// [ADR-0055 §3 amendment · ruling 6398566164] The per-object sharing
// opt-ins, beside the OWD they refine. A composite over the one nested
// block, each sub-row declared so its label and help text reach the
// translation catalogs; the one leaf is a switch, the `enable` toggles'
// face. The help text states what the runtime does with the value and
// what its absence resolves to, the half an author cannot see from the
// schema.
{
field: 'sharing',
type: 'composite',
helpText: 'Per-object sharing opt-ins that refine the org-wide default above; they never replace it. Unset: the default of each opt-in applies.',
fields: [
{
field: 'controlledByParent',
label: 'Controlled by parent',
type: 'composite',
helpText: "Read only while sharingModel is 'controlled by parent'; refused on any other sharing model.",
fields: [
{ field: 'ownerMayEdit', label: 'Owner may edit', type: 'boolean', helpText: "On: the owner of a detail row (its owner_id) may update that row by id with read access to the master; everyone else, and every insert, delete, multi-row update and on-behalf-of write, still needs edit access to the master. Off (the default): every write of a detail needs edit access to its master." },
// [ADR-0055 §3 as amended for #33250 · ruling A+] The second opt-in of the block.
{ field: 'writeRequiresMasterRead', label: 'Read on master is enough to write', type: 'boolean', helpText: "On: anyone who can read the master may insert, update and delete detail rows, as the detail's own permissions, row-level security and field-level security allow. Off (the default): every write of a detail needs edit access to its master. Do not turn on together with Owner may edit, which this already covers." },
],
},
],
},
// #20349 — the two ADR-0066 access keys, beside `sharingModel`, the third
// leg of the same story (grant coverage, capability gate, record
// visibility).
//
// `access` is a strict object with ONE enum member, both of whose values
// are spellable option values, so it takes the `lifecycle` row's face: a
// composite over a select. The sub-row is declared rather than derived
// so its label and help text reach the translation catalogs, which a
// schema-derived sub-field never does.
{
field: 'access',
type: 'composite',
helpText: "Wildcard-grant posture (ADR-0066 D2). Absent resolves to public. It decides whether a permission set's '*' object grant covers this object; record visibility between users is sharingModel.",
fields: [
{ field: 'default', type: 'select', helpText: "public: covered by '*' wildcard grants. private: needs an explicit per-object grant, and is exempt from wildcard row-level security.", options: [
{ label: 'Public — covered by wildcard (*) grants', value: 'public' },
{ label: 'Private — needs an explicit per-object grant', value: 'private' },
] },
],
},
// `requiredPermissions` is a UNION — `string[]` or a strict
// `{read, create, update, delete}` map — so it takes `json`, the
// `validations` row's hint, and ⛔ never `string-tags`: that widget reads
// a non-array as `[]` and its first edit writes the list back, so a
// stored per-operation map would be silently replaced. `json` is not a
// registered widget, so the renderer resolves the face from the stored
// value's union branch instead: a stored map renders the map's four
// sub-keys and an edit merges into the stored object, a stored list
// renders a list input. On a create the first branch (the list)
// renders; the map arm is written in source or reached once stored.
{ field: 'requiredPermissions', widget: 'json', helpText: 'Capabilities (permission-set systemPermissions) a caller must hold to reach this object, checked in addition to CRUD grants (ADR-0066 D3). A list gates every operation; a {read, create, update, delete} map gates only the operations it lists. Absent or empty: no capability gate.' },
// #19332 (flight G2b of ruling record 5861442317) — the share-LINK policy,
// after the three principal-access rows above: `sharingModel` shares with
// named principals, this block with whoever holds a link. A composite
// with declared sub-rows, the `access` / `lifecycle` face, over all six
// keys of the strict block, each read by plugin-sharing
// (`share-link-service.ts` `getPolicy`, `createLink`, `resolveToken`):
//
// - `enabled` a switch, the `enable` toggles' face.
// - `allowedAudiences` / `allowedPermissions` are arrays of an enum
// whose members are all spellable option values, so they take the
// `multiselect` widget objectui derives for an array of enum (the
// derived `appearance.allowedVisualizations` of the view and page
// forms), declared here so each choice carries a label. It writes
// nothing when every choice is cleared, so the form cannot store the
// empty list the service reads as "any audience".
// - `maxExpiryDays` a number, `min` the schema's positive integer.
// - `redactFields` a free-text list, the `highlightFields` face and for
// the same reason (`field-multi` has no catalog on an object draft).
// It pins its widget on purpose: a string list named `*Fields` is
// otherwise turned into that very picker by objectui's name
// convention. A misspelt entry is refused at publish
// (`object-field-ref-unknown`, `error`), and by `os validate`.
// - `eligibility` a plain CEL string (not an ADR-0089 envelope), the
// `type: 'code'` / `language: 'expression'` predicate rows' face.
{
field: 'publicSharing',
type: 'composite',
helpText: 'Share-link policy: whether records of this object can be published through a link that anyone holding it opens, and on what terms. Separate from sharingModel, which shares with named users and teams. Unset or off: no link can be created, and none opens.',
fields: [
{ field: 'enabled', label: 'Enabled', type: 'boolean', helpText: 'Allow share links for this object\'s records. Checked on every redemption: switching it off stops every existing link from opening, and switching it back on serves them again. Off (the default): nothing else here applies.' },
{ field: 'allowedAudiences', label: 'Allowed Audiences', widget: 'multiselect', helpText: 'Audiences a new link may name; any other is refused. Unset: link only. Every audience still needs the link itself: signed in also needs a signed-in user, and email also needs the recipient\'s address on the link\'s list.', options: [
{ label: 'Public', value: 'public' },
{ label: 'Link only — anyone with the link', value: 'link_only' },
{ label: 'Signed in — signed-in users with the link', value: 'signed_in' },
{ label: 'Email — listed recipients with the link', value: 'email' },
] },
{ field: 'allowedPermissions', label: 'Allowed Permissions', widget: 'multiselect', helpText: 'Permission levels a new link may grant; any other is refused. Unset: view only.', options: [
{ label: 'View', value: 'view' },
{ label: 'Comment', value: 'comment' },
{ label: 'Edit', value: 'edit' },
] },
{ field: 'maxExpiryDays', label: 'Max Expiry Days', type: 'number', min: 1, helpText: 'Latest expiry a new link may request, in days from now; a later one is refused. Unset: 365. It does not force an expiry: a link created without one never expires.' },
{ field: 'redactFields', label: 'Redact Fields', widget: 'string-tags', helpText: 'Field names of this object removed from every record a link serves, whatever the audience; the owner\'s own access is unaffected. A name that is not a field of this object is refused at publish.' },
{ field: 'eligibility', label: 'Eligibility', type: 'code', language: 'expression', helpText: 'CEL predicate over the record (e.g. record.status == \'published\'): a link is created only while it is TRUE, and an existing link stops opening once its record no longer qualifies. A predicate that does not compile, or faults, refuses the link.' },
],
},
// No inline `options` here, and that is a CONSTRAINT rather than a
// preference: `FormSelectOptionSchema.value` is a system identifier
// (`^[a-z][a-z0-9_.]*$`), so the four hyphenated members of this enum —
// `system-data`, `engine-owned`, `append-only`, `better-auth` — cannot be
// spelled as option values at all. The enum derives from the served JSON
// Schema, which carries every member verbatim, and the meanings ride the
// help text instead of a list the form face would refuse.
{ field: 'managedBy', helpText: 'Lifecycle bucket: platform (user CRUD), config (admin authored), system-data (platform-defined schema with admin/user-writable data), engine-owned (no user writes), append-only (audit), better-auth (identity). UI clients derive their CRUD affordances from it, so it decides what a user is offered on records of this object.' },
// #19332 (flight G2b of ruling record 5861442317) — the per-entry override
// of the matrix `managedBy` above resolves (`resolveCrudAffordances`),
// so it sits directly under it. A composite with declared sub-rows over
// all six keys of the strict block (its alias and guidance words —
// `new`, `export`, the VIEW block's `sort`, … — are refusals, not keys).
//
// `create` / `import` / `edit` / `delete` are each a UNION — a boolean,
// or a strict `{ enabled, visibleWhen, disabledWhen }` object — so the
// ruling's union rule applies: `json`, ⛔ never a face that can only
// write one arm. `json` is not a registered widget, so objectui resolves
// the face from the stored value's union branch: a stored boolean or a
// new entry (the first arm) renders a switch, and a stored object
// renders its three keys, whose edits merge into it. The object arm is
// therefore written in source and edited here once stored. `exportCsv` is
// a plain boolean, the `enable` toggles' face. `transfer` (the Change Owner
// switch, ruling 7000907189 point 1) is the same union as the four CRUD
// entries, so it takes their `json` face.
//
// A switch reads `false` for an unset entry, which is not what the
// resolved default says for most buckets, so the composite's help text
// states the defaults the switch cannot show.
{
field: 'userActions',
type: 'composite',
helpText: 'Which generic entries (New, Import, Edit, Delete, Export) UI clients offer on this object\'s records, overriding the managedBy default one entry at a time. An unset entry keeps that default: platform offers all five; config and system-data all but Import; engine-owned, append-only and better-auth only Export. An untouched switch writes nothing, so it reads off even where the default offers the entry. On an engine-owned or append-only object, turning an entry on also lets users make that write through the data API. Users still need the matching permission. Change Owner is not part of that matrix: its default follows the sharing model (see its entry).',
fields: [
{ field: 'create', label: 'Create', widget: 'json', helpText: 'The New button: on shows it, off hides it. A stored {enabled, visibleWhen, disabledWhen} object is edited key by key; write one in source to gate the button on the record in scope, evaluated once per toolbar (the host record on a related list).' },
{ field: 'import', label: 'Import', widget: 'json', helpText: 'The CSV import entry: on shows it, off hides it. A stored {enabled, visibleWhen, disabledWhen} object is edited key by key; write one in source to gate the entry on the record in scope, evaluated once per toolbar.' },
{ field: 'edit', label: 'Edit', widget: 'json', helpText: 'Editing existing records, inline and in the form: on offers it, off hides it. A stored {enabled, visibleWhen, disabledWhen} object is edited key by key; write one in source to gate each row on its own record.' },
{ field: 'delete', label: 'Delete', widget: 'json', helpText: 'Row and bulk delete: on offers it, off hides it. A stored {enabled, visibleWhen, disabledWhen} object is edited key by key; write one in source to gate each row on its own record.' },
{ field: 'exportCsv', label: 'Export CSV', type: 'boolean', helpText: 'The Export entry that downloads this object\'s data (CSV, XLSX or JSON) on its grids, list views and dataset reports: on shows it, off hides it. A Gantt chart\'s PNG / PDF export is not covered. Unset: shown, since every managedBy bucket offers export. It is not a permission: who may export is the permission set\'s allowExport.' },
{ field: 'transfer', label: 'Change Owner', widget: 'json', helpText: 'The Change Owner action, single and bulk: on offers it, off hides it. Unset: on, except off on a controlled_by_parent detail. Offered only on an object whose records have a reassignable owner (ownership user or unset, no managedBy, not a sys_ object, owner_id not readonly and, on an external object, declared or mapped); turning it on anywhere else is refused. It gates the action only, not a plain edit of owner_id. A stored {enabled, visibleWhen, disabledWhen} object is edited key by key; write one in source to gate the action on each record.' },
],
},
// [#36366] The action layout per scope. Each arm is an object of two
// name lists (`pinned`, `more`), edited as JSON; the design mode edits
// it on the page.
{
field: 'actionLayout',
type: 'composite',
helpText: 'The order of this object\'s actions and which are buttons, per scope: pinned (at most 3 buttons, in order) and more (the More menu\'s order; an action named in neither follows in its default order). Unset: each surface picks its buttons by the actions\' order, as before.',
fields: [
{ field: 'list', label: 'List', widget: 'json', helpText: 'The list page toolbar, as {"pinned": [...], "more": [...]}: action names placed on the list toolbar; $import / $export only in pinned. At most 3 pinned. Not pinned, the page still draws its own Import / Export menu. os validate refuses a name that is no action of this object or is not placed on the list toolbar; such a name draws nothing.' },
{ field: 'record', label: 'Record', widget: 'json', helpText: 'The record header (record page, side preview, phone bar), as {"pinned": [...], "more": [...]}: action names placed in the record header or its More menu. At most 3 pinned. os validate refuses a name that is no action of this object or is not placed on the record page; such a name draws nothing.' },
],
},
{ field: 'editMode', type: 'select', helpText: "Edit-interaction intent for records of this object. Absent, the renderer picks its own default. Cross-renderer intent, not styling.", options: [
{ label: 'Modal — edit form as a dialog over the current view', value: 'modal' },
{ label: 'Page — navigate to a dedicated full-page edit route', value: 'page' },
] },
{ field: 'fileAccessDelegate', type: 'text', helpText: "Kernel service that authorizes downloads of files owned by this object's media fields, and decides whether a reader who may not read sys_file sees their name, size and type in a record read of this object (asked once per owning record on each such read), instead of testing whether the caller can read the owning row. For objects whose access is mediated by a service. Fails closed." },
{
field: 'lifecycle',
type: 'composite',
helpText:
'Data lifecycle contract (ADR-0057): how long rows live and how space is reclaimed. Leave empty for permanent record semantics. Non-record classes require at least one bounding policy (retention, TTL, or rotation).',
fields: [
{
field: 'class',
type: 'select',
helpText: 'Persistence contract for the rows of this object',
options: [
{ label: 'Record (business truth — permanent)', value: 'record' },
{ label: 'Audit (compliance ledger — retain → archive → delete)', value: 'audit' },
{ label: 'Telemetry (high-frequency log — short retention)', value: 'telemetry' },
{ label: 'Transient (ephemeral state — TTL expiry)', value: 'transient' },
{ label: 'Event (bus messages — very short TTL)', value: 'event' },
],
},
{
field: 'retention',
type: 'composite',
helpText: 'Age-based retention window',
fields: [
{ field: 'maxAge', type: 'text', helpText: 'Rows older than this (by created_at) are reaped. Duration literal: h/d/w/y, e.g. "30d"' },
],
},
{
field: 'ttl',
type: 'composite',
helpText: 'Per-row TTL expiry',
fields: [
{ field: 'field', type: 'text', helpText: 'Timestamp field the TTL is measured from (e.g. expires_at)' },
{ field: 'expireAfter', type: 'text', helpText: 'Rows expire this long after the field, e.g. "1d"' },
],
},
{
field: 'storage',
type: 'composite',
helpText: 'Physical rotation for high-frequency telemetry (SQLite: O(1) shard DROP)',
fields: [
{
field: 'strategy',
type: 'select',
helpText: 'Storage strategy',
options: [{ label: 'Rotation (time-shard + drop oldest)', value: 'rotation' }],
},
{ field: 'shards', type: 'number', min: 2, helpText: 'Shards retained; total window = shards × unit' },
{
field: 'unit',
type: 'select',
helpText: 'Time width of one shard',
options: [
{ label: 'Day', value: 'day' },
{ label: 'Week', value: 'week' },
{ label: 'Month', value: 'month' },
],
},
],
},
{
field: 'archive',
type: 'composite',
helpText: 'Cold-store hand-off (audit class). Rows are never hot-deleted before the archive copy succeeded.',
fields: [
{ field: 'after', type: 'text', helpText: 'Archive rows older than this — must equal retention.maxAge' },
{ field: 'to', type: 'text', helpText: 'Target datasource name for cold storage' },
{ field: 'keep', type: 'text', helpText: 'How long the archive keeps rows (empty = forever), e.g. "7y"' },
],
},
{ field: 'reclaim', type: 'boolean', helpText: 'Reclaim driver space after sweeps (default on for non-record classes)' },
],
},
],
},
],
});