@gitpod/gitpod-protocol 0.1.5-wth-test.80 → 0.1.5-wv-remove-without-ws-flag.5
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 +132 -5
- package/lib/accounting-protocol.d.ts +19 -11
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +35 -33
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +19 -2
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +1 -1
- package/lib/analytics.d.ts.map +1 -1
- package/lib/analytics.js +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 +1 -1
- package/lib/auth.d.ts.map +1 -1
- package/lib/auth.js +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 +1 -2
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +5 -7
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +1 -3
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +13 -26
- package/lib/context-url.spec.js.map +1 -1
- package/lib/encryption/container-module.d.ts +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +2 -2
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +10 -10
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +3 -4
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts +1 -1
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +2 -2
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts +1 -1
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +8 -10
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -6
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +2 -21
- 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 +37 -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/frontend-dashboard-service.d.ts +90 -0
- package/lib/frontend-dashboard-service.d.ts.map +1 -0
- package/lib/frontend-dashboard-service.js +49 -0
- package/lib/frontend-dashboard-service.js.map +1 -0
- package/lib/gitpod-file-parser.d.ts +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +7 -7
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.d.ts +1 -1
- package/lib/gitpod-file-parser.spec.js +43 -40
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +73 -55
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +61 -34
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +2 -1
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +3 -2
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +2 -2
- package/lib/ide-frontend-service.js +1 -1
- package/lib/ide-protocol.d.ts +29 -8
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/ide-protocol.js +11 -1
- package/lib/ide-protocol.js.map +1 -1
- package/lib/index.d.ts +17 -17
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +4 -1
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +4 -3
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts +8 -1
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js +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 +5 -5
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +10 -7
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +5 -19
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +35 -23
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts +10 -2
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +20 -4
- 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/oss-allowlist.d.ts +1 -1
- package/lib/oss-allowlist.js +1 -1
- package/lib/payment-protocol.d.ts +1 -1
- package/lib/payment-protocol.d.ts.map +1 -1
- package/lib/payment-protocol.js +2 -2
- package/lib/payment-protocol.js.map +1 -1
- package/lib/permission.d.ts +7 -4
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +16 -24
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +5 -4
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +211 -172
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +167 -61
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +282 -106
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.spec.d.ts +7 -0
- 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.d.ts +1 -1
- package/lib/snapshot-url.js +1 -1
- package/lib/snapshot-url.spec.d.ts +1 -1
- package/lib/snapshot-url.spec.js +1 -1
- package/lib/snapshot-url.spec.js.map +1 -1
- package/lib/team-subscription-protocol.d.ts +23 -4
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +21 -6
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +29 -6
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +10 -3
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +3 -3
- package/lib/typings/globals.d.ts.map +1 -1
- package/lib/typings/globals.js +1 -1
- package/lib/usage.d.ts +73 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +20 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/analytics.d.ts +1 -1
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +7 -7
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.d.ts +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +4 -4
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.d.ts +1 -1
- package/lib/util/cancelable.js +1 -1
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.d.ts +1 -1
- package/lib/util/date-time.js +7 -7
- 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/deep-partial.d.ts +1 -1
- package/lib/util/deep-partial.js +1 -1
- package/lib/util/deferred.d.ts +1 -1
- package/lib/util/deferred.js +1 -1
- 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 +1 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +7 -2
- 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.d.ts +1 -1
- package/lib/util/generate-workspace-id.spec.js +19 -8
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +2 -2
- package/lib/util/gitpod-cookie.d.ts.map +1 -1
- package/lib/util/gitpod-cookie.js +1 -4
- package/lib/util/gitpod-cookie.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts +12 -3
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +69 -35
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +16 -6
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +21 -1
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js +74 -2
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts +1 -1
- package/lib/util/jaeger-client-types.d.ts.map +1 -1
- package/lib/util/jaeger-client-types.js +1 -1
- package/lib/util/logging.d.ts +2 -2
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +32 -26
- 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.d.ts +1 -1
- package/lib/util/make-link.js +6 -6
- 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 +121 -0
- package/lib/util/nice-grpc.js.map +1 -0
- package/lib/util/parse-workspace-id.d.ts +1 -1
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +2 -3
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +1 -1
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.d.ts +1 -1
- package/lib/util/queue.js +1 -1
- package/lib/util/queue.spec.d.ts +1 -1
- package/lib/util/queue.spec.js +10 -7
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +1 -1
- package/lib/util/repeat.js +1 -1
- package/lib/util/semaphore.d.ts +1 -1
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js +1 -1
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js +1 -1
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts +3 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +16 -4
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts +3 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +35 -1
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +7 -7
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +15 -17
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +1 -1
- package/lib/util/tracing.spec.js +4 -4
- package/lib/util/tracing.spec.js.map +1 -1
- package/lib/util/workspace-port-authentication.d.ts +8 -8
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +9 -12
- 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/webhook-event.js +8 -0
- 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 +13 -14
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +3 -5
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +22 -4
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/workspace-instance.js +1 -1
- package/lib/wsready.d.ts +8 -2
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +3 -3
- package/package.json +14 -6
- package/pkg-yarn.lock +10 -5
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +67 -52
- package/src/admin-protocol.ts +48 -22
- package/src/analytics.ts +22 -22
- package/src/attribution.ts +63 -0
- package/src/auth.ts +3 -3
- package/src/billing-mode.ts +84 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/context-url.spec.ts +18 -22
- package/src/context-url.ts +79 -79
- package/src/encryption/container-module.ts +3 -4
- package/src/encryption/encryption-engine.spec.ts +10 -9
- package/src/encryption/encryption-engine.ts +21 -17
- package/src/encryption/encryption-service.ts +5 -6
- package/src/encryption/key-provider.ts +17 -20
- package/src/env.ts +2 -25
- package/src/experiments/always-default.ts +24 -0
- package/src/experiments/configcat-server.ts +42 -0
- package/src/experiments/configcat.ts +56 -0
- package/src/experiments/types.ts +34 -0
- package/src/frontend-dashboard-service.ts +125 -0
- package/src/gitpod-file-parser.spec.ts +56 -62
- package/src/gitpod-file-parser.ts +17 -18
- package/src/gitpod-service.ts +224 -142
- package/src/headless-workspace-log.ts +7 -5
- package/src/ide-frontend-service.ts +3 -3
- package/src/ide-protocol.ts +38 -10
- package/src/index.ts +17 -17
- package/src/installation-admin-protocol.ts +12 -9
- package/src/license-protocol.ts +13 -7
- package/src/messaging/browser/connection.ts +45 -47
- package/src/messaging/browser/window-connection.ts +40 -30
- package/src/messaging/client-call-metrics.ts +79 -82
- package/src/messaging/error.ts +30 -8
- 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 +4 -4
- package/src/payment-protocol.ts +3 -3
- package/src/permission.ts +25 -32
- package/src/plans.ts +241 -190
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +527 -265
- package/src/snapshot-url.spec.ts +10 -8
- package/src/snapshot-url.ts +1 -1
- package/src/team-subscription-protocol.ts +60 -23
- package/src/teams-projects-protocol.ts +42 -12
- package/src/typings/globals.ts +6 -5
- package/src/usage.ts +85 -0
- package/src/util/analytics.ts +47 -43
- package/src/util/async-iterator.ts +5 -6
- package/src/util/cancelable.ts +4 -4
- package/src/util/date-time.ts +9 -9
- package/src/util/debug-app.ts +81 -0
- package/src/util/deep-partial.ts +1 -1
- package/src/util/deferred.ts +7 -7
- package/src/util/disposable.ts +3 -6
- package/src/util/event.ts +9 -11
- package/src/util/garbage-collected-cache.ts +9 -7
- package/src/util/generate-workspace-id.spec.ts +27 -17
- package/src/util/generate-workspace-id.ts +461 -455
- package/src/util/gitpod-cookie.ts +9 -10
- package/src/util/gitpod-host-url.spec.ts +41 -14
- package/src/util/gitpod-host-url.ts +82 -39
- package/src/util/grpc.ts +94 -2
- package/src/util/jaeger-client-types.ts +3 -3
- package/src/util/logging.spec.ts +23 -0
- package/src/util/logging.ts +61 -43
- package/src/util/make-link.ts +7 -8
- package/src/util/nice-grpc.ts +96 -0
- package/src/util/parse-workspace-id.spec.ts +18 -9
- package/src/util/parse-workspace-id.ts +6 -7
- package/src/util/queue.spec.ts +28 -26
- package/src/util/queue.ts +1 -1
- package/src/util/repeat.ts +2 -2
- package/src/util/semaphore.ts +5 -7
- package/src/util/skip-if.ts +10 -7
- package/src/util/timeutil.spec.ts +41 -15
- package/src/util/timeutil.ts +28 -12
- package/src/util/tracing.spec.ts +29 -24
- package/src/util/tracing.ts +55 -52
- package/src/util/workspace-port-authentication.ts +11 -14
- package/src/webhook-event.ts +55 -0
- package/src/workspace-class.ts +14 -0
- package/src/workspace-cluster.ts +25 -19
- package/src/workspace-instance.ts +67 -25
- package/src/wsready.ts +11 -4
- 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 +0 -8
- package/lib/theia-plugins.js.map +0 -1
- package/src/email-protocol.ts +0 -66
- package/src/theia-plugins.ts +0 -11
package/src/admin-protocol.ts
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { User, Workspace, NamedWorkspaceFeatureFlag } from "./protocol";
|
|
8
|
+
import { BlockedRepository } from "./blocked-repositories-protocol";
|
|
8
9
|
import { FindPrebuildsParams } from "./gitpod-service";
|
|
9
|
-
import { Project, Team, PrebuildWithStatus, TeamMemberInfo, TeamMemberRole } from "./teams-projects-protocol"
|
|
10
|
+
import { Project, Team, PrebuildWithStatus, TeamMemberInfo, TeamMemberRole } from "./teams-projects-protocol";
|
|
10
11
|
import { WorkspaceInstance, WorkspaceInstancePhase } from "./workspace-instance";
|
|
11
12
|
import { RoleOrPermission } from "./permission";
|
|
12
13
|
import { AccountStatement } from "./accounting-protocol";
|
|
13
|
-
import {
|
|
14
|
+
import { BillingMode } from "./billing-mode";
|
|
15
|
+
import { CostCenterJSON, ListUsageRequest, ListUsageResponse } from "./usage";
|
|
16
|
+
import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
|
|
14
17
|
|
|
15
18
|
export interface AdminServer {
|
|
16
19
|
adminGetUsers(req: AdminGetListRequest<User>): Promise<AdminGetListResult<User>>;
|
|
17
20
|
adminGetUser(id: string): Promise<User>;
|
|
18
21
|
adminBlockUser(req: AdminBlockUserRequest): Promise<User>;
|
|
19
22
|
adminDeleteUser(id: string): Promise<void>;
|
|
23
|
+
adminVerifyUser(id: string): Promise<User>;
|
|
20
24
|
adminModifyRoleOrPermission(req: AdminModifyRoleOrPermissionRequest): Promise<User>;
|
|
21
25
|
adminModifyPermanentWorkspaceFeatureFlag(req: AdminModifyPermanentWorkspaceFeatureFlagRequest): Promise<User>;
|
|
22
26
|
|
|
27
|
+
adminCreateBlockedRepository(urlRegexp: string, blockUser: boolean): Promise<BlockedRepository>;
|
|
28
|
+
adminDeleteBlockedRepository(id: number): Promise<void>;
|
|
29
|
+
adminGetBlockedRepositories(
|
|
30
|
+
req: AdminGetListRequest<BlockedRepository>,
|
|
31
|
+
): Promise<AdminGetListResult<BlockedRepository>>;
|
|
32
|
+
|
|
23
33
|
adminGetTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
|
|
24
34
|
adminGetTeams(req: AdminGetListRequest<Team>): Promise<AdminGetListResult<Team>>;
|
|
25
35
|
adminGetTeamById(id: string): Promise<Team | undefined>;
|
|
@@ -41,46 +51,61 @@ export interface AdminServer {
|
|
|
41
51
|
adminIsStudent(userId: string): Promise<boolean>;
|
|
42
52
|
adminAddStudentEmailDomain(userId: string, domain: string): Promise<void>;
|
|
43
53
|
adminGrantExtraHours(userId: string, extraHours: number): Promise<void>;
|
|
54
|
+
adminGetBillingMode(attributionId: string): Promise<BillingMode>;
|
|
55
|
+
|
|
56
|
+
adminGetSettings(): Promise<InstallationAdminSettings>;
|
|
57
|
+
adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
|
|
58
|
+
|
|
59
|
+
adminGetCostCenter(attributionId: string): Promise<CostCenterJSON | undefined>;
|
|
60
|
+
adminSetUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
adminListUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
|
|
63
|
+
adminAddUsageCreditNote(attributionId: string, credits: number, note: string): Promise<void>;
|
|
64
|
+
adminGetUsageBalance(attributionId: string): Promise<number>;
|
|
65
|
+
|
|
66
|
+
// Admin Settings
|
|
67
|
+
adminGetSettings(): Promise<InstallationAdminSettings>;
|
|
68
|
+
adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
|
|
69
|
+
adminGetTelemetryData(): Promise<TelemetryData>;
|
|
47
70
|
}
|
|
48
71
|
|
|
49
72
|
export interface AdminGetListRequest<T> {
|
|
50
|
-
offset: number
|
|
51
|
-
limit: number
|
|
52
|
-
orderBy: keyof T
|
|
53
|
-
orderDir: "asc" | "desc"
|
|
73
|
+
offset: number;
|
|
74
|
+
limit: number;
|
|
75
|
+
orderBy: keyof T;
|
|
76
|
+
orderDir: "asc" | "desc";
|
|
54
77
|
searchTerm?: string;
|
|
55
78
|
}
|
|
56
79
|
|
|
57
80
|
export interface AdminGetListResult<T> {
|
|
58
|
-
total: number
|
|
59
|
-
rows: T[]
|
|
81
|
+
total: number;
|
|
82
|
+
rows: T[];
|
|
60
83
|
}
|
|
61
84
|
|
|
62
85
|
export interface AdminBlockUserRequest {
|
|
63
|
-
id: string
|
|
64
|
-
blocked: boolean
|
|
86
|
+
id: string;
|
|
87
|
+
blocked: boolean;
|
|
65
88
|
}
|
|
66
89
|
|
|
67
90
|
export interface AdminModifyRoleOrPermissionRequest {
|
|
68
91
|
id: string;
|
|
69
92
|
rpp: {
|
|
70
|
-
r: RoleOrPermission
|
|
71
|
-
add: boolean
|
|
72
|
-
}[]
|
|
93
|
+
r: RoleOrPermission;
|
|
94
|
+
add: boolean;
|
|
95
|
+
}[];
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
export interface AdminModifyPermanentWorkspaceFeatureFlagRequest {
|
|
76
99
|
id: string;
|
|
77
100
|
changes: {
|
|
78
|
-
featureFlag: NamedWorkspaceFeatureFlag
|
|
79
|
-
add: boolean
|
|
80
|
-
}[]
|
|
101
|
+
featureFlag: NamedWorkspaceFeatureFlag;
|
|
102
|
+
add: boolean;
|
|
103
|
+
}[];
|
|
81
104
|
}
|
|
82
105
|
|
|
83
|
-
export interface WorkspaceAndInstance
|
|
106
|
+
export interface WorkspaceAndInstance
|
|
107
|
+
extends Omit<Workspace, "id" | "creationTime">,
|
|
108
|
+
Omit<WorkspaceInstance, "id" | "creationTime"> {
|
|
84
109
|
workspaceId: string;
|
|
85
110
|
workspaceCreationTime: string;
|
|
86
111
|
instanceId: string;
|
|
@@ -93,7 +118,7 @@ export namespace WorkspaceAndInstance {
|
|
|
93
118
|
return {
|
|
94
119
|
id: wai.workspaceId,
|
|
95
120
|
creationTime: wai.workspaceCreationTime,
|
|
96
|
-
...wai
|
|
121
|
+
...wai,
|
|
97
122
|
};
|
|
98
123
|
}
|
|
99
124
|
|
|
@@ -104,7 +129,7 @@ export namespace WorkspaceAndInstance {
|
|
|
104
129
|
return {
|
|
105
130
|
id: wai.instanceId,
|
|
106
131
|
creationTime: wai.instanceCreationTime,
|
|
107
|
-
...wai
|
|
132
|
+
...wai,
|
|
108
133
|
};
|
|
109
134
|
}
|
|
110
135
|
}
|
|
@@ -116,4 +141,5 @@ export type AdminGetWorkspacesQuery = {
|
|
|
116
141
|
instanceIdOrWorkspaceId?: string;
|
|
117
142
|
instanceId?: string;
|
|
118
143
|
workspaceId?: string;
|
|
144
|
+
ownerId?: string;
|
|
119
145
|
};
|
package/src/analytics.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
export const IAnalyticsWriter = Symbol("IAnalyticsWriter");
|
|
9
8
|
|
|
10
9
|
type Identity =
|
|
@@ -15,24 +14,27 @@ interface Message {
|
|
|
15
14
|
messageId?: string;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
export type IdentifyMessage = Message &
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
export type IdentifyMessage = Message &
|
|
18
|
+
Identity & {
|
|
19
|
+
traits?: any;
|
|
20
|
+
timestamp?: Date;
|
|
21
|
+
context?: any;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type TrackMessage = Message &
|
|
25
|
+
Identity & {
|
|
26
|
+
event: string;
|
|
27
|
+
properties?: any;
|
|
28
|
+
timestamp?: Date;
|
|
29
|
+
context?: any;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type PageMessage = Message &
|
|
33
|
+
Identity & {
|
|
34
|
+
properties?: any;
|
|
35
|
+
timestamp?: Date;
|
|
36
|
+
context?: any;
|
|
37
|
+
};
|
|
36
38
|
|
|
37
39
|
export type RemoteTrackMessage = Omit<TrackMessage, "timestamp" | "userId">;
|
|
38
40
|
export type RemotePageMessage = Omit<PageMessage, "timestamp" | "userId"> & {
|
|
@@ -42,11 +44,9 @@ export type RemotePageMessage = Omit<PageMessage, "timestamp" | "userId"> & {
|
|
|
42
44
|
export type RemoteIdentifyMessage = Omit<IdentifyMessage, "timestamp" | "userId">;
|
|
43
45
|
|
|
44
46
|
export interface IAnalyticsWriter {
|
|
45
|
-
|
|
46
47
|
identify(msg: IdentifyMessage): void;
|
|
47
48
|
|
|
48
49
|
track(msg: TrackMessage): void;
|
|
49
50
|
|
|
50
51
|
page(msg: PageMessage): void;
|
|
51
|
-
|
|
52
52
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { User } from "./protocol";
|
|
8
|
+
import { Team } from "./teams-projects-protocol";
|
|
9
|
+
|
|
10
|
+
export type AttributionId = UserAttributionId | TeamAttributionId;
|
|
11
|
+
export type AttributionTarget = "user" | "team";
|
|
12
|
+
|
|
13
|
+
export interface UserAttributionId {
|
|
14
|
+
kind: "user";
|
|
15
|
+
userId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TeamAttributionId {
|
|
18
|
+
kind: "team";
|
|
19
|
+
teamId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export namespace AttributionId {
|
|
23
|
+
const SEPARATOR = ":";
|
|
24
|
+
|
|
25
|
+
export function create(userOrTeam: User | Team): AttributionId {
|
|
26
|
+
if (User.is(userOrTeam)) {
|
|
27
|
+
return { kind: "user", userId: userOrTeam.id };
|
|
28
|
+
} else {
|
|
29
|
+
return { kind: "team", teamId: userOrTeam.id };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function parse(s: string): UserAttributionId | TeamAttributionId | undefined {
|
|
34
|
+
if (!s) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const parts = s.split(":");
|
|
38
|
+
if (parts.length !== 2) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
switch (parts[0]) {
|
|
42
|
+
case "user":
|
|
43
|
+
return { kind: "user", userId: parts[1] };
|
|
44
|
+
case "team":
|
|
45
|
+
return { kind: "team", teamId: parts[1] };
|
|
46
|
+
default:
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function render(id: AttributionId): string {
|
|
52
|
+
switch (id.kind) {
|
|
53
|
+
case "user":
|
|
54
|
+
return `user${SEPARATOR}${id.userId}`;
|
|
55
|
+
case "team":
|
|
56
|
+
return `team${SEPARATOR}${id.teamId}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function equals(a: AttributionId, b: AttributionId): boolean {
|
|
61
|
+
return render(a) === render(b);
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/auth.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export interface SelectAccountPayload {
|
|
@@ -11,14 +11,14 @@ export interface SelectAccountPayload {
|
|
|
11
11
|
authHost: string;
|
|
12
12
|
authName: string;
|
|
13
13
|
authProviderType: string;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
otherUser: {
|
|
16
16
|
name: string;
|
|
17
17
|
avatarUrl: string;
|
|
18
18
|
authHost: string;
|
|
19
19
|
authName: string;
|
|
20
20
|
authProviderType: string;
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
}
|
|
23
23
|
export namespace SelectAccountPayload {
|
|
24
24
|
export function is(data: any): data is SelectAccountPayload {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* BillingMode is used to answer the following questions:
|
|
9
|
+
* - Should UI piece x be displayed for this user/team? (getBillingModeForUser/Team)
|
|
10
|
+
* - What model should be used to limit this workspace's capabilities (mayStartWorkspace, setTimeout, workspace class, etc...) (getBillingMode(workspaceInstance.attributionId))
|
|
11
|
+
* - How is a workspace session charged for? (getBillingMode(workspaceInstance.attributionId))
|
|
12
|
+
*/
|
|
13
|
+
export type BillingMode = None | Chargebee | UsageBased;
|
|
14
|
+
export namespace BillingMode {
|
|
15
|
+
export const NONE: None = {
|
|
16
|
+
mode: "none",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Incl. upgrade and status */
|
|
20
|
+
export function showUsageBasedBilling(billingMode?: BillingMode): boolean {
|
|
21
|
+
if (!billingMode) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return (
|
|
25
|
+
billingMode.mode === "usage-based" || (billingMode.mode === "chargebee" && !!billingMode.canUpgradeToUBB)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function showTeamSubscriptionUI(billingMode?: BillingMode): boolean {
|
|
30
|
+
if (!billingMode) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return (
|
|
34
|
+
billingMode.mode === "chargebee" ||
|
|
35
|
+
(billingMode.mode === "usage-based" && !!billingMode.hasChargebeeTeamSubscription)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function canSetWorkspaceClass(billingMode?: BillingMode): boolean {
|
|
40
|
+
if (!billingMode) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// if has any Stripe subscription, either directly or per team, OR we're running on a license
|
|
45
|
+
return billingMode.mode === "usage-based" || billingMode.mode === "none";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function canSetCostCenter(billingMode: BillingMode): boolean {
|
|
49
|
+
// if has any Stripe Subscription, either directly or per team
|
|
50
|
+
return billingMode.mode === "usage-based";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Payment is disabled */
|
|
55
|
+
interface None {
|
|
56
|
+
mode: "none";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Sessions is handled with old subscription logic based on Chargebee */
|
|
60
|
+
interface Chargebee {
|
|
61
|
+
mode: "chargebee";
|
|
62
|
+
|
|
63
|
+
/** True iff this is a team, and is based on a paid plan. Currently only set for teams! */
|
|
64
|
+
paid?: boolean;
|
|
65
|
+
|
|
66
|
+
canUpgradeToUBB?: boolean;
|
|
67
|
+
|
|
68
|
+
/** Name of team(s) that block switching to usage-based */
|
|
69
|
+
teamNames?: string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Session is handld with new usage-based logic */
|
|
73
|
+
interface UsageBased {
|
|
74
|
+
mode: "usage-based";
|
|
75
|
+
|
|
76
|
+
/** True iff this is a team, and is based on a paid plan. Currently only set for teams! */
|
|
77
|
+
paid?: boolean;
|
|
78
|
+
|
|
79
|
+
/** User is already converted, but is member with at least one Chargebee-based "Team Plan" */
|
|
80
|
+
hasChargebeeTeamPlan?: boolean;
|
|
81
|
+
|
|
82
|
+
/** User is already converted, but is member or owner in at least one Chargebee-based "Team Subscription" */
|
|
83
|
+
hasChargebeeTeamSubscription?: boolean;
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface BlockedRepository {
|
|
8
|
+
id: number;
|
|
9
|
+
urlRegexp: string;
|
|
10
|
+
blockUser: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
}
|
package/src/context-url.spec.ts
CHANGED
|
@@ -1,53 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as chai from
|
|
8
|
-
import { suite, test } from
|
|
9
|
-
import { Workspace } from
|
|
10
|
-
import { ContextURL } from
|
|
7
|
+
import * as chai from "chai";
|
|
8
|
+
import { suite, test } from "mocha-typescript";
|
|
9
|
+
import { Workspace } from ".";
|
|
10
|
+
import { ContextURL } from "./context-url";
|
|
11
11
|
const expect = chai.expect;
|
|
12
12
|
|
|
13
13
|
type WsContextUrl = Pick<Workspace, "context" | "contextURL">;
|
|
14
14
|
|
|
15
15
|
@suite
|
|
16
16
|
export class ContextUrlTest {
|
|
17
|
-
|
|
18
17
|
@test public parseContextUrl_withEnvVar() {
|
|
19
|
-
const actual = ContextURL.getNormalizedURL({
|
|
18
|
+
const actual = ContextURL.getNormalizedURL({
|
|
19
|
+
contextURL: "passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo",
|
|
20
|
+
context: {},
|
|
21
|
+
} as WsContextUrl);
|
|
20
22
|
expect(actual?.host).to.equal("github.com");
|
|
21
23
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
@test public parseContextUrl_withEnvVar_withoutSchema() {
|
|
25
|
-
const actual = ContextURL.getNormalizedURL({
|
|
27
|
+
const actual = ContextURL.getNormalizedURL({
|
|
28
|
+
contextURL: "passedin=test%20value/github.com/gitpod-io/gitpod-test-repo",
|
|
29
|
+
context: {},
|
|
30
|
+
} as WsContextUrl);
|
|
26
31
|
expect(actual?.host).to.equal("github.com");
|
|
27
32
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
@test public parseContextUrl_withEnvVar_sshUrl() {
|
|
31
|
-
const actual = ContextURL.getNormalizedURL({
|
|
36
|
+
const actual = ContextURL.getNormalizedURL({
|
|
37
|
+
contextURL: "passedin=test%20value/git@github.com:gitpod-io/gitpod-test-repo.git",
|
|
38
|
+
context: {},
|
|
39
|
+
} as WsContextUrl);
|
|
32
40
|
expect(actual?.host).to.equal("github.com");
|
|
33
41
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo.git");
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
@test public parseContextUrl_withPrebuild() {
|
|
37
|
-
const actual = ContextURL.getNormalizedURL({ contextURL: "prebuild/https://github.com/gitpod-io/gitpod-test-repo", context: {} } as WsContextUrl);
|
|
38
|
-
expect(actual?.host).to.equal("github.com");
|
|
39
|
-
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@test public parseContextUrl_withPrebuild_withoutSchema() {
|
|
43
|
-
const actual = ContextURL.getNormalizedURL({ contextURL: "prebuild/github.com/gitpod-io/gitpod-test-repo", context: {} } as WsContextUrl);
|
|
44
|
-
expect(actual?.host).to.equal("github.com");
|
|
45
|
-
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
@test public parseContextUrl_badUrl() {
|
|
49
45
|
const actual = ContextURL.getNormalizedURL({ contextURL: "[Object object]", context: {} } as WsContextUrl);
|
|
50
46
|
expect(actual).to.be.undefined;
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
|
-
module.exports = new ContextUrlTest()
|
|
49
|
+
module.exports = new ContextUrlTest();
|
package/src/context-url.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Workspace } from ".";
|
|
@@ -15,93 +15,93 @@ import { Workspace } from ".";
|
|
|
15
15
|
* TODO(gpl) See if we can get this into `server` code to remove the burden from clients
|
|
16
16
|
*/
|
|
17
17
|
export namespace ContextURL {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export const REFERRER_PREFIX = 'referrer:';
|
|
18
|
+
export const PREBUILD_PREFIX = "prebuild";
|
|
19
|
+
export const IMAGEBUILD_PREFIX = "imagebuild";
|
|
20
|
+
export const SNAPSHOT_PREFIX = "snapshot";
|
|
21
|
+
export const REFERRER_PREFIX = "referrer:";
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
/**
|
|
24
|
+
* This function will (try to) return the HTTP(S) URL of the context the user originally created this workspace on.
|
|
25
|
+
* Especially it will not contain any modifiers or be of different scheme than HTTP(S).
|
|
26
|
+
*
|
|
27
|
+
* Use this function if you need to provided a _working_ URL to the original context.
|
|
28
|
+
* @param ws
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export function getNormalizedURL(ws: Pick<Workspace, "context" | "contextURL"> | undefined): URL | undefined {
|
|
32
|
+
const normalized = normalize(ws);
|
|
33
|
+
if (!normalized) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
try {
|
|
38
|
+
return new URL(normalized);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.debug(`unable to parse URL from normalized contextURL: '${normalized}'`);
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
42
43
|
}
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
function normalize(ws: Pick<Workspace, "context" | "contextURL"> | undefined): string | undefined {
|
|
46
|
+
if (!ws) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (ws.context.normalizedContextURL) {
|
|
50
|
+
return ws.context.normalizedContextURL;
|
|
51
|
+
}
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
// fallback: we do not yet set normalizedContextURL on all workspaces, yet, let alone older existing workspaces
|
|
54
|
+
let fallback: string | undefined = undefined;
|
|
55
|
+
try {
|
|
56
|
+
fallback = removePrefixes(ws.contextURL);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(`unable to remove prefixes from contextURL: '${ws.contextURL}'`, err);
|
|
59
|
+
}
|
|
60
|
+
return fallback;
|
|
60
61
|
}
|
|
61
|
-
return fallback;
|
|
62
|
-
}
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The field "contextUrl" might contain prefixes like:
|
|
65
|
+
* - envvar1=value1/...
|
|
66
|
+
* - prebuild/...
|
|
67
|
+
* This is the analogon to the (Prefix)ContextParser structure in "server".
|
|
68
|
+
*/
|
|
69
|
+
function removePrefixes(contextUrl: string | undefined): string | undefined {
|
|
70
|
+
if (contextUrl === undefined) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const segments = contextUrl.split("/");
|
|
75
|
+
if (segments.length === 1) {
|
|
76
|
+
return segments[0]; // this might be something, we just try
|
|
77
|
+
}
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
const segmentsToURL = (offset: number): string => {
|
|
80
|
+
let rest = segments.slice(offset).join("/");
|
|
81
|
+
if (/^git@[^:\/]+:/.test(rest)) {
|
|
82
|
+
rest = rest.replace(/^git@([^:\/]+):/, "https://$1/");
|
|
83
|
+
}
|
|
84
|
+
if (!rest.startsWith("http")) {
|
|
85
|
+
rest = "https://" + rest;
|
|
86
|
+
}
|
|
87
|
+
return rest;
|
|
88
|
+
};
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
const firstSegment = segments[0];
|
|
91
|
+
if (
|
|
92
|
+
firstSegment === PREBUILD_PREFIX ||
|
|
93
|
+
firstSegment === IMAGEBUILD_PREFIX ||
|
|
94
|
+
firstSegment === SNAPSHOT_PREFIX ||
|
|
95
|
+
firstSegment.startsWith(REFERRER_PREFIX)
|
|
96
|
+
) {
|
|
97
|
+
return segmentsToURL(1);
|
|
98
|
+
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
// check for env vars
|
|
101
|
+
if (firstSegment.indexOf("=") !== -1) {
|
|
102
|
+
return segmentsToURL(1);
|
|
103
|
+
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
105
|
+
return segmentsToURL(0);
|
|
106
|
+
}
|
|
107
|
+
}
|