@gitpod/gitpod-protocol 0.1.5-svenefftinge-patch-1.3 → 0.1.5-tarun-telemetry-users.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/data/gitpod-schema.json +21 -2
  2. package/lib/accounting-protocol.d.ts +0 -1
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +10 -11
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +18 -2
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +13 -1
  11. package/lib/analytics.d.ts.map +1 -1
  12. package/lib/context-url.d.ts +1 -0
  13. package/lib/context-url.d.ts.map +1 -1
  14. package/lib/context-url.js +7 -5
  15. package/lib/context-url.js.map +1 -1
  16. package/lib/context-url.spec.js +45 -48
  17. package/lib/context-url.spec.js.map +1 -1
  18. package/lib/email-protocol.js +4 -4
  19. package/lib/email-protocol.js.map +1 -1
  20. package/lib/encryption/container-module.js +4 -4
  21. package/lib/encryption/container-module.js.map +1 -1
  22. package/lib/encryption/encryption-engine.js +19 -20
  23. package/lib/encryption/encryption-engine.js.map +1 -1
  24. package/lib/encryption/encryption-engine.spec.js +29 -36
  25. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  26. package/lib/encryption/encryption-service.js +29 -43
  27. package/lib/encryption/encryption-service.js.map +1 -1
  28. package/lib/encryption/key-provider.js +25 -30
  29. package/lib/encryption/key-provider.js.map +1 -1
  30. package/lib/env.d.ts +1 -2
  31. package/lib/env.d.ts.map +1 -1
  32. package/lib/env.js +20 -21
  33. package/lib/env.js.map +1 -1
  34. package/lib/gitpod-file-parser.js +25 -41
  35. package/lib/gitpod-file-parser.js.map +1 -1
  36. package/lib/gitpod-file-parser.spec.js +116 -116
  37. package/lib/gitpod-file-parser.spec.js.map +1 -1
  38. package/lib/gitpod-service.d.ts +68 -20
  39. package/lib/gitpod-service.d.ts.map +1 -1
  40. package/lib/gitpod-service.js +151 -295
  41. package/lib/gitpod-service.js.map +1 -1
  42. package/lib/headless-workspace-log.d.ts +1 -12
  43. package/lib/headless-workspace-log.d.ts.map +1 -1
  44. package/lib/headless-workspace-log.js +1 -7
  45. package/lib/headless-workspace-log.js.map +1 -1
  46. package/lib/ide-protocol.d.ts +101 -0
  47. package/lib/ide-protocol.d.ts.map +1 -0
  48. package/lib/ide-protocol.js +8 -0
  49. package/lib/ide-protocol.js.map +1 -0
  50. package/lib/index.d.ts +3 -0
  51. package/lib/index.d.ts.map +1 -1
  52. package/lib/index.js +3 -0
  53. package/lib/index.js.map +1 -1
  54. package/lib/installation-admin-protocol.d.ts +25 -0
  55. package/lib/installation-admin-protocol.d.ts.map +1 -0
  56. package/lib/installation-admin-protocol.js +30 -0
  57. package/lib/installation-admin-protocol.js.map +1 -0
  58. package/lib/messaging/browser/connection.d.ts +3 -3
  59. package/lib/messaging/browser/connection.d.ts.map +1 -1
  60. package/lib/messaging/browser/connection.js +172 -35
  61. package/lib/messaging/browser/connection.js.map +1 -1
  62. package/lib/messaging/browser/window-connection.js +35 -55
  63. package/lib/messaging/browser/window-connection.js.map +1 -1
  64. package/lib/messaging/client-call-metrics.d.ts +35 -0
  65. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  66. package/lib/messaging/client-call-metrics.js +83 -0
  67. package/lib/messaging/client-call-metrics.js.map +1 -0
  68. package/lib/messaging/connection-error-handler.js +11 -23
  69. package/lib/messaging/connection-error-handler.js.map +1 -1
  70. package/lib/messaging/error.d.ts +2 -1
  71. package/lib/messaging/error.d.ts.map +1 -1
  72. package/lib/messaging/error.js +4 -2
  73. package/lib/messaging/error.js.map +1 -1
  74. package/lib/messaging/handler.d.ts +10 -0
  75. package/lib/messaging/handler.d.ts.map +1 -1
  76. package/lib/messaging/node/connection.d.ts +1 -17
  77. package/lib/messaging/node/connection.d.ts.map +1 -1
  78. package/lib/messaging/node/connection.js +23 -59
  79. package/lib/messaging/node/connection.js.map +1 -1
  80. package/lib/messaging/proxy-factory.d.ts +2 -0
  81. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  82. package/lib/messaging/proxy-factory.js +74 -159
  83. package/lib/messaging/proxy-factory.js.map +1 -1
  84. package/lib/oss-allowlist.d.ts +14 -0
  85. package/lib/oss-allowlist.d.ts.map +1 -0
  86. package/lib/oss-allowlist.js +8 -0
  87. package/lib/oss-allowlist.js.map +1 -0
  88. package/lib/permission.d.ts +4 -2
  89. package/lib/permission.d.ts.map +1 -1
  90. package/lib/permission.js +16 -13
  91. package/lib/permission.js.map +1 -1
  92. package/lib/plans.d.ts +1 -1
  93. package/lib/plans.d.ts.map +1 -1
  94. package/lib/plans.js +38 -57
  95. package/lib/plans.js.map +1 -1
  96. package/lib/protocol.d.ts +51 -49
  97. package/lib/protocol.d.ts.map +1 -1
  98. package/lib/protocol.js +57 -115
  99. package/lib/protocol.js.map +1 -1
  100. package/lib/snapshot-url.d.ts +14 -0
  101. package/lib/snapshot-url.d.ts.map +1 -0
  102. package/lib/snapshot-url.js +26 -0
  103. package/lib/snapshot-url.js.map +1 -0
  104. package/lib/snapshot-url.spec.d.ts +7 -0
  105. package/lib/snapshot-url.spec.d.ts.map +1 -0
  106. package/lib/snapshot-url.spec.js +41 -0
  107. package/lib/snapshot-url.spec.js.map +1 -0
  108. package/lib/team-subscription-protocol.js +13 -13
  109. package/lib/team-subscription-protocol.js.map +1 -1
  110. package/lib/teams-projects-protocol.d.ts +59 -6
  111. package/lib/teams-projects-protocol.d.ts.map +1 -1
  112. package/lib/teams-projects-protocol.js +18 -15
  113. package/lib/teams-projects-protocol.js.map +1 -1
  114. package/lib/util/analytics.d.ts.map +1 -1
  115. package/lib/util/analytics.js +35 -26
  116. package/lib/util/analytics.js.map +1 -1
  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.d.ts +1 -0
  130. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  131. package/lib/util/garbage-collected-cache.js +26 -46
  132. package/lib/util/garbage-collected-cache.js.map +1 -1
  133. package/lib/util/generate-workspace-id.d.ts +1 -1
  134. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  135. package/lib/util/generate-workspace-id.js +29 -68
  136. package/lib/util/generate-workspace-id.js.map +1 -1
  137. package/lib/util/generate-workspace-id.spec.js +57 -78
  138. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  139. package/lib/util/gitpod-cookie.d.ts +20 -0
  140. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  141. package/lib/util/gitpod-cookie.js +44 -0
  142. package/lib/util/gitpod-cookie.js.map +1 -0
  143. package/lib/util/gitpod-host-url.d.ts +1 -1
  144. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  145. package/lib/util/gitpod-host-url.js +93 -103
  146. package/lib/util/gitpod-host-url.js.map +1 -1
  147. package/lib/util/gitpod-host-url.spec.js +87 -135
  148. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  149. package/lib/util/grpc.d.ts +15 -0
  150. package/lib/util/grpc.d.ts.map +1 -0
  151. package/lib/util/grpc.js +18 -0
  152. package/lib/util/grpc.js.map +1 -0
  153. package/lib/util/jaeger-client-types.d.ts +68 -0
  154. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  155. package/lib/util/jaeger-client-types.js +8 -0
  156. package/lib/util/jaeger-client-types.js.map +1 -0
  157. package/lib/util/logging.d.ts +49 -33
  158. package/lib/util/logging.d.ts.map +1 -1
  159. package/lib/util/logging.js +107 -110
  160. package/lib/util/logging.js.map +1 -1
  161. package/lib/util/make-link.js +2 -2
  162. package/lib/util/make-link.js.map +1 -1
  163. package/lib/util/parse-workspace-id.d.ts +10 -0
  164. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  165. package/lib/util/parse-workspace-id.js +31 -7
  166. package/lib/util/parse-workspace-id.js.map +1 -1
  167. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  168. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  169. package/lib/util/parse-workspace-id.spec.js +123 -84
  170. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  171. package/lib/util/queue.js +16 -55
  172. package/lib/util/queue.js.map +1 -1
  173. package/lib/util/queue.spec.js +144 -288
  174. package/lib/util/queue.spec.js.map +1 -1
  175. package/lib/util/repeat.d.ts +15 -0
  176. package/lib/util/repeat.d.ts.map +1 -0
  177. package/lib/util/repeat.js +55 -0
  178. package/lib/util/repeat.js.map +1 -0
  179. package/lib/util/semaphore.js +15 -46
  180. package/lib/util/semaphore.js.map +1 -1
  181. package/lib/util/skip-if.js +6 -6
  182. package/lib/util/skip-if.js.map +1 -1
  183. package/lib/util/timeutil.js +16 -16
  184. package/lib/util/timeutil.js.map +1 -1
  185. package/lib/util/timeutil.spec.js +21 -24
  186. package/lib/util/timeutil.spec.js.map +1 -1
  187. package/lib/util/tracing.d.ts +51 -5
  188. package/lib/util/tracing.d.ts.map +1 -1
  189. package/lib/util/tracing.js +196 -62
  190. package/lib/util/tracing.js.map +1 -1
  191. package/lib/util/tracing.spec.d.ts +7 -0
  192. package/lib/util/tracing.spec.d.ts.map +1 -0
  193. package/lib/util/tracing.spec.js +121 -0
  194. package/lib/util/tracing.spec.js.map +1 -0
  195. package/lib/util/workspace-port-authentication.js +2 -2
  196. package/lib/util/workspace-port-authentication.js.map +1 -1
  197. package/lib/workspace-cluster.d.ts +8 -1
  198. package/lib/workspace-cluster.d.ts.map +1 -1
  199. package/lib/workspace-cluster.js +3 -3
  200. package/lib/workspace-cluster.js.map +1 -1
  201. package/lib/workspace-instance.d.ts +24 -2
  202. package/lib/workspace-instance.d.ts.map +1 -1
  203. package/lib/wsready.js +1 -1
  204. package/package.json +24 -13
  205. package/pkg-yarn.lock +14 -7
  206. package/provenance-bundle.jsonl +2 -0
  207. package/src/accounting-protocol.ts +1 -3
  208. package/src/admin-protocol.ts +25 -6
  209. package/src/analytics.ts +16 -1
  210. package/src/context-url.ts +3 -1
  211. package/src/email-protocol.ts +1 -1
  212. package/src/env.ts +10 -10
  213. package/src/gitpod-service.ts +88 -33
  214. package/src/headless-workspace-log.ts +1 -14
  215. package/src/ide-frontend-service.ts +1 -1
  216. package/src/ide-protocol.ts +114 -0
  217. package/src/index.ts +3 -0
  218. package/src/installation-admin-protocol.ts +40 -0
  219. package/src/messaging/browser/connection.ts +176 -10
  220. package/src/messaging/client-call-metrics.ts +97 -0
  221. package/src/messaging/error.ts +5 -2
  222. package/src/messaging/handler.ts +12 -0
  223. package/src/messaging/node/connection.ts +21 -68
  224. package/src/messaging/proxy-factory.ts +13 -5
  225. package/src/oss-allowlist.ts +15 -0
  226. package/src/permission.ts +5 -1
  227. package/src/protocol.ts +70 -54
  228. package/src/snapshot-url.spec.ts +25 -0
  229. package/src/snapshot-url.ts +27 -0
  230. package/src/team-subscription-protocol.ts +1 -1
  231. package/src/teams-projects-protocol.ts +78 -7
  232. package/src/util/analytics.ts +17 -1
  233. package/src/util/garbage-collected-cache.ts +7 -1
  234. package/src/util/generate-workspace-id.spec.ts +17 -0
  235. package/src/util/generate-workspace-id.ts +20 -2
  236. package/src/util/gitpod-cookie.ts +39 -0
  237. package/src/util/gitpod-host-url.ts +11 -11
  238. package/src/util/grpc.ts +15 -0
  239. package/src/util/jaeger-client-types.ts +102 -0
  240. package/src/util/logging.ts +102 -38
  241. package/src/util/parse-workspace-id.spec.ts +21 -1
  242. package/src/util/parse-workspace-id.ts +32 -6
  243. package/src/util/repeat.ts +45 -0
  244. package/src/util/tracing.spec.ts +83 -0
  245. package/src/util/tracing.ts +183 -18
  246. package/src/workspace-cluster.ts +3 -1
  247. package/src/workspace-instance.ts +35 -6
  248. package/src/wsready.ts +1 -1
  249. package/lib/util/repeater.d.ts +0 -22
  250. package/lib/util/repeater.d.ts.map +0 -1
  251. package/lib/util/repeater.js +0 -118
  252. package/lib/util/repeater.js.map +0 -1
  253. package/lib/util/safe-promise.d.ts +0 -11
  254. package/lib/util/safe-promise.d.ts.map +0 -1
  255. package/lib/util/safe-promise.js +0 -34
  256. package/lib/util/safe-promise.js.map +0 -1
  257. package/src/util/jaeger-client.d.ts +0 -105
  258. package/src/util/repeater.ts +0 -49
  259. package/src/util/safe-promise.ts +0 -26
