@powfix/core-js 0.20.4 → 0.21.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 (217) hide show
  1. package/dist/browser/cjs/index.browser.js +3 -0
  2. package/dist/browser/cjs/shared/utils/UUID.js +9 -9
  3. package/dist/browser/cjs/shared/utils/index.js +1 -1
  4. package/dist/browser/esm/index.browser.mjs +1 -0
  5. package/dist/browser/esm/shared/utils/UUID.mjs +9 -9
  6. package/dist/browser/esm/shared/utils/index.mjs +1 -1
  7. package/dist/browser/types/index.browser.d.ts +1 -0
  8. package/dist/browser/types/shared/utils/UUID.d.ts +5 -5
  9. package/dist/browser/types/shared/utils/index.d.ts +1 -0
  10. package/dist/cjs/index.js +17 -0
  11. package/dist/cjs/shared/constants/COORDINATE.js +10 -0
  12. package/dist/cjs/shared/constants/CRUD.js +22 -0
  13. package/dist/cjs/shared/constants/DATE.js +26 -0
  14. package/dist/cjs/shared/constants/DISTANCE.js +18 -0
  15. package/dist/cjs/shared/constants/DURATION.js +21 -0
  16. package/dist/cjs/shared/constants/NOT_NULL.js +4 -0
  17. package/dist/cjs/shared/constants/index.js +22 -0
  18. package/dist/cjs/shared/index.js +23 -0
  19. package/dist/cjs/shared/interfaces/Coordinate.js +2 -0
  20. package/dist/cjs/shared/interfaces/Point2.js +2 -0
  21. package/dist/cjs/shared/interfaces/Point3.js +2 -0
  22. package/dist/cjs/shared/interfaces/StorageProvider.js +2 -0
  23. package/dist/cjs/shared/interfaces/index.js +20 -0
  24. package/dist/cjs/shared/managers/SessionManager.js +134 -0
  25. package/dist/cjs/shared/managers/SessionManager.type.js +2 -0
  26. package/dist/cjs/shared/managers/index.js +18 -0
  27. package/dist/cjs/shared/scripts/base64Polyfill.js +18 -0
  28. package/dist/cjs/shared/scripts/index.js +17 -0
  29. package/dist/cjs/shared/services/index.js +17 -0
  30. package/dist/cjs/shared/services/time/TimeService.js +180 -0
  31. package/dist/cjs/shared/services/time/TimeService.type.js +2 -0
  32. package/dist/cjs/shared/services/time/index.js +18 -0
  33. package/dist/cjs/shared/types/IntRage.js +2 -0
  34. package/dist/cjs/shared/types/PartialExcept.js +2 -0
  35. package/dist/cjs/shared/types/index.js +18 -0
  36. package/dist/cjs/shared/utils/ArrayUtils.js +30 -0
  37. package/dist/cjs/shared/utils/AxiosUtils.js +53 -0
  38. package/dist/cjs/shared/utils/BooleanUtils.js +8 -0
  39. package/dist/cjs/shared/utils/Calc.js +27 -0
  40. package/dist/cjs/shared/utils/CoordinateUtils.js +42 -0
  41. package/dist/cjs/shared/utils/DateUtils.js +310 -0
  42. package/dist/cjs/shared/utils/Enum.js +36 -0
  43. package/dist/cjs/shared/utils/Enum.types.js +2 -0
  44. package/dist/cjs/shared/utils/I18nUtils.js +13 -0
  45. package/dist/cjs/shared/utils/JuminNumberUtils.js +50 -0
  46. package/dist/cjs/shared/utils/NumberUtils.js +25 -0
  47. package/dist/cjs/shared/utils/ObjectIdUtils.js +30 -0
  48. package/dist/cjs/shared/utils/Point3Utils.js +12 -0
  49. package/dist/cjs/shared/utils/RandomUtils.js +64 -0
  50. package/dist/cjs/shared/utils/Sequencer.js +148 -0
  51. package/dist/cjs/shared/utils/StringUtils.js +37 -0
  52. package/dist/cjs/shared/utils/UUID.js +320 -0
  53. package/dist/cjs/shared/utils/UUID.types.js +2 -0
  54. package/dist/cjs/shared/utils/Uint8ArrayUtils.js +13 -0
  55. package/dist/cjs/shared/utils/UuidUtils.js +77 -0
  56. package/dist/cjs/shared/utils/Validator.js +118 -0
  57. package/dist/cjs/shared/utils/global/atob.js +9 -0
  58. package/dist/cjs/shared/utils/global/base64.js +25 -0
  59. package/dist/cjs/shared/utils/global/between.js +7 -0
  60. package/dist/cjs/shared/utils/global/btoa.js +9 -0
  61. package/dist/cjs/shared/utils/global/castArray.js +6 -0
  62. package/dist/cjs/shared/utils/global/circularDistance.js +14 -0
  63. package/dist/cjs/shared/utils/global/fallbackIfMatch.js +9 -0
  64. package/dist/cjs/shared/utils/global/fallbackIfNull.js +7 -0
  65. package/dist/cjs/shared/utils/global/fallbackIfNullish.js +9 -0
  66. package/dist/cjs/shared/utils/global/fallbackIfUndefined.js +7 -0
  67. package/dist/cjs/shared/utils/global/firstNonNullish.js +13 -0
  68. package/dist/cjs/shared/utils/global/flat.js +117 -0
  69. package/dist/cjs/shared/utils/global/index.js +31 -0
  70. package/dist/cjs/shared/utils/global/processFirstNonNullish.js +11 -0
  71. package/dist/cjs/shared/utils/global/pureEnum.js +23 -0
  72. package/dist/cjs/shared/utils/global/sleep.js +5 -0
  73. package/dist/cjs/shared/utils/index.js +39 -0
  74. package/dist/cjs/shared/utils/try-catch/TryCatch.js +78 -0
  75. package/dist/cjs/shared/utils/try-catch/index.js +17 -0
  76. package/dist/esm/index.mjs +1 -0
  77. package/dist/esm/shared/constants/COORDINATE.mjs +6 -0
  78. package/dist/esm/shared/constants/CRUD.mjs +19 -0
  79. package/dist/esm/shared/constants/DATE.mjs +22 -0
  80. package/dist/esm/shared/constants/DISTANCE.mjs +14 -0
  81. package/dist/esm/shared/constants/DURATION.mjs +17 -0
  82. package/dist/esm/shared/constants/NOT_NULL.mjs +1 -0
  83. package/dist/esm/shared/constants/index.mjs +6 -0
  84. package/dist/esm/shared/index.mjs +7 -0
  85. package/dist/esm/shared/interfaces/Coordinate.mjs +1 -0
  86. package/dist/esm/shared/interfaces/Point2.mjs +1 -0
  87. package/dist/esm/shared/interfaces/Point3.mjs +1 -0
  88. package/dist/esm/shared/interfaces/StorageProvider.mjs +1 -0
  89. package/dist/esm/shared/interfaces/index.mjs +4 -0
  90. package/dist/esm/shared/managers/SessionManager.mjs +127 -0
  91. package/dist/esm/shared/managers/SessionManager.type.mjs +1 -0
  92. package/dist/esm/shared/managers/index.mjs +2 -0
  93. package/dist/esm/shared/scripts/base64Polyfill.mjs +11 -0
  94. package/dist/esm/shared/scripts/index.mjs +1 -0
  95. package/dist/esm/shared/services/index.mjs +1 -0
  96. package/dist/esm/shared/services/time/TimeService.mjs +173 -0
  97. package/dist/esm/shared/services/time/TimeService.type.mjs +1 -0
  98. package/dist/esm/shared/services/time/index.mjs +2 -0
  99. package/dist/esm/shared/types/IntRage.mjs +1 -0
  100. package/dist/esm/shared/types/PartialExcept.mjs +1 -0
  101. package/dist/esm/shared/types/index.mjs +2 -0
  102. package/dist/esm/shared/utils/ArrayUtils.mjs +26 -0
  103. package/dist/esm/shared/utils/AxiosUtils.mjs +49 -0
  104. package/dist/esm/shared/utils/BooleanUtils.mjs +5 -0
  105. package/dist/esm/shared/utils/Calc.mjs +23 -0
  106. package/dist/esm/shared/utils/CoordinateUtils.mjs +38 -0
  107. package/dist/esm/shared/utils/DateUtils.mjs +303 -0
  108. package/dist/esm/shared/utils/Enum.mjs +32 -0
  109. package/dist/esm/shared/utils/Enum.types.mjs +1 -0
  110. package/dist/esm/shared/utils/I18nUtils.mjs +6 -0
  111. package/dist/esm/shared/utils/JuminNumberUtils.mjs +46 -0
  112. package/dist/esm/shared/utils/NumberUtils.mjs +21 -0
  113. package/dist/esm/shared/utils/ObjectIdUtils.mjs +26 -0
  114. package/dist/esm/shared/utils/Point3Utils.mjs +8 -0
  115. package/dist/esm/shared/utils/RandomUtils.mjs +60 -0
  116. package/dist/esm/shared/utils/Sequencer.mjs +141 -0
  117. package/dist/esm/shared/utils/StringUtils.mjs +33 -0
  118. package/dist/esm/shared/utils/UUID.mjs +316 -0
  119. package/dist/esm/shared/utils/UUID.types.mjs +1 -0
  120. package/dist/esm/shared/utils/Uint8ArrayUtils.mjs +9 -0
  121. package/dist/esm/shared/utils/UuidUtils.mjs +40 -0
  122. package/dist/esm/shared/utils/Validator.mjs +114 -0
  123. package/dist/esm/shared/utils/global/atob.mjs +3 -0
  124. package/dist/esm/shared/utils/global/base64.mjs +21 -0
  125. package/dist/esm/shared/utils/global/between.mjs +3 -0
  126. package/dist/esm/shared/utils/global/btoa.mjs +3 -0
  127. package/dist/esm/shared/utils/global/castArray.mjs +3 -0
  128. package/dist/esm/shared/utils/global/circularDistance.mjs +11 -0
  129. package/dist/esm/shared/utils/global/fallbackIfMatch.mjs +6 -0
  130. package/dist/esm/shared/utils/global/fallbackIfNull.mjs +4 -0
  131. package/dist/esm/shared/utils/global/fallbackIfNullish.mjs +6 -0
  132. package/dist/esm/shared/utils/global/fallbackIfUndefined.mjs +4 -0
  133. package/dist/esm/shared/utils/global/firstNonNullish.mjs +10 -0
  134. package/dist/esm/shared/utils/global/flat.mjs +113 -0
  135. package/dist/esm/shared/utils/global/index.mjs +15 -0
  136. package/dist/esm/shared/utils/global/processFirstNonNullish.mjs +8 -0
  137. package/dist/esm/shared/utils/global/pureEnum.mjs +18 -0
  138. package/dist/esm/shared/utils/global/sleep.mjs +1 -0
  139. package/dist/esm/shared/utils/index.mjs +23 -0
  140. package/dist/esm/shared/utils/try-catch/TryCatch.mjs +74 -0
  141. package/dist/esm/shared/utils/try-catch/index.mjs +1 -0
  142. package/dist/node/cjs/index.nodejs.js +3 -0
  143. package/dist/node/cjs/shared/utils/UUID.js +9 -9
  144. package/dist/node/cjs/shared/utils/index.js +1 -1
  145. package/dist/node/esm/index.nodejs.mjs +1 -0
  146. package/dist/node/esm/shared/utils/UUID.mjs +9 -9
  147. package/dist/node/esm/shared/utils/index.mjs +1 -1
  148. package/dist/node/types/index.nodejs.d.ts +1 -0
  149. package/dist/node/types/shared/utils/UUID.d.ts +5 -5
  150. package/dist/node/types/shared/utils/index.d.ts +1 -0
  151. package/dist/types/index.d.ts +1 -0
  152. package/dist/types/shared/constants/COORDINATE.d.ts +7 -0
  153. package/dist/types/shared/constants/CRUD.d.ts +9 -0
  154. package/dist/types/shared/constants/DATE.d.ts +13 -0
  155. package/dist/types/shared/constants/DISTANCE.d.ts +13 -0
  156. package/dist/types/shared/constants/DURATION.d.ts +16 -0
  157. package/dist/types/shared/constants/NOT_NULL.d.ts +1 -0
  158. package/dist/types/shared/constants/index.d.ts +6 -0
  159. package/dist/types/shared/index.d.ts +7 -0
  160. package/dist/types/shared/interfaces/Coordinate.d.ts +8 -0
  161. package/dist/types/shared/interfaces/Point2.d.ts +4 -0
  162. package/dist/types/shared/interfaces/Point3.d.ts +4 -0
  163. package/dist/types/shared/interfaces/StorageProvider.d.ts +7 -0
  164. package/dist/types/shared/interfaces/index.d.ts +4 -0
  165. package/dist/types/shared/managers/SessionManager.d.ts +15 -0
  166. package/dist/types/shared/managers/SessionManager.type.d.ts +9 -0
  167. package/dist/types/shared/managers/index.d.ts +2 -0
  168. package/dist/types/shared/scripts/base64Polyfill.d.ts +1 -0
  169. package/dist/types/shared/scripts/index.d.ts +1 -0
  170. package/dist/types/shared/services/index.d.ts +1 -0
  171. package/dist/types/shared/services/time/TimeService.d.ts +31 -0
  172. package/dist/types/shared/services/time/TimeService.type.d.ts +21 -0
  173. package/dist/types/shared/services/time/index.d.ts +2 -0
  174. package/dist/types/shared/types/IntRage.d.ts +3 -0
  175. package/dist/types/shared/types/PartialExcept.d.ts +1 -0
  176. package/dist/types/shared/types/index.d.ts +2 -0
  177. package/dist/types/shared/utils/ArrayUtils.d.ts +12 -0
  178. package/dist/types/shared/utils/AxiosUtils.d.ts +5 -0
  179. package/dist/types/shared/utils/BooleanUtils.d.ts +1 -0
  180. package/dist/types/shared/utils/Calc.d.ts +4 -0
  181. package/dist/types/shared/utils/CoordinateUtils.d.ts +8 -0
  182. package/dist/types/shared/utils/DateUtils.d.ts +24 -0
  183. package/dist/types/shared/utils/Enum.d.ts +16 -0
  184. package/dist/types/shared/utils/Enum.types.d.ts +6 -0
  185. package/dist/types/shared/utils/I18nUtils.d.ts +4 -0
  186. package/dist/types/shared/utils/JuminNumberUtils.d.ts +4 -0
  187. package/dist/types/shared/utils/NumberUtils.d.ts +4 -0
  188. package/dist/types/shared/utils/ObjectIdUtils.d.ts +4 -0
  189. package/dist/types/shared/utils/Point3Utils.d.ts +4 -0
  190. package/dist/types/shared/utils/RandomUtils.d.ts +8 -0
  191. package/dist/types/shared/utils/Sequencer.d.ts +38 -0
  192. package/dist/types/shared/utils/StringUtils.d.ts +5 -0
  193. package/dist/types/shared/utils/UUID.d.ts +147 -0
  194. package/dist/types/shared/utils/UUID.types.d.ts +2 -0
  195. package/dist/types/shared/utils/Uint8ArrayUtils.d.ts +4 -0
  196. package/dist/types/shared/utils/UuidUtils.d.ts +14 -0
  197. package/dist/types/shared/utils/Validator.d.ts +48 -0
  198. package/dist/types/shared/utils/global/atob.d.ts +2 -0
  199. package/dist/types/shared/utils/global/base64.d.ts +2 -0
  200. package/dist/types/shared/utils/global/between.d.ts +1 -0
  201. package/dist/types/shared/utils/global/btoa.d.ts +2 -0
  202. package/dist/types/shared/utils/global/castArray.d.ts +1 -0
  203. package/dist/types/shared/utils/global/circularDistance.d.ts +1 -0
  204. package/dist/types/shared/utils/global/fallbackIfMatch.d.ts +1 -0
  205. package/dist/types/shared/utils/global/fallbackIfNull.d.ts +1 -0
  206. package/dist/types/shared/utils/global/fallbackIfNullish.d.ts +1 -0
  207. package/dist/types/shared/utils/global/fallbackIfUndefined.d.ts +1 -0
  208. package/dist/types/shared/utils/global/firstNonNullish.d.ts +1 -0
  209. package/dist/types/shared/utils/global/flat.d.ts +14 -0
  210. package/dist/types/shared/utils/global/index.d.ts +15 -0
  211. package/dist/types/shared/utils/global/processFirstNonNullish.d.ts +1 -0
  212. package/dist/types/shared/utils/global/pureEnum.d.ts +17 -0
  213. package/dist/types/shared/utils/global/sleep.d.ts +1 -0
  214. package/dist/types/shared/utils/index.d.ts +23 -0
  215. package/dist/types/shared/utils/try-catch/TryCatch.d.ts +24 -0
  216. package/dist/types/shared/utils/try-catch/index.d.ts +1 -0
  217. package/package.json +10 -4
