Skip to content

Commit 1cdbd87

Browse files
committed
types: slightly improve types
1 parent 829ef71 commit 1cdbd87

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/core/src/shared/awsClientBuilderV3.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
DeserializeHandler,
1313
DeserializeHandlerOptions,
1414
DeserializeMiddleware,
15+
Handler,
1516
HandlerExecutionContext,
1617
MetadataBearer,
1718
MiddlewareStack,
@@ -33,10 +34,18 @@ export type AwsClientConstructor<C> = new (o: AwsClientOptions) => C
3334

3435
// AWS-SDKv3 does not export generic types for clients so we need to build them as needed
3536
// https://github.com/aws/aws-sdk-js-v3/issues/5856#issuecomment-2096950979
36-
interface AwsClient {
37+
export interface AwsClient {
3738
middlewareStack: {
3839
add: MiddlewareStack<any, MetadataBearer>['add']
3940
}
41+
send: (command: AwsCommand, options?: any) => Promise<any>
42+
destroy: () => void
43+
}
44+
45+
export interface AwsCommand {
46+
input: object
47+
middlewareStack: any
48+
resolveMiddleware: (stack: any, configuration: any, options: any) => Handler<any, any>
4049
}
4150

4251
interface AwsClientOptions {

packages/core/src/shared/clients/wrapper.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
import * as vscode from 'vscode'
66
import globals from '../extensionGlobals'
7-
import { AwsClient, AwsClientConstructor } from '../awsClientBuilderV3'
7+
import { AwsClient, AwsClientConstructor, AwsCommand } from '../awsClientBuilderV3'
88
import { pageableToCollection } from '../utilities/collectionUtils'
99

1010
export abstract class ClientWrapper<C extends AwsClient> implements vscode.Disposable {
@@ -23,15 +23,19 @@ export abstract class ClientWrapper<C extends AwsClient> implements vscode.Dispo
2323
return this.client!
2424
}
2525

26-
protected async makeRequest<CommandInput extends object, Command extends object>(
26+
protected async makeRequest<CommandInput extends object, Command extends AwsCommand>(
2727
command: new (o: CommandInput) => Command,
2828
commandOptions: CommandInput
2929
) {
3030
const client = await this.getClient()
3131
return await client.send(new command(commandOptions))
3232
}
3333

34-
protected makePaginatedRequest<CommandInput extends object, CommandOutput extends object, Command extends object>(
34+
protected makePaginatedRequest<
35+
CommandInput extends object,
36+
CommandOutput extends object,
37+
Command extends AwsCommand,
38+
>(
3539
command: new (o: CommandInput) => Command,
3640
commandOptions: CommandInput,
3741
collectKey: keyof CommandOutput & string,

0 commit comments

Comments
 (0)