package/src/protocol.ts CHANGED
@@ -28,8 +28,6 @@ export interface User {
28
28
 
29
29
  identities: Identity[]
30
30
 
31
- allowsMarketingCommunication: boolean;
32
-
33
31
  /**
34
32
  * Whether the user has been blocked to use our service, because of TOS violation for example.
35
33
  * Optional for backwards compatibility.
@@ -106,14 +104,21 @@ export interface AdditionalUserData {
106
104
  oauthClientsApproved?: { [key: string]: string }
107
105
  // to remember GH Orgs the user installed/updated the GH App for
108
106
  knownGitHubOrgs?: string[];
107
+
108
+ // Git clone URL pointing to the user's dotfile repo
109
+ dotfileRepo?: string;
109
110
  }
110
111
 
111
112
  export interface EmailNotificationSettings {
112
- disallowTransactionalEmails?: boolean;
113
+ allowsChangelogMail?: boolean;
114
+ allowsDevXMail?: boolean;
115
+ allowsOnboardingMail?: boolean;
113
116
  }
114
117
 
115
118
  export type IDESettings = {
116
119
  defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
117
122
  }
118
123
 
119
124
  export interface UserPlatform {
@@ -135,14 +140,6 @@ export interface UserPlatform {
135
140
  }
136
141
 
137
142
  export interface UserFeatureSettings {
138
- /**
139
- * This field is used as marker to grant users a free trial for using private repositories,
140
- * independent of any subscription or Chargebee.
141
- * - it is set when the user uses their first private repo
142
- * - whether the trial is expired or not is juged by the UserService
143
- */
144
- privateRepoTrialStartDate?: string;
145
-
146
143
  /**
147
144
  * Permanent feature flags are added to each and every workspace instance
148
145
  * this user starts.
@@ -157,12 +154,23 @@ export interface UserFeatureSettings {
157
154
  export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
158
155
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
159
156
 
160
- export interface UserEnvVarValue {
161
- id?: string;
157
+ export interface EnvVarWithValue {
162
158
  name: string;
163
- repositoryPattern: string;
164
159
  value: string;
165
160
  }
161
+
162
+ export interface ProjectEnvVarWithValue extends EnvVarWithValue {
163
+ id: string;
164
+ projectId: string;
165
+ censored: boolean;
166
+ }
167
+
168
+ export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
169
+
170
+ export interface UserEnvVarValue extends EnvVarWithValue {
171
+ id?: string;
172
+ repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
173
+ }
166
174
  export interface UserEnvVar extends UserEnvVarValue {
167
175
  id: string;
168
176
  userId: string;
@@ -171,10 +179,12 @@ export interface UserEnvVar extends UserEnvVarValue {
171
179
 
172
180
  export namespace UserEnvVar {
173
181
 
182
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
174
183
  export function normalizeRepoPattern(pattern: string) {
175
184
  return pattern.toLocaleLowerCase();
176
185
  }
177
186
 
187
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
178
188
  export function score(value: UserEnvVarValue): number {
179
189
  // We use a score to enforce precedence:
180
190
  // value/value = 0
@@ -197,6 +207,7 @@ export namespace UserEnvVar {
197
207
  return score;
198
208
  }
199
209
 
210
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
200
211
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
201
212
  let result = vars.filter(e => {
202
213
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -244,10 +255,11 @@ export namespace UserEnvVar {
244
255
  return result;
245
256
  }
246
257
 
258
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
247
259
  export function splitRepositoryPattern(repositoryPattern: string): string[] {
248
260
  const patterns = repositoryPattern.split('/');
249
- const repoPattern = patterns.pop() || "";
250
- const ownerPattern = patterns.join('/');
261
+ const repoPattern = patterns.slice(1).join('/')
262
+ const ownerPattern = patterns[0];
251
263
  return [ownerPattern, repoPattern];
252
264
  }
253
265
  }
@@ -378,11 +390,16 @@ export interface PendingGithubEvent {
378
390
  export interface Snapshot {
379
391
  id: string;
380
392
  creationTime: string;
393
+ availableTime?: string;
381
394
  originalWorkspaceId: string;
382
395
  bucketId: string;
383
396
  layoutData?: string;
397
+ state: SnapshotState;
398
+ message?: string;
384
399
  }
385
400
 
401
+ export type SnapshotState = 'pending' | 'available' | 'error';
402
+
386
403
  export interface LayoutData {
387
404
  workspaceId: string;
388
405
  lastUpdatedTime: string;
@@ -559,16 +576,20 @@ export interface WorkspaceConfig {
559
576
  github?: GithubAppConfig;
560
577
  vscode?: VSCodeConfig;
561
578
 
579
+ /** deprecated. Enabled by default **/
580
+ experimentalNetwork?: boolean;
581
+
562
582
  /**
563
583
  * Where the config object originates from.
564
584
  *
565
585
  * repo - from the repository
586
+ * project-db - from the "Project" stored in the database
566
587
  * definitly-gp - from github.com/gitpod-io/definitely-gp
567
588
  * derived - computed based on analyzing the repository
568
589
  * additional-content - config comes from additional content, usually provided through the project's configuration
569
590
  * default - our static catch-all default config
570
591
  */
571
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
592
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
572
593
 
573
594
  /**
574
595
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -585,7 +606,7 @@ export interface GithubAppPrebuildConfig {
585
606
  branches?: boolean
586
607
  pullRequests?: boolean
587
608
  pullRequestsFromForks?: boolean
588
- addCheck?: boolean
609
+ addCheck?: boolean | 'prevent-merge-on-error'
589
610
  addBadge?: boolean
590
611
  addLabel?: boolean | string
591
612
  addComment?: boolean
@@ -681,6 +702,8 @@ export interface PortConfig {
681
702
  port: number;
682
703
  onOpen?: PortOnOpen;
683
704
  visibility?: PortVisibility;
705
+ description?: string;
706
+ name?: string;
684
707
  }
685
708
  export namespace PortConfig {
686
709
  export function is(config: any): config is PortConfig {
@@ -704,7 +727,7 @@ export interface TaskConfig {
704
727
  init?: string;
705
728
  prebuild?: string;
706
729
  command?: string;
707
- env?: { [env: string]: string };
730
+ env?: { [env: string]: any };
708
731
  openIn?: 'bottom' | 'main' | 'left' | 'right';
709
732
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
710
733
  }
@@ -768,6 +791,7 @@ export namespace ExternalImageConfigFile {
768
791
 
769
792
  export interface WorkspaceContext {
770
793
  title: string;
794
+ /** 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. */
771
795
  normalizedContextURL?: string;
772
796
  forceCreateNewWorkspace?: boolean;
773
797
  forceImageBuild?: boolean;
@@ -867,8 +891,20 @@ export namespace PrebuiltWorkspaceContext {
867
891
  }
868
892
  }
