@midwayjs/axios 3.19.2 → 4.0.0-alpha.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.
@@ -14,7 +14,8 @@ let AxiosConfiguration = class AxiosConfiguration {
14
14
  await container.getAsync(serviceManager_1.HttpServiceFactory);
15
15
  }
16
16
  };
17
- AxiosConfiguration = __decorate([
17
+ exports.AxiosConfiguration = AxiosConfiguration;
18
+ exports.AxiosConfiguration = AxiosConfiguration = __decorate([
18
19
  (0, core_1.Configuration)({
19
20
  namespace: 'axios',
20
21
  importConfigs: [
@@ -44,5 +45,4 @@ AxiosConfiguration = __decorate([
44
45
  },
45
46
  })
46
47
  ], AxiosConfiguration);
47
- exports.AxiosConfiguration = AxiosConfiguration;
48
48
  //# sourceMappingURL=configuration.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import axios from 'axios';
1
+ import * as axios from 'axios';
2
2
  import * as Axios from 'axios';
3
3
  export { AxiosConfiguration as Configuration } from './configuration';
4
4
  export * from './interface';
package/dist/index.js CHANGED
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Axios = exports.axios = exports.Configuration = void 0;
18
- const axios_1 = require("axios");
19
- exports.axios = axios_1.default;
18
+ const axios = require("axios");
19
+ exports.axios = axios;
20
20
  const Axios = require("axios");
21
21
  exports.Axios = Axios;
22
22
  var configuration_1 = require("./configuration");
@@ -1,4 +1,5 @@
1
1
  import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, CreateAxiosDefaults } from 'axios';
2
+ import * as axios from 'axios';
2
3
  import { ServiceFactory } from '@midwayjs/core';
3
4
  import { AxiosHttpService } from './interface';
4
5
  export declare class HttpServiceFactory extends ServiceFactory<AxiosInstance> {
@@ -10,14 +11,14 @@ export declare class HttpServiceFactory extends ServiceFactory<AxiosInstance> {
10
11
  export declare class HttpService implements AxiosHttpService {
11
12
  private instance;
12
13
  private serviceFactory;
13
- get defaults(): Omit<import("axios").AxiosDefaults<any>, "headers"> & {
14
- headers: import("axios").HeadersDefaults & {
15
- [key: string]: import("axios").AxiosHeaderValue;
14
+ get defaults(): Omit<axios.AxiosDefaults<any>, "headers"> & {
15
+ headers: axios.HeadersDefaults & {
16
+ [key: string]: axios.AxiosHeaderValue;
16
17
  };
17
18
  };
18
19
  get interceptors(): {
19
- request: import("axios").AxiosInterceptorManager<import("axios").InternalAxiosRequestConfig<any>>;
20
- response: import("axios").AxiosInterceptorManager<AxiosResponse<any, any>>;
20
+ request: axios.AxiosInterceptorManager<axios.InternalAxiosRequestConfig<any>>;
21
+ response: axios.AxiosInterceptorManager<AxiosResponse<any, any>>;
21
22
  };
22
23
  protected init(): Promise<void>;
23
24
  getUri(config?: AxiosRequestConfig): string;
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.HttpService = exports.HttpServiceFactory = void 0;
13
- const axios_1 = require("axios");
13
+ const axios = require("axios");
14
14
  const core_1 = require("@midwayjs/core");
15
15
  let HttpServiceFactory = class HttpServiceFactory extends core_1.ServiceFactory {
16
16
  async init() {
@@ -26,12 +26,13 @@ let HttpServiceFactory = class HttpServiceFactory extends core_1.ServiceFactory
26
26
  await this.initClients(axiosConfig);
27
27
  }
28
28
  async createClient(config, clientName) {
29
- return axios_1.default.create(config);
29
+ return axios.create(config);
30
30
  }
31
31
  getName() {
32
32
  return 'axios';
33
33
  }
34
34
  };
35
+ exports.HttpServiceFactory = HttpServiceFactory;
35
36
  __decorate([
36
37
  (0, core_1.Config)('axios'),
37
38
  __metadata("design:type", Object)
@@ -42,11 +43,10 @@ __decorate([
42
43
  __metadata("design:paramtypes", []),
43
44
  __metadata("design:returntype", Promise)
44
45
  ], HttpServiceFactory.prototype, "init", null);
45
- HttpServiceFactory = __decorate([
46
+ exports.HttpServiceFactory = HttpServiceFactory = __decorate([
46
47
  (0, core_1.Provide)(),
47
48
  (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
48
49
  ], HttpServiceFactory);
49
- exports.HttpServiceFactory = HttpServiceFactory;
50
50
  let HttpService = class HttpService {
51
51
  get defaults() {
52
52
  return this.instance.defaults;
@@ -55,8 +55,7 @@ let HttpService = class HttpService {
55
55
  return this.instance.interceptors;
56
56
  }
57
57
  async init() {
58
- var _a, _b;
59
- this.instance = this.serviceFactory.get(((_b = (_a = this.serviceFactory).getDefaultClientName) === null || _b === void 0 ? void 0 : _b.call(_a)) || 'default');
58
+ this.instance = this.serviceFactory.get(this.serviceFactory.getDefaultClientName?.() || 'default');
60
59
  if (!this.instance) {
61
60
  throw new core_1.MidwayCommonError('axios default instance not found.');
62
61
  }
@@ -98,6 +97,7 @@ let HttpService = class HttpService {
98
97
  return this.instance.patchForm(url, data, config);
99
98
  }
100
99
  };
100
+ exports.HttpService = HttpService;
101
101
  __decorate([
102
102
  (0, core_1.Inject)(),
103
103
  __metadata("design:type", HttpServiceFactory)
@@ -108,9 +108,8 @@ __decorate([
108
108
  __metadata("design:paramtypes", []),
109
109
  __metadata("design:returntype", Promise)
110
110
  ], HttpService.prototype, "init", null);
111
- HttpService = __decorate([
111
+ exports.HttpService = HttpService = __decorate([
112
112
  (0, core_1.Provide)(),
113
113
  (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
114
114
  ], HttpService);
115
- exports.HttpService = HttpService;
116
115
  //# sourceMappingURL=serviceManager.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midwayjs/axios",
3
3
  "description": "midway http client with axios",
4
- "version": "3.19.2",
4
+ "version": "4.0.0-alpha.1",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "files": [
@@ -10,8 +10,8 @@
10
10
  "index.d.ts"
11
11
  ],
12
12
  "devDependencies": {
13
- "@midwayjs/core": "^3.19.0",
14
- "@midwayjs/mock": "^3.19.2",
13
+ "@midwayjs/core": "^4.0.0-alpha.1",
14
+ "@midwayjs/mock": "^4.0.0-alpha.1",
15
15
  "nock": "13.5.6"
16
16
  },
17
17
  "dependencies": {
@@ -25,8 +25,8 @@
25
25
  "license": "MIT",
26
26
  "scripts": {
27
27
  "build": "tsc",
28
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
29
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
28
+ "test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
29
+ "cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
30
30
  "ci": "npm run test",
31
31
  "lint": "mwts check"
32
32
  },
@@ -37,5 +37,5 @@
37
37
  "type": "git",
38
38
  "url": "https://github.com/midwayjs/midway.git"
39
39
  },
40
- "gitHead": "57fd034be94897fb819b0d9ef776de0b9923ab0f"
40
+ "gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
41
41
  }