@gitpod/gitpod-protocol 0.1.5-tweak-workspaceconfig-origin-docs-fork.0 → 0.1.5-update-yarnlock.0

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