axios-annotations 2.2.0 → 3.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.
Files changed (141) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +977 -944
  3. package/es/core/builder.d.ts +33 -0
  4. package/es/core/builder.js +515 -0
  5. package/es/core/common.d.ts +36 -0
  6. package/es/core/common.js +148 -0
  7. package/es/core/config.d.ts +60 -0
  8. package/es/core/config.js +357 -0
  9. package/es/core/core-expect.js +3 -0
  10. package/es/core/expect.d.ts +2 -0
  11. package/es/core/expect.js +2 -0
  12. package/es/core/provider.d.ts +6 -0
  13. package/es/core/provider.js +172 -0
  14. package/es/core/service.d.ts +5 -0
  15. package/es/core/service.js +56 -0
  16. package/es/decorator/path-variables.d.ts +7 -0
  17. package/es/decorator/path-variables.js +32 -0
  18. package/es/decorator/request-body.d.ts +7 -0
  19. package/es/decorator/request-body.js +31 -0
  20. package/es/decorator/request-config.d.ts +7 -0
  21. package/es/decorator/request-config.js +25 -0
  22. package/es/decorator/request-header.d.ts +4 -0
  23. package/es/decorator/request-header.js +14 -0
  24. package/es/decorator/request-mapping.d.ts +6 -0
  25. package/es/decorator/request-mapping.js +56 -0
  26. package/es/decorator/request-param.d.ts +4 -0
  27. package/es/decorator/request-param.js +15 -0
  28. package/es/decorator/request-with.d.ts +3 -0
  29. package/es/decorator/request-with.js +8 -0
  30. package/es/index.d.ts +13 -0
  31. package/es/index.js +14 -0
  32. package/es/plugins/auth/authorizer.d.ts +24 -0
  33. package/es/plugins/auth/authorizer.js +268 -0
  34. package/es/plugins/auth/history.d.ts +15 -0
  35. package/es/plugins/auth/history.js +94 -0
  36. package/es/plugins/auth/index.d.ts +16 -0
  37. package/es/plugins/auth/index.js +358 -0
  38. package/es/plugins/auth/queue.d.ts +29 -0
  39. package/es/plugins/auth/queue.js +281 -0
  40. package/es/plugins/auth/storage.d.ts +6 -0
  41. package/es/plugins/auth/storage.js +203 -0
  42. package/lib/core/builder.d.ts +33 -0
  43. package/lib/core/builder.js +520 -0
  44. package/lib/core/common.d.ts +34 -4
  45. package/lib/core/common.js +139 -147
  46. package/lib/core/config.d.ts +15 -15
  47. package/lib/core/config.js +44 -14
  48. package/lib/core/core-expect.js +8 -0
  49. package/lib/core/expect.d.ts +2 -4
  50. package/lib/core/expect.js +2 -11
  51. package/lib/core/provider.d.ts +5 -5
  52. package/lib/core/provider.js +2 -2
  53. package/lib/core/service.d.ts +3 -151
  54. package/lib/core/service.js +42 -544
  55. package/lib/decorator/path-variables.d.ts +7 -0
  56. package/lib/decorator/path-variables.js +37 -0
  57. package/lib/decorator/request-body.d.ts +7 -1
  58. package/lib/decorator/request-body.js +28 -20
  59. package/lib/decorator/request-config.d.ts +6 -4
  60. package/lib/decorator/request-config.js +23 -16
  61. package/lib/decorator/request-header.d.ts +4 -2
  62. package/lib/decorator/request-header.js +11 -13
  63. package/lib/decorator/request-mapping.d.ts +6 -3
  64. package/lib/decorator/request-mapping.js +46 -43
  65. package/lib/decorator/request-param.d.ts +4 -1
  66. package/lib/decorator/request-param.js +12 -19
  67. package/lib/decorator/request-with.d.ts +3 -1
  68. package/lib/decorator/request-with.js +6 -13
  69. package/lib/index.d.ts +4 -11
  70. package/lib/index.js +19 -68
  71. package/lib/plugins/auth/authorizer.d.ts +6 -5
  72. package/lib/plugins/auth/authorizer.js +3 -2
  73. package/lib/plugins/auth/history.d.ts +5 -4
  74. package/lib/plugins/auth/history.js +2 -0
  75. package/lib/plugins/auth/index.d.ts +7 -0
  76. package/lib/plugins/auth/index.js +11 -3
  77. package/lib/plugins/auth/queue.d.ts +3 -2
  78. package/lib/plugins/auth/queue.js +40 -25
  79. package/lib/plugins/auth/storage.js +2 -2
  80. package/package.json +51 -16
  81. package/wechat-mp/core/builder.d.ts +33 -0
  82. package/wechat-mp/core/builder.js +520 -0
  83. package/wechat-mp/core/common.d.ts +36 -0
  84. package/wechat-mp/core/common.js +158 -0
  85. package/wechat-mp/core/config.d.ts +60 -0
  86. package/wechat-mp/core/config.js +362 -0
  87. package/wechat-mp/core/core-expect.js +8 -0
  88. package/wechat-mp/core/expect.d.ts +2 -0
  89. package/wechat-mp/core/expect.js +6 -0
  90. package/wechat-mp/core/provider.d.ts +6 -0
  91. package/wechat-mp/core/provider.js +178 -0
  92. package/wechat-mp/core/service.d.ts +5 -0
  93. package/wechat-mp/core/service.js +60 -0
  94. package/wechat-mp/decorator/path-variables.d.ts +7 -0
  95. package/wechat-mp/decorator/path-variables.js +37 -0
  96. package/wechat-mp/decorator/request-body.d.ts +7 -0
  97. package/wechat-mp/decorator/request-body.js +36 -0
  98. package/wechat-mp/decorator/request-config.d.ts +7 -0
  99. package/wechat-mp/decorator/request-config.js +30 -0
  100. package/wechat-mp/decorator/request-header.d.ts +4 -0
  101. package/wechat-mp/decorator/request-header.js +19 -0
  102. package/wechat-mp/decorator/request-mapping.d.ts +6 -0
  103. package/wechat-mp/decorator/request-mapping.js +61 -0
  104. package/wechat-mp/decorator/request-param.d.ts +4 -0
  105. package/wechat-mp/decorator/request-param.js +20 -0
  106. package/wechat-mp/decorator/request-with.d.ts +3 -0
  107. package/wechat-mp/decorator/request-with.js +13 -0
  108. package/wechat-mp/index.d.ts +13 -0
  109. package/wechat-mp/index.js +97 -0
  110. package/wechat-mp/plugins/auth/authorizer.d.ts +24 -0
  111. package/wechat-mp/plugins/auth/authorizer.js +272 -0
  112. package/wechat-mp/plugins/auth/history.d.ts +15 -0
  113. package/wechat-mp/plugins/auth/history.js +98 -0
  114. package/wechat-mp/plugins/auth/index.d.ts +16 -0
  115. package/wechat-mp/plugins/auth/index.js +376 -0
  116. package/wechat-mp/plugins/auth/queue.d.ts +29 -0
  117. package/wechat-mp/plugins/auth/queue.js +285 -0
  118. package/wechat-mp/plugins/auth/storage.d.ts +6 -0
  119. package/wechat-mp/plugins/auth/storage.js +207 -0
  120. package/index.d.ts +0 -1
  121. package/index.js +0 -127
  122. package/lib/core/cancel.d.ts +0 -30
  123. package/lib/core/cancel.js +0 -56
  124. package/lib/core/parser.d.ts +0 -19
  125. package/lib/core/parser.js +0 -79
  126. package/lib/decorator/abort-source.d.ts +0 -3
  127. package/lib/decorator/abort-source.js +0 -25
  128. package/lib/decorator/delete-mapping.d.ts +0 -1
  129. package/lib/decorator/delete-mapping.js +0 -13
  130. package/lib/decorator/get-mapping.d.ts +0 -1
  131. package/lib/decorator/get-mapping.js +0 -13
  132. package/lib/decorator/ignore-residual-params.d.ts +0 -1
  133. package/lib/decorator/ignore-residual-params.js +0 -24
  134. package/lib/decorator/patch-mapping.d.ts +0 -1
  135. package/lib/decorator/patch-mapping.js +0 -13
  136. package/lib/decorator/post-mapping.d.ts +0 -1
  137. package/lib/decorator/post-mapping.js +0 -13
  138. package/lib/decorator/put-mapping.d.ts +0 -1
  139. package/lib/decorator/put-mapping.js +0 -13
  140. package/plugins/auth/index.d.ts +0 -4
  141. package/plugins/auth/index.js +0 -26
