@gitpod/gitpod-protocol 0.1.5-minor-updates.0 → 0.1.5-mp-docs-wsp-phase.0
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 +53 -26
- 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 +27 -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 +44 -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 +31 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +102 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +14 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +94 -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 +124 -30
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +167 -278
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +9 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +5 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +105 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/{util/without.js → ide-protocol.js} +2 -2
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +27 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +30 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- 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/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 +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +23 -59
- 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 +8 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +36 -15
- 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 +152 -76
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +139 -131
- 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 +6 -4
- 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 +113 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +30 -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 +88 -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 +31 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +57 -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 -2
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +95 -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/{theia-plugins.js → util/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/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 +51 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +197 -62
- 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 +76 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +33 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +26 -4
- 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 +4 -10
- package/src/admin-protocol.ts +48 -5
- package/src/analytics.ts +52 -0
- package/src/context-url.spec.ts +53 -0
- package/src/context-url.ts +107 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +181 -53
- package/src/headless-workspace-log.ts +8 -11
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +7 -1
- package/src/installation-admin-protocol.ts +42 -0
- 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 +21 -68
- package/src/messaging/proxy-factory.ts +13 -5
- package/src/oss-allowlist.ts +15 -0
- package/src/permission.ts +24 -4
- package/src/plans.ts +632 -0
- package/src/protocol.ts +245 -112
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +9 -5
- package/src/teams-projects-protocol.ts +147 -0
- package/src/util/analytics.ts +105 -0
- package/src/util/garbage-collected-cache.ts +9 -3
- package/src/util/generate-workspace-id.spec.ts +20 -3
- package/src/util/generate-workspace-id.ts +22 -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 +22 -13
- 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/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 +183 -17
- package/src/workspace-cluster.ts +104 -0
- package/src/workspace-instance.ts +66 -30
- package/src/wsready.ts +2 -2
- package/data/builtin-theia-plugins.json +0 -372
- package/lib/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -46
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js.map +0 -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 +0 -10
- 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/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -34
- package/lib/util/safe-promise.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/messaging/connection-error-handler.ts +0 -62
- package/src/theia-plugins.ts +0 -11
- 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/util/safe-promise.ts +0 -26
|
@@ -0,0 +1,107 @@
|
|
|
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 { Workspace } from ".";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The whole point of these methods is to overcome inconsistencies in our data model.
|
|
11
|
+
* Ideally we remove it at some point once we fixed our model, as it:
|
|
12
|
+
* - duplicates logic
|
|
13
|
+
* - but additional burden on clients (using this, copying this to other languages!)
|
|
14
|
+
*
|
|
15
|
+
* TODO(gpl) See if we can get this into `server` code to remove the burden from clients
|
|
16
|
+
*/
|
|
17
|
+
export namespace ContextURL {
|
|
18
|
+
export const INCREMENTAL_PREBUILD_PREFIX = "incremental-prebuild";
|
|
19
|
+
export const PREBUILD_PREFIX = "prebuild";
|
|
20
|
+
export const IMAGEBUILD_PREFIX = "imagebuild";
|
|
21
|
+
export const SNAPSHOT_PREFIX = "snapshot";
|
|
22
|
+
export const REFERRER_PREFIX = 'referrer:';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This function will (try to) return the HTTP(S) URL of the context the user originally created this workspace on.
|
|
26
|
+
* Especially it will not contain any modifiers or be of different scheme than HTTP(S).
|
|
27
|
+
*
|
|
28
|
+
* Use this function if you need to provided a _working_ URL to the original context.
|
|
29
|
+
* @param ws
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export function getNormalizedURL(ws: Pick<Workspace, "context" | "contextURL"> | undefined): URL | undefined {
|
|
33
|
+
const normalized = normalize(ws);
|
|
34
|
+
if (!normalized) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
return new URL(normalized);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error(`unable to parse URL from normalized contextURL: '${normalized}'`, err);
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function normalize(ws: Pick<Workspace, "context" | "contextURL"> | undefined): string | undefined {
|
|
47
|
+
if (!ws) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (ws.context.normalizedContextURL) {
|
|
51
|
+
return ws.context.normalizedContextURL;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// fallback: we do not yet set normalizedContextURL on all workspaces, yet, let alone older existing workspaces
|
|
55
|
+
let fallback: string | undefined = undefined;
|
|
56
|
+
try {
|
|
57
|
+
fallback = removePrefixes(ws.contextURL);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
console.error(`unable to remove prefixes from contextURL: '${ws.contextURL}'`, err);
|
|
60
|
+
}
|
|
61
|
+
return fallback;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The field "contextUrl" might contain prefixes like:
|
|
66
|
+
* - envvar1=value1/...
|
|
67
|
+
* - prebuild/...
|
|
68
|
+
* This is the analogon to the (Prefix)ContextParser structure in "server".
|
|
69
|
+
*/
|
|
70
|
+
function removePrefixes(contextUrl: string | undefined): string | undefined {
|
|
71
|
+
if (contextUrl === undefined) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const segments = contextUrl.split("/");
|
|
76
|
+
if (segments.length === 1) {
|
|
77
|
+
return segments[0]; // this might be something, we just try
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const segmentsToURL = (offset: number): string => {
|
|
81
|
+
let rest = segments.slice(offset).join("/");
|
|
82
|
+
if (/^git@[^:\/]+:/.test(rest)) {
|
|
83
|
+
rest = rest.replace(/^git@([^:\/]+):/, 'https://$1/');
|
|
84
|
+
}
|
|
85
|
+
if (!rest.startsWith("http")) {
|
|
86
|
+
rest = 'https://' + rest;
|
|
87
|
+
}
|
|
88
|
+
return rest;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const firstSegment = segments[0];
|
|
92
|
+
if (firstSegment === PREBUILD_PREFIX ||
|
|
93
|
+
firstSegment === INCREMENTAL_PREBUILD_PREFIX ||
|
|
94
|
+
firstSegment === IMAGEBUILD_PREFIX ||
|
|
95
|
+
firstSegment === SNAPSHOT_PREFIX ||
|
|
96
|
+
firstSegment.startsWith(REFERRER_PREFIX)) {
|
|
97
|
+
return segmentsToURL(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// check for env vars
|
|
101
|
+
if (firstSegment.indexOf("=") !== -1) {
|
|
102
|
+
return segmentsToURL(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return segmentsToURL(0);
|
|
106
|
+
}
|
|
107
|
+
}
|
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,
|
|
9
|
-
WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo,
|
|
10
|
-
Token, UserEnvVarValue,
|
|
11
|
-
|
|
8
|
+
User, WorkspaceInfo, WorkspaceCreationResult, WorkspaceInstanceUser,
|
|
9
|
+
WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, CreateWorkspaceMode,
|
|
10
|
+
Token, UserEnvVarValue, Terms,
|
|
11
|
+
Configuration, UserInfo, GitpodTokenType,
|
|
12
|
+
GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes, ProjectEnvVar
|
|
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';
|
|
@@ -23,11 +28,15 @@ import { Emitter } from './util/event';
|
|
|
23
28
|
import { AccountStatement, CreditAlert } from './accounting-protocol';
|
|
24
29
|
import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
|
|
25
30
|
import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
|
|
31
|
+
import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from './analytics';
|
|
32
|
+
import { IDEServer } from './ide-protocol';
|
|
33
|
+
import { InstallationAdminSettings, TelemetryData } from './installation-admin-protocol';
|
|
26
34
|
|
|
27
35
|
export interface GitpodClient {
|
|
28
36
|
onInstanceUpdate(instance: WorkspaceInstance): void;
|
|
29
37
|
onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
|
|
30
|
-
|
|
38
|
+
|
|
39
|
+
onPrebuildUpdate(update: PrebuildWithStatus): void;
|
|
31
40
|
|
|
32
41
|
onCreditAlert(creditAlert: CreditAlert): void;
|
|
33
42
|
|
|
@@ -38,18 +47,18 @@ export interface GitpodClient {
|
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
export const GitpodServer = Symbol('GitpodServer');
|
|
41
|
-
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService {
|
|
50
|
+
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
|
|
42
51
|
// User related API
|
|
43
52
|
getLoggedInUser(): Promise<User>;
|
|
44
53
|
getTerms(): Promise<Terms>;
|
|
45
54
|
updateLoggedInUser(user: Partial<User>): Promise<User>;
|
|
46
55
|
getAuthProviders(): Promise<AuthProviderInfo[]>;
|
|
47
56
|
getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
|
|
48
|
-
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<
|
|
57
|
+
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
|
|
49
58
|
deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
|
|
50
|
-
getBranding(): Promise<Branding>;
|
|
51
59
|
getConfiguration(): Promise<Configuration>;
|
|
52
60
|
getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
|
|
61
|
+
getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
|
|
53
62
|
/**
|
|
54
63
|
* @deprecated
|
|
55
64
|
*/
|
|
@@ -63,8 +72,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
63
72
|
getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
|
|
64
73
|
getWorkspaceUsers(workspaceId: string): Promise<WorkspaceInstanceUser[]>;
|
|
65
74
|
getFeaturedRepositories(): Promise<WhitelistedRepository[]>;
|
|
75
|
+
getSuggestedContextURLs(): Promise<string[]>;
|
|
76
|
+
/**
|
|
77
|
+
* **Security:**
|
|
78
|
+
* Sensitive information like an owner token is erased, since it allows access for all team members.
|
|
79
|
+
* If you need to access an owner token use `getOwnerToken` instead.
|
|
80
|
+
*/
|
|
66
81
|
getWorkspace(id: string): Promise<WorkspaceInfo>;
|
|
67
82
|
isWorkspaceOwner(workspaceId: string): Promise<boolean>;
|
|
83
|
+
getOwnerToken(workspaceId: string): Promise<string>;
|
|
68
84
|
|
|
69
85
|
/**
|
|
70
86
|
* Creates and starts a workspace for the given context URL.
|
|
@@ -81,8 +97,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
81
97
|
updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
|
|
82
98
|
sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
|
|
83
99
|
watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
|
|
84
|
-
watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
|
|
85
100
|
isPrebuildDone(pwsid: string): Promise<boolean>;
|
|
101
|
+
getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
|
|
86
102
|
|
|
87
103
|
// Workspace timeout
|
|
88
104
|
setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
|
|
@@ -96,19 +112,52 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
96
112
|
openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
|
|
97
113
|
closePort(workspaceId: string, port: number): Promise<void>;
|
|
98
114
|
|
|
99
|
-
// User messages
|
|
100
|
-
getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
|
|
101
|
-
updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
|
|
102
|
-
|
|
103
115
|
// User storage
|
|
104
116
|
getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
|
|
105
117
|
updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
|
|
106
118
|
|
|
107
|
-
//
|
|
119
|
+
// User env vars
|
|
108
120
|
getEnvVars(): Promise<UserEnvVarValue[]>;
|
|
121
|
+
getAllEnvVars(): Promise<UserEnvVarValue[]>;
|
|
109
122
|
setEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
110
123
|
deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
111
124
|
|
|
125
|
+
// Teams
|
|
126
|
+
getTeams(): Promise<Team[]>;
|
|
127
|
+
getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
|
|
128
|
+
createTeam(name: string): Promise<Team>;
|
|
129
|
+
joinTeam(inviteId: string): Promise<Team>;
|
|
130
|
+
setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
|
|
131
|
+
removeTeamMember(teamId: string, userId: string): Promise<void>;
|
|
132
|
+
getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
|
|
133
|
+
resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
|
|
134
|
+
deleteTeam(teamId: string, userId: string): Promise<void>;
|
|
135
|
+
|
|
136
|
+
// Admin Settings
|
|
137
|
+
adminGetSettings(): Promise<InstallationAdminSettings>;
|
|
138
|
+
adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
|
|
139
|
+
adminGetTelemetryData(): Promise<TelemetryData>;
|
|
140
|
+
|
|
141
|
+
// Projects
|
|
142
|
+
getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
|
|
143
|
+
createProject(params: CreateProjectParams): Promise<Project>;
|
|
144
|
+
deleteProject(projectId: string): Promise<void>;
|
|
145
|
+
getTeamProjects(teamId: string): Promise<Project[]>;
|
|
146
|
+
getUserProjects(): Promise<Project[]>;
|
|
147
|
+
getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
|
|
148
|
+
findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
|
|
149
|
+
triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
|
|
150
|
+
cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
|
|
151
|
+
fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
|
|
152
|
+
guessProjectConfiguration(projectId: string): Promise<string | undefined>;
|
|
153
|
+
fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
154
|
+
guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
155
|
+
setProjectConfiguration(projectId: string, configString: string): Promise<void>;
|
|
156
|
+
updateProjectPartial(partialProject: PartialProject): Promise<void>;
|
|
157
|
+
setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
|
|
158
|
+
getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
|
|
159
|
+
deleteProjectEnvironmentVariable(variableId: string): Promise<void>;
|
|
160
|
+
|
|
112
161
|
// content service
|
|
113
162
|
getContentBlobUploadUrl(name: string): Promise<string>
|
|
114
163
|
getContentBlobDownloadUrl(name: string): Promise<string>
|
|
@@ -123,10 +172,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
123
172
|
registerGithubApp(installationId: string): Promise<void>;
|
|
124
173
|
|
|
125
174
|
/**
|
|
126
|
-
* Stores a new snapshot for the given workspace and bucketId
|
|
175
|
+
* Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
|
|
127
176
|
* @return the snapshot id
|
|
128
177
|
*/
|
|
129
178
|
takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
|
|
179
|
+
/**
|
|
180
|
+
*
|
|
181
|
+
* @param snapshotId
|
|
182
|
+
*/
|
|
183
|
+
waitForSnapshot(snapshotId: string): Promise<void>;
|
|
130
184
|
|
|
131
185
|
/**
|
|
132
186
|
* Returns the list of snapshots that exist for a workspace.
|
|
@@ -143,29 +197,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
143
197
|
*/
|
|
144
198
|
getLayout(workspaceId: string): Promise<string | undefined>;
|
|
145
199
|
|
|
146
|
-
|
|
147
|
-
* @param params
|
|
148
|
-
* @returns promise resolves to an URL to be used for the upload
|
|
149
|
-
*/
|
|
150
|
-
preparePluginUpload(params: PreparePluginUploadParams): Promise<string>
|
|
151
|
-
resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
|
|
152
|
-
installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
|
|
153
|
-
uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
|
|
200
|
+
guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
|
|
154
201
|
|
|
155
202
|
/**
|
|
156
203
|
* gitpod.io concerns
|
|
157
204
|
*/
|
|
158
205
|
isStudent(): Promise<boolean>;
|
|
159
|
-
getPrivateRepoTrialEndDate(): Promise<string | undefined>;
|
|
160
|
-
|
|
161
206
|
/**
|
|
162
|
-
*
|
|
207
|
+
*
|
|
163
208
|
*/
|
|
164
209
|
getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
|
|
165
210
|
getRemainingUsageHours(): Promise<number>;
|
|
166
211
|
|
|
167
212
|
/**
|
|
168
|
-
*
|
|
213
|
+
*
|
|
169
214
|
*/
|
|
170
215
|
getChargebeeSiteId(): Promise<string>;
|
|
171
216
|
createPortalSession(): Promise<{}>;
|
|
@@ -175,7 +220,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
175
220
|
|
|
176
221
|
getShowPaymentUI(): Promise<boolean>;
|
|
177
222
|
isChargebeeCustomer(): Promise<boolean>;
|
|
178
|
-
mayAccessPrivateRepo(): Promise<boolean>;
|
|
179
223
|
|
|
180
224
|
subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
181
225
|
subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
@@ -186,13 +230,71 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
186
230
|
tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
|
|
187
231
|
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
|
|
188
232
|
tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
|
|
189
|
-
tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string|undefined): Promise<void>
|
|
233
|
+
tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string | undefined): Promise<void>
|
|
190
234
|
tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
|
|
191
235
|
tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
192
236
|
tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
193
237
|
|
|
194
238
|
getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
|
|
195
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Analytics
|
|
242
|
+
*/
|
|
243
|
+
trackEvent(event: RemoteTrackMessage): Promise<void>;
|
|
244
|
+
trackLocation(event: RemotePageMessage): Promise<void>;
|
|
245
|
+
identifyUser(event: RemoteIdentifyMessage): Promise<void>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface RateLimiterError {
|
|
249
|
+
method?: string,
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Retry after this many seconds, earliest.
|
|
253
|
+
* cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
254
|
+
*/
|
|
255
|
+
retryAfter: number,
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface CreateProjectParams {
|
|
259
|
+
name: string;
|
|
260
|
+
slug?: string;
|
|
261
|
+
account: string;
|
|
262
|
+
provider: string;
|
|
263
|
+
cloneUrl: string;
|
|
264
|
+
teamId?: string;
|
|
265
|
+
userId?: string;
|
|
266
|
+
appInstallationId: string;
|
|
267
|
+
}
|
|
268
|
+
export interface FindPrebuildsParams {
|
|
269
|
+
projectId: string;
|
|
270
|
+
branch?: string;
|
|
271
|
+
latest?: boolean;
|
|
272
|
+
prebuildId?: string;
|
|
273
|
+
// default: 30
|
|
274
|
+
limit?: number;
|
|
275
|
+
}
|
|
276
|
+
export interface GetProviderRepositoriesParams {
|
|
277
|
+
provider: string;
|
|
278
|
+
hints?: { installationId: string } | object;
|
|
279
|
+
}
|
|
280
|
+
export interface ProviderRepository {
|
|
281
|
+
name: string;
|
|
282
|
+
path?: string;
|
|
283
|
+
account: string;
|
|
284
|
+
accountAvatarUrl: string;
|
|
285
|
+
cloneUrl: string;
|
|
286
|
+
updatedAt: string;
|
|
287
|
+
installationId?: number;
|
|
288
|
+
installationUpdatedAt?: string;
|
|
289
|
+
|
|
290
|
+
inUse?: { userName: string };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface ClientHeaderFields {
|
|
294
|
+
ip?: string;
|
|
295
|
+
userAgent?: string;
|
|
296
|
+
dnt?: string;
|
|
297
|
+
clientRegion?: string;
|
|
196
298
|
}
|
|
197
299
|
|
|
198
300
|
export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
|
|
@@ -205,6 +307,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
|
|
|
205
307
|
methods.setClient = methods.setClient || (() => { });
|
|
206
308
|
methods.dispose = methods.dispose || (() => { });
|
|
207
309
|
return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
|
|
310
|
+
// @ts-ignore
|
|
208
311
|
get: (target: S, property: keyof S) => {
|
|
209
312
|
const result = target[property];
|
|
210
313
|
if (!result) {
|
|
@@ -237,6 +340,8 @@ export namespace GitpodServer {
|
|
|
237
340
|
limit?: number;
|
|
238
341
|
searchString?: string;
|
|
239
342
|
pinnedOnly?: boolean;
|
|
343
|
+
projectId?: string | string[];
|
|
344
|
+
includeWithoutProject?: boolean;
|
|
240
345
|
}
|
|
241
346
|
export interface GetAccountStatementOptions {
|
|
242
347
|
date?: string;
|
|
@@ -244,6 +349,7 @@ export namespace GitpodServer {
|
|
|
244
349
|
export interface CreateWorkspaceOptions {
|
|
245
350
|
contextUrl: string;
|
|
246
351
|
mode?: CreateWorkspaceMode;
|
|
352
|
+
forceDefaultConfig?: boolean;
|
|
247
353
|
}
|
|
248
354
|
export interface StartWorkspaceOptions {
|
|
249
355
|
forceDefaultImage: boolean;
|
|
@@ -251,13 +357,8 @@ export namespace GitpodServer {
|
|
|
251
357
|
export interface TakeSnapshotOptions {
|
|
252
358
|
workspaceId: string;
|
|
253
359
|
layoutData?: string;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
readonly releaseNotes?: boolean;
|
|
257
|
-
readonly workspaceInstanceId: string;
|
|
258
|
-
}
|
|
259
|
-
export interface UpdateUserMessagesOptions {
|
|
260
|
-
readonly messageIds: string[];
|
|
360
|
+
/* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
|
|
361
|
+
dontWait?: boolean;
|
|
261
362
|
}
|
|
262
363
|
export interface GetUserStorageResourceOptions {
|
|
263
364
|
readonly uri: string;
|
|
@@ -299,10 +400,12 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
299
400
|
|
|
300
401
|
public registerClient(client: Partial<Client>): Disposable {
|
|
301
402
|
this.clients.push(client);
|
|
302
|
-
const index = this.clients.length;
|
|
303
403
|
return {
|
|
304
404
|
dispose: () => {
|
|
305
|
-
this.clients.
|
|
405
|
+
const index = this.clients.indexOf(client);
|
|
406
|
+
if (index > -1) {
|
|
407
|
+
this.clients.splice(index, 1);
|
|
408
|
+
}
|
|
306
409
|
}
|
|
307
410
|
}
|
|
308
411
|
}
|
|
@@ -319,11 +422,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
319
422
|
}
|
|
320
423
|
}
|
|
321
424
|
|
|
322
|
-
|
|
425
|
+
onPrebuildUpdate(update: PrebuildWithStatus): void {
|
|
323
426
|
for (const client of this.clients) {
|
|
324
|
-
if (client.
|
|
427
|
+
if (client.onPrebuildUpdate) {
|
|
325
428
|
try {
|
|
326
|
-
client.
|
|
429
|
+
client.onPrebuildUpdate(update);
|
|
327
430
|
} catch (error) {
|
|
328
431
|
console.error(error)
|
|
329
432
|
}
|
|
@@ -331,11 +434,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
331
434
|
}
|
|
332
435
|
}
|
|
333
436
|
|
|
334
|
-
|
|
437
|
+
onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
|
|
335
438
|
for (const client of this.clients) {
|
|
336
|
-
if (client.
|
|
439
|
+
if (client.onWorkspaceImageBuildLogs) {
|
|
337
440
|
try {
|
|
338
|
-
client.
|
|
441
|
+
client.onWorkspaceImageBuildLogs(info, content);
|
|
339
442
|
} catch (error) {
|
|
340
443
|
console.error(error)
|
|
341
444
|
}
|
|
@@ -399,7 +502,7 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
399
502
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
|
400
503
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
401
504
|
|
|
402
|
-
private source: 'sync'
|
|
505
|
+
private source: 'sync' | 'update' = 'sync';
|
|
403
506
|
|
|
404
507
|
get info(): WorkspaceInfo {
|
|
405
508
|
return this._info;
|
|
@@ -491,11 +594,15 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
491
594
|
|
|
492
595
|
}
|
|
493
596
|
|
|
597
|
+
export interface GitpodServiceOptions {
|
|
598
|
+
onReconnect?: () => (void | Promise<void>)
|
|
599
|
+
}
|
|
600
|
+
|
|
494
601
|
export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
|
|
495
602
|
|
|
496
603
|
private readonly compositeClient = new GitpodCompositeClient<Client>();
|
|
497
604
|
|
|
498
|
-
constructor(public readonly server: JsonRpcProxy<Server
|
|
605
|
+
constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
|
|
499
606
|
server.setClient(this.compositeClient);
|
|
500
607
|
server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
|
|
501
608
|
server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
|
|
@@ -515,13 +622,34 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
515
622
|
this.instanceListeners.set(workspaceId, listener);
|
|
516
623
|
return listener;
|
|
517
624
|
}
|
|
625
|
+
|
|
626
|
+
async reconnect(): Promise<void> {
|
|
627
|
+
if (this.options?.onReconnect) {
|
|
628
|
+
await this.options.onReconnect();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
518
631
|
}
|
|
519
632
|
|
|
520
|
-
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string) {
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
633
|
+
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
|
|
634
|
+
const toWsUrl = (serverUrl: string) => {
|
|
635
|
+
return new GitpodHostUrl(serverUrl)
|
|
636
|
+
.asWebsocket()
|
|
637
|
+
.withApi({ pathname: GitpodServerPath })
|
|
638
|
+
.toString();
|
|
639
|
+
};
|
|
640
|
+
let url: string | Promise<string>;
|
|
641
|
+
if (typeof serverUrl === "string") {
|
|
642
|
+
url = toWsUrl(serverUrl);
|
|
643
|
+
} else {
|
|
644
|
+
url = serverUrl.then(url => toWsUrl(url));
|
|
645
|
+
}
|
|
646
|
+
|
|
524
647
|
const connectionProvider = new WebSocketConnectionProvider();
|
|
525
|
-
|
|
526
|
-
|
|
648
|
+
let onReconnect = () => { };
|
|
649
|
+
const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
|
|
650
|
+
onListening: socket => {
|
|
651
|
+
onReconnect = () => socket.reconnect();
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
|
|
527
655
|
}
|
|
@@ -11,6 +11,7 @@ export enum HeadlessWorkspaceEventType {
|
|
|
11
11
|
FinishedButFailed = "finish-fail",
|
|
12
12
|
AbortedTimedOut = "aborted-timeout",
|
|
13
13
|
Aborted = "aborted",
|
|
14
|
+
Failed = "failed",
|
|
14
15
|
Started = "started"
|
|
15
16
|
}
|
|
16
17
|
export namespace HeadlessWorkspaceEventType {
|
|
@@ -22,21 +23,17 @@ export namespace HeadlessWorkspaceEventType {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export interface
|
|
26
|
+
export interface HeadlessWorkspaceEvent {
|
|
26
27
|
workspaceID: string;
|
|
27
28
|
text: string;
|
|
28
29
|
type: HeadlessWorkspaceEventType;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
TaskSuccessfulLabel = "workspaceTaskDone"
|
|
32
|
+
export interface HeadlessLogUrls {
|
|
33
|
+
// A map of id to URL
|
|
34
|
+
streams: { [streamID: string]: string };
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
error?: string;
|
|
41
|
-
snapshotURL?: string;
|
|
42
|
-
}
|
|
37
|
+
/** cmp. @const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX */
|
|
38
|
+
export const HEADLESS_LOG_STREAM_STATUS_CODE = "X-LogStream-StatusCode";
|
|
39
|
+
export const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX = /X-LogStream-StatusCode: ([0-9]{3})/;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Event } from "./util/event";
|
|
8
8
|
import { Disposable } from "./util/disposable";
|
|
9
9
|
|
|
10
|
-
export type IDEFrontendState = 'init' | 'ready' |
|
|
10
|
+
export type IDEFrontendState = 'init' | 'ready' | 'terminated';
|
|
11
11
|
|
|
12
12
|
export interface IDEFrontendService {
|
|
13
13
|
readonly state: IDEFrontendState;
|