@gitpod/gitpod-protocol 0.1.5-ps-commit-email-fork.0 → 0.1.5-release-2022.6.1.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 (375) hide show
  1. package/data/gitpod-schema.json +206 -28
  2. package/lib/accounting-protocol.d.ts +17 -13
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +39 -47
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +21 -4
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +44 -0
  11. package/lib/analytics.d.ts.map +1 -0
  12. package/lib/analytics.js +10 -0
  13. package/lib/analytics.js.map +1 -0
  14. package/lib/auth.d.ts.map +1 -1
  15. package/lib/context-url.d.ts +31 -0
  16. package/lib/context-url.d.ts.map +1 -0
  17. package/lib/context-url.js +102 -0
  18. package/lib/context-url.js.map +1 -0
  19. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +4 -0
  20. package/lib/context-url.spec.d.ts.map +1 -0
  21. package/lib/context-url.spec.js +109 -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.d.ts.map +1 -1
  28. package/lib/encryption/container-module.js +4 -4
  29. package/lib/encryption/container-module.js.map +1 -1
  30. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  31. package/lib/encryption/encryption-engine.js +25 -26
  32. package/lib/encryption/encryption-engine.js.map +1 -1
  33. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  34. package/lib/encryption/encryption-engine.spec.js +29 -37
  35. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  36. package/lib/encryption/encryption-service.d.ts.map +1 -1
  37. package/lib/encryption/encryption-service.js +30 -44
  38. package/lib/encryption/encryption-service.js.map +1 -1
  39. package/lib/encryption/key-provider.d.ts.map +1 -1
  40. package/lib/encryption/key-provider.js +31 -38
  41. package/lib/encryption/key-provider.js.map +1 -1
  42. package/lib/env.d.ts +0 -6
  43. package/lib/env.d.ts.map +1 -1
  44. package/lib/env.js +7 -27
  45. package/lib/env.js.map +1 -1
  46. package/lib/experiments/always-default.d.ts +8 -0
  47. package/lib/experiments/always-default.d.ts.map +1 -0
  48. package/lib/experiments/always-default.js +20 -0
  49. package/lib/experiments/always-default.js.map +1 -0
  50. package/lib/experiments/configcat-server.d.ts +8 -0
  51. package/lib/experiments/configcat-server.d.ts.map +1 -0
  52. package/lib/experiments/configcat-server.js +34 -0
  53. package/lib/experiments/configcat-server.js.map +1 -0
  54. package/lib/experiments/configcat.d.ts +21 -0
  55. package/lib/experiments/configcat.d.ts.map +1 -0
  56. package/lib/experiments/configcat.js +47 -0
  57. package/lib/experiments/configcat.js.map +1 -0
  58. package/lib/experiments/types.d.ts +19 -0
  59. package/lib/experiments/types.d.ts.map +1 -0
  60. package/lib/{util/without.js → experiments/types.js} +2 -2
  61. package/lib/experiments/types.js.map +1 -0
  62. package/lib/gitpod-file-parser.d.ts.map +1 -1
  63. package/lib/gitpod-file-parser.js +26 -42
  64. package/lib/gitpod-file-parser.js.map +1 -1
  65. package/lib/gitpod-file-parser.spec.js +145 -142
  66. package/lib/gitpod-file-parser.spec.js.map +1 -1
  67. package/lib/gitpod-service.d.ts +140 -38
  68. package/lib/gitpod-service.d.ts.map +1 -1
  69. package/lib/gitpod-service.js +181 -317
  70. package/lib/gitpod-service.js.map +1 -1
  71. package/lib/headless-workspace-log.d.ts +9 -11
  72. package/lib/headless-workspace-log.d.ts.map +1 -1
  73. package/lib/headless-workspace-log.js +6 -8
  74. package/lib/headless-workspace-log.js.map +1 -1
  75. package/lib/ide-frontend-service.d.ts +1 -1
  76. package/lib/ide-protocol.d.ts +105 -0
  77. package/lib/ide-protocol.d.ts.map +1 -0
  78. package/lib/ide-protocol.js +8 -0
  79. package/lib/ide-protocol.js.map +1 -0
  80. package/lib/index.d.ts +16 -10
  81. package/lib/index.d.ts.map +1 -1
  82. package/lib/index.js +6 -0
  83. package/lib/index.js.map +1 -1
  84. package/lib/installation-admin-protocol.d.ts +30 -0
  85. package/lib/installation-admin-protocol.d.ts.map +1 -0
  86. package/lib/installation-admin-protocol.js +31 -0
  87. package/lib/installation-admin-protocol.js.map +1 -0
  88. package/lib/license-protocol.d.ts +7 -0
  89. package/lib/license-protocol.d.ts.map +1 -1
  90. package/lib/license-protocol.js.map +1 -1
  91. package/lib/messaging/browser/connection.d.ts +3 -3
  92. package/lib/messaging/browser/connection.d.ts.map +1 -1
  93. package/lib/messaging/browser/connection.js +173 -36
  94. package/lib/messaging/browser/connection.js.map +1 -1
  95. package/lib/messaging/browser/window-connection.d.ts +4 -4
  96. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  97. package/lib/messaging/browser/window-connection.js +42 -59
  98. package/lib/messaging/browser/window-connection.js.map +1 -1
  99. package/lib/messaging/client-call-metrics.d.ts +35 -0
  100. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  101. package/lib/messaging/client-call-metrics.js +83 -0
  102. package/lib/messaging/client-call-metrics.js.map +1 -0
  103. package/lib/messaging/error.d.ts +5 -1
  104. package/lib/messaging/error.d.ts.map +1 -1
  105. package/lib/messaging/error.js +10 -2
  106. package/lib/messaging/error.js.map +1 -1
  107. package/lib/messaging/handler.d.ts +10 -0
  108. package/lib/messaging/handler.d.ts.map +1 -1
  109. package/lib/messaging/handler.js +1 -1
  110. package/lib/messaging/node/connection.d.ts +1 -17
  111. package/lib/messaging/node/connection.d.ts.map +1 -1
  112. package/lib/messaging/node/connection.js +24 -60
  113. package/lib/messaging/node/connection.js.map +1 -1
  114. package/lib/messaging/proxy-factory.d.ts +3 -1
  115. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  116. package/lib/messaging/proxy-factory.js +75 -162
  117. package/lib/messaging/proxy-factory.js.map +1 -1
  118. package/lib/oss-allowlist.d.ts +14 -0
  119. package/lib/oss-allowlist.d.ts.map +1 -0
  120. package/lib/oss-allowlist.js +8 -0
  121. package/lib/oss-allowlist.js.map +1 -0
  122. package/lib/payment-protocol.d.ts.map +1 -1
  123. package/lib/payment-protocol.js +1 -1
  124. package/lib/payment-protocol.js.map +1 -1
  125. package/lib/permission.d.ts +10 -3
  126. package/lib/permission.d.ts.map +1 -1
  127. package/lib/permission.js +41 -31
  128. package/lib/permission.js.map +1 -1
  129. package/lib/plans.d.ts +4 -4
  130. package/lib/plans.d.ts.map +1 -1
  131. package/lib/plans.js +225 -209
  132. package/lib/plans.js.map +1 -1
  133. package/lib/protocol.d.ts +172 -85
  134. package/lib/protocol.d.ts.map +1 -1
  135. package/lib/protocol.js +230 -187
  136. package/lib/protocol.js.map +1 -1
  137. package/lib/snapshot-url.d.ts +14 -0
  138. package/lib/snapshot-url.d.ts.map +1 -0
  139. package/lib/snapshot-url.js +26 -0
  140. package/lib/snapshot-url.js.map +1 -0
  141. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  142. package/lib/snapshot-url.spec.d.ts.map +1 -0
  143. package/lib/snapshot-url.spec.js +41 -0
  144. package/lib/snapshot-url.spec.js.map +1 -0
  145. package/lib/team-subscription-protocol.d.ts +22 -4
  146. package/lib/team-subscription-protocol.d.ts.map +1 -1
  147. package/lib/team-subscription-protocol.js +31 -17
  148. package/lib/team-subscription-protocol.js.map +1 -1
  149. package/lib/teams-projects-protocol.d.ts +118 -0
  150. package/lib/teams-projects-protocol.d.ts.map +1 -0
  151. package/lib/teams-projects-protocol.js +30 -0
  152. package/lib/teams-projects-protocol.js.map +1 -0
  153. package/lib/typings/globals.d.ts +2 -2
  154. package/lib/typings/globals.d.ts.map +1 -1
  155. package/lib/util/analytics.d.ts +8 -0
  156. package/lib/util/analytics.d.ts.map +1 -0
  157. package/lib/util/analytics.js +88 -0
  158. package/lib/util/analytics.js.map +1 -0
  159. package/lib/util/async-iterator.d.ts.map +1 -1
  160. package/lib/util/async-iterator.js +57 -135
  161. package/lib/util/async-iterator.js.map +1 -1
  162. package/lib/util/cancelable.js +17 -59
  163. package/lib/util/cancelable.js.map +1 -1
  164. package/lib/util/date-time.js +11 -11
  165. package/lib/util/date-time.js.map +1 -1
  166. package/lib/util/debug-app.d.ts +25 -0
  167. package/lib/util/debug-app.d.ts.map +1 -0
  168. package/lib/util/debug-app.js +100 -0
  169. package/lib/util/debug-app.js.map +1 -0
  170. package/lib/util/deferred.js +10 -12
  171. package/lib/util/deferred.js.map +1 -1
  172. package/lib/util/disposable.d.ts.map +1 -1
  173. package/lib/util/disposable.js +27 -40
  174. package/lib/util/disposable.js.map +1 -1
  175. package/lib/util/event.d.ts.map +1 -1
  176. package/lib/util/event.js +63 -77
  177. package/lib/util/event.js.map +1 -1
  178. package/lib/util/garbage-collected-cache.d.ts +1 -0
  179. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  180. package/lib/util/garbage-collected-cache.js +27 -47
  181. package/lib/util/garbage-collected-cache.js.map +1 -1
  182. package/lib/util/generate-workspace-id.d.ts +6 -1
  183. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  184. package/lib/util/generate-workspace-id.js +469 -502
  185. package/lib/util/generate-workspace-id.js.map +1 -1
  186. package/lib/util/generate-workspace-id.spec.js +68 -78
  187. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  188. package/lib/util/gitpod-cookie.d.ts +20 -0
  189. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  190. package/lib/util/gitpod-cookie.js +41 -0
  191. package/lib/util/gitpod-cookie.js.map +1 -0
  192. package/lib/util/gitpod-host-url.d.ts +1 -2
  193. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  194. package/lib/util/gitpod-host-url.js +108 -109
  195. package/lib/util/gitpod-host-url.js.map +1 -1
  196. package/lib/util/gitpod-host-url.spec.d.ts +6 -0
  197. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  198. package/lib/util/gitpod-host-url.spec.js +112 -30
  199. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  200. package/lib/util/grpc.d.ts +15 -0
  201. package/lib/util/grpc.d.ts.map +1 -0
  202. package/lib/util/grpc.js +18 -0
  203. package/lib/util/grpc.js.map +1 -0
  204. package/lib/util/jaeger-client-types.d.ts +68 -0
  205. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  206. package/lib/{theia-plugins.js → util/jaeger-client-types.js} +1 -1
  207. package/lib/util/jaeger-client-types.js.map +1 -0
  208. package/lib/util/logging.d.ts +49 -33
  209. package/lib/util/logging.d.ts.map +1 -1
  210. package/lib/util/logging.js +125 -129
  211. package/lib/util/logging.js.map +1 -1
  212. package/lib/util/make-link.js +5 -5
  213. package/lib/util/make-link.js.map +1 -1
  214. package/lib/util/parse-workspace-id.d.ts +10 -0
  215. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  216. package/lib/util/parse-workspace-id.js +30 -7
  217. package/lib/util/parse-workspace-id.js.map +1 -1
  218. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  219. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  220. package/lib/util/parse-workspace-id.spec.js +123 -84
  221. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  222. package/lib/util/queue.js +16 -55
  223. package/lib/util/queue.js.map +1 -1
  224. package/lib/util/queue.spec.js +147 -288
  225. package/lib/util/queue.spec.js.map +1 -1
  226. package/lib/util/repeat.d.ts +15 -0
  227. package/lib/util/repeat.d.ts.map +1 -0
  228. package/lib/util/repeat.js +55 -0
  229. package/lib/util/repeat.js.map +1 -0
  230. package/lib/util/semaphore.d.ts.map +1 -1
  231. package/lib/util/semaphore.js +15 -46
  232. package/lib/util/semaphore.js.map +1 -1
  233. package/lib/util/skip-if.d.ts.map +1 -1
  234. package/lib/util/skip-if.js +6 -6
  235. package/lib/util/skip-if.js.map +1 -1
  236. package/lib/util/timeutil.d.ts +1 -0
  237. package/lib/util/timeutil.d.ts.map +1 -1
  238. package/lib/util/timeutil.js +23 -17
  239. package/lib/util/timeutil.js.map +1 -1
  240. package/lib/util/timeutil.spec.d.ts.map +1 -1
  241. package/lib/util/timeutil.spec.js +21 -24
  242. package/lib/util/timeutil.spec.js.map +1 -1
  243. package/lib/util/tracing.d.ts +52 -6
  244. package/lib/util/tracing.d.ts.map +1 -1
  245. package/lib/util/tracing.js +197 -64
  246. package/lib/util/tracing.js.map +1 -1
  247. package/lib/util/tracing.spec.d.ts +7 -0
  248. package/lib/util/tracing.spec.d.ts.map +1 -0
  249. package/lib/util/tracing.spec.js +121 -0
  250. package/lib/util/tracing.spec.js.map +1 -0
  251. package/lib/util/workspace-port-authentication.d.ts +7 -7
  252. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  253. package/lib/util/workspace-port-authentication.js +9 -12
  254. package/lib/util/workspace-port-authentication.js.map +1 -1
  255. package/lib/workspace-cluster.d.ts +24 -3
  256. package/lib/workspace-cluster.d.ts.map +1 -1
  257. package/lib/workspace-cluster.js +19 -4
  258. package/lib/workspace-cluster.js.map +1 -1
  259. package/lib/workspace-instance.d.ts +42 -5
  260. package/lib/workspace-instance.d.ts.map +1 -1
  261. package/lib/wsready.d.ts +1 -1
  262. package/lib/wsready.d.ts.map +1 -1
  263. package/lib/wsready.js +2 -2
  264. package/lib/wsready.js.map +1 -1
  265. package/package.json +35 -18
  266. package/pkg-yarn.lock +20 -10
  267. package/provenance-bundle.jsonl +2 -0
  268. package/src/accounting-protocol.ts +63 -57
  269. package/src/admin-protocol.ts +43 -21
  270. package/src/analytics.ts +52 -0
  271. package/src/auth.ts +2 -2
  272. package/src/context-url.spec.ts +67 -0
  273. package/src/context-url.ts +109 -0
  274. package/src/email-protocol.ts +5 -7
  275. package/src/encryption/container-module.ts +2 -3
  276. package/src/encryption/encryption-engine.spec.ts +9 -8
  277. package/src/encryption/encryption-engine.ts +14 -14
  278. package/src/encryption/encryption-service.ts +4 -5
  279. package/src/encryption/key-provider.ts +16 -19
  280. package/src/env.ts +0 -22
  281. package/src/experiments/always-default.ts +24 -0
  282. package/src/experiments/configcat-server.ts +37 -0
  283. package/src/experiments/configcat.ts +53 -0
  284. package/src/experiments/types.ts +32 -0
  285. package/src/gitpod-file-parser.spec.ts +55 -61
  286. package/src/gitpod-file-parser.ts +16 -17
  287. package/src/gitpod-service.ts +278 -127
  288. package/src/headless-workspace-log.ts +12 -14
  289. package/src/ide-frontend-service.ts +2 -2
  290. package/src/ide-protocol.ts +119 -0
  291. package/src/index.ts +16 -10
  292. package/src/installation-admin-protocol.ts +45 -0
  293. package/src/license-protocol.ts +12 -6
  294. package/src/messaging/browser/connection.ts +185 -21
  295. package/src/messaging/browser/window-connection.ts +39 -29
  296. package/src/messaging/client-call-metrics.ts +96 -0
  297. package/src/messaging/error.ts +15 -5
  298. package/src/messaging/handler.ts +13 -1
  299. package/src/messaging/node/connection.ts +23 -70
  300. package/src/messaging/proxy-factory.ts +35 -34
  301. package/src/oss-allowlist.ts +15 -0
  302. package/src/payment-protocol.ts +2 -2
  303. package/src/permission.ts +42 -33
  304. package/src/plans.ts +236 -189
  305. package/src/protocol.ts +454 -276
  306. package/src/snapshot-url.spec.ts +27 -0
  307. package/src/snapshot-url.ts +27 -0
  308. package/src/team-subscription-protocol.ts +59 -23
  309. package/src/teams-projects-protocol.ts +153 -0
  310. package/src/typings/globals.ts +4 -4
  311. package/src/util/analytics.ts +109 -0
  312. package/src/util/async-iterator.ts +4 -5
  313. package/src/util/cancelable.ts +3 -3
  314. package/src/util/date-time.ts +8 -8
  315. package/src/util/debug-app.ts +81 -0
  316. package/src/util/deferred.ts +6 -6
  317. package/src/util/disposable.ts +3 -6
  318. package/src/util/event.ts +9 -11
  319. package/src/util/garbage-collected-cache.ts +9 -6
  320. package/src/util/generate-workspace-id.spec.ts +37 -10
  321. package/src/util/generate-workspace-id.ts +464 -438
  322. package/src/util/gitpod-cookie.ts +38 -0
  323. package/src/util/gitpod-host-url.spec.ts +58 -7
  324. package/src/util/gitpod-host-url.ts +52 -40
  325. package/src/util/grpc.ts +15 -0
  326. package/src/util/jaeger-client-types.ts +102 -0
  327. package/src/util/logging.ts +145 -72
  328. package/src/util/make-link.ts +6 -7
  329. package/src/util/parse-workspace-id.spec.ts +37 -8
  330. package/src/util/parse-workspace-id.ts +32 -7
  331. package/src/util/queue.spec.ts +27 -25
  332. package/src/util/repeat.ts +45 -0
  333. package/src/util/semaphore.ts +4 -6
  334. package/src/util/skip-if.ts +9 -6
  335. package/src/util/timeutil.spec.ts +14 -15
  336. package/src/util/timeutil.ts +21 -11
  337. package/src/util/tracing.spec.ts +88 -0
  338. package/src/util/tracing.ts +200 -31
  339. package/src/util/workspace-port-authentication.ts +10 -13
  340. package/src/workspace-cluster.ts +34 -7
  341. package/src/workspace-instance.ts +91 -31
  342. package/src/wsready.ts +3 -3
  343. package/data/builtin-theia-plugins.json +0 -372
  344. package/lib/messaging/connection-error-handler.d.ts +0 -27
  345. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  346. package/lib/messaging/connection-error-handler.js +0 -46
  347. package/lib/messaging/connection-error-handler.js.map +0 -1
  348. package/lib/theia-plugins.d.ts +0 -11
  349. package/lib/theia-plugins.d.ts.map +0 -1
  350. package/lib/theia-plugins.js.map +0 -1
  351. package/lib/util/context-url.d.ts +0 -13
  352. package/lib/util/context-url.d.ts.map +0 -1
  353. package/lib/util/context-url.js +0 -26
  354. package/lib/util/context-url.js.map +0 -1
  355. package/lib/util/context-url.spec.d.ts.map +0 -1
  356. package/lib/util/context-url.spec.js +0 -52
  357. package/lib/util/context-url.spec.js.map +0 -1
  358. package/lib/util/repeater.d.ts +0 -22
  359. package/lib/util/repeater.d.ts.map +0 -1
  360. package/lib/util/repeater.js +0 -118
  361. package/lib/util/repeater.js.map +0 -1
  362. package/lib/util/safe-promise.d.ts +0 -11
  363. package/lib/util/safe-promise.d.ts.map +0 -1
  364. package/lib/util/safe-promise.js +0 -34
  365. package/lib/util/safe-promise.js.map +0 -1
  366. package/lib/util/without.d.ts +0 -7
  367. package/lib/util/without.d.ts.map +0 -1
  368. package/lib/util/without.js.map +0 -1
  369. package/src/messaging/connection-error-handler.ts +0 -62
  370. package/src/theia-plugins.ts +0 -11
  371. package/src/util/context-url.spec.ts +0 -25
  372. package/src/util/context-url.ts +0 -23
  373. package/src/util/jaeger-client.d.ts +0 -105
  374. package/src/util/repeater.ts +0 -49
  375. package/src/util/safe-promise.ts +0 -26
