public static _filterCfnType()

in packages/cdk-graph/src/filtering/filters.ts [322:359]


  public static _filterCfnType(
    values: FilterValue[],
    exclude: boolean
  ): IGraphFilter {
    const isMatch = memoize((input: string) => {
      if (input == null) {
        return false;
      }

      return (
        values.find((_value) => {
          if (_value.value) {
            return input === _value.value;
          } else if (_value.regex) {
            return new RegExp(_value.regex).test(input);
          } else {
            return undefined;
          }
        }) != null
      );
    });

    return {
      strategy: FilterStrategy.PRUNE,
      node: {
        filter: (node) => {
          // Preserve container structure (stages, stacks, etc.)
          if (node.isCluster || node.isGraphContainer) return true;
          if (Graph.isResourceLike(node)) {
            const match = !!node.cfnType && isMatch(node.cfnType);
            return (match && !exclude) || (!match && exclude);
          }
          // Preserve non *Resource nodes
          return true;
        },
      },
    };
  }