@gitpod/gitpod-protocol 0.1.5-main.648 → 0.1.5-main.6480

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 +90 -0
  78. package/lib/frontend-dashboard-service.d.ts.map +1 -0
  79. package/lib/frontend-dashboard-service.js +49 -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 +191 -55
  89. package/lib/gitpod-service.d.ts.map +1 -1
  90. package/lib/gitpod-service.js +204 -298
  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 +4 -6
  115. package/lib/messaging/browser/connection.d.ts.map +1 -1
  116. package/lib/messaging/browser/connection.js +176 -45
  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 +6 -5
  154. package/lib/plans.d.ts.map +1 -1
  155. package/lib/plans.js +230 -210
  156. package/lib/plans.js.map +1 -1
  157. package/lib/protocol.d.ts +261 -105
  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 +24 -5
  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 +137 -0
  178. package/lib/teams-projects-protocol.d.ts.map +1 -0
  179. package/lib/teams-projects-protocol.js +41 -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 +12 -7
  233. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  234. package/lib/util/gitpod-host-url.js +132 -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 +28 -8
  318. package/lib/workspace-cluster.d.ts.map +1 -1
  319. package/lib/workspace-cluster.js +20 -5
  320. package/lib/workspace-cluster.js.map +1 -1
  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 +125 -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 +369 -146
  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 +187 -28
  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 +250 -199
  370. package/src/protocol.spec.ts +97 -0
  371. package/src/protocol.ts +636 -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 +62 -23
  375. package/src/teams-projects-protocol.ts +181 -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 +88 -48
  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 +47 -17
  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,60 @@ 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
+ createOrgAuthProvider(params: GitpodServer.CreateOrgAuthProviderParams): Promise<AuthProviderEntry>;
179
+ updateOrgAuthProvider(params: GitpodServer.UpdateOrgAuthProviderParams): Promise<AuthProviderEntry>;
180
+ getOrgAuthProviders(params: GitpodServer.GetOrgAuthProviderParams): Promise<AuthProviderEntry[]>;
181
+ deleteOrgAuthProvider(params: GitpodServer.DeleteOrgAuthProviderParams): Promise<void>;
182
+
183
+ // Projects
184
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
185
+ createProject(params: CreateProjectParams): Promise<Project>;
186
+ deleteProject(projectId: string): Promise<void>;
187
+ getTeamProjects(teamId: string): Promise<Project[]>;
188
+ getUserProjects(): Promise<Project[]>;
189
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
190
+ getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
191
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
192
+ findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
193
+ getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
194
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
195
+ cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
196
+ updateProjectPartial(partialProject: PartialProject): Promise<void>;
197
+ setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
198
+ getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
199
+ deleteProjectEnvironmentVariable(variableId: string): Promise<void>;
200
+
113
201
  // content service
114
- getContentBlobUploadUrl(name: string): Promise<string>
115
- getContentBlobDownloadUrl(name: string): Promise<string>
202
+ getContentBlobUploadUrl(name: string): Promise<string>;
203
+ getContentBlobDownloadUrl(name: string): Promise<string>;
116
204
 
117
205
  // Gitpod token
118
206
  getGitpodTokens(): Promise<GitpodToken[]>;
@@ -120,38 +208,24 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
120
208
  deleteGitpodToken(tokenHash: string): Promise<void>;
121
209
 
122
210
  // misc
123
- sendFeedback(feedback: string): Promise<string | undefined>;
211
+ isGitHubAppEnabled(): Promise<boolean>;
124
212
  registerGithubApp(installationId: string): Promise<void>;
125
213
 
126
214
  /**
127
- * Stores a new snapshot for the given workspace and bucketId
215
+ * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
128
216
  * @return the snapshot id
129
217
  */
130
218
  takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
131
-
132
- /**
133
- * Returns the list of snapshots that exist for a workspace.
134
- */
135
- getSnapshots(workspaceID: string): Promise<string[]>;
136
-
137
- /**
138
- * stores/updates layout information for the given workspace
139
- */
140
- storeLayout(workspaceId: string, layoutData: string): Promise<void>;
141
-
142
219
  /**
143
- * retrieves layout information for the given workspace
220
+ *
221
+ * @param snapshotId
144
222
  */
