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