@@ -10,11 +10,8 @@ import { CallOptions, Code, ConnectError, PromiseClient, createPromiseClient } f
10
10
import { createConnectTransport } from "@connectrpc/connect-web" ;
11
11
import { Disposable } from "@gitpod/gitpod-protocol" ;
12
12
import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter" ;
13
- import { Project as ProtocolProject } from "@gitpod/gitpod-protocol/lib/teams-projects-protocol" ;
14
13
import { HelloService } from "@gitpod/public-api/lib/gitpod/experimental/v1/dummy_connect" ;
15
14
import { OIDCService } from "@gitpod/public-api/lib/gitpod/experimental/v1/oidc_connect" ;
16
- import { ProjectsService } from "@gitpod/public-api/lib/gitpod/experimental/v1/projects_connect" ;
17
- import { Project } from "@gitpod/public-api/lib/gitpod/experimental/v1/projects_pb" ;
18
15
import { TokensService } from "@gitpod/public-api/lib/gitpod/experimental/v1/tokens_connect" ;
19
16
import { OrganizationService } from "@gitpod/public-api/lib/gitpod/v1/organization_connect" ;
20
17
import { WorkspaceService } from "@gitpod/public-api/lib/gitpod/v1/workspace_connect" ;
@@ -52,10 +49,6 @@ export const converter = new PublicAPIConverter();
52
49
53
50
export const helloService = createServiceClient ( HelloService ) ;
54
51
export const personalAccessTokensService = createPromiseClient ( TokensService , transport ) ;
55
- /**
56
- * @deprecated use configurationClient instead
57
- */
58
- export const projectsService = createPromiseClient ( ProjectsService , transport ) ;
59
52
60
53
export const oidcService = createPromiseClient ( OIDCService , transport ) ;
61
54
@@ -68,7 +61,7 @@ export const organizationClient = createServiceClient(OrganizationService, {
68
61
featureFlagSuffix : "organization" ,
69
62
} ) ;
70
63
71
- // No jsonrcp client for the configuration service as it's only used in new UI of the dashboard
64
+ // No jsonrpc client for the configuration service as it's only used in new UI of the dashboard
72
65
export const configurationClient = createServiceClient ( ConfigurationService ) ;
73
66
export const prebuildClient = createServiceClient ( PrebuildService , {
74
67
client : new JsonRpcPrebuildClient ( ) ,
@@ -110,56 +103,6 @@ export const installationClient = createServiceClient(InstallationService, {
110
103
featureFlagSuffix : "installation" ,
111
104
} ) ;
112
105
113
- export async function listAllProjects ( opts : { orgId : string } ) : Promise < ProtocolProject [ ] > {
114
- let pagination = {
115
- page : 1 ,
116
- pageSize : 100 ,
117
- } ;
118
-
119
- const response = await projectsService . listProjects ( {
120
- teamId : opts . orgId ,
121
- pagination,
122
- } ) ;
123
- const results = response . projects ;
124
-
125
- while ( results . length < response . totalResults ) {
126
- pagination = {
127
- pageSize : 100 ,
128
- page : 1 + pagination . page ,
129
- } ;
130
- const response = await projectsService . listProjects ( {
131
- teamId : opts . orgId ,
132
- pagination,
133
- } ) ;
134
- results . push ( ...response . projects ) ;
135
- }
136
-
137
- return results . map ( projectToProtocol ) ;
138
- }
139
-
140
- export function projectToProtocol ( project : Project ) : ProtocolProject {
141
- return {
142
- id : project . id ,
143
- name : project . name ,
144
- cloneUrl : project . cloneUrl ,
145
- creationTime : project . creationTime ?. toDate ( ) . toISOString ( ) || "" ,
146
- teamId : project . teamId ,
147
- appInstallationId : "undefined" ,
148
- settings : {
149
- workspaceClasses : {
150
- regular : project . settings ?. workspace ?. workspaceClass ?. regular || "" ,
151
- } ,
152
- prebuilds : {
153
- enable : project . settings ?. prebuild ?. enablePrebuilds ,
154
- branchStrategy : project . settings ?. prebuild ?. branchStrategy as any ,
155
- branchMatchingPattern : project . settings ?. prebuild ?. branchMatchingPattern ,
156
- prebuildInterval : project . settings ?. prebuild ?. prebuildInterval ,
157
- workspaceClass : project . settings ?. prebuild ?. workspaceClass ,
158
- } ,
159
- } ,
160
- } ;
161
- }
162
-
163
106
let user : { id : string ; email ?: string } | undefined ;
164
107
export function updateUserForExperiments ( newUser ?: { id : string ; email ?: string } ) {
165
108
user = newUser ;
@@ -176,10 +119,13 @@ function createServiceClient<T extends ServiceType>(
176
119
get ( grpcClient , prop ) {
177
120
const experimentsClient = getExperimentsClient ( ) ;
178
121
// TODO(ak) remove after migration
179
- async function resolveClient ( ) : Promise < PromiseClient < T > > {
122
+ async function resolveClient ( preferJsonRpc ?: boolean ) : Promise < PromiseClient < T > > {
180
123
if ( ! jsonRpcOptions ) {
181
124
return grpcClient ;
182
125
}
126
+ if ( preferJsonRpc ) {
127
+ return jsonRpcOptions . client ;
128
+ }
183
129
const featureFlags = [ `dashboard_public_api_${ jsonRpcOptions . featureFlagSuffix } _enabled` ] ;
184
130
const resolvedFlags = await Promise . all (
185
131
featureFlags . map ( ( ff ) =>
@@ -241,7 +187,8 @@ function createServiceClient<T extends ServiceType>(
241
187
}
242
188
return ( async function * ( ) {
243
189
try {
244
- const client = await resolveClient ( ) ;
190
+ // for server streaming, we prefer jsonRPC
191
+ const client = await resolveClient ( true ) ;
245
192
const generator = Reflect . apply ( client [ prop as any ] , client , args ) as AsyncGenerator < any > ;
246
193
for await ( const item of generator ) {
247
194
yield item ;
0 commit comments