145
- getLayout(workspaceId: string): Promise<string | undefined>;
223
+ waitForSnapshot(snapshotId: string): Promise<void>;
146
224
 
147
225
  /**
148
- * @param params
149
- * @returns promise resolves to an URL to be used for the upload
226
+ * Returns the list of snapshots that exist for a workspace.
150
227
  */
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>;
228
+ getSnapshots(workspaceID: string): Promise<string[]>;
155
229
 
156
230
  guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
157
231
 
@@ -159,80 +233,185 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
159
233
  * gitpod.io concerns
160
234
  */
161
235
  isStudent(): Promise<boolean>;
162
- getPrivateRepoTrialEndDate(): Promise<string | undefined>;
163
-
164
236
  /**
165
- *
237
+ *
166
238
  */
167
239
  getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
168
240
  getRemainingUsageHours(): Promise<number>;
169
241
 
170
242
  /**
171
- *
243
+ *
172
244
  */
173
245
  getChargebeeSiteId(): Promise<string>;
174
246
  createPortalSession(): Promise<{}>;
247
+ createTeamPortalSession(teamId: string): Promise<{}>;
175
248
  checkout(planId: string, planQuantity?: number): Promise<{}>;
249
+ teamCheckout(teamId: string, planId: string): Promise<{}>;
176
250
  getAvailableCoupons(): Promise<PlanCoupon[]>;
177
251
  getAppliedCoupons(): Promise<PlanCoupon[]>;
178
252
 
179
253
  getShowPaymentUI(): Promise<boolean>;
180
254
  isChargebeeCustomer(): Promise<boolean>;
181
- mayAccessPrivateRepo(): Promise<boolean>;
182
255
 
183
256
  subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
184
257
  subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
185
258
  subscriptionCancel(subscriptionId: string): Promise<void>;
186
259
  subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
187
260
 
261
+ getTeamSubscription(teamId: string): Promise<TeamSubscription2 | undefined>;
188
262
  tsGet(): Promise<TeamSubscription[]>;
189
263
  tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
190
- tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
264
+ tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
191
265
  tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
192
- tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string|undefined): Promise<void>
266
+ tsAssignSlot(
267
+ teamSubscriptionId: string,
268
+ teamSubscriptionSlotId: string,
269
+ identityStr: string | undefined,
270
+ ): Promise<void>;
193
271
  tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
194
272
  tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
195
273
  tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
196
274
 
197
275
  getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
198
276
 
277
+ getStripePublishableKey(): Promise<string>;
278
+ getStripeSetupIntentClientSecret(): Promise<string>;
279
+ findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
280
+ getPriceInformation(attributionId: string): Promise<string | undefined>;
281
+ createStripeCustomerIfNeeded(attributionId: string, currency: string): Promise<void>;
282
+ subscribeToStripe(attributionId: string, setupIntentId: string, usageLimit: number): Promise<number | undefined>;
283
+ getStripePortalUrl(attributionId: string): Promise<string>;
284
+ getCostCenter(attributionId: string): Promise<CostCenterJSON | undefined>;
285
+ setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
286
+ getUsageBalance(attributionId: string): Promise<number>;
287
+
288
+ listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
289
+
290
+ setUsageAttribution(usageAttribution: string): Promise<void>;
291
+ listAvailableUsageAttributionIds(): Promise<string[]>;
292
+
293
+ getBillingModeForUser(): Promise<BillingMode>;
294
+ getBillingModeForTeam(teamId: string): Promise<BillingMode>;
295
+
296
+ /**
297
+ * Analytics
298
+ */
299
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
300
+ trackLocation(event: RemotePageMessage): Promise<void>;
301
+ identifyUser(event: RemoteIdentifyMessage): Promise<void>;
302
+
303
+ /**
304
+ * Frontend notifications
305
+ */
306
+ getNotifications(): Promise<string[]>;
307
+
308
+ getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
199
309
  }
200
310
 
