@gitpod/gitpod-protocol 0.1.5-main.648 → 0.1.5-main.6480
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 +157 -29
- package/lib/accounting-protocol.d.ts +19 -14
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +44 -48
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +44 -5
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +16 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +44 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/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 +30 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +100 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +12 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +81 -0
- package/lib/context-url.spec.js.map +1 -0
- 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 +5 -5
- 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 +26 -27
- 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 +30 -38
- 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 +31 -45
- 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 +32 -39
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -7
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +8 -28
- 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 +27 -43
- 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 +146 -143
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +191 -55
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +204 -298
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +10 -12
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +7 -9
- 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 +126 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +18 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +17 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -2
- 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 +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 +4 -6
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +176 -45
- 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 +43 -60
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +21 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +95 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/error.d.ts +13 -3
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +25 -5
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -1
- package/lib/messaging/node/connection.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +24 -60
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +3 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +75 -162
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/payment-protocol.d.ts +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 +14 -4
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +45 -32
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +6 -5
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +230 -210
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +261 -105
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +346 -205
- package/lib/protocol.js.map +1 -1
- package/{src/util/without.ts → lib/protocol.spec.d.ts} +3 -4
- 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 +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/lib/snapshot-url.spec.d.ts +7 -0
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +24 -5
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +36 -18
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +137 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +41 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- 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 +8 -0
- package/lib/util/analytics.d.ts.map +1 -0
- package/lib/util/analytics.js +88 -0
- package/lib/util/analytics.js.map +1 -0
- package/lib/util/async-iterator.d.ts +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +58 -136
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.d.ts +1 -1
- package/lib/util/cancelable.js +18 -60
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.d.ts +1 -1
- package/lib/util/date-time.js +12 -12
- 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 +11 -13
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +27 -40
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +63 -77
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +2 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +33 -48
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +6 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +469 -502
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.d.ts +1 -1
- package/lib/util/generate-workspace-id.spec.js +69 -79
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +41 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +12 -7
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +132 -110
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +7 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +113 -31
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +35 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +90 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/{theia-plugins.js → util/jaeger-client-types.js} +2 -2
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +50 -34
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +133 -130
- 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 +11 -1
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +31 -8
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +5 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +124 -85
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.d.ts +1 -1
- package/lib/util/queue.js +17 -56
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.d.ts +1 -1
- package/lib/util/queue.spec.js +148 -289
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/semaphore.d.ts +1 -1
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js +16 -47
- 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 +7 -7
- 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 +30 -18
- 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 +55 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +53 -7
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +198 -65
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.d.ts +8 -8
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +10 -13
- 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 +28 -8
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +20 -5
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +46 -6
- 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 +40 -18
- package/pkg-yarn.lock +23 -10
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +67 -58
- package/src/admin-protocol.ts +88 -20
- package/src/analytics.ts +52 -0
- 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 +49 -0
- package/src/context-url.ts +107 -0
- 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 +369 -146
- package/src/headless-workspace-log.ts +13 -15
- package/src/ide-frontend-service.ts +3 -3
- package/src/ide-protocol.ts +147 -0
- package/src/index.ts +17 -11
- package/src/installation-admin-protocol.ts +45 -0
- package/src/license-protocol.ts +13 -7
- package/src/messaging/browser/connection.ts +187 -28
- package/src/messaging/browser/window-connection.ts +40 -30
- package/src/messaging/client-call-metrics.ts +94 -0
- package/src/messaging/error.ts +36 -8
- package/src/messaging/handler.ts +13 -1
- package/src/messaging/node/connection.ts +23 -70
- package/src/messaging/proxy-factory.ts +35 -34
- package/src/oss-allowlist.ts +15 -0
- package/src/payment-protocol.ts +3 -3
- package/src/permission.ts +47 -34
- package/src/plans.ts +250 -199
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +636 -293
- package/src/snapshot-url.spec.ts +27 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +62 -23
- package/src/teams-projects-protocol.ts +181 -0
- package/src/typings/globals.ts +6 -5
- package/src/usage.ts +85 -0
- package/src/util/analytics.ts +109 -0
- 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 +17 -9
- package/src/util/generate-workspace-id.spec.ts +38 -11
- package/src/util/generate-workspace-id.ts +465 -439
- package/src/util/gitpod-cookie.ts +38 -0
- package/src/util/gitpod-host-url.spec.ts +59 -8
- package/src/util/gitpod-host-url.ts +88 -48
- package/src/util/grpc.ts +107 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.spec.ts +23 -0
- package/src/util/logging.ts +157 -75
- package/src/util/make-link.ts +7 -8
- package/src/util/nice-grpc.ts +96 -0
- package/src/util/parse-workspace-id.spec.ts +38 -9
- package/src/util/parse-workspace-id.ts +33 -8
- package/src/util/queue.spec.ts +28 -26
- package/src/util/queue.ts +1 -1
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +7 -9
- package/src/util/skip-if.ts +11 -8
- package/src/util/timeutil.spec.ts +41 -15
- package/src/util/timeutil.ts +32 -16
- package/src/util/tracing.spec.ts +88 -0
- package/src/util/tracing.ts +201 -32
- 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 +47 -17
- package/src/workspace-instance.ts +106 -32
- package/src/wsready.ts +11 -4
- package/data/builtin-theia-plugins.json +0 -372
- package/lib/email-protocol.d.ts +0 -50
- 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 -46
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js.map +0 -1
- package/lib/util/context-url.d.ts +0 -13
- package/lib/util/context-url.d.ts.map +0 -1
- package/lib/util/context-url.js +0 -26
- package/lib/util/context-url.js.map +0 -1
- package/lib/util/context-url.spec.d.ts +0 -10
- package/lib/util/context-url.spec.d.ts.map +0 -1
- package/lib/util/context-url.spec.js +0 -52
- package/lib/util/context-url.spec.js.map +0 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -34
- package/lib/util/safe-promise.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js +0 -8
- package/lib/util/without.js.map +0 -1
- package/src/email-protocol.ts +0 -67
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/theia-plugins.ts +0 -11
- package/src/util/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
- package/src/util/safe-promise.ts +0 -26
package/src/util/logging.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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
|
-
const inspect: (object: any) => string = require(
|
|
7
|
+
const inspect: (object: any) => string = require("util").inspect; // undefined in frontend
|
|
8
8
|
|
|
9
|
+
let plainLogging: boolean = false; // set to true during development to get non JSON output
|
|
9
10
|
let jsonLogging: boolean = false;
|
|
10
11
|
let component: string | undefined;
|
|
11
12
|
let version: string | undefined;
|
|
@@ -15,81 +16,81 @@ export interface LogContext {
|
|
|
15
16
|
sessionId?: string;
|
|
16
17
|
userId?: string;
|
|
17
18
|
workspaceId?: string;
|
|
18
|
-
}
|
|
19
|
+
}
|
|
19
20
|
export namespace LogContext {
|
|
20
|
-
export function from(params
|
|
21
|
+
export function from(params: { userId?: string; user?: any; request?: any }) {
|
|
21
22
|
return <LogContext>{
|
|
22
23
|
sessionId: params.request?.requestID,
|
|
23
|
-
userId: params.userId || params.user?.id
|
|
24
|
-
}
|
|
24
|
+
userId: params.userId || params.user?.id,
|
|
25
|
+
};
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export interface LogPayload {
|
|
29
30
|
// placeholder to indicate that only dictionary-style objects should be passed as payload
|
|
30
|
-
}
|
|
31
|
+
}
|
|
31
32
|
|
|
32
33
|
export namespace log {
|
|
33
|
-
export function error(context: LogContext, message: string, error:
|
|
34
|
-
export function error(context: LogContext, message: string, error:
|
|
34
|
+
export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
35
|
+
export function error(context: LogContext, message: string, error: any): void;
|
|
35
36
|
export function error(context: LogContext, message: string, payload: LogPayload): void;
|
|
36
37
|
export function error(context: LogContext, message: string): void;
|
|
37
|
-
export function error(context: LogContext, error:
|
|
38
|
-
export function error(context: LogContext, error:
|
|
39
|
-
export function error(message: string, error:
|
|
40
|
-
export function error(message: string, error:
|
|
38
|
+
export function error(context: LogContext, error: any, payload: LogPayload): void;
|
|
39
|
+
export function error(context: LogContext, error: any): void;
|
|
40
|
+
export function error(message: string, error: any, payload: LogPayload): void;
|
|
41
|
+
export function error(message: string, error: any): void;
|
|
41
42
|
export function error(message: string, payload: LogPayload): void;
|
|
42
43
|
export function error(message: string): void;
|
|
43
|
-
export function error(error:
|
|
44
|
-
export function error(error:
|
|
44
|
+
export function error(error: any, payload: LogPayload): void;
|
|
45
|
+
export function error(error: any): void;
|
|
45
46
|
export function error(...args: any[]): void {
|
|
46
47
|
errorLog(false, args);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
export function warn(context: LogContext, message: string, error:
|
|
50
|
-
export function warn(context: LogContext, message: string, error:
|
|
50
|
+
export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
51
|
+
export function warn(context: LogContext, message: string, error: any): void;
|
|
51
52
|
export function warn(context: LogContext, message: string, payload: LogPayload): void;
|
|
52
53
|
export function warn(context: LogContext, message: string): void;
|
|
53
|
-
export function warn(context: LogContext, error:
|
|
54
|
-
export function warn(context: LogContext, error:
|
|
55
|
-
export function warn(message: string, error:
|
|
56
|
-
export function warn(message: string, error:
|
|
54
|
+
export function warn(context: LogContext, error: any, payload: LogPayload): void;
|
|
55
|
+
export function warn(context: LogContext, error: any): void;
|
|
56
|
+
export function warn(message: string, error: any, payload: LogPayload): void;
|
|
57
|
+
export function warn(message: string, error: any): void;
|
|
57
58
|
export function warn(message: string, payload: LogPayload): void;
|
|
58
59
|
export function warn(message: string): void;
|
|
59
|
-
export function warn(error:
|
|
60
|
-
export function warn(error:
|
|
60
|
+
export function warn(error: any, payload: LogPayload): void;
|
|
61
|
+
export function warn(error: any): void;
|
|
61
62
|
export function warn(...args: any[]): void {
|
|
62
63
|
warnLog(false, args);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
export function info(context: LogContext, message: string, error:
|
|
66
|
-
export function info(context: LogContext, message: string, error:
|
|
66
|
+
export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
67
|
+
export function info(context: LogContext, message: string, error: any): void;
|
|
67
68
|
export function info(context: LogContext, message: string, payload: LogPayload): void;
|
|
68
69
|
export function info(context: LogContext, message: string): void;
|
|
69
|
-
export function info(context: LogContext, error:
|
|
70
|
-
export function info(context: LogContext, error:
|
|
71
|
-
export function info(message: string, error:
|
|
72
|
-
export function info(message: string, error:
|
|
70
|
+
export function info(context: LogContext, error: any, payload: LogPayload): void;
|
|
71
|
+
export function info(context: LogContext, error: any): void;
|
|
72
|
+
export function info(message: string, error: any, payload: LogPayload): void;
|
|
73
|
+
export function info(message: string, error: any): void;
|
|
73
74
|
export function info(message: string, payload: LogPayload): void;
|
|
74
75
|
export function info(message: string): void;
|
|
75
|
-
export function info(error:
|
|
76
|
-
export function info(error:
|
|
76
|
+
export function info(error: any, payload: LogPayload): void;
|
|
77
|
+
export function info(error: any): void;
|
|
77
78
|
export function info(...args: any[]): void {
|
|
78
79
|
infoLog(false, args);
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
export function debug(context: LogContext, message: string, error:
|
|
82
|
-
export function debug(context: LogContext, message: string, error:
|
|
82
|
+
export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
83
|
+
export function debug(context: LogContext, message: string, error: any): void;
|
|
83
84
|
export function debug(context: LogContext, message: string, payload: LogPayload): void;
|
|
84
85
|
export function debug(context: LogContext, message: string): void;
|
|
85
|
-
export function debug(context: LogContext, error:
|
|
86
|
-
export function debug(context: LogContext, error:
|
|
87
|
-
export function debug(message: string, error:
|
|
88
|
-
export function debug(message: string, error:
|
|
86
|
+
export function debug(context: LogContext, error: any, payload: LogPayload): void;
|
|
87
|
+
export function debug(context: LogContext, error: any): void;
|
|
88
|
+
export function debug(message: string, error: any, payload: LogPayload): void;
|
|
89
|
+
export function debug(message: string, error: any): void;
|
|
89
90
|
export function debug(message: string, payload: LogPayload): void;
|
|
90
91
|
export function debug(message: string): void;
|
|
91
|
-
export function debug(error:
|
|
92
|
-
export function debug(error:
|
|
92
|
+
export function debug(error: any, payload: LogPayload): void;
|
|
93
|
+
export function debug(error: any): void;
|
|
93
94
|
export function debug(...args: any[]): void {
|
|
94
95
|
debugLog(false, args);
|
|
95
96
|
}
|
|
@@ -97,26 +98,46 @@ export namespace log {
|
|
|
97
98
|
/**
|
|
98
99
|
* Do not use in frontend.
|
|
99
100
|
*/
|
|
100
|
-
export function enableJSONLogging(
|
|
101
|
+
export function enableJSONLogging(
|
|
102
|
+
componentArg: string,
|
|
103
|
+
versionArg: string | undefined,
|
|
104
|
+
logLevel?: LogrusLogLevel,
|
|
105
|
+
): void {
|
|
101
106
|
component = componentArg;
|
|
102
107
|
version = versionArg;
|
|
103
108
|
|
|
109
|
+
setLogLevel(logLevel);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function setLogLevel(logLevel: LogrusLogLevel | undefined) {
|
|
104
113
|
jsonLogging = true;
|
|
105
114
|
|
|
106
115
|
console.error = function (...args: any[]): void {
|
|
107
116
|
errorLog(true, args);
|
|
108
|
-
}
|
|
117
|
+
};
|
|
109
118
|
console.warn = function (...args: any[]): void {
|
|
110
119
|
warnLog(true, args);
|
|
111
|
-
}
|
|
120
|
+
};
|
|
112
121
|
console.info = function (...args: any[]): void {
|
|
113
122
|
infoLog(true, args);
|
|
114
|
-
}
|
|
123
|
+
};
|
|
115
124
|
console.debug = function (...args: any[]): void {
|
|
116
125
|
debugLog(true, args);
|
|
117
|
-
}
|
|
126
|
+
};
|
|
127
|
+
|
|
118
128
|
console.log = console.info;
|
|
119
129
|
// FIXME wrap also other console methods (e.g. trace())
|
|
130
|
+
|
|
131
|
+
// set/unset log functions based on loglevel so we only have to evaluate once, not every call
|
|
132
|
+
const noop = () => {};
|
|
133
|
+
const setLog = (logFunc: DoLogFunction, funcLevel: LogrusLogLevel): DoLogFunction => {
|
|
134
|
+
return LogrusLogLevel.isGreatherOrEqual(funcLevel, logLevel) ? logFunc : noop;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
errorLog = setLog(doErrorLog, "error");
|
|
138
|
+
warnLog = setLog(doWarnLog, "warning");
|
|
139
|
+
infoLog = setLog(doInfoLog, "info");
|
|
140
|
+
debugLog = setLog(doDebugLog, "debug");
|
|
120
141
|
}
|
|
121
142
|
|
|
122
143
|
export function resetToDefaultLogging(): void {
|
|
@@ -128,31 +149,79 @@ export namespace log {
|
|
|
128
149
|
console.info = infoConsoleLog;
|
|
129
150
|
console.debug = debugConsoleLog;
|
|
130
151
|
}
|
|
152
|
+
|
|
153
|
+
export function setVersion(versionArg: string) {
|
|
154
|
+
version = versionArg;
|
|
155
|
+
}
|
|
131
156
|
}
|
|
132
157
|
|
|
133
|
-
|
|
134
|
-
|
|
158
|
+
type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
|
|
159
|
+
|
|
160
|
+
let errorLog = doErrorLog;
|
|
161
|
+
function doErrorLog(calledViaConsole: boolean, args: any[]): void {
|
|
162
|
+
doLog(calledViaConsole, errorConsoleLog, "ERROR", args);
|
|
135
163
|
}
|
|
136
164
|
|
|
137
|
-
|
|
138
|
-
|
|
165
|
+
let warnLog = doWarnLog;
|
|
166
|
+
function doWarnLog(calledViaConsole: boolean, args: any[]): void {
|
|
167
|
+
doLog(calledViaConsole, warnConsoleLog, "WARNING", args);
|
|
139
168
|
}
|
|
140
169
|
|
|
141
|
-
|
|
142
|
-
|
|
170
|
+
let infoLog = doInfoLog;
|
|
171
|
+
function doInfoLog(calledViaConsole: boolean, args: any[]): void {
|
|
172
|
+
doLog(calledViaConsole, infoConsoleLog, "INFO", args);
|
|
143
173
|
}
|
|
144
174
|
|
|
145
|
-
|
|
146
|
-
|
|
175
|
+
let debugLog = doDebugLog;
|
|
176
|
+
function doDebugLog(calledViaConsole: boolean, args: any[]): void {
|
|
177
|
+
doLog(calledViaConsole, debugConsoleLog, "DEBUG", args);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Ref: https://github.com/sirupsen/logrus#level-logging
|
|
181
|
+
export type LogrusLogLevel = keyof typeof LogrusLogLevels;
|
|
182
|
+
export const LogrusLogLevels = {
|
|
183
|
+
trace: true,
|
|
184
|
+
debug: true,
|
|
185
|
+
info: true,
|
|
186
|
+
warning: true,
|
|
187
|
+
error: true,
|
|
188
|
+
fatal: true,
|
|
189
|
+
panic: true,
|
|
190
|
+
};
|
|
191
|
+
export namespace LogrusLogLevel {
|
|
192
|
+
export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
|
|
193
|
+
if (lvl === undefined) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (ref === undefined) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return getLevelArity(lvl) >= getLevelArity(ref);
|
|
200
|
+
}
|
|
201
|
+
function getLevelArity(lvl: LogrusLogLevel): number {
|
|
202
|
+
return Object.keys(LogrusLogLevels).findIndex((l) => l === lvl);
|
|
203
|
+
}
|
|
204
|
+
export function getFromEnv(): LogrusLogLevel | undefined {
|
|
205
|
+
const lvlStr = process.env.LOG_LEVEL;
|
|
206
|
+
if (!lvlStr) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
const lvl = lvlStr as LogrusLogLevel;
|
|
210
|
+
const exists = LogrusLogLevels[lvl];
|
|
211
|
+
if (!exists) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
return lvl;
|
|
215
|
+
}
|
|
147
216
|
}
|
|
148
217
|
|
|
149
218
|
// Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
|
150
|
-
type GoogleLogSeverity =
|
|
219
|
+
type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
|
151
220
|
namespace GoogleLogSeverity {
|
|
152
221
|
export const isGreaterOrEqualThanWarning = (severity: GoogleLogSeverity) => {
|
|
153
222
|
switch (severity) {
|
|
154
|
-
case
|
|
155
|
-
case
|
|
223
|
+
case "INFO":
|
|
224
|
+
case "DEBUG":
|
|
156
225
|
return false;
|
|
157
226
|
default:
|
|
158
227
|
return true;
|
|
@@ -180,7 +249,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
180
249
|
// console.xyz(Error, ...any) / log.xyz(Error) / log.xyz(Error, LogPayload)
|
|
181
250
|
error = args[0];
|
|
182
251
|
payloadArgs = args.slice(1);
|
|
183
|
-
} else if (typeof args[0] ===
|
|
252
|
+
} else if (typeof args[0] === "string") {
|
|
184
253
|
message = args[0];
|
|
185
254
|
if (args.length < 2 || !(args[1] instanceof Error)) {
|
|
186
255
|
// console.xyz(string) / console.xyz(string, !Error, ...any) / log.xyz(string) / log.xyz(string, LogPayload)
|
|
@@ -200,7 +269,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
200
269
|
// log.xyz(LogContext, Error) / log.xyz(LogContext, Error, LogPayload)
|
|
201
270
|
error = args[1];
|
|
202
271
|
payloadArgs = args.slice(2);
|
|
203
|
-
} else if (typeof args[1] ===
|
|
272
|
+
} else if (typeof args[1] === "string") {
|
|
204
273
|
message = args[1];
|
|
205
274
|
if (args.length < 3 || !(args[2] instanceof Error)) {
|
|
206
275
|
// log.xyz(LogContext, string) / log.xyz(LogContext, string, LogPayload)
|
|
@@ -223,9 +292,14 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
223
292
|
}
|
|
224
293
|
}
|
|
225
294
|
|
|
226
|
-
function makeLogItem(
|
|
227
|
-
|
|
228
|
-
|
|
295
|
+
function makeLogItem(
|
|
296
|
+
severity: GoogleLogSeverity,
|
|
297
|
+
context: LogContext | undefined,
|
|
298
|
+
message: string | undefined,
|
|
299
|
+
error: Error | undefined,
|
|
300
|
+
payloadArgs: any[],
|
|
301
|
+
calledViaConsole: boolean,
|
|
302
|
+
): string | undefined {
|
|
229
303
|
if (context !== undefined && Object.keys(context).length == 0) {
|
|
230
304
|
context = undefined;
|
|
231
305
|
}
|
|
@@ -236,34 +310,40 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
|
|
|
236
310
|
}
|
|
237
311
|
|
|
238
312
|
const payload: any = payloadArgs.length == 0 ? undefined : payloadArgs.length == 1 ? payloadArgs[0] : payloadArgs;
|
|
239
|
-
const logItem
|
|
313
|
+
const logItem = {
|
|
240
314
|
// undefined fields get eliminated in JSON.stringify()
|
|
241
315
|
...reportedErrorEvent,
|
|
242
316
|
component,
|
|
243
317
|
severity,
|
|
244
318
|
time: new Date().toISOString(),
|
|
245
|
-
environment: process.env.KUBE_STAGE,
|
|
246
|
-
region: process.env.GITPOD_REGION,
|
|
247
319
|
context,
|
|
248
320
|
message,
|
|
249
321
|
error,
|
|
250
322
|
payload,
|
|
251
|
-
loggedViaConsole: calledViaConsole ? true : undefined
|
|
323
|
+
loggedViaConsole: calledViaConsole ? true : undefined,
|
|
252
324
|
};
|
|
325
|
+
if (plainLogging) {
|
|
326
|
+
return `[${logItem.severity}] [${logItem.component}] ${logItem.message}
|
|
327
|
+
${JSON.stringify(payload || "", undefined, " ")}
|
|
328
|
+
${error || ""}
|
|
329
|
+
`.trim();
|
|
330
|
+
}
|
|
253
331
|
let result: string = stringifyLogItem(logItem);
|
|
254
332
|
|
|
255
333
|
if (result.length > maxAllowedLogItemLength && payload !== undefined) {
|
|
256
334
|
delete logItem.payload;
|
|
257
|
-
|
|
335
|
+
(<any>(
|
|
336
|
+
logItem
|
|
337
|
+
)).payloadStub = `Payload stripped as log item was longer than ${maxAllowedLogItemLength} characters`;
|
|
258
338
|
|
|
259
339
|
result = stringifyLogItem(logItem);
|
|
260
340
|
|
|
261
341
|
if (result.length <= maxAllowedLogItemLength) {
|
|
262
|
-
log.warn(
|
|
342
|
+
log.warn("Log item too large, stripping payload", { logItemStub: makeLogItemStub(logItem) });
|
|
263
343
|
}
|
|
264
344
|
}
|
|
265
345
|
if (result.length > maxAllowedLogItemLength) {
|
|
266
|
-
log.error(
|
|
346
|
+
log.error("Log item too large w/o payload, discarding", { logItemStub: makeLogItemStub(logItem) });
|
|
267
347
|
return undefined;
|
|
268
348
|
}
|
|
269
349
|
|
|
@@ -277,10 +357,10 @@ function makeReportedErrorEvent(error: Error | undefined) {
|
|
|
277
357
|
// Serves as marker only
|
|
278
358
|
"@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
|
|
279
359
|
// This is useful for filtering in the UI
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
360
|
+
serviceContext: {
|
|
361
|
+
service: component || "<ts-not-set>",
|
|
362
|
+
version: version || "<ts-not-set>",
|
|
363
|
+
},
|
|
284
364
|
};
|
|
285
365
|
|
|
286
366
|
if (error) {
|
|
@@ -300,9 +380,9 @@ function makeLogItemStub(logItem: any): any {
|
|
|
300
380
|
severity: logItem.severity,
|
|
301
381
|
time: logItem.time,
|
|
302
382
|
environment: logItem.environment,
|
|
303
|
-
region: logItem.region
|
|
383
|
+
region: logItem.region,
|
|
304
384
|
};
|
|
305
|
-
if (typeof
|
|
385
|
+
if (typeof logItem.message === "string") {
|
|
306
386
|
if (logItem.message.length <= maxMessageStubLength) {
|
|
307
387
|
result.message = logItem.message;
|
|
308
388
|
} else {
|
|
@@ -336,10 +416,12 @@ function stringifyLogItem(logItem: any): string {
|
|
|
336
416
|
* Jsonifies Errors properly, not as {} only.
|
|
337
417
|
*/
|
|
338
418
|
function jsonStringifyWithErrors(value: any): string {
|
|
339
|
-
return JSON.stringify(value, (key: string, value: any): any => {
|
|
419
|
+
return JSON.stringify(value, (key: string, value: any): any => {
|
|
420
|
+
return value instanceof Error ? value.stack : value;
|
|
421
|
+
});
|
|
340
422
|
}
|
|
341
423
|
|
|
342
|
-
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void;
|
|
424
|
+
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
|
|
343
425
|
const logConsoleLog: ConsoleLog = console.log;
|
|
344
426
|
const errorConsoleLog: ConsoleLog = console.error;
|
|
345
427
|
const warnConsoleLog: ConsoleLog = console.warn;
|
package/src/util/make-link.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
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
|
function isOpenNewTab(event: MouseEvent): boolean {
|
|
8
|
-
return event.metaKey ||
|
|
8
|
+
return event.metaKey || event.ctrlKey;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function makeLink(node: HTMLElement, url: string, hover: string): void {
|
|
12
|
-
node.onclick = event => {
|
|
13
|
-
let target =
|
|
12
|
+
node.onclick = (event) => {
|
|
13
|
+
let target = "_self";
|
|
14
14
|
if (isOpenNewTab(event)) {
|
|
15
|
-
target =
|
|
15
|
+
target = "_blank";
|
|
16
16
|
}
|
|
17
17
|
window.open(url, target);
|
|
18
|
-
}
|
|
19
|
-
node.style.cursor =
|
|
18
|
+
};
|
|
19
|
+
node.style.cursor = "pointer";
|
|
20
20
|
node.title = hover;
|
|
21
21
|
}
|
|
22
|
-
|
|
@@ -0,0 +1,96 @@
|
|
|
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 { isAbortError } from "abort-controller-x";
|
|
8
|
+
import {
|
|
9
|
+
CallOptions,
|
|
10
|
+
ClientError,
|
|
11
|
+
ClientMiddleware,
|
|
12
|
+
ClientMiddlewareCall,
|
|
13
|
+
Status,
|
|
14
|
+
MethodDescriptor,
|
|
15
|
+
} from "nice-grpc-common";
|
|
16
|
+
import { GrpcMethodType, IClientCallMetrics } from "./grpc";
|
|
17
|
+
|
|
18
|
+
function getLabels(method: MethodDescriptor) {
|
|
19
|
+
const callType = method.requestStream
|
|
20
|
+
? method.responseStream
|
|
21
|
+
? "bidi_stream"
|
|
22
|
+
: "client_stream"
|
|
23
|
+
: method.responseStream
|
|
24
|
+
? "server_stream"
|
|
25
|
+
: "unary";
|
|
26
|
+
const { path } = method;
|
|
27
|
+
const [serviceName, methodName] = path.split("/").slice(1);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
type: callType as GrpcMethodType,
|
|
31
|
+
service: serviceName,
|
|
32
|
+
method: methodName,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function* incrementStreamMessagesCounter<T>(iterable: AsyncIterable<T>, callback: () => void): AsyncIterable<T> {
|
|
37
|
+
for await (const item of iterable) {
|
|
38
|
+
callback();
|
|
39
|
+
yield item;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function prometheusClientMiddleware(metrics: IClientCallMetrics): ClientMiddleware {
|
|
44
|
+
return async function* prometheusClientMiddlewareGenerator<Request, Response>(
|
|
45
|
+
call: ClientMiddlewareCall<Request, Response>,
|
|
46
|
+
options: CallOptions,
|
|
47
|
+
): AsyncGenerator<Response, Response | void, undefined> {
|
|
48
|
+
const labels = getLabels(call.method);
|
|
49
|
+
|
|
50
|
+
metrics.started(labels);
|
|
51
|
+
|
|
52
|
+
const stopTimer = metrics.startHandleTimer(labels);
|
|
53
|
+
|
|
54
|
+
let settled = false;
|
|
55
|
+
let status: Status = Status.OK;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
let request;
|
|
59
|
+
|
|
60
|
+
if (!call.requestStream) {
|
|
61
|
+
request = call.request;
|
|
62
|
+
} else {
|
|
63
|
+
request = incrementStreamMessagesCounter(call.request, metrics.sent.bind(metrics, labels));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!call.responseStream) {
|
|
67
|
+
const response = yield* call.next(request, options);
|
|
68
|
+
settled = true;
|
|
69
|
+
return response;
|
|
70
|
+
} else {
|
|
71
|
+
yield* incrementStreamMessagesCounter(
|
|
72
|
+
call.next(request, options),
|
|
73
|
+
metrics.received.bind(metrics, labels),
|
|
74
|
+
);
|
|
75
|
+
settled = true;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
settled = true;
|
|
80
|
+
if (err instanceof ClientError) {
|
|
81
|
+
status = err.code;
|
|
82
|
+
} else if (isAbortError(err)) {
|
|
83
|
+
status = Status.CANCELLED;
|
|
84
|
+
} else {
|
|
85
|
+
status = Status.UNKNOWN;
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
} finally {
|
|
89
|
+
if (!settled) {
|
|
90
|
+
status = Status.CANCELLED;
|
|
91
|
+
}
|
|
92
|
+
stopTimer({ grpc_code: Status[status] });
|
|
93
|
+
metrics.handled({ ...labels, code: Status[status] });
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -1,17 +1,20 @@
|
|
|
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 {
|
|
7
|
+
import * as chai from "chai";
|
|
8
|
+
import { suite, test } from "mocha-typescript";
|
|
9
|
+
import {
|
|
10
|
+
matchesInstanceIdOrLegacyWorkspaceIdExactly,
|
|
11
|
+
matchesNewWorkspaceIdExactly,
|
|
12
|
+
parseWorkspaceIdFromHostname,
|
|
13
|
+
} from "./parse-workspace-id";
|
|
10
14
|
const expect = chai.expect;
|
|
11
15
|
|
|
12
16
|
@suite
|
|
13
17
|
export class ParseWorkspaceIdTest {
|
|
14
|
-
|
|
15
18
|
@test public parseWorkspaceIdFromHostname_fromWorkspaceLocation() {
|
|
16
19
|
const actual = parseWorkspaceIdFromHostname("moccasin-ferret-155799b3.ws-eu01.gitpod.io");
|
|
17
20
|
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
@@ -28,7 +31,9 @@ export class ParseWorkspaceIdTest {
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
@test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
|
|
31
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
34
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
35
|
+
"webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com",
|
|
36
|
+
);
|
|
32
37
|
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -44,13 +49,37 @@ export class ParseWorkspaceIdTest {
|
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
|
|
47
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
52
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
53
|
+
"webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io",
|
|
54
|
+
);
|
|
48
55
|
expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
|
|
52
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
59
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
60
|
+
"webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com",
|
|
61
|
+
);
|
|
53
62
|
expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
|
|
54
63
|
}
|
|
64
|
+
|
|
65
|
+
// match - instance ID
|
|
66
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
|
|
67
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
68
|
+
expect(actual).to.be.true;
|
|
69
|
+
}
|
|
70
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
|
|
71
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
|
|
72
|
+
expect(actual).to.be.false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// match - new workspace ID
|
|
76
|
+
@test public matchesWorkspaceIdExactly_new_positive() {
|
|
77
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
|
|
78
|
+
expect(actual).to.be.true;
|
|
79
|
+
}
|
|
80
|
+
@test public matchesWorkspaceIdExactly_new_negative() {
|
|
81
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
|
|
82
|
+
expect(actual).to.be.false;
|
|
83
|
+
}
|
|
55
84
|
}
|
|
56
|
-
module.exports = new ParseWorkspaceIdTest()
|
|
85
|
+
module.exports = new ParseWorkspaceIdTest();
|
|
@@ -1,9 +1,17 @@
|
|
|
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
|
+
const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
|
|
8
|
+
const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
|
|
9
|
+
// We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
|
|
10
|
+
const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
|
|
11
|
+
|
|
12
|
+
const REGEX_WORKSPACE_ID_LEGACY = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
13
|
+
const REGEX_WORKSPACE_ID_LEGACY_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID_LEGACY.source}$`);
|
|
14
|
+
const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID_LEGACY.source})\.ws`);
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Hostname may be of the form:
|
|
@@ -12,18 +20,35 @@
|
|
|
12
20
|
* - webview-1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io (or any other string replacing webview)
|
|
13
21
|
* @param hostname The hostname the request is headed to
|
|
14
22
|
*/
|
|
15
|
-
export const parseWorkspaceIdFromHostname = function(hostname: string) {
|
|
16
|
-
|
|
17
|
-
const wsIdExpression = /([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8})\.ws/g;
|
|
18
|
-
const match = wsIdExpression.exec(hostname);
|
|
23
|
+
export const parseWorkspaceIdFromHostname = function (hostname: string) {
|
|
24
|
+
const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
|
|
19
25
|
if (match && match.length >= 2) {
|
|
20
26
|
return match[1];
|
|
21
27
|
} else {
|
|
22
|
-
const
|
|
23
|
-
const legacyMatch = legacyUrlFormat.exec(hostname);
|
|
28
|
+
const legacyMatch = REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME.exec(hostname);
|
|
24
29
|
if (legacyMatch && legacyMatch.length >= 2) {
|
|
25
30
|
return legacyMatch[1];
|
|
26
31
|
}
|
|
27
32
|
return undefined;
|
|
28
33
|
}
|
|
29
|
-
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Equalls UUIDv4 (and REGEX_WORKSPACE_ID_LEGACY!) */
|
|
37
|
+
const REGEX_INSTANCE_ID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
38
|
+
const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param maybeId
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function (maybeId: string): boolean {
|
|
45
|
+
return REGEX_INSTANCE_ID_EXACT.test(maybeId) || REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param maybeWorkspaceId
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
export const matchesNewWorkspaceIdExactly = function (maybeWorkspaceId: string): boolean {
|
|
53
|
+
return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
|
|
54
|
+
};
|