@punks/backend-core 0.0.79 → 0.0.81
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 +28 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/logging/service.d.ts +1 -0
- package/dist/cjs/types/utils/index.d.ts +1 -1
- package/dist/cjs/types/utils/objects/index.d.ts +2 -0
- package/dist/cjs/types/utils/objects/types.d.ts +3 -0
- package/dist/cjs/types/utils/strings.d.ts +1 -0
- package/dist/esm/index.js +27 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/logging/service.d.ts +1 -0
- package/dist/esm/types/utils/index.d.ts +1 -1
- package/dist/esm/types/utils/objects/index.d.ts +2 -0
- package/dist/esm/types/utils/objects/types.d.ts +3 -0
- package/dist/esm/types/utils/strings.d.ts +1 -0
- package/dist/index.d.ts +8 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ export { CsvColumnDefinition, CsvBuildOptions, csvBuild, csvParse } from "./csv"
|
|
|
5
5
|
export { getDirectoryFilePaths } from "./files";
|
|
6
6
|
export { joinPath, splitPath, ensureDirectory, getDirectoryPath, createDayPath, } from "./paths";
|
|
7
7
|
export * from "./strings";
|
|
8
|
-
export
|
|
8
|
+
export { buildObject, isNullOrUndefined, jsonSerialize, mergeDeep, removeUndefinedProps, replaceUndefinedWithNull, } from "./objects";
|
|
9
9
|
export * from "./encoding";
|
|
10
10
|
export { stripTags } from "./html";
|
|
11
11
|
export { maskVariable } from "./variables";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReplaceUndefinedWithNull } from "./types";
|
|
1
2
|
export declare const removeUndefinedProps: <T extends Record<string, any>>(obj: T, options?: {
|
|
2
3
|
recursive?: boolean;
|
|
3
4
|
}) => T;
|
|
@@ -14,3 +15,4 @@ export declare const jsonSerialize: (obj: any, options?: {
|
|
|
14
15
|
maxStringsLength?: number;
|
|
15
16
|
prettify?: boolean;
|
|
16
17
|
}) => string;
|
|
18
|
+
export declare function replaceUndefinedWithNull<T>(obj: T): ReplaceUndefinedWithNull<T>;
|
|
@@ -8,3 +8,4 @@ export declare const toTitleCase: (str: string) => string;
|
|
|
8
8
|
export declare const ensureTailingSlash: (value: string) => string;
|
|
9
9
|
export declare const ensureStartSlash: (value: string) => string;
|
|
10
10
|
export declare const multipleSplit: (str: string, separators: string[]) => string[];
|
|
11
|
+
export declare const truncateString: (str: string, maxLength: number, filler?: string) => string;
|
package/dist/esm/index.js
CHANGED
|
@@ -305,6 +305,7 @@ const multipleSplit = (str, separators) => {
|
|
|
305
305
|
.join("|");
|
|
306
306
|
return str.split(new RegExp(regexPattern));
|
|
307
307
|
};
|
|
308
|
+
const truncateString = (str, maxLength, filler = "...") => (str.length > maxLength ? str.substring(0, maxLength) + filler : str);
|
|
308
309
|
|
|
309
310
|
const removeUndefinedProps = (obj, options = { recursive: false }) => {
|
|
310
311
|
const { recursive } = options;
|
|
@@ -411,6 +412,24 @@ const jsonSerialize = (obj, options) => {
|
|
|
411
412
|
const spaces = prettify ? 2 : undefined;
|
|
412
413
|
return JSON.stringify(obj, replacer, spaces);
|
|
413
414
|
};
|
|
415
|
+
function replaceUndefinedWithNull(obj) {
|
|
416
|
+
if (obj === undefined) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
if (typeof obj !== "object" || obj === null) {
|
|
420
|
+
return obj;
|
|
421
|
+
}
|
|
422
|
+
if (Array.isArray(obj)) {
|
|
423
|
+
return obj.map(replaceUndefinedWithNull);
|
|
424
|
+
}
|
|
425
|
+
const newObj = {};
|
|
426
|
+
for (const key in obj) {
|
|
427
|
+
if (obj.hasOwnProperty(key)) {
|
|
428
|
+
newObj[key] = replaceUndefinedWithNull(obj[key]);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return newObj;
|
|
432
|
+
}
|
|
414
433
|
|
|
415
434
|
const encodeUtf8 = (value) => Buffer.from(value).toString("utf-8");
|
|
416
435
|
const decodeUtf8 = (value) => Buffer.from(value, "utf-8");
|
|
@@ -31228,15 +31247,15 @@ class InternalLogger {
|
|
|
31228
31247
|
if (meta && typeof meta === "string") {
|
|
31229
31248
|
return meta;
|
|
31230
31249
|
}
|
|
31231
|
-
const serializedMeta = meta
|
|
31232
|
-
|
|
31233
|
-
|
|
31234
|
-
|
|
31235
|
-
})
|
|
31236
|
-
: undefined;
|
|
31250
|
+
const serializedMeta = jsonSerialize(meta, {
|
|
31251
|
+
prettify: true,
|
|
31252
|
+
stripBinaryData: true,
|
|
31253
|
+
});
|
|
31237
31254
|
switch (options.serialization) {
|
|
31238
31255
|
case MetaSerializationType.JSON:
|
|
31239
|
-
return
|
|
31256
|
+
return options.maxMetaLength
|
|
31257
|
+
? truncateString(serializedMeta, options.maxMetaLength, "...")
|
|
31258
|
+
: serializedMeta;
|
|
31240
31259
|
case MetaSerializationType.None:
|
|
31241
31260
|
default:
|
|
31242
31261
|
return serializedMeta ? JSON.parse(serializedMeta) : undefined;
|
|
@@ -31448,5 +31467,5 @@ const processArrayItemMove = (items, input) => {
|
|
|
31448
31467
|
}));
|
|
31449
31468
|
};
|
|
31450
31469
|
|
|
31451
|
-
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, stripTags, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
|
|
31470
|
+
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, replaceUndefinedWithNull, selectMany, serializeQueryString, sleep, sort, splitPath, stripTags, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, truncateString, updateQueryParameters };
|
|
31452
31471
|
//# sourceMappingURL=index.js.map
|