@l-v-yonsama/multi-platform-database-drivers 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/built/src/drivers/Auth0Driver.js +9 -9
- package/built/src/drivers/Auth0Driver.js.map +1 -1
- package/built/src/drivers/AwsDriver.js +3 -3
- package/built/src/drivers/AwsDriver.js.map +1 -1
- package/built/src/drivers/BaseDriver.d.ts +1 -1
- package/built/src/drivers/BaseDriver.js +4 -6
- package/built/src/drivers/BaseDriver.js.map +1 -1
- package/built/src/drivers/DBDriverResolver.js.map +1 -1
- package/built/src/drivers/DBError.js.map +1 -1
- package/built/src/drivers/KeycloakDriver.d.ts +2 -3
- package/built/src/drivers/KeycloakDriver.js +27 -262
- package/built/src/drivers/KeycloakDriver.js.map +1 -1
- package/built/src/drivers/MemcacheDriver.d.ts +0 -1
- package/built/src/drivers/MemcacheDriver.js +5 -5
- package/built/src/drivers/MemcacheDriver.js.map +1 -1
- package/built/src/drivers/MqttDriver.d.ts +0 -1
- package/built/src/drivers/MqttDriver.js +4 -4
- package/built/src/drivers/MqttDriver.js.map +1 -1
- package/built/src/drivers/MySQLDriver.js +12 -12
- package/built/src/drivers/MySQLDriver.js.map +1 -1
- package/built/src/drivers/OracleDriver.js +13 -13
- package/built/src/drivers/OracleDriver.js.map +1 -1
- package/built/src/drivers/PostgresDriver.js +22 -2
- package/built/src/drivers/PostgresDriver.js.map +1 -1
- package/built/src/drivers/RDSBaseDriver.d.ts +1 -1
- package/built/src/drivers/RDSBaseDriver.js +6 -6
- package/built/src/drivers/RDSBaseDriver.js.map +1 -1
- package/built/src/drivers/RedisDriver.js +2 -2
- package/built/src/drivers/RedisDriver.js.map +1 -1
- package/built/src/drivers/SQLServerDriver.js +7 -7
- package/built/src/drivers/SQLServerDriver.js.map +1 -1
- package/built/src/drivers/SQLiteDriver.d.ts +1 -1
- package/built/src/drivers/SQLiteDriver.js +7 -7
- package/built/src/drivers/SQLiteDriver.js.map +1 -1
- package/built/src/drivers/aws/AwsCloudFormationServiceClient.js +2 -2
- package/built/src/drivers/aws/AwsCloudFormationServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsCloudwatchServiceClient.js +3 -3
- package/built/src/drivers/aws/AwsCloudwatchServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsDynamoServiceClient.js +7 -7
- package/built/src/drivers/aws/AwsDynamoServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsS3ServiceClient.js +24 -24
- package/built/src/drivers/aws/AwsS3ServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsSESServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsSQSServiceClient.js +8 -8
- package/built/src/drivers/aws/AwsSQSServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsSecretsManagerServiceClient.js +1 -1
- package/built/src/drivers/aws/AwsSecretsManagerServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsServiceClient.js +2 -2
- package/built/src/drivers/aws/AwsServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsSsmServiceClient.js +1 -1
- package/built/src/drivers/aws/AwsSsmServiceClient.js.map +1 -1
- package/built/src/drivers/keycloak/resourceTreeBuilder.d.ts +5 -0
- package/built/src/drivers/keycloak/resourceTreeBuilder.js +37 -0
- package/built/src/drivers/keycloak/resourceTreeBuilder.js.map +1 -0
- package/built/src/drivers/keycloak/scanResultBuilder.d.ts +8 -0
- package/built/src/drivers/keycloak/scanResultBuilder.js +212 -0
- package/built/src/drivers/keycloak/scanResultBuilder.js.map +1 -0
- package/built/src/drivers/memcache/helper.d.ts +0 -1
- package/built/src/drivers/memcache/helper.js +13 -14
- package/built/src/drivers/memcache/helper.js.map +1 -1
- package/built/src/helpers/ProposalHelper.js +3 -3
- package/built/src/helpers/ProposalHelper.js.map +1 -1
- package/built/src/helpers/RdhRecordRuleHelper.js.map +1 -1
- package/built/src/helpers/RuleEngine.d.ts +5 -5
- package/built/src/helpers/RuleEngine.js +14 -14
- package/built/src/helpers/RuleEngine.js.map +1 -1
- package/built/src/helpers/SQLHelper.d.ts +8 -115
- package/built/src/helpers/SQLHelper.js +35 -1084
- package/built/src/helpers/SQLHelper.js.map +1 -1
- package/built/src/helpers/prompts/Auth0PromptHelper.js.map +1 -1
- package/built/src/helpers/prompts/AwsPromptHelper.js.map +1 -1
- package/built/src/helpers/prompts/KeycloakPromptHelper.js.map +1 -1
- package/built/src/helpers/prompts/MemcachePromptHelper.js.map +1 -1
- package/built/src/helpers/prompts/MqttPromptHelper.js.map +1 -1
- package/built/src/helpers/prompts/RdsPromptHelper.js +1 -1
- package/built/src/helpers/prompts/RdsPromptHelper.js.map +1 -1
- package/built/src/helpers/prompts/RedisPromptHelper.js.map +1 -1
- package/built/src/helpers/prompts/SchemaPromptHelper.js.map +1 -1
- package/built/src/helpers/sql/dynamoConversion.d.ts +2 -0
- package/built/src/helpers/sql/dynamoConversion.js +27 -0
- package/built/src/helpers/sql/dynamoConversion.js.map +1 -0
- package/built/src/helpers/sql/formatQuery.d.ts +6 -0
- package/built/src/helpers/sql/formatQuery.js +45 -0
- package/built/src/helpers/sql/formatQuery.js.map +1 -0
- package/built/src/helpers/sql/mutationQuery.d.ts +54 -0
- package/built/src/helpers/sql/mutationQuery.js +250 -0
- package/built/src/helpers/sql/mutationQuery.js.map +1 -0
- package/built/src/helpers/sql/parameterNormalizer.d.ts +16 -0
- package/built/src/helpers/sql/parameterNormalizer.js +166 -0
- package/built/src/helpers/sql/parameterNormalizer.js.map +1 -0
- package/built/src/helpers/sql/queryParser.d.ts +6 -0
- package/built/src/helpers/sql/queryParser.js +239 -0
- package/built/src/helpers/sql/queryParser.js.map +1 -0
- package/built/src/helpers/sql/quote.d.ts +17 -0
- package/built/src/helpers/sql/quote.js +140 -0
- package/built/src/helpers/sql/quote.js.map +1 -0
- package/built/src/helpers/sql/selectQuery.d.ts +24 -0
- package/built/src/helpers/sql/selectQuery.js +262 -0
- package/built/src/helpers/sql/selectQuery.js.map +1 -0
- package/built/src/resource/aws.d.ts +106 -0
- package/built/src/resource/aws.js +219 -0
- package/built/src/resource/aws.js.map +1 -0
- package/built/src/resource/base.d.ts +28 -0
- package/built/src/resource/base.js +76 -0
- package/built/src/resource/base.js.map +1 -0
- package/built/src/resource/connection.d.ts +35 -0
- package/built/src/resource/connection.js +52 -0
- package/built/src/resource/connection.js.map +1 -0
- package/built/src/resource/fromJson.d.ts +2 -0
- package/built/src/resource/fromJson.js +125 -0
- package/built/src/resource/fromJson.js.map +1 -0
- package/built/src/resource/iam.d.ts +70 -0
- package/built/src/resource/iam.js +175 -0
- package/built/src/resource/iam.js.map +1 -0
- package/built/src/resource/index.d.ts +8 -1
- package/built/src/resource/index.js +8 -1
- package/built/src/resource/index.js.map +1 -1
- package/built/src/resource/keyValue.d.ts +85 -0
- package/built/src/resource/keyValue.js +74 -0
- package/built/src/resource/keyValue.js.map +1 -0
- package/built/src/resource/rdb.d.ts +49 -0
- package/built/src/resource/rdb.js +155 -0
- package/built/src/resource/rdb.js.map +1 -0
- package/built/src/resource/types.d.ts +18 -0
- package/built/src/resource/types.js +3 -0
- package/built/src/resource/types.js.map +1 -0
- package/built/src/types/drivers/Keycloak.js +1 -1
- package/built/src/types/drivers/Keycloak.js.map +1 -1
- package/built/src/types/drivers/MemcachedParams.d.ts +0 -1
- package/built/src/types/helpers/index.js +1 -1
- package/built/src/types/helpers/index.js.map +1 -1
- package/built/src/types/resource/AwsCfnStackAttributes.d.ts +1 -1
- package/built/src/types/resource/MySQLColumnType.js +2 -2
- package/built/src/types/resource/MySQLColumnType.js.map +1 -1
- package/built/src/types/resource/OracleColumnType.js +2 -2
- package/built/src/types/resource/OracleColumnType.js.map +1 -1
- package/built/src/types/resource/PartiQLAttrType.js.map +1 -1
- package/built/src/types/resource/PostgresColumnType.js +2 -2
- package/built/src/types/resource/PostgresColumnType.js.map +1 -1
- package/built/src/types/resource/SQLServerColumnType.js +2 -2
- package/built/src/types/resource/SQLServerColumnType.js.map +1 -1
- package/built/src/types/utils/index.js +2 -2
- package/built/src/types/utils/index.js.map +1 -1
- package/built/src/utils/base.js +1 -1
- package/built/src/utils/base.js.map +1 -1
- package/built/src/utils/cfn/applicationDiagram.js +52 -12
- package/built/src/utils/cfn/applicationDiagram.js.map +1 -1
- package/built/src/utils/cfn/applicationRelations.d.ts +1 -1
- package/built/src/utils/cfn/applicationRelations.js +107 -15
- package/built/src/utils/cfn/applicationRelations.js.map +1 -1
- package/built/src/utils/cfn/cfnDependencyGraphDiagram.js.map +1 -1
- package/built/src/utils/cfn/{architectureTopology.d.ts → deploymentTopology.d.ts} +5 -1
- package/built/src/utils/cfn/{architectureTopology.js → deploymentTopology.js} +127 -13
- package/built/src/utils/cfn/deploymentTopology.js.map +1 -0
- package/built/src/utils/cfn/diagramFileModel.js.map +1 -1
- package/built/src/utils/cfn/drawio/cfnDependencyGraphDiagram.d.ts +3 -0
- package/built/src/utils/cfn/drawio/cfnDependencyGraphDiagram.js +174 -0
- package/built/src/utils/cfn/drawio/cfnDependencyGraphDiagram.js.map +1 -0
- package/built/src/utils/cfn/drawio/commonCells.d.ts +22 -0
- package/built/src/utils/cfn/drawio/commonCells.js +83 -0
- package/built/src/utils/cfn/drawio/commonCells.js.map +1 -0
- package/built/src/utils/cfn/drawio/edgeRouting.d.ts +34 -0
- package/built/src/utils/cfn/drawio/edgeRouting.js +77 -0
- package/built/src/utils/cfn/drawio/edgeRouting.js.map +1 -0
- package/built/src/utils/cfn/drawio/multiAzInfrastructureDiagram.d.ts +3 -0
- package/built/src/utils/cfn/drawio/multiAzInfrastructureDiagram.js +812 -0
- package/built/src/utils/cfn/drawio/multiAzInfrastructureDiagram.js.map +1 -0
- package/built/src/utils/cfn/drawioApplicationDiagram.d.ts +1 -0
- package/built/src/utils/cfn/drawioApplicationDiagram.js +290 -32
- package/built/src/utils/cfn/drawioApplicationDiagram.js.map +1 -1
- package/built/src/utils/cfn/drawioInfrastructureDiagrams.d.ts +2 -4
- package/built/src/utils/cfn/drawioInfrastructureDiagrams.js +7 -441
- package/built/src/utils/cfn/drawioInfrastructureDiagrams.js.map +1 -1
- package/built/src/utils/cfn/drawioXml.d.ts +0 -24
- package/built/src/utils/cfn/drawioXml.js +5 -47
- package/built/src/utils/cfn/drawioXml.js.map +1 -1
- package/built/src/utils/cfn/generateDiagram.js +3 -4
- package/built/src/utils/cfn/generateDiagram.js.map +1 -1
- package/built/src/utils/cfn/icons.js.map +1 -1
- package/built/src/utils/cfn/index.d.ts +4 -4
- package/built/src/utils/cfn/index.js +9 -8
- package/built/src/utils/cfn/index.js.map +1 -1
- package/built/src/utils/cfn/intrinsics.d.ts +1 -1
- package/built/src/utils/cfn/intrinsics.js.map +1 -1
- package/built/src/utils/cfn/multiAzDeploymentTrafficPathsAndProtection.d.ts +27 -0
- package/built/src/utils/cfn/{multiAzDeploymentDataPaths.js → multiAzDeploymentTrafficPathsAndProtection.js} +162 -10
- package/built/src/utils/cfn/multiAzDeploymentTrafficPathsAndProtection.js.map +1 -0
- package/built/src/utils/cfn/multiAzDeploymentTrafficPathsAndProtectionDiagram.d.ts +2 -0
- package/built/src/utils/cfn/{architectureDiagram.js → multiAzDeploymentTrafficPathsAndProtectionDiagram.js} +82 -34
- package/built/src/utils/cfn/multiAzDeploymentTrafficPathsAndProtectionDiagram.js.map +1 -0
- package/built/src/utils/cfn/naming.d.ts +2 -1
- package/built/src/utils/cfn/naming.js +3 -3
- package/built/src/utils/cfn/naming.js.map +1 -1
- package/built/src/utils/cfn/resourceDependencies.js.map +1 -1
- package/built/src/utils/cfn/templateParsing.js +11 -26
- package/built/src/utils/cfn/templateParsing.js.map +1 -1
- package/built/src/utils/csv.js.map +1 -1
- package/built/src/utils/dbType.js.map +1 -1
- package/built/src/utils/diagramLayout/elkLayoutEngine.d.ts +3 -0
- package/built/src/utils/diagramLayout/elkLayoutEngine.js +199 -0
- package/built/src/utils/diagramLayout/elkLayoutEngine.js.map +1 -0
- package/built/src/utils/diagramLayout/index.d.ts +4 -0
- package/built/src/utils/diagramLayout/index.js +13 -0
- package/built/src/utils/diagramLayout/index.js.map +1 -0
- package/built/src/utils/diagramLayout/normalizeLayout.d.ts +33 -0
- package/built/src/utils/diagramLayout/normalizeLayout.js +116 -0
- package/built/src/utils/diagramLayout/normalizeLayout.js.map +1 -0
- package/built/src/utils/diagramLayout/types.d.ts +64 -0
- package/built/src/utils/diagramLayout/types.js +3 -0
- package/built/src/utils/diagramLayout/types.js.map +1 -0
- package/built/src/utils/drawio/drawioXml.d.ts +24 -0
- package/built/src/utils/drawio/drawioXml.js +47 -0
- package/built/src/utils/drawio/drawioXml.js.map +1 -0
- package/built/src/utils/drawio/index.d.ts +2 -0
- package/built/src/utils/drawio/index.js +10 -0
- package/built/src/utils/drawio/index.js.map +1 -0
- package/built/src/utils/driverUtil.d.ts +1 -1
- package/built/src/utils/driverUtil.js.map +1 -1
- package/built/src/utils/er/erDiagramDrawioGenerator.d.ts +26 -0
- package/built/src/utils/er/erDiagramDrawioGenerator.js +99 -0
- package/built/src/utils/er/erDiagramDrawioGenerator.js.map +1 -0
- package/built/src/utils/er/erDiagramDrawioGeneratorAuto.d.ts +2 -0
- package/built/src/utils/er/erDiagramDrawioGeneratorAuto.js +103 -0
- package/built/src/utils/er/erDiagramDrawioGeneratorAuto.js.map +1 -0
- package/built/src/utils/er/erDiagramGenerator.d.ts +7 -0
- package/built/src/utils/er/erDiagramGenerator.js +321 -0
- package/built/src/utils/er/erDiagramGenerator.js.map +1 -0
- package/built/src/utils/er/index.d.ts +4 -0
- package/built/src/utils/er/index.js +13 -0
- package/built/src/utils/er/index.js.map +1 -0
- package/built/src/utils/er/types.d.ts +31 -0
- package/built/src/utils/er/types.js +3 -0
- package/built/src/utils/er/types.js.map +1 -0
- package/built/src/utils/index.d.ts +1 -0
- package/built/src/utils/index.js +1 -0
- package/built/src/utils/index.js.map +1 -1
- package/built/src/utils/log/LogParser.js.map +1 -1
- package/built/src/utils/log/buildSqlExecutions.js +3 -4
- package/built/src/utils/log/buildSqlExecutions.js.map +1 -1
- package/built/src/utils/log/classify/classifyEvent.js +2 -3
- package/built/src/utils/log/classify/classifyEvent.js.map +1 -1
- package/built/src/utils/log/detect/presetDetector.js +4 -5
- package/built/src/utils/log/detect/presetDetector.js.map +1 -1
- package/built/src/utils/log/extract/runExtractors.js +1 -2
- package/built/src/utils/log/extract/runExtractors.js.map +1 -1
- package/built/src/utils/log/logSummary.js +5 -5
- package/built/src/utils/log/logSummary.js.map +1 -1
- package/built/src/utils/log/pattern/logEventPattern.js +2 -3
- package/built/src/utils/log/pattern/logEventPattern.js.map +1 -1
- package/built/src/utils/log/rdh/convertExtractedSqlRdhResult.js +2 -3
- package/built/src/utils/log/rdh/convertExtractedSqlRdhResult.js.map +1 -1
- package/built/src/utils/log/split/splitLogEvents.js +1 -2
- package/built/src/utils/log/split/splitLogEvents.js.map +1 -1
- package/built/src/utils/log/sql/removeSqlComments.js +2 -3
- package/built/src/utils/log/sql/removeSqlComments.js.map +1 -1
- package/built/src/utils/log/validator.js +8 -5
- package/built/src/utils/log/validator.js.map +1 -1
- package/package.json +13 -9
- package/built/src/resource/DbResource.d.ts +0 -373
- package/built/src/resource/DbResource.js +0 -836
- package/built/src/resource/DbResource.js.map +0 -1
- package/built/src/utils/cfn/architectureDiagram.d.ts +0 -3
- package/built/src/utils/cfn/architectureDiagram.js.map +0 -1
- package/built/src/utils/cfn/architectureTopology.js.map +0 -1
- package/built/src/utils/cfn/multiAzDeploymentDataPaths.d.ts +0 -27
- package/built/src/utils/cfn/multiAzDeploymentDataPaths.js.map +0 -1
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateDrawioMultiAzDeploymentTrafficPathsAndProtectionAsync = exports.generateDrawioMultiAzDeploymentTrafficPathsAndProtection = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const diagramLayout_1 = require("../../diagramLayout");
|
|
6
|
+
const drawio_1 = require("../../drawio");
|
|
7
|
+
const deploymentTopology_1 = require("../deploymentTopology");
|
|
8
|
+
const diagramFileModel_1 = require("../diagramFileModel");
|
|
9
|
+
const drawioXml_1 = require("../drawioXml");
|
|
10
|
+
const multiAzDeploymentTrafficPathsAndProtection_1 = require("../multiAzDeploymentTrafficPathsAndProtection");
|
|
11
|
+
const commonCells_1 = require("./commonCells");
|
|
12
|
+
const edgeRouting_1 = require("./edgeRouting");
|
|
13
|
+
const generateDrawioMultiAzDeploymentTrafficPathsAndProtection = (params) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const files = (0, diagramFileModel_1.parseDiagramFiles)(Object.assign(Object.assign({}, params), { options: Object.assign(Object.assign({}, params.options), { includeOutputs: true, includeParameters: true }) }));
|
|
16
|
+
const structure = new deploymentTopology_1.CfnDeploymentTopologyStructure(files);
|
|
17
|
+
const trafficPathsAndProtection = (0, multiAzDeploymentTrafficPathsAndProtection_1.buildMultiAzDeploymentTrafficPathsAndProtection)(files, structure);
|
|
18
|
+
const cells = [];
|
|
19
|
+
const nodeIds = new Map();
|
|
20
|
+
const nodePositions = new Map();
|
|
21
|
+
const subnetPositions = new Map();
|
|
22
|
+
const templatePageByLogicalId = new Map();
|
|
23
|
+
const containedMemberIds = new Set();
|
|
24
|
+
files.forEach((file) => file.resouces.forEach((logicalId) => {
|
|
25
|
+
const identity = `${file.fileIndex}:${logicalId}`;
|
|
26
|
+
if (!templatePageByLogicalId.has(identity) && file.templateSource) {
|
|
27
|
+
templatePageByLogicalId.set(identity, (0, drawio_1.pageLink)(`template_${file.fileIndex}`));
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
const registerNode = (endpointId, cellId, position) => {
|
|
31
|
+
nodeIds.set(endpointId, cellId);
|
|
32
|
+
nodePositions.set(endpointId, position);
|
|
33
|
+
};
|
|
34
|
+
const vpcTop = 100;
|
|
35
|
+
const defaultVpcHeight = 1420;
|
|
36
|
+
const azTop = 720;
|
|
37
|
+
const azWidth = 340;
|
|
38
|
+
const azGap = 20;
|
|
39
|
+
const vpcWidths = structure.vpcs.map((vpc) => Math.max(900, 50 + Math.max(1, vpc.availabilityZones.length) * (azWidth + azGap)));
|
|
40
|
+
const totalVpcWidth = vpcWidths.reduce((sum, width) => sum + width, 0) +
|
|
41
|
+
Math.max(0, structure.vpcs.length - 1) * 40;
|
|
42
|
+
const regionalWidth = trafficPathsAndProtection.regionalNodes.length > 0 ? 360 : 0;
|
|
43
|
+
const canvasWidth = 80 + totalVpcWidth + regionalWidth;
|
|
44
|
+
let maxHeight = vpcTop + defaultVpcHeight;
|
|
45
|
+
let vpcX = 40;
|
|
46
|
+
if (trafficPathsAndProtection.paths.some((path) => path.from.id === 'internet' || path.to.id === 'internet')) {
|
|
47
|
+
const internetPosition = {
|
|
48
|
+
x: 40 + totalVpcWidth / 2 - 75,
|
|
49
|
+
y: 20,
|
|
50
|
+
width: 150,
|
|
51
|
+
height: 55,
|
|
52
|
+
};
|
|
53
|
+
cells.push((0, commonCells_1.nodeCell)('internet', 'Internet', internetPosition.x, internetPosition.y, internetPosition.width, internetPosition.height, '1', '#ecfeff'));
|
|
54
|
+
registerNode('internet', 'internet', internetPosition);
|
|
55
|
+
}
|
|
56
|
+
structure.vpcs.forEach((vpc, vpcIndex) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const vpcId = `vpc_${vpc.fileIndex}_${vpc.logicalId}`;
|
|
59
|
+
const vpcWidth = vpcWidths[vpcIndex];
|
|
60
|
+
const vpcResourceEndpointIds = new Set(vpc.resources.map((resource) => `f${resource.fileIndex}_${resource.logicalId}`));
|
|
61
|
+
const memberParentId = new Map();
|
|
62
|
+
trafficPathsAndProtection.paths
|
|
63
|
+
.filter((path) => path.kind === 'resource-membership')
|
|
64
|
+
.forEach((path) => {
|
|
65
|
+
if (vpcResourceEndpointIds.has(path.from.id) && vpcResourceEndpointIds.has(path.to.id)) {
|
|
66
|
+
memberParentId.set(path.from.id, path.to.id);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const parentMembers = new Map();
|
|
70
|
+
vpc.resources.forEach((resource) => {
|
|
71
|
+
var _a;
|
|
72
|
+
const parentId = memberParentId.get(`f${resource.fileIndex}_${resource.logicalId}`);
|
|
73
|
+
if (!parentId)
|
|
74
|
+
return;
|
|
75
|
+
parentMembers.set(parentId, [...(_a = parentMembers.get(parentId)) !== null && _a !== void 0 ? _a : [], resource]);
|
|
76
|
+
containedMemberIds.add(`f${resource.fileIndex}_${resource.logicalId}`);
|
|
77
|
+
});
|
|
78
|
+
const topLevelResources = vpc.resources.filter((resource) => !memberParentId.has(`f${resource.fileIndex}_${resource.logicalId}`));
|
|
79
|
+
const resourceLayoutGroups = new Map();
|
|
80
|
+
topLevelResources.forEach((resource) => {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
const candidateKey = resource.candidateSubnets
|
|
83
|
+
.map((subnet) => `${subnet.fileIndex}:${subnet.logicalId}`)
|
|
84
|
+
.sort()
|
|
85
|
+
.join('|');
|
|
86
|
+
const key = candidateKey || `connectivity:${(_b = (_a = resource.candidateSubnets[0]) === null || _a === void 0 ? void 0 : _a.connectivity) !== null && _b !== void 0 ? _b : 'private'}`;
|
|
87
|
+
resourceLayoutGroups.set(key, [...(_c = resourceLayoutGroups.get(key)) !== null && _c !== void 0 ? _c : [], resource]);
|
|
88
|
+
});
|
|
89
|
+
const resourceHeight = 65;
|
|
90
|
+
const horizontalInset = 15;
|
|
91
|
+
const verticalTopInset = 50;
|
|
92
|
+
const verticalBottomInset = 15;
|
|
93
|
+
const rowGap = 15;
|
|
94
|
+
const individualHeight = (resource) => {
|
|
95
|
+
const members = parentMembers.get(`f${resource.fileIndex}_${resource.logicalId}`);
|
|
96
|
+
if (!members || members.length === 0)
|
|
97
|
+
return resourceHeight;
|
|
98
|
+
return resourceHeight + rowGap +
|
|
99
|
+
members.length * resourceHeight + Math.max(0, members.length - 1) * rowGap +
|
|
100
|
+
verticalBottomInset;
|
|
101
|
+
};
|
|
102
|
+
const stackedGroupHeight = (group) => verticalTopInset +
|
|
103
|
+
group.reduce((sum, resource) => sum + individualHeight(resource), 0) +
|
|
104
|
+
Math.max(0, group.length - 1) * rowGap +
|
|
105
|
+
verticalBottomInset;
|
|
106
|
+
const maxGroupHeightByConnectivity = {
|
|
107
|
+
public: 0,
|
|
108
|
+
private: 0,
|
|
109
|
+
isolated: 0,
|
|
110
|
+
};
|
|
111
|
+
resourceLayoutGroups.forEach((group) => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
const connectivity = (_b = (_a = group[0]) === null || _a === void 0 ? void 0 : _a.candidateSubnets[0]) === null || _b === void 0 ? void 0 : _b.connectivity;
|
|
114
|
+
if (!connectivity)
|
|
115
|
+
return;
|
|
116
|
+
maxGroupHeightByConnectivity[connectivity] =
|
|
117
|
+
Math.max(maxGroupHeightByConnectivity[connectivity], stackedGroupHeight(group));
|
|
118
|
+
});
|
|
119
|
+
const tierHeight = {
|
|
120
|
+
public: 140,
|
|
121
|
+
private: Math.max(195, maxGroupHeightByConnectivity.private),
|
|
122
|
+
isolated: Math.max(195, maxGroupHeightByConnectivity.isolated),
|
|
123
|
+
};
|
|
124
|
+
const baseRowY = {
|
|
125
|
+
public: 45,
|
|
126
|
+
private: 245,
|
|
127
|
+
isolated: 245 + tierHeight.private + 5,
|
|
128
|
+
};
|
|
129
|
+
const azHeight = baseRowY.isolated + tierHeight.isolated + 10;
|
|
130
|
+
const vpcHeight = Math.max(defaultVpcHeight, azTop + azHeight + 50);
|
|
131
|
+
cells.push((0, commonCells_1.groupCell)(vpcId, `VPC ${(0, commonCells_1.displayCidr)(vpc.cidrBlock)}`, vpcX, vpcTop, vpcWidth, vpcHeight, '1', '#dbeafe', 'left'));
|
|
132
|
+
if (vpc.igw) {
|
|
133
|
+
const endpointId = `f${vpc.igw.fileIndex}_${vpc.igw.logicalId}`;
|
|
134
|
+
const igwId = `node_${endpointId}`;
|
|
135
|
+
const localPosition = { x: vpcWidth / 2 - 85, y: 20, width: 170, height: 55 };
|
|
136
|
+
cells.push((0, commonCells_1.nodeCell)(igwId, `${vpc.igw.logicalId}<br/><font color="#64748b">Internet Gateway</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, vpcId, '#ecfeff', (_a = templatePageByLogicalId.get(`${vpc.igw.fileIndex}:${vpc.igw.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
137
|
+
registerNode(endpointId, igwId, Object.assign(Object.assign({}, localPosition), { x: vpcX + localPosition.x, y: vpcTop + localPosition.y }));
|
|
138
|
+
}
|
|
139
|
+
vpc.availabilityZones.forEach((az, azIndex) => {
|
|
140
|
+
const azId = `${vpcId}_az_${azIndex}`;
|
|
141
|
+
const azGridWidth = Math.max(1, vpc.availabilityZones.length) * azWidth +
|
|
142
|
+
Math.max(0, vpc.availabilityZones.length - 1) * azGap;
|
|
143
|
+
const azStartX = (vpcWidth - azGridWidth) / 2;
|
|
144
|
+
const azX = azStartX + azIndex * (azWidth + azGap);
|
|
145
|
+
cells.push((0, commonCells_1.groupCell)(azId, `Availability Zone ${az.name}`, azX, azTop, azWidth, azHeight, vpcId, '#eff6ff'));
|
|
146
|
+
const rowCounts = { public: 0, private: 0, isolated: 0 };
|
|
147
|
+
az.subnets.forEach((subnet) => {
|
|
148
|
+
const subnetId = `${azId}_f${subnet.fileIndex}_${subnet.logicalId}`;
|
|
149
|
+
const subnetIndex = rowCounts[subnet.connectivity]++;
|
|
150
|
+
const subnetY = baseRowY[subnet.connectivity] + subnetIndex * 18;
|
|
151
|
+
const subnetHeight = tierHeight[subnet.connectivity];
|
|
152
|
+
const subnetTitle = `${subnet.connectivity[0].toUpperCase()}${subnet.connectivity.slice(1)} Subnet ${(0, commonCells_1.displayCidr)(subnet.cidrBlock)}`;
|
|
153
|
+
const fill = subnet.connectivity === 'public'
|
|
154
|
+
? '#f0fdf4'
|
|
155
|
+
: subnet.connectivity === 'private'
|
|
156
|
+
? '#eff6ff'
|
|
157
|
+
: '#fffbeb';
|
|
158
|
+
cells.push((0, commonCells_1.groupCell)(subnetId, subnetTitle, 10, subnetY, 320, subnetHeight, azId, fill));
|
|
159
|
+
subnetPositions.set(`${subnet.fileIndex}:${subnet.logicalId}`, {
|
|
160
|
+
x: azX + 10,
|
|
161
|
+
y: azTop + subnetY,
|
|
162
|
+
width: 320,
|
|
163
|
+
height: subnetHeight,
|
|
164
|
+
});
|
|
165
|
+
subnet.resources.forEach((resource, resourceIndex) => {
|
|
166
|
+
var _a;
|
|
167
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
168
|
+
const resourceId = `node_${endpointId}`;
|
|
169
|
+
const outerFirst = azIndex < vpc.availabilityZones.length / 2 ? 15 : 170;
|
|
170
|
+
const innerSecond = outerFirst === 15 ? 170 : 15;
|
|
171
|
+
const nodeX = resourceIndex % 2 === 0 ? outerFirst : innerSecond;
|
|
172
|
+
const nodeY = 50 + Math.floor(resourceIndex / 2) * 68;
|
|
173
|
+
const nodeWidth = 135;
|
|
174
|
+
const nodeHeight = 55;
|
|
175
|
+
cells.push((0, commonCells_1.nodeCell)(resourceId, `${resource.logicalId}<br/><font color="#64748b">${resource.detail.Type}</font>`, nodeX, nodeY, nodeWidth, nodeHeight, subnetId, '#ffffff', (_a = templatePageByLogicalId.get(`${resource.fileIndex}:${resource.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
176
|
+
registerNode(endpointId, resourceId, {
|
|
177
|
+
x: vpcX + azX + 10 + nodeX,
|
|
178
|
+
y: vpcTop + azTop + subnetY + nodeY,
|
|
179
|
+
width: nodeWidth,
|
|
180
|
+
height: nodeHeight,
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
topLevelResources.forEach((resource) => {
|
|
186
|
+
var _a, _b, _c, _d, _e, _f;
|
|
187
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
188
|
+
const resourceId = `node_${endpointId}`;
|
|
189
|
+
const connectivity = (_b = (_a = resource.candidateSubnets[0]) === null || _a === void 0 ? void 0 : _a.connectivity) !== null && _b !== void 0 ? _b : 'private';
|
|
190
|
+
const localY = connectivity === 'isolated' ? 1250 : connectivity === 'public' ? 810 : 1050;
|
|
191
|
+
const candidateKey = resource.candidateSubnets
|
|
192
|
+
.map((subnet) => `${subnet.fileIndex}:${subnet.logicalId}`)
|
|
193
|
+
.sort()
|
|
194
|
+
.join('|');
|
|
195
|
+
const layoutGroupKey = candidateKey || `connectivity:${connectivity}`;
|
|
196
|
+
const layoutGroup = (_c = resourceLayoutGroups.get(layoutGroupKey)) !== null && _c !== void 0 ? _c : [resource];
|
|
197
|
+
const resourceIndex = layoutGroup.indexOf(resource);
|
|
198
|
+
const ownHeight = individualHeight(resource);
|
|
199
|
+
const cumulativeOffset = layoutGroup
|
|
200
|
+
.slice(0, resourceIndex)
|
|
201
|
+
.reduce((offset, prior) => offset + individualHeight(prior) + rowGap, 0);
|
|
202
|
+
const candidatePositions = resource.candidateSubnets
|
|
203
|
+
.map((subnet) => subnetPositions.get(`${subnet.fileIndex}:${subnet.logicalId}`))
|
|
204
|
+
.filter((position) => Boolean(position));
|
|
205
|
+
const candidateLeft = candidatePositions.length > 0
|
|
206
|
+
? Math.min(...candidatePositions.map((position) => position.x))
|
|
207
|
+
: undefined;
|
|
208
|
+
const candidateRight = candidatePositions.length > 0
|
|
209
|
+
? Math.max(...candidatePositions.map((position) => position.x + position.width))
|
|
210
|
+
: undefined;
|
|
211
|
+
const candidateTop = candidatePositions.length > 0
|
|
212
|
+
? Math.max(...candidatePositions.map((position) => position.y))
|
|
213
|
+
: undefined;
|
|
214
|
+
const candidateBottom = candidatePositions.length > 0
|
|
215
|
+
? Math.min(...candidatePositions.map((position) => position.y + position.height))
|
|
216
|
+
: undefined;
|
|
217
|
+
const stackedHeight = stackedGroupHeight(layoutGroup);
|
|
218
|
+
const fitsCandidateRow = candidateTop !== undefined && candidateBottom !== undefined &&
|
|
219
|
+
candidateBottom - candidateTop >= stackedHeight;
|
|
220
|
+
const localPosition = candidateLeft !== undefined && candidateRight !== undefined &&
|
|
221
|
+
fitsCandidateRow
|
|
222
|
+
? {
|
|
223
|
+
x: candidateLeft + horizontalInset,
|
|
224
|
+
y: candidateTop + verticalTopInset + cumulativeOffset,
|
|
225
|
+
width: candidateRight - candidateLeft - horizontalInset * 2,
|
|
226
|
+
height: ownHeight,
|
|
227
|
+
}
|
|
228
|
+
: {
|
|
229
|
+
x: vpcWidth / 2 - 145,
|
|
230
|
+
y: localY,
|
|
231
|
+
width: 290,
|
|
232
|
+
height: ownHeight,
|
|
233
|
+
};
|
|
234
|
+
const details = [
|
|
235
|
+
...(resource.multiAz ? ['Multi-AZ'] : []),
|
|
236
|
+
...((_d = resource.traits) !== null && _d !== void 0 ? _d : []),
|
|
237
|
+
].map((entry) => `; ${entry}`).join('');
|
|
238
|
+
const members = (_e = parentMembers.get(endpointId)) !== null && _e !== void 0 ? _e : [];
|
|
239
|
+
cells.push((0, commonCells_1.nodeCell)(resourceId, `${resource.logicalId}<br/><font color="#64748b">${resource.placement}${details}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, vpcId, '#ffffff', (_f = templatePageByLogicalId.get(`${resource.fileIndex}:${resource.logicalId}`)) !== null && _f !== void 0 ? _f : '', members.length > 0));
|
|
240
|
+
registerNode(endpointId, resourceId, Object.assign(Object.assign({}, localPosition), { x: vpcX + localPosition.x, y: vpcTop + localPosition.y }));
|
|
241
|
+
members.forEach((member, memberIndex) => {
|
|
242
|
+
var _a;
|
|
243
|
+
const memberEndpointId = `f${member.fileIndex}_${member.logicalId}`;
|
|
244
|
+
const memberCellId = `node_${memberEndpointId}`;
|
|
245
|
+
const memberLocalPosition = {
|
|
246
|
+
x: horizontalInset,
|
|
247
|
+
y: resourceHeight + rowGap + memberIndex * (resourceHeight + rowGap),
|
|
248
|
+
width: localPosition.width - horizontalInset * 2,
|
|
249
|
+
height: resourceHeight,
|
|
250
|
+
};
|
|
251
|
+
cells.push((0, commonCells_1.nodeCell)(memberCellId, `${member.logicalId}<br/><font color="#64748b">${member.detail.Type}</font>`, memberLocalPosition.x, memberLocalPosition.y, memberLocalPosition.width, memberLocalPosition.height, resourceId, '#f8fafc', (_a = templatePageByLogicalId.get(`${member.fileIndex}:${member.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
252
|
+
registerNode(memberEndpointId, memberCellId, {
|
|
253
|
+
x: vpcX + localPosition.x + memberLocalPosition.x,
|
|
254
|
+
y: vpcTop + localPosition.y + memberLocalPosition.y,
|
|
255
|
+
width: memberLocalPosition.width,
|
|
256
|
+
height: memberLocalPosition.height,
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
const renderedIngressNodes = new Set();
|
|
261
|
+
const addIngressNode = (fileIndex, logicalId, typeLabel, row, column) => {
|
|
262
|
+
var _a;
|
|
263
|
+
const endpointId = `f${fileIndex}_${logicalId}`;
|
|
264
|
+
if (renderedIngressNodes.has(endpointId))
|
|
265
|
+
return;
|
|
266
|
+
renderedIngressNodes.add(endpointId);
|
|
267
|
+
const cellId = `node_${endpointId}`;
|
|
268
|
+
const localPosition = {
|
|
269
|
+
x: vpcWidth / 2 - 150 + column * 320,
|
|
270
|
+
y: 120 + row * 150,
|
|
271
|
+
width: 300,
|
|
272
|
+
height: 78,
|
|
273
|
+
};
|
|
274
|
+
cells.push((0, commonCells_1.nodeCell)(cellId, `${logicalId}<br/><font color="#64748b">${typeLabel}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, vpcId, '#f5f3ff', (_a = templatePageByLogicalId.get(`${fileIndex}:${logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
275
|
+
registerNode(endpointId, cellId, Object.assign(Object.assign({}, localPosition), { x: vpcX + localPosition.x, y: vpcTop + localPosition.y }));
|
|
276
|
+
};
|
|
277
|
+
vpc.loadBalancers.forEach((loadBalancer, loadBalancerIndex) => {
|
|
278
|
+
addIngressNode(loadBalancer.fileIndex, loadBalancer.logicalId, `Application Load Balancer<br/>${loadBalancer.internetFacing ? 'internet-facing' : 'internal'}`, 0, loadBalancerIndex);
|
|
279
|
+
loadBalancer.listeners.forEach((listener, listenerIndex) => {
|
|
280
|
+
const listenerDetails = [listener.protocol, listener.port ? `:${listener.port}` : undefined]
|
|
281
|
+
.filter(Boolean).join(' ');
|
|
282
|
+
addIngressNode(listener.fileIndex, listener.logicalId, `Listener${listenerDetails ? `<br/>${listenerDetails}` : ''}`, 1, listenerIndex);
|
|
283
|
+
listener.rules.forEach((rule, ruleIndex) => {
|
|
284
|
+
const ruleDetails = [
|
|
285
|
+
...rule.conditions,
|
|
286
|
+
rule.priority ? `priority: ${rule.priority}` : undefined,
|
|
287
|
+
].filter((value) => Boolean(value));
|
|
288
|
+
addIngressNode(rule.fileIndex, rule.logicalId, `Listener Rule${ruleDetails.length > 0 ? `<br/>${ruleDetails.join('<br/>')}` : ''}`, 2, ruleIndex);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
loadBalancer.targetGroups.forEach((targetGroup, targetGroupIndex) => {
|
|
292
|
+
const targetGroupDetails = [
|
|
293
|
+
targetGroup.protocol,
|
|
294
|
+
targetGroup.port ? `:${targetGroup.port}` : undefined,
|
|
295
|
+
targetGroup.targetType ? `target type: ${targetGroup.targetType}` : undefined,
|
|
296
|
+
].filter(Boolean).join(' ');
|
|
297
|
+
addIngressNode(targetGroup.fileIndex, targetGroup.logicalId, `Target Group${targetGroupDetails ? `<br/>${targetGroupDetails}` : ''}`, 3, targetGroupIndex);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
maxHeight = Math.max(maxHeight, vpcTop + vpcHeight);
|
|
301
|
+
vpcX += vpcWidth + 40;
|
|
302
|
+
});
|
|
303
|
+
const regionalX = 60 + totalVpcWidth;
|
|
304
|
+
if (trafficPathsAndProtection.regionalNodes.length > 0) {
|
|
305
|
+
const regionalHeight = 65 + trafficPathsAndProtection.regionalNodes.length * 150;
|
|
306
|
+
cells.push((0, commonCells_1.groupCell)('regional', 'Regional managed services (outside VPC)', regionalX, 140, 320, regionalHeight, '1', '#fff7ed'));
|
|
307
|
+
trafficPathsAndProtection.regionalNodes.forEach((node, index) => {
|
|
308
|
+
var _a;
|
|
309
|
+
const cellId = `node_${node.endpoint.id}`;
|
|
310
|
+
const localPosition = { x: 20, y: 45 + index * 150, width: 280, height: 65 };
|
|
311
|
+
cells.push((0, commonCells_1.nodeCell)(cellId, `${node.label}<br/><font color="#64748b">${node.type}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, 'regional', '#fff7ed', (_a = templatePageByLogicalId.get(`${node.endpoint.fileIndex}:${node.endpoint.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
312
|
+
registerNode(node.endpoint.id, cellId, Object.assign(Object.assign({}, localPosition), { x: regionalX + localPosition.x, y: 140 + localPosition.y }));
|
|
313
|
+
});
|
|
314
|
+
maxHeight = Math.max(maxHeight, 140 + regionalHeight);
|
|
315
|
+
}
|
|
316
|
+
if (structure.standaloneResources.length > 0) {
|
|
317
|
+
const groupId = 'standalone';
|
|
318
|
+
cells.push((0, commonCells_1.groupCell)(groupId, 'Standalone resources', 40, maxHeight + 30, Math.max(1100, canvasWidth - 80), 120, '1', '#f8fafc'));
|
|
319
|
+
structure.standaloneResources.forEach((resource, index) => {
|
|
320
|
+
var _a;
|
|
321
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
322
|
+
const cellId = `node_${endpointId}`;
|
|
323
|
+
const localPosition = { x: 15 + index * 220, y: 45, width: 200, height: 50 };
|
|
324
|
+
cells.push((0, commonCells_1.nodeCell)(cellId, `${resource.logicalId}<br/><font color="#64748b">${resource.detail.Type}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, groupId, '#ffffff', (_a = templatePageByLogicalId.get(`${resource.fileIndex}:${resource.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
325
|
+
registerNode(endpointId, cellId, Object.assign(Object.assign({}, localPosition), { x: 40 + localPosition.x, y: maxHeight + 30 + localPosition.y }));
|
|
326
|
+
});
|
|
327
|
+
maxHeight += 180;
|
|
328
|
+
}
|
|
329
|
+
const drawablePaths = trafficPathsAndProtection.paths.flatMap((path) => {
|
|
330
|
+
if (path.kind === 'resource-membership' && containedMemberIds.has(path.from.id))
|
|
331
|
+
return [];
|
|
332
|
+
const source = nodeIds.get(path.from.id);
|
|
333
|
+
const target = nodeIds.get(path.to.id);
|
|
334
|
+
const sourcePosition = nodePositions.get(path.from.id);
|
|
335
|
+
const targetPosition = nodePositions.get(path.to.id);
|
|
336
|
+
if (!source || !target || !sourcePosition || !targetPosition)
|
|
337
|
+
return [];
|
|
338
|
+
return [{ path, source, target, sourcePosition, targetPosition }];
|
|
339
|
+
});
|
|
340
|
+
const sideCounts = new Map();
|
|
341
|
+
drawablePaths.forEach(({ path, sourcePosition, targetPosition }) => {
|
|
342
|
+
var _a, _b;
|
|
343
|
+
const layout = (0, edgeRouting_1.connectionLayout)(sourcePosition, targetPosition, path.kind, path.label);
|
|
344
|
+
const sourceKey = `${path.from.id}:${layout.sourceSide}`;
|
|
345
|
+
const targetKey = `${path.to.id}:${layout.targetSide}`;
|
|
346
|
+
sideCounts.set(sourceKey, ((_a = sideCounts.get(sourceKey)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
347
|
+
sideCounts.set(targetKey, ((_b = sideCounts.get(targetKey)) !== null && _b !== void 0 ? _b : 0) + 1);
|
|
348
|
+
});
|
|
349
|
+
const sideUsage = new Map();
|
|
350
|
+
const nextFraction = (endpointId, side) => {
|
|
351
|
+
var _a, _b;
|
|
352
|
+
const key = `${endpointId}:${side}`;
|
|
353
|
+
const used = (_a = sideUsage.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
354
|
+
sideUsage.set(key, used + 1);
|
|
355
|
+
return (used + 1) / (((_b = sideCounts.get(key)) !== null && _b !== void 0 ? _b : 1) + 1);
|
|
356
|
+
};
|
|
357
|
+
drawablePaths.forEach(({ path, source, target, sourcePosition, targetPosition, }, index) => {
|
|
358
|
+
const layout = (0, edgeRouting_1.connectionLayout)(sourcePosition, targetPosition, path.kind, path.label);
|
|
359
|
+
const sourceFraction = nextFraction(path.from.id, layout.sourceSide);
|
|
360
|
+
const targetFraction = nextFraction(path.to.id, layout.targetSide);
|
|
361
|
+
const sourceAnchor = (0, edgeRouting_1.anchorCoordinates)(layout.sourceSide, sourceFraction);
|
|
362
|
+
const targetAnchor = (0, edgeRouting_1.anchorCoordinates)(layout.targetSide, targetFraction);
|
|
363
|
+
const sourcePoint = (0, edgeRouting_1.absoluteAnchorPoint)(sourcePosition, layout.sourceSide, sourceFraction);
|
|
364
|
+
const targetPoint = (0, edgeRouting_1.absoluteAnchorPoint)(targetPosition, layout.targetSide, targetFraction);
|
|
365
|
+
cells.push((0, commonCells_1.edgeCell)(`path_${index}_${path.kind}`, source, target, path.label, (0, edgeRouting_1.edgeKindForPath)(path.kind), path.bidirectional, (0, edgeRouting_1.routePoints)(sourcePosition, targetPosition, sourcePoint, targetPoint, path.kind, path.label), {
|
|
366
|
+
exitX: sourceAnchor.x,
|
|
367
|
+
exitY: sourceAnchor.y,
|
|
368
|
+
entryX: targetAnchor.x,
|
|
369
|
+
entryY: targetAnchor.y,
|
|
370
|
+
}));
|
|
371
|
+
});
|
|
372
|
+
if (((_a = params.options) === null || _a === void 0 ? void 0 : _a.includeLegend) !== false) {
|
|
373
|
+
const usedKinds = new Set(drawablePaths.map(({ path }) => path.kind));
|
|
374
|
+
(0, commonCells_1.addTrafficProtectionLegend)(cells, maxHeight + 30, usedKinds);
|
|
375
|
+
}
|
|
376
|
+
const pages = [(0, drawio_1.drawioPage)('multi-az-traffic-paths-protection', 'Multi-AZ Deployment, Traffic Paths & Protection', cells)];
|
|
377
|
+
files.forEach((file) => {
|
|
378
|
+
if (file.templateSource)
|
|
379
|
+
pages.push((0, drawioXml_1.drawioTemplatePage)(`template_${file.fileIndex}`, file.fileName, file.templateSource));
|
|
380
|
+
});
|
|
381
|
+
return (0, drawio_1.wrapDrawioPages)(pages);
|
|
382
|
+
};
|
|
383
|
+
exports.generateDrawioMultiAzDeploymentTrafficPathsAndProtection = generateDrawioMultiAzDeploymentTrafficPathsAndProtection;
|
|
384
|
+
const subnetResourceCardWidth = 135;
|
|
385
|
+
const subnetResourceCardHeight = 55;
|
|
386
|
+
const placeSubnetResources = (resources, availableWidth, availableHeight) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
387
|
+
const positions = new Map();
|
|
388
|
+
if (resources.length === 0)
|
|
389
|
+
return positions;
|
|
390
|
+
const legacyFallback = () => {
|
|
391
|
+
resources.forEach((resource, index) => {
|
|
392
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
393
|
+
positions.set(endpointId, {
|
|
394
|
+
x: index % 2 === 0 ? 0 : subnetResourceCardWidth + 20,
|
|
395
|
+
y: Math.floor(index / 2) * (subnetResourceCardHeight + 13),
|
|
396
|
+
width: subnetResourceCardWidth,
|
|
397
|
+
height: subnetResourceCardHeight,
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
const layout = yield (0, diagramLayout_1.computeAutoLayout)({
|
|
402
|
+
id: 'subnet-resources',
|
|
403
|
+
direction: 'RIGHT',
|
|
404
|
+
nodes: resources.map((_resource, index) => ({
|
|
405
|
+
id: `r${index}`,
|
|
406
|
+
width: subnetResourceCardWidth,
|
|
407
|
+
height: subnetResourceCardHeight,
|
|
408
|
+
})),
|
|
409
|
+
edges: [],
|
|
410
|
+
layoutOptions: {
|
|
411
|
+
'elk.algorithm': 'box',
|
|
412
|
+
'elk.box.packingMode': 'GROW',
|
|
413
|
+
'elk.spacing.nodeNode': '13',
|
|
414
|
+
'elk.aspectRatio': String(Math.max(0.1, availableWidth / Math.max(1, availableHeight))),
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
if (!layout.usedAutoLayout) {
|
|
418
|
+
legacyFallback();
|
|
419
|
+
return positions;
|
|
420
|
+
}
|
|
421
|
+
const boxes = resources.map((_, index) => layout.nodes.get(`r${index}`));
|
|
422
|
+
if (boxes.some((box) => !box)) {
|
|
423
|
+
legacyFallback();
|
|
424
|
+
return positions;
|
|
425
|
+
}
|
|
426
|
+
const maxX = Math.max(...boxes.map((box) => box.x + box.width));
|
|
427
|
+
const maxY = Math.max(...boxes.map((box) => box.y + box.height));
|
|
428
|
+
if (maxX > availableWidth + 0.5 || maxY > availableHeight + 0.5) {
|
|
429
|
+
legacyFallback();
|
|
430
|
+
return positions;
|
|
431
|
+
}
|
|
432
|
+
resources.forEach((resource, index) => {
|
|
433
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
434
|
+
const box = boxes[index];
|
|
435
|
+
positions.set(endpointId, {
|
|
436
|
+
x: box.x,
|
|
437
|
+
y: box.y,
|
|
438
|
+
width: subnetResourceCardWidth,
|
|
439
|
+
height: subnetResourceCardHeight,
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
return positions;
|
|
443
|
+
});
|
|
444
|
+
const generateDrawioMultiAzDeploymentTrafficPathsAndProtectionAsync = (params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
445
|
+
var _a, _b;
|
|
446
|
+
const files = (0, diagramFileModel_1.parseDiagramFiles)(Object.assign(Object.assign({}, params), { options: Object.assign(Object.assign({}, params.options), { includeOutputs: true, includeParameters: true }) }));
|
|
447
|
+
const structure = new deploymentTopology_1.CfnDeploymentTopologyStructure(files);
|
|
448
|
+
const trafficPathsAndProtection = (0, multiAzDeploymentTrafficPathsAndProtection_1.buildMultiAzDeploymentTrafficPathsAndProtection)(files, structure);
|
|
449
|
+
const cells = [];
|
|
450
|
+
const nodeIds = new Map();
|
|
451
|
+
const nodePositions = new Map();
|
|
452
|
+
const subnetPositions = new Map();
|
|
453
|
+
const templatePageByLogicalId = new Map();
|
|
454
|
+
const containedMemberIds = new Set();
|
|
455
|
+
files.forEach((file) => file.resouces.forEach((logicalId) => {
|
|
456
|
+
const identity = `${file.fileIndex}:${logicalId}`;
|
|
457
|
+
if (!templatePageByLogicalId.has(identity) && file.templateSource) {
|
|
458
|
+
templatePageByLogicalId.set(identity, (0, drawio_1.pageLink)(`template_${file.fileIndex}`));
|
|
459
|
+
}
|
|
460
|
+
}));
|
|
461
|
+
const registerNode = (endpointId, cellId, position) => {
|
|
462
|
+
nodeIds.set(endpointId, cellId);
|
|
463
|
+
nodePositions.set(endpointId, position);
|
|
464
|
+
};
|
|
465
|
+
const vpcTop = 100;
|
|
466
|
+
const defaultVpcHeight = 1420;
|
|
467
|
+
const azTop = 720;
|
|
468
|
+
const azWidth = 340;
|
|
469
|
+
const azGap = 20;
|
|
470
|
+
const vpcWidths = structure.vpcs.map((vpc) => Math.max(900, 50 + Math.max(1, vpc.availabilityZones.length) * (azWidth + azGap)));
|
|
471
|
+
const totalVpcWidth = vpcWidths.reduce((sum, width) => sum + width, 0) +
|
|
472
|
+
Math.max(0, structure.vpcs.length - 1) * 40;
|
|
473
|
+
const regionalWidth = trafficPathsAndProtection.regionalNodes.length > 0 ? 360 : 0;
|
|
474
|
+
const canvasWidth = 80 + totalVpcWidth + regionalWidth;
|
|
475
|
+
let maxHeight = vpcTop + defaultVpcHeight;
|
|
476
|
+
let vpcX = 40;
|
|
477
|
+
if (trafficPathsAndProtection.paths.some((path) => path.from.id === 'internet' || path.to.id === 'internet')) {
|
|
478
|
+
const internetPosition = {
|
|
479
|
+
x: 40 + totalVpcWidth / 2 - 75,
|
|
480
|
+
y: 20,
|
|
481
|
+
width: 150,
|
|
482
|
+
height: 55,
|
|
483
|
+
};
|
|
484
|
+
cells.push((0, commonCells_1.nodeCell)('internet', 'Internet', internetPosition.x, internetPosition.y, internetPosition.width, internetPosition.height, '1', '#ecfeff'));
|
|
485
|
+
registerNode('internet', 'internet', internetPosition);
|
|
486
|
+
}
|
|
487
|
+
for (const [vpcIndex, vpc] of structure.vpcs.entries()) {
|
|
488
|
+
const vpcId = `vpc_${vpc.fileIndex}_${vpc.logicalId}`;
|
|
489
|
+
const vpcWidth = vpcWidths[vpcIndex];
|
|
490
|
+
const vpcResourceEndpointIds = new Set(vpc.resources.map((resource) => `f${resource.fileIndex}_${resource.logicalId}`));
|
|
491
|
+
const memberParentId = new Map();
|
|
492
|
+
trafficPathsAndProtection.paths
|
|
493
|
+
.filter((path) => path.kind === 'resource-membership')
|
|
494
|
+
.forEach((path) => {
|
|
495
|
+
if (vpcResourceEndpointIds.has(path.from.id) && vpcResourceEndpointIds.has(path.to.id)) {
|
|
496
|
+
memberParentId.set(path.from.id, path.to.id);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
const parentMembers = new Map();
|
|
500
|
+
vpc.resources.forEach((resource) => {
|
|
501
|
+
var _a;
|
|
502
|
+
const parentId = memberParentId.get(`f${resource.fileIndex}_${resource.logicalId}`);
|
|
503
|
+
if (!parentId)
|
|
504
|
+
return;
|
|
505
|
+
parentMembers.set(parentId, [...(_a = parentMembers.get(parentId)) !== null && _a !== void 0 ? _a : [], resource]);
|
|
506
|
+
containedMemberIds.add(`f${resource.fileIndex}_${resource.logicalId}`);
|
|
507
|
+
});
|
|
508
|
+
const topLevelResources = vpc.resources.filter((resource) => !memberParentId.has(`f${resource.fileIndex}_${resource.logicalId}`));
|
|
509
|
+
const resourceLayoutGroups = new Map();
|
|
510
|
+
topLevelResources.forEach((resource) => {
|
|
511
|
+
var _a, _b, _c;
|
|
512
|
+
const candidateKey = resource.candidateSubnets
|
|
513
|
+
.map((subnet) => `${subnet.fileIndex}:${subnet.logicalId}`)
|
|
514
|
+
.sort()
|
|
515
|
+
.join('|');
|
|
516
|
+
const key = candidateKey || `connectivity:${(_b = (_a = resource.candidateSubnets[0]) === null || _a === void 0 ? void 0 : _a.connectivity) !== null && _b !== void 0 ? _b : 'private'}`;
|
|
517
|
+
resourceLayoutGroups.set(key, [...(_c = resourceLayoutGroups.get(key)) !== null && _c !== void 0 ? _c : [], resource]);
|
|
518
|
+
});
|
|
519
|
+
const resourceHeight = 65;
|
|
520
|
+
const horizontalInset = 15;
|
|
521
|
+
const verticalTopInset = 50;
|
|
522
|
+
const verticalBottomInset = 15;
|
|
523
|
+
const rowGap = 15;
|
|
524
|
+
const individualHeight = (resource) => {
|
|
525
|
+
const members = parentMembers.get(`f${resource.fileIndex}_${resource.logicalId}`);
|
|
526
|
+
if (!members || members.length === 0)
|
|
527
|
+
return resourceHeight;
|
|
528
|
+
return resourceHeight + rowGap +
|
|
529
|
+
members.length * resourceHeight + Math.max(0, members.length - 1) * rowGap +
|
|
530
|
+
verticalBottomInset;
|
|
531
|
+
};
|
|
532
|
+
const stackedGroupHeight = (group) => verticalTopInset +
|
|
533
|
+
group.reduce((sum, resource) => sum + individualHeight(resource), 0) +
|
|
534
|
+
Math.max(0, group.length - 1) * rowGap +
|
|
535
|
+
verticalBottomInset;
|
|
536
|
+
const maxGroupHeightByConnectivity = {
|
|
537
|
+
public: 0,
|
|
538
|
+
private: 0,
|
|
539
|
+
isolated: 0,
|
|
540
|
+
};
|
|
541
|
+
resourceLayoutGroups.forEach((group) => {
|
|
542
|
+
var _a, _b;
|
|
543
|
+
const connectivity = (_b = (_a = group[0]) === null || _a === void 0 ? void 0 : _a.candidateSubnets[0]) === null || _b === void 0 ? void 0 : _b.connectivity;
|
|
544
|
+
if (!connectivity)
|
|
545
|
+
return;
|
|
546
|
+
maxGroupHeightByConnectivity[connectivity] =
|
|
547
|
+
Math.max(maxGroupHeightByConnectivity[connectivity], stackedGroupHeight(group));
|
|
548
|
+
});
|
|
549
|
+
const tierHeight = {
|
|
550
|
+
public: 140,
|
|
551
|
+
private: Math.max(195, maxGroupHeightByConnectivity.private),
|
|
552
|
+
isolated: Math.max(195, maxGroupHeightByConnectivity.isolated),
|
|
553
|
+
};
|
|
554
|
+
const baseRowY = {
|
|
555
|
+
public: 45,
|
|
556
|
+
private: 245,
|
|
557
|
+
isolated: 245 + tierHeight.private + 5,
|
|
558
|
+
};
|
|
559
|
+
const azHeight = baseRowY.isolated + tierHeight.isolated + 10;
|
|
560
|
+
const vpcHeight = Math.max(defaultVpcHeight, azTop + azHeight + 50);
|
|
561
|
+
cells.push((0, commonCells_1.groupCell)(vpcId, `VPC ${(0, commonCells_1.displayCidr)(vpc.cidrBlock)}`, vpcX, vpcTop, vpcWidth, vpcHeight, '1', '#dbeafe', 'left'));
|
|
562
|
+
if (vpc.igw) {
|
|
563
|
+
const endpointId = `f${vpc.igw.fileIndex}_${vpc.igw.logicalId}`;
|
|
564
|
+
const igwId = `node_${endpointId}`;
|
|
565
|
+
const localPosition = { x: vpcWidth / 2 - 85, y: 20, width: 170, height: 55 };
|
|
566
|
+
cells.push((0, commonCells_1.nodeCell)(igwId, `${vpc.igw.logicalId}<br/><font color="#64748b">Internet Gateway</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, vpcId, '#ecfeff', (_a = templatePageByLogicalId.get(`${vpc.igw.fileIndex}:${vpc.igw.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
567
|
+
registerNode(endpointId, igwId, Object.assign(Object.assign({}, localPosition), { x: vpcX + localPosition.x, y: vpcTop + localPosition.y }));
|
|
568
|
+
}
|
|
569
|
+
for (const [azIndex, az] of vpc.availabilityZones.entries()) {
|
|
570
|
+
const azId = `${vpcId}_az_${azIndex}`;
|
|
571
|
+
const azGridWidth = Math.max(1, vpc.availabilityZones.length) * azWidth +
|
|
572
|
+
Math.max(0, vpc.availabilityZones.length - 1) * azGap;
|
|
573
|
+
const azStartX = (vpcWidth - azGridWidth) / 2;
|
|
574
|
+
const azX = azStartX + azIndex * (azWidth + azGap);
|
|
575
|
+
cells.push((0, commonCells_1.groupCell)(azId, `Availability Zone ${az.name}`, azX, azTop, azWidth, azHeight, vpcId, '#eff6ff'));
|
|
576
|
+
const rowCounts = { public: 0, private: 0, isolated: 0 };
|
|
577
|
+
for (const subnet of az.subnets) {
|
|
578
|
+
const subnetId = `${azId}_f${subnet.fileIndex}_${subnet.logicalId}`;
|
|
579
|
+
const subnetIndex = rowCounts[subnet.connectivity]++;
|
|
580
|
+
const subnetY = baseRowY[subnet.connectivity] + subnetIndex * 18;
|
|
581
|
+
const subnetHeight = tierHeight[subnet.connectivity];
|
|
582
|
+
const subnetTitle = `${subnet.connectivity[0].toUpperCase()}${subnet.connectivity.slice(1)} Subnet ${(0, commonCells_1.displayCidr)(subnet.cidrBlock)}`;
|
|
583
|
+
const fill = subnet.connectivity === 'public'
|
|
584
|
+
? '#f0fdf4'
|
|
585
|
+
: subnet.connectivity === 'private'
|
|
586
|
+
? '#eff6ff'
|
|
587
|
+
: '#fffbeb';
|
|
588
|
+
cells.push((0, commonCells_1.groupCell)(subnetId, subnetTitle, 10, subnetY, 320, subnetHeight, azId, fill));
|
|
589
|
+
subnetPositions.set(`${subnet.fileIndex}:${subnet.logicalId}`, {
|
|
590
|
+
x: azX + 10,
|
|
591
|
+
y: azTop + subnetY,
|
|
592
|
+
width: 320,
|
|
593
|
+
height: subnetHeight,
|
|
594
|
+
});
|
|
595
|
+
const resourcePositions = yield placeSubnetResources(subnet.resources, 320 - horizontalInset * 2, subnetHeight - 60);
|
|
596
|
+
subnet.resources.forEach((resource) => {
|
|
597
|
+
var _a, _b, _c;
|
|
598
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
599
|
+
const resourceId = `node_${endpointId}`;
|
|
600
|
+
const local = resourcePositions.get(endpointId);
|
|
601
|
+
const nodeX = ((_a = local === null || local === void 0 ? void 0 : local.x) !== null && _a !== void 0 ? _a : 0) + horizontalInset;
|
|
602
|
+
const nodeY = ((_b = local === null || local === void 0 ? void 0 : local.y) !== null && _b !== void 0 ? _b : 0) + 50;
|
|
603
|
+
cells.push((0, commonCells_1.nodeCell)(resourceId, `${resource.logicalId}<br/><font color="#64748b">${resource.detail.Type}</font>`, nodeX, nodeY, subnetResourceCardWidth, subnetResourceCardHeight, subnetId, '#ffffff', (_c = templatePageByLogicalId.get(`${resource.fileIndex}:${resource.logicalId}`)) !== null && _c !== void 0 ? _c : ''));
|
|
604
|
+
registerNode(endpointId, resourceId, {
|
|
605
|
+
x: vpcX + azX + 10 + nodeX,
|
|
606
|
+
y: vpcTop + azTop + subnetY + nodeY,
|
|
607
|
+
width: subnetResourceCardWidth,
|
|
608
|
+
height: subnetResourceCardHeight,
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
topLevelResources.forEach((resource) => {
|
|
614
|
+
var _a, _b, _c, _d, _e, _f;
|
|
615
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
616
|
+
const resourceId = `node_${endpointId}`;
|
|
617
|
+
const connectivity = (_b = (_a = resource.candidateSubnets[0]) === null || _a === void 0 ? void 0 : _a.connectivity) !== null && _b !== void 0 ? _b : 'private';
|
|
618
|
+
const localY = connectivity === 'isolated' ? 1250 : connectivity === 'public' ? 810 : 1050;
|
|
619
|
+
const candidateKey = resource.candidateSubnets
|
|
620
|
+
.map((subnet) => `${subnet.fileIndex}:${subnet.logicalId}`)
|
|
621
|
+
.sort()
|
|
622
|
+
.join('|');
|
|
623
|
+
const layoutGroupKey = candidateKey || `connectivity:${connectivity}`;
|
|
624
|
+
const layoutGroup = (_c = resourceLayoutGroups.get(layoutGroupKey)) !== null && _c !== void 0 ? _c : [resource];
|
|
625
|
+
const resourceIndex = layoutGroup.indexOf(resource);
|
|
626
|
+
const ownHeight = individualHeight(resource);
|
|
627
|
+
const cumulativeOffset = layoutGroup
|
|
628
|
+
.slice(0, resourceIndex)
|
|
629
|
+
.reduce((offset, prior) => offset + individualHeight(prior) + rowGap, 0);
|
|
630
|
+
const candidatePositions = resource.candidateSubnets
|
|
631
|
+
.map((subnet) => subnetPositions.get(`${subnet.fileIndex}:${subnet.logicalId}`))
|
|
632
|
+
.filter((position) => Boolean(position));
|
|
633
|
+
const candidateLeft = candidatePositions.length > 0
|
|
634
|
+
? Math.min(...candidatePositions.map((position) => position.x))
|
|
635
|
+
: undefined;
|
|
636
|
+
const candidateRight = candidatePositions.length > 0
|
|
637
|
+
? Math.max(...candidatePositions.map((position) => position.x + position.width))
|
|
638
|
+
: undefined;
|
|
639
|
+
const candidateTop = candidatePositions.length > 0
|
|
640
|
+
? Math.max(...candidatePositions.map((position) => position.y))
|
|
641
|
+
: undefined;
|
|
642
|
+
const candidateBottom = candidatePositions.length > 0
|
|
643
|
+
? Math.min(...candidatePositions.map((position) => position.y + position.height))
|
|
644
|
+
: undefined;
|
|
645
|
+
const stackedHeight = stackedGroupHeight(layoutGroup);
|
|
646
|
+
const fitsCandidateRow = candidateTop !== undefined && candidateBottom !== undefined &&
|
|
647
|
+
candidateBottom - candidateTop >= stackedHeight;
|
|
648
|
+
const localPosition = candidateLeft !== undefined && candidateRight !== undefined &&
|
|
649
|
+
fitsCandidateRow
|
|
650
|
+
? {
|
|
651
|
+
x: candidateLeft + horizontalInset,
|
|
652
|
+
y: candidateTop + verticalTopInset + cumulativeOffset,
|
|
653
|
+
width: candidateRight - candidateLeft - horizontalInset * 2,
|
|
654
|
+
height: ownHeight,
|
|
655
|
+
}
|
|
656
|
+
: {
|
|
657
|
+
x: vpcWidth / 2 - 145,
|
|
658
|
+
y: localY,
|
|
659
|
+
width: 290,
|
|
660
|
+
height: ownHeight,
|
|
661
|
+
};
|
|
662
|
+
const details = [
|
|
663
|
+
...(resource.multiAz ? ['Multi-AZ'] : []),
|
|
664
|
+
...((_d = resource.traits) !== null && _d !== void 0 ? _d : []),
|
|
665
|
+
].map((entry) => `; ${entry}`).join('');
|
|
666
|
+
const members = (_e = parentMembers.get(endpointId)) !== null && _e !== void 0 ? _e : [];
|
|
667
|
+
cells.push((0, commonCells_1.nodeCell)(resourceId, `${resource.logicalId}<br/><font color="#64748b">${resource.placement}${details}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, vpcId, '#ffffff', (_f = templatePageByLogicalId.get(`${resource.fileIndex}:${resource.logicalId}`)) !== null && _f !== void 0 ? _f : '', members.length > 0));
|
|
668
|
+
registerNode(endpointId, resourceId, Object.assign(Object.assign({}, localPosition), { x: vpcX + localPosition.x, y: vpcTop + localPosition.y }));
|
|
669
|
+
members.forEach((member, memberIndex) => {
|
|
670
|
+
var _a;
|
|
671
|
+
const memberEndpointId = `f${member.fileIndex}_${member.logicalId}`;
|
|
672
|
+
const memberCellId = `node_${memberEndpointId}`;
|
|
673
|
+
const memberLocalPosition = {
|
|
674
|
+
x: horizontalInset,
|
|
675
|
+
y: resourceHeight + rowGap + memberIndex * (resourceHeight + rowGap),
|
|
676
|
+
width: localPosition.width - horizontalInset * 2,
|
|
677
|
+
height: resourceHeight,
|
|
678
|
+
};
|
|
679
|
+
cells.push((0, commonCells_1.nodeCell)(memberCellId, `${member.logicalId}<br/><font color="#64748b">${member.detail.Type}</font>`, memberLocalPosition.x, memberLocalPosition.y, memberLocalPosition.width, memberLocalPosition.height, resourceId, '#f8fafc', (_a = templatePageByLogicalId.get(`${member.fileIndex}:${member.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
680
|
+
registerNode(memberEndpointId, memberCellId, {
|
|
681
|
+
x: vpcX + localPosition.x + memberLocalPosition.x,
|
|
682
|
+
y: vpcTop + localPosition.y + memberLocalPosition.y,
|
|
683
|
+
width: memberLocalPosition.width,
|
|
684
|
+
height: memberLocalPosition.height,
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
const renderedIngressNodes = new Set();
|
|
689
|
+
const addIngressNode = (fileIndex, logicalId, typeLabel, row, column) => {
|
|
690
|
+
var _a;
|
|
691
|
+
const endpointId = `f${fileIndex}_${logicalId}`;
|
|
692
|
+
if (renderedIngressNodes.has(endpointId))
|
|
693
|
+
return;
|
|
694
|
+
renderedIngressNodes.add(endpointId);
|
|
695
|
+
const cellId = `node_${endpointId}`;
|
|
696
|
+
const localPosition = {
|
|
697
|
+
x: vpcWidth / 2 - 150 + column * 320,
|
|
698
|
+
y: 120 + row * 150,
|
|
699
|
+
width: 300,
|
|
700
|
+
height: 78,
|
|
701
|
+
};
|
|
702
|
+
cells.push((0, commonCells_1.nodeCell)(cellId, `${logicalId}<br/><font color="#64748b">${typeLabel}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, vpcId, '#f5f3ff', (_a = templatePageByLogicalId.get(`${fileIndex}:${logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
703
|
+
registerNode(endpointId, cellId, Object.assign(Object.assign({}, localPosition), { x: vpcX + localPosition.x, y: vpcTop + localPosition.y }));
|
|
704
|
+
};
|
|
705
|
+
vpc.loadBalancers.forEach((loadBalancer, loadBalancerIndex) => {
|
|
706
|
+
addIngressNode(loadBalancer.fileIndex, loadBalancer.logicalId, `Application Load Balancer<br/>${loadBalancer.internetFacing ? 'internet-facing' : 'internal'}`, 0, loadBalancerIndex);
|
|
707
|
+
loadBalancer.listeners.forEach((listener, listenerIndex) => {
|
|
708
|
+
const listenerDetails = [listener.protocol, listener.port ? `:${listener.port}` : undefined]
|
|
709
|
+
.filter(Boolean).join(' ');
|
|
710
|
+
addIngressNode(listener.fileIndex, listener.logicalId, `Listener${listenerDetails ? `<br/>${listenerDetails}` : ''}`, 1, listenerIndex);
|
|
711
|
+
listener.rules.forEach((rule, ruleIndex) => {
|
|
712
|
+
const ruleDetails = [
|
|
713
|
+
...rule.conditions,
|
|
714
|
+
rule.priority ? `priority: ${rule.priority}` : undefined,
|
|
715
|
+
].filter((value) => Boolean(value));
|
|
716
|
+
addIngressNode(rule.fileIndex, rule.logicalId, `Listener Rule${ruleDetails.length > 0 ? `<br/>${ruleDetails.join('<br/>')}` : ''}`, 2, ruleIndex);
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
loadBalancer.targetGroups.forEach((targetGroup, targetGroupIndex) => {
|
|
720
|
+
const targetGroupDetails = [
|
|
721
|
+
targetGroup.protocol,
|
|
722
|
+
targetGroup.port ? `:${targetGroup.port}` : undefined,
|
|
723
|
+
targetGroup.targetType ? `target type: ${targetGroup.targetType}` : undefined,
|
|
724
|
+
].filter(Boolean).join(' ');
|
|
725
|
+
addIngressNode(targetGroup.fileIndex, targetGroup.logicalId, `Target Group${targetGroupDetails ? `<br/>${targetGroupDetails}` : ''}`, 3, targetGroupIndex);
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
maxHeight = Math.max(maxHeight, vpcTop + vpcHeight);
|
|
729
|
+
vpcX += vpcWidth + 40;
|
|
730
|
+
}
|
|
731
|
+
const regionalX = 60 + totalVpcWidth;
|
|
732
|
+
if (trafficPathsAndProtection.regionalNodes.length > 0) {
|
|
733
|
+
const regionalHeight = 65 + trafficPathsAndProtection.regionalNodes.length * 150;
|
|
734
|
+
cells.push((0, commonCells_1.groupCell)('regional', 'Regional managed services (outside VPC)', regionalX, 140, 320, regionalHeight, '1', '#fff7ed'));
|
|
735
|
+
trafficPathsAndProtection.regionalNodes.forEach((node, index) => {
|
|
736
|
+
var _a;
|
|
737
|
+
const cellId = `node_${node.endpoint.id}`;
|
|
738
|
+
const localPosition = { x: 20, y: 45 + index * 150, width: 280, height: 65 };
|
|
739
|
+
cells.push((0, commonCells_1.nodeCell)(cellId, `${node.label}<br/><font color="#64748b">${node.type}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, 'regional', '#fff7ed', (_a = templatePageByLogicalId.get(`${node.endpoint.fileIndex}:${node.endpoint.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
740
|
+
registerNode(node.endpoint.id, cellId, Object.assign(Object.assign({}, localPosition), { x: regionalX + localPosition.x, y: 140 + localPosition.y }));
|
|
741
|
+
});
|
|
742
|
+
maxHeight = Math.max(maxHeight, 140 + regionalHeight);
|
|
743
|
+
}
|
|
744
|
+
if (structure.standaloneResources.length > 0) {
|
|
745
|
+
const groupId = 'standalone';
|
|
746
|
+
cells.push((0, commonCells_1.groupCell)(groupId, 'Standalone resources', 40, maxHeight + 30, Math.max(1100, canvasWidth - 80), 120, '1', '#f8fafc'));
|
|
747
|
+
structure.standaloneResources.forEach((resource, index) => {
|
|
748
|
+
var _a;
|
|
749
|
+
const endpointId = `f${resource.fileIndex}_${resource.logicalId}`;
|
|
750
|
+
const cellId = `node_${endpointId}`;
|
|
751
|
+
const localPosition = { x: 15 + index * 220, y: 45, width: 200, height: 50 };
|
|
752
|
+
cells.push((0, commonCells_1.nodeCell)(cellId, `${resource.logicalId}<br/><font color="#64748b">${resource.detail.Type}</font>`, localPosition.x, localPosition.y, localPosition.width, localPosition.height, groupId, '#ffffff', (_a = templatePageByLogicalId.get(`${resource.fileIndex}:${resource.logicalId}`)) !== null && _a !== void 0 ? _a : ''));
|
|
753
|
+
registerNode(endpointId, cellId, Object.assign(Object.assign({}, localPosition), { x: 40 + localPosition.x, y: maxHeight + 30 + localPosition.y }));
|
|
754
|
+
});
|
|
755
|
+
maxHeight += 180;
|
|
756
|
+
}
|
|
757
|
+
const drawablePaths = trafficPathsAndProtection.paths.flatMap((path) => {
|
|
758
|
+
if (path.kind === 'resource-membership' && containedMemberIds.has(path.from.id))
|
|
759
|
+
return [];
|
|
760
|
+
const source = nodeIds.get(path.from.id);
|
|
761
|
+
const target = nodeIds.get(path.to.id);
|
|
762
|
+
const sourcePosition = nodePositions.get(path.from.id);
|
|
763
|
+
const targetPosition = nodePositions.get(path.to.id);
|
|
764
|
+
if (!source || !target || !sourcePosition || !targetPosition)
|
|
765
|
+
return [];
|
|
766
|
+
return [{ path, source, target, sourcePosition, targetPosition }];
|
|
767
|
+
});
|
|
768
|
+
const sideCounts = new Map();
|
|
769
|
+
drawablePaths.forEach(({ path, sourcePosition, targetPosition }) => {
|
|
770
|
+
var _a, _b;
|
|
771
|
+
const layout = (0, edgeRouting_1.connectionLayout)(sourcePosition, targetPosition, path.kind, path.label);
|
|
772
|
+
const sourceKey = `${path.from.id}:${layout.sourceSide}`;
|
|
773
|
+
const targetKey = `${path.to.id}:${layout.targetSide}`;
|
|
774
|
+
sideCounts.set(sourceKey, ((_a = sideCounts.get(sourceKey)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
775
|
+
sideCounts.set(targetKey, ((_b = sideCounts.get(targetKey)) !== null && _b !== void 0 ? _b : 0) + 1);
|
|
776
|
+
});
|
|
777
|
+
const sideUsage = new Map();
|
|
778
|
+
const nextFraction = (endpointId, side) => {
|
|
779
|
+
var _a, _b;
|
|
780
|
+
const key = `${endpointId}:${side}`;
|
|
781
|
+
const used = (_a = sideUsage.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
782
|
+
sideUsage.set(key, used + 1);
|
|
783
|
+
return (used + 1) / (((_b = sideCounts.get(key)) !== null && _b !== void 0 ? _b : 1) + 1);
|
|
784
|
+
};
|
|
785
|
+
drawablePaths.forEach(({ path, source, target, sourcePosition, targetPosition, }, index) => {
|
|
786
|
+
const layout = (0, edgeRouting_1.connectionLayout)(sourcePosition, targetPosition, path.kind, path.label);
|
|
787
|
+
const sourceFraction = nextFraction(path.from.id, layout.sourceSide);
|
|
788
|
+
const targetFraction = nextFraction(path.to.id, layout.targetSide);
|
|
789
|
+
const sourceAnchor = (0, edgeRouting_1.anchorCoordinates)(layout.sourceSide, sourceFraction);
|
|
790
|
+
const targetAnchor = (0, edgeRouting_1.anchorCoordinates)(layout.targetSide, targetFraction);
|
|
791
|
+
const sourcePoint = (0, edgeRouting_1.absoluteAnchorPoint)(sourcePosition, layout.sourceSide, sourceFraction);
|
|
792
|
+
const targetPoint = (0, edgeRouting_1.absoluteAnchorPoint)(targetPosition, layout.targetSide, targetFraction);
|
|
793
|
+
cells.push((0, commonCells_1.edgeCell)(`path_${index}_${path.kind}`, source, target, path.label, (0, edgeRouting_1.edgeKindForPath)(path.kind), path.bidirectional, (0, edgeRouting_1.routePoints)(sourcePosition, targetPosition, sourcePoint, targetPoint, path.kind, path.label), {
|
|
794
|
+
exitX: sourceAnchor.x,
|
|
795
|
+
exitY: sourceAnchor.y,
|
|
796
|
+
entryX: targetAnchor.x,
|
|
797
|
+
entryY: targetAnchor.y,
|
|
798
|
+
}));
|
|
799
|
+
});
|
|
800
|
+
if (((_b = params.options) === null || _b === void 0 ? void 0 : _b.includeLegend) !== false) {
|
|
801
|
+
const usedKinds = new Set(drawablePaths.map(({ path }) => path.kind));
|
|
802
|
+
(0, commonCells_1.addTrafficProtectionLegend)(cells, maxHeight + 30, usedKinds);
|
|
803
|
+
}
|
|
804
|
+
const pages = [(0, drawio_1.drawioPage)('multi-az-traffic-paths-protection', 'Multi-AZ Deployment, Traffic Paths & Protection', cells)];
|
|
805
|
+
files.forEach((file) => {
|
|
806
|
+
if (file.templateSource)
|
|
807
|
+
pages.push((0, drawioXml_1.drawioTemplatePage)(`template_${file.fileIndex}`, file.fileName, file.templateSource));
|
|
808
|
+
});
|
|
809
|
+
return (0, drawio_1.wrapDrawioPages)(pages);
|
|
810
|
+
});
|
|
811
|
+
exports.generateDrawioMultiAzDeploymentTrafficPathsAndProtectionAsync = generateDrawioMultiAzDeploymentTrafficPathsAndProtectionAsync;
|
|
812
|
+
//# sourceMappingURL=multiAzInfrastructureDiagram.js.map
|