@gitpod/gitpod-protocol 0.1.5-me-gcp-preview.69 → 0.1.5-me-ingress.19

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 (288) hide show
  1. package/data/builtin-theia-plugins.json +3 -3
  2. package/data/gitpod-schema.json +13 -24
  3. package/lib/accounting-protocol.d.ts +155 -0
  4. package/lib/accounting-protocol.d.ts.map +1 -0
  5. package/lib/accounting-protocol.js +109 -0
  6. package/lib/accounting-protocol.js.map +1 -0
  7. package/lib/admin-protocol.d.ts +20 -4
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +15 -0
  10. package/lib/admin-protocol.js.map +1 -1
  11. package/lib/analytics.d.ts +45 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/context-url.d.ts +18 -0
  16. package/lib/context-url.d.ts.map +1 -0
  17. package/lib/context-url.js +49 -0
  18. package/lib/context-url.js.map +1 -0
  19. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +3 -1
  20. package/lib/context-url.spec.d.ts.map +1 -0
  21. package/lib/context-url.spec.js +73 -0
  22. package/lib/context-url.spec.js.map +1 -0
  23. package/lib/email-protocol.d.ts +1 -2
  24. package/lib/email-protocol.d.ts.map +1 -1
  25. package/lib/email-protocol.js +4 -4
  26. package/lib/email-protocol.js.map +1 -1
  27. package/lib/encryption/container-module.js +5 -4
  28. package/lib/encryption/container-module.js.map +1 -1
  29. package/lib/encryption/encryption-engine.js +19 -20
  30. package/lib/encryption/encryption-engine.js.map +1 -1
  31. package/lib/encryption/encryption-engine.spec.js +29 -36
  32. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  33. package/lib/encryption/encryption-service.js +29 -43
  34. package/lib/encryption/encryption-service.js.map +1 -1
  35. package/lib/encryption/key-provider.js +25 -30
  36. package/lib/encryption/key-provider.js.map +1 -1
  37. package/lib/env.d.ts +1 -2
  38. package/lib/env.d.ts.map +1 -1
  39. package/lib/env.js +20 -21
  40. package/lib/env.js.map +1 -1
  41. package/lib/gitpod-file-parser.js +25 -41
  42. package/lib/gitpod-file-parser.js.map +1 -1
  43. package/lib/gitpod-file-parser.spec.js +116 -116
  44. package/lib/gitpod-file-parser.spec.js.map +1 -1
  45. package/lib/gitpod-service.d.ts +139 -19
  46. package/lib/gitpod-service.d.ts.map +1 -1
  47. package/lib/gitpod-service.js +168 -256
  48. package/lib/gitpod-service.js.map +1 -1
  49. package/lib/headless-workspace-log.d.ts +8 -28
  50. package/lib/headless-workspace-log.d.ts.map +1 -1
  51. package/lib/headless-workspace-log.js +4 -26
  52. package/lib/headless-workspace-log.js.map +1 -1
  53. package/lib/ide-protocol.d.ts +81 -0
  54. package/lib/ide-protocol.d.ts.map +1 -0
  55. package/lib/ide-protocol.js +8 -0
  56. package/lib/ide-protocol.js.map +1 -0
  57. package/lib/index.d.ts +5 -0
  58. package/lib/index.d.ts.map +1 -1
  59. package/lib/index.js +6 -1
  60. package/lib/index.js.map +1 -1
  61. package/lib/messaging/browser/connection.d.ts +5 -3
  62. package/lib/messaging/browser/connection.d.ts.map +1 -1
  63. package/lib/messaging/browser/connection.js +183 -33
  64. package/lib/messaging/browser/connection.js.map +1 -1
  65. package/lib/messaging/browser/window-connection.js +35 -55
  66. package/lib/messaging/browser/window-connection.js.map +1 -1
  67. package/lib/messaging/client-call-metrics.d.ts +35 -0
  68. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  69. package/lib/messaging/client-call-metrics.js +83 -0
  70. package/lib/messaging/client-call-metrics.js.map +1 -0
  71. package/lib/messaging/connection-error-handler.js +11 -23
  72. package/lib/messaging/connection-error-handler.js.map +1 -1
  73. package/lib/messaging/error.d.ts +3 -1
  74. package/lib/messaging/error.d.ts.map +1 -1
  75. package/lib/messaging/error.js +6 -2
  76. package/lib/messaging/error.js.map +1 -1
  77. package/lib/messaging/handler.d.ts +10 -0
  78. package/lib/messaging/handler.d.ts.map +1 -1
  79. package/lib/messaging/node/connection.d.ts +0 -10
  80. package/lib/messaging/node/connection.d.ts.map +1 -1
  81. package/lib/messaging/node/connection.js +12 -50
  82. package/lib/messaging/node/connection.js.map +1 -1
  83. package/lib/messaging/proxy-factory.d.ts +2 -0
  84. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  85. package/lib/messaging/proxy-factory.js +74 -159
  86. package/lib/messaging/proxy-factory.js.map +1 -1
  87. package/lib/oss-allowlist.d.ts +14 -0
  88. package/lib/oss-allowlist.d.ts.map +1 -0
  89. package/lib/oss-allowlist.js +8 -0
  90. package/lib/oss-allowlist.js.map +1 -0
  91. package/lib/payment-protocol.d.ts +18 -0
  92. package/lib/payment-protocol.d.ts.map +1 -0
  93. package/lib/payment-protocol.js +13 -0
  94. package/lib/payment-protocol.js.map +1 -0
  95. package/lib/permission.d.ts +2 -1
  96. package/lib/permission.d.ts.map +1 -1
  97. package/lib/permission.js +14 -13
  98. package/lib/permission.js.map +1 -1
  99. package/lib/plans.d.ts +210 -0
  100. package/lib/plans.d.ts.map +1 -0
  101. package/lib/plans.js +570 -0
  102. package/lib/plans.js.map +1 -0
  103. package/lib/protocol.d.ts +97 -26
  104. package/lib/protocol.d.ts.map +1 -1
  105. package/lib/protocol.js +104 -130
  106. package/lib/protocol.js.map +1 -1
  107. package/lib/snapshot-url.d.ts +14 -0
  108. package/lib/snapshot-url.d.ts.map +1 -0
  109. package/lib/snapshot-url.js +26 -0
  110. package/lib/snapshot-url.js.map +1 -0
  111. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  112. package/lib/snapshot-url.spec.d.ts.map +1 -0
  113. package/lib/snapshot-url.spec.js +41 -0
  114. package/lib/snapshot-url.spec.js.map +1 -0
  115. package/lib/team-subscription-protocol.d.ts +73 -0
  116. package/lib/team-subscription-protocol.d.ts.map +1 -0
  117. package/lib/team-subscription-protocol.js +63 -0
  118. package/lib/team-subscription-protocol.js.map +1 -0
  119. package/lib/teams-projects-protocol.d.ts +110 -0
  120. package/lib/teams-projects-protocol.d.ts.map +1 -0
  121. package/lib/teams-projects-protocol.js +23 -0
  122. package/lib/teams-projects-protocol.js.map +1 -0
  123. package/lib/util/analytics.d.ts +8 -0
  124. package/lib/util/analytics.d.ts.map +1 -0
  125. package/lib/util/analytics.js +79 -0
  126. package/lib/util/analytics.js.map +1 -0
  127. package/lib/util/async-iterator.js +55 -133
  128. package/lib/util/async-iterator.js.map +1 -1
  129. package/lib/util/cancelable.js +17 -59
  130. package/lib/util/cancelable.js.map +1 -1
  131. package/lib/util/date-time.js +8 -8
  132. package/lib/util/date-time.js.map +1 -1
  133. package/lib/util/deferred.js +10 -12
  134. package/lib/util/deferred.js.map +1 -1
  135. package/lib/util/disposable.js +26 -39
  136. package/lib/util/disposable.js.map +1 -1
  137. package/lib/util/event.js +58 -74
  138. package/lib/util/event.js.map +1 -1
  139. package/lib/util/garbage-collected-cache.d.ts +1 -0
  140. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  141. package/lib/util/garbage-collected-cache.js +26 -46
  142. package/lib/util/garbage-collected-cache.js.map +1 -1
  143. package/lib/util/generate-workspace-id.d.ts +1 -1
  144. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  145. package/lib/util/generate-workspace-id.js +30 -68
  146. package/lib/util/generate-workspace-id.js.map +1 -1
  147. package/lib/util/generate-workspace-id.spec.js +56 -78
  148. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  149. package/lib/util/gitpod-cookie.d.ts +20 -0
  150. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  151. package/lib/util/gitpod-cookie.js +44 -0
  152. package/lib/util/gitpod-cookie.js.map +1 -0
  153. package/lib/util/gitpod-host-url.d.ts +1 -1
  154. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  155. package/lib/util/gitpod-host-url.js +98 -98
  156. package/lib/util/gitpod-host-url.js.map +1 -1
  157. package/lib/util/gitpod-host-url.spec.d.ts +7 -1
  158. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  159. package/lib/util/gitpod-host-url.spec.js +103 -31
  160. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  161. package/lib/util/grpc.d.ts +15 -0
  162. package/lib/util/grpc.d.ts.map +1 -0
  163. package/lib/util/grpc.js +18 -0
  164. package/lib/util/grpc.js.map +1 -0
  165. package/lib/util/jaeger-client-types.d.ts +68 -0
  166. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  167. package/lib/util/{without.js → jaeger-client-types.js} +1 -1
  168. package/lib/util/jaeger-client-types.js.map +1 -0
  169. package/lib/util/logging.d.ts +49 -33
  170. package/lib/util/logging.d.ts.map +1 -1
  171. package/lib/util/logging.js +107 -110
  172. package/lib/util/logging.js.map +1 -1
  173. package/lib/util/make-link.js +2 -2
  174. package/lib/util/make-link.js.map +1 -1
  175. package/lib/util/parse-workspace-id.d.ts +10 -0
  176. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  177. package/lib/util/parse-workspace-id.js +32 -7
  178. package/lib/util/parse-workspace-id.js.map +1 -1
  179. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  180. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  181. package/lib/util/parse-workspace-id.spec.js +123 -84
  182. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  183. package/lib/util/queue.js +16 -55
  184. package/lib/util/queue.js.map +1 -1
  185. package/lib/util/queue.spec.js +144 -288
  186. package/lib/util/queue.spec.js.map +1 -1
  187. package/lib/util/repeat.d.ts +15 -0
  188. package/lib/util/repeat.d.ts.map +1 -0
  189. package/lib/util/repeat.js +55 -0
  190. package/lib/util/repeat.js.map +1 -0
  191. package/lib/util/safe-promise.js +9 -12
  192. package/lib/util/safe-promise.js.map +1 -1
  193. package/lib/util/semaphore.js +15 -46
  194. package/lib/util/semaphore.js.map +1 -1
  195. package/lib/util/skip-if.js +6 -6
  196. package/lib/util/skip-if.js.map +1 -1
  197. package/lib/util/timeutil.js +28 -16
  198. package/lib/util/timeutil.js.map +1 -1
  199. package/lib/util/timeutil.spec.js +21 -24
  200. package/lib/util/timeutil.spec.js.map +1 -1
  201. package/lib/util/tracing.d.ts +50 -5
  202. package/lib/util/tracing.d.ts.map +1 -1
  203. package/lib/util/tracing.js +175 -63
  204. package/lib/util/tracing.js.map +1 -1
  205. package/lib/util/tracing.spec.d.ts +7 -0
  206. package/lib/util/tracing.spec.d.ts.map +1 -0
  207. package/lib/util/tracing.spec.js +121 -0
  208. package/lib/util/tracing.spec.js.map +1 -0
  209. package/lib/util/workspace-port-authentication.js +3 -2
  210. package/lib/util/workspace-port-authentication.js.map +1 -1
  211. package/lib/workspace-cluster.d.ts +74 -0
  212. package/lib/workspace-cluster.d.ts.map +1 -0
  213. package/lib/workspace-cluster.js +16 -0
  214. package/lib/workspace-cluster.js.map +1 -0
  215. package/lib/workspace-instance.d.ts +5 -2
  216. package/lib/workspace-instance.d.ts.map +1 -1
  217. package/lib/wsready.d.ts +1 -1
  218. package/lib/wsready.js +2 -2
  219. package/package.json +31 -17
  220. package/pkg-yarn.lock +17 -9
  221. package/provenance-bundle.jsonl +2 -0
  222. package/src/accounting-protocol.ts +229 -0
  223. package/src/admin-protocol.ts +39 -5
  224. package/src/analytics.ts +54 -0
  225. package/src/context-url.spec.ts +39 -0
  226. package/src/context-url.ts +51 -0
  227. package/src/email-protocol.ts +2 -3
  228. package/src/env.ts +10 -10
  229. package/src/gitpod-service.ts +203 -34
  230. package/src/headless-workspace-log.ts +6 -34
  231. package/src/ide-protocol.ts +92 -0
  232. package/src/index.ts +6 -1
  233. package/src/messaging/browser/connection.ts +195 -14
  234. package/src/messaging/client-call-metrics.ts +97 -0
  235. package/src/messaging/error.ts +8 -2
  236. package/src/messaging/handler.ts +12 -0
  237. package/src/messaging/node/connection.ts +3 -47
  238. package/src/messaging/proxy-factory.ts +14 -6
  239. package/src/oss-allowlist.ts +15 -0
  240. package/src/payment-protocol.ts +20 -0
  241. package/src/permission.ts +2 -1
  242. package/src/plans.ts +632 -0
  243. package/src/protocol.ts +158 -55
  244. package/src/snapshot-url.spec.ts +25 -0
  245. package/src/snapshot-url.ts +27 -0
  246. package/src/team-subscription-protocol.ts +113 -0
  247. package/src/teams-projects-protocol.ts +141 -0
  248. package/src/util/analytics.ts +87 -0
  249. package/src/util/deferred.ts +1 -1
  250. package/src/util/garbage-collected-cache.ts +9 -3
  251. package/src/util/generate-workspace-id.spec.ts +19 -3
  252. package/src/util/generate-workspace-id.ts +21 -2
  253. package/src/util/gitpod-cookie.ts +39 -0
  254. package/src/util/gitpod-host-url.spec.ts +25 -1
  255. package/src/util/gitpod-host-url.ts +23 -10
  256. package/src/util/grpc.ts +15 -0
  257. package/src/util/jaeger-client-types.ts +102 -0
  258. package/src/util/logging.ts +102 -38
  259. package/src/util/parse-workspace-id.spec.ts +21 -1
  260. package/src/util/parse-workspace-id.ts +32 -6
  261. package/src/util/queue.spec.ts +1 -1
  262. package/src/util/repeat.ts +45 -0
  263. package/src/util/semaphore.ts +2 -2
  264. package/src/util/skip-if.ts +1 -1
  265. package/src/util/timeutil.ts +4 -4
  266. package/src/util/tracing.spec.ts +83 -0
  267. package/src/util/tracing.ts +162 -18
  268. package/src/workspace-cluster.ts +96 -0
  269. package/src/workspace-instance.ts +25 -13
  270. package/src/wsready.ts +2 -2
  271. package/lib/util/context-url.d.ts +0 -13
  272. package/lib/util/context-url.d.ts.map +0 -1
  273. package/lib/util/context-url.js +0 -26
  274. package/lib/util/context-url.js.map +0 -1
  275. package/lib/util/context-url.spec.d.ts.map +0 -1
  276. package/lib/util/context-url.spec.js +0 -52
  277. package/lib/util/context-url.spec.js.map +0 -1
  278. package/lib/util/repeater.d.ts +0 -22
  279. package/lib/util/repeater.d.ts.map +0 -1
  280. package/lib/util/repeater.js +0 -118
  281. package/lib/util/repeater.js.map +0 -1
  282. package/lib/util/without.d.ts +0 -7
  283. package/lib/util/without.d.ts.map +0 -1
  284. package/lib/util/without.js.map +0 -1
  285. package/src/util/context-url.spec.ts +0 -25
  286. package/src/util/context-url.ts +0 -23
  287. package/src/util/jaeger-client.d.ts +0 -105
  288. package/src/util/repeater.ts +0 -49
