@gitpod/gitpod-protocol 0.1.5-prs-loadgen-update.1 → 0.1.5-prs-test-dazzle-rewrite.22

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 (255) hide show
  1. package/data/gitpod-schema.json +9 -2
  2. package/lib/accounting-protocol.d.ts +3 -6
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +10 -16
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +9 -4
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +13 -2
  11. package/lib/analytics.d.ts.map +1 -1
  12. package/lib/analytics.js.map +1 -1
  13. package/lib/context-url.js +4 -4
  14. package/lib/context-url.js.map +1 -1
  15. package/lib/context-url.spec.js +45 -48
  16. package/lib/context-url.spec.js.map +1 -1
  17. package/lib/email-protocol.d.ts +1 -2
  18. package/lib/email-protocol.d.ts.map +1 -1
  19. package/lib/email-protocol.js +4 -4
  20. package/lib/email-protocol.js.map +1 -1
  21. package/lib/encryption/container-module.js +4 -4
  22. package/lib/encryption/container-module.js.map +1 -1
  23. package/lib/encryption/encryption-engine.js +19 -20
  24. package/lib/encryption/encryption-engine.js.map +1 -1
  25. package/lib/encryption/encryption-engine.spec.js +29 -36
  26. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  27. package/lib/encryption/encryption-service.js +29 -43
  28. package/lib/encryption/encryption-service.js.map +1 -1
  29. package/lib/encryption/key-provider.js +25 -30
  30. package/lib/encryption/key-provider.js.map +1 -1
  31. package/lib/env.d.ts +1 -2
  32. package/lib/env.d.ts.map +1 -1
  33. package/lib/env.js +20 -21
  34. package/lib/env.js.map +1 -1
  35. package/lib/gitpod-file-parser.js +25 -41
  36. package/lib/gitpod-file-parser.js.map +1 -1
  37. package/lib/gitpod-file-parser.spec.js +116 -116
  38. package/lib/gitpod-file-parser.spec.js.map +1 -1
  39. package/lib/gitpod-service.d.ts +58 -20
  40. package/lib/gitpod-service.d.ts.map +1 -1
  41. package/lib/gitpod-service.js +149 -295
  42. package/lib/gitpod-service.js.map +1 -1
  43. package/lib/headless-workspace-log.d.ts +2 -13
  44. package/lib/headless-workspace-log.d.ts.map +1 -1
  45. package/lib/headless-workspace-log.js +1 -7
  46. package/lib/headless-workspace-log.js.map +1 -1
  47. package/lib/ide-protocol.d.ts +81 -0
  48. package/lib/ide-protocol.d.ts.map +1 -0
  49. package/lib/ide-protocol.js +8 -0
  50. package/lib/ide-protocol.js.map +1 -0
  51. package/lib/index.d.ts +3 -0
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/index.js +3 -0
  54. package/lib/index.js.map +1 -1
  55. package/lib/messaging/browser/connection.d.ts +3 -3
  56. package/lib/messaging/browser/connection.d.ts.map +1 -1
  57. package/lib/messaging/browser/connection.js +172 -35
  58. package/lib/messaging/browser/connection.js.map +1 -1
  59. package/lib/messaging/browser/window-connection.js +35 -55
  60. package/lib/messaging/browser/window-connection.js.map +1 -1
  61. package/lib/messaging/client-call-metrics.d.ts +35 -0
  62. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  63. package/lib/messaging/client-call-metrics.js +83 -0
  64. package/lib/messaging/client-call-metrics.js.map +1 -0
  65. package/lib/messaging/connection-error-handler.js +11 -23
  66. package/lib/messaging/connection-error-handler.js.map +1 -1
  67. package/lib/messaging/error.d.ts +2 -1
  68. package/lib/messaging/error.d.ts.map +1 -1
  69. package/lib/messaging/error.js +4 -2
  70. package/lib/messaging/error.js.map +1 -1
  71. package/lib/messaging/handler.d.ts +10 -0
  72. package/lib/messaging/handler.d.ts.map +1 -1
  73. package/lib/messaging/node/connection.d.ts +0 -10
  74. package/lib/messaging/node/connection.d.ts.map +1 -1
  75. package/lib/messaging/node/connection.js +12 -50
  76. package/lib/messaging/node/connection.js.map +1 -1
  77. package/lib/messaging/proxy-factory.d.ts +2 -0
  78. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  79. package/lib/messaging/proxy-factory.js +74 -159
  80. package/lib/messaging/proxy-factory.js.map +1 -1
  81. package/lib/oss-allowlist.d.ts +14 -0
  82. package/lib/oss-allowlist.d.ts.map +1 -0
  83. package/lib/oss-allowlist.js +8 -0
  84. package/lib/oss-allowlist.js.map +1 -0
  85. package/lib/permission.d.ts +1 -2
  86. package/lib/permission.d.ts.map +1 -1
  87. package/lib/permission.js +12 -13
  88. package/lib/permission.js.map +1 -1
  89. package/lib/plans.d.ts +1 -1
  90. package/lib/plans.d.ts.map +1 -1
  91. package/lib/plans.js +38 -57
  92. package/lib/plans.js.map +1 -1
  93. package/lib/protocol.d.ts +44 -94
  94. package/lib/protocol.d.ts.map +1 -1
  95. package/lib/protocol.js +57 -114
  96. package/lib/protocol.js.map +1 -1
  97. package/lib/snapshot-url.d.ts +14 -0
  98. package/lib/snapshot-url.d.ts.map +1 -0
  99. package/lib/snapshot-url.js +26 -0
  100. package/lib/snapshot-url.js.map +1 -0
  101. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  102. package/lib/snapshot-url.spec.d.ts.map +1 -0
  103. package/lib/snapshot-url.spec.js +41 -0
  104. package/lib/snapshot-url.spec.js.map +1 -0
  105. package/lib/team-subscription-protocol.d.ts +2 -3
  106. package/lib/team-subscription-protocol.d.ts.map +1 -1
  107. package/lib/team-subscription-protocol.js +13 -13
  108. package/lib/team-subscription-protocol.js.map +1 -1
  109. package/lib/teams-projects-protocol.d.ts +110 -0
  110. package/lib/teams-projects-protocol.d.ts.map +1 -0
  111. package/lib/teams-projects-protocol.js +23 -0
  112. package/lib/teams-projects-protocol.js.map +1 -0
  113. package/lib/util/analytics.d.ts.map +1 -1
  114. package/lib/util/analytics.js +35 -26
  115. package/lib/util/analytics.js.map +1 -1
  116. package/lib/util/async-iterator.js +55 -133
  117. package/lib/util/async-iterator.js.map +1 -1
  118. package/lib/util/cancelable.js +17 -59
  119. package/lib/util/cancelable.js.map +1 -1
  120. package/lib/util/date-time.js +8 -8
  121. package/lib/util/date-time.js.map +1 -1
  122. package/lib/util/deferred.js +10 -12
  123. package/lib/util/deferred.js.map +1 -1
  124. package/lib/util/disposable.js +26 -39
  125. package/lib/util/disposable.js.map +1 -1
  126. package/lib/util/event.js +58 -74
  127. package/lib/util/event.js.map +1 -1
  128. package/lib/util/garbage-collected-cache.d.ts +1 -0
  129. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  130. package/lib/util/garbage-collected-cache.js +26 -46
  131. package/lib/util/garbage-collected-cache.js.map +1 -1
  132. package/lib/util/generate-workspace-id.d.ts +1 -1
  133. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  134. package/lib/util/generate-workspace-id.js +28 -68
  135. package/lib/util/generate-workspace-id.js.map +1 -1
  136. package/lib/util/generate-workspace-id.spec.js +56 -78
  137. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  138. package/lib/util/gitpod-cookie.d.ts +20 -0
  139. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  140. package/lib/util/gitpod-cookie.js +44 -0
  141. package/lib/util/gitpod-cookie.js.map +1 -0
  142. package/lib/util/gitpod-host-url.d.ts +1 -1
  143. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  144. package/lib/util/gitpod-host-url.js +93 -103
  145. package/lib/util/gitpod-host-url.js.map +1 -1
  146. package/lib/util/gitpod-host-url.spec.js +87 -135
  147. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  148. package/lib/util/grpc.d.ts +15 -0
  149. package/lib/util/grpc.d.ts.map +1 -0
  150. package/lib/util/grpc.js +18 -0
  151. package/lib/util/grpc.js.map +1 -0
  152. package/lib/util/jaeger-client-types.d.ts +68 -0
  153. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  154. package/lib/util/{without.js → jaeger-client-types.js} +1 -1
  155. package/lib/util/jaeger-client-types.js.map +1 -0
  156. package/lib/util/logging.d.ts +49 -33
  157. package/lib/util/logging.d.ts.map +1 -1
  158. package/lib/util/logging.js +107 -110
  159. package/lib/util/logging.js.map +1 -1
  160. package/lib/util/make-link.js +2 -2
  161. package/lib/util/make-link.js.map +1 -1
  162. package/lib/util/parse-workspace-id.d.ts +10 -0
  163. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  164. package/lib/util/parse-workspace-id.js +31 -7
  165. package/lib/util/parse-workspace-id.js.map +1 -1
  166. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  167. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  168. package/lib/util/parse-workspace-id.spec.js +123 -84
  169. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  170. package/lib/util/queue.js +16 -55
  171. package/lib/util/queue.js.map +1 -1
  172. package/lib/util/queue.spec.js +144 -288
  173. package/lib/util/queue.spec.js.map +1 -1
  174. package/lib/util/repeat.d.ts +15 -0
  175. package/lib/util/repeat.d.ts.map +1 -0
  176. package/lib/util/repeat.js +55 -0
  177. package/lib/util/repeat.js.map +1 -0
  178. package/lib/util/safe-promise.js +9 -12
  179. package/lib/util/safe-promise.js.map +1 -1
  180. package/lib/util/semaphore.js +15 -46
  181. package/lib/util/semaphore.js.map +1 -1
  182. package/lib/util/skip-if.js +6 -6
  183. package/lib/util/skip-if.js.map +1 -1
  184. package/lib/util/timeutil.js +16 -16
  185. package/lib/util/timeutil.js.map +1 -1
  186. package/lib/util/timeutil.spec.js +21 -24
  187. package/lib/util/timeutil.spec.js.map +1 -1
  188. package/lib/util/tracing.d.ts +50 -5
  189. package/lib/util/tracing.d.ts.map +1 -1
  190. package/lib/util/tracing.js +175 -63
  191. package/lib/util/tracing.js.map +1 -1
  192. package/lib/util/tracing.spec.d.ts +7 -0
  193. package/lib/util/tracing.spec.d.ts.map +1 -0
  194. package/lib/util/tracing.spec.js +121 -0
  195. package/lib/util/tracing.spec.js.map +1 -0
  196. package/lib/util/workspace-port-authentication.js +2 -2
  197. package/lib/util/workspace-port-authentication.js.map +1 -1
  198. package/lib/workspace-cluster.d.ts +12 -3
  199. package/lib/workspace-cluster.d.ts.map +1 -1
  200. package/lib/workspace-cluster.js +3 -3
  201. package/lib/workspace-cluster.js.map +1 -1
  202. package/lib/workspace-instance.d.ts +5 -2
  203. package/lib/workspace-instance.d.ts.map +1 -1
  204. package/lib/wsready.js +1 -1
  205. package/package.json +24 -13
  206. package/pkg-yarn.lock +14 -7
  207. package/provenance-bundle.jsonl +2 -0
  208. package/src/accounting-protocol.ts +4 -10
  209. package/src/admin-protocol.ts +10 -5
  210. package/src/analytics.ts +16 -2
  211. package/src/email-protocol.ts +2 -3
  212. package/src/env.ts +10 -10
  213. package/src/gitpod-service.ts +74 -31
  214. package/src/headless-workspace-log.ts +2 -15
  215. package/src/ide-protocol.ts +92 -0
  216. package/src/index.ts +3 -0
  217. package/src/messaging/browser/connection.ts +176 -10
  218. package/src/messaging/client-call-metrics.ts +97 -0
  219. package/src/messaging/error.ts +5 -2
  220. package/src/messaging/handler.ts +12 -0
  221. package/src/messaging/node/connection.ts +3 -47
  222. package/src/messaging/proxy-factory.ts +13 -5
  223. package/src/oss-allowlist.ts +15 -0
  224. package/src/permission.ts +0 -1
  225. package/src/protocol.ts +61 -105
  226. package/src/snapshot-url.spec.ts +25 -0
  227. package/src/snapshot-url.ts +27 -0
  228. package/src/team-subscription-protocol.ts +3 -4
  229. package/src/teams-projects-protocol.ts +141 -0
  230. package/src/util/analytics.ts +17 -1
  231. package/src/util/garbage-collected-cache.ts +7 -1
  232. package/src/util/generate-workspace-id.spec.ts +16 -0
  233. package/src/util/generate-workspace-id.ts +19 -2
  234. package/src/util/gitpod-cookie.ts +39 -0
  235. package/src/util/gitpod-host-url.ts +10 -10
  236. package/src/util/grpc.ts +15 -0
  237. package/src/util/jaeger-client-types.ts +102 -0
  238. package/src/util/logging.ts +102 -38
  239. package/src/util/parse-workspace-id.spec.ts +21 -1
  240. package/src/util/parse-workspace-id.ts +32 -6
  241. package/src/util/repeat.ts +45 -0
  242. package/src/util/tracing.spec.ts +83 -0
  243. package/src/util/tracing.ts +162 -18
  244. package/src/workspace-cluster.ts +9 -3
  245. package/src/workspace-instance.ts +15 -6
  246. package/src/wsready.ts +1 -1
  247. package/lib/util/repeater.d.ts +0 -22
  248. package/lib/util/repeater.d.ts.map +0 -1
  249. package/lib/util/repeater.js +0 -118
  250. package/lib/util/repeater.js.map +0 -1
  251. package/lib/util/without.d.ts +0 -7
  252. package/lib/util/without.d.ts.map +0 -1
  253. package/lib/util/without.js.map +0 -1
  254. package/src/util/jaeger-client.d.ts +0 -105
  255. package/src/util/repeater.ts +0 -49
