@gitpod/gitpod-protocol 0.1.5-test.8 → 0.1.5-to-new-image.2

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 (365) hide show
  1. package/data/builtin-theia-plugins.json +28 -18
  2. package/data/gitpod-schema.json +34 -19
  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 +34 -5
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +16 -1
  10. package/lib/admin-protocol.js.map +1 -1
  11. package/lib/analytics.d.ts +44 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/auth.d.ts +25 -0
  16. package/lib/auth.d.ts.map +1 -0
  17. package/lib/auth.js +16 -0
  18. package/lib/auth.js.map +1 -0
  19. package/lib/context-url.d.ts +31 -0
  20. package/lib/context-url.d.ts.map +1 -0
  21. package/lib/context-url.js +102 -0
  22. package/lib/context-url.js.map +1 -0
  23. package/lib/context-url.spec.d.ts +14 -0
  24. package/lib/context-url.spec.d.ts.map +1 -0
  25. package/lib/context-url.spec.js +94 -0
  26. package/lib/context-url.spec.js.map +1 -0
  27. package/lib/email-protocol.d.ts +2 -2
  28. package/lib/email-protocol.d.ts.map +1 -1
  29. package/lib/email-protocol.js +6 -5
  30. package/lib/email-protocol.js.map +1 -1
  31. package/lib/encryption/container-module.d.ts +1 -1
  32. package/lib/encryption/container-module.js +7 -5
  33. package/lib/encryption/container-module.js.map +1 -1
  34. package/lib/encryption/encryption-engine.d.ts +1 -1
  35. package/lib/encryption/encryption-engine.js +21 -21
  36. package/lib/encryption/encryption-engine.js.map +1 -1
  37. package/lib/encryption/encryption-engine.spec.d.ts +2 -2
  38. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  39. package/lib/encryption/encryption-engine.spec.js +31 -37
  40. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  41. package/lib/encryption/encryption-service.d.ts +1 -1
  42. package/lib/encryption/encryption-service.js +31 -44
  43. package/lib/encryption/encryption-service.js.map +1 -1
  44. package/lib/encryption/key-provider.d.ts +2 -2
  45. package/lib/encryption/key-provider.d.ts.map +1 -1
  46. package/lib/encryption/key-provider.js +27 -31
  47. package/lib/encryption/key-provider.js.map +1 -1
  48. package/lib/env.d.ts +2 -3
  49. package/lib/env.d.ts.map +1 -1
  50. package/lib/env.js +21 -21
  51. package/lib/env.js.map +1 -1
  52. package/lib/gitpod-file-parser.d.ts +1 -1
  53. package/lib/gitpod-file-parser.js +27 -42
  54. package/lib/gitpod-file-parser.js.map +1 -1
  55. package/lib/gitpod-file-parser.spec.d.ts +1 -1
  56. package/lib/gitpod-file-parser.spec.js +117 -117
  57. package/lib/gitpod-file-parser.spec.js.map +1 -1
  58. package/lib/gitpod-service.d.ts +213 -35
  59. package/lib/gitpod-service.d.ts.map +1 -1
  60. package/lib/gitpod-service.js +241 -116
  61. package/lib/gitpod-service.js.map +1 -1
  62. package/lib/headless-workspace-log.d.ts +9 -12
  63. package/lib/headless-workspace-log.d.ts.map +1 -1
  64. package/lib/headless-workspace-log.js +5 -7
  65. package/lib/headless-workspace-log.js.map +1 -1
  66. package/lib/ide-frontend-service.d.ts +26 -0
  67. package/lib/ide-frontend-service.d.ts.map +1 -0
  68. package/lib/ide-frontend-service.js +8 -0
  69. package/lib/ide-frontend-service.js.map +1 -0
  70. package/lib/ide-protocol.d.ts +105 -0
  71. package/lib/ide-protocol.d.ts.map +1 -0
  72. package/lib/{util/without.js → ide-protocol.js} +2 -2
  73. package/lib/ide-protocol.js.map +1 -0
  74. package/lib/index.d.ts +7 -1
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +27 -12
  77. package/lib/index.js.map +1 -1
  78. package/lib/installation-admin-protocol.d.ts +27 -0
  79. package/lib/installation-admin-protocol.d.ts.map +1 -0
  80. package/lib/installation-admin-protocol.js +30 -0
  81. package/lib/installation-admin-protocol.js.map +1 -0
  82. package/lib/license-protocol.d.ts +1 -1
  83. package/lib/license-protocol.js +2 -1
  84. package/lib/license-protocol.js.map +1 -1
  85. package/lib/messaging/browser/connection.d.ts +6 -4
  86. package/lib/messaging/browser/connection.d.ts.map +1 -1
  87. package/lib/messaging/browser/connection.js +188 -48
  88. package/lib/messaging/browser/connection.js.map +1 -1
  89. package/lib/messaging/browser/window-connection.d.ts +26 -0
  90. package/lib/messaging/browser/window-connection.d.ts.map +1 -0
  91. package/lib/messaging/browser/window-connection.js +68 -0
  92. package/lib/messaging/browser/window-connection.js.map +1 -0
  93. package/lib/messaging/client-call-metrics.d.ts +35 -0
  94. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  95. package/lib/messaging/client-call-metrics.js +83 -0
  96. package/lib/messaging/client-call-metrics.js.map +1 -0
  97. package/lib/messaging/error.d.ts +7 -2
  98. package/lib/messaging/error.d.ts.map +1 -1
  99. package/lib/messaging/error.js +15 -4
  100. package/lib/messaging/error.js.map +1 -1
  101. package/lib/messaging/handler.d.ts +10 -0
  102. package/lib/messaging/handler.d.ts.map +1 -1
  103. package/lib/messaging/handler.js +1 -0
  104. package/lib/messaging/handler.js.map +1 -1
  105. package/lib/messaging/node/connection.d.ts +1 -17
  106. package/lib/messaging/node/connection.d.ts.map +1 -1
  107. package/lib/messaging/node/connection.js +23 -58
  108. package/lib/messaging/node/connection.js.map +1 -1
  109. package/lib/messaging/proxy-factory.d.ts +2 -0
  110. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  111. package/lib/messaging/proxy-factory.js +75 -169
  112. package/lib/messaging/proxy-factory.js.map +1 -1
  113. package/lib/oss-allowlist.d.ts +14 -0
  114. package/lib/oss-allowlist.d.ts.map +1 -0
  115. package/lib/oss-allowlist.js +8 -0
  116. package/lib/oss-allowlist.js.map +1 -0
  117. package/lib/payment-protocol.d.ts +18 -0
  118. package/lib/payment-protocol.d.ts.map +1 -0
  119. package/lib/payment-protocol.js +13 -0
  120. package/lib/payment-protocol.js.map +1 -0
  121. package/lib/permission.d.ts +20 -12
  122. package/lib/permission.d.ts.map +1 -1
  123. package/lib/permission.js +42 -20
  124. package/lib/permission.js.map +1 -1
  125. package/lib/plans.d.ts +210 -0
  126. package/lib/plans.d.ts.map +1 -0
  127. package/lib/plans.js +570 -0
  128. package/lib/plans.js.map +1 -0
  129. package/lib/protocol.d.ts +146 -65
  130. package/lib/protocol.d.ts.map +1 -1
  131. package/lib/protocol.js +134 -118
  132. package/lib/protocol.js.map +1 -1
  133. package/lib/snapshot-url.d.ts +14 -0
  134. package/lib/snapshot-url.d.ts.map +1 -0
  135. package/lib/snapshot-url.js +26 -0
  136. package/lib/snapshot-url.js.map +1 -0
  137. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +3 -4
  138. package/lib/snapshot-url.spec.d.ts.map +1 -0
  139. package/lib/snapshot-url.spec.js +41 -0
  140. package/lib/snapshot-url.spec.js.map +1 -0
  141. package/lib/team-subscription-protocol.d.ts +73 -0
  142. package/lib/team-subscription-protocol.d.ts.map +1 -0
  143. package/lib/team-subscription-protocol.js +63 -0
  144. package/lib/team-subscription-protocol.js.map +1 -0
  145. package/lib/teams-projects-protocol.d.ts +113 -0
  146. package/lib/teams-projects-protocol.d.ts.map +1 -0
  147. package/lib/teams-projects-protocol.js +30 -0
  148. package/lib/teams-projects-protocol.js.map +1 -0
  149. package/lib/theia-plugins.d.ts +1 -1
  150. package/lib/theia-plugins.js +1 -1
  151. package/lib/typings/globals.d.ts +12 -0
  152. package/lib/typings/globals.d.ts.map +1 -0
  153. package/lib/typings/globals.js +7 -0
  154. package/lib/typings/globals.js.map +1 -0
  155. package/lib/util/analytics.d.ts +8 -0
  156. package/lib/util/analytics.d.ts.map +1 -0
  157. package/lib/util/analytics.js +79 -0
  158. package/lib/util/analytics.js.map +1 -0
  159. package/lib/util/async-iterator.d.ts +1 -1
  160. package/lib/util/async-iterator.js +57 -134
  161. package/lib/util/async-iterator.js.map +1 -1
  162. package/lib/util/cancelable.d.ts +1 -1
  163. package/lib/util/cancelable.js +19 -60
  164. package/lib/util/cancelable.js.map +1 -1
  165. package/lib/util/date-time.d.ts +1 -1
  166. package/lib/util/date-time.js +10 -9
  167. package/lib/util/date-time.js.map +1 -1
  168. package/lib/util/deep-partial.d.ts +1 -1
  169. package/lib/util/deep-partial.js +1 -1
  170. package/lib/util/deferred.d.ts +1 -1
  171. package/lib/util/deferred.js +12 -13
  172. package/lib/util/deferred.js.map +1 -1
  173. package/lib/util/disposable.d.ts +2 -2
  174. package/lib/util/disposable.d.ts.map +1 -1
  175. package/lib/util/disposable.js +27 -39
  176. package/lib/util/disposable.js.map +1 -1
  177. package/lib/util/event.d.ts +1 -1
  178. package/lib/util/event.d.ts.map +1 -1
  179. package/lib/util/event.js +59 -74
  180. package/lib/util/event.js.map +1 -1
  181. package/lib/util/garbage-collected-cache.d.ts +2 -1
  182. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  183. package/lib/util/garbage-collected-cache.js +28 -47
  184. package/lib/util/garbage-collected-cache.js.map +1 -1
  185. package/lib/util/generate-workspace-id.d.ts +4 -0
  186. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  187. package/lib/util/generate-workspace-id.js +487 -0
  188. package/lib/util/generate-workspace-id.js.map +1 -0
  189. package/lib/util/generate-workspace-id.spec.d.ts +7 -0
  190. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  191. package/lib/util/generate-workspace-id.spec.js +87 -0
  192. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  193. package/lib/util/gitpod-cookie.d.ts +20 -0
  194. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  195. package/lib/util/gitpod-cookie.js +44 -0
  196. package/lib/util/gitpod-cookie.js.map +1 -0
  197. package/lib/util/gitpod-host-url.d.ts +8 -4
  198. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  199. package/lib/util/gitpod-host-url.js +103 -76
  200. package/lib/util/gitpod-host-url.js.map +1 -1
  201. package/lib/util/gitpod-host-url.spec.d.ts +16 -0
  202. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
  203. package/lib/util/gitpod-host-url.spec.js +124 -0
  204. package/lib/util/gitpod-host-url.spec.js.map +1 -0
  205. package/lib/util/grpc.d.ts +15 -0
  206. package/lib/util/grpc.d.ts.map +1 -0
  207. package/lib/util/grpc.js +18 -0
  208. package/lib/util/grpc.js.map +1 -0
  209. package/lib/util/jaeger-client-types.d.ts +68 -0
  210. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  211. package/lib/util/jaeger-client-types.js +8 -0
  212. package/lib/util/jaeger-client-types.js.map +1 -0
  213. package/lib/util/logging.d.ts +57 -34
  214. package/lib/util/logging.d.ts.map +1 -1
  215. package/lib/util/logging.js +119 -110
  216. package/lib/util/logging.js.map +1 -1
  217. package/lib/util/make-link.d.ts +1 -1
  218. package/lib/util/make-link.js +4 -3
  219. package/lib/util/make-link.js.map +1 -1
  220. package/lib/util/parse-workspace-id.d.ts +14 -4
  221. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  222. package/lib/util/parse-workspace-id.js +39 -8
  223. package/lib/util/parse-workspace-id.js.map +1 -1
  224. package/lib/util/parse-workspace-id.spec.d.ts +9 -1
  225. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  226. package/lib/util/parse-workspace-id.spec.js +129 -48
  227. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  228. package/lib/util/queue.d.ts +1 -1
  229. package/lib/util/queue.js +18 -56
  230. package/lib/util/queue.js.map +1 -1
  231. package/lib/util/queue.spec.d.ts +1 -1
  232. package/lib/util/queue.spec.js +145 -287
  233. package/lib/util/queue.spec.js.map +1 -1
  234. package/lib/util/repeat.d.ts +15 -0
  235. package/lib/util/repeat.d.ts.map +1 -0
  236. package/lib/util/repeat.js +55 -0
  237. package/lib/util/repeat.js.map +1 -0
  238. package/lib/util/semaphore.d.ts +1 -1
  239. package/lib/util/semaphore.js +17 -47
  240. package/lib/util/semaphore.js.map +1 -1
  241. package/lib/util/skip-if.d.ts +1 -1
  242. package/lib/util/skip-if.js +8 -7
  243. package/lib/util/skip-if.js.map +1 -1
  244. package/lib/util/timeutil.d.ts +1 -1
  245. package/lib/util/timeutil.d.ts.map +1 -1
  246. package/lib/util/timeutil.js +30 -17
  247. package/lib/util/timeutil.js.map +1 -1
  248. package/lib/util/timeutil.spec.d.ts +1 -1
  249. package/lib/util/timeutil.spec.js +23 -25
  250. package/lib/util/timeutil.spec.js.map +1 -1
  251. package/lib/util/tracing.d.ts +52 -6
  252. package/lib/util/tracing.d.ts.map +1 -1
  253. package/lib/util/tracing.js +199 -63
  254. package/lib/util/tracing.js.map +1 -1
  255. package/lib/util/tracing.spec.d.ts +7 -0
  256. package/lib/util/tracing.spec.d.ts.map +1 -0
  257. package/lib/util/tracing.spec.js +121 -0
  258. package/lib/util/tracing.spec.js.map +1 -0
  259. package/lib/util/workspace-port-authentication.d.ts +1 -1
  260. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  261. package/lib/util/workspace-port-authentication.js +5 -3
  262. package/lib/util/workspace-port-authentication.js.map +1 -1
  263. package/lib/workspace-cluster.d.ts +76 -0
  264. package/lib/workspace-cluster.d.ts.map +1 -0
  265. package/lib/workspace-cluster.js +33 -0
  266. package/lib/workspace-cluster.js.map +1 -0
  267. package/lib/workspace-instance.d.ts +29 -4
  268. package/lib/workspace-instance.d.ts.map +1 -1
  269. package/lib/workspace-instance.js +1 -1
  270. package/lib/wsready.d.ts +1 -1
  271. package/lib/wsready.js +3 -2
  272. package/lib/wsready.js.map +1 -1
  273. package/package.json +35 -17
  274. package/pkg-yarn.lock +18 -9
  275. package/provenance-bundle.jsonl +2 -0
  276. package/src/accounting-protocol.ts +229 -0
  277. package/src/admin-protocol.ts +56 -6
  278. package/src/analytics.ts +52 -0
  279. package/src/auth.ts +27 -0
  280. package/src/context-url.spec.ts +53 -0
  281. package/src/context-url.ts +107 -0
  282. package/src/email-protocol.ts +3 -4
  283. package/src/encryption/container-module.ts +1 -1
  284. package/src/encryption/encryption-engine.spec.ts +1 -1
  285. package/src/encryption/encryption-engine.ts +1 -1
  286. package/src/encryption/encryption-service.ts +1 -1
  287. package/src/encryption/key-provider.ts +1 -1
  288. package/src/env.ts +11 -11
  289. package/src/gitpod-file-parser.spec.ts +1 -1
  290. package/src/gitpod-file-parser.ts +1 -1
  291. package/src/gitpod-service.ts +420 -56
  292. package/src/headless-workspace-log.ts +8 -12
  293. package/src/ide-frontend-service.ts +28 -0
  294. package/src/ide-protocol.ts +119 -0
  295. package/src/index.ts +8 -2
  296. package/src/installation-admin-protocol.ts +42 -0
  297. package/src/license-protocol.ts +1 -1
  298. package/src/messaging/browser/connection.ts +201 -23
  299. package/src/messaging/browser/window-connection.ts +72 -0
  300. package/src/messaging/client-call-metrics.ts +97 -0
  301. package/src/messaging/error.ts +19 -4
  302. package/src/messaging/handler.ts +12 -0
  303. package/src/messaging/node/connection.ts +21 -68
  304. package/src/messaging/proxy-factory.ts +16 -14
  305. package/src/oss-allowlist.ts +15 -0
  306. package/src/payment-protocol.ts +20 -0
  307. package/src/permission.ts +31 -11
  308. package/src/plans.ts +632 -0
  309. package/src/protocol.ts +243 -99
  310. package/src/snapshot-url.spec.ts +25 -0
  311. package/src/snapshot-url.ts +27 -0
  312. package/src/team-subscription-protocol.ts +113 -0
  313. package/src/teams-projects-protocol.ts +147 -0
  314. package/src/theia-plugins.ts +1 -1
  315. package/src/typings/globals.ts +12 -0
  316. package/src/util/analytics.ts +87 -0
  317. package/src/util/async-iterator.ts +1 -1
  318. package/src/util/cancelable.ts +1 -1
  319. package/src/util/date-time.ts +1 -1
  320. package/src/util/deep-partial.ts +1 -1
  321. package/src/util/deferred.ts +2 -2
  322. package/src/util/garbage-collected-cache.ts +10 -4
  323. package/src/util/generate-workspace-id.spec.ts +48 -0
  324. package/src/util/generate-workspace-id.ts +475 -0
  325. package/src/util/gitpod-cookie.ts +39 -0
  326. package/src/util/gitpod-host-url.spec.ts +49 -0
  327. package/src/util/gitpod-host-url.ts +56 -16
  328. package/src/util/grpc.ts +15 -0
  329. package/src/util/jaeger-client-types.ts +102 -0
  330. package/src/util/logging.ts +111 -39
  331. package/src/util/make-link.ts +1 -1
  332. package/src/util/parse-workspace-id.spec.ts +46 -5
  333. package/src/util/parse-workspace-id.ts +39 -8
  334. package/src/util/queue.spec.ts +2 -2
  335. package/src/util/queue.ts +1 -1
  336. package/src/util/repeat.ts +45 -0
  337. package/src/util/semaphore.ts +3 -3
  338. package/src/util/skip-if.ts +2 -2
  339. package/src/util/timeutil.spec.ts +1 -1
  340. package/src/util/timeutil.ts +5 -5
  341. package/src/util/tracing.spec.ts +83 -0
  342. package/src/util/tracing.ts +184 -18
  343. package/src/util/workspace-port-authentication.ts +1 -1
  344. package/src/workspace-cluster.ts +104 -0
  345. package/src/workspace-instance.ts +58 -16
  346. package/src/wsready.ts +2 -2
  347. package/lib/messaging/connection-error-handler.d.ts +0 -27
  348. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  349. package/lib/messaging/connection-error-handler.js +0 -45
  350. package/lib/messaging/connection-error-handler.js.map +0 -1
  351. package/lib/util/repeater.d.ts +0 -22
  352. package/lib/util/repeater.d.ts.map +0 -1
  353. package/lib/util/repeater.js +0 -117
  354. package/lib/util/repeater.js.map +0 -1
  355. package/lib/util/safe-promise.d.ts +0 -11
  356. package/lib/util/safe-promise.d.ts.map +0 -1
  357. package/lib/util/safe-promise.js +0 -33
  358. package/lib/util/safe-promise.js.map +0 -1
  359. package/lib/util/without.d.ts +0 -7
  360. package/lib/util/without.d.ts.map +0 -1
  361. package/lib/util/without.js.map +0 -1
  362. package/src/messaging/connection-error-handler.ts +0 -62
  363. package/src/util/jaeger-client.d.ts +0 -105
  364. package/src/util/repeater.ts +0 -49
  365. package/src/util/safe-promise.ts +0 -26
