@gitpod/gitpod-protocol 0.1.5-tweak-workspaceconfig-origin-docs-fork.0 → 0.1.5-update-yarnlock.0
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 +150 -8
- package/lib/accounting-protocol.d.ts +21 -11
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +44 -33
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +29 -1
- 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 +5 -6
- 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 +25 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +58 -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 +19 -7
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +60 -9
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +3 -3
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +20 -12
- 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 +99 -0
- package/lib/frontend-dashboard-service.d.ts.map +1 -0
- package/lib/frontend-dashboard-service.js +55 -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 +143 -51
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +78 -36
- 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 +53 -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 -15
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -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 +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 +12 -2
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +26 -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.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +23 -59
- 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 +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 +13 -4
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +38 -26
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +8 -5
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +227 -172
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +238 -104
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +322 -105
- 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 +24 -4
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +25 -6
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +39 -6
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +21 -3
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +7 -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 +13 -4
- 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 +2 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +12 -3
- 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 +461 -440
- 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 +37 -2
- 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 -5
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +69 -41
- 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 +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 +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 +3 -4
- 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 +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 +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 +47 -13
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +141 -32
- 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 +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 +24 -18
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +22 -2
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +41 -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 +18 -8
- package/pkg-yarn.lock +11 -6
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +76 -52
- package/src/admin-protocol.ts +59 -19
- package/src/analytics.ts +27 -29
- package/src/attribution.ts +67 -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 +25 -15
- package/src/context-url.ts +93 -37
- 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 +148 -0
- package/src/gitpod-file-parser.spec.ts +56 -62
- package/src/gitpod-file-parser.ts +17 -18
- package/src/gitpod-service.ts +315 -136
- package/src/headless-workspace-log.ts +7 -5
- package/src/ide-frontend-service.ts +3 -3
- package/src/ide-protocol.ts +63 -8
- package/src/index.ts +17 -15
- package/src/installation-admin-protocol.ts +45 -0
- 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 +37 -8
- package/src/messaging/handler.ts +6 -6
- package/src/messaging/node/connection.ts +23 -70
- package/src/messaging/proxy-factory.ts +23 -30
- package/src/oss-allowlist.ts +15 -0
- package/src/payment-protocol.ts +3 -3
- package/src/permission.ts +45 -33
- package/src/plans.ts +257 -190
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +650 -305
- package/src/snapshot-url.spec.ts +10 -8
- package/src/snapshot-url.ts +1 -1
- package/src/team-subscription-protocol.ts +63 -23
- package/src/teams-projects-protocol.ts +60 -12
- package/src/typings/globals.ts +12 -5
- package/src/usage.ts +85 -0
- package/src/util/analytics.ts +47 -25
- 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 +15 -7
- package/src/util/generate-workspace-id.spec.ts +35 -8
- package/src/util/generate-workspace-id.ts +465 -441
- 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 +81 -46
- package/src/util/grpc.ts +94 -2
- package/src/util/jaeger-client-types.ts +102 -0
- 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 +7 -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 +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 +88 -0
- package/src/util/tracing.ts +175 -59
- 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 +46 -21
- package/src/workspace-instance.ts +84 -22
- 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/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -34
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js.map +0 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -65
- 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 -31
- package/lib/util/safe-promise.js.map +0 -1
- package/src/email-protocol.ts +0 -66
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/theia-plugins.ts +0 -11
- 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,19 +16,19 @@ 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
34
|
export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
@@ -97,7 +98,11 @@ 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,16 +114,16 @@ export namespace log {
|
|
|
109
114
|
|
|
110
115
|
console.error = function (...args: any[]): void {
|
|
111
116
|
errorLog(true, args);
|
|
112
|
-
}
|
|
117
|
+
};
|
|
113
118
|
console.warn = function (...args: any[]): void {
|
|
114
119
|
warnLog(true, args);
|
|
115
|
-
}
|
|
120
|
+
};
|
|
116
121
|
console.info = function (...args: any[]): void {
|
|
117
122
|
infoLog(true, args);
|
|
118
|
-
}
|
|
123
|
+
};
|
|
119
124
|
console.debug = function (...args: any[]): void {
|
|
120
125
|
debugLog(true, args);
|
|
121
|
-
}
|
|
126
|
+
};
|
|
122
127
|
|
|
123
128
|
console.log = console.info;
|
|
124
129
|
// FIXME wrap also other console methods (e.g. trace())
|
|
@@ -154,26 +159,26 @@ type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
|
|
|
154
159
|
|
|
155
160
|
let errorLog = doErrorLog;
|
|
156
161
|
function doErrorLog(calledViaConsole: boolean, args: any[]): void {
|
|
157
|
-
doLog(calledViaConsole, errorConsoleLog,
|
|
162
|
+
doLog(calledViaConsole, errorConsoleLog, "ERROR", args);
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
let warnLog = doWarnLog;
|
|
161
166
|
function doWarnLog(calledViaConsole: boolean, args: any[]): void {
|
|
162
|
-
doLog(calledViaConsole, warnConsoleLog,
|
|
167
|
+
doLog(calledViaConsole, warnConsoleLog, "WARNING", args);
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
let infoLog = doInfoLog;
|
|
166
171
|
function doInfoLog(calledViaConsole: boolean, args: any[]): void {
|
|
167
|
-
doLog(calledViaConsole, infoConsoleLog,
|
|
172
|
+
doLog(calledViaConsole, infoConsoleLog, "INFO", args);
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
let debugLog = doDebugLog;
|
|
171
176
|
function doDebugLog(calledViaConsole: boolean, args: any[]): void {
|
|
172
|
-
doLog(calledViaConsole, debugConsoleLog,
|
|
177
|
+
doLog(calledViaConsole, debugConsoleLog, "DEBUG", args);
|
|
173
178
|
}
|
|
174
179
|
|
|
175
180
|
// Ref: https://github.com/sirupsen/logrus#level-logging
|
|
176
|
-
export type LogrusLogLevel = keyof
|
|
181
|
+
export type LogrusLogLevel = keyof typeof LogrusLogLevels;
|
|
177
182
|
export const LogrusLogLevels = {
|
|
178
183
|
trace: true,
|
|
179
184
|
debug: true,
|
|
@@ -182,7 +187,7 @@ export const LogrusLogLevels = {
|
|
|
182
187
|
error: true,
|
|
183
188
|
fatal: true,
|
|
184
189
|
panic: true,
|
|
185
|
-
}
|
|
190
|
+
};
|
|
186
191
|
export namespace LogrusLogLevel {
|
|
187
192
|
export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
|
|
188
193
|
if (lvl === undefined) {
|
|
@@ -194,8 +199,7 @@ export namespace LogrusLogLevel {
|
|
|
194
199
|
return getLevelArity(lvl) >= getLevelArity(ref);
|
|
195
200
|
}
|
|
196
201
|
function getLevelArity(lvl: LogrusLogLevel): number {
|
|
197
|
-
return Object.keys(LogrusLogLevels)
|
|
198
|
-
.findIndex((l) => l === lvl);
|
|
202
|
+
return Object.keys(LogrusLogLevels).findIndex((l) => l === lvl);
|
|
199
203
|
}
|
|
200
204
|
export function getFromEnv(): LogrusLogLevel | undefined {
|
|
201
205
|
const lvlStr = process.env.LOG_LEVEL;
|
|
@@ -203,7 +207,7 @@ export namespace LogrusLogLevel {
|
|
|
203
207
|
return undefined;
|
|
204
208
|
}
|
|
205
209
|
const lvl = lvlStr as LogrusLogLevel;
|
|
206
|
-
const exists = LogrusLogLevels[lvl]
|
|
210
|
+
const exists = LogrusLogLevels[lvl];
|
|
207
211
|
if (!exists) {
|
|
208
212
|
return undefined;
|
|
209
213
|
}
|
|
@@ -212,12 +216,12 @@ export namespace LogrusLogLevel {
|
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
// Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
|
215
|
-
type GoogleLogSeverity =
|
|
219
|
+
type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
|
216
220
|
namespace GoogleLogSeverity {
|
|
217
221
|
export const isGreaterOrEqualThanWarning = (severity: GoogleLogSeverity) => {
|
|
218
222
|
switch (severity) {
|
|
219
|
-
case
|
|
220
|
-
case
|
|
223
|
+
case "INFO":
|
|
224
|
+
case "DEBUG":
|
|
221
225
|
return false;
|
|
222
226
|
default:
|
|
223
227
|
return true;
|
|
@@ -245,7 +249,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
245
249
|
// console.xyz(Error, ...any) / log.xyz(Error) / log.xyz(Error, LogPayload)
|
|
246
250
|
error = args[0];
|
|
247
251
|
payloadArgs = args.slice(1);
|
|
248
|
-
} else if (typeof args[0] ===
|
|
252
|
+
} else if (typeof args[0] === "string") {
|
|
249
253
|
message = args[0];
|
|
250
254
|
if (args.length < 2 || !(args[1] instanceof Error)) {
|
|
251
255
|
// console.xyz(string) / console.xyz(string, !Error, ...any) / log.xyz(string) / log.xyz(string, LogPayload)
|
|
@@ -265,7 +269,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
265
269
|
// log.xyz(LogContext, Error) / log.xyz(LogContext, Error, LogPayload)
|
|
266
270
|
error = args[1];
|
|
267
271
|
payloadArgs = args.slice(2);
|
|
268
|
-
} else if (typeof args[1] ===
|
|
272
|
+
} else if (typeof args[1] === "string") {
|
|
269
273
|
message = args[1];
|
|
270
274
|
if (args.length < 3 || !(args[2] instanceof Error)) {
|
|
271
275
|
// log.xyz(LogContext, string) / log.xyz(LogContext, string, LogPayload)
|
|
@@ -288,9 +292,14 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
288
292
|
}
|
|
289
293
|
}
|
|
290
294
|
|
|
291
|
-
function makeLogItem(
|
|
292
|
-
|
|
293
|
-
|
|
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 {
|
|
294
303
|
if (context !== undefined && Object.keys(context).length == 0) {
|
|
295
304
|
context = undefined;
|
|
296
305
|
}
|
|
@@ -301,33 +310,40 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
|
|
|
301
310
|
}
|
|
302
311
|
|
|
303
312
|
const payload: any = payloadArgs.length == 0 ? undefined : payloadArgs.length == 1 ? payloadArgs[0] : payloadArgs;
|
|
304
|
-
const logItem
|
|
313
|
+
const logItem = {
|
|
305
314
|
// undefined fields get eliminated in JSON.stringify()
|
|
306
315
|
...reportedErrorEvent,
|
|
307
316
|
component,
|
|
308
317
|
severity,
|
|
309
318
|
time: new Date().toISOString(),
|
|
310
|
-
environment: process.env.KUBE_STAGE,
|
|
311
319
|
context,
|
|
312
320
|
message,
|
|
313
321
|
error,
|
|
314
322
|
payload,
|
|
315
|
-
loggedViaConsole: calledViaConsole ? true : undefined
|
|
323
|
+
loggedViaConsole: calledViaConsole ? true : undefined,
|
|
316
324
|
};
|
|
325
|
+
if (plainLogging) {
|
|
326
|
+
return `[${logItem.severity}] [${logItem.component}] ${logItem.message}
|
|
327
|
+
${JSON.stringify(payload || "", undefined, " ")}
|
|
328
|
+
${error || ""}
|
|
329
|
+
`.trim();
|
|
330
|
+
}
|
|
317
331
|
let result: string = stringifyLogItem(logItem);
|
|
318
332
|
|
|
319
333
|
if (result.length > maxAllowedLogItemLength && payload !== undefined) {
|
|
320
334
|
delete logItem.payload;
|
|
321
|
-
|
|
335
|
+
(<any>(
|
|
336
|
+
logItem
|
|
337
|
+
)).payloadStub = `Payload stripped as log item was longer than ${maxAllowedLogItemLength} characters`;
|
|
322
338
|
|
|
323
339
|
result = stringifyLogItem(logItem);
|
|
324
340
|
|
|
325
341
|
if (result.length <= maxAllowedLogItemLength) {
|
|
326
|
-
log.warn(
|
|
342
|
+
log.warn("Log item too large, stripping payload", { logItemStub: makeLogItemStub(logItem) });
|
|
327
343
|
}
|
|
328
344
|
}
|
|
329
345
|
if (result.length > maxAllowedLogItemLength) {
|
|
330
|
-
log.error(
|
|
346
|
+
log.error("Log item too large w/o payload, discarding", { logItemStub: makeLogItemStub(logItem) });
|
|
331
347
|
return undefined;
|
|
332
348
|
}
|
|
333
349
|
|
|
@@ -341,10 +357,10 @@ function makeReportedErrorEvent(error: Error | undefined) {
|
|
|
341
357
|
// Serves as marker only
|
|
342
358
|
"@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
|
|
343
359
|
// This is useful for filtering in the UI
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
360
|
+
serviceContext: {
|
|
361
|
+
service: component || "<ts-not-set>",
|
|
362
|
+
version: version || "<ts-not-set>",
|
|
363
|
+
},
|
|
348
364
|
};
|
|
349
365
|
|
|
350
366
|
if (error) {
|
|
@@ -364,9 +380,9 @@ function makeLogItemStub(logItem: any): any {
|
|
|
364
380
|
severity: logItem.severity,
|
|
365
381
|
time: logItem.time,
|
|
366
382
|
environment: logItem.environment,
|
|
367
|
-
region: logItem.region
|
|
383
|
+
region: logItem.region,
|
|
368
384
|
};
|
|
369
|
-
if (typeof
|
|
385
|
+
if (typeof logItem.message === "string") {
|
|
370
386
|
if (logItem.message.length <= maxMessageStubLength) {
|
|
371
387
|
result.message = logItem.message;
|
|
372
388
|
} else {
|
|
@@ -400,10 +416,12 @@ function stringifyLogItem(logItem: any): string {
|
|
|
400
416
|
* Jsonifies Errors properly, not as {} only.
|
|
401
417
|
*/
|
|
402
418
|
function jsonStringifyWithErrors(value: any): string {
|
|
403
|
-
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
|
+
});
|
|
404
422
|
}
|
|
405
423
|
|
|
406
|
-
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void;
|
|
424
|
+
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
|
|
407
425
|
const logConsoleLog: ConsoleLog = console.log;
|
|
408
426
|
const errorConsoleLog: ConsoleLog = console.error;
|
|
409
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,12 +49,16 @@ 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
|
}
|
|
55
64
|
|
|
@@ -73,4 +82,4 @@ export class ParseWorkspaceIdTest {
|
|
|
73
82
|
expect(actual).to.be.false;
|
|
74
83
|
}
|
|
75
84
|
}
|
|
76
|
-
module.exports = new ParseWorkspaceIdTest()
|
|
85
|
+
module.exports = new ParseWorkspaceIdTest();
|
|
@@ -1,10 +1,10 @@
|
|
|
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}/;
|
|
7
|
+
const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
|
|
8
8
|
const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
|
|
9
9
|
// We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
|
|
10
10
|
const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
|
|
@@ -20,7 +20,7 @@ const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_I
|
|
|
20
20
|
* - webview-1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io (or any other string replacing webview)
|
|
21
21
|
* @param hostname The hostname the request is headed to
|
|
22
22
|
*/
|
|
23
|
-
export const parseWorkspaceIdFromHostname = function(hostname: string) {
|
|
23
|
+
export const parseWorkspaceIdFromHostname = function (hostname: string) {
|
|
24
24
|
const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
|
|
25
25
|
if (match && match.length >= 2) {
|
|
26
26
|
return match[1];
|
|
@@ -41,15 +41,14 @@ const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
|
|
|
41
41
|
* @param maybeId
|
|
42
42
|
* @returns
|
|
43
43
|
*/
|
|
44
|
-
export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function(maybeId: string): boolean {
|
|
45
|
-
return REGEX_INSTANCE_ID_EXACT.test(maybeId)
|
|
46
|
-
|| REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
|
|
44
|
+
export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function (maybeId: string): boolean {
|
|
45
|
+
return REGEX_INSTANCE_ID_EXACT.test(maybeId) || REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
|
|
47
46
|
};
|
|
48
47
|
|
|
49
48
|
/**
|
|
50
49
|
* @param maybeWorkspaceId
|
|
51
50
|
* @returns
|
|
52
51
|
*/
|
|
53
|
-
export const matchesNewWorkspaceIdExactly = function(maybeWorkspaceId: string): boolean {
|
|
52
|
+
export const matchesNewWorkspaceIdExactly = function (maybeWorkspaceId: string): boolean {
|
|
54
53
|
return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
|
|
55
|
-
};
|
|
54
|
+
};
|
package/src/util/queue.spec.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
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 { suite, test, slow, timeout } from
|
|
8
|
-
import * as chai from
|
|
9
|
-
const chaiSubset = require(
|
|
7
|
+
import { suite, test, slow, timeout } from "mocha-typescript";
|
|
8
|
+
import * as chai from "chai";
|
|
9
|
+
const chaiSubset = require("chai-subset");
|
|
10
10
|
chai.use(chaiSubset);
|
|
11
11
|
|
|
12
|
-
import { Queue } from
|
|
13
|
-
import { fail } from
|
|
14
|
-
import { Deferred } from
|
|
12
|
+
import { Queue } from "..";
|
|
13
|
+
import { fail } from "assert";
|
|
14
|
+
import { Deferred } from "./deferred";
|
|
15
15
|
|
|
16
|
-
const expect = chai.expect
|
|
17
|
-
|
|
18
|
-
@suite class QueueSpec {
|
|
16
|
+
const expect = chai.expect;
|
|
19
17
|
|
|
18
|
+
@suite
|
|
19
|
+
class QueueSpec {
|
|
20
20
|
queue: Queue;
|
|
21
21
|
seq: number[];
|
|
22
22
|
|
|
@@ -35,8 +35,7 @@ const expect = chai.expect
|
|
|
35
35
|
resolve(undefined);
|
|
36
36
|
}, sleep);
|
|
37
37
|
});
|
|
38
|
-
else
|
|
39
|
-
this.seq.push(seqNr);
|
|
38
|
+
else this.seq.push(seqNr);
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
if (nextTick)
|
|
@@ -45,20 +44,22 @@ const expect = chai.expect
|
|
|
45
44
|
push().then(resolve);
|
|
46
45
|
});
|
|
47
46
|
});
|
|
48
|
-
else
|
|
49
|
-
await push();
|
|
47
|
+
else await push();
|
|
50
48
|
});
|
|
51
49
|
}
|
|
52
50
|
execError(seqNr: number): Deferred<boolean> {
|
|
53
51
|
const deferred = new Deferred<boolean>();
|
|
54
|
-
this.queue
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
this.queue
|
|
53
|
+
.enqueue(async () => {
|
|
54
|
+
this.seq.push(seqNr);
|
|
55
|
+
throw new Error("test error");
|
|
56
|
+
})
|
|
57
|
+
.then(() => {
|
|
58
|
+
deferred.reject(false);
|
|
59
|
+
})
|
|
60
|
+
.catch(() => {
|
|
61
|
+
deferred.resolve(true);
|
|
62
|
+
});
|
|
62
63
|
|
|
63
64
|
return deferred;
|
|
64
65
|
}
|
|
@@ -67,7 +68,9 @@ const expect = chai.expect
|
|
|
67
68
|
expect(actual).to.have.lengthOf(expected.length);
|
|
68
69
|
const expIt = expected.entries();
|
|
69
70
|
for (const act of actual) {
|
|
70
|
-
const {
|
|
71
|
+
const {
|
|
72
|
+
value: [, exp],
|
|
73
|
+
} = expIt.next();
|
|
71
74
|
expect(act).to.deep.equal(exp);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
@@ -93,7 +96,6 @@ const expect = chai.expect
|
|
|
93
96
|
this.expectArray(this.seq, [1, 2]);
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
|
|
97
99
|
@test public async continueDespiteError() {
|
|
98
100
|
this.exec(1);
|
|
99
101
|
const receivedError = this.execError(2);
|
|
@@ -107,7 +109,7 @@ const expect = chai.expect
|
|
|
107
109
|
@test public async mustCatchError() {
|
|
108
110
|
const f = async () => {
|
|
109
111
|
throw new Error();
|
|
110
|
-
}
|
|
112
|
+
};
|
|
111
113
|
try {
|
|
112
114
|
const p = this.queue.enqueue(async () => {
|
|
113
115
|
return f();
|
|
@@ -124,7 +126,7 @@ const expect = chai.expect
|
|
|
124
126
|
@test public async expectUncaughtError() {
|
|
125
127
|
const f = async () => {
|
|
126
128
|
throw new Error();
|
|
127
|
-
}
|
|
129
|
+
};
|
|
128
130
|
const p = this.queue.enqueue(async () => {
|
|
129
131
|
return f();
|
|
130
132
|
});
|
package/src/util/queue.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 { Deferred } from "./deferred";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 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 { Disposable } from "..";
|
|
8
|
+
import { log } from "./logging";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This intends to be a drop-in replacement for 'setInterval' implemented with a 'setTimeout' chain
|
|
12
|
+
* to ensure we're not creating more timeouts than we can process.
|
|
13
|
+
* @param op
|
|
14
|
+
* @param everyMilliseconds
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export function repeat(op: () => Promise<void> | void, everyMilliseconds: number): Disposable {
|
|
18
|
+
let timer: NodeJS.Timeout | undefined = undefined;
|
|
19
|
+
let stopped = false;
|
|
20
|
+
const repeated = () => {
|
|
21
|
+
if (stopped) {
|
|
22
|
+
// in case we missed the clearTimeout i 'await'
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
timer = setTimeout(async () => {
|
|
27
|
+
try {
|
|
28
|
+
await op();
|
|
29
|
+
} catch (err) {
|
|
30
|
+
// catch error here to
|
|
31
|
+
log.error(err);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
repeated(); // chain ourselves - after the 'await'
|
|
35
|
+
}, everyMilliseconds);
|
|
36
|
+
};
|
|
37
|
+
repeated();
|
|
38
|
+
|
|
39
|
+
return Disposable.create(() => {
|
|
40
|
+
stopped = true;
|
|
41
|
+
if (timer) {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|