99 */
1010
1111import { AuthFollowUpType , AuthMessageDataMap } from '../../../../amazonq/auth/model'
12- import { JDKVersion , TransformationCandidateProject , transformByQState } from '../../../../codewhisperer/models/model'
12+ import {
13+ DB ,
14+ JDKVersion ,
15+ TransformationCandidateProject ,
16+ transformByQState ,
17+ } from '../../../../codewhisperer/models/model'
1318import { FeatureAuthState } from '../../../../codewhisperer/util/authUtil'
1419import * as CodeWhispererConstants from '../../../../codewhisperer/models/constants'
1520import {
@@ -48,6 +53,7 @@ export type UnrecoverableErrorType =
4853 | 'unsupported-source-jdk-version'
4954 | 'upload-to-s3-failed'
5055 | 'job-start-failed'
56+ | 'unsupported-source-db-version'
5157
5258export enum GumbyNamedMessages {
5359 COMPILATION_PROGRESS_MESSAGE = 'gumbyProjectCompilationMessage' ,
@@ -151,7 +157,7 @@ export class Messenger {
151157 )
152158 }
153159
154- public async sendProjectPrompt ( projects : TransformationCandidateProject [ ] , tabID : string ) {
160+ public async sendLanguageUpgradeProjectPrompt ( projects : TransformationCandidateProject [ ] , tabID : string ) {
155161 const projectFormOptions : { value : any ; label : string } [ ] = [ ]
156162 const detectedJavaVersions = new Array < JDKVersion | undefined > ( )
157163
@@ -165,7 +171,7 @@ export class Messenger {
165171
166172 const formItems : ChatItemFormItem [ ] = [ ]
167173 formItems . push ( {
168- id : 'GumbyTransformProjectForm ' ,
174+ id : 'GumbyTransformLanguageUpgradeProjectForm ' ,
169175 type : 'select' ,
170176 title : CodeWhispererConstants . chooseProjectFormTitle ,
171177 mandatory : true ,
@@ -181,11 +187,11 @@ export class Messenger {
181187 options : [
182188 {
183189 value : JDKVersion . JDK8 ,
184- label : JDKVersion . JDK8 . toString ( ) ,
190+ label : JDKVersion . JDK8 ,
185191 } ,
186192 {
187193 value : JDKVersion . JDK11 ,
188- label : JDKVersion . JDK11 . toString ( ) ,
194+ label : JDKVersion . JDK11 ,
189195 } ,
190196 {
191197 value : JDKVersion . UNSUPPORTED ,
@@ -210,7 +216,88 @@ export class Messenger {
210216 this . dispatcher . sendAsyncEventProgress (
211217 new AsyncEventProgressMessage ( tabID , {
212218 inProgress : true ,
213- message : MessengerUtils . createTransformationConfirmationPrompt ( detectedJavaVersions ) ,
219+ message : MessengerUtils . createLanguageUpgradeTransformationConfirmationPrompt ( detectedJavaVersions ) ,
220+ } )
221+ )
222+
223+ this . dispatcher . sendAsyncEventProgress (
224+ new AsyncEventProgressMessage ( tabID , {
225+ inProgress : false ,
226+ message : undefined ,
227+ } )
228+ )
229+
230+ this . dispatcher . sendChatPrompt (
231+ new ChatPrompt (
232+ {
233+ message : 'Q Code Transformation' ,
234+ formItems : formItems ,
235+ } ,
236+ 'LanguageUpgradeTransformForm' ,
237+ tabID ,
238+ false
239+ )
240+ )
241+ }
242+
243+ public async sendSQLConversionProjectPrompt ( projects : TransformationCandidateProject [ ] , tabID : string ) {
244+ const projectFormOptions : { value : any ; label : string } [ ] = [ ]
245+
246+ projects . forEach ( ( candidateProject ) => {
247+ projectFormOptions . push ( {
248+ value : candidateProject . path ,
249+ label : candidateProject . name ,
250+ } )
251+ } )
252+
253+ const formItems : ChatItemFormItem [ ] = [ ]
254+ formItems . push ( {
255+ id : 'GumbyTransformSQLConversionProjectForm' ,
256+ type : 'select' ,
257+ title : 'Choose a project to transform' ,
258+ mandatory : true ,
259+
260+ options : projectFormOptions ,
261+ } )
262+
263+ formItems . push ( {
264+ id : 'GumbyTransformDBFromForm' ,
265+ type : 'select' ,
266+ title : 'Choose the source database' ,
267+ mandatory : true ,
268+ options : [
269+ {
270+ value : 'Oracle' ,
271+ label : 'Oracle' ,
272+ } ,
273+ {
274+ value : 'Other' ,
275+ label : 'Other' ,
276+ } ,
277+ ] ,
278+ } )
279+
280+ formItems . push ( {
281+ id : 'GumbyTransformDBToForm' ,
282+ type : 'select' ,
283+ title : 'Choose the target database' ,
284+ mandatory : true ,
285+ options : [
286+ {
287+ value : 'Amazon RDS for PostgreSQL' ,
288+ label : 'Amazon RDS for PostgreSQL' ,
289+ } ,
290+ {
291+ value : 'Amazon Aurora PostgreSQL' ,
292+ label : 'Amazon Aurora PostgreSQL' ,
293+ } ,
294+ ] ,
295+ } )
296+
297+ this . dispatcher . sendAsyncEventProgress (
298+ new AsyncEventProgressMessage ( tabID , {
299+ inProgress : true ,
300+ message : 'I can convert your embedded SQL, but I need some more info from you first.' ,
214301 } )
215302 )
216303
@@ -227,7 +314,7 @@ export class Messenger {
227314 message : 'Q Code Transformation' ,
228315 formItems : formItems ,
229316 } ,
230- 'TransformForm ' ,
317+ 'SQLConversionTransformForm ' ,
231318 tabID ,
232319 false
233320 )
@@ -318,7 +405,7 @@ export class Messenger {
318405 )
319406 }
320407
321- public sendStaticTextResponse ( messageType : StaticTextResponseType , itemType : ChatItemType , tabID : string ) {
408+ public sendStaticTextResponse ( messageType : StaticTextResponseType , tabID : string ) {
322409 let message = '...'
323410
324411 switch ( messageType ) {
@@ -331,16 +418,13 @@ export class Messenger {
331418 case 'choose-transformation-objective' :
332419 message = 'Choose your transformation objective.'
333420 break
334- case 'language-upgrade-selected' :
335- message = 'Got it! I can upgrade your Java 8 or 11 project to Java 17.'
336- break
337421 }
338422
339423 this . dispatcher . sendChatMessage (
340424 new ChatMessage (
341425 {
342426 message,
343- messageType : itemType ,
427+ messageType : 'ai-prompt' ,
344428 } ,
345429 tabID
346430 )
@@ -375,6 +459,9 @@ export class Messenger {
375459 case 'unsupported-source-jdk-version' :
376460 message = CodeWhispererConstants . unsupportedJavaVersionChatMessage
377461 break
462+ case 'unsupported-source-db-version' :
463+ message = CodeWhispererConstants . unsupportedDatabaseChatMessage
464+ break
378465 }
379466
380467 const buttons : ChatItemButton [ ] = [ ]
@@ -451,7 +538,7 @@ export class Messenger {
451538 )
452539 }
453540
454- public sendProjectSelectionMessage (
541+ public sendLanguageUpgradeProjectSelectionMessage (
455542 projectName : string ,
456543 fromJDKVersion : JDKVersion ,
457544 toJDKVersion : JDKVersion ,
@@ -469,6 +556,18 @@ export class Messenger {
469556 this . dispatcher . sendChatMessage ( new ChatMessage ( { message, messageType : 'prompt' } , tabID ) )
470557 }
471558
559+ public sendSQLConversionProjectSelectionMessage ( projectName : string , fromDB : DB , toDB : DB , tabID : string ) {
560+ const message = `### Transformation details
561+ -------------
562+ | | |
563+ | :------------------- | -------: |
564+ | **Project** | ${ projectName } |
565+ | **Source DB** | ${ fromDB } |
566+ | **Target DB** | ${ toDB } |
567+ `
568+ this . dispatcher . sendChatMessage ( new ChatMessage ( { message, messageType : 'prompt' } , tabID ) )
569+ }
570+
472571 public sendSkipTestsSelectionMessage ( skipTestsSelection : string , tabID : string ) {
473572 const message = `Okay, I will ${ skipTestsSelection . toLowerCase ( ) } when building your project.`
474573 this . dispatcher . sendChatMessage ( new ChatMessage ( { message, messageType : 'ai-prompt' } , tabID ) )
0 commit comments