@nu-art/ts-common 0.105.0 → 0.105.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/consts/consts.d.ts +1 -0
  2. package/consts/consts.js +22 -0
  3. package/consts/consts.js.map +1 -0
  4. package/core/application.d.ts +5 -0
  5. package/core/application.js +55 -0
  6. package/core/application.js.map +1 -0
  7. package/core/debug-flags.d.ts +25 -0
  8. package/core/debug-flags.js +87 -0
  9. package/core/debug-flags.js.map +1 -0
  10. package/core/dispatcher.d.ts +18 -0
  11. package/core/dispatcher.js +132 -0
  12. package/core/dispatcher.js.map +1 -0
  13. package/core/error-handling.d.ts +14 -0
  14. package/core/error-handling.js +38 -0
  15. package/core/error-handling.js.map +1 -0
  16. package/core/exceptions.d.ts +118 -0
  17. package/core/exceptions.js +214 -0
  18. package/core/exceptions.js.map +1 -0
  19. package/core/logger/BeLogged.d.ts +14 -0
  20. package/core/logger/BeLogged.js +61 -0
  21. package/core/logger/BeLogged.js.map +1 -0
  22. package/core/logger/LogClient.d.ts +14 -0
  23. package/core/logger/LogClient.js +67 -0
  24. package/core/logger/LogClient.js.map +1 -0
  25. package/core/logger/LogClient_BaseRotate.d.ts +19 -0
  26. package/core/logger/LogClient_BaseRotate.js +80 -0
  27. package/core/logger/LogClient_BaseRotate.js.map +1 -0
  28. package/core/logger/LogClient_Browser.d.ts +9 -0
  29. package/core/logger/LogClient_Browser.js +101 -0
  30. package/core/logger/LogClient_Browser.js.map +1 -0
  31. package/core/logger/LogClient_Function.d.ts +8 -0
  32. package/core/logger/LogClient_Function.js +75 -0
  33. package/core/logger/LogClient_Function.js.map +1 -0
  34. package/core/logger/LogClient_MemBuffer.d.ts +9 -0
  35. package/core/logger/LogClient_MemBuffer.js +61 -0
  36. package/core/logger/LogClient_MemBuffer.js.map +1 -0
  37. package/core/logger/LogClient_Terminal.d.ts +9 -0
  38. package/core/logger/LogClient_Terminal.js +75 -0
  39. package/core/logger/LogClient_Terminal.js.map +1 -0
  40. package/core/logger/Logger.d.ts +38 -0
  41. package/core/logger/Logger.js +216 -0
  42. package/core/logger/Logger.js.map +1 -0
  43. package/core/logger/types.d.ts +10 -0
  44. package/core/logger/types.js +36 -0
  45. package/core/logger/types.js.map +1 -0
  46. package/core/logger/utils.d.ts +5 -0
  47. package/core/logger/utils.js +80 -0
  48. package/core/logger/utils.js.map +1 -0
  49. package/core/module-manager.d.ts +18 -0
  50. package/core/module-manager.js +112 -0
  51. package/core/module-manager.js.map +1 -0
  52. package/core/module.d.ts +32 -0
  53. package/core/module.js +126 -0
  54. package/core/module.js.map +1 -0
  55. package/csv.d.ts +1 -0
  56. package/csv.js +35 -0
  57. package/csv.js.map +1 -0
  58. package/index.d.ts +43 -0
  59. package/index.js +77 -0
  60. package/index.js.map +1 -0
  61. package/modules/CSVModule.d.ts +32 -0
  62. package/modules/CSVModule.js +165 -0
  63. package/modules/CSVModule.js.map +1 -0
  64. package/modules/CliParamsModule.d.ts +27 -0
  65. package/modules/CliParamsModule.js +94 -0
  66. package/modules/CliParamsModule.js.map +1 -0
  67. package/modules/csv-serializer.d.ts +11 -0
  68. package/modules/csv-serializer.js +50 -0
  69. package/modules/csv-serializer.js.map +1 -0
  70. package/package.json +3 -6
  71. package/permissions/permission-group.d.ts +8 -0
  72. package/permissions/permission-group.js +37 -0
  73. package/permissions/permission-group.js.map +1 -0
  74. package/test-index.d.ts +2 -0
  75. package/test-index.js +19 -0
  76. package/test-index.js.map +1 -0
  77. package/testing/consts.d.ts +5 -0
  78. package/testing/consts.js +74 -0
  79. package/testing/consts.js.map +1 -0
  80. package/testing/types.d.ts +16 -0
  81. package/testing/types.js +20 -0
  82. package/testing/types.js.map +1 -0
  83. package/tools/Replacer.d.ts +24 -0
  84. package/tools/Replacer.js +172 -0
  85. package/tools/Replacer.js.map +1 -0
  86. package/tools/get-log-style.d.ts +14 -0
  87. package/tools/get-log-style.js +43 -0
  88. package/tools/get-log-style.js.map +1 -0
  89. package/utils/array-tools.d.ts +85 -0
  90. package/utils/array-tools.js +302 -0
  91. package/utils/array-tools.js.map +1 -0
  92. package/utils/crypto-tools.d.ts +4 -0
  93. package/utils/crypto-tools.js +36 -0
  94. package/utils/crypto-tools.js.map +1 -0
  95. package/utils/date-time-tools.d.ts +28 -0
  96. package/utils/date-time-tools.js +180 -0
  97. package/utils/date-time-tools.js.map +1 -0
  98. package/utils/db-object-tools.d.ts +3 -0
  99. package/utils/db-object-tools.js +9 -0
  100. package/utils/db-object-tools.js.map +1 -0
  101. package/utils/filter-tools.d.ts +137 -0
  102. package/utils/filter-tools.js +217 -0
  103. package/utils/filter-tools.js.map +1 -0
  104. package/utils/hash-tools.d.ts +8 -0
  105. package/utils/hash-tools.js +60 -0
  106. package/utils/hash-tools.js.map +1 -0
  107. package/utils/merge-tools.d.ts +3 -0
  108. package/utils/merge-tools.js +71 -0
  109. package/utils/merge-tools.js.map +1 -0
  110. package/utils/mimetype-tools.d.ts +8 -0
  111. package/utils/mimetype-tools.js +29 -0
  112. package/utils/mimetype-tools.js.map +1 -0
  113. package/utils/number-tools.d.ts +1 -0
  114. package/utils/number-tools.js +26 -0
  115. package/utils/number-tools.js.map +1 -0
  116. package/utils/object-tools.d.ts +13 -0
  117. package/utils/object-tools.js +129 -0
  118. package/utils/object-tools.js.map +1 -0
  119. package/utils/query-params.d.ts +5 -0
  120. package/utils/query-params.js +24 -0
  121. package/utils/query-params.js.map +1 -0
  122. package/utils/queue.d.ts +16 -0
  123. package/utils/queue.js +166 -0
  124. package/utils/queue.js.map +1 -0
  125. package/utils/random-tools.d.ts +2 -0
  126. package/utils/random-tools.js +35 -0
  127. package/utils/random-tools.js.map +1 -0
  128. package/utils/storage-capacity-tools.d.ts +6 -0
  129. package/utils/storage-capacity-tools.js +27 -0
  130. package/utils/storage-capacity-tools.js.map +1 -0
  131. package/utils/string-tools.d.ts +10 -0
  132. package/utils/string-tools.js +100 -0
  133. package/utils/string-tools.js.map +1 -0
  134. package/utils/tools.d.ts +13 -0
  135. package/utils/tools.js +103 -0
  136. package/utils/tools.js.map +1 -0
  137. package/utils/types.d.ts +92 -0
  138. package/utils/types.js +23 -0
  139. package/utils/types.js.map +1 -0
  140. package/utils/version-tools.d.ts +10 -0
  141. package/utils/version-tools.js +51 -0
  142. package/utils/version-tools.js.map +1 -0
  143. package/validator/type-validators.d.ts +29 -0
  144. package/validator/type-validators.js +211 -0
  145. package/validator/type-validators.js.map +1 -0
  146. package/validator/validator-core.d.ts +36 -0
  147. package/validator/validator-core.js +144 -0
  148. package/validator/validator-core.js.map +1 -0
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Created by tacb0ss on 08/07/2018.
3
+ */
4
+ import { Module } from './module';
5
+ import { Logger } from './logger/Logger';
6
+ export declare function moduleResolver(): Module<any, any>[];
7
+ export declare class ModuleManager extends Logger {
8
+ protected config: any;
9
+ protected modules: Module[];
10
+ static instance: ModuleManager;
11
+ protected constructor();
12
+ filterModules<T>(filter: (module: Module) => boolean): T[];
13
+ setConfig(config: object): this;
14
+ addModules(...modules: Module[]): this;
15
+ setModules(...modules: Module[]): this;
16
+ init(): this;
17
+ build(): void;
18
+ }
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ /*
3
+ * ts-common is the basic building blocks of our typescript projects
4
+ *
5
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
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
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.ModuleManager = exports.moduleResolver = void 0;
36
+ var dispatcher_1 = require("./dispatcher");
37
+ var exceptions_1 = require("./exceptions");
38
+ var Logger_1 = require("./logger/Logger");
39
+ var array_tools_1 = require("../utils/array-tools");
40
+ var _modules = [];
41
+ function moduleResolver() {
42
+ return _modules;
43
+ }
44
+ exports.moduleResolver = moduleResolver;
45
+ var ModuleManager = /** @class */ (function (_super) {
46
+ __extends(ModuleManager, _super);
47
+ // noinspection JSUnusedLocalSymbols
48
+ function ModuleManager() {
49
+ var _this = _super.call(this) || this;
50
+ _this.modules = _modules;
51
+ if (ModuleManager.instance)
52
+ throw new exceptions_1.BadImplementationException('Already have one instance of ModuleManager');
53
+ ModuleManager.instance = _this;
54
+ dispatcher_1.Dispatcher.modulesResolver = moduleResolver;
55
+ return _this;
56
+ }
57
+ ModuleManager.prototype.filterModules = function (filter) {
58
+ return this.modules.filter(filter);
59
+ };
60
+ ModuleManager.prototype.setConfig = function (config) {
61
+ this.config = config || {};
62
+ return this;
63
+ };
64
+ ModuleManager.prototype.addModules = function () {
65
+ var modules = [];
66
+ for (var _i = 0; _i < arguments.length; _i++) {
67
+ modules[_i] = arguments[_i];
68
+ }
69
+ modules.reduce(function (carry, module) {
70
+ if (!carry.includes(module))
71
+ (0, array_tools_1.addItemToArray)(carry, module);
72
+ return carry;
73
+ }, this.modules);
74
+ return this;
75
+ };
76
+ ModuleManager.prototype.setModules = function () {
77
+ var modules = [];
78
+ for (var _i = 0; _i < arguments.length; _i++) {
79
+ modules[_i] = arguments[_i];
80
+ }
81
+ this.modules = (0, array_tools_1.filterDuplicates)(modules);
82
+ return this;
83
+ };
84
+ ModuleManager.prototype.init = function () {
85
+ var _this = this;
86
+ this.logInfo("--------- initializing app ---------");
87
+ this.modules.forEach(function (module) {
88
+ // @ts-ignore
89
+ module.setManager(_this);
90
+ if (_this.config)
91
+ // @ts-ignore
92
+ module.setConfig(_this.config[module.getName()]);
93
+ });
94
+ this.modules.forEach(function (module) {
95
+ _this.logDebug("--------- ".concat(module.getName(), " ---------"));
96
+ // @ts-ignore
97
+ module.init();
98
+ // @ts-ignore
99
+ module.initiated = true;
100
+ });
101
+ // @ts-ignore
102
+ this.modules.forEach(function (module) { return module.validate(); });
103
+ this.logInfo("--------- INITIALIZED ---------");
104
+ return this;
105
+ };
106
+ ModuleManager.prototype.build = function () {
107
+ this.init();
108
+ };
109
+ return ModuleManager;
110
+ }(Logger_1.Logger));
111
+ exports.ModuleManager = ModuleManager;
112
+ //# sourceMappingURL=module-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-manager.js","sourceRoot":"","sources":["../../src/main/core/module-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;;;AAMH,2CAAwC;AACxC,2CAAwD;AACxD,0CAAuC;AACvC,oDAAsE;AAGtE,IAAM,QAAQ,GAAa,EAAE,CAAC;AAE9B,SAAgB,cAAc;IAC7B,OAAO,QAAQ,CAAC;AACjB,CAAC;AAFD,wCAEC;AAED;IACS,iCAAM;IAMd,oCAAoC;IACpC;QAAA,YACC,iBAAO,SAMP;QAXS,aAAO,GAAa,QAAQ,CAAC;QAMtC,IAAI,aAAa,CAAC,QAAQ;YACzB,MAAM,IAAI,uCAA0B,CAAC,4CAA4C,CAAC,CAAC;QAEpF,aAAa,CAAC,QAAQ,GAAG,KAAI,CAAC;QAC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AC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM;YAC1B,KAAI,CAAC,QAAQ,CAAC,qBAAc,MAAM,CAAC,OAAO,EAAE,gBAAa,CAAC,CAAC;YAC3D,aAAa;YACb,MAAM,CAAC,IAAI,EAAE,CAAC;YACd,aAAa;YACb,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,aAAa;QACb,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,QAAQ,EAAE,EAAjB,CAAiB,CAAC,CAAC;QAElD,IAAI,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,6BAAK,GAAL;QACC,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IACF,oBAAC;AAAD,CAAC,AAtED,CACS,eAAM,GAqEd;AAtEY,sCAAa"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Created by tacb0ss on 08/07/2018.
3
+ */
4
+ import { ModuleManager } from './module-manager';
5
+ import { Logger } from './logger/Logger';
6
+ import { LogLevel, TimerHandler, ValidatorTypeResolver } from '..';
7
+ type _FinalConfig<Config = any> = Config & {
8
+ minLogLevel?: LogLevel;
9
+ };
10
+ export declare abstract class Module<Config = any, FinalConfig extends _FinalConfig<Config> = _FinalConfig<Config>> extends Logger {
11
+ private name;
12
+ protected readonly manager: ModuleManager;
13
+ protected readonly initiated = false;
14
+ protected readonly config: FinalConfig;
15
+ protected readonly configValidator?: ValidatorTypeResolver<FinalConfig>;
16
+ protected timeoutMap: {
17
+ [k: string]: number;
18
+ };
19
+ constructor(tag?: string);
20
+ debounce(handler: TimerHandler, key: string, ms?: number): void;
21
+ throttle(handler: TimerHandler, key: string, ms?: number): void;
22
+ setConfigValidator(validator: ValidatorTypeResolver<FinalConfig>): void;
23
+ setDefaultConfig(config: Partial<FinalConfig>): void;
24
+ getName(): string;
25
+ setName(name: string): void;
26
+ private setConfig;
27
+ private setManager;
28
+ protected runAsync: (label: string, toCall: () => Promise<any>) => void;
29
+ protected init(): void;
30
+ protected validate(): void;
31
+ }
32
+ export {};
package/core/module.js ADDED
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ /*
3
+ * ts-common is the basic building blocks of our typescript projects
4
+ *
5
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
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
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.Module = void 0;
36
+ var exceptions_1 = require("./exceptions");
37
+ var merge_tools_1 = require("../utils/merge-tools");
38
+ var Logger_1 = require("./logger/Logger");
39
+ var __1 = require("..");
40
+ var Module = /** @class */ (function (_super) {
41
+ __extends(Module, _super);
42
+ // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
43
+ function Module(tag) {
44
+ var _this = _super.call(this, tag) || this;
45
+ _this.initiated = false;
46
+ _this.config = {};
47
+ _this.timeoutMap = {};
48
+ _this.runAsync = function (label, toCall) {
49
+ setTimeout(function () {
50
+ _this.logDebug("Running async: ".concat(label));
51
+ new Promise(toCall)
52
+ .then(function () {
53
+ _this.logDebug("Async call completed: ".concat(label));
54
+ })
55
+ .catch(function (reason) { return _this.logError("Async call error: ".concat(label), reason); });
56
+ }, 0);
57
+ };
58
+ _this.name = _this.constructor['name'];
59
+ if (!_this.name.endsWith('_Class'))
60
+ throw new exceptions_1.BadImplementationException("Found module named: ".concat(_this.name, ", Module class MUST end with '_Class' e.g. MyModule_Class"));
61
+ _this.name = _this.name.replace('_Class', '');
62
+ return _this;
63
+ }
64
+ Module.prototype.debounce = function (handler, key, ms) {
65
+ if (ms === void 0) { ms = 0; }
66
+ (0, __1._clearTimeout)(this.timeoutMap[key]);
67
+ this.timeoutMap[key] = (0, __1._setTimeout)(handler, ms);
68
+ };
69
+ // // possibly to add
70
+ // public async debounceSync(handler: TimerHandler, key: string, ms = 0) {
71
+ // _clearTimeout(this.timeoutMap[key]);
72
+ //
73
+ // await new Promise((resolve, reject) => {
74
+ // this.timeoutMap[key] = setTimeout(async (..._args) => {
75
+ // try {
76
+ // await handler(..._args);
77
+ // resolve();
78
+ // } catch (e:any) {
79
+ // reject(e);
80
+ // }
81
+ // }, ms) as unknown as number;
82
+ // });
83
+ // }
84
+ Module.prototype.throttle = function (handler, key, ms) {
85
+ var _this = this;
86
+ if (ms === void 0) { ms = 0; }
87
+ if (this.timeoutMap[key])
88
+ return;
89
+ this.timeoutMap[key] = (0, __1._setTimeout)(function () {
90
+ handler();
91
+ delete _this.timeoutMap[key];
92
+ }, ms);
93
+ };
94
+ Module.prototype.setConfigValidator = function (validator) {
95
+ // @ts-ignore
96
+ this.configValidator = validator;
97
+ };
98
+ Module.prototype.setDefaultConfig = function (config) {
99
+ // @ts-ignore
100
+ this.config = (0, merge_tools_1.merge)(this.config, config);
101
+ };
102
+ Module.prototype.getName = function () {
103
+ return this.name;
104
+ };
105
+ Module.prototype.setName = function (name) {
106
+ this.name = name;
107
+ };
108
+ Module.prototype.setConfig = function (config) {
109
+ // @ts-ignore
110
+ this.config = this.config ? (0, merge_tools_1.merge)(this.config, config || {}) : config;
111
+ this.config.minLogLevel && this.setMinLevel(this.config.minLogLevel);
112
+ };
113
+ Module.prototype.setManager = function (manager) {
114
+ // @ts-ignore
115
+ this.manager = manager;
116
+ };
117
+ Module.prototype.init = function () {
118
+ // ignorance is bliss
119
+ };
120
+ Module.prototype.validate = function () {
121
+ // ignorance is bliss
122
+ };
123
+ return Module;
124
+ }(Logger_1.Logger));
125
+ exports.Module = Module;
126
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/main/core/module.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;;;AAOH,2CAAwD;AACxD,oDAA2C;AAC3C,0CAAuC;AACvC,wBAA6F;AAK7F;IACS,0BAAM;IASd,oEAAoE;IACpE,gBAAY,GAAY;QAAxB,YACC,kBAAM,GAAG,CAAC,SAMV;QAbkB,eAAS,GAAG,KAAK,CAAC;QAClB,YAAM,GAAgB,EAAiB,CAAC;QAEjD,gBAAU,GAA4B,EAAE,CAAC;QAuEzC,cAAQ,GAAG,UAAC,KAAa,EAAE,MAA0B;YAC9D,UAAU,CAAC;gBACV,KAAI,CAAC,QAAQ,CAAC,yBAAkB,KAAK,CAAE,CAAC,CAAC;gBACzC,IAAI,OAAO,CAAC,MAAM,CAAC;qBACjB,IAAI,CAAC;oBACL,KAAI,CAAC,QAAQ,CAAC,gCAAyB,KAAK,CAAE,CAAC,CAAC;gBACjD,CAAC,CAAC;qBACD,KAAK,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,QAAQ,CAAC,4BAAqB,KAAK,CAAE,EAAE,MAAM,CAAC,EAAnD,CAAmD,CAA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AzB,UAA0B,SAA6C;QACtE,aAAa;QACb,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;IAClC,CAAC;IAEM,iCAAgB,GAAvB,UAAwB,MAA4B;QACnD,aAAa;QACb,IAAI,CAAC,MAAM,GAAG,IAAA,mBAAK,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEM,wBAAO,GAAd;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,wBAAO,GAAd,UAAe,IAAY;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAEO,0BAAS,GAAjB,UAAkB,MAAmB;QACpC,aAAa;QACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,mBAAK,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACtE,CAAC;IAEO,2BAAU,GAAlB,UAAmB,OAAsB;QACxC,aAAa;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAaS,qBAAI,GAAd;QACC,qBAAqB;IACtB,CAAC;IAES,yBAAQ,GAAlB;QACC,qBAAqB;IACtB,CAAC;IACF,aAAC;AAAD,CAAC,AAjGD,CACS,eAAM,GAgGd;AAjGqB,wBAAM"}
package/csv.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './modules/CSVModule';
package/csv.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * ts-common is the basic building blocks of our typescript projects
4
+ *
5
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }) : (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ o[k2] = m[k];
29
+ }));
30
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
31
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ __exportStar(require("./modules/CSVModule"), exports);
35
+ //# sourceMappingURL=csv.js.map
package/csv.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.js","sourceRoot":"","sources":["../src/main/csv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;AAEH,sDAAoC"}
package/index.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ export * from './core/module';
2
+ export * from './core/module-manager';
3
+ export * from './core/application';
4
+ export * from './core/exceptions';
5
+ export * from './core/dispatcher';
6
+ export * from './core/error-handling';
7
+ export * from './core/debug-flags';
8
+ export * from './core/logger/utils';
9
+ export * from './core/logger/LogClient_BaseRotate';
10
+ export * from './core/logger/LogClient_Terminal';
11
+ export * from './core/logger/LogClient_MemBuffer';
12
+ export * from './core/logger/LogClient_Browser';
13
+ export * from './core/logger/LogClient_Function';
14
+ export * from './core/logger/BeLogged';
15
+ export * from './core/logger/Logger';
16
+ export * from './core/logger/types';
17
+ export * from './core/logger/LogClient';
18
+ export * from './permissions/permission-group';
19
+ export * from './tools/Replacer';
20
+ export * from './tools/get-log-style';
21
+ export * from './utils/queue';
22
+ export * from './utils/types';
23
+ export * from './utils/crypto-tools';
24
+ export * from './utils/random-tools';
25
+ export * from './utils/storage-capacity-tools';
26
+ export * from './utils/mimetype-tools';
27
+ export * from './utils/number-tools';
28
+ export * from './utils/string-tools';
29
+ export * from './utils/date-time-tools';
30
+ export * from './utils/array-tools';
31
+ export * from './utils/object-tools';
32
+ export * from './utils/merge-tools';
33
+ export * from './utils/db-object-tools';
34
+ export * from './utils/version-tools';
35
+ export * from './utils/query-params';
36
+ export * from './utils/tools';
37
+ export * from './utils/hash-tools';
38
+ export * from './utils/filter-tools';
39
+ export * from './validator/validator-core';
40
+ export * from './validator/type-validators';
41
+ export * from './consts/consts';
42
+ export * from './modules/CliParamsModule';
43
+ export * from './modules/csv-serializer';
package/index.js ADDED
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /*
3
+ * ts-common is the basic building blocks of our typescript projects
4
+ *
5
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }) : (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ o[k2] = m[k];
29
+ }));
30
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
31
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ __exportStar(require("./core/module"), exports);
35
+ __exportStar(require("./core/module-manager"), exports);
36
+ __exportStar(require("./core/application"), exports);
37
+ __exportStar(require("./core/exceptions"), exports);
38
+ __exportStar(require("./core/dispatcher"), exports);
39
+ __exportStar(require("./core/error-handling"), exports);
40
+ __exportStar(require("./core/debug-flags"), exports);
41
+ __exportStar(require("./core/logger/utils"), exports);
42
+ __exportStar(require("./core/logger/LogClient_BaseRotate"), exports);
43
+ __exportStar(require("./core/logger/LogClient_Terminal"), exports);
44
+ __exportStar(require("./core/logger/LogClient_MemBuffer"), exports);
45
+ __exportStar(require("./core/logger/LogClient_Browser"), exports);
46
+ __exportStar(require("./core/logger/LogClient_Function"), exports);
47
+ __exportStar(require("./core/logger/BeLogged"), exports);
48
+ __exportStar(require("./core/logger/Logger"), exports);
49
+ __exportStar(require("./core/logger/types"), exports);
50
+ __exportStar(require("./core/logger/LogClient"), exports);
51
+ __exportStar(require("./permissions/permission-group"), exports);
52
+ __exportStar(require("./tools/Replacer"), exports);
53
+ __exportStar(require("./tools/get-log-style"), exports);
54
+ __exportStar(require("./utils/queue"), exports);
55
+ __exportStar(require("./utils/types"), exports);
56
+ __exportStar(require("./utils/crypto-tools"), exports);
57
+ __exportStar(require("./utils/random-tools"), exports);
58
+ __exportStar(require("./utils/storage-capacity-tools"), exports);
59
+ __exportStar(require("./utils/mimetype-tools"), exports);
60
+ __exportStar(require("./utils/number-tools"), exports);
61
+ __exportStar(require("./utils/string-tools"), exports);
62
+ __exportStar(require("./utils/date-time-tools"), exports);
63
+ __exportStar(require("./utils/array-tools"), exports);
64
+ __exportStar(require("./utils/object-tools"), exports);
65
+ __exportStar(require("./utils/merge-tools"), exports);
66
+ __exportStar(require("./utils/db-object-tools"), exports);
67
+ __exportStar(require("./utils/version-tools"), exports);
68
+ __exportStar(require("./utils/query-params"), exports);
69
+ __exportStar(require("./utils/tools"), exports);
70
+ __exportStar(require("./utils/hash-tools"), exports);
71
+ __exportStar(require("./utils/filter-tools"), exports);
72
+ __exportStar(require("./validator/validator-core"), exports);
73
+ __exportStar(require("./validator/type-validators"), exports);
74
+ __exportStar(require("./consts/consts"), exports);
75
+ __exportStar(require("./modules/CliParamsModule"), exports);
76
+ __exportStar(require("./modules/csv-serializer"), exports);
77
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/main/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;AAEH,gDAA8B;AAC9B,wDAAsC;AACtC,qDAAmC;AACnC,oDAAkC;AAClC,oDAAkC;AAClC,wDAAsC;AAEtC,qDAAmC;AACnC,sDAAoC;AACpC,qEAAmD;AACnD,mEAAiD;AACjD,oEAAkD;AAClD,kEAAgD;AAChD,mEAAiD;AACjD,yDAAuC;AACvC,uDAAqC;AACrC,sDAAoC;AACpC,0DAAwC;AAExC,iEAA+C;AAE/C,mDAAiC;AACjC,wDAAsC;AAEtC,gDAA8B;AAC9B,gDAA8B;AAC9B,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,yDAAuC;AACvC,uDAAqC;AACrC,uDAAqC;AACrC,0DAAwC;AACxC,sDAAoC;AACpC,uDAAqC;AACrC,sDAAoC;AACpC,0DAAwC;AACxC,wDAAsC;AACtC,uDAAqC;AACrC,gDAA8B;AAC9B,qDAAmC;AACnC,uDAAqC;AAErC,6DAA2C;AAC3C,8DAA4C;AAE5C,kDAAgC;AAEhC,4DAA0C;AAC1C,2DAAyC"}
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /**
4
+ * Created by tacb0ss on 07/05/2018.
5
+ */
6
+ import { ExportToCsv, Options } from 'export-to-csv';
7
+ import { StringMap, TS_Object } from '../utils/types';
8
+ import { Module } from '../core/module';
9
+ import { Readable } from 'stream';
10
+ type Config = {
11
+ options: Options;
12
+ };
13
+ export type ReadPropsMap<K extends TS_Object = TS_Object> = {
14
+ [s: string]: keyof K;
15
+ };
16
+ export type WritePropsMap<K extends TS_Object = TS_Object> = {
17
+ [P in keyof K]: string;
18
+ };
19
+ declare class CSVModule_Class extends Module<Config> {
20
+ private csvExporter;
21
+ constructor();
22
+ protected init(): void;
23
+ static createExporter(options: Options): ExportToCsv;
24
+ export<T>(items: T[], returnCsv?: boolean): any;
25
+ saveToFile<T extends TS_Object>(outputFile: string, items: T[], columnsToProps?: WritePropsMap<T>): Promise<void>;
26
+ readCsvFromFile<T extends Partial<StringMap>>(inputFile: string, columnsToProps?: ReadPropsMap<T>): Promise<T[]>;
27
+ readCsvFromBuffer<T extends Partial<StringMap>>(buffer: Buffer, columnsToProps?: ReadPropsMap<T>): Promise<T[]>;
28
+ readCsvFromStream<T extends Partial<StringMap>>(stream: Readable, columnsToProps?: ReadPropsMap<T>): Promise<T[]>;
29
+ private createReadParserOptions;
30
+ }
31
+ export declare const CSVModule: CSVModule_Class;
32
+ export {};