Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/form-subforms-retirement-tidy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@objectstack/spec': patch
---

Clause-②: no
Metadata-protocol: none

The upgrade text around the retired form `subforms` key now names the same remedy for a lookup child as the stack's own refusal. The `form.subforms` parse prescription and the protocol-19 `ui-form-view-subforms-retired` entry say that a field group places only a body table: a lookup child's foreign key declares `relatedList: 'primary'` (a `master_detail` key that declares no `relatedList` needs nothing), or the stack refuses the group. The protocol-18 `ui-form-view-type-layout-only` entry no longer points readers at `subforms` for child records entered with the parent; it names the field group's `relatedList` instead. Nothing an author can write changes.
4 changes: 2 additions & 2 deletions content/docs/references/ui/view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Column footer summary configuration
| **modalSize** | `never` | optional | [REMOVED] `view.form.modalSize` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no form view opens in a dialog, so nothing reads it from a form view. Delete the key: the console's New and Edit dialogs lay a record out by the object's `fieldGroups` and choose their own size, a form opened by name gets a page of its own, and the React `ObjectForm` block keeps its own `modalSize` prop for the modal it opens with `formType='modal'`. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. |
| **sections** | `{ name?: string; label?: string \| Record<string, string>; description?: string; collapsible?: boolean; … }[]` | optional | |
| **groups** | `{ name?: string; label?: string \| Record<string, string>; description?: string; collapsible?: boolean; … }[]` | optional | [LEGACY ALIAS → `sections`] Accepted for back-compat and folded onto `sections` at parse; `sections` wins when both are present. Prefer `sections`. |
| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. |
| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. A group places only a body table: a lookup child's FK declares `relatedList: 'primary'` (a master_detail FK that declares no `relatedList` needs nothing), or the stack refuses the group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. |
| **sharing** | `{ enabled?: boolean; publicLink?: string; password?: string; allowedDomains?: string[]; … }` | optional | Public sharing configuration for this form |
| **submitBehavior** | `{ kind: 'thank-you'; title?: string; message?: string } \| { kind: 'redirect'; url: string; delayMs?: integer } \| { kind: 'continue' } \| { kind: 'next-record' }` | optional | Post-submit behavior. On the `redirect` arm, `url` is relative-only and interpolates only declared record fields as `{{record.field_name}}`, URL-escaped. |
| **buttons** | `{ submit?: object; cancel?: object }` | optional | Form action-button visibility & labels; folded onto the flat renderer props by ObjectUI ObjectForm. |
Expand Down Expand Up @@ -534,7 +534,7 @@ Form-view select option — the object-field option shape minus the per-option `
| **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record<string, any> }` | optional | Data source configuration (defaults to "object" provider) |
| **sections** | `{ name?: string; label?: string \| Record<string, string>; description?: string; collapsible?: boolean; … }[]` | optional | |
| **groups** | `{ name?: string; label?: string \| Record<string, string>; description?: string; collapsible?: boolean; … }[]` | optional | [LEGACY ALIAS → `sections`] Accepted for back-compat and folded onto `sections` at parse; `sections` wins when both are present. Prefer `sections`. |
| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. |
| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. A group places only a body table: a lookup child's FK declares `relatedList: 'primary'` (a master_detail FK that declares no `relatedList` needs nothing), or the stack refuses the group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. |
| **sharing** | `{ enabled?: boolean; publicLink?: string; password?: string; allowedDomains?: string[]; … }` | optional | Public sharing configuration for this form |
| **submitBehavior** | `{ kind: 'thank-you'; title?: string; message?: string } \| { kind: 'redirect'; url: string; delayMs?: integer } \| { kind: 'continue' } \| { kind: 'next-record' }` | optional | Post-submit behavior. On the `redirect` arm, `url` is relative-only and interpolates only declared record fields as `{{record.field_name}}`, URL-escaped. |
| **buttons** | `{ submit?: object; cancel?: object }` | optional | Form action-button visibility & labels; folded onto the flat renderer props by ObjectUI ObjectForm. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
type ConversionNotice,
} from '@objectstack/spec';
import { applyArtifactForwardConversions } from './artifact-forward-conversion.js';
import { SUPERSEDED_AT_THIS_DOOR, afterRetiringEntries, derivedRetiringIds } from './artifact-forward-conversion.test-support.js';

const SUBJECT = 'dashboard-refresh-interval-to-refresh-interval-seconds';

Expand All @@ -41,60 +42,6 @@ const DOOR_DEFAULT_FLIPS: readonly string[] = [
'permission-view-all-fields-beside-record-bypass',
];

