44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import { Command , Message , MessageType , BaseContext , ApiCallRequestMessage , UnsupportedMessage } from './types'
8- import { StepFunctionApiHandler } from './stepFunctionApiHandler'
9- import globals from '../../shared/extensionGlobals'
7+ import { Command , Message , MessageType , BaseContext , UnsupportedMessage , ApiCallRequestMessage } from './types'
108import { getLogger } from '../../shared/logger/logger'
9+ import { StepFunctionApiHandler } from './stepFunctionApiHandler'
1110
1211/**
1312 * Handler for managing webview stage load, which updates load notifications.
@@ -20,17 +19,6 @@ export async function loadStageMessageHandler(context: BaseContext) {
2019 } , 100 )
2120}
2221
23- /**
24- * Handler for making API calls from the webview and returning the response.
25- * @param request The request message containing the API to call and the parameters
26- * @param context The webview context used for returning the API response to the webview
27- */
28- export function apiCallMessageHandler ( request : ApiCallRequestMessage , context : BaseContext ) {
29- const logger = getLogger ( 'stepfunctions' )
30- const apiHandler = new StepFunctionApiHandler ( globals . awsContext . getCredentialDefaultRegion ( ) , context )
31- apiHandler . performApiCall ( request ) . catch ( ( error ) => logger . error ( '%s API call failed: %O' , request . apiName , error ) )
32- }
33-
3422/**
3523 * Handles unsupported or unrecognized messages by sending a response to the webview. Ensures compatibility with future
3624 * commands and message types, preventing issues if the user has an outdated extension version.
@@ -45,3 +33,15 @@ export async function handleUnsupportedMessage(context: BaseContext, originalMes
4533 originalMessage,
4634 } as UnsupportedMessage )
4735}
36+
37+ /**
38+ * Handler for making API calls from the webview and returning the response.
39+ * @param request The request message containing the API to call and the parameters
40+ * @param context The webview context used for returning the API response to the webview
41+ * @param region The AWS region to use for the API calls
42+ */
43+ export function apiCallMessageHandler ( request : ApiCallRequestMessage , context : BaseContext , region : string ) {
44+ const logger = getLogger ( 'stepfunctions' )
45+ const apiHandler = new StepFunctionApiHandler ( region , context )
46+ apiHandler . performApiCall ( request ) . catch ( ( error ) => logger . error ( '%s API call failed: %O' , request . apiName , error ) )
47+ }
0 commit comments