@@ -0,0 +1,54 @@
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
+
8
+ export const IAnalyticsWriter = Symbol("IAnalyticsWriter");
9
+
10
+ type Identity =
11
+ | { userId: string | number }
12
+ | { userId?: string | number; anonymousId: string | number };
13
+
14
+ interface Message {
15
+ messageId?: string;
16
+ }
17
+
18
+ export type IdentifyMessage = Message & Identity & {
19
+ traits?: any;
20
+ timestamp?: Date;
21
+ context?: any;
22
+ };
23
+
24
+ export type TrackMessage = Message & Identity & {
25
+ event: string;
26
+ properties?: any;
27
+ timestamp?: Date;
28
+ context?: any;
29
+ };
30
+
31
+ export type PageMessage = Message & Identity & {
32
+ properties?: any;
33
+ timestamp?: Date;
34
+ context?: any;
35
+ };
36
+
37
+ export type RemoteTrackMessage = Omit<TrackMessage, "timestamp" | "userId" | "anonymousId"> & {
38
+ anonymousId?: string | number;
39
+ };
40
+ export type RemotePageMessage = Omit<PageMessage, "timestamp" | "userId"> & {
41
+ anonymousId?: string | number;
42
+ };
43
+
44
+ export type RemoteIdentifyMessage = Omit<IdentifyMessage, "timestamp" | "userId" | "anonymousId">;
45
+
46
+ export interface IAnalyticsWriter {
47
+
48
+ identify(msg: IdentifyMessage): void;
49
+
50
+ track(msg: TrackMessage): void;
51
+
52
+ page(msg: PageMessage): void;
53
+
54
+ }
@@ -0,0 +1,39 @@
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 * as chai from 'chai';
8
+ import { suite, test } from 'mocha-typescript';
9
+ import { ContextURL } from './context-url';
10
+ const expect = chai.expect;
11
+
12
+ @suite
13
+ export class ContextUrlTest {
14
+
15
+ @test public parseContextUrl_withEnvVar() {
16
+ const actual = ContextURL.parseToURL("passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo");
17
+ expect(actual?.host).to.equal("github.com");
18
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
19
+ }
20
+
21
+ @test public parseContextUrl_withEnvVar_withoutSchema() {
22
+ const actual = ContextURL.parseToURL("passedin=test%20value/github.com/gitpod-io/gitpod-test-repo");
23
+ expect(actual?.host).to.equal("github.com");
24
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
25
+ }
26
+
27
+ @test public parseContextUrl_withPrebuild() {
28
+ const actual = ContextURL.parseToURL("prebuild/https://github.com/gitpod-io/gitpod-test-repo");
29
+ expect(actual?.host).to.equal("github.com");
30
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
31
+ }
32
+
33
+ @test public parseContextUrl_withPrebuild_withoutSchema() {
34
+ const actual = ContextURL.parseToURL("prebuild/github.com/gitpod-io/gitpod-test-repo");
35
+ expect(actual?.host).to.equal("github.com");
36
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
37
+ }
38
+ }
39
+ module.exports = new ContextUrlTest()
@@ -0,0 +1,51 @@
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
+ export namespace ContextURL {
8
+ export const INCREMENTAL_PREBUILD_PREFIX = "incremental-prebuild";
9
+ export const PREBUILD_PREFIX = "prebuild";
10
+ export const IMAGEBUILD_PREFIX = "imagebuild";
11
+
12
+ /**
13
+ * The field "contextUrl" might contain prefixes like:
14
+ * - envvar1=value1/...
15
+ * - prebuild/...
16
+ * This is the analogon to the (Prefix)ContextParser structure in "server".
17
+ */
18
+ export function parseToURL(contextUrl: string | undefined): URL | undefined {
19
+ if (contextUrl === undefined) {
20
+ return undefined;
21
+ }
22
+
23
+ const segments = contextUrl.split("/");
24
+ if (segments.length === 1) {
25
+ return new URL(segments[0]); // this might be something, we just try
26
+ }
27
+
28
+ const segmentsToURL = (offset: number): URL => {
29
+ let rest = segments.slice(offset).join("/");
30
+ if (!rest.startsWith("http")) {
31
+ rest = 'https://' + rest;
32
+ }
33
+ return new URL(rest);
34
+ };
35
+
36
+
37
+ const firstSegment = segments[0];
38
+ if (firstSegment === PREBUILD_PREFIX ||
39
+ firstSegment === INCREMENTAL_PREBUILD_PREFIX ||
40
+ firstSegment === IMAGEBUILD_PREFIX) {
41
+ return segmentsToURL(1);
42
+ }
43
+
44
+ // check for env vars
45
+ if (firstSegment.indexOf("=") !== -1) {
46
+ return segmentsToURL(1);
47
+ }
48
+
49
+ return segmentsToURL(0);
50
+ }
51
+ }
@@ -4,8 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { Without } from "./util/without";
8
- import uuidv4 = require("uuid/v4");
7
+ import { v4 as uuidv4 } from 'uuid';
9
8
 
