From 37892e4be88d52c3e36e4c312430fddc6c2d3a56 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 12:31:06 +0000 Subject: [PATCH 1/4] fix(examples): lay out the inert internal forms' sections as fieldGroups The showcase (project, business unit, contact) and the CRM (lead, opportunity, activity) still declared internal create/edit forms the Console no longer loads. Their sections move into each object's fieldGroups as group member lists, the contact's sparse create form becomes showOnCreate: false on the five fields it left out, and the inert forms are deleted. The advisories allowlist loses its four form-view-internal-not-loaded rows. Claude-Session: https://claude.ai/code/session_01L9qibzpqH1nQTsbGckLspg Co-authored-by: Claude --- content/docs/ui/field-grouping-and-order.mdx | 2 +- .../areas/access-security.json | 14 +- docs/qa/platform-checklist/areas/i18n.json | 12 +- .../app-crm/src/objects/activity.object.ts | 13 ++ examples/app-crm/src/objects/lead.object.ts | 16 +++ examples/app-crm/src/views/activity.view.ts | 41 +----- examples/app-crm/src/views/lead.view.ts | 52 +------ .../app-crm/src/views/opportunity.view.ts | 24 +--- examples/app-crm/test/i18n-sections.test.ts | 52 ++++++- .../src/data/objects/business-unit.object.ts | 6 + .../src/data/objects/contact.object.ts | 58 ++++---- .../src/data/objects/project.object.ts | 11 ++ .../src/system/translations/index.ts | 46 ++----- .../src/ui/views/business-unit.view.ts | 13 +- .../app-showcase/src/ui/views/contact.view.ts | 98 ++----------- .../app-showcase/src/ui/views/project.view.ts | 19 +-- .../test/author-time-advisories.test.ts | 20 +-- examples/app-showcase/test/seed.test.ts | 130 +++++++++--------- .../cli/test/i18n-section-coverage.test.ts | 19 ++- scripts/cross-package-test-inputs.mjs | 6 +- 20 files changed, 259 insertions(+), 393 deletions(-) diff --git a/content/docs/ui/field-grouping-and-order.mdx b/content/docs/ui/field-grouping-and-order.mdx index b1bdc7aa2c1..af38fd8614d 100644 --- a/content/docs/ui/field-grouping-and-order.mdx +++ b/content/docs/ui/field-grouping-and-order.mdx @@ -112,7 +112,7 @@ Keeping grouping off the field (beyond an optional semantic hint) is what lets * ## Runnable example - [`examples/app-showcase/src/data/objects/contact.object.ts`](https://github.com/objectstack-ai/objectstack/blob/main/examples/app-showcase/src/data/objects/contact.object.ts) — four declared `fieldGroups`, and the fields tagged with the matching `group`. -- [`examples/app-showcase/src/ui/views/contact.view.ts`](https://github.com/objectstack-ai/objectstack/blob/main/examples/app-showcase/src/ui/views/contact.view.ts) — sections that materialise those groups. +- [`examples/app-showcase/src/ui/views/contact.view.ts`](https://github.com/objectstack-ai/objectstack/blob/main/examples/app-showcase/src/ui/views/contact.view.ts) — the contact list, and no form: the create and edit forms are those four groups. ## Anti-patterns diff --git a/docs/qa/platform-checklist/areas/access-security.json b/docs/qa/platform-checklist/areas/access-security.json index d54b43e2e4d..92bbb3e7e29 100644 --- a/docs/qa/platform-checklist/areas/access-security.json +++ b/docs/qa/platform-checklist/areas/access-security.json @@ -851,7 +851,7 @@ "title": "Field-level security: editable:false strips/denies writes API-side and renders read-only in the UI; masked-read half needs an authored readable:false grant", "since": "v15", "status": "active", - "revision": 8, + "revision": 9, "priority": "P1", "surface": "mixed", "personas": [ @@ -876,7 +876,7 @@ "as contributor over the API: PATCH /api/v1/data/showcase_project/ {\"name\": \" (edited)\"} — an editable field, then PATCH {\"budget\": 999999999} — the FLS-locked field", "re-read the project system-side; compare budget before/after", "as admin: PATCH the same budget field to a new value and re-read (the entitled side)", - "in the console as the contributor: open the project's detail/edit form; screenshot; inspect the state of the budget and spent controls — the two budget figures the edit form renders (project.view.ts form section 'Budget & Schedule': budget, spent, start_date, end_date). budget_remaining is a formula field and is not on the edit form at all", + "in the console as the contributor: open the project's detail/edit form; screenshot; inspect the state of the budget and spent controls — the two budget figures the edit form renders as inputs (showcase_project's 'Budget & Schedule' field group, examples/app-showcase/src/data/objects/project.object.ts: budget, spent, start_date, end_date). budget_remaining is a formula field: the edit form draws it disabled in its trailing untitled section for every caller, so it says nothing about the lock", "read-mask half (see knownGaps): grant the STOCK showcase_client_liaison set (fixtures.requires[2] — the readable:false grant on budget, spent and budget_remaining; no scratch set is needed) to a fresh member who holds no showcase_contributor, then GET the project as that member and inspect that the three fields' KEYS are absent from the API body — a readable:false grant deletes the key (the strip mechanism, knownGaps[2]), and a key present with a null or placeholder value is not that shape — AND blank in the UI render", "as admin GET the same row — the unmasked contrast" ], @@ -900,9 +900,9 @@ "evidence": "trace + re-read" }, { - "clause": "the UI renders the FLS state faithfully for the contributor: the budget figures the edit form carries (budget and spent) are visible (readable:true) but not editable — input disabled/read-only on the edit form. budget_remaining is a formula: it is never on the edit form and never editable for anyone, so it cannot discriminate the FLS lock and is not scored here", + "clause": "the UI renders the FLS state faithfully for the contributor: the budget figures the edit form carries (budget and spent) are visible (readable:true) but not editable — input disabled/read-only on the edit form. budget_remaining is a formula: it is never editable for anyone (the edit form draws it disabled in its trailing untitled section, whoever opens it), so it cannot discriminate the FLS lock and is not scored here", "oracle": "dom", - "verify": "after a screenshot confirms the form rendered, assert the disabled/read-only state of the budget and spent controls (the form section names exactly those two of the three figures, examples/app-showcase/src/ui/views/project.view.ts); an EDITABLE budget or spent input for the contributor is the fail", + "verify": "after a screenshot confirms the form rendered, assert the disabled/read-only state of the budget and spent controls (the 'Budget & Schedule' field group names exactly those two of the three figures, examples/app-showcase/src/data/objects/project.object.ts); an EDITABLE budget or spent input for the contributor is the fail", "evidence": "screenshot + DOM read" }, { @@ -977,6 +977,12 @@ "date": "2026-10-31", "change": "acceptance[4] (clause, verify) and steps[5] are made precise. The clause still said 'given the scratch readable:false grant' and 'absent or nulled'; since #9308 fixture 4 the stock showcase_client_liaison set is that grant (fixtures.requires[2], which already said so), and QA run #27409 measured the wire shape: the keys are absent. Source agrees: plugin-security field-masker.ts deletes a non-readable field from the result (the strip), and showcase-client-liaison-fixtures.dogfood.test.ts asserts key absence for all three budget figures. So the clause names the stock grant and all three fields, and a key present with null or a placeholder is a FAIL, never a pass: stronger, not weaker. The UI half is unchanged. Read from source at base efdddc9060. Wave anchor #27377, wave-3 accuracy slice S3; finding parked in anchor comment 6488948228", "ref": "#27409" + }, + { + "revision": 9, + "date": "2026-11-27", + "change": "steps[4] and acceptance[3] re-anchored. Revision 4 read the two budget inputs off project.view.ts's default form, which the Console stopped loading with the internal-form retirement (#36425) and which #36553 deletes: the create and edit forms now lay a project out by showcase_project's fieldGroups, whose 'Budget & Schedule' group lists budget, spent, start_date and end_date. budget_remaining is no longer absent from the edit form: as an ungrouped formula field it is drawn disabled in the trailing untitled section, for every caller, so it still cannot discriminate the lock and is still not scored. Revision 4's text stays as the record of what was true at its base. No clause's assertion changed", + "ref": "#36553" } ] }, diff --git a/docs/qa/platform-checklist/areas/i18n.json b/docs/qa/platform-checklist/areas/i18n.json index adfed75d846..9694702d065 100644 --- a/docs/qa/platform-checklist/areas/i18n.json +++ b/docs/qa/platform-checklist/areas/i18n.json @@ -185,7 +185,7 @@ "title": "Every translatable surface localizes on a zh-CN session — one pass over the full translation-group vocabulary, plus the runtime i18n routes it resolves through", "since": "v15", "status": "active", - "revision": 16, + "revision": 17, "priority": "P1", "surface": "browser", "personas": ["admin on a zh-CN session"], @@ -198,7 +198,7 @@ "knownGaps": [ "the showcase's declared surface carries FROZEN untranslated debt, ratcheted by scripts/check-i18n-coverage.mjs + i18n-coverage-baseline.json — expect some declared strings to legitimately fall back to en; the per-surface check is 'translated keys render translated, untranslated keys render the SOURCE label (never a raw dotted key)', not 100% coverage", "objects._views..emptyState WAS unafforded and no longer is: the #7714 specimen has landed. examples/app-showcase/src/ui/views/task.view.ts authors an emptyState on the `urgent` view (its comment block cites #7714) and src/system/translations/index.ts carries the zh-CN half under objects.showcase_task._views.urgent.emptyState.{title,message}. The variant is runnable; the only setup it needs is an empty `urgent` view (demote the two urgent seed rows)", - "objects._sections is addressable ONLY on sections that declare a `name` (packages/spec/src/ui/component.zod.ts: a nameless section renders its authored label in every locale; packages/lint's translation-section-name-missing rule nudges authors toward the name). On the stock showcase every surface this item reads declares one: showcase_task's DEFAULT form (the New/Edit form, section `task`), the task record page — examples/app-showcase/src/ui/pages/task-detail.page.ts's record:details block names its sections overview / schedule / details since #22036, reusing objects.showcase_task._sections — and showcase_contact's default form. QA run #23163 read all three in zh under zh-CN, so the old reading (the record page renders EN in every locale) is stale. ⚠ The named formViews tabbed / wizard / split are reachable from NO console door: `…/showcase_task/view/tabbed` is a LIST-view route and renders the grid (records-forms.form-view-gallery says why), so do not read _sections there", + "objects._sections is addressable ONLY on sections that declare a `name` (packages/spec/src/ui/component.zod.ts: a nameless section renders its authored label in every locale; packages/lint's translation-section-name-missing rule nudges authors toward the name). On the stock showcase every surface this item reads declares one: showcase_task's DEFAULT form (the New/Edit form, section `task`), the task record page — examples/app-showcase/src/ui/pages/task-detail.page.ts's record:details block names its sections overview / schedule / details since #22036, reusing objects.showcase_task._sections — and showcase_contact's create and edit forms, whose sections are its four fieldGroups (#36553). QA run #23163 read all three in zh under zh-CN, so the old reading (the record page renders EN in every locale) is stale. ⚠ The named formViews tabbed / wizard / split are reachable from NO console door: `…/showcase_task/view/tabbed` is a LIST-view route and renders the grid (records-forms.form-view-gallery says why), so do not read _sections there", "acceptance[5]'s CONFIRM half HAS a stock specimen, so it is no longer pin-only (the old reading, QA run #21782's blocked(fixture) 'no zh confirmText', parked on #22017 row 8, is stale): sys_session's revoke_my_other_sessions, a list_toolbar action on the sys_session list (packages/platform-objects/src/identity/sys-session.object.ts; confirmText 'Sign out of every other device where you're currently logged in? Your current session will remain active.'), whose zh-CN entry in platform-objects' bundle (packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts) reads 要退出你当前已登录的其他所有设备吗?当前会话将保持活跃。 with successMessage 其他所有会话已撤销. Read from source at base f68b47ca and since driven live (QA run #33853: as the zh-CN admin with a second session open, the 退出其他设备 toolbar action on /_console/apps/setup/sys_session showed the zh confirm and the zh toast): drive it the same way, capture the confirm and the toast, and record it. No showcase action declares a `confirmText` still, so the showcase's live row is the toast half (e.g. showcase_recalc_estimate's zh successMessage); the unit pins `automated` names stay the copy's pin" ] }, @@ -210,7 +210,7 @@ "form labels + placeholders on a task edit form (fields group), and select options in the form and list filters (fields..options)", "an action dialog — trigger an object action with confirmText/successMessage and capture the confirm prompt and the success toast (_actions group: label/confirmText/successMessage)", "a view empty state (_views..emptyState) — RUNNABLE on the stock fixture since the #7714 specimen landed: examples/app-showcase/src/ui/views/task.view.ts authors an emptyState on the filtered `urgent` view, and the zh-CN bundle carries objects.showcase_task._views.urgent.emptyState.{title,message}. Demote the two urgent seed rows (or filter them away) so the view renders empty, then read the copy — it resolves to 暂无紧急任务 / 当前没有需要立即处理的事项。任务优先级调整为「紧急」后会出现在这里。 ⛔ Still do not manufacture coverage from the console's built-in zero-row placeholder, which is console chrome and not an objects._views..emptyState resolution", - "section labels (_sections group) — read them off a NAMED-section surface the console actually renders: showcase_task's New form (its default form's `task` section), a task record page (task-detail.page.ts names overview / schedule / details since #22036) and showcase_contact's default form, which renders on the contact record's EDIT (ui/views/contact.view.ts `form`: contact / work / status / notes). ⛔ Not the contact's New dialog for those four: it renders the create formView (formViews.create), whose one section is `who_is_this`, shown as 这是谁. That is a correct fifth named specimen, not a miss of the four. Each declares a stable `name` per section, which is the only thing that makes objects.._sections..label resolvable — the showcase bundle carries 概览/排期/详细信息 and 联系方式/工作信息/状态/备注 for exactly those names. ⛔ Not `…/view/tabbed`: the named formViews are reachable from no console door, and that URL renders the grid (see the knownGap below)", + "section labels (_sections group) — read them off a NAMED-section surface the console actually renders: showcase_task's New form (its default form's `task` section), a task record page (task-detail.page.ts names overview / schedule / details since #22036) and showcase_contact's create and edit forms, both laid out by the object's four fieldGroups (examples/app-showcase/src/data/objects/contact.object.ts: contact / work / status / notes); the New dialog shows the same four headings, less the fields marked showOnCreate false (since #36553 the contact declares no form view, so there is no `who_is_this` / 这是谁 heading any more). Each declares a stable `name` per section (a field group: its `key`), which is the only thing that makes objects.._sections..label resolvable — the showcase bundle carries 概览/排期/详细信息 and 联系方式/工作信息/状态/备注 for exactly those names. ⛔ Not `…/view/tabbed`: the named formViews are reachable from no console door, and that URL renders the grid (see the knownGap below)", "a dashboard — Chart Gallery's title and widget titles (dashboards..label / widgets..title). The showcase bundle translates one widget title: dashboards.showcase_chart_gallery.widgets.combo_count_vs_progress.title → 任务数与平均进度 on the runtime dashboard; read that widget", "a page — a page header's title/subtitle (pages. group). No showcase page carries a translated title or subtitle (QA run #23951 fixture gap), so read a PLATFORM page: pages.connect_agent (label 连接智能体 and its zh subtitle, platform-objects' bundle), and the showcase_command_center page's translated component titles (pages.showcase_command_center.components.*)", "a Settings namespace — title, group titles, key labels, and the source badges (settings. + settingsCommon.sourceLabels)", @@ -374,6 +374,12 @@ "date": "2026-11-17", "change": "acceptance[7].clause and the appTranslationDataShape source line: count-and-list correction, no change of the clause's meaning. The clause still scores every served key against the declared vocabulary; that vocabulary gained the `mappings` group (a named import mapping's label, mappings.NAME.label), so the served platform face is eighteen groups, the per-app face seventeen, and the scored set seventeen with mappings named. The source line also named fifteen groups without hooks, stale before this change; it now names all seventeen. The showcase bundle serves mappings.showcase_inquiry_feed, which the old list would have scored as outside the vocabulary. Read from source at base 0465f4aa", "ref": "#34939" + }, + { + "revision": 17, + "date": "2026-11-27", + "change": "steps[7] and fixtures.knownGaps[2] re-anchored on the contact's field groups. They read the contact's four section headings off ui/views/contact.view.ts's default form and its one create heading (who_is_this, 这是谁) off formViews.create. The internal-form retirement (#36425) stopped the Console loading both, and #36553 deletes them: the contact's create and edit forms are laid out by the object's four fieldGroups (contact / work / status / notes), the create leaving out the fields marked showOnCreate false, and the bundle no longer carries _sections.who_is_this. Revision 13's text stays as the record of what was true at its base. No clause's assertion changed", + "ref": "#36553" } ] }, diff --git a/examples/app-crm/src/objects/activity.object.ts b/examples/app-crm/src/objects/activity.object.ts index 06fca3c3742..f3f0b5baa1b 100644 --- a/examples/app-crm/src/objects/activity.object.ts +++ b/examples/app-crm/src/objects/activity.object.ts @@ -20,6 +20,19 @@ export const Activity = ObjectSchema.create({ // already shows it as the status tag beside the name. highlightFields: ['type', 'due_date', 'contact', 'account'], + // [ADR-0085 §5] The record's sections: the create and edit forms, the + // drawer and the record page lay an activity out by these groups, each + // listing its members in display order. + fieldGroups: [ + { + key: 'activity_details', + label: 'Activity Details', + fields: ['subject', 'type', 'status', 'due_date', 'duration_minutes'], + }, + { key: 'related_records', label: 'Related Records', fields: ['contact', 'account', 'opportunity'] }, + { key: 'notes', label: 'Notes', fields: ['description', 'outcome'] }, + ], + fields: { subject: Field.text({ label: 'Subject', diff --git a/examples/app-crm/src/objects/lead.object.ts b/examples/app-crm/src/objects/lead.object.ts index 02fd93d1b41..4d239214365 100644 --- a/examples/app-crm/src/objects/lead.object.ts +++ b/examples/app-crm/src/objects/lead.object.ts @@ -25,6 +25,22 @@ export const Lead = ObjectSchema.create({ // record page show it. enable: { trackHistory: true }, + // [ADR-0085 §5] The record's sections: the create and edit forms, the + // drawer and the record page lay a lead out by these groups, each listing + // its members in display order (so `company` comes second here, wherever + // it sits among the fields). The public Web-to-Lead form keeps its own + // section: it is a named, shared form (views/lead.view.ts). + fieldGroups: [ + { + key: 'lead_information', + label: 'Lead Information', + fields: ['name', 'company', 'email', 'phone', 'title', 'source'], + }, + { key: 'qualification', label: 'Qualification', fields: ['status', 'lead_score', 'assigned_to', 'account'] }, + { key: 'conversion', label: 'Conversion', fields: ['converted_opportunity', 'is_closed'] }, + { key: 'notes', label: 'Notes', fields: ['notes'] }, + ], + fields: { name: Field.text({ label: 'Lead Name', diff --git a/examples/app-crm/src/views/activity.view.ts b/examples/app-crm/src/views/activity.view.ts index 812f7c7ef96..33fd9a4b314 100644 --- a/examples/app-crm/src/views/activity.view.ts +++ b/examples/app-crm/src/views/activity.view.ts @@ -48,43 +48,6 @@ export const ActivityViews = defineView({ }, }, }, - // The default form. Since #36425 the Console's create and edit surfaces lay - // the record out by the object's fieldGroups and no longer load it, so it is - // inert there (lint: form-view-internal-not-loaded). - form: { - type: 'simple', - sections: [ - { - name: 'activity_details', - label: 'Activity Details', - columns: 2, - fields: [ - { field: 'subject', required: true }, - { field: 'type', required: true }, - { field: 'status', required: true }, - { field: 'due_date' }, - { field: 'duration_minutes' }, - ], - }, - { - name: 'related_records', - label: 'Related Records', - columns: 2, - fields: [ - { field: 'contact' }, - { field: 'account' }, - { field: 'opportunity' }, - ], - }, - { - name: 'notes', - label: 'Notes', - columns: 1, - fields: [ - { field: 'description' }, - { field: 'outcome' }, - ], - }, - ], - }, + // No form here: the create and edit forms lay an activity out by the + // object's `fieldGroups` (objects/activity.object.ts). }); diff --git a/examples/app-crm/src/views/lead.view.ts b/examples/app-crm/src/views/lead.view.ts index 52f9ee9782e..80d2413aaa9 100644 --- a/examples/app-crm/src/views/lead.view.ts +++ b/examples/app-crm/src/views/lead.view.ts @@ -44,55 +44,9 @@ export const LeadViews = defineView({ }, }, }, - // The default form. Since #36425 the Console's create and edit surfaces lay - // the record out by the object's fieldGroups and no longer load it, so it is - // inert there (lint: form-view-internal-not-loaded). The public Web-to-Lead - // form below stays a NAMED form: it is served by its slug and keeps loading. - form: { - type: 'simple', - sections: [ - { - name: 'lead_information', - label: 'Lead Information', - columns: 2, - fields: [ - { field: 'name', required: true }, - { field: 'company' }, - { field: 'email' }, - { field: 'phone' }, - { field: 'title' }, - { field: 'source' }, - ], - }, - { - name: 'qualification', - label: 'Qualification', - columns: 2, - fields: [ - { field: 'status', required: true }, - { field: 'lead_score' }, - { field: 'assigned_to' }, - { field: 'account' }, - ], - }, - { - name: 'conversion', - label: 'Conversion', - columns: 2, - fields: [ - { field: 'converted_opportunity' }, - { field: 'is_closed' }, - ], - }, - { - name: 'notes', - label: 'Notes', - columns: 1, - fields: [{ field: 'notes' }], - }, - ], - }, - + // No default form: the create and edit forms lay a lead out by the + // object's `fieldGroups` (objects/lead.object.ts). The public Web-to-Lead + // form below is a NAMED form: it is served by its slug and keeps loading. formViews: { /** * PUBLIC / ANONYMOUS — Web-to-Lead. diff --git a/examples/app-crm/src/views/opportunity.view.ts b/examples/app-crm/src/views/opportunity.view.ts index 1f0ecb06f63..996122c443d 100644 --- a/examples/app-crm/src/views/opportunity.view.ts +++ b/examples/app-crm/src/views/opportunity.view.ts @@ -46,26 +46,6 @@ export const OpportunityViews = defineView({ }, }, }, - // The default form. Since #36425 the Console's create and edit surfaces lay - // the record out by the object's fieldGroups and no longer load it, so it is - // inert there (lint: form-view-internal-not-loaded). - form: { - type: 'simple', - data: { provider: 'object', object: 'crm_opportunity' }, - sections: [ - { - name: 'opportunity', - label: 'Opportunity', - columns: 2, - fields: [ - { field: 'name', required: true }, - { field: 'account', required: true }, - { field: 'stage', required: true }, - { field: 'amount' }, - { field: 'probability' }, - { field: 'close_date' }, - ], - }, - ], - }, + // No form here: the create and edit forms lay an opportunity out by the + // object's `fieldGroups` (objects/opportunity.object.ts). }); diff --git a/examples/app-crm/test/i18n-sections.test.ts b/examples/app-crm/test/i18n-sections.test.ts index 42abe652434..75fd516a7ff 100644 --- a/examples/app-crm/test/i18n-sections.test.ts +++ b/examples/app-crm/test/i18n-sections.test.ts @@ -1,6 +1,7 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. import { describe, it, expect } from 'vitest'; +import { deriveFieldGroupLayout } from '@objectstack/spec/data'; import stack from '../objectstack.config.js'; /** @@ -17,10 +18,17 @@ import stack from '../objectstack.config.js'; * declares must (a) carry a `name` and (b) resolve to a REAL zh-CN * `_sections..label` — non-empty and not an echoed English string. * - * Read on the COMPOSED stack (`objectstack.config.ts`'s `views`/`translations` - * arrays), not the imported view/bundle modules directly — what the platform's - * i18n resolver and lint gates see is the composed stack, which is exactly the - * reachability this issue is about. + * The object's create and edit forms are laid out by its `fieldGroups`, not by + * a form view (#36425), and a group heading resolves through the same + * `_sections.` entry. So the sweep also covers every titled section + * `deriveFieldGroupLayout` (ADR-0085 §5, the derivation the renderers read) + * gives each object: the default forms the lead, opportunity and activity once + * declared moved there (#36553), and their headings must stay translated. + * + * Read on the COMPOSED stack (`objectstack.config.ts`'s `objects`/`views`/ + * `translations` arrays), not the imported modules directly — what the + * platform's i18n resolver and lint gates see is the composed stack, which is + * exactly the reachability this issue is about. */ describe('app-crm form section i18n coverage (#8231)', () => { const zhBundle = (stack.translations ?? [])[0] as @@ -83,8 +91,30 @@ describe('app-crm form section i18n coverage (#8231)', () => { } } - it('exercised at least one container with named sections (guards against a vacuous sweep)', () => { - const total = containers.reduce( + const objects = (stack.objects ?? []) as Array<{ name: string }>; + /** Every titled section an object's field groups give its forms and record page. */ + const groupSections = objects.flatMap((object) => + (deriveFieldGroupLayout(object) ?? []) + .filter((s): s is typeof s & { key: string } => typeof s.key === 'string') + .map((s) => ({ objectName: object.name, key: s.key, label: s.label ?? s.key })), + ); + + for (const { objectName, key, label } of groupSections) { + it(`${objectName} · fieldGroups · section "${label}" resolves in zh-CN`, () => { + const zhLabel = zhBundle?.['zh-CN']?.objects?.[objectName]?._sections?.[key]?.label; + expect( + zhLabel, + `objects.${objectName}._sections.${key}.label is missing from the zh-CN bundle — ` + + 'the group heading renders in English in every locale.', + ).toBeTruthy(); + expect(zhLabel, `zh-CN _sections.${key}.label reads as untranslated ASCII`).not.toMatch( + /^[\x20-\x7e]+$/, + ); + }); + } + + it('exercised the named sections the app declares (guards against a vacuous sweep)', () => { + const formSections = containers.reduce( (n, c) => n + [...(c.form ? [c.form] : []), ...Object.values(c.formViews ?? {})].reduce( @@ -93,6 +123,14 @@ describe('app-crm form section i18n coverage (#8231)', () => { ), 0, ); - expect(total).toBeGreaterThanOrEqual(9); + // Web-to-Lead's one section, and the ten field-group headings of the + // account (2), opportunity (1), lead (4) and activity (3) objects. Each + // sweep is held separately, so one cannot cover for the other shrinking. + expect(formSections).toBeGreaterThanOrEqual(1); + expect(groupSections.length).toBeGreaterThanOrEqual(10); + // The three objects whose default forms became field groups (#36553). + for (const objectName of ['crm_lead', 'crm_opportunity', 'crm_activity']) { + expect(groupSections.some((s) => s.objectName === objectName), objectName).toBe(true); + } }); }); diff --git a/examples/app-showcase/src/data/objects/business-unit.object.ts b/examples/app-showcase/src/data/objects/business-unit.object.ts index da252693ec1..7a95fee9e64 100644 --- a/examples/app-showcase/src/data/objects/business-unit.object.ts +++ b/examples/app-showcase/src/data/objects/business-unit.object.ts @@ -40,4 +40,10 @@ export const BusinessUnit = ObjectSchema.create({ manager: Field.text({ label: 'Manager', maxLength: 120 }), headcount: Field.number({ label: 'Headcount', min: 0, defaultValue: 0 }), }, + + // [ADR-0085 §5] The record's one section: the create and edit forms and the + // drawer lay a unit out by it, members in this order. + fieldGroups: [ + { key: 'unit', label: 'Unit', fields: ['name', 'parent', 'kind', 'manager', 'headcount'] }, + ], }); diff --git a/examples/app-showcase/src/data/objects/contact.object.ts b/examples/app-showcase/src/data/objects/contact.object.ts index c7c236c6c74..ee47b5f5336 100644 --- a/examples/app-showcase/src/data/objects/contact.object.ts +++ b/examples/app-showcase/src/data/objects/contact.object.ts @@ -5,27 +5,25 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; /** * Contact — the canonical "create form ≠ edit form" example. * - * See the scenario guide: content/docs/guides/solutions/create-vs-edit-form.mdx + * See the scenario guide: content/docs/ui/create-vs-edit-form.mdx * and ADR-0047 (object UI run modes) for the model this demonstrates. * - * The object declares a FLAT field set. Each field carries enough *intent* that - * both the full edit form AND the slimmed create form can be DERIVED from this - * single source — no second hand-maintained field list: + * The object declares ONE flat field set, and both forms come from it. No + * form view is written for either (`ui/views/contact.view.ts` holds the list + * only): * - * - `group` → which section a field belongs to (semantic grouping that - * travels with the data model, not a per-form layout). The - * group must also be DECLARED in `fieldGroups` below — that - * declaration is what authorizes the derivation (ADR-0085 §5). + * - `fieldGroups` + `group` → the sections, on the create form, the edit + * form and the record page alike (ADR-0085 §5). A `group` + * counts only when `fieldGroups` below DECLARES its key. * - declaration order = display order (there is no `field.order`; the order - * you write fields in IS the default order everywhere). - * - `required` → must appear on the create form. - * - `readonly` / derived → never on the create form (you can't set it). - * - `defaultValue` present → can be OMITTED from create (it self-fills). - * - * `views/contact.view.ts` then shows the two projections: - * - the full grouped edit form (mirrors what the platform auto-derives), and - * - a SPARSE `formViews.create` override for the rare case where you want to - * hand-shape the create experience. + * you write fields in IS the order inside a group). + * - `required` → always asked for on create. + * - `showOnCreate: false` → left out of create; still on edit, the record + * page and lists. Here: `title` and `account` (context, not + * needed to bring a contact into being), `stage` (it has a + * default, so it self-fills), `lead_score` (readonly — it + * cannot be set) and `notes` (edit-time only). The create + * form therefore asks for name, email, phone and company. */ export const Contact = ObjectSchema.create({ name: 'showcase_contact', @@ -34,7 +32,7 @@ export const Contact = ObjectSchema.create({ icon: 'user', color: 'blue', description: - 'Demonstrates derive-default + sparse-override forms: one flat, grouped, intent-tagged field set projects into both a full edit form and a slim create form (ADR-0047).', + 'Demonstrates one field set for two forms: its field groups lay out both the full edit form and the create form, and the fields marked showOnCreate false are left out of create (ADR-0047).', sharingModel: 'private', fields: { @@ -43,21 +41,23 @@ export const Contact = ObjectSchema.create({ email: Field.email({ label: 'Email', required: true, searchable: true, group: 'contact' }), phone: Field.text({ label: 'Phone', maxLength: 40, group: 'contact' }), - // ── Work group: useful context, not required to bring a contact into being. ── + // ── Work group: useful context, not required to bring a contact into being. + // The create form asks for the company only. ── company: Field.text({ label: 'Company', maxLength: 120, searchable: true, group: 'work' }), - title: Field.text({ label: 'Job title', maxLength: 120, group: 'work' }), + title: Field.text({ label: 'Job title', maxLength: 120, group: 'work', showOnCreate: false }), // Which account this person belongs to — the parent side of the dependent // (cascading) lookup demo: showcase_invoice.contact declares // `dependsOn: ['account']`, so the invoice's contact picker only offers // contacts whose `account` matches the invoice's selected account. - account: Field.lookup('showcase_account', { label: 'Account', group: 'work' }), + account: Field.lookup('showcase_account', { label: 'Account', group: 'work', showOnCreate: false }), - // ── Status group: lifecycle. `stage` has a default (so it can be omitted - // from create); `lead_score` is derived/readonly (so it must never be - // on the create form — you can't set it). + // ── Status group: lifecycle. `stage` has a default (so create leaves it + // out and it self-fills); `lead_score` is derived/readonly (so create + // leaves it out — you can't set it). stage: Field.select({ label: 'Stage', group: 'status', + showOnCreate: false, options: [ { label: 'New', value: 'new', default: true, color: '#3B82F6' }, { label: 'Working', value: 'working', color: '#F59E0B' }, @@ -65,10 +65,10 @@ export const Contact = ObjectSchema.create({ { label: 'Closed', value: 'closed', color: '#6B7280' }, ], }), - lead_score: Field.number({ label: 'Lead score', readonly: true, group: 'status', inlineHelpText: 'Computed by scoring rules — not user-editable.' }), + lead_score: Field.number({ label: 'Lead score', readonly: true, group: 'status', showOnCreate: false, inlineHelpText: 'Computed by scoring rules — not user-editable.' }), // ── Notes group: long-form, edit-time only. ── - notes: Field.text({ label: 'Notes', maxLength: 4000, group: 'notes' }), + notes: Field.text({ label: 'Notes', maxLength: 4000, group: 'notes', showOnCreate: false }), }, // [ADR-0085 §5] The DECLARATION side of the grouping edge, and the reason the @@ -80,9 +80,9 @@ export const Contact = ObjectSchema.create({ // everything else into the trailing untitled bucket. So a `group` with no // matching entry renders exactly like no `group` at all (`os lint` says so // as `field-group-undeclared`), which is what these nine fields did before - // #5443. Array order is display order; the labels match the four sections - // `ui/views/contact.view.ts` writes out by hand, because the whole point of - // that file's comment is that the two agree. + // #5443. Array order is display order. These four are the sections of the + // create form, the edit form and the record page: no form view restates + // them. fieldGroups: [ { key: 'contact', label: 'Contact' }, { key: 'work', label: 'Work' }, diff --git a/examples/app-showcase/src/data/objects/project.object.ts b/examples/app-showcase/src/data/objects/project.object.ts index b1a3ad349f8..f5f0f24b26f 100644 --- a/examples/app-showcase/src/data/objects/project.object.ts +++ b/examples/app-showcase/src/data/objects/project.object.ts @@ -26,6 +26,17 @@ export const Project = ObjectSchema.create({ // surface (upload / list / download / delete + parent-derived access). enable: { files: true }, + // [ADR-0085 §5] The record's sections: the create and edit forms and the + // drawer lay a project out by these groups, each listing its members in + // display order. The fields no group lists (budget_remaining, labels, + // team_members and the two task roll-ups) follow in a trailing untitled + // section. No group names a related list, so the Tasks table is not inlined + // in the form: tasks are added over time, not entered with the project. + fieldGroups: [ + { key: 'project', label: 'Project', fields: ['name', 'account', 'status', 'health', 'owner'] }, + { key: 'budget_schedule', label: 'Budget & Schedule', fields: ['budget', 'spent', 'start_date', 'end_date'] }, + ], + fields: { name: Field.text({ label: 'Project Name', required: true, searchable: true, maxLength: 200 }), // `relatedList*` is the read-side mirror of inline editing: the Account's diff --git a/examples/app-showcase/src/system/translations/index.ts b/examples/app-showcase/src/system/translations/index.ts index 9739dedf869..1ac29543e14 100644 --- a/examples/app-showcase/src/system/translations/index.ts +++ b/examples/app-showcase/src/system/translations/index.ts @@ -441,11 +441,11 @@ export const ShowcaseTranslationBundle = { by_status: { label: '按状态' }, budget_chart: { label: '按客户预算' }, }, - // Section headings from two surfaces: `ui/views/project.view.ts`'s - // `edit` form (`project` / `budget_schedule`) and + // Section headings from two surfaces: the object's `fieldGroups` + // (`project` / `budget_schedule`, the create and edit forms) and // `ui/pages/project-detail.page.ts`'s `record:details` tab - // (`overview` / `financials` / `timeline`). Each declares a stable - // `name`, the only thing that makes the heading translatable + // (`overview` / `financials` / `timeline`). Each carries a stable key + // or `name`, the only thing that makes the heading translatable // (#8231). Wording reuses vocabulary this bundle already established // elsewhere: `预算` (fields.budget above), `排期` (showcase_task // `_sections.schedule` below), `概览` (showcase_task @@ -662,7 +662,7 @@ export const ShowcaseTranslationBundle = { // ADR reference is kept, as `showcase_client_brief.description` keeps // its own. description: - '演示「默认推导 + 稀疏覆盖」表单:一套扁平、分组、带意图标记的字段集,同时投影为完整的编辑表单和精简的新建表单(ADR-0047)。', + '演示一套字段集供两张表单使用:字段分组同时编排完整的编辑表单和新建表单,标记 showOnCreate false 的字段不出现在新建表单中(ADR-0047)。', fields: { name: { label: '姓名' }, email: { label: '邮箱' }, @@ -688,43 +688,27 @@ export const ShowcaseTranslationBundle = { // no lookup could reach. Its source label is the bare plural // "Contacts", so the object's own `pluralLabel` above is the right // word; the `全部…` spelling the task/project lists use belongs to - // labels that actually say "All …". - // - // `_views.create.title` — the sparse `formViews.create` form's own - // heading (`title: 'New contact'`), which `translateView` overlays - // onto the served form's `config.title`. 新建联系人 follows the - // 新建… shape a create heading takes. Its `submitBehavior` is the - // thank-you panel the same form shows after a save, overlaid onto the - // served form's `config.submitBehavior`. + // labels that actually say "All …". The container declares no form: + // the create and edit forms are the object's `fieldGroups`. _views: { default: { label: '联系人' }, - create: { - title: '新建联系人', - submitBehavior: { title: '联系人已创建', message: '其余信息可在记录中补充。' }, - }, }, - // `_sections` — the four groups of the default edit form in - // `ui/views/contact.view.ts`, plus the sparse `formViews.create` - // override's single section (#8231 remainder). Each declares a - // stable `name`, which is the only reason the heading is - // translatable (`ObjectForm` looks it up as - // `objects.showcase_contact._sections..label` and otherwise + // `_sections` — the object's four `fieldGroups`, the sections of its + // create form, edit form and record page. A group's `key` is what + // makes the heading translatable (`ObjectForm` looks it up as + // `objects.showcase_contact._sections..label` and otherwise // renders the English `label` verbatim). Wording reuses the vocabulary // this bundle already established — 状态 and 备注 are exactly the words // its `stage`-family and `notes` entries use — rather than minting a // second term per idea. `contact` reads 联系方式 (contact DETAILS, its // fields being 姓名/邮箱/电话) instead of a circular 联系人 heading // inside a contact record; `work` follows the `…信息` shape the - // showcase_semantic_zoo headings set. `who_is_this` is the create - // form's own heading — a plain rendering of the English question, - // matching the no-punctuation style every other heading in this file - // uses. + // showcase_semantic_zoo headings set. _sections: { contact: { label: '联系方式' }, work: { label: '工作信息' }, status: { label: '状态' }, notes: { label: '备注' }, - who_is_this: { label: '这是谁' }, }, }, // [#9308 fixture 2] The zh-CN mirror of the `en` block above, key for @@ -942,9 +926,9 @@ export const ShowcaseTranslationBundle = { default: { label: '全部单元' }, org_chart: { label: '组织架构图' }, }, - // `ui/views/business-unit.view.ts` `edit` form's single section. - // Declares a stable `name`, the only thing that makes the heading - // translatable (#8231). Bare object word, matching `全部单元` above. + // The object's single `fieldGroups` entry, the section of its create + // and edit forms. Its stable `key` is the only thing that makes the + // heading translatable (#8231). Bare object word, matching `全部单元` above. _sections: { unit: { label: '单元' }, }, diff --git a/examples/app-showcase/src/ui/views/business-unit.view.ts b/examples/app-showcase/src/ui/views/business-unit.view.ts index a5b824dab0c..2f8ea736119 100644 --- a/examples/app-showcase/src/ui/views/business-unit.view.ts +++ b/examples/app-showcase/src/ui/views/business-unit.view.ts @@ -36,15 +36,6 @@ export const BusinessUnitViews = defineView({ }, }, }, - // The default form. Since #36425 the Console's create and edit surfaces lay - // the record out by the object's fieldGroups and no longer load it, so it is - // inert there (lint: form-view-internal-not-loaded, allow-listed with its - // reason in test/author-time-advisories.test.ts). - form: { - type: 'simple', - data, - sections: [ - { name: 'unit', label: 'Unit', columns: 2, fields: ['name', 'parent', 'kind', 'manager', 'headcount'] }, - ], - }, + // No form here: the create and edit forms lay a unit out by the object's + // `fieldGroups` (data/objects/business-unit.object.ts). }); diff --git a/examples/app-showcase/src/ui/views/contact.view.ts b/examples/app-showcase/src/ui/views/contact.view.ts index 3c36257fbdd..9e6e6f2c0eb 100644 --- a/examples/app-showcase/src/ui/views/contact.view.ts +++ b/examples/app-showcase/src/ui/views/contact.view.ts @@ -5,55 +5,17 @@ import { defineView } from '@objectstack/spec'; const data = { provider: 'object' as const, object: 'showcase_contact' }; /** - * Contact views — the "create form ≠ edit form" pattern, as it was authored - * before #36425. + * Contact views: the list. There is no form here on purpose. * - * Since #36425 the Console's create and edit surfaces no longer load either - * form below: they lay the record out by the object's `fieldGroups` and follow - * the rules on its fields, and a field marked `showOnCreate: false` is left out - * of create only. Both forms are inert there (lint: - * form-view-internal-not-loaded, allow-listed with its reason in - * test/author-time-advisories.test.ts) and stay because test/seed.test.ts and - * the section translations read them. The text below describes what they - * declare, not what the Console draws. + * The create and edit forms lay a contact out by the object's `fieldGroups` + * (data/objects/contact.object.ts): four sections, Contact, Work, Status and + * Notes. The create form leaves out every field marked `showOnCreate: false`, + * so it asks only for name, email, phone and company. A hand-written default + * `form` or `formViews.create` would not be loaded by either surface + * (lint: form-view-internal-not-loaded). * - * Scenario guide: content/docs/guides/solutions/create-vs-edit-form.mdx - * Decision record: ADR-0047 (object UI run modes — derive-default + override). - * - * Two projections of ONE flat, grouped field set (see objects/contact.object.ts): - * - * • `form` (default edit/detail) — the FULL record, grouped into sections by - * each field's `group`. This mirrors what the platform auto-derives, and - * it is written out explicitly here only so the example is legible: OMIT - * it and `deriveFieldGroupLayout` (ADR-0085 §5) produces these same four - * sections, in this order, with these members. Sections list fields as - * bare strings → every field inherits its type / validation / FLS / - * default from the object. - * - * The derivation's authority is the object's `fieldGroups` DECLARATION, - * not `field.group` on its own: a field whose `group` names no declared - * key falls into the trailing ungrouped bucket exactly as if it carried no - * `group` at all (`os lint` reports it as `field-group-undeclared`). That - * is why `objects/contact.object.ts` declares all four keys — without them - * this comment would be promising a grouping the platform never derives - * (#5443). - * - * Two honest differences from the hand-written version below, both of them - * the reason the explicit `form` is still worth authoring here: the - * derived layout appends the platform-injected `owner_id` in a trailing - * untitled section (audit/system columns are excluded, ownership is not), - * and per-section presentation like `columns: 2` is a form-view knob the - * group declaration does not carry. - * - * • `formViews.create` (the escape hatch) — a SPARSE override for the create - * experience: just the core fields, one ungrouped section. Note what is - * absent: `lead_score` (readonly/derived — can't be set), `stage` (has a - * default — self-fills), `notes` (edit-time only). Nothing here restates a - * field's type or rules; it only chooses WHICH fields appear and WHERE. - * - * The list's Add button opens the object's create form, laid out by its - * `fieldGroups`; nothing on `addRecord` names a form (`mode` / `formView` were - * retired, #24692). + * Scenario guide: content/docs/ui/create-vs-edit-form.mdx + * Decision record: ADR-0047 (object UI run modes). */ export const ContactViews = defineView({ // Default list — carries `data` so the view registrar can resolve the object. @@ -67,46 +29,8 @@ export const ContactViews = defineView({ { field: 'company' }, { field: 'stage' }, ], - // The Add button opens the object's create form (its fieldGroups, minus - // any `showOnCreate: false` field); `formViews.create` below is not loaded. + // The Add button opens the object's create form: its fieldGroups, less + // every `showOnCreate: false` field. Nothing here names a form. addRecord: { enabled: true }, }, - - // ── Default (edit/detail) form: the full record, grouped by `field.group`. - // Bare field names → inherit everything from the object definition. ── - form: { - type: 'simple', - data, - sections: [ - { name: 'contact', label: 'Contact', columns: 2, fields: ['name', 'email', 'phone'] }, - { name: 'work', label: 'Work', columns: 2, fields: ['company', 'title', 'account'] }, - { name: 'status', label: 'Status', columns: 2, fields: ['stage', 'lead_score'] }, - { name: 'notes', label: 'Notes', columns: 1, fields: ['notes'] }, - ], - }, - - formViews: { - // ── Sparse create override: only the core fields, one section. - // Omits derived (`lead_score`), defaulted (`stage`) and edit-time - // (`notes`) fields. `owner_id`-style overrides would go inline as - // `{ field: 'phone', required: true }` — only where you actually - // override; everything else stays a bare string and inherits. ── - create: { - type: 'simple', - data, - title: 'New contact', - sections: [ - { - // #8231 remainder — a stable `name` is the only thing that makes - // this heading translatable; see `_sections.who_is_this` in - // `system/translations/index.ts`. - name: 'who_is_this', - label: 'Who is this?', - columns: 1, - fields: ['name', 'email', 'phone', 'company'], - }, - ], - submitBehavior: { kind: 'thank-you', title: 'Contact created', message: 'You can fill in the rest on the record.' }, - }, - }, }); diff --git a/examples/app-showcase/src/ui/views/project.view.ts b/examples/app-showcase/src/ui/views/project.view.ts index 1f4fbdff59c..14c6eea674b 100644 --- a/examples/app-showcase/src/ui/views/project.view.ts +++ b/examples/app-showcase/src/ui/views/project.view.ts @@ -174,21 +174,6 @@ export const ProjectViews = defineView({ }, }, }, - // The default form. Since #36425 the Console's create and edit surfaces lay - // the record out by the object's fieldGroups and no longer load it, so it is - // inert there (lint: form-view-internal-not-loaded, allow-listed with its - // reason in test/author-time-advisories.test.ts). - form: { - type: 'simple', - data, - sections: [ - { name: 'project', label: 'Project', columns: 2, fields: ['name', 'account', 'status', 'health', 'owner'] }, - { name: 'budget_schedule', label: 'Budget & Schedule', columns: 2, fields: ['budget', 'spent', 'start_date', 'end_date'] }, - ], - // No subforms here, and no Tasks subtable either: a child is inlined in - // the parent's form only where a field group of the parent names it, and - // showcase_project names none for its tasks (showcase_task.project sets no - // `inlineEdit` either — tasks are added over time, not entered with the - // project). A view could still add `subforms` to inline them. - }, + // No form here: the create and edit forms lay a project out by the object's + // `fieldGroups` (data/objects/project.object.ts). }); diff --git a/examples/app-showcase/test/author-time-advisories.test.ts b/examples/app-showcase/test/author-time-advisories.test.ts index cccef83ff99..23def79961e 100644 --- a/examples/app-showcase/test/author-time-advisories.test.ts +++ b/examples/app-showcase/test/author-time-advisories.test.ts @@ -71,12 +71,6 @@ const CONTRIBUTOR_TOTALS = 'A contributor sees only its own tasks (task_own_rows), and the project roll-ups count every task: the size ' + "of the project, not other people's task rows."; -const INERT_INTERNAL_FORM = - 'Since #36425 the Console create and edit surfaces lay this object out by its fieldGroups and no longer load ' - + 'this form, so it is inert and the warning is true. It stays as authored because more than the view reads ' - + "it: the form-view layout coverage (coverage.ts formViewTypes), the section translations under the object's " - + '`_sections` in system/translations/index.ts, and for showcase_contact the section pins in test/seed.test.ts. ' - + 'Moving it into fieldGroups and showOnCreate touches those too, so it is left to a follow-up.'; const NESTED_FAN_OUT = 'showcase_nested_fan_out_reminders is the loop { parallel } fixture automation.flow-run-step-nesting scores, ' + 'pinned by test/nested-fan-out-region-indices.test.ts. Wrapping the notify step in a try_catch puts a region ' @@ -131,14 +125,12 @@ export const ALLOWED_ADVISORIES: readonly Allowed[] = [ }, // ── Internal create / edit forms the Console no longer loads (warning) ──── - // Not here: `view "showcase_task" · form`. Three `type: 'form'` actions open it - // by its served name `showcase_task.form` (Log Time, New Task, the Overview's - // Create Task), so it keeps loading and the rule does not report it (#36545); - // the stale-entry direction below fails if it ever fires again. - { rule: 'form-view-internal-not-loaded', where: 'view "showcase_project" · form', reason: INERT_INTERNAL_FORM }, - { rule: 'form-view-internal-not-loaded', where: 'view "showcase_business_unit" · form', reason: INERT_INTERNAL_FORM }, - { rule: 'form-view-internal-not-loaded', where: 'view "showcase_contact" · form', reason: INERT_INTERNAL_FORM }, - { rule: 'form-view-internal-not-loaded', where: 'view "showcase_contact" · formViews.create', reason: INERT_INTERNAL_FORM }, + // None. The showcase lays every object's create and edit forms out by its + // fieldGroups and showOnCreate, and declares no internal form it does not + // load. `view "showcase_task" · form` is not one: three `type: 'form'` + // actions open it by its served name `showcase_task.form` (Log Time, New + // Task, the Overview's Create Task), so it keeps loading and the rule does + // not report it (#36545). A new internal form fails this test unlisted. // ── Fixtures ───────────────────────────────────────────────────────────── { rule: 'flow-loop-body-uncontained', where: "flow 'showcase_nested_fan_out_reminders' · loop 'each_task' body → parallel 'fan_out_audiences' branch 0 · node 'notify_owner' (notify)", reason: NESTED_FAN_OUT }, diff --git a/examples/app-showcase/test/seed.test.ts b/examples/app-showcase/test/seed.test.ts index 74babc14054..80b19e47d11 100644 --- a/examples/app-showcase/test/seed.test.ts +++ b/examples/app-showcase/test/seed.test.ts @@ -84,39 +84,34 @@ describe('showcase stack', () => { }); /** - * #5420 (extended by #8231's remainder) — the section headings the - * registration makes translatable, pinned from BOTH sides on the real - * stack. + * #5420 (extended by #8231's remainder; moved to `fieldGroups` by #36553) — + * the section headings of the contact's create and edit forms, pinned from + * BOTH sides on the real stack. * - * Registering `ContactViews` is what puts its named sections in front of - * the i18n gates, and the two gates read the same set in opposite - * directions: `i18n/missing-section` (#5405) fails on a declared section - * with no bundle entry, `translation-target-unknown` (#5415/#5422) fails on - * a bundle entry no section declares. A test that checked one direction - * would stay green while the other broke, so this asserts set EQUALITY. + * The forms lay a contact out by the object's `fieldGroups`, so the group + * keys are the translatable section anchors, and the two i18n gates read + * them in opposite directions: `i18n/missing-section` (#5405) fails on a + * declared section with no bundle entry, `translation-target-unknown` + * (#5415/#5422) fails on a bundle entry nothing declares. A test that + * checked one direction would stay green while the other broke, so this + * asserts set EQUALITY. `who_is_this`, the heading of the retired create + * form, must not come back: nothing declares it any more. * - * Read on the composed stack, not on the imported container: what the gates - * see is `stack.views`, and that is exactly the reachability this issue was - * about. The default `form`'s four sections AND the sparse - * `formViews.create` override's one section are both named as of #8231's - * remainder, so both contribute to the set below — `formViews.create` is no - * longer excluded. + * Read on the composed stack, not on the imported modules: what the gates + * see is `stack.objects` / `stack.translations`. */ - it('keys the contact form sections to exactly what the container declares', () => { - const contact = (stack.views ?? []).find((v) => targetObject(v) === 'showcase_contact'); - const namesOf = (view: unknown): string[] => { - const sections = (view as { sections?: unknown } | undefined)?.sections; - return (Array.isArray(sections) ? sections : []) - .map((s) => (s as { name?: unknown } | undefined)?.name) - .filter((n): n is string => typeof n === 'string'); - }; - const form = (contact as { form?: unknown } | undefined)?.form; - const formViews = (contact as { formViews?: Record } | undefined)?.formViews ?? {}; - const declared = [...namesOf(form), ...Object.values(formViews).flatMap(namesOf)].sort(); - expect(declared).toEqual(['contact', 'notes', 'status', 'who_is_this', 'work']); + it('keys the contact form sections to exactly the groups the object declares', () => { + const object = (stack.objects ?? []).find( + (o: { name: string }) => o.name === 'showcase_contact', + ); + const declared = (deriveFieldGroupLayout(object) ?? []) + .map((s) => s.key) + .filter((k): k is string => typeof k === 'string') + .sort(); + expect(declared).toEqual(['contact', 'notes', 'status', 'work']); const zh = ShowcaseTranslationBundle['zh-CN']?.objects?.showcase_contact as - | { _sections?: Record } + | { _sections?: Record; _views?: Record } | undefined; expect(Object.keys(zh?._sections ?? {}).sort()).toEqual(declared); // Every entry carries an actual translation — an empty or echoed English @@ -126,54 +121,56 @@ describe('showcase stack', () => { expect(label, `zh-CN _sections.${name}.label`).toBeTruthy(); expect(label).not.toMatch(/^[\x20-\x7e]+$/); } + // The container's only view is its list; no `_views.create` heading. + expect(Object.keys(zh?._views ?? {})).toEqual(['default']); }); /** - * #5443 — the comment at the top of `ui/views/contact.view.ts` promises that - * the hand-written `form` "mirrors what the platform auto-derives", i.e. that - * you may OMIT it and get the same grouped form. That promise is only true if - * the object DECLARES the four groups: `deriveFieldGroupLayout` (ADR-0085 §5, - * the one derivation every renderer and the i18n walker consume) buckets a - * field only when its `group` matches a declared `fieldGroups[].key`, and - * otherwise drops it into the trailing untitled bucket — which is exactly - * what nine `showcase_contact` fields did while the comment claimed - * otherwise (`os lint`: 9 × `field-group-undeclared`). + * #5443, re-anchored by #36553 — the contact is the showcase's "create form + * ≠ edit form" example, and both forms now come from ONE source: the + * object's `fieldGroups` lay them out, and a field marked + * `showOnCreate: false` is left out of create only. No form view restates + * either (`ui/views/contact.view.ts` holds the list), which is the point. * - * So this pins the promise itself, not the declaration: the derived sections - * must equal the authored `form.sections` in ORDER and MEMBERSHIP. Deleting - * `fieldGroups` makes `deriveFieldGroupLayout` return `null` (no declared - * groups → grouping does not apply), and the assertion goes red on the first - * line rather than passing vacuously on an empty comparison. + * So this pins what the two forms draw. The edit form: the four derived + * sections, in order, with their members. `deriveFieldGroupLayout` + * (ADR-0085 §5, the one derivation every renderer and the i18n walker + * consume) buckets a field only when its `group` matches a declared + * `fieldGroups[].key`; deleting `fieldGroups` makes it return `null` and the + * first assertion goes red rather than passing on an empty comparison. The + * create form: those sections less the `showOnCreate: false` fields, which + * must leave exactly what the retired sparse create form asked for — name, + * email, phone and company. And the container declares no internal form. * - * Read on the composed stack for the same reason the section-key test above - * is: what renderers and gates see is `stack.objects`, not the imported - * module. The trailing ungrouped bucket the SERVED object grows (the - * platform injects `owner_id`, which is neither hidden nor an audit column) - * is deliberately out of frame here — it is a registration-time addition, and - * the view comment states it in prose. + * The trailing ungrouped bucket the SERVED object grows (the platform + * injects `owner_id`, which is neither hidden nor an audit column) is + * deliberately out of frame: it is a registration-time addition. */ - it('derives the contact form sections from `fieldGroups` exactly as the view authors them', () => { + it('lays the contact edit and create forms out from `fieldGroups` and `showOnCreate`', () => { const object = (stack.objects ?? []).find( (o: { name: string }) => o.name === 'showcase_contact', - ); + ) as { fields?: Record } | undefined; const derived = deriveFieldGroupLayout(object); expect(derived, 'showcase_contact must declare fieldGroups (#5443)').not.toBeNull(); - expect(derived!.map((s) => s.key)).toEqual(['contact', 'work', 'status', 'notes']); + const edit = derived! + .filter((s) => s.key !== undefined) + .map((s) => ({ key: s.key, label: s.label, fields: s.fields })); + expect(edit).toEqual([ + { key: 'contact', label: 'Contact', fields: ['name', 'email', 'phone'] }, + { key: 'work', label: 'Work', fields: ['company', 'title', 'account'] }, + { key: 'status', label: 'Status', fields: ['stage', 'lead_score'] }, + { key: 'notes', label: 'Notes', fields: ['notes'] }, + ]); - const contact = (stack.views ?? []).find((v) => targetObject(v) === 'showcase_contact'); - const form = (contact as { form?: unknown } | undefined)?.form; - const authored = (form as { sections?: unknown } | undefined)?.sections; - const authoredPairs = (Array.isArray(authored) ? authored : []).map((s) => { - const section = s as { name?: unknown; label?: unknown; fields?: unknown }; - return { - key: section.name, - label: section.label, - fields: Array.isArray(section.fields) ? section.fields : [], - }; - }); - expect(derived!.map((s) => ({ key: s.key, label: s.label, fields: s.fields }))).toEqual( - authoredPairs, - ); + const asked = edit.flatMap((s) => s.fields).filter((f) => object?.fields?.[f]?.showOnCreate !== false); + expect(asked).toEqual(['name', 'email', 'phone', 'company']); + + const contact = (stack.views ?? []).find((v) => targetObject(v) === 'showcase_contact') as + | { form?: unknown; formViews?: unknown } + | undefined; + expect(contact, 'ContactViews must be registered (#5420)').toBeDefined(); + expect(contact?.form).toBeUndefined(); + expect(contact?.formViews).toBeUndefined(); }, 60_000); it('registers UI, automation, security, and AI metadata', () => { @@ -229,7 +226,8 @@ describe('showcase form + page section i18n coverage (#8231)', () => { * * Three sections used to be excluded here — `showcase_task`'s * `formViews.edit` ("Task") and `formViews.quick` ("Quick Edit"), and - * `showcase_contact`'s `formViews.create` ("Who is this?"). Naming them + * `showcase_contact`'s `formViews.create` ("Who is this?", since retired + * with the contact's other internal form, #36553). Naming them * would have flipped a currently-PINNED finding in * `packages/lint/src/validate-translatable-sections.test.ts` and * `validate-translation-references.test.ts`, which imported `TaskViews` / diff --git a/packages/cli/test/i18n-section-coverage.test.ts b/packages/cli/test/i18n-section-coverage.test.ts index cea9d5801fe..e6f3cee9455 100644 --- a/packages/cli/test/i18n-section-coverage.test.ts +++ b/packages/cli/test/i18n-section-coverage.test.ts @@ -525,31 +525,28 @@ describe('the emitted key is the key the platform declares and consumes', () => // ── Real metadata from the in-repo example app ───────────────────────── describe('the showcase app, walked for real', () => { - it('picks up `showcase_contact`’s default-form sections and `showcase_semantic_zoo`’s field groups', async () => { - const [{ ContactViews }, { SemanticZoo }] = await Promise.all([ + it('picks up `showcase_contact`’s and `showcase_semantic_zoo`’s field-group sections', async () => { + const [{ Contact }, { ContactViews }, { SemanticZoo }] = await Promise.all([ + import('../../../examples/app-showcase/src/data/objects/contact.object'), import('../../../examples/app-showcase/src/ui/views/contact.view'), import('../../../examples/app-showcase/src/data/objects/semantic-zoo.object'), ]); - const keys = sectionKeys({ objects: [SemanticZoo], views: [ContactViews] }); + const keys = sectionKeys({ objects: [SemanticZoo, Contact], views: [ContactViews] }); expect(keys.sort()).toEqual([ // `fieldGroups: [{ key: 'basics' }, { key: 'money' }]`, both referenced // by `group:` on real fields. 'objects.showcase_semantic_zoo._sections.basics.label', 'objects.showcase_semantic_zoo._sections.money.label', - // `ContactViews.form.sections[].name` — the container's DEFAULT form, - // which `ObjectForm` renders and translates like any other. NOT the - // only contributor: `formViews.create`'s sparse override names its own - // section too (objectstack#8231), which is the entry right below. + // `Contact.fieldGroups` — the four groups the contact's create and edit + // forms are laid out by (objectstack#36553). `ContactViews` declares a + // list and no form, so it adds no section of its own: the create form's + // former `who_is_this` heading is gone with the form that named it. 'objects.showcase_contact._sections.contact.label', 'objects.showcase_contact._sections.notes.label', 'objects.showcase_contact._sections.status.label', 'objects.showcase_contact._sections.work.label', - // `ContactViews.formViews.create.sections[0].name` — the sparse create - // override's own section ("Who is this?"), named by objectstack#8231's - // remainder. Distinct surface, same object, same walker. - 'objects.showcase_contact._sections.who_is_this.label', ].sort()); }, 60_000); }); diff --git a/scripts/cross-package-test-inputs.mjs b/scripts/cross-package-test-inputs.mjs index 8d94bf5fe71..4429172c853 100644 --- a/scripts/cross-package-test-inputs.mjs +++ b/scripts/cross-package-test-inputs.mjs @@ -465,8 +465,9 @@ export const CROSS_PACKAGE_TEST_INPUTS = { // The `examples/` globs are the showcase modules two i18n tests import LIVE // across the workspace boundary, each named per file because the two read // DIFFERENT namespaces and are not interchangeable: - // test/i18n-section-coverage.test.ts dynamically imports `contact.view` - // and `semantic-zoo.object` and asserts `toEqual` over an exhaustive + // test/i18n-section-coverage.test.ts dynamically imports `contact.view`, + // `contact.object` (whose `fieldGroups` lay out the contact's forms + // since #36553) and `semantic-zoo.object` and asserts `toEqual` over an exhaustive // hardcoded `_sections` key list, so any newly NAMED section in either // module goes red -- this is what PR #8742 broke in queue build // 31825946401, where the merge queue was the first signal. @@ -576,6 +577,7 @@ export const CROSS_PACKAGE_TEST_INPUTS = { 'packages/services/service-cluster/src/**', 'packages/connectors/connector-mcp/src/connector-mcp-plugin.ts', 'examples/app-showcase/src/ui/views/contact.view.ts', + 'examples/app-showcase/src/data/objects/contact.object.ts', 'examples/app-showcase/src/data/objects/semantic-zoo.object.ts', 'examples/app-showcase/src/ui/pages/task-triage.page.ts', 'content/docs/deployment/cli.mdx', From 7bf4784e5da2e9f45ffb428db61ee35656fce932 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 13:10:06 +0000 Subject: [PATCH 2/4] build(turbo): hash the showcase contact object into cli's test inputs packages/cli's i18n-section-coverage pin now reads the contact object's fieldGroups, so the declared input joins the registry and turbo.json. Claude-Session: https://claude.ai/code/session_01L9qibzpqH1nQTsbGckLspg Co-authored-by: Claude --- turbo.json | 1 + 1 file changed, 1 insertion(+) diff --git a/turbo.json b/turbo.json index 5bca2af8cbf..e356037c191 100644 --- a/turbo.json +++ b/turbo.json @@ -280,6 +280,7 @@ "$TURBO_ROOT$/packages/services/service-cluster/src/**", "$TURBO_ROOT$/packages/connectors/connector-mcp/src/connector-mcp-plugin.ts", "$TURBO_ROOT$/examples/app-showcase/src/ui/views/contact.view.ts", + "$TURBO_ROOT$/examples/app-showcase/src/data/objects/contact.object.ts", "$TURBO_ROOT$/examples/app-showcase/src/data/objects/semantic-zoo.object.ts", "$TURBO_ROOT$/examples/app-showcase/src/ui/pages/task-triage.page.ts", "$TURBO_ROOT$/content/docs/deployment/cli.mdx", From 4e61e4ce912c1679b41bc98e564c2e9cce5a2e3d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 14:10:13 +0000 Subject: [PATCH 3/4] test(dogfood): match a withheld field name as a word, and hold the groups' members showcase_project now serves a `budget_schedule` field group to the client liaison: its heading stays, and FLS drops the withheld budget and spent from its member list. The served-document scan matched the group key as a substring, so it now matches `budget` as a whole word and pins the group members separately. Claude-Session: https://claude.ai/code/session_01L9qibzpqH1nQTsbGckLspg Co-authored-by: Claude --- .../test/rest-config-contract-live.dogfood.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts b/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts index 3dba5c2982d..3649edbb295 100644 --- a/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts +++ b/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts @@ -170,8 +170,15 @@ describe('[#26572] the default RestServerConfig on a booted showcase: crud, batc expect(liaisonDoc.status, liaisonDoc.text).toBe(200); const served = Object.keys(fieldsOf(liaisonDoc)); for (const f of WITHHELD) expect(served).not.toContain(f); - // Absent, not blanked: the name appears nowhere in the served document. - expect(liaisonDoc.text).not.toMatch(/budget|"spent"/); + // Absent, not blanked: the name appears nowhere in the served document — + // as a key, a list member or an expression's `record.budget`. Matched as a + // whole word: the object's `budget_schedule` field group is a heading the + // liaison is served, and the next assertion holds its members. + expect(liaisonDoc.text).not.toMatch(/\bbudget\b|"spent"/); + // The field groups keep their headings and drop the withheld members. + const groups = ((liaisonDoc.json.item ?? liaisonDoc.json).fieldGroups ?? []) as Array<{ fields?: string[] }>; + expect(groups.length, 'showcase_project declares fieldGroups').toBeGreaterThan(0); + for (const g of groups) for (const f of WITHHELD) expect(g.fields ?? []).not.toContain(f); // Every other field is served unchanged in kind. expect(served).toEqual(Object.keys(fieldsOf(adminDoc)).filter((f) => !WITHHELD.includes(f))); }); From 6b4b05aca6f289661f9bcce835ae9067aadacf68 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 15:05:38 +0000 Subject: [PATCH 4/4] test(dogfood): keep the full budget scan and take out only the group heading The previous round matched `budget` as a whole word, which treats `_` as a word character and so misses a leaked `budget_amount`. Restore the original /budget|"spent"/ scan and remove only the served heading's exact JSON tokens ("budget_schedule", "Budget & Schedule") from the haystack. Pin that the scan still catches each withheld field and the lookalikes once the heading is out. Claude-Session: https://claude.ai/code/session_01L9qibzpqH1nQTsbGckLspg --- .../rest-config-contract-live.dogfood.test.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts b/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts index 3649edbb295..a17984b3764 100644 --- a/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts +++ b/packages/qa/dogfood/test/rest-config-contract-live.dogfood.test.ts @@ -171,10 +171,20 @@ describe('[#26572] the default RestServerConfig on a booted showcase: crud, batc const served = Object.keys(fieldsOf(liaisonDoc)); for (const f of WITHHELD) expect(served).not.toContain(f); // Absent, not blanked: the name appears nowhere in the served document — - // as a key, a list member or an expression's `record.budget`. Matched as a - // whole word: the object's `budget_schedule` field group is a heading the - // liaison is served, and the next assertion holds its members. - expect(liaisonDoc.text).not.toMatch(/\bbudget\b|"spent"/); + // as a key, a list member, an expression's `record.budget` or a lookalike + // such as `budget_amount`. The one served string that legitimately says + // "budget" is the `budget_schedule` field group's heading; only its exact + // JSON tokens are taken out before the scan, so `"budget_schedule_x"` and + // every other spelling stay in. + const LEAK = /budget|"spent"/; + const HEADING_TOKENS = ['"budget_schedule"', '"Budget & Schedule"']; + expect(liaisonDoc.text, 'the budget_schedule heading is served').toContain('"budget_schedule"'); + const haystack = HEADING_TOKENS.reduce((t, tok) => t.split(tok).join('""'), liaisonDoc.text); + expect(haystack).not.toMatch(LEAK); + // The scan still sees each withheld name, and lookalikes, once the heading is out. + for (const leak of [...WITHHELD.map((f) => `"${f}":{}`), '"budget_amount"', 'record.budget > 1', '"budget_schedule_x"']) { + expect(haystack + leak, leak).toMatch(LEAK); + } // The field groups keep their headings and drop the withheld members. const groups = ((liaisonDoc.json.item ?? liaisonDoc.json).fieldGroups ?? []) as Array<{ fields?: string[] }>; expect(groups.length, 'showcase_project declares fieldGroups').toBeGreaterThan(0);