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