@gitpod/gitpod-protocol 0.1.5-test.6 → 0.1.5-tweak-workspaceconfig-origin-docs-fork.0

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 (331) hide show
  1. package/data/builtin-theia-plugins.json +28 -18
  2. package/data/gitpod-schema.json +17 -17
  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 +22 -5
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +16 -1
  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/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/auth.d.ts +25 -0
  16. package/lib/auth.d.ts.map +1 -0
  17. package/lib/auth.js +16 -0
  18. package/lib/auth.js.map +1 -0
  19. package/lib/context-url.d.ts +18 -0
  20. package/lib/context-url.d.ts.map +1 -0
  21. package/lib/context-url.js +49 -0
  22. package/lib/context-url.js.map +1 -0
  23. package/lib/context-url.spec.d.ts +12 -0
  24. package/lib/context-url.spec.d.ts.map +1 -0
  25. package/lib/context-url.spec.js +73 -0
  26. package/lib/context-url.spec.js.map +1 -0
  27. package/lib/email-protocol.d.ts +2 -2
  28. package/lib/email-protocol.d.ts.map +1 -1
  29. package/lib/email-protocol.js +6 -5
  30. package/lib/email-protocol.js.map +1 -1
  31. package/lib/encryption/container-module.d.ts +1 -1
  32. package/lib/encryption/container-module.js +7 -5
  33. package/lib/encryption/container-module.js.map +1 -1
  34. package/lib/encryption/encryption-engine.d.ts +1 -1
  35. package/lib/encryption/encryption-engine.js +21 -21
  36. package/lib/encryption/encryption-engine.js.map +1 -1
  37. package/lib/encryption/encryption-engine.spec.d.ts +2 -2
  38. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  39. package/lib/encryption/encryption-engine.spec.js +31 -37
  40. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  41. package/lib/encryption/encryption-service.d.ts +1 -1
  42. package/lib/encryption/encryption-service.js +31 -44
  43. package/lib/encryption/encryption-service.js.map +1 -1
  44. package/lib/encryption/key-provider.d.ts +2 -2
  45. package/lib/encryption/key-provider.d.ts.map +1 -1
  46. package/lib/encryption/key-provider.js +27 -31
  47. package/lib/encryption/key-provider.js.map +1 -1
  48. package/lib/env.d.ts +2 -3
  49. package/lib/env.d.ts.map +1 -1
  50. package/lib/env.js +21 -21
  51. package/lib/env.js.map +1 -1
  52. package/lib/gitpod-file-parser.d.ts +1 -1
  53. package/lib/gitpod-file-parser.js +27 -42
  54. package/lib/gitpod-file-parser.js.map +1 -1
  55. package/lib/gitpod-file-parser.spec.d.ts +1 -1
  56. package/lib/gitpod-file-parser.spec.js +117 -117
  57. package/lib/gitpod-file-parser.spec.js.map +1 -1
  58. package/lib/gitpod-service.d.ts +186 -34
  59. package/lib/gitpod-service.d.ts.map +1 -1
  60. package/lib/gitpod-service.js +239 -116
  61. package/lib/gitpod-service.js.map +1 -1
  62. package/lib/headless-workspace-log.d.ts +9 -12
  63. package/lib/headless-workspace-log.d.ts.map +1 -1
  64. package/lib/headless-workspace-log.js +5 -7
  65. package/lib/headless-workspace-log.js.map +1 -1
  66. package/lib/ide-frontend-service.d.ts +26 -0
  67. package/lib/ide-frontend-service.d.ts.map +1 -0
  68. package/lib/ide-frontend-service.js +8 -0
  69. package/lib/ide-frontend-service.js.map +1 -0
  70. package/lib/ide-protocol.d.ts +81 -0
  71. package/lib/ide-protocol.d.ts.map +1 -0
  72. package/lib/{util/without.js → ide-protocol.js} +2 -2
  73. package/lib/ide-protocol.js.map +1 -0
  74. package/lib/index.d.ts +5 -1
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +25 -12
  77. package/lib/index.js.map +1 -1
  78. package/lib/license-protocol.d.ts +1 -1
  79. package/lib/license-protocol.js +2 -1
  80. package/lib/license-protocol.js.map +1 -1
  81. package/lib/messaging/browser/connection.d.ts +6 -4
  82. package/lib/messaging/browser/connection.d.ts.map +1 -1
  83. package/lib/messaging/browser/connection.js +188 -48
  84. package/lib/messaging/browser/connection.js.map +1 -1
  85. package/lib/messaging/browser/window-connection.d.ts +26 -0
  86. package/lib/messaging/browser/window-connection.d.ts.map +1 -0
  87. package/lib/messaging/browser/window-connection.js +68 -0
  88. package/lib/messaging/browser/window-connection.js.map +1 -0
  89. package/lib/messaging/client-call-metrics.d.ts +35 -0
  90. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  91. package/lib/messaging/client-call-metrics.js +83 -0
  92. package/lib/messaging/client-call-metrics.js.map +1 -0
  93. package/lib/messaging/connection-error-handler.js +12 -23
  94. package/lib/messaging/connection-error-handler.js.map +1 -1
  95. package/lib/messaging/error.d.ts +6 -2
  96. package/lib/messaging/error.d.ts.map +1 -1
  97. package/lib/messaging/error.js +13 -4
  98. package/lib/messaging/error.js.map +1 -1
  99. package/lib/messaging/handler.d.ts +10 -0
  100. package/lib/messaging/handler.d.ts.map +1 -1
  101. package/lib/messaging/handler.js +1 -0
  102. package/lib/messaging/handler.js.map +1 -1
  103. package/lib/messaging/node/connection.js +23 -22
  104. package/lib/messaging/node/connection.js.map +1 -1
  105. package/lib/messaging/proxy-factory.d.ts +2 -0
  106. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  107. package/lib/messaging/proxy-factory.js +75 -169
  108. package/lib/messaging/proxy-factory.js.map +1 -1
  109. package/lib/payment-protocol.d.ts +18 -0
  110. package/lib/payment-protocol.d.ts.map +1 -0
  111. package/lib/payment-protocol.js +13 -0
  112. package/lib/payment-protocol.js.map +1 -0
  113. package/lib/permission.d.ts +14 -12
  114. package/lib/permission.d.ts.map +1 -1
  115. package/lib/permission.js +21 -19
  116. package/lib/permission.js.map +1 -1
  117. package/lib/plans.d.ts +210 -0
  118. package/lib/plans.d.ts.map +1 -0
  119. package/lib/plans.js +570 -0
  120. package/lib/plans.js.map +1 -0
  121. package/lib/protocol.d.ts +123 -30
  122. package/lib/protocol.d.ts.map +1 -1
  123. package/lib/protocol.js +121 -117
  124. package/lib/protocol.js.map +1 -1
  125. package/lib/snapshot-url.d.ts +14 -0
  126. package/lib/snapshot-url.d.ts.map +1 -0
  127. package/lib/snapshot-url.js +26 -0
  128. package/lib/snapshot-url.js.map +1 -0
  129. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +3 -4
  130. package/lib/snapshot-url.spec.d.ts.map +1 -0
  131. package/lib/snapshot-url.spec.js +41 -0
  132. package/lib/snapshot-url.spec.js.map +1 -0
  133. package/lib/team-subscription-protocol.d.ts +73 -0
  134. package/lib/team-subscription-protocol.d.ts.map +1 -0
  135. package/lib/team-subscription-protocol.js +63 -0
  136. package/lib/team-subscription-protocol.js.map +1 -0
  137. package/lib/teams-projects-protocol.d.ts +103 -0
  138. package/lib/teams-projects-protocol.d.ts.map +1 -0
  139. package/lib/teams-projects-protocol.js +23 -0
  140. package/lib/teams-projects-protocol.js.map +1 -0
  141. package/lib/theia-plugins.d.ts +1 -1
  142. package/lib/theia-plugins.js +1 -1
  143. package/lib/typings/globals.d.ts +12 -0
  144. package/lib/typings/globals.d.ts.map +1 -0
  145. package/lib/typings/globals.js +7 -0
  146. package/lib/typings/globals.js.map +1 -0
  147. package/lib/util/analytics.d.ts +8 -0
  148. package/lib/util/analytics.d.ts.map +1 -0
  149. package/lib/util/analytics.js +79 -0
  150. package/lib/util/analytics.js.map +1 -0
  151. package/lib/util/async-iterator.d.ts +1 -1
  152. package/lib/util/async-iterator.js +57 -134
  153. package/lib/util/async-iterator.js.map +1 -1
  154. package/lib/util/cancelable.d.ts +1 -1
  155. package/lib/util/cancelable.js +19 -60
  156. package/lib/util/cancelable.js.map +1 -1
  157. package/lib/util/date-time.d.ts +1 -1
  158. package/lib/util/date-time.js +10 -9
  159. package/lib/util/date-time.js.map +1 -1
  160. package/lib/util/deep-partial.d.ts +1 -1
  161. package/lib/util/deep-partial.js +1 -1
  162. package/lib/util/deferred.d.ts +1 -1
  163. package/lib/util/deferred.js +12 -13
  164. package/lib/util/deferred.js.map +1 -1
  165. package/lib/util/disposable.d.ts +2 -2
  166. package/lib/util/disposable.d.ts.map +1 -1
  167. package/lib/util/disposable.js +27 -39
  168. package/lib/util/disposable.js.map +1 -1
  169. package/lib/util/event.d.ts +1 -1
  170. package/lib/util/event.d.ts.map +1 -1
  171. package/lib/util/event.js +59 -74
  172. package/lib/util/event.js.map +1 -1
  173. package/lib/util/garbage-collected-cache.d.ts +1 -1
  174. package/lib/util/garbage-collected-cache.js +24 -47
  175. package/lib/util/garbage-collected-cache.js.map +1 -1
  176. package/lib/util/generate-workspace-id.d.ts +4 -0
  177. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  178. package/lib/util/generate-workspace-id.js +470 -0
  179. package/lib/util/generate-workspace-id.js.map +1 -0
  180. package/lib/util/generate-workspace-id.spec.d.ts +7 -0
  181. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  182. package/lib/util/generate-workspace-id.spec.js +63 -0
  183. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  184. package/lib/util/gitpod-cookie.d.ts +20 -0
  185. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  186. package/lib/util/gitpod-cookie.js +44 -0
  187. package/lib/util/gitpod-cookie.js.map +1 -0
  188. package/lib/util/gitpod-host-url.d.ts +8 -3
  189. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  190. package/lib/util/gitpod-host-url.js +106 -76
  191. package/lib/util/gitpod-host-url.js.map +1 -1
  192. package/lib/util/gitpod-host-url.spec.d.ts +16 -0
  193. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
  194. package/lib/util/gitpod-host-url.spec.js +124 -0
  195. package/lib/util/gitpod-host-url.spec.js.map +1 -0
  196. package/lib/util/grpc.d.ts +15 -0
  197. package/lib/util/grpc.d.ts.map +1 -0
  198. package/lib/util/grpc.js +18 -0
  199. package/lib/util/grpc.js.map +1 -0
  200. package/lib/util/logging.d.ts +57 -34
  201. package/lib/util/logging.d.ts.map +1 -1
  202. package/lib/util/logging.js +119 -110
  203. package/lib/util/logging.js.map +1 -1
  204. package/lib/util/make-link.d.ts +1 -1
  205. package/lib/util/make-link.js +4 -3
  206. package/lib/util/make-link.js.map +1 -1
  207. package/lib/util/parse-workspace-id.d.ts +14 -4
  208. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  209. package/lib/util/parse-workspace-id.js +39 -8
  210. package/lib/util/parse-workspace-id.js.map +1 -1
  211. package/lib/util/parse-workspace-id.spec.d.ts +9 -1
  212. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  213. package/lib/util/parse-workspace-id.spec.js +129 -48
  214. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  215. package/lib/util/queue.d.ts +1 -1
  216. package/lib/util/queue.js +18 -56
  217. package/lib/util/queue.js.map +1 -1
  218. package/lib/util/queue.spec.d.ts +1 -1
  219. package/lib/util/queue.spec.js +145 -287
  220. package/lib/util/queue.spec.js.map +1 -1
  221. package/lib/util/repeater.d.ts +1 -1
  222. package/lib/util/repeater.js +37 -89
  223. package/lib/util/repeater.js.map +1 -1
  224. package/lib/util/safe-promise.d.ts +1 -1
  225. package/lib/util/safe-promise.js +11 -13
  226. package/lib/util/safe-promise.js.map +1 -1
  227. package/lib/util/semaphore.d.ts +1 -1
  228. package/lib/util/semaphore.js +17 -47
  229. package/lib/util/semaphore.js.map +1 -1
  230. package/lib/util/skip-if.d.ts +1 -1
  231. package/lib/util/skip-if.js +8 -7
  232. package/lib/util/skip-if.js.map +1 -1
  233. package/lib/util/timeutil.d.ts +1 -1
  234. package/lib/util/timeutil.d.ts.map +1 -1
  235. package/lib/util/timeutil.js +30 -17
  236. package/lib/util/timeutil.js.map +1 -1
  237. package/lib/util/timeutil.spec.d.ts +1 -1
  238. package/lib/util/timeutil.spec.js +23 -25
  239. package/lib/util/timeutil.spec.js.map +1 -1
  240. package/lib/util/tracing.d.ts +15 -2
  241. package/lib/util/tracing.d.ts.map +1 -1
  242. package/lib/util/tracing.js +86 -51
  243. package/lib/util/tracing.js.map +1 -1
  244. package/lib/util/workspace-port-authentication.d.ts +1 -1
  245. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  246. package/lib/util/workspace-port-authentication.js +5 -3
  247. package/lib/util/workspace-port-authentication.js.map +1 -1
  248. package/lib/workspace-cluster.d.ts +74 -0
  249. package/lib/workspace-cluster.d.ts.map +1 -0
  250. package/lib/workspace-cluster.js +16 -0
  251. package/lib/workspace-cluster.js.map +1 -0
  252. package/lib/workspace-instance.d.ts +10 -4
  253. package/lib/workspace-instance.d.ts.map +1 -1
  254. package/lib/workspace-instance.js +1 -1
  255. package/lib/wsready.d.ts +1 -1
  256. package/lib/wsready.js +3 -2
  257. package/lib/wsready.js.map +1 -1
  258. package/package.json +32 -16
  259. package/pkg-yarn.lock +18 -9
  260. package/src/accounting-protocol.ts +229 -0
  261. package/src/admin-protocol.ts +41 -6
  262. package/src/analytics.ts +54 -0
  263. package/src/auth.ts +27 -0
  264. package/src/context-url.spec.ts +39 -0
  265. package/src/context-url.ts +51 -0
  266. package/src/email-protocol.ts +3 -4
  267. package/src/encryption/container-module.ts +1 -1
  268. package/src/encryption/encryption-engine.spec.ts +1 -1
  269. package/src/encryption/encryption-engine.ts +1 -1
  270. package/src/encryption/encryption-service.ts +1 -1
  271. package/src/encryption/key-provider.ts +1 -1
  272. package/src/env.ts +11 -11
  273. package/src/gitpod-file-parser.spec.ts +1 -1
  274. package/src/gitpod-file-parser.ts +1 -1
  275. package/src/gitpod-service.ts +386 -52
  276. package/src/headless-workspace-log.ts +8 -12
  277. package/src/ide-frontend-service.ts +28 -0
  278. package/src/ide-protocol.ts +92 -0
  279. package/src/index.ts +6 -2
  280. package/src/license-protocol.ts +1 -1
  281. package/src/messaging/browser/connection.ts +201 -23
  282. package/src/messaging/browser/window-connection.ts +72 -0
  283. package/src/messaging/client-call-metrics.ts +97 -0
  284. package/src/messaging/error.ts +16 -4
  285. package/src/messaging/handler.ts +12 -0
  286. package/src/messaging/node/connection.ts +2 -2
  287. package/src/messaging/proxy-factory.ts +16 -14
  288. package/src/payment-protocol.ts +20 -0
  289. package/src/permission.ts +9 -8
  290. package/src/plans.ts +632 -0
  291. package/src/protocol.ts +204 -61
  292. package/src/snapshot-url.spec.ts +25 -0
  293. package/src/snapshot-url.ts +27 -0
  294. package/src/team-subscription-protocol.ts +113 -0
  295. package/src/teams-projects-protocol.ts +132 -0
  296. package/src/theia-plugins.ts +1 -1
  297. package/src/typings/globals.ts +12 -0
  298. package/src/util/analytics.ts +87 -0
  299. package/src/util/async-iterator.ts +1 -1
  300. package/src/util/cancelable.ts +1 -1
  301. package/src/util/date-time.ts +1 -1
  302. package/src/util/deep-partial.ts +1 -1
  303. package/src/util/deferred.ts +2 -2
  304. package/src/util/garbage-collected-cache.ts +3 -3
  305. package/src/util/generate-workspace-id.spec.ts +31 -0
  306. package/src/util/generate-workspace-id.ts +457 -0
  307. package/src/util/gitpod-cookie.ts +39 -0
  308. package/src/util/gitpod-host-url.spec.ts +49 -0
  309. package/src/util/gitpod-host-url.ts +58 -14
  310. package/src/util/grpc.ts +15 -0
  311. package/src/util/jaeger-client.d.ts +1 -1
  312. package/src/util/logging.ts +111 -39
  313. package/src/util/make-link.ts +1 -1
  314. package/src/util/parse-workspace-id.spec.ts +46 -5
  315. package/src/util/parse-workspace-id.ts +39 -8
  316. package/src/util/queue.spec.ts +2 -2
  317. package/src/util/queue.ts +1 -1
  318. package/src/util/repeater.ts +1 -1
  319. package/src/util/safe-promise.ts +1 -1
  320. package/src/util/semaphore.ts +3 -3
  321. package/src/util/skip-if.ts +2 -2
  322. package/src/util/timeutil.spec.ts +1 -1
  323. package/src/util/timeutil.ts +5 -5
  324. package/src/util/tracing.ts +66 -4
  325. package/src/util/workspace-port-authentication.ts +1 -1
  326. package/src/workspace-cluster.ts +96 -0
  327. package/src/workspace-instance.ts +38 -16
  328. package/src/wsready.ts +2 -2
  329. package/lib/util/without.d.ts +0 -7
  330. package/lib/util/without.d.ts.map +0 -1
  331. package/lib/util/without.js.map +0 -1
