@gitpod/gitpod-protocol 0.1.5-patch-2-fork.0 → 0.1.5-pavel-9469.26
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 +188 -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 +0 -6
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +7 -27
- 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 +139 -40
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +186 -289
- 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.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 +190 -82
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +216 -200
- 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 +117 -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 +6 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +469 -502
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +68 -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 +197 -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 +31 -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 +0 -22
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +281 -118
- 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 +2 -2
- package/src/permission.ts +42 -33
- package/src/plans.ts +679 -0
- package/src/protocol.ts +441 -275
- 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 +152 -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 +37 -10
- package/src/util/generate-workspace-id.ts +464 -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 -72
- 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 +200 -31
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/workspace-cluster.ts +107 -0
- package/src/workspace-instance.ts +74 -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[]>;
|
|
@@ -120,13 +189,19 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
120
189
|
|
|
121
190
|
// misc
|
|
122
191
|
sendFeedback(feedback: string): Promise<string | undefined>;
|
|
192
|
+
isGitHubAppEnabled(): Promise<boolean>;
|
|
123
193
|
registerGithubApp(installationId: string): Promise<void>;
|
|
124
194
|
|
|
125
195
|
/**
|
|
126
|
-
* Stores a new snapshot for the given workspace and bucketId
|
|
196
|
+
* Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
|
|
127
197
|
* @return the snapshot id
|
|
128
198
|
*/
|
|
129
199
|
takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
* @param snapshotId
|
|
203
|
+
*/
|
|
204
|
+
waitForSnapshot(snapshotId: string): Promise<void>;
|
|
130
205
|
|
|
131
206
|
/**
|
|
132
207
|
* Returns the list of snapshots that exist for a workspace.
|
|
@@ -143,29 +218,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
143
218
|
*/
|
|
144
219
|
getLayout(workspaceId: string): Promise<string | undefined>;
|
|
145
220
|
|
|
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>;
|
|
221
|
+
guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
|
|
154
222
|
|
|
155
223
|
/**
|
|
156
224
|
* gitpod.io concerns
|
|
157
225
|
*/
|
|
158
226
|
isStudent(): Promise<boolean>;
|
|
159
|
-
getPrivateRepoTrialEndDate(): Promise<string | undefined>;
|
|
160
|
-
|
|
161
227
|
/**
|
|
162
|
-
*
|
|
228
|
+
*
|
|
163
229
|
*/
|
|
164
230
|
getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
|
|
165
231
|
getRemainingUsageHours(): Promise<number>;
|
|
166
232
|
|
|
167
233
|
/**
|
|
168
|
-
*
|
|
234
|
+
*
|
|
169
235
|
*/
|
|
170
236
|
getChargebeeSiteId(): Promise<string>;
|
|
171
237
|
createPortalSession(): Promise<{}>;
|
|
@@ -175,7 +241,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
175
241
|
|
|
176
242
|
getShowPaymentUI(): Promise<boolean>;
|
|
177
243
|
isChargebeeCustomer(): Promise<boolean>;
|
|
178
|
-
mayAccessPrivateRepo(): Promise<boolean>;
|
|
179
244
|
|
|
180
245
|
subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
181
246
|
subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
|
|
@@ -184,52 +249,128 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
184
249
|
|
|
185
250
|
tsGet(): Promise<TeamSubscription[]>;
|
|
186
251
|
tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
|
|
187
|
-
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined
|
|
252
|
+
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
|
|
188
253
|
tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
|
|
189
|
-
tsAssignSlot(
|
|
254
|
+
tsAssignSlot(
|
|
255
|
+
teamSubscriptionId: string,
|
|
256
|
+
teamSubscriptionSlotId: string,
|
|
257
|
+
identityStr: string | undefined,
|
|
258
|
+
): Promise<void>;
|
|
190
259
|
tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
|
|
191
260
|
tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
192
261
|
tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
193
262
|
|
|
194
263
|
getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
|
|
195
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Analytics
|
|
267
|
+
*/
|
|
268
|
+
trackEvent(event: RemoteTrackMessage): Promise<void>;
|
|
269
|
+
trackLocation(event: RemotePageMessage): Promise<void>;
|
|
270
|
+
identifyUser(event: RemoteIdentifyMessage): Promise<void>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface RateLimiterError {
|
|
274
|
+
method?: string;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Retry after this many seconds, earliest.
|
|
278
|
+
* cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
279
|
+
*/
|
|
280
|
+
retryAfter: number;
|
|
196
281
|
}
|
|
197
282
|
|
|
198
|
-
export
|
|
283
|
+
export interface CreateProjectParams {
|
|
284
|
+
name: string;
|
|
285
|
+
slug?: string;
|
|
286
|
+
account: string;
|
|
287
|
+
provider: string;
|
|
288
|
+
cloneUrl: string;
|
|
289
|
+
teamId?: string;
|
|
290
|
+
userId?: string;
|
|
291
|
+
appInstallationId: string;
|
|
292
|
+
}
|
|
293
|
+
export interface FindPrebuildsParams {
|
|
294
|
+
projectId: string;
|
|
295
|
+
branch?: string;
|
|
296
|
+
latest?: boolean;
|
|
297
|
+
prebuildId?: string;
|
|
298
|
+
// default: 30
|
|
299
|
+
limit?: number;
|
|
300
|
+
}
|
|
301
|
+
export interface GetProviderRepositoriesParams {
|
|
302
|
+
provider: string;
|
|
303
|
+
hints?: { installationId: string } | object;
|
|
304
|
+
}
|
|
305
|
+
export interface ProviderRepository {
|
|
306
|
+
name: string;
|
|
307
|
+
path?: string;
|
|
308
|
+
account: string;
|
|
309
|
+
accountAvatarUrl: string;
|
|
310
|
+
cloneUrl: string;
|
|
311
|
+
updatedAt?: string;
|
|
312
|
+
installationId?: number;
|
|
313
|
+
installationUpdatedAt?: string;
|
|
314
|
+
|
|
315
|
+
inUse?: { userName: string };
|
|
316
|
+
}
|
|
199
317
|
|
|
200
|
-
export
|
|
201
|
-
|
|
318
|
+
export interface ClientHeaderFields {
|
|
319
|
+
ip?: string;
|
|
320
|
+
userAgent?: string;
|
|
321
|
+
dnt?: string;
|
|
322
|
+
clientRegion?: string;
|
|
202
323
|
}
|
|
203
324
|
|
|
204
|
-
export const
|
|
205
|
-
|
|
206
|
-
|
|
325
|
+
export const WORKSPACE_TIMEOUT_DEFAULT_SHORT = "short";
|
|
326
|
+
export const WORKSPACE_TIMEOUT_DEFAULT_LONG = "long";
|
|
327
|
+
export const WORKSPACE_TIMEOUT_EXTENDED = "extended";
|
|
328
|
+
export const WORKSPACE_TIMEOUT_EXTENDED_ALT = "180m"; // for backwards compatibility since the IDE uses this
|
|
329
|
+
export const WorkspaceTimeoutValues = [
|
|
330
|
+
WORKSPACE_TIMEOUT_DEFAULT_SHORT,
|
|
331
|
+
WORKSPACE_TIMEOUT_DEFAULT_LONG,
|
|
332
|
+
WORKSPACE_TIMEOUT_EXTENDED,
|
|
333
|
+
WORKSPACE_TIMEOUT_EXTENDED_ALT,
|
|
334
|
+
] as const;
|
|
335
|
+
|
|
336
|
+
export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
337
|
+
methods: Partial<JsonRpcProxy<S>>,
|
|
338
|
+
): GitpodServiceImpl<C, S> {
|
|
339
|
+
return new GitpodServiceImpl<C, S>(createServerMock(methods));
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
343
|
+
methods: Partial<JsonRpcProxy<S>>,
|
|
344
|
+
): JsonRpcProxy<S> {
|
|
345
|
+
methods.setClient = methods.setClient || (() => {});
|
|
346
|
+
methods.dispose = methods.dispose || (() => {});
|
|
207
347
|
return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
|
|
348
|
+
// @ts-ignore
|
|
208
349
|
get: (target: S, property: keyof S) => {
|
|
209
350
|
const result = target[property];
|
|
210
351
|
if (!result) {
|
|
211
352
|
throw new Error(`Method ${property} not implemented`);
|
|
212
353
|
}
|
|
213
354
|
return result;
|
|
214
|
-
}
|
|
355
|
+
},
|
|
215
356
|
});
|
|
216
|
-
}
|
|
357
|
+
};
|
|
217
358
|
|
|
218
359
|
type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
|
|
219
360
|
export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
|
|
220
361
|
|
|
221
362
|
export interface SetWorkspaceTimeoutResult {
|
|
222
|
-
resetTimeoutOnWorkspaces: string[]
|
|
363
|
+
resetTimeoutOnWorkspaces: string[];
|
|
223
364
|
}
|
|
224
365
|
|
|
225
366
|
export interface GetWorkspaceTimeoutResult {
|
|
226
|
-
duration: WorkspaceTimeoutDuration
|
|
227
|
-
canChange: boolean
|
|
367
|
+
duration: WorkspaceTimeoutDuration;
|
|
368
|
+
canChange: boolean;
|
|
228
369
|
}
|
|
229
370
|
|
|
230
371
|
export interface StartWorkspaceResult {
|
|
231
|
-
instanceID: string
|
|
232
|
-
workspaceURL?: string
|
|
372
|
+
instanceID: string;
|
|
373
|
+
workspaceURL?: string;
|
|
233
374
|
}
|
|
234
375
|
|
|
235
376
|
export namespace GitpodServer {
|
|
@@ -237,6 +378,8 @@ export namespace GitpodServer {
|
|
|
237
378
|
limit?: number;
|
|
238
379
|
searchString?: string;
|
|
239
380
|
pinnedOnly?: boolean;
|
|
381
|
+
projectId?: string | string[];
|
|
382
|
+
includeWithoutProject?: boolean;
|
|
240
383
|
}
|
|
241
384
|
export interface GetAccountStatementOptions {
|
|
242
385
|
date?: string;
|
|
@@ -244,6 +387,7 @@ export namespace GitpodServer {
|
|
|
244
387
|
export interface CreateWorkspaceOptions {
|
|
245
388
|
contextUrl: string;
|
|
246
389
|
mode?: CreateWorkspaceMode;
|
|
390
|
+
forceDefaultConfig?: boolean;
|
|
247
391
|
}
|
|
248
392
|
export interface StartWorkspaceOptions {
|
|
249
393
|
forceDefaultImage: boolean;
|
|
@@ -251,13 +395,8 @@ export namespace GitpodServer {
|
|
|
251
395
|
export interface TakeSnapshotOptions {
|
|
252
396
|
workspaceId: string;
|
|
253
397
|
layoutData?: string;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
readonly releaseNotes?: boolean;
|
|
257
|
-
readonly workspaceInstanceId: string;
|
|
258
|
-
}
|
|
259
|
-
export interface UpdateUserMessagesOptions {
|
|
260
|
-
readonly messageIds: string[];
|
|
398
|
+
/* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
|
|
399
|
+
dontWait?: boolean;
|
|
261
400
|
}
|
|
262
401
|
export interface GetUserStorageResourceOptions {
|
|
263
402
|
readonly uri: string;
|
|
@@ -275,23 +414,23 @@ export namespace GitpodServer {
|
|
|
275
414
|
readonly roundTripTime?: number;
|
|
276
415
|
}
|
|
277
416
|
export interface UpdateOwnAuthProviderParams {
|
|
278
|
-
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
|
|
417
|
+
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
|
|
279
418
|
}
|
|
280
419
|
export interface DeleteOwnAuthProviderParams {
|
|
281
|
-
readonly id: string
|
|
420
|
+
readonly id: string;
|
|
282
421
|
}
|
|
283
422
|
export type AdmissionLevel = "owner" | "everyone";
|
|
284
423
|
export type PinAction = "pin" | "unpin" | "toggle";
|
|
285
424
|
export interface GenerateNewGitpodTokenOptions {
|
|
286
|
-
name?: string
|
|
287
|
-
type: GitpodTokenType
|
|
288
|
-
scopes?: string[]
|
|
425
|
+
name?: string;
|
|
426
|
+
type: GitpodTokenType;
|
|
427
|
+
scopes?: string[];
|
|
289
428
|
}
|
|
290
429
|
}
|
|
291
430
|
|
|
292
|
-
export const GitpodServerPath =
|
|
431
|
+
export const GitpodServerPath = "/gitpod";
|
|
293
432
|
|
|
294
|
-
export const GitpodServerProxy = Symbol(
|
|
433
|
+
export const GitpodServerProxy = Symbol("GitpodServerProxy");
|
|
295
434
|
export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
|
|
296
435
|
|
|
297
436
|
export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
|
|
@@ -299,12 +438,14 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
299
438
|
|
|
300
439
|
public registerClient(client: Partial<Client>): Disposable {
|
|
301
440
|
this.clients.push(client);
|
|
302
|
-
const index = this.clients.length;
|
|
303
441
|
return {
|
|
304
442
|
dispose: () => {
|
|
305
|
-
this.clients.
|
|
306
|
-
|
|
307
|
-
|
|
443
|
+
const index = this.clients.indexOf(client);
|
|
444
|
+
if (index > -1) {
|
|
445
|
+
this.clients.splice(index, 1);
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
};
|
|
308
449
|
}
|
|
309
450
|
|
|
310
451
|
onInstanceUpdate(instance: WorkspaceInstance): void {
|
|
@@ -313,31 +454,34 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
313
454
|
try {
|
|
314
455
|
client.onInstanceUpdate(instance);
|
|
315
456
|
} catch (error) {
|
|
316
|
-
console.error(error)
|
|
457
|
+
console.error(error);
|
|
317
458
|
}
|
|
318
459
|
}
|
|
319
460
|
}
|
|
320
461
|
}
|
|
321
462
|
|
|
322
|
-
|
|
463
|
+
onPrebuildUpdate(update: PrebuildWithStatus): void {
|
|
323
464
|
for (const client of this.clients) {
|
|
324
|
-
if (client.
|
|
465
|
+
if (client.onPrebuildUpdate) {
|
|
325
466
|
try {
|
|
326
|
-
client.
|
|
467
|
+
client.onPrebuildUpdate(update);
|
|
327
468
|
} catch (error) {
|
|
328
|
-
console.error(error)
|
|
469
|
+
console.error(error);
|
|
329
470
|
}
|
|
330
471
|
}
|
|
331
472
|
}
|
|
332
473
|
}
|
|
333
474
|
|
|
334
|
-
|
|
475
|
+
onWorkspaceImageBuildLogs(
|
|
476
|
+
info: WorkspaceImageBuild.StateInfo,
|
|
477
|
+
content: WorkspaceImageBuild.LogContent | undefined,
|
|
478
|
+
): void {
|
|
335
479
|
for (const client of this.clients) {
|
|
336
|
-
if (client.
|
|
480
|
+
if (client.onWorkspaceImageBuildLogs) {
|
|
337
481
|
try {
|
|
338
|
-
client.
|
|
482
|
+
client.onWorkspaceImageBuildLogs(info, content);
|
|
339
483
|
} catch (error) {
|
|
340
|
-
console.error(error)
|
|
484
|
+
console.error(error);
|
|
341
485
|
}
|
|
342
486
|
}
|
|
343
487
|
}
|
|
@@ -349,7 +493,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
349
493
|
try {
|
|
350
494
|
client.notifyDidOpenConnection();
|
|
351
495
|
} catch (error) {
|
|
352
|
-
console.error(error)
|
|
496
|
+
console.error(error);
|
|
353
497
|
}
|
|
354
498
|
}
|
|
355
499
|
}
|
|
@@ -361,7 +505,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
361
505
|
try {
|
|
362
506
|
client.notifyDidCloseConnection();
|
|
363
507
|
} catch (error) {
|
|
364
|
-
console.error(error)
|
|
508
|
+
console.error(error);
|
|
365
509
|
}
|
|
366
510
|
}
|
|
367
511
|
}
|
|
@@ -373,17 +517,16 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
373
517
|
try {
|
|
374
518
|
client.onCreditAlert(creditAlert);
|
|
375
519
|
} catch (error) {
|
|
376
|
-
console.error(error)
|
|
520
|
+
console.error(error);
|
|
377
521
|
}
|
|
378
522
|
}
|
|
379
523
|
}
|
|
380
524
|
}
|
|
381
|
-
|
|
382
525
|
}
|
|
383
526
|
|
|
384
527
|
export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
|
|
385
528
|
|
|
386
|
-
const hasWindow =
|
|
529
|
+
const hasWindow = typeof window !== "undefined";
|
|
387
530
|
const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
388
531
|
unknown: 0,
|
|
389
532
|
preparing: 1,
|
|
@@ -393,44 +536,41 @@ const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
|
393
536
|
running: 5,
|
|
394
537
|
interrupted: 6,
|
|
395
538
|
stopping: 7,
|
|
396
|
-
stopped: 8
|
|
539
|
+
stopped: 8,
|
|
397
540
|
};
|
|
398
541
|
export class WorkspaceInstanceUpdateListener {
|
|
399
542
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
|
400
543
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
401
544
|
|
|
402
|
-
private source:
|
|
545
|
+
private source: "sync" | "update" = "sync";
|
|
403
546
|
|
|
404
547
|
get info(): WorkspaceInfo {
|
|
405
548
|
return this._info;
|
|
406
549
|
}
|
|
407
550
|
|
|
408
|
-
constructor(
|
|
409
|
-
private readonly service: GitpodService,
|
|
410
|
-
private _info: WorkspaceInfo
|
|
411
|
-
) {
|
|
551
|
+
constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
|
|
412
552
|
service.registerClient({
|
|
413
|
-
onInstanceUpdate: instance => {
|
|
553
|
+
onInstanceUpdate: (instance) => {
|
|
414
554
|
if (this.isOutOfOrder(instance)) {
|
|
415
555
|
return;
|
|
416
556
|
}
|
|
417
557
|
this.cancelSync();
|
|
418
558
|
this._info.latestInstance = instance;
|
|
419
|
-
this.source =
|
|
559
|
+
this.source = "update";
|
|
420
560
|
this.onDidChangeEmitter.fire(undefined);
|
|
421
561
|
},
|
|
422
562
|
notifyDidOpenConnection: () => {
|
|
423
563
|
this.sync();
|
|
424
|
-
}
|
|
564
|
+
},
|
|
425
565
|
});
|
|
426
566
|
if (hasWindow) {
|
|
427
567
|
// 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 ===
|
|
568
|
+
window.document.addEventListener("visibilitychange", async () => {
|
|
569
|
+
if (window.document.visibilityState === "visible") {
|
|
430
570
|
this.sync();
|
|
431
571
|
}
|
|
432
572
|
});
|
|
433
|
-
window.addEventListener(
|
|
573
|
+
window.addEventListener("pageshow", (e) => {
|
|
434
574
|
if (e.persisted) {
|
|
435
575
|
this.sync();
|
|
436
576
|
}
|
|
@@ -458,12 +598,12 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
458
598
|
return;
|
|
459
599
|
}
|
|
460
600
|
this._info = info;
|
|
461
|
-
this.source =
|
|
601
|
+
this.source = "sync";
|
|
462
602
|
this.onDidChangeEmitter.fire(undefined);
|
|
463
603
|
} catch (e) {
|
|
464
|
-
console.error(
|
|
604
|
+
console.error("failed to sync workspace instance:", e);
|
|
465
605
|
}
|
|
466
|
-
})
|
|
606
|
+
});
|
|
467
607
|
}
|
|
468
608
|
private cancelSync(): void {
|
|
469
609
|
if (this.syncTokenSource) {
|
|
@@ -480,7 +620,7 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
480
620
|
if (instance.workspaceId !== this._info.workspace.id) {
|
|
481
621
|
return true;
|
|
482
622
|
}
|
|
483
|
-
if (this.source ===
|
|
623
|
+
if (this.source === "update") {
|
|
484
624
|
return false;
|
|
485
625
|
}
|
|
486
626
|
if (instance.id !== this.info.latestInstance?.id) {
|
|
@@ -488,14 +628,16 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
488
628
|
}
|
|
489
629
|
return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
|
|
490
630
|
}
|
|
631
|
+
}
|
|
491
632
|
|
|
633
|
+
export interface GitpodServiceOptions {
|
|
634
|
+
onReconnect?: () => void | Promise<void>;
|
|
492
635
|
}
|
|
493
636
|
|
|
494
637
|
export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
|
|
495
|
-
|
|
496
638
|
private readonly compositeClient = new GitpodCompositeClient<Client>();
|
|
497
639
|
|
|
498
|
-
constructor(public readonly server: JsonRpcProxy<Server
|
|
640
|
+
constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
|
|
499
641
|
server.setClient(this.compositeClient);
|
|
500
642
|
server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
|
|
501
643
|
server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
|
|
@@ -507,7 +649,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
507
649
|
|
|
508
650
|
private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
|
|
509
651
|
listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
|
|
510
|
-
const listener =
|
|
652
|
+
const listener =
|
|
653
|
+
this.instanceListeners.get(workspaceId) ||
|
|
511
654
|
(async () => {
|
|
512
655
|
const info = await this.server.getWorkspace(workspaceId);
|
|
513
656
|
return new WorkspaceInstanceUpdateListener(this, info);
|
|
@@ -515,13 +658,33 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
515
658
|
this.instanceListeners.set(workspaceId, listener);
|
|
516
659
|
return listener;
|
|
517
660
|
}
|
|
661
|
+
|
|
662
|
+
async reconnect(): Promise<void> {
|
|
663
|
+
if (this.options?.onReconnect) {
|
|
664
|
+
await this.options.onReconnect();
|
|
665
|
+
}
|
|
666
|
+
}
|
|
518
667
|
}
|
|
519
668
|
|
|
520
|
-
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
669
|
+
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
|
|
670
|
+
serverUrl: string | Promise<string>,
|
|
671
|
+
) {
|
|
672
|
+
const toWsUrl = (serverUrl: string) => {
|
|
673
|
+
return new GitpodHostUrl(serverUrl).asWebsocket().withApi({ pathname: GitpodServerPath }).toString();
|
|
674
|
+
};
|
|
675
|
+
let url: string | Promise<string>;
|
|
676
|
+
if (typeof serverUrl === "string") {
|
|
677
|
+
url = toWsUrl(serverUrl);
|
|
678
|
+
} else {
|
|
679
|
+
url = serverUrl.then((url) => toWsUrl(url));
|
|
680
|
+
}
|
|
681
|
+
|
|
524
682
|
const connectionProvider = new WebSocketConnectionProvider();
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
683
|
+
let onReconnect = () => {};
|
|
684
|
+
const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
|
|
685
|
+
onListening: (socket) => {
|
|
686
|
+
onReconnect = () => socket.reconnect();
|
|
687
|
+
},
|
|
688
|
+
});
|
|
689
|
+
return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
|
|
690
|
+
}
|