Skip to content

Commit 1eb4a28

Browse files
authored
refactor(codecatalyst): migrate to aws-sdk v3 (#8043)
## Problem AWS SDK V2 is at EOL. All client should migrate to V3. ## Solution Migrate CodeCatalyst client to V3. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent d8bc4a3 commit 1eb4a28

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

packages/core/src/codecatalyst/utils.ts

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

6-
import { Ides } from 'aws-sdk/clients/codecatalyst'
6+
import { Ide } from '@aws-sdk/client-codecatalyst'
77
import * as vscode from 'vscode'
88
import { CodeCatalystResource, getCodeCatalystConfig } from '../shared/clients/codecatalystClient'
99
import { pushIf } from '../shared/utilities/collectionUtils'
@@ -55,6 +55,6 @@ export function openCodeCatalystUrl(o: CodeCatalystResource) {
5555
}
5656

5757
/** Returns true if the dev env has a "vscode" IDE runtime. */
58-
export function isDevenvVscode(ides: Ides | undefined): boolean {
58+
export function isDevenvVscode(ides: Ide[] | undefined): boolean {
5959
return ides !== undefined && ides.some((ide) => ide.name === 'VSCode')
6060
}

packages/core/src/codecatalyst/vue/create/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { CancellationError } from '../../../shared/utilities/timeoutUtils'
3232
import { telemetry } from '../../../shared/telemetry/telemetry'
3333
import { isNonNullable } from '../../../shared/utilities/tsUtils'
3434
import { createOrgPrompter, createProjectPrompter } from '../../wizards/selectResource'
35-
import { GetSourceRepositoryCloneUrlsRequest } from 'aws-sdk/clients/codecatalyst'
35+
import { GetSourceRepositoryCloneUrlsRequest } from '@aws-sdk/client-codecatalyst'
3636
import { QuickPickPrompter } from '../../../shared/ui/pickerPrompter'
3737

3838
interface LinkedResponse {

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ import {
2424
} from '../utilities/tsUtils'
2525
import { AsyncCollection, toCollection } from '../utilities/asyncCollection'
2626
import { joinAll, pageableToCollection } from '../utilities/collectionUtils'
27-
import { CodeCatalyst } from 'aws-sdk'
2827
import { ToolkitError } from '../errors'
2928
import { Uri } from 'vscode'
30-
import { GetSourceRepositoryCloneUrlsRequest } from 'aws-sdk/clients/codecatalyst'
3129
import {
3230
CodeCatalystClient as CodeCatalystSDKClient,
3331
CreateAccessTokenCommand,
@@ -53,15 +51,18 @@ import {
5351
GetProjectCommandOutput,
5452
GetProjectRequest,
5553
GetSourceRepositoryCloneUrlsCommand,
54+
GetSourceRepositoryCloneUrlsRequest,
5655
GetSourceRepositoryCloneUrlsResponse,
5756
GetSpaceCommand,
5857
GetSpaceCommandOutput,
5958
GetSpaceRequest,
6059
GetSubscriptionCommand,
6160
GetSubscriptionRequest,
61+
GetSubscriptionResponse,
6262
GetUserDetailsCommand,
6363
GetUserDetailsCommandOutput,
6464
GetUserDetailsRequest,
65+
GetUserDetailsResponse,
6566
ListDevEnvironmentsCommand,
6667
ListDevEnvironmentsRequest,
6768
ListDevEnvironmentsResponse,
@@ -73,6 +74,7 @@ import {
7374
ListSourceRepositoriesRequest,
7475
ListSourceRepositoriesResponse,
7576
ListSourceRepositoryBranchesCommand,
77+
ListSourceRepositoryBranchesItem,
7678
ListSourceRepositoryBranchesRequest,
7779
ListSpacesCommand,
7880
ListSpacesRequest,
@@ -152,14 +154,14 @@ export interface DevEnvironment extends CodeCatalystDevEnvironmentSummary {
152154

153155
/** CodeCatalyst developer environment session. */
154156
// eslint-disable-next-line @typescript-eslint/no-empty-interface
155-
export interface CodeCatalystDevEnvSession extends CodeCatalyst.StartDevEnvironmentResponse {}
157+
export interface CodeCatalystDevEnvSession extends StartDevEnvironmentResponse {}
156158

157159
export interface CodeCatalystOrg extends SpaceSummary {
158160
readonly type: 'org'
159161
readonly name: string
160162
}
161163

162-
export interface CodeCatalystProject extends CodeCatalyst.ProjectSummary {
164+
export interface CodeCatalystProject extends ProjectSummary {
163165
readonly type: 'project'
164166
readonly name: string
165167
readonly org: Pick<CodeCatalystOrg, 'name'>
@@ -172,7 +174,7 @@ export interface CodeCatalystRepo extends ListSourceRepositoriesItem {
172174
readonly project: Pick<CodeCatalystProject, 'name'>
173175
}
174176

175-
export interface CodeCatalystBranch extends CodeCatalyst.ListSourceRepositoryBranchesItem {
177+
export interface CodeCatalystBranch extends ListSourceRepositoryBranchesItem {
176178
readonly type: 'branch'
177179
readonly name: string
178180
readonly repo: Pick<CodeCatalystRepo, 'name'>
@@ -200,7 +202,7 @@ function toBranch(
200202
org: string,
201203
project: string,
202204
repo: string,
203-
branch: CodeCatalyst.ListSourceRepositoryBranchesItem
205+
branch: ListSourceRepositoryBranchesItem
204206
): CodeCatalystBranch {
205207
assertHasProps(branch, 'name')
206208

@@ -229,10 +231,7 @@ function createCodeCatalystClient(
229231
})
230232
}
231233

232-
export type UserDetails = RequiredProps<
233-
CodeCatalyst.GetUserDetailsResponse,
234-
'userId' | 'userName' | 'displayName' | 'primaryEmail'
235-
>
234+
export type UserDetails = RequiredProps<GetUserDetailsResponse, 'userId' | 'userName' | 'displayName' | 'primaryEmail'>
236235

237236
// CodeCatalyst client has two variants: 'logged-in' and 'not logged-in'
238237
// The 'not logged-in' variant is a subtype and has restricted functionality
@@ -421,7 +420,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
421420
}
422421
}
423422

424-
public async getSubscription(request: GetSubscriptionRequest): Promise<CodeCatalyst.GetSubscriptionResponse> {
423+
public async getSubscription(request: GetSubscriptionRequest): Promise<GetSubscriptionResponse> {
425424
return this.call(GetSubscriptionCommand, request, false)
426425
}
427426

packages/core/src/test/shared/sshConfig.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
connectScriptPrefix,
1818
getCodeCatalystSsmEnv,
1919
} from '../../codecatalyst/model'
20-
import { StartDevEnvironmentSessionRequest } from 'aws-sdk/clients/codecatalyst'
20+
import { StartDevEnvironmentSessionRequest } from '@aws-sdk/client-codecatalyst'
2121
import { mkdir, readFile } from 'fs/promises'
2222
import fs from '../../shared/fs/fs'
2323
import { globals } from '../../shared'

packages/core/src/testE2E/codecatalyst/client.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import globals from '../../shared/extensionGlobals'
2020
import { CodeCatalystCreateWebview, SourceResponse } from '../../codecatalyst/vue/create/backend'
2121
import { waitUntil } from '../../shared/utilities/timeoutUtils'
2222
import { AccessDeniedException } from '@aws-sdk/client-sso-oidc'
23-
import { GetDevEnvironmentRequest } from 'aws-sdk/clients/codecatalyst'
23+
import { GetDevEnvironmentRequest, _InstanceType } from '@aws-sdk/client-codecatalyst'
2424
import { getTestWindow } from '../../test/shared/vscode/window'
2525
import { patchObject, registerAuthHook, skipTest, using } from '../../test/setupUtil'
2626
import { isExtensionInstalled } from '../../shared/utilities/vsCodeUtils'
@@ -37,7 +37,6 @@ import {
3737
SsoConnection,
3838
} from '../../auth/connection'
3939
import { hasKey } from '../../shared/utilities/tsUtils'
40-
import { _InstanceType } from '@aws-sdk/client-codecatalyst'
4140

4241
let spaceName: CodeCatalystOrg['name']
4342
let projectName: CodeCatalystProject['name']
@@ -615,6 +614,9 @@ describe('Test how this codebase uses the CodeCatalyst API', function () {
615614
): Promise<void> {
616615
const result = await waitUntil(
617616
async function () {
617+
if (!devEnv.spaceName || !devEnv.projectName) {
618+
return false
619+
}
618620
const devEnvData = await client.getDevEnvironment({
619621
spaceName: devEnv.spaceName,
620622
projectName: devEnv.projectName,

0 commit comments

Comments
 (0)