@@ -0,0 +1,113 @@
1
+ // flat.ts
2
+ function isBuffer(obj) {
3
+ return !!(obj &&
4
+ obj.constructor &&
5
+ typeof obj.constructor.isBuffer === 'function' &&
6
+ obj.constructor.isBuffer(obj));
7
+ }
8
+ function keyIdentity(key) {
9
+ return key;
10
+ }
11
+ export function flatten(target, opts = {}) {
12
+ const delimiter = opts.delimiter || '.';
13
+ const maxDepth = opts.maxDepth;
14
+ const transformKey = opts.transformKey || keyIdentity;
15
+ const output = {};
16
+ function step(object, prev, currentDepth = 1) {
17
+ Object.keys(object).forEach((key) => {
18
+ const value = object[key];
19
+ const isarray = opts.safe && Array.isArray(value);
20
+ const type = Object.prototype.toString.call(value);
21
+ const isbuffer = isBuffer(value);
22
+ const isobject = type === '[object Object]' || type === '[object Array]';
23
+ const newKey = prev
24
+ ? `${prev}${delimiter}${transformKey(key)}`
25
+ : transformKey(key);
26
+ if (!isarray &&
27
+ !isbuffer &&
28
+ isobject &&
29
+ Object.keys(value).length &&
30
+ (!maxDepth || currentDepth < maxDepth)) {
31
+ return step(value, newKey, currentDepth + 1);
32
+ }
33
+ output[newKey] = value;
34
+ });
35
+ }
36
+ step(target);
37
+ return output;
38
+ }
39
+ export function unflatten(target, opts = {}) {
40
+ const delimiter = opts.delimiter || '.';
41
+ const overwrite = opts.overwrite || false;
42
+ const transformKey = opts.transformKey || keyIdentity;
43
+ const result = {};
44
+ if (isBuffer(target) ||
45
+ Object.prototype.toString.call(target) !== '[object Object]') {
46
+ return target;
47
+ }
48
+ function getkey(key) {
49
+ const parsedKey = Number(key);
50
+ return isNaN(parsedKey) || key.indexOf('.') !== -1 || opts.object
51
+ ? key
52
+ : parsedKey;
53
+ }
54
+ function addKeys(keyPrefix, recipient, target) {
55
+ return Object.keys(target).reduce((res, key) => {
56
+ res[`${keyPrefix}${delimiter}${key}`] = target[key];
57
+ return res;
58
+ }, recipient);
59
+ }
60
+ function isEmpty(val) {
61
+ const type = Object.prototype.toString.call(val);
62
+ const isArray = type === '[object Array]';
63
+ const isObject = type === '[object Object]';
64
+ if (!val) {
65
+ return true;
66
+ }
67
+ else if (isArray) {
68
+ return !val.length;
69
+ }
70
+ else if (isObject) {
71
+ return !Object.keys(val).length;
72
+ }
73
+ return false;
74
+ }
75
+ const target2 = Object.keys(target).reduce((res, key) => {
76
+ const value = target[key];
77
+ const type = Object.prototype.toString.call(value);
78
+ const isObject = type === '[object Object]' || type === '[object Array]';
79
+ if (!isObject || isEmpty(value)) {
80
+ res[key] = value;
81
+ return res;
82
+ }
83
+ else {
84
+ return addKeys(key, res, flatten(value, opts));
85
+ }
86
+ }, {});
87
+ Object.keys(target2).forEach((key) => {
88
+ const split = key.split(delimiter).map(transformKey);
89
+ let key1 = getkey(split.shift());
90
+ let key2 = getkey(split[0]);
91
+ let recipient = result;
92
+ while (key2 !== undefined) {
93
+ if (key1 === '__proto__')
94
+ return;
95
+ const type = Object.prototype.toString.call(recipient[key1]);
96
+ const isobject = type === '[object Object]' || type === '[object Array]';
97
+ if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {
98
+ return;
99
+ }
100
+ if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {
101
+ recipient[key1] =
102
+ typeof key2 === 'number' && !opts.object ? [] : {};
103
+ }
104
+ recipient = recipient[key1];
105
+ if (split.length > 0) {
106
+ key1 = getkey(split.shift());
107
+ key2 = getkey(split[0]);
108
+ }
109
+ }
110
+ recipient[key1] = unflatten(target2[key], opts);
111
+ });
112
+ return result;
113
+ }
@@ -0,0 +1,15 @@
1
+ export * from './atob.mjs';
2
+ export * from './base64.mjs';
3
+ export * from './between.mjs';
4
+ export * from './btoa.mjs';
5
+ export * from './castArray.mjs';
6
+ export * from './circularDistance.mjs';
7
+ export * from './sleep.mjs';
8
+ export * from './fallbackIfMatch.mjs';
9
+ export * from './fallbackIfNull.mjs';
10
+ export * from './fallbackIfNullish.mjs';
11
+ export * from './fallbackIfUndefined.mjs';
12
+ export * from './firstNonNullish.mjs';
13
+ export * from './flat.mjs';
14
+ export * from './processFirstNonNullish.mjs';
15
+ export * from './pureEnum.mjs';
@@ -0,0 +1,8 @@
1
+ import { firstNonNullish } from "./firstNonNullish.mjs";
2
+ export function processFirstNonNullish(processor, ...args) {
3
+ const fallback = firstNonNullish(...args);
4
+ if (fallback == null) {
5
+ return undefined;
6
+ }
7
+ return processor(fallback);
8
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @deprecated Use Enum instead.
3
+ */
4
+ export function pureEnum(e) {
5
+ return Object.entries(e).filter(([key, value]) => !/^-?\d+$/g.test(key) && typeof value !== 'function');
6
+ }
7
+ /**
8
+ * @deprecated Use Enum instead.
9
+ */
10
+ export function pureEnumKeys(e) {
11
+ return pureEnum(e).map(([key]) => key);
12
+ }
13
+ /**
14
+ * @deprecated Use Enum instead.
15
+ */
16
+ export function pureEnumValues(e) {
17
+ return pureEnum(e).map(([, value]) => value);
18
+ }
@@ -0,0 +1 @@
1
+ export const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
@@ -0,0 +1,23 @@
1
+ export * from './global/index.mjs';
2
+ export * from './ArrayUtils.mjs';
3
+ export * from './AxiosUtils.mjs';
4
+ export * from './StringUtils.mjs';
5
+ export * from './Uint8ArrayUtils.mjs';
6
+ export * from './UUID.mjs';
7
+ export * from './UUID.types.mjs';
8
+ export * from './UuidUtils.mjs';
9
+ export * from './BooleanUtils.mjs';
10
+ export * from './Calc.mjs';
11
+ export * from './CoordinateUtils.mjs';
12
+ export * from './DateUtils.mjs';
13
+ export * from './Enum.mjs';
14
+ export * from './Enum.types.mjs';
15
+ export * from './I18nUtils.mjs';
16
+ export * from './NumberUtils.mjs';
17
+ export * from './ObjectIdUtils.mjs';
18
+ export * from './Point3Utils.mjs';
19
+ export * from './RandomUtils.mjs';
20
+ export * from './Validator.mjs';
21
+ export * from './JuminNumberUtils.mjs';
22
+ export * from './Sequencer.mjs';
23
+ export * from './try-catch/index.mjs';
@@ -0,0 +1,74 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * Provides a utility class for handling synchronous and asynchronous operations with a consistent try-catch pattern.
12
+ * It returns a tuple where the first element is the error (or null on success) and the second element is the result (or undefined on error).
13
+ */
14
+ export class TryCatch {
15
+ /**
16
+ * Executes a synchronous function within a try-catch block.
17
+ * @template T The return type of the function.
18
+ * @template E The type of the error that might be thrown (defaults to Error).
19
+ * @param fn The synchronous function to execute.
20
+ *@param disableLogging console.error is default way of logging on error. You can disable it by setting it true
21
+ * @returns A tuple containing the result of the function and an error (null if successful).
22
+ */
23
+ static function(fn, disableLogging) {
24
+ try {
25
+ return [
26
+ null,
27
+ fn(),
28
+ ];
29
+ }
30
+ catch (e) {
31
+ if (!disableLogging) {
32
+ console.error("ERROR in TryCatch: ", e);
33
+ }
34
+ if (e == null) {
35
+ e = new Error("Unknown error");
36
+ }
37
+ return [
38
+ e,
39
+ undefined,
40
+ ];
41
+ }
42
+ }
43
+ /**
44
+ * Executes an asynchronous function (Promise) within a try-catch block.
45
+ * @template T The resolved value type of the Promise.
46
+ * @template E The type of the error that might be rejected (defaults to Error).
47
+ * @param fn The Promise to await.
48
+ * @param disableLogging console.error is default way of logging on error. You can disable it by setting it true
49
+ * @returns A tuple containing the resolved value of the Promise and an error (null if successful).
50
+ */
51
+ static asyncFunction(fn, disableLogging) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ try {
54
+ const data = yield fn;
55
+ return [
56
+ null,
57
+ data,
58
+ ];
59
+ }
60
+ catch (e) {
61
+ if (!disableLogging) {
62
+ console.error("ERROR in TryCatch: ", e);
63
+ }
64
+ if (e == null) {
65
+ e = new Error("Unknown error");
66
+ }
67
+ return [
68
+ e,
69
+ undefined,
70
+ ];
71
+ }
72
+ });
73
+ }
74
+ }
@@ -0,0 +1 @@
1
+ export * from "./TryCatch.mjs";
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.UUID = void 0;
17
18
  __exportStar(require("./shared"), exports);