201
- export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
311
+ export interface RateLimiterError {
312
+ method?: string;
202
313
 
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));
314
+ /**
315
+ * Retry after this many seconds, earliest.
316
+ * cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
317
+ */
318
+ retryAfter: number;
319
+ }
320
+
321
+ export interface CreateProjectParams {
322
+ name: string;
323
+ slug: string;
324
+ cloneUrl: string;
325
+ teamId?: string;
326
+ userId?: string;
327
+ appInstallationId: string;
328
+ }
329
+ export interface FindPrebuildsParams {
330
+ projectId: string;
331
+ branch?: string;
332
+ latest?: boolean;
333
+ prebuildId?: string;
334
+ // default: 30
335
+ limit?: number;
336
+ }
337
+ export interface GetProviderRepositoriesParams {
338
+ provider: string;
339
+ hints?: { installationId: string } | object;
340
+ }
341
+ export interface ProviderRepository {
342
+ name: string;
343
+ path?: string;
344
+ account: string;
345
+ accountAvatarUrl: string;
346
+ cloneUrl: string;
347
+ updatedAt?: string;
348
+ installationId?: number;
349
+ installationUpdatedAt?: string;
350
+
351
+ inUse?: { userName: string };
352
+ }
353
+
354
+ export interface ClientHeaderFields {
355
+ ip?: string;
356
+ userAgent?: string;
357
+ dnt?: string;
358
+ clientRegion?: string;
359
+ }
360
+
361
+ export type WorkspaceTimeoutDuration = string;
362
+ export namespace WorkspaceTimeoutDuration {
363
+ export function validate(duration: string): WorkspaceTimeoutDuration {
364
+ const unit = duration.slice(-1);
365
+ if (!["m", "h", "d"].includes(unit)) {
366
+ throw new Error(`Invalid timeout unit: ${unit}`);
367
+ }
368
+ const value = parseInt(duration.slice(0, -1));
369
+ if (isNaN(value) || value <= 0) {
370
+ throw new Error(`Invalid timeout value: ${duration}`);
371
+ }
372
+ return duration;
373
+ }
205
374
  }
206
375
 
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 || (() => { });
376
+ export const WORKSPACE_TIMEOUT_DEFAULT_SHORT: WorkspaceTimeoutDuration = "30m";
377
+ export const WORKSPACE_TIMEOUT_DEFAULT_LONG: WorkspaceTimeoutDuration = "60m";
378
+ export const WORKSPACE_TIMEOUT_EXTENDED: WorkspaceTimeoutDuration = "180m";
379
+
380
+ export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
381
+ methods: Partial<JsonRpcProxy<S>>,
382
+ ): GitpodServiceImpl<C, S> {
383
+ return new GitpodServiceImpl<C, S>(createServerMock(methods));
384
+ };
385
+
386
+ export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
387
+ methods: Partial<JsonRpcProxy<S>>,
388
+ ): JsonRpcProxy<S> {
389
+ methods.setClient = methods.setClient || (() => {});
390
+ methods.dispose = methods.dispose || (() => {});
210
391
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
392
+ // @ts-ignore
211
393
  get: (target: S, property: keyof S) => {
212
394
  const result = target[property];
213
395
  if (!result) {
214
- throw new Error(`Method ${property} not implemented`);
396
+ throw new Error(`Method ${String(property)} not implemented`);
215
397
  }
216
398
  return result;
217
- }
399
+ },
218
400
  });
219
- }
220
-
221
- type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
222
- export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
401
+ };
223
402
 
224
403
  export interface SetWorkspaceTimeoutResult {
225
- resetTimeoutOnWorkspaces: string[]
404
+ resetTimeoutOnWorkspaces: string[];
226
405
  }
227
406
 
228
407
  export interface GetWorkspaceTimeoutResult {
229
- duration: WorkspaceTimeoutDuration
230
- canChange: boolean
408
+ duration: WorkspaceTimeoutDuration;
409
+ canChange: boolean;
231
410
  }
232
411
 
233
412
  export interface StartWorkspaceResult {
234
- instanceID: string
235
- workspaceURL?: string
413
+ instanceID: string;
414
+ workspaceURL?: string;
236
415
  }
237
416
 
