@gitpod/gitpod-protocol 0.1.5-wth-argo.0 → 0.1.5-yh-vmoptions-fork.1

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