Skip to content

Commit 22414cf

Browse files
committed
docs(spec,lint): composite/repeater are untyped JSON; route a typed list to a child object with inlineEdit grid
Claude-Session: https://claude.ai/code/session_01T2U7eGg8aRTpJ8kKXxDiog Co-authored-by: Claude <noreply@anthropic.com>
1 parent adc1b3f commit 22414cf

10 files changed

Lines changed: 69 additions & 20 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/lint': minor
4+
---
5+
6+
feat(spec,lint): object-level `composite` / `repeater` are untyped JSON — a typed list is a child object
7+
8+
Clause-②: no
9+
Metadata-protocol: semantic
10+
Ruling-ref: 6386744473
11+
12+
On an object field, `composite` and `repeater` are untyped JSON containers of CMS lineage (a Strapi component, an ACF group or repeater). The `FieldType` comments used to promise "declared sub-fields", but `FieldSchema` has no member that declares them, so nothing gave the inner keys labels, types, options, required flags or translations, and nothing could validate or address one row. The comments and the field-types docs now say so, and point a list that needs typed columns to a child object: a `master_detail` field pointing back at the parent, with `inlineEdit: 'grid'` to edit the rows inline on the parent's form.
13+
14+
The strict field schema already refused `fields`, `subFields` and `columns` on a field, but named only the key. The refusal now names the route: a typed list is a child object (`columns` also names the live `lookupColumns`, `relatedListColumns` and `inlineColumns`). This changes the message, not what parses.
15+
16+
New `@objectstack/lint` rule `field/embedded-sub-fields` (error): a `composite` / `repeater` object field carrying `fields`, `subFields` or `columns`. It fires on the doors that never parse (`os lint` on a raw object-literal config, `defineStack(x, { strict: false })`, the metadata-generation rubric); every parsed door refuses the field first. `os explain field/embedded-sub-fields` prints the reasoning. A form view's `fields` sub-rows and the Studio metadata forms are not judged.
17+
18+
What to do: nothing for a field that declares no sub-field key — the type is unchanged. A field that carried one never parsed under `defineStack`; model the list as a child object.

