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