18
19
  __exportStar(require("./nodejs"), exports);
20
+ var nodejs_1 = require("./nodejs");
21
+ Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return nodejs_1.UUID; } });
@@ -215,17 +215,17 @@ class UUID {
215
215
  * -------------------------------------------------------------------- */
216
216
  /**
217
217
  * Compares multiple UUIDs for strict equality.
218
- * @param uuids - The UUIDs to compare (at least two required).
218
+ * @param inputs - The UUIDs to compare (at least two required).
219
219
  * @returns true if all provided UUIDs are identical.
220
220
  */
221
- static equals(...uuids) {
222
- const n = uuids.length;
221
+ static equals(...inputs) {
222
+ const n = inputs.length;
223
223
  if (n < 2) {
224
224
  throw new Error('At least two UUIDs required for comparison');
225
225
  }
226
- const ref = uuids[0].bytes;
226
+ const ref = this.parse(inputs[0]);
227
227
  for (let i = 1; i < n; ++i) {
228
- const b = uuids[i].bytes;
228
+ const b = this.parse(inputs[i]);
229
229
  for (let j = 0; j < UUID.BYTE_LENGTH; ++j) {
230
230
  if (ref[j] !== b[j])
231
231
  return false;
@@ -240,8 +240,8 @@ class UUID {
240
240
  * @returns -1 if uuid1 < uuid2, 1 if uuid1 > uuid2, 0 otherwise.
241
241
  */
242
242
  static compare(uuid1, uuid2) {
243
- const a = uuid1.bytes;
244
- const b = uuid2.bytes;
243
+ const a = this.parse(uuid1);
244
+ const b = this.parse(uuid2);
245
245
  for (let i = 0; i < UUID.BYTE_LENGTH; i++) {
246
246
  if (a[i] !== b[i])
247
247
  return a[i] < b[i] ? -1 : 1;
@@ -256,8 +256,8 @@ class UUID {
256
256
  this.bytes = UUID.parse(input);
257
257
  }
258
258
  /** Instance wrapper for {@link equals}. */
259
- equals(...uuids) {
260
- return UUID.equals(this, ...uuids);
259
+ equals(...inputs) {
260
+ return UUID.equals(this, ...inputs);
261
261
  }
262
262
  /** Instance wrapper for {@link compare}. */
263
263
  compare(other) {
@@ -19,7 +19,7 @@ __exportStar(require("./ArrayUtils"), exports);
19
19
  __exportStar(require("./AxiosUtils"), exports);
20
20
  __exportStar(require("./StringUtils"), exports);
21
21
  __exportStar(require("./Uint8ArrayUtils"), exports);
22
- // export * from './UUID';
22
+ __exportStar(require("./UUID"), exports);
23
23
  __exportStar(require("./UUID.types"), exports);
24
24
  __exportStar(require("./UuidUtils"), exports);
25
25
  __exportStar(require("./BooleanUtils"), exports);
@@ -1,2 +1,3 @@
1
1
  export * from './shared/index.mjs';
2
2
  export * from './nodejs/index.mjs';
3
+ export { UUID } from "./nodejs/index.mjs";
@@ -212,17 +212,17 @@ export class UUID {
212
212
  * -------------------------------------------------------------------- */
213
213
  /**
214
214
  * Compares multiple UUIDs for strict equality.
215
- * @param uuids - The UUIDs to compare (at least two required).
215
+ * @param inputs - The UUIDs to compare (at least two required).
216
216
  * @returns true if all provided UUIDs are identical.
217
217
  */
218
- static equals(...uuids) {
219
- const n = uuids.length;
218
+ static equals(...inputs) {
219
+ const n = inputs.length;
220
220
  if (n < 2) {
221
221
  throw new Error('At least two UUIDs required for comparison');
222
222
  }
223
- const ref = uuids[0].bytes;
223
+ const ref = this.parse(inputs[0]);
224
224
  for (let i = 1; i < n; ++i) {
225
- const b = uuids[i].bytes;
225
+ const b = this.parse(inputs[i]);
226
226
  for (let j = 0; j < UUID.BYTE_LENGTH; ++j) {
227
227
  if (ref[j] !== b[j])
228
228
  return false;
@@ -237,8 +237,8 @@ export class UUID {
237
237
  * @returns -1 if uuid1 < uuid2, 1 if uuid1 > uuid2, 0 otherwise.
238
238
  */
239
239
  static compare(uuid1, uuid2) {
240
- const a = uuid1.bytes;
241
- const b = uuid2.bytes;
240
+ const a = this.parse(uuid1);
241
+ const b = this.parse(uuid2);
242
242
  for (let i = 0; i < UUID.BYTE_LENGTH; i++) {
243
243
  if (a[i] !== b[i])
244
244
  return a[i] < b[i] ? -1 : 1;
@@ -253,8 +253,8 @@ export class UUID {
253
253
  this.bytes = UUID.parse(input);
254
254
  }
255
255
  /** Instance wrapper for {@link equals}. */
256
- equals(...uuids) {
257
- return UUID.equals(this, ...uuids);
256
+ equals(...inputs) {
257
+ return UUID.equals(this, ...inputs);
258
258
  }
259
259
  /** Instance wrapper for {@link compare}. */
260
260
  compare(other) {
@@ -3,7 +3,7 @@ export * from './ArrayUtils.mjs';
3
3
  export * from './AxiosUtils.mjs';
4
4
  export * from './StringUtils.mjs';
5
5
  export * from './Uint8ArrayUtils.mjs';
6
- // export * from './UUID';
6
+ export * from './UUID.mjs';
7
7
  export * from './UUID.types.mjs';
8
8
  export * from './UuidUtils.mjs';
9
9
  export * from './BooleanUtils.mjs';
@@ -1,2 +1,3 @@
1
1
  export * from './shared';
2
2
  export * from './nodejs';
3
+ export { UUID } from "./nodejs";
@@ -102,17 +102,17 @@ export declare class UUID {
102
102
  static max<T extends typeof UUID>(this: T): InstanceType<T>;
103
103
  /**
104
104
  * Compares multiple UUIDs for strict equality.
105
- * @param uuids - The UUIDs to compare (at least two required).
105
+ * @param inputs - The UUIDs to compare (at least two required).
106
106
  * @returns true if all provided UUIDs are identical.
107
107
  */
108
- static equals(...uuids: UUID[]): boolean;
108
+ static equals(...inputs: UuidInput[]): boolean;
109
109
  /**
110
110
  * Lexicographically compares two UUIDs.
111
111
  * @param uuid1 - The first UUID.
112
112
  * @param uuid2 - The second UUID.
113
113
  * @returns -1 if uuid1 < uuid2, 1 if uuid1 > uuid2, 0 otherwise.
114
114
  */
115
- static compare(uuid1: UUID, uuid2: UUID): number;
115
+ static compare(uuid1: UuidInput, uuid2: UuidInput): number;
116
116
  /** Raw byte representation of the UUID. */
117
117
  protected readonly bytes: Uint8Array;
118
118
  private _str?;
@@ -123,9 +123,9 @@ export declare class UUID {
123
123
  */
124
124
  constructor(input: UuidInput);
125
125
  /** Instance wrapper for {@link equals}. */
126
- equals(...uuids: UUID[]): boolean;
126
+ equals(...inputs: UuidInput[]): boolean;
127
127
  /** Instance wrapper for {@link compare}. */
128
- compare(other: UUID): number;
128
+ compare(other: UuidInput): number;
129
129
  version(): number;
130
130
  /**
131
131
  * Returns the RFC 4122 string representation of this UUID.
@@ -3,6 +3,7 @@ export * from './ArrayUtils';
3
3
  export * from './AxiosUtils';
4
4
  export * from './StringUtils';
5
5
  export * from './Uint8ArrayUtils';
6
+ export * from './UUID';
6
7
  export * from './UUID.types';
7
8
  export * from './UuidUtils';
8
9
  export * from './BooleanUtils';
@@ -0,0 +1 @@
1
+ export * from './shared';
@@ -0,0 +1,7 @@
1
+ export declare class COORDINATE {
2
+ static LATITUDE_MIN_LENGTH: number;
3
+ static LATITUDE_MAX_LENGTH: number;
4
+ static LONGITUDE_MIN_LENGTH: number;
5
+ static LONGITUDE_MAX_LENGTH: number;
6
+ }
7
+ export declare namespace COORDINATE { }
@@ -0,0 +1,9 @@
1
+ export declare enum CRUD {
2
+ CREATE = 1,
3
+ READ = 2,
4
+ UPDATE = 3,
5
+ DELETE = 4
6
+ }
7
+ export declare namespace CRUD {
8
+ function toString(crud: CRUD): string;
9
+ }
@@ -0,0 +1,13 @@
1
+ export declare class DATE {
2
+ }
3
+ export declare namespace DATE {
4
+ enum FORMAT {
5
+ UNIX = 1,
6
+ SECONDS = 2,
7
+ MILLISECONDS = 3,
8
+ ISO_8601 = 4
9
+ }
10
+ namespace FORMAT {
11
+ function toString(format: FORMAT): string;
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ export declare class DISTANCE {
2
+ }
3
+ export declare namespace DISTANCE {
4
+ enum UNIT {
5
+ FEET = "FEET",
6
+ KILOMETERS = "KILOMETERS",
7
+ MILLIMETERS = "MILLIMETERS",
8
+ CENTIMETERS = "CENTIMETERS",
9
+ METERS = "METERS",
10
+ MILES = "MILES",
11
+ YARDS = "YARDS"
12
+ }
13
+ }
@@ -0,0 +1,16 @@
1
+ export declare class DURATION {
2
+ }
3
+ export declare namespace DURATION {
4
+ enum UNIT {
5
+ NANOSECONDS = "NANOSECONDS",
6
+ MICROSECONDS = "MICROSECONDS",
7
+ MILLISECONDS = "MILLISECONDS",
8
+ SECONDS = "SECONDS",
9
+ MINUTES = "MINUTES",
10
+ HOURS = "HOURS",
11
+ DAYS = "DAYS",
12
+ YEARS = "YEARS",
13
+ DECADES = "DECADES",
14
+ CENTURIES = "CENTURIES"
15
+ }
16
+ }
@@ -0,0 +1 @@
1
+ export declare const NOT_NULL: unique symbol;
@@ -0,0 +1,6 @@
1
+ export * from './COORDINATE';
2
+ export * from './CRUD';
3
+ export * from './DATE';
4
+ export * from './DISTANCE';
5
+ export * from './DURATION';
6
+ export * from './NOT_NULL';
@@ -0,0 +1,7 @@
1
+ export * from './constants';
2
+ export * from './interfaces';
3
+ export * from './managers';
4
+ export * from './scripts';
5
+ export * from './services';
6
+ export * from './types';
7
+ export * from './utils';
@@ -0,0 +1,8 @@
1
+ export interface Coordinate {
2
+ latitude: number;
3
+ longitude: number;
4
+ }
5
+ export interface CoordinateM {
6
+ lat: number;
7
+ lon: number;
8
+ }
@@ -0,0 +1,4 @@
1
+ export interface Point2 {
2
+ x: number;
3
+ y: number;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Point2 } from "./Point2";
2
+ export interface Point3 extends Point2 {
3
+ z: number;
4
+ }
@@ -0,0 +1,7 @@
1
+ export interface StorageProvider {
2
+ key?: () => string;
3
+ set: (key: string, value: string) => Promise<void> | void;
4
+ get: (key: string) => Promise<string | null> | (string | null);
5
+ remove: (key: string) => Promise<void> | void;
6
+ clear?: () => Promise<void> | void;
7
+ }
@@ -0,0 +1,4 @@
1
+ export * from './Coordinate';
2
+ export * from './Point2';
3
+ export * from './Point3';
4
+ export * from './StorageProvider';
@@ -0,0 +1,15 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { StorageProvider } from "../interfaces/StorageProvider";
3
+ import EventEmitter from 'eventemitter3';
4
+ import { SessionManagerEvent, SessionManagerOptions } from "./SessionManager.type";
5
+ export declare class SessionManager extends EventEmitter<SessionManagerEvent> {
6
+ private static readonly DEFAULT_AUTHORIZATION_STORAGE_KEY;
7
+ protected api: AxiosInstance;
8
+ protected storageProvider: StorageProvider;
9
+ constructor(options: SessionManagerOptions);
10
+ private get key();
11
+ hasAuthorization(): Promise<boolean>;
12
+ getAuthorization(): Promise<string | null>;
13
+ setAuthorization(authorization?: string | null): Promise<string | null>;
14
+ removeAuthorization(): Promise<void>;
15
+ }
@@ -0,0 +1,9 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { StorageProvider } from "../interfaces/StorageProvider";
3
+ export interface SessionManagerOptions {
4
+ api: AxiosInstance;
5
+ storageProvider: StorageProvider;
6
+ }
7
+ export type SessionManagerEvent = {
8
+ AUTHORIZATION_CHANGED: (authorization: string | null) => void;
9
+ };
@@ -0,0 +1,2 @@
1
+ export * from './SessionManager';
2
+ export * from './SessionManager.type';
@@ -0,0 +1 @@
1
+ export declare const base64Polyfill: () => void;
@@ -0,0 +1 @@
1
+ export * from './base64Polyfill';
@@ -0,0 +1 @@
1
+ export * from './time';
@@ -0,0 +1,31 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ import type { TimeServiceClientTimeProvider, TimeServiceEvent, TimeServiceNtpResult, TimeServiceOffset, TimeServiceOptions, TimeServiceServerTimeProvider, TimeServiceTimeStamp } from "./TimeService.type";
3
+ export declare class TimeService extends EventEmitter<TimeServiceEvent> {
4
+ private syncHandler?;
5
+ private offset?;
6
+ private syncedAt?;
7
+ protected syncInterval?: number | null;
8
+ protected clientTimeProvider?: TimeServiceClientTimeProvider;
9
+ protected serverTimeProvider?: TimeServiceServerTimeProvider;
10
+ static calculateNTPResultOffset(ntpResult: TimeServiceNtpResult): TimeServiceOffset;
11
+ constructor(options?: TimeServiceOptions);
12
+ getOffset(defaultValue: TimeServiceOffset): TimeServiceOffset;
13
+ getOffset(): TimeServiceOffset | undefined;
14
+ setOffset(offset: TimeServiceOffset): TimeServiceOffset;
15
+ setOffset(offset: TimeServiceOffset | undefined): TimeServiceOffset;
16
+ getSyncedAt(): TimeServiceTimeStamp | undefined;
17
+ private setSyncedAt;
18
+ getSyncInterval(): number | null | undefined;
19
+ setSyncInterval(interval: TimeServiceOptions['syncInterval']): void;
20
+ getClientTimeProvider(): TimeServiceClientTimeProvider | undefined;
21
+ setClientTimeProvider(provider: TimeServiceClientTimeProvider | null | undefined): void;
22
+ getClientTime(): number | undefined;
23
+ getServerTimeProvider(): TimeServiceServerTimeProvider | undefined;
24
+ setServerTimeProvider(provider: TimeServiceServerTimeProvider | null | undefined): void;
25
+ getServerTime(): number | undefined;
26
+ getTime(): number;
27
+ private fetchServerNTPResult;
28
+ sync(): Promise<TimeServiceOffset | null>;
29
+ startSync(): void;
30
+ stopSync(): void;
31
+ }