@sipgate/integration-bridge 0.16.1 → 0.16.2

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,2 +1,2 @@
1
1
  import { AxiosError } from "axios";
2
- export declare const throwAndDelegateError: (error: Error | AxiosError, source: string, apiKey: string | undefined, logMessage?: string) => never;
2
+ export declare const throwAndDelegateError: (error: AxiosError | Error, source: string, apiKey: string | undefined, logMessage?: string) => never;
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.throwAndDelegateError = void 0;
4
- const axios_1 = require("axios");
7
+ const axios_1 = __importDefault(require("axios"));
5
8
  const models_1 = require("../models");
6
9
  const logger_util_1 = require("./logger.util");
7
10
  const throwAndDelegateError = (error, source, apiKey, logMessage) => {
8
11
  var _a, _b, _c;
9
- const errorMessage = error instanceof axios_1.AxiosError
12
+ const errorMessage = axios_1.default.isAxiosError(error)
10
13
  ? ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)
11
14
  ? JSON.stringify((_b = error.response) === null || _b === void 0 ? void 0 : _b.data)
12
15
  : error.message
@@ -17,7 +20,7 @@ const throwAndDelegateError = (error, source, apiKey, logMessage) => {
17
20
  else {
18
21
  (0, logger_util_1.errorLogger)(source, errorMessage, apiKey);
19
22
  }
20
- if (error instanceof axios_1.AxiosError) {
23
+ if (axios_1.default.isAxiosError(error)) {
21
24
  const status = ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) || 500;
22
25
  var errorType;
23
26
  switch (status) {
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/util/error.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,sCAImB;AACnB,+CAA4C;AAErC,MAAM,qBAAqB,GAAG,CACnC,KAAyB,EACzB,MAAc,E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YACT,KAAK,GAAG;gBACN,SAAS,GAAG,6BAAoB,CAAC,6BAA6B,CAAC;gBAC/D,MAAM;YACR;gBACE,MAAM,IAAI,oBAAW,CAAC,MAAM,EAAE,GAAG,MAAM,KAAK,YAAY,GAAG,CAAC,CAAC;SAChE;QACD,MAAM,IAAI,oBAAW,CAAC,kCAAyB,EAAE,SAAS,CAAC,CAAC;KAC7D;IACD,MAAM,IAAI,oBAAW,CAAC,GAAG,EAAE,4BAA4B,CAAC,CAAC;AAC3D,CAAC,CAAC;AAzCW,QAAA,qBAAqB,yBAyChC"}
@@ -10,7 +10,7 @@ const anonymize_key_1 = require("./anonymize-key");
10
10
  * @param args additional data, will be stringified and appended
11
11
  */
12
12
  const infoLogger = (source, message, apiKey, ...args) => {
13
- logger(console.info, source, message, apiKey, args);
13
+ logger(console.info, source, message, apiKey, ...args);
14
14
  };
15
15
  exports.infoLogger = infoLogger;
16
16
  /**
@@ -21,7 +21,7 @@ exports.infoLogger = infoLogger;
21
21
  * @param args additional data, will be stringified and appended
22
22
  */
23
23
  const errorLogger = (source, message, apiKey, ...args) => {
24
- logger(console.error, source, message, apiKey, args);
24
+ logger(console.error, source, message, apiKey, ...args);
25
25
  };
26
26
  exports.errorLogger = errorLogger;
27
27
  /**
@@ -32,20 +32,26 @@ exports.errorLogger = errorLogger;
32
32
  * @param args additional data, will be stringified and appended
33
33
  */
34
34
  const warnLogger = (source, message, apiKey, ...args) => {
35
- logger(console.warn, source, message, apiKey, args);
35
+ logger(console.warn, source, message, apiKey, ...args);
36
36
  };
37
37
  exports.warnLogger = warnLogger;
38
38
  const logger = (logFn, source, message, apiKey, ...args) => {
39
39
  // eslint-disable-next-line no-console
40
- if (apiKey) {
41
- logFn(constructLogMessage(`[${(0, anonymize_key_1.anonymizeKey)(apiKey)}]`, `[${source}]`, message, ...args));
40
+ const anonymizedApiKey = apiKey ? (0, anonymize_key_1.anonymizeKey)(apiKey) : undefined;
41
+ const formatedMessage = constructLogMessage(anonymizedApiKey ? `[${anonymizedApiKey}]` : undefined, `[${source}]`, message);
42
+ if (process.env.NODE_ENV == "development") {
43
+ logFn(formatedMessage, ...args);
42
44
  }
43
45
  else {
44
- logFn(constructLogMessage(`[${source}]`, message, ...args));
46
+ logFn(JSON.stringify({
47
+ message: formatedMessage,
48
+ data: args,
49
+ }));
45
50
  }
46
51
  };
47
52
  const constructLogMessage = (...args) => `${args
48
53
  .flat()
54
+ .filter((item) => item != undefined)
49
55
  .map((item) => {
50
56
  if (Array.isArray(item) && item.length == 0)
51
57
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.util.js","sourceRoot":"","sources":["../../src/util/logger.util.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAE/C;;;;;;GAMG;AACI,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,OAAe,EACf,MAA0B,EAC1B,GAAG,IAAe,EACZ,EAAE;IACR,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC,CAAC;AAPW,QAAA,UAAU,cAOrB;AAEF;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CACzB,MAAc,EACd,OAAe,EACf,MAA0B,EAC1B,GAAG,IAAe,EACZ,EAAE;IACR,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB;AAEF;;;;;;GAMG;AACI,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,OAAe,EACf,MAAe,EACf,GAAG,IAAe,EACZ,EAAE;IACR,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC,CAAC;AAPW,QAAA,UAAU,cAOrB;AAEF,MAAM,MAAM,GAAG,CACb,KAAwD,EACxD,MAAc,EACd,OAAe,E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AI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO;IACpD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC,CAAC;KACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sipgate/integration-bridge",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "sipgate Integration Bridge Framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",