@gitpod/gitpod-protocol 0.1.5-svenefftinge-patch-1.3 → 0.1.5-tar-telemetry-settings-data.3

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 (265) 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 +18 -5
  13. package/lib/context-url.d.ts.map +1 -1
  14. package/lib/context-url.js +62 -9
  15. package/lib/context-url.js.map +1 -1
  16. package/lib/context-url.spec.d.ts +2 -0
  17. package/lib/context-url.spec.d.ts.map +1 -1
  18. package/lib/context-url.spec.js +66 -48
  19. package/lib/context-url.spec.js.map +1 -1
  20. package/lib/email-protocol.js +4 -4
  21. package/lib/email-protocol.js.map +1 -1
  22. package/lib/encryption/container-module.js +4 -4
  23. package/lib/encryption/container-module.js.map +1 -1
  24. package/lib/encryption/encryption-engine.js +19 -20
  25. package/lib/encryption/encryption-engine.js.map +1 -1
  26. package/lib/encryption/encryption-engine.spec.js +29 -36
  27. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  28. package/lib/encryption/encryption-service.js +29 -43
  29. package/lib/encryption/encryption-service.js.map +1 -1
  30. package/lib/encryption/key-provider.js +25 -30
  31. package/lib/encryption/key-provider.js.map +1 -1
  32. package/lib/env.d.ts +1 -2
  33. package/lib/env.d.ts.map +1 -1
  34. package/lib/env.js +20 -21
  35. package/lib/env.js.map +1 -1
  36. package/lib/gitpod-file-parser.js +25 -41
  37. package/lib/gitpod-file-parser.js.map +1 -1
  38. package/lib/gitpod-file-parser.spec.js +116 -116
  39. package/lib/gitpod-file-parser.spec.js.map +1 -1
  40. package/lib/gitpod-service.d.ts +78 -20
  41. package/lib/gitpod-service.d.ts.map +1 -1
  42. package/lib/gitpod-service.js +151 -295
  43. package/lib/gitpod-service.js.map +1 -1
  44. package/lib/headless-workspace-log.d.ts +1 -12
  45. package/lib/headless-workspace-log.d.ts.map +1 -1
  46. package/lib/headless-workspace-log.js +1 -7
  47. package/lib/headless-workspace-log.js.map +1 -1
  48. package/lib/ide-protocol.d.ts +105 -0
  49. package/lib/ide-protocol.d.ts.map +1 -0
  50. package/lib/ide-protocol.js +8 -0
  51. package/lib/ide-protocol.js.map +1 -0
  52. package/lib/index.d.ts +3 -0
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/index.js +3 -0
  55. package/lib/index.js.map +1 -1
  56. package/lib/installation-admin-protocol.d.ts +27 -0
  57. package/lib/installation-admin-protocol.d.ts.map +1 -0
  58. package/lib/installation-admin-protocol.js +30 -0
  59. package/lib/installation-admin-protocol.js.map +1 -0
  60. package/lib/messaging/browser/connection.d.ts +3 -3
  61. package/lib/messaging/browser/connection.d.ts.map +1 -1
  62. package/lib/messaging/browser/connection.js +172 -35
  63. package/lib/messaging/browser/connection.js.map +1 -1
  64. package/lib/messaging/browser/window-connection.js +35 -55
  65. package/lib/messaging/browser/window-connection.js.map +1 -1
  66. package/lib/messaging/client-call-metrics.d.ts +35 -0
  67. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  68. package/lib/messaging/client-call-metrics.js +83 -0
  69. package/lib/messaging/client-call-metrics.js.map +1 -0
  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 +7 -2
  89. package/lib/permission.d.ts.map +1 -1
  90. package/lib/permission.js +34 -15
  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 +52 -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 +197 -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 +14 -2
  198. package/lib/workspace-cluster.d.ts.map +1 -1
  199. package/lib/workspace-cluster.js +21 -4
  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.spec.ts +18 -4
  211. package/src/context-url.ts +62 -6
  212. package/src/email-protocol.ts +1 -1
  213. package/src/env.ts +10 -10
  214. package/src/gitpod-service.ts +99 -32
  215. package/src/headless-workspace-log.ts +1 -14
  216. package/src/ide-frontend-service.ts +1 -1
  217. package/src/ide-protocol.ts +119 -0
  218. package/src/index.ts +3 -0
  219. package/src/installation-admin-protocol.ts +42 -0
  220. package/src/messaging/browser/connection.ts +176 -10
  221. package/src/messaging/client-call-metrics.ts +97 -0
  222. package/src/messaging/error.ts +5 -2
  223. package/src/messaging/handler.ts +12 -0
  224. package/src/messaging/node/connection.ts +21 -68
  225. package/src/messaging/proxy-factory.ts +13 -5
  226. package/src/oss-allowlist.ts +15 -0
  227. package/src/permission.ts +22 -4
  228. package/src/protocol.ts +71 -54
  229. package/src/snapshot-url.spec.ts +25 -0
  230. package/src/snapshot-url.ts +27 -0
  231. package/src/team-subscription-protocol.ts +1 -1
  232. package/src/teams-projects-protocol.ts +78 -7
  233. package/src/util/analytics.ts +17 -1
  234. package/src/util/garbage-collected-cache.ts +7 -1
  235. package/src/util/generate-workspace-id.spec.ts +17 -0
  236. package/src/util/generate-workspace-id.ts +20 -2
  237. package/src/util/gitpod-cookie.ts +39 -0
  238. package/src/util/gitpod-host-url.ts +11 -11
  239. package/src/util/grpc.ts +15 -0
  240. package/src/util/jaeger-client-types.ts +102 -0
  241. package/src/util/logging.ts +102 -38
  242. package/src/util/parse-workspace-id.spec.ts +21 -1
  243. package/src/util/parse-workspace-id.ts +32 -6
  244. package/src/util/repeat.ts +45 -0
  245. package/src/util/tracing.spec.ts +83 -0
  246. package/src/util/tracing.ts +183 -17
  247. package/src/workspace-cluster.ts +18 -3
  248. package/src/workspace-instance.ts +35 -6
  249. package/src/wsready.ts +1 -1
  250. package/lib/messaging/connection-error-handler.d.ts +0 -27
  251. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  252. package/lib/messaging/connection-error-handler.js +0 -46
  253. package/lib/messaging/connection-error-handler.js.map +0 -1
  254. package/lib/util/repeater.d.ts +0 -22
  255. package/lib/util/repeater.d.ts.map +0 -1
  256. package/lib/util/repeater.js +0 -118
  257. package/lib/util/repeater.js.map +0 -1
  258. package/lib/util/safe-promise.d.ts +0 -11
  259. package/lib/util/safe-promise.d.ts.map +0 -1
  260. package/lib/util/safe-promise.js +0 -34
  261. package/lib/util/safe-promise.js.map +0 -1
  262. package/src/messaging/connection-error-handler.ts +0 -62
  263. package/src/util/jaeger-client.d.ts +0 -105
  264. package/src/util/repeater.ts +0 -49
  265. 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,22 @@ 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
