@gitpod/gitpod-protocol 0.1.5-wth-argo.0 → 0.1.5-yh-vmoptions-fork.1
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 +206 -28
- package/lib/accounting-protocol.d.ts +162 -0
- package/lib/accounting-protocol.d.ts.map +1 -0
- package/lib/accounting-protocol.js +107 -0
- package/lib/accounting-protocol.js.map +1 -0
- package/lib/admin-protocol.d.ts +32 -4
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +15 -0
- 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/auth.d.ts.map +1 -1
- package/lib/context-url.d.ts +31 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +102 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +14 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +109 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/email-protocol.d.ts +1 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +5 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +25 -26
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -37
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +30 -44
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +31 -38
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +0 -6
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +7 -27
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +26 -42
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +145 -142
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +180 -33
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +194 -273
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +9 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +6 -8
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +5 -1
- package/lib/ide-frontend-service.d.ts.map +1 -1
- package/lib/ide-protocol.d.ts +105 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/{util/without.js → ide-protocol.js} +2 -2
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +16 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +27 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +30 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/license-protocol.d.ts +7 -0
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +5 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +184 -34
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +4 -4
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +42 -59
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/error.d.ts +6 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +12 -2
- 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 +18 -0
- package/lib/payment-protocol.d.ts.map +1 -0
- package/lib/payment-protocol.js +13 -0
- package/lib/payment-protocol.js.map +1 -0
- package/lib/permission.d.ts +10 -3
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +41 -31
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +210 -0
- package/lib/plans.d.ts.map +1 -0
- package/lib/plans.js +605 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +196 -83
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +264 -200
- package/lib/protocol.js.map +1 -1
- 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/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
- 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 +91 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -0
- package/lib/team-subscription-protocol.js +74 -0
- package/lib/team-subscription-protocol.js.map +1 -0
- package/lib/teams-projects-protocol.d.ts +118 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +30 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/typings/globals.d.ts +2 -2
- package/lib/typings/globals.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/util/async-iterator.js +57 -135
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +11 -11
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- 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 +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +27 -47
- 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.js +68 -78
- 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 +1 -2
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +108 -109
- 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 +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -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} +1 -1
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +49 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +125 -129
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +5 -5
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +31 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +147 -288
- 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.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts +1 -0
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +35 -17
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +52 -6
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +197 -64
- 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 +7 -7
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +10 -12
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +76 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +31 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +45 -5
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +32 -18
- package/pkg-yarn.lock +18 -10
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +241 -0
- package/src/admin-protocol.ts +70 -19
- package/src/analytics.ts +52 -0
- package/src/auth.ts +2 -2
- package/src/context-url.spec.ts +67 -0
- package/src/context-url.ts +109 -0
- package/src/email-protocol.ts +5 -7
- package/src/encryption/container-module.ts +2 -3
- package/src/encryption/encryption-engine.spec.ts +9 -8
- package/src/encryption/encryption-engine.ts +14 -14
- package/src/encryption/encryption-service.ts +4 -5
- package/src/encryption/key-provider.ts +16 -19
- package/src/env.ts +0 -22
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +348 -110
- package/src/headless-workspace-log.ts +12 -14
- package/src/ide-frontend-service.ts +6 -2
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +16 -10
- package/src/installation-admin-protocol.ts +42 -0
- package/src/license-protocol.ts +12 -6
- package/src/messaging/browser/connection.ts +197 -18
- package/src/messaging/browser/window-connection.ts +39 -29
- package/src/messaging/client-call-metrics.ts +96 -0
- package/src/messaging/error.ts +18 -5
- 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 +20 -0
- package/src/permission.ts +42 -33
- package/src/plans.ts +679 -0
- package/src/protocol.ts +493 -275
- package/src/snapshot-url.spec.ts +27 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +147 -0
- package/src/teams-projects-protocol.ts +153 -0
- package/src/typings/globals.ts +4 -4
- package/src/util/analytics.ts +109 -0
- package/src/util/async-iterator.ts +4 -5
- package/src/util/cancelable.ts +3 -3
- package/src/util/date-time.ts +8 -8
- package/src/util/deferred.ts +6 -6
- package/src/util/disposable.ts +3 -6
- package/src/util/event.ts +9 -11
- package/src/util/garbage-collected-cache.ts +11 -8
- package/src/util/generate-workspace-id.spec.ts +37 -10
- package/src/util/generate-workspace-id.ts +464 -438
- 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 +52 -40
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +145 -72
- package/src/util/make-link.ts +6 -7
- package/src/util/parse-workspace-id.spec.ts +37 -8
- package/src/util/parse-workspace-id.ts +32 -7
- package/src/util/queue.spec.ts +28 -26
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +6 -8
- package/src/util/skip-if.ts +10 -7
- package/src/util/timeutil.spec.ts +14 -15
- package/src/util/timeutil.ts +25 -15
- package/src/util/tracing.spec.ts +88 -0
- package/src/util/tracing.ts +200 -31
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/workspace-cluster.ts +107 -0
- package/src/workspace-instance.ts +98 -31
- package/src/wsready.ts +3 -3
- package/data/builtin-theia-plugins.json +0 -372
- 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.map +0 -1
- 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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 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 { suite, test } from "mocha-typescript";
|
|
8
|
+
import * as chai from "chai";
|
|
9
|
+
import { SnapshotUrl } from ".";
|
|
10
|
+
|
|
11
|
+
const expect = chai.expect;
|
|
12
|
+
|
|
13
|
+
@suite
|
|
14
|
+
class TestSnapshotUrlParser {
|
|
15
|
+
@test public testPositive() {
|
|
16
|
+
const actual = SnapshotUrl.parse(
|
|
17
|
+
"workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
expect(actual).to.deep.equal(<SnapshotUrl>{
|
|
21
|
+
bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
|
|
22
|
+
filename: "3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
|
|
23
|
+
fullPath: "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
module.exports = new TestSnapshotUrlParser(); // Only to circumvent no usage warning :-/
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
export interface SnapshotUrl {
|
|
8
|
+
bucketId: string;
|
|
9
|
+
fullPath: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}
|
|
12
|
+
export namespace SnapshotUrl {
|
|
13
|
+
export function parse(url: string): SnapshotUrl {
|
|
14
|
+
const parts = url.split("@");
|
|
15
|
+
if (parts.length !== 2) {
|
|
16
|
+
throw new Error(`cannot parse snapshot URL: ${url}`);
|
|
17
|
+
}
|
|
18
|
+
const [fullPath, bucketId] = parts;
|
|
19
|
+
|
|
20
|
+
const pathParts = fullPath.split("/");
|
|
21
|
+
if (pathParts.length < 1) {
|
|
22
|
+
throw new Error(`cannot parse snapshot URL: ${url}`);
|
|
23
|
+
}
|
|
24
|
+
const filename = pathParts[pathParts.length - 1];
|
|
25
|
+
return { bucketId, fullPath, filename };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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 { v4 as uuidv4 } from "uuid";
|
|
8
|
+
import { Subscription } from "./accounting-protocol";
|
|
9
|
+
|
|
10
|
+
export interface TeamSubscription {
|
|
11
|
+
id: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
planId: string;
|
|
14
|
+
startDate: string;
|
|
15
|
+
endDate?: string;
|
|
16
|
+
quantity: number;
|
|
17
|
+
/** The Chargebee subscription id */
|
|
18
|
+
paymentReference: string;
|
|
19
|
+
cancellationDate?: string;
|
|
20
|
+
deleted?: boolean;
|
|
21
|
+
/** If this flag is set slots are not eligibile for clusters with "more-resources" - even if their plan might be */
|
|
22
|
+
excludeFromMoreResources: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export namespace TeamSubscription {
|
|
26
|
+
export const create = (ts: Omit<TeamSubscription, "id">): TeamSubscription => {
|
|
27
|
+
const withId = ts as TeamSubscription;
|
|
28
|
+
withId.id = uuidv4();
|
|
29
|
+
return withId;
|
|
30
|
+
};
|
|
31
|
+
export const isActive = (ts: TeamSubscription, date: string): boolean => {
|
|
32
|
+
return ts.startDate <= date && (ts.endDate === undefined || date < ts.endDate);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TeamSubscription2 {
|
|
37
|
+
id: string;
|
|
38
|
+
teamId: string;
|
|
39
|
+
planId: string;
|
|
40
|
+
startDate: string;
|
|
41
|
+
endDate?: string;
|
|
42
|
+
quantity: number;
|
|
43
|
+
/** The Chargebee subscription id */
|
|
44
|
+
paymentReference: string;
|
|
45
|
+
cancellationDate?: string;
|
|
46
|
+
excludeFromMoreResources: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export namespace TeamSubscription2 {
|
|
50
|
+
export const create = (ts2: Omit<TeamSubscription2, "id">): TeamSubscription2 => {
|
|
51
|
+
const withId = ts2 as TeamSubscription2;
|
|
52
|
+
withId.id = uuidv4();
|
|
53
|
+
return withId;
|
|
54
|
+
};
|
|
55
|
+
export const isActive = (ts2: TeamSubscription2, date: string): boolean => {
|
|
56
|
+
return ts2.startDate <= date && (ts2.endDate === undefined || date < ts2.endDate);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A slot represents one unit of a TeamSubscription that gets assigned to one user at a time
|
|
62
|
+
*/
|
|
63
|
+
export interface TeamSubscriptionSlot {
|
|
64
|
+
id: string;
|
|
65
|
+
teamSubscriptionId: string;
|
|
66
|
+
assigneeId?: string;
|
|
67
|
+
assigneeIdentifier?: AssigneeIdentifier;
|
|
68
|
+
subscriptionId?: string;
|
|
69
|
+
cancellationDate?: string;
|
|
70
|
+
}
|
|
71
|
+
export type TeamSubscriptionSlotDeactivated = TeamSubscriptionSlot & {
|
|
72
|
+
assigneeId: string;
|
|
73
|
+
assigneeIdentifier: AssigneeIdentifier;
|
|
74
|
+
};
|
|
75
|
+
export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot &
|
|
76
|
+
TeamSubscriptionSlotDeactivated & { subscriptionId: string };
|
|
77
|
+
|
|
78
|
+
export type TeamSubscriptionSlotState = "unassigned" | "assigned" | "deactivated" | "cancelled";
|
|
79
|
+
|
|
80
|
+
export namespace TeamSubscriptionSlot {
|
|
81
|
+
export const create = (ts: Omit<TeamSubscriptionSlot, "id">): TeamSubscriptionSlot => {
|
|
82
|
+
const withId = ts as TeamSubscriptionSlot;
|
|
83
|
+
withId.id = uuidv4();
|
|
84
|
+
return withId;
|
|
85
|
+
};
|
|
86
|
+
export const assign = (
|
|
87
|
+
slot: TeamSubscriptionSlot,
|
|
88
|
+
assigneeId: string,
|
|
89
|
+
subscriptionId: string,
|
|
90
|
+
assigneeIdentifier: AssigneeIdentifier,
|
|
91
|
+
) => {
|
|
92
|
+
slot.assigneeId = assigneeId;
|
|
93
|
+
slot.subscriptionId = subscriptionId;
|
|
94
|
+
slot.assigneeIdentifier = assigneeIdentifier;
|
|
95
|
+
};
|
|
96
|
+
export const deactivate = (slot: TeamSubscriptionSlot, cancellationDate: string) => {
|
|
97
|
+
slot.subscriptionId = undefined;
|
|
98
|
+
slot.cancellationDate = cancellationDate;
|
|
99
|
+
};
|
|
100
|
+
export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
|
|
101
|
+
slot.subscriptionId = subscriptionId;
|
|
102
|
+
slot.cancellationDate = undefined;
|
|
103
|
+
};
|
|
104
|
+
export const status = (slot: TeamSubscriptionSlot, now: string): TeamSubscriptionSlotState => {
|
|
105
|
+
if (slot.cancellationDate) {
|
|
106
|
+
if (slot.cancellationDate < now) {
|
|
107
|
+
return "cancelled";
|
|
108
|
+
} else {
|
|
109
|
+
return "deactivated";
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
if (slot.subscriptionId) {
|
|
113
|
+
return "assigned";
|
|
114
|
+
} else {
|
|
115
|
+
return "unassigned";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
export const isActive = (slot: TeamSubscriptionSlot): boolean => {
|
|
120
|
+
return !slot.cancellationDate;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The mapping between a TeamSubscription and a resulting Subscription, resolved
|
|
126
|
+
*/
|
|
127
|
+
export interface TeamSubscriptionSlotResolved {
|
|
128
|
+
id: string;
|
|
129
|
+
teamSubscription: TeamSubscription;
|
|
130
|
+
state: TeamSubscriptionSlotState;
|
|
131
|
+
assigneeId?: string;
|
|
132
|
+
assigneeIdentifier?: AssigneeIdentifier;
|
|
133
|
+
subscription?: Subscription;
|
|
134
|
+
cancellationDate?: string;
|
|
135
|
+
hoursLeft?: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Contains the data structure that the assigner used to identify the assignee.
|
|
140
|
+
*/
|
|
141
|
+
export type AssigneeIdentifier = AssigneeIdentityIdentifier;
|
|
142
|
+
export interface AssigneeIdentityIdentifier {
|
|
143
|
+
identity: {
|
|
144
|
+
authHost: string;
|
|
145
|
+
authName: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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 { PrebuiltWorkspaceState } from "./protocol";
|
|
8
|
+
import { v4 as uuidv4 } from "uuid";
|
|
9
|
+
import { DeepPartial } from "./util/deep-partial";
|
|
10
|
+
|
|
11
|
+
export interface ProjectConfig {
|
|
12
|
+
".gitpod.yml": string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ProjectSettings {
|
|
16
|
+
useIncrementalPrebuilds?: boolean;
|
|
17
|
+
usePersistentVolumeClaim?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Project {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
slug?: string;
|
|
24
|
+
cloneUrl: string;
|
|
25
|
+
teamId?: string;
|
|
26
|
+
userId?: string;
|
|
27
|
+
appInstallationId: string;
|
|
28
|
+
config?: ProjectConfig;
|
|
29
|
+
settings?: ProjectSettings;
|
|
30
|
+
creationTime: string;
|
|
31
|
+
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
32
|
+
deleted?: boolean;
|
|
33
|
+
markedDeleted?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export namespace Project {
|
|
37
|
+
export const create = (project: Omit<Project, "id" | "creationTime">): Project => {
|
|
38
|
+
return {
|
|
39
|
+
...project,
|
|
40
|
+
id: uuidv4(),
|
|
41
|
+
creationTime: new Date().toISOString(),
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export interface Overview {
|
|
46
|
+
branches: BranchDetails[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export namespace Overview {
|
|
50
|
+
export function is(data?: any): data is Project.Overview {
|
|
51
|
+
return Array.isArray(data?.branches);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface BranchDetails {
|
|
56
|
+
name: string;
|
|
57
|
+
url: string;
|
|
58
|
+
isDefault: boolean;
|
|
59
|
+
|
|
60
|
+
// Latest commit
|
|
61
|
+
changeTitle: string;
|
|
62
|
+
changeDate?: string;
|
|
63
|
+
changeAuthor?: string;
|
|
64
|
+
changeAuthorAvatar?: string;
|
|
65
|
+
changePR?: string;
|
|
66
|
+
changeUrl?: string;
|
|
67
|
+
changeHash: string;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type PartialProject = DeepPartial<Project> & Pick<Project, "id">;
|
|
72
|
+
|
|
73
|
+
export interface ProjectUsage {
|
|
74
|
+
lastWebhookReceived: string;
|
|
75
|
+
lastWorkspaceStart: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface PrebuildWithStatus {
|
|
79
|
+
info: PrebuildInfo;
|
|
80
|
+
status: PrebuiltWorkspaceState;
|
|
81
|
+
error?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface PrebuildInfo {
|
|
85
|
+
id: string;
|
|
86
|
+
buildWorkspaceId: string;
|
|
87
|
+
basedOnPrebuildId?: string;
|
|
88
|
+
|
|
89
|
+
teamId?: string;
|
|
90
|
+
userId?: string;
|
|
91
|
+
|
|
92
|
+
projectId: string;
|
|
93
|
+
projectName: string;
|
|
94
|
+
|
|
95
|
+
cloneUrl: string;
|
|
96
|
+
branch: string;
|
|
97
|
+
|
|
98
|
+
startedAt: string;
|
|
99
|
+
startedBy: string;
|
|
100
|
+
startedByAvatar?: string;
|
|
101
|
+
|
|
102
|
+
changeTitle: string;
|
|
103
|
+
changeDate: string;
|
|
104
|
+
changeAuthor: string;
|
|
105
|
+
changeAuthorAvatar?: string;
|
|
106
|
+
changePR?: string;
|
|
107
|
+
changeUrl?: string;
|
|
108
|
+
changeHash: string;
|
|
109
|
+
}
|
|
110
|
+
export namespace PrebuildInfo {
|
|
111
|
+
export function is(data?: any): data is PrebuildInfo {
|
|
112
|
+
return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every((p) => p in data);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface StartPrebuildResult {
|
|
117
|
+
prebuildId: string;
|
|
118
|
+
wsid: string;
|
|
119
|
+
done: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface Team {
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
slug: string;
|
|
126
|
+
creationTime: string;
|
|
127
|
+
markedDeleted?: boolean;
|
|
128
|
+
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
129
|
+
deleted?: boolean;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type TeamMemberRole = "owner" | "member";
|
|
133
|
+
|
|
134
|
+
export interface TeamMemberInfo {
|
|
135
|
+
userId: string;
|
|
136
|
+
fullName?: string;
|
|
137
|
+
primaryEmail?: string;
|
|
138
|
+
avatarUrl?: string;
|
|
139
|
+
role: TeamMemberRole;
|
|
140
|
+
memberSince: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface TeamMembershipInvite {
|
|
144
|
+
id: string;
|
|
145
|
+
teamId: string;
|
|
146
|
+
role: TeamMemberRole;
|
|
147
|
+
creationTime: string;
|
|
148
|
+
invalidationTime: string;
|
|
149
|
+
invitedEmail?: string;
|
|
150
|
+
|
|
151
|
+
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
152
|
+
deleted?: boolean;
|
|
153
|
+
}
|
package/src/typings/globals.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
interface Window {
|
|
8
8
|
gitpod: {
|
|
9
|
-
service: import(
|
|
10
|
-
ideService?: import(
|
|
11
|
-
}
|
|
12
|
-
}
|
|
9
|
+
service: import("../gitpod-service").GitpodService;
|
|
10
|
+
ideService?: import("../ide-frontend-service").IDEFrontendService;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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 Analytics = require("analytics-node");
|
|
8
|
+
import { IAnalyticsWriter, IdentifyMessage, TrackMessage, PageMessage } from "../analytics";
|
|
9
|
+
import { log } from "./logging";
|
|
10
|
+
|
|
11
|
+
export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
|
|
12
|
+
switch (process.env.GITPOD_ANALYTICS_WRITER) {
|
|
13
|
+
case "segment":
|
|
14
|
+
return new SegmentAnalyticsWriter(process.env.GITPOD_ANALYTICS_SEGMENT_KEY || "");
|
|
15
|
+
case "log":
|
|
16
|
+
return new LogAnalyticsWriter();
|
|
17
|
+
default:
|
|
18
|
+
return new NoAnalyticsWriter();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class SegmentAnalyticsWriter implements IAnalyticsWriter {
|
|
23
|
+
protected readonly analytics: Analytics;
|
|
24
|
+
|
|
25
|
+
constructor(writeKey: string) {
|
|
26
|
+
this.analytics = new Analytics(writeKey);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
identify(msg: IdentifyMessage) {
|
|
30
|
+
try {
|
|
31
|
+
this.analytics.identify(
|
|
32
|
+
{
|
|
33
|
+
...msg,
|
|
34
|
+
integrations: {
|
|
35
|
+
All: true,
|
|
36
|
+
Mixpanel: !!msg.userId,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
(err: Error) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
log.warn("analytics.identify failed", err);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
log.warn("analytics.identify failed", err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
track(msg: TrackMessage) {
|
|
51
|
+
try {
|
|
52
|
+
this.analytics.track(
|
|
53
|
+
{
|
|
54
|
+
...msg,
|
|
55
|
+
integrations: {
|
|
56
|
+
All: true,
|
|
57
|
+
Mixpanel: !!msg.userId,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
(err: Error) => {
|
|
61
|
+
if (err) {
|
|
62
|
+
log.warn("analytics.track failed", err);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
log.warn("analytics.track failed", err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
page(msg: PageMessage) {
|
|
72
|
+
try {
|
|
73
|
+
this.analytics.page(
|
|
74
|
+
{
|
|
75
|
+
...msg,
|
|
76
|
+
integrations: {
|
|
77
|
+
All: true,
|
|
78
|
+
Mixpanel: !!msg.userId,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
(err: Error) => {
|
|
82
|
+
if (err) {
|
|
83
|
+
log.warn("analytics.page failed", err);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
log.warn("analytics.page failed", err);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class LogAnalyticsWriter implements IAnalyticsWriter {
|
|
94
|
+
identify(msg: IdentifyMessage): void {
|
|
95
|
+
log.debug("analytics identify", msg);
|
|
96
|
+
}
|
|
97
|
+
track(msg: TrackMessage): void {
|
|
98
|
+
log.debug("analytics track", msg);
|
|
99
|
+
}
|
|
100
|
+
page(msg: PageMessage): void {
|
|
101
|
+
log.debug("analytics page", msg);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
class NoAnalyticsWriter implements IAnalyticsWriter {
|
|
106
|
+
identify(msg: IdentifyMessage): void {}
|
|
107
|
+
track(msg: TrackMessage): void {}
|
|
108
|
+
page(msg: PageMessage): void {}
|
|
109
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
// Use asyncIterators with es2015
|
|
8
|
-
if (typeof (Symbol as any).asyncIterator ===
|
|
9
|
-
(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol(
|
|
8
|
+
if (typeof (Symbol as any).asyncIterator === "undefined") {
|
|
9
|
+
(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol("asyncIterator");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export async function find<T>(it: AsyncIterableIterator<T>, predicate: (value: T) => boolean): Promise<T | undefined> {
|
|
@@ -31,12 +31,11 @@ export interface AsyncCachingIterator<T> extends AsyncIterableIterator<T> {
|
|
|
31
31
|
resetCursor(): void;
|
|
32
32
|
}
|
|
33
33
|
export class AsyncCachingIteratorImpl<T> implements AsyncIterableIterator<T>, AsyncCachingIterator<T> {
|
|
34
|
-
|
|
35
34
|
protected cache: T[] = [];
|
|
36
35
|
protected cursor = 0;
|
|
37
36
|
protected cacheRead = false;
|
|
38
37
|
|
|
39
|
-
constructor(protected readonly iterable: AsyncIterableIterator<T>) {
|
|
38
|
+
constructor(protected readonly iterable: AsyncIterableIterator<T>) {}
|
|
40
39
|
|
|
41
40
|
public resetCursor() {
|
|
42
41
|
this.cursor = 0;
|
|
@@ -47,7 +46,7 @@ export class AsyncCachingIteratorImpl<T> implements AsyncIterableIterator<T>, As
|
|
|
47
46
|
if (!this.cacheRead && this.cursor < this.cache.length) {
|
|
48
47
|
return {
|
|
49
48
|
done: false,
|
|
50
|
-
value: this.cache[this.cursor++]
|
|
49
|
+
value: this.cache[this.cursor++],
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
52
|
this.cacheRead = true;
|
package/src/util/cancelable.ts
CHANGED
|
@@ -9,10 +9,10 @@ import { Disposable } from "./disposable";
|
|
|
9
9
|
export class Cancelable<T> implements Disposable {
|
|
10
10
|
protected canceled: boolean;
|
|
11
11
|
|
|
12
|
-
constructor(protected readonly activity: (cancel: boolean) => Promise<T> | undefined) {
|
|
12
|
+
constructor(protected readonly activity: (cancel: boolean) => Promise<T> | undefined) {}
|
|
13
13
|
|
|
14
14
|
public async run(): Promise<T | undefined> {
|
|
15
|
-
for(let r = await this.activity(this.canceled); ; r = await this.activity(this.canceled)) {
|
|
15
|
+
for (let r = await this.activity(this.canceled); ; r = await this.activity(this.canceled)) {
|
|
16
16
|
if (this.canceled) {
|
|
17
17
|
return;
|
|
18
18
|
} else if (r !== undefined) {
|
|
@@ -28,4 +28,4 @@ export class Cancelable<T> implements Disposable {
|
|
|
28
28
|
dispose(): void {
|
|
29
29
|
this.cancel();
|
|
30
30
|
}
|
|
31
|
-
}
|
|
31
|
+
}
|
package/src/util/date-time.ts
CHANGED
|
@@ -5,26 +5,26 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export function formatDate(date?: string) {
|
|
8
|
-
return date ? new Date(date).toLocaleString() :
|
|
8
|
+
return date ? new Date(date).toLocaleString() : "";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function formatHours(hours?: number) {
|
|
12
12
|
if (hours === undefined) {
|
|
13
|
-
return
|
|
13
|
+
return "";
|
|
14
14
|
}
|
|
15
15
|
const h = Math.floor(Math.abs(hours));
|
|
16
|
-
const rm = (Math.abs(hours) - h) * 60
|
|
16
|
+
const rm = (Math.abs(hours) - h) * 60;
|
|
17
17
|
const m = Math.floor(rm);
|
|
18
|
-
const rs = (rm - m) * 60
|
|
18
|
+
const rs = (rm - m) * 60;
|
|
19
19
|
const s = Math.floor(rs);
|
|
20
|
-
const result = h +
|
|
20
|
+
const result = h + ":" + pad2(m) + ":" + pad2(s);
|
|
21
21
|
if (hours < 0) {
|
|
22
|
-
return `-${result}
|
|
22
|
+
return `-${result}`;
|
|
23
23
|
} else {
|
|
24
|
-
return `${result}
|
|
24
|
+
return `${result}`;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function pad2(n: number) {
|
|
29
|
-
return n
|
|
29
|
+
return n < 10 ? "0" + n : "" + n;
|
|
30
30
|
}
|
package/src/util/deferred.ts
CHANGED
|
@@ -19,12 +19,12 @@ export class Deferred<T> {
|
|
|
19
19
|
promise = new Promise<T>((resolve, reject) => {
|
|
20
20
|
this.resolve = (o) => {
|
|
21
21
|
this.isResolved = true;
|
|
22
|
-
resolve(o)
|
|
23
|
-
clearTimeout(this.timer)
|
|
22
|
+
resolve(o as any);
|
|
23
|
+
clearTimeout(this.timer);
|
|
24
24
|
};
|
|
25
25
|
this.reject = (e) => {
|
|
26
|
-
reject(e)
|
|
27
|
-
clearTimeout(this.timer)
|
|
28
|
-
}
|
|
26
|
+
reject(e);
|
|
27
|
+
clearTimeout(this.timer);
|
|
28
|
+
};
|
|
29
29
|
});
|
|
30
|
-
}
|
|
30
|
+
}
|
package/src/util/disposable.ts
CHANGED
|
@@ -16,10 +16,10 @@ export interface Disposable {
|
|
|
16
16
|
export namespace Disposable {
|
|
17
17
|
export function create(func: () => void): Disposable {
|
|
18
18
|
return {
|
|
19
|
-
dispose: func
|
|
19
|
+
dispose: func,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export const NULL = create(() => {
|
|
22
|
+
export const NULL = create(() => {});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export class DisposableCollection implements Disposable {
|
|
@@ -69,9 +69,6 @@ export class DisposableCollection implements Disposable {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
pushAll(disposables: Disposable[]): Disposable[] {
|
|
72
|
-
return disposables.map(disposable =>
|
|
73
|
-
this.push(disposable)
|
|
74
|
-
);
|
|
72
|
+
return disposables.map((disposable) => this.push(disposable));
|
|
75
73
|
}
|
|
76
|
-
|
|
77
74
|
}
|
package/src/util/event.ts
CHANGED
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { Disposable } from "./disposable";
|
|
9
|
-
import { log } from
|
|
9
|
+
import { log } from "./logging";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents a typed event.
|
|
13
13
|
*/
|
|
14
14
|
export interface Event<T> {
|
|
15
|
-
|
|
16
15
|
/**
|
|
17
16
|
*
|
|
18
17
|
* @param listener The listener function will be call when the event happens.
|
|
@@ -24,12 +23,13 @@ export interface Event<T> {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export namespace Event {
|
|
27
|
-
const _disposable = { dispose() {
|
|
28
|
-
export const None: Event<any> = function () {
|
|
26
|
+
const _disposable = { dispose() {} };
|
|
27
|
+
export const None: Event<any> = function () {
|
|
28
|
+
return _disposable;
|
|
29
|
+
};
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
class CallbackList {
|
|
32
|
-
|
|
33
33
|
private _callbacks: Function[] | undefined;
|
|
34
34
|
private _contexts: any[] | undefined;
|
|
35
35
|
|
|
@@ -66,7 +66,7 @@ class CallbackList {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (foundCallbackWithDifferentContext) {
|
|
69
|
-
throw new Error(
|
|
69
|
+
throw new Error("When adding a listener with a context, you should remove it with the same context");
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -105,14 +105,12 @@ export interface EmitterOptions {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export class Emitter<T> {
|
|
108
|
-
|
|
109
|
-
private static _noop = function () { };
|
|
108
|
+
private static _noop = function () {};
|
|
110
109
|
|
|
111
110
|
private _event: Event<T>;
|
|
112
111
|
private _callbacks: CallbackList | undefined;
|
|
113
112
|
|
|
114
|
-
constructor(private _options?: EmitterOptions) {
|
|
115
|
-
}
|
|
113
|
+
constructor(private _options?: EmitterOptions) {}
|
|
116
114
|
|
|
117
115
|
/**
|
|
118
116
|
* For the public to allow to subscribe
|
|
@@ -137,7 +135,7 @@ export class Emitter<T> {
|
|
|
137
135
|
if (this._options && this._options.onLastListenerRemove && this._callbacks!.isEmpty()) {
|
|
138
136
|
this._options.onLastListenerRemove(this);
|
|
139
137
|
}
|
|
140
|
-
}
|
|
138
|
+
},
|
|
141
139
|
};
|
|
142
140
|
if (Array.isArray(disposables)) {
|
|
143
141
|
disposables.push(result);
|