@intuitionrobotics/ts-common 0.41.69 → 0.41.72
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/core/application.js +12 -28
- package/core/application.js.map +1 -1
- package/core/debug-flags.js +27 -30
- package/core/debug-flags.js.map +1 -1
- package/core/dispatcher.js +17 -54
- package/core/dispatcher.js.map +1 -1
- package/core/error-handling.js +1 -1
- package/core/error-handling.js.map +1 -1
- package/core/exceptions.js +47 -81
- package/core/exceptions.js.map +1 -1
- package/core/logger/BeLogged.js +19 -25
- package/core/logger/BeLogged.js.map +1 -1
- package/core/logger/LogClient.js +14 -15
- package/core/logger/LogClient.js.map +1 -1
- package/core/logger/LogClient_BaseRotate.js +20 -39
- package/core/logger/LogClient_BaseRotate.js.map +1 -1
- package/core/logger/LogClient_Browser.js +12 -31
- package/core/logger/LogClient_Browser.js.map +1 -1
- package/core/logger/LogClient_Function.js +14 -31
- package/core/logger/LogClient_Function.js.map +1 -1
- package/core/logger/LogClient_MemBuffer.js +14 -32
- package/core/logger/LogClient_MemBuffer.js.map +1 -1
- package/core/logger/LogClient_Terminal.js +12 -31
- package/core/logger/LogClient_Terminal.js.map +1 -1
- package/core/logger/Logger.js +36 -77
- package/core/logger/Logger.js.map +1 -1
- package/core/logger/utils.js +16 -17
- package/core/logger/utils.js.map +1 -1
- package/core/module-manager.js +33 -58
- package/core/module-manager.js.map +1 -1
- package/core/module.js +43 -62
- package/core/module.js.map +1 -1
- package/modules/CSVModule.js +37 -87
- package/modules/CSVModule.js.map +1 -1
- package/modules/CliParamsModule.js +32 -51
- package/modules/CliParamsModule.js.map +1 -1
- package/package.json +1 -1
- package/permissions/permission-group.js +9 -11
- package/permissions/permission-group.js.map +1 -1
- package/testing/test-model.js +28 -87
- package/testing/test-model.js.map +1 -1
- package/ts-generics/array-params.js +14 -22
- package/ts-generics/array-params.js.map +1 -1
- package/ts-generics/omit-and-join.js +4 -15
- package/ts-generics/omit-and-join.js.map +1 -1
- package/utils/array-tools.js +40 -99
- package/utils/array-tools.js.map +1 -1
- package/utils/crypto-tools.js +1 -1
- package/utils/crypto-tools.js.map +1 -1
- package/utils/date-time-tools.js +17 -69
- package/utils/date-time-tools.js.map +1 -1
- package/utils/filter-tools.js +16 -18
- package/utils/filter-tools.js.map +1 -1
- package/utils/hash-tools.js +4 -7
- package/utils/hash-tools.js.map +1 -1
- package/utils/merge-tools.js +6 -6
- package/utils/merge-tools.js.map +1 -1
- package/utils/object-tools.js +13 -15
- package/utils/object-tools.js.map +1 -1
- package/utils/queue.js +47 -112
- package/utils/queue.js.map +1 -1
- package/utils/random-tools.js +2 -2
- package/utils/random-tools.js.map +1 -1
- package/utils/string-tools.js +1 -1
- package/utils/string-tools.js.map +1 -1
- package/utils/tools.js +6 -6
- package/utils/tools.js.map +1 -1
- package/utils/types.js +1 -1
- package/utils/types.js.map +1 -1
- package/utils/version-tools.js +6 -6
- package/utils/version-tools.js.map +1 -1
- package/validator/validator.js +64 -97
- package/validator/validator.js.map +1 -1
package/utils/date-time-tools.js
CHANGED
|
@@ -25,43 +25,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
25
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
-
function step(op) {
|
|
33
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
-
while (_) try {
|
|
35
|
-
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;
|
|
36
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
-
switch (op[0]) {
|
|
38
|
-
case 0: case 1: t = op; break;
|
|
39
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
-
default:
|
|
43
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
-
if (t[2]) _.ops.pop();
|
|
48
|
-
_.trys.pop(); continue;
|
|
49
|
-
}
|
|
50
|
-
op = body.call(thisArg, _);
|
|
51
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
56
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
57
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
58
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
59
|
-
r[k] = a[j];
|
|
60
|
-
return r;
|
|
61
|
-
};
|
|
62
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
29
|
exports.parseTimeString = exports.formatTimestamp = exports.createReadableTimestampObject = exports.currentTimeMilliesWithTimeZone = exports.currentLocalTimeMillies = exports.currentTimeMillies = exports.auditBy = exports._clearInterval = exports._setInterval = exports._clearTimeout = exports._setTimeout = exports.timeout = exports.Format_YYYYMMDD_HHmmss = exports.Format_HHmmss_DDMMYYYY = exports.Week = exports.Day = exports.Hour = exports.Minute = exports.Second = void 0;
|
|
64
|
-
|
|
30
|
+
const moment = require("moment");
|
|
65
31
|
exports.Second = 1000;
|
|
66
32
|
exports.Minute = exports.Second * 60;
|
|
67
33
|
exports.Hour = exports.Minute * 60;
|
|
@@ -70,20 +36,13 @@ exports.Week = exports.Day * 7;
|
|
|
70
36
|
exports.Format_HHmmss_DDMMYYYY = "HH:mm:ss_DD-MM-YYYY";
|
|
71
37
|
exports.Format_YYYYMMDD_HHmmss = "YYYY-MM-DD_HH:mm:ss";
|
|
72
38
|
function timeout(sleepMs) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
return
|
|
75
|
-
return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, sleepMs, undefined); })];
|
|
76
|
-
});
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return new Promise(resolve => setTimeout(resolve, sleepMs, undefined));
|
|
77
41
|
});
|
|
78
42
|
}
|
|
79
43
|
exports.timeout = timeout;
|
|
80
|
-
function _setTimeout(handler, sleepMs) {
|
|
81
|
-
|
|
82
|
-
var args = [];
|
|
83
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
84
|
-
args[_i - 2] = arguments[_i];
|
|
85
|
-
}
|
|
86
|
-
return setTimeout.apply(void 0, __spreadArrays([handler, sleepMs], args));
|
|
44
|
+
function _setTimeout(handler, sleepMs = 0, ...args) {
|
|
45
|
+
return setTimeout(handler, sleepMs, ...args);
|
|
87
46
|
}
|
|
88
47
|
exports._setTimeout = _setTimeout;
|
|
89
48
|
function _clearTimeout(handlerId) {
|
|
@@ -92,13 +51,8 @@ function _clearTimeout(handlerId) {
|
|
|
92
51
|
return clearTimeout(handlerId);
|
|
93
52
|
}
|
|
94
53
|
exports._clearTimeout = _clearTimeout;
|
|
95
|
-
function _setInterval(handler, sleepMs) {
|
|
96
|
-
|
|
97
|
-
var args = [];
|
|
98
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
99
|
-
args[_i - 2] = arguments[_i];
|
|
100
|
-
}
|
|
101
|
-
return setInterval.apply(void 0, __spreadArrays([handler, sleepMs], args));
|
|
54
|
+
function _setInterval(handler, sleepMs = 0, ...args) {
|
|
55
|
+
return setInterval(handler, sleepMs, ...args);
|
|
102
56
|
}
|
|
103
57
|
exports._setInterval = _setInterval;
|
|
104
58
|
function _clearInterval(handlerId) {
|
|
@@ -107,9 +61,8 @@ function _clearInterval(handlerId) {
|
|
|
107
61
|
return clearInterval(handlerId);
|
|
108
62
|
}
|
|
109
63
|
exports._clearInterval = _clearInterval;
|
|
110
|
-
function auditBy(user, comment, timestamp) {
|
|
111
|
-
|
|
112
|
-
var _auditBy = {
|
|
64
|
+
function auditBy(user, comment, timestamp = currentTimeMillies()) {
|
|
65
|
+
const _auditBy = {
|
|
113
66
|
auditBy: user,
|
|
114
67
|
auditAt: createReadableTimestampObject(exports.Format_HHmmss_DDMMYYYY, timestamp)
|
|
115
68
|
};
|
|
@@ -119,24 +72,22 @@ function auditBy(user, comment, timestamp) {
|
|
|
119
72
|
}
|
|
120
73
|
exports.auditBy = auditBy;
|
|
121
74
|
function currentTimeMillies() {
|
|
122
|
-
|
|
75
|
+
const date = new Date();
|
|
123
76
|
return date.getTime();
|
|
124
77
|
}
|
|
125
78
|
exports.currentTimeMillies = currentTimeMillies;
|
|
126
79
|
function currentLocalTimeMillies() {
|
|
127
|
-
|
|
80
|
+
const date = new Date();
|
|
128
81
|
return date.getTime();
|
|
129
82
|
}
|
|
130
83
|
exports.currentLocalTimeMillies = currentLocalTimeMillies;
|
|
131
84
|
function currentTimeMilliesWithTimeZone() {
|
|
132
|
-
|
|
85
|
+
const date = new Date();
|
|
133
86
|
return date.getTime() + date.getTimezoneOffset();
|
|
134
87
|
}
|
|
135
88
|
exports.currentTimeMilliesWithTimeZone = currentTimeMilliesWithTimeZone;
|
|
136
|
-
function createReadableTimestampObject(pattern, timestamp, timezone) {
|
|
137
|
-
|
|
138
|
-
if (timestamp === void 0) { timestamp = currentTimeMillies(); }
|
|
139
|
-
var timeObj = {
|
|
89
|
+
function createReadableTimestampObject(pattern = exports.Format_HHmmss_DDMMYYYY, timestamp = currentTimeMillies(), timezone) {
|
|
90
|
+
const timeObj = {
|
|
140
91
|
timestamp: timestamp,
|
|
141
92
|
pretty: formatTimestamp(pattern, timestamp)
|
|
142
93
|
};
|
|
@@ -145,18 +96,15 @@ function createReadableTimestampObject(pattern, timestamp, timezone) {
|
|
|
145
96
|
return timeObj;
|
|
146
97
|
}
|
|
147
98
|
exports.createReadableTimestampObject = createReadableTimestampObject;
|
|
148
|
-
function formatTimestamp(pattern, timestamp, timezone) {
|
|
149
|
-
|
|
150
|
-
if (timestamp === void 0) { timestamp = currentTimeMillies(); }
|
|
151
|
-
var m = moment.utc(timestamp);
|
|
99
|
+
function formatTimestamp(pattern = exports.Format_HHmmss_DDMMYYYY, timestamp = currentTimeMillies(), timezone) {
|
|
100
|
+
const m = moment.utc(timestamp);
|
|
152
101
|
if (timezone) {
|
|
153
102
|
m.utcOffset(timezone);
|
|
154
103
|
}
|
|
155
104
|
return m.format(pattern);
|
|
156
105
|
}
|
|
157
106
|
exports.formatTimestamp = formatTimestamp;
|
|
158
|
-
function parseTimeString(timestamp, pattern) {
|
|
159
|
-
if (pattern === void 0) { pattern = exports.Format_HHmmss_DDMMYYYY; }
|
|
107
|
+
function parseTimeString(timestamp, pattern = exports.Format_HHmmss_DDMMYYYY) {
|
|
160
108
|
return moment.utc(timestamp, pattern).valueOf();
|
|
161
109
|
}
|
|
162
110
|
exports.parseTimeString = parseTimeString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time-tools.js","sourceRoot":"","sources":["../../src/main/utils/date-time-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG
|
|
1
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QAAQ,EAAE;QACb,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;KACtB;IACD,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAND,0CAMC;AAED,SAAgB,eAAe,CAAC,SAAiB,EAAE,UAAkB,8BAAsB;IAC1F,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;AACjD,CAAC;AAFD,0CAEC"}
|
package/utils/filter-tools.js
CHANGED
|
@@ -18,38 +18,36 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.Filter = void 0;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
class Filter {
|
|
22
|
+
constructor() {
|
|
23
23
|
this._filter = "";
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
setFilter(filter) {
|
|
26
26
|
this._filter = filter;
|
|
27
|
-
}
|
|
28
|
-
|
|
27
|
+
}
|
|
28
|
+
getFilter(filter) {
|
|
29
29
|
this._filter = filter;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return items.filter(
|
|
34
|
-
|
|
35
|
-
for (
|
|
36
|
-
var key = keysToFilter_1[_i];
|
|
30
|
+
}
|
|
31
|
+
filter(items, filter) {
|
|
32
|
+
const filterAsRegexp = this.prepareFilter();
|
|
33
|
+
return items.filter((item) => {
|
|
34
|
+
const keysToFilter = filter(item);
|
|
35
|
+
for (const key of keysToFilter) {
|
|
37
36
|
if (key.toLowerCase().match(filterAsRegexp))
|
|
38
37
|
return true;
|
|
39
38
|
}
|
|
40
39
|
return false;
|
|
41
40
|
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
}
|
|
42
|
+
prepareFilter() {
|
|
43
|
+
let filter = this._filter;
|
|
45
44
|
filter = filter.trim();
|
|
46
45
|
filter = filter.toLowerCase();
|
|
47
46
|
filter = filter.replace(/\s+/, " ");
|
|
48
47
|
filter = filter.replace(new RegExp("(.)", "g"), ".*?$1");
|
|
49
48
|
filter.length === 0 ? filter = ".*?" : filter += ".*";
|
|
50
49
|
return new RegExp(filter);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
}());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
54
52
|
exports.Filter = Filter;
|
|
55
53
|
//# sourceMappingURL=filter-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-tools.js","sourceRoot":"","sources":["../../src/main/utils/filter-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH;
|
|
1
|
+
{"version":3,"file":"filter-tools.js","sourceRoot":"","sources":["../../src/main/utils/filter-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,MAAa,MAAM;IAAnB;QACS,YAAO,GAAG,EAAE,CAAC;IAkCtB,CAAC;IAhCA,SAAS,CAAC,MAAc;QACvB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS,CAAC,MAAc;QACvB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAI,KAAU,EAAE,MAA6B;QAClD,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAE5C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YAC5B,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAClC,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE;gBAC/B,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;oBAC1C,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,aAAa;QACpB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC1B,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC;QAEtD,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;CACD;AAnCD,wBAmCC"}
|
package/utils/hash-tools.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.decode = exports.encode = exports.sha512 = exports.sha384 = exports.sha256 = exports.sha1 = exports.md5 = void 0;
|
|
21
|
-
|
|
21
|
+
const node_forge_1 = require("node-forge");
|
|
22
22
|
function md5(toBeConverted) {
|
|
23
23
|
return node_forge_1.md.md5.create().update(toBeConverted).digest().toHex().toLowerCase();
|
|
24
24
|
}
|
|
@@ -39,9 +39,8 @@ function sha512(toBeConverted) {
|
|
|
39
39
|
return node_forge_1.md.sha512.create().update(toBeConverted).digest().toHex().toLowerCase();
|
|
40
40
|
}
|
|
41
41
|
exports.sha512 = sha512;
|
|
42
|
-
function encode(data, encoding) {
|
|
43
|
-
|
|
44
|
-
var buffer;
|
|
42
|
+
function encode(data, encoding = "base64") {
|
|
43
|
+
let buffer;
|
|
45
44
|
if (Buffer.isBuffer(data))
|
|
46
45
|
buffer = data;
|
|
47
46
|
else if (typeof data === 'string')
|
|
@@ -51,9 +50,7 @@ function encode(data, encoding) {
|
|
|
51
50
|
return buffer.toString(encoding);
|
|
52
51
|
}
|
|
53
52
|
exports.encode = encode;
|
|
54
|
-
function decode(encoded, from, to) {
|
|
55
|
-
if (from === void 0) { from = "base64"; }
|
|
56
|
-
if (to === void 0) { to = "utf8"; }
|
|
53
|
+
function decode(encoded, from = "base64", to = "utf8") {
|
|
57
54
|
return Buffer.from(encoded, from).toString(to);
|
|
58
55
|
}
|
|
59
56
|
exports.decode = decode;
|
package/utils/hash-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-tools.js","sourceRoot":"","sources":["../../src/main/utils/hash-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"hash-tools.js","sourceRoot":"","sources":["../../src/main/utils/hash-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,2CAA8B;AAE9B,SAAgB,GAAG,CAAC,aAAkB;IACrC,OAAO,eAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC;AAC7E,CAAC;AAFD,kBAEC;AAED,SAAgB,IAAI,CAAC,aAAkB;IACtC,OAAO,eAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC;AAC9E,CAAC;AAFD,oBAEC;AAED,SAAgB,MAAM,CAAC,aAAkB;IACxC,OAAO,eAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC;AAChF,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAC,aAAkB;IACxC,OAAO,eAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC;AAChF,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAC,aAAkB;IACxC,OAAO,eAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC;AAChF,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAC,IAA8B,EAAE,WAA2B,QAAQ;IACzF,IAAI,MAAc,CAAC;IACnB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACxB,MAAM,GAAG,IAAI,CAAC;SACV,IAAI,OAAO,IAAI,KAAK,QAAQ;QAChC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;;QAEnC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IAE/C,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC;AAVD,wBAUC;AAED,SAAgB,MAAM,CAAC,OAAe,EAAE,OAAuB,QAAQ,EAAE,KAAqB,MAAM;IACnG,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAChD,CAAC;AAFD,wBAEC"}
|
package/utils/merge-tools.js
CHANGED
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.merge = exports.mergeArray = exports.mergeObject = void 0;
|
|
21
|
-
|
|
21
|
+
const index_1 = require("../index");
|
|
22
22
|
function mergeObject(original, override) {
|
|
23
23
|
if (original === override) {
|
|
24
24
|
console.log("Original: " + JSON.stringify(original));
|
|
25
25
|
console.log("Override: " + JSON.stringify(override));
|
|
26
|
-
throw new index_1.BadImplementationException(
|
|
26
|
+
throw new index_1.BadImplementationException(`trying to merge same Object instance\n Original: ${typeof original}\n Override: ${typeof override}`);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
return Object.keys(override).reduce(
|
|
28
|
+
const returnValue = index_1.deepClone(original);
|
|
29
|
+
return Object.keys(override).reduce((obj, key) => {
|
|
30
30
|
obj[key] = merge(original[key], override[key]);
|
|
31
31
|
if (obj[key] === undefined)
|
|
32
32
|
delete obj[key];
|
|
@@ -38,7 +38,7 @@ function mergeArray(original, override) {
|
|
|
38
38
|
if (original === override) {
|
|
39
39
|
console.log("Original: " + JSON.stringify(original));
|
|
40
40
|
console.log("Override: " + JSON.stringify(override));
|
|
41
|
-
throw new index_1.BadImplementationException(
|
|
41
|
+
throw new index_1.BadImplementationException(`trying to merge same Array instance\n Original: ${typeof original}\n Override: ${typeof override}`);
|
|
42
42
|
}
|
|
43
43
|
// const returnValue = deepClone(original);
|
|
44
44
|
// returnValue.reduce((array, value) => {
|
|
@@ -62,7 +62,7 @@ function merge(original, override) {
|
|
|
62
62
|
if (override === undefined || override === null)
|
|
63
63
|
return undefined;
|
|
64
64
|
if (override && original && typeof original !== typeof override || (typeof original === "object" && typeof override === 'object' && Array.isArray(original) !== Array.isArray(override)))
|
|
65
|
-
throw new index_1.BadImplementationException(
|
|
65
|
+
throw new index_1.BadImplementationException(`trying to merge object of different types!! \n Original: ${typeof original}\n Override: ${typeof override}`);
|
|
66
66
|
if (Array.isArray(original) && Array.isArray(override))
|
|
67
67
|
return mergeArray(original, override);
|
|
68
68
|
if (typeof original === "object" && typeof override === 'object' && !Array.isArray(original) && !Array.isArray(override))
|
package/utils/merge-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-tools.js","sourceRoot":"","sources":["../../src/main/utils/merge-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,
|
|
1
|
+
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/utils/object-tools.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.assert = exports.compare = exports.cloneObj = exports.cloneArr = exports._setTypedProp = exports._values = exports._keys = exports.deepClone = void 0;
|
|
21
|
-
|
|
21
|
+
const index_1 = require("../index");
|
|
22
22
|
function deepClone(obj) {
|
|
23
23
|
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'undefined' || obj === null)
|
|
24
24
|
return obj;
|
|
@@ -40,19 +40,19 @@ function _setTypedProp(instance, key, value) {
|
|
|
40
40
|
}
|
|
41
41
|
exports._setTypedProp = _setTypedProp;
|
|
42
42
|
function cloneArr(value) {
|
|
43
|
-
return value.map(
|
|
43
|
+
return value.map(a => deepClone(a));
|
|
44
44
|
}
|
|
45
45
|
exports.cloneArr = cloneArr;
|
|
46
46
|
function cloneObj(obj) {
|
|
47
|
-
return _keys(obj).reduce(
|
|
47
|
+
return _keys(obj).reduce((carry, key) => {
|
|
48
48
|
carry[key] = deepClone(obj[key]);
|
|
49
49
|
return carry;
|
|
50
50
|
}, {});
|
|
51
51
|
}
|
|
52
52
|
exports.cloneObj = cloneObj;
|
|
53
53
|
function compare(one, two, keys) {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const typeofOne = typeof one;
|
|
55
|
+
const typeofTwo = typeof two;
|
|
56
56
|
if (typeofOne !== typeofTwo)
|
|
57
57
|
return false;
|
|
58
58
|
if (one === undefined && two === undefined)
|
|
@@ -70,26 +70,24 @@ function compare(one, two, keys) {
|
|
|
70
70
|
if (Array.isArray(one) && Array.isArray(two)) {
|
|
71
71
|
if (one.length !== two.length)
|
|
72
72
|
return false;
|
|
73
|
-
for (
|
|
73
|
+
for (let i = 0; i < one.length; i++) {
|
|
74
74
|
if (compare(one[i], two[i]))
|
|
75
75
|
continue;
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
const _one = one;
|
|
81
|
+
const _two = two;
|
|
82
|
+
const oneKeys = keys || Object.keys(_one);
|
|
83
|
+
const twoKeys = keys || Object.keys(_two);
|
|
84
84
|
if (oneKeys.length !== twoKeys.length)
|
|
85
85
|
return false;
|
|
86
|
-
for (
|
|
87
|
-
var oneKey = oneKeys_1[_i];
|
|
86
|
+
for (const oneKey of oneKeys) {
|
|
88
87
|
if (!twoKeys.includes(oneKey))
|
|
89
88
|
return false;
|
|
90
89
|
}
|
|
91
|
-
for (
|
|
92
|
-
var oneKey = oneKeys_2[_a];
|
|
90
|
+
for (const oneKey of oneKeys) {
|
|
93
91
|
if (compare(_one[oneKey], _two[oneKey]))
|
|
94
92
|
continue;
|
|
95
93
|
return false;
|
|
@@ -99,7 +97,7 @@ function compare(one, two, keys) {
|
|
|
99
97
|
exports.compare = compare;
|
|
100
98
|
function assert(message, expected, actual) {
|
|
101
99
|
if (!compare(expected, actual))
|
|
102
|
-
throw new index_1.AssertionException(
|
|
100
|
+
throw new index_1.AssertionException(`Assertion Failed:\n -- ${message}\n -- Expected: ${JSON.stringify(expected)}\n -- Actual: ${JSON.stringify(actual)}\n\n`);
|
|
103
101
|
}
|
|
104
102
|
exports.assert = assert;
|
|
105
103
|
//# sourceMappingURL=object-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-tools.js","sourceRoot":"","sources":["../../src/main/utils/object-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"object-tools.js","sourceRoot":"","sources":["../../src/main/utils/object-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,oCAGkB;AAGlB,SAAgB,SAAS,CAAI,GAAM;IAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,K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O,CAAC,MAAM;QACpC,OAAO,KAAK,CAAC;IAEd,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC7B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5B,OAAO,KAAK,CAAC;KACd;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC7B,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACtC,SAAS;QAEV,OAAO,KAAK,CAAC;KACb;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AA1DD,0BA0DC;AAED,SAAgB,MAAM,CAAI,OAAe,EAAE,QAAW,EAAE,MAAS;IAChE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC7B,MAAM,IAAI,0BAAkB,CAC3B,2BAA2B,OAAO,oBAAoB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACnI,CAAC;AAJD,wBAIC"}
|
package/utils/queue.js
CHANGED
|
@@ -16,19 +16,6 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
var __extends = (this && this.__extends) || (function () {
|
|
20
|
-
var extendStatics = function (d, b) {
|
|
21
|
-
extendStatics = Object.setPrototypeOf ||
|
|
22
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
23
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
24
|
-
return extendStatics(d, b);
|
|
25
|
-
};
|
|
26
|
-
return function (d, b) {
|
|
27
|
-
extendStatics(d, b);
|
|
28
|
-
function __() { this.constructor = d; }
|
|
29
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
-
};
|
|
31
|
-
})();
|
|
32
19
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33
20
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
21
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -38,127 +25,75 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
38
25
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
26
|
});
|
|
40
27
|
};
|
|
41
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
42
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
43
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
44
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
|
-
function step(op) {
|
|
46
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
-
while (_) try {
|
|
48
|
-
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;
|
|
49
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
|
-
switch (op[0]) {
|
|
51
|
-
case 0: case 1: t = op; break;
|
|
52
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
53
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
54
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
55
|
-
default:
|
|
56
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
57
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
58
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
59
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
60
|
-
if (t[2]) _.ops.pop();
|
|
61
|
-
_.trys.pop(); continue;
|
|
62
|
-
}
|
|
63
|
-
op = body.call(thisArg, _);
|
|
64
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
65
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
69
29
|
exports.Queue = void 0;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_this.ignore = function () {
|
|
30
|
+
const index_1 = require("../index");
|
|
31
|
+
const Logger_1 = require("../core/logger/Logger");
|
|
32
|
+
class Queue extends Logger_1.Logger {
|
|
33
|
+
constructor(name) {
|
|
34
|
+
super(name);
|
|
35
|
+
this.parallelCount = 1;
|
|
36
|
+
this.running = 0;
|
|
37
|
+
this.queue = [];
|
|
38
|
+
this.ignore = () => {
|
|
80
39
|
};
|
|
81
|
-
return _this;
|
|
82
40
|
}
|
|
83
|
-
|
|
41
|
+
setParallelCount(parallelCount) {
|
|
84
42
|
this.parallelCount = parallelCount;
|
|
85
43
|
return this;
|
|
86
|
-
}
|
|
87
|
-
|
|
44
|
+
}
|
|
45
|
+
setOnQueueEmpty(onQueueEmpty) {
|
|
88
46
|
this.onQueueEmpty = onQueueEmpty;
|
|
89
47
|
return this;
|
|
90
|
-
}
|
|
91
|
-
|
|
48
|
+
}
|
|
49
|
+
addItem(toExecute, onCompleted, onError) {
|
|
92
50
|
this.addItemImpl(toExecute.bind(this), onCompleted === null || onCompleted === void 0 ? void 0 : onCompleted.bind(this), onError === null || onError === void 0 ? void 0 : onError.bind(this));
|
|
93
51
|
this.execute();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_a.trys.push([1, 3, , 4]);
|
|
106
|
-
return [4 /*yield*/, toExecute()];
|
|
107
|
-
case 2:
|
|
108
|
-
output = _a.sent();
|
|
109
|
-
onCompleted && onCompleted(output);
|
|
110
|
-
return [3 /*break*/, 4];
|
|
111
|
-
case 3:
|
|
112
|
-
e_1 = _a.sent();
|
|
113
|
-
try {
|
|
114
|
-
onError && onError(e_1);
|
|
115
|
-
}
|
|
116
|
-
catch (e1) {
|
|
117
|
-
this.logError("Error while calling onError");
|
|
118
|
-
this.logError("--- Original: ", e_1);
|
|
119
|
-
this.logError("-- Secondary: ", e1);
|
|
120
|
-
}
|
|
121
|
-
return [3 /*break*/, 4];
|
|
122
|
-
case 4:
|
|
123
|
-
this.running--;
|
|
124
|
-
resolve();
|
|
125
|
-
this.execute();
|
|
126
|
-
return [2 /*return*/];
|
|
52
|
+
}
|
|
53
|
+
addItemImpl(toExecute, onCompleted, onError) {
|
|
54
|
+
index_1.addItemToArray(this.queue, (resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
this.running++;
|
|
56
|
+
try {
|
|
57
|
+
const output = yield toExecute();
|
|
58
|
+
onCompleted && onCompleted(output);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
try {
|
|
62
|
+
onError && onError(e);
|
|
127
63
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
64
|
+
catch (e1) {
|
|
65
|
+
this.logError("Error while calling onError");
|
|
66
|
+
this.logError("--- Original: ", e);
|
|
67
|
+
this.logError("-- Secondary: ", e1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
this.running--;
|
|
71
|
+
resolve();
|
|
72
|
+
this.execute();
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
execute() {
|
|
132
76
|
var _a;
|
|
133
77
|
if (this.queue.length === 0 && this.running === 0) {
|
|
134
78
|
this.onQueueEmpty && this.onQueueEmpty();
|
|
135
79
|
return (_a = this.finalResolve) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
136
80
|
}
|
|
137
|
-
for (
|
|
138
|
-
|
|
81
|
+
for (let i = 0; this.running < this.parallelCount && i < this.queue.length; i++) {
|
|
82
|
+
const toExecute = this.queue[0];
|
|
139
83
|
index_1.removeItemFromArray(this.queue, toExecute);
|
|
140
84
|
new Promise(toExecute.bind(this))
|
|
141
85
|
.then(this.ignore)
|
|
142
86
|
.catch(this.ignore);
|
|
143
87
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
case 0: return [4 /*yield*/, new Promise(function (resolve) {
|
|
151
|
-
_this.finalResolve = resolve;
|
|
152
|
-
_this.execute();
|
|
153
|
-
})];
|
|
154
|
-
case 1:
|
|
155
|
-
_a.sent();
|
|
156
|
-
return [2 /*return*/];
|
|
157
|
-
}
|
|
88
|
+
}
|
|
89
|
+
executeSync() {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
yield new Promise(resolve => {
|
|
92
|
+
this.finalResolve = resolve;
|
|
93
|
+
this.execute();
|
|
158
94
|
});
|
|
159
95
|
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
}(Logger_1.Logger));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
163
98
|
exports.Queue = Queue;
|
|
164
99
|
//# sourceMappingURL=queue.js.map
|
package/utils/queue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/main/utils/queue.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/main/utils/queue.ts"],"names":[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