@gitpod/gitpod-protocol 0.1.5-v0.6.0-beta4 → 0.1.5-vn-6525.75

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