function propagatePropertyOperation()

in packages/@aws-c2a/engine/lib/model-diffing/change-propagator.ts [48:86]


function propagatePropertyOperation(
  compOp: PropertyComponentOperation,
  modelDiff: InfraModelDiff,
): ComponentOperation[] {
  const componentUpdate = compOp.getUpdateType();

  if(componentUpdate !== ComponentUpdateType.REPLACEMENT
        && componentUpdate !== ComponentUpdateType.POSSIBLE_REPLACEMENT)
    return compOp instanceof UpdatePropertyComponentOperation
      ? flatMap((compOp.innerOperations ?? []), i => propagatePropertyOperation(i, modelDiff))
      : [];

  /** if the property is a replacement-inducing collection and
    /* the keys have changed, it should propagate to a replacement
    / */
  if(!compOp.propertyTransition.v1?.isPrimitive()){
    const {v1, v2} = compOp.propertyTransition;
    if(v1 !== undefined
            && v2 !== undefined
            && arraysEqual(Object.keys(v1.getCollection()), Object.keys(v2.getCollection()))
            && compOp instanceof UpdatePropertyComponentOperation
    ){
      return flatMap((compOp.innerOperations ?? []), i => propagatePropertyOperation(i, modelDiff));
    }
  }

  const componentTransition = compOp.componentTransition;

  const replacementOp = new ReplaceComponentOperation({
    certainty: componentUpdate === ComponentUpdateType.POSSIBLE_REPLACEMENT
      ? OperationCertainty.PARTIAL : OperationCertainty.ABSOLUTE,
  }, {
    cause: compOp,
    componentTransition,
  },
  );

  return [replacementOp, ...propagateReplacementOperation(replacementOp, modelDiff)];
}