@gitpod/gitpod-protocol 0.1.5-me-gcp-preview.68 → 0.1.5-me-ingress.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 (288) hide show
  1. package/data/builtin-theia-plugins.json +3 -3
  2. package/data/gitpod-schema.json +13 -24
  3. package/lib/accounting-protocol.d.ts +155 -0
  4. package/lib/accounting-protocol.d.ts.map +1 -0
  5. package/lib/accounting-protocol.js +109 -0
  6. package/lib/accounting-protocol.js.map +1 -0
  7. package/lib/admin-protocol.d.ts +20 -4
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +15 -0
  10. package/lib/admin-protocol.js.map +1 -1
  11. package/lib/analytics.d.ts +45 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/context-url.d.ts +18 -0
  16. package/lib/context-url.d.ts.map +1 -0
  17. package/lib/context-url.js +49 -0
  18. package/lib/context-url.js.map +1 -0
  19. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +3 -1
  20. package/lib/context-url.spec.d.ts.map +1 -0
  21. package/lib/context-url.spec.js +73 -0
  22. package/lib/context-url.spec.js.map +1 -0
  23. package/lib/email-protocol.d.ts +1 -2
  24. package/lib/email-protocol.d.ts.map +1 -1
  25. package/lib/email-protocol.js +4 -4
  26. package/lib/email-protocol.js.map +1 -1
  27. package/lib/encryption/container-module.js +5 -4
  28. package/lib/encryption/container-module.js.map +1 -1
  29. package/lib/encryption/encryption-engine.js +19 -20
  30. package/lib/encryption/encryption-engine.js.map +1 -1
  31. package/lib/encryption/encryption-engine.spec.js +29 -36
  32. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  33. package/lib/encryption/encryption-service.js +29 -43
  34. package/lib/encryption/encryption-service.js.map +1 -1
  35. package/lib/encryption/key-provider.js +25 -30
  36. package/lib/encryption/key-provider.js.map +1 -1
  37. package/lib/env.d.ts +1 -2
  38. package/lib/env.d.ts.map +1 -1
  39. package/lib/env.js +20 -21
  40. package/lib/env.js.map +1 -1
  41. package/lib/gitpod-file-parser.js +25 -41
  42. package/lib/gitpod-file-parser.js.map +1 -1
  43. package/lib/gitpod-file-parser.spec.js +116 -116
  44. package/lib/gitpod-file-parser.spec.js.map +1 -1
  45. package/lib/gitpod-service.d.ts +139 -19
  46. package/lib/gitpod-service.d.ts.map +1 -1
  47. package/lib/gitpod-service.js +168 -256
  48. package/lib/gitpod-service.js.map +1 -1
  49. package/lib/headless-workspace-log.d.ts +8 -11
  50. package/lib/headless-workspace-log.d.ts.map +1 -1
  51. package/lib/headless-workspace-log.js +4 -7
  52. package/lib/headless-workspace-log.js.map +1 -1
  53. package/lib/ide-protocol.d.ts +81 -0
  54. package/lib/ide-protocol.d.ts.map +1 -0
  55. package/lib/ide-protocol.js +8 -0
  56. package/lib/ide-protocol.js.map +1 -0
  57. package/lib/index.d.ts +5 -0
  58. package/lib/index.d.ts.map +1 -1
  59. package/lib/index.js +6 -1
  60. package/lib/index.js.map +1 -1
  61. package/lib/messaging/browser/connection.d.ts +5 -3
  62. package/lib/messaging/browser/connection.d.ts.map +1 -1
  63. package/lib/messaging/browser/connection.js +183 -33
  64. package/lib/messaging/browser/connection.js.map +1 -1
  65. package/lib/messaging/browser/window-connection.js +35 -55
  66. package/lib/messaging/browser/window-connection.js.map +1 -1
  67. package/lib/messaging/client-call-metrics.d.ts +35 -0
  68. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  69. package/lib/messaging/client-call-metrics.js +83 -0
  70. package/lib/messaging/client-call-metrics.js.map +1 -0
  71. package/lib/messaging/connection-error-handler.js +11 -23
  72. package/lib/messaging/connection-error-handler.js.map +1 -1
  73. package/lib/messaging/error.d.ts +3 -1
  74. package/lib/messaging/error.d.ts.map +1 -1
  75. package/lib/messaging/error.js +6 -2
  76. package/lib/messaging/error.js.map +1 -1
  77. package/lib/messaging/handler.d.ts +10 -0
  78. package/lib/messaging/handler.d.ts.map +1 -1
  79. package/lib/messaging/node/connection.d.ts +0 -10
  80. package/lib/messaging/node/connection.d.ts.map +1 -1
  81. package/lib/messaging/node/connection.js +12 -50
  82. package/lib/messaging/node/connection.js.map +1 -1
  83. package/lib/messaging/proxy-factory.d.ts +2 -0
  84. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  85. package/lib/messaging/proxy-factory.js +74 -159
  86. package/lib/messaging/proxy-factory.js.map +1 -1
  87. package/lib/oss-allowlist.d.ts +14 -0
  88. package/lib/oss-allowlist.d.ts.map +1 -0
  89. package/lib/oss-allowlist.js +8 -0
  90. package/lib/oss-allowlist.js.map +1 -0
  91. package/lib/payment-protocol.d.ts +18 -0
  92. package/lib/payment-protocol.d.ts.map +1 -0
  93. package/lib/payment-protocol.js +13 -0
  94. package/lib/payment-protocol.js.map +1 -0
  95. package/lib/permission.d.ts +2 -1
  96. package/lib/permission.d.ts.map +1 -1
  97. package/lib/permission.js +14 -13
  98. package/lib/permission.js.map +1 -1
  99. package/lib/plans.d.ts +210 -0
  100. package/lib/plans.d.ts.map +1 -0
  101. package/lib/plans.js +570 -0
  102. package/lib/plans.js.map +1 -0
  103. package/lib/protocol.d.ts +97 -15
  104. package/lib/protocol.d.ts.map +1 -1
  105. package/lib/protocol.js +104 -130
  106. package/lib/protocol.js.map +1 -1
  107. package/lib/snapshot-url.d.ts +14 -0
  108. package/lib/snapshot-url.d.ts.map +1 -0
  109. package/lib/snapshot-url.js +26 -0
  110. package/lib/snapshot-url.js.map +1 -0
  111. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  112. package/lib/snapshot-url.spec.d.ts.map +1 -0
  113. package/lib/snapshot-url.spec.js +41 -0
  114. package/lib/snapshot-url.spec.js.map +1 -0
  115. package/lib/team-subscription-protocol.d.ts +73 -0
  116. package/lib/team-subscription-protocol.d.ts.map +1 -0
  117. package/lib/team-subscription-protocol.js +63 -0
  118. package/lib/team-subscription-protocol.js.map +1 -0
  119. package/lib/teams-projects-protocol.d.ts +110 -0
  120. package/lib/teams-projects-protocol.d.ts.map +1 -0
  121. package/lib/teams-projects-protocol.js +23 -0
  122. package/lib/teams-projects-protocol.js.map +1 -0
  123. package/lib/util/analytics.d.ts +8 -0
  124. package/lib/util/analytics.d.ts.map +1 -0
  125. package/lib/util/analytics.js +79 -0
  126. package/lib/util/analytics.js.map +1 -0
  127. package/lib/util/async-iterator.js +55 -133
  128. package/lib/util/async-iterator.js.map +1 -1
  129. package/lib/util/cancelable.js +17 -59
  130. package/lib/util/cancelable.js.map +1 -1
  131. package/lib/util/date-time.js +8 -8
  132. package/lib/util/date-time.js.map +1 -1
  133. package/lib/util/deferred.js +10 -12
  134. package/lib/util/deferred.js.map +1 -1
  135. package/lib/util/disposable.js +26 -39
  136. package/lib/util/disposable.js.map +1 -1
  137. package/lib/util/event.js +58 -74
  138. package/lib/util/event.js.map +1 -1
  139. package/lib/util/garbage-collected-cache.d.ts +1 -0
  140. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  141. package/lib/util/garbage-collected-cache.js +26 -46
  142. package/lib/util/garbage-collected-cache.js.map +1 -1
  143. package/lib/util/generate-workspace-id.d.ts +1 -1
  144. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  145. package/lib/util/generate-workspace-id.js +30 -68
  146. package/lib/util/generate-workspace-id.js.map +1 -1
  147. package/lib/util/generate-workspace-id.spec.js +56 -78
  148. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  149. package/lib/util/gitpod-cookie.d.ts +20 -0
  150. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  151. package/lib/util/gitpod-cookie.js +44 -0
  152. package/lib/util/gitpod-cookie.js.map +1 -0
  153. package/lib/util/gitpod-host-url.d.ts +1 -1
  154. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  155. package/lib/util/gitpod-host-url.js +98 -98
  156. package/lib/util/gitpod-host-url.js.map +1 -1
  157. package/lib/util/gitpod-host-url.spec.d.ts +7 -1
  158. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  159. package/lib/util/gitpod-host-url.spec.js +103 -31
  160. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  161. package/lib/util/grpc.d.ts +15 -0
  162. package/lib/util/grpc.d.ts.map +1 -0
  163. package/lib/util/grpc.js +18 -0
  164. package/lib/util/grpc.js.map +1 -0
  165. package/lib/util/jaeger-client-types.d.ts +68 -0
  166. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  167. package/lib/util/{without.js → jaeger-client-types.js} +1 -1
  168. package/lib/util/jaeger-client-types.js.map +1 -0
  169. package/lib/util/logging.d.ts +49 -33
  170. package/lib/util/logging.d.ts.map +1 -1
  171. package/lib/util/logging.js +107 -110
  172. package/lib/util/logging.js.map +1 -1
  173. package/lib/util/make-link.js +2 -2
  174. package/lib/util/make-link.js.map +1 -1
  175. package/lib/util/parse-workspace-id.d.ts +10 -0
  176. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  177. package/lib/util/parse-workspace-id.js +32 -7
  178. package/lib/util/parse-workspace-id.js.map +1 -1
  179. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  180. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  181. package/lib/util/parse-workspace-id.spec.js +123 -84
  182. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  183. package/lib/util/queue.js +16 -55
  184. package/lib/util/queue.js.map +1 -1
  185. package/lib/util/queue.spec.js +144 -288
  186. package/lib/util/queue.spec.js.map +1 -1
  187. package/lib/util/repeat.d.ts +15 -0
  188. package/lib/util/repeat.d.ts.map +1 -0
  189. package/lib/util/repeat.js +55 -0
  190. package/lib/util/repeat.js.map +1 -0
  191. package/lib/util/safe-promise.js +9 -12
  192. package/lib/util/safe-promise.js.map +1 -1
  193. package/lib/util/semaphore.js +15 -46
  194. package/lib/util/semaphore.js.map +1 -1
  195. package/lib/util/skip-if.js +6 -6
  196. package/lib/util/skip-if.js.map +1 -1
  197. package/lib/util/timeutil.js +28 -16
  198. package/lib/util/timeutil.js.map +1 -1
  199. package/lib/util/timeutil.spec.js +21 -24
  200. package/lib/util/timeutil.spec.js.map +1 -1
  201. package/lib/util/tracing.d.ts +50 -5
  202. package/lib/util/tracing.d.ts.map +1 -1
  203. package/lib/util/tracing.js +175 -63
  204. package/lib/util/tracing.js.map +1 -1
  205. package/lib/util/tracing.spec.d.ts +7 -0
  206. package/lib/util/tracing.spec.d.ts.map +1 -0
  207. package/lib/util/tracing.spec.js +121 -0
  208. package/lib/util/tracing.spec.js.map +1 -0
  209. package/lib/util/workspace-port-authentication.js +3 -2
  210. package/lib/util/workspace-port-authentication.js.map +1 -1
  211. package/lib/workspace-cluster.d.ts +74 -0
  212. package/lib/workspace-cluster.d.ts.map +1 -0
  213. package/lib/workspace-cluster.js +16 -0
  214. package/lib/workspace-cluster.js.map +1 -0
  215. package/lib/workspace-instance.d.ts +5 -2
  216. package/lib/workspace-instance.d.ts.map +1 -1
  217. package/lib/wsready.d.ts +1 -1
  218. package/lib/wsready.js +2 -2
  219. package/package.json +31 -17
  220. package/pkg-yarn.lock +17 -9
  221. package/provenance-bundle.jsonl +2 -0
  222. package/src/accounting-protocol.ts +229 -0
  223. package/src/admin-protocol.ts +39 -5
  224. package/src/analytics.ts +54 -0
  225. package/src/context-url.spec.ts +39 -0
  226. package/src/context-url.ts +51 -0
  227. package/src/email-protocol.ts +2 -3
  228. package/src/env.ts +10 -10
  229. package/src/gitpod-service.ts +203 -34
  230. package/src/headless-workspace-log.ts +7 -11
  231. package/src/ide-protocol.ts +92 -0
  232. package/src/index.ts +6 -1
  233. package/src/messaging/browser/connection.ts +195 -14
  234. package/src/messaging/client-call-metrics.ts +97 -0
  235. package/src/messaging/error.ts +8 -2
  236. package/src/messaging/handler.ts +12 -0
  237. package/src/messaging/node/connection.ts +3 -47
  238. package/src/messaging/proxy-factory.ts +14 -6
  239. package/src/oss-allowlist.ts +15 -0
  240. package/src/payment-protocol.ts +20 -0
  241. package/src/permission.ts +2 -1
  242. package/src/plans.ts +632 -0
  243. package/src/protocol.ts +158 -43
  244. package/src/snapshot-url.spec.ts +25 -0
  245. package/src/snapshot-url.ts +27 -0
  246. package/src/team-subscription-protocol.ts +113 -0
  247. package/src/teams-projects-protocol.ts +141 -0
  248. package/src/util/analytics.ts +87 -0
  249. package/src/util/deferred.ts +1 -1
  250. package/src/util/garbage-collected-cache.ts +9 -3
  251. package/src/util/generate-workspace-id.spec.ts +19 -3
  252. package/src/util/generate-workspace-id.ts +21 -2
  253. package/src/util/gitpod-cookie.ts +39 -0
  254. package/src/util/gitpod-host-url.spec.ts +25 -1
  255. package/src/util/gitpod-host-url.ts +23 -10
  256. package/src/util/grpc.ts +15 -0
  257. package/src/util/jaeger-client-types.ts +102 -0
  258. package/src/util/logging.ts +102 -38
  259. package/src/util/parse-workspace-id.spec.ts +21 -1
  260. package/src/util/parse-workspace-id.ts +32 -6
  261. package/src/util/queue.spec.ts +1 -1
  262. package/src/util/repeat.ts +45 -0
  263. package/src/util/semaphore.ts +2 -2
  264. package/src/util/skip-if.ts +1 -1
  265. package/src/util/timeutil.ts +4 -4
  266. package/src/util/tracing.spec.ts +83 -0
  267. package/src/util/tracing.ts +162 -18
  268. package/src/workspace-cluster.ts +96 -0
  269. package/src/workspace-instance.ts +25 -13
  270. package/src/wsready.ts +2 -2
  271. package/lib/util/context-url.d.ts +0 -13
  272. package/lib/util/context-url.d.ts.map +0 -1
  273. package/lib/util/context-url.js +0 -26
  274. package/lib/util/context-url.js.map +0 -1
  275. package/lib/util/context-url.spec.d.ts.map +0 -1
  276. package/lib/util/context-url.spec.js +0 -52
  277. package/lib/util/context-url.spec.js.map +0 -1
  278. package/lib/util/repeater.d.ts +0 -22
  279. package/lib/util/repeater.d.ts.map +0 -1
  280. package/lib/util/repeater.js +0 -118
  281. package/lib/util/repeater.js.map +0 -1
  282. package/lib/util/without.d.ts +0 -7
  283. package/lib/util/without.d.ts.map +0 -1
  284. package/lib/util/without.js.map +0 -1
  285. package/src/util/context-url.spec.ts +0 -25
  286. package/src/util/context-url.ts +0 -23
  287. package/src/util/jaeger-client.d.ts +0 -105
  288. package/src/util/repeater.ts +0 -49