/**
* [ADR-0159 D7, ADR-0049] Released step-18 fixtures whose surface a LATER
* major's retired entry rewrites or deletes, where this door replays that entry in the same window: its
* `retiredAfter` is at or above the artifact's floor, so the per-entry half
* opens it beside the step. The fixture is a released major's and is never
* edited. The rule is the one `packages/spec`'s `conversions.test.ts` states
* for the whole table (`SUPERSEDED_FIXTURES`): the expected result is the
* retiring entries applied, in the order listed, to the fixture's `after`,
* and every notice beyond the fixture's own is one of theirs, at the site
* they report. Each of these authors its form in `views[]`, which the
* major-19 form move, replayed at this door, moves to `forms[]`; one also
* carries the form's `subforms` list, which `form-view-subforms-removed`
* (protocol 19) deletes from the moved form. The order is the registry's.
*/
const SUPERSEDED_AT_THIS_DOOR: Readonly<Record<string, readonly string[]>> = {
'form-view-option-default-removed': ['view-forms-to-form-items'],
'view-item-owner-hidden-removed': ['view-forms-to-form-items'],
'view-overlay-owner-hidden-removed': ['view-forms-to-form-items'],
'form-layout-inline-grid-to-vertical': ['view-forms-to-form-items'],
'view-list-tabs-removed': ['view-forms-to-form-items'],
'form-view-subform-columns-canonicalized': ['view-forms-to-form-items', 'form-view-subforms-removed'],
'form-field-public-picker-removed': ['view-forms-to-form-items'],
'view-list-filterable-fields-removed': ['view-forms-to-form-items'],
'form-view-presentation-types-removed': ['view-forms-to-form-items'],
'form-view-buttons-reset-removed': ['view-forms-to-form-items'],
'form-view-drawer-keys-removed': ['view-forms-to-form-items'],
};

/**
* A fixture's `after` as this door leaves it: its retiring entries applied in
* the order listed, and the site each one reports (`ID at PATH`, the path
* relative to the fixture). Every listed entry must be a registered,
* load-retired entry of a later major that changes what it is handed; one that
* stopped firing means its row above is stale and must go. An entry with no
* row comes back as given, with no site.
*/
function afterRetiringEntries(
entry: { id: string; toMajor: number },
after: Record<string, unknown>,
): { stack: Record<string, unknown>; sites: string[] } {
const sites: string[] = [];
let stack = after;
for (const id of SUPERSEDED_AT_THIS_DOOR[entry.id] ?? []) {
const retiring = ALL_CONVERSIONS.find((c) => c.id === id);
expect(retiring, `${id} must be registered`).toBeDefined();
expect(retiring!.retiredFromLoadPath, `${id} must be retired from the load path, or this door never opens it`).toBe(true);
expect(retiring!.toMajor, `${id}: a superseding entry comes from a LATER major`).toBeGreaterThan(entry.toMajor);
const reported = sites.length;
stack = retiring!.apply(stack, (detail) => { sites.push(`${id} at ${detail.path}`); });
expect(sites.length, `${id} must change what it is handed of this fixture's \`after\``).toBeGreaterThan(reported);
}
return { stack, sites };
}

const versionTriple = (v: string): [number, number, number] =>
v.split(/[.-]/).slice(0, 3).map((n) => Number.parseInt(n, 10)) as [number, number, number];

Expand Down Expand Up @@ -410,6 +357,12 @@ describe('[#23027] the conversion reaches every package body — ADR-0130 D4 opt
it('every superseded fixture names a retired step-18 entry, so no row outlives its fixture', () => {
for (const id of Object.keys(SUPERSEDED_AT_THIS_DOOR)) expect(STEP_18.map((c) => c.id), id).toContain(id);
});

// The row agrees with the registry, and so with `packages/spec`'s
// `SUPERSEDED_FIXTURES`, which is held to the same derivation.
it('every step-18 fixture\'s row lists exactly the later entries that change its `after`', () => {
for (const entry of STEP_18) expect(SUPERSEDED_AT_THIS_DOOR[entry.id] ?? [], entry.id).toEqual(derivedRetiringIds(entry));
});
});
});

Expand Down
102 changes: 102 additions & 0 deletions packages/metadata-core/src/artifact-forward-conversion.test-support.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* The superseded-fixture table of the artifact door, shared by the two suites
* that replay the released step-18 fixtures through it
* (`artifact-forward-conversion.test.ts`, the definition's own collections, and
* `artifact-forward-conversion-package-body.test.ts`, each package body). One
* table, so a change to a fixture cannot leave one suite's copy stale.
*
* `packages/spec`'s `conversions.test.ts` states the same rule for the whole
* conversion table (`SUPERSEDED_FIXTURES`) and keeps its own copy, because a
* shared source across the two packages would need a new published export of
* `@objectstack/spec`. The two copies are held together by a rule instead of an
* import: each row must equal {@link derivedRetiringIds} for its fixture, and
* both suites assert that, so a fixture change that moves the derived list
* turns both red at once and names the row.
*
* Test support only: neither `index.ts` nor `testing.ts` imports it, so it is
* not in the published build.
*/

