@gitpod/gitpod-protocol 0.1.5-wth-update-mysql-dependencies-2.31 → 0.1.5-wth-test.80
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 +25 -24
- package/lib/accounting-protocol.d.ts +3 -6
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +10 -16
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +26 -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/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 +94 -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.js +5 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +20 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +124 -22
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +169 -278
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +8 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +4 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +105 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +8 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +6 -0
- 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/messaging/browser/connection.d.ts +5 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +183 -33
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- 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 +3 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +6 -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/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 +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -159
- 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/permission.d.ts +8 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +36 -15
- 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 +570 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +121 -54
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +117 -131
- 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 +4 -4
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +15 -12
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +113 -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/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.js +55 -133
- 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 +8 -8
- 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.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- 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 +26 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +31 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +57 -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 +44 -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 +95 -98
- 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 +103 -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/util/{without.js → 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 +107 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- 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 +32 -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 +144 -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.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +28 -16
- package/lib/util/timeutil.js.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 +51 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +197 -62
- 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.js +3 -2
- 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 +33 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +24 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +31 -17
- package/pkg-yarn.lock +17 -9
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +4 -10
- package/src/admin-protocol.ts +47 -5
- package/src/analytics.ts +52 -0
- package/src/context-url.spec.ts +53 -0
- package/src/context-url.ts +107 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +181 -44
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +7 -1
- package/src/installation-admin-protocol.ts +42 -0
- package/src/messaging/browser/connection.ts +195 -14
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +8 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +21 -68
- package/src/messaging/proxy-factory.ts +14 -6
- package/src/oss-allowlist.ts +15 -0
- package/src/permission.ts +24 -4
- package/src/plans.ts +632 -0
- package/src/protocol.ts +196 -85
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +7 -5
- package/src/teams-projects-protocol.ts +147 -0
- package/src/util/analytics.ts +105 -0
- package/src/util/deferred.ts +1 -1
- package/src/util/garbage-collected-cache.ts +9 -3
- package/src/util/generate-workspace-id.spec.ts +20 -3
- package/src/util/generate-workspace-id.ts +22 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +25 -1
- package/src/util/gitpod-host-url.ts +22 -13
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +102 -38
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/queue.spec.ts +1 -1
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +2 -2
- package/src/util/skip-if.ts +1 -1
- package/src/util/timeutil.ts +4 -4
- package/src/util/tracing.spec.ts +83 -0
- package/src/util/tracing.ts +183 -17
- package/src/workspace-cluster.ts +104 -0
- package/src/workspace-instance.ts +45 -13
- package/src/wsready.ts +2 -2
- 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/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/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/lib/util/queue.spec.js
CHANGED
|
@@ -22,314 +22,170 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var __values = (this && this.__values) || function(o) {
|
|
53
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
54
|
-
if (m) return m.call(o);
|
|
55
|
-
if (o && typeof o.length === "number") return {
|
|
56
|
-
next: function () {
|
|
57
|
-
if (o && i >= o.length) o = void 0;
|
|
58
|
-
return { value: o && o[i++], done: !o };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
62
|
-
};
|
|
63
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
64
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
65
|
-
if (!m) return o;
|
|
66
|
-
var i = m.call(o), r, ar = [], e;
|
|
67
|
-
try {
|
|
68
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
69
|
-
}
|
|
70
|
-
catch (error) { e = { error: error }; }
|
|
71
|
-
finally {
|
|
72
|
-
try {
|
|
73
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
74
|
-
}
|
|
75
|
-
finally { if (e) throw e.error; }
|
|
76
|
-
}
|
|
77
|
-
return ar;
|
|
78
|
-
};
|
|
79
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
26
|
+
const mocha_typescript_1 = require("mocha-typescript");
|
|
27
|
+
const chai = require("chai");
|
|
28
|
+
const chaiSubset = require('chai-subset');
|
|
83
29
|
chai.use(chaiSubset);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
QueueSpec.prototype.before = function () {
|
|
30
|
+
const __1 = require("..");
|
|
31
|
+
const assert_1 = require("assert");
|
|
32
|
+
const deferred_1 = require("./deferred");
|
|
33
|
+
const expect = chai.expect;
|
|
34
|
+
let QueueSpec = class QueueSpec {
|
|
35
|
+
before() {
|
|
92
36
|
this.queue = new __1.Queue();
|
|
93
37
|
this.seq = [];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
switch (_a.label) {
|
|
106
|
-
case 0:
|
|
107
|
-
push = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
108
|
-
var _this = this;
|
|
109
|
-
return __generator(this, function (_a) {
|
|
110
|
-
if (sleep > 0)
|
|
111
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
112
|
-
setTimeout(function () {
|
|
113
|
-
_this.seq.push(seqNr);
|
|
114
|
-
resolve();
|
|
115
|
-
}, sleep);
|
|
116
|
-
})];
|
|
117
|
-
else
|
|
118
|
-
this.seq.push(seqNr);
|
|
119
|
-
return [2 /*return*/];
|
|
120
|
-
});
|
|
121
|
-
}); };
|
|
122
|
-
if (!nextTick) return [3 /*break*/, 1];
|
|
123
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
124
|
-
process.nextTick(function () {
|
|
125
|
-
push().then(resolve);
|
|
126
|
-
});
|
|
127
|
-
})];
|
|
128
|
-
case 1: return [4 /*yield*/, push()];
|
|
129
|
-
case 2:
|
|
130
|
-
_a.sent();
|
|
131
|
-
_a.label = 3;
|
|
132
|
-
case 3: return [2 /*return*/];
|
|
133
|
-
}
|
|
38
|
+
}
|
|
39
|
+
exec(seqNr, nextTick = false, sleep = 0) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const push = () => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (sleep > 0)
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
this.seq.push(seqNr);
|
|
47
|
+
resolve(undefined);
|
|
48
|
+
}, sleep);
|
|
134
49
|
});
|
|
135
|
-
|
|
136
|
-
|
|
50
|
+
else
|
|
51
|
+
this.seq.push(seqNr);
|
|
52
|
+
});
|
|
53
|
+
if (nextTick)
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
process.nextTick(() => {
|
|
56
|
+
push().then(resolve);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
else
|
|
60
|
+
yield push();
|
|
61
|
+
}));
|
|
137
62
|
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
throw new Error('test error');
|
|
146
|
-
});
|
|
147
|
-
}); }).then(function () {
|
|
63
|
+
}
|
|
64
|
+
execError(seqNr) {
|
|
65
|
+
const deferred = new deferred_1.Deferred();
|
|
66
|
+
this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
this.seq.push(seqNr);
|
|
68
|
+
throw new Error('test error');
|
|
69
|
+
})).then(() => {
|
|
148
70
|
deferred.reject(false);
|
|
149
|
-
}).catch(
|
|
71
|
+
}).catch(() => {
|
|
150
72
|
deferred.resolve(true);
|
|
151
73
|
});
|
|
152
74
|
return deferred;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
var e_1, _a;
|
|
75
|
+
}
|
|
76
|
+
expectArray(actual, expected) {
|
|
156
77
|
expect(actual).to.have.lengthOf(expected.length);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var _b = __read(expIt.next().value, 2), exp = _b[1];
|
|
162
|
-
expect(act).to.deep.equal(exp);
|
|
163
|
-
}
|
|
78
|
+
const expIt = expected.entries();
|
|
79
|
+
for (const act of actual) {
|
|
80
|
+
const { value: [, exp] } = expIt.next();
|
|
81
|
+
expect(act).to.deep.equal(exp);
|
|
164
82
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
QueueSpec.prototype.isExecutedInOrder = function () {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
-
return __generator(this, function (_a) {
|
|
176
|
-
switch (_a.label) {
|
|
177
|
-
case 0:
|
|
178
|
-
this.exec(1);
|
|
179
|
-
return [4 /*yield*/, this.exec(2)];
|
|
180
|
-
case 1:
|
|
181
|
-
_a.sent();
|
|
182
|
-
this.expectArray(this.seq, [1, 2]);
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
83
|
+
}
|
|
84
|
+
isExecutedInOrder() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
this.exec(1);
|
|
87
|
+
yield this.exec(2);
|
|
88
|
+
this.expectArray(this.seq, [1, 2]);
|
|
186
89
|
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.exec(1, true);
|
|
194
|
-
return [4 /*yield*/, this.exec(2)];
|
|
195
|
-
case 1:
|
|
196
|
-
_a.sent();
|
|
197
|
-
this.expectArray(this.seq, [1, 2]);
|
|
198
|
-
return [2 /*return*/];
|
|
199
|
-
}
|
|
200
|
-
});
|
|
90
|
+
}
|
|
91
|
+
isExecutedInOrderSkipTick() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
this.exec(1, true);
|
|
94
|
+
yield this.exec(2);
|
|
95
|
+
this.expectArray(this.seq, [1, 2]);
|
|
201
96
|
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.exec(1, false, 2000);
|
|
209
|
-
return [4 /*yield*/, this.exec(2)];
|
|
210
|
-
case 1:
|
|
211
|
-
_a.sent();
|
|
212
|
-
this.expectArray(this.seq, [1, 2]);
|
|
213
|
-
return [2 /*return*/];
|
|
214
|
-
}
|
|
215
|
-
});
|
|
97
|
+
}
|
|
98
|
+
isExecutedInOrderSleep() {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
this.exec(1, false, 2000);
|
|
101
|
+
yield this.exec(2);
|
|
102
|
+
this.expectArray(this.seq, [1, 2]);
|
|
216
103
|
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return [4 /*yield*/, this.exec(3)];
|
|
227
|
-
case 1:
|
|
228
|
-
_b.sent();
|
|
229
|
-
expect(receivedError.isResolved).to.equal(true);
|
|
230
|
-
_a = expect;
|
|
231
|
-
return [4 /*yield*/, receivedError.promise];
|
|
232
|
-
case 2:
|
|
233
|
-
_a.apply(void 0, [_b.sent()]).to.equal(true);
|
|
234
|
-
this.expectArray(this.seq, [1, 2, 3]);
|
|
235
|
-
return [2 /*return*/];
|
|
236
|
-
}
|
|
237
|
-
});
|
|
104
|
+
}
|
|
105
|
+
continueDespiteError() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
this.exec(1);
|
|
108
|
+
const receivedError = this.execError(2);
|
|
109
|
+
yield this.exec(3);
|
|
110
|
+
expect(receivedError.isResolved).to.equal(true);
|
|
111
|
+
expect(yield receivedError.promise).to.equal(true);
|
|
112
|
+
this.expectArray(this.seq, [1, 2, 3]);
|
|
238
113
|
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return __generator(this, function (_a) {
|
|
245
|
-
f = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
246
|
-
return __generator(this, function (_a) {
|
|
247
|
-
throw new Error();
|
|
248
|
-
});
|
|
249
|
-
}); };
|
|
250
|
-
try {
|
|
251
|
-
p = this.queue.enqueue(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
252
|
-
return __generator(this, function (_a) {
|
|
253
|
-
return [2 /*return*/, f()];
|
|
254
|
-
});
|
|
255
|
-
}); });
|
|
256
|
-
p.catch(function (err) {
|
|
257
|
-
// Silence unhandled promise rejection messages
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
catch (err) {
|
|
261
|
-
assert_1.fail("We expect to catch no error");
|
|
262
|
-
}
|
|
263
|
-
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
mustCatchError() {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const f = () => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
throw new Error();
|
|
264
119
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
var _this = this;
|
|
271
|
-
return __generator(this, function (_a) {
|
|
272
|
-
f = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
273
|
-
return __generator(this, function (_a) {
|
|
274
|
-
throw new Error();
|
|
275
|
-
});
|
|
276
|
-
}); };
|
|
277
|
-
p = this.queue.enqueue(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
278
|
-
return __generator(this, function (_a) {
|
|
279
|
-
return [2 /*return*/, f()];
|
|
280
|
-
});
|
|
281
|
-
}); });
|
|
282
|
-
p.then(function (r) {
|
|
283
|
-
assert_1.fail("Expected to catch error!");
|
|
284
|
-
}).catch(function (err) {
|
|
120
|
+
try {
|
|
121
|
+
const p = this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
return f();
|
|
123
|
+
}));
|
|
124
|
+
p.catch((err) => {
|
|
285
125
|
// Silence unhandled promise rejection messages
|
|
286
126
|
});
|
|
287
|
-
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
(0, assert_1.fail)("We expect to catch no error");
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
expectUncaughtError() {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const f = () => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
throw new Error();
|
|
137
|
+
});
|
|
138
|
+
const p = this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
return f();
|
|
140
|
+
}));
|
|
141
|
+
p.then((r) => {
|
|
142
|
+
(0, assert_1.fail)("Expected to catch error!");
|
|
143
|
+
}).catch((err) => {
|
|
144
|
+
// Silence unhandled promise rejection messages
|
|
288
145
|
});
|
|
289
146
|
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}());
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
__decorate([
|
|
150
|
+
mocha_typescript_1.test,
|
|
151
|
+
__metadata("design:type", Function),
|
|
152
|
+
__metadata("design:paramtypes", []),
|
|
153
|
+
__metadata("design:returntype", Promise)
|
|
154
|
+
], QueueSpec.prototype, "isExecutedInOrder", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
mocha_typescript_1.test,
|
|
157
|
+
__metadata("design:type", Function),
|
|
158
|
+
__metadata("design:paramtypes", []),
|
|
159
|
+
__metadata("design:returntype", Promise)
|
|
160
|
+
], QueueSpec.prototype, "isExecutedInOrderSkipTick", null);
|
|
161
|
+
__decorate([
|
|
162
|
+
mocha_typescript_1.test,
|
|
163
|
+
(0, mocha_typescript_1.timeout)(3000),
|
|
164
|
+
(0, mocha_typescript_1.slow)(3000),
|
|
165
|
+
__metadata("design:type", Function),
|
|
166
|
+
__metadata("design:paramtypes", []),
|
|
167
|
+
__metadata("design:returntype", Promise)
|
|
168
|
+
], QueueSpec.prototype, "isExecutedInOrderSleep", null);
|
|
169
|
+
__decorate([
|
|
170
|
+
mocha_typescript_1.test,
|
|
171
|
+
__metadata("design:type", Function),
|
|
172
|
+
__metadata("design:paramtypes", []),
|
|
173
|
+
__metadata("design:returntype", Promise)
|
|
174
|
+
], QueueSpec.prototype, "continueDespiteError", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
mocha_typescript_1.test,
|
|
177
|
+
__metadata("design:type", Function),
|
|
178
|
+
__metadata("design:paramtypes", []),
|
|
179
|
+
__metadata("design:returntype", Promise)
|
|
180
|
+
], QueueSpec.prototype, "mustCatchError", null);
|
|
181
|
+
__decorate([
|
|
182
|
+
mocha_typescript_1.test,
|
|
183
|
+
__metadata("design:type", Function),
|
|
184
|
+
__metadata("design:paramtypes", []),
|
|
185
|
+
__metadata("design:returntype", Promise)
|
|
186
|
+
], QueueSpec.prototype, "expectUncaughtError", null);
|
|
187
|
+
QueueSpec = __decorate([
|
|
188
|
+
mocha_typescript_1.suite
|
|
189
|
+
], QueueSpec);
|
|
334
190
|
module.exports = new QueueSpec();
|
|
335
191
|
//# sourceMappingURL=queue.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.spec.js","sourceRoot":"","sources":["../../src/util/queue.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"queue.spec.js","sourceRoot":"","sources":["../../src/util/queue.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;AAEH,uDAA6D;AAC7D,6BAA4B;AAC5B,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC1C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAErB,0BAA2B;AAC3B,mCAA8B;AAC9B,yCAA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,MAAM,CAAC,GAAG,GAAS,EAAE;gBACjB,MAAM,IAAI,KAAK,EAAE,CAAC;YACtB,CAAC,CAAA,CAAA;YACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAS,EAAE;gBACpC,OAAO,CAAC,EAAE,CAAC;YACf,CAAC,CAAA,CAAC,CAAC;YACH,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,IAAA,aAAI,EAAC,0BAA0B,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,+CAA+C;YACnD,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ,CAAA;AA9DS;IAAL,uBAAI;;;;kDAKJ;AAEK;IAAL,uBAAI;;;;0DAKJ;AAEgC;IAAhC,uBAAI;IAAE,IAAA,0BAAO,EAAC,IAAI,CAAC;IAAE,IAAA,uBAAI,EAAC,IAAI,CAAC;;;;uDAK/B;AAGK;IAAL,uBAAI;;;;qDAQJ;AAEK;IAAL,uBAAI;;;;+CAeJ;AAEK;IAAL,uBAAI;;;;oDAYJ;AAtHQ,SAAS;IAArB,wBAAK;GAAO,SAAS,CAuHrB;AACD,MAAM,CAAC,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
import { Disposable } from "..";
|
|
7
|
+
/**
|
|
8
|
+
* This intends to be a drop-in replacement for 'setInterval' implemented with a 'setTimeout' chain
|
|
9
|
+
* to ensure we're not creating more timeouts than we can process.
|
|
10
|
+
* @param op
|
|
11
|
+
* @param everyMilliseconds
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function repeat(op: () => Promise<void> | void, everyMilliseconds: number): Disposable;
|
|
15
|
+
//# sourceMappingURL=repeat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeat.d.ts","sourceRoot":"","sources":["../../src/util/repeat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAGhC;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,iBAAiB,EAAE,MAAM,GAAG,UAAU,CA4B5F"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
4
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
|
+
* See License-AGPL.txt in the project root for license information.
|
|
6
|
+
*/
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.repeat = void 0;
|
|
18
|
+
const __1 = require("..");
|
|
19
|
+
const logging_1 = require("./logging");
|
|
20
|
+
/**
|
|
21
|
+
* This intends to be a drop-in replacement for 'setInterval' implemented with a 'setTimeout' chain
|
|
22
|
+
* to ensure we're not creating more timeouts than we can process.
|
|
23
|
+
* @param op
|
|
24
|
+
* @param everyMilliseconds
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
function repeat(op, everyMilliseconds) {
|
|
28
|
+
let timer = undefined;
|
|
29
|
+
let stopped = false;
|
|
30
|
+
const repeated = () => {
|
|
31
|
+
if (stopped) {
|
|
32
|
+
// in case we missed the clearTimeout i 'await'
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
timer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
try {
|
|
37
|
+
yield op();
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
// catch error here to
|
|
41
|
+
logging_1.log.error(err);
|
|
42
|
+
}
|
|
43
|
+
repeated(); // chain ourselves - after the 'await'
|
|
44
|
+
}), everyMilliseconds);
|
|
45
|
+
};
|
|
46
|
+
repeated();
|
|
47
|
+
return __1.Disposable.create(() => {
|
|
48
|
+
stopped = true;
|
|
49
|
+
if (timer) {
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.repeat = repeat;
|
|
55
|
+
//# sourceMappingURL=repeat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeat.js","sourceRoot":"","sources":["../../src/util/repeat.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAEH,0BAAgC;AAChC,uCAAgC;AAEhC;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,EAA8B,EAAE,iBAAyB;IAC5E,IAAI,KAAK,GAA+B,SAAS,CAAC;IAClD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,QAAQ,GAAG,GAAG,EAAE;QAClB,IAAI,OAAO,EAAE;YACT,+CAA+C;YAC/C,OAAO;SACV;QAED,KAAK,GAAG,UAAU,CAAC,GAAS,EAAE;YAC1B,IAAI;gBACA,MAAM,EAAE,EAAE,CAAC;aACd;YAAC,OAAO,GAAG,EAAE;gBACV,sBAAsB;gBACtB,aAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aAClB;YAED,QAAQ,EAAE,CAAC,CAAC,sCAAsC;QACtD,CAAC,CAAA,EAAE,iBAAiB,CAAC,CAAC;IAC1B,CAAC,CAAC;IACF,QAAQ,EAAE,CAAC;IAEX,OAAO,cAAU,CAAC,MAAM,CAAC,GAAG,EAAE;QAC1B,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,KAAK,EAAE;YACP,YAAY,CAAC,KAAK,CAAC,CAAC;SACvB;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AA5BD,wBA4BC"}
|