@intuitionrobotics/ts-common 0.47.58 → 1.0.0

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 (199) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +3 -0
  3. package/{consts → dist/consts}/consts.d.ts +1 -0
  4. package/dist/consts/consts.d.ts.map +1 -0
  5. package/{consts → dist/consts}/consts.js +1 -4
  6. package/dist/consts/consts.js.map +1 -0
  7. package/{core → dist/core}/application.d.ts +2 -1
  8. package/dist/core/application.d.ts.map +1 -0
  9. package/{core → dist/core}/application.js +10 -12
  10. package/dist/core/application.js.map +1 -0
  11. package/{core → dist/core}/debug-flags.d.ts +1 -0
  12. package/dist/core/debug-flags.d.ts.map +1 -0
  13. package/{core → dist/core}/debug-flags.js +10 -14
  14. package/dist/core/debug-flags.js.map +1 -0
  15. package/{core → dist/core}/dispatcher.d.ts +2 -1
  16. package/dist/core/dispatcher.d.ts.map +1 -0
  17. package/dist/core/dispatcher.js +21 -0
  18. package/dist/core/dispatcher.js.map +1 -0
  19. package/{core → dist/core}/error-handling.d.ts +2 -1
  20. package/dist/core/error-handling.d.ts.map +1 -0
  21. package/dist/core/error-handling.js +18 -0
  22. package/dist/core/error-handling.js.map +1 -0
  23. package/{core → dist/core}/exceptions.d.ts +8 -3
  24. package/dist/core/exceptions.d.ts.map +1 -0
  25. package/{core → dist/core}/exceptions.js +16 -25
  26. package/dist/core/exceptions.js.map +1 -0
  27. package/{core → dist/core}/logger/BeLogged.d.ts +3 -2
  28. package/dist/core/logger/BeLogged.d.ts.map +1 -0
  29. package/{core → dist/core}/logger/BeLogged.js +7 -10
  30. package/dist/core/logger/BeLogged.js.map +1 -0
  31. package/{core → dist/core}/logger/LogClient.d.ts +2 -1
  32. package/dist/core/logger/LogClient.d.ts.map +1 -0
  33. package/{core → dist/core}/logger/LogClient.js +15 -23
  34. package/dist/core/logger/LogClient.js.map +1 -0
  35. package/{core → dist/core}/logger/LogClient_BaseRotate.d.ts +3 -2
  36. package/dist/core/logger/LogClient_BaseRotate.d.ts.map +1 -0
  37. package/{core → dist/core}/logger/LogClient_BaseRotate.js +11 -11
  38. package/dist/core/logger/LogClient_BaseRotate.js.map +1 -0
  39. package/{core → dist/core}/logger/LogClient_Browser.d.ts +4 -3
  40. package/dist/core/logger/LogClient_Browser.d.ts.map +1 -0
  41. package/{core → dist/core}/logger/LogClient_Browser.js +10 -13
  42. package/dist/core/logger/LogClient_Browser.js.map +1 -0
  43. package/{core → dist/core}/logger/LogClient_Function.d.ts +3 -2
  44. package/dist/core/logger/LogClient_Function.d.ts.map +1 -0
  45. package/{core → dist/core}/logger/LogClient_Function.js +7 -9
  46. package/dist/core/logger/LogClient_Function.js.map +1 -0
  47. package/{core → dist/core}/logger/LogClient_MemBuffer.d.ts +2 -1
  48. package/dist/core/logger/LogClient_MemBuffer.d.ts.map +1 -0
  49. package/dist/core/logger/LogClient_MemBuffer.js +19 -0
  50. package/dist/core/logger/LogClient_MemBuffer.js.map +1 -0
  51. package/{core → dist/core}/logger/LogClient_Terminal.d.ts +3 -2
  52. package/dist/core/logger/LogClient_Terminal.d.ts.map +1 -0
  53. package/{core → dist/core}/logger/LogClient_Terminal.js +13 -16
  54. package/dist/core/logger/LogClient_Terminal.js.map +1 -0
  55. package/{core → dist/core}/logger/Logger.d.ts +3 -2
  56. package/dist/core/logger/Logger.d.ts.map +1 -0
  57. package/{core → dist/core}/logger/Logger.js +24 -26
  58. package/dist/core/logger/Logger.js.map +1 -0
  59. package/{core → dist/core}/logger/types.d.ts +1 -0
  60. package/dist/core/logger/types.d.ts.map +1 -0
  61. package/{core → dist/core}/logger/types.js +3 -6
  62. package/dist/core/logger/types.js.map +1 -0
  63. package/{core → dist/core}/logger/utils.d.ts +2 -1
  64. package/dist/core/logger/utils.d.ts.map +1 -0
  65. package/{core → dist/core}/logger/utils.js +11 -16
  66. package/dist/core/logger/utils.js.map +1 -0
  67. package/{core → dist/core}/module-manager.d.ts +4 -3
  68. package/dist/core/module-manager.d.ts.map +1 -0
  69. package/{core → dist/core}/module-manager.js +17 -18
  70. package/dist/core/module-manager.js.map +1 -0
  71. package/{core → dist/core}/module.d.ts +5 -4
  72. package/dist/core/module.d.ts.map +1 -0
  73. package/{core → dist/core}/module.js +31 -31
  74. package/dist/core/module.js.map +1 -0
  75. package/dist/index.d.ts +36 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +53 -0
  78. package/dist/index.js.map +1 -0
  79. package/{modules → dist/modules}/CliParamsModule.d.ts +3 -2
  80. package/dist/modules/CliParamsModule.d.ts.map +1 -0
  81. package/dist/modules/CliParamsModule.js +54 -0
  82. package/dist/modules/CliParamsModule.js.map +1 -0
  83. package/{permissions → dist/permissions}/permission-group.d.ts +1 -0
  84. package/dist/permissions/permission-group.d.ts.map +1 -0
  85. package/{permissions → dist/permissions}/permission-group.js +8 -8
  86. package/dist/permissions/permission-group.js.map +1 -0
  87. package/{testing → dist/testing}/test-model.d.ts +1 -0
  88. package/dist/testing/test-model.d.ts.map +1 -0
  89. package/dist/testing/test-model.js +62 -0
  90. package/dist/testing/test-model.js.map +1 -0
  91. package/dist/tsconfig.tsbuildinfo +1 -0
  92. package/{utils → dist/utils}/array-tools.d.ts +1 -0
  93. package/dist/utils/array-tools.d.ts.map +1 -0
  94. package/dist/utils/array-tools.js +116 -0
  95. package/dist/utils/array-tools.js.map +1 -0
  96. package/{utils → dist/utils}/crypto-tools.d.ts +1 -0
  97. package/dist/utils/crypto-tools.d.ts.map +1 -0
  98. package/dist/utils/crypto-tools.js +13 -0
  99. package/dist/utils/crypto-tools.js.map +1 -0
  100. package/{utils → dist/utils}/date-time-tools.d.ts +2 -1
  101. package/dist/utils/date-time-tools.d.ts.map +1 -0
  102. package/dist/utils/date-time-tools.js +86 -0
  103. package/dist/utils/date-time-tools.js.map +1 -0
  104. package/{utils → dist/utils}/filter-tools.d.ts +1 -0
  105. package/dist/utils/filter-tools.d.ts.map +1 -0
  106. package/{utils → dist/utils}/filter-tools.js +6 -9
  107. package/dist/utils/filter-tools.js.map +1 -0
  108. package/{utils → dist/utils}/hash-tools.d.ts +1 -0
  109. package/dist/utils/hash-tools.d.ts.map +1 -0
  110. package/dist/utils/hash-tools.js +47 -0
  111. package/dist/utils/hash-tools.js.map +1 -0
  112. package/{utils → dist/utils}/merge-tools.d.ts +1 -0
  113. package/dist/utils/merge-tools.d.ts.map +1 -0
  114. package/{utils → dist/utils}/merge-tools.js +8 -13
  115. package/dist/utils/merge-tools.js.map +1 -0
  116. package/{utils → dist/utils}/object-tools.d.ts +1 -0
  117. package/dist/utils/object-tools.d.ts.map +1 -0
  118. package/{utils → dist/utils}/object-tools.js +11 -21
  119. package/dist/utils/object-tools.js.map +1 -0
  120. package/{utils → dist/utils}/queue.d.ts +2 -1
  121. package/dist/utils/queue.d.ts.map +1 -0
  122. package/dist/utils/queue.js +69 -0
  123. package/dist/utils/queue.js.map +1 -0
  124. package/{utils → dist/utils}/random-tools.d.ts +1 -0
  125. package/dist/utils/random-tools.d.ts.map +1 -0
  126. package/{utils → dist/utils}/random-tools.js +4 -8
  127. package/dist/utils/random-tools.js.map +1 -0
  128. package/{utils → dist/utils}/string-tools.d.ts +1 -0
  129. package/dist/utils/string-tools.d.ts.map +1 -0
  130. package/{utils → dist/utils}/string-tools.js +1 -4
  131. package/dist/utils/string-tools.js.map +1 -0
  132. package/{utils → dist/utils}/tools.d.ts +2 -1
  133. package/dist/utils/tools.d.ts.map +1 -0
  134. package/dist/utils/tools.js +32 -0
  135. package/dist/utils/tools.js.map +1 -0
  136. package/{utils → dist/utils}/types.d.ts +1 -0
  137. package/dist/utils/types.d.ts.map +1 -0
  138. package/dist/utils/types.js +3 -0
  139. package/dist/utils/types.js.map +1 -0
  140. package/{utils → dist/utils}/version-tools.d.ts +1 -0
  141. package/dist/utils/version-tools.d.ts.map +1 -0
  142. package/{utils → dist/utils}/version-tools.js +4 -7
  143. package/dist/utils/version-tools.js.map +1 -0
  144. package/{validator → dist/validator}/validator.d.ts +3 -2
  145. package/dist/validator/validator.d.ts.map +1 -0
  146. package/dist/validator/validator.js +157 -0
  147. package/dist/validator/validator.js.map +1 -0
  148. package/package.json +76 -12
  149. package/consts/consts.js.map +0 -1
  150. package/core/application.js.map +0 -1
  151. package/core/debug-flags.js.map +0 -1
  152. package/core/dispatcher.js +0 -32
  153. package/core/dispatcher.js.map +0 -1
  154. package/core/error-handling.js +0 -21
  155. package/core/error-handling.js.map +0 -1
  156. package/core/exceptions.js.map +0 -1
  157. package/core/logger/BeLogged.js.map +0 -1
  158. package/core/logger/LogClient.js.map +0 -1
  159. package/core/logger/LogClient_BaseRotate.js.map +0 -1
  160. package/core/logger/LogClient_Browser.js.map +0 -1
  161. package/core/logger/LogClient_Function.js.map +0 -1
  162. package/core/logger/LogClient_MemBuffer.js +0 -23
  163. package/core/logger/LogClient_MemBuffer.js.map +0 -1
  164. package/core/logger/LogClient_Terminal.js.map +0 -1
  165. package/core/logger/Logger.js.map +0 -1
  166. package/core/logger/types.js.map +0 -1
  167. package/core/logger/utils.js.map +0 -1
  168. package/core/module-manager.js.map +0 -1
  169. package/core/module.js.map +0 -1
  170. package/index.d.ts +0 -35
  171. package/index.js +0 -69
  172. package/index.js.map +0 -1
  173. package/modules/CliParamsModule.js +0 -56
  174. package/modules/CliParamsModule.js.map +0 -1
  175. package/permissions/permission-group.js.map +0 -1
  176. package/testing/test-model.js +0 -80
  177. package/testing/test-model.js.map +0 -1
  178. package/utils/array-tools.js +0 -145
  179. package/utils/array-tools.js.map +0 -1
  180. package/utils/crypto-tools.js +0 -18
  181. package/utils/crypto-tools.js.map +0 -1
  182. package/utils/date-time-tools.js +0 -111
  183. package/utils/date-time-tools.js.map +0 -1
  184. package/utils/filter-tools.js.map +0 -1
  185. package/utils/hash-tools.js +0 -56
  186. package/utils/hash-tools.js.map +0 -1
  187. package/utils/merge-tools.js.map +0 -1
  188. package/utils/object-tools.js.map +0 -1
  189. package/utils/queue.js +0 -82
  190. package/utils/queue.js.map +0 -1
  191. package/utils/random-tools.js.map +0 -1
  192. package/utils/string-tools.js.map +0 -1
  193. package/utils/tools.js +0 -34
  194. package/utils/tools.js.map +0 -1
  195. package/utils/types.js +0 -6
  196. package/utils/types.js.map +0 -1
  197. package/utils/version-tools.js.map +0 -1
  198. package/validator/validator.js +0 -174
  199. package/validator/validator.js.map +0 -1
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * ts-common is the basic building blocks of our typescript projects
4
3
  *