238
417
  export namespace GitpodServer {
@@ -240,27 +419,31 @@ export namespace GitpodServer {
240
419
  limit?: number;
241
420
  searchString?: string;
242
421
  pinnedOnly?: boolean;
422
+ projectId?: string | string[];
423
+ includeWithoutProject?: boolean;
243
424
  }
244
425
  export interface GetAccountStatementOptions {
245
426
  date?: string;
246
427
  }
247
- export interface CreateWorkspaceOptions {
428
+ export interface CreateWorkspaceOptions extends StartWorkspaceOptions {
248
429
  contextUrl: string;
249
- mode?: CreateWorkspaceMode;
430
+
431
+ // whether running workspaces on the same context should be ignored. If false (default) users will be asked.
432
+ ignoreRunningWorkspaceOnSameCommit?: boolean;
433
+ ignoreRunningPrebuild?: boolean;
434
+ allowUsingPreviousPrebuilds?: boolean;
435
+ forceDefaultConfig?: boolean;
250
436
  }
437
+
251
438
  export interface StartWorkspaceOptions {
252
- forceDefaultImage: boolean;
439
+ forceDefaultImage?: boolean;
440
+ workspaceClass?: string;
441
+ ideSettings?: IDESettings;
253
442
  }
254
443
  export interface TakeSnapshotOptions {
255
444
  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[];
445
+ /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
446
+ dontWait?: boolean;
264
447
  }
265
448
  export interface GetUserStorageResourceOptions {
266
449
  readonly uri: string;
@@ -278,23 +461,36 @@ export namespace GitpodServer {
278
461
  readonly roundTripTime?: number;
279
462
  }
280
463
  export interface UpdateOwnAuthProviderParams {
281
- readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
464
+ readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
282
465
  }
283
466
  export interface DeleteOwnAuthProviderParams {
284
- readonly id: string
467
+ readonly id: string;
468
+ }
469
+ export interface CreateOrgAuthProviderParams {
470
+ readonly entry: AuthProviderEntry.NewOrgEntry;
471
+ }
472
+ export interface UpdateOrgAuthProviderParams {
473
+ readonly entry: AuthProviderEntry.UpdateOrgEntry;
474
+ }
475
+ export interface GetOrgAuthProviderParams {
476
+ readonly organizationId: string;
477
+ }
478
+ export interface DeleteOrgAuthProviderParams {
479
+ readonly id: string;
480
+ readonly organizationId: string;
285
481
  }
286
482
  export type AdmissionLevel = "owner" | "everyone";
287
483
  export type PinAction = "pin" | "unpin" | "toggle";
288
484
  export interface GenerateNewGitpodTokenOptions {
289
- name?: string
290
- type: GitpodTokenType
291
- scopes?: string[]
485
+ name?: string;
486
+ type: GitpodTokenType;
487
+ scopes?: string[];
292
488
  }
293
489
  }
294
490
 
295
- export const GitpodServerPath = '/gitpod';
491
+ export const GitpodServerPath = "/gitpod";
296
492
 
297
- export const GitpodServerProxy = Symbol('GitpodServerProxy');
493
+ export const GitpodServerProxy = Symbol("GitpodServerProxy");
298
494
  export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
299
495
 
300
496
  export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
@@ -302,12 +498,14 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
302
498
 
303
499
  public registerClient(client: Partial<Client>): Disposable {
304
500
  this.clients.push(client);
305
- const index = this.clients.length;
306
501
  return {
307
502
  dispose: () => {
308
- this.clients.slice(index, 1);
309
- }
310
- }
503
+ const index = this.clients.indexOf(client);
504
+ if (index > -1) {
505
+ this.clients.splice(index, 1);
506
+ }
507
+ },
508
+ };
311
509
  }
312
510
 
313
511
  onInstanceUpdate(instance: WorkspaceInstance): void {
@@ -316,31 +514,34 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
316
514
  try {
317
515
  client.onInstanceUpdate(instance);
318
516
  } catch (error) {
319
- console.error(error)
517
+ console.error(error);
320
518
  }
321
519
  }
322
520
  }
323
521
  }
324
522
 