‎content/docs/data-modeling/field-types.mdx‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,18 +511,43 @@ guarantee as a separate requirement to satisfy explicitly, not something
511511
512512
These types store structured values as JSON on the parent row — no separate table or foreign key.
513513
514+
<Callout type="warn">
515+
On an object field, `composite` and `repeater` are **untyped JSON** containers of CMS lineage (similar
516+
to a Strapi component, an ACF group or an ACF repeater). A field declares no sub-fields: `fields`,
517+
`subFields` and `columns` are refused on the field, so nothing gives the inner keys labels, types,
518+
options, required flags or translations, and nothing validates or addresses a single row.
519+
520+
**A list that needs typed columns is a child object** with a [`master_detail`](#master_detail) field
521+
pointing back at the parent — the shape Salesforce, Dynamics, ServiceNow and Odoo use for line items.
522+
The child's own fields carry the types and validation, `inlineEdit: 'grid'` edits the rows as an
523+
inline grid on the parent's form, and every row is a record a lookup, a roll-up or a flow can reach.
524+
</Callout>
525+
514526
### `composite`
515-
Single embedded sub-object with declared sub-fields (similar to a Strapi component / ACF group).
527+
A single embedded JSON object, untyped — no declared sub-fields.
516528
517529
```typescript
518530
{ name: 'dimensions', label: 'Dimensions', type: 'composite' }
519531
```
520532
521533
### `repeater`
522-
Repeating embedded sub-object array with declared sub-fields (similar to a Strapi repeatable component / ACF repeater).
534+
An array of embedded JSON objects, untyped — no declared sub-fields or columns. For typed rows, use a
535+
child object (see above).
523536
524537
```typescript
525-
{ name: 'line_items', label: 'Line Items', type: 'repeater' }
538+
{ name: 'import_log', label: 'Import Log', type: 'repeater' }
539+
```
540+
541+
```typescript
542+
// A typed list: a child object, edited inline on the parent's form
543+
{
544+
name: 'invoice_line',
545+
fields: {
546+
invoice: { type: 'master_detail', reference: 'invoice', required: true, deleteBehavior: 'cascade', inlineEdit: 'grid' },
547+
product: { type: 'text', label: 'Product' },
548+
quantity: { type: 'number', label: 'Quantity' },
549+
},
550+
}
526551
```
527552
528553
### `record`

‎content/docs/data-modeling/validation-rules.mdx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@ application-level emptiness check is needed.
391391
## Embedded Structured Types
392392

393393
These types store structured values as JSON on the parent row — no separate table and no
394-
foreign key. Sub-field shapes are declared on the field, and the stored value is validated
395-
as an open object map (`valueSchemaFor`), so sub-keys are not constrained by the field type
396-
itself.
394+
foreign key. A `composite` / `repeater` field declares no sub-fields (`fields`, `subFields` and
395+
`columns` are refused on it), and the stored value is validated as an open object map
396+
(`valueSchemaFor`), so sub-keys are not constrained at all. A list that needs typed, validated
397+
columns is a child object with a `master_detail` field — see
398+
[Embedded Structured Types](/docs/data-modeling/field-types#embedded-structured-types).
397399

398400
### `composite`
399401

‎content/docs/protocol/objectui/layout-dsl.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,10 @@ sections:
465465

466466
Both examples were doing something the declared shape already does — see the
467467
replacement below. For a value that is genuinely one composite thing rather
468-
than neighbouring fields, the grouping belongs on the **field**: a field of
469-
type `address` (or `composite`) carries its own `fields` list.
468+
than neighbouring fields, the grouping belongs on the **field**: a form field of
469+
type `address` (or `composite`) carries its own `fields` list. That list is the
470+
form's; the object field itself declares no sub-fields (see
471+
[Embedded Structured Types](/docs/data-modeling/field-types#embedded-structured-types)).
470472
</Callout>
471473

472474
Fields sit on the same row because the section says how many columns it has, and

‎packages/lint/src/data-model-rules.embedded-sub-fields.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('field/embedded-sub-fields — one-line verdict, `os explain` carries t
107107
'untyped JSON',
108108
'child object',
109109
'`master_detail`',
110-
'inline related list',
110+
'inline grid',
111111
'form view',
112112
'refuses all three keys at the parse',
113113
'never parse',

‎packages/lint/src/data-model-rules.fix-lines.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ describe('[#22161] data-model-rules.ts — one remedy line per fix', () => {
175175

176176
it('field/embedded-sub-fields: one line, whatever the type, the keys or the names', () => {
177177
const fix =
178-
'Make the typed list a child object whose `master_detail` field points back here (an inline ' +
179-
'related list), and remove the key.';
178+
'Make the typed list a child object whose `master_detail` field points back here ' +
179+
"(`inlineEdit: 'grid'` edits it inline), and remove the key.";
180180
for (const type of ['repeater', 'composite']) {
181181
const objects = [
182182
{

‎packages/lint/src/data-model-rules.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,8 @@ export function lintDataModel(objects: any[]): LintIssue[] {
835835
`object-level ${type} is untyped JSON with no sub-fields`,
836836
path: `${fieldPath}.${declared[0]}`,
837837
fix:
838-
'Make the typed list a child object whose `master_detail` field points back here (an inline ' +
839-
'related list), and remove the key.',
838+
'Make the typed list a child object whose `master_detail` field points back here ' +
839+
"(`inlineEdit: 'grid'` edits it inline), and remove the key.",
840840
});
841841
}
842842
}

‎packages/lint/src/rule-explanations.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,11 +2947,11 @@ const FIELD_EMBEDDED_SUB_FIELDS_EXPLANATION: RuleExplanation = {
29472947
'and nothing — a flow included — can address a single row. Declaring `fields`, `subFields` ' +
29482948
'or `columns` on one promises a typed list the platform does not build.',
29492949
'A list that needs typed columns is a child object: its own fields carry the types, labels, ' +
2950-
'options and validation, a `master_detail` field on it points back at the parent, and the ' +
2951-
'parent\'s record page shows the children as an inline related list, editable in place with ' +
2952-
'`inlineEdit` on that field. Each row then has a record identity that a lookup, a roll-up or a ' +
2953-
'flow can reach. Keep a `composite` / `repeater` only for JSON whose shape the platform does ' +
2954-
'not need to know.',
2950+
'options and validation, and a `master_detail` field on it points back at the parent. The ' +
2951+
'parent\'s record page lists the children as a related list, and `inlineEdit: \'grid\'` on that ' +
2952+
'field edits them as an inline grid on the parent\'s form. Each row then has a record identity ' +
2953+
'that a lookup, a roll-up or a flow can reach. Keep a `composite` / `repeater` only for JSON ' +
2954+
'whose shape the platform does not need to know.',
29552955
'Not judged: a form view\'s `fields` sub-rows and the metadata forms Studio renders — those are ' +
29562956
'other schemas that do declare sub-rows.',
29572957
'Reach: the strict field schema refuses all three keys at the parse with this same route, so ' +

‎packages/spec/src/data/authoring-key-lint.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ export interface UnknownAuthoringKeyFinding {
7979
const EMBEDDED_JSON_TYPED_LIST =
8080
'An object-level `composite` / `repeater` stores untyped JSON — no per-column labels, types, '
8181
+ 'options or required flags. A list that needs typed columns is a child object whose '
82-
+ '`master_detail` field points back at this object, shown on the record as an inline related list.';
82+
+ '`master_detail` field points back at this object; `inlineEdit: \'grid\'` on that field edits '
83+
+ 'its rows as an inline grid on this object\'s form.';
8384

8485
/**
8586
* Semantic near-misses on `FieldSchema` — a different **word** for the same

‎packages/spec/src/data/field.zod.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export const FieldType = z.enum([
9797
// (≈ Strapi component / ACF group / ACF repeater): `FieldSchema` declares no sub-field
9898
// member, so nothing types, labels, validates or addresses the inner keys or rows.
9999
// A list that needs typed columns is a CHILD OBJECT whose `master_detail` field points
100-
// back at the parent, shown on the record as an inline related list (ruling 6386744473).
100+
// back at the parent; `inlineEdit: 'grid'` edits its rows inline on the parent's form
101+
// (ruling 6386744473).
101102
// A form view's `fields` sub-rows (`ui/view.zod.ts`) are a different surface.
102103
'composite', // Single embedded JSON object, untyped — no declared sub-fields
103104
'repeater', // Array of embedded JSON objects, untyped — no declared sub-fields or columns

0 commit comments

Comments
 (0)