@gitpod/gitpod-protocol 0.1.5-to-code-reading.1 → 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 +19 -0
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +4 -5
- 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 +18 -5
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +59 -6
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +2 -0
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +40 -4
- 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 +83 -45
- 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 +38 -6
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/index.d.ts +16 -15
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +30 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +31 -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 +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 +8 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +17 -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 +9 -3
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +34 -25
- 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 +192 -59
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +292 -104
- 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 +29 -5
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +8 -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 +8 -8
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +19 -20
- 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 +18 -17
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +16 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +39 -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 +15 -7
- package/pkg-yarn.lock +11 -6
- package/provenance-bundle.jsonl +3 -1
- package/src/accounting-protocol.ts +66 -51
- package/src/admin-protocol.ts +45 -18
- package/src/analytics.ts +26 -28
- 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 +37 -9
- package/src/context-url.ts +94 -36
- 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 +228 -129
- package/src/headless-workspace-log.ts +6 -4
- package/src/ide-frontend-service.ts +2 -2
- package/src/ide-protocol.ts +43 -6
- package/src/index.ts +16 -15
- package/src/installation-admin-protocol.ts +45 -0
- 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 +26 -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 +40 -32
- package/src/plans.ts +240 -189
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +556 -258
- package/src/snapshot-url.spec.ts +9 -7
- package/src/team-subscription-protocol.ts +59 -22
- package/src/teams-projects-protocol.ts +43 -12
- 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 +58 -54
- 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 +34 -20
- package/src/workspace-instance.ts +76 -20
- 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/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 -34
- 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/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -31
- package/lib/util/safe-promise.js.map +0 -1
- package/src/email-protocol.ts +0 -66
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/util/safe-promise.ts +0 -26
package/src/gitpod-service.ts
CHANGED
|
@@ -5,31 +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 {
|
|
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";
|
|
33
65
|
|
|
34
66
|
export interface GitpodClient {
|
|
35
67
|
onInstanceUpdate(instance: WorkspaceInstance): void;
|
|
@@ -37,6 +69,8 @@ export interface GitpodClient {
|
|
|
37
69
|
|
|
38
70
|
onPrebuildUpdate(update: PrebuildWithStatus): void;
|
|
39
71
|
|
|
72
|
+
onNotificationUpdated(): void;
|
|
73
|
+
|
|
40
74
|
onCreditAlert(creditAlert: CreditAlert): void;
|
|
41
75
|
|
|
42
76
|
//#region propagating reconnection to iframe
|
|
@@ -45,12 +79,14 @@ export interface GitpodClient {
|
|
|
45
79
|
//#endregion
|
|
46
80
|
}
|
|
47
81
|
|
|
48
|
-
export const GitpodServer = Symbol(
|
|
82
|
+
export const GitpodServer = Symbol("GitpodServer");
|
|
49
83
|
export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
|
|
50
84
|
// User related API
|
|
51
85
|
getLoggedInUser(): Promise<User>;
|
|
52
86
|
getTerms(): Promise<Terms>;
|
|
53
87
|
updateLoggedInUser(user: Partial<User>): Promise<User>;
|
|
88
|
+
sendPhoneNumberVerificationToken(phoneNumber: string): Promise<void>;
|
|
89
|
+
verifyPhoneNumberVerificationToken(phoneNumber: string, token: string): Promise<boolean>;
|
|
54
90
|
getAuthProviders(): Promise<AuthProviderInfo[]>;
|
|
55
91
|
getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
|
|
56
92
|
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
|
|
@@ -71,8 +107,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
71
107
|
getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
|
|
72
108
|
getWorkspaceUsers(workspaceId: string): Promise<WorkspaceInstanceUser[]>;
|
|
73
109
|
getFeaturedRepositories(): Promise<WhitelistedRepository[]>;
|
|
110
|
+
getSuggestedContextURLs(): Promise<string[]>;
|
|
111
|
+
/**
|
|
112
|
+
* **Security:**
|
|
113
|
+
* Sensitive information like an owner token is erased, since it allows access for all team members.
|
|
114
|
+
* If you need to access an owner token use `getOwnerToken` instead.
|
|
115
|
+
*/
|
|
74
116
|
getWorkspace(id: string): Promise<WorkspaceInfo>;
|
|
75
117
|
isWorkspaceOwner(workspaceId: string): Promise<boolean>;
|
|
118
|
+
getOwnerToken(workspaceId: string): Promise<string>;
|
|
76
119
|
|
|
77
120
|
/**
|
|
78
121
|
* Creates and starts a workspace for the given context URL.
|
|
@@ -114,7 +157,14 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
114
157
|
setEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
115
158
|
deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
116
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
|
+
|
|
117
166
|
// Teams
|
|
167
|
+
getTeam(teamId: string): Promise<Team>;
|
|
118
168
|
getTeams(): Promise<Team[]>;
|
|
119
169
|
getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
|
|
120
170
|
createTeam(name: string): Promise<Team>;
|
|
@@ -123,7 +173,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
123
173
|
removeTeamMember(teamId: string, userId: string): Promise<void>;
|
|
124
174
|
getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
|
|
125
175
|
resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
|
|
126
|
-
deleteTeam(teamId: string
|
|
176
|
+
deleteTeam(teamId: string): Promise<void>;
|
|
177
|
+
|
|
178
|
+
// Admin Settings
|
|
179
|
+
adminGetSettings(): Promise<InstallationAdminSettings>;
|
|
180
|
+
adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
|
|
181
|
+
adminGetTelemetryData(): Promise<TelemetryData>;
|
|
127
182
|
|
|
128
183
|
// Projects
|
|
129
184
|
getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
|
|
@@ -132,22 +187,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
132
187
|
getTeamProjects(teamId: string): Promise<Project[]>;
|
|
133
188
|
getUserProjects(): Promise<Project[]>;
|
|
134
189
|
getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
|
|
190
|
+
getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
|
|
135
191
|
findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
|
|
192
|
+
findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
|
|
193
|
+
getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
|
|
136
194
|
triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
|
|
137
195
|
cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
|
|
138
|
-
fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
|
|
139
|
-
guessProjectConfiguration(projectId: string): Promise<string | undefined>;
|
|
140
|
-
fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
141
|
-
guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
142
|
-
setProjectConfiguration(projectId: string, configString: string): Promise<void>;
|
|
143
196
|
updateProjectPartial(partialProject: PartialProject): Promise<void>;
|
|
144
197
|
setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
|
|
145
198
|
getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
|
|
146
199
|
deleteProjectEnvironmentVariable(variableId: string): Promise<void>;
|
|
147
200
|
|
|
148
201
|
// content service
|
|
149
|
-
getContentBlobUploadUrl(name: string): Promise<string
|
|
150
|
-
getContentBlobDownloadUrl(name: string): Promise<string
|
|
202
|
+
getContentBlobUploadUrl(name: string): Promise<string>;
|
|
203
|
+
getContentBlobDownloadUrl(name: string): Promise<string>;
|
|
151
204
|
|
|
152
205
|
// Gitpod token
|
|
153
206
|
getGitpodTokens(): Promise<GitpodToken[]>;
|
|
@@ -155,7 +208,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
155
208
|
deleteGitpodToken(tokenHash: string): Promise<void>;
|
|
156
209
|
|
|
157
210
|
// misc
|
|
158
|
-
|
|
211
|
+
isGitHubAppEnabled(): Promise<boolean>;
|
|
159
212
|
registerGithubApp(installationId: string): Promise<void>;
|
|
160
213
|
|
|
161
214
|
/**
|
|
@@ -174,25 +227,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
174
227
|
*/
|
|
175
228
|
getSnapshots(workspaceID: string): Promise<string[]>;
|
|
176
229
|
|
|
177
|
-
/**
|
|
178
|
-
* stores/updates layout information for the given workspace
|
|
179
|
-
*/
|
|
180
|
-
storeLayout(workspaceId: string, layoutData: string): Promise<void>;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* retrieves layout information for the given workspace
|
|
184
|
-
*/
|
|
185
|
-
getLayout(workspaceId: string): Promise<string | undefined>;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @param params
|
|
189
|
-
* @returns promise resolves to an URL to be used for the upload
|
|
190
|
-
*/
|
|
191
|
-
preparePluginUpload(params: PreparePluginUploadParams): Promise<string>
|
|
192
|
-
resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
|
|
193
|
-
installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
|
|
194
|
-
uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
|
|
195
|
-
|
|
196
230
|
guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
|
|
197
231
|
|
|
198
232
|
/**
|
|
@@ -210,7 +244,9 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
210
244
|
*/
|
|
211
245
|
getChargebeeSiteId(): Promise<string>;
|
|
212
246
|
createPortalSession(): Promise<{}>;
|
|
247
|
+
createTeamPortalSession(teamId: string): Promise<{}>;
|
|
213
248
|
checkout(planId: string, planQuantity?: number): Promise<{}>;
|
|
249
|
+
teamCheckout(teamId: string, planId: string): Promise<{}>;
|
|
214
250
|
getAvailableCoupons(): Promise<PlanCoupon[]>;
|
|
215
251
|
getAppliedCoupons(): Promise<PlanCoupon[]>;
|
|
216
252
|
|
|
@@ -222,30 +258,67 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
222
258
|
subscriptionCancel(subscriptionId: string): Promise<void>;
|
|
223
259
|
subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
|
|
224
260
|
|
|
261
|
+
getTeamSubscription(teamId: string): Promise<TeamSubscription2 | undefined>;
|
|
225
262
|
tsGet(): Promise<TeamSubscription[]>;
|
|
226
263
|
tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
|
|
227
|
-
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined
|
|
264
|
+
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
|
|
228
265
|
tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
|
|
229
|
-
tsAssignSlot(
|
|
266
|
+
tsAssignSlot(
|
|
267
|
+
teamSubscriptionId: string,
|
|
268
|
+
teamSubscriptionSlotId: string,
|
|
269
|
+
identityStr: string | undefined,
|
|
270
|
+
): Promise<void>;
|
|
230
271
|
tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
|
|
231
272
|
tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
232
273
|
tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
|
|
233
274
|
|
|
234
275
|
getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
|
|
235
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
|
+
|
|
236
294
|
/**
|
|
237
295
|
* Analytics
|
|
238
296
|
*/
|
|
239
297
|
trackEvent(event: RemoteTrackMessage): Promise<void>;
|
|
240
298
|
trackLocation(event: RemotePageMessage): Promise<void>;
|
|
241
299
|
identifyUser(event: RemoteIdentifyMessage): Promise<void>;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Frontend notifications
|
|
303
|
+
*/
|
|
304
|
+
getNotifications(): Promise<string[]>;
|
|
305
|
+
|
|
306
|
+
getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface RateLimiterError {
|
|
310
|
+
method?: string;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Retry after this many seconds, earliest.
|
|
314
|
+
* cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
315
|
+
*/
|
|
316
|
+
retryAfter: number;
|
|
242
317
|
}
|
|
243
318
|
|
|
244
319
|
export interface CreateProjectParams {
|
|
245
320
|
name: string;
|
|
246
|
-
slug
|
|
247
|
-
account: string;
|
|
248
|
-
provider: string;
|
|
321
|
+
slug: string;
|
|
249
322
|
cloneUrl: string;
|
|
250
323
|
teamId?: string;
|
|
251
324
|
userId?: string;
|
|
@@ -269,7 +342,7 @@ export interface ProviderRepository {
|
|
|
269
342
|
account: string;
|
|
270
343
|
accountAvatarUrl: string;
|
|
271
344
|
cloneUrl: string;
|
|
272
|
-
updatedAt
|
|
345
|
+
updatedAt?: string;
|
|
273
346
|
installationId?: number;
|
|
274
347
|
installationUpdatedAt?: string;
|
|
275
348
|
|
|
@@ -283,42 +356,56 @@ export interface ClientHeaderFields {
|
|
|
283
356
|
clientRegion?: string;
|
|
284
357
|
}
|
|
285
358
|
|
|
286
|
-
export const
|
|
287
|
-
|
|
288
|
-
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> {
|
|
289
373
|
return new GitpodServiceImpl<C, S>(createServerMock(methods));
|
|
290
|
-
}
|
|
374
|
+
};
|
|
291
375
|
|
|
292
|
-
export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
293
|
-
methods
|
|
294
|
-
|
|
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 || (() => {});
|
|
295
381
|
return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
|
|
296
382
|
// @ts-ignore
|
|
297
383
|
get: (target: S, property: keyof S) => {
|
|
298
384
|
const result = target[property];
|
|
299
385
|
if (!result) {
|
|
300
|
-
throw new Error(`Method ${property} not implemented`);
|
|
386
|
+
throw new Error(`Method ${String(property)} not implemented`);
|
|
301
387
|
}
|
|
302
388
|
return result;
|
|
303
|
-
}
|
|
389
|
+
},
|
|
304
390
|
});
|
|
305
|
-
}
|
|
391
|
+
};
|
|
306
392
|
|
|
307
393
|
type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
|
|
308
394
|
export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
|
|
309
395
|
|
|
310
396
|
export interface SetWorkspaceTimeoutResult {
|
|
311
|
-
resetTimeoutOnWorkspaces: string[]
|
|
397
|
+
resetTimeoutOnWorkspaces: string[];
|
|
312
398
|
}
|
|
313
399
|
|
|
314
400
|
export interface GetWorkspaceTimeoutResult {
|
|
315
|
-
duration: WorkspaceTimeoutDuration
|
|
316
|
-
|
|
401
|
+
duration: WorkspaceTimeoutDuration;
|
|
402
|
+
durationRaw: string;
|
|
403
|
+
canChange: boolean;
|
|
317
404
|
}
|
|
318
405
|
|
|
319
406
|
export interface StartWorkspaceResult {
|
|
320
|
-
instanceID: string
|
|
321
|
-
workspaceURL?: string
|
|
407
|
+
instanceID: string;
|
|
408
|
+
workspaceURL?: string;
|
|
322
409
|
}
|
|
323
410
|
|
|
324
411
|
export namespace GitpodServer {
|
|
@@ -334,7 +421,10 @@ export namespace GitpodServer {
|
|
|
334
421
|
}
|
|
335
422
|
export interface CreateWorkspaceOptions {
|
|
336
423
|
contextUrl: string;
|
|
337
|
-
|
|
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;
|
|
338
428
|
forceDefaultConfig?: boolean;
|
|
339
429
|
}
|
|
340
430
|
export interface StartWorkspaceOptions {
|
|
@@ -342,7 +432,6 @@ export namespace GitpodServer {
|
|
|
342
432
|
}
|
|
343
433
|
export interface TakeSnapshotOptions {
|
|
344
434
|
workspaceId: string;
|
|
345
|
-
layoutData?: string;
|
|
346
435
|
/* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
|
|
347
436
|
dontWait?: boolean;
|
|
348
437
|
}
|
|
@@ -362,23 +451,23 @@ export namespace GitpodServer {
|
|
|
362
451
|
readonly roundTripTime?: number;
|
|
363
452
|
}
|
|
364
453
|
export interface UpdateOwnAuthProviderParams {
|
|
365
|
-
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
|
|
454
|
+
readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
|
|
366
455
|
}
|
|
367
456
|
export interface DeleteOwnAuthProviderParams {
|
|
368
|
-
readonly id: string
|
|
457
|
+
readonly id: string;
|
|
369
458
|
}
|
|
370
459
|
export type AdmissionLevel = "owner" | "everyone";
|
|
371
460
|
export type PinAction = "pin" | "unpin" | "toggle";
|
|
372
461
|
export interface GenerateNewGitpodTokenOptions {
|
|
373
|
-
name?: string
|
|
374
|
-
type: GitpodTokenType
|
|
375
|
-
scopes?: string[]
|
|
462
|
+
name?: string;
|
|
463
|
+
type: GitpodTokenType;
|
|
464
|
+
scopes?: string[];
|
|
376
465
|
}
|
|
377
466
|
}
|
|
378
467
|
|
|
379
|
-
export const GitpodServerPath =
|
|
468
|
+
export const GitpodServerPath = "/gitpod";
|
|
380
469
|
|
|
381
|
-
export const GitpodServerProxy = Symbol(
|
|
470
|
+
export const GitpodServerProxy = Symbol("GitpodServerProxy");
|
|
382
471
|
export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
|
|
383
472
|
|
|
384
473
|
export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
|
|
@@ -392,8 +481,8 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
392
481
|
if (index > -1) {
|
|
393
482
|
this.clients.splice(index, 1);
|
|
394
483
|
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
484
|
+
},
|
|
485
|
+
};
|
|
397
486
|
}
|
|
398
487
|
|
|
399
488
|
onInstanceUpdate(instance: WorkspaceInstance): void {
|
|
@@ -402,7 +491,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
402
491
|
try {
|
|
403
492
|
client.onInstanceUpdate(instance);
|
|
404
493
|
} catch (error) {
|
|
405
|
-
console.error(error)
|
|
494
|
+
console.error(error);
|
|
406
495
|
}
|
|
407
496
|
}
|
|
408
497
|
}
|
|
@@ -414,19 +503,22 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
414
503
|
try {
|
|
415
504
|
client.onPrebuildUpdate(update);
|
|
416
505
|
} catch (error) {
|
|
417
|
-
console.error(error)
|
|
506
|
+
console.error(error);
|
|
418
507
|
}
|
|
419
508
|
}
|
|
420
509
|
}
|
|
421
510
|
}
|
|
422
511
|
|
|
423
|
-
onWorkspaceImageBuildLogs(
|
|
512
|
+
onWorkspaceImageBuildLogs(
|
|
513
|
+
info: WorkspaceImageBuild.StateInfo,
|
|
514
|
+
content: WorkspaceImageBuild.LogContent | undefined,
|
|
515
|
+
): void {
|
|
424
516
|
for (const client of this.clients) {
|
|
425
517
|
if (client.onWorkspaceImageBuildLogs) {
|
|
426
518
|
try {
|
|
427
519
|
client.onWorkspaceImageBuildLogs(info, content);
|
|
428
520
|
} catch (error) {
|
|
429
|
-
console.error(error)
|
|
521
|
+
console.error(error);
|
|
430
522
|
}
|
|
431
523
|
}
|
|
432
524
|
}
|
|
@@ -438,7 +530,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
438
530
|
try {
|
|
439
531
|
client.notifyDidOpenConnection();
|
|
440
532
|
} catch (error) {
|
|
441
|
-
console.error(error)
|
|
533
|
+
console.error(error);
|
|
442
534
|
}
|
|
443
535
|
}
|
|
444
536
|
}
|
|
@@ -450,7 +542,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
450
542
|
try {
|
|
451
543
|
client.notifyDidCloseConnection();
|
|
452
544
|
} catch (error) {
|
|
453
|
-
console.error(error)
|
|
545
|
+
console.error(error);
|
|
454
546
|
}
|
|
455
547
|
}
|
|
456
548
|
}
|
|
@@ -462,64 +554,73 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
462
554
|
try {
|
|
463
555
|
client.onCreditAlert(creditAlert);
|
|
464
556
|
} catch (error) {
|
|
465
|
-
console.error(error)
|
|
557
|
+
console.error(error);
|
|
466
558
|
}
|
|
467
559
|
}
|
|
468
560
|
}
|
|
469
561
|
}
|
|
470
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
|
+
}
|
|
471
574
|
}
|
|
472
575
|
|
|
473
576
|
export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
|
|
474
577
|
|
|
475
|
-
const hasWindow =
|
|
578
|
+
const hasWindow = typeof window !== "undefined";
|
|
476
579
|
const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
477
580
|
unknown: 0,
|
|
478
581
|
preparing: 1,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
582
|
+
building: 2,
|
|
583
|
+
pending: 3,
|
|
584
|
+
creating: 4,
|
|
585
|
+
initializing: 5,
|
|
586
|
+
running: 6,
|
|
587
|
+
interrupted: 7,
|
|
588
|
+
stopping: 8,
|
|
589
|
+
stopped: 9,
|
|
486
590
|
};
|
|
487
591
|
export class WorkspaceInstanceUpdateListener {
|
|
488
592
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
|
489
593
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
490
594
|
|
|
491
|
-
private source:
|
|
595
|
+
private source: "sync" | "update" = "sync";
|
|
492
596
|
|
|
493
597
|
get info(): WorkspaceInfo {
|
|
494
598
|
return this._info;
|
|
495
599
|
}
|
|
496
600
|
|
|
497
|
-
constructor(
|
|
498
|
-
private readonly service: GitpodService,
|
|
499
|
-
private _info: WorkspaceInfo
|
|
500
|
-
) {
|
|
601
|
+
constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
|
|
501
602
|
service.registerClient({
|
|
502
|
-
onInstanceUpdate: instance => {
|
|
603
|
+
onInstanceUpdate: (instance) => {
|
|
503
604
|
if (this.isOutOfOrder(instance)) {
|
|
504
605
|
return;
|
|
505
606
|
}
|
|
506
607
|
this.cancelSync();
|
|
507
608
|
this._info.latestInstance = instance;
|
|
508
|
-
this.source =
|
|
609
|
+
this.source = "update";
|
|
509
610
|
this.onDidChangeEmitter.fire(undefined);
|
|
510
611
|
},
|
|
511
612
|
notifyDidOpenConnection: () => {
|
|
512
613
|
this.sync();
|
|
513
|
-
}
|
|
614
|
+
},
|
|
514
615
|
});
|
|
515
616
|
if (hasWindow) {
|
|
516
617
|
// learn about page lifecycle here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
|
|
517
|
-
window.document.addEventListener(
|
|
518
|
-
if (window.document.visibilityState ===
|
|
618
|
+
window.document.addEventListener("visibilitychange", async () => {
|
|
619
|
+
if (window.document.visibilityState === "visible") {
|
|
519
620
|
this.sync();
|
|
520
621
|
}
|
|
521
622
|
});
|
|
522
|
-
window.addEventListener(
|
|
623
|
+
window.addEventListener("pageshow", (e) => {
|
|
523
624
|
if (e.persisted) {
|
|
524
625
|
this.sync();
|
|
525
626
|
}
|
|
@@ -547,12 +648,12 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
547
648
|
return;
|
|
548
649
|
}
|
|
549
650
|
this._info = info;
|
|
550
|
-
this.source =
|
|
651
|
+
this.source = "sync";
|
|
551
652
|
this.onDidChangeEmitter.fire(undefined);
|
|
552
653
|
} catch (e) {
|
|
553
|
-
console.error(
|
|
654
|
+
console.error("failed to sync workspace instance:", e);
|
|
554
655
|
}
|
|
555
|
-
})
|
|
656
|
+
});
|
|
556
657
|
}
|
|
557
658
|
private cancelSync(): void {
|
|
558
659
|
if (this.syncTokenSource) {
|
|
@@ -569,7 +670,7 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
569
670
|
if (instance.workspaceId !== this._info.workspace.id) {
|
|
570
671
|
return true;
|
|
571
672
|
}
|
|
572
|
-
if (this.source ===
|
|
673
|
+
if (this.source === "update") {
|
|
573
674
|
return false;
|
|
574
675
|
}
|
|
575
676
|
if (instance.id !== this.info.latestInstance?.id) {
|
|
@@ -577,15 +678,13 @@ export class WorkspaceInstanceUpdateListener {
|
|
|
577
678
|
}
|
|
578
679
|
return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
|
|
579
680
|
}
|
|
580
|
-
|
|
581
681
|
}
|
|
582
682
|
|
|
583
683
|
export interface GitpodServiceOptions {
|
|
584
|
-
onReconnect?: () =>
|
|
684
|
+
onReconnect?: () => void | Promise<void>;
|
|
585
685
|
}
|
|
586
686
|
|
|
587
687
|
export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
|
|
588
|
-
|
|
589
688
|
private readonly compositeClient = new GitpodCompositeClient<Client>();
|
|
590
689
|
|
|
591
690
|
constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
|
|
@@ -600,7 +699,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
600
699
|
|
|
601
700
|
private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
|
|
602
701
|
listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
|
|
603
|
-
const listener =
|
|
702
|
+
const listener =
|
|
703
|
+
this.instanceListeners.get(workspaceId) ||
|
|
604
704
|
(async () => {
|
|
605
705
|
const info = await this.server.getWorkspace(workspaceId);
|
|
606
706
|
return new WorkspaceInstanceUpdateListener(this, info);
|
|
@@ -616,26 +716,25 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
|
|
|
616
716
|
}
|
|
617
717
|
}
|
|
618
718
|
|
|
619
|
-
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
|
+
) {
|
|
620
722
|
const toWsUrl = (serverUrl: string) => {
|
|
621
|
-
return new GitpodHostUrl(serverUrl)
|
|
622
|
-
.asWebsocket()
|
|
623
|
-
.withApi({ pathname: GitpodServerPath })
|
|
624
|
-
.toString();
|
|
723
|
+
return new GitpodHostUrl(serverUrl).asWebsocket().withApi({ pathname: GitpodServerPath }).toString();
|
|
625
724
|
};
|
|
626
725
|
let url: string | Promise<string>;
|
|
627
726
|
if (typeof serverUrl === "string") {
|
|
628
727
|
url = toWsUrl(serverUrl);
|
|
629
728
|
} else {
|
|
630
|
-
url = serverUrl.then(url => toWsUrl(url));
|
|
729
|
+
url = serverUrl.then((url) => toWsUrl(url));
|
|
631
730
|
}
|
|
632
731
|
|
|
633
732
|
const connectionProvider = new WebSocketConnectionProvider();
|
|
634
|
-
let onReconnect = () => {
|
|
733
|
+
let onReconnect = () => {};
|
|
635
734
|
const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
|
|
636
|
-
onListening: socket => {
|
|
735
|
+
onListening: (socket) => {
|
|
637
736
|
onReconnect = () => socket.reconnect();
|
|
638
|
-
}
|
|
737
|
+
},
|
|
639
738
|
});
|
|
640
739
|
return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
|
|
641
|
-
}
|
|
740
|
+
}
|