325
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
523
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
326
524
  for (const client of this.clients) {
327
- if (client.onWorkspaceImageBuildLogs) {
525
+ if (client.onPrebuildUpdate) {
328
526
  try {
329
- client.onWorkspaceImageBuildLogs(info, content);
527
+ client.onPrebuildUpdate(update);
330
528
  } catch (error) {
331
- console.error(error)
529
+ console.error(error);
332
530
  }
333
531
  }
334
532
  }
335
533
  }
336
534
 
337
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
535
+ onWorkspaceImageBuildLogs(
536
+ info: WorkspaceImageBuild.StateInfo,
537
+ content: WorkspaceImageBuild.LogContent | undefined,
538
+ ): void {
338
539
  for (const client of this.clients) {
339
- if (client.onHeadlessWorkspaceLogs) {
540
+ if (client.onWorkspaceImageBuildLogs) {
340
541
  try {
341
- client.onHeadlessWorkspaceLogs(evt);
542
+ client.onWorkspaceImageBuildLogs(info, content);
342
543
  } catch (error) {
343
- console.error(error)
544
+ console.error(error);
344
545
  }
345
546
  }
346
547
  }
@@ -352,7 +553,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
352
553
  try {
353
554
  client.notifyDidOpenConnection();
354
555
  } catch (error) {
355
- console.error(error)
556
+ console.error(error);
356
557
  }
357
558
  }
358
559
  }
@@ -364,7 +565,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
364
565
  try {
365
566
  client.notifyDidCloseConnection();
366
567
  } catch (error) {
367
- console.error(error)
568
+ console.error(error);
368
569
  }
369
570
  }
370
571
  }
@@ -376,64 +577,73 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
376
577
  try {
377
578
  client.onCreditAlert(creditAlert);
378
579
  } catch (error) {
379
- console.error(error)
580
+ console.error(error);
380
581
  }
381
582
  }
382
583
  }
383
584
  }
384
585
 
586
+ onNotificationUpdated(): void {
587
+ for (const client of this.clients) {
588
+ if (client.onNotificationUpdated) {
589
+ try {
590
+ client.onNotificationUpdated();
591
+ } catch (error) {
592
+ console.error(error);
593
+ }
594
+ }
595
+ }
596
+ }
385
597
  }
386
598
 
387
599
  export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
388
600
 
389
- const hasWindow = (typeof window !== 'undefined');
601
+ const hasWindow = typeof window !== "undefined";
390
602
  const phasesOrder: Record<WorkspaceInstancePhase, number> = {
391
603
  unknown: 0,
392
604
  preparing: 1,
393
- pending: 2,
394
- creating: 3,
395
- initializing: 4,
396
- running: 5,
397
- interrupted: 6,
398
- stopping: 7,
399
- stopped: 8
605
+ building: 2,
606
+ pending: 3,
607
+ creating: 4,
608
+ initializing: 5,
609
+ running: 6,
610
+ interrupted: 7,
611
+ stopping: 8,
612
+ stopped: 9,
400
613
  };
