@gitpod/gitpod-protocol 0.1.5-se-multi-repo.39 → 0.1.5-se-playground.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) 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.map +1 -1
  7. package/lib/admin-protocol.js.map +1 -1
  8. package/lib/analytics.d.ts.map +1 -1
  9. package/lib/analytics.js.map +1 -1
  10. package/lib/auth.d.ts.map +1 -1
  11. package/lib/context-url.d.ts.map +1 -1
  12. package/lib/context-url.js +4 -4
  13. package/lib/context-url.js.map +1 -1
  14. package/lib/context-url.spec.d.ts.map +1 -1
  15. package/lib/context-url.spec.js +20 -5
  16. package/lib/context-url.spec.js.map +1 -1
  17. package/lib/email-protocol.d.ts +1 -1
  18. package/lib/email-protocol.d.ts.map +1 -1
  19. package/lib/email-protocol.js.map +1 -1
  20. package/lib/encryption/container-module.d.ts.map +1 -1
  21. package/lib/encryption/container-module.js +1 -1
  22. package/lib/encryption/container-module.js.map +1 -1
  23. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  24. package/lib/encryption/encryption-engine.js +7 -7
  25. package/lib/encryption/encryption-engine.js.map +1 -1
  26. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  27. package/lib/encryption/encryption-engine.spec.js +2 -3
  28. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  29. package/lib/encryption/encryption-service.d.ts.map +1 -1
  30. package/lib/encryption/encryption-service.js +1 -1
  31. package/lib/encryption/encryption-service.js.map +1 -1
  32. package/lib/encryption/key-provider.d.ts.map +1 -1
  33. package/lib/encryption/key-provider.js +7 -9
  34. package/lib/encryption/key-provider.js.map +1 -1
  35. package/lib/env.d.ts +0 -5
  36. package/lib/env.d.ts.map +1 -1
  37. package/lib/env.js +1 -20
  38. package/lib/env.js.map +1 -1
  39. package/lib/experiments/always-default.d.ts +8 -0
  40. package/lib/experiments/always-default.d.ts.map +1 -0
  41. package/lib/experiments/always-default.js +20 -0
  42. package/lib/experiments/always-default.js.map +1 -0
  43. package/lib/experiments/configcat-server.d.ts +8 -0
  44. package/lib/experiments/configcat-server.d.ts.map +1 -0
  45. package/lib/experiments/configcat-server.js +34 -0
  46. package/lib/experiments/configcat-server.js.map +1 -0
  47. package/lib/experiments/configcat.d.ts +21 -0
  48. package/lib/experiments/configcat.d.ts.map +1 -0
  49. package/lib/experiments/configcat.js +47 -0
  50. package/lib/experiments/configcat.js.map +1 -0
  51. package/lib/experiments/types.d.ts +19 -0
  52. package/lib/experiments/types.d.ts.map +1 -0
  53. package/lib/{theia-plugins.js → experiments/types.js} +2 -2
  54. package/lib/experiments/types.js.map +1 -0
  55. package/lib/gitpod-file-parser.d.ts.map +1 -1
  56. package/lib/gitpod-file-parser.js +6 -6
  57. package/lib/gitpod-file-parser.js.map +1 -1
  58. package/lib/gitpod-file-parser.spec.js +42 -39
  59. package/lib/gitpod-file-parser.spec.js.map +1 -1
  60. package/lib/gitpod-service.d.ts +33 -26
  61. package/lib/gitpod-service.d.ts.map +1 -1
  62. package/lib/gitpod-service.js +39 -32
  63. package/lib/gitpod-service.js.map +1 -1
  64. package/lib/headless-workspace-log.d.ts.map +1 -1
  65. package/lib/headless-workspace-log.js +1 -1
  66. package/lib/headless-workspace-log.js.map +1 -1
  67. package/lib/ide-frontend-service.d.ts +1 -1
  68. package/lib/ide-protocol.d.ts +6 -6
  69. package/lib/ide-protocol.d.ts.map +1 -1
  70. package/lib/index.d.ts +16 -16
  71. package/lib/installation-admin-protocol.d.ts +3 -0
  72. package/lib/installation-admin-protocol.d.ts.map +1 -1
  73. package/lib/installation-admin-protocol.js +3 -2
  74. package/lib/installation-admin-protocol.js.map +1 -1
  75. package/lib/license-protocol.d.ts +7 -0
  76. package/lib/license-protocol.d.ts.map +1 -1
  77. package/lib/license-protocol.js.map +1 -1
  78. package/lib/messaging/browser/connection.d.ts +1 -1
  79. package/lib/messaging/browser/connection.d.ts.map +1 -1
  80. package/lib/messaging/browser/connection.js +19 -19
  81. package/lib/messaging/browser/connection.js.map +1 -1
  82. package/lib/messaging/browser/window-connection.d.ts +4 -4
  83. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  84. package/lib/messaging/browser/window-connection.js +9 -6
  85. package/lib/messaging/browser/window-connection.js.map +1 -1
  86. package/lib/messaging/client-call-metrics.d.ts +2 -2
  87. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  88. package/lib/messaging/client-call-metrics.js +20 -20
  89. package/lib/messaging/client-call-metrics.js.map +1 -1
  90. package/lib/messaging/error.d.ts +2 -0
  91. package/lib/messaging/error.d.ts.map +1 -1
  92. package/lib/messaging/error.js +4 -0
  93. package/lib/messaging/error.js.map +1 -1
  94. package/lib/messaging/handler.d.ts.map +1 -1
  95. package/lib/messaging/handler.js +1 -1
  96. package/lib/messaging/node/connection.js +8 -8
  97. package/lib/messaging/node/connection.js.map +1 -1
  98. package/lib/messaging/proxy-factory.d.ts +1 -1
  99. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  100. package/lib/messaging/proxy-factory.js +7 -9
  101. package/lib/messaging/proxy-factory.js.map +1 -1
  102. package/lib/payment-protocol.d.ts.map +1 -1
  103. package/lib/payment-protocol.js +1 -1
  104. package/lib/payment-protocol.js.map +1 -1
  105. package/lib/permission.d.ts +2 -2
  106. package/lib/permission.d.ts.map +1 -1
  107. package/lib/permission.js +12 -23
  108. package/lib/permission.js.map +1 -1
  109. package/lib/plans.d.ts +3 -3
  110. package/lib/plans.d.ts.map +1 -1
  111. package/lib/plans.js +206 -171
  112. package/lib/plans.js.map +1 -1
  113. package/lib/protocol.d.ts +50 -34
  114. package/lib/protocol.d.ts.map +1 -1
  115. package/lib/protocol.js +146 -90
  116. package/lib/protocol.js.map +1 -1
  117. package/lib/snapshot-url.spec.js.map +1 -1
  118. package/lib/team-subscription-protocol.d.ts +19 -3
  119. package/lib/team-subscription-protocol.d.ts.map +1 -1
  120. package/lib/team-subscription-protocol.js +16 -5
  121. package/lib/team-subscription-protocol.js.map +1 -1
  122. package/lib/teams-projects-protocol.d.ts +9 -3
  123. package/lib/teams-projects-protocol.d.ts.map +1 -1
  124. package/lib/teams-projects-protocol.js +1 -1
  125. package/lib/teams-projects-protocol.js.map +1 -1
  126. package/lib/typings/globals.d.ts +2 -2
  127. package/lib/typings/globals.d.ts.map +1 -1
  128. package/lib/util/analytics.d.ts.map +1 -1
  129. package/lib/util/analytics.js +6 -6
  130. package/lib/util/analytics.js.map +1 -1
  131. package/lib/util/async-iterator.d.ts.map +1 -1
  132. package/lib/util/async-iterator.js +3 -3
  133. package/lib/util/async-iterator.js.map +1 -1
  134. package/lib/util/cancelable.js.map +1 -1
  135. package/lib/util/date-time.js +6 -6
  136. package/lib/util/date-time.js.map +1 -1
  137. package/lib/util/debug-app.d.ts +25 -0
  138. package/lib/util/debug-app.d.ts.map +1 -0
  139. package/lib/util/debug-app.js +100 -0
  140. package/lib/util/debug-app.js.map +1 -0
  141. package/lib/util/deferred.js.map +1 -1
  142. package/lib/util/disposable.d.ts.map +1 -1
  143. package/lib/util/disposable.js +2 -2
  144. package/lib/util/disposable.js.map +1 -1
  145. package/lib/util/event.d.ts.map +1 -1
  146. package/lib/util/event.js +5 -3
  147. package/lib/util/event.js.map +1 -1
  148. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  149. package/lib/util/garbage-collected-cache.js +1 -1
  150. package/lib/util/garbage-collected-cache.js.map +1 -1
  151. package/lib/util/generate-workspace-id.d.ts +5 -0
  152. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  153. package/lib/util/generate-workspace-id.js +446 -442
  154. package/lib/util/generate-workspace-id.js.map +1 -1
  155. package/lib/util/generate-workspace-id.spec.js +18 -7
  156. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  157. package/lib/util/gitpod-cookie.d.ts +1 -1
  158. package/lib/util/gitpod-cookie.d.ts.map +1 -1
  159. package/lib/util/gitpod-cookie.js +0 -3
  160. package/lib/util/gitpod-cookie.js.map +1 -1
  161. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  162. package/lib/util/gitpod-host-url.js +31 -29
  163. package/lib/util/gitpod-host-url.js.map +1 -1
  164. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  165. package/lib/util/gitpod-host-url.spec.js +15 -5
  166. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  167. package/lib/util/grpc.d.ts.map +1 -1
  168. package/lib/util/grpc.js.map +1 -1
  169. package/lib/util/jaeger-client-types.d.ts.map +1 -1
  170. package/lib/util/logging.d.ts +1 -1
  171. package/lib/util/logging.d.ts.map +1 -1
  172. package/lib/util/logging.js +31 -25
  173. package/lib/util/logging.js.map +1 -1
  174. package/lib/util/make-link.js +5 -5
  175. package/lib/util/make-link.js.map +1 -1
  176. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  177. package/lib/util/parse-workspace-id.js +1 -2
  178. package/lib/util/parse-workspace-id.js.map +1 -1
  179. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  180. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  181. package/lib/util/queue.spec.js +9 -6
  182. package/lib/util/queue.spec.js.map +1 -1
  183. package/lib/util/semaphore.d.ts.map +1 -1
  184. package/lib/util/semaphore.js.map +1 -1
  185. package/lib/util/skip-if.d.ts.map +1 -1
  186. package/lib/util/skip-if.js.map +1 -1
  187. package/lib/util/timeutil.d.ts +1 -0
  188. package/lib/util/timeutil.d.ts.map +1 -1
  189. package/lib/util/timeutil.js +9 -3
  190. package/lib/util/timeutil.js.map +1 -1
  191. package/lib/util/timeutil.spec.d.ts.map +1 -1
  192. package/lib/util/timeutil.spec.js.map +1 -1
  193. package/lib/util/tracing.d.ts +6 -6
  194. package/lib/util/tracing.d.ts.map +1 -1
  195. package/lib/util/tracing.js +14 -16
  196. package/lib/util/tracing.js.map +1 -1
  197. package/lib/util/tracing.spec.js +3 -3
  198. package/lib/util/tracing.spec.js.map +1 -1
  199. package/lib/util/workspace-port-authentication.d.ts +7 -7
  200. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  201. package/lib/util/workspace-port-authentication.js +8 -11
  202. package/lib/util/workspace-port-authentication.js.map +1 -1
  203. package/lib/workspace-cluster.d.ts +1 -1
  204. package/lib/workspace-cluster.d.ts.map +1 -1
  205. package/lib/workspace-cluster.js +2 -4
  206. package/lib/workspace-cluster.js.map +1 -1
  207. package/lib/workspace-instance.d.ts +18 -3
  208. package/lib/workspace-instance.d.ts.map +1 -1
  209. package/lib/wsready.d.ts.map +1 -1
  210. package/lib/wsready.js +1 -1
  211. package/package.json +9 -6
  212. package/pkg-yarn.lock +7 -5
  213. package/provenance-bundle.jsonl +1 -1
  214. package/src/accounting-protocol.ts +63 -51
  215. package/src/admin-protocol.ts +22 -20
  216. package/src/analytics.ts +21 -21
  217. package/src/auth.ts +2 -2
  218. package/src/context-url.spec.ts +25 -11
  219. package/src/context-url.ts +80 -78
  220. package/src/email-protocol.ts +5 -6
  221. package/src/encryption/container-module.ts +2 -3
  222. package/src/encryption/encryption-engine.spec.ts +9 -8
  223. package/src/encryption/encryption-engine.ts +14 -14
  224. package/src/encryption/encryption-service.ts +4 -5
  225. package/src/encryption/key-provider.ts +16 -19
  226. package/src/env.ts +0 -22
  227. package/src/experiments/always-default.ts +24 -0
  228. package/src/experiments/configcat-server.ts +37 -0
  229. package/src/experiments/configcat.ts +53 -0
  230. package/src/experiments/types.ts +32 -0
  231. package/src/gitpod-file-parser.spec.ts +55 -61
  232. package/src/gitpod-file-parser.ts +16 -17
  233. package/src/gitpod-service.ts +153 -110
  234. package/src/headless-workspace-log.ts +5 -4
  235. package/src/ide-frontend-service.ts +2 -2
  236. package/src/ide-protocol.ts +8 -8
  237. package/src/index.ts +16 -16
  238. package/src/installation-admin-protocol.ts +11 -8
  239. package/src/license-protocol.ts +12 -6
  240. package/src/messaging/browser/connection.ts +45 -47
  241. package/src/messaging/browser/window-connection.ts +39 -29
  242. package/src/messaging/client-call-metrics.ts +70 -71
  243. package/src/messaging/error.ts +7 -3
  244. package/src/messaging/handler.ts +6 -6
  245. package/src/messaging/node/connection.ts +8 -8
  246. package/src/messaging/proxy-factory.ts +23 -30
  247. package/src/oss-allowlist.ts +3 -3
  248. package/src/payment-protocol.ts +2 -2
  249. package/src/permission.ts +20 -31
  250. package/src/plans.ts +236 -189
  251. package/src/protocol.ts +298 -242
  252. package/src/snapshot-url.spec.ts +9 -7
  253. package/src/team-subscription-protocol.ts +55 -23
  254. package/src/teams-projects-protocol.ts +15 -8
  255. package/src/typings/globals.ts +4 -4
  256. package/src/util/analytics.ts +46 -42
  257. package/src/util/async-iterator.ts +4 -5
  258. package/src/util/cancelable.ts +3 -3
  259. package/src/util/date-time.ts +8 -8
  260. package/src/util/debug-app.ts +81 -0
  261. package/src/util/deferred.ts +6 -6
  262. package/src/util/disposable.ts +3 -6
  263. package/src/util/event.ts +9 -11
  264. package/src/util/garbage-collected-cache.ts +3 -6
  265. package/src/util/generate-workspace-id.spec.ts +26 -16
  266. package/src/util/generate-workspace-id.ts +460 -454
  267. package/src/util/gitpod-cookie.ts +8 -9
  268. package/src/util/gitpod-host-url.spec.ts +40 -13
  269. package/src/util/gitpod-host-url.ts +37 -34
  270. package/src/util/grpc.ts +1 -1
  271. package/src/util/jaeger-client-types.ts +2 -2
  272. package/src/util/logging.ts +60 -42
  273. package/src/util/make-link.ts +6 -7
  274. package/src/util/parse-workspace-id.spec.ts +17 -8
  275. package/src/util/parse-workspace-id.ts +5 -6
  276. package/src/util/queue.spec.ts +27 -25
  277. package/src/util/repeat.ts +1 -1
  278. package/src/util/semaphore.ts +4 -6
  279. package/src/util/skip-if.ts +9 -6
  280. package/src/util/timeutil.spec.ts +14 -15
  281. package/src/util/timeutil.ts +21 -11
  282. package/src/util/tracing.spec.ts +28 -23
  283. package/src/util/tracing.ts +54 -51
  284. package/src/util/workspace-port-authentication.ts +10 -13
  285. package/src/workspace-cluster.ts +15 -12
  286. package/src/workspace-instance.ts +52 -24
  287. package/src/wsready.ts +2 -2
  288. package/data/builtin-theia-plugins.json +0 -372
  289. package/lib/theia-plugins.d.ts +0 -11
  290. package/lib/theia-plugins.d.ts.map +0 -1
  291. package/lib/theia-plugins.js.map +0 -1
  292. 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,13 +723,13 @@ 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
