|
1 | 1 | --- |
2 | | -'@objectstack/lint': patch |
| 2 | +'@objectstack/lint': minor |
3 | 3 | --- |
4 | 4 |
|
5 | | -fix(lint): the field-name indexes judge an object as the registry serves it, so a formula, validation, flow, hook, sharing-rule condition, flow node write, action or hook body write, react page prop or translation key naming a field that an `objectExtensions` entry adds is no longer refused (#30471) |
| 5 | +fix(lint)!: the field-name indexes judge an object as the registry serves it, so a read, write or sort naming a field an `objectExtensions` entry adds is no longer refused as unknown, and the readonly, sortability and translation rules judge that field by its served definition (#30471) |
6 | 6 |
|
7 | | -Clause-②: yes (widening: field-name reads accept fields a sibling package adds through `objectExtensions`, which the runtime already serves; any site that deliberately stays on declared fields says why) |
8 | | -Metadata-protocol: none (lint judgements, no authorable key) |
| 7 | +Clause-②: yes (narrowing) — `os validate` / `os build` / `os lint` refuse two shapes they accepted before: a hook body's literal `ctx.api.object(NAME).update(…)` / `.updateById(…)` / `.insert(…)` writing a field an `objectExtensions` entry adds and declares `readonly: true` moves from a `hook-body-write-unknown-field` warning to a `hook-api-update-readonly-field` error; and a translation key naming a field or validation rule that only a replaced earlier entry of the same package adds, or only a top-level `objectExtensions` beside `packages[]` adds, is now `translation-target-unknown` at `error`, where it resolved. The widening half: a formula, validation, flow condition, hook condition, sharing-rule condition, flow-node, action-body or hook-body write, react page field prop, translation key, page sort or list-view sort naming a field an `objectExtensions` entry of the same artifact adds is no longer refused as an unknown field. |
| 8 | +Metadata-protocol: narrowed |
| 9 | +Skills-docs: updated here — content/docs/automation/hook-bodies.mdx |
9 | 10 |
|
10 | | -- **Before.** The `record.FIELD` index of the expression passes (validation rules, formulas, flow conditions, hooks, sharing-rule conditions), the field index of the three write rules (`flow-node-write-unknown-field`, `action-body-write-unknown-field`, `hook-body-write-unknown-field`) and a react page's field props read an object's declared `fields` only. On a multi-package artifact, where a module package adds fields to an app package's object through `objectExtensions`, a read or write naming one of those fields was refused as unknown although the runtime serves the field. The translation rule folded extensions through a reader of its own that kept every entry and read the top level beside `packages[]`. |
11 | | -- **Now.** They read the one shared fold in `object-graph.ts`, as the field-path rules do since #30383: the declared fields plus every field an `objectExtensions` entry of any body adds, one entry per package per object. A field no body declares or adds keeps the same refusal, with the same rule id, severity and message. A field two packages write at the same deciding priority is a served name, but the expression passes judge neither its type nor whether it is nullable, since which definition wins is registration order. The write rules still leave an object that declares no field unjudged. The translation rule now keeps one entry per package per object too, so a key naming a field or rule only a replaced earlier entry of the same package adds is an orphan, as the registry serves it. The three readonly write rules (`flow-update-readonly-field`, `hook-api-update-readonly-field`, `action-api-update-readonly-when-field` and their siblings) judge an extension field's served definition too, so a body write to an extension field declared `readonly` or `readonlyWhen` is refused by the readonly rule, where it was refused as an unknown field before; for a hook's `ctx.api.object(...).update(...)` write that moves the finding from a `warning` (`hook-body-write-unknown-field`) to the readonly rule's `error`, the severity it already has for a declared readonly field. A field two packages tie on is not judged readonly. A misspelled field within edit distance 3 of an extension-added name now gets a did-you-mean naming that field. |
| 11 | +<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed or renamed: objects, object extensions, flows, hooks, actions, pages, views and translation bundles keep their shapes and meanings. What moves is which rule judges a name an objectExtensions entry adds, and at what severity: the hook write it now refuses was dropped at run time by the readonly strip, and the translation key it now refuses names nothing the registry serves. There is no rewrite that keeps what the author meant; the author drops the write or the key, or moves it to the entry the registry keeps, and the refusal says 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.** The field-name indexes of the expression passes (validation rules, formulas, flow and hook conditions, sharing-rule conditions), the three write rules, a react page's field props, the three readonly write rules and the sort rule read an object's declared `fields` only, so a name an `objectExtensions` entry adds was refused as unknown although the runtime serves the field: `flow-node-write-unknown-field` and `sort-field-unknown` / `page-field-unknown` (page sorts) at `error`, `action-body-write-unknown-field`, `hook-body-write-unknown-field` and `page-field-unknown` (react props) at `warning`, the expression passes' unknown-field error. The translation rule folded extensions through a reader of its own that kept every entry and also read a top-level `objectExtensions` beside `packages[]`. |
| 16 | +- **Now.** Every one of them reads the one shared fold in `object-graph.ts` (since #30383 the field-path rules' fold): the declared fields plus each field an `objectExtensions` entry adds, one entry per package per object, `packages[]` alone when the artifact carries it. A name no body declares or adds keeps the same refusal, rule id, severity and message; a misspelling within edit distance 3 of an extension-added name now gets a did-you-mean naming it. A name the fold adds is judged by its served definition, so these findings move (union artifact and per-package leg alike): |
| 17 | + - a hook body's `ctx.api` update / updateById / insert of a `readonly: true` field: `hook-body-write-unknown-field` `warning` → `hook-api-update-readonly-field` `error`, the severity a declared readonly field already gets (a non-system hook's `ctx.api` write is stripped at run time and the call returns success); |
| 18 | + - a translation key naming a field or rule only a replaced earlier entry of the same package, or only a top-level `objectExtensions` beside `packages[]`, adds: resolved → `translation-target-unknown` `error`, as the registry serves the object; |
| 19 | + - a flow `update_record` / `create_record` of a `readonly: true` field: `flow-node-write-unknown-field` `error` → `flow-update-readonly-field` `error`; |
| 20 | + - a page sort (every slot) or list-view sort by a `formula` field or one declaring `sortable: false`: `page-field-unknown` / `sort-field-unknown` `error` → `sort-field-unsortable` `error`; |
| 21 | + - a `readonlyWhen` field written by a flow `update_record` (`error` → `flow-update-readonly-when-field` `warning`), a hook's `ctx.api` update (`warning` → `hook-api-update-readonly-when-field` `warning`) or an action's `ctx.api` update (`warning` → `action-api-update-readonly-when-field` `warning`); |
| 22 | + - an expression reading the field: the unknown-field error becomes the served type's verdict (a type mismatch or a missing null guard, at `error` in validation rules and hook conditions, at `warning` in formulas and sharing-rule conditions) or nothing. |
| 23 | + Every other read, write or sort naming such a field passes: a hook's `ctx.input` stamp, an action's `ctx.api` write of a `readonly: true` field (an action runs elevated) and a `create_record` of a `readonlyWhen` field land at run time. |
| 24 | +- **Not judged.** A field two packages write at the same deciding priority is a served name, but no rule judges its type, nullability, readonly or sortability: which definition wins is registration order. An object that declares no field of its own stays unjudged by the write, readonly and sort rules, extended or not (an introspected schema). A react page's `searchableFields` still reads declared fields only. |
| 25 | +- **Not changed.** Which extension entries the fold keeps, the runtime, and `defineStack` (its related-list check stays additive). A stack that names no extension field reads as before. |
| 26 | + |
| 27 | +**What an author does.** For a hook writing a readonly extension field, declare the hook `runAs: 'system'`, stamp the value in the record's own `beforeInsert` / `beforeUpdate` hook, or drop the field from the payload. For a translation key the fold drops, key it to a field or rule of the entry the registry keeps (the package's last entry for that object, in a `packages[]` body), or delete it. |
0 commit comments