package/src/protocol.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
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
- export interface UserInfo {
11
+ export interface UserInfo {
11
12
  name?: string
12
13
  }
13
14
 
@@ -27,19 +28,12 @@ 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.
35
34
  */
36
35
  blocked?: boolean;
37
36
 
38
- /**
39
- * whether this user can run workspaces in privileged mode
40
- */
41
- privileged?: boolean;
42
-
43
37
  /** A map of random settings that alter the behaviour of Gitpod on a per-user basis */
44
38
  featureFlags?: UserFeatureSettings;
45
39
 
@@ -61,6 +55,20 @@ export namespace User {
61
55
  export function getIdentity(user: User, authProviderId: string): Identity | undefined {
62
56
  return user.identities.find(id => id.authProviderId === authProviderId);
63
57
  }
58
+ export function censor(user: User): User {
59
+ const res = { ...user };
60
+ delete (res.additionalData);
61
+ res.identities = res.identities.map(i => {
62
+ delete (i.tokens);
63
+
64
+ // The user field is not in the Identity shape, but actually exists on DBIdentity.
65
+ // Trying to push this object out via JSON RPC will fail because of the cyclic nature
66
+ // of this field.
67
+ delete ((i as any).user);
68
+ return i;
69
+ });
70
+ return res;
71
+ }
64
72
  export function getPrimaryEmail(user: User): string {
65
73
  const identities = user.identities.filter(i => !!i.primaryEmail);
66
74
  if (identities.length <= 0) {
@@ -74,7 +82,7 @@ export namespace User {
74
82
  if (name) {
75
83
  return name;
76
84
  }
77
-
85
+
78
86
  for (const id of user.identities) {
79
87
  if (id.authName !== "") {
80
88
  return id.authName;
@@ -87,10 +95,31 @@ export namespace User {
87
95
  export interface AdditionalUserData {
88
96
  platforms?: UserPlatform[];
89
97
  emailNotificationSettings?: EmailNotificationSettings;
98
+ featurePreview?: boolean;
99
+ ideSettings?: IDESettings;
100
+ // key is the name of the news, string the iso date when it was seen
101
+ whatsNewSeen?: { [key: string]: string }
102
+ // key is the name of the OAuth client i.e. local app, string the iso date when it was approved
103
+ // TODO(rl): provide a management UX to allow rescinding of approval
104
+ oauthClientsApproved?: { [key: string]: string }
105
+ // to remember GH Orgs the user installed/updated the GH App for
106
+ knownGitHubOrgs?: string[];
107
+
108
+ // Git clone URL pointing to the user's dotfile repo
109
+ dotfileRepo?: string;
90
110
  }
91
111
 
92
112
  export interface EmailNotificationSettings {
93
- disallowTransactionalEmails?: boolean;
113
+ allowsChangelogMail?: boolean;
114
+ allowsDevXMail?: boolean;
115
+ allowsOnboardingMail?: boolean;
116
+ }
117
+
118
+ export type IDESettings = {
119
+ defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
122
+ useLatestVersion?: boolean
94
123
  }
95
124
 
96
125
  export interface UserPlatform {
@@ -104,7 +133,7 @@ export interface UserPlatform {
104
133
  * Since when does the user have the browser extension installe don this device.
105
134
  */
106
135
  browserExtensionInstalledSince?: string;
107
-
136
+
108
137
  /**
109
138
  * Since when does the user not have the browser extension installed anymore (but previously had).
110
139
  */
@@ -112,14 +141,6 @@ export interface UserPlatform {
112
141
  }
113
142
 
114
143
  export interface UserFeatureSettings {
115
- /**
116
- * This field is used as marker to grant users a free trial for using private repositories,
117
- * independent of any subscription or Chargebee.
118
- * - it is set when the user uses their first private repo
119
- * - whether the trial is expired or not is juged by the UserService
120
- */
121
- privateRepoTrialStartDate?: string;
122
-
123
144
  /**
124
145
  * Permanent feature flags are added to each and every workspace instance
125
146
  * this user starts.
@@ -131,15 +152,26 @@ export interface UserFeatureSettings {
131
152
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
132
153
  * If they don't we'll break things during workspace startup.
133
154
  */
134
- export const WorkspaceFeatureFlags = { "privileged": undefined, "registry_facade": undefined, "full_workspace_backup": undefined, "fixed_resources": undefined };
135
- export type NamedWorkspaceFeatureFlag = keyof(typeof WorkspaceFeatureFlags);
155
+ export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
156
+ export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
136
157
 
137
- export interface UserEnvVarValue {
138
- id?: string;
158
+ export interface EnvVarWithValue {
139
159
  name: string;
140
- repositoryPattern: string;
141
160
  value: string;
142
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
+ }
143
175
  export interface UserEnvVar extends UserEnvVarValue {
144
176
  id: string;
145
177
  userId: string;
@@ -148,10 +180,35 @@ export interface UserEnvVar extends UserEnvVarValue {
148
180
 
149
181
  export namespace UserEnvVar {
150
182
 
183
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
151
184
  export function normalizeRepoPattern(pattern: string) {
152
185
  return pattern.toLocaleLowerCase();
153
186
  }
154
187
 
188
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
189
+ export function score(value: UserEnvVarValue): number {
190
+ // We use a score to enforce precedence:
191
+ // value/value = 0
192
+ // value/* = 1
193
+ // */value = 2
194
+ // */* = 3
195
+ // #/# = 4 (used for env vars passed through the URL)
196
+ // the lower the score, the higher the precedence.
197
+ const [ownerPattern, repoPattern] = splitRepositoryPattern(value.repositoryPattern);
198
+ let score = 0;
199
+ if (repoPattern == "*") {
200
+ score += 1;
201
+ }
202
+ if (ownerPattern == '*') {
203
+ score += 2;
204
+ }
205
+ if (ownerPattern == "#" || repoPattern == "#") {
206
+ score = 4;
207
+ }
208
+ return score;
209
+ }
210
+
211
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
155
212
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
156
213
  let result = vars.filter(e => {
157
214
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -187,25 +244,7 @@ export namespace UserEnvVar {
187
244
  let minscore = 10;
188
245
  let bestCandidate: T | undefined;
189
246
  for (const e of candidates) {
190
- // We use a score to enforce precedence:
191
- // value/value = 0
192
- // value/* = 1
193
- // */value = 2
194
- // */* = 3
195
- // #/# = 4 (used for env vars passed through the URL)
196
- // the lower the score, the higher the precedence.
197
- const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
198
- let score = 0;
199
- if (repoPattern == "*") {
200
- score += 1;
201
- }
202
- if (ownerPattern == '*') {
203
- score += 2;
204
- }
205
- if (ownerPattern == "#" || repoPattern == "#") {
206
- score = 4;
207
- }
208
-
247
+ const score = UserEnvVar.score(e);
209
248
  if (!bestCandidate || score < minscore) {
210
249
  minscore = score;
211
250
  bestCandidate = e;
@@ -217,10 +256,11 @@ export namespace UserEnvVar {
217
256
  return result;
218
257
  }
219
258
 
220
- function splitRepositoryPattern(repositoryPattern: string): string[] {
259
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
260
+ export function splitRepositoryPattern(repositoryPattern: string): string[] {
221
261
  const patterns = repositoryPattern.split('/');
222
- const repoPattern = patterns.pop() || "";
223
- const ownerPattern = patterns.join('/');
262
+ const repoPattern = patterns.slice(1).join('/')
263
+ const ownerPattern = patterns[0];
224
264
  return [ownerPattern, repoPattern];
225
265
  }
226
266
  }
@@ -238,13 +278,13 @@ export interface GitpodToken {
238
278
 
239
279
  /** The user the token belongs to. */
240
280
  user: User
241
-
281
+
242
282
  /** Scopes (e.g. limition to read-only) */
243
283
  scopes: string[]
244
284
 
245
285
  /** Created timestamp */
246
286
  created: string
247
-
287
+
248
288
  // token is deleted on the database and about to be collected by db-sync
249
289
  deleted?: boolean
250
290
  }
@@ -351,11 +391,16 @@ export interface PendingGithubEvent {
351
391
  export interface Snapshot {
352
392
  id: string;
353
393
  creationTime: string;
394
+ availableTime?: string;
354
395
  originalWorkspaceId: string;
355
396
  bucketId: string;
356
397
  layoutData?: string;
398
+ state: SnapshotState;
399
+ message?: string;
357
400
  }
358
401
 
402
+ export type SnapshotState = 'pending' | 'available' | 'error';
403
+
359
404
  export interface LayoutData {
360
405
  workspaceId: string;
361
406
  lastUpdatedTime: string;
@@ -368,9 +413,10 @@ export interface Workspace {
368
413
  contextURL: string;
369
414
  description: string;
370
415
  ownerId: string;
416
+ projectId?: string;
371
417
  context: WorkspaceContext;
372
418
  config: WorkspaceConfig;
373
-
419
+
374
420
  /**
375
421
  * The source where to get the workspace base image from. This source is resolved
376
422
  * during workspace creation. Once a base image has been built the information in here
@@ -476,6 +522,7 @@ export interface PreparePluginUploadParams {
476
522
  export interface ResolvePluginsParams {
477
523
  config?: WorkspaceConfig
478
524
  builtins?: ResolvedPlugins
525
+ vsxRegistryUrl?: string
479
526
  }
480
527
 
481
528
  export interface InstallPluginsParams {
@@ -486,6 +533,24 @@ export interface UninstallPluginParams {
486
533
  pluginId: string;
487
534
  }
488
535
 
536
+ export interface GuessGitTokenScopesParams {
537
+ host: string
538
+ repoUrl: string
539
+ gitCommand: string
540
+ currentToken: GitToken
541
+ }
542
+
543
+ export interface GitToken {
544
+ token: string
545
+ user: string
546
+ scopes: string[]
547
+ }
548
+
549
+ export interface GuessedGitTokenScopes {
550
+ message?: string
551
+ scopes?: string[]
552
+ }
553
+
489
554
  export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
490
555
 
491
556
  export interface ResolvedPlugins {
@@ -508,21 +573,24 @@ export interface WorkspaceConfig {
508
573
  tasks?: TaskConfig[];
509
574
  checkoutLocation?: string;
510
575
  workspaceLocation?: string;
511
- privileged?: boolean;
512
576
  gitConfig?: { [config: string]: string };
513
577
  github?: GithubAppConfig;
514
578
  vscode?: VSCodeConfig;
515
- ide?: 'theia' | 'code' | string;
579
+
580
+ /** deprecated. Enabled by default **/
581
+ experimentalNetwork?: boolean;
516
582
 
517
583
  /**
518
584
  * Where the config object originates from.
519
- *
585
+ *
520
586
  * repo - from the repository
587
+ * project-db - from the "Project" stored in the database
521
588
  * definitly-gp - from github.com/gitpod-io/definitely-gp
522
589
  * derived - computed based on analyzing the repository
590
+ * additional-content - config comes from additional content, usually provided through the project's configuration
523
591
  * default - our static catch-all default config
524
592
  */
525
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
593
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
526
594
 
527
595
  /**
528
596
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -539,7 +607,7 @@ export interface GithubAppPrebuildConfig {
539
607
  branches?: boolean
540
608
  pullRequests?: boolean
541
609
  pullRequestsFromForks?: boolean
542
- addCheck?: boolean
610
+ addCheck?: boolean | 'prevent-merge-on-error'
543
611
  addBadge?: boolean
544
612
  addLabel?: boolean | string
545
613
  addComment?: boolean
@@ -552,16 +620,13 @@ export namespace GithubAppPrebuildConfig {
552
620
 
553
621
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
554
622
  export interface WorkspaceImageSourceDocker {
555
- // TODO: clean this up. We should have the commit and an ImageSource in here, not duplicate the whole thing again.
556
- // We have a ton of those objects in the database, thus cleaning this up means lengthy DB migrations. Yuck.
557
- dockerFileHash: string
558
- dockerFileSource: Commit
559
623
  dockerFilePath: string
624
+ dockerFileHash: string
625
+ dockerFileSource?: Commit
560
626
  }
561
627
  export namespace WorkspaceImageSourceDocker {
562
628
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
563
629
  return 'dockerFileHash' in obj
564
- && 'dockerFileSource' in obj
565
630
  && 'dockerFilePath' in obj;
566
631
  }
567
632
  }
@@ -590,6 +655,8 @@ export type PrebuiltWorkspaceState
590
655
  export interface PrebuiltWorkspace {
591
656
  id: string;
592
657
  cloneURL: string;
658
+ branch?: string;
659
+ projectId?: string;
593
660
  commit: string;
594
661
  buildWorkspaceId: string;
595
662
  creationTime: string;
@@ -599,6 +666,10 @@ export interface PrebuiltWorkspace {
599
666
  }
600
667
 
601
668
  export namespace PrebuiltWorkspace {
669
+ export function isDone(pws: PrebuiltWorkspace) {
670
+ return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
671
+ }
672
+
602
673
  export function isAvailable(pws: PrebuiltWorkspace) {
603
674
  return pws.state === "available" && !!pws.snapshot;
604
675
  }
@@ -632,6 +703,8 @@ export interface PortConfig {
632
703
  port: number;
633
704
  onOpen?: PortOnOpen;
634
705
  visibility?: PortVisibility;
706
+ description?: string;
707
+ name?: string;
635
708
  }
636
709
  export namespace PortConfig {
637
710
  export function is(config: any): config is PortConfig {
@@ -655,7 +728,7 @@ export interface TaskConfig {
655
728
  init?: string;
656
729
  prebuild?: string;
657
730
  command?: string;
658
- env?: { [env: string]: string };
731
+ env?: { [env: string]: any };
659
732
  openIn?: 'bottom' | 'main' | 'left' | 'right';
660
733
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
661
734
  }
@@ -719,8 +792,10 @@ export namespace ExternalImageConfigFile {
719
792
 
720
793
  export interface WorkspaceContext {
721
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. */
722
796
  normalizedContextURL?: string;
723
797
  forceCreateNewWorkspace?: boolean;
798
+ forceImageBuild?: boolean;
724
799
  }
725
800
 
726
801
  export namespace WorkspaceContext {
@@ -740,27 +815,49 @@ export namespace WithSnapshot {
740
815
  }
741
816
  }
742
817
 
743
- export interface WithPrebuild {
744
- snapshotBucketId: string;
818
+ export interface WithPrebuild extends WithSnapshot {
745
819
  prebuildWorkspaceId: string;
746
820
  wasPrebuilt: true;
747
821
  }
748
822
  export namespace WithPrebuild {
749
823
  export function is(context: any): context is WithPrebuild {
750
824
  return context
751
- && 'snapshotBucketId' in context
825
+ && WithSnapshot.is(context)
752
826
  && 'prebuildWorkspaceId' in context
753
827
  && 'wasPrebuilt' in context;
754
828
  }
755
829
  }
756
830
 
831
+ /**
832
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
833
+ * and fall back to the built-in configuration.
834
+ */
835
+ export interface WithDefaultConfig {
836
+ withDefaultConfig: true;
837
+ }
838
+
839
+ export namespace WithDefaultConfig {
840
+ export function is(context: any): context is WithDefaultConfig {
841
+ return context
842
+ && 'withDefaultConfig' in context
843
+ && context.withDefaultConfig;
844
+ }
845
+
846
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
847
+ return {
848
+ ...ctx,
849
+ withDefaultConfig: true
850
+ }
851
+ }
852
+ }
853
+
757
854
  export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
758
855
  snapshotId: string;
759
856
  }
760
857
 
761
858
  export namespace SnapshotContext {
762
859
  export function is(context: any): context is SnapshotContext {
763
- return context
860
+ return context
764
861
  && WithSnapshot.is(context)
765
862
  && 'snapshotId' in context;
766
863
  }
@@ -768,6 +865,9 @@ export namespace SnapshotContext {
768
865
 
769
866
  export interface StartPrebuildContext extends WorkspaceContext {
770
867
  actual: WorkspaceContext;
868
+ commitHistory?: string[];
869
+ project?: Project;
870
+ branch?: string;
771
871
  }
772
872
 
773
873
  export namespace StartPrebuildContext {
@@ -791,8 +891,20 @@ export namespace PrebuiltWorkspaceContext {
791
891
  }
792
892
  }
793
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
+
794
906
  export interface WithEnvvarsContext extends WorkspaceContext {
795
- envvars: UserEnvVarValue[];
907
+ envvars: EnvVarWithValue[];
796
908
  }
797
909
 
798
910
  export namespace WithEnvvarsContext {
@@ -837,6 +949,25 @@ export interface Commit {
837
949
  refType?: RefType
838
950
  }
839
951
 
952
+ export interface AdditionalContentContext extends WorkspaceContext {
953
+
954
+ /**
955
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
956
+ */
957
+ additionalFiles: {[filePath: string]: string};
958
+
959
+ }
960
+
961
+ export namespace AdditionalContentContext {
962
+ export function is(ctx: any): ctx is AdditionalContentContext {
963
+ return 'additionalFiles' in ctx;
964
+ }
965
+
966
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
967
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
968
+ }
969
+ }
970
+
840
971
  export interface CommitContext extends WorkspaceContext, Commit {
841
972
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
842
973
  cloneUrl?: string
@@ -912,6 +1043,19 @@ export interface Repository {
912
1043
  parent: Repository
913
1044
  }
914
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
+ }
915
1059
 
916
1060
  export namespace Repository {
917
1061
  export function fullRepoName(repo: Repository): string {
@@ -939,6 +1083,12 @@ export interface WorkspaceInfo {
939
1083
  latestInstance?: WorkspaceInstance
940
1084
  }
941
1085
 
1086
+ export namespace WorkspaceInfo {
1087
+ export function lastActiveISODate(info: WorkspaceInfo): string {
1088
+ return info.latestInstance?.creationTime || info.workspace.creationTime;
1089
+ }
1090
+ }
1091
+
942
1092
  export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
943
1093
 
944
1094
  export interface WorkspaceCreationResult {
@@ -948,6 +1098,7 @@ export interface WorkspaceCreationResult {
948
1098
  runningWorkspacePrebuild?: {
949
1099
  prebuildID: string
950
1100
  workspaceID: string
1101
+ instanceID: string
951
1102
  starting: RunningWorkspacePrebuildStarting
952
1103
  sameCluster: boolean
953
1104
  }
@@ -1019,6 +1170,8 @@ export interface AuthProviderEntry {
1019
1170
  readonly status: AuthProviderEntry.Status;
1020
1171
 
1021
1172
  readonly oauth: OAuth2Config;
1173
+ /** A random string that is to change whenever oauth changes (enforced on DB level) */
1174
+ readonly oauthRevision?: string;
1022
1175
  }
1023
1176
 
1024
1177
  export interface OAuth2Config {
@@ -1038,40 +1191,16 @@ export interface OAuth2Config {
1038
1191
  export namespace AuthProviderEntry {
1039
1192
  export type Type = "GitHub" | "GitLab" | string;
1040
1193
  export type Status = "pending" | "verified";
1041
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type">;
1194
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1042
1195
  export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
1043
- }
1044
-
1045
- export interface Branding {
1046
- readonly name: string;
1047
- readonly favicon?: string;
1048
- /** Either including domain OR absolute path (interpreted relative to host URL) */
1049
- readonly logo: string;
1050
- readonly startupLogo: string;
1051
- readonly showProductivityTips: boolean;
1052
- readonly redirectUrlIfNotAuthenticated?: string;
1053
- readonly redirectUrlAfterLogout?: string;
1054
- readonly homepage: string;
1055
- readonly ide?: {
1056
- readonly logo: string;
1057
- readonly showReleaseNotes: boolean;
1058
- readonly helpMenu: Branding.Link[];
1059
- }
1060
- readonly links: {
1061
- readonly header: Branding.Link[];
1062
- readonly footer: Branding.Link[];
1063
- readonly social: Branding.SocialLink[];
1064
- readonly legal: Branding.Link[];
1065
- }
1066
- }
1067
- export namespace Branding {
1068
- export interface Link {
1069
- readonly name: string;
1070
- readonly url: string;
1071
- }
1072
- export interface SocialLink {
1073
- readonly type: string;
1074
- readonly url: string;
1196
+ export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1197
+ return {
1198
+ ...entry,
1199
+ oauth: {
1200
+ ...entry.oauth,
1201
+ clientSecret: "redacted"
1202
+ }
1203
+ }
1075
1204
  }
1076
1205
  }
1077
1206
 
@@ -1100,3 +1229,18 @@ export namespace TheiaPlugin {
1100
1229
  CheckinFailed = "checkin-failed",
1101
1230
  }
1102
1231
  }
1232
+
1233
+ export interface TermsAcceptanceEntry {
1234
+ readonly userId: string;
1235
+ readonly termsRevision: string;
1236
+ readonly acceptionTime: string;
1237
+ }
1238
+
1239
+ export interface Terms {
1240
+ readonly revision: string;
1241
+ readonly activeSince: string;
1242
+ readonly adminOnlyTerms: boolean;
1243
+ readonly updateMessage: string;
1244
+ readonly content: string;
1245
+ readonly formElements?: object;
1246
+ }
@@ -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
+ }