ismx-nexo-node-app 0.4.101 → 0.4.103

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.
@@ -156,22 +156,24 @@ class BusinessServer extends Business_1.default {
156
156
  }
157
157
  load(parent, path) {
158
158
  return __awaiter(this, void 0, void 0, function* () {
159
- const { readdir } = yield Promise.resolve().then(() => __importStar(require('fs/promises')));
160
- const pathModule = yield Promise.resolve().then(() => __importStar(require('path')));
161
- const { fileURLToPath } = yield Promise.resolve().then(() => __importStar(require('url')));
159
+ /*
160
+ const { readdir } = await import('fs/promises');
161
+ const pathModule = await import('path');
162
+ const { fileURLToPath } = await import('url');
163
+
162
164
  // @ts-ignore
163
165
  const __dirname = pathModule.dirname(fileURLToPath(parent));
164
166
  const servicesPath = pathModule.join(__dirname, path);
165
- const files = yield readdir(servicesPath);
167
+
168
+ const files = await readdir(servicesPath);
166
169
  for (const file of files) {
167
- if (!file.endsWith('.ts') && !file.endsWith('.js'))
168
- continue;
170
+ if (!file.endsWith('.ts') && !file.endsWith('.js')) continue;
169
171
  const modulePath = pathModule.join(servicesPath, file);
170
- const mod = yield Promise.resolve(`${modulePath}`).then(s => __importStar(require(s)));
172
+ const mod = await import(modulePath);
171
173
  const ServiceClass = Object.values(mod)[0];
172
174
  // @ts-ignore
173
175
  const instance = new ServiceClass();
174
- }
176
+ }*/
175
177
  });
176
178
  }
177
179
  }
@@ -69,14 +69,16 @@ class RepositoryRest extends Repository_1.default {
69
69
  let revived = (_b = (_a = this.options).jsonReviver) === null || _b === void 0 ? void 0 : _b.call(_a, key, value);
70
70
  if (revived)
71
71
  return revived;
72
- if (DateUtils_1.default.isIsoDate(value))
73
- return new Date(value);
74
- return value;
72
+ return RepositoryRest.defaultReviver(key, value);
75
73
  }
76
74
  }
77
75
  RepositoryRest.defaultReviver = (key, value) => {
78
76
  if (DateUtils_1.default.isIsoDate(value))
79
77
  return new Date(value);
78
+ if (Number.isInteger(value))
79
+ return parseInt(value);
80
+ if (!isNaN(Number(value)) && value.includes("."))
81
+ return parseFloat(value);
80
82
  return value;
81
83
  };
82
84
  exports.default = RepositoryRest;
@@ -13,5 +13,5 @@ export default class RepositoryRest<Body = any, Res = any> extends Repository {
13
13
  constructor(baseUrl: string, options?: RestOptions);
14
14
  call<B = Body, E = Res>(method?: string, endpoint?: string, request?: HttpRequest<B>): Promise<HttpResponse<E>>;
15
15
  private reviver;
16
- static defaultReviver: (key: string, value: string) => string | Date;
16
+ static defaultReviver: (key: string, value: string) => string | number | Date;
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.101",
3
+ "version": "0.4.103",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -115,6 +115,7 @@ export default class BusinessServer extends Business
115
115
 
116
116
  public async load(parent: string, path: string): Promise<void>
117
117
  {
118
+ /*
118
119
  const { readdir } = await import('fs/promises');
119
120
  const pathModule = await import('path');
120
121
  const { fileURLToPath } = await import('url');
@@ -131,6 +132,6 @@ export default class BusinessServer extends Business
131
132
  const ServiceClass = Object.values(mod)[0];
132
133
  // @ts-ignore
133
134
  const instance = new ServiceClass();
134
- }
135
+ }*/
135
136
  }
136
137
  }
@@ -81,13 +81,14 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
81
81
  private reviver(key: string, value: string) {
82
82
  let revived = this.options.jsonReviver?.(key, value);
83
83
  if (revived) return revived;
84
-
85
- if (DateUtils.isIsoDate(value)) return new Date(value);
86
- return value;
84
+
85
+ return RepositoryRest.defaultReviver(key, value);
87
86
  }
88
87
 
89
88
  static defaultReviver = (key: string, value: string) => {
90
89
  if (DateUtils.isIsoDate(value)) return new Date(value);
90
+ if (Number.isInteger(value)) return parseInt(value);
91
+ if (!isNaN(Number(value)) && value.includes(".")) return parseFloat(value);
91
92
  return value;
92
93
  }
93
94