@dereekb/util 13.0.0 → 13.0.2
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/fetch/index.cjs.default.js +1 -0
- package/fetch/index.cjs.js +2234 -665
- package/fetch/index.cjs.mjs +2 -0
- package/fetch/index.esm.js +2235 -666
- package/fetch/package.json +13 -18
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +12544 -7968
- package/index.cjs.mjs +2 -0
- package/index.esm.js +12544 -7968
- package/package.json +18 -35
- package/src/lib/object/object.filter.pojo.d.ts +3 -1
- package/test/index.cjs.default.js +1 -0
- package/test/index.cjs.js +1283 -513
- package/test/index.cjs.mjs +2 -0
- package/test/index.esm.js +1283 -513
- package/test/package.json +12 -16
package/fetch/index.esm.js
CHANGED
|
@@ -1,151 +1,580 @@
|
|
|
1
1
|
import { BaseError } from 'make-error';
|
|
2
|
-
import '
|
|
3
|
-
import 'core-js/modules/es.iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/es.set.difference.v2.js';
|
|
5
|
-
import 'core-js/modules/es.set.symmetric-difference.v2.js';
|
|
6
|
-
import 'core-js/modules/es.set.union.v2.js';
|
|
7
|
-
import { removeTrailingSlashes, asGetter, multiValueMapBuilder, filterMaybeArrayValues, isPromiseLike, isWebsiteUrlWithPrefix, fixMultiSlashesInSlashPath, cachedGetter, FIRST_PAGE, performTasksFromFactoryInParallelFunction, mapIdentityFunction, performAsyncTasks, mergeObjects, filterEmptyPojoValues, useIterableOrValue, isEmptyIterable, fixExtraQueryParameters, forEachInIterable, forEachKeyValue, isIterable } from '@dereekb/util';
|
|
2
|
+
import { removeTrailingSlashes, asGetter, multiValueMapBuilder, filterMaybeArrayValues, isWebsiteUrlWithPrefix, fixMultiSlashesInSlashPath, isPromiseLike, cachedGetter, FIRST_PAGE, mapIdentityFunction, performTasksFromFactoryInParallelFunction, performAsyncTasks, mergeObjects, filterEmptyPojoValues, useIterableOrValue, isEmptyIterable, fixExtraQueryParameters, forEachInIterable, forEachKeyValue, isIterable } from '@dereekb/util';
|
|
8
3
|
import { safeParse } from 'fast-content-type-parse';
|
|
9
|
-
import 'core-js/modules/es.iterator.map.js';
|
|
10
|
-
import 'core-js/modules/es.json.stringify.js';
|
|
11
4
|
|
|
5
|
+
function _assert_this_initialized$3(self) {
|
|
6
|
+
if (self === void 0) {
|
|
7
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
8
|
+
}
|
|
9
|
+
return self;
|
|
10
|
+
}
|
|
11
|
+
function _call_super$3(_this, derived, args) {
|
|
12
|
+
derived = _get_prototype_of$3(derived);
|
|
13
|
+
return _possible_constructor_return$3(_this, _is_native_reflect_construct$3() ? Reflect.construct(derived, args || [], _get_prototype_of$3(_this).constructor) : derived.apply(_this, args));
|
|
14
|
+
}
|
|
15
|
+
function _class_call_check$3(instance, Constructor) {
|
|
16
|
+
if (!(instance instanceof Constructor)) {
|
|
17
|
+
throw new TypeError("Cannot call a class as a function");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function _define_property$5(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
function _get_prototype_of$3(o) {
|
|
34
|
+
_get_prototype_of$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
35
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
36
|
+
};
|
|
37
|
+
return _get_prototype_of$3(o);
|
|
38
|
+
}
|
|
39
|
+
function _inherits$3(subClass, superClass) {
|
|
40
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
41
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
42
|
+
}
|
|
43
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
44
|
+
constructor: {
|
|
45
|
+
value: subClass,
|
|
46
|
+
writable: true,
|
|
47
|
+
configurable: true
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (superClass) _set_prototype_of$3(subClass, superClass);
|
|
51
|
+
}
|
|
52
|
+
function _possible_constructor_return$3(self, call) {
|
|
53
|
+
if (call && (_type_of$5(call) === "object" || typeof call === "function")) {
|
|
54
|
+
return call;
|
|
55
|
+
}
|
|
56
|
+
return _assert_this_initialized$3(self);
|
|
57
|
+
}
|
|
58
|
+
function _set_prototype_of$3(o, p) {
|
|
59
|
+
_set_prototype_of$3 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
60
|
+
o.__proto__ = p;
|
|
61
|
+
return o;
|
|
62
|
+
};
|
|
63
|
+
return _set_prototype_of$3(o, p);
|
|
64
|
+
}
|
|
65
|
+
function _type_of$5(obj) {
|
|
66
|
+
"@swc/helpers - typeof";
|
|
67
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
68
|
+
}
|
|
69
|
+
function _is_native_reflect_construct$3() {
|
|
70
|
+
try {
|
|
71
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
72
|
+
} catch (_) {}
|
|
73
|
+
return (_is_native_reflect_construct$3 = function() {
|
|
74
|
+
return !!result;
|
|
75
|
+
})();
|
|
76
|
+
}
|
|
12
77
|
/**
|
|
13
78
|
* Thrown by a FetchRequestFactory if one of the async request initialization steps fails.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
79
|
+
*/ var FetchRequestFactoryError = /*#__PURE__*/ function(BaseError) {
|
|
80
|
+
_inherits$3(FetchRequestFactoryError, BaseError);
|
|
81
|
+
function FetchRequestFactoryError(error) {
|
|
82
|
+
_class_call_check$3(this, FetchRequestFactoryError);
|
|
83
|
+
var _this;
|
|
84
|
+
var _error_message;
|
|
85
|
+
_this = _call_super$3(this, FetchRequestFactoryError, [
|
|
86
|
+
"Fetch request failed to build due to an unexpected error: ".concat((typeof error === "undefined" ? "undefined" : _type_of$5(error)) === 'object' ? (_error_message = error.message) !== null && _error_message !== void 0 ? _error_message : '' : error)
|
|
87
|
+
]), _define_property$5(_this, "error", void 0);
|
|
88
|
+
_this.error = error;
|
|
89
|
+
return _this;
|
|
90
|
+
}
|
|
91
|
+
return FetchRequestFactoryError;
|
|
92
|
+
}(BaseError);
|
|
22
93
|
/**
|
|
23
94
|
* Wraps the input fetch function to always pass the fetch response promise to requireOkResponse().
|
|
24
95
|
*
|
|
25
96
|
* @param inputFetch
|
|
26
97
|
* @returns
|
|
27
|
-
*/
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
class FetchResponseError extends BaseError {
|
|
32
|
-
constructor(response) {
|
|
33
|
-
super(`Fetch response was a non-ok status code (${response.status}): ${response.statusText}`);
|
|
34
|
-
this.response = void 0;
|
|
35
|
-
this.response = response;
|
|
36
|
-
}
|
|
98
|
+
*/ function fetchOk(inputFetch) {
|
|
99
|
+
return function(input, init) {
|
|
100
|
+
return requireOkResponse(inputFetch(input, init));
|
|
101
|
+
};
|
|
37
102
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
103
|
+
var FetchResponseError = /*#__PURE__*/ function(BaseError) {
|
|
104
|
+
_inherits$3(FetchResponseError, BaseError);
|
|
105
|
+
function FetchResponseError(response) {
|
|
106
|
+
_class_call_check$3(this, FetchResponseError);
|
|
107
|
+
var _this;
|
|
108
|
+
_this = _call_super$3(this, FetchResponseError, [
|
|
109
|
+
"Fetch response was a non-ok status code (".concat(response.status, "): ").concat(response.statusText)
|
|
110
|
+
]), _define_property$5(_this, "response", void 0);
|
|
111
|
+
_this.response = response;
|
|
112
|
+
return _this;
|
|
42
113
|
}
|
|
43
|
-
return
|
|
44
|
-
|
|
114
|
+
return FetchResponseError;
|
|
115
|
+
}(BaseError);
|
|
116
|
+
function requireOkResponse(responsePromise) {
|
|
117
|
+
return responsePromise.then(function(response) {
|
|
118
|
+
if (!response.ok) {
|
|
119
|
+
throw new FetchResponseError(response);
|
|
120
|
+
}
|
|
121
|
+
return response;
|
|
122
|
+
});
|
|
45
123
|
}
|
|
46
124
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
125
|
+
function _assert_this_initialized$2(self) {
|
|
126
|
+
if (self === void 0) {
|
|
127
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
128
|
+
}
|
|
129
|
+
return self;
|
|
130
|
+
}
|
|
131
|
+
function _call_super$2(_this, derived, args) {
|
|
132
|
+
derived = _get_prototype_of$2(derived);
|
|
133
|
+
return _possible_constructor_return$2(_this, _is_native_reflect_construct$2() ? Reflect.construct(derived, args || [], _get_prototype_of$2(_this).constructor) : derived.apply(_this, args));
|
|
134
|
+
}
|
|
135
|
+
function _class_call_check$2(instance, Constructor) {
|
|
136
|
+
if (!(instance instanceof Constructor)) {
|
|
137
|
+
throw new TypeError("Cannot call a class as a function");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function _define_property$4(obj, key, value) {
|
|
141
|
+
if (key in obj) {
|
|
142
|
+
Object.defineProperty(obj, key, {
|
|
143
|
+
value: value,
|
|
144
|
+
enumerable: true,
|
|
145
|
+
configurable: true,
|
|
146
|
+
writable: true
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
obj[key] = value;
|
|
150
|
+
}
|
|
151
|
+
return obj;
|
|
152
|
+
}
|
|
153
|
+
function _get_prototype_of$2(o) {
|
|
154
|
+
_get_prototype_of$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
155
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
156
|
+
};
|
|
157
|
+
return _get_prototype_of$2(o);
|
|
158
|
+
}
|
|
159
|
+
function _inherits$2(subClass, superClass) {
|
|
160
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
161
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
162
|
+
}
|
|
163
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
164
|
+
constructor: {
|
|
165
|
+
value: subClass,
|
|
166
|
+
writable: true,
|
|
167
|
+
configurable: true
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
if (superClass) _set_prototype_of$2(subClass, superClass);
|
|
55
171
|
}
|
|
172
|
+
function _object_spread$4(target) {
|
|
173
|
+
for(var i = 1; i < arguments.length; i++){
|
|
174
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
175
|
+
var ownKeys = Object.keys(source);
|
|
176
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
177
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
178
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
ownKeys.forEach(function(key) {
|
|
182
|
+
_define_property$4(target, key, source[key]);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return target;
|
|
186
|
+
}
|
|
187
|
+
function ownKeys$3(object, enumerableOnly) {
|
|
188
|
+
var keys = Object.keys(object);
|
|
189
|
+
if (Object.getOwnPropertySymbols) {
|
|
190
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
191
|
+
keys.push.apply(keys, symbols);
|
|
192
|
+
}
|
|
193
|
+
return keys;
|
|
194
|
+
}
|
|
195
|
+
function _object_spread_props$3(target, source) {
|
|
196
|
+
source = source != null ? source : {};
|
|
197
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
198
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
199
|
+
} else {
|
|
200
|
+
ownKeys$3(Object(source)).forEach(function(key) {
|
|
201
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return target;
|
|
205
|
+
}
|
|
206
|
+
function _possible_constructor_return$2(self, call) {
|
|
207
|
+
if (call && (_type_of$4(call) === "object" || typeof call === "function")) {
|
|
208
|
+
return call;
|
|
209
|
+
}
|
|
210
|
+
return _assert_this_initialized$2(self);
|
|
211
|
+
}
|
|
212
|
+
function _set_prototype_of$2(o, p) {
|
|
213
|
+
_set_prototype_of$2 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
214
|
+
o.__proto__ = p;
|
|
215
|
+
return o;
|
|
216
|
+
};
|
|
217
|
+
return _set_prototype_of$2(o, p);
|
|
218
|
+
}
|
|
219
|
+
function _type_of$4(obj) {
|
|
220
|
+
"@swc/helpers - typeof";
|
|
221
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
222
|
+
}
|
|
223
|
+
function _is_native_reflect_construct$2() {
|
|
224
|
+
try {
|
|
225
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
226
|
+
} catch (_) {}
|
|
227
|
+
return (_is_native_reflect_construct$2 = function() {
|
|
228
|
+
return !!result;
|
|
229
|
+
})();
|
|
230
|
+
}
|
|
231
|
+
var FetchTimeoutError = /*#__PURE__*/ function(BaseError) {
|
|
232
|
+
_inherits$2(FetchTimeoutError, BaseError);
|
|
233
|
+
function FetchTimeoutError(response, timeout) {
|
|
234
|
+
_class_call_check$2(this, FetchTimeoutError);
|
|
235
|
+
var _this;
|
|
236
|
+
_this = _call_super$2(this, FetchTimeoutError, [
|
|
237
|
+
"Fetch response was timed out (".concat(timeout, ")")
|
|
238
|
+
]), _define_property$4(_this, "response", void 0), _define_property$4(_this, "timeout", void 0);
|
|
239
|
+
_this.response = response;
|
|
240
|
+
_this.timeout = timeout;
|
|
241
|
+
return _this;
|
|
242
|
+
}
|
|
243
|
+
return FetchTimeoutError;
|
|
244
|
+
}(BaseError);
|
|
56
245
|
function fetchTimeout(inputFetch) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
246
|
+
return function(input, init) {
|
|
247
|
+
var _ref;
|
|
248
|
+
var controller;
|
|
249
|
+
var timeout = (_ref = init === null || init === void 0 ? void 0 : init.timeout) !== null && _ref !== void 0 ? _ref : input.timeout;
|
|
250
|
+
// if signal is not provided, and a timeout is specified, configure the timeout
|
|
251
|
+
if (!(init === null || init === void 0 ? void 0 : init.signal) && timeout) {
|
|
252
|
+
var abortController = new AbortController();
|
|
253
|
+
controller = abortController;
|
|
254
|
+
init = _object_spread_props$3(_object_spread$4({}, init), {
|
|
255
|
+
signal: abortController.signal // pass the abort signal
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
var responsePromise = inputFetch(input, init);
|
|
259
|
+
if (timeout) {
|
|
260
|
+
var timeoutId = setTimeout(function() {
|
|
261
|
+
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
262
|
+
}, timeout);
|
|
263
|
+
responsePromise = responsePromise.finally(function() {
|
|
264
|
+
clearTimeout(timeoutId);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return responsePromise;
|
|
268
|
+
};
|
|
80
269
|
}
|
|
81
270
|
|
|
271
|
+
function _array_like_to_array$2(arr, len) {
|
|
272
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
273
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
274
|
+
return arr2;
|
|
275
|
+
}
|
|
276
|
+
function _array_with_holes$2(arr) {
|
|
277
|
+
if (Array.isArray(arr)) return arr;
|
|
278
|
+
}
|
|
279
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
280
|
+
try {
|
|
281
|
+
var info = gen[key](arg);
|
|
282
|
+
var value = info.value;
|
|
283
|
+
} catch (error) {
|
|
284
|
+
reject(error);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (info.done) {
|
|
288
|
+
resolve(value);
|
|
289
|
+
} else {
|
|
290
|
+
Promise.resolve(value).then(_next, _throw);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function _async_to_generator$3(fn) {
|
|
294
|
+
return function() {
|
|
295
|
+
var self = this, args = arguments;
|
|
296
|
+
return new Promise(function(resolve, reject) {
|
|
297
|
+
var gen = fn.apply(self, args);
|
|
298
|
+
function _next(value) {
|
|
299
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
300
|
+
}
|
|
301
|
+
function _throw(err) {
|
|
302
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
303
|
+
}
|
|
304
|
+
_next(undefined);
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function _define_property$3(obj, key, value) {
|
|
309
|
+
if (key in obj) {
|
|
310
|
+
Object.defineProperty(obj, key, {
|
|
311
|
+
value: value,
|
|
312
|
+
enumerable: true,
|
|
313
|
+
configurable: true,
|
|
314
|
+
writable: true
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
obj[key] = value;
|
|
318
|
+
}
|
|
319
|
+
return obj;
|
|
320
|
+
}
|
|
321
|
+
function _instanceof$1(left, right) {
|
|
322
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
323
|
+
return !!right[Symbol.hasInstance](left);
|
|
324
|
+
} else {
|
|
325
|
+
return left instanceof right;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function _iterable_to_array_limit$2(arr, i) {
|
|
329
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
330
|
+
if (_i == null) return;
|
|
331
|
+
var _arr = [];
|
|
332
|
+
var _n = true;
|
|
333
|
+
var _d = false;
|
|
334
|
+
var _s, _e;
|
|
335
|
+
try {
|
|
336
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
337
|
+
_arr.push(_s.value);
|
|
338
|
+
if (i && _arr.length === i) break;
|
|
339
|
+
}
|
|
340
|
+
} catch (err) {
|
|
341
|
+
_d = true;
|
|
342
|
+
_e = err;
|
|
343
|
+
} finally{
|
|
344
|
+
try {
|
|
345
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
346
|
+
} finally{
|
|
347
|
+
if (_d) throw _e;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return _arr;
|
|
351
|
+
}
|
|
352
|
+
function _non_iterable_rest$2() {
|
|
353
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
354
|
+
}
|
|
355
|
+
function _object_spread$3(target) {
|
|
356
|
+
for(var i = 1; i < arguments.length; i++){
|
|
357
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
358
|
+
var ownKeys = Object.keys(source);
|
|
359
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
360
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
361
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
ownKeys.forEach(function(key) {
|
|
365
|
+
_define_property$3(target, key, source[key]);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
return target;
|
|
369
|
+
}
|
|
370
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
371
|
+
var keys = Object.keys(object);
|
|
372
|
+
if (Object.getOwnPropertySymbols) {
|
|
373
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
374
|
+
keys.push.apply(keys, symbols);
|
|
375
|
+
}
|
|
376
|
+
return keys;
|
|
377
|
+
}
|
|
378
|
+
function _object_spread_props$2(target, source) {
|
|
379
|
+
source = source != null ? source : {};
|
|
380
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
381
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
382
|
+
} else {
|
|
383
|
+
ownKeys$2(Object(source)).forEach(function(key) {
|
|
384
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return target;
|
|
388
|
+
}
|
|
389
|
+
function _sliced_to_array$2(arr, i) {
|
|
390
|
+
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
|
|
391
|
+
}
|
|
392
|
+
function _type_of$3(obj) {
|
|
393
|
+
"@swc/helpers - typeof";
|
|
394
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
395
|
+
}
|
|
396
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
397
|
+
if (!o) return;
|
|
398
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
399
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
400
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
401
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
402
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
403
|
+
}
|
|
404
|
+
function _ts_generator$3(thisArg, body) {
|
|
405
|
+
var f, y, t, _ = {
|
|
406
|
+
label: 0,
|
|
407
|
+
sent: function() {
|
|
408
|
+
if (t[0] & 1) throw t[1];
|
|
409
|
+
return t[1];
|
|
410
|
+
},
|
|
411
|
+
trys: [],
|
|
412
|
+
ops: []
|
|
413
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
414
|
+
return d(g, "next", {
|
|
415
|
+
value: verb(0)
|
|
416
|
+
}), d(g, "throw", {
|
|
417
|
+
value: verb(1)
|
|
418
|
+
}), d(g, "return", {
|
|
419
|
+
value: verb(2)
|
|
420
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
421
|
+
value: function() {
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
}), g;
|
|
425
|
+
function verb(n) {
|
|
426
|
+
return function(v) {
|
|
427
|
+
return step([
|
|
428
|
+
n,
|
|
429
|
+
v
|
|
430
|
+
]);
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function step(op) {
|
|
434
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
435
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
436
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
437
|
+
if (y = 0, t) op = [
|
|
438
|
+
op[0] & 2,
|
|
439
|
+
t.value
|
|
440
|
+
];
|
|
441
|
+
switch(op[0]){
|
|
442
|
+
case 0:
|
|
443
|
+
case 1:
|
|
444
|
+
t = op;
|
|
445
|
+
break;
|
|
446
|
+
case 4:
|
|
447
|
+
_.label++;
|
|
448
|
+
return {
|
|
449
|
+
value: op[1],
|
|
450
|
+
done: false
|
|
451
|
+
};
|
|
452
|
+
case 5:
|
|
453
|
+
_.label++;
|
|
454
|
+
y = op[1];
|
|
455
|
+
op = [
|
|
456
|
+
0
|
|
457
|
+
];
|
|
458
|
+
continue;
|
|
459
|
+
case 7:
|
|
460
|
+
op = _.ops.pop();
|
|
461
|
+
_.trys.pop();
|
|
462
|
+
continue;
|
|
463
|
+
default:
|
|
464
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
465
|
+
_ = 0;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
469
|
+
_.label = op[1];
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
473
|
+
_.label = t[1];
|
|
474
|
+
t = op;
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
if (t && _.label < t[2]) {
|
|
478
|
+
_.label = t[2];
|
|
479
|
+
_.ops.push(op);
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
if (t[2]) _.ops.pop();
|
|
483
|
+
_.trys.pop();
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
op = body.call(thisArg, _);
|
|
487
|
+
} catch (e) {
|
|
488
|
+
op = [
|
|
489
|
+
6,
|
|
490
|
+
e
|
|
491
|
+
];
|
|
492
|
+
y = 0;
|
|
493
|
+
} finally{
|
|
494
|
+
f = t = 0;
|
|
495
|
+
}
|
|
496
|
+
if (op[0] & 5) throw op[1];
|
|
497
|
+
return {
|
|
498
|
+
value: op[0] ? op[1] : void 0,
|
|
499
|
+
done: true
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
82
503
|
/**
|
|
83
504
|
* Used to create a FetchService.
|
|
84
505
|
*
|
|
85
506
|
* @param config
|
|
86
507
|
* @returns
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
return factory;
|
|
508
|
+
*/ function fetchService(config) {
|
|
509
|
+
var inputMakeFetch = config.makeFetch, makeRequest = config.makeRequest, baseRequest = config.baseRequest;
|
|
510
|
+
var factory = {
|
|
511
|
+
fetchRequestFactory: function fetchRequestFactory1(config) {
|
|
512
|
+
return fetchRequestFactory(_object_spread$3({
|
|
513
|
+
makeRequest: makeRequest,
|
|
514
|
+
baseRequest: baseRequest
|
|
515
|
+
}, config));
|
|
516
|
+
},
|
|
517
|
+
makeFetch: function makeFetch() {
|
|
518
|
+
var _$config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
519
|
+
return configureFetch(_object_spread$3({
|
|
520
|
+
makeRequest: makeRequest,
|
|
521
|
+
makeFetch: inputMakeFetch,
|
|
522
|
+
baseRequest: baseRequest
|
|
523
|
+
}, _$config));
|
|
524
|
+
},
|
|
525
|
+
makeRequest: config.makeRequest
|
|
526
|
+
};
|
|
527
|
+
return factory;
|
|
109
528
|
}
|
|
110
529
|
/**
|
|
111
530
|
* Default FetchHabdler
|
|
112
531
|
* @param request
|
|
113
532
|
* @param makeFetch
|
|
114
533
|
* @returns
|
|
115
|
-
*/
|
|
116
|
-
|
|
534
|
+
*/ var DEFAULT_FETCH_HANDLER = function DEFAULT_FETCH_HANDLER(request, makeFetch) {
|
|
535
|
+
return makeFetch(request);
|
|
536
|
+
};
|
|
117
537
|
/**
|
|
118
538
|
* Creates a function that wraps fetch and uses a FetchRequestFactory to generate a Request before invoking Fetch.
|
|
119
539
|
*
|
|
120
540
|
* @param config
|
|
121
541
|
* @returns
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
542
|
+
*/ function configureFetch(config) {
|
|
543
|
+
var tmp = config.makeFetch, inputMakeFetch = tmp === void 0 ? fetch : tmp, _config_fetchHandler = config.fetchHandler, fetchHandler = _config_fetchHandler === void 0 ? DEFAULT_FETCH_HANDLER : _config_fetchHandler, useTimeout = config.useTimeout, inputRequireOkResponse = config.requireOkResponse, mapResponse = config.mapResponse;
|
|
544
|
+
var makeFetch = inputMakeFetch;
|
|
545
|
+
if (useTimeout) {
|
|
546
|
+
// add fetchTimeout
|
|
547
|
+
makeFetch = fetchTimeout(makeFetch);
|
|
548
|
+
}
|
|
549
|
+
if (inputRequireOkResponse) {
|
|
550
|
+
// Add fetchOk
|
|
551
|
+
makeFetch = fetchOk(makeFetch);
|
|
552
|
+
}
|
|
553
|
+
var makeFetchRequest = fetchRequestFactory(config);
|
|
554
|
+
return function(input, init) {
|
|
555
|
+
return _async_to_generator$3(function() {
|
|
556
|
+
var request, response;
|
|
557
|
+
return _ts_generator$3(this, function(_state) {
|
|
558
|
+
switch(_state.label){
|
|
559
|
+
case 0:
|
|
560
|
+
return [
|
|
561
|
+
4,
|
|
562
|
+
makeFetchRequest(input, init)
|
|
563
|
+
];
|
|
564
|
+
case 1:
|
|
565
|
+
request = _state.sent();
|
|
566
|
+
response = fetchHandler(request, makeFetch);
|
|
567
|
+
if (mapResponse) {
|
|
568
|
+
response = mapResponse(response);
|
|
569
|
+
}
|
|
570
|
+
return [
|
|
571
|
+
2,
|
|
572
|
+
response
|
|
573
|
+
];
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
})();
|
|
577
|
+
};
|
|
149
578
|
}
|
|
150
579
|
/**
|
|
151
580
|
* The deafult FetchRequestFactory implementation that uses window/global Request.
|
|
@@ -153,448 +582,1368 @@ function configureFetch(config) {
|
|
|
153
582
|
* @param input
|
|
154
583
|
* @param init
|
|
155
584
|
* @returns
|
|
156
|
-
*/
|
|
157
|
-
|
|
585
|
+
*/ var DEFAULT_FETCH_REQUEST_FACTORY = function DEFAULT_FETCH_REQUEST_FACTORY(input, init) {
|
|
586
|
+
return new Request(input, init);
|
|
587
|
+
};
|
|
158
588
|
function fetchRequestFactory(config) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
baseUrl
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
589
|
+
var _config_makeRequest = config.makeRequest, makeRequest = _config_makeRequest === void 0 ? DEFAULT_FETCH_REQUEST_FACTORY : _config_makeRequest, inputBaseUrl = config.baseUrl, inputBaseRequest = config.baseRequest, timeout = config.timeout, requestInitFactory = config.requestInitFactory, _config_useBaseUrlForConfiguredFetchRequests = config.useBaseUrlForConfiguredFetchRequests, useBaseUrlForConfiguredFetchRequests = _config_useBaseUrlForConfiguredFetchRequests === void 0 ? false : _config_useBaseUrlForConfiguredFetchRequests, _config_forceBaseUrlForWebsiteUrlWithPrefix = config.forceBaseUrlForWebsiteUrlWithPrefix, forceBaseUrlForWebsiteUrlWithPrefix = _config_forceBaseUrlForWebsiteUrlWithPrefix === void 0 ? useBaseUrlForConfiguredFetchRequests : _config_forceBaseUrlForWebsiteUrlWithPrefix;
|
|
590
|
+
var baseUrl = inputBaseUrl ? new URL(removeTrailingSlashes(inputBaseUrl)) : undefined;
|
|
591
|
+
var buildUrl = baseUrl ? function(url) {
|
|
592
|
+
var result;
|
|
593
|
+
var urlString = url.toString();
|
|
594
|
+
// retain the origin and any pathname from the base url, unless the url contains a prefix
|
|
595
|
+
if (!forceBaseUrlForWebsiteUrlWithPrefix && isWebsiteUrlWithPrefix(urlString)) {
|
|
596
|
+
result = new URL(urlString);
|
|
597
|
+
} else {
|
|
598
|
+
var urlPath = baseUrl.origin + fixMultiSlashesInSlashPath('/' + baseUrl.pathname + '/' + url);
|
|
599
|
+
result = new URL(urlPath, baseUrl);
|
|
600
|
+
}
|
|
601
|
+
return result;
|
|
602
|
+
} : undefined;
|
|
603
|
+
function asFetchRequest(input) {
|
|
604
|
+
return _async_to_generator$3(function() {
|
|
605
|
+
var awaitedInput, _tmp;
|
|
606
|
+
return _ts_generator$3(this, function(_state) {
|
|
607
|
+
switch(_state.label){
|
|
608
|
+
case 0:
|
|
609
|
+
if (!isPromiseLike(input)) return [
|
|
610
|
+
3,
|
|
611
|
+
2
|
|
612
|
+
];
|
|
613
|
+
return [
|
|
614
|
+
4,
|
|
615
|
+
input
|
|
616
|
+
];
|
|
617
|
+
case 1:
|
|
618
|
+
_tmp = _state.sent();
|
|
619
|
+
return [
|
|
620
|
+
3,
|
|
621
|
+
3
|
|
622
|
+
];
|
|
623
|
+
case 2:
|
|
624
|
+
_tmp = input;
|
|
625
|
+
_state.label = 3;
|
|
626
|
+
case 3:
|
|
627
|
+
awaitedInput = _tmp;
|
|
628
|
+
if (isFetchRequest(awaitedInput)) {
|
|
629
|
+
return [
|
|
630
|
+
2,
|
|
631
|
+
awaitedInput
|
|
632
|
+
];
|
|
633
|
+
} else {
|
|
634
|
+
return [
|
|
635
|
+
2,
|
|
636
|
+
makeRequest(awaitedInput)
|
|
637
|
+
];
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
})();
|
|
178
642
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
643
|
+
var buildRequestWithFixedUrl = buildUrl ? function(input) {
|
|
644
|
+
return _async_to_generator$3(function() {
|
|
645
|
+
var relativeUrl, baseRequest, request, url;
|
|
646
|
+
return _ts_generator$3(this, function(_state) {
|
|
647
|
+
switch(_state.label){
|
|
648
|
+
case 0:
|
|
649
|
+
if (!(typeof input === 'string')) return [
|
|
650
|
+
3,
|
|
651
|
+
1
|
|
652
|
+
];
|
|
653
|
+
relativeUrl = input;
|
|
654
|
+
return [
|
|
655
|
+
3,
|
|
656
|
+
4
|
|
657
|
+
];
|
|
658
|
+
case 1:
|
|
659
|
+
if (!isFetchRequest(input)) return [
|
|
660
|
+
3,
|
|
661
|
+
2
|
|
662
|
+
];
|
|
663
|
+
if (useBaseUrlForConfiguredFetchRequests) {
|
|
664
|
+
relativeUrl = input.url; // copy the url, and use it as the base.
|
|
665
|
+
baseRequest = input;
|
|
666
|
+
} else {
|
|
667
|
+
request = input;
|
|
668
|
+
}
|
|
669
|
+
return [
|
|
670
|
+
3,
|
|
671
|
+
4
|
|
672
|
+
];
|
|
673
|
+
case 2:
|
|
674
|
+
return [
|
|
675
|
+
4,
|
|
676
|
+
makeRequest(input)
|
|
677
|
+
];
|
|
678
|
+
case 3:
|
|
679
|
+
request = _state.sent();
|
|
680
|
+
_state.label = 4;
|
|
681
|
+
case 4:
|
|
682
|
+
if (!!request) return [
|
|
683
|
+
3,
|
|
684
|
+
6
|
|
685
|
+
];
|
|
686
|
+
url = buildUrl(relativeUrl);
|
|
687
|
+
return [
|
|
688
|
+
4,
|
|
689
|
+
makeRequest(url.href, baseRequest)
|
|
690
|
+
];
|
|
691
|
+
case 5:
|
|
692
|
+
request = _state.sent();
|
|
693
|
+
_state.label = 6;
|
|
694
|
+
case 6:
|
|
695
|
+
return [
|
|
696
|
+
2,
|
|
697
|
+
request
|
|
698
|
+
];
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
})();
|
|
702
|
+
} : asFetchRequest;
|
|
703
|
+
var buildRequestInit;
|
|
704
|
+
if (inputBaseRequest != null || timeout != null) {
|
|
705
|
+
var computeBaseRequest = function computeBaseRequest() {
|
|
706
|
+
return _async_to_generator$3(function() {
|
|
707
|
+
var computedBaseRequest, baseRequest;
|
|
708
|
+
return _ts_generator$3(this, function(_state) {
|
|
709
|
+
switch(_state.label){
|
|
710
|
+
case 0:
|
|
711
|
+
return [
|
|
712
|
+
4,
|
|
713
|
+
inputBaseRequestAsGetter()
|
|
714
|
+
];
|
|
715
|
+
case 1:
|
|
716
|
+
computedBaseRequest = _state.sent();
|
|
717
|
+
baseRequest = timeout ? _object_spread_props$2(_object_spread$3({}, computedBaseRequest), {
|
|
718
|
+
timeout: timeout
|
|
719
|
+
}) : computedBaseRequest;
|
|
720
|
+
return [
|
|
721
|
+
2,
|
|
722
|
+
baseRequest
|
|
723
|
+
];
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
})();
|
|
727
|
+
};
|
|
728
|
+
var combineRequestInits = function combineRequestInits(request, requestInit) {
|
|
729
|
+
return _async_to_generator$3(function() {
|
|
730
|
+
var baseRequest, merged, _tmp, timeout;
|
|
731
|
+
return _ts_generator$3(this, function(_state) {
|
|
732
|
+
switch(_state.label){
|
|
733
|
+
case 0:
|
|
734
|
+
return [
|
|
735
|
+
4,
|
|
736
|
+
computeBaseRequest()
|
|
737
|
+
];
|
|
738
|
+
case 1:
|
|
739
|
+
baseRequest = _state.sent();
|
|
740
|
+
_tmp = [
|
|
741
|
+
baseRequest
|
|
742
|
+
];
|
|
743
|
+
return [
|
|
744
|
+
4,
|
|
745
|
+
requestInit
|
|
746
|
+
];
|
|
747
|
+
case 2:
|
|
748
|
+
merged = mergeRequestInits.apply(void 0, _tmp.concat([
|
|
749
|
+
_state.sent()
|
|
750
|
+
]));
|
|
751
|
+
timeout = merged.timeout === undefined ? request.timeout : merged.timeout;
|
|
752
|
+
return [
|
|
753
|
+
2,
|
|
754
|
+
_object_spread_props$2(_object_spread$3({}, merged), {
|
|
755
|
+
timeout: timeout
|
|
756
|
+
})
|
|
757
|
+
];
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
})();
|
|
761
|
+
};
|
|
762
|
+
var inputBaseRequestAsGetter = asGetter(inputBaseRequest);
|
|
763
|
+
if (requestInitFactory) {
|
|
764
|
+
buildRequestInit = function buildRequestInit(req, x) {
|
|
765
|
+
return requestInitFactory(req, combineRequestInits(req, x));
|
|
766
|
+
};
|
|
767
|
+
} else {
|
|
768
|
+
buildRequestInit = function buildRequestInit(req, x) {
|
|
769
|
+
return combineRequestInits(req, x);
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
} else if (requestInitFactory) {
|
|
773
|
+
buildRequestInit = requestInitFactory;
|
|
185
774
|
} else {
|
|
186
|
-
|
|
775
|
+
buildRequestInit = function buildRequestInit(_, x) {
|
|
776
|
+
return x;
|
|
777
|
+
};
|
|
187
778
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
} else {
|
|
239
|
-
buildRequestInit = (_, x) => x;
|
|
240
|
-
}
|
|
241
|
-
return async (input, init) => {
|
|
242
|
-
try {
|
|
243
|
-
const fixedRequest = await buildRequestWithFixedUrl(input);
|
|
244
|
-
init = await buildRequestInit(fixedRequest, init);
|
|
245
|
-
const request = await makeRequest(fixedRequest, init);
|
|
246
|
-
request.timeout = timeout; // copy/set timeout on the request directly
|
|
247
|
-
return request;
|
|
248
|
-
} catch (e) {
|
|
249
|
-
if (e instanceof FetchRequestFactoryError) {
|
|
250
|
-
throw e;
|
|
251
|
-
} else {
|
|
252
|
-
throw new FetchRequestFactoryError(e);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
};
|
|
779
|
+
return function(input, init) {
|
|
780
|
+
return _async_to_generator$3(function() {
|
|
781
|
+
var fixedRequest, request, e;
|
|
782
|
+
return _ts_generator$3(this, function(_state) {
|
|
783
|
+
switch(_state.label){
|
|
784
|
+
case 0:
|
|
785
|
+
_state.trys.push([
|
|
786
|
+
0,
|
|
787
|
+
4,
|
|
788
|
+
,
|
|
789
|
+
5
|
|
790
|
+
]);
|
|
791
|
+
return [
|
|
792
|
+
4,
|
|
793
|
+
buildRequestWithFixedUrl(input)
|
|
794
|
+
];
|
|
795
|
+
case 1:
|
|
796
|
+
fixedRequest = _state.sent();
|
|
797
|
+
return [
|
|
798
|
+
4,
|
|
799
|
+
buildRequestInit(fixedRequest, init)
|
|
800
|
+
];
|
|
801
|
+
case 2:
|
|
802
|
+
init = _state.sent();
|
|
803
|
+
return [
|
|
804
|
+
4,
|
|
805
|
+
makeRequest(fixedRequest, init)
|
|
806
|
+
];
|
|
807
|
+
case 3:
|
|
808
|
+
request = _state.sent();
|
|
809
|
+
request.timeout = timeout; // copy/set timeout on the request directly
|
|
810
|
+
return [
|
|
811
|
+
2,
|
|
812
|
+
request
|
|
813
|
+
];
|
|
814
|
+
case 4:
|
|
815
|
+
e = _state.sent();
|
|
816
|
+
if (_instanceof$1(e, FetchRequestFactoryError)) {
|
|
817
|
+
throw e;
|
|
818
|
+
} else {
|
|
819
|
+
throw new FetchRequestFactoryError(e);
|
|
820
|
+
}
|
|
821
|
+
case 5:
|
|
822
|
+
return [
|
|
823
|
+
2
|
|
824
|
+
];
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
})();
|
|
828
|
+
};
|
|
256
829
|
}
|
|
257
830
|
function mergeRequestInits(base, requestInit) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
831
|
+
if (requestInit) {
|
|
832
|
+
var headers = mergeRequestHeaders([
|
|
833
|
+
base.headers,
|
|
834
|
+
requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers
|
|
835
|
+
]);
|
|
836
|
+
return _object_spread_props$2(_object_spread$3({}, base, requestInit), {
|
|
837
|
+
headers: headers
|
|
838
|
+
});
|
|
839
|
+
} else {
|
|
840
|
+
return base;
|
|
841
|
+
}
|
|
268
842
|
}
|
|
269
843
|
function mergeRequestHeaders(inputHeadersArray) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
844
|
+
var headersMap = multiValueMapBuilder();
|
|
845
|
+
filterMaybeArrayValues(inputHeadersArray).forEach(function(headers) {
|
|
846
|
+
var tuples = headersToHeadersTuple(headers);
|
|
847
|
+
var visitedKeysSet = new Set();
|
|
848
|
+
tuples.forEach(function(param) {
|
|
849
|
+
var _param = _sliced_to_array$2(param, 2), key = _param[0], value = _param[1];
|
|
850
|
+
if (!visitedKeysSet.has(key)) {
|
|
851
|
+
headersMap.delete(key); // delete all existing values to "override" them
|
|
852
|
+
visitedKeysSet.add(key);
|
|
853
|
+
}
|
|
854
|
+
if (value) {
|
|
855
|
+
headersMap.add(key, value);
|
|
856
|
+
}
|
|
857
|
+
});
|
|
282
858
|
});
|
|
283
|
-
|
|
284
|
-
return headersMap.tuples();
|
|
859
|
+
return headersMap.tuples();
|
|
285
860
|
}
|
|
286
861
|
function headersToHeadersTuple(headers) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
862
|
+
var tuples = [];
|
|
863
|
+
if (Array.isArray(headers)) {
|
|
864
|
+
// use as tuples
|
|
865
|
+
tuples = headers;
|
|
866
|
+
} else if (typeof headers.forEach === 'function') {
|
|
867
|
+
// use as a headers object
|
|
868
|
+
headers.forEach(function(value, key) {
|
|
869
|
+
tuples.push([
|
|
870
|
+
key,
|
|
871
|
+
value
|
|
872
|
+
]);
|
|
873
|
+
});
|
|
874
|
+
} else if ((typeof headers === "undefined" ? "undefined" : _type_of$3(headers)) === 'object') {
|
|
875
|
+
// use as a normal object
|
|
876
|
+
tuples = Object.entries(headers);
|
|
877
|
+
}
|
|
878
|
+
return tuples;
|
|
301
879
|
}
|
|
302
880
|
function isFetchRequest(input) {
|
|
303
|
-
|
|
881
|
+
return Boolean(input.url);
|
|
304
882
|
}
|
|
305
883
|
|
|
306
884
|
function fetchUploadFile(input) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
'Content-Type': inputBody.mimeType
|
|
318
|
-
}
|
|
319
|
-
});
|
|
885
|
+
var _input_method;
|
|
886
|
+
var inputFetch = input.fetch, url = input.url, inputBody = input.body;
|
|
887
|
+
var useFetch = inputFetch !== null && inputFetch !== void 0 ? inputFetch : fetch;
|
|
888
|
+
return useFetch(url, {
|
|
889
|
+
method: (_input_method = input.method) !== null && _input_method !== void 0 ? _input_method : 'POST',
|
|
890
|
+
body: inputBody.body,
|
|
891
|
+
headers: {
|
|
892
|
+
'Content-Type': inputBody.mimeType
|
|
893
|
+
}
|
|
894
|
+
});
|
|
320
895
|
}
|
|
321
896
|
/**
|
|
322
897
|
* Parses the file response and returns the response wrapped in a FetchFileResponse object.
|
|
323
898
|
*
|
|
324
899
|
* @param response
|
|
325
900
|
* @returns
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
};
|
|
901
|
+
*/ function parseFetchFileResponse(response) {
|
|
902
|
+
var rawContentType = response.headers.get('content-type');
|
|
903
|
+
var parseContentTypeResult = safeParse(rawContentType !== null && rawContentType !== void 0 ? rawContentType : '');
|
|
904
|
+
var contentType = parseContentTypeResult.type !== '' ? parseContentTypeResult : undefined;
|
|
905
|
+
return {
|
|
906
|
+
response: response,
|
|
907
|
+
rawContentType: rawContentType,
|
|
908
|
+
contentType: contentType,
|
|
909
|
+
mimeType: contentType === null || contentType === void 0 ? void 0 : contentType.type
|
|
910
|
+
};
|
|
337
911
|
}
|
|
338
912
|
|
|
913
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
914
|
+
try {
|
|
915
|
+
var info = gen[key](arg);
|
|
916
|
+
var value = info.value;
|
|
917
|
+
} catch (error) {
|
|
918
|
+
reject(error);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
if (info.done) {
|
|
922
|
+
resolve(value);
|
|
923
|
+
} else {
|
|
924
|
+
Promise.resolve(value).then(_next, _throw);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
function _async_to_generator$2(fn) {
|
|
928
|
+
return function() {
|
|
929
|
+
var self = this, args = arguments;
|
|
930
|
+
return new Promise(function(resolve, reject) {
|
|
931
|
+
var gen = fn.apply(self, args);
|
|
932
|
+
function _next(value) {
|
|
933
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
934
|
+
}
|
|
935
|
+
function _throw(err) {
|
|
936
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
937
|
+
}
|
|
938
|
+
_next(undefined);
|
|
939
|
+
});
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
function _ts_generator$2(thisArg, body) {
|
|
943
|
+
var f, y, t, _ = {
|
|
944
|
+
label: 0,
|
|
945
|
+
sent: function() {
|
|
946
|
+
if (t[0] & 1) throw t[1];
|
|
947
|
+
return t[1];
|
|
948
|
+
},
|
|
949
|
+
trys: [],
|
|
950
|
+
ops: []
|
|
951
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
952
|
+
return d(g, "next", {
|
|
953
|
+
value: verb(0)
|
|
954
|
+
}), d(g, "throw", {
|
|
955
|
+
value: verb(1)
|
|
956
|
+
}), d(g, "return", {
|
|
957
|
+
value: verb(2)
|
|
958
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
959
|
+
value: function() {
|
|
960
|
+
return this;
|
|
961
|
+
}
|
|
962
|
+
}), g;
|
|
963
|
+
function verb(n) {
|
|
964
|
+
return function(v) {
|
|
965
|
+
return step([
|
|
966
|
+
n,
|
|
967
|
+
v
|
|
968
|
+
]);
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
function step(op) {
|
|
972
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
973
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
974
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
975
|
+
if (y = 0, t) op = [
|
|
976
|
+
op[0] & 2,
|
|
977
|
+
t.value
|
|
978
|
+
];
|
|
979
|
+
switch(op[0]){
|
|
980
|
+
case 0:
|
|
981
|
+
case 1:
|
|
982
|
+
t = op;
|
|
983
|
+
break;
|
|
984
|
+
case 4:
|
|
985
|
+
_.label++;
|
|
986
|
+
return {
|
|
987
|
+
value: op[1],
|
|
988
|
+
done: false
|
|
989
|
+
};
|
|
990
|
+
case 5:
|
|
991
|
+
_.label++;
|
|
992
|
+
y = op[1];
|
|
993
|
+
op = [
|
|
994
|
+
0
|
|
995
|
+
];
|
|
996
|
+
continue;
|
|
997
|
+
case 7:
|
|
998
|
+
op = _.ops.pop();
|
|
999
|
+
_.trys.pop();
|
|
1000
|
+
continue;
|
|
1001
|
+
default:
|
|
1002
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1003
|
+
_ = 0;
|
|
1004
|
+
continue;
|
|
1005
|
+
}
|
|
1006
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1007
|
+
_.label = op[1];
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1011
|
+
_.label = t[1];
|
|
1012
|
+
t = op;
|
|
1013
|
+
break;
|
|
1014
|
+
}
|
|
1015
|
+
if (t && _.label < t[2]) {
|
|
1016
|
+
_.label = t[2];
|
|
1017
|
+
_.ops.push(op);
|
|
1018
|
+
break;
|
|
1019
|
+
}
|
|
1020
|
+
if (t[2]) _.ops.pop();
|
|
1021
|
+
_.trys.pop();
|
|
1022
|
+
continue;
|
|
1023
|
+
}
|
|
1024
|
+
op = body.call(thisArg, _);
|
|
1025
|
+
} catch (e) {
|
|
1026
|
+
op = [
|
|
1027
|
+
6,
|
|
1028
|
+
e
|
|
1029
|
+
];
|
|
1030
|
+
y = 0;
|
|
1031
|
+
} finally{
|
|
1032
|
+
f = t = 0;
|
|
1033
|
+
}
|
|
1034
|
+
if (op[0] & 5) throw op[1];
|
|
1035
|
+
return {
|
|
1036
|
+
value: op[0] ? op[1] : void 0,
|
|
1037
|
+
done: true
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
339
1041
|
function rateLimitedFetchHandler(config) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
1042
|
+
var updateWithResponse = config.updateWithResponse, inputMaxRetries = config.maxRetries;
|
|
1043
|
+
var maxRetries = inputMaxRetries !== null && inputMaxRetries !== void 0 ? inputMaxRetries : 1;
|
|
1044
|
+
var _rateLimiter = config.rateLimiter;
|
|
1045
|
+
var fetchHandler = function fetchHandler(request, makeFetch) {
|
|
1046
|
+
return _async_to_generator$2(function() {
|
|
1047
|
+
function tryFetch(retriesAttempted) {
|
|
1048
|
+
return _async_to_generator$2(function() {
|
|
1049
|
+
var response, fetchResponseError, e, shouldRetry, _tmp;
|
|
1050
|
+
return _ts_generator$2(this, function(_state) {
|
|
1051
|
+
switch(_state.label){
|
|
1052
|
+
case 0:
|
|
1053
|
+
// wait for the rate limiter
|
|
1054
|
+
return [
|
|
1055
|
+
4,
|
|
1056
|
+
_rateLimiter.waitForRateLimit()
|
|
1057
|
+
];
|
|
1058
|
+
case 1:
|
|
1059
|
+
_state.sent();
|
|
1060
|
+
_state.label = 2;
|
|
1061
|
+
case 2:
|
|
1062
|
+
_state.trys.push([
|
|
1063
|
+
2,
|
|
1064
|
+
4,
|
|
1065
|
+
,
|
|
1066
|
+
5
|
|
1067
|
+
]);
|
|
1068
|
+
return [
|
|
1069
|
+
4,
|
|
1070
|
+
makeFetch(request.clone())
|
|
1071
|
+
];
|
|
1072
|
+
case 3:
|
|
1073
|
+
response = _state.sent();
|
|
1074
|
+
return [
|
|
1075
|
+
3,
|
|
1076
|
+
5
|
|
1077
|
+
];
|
|
1078
|
+
case 4:
|
|
1079
|
+
e = _state.sent();
|
|
1080
|
+
fetchResponseError = e;
|
|
1081
|
+
response = fetchResponseError.response;
|
|
1082
|
+
return [
|
|
1083
|
+
3,
|
|
1084
|
+
5
|
|
1085
|
+
];
|
|
1086
|
+
case 5:
|
|
1087
|
+
if (!response) return [
|
|
1088
|
+
3,
|
|
1089
|
+
7
|
|
1090
|
+
];
|
|
1091
|
+
return [
|
|
1092
|
+
4,
|
|
1093
|
+
updateWithResponse(response, fetchResponseError)
|
|
1094
|
+
];
|
|
1095
|
+
case 6:
|
|
1096
|
+
_tmp = _state.sent();
|
|
1097
|
+
return [
|
|
1098
|
+
3,
|
|
1099
|
+
8
|
|
1100
|
+
];
|
|
1101
|
+
case 7:
|
|
1102
|
+
_tmp = false;
|
|
1103
|
+
_state.label = 8;
|
|
1104
|
+
case 8:
|
|
1105
|
+
shouldRetry = _tmp;
|
|
1106
|
+
if (!(shouldRetry && retriesAttempted < maxRetries)) return [
|
|
1107
|
+
3,
|
|
1108
|
+
10
|
|
1109
|
+
];
|
|
1110
|
+
return [
|
|
1111
|
+
4,
|
|
1112
|
+
tryFetch(retriesAttempted + 1)
|
|
1113
|
+
];
|
|
1114
|
+
case 9:
|
|
1115
|
+
response = _state.sent();
|
|
1116
|
+
return [
|
|
1117
|
+
3,
|
|
1118
|
+
11
|
|
1119
|
+
];
|
|
1120
|
+
case 10:
|
|
1121
|
+
// re-throw the fetch response error if it exists and we cannot retry
|
|
1122
|
+
if (fetchResponseError != null) {
|
|
1123
|
+
throw fetchResponseError;
|
|
1124
|
+
}
|
|
1125
|
+
_state.label = 11;
|
|
1126
|
+
case 11:
|
|
1127
|
+
// if response is null at this point but fetchResponseError is not, rethrow the error
|
|
1128
|
+
if (response == null && fetchResponseError != null) {
|
|
1129
|
+
throw fetchResponseError;
|
|
1130
|
+
}
|
|
1131
|
+
return [
|
|
1132
|
+
2,
|
|
1133
|
+
response
|
|
1134
|
+
];
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
})();
|
|
1138
|
+
}
|
|
1139
|
+
return _ts_generator$2(this, function(_state) {
|
|
1140
|
+
return [
|
|
1141
|
+
2,
|
|
1142
|
+
tryFetch(0)
|
|
1143
|
+
];
|
|
1144
|
+
});
|
|
1145
|
+
})();
|
|
1146
|
+
};
|
|
1147
|
+
fetchHandler._rateLimiter = _rateLimiter;
|
|
1148
|
+
return fetchHandler;
|
|
378
1149
|
}
|
|
379
1150
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
1151
|
+
function _assert_this_initialized$1(self) {
|
|
1152
|
+
if (self === void 0) {
|
|
1153
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1154
|
+
}
|
|
1155
|
+
return self;
|
|
1156
|
+
}
|
|
1157
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1158
|
+
try {
|
|
1159
|
+
var info = gen[key](arg);
|
|
1160
|
+
var value = info.value;
|
|
1161
|
+
} catch (error) {
|
|
1162
|
+
reject(error);
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
if (info.done) {
|
|
1166
|
+
resolve(value);
|
|
1167
|
+
} else {
|
|
1168
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1169
|
+
}
|
|
395
1170
|
}
|
|
1171
|
+
function _async_to_generator$1(fn) {
|
|
1172
|
+
return function() {
|
|
1173
|
+
var self = this, args = arguments;
|
|
1174
|
+
return new Promise(function(resolve, reject) {
|
|
1175
|
+
var gen = fn.apply(self, args);
|
|
1176
|
+
function _next(value) {
|
|
1177
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1178
|
+
}
|
|
1179
|
+
function _throw(err) {
|
|
1180
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1181
|
+
}
|
|
1182
|
+
_next(undefined);
|
|
1183
|
+
});
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
function _call_super$1(_this, derived, args) {
|
|
1187
|
+
derived = _get_prototype_of$1(derived);
|
|
1188
|
+
return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, args || [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
|
|
1189
|
+
}
|
|
1190
|
+
function _class_call_check$1(instance, Constructor) {
|
|
1191
|
+
if (!(instance instanceof Constructor)) {
|
|
1192
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
function _define_property$2(obj, key, value) {
|
|
1196
|
+
if (key in obj) {
|
|
1197
|
+
Object.defineProperty(obj, key, {
|
|
1198
|
+
value: value,
|
|
1199
|
+
enumerable: true,
|
|
1200
|
+
configurable: true,
|
|
1201
|
+
writable: true
|
|
1202
|
+
});
|
|
1203
|
+
} else {
|
|
1204
|
+
obj[key] = value;
|
|
1205
|
+
}
|
|
1206
|
+
return obj;
|
|
1207
|
+
}
|
|
1208
|
+
function _get_prototype_of$1(o) {
|
|
1209
|
+
_get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
1210
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
1211
|
+
};
|
|
1212
|
+
return _get_prototype_of$1(o);
|
|
1213
|
+
}
|
|
1214
|
+
function _inherits$1(subClass, superClass) {
|
|
1215
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
1216
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
1217
|
+
}
|
|
1218
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1219
|
+
constructor: {
|
|
1220
|
+
value: subClass,
|
|
1221
|
+
writable: true,
|
|
1222
|
+
configurable: true
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
if (superClass) _set_prototype_of$1(subClass, superClass);
|
|
1226
|
+
}
|
|
1227
|
+
function _object_spread$2(target) {
|
|
1228
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1229
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
1230
|
+
var ownKeys = Object.keys(source);
|
|
1231
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1232
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1233
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1234
|
+
}));
|
|
1235
|
+
}
|
|
1236
|
+
ownKeys.forEach(function(key) {
|
|
1237
|
+
_define_property$2(target, key, source[key]);
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
return target;
|
|
1241
|
+
}
|
|
1242
|
+
function _possible_constructor_return$1(self, call) {
|
|
1243
|
+
if (call && (_type_of$2(call) === "object" || typeof call === "function")) {
|
|
1244
|
+
return call;
|
|
1245
|
+
}
|
|
1246
|
+
return _assert_this_initialized$1(self);
|
|
1247
|
+
}
|
|
1248
|
+
function _set_prototype_of$1(o, p) {
|
|
1249
|
+
_set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
1250
|
+
o.__proto__ = p;
|
|
1251
|
+
return o;
|
|
1252
|
+
};
|
|
1253
|
+
return _set_prototype_of$1(o, p);
|
|
1254
|
+
}
|
|
1255
|
+
function _type_of$2(obj) {
|
|
1256
|
+
"@swc/helpers - typeof";
|
|
1257
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1258
|
+
}
|
|
1259
|
+
function _is_native_reflect_construct$1() {
|
|
1260
|
+
try {
|
|
1261
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
1262
|
+
} catch (_) {}
|
|
1263
|
+
return (_is_native_reflect_construct$1 = function() {
|
|
1264
|
+
return !!result;
|
|
1265
|
+
})();
|
|
1266
|
+
}
|
|
1267
|
+
function _ts_generator$1(thisArg, body) {
|
|
1268
|
+
var f, y, t, _ = {
|
|
1269
|
+
label: 0,
|
|
1270
|
+
sent: function() {
|
|
1271
|
+
if (t[0] & 1) throw t[1];
|
|
1272
|
+
return t[1];
|
|
1273
|
+
},
|
|
1274
|
+
trys: [],
|
|
1275
|
+
ops: []
|
|
1276
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1277
|
+
return d(g, "next", {
|
|
1278
|
+
value: verb(0)
|
|
1279
|
+
}), d(g, "throw", {
|
|
1280
|
+
value: verb(1)
|
|
1281
|
+
}), d(g, "return", {
|
|
1282
|
+
value: verb(2)
|
|
1283
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1284
|
+
value: function() {
|
|
1285
|
+
return this;
|
|
1286
|
+
}
|
|
1287
|
+
}), g;
|
|
1288
|
+
function verb(n) {
|
|
1289
|
+
return function(v) {
|
|
1290
|
+
return step([
|
|
1291
|
+
n,
|
|
1292
|
+
v
|
|
1293
|
+
]);
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function step(op) {
|
|
1297
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1298
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1299
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1300
|
+
if (y = 0, t) op = [
|
|
1301
|
+
op[0] & 2,
|
|
1302
|
+
t.value
|
|
1303
|
+
];
|
|
1304
|
+
switch(op[0]){
|
|
1305
|
+
case 0:
|
|
1306
|
+
case 1:
|
|
1307
|
+
t = op;
|
|
1308
|
+
break;
|
|
1309
|
+
case 4:
|
|
1310
|
+
_.label++;
|
|
1311
|
+
return {
|
|
1312
|
+
value: op[1],
|
|
1313
|
+
done: false
|
|
1314
|
+
};
|
|
1315
|
+
case 5:
|
|
1316
|
+
_.label++;
|
|
1317
|
+
y = op[1];
|
|
1318
|
+
op = [
|
|
1319
|
+
0
|
|
1320
|
+
];
|
|
1321
|
+
continue;
|
|
1322
|
+
case 7:
|
|
1323
|
+
op = _.ops.pop();
|
|
1324
|
+
_.trys.pop();
|
|
1325
|
+
continue;
|
|
1326
|
+
default:
|
|
1327
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1328
|
+
_ = 0;
|
|
1329
|
+
continue;
|
|
1330
|
+
}
|
|
1331
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1332
|
+
_.label = op[1];
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1335
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1336
|
+
_.label = t[1];
|
|
1337
|
+
t = op;
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
if (t && _.label < t[2]) {
|
|
1341
|
+
_.label = t[2];
|
|
1342
|
+
_.ops.push(op);
|
|
1343
|
+
break;
|
|
1344
|
+
}
|
|
1345
|
+
if (t[2]) _.ops.pop();
|
|
1346
|
+
_.trys.pop();
|
|
1347
|
+
continue;
|
|
1348
|
+
}
|
|
1349
|
+
op = body.call(thisArg, _);
|
|
1350
|
+
} catch (e) {
|
|
1351
|
+
op = [
|
|
1352
|
+
6,
|
|
1353
|
+
e
|
|
1354
|
+
];
|
|
1355
|
+
y = 0;
|
|
1356
|
+
} finally{
|
|
1357
|
+
f = t = 0;
|
|
1358
|
+
}
|
|
1359
|
+
if (op[0] & 5) throw op[1];
|
|
1360
|
+
return {
|
|
1361
|
+
value: op[0] ? op[1] : void 0,
|
|
1362
|
+
done: true
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
var FetchPageNoNextPageError = /*#__PURE__*/ function(FetchRequestFactoryError) {
|
|
1367
|
+
_inherits$1(FetchPageNoNextPageError, FetchRequestFactoryError);
|
|
1368
|
+
function FetchPageNoNextPageError(page) {
|
|
1369
|
+
_class_call_check$1(this, FetchPageNoNextPageError);
|
|
1370
|
+
var _this;
|
|
1371
|
+
_this = _call_super$1(this, FetchPageNoNextPageError, [
|
|
1372
|
+
"There was no next page for this."
|
|
1373
|
+
]), _define_property$2(_this, "page", void 0);
|
|
1374
|
+
_this.page = page;
|
|
1375
|
+
return _this;
|
|
1376
|
+
}
|
|
1377
|
+
return FetchPageNoNextPageError;
|
|
1378
|
+
}(FetchRequestFactoryError);
|
|
1379
|
+
var FetchPageLimitReachedError = /*#__PURE__*/ function(FetchRequestFactoryError) {
|
|
1380
|
+
_inherits$1(FetchPageLimitReachedError, FetchRequestFactoryError);
|
|
1381
|
+
function FetchPageLimitReachedError(page, limit) {
|
|
1382
|
+
_class_call_check$1(this, FetchPageLimitReachedError);
|
|
1383
|
+
var _this;
|
|
1384
|
+
_this = _call_super$1(this, FetchPageLimitReachedError, [
|
|
1385
|
+
"The limit of ".concat(limit, " for the number of pages to read was reached.")
|
|
1386
|
+
]), _define_property$2(_this, "page", void 0), _define_property$2(_this, "limit", void 0);
|
|
1387
|
+
_this.page = page;
|
|
1388
|
+
_this.limit = limit;
|
|
1389
|
+
return _this;
|
|
1390
|
+
}
|
|
1391
|
+
return FetchPageLimitReachedError;
|
|
1392
|
+
}(FetchRequestFactoryError);
|
|
396
1393
|
/**
|
|
397
1394
|
* Default max page for a FetchPageFactory.
|
|
398
|
-
*/
|
|
399
|
-
const FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE = 100;
|
|
1395
|
+
*/ var FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE = 100;
|
|
400
1396
|
/**
|
|
401
1397
|
* Creates a new FetchPageFactory from the input.
|
|
402
1398
|
*
|
|
403
1399
|
* @param config
|
|
404
1400
|
* @returns
|
|
405
|
-
*/
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1401
|
+
*/ function fetchPageFactory(config) {
|
|
1402
|
+
var fetch = config.fetch, readFetchPageResultInfo = config.readFetchPageResultInfo, buildInputForNextPage = config.buildInputForNextPage, defaultMaxPage = config.defaultMaxPage, defaultMaxItemsPerPage = config.defaultMaxItemsPerPage;
|
|
1403
|
+
return function(initalInput, options) {
|
|
1404
|
+
var _ref = options !== null && options !== void 0 ? options : {}, tmp = _ref.maxPage, inputMaxPage = tmp === void 0 ? defaultMaxPage : tmp, inputMaxItemsPerPage = _ref.maxItemsPerPage;
|
|
1405
|
+
var maxItemsPerPage = inputMaxItemsPerPage !== null && inputMaxItemsPerPage !== void 0 ? inputMaxItemsPerPage : defaultMaxItemsPerPage;
|
|
1406
|
+
var maxPage = inputMaxPage === null ? Number.MAX_SAFE_INTEGER : inputMaxPage !== null && inputMaxPage !== void 0 ? inputMaxPage : FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE;
|
|
1407
|
+
function fetchNextWithInput(input) {
|
|
1408
|
+
var previous = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : undefined;
|
|
1409
|
+
return function() {
|
|
1410
|
+
return _async_to_generator$1(function() {
|
|
1411
|
+
var result, _ref, readCursor, nextPageCursor, readHasNext, cursor, hasNext, page, isAtMaxPage, nextPageResult;
|
|
1412
|
+
return _ts_generator$1(this, function(_state) {
|
|
1413
|
+
switch(_state.label){
|
|
1414
|
+
case 0:
|
|
1415
|
+
return [
|
|
1416
|
+
4,
|
|
1417
|
+
fetch(input)
|
|
1418
|
+
];
|
|
1419
|
+
case 1:
|
|
1420
|
+
result = _state.sent();
|
|
1421
|
+
return [
|
|
1422
|
+
4,
|
|
1423
|
+
readFetchPageResultInfo(result)
|
|
1424
|
+
];
|
|
1425
|
+
case 2:
|
|
1426
|
+
_ref = _state.sent(), readCursor = _ref.cursor, nextPageCursor = _ref.nextPageCursor, readHasNext = _ref.hasNext;
|
|
1427
|
+
cursor = readCursor !== null && readCursor !== void 0 ? readCursor : previous === null || previous === void 0 ? void 0 : previous.cursor;
|
|
1428
|
+
hasNext = readHasNext !== false;
|
|
1429
|
+
page = previous ? previous.page + 1 : FIRST_PAGE;
|
|
1430
|
+
isAtMaxPage = page >= maxPage;
|
|
1431
|
+
nextPageResult = {
|
|
1432
|
+
input: input,
|
|
1433
|
+
result: result,
|
|
1434
|
+
page: page,
|
|
1435
|
+
previous: previous,
|
|
1436
|
+
hasNext: hasNext,
|
|
1437
|
+
isAtMaxPage: isAtMaxPage,
|
|
1438
|
+
cursor: cursor,
|
|
1439
|
+
nextPageCursor: nextPageCursor,
|
|
1440
|
+
fetchNext: cachedGetter(function() {
|
|
1441
|
+
return _async_to_generator$1(function() {
|
|
1442
|
+
var nextPageInfo, _tmp;
|
|
1443
|
+
return _ts_generator$1(this, function(_state) {
|
|
1444
|
+
switch(_state.label){
|
|
1445
|
+
case 0:
|
|
1446
|
+
// assert max page
|
|
1447
|
+
if (isAtMaxPage) {
|
|
1448
|
+
throw new FetchPageLimitReachedError(nextPageResult, maxPage);
|
|
1449
|
+
}
|
|
1450
|
+
if (!hasNext) return [
|
|
1451
|
+
3,
|
|
1452
|
+
2
|
|
1453
|
+
];
|
|
1454
|
+
return [
|
|
1455
|
+
4,
|
|
1456
|
+
buildInputForNextPage(nextPageResult, input, {
|
|
1457
|
+
maxPage: maxPage,
|
|
1458
|
+
maxItemsPerPage: maxItemsPerPage
|
|
1459
|
+
})
|
|
1460
|
+
];
|
|
1461
|
+
case 1:
|
|
1462
|
+
_tmp = _state.sent();
|
|
1463
|
+
return [
|
|
1464
|
+
3,
|
|
1465
|
+
3
|
|
1466
|
+
];
|
|
1467
|
+
case 2:
|
|
1468
|
+
_tmp = undefined;
|
|
1469
|
+
_state.label = 3;
|
|
1470
|
+
case 3:
|
|
1471
|
+
nextPageInfo = _tmp;
|
|
1472
|
+
if (!nextPageInfo) {
|
|
1473
|
+
throw new FetchPageNoNextPageError(nextPageResult);
|
|
1474
|
+
}
|
|
1475
|
+
return [
|
|
1476
|
+
2,
|
|
1477
|
+
fetchNextWithInput(_object_spread$2({}, input, nextPageInfo), nextPageResult)()
|
|
1478
|
+
];
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
})();
|
|
1482
|
+
})
|
|
1483
|
+
};
|
|
1484
|
+
return [
|
|
1485
|
+
2,
|
|
1486
|
+
nextPageResult
|
|
1487
|
+
];
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
})();
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
var page = {
|
|
1494
|
+
input: initalInput,
|
|
1495
|
+
fetchNext: cachedGetter(function() {
|
|
1496
|
+
return fetchNextWithInput(initalInput)();
|
|
1497
|
+
})
|
|
1498
|
+
};
|
|
1499
|
+
return page;
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
function _array_like_to_array$1(arr, len) {
|
|
1504
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1505
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1506
|
+
return arr2;
|
|
1507
|
+
}
|
|
1508
|
+
function _array_with_holes$1(arr) {
|
|
1509
|
+
if (Array.isArray(arr)) return arr;
|
|
1510
|
+
}
|
|
1511
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1512
|
+
try {
|
|
1513
|
+
var info = gen[key](arg);
|
|
1514
|
+
var value = info.value;
|
|
1515
|
+
} catch (error) {
|
|
1516
|
+
reject(error);
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
if (info.done) {
|
|
1520
|
+
resolve(value);
|
|
1521
|
+
} else {
|
|
1522
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
function _async_to_generator(fn) {
|
|
1526
|
+
return function() {
|
|
1527
|
+
var self = this, args = arguments;
|
|
1528
|
+
return new Promise(function(resolve, reject) {
|
|
1529
|
+
var gen = fn.apply(self, args);
|
|
1530
|
+
function _next(value) {
|
|
1531
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
446
1532
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
maxPage,
|
|
450
|
-
maxItemsPerPage
|
|
451
|
-
}) : undefined;
|
|
452
|
-
if (!nextPageInfo) {
|
|
453
|
-
throw new FetchPageNoNextPageError(nextPageResult);
|
|
1533
|
+
function _throw(err) {
|
|
1534
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
454
1535
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
1536
|
+
_next(undefined);
|
|
1537
|
+
});
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
function _define_property$1(obj, key, value) {
|
|
1541
|
+
if (key in obj) {
|
|
1542
|
+
Object.defineProperty(obj, key, {
|
|
1543
|
+
value: value,
|
|
1544
|
+
enumerable: true,
|
|
1545
|
+
configurable: true,
|
|
1546
|
+
writable: true
|
|
1547
|
+
});
|
|
1548
|
+
} else {
|
|
1549
|
+
obj[key] = value;
|
|
1550
|
+
}
|
|
1551
|
+
return obj;
|
|
1552
|
+
}
|
|
1553
|
+
function _iterable_to_array_limit$1(arr, i) {
|
|
1554
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1555
|
+
if (_i == null) return;
|
|
1556
|
+
var _arr = [];
|
|
1557
|
+
var _n = true;
|
|
1558
|
+
var _d = false;
|
|
1559
|
+
var _s, _e;
|
|
1560
|
+
try {
|
|
1561
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1562
|
+
_arr.push(_s.value);
|
|
1563
|
+
if (i && _arr.length === i) break;
|
|
1564
|
+
}
|
|
1565
|
+
} catch (err) {
|
|
1566
|
+
_d = true;
|
|
1567
|
+
_e = err;
|
|
1568
|
+
} finally{
|
|
1569
|
+
try {
|
|
1570
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1571
|
+
} finally{
|
|
1572
|
+
if (_d) throw _e;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
return _arr;
|
|
1576
|
+
}
|
|
1577
|
+
function _non_iterable_rest$1() {
|
|
1578
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1579
|
+
}
|
|
1580
|
+
function _object_spread$1(target) {
|
|
1581
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1582
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
1583
|
+
var ownKeys = Object.keys(source);
|
|
1584
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1585
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1586
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1587
|
+
}));
|
|
1588
|
+
}
|
|
1589
|
+
ownKeys.forEach(function(key) {
|
|
1590
|
+
_define_property$1(target, key, source[key]);
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
return target;
|
|
1594
|
+
}
|
|
1595
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
1596
|
+
var keys = Object.keys(object);
|
|
1597
|
+
if (Object.getOwnPropertySymbols) {
|
|
1598
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
1599
|
+
keys.push.apply(keys, symbols);
|
|
1600
|
+
}
|
|
1601
|
+
return keys;
|
|
1602
|
+
}
|
|
1603
|
+
function _object_spread_props$1(target, source) {
|
|
1604
|
+
source = source != null ? source : {};
|
|
1605
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
1606
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1607
|
+
} else {
|
|
1608
|
+
ownKeys$1(Object(source)).forEach(function(key) {
|
|
1609
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
return target;
|
|
1613
|
+
}
|
|
1614
|
+
function _sliced_to_array$1(arr, i) {
|
|
1615
|
+
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
1616
|
+
}
|
|
1617
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
1618
|
+
if (!o) return;
|
|
1619
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
1620
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1621
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1622
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1623
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
1624
|
+
}
|
|
1625
|
+
function _ts_generator(thisArg, body) {
|
|
1626
|
+
var f, y, t, _ = {
|
|
1627
|
+
label: 0,
|
|
1628
|
+
sent: function() {
|
|
1629
|
+
if (t[0] & 1) throw t[1];
|
|
1630
|
+
return t[1];
|
|
1631
|
+
},
|
|
1632
|
+
trys: [],
|
|
1633
|
+
ops: []
|
|
1634
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1635
|
+
return d(g, "next", {
|
|
1636
|
+
value: verb(0)
|
|
1637
|
+
}), d(g, "throw", {
|
|
1638
|
+
value: verb(1)
|
|
1639
|
+
}), d(g, "return", {
|
|
1640
|
+
value: verb(2)
|
|
1641
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1642
|
+
value: function() {
|
|
1643
|
+
return this;
|
|
1644
|
+
}
|
|
1645
|
+
}), g;
|
|
1646
|
+
function verb(n) {
|
|
1647
|
+
return function(v) {
|
|
1648
|
+
return step([
|
|
1649
|
+
n,
|
|
1650
|
+
v
|
|
1651
|
+
]);
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
function step(op) {
|
|
1655
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1656
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1657
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1658
|
+
if (y = 0, t) op = [
|
|
1659
|
+
op[0] & 2,
|
|
1660
|
+
t.value
|
|
1661
|
+
];
|
|
1662
|
+
switch(op[0]){
|
|
1663
|
+
case 0:
|
|
1664
|
+
case 1:
|
|
1665
|
+
t = op;
|
|
1666
|
+
break;
|
|
1667
|
+
case 4:
|
|
1668
|
+
_.label++;
|
|
1669
|
+
return {
|
|
1670
|
+
value: op[1],
|
|
1671
|
+
done: false
|
|
1672
|
+
};
|
|
1673
|
+
case 5:
|
|
1674
|
+
_.label++;
|
|
1675
|
+
y = op[1];
|
|
1676
|
+
op = [
|
|
1677
|
+
0
|
|
1678
|
+
];
|
|
1679
|
+
continue;
|
|
1680
|
+
case 7:
|
|
1681
|
+
op = _.ops.pop();
|
|
1682
|
+
_.trys.pop();
|
|
1683
|
+
continue;
|
|
1684
|
+
default:
|
|
1685
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1686
|
+
_ = 0;
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1690
|
+
_.label = op[1];
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1693
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1694
|
+
_.label = t[1];
|
|
1695
|
+
t = op;
|
|
1696
|
+
break;
|
|
1697
|
+
}
|
|
1698
|
+
if (t && _.label < t[2]) {
|
|
1699
|
+
_.label = t[2];
|
|
1700
|
+
_.ops.push(op);
|
|
1701
|
+
break;
|
|
1702
|
+
}
|
|
1703
|
+
if (t[2]) _.ops.pop();
|
|
1704
|
+
_.trys.pop();
|
|
1705
|
+
continue;
|
|
1706
|
+
}
|
|
1707
|
+
op = body.call(thisArg, _);
|
|
1708
|
+
} catch (e) {
|
|
1709
|
+
op = [
|
|
1710
|
+
6,
|
|
1711
|
+
e
|
|
1712
|
+
];
|
|
1713
|
+
y = 0;
|
|
1714
|
+
} finally{
|
|
1715
|
+
f = t = 0;
|
|
1716
|
+
}
|
|
1717
|
+
if (op[0] & 5) throw op[1];
|
|
1718
|
+
return {
|
|
1719
|
+
value: op[0] ? op[1] : void 0,
|
|
1720
|
+
done: true
|
|
460
1721
|
};
|
|
461
|
-
return nextPageResult;
|
|
462
|
-
};
|
|
463
1722
|
}
|
|
464
|
-
const page = {
|
|
465
|
-
input: initalInput,
|
|
466
|
-
fetchNext: cachedGetter(() => fetchNextWithInput(initalInput)())
|
|
467
|
-
};
|
|
468
|
-
return page;
|
|
469
|
-
};
|
|
470
1723
|
}
|
|
471
|
-
|
|
472
1724
|
/**
|
|
473
1725
|
* Iterates through the pages of a created FetchPage instance by each item individually.
|
|
474
1726
|
*
|
|
475
1727
|
* @param config
|
|
476
1728
|
* @returns
|
|
477
|
-
*/
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
1729
|
+
*/ function iterateFetchPagesByEachItem(config) {
|
|
1730
|
+
return _async_to_generator(function() {
|
|
1731
|
+
var iterateEachPageItem, iteratePerformTasksConfig;
|
|
1732
|
+
return _ts_generator(this, function(_state) {
|
|
1733
|
+
iterateEachPageItem = config.iterateEachPageItem, iteratePerformTasksConfig = config.iteratePerformTasksConfig;
|
|
1734
|
+
return [
|
|
1735
|
+
2,
|
|
1736
|
+
iterateFetchPagesByItems(_object_spread_props$1(_object_spread$1({}, config), {
|
|
1737
|
+
iteratePageItems: function iteratePageItems(items, fetchPageResult, startIndex) {
|
|
1738
|
+
return _async_to_generator(function() {
|
|
1739
|
+
var itemIndexPairs, performTasksResults;
|
|
1740
|
+
return _ts_generator(this, function(_state) {
|
|
1741
|
+
switch(_state.label){
|
|
1742
|
+
case 0:
|
|
1743
|
+
itemIndexPairs = items.map(function(x, i) {
|
|
1744
|
+
return [
|
|
1745
|
+
x,
|
|
1746
|
+
i + startIndex
|
|
1747
|
+
];
|
|
1748
|
+
});
|
|
1749
|
+
return [
|
|
1750
|
+
4,
|
|
1751
|
+
performAsyncTasks(itemIndexPairs, function(param) {
|
|
1752
|
+
var _param = _sliced_to_array$1(param, 2), item = _param[0], i = _param[1];
|
|
1753
|
+
return iterateEachPageItem(item, i, fetchPageResult);
|
|
1754
|
+
}, _object_spread$1({
|
|
1755
|
+
sequential: true
|
|
1756
|
+
}, iteratePerformTasksConfig))
|
|
1757
|
+
];
|
|
1758
|
+
case 1:
|
|
1759
|
+
performTasksResults = _state.sent();
|
|
1760
|
+
return [
|
|
1761
|
+
2,
|
|
1762
|
+
performTasksResults
|
|
1763
|
+
];
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
})();
|
|
1767
|
+
}
|
|
1768
|
+
}))
|
|
1769
|
+
];
|
|
1770
|
+
});
|
|
1771
|
+
})();
|
|
497
1772
|
}
|
|
498
1773
|
/**
|
|
499
1774
|
* Iterates through the pages of a created FetchPage instance.
|
|
500
1775
|
*
|
|
501
1776
|
* @param config
|
|
502
1777
|
* @returns
|
|
503
|
-
*/
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
1778
|
+
*/ function iterateFetchPagesByItems(config) {
|
|
1779
|
+
return _async_to_generator(function() {
|
|
1780
|
+
var readItemsFromPageResult, inputTotalIterateItemsLimit, inputTotalLoadItemLimit, inputFilterPageItems, iteratePageItems, iterateItemsLimit, loadItemLimit, filterPageItems, totalItemsLoaded, totalItemsVisited, hasReachedFinalItem, fetchPagesConfig, iterateFetchPagesResult;
|
|
1781
|
+
return _ts_generator(this, function(_state) {
|
|
1782
|
+
switch(_state.label){
|
|
1783
|
+
case 0:
|
|
1784
|
+
readItemsFromPageResult = config.readItemsFromPageResult, inputTotalIterateItemsLimit = config.iterateItemsLimit, inputTotalLoadItemLimit = config.loadItemLimit, inputFilterPageItems = config.filterPageItems, iteratePageItems = config.iteratePageItems;
|
|
1785
|
+
iterateItemsLimit = inputTotalIterateItemsLimit !== null && inputTotalIterateItemsLimit !== void 0 ? inputTotalIterateItemsLimit : Number.MAX_SAFE_INTEGER;
|
|
1786
|
+
loadItemLimit = inputTotalLoadItemLimit !== null && inputTotalLoadItemLimit !== void 0 ? inputTotalLoadItemLimit : Number.MAX_SAFE_INTEGER;
|
|
1787
|
+
filterPageItems = inputFilterPageItems !== null && inputFilterPageItems !== void 0 ? inputFilterPageItems : mapIdentityFunction();
|
|
1788
|
+
totalItemsLoaded = 0;
|
|
1789
|
+
totalItemsVisited = 0;
|
|
1790
|
+
hasReachedFinalItem = false;
|
|
1791
|
+
fetchPagesConfig = _object_spread_props$1(_object_spread$1({}, config), {
|
|
1792
|
+
iteratePage: function iteratePage(fetchPageResult) {
|
|
1793
|
+
return _async_to_generator(function() {
|
|
1794
|
+
var items, filteredItems, results;
|
|
1795
|
+
return _ts_generator(this, function(_state) {
|
|
1796
|
+
switch(_state.label){
|
|
1797
|
+
case 0:
|
|
1798
|
+
items = readItemsFromPageResult(fetchPageResult);
|
|
1799
|
+
return [
|
|
1800
|
+
4,
|
|
1801
|
+
filterPageItems(items, fetchPageResult)
|
|
1802
|
+
];
|
|
1803
|
+
case 1:
|
|
1804
|
+
filteredItems = _state.sent();
|
|
1805
|
+
return [
|
|
1806
|
+
4,
|
|
1807
|
+
iteratePageItems(filteredItems, fetchPageResult, totalItemsVisited)
|
|
1808
|
+
];
|
|
1809
|
+
case 2:
|
|
1810
|
+
results = _state.sent();
|
|
1811
|
+
totalItemsLoaded += items.length;
|
|
1812
|
+
totalItemsVisited += filteredItems.length;
|
|
1813
|
+
hasReachedFinalItem = totalItemsLoaded >= loadItemLimit || totalItemsVisited >= iterateItemsLimit;
|
|
1814
|
+
return [
|
|
1815
|
+
2,
|
|
1816
|
+
results
|
|
1817
|
+
];
|
|
1818
|
+
}
|
|
1819
|
+
});
|
|
1820
|
+
})();
|
|
1821
|
+
},
|
|
1822
|
+
endEarly: function endEarly() {
|
|
1823
|
+
return hasReachedFinalItem;
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
return [
|
|
1827
|
+
4,
|
|
1828
|
+
iterateFetchPages(fetchPagesConfig)
|
|
1829
|
+
];
|
|
1830
|
+
case 1:
|
|
1831
|
+
iterateFetchPagesResult = _state.sent();
|
|
1832
|
+
return [
|
|
1833
|
+
2,
|
|
1834
|
+
_object_spread_props$1(_object_spread$1({}, iterateFetchPagesResult), {
|
|
1835
|
+
totalItemsLoaded: totalItemsLoaded,
|
|
1836
|
+
totalItemsVisited: totalItemsVisited
|
|
1837
|
+
})
|
|
1838
|
+
];
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
})();
|
|
1842
|
+
}
|
|
1843
|
+
function iterateFetchPages(config) {
|
|
1844
|
+
return _async_to_generator(function() {
|
|
1845
|
+
var _ref, _ref1, iteratePage, inputFetchPage, input, fetchPageFactory, usePageResult, maxParallelPages, waitBetweenPages, maxPage, maxItemsPerPage, endEarly, hasReachedEnd, fetchPage, currentNextPage, performTaskFn, result;
|
|
1846
|
+
function taskInputFactory() {
|
|
1847
|
+
return _async_to_generator(function() {
|
|
1848
|
+
return _ts_generator(this, function(_state) {
|
|
1849
|
+
switch(_state.label){
|
|
1850
|
+
case 0:
|
|
1851
|
+
if (hasReachedEnd) {
|
|
1852
|
+
return [
|
|
1853
|
+
2,
|
|
1854
|
+
null
|
|
1855
|
+
]; // issue no more tasks
|
|
1856
|
+
}
|
|
1857
|
+
if (currentNextPage != null && (currentNextPage.isAtMaxPage || !currentNextPage.hasNext)) {
|
|
1858
|
+
hasReachedEnd = true;
|
|
1859
|
+
return [
|
|
1860
|
+
2,
|
|
1861
|
+
null
|
|
1862
|
+
];
|
|
1863
|
+
}
|
|
1864
|
+
return [
|
|
1865
|
+
4,
|
|
1866
|
+
fetchPage.fetchNext()
|
|
1867
|
+
];
|
|
1868
|
+
case 1:
|
|
1869
|
+
currentNextPage = _state.sent();
|
|
1870
|
+
fetchPage = currentNextPage;
|
|
1871
|
+
return [
|
|
1872
|
+
2,
|
|
1873
|
+
{
|
|
1874
|
+
i: currentNextPage.page,
|
|
1875
|
+
fetchPageResult: currentNextPage
|
|
1876
|
+
}
|
|
1877
|
+
];
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1880
|
+
})();
|
|
1881
|
+
}
|
|
1882
|
+
return _ts_generator(this, function(_state) {
|
|
1883
|
+
switch(_state.label){
|
|
1884
|
+
case 0:
|
|
1885
|
+
iteratePage = config.iteratePage, inputFetchPage = config.fetchPage, input = config.input, fetchPageFactory = config.fetchPageFactory, usePageResult = config.usePageResult, maxParallelPages = config.maxParallelPages, waitBetweenPages = config.waitBetweenPages, maxPage = config.maxPage, maxItemsPerPage = config.maxItemsPerPage, endEarly = config.endEarly;
|
|
1886
|
+
hasReachedEnd = false;
|
|
1887
|
+
fetchPage = inputFetchPage !== null && inputFetchPage !== void 0 ? inputFetchPage : fetchPageFactory(input, {
|
|
1888
|
+
maxPage: maxPage,
|
|
1889
|
+
maxItemsPerPage: maxItemsPerPage
|
|
1890
|
+
});
|
|
1891
|
+
performTaskFn = performTasksFromFactoryInParallelFunction({
|
|
1892
|
+
maxParallelTasks: maxParallelPages,
|
|
1893
|
+
waitBetweenTasks: waitBetweenPages,
|
|
1894
|
+
taskFactory: function taskFactory(param) {
|
|
1895
|
+
var i = param.i, fetchPageResult = param.fetchPageResult;
|
|
1896
|
+
return _async_to_generator(function() {
|
|
1897
|
+
var result, iterationResult, shouldEndEarly;
|
|
1898
|
+
return _ts_generator(this, function(_state) {
|
|
1899
|
+
switch(_state.label){
|
|
1900
|
+
case 0:
|
|
1901
|
+
return [
|
|
1902
|
+
4,
|
|
1903
|
+
iteratePage(fetchPageResult)
|
|
1904
|
+
];
|
|
1905
|
+
case 1:
|
|
1906
|
+
result = _state.sent();
|
|
1907
|
+
iterationResult = {
|
|
1908
|
+
i: i,
|
|
1909
|
+
fetchPageResult: fetchPageResult,
|
|
1910
|
+
result: result
|
|
1911
|
+
};
|
|
1912
|
+
return [
|
|
1913
|
+
4,
|
|
1914
|
+
usePageResult === null || usePageResult === void 0 ? void 0 : usePageResult(iterationResult)
|
|
1915
|
+
];
|
|
1916
|
+
case 2:
|
|
1917
|
+
_state.sent();
|
|
1918
|
+
shouldEndEarly = endEarly === null || endEarly === void 0 ? void 0 : endEarly(iterationResult);
|
|
1919
|
+
if (shouldEndEarly) {
|
|
1920
|
+
hasReachedEnd = true;
|
|
1921
|
+
}
|
|
1922
|
+
return [
|
|
1923
|
+
2
|
|
1924
|
+
];
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
})();
|
|
1928
|
+
}
|
|
1929
|
+
});
|
|
1930
|
+
return [
|
|
1931
|
+
4,
|
|
1932
|
+
performTaskFn(taskInputFactory)
|
|
1933
|
+
];
|
|
1934
|
+
case 1:
|
|
1935
|
+
_state.sent();
|
|
1936
|
+
result = {
|
|
1937
|
+
totalPages: ((_ref = currentNextPage === null || currentNextPage === void 0 ? void 0 : currentNextPage.page) !== null && _ref !== void 0 ? _ref : 0) + 1,
|
|
1938
|
+
totalPagesLimitReached: (_ref1 = currentNextPage === null || currentNextPage === void 0 ? void 0 : currentNextPage.isAtMaxPage) !== null && _ref1 !== void 0 ? _ref1 : false
|
|
1939
|
+
};
|
|
1940
|
+
return [
|
|
1941
|
+
2,
|
|
1942
|
+
result
|
|
1943
|
+
];
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
})();
|
|
598
1947
|
}
|
|
599
1948
|
|
|
600
1949
|
/**
|
|
@@ -603,209 +1952,429 @@ async function iterateFetchPages(config) {
|
|
|
603
1952
|
* @param input
|
|
604
1953
|
* @param omitKeys
|
|
605
1954
|
* @returns
|
|
606
|
-
*/
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
return searchParams;
|
|
1955
|
+
*/ function makeUrlSearchParams(input, options) {
|
|
1956
|
+
var _ref = options !== null && options !== void 0 ? options : {}, omitKeys = _ref.omitKeys, filterValues = _ref.filterEmptyValues;
|
|
1957
|
+
var mergedInput = Array.isArray(input) ? mergeObjects(input) : input;
|
|
1958
|
+
var filteredInput = (filterValues !== null && filterValues !== void 0 ? filterValues : true) ? filterEmptyPojoValues(mergedInput !== null && mergedInput !== void 0 ? mergedInput : {}) : mergedInput;
|
|
1959
|
+
var searchParams = new URLSearchParams(filteredInput);
|
|
1960
|
+
if (omitKeys != null) {
|
|
1961
|
+
useIterableOrValue(omitKeys, function(key) {
|
|
1962
|
+
return searchParams.delete(key);
|
|
1963
|
+
}, false);
|
|
1964
|
+
}
|
|
1965
|
+
return searchParams;
|
|
619
1966
|
}
|
|
620
1967
|
/**
|
|
621
1968
|
* Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
|
|
622
|
-
*/
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
1969
|
+
*/ function mergeMakeUrlSearchParamsOptions(options) {
|
|
1970
|
+
var omitKeys = new Set();
|
|
1971
|
+
useIterableOrValue(options, function(x) {
|
|
1972
|
+
if ((x === null || x === void 0 ? void 0 : x.omitKeys) != null) {
|
|
1973
|
+
useIterableOrValue(x.omitKeys, function(key) {
|
|
1974
|
+
return omitKeys.add(key);
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
return {
|
|
1979
|
+
omitKeys: omitKeys.size > 0 ? Array.from(omitKeys) : undefined
|
|
1980
|
+
};
|
|
633
1981
|
}
|
|
634
1982
|
|
|
1983
|
+
function _array_like_to_array(arr, len) {
|
|
1984
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1985
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1986
|
+
return arr2;
|
|
1987
|
+
}
|
|
1988
|
+
function _array_with_holes(arr) {
|
|
1989
|
+
if (Array.isArray(arr)) return arr;
|
|
1990
|
+
}
|
|
1991
|
+
function _instanceof(left, right) {
|
|
1992
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1993
|
+
return !!right[Symbol.hasInstance](left);
|
|
1994
|
+
} else {
|
|
1995
|
+
return left instanceof right;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
function _iterable_to_array_limit(arr, i) {
|
|
1999
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2000
|
+
if (_i == null) return;
|
|
2001
|
+
var _arr = [];
|
|
2002
|
+
var _n = true;
|
|
2003
|
+
var _d = false;
|
|
2004
|
+
var _s, _e;
|
|
2005
|
+
try {
|
|
2006
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
2007
|
+
_arr.push(_s.value);
|
|
2008
|
+
if (i && _arr.length === i) break;
|
|
2009
|
+
}
|
|
2010
|
+
} catch (err) {
|
|
2011
|
+
_d = true;
|
|
2012
|
+
_e = err;
|
|
2013
|
+
} finally{
|
|
2014
|
+
try {
|
|
2015
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
2016
|
+
} finally{
|
|
2017
|
+
if (_d) throw _e;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
return _arr;
|
|
2021
|
+
}
|
|
2022
|
+
function _non_iterable_rest() {
|
|
2023
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2024
|
+
}
|
|
2025
|
+
function _sliced_to_array(arr, i) {
|
|
2026
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
2027
|
+
}
|
|
2028
|
+
function _type_of$1(obj) {
|
|
2029
|
+
"@swc/helpers - typeof";
|
|
2030
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
2031
|
+
}
|
|
2032
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
2033
|
+
if (!o) return;
|
|
2034
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
2035
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2036
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2037
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2038
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
2039
|
+
}
|
|
635
2040
|
function fetchURL(input) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
} else {
|
|
642
|
-
const baseUrl = fetchURL(input.url);
|
|
643
|
-
if (input.queryParams) {
|
|
644
|
-
const searchParams = queryParamsToSearchParams(input.queryParams);
|
|
645
|
-
if (!isEmptyIterable(searchParams)) {
|
|
646
|
-
url = fixExtraQueryParameters(baseUrl + `?${searchParams.toString()}`);
|
|
647
|
-
} else {
|
|
648
|
-
url = baseUrl;
|
|
649
|
-
}
|
|
2041
|
+
var url;
|
|
2042
|
+
if (typeof input === 'string') {
|
|
2043
|
+
url = input;
|
|
2044
|
+
} else if (isURL(input)) {
|
|
2045
|
+
url = input.href;
|
|
650
2046
|
} else {
|
|
651
|
-
|
|
2047
|
+
var baseUrl = fetchURL(input.url);
|
|
2048
|
+
if (input.queryParams) {
|
|
2049
|
+
var searchParams = queryParamsToSearchParams(input.queryParams);
|
|
2050
|
+
if (!isEmptyIterable(searchParams)) {
|
|
2051
|
+
url = fixExtraQueryParameters(baseUrl + "?".concat(searchParams.toString()));
|
|
2052
|
+
} else {
|
|
2053
|
+
url = baseUrl;
|
|
2054
|
+
}
|
|
2055
|
+
} else {
|
|
2056
|
+
url = baseUrl;
|
|
2057
|
+
}
|
|
652
2058
|
}
|
|
653
|
-
|
|
654
|
-
return url;
|
|
2059
|
+
return url;
|
|
655
2060
|
}
|
|
656
2061
|
function isURL(input) {
|
|
657
|
-
|
|
2062
|
+
return (typeof input === "undefined" ? "undefined" : _type_of$1(input)) === 'object' && _instanceof(input, URL);
|
|
658
2063
|
}
|
|
659
2064
|
function isURLSearchParams(input) {
|
|
660
|
-
|
|
2065
|
+
return (typeof input === "undefined" ? "undefined" : _type_of$1(input)) === 'object' && _instanceof(input, URLSearchParams);
|
|
661
2066
|
}
|
|
662
2067
|
/**
|
|
663
2068
|
* Converts the input
|
|
664
2069
|
*
|
|
665
2070
|
* @param input
|
|
666
2071
|
* @returns
|
|
667
|
-
*/
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
2072
|
+
*/ function fetchURLQueryKeyValueStringTuples(input) {
|
|
2073
|
+
var paramTuples = [];
|
|
2074
|
+
forEachInIterable(input, function(tuple) {
|
|
2075
|
+
var _tuple = _sliced_to_array(tuple, 2), key = _tuple[0], values = _tuple[1];
|
|
2076
|
+
// ignore null/undefined keys and values
|
|
2077
|
+
if (key != null && values != null) {
|
|
2078
|
+
var keyString = String(key);
|
|
2079
|
+
useIterableOrValue(values, function(value) {
|
|
2080
|
+
// ignore null/undefined values
|
|
2081
|
+
if (value != null) {
|
|
2082
|
+
paramTuples.push([
|
|
2083
|
+
keyString,
|
|
2084
|
+
String(value)
|
|
2085
|
+
]);
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
});
|
|
2090
|
+
return paramTuples;
|
|
684
2091
|
}
|
|
685
2092
|
function queryParamsToSearchParams(input) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
2093
|
+
var result;
|
|
2094
|
+
if (isURLSearchParams(input)) {
|
|
2095
|
+
// by url search params
|
|
2096
|
+
result = input;
|
|
2097
|
+
} else if (typeof input === 'string') {
|
|
2098
|
+
result = new URLSearchParams(input);
|
|
2099
|
+
} else if (isIterable(input)) {
|
|
2100
|
+
// By tuples
|
|
2101
|
+
result = new URLSearchParams(fetchURLQueryKeyValueStringTuples(input));
|
|
2102
|
+
} else {
|
|
2103
|
+
result = fetchURLSearchParamsObjectToURLSearchParams(input);
|
|
2104
|
+
}
|
|
2105
|
+
return result;
|
|
699
2106
|
}
|
|
700
2107
|
function fetchURLSearchParamsObjectToURLSearchParams(input) {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
2108
|
+
var paramTuples = [];
|
|
2109
|
+
forEachKeyValue(input, {
|
|
2110
|
+
forEach: function forEach(tuple) {
|
|
2111
|
+
var _tuple = _sliced_to_array(tuple, 2), key = _tuple[0], values = _tuple[1];
|
|
2112
|
+
// ignore null/undefined keys and values
|
|
2113
|
+
if (key != null && values != null) {
|
|
2114
|
+
var keyString = String(key);
|
|
2115
|
+
useIterableOrValue(values, function(x) {
|
|
2116
|
+
// ignore null/undefined values
|
|
2117
|
+
if (x != null) {
|
|
2118
|
+
paramTuples.push([
|
|
2119
|
+
keyString,
|
|
2120
|
+
String(x)
|
|
2121
|
+
]);
|
|
2122
|
+
}
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
});
|
|
2127
|
+
return new URLSearchParams(paramTuples);
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
function _assert_this_initialized(self) {
|
|
2131
|
+
if (self === void 0) {
|
|
2132
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2133
|
+
}
|
|
2134
|
+
return self;
|
|
2135
|
+
}
|
|
2136
|
+
function _call_super(_this, derived, args) {
|
|
2137
|
+
derived = _get_prototype_of(derived);
|
|
2138
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
2139
|
+
}
|
|
2140
|
+
function _class_call_check(instance, Constructor) {
|
|
2141
|
+
if (!(instance instanceof Constructor)) {
|
|
2142
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
function _construct(Parent, args, Class) {
|
|
2146
|
+
if (_is_native_reflect_construct()) {
|
|
2147
|
+
_construct = Reflect.construct;
|
|
2148
|
+
} else {
|
|
2149
|
+
_construct = function construct(Parent, args, Class) {
|
|
2150
|
+
var a = [
|
|
2151
|
+
null
|
|
2152
|
+
];
|
|
2153
|
+
a.push.apply(a, args);
|
|
2154
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
2155
|
+
var instance = new Constructor();
|
|
2156
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
2157
|
+
return instance;
|
|
2158
|
+
};
|
|
2159
|
+
}
|
|
2160
|
+
return _construct.apply(null, arguments);
|
|
2161
|
+
}
|
|
2162
|
+
function _define_property(obj, key, value) {
|
|
2163
|
+
if (key in obj) {
|
|
2164
|
+
Object.defineProperty(obj, key, {
|
|
2165
|
+
value: value,
|
|
2166
|
+
enumerable: true,
|
|
2167
|
+
configurable: true,
|
|
2168
|
+
writable: true
|
|
2169
|
+
});
|
|
2170
|
+
} else {
|
|
2171
|
+
obj[key] = value;
|
|
2172
|
+
}
|
|
2173
|
+
return obj;
|
|
2174
|
+
}
|
|
2175
|
+
function _get_prototype_of(o) {
|
|
2176
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
2177
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
2178
|
+
};
|
|
2179
|
+
return _get_prototype_of(o);
|
|
2180
|
+
}
|
|
2181
|
+
function _inherits(subClass, superClass) {
|
|
2182
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
2183
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
2184
|
+
}
|
|
2185
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
2186
|
+
constructor: {
|
|
2187
|
+
value: subClass,
|
|
2188
|
+
writable: true,
|
|
2189
|
+
configurable: true
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
2193
|
+
}
|
|
2194
|
+
function _is_native_function(fn) {
|
|
2195
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
2196
|
+
}
|
|
2197
|
+
function _object_spread(target) {
|
|
2198
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2199
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2200
|
+
var ownKeys = Object.keys(source);
|
|
2201
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
2202
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
2203
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
2204
|
+
}));
|
|
2205
|
+
}
|
|
2206
|
+
ownKeys.forEach(function(key) {
|
|
2207
|
+
_define_property(target, key, source[key]);
|
|
713
2208
|
});
|
|
714
|
-
}
|
|
715
2209
|
}
|
|
716
|
-
|
|
717
|
-
return new URLSearchParams(paramTuples);
|
|
2210
|
+
return target;
|
|
718
2211
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
2212
|
+
function ownKeys(object, enumerableOnly) {
|
|
2213
|
+
var keys = Object.keys(object);
|
|
2214
|
+
if (Object.getOwnPropertySymbols) {
|
|
2215
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
2216
|
+
keys.push.apply(keys, symbols);
|
|
2217
|
+
}
|
|
2218
|
+
return keys;
|
|
2219
|
+
}
|
|
2220
|
+
function _object_spread_props(target, source) {
|
|
2221
|
+
source = source != null ? source : {};
|
|
2222
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
2223
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
2224
|
+
} else {
|
|
2225
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
2226
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
return target;
|
|
2230
|
+
}
|
|
2231
|
+
function _possible_constructor_return(self, call) {
|
|
2232
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
2233
|
+
return call;
|
|
2234
|
+
}
|
|
2235
|
+
return _assert_this_initialized(self);
|
|
2236
|
+
}
|
|
2237
|
+
function _set_prototype_of(o, p) {
|
|
2238
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
2239
|
+
o.__proto__ = p;
|
|
2240
|
+
return o;
|
|
2241
|
+
};
|
|
2242
|
+
return _set_prototype_of(o, p);
|
|
2243
|
+
}
|
|
2244
|
+
function _type_of(obj) {
|
|
2245
|
+
"@swc/helpers - typeof";
|
|
2246
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
726
2247
|
}
|
|
2248
|
+
function _wrap_native_super(Class) {
|
|
2249
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
2250
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
2251
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
2252
|
+
if (typeof Class !== "function") {
|
|
2253
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
2254
|
+
}
|
|
2255
|
+
if (typeof _cache !== "undefined") {
|
|
2256
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
2257
|
+
_cache.set(Class, Wrapper);
|
|
2258
|
+
}
|
|
2259
|
+
function Wrapper() {
|
|
2260
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
2261
|
+
}
|
|
2262
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
2263
|
+
constructor: {
|
|
2264
|
+
value: Wrapper,
|
|
2265
|
+
enumerable: false,
|
|
2266
|
+
writable: true,
|
|
2267
|
+
configurable: true
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2270
|
+
return _set_prototype_of(Wrapper, Class);
|
|
2271
|
+
};
|
|
2272
|
+
return _wrap_native_super(Class);
|
|
2273
|
+
}
|
|
2274
|
+
function _is_native_reflect_construct() {
|
|
2275
|
+
try {
|
|
2276
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
2277
|
+
} catch (_) {}
|
|
2278
|
+
return (_is_native_reflect_construct = function() {
|
|
2279
|
+
return !!result;
|
|
2280
|
+
})();
|
|
2281
|
+
}
|
|
2282
|
+
var JsonResponseParseError = /*#__PURE__*/ function(Error1) {
|
|
2283
|
+
_inherits(JsonResponseParseError, Error1);
|
|
2284
|
+
function JsonResponseParseError(response) {
|
|
2285
|
+
_class_call_check(this, JsonResponseParseError);
|
|
2286
|
+
var _this;
|
|
2287
|
+
_this = _call_super(this, JsonResponseParseError, [
|
|
2288
|
+
'Failed to parse the JSON body.'
|
|
2289
|
+
]), _define_property(_this, "response", void 0);
|
|
2290
|
+
_this.response = response;
|
|
2291
|
+
return _this;
|
|
2292
|
+
}
|
|
2293
|
+
return JsonResponseParseError;
|
|
2294
|
+
}(_wrap_native_super(Error));
|
|
727
2295
|
/**
|
|
728
2296
|
* Converts the input to a JSON string, or undefined if not provided.
|
|
729
2297
|
*
|
|
730
2298
|
* @param body
|
|
731
2299
|
* @returns
|
|
732
|
-
*/
|
|
733
|
-
|
|
734
|
-
return body != null ? typeof body === 'string' ? body : JSON.stringify(body) : undefined;
|
|
2300
|
+
*/ function fetchJsonBodyString(body) {
|
|
2301
|
+
return body != null ? typeof body === 'string' ? body : JSON.stringify(body) : undefined;
|
|
735
2302
|
}
|
|
736
|
-
|
|
737
|
-
|
|
2303
|
+
var throwJsonResponseParseErrorFunction = function throwJsonResponseParseErrorFunction(response) {
|
|
2304
|
+
throw new JsonResponseParseError(response);
|
|
2305
|
+
};
|
|
2306
|
+
var returnNullHandleFetchJsonParseErrorFunction = function returnNullHandleFetchJsonParseErrorFunction(_) {
|
|
2307
|
+
return null;
|
|
738
2308
|
};
|
|
739
|
-
const returnNullHandleFetchJsonParseErrorFunction = _ => null;
|
|
740
2309
|
/**
|
|
741
2310
|
* Creates a FetchJsonFunction from the input ConfiguredFetch.
|
|
742
|
-
*/
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
} else {
|
|
750
|
-
config = inputConfig ?? {};
|
|
751
|
-
}
|
|
752
|
-
config = {
|
|
753
|
-
...config,
|
|
754
|
-
handleFetchJsonParseErrorFunction: config.handleFetchJsonParseErrorFunction ?? throwJsonResponseParseErrorFunction
|
|
755
|
-
};
|
|
756
|
-
const {
|
|
757
|
-
handleFetchJsonParseErrorFunction,
|
|
758
|
-
interceptJsonResponse
|
|
759
|
-
} = config;
|
|
760
|
-
const configuredFetchJsonRequestInit = fetchJsonRequestInitFunction(config);
|
|
761
|
-
return (url, methodOrInput, body) => {
|
|
762
|
-
const requestUrl = fetchURL(url);
|
|
763
|
-
const requestInit = configuredFetchJsonRequestInit(methodOrInput, body);
|
|
764
|
-
const inputIntercept = typeof methodOrInput === 'object' ? methodOrInput.interceptResponse : undefined;
|
|
765
|
-
const responsePromise = fetch(requestUrl, requestInit);
|
|
766
|
-
return responsePromise.then(response => {
|
|
767
|
-
const jsonPromise = response.json().catch(handleFetchJsonParseErrorFunction);
|
|
768
|
-
const interceptedJsonResponsePromise = interceptJsonResponse ? jsonPromise.then(json => interceptJsonResponse(json, response)) : jsonPromise;
|
|
769
|
-
return inputIntercept ? interceptedJsonResponsePromise.then(result => inputIntercept(result, response)) : interceptedJsonResponsePromise;
|
|
770
|
-
});
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
function fetchJsonRequestInitFunction(config = {}) {
|
|
774
|
-
const {
|
|
775
|
-
defaultMethod = 'GET',
|
|
776
|
-
mapFetchJsonInput = mapIdentityFunction()
|
|
777
|
-
} = config;
|
|
778
|
-
return (methodOrInput = defaultMethod, body) => {
|
|
779
|
-
let config;
|
|
780
|
-
if (methodOrInput === null) {
|
|
781
|
-
config = {
|
|
782
|
-
method: defaultMethod
|
|
783
|
-
};
|
|
784
|
-
} else if (typeof methodOrInput === 'string') {
|
|
785
|
-
config = {
|
|
786
|
-
method: methodOrInput,
|
|
787
|
-
body
|
|
788
|
-
};
|
|
2311
|
+
*/ function fetchJsonFunction(fetch, inputConfig) {
|
|
2312
|
+
var _config_handleFetchJsonParseErrorFunction;
|
|
2313
|
+
var config;
|
|
2314
|
+
if (typeof inputConfig === 'function') {
|
|
2315
|
+
config = {
|
|
2316
|
+
handleFetchJsonParseErrorFunction: inputConfig
|
|
2317
|
+
};
|
|
789
2318
|
} else {
|
|
790
|
-
|
|
2319
|
+
config = inputConfig !== null && inputConfig !== void 0 ? inputConfig : {};
|
|
791
2320
|
}
|
|
792
|
-
config =
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
2321
|
+
config = _object_spread_props(_object_spread({}, config), {
|
|
2322
|
+
handleFetchJsonParseErrorFunction: (_config_handleFetchJsonParseErrorFunction = config.handleFetchJsonParseErrorFunction) !== null && _config_handleFetchJsonParseErrorFunction !== void 0 ? _config_handleFetchJsonParseErrorFunction : throwJsonResponseParseErrorFunction
|
|
2323
|
+
});
|
|
2324
|
+
var handleFetchJsonParseErrorFunction = config.handleFetchJsonParseErrorFunction, interceptJsonResponse = config.interceptJsonResponse;
|
|
2325
|
+
var configuredFetchJsonRequestInit = fetchJsonRequestInitFunction(config);
|
|
2326
|
+
return function(url, methodOrInput, body) {
|
|
2327
|
+
var requestUrl = fetchURL(url);
|
|
2328
|
+
var requestInit = configuredFetchJsonRequestInit(methodOrInput, body);
|
|
2329
|
+
var inputIntercept = (typeof methodOrInput === "undefined" ? "undefined" : _type_of(methodOrInput)) === 'object' ? methodOrInput.interceptResponse : undefined;
|
|
2330
|
+
var responsePromise = fetch(requestUrl, requestInit);
|
|
2331
|
+
return responsePromise.then(function(response) {
|
|
2332
|
+
var jsonPromise = response.json().catch(handleFetchJsonParseErrorFunction);
|
|
2333
|
+
var interceptedJsonResponsePromise = interceptJsonResponse ? jsonPromise.then(function(json) {
|
|
2334
|
+
return interceptJsonResponse(json, response);
|
|
2335
|
+
}) : jsonPromise;
|
|
2336
|
+
return inputIntercept ? interceptedJsonResponsePromise.then(function(result) {
|
|
2337
|
+
return inputIntercept(result, response);
|
|
2338
|
+
}) : interceptedJsonResponsePromise;
|
|
2339
|
+
});
|
|
797
2340
|
};
|
|
798
|
-
return requestInit;
|
|
799
|
-
};
|
|
800
2341
|
}
|
|
801
|
-
|
|
2342
|
+
function fetchJsonRequestInitFunction() {
|
|
2343
|
+
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2344
|
+
var _config_defaultMethod = config.defaultMethod, defaultMethod = _config_defaultMethod === void 0 ? 'GET' : _config_defaultMethod, _config_mapFetchJsonInput = config.mapFetchJsonInput, mapFetchJsonInput = _config_mapFetchJsonInput === void 0 ? mapIdentityFunction() : _config_mapFetchJsonInput;
|
|
2345
|
+
return function() {
|
|
2346
|
+
var methodOrInput = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultMethod, body = arguments.length > 1 ? arguments[1] : void 0;
|
|
2347
|
+
var _config_method;
|
|
2348
|
+
var config;
|
|
2349
|
+
if (methodOrInput === null) {
|
|
2350
|
+
config = {
|
|
2351
|
+
method: defaultMethod
|
|
2352
|
+
};
|
|
2353
|
+
} else if (typeof methodOrInput === 'string') {
|
|
2354
|
+
config = {
|
|
2355
|
+
method: methodOrInput,
|
|
2356
|
+
body: body
|
|
2357
|
+
};
|
|
2358
|
+
} else {
|
|
2359
|
+
config = methodOrInput;
|
|
2360
|
+
}
|
|
2361
|
+
config = mapFetchJsonInput(config);
|
|
2362
|
+
var requestInit = _object_spread_props(_object_spread({}, config), {
|
|
2363
|
+
method: (_config_method = config.method) !== null && _config_method !== void 0 ? _config_method : defaultMethod,
|
|
2364
|
+
body: fetchJsonBodyString(config.body)
|
|
2365
|
+
});
|
|
2366
|
+
return requestInit;
|
|
2367
|
+
};
|
|
2368
|
+
}
|
|
2369
|
+
var fetchJsonRequestInit = fetchJsonRequestInitFunction();
|
|
802
2370
|
|
|
803
2371
|
/**
|
|
804
2372
|
* Default FetchService implementation that uses the native Fetch api.
|
|
805
|
-
*/
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
2373
|
+
*/ var fetchApiFetchService = fetchService({
|
|
2374
|
+
makeFetch: fetch,
|
|
2375
|
+
makeRequest: function makeRequest(x, y) {
|
|
2376
|
+
return new Request(x, y);
|
|
2377
|
+
}
|
|
809
2378
|
});
|
|
810
2379
|
|
|
811
2380
|
export { DEFAULT_FETCH_HANDLER, DEFAULT_FETCH_REQUEST_FACTORY, FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE, FetchPageLimitReachedError, FetchPageNoNextPageError, FetchRequestFactoryError, FetchResponseError, FetchTimeoutError, JsonResponseParseError, configureFetch, fetchApiFetchService, fetchJsonBodyString, fetchJsonFunction, fetchJsonRequestInit, fetchJsonRequestInitFunction, fetchOk, fetchPageFactory, fetchRequestFactory, fetchService, fetchTimeout, fetchURL, fetchURLQueryKeyValueStringTuples, fetchURLSearchParamsObjectToURLSearchParams, fetchUploadFile, headersToHeadersTuple, isFetchRequest, isURL, isURLSearchParams, iterateFetchPages, iterateFetchPagesByEachItem, iterateFetchPagesByItems, makeUrlSearchParams, mergeMakeUrlSearchParamsOptions, mergeRequestHeaders, mergeRequestInits, parseFetchFileResponse, queryParamsToSearchParams, rateLimitedFetchHandler, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction };
|