@@ -1,42 +1,67 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { User, WorkspaceInfo, WorkspaceCreationResult, UserMessage, WorkspaceInstanceUser,
7
+ import {
8
+ User, WorkspaceInfo, WorkspaceCreationResult, WorkspaceInstanceUser,
8
9
  WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode,
9
- Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams,
10
- ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType, GitpodToken, AuthProviderEntry } from './protocol';
10
+ Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
+ ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
+ GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes
13
+ } from './protocol';
14
+ import {
15
+ Team, TeamMemberInfo,
16
+ TeamMembershipInvite, Project, TeamMemberRole, PrebuildWithStatus, StartPrebuildResult
17
+ } from './teams-projects-protocol';
11
18
  import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
12
- import { injectable, inject } from 'inversify';
13
- import { Disposable } from 'vscode-jsonrpc';
14
- import { HeadlessLogEvent } from './headless-workspace-log';
15
- import { WorkspaceInstance, WorkspaceInstancePort } from './workspace-instance';
19
+ import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
20
+ import { HeadlessLogUrls } from './headless-workspace-log';
21
+ import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
16
22
  import { AdminServer } from './admin-protocol';
17
23
  import { GitpodHostUrl } from './util/gitpod-host-url';
18
24
  import { WebSocketConnectionProvider } from './messaging/browser/connection';