@@ -1,166 +1,158 @@
1
1
  "use strict";
2
- var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
3
- function adopt(value) {
4
- return value instanceof P ? value : new P(function(resolve) {
5
- resolve(value);
6
- });
7
- }
8
- return new (P || (P = Promise))(function(resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
- function rejected(value) {
17
- try {
18
- step(generator["throw"](value));
19
- } catch (e) {
20
- reject(e);
21
- }
22
- }
23
- function step(result) {
24
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
25
- }
26
- step((generator = generator.apply(thisArg, _arguments || [])).next());
27
- });
28
- };
29
- var __generator = this && this.__generator || function(thisArg, body) {
30
- var _ = {
31
- label: 0,
32
- sent: function sent() {
33
- if (t[0] & 1) throw t[1];
34
- return t[1];
35
- },
36
- trys: [],
37
- ops: []
38
- }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
39
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
40
- return this;
41
- }), g;
42
- function verb(n) {
43
- return function(v) {
44
- return step([
45
- n,
46
- v
47
- ]);
48
- };
49
- }
50
- function step(op) {
51
- if (f) throw new TypeError("Generator is already executing.");
52
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
53
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
54
- if (y = 0, t) op = [
55
- op[0] & 2,
56
- t.value
57
- ];
58
- switch(op[0]){
59
- case 0:
60
- case 1:
61
- t = op;
62
- break;
63
- case 4:
64
- _.label++;
65
- return {
66
- value: op[1],
67
- done: false
68
- };
69
- case 5:
70
- _.label++;
71
- y = op[1];
72
- op = [
73
- 0
74
- ];
75
- continue;
76
- case 7:
77
- op = _.ops.pop();
78
- _.trys.pop();
79
- continue;
80
- default:
81
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
82
- _ = 0;
83
- continue;
84
- }
85
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
86
- _.label = op[1];
87
- break;
88
- }
89
- if (op[0] === 6 && _.label < t[1]) {
90
- _.label = t[1];
91
- t = op;
92
- break;
93
- }
94
- if (t && _.label < t[2]) {
95
- _.label = t[2];
96
- _.ops.push(op);
97
- break;
98
- }
99
- if (t[2]) _.ops.pop();
100
- _.trys.pop();
101
- continue;
102
- }
103
- op = body.call(thisArg, _);
104
- } catch (e) {
105
- op = [
106
- 6,
107
- e
108
- ];
109
- y = 0;
110
- } finally{
111
- f = t = 0;
2
+ function _type_of(obj) {
3
+ "@swc/helpers - typeof";
4
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5
+ }
6
+ var __values = (void 0) && (void 0).__values || function(o) {
7
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8
+ if (m) return m.call(o);
9
+ if (o && typeof o.length === "number") return {
10
+ next: function next() {
11
+ if (o && i >= o.length) o = void 0;
12
+ return {
13
+ value: o && o[i++],
14
+ done: !o
15
+ };
112
16
  }
113
- if (op[0] & 5) throw op[1];
114
- return {
115
- value: op[0] ? op[1] : void 0,
116
- done: true
117
- };
118
- }
17
+ };
18
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
119
19
  };
