@gitpod/gitpod-protocol 0.1.5-tar-telemetry-settings-data.3 → 0.1.5-team-conns.1

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