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