From f2e170a6462ac009fa6f210c16b8ba0d272176cf Mon Sep 17 00:00:00 2001 From: Alain Krok Date: Thu, 14 Dec 2023 18:57:50 -0600 Subject: [PATCH] fix(lint): run linter --- src/common/helpers/utils.ts | 62 +++++++++---------- .../index.ts | 8 +-- .../aws-summarization-appsync-stepfn/index.ts | 8 +-- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/common/helpers/utils.ts b/src/common/helpers/utils.ts index 631b7478..f3406764 100644 --- a/src/common/helpers/utils.ts +++ b/src/common/helpers/utils.ts @@ -22,34 +22,34 @@ import * as cdk from 'aws-cdk-lib'; * */ export function generatePhysicalName( - prefix: string, - parts: string[], - maxLength: number, - ): string { - // The result will consist of: - // -The prefix - unaltered - // -The parts concatenated, but reduced in size to meet the maxLength limit for the overall name - // -A hyphen delimiter - // -The GUID portion of the stack arn - - const stackIdGuidLength = 36; - const prefixLength = prefix.length; - const maxPartsLength = maxLength - prefixLength - 1 - stackIdGuidLength; // 1 is the hyphen - - // Extract the Stack ID Guid - const uniqueStackIdPart = cdk.Fn.select(2, cdk.Fn.split('/', `${cdk.Aws.STACK_ID}`)); - - let allParts: string = ''; - - parts.forEach((part) => { - allParts += part; - }); - - if (allParts.length > maxPartsLength) { - const subStringLength = maxPartsLength / 2; - allParts = allParts.substring(0, subStringLength) + allParts.substring(allParts.length - subStringLength); - } - - const finalName = prefix.toLowerCase() + allParts + '-' + uniqueStackIdPart; - return finalName; - } \ No newline at end of file + prefix: string, + parts: string[], + maxLength: number, +): string { + // The result will consist of: + // -The prefix - unaltered + // -The parts concatenated, but reduced in size to meet the maxLength limit for the overall name + // -A hyphen delimiter + // -The GUID portion of the stack arn + + const stackIdGuidLength = 36; + const prefixLength = prefix.length; + const maxPartsLength = maxLength - prefixLength - 1 - stackIdGuidLength; // 1 is the hyphen + + // Extract the Stack ID Guid + const uniqueStackIdPart = cdk.Fn.select(2, cdk.Fn.split('/', `${cdk.Aws.STACK_ID}`)); + + let allParts: string = ''; + + parts.forEach((part) => { + allParts += part; + }); + + if (allParts.length > maxPartsLength) { + const subStringLength = maxPartsLength / 2; + allParts = allParts.substring(0, subStringLength) + allParts.substring(allParts.length - subStringLength); + } + + const finalName = prefix.toLowerCase() + allParts + '-' + uniqueStackIdPart; + return finalName; +} \ No newline at end of file diff --git a/src/patterns/gen-ai/aws-rag-appsync-stepfn-opensearch/index.ts b/src/patterns/gen-ai/aws-rag-appsync-stepfn-opensearch/index.ts index 482377db..2e4e7eeb 100644 --- a/src/patterns/gen-ai/aws-rag-appsync-stepfn-opensearch/index.ts +++ b/src/patterns/gen-ai/aws-rag-appsync-stepfn-opensearch/index.ts @@ -28,8 +28,8 @@ import * as stepfn_task from 'aws-cdk-lib/aws-stepfunctions-tasks'; import { NagSuppressions } from 'cdk-nag'; import { Construct } from 'constructs'; import * as s3_bucket_helper from '../../../common/helpers/s3-bucket-helper'; -import * as vpc_helper from '../../../common/helpers/vpc-helper'; import { generatePhysicalName } from '../../../common/helpers/utils'; +import * as vpc_helper from '../../../common/helpers/vpc-helper'; /** * The properties for the RagAppsyncStepfnOpensearchProps class. @@ -776,12 +776,12 @@ export class RagAppsyncStepfnOpensearch extends Construct { const maxGeneratedNameLength = maxLogGroupNameLength - logGroupPrefix.length; const nameParts: string[] = [ Stack.of(scope).stackName, // Name of the stack - scope.node.id, // Construct ID - 'StateMachineLog' // Literal string for log group name portion + scope.node.id, // Construct ID + 'StateMachineLog', // Literal string for log group name portion ]; const logGroupName = generatePhysicalName(logGroupPrefix, nameParts, maxGeneratedNameLength); const ragLogGroup = new logs.LogGroup(this, 'ingestionStepFunctionLogGroup', { - logGroupName: logGroupName + logGroupName: logGroupName, }); const ingestion_step_function = new stepfn.StateMachine( diff --git a/src/patterns/gen-ai/aws-summarization-appsync-stepfn/index.ts b/src/patterns/gen-ai/aws-summarization-appsync-stepfn/index.ts index ca787bbc..4b611ada 100644 --- a/src/patterns/gen-ai/aws-summarization-appsync-stepfn/index.ts +++ b/src/patterns/gen-ai/aws-summarization-appsync-stepfn/index.ts @@ -30,8 +30,8 @@ import { Construct } from 'constructs'; import * as eventBridge from '../../../common/helpers/eventbridge-helper'; import * as redisHelper from '../../../common/helpers/redis-helper'; import * as s3BucketHelper from '../../../common/helpers/s3-bucket-helper'; -import * as vpcHelper from '../../../common/helpers/vpc-helper'; import { generatePhysicalName } from '../../../common/helpers/utils'; +import * as vpcHelper from '../../../common/helpers/vpc-helper'; export interface SummarizationAppsyncStepfnProps { /** @@ -810,12 +810,12 @@ export class SummarizationAppsyncStepfn extends Construct { const maxGeneratedNameLength = maxLogGroupNameLength - logGroupPrefix.length; const nameParts: string[] = [ Stack.of(scope).stackName, // Name of the stack - scope.node.id, // Construct ID - 'StateMachineLog' // Literal string for log group name portion + scope.node.id, // Construct ID + 'StateMachineLog', // Literal string for log group name portion ]; const logGroupName = generatePhysicalName(logGroupPrefix, nameParts, maxGeneratedNameLength); const summarizationLogGroup = new logs.LogGroup(this, 'summarizationLogGroup', { - logGroupName: logGroupName + logGroupName: logGroupName, }); // step function definition