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