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