@ama-sdk/client-fetch 11.3.0-prerelease.33
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/LICENSE +26 -0
- package/README.md +33 -0
- package/cjs/api-fetch-client.js +581 -0
- package/cjs/fetch-plugin.js +4 -0
- package/cjs/plugins/abort/abort.fetch.js +84 -0
- package/cjs/plugins/abort/abort.spec.js +204 -0
- package/cjs/plugins/abort/index.js +18 -0
- package/cjs/plugins/concurrent/concurrent.fetch.js +263 -0
- package/cjs/plugins/concurrent/concurrent.spec.js +239 -0
- package/cjs/plugins/concurrent/index.js +18 -0
- package/cjs/plugins/index.js +25 -0
- package/cjs/plugins/keepalive/index.js +18 -0
- package/cjs/plugins/keepalive/keepalive.request.js +289 -0
- package/cjs/plugins/keepalive/keepalive.spec.js +162 -0
- package/cjs/plugins/mock-intercept/index.js +19 -0
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +288 -0
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +4 -0
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +445 -0
- package/cjs/plugins/perf-metric/index.js +18 -0
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +371 -0
- package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +60 -0
- package/cjs/plugins/retry/index.js +18 -0
- package/cjs/plugins/retry/retry.fetch.js +371 -0
- package/cjs/plugins/retry/retry.spec.js +348 -0
- package/cjs/plugins/timeout/index.js +18 -0
- package/cjs/plugins/timeout/timeout.fetch.js +320 -0
- package/cjs/plugins/timeout/timeout.spec.js +443 -0
- package/cjs/plugins/wait-for/index.js +18 -0
- package/cjs/plugins/wait-for/wait-for.fetch.js +350 -0
- package/cjs/plugins/wait-for/wait-for.spec.js +383 -0
- package/cjs/public_api.js +20 -0
- package/collection.json +11 -0
- package/esm2015/api-fetch-client.js +571 -0
- package/esm2015/fetch-plugin.js +4 -0
- package/esm2015/plugins/abort/abort.fetch.js +74 -0
- package/esm2015/plugins/abort/abort.spec.js +200 -0
- package/esm2015/plugins/abort/index.js +1 -0
- package/esm2015/plugins/concurrent/concurrent.fetch.js +255 -0
- package/esm2015/plugins/concurrent/concurrent.spec.js +235 -0
- package/esm2015/plugins/concurrent/index.js +1 -0
- package/esm2015/plugins/index.js +8 -0
- package/esm2015/plugins/keepalive/index.js +1 -0
- package/esm2015/plugins/keepalive/keepalive.request.js +281 -0
- package/esm2015/plugins/keepalive/keepalive.spec.js +158 -0
- package/esm2015/plugins/mock-intercept/index.js +2 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +283 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +1 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +441 -0
- package/esm2015/plugins/perf-metric/index.js +1 -0
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +363 -0
- package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +56 -0
- package/esm2015/plugins/retry/index.js +1 -0
- package/esm2015/plugins/retry/retry.fetch.js +363 -0
- package/esm2015/plugins/retry/retry.spec.js +344 -0
- package/esm2015/plugins/timeout/index.js +1 -0
- package/esm2015/plugins/timeout/timeout.fetch.js +310 -0
- package/esm2015/plugins/timeout/timeout.spec.js +439 -0
- package/esm2015/plugins/wait-for/index.js +1 -0
- package/esm2015/plugins/wait-for/wait-for.fetch.js +379 -0
- package/esm2015/plugins/wait-for/wait-for.spec.js +379 -0
- package/esm2015/public_api.js +3 -0
- package/package.json +196 -0
- package/schematics/ng-add/index.d.ts +8 -0
- package/schematics/ng-add/index.d.ts.map +1 -0
- package/schematics/ng-add/index.js +67 -0
- package/schematics/ng-add/migration/import-map.d.ts +6 -0
- package/schematics/ng-add/migration/import-map.d.ts.map +1 -0
- package/schematics/ng-add/migration/import-map.js +39 -0
- package/schematics/ng-add/schema.d.ts +6 -0
- package/schematics/ng-add/schema.d.ts.map +1 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.json +18 -0
- package/schematics/package.json +3 -0
- package/src/api-fetch-client.d.ts +46 -0
- package/src/api-fetch-client.d.ts.map +1 -0
- package/src/api-fetch-client.js +126 -0
- package/src/api-fetch-client.js.map +1 -0
- package/src/fetch-plugin.d.ts +38 -0
- package/src/fetch-plugin.d.ts.map +1 -0
- package/src/fetch-plugin.js +2 -0
- package/src/fetch-plugin.js.map +1 -0
- package/src/plugins/abort/abort.fetch.d.ts +66 -0
- package/src/plugins/abort/abort.fetch.d.ts.map +1 -0
- package/src/plugins/abort/abort.fetch.js +32 -0
- package/src/plugins/abort/abort.fetch.js.map +1 -0
- package/src/plugins/abort/index.d.ts +2 -0
- package/src/plugins/abort/index.d.ts.map +1 -0
- package/src/plugins/abort/index.js +2 -0
- package/src/plugins/abort/index.js.map +1 -0
- package/src/plugins/concurrent/concurrent.fetch.d.ts +33 -0
- package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -0
- package/src/plugins/concurrent/concurrent.fetch.js +57 -0
- package/src/plugins/concurrent/concurrent.fetch.js.map +1 -0
- package/src/plugins/concurrent/index.d.ts +2 -0
- package/src/plugins/concurrent/index.d.ts.map +1 -0
- package/src/plugins/concurrent/index.js +2 -0
- package/src/plugins/concurrent/index.js.map +1 -0
- package/src/plugins/index.d.ts +9 -0
- package/src/plugins/index.d.ts.map +1 -0
- package/src/plugins/index.js +9 -0
- package/src/plugins/index.js.map +1 -0
- package/src/plugins/keepalive/index.d.ts +2 -0
- package/src/plugins/keepalive/index.d.ts.map +1 -0
- package/src/plugins/keepalive/index.js +2 -0
- package/src/plugins/keepalive/index.js.map +1 -0
- package/src/plugins/keepalive/keepalive.request.d.ts +18 -0
- package/src/plugins/keepalive/keepalive.request.d.ts.map +1 -0
- package/src/plugins/keepalive/keepalive.request.js +39 -0
- package/src/plugins/keepalive/keepalive.request.js.map +1 -0
- package/src/plugins/mock-intercept/index.d.ts +3 -0
- package/src/plugins/mock-intercept/index.d.ts.map +1 -0
- package/src/plugins/mock-intercept/index.js +3 -0
- package/src/plugins/mock-intercept/index.js.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts +15 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.js +47 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts +10 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.js +2 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.js.map +1 -0
- package/src/plugins/perf-metric/index.d.ts +2 -0
- package/src/plugins/perf-metric/index.d.ts.map +1 -0
- package/src/plugins/perf-metric/index.js +2 -0
- package/src/plugins/perf-metric/index.js.map +1 -0
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts +133 -0
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts.map +1 -0
- package/src/plugins/perf-metric/perf-metric.fetch.js +111 -0
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -0
- package/src/plugins/retry/index.d.ts +2 -0
- package/src/plugins/retry/index.d.ts.map +1 -0
- package/src/plugins/retry/index.js +2 -0
- package/src/plugins/retry/index.js.map +1 -0
- package/src/plugins/retry/retry.fetch.d.ts +53 -0
- package/src/plugins/retry/retry.fetch.d.ts.map +1 -0
- package/src/plugins/retry/retry.fetch.js +66 -0
- package/src/plugins/retry/retry.fetch.js.map +1 -0
- package/src/plugins/timeout/index.d.ts +2 -0
- package/src/plugins/timeout/index.d.ts.map +1 -0
- package/src/plugins/timeout/index.js +2 -0
- package/src/plugins/timeout/index.js.map +1 -0
- package/src/plugins/timeout/timeout.fetch.d.ts +47 -0
- package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -0
- package/src/plugins/timeout/timeout.fetch.js +105 -0
- package/src/plugins/timeout/timeout.fetch.js.map +1 -0
- package/src/plugins/wait-for/index.d.ts +2 -0
- package/src/plugins/wait-for/index.d.ts.map +1 -0
- package/src/plugins/wait-for/index.js +2 -0
- package/src/plugins/wait-for/index.js.map +1 -0
- package/src/plugins/wait-for/wait-for.fetch.d.ts +78 -0
- package/src/plugins/wait-for/wait-for.fetch.d.ts.map +1 -0
- package/src/plugins/wait-for/wait-for.fetch.js +104 -0
- package/src/plugins/wait-for/wait-for.fetch.js.map +1 -0
- package/src/public_api.d.ts +4 -0
- package/src/public_api.d.ts.map +1 -0
- package/src/public_api.js +4 -0
- package/src/public_api.js.map +1 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _class_call_check(instance, Constructor) {
|
|
39
|
+
if (!(instance instanceof Constructor)) {
|
|
40
|
+
throw new TypeError("Cannot call a class as a function");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function _defineProperties(target, props) {
|
|
44
|
+
for(var i = 0; i < props.length; i++){
|
|
45
|
+
var descriptor = props[i];
|
|
46
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
47
|
+
descriptor.configurable = true;
|
|
48
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
49
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
53
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
55
|
+
return Constructor;
|
|
56
|
+
}
|
|
57
|
+
function _define_property(obj, key, value) {
|
|
58
|
+
if (key in obj) {
|
|
59
|
+
Object.defineProperty(obj, key, {
|
|
60
|
+
value: value,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
obj[key] = value;
|
|
67
|
+
}
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
function _instanceof(left, right) {
|
|
71
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
72
|
+
return !!right[Symbol.hasInstance](left);
|
|
73
|
+
} else {
|
|
74
|
+
return left instanceof right;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function _iterable_to_array(iter) {
|
|
78
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
79
|
+
}
|
|
80
|
+
function _non_iterable_spread() {
|
|
81
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
82
|
+
}
|
|
83
|
+
function _object_spread(target) {
|
|
84
|
+
for(var i = 1; i < arguments.length; i++){
|
|
85
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
86
|
+
var ownKeys = Object.keys(source);
|
|
87
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
88
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
89
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
ownKeys.forEach(function(key) {
|
|
93
|
+
_define_property(target, key, source[key]);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return target;
|
|
97
|
+
}
|
|
98
|
+
function ownKeys(object, enumerableOnly) {
|
|
99
|
+
var keys = Object.keys(object);
|
|
100
|
+
if (Object.getOwnPropertySymbols) {
|
|
101
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
102
|
+
if (enumerableOnly) {
|
|
103
|
+
symbols = symbols.filter(function(sym) {
|
|
104
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
keys.push.apply(keys, symbols);
|
|
108
|
+
}
|
|
109
|
+
return keys;
|
|
110
|
+
}
|
|
111
|
+
function _object_spread_props(target, source) {
|
|
112
|
+
source = source != null ? source : {};
|
|
113
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
114
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
115
|
+
} else {
|
|
116
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
117
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
function _to_consumable_array(arr) {
|
|
123
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
124
|
+
}
|
|
125
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
126
|
+
if (!o) return;
|
|
127
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
128
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
129
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
130
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
131
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
132
|
+
}
|
|
133
|
+
function _ts_generator(thisArg, body) {
|
|
134
|
+
var f, y, t, g, _ = {
|
|
135
|
+
label: 0,
|
|
136
|
+
sent: function() {
|
|
137
|
+
if (t[0] & 1) throw t[1];
|
|
138
|
+
return t[1];
|
|
139
|
+
},
|
|
140
|
+
trys: [],
|
|
141
|
+
ops: []
|
|
142
|
+
};
|
|
143
|
+
return g = {
|
|
144
|
+
next: verb(0),
|
|
145
|
+
"throw": verb(1),
|
|
146
|
+
"return": verb(2)
|
|
147
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
148
|
+
return this;
|
|
149
|
+
}), g;
|
|
150
|
+
function verb(n) {
|
|
151
|
+
return function(v) {
|
|
152
|
+
return step([
|
|
153
|
+
n,
|
|
154
|
+
v
|
|
155
|
+
]);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function step(op) {
|
|
159
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
160
|
+
while(_)try {
|
|
161
|
+
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;
|
|
162
|
+
if (y = 0, t) op = [
|
|
163
|
+
op[0] & 2,
|
|
164
|
+
t.value
|
|
165
|
+
];
|
|
166
|
+
switch(op[0]){
|
|
167
|
+
case 0:
|
|
168
|
+
case 1:
|
|
169
|
+
t = op;
|
|
170
|
+
break;
|
|
171
|
+
case 4:
|
|
172
|
+
_.label++;
|
|
173
|
+
return {
|
|
174
|
+
value: op[1],
|
|
175
|
+
done: false
|
|
176
|
+
};
|
|
177
|
+
case 5:
|
|
178
|
+
_.label++;
|
|
179
|
+
y = op[1];
|
|
180
|
+
op = [
|
|
181
|
+
0
|
|
182
|
+
];
|
|
183
|
+
continue;
|
|
184
|
+
case 7:
|
|
185
|
+
op = _.ops.pop();
|
|
186
|
+
_.trys.pop();
|
|
187
|
+
continue;
|
|
188
|
+
default:
|
|
189
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
190
|
+
_ = 0;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
194
|
+
_.label = op[1];
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
198
|
+
_.label = t[1];
|
|
199
|
+
t = op;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
if (t && _.label < t[2]) {
|
|
203
|
+
_.label = t[2];
|
|
204
|
+
_.ops.push(op);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
if (t[2]) _.ops.pop();
|
|
208
|
+
_.trys.pop();
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
op = body.call(thisArg, _);
|
|
212
|
+
} catch (e) {
|
|
213
|
+
op = [
|
|
214
|
+
6,
|
|
215
|
+
e
|
|
216
|
+
];
|
|
217
|
+
y = 0;
|
|
218
|
+
} finally{
|
|
219
|
+
f = t = 0;
|
|
220
|
+
}
|
|
221
|
+
if (op[0] & 5) throw op[1];
|
|
222
|
+
return {
|
|
223
|
+
value: op[0] ? op[1] : void 0,
|
|
224
|
+
done: true
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
import { CanceledCallError, EmptyResponseError, ExceptionReply, extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, ResponseJSONParseError, ReviverReply, tokenizeRequestOptions } from '@ama-sdk/core';
|
|
229
|
+
var DEFAULT_OPTIONS = {
|
|
230
|
+
replyPlugins: [
|
|
231
|
+
new ReviverReply(),
|
|
232
|
+
new ExceptionReply()
|
|
233
|
+
],
|
|
234
|
+
fetchPlugins: [],
|
|
235
|
+
requestPlugins: [],
|
|
236
|
+
enableTokenization: false,
|
|
237
|
+
disableFallback: false
|
|
238
|
+
};
|
|
239
|
+
/** Client to process the call to the API using Fetch API */ export var ApiFetchClient = /*#__PURE__*/ function() {
|
|
240
|
+
"use strict";
|
|
241
|
+
function ApiFetchClient(options) {
|
|
242
|
+
_class_call_check(this, ApiFetchClient);
|
|
243
|
+
/** @inheritdoc */ _define_property(this, "options", void 0);
|
|
244
|
+
this.options = _object_spread({}, DEFAULT_OPTIONS, options);
|
|
245
|
+
}
|
|
246
|
+
_create_class(ApiFetchClient, [
|
|
247
|
+
{
|
|
248
|
+
key: "extractQueryParams",
|
|
249
|
+
value: /** @inheritdoc */ function extractQueryParams1(data, names) {
|
|
250
|
+
return extractQueryParams(data, names);
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
key: "tokenizeRequestOptions",
|
|
255
|
+
value: /** @inheritdoc */ function tokenizeRequestOptions1(url, queryParameters, piiParamTokens, data) {
|
|
256
|
+
return this.options.enableTokenization ? tokenizeRequestOptions(url, queryParameters, piiParamTokens, data) : undefined;
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
key: "getRequestOptions",
|
|
261
|
+
value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
|
|
262
|
+
var _this = this;
|
|
263
|
+
return _async_to_generator(function() {
|
|
264
|
+
var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
|
|
265
|
+
return _ts_generator(this, function(_state) {
|
|
266
|
+
switch(_state.label){
|
|
267
|
+
case 0:
|
|
268
|
+
opts = _object_spread_props(_object_spread({}, requestOptionsParameters), {
|
|
269
|
+
headers: new Headers(filterUndefinedValues(requestOptionsParameters.headers)),
|
|
270
|
+
queryParams: filterUndefinedValues(requestOptionsParameters.queryParams)
|
|
271
|
+
});
|
|
272
|
+
if (!_this.options.requestPlugins) return [
|
|
273
|
+
3,
|
|
274
|
+
8
|
|
275
|
+
];
|
|
276
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
277
|
+
_state.label = 1;
|
|
278
|
+
case 1:
|
|
279
|
+
_state.trys.push([
|
|
280
|
+
1,
|
|
281
|
+
6,
|
|
282
|
+
7,
|
|
283
|
+
8
|
|
284
|
+
]);
|
|
285
|
+
_iterator = _this.options.requestPlugins[Symbol.iterator]();
|
|
286
|
+
_state.label = 2;
|
|
287
|
+
case 2:
|
|
288
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
289
|
+
3,
|
|
290
|
+
5
|
|
291
|
+
];
|
|
292
|
+
plugin = _step.value;
|
|
293
|
+
return [
|
|
294
|
+
4,
|
|
295
|
+
plugin.load({
|
|
296
|
+
logger: _this.options.logger,
|
|
297
|
+
apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
|
|
298
|
+
}).transform(opts)
|
|
299
|
+
];
|
|
300
|
+
case 3:
|
|
301
|
+
opts = _state.sent();
|
|
302
|
+
_state.label = 4;
|
|
303
|
+
case 4:
|
|
304
|
+
_iteratorNormalCompletion = true;
|
|
305
|
+
return [
|
|
306
|
+
3,
|
|
307
|
+
2
|
|
308
|
+
];
|
|
309
|
+
case 5:
|
|
310
|
+
return [
|
|
311
|
+
3,
|
|
312
|
+
8
|
|
313
|
+
];
|
|
314
|
+
case 6:
|
|
315
|
+
err = _state.sent();
|
|
316
|
+
_didIteratorError = true;
|
|
317
|
+
_iteratorError = err;
|
|
318
|
+
return [
|
|
319
|
+
3,
|
|
320
|
+
8
|
|
321
|
+
];
|
|
322
|
+
case 7:
|
|
323
|
+
try {
|
|
324
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
325
|
+
_iterator.return();
|
|
326
|
+
}
|
|
327
|
+
} finally{
|
|
328
|
+
if (_didIteratorError) {
|
|
329
|
+
throw _iteratorError;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return [
|
|
333
|
+
7
|
|
334
|
+
];
|
|
335
|
+
case 8:
|
|
336
|
+
return [
|
|
337
|
+
2,
|
|
338
|
+
opts
|
|
339
|
+
];
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
})();
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
key: "prepareUrl",
|
|
347
|
+
value: /** @inheritdoc */ function prepareUrl1(url) {
|
|
348
|
+
var queryParameters = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
349
|
+
return prepareUrl(url, queryParameters);
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
key: "processFormData",
|
|
354
|
+
value: /** @inheritdoc */ function processFormData1(data, type) {
|
|
355
|
+
return processFormData(data, type);
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
key: "processCall",
|
|
360
|
+
value: function processCall(url, options, apiType, apiName, revivers, operationId) {
|
|
361
|
+
var _this = this;
|
|
362
|
+
return _async_to_generator(function() {
|
|
363
|
+
var response, asyncResponse, root, body, exception, origin, _options_metadata, metadataSignal, controller, loadedPlugins, _loadedPlugins, canStart, isCanceledBy, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, e, reviver, replyPlugins, parsedData, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, pluginRunner, err;
|
|
364
|
+
return _ts_generator(this, function(_state) {
|
|
365
|
+
switch(_state.label){
|
|
366
|
+
case 0:
|
|
367
|
+
origin = options.headers.get('Origin');
|
|
368
|
+
_state.label = 1;
|
|
369
|
+
case 1:
|
|
370
|
+
_state.trys.push([
|
|
371
|
+
1,
|
|
372
|
+
5,
|
|
373
|
+
,
|
|
374
|
+
6
|
|
375
|
+
]);
|
|
376
|
+
metadataSignal = (_options_metadata = options.metadata) === null || _options_metadata === void 0 ? void 0 : _options_metadata.signal;
|
|
377
|
+
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
|
|
378
|
+
controller = new AbortController();
|
|
379
|
+
options.signal = controller.signal;
|
|
380
|
+
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener('abort', function() {
|
|
381
|
+
return controller.abort();
|
|
382
|
+
});
|
|
383
|
+
loadedPlugins = [];
|
|
384
|
+
if (_this.options.fetchPlugins) {
|
|
385
|
+
;
|
|
386
|
+
(_loadedPlugins = loadedPlugins).push.apply(_loadedPlugins, _to_consumable_array(_this.options.fetchPlugins.map(function(plugin) {
|
|
387
|
+
return plugin.load({
|
|
388
|
+
url: url,
|
|
389
|
+
options: options,
|
|
390
|
+
fetchPlugins: loadedPlugins,
|
|
391
|
+
controller: controller,
|
|
392
|
+
apiClient: _this,
|
|
393
|
+
logger: _this.options.logger
|
|
394
|
+
});
|
|
395
|
+
})));
|
|
396
|
+
}
|
|
397
|
+
return [
|
|
398
|
+
4,
|
|
399
|
+
Promise.all(loadedPlugins.map(function(plugin) {
|
|
400
|
+
return !plugin.canStart || plugin.canStart();
|
|
401
|
+
}))
|
|
402
|
+
];
|
|
403
|
+
case 2:
|
|
404
|
+
canStart = _state.sent();
|
|
405
|
+
isCanceledBy = canStart.indexOf(false);
|
|
406
|
+
if (isCanceledBy >= 0) {
|
|
407
|
+
// One of the fetch plugins cancelled the execution of the call
|
|
408
|
+
asyncResponse = Promise.reject(new CanceledCallError("Is canceled by the plugin ".concat(isCanceledBy), isCanceledBy, _this.options.fetchPlugins[isCanceledBy], {
|
|
409
|
+
apiName: apiName,
|
|
410
|
+
operationId: operationId,
|
|
411
|
+
url: url,
|
|
412
|
+
origin: origin
|
|
413
|
+
}));
|
|
414
|
+
} else {
|
|
415
|
+
asyncResponse = fetch(url, options);
|
|
416
|
+
}
|
|
417
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
418
|
+
try {
|
|
419
|
+
for(_iterator = loadedPlugins[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
420
|
+
plugin = _step.value;
|
|
421
|
+
asyncResponse = plugin.transform(asyncResponse);
|
|
422
|
+
}
|
|
423
|
+
} catch (err) {
|
|
424
|
+
_didIteratorError = true;
|
|
425
|
+
_iteratorError = err;
|
|
426
|
+
} finally{
|
|
427
|
+
try {
|
|
428
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
429
|
+
_iterator.return();
|
|
430
|
+
}
|
|
431
|
+
} finally{
|
|
432
|
+
if (_didIteratorError) {
|
|
433
|
+
throw _iteratorError;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return [
|
|
438
|
+
4,
|
|
439
|
+
asyncResponse
|
|
440
|
+
];
|
|
441
|
+
case 3:
|
|
442
|
+
response = _state.sent();
|
|
443
|
+
return [
|
|
444
|
+
4,
|
|
445
|
+
response.text()
|
|
446
|
+
];
|
|
447
|
+
case 4:
|
|
448
|
+
body = _state.sent();
|
|
449
|
+
return [
|
|
450
|
+
3,
|
|
451
|
+
6
|
|
452
|
+
];
|
|
453
|
+
case 5:
|
|
454
|
+
e = _state.sent();
|
|
455
|
+
if (_instanceof(e, CanceledCallError)) {
|
|
456
|
+
exception = e;
|
|
457
|
+
} else {
|
|
458
|
+
exception = new EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
|
|
459
|
+
apiName: apiName,
|
|
460
|
+
operationId: operationId,
|
|
461
|
+
url: url,
|
|
462
|
+
origin: origin
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
return [
|
|
466
|
+
3,
|
|
467
|
+
6
|
|
468
|
+
];
|
|
469
|
+
case 6:
|
|
470
|
+
try {
|
|
471
|
+
root = body ? JSON.parse(body) : undefined;
|
|
472
|
+
} catch (e) {
|
|
473
|
+
exception = new ResponseJSONParseError(e.message || 'Fail to parse response body', response && response.status || 0, body, {
|
|
474
|
+
apiName: apiName,
|
|
475
|
+
operationId: operationId,
|
|
476
|
+
url: url,
|
|
477
|
+
origin: origin
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
// eslint-disable-next-line no-console
|
|
481
|
+
reviver = getResponseReviver(revivers, response, operationId, {
|
|
482
|
+
disableFallback: _this.options.disableFallback,
|
|
483
|
+
log: console.error
|
|
484
|
+
});
|
|
485
|
+
replyPlugins = _this.options.replyPlugins ? _this.options.replyPlugins.map(function(plugin) {
|
|
486
|
+
return plugin.load({
|
|
487
|
+
dictionaries: root && root.dictionaries,
|
|
488
|
+
response: response,
|
|
489
|
+
reviver: reviver,
|
|
490
|
+
apiType: apiType,
|
|
491
|
+
apiName: apiName,
|
|
492
|
+
exception: exception,
|
|
493
|
+
operationId: operationId,
|
|
494
|
+
url: url,
|
|
495
|
+
origin: origin,
|
|
496
|
+
logger: _this.options.logger
|
|
497
|
+
});
|
|
498
|
+
}) : [];
|
|
499
|
+
parsedData = root;
|
|
500
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
501
|
+
_state.label = 7;
|
|
502
|
+
case 7:
|
|
503
|
+
_state.trys.push([
|
|
504
|
+
7,
|
|
505
|
+
12,
|
|
506
|
+
13,
|
|
507
|
+
14
|
|
508
|
+
]);
|
|
509
|
+
_iterator1 = replyPlugins[Symbol.iterator]();
|
|
510
|
+
_state.label = 8;
|
|
511
|
+
case 8:
|
|
512
|
+
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
513
|
+
3,
|
|
514
|
+
11
|
|
515
|
+
];
|
|
516
|
+
pluginRunner = _step1.value;
|
|
517
|
+
return [
|
|
518
|
+
4,
|
|
519
|
+
pluginRunner.transform(parsedData)
|
|
520
|
+
];
|
|
521
|
+
case 9:
|
|
522
|
+
parsedData = _state.sent();
|
|
523
|
+
_state.label = 10;
|
|
524
|
+
case 10:
|
|
525
|
+
_iteratorNormalCompletion1 = true;
|
|
526
|
+
return [
|
|
527
|
+
3,
|
|
528
|
+
8
|
|
529
|
+
];
|
|
530
|
+
case 11:
|
|
531
|
+
return [
|
|
532
|
+
3,
|
|
533
|
+
14
|
|
534
|
+
];
|
|
535
|
+
case 12:
|
|
536
|
+
err = _state.sent();
|
|
537
|
+
_didIteratorError1 = true;
|
|
538
|
+
_iteratorError1 = err;
|
|
539
|
+
return [
|
|
540
|
+
3,
|
|
541
|
+
14
|
|
542
|
+
];
|
|
543
|
+
case 13:
|
|
544
|
+
try {
|
|
545
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
546
|
+
_iterator1.return();
|
|
547
|
+
}
|
|
548
|
+
} finally{
|
|
549
|
+
if (_didIteratorError1) {
|
|
550
|
+
throw _iteratorError1;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return [
|
|
554
|
+
7
|
|
555
|
+
];
|
|
556
|
+
case 14:
|
|
557
|
+
if (exception) {
|
|
558
|
+
throw exception;
|
|
559
|
+
}
|
|
560
|
+
return [
|
|
561
|
+
2,
|
|
562
|
+
parsedData
|
|
563
|
+
];
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
})();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
]);
|
|
570
|
+
return ApiFetchClient;
|
|
571
|
+
}();
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(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 _type_of(obj) {
|
|
34
|
+
"@swc/helpers - typeof";
|
|
35
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
36
|
+
}
|
|
37
|
+
var isPromise = function(result) {
|
|
38
|
+
if ((typeof result === "undefined" ? "undefined" : _type_of(result)) !== 'object') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
/** Plugin to abort a Fetch request */ export var AbortFetch = /*#__PURE__*/ function() {
|
|
44
|
+
"use strict";
|
|
45
|
+
function AbortFetch(abortCallback) {
|
|
46
|
+
_class_call_check(this, AbortFetch);
|
|
47
|
+
_define_property(this, "abortCallback", void 0);
|
|
48
|
+
this.abortCallback = abortCallback;
|
|
49
|
+
}
|
|
50
|
+
_create_class(AbortFetch, [
|
|
51
|
+
{
|
|
52
|
+
key: "load",
|
|
53
|
+
value: /** @inheritDoc */ function load(context) {
|
|
54
|
+
var _this = this;
|
|
55
|
+
return {
|
|
56
|
+
transform: function(fetchCall) {
|
|
57
|
+
var abortCallbackResult = _this.abortCallback();
|
|
58
|
+
if (isPromise(abortCallbackResult)) {
|
|
59
|
+
void abortCallbackResult.then(function(res) {
|
|
60
|
+
var _context_controller;
|
|
61
|
+
return res && ((_context_controller = context.controller) === null || _context_controller === void 0 ? void 0 : _context_controller.abort());
|
|
62
|
+
});
|
|
63
|
+
} else if (abortCallbackResult) {
|
|
64
|
+
var _context_controller;
|
|
65
|
+
(_context_controller = context.controller) === null || _context_controller === void 0 ? void 0 : _context_controller.abort();
|
|
66
|
+
}
|
|
67
|
+
return fetchCall;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]);
|
|
73
|
+
return AbortFetch;
|
|
74
|
+
}();
|