@@ -16,7 +16,7 @@ import { ServiceConfigurationOptions } from 'aws-sdk/lib/service'
1616import { CancellationError , Timeout , waitTimeout , waitUntil } from '../utilities/timeoutUtils'
1717import { isUserCancelledError } from '../../shared/errors'
1818import { showMessageWithCancel } from '../utilities/messages'
19- import { assertHasProps , ClassToInterfaceType , isNonNullable , RequiredProps } from '../utilities/tsUtils'
19+ import { assertHasProps , ClassToInterfaceType , hasProps , isNonNullable , RequiredProps } from '../utilities/tsUtils'
2020import { AsyncCollection , toCollection } from '../utilities/asyncCollection'
2121import { joinAll , pageableToCollection } from '../utilities/collectionUtils'
2222import { CodeCatalyst } from 'aws-sdk'
@@ -33,6 +33,10 @@ import {
3333 CreateAccessTokenCommand ,
3434 CreateAccessTokenRequest ,
3535 CreateAccessTokenResponse ,
36+ DevEnvironmentSummary ,
37+ GetDevEnvironmentCommand ,
38+ GetDevEnvironmentRequest ,
39+ GetDevEnvironmentResponse ,
3640 GetProjectCommand ,
3741 GetProjectCommandOutput ,
3842 GetProjectRequest ,
@@ -44,6 +48,17 @@ import {
4448 GetUserDetailsCommand ,
4549 GetUserDetailsCommandOutput ,
4650 GetUserDetailsRequest ,
51+ ListDevEnvironmentsCommand ,
52+ ListDevEnvironmentSessionsResponse ,
53+ ListDevEnvironmentsRequest ,
54+ ListDevEnvironmentsResponse ,
55+ ListProjectsCommand ,
56+ ListProjectsRequest ,
57+ ListProjectsResponse ,
58+ ListSpacesCommand ,
59+ ListSpacesRequest ,
60+ ListSpacesResponse ,
61+ SpaceSummary ,
4762} from '@aws-sdk/client-codecatalyst'
4863import { truncateProps } from '../utilities/textUtilities'
4964import { SsoConnection } from '../../auth/connection'
@@ -76,7 +91,7 @@ export function getCodeCatalystConfig(): CodeCatalystConfig {
7691 }
7792}
7893
79- export interface DevEnvironment extends CodeCatalyst . DevEnvironmentSummary {
94+ export interface DevEnvironment extends DevEnvironmentSummary {
8095 readonly type : 'devEnvironment'
8196 readonly id : string
8297 readonly org : Pick < CodeCatalystOrg , 'name' >
@@ -87,7 +102,7 @@ export interface DevEnvironment extends CodeCatalyst.DevEnvironmentSummary {
87102// eslint-disable-next-line @typescript-eslint/no-empty-interface
88103export interface CodeCatalystDevEnvSession extends CodeCatalyst . StartDevEnvironmentResponse { }
89104
90- export interface CodeCatalystOrg extends CodeCatalyst . SpaceSummary {
105+ export interface CodeCatalystOrg extends SpaceSummary {
91106 readonly type : 'org'
92107 readonly name : string
93108}
@@ -120,7 +135,11 @@ export type CodeCatalystResource =
120135 | CodeCatalystBranch
121136 | DevEnvironment
122137
123- function toDevEnv ( spaceName : string , projectName : string , summary : CodeCatalyst . DevEnvironmentSummary ) : DevEnvironment {
138+ function toDevEnv (
139+ spaceName : string ,
140+ projectName : string ,
141+ summary : RequiredProps < DevEnvironmentSummary , 'id' | 'status' >
142+ ) : RequiredProps < DevEnvironment , 'status' > {
124143 return {
125144 type : 'devEnvironment' ,
126145 org : { name : spaceName } ,
@@ -503,18 +522,23 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
503522 /**
504523 * Gets a list of all spaces (orgs) for the current CodeCatalyst user.
505524 */
506- public listSpaces ( request : CodeCatalyst . ListSpacesRequest = { } ) : AsyncCollection < CodeCatalystOrg [ ] > {
507- const requester = async ( request : CodeCatalyst . ListSpacesRequest ) =>
508- this . call ( this . sdkClient . listSpaces ( request ) , true , { items : [ ] } )
509- const collection = pageableToCollection ( requester , request , 'nextToken' , 'items' )
510-
511- return collection . map ( ( summaries ) => summaries ?. map ( ( s ) => ( { type : 'org' , ...s } ) ) ?? [ ] )
525+ public listSpaces ( request : ListSpacesRequest = { } ) : AsyncCollection < CodeCatalystOrg [ ] > {
526+ const requester : ( request : ListSpacesRequest ) => Promise < ListSpacesResponse > = async ( request ) =>
527+ this . callV3 ( ListSpacesCommand , request , true , { items : [ ] } )
528+ const collection = pageableToCollection ( requester , request , 'nextToken' , 'items' ) . filter (
529+ ( summaries ) => summaries !== undefined
530+ )
531+ return collection . map ( ( summaries ) =>
532+ summaries . filter ( ( s ) => hasProps ( s , 'name' ) ) . map ( ( s ) => ( { type : 'org' , ...s } ) )
533+ )
512534 }
513535
514536 /**
515537 * Gets a list of all projects for the given CodeCatalyst user.
516538 */
517- public listProjects ( request : CodeCatalyst . ListProjectsRequest ) : AsyncCollection < CodeCatalystProject [ ] > {
539+ public listProjects (
540+ request : RequiredProps < ListProjectsRequest , 'spaceName' >
541+ ) : AsyncCollection < CodeCatalystProject [ ] > {
518542 // Only get projects the user is a member of.
519543 request . filters = [
520544 ...( request . filters ?? [ ] ) ,
@@ -524,17 +548,21 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
524548 } ,
525549 ]
526550
527- const requester = async ( request : CodeCatalyst . ListProjectsRequest ) =>
528- this . call ( this . sdkClient . listProjects ( request ) , true , { items : [ ] } )
529- const collection = pageableToCollection ( requester , request , 'nextToken' , 'items' )
551+ const requester : ( request : ListProjectsRequest ) => Promise < ListProjectsResponse > = ( request ) =>
552+ this . callV3 ( ListProjectsCommand , request , true , { items : [ ] } )
530553
531- return collection . map (
532- ( summaries ) =>
533- summaries ?. map ( ( s ) => ( {
554+ const collection = pageableToCollection ( requester , request , 'nextToken' , 'items' ) . filter (
555+ ( summaries ) => summaries !== undefined
556+ )
557+
558+ return collection . map ( ( summaries ) =>
559+ summaries
560+ . filter ( ( s ) => hasProps ( s , 'name' ) )
561+ . map ( ( s ) => ( {
534562 type : 'project' ,
535563 org : { name : request . spaceName } ,
536564 ...s ,
537- } ) ) ?? [ ]
565+ } ) )
538566 )
539567 }
540568
@@ -543,15 +571,15 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
543571 */
544572 public listDevEnvironments ( proj : CodeCatalystProject ) : AsyncCollection < DevEnvironment [ ] > {
545573 const initRequest = { spaceName : proj . org . name , projectName : proj . name }
546- const requester = async ( request : CodeCatalyst . ListDevEnvironmentsRequest ) =>
547- this . call ( this . sdkClient . listDevEnvironments ( request ) , true , {
548- // spaceName: proj.org.name,
549- // projectName: proj.name,
550- items : [ ] ,
551- } )
552- const collection = pageableToCollection ( requester , initRequest , 'nextToken' , 'items' )
574+ const requester : ( request : ListDevEnvironmentsRequest ) => Promise < ListDevEnvironmentsResponse > = ( request ) =>
575+ this . callV3 ( ListDevEnvironmentsCommand , request , true , { items : [ ] } )
576+ const collection = pageableToCollection ( requester , initRequest , 'nextToken' , 'items' ) . filter (
577+ ( c ) => c !== undefined
578+ )
553579
554- return collection . map ( ( envs ) => envs . map ( ( s ) => toDevEnv ( proj . org . name , proj . name , s ) ) )
580+ return collection . map ( ( envs ) =>
581+ envs . filter ( ( s ) => hasProps ( s , 'id' , 'status' ) ) . map ( ( s ) => toDevEnv ( proj . org . name , proj . name , s ) )
582+ )
555583 }
556584
557585 /**
@@ -700,13 +728,18 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
700728 return this . call ( this . sdkClient . stopDevEnvironment ( args ) , false )
701729 }
702730
703- public async getDevEnvironment ( args : CodeCatalyst . GetDevEnvironmentRequest ) : Promise < DevEnvironment > {
731+ public async getDevEnvironment (
732+ args : RequiredProps < GetDevEnvironmentRequest , 'spaceName' | 'projectName' >
733+ ) : Promise < RequiredProps < DevEnvironment , 'status' > > {
704734 const a = { ...args }
705735 delete ( a as any ) . ides
706736 delete ( a as any ) . repositories
707- const r = await this . call ( this . sdkClient . getDevEnvironment ( a ) , false )
708737
709- return toDevEnv ( args . spaceName , args . projectName , { ...args , ...r } )
738+ const r : GetDevEnvironmentResponse = await this . callV3 ( GetDevEnvironmentCommand , a , false )
739+ const summary = { ...args , ...r }
740+ assertHasProps ( summary , 'id' , 'status' )
741+
742+ return toDevEnv ( args . spaceName , args . projectName , summary )
710743 }
711744
712745 public async deleteDevEnvironment (
0 commit comments