@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
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare const encodeUtf8: (value: Uint8Array) => string;
|
|
3
|
+
export declare const decodeUtf8: (value: string) => Buffer;
|
|
4
|
+
export declare const encodeBase64: (value: Uint8Array) => string;
|
|
5
|
+
export declare const decodeBase64: (value: string) => Buffer;
|
|
@@ -6,6 +6,7 @@ export { getDirectoryFilePaths } from "./files";
|
|
|
6
6
|
export { joinPath, splitPath, ensureDirectory, getDirectoryPath, createDayPath, } from "./paths";
|
|
7
7
|
export * from "./strings";
|
|
8
8
|
export * from "./objects";
|
|
9
|
+
export * from "./encoding";
|
|
9
10
|
export { maskVariable } from "./variables";
|
|
10
11
|
export * from "./text";
|
|
11
12
|
export * from "./threading";
|
|
@@ -17,9 +17,11 @@ export declare enum ExcelKeyTransform {
|
|
|
17
17
|
Lower = "lower",
|
|
18
18
|
Upper = "upper"
|
|
19
19
|
}
|
|
20
|
+
export type ParsedExcelSheet = ReturnType<typeof parseExcelRaw>[number];
|
|
20
21
|
export type ExcelParseOptions = {
|
|
21
22
|
keysTransform?: ExcelKeyTransform;
|
|
22
23
|
sheetIndex?: number;
|
|
23
24
|
dateColumns?: string[];
|
|
25
|
+
sheetFilter?: (sheet: ParsedExcelSheet) => boolean;
|
|
24
26
|
};
|
|
25
27
|
export declare const excelParse: (file: string | ArrayBuffer, options?: ExcelParseOptions) => any;
|
package/dist/esm/index.js
CHANGED
|
@@ -412,6 +412,11 @@ const jsonSerialize = (obj, options) => {
|
|
|
412
412
|
return JSON.stringify(obj, replacer, spaces);
|
|
413
413
|
};
|
|
414
414
|
|
|
415
|
+
const encodeUtf8 = (value) => Buffer.from(value).toString("utf-8");
|
|
416
|
+
const decodeUtf8 = (value) => Buffer.from(value, "utf-8");
|
|
417
|
+
const encodeBase64 = (value) => Buffer.from(value).toString("base64");
|
|
418
|
+
const decodeBase64 = (value) => Buffer.from(value, "base64");
|
|
419
|
+
|
|
415
420
|
const maskVariable = (value, unmaskedLength = 4) => value
|
|
416
421
|
? value.substring(0, unmaskedLength).concat(Array.from(value.substring(unmaskedLength))
|
|
417
422
|
.map(() => "*")
|
|
@@ -478,6 +483,13 @@ const newUuid = () => {
|
|
|
478
483
|
return v.toString(16);
|
|
479
484
|
});
|
|
480
485
|
};
|
|
486
|
+
const generateHash = (length) => {
|
|
487
|
+
let text = "";
|
|
488
|
+
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
489
|
+
for (let i = 0; i < length; i++)
|
|
490
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
491
|
+
return text;
|
|
492
|
+
};
|
|
481
493
|
|
|
482
494
|
function serializeQueryString(obj) {
|
|
483
495
|
let queryString = "";
|
|
@@ -30971,17 +30983,14 @@ const aggregateRow = (header, row, options) => {
|
|
|
30971
30983
|
return record;
|
|
30972
30984
|
};
|
|
30973
30985
|
const excelParse = (file, options) => {
|
|
30974
|
-
const sheets = parseExcelRaw(file).
|
|
30975
|
-
|
|
30976
|
-
? sheets[0]
|
|
30977
|
-
: sheets.reduce((acc, sheet, index) => {
|
|
30978
|
-
acc[sheet.name || `Sheet${index + 1}`] = sheets[index];
|
|
30986
|
+
const sheets = parseExcelRaw(file).reduce((acc, sheet) => {
|
|
30987
|
+
if (options?.sheetFilter && !options.sheetFilter(sheet))
|
|
30979
30988
|
return acc;
|
|
30980
|
-
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
return
|
|
30989
|
+
const [header, ...rows] = sheet.data.filter((row) => isValidRow(row));
|
|
30990
|
+
acc.push(rows.map((row) => aggregateRow(header, row, options)));
|
|
30991
|
+
return acc;
|
|
30992
|
+
}, []);
|
|
30993
|
+
return sheets.length === 1 ? sheets[0] : sheets.flat();
|
|
30985
30994
|
};
|
|
30986
30995
|
|
|
30987
30996
|
const getLevelValue = (level) => {
|
|
@@ -31250,5 +31259,5 @@ const processArrayItemMove = (items, input) => {
|
|
|
31250
31259
|
}));
|
|
31251
31260
|
};
|
|
31252
31261
|
|
|
31253
|
-
export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, deserializeQueryString, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
|
|
31262
|
+
export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, decodeBase64, decodeUtf8, deserializeQueryString, distinct, distinctElements, encodeBase64, encodeUtf8, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, generateHash, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
|
|
31254
31263
|
//# sourceMappingURL=index.js.map
|