@gitpod/gitpod-protocol 0.1.5-patch-2-fork.0 → 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 +10 -13
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +31 -46
- 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/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 +133 -39
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +175 -287
- 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 +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/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.map +1 -1
- package/lib/payment-protocol.js +1 -1
- package/lib/payment-protocol.js.map +1 -1
- 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 +7 -5
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +19 -16
- 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/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 +53 -57
- package/src/admin-protocol.ts +64 -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 +270 -117
- 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 +9 -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 +2 -2
- 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 +36 -24
- 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,29 +5,58 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
User,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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";
|
|
26
54
|
|
|
27
55
|
export interface GitpodClient {
|
|
28
56
|
onInstanceUpdate(instance: WorkspaceInstance): void;
|
|
29
57
|
onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
|
|
30
|
-
|
|
58
|
+
|
|
59
|
+
onPrebuildUpdate(update: PrebuildWithStatus): void;
|
|
31
60
|
|
|
32
61
|
onCreditAlert(creditAlert: CreditAlert): void;
|
|
33
62
|
|
|
@@ -37,19 +66,19 @@ export interface GitpodClient {
|
|
|
37
66
|
//#endregion
|
|
38
67
|
}
|
|
39
68
|
|
|
40
|
-
export const GitpodServer = Symbol(
|
|
41
|
-
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService {
|
|
69
|
+
export const GitpodServer = Symbol("GitpodServer");
|
|
70
|
+
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
|
|
42
71
|
// User related API
|
|
43
72
|
getLoggedInUser(): Promise<User>;
|
|
44
73
|
getTerms(): Promise<Terms>;
|
|
45
74
|
updateLoggedInUser(user: Partial<User>): Promise<User>;
|
|
46
75
|
getAuthProviders(): Promise<AuthProviderInfo[]>;
|
|
47
76
|
getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
|
|
48
|
-
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<
|
|
77
|
+
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
|
|
49
78
|
deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
|
|
50
|
-
getBranding(): Promise<Branding>;
|
|
51
79
|
getConfiguration(): Promise<Configuration>;
|
|
52
80
|
getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
|
|
81
|
+
getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
|
|
53
82
|
/**
|
|
54
83
|
* @deprecated
|
|
55
84
|
*/
|
|
@@ -63,8 +92,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
63
92
|
getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
|
|
64
93
|
getWorkspaceUsers(workspaceId: string): Promise<WorkspaceInstanceUser[]>;
|
|
65
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
|
+
*/
|
|
66
101
|
getWorkspace(id: string): Promise<WorkspaceInfo>;
|
|
67
102
|
isWorkspaceOwner(workspaceId: string): Promise<boolean>;
|
|
103
|
+
getOwnerToken(workspaceId: string): Promise<string>;
|
|
68
104
|
|
|
69
105
|
/**
|
|
70
106
|
* Creates and starts a workspace for the given context URL.
|
|
@@ -81,8 +117,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
81
117
|
updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
|
|
82
118
|
sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
|
|
83
119
|
watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
|
|
84
|
-
watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
|
|
85
120
|
isPrebuildDone(pwsid: string): Promise<boolean>;
|
|
121
|
+
getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
|
|
86
122
|
|
|
87
123
|
// Workspace timeout
|
|
88
124
|
setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
|
|
@@ -96,22 +132,55 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
96
132
|
openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
|
|
97
133
|
closePort(workspaceId: string, port: number): Promise<void>;
|
|
98
134
|
|
|
99
|
-
// User messages
|
|
100
|
-
getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
|
|
101
|
-
updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
|
|
102
|
-
|
|
103
135
|
// User storage
|
|
104
136
|
getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
|
|
105
137
|
updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
|
|
106
138
|
|
|
107
|
-
//
|
|
139
|
+
// User env vars
|
|
108
140
|
getEnvVars(): Promise<UserEnvVarValue[]>;
|
|
141
|
+
getAllEnvVars(): Promise<UserEnvVarValue[]>;
|
|
109
142
|
setEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
110
143
|
deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
111
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
|
+
|
|
112
181
|
// content service
|
|
113
|
-
getContentBlobUploadUrl(name: string): Promise<string
|
|
114
|
-
getContentBlobDownloadUrl(name: string): Promise<string
|
|
182
|
+
getContentBlobUploadUrl(name: string): Promise<string>;
|
|
183
|
+
getContentBlobDownloadUrl(name: string): Promise<string>;
|
|
115
184
|
|
|
116
185
|
// Gitpod token
|
|
117
186
|
getGitpodTokens(): Promise<GitpodToken[]>;
|
|
@@ -123,10 +192,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
123
192
|
registerGithubApp(installationId: string): Promise<void>;
|
|
124
193
|
|
|
125
194
|
/**
|
|
126
|
-
* 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`.
|
|
127
196
|
* @return the snapshot id
|
|
128
197
|
*/
|
|
129
198
|
takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
|
|
199
|
+
/**
|
|
200
|
+
*
|
|
201
|
+
* @param snapshotId
|
|
202
|
+
*/
|
|
203
|
+
waitForSnapshot(snapshotId: string): Promise<void>;
|
|
130
204
|
|
|
131
205
|
/**
|
|
132
206
|
* Returns the list of snapshots that exist for a workspace.
|
|
@@ -143,29 +217,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
143
217
|
*/
|
|
144
218
|
getLayout(workspaceId: string): Promise<string | undefined>;
|
|
145
219
|
|
|
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>;
|
|
220
|
+
guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
|
|
154
221
|
|
|
155
222
|
/**
|
|
156
223
|
* gitpod.io concerns
|
|
157
224
|
*/
|
|
158
225
|
isStudent(): Promise<boolean>;
|
|
159
|
-
getPrivateRepoTrialEndDate(): Promise<string | undefined>;
|
|
160
|
-
|
|
161
226
|
/**
|
|
162
|
-
*
|
|
227
|
+
*
|
|
163
228
|
*/
|
|
164
229
|
getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
|
|
165
230
|
getRemainingUsageHours(): Promise<number>;
|
|
166
231
|
|
|
167
232
|
/**
|
|
168
|
-
*
|
|
233
|
+
*
|
|
169
234
|
*/
|
|
170
235
|
getChargebeeSiteId(): Promise<string>;
|
|
171
236
|
createPortalSession(): Promise<{}>;
|
|
@@ -175,7 +240,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
175
240
|
|
|
176
241
|
getShowPaymentUI(): Promise<boolean>;
|
|
177
242
|
isChargebeeCustomer(): Promise<boolean>;
|
|
178
|
-
mayAccessPrivateRepo(): Promise<boolean>;
|
|
179
243
|
|
|
180
244
|
subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
181
245
|
subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
@@ -184,52 +248,119 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
184
248
|
|
|
185
249
|
tsGet(): Promise<TeamSubscription[]>;
|
|
186
250
|
tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
|
|
187
|
-
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined
|
|
251
|
+
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
|
|
188
252
|
tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
|
|
189
|
-
tsAssignSlot(
|
|
253
|
+
tsAssignSlot(
|
|
254
|
+
teamSubscriptionId: string,
|
|
255
|
+
teamSubscriptionSlotId: string,
|
|
256
|
+
identityStr: string | undefined,
|
|
257
|
+
): Promise<void>;
|
|
190
258
|
tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
|
|
191
259
|
tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
192
260
|
tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
193
261
|
|
|
194
262
|
getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
|
|
195
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
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Retry after this many seconds, earliest.
|
|
277
|
+
* cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
278
|
+
*/
|
|
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;
|
|
196
322
|
}
|
|
197
323
|
|
|
198
324
|
export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
|
|
199
325
|
|
|
200
|
-
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> {
|
|
201
329
|
return new GitpodServiceImpl<C, S>(createServerMock(methods));
|
|
202
|
-
}
|
|
330
|
+
};
|
|
203
331
|
|
|
204
|
-
export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
205
|
-
methods
|
|
206
|
-
|
|
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 || (() => {});
|
|
207
337
|
return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
|
|
338
|
+
// @ts-ignore
|
|
208
339
|
get: (target: S, property: keyof S) => {
|
|
209
340
|
const result = target[property];
|
|
210
341
|
if (!result) {
|
|
211
342
|
throw new Error(`Method ${property} not implemented`);
|
|
212
343
|
}
|
|
213
344
|
return result;
|
|
214
|
-
}
|
|
345
|
+
},
|
|
215
346
|
});
|
|
216
|
-
}
|
|
347
|
+
};
|
|
217
348
|
|
|
218
349
|
type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
|
|
219
350
|
export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
|
|
220
351
|
|
|
221
352
|
export interface SetWorkspaceTimeoutResult {
|
|
222
|
-
resetTimeoutOnWorkspaces: string[]
|
|
353
|
+
resetTimeoutOnWorkspaces: string[];
|
|
223
354
|
}
|
|
224
355
|
|
|
225
356
|
export interface GetWorkspaceTimeoutResult {
|
|
226
|
-
duration: WorkspaceTimeoutDuration
|
|
227
|
-
canChange: boolean
|
|
357
|
+
duration: WorkspaceTimeoutDuration;
|
|
358
|
+
canChange: boolean;
|
|
228
359
|
}
|
|
229
360
|
|
|
230
361
|
export interface StartWorkspaceResult {
|
|
231
|
-
instanceID: string
|
|
232
|
-
workspaceURL?: string
|
|
362
|
+
instanceID: string;
|
|
363
|
+
workspaceURL?: string;
|
|
233
364
|
}
|
|
234
365
|
|
|
235
366
|
export namespace GitpodServer {
|
|
@@ -237,6 +368,8 @@ export namespace GitpodServer {
|
|
|
237
368
|
limit?: number;
|
|
238
369
|
searchString?: string;
|
|
239
370
|
pinnedOnly?: boolean;
|
|
371
|
+
projectId?: string | string[];
|
|
372
|
+
includeWithoutProject?: boolean;
|
|
240
373
|
}
|
|
241
374
|
export interface GetAccountStatementOptions {
|
|
242
375
|
date?: string;
|
|
@@ -244,6 +377,7 @@ export namespace GitpodServer {
|
|
|
244
377
|
export interface CreateWorkspaceOptions {
|
|
245
378
|
contextUrl: string;
|
|
246
379
|
mode?: CreateWorkspaceMode;
|
|
380
|
+
forceDefaultConfig?: boolean;
|
|
247
381
|
}
|
|
248
382
|
export interface StartWorkspaceOptions {
|
|
249
383
|
forceDefaultImage: boolean;
|
|
@@ -251,13 +385,8 @@ export namespace GitpodServer {
|
|
|
251
385
|
export interface TakeSnapshotOptions {
|
|
252
386
|
workspaceId: string;
|
|
253
387
|
layoutData?: string;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
readonly releaseNotes?: boolean;
|
|
257
|
-
readonly workspaceInstanceId: string;
|
|
258
|
-
}
|
|
259
|
-
export interface UpdateUserMessagesOptions {
|
|
260
|
-
readonly messageIds: string[];
|
|
388
|
+
/* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
|
|
389
|
+
dontWait?: boolean;
|
|
261
390
|
}
|
|
262
391
|
export interface GetUserStorageResourceOptions {
|
|
263
392
|
readonly uri: string;
|
|
@@ -275,23 +404,23 @@ export namespace GitpodServer {
|
|
|
275
404
|
readonly roundTripTime?: number;
|
|
276
405
|
}
|
|
277
406
|
export interface UpdateOwnAuthProviderParams {
|
|
278
|
-
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
|
|
407
|
+
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
|
|
279
408
|
}
|
|
280
409
|
export interface DeleteOwnAuthProviderParams {
|
|
281
|
-
readonly id: string
|
|
410
|
+
readonly id: string;
|
|
282
411
|
}
|
|
283
412
|
export type AdmissionLevel = "owner" | "everyone";
|
|
284
413
|
export type PinAction = "pin" | "unpin" | "toggle";
|
|
285
414
|
export interface GenerateNewGitpodTokenOptions {
|
|
286
|
-
name?: string
|
|
287
|
-
type: GitpodTokenType
|
|
288
|
-
scopes?: string[]
|
|
415
|
+
name?: string;
|
|
416
|
+
type: GitpodTokenType;
|
|
417
|
+
scopes?: string[];
|
|
289
418
|
}
|
|
290
419
|
}
|
|
291
420
|
|
|
292
|
-
export const GitpodServerPath =
|
|
421
|
+
export const GitpodServerPath = "/gitpod";
|
|
293
422
|
|
|
294
|
-
export const GitpodServerProxy = Symbol(
|
|
423
|
+
export const GitpodServerProxy = Symbol("GitpodServerProxy");
|
|
295
424
|
export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
|
|
296
425
|
|
|
297
426
|
export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
|
|
@@ -299,12 +428,14 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
299
428
|
|
|
300
429
|
public registerClient(client: Partial<Client>): Disposable {
|
|
301
430
|
this.clients.push(client);
|
|
302
|
-
const index = this.clients.length;
|
|
303
431
|
return {
|
|
304
432
|
dispose: () => {
|
|
305
|
-
this.clients.
|
|
306
|
-
|
|
307
|
-
|
|
433
|
+
const index = this.clients.indexOf(client);
|
|
434
|
+
if (index > -1) {
|
|
435
|
+
this.clients.splice(index, 1);
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
};
|
|
308
439
|
}
|
|
309
440
|
|
|
310
441
|
onInstanceUpdate(instance: WorkspaceInstance): void {
|
|
@@ -313,31 +444,34 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
313
444
|
try {
|
|
314
445
|
client.onInstanceUpdate(instance);
|
|
315
446
|
} catch (error) {
|
|
316
|
-
console.error(error)
|
|
447
|
+
console.error(error);
|
|
317
448
|
}
|
|
318
449
|
}
|
|
319
450
|
}
|
|
320
451
|
}
|
|
321
452
|
|
|
322
|
-
|
|
453
|
+
onPrebuildUpdate(update: PrebuildWithStatus): void {
|
|
323
454
|
for (const client of this.clients) {
|
|
324
|
-
if (client.
|
|
455
|
+
if (client.onPrebuildUpdate) {
|
|
325
456
|
try {
|
|
326
|
-
client.
|
|
457
|
+
client.onPrebuildUpdate(update);
|
|
327
458
|
} catch (error) {
|
|
328
|
-
console.error(error)
|
|
459
|
+
console.error(error);
|
|
329
460
|
}
|
|
330
461
|
}
|
|
331
462
|
}
|
|
332
463
|
}
|
|
333
464
|
|
|
334
|
-
|
|
465
|
+
onWorkspaceImageBuildLogs(
|
|
466
|
+
info: WorkspaceImageBuild.StateInfo,
|
|
467
|
+
content: WorkspaceImageBuild.LogContent | undefined,
|
|
468
|
+
): void {
|
|
335
469
|
for (const client of this.clients) {
|
|
336
|
-
if (client.
|
|
470
|
+
if (client.onWorkspaceImageBuildLogs) {
|
|
337
471
|
try {
|
|
338
|
-
client.
|
|
472
|
+
client.onWorkspaceImageBuildLogs(info, content);
|
|
339
473
|
} catch (error) {
|
|
340
|
-
console.error(error)
|
|
474
|
+
console.error(error);
|
|
341
475
|
}
|
|
342
476
|
}
|
|
343
477
|
}
|
|
@@ -349,7 +483,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
349
483
|
try {
|
|
350
484
|
client.notifyDidOpenConnection();
|
|
351
485
|
} catch (error) {
|
|
352
|
-
console.error(error)
|
|
486
|
+
console.error(error);
|
|
353
487
|
}
|
|
354
488
|
}
|
|
355
489
|
}
|
|
@@ -361,7 +495,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
361
495
|
try {
|
|
362
496
|
client.notifyDidCloseConnection();
|
|
363
497
|
} catch (error) {
|
|
364
|
-
console.error(error)
|
|
498
|
+
console.error(error);
|
|
365
499
|
}
|
|
366
500
|
}
|
|
367
501
|
}
|
|
@@ -373,17 +507,16 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
373
507
|
try {
|
|
374
508
|
client.onCreditAlert(creditAlert);
|
|
375
509
|
} catch (error) {
|
|
376
|
-
console.error(error)
|
|
510
|
+
console.error(error);
|
|
377
511
|
}
|
|
378
512
|
}
|
|
379
513
|
}
|
|
380
514
|
}
|
|
381
|
-
|
|
382
515
|
}
|
|
383
516
|
|
|
384
517
|
export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
|
|
385
518
|
|
|
386
|
-
const hasWindow =
|
|
519
|
+
const hasWindow = typeof window !== "undefined";
|
|
387
520
|
const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
388
521
|
unknown: 0,
|
|
389
522
|
preparing: 1,
|
|
@@ -393,44 +526,41 @@ const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
|
393
526
|
running: 5,
|
|
394
527
|
interrupted: 6,
|
|
395
528
|
stopping: 7,
|
|
396
|
-
stopped: 8
|
|
529
|
+
stopped: 8,
|
|
397
530
|
};
|
|
398
531
|
export class WorkspaceInstanceUpdateListener {
|
|
399
532
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
|
400
533
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
401
534
|
|
|
402
|
-
private source:
|
|
535
|
+
private source: "sync" | "update" = "sync";
|
|
403
536
|
|
|
404
537
|
get info(): WorkspaceInfo {
|
|
405
538
|
return this._info;
|
|
406
539
|
}
|
|
407
540
|
|
|
408
|
-
constructor(
|
|
409
|
-
private readonly service: GitpodService,
|
|
410
|
-
private _info: WorkspaceInfo
|
|
411
|
-
) {
|
|
541
|
+
constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
|
|
412
542
|
service.registerClient({
|
|
413
|
-
onInstanceUpdate: instance => {
|
|
543
|
+
onInstanceUpdate: (instance) => {
|
|
414
544
|
if (this.isOutOfOrder(instance)) {
|
|
415
545
|
return;
|
|
416
546
|
}
|
|
417
547
|
this.cancelSync();
|
|
418
548
|
this._info.latestInstance = instance;
|
|
419
|
-
this.source =
|
|
549
|
+
this.source = "update";
|
|
420
550
|
this.onDidChangeEmitter.fire(undefined);
|
|
421
551
|
},
|
|
422
552
|
notifyDidOpenConnection: () => {
|
|
423
553
|
this.sync();
|
|
424
|
-
}
|
|
554
|
+
},
|
|
425
555
|
});
|
|
426
556
|
if (hasWindow) {
|
|
427
557
|
// learn about page lifecycle here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
|
|
428
|
-
window.document.addEventListener(
|
|
429
|
-
if (window.document.visibilityState ===
|
|
558
|
+
window.document.addEventListener("visibilitychange", async () => {
|
|
559
|
+
if (window.document.visibilityState === "visible") {
|
|
430
560
|
this.sync();
|
|
431
561
|
}
|
|
432
562
|
});
|
|
433
|
-
window.addEventListener(
|
|
563
|
+
window.addEventListener("pageshow", (e) => {
|
|
434
564
|
if (e.persisted) {
|
|
435
565
|
this.sync();
|
|
436
566
|
}
|
|
@@ -458,12 +588,12 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
458
588
|
return;
|
|
459
589
|
}
|
|
460
590
|
this._info = info;
|
|
461
|
-
this.source =
|
|
591
|
+
this.source = "sync";
|
|
462
592
|
this.onDidChangeEmitter.fire(undefined);
|
|
463
593
|
} catch (e) {
|
|
464
|
-
console.error(
|
|
594
|
+
console.error("failed to sync workspace instance:", e);
|
|
465
595
|
}
|
|
466
|
-
})
|
|
596
|
+
});
|
|
467
597
|
}
|
|
468
598
|
private cancelSync(): void {
|
|
469
599
|
if (this.syncTokenSource) {
|
|
@@ -480,7 +610,7 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
480
610
|
if (instance.workspaceId !== this._info.workspace.id) {
|
|
481
611
|
return true;
|
|
482
612
|
}
|
|
483
|
-
if (this.source ===
|
|
613
|
+
if (this.source === "update") {
|
|
484
614
|
return false;
|
|
485
615
|
}
|
|
486
616
|
if (instance.id !== this.info.latestInstance?.id) {
|
|
@@ -488,14 +618,16 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
488
618
|
}
|
|
489
619
|
return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
|
|
490
620
|
}
|
|
621
|
+
}
|
|
491
622
|
|
|
623
|
+
export interface GitpodServiceOptions {
|
|
624
|
+
onReconnect?: () => void | Promise<void>;
|
|
492
625
|
}
|
|
493
626
|
|
|
494
627
|
export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
|
|
495
|
-
|
|
496
628
|
private readonly compositeClient = new GitpodCompositeClient<Client>();
|
|
497
629
|
|
|
498
|
-
constructor(public readonly server: JsonRpcProxy<Server
|
|
630
|
+
constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
|
|
499
631
|
server.setClient(this.compositeClient);
|
|
500
632
|
server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
|
|
501
633
|
server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
|
|
@@ -507,7 +639,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
507
639
|
|
|
508
640
|
private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
|
|
509
641
|
listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
|
|
510
|
-
const listener =
|
|
642
|
+
const listener =
|
|
643
|
+
this.instanceListeners.get(workspaceId) ||
|
|
511
644
|
(async () => {
|
|
512
645
|
const info = await this.server.getWorkspace(workspaceId);
|
|
513
646
|
return new WorkspaceInstanceUpdateListener(this, info);
|
|
@@ -515,13 +648,33 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
515
648
|
this.instanceListeners.set(workspaceId, listener);
|
|
516
649
|
return listener;
|
|
517
650
|
}
|
|
651
|
+
|
|
652
|
+
async reconnect(): Promise<void> {
|
|
653
|
+
if (this.options?.onReconnect) {
|
|
654
|
+
await this.options.onReconnect();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
518
657
|
}
|
|
519
658
|
|
|
520
|
-
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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
|
+
|
|
524
672
|
const connectionProvider = new WebSocketConnectionProvider();
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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
|
+
}
|