sim-node-lib 0.4.1 → 0.4.3

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.
@@ -23,6 +23,7 @@ export declare enum PubSubTableEnum {
23
23
  grupoEmpresaEmpresa = "grupo_empresa_empresa",
24
24
  empresaCargoUsuario = "empresa_cargo_usuario",
25
25
  empresaHorario = "empresa_horario",
26
+ empresaInquilino = "empresa_inquilino",
26
27
  empresaItem = "empresa_item",
27
28
  empresaServico = "empresa_servico",
28
29
  evento = "evento",
@@ -27,6 +27,7 @@ var PubSubTableEnum;
27
27
  PubSubTableEnum["grupoEmpresaEmpresa"] = "grupo_empresa_empresa";
28
28
  PubSubTableEnum["empresaCargoUsuario"] = "empresa_cargo_usuario";
29
29
  PubSubTableEnum["empresaHorario"] = "empresa_horario";
30
+ PubSubTableEnum["empresaInquilino"] = "empresa_inquilino";
30
31
  PubSubTableEnum["empresaItem"] = "empresa_item";
31
32
  PubSubTableEnum["empresaServico"] = "empresa_servico";
32
33
  PubSubTableEnum["evento"] = "evento";
@@ -0,0 +1,4 @@
1
+ export declare enum AgendamentoCiclicaOrigemEnum {
2
+ automatizado = "AU",
3
+ manual = "MA"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgendamentoCiclicaOrigemEnum = void 0;
4
+ var AgendamentoCiclicaOrigemEnum;
5
+ (function (AgendamentoCiclicaOrigemEnum) {
6
+ AgendamentoCiclicaOrigemEnum["automatizado"] = "AU";
7
+ AgendamentoCiclicaOrigemEnum["manual"] = "MA";
8
+ })(AgendamentoCiclicaOrigemEnum = exports.AgendamentoCiclicaOrigemEnum || (exports.AgendamentoCiclicaOrigemEnum = {}));
@@ -16,15 +16,19 @@ exports.errorSwitch = void 0;
16
16
  const Enums_1 = require("../Enums");
17
17
  const BasicException_1 = __importDefault(require("../Models/BasicException"));
18
18
  function errorSwitch(error, ctx, logger) {
19
+ var _a;
19
20
  return __awaiter(this, void 0, void 0, function* () {
20
21
  switch (error.code) {
21
- case Enums_1.ExceptionsCodesEnum.validationFailed:
22
+ case Enums_1.ExceptionsCodesEnum.validationFailed: {
22
23
  logger.warn(error);
23
- return ctx.response.unprocessableEntity(new BasicException_1.default(error.code, `${error.messages.errors
24
+ if (error instanceof BasicException_1.default)
25
+ return ctx.response.unprocessableEntity(error);
26
+ return ctx.response.unprocessableEntity(new BasicException_1.default(error.code, `${((_a = error === null || error === void 0 ? void 0 : error.messages) === null || _a === void 0 ? void 0 : _a.errors)
24
27
  ?
25
28
  error.messages.errors[0].message
26
29
  :
27
30
  Object.values(error.messages)[0]}`));
31
+ }
28
32
  case Enums_1.ExceptionsCodesEnum.unauthorized:
29
33
  logger.warn(error);
30
34
  return ctx.response.unauthorized(new BasicException_1.default(error.code, Enums_1.ExceptionsMessagesEnum.unauthorized + ` (${error.message})`));
@@ -10,4 +10,5 @@ export declare class AxiosService {
10
10
  put(params?: object, data?: object): Promise<AxiosResponse<any, any>>;
11
11
  delete(params?: object, data?: object): Promise<AxiosResponse<any, any>>;
12
12
  byPass(method: Method, data?: object, params?: object): Promise<AxiosResponse<any, any>>;
13
+ private handleAxiosError;
13
14
  }
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.AxiosService = void 0;
39
39
  const axios_1 = __importDefault(require("axios"));
40
40
  const dotenv = __importStar(require("dotenv"));
41
+ const BasicException_1 = __importDefault(require("../Models/BasicException"));
41
42
  let headers;
42
43
  class AxiosService {
43
44
  constructor(url) {
@@ -78,7 +79,7 @@ class AxiosService {
78
79
  return response;
79
80
  })
80
81
  .catch((reason) => {
81
- throw reason;
82
+ throw this.handleAxiosError(reason);
82
83
  });
83
84
  });
84
85
  }
@@ -95,7 +96,7 @@ class AxiosService {
95
96
  return response;
96
97
  })
97
98
  .catch((reason) => {
98
- throw reason;
99
+ throw this.handleAxiosError(reason);
99
100
  });
100
101
  });
101
102
  }
@@ -112,7 +113,7 @@ class AxiosService {
112
113
  return response;
113
114
  })
114
115
  .catch((reason) => {
115
- throw reason;
116
+ throw this.handleAxiosError(reason);
116
117
  });
117
118
  });
118
119
  }
@@ -129,7 +130,7 @@ class AxiosService {
129
130
  return response;
130
131
  })
131
132
  .catch((reason) => {
132
- throw reason;
133
+ throw this.handleAxiosError(reason);
133
134
  });
134
135
  });
135
136
  }
@@ -144,5 +145,13 @@ class AxiosService {
144
145
  return yield (0, axios_1.default)(this.url, content);
145
146
  });
146
147
  }
148
+ handleAxiosError(error) {
149
+ var _a;
150
+ const data = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data;
151
+ if ((data === null || data === void 0 ? void 0 : data.code) && (data === null || data === void 0 ? void 0 : data.message)) {
152
+ throw new BasicException_1.default(data.code, data.message);
153
+ }
154
+ throw data;
155
+ }
147
156
  }
148
157
  exports.AxiosService = AxiosService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",