@gitpod/gitpod-protocol 0.1.5-me-image.3 → 0.1.5-me-test3.3

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