@@ -0,0 +1,97 @@
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 { injectable } from 'inversify';
8
+ import * as prometheusClient from 'prom-client';
9
+
10
+ type GrpcMethodType = 'unary' | 'client_stream' | 'server_stream' | 'bidi_stream';
11
+ export interface IGrpcCallMetricsLabels {
12
+ service: string,
13
+ method: string,
14
+ type: GrpcMethodType,
15
+ }
16
+
17
+ export interface IGrpcCallMetricsLabelsWithCode extends IGrpcCallMetricsLabels {
18
+ code: string
19
+ }
20
+
21
+ export const IClientCallMetrics = Symbol("IClientCallMetrics");
22
+
23
+ export interface IClientCallMetrics {
24
+ started(labels: IGrpcCallMetricsLabels) : void;
25
+ sent(labels: IGrpcCallMetricsLabels) : void;
26
+ received(labels: IGrpcCallMetricsLabels) : void;
27
+ handled(labels: IGrpcCallMetricsLabelsWithCode) : void;
28
+ }
29
+
30
+ @injectable()
31
+ export class PrometheusClientCallMetrics implements IClientCallMetrics {
32
+
33
+ readonly startedCounter: prometheusClient.Counter<string>;
34
+ readonly sentCounter: prometheusClient.Counter<string>;
35
+ readonly receivedCounter: prometheusClient.Counter<string>;
36
+ readonly handledCounter: prometheusClient.Counter<string>;
37
+
38
+ constructor() {
39
+ this.startedCounter = new prometheusClient.Counter({
40
+ name: 'grpc_client_started_total',
41
+ help: 'Total number of RPCs started on the client.',
42
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
43
+ registers: [prometheusClient.register]
44
+ });
45
+ this.sentCounter = new prometheusClient.Counter({
46
+ name: 'grpc_client_msg_sent_total',
47
+ help: ' Total number of gRPC stream messages sent by the client.',
48
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
49
+ registers: [prometheusClient.register]
50
+ });
51
+ this.receivedCounter = new prometheusClient.Counter({
52
+ name: 'grpc_client_msg_received_total',
53
+ help: 'Total number of RPC stream messages received by the client.',
54
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
55
+ registers: [prometheusClient.register]
56
+ });
57
+ this.handledCounter = new prometheusClient.Counter({
58
+ name: 'grpc_client_handled_total',
59
+ help: 'Total number of RPCs completed by the client, regardless of success or failure.',
60
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type', 'grpc_code'],
61
+ registers: [prometheusClient.register]
62
+ });
63
+ }
64
+
65
+ started(labels: IGrpcCallMetricsLabels): void {
66
+ this.startedCounter.inc({
67
+ grpc_service: labels.service,
68
+ grpc_method: labels.method,
69
+ grpc_type: labels.type
70
+ });
71
+ }
72
+
73
+ sent(labels: IGrpcCallMetricsLabels): void {
74
+ this.sentCounter.inc({
75
+ grpc_service: labels.service,
76
+ grpc_method: labels.method,
77
+ grpc_type: labels.type
78
+ });
79
+ }
80
+
81
+ received(labels: IGrpcCallMetricsLabels): void {
82
+ this.receivedCounter.inc({
83
+ grpc_service: labels.service,
84
+ grpc_method: labels.method,
85
+ grpc_type: labels.type
86
+ });
87
+ }
88
+
89
+ handled(labels: IGrpcCallMetricsLabelsWithCode): void {
90
+ this.handledCounter.inc({
91
+ grpc_service: labels.service,
92
+ grpc_method: labels.method,
93
+ grpc_type: labels.type,
94
+ grpc_code: labels.code
95
+ });
96
+ }
97
+ }
@@ -34,6 +34,9 @@ export namespace ErrorCodes {
34
34
  // 460 Context Parse Error (custom status code)
35
35
  export const CONTEXT_PARSE_ERROR = 460;
36
36
 
37
+ // 461 Invalid gitpod yml
38
+ export const INVALID_GITPOD_YML = 461;
39
+
37
40
  // 450 Payment error
38
41
  export const PAYMENT_ERROR = 450;
39
42
 
@@ -73,6 +76,6 @@ export namespace ErrorCodes {
73
76
  // 620 Team Subscription Assignment Failed
74
77
  export const TEAM_SUBSCRIPTION_ASSIGNMENT_FAILED = 620;
75
78
 
76
- // 666 Not Implemented TODO IO-SPLIT remove
77
- export const NOT_IMPLEMENTED = 666;
79
+ // 630 Snapshot Error
80
+ export const SNAPSHOT_ERROR = 630;
78
81
  }
@@ -13,3 +13,15 @@ export interface ConnectionHandler {
13
13
  readonly path: string;
14
14
  onConnection(connection: MessageConnection, session?: object): void;
15
15
  }
16
+
17
+ export interface ConnectionEventHandler {
18
+ /**
19
+ * Called when the transport underpinning the connection got closed
20
+ */
21
+ onTransportDidClose(): void;
22
+
23
+ /**
24
+ * Called when the transport underpinning the connection is (re-)opened
25
+ */
26
+ onTransportDidOpen(): void;
27
+ }
@@ -7,71 +7,27 @@
7
7
 
8
8
  import * as ws from "ws";
9
9
  import * as http from "http";
10
- import * as https from "https";
11
- import * as url from "url";
12
10
  import * as net from "net";
13
- import { MessageConnection } from "vscode-jsonrpc";
14
- import { createWebSocketConnection, IWebSocket } from "vscode-ws-jsonrpc";
11
+ import { IWebSocket } from "vscode-ws-jsonrpc";
15
12
  import { log } from '../../util/logging';
16
13
 
17
- export interface IServerOptions {
18
- readonly server: http.Server | https.Server;
19
- readonly path?: string;
20
- matches?(request: http.IncomingMessage): boolean;
21
- }
22
-
23
- export function createServerWebSocketConnection(options: IServerOptions, onConnect: (connection: MessageConnection) => void): void {
24
- openJsonRpcSocket(options, socket => {
25
- onConnect(createWebSocketConnection(socket, console));
26
- });
27
- }
28
-
29
- export function openJsonRpcSocket(options: IServerOptions, onOpen: (socket: IWebSocket) => void): void {
30
- openSocket(options, socket => {
31
- const webSocket = toIWebSocket(socket);
32
- onOpen(webSocket);
33
- });
34
- }
35
-
36
14
  export interface OnOpen {
37
15
  (webSocket: ws, request: http.IncomingMessage, socket: net.Socket, head: Buffer): void;
38
16
  }
39
17
 
40
- export function openSocket(options: IServerOptions, onOpen: OnOpen): void {
41
- const wss = new ws.Server({
42
- noServer: true,
43
- perMessageDeflate: {
44
- // don't compress if a message is less than 256kb
45
- threshold: 256 * 1024
46
- }
47
- });
48
- options.server.on('upgrade', (request: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
49
- const pathname = request.url ? url.parse(request.url).pathname : undefined;
50
- if (options.path && pathname === options.path || options.matches && options.matches(request)) {
51
- wss.handleUpgrade(request, socket, head, webSocket => {
52
- if (webSocket.readyState === webSocket.OPEN) {
53
- onOpen(webSocket, request, socket, head);
54
- } else {
55
- webSocket.on('open', () => onOpen(webSocket, request, socket, head));
56
- }
57
- });
58
- }
59
- });
60
- }
61
-
62
18
  export function toIWebSocket(webSocket: ws) {
63
19
  let sendsAfterOpen = 0;
64
20
  return <IWebSocket>{
65
21
  send: content => {
66
22
  if (webSocket.readyState !== ws.OPEN) {
67
23
  if (sendsAfterOpen++ > 3) {
68
- log.error(`Repeated try to send on closed web socket (readyState was ${webSocket.readyState})`, { ws });
24
+ //log.debug(`Repeated try to send on closed web socket (readyState was ${webSocket.readyState})`, { ws });
69
25
  }
70
26
  return;
71
27
  }
72
28
  webSocket.send(content, err => {
73
29
  if (err) {
74
- log.error('Error in ws.send()', err, { ws });
30
+ log.error('error in ws.send()', err, { ws });
75
31
  }
76
32
  })
77
33
  },
@@ -105,13 +105,19 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
105
105
  this.connectionPromiseResolve = resolve
106
106
  );
107
107
  this.connectionPromise.then(connection => {
108
- connection.onClose(() =>
109
- this.onDidCloseConnectionEmitter.fire(undefined)
110
- );
111
- this.onDidOpenConnectionEmitter.fire(undefined);
108
+ connection.onClose(() => this.fireConnectionClosed());
109
+ this.fireConnectionOpened();
112
110
  });
113
111
  }
114
112
 
113
+ fireConnectionClosed() {
114
+ this.onDidCloseConnectionEmitter.fire(undefined)
115
+ }
116
+
117
+ fireConnectionOpened() {
118
+ this.onDidOpenConnectionEmitter.fire(undefined);
119
+ }
120
+
115
121
  /**
116
122
  * Connect a MessageConnection to the factory.
117
123
  *
@@ -158,7 +164,9 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
158
164
  * methods calls.
159
165
  */
160
166
  protected onNotification(method: string, ...args: any[]): void {
161
- this.target[method](...args);
167
+ if (this.target[method]) {
168
+ this.target[method](...args);
169
+ }
162
170
  }
163
171
 
164
172
  /**
@@ -0,0 +1,15 @@
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 OssAllowList {
8
+ /**
9
+ * A string that identifies a GitHub/GitLab/Bitbucket identity of the form "<host>/<profilename>"
10
+ * E.g., "github.com/geropl"
11
+ */
12
+ identity: string,
13
+
14
+ deleted?: boolean,
15
+ }
package/src/permission.ts CHANGED
@@ -16,7 +16,6 @@ export const Permissions = {
16
16
  "admin-api": undefined,
17
17
  "ide-settings": undefined,
18
18
  "new-workspace-cluster": undefined,
19
- "teams-and-projects": undefined,
20
19
  };