735
  // the prebuild was aborted
@@ -671,13 +750,16 @@ export interface PrebuiltWorkspace {
671
750
  buildWorkspaceId: string;
672
751
  creationTime: string;
673
752
  state: PrebuiltWorkspaceState;
753
+ statusVersion: number;
674
754
  error?: string;
675
755
  snapshot?: string;
676
756
  }
677
757
 
678
758
  export namespace PrebuiltWorkspace {
679
759
  export function isDone(pws: PrebuiltWorkspace) {
680
- 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
+ );
681
763
  }
682
764
 
683
765
  export function isAvailable(pws: PrebuiltWorkspace) {
@@ -705,13 +787,13 @@ export interface PrebuiltWorkspaceUpdatable {
705
787
  }
706
788
 
707
789
  export interface WhitelistedRepository {
708
- url: string
709
- name: string
710
- description?: string
711
- avatar?: string
790
+ url: string;
791
+ name: string;
792
+ description?: string;
793
+ avatar?: string;
712
794
  }
713
795
 
714
- export type PortOnOpen = 'open-browser' | 'open-preview' | 'notify' | 'ignore';
796
+ export type PortOnOpen = "open-browser" | "open-preview" | "notify" | "ignore";
715
797
 
716
798
  export interface PortConfig {
717
799
  port: number;
@@ -722,7 +804,7 @@ export interface PortConfig {
722
804
  }
723
805
  export namespace PortConfig {
724
806
  export function is(config: any): config is PortConfig {
725
- return config && ('port' in config) && (typeof config.port === 'number');
807
+ return config && "port" in config && typeof config.port === "number";
726
808
  }
727
809
  }
728
810
 
@@ -732,7 +814,7 @@ export interface PortRangeConfig {
732
814
  }
733
815
  export namespace PortRangeConfig {
734
816
  export function is(config: any): config is PortRangeConfig {
735
- 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);
736
818
  }
737
819
  }
738
820
 
@@ -743,32 +825,31 @@ export interface TaskConfig {
743
825
  prebuild?: string;
744
826
  command?: string;
745
827
  env?: { [env: string]: any };
746
- openIn?: 'bottom' | 'main' | 'left' | 'right';
747
- 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";
748
830
  }
749
831
 
750
832
  export namespace TaskConfig {
751
833
  export function is(config: any): config is TaskConfig {
752
- return config
753
- && ('command' in config || 'init' in config || 'before' in config);
834
+ return config && ("command" in config || "init" in config || "before" in config);
754
835
  }
755
836
  }
756
837
 
757
838
  export namespace WorkspaceImageBuild {
758
- export type Phase = 'BaseImage' | 'GitpodLayer' | 'Error' | 'Done';
839
+ export type Phase = "BaseImage" | "GitpodLayer" | "Error" | "Done";
759
840
  export interface StateInfo {
760
- phase: Phase
761
- currentStep?: number
762
- maxSteps?: number
841
+ phase: Phase;
842
+ currentStep?: number;
843
+ maxSteps?: number;
763
844
  }
764
845
  export interface LogContent {
765
- text: string
766
- upToLine?: number
767
- isDiff?: boolean
846
+ text: string;
847
+ upToLine?: number;
848
+ isDiff?: boolean;
768
849
  }
769
850
  export type LogCallback = (info: StateInfo, content: LogContent | undefined) => void;
770
851
  export namespace LogLine {
771
- export const DELIMITER = '\r\n';
852
+ export const DELIMITER = "\r\n";
772
853
  export const DELIMITER_REGEX = /\r?\n/;
773
854
  }
774
855
  }
@@ -777,20 +858,18 @@ export type ImageConfig = ImageConfigString | ImageConfigFile;
777
858
  export type ImageConfigString = string;
778
859
  export namespace ImageConfigString {
779
860
  export function is(config: ImageConfig | undefined): config is ImageConfigString {
780
- return typeof config === 'string';
861
+ return typeof config === "string";
781
862
  }
782
-
783
863
  }
784
864
  export interface ImageConfigFile {
785
865
  // Path to the Dockerfile relative to repository root
786
- file: string,
866
+ file: string;
787
867
  // Path to the docker build context relative to repository root
788
- context?: string
868
+ context?: string;
789
869
  }
790
870
  export namespace ImageConfigFile {
791
871
  export function is(config: ImageConfig | undefined): config is ImageConfigFile {
792
- return typeof config === 'object'
793
- && 'file' in config;
872
+ return typeof config === "object" && "file" in config;
794
873
  }
795
874
  }
796
875
  export interface ExternalImageConfigFile extends ImageConfigFile {
@@ -798,14 +877,13 @@ export interface ExternalImageConfigFile extends ImageConfigFile {
798
877
  }
799
878
  export namespace ExternalImageConfigFile {
800
879
  export function is(config: any | undefined): config is ExternalImageConfigFile {
801
- return typeof config === 'object'
802
- && 'file' in config
803
- && 'externalSource' in config;
880
+ return typeof config === "object" && "file" in config && "externalSource" in config;
804
881
  }
805
882
  }
806
883
 
807
884
  export interface WorkspaceContext {
808
885
  title: string;
886
+ ref?: string;
809
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. */
810
888
  normalizedContextURL?: string;
811
889
  forceCreateNewWorkspace?: boolean;
@@ -814,8 +892,7 @@ export interface WorkspaceContext {
814
892
 
815
893
  export namespace WorkspaceContext {
816
894
  export function is(context: any): context is WorkspaceContext {
817
- return context
818
- && 'title' in context;
895
+ return context && "title" in context;
819
896
  }
820
897
  }
821
898
 
@@ -824,8 +901,7 @@ export interface WithSnapshot {
824
901
  }
825
902
  export namespace WithSnapshot {
826
903
  export function is(context: any): context is WithSnapshot {
827
- return context
828
- && 'snapshotBucketId' in context;
904
+ return context && "snapshotBucketId" in context;
829
905
  }
830
906
  }
831
907
 
@@ -835,10 +911,7 @@ export interface WithPrebuild extends WithSnapshot {
835
911
  }
836
912
  export namespace WithPrebuild {
837
913
  export function is(context: any): context is WithPrebuild {
838
- return context
839
- && WithSnapshot.is(context)
840
- && 'prebuildWorkspaceId' in context
841
- && 'wasPrebuilt' in context;
914
+ return context && WithSnapshot.is(context) && "prebuildWorkspaceId" in context && "wasPrebuilt" in context;
842
915
  }
843
916
  }
844
917
 
@@ -852,16 +925,14 @@ export interface WithDefaultConfig {
852
925
 
853
926
  export namespace WithDefaultConfig {
854
927
  export function is(context: any): context is WithDefaultConfig {
855
- return context
856
- && 'withDefaultConfig' in context
857
- && context.withDefaultConfig;
928
+ return context && "withDefaultConfig" in context && context.withDefaultConfig;
858
929
  }
859
930
 
860
931
  export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
861
932
  return {
862
933
  ...ctx,
863
- withDefaultConfig: true
864
- }
934
+ withDefaultConfig: true,
935
+ };
865
936
  }
866
937
  }
867
938
 
@@ -871,9 +942,7 @@ export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
871
942
 
872
943
  export namespace SnapshotContext {
873
944
  export function is(context: any): context is SnapshotContext {
874
- return context
875
- && WithSnapshot.is(context)
876
- && 'snapshotId' in context;
945
+ return context && WithSnapshot.is(context) && "snapshotId" in context;
877
946
  }
878
947
  }
879
948
 
@@ -890,8 +959,7 @@ export interface StartPrebuildContext extends WorkspaceContext {
890
959
 
891
960
  export namespace StartPrebuildContext {
892
961
  export function is(context: any): context is StartPrebuildContext {
893
- return context
894
- && 'actual' in context;
962
+ return context && "actual" in context;
895
963
  }
896
964
  }
897
965
 
@@ -903,21 +971,18 @@ export interface PrebuiltWorkspaceContext extends WorkspaceContext {
903
971
 
904
972
  export namespace PrebuiltWorkspaceContext {
905
973
  export function is(context: any): context is PrebuiltWorkspaceContext {
906
- return context
907
- && 'originalContext' in context
908
- && 'prebuiltWorkspace' in context;
974
+ return context && "originalContext" in context && "prebuiltWorkspace" in context;
909
975
  }
910
976
  }
911
977
 
912
978
  export interface WithReferrerContext extends WorkspaceContext {
913
- referrer: string
914
- referrerIde?: string
979
+ referrer: string;
980
+ referrerIde?: string;
915
981
  }
916
982
 
917
983
  export namespace WithReferrerContext {
918
984
  export function is(context: any): context is WithReferrerContext {
919
- return context
920
- && 'referrer' in context;
985
+ return context && "referrer" in context;
921
986
  }
922
987
  }
923
988
 
@@ -927,21 +992,18 @@ export interface WithEnvvarsContext extends WorkspaceContext {
927
992
 
928
993
  export namespace WithEnvvarsContext {
929
994
  export function is(context: any): context is WithEnvvarsContext {
930
- return context
931
- && 'envvars' in context
995
+ return context && "envvars" in context;
932
996
  }
933
997
  }
934
998
 
935
999
  export interface WorkspaceProbeContext extends WorkspaceContext {
936
- responseURL: string
937
- responseToken: string
1000
+ responseURL: string;
1001
+ responseToken: string;
938
1002
  }
939
1003
 
940
1004
  export namespace WorkspaceProbeContext {
941
1005
  export function is(context: any): context is WorkspaceProbeContext {
942
- return context
943
- && 'responseURL' in context
944
- && 'responseToken' in context;
1006
+ return context && "responseURL" in context && "responseToken" in context;
945
1007
  }
946
1008
  }
947
1009
 
@@ -953,32 +1015,30 @@ export namespace RefType {
953
1015
  }
954
1016
  // This fallback is meant to handle the cases where (for historic reasons) ref is present but refType is missing
955
1017
  return commit.refType || "branch";
956
- }
1018
+ };
957
1019
  }
958
1020
 
959
1021
  export interface Commit {
960
- repository: Repository
961
- revision: string
1022
+ repository: Repository;
1023
+ revision: string;
962
1024
 
963
1025
  // Might contain either a branch or a tag (determined by refType)
964
- ref?: string
1026
+ ref?: string;
965
1027
 
966
1028
  // refType is only set if ref is present (and not for old workspaces, before this feature was added)
967
- refType?: RefType
1029
+ refType?: RefType;
968
1030
  }
969
1031
 
970
1032
  export interface AdditionalContentContext extends WorkspaceContext {
971
-
972
1033
  /**
973
1034
  * utf-8 encoded contents that will be copied on top of the workspace's filesystem
974
1035
  */
975
- additionalFiles: {[filePath: string]: string};
976
-
1036
+ additionalFiles: { [filePath: string]: string };
977
1037
  }
978
1038
 
979
1039
  export namespace AdditionalContentContext {
980
1040
  export function is(ctx: any): ctx is AdditionalContentContext {
981
- return 'additionalFiles' in ctx;
1041
+ return "additionalFiles" in ctx;
982
1042
  }
983
1043
 
984
1044
  export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
@@ -988,7 +1048,7 @@ export namespace AdditionalContentContext {
988
1048
 
989
1049
  export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
990
1050
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
991
- cloneUrl?: string
1051
+ cloneUrl?: string;
992
1052
 
993
1053
  /**
994
1054
  * The clone and checkout information for additional repositories in case of multi-repo projects.
@@ -997,7 +1057,6 @@ export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
997
1057
  }
998
1058
 
999
1059
  export namespace CommitContext {
1000
-
1001
1060
  /**
1002
1061
  * Creates a hash for all the commits of the CommitContext and all sub-repo commit infos.
1003
1062
  * The hash is max 255 chars long.
@@ -1006,17 +1065,19 @@ export namespace CommitContext {
1006
1065
  */
1007
1066
  export function computeHash(commitContext: CommitContext): string {
1008
1067
  // for single commits we use the revision to be backward compatible.
1009
- if (!commitContext.additionalRepositoryCheckoutInfo || commitContext.additionalRepositoryCheckoutInfo.length === 0) {
1068
+ if (
1069
+ !commitContext.additionalRepositoryCheckoutInfo ||
1070
+ commitContext.additionalRepositoryCheckoutInfo.length === 0
1071
+ ) {
1010
1072
  return commitContext.revision;
1011
1073
  }
1012
- const hasher = createHash('sha256');
1074
+ const hasher = createHash("sha256");
1013
1075
  hasher.update(commitContext.revision);
1014
1076
  for (const info of commitContext.additionalRepositoryCheckoutInfo) {
1015
1077
  hasher.update(info.revision);
1016
1078
  }
1017
- return hasher.digest('hex');
1079
+ return hasher.digest("hex");
1018
1080
  }
1019
-
1020
1081
  }
1021
1082
 
1022
1083
  export interface GitCheckoutInfo extends Commit {
@@ -1027,9 +1088,7 @@ export interface GitCheckoutInfo extends Commit {
1027
1088
 
1028
1089
  export namespace CommitContext {
1029
1090
  export function is(commit: any): commit is CommitContext {
1030
- return WorkspaceContext.is(commit)
1031
- && 'repository' in commit
1032
- && 'revision' in commit
1091
+ return WorkspaceContext.is(commit) && "repository" in commit && "revision" in commit;
1033
1092
  }
1034
1093
  }
1035
1094
 
@@ -1037,17 +1096,14 @@ export interface PullRequestContext extends CommitContext {
1037
1096
  nr: number;
1038
1097
  ref: string;
1039
1098
  base: {
1040
- repository: Repository
1041
- ref: string
1042
- }
1099
+ repository: Repository;
1100
+ ref: string;
1101
+ };
1043
1102
  }
1044
1103
 
1045
1104
  export namespace PullRequestContext {
1046
1105
  export function is(ctx: any): ctx is PullRequestContext {
1047
- return CommitContext.is(ctx)
1048
- && 'nr' in ctx
1049
- && 'ref' in ctx
1050
- && 'base' in ctx
1106
+ return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "base" in ctx;
1051
1107
  }
1052
1108
  }
1053
1109
 
@@ -1059,10 +1115,7 @@ export interface IssueContext extends CommitContext {
1059
1115
 
1060
1116
  export namespace IssueContext {
1061
1117
  export function is(ctx: any): ctx is IssueContext {
1062
- return CommitContext.is(ctx)
1063
- && 'nr' in ctx
1064
- && 'ref' in ctx
1065
- && 'localBranch' in ctx
1118
+ return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "localBranch" in ctx;
1066
1119
  }
1067
1120
  }
1068
1121
 
@@ -1073,9 +1126,7 @@ export interface NavigatorContext extends CommitContext {
1073
1126
 
1074
1127
  export namespace NavigatorContext {
1075
1128
  export function is(ctx: any): ctx is NavigatorContext {
1076
- return CommitContext.is(ctx)
1077
- && 'path' in ctx
1078
- && 'isFile' in ctx
1129
+ return CommitContext.is(ctx) && "path" in ctx && "isFile" in ctx;
1079
1130
  }
1080
1131
  }
1081
1132
 
@@ -1084,6 +1135,8 @@ export interface Repository {
1084
1135
  owner: string;
1085
1136
  name: string;
1086
1137
  cloneUrl: string;
1138
+ /* Optional kind to differentiate between repositories of orgs/groups/projects and personal repos. */
1139
+ repoKind?: string;
1087
1140
  description?: string;
1088
1141
  avatarUrl?: string;
1089
1142
  webUrl?: string;
@@ -1092,8 +1145,8 @@ export interface Repository {
1092
1145
  private?: boolean;
1093
1146
  fork?: {
1094
1147
  // The direct parent of this fork
1095
- parent: Repository
1096
- }
1148
+ parent: Repository;
1149
+ };
1097
1150
  }
1098
1151
  export interface Branch {
1099
1152
  name: string;
@@ -1118,21 +1171,19 @@ export namespace Repository {
1118
1171
  export interface WorkspaceInstancePortsChangedEvent {
1119
1172
  type: "PortsChanged";
1120
1173
  instanceID: string;
1121
- portsOpened: number[]
1122
- portsClosed: number[]
1174
+ portsOpened: number[];
1175
+ portsClosed: number[];
1123
1176
  }
1124
1177
 
1125
1178
  export namespace WorkspaceInstancePortsChangedEvent {
1126
-
1127
1179
  export function is(data: any): data is WorkspaceInstancePortsChangedEvent {
1128
1180
  return data && data.type == "PortsChanged";
1129
1181
  }
1130
-
1131
1182
  }
1132
1183
 
1133
1184
  export interface WorkspaceInfo {
1134
- workspace: Workspace
1135
- latestInstance?: WorkspaceInstance
1185
+ workspace: Workspace;
1186
+ latestInstance?: WorkspaceInstance;
1136
1187
  }
1137
1188
 
1138
1189
  export namespace WorkspaceInfo {
@@ -1148,35 +1199,36 @@ export interface WorkspaceCreationResult {
1148
1199
  workspaceURL?: string;
1149
1200
  existingWorkspaces?: WorkspaceInfo[];
1150
1201
  runningWorkspacePrebuild?: {
1151
- prebuildID: string
1152
- workspaceID: string
1153
- instanceID: string
1154
- starting: RunningWorkspacePrebuildStarting
1155
- sameCluster: boolean
1156
- }
1202
+ prebuildID: string;
1203
+ workspaceID: string;
1204
+ instanceID: string;
1205
+ starting: RunningWorkspacePrebuildStarting;
1206
+ sameCluster: boolean;
1207
+ };
1157
1208
  runningPrebuildWorkspaceID?: string;
1158
1209
  }
1159
- export type RunningWorkspacePrebuildStarting = 'queued' | 'starting' | 'running';
1210
+ export type RunningWorkspacePrebuildStarting = "queued" | "starting" | "running";
1160
1211
 
1161
1212
  export enum CreateWorkspaceMode {
1162
1213
  // Default returns a running prebuild if there is any, otherwise creates a new workspace (using a prebuild if one is available)
1163
- Default = 'default',
1214
+ Default = "default",
1164
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.
1165
- ForceNew = 'force-new',
1216
+ ForceNew = "force-new",
1166
1217
  // UsePrebuild polls the database waiting for a currently running prebuild to become available. This mode exists to handle the db-sync delay.
1167
- UsePrebuild = 'use-prebuild',
1218
+ UsePrebuild = "use-prebuild",
1168
1219
  // SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
1169
- SelectIfRunning = 'select-if-running',
1220
+ SelectIfRunning = "select-if-running",
1170
1221
  }
1171
1222
 
1172
1223
  export namespace WorkspaceCreationResult {
1173
1224
  export function is(data: any): data is WorkspaceCreationResult {
1174
- return data && (
1175
- 'createdWorkspaceId' in data
1176
- || 'existingWorkspaces' in data
1177
- || 'runningWorkspacePrebuild' in data
1178
- || 'runningPrebuildWorkspaceID' in data
1179
- )
1225
+ return (
1226
+ data &&
1227
+ ("createdWorkspaceId" in data ||
1228
+ "existingWorkspaces" in data ||
1229
+ "runningWorkspacePrebuild" in data ||
1230
+ "runningPrebuildWorkspaceID" in data)
1231
+ );
1180
1232
  }
1181
1233
  }
1182
1234
 
@@ -1210,7 +1262,7 @@ export interface AuthProviderInfo {
1210
1262
  readonly default: string[];
1211
1263
  readonly publicRepo: string[];
1212
1264
  readonly privateRepo: string[];
1213
- }
1265
+ };
1214
1266
  }
1215
1267
 
1216
1268
  export interface AuthProviderEntry {
@@ -1236,23 +1288,27 @@ export interface OAuth2Config {
1236
1288
  readonly scopeSeparator?: string;
1237
1289
 
1238
1290
  readonly settingsUrl?: string;
1239
- readonly authorizationParams?: { [key: string]: string }
1291
+ readonly authorizationParams?: { [key: string]: string };
1240
1292
  readonly configURL?: string;
1241
1293
  }
1242
1294
 
1243
1295
  export namespace AuthProviderEntry {
1244
1296
  export type Type = "GitHub" | "GitLab" | string;
1245
1297
  export type Status = "pending" | "verified";
1246
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1247
- 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">;
1248
1304
  export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1249
1305
  return {
1250
1306
  ...entry,
1251
1307
  oauth: {
1252
1308
  ...entry.oauth,
1253
- clientSecret: "redacted"
1254
- }
1255
- }
1309
+ clientSecret: "redacted",
1310
+ },
1311
+ };
1256
1312
  }
1257
1313
  }
1258
1314