@gitpod/gitpod-protocol 0.1.5-wth-argo.0 → 0.1.5-wth-test.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/data/builtin-theia-plugins.json +9 -9
  2. package/data/gitpod-schema.json +8 -22
  3. package/lib/accounting-protocol.d.ts +155 -0
  4. package/lib/accounting-protocol.d.ts.map +1 -0
  5. package/lib/accounting-protocol.js +109 -0
  6. package/lib/accounting-protocol.js.map +1 -0
  7. package/lib/admin-protocol.d.ts +20 -4
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +15 -0
  10. package/lib/admin-protocol.js.map +1 -1
  11. package/lib/analytics.d.ts +45 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/{util/without.js → analytics.js} +4 -2
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/context-url.d.ts +18 -0
  16. package/lib/context-url.d.ts.map +1 -0
  17. package/lib/context-url.js +49 -0
  18. package/lib/context-url.js.map +1 -0
  19. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +3 -1
  20. package/lib/context-url.spec.d.ts.map +1 -0
  21. package/lib/context-url.spec.js +73 -0
  22. package/lib/context-url.spec.js.map +1 -0
  23. package/lib/email-protocol.d.ts +1 -2
  24. package/lib/email-protocol.d.ts.map +1 -1
  25. package/lib/email-protocol.js +4 -4
  26. package/lib/email-protocol.js.map +1 -1
  27. package/lib/encryption/container-module.js +5 -4
  28. package/lib/encryption/container-module.js.map +1 -1
  29. package/lib/encryption/encryption-engine.js +19 -20
  30. package/lib/encryption/encryption-engine.js.map +1 -1
  31. package/lib/encryption/encryption-engine.spec.js +29 -36
  32. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  33. package/lib/encryption/encryption-service.js +29 -43
  34. package/lib/encryption/encryption-service.js.map +1 -1
  35. package/lib/encryption/key-provider.js +25 -30
  36. package/lib/encryption/key-provider.js.map +1 -1
  37. package/lib/env.d.ts +1 -2
  38. package/lib/env.d.ts.map +1 -1
  39. package/lib/env.js +20 -21
  40. package/lib/env.js.map +1 -1
  41. package/lib/gitpod-file-parser.js +25 -41
  42. package/lib/gitpod-file-parser.js.map +1 -1
  43. package/lib/gitpod-file-parser.spec.js +116 -116
  44. package/lib/gitpod-file-parser.spec.js.map +1 -1
  45. package/lib/gitpod-service.d.ts +132 -18
  46. package/lib/gitpod-service.d.ts.map +1 -1
  47. package/lib/gitpod-service.js +168 -256
  48. package/lib/gitpod-service.js.map +1 -1
  49. package/lib/headless-workspace-log.d.ts +8 -11
  50. package/lib/headless-workspace-log.d.ts.map +1 -1
  51. package/lib/headless-workspace-log.js +4 -7
  52. package/lib/headless-workspace-log.js.map +1 -1
  53. package/lib/ide-frontend-service.d.ts +4 -0
  54. package/lib/ide-frontend-service.d.ts.map +1 -1
  55. package/lib/index.d.ts +4 -0
  56. package/lib/index.d.ts.map +1 -1
  57. package/lib/index.js +5 -1
  58. package/lib/index.js.map +1 -1
  59. package/lib/messaging/browser/connection.d.ts +5 -3
  60. package/lib/messaging/browser/connection.d.ts.map +1 -1
  61. package/lib/messaging/browser/connection.js +183 -33
  62. package/lib/messaging/browser/connection.js.map +1 -1
  63. package/lib/messaging/browser/window-connection.js +35 -55
  64. package/lib/messaging/browser/window-connection.js.map +1 -1
  65. package/lib/messaging/client-call-metrics.d.ts +35 -0
  66. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  67. package/lib/messaging/client-call-metrics.js +83 -0
  68. package/lib/messaging/client-call-metrics.js.map +1 -0
  69. package/lib/messaging/connection-error-handler.js +11 -23
  70. package/lib/messaging/connection-error-handler.js.map +1 -1
  71. package/lib/messaging/error.d.ts +3 -1
  72. package/lib/messaging/error.d.ts.map +1 -1
  73. package/lib/messaging/error.js +6 -2
  74. package/lib/messaging/error.js.map +1 -1
  75. package/lib/messaging/handler.d.ts +10 -0
  76. package/lib/messaging/handler.d.ts.map +1 -1
  77. package/lib/messaging/node/connection.js +22 -22
  78. package/lib/messaging/node/connection.js.map +1 -1
  79. package/lib/messaging/proxy-factory.d.ts +2 -0
  80. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  81. package/lib/messaging/proxy-factory.js +74 -159
  82. package/lib/messaging/proxy-factory.js.map +1 -1
  83. package/lib/payment-protocol.d.ts +18 -0
  84. package/lib/payment-protocol.d.ts.map +1 -0
  85. package/lib/payment-protocol.js +13 -0
  86. package/lib/payment-protocol.js.map +1 -0
  87. package/lib/permission.d.ts +2 -1
  88. package/lib/permission.d.ts.map +1 -1
  89. package/lib/permission.js +14 -13
  90. package/lib/permission.js.map +1 -1
  91. package/lib/plans.d.ts +210 -0
  92. package/lib/plans.d.ts.map +1 -0
  93. package/lib/plans.js +570 -0
  94. package/lib/plans.js.map +1 -0
  95. package/lib/protocol.d.ts +94 -16
  96. package/lib/protocol.d.ts.map +1 -1
  97. package/lib/protocol.js +104 -130
  98. package/lib/protocol.js.map +1 -1
  99. package/lib/snapshot-url.d.ts +14 -0
  100. package/lib/snapshot-url.d.ts.map +1 -0
  101. package/lib/snapshot-url.js +26 -0
  102. package/lib/snapshot-url.js.map +1 -0
  103. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  104. package/lib/snapshot-url.spec.d.ts.map +1 -0
  105. package/lib/snapshot-url.spec.js +41 -0
  106. package/lib/snapshot-url.spec.js.map +1 -0
  107. package/lib/team-subscription-protocol.d.ts +73 -0
  108. package/lib/team-subscription-protocol.d.ts.map +1 -0
  109. package/lib/team-subscription-protocol.js +63 -0
  110. package/lib/team-subscription-protocol.js.map +1 -0
  111. package/lib/teams-projects-protocol.d.ts +103 -0
  112. package/lib/teams-projects-protocol.d.ts.map +1 -0
  113. package/lib/teams-projects-protocol.js +23 -0
  114. package/lib/teams-projects-protocol.js.map +1 -0
  115. package/lib/util/analytics.d.ts +8 -0
  116. package/lib/util/analytics.d.ts.map +1 -0
  117. package/lib/util/analytics.js +79 -0
  118. package/lib/util/analytics.js.map +1 -0
  119. package/lib/util/async-iterator.js +55 -133
  120. package/lib/util/async-iterator.js.map +1 -1
  121. package/lib/util/cancelable.js +17 -59
  122. package/lib/util/cancelable.js.map +1 -1
  123. package/lib/util/date-time.js +8 -8
  124. package/lib/util/date-time.js.map +1 -1
  125. package/lib/util/deferred.js +10 -12
  126. package/lib/util/deferred.js.map +1 -1
  127. package/lib/util/disposable.js +26 -39
  128. package/lib/util/disposable.js.map +1 -1
  129. package/lib/util/event.js +58 -74
  130. package/lib/util/event.js.map +1 -1
  131. package/lib/util/garbage-collected-cache.js +22 -46
  132. package/lib/util/garbage-collected-cache.js.map +1 -1
  133. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  134. package/lib/util/generate-workspace-id.js +13 -67
  135. package/lib/util/generate-workspace-id.js.map +1 -1
  136. package/lib/util/generate-workspace-id.spec.js +34 -79
  137. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  138. package/lib/util/gitpod-cookie.d.ts +20 -0
  139. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  140. package/lib/util/gitpod-cookie.js +44 -0
  141. package/lib/util/gitpod-cookie.js.map +1 -0
  142. package/lib/util/gitpod-host-url.d.ts +1 -1
  143. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  144. package/lib/util/gitpod-host-url.js +98 -98
  145. package/lib/util/gitpod-host-url.js.map +1 -1
  146. package/lib/util/gitpod-host-url.spec.d.ts +7 -1
  147. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  148. package/lib/util/gitpod-host-url.spec.js +103 -31
  149. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  150. package/lib/util/grpc.d.ts +15 -0
  151. package/lib/util/grpc.d.ts.map +1 -0
  152. package/lib/util/grpc.js +18 -0
  153. package/lib/util/grpc.js.map +1 -0
  154. package/lib/util/logging.d.ts +49 -33
  155. package/lib/util/logging.d.ts.map +1 -1
  156. package/lib/util/logging.js +107 -110
  157. package/lib/util/logging.js.map +1 -1
  158. package/lib/util/make-link.js +2 -2
  159. package/lib/util/make-link.js.map +1 -1
  160. package/lib/util/parse-workspace-id.d.ts +10 -0
  161. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  162. package/lib/util/parse-workspace-id.js +32 -7
  163. package/lib/util/parse-workspace-id.js.map +1 -1
  164. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  165. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  166. package/lib/util/parse-workspace-id.spec.js +123 -84
  167. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  168. package/lib/util/queue.js +16 -55
  169. package/lib/util/queue.js.map +1 -1
  170. package/lib/util/queue.spec.js +144 -288
  171. package/lib/util/queue.spec.js.map +1 -1
  172. package/lib/util/repeater.js +35 -88
  173. package/lib/util/repeater.js.map +1 -1
  174. package/lib/util/safe-promise.js +9 -12
  175. package/lib/util/safe-promise.js.map +1 -1
  176. package/lib/util/semaphore.js +15 -46
  177. package/lib/util/semaphore.js.map +1 -1
  178. package/lib/util/skip-if.js +6 -6
  179. package/lib/util/skip-if.js.map +1 -1
  180. package/lib/util/timeutil.js +28 -16
  181. package/lib/util/timeutil.js.map +1 -1
  182. package/lib/util/timeutil.spec.js +21 -24
  183. package/lib/util/timeutil.spec.js.map +1 -1
  184. package/lib/util/tracing.js +43 -47
  185. package/lib/util/tracing.js.map +1 -1
  186. package/lib/util/workspace-port-authentication.js +3 -2
  187. package/lib/util/workspace-port-authentication.js.map +1 -1
  188. package/lib/workspace-cluster.d.ts +74 -0
  189. package/lib/workspace-cluster.d.ts.map +1 -0
  190. package/lib/workspace-cluster.js +16 -0
  191. package/lib/workspace-cluster.js.map +1 -0
  192. package/lib/workspace-instance.d.ts +7 -2
  193. package/lib/workspace-instance.d.ts.map +1 -1
  194. package/lib/wsready.d.ts +1 -1
  195. package/lib/wsready.js +2 -2
  196. package/package.json +28 -16
  197. package/pkg-yarn.lock +17 -9
  198. package/src/accounting-protocol.ts +229 -0
  199. package/src/admin-protocol.ts +39 -5
  200. package/src/analytics.ts +54 -0
  201. package/src/context-url.spec.ts +39 -0
  202. package/src/context-url.ts +51 -0
  203. package/src/email-protocol.ts +2 -3
  204. package/src/env.ts +10 -10
  205. package/src/gitpod-service.ts +198 -33
  206. package/src/headless-workspace-log.ts +7 -11
  207. package/src/ide-frontend-service.ts +4 -0
  208. package/src/index.ts +5 -1
  209. package/src/messaging/browser/connection.ts +195 -14
  210. package/src/messaging/client-call-metrics.ts +97 -0
  211. package/src/messaging/error.ts +8 -2
  212. package/src/messaging/handler.ts +12 -0
  213. package/src/messaging/node/connection.ts +2 -2
  214. package/src/messaging/proxy-factory.ts +14 -6
  215. package/src/payment-protocol.ts +20 -0
  216. package/src/permission.ts +2 -1
  217. package/src/plans.ts +632 -0
  218. package/src/protocol.ts +153 -43
  219. package/src/snapshot-url.spec.ts +25 -0
  220. package/src/snapshot-url.ts +27 -0
  221. package/src/team-subscription-protocol.ts +113 -0
  222. package/src/teams-projects-protocol.ts +132 -0
  223. package/src/util/analytics.ts +87 -0
  224. package/src/util/deferred.ts +1 -1
  225. package/src/util/garbage-collected-cache.ts +2 -2
  226. package/src/util/generate-workspace-id.spec.ts +3 -3
  227. package/src/util/generate-workspace-id.ts +2 -0
  228. package/src/util/gitpod-cookie.ts +39 -0
  229. package/src/util/gitpod-host-url.spec.ts +25 -1
  230. package/src/util/gitpod-host-url.ts +23 -10
  231. package/src/util/grpc.ts +15 -0
  232. package/src/util/logging.ts +102 -38
  233. package/src/util/parse-workspace-id.spec.ts +21 -1
  234. package/src/util/parse-workspace-id.ts +32 -6
  235. package/src/util/queue.spec.ts +1 -1
  236. package/src/util/semaphore.ts +2 -2
  237. package/src/util/skip-if.ts +1 -1
  238. package/src/util/timeutil.ts +4 -4
  239. package/src/workspace-cluster.ts +96 -0
  240. package/src/workspace-instance.ts +31 -13
  241. package/src/wsready.ts +2 -2
  242. package/lib/util/context-url.d.ts +0 -13
  243. package/lib/util/context-url.d.ts.map +0 -1
  244. package/lib/util/context-url.js +0 -26
  245. package/lib/util/context-url.js.map +0 -1
  246. package/lib/util/context-url.spec.d.ts.map +0 -1
  247. package/lib/util/context-url.spec.js +0 -52
  248. package/lib/util/context-url.spec.js.map +0 -1
  249. package/lib/util/without.d.ts +0 -7
  250. package/lib/util/without.d.ts.map +0 -1
  251. package/lib/util/without.js.map +0 -1
  252. package/src/util/context-url.spec.ts +0 -25
  253. package/src/util/context-url.ts +0 -23
