@dexteel/mesf-core 2.1.8 → 2.2.0

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/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # CHANGELOG
2
+ ## 2.2.0
3
+ - Add new callJSON method inside MESApiService
2
4
  ## 2.1.5
3
5
  - Fix exportExcel method. Now it supports when sheets structure is defined. **REQUIRES mesf-core-api@1.2.2**
4
6
  ## 2.1.3
package/dist/index.cjs.js CHANGED
@@ -2461,6 +2461,55 @@ var MESApiService = /** @class */ (function () {
2461
2461
  });
2462
2462
  });
2463
2463
  };
2464
+ MESApiService.prototype.callJSON = function (procedure, parameters, database) {
2465
+ if (database === void 0) { database = ''; }
2466
+ return __awaiter(this, void 0, void 0, function () {
2467
+ var data, formattedParameters, isError;
2468
+ var _this = this;
2469
+ return __generator(this, function (_a) {
2470
+ data = {};
2471
+ formattedParameters = [];
2472
+ parameters.forEach(function (element) {
2473
+ var formattedParameter = {};
2474
+ formattedParameter.name = element.name;
2475
+ if (element.value === null || element.value === undefined)
2476
+ formattedParameter.value = null;
2477
+ else
2478
+ formattedParameter.value = element.value;
2479
+ formattedParameters.push(formattedParameter);
2480
+ });
2481
+ data.method = procedure;
2482
+ data.dataBaseName = database;
2483
+ data.parameters = formattedParameters;
2484
+ Date.prototype.toJSON = function () { return moment__default["default"](this).format('YYYY-MM-DDTHH:mm:ss'); }; // eslint-disable-line
2485
+ isError = { ok: true };
2486
+ return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + '/ExecuteJSON', {
2487
+ method: "POST",
2488
+ mode: "cors",
2489
+ headers: {
2490
+ "Content-Type": "application/json",
2491
+ 'Authorization': 'Bearer ' + this.TOKEN
2492
+ },
2493
+ body: JSON.stringify(data)
2494
+ })["catch"](function (errorMsg) {
2495
+ throw new FetchError(errorMsg.message, 404, "ERR_CONNECTION_REFUSED");
2496
+ })
2497
+ .then(function (response) {
2498
+ isError = { ok: response.ok, status: response.status, statusText: response.statusText };
2499
+ return response.json();
2500
+ })
2501
+ .then(function (object) {
2502
+ if (!isError.ok)
2503
+ throw new FetchError(isError.statusText, isError.status, object);
2504
+ return object;
2505
+ })["catch"](function (err) {
2506
+ _this.hasErrors = true;
2507
+ _this.error = err;
2508
+ return;
2509
+ })];
2510
+ });
2511
+ });
2512
+ };
2464
2513
  MESApiService.prototype["import"] = function (procedure, parameters, files, uniqueFile, database) {
2465
2514
  if (database === void 0) { database = ''; }
2466
2515
  return __awaiter(this, void 0, void 0, function () {
@@ -29,6 +29,7 @@ export declare class MESApiService {
29
29
  authenticate(userName: string, password: string): Promise<any>;
30
30
  loginWithAzureAD(accessToken: string): Promise<any>;
31
31
  call(procedure: string, parameters: any[], database?: string): Promise<any>;
32
+ callJSON(procedure: string, parameters: any[], database?: string): Promise<any>;
32
33
  import(procedure: string, parameters: any[], files: any[], uniqueFile: any, database?: string): Promise<any>;
33
34
  export(procedure: string, parameters: spParameter[], fileName: string, database?: string): Promise<string | void>;
34
35
  exportExcel(procedure: string, parameters: spParameter[], fileName: string, excelStructure: ExportStructure, database?: string): Promise<string | void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexteel/mesf-core",
3
- "version": "2.1.8",
3
+ "version": "2.2.0",
4
4
  "author": "Lucas Rueda",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",