@gitpod/gitpod-protocol 0.1.5-me-version.1 → 0.1.5-me-ingress.14
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 +11 -4
- 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 +45 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/context-url.d.ts +18 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +49 -0
- package/lib/context-url.js.map +1 -0
- package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +2 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +73 -0
- package/lib/context-url.spec.js.map +1 -0
- 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 +86 -9
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +150 -295
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +8 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +4 -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 +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -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 +50 -48
- 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 +3 -3
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +15 -12
- 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 +1 -26
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +36 -28
- 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 +29 -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 -0
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +96 -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 +54 -0
- package/src/context-url.spec.ts +39 -0
- package/src/context-url.ts +51 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +101 -17
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-protocol.ts +92 -0
- package/src/index.ts +4 -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 +68 -56
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +6 -4
- package/src/teams-projects-protocol.ts +141 -0
- package/src/util/analytics.ts +17 -30
- 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 +20 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.ts +12 -8
- 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 +18 -6
- package/src/wsready.ts +1 -1
- package/lib/util/context-url.d.ts +0 -13
- package/lib/util/context-url.d.ts.map +0 -1
- package/lib/util/context-url.js +0 -26
- package/lib/util/context-url.js.map +0 -1
- package/lib/util/context-url.spec.d.ts.map +0 -1
- package/lib/util/context-url.spec.js +0 -52
- package/lib/util/context-url.spec.js.map +0 -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/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
- 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.
|
|
@@ -103,14 +102,23 @@ export interface AdditionalUserData {
|
|
|
103
102
|
// key is the name of the OAuth client i.e. local app, string the iso date when it was approved
|
|
104
103
|
// TODO(rl): provide a management UX to allow rescinding of approval
|
|
105
104
|
oauthClientsApproved?: { [key: string]: string }
|
|
105
|
+
// to remember GH Orgs the user installed/updated the GH App for
|
|
106
|
+
knownGitHubOrgs?: string[];
|
|
107
|
+
|
|
108
|
+
// Git clone URL pointing to the user's dotfile repo
|
|
109
|
+
dotfileRepo?: string;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
export interface EmailNotificationSettings {
|
|
109
|
-
|
|
113
|
+
allowsChangelogMail?: boolean;
|
|
114
|
+
allowsDevXMail?: boolean;
|
|
115
|
+
allowsOnboardingMail?: boolean;
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
export type IDESettings = {
|
|
113
119
|
defaultIde?: string
|
|
120
|
+
useDesktopIde?: boolean
|
|
121
|
+
defaultDesktopIde?: string
|
|
114
122
|
}
|
|
115
123
|
|
|
116
124
|
export interface UserPlatform {
|
|
@@ -132,14 +140,6 @@ export interface UserPlatform {
|
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
export interface UserFeatureSettings {
|
|
135
|
-
/**
|
|
136
|
-
* This field is used as marker to grant users a free trial for using private repositories,
|
|
137
|
-
* independent of any subscription or Chargebee.
|
|
138
|
-
* - it is set when the user uses their first private repo
|
|
139
|
-
* - whether the trial is expired or not is juged by the UserService
|
|
140
|
-
*/
|
|
141
|
-
privateRepoTrialStartDate?: string;
|
|
142
|
-
|
|
143
143
|
/**
|
|
144
144
|
* Permanent feature flags are added to each and every workspace instance
|
|
145
145
|
* this user starts.
|
|
@@ -375,11 +375,16 @@ export interface PendingGithubEvent {
|
|
|
375
375
|
export interface Snapshot {
|
|
376
376
|
id: string;
|
|
377
377
|
creationTime: string;
|
|
378
|
+
availableTime?: string;
|
|
378
379
|
originalWorkspaceId: string;
|
|
379
380
|
bucketId: string;
|
|
380
381
|
layoutData?: string;
|
|
382
|
+
state: SnapshotState;
|
|
383
|
+
message?: string;
|
|
381
384
|
}
|
|
382
385
|
|
|
386
|
+
export type SnapshotState = 'pending' | 'available' | 'error';
|
|
387
|
+
|
|
383
388
|
export interface LayoutData {
|
|
384
389
|
workspaceId: string;
|
|
385
390
|
lastUpdatedTime: string;
|
|
@@ -392,6 +397,7 @@ export interface Workspace {
|
|
|
392
397
|
contextURL: string;
|
|
393
398
|
description: string;
|
|
394
399
|
ownerId: string;
|
|
400
|
+
projectId?: string;
|
|
395
401
|
context: WorkspaceContext;
|
|
396
402
|
config: WorkspaceConfig;
|
|
397
403
|
|
|
@@ -555,16 +561,20 @@ export interface WorkspaceConfig {
|
|
|
555
561
|
github?: GithubAppConfig;
|
|
556
562
|
vscode?: VSCodeConfig;
|
|
557
563
|
|
|
564
|
+
/** deprecated. Enabled by default **/
|
|
565
|
+
experimentalNetwork?: boolean;
|
|
566
|
+
|
|
558
567
|
/**
|
|
559
568
|
* Where the config object originates from.
|
|
560
569
|
*
|
|
561
570
|
* repo - from the repository
|
|
571
|
+
* project-db - from the "Project" stored in the database
|
|
562
572
|
* definitly-gp - from github.com/gitpod-io/definitely-gp
|
|
563
573
|
* derived - computed based on analyzing the repository
|
|
564
574
|
* additional-content - config comes from additional content, usually provided through the project's configuration
|
|
565
575
|
* default - our static catch-all default config
|
|
566
576
|
*/
|
|
567
|
-
_origin?: 'repo' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
|
|
577
|
+
_origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
|
|
568
578
|
|
|
569
579
|
/**
|
|
570
580
|
* Set of automatically infered feature flags. That's not something the user can set, but
|
|
@@ -629,6 +639,8 @@ export type PrebuiltWorkspaceState
|
|
|
629
639
|
export interface PrebuiltWorkspace {
|
|
630
640
|
id: string;
|
|
631
641
|
cloneURL: string;
|
|
642
|
+
branch?: string;
|
|
643
|
+
projectId?: string;
|
|
632
644
|
commit: string;
|
|
633
645
|
buildWorkspaceId: string;
|
|
634
646
|
creationTime: string;
|
|
@@ -675,6 +687,8 @@ export interface PortConfig {
|
|
|
675
687
|
port: number;
|
|
676
688
|
onOpen?: PortOnOpen;
|
|
677
689
|
visibility?: PortVisibility;
|
|
690
|
+
description?: string;
|
|
691
|
+
name?: string;
|
|
678
692
|
}
|
|
679
693
|
export namespace PortConfig {
|
|
680
694
|
export function is(config: any): config is PortConfig {
|
|
@@ -698,7 +712,7 @@ export interface TaskConfig {
|
|
|
698
712
|
init?: string;
|
|
699
713
|
prebuild?: string;
|
|
700
714
|
command?: string;
|
|
701
|
-
env?: { [env: string]:
|
|
715
|
+
env?: { [env: string]: any };
|
|
702
716
|
openIn?: 'bottom' | 'main' | 'left' | 'right';
|
|
703
717
|
openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
|
|
704
718
|
}
|
|
@@ -762,6 +776,7 @@ export namespace ExternalImageConfigFile {
|
|
|
762
776
|
|
|
763
777
|
export interface WorkspaceContext {
|
|
764
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. */
|
|
765
780
|
normalizedContextURL?: string;
|
|
766
781
|
forceCreateNewWorkspace?: boolean;
|
|
767
782
|
forceImageBuild?: boolean;
|
|
@@ -798,6 +813,29 @@ export namespace WithPrebuild {
|
|
|
798
813
|
}
|
|
799
814
|
}
|
|
800
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
|
+
|
|
801
839
|
export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
|
|
802
840
|
snapshotId: string;
|
|
803
841
|
}
|
|
@@ -813,6 +851,8 @@ export namespace SnapshotContext {
|
|
|
813
851
|
export interface StartPrebuildContext extends WorkspaceContext {
|
|
814
852
|
actual: WorkspaceContext;
|
|
815
853
|
commitHistory?: string[];
|
|
854
|
+
project?: Project;
|
|
855
|
+
branch?: string;
|
|
816
856
|
}
|
|
817
857
|
|
|
818
858
|
export namespace StartPrebuildContext {
|
|
@@ -882,7 +922,7 @@ export interface Commit {
|
|
|
882
922
|
refType?: RefType
|
|
883
923
|
}
|
|
884
924
|
|
|
885
|
-
export interface AdditionalContentContext {
|
|
925
|
+
export interface AdditionalContentContext extends WorkspaceContext {
|
|
886
926
|
|
|
887
927
|
/**
|
|
888
928
|
* utf-8 encoded contents that will be copied on top of the workspace's filesystem
|
|
@@ -976,6 +1016,19 @@ export interface Repository {
|
|
|
976
1016
|
parent: Repository
|
|
977
1017
|
}
|
|
978
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
|
+
}
|
|
979
1032
|
|
|
980
1033
|
export namespace Repository {
|
|
981
1034
|
export function fullRepoName(repo: Repository): string {
|
|
@@ -1018,6 +1071,7 @@ export interface WorkspaceCreationResult {
|
|
|
1018
1071
|
runningWorkspacePrebuild?: {
|
|
1019
1072
|
prebuildID: string
|
|
1020
1073
|
workspaceID: string
|
|
1074
|
+
instanceID: string
|
|
1021
1075
|
starting: RunningWorkspacePrebuildStarting
|
|
1022
1076
|
sameCluster: boolean
|
|
1023
1077
|
}
|
|
@@ -1194,45 +1248,3 @@ export interface Terms {
|
|
|
1194
1248
|
readonly content: string;
|
|
1195
1249
|
readonly formElements?: object;
|
|
1196
1250
|
}
|
|
1197
|
-
|
|
1198
|
-
export interface Project {
|
|
1199
|
-
id: string;
|
|
1200
|
-
cloneUrl: string;
|
|
1201
|
-
teamId: string;
|
|
1202
|
-
appInstallationId: string;
|
|
1203
|
-
creationTime: string;
|
|
1204
|
-
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
1205
|
-
deleted?: boolean;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
export interface Team {
|
|
1209
|
-
id: string;
|
|
1210
|
-
name: string;
|
|
1211
|
-
slug: string;
|
|
1212
|
-
creationTime: string;
|
|
1213
|
-
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
1214
|
-
deleted?: boolean;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
export type TeamMemberRole = "owner" | "member";
|
|
1218
|
-
|
|
1219
|
-
export interface TeamMemberInfo {
|
|
1220
|
-
userId: string;
|
|
1221
|
-
fullName?: string;
|
|
1222
|
-
primaryEmail?: string;
|
|
1223
|
-
avatarUrl?: string;
|
|
1224
|
-
role: TeamMemberRole;
|
|
1225
|
-
memberSince: string;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
export interface TeamMembershipInvite {
|
|
1229
|
-
id: string;
|
|
1230
|
-
teamId: string;
|
|
1231
|
-
role: TeamMemberRole;
|
|
1232
|
-
creationTime: string;
|
|
1233
|
-
invalidationTime: string;
|
|
1234
|
-
invitedEmail?: string;
|
|
1235
|
-
|
|
1236
|
-
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
1237
|
-
deleted?: boolean;
|
|
1238
|
-
}
|
|
@@ -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;
|
|
@@ -83,6 +82,9 @@ export namespace TeamSubscriptionSlot {
|
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
}
|
|
85
|
+
export const isActive = (slot: TeamSubscriptionSlot): boolean => {
|
|
86
|
+
return !slot.cancellationDate;
|
|
87
|
+
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
/**
|