@sipgate/integration-bridge 0.14.26 → 0.15.1
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/dist/models/integration-error.model.d.ts +3 -0
- package/dist/models/integration-error.model.js +4 -0
- package/dist/models/integration-error.model.js.map +1 -1
- package/dist/util/error.d.ts +2 -0
- package/dist/util/error.js +37 -0
- package/dist/util/error.js.map +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/dist/util/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export declare enum IntegrationErrorType {
|
|
2
2
|
INTEGRATION_INVALID_URL = "integration/invalid-url",
|
|
3
3
|
INTEGRATION_REFRESH_ERROR = "integration/refresh-error",
|
|
4
|
+
INTEGRATION_ERROR_FORBIDDEN = "integration/error/forbidden",
|
|
5
|
+
INTEGRATION_ERROR_UNAVAILABLE = "integration/error/unavailable",
|
|
6
|
+
ENTITY_ERROR_CONFLICT = "entity/error/conflict",
|
|
4
7
|
CONTACT_CREATE_ERROR_CONFLICT = "contact/create-error/conflict",
|
|
5
8
|
CONTACT_CREATE_ERROR_EMAIL_CONFLICT = "contact/create-error/email-conflict",
|
|
6
9
|
CONTACT_ERROR_TOO_MANY_NUMBERS = "contact/error/too-many-numbers",
|
|
@@ -4,7 +4,11 @@ exports.DELEGATE_TO_FRONTEND_CODE = exports.IntegrationErrorType = void 0;
|
|
|
4
4
|
var IntegrationErrorType;
|
|
5
5
|
(function (IntegrationErrorType) {
|
|
6
6
|
IntegrationErrorType["INTEGRATION_INVALID_URL"] = "integration/invalid-url";
|
|
7
|
+
// TODO: rename to INTEGRATION_ERROR_REFRESH = "integration/error/refresh"
|
|
7
8
|
IntegrationErrorType["INTEGRATION_REFRESH_ERROR"] = "integration/refresh-error";
|
|
9
|
+
IntegrationErrorType["INTEGRATION_ERROR_FORBIDDEN"] = "integration/error/forbidden";
|
|
10
|
+
IntegrationErrorType["INTEGRATION_ERROR_UNAVAILABLE"] = "integration/error/unavailable";
|
|
11
|
+
IntegrationErrorType["ENTITY_ERROR_CONFLICT"] = "entity/error/conflict";
|
|
8
12
|
IntegrationErrorType["CONTACT_CREATE_ERROR_CONFLICT"] = "contact/create-error/conflict";
|
|
9
13
|
IntegrationErrorType["CONTACT_CREATE_ERROR_EMAIL_CONFLICT"] = "contact/create-error/email-conflict";
|
|
10
14
|
IntegrationErrorType["CONTACT_ERROR_TOO_MANY_NUMBERS"] = "contact/error/too-many-numbers";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-error.model.js","sourceRoot":"","sources":["../../src/models/integration-error.model.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"integration-error.model.js","sourceRoot":"","sources":["../../src/models/integration-error.model.ts"],"names":[],"mappings":";;;AAAA,IAAY,oBAcX;AAdD,WAAY,oBAAoB;IAC9B,2EAAmD,CAAA;IAEnD,0EAA0E;IAC1E,+EAAuD,CAAA;IACvD,mFAA2D,CAAA;IAC3D,uFAA+D,CAAA;IAE/D,uEAA+C,CAAA;IAE/C,uFAA+D,CAAA;IAC/D,mGAA2E,CAAA;IAC3E,yFAAiE,CAAA;IACjE,6FAAqE,CAAA;AACvE,CAAC,EAdW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAc/B;AAEY,QAAA,yBAAyB,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateError = void 0;
|
|
4
|
+
const axios_1 = require("axios");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const generateError = (error, intentMessage) => {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
if (error instanceof axios_1.AxiosError) {
|
|
9
|
+
const message = ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)
|
|
10
|
+
? JSON.stringify((_b = error.response) === null || _b === void 0 ? void 0 : _b.data)
|
|
11
|
+
: error.message;
|
|
12
|
+
const status = ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) || 500;
|
|
13
|
+
var errorType;
|
|
14
|
+
switch (status) {
|
|
15
|
+
case 401:
|
|
16
|
+
errorType = models_1.IntegrationErrorType.INTEGRATION_REFRESH_ERROR;
|
|
17
|
+
break;
|
|
18
|
+
case 403:
|
|
19
|
+
errorType = models_1.IntegrationErrorType.INTEGRATION_ERROR_FORBIDDEN;
|
|
20
|
+
break;
|
|
21
|
+
case 409:
|
|
22
|
+
errorType = models_1.IntegrationErrorType.ENTITY_ERROR_CONFLICT;
|
|
23
|
+
break;
|
|
24
|
+
case 502:
|
|
25
|
+
case 503:
|
|
26
|
+
case 504:
|
|
27
|
+
errorType = models_1.IntegrationErrorType.INTEGRATION_ERROR_UNAVAILABLE;
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
throw new models_1.ServerError(status, `${intentMessage} (${message})`);
|
|
31
|
+
}
|
|
32
|
+
throw new models_1.ServerError(models_1.DELEGATE_TO_FRONTEND_CODE, errorType);
|
|
33
|
+
}
|
|
34
|
+
throw new models_1.ServerError(500, "An internal error occurred");
|
|
35
|
+
};
|
|
36
|
+
exports.generateError = generateError;
|
|
37
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/util/error.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,sCAImB;AAEZ,MAAM,aAAa,GAAG,CAC3B,KAAyB,EACzB,aAAqB,EACrB,EAAE;;IACF,IAAI,KAAK,YAAY,kBAAU,EAAE;QAC/B,MAAM,OAAO,GAAG,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI;YAClC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,CAAC;YACtC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QAClB,MAAM,MAAM,GAAG,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,KAAI,GAAG,CAAC;QAC7C,IAAI,SAA+B,CAAC;QACpC,QAAQ,MAAM,EAAE;YACd,KAAK,GAAG;gBACN,SAAS,GAAG,6BAAoB,CAAC,yBAAyB,CAAC;gBAC3D,MAAM;YACR,KAAK,GAAG;gBACN,SAAS,GAAG,6BAAoB,CAAC,2BAA2B,CAAC;gBAC7D,MAAM;YACR,KAAK,GAAG;gBACN,SAAS,GAAG,6BAAoB,CAAC,qBAAqB,CAAC;gBACvD,MAAM;YACR,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,SAAS,GAAG,6BAAoB,CAAC,6BAA6B,CAAC;gBAC/D,MAAM;YACR;gBACE,MAAM,IAAI,oBAAW,CAAC,MAAM,EAAE,GAAG,aAAa,KAAK,OAAO,GAAG,CAAC,CAAC;SAClE;QACD,MAAM,IAAI,oBAAW,CAAC,kCAAyB,EAAE,SAAS,CAAC,CAAC;KAC7D;IACD,MAAM,IAAI,oBAAW,CAAC,GAAG,EAAE,4BAA4B,CAAC,CAAC;AAC3D,CAAC,CAAC;AA/BW,QAAA,aAAa,iBA+BxB"}
|
package/dist/util/index.d.ts
CHANGED
package/dist/util/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./phone-number-utils"), exports);
|
|
|
18
18
|
__exportStar(require("./anonymize-key"), exports);
|
|
19
19
|
__exportStar(require("./logger.util"), exports);
|
|
20
20
|
__exportStar(require("./call-comment"), exports);
|
|
21
|
+
__exportStar(require("./error"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,kDAAgC;AAChC,gDAA8B;AAC9B,iDAA+B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,kDAAgC;AAChC,gDAA8B;AAC9B,iDAA+B;AAC/B,0CAAwB"}
|