@@ -16,18 +15,14 @@
16
15
  * See the License for the specific language governing permissions and
17
16
  * limitations under the License.
18
17
  */
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.mergeObject = mergeObject;
21
- exports.mergeArray = mergeArray;
22
- exports.merge = merge;
23
- const index_1 = require("../index");
24
- function mergeObject(original, override) {
18
+ import { BadImplementationException, deepClone } from "../index.js";
19
+ export function mergeObject(original, override) {
25
20
  if (original === override) {
26
21
  console.log("Original: " + JSON.stringify(original));
27
22
  console.log("Override: " + JSON.stringify(override));
28
- throw new index_1.BadImplementationException(`trying to merge same Object instance\n Original: ${typeof original}\n Override: ${typeof override}`);
23
+ throw new BadImplementationException(`trying to merge same Object instance\n Original: ${typeof original}\n Override: ${typeof override}`);
29
24
  }
30
- const returnValue = (0, index_1.deepClone)(original);
25
+ const returnValue = deepClone(original);
31
26
  return Object.keys(override).reduce((obj, key) => {
32
27
  obj[key] = merge(original[key], override[key]);
33
28
  if (obj[key] === undefined)
@@ -35,11 +30,11 @@ function mergeObject(original, override) {
35
30
  return obj;
36
31
  }, returnValue);
37
32
  }
38
- function mergeArray(original, override) {
33
+ export function mergeArray(original, override) {
39
34
  if (original === override) {
40
35
  console.log("Original: " + JSON.stringify(original));
41
36
  console.log("Override: " + JSON.stringify(override));
42
- throw new index_1.BadImplementationException(`trying to merge same Array instance\n Original: ${typeof original}\n Override: ${typeof override}`);
37
+ throw new BadImplementationException(`trying to merge same Array instance\n Original: ${typeof original}\n Override: ${typeof override}`);
43
38
  }
44
39
  // const returnValue = deepClone(original);
45
40
  // returnValue.reduce((array, value) => {
@@ -58,11 +53,11 @@ function mergeArray(original, override) {
58
53
  // });
59
54
  return override;
60
55
  }
61
- function merge(original, override) {
56
+ export function merge(original, override) {
62
57
  if (override === undefined || override === null)
63
58
  return undefined;
64
59
  if (override && original && typeof original !== typeof override || (typeof original === "object" && typeof override === 'object' && Array.isArray(original) !== Array.isArray(override)))
65
- throw new index_1.BadImplementationException(`trying to merge object of different types!! \n Original: ${typeof original}\n Override: ${typeof override}`);
60
+ throw new BadImplementationException(`trying to merge object of different types!! \n Original: ${typeof original}\n Override: ${typeof override}`);
66
61
  if (Array.isArray(original) && Array.isArray(override))
67
62
  return mergeArray(original, override);
68
63
  if (typeof original === "object" && typeof override === 'object' && !Array.isArray(original) && !Array.isArray(override))
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-tools.js","sourceRoot":"","sources":["../../src/main/utils/merge-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACN,0BAA0B,EAC1B,SAAS,EACT,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,WAAW,CAAC,QAAa,EAAE,QAAa;IACvD,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrD,MAAM,IAAI,0BAA0B,CAAC,oDAAoD,OAAO,QAAQ,gBAAgB,OAAO,QAAQ,EAAE,CAAC,CAAC;IAC5I,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,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,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvL,MAAM,IAAI,0BAA0B,CAAC,4DAA4D,OAAO,QAAQ,gBAAgB,OAAO,QAAQ,EAAE,CAAC,CAAC;IAEpJ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QACrD,OAAO,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEvC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QACvH,OAAO,WAAW,CAAC,QAAQ,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IAE9C,OAAO,QAAQ,CAAA;AAChB,CAAC"}
@@ -8,3 +8,4 @@ export declare function cloneArr<T>(value: T[]): T[];
8
8
  export declare function cloneObj<T extends object>(obj: T): T;
9
9
  export declare function compare<T>(one?: T, two?: T, keys?: (keyof T)[]): boolean;
10
10
  export declare function assert<T>(message: string, expected: T, actual: T): void;
11
+ //# sourceMappingURL=object-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-tools.d.ts","sourceRoot":"","sources":["../../src/main/utils/object-tools.ts"],"names":[],"mappings":"AAwBA,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAQtC;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,CAEzF;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAE5E;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,QAE3F;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE3C;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAKpD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,OAAO,CA0DxE;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,QAIhE"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * ts-common is the basic building blocks of our typescript projects
4
3
  *
@@ -16,42 +15,33 @@
16
15
  * See the License for the specific language governing permissions and
17
16
  * limitations under the License.
18
17
  */
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.deepClone = deepClone;
21
- exports._keys = _keys;
22
- exports._values = _values;
23
- exports._setTypedProp = _setTypedProp;
24
- exports.cloneArr = cloneArr;
25
- exports.cloneObj = cloneObj;
26
- exports.compare = compare;
27
- exports.assert = assert;
28
- const index_1 = require("../index");
29
- function deepClone(obj) {
18
+ import { AssertionException, BadImplementationException } from "../index.js";
19
+ export function deepClone(obj) {
30
20
  if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'undefined' || obj === null)
31
21
  return obj;
32
22
  if (Array.isArray(obj))
33
23
  return cloneArr(obj);
34
24
  return cloneObj(obj);
35
25
  }
36
- function _keys(instance) {
26
+ export function _keys(instance) {
37
27
  return Object.keys(instance);
38
28
  }
39
- function _values(object) {
29
+ export function _values(object) {
40
30
  return Object.values(object);
41
31
  }
42
- function _setTypedProp(instance, key, value) {
32
+ export function _setTypedProp(instance, key, value) {
43
33
  instance[key] = value;
44
34
  }
45
- function cloneArr(value) {
35
+ export function cloneArr(value) {
46
36
  return value.map(a => deepClone(a));
47
37
  }
48
- function cloneObj(obj) {
38
+ export function cloneObj(obj) {
49
39
  return _keys(obj).reduce((carry, key) => {
50
40
  carry[key] = deepClone(obj[key]);
51
41
  return carry;
52
42
  }, {});
53
43
  }
54
- function compare(one, two, keys) {
44
+ export function compare(one, two, keys) {
55
45
  const typeofOne = typeof one;
56
46
  const typeofTwo = typeof two;
57
47
  if (typeofOne !== typeofTwo)
@@ -65,7 +55,7 @@ function compare(one, two, keys) {
65
55
  if (one === null || two === null)
66
56
  return false;
67
57
  if (typeofOne === "function")
68
- throw new index_1.BadImplementationException("This compare meant to compare two POJOs.. nothing more");
58
+ throw new BadImplementationException("This compare meant to compare two POJOs.. nothing more");
69
59
  if (typeofOne !== "object")
70
60
  return one === two;
71
61
  if (Array.isArray(one) && Array.isArray(two)) {
@@ -95,8 +85,8 @@ function compare(one, two, keys) {
95
85
  }
96
86
  return true;
97
87
  }
98
- function assert(message, expected, actual) {
88
+ export function assert(message, expected, actual) {
99
89
  if (!compare(expected, actual))
100
- throw new index_1.AssertionException(`Assertion Failed:\n -- ${message}\n -- Expected: ${JSON.stringify(expected)}\n -- Actual: ${JSON.stringify(actual)}\n\n`);
90
+ throw new AssertionException(`Assertion Failed:\n -- ${message}\n -- Expected: ${JSON.stringify(expected)}\n -- Actual: ${JSON.stringify(actual)}\n\n`);
101
91
  }
102
92
  //# sourceMappingURL=object-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-tools.js","sourceRoot":"","sources":["../../src/main/utils/object-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAA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AC;IACtD,MAAM,OAAO,GAAG,IAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QACpC,OAAO,KAAK,CAAC;IAEd,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACtC,SAAS;QAEV,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,MAAM,CAAI,OAAe,EAAE,QAAW,EAAE,MAAS;IAChE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC7B,MAAM,IAAI,kBAAkB,CAC3B,2BAA2B,OAAO,oBAAoB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACnI,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Logger } from "../core/logger/Logger";
1
+ import { Logger } from "../core/logger/Logger.js";
2
2
  export declare class Queue extends Logger {
3
3
  private parallelCount;
4
4
  private running;
@@ -14,3 +14,4 @@ export declare class Queue extends Logger {
14
14
  execute(): void;
15
15
  executeSync(): Promise<void>;
16
16
  }
17
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/main/utils/queue.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAEhD,qBAAa,KACZ,SAAQ,MAAM;IAEd,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,YAAY,CAAC,CAA4B;gBAErC,IAAI,EAAE,MAAM;IAIxB,gBAAgB,CAAC,aAAa,EAAE,MAAM;IAKtC,eAAe,CAAC,YAAY,EAAE,MAAM,IAAI;IAKxC,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI;IAMzG,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI;IAqB7G,MAAM,aACJ;IAEF,OAAO;IAeD,WAAW;CAMjB"}
@@ -0,0 +1,69 @@
1
+ import { addItemToArray, removeItemFromArray, } from "../index.js";
2
+ import { Logger } from "../core/logger/Logger.js";
3
+ export class Queue extends Logger {
4
+ parallelCount = 1;
5
+ running = 0;
6
+ queue = [];
7
+ onQueueEmpty;
8
+ finalResolve;
9
+ constructor(name) {
10
+ super(name);
11
+ }
12
+ setParallelCount(parallelCount) {
13
+ this.parallelCount = parallelCount;
14
+ return this;
15
+ }
16
+ setOnQueueEmpty(onQueueEmpty) {
17
+ this.onQueueEmpty = onQueueEmpty;
18
+ return this;
19
+ }
20
+ addItem(toExecute, onCompleted, onError) {
21
+ this.addItemImpl(toExecute.bind(this), onCompleted?.bind(this), onError?.bind(this));
22
+ this.execute();
23
+ }
24
+ addItemImpl(toExecute, onCompleted, onError) {
25
+ addItemToArray(this.queue, async (resolve) => {
26
+ this.running++;
27
+ try {
28
+ const output = await toExecute();
29
+ onCompleted?.(output);
30
+ }
31
+ catch (e) {
32
+ try {
33
+ onError?.(e);
34
+ }
35
+ catch (e1) {
36
+ this.logError("Error while calling onError");
37
+ this.logError("--- Original: ", e);
38
+ this.logError("-- Secondary: ", e1);
39
+ }
40
+ }
41
+ this.running--;
42
+ resolve();
43
+ this.execute();
44
+ });
45
+ }
46
+ ignore = () => {
47
+ };
48
+ execute() {
49
+ if (this.queue.length === 0 && this.running === 0) {
50
+ if (this.onQueueEmpty)
51
+ this.onQueueEmpty();
52
+ return this.finalResolve?.();
53
+ }
54
+ for (let i = 0; this.running < this.parallelCount && i < this.queue.length; i++) {
55
+ const toExecute = this.queue[0];
56
+ removeItemFromArray(this.queue, toExecute);
57
+ new Promise(toExecute.bind(this))
58
+ .then(this.ignore)
59
+ .catch(this.ignore);
60
+ }
61
+ }
62
+ async executeSync() {
63
+ await new Promise(resolve => {
64
+ this.finalResolve = resolve;
65
+ this.execute();
66
+ });
67
+ }
68
+ }
69
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/main/utils/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,mBAAmB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAEhD,MAAM,OAAO,KACZ,SAAQ,MAAM;IAEN,aAAa,GAAG,CAAC,CAAC;IAClB,OAAO,GAAG,CAAC,CAAC;IACZ,KAAK,GAA4B,EAAE,CAAC;IACpC,YAAY,CAAc;IAC1B,YAAY,CAA6B;IAEjD,YAAY,IAAY;QACvB,KAAK,CAAC,IAAI,CAAC,CAAC;IACb,CAAC;IAED,gBAAgB,CAAC,aAAqB;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,eAAe,CAAC,YAAwB;QACvC,IAAI,CAAC,Y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;YACnD,IAAI,IAAI,CAAC,YAAY;gBAAE,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QAC9B,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACjF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAChC,mBAAmB,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAC3C,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC/B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;iBACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;IAED,KAAK,CAAC,WAAW;QAChB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -1,2 +1,3 @@
1
1
  export declare function generateHex(length: number): string;
2
2
  export declare function generateUUID(): string;
3
+ //# sourceMappingURL=random-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-tools.d.ts","sourceRoot":"","sources":["../../src/main/utils/random-tools.ts"],"names":[],"mappings":"AAoBA,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,UAIzC;AAED,wBAAgB,YAAY,WAK3B"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * ts-common is the basic building blocks of our typescript projects
4
3
  *
@@ -16,16 +15,13 @@
16
15
  * See the License for the specific language governing permissions and
17
16
  * limitations under the License.
18
17
  */
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.generateHex = generateHex;
21
- exports.generateUUID = generateUUID;
22
- const crypto_1 = require("crypto");
23
- function generateHex(length) {
24
- return (0, crypto_1.randomBytes)(Math.ceil(length / 2))
18
+ import { randomBytes } from 'crypto';
19
+ export function generateHex(length) {
20
+ return randomBytes(Math.ceil(length / 2))
25
21
  .toString('hex')
26
22
  .slice(0, length).toLowerCase();
27
23
  }
28
- function generateUUID() {
24
+ export function generateUUID() {
29
25
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
30
26
  const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
31
27
  return v.toString(16);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-tools.js","sourceRoot":"","sources":["../../src/main/utils/random-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAC;AAEnC,MAAM,UAAU,WAAW,CAAC,MAAc;IACzC,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACvC,QAAQ,CAAC,KAAK,CAAC;SACf,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,YAAY;IAC3B,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;QACzE,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;QACtE,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare function padNumber(num: number | string, length: number): string;
2
+ //# sourceMappingURL=string-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-tools.d.ts","sourceRoot":"","sources":["../../src/main/utils/string-tools.ts"],"names":[],"mappings":"AAkBA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGtE"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * ts-common is the basic building blocks of our typescript projects
4
3
  *
@@ -16,9 +15,7 @@
16
15
  * See the License for the specific language governing permissions and
17
16
  * limitations under the License.
18
17
  */
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.padNumber = padNumber;
21
- function padNumber(num, length) {
18
+ export function padNumber(num, length) {
22
19
  const _num = num.toString();
23
20
  return _num.length < length ? padNumber("0" + _num, length) : _num;
24
21
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-tools.js","sourceRoot":"","sources":["../../src/main/utils/string-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,UAAU,SAAS,CAAC,GAAoB,EAAE,MAAc;IAC7D,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC5B,OAAO,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,CAAC"}
@@ -1,7 +1,8 @@
1
- import { ObjectTS } from "./types";
1
+ import { type ObjectTS } from "./types.js";
2
2
  export declare function regexpCase(value: string, reg: string): RegExpMatchArray | {
3
3
  input: undefined;
4
4
  };
5
5
  export declare function createFilterPattern(rawFilter?: string): string;
6
6
  export declare function calculateJsonSizeMb(data: ObjectTS): number;
7
7
  export declare function __stringify<T>(obj: T, pretty?: boolean | (keyof T)[]): string;
8
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/main/utils/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEzC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;;EAEpD;AAED,wBAAgB,mBAAmB,CAAC,SAAS,CAAC,EAAE,MAAM,UAOrD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,UAGjD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,MAAM,CAY7E"}
@@ -0,0 +1,32 @@
1
+ import { _keys } from "./object-tools.js";
2
+ import {} from "./types.js";
3
+ export function regexpCase(value, reg) {
4
+ return value.match(new RegExp(reg)) || { input: undefined };
5
+ }
6
+ export function createFilterPattern(rawFilter) {
7
+ let filter = rawFilter || "";
8
+ filter = filter.trim();
9
+ filter = filter.replace(/\s+/, " ");
10
+ filter = filter.replace(new RegExp("(.)", "g"), ".*?$1");
11
+ if (filter.length === 0)
12
+ filter = ".*?";
13
+ else
14
+ filter += ".*";
15
+ return filter;
16
+ }
17
+ export function calculateJsonSizeMb(data) {
18
+ const number = JSON.stringify(data).length / 1024 / 1024;
19
+ return Math.round(number * 100) / 100;
20
+ }
21
+ export function __stringify(obj, pretty) {
22
+ if (Array.isArray(pretty) && typeof obj === "object") {
23
+ return `${_keys(obj).reduce((carry, key, idx) => {
24
+ // @ts-expect-error TS struggles with this dynamic typing
25
+ return carry + ` ${String(key)}: ${__stringify(obj[key], pretty.includes(key))}${idx !== _keys(obj).length - 1 && ',\n'}`;
26
+ }, `{\n`)}\n}`;
27
+ }
28
+ if (pretty)
29
+ return JSON.stringify(obj, null, 2);
30
+ return JSON.stringify(obj);
31
+ }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C,GAAwB,CAAC,CAAC,MAAM,CAAC,CAAC,KAAa,EAAE,GAAY,EAAE,GAAW,EAAE,EAAE;YAC7F,yDAAyD;YACzD,OAAO,KAAK,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;QAC5H,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;IAChB,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAErC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
@@ -63,3 +63,4 @@ export type RangeTimestamp = {
63
63
  min: number;
64
64
  max: number;
65
65
  };
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/main/utils/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI;KACjC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;KACtB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;CAAE,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AACnI,MAAM,M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src/main/utils/types.ts"],"names":[],"mappings":"AAoDA,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE;AAC1B,CAAC,CAAC,EAAE,CAAC"}
@@ -8,3 +8,4 @@
8
8
  * 1 if second is greater
9
9
  */
10
10
  export declare function compareVersions(firstVersion: string, secondVersion: string): 0 | 1 | -1;
11
+ //# sourceMappingURL=version-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-tools.d.ts","sourceRoot":"","sources":["../../src/main/utils/version-tools.ts"],"names":[],"mappings":"AAqBA;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAuB1E"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * ts-common is the basic building blocks of our typescript projects
4
3
  *
@@ -16,9 +15,7 @@
16
15
  * See the License for the specific language governing permissions and
17
16
  * limitations under the License.
18
17
  */
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.compareVersions = compareVersions;
21
- const index_1 = require("../index");
18
+ import { BadImplementationException } from "../index.js";
22
19
  /**
23
20
  *
24
21
  * @param firstVersion a version
@@ -28,11 +25,11 @@ const index_1 = require("../index");
28
25
  * 0 if versions match
29
26
  * 1 if second is greater
30
27
  */
31
- function compareVersions(firstVersion, secondVersion) {
28
+ export function compareVersions(firstVersion, secondVersion) {
32
29
  if (!firstVersion)
33
- throw new index_1.BadImplementationException("First version is undefined");
30
+ throw new BadImplementationException("First version is undefined");
34
31
  if (!secondVersion)
35
- throw new index_1.BadImplementationException("Second version is undefined");
32
+ throw new BadImplementationException("Second version is undefined");
36
33
  const firstVersionAsArray = firstVersion.split("\.");
37
34
  const secondVersionAsArray = secondVersion.split("\.");
38
35
  for (let i = 0; i < firstVersionAsArray.length; i++) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-tools.js","sourceRoot":"","sources":["../../src/main/utils/version-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,0BAA0B,EAAC,MAAM,aAAa,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,YAAoB,EAAE,aAAqB;IAC1E,IAAI,CAAC,YAAY;QAChB,MAAM,IAAI,0BAA0B,CAAC,4BAA4B,CAAC,CAAC;IAEpE,IAAI,CAAC,aAAa;QACjB,MAAM,IAAI,0BAA0B,CAAC,6BAA6B,CAAC,CAAC;IAErE,MAAM,mBAAmB,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,oBAAoB,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,MAAM,SAAS,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,SAAS,GAAG,QAAQ;YACvB,OAAO,CAAC,CAAC;QAEV,IAAI,SAAS,KAAK,QAAQ;YACzB,SAAS;QAEV,IAAI,SAAS,GAAG,QAAQ;YACvB,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,CAAC,CAAC;AACV,CAAC"}
@@ -1,5 +1,5 @@
1
- import { CustomException } from "../core/exceptions";
2
- import { ArrayType, AuditBy, ObjectTS, RangeTimestamp } from "../utils/types";
1
+ import { CustomException } from "../core/exceptions.js";
2
+ import { type ArrayType, type AuditBy, type ObjectTS, type RangeTimestamp } from "../utils/types.js";
3
3
  export type ValidatorTypeResolver<K> = K extends any[] ? Validator<K> : K extends object ? TypeValidator<K> | Validator<K> : Validator<K>;
4
4
  export type Validator<P> = undefined | ((path: string, p?: P) => void);
5
5
  export type TypeValidator<T extends ObjectTS> = {
@@ -33,3 +33,4 @@ export declare const isTimestampValid: (time: number, range?: {
33
33
  export declare const auditValidator: (range?: RangeTimestamp) => (_path: string, audit?: AuditBy) => void;
34
34
  export declare const timestampValidator: (range?: RangeTimestamp) => (_path: string, timestamp?: number) => void;
35
35
  export declare const validateEmail: Validator<string>;
36
+ //# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/main/validator/validator.ts"],"names":[],"mappings":"AAkBA,OAAO,EAEN,eAAe,EACf,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACN,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,MAAM,mBAAmB,CAAC;AAM3B,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAClC,CAAC,SAAS,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,GAC7B,CAAC,SAAS,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GACjD,SAAS,CAAC,CAAC,CAAC,CAAC;AAEhB,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;AACvE,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,QAAQ,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEhG,qBAAa,mBACZ,SAAQ,eAAe;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEV,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;CAK3D;AAUD,eAAO,MAAM,cAAc,GAAI,mBAAgB,KAAG,SAAS,CAAC,GAAG,CAI9D,CAAC;AAEF,e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EAAE,YAAY,qBAAqB,CAAC,CAAC,CAAC,EAAE,aAAS,SAoBvF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,aAAa,aAAa,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,EAAE,aAAS,SAgB3F,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE;;;CAAwF,KAAG,OAEzI,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,cAAc,MAAM,OAAO,MAAM,EAAE,QAAQ,OAAO,SAExF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,cAAc,MAAM,OAAO,MAAM,EAAE,YAAY,MAAM,SAG/F,CAAA;AAED,eAAO,MAAM,aAAa,mBAC+G,CAAC"}
@@ -0,0 +1,157 @@
1
+ /*
2
+ * ts-common is the basic building blocks of our typescript projects
3
+ *
4
+ * Copyright (C) 2020 Intuition Robotics
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { BadImplementationException, CustomException } from "../core/exceptions.js";
19
+ import { __stringify, } from "../utils/tools.js";
20
+ import { _keys } from "../utils/object-tools.js";
21
+ import {} from "../utils/types.js";
22
+ import { currentTimeMillies, Day } from "../index.js";
23
+ export class ValidationException extends CustomException {
24
+ path;
25
+ input;
26
+ constructor(debugMessage, path, input) {
27
+ super(ValidationException, debugMessage);
28
+ this.path = path;
29
+ this.input = input;
30
+ }
31
+ }
32
+ const assertMandatory = (mandatory, path, input) => {
33
+ if (input !== undefined && input !== null)
34
+ return;
35
+ if (mandatory)
36
+ throw new ValidationException(`Missing mandatory field: ${path}\n`, path, input);
37
+ };
38
+ export const validateExists = (mandatory = true) => {
39
+ return (path, input) => {
40
+ assertMandatory(mandatory, path, input);
41
+ };
42
+ };
43
+ export const validateType = (type, mandatory = true) => {
44
+ return (path, input) => {
45
+ assertMandatory(mandatory, path, input);
46
+ const typeOfInput = typeof input;
47
+ if (input && typeOfInput !== type)
48
+ throw new ValidationException(`Got ${typeOfInput} when expecting ${type} for field: ${path}\n`, path, input);
49
+ };
50
+ };
51
+ export const validateString = (mandatory = true) => {
52
+ return validateType('string', mandatory);
53
+ };
54
+ export const validateNumber = (mandatory = true) => {
55
+ return validateType('number', mandatory);
56
+ };
57
+ export const validateBoolean = (mandatory = true) => {
58
+ return validateType('boolean', mandatory);
59
+ };
60
+ export const validateObjectValues = (validator, mandatory = true) => (path, input) => {
61
+ assertMandatory(mandatory, path, input);
62
+ if (!input)
63
+ return;
64
+ for (const key of _keys(input)) {
65
+ const inputValue = input[key];
66
+ if (typeof inputValue === "object") {
67
+ const objectValidator = validateObjectValues(validator, mandatory);
68
+ if (!objectValidator)
69
+ return;
70
+ return objectValidator(`${path}/${key}`, inputValue);
71
+ }
72
+ validate(inputValue, validator, `${path}/${key}`);
73
+ }
74
+ };
75
+ export const validateArray = (validator, mandatory = true) => (path, input) => {
76
+ assertMandatory(mandatory, path, input);
77
+ if (!input)
78
+ return;
79
+ const _input = input;
80
+ for (let i = 0; i < _input.length; i++) {
81
+ validate(_input[i], validator, `${path}/${i}`);
82
+ }
83
+ };
84
+ export const validateRegexp = (regexp, mandatory = true) => {
85
+ return (path, input) => {
86
+ assertMandatory(mandatory, path, input);
87
+ if (!input)
88
+ return;
89
+ if (regexp.test(input))
90
+ return;
91
+ throw new ValidationException(`Input is not valid:\n input: ${input}\n regexp: ${regexp}\n`, path, input);
92
+ };
93
+ };
94
+ export const validateValue = (values, mandatory = true) => {
95
+ return (path, input) => {
96
+ assertMandatory(mandatory, path, input);
97
+ if (!input)
98
+ return;
99
+ if (values.includes(input))
100
+ return;
101
+ throw new ValidationException(`Input is not valid:\n input: ${input}\n options: ${__stringify(values)}\n`, path, input);
102
+ };
103
+ };
104
+ export const validateRange = (ranges, mandatory = true) => {
105
+ return (path, input) => {
106
+ assertMandatory(mandatory, path, input);
107
+ if (!input)
108
+ return;
109
+ for (const range of ranges) {
110
+ if (range[0] <= input && input <= range[1])
111
+ return;
112
+ }
113
+ throw new ValidationException(`Input is not valid:\n input: ${input}\n regexp: ${__stringify(ranges)}\n`, path, input);
114
+ };
115
+ };
116
+ export const validate = (instance, _validator, path = "") => {
117
+ if (!_validator)
118
+ return;
119
+ if (typeof _validator === "function") {
120
+ const validator = _validator;
121
+ if (!validator)
122
+ return;
123
+ return validator(`${path}`, instance);
124
+ }
125
+ if (typeof _validator === "object") {
126
+ if (!instance && _validator)
127
+ throw new BadImplementationException(`Unexpect object at '${path}'\nif you want to ignore the validation of this object,\n add the following to your validator:\n {\n ...\n ${path}: undefined\n ...\n}\n`);
128
+ const __validator = _validator;
129
+ validateObject(__validator, instance, path);
130
+ }
131
+ };
132
+ export const validateObject = (__validator, instance, path = "") => {
133
+ const validatorKeys = _keys(__validator);
134
+ const instanceKeys = Object.keys(instance);
135
+ for (const key of instanceKeys) {
136
+ // @ts-expect-error TS struggles with this dynamic typing
137
+ if (!validatorKeys.includes(key))
138
+ throw new BadImplementationException(`Unexpect key '${path}${key}'\nif you want to ignore the validation of this property,\n add the following to your validator:\n {\n ...\n ${key}: undefined\n ...\n}\nAvailable keys are ${validatorKeys.join()}`);
139
+ }
140
+ for (const key of validatorKeys) {
141
+ const value = instance[key];
142
+ const validator = __validator[key];
143
+ validate(value, validator, `${path}/${key}`);
144
+ }
145
+ };
146
+ export const isTimestampValid = (time, range = { min: currentTimeMillies() - 1000 * Day, max: currentTimeMillies() + 1000 * Day }) => {
147
+ return time >= range.min && time <= range.max;
148
+ };
149
+ export const auditValidator = (range) => (_path, audit) => {
150
+ timestampValidator(range)(_path, audit?.auditAt?.timestamp);
151
+ };
152
+ export const timestampValidator = (range) => (_path, timestamp) => {
153
+ if (!timestamp || !isTimestampValid(timestamp, range))
154
+ throw new ValidationException('Time is not proper', _path, timestamp);
155
+ };
156
+ export const validateEmail = validateRegexp(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/);
157
+ //# sourceMappingURL=validator.js.map