@nu-art/ts-common 0.200.23 → 0.200.25
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/consts/consts.js +0 -1
- package/core/application.js +12 -31
- package/core/debug-flags.js +33 -38
- package/core/dispatcher.js +30 -92
- package/core/error-handling.js +1 -2
- package/core/exceptions.js +47 -84
- package/core/logger/BeLogged.js +19 -26
- package/core/logger/LogClient.js +14 -16
- package/core/logger/LogClient_BaseRotate.js +20 -42
- package/core/logger/LogClient_Browser.js +16 -36
- package/core/logger/LogClient_Function.js +14 -34
- package/core/logger/LogClient_MemBuffer.js +14 -35
- package/core/logger/LogClient_Terminal.js +12 -34
- package/core/logger/Logger.js +69 -152
- package/core/logger/types.js +0 -1
- package/core/logger/utils.js +16 -18
- package/core/module-manager.js +33 -61
- package/core/module.js +43 -65
- package/csv.js +0 -1
- package/index.js +0 -1
- package/modules/CSVModule.js +50 -110
- package/modules/CliParamsModule.js +32 -54
- package/modules/csv-serializer.js +10 -22
- package/package.json +8 -18
- package/permissions/permission-group.js +9 -12
- package/test-index.js +0 -1
- package/testing/consts.js +18 -54
- package/testing/types.js +0 -1
- package/tools/Replacer.js +72 -96
- package/tools/get-log-style.js +5 -10
- package/utils/array-tools.js +63 -127
- package/utils/crypto-tools.js +1 -2
- package/utils/date-time-tools.js +19 -75
- package/utils/db-object-tools.js +0 -1
- package/utils/filter-tools.js +38 -43
- package/utils/hash-tools.js +4 -8
- package/utils/merge-tools.js +4 -5
- package/utils/mimetype-tools.js +0 -1
- package/utils/number-tools.js +3 -4
- package/utils/object-tools.js +16 -20
- package/utils/query-params.js +8 -11
- package/utils/queue.js +47 -115
- package/utils/random-tools.js +2 -3
- package/utils/storage-capacity-tools.js +0 -1
- package/utils/string-tools.js +16 -18
- package/utils/tools.js +11 -42
- package/utils/types.js +1 -2
- package/utils/ui-tools.js +8 -15
- package/utils/version-tools.js +6 -7
- package/validator/type-validators.js +65 -84
- package/validator/validator-core.js +34 -58
- package/consts/consts.js.map +0 -1
- package/core/application.js.map +0 -1
- package/core/debug-flags.js.map +0 -1
- package/core/dispatcher.js.map +0 -1
- package/core/error-handling.js.map +0 -1
- package/core/exceptions.js.map +0 -1
- package/core/logger/BeLogged.js.map +0 -1
- package/core/logger/LogClient.js.map +0 -1
- package/core/logger/LogClient_BaseRotate.js.map +0 -1
- package/core/logger/LogClient_Browser.js.map +0 -1
- package/core/logger/LogClient_Function.js.map +0 -1
- package/core/logger/LogClient_MemBuffer.js.map +0 -1
- package/core/logger/LogClient_Terminal.js.map +0 -1
- package/core/logger/Logger.js.map +0 -1
- package/core/logger/types.js.map +0 -1
- package/core/logger/utils.js.map +0 -1
- package/core/module-manager.js.map +0 -1
- package/core/module.js.map +0 -1
- package/csv.js.map +0 -1
- package/index.js.map +0 -1
- package/modules/CSVModule.js.map +0 -1
- package/modules/CliParamsModule.js.map +0 -1
- package/modules/csv-serializer.js.map +0 -1
- package/permissions/permission-group.js.map +0 -1
- package/test-index.js.map +0 -1
- package/testing/consts.js.map +0 -1
- package/testing/types.js.map +0 -1
- package/tools/Replacer.js.map +0 -1
- package/tools/get-log-style.js.map +0 -1
- package/utils/array-tools.js.map +0 -1
- package/utils/crypto-tools.js.map +0 -1
- package/utils/date-time-tools.js.map +0 -1
- package/utils/db-object-tools.js.map +0 -1
- package/utils/filter-tools.js.map +0 -1
- package/utils/hash-tools.js.map +0 -1
- package/utils/merge-tools.js.map +0 -1
- package/utils/mimetype-tools.js.map +0 -1
- package/utils/number-tools.js.map +0 -1
- package/utils/object-tools.js.map +0 -1
- package/utils/query-params.js.map +0 -1
- package/utils/queue.js.map +0 -1
- package/utils/random-tools.js.map +0 -1
- package/utils/storage-capacity-tools.js.map +0 -1
- package/utils/string-tools.js.map +0 -1
- package/utils/tools.js.map +0 -1
- package/utils/types.js.map +0 -1
- package/utils/ui-tools.js.map +0 -1
- package/utils/version-tools.js.map +0 -1
- package/validator/type-validators.js.map +0 -1
- package/validator/validator-core.js.map +0 -1
package/consts/consts.js
CHANGED
package/core/application.js
CHANGED
|
@@ -16,40 +16,21 @@
|
|
|
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
|
-
if (typeof b !== "function" && b !== null)
|
|
28
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29
|
-
extendStatics(d, b);
|
|
30
|
-
function __() { this.constructor = d; }
|
|
31
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
32
|
-
};
|
|
33
|
-
})();
|
|
34
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
20
|
exports.Application = void 0;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return _super.call(this) || this;
|
|
21
|
+
const module_manager_1 = require("./module-manager");
|
|
22
|
+
class Application extends module_manager_1.ModuleManager {
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
41
25
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
_super.prototype.build.call(this);
|
|
26
|
+
build(onStarted) {
|
|
27
|
+
super.build();
|
|
45
28
|
onStarted && onStarted()
|
|
46
|
-
.then(
|
|
47
|
-
data &&
|
|
48
|
-
|
|
29
|
+
.then((data) => {
|
|
30
|
+
data && this.logInfo("data: ", data);
|
|
31
|
+
this.logInfo("Completed");
|
|
49
32
|
})
|
|
50
|
-
.catch(
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
}(module_manager_1.ModuleManager));
|
|
33
|
+
.catch((err) => this.logError("Error", err));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
54
36
|
exports.Application = Application;
|
|
55
|
-
//# sourceMappingURL=application.js.map
|
package/core/debug-flags.js
CHANGED
|
@@ -18,69 +18,64 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.DebugFlags = exports.DebugFlag = void 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (minLogLevel === void 0) { minLogLevel = types_1.LogLevel.Info; }
|
|
21
|
+
const array_tools_1 = require("../utils/array-tools");
|
|
22
|
+
const types_1 = require("./logger/types");
|
|
23
|
+
class DebugFlag {
|
|
24
|
+
constructor(key, minLogLevel = types_1.LogLevel.Info) {
|
|
26
25
|
this.key = key;
|
|
27
26
|
this.minLogLevel = minLogLevel;
|
|
28
27
|
DebugFlags.add(this);
|
|
29
28
|
}
|
|
30
|
-
|
|
29
|
+
setMinLevel(minLogLevel) {
|
|
31
30
|
this.minLogLevel = minLogLevel;
|
|
32
|
-
}
|
|
33
|
-
|
|
31
|
+
}
|
|
32
|
+
rename(newKey) {
|
|
34
33
|
DebugFlags.rename(this.key, newKey);
|
|
35
|
-
}
|
|
36
|
-
|
|
34
|
+
}
|
|
35
|
+
getKey() {
|
|
37
36
|
return this.key;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (enable === void 0) { enable = true; }
|
|
37
|
+
}
|
|
38
|
+
enable(enable = true) {
|
|
41
39
|
if (this.isEnabled() === enable)
|
|
42
40
|
return;
|
|
43
41
|
if (enable)
|
|
44
42
|
this._enable();
|
|
45
43
|
else
|
|
46
44
|
this._disable();
|
|
47
|
-
}
|
|
48
|
-
|
|
45
|
+
}
|
|
46
|
+
isEnabled() {
|
|
49
47
|
return DebugFlags.instance.ActiveDebugFlags.includes(this.key);
|
|
50
|
-
}
|
|
51
|
-
|
|
48
|
+
}
|
|
49
|
+
canLog(level) {
|
|
52
50
|
return types_1.LogLevelOrdinal.indexOf(level) >= types_1.LogLevelOrdinal.indexOf(this.minLogLevel);
|
|
53
|
-
}
|
|
54
|
-
|
|
51
|
+
}
|
|
52
|
+
_enable() {
|
|
55
53
|
(0, array_tools_1.addItemToArray)(DebugFlags.instance.ActiveDebugFlags, this.key);
|
|
56
|
-
}
|
|
57
|
-
|
|
54
|
+
}
|
|
55
|
+
_disable() {
|
|
58
56
|
(0, array_tools_1.removeItemFromArray)(DebugFlags.instance.ActiveDebugFlags, this.key);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
62
59
|
exports.DebugFlag = DebugFlag;
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
class DebugFlags {
|
|
61
|
+
constructor() {
|
|
65
62
|
this.AllDebugFlags = {};
|
|
66
63
|
this.ActiveDebugFlags = [];
|
|
67
64
|
}
|
|
68
|
-
|
|
69
|
-
if (minLogLevel === void 0) { minLogLevel = types_1.LogLevel.Info; }
|
|
65
|
+
static createFlag(key, minLogLevel = types_1.LogLevel.Info) {
|
|
70
66
|
// @ts-ignore
|
|
71
67
|
return new DebugFlag(key, minLogLevel);
|
|
72
|
-
}
|
|
73
|
-
|
|
68
|
+
}
|
|
69
|
+
static add(flag) {
|
|
74
70
|
this.instance.AllDebugFlags[flag.getKey()] = flag;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
}
|
|
72
|
+
static rename(previousKey, newKey) {
|
|
73
|
+
const flag = this.instance.AllDebugFlags[previousKey];
|
|
78
74
|
if (!flag)
|
|
79
75
|
return;
|
|
80
76
|
delete this.instance.AllDebugFlags[previousKey];
|
|
81
77
|
this.instance.AllDebugFlags[newKey] = flag;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
//# sourceMappingURL=debug-flags.js.map
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
DebugFlags.instance = new DebugFlags();
|
|
81
|
+
exports.DebugFlags = DebugFlags;
|
package/core/dispatcher.js
CHANGED
|
@@ -16,21 +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
|
-
if (typeof b !== "function" && b !== null)
|
|
28
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29
|
-
extendStatics(d, b);
|
|
30
|
-
function __() { this.constructor = d; }
|
|
31
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
32
|
-
};
|
|
33
|
-
})();
|
|
34
19
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
35
20
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
36
21
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -40,93 +25,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
40
25
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
26
|
});
|
|
42
27
|
};
|
|
43
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
44
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
45
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
46
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
47
|
-
function step(op) {
|
|
48
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
49
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
50
|
-
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;
|
|
51
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
52
|
-
switch (op[0]) {
|
|
53
|
-
case 0: case 1: t = op; break;
|
|
54
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
55
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
56
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
57
|
-
default:
|
|
58
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
59
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
60
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
61
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
62
|
-
if (t[2]) _.ops.pop();
|
|
63
|
-
_.trys.pop(); continue;
|
|
64
|
-
}
|
|
65
|
-
op = body.call(thisArg, _);
|
|
66
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
67
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
29
|
exports.Dispatcher = exports.Processor = void 0;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
_this.filter = function (listener) { return !!listener[_this.method]; };
|
|
79
|
-
return _this;
|
|
30
|
+
const Logger_1 = require("./logger/Logger");
|
|
31
|
+
class Processor extends Logger_1.Logger {
|
|
32
|
+
constructor(method) {
|
|
33
|
+
super(method);
|
|
34
|
+
this.method = method;
|
|
35
|
+
this.filter = (listener) => !!listener[this.method];
|
|
80
36
|
}
|
|
81
|
-
|
|
37
|
+
processModules(processor) {
|
|
82
38
|
return this.filterModules().filter(this.filter).map(processor);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
return
|
|
87
|
-
return [2 /*return*/, Promise.all(this.filterModules().map(processor))];
|
|
88
|
-
});
|
|
39
|
+
}
|
|
40
|
+
processModulesAsync(processor) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
return Promise.all(this.filterModules().map(processor));
|
|
89
43
|
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
44
|
+
}
|
|
45
|
+
filterModules() {
|
|
46
|
+
const listeners = Dispatcher.modulesResolver();
|
|
93
47
|
return listeners.filter(this.filter);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
}(Logger_1.Logger));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
97
50
|
exports.Processor = Processor;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return _super.call(this, method) || this;
|
|
51
|
+
class Dispatcher extends Processor {
|
|
52
|
+
constructor(method) {
|
|
53
|
+
super(method);
|
|
102
54
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var p = [];
|
|
106
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
107
|
-
p[_i] = arguments[_i];
|
|
108
|
-
}
|
|
109
|
-
return this.processModules(function (listener) {
|
|
55
|
+
dispatchModule(...p) {
|
|
56
|
+
return this.processModules((listener) => {
|
|
110
57
|
// @ts-ignore
|
|
111
|
-
return listener[
|
|
58
|
+
return (listener[this.method])(...p);
|
|
112
59
|
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
-
var _this = this;
|
|
121
|
-
return __generator(this, function (_a) {
|
|
122
|
-
return [2 /*return*/, this.processModulesAsync(function (listener) {
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
return listener[_this.method].apply(listener, p);
|
|
125
|
-
})];
|
|
60
|
+
}
|
|
61
|
+
dispatchModuleAsync(...p) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return this.processModulesAsync((listener) => {
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
return listener[this.method](...p);
|
|
126
66
|
});
|
|
127
67
|
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
}(Processor));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
131
70
|
exports.Dispatcher = Dispatcher;
|
|
132
|
-
//# sourceMappingURL=dispatcher.js.map
|
package/core/error-handling.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.dispatch_onServerError = exports.ServerErrorSeverity_Ordinal = exports.ServerErrorSeverity = void 0;
|
|
21
|
-
|
|
21
|
+
const dispatcher_1 = require("./dispatcher");
|
|
22
22
|
var ServerErrorSeverity;
|
|
23
23
|
(function (ServerErrorSeverity) {
|
|
24
24
|
ServerErrorSeverity["Debug"] = "Debug";
|
|
@@ -35,4 +35,3 @@ exports.ServerErrorSeverity_Ordinal = [
|
|
|
35
35
|
ServerErrorSeverity.Critical
|
|
36
36
|
];
|
|
37
37
|
exports.dispatch_onServerError = new dispatcher_1.Dispatcher("__processApplicationError");
|
|
38
|
-
//# sourceMappingURL=error-handling.js.map
|
package/core/exceptions.js
CHANGED
|
@@ -19,21 +19,6 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* Created by TacB0sS on 3/16/17.
|
|
21
21
|
*/
|
|
22
|
-
var __extends = (this && this.__extends) || (function () {
|
|
23
|
-
var extendStatics = function (d, b) {
|
|
24
|
-
extendStatics = Object.setPrototypeOf ||
|
|
25
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
27
|
-
return extendStatics(d, b);
|
|
28
|
-
};
|
|
29
|
-
return function (d, b) {
|
|
30
|
-
if (typeof b !== "function" && b !== null)
|
|
31
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
32
|
-
extendStatics(d, b);
|
|
33
|
-
function __() { this.constructor = d; }
|
|
34
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
23
|
exports.AssertionException = exports.WhoCallthisException = exports.DontCallthisException = exports.ThisShouldNotHappenException = exports.NotImplementedYetException = exports.MUSTNeverHappenException = exports.ImplementationMissingException = exports.BadImplementationException = exports.Exception = exports.CustomException = exports.isErrorOfType = void 0;
|
|
39
24
|
/**
|
|
@@ -62,7 +47,7 @@ exports.AssertionException = exports.WhoCallthisException = exports.DontCallthis
|
|
|
62
47
|
*/
|
|
63
48
|
function isErrorOfType(e, _exceptionType) {
|
|
64
49
|
var _a;
|
|
65
|
-
|
|
50
|
+
const _e = e;
|
|
66
51
|
if ((_a = _e.isInstanceOf) === null || _a === void 0 ? void 0 : _a.call(_e, _exceptionType))
|
|
67
52
|
return e;
|
|
68
53
|
}
|
|
@@ -78,137 +63,115 @@ exports.isErrorOfType = isErrorOfType;
|
|
|
78
63
|
*
|
|
79
64
|
* @category Exceptions
|
|
80
65
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return _this.exceptionType === _exceptionType.name;
|
|
66
|
+
class CustomException extends Error {
|
|
67
|
+
constructor(exceptionType, message, cause) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.message = message;
|
|
70
|
+
this.stack = (new Error(message)).stack;
|
|
71
|
+
this.cause = cause;
|
|
72
|
+
this.exceptionType = exceptionType.name;
|
|
73
|
+
this.isInstanceOf = (_exceptionType) => {
|
|
74
|
+
return this.exceptionType === _exceptionType.name;
|
|
91
75
|
};
|
|
92
|
-
return _this;
|
|
93
76
|
}
|
|
94
|
-
|
|
95
|
-
}(Error));
|
|
77
|
+
}
|
|
96
78
|
exports.CustomException = CustomException;
|
|
97
79
|
/**
|
|
98
80
|
* # <ins>Exception</ins>
|
|
99
81
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "Exception",
|
|
100
82
|
* @category Exceptions
|
|
101
83
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return _super.call(this, Exception, message, cause) || this;
|
|
84
|
+
class Exception extends CustomException {
|
|
85
|
+
constructor(message, cause) {
|
|
86
|
+
super(Exception, message, cause);
|
|
106
87
|
}
|
|
107
|
-
|
|
108
|
-
}(CustomException));
|
|
88
|
+
}
|
|
109
89
|
exports.Exception = Exception;
|
|
110
90
|
/**
|
|
111
91
|
* # <ins>BadImplementationException</ins>
|
|
112
92
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "BadImplementationException",
|
|
113
93
|
* @category Exceptions
|
|
114
94
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return _super.call(this, BadImplementationException, message, cause) || this;
|
|
95
|
+
class BadImplementationException extends CustomException {
|
|
96
|
+
constructor(message, cause) {
|
|
97
|
+
super(BadImplementationException, message, cause);
|
|
119
98
|
}
|
|
120
|
-
|
|
121
|
-
}(CustomException));
|
|
99
|
+
}
|
|
122
100
|
exports.BadImplementationException = BadImplementationException;
|
|
123
101
|
/**
|
|
124
102
|
* # <ins>ImplementationMissingException</ins>
|
|
125
103
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "ImplementationMissingException",
|
|
126
104
|
* @category Exceptions
|
|
127
105
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return _super.call(this, ImplementationMissingException, message, cause) || this;
|
|
106
|
+
class ImplementationMissingException extends CustomException {
|
|
107
|
+
constructor(message, cause) {
|
|
108
|
+
super(ImplementationMissingException, message, cause);
|
|
132
109
|
}
|
|
133
|
-
|
|
134
|
-
}(CustomException));
|
|
110
|
+
}
|
|
135
111
|
exports.ImplementationMissingException = ImplementationMissingException;
|
|
136
112
|
/**
|
|
137
113
|
* # <ins>MUSTNeverHappenException</ins>
|
|
138
114
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "MUSTNeverHappenException",
|
|
139
115
|
* @category Exceptions
|
|
140
116
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return _super.call(this, MUSTNeverHappenException, message, cause) || this;
|
|
117
|
+
class MUSTNeverHappenException extends CustomException {
|
|
118
|
+
constructor(message, cause) {
|
|
119
|
+
super(MUSTNeverHappenException, message, cause);
|
|
145
120
|
}
|
|
146
|
-
|
|
147
|
-
}(CustomException));
|
|
121
|
+
}
|
|
148
122
|
exports.MUSTNeverHappenException = MUSTNeverHappenException;
|
|
149
123
|
/**
|
|
150
124
|
* # <ins>NotImplementedYetException</ins>
|
|
151
125
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "NotImplementedYetException",
|
|
152
126
|
* @category Exceptions
|
|
153
127
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return _super.call(this, NotImplementedYetException, message, cause) || this;
|
|
128
|
+
class NotImplementedYetException extends CustomException {
|
|
129
|
+
constructor(message, cause) {
|
|
130
|
+
super(NotImplementedYetException, message, cause);
|
|
158
131
|
}
|
|
159
|
-
|
|
160
|
-
}(CustomException));
|
|
132
|
+
}
|
|
161
133
|
exports.NotImplementedYetException = NotImplementedYetException;
|
|
162
134
|
/**
|
|
163
135
|
* # <ins>ThisShouldNotHappenException</ins>
|
|
164
136
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "ThisShouldNotHappenException",
|
|
165
137
|
* @category Exceptions
|
|
166
138
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return _super.call(this, ThisShouldNotHappenException, message, cause) || this;
|
|
139
|
+
class ThisShouldNotHappenException extends CustomException {
|
|
140
|
+
constructor(message, cause) {
|
|
141
|
+
super(ThisShouldNotHappenException, message, cause);
|
|
171
142
|
}
|
|
172
|
-
|
|
173
|
-
}(CustomException));
|
|
143
|
+
}
|
|
174
144
|
exports.ThisShouldNotHappenException = ThisShouldNotHappenException;
|
|
175
145
|
/**
|
|
176
146
|
* # <ins>DontCallthisException</ins>
|
|
177
147
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "DontCallthisException",
|
|
178
148
|
* @category Exceptions
|
|
179
149
|
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return _super.call(this, DontCallthisException, message, cause) || this;
|
|
150
|
+
class DontCallthisException extends CustomException {
|
|
151
|
+
constructor(message, cause) {
|
|
152
|
+
super(DontCallthisException, message, cause);
|
|
184
153
|
}
|
|
185
|
-
|
|
186
|
-
}(CustomException));
|
|
154
|
+
}
|
|
187
155
|
exports.DontCallthisException = DontCallthisException;
|
|
188
156
|
/**
|
|
189
157
|
* # <ins>WhoCallthisException</ins>
|
|
190
158
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "WhoCallthisException",
|
|
191
159
|
* @category Exceptions
|
|
192
160
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return _super.call(this, WhoCallthisException, message, cause) || this;
|
|
161
|
+
class WhoCallthisException extends CustomException {
|
|
162
|
+
constructor(message, cause) {
|
|
163
|
+
super(WhoCallthisException, message, cause);
|
|
197
164
|
}
|
|
198
|
-
|
|
199
|
-
}(CustomException));
|
|
165
|
+
}
|
|
200
166
|
exports.WhoCallthisException = WhoCallthisException;
|
|
201
167
|
/**
|
|
202
168
|
* # <ins>AssertionException</ins>
|
|
203
169
|
* This class inherits {@link CustomException} and functions like it, after setting the exceptionType property as "AssertionException",
|
|
204
170
|
* @category Exceptions
|
|
205
171
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return _super.call(this, AssertionException, message, cause) || this;
|
|
172
|
+
class AssertionException extends CustomException {
|
|
173
|
+
constructor(message, cause) {
|
|
174
|
+
super(AssertionException, message, cause);
|
|
210
175
|
}
|
|
211
|
-
|
|
212
|
-
}(CustomException));
|
|
176
|
+
}
|
|
213
177
|
exports.AssertionException = AssertionException;
|
|
214
|
-
//# sourceMappingURL=exceptions.js.map
|
package/core/logger/BeLogged.js
CHANGED
|
@@ -18,44 +18,37 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.BeLogged = void 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const array_tools_1 = require("../../utils/array-tools");
|
|
22
|
+
class BeLogged_Class {
|
|
23
|
+
constructor() {
|
|
24
24
|
this.clients = [];
|
|
25
25
|
this.lineCount = 0;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
addClient(client) {
|
|
28
28
|
if (this.clients.indexOf(client) !== -1)
|
|
29
29
|
return;
|
|
30
30
|
this.clients.push(client);
|
|
31
|
-
}
|
|
32
|
-
|
|
31
|
+
}
|
|
32
|
+
removeConsole(client) {
|
|
33
33
|
if (this.clients.indexOf(client) === -1)
|
|
34
34
|
return;
|
|
35
35
|
(0, array_tools_1.removeItemFromArray)(this.clients, client);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var toLog = [];
|
|
39
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
40
|
-
toLog[_i - 3] = arguments[_i];
|
|
41
|
-
}
|
|
36
|
+
}
|
|
37
|
+
log(tag, level, bold, ...toLog) {
|
|
42
38
|
this.logImpl(tag, level, bold, toLog);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
for (
|
|
46
|
-
var client = _a[_i];
|
|
39
|
+
}
|
|
40
|
+
logImpl(tag, level, bold, toLog) {
|
|
41
|
+
for (const client of this.clients) {
|
|
47
42
|
client.log(tag, level, bold, toLog);
|
|
48
43
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (
|
|
52
|
-
process.stdout.write(
|
|
44
|
+
}
|
|
45
|
+
clearFooter() {
|
|
46
|
+
for (let i = 0; i < this.lineCount + 3; i++) {
|
|
47
|
+
process.stdout.write(`\n`);
|
|
53
48
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
49
|
+
}
|
|
50
|
+
rewriteConsole(lineCount) {
|
|
56
51
|
this.lineCount = lineCount;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
60
54
|
exports.BeLogged = new BeLogged_Class();
|
|
61
|
-
//# sourceMappingURL=BeLogged.js.map
|
package/core/logger/LogClient.js
CHANGED
|
@@ -18,26 +18,25 @@
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.DefaultLogPrefixComposer = exports._logger_getPrefix = exports._logger_finalDate = exports._logger_timezoneOffset = exports.LogClient = void 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const types_1 = require("./types");
|
|
22
|
+
class LogClient {
|
|
23
|
+
constructor() {
|
|
24
24
|
this.prefixComposer = exports.DefaultLogPrefixComposer;
|
|
25
|
-
this.filter =
|
|
25
|
+
this.filter = () => true;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
setComposer(logComposer) {
|
|
28
28
|
this.prefixComposer = logComposer;
|
|
29
|
-
}
|
|
30
|
-
|
|
29
|
+
}
|
|
30
|
+
setFilter(filter) {
|
|
31
31
|
this.filter = filter;
|
|
32
32
|
return this;
|
|
33
|
-
}
|
|
34
|
-
|
|
33
|
+
}
|
|
34
|
+
log(tag, level, bold, toLog) {
|
|
35
35
|
if (!this.filter(level, tag))
|
|
36
36
|
return;
|
|
37
37
|
this.logMessage(level, bold, this.prefixComposer(tag, level), toLog);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
41
40
|
exports.LogClient = LogClient;
|
|
42
41
|
exports._logger_timezoneOffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
|
|
43
42
|
exports._logger_finalDate = new Date();
|
|
@@ -58,10 +57,9 @@ function _logger_getPrefix(level) {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
exports._logger_getPrefix = _logger_getPrefix;
|
|
61
|
-
|
|
60
|
+
const DefaultLogPrefixComposer = (tag, level) => {
|
|
62
61
|
exports._logger_finalDate.setTime(Date.now() - exports._logger_timezoneOffset);
|
|
63
|
-
|
|
64
|
-
return
|
|
62
|
+
const date = exports._logger_finalDate.toISOString().replace(/T/, '_').replace(/Z/, '').substring(0, 23);
|
|
63
|
+
return ` ${date} ${_logger_getPrefix(level)} ${tag}: `;
|
|
65
64
|
};
|
|
66
65
|
exports.DefaultLogPrefixComposer = DefaultLogPrefixComposer;
|
|
67
|
-
//# sourceMappingURL=LogClient.js.map
|