- 新增 CheckerDefinition.normalize 必需方法,typecheck 兜底遗漏实现 - 新增 expect/normalize.ts 共享 helper(compactExpect、normalizeValue、 normalizeContent、normalizeKeyed) - 为 HTTP、Cmd、DB、TCP、UDP、ICMP、LLM、WS、DNS 各新增独立 normalize.ts - 简化 normalizer.ts:删除所有 checker type switch,改为 registry 委托 - 修复 DNS authoring 简写 bug:durationMs、valueCount、result 等字段 现可通过完整加载链路 - 新增 DNS 回归测试和 registry 级合同测试 - 更新 docs/development/checker.md:补充 normalize 规范、文件结构、 测试要求和 checklist
20 lines
751 B
TypeScript
20 lines
751 B
TypeScript
import { isPlainObject } from "es-toolkit";
|
|
|
|
import type { RawTargetConfig } from "../../types";
|
|
|
|
import { compactExpect, normalizeContent, normalizeKeyed, normalizeValue } from "../../expect/normalize";
|
|
|
|
export function normalizeTargetExpect(target: RawTargetConfig): RawTargetConfig {
|
|
if (target.expect === undefined || !isPlainObject(target.expect)) return target;
|
|
const raw = target.expect as Record<string, unknown>;
|
|
return {
|
|
...target,
|
|
expect: compactExpect(raw, {
|
|
durationMs: normalizeValue(raw["durationMs"]),
|
|
result: normalizeContent(raw["result"]),
|
|
rowCount: normalizeValue(raw["rowCount"]),
|
|
rows: Array.isArray(raw["rows"]) ? raw["rows"].map((row) => normalizeKeyed(row)) : raw["rows"],
|
|
}),
|
|
};
|
|
}
|