package/src/protocol.ts CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
8
8
  import { RoleOrPermission } from "./permission";
9
+ import { Project } from "./teams-projects-protocol";
9
10
 
10
11
  export interface UserInfo {
11
12
  name?: string
@@ -27,8 +28,6 @@ export interface User {
27
28
 
28
29
  identities: Identity[]
29
30
 
30
- allowsMarketingCommunication: boolean;
31
-
32
31
  /**
33
32
  * Whether the user has been blocked to use our service, because of TOS violation for example.
34
33
  * Optional for backwards compatibility.
@@ -98,14 +97,28 @@ export interface AdditionalUserData {
98
97
  emailNotificationSettings?: EmailNotificationSettings;
99
98
  featurePreview?: boolean;
100
99
  ideSettings?: IDESettings;
100
+ // key is the name of the news, string the iso date when it was seen
101
+ whatsNewSeen?: { [key: string]: string }
102
+ // key is the name of the OAuth client i.e. local app, string the iso date when it was approved
103
+ // TODO(rl): provide a management UX to allow rescinding of approval
104
+ oauthClientsApproved?: { [key: string]: string }
105
+ // to remember GH Orgs the user installed/updated the GH App for
106
+ knownGitHubOrgs?: string[];
107
+
108
+ // Git clone URL pointing to the user's dotfile repo
109
+ dotfileRepo?: string;
101
110
  }
102
111
 
103
112
  export interface EmailNotificationSettings {
104
- disallowTransactionalEmails?: boolean;
113
+ allowsChangelogMail?: boolean;
114
+ allowsDevXMail?: boolean;
115
+ allowsOnboardingMail?: boolean;
105
116
  }
106
117
 
107
118
  export type IDESettings = {
108
119
  defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
109
122
  }
110
123
 
111
124
  export interface UserPlatform {
@@ -127,14 +140,6 @@ export interface UserPlatform {
127
140
  }
128
141
 
129
142
  export interface UserFeatureSettings {
130
- /**
131
- * This field is used as marker to grant users a free trial for using private repositories,
132
- * independent of any subscription or Chargebee.
133
- * - it is set when the user uses their first private repo
134
- * - whether the trial is expired or not is juged by the UserService
135
- */
136
- privateRepoTrialStartDate?: string;
137
-
138
143
  /**
139
144
  * Permanent feature flags are added to each and every workspace instance
140
145
  * this user starts.
@@ -146,7 +151,7 @@ export interface UserFeatureSettings {
146
151
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
147
152
  * If they don't we'll break things during workspace startup.
148
153
  */
149
- export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined, "user_namespace": undefined };
154
+ export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
150
155
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
151
156
 
152
157
  export interface UserEnvVarValue {
@@ -167,6 +172,28 @@ export namespace UserEnvVar {
167
172
  return pattern.toLocaleLowerCase();
168
173
  }
169
174
 
175
+ export function score(value: UserEnvVarValue): number {
176
+ // We use a score to enforce precedence:
177
+ // value/value = 0
178
+ // value/* = 1
179
+ // */value = 2
180
+ // */* = 3
181
+ // #/# = 4 (used for env vars passed through the URL)
182
+ // the lower the score, the higher the precedence.
183
+ const [ownerPattern, repoPattern] = splitRepositoryPattern(value.repositoryPattern);
184
+ let score = 0;
185
+ if (repoPattern == "*") {
186
+ score += 1;
187
+ }
188
+ if (ownerPattern == '*') {
189
+ score += 2;
190
+ }
191
+ if (ownerPattern == "#" || repoPattern == "#") {
192
+ score = 4;
193
+ }
194
+ return score;
195
+ }
196
+
170
197
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
171
198
  let result = vars.filter(e => {
172
199
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -202,25 +229,7 @@ export namespace UserEnvVar {
202
229
  let minscore = 10;
203
230
  let bestCandidate: T | undefined;
204
231
  for (const e of candidates) {
205
- // We use a score to enforce precedence:
206
- // value/value = 0
207
- // value/* = 1
208
- // */value = 2
209
- // */* = 3
210
- // #/# = 4 (used for env vars passed through the URL)
211
- // the lower the score, the higher the precedence.
212
- const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
213
- let score = 0;
214
- if (repoPattern == "*") {
215
- score += 1;
216
- }
217
- if (ownerPattern == '*') {
218
- score += 2;
219
- }
220
- if (ownerPattern == "#" || repoPattern == "#") {
221
- score = 4;
222
- }
223
-
232
+ const score = UserEnvVar.score(e);
224
233
  if (!bestCandidate || score < minscore) {
225
234
  minscore = score;
226
235
  bestCandidate = e;
@@ -232,7 +241,7 @@ export namespace UserEnvVar {
232
241
  return result;
233
242
  }
234
243
 
235
- function splitRepositoryPattern(repositoryPattern: string): string[] {
244
+ export function splitRepositoryPattern(repositoryPattern: string): string[] {
236
245
  const patterns = repositoryPattern.split('/');
237
246
  const repoPattern = patterns.pop() || "";
238
247
  const ownerPattern = patterns.join('/');
@@ -366,11 +375,16 @@ export interface PendingGithubEvent {
366
375
  export interface Snapshot {
367
376
  id: string;
368
377
  creationTime: string;
378
+ availableTime?: string;
369
379
  originalWorkspaceId: string;
370
380
  bucketId: string;
371
381
  layoutData?: string;
382
+ state: SnapshotState;
383
+ message?: string;
372
384
  }
373
385
 
386
+ export type SnapshotState = 'pending' | 'available' | 'error';
387
+
374
388
  export interface LayoutData {
375
389
  workspaceId: string;
376
390
  lastUpdatedTime: string;
@@ -383,6 +397,7 @@ export interface Workspace {
383
397
  contextURL: string;
384
398
  description: string;
385
399
  ownerId: string;
400
+ projectId?: string;
386
401
  context: WorkspaceContext;
387
402
  config: WorkspaceConfig;
388
403
 
@@ -502,6 +517,24 @@ export interface UninstallPluginParams {
502
517
  pluginId: string;
503
518
  }
504
519
 
520
+ export interface GuessGitTokenScopesParams {
521
+ host: string
522
+ repoUrl: string
523
+ gitCommand: string
524
+ currentToken: GitToken
525
+ }
526
+
527
+ export interface GitToken {
528
+ token: string
529
+ user: string
530
+ scopes: string[]
531
+ }
532
+
533
+ export interface GuessedGitTokenScopes {
534
+ message?: string
535
+ scopes?: string[]
536
+ }
537
+
505
538
  export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
506
539
 
507
540
  export interface ResolvedPlugins {
@@ -527,16 +560,21 @@ export interface WorkspaceConfig {
527
560
  gitConfig?: { [config: string]: string };
528
561
  github?: GithubAppConfig;
529
562
  vscode?: VSCodeConfig;
530
-
563
+
564
+ /** deprecated. Enabled by default **/
565
+ experimentalNetwork?: boolean;
566
+
531
567
  /**
532
568
  * Where the config object originates from.
533
- *
569
+ *
534
570
  * repo - from the repository
571
+ * project-db - from the "Project" stored in the database
535
572
  * definitly-gp - from github.com/gitpod-io/definitely-gp
536
573
  * derived - computed based on analyzing the repository
574
+ * additional-content - config comes from additional content, usually provided through the project's configuration
537
575
  * default - our static catch-all default config
538
576
  */
539
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
577
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
540
578
 
541
579
  /**
542
580
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -566,16 +604,13 @@ export namespace GithubAppPrebuildConfig {
566
604
 
567
605
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
568
606
  export interface WorkspaceImageSourceDocker {
569
- // TODO: clean this up. We should have the commit and an ImageSource in here, not duplicate the whole thing again.
570
- // We have a ton of those objects in the database, thus cleaning this up means lengthy DB migrations. Yuck.
571
- dockerFileHash: string
572
- dockerFileSource: Commit
573
607
  dockerFilePath: string
608
+ dockerFileHash: string
609
+ dockerFileSource?: Commit
574
610
  }
575
611
  export namespace WorkspaceImageSourceDocker {
576
612
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
577
613
  return 'dockerFileHash' in obj
578
- && 'dockerFileSource' in obj
579
614
  && 'dockerFilePath' in obj;
580
615
  }
581
616
  }
@@ -604,6 +639,8 @@ export type PrebuiltWorkspaceState
604
639
  export interface PrebuiltWorkspace {
605
640
  id: string;
606
641
  cloneURL: string;
642
+ branch?: string;
643
+ projectId?: string;
607
644
  commit: string;
608
645
  buildWorkspaceId: string;
609
646
  creationTime: string;
@@ -614,7 +651,7 @@ export interface PrebuiltWorkspace {
614
651
 
615
652
  export namespace PrebuiltWorkspace {
616
653
  export function isDone(pws: PrebuiltWorkspace) {
617
- return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
654
+ return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
618
655
  }
619
656
 
620
657
  export function isAvailable(pws: PrebuiltWorkspace) {
@@ -650,6 +687,8 @@ export interface PortConfig {
650
687
  port: number;
651
688
  onOpen?: PortOnOpen;
652
689
  visibility?: PortVisibility;
690
+ description?: string;
691
+ name?: string;
653
692
  }
654
693
  export namespace PortConfig {
655
694
  export function is(config: any): config is PortConfig {
@@ -673,7 +712,7 @@ export interface TaskConfig {
673
712
  init?: string;
674
713
  prebuild?: string;
675
714
  command?: string;
676
- env?: { [env: string]: string };
715
+ env?: { [env: string]: any };
677
716
  openIn?: 'bottom' | 'main' | 'left' | 'right';
678
717
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
679
718
  }
@@ -737,8 +776,10 @@ export namespace ExternalImageConfigFile {
737
776
 
738
777
  export interface WorkspaceContext {
739
778
  title: string;
779
+ /** 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. */
740
780
  normalizedContextURL?: string;
741
781
  forceCreateNewWorkspace?: boolean;
782
+ forceImageBuild?: boolean;
742
783
  }
743
784
 
744
785
  export namespace WorkspaceContext {
@@ -772,6 +813,29 @@ export namespace WithPrebuild {
772
813
  }
773
814
  }
774
815
 
816
+ /**
817
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
818
+ * and fall back to the built-in configuration.
819
+ */
820
+ export interface WithDefaultConfig {
821
+ withDefaultConfig: true;
822
+ }
823
+
824
+ export namespace WithDefaultConfig {
825
+ export function is(context: any): context is WithDefaultConfig {
826
+ return context
827
+ && 'withDefaultConfig' in context
828
+ && context.withDefaultConfig;
829
+ }
830
+
831
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
832
+ return {
833
+ ...ctx,
834
+ withDefaultConfig: true
835
+ }
836
+ }
837
+ }
838
+
775
839
  export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
776
840
  snapshotId: string;
777
841
  }
@@ -786,6 +850,9 @@ export namespace SnapshotContext {
786
850
 
787
851
  export interface StartPrebuildContext extends WorkspaceContext {
788
852
  actual: WorkspaceContext;
853
+ commitHistory?: string[];
854
+ project?: Project;
855
+ branch?: string;
789
856
  }
790
857
 
791
858
  export namespace StartPrebuildContext {
@@ -855,6 +922,25 @@ export interface Commit {
855
922
  refType?: RefType
856
923
  }
857
924
 
925
+ export interface AdditionalContentContext extends WorkspaceContext {
926
+
927
+ /**
928
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
929
+ */
930
+ additionalFiles: {[filePath: string]: string};
931
+
932
+ }
933
+
934
+ export namespace AdditionalContentContext {
935
+ export function is(ctx: any): ctx is AdditionalContentContext {
936
+ return 'additionalFiles' in ctx;
937
+ }
938
+
939
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
940
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
941
+ }
942
+ }
943
+
858
944
  export interface CommitContext extends WorkspaceContext, Commit {
859
945
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
860
946
  cloneUrl?: string
@@ -930,6 +1016,19 @@ export interface Repository {
930
1016
  parent: Repository
931
1017
  }
932
1018
  }
1019
+ export interface Branch {
1020
+ name: string;
1021
+ commit: CommitInfo;
1022
+ htmlUrl: string;
1023
+ }
1024
+
1025
+ export interface CommitInfo {
1026
+ author: string;
1027
+ sha: string;
1028
+ commitMessage: string;
1029
+ authorAvatarUrl?: string;
1030
+ authorDate?: string;
1031
+ }
933
1032
 
934
1033
  export namespace Repository {
935
1034
  export function fullRepoName(repo: Repository): string {
@@ -957,6 +1056,12 @@ export interface WorkspaceInfo {
957
1056
  latestInstance?: WorkspaceInstance
958
1057
  }
959
1058
 
1059
+ export namespace WorkspaceInfo {
1060
+ export function lastActiveISODate(info: WorkspaceInfo): string {
1061
+ return info.latestInstance?.creationTime || info.workspace.creationTime;
1062
+ }
1063
+ }
1064
+
960
1065
  export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
961
1066
 
962
1067
  export interface WorkspaceCreationResult {
@@ -966,6 +1071,7 @@ export interface WorkspaceCreationResult {
966
1071
  runningWorkspacePrebuild?: {
967
1072
  prebuildID: string
968
1073
  workspaceID: string
1074
+ instanceID: string
969
1075
  starting: RunningWorkspacePrebuildStarting
970
1076
  sameCluster: boolean
971
1077
  }
@@ -1056,8 +1162,17 @@ export interface OAuth2Config {
1056
1162
  export namespace AuthProviderEntry {
1057
1163
  export type Type = "GitHub" | "GitLab" | string;
1058
1164
  export type Status = "pending" | "verified";
1059
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type">;
1165
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1060
1166
  export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
1167
+ export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1168
+ return {
1169
+ ...entry,
1170
+ oauth: {
1171
+ ...entry.oauth,
1172
+ clientSecret: "redacted"
1173
+ }
1174
+ }
1175
+ }
1061
1176
  }
1062
1177
 
1063
1178
  export interface Branding {
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { suite, test } from "mocha-typescript"
8
+ import * as chai from "chai"
9
+ import { SnapshotUrl } from ".";
10
+
11
+ const expect = chai.expect
12
+
13
+ @suite class TestSnapshotUrlParser {
14
+
15
+ @test public testPositive() {
16
+ const actual = SnapshotUrl.parse("workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd");
17
+
18
+ expect(actual).to.deep.equal(<SnapshotUrl>{
19
+ bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
20
+ filename: "3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
21
+ fullPath: "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
22
+ });
23
+ }
24
+ }
25
+ module.exports = new TestSnapshotUrlParser() // Only to circumvent no usage warning :-/
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ export interface SnapshotUrl {
8
+ bucketId: string;
9
+ fullPath: string;
10
+ filename: string;
11
+ }
12
+ export namespace SnapshotUrl {
13
+ export function parse(url: string): SnapshotUrl {
14
+ const parts = url.split("@");
15
+ if (parts.length !== 2) {
16
+ throw new Error(`cannot parse snapshot URL: ${url}`);
17
+ }
18
+ const [fullPath, bucketId] = parts;
19
+
20
+ const pathParts = fullPath.split("/");
21
+ if (pathParts.length < 1) {
22
+ throw new Error(`cannot parse snapshot URL: ${url}`);
23
+ }
24
+ const filename = pathParts[pathParts.length - 1];
25
+ return { bucketId, fullPath, filename };
26
+ }
27
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { v4 as uuidv4 } from 'uuid';
8
+ import { Subscription } from "./accounting-protocol";
9
+
10
+ export interface TeamSubscription {
11
+ id: string;
12
+ userId: string;
13
+ planId: string;
14
+ startDate: string;
15
+ endDate?: string;
16
+ quantity: number;
17
+ /** The Chargebee subscription id */
18
+ paymentReference: string;
19
+ cancellationDate?: string;
20
+ deleted?: boolean;
21
+ }
22
+
23
+ export namespace TeamSubscription {
24
+ export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
25
+ const withId = ts as TeamSubscription;
26
+ withId.id = uuidv4();
27
+ return withId;
28
+ }
29
+ export const isActive = (ts: TeamSubscription, date: string): boolean => {
30
+ return ts.startDate <= date && (ts.endDate === undefined || date < ts.endDate);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * A slot represents one unit of a TeamSubscription that gets assigned to one user at a time
36
+ */
37
+ export interface TeamSubscriptionSlot {
38
+ id: string;
39
+ teamSubscriptionId: string;
40
+ assigneeId?: string;
41
+ assigneeIdentifier?: AssigneeIdentifier;
42
+ subscriptionId?: string;
43
+ cancellationDate?: string;
44
+ }
45
+ export type TeamSubscriptionSlotDeactivated = TeamSubscriptionSlot & { assigneeId: string, assigneeIdentifier: AssigneeIdentifier };
46
+ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscriptionSlotDeactivated & { subscriptionId: string };
47
+
48
+ export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
49
+
50
+ export namespace TeamSubscriptionSlot {
51
+ export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
52
+ const withId = ts as TeamSubscriptionSlot;
53
+ withId.id = uuidv4();
54
+ return withId;
55
+ }
56
+ export const assign = (slot: TeamSubscriptionSlot, assigneeId: string, subscriptionId: string, assigneeIdentifier: AssigneeIdentifier) => {
57
+ slot.assigneeId = assigneeId;
58
+ slot.subscriptionId = subscriptionId;
59
+ slot.assigneeIdentifier = assigneeIdentifier;
60
+ }
61
+ export const deactivate = (slot: TeamSubscriptionSlot, cancellationDate: string) => {
62
+ slot.subscriptionId = undefined;
63
+ slot.cancellationDate = cancellationDate;
64
+ }
65
+ export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
66
+ slot.subscriptionId = subscriptionId;
67
+ slot.cancellationDate = undefined;
68
+ }
69
+ export const status = (slot: TeamSubscriptionSlot, now: string): TeamSubscriptionSlotState => {
70
+ if (slot.cancellationDate) {
71
+ if (slot.cancellationDate < now) {
72
+ return 'cancelled';
73
+ } else {
74
+ return 'deactivated';
75
+ }
76
+ } else {
77
+ if (slot.subscriptionId) {
78
+ return 'assigned';
79
+ } else {
80
+ return 'unassigned';
81
+ }
82
+ }
83
+
84
+ }
85
+ export const isActive = (slot: TeamSubscriptionSlot): boolean => {
86
+ return !slot.cancellationDate;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * The mapping between a TeamSubscription and a resulting Subscription, resolved
92
+ */
93
+ export interface TeamSubscriptionSlotResolved {
94
+ id: string;
95
+ teamSubscription: TeamSubscription;
96
+ state: TeamSubscriptionSlotState;
97
+ assigneeId?: string;
98
+ assigneeIdentifier?: AssigneeIdentifier;
99
+ subscription?: Subscription;
100
+ cancellationDate?: string;
101
+ hoursLeft?: number;
102
+ }
103
+
104
+ /**
105
+ * Contains the data structure that the assigner used to identify the assignee.
106
+ */
107
+ export type AssigneeIdentifier = AssigneeIdentityIdentifier;
108
+ export interface AssigneeIdentityIdentifier {
109
+ identity: {
110
+ authHost: string,
111
+ authName: string
112
+ }
113
+ }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { PrebuiltWorkspaceState } from "./protocol";
8
+ import { v4 as uuidv4 } from 'uuid';
9
+ import { DeepPartial } from "./util/deep-partial";
10
+
11
+ export interface ProjectConfig {
12
+ '.gitpod.yml': string;
13
+ }
14
+
15
+ export interface ProjectSettings {
16
+ useIncrementalPrebuilds?: boolean;
17
+ }
18
+
19
+ export interface Project {
20
+ id: string;
21
+ name: string;
22
+ slug?: string;
23
+ cloneUrl: string;
24
+ teamId?: string;
25
+ userId?: string;
26
+ appInstallationId: string;
27
+ config?: ProjectConfig;
28
+ settings?: ProjectSettings;
29
+ creationTime: string;
30
+ /** This is a flag that triggers the HARD DELETION of this entity */
31
+ deleted?: boolean;
32
+ markedDeleted?: boolean;
33
+ }
34
+
35
+ export namespace Project {
36
+ export const create = (project: Omit<Project, 'id' | 'creationTime'>): Project => {
37
+ return {
38
+ ...project,
39
+ id: uuidv4(),
40
+ creationTime: new Date().toISOString()
41
+ };
42
+ }
43
+
44
+ export interface Overview {
45
+ branches: BranchDetails[]
46
+ }
47
+
48
+ export interface BranchDetails {
49
+ name: string;
50
+ url: string;
51
+ isDefault: boolean;
52
+
53
+ // Latest commit
54
+ changeTitle: string;
55
+ changeDate?: string;
56
+ changeAuthor?: string;
57
+ changeAuthorAvatar?: string;
58
+ changePR?: string;
59
+ changeUrl?: string;
60
+ changeHash: string;
61
+ }
62
+ }
63
+
64
+ export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
65
+
66
+ export interface PrebuildWithStatus {
67
+ info: PrebuildInfo;
68
+ status: PrebuiltWorkspaceState;
69
+ error?: string;
70
+ }
71
+
72
+ export interface PrebuildInfo {
73
+ id: string;
74
+ buildWorkspaceId: string;
75
+ basedOnPrebuildId?: string;
76
+
77
+ teamId?: string;
78
+ userId?: string;
79
+
80
+ projectId: string;
81
+ projectName: string;
82
+
83
+ cloneUrl: string;
84
+ branch: string;
85
+
86
+ startedAt: string;
87
+ startedBy: string;
88
+ startedByAvatar?: string;
89
+
90
+ changeTitle: string;
91
+ changeDate: string;
92
+ changeAuthor: string;
93
+ changeAuthorAvatar?: string;
94
+ changePR?: string;
95
+ changeUrl?: string;
96
+ changeHash: string;
97
+ }
98
+ export namespace PrebuildInfo {
99
+ export function is(data?: any): data is PrebuildInfo {
100
+ return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every(p => p in data);
101
+ }
102
+ }
103
+
104
+ export interface StartPrebuildResult {
105
+ prebuildId: string;
106
+ wsid: string;
107
+ done: boolean;
108
+ }
109
+
110
+ export interface Team {
111
+ id: string;
112
+ name: string;
113
+ slug: string;
114
+ creationTime: string;
115
+ markedDeleted?: boolean;
116
+ /** This is a flag that triggers the HARD DELETION of this entity */
117
+ deleted?: boolean;
118
+ }
119
+
120
+ export type TeamMemberRole = "owner" | "member";
121
+
122
+ export interface TeamMemberInfo {
123
+ userId: string;
124
+ fullName?: string;
125
+ primaryEmail?: string;
126
+ avatarUrl?: string;
127
+ role: TeamMemberRole;
128
+ memberSince: string;
129
+ }
130
+
131
+ export interface TeamMembershipInvite {
132
+ id: string;
133
+ teamId: string;
134
+ role: TeamMemberRole;
135
+ creationTime: string;
136
+ invalidationTime: string;
137
+ invitedEmail?: string;
138
+
139
+ /** This is a flag that triggers the HARD DELETION of this entity */
140
+ deleted?: boolean;
141
+ }