@@ -5,30 +5,64 @@
5
5
  */
6
6
 
7
7
  import {
8
- User, WorkspaceInfo, WorkspaceCreationResult, UserMessage, WorkspaceInstanceUser,
9
- WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode,
10
- Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
- ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
- GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes
13
- } from './protocol';
14
- import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
15
- import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
16
- import { HeadlessLogEvent } from './headless-workspace-log';
17
- import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
18
- import { AdminServer } from './admin-protocol';
19
- import { GitpodHostUrl } from './util/gitpod-host-url';
20
- import { WebSocketConnectionProvider } from './messaging/browser/connection';
21
- import { PermissionName } from './permission';
22
- import { LicenseService } from './license-protocol';
23
- import { Emitter } from './util/event';
24
- import { AccountStatement, CreditAlert } from './accounting-protocol';
25
- import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
26
- import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
8
+ User,
9
+ WorkspaceInfo,
10
+ WorkspaceCreationResult,
11
+ WorkspaceInstanceUser,
12
+ WhitelistedRepository,
13
+ WorkspaceImageBuild,
14
+ AuthProviderInfo,
15
+ CreateWorkspaceMode,
16
+ Token,
17
+ UserEnvVarValue,
18
+ Terms,
19
+ Configuration,
20
+ UserInfo,
21
+ GitpodTokenType,
22
+ GitpodToken,
23
+ AuthProviderEntry,
24
+ GuessGitTokenScopesParams,
25
+ GuessedGitTokenScopes,
26
+ ProjectEnvVar,
27
+ } from "./protocol";
28
+ import {
29
+ Team,
30
+ TeamMemberInfo,
31
+ TeamMembershipInvite,
32
+ Project,
33
+ TeamMemberRole,
34
+ PrebuildWithStatus,
35
+ StartPrebuildResult,
36
+ PartialProject,
37
+ } from "./teams-projects-protocol";
38
+ import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
39
+ import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
40
+ import { HeadlessLogUrls } from "./headless-workspace-log";
41
+ import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from "./workspace-instance";
42
+ import { AdminServer } from "./admin-protocol";
43
+ import { GitpodHostUrl } from "./util/gitpod-host-url";
44
+ import { WebSocketConnectionProvider } from "./messaging/browser/connection";
45
+ import { PermissionName } from "./permission";
46
+ import { LicenseService } from "./license-protocol";
47
+ import { Emitter } from "./util/event";
48
+ import { AccountStatement, CreditAlert } from "./accounting-protocol";
49
+ import { GithubUpgradeURL, PlanCoupon } from "./payment-protocol";
50
+ import {
51
+ TeamSubscription,
52
+ TeamSubscription2,
53
+ TeamSubscriptionSlot,
54
+ TeamSubscriptionSlotResolved,
55
+ } from "./team-subscription-protocol";
56
+ import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
57
+ import { IDEServer } from "./ide-protocol";
58
+ import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
59
+ import { Currency } from "./plans";
27
60
 
