@gitpod/gitpod-protocol 0.1.5-wth-update-mysql-dependencies-2.30 → 0.1.5-wth-test.41

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 (250) hide show
  1. package/data/builtin-theia-plugins.json +9 -9
  2. package/data/gitpod-schema.json +8 -22
  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/{util/without.js → analytics.js} +4 -2
  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 +132 -18
  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/index.d.ts +4 -0
  54. package/lib/index.d.ts.map +1 -1
  55. package/lib/index.js +5 -1
  56. package/lib/index.js.map +1 -1
  57. package/lib/messaging/browser/connection.d.ts +5 -3
  58. package/lib/messaging/browser/connection.d.ts.map +1 -1
  59. package/lib/messaging/browser/connection.js +183 -33
  60. package/lib/messaging/browser/connection.js.map +1 -1
  61. package/lib/messaging/browser/window-connection.js +35 -55
  62. package/lib/messaging/browser/window-connection.js.map +1 -1
  63. package/lib/messaging/client-call-metrics.d.ts +35 -0
  64. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  65. package/lib/messaging/client-call-metrics.js +83 -0
  66. package/lib/messaging/client-call-metrics.js.map +1 -0
  67. package/lib/messaging/connection-error-handler.js +11 -23
  68. package/lib/messaging/connection-error-handler.js.map +1 -1
  69. package/lib/messaging/error.d.ts +3 -1
  70. package/lib/messaging/error.d.ts.map +1 -1
  71. package/lib/messaging/error.js +6 -2
  72. package/lib/messaging/error.js.map +1 -1
  73. package/lib/messaging/handler.d.ts +10 -0
  74. package/lib/messaging/handler.d.ts.map +1 -1
  75. package/lib/messaging/node/connection.js +22 -22
  76. package/lib/messaging/node/connection.js.map +1 -1
  77. package/lib/messaging/proxy-factory.d.ts +2 -0
  78. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  79. package/lib/messaging/proxy-factory.js +74 -159
  80. package/lib/messaging/proxy-factory.js.map +1 -1
  81. package/lib/payment-protocol.d.ts +18 -0
  82. package/lib/payment-protocol.d.ts.map +1 -0
  83. package/lib/payment-protocol.js +13 -0
  84. package/lib/payment-protocol.js.map +1 -0
  85. package/lib/permission.d.ts +2 -1
  86. package/lib/permission.d.ts.map +1 -1
  87. package/lib/permission.js +14 -13
  88. package/lib/permission.js.map +1 -1
  89. package/lib/plans.d.ts +210 -0
  90. package/lib/plans.d.ts.map +1 -0
  91. package/lib/plans.js +570 -0
  92. package/lib/plans.js.map +1 -0
  93. package/lib/protocol.d.ts +94 -15
  94. package/lib/protocol.d.ts.map +1 -1
  95. package/lib/protocol.js +104 -130
  96. package/lib/protocol.js.map +1 -1
  97. package/lib/snapshot-url.d.ts +14 -0
  98. package/lib/snapshot-url.d.ts.map +1 -0
  99. package/lib/snapshot-url.js +26 -0
  100. package/lib/snapshot-url.js.map +1 -0
  101. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  102. package/lib/snapshot-url.spec.d.ts.map +1 -0
  103. package/lib/snapshot-url.spec.js +41 -0
  104. package/lib/snapshot-url.spec.js.map +1 -0
  105. package/lib/team-subscription-protocol.d.ts +73 -0
  106. package/lib/team-subscription-protocol.d.ts.map +1 -0
  107. package/lib/team-subscription-protocol.js +63 -0
  108. package/lib/team-subscription-protocol.js.map +1 -0
  109. package/lib/teams-projects-protocol.d.ts +103 -0
  110. package/lib/teams-projects-protocol.d.ts.map +1 -0
  111. package/lib/teams-projects-protocol.js +23 -0
  112. package/lib/teams-projects-protocol.js.map +1 -0
  113. package/lib/util/analytics.d.ts +8 -0
  114. package/lib/util/analytics.d.ts.map +1 -0
  115. package/lib/util/analytics.js +79 -0
  116. package/lib/util/analytics.js.map +1 -0
  117. package/lib/util/async-iterator.js +55 -133
  118. package/lib/util/async-iterator.js.map +1 -1
  119. package/lib/util/cancelable.js +17 -59
  120. package/lib/util/cancelable.js.map +1 -1
  121. package/lib/util/date-time.js +8 -8
  122. package/lib/util/date-time.js.map +1 -1
  123. package/lib/util/deferred.js +10 -12
  124. package/lib/util/deferred.js.map +1 -1
  125. package/lib/util/disposable.js +26 -39
  126. package/lib/util/disposable.js.map +1 -1
  127. package/lib/util/event.js +58 -74
  128. package/lib/util/event.js.map +1 -1
  129. package/lib/util/garbage-collected-cache.js +22 -46
  130. package/lib/util/garbage-collected-cache.js.map +1 -1
  131. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  132. package/lib/util/generate-workspace-id.js +13 -67
  133. package/lib/util/generate-workspace-id.js.map +1 -1
  134. package/lib/util/generate-workspace-id.spec.js +34 -79
  135. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  136. package/lib/util/gitpod-cookie.d.ts +20 -0
  137. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  138. package/lib/util/gitpod-cookie.js +44 -0
  139. package/lib/util/gitpod-cookie.js.map +1 -0
  140. package/lib/util/gitpod-host-url.d.ts +1 -1
  141. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  142. package/lib/util/gitpod-host-url.js +98 -98
  143. package/lib/util/gitpod-host-url.js.map +1 -1
  144. package/lib/util/gitpod-host-url.spec.d.ts +7 -1
  145. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  146. package/lib/util/gitpod-host-url.spec.js +103 -31
  147. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  148. package/lib/util/grpc.d.ts +15 -0
  149. package/lib/util/grpc.d.ts.map +1 -0
  150. package/lib/util/grpc.js +18 -0
  151. package/lib/util/grpc.js.map +1 -0
  152. package/lib/util/logging.d.ts +49 -33
  153. package/lib/util/logging.d.ts.map +1 -1
  154. package/lib/util/logging.js +107 -110
  155. package/lib/util/logging.js.map +1 -1
  156. package/lib/util/make-link.js +2 -2
  157. package/lib/util/make-link.js.map +1 -1
  158. package/lib/util/parse-workspace-id.d.ts +10 -0
  159. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  160. package/lib/util/parse-workspace-id.js +32 -7
  161. package/lib/util/parse-workspace-id.js.map +1 -1
  162. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  163. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  164. package/lib/util/parse-workspace-id.spec.js +123 -84
  165. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  166. package/lib/util/queue.js +16 -55
  167. package/lib/util/queue.js.map +1 -1
  168. package/lib/util/queue.spec.js +144 -288
  169. package/lib/util/queue.spec.js.map +1 -1
  170. package/lib/util/repeater.js +35 -88
  171. package/lib/util/repeater.js.map +1 -1
  172. package/lib/util/safe-promise.js +9 -12
  173. package/lib/util/safe-promise.js.map +1 -1
  174. package/lib/util/semaphore.js +15 -46
  175. package/lib/util/semaphore.js.map +1 -1
  176. package/lib/util/skip-if.js +6 -6
  177. package/lib/util/skip-if.js.map +1 -1
  178. package/lib/util/timeutil.js +28 -16
  179. package/lib/util/timeutil.js.map +1 -1
  180. package/lib/util/timeutil.spec.js +21 -24
  181. package/lib/util/timeutil.spec.js.map +1 -1
  182. package/lib/util/tracing.js +43 -47
  183. package/lib/util/tracing.js.map +1 -1
  184. package/lib/util/workspace-port-authentication.js +3 -2
  185. package/lib/util/workspace-port-authentication.js.map +1 -1
  186. package/lib/workspace-cluster.d.ts +74 -0
  187. package/lib/workspace-cluster.d.ts.map +1 -0
  188. package/lib/workspace-cluster.js +16 -0
  189. package/lib/workspace-cluster.js.map +1 -0
  190. package/lib/workspace-instance.d.ts +5 -2
  191. package/lib/workspace-instance.d.ts.map +1 -1
  192. package/lib/wsready.d.ts +1 -1
  193. package/lib/wsready.js +2 -2
  194. package/package.json +28 -16
  195. package/pkg-yarn.lock +17 -9
  196. package/src/accounting-protocol.ts +229 -0
  197. package/src/admin-protocol.ts +39 -5
  198. package/src/analytics.ts +54 -0
  199. package/src/context-url.spec.ts +39 -0
  200. package/src/context-url.ts +51 -0
  201. package/src/email-protocol.ts +2 -3
  202. package/src/env.ts +10 -10
  203. package/src/gitpod-service.ts +198 -33
  204. package/src/headless-workspace-log.ts +7 -11
  205. package/src/index.ts +5 -1
  206. package/src/messaging/browser/connection.ts +195 -14
  207. package/src/messaging/client-call-metrics.ts +97 -0
  208. package/src/messaging/error.ts +8 -2
  209. package/src/messaging/handler.ts +12 -0
  210. package/src/messaging/node/connection.ts +2 -2
  211. package/src/messaging/proxy-factory.ts +14 -6
  212. package/src/payment-protocol.ts +20 -0
  213. package/src/permission.ts +2 -1
  214. package/src/plans.ts +632 -0
  215. package/src/protocol.ts +153 -43
  216. package/src/snapshot-url.spec.ts +25 -0
  217. package/src/snapshot-url.ts +27 -0
  218. package/src/team-subscription-protocol.ts +113 -0
  219. package/src/teams-projects-protocol.ts +132 -0
  220. package/src/util/analytics.ts +87 -0
  221. package/src/util/deferred.ts +1 -1
  222. package/src/util/garbage-collected-cache.ts +2 -2
  223. package/src/util/generate-workspace-id.spec.ts +3 -3
  224. package/src/util/generate-workspace-id.ts +2 -0
  225. package/src/util/gitpod-cookie.ts +39 -0
  226. package/src/util/gitpod-host-url.spec.ts +25 -1
  227. package/src/util/gitpod-host-url.ts +23 -10
  228. package/src/util/grpc.ts +15 -0
  229. package/src/util/logging.ts +102 -38
  230. package/src/util/parse-workspace-id.spec.ts +21 -1
  231. package/src/util/parse-workspace-id.ts +32 -6
  232. package/src/util/queue.spec.ts +1 -1
  233. package/src/util/semaphore.ts +2 -2
  234. package/src/util/skip-if.ts +1 -1
  235. package/src/util/timeutil.ts +4 -4
  236. package/src/workspace-cluster.ts +96 -0
  237. package/src/workspace-instance.ts +25 -13
  238. package/src/wsready.ts +2 -2
  239. package/lib/util/context-url.d.ts +0 -13
  240. package/lib/util/context-url.d.ts.map +0 -1
  241. package/lib/util/context-url.js +0 -26
  242. package/lib/util/context-url.js.map +0 -1
  243. package/lib/util/context-url.spec.d.ts.map +0 -1
  244. package/lib/util/context-url.spec.js +0 -52
  245. package/lib/util/context-url.spec.js.map +0 -1
  246. package/lib/util/without.d.ts +0 -7
  247. package/lib/util/without.d.ts.map +0 -1
  248. package/lib/util/without.js.map +0 -1
  249. package/src/util/context-url.spec.ts +0 -25
  250. package/src/util/context-url.ts +0 -23
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,25 @@ 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[];
101
107
  }
