@punks/backend-core 0.0.35 → 0.0.37
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 +39 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/logging/service.d.ts +1 -3
- package/dist/cjs/types/utils/{objects.d.ts → objects/index.d.ts} +1 -0
- package/dist/esm/index.js +39 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/logging/service.d.ts +1 -3
- package/dist/esm/types/utils/{objects.d.ts → objects/index.d.ts} +1 -0
- package/dist/esm/types/utils/objects/mergeDeep.spec.d.ts +1 -0
- package/dist/esm/types/utils/objects/removeUndefinedProps.spec.d.ts +1 -0
- package/dist/index.d.ts +3 -4
- package/package.json +1 -1
- /package/dist/cjs/types/utils/{objects.test.d.ts → objects/mergeDeep.spec.d.ts} +0 -0
- /package/dist/{esm/types/utils/objects.test.d.ts → cjs/types/utils/objects/removeUndefinedProps.spec.d.ts} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -281,6 +281,21 @@ const buildObject = (...props) => {
|
|
|
281
281
|
}
|
|
282
282
|
return out;
|
|
283
283
|
};
|
|
284
|
+
const mergeDeep = (a, b) => {
|
|
285
|
+
const c = { ...(a ?? {}) };
|
|
286
|
+
for (const key in b ?? {}) {
|
|
287
|
+
if (b.hasOwnProperty(key)) {
|
|
288
|
+
const value = b[key];
|
|
289
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
290
|
+
c[key] = mergeDeep(c[key] ?? {}, value);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
c[key] = value;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return c;
|
|
298
|
+
};
|
|
284
299
|
|
|
285
300
|
const pluralize = (word) => {
|
|
286
301
|
return word.endsWith("s") ? `${word}es` : `${word}s`;
|
|
@@ -28423,44 +28438,42 @@ class DefaultLogger {
|
|
|
28423
28438
|
}
|
|
28424
28439
|
|
|
28425
28440
|
class InternalLogger {
|
|
28426
|
-
constructor(
|
|
28427
|
-
this.
|
|
28428
|
-
this.level = level;
|
|
28429
|
-
this.serialization = serialization;
|
|
28441
|
+
constructor(options, provider) {
|
|
28442
|
+
this.options = options;
|
|
28430
28443
|
this.provider = provider;
|
|
28431
28444
|
}
|
|
28432
28445
|
debug(message, meta) {
|
|
28433
|
-
if (this.enabled && this.level === exports.LogLevel.Debug) {
|
|
28446
|
+
if (this.options.enabled && this.options.level === exports.LogLevel.Debug) {
|
|
28434
28447
|
this.provider.debug(message, this.serializeMeta(meta));
|
|
28435
28448
|
}
|
|
28436
28449
|
}
|
|
28437
28450
|
info(message, meta) {
|
|
28438
|
-
if (this.enabled && this.level <= exports.LogLevel.Info) {
|
|
28451
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Info) {
|
|
28439
28452
|
this.provider.info(message, this.serializeMeta(meta));
|
|
28440
28453
|
}
|
|
28441
28454
|
}
|
|
28442
28455
|
warn(message, meta) {
|
|
28443
|
-
if (this.enabled && this.level <= exports.LogLevel.Warn) {
|
|
28456
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Warn) {
|
|
28444
28457
|
this.provider.warn(message, this.serializeMeta(meta));
|
|
28445
28458
|
}
|
|
28446
28459
|
}
|
|
28447
28460
|
error(message, meta) {
|
|
28448
|
-
if (this.enabled && this.level <= exports.LogLevel.Error) {
|
|
28461
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Error) {
|
|
28449
28462
|
this.provider.error(message, this.serializeMeta(meta));
|
|
28450
28463
|
}
|
|
28451
28464
|
}
|
|
28452
28465
|
fatal(message, meta) {
|
|
28453
|
-
if (this.enabled && this.level <= exports.LogLevel.Fatal) {
|
|
28466
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Fatal) {
|
|
28454
28467
|
this.provider.fatal(message, this.serializeMeta(meta));
|
|
28455
28468
|
}
|
|
28456
28469
|
}
|
|
28457
28470
|
exception(message, error, meta) {
|
|
28458
|
-
if (this.enabled && this.level <= exports.LogLevel.Error) {
|
|
28471
|
+
if (this.options.enabled && this.options.level <= exports.LogLevel.Error) {
|
|
28459
28472
|
this.provider.exception(message, error, this.serializeMeta(meta));
|
|
28460
28473
|
}
|
|
28461
28474
|
}
|
|
28462
28475
|
serializeMeta(meta) {
|
|
28463
|
-
switch (this.serialization) {
|
|
28476
|
+
switch (this.options.serialization) {
|
|
28464
28477
|
case exports.MetaSerializationType.JSON:
|
|
28465
28478
|
return JSON.stringify(meta, null, 2);
|
|
28466
28479
|
case exports.MetaSerializationType.None:
|
|
@@ -28469,35 +28482,36 @@ class InternalLogger {
|
|
|
28469
28482
|
}
|
|
28470
28483
|
}
|
|
28471
28484
|
}
|
|
28472
|
-
const getLogger = ({
|
|
28473
|
-
return new InternalLogger(
|
|
28485
|
+
const getLogger = ({ options, loggerName, }) => {
|
|
28486
|
+
return new InternalLogger(options, new DefaultLogger(loggerName));
|
|
28474
28487
|
};
|
|
28475
28488
|
class Log {
|
|
28476
28489
|
static setSerializationType(type) {
|
|
28477
|
-
this.
|
|
28490
|
+
this.options.serialization = type;
|
|
28478
28491
|
}
|
|
28479
28492
|
static setLevel(level) {
|
|
28480
|
-
this.level = level;
|
|
28481
|
-
this.
|
|
28493
|
+
this.options.level = level;
|
|
28494
|
+
this.options.level = level;
|
|
28495
|
+
this.options.enabled = true;
|
|
28482
28496
|
}
|
|
28483
28497
|
static enable() {
|
|
28484
|
-
this.enabled = true;
|
|
28498
|
+
this.options.enabled = true;
|
|
28485
28499
|
}
|
|
28486
28500
|
static disable() {
|
|
28487
|
-
this.enabled = false;
|
|
28501
|
+
this.options.enabled = false;
|
|
28488
28502
|
}
|
|
28489
28503
|
static getLogger(loggerName) {
|
|
28490
28504
|
return getLogger({
|
|
28491
|
-
|
|
28492
|
-
level: this.level,
|
|
28493
|
-
serialization: this.metaSerialization,
|
|
28505
|
+
options: this.options,
|
|
28494
28506
|
loggerName,
|
|
28495
28507
|
});
|
|
28496
28508
|
}
|
|
28497
28509
|
}
|
|
28498
|
-
Log.
|
|
28499
|
-
|
|
28500
|
-
|
|
28510
|
+
Log.options = {
|
|
28511
|
+
enabled: true,
|
|
28512
|
+
level: exports.LogLevel.Debug,
|
|
28513
|
+
serialization: exports.MetaSerializationType.None,
|
|
28514
|
+
};
|
|
28501
28515
|
|
|
28502
28516
|
exports.Log = Log;
|
|
28503
28517
|
exports.addTime = addTime;
|
|
@@ -28528,6 +28542,7 @@ exports.joinPath = joinPath;
|
|
|
28528
28542
|
exports.jsonDistinct = jsonDistinct;
|
|
28529
28543
|
exports.last = last;
|
|
28530
28544
|
exports.mapOrThrow = mapOrThrow;
|
|
28545
|
+
exports.mergeDeep = mergeDeep;
|
|
28531
28546
|
exports.newUuid = newUuid;
|
|
28532
28547
|
exports.notNull = notNull;
|
|
28533
28548
|
exports.notUndefined = notUndefined;
|