28
61
  export interface GitpodClient {
29
62
  onInstanceUpdate(instance: WorkspaceInstance): void;
30
63
  onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
31
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void;
64
+
65
+ onPrebuildUpdate(update: PrebuildWithStatus): void;
32
66
 
33
67
  onCreditAlert(creditAlert: CreditAlert): void;
34
68
 
@@ -38,8 +72,8 @@ export interface GitpodClient {
38
72
  //#endregion
39
73
  }
40
74
 
41
- export const GitpodServer = Symbol('GitpodServer');
42
- export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService {
75
+ export const GitpodServer = Symbol("GitpodServer");
76
+ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
43
77
  // User related API
44
78
  getLoggedInUser(): Promise<User>;
45
79
  getTerms(): Promise<Terms>;
@@ -48,9 +82,9 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
48
82
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
49
83
  updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
50
84
  deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
51
- getBranding(): Promise<Branding>;
52
85
  getConfiguration(): Promise<Configuration>;
53
86
  getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
87
+ getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
54
88
  /**
55
89
  * @deprecated
56
90
  */
@@ -64,8 +98,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
64
98
  getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
65
99
  getWorkspaceUsers(workspaceId: string): Promise<WorkspaceInstanceUser[]>;
66
100
  getFeaturedRepositories(): Promise<WhitelistedRepository[]>;
101
+ getSuggestedContextURLs(): Promise<string[]>;
102
+ /**
103
+ * **Security:**
104
+ * Sensitive information like an owner token is erased, since it allows access for all team members.
105
+ * If you need to access an owner token use `getOwnerToken` instead.
106
+ */
67
107
  getWorkspace(id: string): Promise<WorkspaceInfo>;
68
108
  isWorkspaceOwner(workspaceId: string): Promise<boolean>;
109
+ getOwnerToken(workspaceId: string): Promise<string>;
69
110
 
70
111
  /**
71
112
  * Creates and starts a workspace for the given context URL.
@@ -82,8 +123,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
82
123
  updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
83
124
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
84
125
  watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
85
- watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
86
126
  isPrebuildDone(pwsid: string): Promise<boolean>;
127
+ getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
87
128
 
88
129
  // Workspace timeout
89
130
  setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
@@ -97,23 +138,55 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
97
138
  openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
98
139
  closePort(workspaceId: string, port: number): Promise<void>;
99
140
 
100
- // User messages
101
- getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
102
- updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
103
-
104
141
  // User storage
105
142
  getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
106
143
  updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
107
144
 
108
- // user env vars
145
+ // User env vars
109
146
  getEnvVars(): Promise<UserEnvVarValue[]>;
110
147
  getAllEnvVars(): Promise<UserEnvVarValue[]>;
111
148
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
112
149
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
113
150
 
151
+ // Teams
152
+ getTeams(): Promise<Team[]>;
153
+ getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
154
+ createTeam(name: string): Promise<Team>;
155
+ joinTeam(inviteId: string): Promise<Team>;
156
+ setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
157
+ removeTeamMember(teamId: string, userId: string): Promise<void>;
158
+ getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
159
+ resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
160
+ deleteTeam(teamId: string, userId: string): Promise<void>;
161
+
162
+ // Admin Settings
163
+ adminGetSettings(): Promise<InstallationAdminSettings>;
164
+ adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
165
+ adminGetTelemetryData(): Promise<TelemetryData>;
166
+
167
+ // Projects
168
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
169
+ createProject(params: CreateProjectParams): Promise<Project>;
170
+ deleteProject(projectId: string): Promise<void>;
171
+ getTeamProjects(teamId: string): Promise<Project[]>;
172
+ getUserProjects(): Promise<Project[]>;
173
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
174
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
175
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
176
+ cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
177
+ fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
178
+ guessProjectConfiguration(projectId: string): Promise<string | undefined>;
179
+ fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
180
+ guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
181
+ setProjectConfiguration(projectId: string, configString: string): Promise<void>;
182
+ updateProjectPartial(partialProject: PartialProject): Promise<void>;
183
+ setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
184
+ getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
185
+ deleteProjectEnvironmentVariable(variableId: string): Promise<void>;
186
+
114
187
  // content service
115
- getContentBlobUploadUrl(name: string): Promise<string>
116
- getContentBlobDownloadUrl(name: string): Promise<string>
188
+ getContentBlobUploadUrl(name: string): Promise<string>;
189
+ getContentBlobDownloadUrl(name: string): Promise<string>;
117
190
 
118
191
  // Gitpod token
119
192
  getGitpodTokens(): Promise<GitpodToken[]>;
@@ -122,13 +195,19 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
122
195
 
123
196
  // misc
124
197
  sendFeedback(feedback: string): Promise<string | undefined>;
198
+ isGitHubAppEnabled(): Promise<boolean>;
125
199
  registerGithubApp(installationId: string): Promise<void>;
126
200
 
127
201
  /**
128
- * Stores a new snapshot for the given workspace and bucketId
202
+ * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
129
203
  * @return the snapshot id
130
204
  */
131
205
  takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
206
+ /**
207
+ *
208
+ * @param snapshotId
209
+ */
210
+ waitForSnapshot(snapshotId: string): Promise<void>;
132
211
 
133
212
  /**
134
213
  * Returns the list of snapshots that exist for a workspace.
@@ -145,23 +224,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
145
224
  */
146
225
  getLayout(workspaceId: string): Promise<string | undefined>;
147
226
 
148
- /**
149
- * @param params
150
- * @returns promise resolves to an URL to be used for the upload
151
- */
152
- preparePluginUpload(params: PreparePluginUploadParams): Promise<string>
153
- resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
154
- installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
155
- uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
156
-
157
227
  guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
158
228
 
159
229
  /**
160
230
  * gitpod.io concerns
161
231
  */
162
232
  isStudent(): Promise<boolean>;
163
- getPrivateRepoTrialEndDate(): Promise<string | undefined>;
164
-
165
233
  /**
166
234
  *
167
235
  */
@@ -173,67 +241,152 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
173
241
  */
174
242
  getChargebeeSiteId(): Promise<string>;
175
243
  createPortalSession(): Promise<{}>;
244
+ createTeamPortalSession(teamId: string): Promise<{}>;
176
245
  checkout(planId: string, planQuantity?: number): Promise<{}>;
246
+ teamCheckout(teamId: string, planId: string): Promise<{}>;
177
247
  getAvailableCoupons(): Promise<PlanCoupon[]>;
178
248
  getAppliedCoupons(): Promise<PlanCoupon[]>;
179
249
 
180
250
  getShowPaymentUI(): Promise<boolean>;
181
251
  isChargebeeCustomer(): Promise<boolean>;
182
- mayAccessPrivateRepo(): Promise<boolean>;
183
252
 
184
253
  subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
185
254
  subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
186
255
  subscriptionCancel(subscriptionId: string): Promise<void>;
187
256
  subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
188
257
 
258
+ getTeamSubscription(teamId: string): Promise<TeamSubscription2 | undefined>;
189
259
  tsGet(): Promise<TeamSubscription[]>;
190
260
  tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
191
- tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
261
+ tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
192
262
  tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
193
- tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string | undefined): Promise<void>
263
+ tsAssignSlot(
264
+ teamSubscriptionId: string,
265
+ teamSubscriptionSlotId: string,
266
+ identityStr: string | undefined,
267
+ ): Promise<void>;
194
268
  tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
195
269
  tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
196
270
  tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
197
271
 
198
272
  getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
199
273
 
274
+ getStripePublishableKey(): Promise<string>;
275
+ getStripeSetupIntentClientSecret(): Promise<string>;
276
+ findStripeSubscriptionIdForTeam(teamId: string): Promise<string | undefined>;
277
+ subscribeTeamToStripe(teamId: string, setupIntentId: string, currency: Currency): Promise<void>;
278
+ getStripePortalUrlForTeam(teamId: string): Promise<string>;
279
+
280
+ /**
281
+ * Analytics
282
+ */
283
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
284
+ trackLocation(event: RemotePageMessage): Promise<void>;
285
+ identifyUser(event: RemoteIdentifyMessage): Promise<void>;
200
286
  }
