aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 981 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyMixin=applyMixin,exports.withMixins=withMixins;var constants_1=()=>{var tmp=require("../../constants");return constants_1=()=>tmp,tmp},constants_2=()=>{var tmp=require("../../private/constants");return constants_2=()=>tmp,tmp};const MIXIN_METADATA_KEY="aws:cdk:analytics:mixin";function addMetadata(construct,mixin){let reportedValue="*";const fqn=Object.getPrototypeOf(mixin).constructor[constants_1().JSII_RUNTIME_SYMBOL]?.fqn;fqn&&constants_2().ALLOWED_FQN_PREFIXES.find(prefix=>fqn.startsWith(prefix))&&(reportedValue=fqn),construct.node.addMetadata(MIXIN_METADATA_KEY,{mixin:reportedValue})}function applyMixin(construct,mixin){addMetadata(construct,mixin),mixin.applyTo(construct)}function withMixins(target,...mixins){const allConstructs=target.node.findAll();for(const mixin of mixins)for(const construct of allConstructs)mixin.supports(construct)&&applyMixin(construct,mixin);return target}