@punks/backend-core 0.0.75 → 0.0.77
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/cjs/index.js +24 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/encoding.d.ts +5 -0
- package/dist/cjs/types/utils/index.d.ts +1 -0
- package/dist/cjs/types/utils/uid.d.ts +1 -0
- package/dist/cjs/types/utils/xls.d.ts +2 -0
- package/dist/esm/index.js +20 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/encoding.d.ts +5 -0
- package/dist/esm/types/utils/index.d.ts +1 -0
- package/dist/esm/types/utils/uid.d.ts +1 -0
- package/dist/esm/types/utils/xls.d.ts +2 -0
- package/dist/index.d.ts +13 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -440,6 +440,11 @@ const jsonSerialize = (obj, options) => {
|
|
|
440
440
|
return JSON.stringify(obj, replacer, spaces);
|
|
441
441
|
};
|
|
442
442
|
|
|
443
|
+
const encodeUtf8 = (value) => Buffer.from(value).toString("utf-8");
|
|
444
|
+
const decodeUtf8 = (value) => Buffer.from(value, "utf-8");
|
|
445
|
+
const encodeBase64 = (value) => Buffer.from(value).toString("base64");
|
|
446
|
+
const decodeBase64 = (value) => Buffer.from(value, "base64");
|
|
447
|
+
|
|
443
448
|
const maskVariable = (value, unmaskedLength = 4) => value
|
|
444
449
|
? value.substring(0, unmaskedLength).concat(Array.from(value.substring(unmaskedLength))
|
|
445
450
|
.map(() => "*")
|
|
@@ -506,6 +511,13 @@ const newUuid = () => {
|
|
|
506
511
|
return v.toString(16);
|
|
507
512
|
});
|
|
508
513
|
};
|
|
514
|
+
const generateHash = (length) => {
|
|
515
|
+
let text = "";
|
|
516
|
+
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
517
|
+
for (let i = 0; i < length; i++)
|
|
518
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
519
|
+
return text;
|
|
520
|
+
};
|
|
509
521
|
|
|
510
522
|
function serializeQueryString(obj) {
|
|
511
523
|
let queryString = "";
|
|
@@ -30999,17 +31011,14 @@ const aggregateRow = (header, row, options) => {
|
|
|
30999
31011
|
return record;
|
|
31000
31012
|
};
|
|
31001
31013
|
const excelParse = (file, options) => {
|
|
31002
|
-
const sheets = parseExcelRaw(file).
|
|
31003
|
-
|
|
31004
|
-
? sheets[0]
|
|
31005
|
-
: sheets.reduce((acc, sheet, index) => {
|
|
31006
|
-
acc[sheet.name || `Sheet${index + 1}`] = sheets[index];
|
|
31014
|
+
const sheets = parseExcelRaw(file).reduce((acc, sheet) => {
|
|
31015
|
+
if (options?.sheetFilter && !options.sheetFilter(sheet))
|
|
31007
31016
|
return acc;
|
|
31008
|
-
|
|
31009
|
-
|
|
31010
|
-
|
|
31011
|
-
|
|
31012
|
-
return
|
|
31017
|
+
const [header, ...rows] = sheet.data.filter((row) => isValidRow(row));
|
|
31018
|
+
acc.push(rows.map((row) => aggregateRow(header, row, options)));
|
|
31019
|
+
return acc;
|
|
31020
|
+
}, []);
|
|
31021
|
+
return sheets.length === 1 ? sheets[0] : sheets.flat();
|
|
31013
31022
|
};
|
|
31014
31023
|
|
|
31015
31024
|
const getLevelValue = (level) => {
|
|
@@ -31293,9 +31302,13 @@ exports.camelToSnakeCase = camelToSnakeCase;
|
|
|
31293
31302
|
exports.createDayPath = createDayPath;
|
|
31294
31303
|
exports.csvBuild = csvBuild;
|
|
31295
31304
|
exports.csvParse = csvParse;
|
|
31305
|
+
exports.decodeBase64 = decodeBase64;
|
|
31306
|
+
exports.decodeUtf8 = decodeUtf8;
|
|
31296
31307
|
exports.deserializeQueryString = deserializeQueryString;
|
|
31297
31308
|
exports.distinct = distinct;
|
|
31298
31309
|
exports.distinctElements = distinctElements;
|
|
31310
|
+
exports.encodeBase64 = encodeBase64;
|
|
31311
|
+
exports.encodeUtf8 = encodeUtf8;
|
|
31299
31312
|
exports.ensureDirectory = ensureDirectory;
|
|
31300
31313
|
exports.ensureStartSlash = ensureStartSlash;
|
|
31301
31314
|
exports.ensureTailingSlash = ensureTailingSlash;
|
|
@@ -31304,6 +31317,7 @@ exports.excelParse = excelParse;
|
|
|
31304
31317
|
exports.first = first;
|
|
31305
31318
|
exports.flatten = flatten;
|
|
31306
31319
|
exports.floorDateToSecond = floorDateToSecond;
|
|
31320
|
+
exports.generateHash = generateHash;
|
|
31307
31321
|
exports.getDirectoryFilePaths = getDirectoryFilePaths;
|
|
31308
31322
|
exports.getDirectoryPath = getDirectoryPath;
|
|
31309
31323
|
exports.getQueryParameter = getQueryParameter;
|