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
@@ -0,0 +1,158 @@
1
+ "use strict";
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
+ };
16
+ }
17
+ };
18
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
19
+ };
20
+ Object.defineProperty(exports, "__esModule", {
21
+ value: true
22
+ });
23
+ exports.normalizePath = normalizePath;
24
+ exports.isNullOrEmpty = isNullOrEmpty;
25
+ exports.castToMetaDescriptor = castToMetaDescriptor;
26
+ exports.mergeAxiosConfigs = mergeAxiosConfigs;
27
+ exports.formatUrl = formatUrl;
28
+ exports.isPlainObject = isPlainObject;
29
+ var builder_1 = require("./builder");
30
+ function normalizePath(path) {
31
+ return path.replace(/\/+/g, "/").replace(/\/$/, "");
32
+ }
33
+ function isNullOrEmpty(param) {
34
+ return param === null || param === undefined || param === "";
35
+ }
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);
130
+ }
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;
143
+ });
144
+ }
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;
156
+ }
157
+ return proto === Object.prototype;
158
+ }
@@ -0,0 +1,60 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ import AxiosStaticInstanceProvider from "./provider";
3
+ export type ConfigPlugin = (axios: AxiosInstance, config: Config) => void;
4
+ export type PartialConstructorString = string | null;
5
+ export type PartialConstructorNumber = number | null;
6
+ export type PartialPluginConstructorPlugins = ConfigPlugin[] | null;
7
+ export default class Config {
8
+ private _host;
9
+ private _port;
10
+ private _protocol;
11
+ private _prefix;
12
+ private _axiosProvider;
13
+ private _axios;
14
+ private _plugins;
15
+ constructor(options?: {
16
+ protocol?: PartialConstructorString;
17
+ host?: PartialConstructorString;
18
+ port?: PartialConstructorNumber;
19
+ prefix?: PartialConstructorString;
20
+ plugins?: PartialPluginConstructorPlugins;
21
+ axiosProvider?: AxiosStaticInstanceProvider;
22
+ });
23
+ static forName(name: string): Config | null;
24
+ init(protocol: PartialConstructorString, host: PartialConstructorString, port: PartialConstructorNumber, prefix: PartialConstructorString, plugins: PartialPluginConstructorPlugins): void;
25
+ get host(): string;
26
+ set host(value: string);
27
+ get port(): number;
28
+ set port(value: number);
29
+ get protocol(): string;
30
+ set protocol(value: string);
31
+ get prefix(): string;
32
+ set prefix(value: string);
33
+ /**
34
+ * default value: <br/>
35
+ * http://localhost:8080
36
+ */
37
+ get origin(): string;
38
+ /**
39
+ * if prefix = "/a" <br/>
40
+ * return "http://localhost:8080/a"
41
+ */
42
+ get baseURL(): string;
43
+ get plugins(): PartialPluginConstructorPlugins;
44
+ set plugins(value: PartialPluginConstructorPlugins);
45
+ get axiosProvider(): AxiosStaticInstanceProvider;
46
+ set axiosProvider(value: AxiosStaticInstanceProvider);
47
+ /**
48
+ * register config global and return self.
49
+ * @param name
50
+ * @return {Config} config self
51
+ */
52
+ register(name: string): Config;
53
+ /**
54
+ * remove self from global config store.
55
+ * @return {Config} - config self
56
+ */
57
+ unregister(): Config;
58
+ requestAxiosInstance(): Promise<AxiosInstance>;
59
+ }
60
+ export declare const config: Config;
@@ -0,0 +1,362 @@
1
+ "use strict";
2
+ var __awaiter = (void 0) && (void 0).__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 = (void 0) && (void 0).__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;
112
+ }
113
+ if (op[0] & 5) throw op[1];
114
+ return {
115
+ value: op[0] ? op[1] : void 0,
116
+ done: true
117
+ };
118
+ }
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
+ };
134
+ Object.defineProperty(exports, "__esModule", {
135
+ value: true
136
+ });
137
+ exports.config = void 0;
138
+ var provider_1 = require("./provider");
139
+ var _global_configs = [];
140
+ var Config = /** @class */ function() {
141
+ function Config(options) {
142
+ this._host = "localhost";
143
+ this._port = 8080;
144
+ this._protocol = "http";
145
+ this._prefix = "";
146
+ this._axiosProvider = new provider_1["default"]();
147
+ this._axios = null;
148
+ this._plugins = null;
149
+ if (options === null || options === void 0 ? void 0 : options.axiosProvider) {
150
+ this._axiosProvider = options === null || options === void 0 ? void 0 : options.axiosProvider;
151
+ }
152
+ this.init((options === null || options === void 0 ? void 0 : options.protocol) || null, (options === null || options === void 0 ? void 0 : options.host) || null, (options === null || options === void 0 ? void 0 : options.port) || null, (options === null || options === void 0 ? void 0 : options.prefix) || null, (options === null || options === void 0 ? void 0 : options.plugins) || null);
153
+ }
154
+ Config.forName = function(name) {
155
+ var c = _global_configs.find(function(i) {
156
+ return i.name === name;
157
+ });
158
+ if (c) {
159
+ return c.config;
160
+ } else {
161
+ return null;
162
+ }
163
+ };
164
+ Config.prototype.init = function(protocol, host, port, prefix, plugins) {
165
+ if (port) {
166
+ this.port = port;
167
+ }
168
+ if (protocol) {
169
+ this.protocol = protocol;
170
+ }
171
+ if (host) {
172
+ this.host = host;
173
+ }
174
+ if (prefix) {
175
+ this.prefix = prefix;
176
+ }
177
+ if (Array.isArray(plugins)) {
178
+ this._plugins = plugins;
179
+ }
180
+ };
181
+ Object.defineProperty(Config.prototype, "host", {
182
+ get: function get() {
183
+ return this._host;
184
+ },
185
+ set: function set(value) {
186
+ this._host = value;
187
+ },
188
+ enumerable: false,
189
+ configurable: true
190
+ });
191
+ Object.defineProperty(Config.prototype, "port", {
192
+ get: function get() {
193
+ return this._port;
194
+ },
195
+ set: function set(value) {
196
+ this._port = value;
197
+ },
198
+ enumerable: false,
199
+ configurable: true
200
+ });
201
+ Object.defineProperty(Config.prototype, "protocol", {
202
+ get: function get() {
203
+ return this._protocol;
204
+ },
205
+ set: function set(value) {
206
+ this._protocol = value;
207
+ },
208
+ enumerable: false,
209
+ configurable: true
210
+ });
211
+ Object.defineProperty(Config.prototype, "prefix", {
212
+ get: function get() {
213
+ return this._prefix;
214
+ },
215
+ set: function set(value) {
216
+ this._prefix = value;
217
+ },
218
+ enumerable: false,
219
+ configurable: true
220
+ });
221
+ Object.defineProperty(Config.prototype, "origin", {
222
+ /**
223
+ * default value: <br/>
224
+ * http://localhost:8080
225
+ */ get: function get() {
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 : "");
228
+ },
229
+ enumerable: false,
230
+ configurable: true
231
+ });
232
+ Object.defineProperty(Config.prototype, "baseURL", {
233
+ /**
234
+ * if prefix = "/a" <br/>
235
+ * return "http://localhost:8080/a"
236
+ */ get: function get() {
237
+ return "".concat(this.origin).concat(this.prefix);
238
+ },
239
+ enumerable: false,
240
+ configurable: true
241
+ });
242
+ Object.defineProperty(Config.prototype, "plugins", {
243
+ get: function get() {
244
+ return this._plugins;
245
+ },
246
+ set: function set(value) {
247
+ this._plugins = value;
248
+ },
249
+ enumerable: false,
250
+ configurable: true
251
+ });
252
+ Object.defineProperty(Config.prototype, "axiosProvider", {
253
+ get: function get() {
254
+ return this._axiosProvider;
255
+ },
256
+ set: function set(value) {
257
+ this._axiosProvider = value;
258
+ },
259
+ enumerable: false,
260
+ configurable: true
261
+ });
262
+ /**
263
+ * register config global and return self.
264
+ * @param name
265
+ * @return {Config} config self
266
+ */ Config.prototype.register = function(name) {
267
+ var _this = this;
268
+ var c = _global_configs.find(function(i) {
269
+ return i.config === _this;
270
+ });
271
+ if (c) {
272
+ c.name = name;
273
+ } else {
274
+ _global_configs.push({
275
+ name: name,
276
+ config: this
277
+ });
278
+ }
279
+ return this;
280
+ };
281
+ // noinspection JSUnusedGlobalSymbols
282
+ /**
283
+ * remove self from global config store.
284
+ * @return {Config} - config self
285
+ */ Config.prototype.unregister = function() {
286
+ var _this = this;
287
+ var index = _global_configs.findIndex(function(i) {
288
+ return i.config === _this;
289
+ });
290
+ if (index >= 0) {
291
+ _global_configs.splice(index, 1);
292
+ }
293
+ return this;
294
+ };
295
+ // 创建 axios 实例
296
+ Config.prototype.requestAxiosInstance = function() {
297
+ return __awaiter(this, void 0, void 0, function() {
298
+ var _a, e_1, _b, _c, plugin;
299
+ var e_2, _d;
300
+ return __generator(this, function(_e) {
301
+ switch(_e.label){
302
+ case 0:
303
+ if (this._axios) {
304
+ return [
305
+ 2 /*return*/ ,
306
+ this._axios
307
+ ];
308
+ }
309
+ _e.label = 1;
310
+ case 1:
311
+ _e.trys.push([
312
+ 1,
313
+ 3,
314
+ ,
315
+ 4
316
+ ]);
317
+ _a = this;
318
+ return [
319
+ 4 /*yield*/ ,
320
+ this._axiosProvider.get()
321
+ ];
322
+ case 2:
323
+ _a._axios = _e.sent().create();
324
+ return [
325
+ 3 /*break*/ ,
326
+ 4
327
+ ];
328
+ case 3:
329
+ e_1 = _e.sent();
330
+ throw e_1;
331
+ case 4:
332
+ // 插件注入
333
+ if (this._plugins && this._plugins.length) {
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
+ }
350
+ }
351
+ return [
352
+ 2 /*return*/ ,
353
+ this._axios
354
+ ];
355
+ }
356
+ });
357
+ });
358
+ };
359
+ return Config;
360
+ }();
361
+ exports["default"] = Config;
362
+ exports.config = new Config();
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ import Expect from "./core-expect";
2
+ export default Expect;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var core_expect_1 = require("./core-expect");
6
+ exports["default"] = core_expect_1["default"];
@@ -0,0 +1,6 @@
1
+ import type { AxiosStatic } from 'axios';
2
+ export default class AxiosStaticInstanceProvider {
3
+ __instance: AxiosStatic | null;
4
+ provide(): Promise<AxiosStatic>;
5
+ get(): Promise<AxiosStatic>;
6
+ }