Tags: aws/constructs
Tags
feat: add stackTraceOverride option to MetadataOptions (#2853) Allow callers to provide a custom stack trace via the new `stackTraceOverride` property on `MetadataOptions`. When a non-empty array is supplied, it is used as-is and the `stackTrace` / `traceFromFunction` options are ignored.
fix: provide default implementation of `with()` on `Node` class (#2848) The `with()` method for applying mixins was previously only implemented directly on the `Construct` class. This made it difficult for custom `IConstruct` implementations to support mixins without duplicating the implementation logic. This change moves the core implementation to the `Node` class, exposing it as `node.with()`. The `Construct.with()` method now simply delegates to this new implementation. Any custom `IConstruct` implementation can now easily support mixins by delegating to `this.node.with()`, following the same pattern. This is particularly useful for libraries that extend the constructs model with their own base classes, as they no longer need to copy the mixin application logic. --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
feat(mixin): add IMixin interface and Construct.with() method (#2843) This PR implements the `constructs` package parts of [RFC-0814: CDK Mixins](https://github.com/aws/aws-cdk-rfcs/blob/58051ea8cc408b8ccd0d2c66dc1790ebb67da08f/text/0814-cdk-mixins.md). CDK Mixins are composable, reusable abstractions that can be applied to any construct. This change adds the foundational support to the `constructs` library, enabling the fluent `.with()` API described in the RFC. ## Changes The `IMixin` interface defines the contract for mixins with two methods: - `supports(construct)` - determines if a mixin can be applied to a given construct - `applyTo(construct)` - applies the mixin functionality to the target The `with()` method is added to `Construct` and `IConstruct`, allowing mixins to be applied fluently. When called, it traverses the construct tree and applies each mixin to all supported constructs. ```typescript const bucket = new s3.CfnBucket(scope, "MyBucket") .with(new EncryptionAtRest()) .with(new AutoDeleteObjects()); ``` ## Why Mixins are a new way to build abstractions, that does not rely on the construct level approach many implementors use. They allow users to employ a mix and match approach for features that doesn't lock consumers into specific implementations.
fix: save memory by lazy initializing all fields (#2838) Every construct has a `Node` object, and every `Node` object has a number of fields that for a large swathe of constructs are just empty collections. Do not initialize these collections until we have a value to put into them, to save memory. This saves about ~0.5kB per construct. This is not a lot, but can add up over the course of a large construct tree.
fix: Python constructs do not implement a compatible interface (#2495) Reverting to and pinning an older version of jsii-pacmak that will generate python bindings with correct dependency constraints for typeguard. Needs to be reverted once aws/jsii#4658 is resolved.
PreviousNext