package/src/env.ts CHANGED
@@ -13,18 +13,18 @@ const legacyStagenameTranslation: { [key: string]: KubeStage } = {
13
13
  "dev": "dev"
14
14
  }
15
15
 
16
+ export function translateLegacyStagename(kubeStage: string): KubeStage {
17
+ const stage = legacyStagenameTranslation[kubeStage];
18
+ if (!stage) {
19
+ throw new Error(`Invalid KUBE_STAGE: ${kubeStage}`);
20
+ }
21
+
22
+ return stage;
23
+ }
24
+
16
25
  @injectable()
17
26
  export abstract class AbstractComponentEnv {
18
- readonly kubeStage: KubeStage = getEnvVarParsed('KUBE_STAGE', (kubeStage) => {
19
- const stage = legacyStagenameTranslation[kubeStage];
20
- if (!stage) {
21
- throw new Error(`Environment variable invalid: KUBE_STAGE=${kubeStage}`);
22
- }
23
-
24
- return stage;
25
- });
26
- readonly kubeNamespace: string = getEnvVar('KUBE_NAMESPACE');
27
- readonly version: string = getEnvVar('VERSION');
27
+ readonly kubeStage: KubeStage = getEnvVarParsed('KUBE_STAGE', translateLegacyStagename);
28
28
 
29
29
  readonly installationLongname: string = getEnvVar("GITPOD_INSTALLATION_LONGNAME")
30
30
  readonly installationShortname: string = getEnvVar("GITPOD_INSTALLATION_SHORTNAME")
@@ -5,14 +5,19 @@
5
5
  */
6
6
 
7
7
  import {
8
- User, WorkspaceInfo, WorkspaceCreationResult, UserMessage, WorkspaceInstanceUser,
8
+ User, WorkspaceInfo, WorkspaceCreationResult, WorkspaceInstanceUser,
9
9
  WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode,
10
10
  Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
- ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType, GitpodToken, AuthProviderEntry
11
+ ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
+ GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes
12
13
  } from './protocol';
14
+ import {
15
+ Team, TeamMemberInfo,
16
+ TeamMembershipInvite, Project, TeamMemberRole, PrebuildWithStatus, StartPrebuildResult
17
+ } from './teams-projects-protocol';
13
18
  import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
14
19
  import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
15
- import { HeadlessLogEvent } from './headless-workspace-log';
20
+ import { HeadlessLogUrls } from './headless-workspace-log';
16
21
  import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
17
22
  import { AdminServer } from './admin-protocol';
18
23
  import { GitpodHostUrl } from './util/gitpod-host-url';
@@ -20,11 +25,18 @@ import { WebSocketConnectionProvider } from './messaging/browser/connection';
20
25
  import { PermissionName } from './permission';
21
26
  import { LicenseService } from './license-protocol';
22
27
  import { Emitter } from './util/event';
28
+ import { AccountStatement, CreditAlert } from './accounting-protocol';
29
+ import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
30
+ import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
31
+ import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from './analytics';
23
32
 
24
33
  export interface GitpodClient {
25
34
  onInstanceUpdate(instance: WorkspaceInstance): void;
26
35
  onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
27
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void;
36
+
37
+ onPrebuildUpdate(update: PrebuildWithStatus): void;
38
+
39
+ onCreditAlert(creditAlert: CreditAlert): void;
28
40
 
29
41
  //#region propagating reconnection to iframe
30
42
  notifyDidOpenConnection(): void;
@@ -40,11 +52,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
40
52
  updateLoggedInUser(user: Partial<User>): Promise<User>;
41
53
  getAuthProviders(): Promise<AuthProviderInfo[]>;
42
54
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
43
- updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<void>;
55
+ updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
44
56
  deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
45
57
  getBranding(): Promise<Branding>;
46
58
  getConfiguration(): Promise<Configuration>;
47
59
  getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
60
+ getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
48
61
  /**
49
62
  * @deprecated
50
63
  */
@@ -76,8 +89,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
76
89
  updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
77
90
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
78
91
  watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
79
- watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
80
92
  isPrebuildDone(pwsid: string): Promise<boolean>;
93
+ getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
81
94
 
82
95
  // Workspace timeout
83
96
  setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
@@ -91,19 +104,41 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
91
104
  openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
92
105
  closePort(workspaceId: string, port: number): Promise<void>;
93
106
 
94
- // User messages
95
- getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
96
- updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
97
-
98
107
  // User storage
99
108
  getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
100
109
  updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
101
110
 
102
- // user env vars
111
+ // User env vars
103
112
  getEnvVars(): Promise<UserEnvVarValue[]>;
113
+ getAllEnvVars(): Promise<UserEnvVarValue[]>;
104
114
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
105
115
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
106
116
 
117
+ // Teams
118
+ getTeams(): Promise<Team[]>;
119
+ getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
120
+ createTeam(name: string): Promise<Team>;
121
+ joinTeam(inviteId: string): Promise<Team>;
122
+ setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
123
+ removeTeamMember(teamId: string, userId: string): Promise<void>;
124
+ getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
125
+ resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
126
+ deleteTeam(teamId: string, userId: string): Promise<void>;
127
+
128
+ // Projects
129
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
130
+ createProject(params: CreateProjectParams): Promise<Project>;
131
+ deleteProject(projectId: string): Promise<void>;
132
+ getTeamProjects(teamId: string): Promise<Project[]>;
133
+ getUserProjects(): Promise<Project[]>;
134
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
135
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
136
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
137
+ cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
138
+ setProjectConfiguration(projectId: string, configString: string): Promise<void>;
139
+ fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
140
+ guessProjectConfiguration(projectId: string): Promise<string | undefined>;
141
+
107
142
  // content service
108
143
  getContentBlobUploadUrl(name: string): Promise<string>
109
144
  getContentBlobDownloadUrl(name: string): Promise<string>
@@ -118,10 +153,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
118
153
  registerGithubApp(installationId: string): Promise<void>;
119
154
 
120
155
  /**
121
- * Stores a new snapshot for the given workspace and bucketId
156
+ * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
122
157
  * @return the snapshot id
123
158
  */
124
159
  takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
160
+ /**
161
+ *
162
+ * @param snapshotId
163
+ */
164
+ waitForSnapshot(snapshotId: string): Promise<void>;
125
165
 
126
166
  /**
127
167
  * Returns the list of snapshots that exist for a workspace.
@@ -146,6 +186,95 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
146
186
  resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
147
187
  installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
148
188
  uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
189
+
190
+ guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
191
+
192
+ /**
193
+ * gitpod.io concerns
194
+ */
195
+ isStudent(): Promise<boolean>;
196
+ /**
197
+ *
198
+ */
199
+ getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
200
+ getRemainingUsageHours(): Promise<number>;
201
+
202
+ /**
203
+ *
204
+ */
205
+ getChargebeeSiteId(): Promise<string>;
206
+ createPortalSession(): Promise<{}>;
207
+ checkout(planId: string, planQuantity?: number): Promise<{}>;
208
+ getAvailableCoupons(): Promise<PlanCoupon[]>;
209
+ getAppliedCoupons(): Promise<PlanCoupon[]>;
210
+
211
+ getShowPaymentUI(): Promise<boolean>;
212
+ isChargebeeCustomer(): Promise<boolean>;
213
+
214
+ subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
215
+ subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
216
+ subscriptionCancel(subscriptionId: string): Promise<void>;
217
+ subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
218
+
219
+ tsGet(): Promise<TeamSubscription[]>;
220
+ tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
221
+ tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
222
+ tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
223
+ tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string | undefined): Promise<void>
224
+ tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
225
+ tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
226
+ tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
227
+
228
+ getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
229
+
230
+ /**
231
+ * Analytics
232
+ */
233
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
234
+ trackLocation(event: RemotePageMessage): Promise<void>;
235
+ identifyUser(event: RemoteIdentifyMessage): Promise<void>;
236
+ }
237
+
238
+ export interface CreateProjectParams {
239
+ name: string;
240
+ slug?: string;
241
+ account: string;
242
+ provider: string;
243
+ cloneUrl: string;
244
+ teamId?: string;
245
+ userId?: string;
246
+ appInstallationId: string;
247
+ }
248
+ export interface FindPrebuildsParams {
249
+ projectId: string;
250
+ branch?: string;
251
+ latest?: boolean;
252
+ prebuildId?: string;
253
+ // default: 30
254
+ limit?: number;
255
+ }
256
+ export interface GetProviderRepositoriesParams {
257
+ provider: string;
258
+ hints?: { installationId: string } | object;
259
+ }
260
+ export interface ProviderRepository {
261
+ name: string;
262
+ path?: string;
263
+ account: string;
264
+ accountAvatarUrl: string;
265
+ cloneUrl: string;
266
+ updatedAt: string;
267
+ installationId?: number;
268
+ installationUpdatedAt?: string;
269
+
270
+ inUse?: boolean;
271
+ }
272
+
273
+ export interface ClientHeaderFields {
274
+ ip?: string;
275
+ userAgent?: string;
276
+ dnt?: string;
277
+ clientRegion?: string;
149
278
  }
