feat(core): PropertyMergeStrategy now supports array merge strategies#37841
Conversation
…fnPropsMixin now supports a static `of()` factory that accepts a\nresource type name string instead of the class constructor, avoiding\ncircular dependency issues. The type parameter is enforced (defaults\nto `never`) so autocomplete works correctly.\n\nPropertyMergeStrategy.combine() now accepts an `arrays` option with\nstrategies: replace (default), append, prepend, replaceByIndex, and\nreplaceByKey. Array elements are never deep-merged.
|
👋 It looks like your PR description follows the template but is missing a valid issue number in the first section. PRs without a linked issue will receive lower priority for review and merging. Please update the description to include a reference like |
PropertyMergeStrategy now supports array merge strategies
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Merge Queue Status
This pull request spent 35 minutes 37 seconds in the queue, including 1 hour 6 minutes 42 seconds running CI. Required conditions to merge
|
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
N/A
Reason for this change
The
combinemerge strategy always replaced arrays wholesale. There was no way to append, prepend, or selectively update array elements when applying property mixins — a common need for tags, rules, and other list-typed CloudFormation properties.Description of changes
PropertyMergeStrategy.combine()now accepts an optionalarraysoption powered by a newArrayMergeStrategyclass. Available strategies are:replace— replace the target array entirely (default, preserves existing behavior)append— add source elements after target elementsprepend— add source elements before target elementsreplaceByIndex— overwrite target elements positionally from the frontreplaceByKey(key)— match object elements by a shared key field, replacing matches and appending new onesArray elements are never deep-merged regardless of strategy.
Additionally,
CfnPropsMixingains a staticof<T>()factory to avoid circular imports when referencing L1 classes across module boundaries.Describe any new or updated permissions being added
N/A
Description of how you validated changes
Unit tests for all array merge strategies and the
CfnPropsMixin.of()factory. All existing tests continue to pass.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license