102
108
 
103
109
  export interface EmailNotificationSettings {
104
- disallowTransactionalEmails?: boolean;
110
+ allowsChangelogMail?: boolean;
111
+ allowsDevXMail?: boolean;
112
+ allowsOnboardingMail?: boolean;
105
113
  }
106
114
 
107
115
  export type IDESettings = {
108
116
  defaultIde?: string
117
+ useDesktopIde?: boolean
118
+ defaultDesktopIde?: string
109
119
  }
110
120
 
111
121
  export interface UserPlatform {
@@ -127,14 +137,6 @@ export interface UserPlatform {
127
137
  }
128
138
 
129
139
  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
140
  /**
139
141
  * Permanent feature flags are added to each and every workspace instance
140
142
  * this user starts.
@@ -146,7 +148,7 @@ export interface UserFeatureSettings {
146
148
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
147
149
  * If they don't we'll break things during workspace startup.
148
150
  */
149
- export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined, "user_namespace": undefined };
151
+ export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
150
152
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
151
153
 
152
154
  export interface UserEnvVarValue {
@@ -167,6 +169,28 @@ export namespace UserEnvVar {
167
169
  return pattern.toLocaleLowerCase();
168
170
  }
169
171
 
172
+ export function score(value: UserEnvVarValue): number {
173
+ // We use a score to enforce precedence:
174
+ // value/value = 0
175
+ // value/* = 1
176
+ // */value = 2
177
+ // */* = 3
178
+ // #/# = 4 (used for env vars passed through the URL)
179
+ // the lower the score, the higher the precedence.
180
+ const [ownerPattern, repoPattern] = splitRepositoryPattern(value.repositoryPattern);
181
+ let score = 0;
182
+ if (repoPattern == "*") {
183
+ score += 1;
184
+ }
185
+ if (ownerPattern == '*') {
186
+ score += 2;
187
+ }
188
+ if (ownerPattern == "#" || repoPattern == "#") {
189
+ score = 4;
190
+ }
191
+ return score;
192
+ }
193
+
170
194
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
171
195
  let result = vars.filter(e => {
172
196
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -202,25 +226,7 @@ export namespace UserEnvVar {
202
226
  let minscore = 10;
203
227
  let bestCandidate: T | undefined;
204
228
  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
-
229
+ const score = UserEnvVar.score(e);
224
230
  if (!bestCandidate || score < minscore) {
225
231
  minscore = score;
226
232
  bestCandidate = e;
@@ -232,7 +238,7 @@ export namespace UserEnvVar {
232
238
  return result;
233
239
  }
234
240
 
235
- function splitRepositoryPattern(repositoryPattern: string): string[] {
241
+ export function splitRepositoryPattern(repositoryPattern: string): string[] {
236
242
  const patterns = repositoryPattern.split('/');
237
243
  const repoPattern = patterns.pop() || "";
238
244
  const ownerPattern = patterns.join('/');
@@ -366,11 +372,16 @@ export interface PendingGithubEvent {
366
372
  export interface Snapshot {
367
373
  id: string;
368
374
  creationTime: string;
375
+ availableTime?: string;
369
376
  originalWorkspaceId: string;
370
377
  bucketId: string;
371
378
  layoutData?: string;
379
+ state: SnapshotState;
380
+ message?: string;
372
381
  }
373
382
 
383
+ export type SnapshotState = 'pending' | 'available' | 'error';
384
+
374
385
  export interface LayoutData {
375
386
  workspaceId: string;
376
387
  lastUpdatedTime: string;
@@ -383,6 +394,7 @@ export interface Workspace {
383
394
  contextURL: string;
384
395
  description: string;
385
396
  ownerId: string;
397
+ projectId?: string;
386
398
  context: WorkspaceContext;
387
399
  config: WorkspaceConfig;
388
400
 
@@ -502,6 +514,24 @@ export interface UninstallPluginParams {
502
514
  pluginId: string;
503
515
  }
504
516
 
517
+ export interface GuessGitTokenScopesParams {
518
+ host: string
519
+ repoUrl: string
520
+ gitCommand: string
521
+ currentToken: GitToken
522
+ }
523
+
524
+ export interface GitToken {
525
+ token: string
526
+ user: string
527
+ scopes: string[]
528
+ }
529
+
530
+ export interface GuessedGitTokenScopes {
531
+ message?: string
532
+ scopes?: string[]
533
+ }
534
+
505
535
  export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
506
536
 
507
537
  export interface ResolvedPlugins {
@@ -527,16 +557,21 @@ export interface WorkspaceConfig {
527
557
  gitConfig?: { [config: string]: string };
528
558
  github?: GithubAppConfig;
529
559
  vscode?: VSCodeConfig;
530
-
560
+
561
+ /** tailscale demo */
562
+ experimentalNetwork?: boolean;
563
+
531
564
  /**
532
565
  * Where the config object originates from.
533
- *
566
+ *
534
567
  * repo - from the repository
568
+ * project-db - from the "Project" stored in the database
535
569
  * definitly-gp - from github.com/gitpod-io/definitely-gp
536
570
  * derived - computed based on analyzing the repository
571
+ * additional-content - config comes from additional content, usually provided through the project's configuration
537
572
  * default - our static catch-all default config
538
573
  */
539
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
574
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
540
575
 
541
576
  /**
542
577
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -566,16 +601,13 @@ export namespace GithubAppPrebuildConfig {
566
601
 
567
602
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
568
603
  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
604
  dockerFilePath: string
605
+ dockerFileHash: string
606
+ dockerFileSource?: Commit
574
607
  }
575
608
  export namespace WorkspaceImageSourceDocker {
576
609
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
577
610
  return 'dockerFileHash' in obj
578
- && 'dockerFileSource' in obj
579
611
  && 'dockerFilePath' in obj;
580
612
  }
581
613
  }
@@ -604,6 +636,8 @@ export type PrebuiltWorkspaceState
604
636
  export interface PrebuiltWorkspace {
605
637
  id: string;
606
638
  cloneURL: string;
639
+ branch?: string;
640
+ projectId?: string;
607
641
  commit: string;
608
642
  buildWorkspaceId: string;
609
643
  creationTime: string;
@@ -614,7 +648,7 @@ export interface PrebuiltWorkspace {
614
648
 
615
649
  export namespace PrebuiltWorkspace {
616
650
  export function isDone(pws: PrebuiltWorkspace) {
617
- return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
651
+ return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
618
652
  }
619
653
 
620
654
  export function isAvailable(pws: PrebuiltWorkspace) {
@@ -673,7 +707,7 @@ export interface TaskConfig {
673
707
  init?: string;
674
708
  prebuild?: string;
675
709
  command?: string;
676
- env?: { [env: string]: string };
710
+ env?: { [env: string]: any };
677
711
  openIn?: 'bottom' | 'main' | 'left' | 'right';
678
712
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
679
713
  }
@@ -737,8 +771,10 @@ export namespace ExternalImageConfigFile {
737
771
 
738
772
  export interface WorkspaceContext {
739
773
  title: string;
774
+ /** 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
775
  normalizedContextURL?: string;
741
776
  forceCreateNewWorkspace?: boolean;
777
+ forceImageBuild?: boolean;
742
778
  }
743
779
 
744
780
  export namespace WorkspaceContext {
@@ -772,6 +808,29 @@ export namespace WithPrebuild {
772
808
  }
773
809
  }
774
810
 
811
+ /**
812
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
813
+ * and fall back to the built-in configuration.
814
+ */
815
+ export interface WithDefaultConfig {
816
+ withDefaultConfig: true;
817
+ }
818
+
819
+ export namespace WithDefaultConfig {
820
+ export function is(context: any): context is WithDefaultConfig {
821
+ return context
822
+ && 'withDefaultConfig' in context
823
+ && context.withDefaultConfig;
824
+ }
825
+
826
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
827
+ return {
828
+ ...ctx,
829
+ withDefaultConfig: true
830
+ }
831
+ }
832
+ }
833
+
775
834
  export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
776
835
  snapshotId: string;
777
836
  }
@@ -786,6 +845,9 @@ export namespace SnapshotContext {
786
845
 
787
846
  export interface StartPrebuildContext extends WorkspaceContext {
788
847
  actual: WorkspaceContext;
848
+ commitHistory?: string[];
849
+ project?: Project;
850
+ branch?: string;
789
851
  }
790
852
 
791
853
  export namespace StartPrebuildContext {
@@ -855,6 +917,25 @@ export interface Commit {
855
917
  refType?: RefType
856
918
  }
857
919
 
920
+ export interface AdditionalContentContext extends WorkspaceContext {
921
+
922
+ /**
923
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
924
+ */
925
+ additionalFiles: {[filePath: string]: string};
926
+
927
+ }
928
+
929
+ export namespace AdditionalContentContext {
930
+ export function is(ctx: any): ctx is AdditionalContentContext {
931
+ return 'additionalFiles' in ctx;
932
+ }
933
+
934
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
935
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
936
+ }
937
+ }
938
+
858
939
  export interface CommitContext extends WorkspaceContext, Commit {
859
940
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
860
941
  cloneUrl?: string
@@ -930,6 +1011,19 @@ export interface Repository {
930
1011
  parent: Repository
931
1012
  }
932
1013
  }
1014
+ export interface Branch {
1015
+ name: string;
1016
+ commit: CommitInfo;
1017
+ htmlUrl: string;
1018
+ }
1019
+
1020
+ export interface CommitInfo {
1021
+ author: string;
1022
+ sha: string;
1023
+ commitMessage: string;
1024
+ authorAvatarUrl?: string;
1025
+ authorDate?: string;
1026
+ }
933
1027
 
934
1028
  export namespace Repository {
935
1029
  export function fullRepoName(repo: Repository): string {
@@ -957,6 +1051,12 @@ export interface WorkspaceInfo {
957
1051
  latestInstance?: WorkspaceInstance
958
1052
  }
959
1053
 
1054
+ export namespace WorkspaceInfo {
1055
+ export function lastActiveISODate(info: WorkspaceInfo): string {
1056
+ return info.latestInstance?.creationTime || info.workspace.creationTime;
1057
+ }
1058
+ }
1059
+
960
1060
  export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
961
1061
 
962
1062
  export interface WorkspaceCreationResult {
@@ -966,6 +1066,7 @@ export interface WorkspaceCreationResult {
966
1066
  runningWorkspacePrebuild?: {
967
1067
  prebuildID: string
968
1068
  workspaceID: string
1069
+ instanceID: string
969
1070
  starting: RunningWorkspacePrebuildStarting
970
1071
  sameCluster: boolean
971
1072
  }
@@ -1056,8 +1157,17 @@ export interface OAuth2Config {
1056
1157
  export namespace AuthProviderEntry {
1057
1158
  export type Type = "GitHub" | "GitLab" | string;
1058
1159
  export type Status = "pending" | "verified";
1059
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type">;
1160
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1060
1161
  export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
1162
+ export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1163
+ return {
1164
+ ...entry,
1165
+ oauth: {
1166
+ ...entry.oauth,
1167
+ clientSecret: "redacted"
1168
+ }
1169
+ }
1170
+ }
1061
1171
  }
1062
1172
 
1063
1173
  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,132 @@
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
+
10
+ export interface ProjectConfig {
11
+ '.gitpod.yml': string;
12
+ }
13
+
14
+ export interface Project {
15
+ id: string;
16
+ name: string;
17
+ slug?: string;
18
+ cloneUrl: string;
19
+ teamId?: string;
20
+ userId?: string;
21
+ appInstallationId: string;
22
+ config?: ProjectConfig;
23
+ creationTime: string;
24
+ /** This is a flag that triggers the HARD DELETION of this entity */
25
+ deleted?: boolean;
26
+ markedDeleted?: boolean;
27
+ }
28
+
29
+ export namespace Project {
30
+ export const create = (project: Omit<Project, 'id' | 'creationTime'>): Project => {
31
+ return {
32
+ ...project,
33
+ id: uuidv4(),
34
+ creationTime: new Date().toISOString()
35
+ };
36
+ }
37
+
38
+ export interface Overview {
39
+ branches: BranchDetails[]
40
+ }
41
+
42
+ export interface BranchDetails {
43
+ name: string;
44
+ url: string;
45
+ isDefault: boolean;
46
+
47
+ // Latest commit
48
+ changeTitle: string;
49
+ changeDate?: string;
50
+ changeAuthor?: string;
51
+ changeAuthorAvatar?: string;
52
+ changePR?: string;
53
+ changeUrl?: string;
54
+ changeHash: string;
55
+ }
56
+ }
57
+
58
+ export interface PrebuildWithStatus {
59
+ info: PrebuildInfo;
60
+ status: PrebuiltWorkspaceState;
61
+ error?: string;
62
+ }
63
+
64
+ export interface PrebuildInfo {
65
+ id: string;
66
+ buildWorkspaceId: string;
67
+
68
+ teamId?: string;
69
+ userId?: string;
70
+
71
+ projectId: string;
72
+ projectName: string;
73
+
74
+ cloneUrl: string;
75
+ branch: string;
76
+
77
+ startedAt: string;
78
+ startedBy: string;
79
+ startedByAvatar?: string;
80
+
81
+ changeTitle: string;
82
+ changeDate: string;
83
+ changeAuthor: string;
84
+ changeAuthorAvatar?: string;
85
+ changePR?: string;
86
+ changeUrl?: string;
87
+ changeHash: string;
88
+ }
89
+ export namespace PrebuildInfo {
90
+ export function is(data?: any): data is PrebuildInfo {
91
+ return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every(p => p in data);
92
+ }
93
+ }
94
+
95
+ export interface StartPrebuildResult {
96
+ prebuildId: string;
97
+ wsid: string;
98
+ done: boolean;
99
+ }
100
+
101
+ export interface Team {
102
+ id: string;
103
+ name: string;
104
+ slug: string;
105
+ creationTime: string;
106
+ markedDeleted?: boolean;
107
+ /** This is a flag that triggers the HARD DELETION of this entity */
108
+ deleted?: boolean;
109
+ }
110
+
111
+ export type TeamMemberRole = "owner" | "member";
112
+
113
+ export interface TeamMemberInfo {
114
+ userId: string;
115
+ fullName?: string;
116
+ primaryEmail?: string;
117
+ avatarUrl?: string;
118
+ role: TeamMemberRole;
119
+ memberSince: string;
120
+ }
121
+
122
+ export interface TeamMembershipInvite {
123
+ id: string;
124
+ teamId: string;
125
+ role: TeamMemberRole;
126
+ creationTime: string;
127
+ invalidationTime: string;
128
+ invitedEmail?: string;
129
+
130
+ /** This is a flag that triggers the HARD DELETION of this entity */
131
+ deleted?: boolean;
132
+ }