@gitpod/gitpod-protocol 0.1.5-to-new-image.2 → 0.1.5-to-monitor-delete.18
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 +124 -5
- package/lib/accounting-protocol.d.ts +18 -10
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +34 -32
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +7 -0
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts.map +1 -1
- package/lib/analytics.js.map +1 -1
- package/lib/attribution.d.ts +24 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +54 -0
- package/lib/attribution.js.map +1 -0
- package/lib/auth.d.ts.map +1 -1
- package/lib/billing-mode.d.ts +45 -0
- package/lib/billing-mode.d.ts.map +1 -0
- package/lib/billing-mode.js +44 -0
- package/lib/billing-mode.js.map +1 -0
- package/lib/blocked-repositories-protocol.d.ts +13 -0
- package/lib/blocked-repositories-protocol.d.ts.map +1 -0
- package/lib/blocked-repositories-protocol.js +8 -0
- package/lib/blocked-repositories-protocol.js.map +1 -0
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +4 -4
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +20 -5
- package/lib/context-url.spec.js.map +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +1 -1
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +9 -9
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +2 -3
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +1 -1
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +7 -9
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +0 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +1 -20
- package/lib/env.js.map +1 -1
- package/lib/experiments/always-default.d.ts +8 -0
- package/lib/experiments/always-default.d.ts.map +1 -0
- package/lib/experiments/always-default.js +20 -0
- package/lib/experiments/always-default.js.map +1 -0
- package/lib/experiments/configcat-server.d.ts +10 -0
- package/lib/experiments/configcat-server.d.ts.map +1 -0
- package/lib/experiments/configcat-server.js +36 -0
- package/lib/experiments/configcat-server.js.map +1 -0
- package/lib/experiments/configcat.d.ts +21 -0
- package/lib/experiments/configcat.d.ts.map +1 -0
- package/lib/experiments/configcat.js +51 -0
- package/lib/experiments/configcat.js.map +1 -0
- package/lib/experiments/types.d.ts +22 -0
- package/lib/experiments/types.d.ts.map +1 -0
- package/lib/experiments/types.js +10 -0
- package/lib/experiments/types.js.map +1 -0
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +6 -6
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +42 -39
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +65 -46
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +52 -33
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +1 -0
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +2 -1
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +1 -1
- package/lib/ide-protocol.d.ts +14 -6
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/index.d.ts +16 -16
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +3 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +3 -2
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts +7 -0
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +1 -1
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +19 -19
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +4 -4
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +9 -6
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +2 -18
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +21 -22
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts +7 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +15 -3
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -1
- package/lib/messaging/node/connection.js +8 -8
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +1 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +7 -9
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/payment-protocol.d.ts.map +1 -1
- package/lib/payment-protocol.js +1 -1
- package/lib/payment-protocol.js.map +1 -1
- package/lib/permission.d.ts +2 -2
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +12 -23
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +4 -3
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +210 -171
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +181 -57
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +285 -105
- package/lib/protocol.js.map +1 -1
- package/{src/theia-plugins.ts → lib/protocol.spec.d.ts} +2 -6
- package/lib/protocol.spec.d.ts.map +1 -0
- package/lib/protocol.spec.js +127 -0
- package/lib/protocol.spec.js.map +1 -0
- package/lib/snapshot-url.spec.js.map +1 -1
- package/lib/team-subscription-protocol.d.ts +22 -3
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +20 -5
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +26 -5
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +1 -1
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +2 -2
- package/lib/typings/globals.d.ts.map +1 -1
- package/lib/usage.d.ts +61 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +14 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +12 -3
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +3 -3
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +6 -6
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/debug-app.d.ts +25 -0
- package/lib/util/debug-app.d.ts.map +1 -0
- package/lib/util/debug-app.js +100 -0
- package/lib/util/debug-app.js.map +1 -0
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +2 -2
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +5 -3
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +6 -1
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +5 -0
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +446 -442
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +18 -7
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +1 -1
- package/lib/util/gitpod-cookie.d.ts.map +1 -1
- package/lib/util/gitpod-cookie.js +0 -3
- package/lib/util/gitpod-cookie.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts +3 -0
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +49 -29
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +15 -5
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +19 -0
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js +73 -1
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts.map +1 -1
- package/lib/util/logging.d.ts +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +31 -25
- package/lib/util/logging.js.map +1 -1
- package/lib/util/logging.spec.d.ts +7 -0
- package/lib/util/logging.spec.d.ts.map +1 -0
- package/lib/util/logging.spec.js +52 -0
- package/lib/util/logging.spec.js.map +1 -0
- package/lib/util/make-link.js +5 -5
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/nice-grpc.d.ts +9 -0
- package/lib/util/nice-grpc.d.ts.map +1 -0
- package/lib/util/nice-grpc.js +119 -0
- package/lib/util/nice-grpc.js.map +1 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +1 -2
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.spec.js +9 -6
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts +2 -0
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +15 -3
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts +2 -0
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +34 -0
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +6 -6
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +14 -16
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.js +3 -3
- package/lib/util/tracing.spec.js.map +1 -1
- package/lib/util/workspace-port-authentication.d.ts +7 -7
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +8 -11
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/webhook-event.d.ts +44 -0
- package/lib/webhook-event.d.ts.map +1 -0
- package/lib/{theia-plugins.js → webhook-event.js} +2 -2
- package/lib/webhook-event.js.map +1 -0
- package/lib/workspace-class.d.ts +14 -0
- package/lib/workspace-class.d.ts.map +1 -0
- package/lib/workspace-class.js +8 -0
- package/lib/workspace-class.js.map +1 -0
- package/lib/workspace-cluster.d.ts +12 -13
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +2 -4
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +20 -3
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +14 -6
- package/pkg-yarn.lock +10 -5
- package/provenance-bundle.jsonl +3 -1
- package/src/accounting-protocol.ts +66 -51
- package/src/admin-protocol.ts +32 -20
- package/src/analytics.ts +21 -21
- package/src/attribution.ts +63 -0
- package/src/auth.ts +2 -2
- package/src/billing-mode.ts +84 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/context-url.spec.ts +25 -11
- package/src/context-url.ts +80 -78
- package/src/encryption/container-module.ts +2 -3
- package/src/encryption/encryption-engine.spec.ts +9 -8
- package/src/encryption/encryption-engine.ts +20 -16
- package/src/encryption/encryption-service.ts +4 -5
- package/src/encryption/key-provider.ts +16 -19
- package/src/env.ts +0 -22
- package/src/experiments/always-default.ts +24 -0
- package/src/experiments/configcat-server.ts +41 -0
- package/src/experiments/configcat.ts +56 -0
- package/src/experiments/types.ts +34 -0
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +208 -132
- package/src/headless-workspace-log.ts +6 -4
- package/src/ide-frontend-service.ts +2 -2
- package/src/ide-protocol.ts +18 -8
- package/src/index.ts +16 -16
- package/src/installation-admin-protocol.ts +11 -8
- package/src/license-protocol.ts +12 -6
- package/src/messaging/browser/connection.ts +45 -47
- package/src/messaging/browser/window-connection.ts +39 -29
- package/src/messaging/client-call-metrics.ts +62 -82
- package/src/messaging/error.ts +23 -7
- package/src/messaging/handler.ts +6 -6
- package/src/messaging/node/connection.ts +8 -8
- package/src/messaging/proxy-factory.ts +23 -30
- package/src/oss-allowlist.ts +3 -3
- package/src/payment-protocol.ts +2 -2
- package/src/permission.ts +20 -31
- package/src/plans.ts +240 -189
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +545 -261
- package/src/snapshot-url.spec.ts +9 -7
- package/src/team-subscription-protocol.ts +59 -22
- package/src/teams-projects-protocol.ts +36 -11
- package/src/typings/globals.ts +4 -4
- package/src/usage.ts +71 -0
- package/src/util/analytics.ts +46 -24
- 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/debug-app.ts +81 -0
- 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 +8 -6
- package/src/util/generate-workspace-id.spec.ts +26 -16
- package/src/util/generate-workspace-id.ts +460 -454
- package/src/util/gitpod-cookie.ts +8 -9
- package/src/util/gitpod-host-url.spec.ts +40 -13
- package/src/util/gitpod-host-url.ts +57 -33
- package/src/util/grpc.ts +90 -1
- package/src/util/jaeger-client-types.ts +2 -2
- package/src/util/logging.spec.ts +23 -0
- package/src/util/logging.ts +60 -42
- package/src/util/make-link.ts +6 -7
- package/src/util/nice-grpc.ts +93 -0
- package/src/util/parse-workspace-id.spec.ts +17 -8
- package/src/util/parse-workspace-id.ts +5 -6
- package/src/util/queue.spec.ts +27 -25
- package/src/util/repeat.ts +1 -1
- package/src/util/semaphore.ts +4 -6
- package/src/util/skip-if.ts +9 -6
- package/src/util/timeutil.spec.ts +40 -14
- package/src/util/timeutil.ts +27 -11
- package/src/util/tracing.spec.ts +28 -23
- package/src/util/tracing.ts +54 -51
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/webhook-event.ts +55 -0
- package/src/workspace-class.ts +14 -0
- package/src/workspace-cluster.ts +24 -18
- package/src/workspace-instance.ts +60 -24
- package/src/wsready.ts +3 -3
- package/data/builtin-theia-plugins.json +0 -372
- package/lib/email-protocol.d.ts +0 -49
- package/lib/email-protocol.d.ts.map +0 -1
- package/lib/email-protocol.js +0 -28
- package/lib/email-protocol.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/src/email-protocol.ts +0 -66
package/src/gitpod-service.ts
CHANGED
|
@@ -5,32 +5,63 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
User,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
User,
|
|
9
|
+
WorkspaceInfo,
|
|
10
|
+
WorkspaceCreationResult,
|
|
11
|
+
WorkspaceInstanceUser,
|
|
12
|
+
WhitelistedRepository,
|
|
13
|
+
WorkspaceImageBuild,
|
|
14
|
+
AuthProviderInfo,
|
|
15
|
+
Token,
|
|
16
|
+
UserEnvVarValue,
|
|
17
|
+
Terms,
|
|
18
|
+
Configuration,
|
|
19
|
+
UserInfo,
|
|
20
|
+
GitpodTokenType,
|
|
21
|
+
GitpodToken,
|
|
22
|
+
AuthProviderEntry,
|
|
23
|
+
GuessGitTokenScopesParams,
|
|
24
|
+
GuessedGitTokenScopes,
|
|
25
|
+
ProjectEnvVar,
|
|
26
|
+
PrebuiltWorkspace,
|
|
27
|
+
UserSSHPublicKeyValue,
|
|
28
|
+
SSHPublicKeyValue,
|
|
29
|
+
} from "./protocol";
|
|
14
30
|
import {
|
|
15
|
-
Team,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
31
|
+
Team,
|
|
32
|
+
TeamMemberInfo,
|
|
33
|
+
TeamMembershipInvite,
|
|
34
|
+
Project,
|
|
35
|
+
TeamMemberRole,
|
|
36
|
+
PrebuildWithStatus,
|
|
37
|
+
StartPrebuildResult,
|
|
38
|
+
PartialProject,
|
|
39
|
+
PrebuildEvent,
|
|
40
|
+
} from "./teams-projects-protocol";
|
|
41
|
+
import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
|
|
42
|
+
import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
|
|
43
|
+
import { HeadlessLogUrls } from "./headless-workspace-log";
|
|
44
|
+
import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from "./workspace-instance";
|
|
45
|
+
import { AdminServer } from "./admin-protocol";
|
|
46
|
+
import { GitpodHostUrl } from "./util/gitpod-host-url";
|
|
47
|
+
import { WebSocketConnectionProvider } from "./messaging/browser/connection";
|
|
48
|
+
import { PermissionName } from "./permission";
|
|
49
|
+
import { LicenseService } from "./license-protocol";
|
|
50
|
+
import { Emitter } from "./util/event";
|
|
51
|
+
import { AccountStatement, CreditAlert } from "./accounting-protocol";
|
|
52
|
+
import { GithubUpgradeURL, PlanCoupon } from "./payment-protocol";
|
|
53
|
+
import {
|
|
54
|
+
TeamSubscription,
|
|
55
|
+
TeamSubscription2,
|
|
56
|
+
TeamSubscriptionSlot,
|
|
57
|
+
TeamSubscriptionSlotResolved,
|
|
58
|
+
} from "./team-subscription-protocol";
|
|
59
|
+
import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
|
|
60
|
+
import { IDEServer } from "./ide-protocol";
|
|
61
|
+
import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
|
|
62
|
+
import { ListUsageRequest, ListUsageResponse } from "./usage";
|
|
63
|
+
import { SupportedWorkspaceClass } from "./workspace-class";
|
|
64
|
+
import { BillingMode } from "./billing-mode";
|
|
34
65
|
|
|
35
66
|
export interface GitpodClient {
|
|
36
67
|
onInstanceUpdate(instance: WorkspaceInstance): void;
|
|
@@ -38,6 +69,8 @@ export interface GitpodClient {
|
|
|
38
69
|
|
|
39
70
|
onPrebuildUpdate(update: PrebuildWithStatus): void;
|
|
40
71
|
|
|
72
|
+
onNotificationUpdated(): void;
|
|
73
|
+
|
|
41
74
|
onCreditAlert(creditAlert: CreditAlert): void;
|
|
42
75
|
|
|
43
76
|
//#region propagating reconnection to iframe
|
|
@@ -46,12 +79,14 @@ export interface GitpodClient {
|
|
|
46
79
|
//#endregion
|
|
47
80
|
}
|
|
48
81
|
|
|
49
|
-
export const GitpodServer = Symbol(
|
|
82
|
+
export const GitpodServer = Symbol("GitpodServer");
|
|
50
83
|
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
|
|
51
84
|
// User related API
|
|
52
85
|
getLoggedInUser(): Promise<User>;
|
|
53
86
|
getTerms(): Promise<Terms>;
|
|
54
87
|
updateLoggedInUser(user: Partial<User>): Promise<User>;
|
|
88
|
+
sendPhoneNumberVerificationToken(phoneNumber: string): Promise<void>;
|
|
89
|
+
verifyPhoneNumberVerificationToken(phoneNumber: string, token: string): Promise<boolean>;
|
|
55
90
|
getAuthProviders(): Promise<AuthProviderInfo[]>;
|
|
56
91
|
getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
|
|
57
92
|
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
|
|
@@ -122,7 +157,14 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
122
157
|
setEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
123
158
|
deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
124
159
|
|
|
160
|
+
// User SSH Keys
|
|
161
|
+
hasSSHPublicKey(): Promise<boolean>;
|
|
162
|
+
getSSHPublicKeys(): Promise<UserSSHPublicKeyValue[]>;
|
|
163
|
+
addSSHPublicKey(value: SSHPublicKeyValue): Promise<UserSSHPublicKeyValue>;
|
|
164
|
+
deleteSSHPublicKey(id: string): Promise<void>;
|
|
165
|
+
|
|
125
166
|
// Teams
|
|
167
|
+
getTeam(teamId: string): Promise<Team>;
|
|
126
168
|
getTeams(): Promise<Team[]>;
|
|
127
169
|
getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
|
|
128
170
|
createTeam(name: string): Promise<Team>;
|
|
@@ -131,7 +173,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
131
173
|
removeTeamMember(teamId: string, userId: string): Promise<void>;
|
|
132
174
|
getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
|
|
133
175
|
resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
|
|
134
|
-
deleteTeam(teamId: string
|
|
176
|
+
deleteTeam(teamId: string): Promise<void>;
|
|
135
177
|
|
|
136
178
|
// Admin Settings
|
|
137
179
|
adminGetSettings(): Promise<InstallationAdminSettings>;
|
|
@@ -145,22 +187,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
145
187
|
getTeamProjects(teamId: string): Promise<Project[]>;
|
|
146
188
|
getUserProjects(): Promise<Project[]>;
|
|
147
189
|
getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
|
|
190
|
+
getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
|
|
148
191
|
findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
|
|
192
|
+
findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
|
|
193
|
+
getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
|
|
149
194
|
triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
|
|
150
195
|
cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
|
|
151
|
-
fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
|
|
152
|
-
guessProjectConfiguration(projectId: string): Promise<string | undefined>;
|
|
153
|
-
fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
154
|
-
guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
155
|
-
setProjectConfiguration(projectId: string, configString: string): Promise<void>;
|
|
156
196
|
updateProjectPartial(partialProject: PartialProject): Promise<void>;
|
|
157
197
|
setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
|
|
158
198
|
getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
|
|
159
199
|
deleteProjectEnvironmentVariable(variableId: string): Promise<void>;
|
|
160
200
|
|
|
161
201
|
// content service
|
|
162
|
-
getContentBlobUploadUrl(name: string): Promise<string
|
|
163
|
-
getContentBlobDownloadUrl(name: string): Promise<string
|
|
202
|
+
getContentBlobUploadUrl(name: string): Promise<string>;
|
|
203
|
+
getContentBlobDownloadUrl(name: string): Promise<string>;
|
|
164
204
|
|
|
165
205
|
// Gitpod token
|
|
166
206
|
getGitpodTokens(): Promise<GitpodToken[]>;
|
|
@@ -168,7 +208,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
168
208
|
deleteGitpodToken(tokenHash: string): Promise<void>;
|
|
169
209
|
|
|
170
210
|
// misc
|
|
171
|
-
|
|
211
|
+
isGitHubAppEnabled(): Promise<boolean>;
|
|
172
212
|
registerGithubApp(installationId: string): Promise<void>;
|
|
173
213
|
|
|
174
214
|
/**
|
|
@@ -187,25 +227,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
187
227
|
*/
|
|
188
228
|
getSnapshots(workspaceID: string): Promise<string[]>;
|
|
189
229
|
|
|
190
|
-
/**
|
|
191
|
-
* stores/updates layout information for the given workspace
|
|
192
|
-
*/
|
|
193
|
-
storeLayout(workspaceId: string, layoutData: string): Promise<void>;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* retrieves layout information for the given workspace
|
|
197
|
-
*/
|
|
198
|
-
getLayout(workspaceId: string): Promise<string | undefined>;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @param params
|
|
202
|
-
* @returns promise resolves to an URL to be used for the upload
|
|
203
|
-
*/
|
|
204
|
-
preparePluginUpload(params: PreparePluginUploadParams): Promise<string>
|
|
205
|
-
resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
|
|
206
|
-
installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
|
|
207
|
-
uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
|
|
208
|
-
|
|
209
230
|
guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
|
|
210
231
|
|
|
211
232
|
/**
|
|
@@ -223,7 +244,9 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
223
244
|
*/
|
|
224
245
|
getChargebeeSiteId(): Promise<string>;
|
|
225
246
|
createPortalSession(): Promise<{}>;
|
|
247
|
+
createTeamPortalSession(teamId: string): Promise<{}>;
|
|
226
248
|
checkout(planId: string, planQuantity?: number): Promise<{}>;
|
|
249
|
+
teamCheckout(teamId: string, planId: string): Promise<{}>;
|
|
227
250
|
getAvailableCoupons(): Promise<PlanCoupon[]>;
|
|
228
251
|
getAppliedCoupons(): Promise<PlanCoupon[]>;
|
|
229
252
|
|
|
@@ -235,40 +258,67 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
235
258
|
subscriptionCancel(subscriptionId: string): Promise<void>;
|
|
236
259
|
subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
|
|
237
260
|
|
|
261
|
+
getTeamSubscription(teamId: string): Promise<TeamSubscription2 | undefined>;
|
|
238
262
|
tsGet(): Promise<TeamSubscription[]>;
|
|
239
263
|
tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
|
|
240
|
-
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined
|
|
264
|
+
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
|
|
241
265
|
tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
|
|
242
|
-
tsAssignSlot(
|
|
266
|
+
tsAssignSlot(
|
|
267
|
+
teamSubscriptionId: string,
|
|
268
|
+
teamSubscriptionSlotId: string,
|
|
269
|
+
identityStr: string | undefined,
|
|
270
|
+
): Promise<void>;
|
|
243
271
|
tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
|
|
244
272
|
tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
245
273
|
tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
246
274
|
|
|
247
275
|
getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
|
|
248
276
|
|
|
277
|
+
getStripePublishableKey(): Promise<string>;
|
|
278
|
+
getStripeSetupIntentClientSecret(): Promise<string>;
|
|
279
|
+
findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
|
|
280
|
+
createStripeCustomerIfNeeded(attributionId: string, currency: string): Promise<void>;
|
|
281
|
+
subscribeToStripe(attributionId: string, setupIntentId: string, usageLimit: number): Promise<number | undefined>;
|
|
282
|
+
getStripePortalUrl(attributionId: string): Promise<string>;
|
|
283
|
+
getUsageLimit(attributionId: string): Promise<number | undefined>;
|
|
284
|
+
setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
|
|
285
|
+
|
|
286
|
+
listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
|
|
287
|
+
|
|
288
|
+
setUsageAttribution(usageAttribution: string): Promise<void>;
|
|
289
|
+
listAvailableUsageAttributionIds(): Promise<string[]>;
|
|
290
|
+
|
|
291
|
+
getBillingModeForUser(): Promise<BillingMode>;
|
|
292
|
+
getBillingModeForTeam(teamId: string): Promise<BillingMode>;
|
|
293
|
+
|
|
249
294
|
/**
|
|
250
295
|
* Analytics
|
|
251
296
|
*/
|
|
252
297
|
trackEvent(event: RemoteTrackMessage): Promise<void>;
|
|
253
298
|
trackLocation(event: RemotePageMessage): Promise<void>;
|
|
254
299
|
identifyUser(event: RemoteIdentifyMessage): Promise<void>;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Frontend notifications
|
|
303
|
+
*/
|
|
304
|
+
getNotifications(): Promise<string[]>;
|
|
305
|
+
|
|
306
|
+
getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
|
|
255
307
|
}
|
|
256
308
|
|
|
257
309
|
export interface RateLimiterError {
|
|
258
|
-
method?: string
|
|
310
|
+
method?: string;
|
|
259
311
|
|
|
260
312
|
/**
|
|
261
313
|
* Retry after this many seconds, earliest.
|
|
262
314
|
* cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
263
315
|
*/
|
|
264
|
-
retryAfter: number
|
|
316
|
+
retryAfter: number;
|
|
265
317
|
}
|
|
266
318
|
|
|
267
319
|
export interface CreateProjectParams {
|
|
268
320
|
name: string;
|
|
269
|
-
slug
|
|
270
|
-
account: string;
|
|
271
|
-
provider: string;
|
|
321
|
+
slug: string;
|
|
272
322
|
cloneUrl: string;
|
|
273
323
|
teamId?: string;
|
|
274
324
|
userId?: string;
|
|
@@ -292,7 +342,7 @@ export interface ProviderRepository {
|
|
|
292
342
|
account: string;
|
|
293
343
|
accountAvatarUrl: string;
|
|
294
344
|
cloneUrl: string;
|
|
295
|
-
updatedAt
|
|
345
|
+
updatedAt?: string;
|
|
296
346
|
installationId?: number;
|
|
297
347
|
installationUpdatedAt?: string;
|
|
298
348
|
|
|
@@ -306,42 +356,56 @@ export interface ClientHeaderFields {
|
|
|
306
356
|
clientRegion?: string;
|
|
307
357
|
}
|
|
308
358
|
|
|
309
|
-
export const
|
|
310
|
-
|
|
311
|
-
export const
|
|
359
|
+
export const WORKSPACE_TIMEOUT_DEFAULT_SHORT = "short";
|
|
360
|
+
export const WORKSPACE_TIMEOUT_DEFAULT_LONG = "long";
|
|
361
|
+
export const WORKSPACE_TIMEOUT_EXTENDED = "extended";
|
|
362
|
+
export const WORKSPACE_TIMEOUT_EXTENDED_ALT = "180m"; // for backwards compatibility since the IDE uses this
|
|
363
|
+
export const WorkspaceTimeoutValues = [
|
|
364
|
+
WORKSPACE_TIMEOUT_DEFAULT_SHORT,
|
|
365
|
+
WORKSPACE_TIMEOUT_DEFAULT_LONG,
|
|
366
|
+
WORKSPACE_TIMEOUT_EXTENDED,
|
|
367
|
+
WORKSPACE_TIMEOUT_EXTENDED_ALT,
|
|
368
|
+
] as const;
|
|
369
|
+
|
|
370
|
+
export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
371
|
+
methods: Partial<JsonRpcProxy<S>>,
|
|
372
|
+
): GitpodServiceImpl<C, S> {
|
|
312
373
|
return new GitpodServiceImpl<C, S>(createServerMock(methods));
|
|
313
|
-
}
|
|
374
|
+
};
|
|
314
375
|
|
|
315
|
-
export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
316
|
-
methods
|
|
317
|
-
|
|
376
|
+
export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
377
|
+
methods: Partial<JsonRpcProxy<S>>,
|
|
378
|
+
): JsonRpcProxy<S> {
|
|
379
|
+
methods.setClient = methods.setClient || (() => {});
|
|
380
|
+
methods.dispose = methods.dispose || (() => {});
|
|
318
381
|
return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
|
|
319
382
|
// @ts-ignore
|
|
320
383
|
get: (target: S, property: keyof S) => {
|
|
321
384
|
const result = target[property];
|
|
322
385
|
if (!result) {
|
|
323
|
-
throw new Error(`Method ${property} not implemented`);
|
|
386
|
+
throw new Error(`Method ${String(property)} not implemented`);
|
|
324
387
|
}
|
|
325
388
|
return result;
|
|
326
|
-
}
|
|
389
|
+
},
|
|
327
390
|
});
|
|
328
|
-
}
|
|
391
|
+
};
|
|
329
392
|
|
|
330
393
|
type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
|
|
331
394
|
export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
|
|
332
395
|
|
|
333
396
|
export interface SetWorkspaceTimeoutResult {
|
|
334
|
-
resetTimeoutOnWorkspaces: string[]
|
|
397
|
+
resetTimeoutOnWorkspaces: string[];
|
|
335
398
|
}
|
|
336
399
|
|
|
337
400
|
export interface GetWorkspaceTimeoutResult {
|
|
338
|
-
duration: WorkspaceTimeoutDuration
|
|
339
|
-
|
|
401
|
+
duration: WorkspaceTimeoutDuration;
|
|
402
|
+
durationRaw: string;
|
|
403
|
+
canChange: boolean;
|
|
340
404
|
}
|
|
341
405
|
|
|
342
406
|
export interface StartWorkspaceResult {
|
|
343
|
-
instanceID: string
|
|
344
|
-
workspaceURL?: string
|
|
407
|
+
instanceID: string;
|
|
408
|
+
workspaceURL?: string;
|
|
345
409
|
}
|
|
346
410
|
|
|
347
411
|
export namespace GitpodServer {
|
|
@@ -357,7 +421,10 @@ export namespace GitpodServer {
|
|
|
357
421
|
}
|
|
358
422
|
export interface CreateWorkspaceOptions {
|
|
359
423
|
contextUrl: string;
|
|
360
|
-
|
|
424
|
+
// whether running workspaces on the same context should be ignored. If false (default) users will be asked.
|
|
425
|
+
ignoreRunningWorkspaceOnSameCommit?: boolean;
|
|
426
|
+
ignoreRunningPrebuild?: boolean;
|
|
427
|
+
allowUsingPreviousPrebuilds?: boolean;
|
|
361
428
|
forceDefaultConfig?: boolean;
|
|
362
429
|
}
|
|
363
430
|
export interface StartWorkspaceOptions {
|
|
@@ -365,7 +432,6 @@ export namespace GitpodServer {
|
|
|
365
432
|
}
|
|
366
433
|
export interface TakeSnapshotOptions {
|
|
367
434
|
workspaceId: string;
|
|
368
|
-
layoutData?: string;
|
|
369
435
|
/* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
|
|
370
436
|
dontWait?: boolean;
|
|
371
437
|
}
|
|
@@ -385,23 +451,23 @@ export namespace GitpodServer {
|
|
|
385
451
|
readonly roundTripTime?: number;
|
|
386
452
|
}
|
|
387
453
|
export interface UpdateOwnAuthProviderParams {
|
|
388
|
-
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
|
|
454
|
+
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
|
|
389
455
|
}
|
|
390
456
|
export interface DeleteOwnAuthProviderParams {
|
|
391
|
-
readonly id: string
|
|
457
|
+
readonly id: string;
|
|
392
458
|
}
|
|
393
459
|
export type AdmissionLevel = "owner" | "everyone";
|
|
394
460
|
export type PinAction = "pin" | "unpin" | "toggle";
|
|
395
461
|
export interface GenerateNewGitpodTokenOptions {
|
|
396
|
-
name?: string
|
|
397
|
-
type: GitpodTokenType
|
|
398
|
-
scopes?: string[]
|
|
462
|
+
name?: string;
|
|
463
|
+
type: GitpodTokenType;
|
|
464
|
+
scopes?: string[];
|
|
399
465
|
}
|
|
400
466
|
}
|
|
401
467
|
|
|
402
|
-
export const GitpodServerPath =
|
|
468
|
+
export const GitpodServerPath = "/gitpod";
|
|
403
469
|
|
|
404
|
-
export const GitpodServerProxy = Symbol(
|
|
470
|
+
export const GitpodServerProxy = Symbol("GitpodServerProxy");
|
|
405
471
|
export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
|
|
406
472
|
|
|
407
473
|
export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
|
|
@@ -415,8 +481,8 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
415
481
|
if (index > -1) {
|
|
416
482
|
this.clients.splice(index, 1);
|
|
417
483
|
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
484
|
+
},
|
|
485
|
+
};
|
|
420
486
|
}
|
|
421
487
|
|
|
422
488
|
onInstanceUpdate(instance: WorkspaceInstance): void {
|
|
@@ -425,7 +491,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
425
491
|
try {
|
|
426
492
|
client.onInstanceUpdate(instance);
|
|
427
493
|
} catch (error) {
|
|
428
|
-
console.error(error)
|
|
494
|
+
console.error(error);
|
|
429
495
|
}
|
|
430
496
|
}
|
|
431
497
|
}
|
|
@@ -437,19 +503,22 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
437
503
|
try {
|
|
438
504
|
client.onPrebuildUpdate(update);
|
|
439
505
|
} catch (error) {
|
|
440
|
-
console.error(error)
|
|
506
|
+
console.error(error);
|
|
441
507
|
}
|
|
442
508
|
}
|
|
443
509
|
}
|
|
444
510
|
}
|
|
445
511
|
|
|
446
|
-
onWorkspaceImageBuildLogs(
|
|
512
|
+
onWorkspaceImageBuildLogs(
|
|
513
|
+
info: WorkspaceImageBuild.StateInfo,
|
|
514
|
+
content: WorkspaceImageBuild.LogContent | undefined,
|
|
515
|
+
): void {
|
|
447
516
|
for (const client of this.clients) {
|
|
448
517
|
if (client.onWorkspaceImageBuildLogs) {
|
|
449
518
|
try {
|
|
450
519
|
client.onWorkspaceImageBuildLogs(info, content);
|
|
451
520
|
} catch (error) {
|
|
452
|
-
console.error(error)
|
|
521
|
+
console.error(error);
|
|
453
522
|
}
|
|
454
523
|
}
|
|
455
524
|
}
|
|
@@ -461,7 +530,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
461
530
|
try {
|
|
462
531
|
client.notifyDidOpenConnection();
|
|
463
532
|
} catch (error) {
|
|
464
|
-
console.error(error)
|
|
533
|
+
console.error(error);
|
|
465
534
|
}
|
|
466
535
|
}
|
|
467
536
|
}
|
|
@@ -473,7 +542,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
473
542
|
try {
|
|
474
543
|
client.notifyDidCloseConnection();
|
|
475
544
|
} catch (error) {
|
|
476
|
-
console.error(error)
|
|
545
|
+
console.error(error);
|
|
477
546
|
}
|
|
478
547
|
}
|
|
479
548
|
}
|
|
@@ -485,64 +554,73 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
485
554
|
try {
|
|
486
555
|
client.onCreditAlert(creditAlert);
|
|
487
556
|
} catch (error) {
|
|
488
|
-
console.error(error)
|
|
557
|
+
console.error(error);
|
|
489
558
|
}
|
|
490
559
|
}
|
|
491
560
|
}
|
|
492
561
|
}
|
|
493
562
|
|
|
563
|
+
onNotificationUpdated(): void {
|
|
564
|
+
for (const client of this.clients) {
|
|
565
|
+
if (client.onNotificationUpdated) {
|
|
566
|
+
try {
|
|
567
|
+
client.onNotificationUpdated();
|
|
568
|
+
} catch (error) {
|
|
569
|
+
console.error(error);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
494
574
|
}
|
|
495
575
|
|
|
496
576
|
export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
|
|
497
577
|
|
|
498
|
-
const hasWindow =
|
|
578
|
+
const hasWindow = typeof window !== "undefined";
|
|
499
579
|
const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
500
580
|
unknown: 0,
|
|
501
581
|
preparing: 1,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
582
|
+
building: 2,
|
|
583
|
+
pending: 3,
|
|
584
|
+
creating: 4,
|
|
585
|
+
initializing: 5,
|
|
586
|
+
running: 6,
|
|
587
|
+
interrupted: 7,
|
|
588
|
+
stopping: 8,
|
|
589
|
+
stopped: 9,
|
|
509
590
|
};
|
|
510
591
|
export class WorkspaceInstanceUpdateListener {
|
|
511
592
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
|
512
593
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
513
594
|
|
|
514
|
-
private source:
|
|
595
|
+
private source: "sync" | "update" = "sync";
|
|
515
596
|
|
|
516
597
|
get info(): WorkspaceInfo {
|
|
517
598
|
return this._info;
|
|
518
599
|
}
|
|
519
600
|
|
|
520
|
-
constructor(
|
|
521
|
-
private readonly service: GitpodService,
|
|
522
|
-
private _info: WorkspaceInfo
|
|
523
|
-
) {
|
|
601
|
+
constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
|
|
524
602
|
service.registerClient({
|
|
525
|
-
onInstanceUpdate: instance => {
|
|
603
|
+
onInstanceUpdate: (instance) => {
|
|
526
604
|
if (this.isOutOfOrder(instance)) {
|
|
527
605
|
return;
|
|
528
606
|
}
|
|
529
607
|
this.cancelSync();
|
|
530
608
|
this._info.latestInstance = instance;
|
|
531
|
-
this.source =
|
|
609
|
+
this.source = "update";
|
|
532
610
|
this.onDidChangeEmitter.fire(undefined);
|
|
533
611
|
},
|
|
534
612
|
notifyDidOpenConnection: () => {
|
|
535
613
|
this.sync();
|
|
536
|
-
}
|
|
614
|
+
},
|
|
537
615
|
});
|
|
538
616
|
if (hasWindow) {
|
|
539
617
|
// learn about page lifecycle here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
|
|
540
|
-
window.document.addEventListener(
|
|
541
|
-
if (window.document.visibilityState ===
|
|
618
|
+
window.document.addEventListener("visibilitychange", async () => {
|
|
619
|
+
if (window.document.visibilityState === "visible") {
|
|
542
620
|
this.sync();
|
|
543
621
|
}
|
|
544
622
|
});
|
|
545
|
-
window.addEventListener(
|
|
623
|
+
window.addEventListener("pageshow", (e) => {
|
|
546
624
|
if (e.persisted) {
|
|
547
625
|
this.sync();
|
|
548
626
|
}
|
|
@@ -570,12 +648,12 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
570
648
|
return;
|
|
571
649
|
}
|
|
572
650
|
this._info = info;
|
|
573
|
-
this.source =
|
|
651
|
+
this.source = "sync";
|
|
574
652
|
this.onDidChangeEmitter.fire(undefined);
|
|
575
653
|
} catch (e) {
|
|
576
|
-
console.error(
|
|
654
|
+
console.error("failed to sync workspace instance:", e);
|
|
577
655
|
}
|
|
578
|
-
})
|
|
656
|
+
});
|
|
579
657
|
}
|
|
580
658
|
private cancelSync(): void {
|
|
581
659
|
if (this.syncTokenSource) {
|
|
@@ -592,7 +670,7 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
592
670
|
if (instance.workspaceId !== this._info.workspace.id) {
|
|
593
671
|
return true;
|
|
594
672
|
}
|
|
595
|
-
if (this.source ===
|
|
673
|
+
if (this.source === "update") {
|
|
596
674
|
return false;
|
|
597
675
|
}
|
|
598
676
|
if (instance.id !== this.info.latestInstance?.id) {
|
|
@@ -600,15 +678,13 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
600
678
|
}
|
|
601
679
|
return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
|
|
602
680
|
}
|
|
603
|
-
|
|
604
681
|
}
|
|
605
682
|
|
|
606
683
|
export interface GitpodServiceOptions {
|
|
607
|
-
onReconnect?: () =>
|
|
684
|
+
onReconnect?: () => void | Promise<void>;
|
|
608
685
|
}
|
|
609
686
|
|
|
610
687
|
export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
|
|
611
|
-
|
|
612
688
|
private readonly compositeClient = new GitpodCompositeClient<Client>();
|
|
613
689
|
|
|
614
690
|
constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
|
|
@@ -623,7 +699,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
623
699
|
|
|
624
700
|
private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
|
|
625
701
|
listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
|
|
626
|
-
const listener =
|
|
702
|
+
const listener =
|
|
703
|
+
this.instanceListeners.get(workspaceId) ||
|
|
627
704
|
(async () => {
|
|
628
705
|
const info = await this.server.getWorkspace(workspaceId);
|
|
629
706
|
return new WorkspaceInstanceUpdateListener(this, info);
|
|
@@ -639,26 +716,25 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
639
716
|
}
|
|
640
717
|
}
|
|
641
718
|
|
|
642
|
-
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
|
|
719
|
+
export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
|
|
720
|
+
serverUrl: string | Promise<string>,
|
|
721
|
+
) {
|
|
643
722
|
const toWsUrl = (serverUrl: string) => {
|
|
644
|
-
return new GitpodHostUrl(serverUrl)
|
|
645
|
-
.asWebsocket()
|
|
646
|
-
.withApi({ pathname: GitpodServerPath })
|
|
647
|
-
.toString();
|
|
723
|
+
return new GitpodHostUrl(serverUrl).asWebsocket().withApi({ pathname: GitpodServerPath }).toString();
|
|
648
724
|
};
|
|
649
725
|
let url: string | Promise<string>;
|
|
650
726
|
if (typeof serverUrl === "string") {
|
|
651
727
|
url = toWsUrl(serverUrl);
|
|
652
728
|
} else {
|
|
653
|
-
url = serverUrl.then(url => toWsUrl(url));
|
|
729
|
+
url = serverUrl.then((url) => toWsUrl(url));
|
|
654
730
|
}
|
|
655
731
|
|
|
656
732
|
const connectionProvider = new WebSocketConnectionProvider();
|
|
657
|
-
let onReconnect = () => {
|
|
733
|
+
let onReconnect = () => {};
|
|
658
734
|
const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
|
|
659
|
-
onListening: socket => {
|
|
735
|
+
onListening: (socket) => {
|
|
660
736
|
onReconnect = () => socket.reconnect();
|
|
661
|
-
}
|
|
737
|
+
},
|
|
662
738
|
});
|
|
663
739
|
return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
|
|
664
|
-
}
|
|
740
|
+
}
|