869
893
 
894
+ export interface WithReferrerContext extends WorkspaceContext {
895
+ referrer: string
896
+ referrerIde?: string
897
+ }
898
+
899
+ export namespace WithReferrerContext {
900
+ export function is(context: any): context is WithReferrerContext {
901
+ return context
902
+ && 'referrer' in context;
903
+ }
904
+ }
905
+
870
906
  export interface WithEnvvarsContext extends WorkspaceContext {
871
- envvars: UserEnvVarValue[];
907
+ envvars: EnvVarWithValue[];
872
908
  }
873
909
 
874
910
  export namespace WithEnvvarsContext {
@@ -913,7 +949,7 @@ export interface Commit {
913
949
  refType?: RefType
914
950
  }
915
951
 
916
- export interface AdditionalContentContext {
952
+ export interface AdditionalContentContext extends WorkspaceContext {
917
953
 
918
954
  /**
919
955
  * utf-8 encoded contents that will be copied on top of the workspace's filesystem
@@ -1007,6 +1043,19 @@ export interface Repository {
1007
1043
  parent: Repository
1008
1044
  }
1009
1045
  }
1046
+ export interface Branch {
1047
+ name: string;
1048
+ commit: CommitInfo;
1049
+ htmlUrl: string;
1050
+ }
1051
+
1052
+ export interface CommitInfo {
1053
+ author: string;
1054
+ sha: string;
1055
+ commitMessage: string;
1056
+ authorAvatarUrl?: string;
1057
+ authorDate?: string;
1058
+ }
1010
1059
 
1011
1060
  export namespace Repository {
1012
1061
  export function fullRepoName(repo: Repository): string {
@@ -1153,39 +1202,6 @@ export namespace AuthProviderEntry {
1153
1202
  }
1154
1203
  }
1155
1204
 
1156
- export interface Branding {
1157
- readonly name: string;
1158
- readonly favicon?: string;
1159
- /** Either including domain OR absolute path (interpreted relative to host URL) */
1160
- readonly logo: string;
1161
- readonly startupLogo: string;
1162
- readonly showProductivityTips: boolean;
1163
- readonly redirectUrlIfNotAuthenticated?: string;
1164
- readonly redirectUrlAfterLogout?: string;
1165
- readonly homepage: string;
1166
- readonly ide?: {
1167
- readonly logo: string;
1168
- readonly showReleaseNotes: boolean;
1169
- readonly helpMenu: Branding.Link[];
1170
- }
1171
- readonly links: {
1172
- readonly header: Branding.Link[];
1173
- readonly footer: Branding.Link[];
1174
- readonly social: Branding.SocialLink[];
1175
- readonly legal: Branding.Link[];
1176
- }
1177
- }
1178
- export namespace Branding {
1179
- export interface Link {
1180
- readonly name: string;
1181
- readonly url: string;
1182
- }
1183
- export interface SocialLink {
1184
- readonly type: string;
1185
- readonly url: string;
1186
- }
1187
- }
1188
-
1189
1205
  export interface Configuration {
1190
1206
  readonly daysBeforeGarbageCollection: number;
1191
1207
  readonly garbageCollectionStartDate: number;
@@ -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
+ }
@@ -4,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import uuidv4 = require("uuid/v4");
7
+ import { v4 as uuidv4 } from 'uuid';
8
8
  import { Subscription } from "./accounting-protocol";
9
9
 
10
10
  export interface TeamSubscription {
@@ -5,17 +5,31 @@
5
5
  */
6
6
 
7
7
  import { PrebuiltWorkspaceState } from "./protocol";
8
- import uuidv4 = require("uuid/v4");
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
+ }
9
18
 
10
19
  export interface Project {
11
20
  id: string;
12
21
  name: string;
22
+ slug?: string;
13
23
  cloneUrl: string;
14
- teamId: string;
24
+ teamId?: string;
25
+ userId?: string;
15
26
  appInstallationId: string;
27
+ config?: ProjectConfig;
28
+ settings?: ProjectSettings;
16
29
  creationTime: string;
17
30
  /** This is a flag that triggers the HARD DELETION of this entity */
18
31
  deleted?: boolean;
32
+ markedDeleted?: boolean;
19
33
  }
20
34
 
21
35
  export namespace Project {
@@ -26,21 +40,77 @@ export namespace Project {
26
40
  creationTime: new Date().toISOString()
27
41
  };
28
42
  }
43
+
44
+ export interface Overview {
45
+ branches: BranchDetails[];
46
+ }
47
+
48
+ export namespace Overview {
49
+ export function is(data?: any): data is Project.Overview {
50
+ return Array.isArray(data?.branches);
51
+ }
52
+ }
53
+
54
+ export interface BranchDetails {
55
+ name: string;
56
+ url: string;
57
+ isDefault: boolean;
58
+
59
+ // Latest commit
60
+ changeTitle: string;
61
+ changeDate?: string;
62
+ changeAuthor?: string;
63
+ changeAuthorAvatar?: string;
64
+ changePR?: string;
65
+ changeUrl?: string;
66
+ changeHash: string;
67
+ }
29
68
  }
30
69
 
31
- export interface ProjectInfo extends Project {
32
- lastPrebuild?: PrebuildInfo;
70
+ export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
71
+
72
+ export interface PrebuildWithStatus {
73
+ info: PrebuildInfo;
74
+ status: PrebuiltWorkspaceState;
75
+ error?: string;
33
76
  }
34
77
 
35
78
  export interface PrebuildInfo {
36
79
  id: string;
37
- teamId: string;
38
- project: string;
80
+ buildWorkspaceId: string;
81
+ basedOnPrebuildId?: string;
82
+
83
+ teamId?: string;
84
+ userId?: string;
85
+
86
+ projectId: string;
87
+ projectName: string;
88
+
39
89
  cloneUrl: string;
40
90
  branch: string;
91
+
41
92
  startedAt: string;
42
93
  startedBy: string;
43
- status: PrebuiltWorkspaceState;
94
+ startedByAvatar?: string;
95
+
96
+ changeTitle: string;
97
+ changeDate: string;
98
+ changeAuthor: string;
99
+ changeAuthorAvatar?: string;
100
+ changePR?: string;
101
+ changeUrl?: string;
102
+ changeHash: string;
103
+ }
104
+ export namespace PrebuildInfo {
105
+ export function is(data?: any): data is PrebuildInfo {
106
+ return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every(p => p in data);
107
+ }
108
+ }
109
+
110
+ export interface StartPrebuildResult {
111
+ prebuildId: string;
112
+ wsid: string;
113
+ done: boolean;
44
114
  }
45
115
 
46
116
  export interface Team {
@@ -48,6 +118,7 @@ export interface Team {
48
118
  name: string;
49
119
  slug: string;
50
120
  creationTime: string;
121
+ markedDeleted?: boolean;
51
122
  /** This is a flag that triggers the HARD DELETION of this entity */
52
123
  deleted?: boolean;
53
124
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import Analytics = require("analytics-node");
8
- import { IAnalyticsWriter, IdentifyMessage, TrackMessage } from "../analytics";
8
+ import { IAnalyticsWriter, IdentifyMessage, TrackMessage, PageMessage } from "../analytics";
9
9
  import { log } from './logging';
10
10
 
11
11
 
@@ -52,6 +52,18 @@ class SegmentAnalyticsWriter implements IAnalyticsWriter {
52
52
  }
53
53
  }
54
54
 
55
+ page(msg: PageMessage) {
56
+ try{
57
+ this.analytics.page(msg, (err: Error) => {
58
+ if (err) {
59
+ log.warn("analytics.page failed", err);
60
+ }
61
+ });
62
+ } catch (err) {
63
+ log.warn("analytics.page failed", err);
64
+ }
65
+ }
66
+
55
67
  }
56
68
 
57
69
  class LogAnalyticsWriter implements IAnalyticsWriter {
@@ -62,10 +74,14 @@ class LogAnalyticsWriter implements IAnalyticsWriter {
62
74
  track(msg: TrackMessage): void {
63
75
  log.debug("analytics track", msg);
64
76
  }
77
+ page(msg: PageMessage): void {
78
+ log.debug("analytics page", msg);
79
+ }
65
80
 
66
81
  }
67
82
 
68
83
  class NoAnalyticsWriter implements IAnalyticsWriter {
69
84
  identify(msg: IdentifyMessage): void {}
70
85
  track(msg: TrackMessage): void {}
86
+ page(msg: PageMessage): void {}
71
87
  }
@@ -4,6 +4,8 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
+ import { repeat } from "./repeat";
8
+
7
9
 
8
10
  interface CacheEntry<T> {
9
11
  key: string;
@@ -41,8 +43,12 @@ export class GarbageCollectedCache<T> {
41
43
  return entry.value;
42
44
  }
43
45
 
46
+ public delete(key: string) {
47
+ this.store.delete(key);
48
+ }
49
+
44
50
  protected regularlyCollectGarbage() {
45
- setInterval(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
51
+ repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
46
52
  }
47
53
 
48
54
  protected collectGarbage() {
@@ -27,5 +27,22 @@ const expect = chai.expect
27
27
  expect(longestName.length <= 36, `"${longestName}" is longer than 36 chars (${longestName.length})`).to.be.true;
28
28
  }
29
29
 
30
+ @test public async testCustomName() {
31
+ const data = [
32
+ ['foo','bar','foo-bar-'],
33
+ ['f','bar','.{2,16}-bar-'],
34
+ ['gitpod-io','gitpod','gitpodio-gitpod-'],
35
+ ['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
36
+ ['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
37
+ ['UPPER', "CaSe", "upper-case-"]
38
+ ]
39
+ for (const d of data) {
40
+ const id = await generateWorkspaceID(d[0], d[1]);
41
+ expect(id).match(new RegExp("^"+d[2]));
42
+ expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
43
+ expect(id.length <= 36, `"${id}" is longer than 36 chars (${id.length})`).to.be.true;
44
+ }
45
+ }
46
+
30
47
  }
31
48
  module.exports = new TestGenerateWorkspaceId()
@@ -5,8 +5,26 @@
5
5
  */
6
6
  import randomNumber = require("random-number-csprng");
7
7
 
8
- export async function generateWorkspaceID(): Promise<string> {
9
- return (await random(colors))+'-'+(await random(animals))+'-'+(await random(characters, 8));
8
+ export async function generateWorkspaceID(firstSegment?: string, secondSegment?: string): Promise<string> {
9
+ const firstSeg = clean(firstSegment) || await random(colors);
10
+ const secSeg = clean(secondSegment, Math.min(15, 23 - firstSeg.length)) || await random(animals);
11
+ return firstSeg+'-'+secSeg+'-'+(await random(characters, 11));
12
+ }
13
+
14
+ function clean(segment: string | undefined, maxChars: number = 15) {
15
+ if (!segment) {
16
+ return undefined;
17
+ }
18
+ segment = segment.toLowerCase();
19
+ let result = '';
20
+ for (let i =0; i < segment.length; i++) {
21
+ if (characters.indexOf(segment[i]) !== -1) {
22
+ result += segment[i];
23
+ }
24
+ }
25
+ if (result.length >= 2) {
26
+ return result.substring(0, maxChars);
27
+ }
10
28
  }
11
29
 
12
30
  async function random(array: string[], length: number = 1): Promise<string> {
@@ -0,0 +1,39 @@
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
+ import * as cookie from 'cookie';
7
+
8
+
9
+ /**
10
+ * This cookie indicates whether the connected client is a Gitpod user (= "has logged in within the last year") or not.
11
+ * This is used by "gitpod.io" and "www.gitpod.io" to display different content/buttons.
12
+ */
13
+ export const NAME = "gitpod-user";
14
+ export const VALUE = "true";
15
+
16
+ /**
17
+ * @param domain The domain the Gitpod installation is installed onto
18
+ * @returns
19
+ */
20
+ export function options(domain: string): cookie.CookieSerializeOptions {
21
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
22
+ return {
23
+ path: "/", // make sure we send the cookie to all sub-pages
24
+ httpOnly: false,
25
+ secure: false,
26
+ maxAge: 60 * 60 * 24 * 365, // 1 year
27
+ sameSite: "lax", // default: true. "Lax" needed to ensure we see cookies from users that neavigate to gitpod.io from external sites
28
+ domain: `.${domain}`, // explicilty include subdomains to not only cover "gitpod.io", but also "www.gitpod.io" or workspaces
29
+ };
30
+ };
31
+
32
+ export function generateCookie(domain: string): string {
33
+ return cookie.serialize(NAME, VALUE, options(domain));
34
+ };
35
+
36
+ export function isPresent(cookies: string): boolean {
37
+ // needs to match the old (gitpod-user=loggedIn) and new (gitpod-user=true) values to ensure a smooth transition during rollout.
38
+ return !!cookies.match(`${NAME}=`);
39
+ };
@@ -12,13 +12,13 @@ export interface UrlChange {
12
12
  }
13
13
  export type UrlUpdate = UrlChange | Partial<URL>;
14
14
 
15
- const basewoWkspaceIDRegex = "(([a-f][0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8}))";
15
+ const baseWorkspaceIDRegex = "(([a-f][0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}))";
16
16
 
17
17
  // this pattern matches v4 UUIDs as well as the new generated workspace ids (e.g. pink-panda-ns35kd21)
18
- const workspaceIDRegex = RegExp(`^${basewoWkspaceIDRegex}$`);
18
+ const workspaceIDRegex = RegExp(`^${baseWorkspaceIDRegex}$`);
19
19
 
20
20
  // this pattern matches URL prefixes of workspaces
21
- const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${basewoWkspaceIDRegex}\\.`);
21
+ const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${baseWorkspaceIDRegex}\\.`);
22
22
 
23
23
  export class GitpodHostUrl {
24
24
  readonly url: URL;
@@ -85,27 +85,27 @@ export class GitpodHostUrl {
85
85
  }
86
86
 
87
87
  asDashboard(): GitpodHostUrl {
88
- return this.with(url => ({ pathname: '/workspaces/' }));
88
+ return this.with(url => ({ pathname: '/' }));
89
89
  }
90
90
 
91
91
  asLogin(): GitpodHostUrl {
92
- return this.with(url => ({ pathname: '/login/' }));
92
+ return this.with(url => ({ pathname: '/login' }));
93
93
  }
94
94
 
95
95
  asUpgradeSubscription(): GitpodHostUrl {
96
- return this.with(url => ({ pathname: '/plans/' }));
96
+ return this.with(url => ({ pathname: '/plans' }));
97
97
  }
98
98
 
99
99
  asAccessControl(): GitpodHostUrl {
100
- return this.with(url => ({ pathname: '/access-control/' }));
100
+ return this.with(url => ({ pathname: '/integrations' }));
101
101
  }
102
102
 
103
103
  asSettings(): GitpodHostUrl {
104
- return this.with(url => ({ pathname: '/settings/' }));
104
+ return this.with(url => ({ pathname: '/settings' }));
105
105
  }
106
106
 
107
- asGraphQLApi(): GitpodHostUrl {
108
- return this.with(url => ({ pathname: '/graphql/' }));
107
+ asPreferences(): GitpodHostUrl {
108
+ return this.with(url => ({ pathname: '/preferences' }));
109
109
  }
110
110
 
111
111
  asStart(workspaceId = this.workspaceId): GitpodHostUrl {
@@ -150,7 +150,7 @@ export class GitpodHostUrl {
150
150
  return undefined;
151
151
  }
152
152
 
153
- get blobServe(): boolean {
153
+ get blobServe(): boolean {
154
154
  const hostSegments = this.url.host.split(".");
155
155
  if (hostSegments[0] === 'blobserve') {
156
156
  return true;