@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
package/src/protocol.ts CHANGED
@@ -1,33 +1,33 @@
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 { WorkspaceInstance, PortVisibility } from "./workspace-instance";
8
8
  import { RoleOrPermission } from "./permission";
9
+ import { Project } from "./teams-projects-protocol";
10
+ import { createHash } from "crypto";
9
11
 
10
12
  export interface UserInfo {
11
- name?: string
13
+ name?: string;
12
14
  }
13
15
 
14
16
  export interface User {
15
17
  /** The user id */
16
- id: string
18
+ id: string;
17
19
 
18
20
  /** The timestamp when the user entry was created */
19
- creationDate: string
21
+ creationDate: string;
20
22
 
21
- avatarUrl?: string
23
+ avatarUrl?: string;
22
24
 
23
- name?: string
25
+ name?: string;
24
26
 
25
27
  /** Optional for backwards compatibility */
26
- fullName?: string
28
+ fullName?: string;
27
29
 
28
- identities: Identity[]
29
-
30
- allowsMarketingCommunication: boolean;
30
+ identities: Identity[];
31
31
 
32
32
  /**
33
33
  * Whether the user has been blocked to use our service, because of TOS violation for example.
@@ -45,38 +45,54 @@ export interface User {
45
45
  markedDeleted?: boolean;
46
46
 
47
47
  additionalData?: AdditionalUserData;
48
+
49
+ // Identifies an explicit team or user ID to which all the user's workspace usage should be attributed to (e.g. for billing purposes)
50
+ usageAttributionId?: string;
51
+
52
+ // The last time this user got verified somehow. The user is not verified if this is empty.
53
+ lastVerificationTime?: string;
54
+
55
+ // The phone number used for the last phone verification.
56
+ verificationPhoneNumber?: string;
48
57
  }
49
58
 
50
59
  export namespace User {
51
60
  export function is(data: any): data is User {
52
- return data
53
- && data.hasOwnProperty('id')
54
- && data.hasOwnProperty('identities')
61
+ return data && data.hasOwnProperty("id") && data.hasOwnProperty("identities");
55
62
  }
56
63
  export function getIdentity(user: User, authProviderId: string): Identity | undefined {
57
- return user.identities.find(id => id.authProviderId === authProviderId);
64
+ return user.identities.find((id) => id.authProviderId === authProviderId);
58
65
  }
59
66
  export function censor(user: User): User {
60
67
  const res = { ...user };
61
- delete (res.additionalData);
62
- res.identities = res.identities.map(i => {
63
- delete (i.tokens);
68
+ delete res.additionalData;
69
+ res.identities = res.identities.map((i) => {
70
+ delete i.tokens;
64
71
 
65
72
  // The user field is not in the Identity shape, but actually exists on DBIdentity.
66
73
  // Trying to push this object out via JSON RPC will fail because of the cyclic nature
67
74
  // of this field.
68
- delete ((i as any).user);
75
+ delete (i as any).user;
69
76
  return i;
70
77
  });
71
78
  return res;
72
79
  }
73
- export function getPrimaryEmail(user: User): string {
74
- const identities = user.identities.filter(i => !!i.primaryEmail);
80
+
81
+ /**
82
+ * Returns the stored email or if it doesn't exist returns the primaryEmail of the first identity this user signed up with.
83
+ * @param user
84
+ * @returns A primaryEmail, or undefined if there is none.
85
+ */
86
+ export function getPrimaryEmail(user: User): string | undefined {
87
+ if (user.additionalData?.profile?.emailAddress) {
88
+ return user.additionalData?.profile?.emailAddress;
89
+ }
90
+ const identities = user.identities.filter((i) => !!i.primaryEmail);
75
91
  if (identities.length <= 0) {
76
- throw new Error(`No identity with primary email for user: ${user.id}!`);
92
+ return undefined;
77
93
  }
78
94
 
79
- return identities[0].primaryEmail!;
95
+ return identities[0].primaryEmail || undefined;
80
96
  }
81
97
  export function getName(user: User): string | undefined {
82
98
  const name = user.fullName || user.name;
@@ -91,6 +107,91 @@ export namespace User {
91
107
  }
92
108
  return undefined;
93
109
  }
110
+
111
+ export function hasPreferredIde(user: User) {
112
+ return (
113
+ typeof user?.additionalData?.ideSettings?.defaultIde !== "undefined" ||
114
+ typeof user?.additionalData?.ideSettings?.useLatestVersion !== "undefined"
115
+ );
116
+ }
117
+
118
+ export function isOnboardingUser(user: User) {
119
+ return !hasPreferredIde(user);
120
+ }
121
+
122
+ export function migrationIDESettings(user: User) {
123
+ if (
124
+ !user?.additionalData?.ideSettings ||
125
+ Object.keys(user.additionalData.ideSettings).length === 0 ||
126
+ user.additionalData.ideSettings.settingVersion === "2.0"
127
+ ) {
128
+ return;
129
+ }
130
+ const newIDESettings: IDESettings = {
131
+ settingVersion: "2.0",
132
+ };
133
+ const ideSettings = user.additionalData.ideSettings;
134
+ if (ideSettings.useDesktopIde) {
135
+ if (ideSettings.defaultDesktopIde === "code-desktop") {
136
+ newIDESettings.defaultIde = "code-desktop";
137
+ } else if (ideSettings.defaultDesktopIde === "code-desktop-insiders") {
138
+ newIDESettings.defaultIde = "code-desktop";
139
+ newIDESettings.useLatestVersion = true;
140
+ } else {
141
+ newIDESettings.defaultIde = ideSettings.defaultDesktopIde;
142
+ newIDESettings.useLatestVersion = ideSettings.useLatestVersion;
143
+ }
144
+ } else {
145
+ const useLatest = ideSettings.defaultIde === "code-latest";
146
+ newIDESettings.defaultIde = "code";
147
+ newIDESettings.useLatestVersion = useLatest;
148
+ }
149
+ user.additionalData.ideSettings = newIDESettings;
150
+ }
151
+
152
+ export function getProfile(user: User): Profile {
153
+ return {
154
+ name: User.getName(user!) || "",
155
+ email: User.getPrimaryEmail(user!) || "",
156
+ company: user?.additionalData?.profile?.companyName,
157
+ avatarURL: user?.avatarUrl,
158
+ };
159
+ }
160
+
161
+ export function setProfile(user: User, profile: Profile): User {
162
+ user.fullName = profile.name;
163
+ user.avatarUrl = profile.avatarURL;
164
+
165
+ if (!user.additionalData) {
166
+ user.additionalData = {};
167
+ }
168
+ if (!user.additionalData.profile) {
169
+ user.additionalData.profile = {};
170
+ }
171
+ user.additionalData.profile.emailAddress = profile.email;
172
+ user.additionalData.profile.companyName = profile.company;
173
+ user.additionalData.profile.lastUpdatedDetailsNudge = new Date().toISOString();
174
+
175
+ return user;
176
+ }
177
+
178
+ // The actual Profile of a User
179
+ export interface Profile {
180
+ name: string;
181
+ email: string;
182
+ company?: string;
183
+ avatarURL?: string;
184
+ }
185
+ export namespace Profile {
186
+ export function hasChanges(before: Profile, after: Profile) {
187
+ return (
188
+ before.name !== after.name ||
189
+ before.email !== after.email ||
190
+ before.company !== after.company ||
191
+ before.avatarURL !== after.avatarURL
192
+ );
193
+ }
194
+ }
94
195
  }
