Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hasani committed Oct 11, 2024
1 parent 34dc003 commit d4c7c14
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
26 changes: 13 additions & 13 deletions packages/core/src/amazonqGumby/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class GumbyController {
const authState = await AuthUtil.instance.getChatAuthState()
if (authState.amazonQ !== 'connected') {
this.sessionStorage.getSession().isAuthenticating = true
this.messenger.sendAuthNeededExceptionMessage(authState, message.tabID)
await this.messenger.sendAuthNeededExceptionMessage(authState, message.tabID)
throw new NoAuthError()
}
this.messenger.sendTransformationIntroduction(message.tabID)
Expand All @@ -246,7 +246,7 @@ export class GumbyController {
private async handleLanguageUpgrade(message: any) {
try {
await this.beginTransformation(message)
const validProjects = await this.validateLanguageUpgradeProjectsWithReplyOnError(message)
const validProjects = await this.validateLanguageUpgradeProjects(message)
if (validProjects.length > 0) {
this.sessionStorage.getSession().updateCandidateProjects(validProjects)
await this.messenger.sendLanguageUpgradeProjectPrompt(validProjects, message.tabID)
Expand All @@ -259,7 +259,7 @@ export class GumbyController {
private async handleSQLConversion(message: any) {
try {
await this.beginTransformation(message)
const validProjects = await this.validateSQLConversionProjectsWithReplyOnError(message)
const validProjects = await this.validateSQLConversionProjects(message)
if (validProjects.length > 0) {
this.sessionStorage.getSession().updateCandidateProjects(validProjects)
await this.messenger.sendSelectSQLMetadataFileMessage(message.tabID)
Expand All @@ -269,7 +269,7 @@ export class GumbyController {
}
}

private async validateLanguageUpgradeProjectsWithReplyOnError(message: any) {
private async validateLanguageUpgradeProjects(message: any) {
let telemetryJavaVersion = JDKToTelemetryValue(JDKVersion.UNSUPPORTED) as CodeTransformJavaSourceVersionsAllowed
try {
const validProjects = await telemetry.codeTransform_validateProject.run(async () => {
Expand Down Expand Up @@ -306,7 +306,7 @@ export class GumbyController {
return []
}

private async validateSQLConversionProjectsWithReplyOnError(message: any) {
private async validateSQLConversionProjects(message: any) {
try {
const validProjects = await telemetry.codeTransform_validateProject.run(async () => {
telemetry.record({
Expand All @@ -330,7 +330,7 @@ export class GumbyController {
const typedAction = MessengerUtils.stringToEnumValue(ButtonActions, message.action as any)
switch (typedAction) {
case ButtonActions.CONFIRM_LANGUAGE_UPGRADE_TRANSFORMATION_FORM:
await this.handleUserLanguageUpgradeProjectSelection(message)
await this.handleUserLanguageUpgradeProjectChoice(message)
break
case ButtonActions.CANCEL_TRANSFORMATION_FORM:
telemetry.codeTransform_submitSelection.emit({
Expand Down Expand Up @@ -403,7 +403,7 @@ export class GumbyController {
await this.validateBuildWithPromptOnError(message)
}

private async handleUserLanguageUpgradeProjectSelection(message: any) {
private async handleUserLanguageUpgradeProjectChoice(message: any) {
await telemetry.codeTransform_submitSelection.run(async () => {
const pathToProject: string = message.formSelectedValues['GumbyTransformLanguageUpgradeProjectForm']
const toJDKVersion: JDKVersion = message.formSelectedValues['GumbyTransformJdkToForm']
Expand All @@ -421,7 +421,7 @@ export class GumbyController {
})

const projectName = path.basename(pathToProject)
this.messenger.sendLanguageUpgradeProjectSelectionMessage(
this.messenger.sendLanguageUpgradeProjectChoiceMessage(
projectName,
fromJDKVersion,
toJDKVersion,
Expand Down Expand Up @@ -465,7 +465,7 @@ export class GumbyController {
})
}

private async prepareLanguageUpgradeProjectForSubmission(message: { pathToJavaHome: string; tabID: string }) {
private async prepareLanguageUpgradeProject(message: { pathToJavaHome: string; tabID: string }) {
if (message.pathToJavaHome) {
transformByQState.setJavaHome(message.pathToJavaHome)
getLogger().info(
Expand Down Expand Up @@ -524,7 +524,7 @@ export class GumbyController {
throw err
}

await this.prepareLanguageUpgradeProjectForSubmission(message)
await this.prepareLanguageUpgradeProject(message)
}

private async processMetadataFile(message: any) {
Expand Down Expand Up @@ -597,7 +597,7 @@ export class GumbyController {
case ConversationState.PROMPT_JAVA_HOME: {
const pathToJavaHome = extractPath(data.message)
if (pathToJavaHome) {
await this.prepareLanguageUpgradeProjectForSubmission({
await this.prepareLanguageUpgradeProject({
pathToJavaHome,
tabID: data.tabID,
})
Expand All @@ -610,9 +610,9 @@ export class GumbyController {
case ConversationState.WAITING_FOR_OBJECTIVE: {
const objective = data.message.trim().toLowerCase()
if (objective === 'language upgrade') {
this.handleLanguageUpgrade(data)
await this.handleLanguageUpgrade(data)
} else if (objective === 'sql conversion') {
this.handleSQLConversion(data)
await this.handleSQLConversion(data)
} else {
// keep prompting user until they enter a valid option
await this.transformInitiated(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class Messenger {
this.dispatcher.sendAsyncEventProgress(
new AsyncEventProgressMessage(tabID, {
inProgress: true,
message: MessengerUtils.createLanguageUpgradeTransformationConfirmationPrompt(detectedJavaVersions),
message: MessengerUtils.createLanguageUpgradeConfirmationPrompt(detectedJavaVersions),
})
)

Expand Down Expand Up @@ -433,10 +433,10 @@ export class Messenger {
message = CodeWhispererConstants.unsupportedJavaVersionChatMessage
break
case 'unsupported-source-db':
message = CodeWhispererConstants.invalidMetadataFileUnsupportedSourceVendor
message = CodeWhispererConstants.invalidMetadataFileUnsupportedSourceDB
break
case 'unsupported-target-db':
message = CodeWhispererConstants.invalidMetadataFileUnsupportedTargetVendor
message = CodeWhispererConstants.invalidMetadataFileUnsupportedTargetDB
break
case 'error-parsing-sct-file':
message = CodeWhispererConstants.invalidMetadataFileErrorParsing
Expand Down Expand Up @@ -518,7 +518,7 @@ export class Messenger {
// TO-DO: add a delay for 2s here to match IntelliJ
}

public sendLanguageUpgradeProjectSelectionMessage(
public sendLanguageUpgradeProjectChoiceMessage(
projectName: string,
fromJDKVersion: JDKVersion,
toJDKVersion: JDKVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ export default class MessengerUtils {
}
}

static createLanguageUpgradeTransformationConfirmationPrompt = (
detectedJavaVersions: Array<JDKVersion | undefined>
): string => {
static createLanguageUpgradeConfirmationPrompt = (detectedJavaVersions: Array<JDKVersion | undefined>): string => {
let javaVersionString = 'Java project'
const uniqueJavaOptions = new Set(detectedJavaVersions)

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/codewhisperer/commands/startTransformByQ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export async function validateSQLMetadataFile(fileContents: string, message: any
let sctData: any = undefined
xml2js.parseString(fileContents, (err, result) => {
if (err) {
getLogger().error('Error parsing .sct file, not valid XML:', err)
getLogger().error('CodeTransformation: Error parsing .sct file, not valid XML.', err)
throw new Error(`Invalid XML encountered`)
} else {
sctData = result
Expand Down Expand Up @@ -143,10 +143,10 @@ export async function validateSQLMetadataFile(fileContents: string, message: any
})
transformByQState.setSchemaOptions(schemaNames) // user will choose one of these
getLogger().info(
`Parsed SCT file with source DB: ${sourceDB}, target DB: ${targetDB}, source host name: ${sourceServerName}, and schema names: ${schemaNames}`
`CodeTransformation: Parsed .sct file with source DB: ${sourceDB}, target DB: ${targetDB}, source host name: ${sourceServerName}, and schema names: ${Array.from(schemaNames)}`
)
} catch (e: any) {
getLogger().error('Error parsing .sct file:', e)
} catch (err: any) {
getLogger().error('CodeTransformation: Error parsing .sct file.', err)
transformByQState.getChatMessenger()?.sendUnrecoverableErrorResponse('error-parsing-sct-file', message.tabID)
return false
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ export const unsupportedJavaVersionChatMessage = `Sorry, currently I can only up
export const selectSQLMetadataFileHelpMessage =
'Next, I need the .sct metadata file of your project. You can download the .sct file by going to AWS Console -> AWS DMS -> Migration Projects. Open the schema conversion project and navigate to the S3 bucket linked to it. You will find the ZIP containing the .sct file under the {schema-conversion-project}/ directory.'

export const invalidMetadataFileUnsupportedSourceVendor = `Sorry, your .sct metadata file appears to be invalid; the source DB must be Oracle.`
export const invalidMetadataFileUnsupportedSourceDB = `Sorry, your .sct metadata file appears to be invalid; the source DB must be Oracle.`

export const invalidMetadataFileUnsupportedTargetVendor = `Sorry, your .sct metadata file appears to be invalid; the target DB must be Aurora Postgresql or Amazon RDS for Postgresql.`
export const invalidMetadataFileUnsupportedTargetDB = `Sorry, your .sct metadata file appears to be invalid; the target DB must be Aurora Postgresql or Amazon RDS for Postgresql.`

export const invalidMetadataFileErrorParsing = 'Sorry, the .sct metadata file you provided appears to be invalid.'

Expand Down

0 comments on commit d4c7c14

Please sign in to comment.