fix(form): harden the spec↔runtime form-field chokepoint, derive SelectOption, complete FormFieldSchema (#3090 PR1) - #3091
Merged
Conversation
…ctOption, complete FormFieldSchema (#3090) normalizeSectionField dropped four spec-17 FormField keys — worst of all the ADR-0089 canonical `visibleWhen` spelling (the deprecated `visibleOn` worked): route it into the view-level slot so it ANDs with the object-level rule, carry `dependsOn`/`keyField`/`disclosure`, and fold the same slot into WizardForm's final-submit gate so a view-hidden required field can no longer block submission from off-screen. A behavioral parity gate now walks the spec FormFieldSchema key set both ways (added key = unmapped failure, retired key = stale failure), mutation-tested. SelectOptionSchema derives from @objectstack/spec/data by reference — it used to strip `color` (which @object-ui/fields renders), `default`, and the per-option `visibleWhen` gate — with pinned divergences (value widened for UI forms, visibleWhen on the #2212 wire contract) and documented UI-only extensions; ledger 124 → 122 (SelectOption, SelectOptionSchema → ALLOW with drift guards). FormFieldSchema now covers every key the FormField interface declares and makes `type` optional to match it, so `objectui validate` stops rejecting metadata the renderer accepts and stops stripping typo'd predicates; `{ field: … }` (spec vocabulary) stays rejected, pinning the two-layer boundary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#3090 的 PR1(修缺陷,零破坏)。三块,每块都带 mutation-tested 闸门。
1. 枢纽补缺:
normalizeSectionField丢了四个 spec 17 键最恶劣的一个:ADR-0089 把视图级可见性谓词的规范拼写定为
visibleWhen,而枢纽只 attach 弃用的visibleOn—— 用规范拼写写的表单视图丢谓词,用弃用拼写反而能用。修法:视图级visibleWhen路由进视图层槽位(visibleOn),与对象级规则(fromObjectSchema拷入的visibleWhen槽)AND 叠加而非互相覆盖(渲染器本来就分别评估两个槽位);两个拼写同时出现时规范拼写赢(saveMeta按原样持久化,线上的元数据两种都有)。连带堵住一个新暴露面:WizardForm 的最终提交重查只评估
visibleWhen槽 —— 视图级谓词生效后,一个被视图隐藏的必填字段会在屏幕外卡死提交。重查现在与 form.tsx 一样折叠visibleOn槽(回归测试:谓词为假时提交放行)。另三个键:
dependsOn(级联声明,渲染器读顶层)、keyField、disclosure(record/composite 控件配置,透传)。闸门:
sectionFields.spec-parity.test.ts按 specFormFieldSchema.in.shape逐键行为断言(28 键各有一行,断言落点:helpText→description、readonly→disabled、双拼写→visibleOn槽……),并双向比对键集 —— spec 加键红(unmapped)、退键红(stale)。已突变验证:删掉keyField映射行,对应行即红。2.
SelectOptionSchema改为 spec 派生(台账 124 → 122)旧手抄件静默剥掉
color(@object-ui/fields实际渲染 badge/dot 颜色)、default、以及逐选项visibleWhen门控 —— 一个带权限门控的选项过了objectui validate,门却被扒了。现在 spec 键按引用流入,两个钉住的有意分歧(value放宽到 string|number|boolean;visibleWhen保持 #2212 wire 契约,不用 spec 的 envelope 规范化管道,输出形状不变)+ 两个 UI 扩展(disabled/icon)。TSSelectOption补color/default。台账:
SelectOption/SelectOptionSchema从 DEBT 移入 ALLOW(带理由与守卫指针)。parity 测试四向守卫:spec 加键、退键、认领扩展名、自行放宽value,任一发生即红。3.
FormFieldSchema(runtime 词汇)补齐自家契约CLI 唯一强制执行的表单字段契约此前只覆盖 TS 接口 13 个声明键、且要求接口里可选的
type必填:渲染器接受的元数据过不了校验,而visibleWhen: 42这种错值被 strip 静默吞掉。补齐widget/dependsOn/hidden/readonly/visibleOn/visibleWhen/readonlyWhen/requiredWhen/span,type改可选。边界钉死:
{ field: 'email' }(spec 词汇)仍然拒绝 —— 双层边界属于枢纽,不属于双键读(PR2 只改错误文案,不改判定)。set-coverage 断言钉住键集(TS 接口带 index signature,两个方向的可赋值性探针都会说谎 —— 见 checker 头注 lie #3 —— 故按 #3017 模板用 pinned list)。验证
Closes 部分 #3090(PR1 复选框)。关联 objectstack#4115。
🤖 Generated with Claude Code