21
20
  export type PermissionName = keyof (typeof Permissions);
22
21
  export const Roles = {"devops": undefined, "viewer": undefined, "admin": undefined };
package/src/protocol.ts CHANGED
@@ -6,6 +6,7 @@
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
11
  export interface UserInfo {
11
12
  name?: string
@@ -27,8 +28,6 @@ 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.
@@ -105,14 +104,21 @@ export interface AdditionalUserData {
105
104
  oauthClientsApproved?: { [key: string]: string }
106
105
  // to remember GH Orgs the user installed/updated the GH App for
107
106
  knownGitHubOrgs?: string[];
107
+
108
+ // Git clone URL pointing to the user's dotfile repo
109
+ dotfileRepo?: string;
108
110
  }
109
111
 
110
112
  export interface EmailNotificationSettings {
111
- disallowTransactionalEmails?: boolean;
113
+ allowsChangelogMail?: boolean;
114
+ allowsDevXMail?: boolean;
115
+ allowsOnboardingMail?: boolean;
112
116
  }
113
117
 
114
118
  export type IDESettings = {
115
119
  defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
116
122
  }
117
123
 
118
124
  export interface UserPlatform {
@@ -134,14 +140,6 @@ export interface UserPlatform {
134
140
  }
135
141
 
136
142
  export interface UserFeatureSettings {
137
- /**
138
- * This field is used as marker to grant users a free trial for using private repositories,
139
- * independent of any subscription or Chargebee.
140
- * - it is set when the user uses their first private repo
141
- * - whether the trial is expired or not is juged by the UserService
142
- */
143
- privateRepoTrialStartDate?: string;
144
-
145
143
  /**
146
144
  * Permanent feature flags are added to each and every workspace instance
147
145
  * this user starts.
@@ -377,11 +375,16 @@ export interface PendingGithubEvent {
377
375
  export interface Snapshot {
378
376
  id: string;
379
377
  creationTime: string;
378
+ availableTime?: string;
380
379
  originalWorkspaceId: string;
381
380
  bucketId: string;
382
381
  layoutData?: string;
382
+ state: SnapshotState;
383
+ message?: string;
383
384
  }
384
385
 
386
+ export type SnapshotState = 'pending' | 'available' | 'error';
387
+
385
388
  export interface LayoutData {
386
389
  workspaceId: string;
387
390
  lastUpdatedTime: string;
@@ -394,6 +397,7 @@ export interface Workspace {
394
397
  contextURL: string;
395
398
  description: string;
396
399
  ownerId: string;
400
+ projectId?: string;
397
401
  context: WorkspaceContext;
398
402
  config: WorkspaceConfig;
399
403
 
@@ -557,16 +561,20 @@ export interface WorkspaceConfig {
557
561
  github?: GithubAppConfig;
558
562
  vscode?: VSCodeConfig;
559
563
 
564
+ /** deprecated. Enabled by default **/
565
+ experimentalNetwork?: boolean;
566
+
560
567
  /**
561
568
  * Where the config object originates from.
562
569
  *
563
570
  * repo - from the repository
571
+ * project-db - from the "Project" stored in the database
564
572
  * definitly-gp - from github.com/gitpod-io/definitely-gp
565
573
  * derived - computed based on analyzing the repository
566
574
  * additional-content - config comes from additional content, usually provided through the project's configuration
567
575
  * default - our static catch-all default config
568
576
  */
569
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
577
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
570
578
 
571
579
  /**
572
580
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -679,6 +687,8 @@ export interface PortConfig {
679
687
  port: number;
680
688
  onOpen?: PortOnOpen;
681
689
  visibility?: PortVisibility;
690
+ description?: string;
691
+ name?: string;
682
692
  }
683
693
  export namespace PortConfig {
684
694
  export function is(config: any): config is PortConfig {
@@ -702,7 +712,7 @@ export interface TaskConfig {
702
712
  init?: string;
703
713
  prebuild?: string;
704
714
  command?: string;
705
- env?: { [env: string]: string };
715
+ env?: { [env: string]: any };
706
716
  openIn?: 'bottom' | 'main' | 'left' | 'right';
707
717
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
708
718
  }
@@ -766,6 +776,7 @@ export namespace ExternalImageConfigFile {
766
776
 
767
777
  export interface WorkspaceContext {
768
778
  title: string;
779
+ /** 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. */
769
780
  normalizedContextURL?: string;
770
781
  forceCreateNewWorkspace?: boolean;
771
782
  forceImageBuild?: boolean;
@@ -802,6 +813,29 @@ export namespace WithPrebuild {
802
813
  }
803
814
  }
804
815
 
816
+ /**
817
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
818
+ * and fall back to the built-in configuration.
819
+ */
820
+ export interface WithDefaultConfig {
821
+ withDefaultConfig: true;
822
+ }
823
+
824
+ export namespace WithDefaultConfig {
825
+ export function is(context: any): context is WithDefaultConfig {
826
+ return context
827
+ && 'withDefaultConfig' in context
828
+ && context.withDefaultConfig;
829
+ }
830
+
831
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
832
+ return {
833
+ ...ctx,
834
+ withDefaultConfig: true
835
+ }
836
+ }
837
+ }
838
+
805
839
  export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
806
840
  snapshotId: string;
807
841
  }
