Stakeholder data that may contain either the deprecated
current_relationship field, the newer current_relationships field, or both.
Optionalcontext: stringOptional human-readable context used when emitting deprecation
warnings. Defaults to "Stakeholder" when not provided.
Normalized stakeholder relationship fields, including
current_relationships (always an array) and a usedDeprecatedField flag
indicating whether only the deprecated field was relied upon.
const normalized = normalizeDeprecatedStakeholderFields({
current_relationship: 'EMPLOYEE',
});
normalized.current_relationships; // ['EMPLOYEE']
normalized.usedDeprecatedField; // true
const normalized = normalizeDeprecatedStakeholderFields({
current_relationship: 'ADVISOR',
current_relationships: ['FOUNDER', 'DIRECTOR'],
});
// The array field takes precedence when both are present.
normalized.current_relationships; // ['FOUNDER', 'DIRECTOR']
normalized.usedDeprecatedField; // false
Normalize deprecated stakeholder relationship fields to their canonical form.
This helper accepts stakeholder data that may use the legacy singular
current_relationshipfield or the newer array-basedcurrent_relationshipsfield and returns a normalized representation plus metadata about deprecation use.Behavior:
current_relationshipis provided, it is converted to a single-elementcurrent_relationshipsarray andusedDeprecatedFieldis set totrue.current_relationshipsis provided and non-empty, it is used as-is andusedDeprecatedFieldis set tofalse, even ifcurrent_relationshipis also present.current_relationshipswill be an empty array andusedDeprecatedFieldwill befalse.The input object is not mutated.