@@ -7,6 +7,7 @@ import * as vscode from 'vscode'
77import { getLogger } from './logger/logger'
88import * as redshift from '../awsService/redshift/models/models'
99import { TypeConstructor , cast } from './utilities/typeConstructors'
10+ import { Customization } from '../codewhisperer/client/codewhispereruserclient'
1011
1112type ToolId = 'codecatalyst' | 'codewhisperer' | 'testId'
1213export type ToolIdStateKey = `${ToolId } .savedConnectionId`
@@ -227,6 +228,27 @@ export class GlobalState implements vscode.Memento {
227228 return all ?. [ warehouseArn ]
228229 }
229230
231+ /**
232+ * Get the codewhisperer customerization. If legacy (map of customizations) store the
233+ * customization with label of profile name
234+ *
235+ * @param profileName name of profile, only used in case legacy customization is found
236+ * @returns codewhisperer customization, or undefined if not found.
237+ * If legacy, return the codewhisperer customization for the auth profile name
238+ */
239+ getCodewhispererCustomization ( profileName : string ) : Customization | undefined {
240+ const result = this . tryGet ( 'CODEWHISPERER_SELECTED_CUSTOMIZATION' , Object , undefined )
241+
242+ // Legacy migration for old customization map of type { [label: string]: Customization[] }
243+ if ( typeof result === 'object' && Object . values ( result ) . every ( Array . isArray ) ) {
244+ const selectedCustomization = result [ profileName ]
245+ this . tryUpdate ( 'CODEWHISPERER_SELECTED_CUSTOMIZATION' , selectedCustomization )
246+ return selectedCustomization
247+ } else {
248+ return result
249+ }
250+ }
251+
230252 /**
231253 * Sets SSO session creation timestamp for the given session `id`.
232254 *
0 commit comments