ag-common 0.0.894 → 0.0.896
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/LICENSE.md +2 -3
- package/README.md +2 -2
- package/dist/api/helpers/acm.d.ts +1 -1
- package/dist/api/helpers/acm.js +3 -3
- package/dist/api/helpers/api.d.ts +2 -2
- package/dist/api/helpers/api.js +26 -22
- package/dist/api/helpers/apigw.js +4 -4
- package/dist/api/helpers/aws.js +2 -2
- package/dist/api/helpers/cosmos/delete.d.ts +1 -1
- package/dist/api/helpers/cosmos/delete.js +15 -16
- package/dist/api/helpers/cosmos/get.d.ts +3 -3
- package/dist/api/helpers/cosmos/get.js +26 -32
- package/dist/api/helpers/cosmos/index.d.ts +3 -3
- package/dist/api/helpers/cosmos/index.js +1 -1
- package/dist/api/helpers/cosmos/utils.d.ts +1 -1
- package/dist/api/helpers/cosmos/utils.js +3 -7
- package/dist/api/helpers/cosmos/write.d.ts +1 -1
- package/dist/api/helpers/cosmos/write.js +11 -12
- package/dist/api/helpers/dynamo/delete.d.ts +1 -1
- package/dist/api/helpers/dynamo/delete.js +3 -3
- package/dist/api/helpers/dynamo/get.d.ts +2 -2
- package/dist/api/helpers/dynamo/get.js +20 -14
- package/dist/api/helpers/dynamo/index.d.ts +10 -38
- package/dist/api/helpers/dynamo/index.js +4 -4
- package/dist/api/helpers/dynamo/set.d.ts +1 -1
- package/dist/api/helpers/dynamo/set.js +10 -10
- package/dist/api/helpers/dynamo/types.d.ts +3 -3
- package/dist/api/helpers/dynamo/types.js +1 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.d.ts +13 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.js +3 -4
- package/dist/api/helpers/google/apikey.js +1 -1
- package/dist/api/helpers/google/gemini.d.ts +1 -1
- package/dist/api/helpers/google/gemini.js +43 -45
- package/dist/api/helpers/google/index.d.ts +2 -2
- package/dist/api/helpers/index.d.ts +17 -17
- package/dist/api/helpers/retryOnError.js +6 -11
- package/dist/api/helpers/s3.d.ts +9 -9
- package/dist/api/helpers/s3.js +19 -16
- package/dist/api/helpers/ses.d.ts +1 -1
- package/dist/api/helpers/ses.js +9 -9
- package/dist/api/helpers/sqs.d.ts +1 -1
- package/dist/api/helpers/sqs.js +1 -1
- package/dist/api/helpers/ssm.d.ts +1 -1
- package/dist/api/helpers/ssm.js +2 -2
- package/dist/api/helpers/ssmInfra/apigw.d.ts +6 -6
- package/dist/api/helpers/ssmInfra/apigw.js +6 -10
- package/dist/api/helpers/ssmInfra/dynamo.d.ts +2 -2
- package/dist/api/helpers/ssmInfra/dynamo.js +1 -1
- package/dist/api/helpers/ssmInfra/index.d.ts +4 -4
- package/dist/api/helpers/ssmInfra/s3.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/s3.js +1 -1
- package/dist/api/helpers/ssmInfra/sqs.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/sqs.js +1 -1
- package/dist/api/helpers/sts.d.ts +1 -1
- package/dist/api/helpers/sts.js +4 -4
- package/dist/api/helpers/validations.d.ts +2 -2
- package/dist/api/helpers/validations.js +14 -14
- package/dist/api/helpers/zod.d.ts +1 -1
- package/dist/api/helpers/zod.js +21 -27
- package/dist/api/index.d.ts +2 -2
- package/dist/api/types/aws.d.ts +0 -56
- package/dist/api/types/aws.js +0 -1
- package/dist/api/types/index.d.ts +1 -1
- package/dist/common/helpers/array.js +9 -10
- package/dist/common/helpers/async.js +2 -2
- package/dist/common/helpers/binary.d.ts +1 -1
- package/dist/common/helpers/binary.js +1 -1
- package/dist/common/helpers/csv.d.ts +4 -2
- package/dist/common/helpers/csv.js +8 -12
- package/dist/common/helpers/date.d.ts +2 -4
- package/dist/common/helpers/date.js +2 -2
- package/dist/common/helpers/email.js +2 -2
- package/dist/common/helpers/fetch.js +8 -8
- package/dist/common/helpers/generator.js +2 -2
- package/dist/common/helpers/groupBy.js +0 -2
- package/dist/common/helpers/hashCode.js +2 -6
- package/dist/common/helpers/headers.d.ts +20 -20
- package/dist/common/helpers/headers.js +38 -38
- package/dist/common/helpers/i18n.d.ts +2 -2
- package/dist/common/helpers/i18n.js +5 -6
- package/dist/common/helpers/index.d.ts +25 -25
- package/dist/common/helpers/log.d.ts +1 -1
- package/dist/common/helpers/log.js +30 -30
- package/dist/common/helpers/math.d.ts +2 -2
- package/dist/common/helpers/math.js +6 -6
- package/dist/common/helpers/memo.d.ts +1 -1
- package/dist/common/helpers/memo.js +1 -3
- package/dist/common/helpers/node-cache.d.ts +2 -2
- package/dist/common/helpers/node-cache.js +0 -1
- package/dist/common/helpers/object.d.ts +1 -1
- package/dist/common/helpers/object.js +16 -27
- package/dist/common/helpers/secondsInNearest.js +5 -5
- package/dist/common/helpers/stream.js +4 -6
- package/dist/common/helpers/string/base64.js +2 -2
- package/dist/common/helpers/string/chunk.js +1 -1
- package/dist/common/helpers/string/contains.js +1 -3
- package/dist/common/helpers/string/getExtendedStringSegment.js +1 -1
- package/dist/common/helpers/string/index.d.ts +11 -11
- package/dist/common/helpers/string/json.js +1 -1
- package/dist/common/helpers/string/redact.js +38 -39
- package/dist/common/helpers/string/trim.js +4 -4
- package/dist/common/helpers/string/truncate.js +1 -1
- package/dist/common/helpers/string/url.js +7 -8
- package/dist/common/helpers/withRetry.js +7 -7
- package/dist/common/helpers/xml.d.ts +7 -3
- package/dist/common/helpers/xml.js +33 -36
- package/dist/common/index.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/node/helpers/fetch.js +1 -2
- package/dist/node/helpers/fs.js +2 -2
- package/dist/node/helpers/index.d.ts +2 -2
- package/dist/node/index.d.ts +1 -1
- package/dist/ui/components/DarkMode/Base.d.ts +4 -4
- package/dist/ui/components/DarkMode/Base.js +26 -31
- package/dist/ui/components/DarkMode/index.d.ts +2 -2
- package/dist/ui/components/DarkMode/types.d.ts +5 -5
- package/dist/ui/components/HeadersRaw/index.d.ts +2 -2
- package/dist/ui/components/HeadersRaw/index.js +5 -5
- package/dist/ui/components/Markdown/index.d.ts +1 -1
- package/dist/ui/components/Markdown/index.js +10 -10
- package/dist/ui/components/index.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.js +6 -6
- package/dist/ui/components/shadcn/alert.d.ts +2 -2
- package/dist/ui/components/shadcn/alert.js +6 -6
- package/dist/ui/components/shadcn/avatar.d.ts +2 -2
- package/dist/ui/components/shadcn/avatar.js +4 -4
- package/dist/ui/components/shadcn/button.d.ts +4 -4
- package/dist/ui/components/shadcn/button.js +14 -14
- package/dist/ui/components/shadcn/card.d.ts +2 -2
- package/dist/ui/components/shadcn/card.js +6 -6
- package/dist/ui/components/shadcn/checkbox.d.ts +2 -2
- package/dist/ui/components/shadcn/checkbox.js +3 -3
- package/dist/ui/components/shadcn/dialog.d.ts +10 -10
- package/dist/ui/components/shadcn/dialog.js +9 -11
- package/dist/ui/components/shadcn/divider.d.ts +1 -1
- package/dist/ui/components/shadcn/divider.js +1 -1
- package/dist/ui/components/shadcn/dropdown-list.d.ts +1 -1
- package/dist/ui/components/shadcn/dropdown-list.js +5 -5
- package/dist/ui/components/shadcn/dropdown-menu.d.ts +6 -6
- package/dist/ui/components/shadcn/dropdown-menu.js +11 -11
- package/dist/ui/components/shadcn/index.d.ts +21 -21
- package/dist/ui/components/shadcn/input-selector.d.ts +1 -1
- package/dist/ui/components/shadcn/input-selector.js +10 -12
- package/dist/ui/components/shadcn/input.d.ts +1 -1
- package/dist/ui/components/shadcn/input.js +1 -1
- package/dist/ui/components/shadcn/label.d.ts +3 -3
- package/dist/ui/components/shadcn/label.js +2 -2
- package/dist/ui/components/shadcn/popover.d.ts +2 -2
- package/dist/ui/components/shadcn/popover.js +3 -3
- package/dist/ui/components/shadcn/radio-group.d.ts +2 -2
- package/dist/ui/components/shadcn/radio-group.js +2 -2
- package/dist/ui/components/shadcn/scroll-area.d.ts +2 -2
- package/dist/ui/components/shadcn/scroll-area.js +3 -5
- package/dist/ui/components/shadcn/select.d.ts +2 -2
- package/dist/ui/components/shadcn/select.js +12 -12
- package/dist/ui/components/shadcn/sheet.d.ts +12 -12
- package/dist/ui/components/shadcn/sheet.js +15 -15
- package/dist/ui/components/shadcn/switch.d.ts +2 -2
- package/dist/ui/components/shadcn/switch.js +3 -3
- package/dist/ui/components/shadcn/textarea.d.ts +1 -1
- package/dist/ui/components/shadcn/textarea.js +1 -1
- package/dist/ui/components/shadcn/toast.d.ts +2 -2
- package/dist/ui/components/shadcn/toast.js +25 -25
- package/dist/ui/helpers/cognito.d.ts +1 -1
- package/dist/ui/helpers/cookie/const.js +1 -1
- package/dist/ui/helpers/cookie/get.js +3 -4
- package/dist/ui/helpers/cookie/index.d.ts +5 -5
- package/dist/ui/helpers/cookie/raw.d.ts +1 -1
- package/dist/ui/helpers/cookie/raw.js +8 -9
- package/dist/ui/helpers/cookie/use.d.ts +1 -1
- package/dist/ui/helpers/cookie/use.js +4 -4
- package/dist/ui/helpers/date.js +8 -8
- package/dist/ui/helpers/debounce.js +1 -1
- package/dist/ui/helpers/dom.d.ts +1 -1
- package/dist/ui/helpers/dom.js +4 -14
- package/dist/ui/helpers/index.d.ts +26 -26
- package/dist/ui/helpers/jwt.d.ts +3 -3
- package/dist/ui/helpers/openDialog.d.ts +2 -2
- package/dist/ui/helpers/openDialog.js +8 -8
- package/dist/ui/helpers/plural.js +1 -1
- package/dist/ui/helpers/routes.d.ts +2 -2
- package/dist/ui/helpers/routes.js +14 -15
- package/dist/ui/helpers/serviceWorker.js +1 -1
- package/dist/ui/helpers/useContextMenu.d.ts +1 -1
- package/dist/ui/helpers/useContextMenu.js +9 -10
- package/dist/ui/helpers/useElementAttribute.js +3 -5
- package/dist/ui/helpers/useGranularHook.d.ts +1 -1
- package/dist/ui/helpers/useGranularHook.js +2 -3
- package/dist/ui/helpers/useInterval.d.ts +2 -2
- package/dist/ui/helpers/useInterval.js +2 -2
- package/dist/ui/helpers/useIsInViewport.d.ts +1 -1
- package/dist/ui/helpers/useIsInViewport.js +0 -1
- package/dist/ui/helpers/useLocalStorage.js +6 -6
- package/dist/ui/helpers/useLockBodyScroll.js +2 -2
- package/dist/ui/helpers/useOnClickOutside.d.ts +1 -1
- package/dist/ui/helpers/useOnClickOutside.js +3 -6
- package/dist/ui/helpers/useOnScroll.d.ts +1 -1
- package/dist/ui/helpers/useOnScroll.js +3 -4
- package/dist/ui/helpers/useOverloadPageSearch.js +8 -10
- package/dist/ui/helpers/useQueryString.js +7 -7
- package/dist/ui/helpers/useResize.js +5 -6
- package/dist/ui/helpers/useTimeout.js +1 -1
- package/dist/ui/helpers/useTooltip.d.ts +2 -2
- package/dist/ui/helpers/useTooltip.js +5 -7
- package/dist/ui/helpers/utils.d.ts +2 -2
- package/dist/ui/icons/Checkmark.d.ts +2 -2
- package/dist/ui/icons/Checkmark.js +1 -1
- package/dist/ui/icons/ChevronRight.d.ts +1 -1
- package/dist/ui/icons/Circle.d.ts +2 -2
- package/dist/ui/icons/Circle.js +1 -1
- package/dist/ui/icons/CircleDot.d.ts +2 -2
- package/dist/ui/icons/Cog.d.ts +2 -2
- package/dist/ui/icons/Computer.d.ts +2 -2
- package/dist/ui/icons/Door.d.ts +1 -1
- package/dist/ui/icons/Hamburger.d.ts +1 -1
- package/dist/ui/icons/HorizontalDots.d.ts +1 -1
- package/dist/ui/icons/House.d.ts +2 -2
- package/dist/ui/icons/Magnify.d.ts +2 -2
- package/dist/ui/icons/Magnify.js +1 -1
- package/dist/ui/icons/Moon.d.ts +2 -2
- package/dist/ui/icons/Pencil.d.ts +1 -1
- package/dist/ui/icons/Save.d.ts +1 -1
- package/dist/ui/icons/Sun.d.ts +1 -1
- package/dist/ui/icons/Sun.js +1 -1
- package/dist/ui/icons/Undo.d.ts +1 -1
- package/dist/ui/icons/UserOutline.d.ts +1 -1
- package/dist/ui/icons/Warning.d.ts +2 -2
- package/dist/ui/icons/Warning.js +1 -1
- package/dist/ui/icons/index.d.ts +32 -74
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/styles/colours.js +29 -29
- package/dist/ui/styles/common.d.ts +1 -1
- package/dist/ui/styles/common.js +10 -10
- package/dist/ui/styles/index.d.ts +3 -3
- package/package.json +65 -75
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useTranslation = exports.t = exports.getValidatedLang = exports.AllLang = void 0;
|
|
4
|
-
exports.AllLang = [
|
|
4
|
+
exports.AllLang = ["en", "id", "vi", "pt"];
|
|
5
5
|
const getValidatedLang = (raw) => {
|
|
6
6
|
const f = exports.AllLang.find((l) => l === raw);
|
|
7
7
|
if (!f) {
|
|
8
|
-
return
|
|
8
|
+
return "en";
|
|
9
9
|
}
|
|
10
10
|
return f;
|
|
11
11
|
};
|
|
12
12
|
exports.getValidatedLang = getValidatedLang;
|
|
13
13
|
const t = (res, lang) => {
|
|
14
14
|
if (res[lang] === null) {
|
|
15
|
-
return
|
|
15
|
+
return "";
|
|
16
16
|
}
|
|
17
17
|
return res[lang] ?? res.en;
|
|
18
18
|
};
|
|
@@ -21,10 +21,9 @@ const useTranslation = (texts, lang) => {
|
|
|
21
21
|
const ret = (lineText) => {
|
|
22
22
|
const v1 = texts[lineText][lang];
|
|
23
23
|
if (v1 || v1 === null) {
|
|
24
|
-
return v1 ??
|
|
24
|
+
return v1 ?? "";
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
return texts[lineText].en ?? '???';
|
|
26
|
+
return texts[lineText].en ?? "???";
|
|
28
27
|
};
|
|
29
28
|
return ret;
|
|
30
29
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
1
|
+
export * from "./array";
|
|
2
|
+
export * from "./async";
|
|
3
|
+
export * from "./binary";
|
|
4
|
+
export * from "./csv";
|
|
5
|
+
export * from "./date";
|
|
6
|
+
export * from "./email";
|
|
7
|
+
export * from "./fetch";
|
|
8
|
+
export * from "./func";
|
|
9
|
+
export * from "./generator";
|
|
10
|
+
export * from "./groupBy";
|
|
11
|
+
export * from "./hashCode";
|
|
12
|
+
export * from "./headers";
|
|
13
|
+
export * from "./i18n";
|
|
14
|
+
export * from "./log";
|
|
15
|
+
export * from "./math";
|
|
16
|
+
export * from "./memo";
|
|
17
|
+
export * from "./node-cache";
|
|
18
|
+
export * from "./object";
|
|
19
|
+
export * from "./random";
|
|
20
|
+
export * from "./secondsInNearest";
|
|
21
|
+
export * from "./sleep";
|
|
22
|
+
export * from "./stream";
|
|
23
|
+
export * from "./string";
|
|
24
|
+
export * from "./withRetry";
|
|
25
|
+
export * from "./xml";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type TLogType =
|
|
1
|
+
export type TLogType = "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL";
|
|
2
2
|
export declare const GetLogLevel: (l: TLogType) => number;
|
|
3
3
|
export type TLogShim = (...args: unknown[]) => void;
|
|
4
4
|
/** if passed in, will use this instead of console.xxx */
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.fatal = exports.error = exports.trace = exports.warn = exports.info = exports.debug = exports.SetLogLevel = exports.SetLogShim = exports.GetLogLevel = void 0;
|
|
5
4
|
const array_1 = require("./array");
|
|
6
5
|
const redact_1 = require("./string/redact");
|
|
7
|
-
const GetLogLevel = (l) => [
|
|
6
|
+
const GetLogLevel = (l) => ["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"].findIndex((s) => s === l);
|
|
8
7
|
exports.GetLogLevel = GetLogLevel;
|
|
9
8
|
let logShim;
|
|
9
|
+
// oxlint-disable-next-line no-console -- console is the intentional fallback when no shim is set
|
|
10
|
+
const fallbackConsole = console;
|
|
10
11
|
/** if passed in, will use this instead of console.xxx */
|
|
11
12
|
const SetLogShim = (ls) => {
|
|
12
13
|
logShim = ls;
|
|
@@ -14,7 +15,7 @@ const SetLogShim = (ls) => {
|
|
|
14
15
|
exports.SetLogShim = SetLogShim;
|
|
15
16
|
let userLogLevel;
|
|
16
17
|
const SetLogLevel = (l) => {
|
|
17
|
-
const lu = (l ??
|
|
18
|
+
const lu = (l ?? "INFO").toUpperCase();
|
|
18
19
|
if ((0, exports.GetLogLevel)(lu) === -1) {
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
@@ -25,14 +26,14 @@ function logprocess(type, args) {
|
|
|
25
26
|
if (!userLogLevel) {
|
|
26
27
|
(0, exports.SetLogLevel)(process.env.LOG_LEVEL);
|
|
27
28
|
}
|
|
28
|
-
const min = (0, exports.GetLogLevel)(userLogLevel ??
|
|
29
|
+
const min = (0, exports.GetLogLevel)(userLogLevel ?? "WARN");
|
|
29
30
|
const typesLogLevel = (0, exports.GetLogLevel)(type);
|
|
30
31
|
// env ignores it
|
|
31
32
|
if (typesLogLevel < min) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
////////
|
|
35
|
-
const datetime = new Date().toLocaleTimeString(
|
|
36
|
+
const datetime = new Date().toLocaleTimeString("en-GB");
|
|
36
37
|
const log = [
|
|
37
38
|
`[${datetime}]`,
|
|
38
39
|
type,
|
|
@@ -53,32 +54,32 @@ function logprocess(type, args) {
|
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
56
|
switch (type) {
|
|
56
|
-
case
|
|
57
|
-
|
|
57
|
+
case "TRACE": {
|
|
58
|
+
fallbackConsole.trace(...log);
|
|
58
59
|
break;
|
|
59
60
|
}
|
|
60
|
-
case
|
|
61
|
-
|
|
61
|
+
case "DEBUG": {
|
|
62
|
+
fallbackConsole.debug(...log);
|
|
62
63
|
break;
|
|
63
64
|
}
|
|
64
|
-
case
|
|
65
|
-
|
|
65
|
+
case "INFO": {
|
|
66
|
+
fallbackConsole.log(...log);
|
|
66
67
|
break;
|
|
67
68
|
}
|
|
68
|
-
case
|
|
69
|
-
|
|
69
|
+
case "WARN": {
|
|
70
|
+
fallbackConsole.warn(...log);
|
|
70
71
|
break;
|
|
71
72
|
}
|
|
72
|
-
case
|
|
73
|
-
|
|
73
|
+
case "ERROR": {
|
|
74
|
+
fallbackConsole.error(...log);
|
|
74
75
|
break;
|
|
75
76
|
}
|
|
76
|
-
case
|
|
77
|
-
|
|
77
|
+
case "FATAL": {
|
|
78
|
+
fallbackConsole.error(...log);
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
80
81
|
default: {
|
|
81
|
-
|
|
82
|
+
fallbackConsole.log(...log);
|
|
82
83
|
break;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
@@ -87,13 +88,13 @@ function printStackTrace(...args) {
|
|
|
87
88
|
const callstack = [];
|
|
88
89
|
let isCallstackPopulated = false;
|
|
89
90
|
try {
|
|
90
|
-
throw new Error(
|
|
91
|
+
throw new Error("Test");
|
|
91
92
|
}
|
|
92
93
|
catch (e) {
|
|
93
94
|
const er = e;
|
|
94
95
|
if (er.stack) {
|
|
95
96
|
// Firefox / chrome
|
|
96
|
-
const lines = er.stack.split(
|
|
97
|
+
const lines = er.stack.split("\n");
|
|
97
98
|
for (let i = 0, len = lines.length; i < len; i += 1) {
|
|
98
99
|
callstack.push(` ${lines[i]} `);
|
|
99
100
|
}
|
|
@@ -104,7 +105,7 @@ function printStackTrace(...args) {
|
|
|
104
105
|
}
|
|
105
106
|
else if (window.opera && er.message) {
|
|
106
107
|
// Opera
|
|
107
|
-
const lines = er.message.split(
|
|
108
|
+
const lines = er.message.split("\n");
|
|
108
109
|
for (let i = 0, len = lines.length; i < len; i += 1) {
|
|
109
110
|
if (lines[i].match(/^\s*[A-Za-z0-9\-_$]+\(/)) {
|
|
110
111
|
let entry = lines[i];
|
|
@@ -127,33 +128,32 @@ function printStackTrace(...args) {
|
|
|
127
128
|
let currentFunction = args.callee.caller;
|
|
128
129
|
while (currentFunction) {
|
|
129
130
|
const fn = currentFunction.toString();
|
|
130
|
-
const fname = fn.substring(fn.indexOf(
|
|
131
|
-
'anonymous';
|
|
131
|
+
const fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) ?? "anonymous";
|
|
132
132
|
callstack.push(fname);
|
|
133
133
|
currentFunction = currentFunction.caller;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
return callstack.join(
|
|
136
|
+
return callstack.join("\n");
|
|
137
137
|
}
|
|
138
|
-
const debug = (...args) => logprocess(
|
|
138
|
+
const debug = (...args) => logprocess("DEBUG", args);
|
|
139
139
|
exports.debug = debug;
|
|
140
|
-
const info = (...args) => logprocess(
|
|
140
|
+
const info = (...args) => logprocess("INFO", args);
|
|
141
141
|
exports.info = info;
|
|
142
|
-
const warn = (...args) => logprocess(
|
|
142
|
+
const warn = (...args) => logprocess("WARN", args);
|
|
143
143
|
exports.warn = warn;
|
|
144
144
|
//
|
|
145
145
|
const trace = (...args) => {
|
|
146
146
|
args.push(printStackTrace());
|
|
147
|
-
logprocess(
|
|
147
|
+
logprocess("TRACE", args);
|
|
148
148
|
};
|
|
149
149
|
exports.trace = trace;
|
|
150
150
|
const error = (...args) => {
|
|
151
151
|
args.push(printStackTrace());
|
|
152
|
-
logprocess(
|
|
152
|
+
logprocess("ERROR", args);
|
|
153
153
|
};
|
|
154
154
|
exports.error = error;
|
|
155
155
|
const fatal = (...args) => {
|
|
156
156
|
args.push(printStackTrace());
|
|
157
|
-
logprocess(
|
|
157
|
+
logprocess("FATAL", args);
|
|
158
158
|
};
|
|
159
159
|
exports.fatal = fatal;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const toFixed: (num: number, fixed: number) => number;
|
|
2
2
|
export declare function roundToHalf(converted: number): number;
|
|
3
3
|
/** restricts value between two numbers */
|
|
4
|
-
export declare function clamp({ value, min, max
|
|
4
|
+
export declare function clamp({ value, min, max }: {
|
|
5
5
|
value: number;
|
|
6
6
|
min: number;
|
|
7
7
|
max: number;
|
|
@@ -15,7 +15,7 @@ export declare function toFixedDown(num: number, scale: number): number;
|
|
|
15
15
|
* @param param0
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
|
-
export declare function rangePercentage({ value, min, max
|
|
18
|
+
export declare function rangePercentage({ value, min, max }: {
|
|
19
19
|
value: number;
|
|
20
20
|
min: number;
|
|
21
21
|
max: number;
|
|
@@ -27,7 +27,7 @@ function roundToHalf(converted) {
|
|
|
27
27
|
return parseInt(converted.toString(), 10) + 0.5;
|
|
28
28
|
}
|
|
29
29
|
/** restricts value between two numbers */
|
|
30
|
-
function clamp({ value, min, max
|
|
30
|
+
function clamp({ value, min, max }) {
|
|
31
31
|
if (value < min) {
|
|
32
32
|
return min;
|
|
33
33
|
}
|
|
@@ -42,14 +42,14 @@ function sumArray(array) {
|
|
|
42
42
|
const isNumber = (num) => !isNaN(Number(num));
|
|
43
43
|
exports.isNumber = isNumber;
|
|
44
44
|
function toFixedDown(num, scale) {
|
|
45
|
-
if (!`${num}`.includes(
|
|
45
|
+
if (!`${num}`.includes("e")) {
|
|
46
46
|
// @ts-ignore
|
|
47
47
|
return +`${Math.round(`${num}e+${scale}`)}e-${scale}`;
|
|
48
48
|
}
|
|
49
|
-
const arr = `${num}`.split(
|
|
50
|
-
let sig =
|
|
49
|
+
const arr = `${num}`.split("e");
|
|
50
|
+
let sig = "";
|
|
51
51
|
if (+arr[1] + scale > 0) {
|
|
52
|
-
sig =
|
|
52
|
+
sig = "+";
|
|
53
53
|
}
|
|
54
54
|
// @ts-ignore
|
|
55
55
|
return +`${Math.round(`${+arr[0]}e${sig}${+arr[1] + scale}`)}e-${scale}`;
|
|
@@ -60,7 +60,7 @@ function toFixedDown(num, scale) {
|
|
|
60
60
|
* @param param0
|
|
61
61
|
* @returns
|
|
62
62
|
*/
|
|
63
|
-
function rangePercentage({ value, min, max
|
|
63
|
+
function rangePercentage({ value, min, max }) {
|
|
64
64
|
const v = clamp({ value, min, max });
|
|
65
65
|
const r = (v - min) / (max - min);
|
|
66
66
|
if (isNaN(r)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function memo<T>(func: (...
|
|
1
|
+
export declare function memo<T, TArgs extends unknown[]>(func: (...args: TArgs) => T, ...args: TArgs): T;
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.memo = memo;
|
|
4
4
|
const hashCode_1 = require("./hashCode");
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
5
|
const memoData = {};
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
6
|
function memo(func, ...args) {
|
|
9
7
|
const hc = (0, hashCode_1.hashCode)(JSON.stringify(args));
|
|
10
|
-
if (!memoData
|
|
8
|
+
if (!(hc in memoData)) {
|
|
11
9
|
memoData[hc] = func(...args);
|
|
12
10
|
}
|
|
13
11
|
return memoData[hc];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import NodeCache from
|
|
1
|
+
import NodeCache from "node-cache";
|
|
2
2
|
export interface CacheOptions {
|
|
3
3
|
stdTTL?: number;
|
|
4
4
|
checkperiod?: number;
|
|
@@ -7,7 +7,7 @@ export interface CacheOptions {
|
|
|
7
7
|
enableLegacyCallbacks?: boolean;
|
|
8
8
|
maxKeys?: number;
|
|
9
9
|
}
|
|
10
|
-
export declare class TypedNodeCache<T =
|
|
10
|
+
export declare class TypedNodeCache<T = unknown> {
|
|
11
11
|
private cache;
|
|
12
12
|
constructor(options?: CacheOptions);
|
|
13
13
|
/**
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TypedNodeCache = void 0;
|
|
7
7
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
8
|
class TypedNodeCache {
|
|
10
9
|
cache;
|
|
11
10
|
constructor(options = {}) {
|
|
@@ -55,7 +55,7 @@ export declare const castObject: <TIn, TOut>(orig: Record<string, TIn>, castF: (
|
|
|
55
55
|
*/
|
|
56
56
|
export declare const filterObject: <TA extends Record<string | number, TB>, TB>(orig: TA, filterF: (t: TB) => boolean) => Partial<TA>;
|
|
57
57
|
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
58
|
-
export declare const removeUndefValuesFromObject: <TA>(orig: Record<string, TA>) => Record<string, TA
|
|
58
|
+
export declare const removeUndefValuesFromObject: <TA>(orig: Record<string, TA>) => Record<string, Exclude<TA, null | undefined>>;
|
|
59
59
|
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
60
60
|
export declare const removeUndefValuesFromObjectAdditional: <T>(orig: Record<string, T>,
|
|
61
61
|
/** other than null or undefined */
|
|
@@ -11,32 +11,28 @@ const tryJsonParse = (str, defaultValue) => {
|
|
|
11
11
|
}
|
|
12
12
|
try {
|
|
13
13
|
return JSON.parse(str);
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
14
|
}
|
|
16
|
-
catch
|
|
15
|
+
catch {
|
|
17
16
|
return defaultValue;
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
19
|
exports.tryJsonParse = tryJsonParse;
|
|
21
20
|
function isJson(str) {
|
|
22
21
|
try {
|
|
23
|
-
JSON.parse(typeof str ===
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
+
JSON.parse(typeof str === "string" ? str : JSON.stringify(str));
|
|
25
23
|
}
|
|
26
|
-
catch
|
|
24
|
+
catch {
|
|
27
25
|
return false;
|
|
28
26
|
}
|
|
29
27
|
return true;
|
|
30
28
|
}
|
|
31
29
|
const objectKeysToLowerCase = (origObj) => {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
33
30
|
if (!origObj || Object.keys(origObj).length === 0) {
|
|
34
31
|
return {};
|
|
35
32
|
}
|
|
36
33
|
return Object.keys(origObj).reduce((newObj, key) => {
|
|
37
34
|
const val = origObj[key];
|
|
38
|
-
|
|
39
|
-
const newVal = typeof val === 'object'
|
|
35
|
+
const newVal = typeof val === "object"
|
|
40
36
|
? (0, exports.objectKeysToLowerCase)(val)
|
|
41
37
|
: val;
|
|
42
38
|
newObj[key.toLowerCase()] = newVal;
|
|
@@ -47,7 +43,6 @@ exports.objectKeysToLowerCase = objectKeysToLowerCase;
|
|
|
47
43
|
const getObjectKeysAsNumber = (o) => Object.keys(o).map((o2) => parseInt(o2, 10));
|
|
48
44
|
exports.getObjectKeysAsNumber = getObjectKeysAsNumber;
|
|
49
45
|
function objectToArray(obj) {
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
51
46
|
if (!obj) {
|
|
52
47
|
return [];
|
|
53
48
|
}
|
|
@@ -67,23 +62,19 @@ const objectAlphaSort = (object, depthLeft = -1) => {
|
|
|
67
62
|
if (depthLeft === 0) {
|
|
68
63
|
return object;
|
|
69
64
|
}
|
|
70
|
-
if (object
|
|
71
|
-
return (
|
|
65
|
+
if (Array.isArray(object)) {
|
|
66
|
+
return object.map((value) => (0, exports.objectAlphaSort)(value, depthLeft - 1));
|
|
67
|
+
}
|
|
68
|
+
if (object !== null && typeof object === "object") {
|
|
69
|
+
const source = object;
|
|
70
|
+
return Object.keys(source)
|
|
72
71
|
.sort((a, b) => (a.toLowerCase() < b.toLowerCase() ? -1 : 1))
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
72
|
.reduce((result, key) => {
|
|
75
|
-
|
|
76
|
-
result[key] = (0, exports.objectAlphaSort)(object[key], depthLeft - 1);
|
|
73
|
+
result[key] = (0, exports.objectAlphaSort)(source[key], depthLeft - 1);
|
|
77
74
|
return result;
|
|
78
|
-
}, {})
|
|
79
|
-
}
|
|
80
|
-
else if (Array.isArray(object)) {
|
|
81
|
-
//@ts-ignore
|
|
82
|
-
return object.map((obj) => (0, exports.objectAlphaSort)(obj, depthLeft - 1));
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return object;
|
|
75
|
+
}, {});
|
|
86
76
|
}
|
|
77
|
+
return object;
|
|
87
78
|
};
|
|
88
79
|
exports.objectAlphaSort = objectAlphaSort;
|
|
89
80
|
/**
|
|
@@ -110,9 +101,8 @@ function objectToString(obj,
|
|
|
110
101
|
joinKeyValue,
|
|
111
102
|
/** eg '&' */
|
|
112
103
|
joinKeys) {
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
114
104
|
if (!obj || Object.keys(obj).length === 0) {
|
|
115
|
-
return
|
|
105
|
+
return "";
|
|
116
106
|
}
|
|
117
107
|
const raw = Object.entries(obj).map(([key, value]) => key + joinKeyValue + value);
|
|
118
108
|
const ret = raw.join(joinKeys);
|
|
@@ -154,7 +144,6 @@ const removeUndefValuesFromObject = (orig) => {
|
|
|
154
144
|
const ret = {};
|
|
155
145
|
Object.entries(orig).forEach(([k, v]) => {
|
|
156
146
|
if (v !== null && v !== undefined) {
|
|
157
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
147
|
ret[k] = v;
|
|
159
148
|
}
|
|
160
149
|
});
|
|
@@ -183,13 +172,13 @@ const castStringlyObject = (orig) => {
|
|
|
183
172
|
const noundef = (0, exports.removeUndefValuesFromObject)(orig);
|
|
184
173
|
return (0, exports.castObject)(noundef, (s) => {
|
|
185
174
|
if (Array.isArray(s)) {
|
|
186
|
-
return s.join(
|
|
175
|
+
return s.join(",");
|
|
187
176
|
}
|
|
188
177
|
return s;
|
|
189
178
|
});
|
|
190
179
|
};
|
|
191
180
|
exports.castStringlyObject = castStringlyObject;
|
|
192
|
-
const isObject = (o) => o && typeof o ===
|
|
181
|
+
const isObject = (o) => o && typeof o === "object" && !Array.isArray(o);
|
|
193
182
|
exports.isObject = isObject;
|
|
194
183
|
const copy = (v) => JSON.parse(JSON.stringify(v));
|
|
195
184
|
exports.copy = copy;
|
|
@@ -15,24 +15,24 @@ const toFixed = (num, fixed) => {
|
|
|
15
15
|
*/
|
|
16
16
|
const secondsInNearest = ({ seconds, precision = 2, }) => {
|
|
17
17
|
if (seconds <= 0) {
|
|
18
|
-
return
|
|
18
|
+
return "Now";
|
|
19
19
|
}
|
|
20
20
|
if (seconds < 90) {
|
|
21
21
|
const v = toFixed(seconds, precision);
|
|
22
|
-
return `${v} ${v === 1 ?
|
|
22
|
+
return `${v} ${v === 1 ? "second" : "seconds"}`;
|
|
23
23
|
}
|
|
24
24
|
const mins = seconds / 60;
|
|
25
25
|
if (mins < 120) {
|
|
26
26
|
const v = toFixed(mins, precision);
|
|
27
|
-
return `${v} ${v === 1 ?
|
|
27
|
+
return `${v} ${v === 1 ? "minute" : "minutes"}`;
|
|
28
28
|
}
|
|
29
29
|
const hours = mins / 60;
|
|
30
30
|
if (hours < 24) {
|
|
31
31
|
const v = toFixed(hours, precision);
|
|
32
|
-
return `${v} ${v === 1 ?
|
|
32
|
+
return `${v} ${v === 1 ? "hour" : "hours"}`;
|
|
33
33
|
}
|
|
34
34
|
const days = hours / 24;
|
|
35
35
|
const v = toFixed(days, precision);
|
|
36
|
-
return `${v} ${v === 1 ?
|
|
36
|
+
return `${v} ${v === 1 ? "day" : "days"}`;
|
|
37
37
|
};
|
|
38
38
|
exports.secondsInNearest = secondsInNearest;
|
|
@@ -5,11 +5,10 @@ const log_1 = require("./log");
|
|
|
5
5
|
async function getStringFromStream(stream) {
|
|
6
6
|
const decoder = new TextDecoder();
|
|
7
7
|
const reader = stream.getReader();
|
|
8
|
-
let result =
|
|
8
|
+
let result = "";
|
|
9
9
|
try {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
11
10
|
while (true) {
|
|
12
|
-
//
|
|
11
|
+
// oxlint-disable-next-line no-await-in-loop -- stream chunks must be read sequentially
|
|
13
12
|
const { done, value } = await reader.read();
|
|
14
13
|
if (done)
|
|
15
14
|
break;
|
|
@@ -18,10 +17,9 @@ async function getStringFromStream(stream) {
|
|
|
18
17
|
// Append the chunk to the final result
|
|
19
18
|
result += chunkString;
|
|
20
19
|
}
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
20
|
}
|
|
23
|
-
catch
|
|
24
|
-
(0, log_1.error)(
|
|
21
|
+
catch {
|
|
22
|
+
(0, log_1.error)("error converting stream");
|
|
25
23
|
}
|
|
26
24
|
finally {
|
|
27
25
|
reader.releaseLock();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fromBase64 = exports.toBase64 = void 0;
|
|
4
4
|
const buffer_1 = require("buffer");
|
|
5
|
-
const toBase64 = (str) => buffer_1.Buffer.from(str).toString(
|
|
5
|
+
const toBase64 = (str) => buffer_1.Buffer.from(str).toString("base64");
|
|
6
6
|
exports.toBase64 = toBase64;
|
|
7
|
-
const fromBase64 = (str) => buffer_1.Buffer.from(decodeURIComponent(str),
|
|
7
|
+
const fromBase64 = (str) => buffer_1.Buffer.from(decodeURIComponent(str), "base64").toString();
|
|
8
8
|
exports.fromBase64 = fromBase64;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.chunkString = void 0;
|
|
4
|
-
const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`,
|
|
4
|
+
const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`, "g"));
|
|
5
5
|
exports.chunkString = chunkString;
|
|
@@ -49,9 +49,7 @@ function containsInsensitiveIndexes({ haystack, needle, fromLast = false, maxFou
|
|
|
49
49
|
if (indexes.length >= maxFound) {
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
|
-
lastIndex = fromLast
|
|
53
|
-
? lstr.lastIndexOf(needle, lastIndex)
|
|
54
|
-
: lstr.indexOf(needle, lastIndex);
|
|
52
|
+
lastIndex = fromLast ? lstr.lastIndexOf(needle, lastIndex) : lstr.indexOf(needle, lastIndex);
|
|
55
53
|
if (lastIndex === -1) {
|
|
56
54
|
break;
|
|
57
55
|
}
|
|
@@ -9,7 +9,7 @@ const contains_1 = require("./contains");
|
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
const getExtendedStringSegments = (p) => {
|
|
12
|
-
const { blocksOnEitherSide = 5, gapChars = [
|
|
12
|
+
const { blocksOnEitherSide = 5, gapChars = ["\n", "\r\n"], hay, needle } = p;
|
|
13
13
|
const fis = (0, contains_1.containsInsensitiveIndexes)({ haystack: hay, needle });
|
|
14
14
|
const founds = [];
|
|
15
15
|
fis.forEach((fi) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
1
|
+
export * from "./base64";
|
|
2
|
+
export * from "./chunk";
|
|
3
|
+
export * from "./contains";
|
|
4
|
+
export * from "./getExtendedStringSegment";
|
|
5
|
+
export * from "./json";
|
|
6
|
+
export * from "./object";
|
|
7
|
+
export * from "./redact";
|
|
8
|
+
export * from "./surround";
|
|
9
|
+
export * from "./trim";
|
|
10
|
+
export * from "./truncate";
|
|
11
|
+
export * from "./url";
|
|
@@ -9,7 +9,7 @@ exports.safeStringify = void 0;
|
|
|
9
9
|
*/
|
|
10
10
|
const safeStringify = (obj, indent = 2) => {
|
|
11
11
|
let cache = [];
|
|
12
|
-
const retVal = JSON.stringify(obj, (_key, value) => typeof value ===
|
|
12
|
+
const retVal = JSON.stringify(obj, (_key, value) => typeof value === "object" && value !== null
|
|
13
13
|
? cache.includes(value)
|
|
14
14
|
? undefined // Duplicate reference found, discard key
|
|
15
15
|
: cache.push(value) && value // Store value in our collection
|