201
287
 
202
- export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
288
+ export interface RateLimiterError {
289
+ method?: string;
203
290
 
204
- export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): GitpodServiceImpl<C, S> {
205
- return new GitpodServiceImpl<C, S>(createServerMock(methods));
291
+ /**
292
+ * Retry after this many seconds, earliest.
293
+ * cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
294
+ */
295
+ retryAfter: number;
206
296
  }
207
297
 
208
- export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): JsonRpcProxy<S> {
209
- methods.setClient = methods.setClient || (() => { });
210
- methods.dispose = methods.dispose || (() => { });
298
+ export interface CreateProjectParams {
299
+ name: string;
300
+ slug?: string;
301
+ account: string;
302
+ provider: string;
303
+ cloneUrl: string;
304
+ teamId?: string;
305
+ userId?: string;
306
+ appInstallationId: string;
307
+ }
308
+ export interface FindPrebuildsParams {
309
+ projectId: string;
310
+ branch?: string;
311
+ latest?: boolean;
312
+ prebuildId?: string;
313
+ // default: 30
314
+ limit?: number;
315
+ }
316
+ export interface GetProviderRepositoriesParams {
317
+ provider: string;
318
+ hints?: { installationId: string } | object;
319
+ }
320
+ export interface ProviderRepository {
321
+ name: string;
322
+ path?: string;
323
+ account: string;
324
+ accountAvatarUrl: string;
325
+ cloneUrl: string;
326
+ updatedAt?: string;
327
+ installationId?: number;
328
+ installationUpdatedAt?: string;
329
+
330
+ inUse?: { userName: string };
331
+ }
332
+
333
+ export interface ClientHeaderFields {
334
+ ip?: string;
335
+ userAgent?: string;
336
+ dnt?: string;
337
+ clientRegion?: string;
338
+ }
339
+
340
+ export const WORKSPACE_TIMEOUT_DEFAULT_SHORT = "short";
341
+ export const WORKSPACE_TIMEOUT_DEFAULT_LONG = "long";
342
+ export const WORKSPACE_TIMEOUT_EXTENDED = "extended";
343
+ export const WORKSPACE_TIMEOUT_EXTENDED_ALT = "180m"; // for backwards compatibility since the IDE uses this
344
+ export const WorkspaceTimeoutValues = [
345
+ WORKSPACE_TIMEOUT_DEFAULT_SHORT,
346
+ WORKSPACE_TIMEOUT_DEFAULT_LONG,
347
+ WORKSPACE_TIMEOUT_EXTENDED,
348
+ WORKSPACE_TIMEOUT_EXTENDED_ALT,
349
+ ] as const;
350
+
351
+ export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
352
+ methods: Partial<JsonRpcProxy<S>>,
353
+ ): GitpodServiceImpl<C, S> {
354
+ return new GitpodServiceImpl<C, S>(createServerMock(methods));
355
+ };
356
+
357
+ export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
358
+ methods: Partial<JsonRpcProxy<S>>,
359
+ ): JsonRpcProxy<S> {
360
+ methods.setClient = methods.setClient || (() => {});
361
+ methods.dispose = methods.dispose || (() => {});
211
362
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
363
+ // @ts-ignore
212
364
  get: (target: S, property: keyof S) => {
213
365
  const result = target[property];
214
366
  if (!result) {
215
367
  throw new Error(`Method ${property} not implemented`);
216
368
  }
217
369
  return result;
218
- }
370
+ },
219
371
  });
