@gitpod/gitpod-protocol 0.1.5-patch-1.2 → 0.1.5-pavel-pvc-feat.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 +155 -0
- package/lib/accounting-protocol.d.ts.map +1 -0
- package/lib/accounting-protocol.js +100 -0
- package/lib/accounting-protocol.js.map +1 -0
- package/lib/admin-protocol.d.ts +32 -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/auth.d.ts.map +1 -1
- 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 +109 -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.d.ts.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.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +25 -26
- 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 +29 -37
- 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 +30 -44
- 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 +31 -38
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +2 -3
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +24 -25
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +26 -42
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +145 -142
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +165 -32
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +176 -265
- 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 +6 -8
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +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 +16 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- 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/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.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 +184 -34
- 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 +42 -59
- 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 +4 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +8 -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/handler.js +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 +24 -60
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +3 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +75 -162
- 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 +10 -3
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +41 -31
- 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 +605 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +163 -82
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +180 -199
- 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 +75 -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 +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/typings/globals.d.ts +2 -2
- package/lib/typings/globals.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/lib/util/async-iterator.js +57 -135
- 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 +11 -11
- 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.d.ts.map +1 -1
- package/lib/util/disposable.js +27 -40
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +63 -77
- 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 +27 -47
- 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 +460 -497
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +61 -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 +41 -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 +108 -109
- 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 +113 -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 +125 -129
- 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 +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 +147 -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.d.ts.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +28 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts.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 +52 -6
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +199 -64
- 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.d.ts +7 -7
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +10 -12
- 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 +31 -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.d.ts.map +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 +231 -0
- package/src/admin-protocol.ts +70 -19
- package/src/analytics.ts +52 -0
- package/src/auth.ts +2 -2
- package/src/context-url.spec.ts +67 -0
- package/src/context-url.ts +109 -0
- package/src/email-protocol.ts +5 -7
- 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 +18 -18
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +315 -103
- package/src/headless-workspace-log.ts +12 -14
- package/src/ide-frontend-service.ts +2 -2
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +16 -10
- package/src/installation-admin-protocol.ts +42 -0
- package/src/license-protocol.ts +5 -6
- package/src/messaging/browser/connection.ts +197 -18
- package/src/messaging/browser/window-connection.ts +39 -29
- package/src/messaging/client-call-metrics.ts +96 -0
- package/src/messaging/error.ts +12 -5
- package/src/messaging/handler.ts +13 -1
- package/src/messaging/node/connection.ts +23 -70
- package/src/messaging/proxy-factory.ts +35 -34
- package/src/oss-allowlist.ts +15 -0
- package/src/payment-protocol.ts +20 -0
- package/src/permission.ts +42 -33
- package/src/plans.ts +679 -0
- package/src/protocol.ts +378 -273
- package/src/snapshot-url.spec.ts +27 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +123 -0
- package/src/teams-projects-protocol.ts +147 -0
- package/src/typings/globals.ts +4 -4
- package/src/util/analytics.ts +109 -0
- 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 +11 -8
- package/src/util/generate-workspace-id.spec.ts +29 -9
- package/src/util/generate-workspace-id.ts +458 -438
- package/src/util/gitpod-cookie.ts +38 -0
- package/src/util/gitpod-host-url.spec.ts +59 -8
- package/src/util/gitpod-host-url.ts +52 -40
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +145 -71
- package/src/util/make-link.ts +6 -7
- package/src/util/parse-workspace-id.spec.ts +37 -8
- package/src/util/parse-workspace-id.ts +32 -7
- package/src/util/queue.spec.ts +28 -26
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +6 -8
- package/src/util/skip-if.ts +10 -7
- package/src/util/timeutil.spec.ts +14 -15
- package/src/util/timeutil.ts +19 -15
- package/src/util/tracing.spec.ts +88 -0
- package/src/util/tracing.ts +202 -31
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/workspace-cluster.ts +107 -0
- package/src/workspace-instance.ts +66 -30
- package/src/wsready.ts +3 -3
- 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
package/src/gitpod-service.ts
CHANGED
|
@@ -5,26 +5,60 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
User,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
User,
|
|
9
|
+
WorkspaceInfo,
|
|
10
|
+
WorkspaceCreationResult,
|
|
11
|
+
WorkspaceInstanceUser,
|
|
12
|
+
WhitelistedRepository,
|
|
13
|
+
WorkspaceImageBuild,
|
|
14
|
+
AuthProviderInfo,
|
|
15
|
+
CreateWorkspaceMode,
|
|
16
|
+
Token,
|
|
17
|
+
UserEnvVarValue,
|
|
18
|
+
Terms,
|
|
19
|
+
Configuration,
|
|
20
|
+
UserInfo,
|
|
21
|
+
GitpodTokenType,
|
|
22
|
+
GitpodToken,
|
|
23
|
+
AuthProviderEntry,
|
|
24
|
+
GuessGitTokenScopesParams,
|
|
25
|
+
GuessedGitTokenScopes,
|
|
26
|
+
ProjectEnvVar,
|
|
27
|
+
} from "./protocol";
|
|
28
|
+
import {
|
|
29
|
+
Team,
|
|
30
|
+
TeamMemberInfo,
|
|
31
|
+
TeamMembershipInvite,
|
|
32
|
+
Project,
|
|
33
|
+
TeamMemberRole,
|
|
34
|
+
PrebuildWithStatus,
|
|
35
|
+
StartPrebuildResult,
|
|
36
|
+
PartialProject,
|
|
37
|
+
} from "./teams-projects-protocol";
|
|
38
|
+
import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
|
|
39
|
+
import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
|
|
40
|
+
import { HeadlessLogUrls } from "./headless-workspace-log";
|
|
41
|
+
import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from "./workspace-instance";
|
|
42
|
+
import { AdminServer } from "./admin-protocol";
|
|
43
|
+
import { GitpodHostUrl } from "./util/gitpod-host-url";
|
|
44
|
+
import { WebSocketConnectionProvider } from "./messaging/browser/connection";
|
|
45
|
+
import { PermissionName } from "./permission";
|
|
46
|
+
import { LicenseService } from "./license-protocol";
|
|
47
|
+
import { Emitter } from "./util/event";
|
|
48
|
+
import { AccountStatement, CreditAlert } from "./accounting-protocol";
|
|
49
|
+
import { GithubUpgradeURL, PlanCoupon } from "./payment-protocol";
|
|
50
|
+
import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from "./team-subscription-protocol";
|
|
51
|
+
import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
|
|
52
|
+
import { IDEServer } from "./ide-protocol";
|
|
53
|
+
import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
|
|
23
54
|
|
|
24
55
|
export interface GitpodClient {
|
|
25
56
|
onInstanceUpdate(instance: WorkspaceInstance): void;
|
|
26
57
|
onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
|
|
27
|
-
|
|
58
|
+
|
|
59
|
+
onPrebuildUpdate(update: PrebuildWithStatus): void;
|
|
60
|
+
|
|
61
|
+
onCreditAlert(creditAlert: CreditAlert): void;
|
|
28
62
|
|
|
29
63
|
//#region propagating reconnection to iframe
|
|
30
64
|
notifyDidOpenConnection(): void;
|
|
@@ -32,19 +66,19 @@ export interface GitpodClient {
|
|
|
32
66
|
//#endregion
|
|
33
67
|
}
|
|
34
68
|
|
|
35
|
-
export const GitpodServer = Symbol(
|
|
36
|
-
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService {
|
|
69
|
+
export const GitpodServer = Symbol("GitpodServer");
|
|
70
|
+
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
|
|
37
71
|
// User related API
|
|
38
72
|
getLoggedInUser(): Promise<User>;
|
|
39
73
|
getTerms(): Promise<Terms>;
|
|
40
74
|
updateLoggedInUser(user: Partial<User>): Promise<User>;
|
|
41
75
|
getAuthProviders(): Promise<AuthProviderInfo[]>;
|
|
42
76
|
getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
|
|
43
|
-
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<
|
|
77
|
+
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
|
|
44
78
|
deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
|
|
45
|
-
getBranding(): Promise<Branding>;
|
|
46
79
|
getConfiguration(): Promise<Configuration>;
|
|
47
80
|
getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
|
|
81
|
+
getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
|
|
48
82
|
/**
|
|
49
83
|
* @deprecated
|
|
50
84
|
*/
|
|
@@ -58,8 +92,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
58
92
|
getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
|
|
59
93
|
getWorkspaceUsers(workspaceId: string): Promise<WorkspaceInstanceUser[]>;
|
|
60
94
|
getFeaturedRepositories(): Promise<WhitelistedRepository[]>;
|
|
95
|
+
getSuggestedContextURLs(): Promise<string[]>;
|
|
96
|
+
/**
|
|
97
|
+
* **Security:**
|
|
98
|
+
* Sensitive information like an owner token is erased, since it allows access for all team members.
|
|
99
|
+
* If you need to access an owner token use `getOwnerToken` instead.
|
|
100
|
+
*/
|
|
61
101
|
getWorkspace(id: string): Promise<WorkspaceInfo>;
|
|
62
102
|
isWorkspaceOwner(workspaceId: string): Promise<boolean>;
|
|
103
|
+
getOwnerToken(workspaceId: string): Promise<string>;
|
|
63
104
|
|
|
64
105
|
/**
|
|
65
106
|
* Creates and starts a workspace for the given context URL.
|
|
@@ -76,8 +117,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
76
117
|
updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
|
|
77
118
|
sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
|
|
78
119
|
watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
|
|
79
|
-
watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
|
|
80
120
|
isPrebuildDone(pwsid: string): Promise<boolean>;
|
|
121
|
+
getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
|
|
81
122
|
|
|
82
123
|
// Workspace timeout
|
|
83
124
|
setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
|
|
@@ -91,22 +132,55 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
91
132
|
openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
|
|
92
133
|
closePort(workspaceId: string, port: number): Promise<void>;
|
|
93
134
|
|
|
94
|
-
// User messages
|
|
95
|
-
getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
|
|
96
|
-
updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
|
|
97
|
-
|
|
98
135
|
// User storage
|
|
99
136
|
getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
|
|
100
137
|
updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
|
|
101
138
|
|
|
102
|
-
//
|
|
139
|
+
// User env vars
|
|
103
140
|
getEnvVars(): Promise<UserEnvVarValue[]>;
|
|
141
|
+
getAllEnvVars(): Promise<UserEnvVarValue[]>;
|
|
104
142
|
setEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
105
143
|
deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
106
144
|
|
|
145
|
+
// Teams
|
|
146
|
+
getTeams(): Promise<Team[]>;
|
|
147
|
+
getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
|
|
148
|
+
createTeam(name: string): Promise<Team>;
|
|
149
|
+
joinTeam(inviteId: string): Promise<Team>;
|
|
150
|
+
setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
|
|
151
|
+
removeTeamMember(teamId: string, userId: string): Promise<void>;
|
|
152
|
+
getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
|
|
153
|
+
resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
|
|
154
|
+
deleteTeam(teamId: string, userId: string): Promise<void>;
|
|
155
|
+
|
|
156
|
+
// Admin Settings
|
|
157
|
+
adminGetSettings(): Promise<InstallationAdminSettings>;
|
|
158
|
+
adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
|
|
159
|
+
adminGetTelemetryData(): Promise<TelemetryData>;
|
|
160
|
+
|
|
161
|
+
// Projects
|
|
162
|
+
getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
|
|
163
|
+
createProject(params: CreateProjectParams): Promise<Project>;
|
|
164
|
+
deleteProject(projectId: string): Promise<void>;
|
|
165
|
+
getTeamProjects(teamId: string): Promise<Project[]>;
|
|
166
|
+
getUserProjects(): Promise<Project[]>;
|
|
167
|
+
getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
|
|
168
|
+
findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
|
|
169
|
+
triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
|
|
170
|
+
cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
|
|
171
|
+
fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
|
|
172
|
+
guessProjectConfiguration(projectId: string): Promise<string | undefined>;
|
|
173
|
+
fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
174
|
+
guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
175
|
+
setProjectConfiguration(projectId: string, configString: string): Promise<void>;
|
|
176
|
+
updateProjectPartial(partialProject: PartialProject): Promise<void>;
|
|
177
|
+
setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
|
|
178
|
+
getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
|
|
179
|
+
deleteProjectEnvironmentVariable(variableId: string): Promise<void>;
|
|
180
|
+
|
|
107
181
|
// content service
|
|
108
|
-
getContentBlobUploadUrl(name: string): Promise<string
|
|
109
|
-
getContentBlobDownloadUrl(name: string): Promise<string
|
|
182
|
+
getContentBlobUploadUrl(name: string): Promise<string>;
|
|
183
|
+
getContentBlobDownloadUrl(name: string): Promise<string>;
|
|
110
184
|
|
|
111
185
|
// Gitpod token
|
|
112
186
|
getGitpodTokens(): Promise<GitpodToken[]>;
|
|
@@ -118,10 +192,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
118
192
|
registerGithubApp(installationId: string): Promise<void>;
|
|
119
193
|
|
|
120
194
|
/**
|
|
121
|
-
* Stores a new snapshot for the given workspace and bucketId
|
|
195
|
+
* Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
|
|
122
196
|
* @return the snapshot id
|
|
123
197
|
*/
|
|
124
198
|
takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
|
|
199
|
+
/**
|
|
200
|
+
*
|
|
201
|
+
* @param snapshotId
|
|
202
|
+
*/
|
|
203
|
+
waitForSnapshot(snapshotId: string): Promise<void>;
|
|
125
204
|
|
|
126
205
|
/**
|
|
127
206
|
* Returns the list of snapshots that exist for a workspace.
|
|
@@ -138,51 +217,150 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
138
217
|
*/
|
|
139
218
|
getLayout(workspaceId: string): Promise<string | undefined>;
|
|
140
219
|
|
|
220
|
+
guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* gitpod.io concerns
|
|
224
|
+
*/
|
|
225
|
+
isStudent(): Promise<boolean>;
|
|
226
|
+
/**
|
|
227
|
+
*
|
|
228
|
+
*/
|
|
229
|
+
getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
|
|
230
|
+
getRemainingUsageHours(): Promise<number>;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
*/
|
|
235
|
+
getChargebeeSiteId(): Promise<string>;
|
|
236
|
+
createPortalSession(): Promise<{}>;
|
|
237
|
+
checkout(planId: string, planQuantity?: number): Promise<{}>;
|
|
238
|
+
getAvailableCoupons(): Promise<PlanCoupon[]>;
|
|
239
|
+
getAppliedCoupons(): Promise<PlanCoupon[]>;
|
|
240
|
+
|
|
241
|
+
getShowPaymentUI(): Promise<boolean>;
|
|
242
|
+
isChargebeeCustomer(): Promise<boolean>;
|
|
243
|
+
|
|
244
|
+
subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
245
|
+
subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
246
|
+
subscriptionCancel(subscriptionId: string): Promise<void>;
|
|
247
|
+
subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
|
|
248
|
+
|
|
249
|
+
tsGet(): Promise<TeamSubscription[]>;
|
|
250
|
+
tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
|
|
251
|
+
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
|
|
252
|
+
tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
|
|
253
|
+
tsAssignSlot(
|
|
254
|
+
teamSubscriptionId: string,
|
|
255
|
+
teamSubscriptionSlotId: string,
|
|
256
|
+
identityStr: string | undefined,
|
|
257
|
+
): Promise<void>;
|
|
258
|
+
tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
|
|
259
|
+
tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
260
|
+
tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
261
|
+
|
|
262
|
+
getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Analytics
|
|
266
|
+
*/
|
|
267
|
+
trackEvent(event: RemoteTrackMessage): Promise<void>;
|
|
268
|
+
trackLocation(event: RemotePageMessage): Promise<void>;
|
|
269
|
+
identifyUser(event: RemoteIdentifyMessage): Promise<void>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface RateLimiterError {
|
|
273
|
+
method?: string;
|
|
274
|
+
|
|
141
275
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
276
|
+
* Retry after this many seconds, earliest.
|
|
277
|
+
* cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
144
278
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
279
|
+
retryAfter: number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface CreateProjectParams {
|
|
283
|
+
name: string;
|
|
284
|
+
slug?: string;
|
|
285
|
+
account: string;
|
|
286
|
+
provider: string;
|
|
287
|
+
cloneUrl: string;
|
|
288
|
+
teamId?: string;
|
|
289
|
+
userId?: string;
|
|
290
|
+
appInstallationId: string;
|
|
291
|
+
}
|
|
292
|
+
export interface FindPrebuildsParams {
|
|
293
|
+
projectId: string;
|
|
294
|
+
branch?: string;
|
|
295
|
+
latest?: boolean;
|
|
296
|
+
prebuildId?: string;
|
|
297
|
+
// default: 30
|
|
298
|
+
limit?: number;
|
|
299
|
+
}
|
|
300
|
+
export interface GetProviderRepositoriesParams {
|
|
301
|
+
provider: string;
|
|
302
|
+
hints?: { installationId: string } | object;
|
|
303
|
+
}
|
|
304
|
+
export interface ProviderRepository {
|
|
305
|
+
name: string;
|
|
306
|
+
path?: string;
|
|
307
|
+
account: string;
|
|
308
|
+
accountAvatarUrl: string;
|
|
309
|
+
cloneUrl: string;
|
|
310
|
+
updatedAt?: string;
|
|
311
|
+
installationId?: number;
|
|
312
|
+
installationUpdatedAt?: string;
|
|
313
|
+
|
|
314
|
+
inUse?: { userName: string };
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface ClientHeaderFields {
|
|
318
|
+
ip?: string;
|
|
319
|
+
userAgent?: string;
|
|
320
|
+
dnt?: string;
|
|
321
|
+
clientRegion?: string;
|
|
149
322
|
}
|
|
150
323
|
|
|
151
324
|
export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
|
|
152
325
|
|
|
153
|
-
export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
326
|
+
export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
327
|
+
methods: Partial<JsonRpcProxy<S>>,
|
|
328
|
+
): GitpodServiceImpl<C, S> {
|
|
154
329
|
return new GitpodServiceImpl<C, S>(createServerMock(methods));
|
|
155
|
-
}
|
|
330
|
+
};
|
|
156
331
|
|
|
157
|
-
export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
158
|
-
methods
|
|
159
|
-
|
|
332
|
+
export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
333
|
+
methods: Partial<JsonRpcProxy<S>>,
|
|
334
|
+
): JsonRpcProxy<S> {
|
|
335
|
+
methods.setClient = methods.setClient || (() => {});
|
|
336
|
+
methods.dispose = methods.dispose || (() => {});
|
|
160
337
|
return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
|
|
338
|
+
// @ts-ignore
|
|
161
339
|
get: (target: S, property: keyof S) => {
|
|
162
340
|
const result = target[property];
|
|
163
341
|
if (!result) {
|
|
164
342
|
throw new Error(`Method ${property} not implemented`);
|
|
165
343
|
}
|
|
166
344
|
return result;
|
|
167
|
-
}
|
|
345
|
+
},
|
|
168
346
|
});
|
|
169
|
-
}
|
|
347
|
+
};
|
|
170
348
|
|
|
171
349
|
type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
|
|
172
350
|
export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
|
|
173
351
|
|
|
174
352
|
export interface SetWorkspaceTimeoutResult {
|
|
175
|
-
resetTimeoutOnWorkspaces: string[]
|
|
353
|
+
resetTimeoutOnWorkspaces: string[];
|
|
176
354
|
}
|
|
177
355
|
|
|
178
356
|
export interface GetWorkspaceTimeoutResult {
|
|
179
|
-
duration: WorkspaceTimeoutDuration
|
|
180
|
-
canChange: boolean
|
|
357
|
+
duration: WorkspaceTimeoutDuration;
|
|
358
|
+
canChange: boolean;
|
|
181
359
|
}
|
|
182
360
|
|
|
183
361
|
export interface StartWorkspaceResult {
|
|
184
|
-
instanceID: string
|
|
185
|
-
workspaceURL?: string
|
|
362
|
+
instanceID: string;
|
|
363
|
+
workspaceURL?: string;
|
|
186
364
|
}
|
|
187
365
|
|
|
188
366
|
export namespace GitpodServer {
|
|
@@ -190,6 +368,8 @@ export namespace GitpodServer {
|
|
|
190
368
|
limit?: number;
|
|
191
369
|
searchString?: string;
|
|
192
370
|
pinnedOnly?: boolean;
|
|
371
|
+
projectId?: string | string[];
|
|
372
|
+
includeWithoutProject?: boolean;
|
|
193
373
|
}
|
|
194
374
|
export interface GetAccountStatementOptions {
|
|
195
375
|
date?: string;
|
|
@@ -197,6 +377,7 @@ export namespace GitpodServer {
|
|
|
197
377
|
export interface CreateWorkspaceOptions {
|
|
198
378
|
contextUrl: string;
|
|
199
379
|
mode?: CreateWorkspaceMode;
|
|
380
|
+
forceDefaultConfig?: boolean;
|
|
200
381
|
}
|
|
201
382
|
export interface StartWorkspaceOptions {
|
|
202
383
|
forceDefaultImage: boolean;
|
|
@@ -204,13 +385,8 @@ export namespace GitpodServer {
|
|
|
204
385
|
export interface TakeSnapshotOptions {
|
|
205
386
|
workspaceId: string;
|
|
206
387
|
layoutData?: string;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
readonly releaseNotes?: boolean;
|
|
210
|
-
readonly workspaceInstanceId: string;
|
|
211
|
-
}
|
|
212
|
-
export interface UpdateUserMessagesOptions {
|
|
213
|
-
readonly messageIds: string[];
|
|
388
|
+
/* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
|
|
389
|
+
dontWait?: boolean;
|
|
214
390
|
}
|
|
215
391
|
export interface GetUserStorageResourceOptions {
|
|
216
392
|
readonly uri: string;
|
|
@@ -228,23 +404,23 @@ export namespace GitpodServer {
|
|
|
228
404
|
readonly roundTripTime?: number;
|
|
229
405
|
}
|
|
230
406
|
export interface UpdateOwnAuthProviderParams {
|
|
231
|
-
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
|
|
407
|
+
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
|
|
232
408
|
}
|
|
233
409
|
export interface DeleteOwnAuthProviderParams {
|
|
234
|
-
readonly id: string
|
|
410
|
+
readonly id: string;
|
|
235
411
|
}
|
|
236
412
|
export type AdmissionLevel = "owner" | "everyone";
|
|
237
413
|
export type PinAction = "pin" | "unpin" | "toggle";
|
|
238
414
|
export interface GenerateNewGitpodTokenOptions {
|
|
239
|
-
name?: string
|
|
240
|
-
type: GitpodTokenType
|
|
241
|
-
scopes?: string[]
|
|
415
|
+
name?: string;
|
|
416
|
+
type: GitpodTokenType;
|
|
417
|
+
scopes?: string[];
|
|
242
418
|
}
|
|
243
419
|
}
|
|
244
420
|
|
|
245
|
-
export const GitpodServerPath =
|
|
421
|
+
export const GitpodServerPath = "/gitpod";
|
|
246
422
|
|
|
247
|
-
export const GitpodServerProxy = Symbol(
|
|
423
|
+
export const GitpodServerProxy = Symbol("GitpodServerProxy");
|
|
248
424
|
export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
|
|
249
425
|
|
|
250
426
|
export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
|
|
@@ -252,12 +428,14 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
252
428
|
|
|
253
429
|
public registerClient(client: Partial<Client>): Disposable {
|
|
254
430
|
this.clients.push(client);
|
|
255
|
-
const index = this.clients.length;
|
|
256
431
|
return {
|
|
257
432
|
dispose: () => {
|
|
258
|
-
this.clients.
|
|
259
|
-
|
|
260
|
-
|
|
433
|
+
const index = this.clients.indexOf(client);
|
|
434
|
+
if (index > -1) {
|
|
435
|
+
this.clients.splice(index, 1);
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
};
|
|
261
439
|
}
|
|
262
440
|
|
|
263
441
|
onInstanceUpdate(instance: WorkspaceInstance): void {
|
|
@@ -266,31 +444,34 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
266
444
|
try {
|
|
267
445
|
client.onInstanceUpdate(instance);
|
|
268
446
|
} catch (error) {
|
|
269
|
-
console.error(error)
|
|
447
|
+
console.error(error);
|
|
270
448
|
}
|
|
271
449
|
}
|
|
272
450
|
}
|
|
273
451
|
}
|
|
274
452
|
|
|
275
|
-
|
|
453
|
+
onPrebuildUpdate(update: PrebuildWithStatus): void {
|
|
276
454
|
for (const client of this.clients) {
|
|
277
|
-
if (client.
|
|
455
|
+
if (client.onPrebuildUpdate) {
|
|
278
456
|
try {
|
|
279
|
-
client.
|
|
457
|
+
client.onPrebuildUpdate(update);
|
|
280
458
|
} catch (error) {
|
|
281
|
-
console.error(error)
|
|
459
|
+
console.error(error);
|
|
282
460
|
}
|
|
283
461
|
}
|
|
284
462
|
}
|
|
285
463
|
}
|
|
286
464
|
|
|
287
|
-
|
|
465
|
+
onWorkspaceImageBuildLogs(
|
|
466
|
+
info: WorkspaceImageBuild.StateInfo,
|
|
467
|
+
content: WorkspaceImageBuild.LogContent | undefined,
|
|
468
|
+
): void {
|
|
288
469
|
for (const client of this.clients) {
|
|
289
|
-
if (client.
|
|
470
|
+
if (client.onWorkspaceImageBuildLogs) {
|
|
290
471
|
try {
|
|
291
|
-
client.
|
|
472
|
+
client.onWorkspaceImageBuildLogs(info, content);
|
|
292
473
|
} catch (error) {
|
|
293
|
-
console.error(error)
|
|
474
|
+
console.error(error);
|
|
294
475
|
}
|
|
295
476
|
}
|
|
296
477
|
}
|
|
@@ -302,7 +483,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
302
483
|
try {
|
|
303
484
|
client.notifyDidOpenConnection();
|
|
304
485
|
} catch (error) {
|
|
305
|
-
console.error(error)
|
|
486
|
+
console.error(error);
|
|
306
487
|
}
|
|
307
488
|
}
|
|
308
489
|
}
|
|
@@ -314,17 +495,28 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
314
495
|
try {
|
|
315
496
|
client.notifyDidCloseConnection();
|
|
316
497
|
} catch (error) {
|
|
317
|
-
console.error(error)
|
|
498
|
+
console.error(error);
|
|
318
499
|
}
|
|
319
500
|
}
|
|
320
501
|
}
|
|
321
502
|
}
|
|
322
503
|
|
|
504
|
+
onCreditAlert(creditAlert: CreditAlert): void {
|
|
505
|
+
for (const client of this.clients) {
|
|
506
|
+
if (client.onCreditAlert) {
|
|
507
|
+
try {
|
|
508
|
+
client.onCreditAlert(creditAlert);
|
|
509
|
+
} catch (error) {
|
|
510
|
+
console.error(error);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
323
515
|
}
|
|
324
516
|
|
|
325
517
|
export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
|
|
326
518
|
|
|
327
|
-
const hasWindow =
|
|
519
|
+
const hasWindow = typeof window !== "undefined";
|
|
328
520
|
const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
329
521
|
unknown: 0,
|
|
330
522
|
preparing: 1,
|
|
@@ -334,44 +526,41 @@ const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
|
334
526
|
running: 5,
|
|
335
527
|
interrupted: 6,
|
|
336
528
|
stopping: 7,
|
|
337
|
-
stopped: 8
|
|
529
|
+
stopped: 8,
|
|
338
530
|
};
|
|
339
531
|
export class WorkspaceInstanceUpdateListener {
|
|
340
532
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
|
341
533
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
342
534
|
|
|
343
|
-
private source:
|
|
535
|
+
private source: "sync" | "update" = "sync";
|
|
344
536
|
|
|
345
537
|
get info(): WorkspaceInfo {
|
|
346
538
|
return this._info;
|
|
347
539
|
}
|
|
348
540
|
|
|
349
|
-
constructor(
|
|
350
|
-
private readonly service: GitpodService,
|
|
351
|
-
private _info: WorkspaceInfo
|
|
352
|
-
) {
|
|
541
|
+
constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
|
|
353
542
|
service.registerClient({
|
|
354
|
-
onInstanceUpdate: instance => {
|
|
543
|
+
onInstanceUpdate: (instance) => {
|
|
355
544
|
if (this.isOutOfOrder(instance)) {
|
|
356
545
|
return;
|
|
357
546
|
}
|
|
358
547
|
this.cancelSync();
|
|
359
548
|
this._info.latestInstance = instance;
|
|
360
|
-
this.source =
|
|
549
|
+
this.source = "update";
|
|
361
550
|
this.onDidChangeEmitter.fire(undefined);
|
|
362
551
|
},
|
|
363
552
|
notifyDidOpenConnection: () => {
|
|
364
553
|
this.sync();
|
|
365
|
-
}
|
|
554
|
+
},
|
|
366
555
|
});
|
|
367
556
|
if (hasWindow) {
|
|
368
557
|
// learn about page lifecycle here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
|
|
369
|
-
window.document.addEventListener(
|
|
370
|
-
if (window.document.visibilityState ===
|
|
558
|
+
window.document.addEventListener("visibilitychange", async () => {
|
|
559
|
+
if (window.document.visibilityState === "visible") {
|
|
371
560
|
this.sync();
|
|
372
561
|
}
|
|
373
562
|
});
|
|
374
|
-
window.addEventListener(
|
|
563
|
+
window.addEventListener("pageshow", (e) => {
|
|
375
564
|
if (e.persisted) {
|
|
376
565
|
this.sync();
|
|
377
566
|
}
|
|
@@ -399,12 +588,12 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
399
588
|
return;
|
|
400
589
|
}
|
|
401
590
|
this._info = info;
|
|
402
|
-
this.source =
|
|
591
|
+
this.source = "sync";
|
|
403
592
|
this.onDidChangeEmitter.fire(undefined);
|
|
404
593
|
} catch (e) {
|
|
405
|
-
console.error(
|
|
594
|
+
console.error("failed to sync workspace instance:", e);
|
|
406
595
|
}
|
|
407
|
-
})
|
|
596
|
+
});
|
|
408
597
|
}
|
|
409
598
|
private cancelSync(): void {
|
|
410
599
|
if (this.syncTokenSource) {
|
|
@@ -421,7 +610,7 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
421
610
|
if (instance.workspaceId !== this._info.workspace.id) {
|
|
422
611
|
return true;
|
|
423
612
|
}
|
|
424
|
-
if (this.source ===
|
|
613
|
+
if (this.source === "update") {
|
|
425
614
|
return false;
|
|
426
615
|
}
|
|
427
616
|
if (instance.id !== this.info.latestInstance?.id) {
|
|
@@ -429,14 +618,16 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
429
618
|
}
|
|
430
619
|
return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
|
|
431
620
|
}
|
|
621
|
+
}
|
|
432
622
|
|
|
623
|
+
export interface GitpodServiceOptions {
|
|
624
|
+
onReconnect?: () => void | Promise<void>;
|
|
433
625
|
}
|
|
434
626
|
|
|
435
627
|
export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
|
|
436
|
-
|
|
437
628
|
private readonly compositeClient = new GitpodCompositeClient<Client>();
|
|
438
629
|
|
|
439
|
-
constructor(public readonly server: JsonRpcProxy<Server
|
|
630
|
+
constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
|
|
440
631
|
server.setClient(this.compositeClient);
|
|
441
632
|
server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
|
|
442
633
|
server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
|
|
@@ -448,7 +639,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
448
639
|
|
|
449
640
|
private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
|
|
450
641
|
listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
|
|
451
|
-
const listener =
|
|
642
|
+
const listener =
|
|
643
|
+
this.instanceListeners.get(workspaceId) ||
|
|
452
644
|
(async () => {
|
|
453
645
|
const info = await this.server.getWorkspace(workspaceId);
|
|
454
646
|
return new WorkspaceInstanceUpdateListener(this, info);
|
|
@@ -456,13 +648,33 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
456
648
|
this.instanceListeners.set(workspaceId, listener);
|
|
457
649
|
return listener;
|
|
458
650
|
}
|
|
651
|
+
|
|
652
|
+
async reconnect(): Promise<void> {
|
|
653
|
+
if (this.options?.onReconnect) {
|
|
654
|
+
await this.options.onReconnect();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
459
657
|
}
|
|
460
658
|
|
|
461
|
-
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
659
|
+
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
|
|
660
|
+
serverUrl: string | Promise<string>,
|
|
661
|
+
) {
|
|
662
|
+
const toWsUrl = (serverUrl: string) => {
|
|
663
|
+
return new GitpodHostUrl(serverUrl).asWebsocket().withApi({ pathname: GitpodServerPath }).toString();
|
|
664
|
+
};
|
|
665
|
+
let url: string | Promise<string>;
|
|
666
|
+
if (typeof serverUrl === "string") {
|
|
667
|
+
url = toWsUrl(serverUrl);
|
|
668
|
+
} else {
|
|
669
|
+
url = serverUrl.then((url) => toWsUrl(url));
|
|
670
|
+
}
|
|
671
|
+
|
|
465
672
|
const connectionProvider = new WebSocketConnectionProvider();
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
673
|
+
let onReconnect = () => {};
|
|
674
|
+
const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
|
|
675
|
+
onListening: (socket) => {
|
|
676
|
+
onReconnect = () => socket.reconnect();
|
|
677
|
+
},
|
|
678
|
+
});
|
|
679
|
+
return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
|
|
680
|
+
}
|