import { expect } from 'vitest';
import { ALL_CONVERSIONS } from '@objectstack/spec';

/**
* [ADR-0159 D7, ADR-0049] Released step-18 fixtures whose surface a LATER
* major's retired entry rewrites or deletes, where this door replays that entry in the same window: its
* `retiredAfter` is at or above the artifact's floor, so the per-entry half
* opens it beside the step. The fixture is a released major's and is never
* edited. The rule is the one `packages/spec`'s `conversions.test.ts` states
* for the whole table (`SUPERSEDED_FIXTURES`): the expected result is the
* retiring entries applied, in the order listed, to the fixture's `after`,
* and every notice beyond the fixture's own is one of theirs, at the site
* they report. Each of these authors its form in `views[]`, which the
* major-19 form move, replayed at this door, moves to `forms[]`; one also
* carries the form's `subforms` list, which `form-view-subforms-removed`
* (protocol 19) deletes from the moved form. The order is the registry's.
*/
export const SUPERSEDED_AT_THIS_DOOR: Readonly<Record<string, readonly string[]>> = {
'form-view-option-default-removed': ['view-forms-to-form-items'],
'view-item-owner-hidden-removed': ['view-forms-to-form-items'],
'view-overlay-owner-hidden-removed': ['view-forms-to-form-items'],
'form-layout-inline-grid-to-vertical': ['view-forms-to-form-items'],
'view-list-tabs-removed': ['view-forms-to-form-items'],
'form-view-subform-columns-canonicalized': ['view-forms-to-form-items', 'form-view-subforms-removed'],
'form-field-public-picker-removed': ['view-forms-to-form-items'],
'view-list-filterable-fields-removed': ['view-forms-to-form-items'],
'form-view-presentation-types-removed': ['view-forms-to-form-items'],
'form-view-buttons-reset-removed': ['view-forms-to-form-items'],
'form-view-drawer-keys-removed': ['view-forms-to-form-items'],
};

/**
* The retiring entries a fixture's row must list, read off the registry: every
* entry of a later major, in registry order, that changes what it is handed
* when the ones before it in this list have been applied to the fixture's
* `after`. `packages/spec`'s `conversions.test.ts` derives its rows the same
* way, so the two tables cannot disagree on a fixture.
*/
export function derivedRetiringIds(entry: {
id: string;
toMajor: number;
fixture: { after: Record<string, unknown> };
}): string[] {
const ids: string[] = [];
let stack: Record<string, unknown> = structuredClone(entry.fixture.after);
for (const later of ALL_CONVERSIONS) {
if (later.toMajor <= entry.toMajor) continue;
let fired = false;
const next = later.apply(structuredClone(stack), () => { fired = true; });
if (!fired) continue;
ids.push(later.id);
stack = next;
}
return ids;
}

/**
* A fixture's `after` as this door leaves it: its retiring entries applied in
* the order listed, and the site each one reports (`ID at PATH`, the path
* relative to the fixture). Every listed entry must be a registered,
* load-retired entry of a later major that changes what it is handed; one that
* stopped firing means its row above is stale and must go. An entry with no
* row comes back as given, with no site.
*/
export function afterRetiringEntries(
entry: { id: string; toMajor: number },
after: Record<string, unknown>,
): { stack: Record<string, unknown>; sites: string[] } {
const sites: string[] = [];
let stack = after;
for (const id of SUPERSEDED_AT_THIS_DOOR[entry.id] ?? []) {
const retiring = ALL_CONVERSIONS.find((c) => c.id === id);
expect(retiring, `${id} must be registered`).toBeDefined();
expect(retiring!.retiredFromLoadPath, `${id} must be retired from the load path, or this door never opens it`).toBe(true);
expect(retiring!.toMajor, `${id}: a superseding entry comes from a LATER major`).toBeGreaterThan(entry.toMajor);
const reported = sites.length;
stack = retiring!.apply(stack, (detail) => { sites.push(`${id} at ${detail.path}`); });
expect(sites.length, `${id} must change what it is handed of this fixture's \`after\``).toBeGreaterThan(reported);
}
return { stack, sites };
}
Loading
Loading