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