120
20
  Object.defineProperty(exports, "__esModule", {
121
21
  value: true
122
22
  });
123
23
  exports.normalizePath = normalizePath;
124
24
  exports.isNullOrEmpty = isNullOrEmpty;
125
- exports.forward = forward;
126
- exports.replaceAllStr = replaceAllStr;
127
- exports.mapToDefaultMethod = mapToDefaultMethod;
25
+ exports.castToMetaDescriptor = castToMetaDescriptor;
26
+ exports.mergeAxiosConfigs = mergeAxiosConfigs;
27
+ exports.formatUrl = formatUrl;
28
+ exports.isPlainObject = isPlainObject;
29
+ var builder_1 = require("./builder");
128
30
  function normalizePath(path) {
129
31
  return path.replace(/\/+/g, "/").replace(/\/$/, "");
130
32
  }
131
33
  function isNullOrEmpty(param) {
132
34
  return param === null || param === undefined || param === "";
133
35
  }
134
- function forward(axios, origin, prefix1, prefix2, path, method, query, body, config) {
135
- return __awaiter(this, void 0, void 0, function() {
136
- var url;
137
- return __generator(this, function(_a) {
138
- url = "".concat(origin) + normalizePath("/".concat(prefix1, "/").concat(prefix2, "/").concat(path));
139
- if (query) {
140
- if (url.lastIndexOf("?") >= 0) {
141
- url += "&" + query;
142
- } else {
143
- url += "?" + query;
144
- }
36
+ function castToMetaDescriptor(descriptor) {
37
+ if (!descriptor.builder) {
38
+ descriptor.builder = new builder_1["default"]();
39
+ }
40
+ return descriptor;
41
+ }
42
+ /**
43
+ * Merges multiple Axios request configurations with specific logic for Axios.
44
+ * - `headers` and `params` are shallowly merged.
45
+ * - All other properties are replaced by the last provided value.
46
+ *
47
+ * @param sources A list of AxiosRequestConfig objects to merge.
48
+ * @returns A new, merged AxiosRequestConfig object.
49
+ */ function mergeAxiosConfigs() {
50
+ var e_1, _a, e_2, _b;
51
+ var sources = [];
52
+ for(var _i = 0; _i < arguments.length; _i++){
53
+ sources[_i] = arguments[_i];
54
+ }
55
+ // Start with an empty config
56
+ var finalConfig = {};
57
+ try {
58
+ // Sequentially apply all source configs. This handles the "replacement" logic for most properties.
59
+ for(var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()){
60
+ var source = sources_1_1.value;
61
+ if (source) {
62
+ Object.assign(finalConfig, source);
63
+ }
64
+ }
65
+ } catch (e_1_1) {
66
+ e_1 = {
67
+ error: e_1_1
68
+ };
69
+ } finally{
70
+ try {
71
+ if (sources_1_1 && !sources_1_1.done && (_a = sources_1["return"])) _a.call(sources_1);
72
+ } finally{
73
+ if (e_1) throw e_1.error;
74
+ }
75
+ }
76
+ // Now, handle the special merge logic for 'headers' and 'params'
77
+ var finalHeaders = {};
78
+ var finalParams = {};
79
+ try {
80
+ for(var sources_2 = __values(sources), sources_2_1 = sources_2.next(); !sources_2_1.done; sources_2_1 = sources_2.next()){
81
+ var source = sources_2_1.value;
82
+ if (source === null || source === void 0 ? void 0 : source.headers) {
83
+ Object.assign(finalHeaders, source.headers);
84
+ }
85
+ if (source === null || source === void 0 ? void 0 : source.params) {
86
+ Object.assign(finalParams, source.params);
87
+ }
88
+ }
89
+ } catch (e_2_1) {
90
+ e_2 = {
91
+ error: e_2_1
92
+ };
93
+ } finally{
94
+ try {
95
+ if (sources_2_1 && !sources_2_1.done && (_b = sources_2["return"])) _b.call(sources_2);
96
+ } finally{
97
+ if (e_2) throw e_2.error;
98
+ }
99
+ }
100
+ // Assign the merged headers and params back to the final config
101
+ if (Object.keys(finalHeaders).length > 0) {
102
+ finalConfig.headers = finalHeaders;
103
+ }
104
+ if (Object.keys(finalParams).length > 0) {
105
+ finalConfig.params = finalParams;
106
+ }
107
+ return finalConfig;
108
+ }
109
+ /**
110
+ * 替换链接占位符,注意使用基本类型
111
+ * Replaces placeholders in a URL with values from a data object.
112
+ * e.g., formatUrl("http://a.com/{c}?d={e}", {c: 'x', e: 100}) -> "http://a.com/x?d=100"
113
+ *
114
+ * @param url The URL string with placeholders like {key}.
115
+ * @param data The plain object data source.
116
+ * @returns The formatted URL string.
117
+ */ function formatUrl(url, data) {
118
+ return url.replace(/\{([^{}]+)}/g, function(match, key) {
119
+ // Check if the key exists in the data object
120
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
121
+ var value = data[key];
122
+ // Handle null, undefined, NaN
123
+ if (value === null) return 'null';
124
+ if (value === undefined) return 'undefined';
125
+ if (Number.isNaN(value)) return 'NaN';
126
+ var valueType = typeof value === "undefined" ? "undefined" : _type_of(value);
127
+ // Handle primitive types
128
+ if (valueType === 'string' || valueType === 'number' || valueType === 'boolean') {
129
+ return String(value);
145
130
  }
146
- return [
147
- 2 /*return*/ ,
148
- axios.request(Object.assign({
149
- method: method,
150
- url: url,
151
- data: body
152
- }, config))
153
- ];
154
- });
131
+ // Handle objects and arrays
132
+ try {
133
+ // 此处不应该触发 不要传奇怪的类型
134
+ return JSON.stringify(value);
135
+ } catch (e) {
136
+ // 如果取出的值不是基本类型(例如数组),则直接JSON.stringify后替换,JSON转换过程抛异常则替换为 undefined
137
+ console.error("Error stringify value for key \"".concat(key, "\":"), e);
138
+ return 'undefined'; // Replace with 'undefined' on stringify error
139
+ }
140
+ }
141
+ // If key is not found in data, return the original placeholder
142
+ return match;
155
143
  });
156
144
  }
157
- function replaceAllStr(target, search, replacement) {
158
- var pattern = typeof search === 'string' ? RegExp(search, 'g') : search;
159
- return target.replace(pattern, replacement);
160
- }
161
- function mapToDefaultMethod(method, defaultMethod) {
162
- if (defaultMethod === void 0) {
163
- defaultMethod = "GET";
145
+ /**
146
+ * Checks if a value is a plain object, i.e., an object created by `{}` or `new Object()`.
147
+ * @param value The value to check.
148
+ * @returns True if the value is a plain object, false otherwise.
149
+ */ function isPlainObject(value) {
150
+ if (value === null || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object') {
151
+ return false;
152
+ }
153
+ var proto = Object.getPrototypeOf(value);
154
+ if (proto === null) {
155
+ return true;
164
156
  }
165
- return typeof method === "string" ? method : defaultMethod;
157
+ return proto === Object.prototype;
166
158
  }
@@ -1,10 +1,10 @@
1
+ import type { AxiosInstance } from 'axios';
1
2
  import AxiosStaticInstanceProvider from "./provider";
2
- import type { AxiosInstance, AxiosStatic } from "axios";
3
- export type ConfigPlugin<StaticType = AxiosStatic, InstanceType = AxiosInstance> = (axios: InstanceType, config: Config<StaticType, InstanceType>) => void;
3
+ export type ConfigPlugin = (axios: AxiosInstance, config: Config) => void;
4
4
  export type PartialConstructorString = string | null;
5
5
  export type PartialConstructorNumber = number | null;
6
- export type PartialPluginConstructorPlugins<StaticType = AxiosStatic, InstanceType = AxiosInstance> = ConfigPlugin<StaticType, InstanceType>[] | null;
7
- export default class Config<StaticType = AxiosStatic, InstanceType = AxiosInstance> {
6
+ export type PartialPluginConstructorPlugins = ConfigPlugin[] | null;
7
+ export default class Config {
8
8
  private _host;
9
9
  private _port;
10
10
  private _protocol;
@@ -17,11 +17,11 @@ export default class Config<StaticType = AxiosStatic, InstanceType = AxiosInstan
17
17
  host?: PartialConstructorString;
18
18
  port?: PartialConstructorNumber;
19
19
  prefix?: PartialConstructorString;
20
- plugins?: PartialPluginConstructorPlugins<StaticType, InstanceType>;
21
- axiosProvider?: AxiosStaticInstanceProvider<StaticType>;
20
+ plugins?: PartialPluginConstructorPlugins;
21
+ axiosProvider?: AxiosStaticInstanceProvider;
22
22
  });
23
23
  static forName(name: string): Config | null;
24
- init(protocol: PartialConstructorString, host: PartialConstructorString, port: PartialConstructorNumber, prefix: PartialConstructorString, plugins: PartialPluginConstructorPlugins<StaticType, InstanceType>): void;
24
+ init(protocol: PartialConstructorString, host: PartialConstructorString, port: PartialConstructorNumber, prefix: PartialConstructorString, plugins: PartialPluginConstructorPlugins): void;
25
25
  get host(): string;
26
26
  set host(value: string);
27
27
  get port(): number;
@@ -40,21 +40,21 @@ export default class Config<StaticType = AxiosStatic, InstanceType = AxiosInstan
40
40
  * return "http://localhost:8080/a"
41
41
  */
42
42
  get baseURL(): string;
43
- get plugins(): PartialPluginConstructorPlugins<StaticType, InstanceType>;
44
- set plugins(value: PartialPluginConstructorPlugins<StaticType, InstanceType>);
45
- get axiosProvider(): AxiosStaticInstanceProvider<StaticType>;
46
- set axiosProvider(value: AxiosStaticInstanceProvider<StaticType>);
43
+ get plugins(): PartialPluginConstructorPlugins;
44
+ set plugins(value: PartialPluginConstructorPlugins);
45
+ get axiosProvider(): AxiosStaticInstanceProvider;
46
+ set axiosProvider(value: AxiosStaticInstanceProvider);
47
47
  /**
48
48
  * register config global and return self.
49
49
  * @param name
50
50
  * @return {Config} config self
51
51
  */
52
- register(name: string): Config<StaticType, InstanceType>;
52
+ register(name: string): Config;
53
53
  /**
54
54
  * remove self from global config store.
55
55
  * @return {Config} - config self
56
56
  */
57
- unregister(): Config<StaticType, InstanceType>;
58
- requestAxiosInstance(): Promise<InstanceType>;
57
+ unregister(): Config;
58
+ requestAxiosInstance(): Promise<AxiosInstance>;
59
59
  }
60
- export declare const config: Config<AxiosStatic, AxiosInstance>;
60
+ export declare const config: Config;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
2
+ var __awaiter = (void 0) && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
3
3
  function adopt(value) {
4
4
  return value instanceof P ? value : new P(function(resolve) {
5
5
  resolve(value);
@@ -26,7 +26,7 @@ var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, gener
26
26
  step((generator = generator.apply(thisArg, _arguments || [])).next());
27
27
  });
28
28
  };
29
- var __generator = this && this.__generator || function(thisArg, body) {
29
+ var __generator = (void 0) && (void 0).__generator || function(thisArg, body) {
30
30
  var _ = {
31
31
  label: 0,
32
32
  sent: function sent() {
@@ -117,6 +117,20 @@ var __generator = this && this.__generator || function(thisArg, body) {
117
117
  };
118
118
  }
119
119
  };
120
+ var __values = (void 0) && (void 0).__values || function(o) {
121
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
122
+ if (m) return m.call(o);
123
+ if (o && typeof o.length === "number") return {
124
+ next: function next() {
125
+ if (o && i >= o.length) o = void 0;
126
+ return {
127
+ value: o && o[i++],
128
+ done: !o
129
+ };
130
+ }
131
+ };
132
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
133
+ };
120
134
  Object.defineProperty(exports, "__esModule", {
121
135
  value: true
122
136
  });
@@ -209,7 +223,8 @@ var Config = /** @class */ function() {
209
223
  * default value: <br/>
210
224
  * http://localhost:8080
211
225
  */ get: function get() {
212
- return "".concat(this.protocol, "://").concat(this.host).concat(this.port ? ":" + this.port : "");
226
+ var port = this.protocol === "https" && String(this.port) === "443" || this.protocol === "http" && String(this.port) === "80" ? "" : this.port;
227
+ return "".concat(this.protocol, "://").concat(this.host).concat(port ? ":" + port : "");
213
228
  },
214
229
  enumerable: false,
215
230
  configurable: true
@@ -277,12 +292,13 @@ var Config = /** @class */ function() {
277
292
  }
278
293
  return this;
279
294
  };
295
+ // 创建 axios 实例
280
296
  Config.prototype.requestAxiosInstance = function() {
281
297
  return __awaiter(this, void 0, void 0, function() {
282
- var _a, e_1;
283
- var _this = this;
284
- return __generator(this, function(_b) {
285
- switch(_b.label){
298
+ var _a, e_1, _b, _c, plugin;
299
+ var e_2, _d;
300
+ return __generator(this, function(_e) {
301
+ switch(_e.label){
286
302
  case 0:
287
303
  if (this._axios) {
288
304
  return [
@@ -290,9 +306,9 @@ var Config = /** @class */ function() {
290
306
  this._axios
291
307
  ];
292
308
  }
293
- _b.label = 1;
309
+ _e.label = 1;
294
310
  case 1:
295
- _b.trys.push([
311
+ _e.trys.push([
296
312
  1,
297
313
  3,
298
314
  ,
@@ -304,19 +320,33 @@ var Config = /** @class */ function() {
304
320
  this._axiosProvider.get()
305
321
  ];
306
322
  case 2:
307
- _a._axios = _b.sent().create();
323
+ _a._axios = _e.sent().create();
308
324
  return [
309
325
  3 /*break*/ ,
310
326
  4
311
327
  ];
312
328
  case 3:
313
- e_1 = _b.sent();
329
+ e_1 = _e.sent();
314
330
  throw e_1;
315
331
  case 4:
332
+ // 插件注入
316
333
  if (this._plugins && this._plugins.length) {
317
- this._plugins.forEach(function(plugin) {
318
- plugin(_this._axios, _this);
319
- });
334
+ try {
335
+ for(_b = __values(this._plugins), _c = _b.next(); !_c.done; _c = _b.next()){
336
+ plugin = _c.value;
337
+ plugin(this._axios, this);
338
+ }
339
+ } catch (e_2_1) {
340
+ e_2 = {
341
+ error: e_2_1
342
+ };
343
+ } finally{
344
+ try {
345
+ if (_c && !_c.done && (_d = _b["return"])) _d.call(_b);
346
+ } finally{
347
+ if (e_2) throw e_2.error;
348
+ }
349
+ }
320
350
  }
321
351
  return [
322
352
  2 /*return*/ ,
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports["default"] = IndexCjs;
6
+ function IndexCjs(params) {
7
+ return params;
8
+ }
@@ -1,4 +1,2 @@
1
- import type {AxiosPromise} from "axios";
2
-
3
- export default function Expect<T, D = AxiosPromise<T>>(params: any): D;
4
- export {};
1
+ import Expect from "./core-expect";
2
+ export default Expect;
@@ -2,14 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports["default"] = Expect;
6
- /**
7
- * 警告 Warning: <br/>
8
- * 仅用于仿冒使用装饰器的方法返回值,绕过IDE/Typescript的类型检查,获得代码提示功能。<br/>
9
- *
10
- * Only used to ensure the return value of a method that uses decorators,
11
- * bypassing IDE/Typescript type checking and obtaining code intelligence.
12
- */
13
- function Expect(params) {
14
- return params;
15
- }
5
+ var core_expect_1 = require("./core-expect");
6
+ exports["default"] = core_expect_1["default"];
@@ -1,6 +1,6 @@
1
- import type { AxiosStatic } from "axios";
2
- export default class AxiosStaticInstanceProvider<StaticType = AxiosStatic> {
3
- __instance: StaticType | null;
4
- provide(): Promise<StaticType>;
5
- get(): Promise<StaticType>;
1
+ import type { AxiosStatic } from 'axios';
2
+ export default class AxiosStaticInstanceProvider {
3
+ __instance: AxiosStatic | null;
4
+ provide(): Promise<AxiosStatic>;
5
+ get(): Promise<AxiosStatic>;
6
6
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
2
+ var __awaiter = (void 0) && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
3
3
  function adopt(value) {
4
4
  return value instanceof P ? value : new P(function(resolve) {
5
5
  resolve(value);
@@ -26,7 +26,7 @@ var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, gener
26
26
  step((generator = generator.apply(thisArg, _arguments || [])).next());
27
27
  });
28
28
  };
29
- var __generator = this && this.__generator || function(thisArg, body) {
29
+ var __generator = (void 0) && (void 0).__generator || function(thisArg, body) {
30
30
  var _ = {
31
31
  label: 0,
32
32
  sent: function sent() {