collectDerivations
Collects all derivation entries from field definitions.
This function traverses the field definition tree and extracts:
- Shorthand
derivationproperties on fields - Full
logicarray entries withtype: 'derivation'
The collected entries include dependency information for cycle detection and reactive evaluation. Entries are sorted topologically so derivations are processed in dependency order.
Lookup maps (byTarget, byDependency, etc.) are NOT built here - they are computed lazily via {@link DerivationLookup} to avoid hidden mutation and reduce the size of the returned collection.
Presentation
function collectDerivations (
fields: FieldDef <unknown, FieldMeta >[],
): DerivationCollection ;Returns
Parameters
Example usage
const fields = [
{ key: 'quantity', type: 'number' },
{ key: 'unitPrice', type: 'number' },
{
key: 'total',
type: 'number',
derivation: 'formValue.quantity * formValue.unitPrice',
},
];
const collection = collectDerivations (fields);
// collection.entries has 1 entry for the 'total' field derivation