ag-common 0.0.418 → 0.0.419

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 (179) hide show
  1. package/dist/api/helpers/api.js +34 -35
  2. package/dist/api/helpers/aws.js +9 -13
  3. package/dist/api/helpers/cloudfront.js +7 -24
  4. package/dist/api/helpers/dynamo.js +85 -134
  5. package/dist/api/helpers/dynamoInfra.js +14 -19
  6. package/dist/api/helpers/enforceDynamoProvisionCap.js +14 -18
  7. package/dist/api/helpers/index.js +14 -30
  8. package/dist/api/helpers/openApiHelpers.d.ts +2 -3
  9. package/dist/api/helpers/openApiHelpers.js +34 -37
  10. package/dist/api/helpers/s3.js +81 -126
  11. package/dist/api/helpers/ses.js +9 -28
  12. package/dist/api/helpers/sqs.js +9 -26
  13. package/dist/api/helpers/ssm.js +8 -14
  14. package/dist/api/helpers/sts.js +16 -34
  15. package/dist/api/helpers/validateOpenApi.js +92 -103
  16. package/dist/api/helpers/validations.js +29 -46
  17. package/dist/api/index.js +2 -18
  18. package/dist/api/openapi-prefix.js +25 -38
  19. package/dist/api/types/aws.js +1 -2
  20. package/dist/api/types/index.js +1 -17
  21. package/dist/common/const.js +2 -5
  22. package/dist/common/helpers/array.js +8 -19
  23. package/dist/common/helpers/async.js +10 -28
  24. package/dist/common/helpers/binary.js +5 -10
  25. package/dist/common/helpers/date.js +14 -25
  26. package/dist/common/helpers/email.js +5 -11
  27. package/dist/common/helpers/func.js +3 -7
  28. package/dist/common/helpers/generator.js +9 -24
  29. package/dist/common/helpers/groupBy.js +3 -9
  30. package/dist/common/helpers/hashCode.js +3 -9
  31. package/dist/common/helpers/i18n.js +9 -17
  32. package/dist/common/helpers/index.js +18 -34
  33. package/dist/common/helpers/log.js +16 -28
  34. package/dist/common/helpers/math.js +9 -21
  35. package/dist/common/helpers/memo.js +3 -7
  36. package/dist/common/helpers/object.js +20 -35
  37. package/dist/common/helpers/random.js +4 -10
  38. package/dist/common/helpers/secondsInNearest.js +2 -7
  39. package/dist/common/helpers/sleep.js +1 -5
  40. package/dist/common/helpers/string/base64.js +2 -7
  41. package/dist/common/helpers/string/chunk.js +1 -5
  42. package/dist/common/helpers/string/contains.js +2 -7
  43. package/dist/common/helpers/string/getExtendedStringSegment.js +5 -9
  44. package/dist/common/helpers/string/index.js +10 -26
  45. package/dist/common/helpers/string/json.js +1 -5
  46. package/dist/common/helpers/string/object.js +1 -5
  47. package/dist/common/helpers/string/surround.js +1 -5
  48. package/dist/common/helpers/string/trim.js +2 -7
  49. package/dist/common/helpers/string/truncate.js +1 -5
  50. package/dist/common/helpers/string/url.js +4 -9
  51. package/dist/common/index.js +2 -18
  52. package/dist/index.js +3 -19
  53. package/dist/ui/components/BorderGradient/index.js +18 -25
  54. package/dist/ui/components/Button/index.js +17 -25
  55. package/dist/ui/components/Chevron/index.js +9 -16
  56. package/dist/ui/components/Close/index.js +6 -13
  57. package/dist/ui/components/Confirm/Dialog.js +9 -25
  58. package/dist/ui/components/Confirm/Modal.js +20 -27
  59. package/dist/ui/components/Confirm/index.js +3 -19
  60. package/dist/ui/components/Confirm/types.js +1 -2
  61. package/dist/ui/components/DropdownList/Base.js +33 -64
  62. package/dist/ui/components/DropdownList/Dialog.js +8 -24
  63. package/dist/ui/components/DropdownList/index.js +2 -18
  64. package/dist/ui/components/DropdownList/types.js +1 -2
  65. package/dist/ui/components/FlexColumn/index.js +4 -14
  66. package/dist/ui/components/FlexRow/index.js +4 -14
  67. package/dist/ui/components/HeadersRaw/index.js +20 -27
  68. package/dist/ui/components/HorizontalScrollBar/index.js +6 -34
  69. package/dist/ui/components/Icon/index.js +9 -16
  70. package/dist/ui/components/Image/index.js +10 -28
  71. package/dist/ui/components/InfiniteScroll/index.js +18 -50
  72. package/dist/ui/components/KebabDots/index.js +6 -13
  73. package/dist/ui/components/Loader/index.js +9 -39
  74. package/dist/ui/components/Modal/Dialog.js +7 -23
  75. package/dist/ui/components/Modal/Modal.js +19 -49
  76. package/dist/ui/components/Modal/index.js +3 -19
  77. package/dist/ui/components/Modal/types.js +1 -2
  78. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +26 -34
  79. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +12 -19
  80. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +6 -11
  81. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +8 -15
  82. package/dist/ui/components/OpenApiCodeBlock/curl/index.js +14 -21
  83. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +8 -15
  84. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +3 -8
  85. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +27 -34
  86. package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +11 -18
  87. package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +7 -17
  88. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +6 -15
  89. package/dist/ui/components/OpenApiCodeBlock/index.js +2 -18
  90. package/dist/ui/components/OpenApiCodeBlock/types.js +1 -2
  91. package/dist/ui/components/PieChart/index.js +11 -18
  92. package/dist/ui/components/ProgressBar/index.js +15 -45
  93. package/dist/ui/components/Prompt/Dialog.js +7 -23
  94. package/dist/ui/components/Prompt/Modal.js +25 -55
  95. package/dist/ui/components/Prompt/index.js +2 -18
  96. package/dist/ui/components/RowOrColumn/index.js +7 -17
  97. package/dist/ui/components/Search/AutoHideSearchBox.js +24 -56
  98. package/dist/ui/components/Search/Base.js +21 -52
  99. package/dist/ui/components/Search/Dialog.js +10 -26
  100. package/dist/ui/components/Search/Inline.js +3 -10
  101. package/dist/ui/components/Search/Modal.js +10 -17
  102. package/dist/ui/components/Search/SearchBox.js +26 -58
  103. package/dist/ui/components/Search/index.js +7 -23
  104. package/dist/ui/components/Search/types.js +1 -2
  105. package/dist/ui/components/Sidebar/index.js +18 -25
  106. package/dist/ui/components/SparkLine/index.js +17 -27
  107. package/dist/ui/components/Table/index.js +15 -22
  108. package/dist/ui/components/TextEdit/CheckboxEdit.js +21 -51
  109. package/dist/ui/components/TextEdit/ColourEdit.js +17 -44
  110. package/dist/ui/components/TextEdit/LengthBox.js +5 -12
  111. package/dist/ui/components/TextEdit/ListboxEdit.js +15 -42
  112. package/dist/ui/components/TextEdit/RadioGroup.js +13 -43
  113. package/dist/ui/components/TextEdit/TextEdit.js +48 -78
  114. package/dist/ui/components/TextEdit/common.js +11 -17
  115. package/dist/ui/components/TextEdit/index.js +6 -22
  116. package/dist/ui/components/TextEdit/types.js +1 -2
  117. package/dist/ui/components/TextWithButton/index.js +10 -40
  118. package/dist/ui/components/TimelineChart/index.js +14 -24
  119. package/dist/ui/components/Toast/Cross.js +9 -16
  120. package/dist/ui/components/Toast/Tick.js +4 -11
  121. package/dist/ui/components/Toast/Warning.js +8 -15
  122. package/dist/ui/components/Toast/base.js +33 -65
  123. package/dist/ui/components/Toast/index.js +2 -18
  124. package/dist/ui/components/Toast/types.js +1 -2
  125. package/dist/ui/components/UserImage/index.js +17 -48
  126. package/dist/ui/components/index.js +30 -46
  127. package/dist/ui/helpers/axiosHelper.js +25 -39
  128. package/dist/ui/helpers/browserHelpers.js +7 -22
  129. package/dist/ui/helpers/callOpenApi/cached.js +18 -37
  130. package/dist/ui/helpers/callOpenApi/direct.js +46 -59
  131. package/dist/ui/helpers/callOpenApi/helpers.js +25 -40
  132. package/dist/ui/helpers/callOpenApi/hook.js +47 -36
  133. package/dist/ui/helpers/callOpenApi/index.js +5 -21
  134. package/dist/ui/helpers/callOpenApi/types.js +1 -2
  135. package/dist/ui/helpers/cognito.js +1 -2
  136. package/dist/ui/helpers/cookie/const.js +2 -5
  137. package/dist/ui/helpers/cookie/get.js +13 -14
  138. package/dist/ui/helpers/cookie/index.js +5 -21
  139. package/dist/ui/helpers/cookie/raw.js +9 -16
  140. package/dist/ui/helpers/cookie/set.js +10 -15
  141. package/dist/ui/helpers/cookie/use.js +23 -16
  142. package/dist/ui/helpers/date.js +10 -15
  143. package/dist/ui/helpers/debounce.js +5 -10
  144. package/dist/ui/helpers/dom.js +6 -13
  145. package/dist/ui/helpers/extractAttributes.js +2 -7
  146. package/dist/ui/helpers/index.js +25 -41
  147. package/dist/ui/helpers/jwt.js +1 -2
  148. package/dist/ui/helpers/plural.js +1 -5
  149. package/dist/ui/helpers/routes.js +17 -24
  150. package/dist/ui/helpers/serviceWorker.js +8 -23
  151. package/dist/ui/helpers/useContextMenu.js +9 -14
  152. package/dist/ui/helpers/useElementAttribute.js +3 -7
  153. package/dist/ui/helpers/useGranularHook.js +5 -10
  154. package/dist/ui/helpers/useInterval.js +8 -12
  155. package/dist/ui/helpers/useLocalStorage.js +24 -32
  156. package/dist/ui/helpers/useLockBodyScroll.js +3 -7
  157. package/dist/ui/helpers/useOnClickOutside.js +7 -12
  158. package/dist/ui/helpers/useOnScroll.js +15 -21
  159. package/dist/ui/helpers/useOverloadPageSearch.js +3 -7
  160. package/dist/ui/helpers/useQueryString.js +14 -20
  161. package/dist/ui/helpers/useResize.js +8 -12
  162. package/dist/ui/helpers/useTimeout.js +5 -9
  163. package/dist/ui/icons/ChevronRight.js +3 -9
  164. package/dist/ui/icons/CrossIcon.js +5 -12
  165. package/dist/ui/icons/Door.js +4 -10
  166. package/dist/ui/icons/HorizontalDots.js +3 -9
  167. package/dist/ui/icons/Magnify.js +3 -10
  168. package/dist/ui/icons/Pencil.js +5 -12
  169. package/dist/ui/icons/Save.js +4 -11
  170. package/dist/ui/icons/Undo.js +5 -12
  171. package/dist/ui/icons/UserOutline.js +3 -9
  172. package/dist/ui/icons/index.js +9 -25
  173. package/dist/ui/index.js +4 -20
  174. package/dist/ui/styles/colours.js +7 -12
  175. package/dist/ui/styles/common.js +14 -22
  176. package/dist/ui/styles/index.js +4 -20
  177. package/dist/ui/styles/media.js +7 -10
  178. package/dist/ui/styles/standaloneStyles.js +10 -16
  179. package/package.json +18 -17
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.distinct = exports.distinctBy = exports.notEmpty = exports.partition = exports.chunk = exports.take = exports.flat = exports.arrayToObject = void 0;
4
- const arrayToObject = (
1
+ export const arrayToObject = (
5
2
  /**
6
3
  * array items
7
4
  */
@@ -24,17 +21,14 @@ valueF) => {
24
21
  });
