@@ -16,7 +16,7 @@ import { ServiceConfigurationOptions } from 'aws-sdk/lib/service'
16
16
import { CancellationError , Timeout , waitTimeout , waitUntil } from '../utilities/timeoutUtils'
17
17
import { isUserCancelledError } from '../../shared/errors'
18
18
import { showMessageWithCancel } from '../utilities/messages'
19
- import { assertHasProps , ClassToInterfaceType , isNonNullable , RequiredProps } from '../utilities/tsUtils'
19
+ import { assertHasProps , ClassToInterfaceType , hasProps , isNonNullable , RequiredProps } from '../utilities/tsUtils'
20
20
import { AsyncCollection , toCollection } from '../utilities/asyncCollection'
21
21
import { joinAll , pageableToCollection } from '../utilities/collectionUtils'
22
22
import { CodeCatalyst } from 'aws-sdk'
@@ -33,6 +33,10 @@ import {
33
33
CreateAccessTokenCommand ,
34
34
CreateAccessTokenRequest ,
35
35
CreateAccessTokenResponse ,
36
+ DevEnvironmentSummary ,
37
+ GetDevEnvironmentCommand ,
38
+ GetDevEnvironmentRequest ,
39
+ GetDevEnvironmentResponse ,
36
40
GetProjectCommand ,
37
41
GetProjectCommandOutput ,
38
42
GetProjectRequest ,
@@ -44,6 +48,17 @@ import {
44
48
GetUserDetailsCommand ,
45
49
GetUserDetailsCommandOutput ,
46
50
GetUserDetailsRequest ,
51
+ ListDevEnvironmentsCommand ,
52
+ ListDevEnvironmentSessionsResponse ,
53
+ ListDevEnvironmentsRequest ,
54
+ ListDevEnvironmentsResponse ,
55
+ ListProjectsCommand ,
56
+ ListProjectsRequest ,
57
+ ListProjectsResponse ,
58
+ ListSpacesCommand ,
59
+ ListSpacesRequest ,
60
+ ListSpacesResponse ,
61
+ SpaceSummary ,
47
62
} from '@aws-sdk/client-codecatalyst'
48
63
import { truncateProps } from '../utilities/textUtilities'
49
64
import { SsoConnection } from '../../auth/connection'
@@ -76,7 +91,7 @@ export function getCodeCatalystConfig(): CodeCatalystConfig {
76
91
}
77
92
}
78
93
79
- export interface DevEnvironment extends CodeCatalyst . DevEnvironmentSummary {
94
+ export interface DevEnvironment extends DevEnvironmentSummary {
80
95
readonly type : 'devEnvironment'
81
96
readonly id : string
82
97
readonly org : Pick < CodeCatalystOrg , 'name' >
@@ -87,7 +102,7 @@ export interface DevEnvironment extends CodeCatalyst.DevEnvironmentSummary {
87
102
// eslint-disable-next-line @typescript-eslint/no-empty-interface
88
103
export interface CodeCatalystDevEnvSession extends CodeCatalyst . StartDevEnvironmentResponse { }
89
104
90
- export interface CodeCatalystOrg extends CodeCatalyst . SpaceSummary {
105
+ export interface CodeCatalystOrg extends SpaceSummary {
91
106
readonly type : 'org'
92
107
readonly name : string
93
108
}
@@ -120,7 +135,11 @@ export type CodeCatalystResource =
120
135
| CodeCatalystBranch
121
136
| DevEnvironment
122
137
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' > {
124
143
return {
125
144
type : 'devEnvironment' ,
126
145
org : { name : spaceName } ,
@@ -503,18 +522,23 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
503
522
/**
504
523
* Gets a list of all spaces (orgs) for the current CodeCatalyst user.
505
524
*/
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
+ )
512
534
}
513
535
514
536
/**
515
537
* Gets a list of all projects for the given CodeCatalyst user.
516
538
*/
517
- public listProjects ( request : CodeCatalyst . ListProjectsRequest ) : AsyncCollection < CodeCatalystProject [ ] > {
539
+ public listProjects (
540
+ request : RequiredProps < ListProjectsRequest , 'spaceName' >
541
+ ) : AsyncCollection < CodeCatalystProject [ ] > {
518
542
// Only get projects the user is a member of.
519
543
request . filters = [
520
544
...( request . filters ?? [ ] ) ,
@@ -524,17 +548,21 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
524
548
} ,
525
549
]
526
550
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 : [ ] } )
530
553
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 ) => ( {
534
562
type : 'project' ,
535
563
org : { name : request . spaceName } ,
536
564
...s ,
537
- } ) ) ?? [ ]
565
+ } ) )
538
566
)
539
567
}
540
568
@@ -543,15 +571,15 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
543
571
*/
544
572
public listDevEnvironments ( proj : CodeCatalystProject ) : AsyncCollection < DevEnvironment [ ] > {
545
573
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
+ )
553
579
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
+ )
555
583
}
556
584
557
585
/**
@@ -700,13 +728,18 @@ class CodeCatalystClientInternal extends ClientWrapper<CodeCatalystSDKClient> {
700
728
return this . call ( this . sdkClient . stopDevEnvironment ( args ) , false )
701
729
}
702
730
703
- public async getDevEnvironment ( args : CodeCatalyst . GetDevEnvironmentRequest ) : Promise < DevEnvironment > {
731
+ public async getDevEnvironment (
732
+ args : RequiredProps < GetDevEnvironmentRequest , 'spaceName' | 'projectName' >
733
+ ) : Promise < RequiredProps < DevEnvironment , 'status' > > {
704
734
const a = { ...args }
705
735
delete ( a as any ) . ides
706
736
delete ( a as any ) . repositories
707
- const r = await this . call ( this . sdkClient . getDevEnvironment ( a ) , false )
708
737
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 )
710
743
}
711
744
712
745
public async deleteDevEnvironment (
0 commit comments