@gitpod/gitpod-protocol 0.1.5-main.628 → 0.1.5-main.6281

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