19
25
  import { PermissionName } from './permission';
20
26
  import { LicenseService } from './license-protocol';
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';
32
+ import { IDEServer } from './ide-protocol';
21
33
 
22
34
  export interface GitpodClient {
23
35
  onInstanceUpdate(instance: WorkspaceInstance): void;
24
36
  onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
25
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void;
37
+
38
+ onPrebuildUpdate(update: PrebuildWithStatus): void;
39
+
40
+ onCreditAlert(creditAlert: CreditAlert): void;
41
+
42
+ //#region propagating reconnection to iframe
43
+ notifyDidOpenConnection(): void;
44
+ notifyDidCloseConnection(): void;
45
+ //#endregion
26
46
  }
27
47
 
28
48
  export const GitpodServer = Symbol('GitpodServer');
29
- export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService {
49
+ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
30
50
  // User related API
31
51
  getLoggedInUser(): Promise<User>;
52
+ getTerms(): Promise<Terms>;
32
53
  updateLoggedInUser(user: Partial<User>): Promise<User>;
33
54
  getAuthProviders(): Promise<AuthProviderInfo[]>;
34
55
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
35
- updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<void>;
56
+ updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
36
57
  deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
37
58
  getBranding(): Promise<Branding>;
38
59
  getConfiguration(): Promise<Configuration>;
39
60
  getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
61
+ getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
62
+ /**
63
+ * @deprecated
64
+ */
40
65
  getPortAuthenticationToken(workspaceId: string): Promise<Token>;
41
66
  deleteAccount(): Promise<void>;
42
67
  getClientRegion(): Promise<string | undefined>;
@@ -44,7 +69,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
44
69
 
45
70
  // Query/retrieve workspaces
46
71
  getWorkspaces(options: GitpodServer.GetWorkspacesOptions): Promise<WorkspaceInfo[]>;
47
- getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
72
+ getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
48
73
  getWorkspaceUsers(workspaceId: string): Promise<WorkspaceInstanceUser[]>;
49
74
  getFeaturedRepositories(): Promise<WhitelistedRepository[]>;
50
75
  getWorkspace(id: string): Promise<WorkspaceInfo>;
@@ -56,46 +81,72 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
56
81
  * @return WorkspaceCreationResult
57
82
  */
58
83
  createWorkspace(options: GitpodServer.CreateWorkspaceOptions): Promise<WorkspaceCreationResult>;
59
- startWorkspace(id: string, options: {forceDefaultImage: boolean}): Promise<StartWorkspaceResult>;
84
+ startWorkspace(id: string, options: GitpodServer.StartWorkspaceOptions): Promise<StartWorkspaceResult>;
60
85
  stopWorkspace(id: string): Promise<void>;
61
86
  deleteWorkspace(id: string): Promise<void>;
62
87
  setWorkspaceDescription(id: string, desc: string): Promise<void>;
63
- controlAdmission(id: string, level: "owner" | "everyone"): Promise<void>;
88
+ controlAdmission(id: string, level: GitpodServer.AdmissionLevel): Promise<void>;
64
89
 
65
- updateWorkspaceUserPin(id: string, action: "pin" | "unpin" | "toggle"): Promise<void>;
90
+ updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
66
91
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
67
92
  watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
68
- watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
69
- isPrebuildAvailable(pwsid: string): Promise<boolean>;
70
-
93
+ isPrebuildDone(pwsid: string): Promise<boolean>;
94
+ getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
95
+
71
96
  // Workspace timeout
72
97
  setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
73
98
  getWorkspaceTimeout(workspaceId: string): Promise<GetWorkspaceTimeoutResult>;
74
99
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
75
100
 
76
- updateWorkspaceUserPin(id: string, action: "pin" | "unpin" | "toggle"): Promise<void>;
101
+ updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
77
102
 
78
103
  // Port management
79
104
  getOpenPorts(workspaceId: string): Promise<WorkspaceInstancePort[]>;
80
105
  openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
81
106
  closePort(workspaceId: string, port: number): Promise<void>;
82
107
 
83
- // User messages
84
- getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
85
- updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
86
-
87
108
  // User storage
88
109
  getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
89
110
  updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
90
111
 
91
- // user env vars
112
+ // User env vars
92
113
  getEnvVars(): Promise<UserEnvVarValue[]>;
114
+ getAllEnvVars(): Promise<UserEnvVarValue[]>;
93
115
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
94
116
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
95
117
 
118
+ // Teams
119
+ getTeams(): Promise<Team[]>;
120
+ getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
121
+ createTeam(name: string): Promise<Team>;
122
+ joinTeam(inviteId: string): Promise<Team>;
123
+ setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
124
+ removeTeamMember(teamId: string, userId: string): Promise<void>;
125
+ getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
126
+ resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
127
+ deleteTeam(teamId: string, userId: string): Promise<void>;
128
+
129
+ // Projects
130
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
131
+ createProject(params: CreateProjectParams): Promise<Project>;
132
+ deleteProject(projectId: string): Promise<void>;
133
+ getTeamProjects(teamId: string): Promise<Project[]>;
134
+ getUserProjects(): Promise<Project[]>;
135
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
136
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
137
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
138
+ cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
139
+ setProjectConfiguration(projectId: string, configString: string): Promise<void>;
140
+ fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
141
+ guessProjectConfiguration(projectId: string): Promise<string | undefined>;
142
+
143
+ // content service
144
+ getContentBlobUploadUrl(name: string): Promise<string>
145
+ getContentBlobDownloadUrl(name: string): Promise<string>
146
+
96
147
  // Gitpod token
97
148
  getGitpodTokens(): Promise<GitpodToken[]>;
98
- generateNewGitpodToken(options: { name?: string, type: GitpodTokenType, scopes?: [] }): Promise<string>;
149
+ generateNewGitpodToken(options: GitpodServer.GenerateNewGitpodTokenOptions): Promise<string>;
99
150
  deleteGitpodToken(tokenHash: string): Promise<void>;
100
151
 
101
152
  // misc
@@ -103,10 +154,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
103
154
  registerGithubApp(installationId: string): Promise<void>;
104
155
 
105
156
  /**
106
- * Stores a new snapshot for the given workspace and bucketId
157
+ * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
107
158
  * @return the snapshot id
108
159
  */
109
160
  takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
161
+ /**
162
+ *
163
+ * @param snapshotId
164
+ */
165
+ waitForSnapshot(snapshotId: string): Promise<void>;
110
166
 
111
167
  /**
112
168
  * Returns the list of snapshots that exist for a workspace.
@@ -131,18 +187,108 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
131
187
  resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
132
188
  installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
133
189
  uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
190
+
191
+ guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
192
+
193
+ /**
194
+ * gitpod.io concerns
195
+ */
196
+ isStudent(): Promise<boolean>;
197
+ /**
198
+ *
199
+ */
200
+ getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
201
+ getRemainingUsageHours(): Promise<number>;
202
+
203
+ /**
204
+ *
205
+ */
206
+ getChargebeeSiteId(): Promise<string>;
207
+ createPortalSession(): Promise<{}>;
208
+ checkout(planId: string, planQuantity?: number): Promise<{}>;
209
+ getAvailableCoupons(): Promise<PlanCoupon[]>;
210
+ getAppliedCoupons(): Promise<PlanCoupon[]>;
211
+
212
+ getShowPaymentUI(): Promise<boolean>;
213
+ isChargebeeCustomer(): Promise<boolean>;
214
+
215
+ subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
216
+ subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
217
+ subscriptionCancel(subscriptionId: string): Promise<void>;
218
+ subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
219
+
220
+ tsGet(): Promise<TeamSubscription[]>;
221
+ tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
222
+ tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
223
+ tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
224
+ tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string | undefined): Promise<void>
225
+ tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
226
+ tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
227
+ tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
228
+
229
+ getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
230
+
231
+ /**
232
+ * Analytics
233
+ */
234
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
235
+ trackLocation(event: RemotePageMessage): Promise<void>;
236
+ identifyUser(event: RemoteIdentifyMessage): Promise<void>;
237
+ }
238
+
239
+ export interface CreateProjectParams {
240
+ name: string;
241
+ slug?: string;
242
+ account: string;
243
+ provider: string;
244
+ cloneUrl: string;
245
+ teamId?: string;
246
+ userId?: string;
247
+ appInstallationId: string;
248
+ }
249
+ export interface FindPrebuildsParams {
250
+ projectId: string;
251
+ branch?: string;
252
+ latest?: boolean;
253
+ prebuildId?: string;
254
+ // default: 30
255
+ limit?: number;
256
+ }
257
+ export interface GetProviderRepositoriesParams {
258
+ provider: string;
259
+ hints?: { installationId: string } | object;
260
+ }
261
+ export interface ProviderRepository {
262
+ name: string;
263
+ path?: string;
264
+ account: string;
265
+ accountAvatarUrl: string;
266
+ cloneUrl: string;
267
+ updatedAt: string;
268
+ installationId?: number;
269
+ installationUpdatedAt?: string;
270
+
271
+ inUse?: boolean;
272
+ }
273
+
274
+ export interface ClientHeaderFields {
275
+ ip?: string;
276
+ userAgent?: string;
277
+ dnt?: string;
278
+ clientRegion?: string;
134
279
  }
