@gitpod/gitpod-protocol 0.1.5-se-multi-repo.37 → 0.1.5-se-cancel-reason.0

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