* Build the fields for a self-contained variant record: the common fields plus * the variant's own fields (inlined from a referenced record, or taken from an * inline group). Returns `{ fields, label }` where label names the variant.
(commonFields, entry, defMap, index)
| 325 | * inline group). Returns `{ fields, label }` where label names the variant. |
| 326 | */ |
| 327 | function variantRecord(commonFields, entry, defMap, index) { |
| 328 | const common = commonFields.map((f) => structuredClone(f)) |
| 329 | if (isGroupRef(entry)) { |
| 330 | const target = defMap.get(entry.Value) |
| 331 | const ownFields = |
| 332 | target && Array.isArray(target.Properties) ? structuredClone(target.Properties) : [structuredClone({ ...entry })] |
| 333 | return { fields: [...common, ...ownFields], label: splitName(entry.Value).local, supersedes: entry.Value } |
| 334 | } |
| 335 | // inline group: label by its sole distinguishing field when there is one |
| 336 | const ownFields = structuredClone(entry.Properties) |
| 337 | const named = ownFields.filter((f) => f && typeof f === 'object' && f.Name) |
| 338 | const label = named.length === 1 ? pascal(named[0].Name) : `Variant${index}` |
| 339 | return { fields: [...common, ...ownFields], label } |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Rewrite variant-union params into a canonical `variable` union of |
no test coverage detected