220
- }
372
+ };
221
373
 
222
374
  type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
223
375
  export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
224
376
 
225
377
  export interface SetWorkspaceTimeoutResult {
226
- resetTimeoutOnWorkspaces: string[]
378
+ resetTimeoutOnWorkspaces: string[];
227
379
  }
228
380
 
229
381
  export interface GetWorkspaceTimeoutResult {
230
- duration: WorkspaceTimeoutDuration
231
- canChange: boolean
382
+ duration: WorkspaceTimeoutDuration;
383
+ durationRaw: string;
384
+ canChange: boolean;
232
385
  }
233
386
 
234
387
  export interface StartWorkspaceResult {
235
- instanceID: string
236
- workspaceURL?: string
388
+ instanceID: string;
389
+ workspaceURL?: string;
237
390
  }
238
391
 
239
392
  export namespace GitpodServer {
@@ -241,6 +394,8 @@ export namespace GitpodServer {
241
394
  limit?: number;
242
395
  searchString?: string;
243
396
  pinnedOnly?: boolean;
397
+ projectId?: string | string[];
398
+ includeWithoutProject?: boolean;
244
399
  }
245
400
  export interface GetAccountStatementOptions {
246
401
  date?: string;
@@ -248,6 +403,7 @@ export namespace GitpodServer {
248
403
  export interface CreateWorkspaceOptions {
249
404
  contextUrl: string;
250
405
  mode?: CreateWorkspaceMode;
406
+ forceDefaultConfig?: boolean;
251
407
  }
252
408
  export interface StartWorkspaceOptions {
253
409
  forceDefaultImage: boolean;
@@ -255,13 +411,8 @@ export namespace GitpodServer {
255
411
  export interface TakeSnapshotOptions {
256
412
  workspaceId: string;
257
413
  layoutData?: string;
258
- }
259
- export interface GetUserMessagesOptions {
260
- readonly releaseNotes?: boolean;
261
- readonly workspaceInstanceId: string;
262
- }
263
- export interface UpdateUserMessagesOptions {
264
- readonly messageIds: string[];
414
+ /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
415
+ dontWait?: boolean;
265
416
  }
266
417
  export interface GetUserStorageResourceOptions {
267
418
  readonly uri: string;
@@ -279,23 +430,23 @@ export namespace GitpodServer {
279
430
  readonly roundTripTime?: number;
280
431
  }
281
432
  export interface UpdateOwnAuthProviderParams {
282
- readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
433
+ readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
283
434
  }
284
435
  export interface DeleteOwnAuthProviderParams {
285
- readonly id: string
436
+ readonly id: string;
286
437
  }
287
438
  export type AdmissionLevel = "owner" | "everyone";
288
439
  export type PinAction = "pin" | "unpin" | "toggle";
289
440
  export interface GenerateNewGitpodTokenOptions {
290
- name?: string
291
- type: GitpodTokenType
292
- scopes?: string[]
441
+ name?: string;
442
+ type: GitpodTokenType;
443
+ scopes?: string[];
293
444
  }
294
445
  }
295
446
 
296
- export const GitpodServerPath = '/gitpod';
447
+ export const GitpodServerPath = "/gitpod";
297
448
 
298
- export const GitpodServerProxy = Symbol('GitpodServerProxy');
449
+ export const GitpodServerProxy = Symbol("GitpodServerProxy");
299
450
  export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
300
451
 
301
452
  export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
@@ -303,12 +454,14 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
303
454
 
304
455
  public registerClient(client: Partial<Client>): Disposable {
305
456
  this.clients.push(client);
306
- const index = this.clients.length;
307
457
  return {
308
458
  dispose: () => {
309
- this.clients.slice(index, 1);
310
- }
311
- }
459
+ const index = this.clients.indexOf(client);
460
+ if (index > -1) {
461
+ this.clients.splice(index, 1);
462
+ }
463
+ },
464
+ };
312
465
  }
313
466
 
314
467
  onInstanceUpdate(instance: WorkspaceInstance): void {
@@ -317,31 +470,34 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
317
470
  try {
318
471
  client.onInstanceUpdate(instance);
319
472
  } catch (error) {
320
- console.error(error)
473
+ console.error(error);
321
474
  }
322
475
  }
323
476
  }
324
477
  }
325
478
 
326
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
479
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
327
480
  for (const client of this.clients) {
328
- if (client.onWorkspaceImageBuildLogs) {
481
+ if (client.onPrebuildUpdate) {
329
482
  try {
330
- client.onWorkspaceImageBuildLogs(info, content);
483
+ client.onPrebuildUpdate(update);
331
484
  } catch (error) {
332
- console.error(error)
485
+ console.error(error);
333
486
  }
334
487
  }
335
488
  }
336
489
  }
337
490
 
338
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
491
+ onWorkspaceImageBuildLogs(
492
+ info: WorkspaceImageBuild.StateInfo,
493
+ content: WorkspaceImageBuild.LogContent | undefined,
494
+ ): void {
339
495
  for (const client of this.clients) {
340
- if (client.onHeadlessWorkspaceLogs) {
496
+ if (client.onWorkspaceImageBuildLogs) {
341
497
  try {
342
- client.onHeadlessWorkspaceLogs(evt);
498
+ client.onWorkspaceImageBuildLogs(info, content);
343
499
  } catch (error) {
344
- console.error(error)
500
+ console.error(error);
345
501
  }
346
502
  }
347
503
  }
@@ -353,7 +509,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
353
509
  try {
354
510
  client.notifyDidOpenConnection();
355
511
  } catch (error) {
356
- console.error(error)
512
+ console.error(error);
357
513
  }
358
514
  }
359
515
  }
@@ -365,7 +521,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
365
521
  try {
366
522
  client.notifyDidCloseConnection();
367
523
  } catch (error) {
368
- console.error(error)
524
+ console.error(error);
369
525
  }
370
526
  }
