Skip to content

Commit d52bc7f

Browse files
committed
refactor: remove final imports
1 parent bd39380 commit d52bc7f

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

packages/core/src/dynamicResources/explorer/nodes/resourcesNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { PlaceholderNode } from '../../../shared/treeview/nodes/placeholderNode'
1111
import { makeChildrenNodes } from '../../../shared/treeview/utils'
1212
import { toArrayAsync, updateInPlace } from '../../../shared/utilities/collectionUtils'
1313
import { ResourceTypeNode } from './resourceTypeNode'
14-
import { CloudFormation } from 'aws-sdk'
1514
import { CloudControlClient, DefaultCloudControlClient } from '../../../shared/clients/cloudControlClient'
1615
import { memoizedGetResourceTypes, ResourceTypeMetadata } from '../../model/resources'
1716
import { ResourcesSettings } from '../../commands/configure'
17+
import { TypeSummary } from '@aws-sdk/client-cloudformation'
1818

1919
const localize = nls.loadMessageBundle()
2020

@@ -62,7 +62,7 @@ export class ResourcesNode extends AWSTreeNodeBase {
6262
const types = await toArrayAsync(this.cloudFormation.listTypes())
6363
types.sort((a, b) => (a.LastUpdated?.getTime() ?? 0) - (b.LastUpdated?.getTime() ?? 0))
6464

65-
const availableTypes: Map<string, CloudFormation.TypeSummary> = new Map()
65+
const availableTypes: Map<string, TypeSummary> = new Map()
6666
for (const type of types) {
6767
if (type.TypeName) {
6868
availableTypes.set(type.TypeName!, type)

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { CloudFormation } from 'aws-sdk'
76
import * as CloudFormationV3 from '@aws-sdk/client-cloudformation'
8-
import globals from '../extensionGlobals'
97
import { AsyncCollection } from '../utilities/asyncCollection'
108
import { hasProps, isNonNullable, RequiredProps } from '../utilities/tsUtils'
119
import { ClientWrapper } from './clientWrapper'
@@ -29,21 +27,14 @@ export class CloudFormationClient extends ClientWrapper<CloudFormationV3.CloudFo
2927
return await this.makeRequest(CloudFormationV3.DeleteStackCommand, { StackName: name })
3028
}
3129

32-
public async describeType(typeName: string): Promise<CloudFormation.DescribeTypeOutput> {
33-
const client = await this.createSdkClient()
34-
35-
return await client
36-
.describeType({
37-
Type: 'RESOURCE',
38-
TypeName: typeName,
39-
})
40-
.promise()
30+
public async describeType(typeName: string): Promise<CloudFormationV3.DescribeTypeOutput> {
31+
return await this.makeRequest(CloudFormationV3.DescribeTypeCommand, { TypeName: typeName })
4132
}
4233

4334
public async *listStacks(
44-
statusFilter: string[] = ['CREATE_COMPLETE', 'UPDATE_COMPLETE']
35+
statusFilter: CloudFormationV3.StackStatus[] = ['CREATE_COMPLETE', 'UPDATE_COMPLETE']
4536
): AsyncIterableIterator<StackSummary> {
46-
const request: CloudFormation.ListStacksInput = {
37+
const request: CloudFormationV3.ListStacksInput = {
4738
StackStatusFilter: statusFilter,
4839
}
4940

@@ -94,10 +85,6 @@ export class CloudFormationClient extends ClientWrapper<CloudFormationV3.CloudFo
9485
public async describeStackResources(name: string): Promise<DescribeStackResourcesOutput> {
9586
return await this.makeRequest(CloudFormationV3.DescribeStackResourcesCommand, { StackName: name })
9687
}
97-
98-
private async createSdkClient(): Promise<CloudFormation> {
99-
return await globals.sdkClientBuilder.createAwsService(CloudFormation, undefined, this.regionCode)
100-
}
10188
}
10289

10390
function isStackSummary(s: CloudFormationV3.StackSummary | undefined): s is StackSummary {

packages/core/src/test/dynamicResources/awsResourceManager.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import { existsSync } from 'fs' // eslint-disable-line no-restricted-imports
2020
import { ResourceTypeMetadata } from '../../dynamicResources/model/resources'
2121
import globals from '../../shared/extensionGlobals'
2222
import { Stub, stub } from '../utilities/stubber'
23-
import { CloudControl, CloudFormation } from 'aws-sdk'
23+
import { CloudControl } from 'aws-sdk'
2424
import { fs } from '../../shared'
25+
import { DescribeTypeOutput } from '@aws-sdk/client-cloudformation'
2526

2627
describe('ResourceManager', function () {
2728
let sandbox: sinon.SinonSandbox
@@ -237,7 +238,7 @@ describe('ResourceManager', function () {
237238
})
238239
cloudFormation.describeType.callsFake(async (name: string) => {
239240
if (name === fakeTypeName) {
240-
return { Schema: '{}' } as any as CloudFormation.DescribeTypeOutput
241+
return { Schema: '{}' } as any as DescribeTypeOutput
241242
}
242243
throw new Error()
243244
})

packages/core/src/test/dynamicResources/explorer/moreResourcesNode.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { ResourceTypeNode } from '../../../dynamicResources/explorer/nodes/resou
1010
import { CloudFormationClient } from '../../../shared/clients/cloudFormation'
1111
import { assertNodeListOnlyHasPlaceholderNode } from '../../utilities/explorerNodeAssertions'
1212
import { asyncGenerator } from '../../../shared/utilities/collectionUtils'
13-
import { CloudFormation } from 'aws-sdk'
1413
import { CloudControlClient } from '../../../shared/clients/cloudControlClient'
1514
import { Settings } from '../../../shared/settings'
1615
import { ResourcesSettings } from '../../../dynamicResources/commands/configure'
1716
import sinon from 'sinon'
17+
import { TypeSummary } from '@aws-sdk/client-cloudformation'
1818

1919
const unsortedText = ['zebra', 'Antelope', 'aardvark', 'elephant']
2020
const sortedText = ['aardvark', 'Antelope', 'elephant', 'zebra']
@@ -101,8 +101,8 @@ describe('ResourcesNode', function () {
101101

102102
function prepareMock(resourceTypes: string[]) {
103103
const listStub = sinon.stub().returns(
104-
asyncGenerator<CloudFormation.TypeSummary>(
105-
resourceTypes.map<CloudFormation.TypeSummary>((resourceType) => {
104+
asyncGenerator<TypeSummary>(
105+
resourceTypes.map<TypeSummary>((resourceType) => {
106106
return {
107107
TypeName: resourceType,
108108
}

0 commit comments

Comments
 (0)