Skip to content

Commit 2818af5

Browse files
committed
fix(lint)!: the remaining field indexes judge an object as served, and an object that declares no field keeps the list-view skip once extended (#30608)
The form-layout, notify email-field recipient, public form file-field, flow template, page visualization binding, searchable-fields and autonumber indexes read objectsAsServed: a field an objectExtensions entry adds is known, a re-declared field is judged on the extension's definition, a tied field is a served name judged on no definition, and an object that declares no field stays unjudged where main skipped it. A react page's <ListView searchableFields> reads the same served search index. The list-view rule asks its declares-nothing skip of the declared object. Claude-Session: https://claude.ai/code/session_01L6bhgVSM5tJd2UYk3Aa1MM Co-authored-by: Claude <noreply@anthropic.com>
1 parent a839020 commit 2818af5

11 files changed

Lines changed: 530 additions & 58 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/lint': minor
3+
---
4+
5+
fix(lint)!: the remaining field indexes (form layout, notify email-field recipient, public form file field, flow templates, page visualization bindings, searchable fields, autonumber formats) judge an object as the registry serves it, and an object that declares no field keeps the list-view rule's skip once an extension adds to it (#30608)
6+
7+
Clause-②: yes (narrowing) — `os validate` / `os build` / `os lint` refuse shapes they accepted before, each a field an `objectExtensions` entry of the same artifact adds or re-declares, now judged on its served definition: a notify node's `recipients.emailField` naming an owner `email` field an extension re-declares as `text` is `notify-email-field-not-email` at `error`; a form open to anonymous intake whose section names an `image` / `file` field an extension adds, or an owner field an extension re-declares as one, is `public-form-file-field` at `error`; a `list` page whose `allowedVisualizations` leads with `gallery` over an owner `image` field an extension re-declares as `text` is `page/visualization-without-binding` at `error`; a `searchableFields` entry naming an owner text field an extension re-declares as `formula` is `searchable-field-unsearchable` at `error`; an autonumber field an extension adds whose format names a field the object lacks is `autonumber-references-unknown-field` at `error`, and an autonumber format naming an owner field declared `required: true` that an extension re-declares without it is `autonumber-references-optional-field` at `warning`; a flow template `{{ record.F.sub }}` through an owner text field an extension re-declares as a lookup is `flow-template-lookup-traversal` at `warning`. The widening half: a form section, a notify email-field recipient, a flow template hole, a gallery or calendar binding, a `searchableFields` entry (an object's own set, a list view's narrowing, a react page's `<ListView searchableFields>`) or an autonumber format naming a field an `objectExtensions` entry adds is no longer refused as unknown, and a list view over an object that declares no field is no longer refused once an extension adds to it.
8+
Metadata-protocol: narrowed
9+
Skills-docs: none — measured: no sentence in `skills/` or `content/docs/` states a declared-only reading of the moved rule ids
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed or renamed: objects, object extensions, forms, flows, pages, views and autonumber formats keep their shapes and meanings. What moves is that a field an objectExtensions entry adds or re-declares is judged on the definition the registry serves. Each new refusal names a field whose served definition the runtime already refuses or misrenders (a text address, a file on an anonymous form, a gallery with no image field, a formula search column, an autonumber whose scope field may be blank or absent). There is no rewrite that keeps what the author meant; the author fixes the extension's definition or the reference, and the refusal names which. -->
12+
13+
**BREAKING** accept-set narrowing in `os validate` / `os build` / `os lint` (`@objectstack/lint`), for multi-package artifacts whose bodies add fields to another package's object through `objectExtensions`.
14+
15+
- **Before.** Seven field indexes read an object's declared `fields` only: the form-layout rule (`form-field-unknown`), the notify email-field recipient rule, the public form file-field rule, the flow template rule, the page visualization binding rule, the searchable-fields index (`indexObjectSearchTargets`, behind both an object's or list view's `searchableFields` and a react page's `<ListView searchableFields>`) and the autonumber format lint. A field an `objectExtensions` entry adds was unknown to them although the runtime serves it, and a field an extension re-declares was judged on the owner's definition. The list-view rule, since it reads the served graph, judged an object that declares no field as having only the extension's fields.
16+
- **Now.** Each reads the shared fold in `object-graph.ts` (`objectsAsServed`): the declared fields plus each field an `objectExtensions` entry adds, an extension's re-declared field replacing the owner's definition whole, as the registry's `mergeObjectDefinitions` does. A name no body declares or adds keeps the same refusal, rule id, severity and message. These findings move (union artifact and per-package leg alike):
17+
- an extension-added field named by a form section, a notify email-field recipient (typed `email`), a flow template hole, a `searchableFields` entry or an autonumber format (declared `required: true`): its unknown-field verdict (`form-field-unknown` `warning`, `notify-email-field-unknown` `error`, `flow-template-unknown-field` `warning`, `searchable-field-unknown` `error`, `autonumber-references-unknown-field` `error`) → nothing; a `gallery` / `calendar` binding derives from it, so `page/visualization-without-binding` → nothing;
18+
- the same field typed otherwise: a notify recipient typed `text` → `notify-email-field-not-email` `error` (was `notify-email-field-unknown` `error`); an autonumber format naming it not `required` → `autonumber-references-optional-field` `warning` (was `autonumber-references-unknown-field` `error`); on a public form, an `image` / `file` / `avatar` / `video` / `audio` field → `public-form-file-field` `error` (was unjudged);
19+
- an owner field an extension re-declares: judged on the extension's type, `required`, or autonumber format (the rows the Clause-② line names), and the inverse re-declarations pass (an owner `file` field re-declared `text` on a public form, an owner lookup re-declared `text` in a template, an owner autonumber re-declared `text`);
20+
- an autonumber field an extension adds is checked as an owner's is;
21+
- a list view over an object that declares no field: `list-view-field-unknown` `error` → nothing, extended or not.
22+
- **Not judged.** A field two packages write at the same deciding priority is a served name, but no rule judges its type, `required` or autonumber format: which definition wins is registration order (a gallery page over an object carrying one is not reported). An object that declares no field of its own stays unjudged by the notify, public form, page visualization, searchable and autonumber rules and by the list-view rule, extended or not (an introspected schema). The form-layout and flow template rules judged such an object against the empty set before and still do, an extension's own names now known.
23+
- **Not changed.** Which extension entries the fold keeps, the runtime, the object-level reads (`external`, the injected anchors, an object's own list views and `searchableFields`), and the finding paths. A stack that names no extension field reads as before.
24+
25+
**What an author does.** Fix the extension's field definition (type an email recipient `email`, keep a file field off a public form, give a gallery an image field, keep a search column stored, mark an autonumber scope field `required: true`) or the reference that names it.

‎packages/lint/src/lint-autonumber-formats.ts‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,26 @@
2727
* a `format` shorthand the runtime then rendered and threw on. A field that
2828
* declares neither key is checked against the contract default, which is what
2929
* it mints with.
30+
*
31+
* [#30608] Each object is read as SERVED (`objectsAsServed`, the package's one
32+
* fold): the engine mints against the registry's merged object, so a format
33+
* may interpolate a field an `objectExtensions` entry of the same artifact
34+
* adds, an autonumber field an extension adds is minted and so checked, and an
35+
* owner's field an extension re-declares is read on the extension's
36+
* definition, which replaces the owner's whole (the registry's
37+
* `mergeObjectDefinitions`): an autonumber re-declared as `text` mints
38+
* nothing, and a referenced field re-declared without `required` is optional.
39+
* Whether a field is an autonumber, its format and whether it is required are
40+
* its definition, so a field two packages tie on is never walked as an
41+
* autonumber, and a format naming one is reported neither unknown (the name is
42+
* served) nor optional (which definition wins is registration order). An
43+
* object that declares no field (an introspected schema) is skipped, extended
44+
* or not: its other columns are not visible here, so a format naming one would
45+
* read as unknown.
3046
*/
3147

