@gitpod/gitpod-protocol 0.1.5-wth-test.80 → 0.1.5-yh-vmoptions-fork.1
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 +181 -4
- package/lib/accounting-protocol.d.ts +17 -10
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +30 -32
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +1 -0
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts.map +1 -1
- package/lib/analytics.js.map +1 -1
- package/lib/auth.d.ts.map +1 -1
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +3 -3
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +20 -5
- package/lib/context-url.spec.js.map +1 -1
- package/lib/email-protocol.d.ts +1 -1
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +1 -1
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +7 -7
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +2 -3
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +1 -1
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +7 -9
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +0 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +1 -20
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +6 -6
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +42 -39
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +32 -26
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +39 -32
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +1 -0
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +2 -1
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +1 -1
- package/lib/ide-protocol.d.ts +6 -6
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/index.d.ts +16 -16
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +2 -2
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts +7 -0
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +1 -1
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +19 -19
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +4 -4
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +9 -6
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +2 -2
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +20 -20
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts +2 -0
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +4 -0
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -1
- package/lib/messaging/node/connection.js +8 -8
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +1 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +7 -9
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/payment-protocol.d.ts.map +1 -1
- package/lib/payment-protocol.js +1 -1
- package/lib/payment-protocol.js.map +1 -1
- package/lib/permission.d.ts +2 -2
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +12 -23
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +3 -3
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +206 -171
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +83 -36
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +165 -87
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.spec.js.map +1 -1
- package/lib/team-subscription-protocol.d.ts +21 -3
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +16 -5
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +8 -3
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +1 -1
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +2 -2
- package/lib/typings/globals.d.ts.map +1 -1
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +6 -6
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +3 -3
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +6 -6
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +2 -2
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +5 -3
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +1 -1
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +5 -0
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +446 -442
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +18 -7
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +1 -1
- package/lib/util/gitpod-cookie.d.ts.map +1 -1
- package/lib/util/gitpod-cookie.js +0 -3
- package/lib/util/gitpod-cookie.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +31 -29
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +15 -5
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts.map +1 -1
- package/lib/util/logging.d.ts +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +23 -24
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +5 -5
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +1 -2
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.spec.js +9 -6
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts +1 -0
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +9 -3
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +6 -6
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +14 -16
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.js +3 -3
- package/lib/util/tracing.spec.js.map +1 -1
- package/lib/util/workspace-port-authentication.d.ts +7 -7
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +8 -11
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +1 -1
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +2 -4
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +19 -3
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +6 -6
- package/pkg-yarn.lock +5 -5
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +63 -51
- package/src/admin-protocol.ts +23 -20
- package/src/analytics.ts +21 -21
- package/src/auth.ts +2 -2
- package/src/context-url.spec.ts +25 -11
- package/src/context-url.ts +80 -78
- package/src/email-protocol.ts +5 -6
- package/src/encryption/container-module.ts +2 -3
- package/src/encryption/encryption-engine.spec.ts +9 -8
- package/src/encryption/encryption-engine.ts +14 -14
- package/src/encryption/encryption-service.ts +4 -5
- package/src/encryption/key-provider.ts +16 -19
- package/src/env.ts +0 -22
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +152 -110
- package/src/headless-workspace-log.ts +6 -4
- package/src/ide-frontend-service.ts +2 -2
- package/src/ide-protocol.ts +8 -8
- package/src/index.ts +16 -16
- package/src/installation-admin-protocol.ts +8 -8
- package/src/license-protocol.ts +12 -6
- package/src/messaging/browser/connection.ts +45 -47
- package/src/messaging/browser/window-connection.ts +39 -29
- package/src/messaging/client-call-metrics.ts +70 -71
- package/src/messaging/error.ts +7 -3
- package/src/messaging/handler.ts +6 -6
- package/src/messaging/node/connection.ts +8 -8
- package/src/messaging/proxy-factory.ts +23 -30
- package/src/oss-allowlist.ts +3 -3
- package/src/payment-protocol.ts +2 -2
- package/src/permission.ts +20 -31
- package/src/plans.ts +236 -189
- package/src/protocol.ts +346 -239
- package/src/snapshot-url.spec.ts +9 -7
- package/src/team-subscription-protocol.ts +57 -23
- package/src/teams-projects-protocol.ts +14 -8
- package/src/typings/globals.ts +4 -4
- package/src/util/analytics.ts +46 -42
- package/src/util/async-iterator.ts +4 -5
- package/src/util/cancelable.ts +3 -3
- package/src/util/date-time.ts +8 -8
- package/src/util/deferred.ts +6 -6
- package/src/util/disposable.ts +3 -6
- package/src/util/event.ts +9 -11
- package/src/util/garbage-collected-cache.ts +3 -6
- package/src/util/generate-workspace-id.spec.ts +26 -16
- package/src/util/generate-workspace-id.ts +460 -454
- package/src/util/gitpod-cookie.ts +8 -9
- package/src/util/gitpod-host-url.spec.ts +40 -13
- package/src/util/gitpod-host-url.ts +37 -34
- package/src/util/grpc.ts +1 -1
- package/src/util/jaeger-client-types.ts +2 -2
- package/src/util/logging.ts +49 -40
- package/src/util/make-link.ts +6 -7
- package/src/util/parse-workspace-id.spec.ts +17 -8
- package/src/util/parse-workspace-id.ts +5 -6
- package/src/util/queue.spec.ts +27 -25
- package/src/util/repeat.ts +1 -1
- package/src/util/semaphore.ts +4 -6
- package/src/util/skip-if.ts +9 -6
- package/src/util/timeutil.spec.ts +14 -15
- package/src/util/timeutil.ts +21 -11
- package/src/util/tracing.spec.ts +28 -23
- package/src/util/tracing.ts +54 -51
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/workspace-cluster.ts +15 -12
- package/src/workspace-instance.ts +53 -24
- package/src/wsready.ts +3 -3
- package/data/builtin-theia-plugins.json +0 -372
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js +0 -8
- package/lib/theia-plugins.js.map +0 -1
- package/src/theia-plugins.ts +0 -11
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { v4 as uuidv4 } from
|
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
|
8
8
|
|
|
9
9
|
const InstallationAdminSettingsPrototype = {
|
|
10
|
-
sendTelemetry: true
|
|
11
|
-
}
|
|
10
|
+
sendTelemetry: true,
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
export type InstallationAdminSettings = typeof InstallationAdminSettingsPrototype;
|
|
14
14
|
|
|
@@ -24,10 +24,10 @@ export interface InstallationAdmin {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface TelemetryData {
|
|
27
|
-
installationAdmin: InstallationAdmin
|
|
28
|
-
totalUsers: number
|
|
29
|
-
totalWorkspaces: number
|
|
30
|
-
totalInstances: number
|
|
27
|
+
installationAdmin: InstallationAdmin;
|
|
28
|
+
totalUsers: number;
|
|
29
|
+
totalWorkspaces: number;
|
|
30
|
+
totalInstances: number;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export namespace InstallationAdmin {
|
|
@@ -36,7 +36,7 @@ export namespace InstallationAdmin {
|
|
|
36
36
|
id: uuidv4(),
|
|
37
37
|
settings: {
|
|
38
38
|
...InstallationAdminSettingsPrototype,
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/license-protocol.ts
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
export interface LicenseValidationResult {
|
|
9
|
-
valid: boolean
|
|
10
|
-
msg?: string
|
|
11
|
-
issue?: LicenseIssue
|
|
8
|
+
valid: boolean;
|
|
9
|
+
msg?: string;
|
|
10
|
+
issue?: LicenseIssue;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export type LicenseIssue = "seats-exhausted";
|
|
@@ -16,9 +15,15 @@ export type LicenseIssue = "seats-exhausted";
|
|
|
16
15
|
export interface LicenseInfo {
|
|
17
16
|
key: string;
|
|
18
17
|
seats: number;
|
|
18
|
+
userCount?: number;
|
|
19
19
|
valid: boolean;
|
|
20
20
|
validUntil: string;
|
|
21
21
|
plan?: string;
|
|
22
|
+
features?: string[];
|
|
23
|
+
enabledFeatures?: string[];
|
|
24
|
+
type?: string;
|
|
25
|
+
errorMsg?: string;
|
|
26
|
+
fallbackAllowed: boolean;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export interface GetLicenseInfoResult {
|
|
@@ -34,5 +39,6 @@ export enum LicenseFeature {
|
|
|
34
39
|
export interface LicenseService {
|
|
35
40
|
validateLicense(): Promise<LicenseValidationResult>;
|
|
36
41
|
getLicenseInfo(): Promise<GetLicenseInfoResult>;
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
adminGetLicense(): Promise<LicenseInfo>;
|
|
43
|
+
licenseIncludesFeature(feature: LicenseFeature): Promise<boolean>;
|
|
44
|
+
}
|
|
@@ -11,7 +11,7 @@ import { AbstractMessageWriter } from "vscode-jsonrpc/lib/messageWriter";
|
|
|
11
11
|
import { AbstractMessageReader } from "vscode-jsonrpc/lib/messageReader";
|
|
12
12
|
import { JsonRpcProxyFactory, JsonRpcProxy } from "../proxy-factory";
|
|
13
13
|
import { ConnectionEventHandler, ConnectionHandler } from "../handler";
|
|
14
|
-
import ReconnectingWebSocket, { Event } from
|
|
14
|
+
import ReconnectingWebSocket, { Event } from "reconnecting-websocket";
|
|
15
15
|
|
|
16
16
|
export interface WebSocketOptions {
|
|
17
17
|
onerror?: (event: Event) => void;
|
|
@@ -19,7 +19,6 @@ export interface WebSocketOptions {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export class WebSocketConnectionProvider {
|
|
22
|
-
|
|
23
22
|
/**
|
|
24
23
|
* Create a proxy object to remote interface of T type
|
|
25
24
|
* over a web socket connection for the given path.
|
|
@@ -27,27 +26,33 @@ export class WebSocketConnectionProvider {
|
|
|
27
26
|
* An optional target can be provided to handle
|
|
28
27
|
* notifications and requests from a remote side.
|
|
29
28
|
*/
|
|
30
|
-
createProxy<T extends object>(
|
|
29
|
+
createProxy<T extends object>(
|
|
30
|
+
path: string | Promise<string>,
|
|
31
|
+
target?: object,
|
|
32
|
+
options?: WebSocketOptions,
|
|
33
|
+
): JsonRpcProxy<T> {
|
|
31
34
|
const factory = new JsonRpcProxyFactory<T>(target);
|
|
32
35
|
const startListening = (path: string) => {
|
|
33
|
-
const socket = this.listen(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const socket = this.listen(
|
|
37
|
+
{
|
|
38
|
+
path,
|
|
39
|
+
onConnection: (c) => factory.listen(c),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
onTransportDidClose: () => factory.fireConnectionClosed(),
|
|
43
|
+
onTransportDidOpen: () => factory.fireConnectionOpened(),
|
|
44
|
+
},
|
|
45
|
+
options,
|
|
41
46
|
);
|
|
42
47
|
if (options?.onListening) {
|
|
43
|
-
options.onListening(socket as any as ReconnectingWebSocket)
|
|
48
|
+
options.onListening(socket as any as ReconnectingWebSocket);
|
|
44
49
|
}
|
|
45
50
|
};
|
|
46
51
|
|
|
47
52
|
if (typeof path === "string") {
|
|
48
53
|
startListening(path);
|
|
49
54
|
} else {
|
|
50
|
-
path.then(path => startListening(path));
|
|
55
|
+
path.then((path) => startListening(path));
|
|
51
56
|
}
|
|
52
57
|
return factory.createProxy();
|
|
53
58
|
}
|
|
@@ -62,20 +67,15 @@ export class WebSocketConnectionProvider {
|
|
|
62
67
|
const logger = this.createLogger();
|
|
63
68
|
if (options && options.onerror) {
|
|
64
69
|
const onerror = options.onerror;
|
|
65
|
-
webSocket.addEventListener(
|
|
70
|
+
webSocket.addEventListener("error", (event) => {
|
|
66
71
|
onerror(event);
|
|
67
72
|
});
|
|
68
73
|
} else {
|
|
69
|
-
webSocket.addEventListener(
|
|
74
|
+
webSocket.addEventListener("error", (error: Event) => {
|
|
70
75
|
logger.error(JSON.stringify(error));
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
|
-
doListen(
|
|
74
|
-
webSocket as any as ReconnectingWebSocket,
|
|
75
|
-
handler,
|
|
76
|
-
eventHandler,
|
|
77
|
-
logger,
|
|
78
|
-
);
|
|
78
|
+
doListen(webSocket as any as ReconnectingWebSocket, handler, eventHandler, logger);
|
|
79
79
|
return webSocket;
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -93,10 +93,9 @@ export class WebSocketConnectionProvider {
|
|
|
93
93
|
reconnectionDelayGrowFactor: 1.3,
|
|
94
94
|
maxRetries: Infinity,
|
|
95
95
|
debug: false,
|
|
96
|
-
WebSocket: WebSocket
|
|
96
|
+
WebSocket: WebSocket,
|
|
97
97
|
}) as any;
|
|
98
98
|
}
|
|
99
|
-
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
// The following was extracted from vscode-ws-jsonrpc to make these changes:
|
|
@@ -104,7 +103,12 @@ export class WebSocketConnectionProvider {
|
|
|
104
103
|
// - webSocket.onopen: making sure it's only ever called once so we're re-using MessageConnection
|
|
105
104
|
// - WebSocketMessageWriter: buffer and re-try messages instead of throwing an error immidiately
|
|
106
105
|
// - WebSocketMessageReader: don't close MessageConnection on 'socket.onclose'
|
|
107
|
-
function doListen(
|
|
106
|
+
function doListen(
|
|
107
|
+
resocket: ReconnectingWebSocket,
|
|
108
|
+
handler: ConnectionHandler,
|
|
109
|
+
eventHandler: ConnectionEventHandler,
|
|
110
|
+
logger: Logger,
|
|
111
|
+
) {
|
|
108
112
|
resocket.addEventListener("close", () => eventHandler.onTransportDidClose());
|
|
109
113
|
|
|
110
114
|
let alreadyOpened = false;
|
|
@@ -169,7 +173,7 @@ class BufferingWebSocketMessageWriter extends AbstractMessageWriter {
|
|
|
169
173
|
|
|
170
174
|
protected flushBuffer() {
|
|
171
175
|
if (this.buffer.length === 0) {
|
|
172
|
-
return
|
|
176
|
+
return;
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
const buffer = [...this.buffer];
|
|
@@ -186,26 +190,25 @@ class BufferingWebSocketMessageWriter extends AbstractMessageWriter {
|
|
|
186
190
|
}
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
|
|
190
193
|
/**
|
|
191
194
|
* This takes vscode-ws-jsonrpc/lib/socket/reader/WebSocketMessageReader and removes the "onClose -> fireClose" connection
|
|
192
195
|
*/
|
|
193
196
|
class NonClosingWebSocketMessageReader extends AbstractMessageReader {
|
|
194
197
|
protected readonly socket: IWebSocket;
|
|
195
198
|
protected readonly events: any[] = [];
|
|
196
|
-
protected state:
|
|
199
|
+
protected state: "initial" | "listening" | "closed" = "initial";
|
|
197
200
|
protected callback: (message: any) => void = () => {};
|
|
198
201
|
|
|
199
202
|
constructor(socket: IWebSocket) {
|
|
200
203
|
super();
|
|
201
204
|
this.socket = socket;
|
|
202
|
-
this.socket.onMessage(message => this.readMessage(message));
|
|
203
|
-
this.socket.onError(error => this.fireError(error));
|
|
205
|
+
this.socket.onMessage((message) => this.readMessage(message));
|
|
206
|
+
this.socket.onError((error) => this.fireError(error));
|
|
204
207
|
this.socket.onClose((code, reason) => {
|
|
205
208
|
if (code !== 1000) {
|
|
206
209
|
const error = {
|
|
207
|
-
name:
|
|
208
|
-
message: `Error during socket reconnect: code = ${code}, reason = ${reason}
|
|
210
|
+
name: "" + code,
|
|
211
|
+
message: `Error during socket reconnect: code = ${code}, reason = ${reason}`,
|
|
209
212
|
};
|
|
210
213
|
this.fireError(error);
|
|
211
214
|
}
|
|
@@ -213,47 +216,42 @@ class NonClosingWebSocketMessageReader extends AbstractMessageReader {
|
|
|
213
216
|
});
|
|
214
217
|
}
|
|
215
218
|
listen(callback: (message: any) => void) {
|
|
216
|
-
if (this.state ===
|
|
217
|
-
this.state =
|
|
219
|
+
if (this.state === "initial") {
|
|
220
|
+
this.state = "listening";
|
|
218
221
|
this.callback = callback;
|
|
219
222
|
while (this.events.length !== 0) {
|
|
220
223
|
const event = this.events.pop();
|
|
221
224
|
if (event.message) {
|
|
222
225
|
this.readMessage(event.message);
|
|
223
|
-
}
|
|
224
|
-
else if (event.error) {
|
|
226
|
+
} else if (event.error) {
|
|
225
227
|
this.fireError(event.error);
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
+
} else {
|
|
228
229
|
this.fireClose();
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
readMessage(message: any) {
|
|
234
|
-
if (this.state ===
|
|
235
|
+
if (this.state === "initial") {
|
|
235
236
|
this.events.splice(0, 0, { message });
|
|
236
|
-
}
|
|
237
|
-
else if (this.state === 'listening') {
|
|
237
|
+
} else if (this.state === "listening") {
|
|
238
238
|
const data = JSON.parse(message);
|
|
239
239
|
this.callback(data);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
fireError(error: any) {
|
|
243
|
-
if (this.state ===
|
|
243
|
+
if (this.state === "initial") {
|
|
244
244
|
this.events.splice(0, 0, { error });
|
|
245
|
-
}
|
|
246
|
-
else if (this.state === 'listening') {
|
|
245
|
+
} else if (this.state === "listening") {
|
|
247
246
|
super.fireError(error);
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
249
|
fireClose() {
|
|
251
|
-
if (this.state ===
|
|
250
|
+
if (this.state === "initial") {
|
|
252
251
|
this.events.splice(0, 0, {});
|
|
253
|
-
}
|
|
254
|
-
else if (this.state === 'listening') {
|
|
252
|
+
} else if (this.state === "listening") {
|
|
255
253
|
super.fireClose();
|
|
256
254
|
}
|
|
257
|
-
this.state =
|
|
255
|
+
this.state = "closed";
|
|
258
256
|
}
|
|
259
257
|
}
|
|
@@ -4,23 +4,27 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Message } from
|
|
8
|
-
import { AbstractMessageWriter, MessageWriter } from
|
|
9
|
-
import { AbstractMessageReader, MessageReader, DataCallback } from
|
|
10
|
-
import { MessageConnection, createMessageConnection } from
|
|
11
|
-
import { ConsoleLogger } from
|
|
7
|
+
import { Message } from "vscode-jsonrpc/lib/messages";
|
|
8
|
+
import { AbstractMessageWriter, MessageWriter } from "vscode-jsonrpc/lib/messageWriter";
|
|
9
|
+
import { AbstractMessageReader, MessageReader, DataCallback } from "vscode-jsonrpc/lib/messageReader";
|
|
10
|
+
import { MessageConnection, createMessageConnection } from "vscode-jsonrpc/lib/main";
|
|
11
|
+
import { ConsoleLogger } from "vscode-ws-jsonrpc";
|
|
12
12
|
|
|
13
13
|
interface WindowMessage extends Message {
|
|
14
|
-
serviceId: string
|
|
14
|
+
serviceId: string;
|
|
15
15
|
}
|
|
16
16
|
function isWindowMessage(value: any): value is WindowMessage {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
return (
|
|
18
|
+
!!value &&
|
|
19
|
+
typeof value === "object" &&
|
|
20
|
+
"jsonrpc" in value &&
|
|
21
|
+
typeof value["jsonrpc"] === "string" &&
|
|
22
|
+
"serviceId" in value &&
|
|
23
|
+
typeof value["serviceId"] === "string"
|
|
24
|
+
);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export class WindowMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
|
23
|
-
|
|
24
28
|
constructor(readonly serviceId: string, readonly window: Window, readonly targetOrigin: string) {
|
|
25
29
|
super();
|
|
26
30
|
}
|
|
@@ -29,44 +33,50 @@ export class WindowMessageWriter extends AbstractMessageWriter implements Messag
|
|
|
29
33
|
const { serviceId } = this;
|
|
30
34
|
this.window.postMessage(Object.assign(msg, { serviceId }), this.targetOrigin);
|
|
31
35
|
}
|
|
32
|
-
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
export class WindowMessageReader extends AbstractMessageReader implements MessageReader {
|
|
36
|
-
|
|
37
39
|
protected callback?: DataCallback;
|
|
38
40
|
protected readonly buffer: Message[] = [];
|
|
39
41
|
|
|
40
42
|
constructor(readonly serviceId: string, readonly sourceOrigin: string) {
|
|
41
43
|
super();
|
|
42
|
-
window.addEventListener(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
window.addEventListener(
|
|
45
|
+
"message",
|
|
46
|
+
(event) => {
|
|
47
|
+
if (this.sourceOrigin !== "*" && event.origin !== this.sourceOrigin) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!isWindowMessage(event.data) || event.data.serviceId !== this.serviceId) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (this.callback) {
|
|
54
|
+
this.callback(event.data);
|
|
55
|
+
} else {
|
|
56
|
+
this.buffer.push(event.data);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
false,
|
|
60
|
+
);
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
listen(callback: DataCallback): void {
|
|
58
64
|
let message;
|
|
59
|
-
while (message = this.buffer.pop()) {
|
|
65
|
+
while ((message = this.buffer.pop())) {
|
|
60
66
|
callback(message);
|
|
61
67
|
}
|
|
62
68
|
Object.freeze(this.buffer);
|
|
63
69
|
this.callback = callback;
|
|
64
70
|
}
|
|
65
|
-
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
export function createWindowMessageConnection(
|
|
73
|
+
export function createWindowMessageConnection(
|
|
74
|
+
serviceId: string,
|
|
75
|
+
window: Window,
|
|
76
|
+
sourceOrigin: string,
|
|
77
|
+
targetOrigin = sourceOrigin,
|
|
78
|
+
): MessageConnection {
|
|
69
79
|
const reader = new WindowMessageReader(serviceId, sourceOrigin);
|
|
70
80
|
const writer = new WindowMessageWriter(serviceId, window, targetOrigin);
|
|
71
81
|
return createMessageConnection(reader, writer, new ConsoleLogger());
|
|
72
|
-
}
|
|
82
|
+
}
|
|
@@ -4,94 +4,93 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { injectable } from
|
|
8
|
-
import * as prometheusClient from
|
|
7
|
+
import { injectable } from "inversify";
|
|
8
|
+
import * as prometheusClient from "prom-client";
|
|
9
9
|
|
|
10
|
-
type GrpcMethodType =
|
|
10
|
+
type GrpcMethodType = "unary" | "client_stream" | "server_stream" | "bidi_stream";
|
|
11
11
|
export interface IGrpcCallMetricsLabels {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
service: string;
|
|
13
|
+
method: string;
|
|
14
|
+
type: GrpcMethodType;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface IGrpcCallMetricsLabelsWithCode extends IGrpcCallMetricsLabels {
|
|
18
|
-
|
|
18
|
+
code: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const IClientCallMetrics = Symbol("IClientCallMetrics");
|
|
22
22
|
|
|
23
23
|
export interface IClientCallMetrics {
|
|
24
|
-
|
|
25
|
-
sent(labels: IGrpcCallMetricsLabels)
|
|
26
|
-
received(labels: IGrpcCallMetricsLabels)
|
|
27
|
-
handled(labels: IGrpcCallMetricsLabelsWithCode)
|
|
24
|
+
started(labels: IGrpcCallMetricsLabels): void;
|
|
25
|
+
sent(labels: IGrpcCallMetricsLabels): void;
|
|
26
|
+
received(labels: IGrpcCallMetricsLabels): void;
|
|
27
|
+
handled(labels: IGrpcCallMetricsLabelsWithCode): void;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
@injectable()
|
|
31
31
|
export class PrometheusClientCallMetrics implements IClientCallMetrics {
|
|
32
|
+
readonly startedCounter: prometheusClient.Counter<string>;
|
|
33
|
+
readonly sentCounter: prometheusClient.Counter<string>;
|
|
34
|
+
readonly receivedCounter: prometheusClient.Counter<string>;
|
|
35
|
+
readonly handledCounter: prometheusClient.Counter<string>;
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
constructor() {
|
|
38
|
+
this.startedCounter = new prometheusClient.Counter({
|
|
39
|
+
name: "grpc_client_started_total",
|
|
40
|
+
help: "Total number of RPCs started on the client.",
|
|
41
|
+
labelNames: ["grpc_service", "grpc_method", "grpc_type"],
|
|
42
|
+
registers: [prometheusClient.register],
|
|
43
|
+
});
|
|
44
|
+
this.sentCounter = new prometheusClient.Counter({
|
|
45
|
+
name: "grpc_client_msg_sent_total",
|
|
46
|
+
help: " Total number of gRPC stream messages sent by the client.",
|
|
47
|
+
labelNames: ["grpc_service", "grpc_method", "grpc_type"],
|
|
48
|
+
registers: [prometheusClient.register],
|
|
49
|
+
});
|
|
50
|
+
this.receivedCounter = new prometheusClient.Counter({
|
|
51
|
+
name: "grpc_client_msg_received_total",
|
|
52
|
+
help: "Total number of RPC stream messages received by the client.",
|
|
53
|
+
labelNames: ["grpc_service", "grpc_method", "grpc_type"],
|
|
54
|
+
registers: [prometheusClient.register],
|
|
55
|
+
});
|
|
56
|
+
this.handledCounter = new prometheusClient.Counter({
|
|
57
|
+
name: "grpc_client_handled_total",
|
|
58
|
+
help: "Total number of RPCs completed by the client, regardless of success or failure.",
|
|
59
|
+
labelNames: ["grpc_service", "grpc_method", "grpc_type", "grpc_code"],
|
|
60
|
+
registers: [prometheusClient.register],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
37
63
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
started(labels: IGrpcCallMetricsLabels): void {
|
|
65
|
+
this.startedCounter.inc({
|
|
66
|
+
grpc_service: labels.service,
|
|
67
|
+
grpc_method: labels.method,
|
|
68
|
+
grpc_type: labels.type,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
sent(labels: IGrpcCallMetricsLabels): void {
|
|
73
|
+
this.sentCounter.inc({
|
|
74
|
+
grpc_service: labels.service,
|
|
75
|
+
grpc_method: labels.method,
|
|
76
|
+
grpc_type: labels.type,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
received(labels: IGrpcCallMetricsLabels): void {
|
|
81
|
+
this.receivedCounter.inc({
|
|
82
|
+
grpc_service: labels.service,
|
|
83
|
+
grpc_method: labels.method,
|
|
84
|
+
grpc_type: labels.type,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
80
87
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
}
|
|
88
|
+
handled(labels: IGrpcCallMetricsLabelsWithCode): void {
|
|
89
|
+
this.handledCounter.inc({
|
|
90
|
+
grpc_service: labels.service,
|
|
91
|
+
grpc_method: labels.method,
|
|
92
|
+
grpc_type: labels.type,
|
|
93
|
+
grpc_code: labels.code,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
97
96
|
}
|
package/src/messaging/error.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
7
|
export namespace ErrorCodes {
|
|
8
|
+
// 400 Unauthorized
|
|
9
|
+
export const BAD_REQUEST = 400;
|
|
10
|
+
|
|
10
11
|
// 401 Unauthorized
|
|
11
12
|
export const NOT_AUTHENTICATED = 401;
|
|
12
13
|
|
|
@@ -61,6 +62,9 @@ export namespace ErrorCodes {
|
|
|
61
62
|
// 490 Too Many Running Workspace
|
|
62
63
|
export const TOO_MANY_RUNNING_WORKSPACES = 490;
|
|
63
64
|
|
|
65
|
+
// 500 Internal Server Error
|
|
66
|
+
export const INTERNAL_SERVER_ERROR = 500;
|
|
67
|
+
|
|
64
68
|
// 501 EE Feature
|
|
65
69
|
export const EE_FEATURE = 501;
|
|
66
70
|
|
|
@@ -81,4 +85,4 @@ export namespace ErrorCodes {
|
|
|
81
85
|
|
|
82
86
|
// 640 Headless logs are not available (yet)
|
|
83
87
|
export const HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
|
|
84
|
-
}
|
|
88
|
+
}
|
package/src/messaging/handler.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { MessageConnection } from "vscode-jsonrpc";
|
|
9
9
|
|
|
10
|
-
export const ConnectionHandler = Symbol(
|
|
10
|
+
export const ConnectionHandler = Symbol("ConnectionHandler");
|
|
11
11
|
|
|
12
12
|
export interface ConnectionHandler {
|
|
13
13
|
readonly path: string;
|
|
@@ -18,10 +18,10 @@ export interface ConnectionEventHandler {
|
|
|
18
18
|
/**
|
|
19
19
|
* Called when the transport underpinning the connection got closed
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
onTransportDidClose(): void;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Called when the transport underpinning the connection is (re-)opened
|
|
25
|
+
*/
|
|
26
|
+
onTransportDidOpen(): void;
|
|
27
27
|
}
|
|
@@ -10,7 +10,7 @@ import { IWebSocket } from "vscode-ws-jsonrpc";
|
|
|
10
10
|
|
|
11
11
|
export function toIWebSocket(ws: ws) {
|
|
12
12
|
return <IWebSocket>{
|
|
13
|
-
send: content => {
|
|
13
|
+
send: (content) => {
|
|
14
14
|
if (ws.readyState >= ws.CLOSING) {
|
|
15
15
|
// ws is already CLOSING/CLOSED, send() would just return an error.
|
|
16
16
|
return;
|
|
@@ -18,23 +18,23 @@ export function toIWebSocket(ws: ws) {
|
|
|
18
18
|
|
|
19
19
|
// in general send-errors should trigger an 'error' event already, we just make sure it actually happens.
|
|
20
20
|
try {
|
|
21
|
-
ws.send(content, err => {
|
|
21
|
+
ws.send(content, (err) => {
|
|
22
22
|
if (!err) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
ws.emit(
|
|
25
|
+
ws.emit("error", err);
|
|
26
26
|
});
|
|
27
27
|
} catch (err) {
|
|
28
|
-
ws.emit(
|
|
28
|
+
ws.emit("error", err);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
onMessage: cb => ws.on(
|
|
32
|
-
onError: cb => ws.on(
|
|
33
|
-
onClose: cb => ws.on(
|
|
31
|
+
onMessage: (cb) => ws.on("message", cb),
|
|
32
|
+
onError: (cb) => ws.on("error", cb),
|
|
33
|
+
onClose: (cb) => ws.on("close", cb),
|
|
34
34
|
dispose: () => {
|
|
35
35
|
if (ws.readyState < ws.CLOSING) {
|
|
36
36
|
ws.close();
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
39
|
};
|
|
40
40
|
}
|