25
22
  return ret;
26
23
  };
27
- exports.arrayToObject = arrayToObject;
28
24
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
29
25
  // @ts-ignore
30
- const flat = (arr) => [].concat(...arr);
31
- exports.flat = flat;
32
- const take = (array, num) => {
26
+ export const flat = (arr) => [].concat(...arr);
27
+ export const take = (array, num) => {
33
28
  const ret = JSON.parse(JSON.stringify(array));
34
29
  return { part: ret.slice(0, num), rest: ret.slice(num) };
35
30
  };
36
- exports.take = take;
37
- const chunk = (array, max) => {
31
+ export const chunk = (array, max) => {
38
32
  const rows = [];
39
33
  let row = [];
40
34
  for (const k in array) {
@@ -50,22 +44,19 @@ const chunk = (array, max) => {
50
44
  }
51
45
  return rows;
52
46
  };
53
- exports.chunk = chunk;
54
- const partition = (array, func) => !(array === null || array === void 0 ? void 0 : array.length)
47
+ export const partition = (array, func) => !array?.length
55
48
  ? null
56
49
  : [array.filter((r) => func(r)), array.filter((r) => !func(r))];
57
- exports.partition = partition;
58
- function notEmpty(value) {
50
+ export function notEmpty(value) {
59
51
  return value !== null && value !== undefined && value !== false;
60
52
  }
61
- exports.notEmpty = notEmpty;
62
53
  /**
63
54
  * return a distinct array of items determined by a key function
64
55
  * @param data
65
56
  * @param key
66
57
  * @param ignoreEmpty
67
58
  */
68
- function distinctBy(data, key, ignoreEmpty) {
59
+ export function distinctBy(data, key, ignoreEmpty) {
69
60
  if (!data || data.length === 0) {
70
61
  return data;
71
62
  }
@@ -88,8 +79,6 @@ function distinctBy(data, key, ignoreEmpty) {
88
79
  return false;
89
80
  });
90
81
  }
91
- exports.distinctBy = distinctBy;
92
- const distinct = (arr) => [
82
+ export const distinct = (arr) => [
93
83
  ...new Set(arr),
94
84
  ];
95
- exports.distinct = distinct;
@@ -1,41 +1,23 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.asyncMap = exports.asyncForEach = void 0;
13
1
  /**
14
2
  * run async forEach over all array items
15
3
  * @param array
16
4
  * @param callback
17
5
  */
18
- function asyncForEach(array, callback) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- for (let index = 0; index < array.length; index += 1) {
21
- yield callback(array[index], index, array);
22
- }
23
- });
6
+ export async function asyncForEach(array, callback) {
7
+ for (let index = 0; index < array.length; index += 1) {
8
+ await callback(array[index], index, array);
9
+ }
24
10
  }
25
- exports.asyncForEach = asyncForEach;
26
11
  /**
27
12
  * run async map over all array items
28
13
  * @param array
29
14
  * @param callback
30
15
  * @returns
31
16
  */
32
- function asyncMap(array, callback) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const ret = [];
35
- for (let index = 0; index < array.length; index += 1) {
36
- ret.push(yield callback(array[index], index, array));
37
- }
38
- return ret;
39
- });
17
+ export async function asyncMap(array, callback) {
18
+ const ret = [];
19
+ for (let index = 0; index < array.length; index += 1) {
20
+ ret.push(await callback(array[index], index, array));
21
+ }
22
+ return ret;
40
23
  }
41
- exports.asyncMap = asyncMap;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.base64ToBinary = exports.arrayBufferToBase64 = void 0;
4
- const base64_1 = require("./string/base64");
1
+ import { fromBase64, toBase64 } from './string/base64';
5
2
  function toBuffer(ab) {
6
3
  const buffer = new Buffer(ab.byteLength);
7
4
  const view = new Uint8Array(ab);
@@ -11,7 +8,7 @@ function toBuffer(ab) {
11
8
  return buffer;
12
9
  }
13
10
  function toArrayBuffer(base64) {
14
- const binary_string = (0, base64_1.fromBase64)(base64);
11
+ const binary_string = fromBase64(base64);
15
12
  const len = binary_string.length;
16
13
  const bytes = new Uint8Array(len);
17
14
  for (let i = 0; i < len; i += 1) {
@@ -24,20 +21,18 @@ function toArrayBuffer(base64) {
24
21
  * @param buffer
25
22
  * @returns
26
23
  */
27
- function arrayBufferToBase64(buffer) {
24
+ export function arrayBufferToBase64(buffer) {
28
25
  let binary = '';
29
26
  const bytes = new Uint8Array(buffer);
30
27
  const len = bytes.byteLength;
31
28
  for (let i = 0; i < len; i += 1) {
32
29
  binary += String.fromCharCode(bytes[i]);
33
30
  }
34
- return (0, base64_1.toBase64)(binary);
31
+ return toBase64(binary);
35
32
  }
36
- exports.arrayBufferToBase64 = arrayBufferToBase64;
37
33
  /**
38
34
  * convert a base64 string to a binary Buffer. Usually on server side from client sent content
39
35
  * @param raw
40
36
  * @returns
41
37
  */
42
- const base64ToBinary = (raw) => toBuffer(toArrayBuffer(raw));
43
- exports.base64ToBinary = base64ToBinary;
38
+ export const base64ToBinary = (raw) => toBuffer(toArrayBuffer(raw));
@@ -1,42 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dateTimeToNearestMinute = exports.CSharpToJs = exports.dateDiff = exports.lastDayInMonth = exports.addMinutes = exports.addDays = exports.addHours = exports.getTimeSeconds = void 0;
4
- const math_1 = require("./math");
5
- const getTimeSeconds = () => Math.ceil(new Date().getTime() / 1000);
6
- exports.getTimeSeconds = getTimeSeconds;
7
- const addHours = (d, h) => {
1
+ import { toFixedDown } from './math';
2
+ export const getTimeSeconds = () => Math.ceil(new Date().getTime() / 1000);
3
+ export const addHours = (d, h) => {
8
4
  return new Date(d + h * 60 * 60 * 1000);
9
5
  };
10
- exports.addHours = addHours;
11
- const addDays = (dIn, count) => {
6
+ export const addDays = (dIn, count) => {
12
7
  const d = new Date(dIn);
13
8
  d.setDate(d.getDate() + count);
14
9
  return d;
15
10
  };
16
- exports.addDays = addDays;
17
- const addMinutes = (date, minutes) => new Date(date.getTime() + minutes * 60000);
18
- exports.addMinutes = addMinutes;
19
- const lastDayInMonth = (date) => new Date(date.getFullYear(), date.getMonth() + 1, 0);
20
- exports.lastDayInMonth = lastDayInMonth;
11
+ export const addMinutes = (date, minutes) => new Date(date.getTime() + minutes * 60000);
12
+ export const lastDayInMonth = (date) => new Date(date.getFullYear(), date.getMonth() + 1, 0);
21
13
  /**
22
14
  * breaks ticks into time diffs
23
15
  * @param lowDate
24
16
  * @param highDate defaults to Date.Now
25
17
  * @returns
26
18
  */
27
- const dateDiff = (lowDate, highDate) => {
28
- const ticksSince = (highDate !== null && highDate !== void 0 ? highDate : new Date()).getTime() - lowDate.getTime();
29
- const totalMinutes = (0, math_1.toFixedDown)(ticksSince / 1000 / 60, 0);
30
- const totalHours = (0, math_1.toFixedDown)(totalMinutes / 60, 0);
31
- const totalDays = (0, math_1.toFixedDown)(totalHours / 24, 0);
32
- const totalYears = (0, math_1.toFixedDown)(totalDays / 365, 0);
19
+ export const dateDiff = (lowDate, highDate) => {
20
+ const ticksSince = (highDate ?? new Date()).getTime() - lowDate.getTime();
21
+ const totalMinutes = toFixedDown(ticksSince / 1000 / 60, 0);
22
+ const totalHours = toFixedDown(totalMinutes / 60, 0);
23
+ const totalDays = toFixedDown(totalHours / 24, 0);
24
+ const totalYears = toFixedDown(totalDays / 365, 0);
33
25
  return { totalMinutes, totalHours, totalDays, totalYears };
34
26
  };
35
- exports.dateDiff = dateDiff;
36
27
  /**
37
28
  * convert csharp datetime to js datetime
38
29
  */
39
- const CSharpToJs = (charpTicks) => {
30
+ export const CSharpToJs = (charpTicks) => {
40
31
  // ticks are in nanotime; convert to microtime
41
32
  const ticks = charpTicks / 10000;
42
33
  // ticks are recorded from 1/1/1; get microtime difference from 1/1/1/ to 1/1/1970
@@ -45,14 +36,13 @@ const CSharpToJs = (charpTicks) => {
45
36
  const tickDate = new Date(ticks - epochMicrotimeDiff);
46
37
  return tickDate;
47
38
  };
48
- exports.CSharpToJs = CSharpToJs;
49
39
  /**
50
40
  *
51
41
  * @param minutes
52
42
  * @param date default = now
53
43
  * @returns
54
44
  */
55
- const dateTimeToNearestMinute = (minutes, date) => {
45
+ export const dateTimeToNearestMinute = (minutes, date) => {
56
46
  const coeff = 1000 * 60 * minutes;
57
47
  if (!date) {
58
48
  // eslint-disable-next-line no-param-reassign
@@ -61,4 +51,3 @@ const dateTimeToNearestMinute = (minutes, date) => {
61
51
  const rounded = new Date(Math.round(date.getTime() / coeff) * coeff);
62
52
  return rounded;
63
53
  };
64
- exports.dateTimeToNearestMinute = dateTimeToNearestMinute;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEmailsErrors = exports.getEmailErrors = exports.isEmailValid = void 0;
4
- const array_1 = require("./array");
1
+ import { notEmpty } from './array';
5
2
  const regex = /^[-!#$%&'*+/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
6
- const isEmailValid = (email) => {
3
+ export const isEmailValid = (email) => {
7
4
  if (!email)
8
5
  return false;
9
6
  if (email.length > 256)
@@ -20,9 +17,8 @@ const isEmailValid = (email) => {
20
17
  }
21
18
  return true;
22
19
  };
23
- exports.isEmailValid = isEmailValid;
24
- const getEmailErrors = (email, event) => {
25
- if (!(0, exports.isEmailValid)(email)) {
20
+ export const getEmailErrors = (email, event) => {
21
+ if (!isEmailValid(email)) {
26
22
  return `email not valid:${email}`;
27
23
  }
28
24
  if (event.creatorId === email) {
@@ -30,6 +26,4 @@ const getEmailErrors = (email, event) => {
30
26
  }
31
27
  return undefined;
32
28
  };
33
- exports.getEmailErrors = getEmailErrors;
34
- const getEmailsErrors = (emails, event) => emails.map((email) => (0, exports.getEmailErrors)(email, event)).filter(array_1.notEmpty);
35
- exports.getEmailsErrors = getEmailsErrors;
29
+ export const getEmailsErrors = (emails, event) => emails.map((email) => getEmailErrors(email, event)).filter(notEmpty);
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retry = void 0;
4
- const log_1 = require("./log");
5
- function retry(name, fn, retriesLeft = 3, interval = 1000) {
1
+ import { error } from './log';
2
+ export function retry(name, fn, retriesLeft = 3, interval = 1000) {
6
3
  return new Promise((resolve, reject) => {
7
4
  fn()
8
5
  .then(resolve)
9
6
  .catch((e) => {
10
7
  setTimeout(() => {
11
8
  if (retriesLeft === 1) {
12
- (0, log_1.error)(`retry/${name} failed:${e}`);
9
+ error(`retry/${name} failed:${e}`);
13
10
  reject(e);
14
11
  }
15
12
  else {
@@ -19,4 +16,3 @@ function retry(name, fn, retriesLeft = 3, interval = 1000) {
19
16
  });
20
17
  });
21
18
  }
22
- exports.retry = retry;
@@ -1,26 +1,11 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.runGenerator = void 0;
13
1
  /* eslint-disable no-await-in-loop */
14
- function runGenerator(iter, partialRun) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- let curr;
17
- do {
18
- curr = yield iter.next();
19
- if (!(curr === null || curr === void 0 ? void 0 : curr.value) || curr.value.length === 0) {
20
- return;
21
- }
22
- yield partialRun(curr.value);
23
- } while (!curr.done);
24
- });
2
+ export async function runGenerator(iter, partialRun) {
3
+ let curr;
4
+ do {
5
+ curr = await iter.next();
6
+ if (!curr?.value || curr.value.length === 0) {
7
+ return;
8
+ }
9
+ await partialRun(curr.value);
10
+ } while (!curr.done);
25
11
  }
26
- exports.runGenerator = runGenerator;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupByTwice = exports.groupByList = exports.groupBy = void 0;
4
1
  /**
5
2
  * group an array of items by the output of a key function
6
3
  * @param arr
7
4
  * @param getKey
8
5
  */
9
- function groupBy(arr, getKey) {
6
+ export function groupBy(arr, getKey) {
10
7
  const ret = {};
11
8
  arr.forEach((item) => {
12
9
  const key = getKey(item);
@@ -17,13 +14,12 @@ function groupBy(arr, getKey) {
17
14
  });
18
15
  return ret;
19
16
  }
20
- exports.groupBy = groupBy;
21
17
  /**
22
18
  * group an array of items by the output of a key function
23
19
  * @param arr
24
20
  * @param getKey
25
21
  */
26
- function groupByList(arr, getKey) {
22
+ export function groupByList(arr, getKey) {
27
23
  const ret = [];
28
24
  arr.forEach((item) => {
29
25
  const key = getKey(item);
@@ -37,8 +33,7 @@ function groupByList(arr, getKey) {
37
33
  });
38
34
  return ret;
39
35
  }
40
- exports.groupByList = groupByList;
41
- function groupByTwice(arr, getKey, getSubKey) {
36
+ export function groupByTwice(arr, getKey, getSubKey) {
42
37
  const ret = {};
43
38
  arr.forEach((item) => {
44
39
  const key = getKey(item);
@@ -50,4 +45,3 @@ function groupByTwice(arr, getKey, getSubKey) {
50
45
  });
51
46
  return ret;
52
47
  }
53
- exports.groupByTwice = groupByTwice;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateNewPK = exports.hashCode = exports.hashCodeInt = void 0;
4
1
  /* eslint-disable no-bitwise */
5
- const hashCodeInt = (str, seed = 0) => {
2
+ export const hashCodeInt = (str, seed = 0) => {
6
3
  if (!str) {
7
4
  return 0;
8
5
  }
@@ -22,8 +19,5 @@ const hashCodeInt = (str, seed = 0) => {
22
19
  const ret = 4294967296 * (2097151 & h2) + (h1 >>> 0);
23
20
  return ret;
24
21
  };
25
- exports.hashCodeInt = hashCodeInt;
26
- const hashCode = (str, seed = 0) => (0, exports.hashCodeInt)(str, seed).toString();
27
- exports.hashCode = hashCode;
28
- const generateNewPK = () => (0, exports.hashCode)(new Date().getTime().toString());
29
- exports.generateNewPK = generateNewPK;
22
+ export const hashCode = (str, seed = 0) => hashCodeInt(str, seed).toString();
23
+ export const generateNewPK = () => hashCode(new Date().getTime().toString());
@@ -1,32 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTranslation = exports.t = exports.getValidatedLang = exports.AllLang = void 0;
4
- exports.AllLang = ['en', 'id', 'vi', 'pt'];
5
- const getValidatedLang = (raw) => {
6
- const f = exports.AllLang.find((l) => l === raw);
1
+ export const AllLang = ['en', 'id', 'vi', 'pt'];
2
+ export const getValidatedLang = (raw) => {
3
+ const f = AllLang.find((l) => l === raw);
7
4
  if (!f) {
8
5
  return 'en';
9
6
  }
10
7
  return f;
11
8
  };
12
- exports.getValidatedLang = getValidatedLang;
13
- const t = (res, lang) => {
14
- var _a;
9
+ export const t = (res, lang) => {
15
10
  if (res[lang] === null) {
16
11
  return '';
17
12
  }
18
- return (_a = res[lang]) !== null && _a !== void 0 ? _a : res.en;
13
+ return res[lang] ?? res.en;
19
14
  };
20
- exports.t = t;
21
- const useTranslation = (texts, lang) => {
15
+ export const useTranslation = (texts, lang) => {
22
16
  const ret = (lineText) => {
23
- var _a, _b;
24
- const v1 = (_a = texts[lineText]) === null || _a === void 0 ? void 0 : _a[lang];
17
+ const v1 = texts[lineText]?.[lang];
25
18
  if (v1 || v1 === null) {
26
- return v1 !== null && v1 !== void 0 ? v1 : '';
19
+ return v1 ?? '';
27
20
  }
28
- return (_b = texts[lineText].en) !== null && _b !== void 0 ? _b : '???';
21
+ return texts[lineText].en ?? '???';
29
22
  };
30
23
  return ret;
31
24
  };
32
- exports.useTranslation = useTranslation;
@@ -1,34 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./array"), exports);
18
- __exportStar(require("./async"), exports);
19
- __exportStar(require("./binary"), exports);
20
- __exportStar(require("./date"), exports);
21
- __exportStar(require("./email"), exports);
22
- __exportStar(require("./func"), exports);
23
- __exportStar(require("./generator"), exports);
24
- __exportStar(require("./groupBy"), exports);
25
- __exportStar(require("./hashCode"), exports);
26
- __exportStar(require("./i18n"), exports);
27
- __exportStar(require("./log"), exports);
28
- __exportStar(require("./math"), exports);
29
- __exportStar(require("./memo"), exports);
30
- __exportStar(require("./object"), exports);
31
- __exportStar(require("./random"), exports);
32
- __exportStar(require("./secondsInNearest"), exports);
33
- __exportStar(require("./sleep"), exports);
34
- __exportStar(require("./string"), exports);
1
+ export * from './array';
2
+ export * from './async';
3
+ export * from './binary';
4
+ export * from './date';
5
+ export * from './email';
6
+ export * from './func';
7
+ export * from './generator';
8
+ export * from './groupBy';
9
+ export * from './hashCode';
10
+ export * from './i18n';
11
+ export * from './log';
12
+ export * from './math';
13
+ export * from './memo';
14
+ export * from './object';
15
+ export * from './random';
16
+ export * from './secondsInNearest';
17
+ export * from './sleep';
18
+ export * from './string';
@@ -1,38 +1,32 @@
1
- "use strict";
2
1
  /* eslint-disable no-console */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.fatal = exports.error = exports.trace = exports.warn = exports.info = exports.debug = exports.SetLogLevel = exports.SetLogShim = exports.GetLogLevel = void 0;
5
- const _1 = require(".");
6
- const GetLogLevel = (l) => ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'].findIndex((s) => s === l);
7
- exports.GetLogLevel = GetLogLevel;
2
+ import { notEmpty } from '.';
3
+ export const GetLogLevel = (l) => ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'].findIndex((s) => s === l);
8
4
  let logShim;
9
5
  /** if passed in, will use this instead of console.xxx */
10
- const SetLogShim = (ls) => {
6
+ export const SetLogShim = (ls) => {
11
7
  logShim = ls;
12
8
  };
13
- exports.SetLogShim = SetLogShim;
14
9
  let userLogLevel;
15
- const SetLogLevel = (l) => {
16
- const lu = l === null || l === void 0 ? void 0 : l.toUpperCase();
17
- if ((0, exports.GetLogLevel)(lu) === -1) {
10
+ export const SetLogLevel = (l) => {
11
+ const lu = l?.toUpperCase();
12
+ if (GetLogLevel(lu) === -1) {
18
13
  return;
19
14
  }
20
15
  userLogLevel = lu;
21
16
  };
22
- exports.SetLogLevel = SetLogLevel;
23
17
  function logprocess(type, args) {
24
18
  if (!userLogLevel) {
25
- (0, exports.SetLogLevel)(process.env.LOG_LEVEL);
19
+ SetLogLevel(process.env.LOG_LEVEL);
26
20
  }
27
- const min = (0, exports.GetLogLevel)(userLogLevel || 'WARN');
28
- const typesLogLevel = (0, exports.GetLogLevel)(type);
21
+ const min = GetLogLevel(userLogLevel || 'WARN');
22
+ const typesLogLevel = GetLogLevel(type);
29
23
  // env ignores it
30
24
  if (typesLogLevel < min) {
31
25
  return;
32
26
  }
33
27
  ////////
34
28
  const datetime = new Date().toLocaleTimeString('en-GB');
35
- const log = [`[${datetime}]`, type, ...args.filter(_1.notEmpty)];
29
+ const log = [`[${datetime}]`, type, ...args.filter(notEmpty)];
36
30
  if (logShim) {
37
31
  logShim(...log);
38
32
  return;
@@ -122,25 +116,19 @@ function printStackTrace(...args) {
122
116
  }
123
117
  return callstack.join('\n');
124
118
  }
125
- const debug = (...args) => logprocess('DEBUG', args);
126
- exports.debug = debug;
127
- const info = (...args) => logprocess('INFO', args);
128
- exports.info = info;
129
- const warn = (...args) => logprocess('WARN', args);
130
- exports.warn = warn;
119
+ export const debug = (...args) => logprocess('DEBUG', args);
120
+ export const info = (...args) => logprocess('INFO', args);
121
+ export const warn = (...args) => logprocess('WARN', args);
131
122
  //
132
- const trace = (...args) => {
123
+ export const trace = (...args) => {
133
124
  args.push(printStackTrace());
134
125
  logprocess('TRACE', args);
135
126
  };
136
- exports.trace = trace;
137
- const error = (...args) => {
127
+ export const error = (...args) => {
138
128
  args.push(printStackTrace());
139
129
  logprocess('ERROR', args);
140
130
  };
141
- exports.error = error;
142
- const fatal = (...args) => {
131
+ export const fatal = (...args) => {
143
132
  args.push(printStackTrace());
144
133
  logprocess('FATAL', args);
145
134
  };
146
- exports.fatal = fatal;
@@ -1,17 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.interpolatePercentInRange = exports.rangePercentage = exports.toFixedDown = exports.isNumber = exports.sumArray = exports.clamp = exports.roundToHalf = exports.toFixed = void 0;
4
- const toFixed = (num, fixed) => {
5
- var _a, _b;
1
+ export const toFixed = (num, fixed) => {
6
2
  const re = new RegExp(`^-?\\d+(?:.\\d{0,${fixed || -1}})?`);
7
- const x = (_b = (_a = num === null || num === void 0 ? void 0 : num.toString()) === null || _a === void 0 ? void 0 : _a.match(re)) === null || _b === void 0 ? void 0 : _b[0];
3
+ const x = num?.toString()?.match(re)?.[0];
8
4
  if (!x) {
9
5
  return num;
10
6
  }
11
7
  return Number.parseFloat(x);
12
8
  };
13
- exports.toFixed = toFixed;
14
- function roundToHalf(converted) {
9
+ export function roundToHalf(converted) {
15
10
  let decimal = converted - parseInt(converted.toString(), 10);
16
11
  decimal = Math.round(decimal * 10);
17
12
  if (decimal === 5) {
@@ -22,9 +17,8 @@ function roundToHalf(converted) {
22
17
  }
23
18
  return parseInt(converted.toString(), 10) + 0.5;
24
19
  }
25
- exports.roundToHalf = roundToHalf;
26
20
  /** restricts value between two numbers */
27
- function clamp({ value, min, max, }) {
21
+ export function clamp({ value, min, max, }) {
28
22
  if (value < min) {
29
23
  return min;
30
24
  }
@@ -33,18 +27,15 @@ function clamp({ value, min, max, }) {
33
27
  }
34
28
  return value;
35
29
  }
36
- exports.clamp = clamp;
37
- function sumArray(array) {
30
+ export function sumArray(array) {
38
31
  return array.reduce((a, b) => a + b, 0);
39
32
  }
40
- exports.sumArray = sumArray;
41
- function isNumber(val) {
33
+ export function isNumber(val) {
42
34
  const re = new RegExp(`(\\d+\\.?\\d*)(\\d)`);
43
35
  const m = val.toString().match(re);
44
36
  return !!m;
45
37
  }
46
- exports.isNumber = isNumber;
47
- function toFixedDown(num, scale) {
38
+ export function toFixedDown(num, scale) {
48
39
  if (!`${num}`.includes('e')) {
49
40
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
50
41
  // @ts-ignore
@@ -59,19 +50,16 @@ function toFixedDown(num, scale) {
59
50
  // @ts-ignore
60
51
  return +`${Math.round(`${+arr[0]}e${sig}${+arr[1] + scale}`)}e-${scale}`;
61
52
  }
62
- exports.toFixedDown = toFixedDown;
63
53
  /**
64
54
  * get percentage of value within supplied range
65
55
  * eg value of 5 between 0-10 = 0.5. value of 5 between 5-10 = 0
66
56
  * @param param0
67
57
  * @returns
68
58
  */
69
- function rangePercentage({ value, min, max, }) {
59
+ export function rangePercentage({ value, min, max, }) {
70
60
  const v = clamp({ value, min, max });
71
61
  const r = (v - min) / (max - min);
72
62
  return r;
73
63
  }
74
- exports.rangePercentage = rangePercentage;
75
64
  /** will interpolate value of percent inside range. 0.5 between 100 and 200 = 150 */
76
- const interpolatePercentInRange = ({ percent, min, max, }) => (max - min) * percent + min;
77
- exports.interpolatePercentInRange = interpolatePercentInRange;
65
+ export const interpolatePercentInRange = ({ percent, min, max, }) => (max - min) * percent + min;