@@ -888,7 +922,7 @@ export interface Commit {
888
922
  refType?: RefType
889
923
  }
890
924
 
891
- export interface AdditionalContentContext {
925
+ export interface AdditionalContentContext extends WorkspaceContext {
892
926
 
893
927
  /**
894
928
  * utf-8 encoded contents that will be copied on top of the workspace's filesystem
@@ -982,6 +1016,19 @@ export interface Repository {
982
1016
  parent: Repository
983
1017
  }
984
1018
  }
1019
+ export interface Branch {
1020
+ name: string;
1021
+ commit: CommitInfo;
1022
+ htmlUrl: string;
1023
+ }
1024
+
1025
+ export interface CommitInfo {
1026
+ author: string;
1027
+ sha: string;
1028
+ commitMessage: string;
1029
+ authorAvatarUrl?: string;
1030
+ authorDate?: string;
1031
+ }
985
1032
 
986
1033
  export namespace Repository {
987
1034
  export function fullRepoName(repo: Repository): string {
@@ -1128,39 +1175,6 @@ export namespace AuthProviderEntry {
1128
1175
  }
1129
1176
  }
1130
1177
 
1131
- export interface Branding {
1132
- readonly name: string;
1133
- readonly favicon?: string;
1134
- /** Either including domain OR absolute path (interpreted relative to host URL) */
1135
- readonly logo: string;
1136
- readonly startupLogo: string;
1137
- readonly showProductivityTips: boolean;
1138
- readonly redirectUrlIfNotAuthenticated?: string;
1139
- readonly redirectUrlAfterLogout?: string;
1140
- readonly homepage: string;
1141
- readonly ide?: {
1142
- readonly logo: string;
1143
- readonly showReleaseNotes: boolean;
1144
- readonly helpMenu: Branding.Link[];
1145
- }
1146
- readonly links: {
1147
- readonly header: Branding.Link[];
1148
- readonly footer: Branding.Link[];
1149
- readonly social: Branding.SocialLink[];
1150
- readonly legal: Branding.Link[];
1151
- }
1152
- }
1153
- export namespace Branding {
1154
- export interface Link {
1155
- readonly name: string;
1156
- readonly url: string;
1157
- }
1158
- export interface SocialLink {
1159
- readonly type: string;
1160
- readonly url: string;
1161
- }
1162
- }
1163
-
1164
1178
  export interface Configuration {
1165
1179
  readonly daysBeforeGarbageCollection: number;
1166
1180
  readonly garbageCollectionStartDate: number;
@@ -1201,61 +1215,3 @@ export interface Terms {
1201
1215
  readonly content: string;
1202
1216
  readonly formElements?: object;
1203
1217
  }
1204
-
1205
- export interface Project {
1206
- id: string;
1207
- name: string;
1208
- cloneUrl: string;
1209
- teamId: string;
1210
- appInstallationId: string;
1211
- creationTime: string;
1212
- /** This is a flag that triggers the HARD DELETION of this entity */
1213
- deleted?: boolean;
1214
- }
1215
-
1216
- export interface ProjectInfo extends Project {
1217
- lastPrebuild?: PrebuildInfo;
1218
- }
1219
-
1220
- export interface PrebuildInfo {
1221
- id: string;
1222
- teamId: string;
1223
- project: string;
1224
- cloneUrl: string;
1225
- branch: string;
1226
- startedAt: string;
1227
- startedBy: string;
1228
- status: PrebuiltWorkspaceState;
1229
- }
1230
-
1231
- export interface Team {
1232
- id: string;
1233
- name: string;
1234
- slug: string;
1235
- creationTime: string;
1236
- /** This is a flag that triggers the HARD DELETION of this entity */
1237
- deleted?: boolean;
1238
- }
1239
-
1240
- export type TeamMemberRole = "owner" | "member";
1241
-
1242
- export interface TeamMemberInfo {
1243
- userId: string;
1244
- fullName?: string;
1245
- primaryEmail?: string;
1246
- avatarUrl?: string;
1247
- role: TeamMemberRole;
1248
- memberSince: string;
1249
- }
1250
-
1251
- export interface TeamMembershipInvite {
1252
- id: string;
1253
- teamId: string;
1254
- role: TeamMemberRole;
1255
- creationTime: string;
1256
- invalidationTime: string;
1257
- invitedEmail?: string;
1258
-
1259
- /** This is a flag that triggers the HARD DELETION of this entity */
1260
- deleted?: boolean;
1261
- }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { suite, test } from "mocha-typescript"
8
+ import * as chai from "chai"
9
+ import { SnapshotUrl } from ".";
10
+
11
+ const expect = chai.expect
12
+
13
+ @suite class TestSnapshotUrlParser {
14
+
15
+ @test public testPositive() {
16
+ const actual = SnapshotUrl.parse("workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd");
17
+
18
+ expect(actual).to.deep.equal(<SnapshotUrl>{
19
+ bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
20
+ filename: "3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
21
+ fullPath: "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
22
+ });
23
+ }
24
+ }
25
+ module.exports = new TestSnapshotUrlParser() // Only to circumvent no usage warning :-/
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ export interface SnapshotUrl {
8
+ bucketId: string;
9
+ fullPath: string;
10
+ filename: string;
11
+ }
12
+ export namespace SnapshotUrl {
13
+ export function parse(url: string): SnapshotUrl {
14
+ const parts = url.split("@");
15
+ if (parts.length !== 2) {
16
+ throw new Error(`cannot parse snapshot URL: ${url}`);
17
+ }
18
+ const [fullPath, bucketId] = parts;
19
+
20
+ const pathParts = fullPath.split("/");
21
+ if (pathParts.length < 1) {
22
+ throw new Error(`cannot parse snapshot URL: ${url}`);
23
+ }
24
+ const filename = pathParts[pathParts.length - 1];
25
+ return { bucketId, fullPath, filename };
26
+ }
27
+ }
@@ -4,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
  import { Subscription } from "./accounting-protocol";
10
9
 
11
10
  export interface TeamSubscription {
@@ -22,7 +21,7 @@ export interface TeamSubscription {
22
21
  }
23
22
 
24
23
  export namespace TeamSubscription {
25
- export const create = (ts: Without<TeamSubscription, 'id'>): TeamSubscription => {
24
+ export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
26
25
  const withId = ts as TeamSubscription;
27
26
  withId.id = uuidv4();
28
27
  return withId;
@@ -49,7 +48,7 @@ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscripti
49
48
  export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
50
49
 
51
50
  export namespace TeamSubscriptionSlot {
52
- export const create = (ts: Without<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
51
+ export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
53
52
  const withId = ts as TeamSubscriptionSlot;
54
53
  withId.id = uuidv4();
55
54
  return withId;