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