@gitpod/gitpod-protocol 0.1.5-se-prebuilds-failed.3 → 0.1.5-se-playground.14

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