Open Cap Table Protocol Canton SDK - v0.2.224
    Preparing search index...

    Function normalizeDeprecatedStakeholderFields

    • Normalize deprecated stakeholder relationship fields to their canonical form.

      This helper accepts stakeholder data that may use the legacy singular current_relationship field or the newer array-based current_relationships field and returns a normalized representation plus metadata about deprecation use.

      Behavior:

      • If only current_relationship is provided, it is converted to a single-element current_relationships array and usedDeprecatedField is set to true.
      • If current_relationships is provided and non-empty, it is used as-is and usedDeprecatedField is set to false, even if current_relationship is also present.
      • If neither field is provided, current_relationships will be an empty array and usedDeprecatedField will be false.

      The input object is not mutated.

      Parameters

      • data: StakeholderDataWithDeprecatedField

        Stakeholder data that may contain either the deprecated current_relationship field, the newer current_relationships field, or both.

      • Optionalcontext: string

        Optional human-readable context used when emitting deprecation warnings. Defaults to "Stakeholder" when not provided.

      Returns NormalizedStakeholderFields

      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