371
527
  }
@@ -377,64 +533,61 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
377
533
  try {
378
534
  client.onCreditAlert(creditAlert);
379
535
  } catch (error) {
380
- console.error(error)
536
+ console.error(error);
381
537
  }
382
538
  }
383
539
  }
384
540
  }
385
-
386
541
  }
387
542
 
388
543
  export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
389
544
 
390
- const hasWindow = (typeof window !== 'undefined');
545
+ const hasWindow = typeof window !== "undefined";
391
546
  const phasesOrder: Record<WorkspaceInstancePhase, number> = {
392
547
  unknown: 0,
393
548
  preparing: 1,
394
- pending: 2,
395
- creating: 3,
396
- initializing: 4,
397
- running: 5,
398
- interrupted: 6,
399
- stopping: 7,
400
- stopped: 8
549
+ building: 2,
550
+ pending: 3,
551
+ creating: 4,
552
+ initializing: 5,
553
+ running: 6,
554
+ interrupted: 7,
555
+ stopping: 8,
556
+ stopped: 9,
401
557
  };
402
558
  export class WorkspaceInstanceUpdateListener {
403
559
  private readonly onDidChangeEmitter = new Emitter<void>();
404
560
  readonly onDidChange = this.onDidChangeEmitter.event;
405
561
 
406
- private source: 'sync' | 'update' = 'sync';
562
+ private source: "sync" | "update" = "sync";
407
563
 
408
564
  get info(): WorkspaceInfo {
409
565
  return this._info;
410
566
  }
411
567
 
412
- constructor(
413
- private readonly service: GitpodService,
414
- private _info: WorkspaceInfo
415
- ) {
568
+ constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
416
569
  service.registerClient({
417
- onInstanceUpdate: instance => {
570
+ onInstanceUpdate: (instance) => {
418
571
  if (this.isOutOfOrder(instance)) {
419
572
  return;
420
573
  }
421
574
  this.cancelSync();
422
575
  this._info.latestInstance = instance;
423
- this.source = 'update';
576
+ this.source = "update";
424
577
  this.onDidChangeEmitter.fire(undefined);
425
578
  },
426
579
  notifyDidOpenConnection: () => {
427
580
  this.sync();
428
- }
581
+ },
429
582
  });
430
583
  if (hasWindow) {
431
584
  // learn about page lifecycle here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
432
- window.document.addEventListener('visibilitychange', async () => {
433
- if (window.document.visibilityState === 'visible') {
585
+ window.document.addEventListener("visibilitychange", async () => {
586
+ if (window.document.visibilityState === "visible") {
434
587
  this.sync();
435
588
  }
436
589
  });
437
- window.addEventListener('pageshow', e => {
590
+ window.addEventListener("pageshow", (e) => {
438
591
  if (e.persisted) {
439
592
  this.sync();
440
593
  }
@@ -462,12 +615,12 @@ export class WorkspaceInstanceUpdateListener {
462
615
  return;
463
616
  }
464
617
  this._info = info;
465
- this.source = 'sync';
618
+ this.source = "sync";
466
619
  this.onDidChangeEmitter.fire(undefined);
467
620
  } catch (e) {
468
- console.error('failed to sync workspace instance:', e)
621
+ console.error("failed to sync workspace instance:", e);
469
622
  }
470
- })
623
+ });
471
624
  }
472
625
  private cancelSync(): void {
473
626
  if (this.syncTokenSource) {
@@ -484,7 +637,7 @@ export class WorkspaceInstanceUpdateListener {
484
637
  if (instance.workspaceId !== this._info.workspace.id) {
485
638
  return true;
486
639
  }
487
- if (this.source === 'update') {
640
+ if (this.source === "update") {
488
641
  return false;
489
642
  }
490
643
  if (instance.id !== this.info.latestInstance?.id) {
@@ -492,15 +645,13 @@ export class WorkspaceInstanceUpdateListener {
492
645
  }
493
646
  return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
494
647
  }
495
-
496
648
  }
497
649
 
498
650
  export interface GitpodServiceOptions {
499
- onReconnect?: () => (void | Promise<void>)
651
+ onReconnect?: () => void | Promise<void>;
500
652
  }
501
653
 
502
654
  export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
503
-
504
655
  private readonly compositeClient = new GitpodCompositeClient<Client>();
505
656
 
506
657
  constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
@@ -515,7 +666,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
515
666
 
516
667
  private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
517
668
  listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
518
- const listener = this.instanceListeners.get(workspaceId) ||
669
+ const listener =
670
+ this.instanceListeners.get(workspaceId) ||
519
671
  (async () => {
520
672
  const info = await this.server.getWorkspace(workspaceId);
521
673
  return new WorkspaceInstanceUpdateListener(this, info);
@@ -531,26 +683,25 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
531
683
  }
532
684
  }
533
685
 
534
- export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
686
+ export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
687
+ serverUrl: string | Promise<string>,
688
+ ) {
535
689
  const toWsUrl = (serverUrl: string) => {
536
- return new GitpodHostUrl(serverUrl)
537
- .asWebsocket()
538
- .withApi({ pathname: GitpodServerPath })
539
- .toString();
690
+ return new GitpodHostUrl(serverUrl).asWebsocket().withApi({ pathname: GitpodServerPath }).toString();
540
691
  };
541
692
  let url: string | Promise<string>;
542
693
  if (typeof serverUrl === "string") {
543
694
  url = toWsUrl(serverUrl);
544
695
  } else {
545
- url = serverUrl.then(url => toWsUrl(url));
696
+ url = serverUrl.then((url) => toWsUrl(url));
546
697
  }
547
698
 
548
699
  const connectionProvider = new WebSocketConnectionProvider();
549
- let onReconnect = () => { };
700
+ let onReconnect = () => {};
550
701
  const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
551
- onListening: socket => {
702
+ onListening: (socket) => {
552
703
  onReconnect = () => socket.reconnect();
553
- }
704
+ },
554
705
  });
555
706
  return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
556
- }
707
+ }