10
9
  export type EMailState = "scheduledInternal"
11
10
  | "scheduledSendgrid";
@@ -59,7 +58,7 @@ export type EMail = {
59
58
  } & EMailStatus;
60
59
 
61
60
  export namespace EMail {
62
- export const create = (ts: Without<EMail, 'uid'>): EMail => {
61
+ export const create = (ts: Omit<EMail, 'uid'>): EMail => {
63
62
  const withId = ts as EMail;
64
63
  withId.uid = uuidv4();
65
64
  return withId;
package/src/env.ts CHANGED
@@ -13,18 +13,18 @@ const legacyStagenameTranslation: { [key: string]: KubeStage } = {
13
13
  "dev": "dev"
14
14
  }
15
15
 
16
+ export function translateLegacyStagename(kubeStage: string): KubeStage {
17
+ const stage = legacyStagenameTranslation[kubeStage];
18
+ if (!stage) {
19
+ throw new Error(`Invalid KUBE_STAGE: ${kubeStage}`);
20
+ }
21
+
22
+ return stage;
23
+ }
24
+
16
25
  @injectable()
17
26
  export abstract class AbstractComponentEnv {
18
- readonly kubeStage: KubeStage = getEnvVarParsed('KUBE_STAGE', (kubeStage) => {
19
- const stage = legacyStagenameTranslation[kubeStage];
20
- if (!stage) {
21
- throw new Error(`Environment variable invalid: KUBE_STAGE=${kubeStage}`);
22
- }
23
-
24
- return stage;
25
- });
26
- readonly kubeNamespace: string = getEnvVar('KUBE_NAMESPACE');
27
- readonly version: string = getEnvVar('VERSION');
27
+ readonly kubeStage: KubeStage = getEnvVarParsed('KUBE_STAGE', translateLegacyStagename);
28
28
 
29
29
  readonly installationLongname: string = getEnvVar("GITPOD_INSTALLATION_LONGNAME")
30
30
  readonly installationShortname: string = getEnvVar("GITPOD_INSTALLATION_SHORTNAME")
@@ -5,14 +5,19 @@
5
5
  */
6
6
 
7
7
  import {
8
- User, WorkspaceInfo, WorkspaceCreationResult, UserMessage, WorkspaceInstanceUser,
8
+ User, WorkspaceInfo, WorkspaceCreationResult, WorkspaceInstanceUser,
9
9
  WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode,
10
10
  Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
- ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType, GitpodToken, AuthProviderEntry
11
+ ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
+ GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes
12
13
  } from './protocol';
14
+ import {
15
+ Team, TeamMemberInfo,
16
+ TeamMembershipInvite, Project, TeamMemberRole, PrebuildWithStatus, StartPrebuildResult, PartialProject
17
+ } from './teams-projects-protocol';
13
18
  import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
14
19
  import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
15
- import { HeadlessLogEvent } from './headless-workspace-log';
20
+ import { HeadlessLogUrls } from './headless-workspace-log';
16
21
  import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
17
22
  import { AdminServer } from './admin-protocol';
18
23
  import { GitpodHostUrl } from './util/gitpod-host-url';
@@ -20,11 +25,19 @@ import { WebSocketConnectionProvider } from './messaging/browser/connection';
20
25
  import { PermissionName } from './permission';
21
26
  import { LicenseService } from './license-protocol';
22
27
  import { Emitter } from './util/event';
28
+ import { AccountStatement, CreditAlert } from './accounting-protocol';
29
+ import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
30
+ import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
31
+ import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from './analytics';
32
+ import { IDEServer } from './ide-protocol';
23
33
 
24
34
  export interface GitpodClient {
25
35
  onInstanceUpdate(instance: WorkspaceInstance): void;
26
36
  onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
27
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void;
37
+
38
+ onPrebuildUpdate(update: PrebuildWithStatus): void;
39
+
40
+ onCreditAlert(creditAlert: CreditAlert): void;
28
41
 
29
42
  //#region propagating reconnection to iframe
30
43
  notifyDidOpenConnection(): void;
@@ -33,18 +46,19 @@ export interface GitpodClient {
33
46
  }
34
47
 
35
48
  export const GitpodServer = Symbol('GitpodServer');
36
- export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService {
49
+ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
37
50
  // User related API
38
51
  getLoggedInUser(): Promise<User>;
39
52
  getTerms(): Promise<Terms>;
40
53
  updateLoggedInUser(user: Partial<User>): Promise<User>;
41
54
  getAuthProviders(): Promise<AuthProviderInfo[]>;
42
55
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
43
- updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<void>;
56
+ updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
44
57
  deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
45
58
  getBranding(): Promise<Branding>;
46
59
  getConfiguration(): Promise<Configuration>;
47
60
  getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
61
+ getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
48
62
  /**
49
63
  * @deprecated
50
64
  */
@@ -76,8 +90,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
76
90
  updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
77
91
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
78
92
  watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
79
- watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
80
93
  isPrebuildDone(pwsid: string): Promise<boolean>;
94
+ getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
81
95
 
82
96
  // Workspace timeout
83
97
  setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
@@ -91,19 +105,44 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
91
105
  openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
92
106
  closePort(workspaceId: string, port: number): Promise<void>;
93
107
 
94
- // User messages
95
- getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
96
- updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
97
-
98
108
  // User storage
99
109
  getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
100
110
  updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
101
111
 
102
- // user env vars
112
+ // User env vars
103
113
  getEnvVars(): Promise<UserEnvVarValue[]>;
114
+ getAllEnvVars(): Promise<UserEnvVarValue[]>;
104
115
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
105
116
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
106
117
 
118
+ // Teams
119
+ getTeams(): Promise<Team[]>;
120
+ getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
121
+ createTeam(name: string): Promise<Team>;
122
+ joinTeam(inviteId: string): Promise<Team>;
123
+ setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
124
+ removeTeamMember(teamId: string, userId: string): Promise<void>;
125
+ getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
126
+ resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
127
+ deleteTeam(teamId: string, userId: string): Promise<void>;
128
+
129
+ // Projects
130
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
131
+ createProject(params: CreateProjectParams): Promise<Project>;
132
+ deleteProject(projectId: string): Promise<void>;
133
+ getTeamProjects(teamId: string): Promise<Project[]>;
134
+ getUserProjects(): Promise<Project[]>;
135
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
136
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
137
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
138
+ cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
139
+ fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
140
+ guessProjectConfiguration(projectId: string): Promise<string | undefined>;
141
+ fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
142
+ guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
143
+ setProjectConfiguration(projectId: string, configString: string): Promise<void>;
144
+ updateProjectPartial(partialProject: PartialProject): Promise<void>;
145
+
107
146
  // content service
108
147
  getContentBlobUploadUrl(name: string): Promise<string>
109
148
  getContentBlobDownloadUrl(name: string): Promise<string>
@@ -118,10 +157,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
118
157
  registerGithubApp(installationId: string): Promise<void>;
119
158
 
120
159
  /**
121
- * Stores a new snapshot for the given workspace and bucketId
160
+ * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
122
161
  * @return the snapshot id
123
162
  */
124
163
  takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
164
+ /**
165
+ *
166
+ * @param snapshotId
167
+ */
168
+ waitForSnapshot(snapshotId: string): Promise<void>;
125
169
 
126
170
  /**
127
171
  * Returns the list of snapshots that exist for a workspace.
@@ -146,6 +190,95 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
146
190
  resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
147
191
  installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
148
192
  uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
193
+
194
+ guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
195
+
196
+ /**
197
+ * gitpod.io concerns
198
+ */
199
+ isStudent(): Promise<boolean>;
200
+ /**
201
+ *
202
+ */
203
+ getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
204
+ getRemainingUsageHours(): Promise<number>;
205
+
206
+ /**
207
+ *
208
+ */
209
+ getChargebeeSiteId(): Promise<string>;
210
+ createPortalSession(): Promise<{}>;
211
+ checkout(planId: string, planQuantity?: number): Promise<{}>;
212
+ getAvailableCoupons(): Promise<PlanCoupon[]>;
213
+ getAppliedCoupons(): Promise<PlanCoupon[]>;
214
+
215
+ getShowPaymentUI(): Promise<boolean>;
216
+ isChargebeeCustomer(): Promise<boolean>;
217
+
218
+ subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
219
+ subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
220
+ subscriptionCancel(subscriptionId: string): Promise<void>;
221
+ subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
222
+
223
+ tsGet(): Promise<TeamSubscription[]>;
224
+ tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
225
+ tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
226
+ tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
227
+ tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string | undefined): Promise<void>
228
+ tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
229
+ tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
230
+ tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
231
+
232
+ getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
233
+
234
+ /**
235
+ * Analytics
236
+ */
237
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
238
+ trackLocation(event: RemotePageMessage): Promise<void>;
239
+ identifyUser(event: RemoteIdentifyMessage): Promise<void>;
240
+ }
241
+
242
+ export interface CreateProjectParams {
243
+ name: string;
244
+ slug?: string;
245
+ account: string;
246
+ provider: string;
247
+ cloneUrl: string;
248
+ teamId?: string;
249
+ userId?: string;
250
+ appInstallationId: string;
251
+ }
252
+ export interface FindPrebuildsParams {
253
+ projectId: string;
254
+ branch?: string;
255
+ latest?: boolean;
256
+ prebuildId?: string;
257
+ // default: 30
258
+ limit?: number;
259
+ }
260
+ export interface GetProviderRepositoriesParams {
261
+ provider: string;
262
+ hints?: { installationId: string } | object;
263
+ }
264
+ export interface ProviderRepository {
265
+ name: string;
266
+ path?: string;
267
+ account: string;
268
+ accountAvatarUrl: string;
269
+ cloneUrl: string;
270
+ updatedAt: string;
271
+ installationId?: number;
272
+ installationUpdatedAt?: string;
273
+
274
+ inUse?: { userName: string };
275
+ }
276
+
277
+ export interface ClientHeaderFields {
278
+ ip?: string;
279
+ userAgent?: string;
280
+ dnt?: string;
281
+ clientRegion?: string;
149
282
  }
150
283
 
151
284
  export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
@@ -158,6 +291,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
158
291
  methods.setClient = methods.setClient || (() => { });
159
292
  methods.dispose = methods.dispose || (() => { });
160
293
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
294
+ // @ts-ignore
161
295
  get: (target: S, property: keyof S) => {
162
296
  const result = target[property];
163
297
  if (!result) {
@@ -190,6 +324,8 @@ export namespace GitpodServer {
190
324
  limit?: number;
191
325
  searchString?: string;
192
326
  pinnedOnly?: boolean;
327
+ projectId?: string | string[];
328
+ includeWithoutProject?: boolean;
193
329
  }
194
330
  export interface GetAccountStatementOptions {
195
331
  date?: string;
@@ -197,6 +333,7 @@ export namespace GitpodServer {
197
333
  export interface CreateWorkspaceOptions {
198
334
  contextUrl: string;
199
335
  mode?: CreateWorkspaceMode;
336
+ forceDefaultConfig?: boolean;
200
337
  }
201
338
  export interface StartWorkspaceOptions {
202
339
  forceDefaultImage: boolean;
@@ -204,13 +341,8 @@ export namespace GitpodServer {
204
341
  export interface TakeSnapshotOptions {
205
342
  workspaceId: string;
206
343
  layoutData?: string;
207
- }
208
- export interface GetUserMessagesOptions {
209
- readonly releaseNotes?: boolean;
210
- readonly workspaceInstanceId: string;
211
- }
212
- export interface UpdateUserMessagesOptions {
213
- readonly messageIds: string[];
344
+ /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
345
+ dontWait?: boolean;
214
346
  }
215
347
  export interface GetUserStorageResourceOptions {
216
348
  readonly uri: string;
@@ -272,11 +404,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
272
404
  }
273
405
  }
274
406
 
275
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
407
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
276
408
  for (const client of this.clients) {
277
- if (client.onWorkspaceImageBuildLogs) {
409
+ if (client.onPrebuildUpdate) {
278
410
  try {
279
- client.onWorkspaceImageBuildLogs(info, content);
411
+ client.onPrebuildUpdate(update);
280
412
  } catch (error) {
281
413
  console.error(error)
282
414
  }
@@ -284,11 +416,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
284
416
  }
285
417
  }
286
418
 
287
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
419
+ onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
288
420
  for (const client of this.clients) {
289
- if (client.onHeadlessWorkspaceLogs) {
421
+ if (client.onWorkspaceImageBuildLogs) {
290
422
  try {
291
- client.onHeadlessWorkspaceLogs(evt);
423
+ client.onWorkspaceImageBuildLogs(info, content);
292
424
  } catch (error) {
293
425
  console.error(error)
294
426
  }
@@ -320,6 +452,18 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
320
452
  }
321
453
  }
322
454
 
455
+ onCreditAlert(creditAlert: CreditAlert): void {
456
+ for (const client of this.clients) {
457
+ if (client.onCreditAlert) {
458
+ try {
459
+ client.onCreditAlert(creditAlert);
460
+ } catch (error) {
461
+ console.error(error)
462
+ }
463
+ }
464
+ }
465
+ }
466
+
323
467
  }
324
468
 
325
469
  export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
@@ -340,7 +484,7 @@ export class WorkspaceInstanceUpdateListener {
340
484
  private readonly onDidChangeEmitter = new Emitter<void>();
341
485
  readonly onDidChange = this.onDidChangeEmitter.event;
342
486
 
343
- private source: 'sync' | 'update' = 'sync';
487
+ private source: 'sync' | 'update' = 'sync';
344
488
 
345
489
  get info(): WorkspaceInfo {
346
490
  return this._info;
@@ -432,11 +576,15 @@ export class WorkspaceInstanceUpdateListener {
432
576
 
433
577
  }
434
578
 
579
+ export interface GitpodServiceOptions {
580
+ onReconnect?: () => (void | Promise<void>)
581
+ }
582
+
435
583
  export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
436
584
 
437
585
  private readonly compositeClient = new GitpodCompositeClient<Client>();
438
586
 
439
- constructor(public readonly server: JsonRpcProxy<Server>) {
587
+ constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
440
588
  server.setClient(this.compositeClient);
441
589
  server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
442
590
  server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
@@ -456,13 +604,34 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
456
604
  this.instanceListeners.set(workspaceId, listener);
457
605
  return listener;
458
606
  }
607
+
608
+ async reconnect(): Promise<void> {
609
+ if (this.options?.onReconnect) {
610
+ await this.options.onReconnect();
611
+ }
612
+ }
459
613
  }
460
614
 
461
- export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string) {
462
- const url = new GitpodHostUrl(serverUrl)
463
- .asWebsocket()
464
- .withApi({ pathname: GitpodServerPath });
615
+ export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
616
+ const toWsUrl = (serverUrl: string) => {
617
+ return new GitpodHostUrl(serverUrl)
618
+ .asWebsocket()
619
+ .withApi({ pathname: GitpodServerPath })
620
+ .toString();
621
+ };
622
+ let url: string | Promise<string>;
623
+ if (typeof serverUrl === "string") {
624
+ url = toWsUrl(serverUrl);
625
+ } else {
626
+ url = serverUrl.then(url => toWsUrl(url));
627
+ }
628
+
465
629
  const connectionProvider = new WebSocketConnectionProvider();
466
- const gitpodServer = connectionProvider.createProxy<S>(url.toString());
467
- return new GitpodServiceImpl<C, S>(gitpodServer);
630
+ let onReconnect = () => { };
631
+ const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
632
+ onListening: socket => {
633
+ onReconnect = () => socket.reconnect();
634
+ }
635
+ });
636
+ return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
468
637
  }
@@ -4,39 +4,11 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
-
8
- export enum HeadlessWorkspaceEventType {
9
- LogOutput = "log-output",
10
- FinishedSuccessfully = "finish-success",
11
- FinishedButFailed = "finish-fail",
12
- AbortedTimedOut = "aborted-timeout",
13
- Aborted = "aborted",
14
- Started = "started"
15
- }
16
- export namespace HeadlessWorkspaceEventType {
17
- export function isRunning(t: HeadlessWorkspaceEventType) {
18
- return t === HeadlessWorkspaceEventType.LogOutput;
19
- }
20
- export function didFinish(t: HeadlessWorkspaceEventType) {
21
- return t === HeadlessWorkspaceEventType.FinishedButFailed || t === HeadlessWorkspaceEventType.FinishedSuccessfully;
22
- }
23
- }
24
-
25
- export interface HeadlessLogEvent {
26
- workspaceID: string;
27
- text: string;
28
- type: HeadlessWorkspaceEventType;
7
+ export interface HeadlessLogUrls {
8
+ // A map of id to URL
9
+ streams: { [streamID: string]: string };
29
10
  }
30
11
 
31
- export enum TheiaHeadlessLogType {
32
- TaskLogLabel = "workspaceTaskOutput",
33
- TaskFailedLabel = "workspaceTaskFailed",
34
- TaskSuccessfulLabel = "workspaceTaskDone"
35
- }
36
-
37
- export interface TheiaHeadlessLogMessage {
38
- type: TheiaHeadlessLogType;
39
- data?: string;
40
- error?: string;
41
- snapshotURL?: string;
42
- }
12
+ /** cmp. @const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX */
13
+ export const HEADLESS_LOG_STREAM_STATUS_CODE = "X-LogStream-StatusCode";
14
+ export const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX = /X-LogStream-StatusCode: ([0-9]{3})/;