122
+ useLatestVersion?: boolean
117
123
  }
118
124
 
119
125
  export interface UserPlatform {
@@ -135,14 +141,6 @@ export interface UserPlatform {
135
141
  }
136
142
 
137
143
  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
144
  /**
147
145
  * Permanent feature flags are added to each and every workspace instance
148
146
  * this user starts.
@@ -157,12 +155,23 @@ export interface UserFeatureSettings {
157
155
  export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
158
156
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
159
157
 
160
- export interface UserEnvVarValue {
161
- id?: string;
158
+ export interface EnvVarWithValue {
162
159
  name: string;
163
- repositoryPattern: string;
164
160
  value: string;
165
161
  }
162
+
163
+ export interface ProjectEnvVarWithValue extends EnvVarWithValue {
164
+ id: string;
165
+ projectId: string;
166
+ censored: boolean;
167
+ }
168
+
169
+ export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
170
+
171
+ export interface UserEnvVarValue extends EnvVarWithValue {
172
+ id?: string;
173
+ repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
174
+ }
166
175
  export interface UserEnvVar extends UserEnvVarValue {
167
176
  id: string;
168
177
  userId: string;
@@ -171,10 +180,12 @@ export interface UserEnvVar extends UserEnvVarValue {
171
180
 
172
181
  export namespace UserEnvVar {
173
182
 
183
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
174
184
  export function normalizeRepoPattern(pattern: string) {
175
185
  return pattern.toLocaleLowerCase();
176
186
  }
177
187
 
188
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
178
189
  export function score(value: UserEnvVarValue): number {
179
190
  // We use a score to enforce precedence:
180
191
  // value/value = 0
@@ -197,6 +208,7 @@ export namespace UserEnvVar {
197
208
  return score;
198
209
  }
199
210
 
211
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
200
212
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
201
213
  let result = vars.filter(e => {
202
214
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -244,10 +256,11 @@ export namespace UserEnvVar {
244
256
  return result;
245
257
  }
246
258
 
259
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
247
260
  export function splitRepositoryPattern(repositoryPattern: string): string[] {
248
261
  const patterns = repositoryPattern.split('/');
249
- const repoPattern = patterns.pop() || "";
250
- const ownerPattern = patterns.join('/');
262
+ const repoPattern = patterns.slice(1).join('/')
263
+ const ownerPattern = patterns[0];
251
264
  return [ownerPattern, repoPattern];
252
265
  }
253
266
  }
@@ -378,11 +391,16 @@ export interface PendingGithubEvent {
378
391
  export interface Snapshot {
379
392
  id: string;
380
393
  creationTime: string;
394
+ availableTime?: string;
381
395
  originalWorkspaceId: string;
382
396
  bucketId: string;
383
397
  layoutData?: string;
398
+ state: SnapshotState;
399
+ message?: string;
384
400
  }
385
401
 
402
+ export type SnapshotState = 'pending' | 'available' | 'error';
403
+
386
404
  export interface LayoutData {
387
405
  workspaceId: string;
388
406
  lastUpdatedTime: string;
@@ -559,16 +577,20 @@ export interface WorkspaceConfig {
559
577
  github?: GithubAppConfig;
560
578
  vscode?: VSCodeConfig;
561
579
 
580
+ /** deprecated. Enabled by default **/
581
+ experimentalNetwork?: boolean;
582
+
562
583
  /**
563
584
  * Where the config object originates from.
564
585
  *
565
586
  * repo - from the repository
587
+ * project-db - from the "Project" stored in the database
566
588
  * definitly-gp - from github.com/gitpod-io/definitely-gp
567
589
  * derived - computed based on analyzing the repository
568
590
  * additional-content - config comes from additional content, usually provided through the project's configuration
569
591
  * default - our static catch-all default config
570
592
  */
571
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
593
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
572
594
 
573
595
  /**
574
596
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -585,7 +607,7 @@ export interface GithubAppPrebuildConfig {
585
607
  branches?: boolean
586
608
  pullRequests?: boolean
587
609
  pullRequestsFromForks?: boolean
588
- addCheck?: boolean
610
+ addCheck?: boolean | 'prevent-merge-on-error'
589
611
  addBadge?: boolean
590
612
  addLabel?: boolean | string
591
613
  addComment?: boolean
@@ -681,6 +703,8 @@ export interface PortConfig {
681
703
  port: number;
682
704
  onOpen?: PortOnOpen;
683
705
  visibility?: PortVisibility;
706
+ description?: string;
707
+ name?: string;
684
708
  }
685
709
  export namespace PortConfig {
686
710
  export function is(config: any): config is PortConfig {
@@ -704,7 +728,7 @@ export interface TaskConfig {
704
728
  init?: string;
705
729
  prebuild?: string;
706
730
  command?: string;
707
- env?: { [env: string]: string };
731
+ env?: { [env: string]: any };
708
732
  openIn?: 'bottom' | 'main' | 'left' | 'right';
709
733
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
710
734
  }
@@ -768,6 +792,7 @@ export namespace ExternalImageConfigFile {
768
792
 
769
793
  export interface WorkspaceContext {
770
794
  title: string;
795
+ /** 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
796
  normalizedContextURL?: string;
772
797
  forceCreateNewWorkspace?: boolean;
773
798
  forceImageBuild?: boolean;
@@ -867,8 +892,20 @@ export namespace PrebuiltWorkspaceContext {
867
892
  }
868
893
  }
869
894
 
895
+ export interface WithReferrerContext extends WorkspaceContext {
896
+ referrer: string
897
+ referrerIde?: string
898
+ }
899
+
900
+ export namespace WithReferrerContext {
901
+ export function is(context: any): context is WithReferrerContext {
902
+ return context
903
+ && 'referrer' in context;
904
+ }
905
+ }
906
+
870
907
  export interface WithEnvvarsContext extends WorkspaceContext {
871
- envvars: UserEnvVarValue[];
908
+ envvars: EnvVarWithValue[];
872
909
  }
873
910
 
874
911
  export namespace WithEnvvarsContext {
@@ -913,7 +950,7 @@ export interface Commit {
913
950
  refType?: RefType
914
951
  }
915
952
 
916
- export interface AdditionalContentContext {
953
+ export interface AdditionalContentContext extends WorkspaceContext {
917
954
 
918
955
  /**
919
956
  * utf-8 encoded contents that will be copied on top of the workspace's filesystem
@@ -1007,6 +1044,19 @@ export interface Repository {
1007
1044
  parent: Repository
1008
1045
  }
1009
1046
  }
1047
+ export interface Branch {
1048
+ name: string;
1049
+ commit: CommitInfo;
1050
+ htmlUrl: string;
1051
+ }
1052
+
1053
+ export interface CommitInfo {
1054
+ author: string;
1055
+ sha: string;
1056
+ commitMessage: string;
1057
+ authorAvatarUrl?: string;
1058
+ authorDate?: string;
1059
+ }
1010
1060
 
1011
1061
  export namespace Repository {
1012
1062
  export function fullRepoName(repo: Repository): string {
@@ -1153,39 +1203,6 @@ export namespace AuthProviderEntry {
1153
1203
  }
1154
1204
  }
1155
1205
 
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
1206
  export interface Configuration {
1190
1207
  readonly daysBeforeGarbageCollection: number;
1191
1208
  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;