@arkyn/shared 3.0.1-beta.160 → 3.0.1-beta.166
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/generators/generateId.d.ts.map +1 -1
- package/dist/index.js +343 -344
- package/dist/modules/formats/formatDate.js +33 -40
- package/dist/modules/formats/formatJsonObject.js +22 -31
- package/dist/modules/formats/formatJsonString.js +10 -12
- package/dist/modules/formats/formatToCapitalizeFirstWordLetter.js +5 -8
- package/dist/modules/formats/formatToCep.js +8 -8
- package/dist/modules/formats/formatToCnpj.js +8 -8
- package/dist/modules/formats/formatToCpf.js +8 -8
- package/dist/modules/formats/formatToCurrency.js +12 -14
- package/dist/modules/formats/formatToEllipsis.js +9 -10
- package/dist/modules/formats/formatToHiddenDigits.js +21 -11
- package/dist/modules/formats/formatToPhone.js +13 -16
- package/dist/modules/generators/generateColorByString.js +7 -8
- package/dist/modules/generators/generateId.js +28 -22
- package/dist/modules/generators/generateSlug.js +6 -6
- package/dist/modules/index.js +26 -52
- package/dist/modules/parsers/parseLargeFields.js +16 -21
- package/dist/modules/parsers/parseSensitiveData.js +27 -25
- package/dist/modules/parsers/parseToDate.js +22 -26
- package/dist/modules/services/validateDateService.js +60 -58
- package/dist/modules/utilities/calculateCardInstallment.js +16 -20
- package/dist/modules/utilities/ensureQuotes.js +6 -6
- package/dist/modules/utilities/findCountryMask.js +22 -24
- package/dist/modules/utilities/isHtml.js +5 -5
- package/dist/modules/utilities/removeCurrencySymbols.js +5 -5
- package/dist/modules/utilities/removeNonNumeric.js +5 -5
- package/dist/modules/utilities/stripHtmlTags.js +5 -5
- package/package.json +16 -12
|
@@ -1,42 +1,35 @@
|
|
|
1
|
-
import { ValidateDateService as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(i) => m[i]
|
|
15
|
-
);
|
|
1
|
+
import { ValidateDateService as e } from "../services/validateDateService.js";
|
|
2
|
+
//#region src/formats/formatDate.ts
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
let n = (e) => e.toString().padStart(2, "0"), r = {
|
|
5
|
+
YYYY: e.getUTCFullYear().toString(),
|
|
6
|
+
YY: e.getUTCFullYear().toString().slice(-2),
|
|
7
|
+
MM: n(e.getUTCMonth() + 1),
|
|
8
|
+
DD: n(e.getUTCDate()),
|
|
9
|
+
hh: n(e.getUTCHours()),
|
|
10
|
+
mm: n(e.getUTCMinutes()),
|
|
11
|
+
ss: n(e.getUTCSeconds())
|
|
12
|
+
};
|
|
13
|
+
return t.replace(/YYYY|YY|MM|DD|hh|mm|ss/g, (e) => r[e]);
|
|
16
14
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Date.UTC(s, r - 1, a, g, u, Y)
|
|
36
|
-
);
|
|
37
|
-
if (isNaN(o.getTime())) throw new Error("Invalid date");
|
|
38
|
-
return o.setUTCHours(o.getUTCHours() + i), T(o, m);
|
|
15
|
+
function n([n, r = "00:00:00"], i, a, o = 0) {
|
|
16
|
+
let s = new e();
|
|
17
|
+
s.validateInputFormat(i);
|
|
18
|
+
let c = n.split(/[-/]/).map(Number), l = r.split(".")[0].split(":").map(Number), u, d, f, [p = 0, m = 0, h = 0] = l;
|
|
19
|
+
switch (i) {
|
|
20
|
+
case "brazilianDate":
|
|
21
|
+
[u, d, f] = c, s.validateDateParts(f, d, u);
|
|
22
|
+
break;
|
|
23
|
+
case "isoDate":
|
|
24
|
+
[d, u, f] = c, s.validateDateParts(f, d, u);
|
|
25
|
+
break;
|
|
26
|
+
case "timestamp":
|
|
27
|
+
[f, d, u] = c, s.validateDateParts(f, d, u);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
let g = new Date(Date.UTC(f, d - 1, u, p, m, h));
|
|
31
|
+
if (isNaN(g.getTime())) throw Error("Invalid date");
|
|
32
|
+
return g.setUTCHours(g.getUTCHours() + o), t(g, a);
|
|
39
33
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { n as formatDate };
|
|
@@ -1,32 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const r = JSON.parse(e);
|
|
22
|
-
t += l(r, f);
|
|
23
|
-
} catch {
|
|
24
|
-
t += '"' + e + '"';
|
|
25
|
-
}
|
|
26
|
-
else
|
|
27
|
-
t += e;
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
l as formatJsonObject
|
|
1
|
+
//#region src/formats/formatJsonObject.ts
|
|
2
|
+
var e = (t, n) => {
|
|
3
|
+
let r = " ".repeat(n), i = "";
|
|
4
|
+
if (typeof t == "object" && t) if (Array.isArray(t)) t.length === 0 ? i += "[]" : (i += "[\n", t.forEach((a, o) => {
|
|
5
|
+
i += r + " " + e(a, n + 1), o < t.length - 1 && (i += ","), i += "\n";
|
|
6
|
+
}), i += r + "]");
|
|
7
|
+
else {
|
|
8
|
+
let a = Object.keys(t);
|
|
9
|
+
a.length === 0 ? i += "{}" : (i += "{\n", a.forEach((o, s) => {
|
|
10
|
+
i += r + " \"" + o + "\": " + e(t[o], n + 1), s < a.length - 1 && (i += ","), i += "\n";
|
|
11
|
+
}), i += r + "}");
|
|
12
|
+
}
|
|
13
|
+
else if (typeof t == "string") try {
|
|
14
|
+
let r = JSON.parse(t);
|
|
15
|
+
i += e(r, n);
|
|
16
|
+
} catch {
|
|
17
|
+
i += "\"" + t + "\"";
|
|
18
|
+
}
|
|
19
|
+
else i += t;
|
|
20
|
+
return i;
|
|
32
21
|
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { e as formatJsonObject };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { formatJsonObject as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
e as formatJsonString
|
|
1
|
+
import { formatJsonObject as e } from "./formatJsonObject.js";
|
|
2
|
+
//#region src/formats/formatJsonString.ts
|
|
3
|
+
var t = (t) => {
|
|
4
|
+
try {
|
|
5
|
+
return e(JSON.parse(t), 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
throw Error(`Invalid JSON string \n ${e}`);
|
|
8
|
+
}
|
|
13
9
|
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as formatJsonString };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return o + e;
|
|
5
|
-
}).join(" ");
|
|
1
|
+
//#region src/formats/formatToCapitalizeFirstWordLetter.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e.split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ");
|
|
6
4
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
5
|
+
//#endregion
|
|
6
|
+
export { e as formatToCapitalizeFirstWordLetter };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { removeNonNumeric as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { removeNonNumeric as e } from "../utilities/removeNonNumeric.js";
|
|
2
|
+
//#region src/formats/formatToCep.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = e(t).match(/^(\d{5})(\d{3})$/), r = `CEP must be contain 8 numeric digits: ${t}`;
|
|
5
|
+
if (!n) throw Error(r);
|
|
6
|
+
return `${n[1]}-${n[2]}`;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as formatToCep };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { removeNonNumeric as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { removeNonNumeric as e } from "../utilities/removeNonNumeric.js";
|
|
2
|
+
//#region src/formats/formatToCnpj.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = e(t).match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/), r = `CNPJ must be contain 14 numeric digits: ${t}`;
|
|
5
|
+
if (!n) throw Error(r);
|
|
6
|
+
return `${n[1]}.${n[2]}.${n[3]}/${n[4]}-${n[5]}`;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as formatToCnpj };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { removeNonNumeric as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { removeNonNumeric as e } from "../utilities/removeNonNumeric.js";
|
|
2
|
+
//#region src/formats/formatToCpf.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = e(t).match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/), r = `CPF must be contain 11 numeric digits: ${t}`;
|
|
5
|
+
if (!n) throw Error(r);
|
|
6
|
+
return `${n[1]}.${n[2]}.${n[3]}-${n[4]}`;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as formatToCpf };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return c ? o.replace(/\s/g, " ") : y(o).replace(/\s/g, " ");
|
|
1
|
+
import { removeCurrencySymbols as e } from "../utilities/removeCurrencySymbols.js";
|
|
2
|
+
import { countryCurrencies as t } from "@arkyn/templates";
|
|
3
|
+
//#region src/formats/formatToCurrency.ts
|
|
4
|
+
function n(n, r, i) {
|
|
5
|
+
if (!t?.[r]) throw Error("Unsupported currency code");
|
|
6
|
+
let a = i?.showPrefix ?? !0, { countryCurrency: o, countryLanguage: s } = t[r], c = new Intl.NumberFormat(s, {
|
|
7
|
+
style: "currency",
|
|
8
|
+
currency: o
|
|
9
|
+
}).format(n);
|
|
10
|
+
return a ? c.replace(/\s/g, " ") : e(c).replace(/\s/g, " ");
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as formatToCurrency };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/formats/formatToEllipsis.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (e.length > t) {
|
|
4
|
+
let n = e.substring(0, t), r = n.lastIndexOf(" ");
|
|
5
|
+
return r > 0 && (n = n.substring(0, r)), n = n.replace(/[\s.,!?;:]+$/, ""), n.trim().length === 0 || /^[.,!?;:\s]+$/.test(n) ? "..." : `${n}...`;
|
|
6
|
+
}
|
|
7
|
+
return e;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as formatToEllipsis };
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//#region src/formats/formatToHiddenDigits.ts
|
|
2
|
+
var e = /^\d$/, t = (t) => {
|
|
3
|
+
let n = 0, r = t.split("").map((t) => e.test(t) ? {
|
|
4
|
+
character: t,
|
|
5
|
+
kind: "digit",
|
|
6
|
+
digit: ++n
|
|
7
|
+
} : {
|
|
8
|
+
character: t,
|
|
9
|
+
kind: "other"
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
digits: n,
|
|
13
|
+
children: r,
|
|
14
|
+
kind: "root"
|
|
15
|
+
};
|
|
16
|
+
}, n = (e, t) => Array.isArray(e) ? e : e >= 0 ? [0, e] : [t + 1 - Math.abs(e), t], r = (e, t) => t >= e[0] && t <= e[1];
|
|
17
|
+
function i(e, i) {
|
|
18
|
+
let a = t(e), o = n(i?.range ?? 3, a.digits);
|
|
19
|
+
return a.children.map((e) => e.kind === "digit" && r(o, e.digit) ? i?.hider ?? "*" : e.character).join("");
|
|
9
20
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { i as formatToHiddenDigits };
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throw new Error(o.message);
|
|
13
|
-
}
|
|
1
|
+
import { findCountryMask as e } from "../utilities/findCountryMask.js";
|
|
2
|
+
import { parsePhoneNumberWithError as t } from "libphonenumber-js";
|
|
3
|
+
//#region src/formats/formatToPhone.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
try {
|
|
6
|
+
let r = t(n).nationalNumber.toString(), i = e(n)[0];
|
|
7
|
+
for (let e = 0, t = 0; e < i.length && t < r.length; e++) i[e] === "_" && (i = i.substring(0, e) + r[t] + i.substring(e + 1), t++);
|
|
8
|
+
return i;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
throw Error(e.message);
|
|
11
|
+
}
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as formatToPhone };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//#region src/generators/generateColorByString.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
for (var t = 0, n = 0; n < e.length; n++) t = e.charCodeAt(n) + ((t << 5) - t);
|
|
4
|
+
var r = (t & 16711680) >> 16, i = (t & 65280) >> 8, a = t & 255, o = r.toString(16).padStart(2, "0"), s = i.toString(16).padStart(2, "0"), c = a.toString(16).padStart(2, "0");
|
|
5
|
+
return "#" + o + s + c;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as generateColorByString };
|
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return r;
|
|
1
|
+
//#region src/generators/generateId.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
e = e.replace(/-/g, "");
|
|
4
|
+
let t = new Uint8Array(e.length / 2);
|
|
5
|
+
for (let n = 0; n < e.length; n += 2) t[n / 2] = parseInt(e.substring(n, n + 2), 16);
|
|
6
|
+
return t;
|
|
8
7
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function t() {
|
|
9
|
+
let t = crypto.randomUUID();
|
|
10
|
+
return {
|
|
11
|
+
text: t,
|
|
12
|
+
binary: e(t)
|
|
13
|
+
};
|
|
12
14
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
function n() {
|
|
16
|
+
let t = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)), n = BigInt(Date.now());
|
|
17
|
+
t[0] = Number(n >> 40n & 255n), t[1] = Number(n >> 32n & 255n), t[2] = Number(n >> 24n & 255n), t[3] = Number(n >> 16n & 255n), t[4] = Number(n >> 8n & 255n), t[5] = Number(n & 255n), t[6] = t[6] & 15 | 112, t[8] = t[8] & 63 | 128;
|
|
18
|
+
let r = [...t].map((e) => e.toString(16).padStart(2, "0")).join("").replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
|
|
19
|
+
return {
|
|
20
|
+
text: r,
|
|
21
|
+
binary: e(r)
|
|
22
|
+
};
|
|
16
23
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
function r(e, r) {
|
|
25
|
+
if (e === "text" && r === "v4") return t().text;
|
|
26
|
+
if (e === "binary" && r === "v4") return t().binary;
|
|
27
|
+
if (e === "text" && r === "v7") return n().text;
|
|
28
|
+
if (e === "binary" && r === "v7") return n().binary;
|
|
29
|
+
throw Error("Invalid type or format");
|
|
23
30
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { r as generateId };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/generators/generateSlug.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = e.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
4
|
+
return t = t.replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").toLowerCase(), t = t.replace(/-{2,}/g, "-"), t = t.replace(/^-+|-+$/g, ""), t;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as generateSlug };
|
package/dist/modules/index.js
CHANGED
|
@@ -1,52 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { stripHtmlTags as
|
|
26
|
-
export {
|
|
27
|
-
M as ValidateDateService,
|
|
28
|
-
P as calculateCardInstallment,
|
|
29
|
-
V as ensureQuotes,
|
|
30
|
-
q as findCountryMask,
|
|
31
|
-
e as formatDate,
|
|
32
|
-
m as formatJsonObject,
|
|
33
|
-
p as formatJsonString,
|
|
34
|
-
x as formatToCapitalizeFirstWordLetter,
|
|
35
|
-
n as formatToCep,
|
|
36
|
-
l as formatToCnpj,
|
|
37
|
-
g as formatToCpf,
|
|
38
|
-
d as formatToCurrency,
|
|
39
|
-
c as formatToEllipsis,
|
|
40
|
-
y as formatToHiddenDigits,
|
|
41
|
-
v as formatToPhone,
|
|
42
|
-
b as generateColorByString,
|
|
43
|
-
F as generateId,
|
|
44
|
-
J as generateSlug,
|
|
45
|
-
A as isHtml,
|
|
46
|
-
N as parseLargeFields,
|
|
47
|
-
k as parseSensitiveData,
|
|
48
|
-
B as parseToDate,
|
|
49
|
-
K as removeCurrencySymbols,
|
|
50
|
-
U as removeNonNumeric,
|
|
51
|
-
Y as stripHtmlTags
|
|
52
|
-
};
|
|
1
|
+
import { ValidateDateService as e } from "./services/validateDateService.js";
|
|
2
|
+
import { formatDate as t } from "./formats/formatDate.js";
|
|
3
|
+
import { formatJsonObject as n } from "./formats/formatJsonObject.js";
|
|
4
|
+
import { formatJsonString as r } from "./formats/formatJsonString.js";
|
|
5
|
+
import { formatToCapitalizeFirstWordLetter as i } from "./formats/formatToCapitalizeFirstWordLetter.js";
|
|
6
|
+
import { removeNonNumeric as a } from "./utilities/removeNonNumeric.js";
|
|
7
|
+
import { formatToCep as o } from "./formats/formatToCep.js";
|
|
8
|
+
import { formatToCnpj as s } from "./formats/formatToCnpj.js";
|
|
9
|
+
import { formatToCpf as c } from "./formats/formatToCpf.js";
|
|
10
|
+
import { removeCurrencySymbols as l } from "./utilities/removeCurrencySymbols.js";
|
|
11
|
+
import { formatToCurrency as u } from "./formats/formatToCurrency.js";
|
|
12
|
+
import { formatToEllipsis as d } from "./formats/formatToEllipsis.js";
|
|
13
|
+
import { formatToHiddenDigits as f } from "./formats/formatToHiddenDigits.js";
|
|
14
|
+
import { findCountryMask as p } from "./utilities/findCountryMask.js";
|
|
15
|
+
import { formatToPhone as m } from "./formats/formatToPhone.js";
|
|
16
|
+
import { generateColorByString as h } from "./generators/generateColorByString.js";
|
|
17
|
+
import { generateId as g } from "./generators/generateId.js";
|
|
18
|
+
import { generateSlug as _ } from "./generators/generateSlug.js";
|
|
19
|
+
import { parseLargeFields as v } from "./parsers/parseLargeFields.js";
|
|
20
|
+
import { parseSensitiveData as y } from "./parsers/parseSensitiveData.js";
|
|
21
|
+
import { parseToDate as b } from "./parsers/parseToDate.js";
|
|
22
|
+
import { calculateCardInstallment as x } from "./utilities/calculateCardInstallment.js";
|
|
23
|
+
import { ensureQuotes as S } from "./utilities/ensureQuotes.js";
|
|
24
|
+
import { isHtml as C } from "./utilities/isHtml.js";
|
|
25
|
+
import { stripHtmlTags as w } from "./utilities/stripHtmlTags.js";
|
|
26
|
+
export { e as ValidateDateService, x as calculateCardInstallment, S as ensureQuotes, p as findCountryMask, t as formatDate, n as formatJsonObject, r as formatJsonString, i as formatToCapitalizeFirstWordLetter, o as formatToCep, s as formatToCnpj, c as formatToCpf, u as formatToCurrency, d as formatToEllipsis, f as formatToHiddenDigits, m as formatToPhone, h as generateColorByString, g as generateId, _ as generateSlug, C as isHtml, v as parseLargeFields, y as parseSensitiveData, b as parseToDate, l as removeCurrencySymbols, a as removeNonNumeric, w as stripHtmlTags };
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return JSON.stringify(t);
|
|
16
|
-
} catch {
|
|
17
|
-
throw new Error("Invalid JSON string");
|
|
18
|
-
}
|
|
1
|
+
//#region src/parsers/parseLargeFields.ts
|
|
2
|
+
function e(e, t = 1e3) {
|
|
3
|
+
function n(e) {
|
|
4
|
+
return typeof e == "string" && e.length > t ? `To large information: field as ${e.length} characters` : e;
|
|
5
|
+
}
|
|
6
|
+
function r(e) {
|
|
7
|
+
return Array.isArray(e) ? e.map((e) => r(e)) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e, r(t)])) : n(e);
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
let t = r(JSON.parse(e));
|
|
11
|
+
return JSON.stringify(t);
|
|
12
|
+
} catch {
|
|
13
|
+
throw Error("Invalid JSON string");
|
|
14
|
+
}
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as parseLargeFields };
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
//#region src/parsers/parseSensitiveData.ts
|
|
2
|
+
function e(e, t = [
|
|
3
|
+
"password",
|
|
4
|
+
"confirmPassword",
|
|
5
|
+
"creditCard"
|
|
6
|
+
]) {
|
|
7
|
+
function n(e, n) {
|
|
8
|
+
return t.includes(e) ? "****" : n;
|
|
9
|
+
}
|
|
10
|
+
function r(e) {
|
|
11
|
+
return Array.isArray(e) ? e.map((e) => r(e)) : typeof e == "object" && e ? Object.keys(e).reduce((t, i) => {
|
|
12
|
+
let a = e[i];
|
|
13
|
+
if (typeof a == "string") try {
|
|
14
|
+
let e = JSON.parse(a);
|
|
15
|
+
typeof e == "object" && (a = JSON.stringify(r(e)));
|
|
16
|
+
} catch {}
|
|
17
|
+
return t[i] = r(n(i, a)), t;
|
|
18
|
+
}, {}) : e;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
let t = r(JSON.parse(e));
|
|
22
|
+
return JSON.stringify(t);
|
|
23
|
+
} catch {
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { e as parseSensitiveData };
|