classifyCustomFieldsSync function exported ✓ 100.0%
Last updated: 2026-03-04T23:21:38.391Z
Metrics
LOC: 22
Complexity: 7
Params: 1
Coverage: 100.0% (4/4 lines, 0x executed)
Signature
classifyCustomFieldsSync(fields: FormField[]): : FormField[]
Source Code
export function classifyCustomFieldsSync(fields: FormField[]): FormField[] {
for (const field of fields) {
const result = keywordClassifier.detect(field);
if (result) {
// Only upgrade when keyword adds semantic specificity.
// Never let a generic type ("text", "unknown") override a concrete
// adapter-set type such as "select" — that would cause the fill logic
// to generate lorem-ipsum and type it into a dropdown search box.
const shouldOverride =
!GENERIC_TYPES.has(result.type) || GENERIC_TYPES.has(field.fieldType);
if (shouldOverride) {
field.fieldType = result.type;
}
field.detectionMethod = "keyword";
field.detectionConfidence = result.confidence;
} else if (!field.detectionMethod) {
field.detectionMethod = "custom-select";
field.detectionConfidence = 0.9;
}
}
return fields;
}
No outgoing dependencies.
Impact (Incoming)
| Source | Type |
|---|---|
| detectFormFields | uses |
| detectAllFields | calls |
| makeField | uses |
| classifierNames | uses |