@punks/backend-core 0.0.55 → 0.0.57

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.
@@ -1,13 +1,13 @@
1
1
  export declare enum LogLevel {
2
- Debug = 0,
3
- Info = 1,
4
- Warn = 2,
5
- Error = 3,
6
- Fatal = 4
2
+ Debug = "debug",
3
+ Info = "info",
4
+ Warn = "warn",
5
+ Error = "error",
6
+ Fatal = "fatal"
7
7
  }
8
8
  export declare enum MetaSerializationType {
9
- None = 0,
10
- JSON = 1
9
+ None = "none",
10
+ JSON = "json"
11
11
  }
12
12
  export interface ILoggerProvider {
13
13
  debug(loggerName: string, message: string, meta?: any): void;
@@ -0,0 +1,2 @@
1
+ import { LogLevel } from "../abstractions";
2
+ export declare const getLevelValue: (level: LogLevel) => 1 | 0 | 2 | 3 | 4;
@@ -5,6 +5,7 @@ export interface Dict<TVal> {
5
5
  }
6
6
  export declare const toDict: <TVal>(array: TVal[], keySelector: (value: TVal) => string) => Dict<TVal>;
7
7
  export declare const toItemsDict: <TItem, TVal>(array: TItem[], keySelector: (value: TItem) => string, elementSelector: (value: TItem) => TVal) => Dict<TVal>;
8
+ export declare const toArrayDict: <TVal>(array: TVal[], keySelector: (value: TVal) => string) => Dict<TVal[]>;
8
9
  export declare const toMap: <TKey, TVal>(array: TVal[], key: (val: TVal) => TKey) => Map<TKey, TVal>;
9
10
  export declare const toItemsMap: <TItem, TKey, TVal>(array: TItem[], key: (val: TItem) => TKey, element: (val: TItem) => TVal) => Map<TKey, TVal>;
10
11
  export declare const last: <T>(arr: T[]) => T;
package/dist/esm/index.js CHANGED
@@ -5,16 +5,16 @@ import * as winston from 'winston';
5
5
 
6
6
  var LogLevel;
7
7
  (function (LogLevel) {
8
- LogLevel[LogLevel["Debug"] = 0] = "Debug";
9
- LogLevel[LogLevel["Info"] = 1] = "Info";
10
- LogLevel[LogLevel["Warn"] = 2] = "Warn";
11
- LogLevel[LogLevel["Error"] = 3] = "Error";
12
- LogLevel[LogLevel["Fatal"] = 4] = "Fatal";
8
+ LogLevel["Debug"] = "debug";
9
+ LogLevel["Info"] = "info";
10
+ LogLevel["Warn"] = "warn";
11
+ LogLevel["Error"] = "error";
12
+ LogLevel["Fatal"] = "fatal";
13
13
  })(LogLevel || (LogLevel = {}));
14
14
  var MetaSerializationType;
15
15
  (function (MetaSerializationType) {
16
- MetaSerializationType[MetaSerializationType["None"] = 0] = "None";
17
- MetaSerializationType[MetaSerializationType["JSON"] = 1] = "JSON";
16
+ MetaSerializationType["None"] = "none";
17
+ MetaSerializationType["JSON"] = "json";
18
18
  })(MetaSerializationType || (MetaSerializationType = {}));
19
19
 
20
20
  const range = (start, end) => {
@@ -35,6 +35,17 @@ const toItemsDict = (array, keySelector, elementSelector) => {
35
35
  }
36
36
  return data;
37
37
  };
38
+ const toArrayDict = (array, keySelector) => {
39
+ const data = {};
40
+ for (const item of array) {
41
+ const key = keySelector(item);
42
+ if (!data[key]) {
43
+ data[key] = [];
44
+ }
45
+ data[key].push(item);
46
+ }
47
+ return data;
48
+ };
38
49
  const toMap = (array, key) => {
39
50
  const map = new Map();
40
51
  array.forEach((x) => map.set(key(x), x));
@@ -28407,6 +28418,21 @@ const excelParse = (file, options) => {
28407
28418
  .map((x) => aggregateRow(header, x, options));
28408
28419
  };
28409
28420
 
28421
+ const getLevelValue = (level) => {
28422
+ switch (level) {
28423
+ case LogLevel.Debug:
28424
+ return 0;
28425
+ case LogLevel.Info:
28426
+ return 1;
28427
+ case LogLevel.Warn:
28428
+ return 2;
28429
+ case LogLevel.Error:
28430
+ return 3;
28431
+ case LogLevel.Fatal:
28432
+ return 4;
28433
+ }
28434
+ };
28435
+
28410
28436
  class InternalLogger {
28411
28437
  constructor(loggerName, container) {
28412
28438
  this.loggerName = loggerName;
@@ -28431,7 +28457,8 @@ class InternalLogger {
28431
28457
  this.getEnabledInstances(LogLevel.Error).forEach((x) => x.provider.exception(this.loggerName, message, error, this.serializeMeta(x.options, meta)));
28432
28458
  }
28433
28459
  getEnabledInstances(level) {
28434
- return this.container.instances.filter((x) => x.options.enabled && x.options.level <= level);
28460
+ return this.container.instances.filter((x) => x.options.enabled &&
28461
+ getLevelValue(x.options.level) <= getLevelValue(level));
28435
28462
  }
28436
28463
  serializeMeta(options, meta) {
28437
28464
  if (meta && typeof meta === "string") {
@@ -28604,5 +28631,5 @@ const processArrayItemMove = (items, input) => {
28604
28631
  }));
28605
28632
  };
28606
28633
 
28607
- export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, groupBy, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapOrThrow, mergeDeep, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, subArrays, subtractTime, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
28634
+ export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, groupBy, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapOrThrow, mergeDeep, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, subArrays, subtractTime, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
28608
28635
  //# sourceMappingURL=index.js.map