401
614
  export class WorkspaceInstanceUpdateListener {
402
615
  private readonly onDidChangeEmitter = new Emitter<void>();
403
616
  readonly onDidChange = this.onDidChangeEmitter.event;
404
617
 
405
- private source: 'sync| 'update' = 'sync';
618
+ private source: "sync" | "update" = "sync";
406
619
 
407
620
  get info(): WorkspaceInfo {
408
621
  return this._info;
409
622
  }
410
623
 
411
- constructor(
412
- private readonly service: GitpodService,
413
- private _info: WorkspaceInfo
414
- ) {
624
+ constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
415
625
  service.registerClient({
416
- onInstanceUpdate: instance => {
626
+ onInstanceUpdate: (instance) => {
417
627
  if (this.isOutOfOrder(instance)) {
418
628
  return;
419
629
  }
420
630
  this.cancelSync();
421
631
  this._info.latestInstance = instance;
422
- this.source = 'update';
632
+ this.source = "update";
423
633
  this.onDidChangeEmitter.fire(undefined);
424
634
  },
425
635
  notifyDidOpenConnection: () => {
426
636
  this.sync();
427
- }
637
+ },
428
638
  });
429
639
  if (hasWindow) {
430
640
  // 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') {
641
+ window.document.addEventListener("visibilitychange", async () => {
642
+ if (window.document.visibilityState === "visible") {
433
643
  this.sync();
434
644
  }
435
645
  });
436
- window.addEventListener('pageshow', e => {
646
+ window.addEventListener("pageshow", (e) => {
437
647
  if (e.persisted) {
438
648
  this.sync();
439
649
  }
@@ -461,12 +671,12 @@ export class WorkspaceInstanceUpdateListener {
461
671
  return;
462
672
  }
463
673
  this._info = info;
464
- this.source = 'sync';
674
+ this.source = "sync";
465
675
  this.onDidChangeEmitter.fire(undefined);
466
676
  } catch (e) {
467
- console.error('failed to sync workspace instance:', e)
677
+ console.error("failed to sync workspace instance:", e);
468
678
  }
469
- })
679
+ });
470
680
  }
471
681
  private cancelSync(): void {
472
682
  if (this.syncTokenSource) {
@@ -483,7 +693,7 @@ export class WorkspaceInstanceUpdateListener {
483
693
  if (instance.workspaceId !== this._info.workspace.id) {
484
694
  return true;
485
695
  }
486
- if (this.source === 'update') {
696
+ if (this.source === "update") {
487
697
  return false;
488
698
  }
489
699
  if (instance.id !== this.info.latestInstance?.id) {
@@ -491,14 +701,16 @@ export class WorkspaceInstanceUpdateListener {
491
701
  }
492
702
  return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
493
703
  }
704
+ }
494
705
 
706
+ export interface GitpodServiceOptions {
707
+ onReconnect?: () => void | Promise<void>;
495
708
  }
496
709
 
497
710
  export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
498
-
499
711
  private readonly compositeClient = new GitpodCompositeClient<Client>();
500
712
 
501
- constructor(public readonly server: JsonRpcProxy<Server>) {
713
+ constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
502
714
  server.setClient(this.compositeClient);
503
715
  server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
504
716
  server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
@@ -510,7 +722,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
510
722
 
511
723
  private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
512
724
  listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
513
- const listener = this.instanceListeners.get(workspaceId) ||
725
+ const listener =
726
+ this.instanceListeners.get(workspaceId) ||
514
727
  (async () => {
515
728
  const info = await this.server.getWorkspace(workspaceId);
516
729
  return new WorkspaceInstanceUpdateListener(this, info);
@@ -518,23 +731,33 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
518
731
  this.instanceListeners.set(workspaceId, listener);
519
732
  return listener;
520
733
  }
734
+
735
+ async reconnect(): Promise<void> {
736
+ if (this.options?.onReconnect) {
737
+ await this.options.onReconnect();
738
+ }
739
+ }
521
740
  }
522
741
 
523
- export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
742
+ export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
743
+ serverUrl: string | Promise<string>,
744
+ ) {
524
745
  const toWsUrl = (serverUrl: string) => {
525
- return new GitpodHostUrl(serverUrl)
526
- .asWebsocket()
527
- .withApi({ pathname: GitpodServerPath })
528
- .toString();
746
+ return new GitpodHostUrl(serverUrl).asWebsocket().withApi({ pathname: GitpodServerPath }).toString();
529
747
  };
530
748
  let url: string | Promise<string>;
531
749
  if (typeof serverUrl === "string") {
532
750
  url = toWsUrl(serverUrl);
533
751
  } else {
534
- url = serverUrl.then(url => toWsUrl(url));
752
+ url = serverUrl.then((url) => toWsUrl(url));
535
753
  }
536
754
 
537
755
  const connectionProvider = new WebSocketConnectionProvider();
538
- const gitpodServer = connectionProvider.createProxy<S>(url);
539
- return new GitpodServiceImpl<C, S>(gitpodServer);
540
- }
756
+ let onReconnect = () => {};
757
+ const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
758
+ onListening: (socket) => {
759
+ onReconnect = () => socket.reconnect();
760
+ },
761
+ });
762
+ return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
763
+ }