@@ -10,11 +10,8 @@ import { CallOptions, Code, ConnectError, PromiseClient, createPromiseClient } f
1010import  {  createConnectTransport  }  from  "@connectrpc/connect-web" ; 
1111import  {  Disposable  }  from  "@gitpod/gitpod-protocol" ; 
1212import  {  PublicAPIConverter  }  from  "@gitpod/public-api-common/lib/public-api-converter" ; 
13- import  {  Project  as  ProtocolProject  }  from  "@gitpod/gitpod-protocol/lib/teams-projects-protocol" ; 
1413import  {  HelloService  }  from  "@gitpod/public-api/lib/gitpod/experimental/v1/dummy_connect" ; 
1514import  {  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" ; 
1815import  {  TokensService  }  from  "@gitpod/public-api/lib/gitpod/experimental/v1/tokens_connect" ; 
1916import  {  OrganizationService  }  from  "@gitpod/public-api/lib/gitpod/v1/organization_connect" ; 
2017import  {  WorkspaceService  }  from  "@gitpod/public-api/lib/gitpod/v1/workspace_connect" ; 
@@ -52,10 +49,6 @@ export const converter = new PublicAPIConverter();
5249
5350export  const  helloService  =  createServiceClient ( HelloService ) ; 
5451export  const  personalAccessTokensService  =  createPromiseClient ( TokensService ,  transport ) ; 
55- /** 
56-  * @deprecated  use configurationClient instead 
57-  */ 
58- export  const  projectsService  =  createPromiseClient ( ProjectsService ,  transport ) ; 
5952
6053export  const  oidcService  =  createPromiseClient ( OIDCService ,  transport ) ; 
6154
@@ -68,7 +61,7 @@ export const organizationClient = createServiceClient(OrganizationService, {
6861    featureFlagSuffix : "organization" , 
6962} ) ; 
7063
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 
7265export  const  configurationClient  =  createServiceClient ( ConfigurationService ) ; 
7366export  const  prebuildClient  =  createServiceClient ( PrebuildService ,  { 
7467    client : new  JsonRpcPrebuildClient ( ) , 
@@ -110,56 +103,6 @@ export const installationClient = createServiceClient(InstallationService, {
110103    featureFlagSuffix : "installation" , 
111104} ) ; 
112105
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- 
163106let  user : {  id : string ;  email ?: string  }  |  undefined ; 
164107export  function  updateUserForExperiments ( newUser ?: {  id : string ;  email ?: string  } )  { 
165108    user  =  newUser ; 
@@ -176,10 +119,14 @@ function createServiceClient<T extends ServiceType>(
176119        get ( grpcClient ,  prop )  { 
177120            const  experimentsClient  =  getExperimentsClient ( ) ; 
178121            // TODO(ak) remove after migration 
179-             async  function  resolveClient ( ) : Promise < PromiseClient < T > >  { 
122+             async  function  resolveClient ( preferJsonRpc ?:  boolean ) : Promise < PromiseClient < T > >  { 
180123                if  ( ! jsonRpcOptions )  { 
181124                    return  grpcClient ; 
182125                } 
126+                 if  ( preferJsonRpc )  { 
127+                     console . debug ( "using preferred jsonrpc client for" ,  type . typeName ,  prop ) ; 
128+                     return  jsonRpcOptions . client ; 
129+                 } 
183130                const  featureFlags  =  [ `dashboard_public_api_${ jsonRpcOptions . featureFlagSuffix }  _enabled` ] ; 
184131                const  resolvedFlags  =  await  Promise . all ( 
185132                    featureFlags . map ( ( ff )  => 
@@ -241,7 +188,8 @@ function createServiceClient<T extends ServiceType>(
241188                } 
242189                return  ( async  function *  ( )  { 
243190                    try  { 
244-                         const  client  =  await  resolveClient ( ) ; 
191+                         // for server streaming, we prefer jsonRPC 
192+                         const  client  =  await  resolveClient ( true ) ; 
245193                        const  generator  =  Reflect . apply ( client [ prop  as  any ] ,  client ,  args )  as  AsyncGenerator < any > ; 
246194                        for  await  ( const  item  of  generator )  { 
247195                            yield  item ; 
0 commit comments