150
279
 
151
280
  export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
@@ -158,6 +287,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
158
287
  methods.setClient = methods.setClient || (() => { });
159
288
  methods.dispose = methods.dispose || (() => { });
160
289
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
290
+ // @ts-ignore
161
291
  get: (target: S, property: keyof S) => {
162
292
  const result = target[property];
163
293
  if (!result) {
@@ -190,6 +320,8 @@ export namespace GitpodServer {
190
320
  limit?: number;
191
321
  searchString?: string;
192
322
  pinnedOnly?: boolean;
323
+ projectId?: string | string[];
324
+ includeWithoutProject?: boolean;
193
325
  }
194
326
  export interface GetAccountStatementOptions {
195
327
  date?: string;
@@ -197,6 +329,7 @@ export namespace GitpodServer {
197
329
  export interface CreateWorkspaceOptions {
198
330
  contextUrl: string;
199
331
  mode?: CreateWorkspaceMode;
332
+ forceDefaultConfig?: boolean;
200
333
  }
201
334
  export interface StartWorkspaceOptions {
202
335
  forceDefaultImage: boolean;
@@ -204,13 +337,8 @@ export namespace GitpodServer {
204
337
  export interface TakeSnapshotOptions {
205
338
  workspaceId: string;
206
339
  layoutData?: string;
207
- }
208
- export interface GetUserMessagesOptions {
209
- readonly releaseNotes?: boolean;
210
- readonly workspaceInstanceId: string;
211
- }
212
- export interface UpdateUserMessagesOptions {
213
- readonly messageIds: string[];
340
+ /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
341
+ dontWait?: boolean;
214
342
  }
215
343
  export interface GetUserStorageResourceOptions {
216
344
  readonly uri: string;
@@ -272,11 +400,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
272
400
  }
273
401
  }
274
402
 
275
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
403
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
276
404
  for (const client of this.clients) {
277
- if (client.onWorkspaceImageBuildLogs) {
405
+ if (client.onPrebuildUpdate) {
278
406
  try {
279
- client.onWorkspaceImageBuildLogs(info, content);
407
+ client.onPrebuildUpdate(update);
280
408
  } catch (error) {
281
409
  console.error(error)
282
410
  }
@@ -284,11 +412,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
284
412
  }
285
413
  }
286
414
 
287
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
415
+ onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
288
416
  for (const client of this.clients) {
289
- if (client.onHeadlessWorkspaceLogs) {
417
+ if (client.onWorkspaceImageBuildLogs) {
290
418
  try {
291
- client.onHeadlessWorkspaceLogs(evt);
419
+ client.onWorkspaceImageBuildLogs(info, content);
292
420
  } catch (error) {
293
421
  console.error(error)
294
422
  }
@@ -320,6 +448,18 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
320
448
  }
321
449
  }
322
450
 
451
+ onCreditAlert(creditAlert: CreditAlert): void {
452
+ for (const client of this.clients) {
453
+ if (client.onCreditAlert) {
454
+ try {
455
+ client.onCreditAlert(creditAlert);
456
+ } catch (error) {
457
+ console.error(error)
458
+ }
459
+ }
460
+ }
461
+ }
462
+
323
463
  }
324
464
 
325
465
  export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
@@ -340,7 +480,7 @@ export class WorkspaceInstanceUpdateListener {
340
480
  private readonly onDidChangeEmitter = new Emitter<void>();
341
481
  readonly onDidChange = this.onDidChangeEmitter.event;
342
482
 
343
- private source: 'sync' | 'update' = 'sync';
483
+ private source: 'sync' | 'update' = 'sync';
344
484
 
345
485
  get info(): WorkspaceInfo {
346
486
  return this._info;
@@ -432,11 +572,15 @@ export class WorkspaceInstanceUpdateListener {
432
572
 
433
573
  }
434
574
 
575
+ export interface GitpodServiceOptions {
576
+ onReconnect?: () => (void | Promise<void>)
577
+ }
578
+
435
579
  export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
436
580
 
437
581
  private readonly compositeClient = new GitpodCompositeClient<Client>();
438
582
 
439
- constructor(public readonly server: JsonRpcProxy<Server>) {
583
+ constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
440
584
  server.setClient(this.compositeClient);
441
585
  server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
442
586
  server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
@@ -456,13 +600,34 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
456
600
  this.instanceListeners.set(workspaceId, listener);
457
601
  return listener;
458
602
  }
603
+
604
+ async reconnect(): Promise<void> {
605
+ if (this.options?.onReconnect) {
606
+ await this.options.onReconnect();
607
+ }
608
+ }
459
609
  }
460
610
 
461
- export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string) {
462
- const url = new GitpodHostUrl(serverUrl)
463
- .asWebsocket()
464
- .withApi({ pathname: GitpodServerPath });
611
+ export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
612
+ const toWsUrl = (serverUrl: string) => {
613
+ return new GitpodHostUrl(serverUrl)
614
+ .asWebsocket()
615
+ .withApi({ pathname: GitpodServerPath })
616
+ .toString();
617
+ };
618
+ let url: string | Promise<string>;
619
+ if (typeof serverUrl === "string") {
620
+ url = toWsUrl(serverUrl);
621
+ } else {
622
+ url = serverUrl.then(url => toWsUrl(url));
623
+ }
624
+
465
625
  const connectionProvider = new WebSocketConnectionProvider();
466
- const gitpodServer = connectionProvider.createProxy<S>(url.toString());
467
- return new GitpodServiceImpl<C, S>(gitpodServer);
626
+ let onReconnect = () => { };
627
+ const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
628
+ onListening: socket => {
629
+ onReconnect = () => socket.reconnect();
630
+ }
631
+ });
632
+ return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
468
633
  }
@@ -22,21 +22,17 @@ export namespace HeadlessWorkspaceEventType {
22
22
  }
23
23
  }
24
24
 
25
- export interface HeadlessLogEvent {
25
+ export interface HeadlessWorkspaceEvent {
26
26
  workspaceID: string;
27
27
  text: string;
28
28
  type: HeadlessWorkspaceEventType;
29
29
  }
30
30
 
31
- export enum TheiaHeadlessLogType {
32
- TaskLogLabel = "workspaceTaskOutput",
33
- TaskFailedLabel = "workspaceTaskFailed",
34
- TaskSuccessfulLabel = "workspaceTaskDone"
31
+ export interface HeadlessLogUrls {
32
+ // A map of id to URL
33
+ streams: { [streamID: string]: string };
35
34
  }
36
35
 
37
- export interface TheiaHeadlessLogMessage {
38
- type: TheiaHeadlessLogType;
39
- data?: string;
40
- error?: string;
41
- snapshotURL?: string;
42
- }
36
+ /** cmp. @const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX */
37
+ export const HEADLESS_LOG_STREAM_STATUS_CODE = "X-LogStream-StatusCode";
38
+ export const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX = /X-LogStream-StatusCode: ([0-9]{3})/;
@@ -11,6 +11,10 @@ export type IDEFrontendState = 'init' | 'ready' | 'terminated';
11
11
 
12
12
  export interface IDEFrontendService {
13
13
  readonly state: IDEFrontendState;
14
+ /**
15
+ * A cause of the ide frontend application failure when state is terminated.
16
+ */
17
+ readonly failureCause?: Error;
14
18
  readonly onDidChange: Event<void>;
15
19
  /**
16
20
  * Starts the ide frontend application.
package/src/index.ts CHANGED
@@ -13,4 +13,8 @@ export * from './license-protocol';
13
13
  export * from './workspace-instance';
14
14
  export * from './permission';
15
15
  export * from './admin-protocol';
16
- export * from './email-protocol';
16
+ export * from './email-protocol';
17
+ export * from './headless-workspace-log';
18
+ export * from './context-url';
19
+ export * from './teams-projects-protocol';
20
+ export * from './snapshot-url';