@gitpod/gitpod-protocol 0.1.5-test.9 → 0.1.5-tweak-workspaceconfig-origin-docs-fork.0

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 (331) hide show
  1. package/data/builtin-theia-plugins.json +28 -18
  2. package/data/gitpod-schema.json +17 -17
  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 +22 -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 +45 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/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 +18 -0
  20. package/lib/context-url.d.ts.map +1 -0
  21. package/lib/context-url.js +49 -0
  22. package/lib/context-url.js.map +1 -0
  23. package/lib/context-url.spec.d.ts +12 -0
  24. package/lib/context-url.spec.d.ts.map +1 -0
  25. package/lib/context-url.spec.js +73 -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 +186 -34
  59. package/lib/gitpod-service.d.ts.map +1 -1
  60. package/lib/gitpod-service.js +239 -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 +81 -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 +5 -1
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +25 -12
  77. package/lib/index.js.map +1 -1
  78. package/lib/license-protocol.d.ts +1 -1
  79. package/lib/license-protocol.js +2 -1
  80. package/lib/license-protocol.js.map +1 -1
  81. package/lib/messaging/browser/connection.d.ts +6 -4
  82. package/lib/messaging/browser/connection.d.ts.map +1 -1
  83. package/lib/messaging/browser/connection.js +188 -48
  84. package/lib/messaging/browser/connection.js.map +1 -1
  85. package/lib/messaging/browser/window-connection.d.ts +26 -0
  86. package/lib/messaging/browser/window-connection.d.ts.map +1 -0
  87. package/lib/messaging/browser/window-connection.js +68 -0
  88. package/lib/messaging/browser/window-connection.js.map +1 -0
  89. package/lib/messaging/client-call-metrics.d.ts +35 -0
  90. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  91. package/lib/messaging/client-call-metrics.js +83 -0
  92. package/lib/messaging/client-call-metrics.js.map +1 -0
  93. package/lib/messaging/connection-error-handler.js +12 -23
  94. package/lib/messaging/connection-error-handler.js.map +1 -1
  95. package/lib/messaging/error.d.ts +6 -2
  96. package/lib/messaging/error.d.ts.map +1 -1
  97. package/lib/messaging/error.js +13 -4
  98. package/lib/messaging/error.js.map +1 -1
  99. package/lib/messaging/handler.d.ts +10 -0
  100. package/lib/messaging/handler.d.ts.map +1 -1
  101. package/lib/messaging/handler.js +1 -0
  102. package/lib/messaging/handler.js.map +1 -1
  103. package/lib/messaging/node/connection.js +23 -22
  104. package/lib/messaging/node/connection.js.map +1 -1
  105. package/lib/messaging/proxy-factory.d.ts +2 -0
  106. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  107. package/lib/messaging/proxy-factory.js +75 -169
  108. package/lib/messaging/proxy-factory.js.map +1 -1
  109. package/lib/payment-protocol.d.ts +18 -0
  110. package/lib/payment-protocol.d.ts.map +1 -0
  111. package/lib/payment-protocol.js +13 -0
  112. package/lib/payment-protocol.js.map +1 -0
  113. package/lib/permission.d.ts +14 -12
  114. package/lib/permission.d.ts.map +1 -1
  115. package/lib/permission.js +21 -19
  116. package/lib/permission.js.map +1 -1
  117. package/lib/plans.d.ts +210 -0
  118. package/lib/plans.d.ts.map +1 -0
  119. package/lib/plans.js +570 -0
  120. package/lib/plans.js.map +1 -0
  121. package/lib/protocol.d.ts +123 -30
  122. package/lib/protocol.d.ts.map +1 -1
  123. package/lib/protocol.js +121 -117
  124. package/lib/protocol.js.map +1 -1
  125. package/lib/snapshot-url.d.ts +14 -0
  126. package/lib/snapshot-url.d.ts.map +1 -0
  127. package/lib/snapshot-url.js +26 -0
  128. package/lib/snapshot-url.js.map +1 -0
  129. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +3 -4
  130. package/lib/snapshot-url.spec.d.ts.map +1 -0
  131. package/lib/snapshot-url.spec.js +41 -0
  132. package/lib/snapshot-url.spec.js.map +1 -0
  133. package/lib/team-subscription-protocol.d.ts +73 -0
  134. package/lib/team-subscription-protocol.d.ts.map +1 -0
  135. package/lib/team-subscription-protocol.js +63 -0
  136. package/lib/team-subscription-protocol.js.map +1 -0
  137. package/lib/teams-projects-protocol.d.ts +103 -0
  138. package/lib/teams-projects-protocol.d.ts.map +1 -0
  139. package/lib/teams-projects-protocol.js +23 -0
  140. package/lib/teams-projects-protocol.js.map +1 -0
  141. package/lib/theia-plugins.d.ts +1 -1
  142. package/lib/theia-plugins.js +1 -1
  143. package/lib/typings/globals.d.ts +12 -0
  144. package/lib/typings/globals.d.ts.map +1 -0
  145. package/lib/typings/globals.js +7 -0
  146. package/lib/typings/globals.js.map +1 -0
  147. package/lib/util/analytics.d.ts +8 -0
  148. package/lib/util/analytics.d.ts.map +1 -0
  149. package/lib/util/analytics.js +79 -0
  150. package/lib/util/analytics.js.map +1 -0
  151. package/lib/util/async-iterator.d.ts +1 -1
  152. package/lib/util/async-iterator.js +57 -134
  153. package/lib/util/async-iterator.js.map +1 -1
  154. package/lib/util/cancelable.d.ts +1 -1
  155. package/lib/util/cancelable.js +19 -60
  156. package/lib/util/cancelable.js.map +1 -1
  157. package/lib/util/date-time.d.ts +1 -1
  158. package/lib/util/date-time.js +10 -9
  159. package/lib/util/date-time.js.map +1 -1
  160. package/lib/util/deep-partial.d.ts +1 -1
  161. package/lib/util/deep-partial.js +1 -1
  162. package/lib/util/deferred.d.ts +1 -1
  163. package/lib/util/deferred.js +12 -13
  164. package/lib/util/deferred.js.map +1 -1
  165. package/lib/util/disposable.d.ts +2 -2
  166. package/lib/util/disposable.d.ts.map +1 -1
  167. package/lib/util/disposable.js +27 -39
  168. package/lib/util/disposable.js.map +1 -1
  169. package/lib/util/event.d.ts +1 -1
  170. package/lib/util/event.d.ts.map +1 -1
  171. package/lib/util/event.js +59 -74
  172. package/lib/util/event.js.map +1 -1
  173. package/lib/util/garbage-collected-cache.d.ts +1 -1
  174. package/lib/util/garbage-collected-cache.js +24 -47
  175. package/lib/util/garbage-collected-cache.js.map +1 -1
  176. package/lib/util/generate-workspace-id.d.ts +4 -0
  177. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  178. package/lib/util/generate-workspace-id.js +470 -0
  179. package/lib/util/generate-workspace-id.js.map +1 -0
  180. package/lib/util/generate-workspace-id.spec.d.ts +7 -0
  181. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  182. package/lib/util/generate-workspace-id.spec.js +63 -0
  183. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  184. package/lib/util/gitpod-cookie.d.ts +20 -0
  185. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  186. package/lib/util/gitpod-cookie.js +44 -0
  187. package/lib/util/gitpod-cookie.js.map +1 -0
  188. package/lib/util/gitpod-host-url.d.ts +8 -3
  189. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  190. package/lib/util/gitpod-host-url.js +106 -76
  191. package/lib/util/gitpod-host-url.js.map +1 -1
  192. package/lib/util/gitpod-host-url.spec.d.ts +16 -0
  193. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
  194. package/lib/util/gitpod-host-url.spec.js +124 -0
  195. package/lib/util/gitpod-host-url.spec.js.map +1 -0
  196. package/lib/util/grpc.d.ts +15 -0
  197. package/lib/util/grpc.d.ts.map +1 -0
  198. package/lib/util/grpc.js +18 -0
  199. package/lib/util/grpc.js.map +1 -0
  200. package/lib/util/logging.d.ts +57 -34
  201. package/lib/util/logging.d.ts.map +1 -1
  202. package/lib/util/logging.js +119 -110
  203. package/lib/util/logging.js.map +1 -1
  204. package/lib/util/make-link.d.ts +1 -1
  205. package/lib/util/make-link.js +4 -3
  206. package/lib/util/make-link.js.map +1 -1
  207. package/lib/util/parse-workspace-id.d.ts +14 -4
  208. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  209. package/lib/util/parse-workspace-id.js +39 -8
  210. package/lib/util/parse-workspace-id.js.map +1 -1
  211. package/lib/util/parse-workspace-id.spec.d.ts +9 -1
  212. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  213. package/lib/util/parse-workspace-id.spec.js +129 -48
  214. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  215. package/lib/util/queue.d.ts +1 -1
  216. package/lib/util/queue.js +18 -56
  217. package/lib/util/queue.js.map +1 -1
  218. package/lib/util/queue.spec.d.ts +1 -1
  219. package/lib/util/queue.spec.js +145 -287
  220. package/lib/util/queue.spec.js.map +1 -1
  221. package/lib/util/repeater.d.ts +1 -1
  222. package/lib/util/repeater.js +37 -89
  223. package/lib/util/repeater.js.map +1 -1
  224. package/lib/util/safe-promise.d.ts +1 -1
  225. package/lib/util/safe-promise.js +11 -13
  226. package/lib/util/safe-promise.js.map +1 -1
  227. package/lib/util/semaphore.d.ts +1 -1
  228. package/lib/util/semaphore.js +17 -47
  229. package/lib/util/semaphore.js.map +1 -1
  230. package/lib/util/skip-if.d.ts +1 -1
  231. package/lib/util/skip-if.js +8 -7
  232. package/lib/util/skip-if.js.map +1 -1
  233. package/lib/util/timeutil.d.ts +1 -1
  234. package/lib/util/timeutil.d.ts.map +1 -1
  235. package/lib/util/timeutil.js +30 -17
  236. package/lib/util/timeutil.js.map +1 -1
  237. package/lib/util/timeutil.spec.d.ts +1 -1
  238. package/lib/util/timeutil.spec.js +23 -25
  239. package/lib/util/timeutil.spec.js.map +1 -1
  240. package/lib/util/tracing.d.ts +15 -2
  241. package/lib/util/tracing.d.ts.map +1 -1
  242. package/lib/util/tracing.js +86 -51
  243. package/lib/util/tracing.js.map +1 -1
  244. package/lib/util/workspace-port-authentication.d.ts +1 -1
  245. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  246. package/lib/util/workspace-port-authentication.js +5 -3
  247. package/lib/util/workspace-port-authentication.js.map +1 -1
  248. package/lib/workspace-cluster.d.ts +74 -0
  249. package/lib/workspace-cluster.d.ts.map +1 -0
  250. package/lib/workspace-cluster.js +16 -0
  251. package/lib/workspace-cluster.js.map +1 -0
  252. package/lib/workspace-instance.d.ts +10 -4
  253. package/lib/workspace-instance.d.ts.map +1 -1
  254. package/lib/workspace-instance.js +1 -1
  255. package/lib/wsready.d.ts +1 -1
  256. package/lib/wsready.js +3 -2
  257. package/lib/wsready.js.map +1 -1
  258. package/package.json +32 -16
  259. package/pkg-yarn.lock +18 -9
  260. package/src/accounting-protocol.ts +229 -0
  261. package/src/admin-protocol.ts +41 -6
  262. package/src/analytics.ts +54 -0
  263. package/src/auth.ts +27 -0
  264. package/src/context-url.spec.ts +39 -0
  265. package/src/context-url.ts +51 -0
  266. package/src/email-protocol.ts +3 -4
  267. package/src/encryption/container-module.ts +1 -1
  268. package/src/encryption/encryption-engine.spec.ts +1 -1
  269. package/src/encryption/encryption-engine.ts +1 -1
  270. package/src/encryption/encryption-service.ts +1 -1
  271. package/src/encryption/key-provider.ts +1 -1
  272. package/src/env.ts +11 -11
  273. package/src/gitpod-file-parser.spec.ts +1 -1
  274. package/src/gitpod-file-parser.ts +1 -1
  275. package/src/gitpod-service.ts +386 -52
  276. package/src/headless-workspace-log.ts +8 -12
  277. package/src/ide-frontend-service.ts +28 -0
  278. package/src/ide-protocol.ts +92 -0
  279. package/src/index.ts +6 -2
  280. package/src/license-protocol.ts +1 -1
  281. package/src/messaging/browser/connection.ts +201 -23
  282. package/src/messaging/browser/window-connection.ts +72 -0
  283. package/src/messaging/client-call-metrics.ts +97 -0
  284. package/src/messaging/error.ts +16 -4
  285. package/src/messaging/handler.ts +12 -0
  286. package/src/messaging/node/connection.ts +2 -2
  287. package/src/messaging/proxy-factory.ts +16 -14
  288. package/src/payment-protocol.ts +20 -0
  289. package/src/permission.ts +9 -8
  290. package/src/plans.ts +632 -0
  291. package/src/protocol.ts +204 -61
  292. package/src/snapshot-url.spec.ts +25 -0
  293. package/src/snapshot-url.ts +27 -0
  294. package/src/team-subscription-protocol.ts +113 -0
  295. package/src/teams-projects-protocol.ts +132 -0
  296. package/src/theia-plugins.ts +1 -1
  297. package/src/typings/globals.ts +12 -0
  298. package/src/util/analytics.ts +87 -0
  299. package/src/util/async-iterator.ts +1 -1
  300. package/src/util/cancelable.ts +1 -1
  301. package/src/util/date-time.ts +1 -1
  302. package/src/util/deep-partial.ts +1 -1
  303. package/src/util/deferred.ts +2 -2
  304. package/src/util/garbage-collected-cache.ts +3 -3
  305. package/src/util/generate-workspace-id.spec.ts +31 -0
  306. package/src/util/generate-workspace-id.ts +457 -0
  307. package/src/util/gitpod-cookie.ts +39 -0
  308. package/src/util/gitpod-host-url.spec.ts +49 -0
  309. package/src/util/gitpod-host-url.ts +58 -14
  310. package/src/util/grpc.ts +15 -0
  311. package/src/util/jaeger-client.d.ts +1 -1
  312. package/src/util/logging.ts +111 -39
  313. package/src/util/make-link.ts +1 -1
  314. package/src/util/parse-workspace-id.spec.ts +46 -5
  315. package/src/util/parse-workspace-id.ts +39 -8
  316. package/src/util/queue.spec.ts +2 -2
  317. package/src/util/queue.ts +1 -1
  318. package/src/util/repeater.ts +1 -1
  319. package/src/util/safe-promise.ts +1 -1
  320. package/src/util/semaphore.ts +3 -3
  321. package/src/util/skip-if.ts +2 -2
  322. package/src/util/timeutil.spec.ts +1 -1
  323. package/src/util/timeutil.ts +5 -5
  324. package/src/util/tracing.ts +66 -4
  325. package/src/util/workspace-port-authentication.ts +1 -1
  326. package/src/workspace-cluster.ts +96 -0
  327. package/src/workspace-instance.ts +38 -16
  328. package/src/wsready.ts +2 -2
  329. package/lib/util/without.d.ts +0 -7
  330. package/lib/util/without.d.ts.map +0 -1
  331. package/lib/util/without.js.map +0 -1
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,27 @@ 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[];
90
107
  }
