Skip to content

Commit 79e1de1

Browse files
committed
refactor: remove v3 suffix
1 parent f0c3e31 commit 79e1de1

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

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

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function toBranch(
213213
}
214214
}
215215

216-
function createCodeCatalystClientV3(
216+
function createCodeCatalystClient(
217217
tokenProvider: TokenIdentityProvider,
218218
regionCode: string,
219219
endpoint: string
@@ -257,7 +257,7 @@ export async function createClient(
257257
endpoint = getCodeCatalystConfig().endpoint,
258258
authOptions: AuthOptions = {}
259259
): Promise<CodeCatalystClient> {
260-
const sdkv3Client = createCodeCatalystClientV3(getTokenProvider(connection), regionCode, endpoint)
260+
const sdkv3Client = createCodeCatalystClient(getTokenProvider(connection), regionCode, endpoint)
261261
const c = new CodeCatalystClientInternal(connection, sdkv3Client, regionCode)
262262
try {
263263
await c.verifySession()
@@ -334,7 +334,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
334334
return { id: this.userDetails.userId, name: this.userDetails.userName }
335335
}
336336

337-
private async callV3<
337+
private async call<
338338
CommandInput extends object,
339339
CommandOutput extends object,
340340
CommandOptions extends CommandInput,
@@ -345,13 +345,13 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
345345
silent: true,
346346
defaultVal: CommandOutput
347347
): Promise<CommandOutput>
348-
private async callV3<
348+
private async call<
349349
CommandInput extends object,
350350
CommandOutput extends object,
351351
CommandOptions extends CommandInput,
352352
Command extends AwsCommand<CommandInput, CommandOutput>,
353353
>(cmd: new (o: CommandInput) => Command, commandOptions: CommandOptions, silent: false): Promise<CommandOutput>
354-
private async callV3<
354+
private async call<
355355
CommandInput extends object,
356356
CommandOutput extends object,
357357
CommandOptions extends CommandInput,
@@ -407,7 +407,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
407407
args: CreateAccessTokenRequest
408408
): Promise<RequiredProps<CreateAccessTokenResponse, 'secret'>> {
409409
try {
410-
return await this.callV3(CreateAccessTokenCommand, args, false)
410+
return await this.call(CreateAccessTokenCommand, args, false)
411411
} catch (e) {
412412
if ((e as Error).name === 'ServiceQuotaExceededException') {
413413
throw new ToolkitError('Access token limit exceeded', { cause: e as Error })
@@ -417,7 +417,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
417417
}
418418

419419
public async getSubscription(request: GetSubscriptionRequest): Promise<CodeCatalyst.GetSubscriptionResponse> {
420-
return this.callV3(GetSubscriptionCommand, request, false)
420+
return this.call(GetSubscriptionCommand, request, false)
421421
}
422422

423423
/**
@@ -438,7 +438,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
438438
return CodeCatalystClientInternal.identityCache.get(accessToken)!
439439
}
440440

441-
const r: VerifySessionCommandOutput = await this.callV3(VerifySessionCommand, {}, false)
441+
const r: VerifySessionCommandOutput = await this.call(VerifySessionCommand, {}, false)
442442
assertHasProps(r, 'identity')
443443

444444
CodeCatalystClientInternal.identityCache.set(accessToken, r.identity)
@@ -455,20 +455,20 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
455455
}
456456

457457
private async getUserDetails(args: GetUserDetailsRequest) {
458-
const resp: GetUserDetailsCommandOutput = await this.callV3(GetUserDetailsCommand, args, false)
458+
const resp: GetUserDetailsCommandOutput = await this.call(GetUserDetailsCommand, args, false)
459459
assertHasProps(resp, 'userId', 'userName', 'displayName', 'primaryEmail')
460460

461461
return { ...resp, version: resp.version } as const
462462
}
463463

464464
public async getSpace(request: GetSpaceRequest): Promise<CodeCatalystOrg> {
465-
const resp: GetSpaceCommandOutput = await this.callV3(GetSpaceCommand, request, false)
465+
const resp: GetSpaceCommandOutput = await this.call(GetSpaceCommand, request, false)
466466
assertHasProps(resp, 'name', 'regionName')
467467
return { ...resp, type: 'org' }
468468
}
469469

470470
public async getProject(request: RequiredProps<GetProjectRequest, 'spaceName'>): Promise<CodeCatalystProject> {
471-
const resp: GetProjectCommandOutput = await this.callV3(GetProjectCommand, request, false)
471+
const resp: GetProjectCommandOutput = await this.call(GetProjectCommand, request, false)
472472
assertHasProps(resp, 'name')
473473
return { ...resp, type: 'project', org: { name: request.spaceName } }
474474
}
@@ -478,7 +478,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
478478
*/
479479
public listSpaces(request: ListSpacesRequest = {}): AsyncCollection<CodeCatalystOrg[]> {
480480
const requester: (request: ListSpacesRequest) => Promise<ListSpacesResponse> = async (request) =>
481-
this.callV3(ListSpacesCommand, request, true, { items: [] })
481+
this.call(ListSpacesCommand, request, true, { items: [] })
482482
const collection = pageableToCollection(requester, request, 'nextToken', 'items').filter(isDefined)
483483
// ts doesn't recognize nested assertion, so we add cast.This is safe because we assert it in the same line.
484484
return collection.map((summaries) => summaries.filter(hasName).map(toOrg))
@@ -507,7 +507,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
507507
]
508508

509509
const requester: (request: ListProjectsRequest) => Promise<ListProjectsResponse> = (request) =>
510-
this.callV3(ListProjectsCommand, request, true, { items: [] })
510+
this.call(ListProjectsCommand, request, true, { items: [] })
511511

512512
const collection = pageableToCollection(requester, request, 'nextToken', 'items')
513513
return collection.filter(isDefined).map((summaries) => summaries.filter(hasName).map(toProject))
@@ -527,7 +527,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
527527
public listDevEnvironments(proj: CodeCatalystProject): AsyncCollection<DevEnvironment[]> {
528528
const initRequest = { spaceName: proj.org.name, projectName: proj.name }
529529
const requester: (request: ListDevEnvironmentsRequest) => Promise<ListDevEnvironmentsResponse> = (request) =>
530-
this.callV3(ListDevEnvironmentsCommand, request, true, { items: [] })
530+
this.call(ListDevEnvironmentsCommand, request, true, { items: [] })
531531
const collection = pageableToCollection(requester, initRequest, 'nextToken' as never, 'items').filter(isDefined)
532532
// ts unable to recognize nested assertion here, so we need to cast. This is safe because we assert it in the same line.
533533
return collection.map((envs) => {
@@ -547,7 +547,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
547547
thirdParty: boolean = true
548548
): AsyncCollection<CodeCatalystRepo[]> {
549549
const requester = async (r: typeof request) => {
550-
const allRepositories: Promise<ListSourceRepositoriesResponse> = this.callV3(
550+
const allRepositories: Promise<ListSourceRepositoriesResponse> = this.call(
551551
ListSourceRepositoriesCommand,
552552
r,
553553
true,
@@ -591,7 +591,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
591591
>
592592
): AsyncCollection<CodeCatalystBranch[]> {
593593
const requester = async (r: typeof request) =>
594-
this.callV3(ListSourceRepositoryBranchesCommand, r, true, { items: [] })
594+
this.call(ListSourceRepositoryBranchesCommand, r, true, { items: [] })
595595
const collection = pageableToCollection(requester, request, 'nextToken' as never, 'items')
596596

597597
return collection
@@ -640,14 +640,14 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
640640
public async createSourceBranch(
641641
args: CreateSourceRepositoryBranchRequest
642642
): Promise<CreateSourceRepositoryBranchResponse> {
643-
return this.callV3(CreateSourceRepositoryBranchCommand, args, false)
643+
return this.call(CreateSourceRepositoryBranchCommand, args, false)
644644
}
645645

646646
/**
647647
* Gets the git source host URL for the given CodeCatalyst or third-party repo.
648648
*/
649649
public async getRepoCloneUrl(args: GetSourceRepositoryCloneUrlsRequest): Promise<string> {
650-
const r: GetSourceRepositoryCloneUrlsResponse = await this.callV3(
650+
const r: GetSourceRepositoryCloneUrlsResponse = await this.call(
651651
GetSourceRepositoryCloneUrlsCommand,
652652
args,
653653
false
@@ -662,11 +662,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
662662
args: RequiredProps<CreateDevEnvironmentRequest, 'projectName' | 'spaceName'>
663663
): Promise<DevEnvironment> {
664664
const request = fixAliasInRequest(args)
665-
const response: CreateDevEnvironmentCommandOutput = await this.callV3(
666-
CreateDevEnvironmentCommand,
667-
request,
668-
false
669-
)
665+
const response: CreateDevEnvironmentCommandOutput = await this.call(CreateDevEnvironmentCommand, request, false)
670666
assertHasProps(response, 'id')
671667

672668
return this.getDevEnvironment({
@@ -677,29 +673,29 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
677673
}
678674

679675
public async startDevEnvironment(args: StartDevEnvironmentRequest): Promise<StartDevEnvironmentResponse> {
680-
return this.callV3(StartDevEnvironmentCommand, args, false)
676+
return this.call(StartDevEnvironmentCommand, args, false)
681677
}
682678

683679
public async createProject(
684680
args: RequiredProps<CreateProjectRequest, 'displayName' | 'spaceName'>
685681
): Promise<CodeCatalystProject> {
686-
await this.callV3(CreateProjectCommand, args, false)
682+
await this.call(CreateProjectCommand, args, false)
687683

688684
return { ...args, name: args.displayName, type: 'project', org: { name: args.spaceName } }
689685
}
690686

691687
public async startDevEnvironmentSession(
692688
args: StartDevEnvironmentSessionRequest
693689
): Promise<StartDevEnvironmentSessionResponse & { sessionId: string }> {
694-
const r: StartDevEnvironmentSessionResponse = await this.callV3(StartDevEnvironmentSessionCommand, args, false)
690+
const r: StartDevEnvironmentSessionResponse = await this.call(StartDevEnvironmentSessionCommand, args, false)
695691
if (!r.sessionId) {
696692
throw new TypeError('got falsy dev environment "sessionId"')
697693
}
698694
return { ...r, sessionId: r.sessionId }
699695
}
700696

701697
public async stopDevEnvironment(args: StopDevEnvironmentRequest): Promise<StopDevEnvironmentResponse> {
702-
return this.callV3(StopDevEnvironmentCommand, args, false)
698+
return this.call(StopDevEnvironmentCommand, args, false)
703699
}
704700

705701
public async getDevEnvironment(
@@ -709,7 +705,7 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
709705
delete (a as any).ides
710706
delete (a as any).repositories
711707

712-
const r: GetDevEnvironmentResponse = await this.callV3(GetDevEnvironmentCommand, a, false)
708+
const r: GetDevEnvironmentResponse = await this.call(GetDevEnvironmentCommand, a, false)
713709
const summary = { ...args, ...r }
714710
if (!isValidEnvSummary(summary)) {
715711
throw new ToolkitError(`GetDevEnvironment failed due to response missing required properties`)
@@ -719,12 +715,12 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
719715
}
720716

721717
public async deleteDevEnvironment(args: DeleteDevEnvironmentRequest): Promise<DeleteDevEnvironmentResponse> {
722-
return this.callV3(DeleteDevEnvironmentCommand, args, false)
718+
return this.call(DeleteDevEnvironmentCommand, args, false)
723719
}
724720

725721
public updateDevEnvironment(args: UpdateDevEnvironmentRequest): Promise<UpdateDevEnvironmentResponse> {
726722
const request = fixAliasInRequest(args)
727-
return this.callV3(UpdateDevEnvironmentCommand, request, false)
723+
return this.call(UpdateDevEnvironmentCommand, request, false)
728724
}
729725

730726
/**

0 commit comments

Comments
 (0)