@snail-js/api 0.1.1 → 0.1.3
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.
- package/README.md +304 -105
- package/dist/cache/index.d.ts +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/snail.d.ts +27 -19
- package/dist/decorators/api.d.ts +12 -0
- package/dist/decorators/cache.d.ts +3 -0
- package/dist/decorators/param.d.ts +4 -0
- package/dist/decorators/server.d.ts +4 -0
- package/dist/decorators/strategy.d.ts +4 -0
- package/dist/decorators/versioning.d.ts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/{snail-api.mjs → snail-api.js} +1542 -420
- package/dist/{snail-api.umd.js → snail-api.umd.cjs} +1544 -422
- package/dist/strategies/jwtStrategy.d.ts +4 -0
- package/dist/typings/api.config.d.ts +5 -24
- package/dist/typings/apiProxy.d.ts +11 -0
- package/dist/typings/cache.management.option.d.ts +19 -0
- package/dist/typings/index.d.ts +5 -3
- package/dist/typings/response.data.d.ts +3 -3
- package/dist/typings/snail.option.d.ts +7 -0
- package/dist/typings/strategy.d.ts +5 -0
- package/dist/typings/versioning.option.d.ts +30 -0
- package/dist/utils/function.d.ts +0 -2
- package/dist/versioning/versioning.d.ts +3 -2
- package/package.json +17 -7
- package/dist/core/api.d.ts +0 -40
- package/dist/typings/cache.management.config.d.ts +0 -19
- package/dist/typings/snail.config.d.ts +0 -21
- package/dist/typings/versioning.config.d.ts +0 -30
|
@@ -5,284 +5,1084 @@
|
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
9
|
+
/*! *****************************************************************************
|
|
10
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
11
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
12
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
13
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
17
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
18
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
19
|
+
|
|
20
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
21
|
+
and limitations under the License.
|
|
22
|
+
***************************************************************************** */
|
|
23
|
+
var Reflect$1;
|
|
24
|
+
(function(Reflect2) {
|
|
25
|
+
(function(factory) {
|
|
26
|
+
var root = typeof globalThis === "object" ? globalThis : typeof commonjsGlobal === "object" ? commonjsGlobal : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
|
|
27
|
+
var exporter = makeExporter(Reflect2);
|
|
28
|
+
if (typeof root.Reflect !== "undefined") {
|
|
29
|
+
exporter = makeExporter(root.Reflect, exporter);
|
|
30
|
+
}
|
|
31
|
+
factory(exporter, root);
|
|
32
|
+
if (typeof root.Reflect === "undefined") {
|
|
33
|
+
root.Reflect = Reflect2;
|
|
34
|
+
}
|
|
35
|
+
function makeExporter(target, previous) {
|
|
36
|
+
return function(key, value) {
|
|
37
|
+
Object.defineProperty(target, key, { configurable: true, writable: true, value });
|
|
38
|
+
if (previous)
|
|
39
|
+
previous(key, value);
|
|
40
|
+
};
|
|
31
41
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const key = versioning.key || "version";
|
|
75
|
-
const separator = "?";
|
|
76
|
-
return {
|
|
77
|
-
url: `${separator}${key}=${version}`
|
|
42
|
+
function functionThis() {
|
|
43
|
+
try {
|
|
44
|
+
return Function("return this;")();
|
|
45
|
+
} catch (_) {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function indirectEvalThis() {
|
|
49
|
+
try {
|
|
50
|
+
return (void 0, eval)("(function() { return this; })()");
|
|
51
|
+
} catch (_) {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function sloppyModeThis() {
|
|
55
|
+
return functionThis() || indirectEvalThis();
|
|
56
|
+
}
|
|
57
|
+
})(function(exporter, root) {
|
|
58
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
59
|
+
var supportsSymbol = typeof Symbol === "function";
|
|
60
|
+
var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
|
|
61
|
+
var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
|
|
62
|
+
var supportsCreate = typeof Object.create === "function";
|
|
63
|
+
var supportsProto = { __proto__: [] } instanceof Array;
|
|
64
|
+
var downLevel = !supportsCreate && !supportsProto;
|
|
65
|
+
var HashMap = {
|
|
66
|
+
// create an object in dictionary mode (a.k.a. "slow" mode in v8)
|
|
67
|
+
create: supportsCreate ? function() {
|
|
68
|
+
return MakeDictionary(/* @__PURE__ */ Object.create(null));
|
|
69
|
+
} : supportsProto ? function() {
|
|
70
|
+
return MakeDictionary({ __proto__: null });
|
|
71
|
+
} : function() {
|
|
72
|
+
return MakeDictionary({});
|
|
73
|
+
},
|
|
74
|
+
has: downLevel ? function(map, key) {
|
|
75
|
+
return hasOwn.call(map, key);
|
|
76
|
+
} : function(map, key) {
|
|
77
|
+
return key in map;
|
|
78
|
+
},
|
|
79
|
+
get: downLevel ? function(map, key) {
|
|
80
|
+
return hasOwn.call(map, key) ? map[key] : void 0;
|
|
81
|
+
} : function(map, key) {
|
|
82
|
+
return map[key];
|
|
83
|
+
}
|
|
78
84
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
85
|
+
var functionPrototype = Object.getPrototypeOf(Function);
|
|
86
|
+
var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
|
|
87
|
+
var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
|
|
88
|
+
var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
|
|
89
|
+
var registrySymbol = supportsSymbol ? Symbol.for("@reflect-metadata:registry") : void 0;
|
|
90
|
+
var metadataRegistry = GetOrCreateMetadataRegistry();
|
|
91
|
+
var metadataProvider = CreateMetadataProvider(metadataRegistry);
|
|
92
|
+
function decorate(decorators, target, propertyKey, attributes) {
|
|
93
|
+
if (!IsUndefined(propertyKey)) {
|
|
94
|
+
if (!IsArray(decorators))
|
|
95
|
+
throw new TypeError();
|
|
96
|
+
if (!IsObject(target))
|
|
97
|
+
throw new TypeError();
|
|
98
|
+
if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
|
|
99
|
+
throw new TypeError();
|
|
100
|
+
if (IsNull(attributes))
|
|
101
|
+
attributes = void 0;
|
|
102
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
103
|
+
return DecorateProperty(decorators, target, propertyKey, attributes);
|
|
104
|
+
} else {
|
|
105
|
+
if (!IsArray(decorators))
|
|
106
|
+
throw new TypeError();
|
|
107
|
+
if (!IsConstructor(target))
|
|
108
|
+
throw new TypeError();
|
|
109
|
+
return DecorateConstructor(decorators, target);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exporter("decorate", decorate);
|
|
113
|
+
function metadata(metadataKey, metadataValue) {
|
|
114
|
+
function decorator(target, propertyKey) {
|
|
115
|
+
if (!IsObject(target))
|
|
116
|
+
throw new TypeError();
|
|
117
|
+
if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
|
|
118
|
+
throw new TypeError();
|
|
119
|
+
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
|
|
120
|
+
}
|
|
121
|
+
return decorator;
|
|
122
|
+
}
|
|
123
|
+
exporter("metadata", metadata);
|
|
124
|
+
function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
|
|
125
|
+
if (!IsObject(target))
|
|
126
|
+
throw new TypeError();
|
|
127
|
+
if (!IsUndefined(propertyKey))
|
|
128
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
129
|
+
return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
|
|
130
|
+
}
|
|
131
|
+
exporter("defineMetadata", defineMetadata);
|
|
132
|
+
function hasMetadata(metadataKey, target, propertyKey) {
|
|
133
|
+
if (!IsObject(target))
|
|
134
|
+
throw new TypeError();
|
|
135
|
+
if (!IsUndefined(propertyKey))
|
|
136
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
137
|
+
return OrdinaryHasMetadata(metadataKey, target, propertyKey);
|
|
138
|
+
}
|
|
139
|
+
exporter("hasMetadata", hasMetadata);
|
|
140
|
+
function hasOwnMetadata(metadataKey, target, propertyKey) {
|
|
141
|
+
if (!IsObject(target))
|
|
142
|
+
throw new TypeError();
|
|
143
|
+
if (!IsUndefined(propertyKey))
|
|
144
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
145
|
+
return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
|
|
146
|
+
}
|
|
147
|
+
exporter("hasOwnMetadata", hasOwnMetadata);
|
|
148
|
+
function getMetadata(metadataKey, target, propertyKey) {
|
|
149
|
+
if (!IsObject(target))
|
|
150
|
+
throw new TypeError();
|
|
151
|
+
if (!IsUndefined(propertyKey))
|
|
152
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
153
|
+
return OrdinaryGetMetadata(metadataKey, target, propertyKey);
|
|
154
|
+
}
|
|
155
|
+
exporter("getMetadata", getMetadata);
|
|
156
|
+
function getOwnMetadata(metadataKey, target, propertyKey) {
|
|
157
|
+
if (!IsObject(target))
|
|
158
|
+
throw new TypeError();
|
|
159
|
+
if (!IsUndefined(propertyKey))
|
|
160
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
161
|
+
return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
|
|
162
|
+
}
|
|
163
|
+
exporter("getOwnMetadata", getOwnMetadata);
|
|
164
|
+
function getMetadataKeys(target, propertyKey) {
|
|
165
|
+
if (!IsObject(target))
|
|
166
|
+
throw new TypeError();
|
|
167
|
+
if (!IsUndefined(propertyKey))
|
|
168
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
169
|
+
return OrdinaryMetadataKeys(target, propertyKey);
|
|
170
|
+
}
|
|
171
|
+
exporter("getMetadataKeys", getMetadataKeys);
|
|
172
|
+
function getOwnMetadataKeys(target, propertyKey) {
|
|
173
|
+
if (!IsObject(target))
|
|
174
|
+
throw new TypeError();
|
|
175
|
+
if (!IsUndefined(propertyKey))
|
|
176
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
177
|
+
return OrdinaryOwnMetadataKeys(target, propertyKey);
|
|
178
|
+
}
|
|
179
|
+
exporter("getOwnMetadataKeys", getOwnMetadataKeys);
|
|
180
|
+
function deleteMetadata(metadataKey, target, propertyKey) {
|
|
181
|
+
if (!IsObject(target))
|
|
182
|
+
throw new TypeError();
|
|
183
|
+
if (!IsUndefined(propertyKey))
|
|
184
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
185
|
+
if (!IsObject(target))
|
|
186
|
+
throw new TypeError();
|
|
187
|
+
if (!IsUndefined(propertyKey))
|
|
188
|
+
propertyKey = ToPropertyKey(propertyKey);
|
|
189
|
+
var provider = GetMetadataProvider(
|
|
190
|
+
target,
|
|
191
|
+
propertyKey,
|
|
192
|
+
/*Create*/
|
|
193
|
+
false
|
|
135
194
|
);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
195
|
+
if (IsUndefined(provider))
|
|
196
|
+
return false;
|
|
197
|
+
return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
|
|
198
|
+
}
|
|
199
|
+
exporter("deleteMetadata", deleteMetadata);
|
|
200
|
+
function DecorateConstructor(decorators, target) {
|
|
201
|
+
for (var i = decorators.length - 1; i >= 0; --i) {
|
|
202
|
+
var decorator = decorators[i];
|
|
203
|
+
var decorated = decorator(target);
|
|
204
|
+
if (!IsUndefined(decorated) && !IsNull(decorated)) {
|
|
205
|
+
if (!IsConstructor(decorated))
|
|
206
|
+
throw new TypeError();
|
|
207
|
+
target = decorated;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return target;
|
|
211
|
+
}
|
|
212
|
+
function DecorateProperty(decorators, target, propertyKey, descriptor) {
|
|
213
|
+
for (var i = decorators.length - 1; i >= 0; --i) {
|
|
214
|
+
var decorator = decorators[i];
|
|
215
|
+
var decorated = decorator(target, propertyKey, descriptor);
|
|
216
|
+
if (!IsUndefined(decorated) && !IsNull(decorated)) {
|
|
217
|
+
if (!IsObject(decorated))
|
|
218
|
+
throw new TypeError();
|
|
219
|
+
descriptor = decorated;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return descriptor;
|
|
223
|
+
}
|
|
224
|
+
function OrdinaryHasMetadata(MetadataKey, O, P) {
|
|
225
|
+
var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
|
226
|
+
if (hasOwn2)
|
|
227
|
+
return true;
|
|
228
|
+
var parent = OrdinaryGetPrototypeOf(O);
|
|
229
|
+
if (!IsNull(parent))
|
|
230
|
+
return OrdinaryHasMetadata(MetadataKey, parent, P);
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
|
|
234
|
+
var provider = GetMetadataProvider(
|
|
235
|
+
O,
|
|
236
|
+
P,
|
|
237
|
+
/*Create*/
|
|
238
|
+
false
|
|
239
|
+
);
|
|
240
|
+
if (IsUndefined(provider))
|
|
241
|
+
return false;
|
|
242
|
+
return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
|
|
243
|
+
}
|
|
244
|
+
function OrdinaryGetMetadata(MetadataKey, O, P) {
|
|
245
|
+
var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
|
246
|
+
if (hasOwn2)
|
|
247
|
+
return OrdinaryGetOwnMetadata(MetadataKey, O, P);
|
|
248
|
+
var parent = OrdinaryGetPrototypeOf(O);
|
|
249
|
+
if (!IsNull(parent))
|
|
250
|
+
return OrdinaryGetMetadata(MetadataKey, parent, P);
|
|
251
|
+
return void 0;
|
|
252
|
+
}
|
|
253
|
+
function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
|
|
254
|
+
var provider = GetMetadataProvider(
|
|
255
|
+
O,
|
|
256
|
+
P,
|
|
257
|
+
/*Create*/
|
|
258
|
+
false
|
|
259
|
+
);
|
|
260
|
+
if (IsUndefined(provider))
|
|
261
|
+
return;
|
|
262
|
+
return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
|
|
263
|
+
}
|
|
264
|
+
function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
|
|
265
|
+
var provider = GetMetadataProvider(
|
|
266
|
+
O,
|
|
267
|
+
P,
|
|
268
|
+
/*Create*/
|
|
269
|
+
true
|
|
270
|
+
);
|
|
271
|
+
provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
|
|
272
|
+
}
|
|
273
|
+
function OrdinaryMetadataKeys(O, P) {
|
|
274
|
+
var ownKeys = OrdinaryOwnMetadataKeys(O, P);
|
|
275
|
+
var parent = OrdinaryGetPrototypeOf(O);
|
|
276
|
+
if (parent === null)
|
|
277
|
+
return ownKeys;
|
|
278
|
+
var parentKeys = OrdinaryMetadataKeys(parent, P);
|
|
279
|
+
if (parentKeys.length <= 0)
|
|
280
|
+
return ownKeys;
|
|
281
|
+
if (ownKeys.length <= 0)
|
|
282
|
+
return parentKeys;
|
|
283
|
+
var set = new _Set();
|
|
284
|
+
var keys = [];
|
|
285
|
+
for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
|
|
286
|
+
var key = ownKeys_1[_i];
|
|
287
|
+
var hasKey = set.has(key);
|
|
288
|
+
if (!hasKey) {
|
|
289
|
+
set.add(key);
|
|
290
|
+
keys.push(key);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
|
|
294
|
+
var key = parentKeys_1[_a];
|
|
295
|
+
var hasKey = set.has(key);
|
|
296
|
+
if (!hasKey) {
|
|
297
|
+
set.add(key);
|
|
298
|
+
keys.push(key);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return keys;
|
|
302
|
+
}
|
|
303
|
+
function OrdinaryOwnMetadataKeys(O, P) {
|
|
304
|
+
var provider = GetMetadataProvider(
|
|
305
|
+
O,
|
|
306
|
+
P,
|
|
307
|
+
/*create*/
|
|
308
|
+
false
|
|
309
|
+
);
|
|
310
|
+
if (!provider) {
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
return provider.OrdinaryOwnMetadataKeys(O, P);
|
|
314
|
+
}
|
|
315
|
+
function Type(x) {
|
|
316
|
+
if (x === null)
|
|
317
|
+
return 1;
|
|
318
|
+
switch (typeof x) {
|
|
319
|
+
case "undefined":
|
|
320
|
+
return 0;
|
|
321
|
+
case "boolean":
|
|
322
|
+
return 2;
|
|
323
|
+
case "string":
|
|
324
|
+
return 3;
|
|
325
|
+
case "symbol":
|
|
326
|
+
return 4;
|
|
327
|
+
case "number":
|
|
328
|
+
return 5;
|
|
329
|
+
case "object":
|
|
330
|
+
return x === null ? 1 : 6;
|
|
331
|
+
default:
|
|
332
|
+
return 6;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function IsUndefined(x) {
|
|
336
|
+
return x === void 0;
|
|
337
|
+
}
|
|
338
|
+
function IsNull(x) {
|
|
339
|
+
return x === null;
|
|
340
|
+
}
|
|
341
|
+
function IsSymbol(x) {
|
|
342
|
+
return typeof x === "symbol";
|
|
343
|
+
}
|
|
344
|
+
function IsObject(x) {
|
|
345
|
+
return typeof x === "object" ? x !== null : typeof x === "function";
|
|
346
|
+
}
|
|
347
|
+
function ToPrimitive(input, PreferredType) {
|
|
348
|
+
switch (Type(input)) {
|
|
349
|
+
case 0:
|
|
350
|
+
return input;
|
|
351
|
+
case 1:
|
|
352
|
+
return input;
|
|
353
|
+
case 2:
|
|
354
|
+
return input;
|
|
355
|
+
case 3:
|
|
356
|
+
return input;
|
|
357
|
+
case 4:
|
|
358
|
+
return input;
|
|
359
|
+
case 5:
|
|
360
|
+
return input;
|
|
361
|
+
}
|
|
362
|
+
var hint = "string";
|
|
363
|
+
var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
|
|
364
|
+
if (exoticToPrim !== void 0) {
|
|
365
|
+
var result = exoticToPrim.call(input, hint);
|
|
366
|
+
if (IsObject(result))
|
|
367
|
+
throw new TypeError();
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
return OrdinaryToPrimitive(input);
|
|
371
|
+
}
|
|
372
|
+
function OrdinaryToPrimitive(O, hint) {
|
|
373
|
+
var valueOf, result;
|
|
374
|
+
{
|
|
375
|
+
var toString_1 = O.toString;
|
|
376
|
+
if (IsCallable(toString_1)) {
|
|
377
|
+
var result = toString_1.call(O);
|
|
378
|
+
if (!IsObject(result))
|
|
379
|
+
return result;
|
|
380
|
+
}
|
|
381
|
+
var valueOf = O.valueOf;
|
|
382
|
+
if (IsCallable(valueOf)) {
|
|
383
|
+
var result = valueOf.call(O);
|
|
384
|
+
if (!IsObject(result))
|
|
385
|
+
return result;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
throw new TypeError();
|
|
389
|
+
}
|
|
390
|
+
function ToBoolean(argument) {
|
|
391
|
+
return !!argument;
|
|
392
|
+
}
|
|
393
|
+
function ToString(argument) {
|
|
394
|
+
return "" + argument;
|
|
395
|
+
}
|
|
396
|
+
function ToPropertyKey(argument) {
|
|
397
|
+
var key = ToPrimitive(argument);
|
|
398
|
+
if (IsSymbol(key))
|
|
399
|
+
return key;
|
|
400
|
+
return ToString(key);
|
|
401
|
+
}
|
|
402
|
+
function IsArray(argument) {
|
|
403
|
+
return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
|
|
404
|
+
}
|
|
405
|
+
function IsCallable(argument) {
|
|
406
|
+
return typeof argument === "function";
|
|
407
|
+
}
|
|
408
|
+
function IsConstructor(argument) {
|
|
409
|
+
return typeof argument === "function";
|
|
410
|
+
}
|
|
411
|
+
function IsPropertyKey(argument) {
|
|
412
|
+
switch (Type(argument)) {
|
|
413
|
+
case 3:
|
|
414
|
+
return true;
|
|
415
|
+
case 4:
|
|
416
|
+
return true;
|
|
417
|
+
default:
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function SameValueZero(x, y) {
|
|
422
|
+
return x === y || x !== x && y !== y;
|
|
423
|
+
}
|
|
424
|
+
function GetMethod(V, P) {
|
|
425
|
+
var func = V[P];
|
|
426
|
+
if (func === void 0 || func === null)
|
|
427
|
+
return void 0;
|
|
428
|
+
if (!IsCallable(func))
|
|
429
|
+
throw new TypeError();
|
|
430
|
+
return func;
|
|
431
|
+
}
|
|
432
|
+
function GetIterator(obj) {
|
|
433
|
+
var method = GetMethod(obj, iteratorSymbol);
|
|
434
|
+
if (!IsCallable(method))
|
|
435
|
+
throw new TypeError();
|
|
436
|
+
var iterator = method.call(obj);
|
|
437
|
+
if (!IsObject(iterator))
|
|
438
|
+
throw new TypeError();
|
|
439
|
+
return iterator;
|
|
440
|
+
}
|
|
441
|
+
function IteratorValue(iterResult) {
|
|
442
|
+
return iterResult.value;
|
|
443
|
+
}
|
|
444
|
+
function IteratorStep(iterator) {
|
|
445
|
+
var result = iterator.next();
|
|
446
|
+
return result.done ? false : result;
|
|
447
|
+
}
|
|
448
|
+
function IteratorClose(iterator) {
|
|
449
|
+
var f = iterator["return"];
|
|
450
|
+
if (f)
|
|
451
|
+
f.call(iterator);
|
|
452
|
+
}
|
|
453
|
+
function OrdinaryGetPrototypeOf(O) {
|
|
454
|
+
var proto = Object.getPrototypeOf(O);
|
|
455
|
+
if (typeof O !== "function" || O === functionPrototype)
|
|
456
|
+
return proto;
|
|
457
|
+
if (proto !== functionPrototype)
|
|
458
|
+
return proto;
|
|
459
|
+
var prototype2 = O.prototype;
|
|
460
|
+
var prototypeProto = prototype2 && Object.getPrototypeOf(prototype2);
|
|
461
|
+
if (prototypeProto == null || prototypeProto === Object.prototype)
|
|
462
|
+
return proto;
|
|
463
|
+
var constructor = prototypeProto.constructor;
|
|
464
|
+
if (typeof constructor !== "function")
|
|
465
|
+
return proto;
|
|
466
|
+
if (constructor === O)
|
|
467
|
+
return proto;
|
|
468
|
+
return constructor;
|
|
469
|
+
}
|
|
470
|
+
function CreateMetadataRegistry() {
|
|
471
|
+
var fallback;
|
|
472
|
+
if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") {
|
|
473
|
+
fallback = CreateFallbackProvider(root.Reflect);
|
|
474
|
+
}
|
|
475
|
+
var first;
|
|
476
|
+
var second;
|
|
477
|
+
var rest;
|
|
478
|
+
var targetProviderMap = new _WeakMap();
|
|
479
|
+
var registry = {
|
|
480
|
+
registerProvider,
|
|
481
|
+
getProvider,
|
|
482
|
+
setProvider
|
|
139
483
|
};
|
|
484
|
+
return registry;
|
|
485
|
+
function registerProvider(provider) {
|
|
486
|
+
if (!Object.isExtensible(registry)) {
|
|
487
|
+
throw new Error("Cannot add provider to a frozen registry.");
|
|
488
|
+
}
|
|
489
|
+
switch (true) {
|
|
490
|
+
case fallback === provider:
|
|
491
|
+
break;
|
|
492
|
+
case IsUndefined(first):
|
|
493
|
+
first = provider;
|
|
494
|
+
break;
|
|
495
|
+
case first === provider:
|
|
496
|
+
break;
|
|
497
|
+
case IsUndefined(second):
|
|
498
|
+
second = provider;
|
|
499
|
+
break;
|
|
500
|
+
case second === provider:
|
|
501
|
+
break;
|
|
502
|
+
default:
|
|
503
|
+
if (rest === void 0)
|
|
504
|
+
rest = new _Set();
|
|
505
|
+
rest.add(provider);
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function getProviderNoCache(O, P) {
|
|
510
|
+
if (!IsUndefined(first)) {
|
|
511
|
+
if (first.isProviderFor(O, P))
|
|
512
|
+
return first;
|
|
513
|
+
if (!IsUndefined(second)) {
|
|
514
|
+
if (second.isProviderFor(O, P))
|
|
515
|
+
return first;
|
|
516
|
+
if (!IsUndefined(rest)) {
|
|
517
|
+
var iterator = GetIterator(rest);
|
|
518
|
+
while (true) {
|
|
519
|
+
var next = IteratorStep(iterator);
|
|
520
|
+
if (!next) {
|
|
521
|
+
return void 0;
|
|
522
|
+
}
|
|
523
|
+
var provider = IteratorValue(next);
|
|
524
|
+
if (provider.isProviderFor(O, P)) {
|
|
525
|
+
IteratorClose(iterator);
|
|
526
|
+
return provider;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {
|
|
533
|
+
return fallback;
|
|
534
|
+
}
|
|
535
|
+
return void 0;
|
|
536
|
+
}
|
|
537
|
+
function getProvider(O, P) {
|
|
538
|
+
var providerMap = targetProviderMap.get(O);
|
|
539
|
+
var provider;
|
|
540
|
+
if (!IsUndefined(providerMap)) {
|
|
541
|
+
provider = providerMap.get(P);
|
|
542
|
+
}
|
|
543
|
+
if (!IsUndefined(provider)) {
|
|
544
|
+
return provider;
|
|
545
|
+
}
|
|
546
|
+
provider = getProviderNoCache(O, P);
|
|
547
|
+
if (!IsUndefined(provider)) {
|
|
548
|
+
if (IsUndefined(providerMap)) {
|
|
549
|
+
providerMap = new _Map();
|
|
550
|
+
targetProviderMap.set(O, providerMap);
|
|
551
|
+
}
|
|
552
|
+
providerMap.set(P, provider);
|
|
553
|
+
}
|
|
554
|
+
return provider;
|
|
555
|
+
}
|
|
556
|
+
function hasProvider(provider) {
|
|
557
|
+
if (IsUndefined(provider))
|
|
558
|
+
throw new TypeError();
|
|
559
|
+
return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
|
|
560
|
+
}
|
|
561
|
+
function setProvider(O, P, provider) {
|
|
562
|
+
if (!hasProvider(provider)) {
|
|
563
|
+
throw new Error("Metadata provider not registered.");
|
|
564
|
+
}
|
|
565
|
+
var existingProvider = getProvider(O, P);
|
|
566
|
+
if (existingProvider !== provider) {
|
|
567
|
+
if (!IsUndefined(existingProvider)) {
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
var providerMap = targetProviderMap.get(O);
|
|
571
|
+
if (IsUndefined(providerMap)) {
|
|
572
|
+
providerMap = new _Map();
|
|
573
|
+
targetProviderMap.set(O, providerMap);
|
|
574
|
+
}
|
|
575
|
+
providerMap.set(P, provider);
|
|
576
|
+
}
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
140
579
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const version = (options == null ? void 0 : options.version) || this.version;
|
|
156
|
-
console.log("send version:", version);
|
|
157
|
-
this.handleVersioning(version);
|
|
158
|
-
return new Promise(async (resolve, reject) => {
|
|
159
|
-
var _a, _b, _c;
|
|
160
|
-
const { data, headers } = this.processRequestPipes();
|
|
161
|
-
this.data = data;
|
|
162
|
-
this.headers = headers;
|
|
163
|
-
this.key = apiKey(this);
|
|
164
|
-
const cachedResponse = await this.checkCache(version);
|
|
165
|
-
if (cachedResponse) {
|
|
166
|
-
const versionUrl = ((_a = this.versioning) == null ? void 0 : _a.url) ? (_b = this.versioning) == null ? void 0 : _b.url : "";
|
|
167
|
-
console.warn(
|
|
168
|
-
`请求[${this.context.baseURL}/${versionUrl == "" ? "" : `${versionUrl}/`}${this.url}]命中缓存`
|
|
169
|
-
);
|
|
170
|
-
return resolve({
|
|
171
|
-
error: null,
|
|
172
|
-
data: cachedResponse,
|
|
173
|
-
hitCache: this.hitCache,
|
|
174
|
-
Catch: (handler) => handler()
|
|
580
|
+
function GetOrCreateMetadataRegistry() {
|
|
581
|
+
var metadataRegistry2;
|
|
582
|
+
if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
|
|
583
|
+
metadataRegistry2 = root.Reflect[registrySymbol];
|
|
584
|
+
}
|
|
585
|
+
if (IsUndefined(metadataRegistry2)) {
|
|
586
|
+
metadataRegistry2 = CreateMetadataRegistry();
|
|
587
|
+
}
|
|
588
|
+
if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
|
|
589
|
+
Object.defineProperty(root.Reflect, registrySymbol, {
|
|
590
|
+
enumerable: false,
|
|
591
|
+
configurable: false,
|
|
592
|
+
writable: false,
|
|
593
|
+
value: metadataRegistry2
|
|
175
594
|
});
|
|
176
595
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
596
|
+
return metadataRegistry2;
|
|
597
|
+
}
|
|
598
|
+
function CreateMetadataProvider(registry) {
|
|
599
|
+
var metadata2 = new _WeakMap();
|
|
600
|
+
var provider = {
|
|
601
|
+
isProviderFor: function(O, P) {
|
|
602
|
+
var targetMetadata = metadata2.get(O);
|
|
603
|
+
if (IsUndefined(targetMetadata))
|
|
604
|
+
return false;
|
|
605
|
+
return targetMetadata.has(P);
|
|
606
|
+
},
|
|
607
|
+
OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata2,
|
|
608
|
+
OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata2,
|
|
609
|
+
OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata2,
|
|
610
|
+
OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys2,
|
|
611
|
+
OrdinaryDeleteMetadata
|
|
612
|
+
};
|
|
613
|
+
metadataRegistry.registerProvider(provider);
|
|
614
|
+
return provider;
|
|
615
|
+
function GetOrCreateMetadataMap(O, P, Create) {
|
|
616
|
+
var targetMetadata = metadata2.get(O);
|
|
617
|
+
var createdTargetMetadata = false;
|
|
618
|
+
if (IsUndefined(targetMetadata)) {
|
|
619
|
+
if (!Create)
|
|
620
|
+
return void 0;
|
|
621
|
+
targetMetadata = new _Map();
|
|
622
|
+
metadata2.set(O, targetMetadata);
|
|
623
|
+
createdTargetMetadata = true;
|
|
187
624
|
}
|
|
188
|
-
|
|
189
|
-
(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
});
|
|
625
|
+
var metadataMap = targetMetadata.get(P);
|
|
626
|
+
if (IsUndefined(metadataMap)) {
|
|
627
|
+
if (!Create)
|
|
628
|
+
return void 0;
|
|
629
|
+
metadataMap = new _Map();
|
|
630
|
+
targetMetadata.set(P, metadataMap);
|
|
631
|
+
if (!registry.setProvider(O, P, provider)) {
|
|
632
|
+
targetMetadata.delete(P);
|
|
633
|
+
if (createdTargetMetadata) {
|
|
634
|
+
metadata2.delete(O);
|
|
635
|
+
}
|
|
636
|
+
throw new Error("Wrong provider for target.");
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return metadataMap;
|
|
204
640
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
tempKey = apiKey({
|
|
216
|
-
...this,
|
|
217
|
-
version
|
|
218
|
-
});
|
|
641
|
+
function OrdinaryHasOwnMetadata2(MetadataKey, O, P) {
|
|
642
|
+
var metadataMap = GetOrCreateMetadataMap(
|
|
643
|
+
O,
|
|
644
|
+
P,
|
|
645
|
+
/*Create*/
|
|
646
|
+
false
|
|
647
|
+
);
|
|
648
|
+
if (IsUndefined(metadataMap))
|
|
649
|
+
return false;
|
|
650
|
+
return ToBoolean(metadataMap.has(MetadataKey));
|
|
219
651
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
652
|
+
function OrdinaryGetOwnMetadata2(MetadataKey, O, P) {
|
|
653
|
+
var metadataMap = GetOrCreateMetadataMap(
|
|
654
|
+
O,
|
|
655
|
+
P,
|
|
656
|
+
/*Create*/
|
|
657
|
+
false
|
|
658
|
+
);
|
|
659
|
+
if (IsUndefined(metadataMap))
|
|
660
|
+
return void 0;
|
|
661
|
+
return metadataMap.get(MetadataKey);
|
|
662
|
+
}
|
|
663
|
+
function OrdinaryDefineOwnMetadata2(MetadataKey, MetadataValue, O, P) {
|
|
664
|
+
var metadataMap = GetOrCreateMetadataMap(
|
|
665
|
+
O,
|
|
666
|
+
P,
|
|
667
|
+
/*Create*/
|
|
668
|
+
true
|
|
669
|
+
);
|
|
670
|
+
metadataMap.set(MetadataKey, MetadataValue);
|
|
671
|
+
}
|
|
672
|
+
function OrdinaryOwnMetadataKeys2(O, P) {
|
|
673
|
+
var keys = [];
|
|
674
|
+
var metadataMap = GetOrCreateMetadataMap(
|
|
675
|
+
O,
|
|
676
|
+
P,
|
|
677
|
+
/*Create*/
|
|
678
|
+
false
|
|
679
|
+
);
|
|
680
|
+
if (IsUndefined(metadataMap))
|
|
681
|
+
return keys;
|
|
682
|
+
var keysObj = metadataMap.keys();
|
|
683
|
+
var iterator = GetIterator(keysObj);
|
|
684
|
+
var k = 0;
|
|
685
|
+
while (true) {
|
|
686
|
+
var next = IteratorStep(iterator);
|
|
687
|
+
if (!next) {
|
|
688
|
+
keys.length = k;
|
|
689
|
+
return keys;
|
|
690
|
+
}
|
|
691
|
+
var nextValue = IteratorValue(next);
|
|
692
|
+
try {
|
|
693
|
+
keys[k] = nextValue;
|
|
694
|
+
} catch (e) {
|
|
695
|
+
try {
|
|
696
|
+
IteratorClose(iterator);
|
|
697
|
+
} finally {
|
|
698
|
+
throw e;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
k++;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function OrdinaryDeleteMetadata(MetadataKey, O, P) {
|
|
705
|
+
var metadataMap = GetOrCreateMetadataMap(
|
|
706
|
+
O,
|
|
707
|
+
P,
|
|
708
|
+
/*Create*/
|
|
709
|
+
false
|
|
710
|
+
);
|
|
711
|
+
if (IsUndefined(metadataMap))
|
|
712
|
+
return false;
|
|
713
|
+
if (!metadataMap.delete(MetadataKey))
|
|
714
|
+
return false;
|
|
715
|
+
if (metadataMap.size === 0) {
|
|
716
|
+
var targetMetadata = metadata2.get(O);
|
|
717
|
+
if (!IsUndefined(targetMetadata)) {
|
|
718
|
+
targetMetadata.delete(P);
|
|
719
|
+
if (targetMetadata.size === 0) {
|
|
720
|
+
metadata2.delete(targetMetadata);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return true;
|
|
226
725
|
}
|
|
227
|
-
this.hitCache = true;
|
|
228
|
-
return resolve(data);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
async delCache(version) {
|
|
232
|
-
let tempKey;
|
|
233
|
-
if (version) {
|
|
234
|
-
tempKey = apiKey({
|
|
235
|
-
...this,
|
|
236
|
-
version
|
|
237
|
-
});
|
|
238
726
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
727
|
+
function CreateFallbackProvider(reflect) {
|
|
728
|
+
var defineMetadata2 = reflect.defineMetadata, hasOwnMetadata2 = reflect.hasOwnMetadata, getOwnMetadata2 = reflect.getOwnMetadata, getOwnMetadataKeys2 = reflect.getOwnMetadataKeys, deleteMetadata2 = reflect.deleteMetadata;
|
|
729
|
+
var metadataOwner = new _WeakMap();
|
|
730
|
+
var provider = {
|
|
731
|
+
isProviderFor: function(O, P) {
|
|
732
|
+
var metadataPropertySet = metadataOwner.get(O);
|
|
733
|
+
if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
if (getOwnMetadataKeys2(O, P).length) {
|
|
737
|
+
if (IsUndefined(metadataPropertySet)) {
|
|
738
|
+
metadataPropertySet = new _Set();
|
|
739
|
+
metadataOwner.set(O, metadataPropertySet);
|
|
740
|
+
}
|
|
741
|
+
metadataPropertySet.add(P);
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
744
|
+
return false;
|
|
251
745
|
},
|
|
252
|
-
|
|
746
|
+
OrdinaryDefineOwnMetadata: defineMetadata2,
|
|
747
|
+
OrdinaryHasOwnMetadata: hasOwnMetadata2,
|
|
748
|
+
OrdinaryGetOwnMetadata: getOwnMetadata2,
|
|
749
|
+
OrdinaryOwnMetadataKeys: getOwnMetadataKeys2,
|
|
750
|
+
OrdinaryDeleteMetadata: deleteMetadata2
|
|
751
|
+
};
|
|
752
|
+
return provider;
|
|
753
|
+
}
|
|
754
|
+
function GetMetadataProvider(O, P, Create) {
|
|
755
|
+
var registeredProvider = metadataRegistry.getProvider(O, P);
|
|
756
|
+
if (!IsUndefined(registeredProvider)) {
|
|
757
|
+
return registeredProvider;
|
|
758
|
+
}
|
|
759
|
+
if (Create) {
|
|
760
|
+
if (metadataRegistry.setProvider(O, P, metadataProvider)) {
|
|
761
|
+
return metadataProvider;
|
|
762
|
+
}
|
|
763
|
+
throw new Error("Illegal state.");
|
|
764
|
+
}
|
|
765
|
+
return void 0;
|
|
766
|
+
}
|
|
767
|
+
function CreateMapPolyfill() {
|
|
768
|
+
var cacheSentinel = {};
|
|
769
|
+
var arraySentinel = [];
|
|
770
|
+
var MapIterator = (
|
|
771
|
+
/** @class */
|
|
772
|
+
function() {
|
|
773
|
+
function MapIterator2(keys, values, selector) {
|
|
774
|
+
this._index = 0;
|
|
775
|
+
this._keys = keys;
|
|
776
|
+
this._values = values;
|
|
777
|
+
this._selector = selector;
|
|
778
|
+
}
|
|
779
|
+
MapIterator2.prototype["@@iterator"] = function() {
|
|
780
|
+
return this;
|
|
781
|
+
};
|
|
782
|
+
MapIterator2.prototype[iteratorSymbol] = function() {
|
|
783
|
+
return this;
|
|
784
|
+
};
|
|
785
|
+
MapIterator2.prototype.next = function() {
|
|
786
|
+
var index = this._index;
|
|
787
|
+
if (index >= 0 && index < this._keys.length) {
|
|
788
|
+
var result = this._selector(this._keys[index], this._values[index]);
|
|
789
|
+
if (index + 1 >= this._keys.length) {
|
|
790
|
+
this._index = -1;
|
|
791
|
+
this._keys = arraySentinel;
|
|
792
|
+
this._values = arraySentinel;
|
|
793
|
+
} else {
|
|
794
|
+
this._index++;
|
|
795
|
+
}
|
|
796
|
+
return { value: result, done: false };
|
|
797
|
+
}
|
|
798
|
+
return { value: void 0, done: true };
|
|
799
|
+
};
|
|
800
|
+
MapIterator2.prototype.throw = function(error) {
|
|
801
|
+
if (this._index >= 0) {
|
|
802
|
+
this._index = -1;
|
|
803
|
+
this._keys = arraySentinel;
|
|
804
|
+
this._values = arraySentinel;
|
|
805
|
+
}
|
|
806
|
+
throw error;
|
|
807
|
+
};
|
|
808
|
+
MapIterator2.prototype.return = function(value) {
|
|
809
|
+
if (this._index >= 0) {
|
|
810
|
+
this._index = -1;
|
|
811
|
+
this._keys = arraySentinel;
|
|
812
|
+
this._values = arraySentinel;
|
|
813
|
+
}
|
|
814
|
+
return { value, done: true };
|
|
815
|
+
};
|
|
816
|
+
return MapIterator2;
|
|
817
|
+
}()
|
|
818
|
+
);
|
|
819
|
+
var Map2 = (
|
|
820
|
+
/** @class */
|
|
821
|
+
function() {
|
|
822
|
+
function Map3() {
|
|
823
|
+
this._keys = [];
|
|
824
|
+
this._values = [];
|
|
825
|
+
this._cacheKey = cacheSentinel;
|
|
826
|
+
this._cacheIndex = -2;
|
|
827
|
+
}
|
|
828
|
+
Object.defineProperty(Map3.prototype, "size", {
|
|
829
|
+
get: function() {
|
|
830
|
+
return this._keys.length;
|
|
831
|
+
},
|
|
832
|
+
enumerable: true,
|
|
833
|
+
configurable: true
|
|
834
|
+
});
|
|
835
|
+
Map3.prototype.has = function(key) {
|
|
836
|
+
return this._find(
|
|
837
|
+
key,
|
|
838
|
+
/*insert*/
|
|
839
|
+
false
|
|
840
|
+
) >= 0;
|
|
841
|
+
};
|
|
842
|
+
Map3.prototype.get = function(key) {
|
|
843
|
+
var index = this._find(
|
|
844
|
+
key,
|
|
845
|
+
/*insert*/
|
|
846
|
+
false
|
|
847
|
+
);
|
|
848
|
+
return index >= 0 ? this._values[index] : void 0;
|
|
849
|
+
};
|
|
850
|
+
Map3.prototype.set = function(key, value) {
|
|
851
|
+
var index = this._find(
|
|
852
|
+
key,
|
|
853
|
+
/*insert*/
|
|
854
|
+
true
|
|
855
|
+
);
|
|
856
|
+
this._values[index] = value;
|
|
857
|
+
return this;
|
|
858
|
+
};
|
|
859
|
+
Map3.prototype.delete = function(key) {
|
|
860
|
+
var index = this._find(
|
|
861
|
+
key,
|
|
862
|
+
/*insert*/
|
|
863
|
+
false
|
|
864
|
+
);
|
|
865
|
+
if (index >= 0) {
|
|
866
|
+
var size = this._keys.length;
|
|
867
|
+
for (var i = index + 1; i < size; i++) {
|
|
868
|
+
this._keys[i - 1] = this._keys[i];
|
|
869
|
+
this._values[i - 1] = this._values[i];
|
|
870
|
+
}
|
|
871
|
+
this._keys.length--;
|
|
872
|
+
this._values.length--;
|
|
873
|
+
if (SameValueZero(key, this._cacheKey)) {
|
|
874
|
+
this._cacheKey = cacheSentinel;
|
|
875
|
+
this._cacheIndex = -2;
|
|
876
|
+
}
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
return false;
|
|
880
|
+
};
|
|
881
|
+
Map3.prototype.clear = function() {
|
|
882
|
+
this._keys.length = 0;
|
|
883
|
+
this._values.length = 0;
|
|
884
|
+
this._cacheKey = cacheSentinel;
|
|
885
|
+
this._cacheIndex = -2;
|
|
886
|
+
};
|
|
887
|
+
Map3.prototype.keys = function() {
|
|
888
|
+
return new MapIterator(this._keys, this._values, getKey);
|
|
889
|
+
};
|
|
890
|
+
Map3.prototype.values = function() {
|
|
891
|
+
return new MapIterator(this._keys, this._values, getValue);
|
|
892
|
+
};
|
|
893
|
+
Map3.prototype.entries = function() {
|
|
894
|
+
return new MapIterator(this._keys, this._values, getEntry);
|
|
895
|
+
};
|
|
896
|
+
Map3.prototype["@@iterator"] = function() {
|
|
897
|
+
return this.entries();
|
|
898
|
+
};
|
|
899
|
+
Map3.prototype[iteratorSymbol] = function() {
|
|
900
|
+
return this.entries();
|
|
901
|
+
};
|
|
902
|
+
Map3.prototype._find = function(key, insert) {
|
|
903
|
+
if (!SameValueZero(this._cacheKey, key)) {
|
|
904
|
+
this._cacheIndex = -1;
|
|
905
|
+
for (var i = 0; i < this._keys.length; i++) {
|
|
906
|
+
if (SameValueZero(this._keys[i], key)) {
|
|
907
|
+
this._cacheIndex = i;
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
if (this._cacheIndex < 0 && insert) {
|
|
913
|
+
this._cacheIndex = this._keys.length;
|
|
914
|
+
this._keys.push(key);
|
|
915
|
+
this._values.push(void 0);
|
|
916
|
+
}
|
|
917
|
+
return this._cacheIndex;
|
|
918
|
+
};
|
|
919
|
+
return Map3;
|
|
920
|
+
}()
|
|
253
921
|
);
|
|
254
|
-
|
|
255
|
-
|
|
922
|
+
return Map2;
|
|
923
|
+
function getKey(key, _) {
|
|
924
|
+
return key;
|
|
925
|
+
}
|
|
926
|
+
function getValue(_, value) {
|
|
927
|
+
return value;
|
|
928
|
+
}
|
|
929
|
+
function getEntry(key, value) {
|
|
930
|
+
return [key, value];
|
|
931
|
+
}
|
|
256
932
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
933
|
+
function CreateSetPolyfill() {
|
|
934
|
+
var Set2 = (
|
|
935
|
+
/** @class */
|
|
936
|
+
function() {
|
|
937
|
+
function Set3() {
|
|
938
|
+
this._map = new _Map();
|
|
939
|
+
}
|
|
940
|
+
Object.defineProperty(Set3.prototype, "size", {
|
|
941
|
+
get: function() {
|
|
942
|
+
return this._map.size;
|
|
943
|
+
},
|
|
944
|
+
enumerable: true,
|
|
945
|
+
configurable: true
|
|
946
|
+
});
|
|
947
|
+
Set3.prototype.has = function(value) {
|
|
948
|
+
return this._map.has(value);
|
|
949
|
+
};
|
|
950
|
+
Set3.prototype.add = function(value) {
|
|
951
|
+
return this._map.set(value, value), this;
|
|
952
|
+
};
|
|
953
|
+
Set3.prototype.delete = function(value) {
|
|
954
|
+
return this._map.delete(value);
|
|
955
|
+
};
|
|
956
|
+
Set3.prototype.clear = function() {
|
|
957
|
+
this._map.clear();
|
|
958
|
+
};
|
|
959
|
+
Set3.prototype.keys = function() {
|
|
960
|
+
return this._map.keys();
|
|
961
|
+
};
|
|
962
|
+
Set3.prototype.values = function() {
|
|
963
|
+
return this._map.keys();
|
|
964
|
+
};
|
|
965
|
+
Set3.prototype.entries = function() {
|
|
966
|
+
return this._map.entries();
|
|
967
|
+
};
|
|
968
|
+
Set3.prototype["@@iterator"] = function() {
|
|
969
|
+
return this.keys();
|
|
970
|
+
};
|
|
971
|
+
Set3.prototype[iteratorSymbol] = function() {
|
|
972
|
+
return this.keys();
|
|
973
|
+
};
|
|
974
|
+
return Set3;
|
|
975
|
+
}()
|
|
976
|
+
);
|
|
977
|
+
return Set2;
|
|
978
|
+
}
|
|
979
|
+
function CreateWeakMapPolyfill() {
|
|
980
|
+
var UUID_SIZE = 16;
|
|
981
|
+
var keys = HashMap.create();
|
|
982
|
+
var rootKey = CreateUniqueKey();
|
|
983
|
+
return (
|
|
984
|
+
/** @class */
|
|
985
|
+
function() {
|
|
986
|
+
function WeakMap2() {
|
|
987
|
+
this._key = CreateUniqueKey();
|
|
988
|
+
}
|
|
989
|
+
WeakMap2.prototype.has = function(target) {
|
|
990
|
+
var table = GetOrCreateWeakMapTable(
|
|
991
|
+
target,
|
|
992
|
+
/*create*/
|
|
993
|
+
false
|
|
994
|
+
);
|
|
995
|
+
return table !== void 0 ? HashMap.has(table, this._key) : false;
|
|
996
|
+
};
|
|
997
|
+
WeakMap2.prototype.get = function(target) {
|
|
998
|
+
var table = GetOrCreateWeakMapTable(
|
|
999
|
+
target,
|
|
1000
|
+
/*create*/
|
|
1001
|
+
false
|
|
1002
|
+
);
|
|
1003
|
+
return table !== void 0 ? HashMap.get(table, this._key) : void 0;
|
|
1004
|
+
};
|
|
1005
|
+
WeakMap2.prototype.set = function(target, value) {
|
|
1006
|
+
var table = GetOrCreateWeakMapTable(
|
|
1007
|
+
target,
|
|
1008
|
+
/*create*/
|
|
1009
|
+
true
|
|
1010
|
+
);
|
|
1011
|
+
table[this._key] = value;
|
|
1012
|
+
return this;
|
|
1013
|
+
};
|
|
1014
|
+
WeakMap2.prototype.delete = function(target) {
|
|
1015
|
+
var table = GetOrCreateWeakMapTable(
|
|
1016
|
+
target,
|
|
1017
|
+
/*create*/
|
|
1018
|
+
false
|
|
1019
|
+
);
|
|
1020
|
+
return table !== void 0 ? delete table[this._key] : false;
|
|
1021
|
+
};
|
|
1022
|
+
WeakMap2.prototype.clear = function() {
|
|
1023
|
+
this._key = CreateUniqueKey();
|
|
1024
|
+
};
|
|
1025
|
+
return WeakMap2;
|
|
1026
|
+
}()
|
|
1027
|
+
);
|
|
1028
|
+
function CreateUniqueKey() {
|
|
1029
|
+
var key;
|
|
1030
|
+
do
|
|
1031
|
+
key = "@@WeakMap@@" + CreateUUID();
|
|
1032
|
+
while (HashMap.has(keys, key));
|
|
1033
|
+
keys[key] = true;
|
|
1034
|
+
return key;
|
|
1035
|
+
}
|
|
1036
|
+
function GetOrCreateWeakMapTable(target, create) {
|
|
1037
|
+
if (!hasOwn.call(target, rootKey)) {
|
|
1038
|
+
if (!create)
|
|
1039
|
+
return void 0;
|
|
1040
|
+
Object.defineProperty(target, rootKey, { value: HashMap.create() });
|
|
1041
|
+
}
|
|
1042
|
+
return target[rootKey];
|
|
1043
|
+
}
|
|
1044
|
+
function FillRandomBytes(buffer, size) {
|
|
1045
|
+
for (var i = 0; i < size; ++i)
|
|
1046
|
+
buffer[i] = Math.random() * 255 | 0;
|
|
1047
|
+
return buffer;
|
|
1048
|
+
}
|
|
1049
|
+
function GenRandomBytes(size) {
|
|
1050
|
+
if (typeof Uint8Array === "function") {
|
|
1051
|
+
var array = new Uint8Array(size);
|
|
1052
|
+
if (typeof crypto !== "undefined") {
|
|
1053
|
+
crypto.getRandomValues(array);
|
|
1054
|
+
} else if (typeof msCrypto !== "undefined") {
|
|
1055
|
+
msCrypto.getRandomValues(array);
|
|
1056
|
+
} else {
|
|
1057
|
+
FillRandomBytes(array, size);
|
|
1058
|
+
}
|
|
1059
|
+
return array;
|
|
1060
|
+
}
|
|
1061
|
+
return FillRandomBytes(new Array(size), size);
|
|
1062
|
+
}
|
|
1063
|
+
function CreateUUID() {
|
|
1064
|
+
var data = GenRandomBytes(UUID_SIZE);
|
|
1065
|
+
data[6] = data[6] & 79 | 64;
|
|
1066
|
+
data[8] = data[8] & 191 | 128;
|
|
1067
|
+
var result = "";
|
|
1068
|
+
for (var offset = 0; offset < UUID_SIZE; ++offset) {
|
|
1069
|
+
var byte = data[offset];
|
|
1070
|
+
if (offset === 4 || offset === 6 || offset === 8)
|
|
1071
|
+
result += "-";
|
|
1072
|
+
if (byte < 16)
|
|
1073
|
+
result += "0";
|
|
1074
|
+
result += byte.toString(16).toLowerCase();
|
|
1075
|
+
}
|
|
1076
|
+
return result;
|
|
1077
|
+
}
|
|
283
1078
|
}
|
|
284
|
-
|
|
285
|
-
|
|
1079
|
+
function MakeDictionary(obj) {
|
|
1080
|
+
obj.__ = void 0;
|
|
1081
|
+
delete obj.__;
|
|
1082
|
+
return obj;
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
})(Reflect$1 || (Reflect$1 = {}));
|
|
286
1086
|
function bind(fn, thisArg) {
|
|
287
1087
|
return function wrap() {
|
|
288
1088
|
return fn.apply(thisArg, arguments);
|
|
@@ -665,7 +1465,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
665
1465
|
setImmediate: _setImmediate,
|
|
666
1466
|
asap
|
|
667
1467
|
};
|
|
668
|
-
function AxiosError(message, code, config, request, response) {
|
|
1468
|
+
function AxiosError$1(message, code, config, request, response) {
|
|
669
1469
|
Error.call(this);
|
|
670
1470
|
if (Error.captureStackTrace) {
|
|
671
1471
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -682,7 +1482,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
682
1482
|
this.status = response.status ? response.status : null;
|
|
683
1483
|
}
|
|
684
1484
|
}
|
|
685
|
-
utils$1.inherits(AxiosError, Error, {
|
|
1485
|
+
utils$1.inherits(AxiosError$1, Error, {
|
|
686
1486
|
toJSON: function toJSON() {
|
|
687
1487
|
return {
|
|
688
1488
|
// Standard
|
|
@@ -703,7 +1503,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
703
1503
|
};
|
|
704
1504
|
}
|
|
705
1505
|
});
|
|
706
|
-
const prototype$1 = AxiosError.prototype;
|
|
1506
|
+
const prototype$1 = AxiosError$1.prototype;
|
|
707
1507
|
const descriptors = {};
|
|
708
1508
|
[
|
|
709
1509
|
"ERR_BAD_OPTION_VALUE",
|
|
@@ -722,16 +1522,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
722
1522
|
].forEach((code) => {
|
|
723
1523
|
descriptors[code] = { value: code };
|
|
724
1524
|
});
|
|
725
|
-
Object.defineProperties(AxiosError, descriptors);
|
|
1525
|
+
Object.defineProperties(AxiosError$1, descriptors);
|
|
726
1526
|
Object.defineProperty(prototype$1, "isAxiosError", { value: true });
|
|
727
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
1527
|
+
AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
728
1528
|
const axiosError = Object.create(prototype$1);
|
|
729
1529
|
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
730
1530
|
return obj !== Error.prototype;
|
|
731
1531
|
}, (prop) => {
|
|
732
1532
|
return prop !== "isAxiosError";
|
|
733
1533
|
});
|
|
734
|
-
AxiosError.call(axiosError, error.message, code, config, request, response);
|
|
1534
|
+
AxiosError$1.call(axiosError, error.message, code, config, request, response);
|
|
735
1535
|
axiosError.cause = error;
|
|
736
1536
|
axiosError.name = error.name;
|
|
737
1537
|
customProps && Object.assign(axiosError, customProps);
|
|
@@ -757,7 +1557,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
757
1557
|
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
758
1558
|
return /^is[A-Z]/.test(prop);
|
|
759
1559
|
});
|
|
760
|
-
function toFormData(obj, formData, options) {
|
|
1560
|
+
function toFormData$1(obj, formData, options) {
|
|
761
1561
|
if (!utils$1.isObject(obj)) {
|
|
762
1562
|
throw new TypeError("target must be an object");
|
|
763
1563
|
}
|
|
@@ -784,7 +1584,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
784
1584
|
return value.toISOString();
|
|
785
1585
|
}
|
|
786
1586
|
if (!useBlob && utils$1.isBlob(value)) {
|
|
787
|
-
throw new AxiosError("Blob is not supported. Use a Buffer instead.");
|
|
1587
|
+
throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
|
|
788
1588
|
}
|
|
789
1589
|
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
790
1590
|
return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
|
|
@@ -863,7 +1663,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
863
1663
|
}
|
|
864
1664
|
function AxiosURLSearchParams(params, options) {
|
|
865
1665
|
this._pairs = [];
|
|
866
|
-
params && toFormData(params, this, options);
|
|
1666
|
+
params && toFormData$1(params, this, options);
|
|
867
1667
|
}
|
|
868
1668
|
const prototype = AxiosURLSearchParams.prototype;
|
|
869
1669
|
prototype.append = function append(name, value) {
|
|
@@ -1005,7 +1805,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1005
1805
|
...platform$1
|
|
1006
1806
|
};
|
|
1007
1807
|
function toURLEncodedForm(data, options) {
|
|
1008
|
-
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
1808
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
1009
1809
|
visitor: function(value, key, path, helpers) {
|
|
1010
1810
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1011
1811
|
this.append(key, value.toString("base64"));
|
|
@@ -1109,7 +1909,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1109
1909
|
}
|
|
1110
1910
|
if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
|
|
1111
1911
|
const _FormData = this.env && this.env.FormData;
|
|
1112
|
-
return toFormData(
|
|
1912
|
+
return toFormData$1(
|
|
1113
1913
|
isFileList2 ? { "files[]": data } : data,
|
|
1114
1914
|
_FormData && new _FormData(),
|
|
1115
1915
|
this.formSerializer
|
|
@@ -1137,7 +1937,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1137
1937
|
} catch (e) {
|
|
1138
1938
|
if (strictJSONParsing) {
|
|
1139
1939
|
if (e.name === "SyntaxError") {
|
|
1140
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1940
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1141
1941
|
}
|
|
1142
1942
|
throw e;
|
|
1143
1943
|
}
|
|
@@ -1265,7 +2065,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1265
2065
|
});
|
|
1266
2066
|
});
|
|
1267
2067
|
}
|
|
1268
|
-
class AxiosHeaders {
|
|
2068
|
+
let AxiosHeaders$1 = class AxiosHeaders {
|
|
1269
2069
|
constructor(headers) {
|
|
1270
2070
|
headers && this.set(headers);
|
|
1271
2071
|
}
|
|
@@ -1420,9 +2220,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1420
2220
|
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1421
2221
|
return this;
|
|
1422
2222
|
}
|
|
1423
|
-
}
|
|
1424
|
-
AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
|
1425
|
-
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
2223
|
+
};
|
|
2224
|
+
AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
|
2225
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
1426
2226
|
let mapped = key[0].toUpperCase() + key.slice(1);
|
|
1427
2227
|
return {
|
|
1428
2228
|
get: () => value,
|
|
@@ -1431,11 +2231,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1431
2231
|
}
|
|
1432
2232
|
};
|
|
1433
2233
|
});
|
|
1434
|
-
utils$1.freezeMethods(AxiosHeaders);
|
|
2234
|
+
utils$1.freezeMethods(AxiosHeaders$1);
|
|
1435
2235
|
function transformData(fns, response) {
|
|
1436
2236
|
const config = this || defaults;
|
|
1437
2237
|
const context = response || config;
|
|
1438
|
-
const headers = AxiosHeaders.from(context.headers);
|
|
2238
|
+
const headers = AxiosHeaders$1.from(context.headers);
|
|
1439
2239
|
let data = context.data;
|
|
1440
2240
|
utils$1.forEach(fns, function transform(fn) {
|
|
1441
2241
|
data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
|
|
@@ -1443,14 +2243,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1443
2243
|
headers.normalize();
|
|
1444
2244
|
return data;
|
|
1445
2245
|
}
|
|
1446
|
-
function isCancel(value) {
|
|
2246
|
+
function isCancel$1(value) {
|
|
1447
2247
|
return !!(value && value.__CANCEL__);
|
|
1448
2248
|
}
|
|
1449
|
-
function CanceledError(message, config, request) {
|
|
1450
|
-
AxiosError.call(this, message == null ? "canceled" : message, AxiosError.ERR_CANCELED, config, request);
|
|
2249
|
+
function CanceledError$1(message, config, request) {
|
|
2250
|
+
AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
1451
2251
|
this.name = "CanceledError";
|
|
1452
2252
|
}
|
|
1453
|
-
utils$1.inherits(CanceledError, AxiosError, {
|
|
2253
|
+
utils$1.inherits(CanceledError$1, AxiosError$1, {
|
|
1454
2254
|
__CANCEL__: true
|
|
1455
2255
|
});
|
|
1456
2256
|
function settle(resolve, reject, response) {
|
|
@@ -1458,9 +2258,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1458
2258
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
1459
2259
|
resolve(response);
|
|
1460
2260
|
} else {
|
|
1461
|
-
reject(new AxiosError(
|
|
2261
|
+
reject(new AxiosError$1(
|
|
1462
2262
|
"Request failed with status code " + response.status,
|
|
1463
|
-
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
2263
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
1464
2264
|
response.config,
|
|
1465
2265
|
response.request,
|
|
1466
2266
|
response
|
|
@@ -1619,8 +2419,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1619
2419
|
}
|
|
1620
2420
|
return requestedURL;
|
|
1621
2421
|
}
|
|
1622
|
-
const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
|
|
1623
|
-
function mergeConfig(config1, config2) {
|
|
2422
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2423
|
+
function mergeConfig$1(config1, config2) {
|
|
1624
2424
|
config2 = config2 || {};
|
|
1625
2425
|
const config = {};
|
|
1626
2426
|
function getMergedValue(target, source, prop, caseless) {
|
|
@@ -1698,9 +2498,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1698
2498
|
return config;
|
|
1699
2499
|
}
|
|
1700
2500
|
const resolveConfig = (config) => {
|
|
1701
|
-
const newConfig = mergeConfig({}, config);
|
|
2501
|
+
const newConfig = mergeConfig$1({}, config);
|
|
1702
2502
|
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
1703
|
-
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
2503
|
+
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
1704
2504
|
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
1705
2505
|
if (auth) {
|
|
1706
2506
|
headers.set(
|
|
@@ -1733,7 +2533,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1733
2533
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
1734
2534
|
const _config = resolveConfig(config);
|
|
1735
2535
|
let requestData = _config.data;
|
|
1736
|
-
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
|
2536
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
1737
2537
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
1738
2538
|
let onCanceled;
|
|
1739
2539
|
let uploadThrottled, downloadThrottled;
|
|
@@ -1751,7 +2551,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1751
2551
|
if (!request) {
|
|
1752
2552
|
return;
|
|
1753
2553
|
}
|
|
1754
|
-
const responseHeaders = AxiosHeaders.from(
|
|
2554
|
+
const responseHeaders = AxiosHeaders$1.from(
|
|
1755
2555
|
"getAllResponseHeaders" in request && request.getAllResponseHeaders()
|
|
1756
2556
|
);
|
|
1757
2557
|
const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
|
|
@@ -1789,11 +2589,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1789
2589
|
if (!request) {
|
|
1790
2590
|
return;
|
|
1791
2591
|
}
|
|
1792
|
-
reject(new AxiosError("Request aborted", AxiosError.ECONNABORTED, config, request));
|
|
2592
|
+
reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config, request));
|
|
1793
2593
|
request = null;
|
|
1794
2594
|
};
|
|
1795
2595
|
request.onerror = function handleError() {
|
|
1796
|
-
reject(new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request));
|
|
2596
|
+
reject(new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request));
|
|
1797
2597
|
request = null;
|
|
1798
2598
|
};
|
|
1799
2599
|
request.ontimeout = function handleTimeout() {
|
|
@@ -1802,9 +2602,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1802
2602
|
if (_config.timeoutErrorMessage) {
|
|
1803
2603
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
1804
2604
|
}
|
|
1805
|
-
reject(new AxiosError(
|
|
2605
|
+
reject(new AxiosError$1(
|
|
1806
2606
|
timeoutErrorMessage,
|
|
1807
|
-
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
2607
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
1808
2608
|
config,
|
|
1809
2609
|
request
|
|
1810
2610
|
));
|
|
@@ -1836,7 +2636,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1836
2636
|
if (!request) {
|
|
1837
2637
|
return;
|
|
1838
2638
|
}
|
|
1839
|
-
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
2639
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
1840
2640
|
request.abort();
|
|
1841
2641
|
request = null;
|
|
1842
2642
|
};
|
|
@@ -1847,7 +2647,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1847
2647
|
}
|
|
1848
2648
|
const protocol = parseProtocol(_config.url);
|
|
1849
2649
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
1850
|
-
reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config));
|
|
2650
|
+
reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config));
|
|
1851
2651
|
return;
|
|
1852
2652
|
}
|
|
1853
2653
|
request.send(requestData || null);
|
|
@@ -1863,12 +2663,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1863
2663
|
aborted = true;
|
|
1864
2664
|
unsubscribe();
|
|
1865
2665
|
const err = reason instanceof Error ? reason : this.reason;
|
|
1866
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
2666
|
+
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
|
1867
2667
|
}
|
|
1868
2668
|
};
|
|
1869
2669
|
let timer = timeout && setTimeout(() => {
|
|
1870
2670
|
timer = null;
|
|
1871
|
-
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
2671
|
+
onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
1872
2672
|
}, timeout);
|
|
1873
2673
|
const unsubscribe = () => {
|
|
1874
2674
|
if (signals) {
|
|
@@ -1991,7 +2791,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1991
2791
|
isFetchSupported && ((res) => {
|
|
1992
2792
|
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
|
|
1993
2793
|
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res2) => res2[type]() : (_, config) => {
|
|
1994
|
-
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
2794
|
+
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
1995
2795
|
});
|
|
1996
2796
|
});
|
|
1997
2797
|
})(new Response());
|
|
@@ -2103,7 +2903,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2103
2903
|
return await new Promise((resolve, reject) => {
|
|
2104
2904
|
settle(resolve, reject, {
|
|
2105
2905
|
data: responseData,
|
|
2106
|
-
headers: AxiosHeaders.from(response.headers),
|
|
2906
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
2107
2907
|
status: response.status,
|
|
2108
2908
|
statusText: response.statusText,
|
|
2109
2909
|
config,
|
|
@@ -2114,13 +2914,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2114
2914
|
unsubscribe && unsubscribe();
|
|
2115
2915
|
if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
|
|
2116
2916
|
throw Object.assign(
|
|
2117
|
-
new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request),
|
|
2917
|
+
new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request),
|
|
2118
2918
|
{
|
|
2119
2919
|
cause: err.cause || err
|
|
2120
2920
|
}
|
|
2121
2921
|
);
|
|
2122
2922
|
}
|
|
2123
|
-
throw AxiosError.from(err, err && err.code, config, request);
|
|
2923
|
+
throw AxiosError$1.from(err, err && err.code, config, request);
|
|
2124
2924
|
}
|
|
2125
2925
|
});
|
|
2126
2926
|
const knownAdapters = {
|
|
@@ -2153,7 +2953,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2153
2953
|
if (!isResolvedHandle(nameOrAdapter)) {
|
|
2154
2954
|
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
2155
2955
|
if (adapter === void 0) {
|
|
2156
|
-
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
2956
|
+
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
2157
2957
|
}
|
|
2158
2958
|
}
|
|
2159
2959
|
if (adapter) {
|
|
@@ -2166,7 +2966,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2166
2966
|
([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
|
|
2167
2967
|
);
|
|
2168
2968
|
let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
|
|
2169
|
-
throw new AxiosError(
|
|
2969
|
+
throw new AxiosError$1(
|
|
2170
2970
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
2171
2971
|
"ERR_NOT_SUPPORT"
|
|
2172
2972
|
);
|
|
@@ -2180,12 +2980,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2180
2980
|
config.cancelToken.throwIfRequested();
|
|
2181
2981
|
}
|
|
2182
2982
|
if (config.signal && config.signal.aborted) {
|
|
2183
|
-
throw new CanceledError(null, config);
|
|
2983
|
+
throw new CanceledError$1(null, config);
|
|
2184
2984
|
}
|
|
2185
2985
|
}
|
|
2186
2986
|
function dispatchRequest(config) {
|
|
2187
2987
|
throwIfCancellationRequested(config);
|
|
2188
|
-
config.headers = AxiosHeaders.from(config.headers);
|
|
2988
|
+
config.headers = AxiosHeaders$1.from(config.headers);
|
|
2189
2989
|
config.data = transformData.call(
|
|
2190
2990
|
config,
|
|
2191
2991
|
config.transformRequest
|
|
@@ -2201,10 +3001,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2201
3001
|
config.transformResponse,
|
|
2202
3002
|
response
|
|
2203
3003
|
);
|
|
2204
|
-
response.headers = AxiosHeaders.from(response.headers);
|
|
3004
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
|
2205
3005
|
return response;
|
|
2206
3006
|
}, function onAdapterRejection(reason) {
|
|
2207
|
-
if (!isCancel(reason)) {
|
|
3007
|
+
if (!isCancel$1(reason)) {
|
|
2208
3008
|
throwIfCancellationRequested(config);
|
|
2209
3009
|
if (reason && reason.response) {
|
|
2210
3010
|
reason.response.data = transformData.call(
|
|
@@ -2212,13 +3012,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2212
3012
|
config.transformResponse,
|
|
2213
3013
|
reason.response
|
|
2214
3014
|
);
|
|
2215
|
-
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
3015
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
2216
3016
|
}
|
|
2217
3017
|
}
|
|
2218
3018
|
return Promise.reject(reason);
|
|
2219
3019
|
});
|
|
2220
3020
|
}
|
|
2221
|
-
const VERSION = "1.7.9";
|
|
3021
|
+
const VERSION$1 = "1.7.9";
|
|
2222
3022
|
const validators$1 = {};
|
|
2223
3023
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
2224
3024
|
validators$1[type] = function validator2(thing) {
|
|
@@ -2228,13 +3028,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2228
3028
|
const deprecatedWarnings = {};
|
|
2229
3029
|
validators$1.transitional = function transitional(validator2, version, message) {
|
|
2230
3030
|
function formatMessage(opt, desc) {
|
|
2231
|
-
return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
3031
|
+
return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
2232
3032
|
}
|
|
2233
3033
|
return (value, opt, opts) => {
|
|
2234
3034
|
if (validator2 === false) {
|
|
2235
|
-
throw new AxiosError(
|
|
3035
|
+
throw new AxiosError$1(
|
|
2236
3036
|
formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
|
|
2237
|
-
AxiosError.ERR_DEPRECATED
|
|
3037
|
+
AxiosError$1.ERR_DEPRECATED
|
|
2238
3038
|
);
|
|
2239
3039
|
}
|
|
2240
3040
|
if (version && !deprecatedWarnings[opt]) {
|
|
@@ -2257,7 +3057,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2257
3057
|
};
|
|
2258
3058
|
function assertOptions(options, schema, allowUnknown) {
|
|
2259
3059
|
if (typeof options !== "object") {
|
|
2260
|
-
throw new AxiosError("options must be an object", AxiosError.ERR_BAD_OPTION_VALUE);
|
|
3060
|
+
throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
2261
3061
|
}
|
|
2262
3062
|
const keys = Object.keys(options);
|
|
2263
3063
|
let i = keys.length;
|
|
@@ -2268,12 +3068,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2268
3068
|
const value = options[opt];
|
|
2269
3069
|
const result = value === void 0 || validator2(value, opt, options);
|
|
2270
3070
|
if (result !== true) {
|
|
2271
|
-
throw new AxiosError("option " + opt + " must be " + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
|
3071
|
+
throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
2272
3072
|
}
|
|
2273
3073
|
continue;
|
|
2274
3074
|
}
|
|
2275
3075
|
if (allowUnknown !== true) {
|
|
2276
|
-
throw new AxiosError("Unknown option " + opt, AxiosError.ERR_BAD_OPTION);
|
|
3076
|
+
throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
|
|
2277
3077
|
}
|
|
2278
3078
|
}
|
|
2279
3079
|
}
|
|
@@ -2282,7 +3082,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2282
3082
|
validators: validators$1
|
|
2283
3083
|
};
|
|
2284
3084
|
const validators = validator.validators;
|
|
2285
|
-
class Axios {
|
|
3085
|
+
let Axios$1 = class Axios {
|
|
2286
3086
|
constructor(instanceConfig) {
|
|
2287
3087
|
this.defaults = instanceConfig;
|
|
2288
3088
|
this.interceptors = {
|
|
@@ -2325,7 +3125,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2325
3125
|
} else {
|
|
2326
3126
|
config = configOrUrl || {};
|
|
2327
3127
|
}
|
|
2328
|
-
config = mergeConfig(this.defaults, config);
|
|
3128
|
+
config = mergeConfig$1(this.defaults, config);
|
|
2329
3129
|
const { transitional, paramsSerializer, headers } = config;
|
|
2330
3130
|
if (transitional !== void 0) {
|
|
2331
3131
|
validator.assertOptions(transitional, {
|
|
@@ -2361,7 +3161,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2361
3161
|
delete headers[method];
|
|
2362
3162
|
}
|
|
2363
3163
|
);
|
|
2364
|
-
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
3164
|
+
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
2365
3165
|
const requestInterceptorChain = [];
|
|
2366
3166
|
let synchronousRequestInterceptors = true;
|
|
2367
3167
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
@@ -2415,14 +3215,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2415
3215
|
return promise;
|
|
2416
3216
|
}
|
|
2417
3217
|
getUri(config) {
|
|
2418
|
-
config = mergeConfig(this.defaults, config);
|
|
3218
|
+
config = mergeConfig$1(this.defaults, config);
|
|
2419
3219
|
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
2420
3220
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
2421
3221
|
}
|
|
2422
|
-
}
|
|
3222
|
+
};
|
|
2423
3223
|
utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
2424
|
-
Axios.prototype[method] = function(url, config) {
|
|
2425
|
-
return this.request(mergeConfig(config || {}, {
|
|
3224
|
+
Axios$1.prototype[method] = function(url, config) {
|
|
3225
|
+
return this.request(mergeConfig$1(config || {}, {
|
|
2426
3226
|
method,
|
|
2427
3227
|
url,
|
|
2428
3228
|
data: (config || {}).data
|
|
@@ -2432,7 +3232,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2432
3232
|
utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
2433
3233
|
function generateHTTPMethod(isForm) {
|
|
2434
3234
|
return function httpMethod(url, data, config) {
|
|
2435
|
-
return this.request(mergeConfig(config || {}, {
|
|
3235
|
+
return this.request(mergeConfig$1(config || {}, {
|
|
2436
3236
|
method,
|
|
2437
3237
|
headers: isForm ? {
|
|
2438
3238
|
"Content-Type": "multipart/form-data"
|
|
@@ -2442,10 +3242,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2442
3242
|
}));
|
|
2443
3243
|
};
|
|
2444
3244
|
}
|
|
2445
|
-
Axios.prototype[method] = generateHTTPMethod();
|
|
2446
|
-
Axios.prototype[method + "Form"] = generateHTTPMethod(true);
|
|
3245
|
+
Axios$1.prototype[method] = generateHTTPMethod();
|
|
3246
|
+
Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
|
|
2447
3247
|
});
|
|
2448
|
-
|
|
3248
|
+
let CancelToken$1 = class CancelToken2 {
|
|
2449
3249
|
constructor(executor) {
|
|
2450
3250
|
if (typeof executor !== "function") {
|
|
2451
3251
|
throw new TypeError("executor must be a function.");
|
|
@@ -2478,7 +3278,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2478
3278
|
if (token.reason) {
|
|
2479
3279
|
return;
|
|
2480
3280
|
}
|
|
2481
|
-
token.reason = new CanceledError(message, config, request);
|
|
3281
|
+
token.reason = new CanceledError$1(message, config, request);
|
|
2482
3282
|
resolvePromise(token.reason);
|
|
2483
3283
|
});
|
|
2484
3284
|
}
|
|
@@ -2531,7 +3331,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2531
3331
|
*/
|
|
2532
3332
|
static source() {
|
|
2533
3333
|
let cancel;
|
|
2534
|
-
const token = new
|
|
3334
|
+
const token = new CancelToken2(function executor(c) {
|
|
2535
3335
|
cancel = c;
|
|
2536
3336
|
});
|
|
2537
3337
|
return {
|
|
@@ -2539,16 +3339,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2539
3339
|
cancel
|
|
2540
3340
|
};
|
|
2541
3341
|
}
|
|
2542
|
-
}
|
|
2543
|
-
function spread(callback) {
|
|
3342
|
+
};
|
|
3343
|
+
function spread$1(callback) {
|
|
2544
3344
|
return function wrap(arr) {
|
|
2545
3345
|
return callback.apply(null, arr);
|
|
2546
3346
|
};
|
|
2547
3347
|
}
|
|
2548
|
-
function isAxiosError(payload) {
|
|
3348
|
+
function isAxiosError$1(payload) {
|
|
2549
3349
|
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
2550
3350
|
}
|
|
2551
|
-
const HttpStatusCode = {
|
|
3351
|
+
const HttpStatusCode$1 = {
|
|
2552
3352
|
Continue: 100,
|
|
2553
3353
|
SwitchingProtocols: 101,
|
|
2554
3354
|
Processing: 102,
|
|
@@ -2613,39 +3413,57 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2613
3413
|
NotExtended: 510,
|
|
2614
3414
|
NetworkAuthenticationRequired: 511
|
|
2615
3415
|
};
|
|
2616
|
-
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
2617
|
-
HttpStatusCode[value] = key;
|
|
3416
|
+
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
|
3417
|
+
HttpStatusCode$1[value] = key;
|
|
2618
3418
|
});
|
|
2619
3419
|
function createInstance(defaultConfig) {
|
|
2620
|
-
const context = new Axios(defaultConfig);
|
|
2621
|
-
const instance = bind(Axios.prototype.request, context);
|
|
2622
|
-
utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
|
|
3420
|
+
const context = new Axios$1(defaultConfig);
|
|
3421
|
+
const instance = bind(Axios$1.prototype.request, context);
|
|
3422
|
+
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
2623
3423
|
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
2624
3424
|
instance.create = function create(instanceConfig) {
|
|
2625
|
-
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
|
3425
|
+
return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
|
2626
3426
|
};
|
|
2627
3427
|
return instance;
|
|
2628
3428
|
}
|
|
2629
3429
|
const axios = createInstance(defaults);
|
|
2630
|
-
axios.Axios = Axios;
|
|
2631
|
-
axios.CanceledError = CanceledError;
|
|
2632
|
-
axios.CancelToken = CancelToken;
|
|
2633
|
-
axios.isCancel = isCancel;
|
|
2634
|
-
axios.VERSION = VERSION;
|
|
2635
|
-
axios.toFormData = toFormData;
|
|
2636
|
-
axios.AxiosError = AxiosError;
|
|
3430
|
+
axios.Axios = Axios$1;
|
|
3431
|
+
axios.CanceledError = CanceledError$1;
|
|
3432
|
+
axios.CancelToken = CancelToken$1;
|
|
3433
|
+
axios.isCancel = isCancel$1;
|
|
3434
|
+
axios.VERSION = VERSION$1;
|
|
3435
|
+
axios.toFormData = toFormData$1;
|
|
3436
|
+
axios.AxiosError = AxiosError$1;
|
|
2637
3437
|
axios.Cancel = axios.CanceledError;
|
|
2638
|
-
axios.all = function
|
|
3438
|
+
axios.all = function all2(promises) {
|
|
2639
3439
|
return Promise.all(promises);
|
|
2640
3440
|
};
|
|
2641
|
-
axios.spread = spread;
|
|
2642
|
-
axios.isAxiosError = isAxiosError;
|
|
2643
|
-
axios.mergeConfig = mergeConfig;
|
|
2644
|
-
axios.AxiosHeaders = AxiosHeaders;
|
|
3441
|
+
axios.spread = spread$1;
|
|
3442
|
+
axios.isAxiosError = isAxiosError$1;
|
|
3443
|
+
axios.mergeConfig = mergeConfig$1;
|
|
3444
|
+
axios.AxiosHeaders = AxiosHeaders$1;
|
|
2645
3445
|
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
2646
3446
|
axios.getAdapter = adapters.getAdapter;
|
|
2647
|
-
axios.HttpStatusCode = HttpStatusCode;
|
|
3447
|
+
axios.HttpStatusCode = HttpStatusCode$1;
|
|
2648
3448
|
axios.default = axios;
|
|
3449
|
+
const {
|
|
3450
|
+
Axios,
|
|
3451
|
+
AxiosError,
|
|
3452
|
+
CanceledError,
|
|
3453
|
+
isCancel,
|
|
3454
|
+
CancelToken,
|
|
3455
|
+
VERSION,
|
|
3456
|
+
all,
|
|
3457
|
+
Cancel,
|
|
3458
|
+
isAxiosError,
|
|
3459
|
+
spread,
|
|
3460
|
+
toFormData,
|
|
3461
|
+
AxiosHeaders,
|
|
3462
|
+
HttpStatusCode,
|
|
3463
|
+
formToJSON,
|
|
3464
|
+
getAdapter,
|
|
3465
|
+
mergeConfig
|
|
3466
|
+
} = axios;
|
|
2649
3467
|
class MemoryCache {
|
|
2650
3468
|
constructor(ttl) {
|
|
2651
3469
|
__publicField(this, "cache", {});
|
|
@@ -2843,6 +3661,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2843
3661
|
});
|
|
2844
3662
|
}
|
|
2845
3663
|
}
|
|
3664
|
+
var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
|
|
3665
|
+
RequestMethod2["GET"] = "GET";
|
|
3666
|
+
RequestMethod2["HEAD"] = "HEAD";
|
|
3667
|
+
RequestMethod2["POST"] = "POST";
|
|
3668
|
+
RequestMethod2["PUT"] = "PUT";
|
|
3669
|
+
RequestMethod2["DELETE"] = "DELETE";
|
|
3670
|
+
RequestMethod2["PATCH"] = "PATCH";
|
|
3671
|
+
RequestMethod2["OPTIONS"] = "OPTIONS";
|
|
3672
|
+
return RequestMethod2;
|
|
3673
|
+
})(RequestMethod || {});
|
|
3674
|
+
var VersioningType = /* @__PURE__ */ ((VersioningType2) => {
|
|
3675
|
+
VersioningType2[VersioningType2["Uri"] = 0] = "Uri";
|
|
3676
|
+
VersioningType2[VersioningType2["Header"] = 1] = "Header";
|
|
3677
|
+
VersioningType2[VersioningType2["Query"] = 2] = "Query";
|
|
3678
|
+
VersioningType2[VersioningType2["Custom"] = 3] = "Custom";
|
|
3679
|
+
return VersioningType2;
|
|
3680
|
+
})(VersioningType || {});
|
|
3681
|
+
var CacheType = /* @__PURE__ */ ((CacheType2) => {
|
|
3682
|
+
CacheType2[CacheType2["Memory"] = 0] = "Memory";
|
|
3683
|
+
CacheType2[CacheType2["IndexDB"] = 1] = "IndexDB";
|
|
3684
|
+
CacheType2[CacheType2["LocalStorage"] = 2] = "LocalStorage";
|
|
3685
|
+
return CacheType2;
|
|
3686
|
+
})(CacheType || {});
|
|
3687
|
+
class Strategy {
|
|
3688
|
+
}
|
|
2846
3689
|
function createCache(type, ttl) {
|
|
2847
3690
|
if (type === CacheType.Memory) {
|
|
2848
3691
|
return new MemoryCache(ttl);
|
|
@@ -2857,99 +3700,378 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2857
3700
|
}
|
|
2858
3701
|
return void 0;
|
|
2859
3702
|
}
|
|
2860
|
-
const
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
3703
|
+
const apiKey = (apiInstance) => {
|
|
3704
|
+
const { version, method, url, params, headers } = apiInstance;
|
|
3705
|
+
return `[${method}]${version ? `-v${version}` : ""}-${url}${params ? `-${recordToString(params)}` : ""}${headers ? `-${recordToString(headers)}` : ""}`;
|
|
3706
|
+
};
|
|
3707
|
+
function recordToString(record) {
|
|
3708
|
+
return Object.keys(record).map((key) => {
|
|
3709
|
+
return `${key}=${record[key]}`;
|
|
3710
|
+
}).sort((a, b) => a.localeCompare(b)).join("&");
|
|
3711
|
+
}
|
|
3712
|
+
const versionHandlers = {
|
|
3713
|
+
[VersioningType.Uri]: (version, versioning) => {
|
|
3714
|
+
const prefix = versioning.prefix || "v";
|
|
3715
|
+
return {
|
|
3716
|
+
url: `${prefix}${version}`
|
|
3717
|
+
};
|
|
3718
|
+
},
|
|
3719
|
+
[VersioningType.Header]: (version, versioning) => {
|
|
3720
|
+
const headers = {
|
|
3721
|
+
[versioning.header || "version"]: version
|
|
3722
|
+
};
|
|
3723
|
+
return {
|
|
3724
|
+
headers
|
|
3725
|
+
};
|
|
3726
|
+
},
|
|
3727
|
+
[VersioningType.Query]: (version, versioning) => {
|
|
3728
|
+
const key = versioning.key || "version";
|
|
3729
|
+
return {
|
|
3730
|
+
params: {
|
|
3731
|
+
[key]: version
|
|
3732
|
+
}
|
|
3733
|
+
};
|
|
3734
|
+
},
|
|
3735
|
+
[VersioningType.Custom]: (version, versioning) => {
|
|
3736
|
+
return versioning.extractor({
|
|
3737
|
+
version
|
|
3738
|
+
});
|
|
2867
3739
|
}
|
|
2868
3740
|
};
|
|
3741
|
+
function applyVersioning(version, versioning) {
|
|
3742
|
+
const handler = versionHandlers[versioning.type];
|
|
3743
|
+
return handler(
|
|
3744
|
+
version,
|
|
3745
|
+
versioning
|
|
3746
|
+
);
|
|
3747
|
+
}
|
|
3748
|
+
const METHOD_KEY = Symbol("SNAIL_METHOD_KEY");
|
|
3749
|
+
const API_CONFIG_KEY = Symbol("SNAIL_API_CONFIG_KEY");
|
|
3750
|
+
const Api = (url = "", config) => {
|
|
3751
|
+
return (target) => {
|
|
3752
|
+
Reflect.defineMetadata(API_CONFIG_KEY, { url, ...config }, target);
|
|
3753
|
+
};
|
|
3754
|
+
};
|
|
3755
|
+
const createMethodDecorator = (method) => {
|
|
3756
|
+
return (path = "") => {
|
|
3757
|
+
return (target, propertyKey) => {
|
|
3758
|
+
if (target) {
|
|
3759
|
+
Reflect.defineMetadata(METHOD_KEY, { method, path }, target, propertyKey);
|
|
3760
|
+
return;
|
|
3761
|
+
}
|
|
3762
|
+
Reflect.metadata(METHOD_KEY, { method, path });
|
|
3763
|
+
};
|
|
3764
|
+
};
|
|
3765
|
+
};
|
|
3766
|
+
const Get = createMethodDecorator(RequestMethod.GET);
|
|
3767
|
+
const Post = createMethodDecorator(RequestMethod.POST);
|
|
3768
|
+
const Put = createMethodDecorator(RequestMethod.PUT);
|
|
3769
|
+
const Delete = createMethodDecorator(RequestMethod.DELETE);
|
|
3770
|
+
const Patch = createMethodDecorator(RequestMethod.PATCH);
|
|
3771
|
+
const Options = createMethodDecorator(RequestMethod.OPTIONS);
|
|
3772
|
+
const Head = createMethodDecorator(RequestMethod.HEAD);
|
|
3773
|
+
const SERVER_CONFIG_KEY = Symbol("SANIL_SERVER_CONFIG_KEY");
|
|
3774
|
+
const Server = (config) => {
|
|
3775
|
+
return (target) => {
|
|
3776
|
+
Reflect.defineMetadata(SERVER_CONFIG_KEY, config, target);
|
|
3777
|
+
};
|
|
3778
|
+
};
|
|
3779
|
+
const STRATEGY_KEY = Symbol("SNAIL_STRATEGY_KEY");
|
|
3780
|
+
const UseStrategy = (...strategies) => {
|
|
3781
|
+
return (target, propertyKey) => {
|
|
3782
|
+
const key = propertyKey ? `${STRATEGY_KEY.toString()}_${propertyKey}` : STRATEGY_KEY;
|
|
3783
|
+
Reflect.defineMetadata(key, strategies, target);
|
|
3784
|
+
};
|
|
3785
|
+
};
|
|
3786
|
+
const REQUEST_ARGS_KEY = Symbol("SNAIL_REQUEST_ARGS_KEY");
|
|
3787
|
+
const Params = (key) => createArgsDecorator("params", key);
|
|
3788
|
+
const Data = () => createArgsDecorator("data");
|
|
3789
|
+
const createArgsDecorator = (type, key) => {
|
|
3790
|
+
return (target, propertyKey, parameterIndex) => {
|
|
3791
|
+
const args = Reflect.getMetadata(REQUEST_ARGS_KEY, target, propertyKey) || [];
|
|
3792
|
+
args.push({ index: parameterIndex, type, key });
|
|
3793
|
+
Reflect.defineMetadata(REQUEST_ARGS_KEY, args, target, propertyKey);
|
|
3794
|
+
};
|
|
3795
|
+
};
|
|
3796
|
+
const VERSIONING_KEY = Symbol("SNAIL_VERSIONING_KEY");
|
|
3797
|
+
const VERSION_KEY = Symbol("SNAIL_VERSION_KEY");
|
|
3798
|
+
const Versioning = (options) => {
|
|
3799
|
+
return (target) => {
|
|
3800
|
+
Reflect.defineMetadata(VERSIONING_KEY, options, target);
|
|
3801
|
+
};
|
|
3802
|
+
};
|
|
3803
|
+
const Version = (version) => {
|
|
3804
|
+
return (target, propertyKey) => {
|
|
3805
|
+
Reflect.defineMetadata(VERSION_KEY, version, target, propertyKey);
|
|
3806
|
+
};
|
|
3807
|
+
};
|
|
3808
|
+
const CACHE_OPTIONS_KEY = Symbol("SNALI_CACHE_OPTIONS_KEY");
|
|
3809
|
+
const Cache = (hitSource) => {
|
|
3810
|
+
return (target, propertyKey) => {
|
|
3811
|
+
const key = propertyKey ? `${CACHE_OPTIONS_KEY.toString()}_${propertyKey}` : CACHE_OPTIONS_KEY;
|
|
3812
|
+
Reflect.defineMetadata(key, hitSource, target);
|
|
3813
|
+
};
|
|
3814
|
+
};
|
|
2869
3815
|
class Snail {
|
|
2870
|
-
constructor(
|
|
3816
|
+
constructor() {
|
|
2871
3817
|
__publicField(this, "axiosInstance");
|
|
2872
|
-
|
|
2873
|
-
__publicField(this, "
|
|
2874
|
-
__publicField(this, "options");
|
|
3818
|
+
// private config: SnailConfig;
|
|
3819
|
+
__publicField(this, "strategies", []);
|
|
2875
3820
|
__publicField(this, "cacheStorage");
|
|
2876
|
-
__publicField(this, "
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
3821
|
+
__publicField(this, "version");
|
|
3822
|
+
__publicField(this, "sourceMap", /* @__PURE__ */ new Map());
|
|
3823
|
+
}
|
|
3824
|
+
registerStrategy(strategy) {
|
|
3825
|
+
this.strategies.push(strategy);
|
|
3826
|
+
}
|
|
3827
|
+
createApi(constructor) {
|
|
3828
|
+
const instance = new constructor();
|
|
3829
|
+
const serverConfig = this.getServerConfig();
|
|
3830
|
+
const { baseURL, timeout, CacheManage, enableLog } = serverConfig;
|
|
3831
|
+
enableLog && console.log("serverConfig:", serverConfig);
|
|
3832
|
+
this.initAxios({ baseURL, timeout });
|
|
3833
|
+
enableLog && console.log("CacheManage:", CacheManage);
|
|
3834
|
+
this.initCacheManage(CacheManage);
|
|
3835
|
+
const apiConfig = this.getApiConfig(constructor);
|
|
3836
|
+
enableLog && console.log("ApiConfig:", apiConfig);
|
|
3837
|
+
this.version = apiConfig.version;
|
|
3838
|
+
return new Proxy(instance, {
|
|
3839
|
+
get: (target, propertyKey) => {
|
|
3840
|
+
enableLog && console.log("proxy:", target, "|", propertyKey);
|
|
3841
|
+
if (typeof propertyKey !== "string") return;
|
|
3842
|
+
const methodConfig = Reflect.getMetadata(
|
|
3843
|
+
METHOD_KEY,
|
|
3844
|
+
target,
|
|
3845
|
+
propertyKey
|
|
3846
|
+
);
|
|
3847
|
+
if (!methodConfig) return target[propertyKey];
|
|
3848
|
+
return async (...args) => {
|
|
3849
|
+
const url = methodConfig.path == "" ? apiConfig.url : apiConfig.url + `/${methodConfig.path}`;
|
|
3850
|
+
enableLog && console.log("url:", url);
|
|
3851
|
+
let request = {
|
|
3852
|
+
// baseURL: serverConfig.baseURL,
|
|
3853
|
+
url,
|
|
3854
|
+
method: methodConfig.method,
|
|
3855
|
+
timeout: apiConfig.timeout ? apiConfig.timeout : serverConfig.timeout
|
|
3856
|
+
};
|
|
3857
|
+
request = {
|
|
3858
|
+
...request,
|
|
3859
|
+
...this.applyVersion(request, target, propertyKey)
|
|
3860
|
+
};
|
|
3861
|
+
enableLog && console.log("版本管理参数:", request);
|
|
3862
|
+
const strategies = this.getStrategies(target, propertyKey);
|
|
3863
|
+
const params = this.buildRequestArgs(target, propertyKey, args);
|
|
3864
|
+
request = { ...request, ...params };
|
|
3865
|
+
enableLog && console.log("构建请求参数:", request);
|
|
3866
|
+
const requestStrategies = strategies.filter(
|
|
3867
|
+
(strategy) => strategy.applyRequest
|
|
3868
|
+
);
|
|
3869
|
+
request = await this.applyStrategies(
|
|
3870
|
+
request,
|
|
3871
|
+
requestStrategies,
|
|
3872
|
+
"request"
|
|
3873
|
+
);
|
|
3874
|
+
const hitSource = this.getHitSource(target, propertyKey);
|
|
3875
|
+
enableLog && console.log("hitSource:", hitSource);
|
|
3876
|
+
if (typeof hitSource == "string") {
|
|
3877
|
+
this.setHitSource(request, hitSource);
|
|
3878
|
+
}
|
|
3879
|
+
if (hitSource !== null) {
|
|
3880
|
+
const cachedResponse = await this.getCache(request, strategies);
|
|
3881
|
+
if (cachedResponse) {
|
|
3882
|
+
enableLog && console.warn("数据从缓存获取");
|
|
3883
|
+
return this.handleResponse(cachedResponse, true);
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
try {
|
|
3887
|
+
enableLog && console.log("send request:", request);
|
|
3888
|
+
const response = await this.axiosInstance(request);
|
|
3889
|
+
hitSource !== null && this.setCache(request, response);
|
|
3890
|
+
this.expireCache(propertyKey);
|
|
3891
|
+
return this.handleResponse(response, false);
|
|
3892
|
+
} catch (error) {
|
|
3893
|
+
return this.handleError(error);
|
|
3894
|
+
}
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
2888
3897
|
});
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
3898
|
+
}
|
|
3899
|
+
buildRequestArgs(target, propertyKey, args) {
|
|
3900
|
+
const requestArgs = { params: {}, data: {} };
|
|
3901
|
+
const paramConfigs = Reflect.getMetadata(REQUEST_ARGS_KEY, target, propertyKey) || [];
|
|
3902
|
+
paramConfigs.forEach(({ index, type, key }) => {
|
|
3903
|
+
const value = args[index];
|
|
3904
|
+
if (type === "params" && !key && typeof value === "object") {
|
|
3905
|
+
requestArgs.params = { ...requestArgs.params, ...value };
|
|
3906
|
+
}
|
|
3907
|
+
if (type === "params" && key) {
|
|
3908
|
+
requestArgs.params[key] = value;
|
|
3909
|
+
}
|
|
3910
|
+
if (type === "data" && !key && typeof value === "object") {
|
|
3911
|
+
requestArgs.data = { ...requestArgs.data, ...value };
|
|
3912
|
+
}
|
|
3913
|
+
if (type === "data" && key) {
|
|
3914
|
+
requestArgs.data[key] = value;
|
|
3915
|
+
}
|
|
3916
|
+
});
|
|
3917
|
+
return requestArgs;
|
|
3918
|
+
}
|
|
3919
|
+
getStrategies(target, propertyKey) {
|
|
3920
|
+
const serverStrategies = Reflect.getMetadata(STRATEGY_KEY, this.constructor) || [];
|
|
3921
|
+
const classStrategies = Reflect.getMetadata(STRATEGY_KEY, target.constructor) || [];
|
|
3922
|
+
const methodStrategies = Reflect.getMetadata(
|
|
3923
|
+
`${STRATEGY_KEY.toString()}_${propertyKey}`,
|
|
3924
|
+
target
|
|
3925
|
+
) || [];
|
|
3926
|
+
const allStrategies = [
|
|
3927
|
+
...this.strategies,
|
|
3928
|
+
...serverStrategies,
|
|
3929
|
+
...classStrategies,
|
|
3930
|
+
...methodStrategies
|
|
3931
|
+
];
|
|
3932
|
+
return allStrategies;
|
|
3933
|
+
}
|
|
3934
|
+
async applyStrategies(data, strategies, type = "request") {
|
|
3935
|
+
return await strategies.reduce(async (result, strategy) => {
|
|
3936
|
+
if (type == "response")
|
|
3937
|
+
return await strategy.applyResponse(await result);
|
|
3938
|
+
return await strategy.applyRequest(await result);
|
|
3939
|
+
}, Promise.resolve(data));
|
|
3940
|
+
}
|
|
3941
|
+
applyVersion(request, target, propertyKey) {
|
|
3942
|
+
const versioning = Reflect.getMetadata(
|
|
3943
|
+
VERSIONING_KEY,
|
|
3944
|
+
this.constructor
|
|
3945
|
+
);
|
|
3946
|
+
if (!versioning) return request;
|
|
3947
|
+
const version = Reflect.getMetadata(VERSION_KEY, target, propertyKey);
|
|
3948
|
+
const currentVersion = version || this.version || versioning.defaultVersion;
|
|
3949
|
+
const { url, headers, params } = applyVersioning(
|
|
3950
|
+
currentVersion,
|
|
3951
|
+
versioning
|
|
3952
|
+
);
|
|
3953
|
+
const versionUrl = url ? `${url}/${request.url}` : request.url;
|
|
3954
|
+
return { ...request, url: versionUrl, headers, params };
|
|
3955
|
+
}
|
|
3956
|
+
async getCache(request, strategies) {
|
|
3957
|
+
var _a;
|
|
3958
|
+
if (!this.cacheStorage) return void 0;
|
|
3959
|
+
const cacheKey = apiKey(request);
|
|
3960
|
+
const cached = await ((_a = this.cacheStorage) == null ? void 0 : _a.get(cacheKey));
|
|
3961
|
+
if (cached && cached.error === null) {
|
|
3962
|
+
let cacheResponse = {
|
|
3963
|
+
data: cached.data,
|
|
3964
|
+
status: 304,
|
|
3965
|
+
headers: {},
|
|
3966
|
+
statusText: "get response data from cache",
|
|
3967
|
+
config: { headers: new AxiosHeaders() }
|
|
3968
|
+
};
|
|
3969
|
+
const responseStrategies = strategies.filter(
|
|
3970
|
+
(strategy) => strategy.applyResponse
|
|
2898
3971
|
);
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
var _a, _b;
|
|
2904
|
-
const result = (_b = (_a = SnailOptions.responseInterceptors) == null ? void 0 : _a.onFulfilled) == null ? void 0 : _b.call(_a, response);
|
|
2905
|
-
return result ? result : response;
|
|
2906
|
-
},
|
|
2907
|
-
(error) => {
|
|
2908
|
-
var _a, _b;
|
|
2909
|
-
const result = (_b = (_a = SnailOptions.responseInterceptors) == null ? void 0 : _a.onRejected) == null ? void 0 : _b.call(_a, error);
|
|
2910
|
-
return Promise.reject(result || error);
|
|
2911
|
-
}
|
|
3972
|
+
const strategyResponse = await this.applyStrategies(
|
|
3973
|
+
cacheResponse,
|
|
3974
|
+
responseStrategies,
|
|
3975
|
+
"response"
|
|
2912
3976
|
);
|
|
3977
|
+
return strategyResponse;
|
|
2913
3978
|
}
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
3979
|
+
}
|
|
3980
|
+
initCacheManage(options) {
|
|
3981
|
+
if (!this.cacheStorage && options !== void 0) {
|
|
3982
|
+
this.cacheStorage = createCache(options.type, options.ttl || 300);
|
|
2917
3983
|
}
|
|
2918
3984
|
}
|
|
2919
|
-
|
|
2920
|
-
|
|
3985
|
+
getHitSource(target, propertyKey) {
|
|
3986
|
+
const methodHitSource = Reflect.getMetadata(
|
|
3987
|
+
`${CACHE_OPTIONS_KEY.toString()}_${propertyKey}`,
|
|
3988
|
+
target
|
|
3989
|
+
);
|
|
3990
|
+
if (methodHitSource !== void 0) return methodHitSource;
|
|
3991
|
+
const apiHitSource = Reflect.getMetadata(
|
|
3992
|
+
CACHE_OPTIONS_KEY,
|
|
3993
|
+
target.constructor
|
|
3994
|
+
);
|
|
3995
|
+
return apiHitSource;
|
|
3996
|
+
}
|
|
3997
|
+
setHitSource(request, hitSource) {
|
|
3998
|
+
const cacheKeys = this.sourceMap.get(hitSource);
|
|
3999
|
+
const currentCacheKey = apiKey(request);
|
|
4000
|
+
if (cacheKeys) {
|
|
4001
|
+
cacheKeys.push(currentCacheKey);
|
|
4002
|
+
this.sourceMap.set(hitSource, cacheKeys);
|
|
4003
|
+
} else {
|
|
4004
|
+
this.sourceMap.set(hitSource, [currentCacheKey]);
|
|
4005
|
+
}
|
|
2921
4006
|
}
|
|
2922
|
-
|
|
2923
|
-
|
|
4007
|
+
async setCache(request, response) {
|
|
4008
|
+
var _a;
|
|
4009
|
+
const cacheKey = apiKey(request);
|
|
4010
|
+
await ((_a = this.cacheStorage) == null ? void 0 : _a.set(cacheKey, response.data));
|
|
4011
|
+
}
|
|
4012
|
+
async expireCache(hitSource) {
|
|
4013
|
+
const keys = this.sourceMap.get(hitSource);
|
|
4014
|
+
if (keys) {
|
|
4015
|
+
Promise.all(
|
|
4016
|
+
keys.map(async (key) => {
|
|
4017
|
+
var _a;
|
|
4018
|
+
await ((_a = this.cacheStorage) == null ? void 0 : _a.delete(key));
|
|
4019
|
+
})
|
|
4020
|
+
);
|
|
4021
|
+
}
|
|
2924
4022
|
}
|
|
2925
|
-
|
|
2926
|
-
return
|
|
4023
|
+
getServerConfig() {
|
|
4024
|
+
return Reflect.getMetadata(
|
|
4025
|
+
SERVER_CONFIG_KEY,
|
|
4026
|
+
this.constructor
|
|
4027
|
+
);
|
|
2927
4028
|
}
|
|
2928
|
-
|
|
2929
|
-
return
|
|
4029
|
+
getApiConfig(constructor) {
|
|
4030
|
+
return Reflect.getMetadata(API_CONFIG_KEY, constructor);
|
|
2930
4031
|
}
|
|
2931
|
-
|
|
2932
|
-
|
|
4032
|
+
initAxios(config) {
|
|
4033
|
+
if (!this.axiosInstance) {
|
|
4034
|
+
this.axiosInstance = axios.create({
|
|
4035
|
+
baseURL: config.baseURL,
|
|
4036
|
+
timeout: config.timeout
|
|
4037
|
+
});
|
|
4038
|
+
}
|
|
2933
4039
|
}
|
|
2934
|
-
|
|
2935
|
-
return
|
|
4040
|
+
handleResponse(response, hitCache) {
|
|
4041
|
+
return {
|
|
4042
|
+
data: response.data,
|
|
4043
|
+
error: null,
|
|
4044
|
+
hitCache
|
|
4045
|
+
};
|
|
2936
4046
|
}
|
|
2937
|
-
|
|
2938
|
-
return
|
|
4047
|
+
handleError(error) {
|
|
4048
|
+
return {
|
|
4049
|
+
data: null,
|
|
4050
|
+
error
|
|
4051
|
+
};
|
|
2939
4052
|
}
|
|
2940
4053
|
}
|
|
2941
|
-
const createSnail = (option) => {
|
|
2942
|
-
return new Snail(option);
|
|
2943
|
-
};
|
|
2944
4054
|
exports2.Api = Api;
|
|
4055
|
+
exports2.Cache = Cache;
|
|
2945
4056
|
exports2.CacheType = CacheType;
|
|
4057
|
+
exports2.Data = Data;
|
|
4058
|
+
exports2.Delete = Delete;
|
|
4059
|
+
exports2.Get = Get;
|
|
4060
|
+
exports2.Head = Head;
|
|
4061
|
+
exports2.Options = Options;
|
|
4062
|
+
exports2.Params = Params;
|
|
4063
|
+
exports2.Patch = Patch;
|
|
4064
|
+
exports2.Post = Post;
|
|
4065
|
+
exports2.Put = Put;
|
|
2946
4066
|
exports2.RequestMethod = RequestMethod;
|
|
4067
|
+
exports2.Server = Server;
|
|
2947
4068
|
exports2.Snail = Snail;
|
|
4069
|
+
exports2.Strategy = Strategy;
|
|
4070
|
+
exports2.UseStrategy = UseStrategy;
|
|
4071
|
+
exports2.Version = Version;
|
|
4072
|
+
exports2.Versioning = Versioning;
|
|
2948
4073
|
exports2.VersioningType = VersioningType;
|
|
2949
4074
|
exports2.apiKey = apiKey;
|
|
2950
|
-
exports2.createSnail = createSnail;
|
|
2951
|
-
exports2.deepCopy = deepCopy;
|
|
2952
|
-
exports2.getResponseDataFromCache = getResponseDataFromCache;
|
|
2953
4075
|
exports2.recordToString = recordToString;
|
|
2954
4076
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
2955
4077
|
});
|