@sipgate/integration-bridge 0.14.25 → 0.15.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/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 +3 -0
- package/dist/util/error.js +31 -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,31 @@
|
|
|
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
|
+
switch (status) {
|
|
14
|
+
case 401:
|
|
15
|
+
return new models_1.ServerError(models_1.DELEGATE_TO_FRONTEND_CODE, models_1.IntegrationErrorType.INTEGRATION_REFRESH_ERROR);
|
|
16
|
+
case 403:
|
|
17
|
+
return new models_1.ServerError(models_1.DELEGATE_TO_FRONTEND_CODE, models_1.IntegrationErrorType.INTEGRATION_ERROR_FORBIDDEN);
|
|
18
|
+
case 409:
|
|
19
|
+
return new models_1.ServerError(models_1.DELEGATE_TO_FRONTEND_CODE, models_1.IntegrationErrorType.ENTITY_ERROR_CONFLICT);
|
|
20
|
+
case 502:
|
|
21
|
+
case 503:
|
|
22
|
+
case 504:
|
|
23
|
+
return new models_1.ServerError(models_1.DELEGATE_TO_FRONTEND_CODE, models_1.IntegrationErrorType.INTEGRATION_ERROR_UNAVAILABLE);
|
|
24
|
+
default:
|
|
25
|
+
return new models_1.ServerError(status, `${intentMessage} (${message})`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return new models_1.ServerError(500, "An internal error occurred");
|
|
29
|
+
};
|
|
30
|
+
exports.generateError = generateError;
|
|
31
|
+
//# 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,EACR,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,QAAQ,MAAM,EAAE;YACd,KAAK,GAAG;gBACN,OAAO,IAAI,oBAAW,CACpB,kCAAyB,EACzB,6BAAoB,CAAC,yBAAyB,CAC/C,CAAC;YACJ,KAAK,GAAG;gBACN,OAAO,IAAI,oBAAW,CACpB,kCAAyB,EACzB,6BAAoB,CAAC,2BAA2B,CACjD,CAAC;YACJ,KAAK,GAAG;gBACN,OAAO,IAAI,oBAAW,CACpB,kCAAyB,EACzB,6BAAoB,CAAC,qBAAqB,CAC3C,CAAC;YACJ,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,OAAO,IAAI,oBAAW,CACpB,kCAAyB,EACzB,6BAAoB,CAAC,6BAA6B,CACnD,CAAC;YAEJ;gBACE,OAAO,IAAI,oBAAW,CAAC,MAAM,EAAE,GAAG,aAAa,KAAK,OAAO,GAAG,CAAC,CAAC;SACnE;KACF;IACD,OAAO,IAAI,oBAAW,CAAC,GAAG,EAAE,4BAA4B,CAAC,CAAC;AAC5D,CAAC,CAAC;AAtCW,QAAA,aAAa,iBAsCxB"}
|
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"}
|