91
108
 
92
109
  export interface EmailNotificationSettings {
93
- disallowTransactionalEmails?: boolean;
110
+ allowsChangelogMail?: boolean;
111
+ allowsDevXMail?: boolean;
112
+ allowsOnboardingMail?: boolean;
113
+ }
114
+
115
+ export type IDESettings = {
116
+ defaultIde?: string
117
+ useDesktopIde?: boolean
118
+ defaultDesktopIde?: string
94
119
  }
95
120
 
96
121
  export interface UserPlatform {
@@ -104,7 +129,7 @@ export interface UserPlatform {
104
129
  * Since when does the user have the browser extension installe don this device.
105
130
  */
106
131
  browserExtensionInstalledSince?: string;
107
-
132
+
108
133
  /**
109
134
  * Since when does the user not have the browser extension installed anymore (but previously had).
110
135
  */
@@ -112,14 +137,6 @@ export interface UserPlatform {
112
137
  }
113
138
 
114
139
  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
140
  /**
124
141
  * Permanent feature flags are added to each and every workspace instance
125
142
  * this user starts.
@@ -131,8 +148,8 @@ export interface UserFeatureSettings {
131
148
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
132
149
  * If they don't we'll break things during workspace startup.
133
150
  */
134
- export const WorkspaceFeatureFlags = { "privileged": undefined, "registry_facade": undefined, "full_workspace_backup": undefined, "fixed_resources": undefined };
135
- export type NamedWorkspaceFeatureFlag = keyof(typeof WorkspaceFeatureFlags);
151
+ export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
152
+ export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
136
153
 
137
154
  export interface UserEnvVarValue {
138
155
  id?: string;
@@ -152,6 +169,28 @@ export namespace UserEnvVar {
152
169
  return pattern.toLocaleLowerCase();
153
170
  }
154
171
 
172
+ export function score(value: UserEnvVarValue): number {
173
+ // We use a score to enforce precedence:
174
+ // value/value = 0
175
+ // value/* = 1
176
+ // */value = 2
177
+ // */* = 3
178
+ // #/# = 4 (used for env vars passed through the URL)
179
+ // the lower the score, the higher the precedence.
180
+ const [ownerPattern, repoPattern] = splitRepositoryPattern(value.repositoryPattern);
181
+ let score = 0;
182
+ if (repoPattern == "*") {
183
+ score += 1;
184
+ }
185
+ if (ownerPattern == '*') {
186
+ score += 2;
187
+ }
188
+ if (ownerPattern == "#" || repoPattern == "#") {
189
+ score = 4;
190
+ }
191
+ return score;
192
+ }
193
+
155
194
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
156
195
  let result = vars.filter(e => {
157
196
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -187,25 +226,7 @@ export namespace UserEnvVar {
187
226
  let minscore = 10;
188
227
  let bestCandidate: T | undefined;
189
228
  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
-
229
+ const score = UserEnvVar.score(e);
209
230
  if (!bestCandidate || score < minscore) {
210
231
  minscore = score;
211
232
  bestCandidate = e;
@@ -217,7 +238,7 @@ export namespace UserEnvVar {
217
238
  return result;
218
239
  }
219
240
 
220
- function splitRepositoryPattern(repositoryPattern: string): string[] {
241
+ export function splitRepositoryPattern(repositoryPattern: string): string[] {
221
242
  const patterns = repositoryPattern.split('/');
222
243
  const repoPattern = patterns.pop() || "";
223
244
  const ownerPattern = patterns.join('/');
@@ -238,13 +259,13 @@ export interface GitpodToken {
238
259
 
239
260
  /** The user the token belongs to. */
240
261
  user: User
241
-
262
+
242
263
  /** Scopes (e.g. limition to read-only) */
243
264
  scopes: string[]
244
265
 
245
266
  /** Created timestamp */
246
267
  created: string
247
-
268
+
248
269
  // token is deleted on the database and about to be collected by db-sync
249
270
  deleted?: boolean
250
271
  }
@@ -351,11 +372,16 @@ export interface PendingGithubEvent {
351
372
  export interface Snapshot {
352
373
  id: string;
353
374
  creationTime: string;
375
+ availableTime?: string;
354
376
  originalWorkspaceId: string;
355
377
  bucketId: string;
356
378
  layoutData?: string;
379
+ state: SnapshotState;
380
+ message?: string;
357
381
  }
358
382
 
383
+ export type SnapshotState = 'pending' | 'available' | 'error';
384
+
359
385
  export interface LayoutData {
360
386
  workspaceId: string;
361
387
  lastUpdatedTime: string;
@@ -368,9 +394,10 @@ export interface Workspace {
368
394
  contextURL: string;
369
395
  description: string;
370
396
  ownerId: string;
397
+ projectId?: string;
371
398
  context: WorkspaceContext;
372
399
  config: WorkspaceConfig;
373
-
400
+
374
401
  /**
375
402
  * The source where to get the workspace base image from. This source is resolved
376
403
  * during workspace creation. Once a base image has been built the information in here
@@ -476,6 +503,7 @@ export interface PreparePluginUploadParams {
476
503
  export interface ResolvePluginsParams {
477
504
  config?: WorkspaceConfig
478
505
  builtins?: ResolvedPlugins
506
+ vsxRegistryUrl?: string
479
507
  }
480
508
 
481
509
  export interface InstallPluginsParams {
@@ -486,6 +514,24 @@ export interface UninstallPluginParams {
486
514
  pluginId: string;
487
515
  }
488
516
 
517
+ export interface GuessGitTokenScopesParams {
518
+ host: string
519
+ repoUrl: string
520
+ gitCommand: string
521
+ currentToken: GitToken
522
+ }
523
+
524
+ export interface GitToken {
525
+ token: string
526
+ user: string
527
+ scopes: string[]
528
+ }
529
+
530
+ export interface GuessedGitTokenScopes {
531
+ message?: string
532
+ scopes?: string[]
533
+ }
534
+
489
535
  export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
490
536
 
491
537
  export interface ResolvedPlugins {
@@ -508,21 +554,24 @@ export interface WorkspaceConfig {
508
554
  tasks?: TaskConfig[];
509
555
  checkoutLocation?: string;
510
556
  workspaceLocation?: string;
511
- privileged?: boolean;
512
557
  gitConfig?: { [config: string]: string };
513
558
  github?: GithubAppConfig;
514
559
  vscode?: VSCodeConfig;
515
- ide?: 'theia' | 'code' | string;
560
+
561
+ /** tailscale demo */
562
+ experimentalNetwork?: boolean;
516
563
 
517
564
  /**
518
565
  * Where the config object originates from.
519
- *
520
- * repo - from the repository
521
- * definitly-gp - from github.com/gitpod-io/definitely-gp
522
- * derived - computed based on analyzing the repository
523
- * default - our static catch-all default config
566
+ *
567
+ * - repo - from the repository
568
+ * - project-db - from the "Project" stored in the database
569
+ * - definitly-gp - from github.com/gitpod-io/definitely-gp
570
+ * - derived - computed based on analyzing the repository
571
+ * - additional-content - config comes from additional content, usually provided through the project's configuration
572
+ * - default - our static catch-all default config
524
573
  */
525
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
574
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
526
575
 
527
576
  /**
528
577
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -552,16 +601,13 @@ export namespace GithubAppPrebuildConfig {
552
601
 
553
602
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
554
603
  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
604
  dockerFilePath: string
605
+ dockerFileHash: string
606
+ dockerFileSource?: Commit
560
607
  }
561
608
  export namespace WorkspaceImageSourceDocker {
562
609
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
563
610
  return 'dockerFileHash' in obj
564
- && 'dockerFileSource' in obj
565
611
  && 'dockerFilePath' in obj;
566
612
  }
567
613
  }
@@ -590,6 +636,8 @@ export type PrebuiltWorkspaceState
590
636
  export interface PrebuiltWorkspace {
591
637
  id: string;
592
638
  cloneURL: string;
639
+ branch?: string;
640
+ projectId?: string;
593
641
  commit: string;
594
642
  buildWorkspaceId: string;
595
643
  creationTime: string;
@@ -599,6 +647,10 @@ export interface PrebuiltWorkspace {
599
647
  }
600
648
 
601
649
  export namespace PrebuiltWorkspace {
650
+ export function isDone(pws: PrebuiltWorkspace) {
651
+ return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
652
+ }
653
+
602
654
  export function isAvailable(pws: PrebuiltWorkspace) {
603
655
  return pws.state === "available" && !!pws.snapshot;
604
656
  }
@@ -655,7 +707,7 @@ export interface TaskConfig {
655
707
  init?: string;
656
708
  prebuild?: string;
657
709
  command?: string;
658
- env?: { [env: string]: string };
710
+ env?: { [env: string]: any };
659
711
  openIn?: 'bottom' | 'main' | 'left' | 'right';
660
712
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
661
713
  }
@@ -719,8 +771,10 @@ export namespace ExternalImageConfigFile {
719
771
 
720
772
  export interface WorkspaceContext {
721
773
  title: string;
774
+ /** This contains the URL portion of the contextURL (which might contain other modifiers as well). It's optional because it's not set for older workspaces. */
722
775
  normalizedContextURL?: string;
723
776
  forceCreateNewWorkspace?: boolean;
777
+ forceImageBuild?: boolean;
724
778
  }
725
779
 
726
780
  export namespace WorkspaceContext {
@@ -754,13 +808,36 @@ export namespace WithPrebuild {
754
808
  }
755
809
  }
756
810
 
811
+ /**
812
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
813
+ * and fall back to the built-in configuration.
814
+ */
815
+ export interface WithDefaultConfig {
816
+ withDefaultConfig: true;
817
+ }
818
+
819
+ export namespace WithDefaultConfig {
820
+ export function is(context: any): context is WithDefaultConfig {
821
+ return context
822
+ && 'withDefaultConfig' in context
823
+ && context.withDefaultConfig;
824
+ }
825
+
826
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
827
+ return {
828
+ ...ctx,
829
+ withDefaultConfig: true
830
+ }
831
+ }
832
+ }
833
+
757
834
  export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
758
835
  snapshotId: string;
759
836
  }
760
837
 
761
838
  export namespace SnapshotContext {
762
839
  export function is(context: any): context is SnapshotContext {
763
- return context
840
+ return context
764
841
  && WithSnapshot.is(context)
765
842
  && 'snapshotId' in context;
766
843
  }
@@ -768,6 +845,9 @@ export namespace SnapshotContext {
768
845
 
769
846
  export interface StartPrebuildContext extends WorkspaceContext {
770
847
  actual: WorkspaceContext;
848
+ commitHistory?: string[];
849
+ project?: Project;
850
+ branch?: string;
771
851
  }
772
852
 
773
853
  export namespace StartPrebuildContext {
@@ -837,6 +917,25 @@ export interface Commit {
837
917
  refType?: RefType
838
918
  }
839
919
 
920
+ export interface AdditionalContentContext extends WorkspaceContext {
921
+
922
+ /**
923
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
924
+ */
925
+ additionalFiles: {[filePath: string]: string};
926
+
927
+ }
928
+
929
+ export namespace AdditionalContentContext {
930
+ export function is(ctx: any): ctx is AdditionalContentContext {
931
+ return 'additionalFiles' in ctx;
932
+ }
933
+
934
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
935
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
936
+ }
937
+ }
938
+
840
939
  export interface CommitContext extends WorkspaceContext, Commit {
841
940
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
842
941
  cloneUrl?: string
@@ -912,6 +1011,19 @@ export interface Repository {
912
1011
  parent: Repository
913
1012
  }
914
1013
  }
1014
+ export interface Branch {
1015
+ name: string;
1016
+ commit: CommitInfo;
1017
+ htmlUrl: string;
1018
+ }
1019
+
1020
+ export interface CommitInfo {
1021
+ author: string;
1022
+ sha: string;
1023
+ commitMessage: string;
1024
+ authorAvatarUrl?: string;
1025
+ authorDate?: string;
1026
+ }
915
1027
 
916
1028
  export namespace Repository {
917
1029
  export function fullRepoName(repo: Repository): string {
@@ -939,6 +1051,12 @@ export interface WorkspaceInfo {
939
1051
  latestInstance?: WorkspaceInstance
940
1052
  }
941
1053
 
1054
+ export namespace WorkspaceInfo {
1055
+ export function lastActiveISODate(info: WorkspaceInfo): string {
1056
+ return info.latestInstance?.creationTime || info.workspace.creationTime;
1057
+ }
1058
+ }
1059
+
942
1060
  export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
943
1061
 
944
1062
  export interface WorkspaceCreationResult {
@@ -948,6 +1066,7 @@ export interface WorkspaceCreationResult {
948
1066
  runningWorkspacePrebuild?: {
949
1067
  prebuildID: string
950
1068
  workspaceID: string
1069
+ instanceID: string
951
1070
  starting: RunningWorkspacePrebuildStarting
952
1071
  sameCluster: boolean
953
1072
  }
@@ -1038,8 +1157,17 @@ export interface OAuth2Config {
1038
1157
  export namespace AuthProviderEntry {
1039
1158
  export type Type = "GitHub" | "GitLab" | string;
1040
1159
  export type Status = "pending" | "verified";
1041
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type">;
1160
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1042
1161
  export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
1162
+ export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1163
+ return {
1164
+ ...entry,
1165
+ oauth: {
1166
+ ...entry.oauth,
1167
+ clientSecret: "redacted"
1168
+ }
1169
+ }
1170
+ }
1043
1171
  }
1044
1172
 
1045
1173
  export interface Branding {
@@ -1100,3 +1228,18 @@ export namespace TheiaPlugin {
1100
1228
  CheckinFailed = "checkin-failed",
1101
1229
  }
1102
1230
  }
1231
+
1232
+ export interface TermsAcceptanceEntry {
1233
+ readonly userId: string;
1234
+ readonly termsRevision: string;
1235
+ readonly acceptionTime: string;
1236
+ }
1237
+
1238
+ export interface Terms {
1239
+ readonly revision: string;
1240
+ readonly activeSince: string;
1241
+ readonly adminOnlyTerms: boolean;
1242
+ readonly updateMessage: string;
1243
+ readonly content: string;
1244
+ readonly formElements?: object;
1245
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { suite, test } from "mocha-typescript"
8
+ import * as chai from "chai"
9
+ import { SnapshotUrl } from ".";
10
+
11
+ const expect = chai.expect
12
+
13
+ @suite class TestSnapshotUrlParser {
14
+
15
+ @test public testPositive() {
16
+ const actual = SnapshotUrl.parse("workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd");
17
+
18
+ expect(actual).to.deep.equal(<SnapshotUrl>{
19
+ bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
20
+ filename: "3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
21
+ fullPath: "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
22
+ });
23
+ }
24
+ }
25
+ module.exports = new TestSnapshotUrlParser() // Only to circumvent no usage warning :-/
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ export interface SnapshotUrl {
8
+ bucketId: string;
9
+ fullPath: string;
10
+ filename: string;
11
+ }
12
+ export namespace SnapshotUrl {
13
+ export function parse(url: string): SnapshotUrl {
14
+ const parts = url.split("@");
15
+ if (parts.length !== 2) {
16
+ throw new Error(`cannot parse snapshot URL: ${url}`);
17
+ }
18
+ const [fullPath, bucketId] = parts;
19
+
20
+ const pathParts = fullPath.split("/");
21
+ if (pathParts.length < 1) {
22
+ throw new Error(`cannot parse snapshot URL: ${url}`);
23
+ }
24
+ const filename = pathParts[pathParts.length - 1];
25
+ return { bucketId, fullPath, filename };
26
+ }
27
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { v4 as uuidv4 } from 'uuid';
8
+ import { Subscription } from "./accounting-protocol";
9
+
10
+ export interface TeamSubscription {
11
+ id: string;
12
+ userId: string;
13
+ planId: string;
14
+ startDate: string;
15
+ endDate?: string;
16
+ quantity: number;
17
+ /** The Chargebee subscription id */
18
+ paymentReference: string;
19
+ cancellationDate?: string;
20
+ deleted?: boolean;
21
+ }
22
+
23
+ export namespace TeamSubscription {
24
+ export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
25
+ const withId = ts as TeamSubscription;
26
+ withId.id = uuidv4();
27
+ return withId;
28
+ }
29
+ export const isActive = (ts: TeamSubscription, date: string): boolean => {
30
+ return ts.startDate <= date && (ts.endDate === undefined || date < ts.endDate);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * A slot represents one unit of a TeamSubscription that gets assigned to one user at a time
36
+ */
37
+ export interface TeamSubscriptionSlot {
38
+ id: string;
39
+ teamSubscriptionId: string;
40
+ assigneeId?: string;
41
+ assigneeIdentifier?: AssigneeIdentifier;
42
+ subscriptionId?: string;
43
+ cancellationDate?: string;
44
+ }
45
+ export type TeamSubscriptionSlotDeactivated = TeamSubscriptionSlot & { assigneeId: string, assigneeIdentifier: AssigneeIdentifier };
46
+ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscriptionSlotDeactivated & { subscriptionId: string };
47
+
48
+ export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
49
+
50
+ export namespace TeamSubscriptionSlot {
51
+ export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
52
+ const withId = ts as TeamSubscriptionSlot;
53
+ withId.id = uuidv4();
54
+ return withId;
55
+ }
56
+ export const assign = (slot: TeamSubscriptionSlot, assigneeId: string, subscriptionId: string, assigneeIdentifier: AssigneeIdentifier) => {
57
+ slot.assigneeId = assigneeId;
58
+ slot.subscriptionId = subscriptionId;
59
+ slot.assigneeIdentifier = assigneeIdentifier;
60
+ }
61
+ export const deactivate = (slot: TeamSubscriptionSlot, cancellationDate: string) => {
62
+ slot.subscriptionId = undefined;
63
+ slot.cancellationDate = cancellationDate;
64
+ }
65
+ export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
66
+ slot.subscriptionId = subscriptionId;
67
+ slot.cancellationDate = undefined;
68
+ }
69
+ export const status = (slot: TeamSubscriptionSlot, now: string): TeamSubscriptionSlotState => {
70
+ if (slot.cancellationDate) {
71
+ if (slot.cancellationDate < now) {
72
+ return 'cancelled';
73
+ } else {
74
+ return 'deactivated';
75
+ }
76
+ } else {
77
+ if (slot.subscriptionId) {
78
+ return 'assigned';
79
+ } else {
80
+ return 'unassigned';
81
+ }
82
+ }
83
+
84
+ }
85
+ export const isActive = (slot: TeamSubscriptionSlot): boolean => {
86
+ return !slot.cancellationDate;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * The mapping between a TeamSubscription and a resulting Subscription, resolved
92
+ */
93
+ export interface TeamSubscriptionSlotResolved {
94
+ id: string;
95
+ teamSubscription: TeamSubscription;
96
+ state: TeamSubscriptionSlotState;
97
+ assigneeId?: string;
98
+ assigneeIdentifier?: AssigneeIdentifier;
99
+ subscription?: Subscription;
100
+ cancellationDate?: string;
101
+ hoursLeft?: number;
102
+ }
103
+
104
+ /**
105
+ * Contains the data structure that the assigner used to identify the assignee.
106
+ */
107
+ export type AssigneeIdentifier = AssigneeIdentityIdentifier;
108
+ export interface AssigneeIdentityIdentifier {
109
+ identity: {
110
+ authHost: string,
111
+ authName: string
112
+ }
113
+ }