refactor(browser): unify fill field normalization

This commit is contained in:
Peter Steinberger
2026-02-26 22:17:58 +01:00
parent 69b2f8cd8b
commit eaa9e1c661
6 changed files with 94 additions and 53 deletions

View File

@@ -1,4 +1,5 @@
import type { BrowserFormField } from "../client-actions-core.js";
import { normalizeBrowserFormField } from "../form-fields.js";
import type { BrowserRouteContext } from "../server-context.js";
import { registerBrowserAgentActDownloadRoutes } from "./agent.act.download.js";
import { registerBrowserAgentActHookRoutes } from "./agent.act.hooks.js";
@@ -190,21 +191,7 @@ export function registerBrowserAgentActRoutes(
if (!field || typeof field !== "object") {
return null;
}
const rec = field as Record<string, unknown>;
const ref = toStringOrEmpty(rec.ref);
const type = toStringOrEmpty(rec.type) || "text";
if (!ref) {
return null;
}
const value =
typeof rec.value === "string" ||
typeof rec.value === "number" ||
typeof rec.value === "boolean"
? rec.value
: undefined;
const parsed: BrowserFormField =
value === undefined ? { ref, type } : { ref, type, value };
return parsed;
return normalizeBrowserFormField(field as Record<string, unknown>);
})
.filter((field): field is BrowserFormField => field !== null);
if (!fields.length) {