135
280
 
136
281
  export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
137
282
 
138
- export const createServiceMock = function<C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): GitpodServiceImpl<C, S> {
283
+ export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): GitpodServiceImpl<C, S> {
139
284
  return new GitpodServiceImpl<C, S>(createServerMock(methods));
140
285
  }
141
286
 
142
- export const createServerMock = function<C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): JsonRpcProxy<S> {
143
- methods.setClient = methods.setClient || (() => {});
144
- methods.dispose = methods.dispose || (() => {});
287
+ export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): JsonRpcProxy<S> {
288
+ methods.setClient = methods.setClient || (() => { });
289
+ methods.dispose = methods.dispose || (() => { });
145
290
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
291
+ // @ts-ignore
146
292
  get: (target: S, property: keyof S) => {
147
293
  const result = target[property];
148
294
  if (!result) {
@@ -175,6 +321,8 @@ export namespace GitpodServer {
175
321
  limit?: number;
176
322
  searchString?: string;
177
323
  pinnedOnly?: boolean;
324
+ projectId?: string | string[];
325
+ includeWithoutProject?: boolean;
178
326
  }
179
327
  export interface GetAccountStatementOptions {
180
328
  date?: string;
@@ -182,17 +330,16 @@ export namespace GitpodServer {
182
330
  export interface CreateWorkspaceOptions {
183
331
  contextUrl: string;
184
332
  mode?: CreateWorkspaceMode;
333
+ forceDefaultConfig?: boolean;
334
+ }
335
+ export interface StartWorkspaceOptions {
336
+ forceDefaultImage: boolean;
185
337
  }
186
338
  export interface TakeSnapshotOptions {
187
339
  workspaceId: string;
188
340
  layoutData?: string;
189
- }
190
- export interface GetUserMessagesOptions {
191
- readonly releaseNotes?: boolean;
192
- readonly workspaceInstanceId: string;
193
- }
194
- export interface UpdateUserMessagesOptions {
195
- readonly messageIds: string[];
341
+ /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
342
+ dontWait?: boolean;
196
343
  }
197
344
  export interface GetUserStorageResourceOptions {
198
345
  readonly uri: string;
@@ -215,6 +362,13 @@ export namespace GitpodServer {
215
362
  export interface DeleteOwnAuthProviderParams {
216
363
  readonly id: string
217
364
  }
365
+ export type AdmissionLevel = "owner" | "everyone";
366
+ export type PinAction = "pin" | "unpin" | "toggle";
367
+ export interface GenerateNewGitpodTokenOptions {
368
+ name?: string
369
+ type: GitpodTokenType
370
+ scopes?: string[]
371
+ }
218
372
  }
219
373
 
220
374
  export const GitpodServerPath = '/gitpod';
@@ -223,7 +377,6 @@ export const GitpodServerProxy = Symbol('GitpodServerProxy');
223
377
  export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
224
378
 
225
379
  export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
226
-
227
380
  protected clients: Partial<Client>[] = [];
228
381
 
229
382
  public registerClient(client: Partial<Client>): Disposable {
@@ -248,6 +401,18 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
248
401
  }
249
402
  }
250
403
 
404
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
405
+ for (const client of this.clients) {
406
+ if (client.onPrebuildUpdate) {
407
+ try {
408
+ client.onPrebuildUpdate(update);
409
+ } catch (error) {
410
+ console.error(error)
411
+ }
412
+ }
413
+ }
414
+ }
415
+
251
416
  onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
252
417
  for (const client of this.clients) {
253
418
  if (client.onWorkspaceImageBuildLogs) {
@@ -260,41 +425,210 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
260
425
  }
261
426
  }
262
427
 
263
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
428
+ notifyDidOpenConnection(): void {
264
429
  for (const client of this.clients) {
265
- if (client.onHeadlessWorkspaceLogs) {
430
+ if (client.notifyDidOpenConnection) {
266
431
  try {
267
- client.onHeadlessWorkspaceLogs(evt);
432
+ client.notifyDidOpenConnection();
268
433
  } catch (error) {
269
434
  console.error(error)
270
435
  }
271
436
  }
272
437
  }
273
438
  }
439
+
440
+ notifyDidCloseConnection(): void {
441
+ for (const client of this.clients) {
442
+ if (client.notifyDidCloseConnection) {
443
+ try {
444
+ client.notifyDidCloseConnection();
445
+ } catch (error) {
446
+ console.error(error)
447
+ }
448
+ }
449
+ }
450
+ }
451
+
452
+ onCreditAlert(creditAlert: CreditAlert): void {
453
+ for (const client of this.clients) {
454
+ if (client.onCreditAlert) {
455
+ try {
456
+ client.onCreditAlert(creditAlert);
457
+ } catch (error) {
458
+ console.error(error)
459
+ }
460
+ }
461
+ }
462
+ }
463
+
274
464
  }
275
465
 
276
- export const GitpodService = Symbol('GitpodService');
277
- export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>
466
+ export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
467
+
468
+ const hasWindow = (typeof window !== 'undefined');
469
+ const phasesOrder: Record<WorkspaceInstancePhase, number> = {
470
+ unknown: 0,
471
+ preparing: 1,
472
+ pending: 2,
473
+ creating: 3,
474
+ initializing: 4,
475
+ running: 5,
476
+ interrupted: 6,
477
+ stopping: 7,
478
+ stopped: 8
479
+ };
480
+ export class WorkspaceInstanceUpdateListener {
481
+ private readonly onDidChangeEmitter = new Emitter<void>();
482
+ readonly onDidChange = this.onDidChangeEmitter.event;
483
+
484
+ private source: 'sync' | 'update' = 'sync';
485
+
486
+ get info(): WorkspaceInfo {
487
+ return this._info;
488
+ }
489
+
490
+ constructor(
491
+ private readonly service: GitpodService,
492
+ private _info: WorkspaceInfo
493
+ ) {
494
+ service.registerClient({
495
+ onInstanceUpdate: instance => {
496
+ if (this.isOutOfOrder(instance)) {
497
+ return;
498
+ }
499
+ this.cancelSync();
500
+ this._info.latestInstance = instance;
501
+ this.source = 'update';
502
+ this.onDidChangeEmitter.fire(undefined);
503
+ },
504
+ notifyDidOpenConnection: () => {
505
+ this.sync();
506
+ }
507
+ });
508
+ if (hasWindow) {
509
+ // learn about page lifecycle here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
510
+ window.document.addEventListener('visibilitychange', async () => {
511
+ if (window.document.visibilityState === 'visible') {
512
+ this.sync();
513
+ }
514
+ });
515
+ window.addEventListener('pageshow', e => {
516
+ if (e.persisted) {
517
+ this.sync();
518
+ }
519
+ });
520
+ }
521
+ }
522
+
523
+ private syncQueue = Promise.resolve();
524
+ private syncTokenSource: CancellationTokenSource | undefined;
525
+ /**
526
+ * Only one sync can be performed at the same time.
527
+ * Any new sync request or instance update cancels all previously scheduled sync requests.
528
+ */
529
+ private sync(): void {
530
+ this.cancelSync();
531
+ this.syncTokenSource = new CancellationTokenSource();
532
+ const token = this.syncTokenSource.token;
533
+ this.syncQueue = this.syncQueue.then(async () => {
534
+ if (token.isCancellationRequested) {
535
+ return;
536
+ }
537
+ try {
538
+ const info = await this.service.server.getWorkspace(this._info.workspace.id);
539
+ if (token.isCancellationRequested) {
540
+ return;
541
+ }
542
+ this._info = info;
543
+ this.source = 'sync';
544
+ this.onDidChangeEmitter.fire(undefined);
545
+ } catch (e) {
546
+ console.error('failed to sync workspace instance:', e)
547
+ }
548
+ })
549
+ }
550
+ private cancelSync(): void {
551
+ if (this.syncTokenSource) {
552
+ this.syncTokenSource.cancel();
553
+ this.syncTokenSource = undefined;
554
+ }
555
+ }
556
+
557
+ /**
558
+ * If sync seen more recent update then ignore all updates with previous phases.
559
+ * Within the same phase still the race can occur but which should be eventually consistent.
560
+ */
561
+ private isOutOfOrder(instance: WorkspaceInstance): boolean {
562
+ if (instance.workspaceId !== this._info.workspace.id) {
563
+ return true;
564
+ }
565
+ if (this.source === 'update') {
566
+ return false;
567
+ }
568
+ if (instance.id !== this.info.latestInstance?.id) {
569
+ return false;
570
+ }
571
+ return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
572
+ }
573
+
574
+ }
575
+
576
+ export interface GitpodServiceOptions {
577
+ onReconnect?: () => (void | Promise<void>)
578
+ }
278
579
 
279
- @injectable()
280
580
  export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
281
581
 
282
- protected compositeClient = new GitpodCompositeClient<Client>();
582
+ private readonly compositeClient = new GitpodCompositeClient<Client>();
283
583
 
284
- constructor(@inject(GitpodServer) public readonly server: JsonRpcProxy<Server>) {
584
+ constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
285
585
  server.setClient(this.compositeClient);
586
+ server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
587
+ server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
286
588
  }
287
589
 
288
590
  public registerClient(client: Partial<Client>): Disposable {
289
591
  return this.compositeClient.registerClient(client);
290
592
  }
593
+
594
+ private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
595
+ listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
596
+ const listener = this.instanceListeners.get(workspaceId) ||
597
+ (async () => {
598
+ const info = await this.server.getWorkspace(workspaceId);
599
+ return new WorkspaceInstanceUpdateListener(this, info);
600
+ })();
601
+ this.instanceListeners.set(workspaceId, listener);
602
+ return listener;
603
+ }
604
+
605
+ async reconnect(): Promise<void> {
606
+ if (this.options?.onReconnect) {
607
+ await this.options.onReconnect();
608
+ }
609
+ }
291
610
  }
292
611
 
293
- export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string) {
294
- const url = new GitpodHostUrl(serverUrl)
295
- .asWebsocket()
296
- .withApi({ pathname: GitpodServerPath });
612
+ export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
613
+ const toWsUrl = (serverUrl: string) => {
614
+ return new GitpodHostUrl(serverUrl)
615
+ .asWebsocket()
616
+ .withApi({ pathname: GitpodServerPath })
617
+ .toString();
618
+ };
619
+ let url: string | Promise<string>;
620
+ if (typeof serverUrl === "string") {
621
+ url = toWsUrl(serverUrl);
622
+ } else {
623
+ url = serverUrl.then(url => toWsUrl(url));
624
+ }
625
+
297
626
  const connectionProvider = new WebSocketConnectionProvider();
298
- const gitpodServer = connectionProvider.createProxy<S>(url.toString());
299
- return new GitpodServiceImpl<C, S>(gitpodServer);
627
+ let onReconnect = () => { };
628
+ const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
629
+ onListening: socket => {
630
+ onReconnect = () => socket.reconnect();
631
+ }
632
+ });
633
+ return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
300
634
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -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})/;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { Event } from "./util/event";
8
+ import { Disposable } from "./util/disposable";
9
+
10
+ export type IDEFrontendState = 'init' | 'ready' | 'terminated';
11
+
12
+ export interface IDEFrontendService {
13
+ readonly state: IDEFrontendState;
14
+ /**
15
+ * A cause of the ide frontend application failure when state is terminated.
16
+ */
17
+ readonly failureCause?: Error;
18
+ readonly onDidChange: Event<void>;
19
+ /**
20
+ * Starts the ide frontend application.
21
+ * Returns the disposable object which is triggered when the ide application should be stopped.
22
+ *
23
+ * On stop the application should store the unsaved changes.
24
+ * It won't receive any `beforeunload` events from window anymore to prevent
25
+ * confirmation dialogs for stopped workspaces.
26
+ */
27
+ start(): Disposable;
28
+ }