aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 1.74 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConstructSelector=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var cfn_resource_1=()=>{var tmp=require("../cfn-resource");return cfn_resource_1=()=>tmp,tmp};class ConstructSelector{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.ConstructSelector",version:"2.251.0"};static all(){return new AllConstructsSelector}static cfnResource(){return new CfnResourceSelector}static onlyItself(){return new OnlyItselfSelector}static resourcesOfType(...types){return new ResourceTypeSelector(types)}static byId(pattern){return new IdPatternSelector(pattern,"id")}static byPath(pattern){return new IdPatternSelector(pattern,"path")}}exports.ConstructSelector=ConstructSelector;class AllConstructsSelector{select(scope){return scope.node.findAll()}}class CfnResourceSelector{select(scope){if(cfn_resource_1().CfnResource.isCfnResource(scope))return[scope];const defaultChild=scope.node.defaultChild;return cfn_resource_1().CfnResource.isCfnResource(defaultChild)?[defaultChild]:[]}}class ResourceTypeSelector{types;constructor(types){this.types=types}select(scope){const result=[],visit=node=>{cfn_resource_1().CfnResource.isCfnResource(node)&&this.types.includes(node.cfnResourceType)&&result.push(node);for(const child of node.node.children)visit(child)};return visit(scope),result}}const{minimatch}=require("minimatch");class IdPatternSelector{pattern;field;constructor(pattern,field){this.pattern=pattern,this.field=field}select(scope){const result=[],visit=node=>{minimatch(node.node[this.field],this.pattern)&&result.push(node);for(const child of node.node.children)visit(child)};return visit(scope),result}}class OnlyItselfSelector{select(scope){return[scope]}}