Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/diagram/aws/aws-edge-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
import {RootComponent} from "../component/root-component"
import {EdgeTarget, EdgeTargetSimpleString, EdgeTargetStackExport} from "./edge-target"


/**
* Resources with this ID are complete hidden from the logical ID calculation.
*
* @see packages/@aws-cdk/cdk/lib/util/uniqueid.ts
*/
const HIDDEN_ID = 'Default';

/**
* Finds references between nodes in AWS-CDK trees and converts them to Diagrams subComponent links
*/
Expand Down Expand Up @@ -40,7 +48,7 @@
const cdkStackTree = originComponent.treeAncestorWithTag(ComponentTags.isCdkStack, "true")

if (cdkStackTree) {
let targetComponent = this.findTargetComponent(cdkStackTree, targetString)

Check failure on line 51 in src/diagram/aws/aws-edge-resolver.ts

View workflow job for this annotation

GitHub Actions / test

'targetComponent' is never reassigned. Use 'const' instead

if (targetComponent != null) {
originComponent.links.addLink(targetComponent)
Expand Down Expand Up @@ -89,7 +97,7 @@
const stackDepth = component.treeAncestorWithTag(ComponentTags.isCdkStack, "true")
const pathParts: string[] = component.idPathParts().slice(stackDepth.depth())

if (pathParts.length === 0) return false
if (pathParts.filter(x => x !== HIDDEN_ID).length === 0) return false

return makeUniqueId(pathParts)
}
Expand Down Expand Up @@ -125,7 +133,7 @@
if (key === "Fn::ImportValue" && object[key] !== undefined) {
try {
edgeTargets.push(EdgeTargetStackExport.fromFnImportValue(object[key] as string))
} catch (e) {}

Check failure on line 136 in src/diagram/aws/aws-edge-resolver.ts

View workflow job for this annotation

GitHub Actions / test

Empty block statement
}

if (key === "Ref" && (typeof object[key] === "string")) {
Expand All @@ -140,7 +148,7 @@
return _.uniqWith(edgeTargets, ((a: EdgeTarget, b: EdgeTarget) => a.isEqual(b)))
}

scrapeAllStrings(object: any): Set<EdgeTarget> {

Check warning on line 151 in src/diagram/aws/aws-edge-resolver.ts

View workflow job for this annotation

GitHub Actions / test

Argument 'object' should be typed with a non-any type

Check warning on line 151 in src/diagram/aws/aws-edge-resolver.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

if (object === null || object === undefined) {
return new Set<EdgeTarget>()
Expand All @@ -151,7 +159,7 @@
}

if (Array.isArray(object)) {
const array: EdgeTarget[][] = (object as Array<any>).map(it => {

Check warning on line 162 in src/diagram/aws/aws-edge-resolver.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
return Array.from(this.scrapeAllStrings(it))
})
const strings: EdgeTarget[] = _.flatten(array)
Expand Down
Loading