3248
import { parseAutonumberFormat, referencedFields, resolveAutonumberFormat } from '@objectstack/spec/data';
33-
import { recordsOf } from './object-graph.js';
49+
import { objectsAsServed, objectsWithoutTiedFields, recordsOf } from './object-graph.js';
3450

3551
export interface AutonumberLintFinding {
3652
where: string;
@@ -53,14 +69,22 @@ export const AUTONUMBER_LITERAL_TOKEN = 'autonumber-unrecognized-token';
5369
*/
5470
export function lintAutonumberFormats(stack: AnyRec): AutonumberLintFinding[] {
5571
const findings: AutonumberLintFinding[] = [];
56-
for (const obj of recordsOf(stack.objects)) {
72+
const declared = recordsOf(stack.objects);
73+
const servedFold = objectsAsServed(stack);
74+
const served = objectsWithoutTiedFields(servedFold);
75+
declared.forEach((obj, i) => {
5776
const objectName = typeof obj.name === 'string' ? obj.name : '(unnamed object)';
58-
const fields = recordsOf(obj.fields);
59-
// name → required?, for schema-aware reference checks.
60-
const fieldMeta = new Map<string, { required: boolean }>();
77+
// [#30608] Skipped when it declares no field, extended or not (module note).
78+
if (!recordsOf(obj.fields).some((f) => typeof f.name === 'string')) return;
79+
const fields = recordsOf(served[i].fields);
80+
const tiedKeys = typeof obj.name === 'string' ? servedFold.tied.get(obj.name) : undefined;
81+
// name → required?, for schema-aware reference checks. `null` is a field
82+
// two packages tie on: served, of no stated definition.
83+
const fieldMeta = new Map<string, { required: boolean } | null>();
6184
for (const f of fields) {
6285
if (typeof f.name === 'string') fieldMeta.set(f.name, { required: f.required === true });
6386
}
87+
for (const key of tiedKeys ?? []) fieldMeta.set(key, null);
6488

6589
for (const f of fields) {
6690
if (f.type !== 'autonumber') continue;
@@ -106,6 +130,7 @@ export function lintAutonumberFormats(stack: AnyRec): AutonumberLintFinding[] {
106130
continue;
107131
}
108132
const meta = fieldMeta.get(ref);
133+
if (meta === null) continue;
109134
if (!meta) {
110135
findings.push({
111136
where,
@@ -125,6 +150,6 @@ export function lintAutonumberFormats(stack: AnyRec): AutonumberLintFinding[] {
125150
}
126151
}
127152
}
128-
}
153+
});
129154
return findings;
130155
}

0 commit comments

Comments
 (0)