@abyss-project/main 36.10.0 → 36.12.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.
@@ -0,0 +1 @@
1
+ export declare const isDownstreamDependencyError: (error: unknown) => boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDownstreamDependencyError = void 0;
4
+ const axios_1 = require("axios");
5
+ const isDownstreamDependencyError = (error) => {
6
+ if (!(0, axios_1.isAxiosError)(error)) {
7
+ return false;
8
+ }
9
+ const status = error.response?.status;
10
+ return status === undefined || status >= 500;
11
+ };
12
+ exports.isDownstreamDependencyError = isDownstreamDependencyError;
13
+ //# sourceMappingURL=downstream-dependency.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"downstream-dependency.utils.js","sourceRoot":"","sources":["../../src/utils/downstream-dependency.utils.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAa9B,MAAM,2BAA2B,GAAG,CAAC,KAAc,EAAW,EAAE;IACrE,IAAI,CAAC,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;IACtC,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,IAAI,GAAG,CAAC;AAC/C,CAAC,CAAC;AANW,QAAA,2BAA2B,+BAMtC"}
@@ -1,5 +1,6 @@
1
1
  export * from './enum-to-array.utils';
2
2
  export * from './error.utils';
3
+ export * from './downstream-dependency.utils';
3
4
  export * from './is-valid-object.utils';
4
5
  export * from './byte.utils';
5
6
  export * from './import.utils';
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./enum-to-array.utils"), exports);
18
18
  __exportStar(require("./error.utils"), exports);
19
+ __exportStar(require("./downstream-dependency.utils"), exports);
19
20
  __exportStar(require("./is-valid-object.utils"), exports);
20
21
  __exportStar(require("./byte.utils"), exports);
21
22
  __exportStar(require("./import.utils"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,gDAA8B;AAC9B,0DAAwC;AACxC,+CAA6B;AAC7B,iDAA+B;AAC/B,uDAAqC;AACrC,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,sDAAoC;AACpC,iDAA+B;AAC/B,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,wDAAsC;AACtC,wDAAsC;AACtC,wDAAsC;AACtC,6DAA2C;AAC3C,8DAA4C;AAC5C,qDAAmC;AACnC,0DAAwC;AACxC,6DAA2C;AAC3C,uDAAqC;AACrC,0DAAwC;AACxC,iEAA+C;AAI/C,kDAAgC;AAChC,wDAAsC;AACtC,4DAA0C;AAC1C,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,gDAA8B;AAC9B,gEAA8C;AAC9C,0DAAwC;AACxC,+CAA6B;AAC7B,iDAA+B;AAC/B,uDAAqC;AACrC,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,sDAAoC;AACpC,iDAA+B;AAC/B,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,wDAAsC;AACtC,wDAAsC;AACtC,wDAAsC;AACtC,6DAA2C;AAC3C,8DAA4C;AAC5C,qDAAmC;AACnC,0DAAwC;AACxC,6DAA2C;AAC3C,uDAAqC;AACrC,0DAAwC;AACxC,iEAA+C;AAI/C,kDAAgC;AAChC,wDAAsC;AACtC,4DAA0C;AAC1C,yDAAuC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const axios_1 = require("axios");
4
+ const downstream_dependency_utils_1 = require("../downstream-dependency.utils");
5
+ const response = (status) => ({
6
+ status,
7
+ statusText: '',
8
+ data: {},
9
+ headers: {},
10
+ config: { headers: new axios_1.AxiosHeaders() },
11
+ });
12
+ const axiosError = (code, status) => new axios_1.AxiosError('failed', code, undefined, undefined, status ? response(status) : undefined);
13
+ describe('isDownstreamDependencyError', () => {
14
+ it.each([
15
+ ['a timeout', axiosError('ECONNABORTED')],
16
+ ['a refused connection', axiosError('ECONNREFUSED')],
17
+ ['a DNS failure', axiosError('ENOTFOUND')],
18
+ ['a 500', axiosError('ERR_BAD_RESPONSE', 500)],
19
+ ['a 502', axiosError('ERR_BAD_RESPONSE', 502)],
20
+ ['a 503', axiosError('ERR_BAD_RESPONSE', 503)],
21
+ ])('is an outage for %s', (_label, error) => {
22
+ expect((0, downstream_dependency_utils_1.isDownstreamDependencyError)(error)).toBe(true);
23
+ });
24
+ it.each([
25
+ ['a 400', axiosError('ERR_BAD_REQUEST', 400)],
26
+ ['a 401', axiosError('ERR_BAD_REQUEST', 401)],
27
+ ['a 403', axiosError('ERR_BAD_REQUEST', 403)],
28
+ ['a 404', axiosError('ERR_BAD_REQUEST', 404)],
29
+ ['a 429', axiosError('ERR_BAD_REQUEST', 429)],
30
+ ['an error that is not an HTTP call', new Error('boom')],
31
+ ['a value that is not an error', 'boom'],
32
+ ])('is not an outage for %s', (_label, error) => {
33
+ expect((0, downstream_dependency_utils_1.isDownstreamDependencyError)(error)).toBe(false);
34
+ });
35
+ });
36
+ //# sourceMappingURL=downstream-dependency.utils.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"downstream-dependency.utils.spec.js","sourceRoot":"","sources":["../../../src/utils/tests/downstream-dependency.utils.spec.ts"],"names":[],"mappings":";;AAAA,iCA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AAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QAC7C,CAAC,OAAO,EAAE,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QAC7C,CAAC,OAAO,EAAE,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QAC7C,CAAC,OAAO,EAAE,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QAC7C,CAAC,mCAAmC,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QACxD,CAAC,8BAA8B,EAAE,MAAM,CAAC;KACzC,CAAC,CAAC,yBAAyB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAC9C,MAAM,CAAC,IAAA,yDAA2B,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/main",
3
- "version": "36.10.0",
3
+ "version": "36.12.0",
4
4
  "description": "Core package to interact with Abyss-Project",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",