@alanszp/axios-node 16.5.4 → 17.0.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,7 @@
1
+ // Used by Jest
2
+ module.exports = {
3
+ presets: [
4
+ ["@babel/preset-env", { targets: { node: "current" } }],
5
+ "@babel/preset-typescript",
6
+ ],
7
+ };
package/dist/axios.js CHANGED
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createAxiosWithTrace = exports.createAxios = exports.isAxiosError = void 0;
6
+ exports.isAxiosError = void 0;
7
+ exports.createAxios = createAxios;
8
+ exports.createAxiosWithTrace = createAxiosWithTrace;
7
9
  const axios_1 = __importDefault(require("axios"));
8
10
  const NetworkRequestError_1 = require("./errors/NetworkRequestError");
9
11
  const Non200ResponseError_1 = require("./errors/Non200ResponseError");
@@ -16,7 +18,7 @@ function mapAxiosErrorToRequestError(error) {
16
18
  if (error.request) {
17
19
  return Promise.reject(new NetworkRequestError_1.NetworkRequestError(error));
18
20
  }
19
- Promise.reject(new GenericError_1.GenericError(error));
21
+ return Promise.reject(new GenericError_1.GenericError(error));
20
22
  }
21
23
  function id(a) {
22
24
  return a;
@@ -27,16 +29,14 @@ function createAxios() {
27
29
  axios.interceptors.response.use(id, mapAxiosErrorToRequestError);
28
30
  return axios;
29
31
  }
30
- exports.createAxios = createAxios;
31
32
  function createAxiosWithTrace(sharedContext) {
32
33
  const axios = axios_1.default.create();
33
34
  axios.interceptors.request.use((config) => {
34
- return Object.assign(Object.assign({}, config), {
35
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
36
- headers: Object.assign({ "x-lifecycle-id": sharedContext.getLifecycleId(), "x-lifecycle-chain": sharedContext.getLifecycleChain() }, config.headers) });
35
+ config.headers.set("x-lifecycle-id", sharedContext.getLifecycleId());
36
+ config.headers.set("x-lifecycle-chain", sharedContext.getLifecycleChain());
37
+ return config;
37
38
  }, mapAxiosErrorToRequestError);
38
39
  axios.interceptors.response.use(id, mapAxiosErrorToRequestError);
39
40
  return axios;
40
41
  }
41
- exports.createAxiosWithTrace = createAxiosWithTrace;
42
42
  //# sourceMappingURL=axios.js.map
package/dist/axios.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"axios.js","sourceRoot":"","sources":["../src/axios.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAgD;AAChD,sEAAmE;AACnE,sEAAmE;AACnE,wDAAqD;AAGxC,QAAA,YAAY,GAAG,eAAW,CAAC,YAAY,CAAC,IAAI,CAAC,eAAW,CAAC,CAAC;AAEvE,SAAS,2BAA2B,CAAI,KAAU;IAChD,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,yCAAmB,CAAI,KAAsB,CAAC,CAAC,CAAC;KAC3E;IAED,IAAI,KAAK,CAAC,OAAO,EAAE;QACjB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,yCAAmB,CAAC,KAAsB,CAAC,CAAC,CAAC;KACxE;IAED,OAAO,CAAC,MAAM,CAAC,IAAI,2BAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,EAAE,CAAI,CAAI;IACjB,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAgB,WAAW;IACzB,MAAM,KAAK,GAAG,eAAW,CAAC,MAAM,EAAE,CAAC;IACnC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAChE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IACjE,OAAO,KAAK,CAAC;AACf,CAAC;AALD,kCAKC;AAED,SAAgB,oBAAoB,CAAC,aAA4B;IAC/D,MAAM,KAAK,GA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nC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAChE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IACjE,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,oBAAoB,CAAC,aAA4B;IAC/D,MAAM,KAAK,GAAG,eAAW,CAAC,MAAM,EAAE,CAAC;IAEnC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAkC,EAAE,EAAE;QACpE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC;QACrE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,aAAa,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAC3E,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,2BAA2B,CAAC,CAAC;IAEhC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAEjE,OAAO,KAAK,CAAC;AACf,CAAC"}
package/jest.config.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}"],
3
+ roots: ["<rootDir>/src/"],
4
+ clearMocks: true,
5
+ resetMocks: true,
6
+ testEnvironment: "node",
7
+ moduleNameMapper: {
8
+ "@/(.*)": "<rootDir>/src/$1",
9
+ },
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alanszp/axios-node",
3
- "version": "16.5.4",
3
+ "version": "17.0.0",
4
4
  "description": "Alan's axios wrapper with base interceptor.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -11,6 +11,7 @@
11
11
  "scripts": {
12
12
  "compile": "rm -rf ./dist && tsc --declaration",
13
13
  "compile-watch": "tsc -w",
14
+ "test": "TZ=Etc/UTC jest",
14
15
  "build": "yarn run compile",
15
16
  "prepack": "yarn run build",
16
17
  "yalc-publish": "yarn run yalc publish"
@@ -19,11 +20,19 @@
19
20
  "@alanszp/errors": ">=12.0.0"
20
21
  },
21
22
  "dependencies": {
22
- "@alanszp/shared-context": "^16.5.4",
23
- "axios": "^0.28.0"
23
+ "@alanszp/shared-context": "^17.0.0",
24
+ "axios": "^1.12.2"
24
25
  },
25
26
  "devDependencies": {
26
- "@types/node": "^20.11.17"
27
+ "@babel/core": "^7.24.0",
28
+ "@babel/preset-env": "^7.24.0",
29
+ "@babel/preset-typescript": "^7.23.3",
30
+ "@types/jest": "^29.5.12",
31
+ "@types/node": "^20.11.17",
32
+ "babel-jest": "^29.7.0",
33
+ "jest": "^29.7.0",
34
+ "ts-node": "^10.9.2",
35
+ "typescript": "^5.7.3"
27
36
  },
28
- "gitHead": "8d1aacba9dbc946adcff7cf00a14ba0f08d4a061"
37
+ "gitHead": "db3463706e4b0b7fc97aa74e95cc7d6572c5d74b"
29
38
  }
package/tsconfig.json CHANGED
@@ -11,5 +11,5 @@
11
11
  "alwaysStrict": true,
12
12
  "strictNullChecks": true
13
13
  },
14
- "exclude": ["node_modules"]
14
+ "exclude": ["node_modules", "**/*.test.ts", "**/*.spec.ts"]
15
15
  }