ismx-nexo-node-app 0.4.138 → 0.4.140

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.
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ObjectUtils {
4
+ static snakeToCamel(obj) {
5
+ if (typeof obj === 'string')
6
+ return obj.toLowerCase().replace(/([-_][a-z])/g, group => group.toUpperCase().replace('-', '').replace('_', ''));
7
+ if (Array.isArray(obj))
8
+ return obj.map(el => ObjectUtils.snakeToCamel(el));
9
+ if (typeof obj === 'function' || obj !== Object(obj) || obj instanceof Date)
10
+ return obj;
11
+ return ObjectUtils.fromEntries(Object.entries(obj).map(([key, value]) => [
12
+ ObjectUtils.snakeToCamel(key), value,
13
+ ]));
14
+ }
15
+ static fromEntries(iterable) {
16
+ const result = {};
17
+ for (const [key, value] of iterable)
18
+ result[key] = value;
19
+ return result;
20
+ }
21
+ }
22
+ exports.default = ObjectUtils;
package/dist/js/index.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.PostgresUtils = exports.RestUtils = exports.QueryUtils = exports.RepositoryRestFormalTemplate = exports.RepositoryRestFormal = exports.RepositoryRest = exports.RepositoryDatabasePostgres = exports.RepositoryDatabase = exports.Repository = exports.PromiseUtils = exports.ArrayUtils = exports.StringUtils = exports.NumberUtils = exports.CryptoUtils = exports.DateUtils = exports.BusinessLogger = exports.FormalError = exports.BusinessErrors = exports.BusinessThreadState = exports.BusinessThread = exports.BusinessServer = exports.FormalLoopbackBusiness = exports.FormalProxyBusiness = exports.ProxyBusiness = exports.BusinessState = exports.Business = exports.ColorUtils = exports.ServiceRestFormalTemplate = exports.ServiceRestFormal = exports.ServiceRest = exports.HttpResponse = exports.Service = void 0;
29
+ exports.PostgresUtils = exports.RestUtils = exports.QueryUtils = exports.RepositoryRestFormalTemplate = exports.RepositoryRestFormal = exports.RepositoryRest = exports.RepositoryDatabasePostgres = exports.RepositoryDatabase = exports.Repository = exports.PromiseUtils = exports.ArrayUtils = exports.StringUtils = exports.ObjectUtils = exports.NumberUtils = exports.CryptoUtils = exports.DateUtils = exports.BusinessLogger = exports.FormalError = exports.BusinessErrors = exports.BusinessThreadState = exports.BusinessThread = exports.BusinessServer = exports.FormalLoopbackBusiness = exports.FormalProxyBusiness = exports.ProxyBusiness = exports.BusinessState = exports.Business = exports.ColorUtils = exports.ServiceRestFormalTemplate = exports.ServiceRestFormal = exports.ServiceRest = exports.HttpResponse = exports.Service = void 0;
30
30
  const Service_1 = __importStar(require("./api/Service"));
31
31
  class Service extends Service_1.default {
32
32
  }
@@ -106,6 +106,10 @@ const NumberUtils_1 = __importDefault(require("./business/utils/NumberUtils"));
106
106
  class NumberUtils extends NumberUtils_1.default {
107
107
  }
108
108
  exports.NumberUtils = NumberUtils;
109
+ const ObjectUtils_1 = __importDefault(require("./business/utils/ObjectUtils"));
110
+ class ObjectUtils extends ObjectUtils_1.default {
111
+ }
112
+ exports.ObjectUtils = ObjectUtils;
109
113
  const StringUtils_1 = __importDefault(require("./business/utils/StringUtils"));
110
114
  class StringUtils extends StringUtils_1.default {
111
115
  }
@@ -0,0 +1,6 @@
1
+ export default class ObjectUtils {
2
+ static snakeToCamel(obj: any): any;
3
+ static fromEntries(iterable: [string, any][]): {
4
+ [key: string]: any;
5
+ };
6
+ }
@@ -65,6 +65,9 @@ export declare abstract class CryptoUtils extends _CryptoUtils {
65
65
  import _NumberUtils from "./business/utils/NumberUtils";
66
66
  export declare abstract class NumberUtils extends _NumberUtils {
67
67
  }
68
+ import _ObjectUtils from "./business/utils/ObjectUtils";
69
+ export declare abstract class ObjectUtils extends _ObjectUtils {
70
+ }
68
71
  import _StringUtils from "./business/utils/StringUtils";
69
72
  export declare abstract class StringUtils extends _StringUtils {
70
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.138",
3
+ "version": "0.4.140",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -124,5 +124,4 @@ export default abstract class ArrayUtils {
124
124
  static sorted<T>(array: T[], compareFn?: (a: T, b: T) => number): T[] {
125
125
  return [ ...array ].sort(compareFn);
126
126
  }
127
-
128
127
  }
@@ -0,0 +1,28 @@
1
+ export default class ObjectUtils {
2
+
3
+ static snakeToCamel(obj: any): any {
4
+ if (typeof obj === 'string')
5
+ return obj.toLowerCase().replace(/([-_][a-z])/g, group =>
6
+ group.toUpperCase().replace('-', '').replace('_', '')
7
+ );
8
+
9
+ if (Array.isArray(obj))
10
+ return obj.map(el => ObjectUtils.snakeToCamel(el));
11
+
12
+ if (typeof obj === 'function' || obj !== Object(obj) || obj instanceof Date)
13
+ return obj;
14
+
15
+ return ObjectUtils.fromEntries(
16
+ Object.entries(obj).map(([key, value]) => [
17
+ ObjectUtils.snakeToCamel(key), value,
18
+ ]),
19
+ );
20
+ }
21
+
22
+ static fromEntries(iterable: [string,any][]): {[key:string]:any} {
23
+ const result: {[key:string]:any} = {};
24
+ for (const [key, value] of iterable)
25
+ result[key] = value;
26
+ return result;
27
+ }
28
+ }
@@ -61,6 +61,9 @@ export abstract class CryptoUtils extends _CryptoUtils {}
61
61
  import _NumberUtils from "./business/utils/NumberUtils";
62
62
  export abstract class NumberUtils extends _NumberUtils {}
63
63
 
64
+ import _ObjectUtils from "./business/utils/ObjectUtils";
65
+ export abstract class ObjectUtils extends _ObjectUtils {}
66
+
64
67
  import _StringUtils from "./business/utils/StringUtils";
65
68
  export abstract class StringUtils extends _StringUtils {}
66
69