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.
- package/dist/api/helpers/api.js +35 -34
- package/dist/api/helpers/aws.js +13 -9
- package/dist/api/helpers/cloudfront.js +24 -7
- package/dist/api/helpers/dynamo.js +134 -85
- package/dist/api/helpers/dynamoInfra.js +19 -14
- package/dist/api/helpers/enforceDynamoProvisionCap.js +18 -14
- package/dist/api/helpers/index.js +30 -14
- package/dist/api/helpers/openApiHelpers.js +37 -34
- package/dist/api/helpers/s3.js +126 -81
- package/dist/api/helpers/ses.js +28 -9
- package/dist/api/helpers/sqs.js +26 -9
- package/dist/api/helpers/ssm.js +14 -8
- package/dist/api/helpers/sts.js +34 -16
- package/dist/api/helpers/validateOpenApi.js +103 -92
- package/dist/api/helpers/validations.js +46 -29
- package/dist/api/index.js +18 -2
- package/dist/api/openapi-prefix.js +38 -25
- package/dist/api/types/aws.js +2 -1
- package/dist/api/types/index.js +17 -1
- package/dist/common/const.js +5 -2
- package/dist/common/helpers/array.js +19 -8
- package/dist/common/helpers/async.js +28 -10
- package/dist/common/helpers/binary.js +10 -5
- package/dist/common/helpers/date.js +25 -14
- package/dist/common/helpers/email.js +11 -5
- package/dist/common/helpers/func.js +7 -3
- package/dist/common/helpers/generator.js +24 -9
- package/dist/common/helpers/groupBy.js +9 -3
- package/dist/common/helpers/hashCode.js +9 -3
- package/dist/common/helpers/i18n.js +17 -9
- package/dist/common/helpers/index.js +34 -18
- package/dist/common/helpers/log.js +28 -16
- package/dist/common/helpers/math.js +21 -9
- package/dist/common/helpers/memo.js +7 -3
- package/dist/common/helpers/object.js +35 -20
- package/dist/common/helpers/random.js +10 -4
- package/dist/common/helpers/secondsInNearest.js +7 -2
- package/dist/common/helpers/sleep.js +5 -1
- package/dist/common/helpers/string/base64.js +7 -2
- package/dist/common/helpers/string/chunk.js +5 -1
- package/dist/common/helpers/string/contains.js +7 -2
- package/dist/common/helpers/string/getExtendedStringSegment.js +9 -5
- package/dist/common/helpers/string/index.js +26 -10
- package/dist/common/helpers/string/json.js +5 -1
- package/dist/common/helpers/string/object.js +5 -1
- package/dist/common/helpers/string/surround.js +5 -1
- package/dist/common/helpers/string/trim.js +7 -2
- package/dist/common/helpers/string/truncate.js +5 -1
- package/dist/common/helpers/string/url.js +9 -4
- package/dist/common/index.js +18 -2
- package/dist/index.js +19 -3
- package/dist/ui/components/BorderGradient/index.js +25 -18
- package/dist/ui/components/Button/index.js +25 -17
- package/dist/ui/components/Chevron/index.js +16 -9
- package/dist/ui/components/Close/index.js +13 -6
- package/dist/ui/components/Confirm/Dialog.js +25 -9
- package/dist/ui/components/Confirm/Modal.js +27 -20
- package/dist/ui/components/Confirm/index.js +19 -3
- package/dist/ui/components/Confirm/types.js +2 -1
- package/dist/ui/components/DropdownList/Base.js +64 -33
- package/dist/ui/components/DropdownList/Dialog.js +24 -8
- package/dist/ui/components/DropdownList/index.js +18 -2
- package/dist/ui/components/DropdownList/types.js +2 -1
- package/dist/ui/components/FlexColumn/index.js +14 -4
- package/dist/ui/components/FlexRow/index.js +14 -4
- package/dist/ui/components/HeadersRaw/index.js +27 -20
- package/dist/ui/components/HorizontalScrollBar/index.js +34 -6
- package/dist/ui/components/Icon/index.js +16 -9
- package/dist/ui/components/Image/index.js +28 -10
- package/dist/ui/components/InfiniteScroll/index.js +50 -18
- package/dist/ui/components/KebabDots/index.js +13 -6
- package/dist/ui/components/Loader/index.js +39 -9
- package/dist/ui/components/Modal/Dialog.js +23 -7
- package/dist/ui/components/Modal/Modal.js +49 -19
- package/dist/ui/components/Modal/index.js +19 -3
- package/dist/ui/components/Modal/types.js +2 -1
- package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +34 -26
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +19 -12
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +11 -6
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +15 -8
- package/dist/ui/components/OpenApiCodeBlock/curl/index.js +21 -14
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +15 -8
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +8 -3
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +34 -27
- package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +18 -11
- package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +17 -7
- package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +15 -6
- package/dist/ui/components/OpenApiCodeBlock/index.js +18 -2
- package/dist/ui/components/OpenApiCodeBlock/types.js +2 -1
- package/dist/ui/components/PieChart/index.js +18 -11
- package/dist/ui/components/ProgressBar/index.js +45 -15
- package/dist/ui/components/Prompt/Dialog.js +23 -7
- package/dist/ui/components/Prompt/Modal.js +55 -25
- package/dist/ui/components/Prompt/index.js +18 -2
- package/dist/ui/components/RowOrColumn/index.js +17 -7
- package/dist/ui/components/Search/AutoHideSearchBox.js +56 -24
- package/dist/ui/components/Search/Base.js +52 -21
- package/dist/ui/components/Search/Dialog.js +26 -10
- package/dist/ui/components/Search/Inline.js +10 -3
- package/dist/ui/components/Search/Modal.js +17 -10
- package/dist/ui/components/Search/SearchBox.js +58 -26
- package/dist/ui/components/Search/index.js +23 -7
- package/dist/ui/components/Search/types.js +2 -1
- package/dist/ui/components/Sidebar/index.js +25 -18
- package/dist/ui/components/SparkLine/index.js +27 -17
- package/dist/ui/components/Table/index.js +22 -15
- package/dist/ui/components/TextEdit/CheckboxEdit.js +51 -21
- package/dist/ui/components/TextEdit/ColourEdit.js +44 -17
- package/dist/ui/components/TextEdit/LengthBox.js +12 -5
- package/dist/ui/components/TextEdit/ListboxEdit.js +42 -15
- package/dist/ui/components/TextEdit/RadioGroup.js +43 -13
- package/dist/ui/components/TextEdit/TextEdit.js +78 -48
- package/dist/ui/components/TextEdit/common.js +17 -11
- package/dist/ui/components/TextEdit/index.js +22 -6
- package/dist/ui/components/TextEdit/types.js +2 -1
- package/dist/ui/components/TextWithButton/index.js +40 -10
- package/dist/ui/components/TimelineChart/index.js +24 -14
- package/dist/ui/components/Toast/Cross.js +16 -9
- package/dist/ui/components/Toast/Tick.js +11 -4
- package/dist/ui/components/Toast/Warning.js +15 -8
- package/dist/ui/components/Toast/base.js +65 -33
- package/dist/ui/components/Toast/index.js +18 -2
- package/dist/ui/components/Toast/types.js +2 -1
- package/dist/ui/components/UserImage/index.js +48 -17
- package/dist/ui/components/index.js +46 -30
- package/dist/ui/helpers/axiosHelper.js +39 -25
- package/dist/ui/helpers/browserHelpers.js +22 -7
- package/dist/ui/helpers/callOpenApi/cached.js +37 -18
- package/dist/ui/helpers/callOpenApi/direct.js +59 -46
- package/dist/ui/helpers/callOpenApi/helpers.js +40 -25
- package/dist/ui/helpers/callOpenApi/hook.js +36 -47
- package/dist/ui/helpers/callOpenApi/index.js +21 -5
- package/dist/ui/helpers/callOpenApi/types.js +2 -1
- package/dist/ui/helpers/cognito.js +2 -1
- package/dist/ui/helpers/cookie/const.js +5 -2
- package/dist/ui/helpers/cookie/get.js +14 -13
- package/dist/ui/helpers/cookie/index.js +21 -5
- package/dist/ui/helpers/cookie/raw.js +16 -9
- package/dist/ui/helpers/cookie/set.js +15 -10
- package/dist/ui/helpers/cookie/use.js +16 -23
- package/dist/ui/helpers/date.js +15 -10
- package/dist/ui/helpers/debounce.js +10 -5
- package/dist/ui/helpers/dom.js +13 -6
- package/dist/ui/helpers/extractAttributes.js +7 -2
- package/dist/ui/helpers/index.js +41 -25
- package/dist/ui/helpers/jwt.js +2 -1
- package/dist/ui/helpers/plural.js +5 -1
- package/dist/ui/helpers/routes.js +24 -17
- package/dist/ui/helpers/serviceWorker.js +23 -8
- package/dist/ui/helpers/useContextMenu.js +14 -9
- package/dist/ui/helpers/useElementAttribute.js +7 -3
- package/dist/ui/helpers/useGranularHook.js +10 -5
- package/dist/ui/helpers/useInterval.js +12 -8
- package/dist/ui/helpers/useLocalStorage.js +32 -24
- package/dist/ui/helpers/useLockBodyScroll.js +7 -3
- package/dist/ui/helpers/useOnClickOutside.js +12 -7
- package/dist/ui/helpers/useOnScroll.js +21 -15
- package/dist/ui/helpers/useOverloadPageSearch.js +7 -3
- package/dist/ui/helpers/useQueryString.js +20 -14
- package/dist/ui/helpers/useResize.js +19 -17
- package/dist/ui/helpers/useTimeout.js +9 -5
- package/dist/ui/icons/ChevronRight.js +9 -3
- package/dist/ui/icons/CrossIcon.js +12 -5
- package/dist/ui/icons/Door.js +10 -4
- package/dist/ui/icons/HorizontalDots.js +9 -3
- package/dist/ui/icons/Magnify.js +10 -3
- package/dist/ui/icons/Pencil.js +12 -5
- package/dist/ui/icons/Save.js +11 -4
- package/dist/ui/icons/Undo.js +12 -5
- package/dist/ui/icons/UserOutline.js +9 -3
- package/dist/ui/icons/index.js +25 -9
- package/dist/ui/index.js +20 -4
- package/dist/ui/styles/colours.js +12 -7
- package/dist/ui/styles/common.js +22 -14
- package/dist/ui/styles/index.js +20 -4
- package/dist/ui/styles/media.js +10 -7
- package/dist/ui/styles/standaloneStyles.js +16 -10
- package/package.json +2 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
+
const base64ToBinary = (raw) => toBuffer(toArrayBuffer(raw));
|
|
43
|
+
exports.base64ToBinary = base64ToBinary;
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
20
|
-
const ticksSince = (highDate
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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]
|
|
18
|
+
return (_a = res[lang]) !== null && _a !== void 0 ? _a : res.en;
|
|
14
19
|
};
|
|
15
|
-
|
|
20
|
+
exports.t = t;
|
|
21
|
+
const useTranslation = (texts, lang) => {
|
|
16
22
|
const ret = (lineText) => {
|
|
17
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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,32 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
10
|
+
const SetLogShim = (ls) => {
|
|
7
11
|
logShim = ls;
|
|
8
12
|
};
|
|
13
|
+
exports.SetLogShim = SetLogShim;
|
|
9
14
|
let userLogLevel;
|
|
10
|
-
|
|
11
|
-
const lu = l
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
132
|
+
const trace = (...args) => {
|
|
124
133
|
args.push(printStackTrace());
|
|
125
134
|
logprocess('TRACE', args);
|
|
126
135
|
};
|
|
127
|
-
|
|
136
|
+
exports.trace = trace;
|
|
137
|
+
const error = (...args) => {
|
|
128
138
|
args.push(printStackTrace());
|
|
129
139
|
logprocess('ERROR', args);
|
|
130
140
|
};
|
|
131
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
+
exports.clamp = clamp;
|
|
37
|
+
function sumArray(array) {
|
|
31
38
|
return array.reduce((a, b) => a + b, 0);
|
|
32
39
|
}
|
|
33
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
76
|
+
const interpolatePercentInRange = ({ percent, min, max, }) => (max - min) * percent + min;
|
|
77
|
+
exports.interpolatePercentInRange = interpolatePercentInRange;
|