95
196
 
96
197
  export interface AdditionalUserData {
@@ -99,15 +200,66 @@ export interface AdditionalUserData {
99
200
  featurePreview?: boolean;
100
201
  ideSettings?: IDESettings;
101
202
  // key is the name of the news, string the iso date when it was seen
102
- whatsNewSeen?: { [key: string]: string }
203
+ whatsNewSeen?: { [key: string]: string };
204
+ // key is the name of the OAuth client i.e. local app, string the iso date when it was approved
205
+ // TODO(rl): provide a management UX to allow rescinding of approval
206
+ oauthClientsApproved?: { [key: string]: string };
207
+ // to remember GH Orgs the user installed/updated the GH App for
208
+ knownGitHubOrgs?: string[];
209
+ // Git clone URL pointing to the user's dotfile repo
210
+ dotfileRepo?: string;
211
+ // preferred workspace classes
212
+ workspaceClasses?: WorkspaceClasses;
213
+ // additional user profile data
214
+ profile?: ProfileDetails;
215
+ // whether the user has been migrated to team attribution.
216
+ // a corresponding feature flag (team_only_attribution) triggers the migration.
217
+ isMigratedToTeamOnlyAttribution?: boolean;
218
+ }
219
+ export namespace AdditionalUserData {
220
+ export function set(user: User, partialData: Partial<AdditionalUserData>): User {
221
+ if (!user.additionalData) {
222
+ user.additionalData = {
223
+ ...partialData,
224
+ };
225
+ } else {
226
+ user.additionalData = {
227
+ ...user.additionalData,
228
+ ...partialData,
229
+ };
230
+ }
231
+ return user;
232
+ }
233
+ }
234
+ // The format in which we store User Profiles in
235
+ export interface ProfileDetails {
236
+ // when was the last time the user updated their profile information or has been nudged to do so.
237
+ lastUpdatedDetailsNudge?: string;
238
+ // the user's company name
239
+ companyName?: string;
240
+ // the user's email
241
+ emailAddress?: string;
103
242
  }
104
243
 
105
244
  export interface EmailNotificationSettings {
106
- disallowTransactionalEmails?: boolean;
245
+ allowsChangelogMail?: boolean;
246
+ allowsDevXMail?: boolean;
247
+ allowsOnboardingMail?: boolean;
107
248
  }
108
249
 
109
250
  export type IDESettings = {
110
- defaultIde?: string
251
+ settingVersion?: string;
252
+ defaultIde?: string;
253
+ // DEPRECATED: Use defaultIde after `settingVersion: 2.0`, no more specialify desktop or browser.
254
+ useDesktopIde?: boolean;
255
+ // DEPRECATED: Same with useDesktopIde.
256
+ defaultDesktopIde?: string;
257
+ useLatestVersion?: boolean;
258
+ };
259
+
260
+ export interface WorkspaceClasses {
261
+ regular?: string;
262
+ prebuild?: string;
111
263
  }
112
264
 
113
265
  export interface UserPlatform {
@@ -129,14 +281,6 @@ export interface UserPlatform {
129
281
  }
130
282
 
131
283
  export interface UserFeatureSettings {
132
- /**
133
- * This field is used as marker to grant users a free trial for using private repositories,
134
- * independent of any subscription or Chargebee.
135
- * - it is set when the user uses their first private repo
136
- * - whether the trial is expired or not is juged by the UserService
137
- */
138
- privateRepoTrialStartDate?: string;
139
-
140
284
  /**
141
285
  * Permanent feature flags are added to each and every workspace instance
142
286
  * this user starts.
@@ -144,19 +288,43 @@ export interface UserFeatureSettings {
144
288
  permanentWSFeatureFlags?: NamedWorkspaceFeatureFlag[];
145
289
  }
146
290
 
291
+ export type BillingTier = "paid" | "free";
292
+
147
293
  /**
148
294
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
149
295
  * If they don't we'll break things during workspace startup.
150
296
  */
151
- export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
152
- export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
297
+ export const WorkspaceFeatureFlags = {
298
+ full_workspace_backup: undefined,
299
+ workspace_class_limiting: undefined,
300
+ workspace_connection_limiting: undefined,
301
+ workspace_psi: undefined,
302
+ };
303
+ export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
304
+ export namespace NamedWorkspaceFeatureFlag {
305
+ export const WORKSPACE_PERSISTED_FEATTURE_FLAGS: NamedWorkspaceFeatureFlag[] = ["full_workspace_backup"];
306
+ export function isWorkspacePersisted(ff: NamedWorkspaceFeatureFlag): boolean {
307
+ return WORKSPACE_PERSISTED_FEATTURE_FLAGS.includes(ff);
308
+ }
309
+ }
153
310
 
154
- export interface UserEnvVarValue {
155
- id?: string;
311
+ export interface EnvVarWithValue {
156
312
  name: string;
157
- repositoryPattern: string;
158
313
  value: string;
159
314
  }
315
+
316
+ export interface ProjectEnvVarWithValue extends EnvVarWithValue {
317
+ id: string;
318
+ projectId: string;
319
+ censored: boolean;
320
+ }
321
+
322
+ export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, "value">;
323
+
324
+ export interface UserEnvVarValue extends EnvVarWithValue {
325
+ id?: string;
326
+ repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
327
+ }
160
328
  export interface UserEnvVar extends UserEnvVarValue {
161
329
  id: string;
162
330
  userId: string;
@@ -164,11 +332,51 @@ export interface UserEnvVar extends UserEnvVarValue {
164
332
  }
165
333
 
166
334
  export namespace UserEnvVar {
335
+ /**
336
+ * @param variable
337
+ * @returns Either a string containing an error message or undefined.
338
+ */
339
+ export function validate(variable: UserEnvVarValue): string | undefined {
340
+ const name = variable.name;
341
+ const pattern = variable.repositoryPattern;
342
+ if (name.trim() === "") {
343
+ return "Name must not be empty.";
344
+ }
345
+ if (name.length > 255) {
346
+ return "Name too long. Maximum name length is 255 characters.";
347
+ }
348
+ if (!/^[a-zA-Z_]+[a-zA-Z0-9_]*$/.test(name)) {
349
+ return "Name must match /^[a-zA-Z_]+[a-zA-Z0-9_]*$/.";
350
+ }
351
+ if (variable.value.trim() === "") {
352
+ return "Value must not be empty.";
353
+ }
354
+ if (variable.value.length > 32767) {
355
+ return "Value too long. Maximum value length is 32767 characters.";
356
+ }
357
+ if (pattern.trim() === "") {
358
+ return "Scope must not be empty.";
359
+ }
360
+ const split = pattern.split("/");
361
+ if (split.length < 2) {
362
+ return "A scope must use the form 'organization/repo'.";
363
+ }
364
+ for (const name of split) {
365
+ if (name !== "*") {
366
+ if (!/^[a-zA-Z0-9_\-.\*]+$/.test(name)) {
367
+ return "Invalid scope segment. Only ASCII characters, numbers, -, _, . or * are allowed.";
368
+ }
369
+ }
370
+ }
371
+ return undefined;
372
+ }
167
373
 
374
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
168
375
  export function normalizeRepoPattern(pattern: string) {
169
376
  return pattern.toLocaleLowerCase();
170
377
  }
171
378
 
379
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
172
380
  export function score(value: UserEnvVarValue): number {
173
381
  // We use a score to enforce precedence:
174
382
  // value/value = 0
@@ -182,7 +390,7 @@ export namespace UserEnvVar {
182
390
  if (repoPattern == "*") {
183
391
  score += 1;
184
392
  }
185
- if (ownerPattern == '*') {
393
+ if (ownerPattern == "*") {
186
394
  score += 2;
187
395
  }
188
396
  if (ownerPattern == "#" || repoPattern == "#") {
@@ -191,21 +399,22 @@ export namespace UserEnvVar {
191
399
  return score;
192
400
  }
193
401
 
402
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
194
403
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
195
- let result = vars.filter(e => {
404
+ let result = vars.filter((e) => {
196
405
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
197
- if (ownerPattern !== '*' && ownerPattern !== '#' && (!!owner && ownerPattern !== owner.toLocaleLowerCase())) {
406
+ if (ownerPattern !== "*" && ownerPattern !== "#" && !!owner && ownerPattern !== owner.toLocaleLowerCase()) {
198
407
  return false;
199
408
  }
200
- if (repoPattern !== '*' && repoPattern !== '#' && (!!repo && repoPattern !== repo.toLocaleLowerCase())) {
409
+ if (repoPattern !== "*" && repoPattern !== "#" && !!repo && repoPattern !== repo.toLocaleLowerCase()) {
201
410
  return false;
202
411
  }
203
412
  return true;
204
413
  });
205
414
 
206
415
  const resmap = new Map<string, T[]>();
207
- result.forEach(e => {
208
- const l = (resmap.get(e.name) || []);
416
+ result.forEach((e) => {
417
+ const l = resmap.get(e.name) || [];
209
418
  l.push(e);
210
419
  resmap.set(e.name, l);
211
420
  });
@@ -238,47 +447,109 @@ export namespace UserEnvVar {
238
447
  return result;
239
448
  }
240
449
 
450
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
241
451
  export function splitRepositoryPattern(repositoryPattern: string): string[] {
242
- const patterns = repositoryPattern.split('/');
243
- const repoPattern = patterns.pop() || "";
244
- const ownerPattern = patterns.join('/');
452
+ const patterns = repositoryPattern.split("/");
453
+ const repoPattern = patterns.slice(1).join("/");
454
+ const ownerPattern = patterns[0];
245
455
  return [ownerPattern, repoPattern];
246
456
  }
247
457
  }
248
458
 
249
- export interface GitpodToken {
459
+ export interface SSHPublicKeyValue {
460
+ name: string;
461
+ key: string;
462
+ }
463
+ export interface UserSSHPublicKey extends SSHPublicKeyValue {
464
+ id: string;
465
+ key: string;
466
+ userId: string;
467
+ fingerprint: string;
468
+ creationTime: string;
469
+ lastUsedTime?: string;
470
+ }
471
+
472
+ export type UserSSHPublicKeyValue = Omit<UserSSHPublicKey, "userId">;
250
473
 
474
+ export namespace SSHPublicKeyValue {
475
+ export function validate(value: SSHPublicKeyValue): string | undefined {
476
+ if (value.name.length === 0) {
477
+ return "Title must not be empty.";
478
+ }
479
+ if (value.name.length > 255) {
480
+ return "Title too long. Maximum value length is 255 characters.";
481
+ }
482
+ if (value.key.length === 0) {
483
+ return "Key must not be empty.";
484
+ }
485
+ try {
486
+ getData(value);
487
+ } catch (e) {
488
+ return "Key is invalid. You must supply a key in OpenSSH public key format.";
489
+ }
490
+ return;
491
+ }
492
+
493
+ export function getData(value: SSHPublicKeyValue) {
494
+ // Begins with 'ssh-rsa', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'ssh-ed25519', 'sk-ecdsa-sha2-nistp256@openssh.com', or 'sk-ssh-ed25519@openssh.com'.
495
+ const regex =
496
+ /^(?<type>ssh-rsa|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521|ssh-ed25519|sk-ecdsa-sha2-nistp256@openssh\.com|sk-ssh-ed25519@openssh\.com) (?<key>.*?)( (?<email>.*?))?$/;
497
+ const resultGroup = regex.exec(value.key.trim());
498
+ if (!resultGroup) {
499
+ throw new Error("Key is invalid.");
500
+ }
501
+ return {
502
+ type: resultGroup.groups?.["type"] as string,
503
+ key: resultGroup.groups?.["key"] as string,
504
+ email: resultGroup.groups?.["email"] || undefined,
505
+ };
506
+ }
507
+
508
+ export function getFingerprint(value: SSHPublicKeyValue) {
509
+ const data = getData(value);
510
+ let buf = Buffer.from(data.key, "base64");
511
+ // gitlab style
512
+ // const hash = createHash("md5").update(buf).digest("hex");
513
+ // github style
514
+ const hash = createHash("sha256").update(buf).digest("base64");
515
+ return hash;
516
+ }
517
+
518
+ export const MAXIMUM_KEY_LENGTH = 5;
519
+ }
520
+
521
+ export interface GitpodToken {
251
522
  /** Hash value (SHA256) of the token (primary key). */
252
- tokenHash: string
523
+ tokenHash: string;
253
524
 
254
525
  /** Human readable name of the token */
255
- name?: string
526
+ name?: string;
256
527
 
257
528
  /** Token kind */
258
- type: GitpodTokenType
529
+ type: GitpodTokenType;
259
530
 
260
531
  /** The user the token belongs to. */
261
- user: User
532
+ user: User;
262
533
 
263
534
  /** Scopes (e.g. limition to read-only) */
264
- scopes: string[]
535
+ scopes: string[];
265
536
 
266
537
  /** Created timestamp */
267
- created: string
538
+ created: string;
268
539
 
269
540
  // token is deleted on the database and about to be collected by db-sync
270
- deleted?: boolean
541
+ deleted?: boolean;
271
542
  }
272
543
 
273
544
  export enum GitpodTokenType {
274
545
  API_AUTH_TOKEN = 0,
275
- MACHINE_AUTH_TOKEN = 1
546
+ MACHINE_AUTH_TOKEN = 1,
276
547
  }
277
548
 
278
549
  export interface OneTimeSecret {
279
- id: string
550
+ id: string;
280
551
 
281
- value: string
552
+ value: string;
282
553
 
283
554
  expirationTime: string;
284
555
 
@@ -310,13 +581,12 @@ export type IdentityLookup = Pick<Identity, "authProviderId" | "authId">;
310
581
 
311
582
  export namespace Identity {
312
583
  export function is(data: any): data is Identity {
313
- return data.hasOwnProperty('authProviderId')
314
- && data.hasOwnProperty('authId')
315
- && data.hasOwnProperty('authName')
584
+ return (
585
+ data.hasOwnProperty("authProviderId") && data.hasOwnProperty("authId") && data.hasOwnProperty("authName")
586
+ );
316
587
  }
317
588
  export function equals(id1: IdentityLookup, id2: IdentityLookup) {
318
- return id1.authProviderId === id2.authProviderId
319
- && id1.authId === id2.authId
589
+ return id1.authProviderId === id2.authProviderId && id1.authId === id2.authId;
320
590
  }
321
591
  }
322
592
 
@@ -367,21 +637,20 @@ export interface PendingGithubEvent {
367
637
  creationDate: Date;
368
638
  type: string;
369
639
  event: string;
640
+ deleted: boolean;
370
641
  }
371
642
 
372
643
  export interface Snapshot {
373
644
  id: string;
374
645
  creationTime: string;
646
+ availableTime?: string;
375
647
  originalWorkspaceId: string;
376
648
  bucketId: string;
377
- layoutData?: string;
649
+ state: SnapshotState;
650
+ message?: string;
378
651
  }
379
652
 
380
- export interface LayoutData {
381
- workspaceId: string;
382
- lastUpdatedTime: string;
383
- layoutData: string;
384
- }
653
+ export type SnapshotState = "pending" | "available" | "error";
385
654
 
386
655
  export interface Workspace {
387
656
  id: string;
@@ -389,6 +658,7 @@ export interface Workspace {
389
658
  contextURL: string;
390
659
  description: string;
391
660
  ownerId: string;
661
+ projectId?: string;
392
662
  context: WorkspaceContext;
393
663
  config: WorkspaceConfig;
394
664
 
@@ -403,13 +673,13 @@ export interface Workspace {
403
673
  * The resolved, fix name of the workspace image. We only use this
404
674
  * to access the logs during an image build.
405
675
  */
406
- imageNameResolved?: string
676
+ imageNameResolved?: string;
407
677
 
408
678
  /**
409
679
  * The resolved/built fixed named of the base image. This field is only set if the workspace
410
680
  * already has its base image built.
411
681
  */
412
- baseImageNameResolved?: string
682
+ baseImageNameResolved?: string;
413
683
 
414
684
  shareable?: boolean;
415
685
  pinned?: boolean;
@@ -443,20 +713,19 @@ export interface Workspace {
443
713
 
444
714
  export type WorkspaceSoftDeletion = "user" | "gc";
445
715
 
446
- export type WorkspaceType = "regular" | "prebuild" | "probe";
716
+ export type WorkspaceType = "regular" | "prebuild";
447
717
 
448
718
  export namespace Workspace {
449
-
450
719
  export function getFullRepositoryName(ws: Workspace): string | undefined {
451
720
  if (CommitContext.is(ws.context)) {
452
- return ws.context.repository.owner + '/' + ws.context.repository.name
721
+ return ws.context.repository.owner + "/" + ws.context.repository.name;
453
722
  }
454
723
  return undefined;
455
724
  }
456
725
 
457
726
  export function getFullRepositoryUrl(ws: Workspace): string | undefined {
458
727
  if (CommitContext.is(ws.context)) {
459
- return `https://${ws.context.repository.host}/${getFullRepositoryName(ws)}`
728
+ return `https://${ws.context.repository.host}/${getFullRepositoryName(ws)}`;
460
729
  }
461
730
  return undefined;
462
731
  }
@@ -490,59 +759,60 @@ export namespace Workspace {
490
759
  }
491
760
  }
492
761
 
493
- export interface PreparePluginUploadParams {
494
- fullPluginName: string;
495
- }
496
-
497
- export interface ResolvePluginsParams {
498
- config?: WorkspaceConfig
499
- builtins?: ResolvedPlugins
500
- vsxRegistryUrl?: string
501
- }
502
-
503
- export interface InstallPluginsParams {
504
- pluginIds: string[]
505
- }
506
-
507
- export interface UninstallPluginParams {
508
- pluginId: string;
509
- }
510
-
511
762
  export interface GuessGitTokenScopesParams {
512
- host: string
513
- repoUrl: string
514
- gitCommand: string
515
- currentToken: GitToken
763
+ host: string;
764
+ repoUrl: string;
765
+ gitCommand: string;
766
+ currentToken: GitToken;
516
767
  }
517
768
 
518
769
  export interface GitToken {
519
- token: string
520
- user: string
521
- scopes: string[]
770
+ token: string;
771
+ user: string;
772
+ scopes: string[];
522
773
  }
523
774
 
524
775
  export interface GuessedGitTokenScopes {
525
- message?: string
526
- scopes?: string[]
776
+ message?: string;
777
+ scopes?: string[];
527
778
  }
528
779
 
529
- export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
780
+ export interface VSCodeConfig {
781
+ extensions?: string[];
782
+ }
530
783
 
531
- export interface ResolvedPlugins {
532
- [pluginId: string]: ResolvedPlugin | undefined
784
+ export interface JetBrainsConfig {
785
+ intellij?: JetBrainsProductConfig;
786
+ goland?: JetBrainsProductConfig;
787
+ pycharm?: JetBrainsProductConfig;
788
+ phpstorm?: JetBrainsProductConfig;
789
+ rubymine?: JetBrainsProductConfig;
790
+ webstorm?: JetBrainsProductConfig;
791
+ rider?: JetBrainsProductConfig;
792
+ clion?: JetBrainsProductConfig;
793
+ }
794
+ export interface JetBrainsProductConfig {
795
+ prebuilds?: JetBrainsPrebuilds;
796
+ vmoptions?: string;
797
+ }
798
+ export interface JetBrainsPrebuilds {
799
+ version?: "stable" | "latest" | "both";
533
800
  }
534
801
 
535
- export interface ResolvedPlugin {
536
- fullPluginName: string;
802
+ export interface RepositoryCloneInformation {
537
803
  url: string;
538
- kind: ResolvedPluginKind;
804
+ checkoutLocation?: string;
539
805
  }
540
806
 
541
- export interface VSCodeConfig {
542
- extensions?: string[];
807
+ export interface CoreDumpConfig {
808
+ enabled?: boolean;
809
+ softLimit?: number;
810
+ hardLimit?: number;
543
811
  }
544
812
 
545
813
  export interface WorkspaceConfig {
814
+ mainConfiguration?: string;
815
+ additionalRepositories?: RepositoryCloneInformation[];
546
816
  image?: ImageConfig;
547
817
  ports?: PortConfig[];
548
818
  tasks?: TaskConfig[];
@@ -551,6 +821,11 @@ export interface WorkspaceConfig {
551
821
  gitConfig?: { [config: string]: string };
552
822
  github?: GithubAppConfig;
553
823
  vscode?: VSCodeConfig;
824
+ jetbrains?: JetBrainsConfig;
825
+ coreDump?: CoreDumpConfig;
826
+
827
+ /** deprecated. Enabled by default **/
828
+ experimentalNetwork?: boolean;
554
829
 
555
830
  /**
556
831
  * Where the config object originates from.
@@ -558,9 +833,10 @@ export interface WorkspaceConfig {
558
833
  * repo - from the repository
559
834
  * definitly-gp - from github.com/gitpod-io/definitely-gp
560
835
  * derived - computed based on analyzing the repository
836
+ * additional-content - config comes from additional content, usually provided through the project's configuration
561
837
  * default - our static catch-all default config
562
838
  */
563
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
839
+ _origin?: "repo" | "definitely-gp" | "derived" | "additional-content" | "default";
564
840
 
565
841
  /**
566
842
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -570,37 +846,33 @@ export interface WorkspaceConfig {
570
846
  }
571
847
 
572
848
  export interface GithubAppConfig {
573
- prebuilds?: GithubAppPrebuildConfig
849
+ prebuilds?: GithubAppPrebuildConfig;
574
850
  }
575
851
  export interface GithubAppPrebuildConfig {
576
- master?: boolean
577
- branches?: boolean
578
- pullRequests?: boolean
579
- pullRequestsFromForks?: boolean
580
- addCheck?: boolean
581
- addBadge?: boolean
582
- addLabel?: boolean | string
583
- addComment?: boolean
852
+ master?: boolean;
853
+ branches?: boolean;
854
+ pullRequests?: boolean;
855
+ pullRequestsFromForks?: boolean;
856
+ addCheck?: boolean | "prevent-merge-on-error";
857
+ addBadge?: boolean;
858
+ addLabel?: boolean | string;
859
+ addComment?: boolean;
584
860
  }
585
861
  export namespace GithubAppPrebuildConfig {
586
862
  export function is(obj: boolean | GithubAppPrebuildConfig): obj is GithubAppPrebuildConfig {
587
- return !(typeof obj === 'boolean');
863
+ return !(typeof obj === "boolean");
588
864
  }
589
865
  }
590
866
 
591
867
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
592
868
  export interface WorkspaceImageSourceDocker {
593
- // TODO: clean this up. We should have the commit and an ImageSource in here, not duplicate the whole thing again.
594
- // We have a ton of those objects in the database, thus cleaning this up means lengthy DB migrations. Yuck.
595
- dockerFileHash: string
596
- dockerFileSource: Commit
597
- dockerFilePath: string
869
+ dockerFilePath: string;
870
+ dockerFileHash: string;
871
+ dockerFileSource?: Commit;
598
872
  }
599
873
  export namespace WorkspaceImageSourceDocker {
600
874
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
601
- return 'dockerFileHash' in obj
602
- && 'dockerFileSource' in obj
603
- && 'dockerFilePath' in obj;
875
+ return "dockerFileHash" in obj && "dockerFilePath" in obj;
604
876
  }
605
877
  }
606
878
  export interface WorkspaceImageSourceReference {
@@ -609,36 +881,43 @@ export interface WorkspaceImageSourceReference {
609
881
  }
610
882
  export namespace WorkspaceImageSourceReference {
611
883
  export function is(obj: object): obj is WorkspaceImageSourceReference {
612
- return 'baseImageResolved' in obj;
884
+ return "baseImageResolved" in obj;
613
885
  }
614
886
  }
615
887
 
616
- export type PrebuiltWorkspaceState
888
+ export type PrebuiltWorkspaceState =
617
889
  // the prebuild is queued and may start at anytime
618
- = "queued"
890
+ | "queued"
619
891
  // the workspace prebuild is currently running (i.e. there's a workspace pod deployed)
620
892
  | "building"
621
- // the prebuild failed due to some issue with the system (e.g. missed a message, could not start workspace)
893
+ // the prebuild was aborted
622
894
  | "aborted"
623
895
  // the prebuild timed out
624
896
  | "timeout"
625
- // the prebuild has finished and a snapshot is available
626
- | "available";
897
+ // the prebuild has finished (even if a headless task failed) and a snapshot is available
898
+ | "available"
899
+ // the prebuild (headless workspace) failed due to some system error
900
+ | "failed";
627
901
 
628
902
  export interface PrebuiltWorkspace {
629
903
  id: string;
630
904
  cloneURL: string;
905
+ branch?: string;
906
+ projectId?: string;
631
907
  commit: string;
632
908
  buildWorkspaceId: string;
633
909
  creationTime: string;
634
910
  state: PrebuiltWorkspaceState;
911
+ statusVersion: number;
635
912
  error?: string;
636
913
  snapshot?: string;
637
914
  }
638
915
 
639
916
  export namespace PrebuiltWorkspace {
640
917
  export function isDone(pws: PrebuiltWorkspace) {
641
- return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
918
+ return (
919
+ pws.state === "available" || pws.state === "timeout" || pws.state === "aborted" || pws.state === "failed"
920
+ );
642
921
  }
643
922
 
644
923
  export function isAvailable(pws: PrebuiltWorkspace) {
@@ -657,27 +936,33 @@ export interface PrebuiltWorkspaceUpdatable {
657
936
  repo: string;
658
937
  isResolved: boolean;
659
938
  installationId: string;
939
+ /**
940
+ * the commitSHA of the commit that triggered the prebuild
941
+ */
942
+ commitSHA?: string;
660
943
  issue?: string;
661
944
  contextUrl?: string;
662
945
  }
663
946
 
664
947
  export interface WhitelistedRepository {
665
- url: string
666
- name: string
667
- description?: string
668
- avatar?: string
948
+ url: string;
949
+ name: string;
950
+ description?: string;
951
+ avatar?: string;
669
952
  }
670
953
 
671
- export type PortOnOpen = 'open-browser' | 'open-preview' | 'notify' | 'ignore';
954
+ export type PortOnOpen = "open-browser" | "open-preview" | "notify" | "ignore";
672
955
 
673
956
  export interface PortConfig {
674
957
  port: number;
675
958
  onOpen?: PortOnOpen;
676
959
  visibility?: PortVisibility;
960
+ description?: string;
961
+ name?: string;
677
962
  }
678
963
  export namespace PortConfig {
679
964
  export function is(config: any): config is PortConfig {
680
- return config && ('port' in config) && (typeof config.port === 'number');
965
+ return config && "port" in config && typeof config.port === "number";
681
966
  }
682
967
  }
683
968
 
@@ -687,7 +972,7 @@ export interface PortRangeConfig {
687
972
  }
688
973
  export namespace PortRangeConfig {
689
974
  export function is(config: any): config is PortRangeConfig {
690
- return config && ('port' in config) && (typeof config.port === 'string' || config.port instanceof String);
975
+ return config && "port" in config && (typeof config.port === "string" || config.port instanceof String);
691
976
  }
692
977
  }
693
978
 
@@ -697,33 +982,32 @@ export interface TaskConfig {
697
982
  init?: string;
698
983
  prebuild?: string;
699
984
  command?: string;
700
- env?: { [env: string]: string };
701
- openIn?: 'bottom' | 'main' | 'left' | 'right';
702
- openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
985
+ env?: { [env: string]: any };
986
+ openIn?: "bottom" | "main" | "left" | "right";
987
+ openMode?: "split-top" | "split-left" | "split-right" | "split-bottom" | "tab-before" | "tab-after";
703
988
  }
704
989
 
705
990
  export namespace TaskConfig {
706
991
  export function is(config: any): config is TaskConfig {
707
- return config
708
- && ('command' in config || 'init' in config || 'before' in config);
992
+ return config && ("command" in config || "init" in config || "before" in config);
709
993
  }
710
994
  }
711
995
 
712
996
  export namespace WorkspaceImageBuild {
713
- export type Phase = 'BaseImage' | 'GitpodLayer' | 'Error' | 'Done';
997
+ export type Phase = "BaseImage" | "GitpodLayer" | "Error" | "Done";
714
998
  export interface StateInfo {
715
- phase: Phase
716
- currentStep?: number
717
- maxSteps?: number
999
+ phase: Phase;
1000
+ currentStep?: number;
1001
+ maxSteps?: number;
718
1002
  }
719
1003
  export interface LogContent {
720
- text: string
721
- upToLine?: number
722
- isDiff?: boolean
1004
+ text: string;
1005
+ upToLine?: number;
1006
+ isDiff?: boolean;
723
1007
  }
724
1008
  export type LogCallback = (info: StateInfo, content: LogContent | undefined) => void;
725
1009
  export namespace LogLine {
726
- export const DELIMITER = '\r\n';
1010
+ export const DELIMITER = "\r\n";
727
1011
  export const DELIMITER_REGEX = /\r?\n/;
728
1012
  }
729
1013
  }
@@ -732,20 +1016,18 @@ export type ImageConfig = ImageConfigString | ImageConfigFile;
732
1016
  export type ImageConfigString = string;
733
1017
  export namespace ImageConfigString {
734
1018
  export function is(config: ImageConfig | undefined): config is ImageConfigString {
735
- return typeof config === 'string';
1019
+ return typeof config === "string";
736
1020
  }
737
-
738
1021
  }
739
1022
  export interface ImageConfigFile {
740
1023
  // Path to the Dockerfile relative to repository root
741
- file: string,
1024
+ file: string;
742
1025
  // Path to the docker build context relative to repository root
743
- context?: string
1026
+ context?: string;
744
1027
  }
745
1028
  export namespace ImageConfigFile {
746
1029
  export function is(config: ImageConfig | undefined): config is ImageConfigFile {
747
- return typeof config === 'object'
748
- && 'file' in config;
1030
+ return typeof config === "object" && "file" in config;
749
1031
  }
750
1032
  }
751
1033
  export interface ExternalImageConfigFile extends ImageConfigFile {
@@ -753,22 +1035,22 @@ export interface ExternalImageConfigFile extends ImageConfigFile {
753
1035
  }
754
1036
  export namespace ExternalImageConfigFile {
755
1037
  export function is(config: any | undefined): config is ExternalImageConfigFile {
756
- return typeof config === 'object'
757
- && 'file' in config
758
- && 'externalSource' in config;
1038
+ return typeof config === "object" && "file" in config && "externalSource" in config;
759
1039
  }
760
1040
  }
761
1041
 
762
1042
  export interface WorkspaceContext {
763
1043
  title: string;
1044
+ ref?: string;
1045
+ /** This contains the URL portion of the contextURL (which might contain other modifiers as well). It's optional because it's not set for older workspaces. */
764
1046
  normalizedContextURL?: string;
765
1047
  forceCreateNewWorkspace?: boolean;
1048
+ forceImageBuild?: boolean;
766
1049
  }
767
1050
 
768
1051
  export namespace WorkspaceContext {
769
1052
  export function is(context: any): context is WorkspaceContext {
770
- return context
771
- && 'title' in context;
1053
+ return context && "title" in context;
772
1054
  }
773
1055
  }
774
1056
 
@@ -777,22 +1059,38 @@ export interface WithSnapshot {
777
1059
  }
778
1060
  export namespace WithSnapshot {
779
1061
  export function is(context: any): context is WithSnapshot {
780
- return context
781
- && 'snapshotBucketId' in context;
1062
+ return context && "snapshotBucketId" in context;
782
1063
  }
783
1064
  }
784
1065
 
785
- export interface WithPrebuild {
786
- snapshotBucketId: string;
1066
+ export interface WithPrebuild extends WithSnapshot {
787
1067
  prebuildWorkspaceId: string;
788
1068
  wasPrebuilt: true;
789
1069
  }
790
1070
  export namespace WithPrebuild {
791
1071
  export function is(context: any): context is WithPrebuild {
792
- return context
793
- && 'snapshotBucketId' in context
794
- && 'prebuildWorkspaceId' in context
795
- && 'wasPrebuilt' in context;
1072
+ return context && WithSnapshot.is(context) && "prebuildWorkspaceId" in context && "wasPrebuilt" in context;
1073
+ }
1074
+ }
1075
+
1076
+ /**
1077
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
1078
+ * and fall back to the built-in configuration.
1079
+ */
1080
+ export interface WithDefaultConfig {
1081
+ withDefaultConfig: true;
1082
+ }
1083
+
1084
+ export namespace WithDefaultConfig {
1085
+ export function is(context: any): context is WithDefaultConfig {
1086
+ return context && "withDefaultConfig" in context && context.withDefaultConfig;
1087
+ }
1088
+
1089
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
1090
+ return {
1091
+ ...ctx,
1092
+ withDefaultConfig: true,
1093
+ };
796
1094
  }
797
1095
  }
798
1096
 
@@ -802,20 +1100,27 @@ export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
802
1100
 
803
1101
  export namespace SnapshotContext {
804
1102
  export function is(context: any): context is SnapshotContext {
805
- return context
806
- && WithSnapshot.is(context)
807
- && 'snapshotId' in context;
1103
+ return context && WithSnapshot.is(context) && "snapshotId" in context;
808
1104
  }
809
1105
  }
810
1106
 
811
- export interface StartPrebuildContext extends WorkspaceContext {
1107
+ export interface WithCommitHistory {
1108
+ commitHistory?: string[];
1109
+ additionalRepositoryCommitHistories?: {
1110
+ cloneUrl: string;
1111
+ commitHistory: string[];
1112
+ }[];
1113
+ }
1114
+
1115
+ export interface StartPrebuildContext extends WorkspaceContext, WithCommitHistory {
812
1116
  actual: WorkspaceContext;
1117
+ project: Project;
1118
+ branch?: string;
813
1119
  }
814
1120
 
815
1121
  export namespace StartPrebuildContext {
816
1122
  export function is(context: any): context is StartPrebuildContext {
817
- return context
818
- && 'actual' in context;
1123
+ return context && "actual" in context;
819
1124
  }
820
1125
  }
821
1126
 
@@ -827,33 +1132,28 @@ export interface PrebuiltWorkspaceContext extends WorkspaceContext {
827
1132
 
828
1133
  export namespace PrebuiltWorkspaceContext {
829
1134
  export function is(context: any): context is PrebuiltWorkspaceContext {
830
- return context
831
- && 'originalContext' in context
832
- && 'prebuiltWorkspace' in context;
1135
+ return context && "originalContext" in context && "prebuiltWorkspace" in context;
833
1136
  }
834
1137
  }
835
1138
 
836
- export interface WithEnvvarsContext extends WorkspaceContext {
837
- envvars: UserEnvVarValue[];
1139
+ export interface WithReferrerContext extends WorkspaceContext {
1140
+ referrer: string;
1141
+ referrerIde?: string;
838
1142
  }
839
1143
 
840
- export namespace WithEnvvarsContext {
841
- export function is(context: any): context is WithEnvvarsContext {
842
- return context
843
- && 'envvars' in context
1144
+ export namespace WithReferrerContext {
1145
+ export function is(context: any): context is WithReferrerContext {
1146
+ return context && "referrer" in context;
844
1147
  }
845
1148
  }
846
1149
 
847
- export interface WorkspaceProbeContext extends WorkspaceContext {
848
- responseURL: string
849
- responseToken: string
1150
+ export interface WithEnvvarsContext extends WorkspaceContext {
1151
+ envvars: EnvVarWithValue[];
850
1152
  }
851
1153
 
852
- export namespace WorkspaceProbeContext {
853
- export function is(context: any): context is WorkspaceProbeContext {
854
- return context
855
- && 'responseURL' in context
856
- && 'responseToken' in context;
1154
+ export namespace WithEnvvarsContext {
1155
+ export function is(context: any): context is WithEnvvarsContext {
1156
+ return context && "envvars" in context;
857
1157
  }
858
1158
  }
859
1159
 
@@ -865,30 +1165,90 @@ export namespace RefType {
865
1165
  }
866
1166
  // This fallback is meant to handle the cases where (for historic reasons) ref is present but refType is missing
867
1167
  return commit.refType || "branch";
868
- }
1168
+ };
869
1169
  }
870
1170
 
871
1171
  export interface Commit {
872
- repository: Repository
873
- revision: string
1172
+ repository: Repository;
1173
+ revision: string;
874
1174
 
875
1175
  // Might contain either a branch or a tag (determined by refType)
876
- ref?: string
1176
+ ref?: string;
877
1177
 
878
1178
  // refType is only set if ref is present (and not for old workspaces, before this feature was added)
879
- refType?: RefType
1179
+ refType?: RefType;
880
1180
  }
881
1181
 
882
- export interface CommitContext extends WorkspaceContext, Commit {
1182
+ export interface AdditionalContentContext extends WorkspaceContext {
1183
+ /**
1184
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
1185
+ */
1186
+ additionalFiles: { [filePath: string]: string };
1187
+ }
1188
+
1189
+ export namespace AdditionalContentContext {
1190
+ export function is(ctx: any): ctx is AdditionalContentContext {
1191
+ return "additionalFiles" in ctx;
1192
+ }
1193
+
1194
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
1195
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
1196
+ }
1197
+ }
1198
+
1199
+ export interface OpenPrebuildContext extends WorkspaceContext {
1200
+ openPrebuildID: string;
1201
+ }
1202
+
1203
+ export namespace OpenPrebuildContext {
1204
+ export function is(ctx: any): ctx is OpenPrebuildContext {
1205
+ return "openPrebuildID" in ctx;
1206
+ }
1207
+ }
1208
+
1209
+ export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
883
1210
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
884
- cloneUrl?: string
1211
+ cloneUrl?: string;
1212
+
1213
+ /**
1214
+ * The clone and checkout information for additional repositories in case of multi-repo projects.
1215
+ */
1216
+ additionalRepositoryCheckoutInfo?: GitCheckoutInfo[];
1217
+ }
1218
+
1219
+ export namespace CommitContext {
1220
+ /**
1221
+ * Creates a hash for all the commits of the CommitContext and all sub-repo commit infos.
1222
+ * The hash is max 255 chars long.
1223
+ * @param commitContext
1224
+ * @returns hash for commitcontext
1225
+ */
1226
+ export function computeHash(commitContext: CommitContext): string {
1227
+ // for single commits we use the revision to be backward compatible.
1228
+ if (
1229
+ !commitContext.additionalRepositoryCheckoutInfo ||
1230
+ commitContext.additionalRepositoryCheckoutInfo.length === 0
1231
+ ) {
1232
+ return commitContext.revision;
1233
+ }
1234
+ const hasher = createHash("sha256");
1235
+ hasher.update(commitContext.revision);
1236
+ for (const info of commitContext.additionalRepositoryCheckoutInfo) {
1237
+ hasher.update(info.revision);
1238
+ }
1239
+ return hasher.digest("hex");
1240
+ }
1241
+ }
1242
+
1243
+ export interface GitCheckoutInfo extends Commit {
1244
+ checkoutLocation?: string;
1245
+ upstreamRemoteURI?: string;
1246
+ localBranch?: string;
885
1247
  }
886
1248
 
887
1249
  export namespace CommitContext {
888
1250
  export function is(commit: any): commit is CommitContext {
889
- return WorkspaceContext.is(commit)
890
- && 'repository' in commit
891
- && 'revision' in commit
1251
+ return WorkspaceContext.is(commit) && "repository" in commit && "revision" in commit;
892
1252
  }
893
1253
  }
894
1254
 
@@ -896,17 +1256,14 @@ export interface PullRequestContext extends CommitContext {
896
1256
  nr: number;
897
1257
  ref: string;
898
1258
  base: {
899
- repository: Repository
900
- ref: string
901
- }
1259
+ repository: Repository;
1260
+ ref: string;
1261
+ };
902
1262
  }
903
1263
 
904
1264
  export namespace PullRequestContext {
905
1265
  export function is(ctx: any): ctx is PullRequestContext {
906
- return CommitContext.is(ctx)
907
- && 'nr' in ctx
908
- && 'ref' in ctx
909
- && 'base' in ctx
1266
+ return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "base" in ctx;
910
1267
  }
911
1268
  }
912
1269
 
@@ -918,10 +1275,7 @@ export interface IssueContext extends CommitContext {
918
1275
 
919
1276
  export namespace IssueContext {
920
1277
  export function is(ctx: any): ctx is IssueContext {
921
- return CommitContext.is(ctx)
922
- && 'nr' in ctx
923
- && 'ref' in ctx
924
- && 'localBranch' in ctx
1278
+ return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "localBranch" in ctx;
925
1279
  }
926
1280
  }
927
1281
 
@@ -932,9 +1286,7 @@ export interface NavigatorContext extends CommitContext {
932
1286
 
933
1287
  export namespace NavigatorContext {
934
1288
  export function is(ctx: any): ctx is NavigatorContext {
935
- return CommitContext.is(ctx)
936
- && 'path' in ctx
937
- && 'isFile' in ctx
1289
+ return CommitContext.is(ctx) && "path" in ctx && "isFile" in ctx;
938
1290
  }
939
1291
  }
940
1292
 
@@ -943,6 +1295,8 @@ export interface Repository {
943
1295
  owner: string;
944
1296
  name: string;
945
1297
  cloneUrl: string;
1298
+ /* Optional kind to differentiate between repositories of orgs/groups/projects and personal repos. */
1299
+ repoKind?: string;
946
1300
  description?: string;
947
1301
  avatarUrl?: string;
948
1302
  webUrl?: string;
@@ -951,8 +1305,21 @@ export interface Repository {
951
1305
  private?: boolean;
952
1306
  fork?: {
953
1307
  // The direct parent of this fork
954
- parent: Repository
955
- }
1308
+ parent: Repository;
1309
+ };
1310
+ }
1311
+ export interface Branch {
1312
+ name: string;
1313
+ commit: CommitInfo;
1314
+ htmlUrl: string;
1315
+ }
1316
+
1317
+ export interface CommitInfo {
1318
+ author: string;
1319
+ sha: string;
1320
+ commitMessage: string;
1321
+ authorAvatarUrl?: string;
1322
+ authorDate?: string;
956
1323
  }
957
1324
 
958
1325
  export namespace Repository {
@@ -964,21 +1331,19 @@ export namespace Repository {
964
1331
  export interface WorkspaceInstancePortsChangedEvent {
965
1332
  type: "PortsChanged";
966
1333
  instanceID: string;
967
- portsOpened: number[]
968
- portsClosed: number[]
1334
+ portsOpened: number[];
1335
+ portsClosed: number[];
969
1336
  }
970
1337
 
971
1338
  export namespace WorkspaceInstancePortsChangedEvent {
972
-
973
1339
  export function is(data: any): data is WorkspaceInstancePortsChangedEvent {
974
1340
  return data && data.type == "PortsChanged";
975
1341
  }
976
-
977
1342
  }
978
1343
 
979
1344
  export interface WorkspaceInfo {
980
- workspace: Workspace
981
- latestInstance?: WorkspaceInstance
1345
+ workspace: Workspace;
1346
+ latestInstance?: WorkspaceInstance;
982
1347
  }
983
1348
 
984
1349
  export namespace WorkspaceInfo {
@@ -994,34 +1359,25 @@ export interface WorkspaceCreationResult {
994
1359
  workspaceURL?: string;
995
1360
  existingWorkspaces?: WorkspaceInfo[];
996
1361
  runningWorkspacePrebuild?: {
997
- prebuildID: string
998
- workspaceID: string
999
- starting: RunningWorkspacePrebuildStarting
1000
- sameCluster: boolean
1001
- }
1362
+ prebuildID: string;
1363
+ workspaceID: string;
1364
+ instanceID: string;
1365
+ starting: RunningWorkspacePrebuildStarting;
1366
+ sameCluster: boolean;
1367
+ };
1002
1368
  runningPrebuildWorkspaceID?: string;
1003
1369
  }
1004
- export type RunningWorkspacePrebuildStarting = 'queued' | 'starting' | 'running';
1005
-
1006
- export enum CreateWorkspaceMode {
1007
- // Default returns a running prebuild if there is any, otherwise creates a new workspace (using a prebuild if one is available)
1008
- Default = 'default',
1009
- // ForceNew creates a new workspace irrespective of any running prebuilds. This mode is guaranteed to actually create a workspace - but may degrade user experience as currently runnig prebuilds are ignored.
1010
- ForceNew = 'force-new',
1011
- // UsePrebuild polls the database waiting for a currently running prebuild to become available. This mode exists to handle the db-sync delay.
1012
- UsePrebuild = 'use-prebuild',
1013
- // SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
1014
- SelectIfRunning = 'select-if-running',
1015
- }
1370
+ export type RunningWorkspacePrebuildStarting = "queued" | "starting" | "running";
1016
1371
 
1017
1372
  export namespace WorkspaceCreationResult {
1018
1373
  export function is(data: any): data is WorkspaceCreationResult {
1019
- return data && (
1020
- 'createdWorkspaceId' in data
1021
- || 'existingWorkspaces' in data
1022
- || 'runningWorkspacePrebuild' in data
1023
- || 'runningPrebuildWorkspaceID' in data
1024
- )
1374
+ return (
1375
+ data &&
1376
+ ("createdWorkspaceId" in data ||
1377
+ "existingWorkspaces" in data ||
1378
+ "runningWorkspacePrebuild" in data ||
1379
+ "runningPrebuildWorkspaceID" in data)
1380
+ );
1025
1381
  }
1026
1382
  }
1027
1383
 
@@ -1055,7 +1411,7 @@ export interface AuthProviderInfo {
1055
1411
  readonly default: string[];
1056
1412
  readonly publicRepo: string[];
1057
1413
  readonly privateRepo: string[];
1058
- }
1414
+ };
1059
1415
  }
1060
1416
 
1061
1417
  export interface AuthProviderEntry {
@@ -1063,10 +1419,13 @@ export interface AuthProviderEntry {
1063
1419
  readonly type: AuthProviderEntry.Type;
1064
1420
  readonly host: string;
1065
1421
  readonly ownerId: string;
1422
+ readonly organizationId?: string;
1066
1423
 
1067
1424
  readonly status: AuthProviderEntry.Status;
1068
1425
 
1069
1426
  readonly oauth: OAuth2Config;
1427
+ /** A random string that is to change whenever oauth changes (enforced on DB level) */
1428
+ readonly oauthRevision?: string;
1070
1429
  }
1071
1430
 
1072
1431
  export interface OAuth2Config {
@@ -1079,56 +1438,35 @@ export interface OAuth2Config {
1079
1438
  readonly scopeSeparator?: string;
1080
1439
 
1081
1440
  readonly settingsUrl?: string;
1082
- readonly authorizationParams?: { [key: string]: string }
1441
+ readonly authorizationParams?: { [key: string]: string };
1083
1442
  readonly configURL?: string;
1084
1443
  }
1085
1444
 
1086
1445
  export namespace AuthProviderEntry {
1087
1446
  export type Type = "GitHub" | "GitLab" | string;
1088
1447
  export type Status = "pending" | "verified";
1089
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1090
- export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
1448
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & {
1449
+ clientId?: string;
1450
+ clientSecret?: string;
1451
+ };
1452
+ export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> &
1453
+ Pick<OAuth2Config, "clientId" | "clientSecret">;
1454
+ export type NewOrgEntry = NewEntry & {
1455
+ organizationId: string;
1456
+ };
1457
+ export type UpdateOrgEntry = Pick<AuthProviderEntry, "id"> & {
1458
+ clientId: string;
1459
+ clientSecret: string;
1460
+ organizationId: string;
1461
+ };
1091
1462
  export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1092
1463
  return {
1093
1464
  ...entry,
1094
1465
  oauth: {
1095
1466
  ...entry.oauth,
1096
- clientSecret: "redacted"
1097
- }
1098
- }
1099
- }
1100
- }
1101
-
1102
- export interface Branding {
1103
- readonly name: string;
1104
- readonly favicon?: string;
1105
- /** Either including domain OR absolute path (interpreted relative to host URL) */
1106
- readonly logo: string;
1107
- readonly startupLogo: string;
1108
- readonly showProductivityTips: boolean;
1109
- readonly redirectUrlIfNotAuthenticated?: string;
1110
- readonly redirectUrlAfterLogout?: string;
1111
- readonly homepage: string;
1112
- readonly ide?: {
1113
- readonly logo: string;
1114
- readonly showReleaseNotes: boolean;
1115
- readonly helpMenu: Branding.Link[];
1116
- }
1117
- readonly links: {
1118
- readonly header: Branding.Link[];
1119
- readonly footer: Branding.Link[];
1120
- readonly social: Branding.SocialLink[];
1121
- readonly legal: Branding.Link[];
1122
- }
1123
- }
1124
- export namespace Branding {
1125
- export interface Link {
1126
- readonly name: string;
1127
- readonly url: string;
1128
- }
1129
- export interface SocialLink {
1130
- readonly type: string;
1131
- readonly url: string;
1467
+ clientSecret: "redacted",
1468
+ },
1469
+ };
1132
1470
  }
1133
1471
  }
1134
1472
 
@@ -1172,3 +1510,8 @@ export interface Terms {
1172
1510
  readonly content: string;
1173
1511
  readonly formElements?: object;
1174
1512
  }
1513
+
1514
+ export interface StripeConfig {
1515
+ individualUsagePriceIds: { [currency: string]: string };
1516
+ teamUsagePriceIds: { [currency: string]: string };
1517
+ }