From 472f310b64786f1b14faed91c432d68538f8cf26 Mon Sep 17 00:00:00 2001 From: ssw Date: Tue, 28 Jul 2026 15:55:51 +0800 Subject: [PATCH] =?UTF-8?q?chore(form):=20T2=20review=20=E2=80=94=20orphan?= =?UTF-8?q?=20--strict,=20@deprecated=20tag,=20magic=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/form/_relationform_completeness.ts | 3 +++ src/commands/form/_schema_normalize.ts | 6 ++++-- src/commands/form/update.ts | 12 ++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/commands/form/_relationform_completeness.ts b/src/commands/form/_relationform_completeness.ts index ade0d59..6b708af 100644 --- a/src/commands/form/_relationform_completeness.ts +++ b/src/commands/form/_relationform_completeness.ts @@ -177,6 +177,9 @@ export async function completeRelationFormFields( * 现 (webapi hardening) 合并为统一规则: relationForm 控件必须 3 字段齐全, 走 * `validateStrictSchema` 一处定义. 旧 API 保留为薄壳, 内部 delegate, 避免上游 * (form/update + tests/unit/form_update_fields.test.ts) 出现"两套校验" 漂移. + * + * @deprecated since v0.23 — use `validateStrictSchema` from `./_schema_normalize.ts`. + * Retained only for backward compatibility with `tests/unit/form_update_fields.test.ts`. */ export function validateRelationFormFields(fields: any[]): { ok: boolean; errors: string[] } { return validateStrictSchema(fields as any) diff --git a/src/commands/form/_schema_normalize.ts b/src/commands/form/_schema_normalize.ts index 4ed889f..6bc5959 100644 --- a/src/commands/form/_schema_normalize.ts +++ b/src/commands/form/_schema_normalize.ts @@ -23,6 +23,8 @@ const CONFIG_KEYS = [ ] as const const CONFIG_KEY_SET = new Set(CONFIG_KEYS) const RELATION_FORM_KEYS = ['modelId', 'propsValue', 'relationField', 'showField', 'relationTable'] +/** 控件 jnpfKey 标识: 关联表单 (web formGenerator `relationForm` 控件). */ +export const RELATION_FORM_JNPF_KEY = 'relationForm' /** relationForm 控件必填字段 (web 渲染需 modelId + propsValue + relationField 才能下拉选择). */ const RELATION_FORM_REQUIRED = ['modelId', 'propsValue', 'relationField'] /** 控件禁止 required 的集合 — mirrors web component capability matrix @@ -72,7 +74,7 @@ export function applyNormalizedPatch(existing: FormField[], patches: Record', '期望的 enCode (与 getInfo 对比, 防止覆盖外部修改)') .option('--expected-state ', '期望的 state (0/1/2, 防止覆盖外部修改)') .option('--force', '跳过 dirty check, 强制覆盖 (慎用!)', false) - .option('--strict', 'v2.4+: 严格校验 relationForm 4 字段 (jnpfKey/modelId/propsValue/relationField) 必填. 默认 ON, --no-strict 跳过', true) - .option('--no-strict', 'v2.4+: 跳过 strict 校验 (兼容老用法, 不推荐)') + .option('--strict', 'deprecated since v0.23: strict 永远跑, 此选项保留仅为向后兼容, 不再生效 (统一走 validateStrictSchema)', true) + .option('--no-strict', 'deprecated since v0.23: 已 no-op, strict 永远跑. 仅作为迁移诊断选项保留') addOutputOptions(cmd) .action(async (opts: Opts) => { setupOutputFilter(opts) @@ -433,7 +437,7 @@ export function buildFormUpdateCommand(): Command { 'PUT 语义, 未传字段保留原值', '自动 BS-49 enCode 唯一性检测 + BS-53 自动重新发布', '--fields 增量合并, 按 vmodel 去重 (新增追加, 重复替换)', - 'v2.4+ (2026-07-24): --strict (默认 ON) 校验 relationForm 4 字段必填. 缺字段时用 `dacli form relation-form-complete --id=` 自动补', + 'v0.23+ (webapi hardening): strict 校验已无条件执行 (validateStrictSchema 统一一处). --strict / --no-strict 已 deprecated, 保留仅为向后兼容. 缺字段时用 `dacli form relation-form-complete --id=` 自动补', ], }) return cmd