@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.
- package/data/gitpod-schema.json +9 -2
- package/lib/accounting-protocol.d.ts +3 -6
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +10 -16
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +9 -4
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +2 -13
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +13 -2
- package/lib/analytics.d.ts.map +1 -1
- package/lib/analytics.js.map +1 -1
- package/lib/context-url.js +4 -4
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.js +45 -48
- package/lib/context-url.spec.js.map +1 -1
- package/lib/email-protocol.d.ts +1 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.js +4 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +20 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +58 -20
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +149 -295
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +2 -13
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +1 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +81 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +8 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +3 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +172 -35
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/connection-error-handler.js +11 -23
- package/lib/messaging/connection-error-handler.js.map +1 -1
- package/lib/messaging/error.d.ts +2 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +4 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/node/connection.d.ts +0 -10
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +12 -50
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -159
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/permission.d.ts +1 -2
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +12 -13
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +1 -1
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +38 -57
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +44 -94
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +57 -114
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +2 -3
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +13 -13
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +110 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +23 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +35 -26
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.js +55 -133
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +8 -8
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +26 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +28 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +56 -78
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +93 -103
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +87 -135
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/util/{without.js → jaeger-client-types.js} +1 -1
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +49 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +107 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +31 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +144 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/safe-promise.js +9 -12
- package/lib/util/safe-promise.js.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +16 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +50 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +175 -63
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.js +2 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +12 -3
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +3 -3
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +5 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.js +1 -1
- package/package.json +24 -13
- package/pkg-yarn.lock +14 -7
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +4 -10
- package/src/admin-protocol.ts +10 -5
- package/src/analytics.ts +16 -2
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +74 -31
- package/src/headless-workspace-log.ts +2 -15
- package/src/ide-protocol.ts +92 -0
- package/src/index.ts +3 -0
- package/src/messaging/browser/connection.ts +176 -10
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +5 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +3 -47
- package/src/messaging/proxy-factory.ts +13 -5
- package/src/oss-allowlist.ts +15 -0
- package/src/permission.ts +0 -1
- package/src/protocol.ts +61 -105
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +3 -4
- package/src/teams-projects-protocol.ts +141 -0
- package/src/util/analytics.ts +17 -1
- package/src/util/garbage-collected-cache.ts +7 -1
- package/src/util/generate-workspace-id.spec.ts +16 -0
- package/src/util/generate-workspace-id.ts +19 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.ts +10 -10
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +102 -38
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/repeat.ts +45 -0
- package/src/util/tracing.spec.ts +83 -0
- package/src/util/tracing.ts +162 -18
- package/src/workspace-cluster.ts +9 -3
- package/src/workspace-instance.ts +15 -6
- package/src/wsready.ts +1 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js.map +0 -1
- package/src/util/jaeger-client.d.ts +0 -105
- 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
|
+
}
|
package/src/messaging/error.ts
CHANGED
|
@@ -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
|
-
//
|
|
77
|
-
export const
|
|
79
|
+
// 630 Snapshot Error
|
|
80
|
+
export const SNAPSHOT_ERROR = 630;
|
|
78
81
|
}
|
package/src/messaging/handler.ts
CHANGED
|
@@ -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 {
|
|
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.
|
|
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('
|
|
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
|
-
|
|
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]
|
|
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
|
-
|
|
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]:
|
|
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 {
|
|
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:
|
|
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:
|
|
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;
|