@nu-art/ts-common 0.200.22 → 0.200.24

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.
Files changed (101) hide show
  1. package/consts/consts.js +0 -1
  2. package/core/application.js +12 -31
  3. package/core/debug-flags.js +32 -38
  4. package/core/dispatcher.js +30 -92
  5. package/core/error-handling.js +1 -2
  6. package/core/exceptions.js +47 -84
  7. package/core/logger/BeLogged.js +19 -26
  8. package/core/logger/LogClient.js +14 -16
  9. package/core/logger/LogClient_BaseRotate.js +20 -42
  10. package/core/logger/LogClient_Browser.js +16 -36
  11. package/core/logger/LogClient_Function.js +14 -34
  12. package/core/logger/LogClient_MemBuffer.js +14 -35
  13. package/core/logger/LogClient_Terminal.js +12 -34
  14. package/core/logger/Logger.js +67 -152
  15. package/core/logger/types.js +0 -1
  16. package/core/logger/utils.js +16 -18
  17. package/core/module-manager.js +33 -61
  18. package/core/module.js +43 -65
  19. package/csv.js +0 -1
  20. package/index.js +0 -1
  21. package/modules/CSVModule.js +50 -110
  22. package/modules/CliParamsModule.js +32 -54
  23. package/modules/csv-serializer.js +10 -22
  24. package/package.json +8 -18
  25. package/permissions/permission-group.js +9 -12
  26. package/test-index.js +0 -1
  27. package/testing/consts.js +18 -54
  28. package/testing/types.js +0 -1
  29. package/tools/Replacer.js +71 -96
  30. package/tools/get-log-style.js +5 -10
  31. package/utils/array-tools.js +63 -127
  32. package/utils/crypto-tools.js +1 -2
  33. package/utils/date-time-tools.js +19 -75
  34. package/utils/db-object-tools.js +0 -1
  35. package/utils/filter-tools.js +37 -43
  36. package/utils/hash-tools.js +4 -8
  37. package/utils/merge-tools.js +4 -5
  38. package/utils/mimetype-tools.js +0 -1
  39. package/utils/number-tools.js +3 -4
  40. package/utils/object-tools.js +16 -20
  41. package/utils/query-params.js +8 -11
  42. package/utils/queue.js +47 -115
  43. package/utils/random-tools.js +2 -3
  44. package/utils/storage-capacity-tools.js +0 -1
  45. package/utils/string-tools.js +16 -18
  46. package/utils/tools.js +11 -42
  47. package/utils/types.js +1 -2
  48. package/utils/ui-tools.js +8 -15
  49. package/utils/version-tools.js +6 -7
  50. package/validator/type-validators.js +65 -84
  51. package/validator/validator-core.js +34 -58
  52. package/consts/consts.js.map +0 -1
  53. package/core/application.js.map +0 -1
  54. package/core/debug-flags.js.map +0 -1
  55. package/core/dispatcher.js.map +0 -1
  56. package/core/error-handling.js.map +0 -1
  57. package/core/exceptions.js.map +0 -1
  58. package/core/logger/BeLogged.js.map +0 -1
  59. package/core/logger/LogClient.js.map +0 -1
  60. package/core/logger/LogClient_BaseRotate.js.map +0 -1
  61. package/core/logger/LogClient_Browser.js.map +0 -1
  62. package/core/logger/LogClient_Function.js.map +0 -1
  63. package/core/logger/LogClient_MemBuffer.js.map +0 -1
  64. package/core/logger/LogClient_Terminal.js.map +0 -1
  65. package/core/logger/Logger.js.map +0 -1
  66. package/core/logger/types.js.map +0 -1
  67. package/core/logger/utils.js.map +0 -1
  68. package/core/module-manager.js.map +0 -1
  69. package/core/module.js.map +0 -1
  70. package/csv.js.map +0 -1
  71. package/index.js.map +0 -1
  72. package/modules/CSVModule.js.map +0 -1
  73. package/modules/CliParamsModule.js.map +0 -1
  74. package/modules/csv-serializer.js.map +0 -1
  75. package/permissions/permission-group.js.map +0 -1
  76. package/test-index.js.map +0 -1
  77. package/testing/consts.js.map +0 -1
  78. package/testing/types.js.map +0 -1
  79. package/tools/Replacer.js.map +0 -1
  80. package/tools/get-log-style.js.map +0 -1
  81. package/utils/array-tools.js.map +0 -1
  82. package/utils/crypto-tools.js.map +0 -1
  83. package/utils/date-time-tools.js.map +0 -1
  84. package/utils/db-object-tools.js.map +0 -1
  85. package/utils/filter-tools.js.map +0 -1
  86. package/utils/hash-tools.js.map +0 -1
  87. package/utils/merge-tools.js.map +0 -1
  88. package/utils/mimetype-tools.js.map +0 -1
  89. package/utils/number-tools.js.map +0 -1
  90. package/utils/object-tools.js.map +0 -1
  91. package/utils/query-params.js.map +0 -1
  92. package/utils/queue.js.map +0 -1
  93. package/utils/random-tools.js.map +0 -1
  94. package/utils/storage-capacity-tools.js.map +0 -1
  95. package/utils/string-tools.js.map +0 -1
  96. package/utils/tools.js.map +0 -1
  97. package/utils/types.js.map +0 -1
  98. package/utils/ui-tools.js.map +0 -1
  99. package/utils/version-tools.js.map +0 -1
  100. package/validator/type-validators.js.map +0 -1
  101. package/validator/validator-core.js.map +0 -1
