refactor(frontend): extract isRelationshipSchema field type guard
Merged
BI
4mo ago+77+77+01234567890123456789-23-23-01234567890123456789
Why
Field-schema discrimination between attributes and relationships was duplicated as an inline "peer" in fieldSchema check across a dozen form, table, filter and detail components — untested, easy to get subtly wrong, and with no single place to document the invariant.
What changed
- Added a shared, tested
isRelationshipSchematype guard under the schema entity's domain rules (entities/schema/domain/rules/), alongside the existingisNodeSchema/isGenericSchemaguards. - Routed all inline
"peer" in fieldSchemanarrowing through it (11 call sites: form field generation, sort resolution, dynamic filter input, filter definitions, table columns/headers, object detail rows, field icon, proposed-change and IPAM headers). - Swapped the positive
"default_value" in fieldSchemaattribute check ingetDefaultValueFromSchemafor!isRelationshipSchema(...)— behaviour identical, discrimination now type-safe.
What stayed the same: no behavioural change — the guard narrows exactly as the inline in checks did (true → RelationshipSchema, false → AttributeSchema).
How to test
cd frontend/app
pnpm test src/entities/schema/domain/rules/is-relationship-schema.test.ts
pnpm exec biome ci . && pnpm exec betterer ci
Checklist
- Tests added/updated
- Changelog entry added (
+is-relationship-schema-guard.housekeeping.md) - External docs updated — n/a (internal refactor, no user-facing change)
Summary by cubic
Extracted a shared isRelationshipSchema type guard and replaced duplicated "peer" checks across forms, tables, filters, and detail views. This centralizes attribute/relationship discrimination with tests and keeps behavior unchanged.
- Refactors
- Added
isRelationshipSchemaunder schema domain rules with unit tests. - Routed all inline checks through the guard at 11 call sites (form field gen, sort, dynamic filter input/definitions, table columns/headers, object detail rows, field icon, proposed-change and IPAM headers).
- Updated
getDefaultValueFromSchemato use the guard and early-return style; behavior identical and now type-safe.
- Added