ag-common 0.0.419 → 0.0.421

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