@gitpod/gitpod-protocol 0.1.5-patch-1-fork.0 → 0.1.5-pavel-pvc-feat.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 (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 +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 +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 +175 -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 +7 -1
  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 +163 -82
  117. package/lib/protocol.d.ts.map +1 -1
  118. package/lib/protocol.js +184 -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 +31 -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 +28 -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 +10 -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 +383 -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 +28 -26
  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,30 @@ 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);
151
-
152
- export interface UserEnvVarValue {
153
- id?: string;
154
+ export const WorkspaceFeatureFlags = {
155
+ full_workspace_backup: undefined,
156
+ fixed_resources: undefined,
157
+ persistent_volume_claim: undefined,
158
+ };
159
+ export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
160
+
161
+ export interface EnvVarWithValue {
154
162
  name: string;
155
- repositoryPattern: string;
156
163
  value: string;
157
164
  }
165
+
166
+ export interface ProjectEnvVarWithValue extends EnvVarWithValue {
167
+ id: string;
168
+ projectId: string;
169
+ censored: boolean;
170
+ }
171
+
172
+ export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, "value">;
173
+
174
+ export interface UserEnvVarValue extends EnvVarWithValue {
175
+ id?: string;
176
+ repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
177
+ }
158
178
  export interface UserEnvVar extends UserEnvVarValue {
159
179
  id: string;
160
180
  userId: string;
@@ -162,26 +182,50 @@ export interface UserEnvVar extends UserEnvVarValue {
162
182
  }
163
183
 
164
184
  export namespace UserEnvVar {
165
-
185
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
166
186
  export function normalizeRepoPattern(pattern: string) {
167
187
  return pattern.toLocaleLowerCase();
168
188
  }
169
189
 
190
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
191
+ export function score(value: UserEnvVarValue): number {
192
+ // We use a score to enforce precedence:
193
+ // value/value = 0
194
+ // value/* = 1
195
+ // */value = 2
196
+ // */* = 3
197
+ // #/# = 4 (used for env vars passed through the URL)
198
+ // the lower the score, the higher the precedence.
199
+ const [ownerPattern, repoPattern] = splitRepositoryPattern(value.repositoryPattern);
200
+ let score = 0;
201
+ if (repoPattern == "*") {
202
+ score += 1;
203
+ }
204
+ if (ownerPattern == "*") {
205
+ score += 2;
206
+ }
207
+ if (ownerPattern == "#" || repoPattern == "#") {
208
+ score = 4;
209
+ }
210
+ return score;
211
+ }
212
+
213
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
170
214
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
171
- let result = vars.filter(e => {
215
+ let result = vars.filter((e) => {
172
216
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
173
- if (ownerPattern !== '*' && ownerPattern !== '#' && (!!owner && ownerPattern !== owner.toLocaleLowerCase())) {
217
+ if (ownerPattern !== "*" && ownerPattern !== "#" && !!owner && ownerPattern !== owner.toLocaleLowerCase()) {
174
218
  return false;
175
219
  }
176
- if (repoPattern !== '*' && repoPattern !== '#' && (!!repo && repoPattern !== repo.toLocaleLowerCase())) {
220
+ if (repoPattern !== "*" && repoPattern !== "#" && !!repo && repoPattern !== repo.toLocaleLowerCase()) {
177
221
  return false;
178
222
  }
179
223
  return true;
180
224
  });
181
225
 
182
226
  const resmap = new Map<string, T[]>();
183
- result.forEach(e => {
184
- const l = (resmap.get(e.name) || []);
227
+ result.forEach((e) => {
228
+ const l = resmap.get(e.name) || [];
185
229
  l.push(e);
186
230
  resmap.set(e.name, l);
187
231
  });
@@ -202,25 +246,7 @@ export namespace UserEnvVar {
202
246
  let minscore = 10;
203
247
  let bestCandidate: T | undefined;
204
248
  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
-
249
+ const score = UserEnvVar.score(e);
224
250
  if (!bestCandidate || score < minscore) {
225
251
  minscore = score;
226
252
  bestCandidate = e;
@@ -232,47 +258,47 @@ export namespace UserEnvVar {
232
258
  return result;
233
259
  }
234
260
 
235
- function splitRepositoryPattern(repositoryPattern: string): string[] {
236
- const patterns = repositoryPattern.split('/');
237
- const repoPattern = patterns.pop() || "";
238
- const ownerPattern = patterns.join('/');
261
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
262
+ export function splitRepositoryPattern(repositoryPattern: string): string[] {
263
+ const patterns = repositoryPattern.split("/");
264
+ const repoPattern = patterns.slice(1).join("/");
265
+ const ownerPattern = patterns[0];
239
266
  return [ownerPattern, repoPattern];
240
267
  }
241
268
  }
242
269
 
243
270
  export interface GitpodToken {
244
-
245
271
  /** Hash value (SHA256) of the token (primary key). */
246
- tokenHash: string
272
+ tokenHash: string;
247
273
 
248
274
  /** Human readable name of the token */
249
- name?: string
275
+ name?: string;
250
276
 
251
277
  /** Token kind */
252
- type: GitpodTokenType
278
+ type: GitpodTokenType;
253
279
 
254
280
  /** The user the token belongs to. */
255
- user: User
281
+ user: User;
256
282
 
257
283
  /** Scopes (e.g. limition to read-only) */
258
- scopes: string[]
284
+ scopes: string[];
259
285
 
260
286
  /** Created timestamp */
261
- created: string
287
+ created: string;
262
288
 
263
289
  // token is deleted on the database and about to be collected by db-sync
264
- deleted?: boolean
290
+ deleted?: boolean;
265
291
  }
266
292
 
267
293
  export enum GitpodTokenType {
268
294
  API_AUTH_TOKEN = 0,
269
- MACHINE_AUTH_TOKEN = 1
295
+ MACHINE_AUTH_TOKEN = 1,
270
296
  }
271
297
 
272
298
  export interface OneTimeSecret {
273
- id: string
299
+ id: string;
274
300
 
275
- value: string
301
+ value: string;
276
302
 
277
303
  expirationTime: string;
278
304
 
@@ -304,13 +330,12 @@ export type IdentityLookup = Pick<Identity, "authProviderId" | "authId">;
304
330
 
305
331
  export namespace Identity {
306
332
  export function is(data: any): data is Identity {
307
- return data.hasOwnProperty('authProviderId')
308
- && data.hasOwnProperty('authId')
309
- && data.hasOwnProperty('authName')
333
+ return (
334
+ data.hasOwnProperty("authProviderId") && data.hasOwnProperty("authId") && data.hasOwnProperty("authName")
335
+ );
310
336
  }
311
337
  export function equals(id1: IdentityLookup, id2: IdentityLookup) {
312
- return id1.authProviderId === id2.authProviderId
313
- && id1.authId === id2.authId
338
+ return id1.authProviderId === id2.authProviderId && id1.authId === id2.authId;
314
339
  }
315
340
  }
316
341
 
@@ -366,11 +391,16 @@ export interface PendingGithubEvent {
366
391
  export interface Snapshot {
367
392
  id: string;
368
393
  creationTime: string;
394
+ availableTime?: string;
369
395
  originalWorkspaceId: string;
370
396
  bucketId: string;
371
397
  layoutData?: string;
398
+ state: SnapshotState;
399
+ message?: string;
372
400
  }
373
401
 
402
+ export type SnapshotState = "pending" | "available" | "error";
403
+
374
404
  export interface LayoutData {
375
405
  workspaceId: string;
376
406
  lastUpdatedTime: string;
@@ -383,6 +413,7 @@ export interface Workspace {
383
413
  contextURL: string;
384
414
  description: string;
385
415
  ownerId: string;
416
+ projectId?: string;
386
417
  context: WorkspaceContext;
387
418
  config: WorkspaceConfig;
388
419
 
@@ -397,13 +428,13 @@ export interface Workspace {
397
428
  * The resolved, fix name of the workspace image. We only use this
398
429
  * to access the logs during an image build.
399
430
  */
400
- imageNameResolved?: string
431
+ imageNameResolved?: string;
401
432
 
402
433
  /**
403
434
  * The resolved/built fixed named of the base image. This field is only set if the workspace
404
435
  * already has its base image built.
405
436
  */
406
- baseImageNameResolved?: string
437
+ baseImageNameResolved?: string;
407
438
 
408
439
  shareable?: boolean;
409
440
  pinned?: boolean;
@@ -440,17 +471,16 @@ export type WorkspaceSoftDeletion = "user" | "gc";
440
471
  export type WorkspaceType = "regular" | "prebuild" | "probe";
441
472
 
442
473
  export namespace Workspace {
443
-
444
474
  export function getFullRepositoryName(ws: Workspace): string | undefined {
445
475
  if (CommitContext.is(ws.context)) {
446
- return ws.context.repository.owner + '/' + ws.context.repository.name
476
+ return ws.context.repository.owner + "/" + ws.context.repository.name;
447
477
  }
448
478
  return undefined;
449
479
  }
450
480
 
451
481
  export function getFullRepositoryUrl(ws: Workspace): string | undefined {
452
482
  if (CommitContext.is(ws.context)) {
453
- return `https://${ws.context.repository.host}/${getFullRepositoryName(ws)}`
483
+ return `https://${ws.context.repository.host}/${getFullRepositoryName(ws)}`;
454
484
  }
455
485
  return undefined;
456
486
  }
@@ -484,41 +514,36 @@ export namespace Workspace {
484
514
  }
485
515
  }
486
516
 
487
- export interface PreparePluginUploadParams {
488
- fullPluginName: string;
489
- }
490
-
491
- export interface ResolvePluginsParams {
492
- config?: WorkspaceConfig
493
- builtins?: ResolvedPlugins
494
- vsxRegistryUrl?: string
517
+ export interface GuessGitTokenScopesParams {
518
+ host: string;
519
+ repoUrl: string;
520
+ gitCommand: string;
521
+ currentToken: GitToken;
495
522
  }
496
523
 
497
- export interface InstallPluginsParams {
498
- pluginIds: string[]
524
+ export interface GitToken {
525
+ token: string;
526
+ user: string;
527
+ scopes: string[];
499
528
  }
500
529
 
501
- export interface UninstallPluginParams {
502
- pluginId: string;
530
+ export interface GuessedGitTokenScopes {
531
+ message?: string;
532
+ scopes?: string[];
503
533
  }
504
534
 
505
- export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
506
-
507
- export interface ResolvedPlugins {
508
- [pluginId: string]: ResolvedPlugin | undefined
535
+ export interface VSCodeConfig {
536
+ extensions?: string[];
509
537
  }
510
538
 
511
- export interface ResolvedPlugin {
512
- fullPluginName: string;
539
+ export interface RepositoryCloneInformation {
513
540
  url: string;
514
- kind: ResolvedPluginKind;
515
- }
516
-
517
- export interface VSCodeConfig {
518
- extensions?: string[];
541
+ checkoutLocation?: string;
519
542
  }
520
543
 
521
544
  export interface WorkspaceConfig {
545
+ mainConfiguration?: string;
546
+ additionalRepositories?: RepositoryCloneInformation[];
522
547
  image?: ImageConfig;
523
548
  ports?: PortConfig[];
524
549
  tasks?: TaskConfig[];
@@ -527,16 +552,21 @@ export interface WorkspaceConfig {
527
552
  gitConfig?: { [config: string]: string };
528
553
  github?: GithubAppConfig;
529
554
  vscode?: VSCodeConfig;
530
-
555
+
556
+ /** deprecated. Enabled by default **/
557
+ experimentalNetwork?: boolean;
558
+
531
559
  /**
532
560
  * Where the config object originates from.
533
- *
561
+ *
534
562
  * repo - from the repository
563
+ * project-db - from the "Project" stored in the database
535
564
  * definitly-gp - from github.com/gitpod-io/definitely-gp
536
565
  * derived - computed based on analyzing the repository
566
+ * additional-content - config comes from additional content, usually provided through the project's configuration
537
567
  * default - our static catch-all default config
538
568
  */
539
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
569
+ _origin?: "repo" | "project-db" | "definitely-gp" | "derived" | "additional-content" | "default";
540
570
 
541
571
  /**
542
572
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -546,37 +576,33 @@ export interface WorkspaceConfig {
546
576
  }
547
577
 
548
578
  export interface GithubAppConfig {
549
- prebuilds?: GithubAppPrebuildConfig
579
+ prebuilds?: GithubAppPrebuildConfig;
550
580
  }
551
581
  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
582
+ master?: boolean;
583
+ branches?: boolean;
584
+ pullRequests?: boolean;
585
+ pullRequestsFromForks?: boolean;
586
+ addCheck?: boolean | "prevent-merge-on-error";
587
+ addBadge?: boolean;
588
+ addLabel?: boolean | string;
589
+ addComment?: boolean;
560
590
  }
561
591
  export namespace GithubAppPrebuildConfig {
562
592
  export function is(obj: boolean | GithubAppPrebuildConfig): obj is GithubAppPrebuildConfig {
563
- return !(typeof obj === 'boolean');
593
+ return !(typeof obj === "boolean");
564
594
  }
565
595
  }
566
596
 
567
597
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
568
598
  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
599
+ dockerFilePath: string;
600
+ dockerFileHash: string;
601
+ dockerFileSource?: Commit;
574
602
  }
575
603
  export namespace WorkspaceImageSourceDocker {
576
604
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
577
- return 'dockerFileHash' in obj
578
- && 'dockerFileSource' in obj
579
- && 'dockerFilePath' in obj;
605
+ return "dockerFileHash" in obj && "dockerFilePath" in obj;
580
606
  }
581
607
  }
582
608
  export interface WorkspaceImageSourceReference {
@@ -585,25 +611,29 @@ export interface WorkspaceImageSourceReference {
585
611
  }
586
612
  export namespace WorkspaceImageSourceReference {
587
613
  export function is(obj: object): obj is WorkspaceImageSourceReference {
588
- return 'baseImageResolved' in obj;
614
+ return "baseImageResolved" in obj;
589
615
  }
590
616
  }
591
617
 
592
- export type PrebuiltWorkspaceState
618
+ export type PrebuiltWorkspaceState =
593
619
  // the prebuild is queued and may start at anytime
594
- = "queued"
620
+ | "queued"
595
621
  // the workspace prebuild is currently running (i.e. there's a workspace pod deployed)
596
622
  | "building"
597
- // the prebuild failed due to some issue with the system (e.g. missed a message, could not start workspace)
623
+ // the prebuild was aborted
598
624
  | "aborted"
599
625
  // the prebuild timed out
600
626
  | "timeout"
601
- // the prebuild has finished and a snapshot is available
602
- | "available";
627
+ // the prebuild has finished (even if a headless task failed) and a snapshot is available
628
+ | "available"
629
+ // the prebuild (headless workspace) failed due to some system error
630
+ | "failed";
603
631
 
604
632
  export interface PrebuiltWorkspace {
605
633
  id: string;
606
634
  cloneURL: string;
635
+ branch?: string;
636
+ projectId?: string;
607
637
  commit: string;
608
638
  buildWorkspaceId: string;
609
639
  creationTime: string;
@@ -614,7 +644,7 @@ export interface PrebuiltWorkspace {
614
644
 
615
645
  export namespace PrebuiltWorkspace {
616
646
  export function isDone(pws: PrebuiltWorkspace) {
617
- return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
647
+ return pws.state === "available" || pws.state === "timeout" || pws.state === "aborted";
618
648
  }
619
649
 
620
650
  export function isAvailable(pws: PrebuiltWorkspace) {
@@ -633,27 +663,33 @@ export interface PrebuiltWorkspaceUpdatable {
633
663
  repo: string;
634
664
  isResolved: boolean;
635
665
  installationId: string;
666
+ /**
667
+ * the commitSHA of the commit that triggered the prebuild
668
+ */
669
+ commitSHA?: string;
636
670
  issue?: string;
637
671
  contextUrl?: string;
638
672
  }
639
673
 
640
674
  export interface WhitelistedRepository {
641
- url: string
642
- name: string
643
- description?: string
644
- avatar?: string
675
+ url: string;
676
+ name: string;
677
+ description?: string;
678
+ avatar?: string;
645
679
  }
646
680
 
647
- export type PortOnOpen = 'open-browser' | 'open-preview' | 'notify' | 'ignore';
681
+ export type PortOnOpen = "open-browser" | "open-preview" | "notify" | "ignore";
648
682
 
649
683
  export interface PortConfig {
650
684
  port: number;
651
685
  onOpen?: PortOnOpen;
652
686
  visibility?: PortVisibility;
687
+ description?: string;
688
+ name?: string;
653
689
  }
654
690
  export namespace PortConfig {
655
691
  export function is(config: any): config is PortConfig {
656
- return config && ('port' in config) && (typeof config.port === 'number');
692
+ return config && "port" in config && typeof config.port === "number";
657
693
  }
658
694
  }
659
695
 
@@ -663,7 +699,7 @@ export interface PortRangeConfig {
663
699
  }
664
700
  export namespace PortRangeConfig {
665
701
  export function is(config: any): config is PortRangeConfig {
666
- return config && ('port' in config) && (typeof config.port === 'string' || config.port instanceof String);
702
+ return config && "port" in config && (typeof config.port === "string" || config.port instanceof String);
667
703
  }
668
704
  }
669
705
 
@@ -673,33 +709,32 @@ export interface TaskConfig {
673
709
  init?: string;
674
710
  prebuild?: string;
675
711
  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';
712
+ env?: { [env: string]: any };
713
+ openIn?: "bottom" | "main" | "left" | "right";
714
+ openMode?: "split-top" | "split-left" | "split-right" | "split-bottom" | "tab-before" | "tab-after";
679
715
  }
680
716
 
681
717
  export namespace TaskConfig {
682
718
  export function is(config: any): config is TaskConfig {
683
- return config
684
- && ('command' in config || 'init' in config || 'before' in config);
719
+ return config && ("command" in config || "init" in config || "before" in config);
685
720
  }
686
721
  }
687
722
 
688
723
  export namespace WorkspaceImageBuild {
689
- export type Phase = 'BaseImage' | 'GitpodLayer' | 'Error' | 'Done';
724
+ export type Phase = "BaseImage" | "GitpodLayer" | "Error" | "Done";
690
725
  export interface StateInfo {
691
- phase: Phase
692
- currentStep?: number
693
- maxSteps?: number
726
+ phase: Phase;
727
+ currentStep?: number;
728
+ maxSteps?: number;
694
729
  }
695
730
  export interface LogContent {
696
- text: string
697
- upToLine?: number
698
- isDiff?: boolean
731
+ text: string;
732
+ upToLine?: number;
733
+ isDiff?: boolean;
699
734
  }
700
735
  export type LogCallback = (info: StateInfo, content: LogContent | undefined) => void;
701
736
  export namespace LogLine {
702
- export const DELIMITER = '\r\n';
737
+ export const DELIMITER = "\r\n";
703
738
  export const DELIMITER_REGEX = /\r?\n/;
704
739
  }
705
740
  }
@@ -708,20 +743,18 @@ export type ImageConfig = ImageConfigString | ImageConfigFile;
708
743
  export type ImageConfigString = string;
709
744
  export namespace ImageConfigString {
710
745
  export function is(config: ImageConfig | undefined): config is ImageConfigString {
711
- return typeof config === 'string';
746
+ return typeof config === "string";
712
747
  }
713
-
714
748
  }
715
749
  export interface ImageConfigFile {
716
750
  // Path to the Dockerfile relative to repository root
717
- file: string,
751
+ file: string;
718
752
  // Path to the docker build context relative to repository root
719
- context?: string
753
+ context?: string;
720
754
  }
721
755
  export namespace ImageConfigFile {
722
756
  export function is(config: ImageConfig | undefined): config is ImageConfigFile {
723
- return typeof config === 'object'
724
- && 'file' in config;
757
+ return typeof config === "object" && "file" in config;
725
758
  }
726
759
  }
727
760
  export interface ExternalImageConfigFile extends ImageConfigFile {
@@ -729,22 +762,21 @@ export interface ExternalImageConfigFile extends ImageConfigFile {
729
762
  }
730
763
  export namespace ExternalImageConfigFile {
731
764
  export function is(config: any | undefined): config is ExternalImageConfigFile {
732
- return typeof config === 'object'
733
- && 'file' in config
734
- && 'externalSource' in config;
765
+ return typeof config === "object" && "file" in config && "externalSource" in config;
735
766
  }
736
767
  }
737
768
 
738
769
  export interface WorkspaceContext {
739
770
  title: string;
771
+ /** 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
772
  normalizedContextURL?: string;
741
773
  forceCreateNewWorkspace?: boolean;
774
+ forceImageBuild?: boolean;
742
775
  }
743
776
 
744
777
  export namespace WorkspaceContext {
745
778
  export function is(context: any): context is WorkspaceContext {
746
- return context
747
- && 'title' in context;
779
+ return context && "title" in context;
748
780
  }
749
781
  }
750
782
 
@@ -753,22 +785,38 @@ export interface WithSnapshot {
753
785
  }
754
786
  export namespace WithSnapshot {
755
787
  export function is(context: any): context is WithSnapshot {
756
- return context
757
- && 'snapshotBucketId' in context;
788
+ return context && "snapshotBucketId" in context;
758
789
  }
759
790
  }
760
791
 
761
- export interface WithPrebuild {
762
- snapshotBucketId: string;
792
+ export interface WithPrebuild extends WithSnapshot {
763
793
  prebuildWorkspaceId: string;
764
794
  wasPrebuilt: true;
765
795
  }
766
796
  export namespace WithPrebuild {
767
797
  export function is(context: any): context is WithPrebuild {
768
- return context
769
- && 'snapshotBucketId' in context
770
- && 'prebuildWorkspaceId' in context
771
- && 'wasPrebuilt' in context;
798
+ return context && WithSnapshot.is(context) && "prebuildWorkspaceId" in context && "wasPrebuilt" in context;
799
+ }
800
+ }
801
+
802
+ /**
803
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
804
+ * and fall back to the built-in configuration.
805
+ */
806
+ export interface WithDefaultConfig {
807
+ withDefaultConfig: true;
808
+ }
809
+
810
+ export namespace WithDefaultConfig {
811
+ export function is(context: any): context is WithDefaultConfig {
812
+ return context && "withDefaultConfig" in context && context.withDefaultConfig;
813
+ }
814
+
815
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
816
+ return {
817
+ ...ctx,
818
+ withDefaultConfig: true,
819
+ };
772
820
  }
773
821
  }
774
822
 
@@ -778,20 +826,24 @@ export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
778
826
 
779
827
  export namespace SnapshotContext {
780
828
  export function is(context: any): context is SnapshotContext {
781
- return context
782
- && WithSnapshot.is(context)
783
- && 'snapshotId' in context;
829
+ return context && WithSnapshot.is(context) && "snapshotId" in context;
784
830
  }
785
831
  }
786
832
 
787
833
  export interface StartPrebuildContext extends WorkspaceContext {
788
834
  actual: WorkspaceContext;
835
+ commitHistory?: string[];
836
+ additionalRepositoryCommitHistories?: {
837
+ cloneUrl: string;
838
+ commitHistory: string[];
839
+ }[];
840
+ project?: Project;
841
+ branch?: string;
789
842
  }
790
843
 
791
844
  export namespace StartPrebuildContext {
792
845
  export function is(context: any): context is StartPrebuildContext {
793
- return context
794
- && 'actual' in context;
846
+ return context && "actual" in context;
795
847
  }
796
848
  }
797
849
 
@@ -803,33 +855,39 @@ export interface PrebuiltWorkspaceContext extends WorkspaceContext {
803
855
 
804
856
  export namespace PrebuiltWorkspaceContext {
805
857
  export function is(context: any): context is PrebuiltWorkspaceContext {
806
- return context
807
- && 'originalContext' in context
808
- && 'prebuiltWorkspace' in context;
858
+ return context && "originalContext" in context && "prebuiltWorkspace" in context;
859
+ }
860
+ }
861
+
862
+ export interface WithReferrerContext extends WorkspaceContext {
863
+ referrer: string;
864
+ referrerIde?: string;
865
+ }
866
+
867
+ export namespace WithReferrerContext {
868
+ export function is(context: any): context is WithReferrerContext {
869
+ return context && "referrer" in context;
809
870
  }
810
871
  }
811
872
 
812
873
  export interface WithEnvvarsContext extends WorkspaceContext {
813
- envvars: UserEnvVarValue[];
874
+ envvars: EnvVarWithValue[];
814
875
  }
815
876
 
816
877
  export namespace WithEnvvarsContext {
817
878
  export function is(context: any): context is WithEnvvarsContext {
818
- return context
819
- && 'envvars' in context
879
+ return context && "envvars" in context;
820
880
  }
821
881
  }
822
882
 
823
883
  export interface WorkspaceProbeContext extends WorkspaceContext {
824
- responseURL: string
825
- responseToken: string
884
+ responseURL: string;
885
+ responseToken: string;
826
886
  }
827
887
 
828
888
  export namespace WorkspaceProbeContext {
829
889
  export function is(context: any): context is WorkspaceProbeContext {
830
- return context
831
- && 'responseURL' in context
832
- && 'responseToken' in context;
890
+ return context && "responseURL" in context && "responseToken" in context;
833
891
  }
834
892
  }
835
893
 
@@ -841,30 +899,80 @@ export namespace RefType {
841
899
  }
842
900
  // This fallback is meant to handle the cases where (for historic reasons) ref is present but refType is missing
843
901
  return commit.refType || "branch";
844
- }
902
+ };
845
903
  }
846
904
 
847
905
  export interface Commit {
848
- repository: Repository
849
- revision: string
906
+ repository: Repository;
907
+ revision: string;
850
908
 
851
909
  // Might contain either a branch or a tag (determined by refType)
852
- ref?: string
910
+ ref?: string;
853
911
 
854
912
  // refType is only set if ref is present (and not for old workspaces, before this feature was added)
855
- refType?: RefType
913
+ refType?: RefType;
914
+ }
915
+
916
+ export interface AdditionalContentContext extends WorkspaceContext {
917
+ /**
918
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
919
+ */
920
+ additionalFiles: { [filePath: string]: string };
921
+ }
922
+
923
+ export namespace AdditionalContentContext {
924
+ export function is(ctx: any): ctx is AdditionalContentContext {
925
+ return "additionalFiles" in ctx;
926
+ }
927
+
928
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
929
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
930
+ }
856
931
  }
857
932
 
858
- export interface CommitContext extends WorkspaceContext, Commit {
933
+ export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
859
934
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
860
- cloneUrl?: string
935
+ cloneUrl?: string;
936
+
937
+ /**
938
+ * The clone and checkout information for additional repositories in case of multi-repo projects.
939
+ */
940
+ additionalRepositoryCheckoutInfo?: GitCheckoutInfo[];
941
+ }
942
+
943
+ export namespace CommitContext {
944
+ /**
945
+ * Creates a hash for all the commits of the CommitContext and all sub-repo commit infos.
946
+ * The hash is max 255 chars long.
947
+ * @param commitContext
948
+ * @returns hash for commitcontext
949
+ */
950
+ export function computeHash(commitContext: CommitContext): string {
951
+ // for single commits we use the revision to be backward compatible.
952
+ if (
953
+ !commitContext.additionalRepositoryCheckoutInfo ||
954
+ commitContext.additionalRepositoryCheckoutInfo.length === 0
955
+ ) {
956
+ return commitContext.revision;
957
+ }
958
+ const hasher = createHash("sha256");
959
+ hasher.update(commitContext.revision);
960
+ for (const info of commitContext.additionalRepositoryCheckoutInfo) {
961
+ hasher.update(info.revision);
962
+ }
963
+ return hasher.digest("hex");
964
+ }
965
+ }
966
+
967
+ export interface GitCheckoutInfo extends Commit {
968
+ checkoutLocation?: string;
969
+ upstreamRemoteURI?: string;
970
+ localBranch?: string;
861
971
  }
862
972
 
863
973
  export namespace CommitContext {
864
974
  export function is(commit: any): commit is CommitContext {
865
- return WorkspaceContext.is(commit)
866
- && 'repository' in commit
867
- && 'revision' in commit
975
+ return WorkspaceContext.is(commit) && "repository" in commit && "revision" in commit;
868
976
  }
869
977
  }
870
978
 
@@ -872,17 +980,14 @@ export interface PullRequestContext extends CommitContext {
872
980
  nr: number;
873
981
  ref: string;
874
982
  base: {
875
- repository: Repository
876
- ref: string
877
- }
983
+ repository: Repository;
984
+ ref: string;
985
+ };
878
986
  }
879
987
 
880
988
  export namespace PullRequestContext {
881
989
  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
990
+ return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "base" in ctx;
886
991
  }
887
992
  }
888
993
 
@@ -894,10 +999,7 @@ export interface IssueContext extends CommitContext {
894
999
 
895
1000
  export namespace IssueContext {
896
1001
  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
1002
+ return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "localBranch" in ctx;
901
1003
  }
902
1004
  }
903
1005
 
@@ -908,9 +1010,7 @@ export interface NavigatorContext extends CommitContext {
908
1010
 
909
1011
  export namespace NavigatorContext {
910
1012
  export function is(ctx: any): ctx is NavigatorContext {
911
- return CommitContext.is(ctx)
912
- && 'path' in ctx
913
- && 'isFile' in ctx
1013
+ return CommitContext.is(ctx) && "path" in ctx && "isFile" in ctx;
914
1014
  }
915
1015
  }
916
1016
 
@@ -919,6 +1019,8 @@ export interface Repository {
919
1019
  owner: string;
920
1020
  name: string;
921
1021
  cloneUrl: string;
1022
+ /* Optional kind to differentiate between repositories of orgs/groups/projects and personal repos. */
1023
+ repoKind?: string;
922
1024
  description?: string;
923
1025
  avatarUrl?: string;
924
1026
  webUrl?: string;
@@ -927,8 +1029,21 @@ export interface Repository {
927
1029
  private?: boolean;
928
1030
  fork?: {
929
1031
  // The direct parent of this fork
930
- parent: Repository
931
- }
1032
+ parent: Repository;
1033
+ };
1034
+ }
1035
+ export interface Branch {
1036
+ name: string;
1037
+ commit: CommitInfo;
1038
+ htmlUrl: string;
1039
+ }
1040
+
1041
+ export interface CommitInfo {
1042
+ author: string;
1043
+ sha: string;
1044
+ commitMessage: string;
1045
+ authorAvatarUrl?: string;
1046
+ authorDate?: string;
932
1047
  }
933
1048
 
934
1049
  export namespace Repository {
@@ -940,21 +1055,25 @@ export namespace Repository {
940
1055
  export interface WorkspaceInstancePortsChangedEvent {
941
1056
  type: "PortsChanged";
942
1057
  instanceID: string;
943
- portsOpened: number[]
944
- portsClosed: number[]
1058
+ portsOpened: number[];
1059
+ portsClosed: number[];
945
1060
  }
946
1061
 
947
1062
  export namespace WorkspaceInstancePortsChangedEvent {
948
-
949
1063
  export function is(data: any): data is WorkspaceInstancePortsChangedEvent {
950
1064
  return data && data.type == "PortsChanged";
951
1065
  }
952
-
953
1066
  }
954
1067
 
955
1068
  export interface WorkspaceInfo {
956
- workspace: Workspace
957
- latestInstance?: WorkspaceInstance
1069
+ workspace: Workspace;
1070
+ latestInstance?: WorkspaceInstance;
1071
+ }
1072
+
1073
+ export namespace WorkspaceInfo {
1074
+ export function lastActiveISODate(info: WorkspaceInfo): string {
1075
+ return info.latestInstance?.creationTime || info.workspace.creationTime;
1076
+ }
958
1077
  }
959
1078
 
960
1079
  export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
@@ -964,34 +1083,36 @@ export interface WorkspaceCreationResult {
964
1083
  workspaceURL?: string;
965
1084
  existingWorkspaces?: WorkspaceInfo[];
966
1085
  runningWorkspacePrebuild?: {
967
- prebuildID: string
968
- workspaceID: string
969
- starting: RunningWorkspacePrebuildStarting
970
- sameCluster: boolean
971
- }
1086
+ prebuildID: string;
1087
+ workspaceID: string;
1088
+ instanceID: string;
1089
+ starting: RunningWorkspacePrebuildStarting;
1090
+ sameCluster: boolean;
1091
+ };
972
1092
  runningPrebuildWorkspaceID?: string;
973
1093
  }
974
- export type RunningWorkspacePrebuildStarting = 'queued' | 'starting' | 'running';
1094
+ export type RunningWorkspacePrebuildStarting = "queued" | "starting" | "running";
975
1095
 
976
1096
  export enum CreateWorkspaceMode {
977
1097
  // Default returns a running prebuild if there is any, otherwise creates a new workspace (using a prebuild if one is available)
978
- Default = 'default',
1098
+ Default = "default",
979
1099
  // 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',
1100
+ ForceNew = "force-new",
981
1101
  // 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',
1102
+ UsePrebuild = "use-prebuild",
983
1103
  // 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',
1104
+ SelectIfRunning = "select-if-running",
985
1105
  }
986
1106
 
987
1107
  export namespace WorkspaceCreationResult {
988
1108
  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
- )
1109
+ return (
1110
+ data &&
1111
+ ("createdWorkspaceId" in data ||
1112
+ "existingWorkspaces" in data ||
1113
+ "runningWorkspacePrebuild" in data ||
1114
+ "runningPrebuildWorkspaceID" in data)
1115
+ );
995
1116
  }
996
1117
  }
997
1118
 
@@ -1025,6 +1146,12 @@ export interface AuthProviderInfo {
1025
1146
  readonly default: string[];
1026
1147
  readonly publicRepo: string[];
1027
1148
  readonly privateRepo: string[];
1149
+ };
1150
+ }
1151
+
1152
+ export namespace AuthProviderInfo {
1153
+ export function isGitHubEnterprise(info?: AuthProviderInfo): boolean {
1154
+ return !!info && info.authProviderType === "GitHub" && info.host !== "github.com";
1028
1155
  }
1029
1156
  }
1030
1157
 
@@ -1037,6 +1164,8 @@ export interface AuthProviderEntry {
1037
1164
  readonly status: AuthProviderEntry.Status;
1038
1165
 
1039
1166
  readonly oauth: OAuth2Config;
1167
+ /** A random string that is to change whenever oauth changes (enforced on DB level) */
1168
+ readonly oauthRevision?: string;
1040
1169
  }
1041
1170
 
1042
1171
  export interface OAuth2Config {
@@ -1049,47 +1178,27 @@ export interface OAuth2Config {
1049
1178
  readonly scopeSeparator?: string;
1050
1179
 
1051
1180
  readonly settingsUrl?: string;
1052
- readonly authorizationParams?: { [key: string]: string }
1181
+ readonly authorizationParams?: { [key: string]: string };
1053
1182
  readonly configURL?: string;
1054
1183
  }
1055
1184
 
1056
1185
  export namespace AuthProviderEntry {
1057
1186
  export type Type = "GitHub" | "GitLab" | string;
1058
1187
  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;
1188
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & {
1189
+ clientId?: string;
1190
+ clientSecret?: string;
1191
+ };
1192
+ export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> &
1193
+ Pick<OAuth2Config, "clientId" | "clientSecret">;
1194
+ export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1195
+ return {
1196
+ ...entry,
1197
+ oauth: {
1198
+ ...entry.oauth,
1199
+ clientSecret: "redacted",
1200
+ },
1201
+ };
1093
1202
  }
1094
1203
  }
1095
1204