@@ -16,79 +16,57 @@
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.CliParamsModule = void 0;
36
- var module_1 = require("../core/module");
37
- var exceptions_1 = require("../core/exceptions");
38
- var __1 = require("..");
39
- var CliParamsModule_Class = /** @class */ (function (_super) {
40
- __extends(CliParamsModule_Class, _super);
41
- function CliParamsModule_Class() {
42
- var _this = _super !== null && _super.apply(this, arguments) || this;
43
- _this.paramsValue = {};
44
- _this.printHowTo = function (params) {
45
- var missingParams = params.filter(function (param) { return !_this.paramsValue[param.keyName] && !param.optional; });
46
- var foundParams = params.filter(function (param) { return _this.paramsValue[param.keyName]; });
47
- _this.printFoundArgs('Found Args', foundParams, _this.paramsValue);
21
+ const module_1 = require("../core/module");
22
+ const exceptions_1 = require("../core/exceptions");
23
+ const __1 = require("..");
24
+ class CliParamsModule_Class extends module_1.Module {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.paramsValue = {};
28
+ this.printHowTo = (params) => {
29
+ const missingParams = params.filter((param) => !this.paramsValue[param.keyName] && !param.optional);
30
+ const foundParams = params.filter((param) => this.paramsValue[param.keyName]);
31
+ this.printFoundArgs('Found Args', foundParams, this.paramsValue);
48
32
  if (missingParams.length === 0)
49
33
  return;
50
- _this.printFoundArgs('Missing Args', missingParams, _this.paramsValue);
34
+ this.printFoundArgs('Missing Args', missingParams, this.paramsValue);
51
35
  throw new exceptions_1.ImplementationMissingException('Missing cli params');
52
36
  };
53
- _this.getParams = function () {
54
- return _this.paramsValue;
37
+ this.getParams = () => {
38
+ return this.paramsValue;
55
39
  };
56
- return _this;
57
40
  }
58
- CliParamsModule_Class.prototype.init = function () {
59
- var _this = this;
60
- this.config.params.forEach(function (param) { return _this.paramsValue[param.keyName] = _this.getParam(param); });
41
+ init() {
42
+ this.config.params.forEach((param) => this.paramsValue[param.keyName] = this.getParam(param));
61
43
  this.printHowTo(this.config.params);
62
44
  return this.paramsValue;
63
- };
64
- CliParamsModule_Class.prototype.getParam = function (param, args) {
65
- if (args === void 0) { args = process.argv.slice(2, process.argv.length); }
66
- if (!this.config.params.find(function (_param) { return _param.keyName === param.keyName; }))
45
+ }
46
+ getParam(param, args = process.argv.slice(2, process.argv.length)) {
47
+ if (!this.config.params.find(_param => _param.keyName === param.keyName))
67
48
  throw new exceptions_1.BadImplementationException('Requested not existing param');
68
- var value = this.extractParam(param, args);
49
+ let value = this.extractParam(param, args);
69
50
  if (!value)
70
51
  value = param.defaultValue;
71
52
  if (!value)
72
53
  return value;
73
54
  return (param.process ? param.process(value) : value);
74
- };
75
- CliParamsModule_Class.prototype.extractParam = function (param, argv) {
55
+ }
56
+ extractParam(param, argv) {
76
57
  if (param.isArray)
77
- return param.keys.reduce(function (values, key) {
78
- values.push.apply(values, (0, __1.filterInstances)(argv.map(function (arg) { var _a; return (_a = arg.match(new RegExp("".concat(key, "=(.*)")))) === null || _a === void 0 ? void 0 : _a[1]; })));
58
+ return param.keys.reduce((values, key) => {
59
+ values.push(...(0, __1.filterInstances)(argv.map(arg => { var _a; return (_a = arg.match(new RegExp(`${key}=(.*)`))) === null || _a === void 0 ? void 0 : _a[1]; })));
79
60
  return values;
80
61
  }, []);
81
- var find = param.keys.map(function (key) { return argv.map(function (arg) { var _a; return (_a = arg.match(new RegExp("".concat(key, "=(.*)")))) === null || _a === void 0 ? void 0 : _a[1]; }); });
82
- return (0, __1.flatArray)(find).find(function (k) { return k; });
83
- };
84
- CliParamsModule_Class.prototype.printFoundArgs = function (title, params, foundArgs) {
85
- var _this = this;
62
+ const find = param.keys.map(key => argv.map(arg => { var _a; return (_a = arg.match(new RegExp(`${key}=(.*)`))) === null || _a === void 0 ? void 0 : _a[1]; }));
63
+ return (0, __1.flatArray)(find).find(k => k);
64
+ }
65
+ printFoundArgs(title, params, foundArgs) {
86
66
  if (params.length)
87
67
  return;
88
- this.logInfoBold(" ".concat(title, ":"));
89
- params.forEach(function (param) { return _this.logInfo(" ".concat(param.keys[0], "=").concat(foundArgs[param.keyName] || "<".concat(param.name, ">"))); });
90
- };
91
- return CliParamsModule_Class;
92
- }(module_1.Module));
68
+ this.logInfoBold(` ${title}:`);
69
+ params.forEach((param) => this.logInfo(` ${param.keys[0]}=${foundArgs[param.keyName] || `<${param.name}>`}`));
70
+ }
71
+ }
93
72
  exports.CliParamsModule = new CliParamsModule_Class();
94
- //# sourceMappingURL=CliParamsModule.js.map
@@ -16,35 +16,23 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- var __assign = (this && this.__assign) || function () {
20
- __assign = Object.assign || function(t) {
21
- for (var s, i = 1, n = arguments.length; i < n; i++) {
22
- s = arguments[i];
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
24
- t[p] = s[p];
25
- }
26
- return t;
27
- };
28
- return __assign.apply(this, arguments);
29
- };
30
19
  Object.defineProperty(exports, "__esModule", { value: true });
31
20
  exports.csvSerializer = void 0;
32
21
  function csvSerializer(items, _csvProps) {
33
- var csvProps = __assign({ decimalSeparator: '.', withHeaders: true, fieldWrapper: '"', lineSeparator: '\n', fieldSeparator: ',', columnNames: function (k) { return k.toString(); } }, _csvProps);
22
+ const csvProps = Object.assign({ decimalSeparator: '.', withHeaders: true, fieldWrapper: '"', lineSeparator: '\n', fieldSeparator: ',', columnNames: (k) => k.toString() }, _csvProps);
34
23
  function processValue(value) {
35
- var escapedValue = (value.toString() || '').replace(csvProps.fieldWrapper, "\\".concat(csvProps.fieldWrapper));
24
+ let escapedValue = (value.toString() || '').replace(csvProps.fieldWrapper, `\\${csvProps.fieldWrapper}`);
36
25
  if (escapedValue.includes(csvProps.lineSeparator) || escapedValue.includes(csvProps.fieldSeparator))
37
- escapedValue = "".concat(csvProps.fieldWrapper).concat(escapedValue).concat(csvProps.fieldWrapper);
38
- return "".concat(escapedValue).concat(csvProps.fieldSeparator);
26
+ escapedValue = `${csvProps.fieldWrapper}${escapedValue}${csvProps.fieldWrapper}`;
27
+ return `${escapedValue}${csvProps.fieldSeparator}`;
39
28
  }
40
- var outputRows = [];
41
- var columnsByOrder = csvProps.columns.map(function (c) { return c.toString(); });
42
- var headersLine = columnsByOrder.reduce(function (output, header) { return "".concat(output).concat(processValue(csvProps.columnNames(header))); }, '').slice(0, -1);
29
+ const outputRows = [];
30
+ const columnsByOrder = csvProps.columns.map(c => c.toString());
31
+ const headersLine = columnsByOrder.reduce((output, header) => `${output}${processValue(csvProps.columnNames(header))}`, '').slice(0, -1);
43
32
  if (csvProps.withHeaders)
44
33
  outputRows.push(headersLine);
45
- var rowsData = items.map(function (row) { return columnsByOrder.reduce(function (output, header) { return "".concat(output).concat(processValue(row[header])); }, '').slice(0, -1); });
46
- outputRows.push.apply(outputRows, rowsData);
47
- return outputRows.reduce(function (content, row) { return "".concat(content).concat(row).concat(csvProps.lineSeparator); }, '').slice(0, -1);
34
+ const rowsData = items.map((row) => columnsByOrder.reduce((output, header) => `${output}${processValue(row[header])}`, '').slice(0, -1));
35
+ outputRows.push(...rowsData);
36
+ return outputRows.reduce((content, row) => `${content}${row}${csvProps.lineSeparator}`, '').slice(0, -1);
48
37
  }
49
38
  exports.csvSerializer = csvSerializer;
50
- //# sourceMappingURL=csv-serializer.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-common",
3
- "version": "0.200.22",
3
+ "version": "0.200.24",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -18,6 +18,10 @@
18
18
  "type": "git",
19
19
  "url": "git+ssh://git@github.com:nu-art-js/ts-common.git"
20
20
  },
21
+ "publishConfig": {
22
+ "directory": "dist",
23
+ "linkDirectory": true
24
+ },
21
25
  "license": "Apache-2.0",
22
26
  "author": "TacB0sS",
23
27
  "main": "index.js",
@@ -31,26 +35,12 @@
31
35
  "export-to-csv": "^0.2.1",
32
36
  "moment": "^2.24.0",
33
37
  "node-forge": "^1.2.1",
34
- "uuid": "^9.0.0"
38
+ "uuid": "^9.0.0",
39
+ "csv-parser": "^2.3.3"
35
40
  },
36
41
  "devDependencies": {
37
- "@types/chai": "^4.3.4",
38
- "@types/chai-as-promised": "^7.1.5",
39
42
  "@types/minimatch": "^5.1.2",
40
- "@types/mocha": "^10.0.1",
41
- "@types/node-forge": "^1.0.0",
42
- "@typescript-eslint/eslint-plugin": "^5.8.0",
43
- "chai": "^4.3.7",
44
- "chai-as-promised": "^7.1.1",
45
- "csv-parser": "^2.3.3",
46
- "eslint": "^6.8.0",
47
- "mocha": "^10.2.0",
48
- "ts-mocha": "^10.0.0",
49
- "ts-node": "^8.6.2",
50
- "tsdoc": "^0.0.4",
51
- "typedoc": "^0.22.18",
52
- "typedoc-theme-yaf": "^0.0.3",
53
- "typescript": "^4.5.0"
43
+ "@types/node-forge": "^1.0.0"
54
44
  },
55
45
  "_moduleAliases": {
56
46
  "@main": "dist/main/ts",
@@ -18,20 +18,17 @@ exports.PermissionCategory = void 0;
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
20
  */
21
- var index_1 = require("../index");
22
- var PermissionCategory = /** @class */ (function () {
23
- function PermissionCategory(key, permissionsEnum, defaultValue) {
21
+ const index_1 = require("../index");
22
+ class PermissionCategory {
23
+ constructor(key, permissionsEnum, defaultValue) {
24
24
  this.key = key;
25
25
  this.permissionsEnum = permissionsEnum;
26
26
  this.defaultValue = defaultValue;
27
- var _levels = Object.keys(permissionsEnum).filter(function (value) { return isNaN(parseInt(value)); });
28
- this.levels = (0, index_1.sortArray)(_levels, function (_key) { return permissionsEnum[_key]; }).reverse();
27
+ const _levels = Object.keys(permissionsEnum).filter(value => isNaN(parseInt(value)));
28
+ this.levels = (0, index_1.sortArray)(_levels, (_key) => permissionsEnum[_key]).reverse();
29
29
  }
30
- PermissionCategory.prototype.getClosestMatch = function (permission) {
31
- var _this = this;
32
- return (0, index_1.deepClone)(this.levels).reverse().find((function (level) { return _this.permissionsEnum[level] <= permission; }));
33
- };
34
- return PermissionCategory;
35
- }());
30
+ getClosestMatch(permission) {
31
+ return (0, index_1.deepClone)(this.levels).reverse().find(((level) => this.permissionsEnum[level] <= permission));
32
+ }
33
+ }
36
34
  exports.PermissionCategory = PermissionCategory;
37
- //# sourceMappingURL=permission-group.js.map
package/test-index.js CHANGED
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./testing/types"), exports);
18
18
  __exportStar(require("./testing/consts"), exports);
19
- //# sourceMappingURL=test-index.js.map
package/testing/consts.js CHANGED
@@ -8,67 +8,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.expectFailAsync = exports.testSuiteTester = void 0;
40
- var chai_1 = require("chai");
41
- var __1 = require("..");
42
- var testSuiteTester = function (testSuit) {
43
- describe(testSuit.label, function () {
13
+ const chai_1 = require("chai");
14
+ const __1 = require("..");
15
+ const testSuiteTester = (testSuit) => {
16
+ describe(testSuit.label, () => {
44
17
  //Run pre-process
45
18
  if (testSuit.preProcessor) {
46
- it("".concat(testSuit.label, " - Preprocessing"), testSuit.preProcessor);
19
+ it(`${testSuit.label} - Preprocessing`, testSuit.preProcessor);
47
20
  }
48
- testSuit.testcases.forEach(function (testCase) {
49
- it(testCase.description, function () { return testSuit.processor(testCase); });
21
+ testSuit.testcases.forEach(testCase => {
22
+ it(testCase.description, () => testSuit.processor(testCase));
50
23
  });
51
24
  });
52
25
  };
53
26
  exports.testSuiteTester = testSuiteTester;
54
- var expectFailAsync = function (action) { return __awaiter(void 0, void 0, void 0, function () {
55
- var e_1;
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
58
- case 0:
59
- _a.trys.push([0, 2, , 3]);
60
- return [4 /*yield*/, action()];
61
- case 1:
62
- _a.sent();
63
- return [2 /*return*/, (0, chai_1.expect)(__1.voidFunction)];
64
- case 2:
65
- e_1 = _a.sent();
66
- return [2 /*return*/, (0, chai_1.expect)(function () {
67
- throw e_1;
68
- })];
69
- case 3: return [2 /*return*/];
70
- }
71
- });
72
- }); };
27
+ const expectFailAsync = (action) => __awaiter(void 0, void 0, void 0, function* () {
28
+ try {
29
+ yield action();
30
+ return (0, chai_1.expect)(__1.voidFunction);
31
+ }
32
+ catch (e) {
33
+ return (0, chai_1.expect)(() => {
34
+ throw e;
35
+ });
36
+ }
37
+ });
73
38
  exports.expectFailAsync = expectFailAsync;
74
- //# sourceMappingURL=consts.js.map
package/testing/types.js CHANGED
@@ -17,4 +17,3 @@
17
17
  * limitations under the License.
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- //# sourceMappingURL=types.js.map
package/tools/Replacer.js CHANGED
@@ -16,119 +16,96 @@
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.Replacer = void 0;
36
- var Logger_1 = require("../core/logger/Logger");
37
- var validator_core_1 = require("../validator/validator-core");
38
- var Replacer = /** @class */ (function (_super) {
39
- __extends(Replacer, _super);
40
- function Replacer() {
41
- var _this = _super.call(this) || this;
42
- _this.strictMode = true;
43
- _this.input = {};
44
- _this.aliases = [];
45
- return _this;
21
+ const Logger_1 = require("../core/logger/Logger");
22
+ const validator_core_1 = require("../validator/validator-core");
23
+ class Replacer extends Logger_1.Logger {
24
+ constructor() {
25
+ super();
26
+ this.strictMode = true;
27
+ this.input = {};
28
+ this.aliases = [];
46
29
  // this.setMinLevel(LogLevel.Error);
47
30
  }
48
- Replacer.prototype.setFallbackReplacer = function (fallbackReplacer) {
31
+ setFallbackReplacer(fallbackReplacer) {
49
32
  this.fallbackReplacer = fallbackReplacer;
50
33
  return this;
51
- };
52
- Replacer.prototype.setNotStrict = function () {
34
+ }
35
+ setNotStrict() {
53
36
  this.strictMode = false;
54
37
  return this;
55
- };
56
- Replacer.prototype.getInput = function () {
38
+ }
39
+ getInput() {
57
40
  return this.input;
58
- };
59
- Replacer.prototype.setInput = function (input, aliases) {
60
- if (aliases === void 0) { aliases = []; }
41
+ }
42
+ setInput(input, aliases = []) {
61
43
  this.input = input;
62
44
  this.aliases = aliases;
63
45
  return this;
64
- };
65
- Replacer.prototype.replace = function (_content, runtime) {
66
- if (_content === void 0) { _content = ''; }
67
- var content = this.replaceLoops(_content, runtime);
46
+ }
47
+ replace(_content = '', runtime) {
48
+ let content = this.replaceLoops(_content, runtime);
68
49
  content = this.replaceParams(content, runtime);
69
50
  if (_content !== content)
70
51
  content = this.replace(content, runtime);
71
52
  return content;
72
- };
73
- Replacer.prototype.replaceParams = function (content, runtime) {
74
- var _this = this;
75
- if (content === void 0) { content = ''; }
76
- var matches = content.match(Replacer.Regexp_paramGroup);
77
- return (matches === null || matches === void 0 ? void 0 : matches.reduce(function (toRet, match) {
53
+ }
54
+ replaceParams(content = '', runtime) {
55
+ const matches = content.match(Replacer.Regexp_paramGroup);
56
+ return (matches === null || matches === void 0 ? void 0 : matches.reduce((toRet, match) => {
78
57
  var _a;
79
- var param = match;
58
+ let param = match;
80
59
  while (Replacer.Regexp_param.test(param))
81
60
  param = (_a = param.match(Replacer.Regexp_param)) === null || _a === void 0 ? void 0 : _a[1];
82
61
  if (param === undefined)
83
62
  return toRet;
84
- var value = _this.resolveParam(param, toRet, runtime);
63
+ const value = this.resolveParam(param, toRet, runtime);
85
64
  return toRet.replace(match, value);
86
65
  }, content)) || content;
87
- };
88
- Replacer.prototype.resolveParam = function (param, toRet, runtime) {
89
- var value = this.resolveParamValue(param, runtime);
66
+ }
67
+ resolveParam(param, toRet, runtime) {
68
+ const value = this.resolveParamValue(param, runtime);
90
69
  if (this.fallbackReplacer && (value === undefined || value === ''))
91
70
  return this.fallbackReplacer.resolveParam(param, toRet, runtime);
92
71
  return value;
93
- };
94
- Replacer.prototype.replaceLoops = function (content, runtime) {
95
- var _this = this;
96
- if (content === void 0) { content = ''; }
97
- var matches = content.match(Replacer.Regexp_forLoopGroupStart);
98
- return (matches === null || matches === void 0 ? void 0 : matches.reduce(function (toRet, match) {
99
- var varsMatch = match.match(Replacer.Regexp_forLoopParam);
100
- var string = varsMatch[0];
101
- var iterable = varsMatch[1];
102
- var iterator = varsMatch[2];
103
- var endMatch = "{{/foreach ".concat(iterator, "}}");
104
- var indexOfEnd = toRet.indexOf(endMatch);
105
- var fullOriginLoopText = toRet.substring(toRet.indexOf(string), indexOfEnd + endMatch.length);
106
- var loopText = toRet.substring(toRet.indexOf(string) + string.length, indexOfEnd);
107
- _this.logDebug("indexOfEnd: ".concat(endMatch, " ").concat(indexOfEnd));
108
- _this.logDebug("string: ".concat(string, " ").concat(toRet.indexOf(string)));
109
- _this.logDebug("iterable: ".concat(iterable));
110
- _this.logDebug("iterator: ".concat(iterator));
111
- _this.logDebug("loopText: ".concat(loopText));
112
- var loopArray;
113
- var iterableProp = "".concat(iterator);
72
+ }
73
+ replaceLoops(content = '', runtime) {
74
+ const matches = content.match(Replacer.Regexp_forLoopGroupStart);
75
+ return (matches === null || matches === void 0 ? void 0 : matches.reduce((toRet, match) => {
76
+ const varsMatch = match.match(Replacer.Regexp_forLoopParam);
77
+ const string = varsMatch[0];
78
+ const iterable = varsMatch[1];
79
+ const iterator = varsMatch[2];
80
+ const endMatch = `{{/foreach ${iterator}}}`;
81
+ const indexOfEnd = toRet.indexOf(endMatch);
82
+ const fullOriginLoopText = toRet.substring(toRet.indexOf(string), indexOfEnd + endMatch.length);
83
+ const loopText = toRet.substring(toRet.indexOf(string) + string.length, indexOfEnd);
84
+ this.logDebug(`indexOfEnd: ${endMatch} ${indexOfEnd}`);
85
+ this.logDebug(`string: ${string} ${toRet.indexOf(string)}`);
86
+ this.logDebug(`iterable: ${iterable}`);
87
+ this.logDebug(`iterator: ${iterator}`);
88
+ this.logDebug(`loopText: ${loopText}`);
89
+ let loopArray;
90
+ const iterableProp = `${iterator}`;
114
91
  try {
115
- loopArray = _this.resolveParamValue(iterableProp, runtime);
92
+ loopArray = this.resolveParamValue(iterableProp, runtime);
116
93
  }
117
94
  catch (e) {
118
- throw new validator_core_1.ValidationException("Error while looping on variable for parts: ", iterableProp, _this.input, e);
95
+ throw new validator_core_1.ValidationException(`Error while looping on variable for parts: `, iterableProp, this.input, e);
119
96
  }
120
97
  if (!Array.isArray(loopArray))
121
- _this.logWarning("Loop object is not an array.. found:", loopArray);
122
- var replacement = loopArray.reduce(function (_toRet, value) {
123
- return _toRet + _this.replace(loopText, { property: value });
98
+ this.logWarning(`Loop object is not an array.. found:`, loopArray);
99
+ const replacement = loopArray.reduce((_toRet, value) => {
100
+ return _toRet + this.replace(loopText, { property: value });
124
101
  }, '');
125
- var s = toRet.replace(fullOriginLoopText, replacement);
102
+ const s = toRet.replace(fullOriginLoopText, replacement);
126
103
  return s;
127
104
  }, content)) || content;
128
- };
129
- Replacer.prototype.resolveParamValue = function (_param, runtime) {
130
- var param = _param;
131
- var alias = this.aliases.find(function (alias) { return alias.key === param; });
105
+ }
106
+ resolveParamValue(_param, runtime) {
107
+ let param = _param;
108
+ const alias = this.aliases.find(alias => alias.key === param);
132
109
  if (alias) {
133
110
  this.logInfo('using alias: ', alias);
134
111
  param = alias.value || param;
@@ -137,36 +114,34 @@ var Replacer = /** @class */ (function (_super) {
137
114
  if (param.endsWith('.'))
138
115
  param = param.substring(0, param.length - 1);
139
116
  if (param.startsWith(Replacer.Indicator_RuntimeParam))
140
- param = "".concat(Replacer.RuntimeParam, ".").concat(param.substring(Replacer.Indicator_RuntimeParam.length));
141
- var parts = param.split('\.');
142
- var value;
117
+ param = `${Replacer.RuntimeParam}.${param.substring(Replacer.Indicator_RuntimeParam.length)}`;
118
+ const parts = param.split('\.');
119
+ let value;
143
120
  try {
144
121
  if (runtime)
145
- value = parts.reduce(function (value, key) { return value === null || value === void 0 ? void 0 : value[key]; }, runtime);
122
+ value = parts.reduce((value, key) => value === null || value === void 0 ? void 0 : value[key], runtime);
146
123
  if (value === undefined)
147
- value = parts.reduce(function (value, key) { return value[key]; }, this.input);
124
+ value = parts.reduce((value, key) => value[key], this.input);
148
125
  }
149
126
  catch (e) {
150
127
  this.logWarning('input', this.input);
151
- throw new validator_core_1.ValidationException("Error while resolving runtime variable for parts ".concat(param), param, this.input, e);
128
+ throw new validator_core_1.ValidationException(`Error while resolving runtime variable for parts ${param}`, param, this.input, e);
152
129
  }
153
130
  if (value === undefined) {
154
131
  this.logWarning('input', this.input);
155
132
  if (this.strictMode)
156
- throw new validator_core_1.ValidationException("Cannot resolve runtime variable for parts ".concat(param), param, this.input);
133
+ throw new validator_core_1.ValidationException(`Cannot resolve runtime variable for parts ${param}`, param, this.input);
157
134
  }
158
135
  return value;
159
136
  // this.logDebug(`Input:`, this.input);
160
137
  // this.logDebug(`Param: ${param}`, 'Parts: ', parts);
161
138
  // this.logDebug(value);
162
- };
163
- Replacer.RuntimeParam = '__runtime';
164
- Replacer.Indicator_RuntimeParam = '__';
165
- Replacer.Regexp_paramGroup = /\$\{(\{?.*?\}?)\}/g;
166
- Replacer.Regexp_param = /\$\{(\{?.*?\}?)\}/;
167
- Replacer.Regexp_forLoopGroupStart = /\{\{foreach (.*?) in (.*?)\}\}/g;
168
- Replacer.Regexp_forLoopParam = /\{\{foreach (.*?) in (.*?)\}\}/;
169
- return Replacer;
170
- }(Logger_1.Logger));
139
+ }
140
+ }
141
+ Replacer.RuntimeParam = '__runtime';
142
+ Replacer.Indicator_RuntimeParam = '__';
143
+ Replacer.Regexp_paramGroup = /\$\{(\{?.*?\}?)\}/g;
144
+ Replacer.Regexp_param = /\$\{(\{?.*?\}?)\}/;
145
+ Replacer.Regexp_forLoopGroupStart = /\{\{foreach (.*?) in (.*?)\}\}/g;
146
+ Replacer.Regexp_forLoopParam = /\{\{foreach (.*?) in (.*?)\}\}/;
171
147
  exports.Replacer = Replacer;
172
- //# sourceMappingURL=Replacer.js.map
@@ -18,7 +18,7 @@
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.getLogStyle = void 0;
21
- var object_tools_1 = require("../utils/object-tools");
21
+ const object_tools_1 = require("../utils/object-tools");
22
22
  /**
23
23
  * Returns a style string for console.log()
24
24
  * To log with style, make sure to add '%c' at the start of the log.
@@ -26,18 +26,13 @@ var object_tools_1 = require("../utils/object-tools");
26
26
  *
27
27
  * @param styleObj - one or more style objects defining the log style
28
28
  */
29
- function getLogStyle() {
30
- var styleObj = [];
31
- for (var _i = 0; _i < arguments.length; _i++) {
32
- styleObj[_i] = arguments[_i];
33
- }
34
- var style = '';
35
- styleObj.forEach(function (obj) {
36
- var _arr = (0, object_tools_1._keys)(obj).map(function (key) { return "".concat(key, ": ").concat(obj[key]); });
29
+ function getLogStyle(...styleObj) {
30
+ let style = '';
31
+ styleObj.forEach(obj => {
32
+ const _arr = (0, object_tools_1._keys)(obj).map(key => `${key}: ${obj[key]}`);
37
33
  style += _arr.join(';');
38
34
  style += ';';
39
35
  });
40
36
  return style;
41
37
  }
42
38
  exports.getLogStyle = getLogStyle;
43
- //# sourceMappingURL=get-log-style.js.map