@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.
Files changed (157) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +33 -0
  3. package/cjs/api-fetch-client.js +581 -0
  4. package/cjs/fetch-plugin.js +4 -0
  5. package/cjs/plugins/abort/abort.fetch.js +84 -0
  6. package/cjs/plugins/abort/abort.spec.js +204 -0
  7. package/cjs/plugins/abort/index.js +18 -0
  8. package/cjs/plugins/concurrent/concurrent.fetch.js +263 -0
  9. package/cjs/plugins/concurrent/concurrent.spec.js +239 -0
  10. package/cjs/plugins/concurrent/index.js +18 -0
  11. package/cjs/plugins/index.js +25 -0
  12. package/cjs/plugins/keepalive/index.js +18 -0
  13. package/cjs/plugins/keepalive/keepalive.request.js +289 -0
  14. package/cjs/plugins/keepalive/keepalive.spec.js +162 -0
  15. package/cjs/plugins/mock-intercept/index.js +19 -0
  16. package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +288 -0
  17. package/cjs/plugins/mock-intercept/mock-intercept.interface.js +4 -0
  18. package/cjs/plugins/mock-intercept/mock-intercept.spec.js +445 -0
  19. package/cjs/plugins/perf-metric/index.js +18 -0
  20. package/cjs/plugins/perf-metric/perf-metric.fetch.js +371 -0
  21. package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +60 -0
  22. package/cjs/plugins/retry/index.js +18 -0
  23. package/cjs/plugins/retry/retry.fetch.js +371 -0
  24. package/cjs/plugins/retry/retry.spec.js +348 -0
  25. package/cjs/plugins/timeout/index.js +18 -0
  26. package/cjs/plugins/timeout/timeout.fetch.js +320 -0
  27. package/cjs/plugins/timeout/timeout.spec.js +443 -0
  28. package/cjs/plugins/wait-for/index.js +18 -0
  29. package/cjs/plugins/wait-for/wait-for.fetch.js +350 -0
  30. package/cjs/plugins/wait-for/wait-for.spec.js +383 -0
  31. package/cjs/public_api.js +20 -0
  32. package/collection.json +11 -0
  33. package/esm2015/api-fetch-client.js +571 -0
  34. package/esm2015/fetch-plugin.js +4 -0
  35. package/esm2015/plugins/abort/abort.fetch.js +74 -0
  36. package/esm2015/plugins/abort/abort.spec.js +200 -0
  37. package/esm2015/plugins/abort/index.js +1 -0
  38. package/esm2015/plugins/concurrent/concurrent.fetch.js +255 -0
  39. package/esm2015/plugins/concurrent/concurrent.spec.js +235 -0
  40. package/esm2015/plugins/concurrent/index.js +1 -0
  41. package/esm2015/plugins/index.js +8 -0
  42. package/esm2015/plugins/keepalive/index.js +1 -0
  43. package/esm2015/plugins/keepalive/keepalive.request.js +281 -0
  44. package/esm2015/plugins/keepalive/keepalive.spec.js +158 -0
  45. package/esm2015/plugins/mock-intercept/index.js +2 -0
  46. package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +283 -0
  47. package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +1 -0
  48. package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +441 -0
  49. package/esm2015/plugins/perf-metric/index.js +1 -0
  50. package/esm2015/plugins/perf-metric/perf-metric.fetch.js +363 -0
  51. package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +56 -0
  52. package/esm2015/plugins/retry/index.js +1 -0
  53. package/esm2015/plugins/retry/retry.fetch.js +363 -0
  54. package/esm2015/plugins/retry/retry.spec.js +344 -0
  55. package/esm2015/plugins/timeout/index.js +1 -0
  56. package/esm2015/plugins/timeout/timeout.fetch.js +310 -0
  57. package/esm2015/plugins/timeout/timeout.spec.js +439 -0
  58. package/esm2015/plugins/wait-for/index.js +1 -0
  59. package/esm2015/plugins/wait-for/wait-for.fetch.js +379 -0
  60. package/esm2015/plugins/wait-for/wait-for.spec.js +379 -0
  61. package/esm2015/public_api.js +3 -0
  62. package/package.json +196 -0
  63. package/schematics/ng-add/index.d.ts +8 -0
  64. package/schematics/ng-add/index.d.ts.map +1 -0
  65. package/schematics/ng-add/index.js +67 -0
  66. package/schematics/ng-add/migration/import-map.d.ts +6 -0
  67. package/schematics/ng-add/migration/import-map.d.ts.map +1 -0
  68. package/schematics/ng-add/migration/import-map.js +39 -0
  69. package/schematics/ng-add/schema.d.ts +6 -0
  70. package/schematics/ng-add/schema.d.ts.map +1 -0
  71. package/schematics/ng-add/schema.js +3 -0
  72. package/schematics/ng-add/schema.json +18 -0
  73. package/schematics/package.json +3 -0
  74. package/src/api-fetch-client.d.ts +46 -0
  75. package/src/api-fetch-client.d.ts.map +1 -0
  76. package/src/api-fetch-client.js +126 -0
  77. package/src/api-fetch-client.js.map +1 -0
  78. package/src/fetch-plugin.d.ts +38 -0
  79. package/src/fetch-plugin.d.ts.map +1 -0
  80. package/src/fetch-plugin.js +2 -0
  81. package/src/fetch-plugin.js.map +1 -0
  82. package/src/plugins/abort/abort.fetch.d.ts +66 -0
  83. package/src/plugins/abort/abort.fetch.d.ts.map +1 -0
  84. package/src/plugins/abort/abort.fetch.js +32 -0
  85. package/src/plugins/abort/abort.fetch.js.map +1 -0
  86. package/src/plugins/abort/index.d.ts +2 -0
  87. package/src/plugins/abort/index.d.ts.map +1 -0
  88. package/src/plugins/abort/index.js +2 -0
  89. package/src/plugins/abort/index.js.map +1 -0
  90. package/src/plugins/concurrent/concurrent.fetch.d.ts +33 -0
  91. package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -0
  92. package/src/plugins/concurrent/concurrent.fetch.js +57 -0
  93. package/src/plugins/concurrent/concurrent.fetch.js.map +1 -0
  94. package/src/plugins/concurrent/index.d.ts +2 -0
  95. package/src/plugins/concurrent/index.d.ts.map +1 -0
  96. package/src/plugins/concurrent/index.js +2 -0
  97. package/src/plugins/concurrent/index.js.map +1 -0
  98. package/src/plugins/index.d.ts +9 -0
  99. package/src/plugins/index.d.ts.map +1 -0
  100. package/src/plugins/index.js +9 -0
  101. package/src/plugins/index.js.map +1 -0
  102. package/src/plugins/keepalive/index.d.ts +2 -0
  103. package/src/plugins/keepalive/index.d.ts.map +1 -0
  104. package/src/plugins/keepalive/index.js +2 -0
  105. package/src/plugins/keepalive/index.js.map +1 -0
  106. package/src/plugins/keepalive/keepalive.request.d.ts +18 -0
  107. package/src/plugins/keepalive/keepalive.request.d.ts.map +1 -0
  108. package/src/plugins/keepalive/keepalive.request.js +39 -0
  109. package/src/plugins/keepalive/keepalive.request.js.map +1 -0
  110. package/src/plugins/mock-intercept/index.d.ts +3 -0
  111. package/src/plugins/mock-intercept/index.d.ts.map +1 -0
  112. package/src/plugins/mock-intercept/index.js +3 -0
  113. package/src/plugins/mock-intercept/index.js.map +1 -0
  114. package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts +15 -0
  115. package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts.map +1 -0
  116. package/src/plugins/mock-intercept/mock-intercept.fetch.js +47 -0
  117. package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -0
  118. package/src/plugins/mock-intercept/mock-intercept.interface.d.ts +10 -0
  119. package/src/plugins/mock-intercept/mock-intercept.interface.d.ts.map +1 -0
  120. package/src/plugins/mock-intercept/mock-intercept.interface.js +2 -0
  121. package/src/plugins/mock-intercept/mock-intercept.interface.js.map +1 -0
  122. package/src/plugins/perf-metric/index.d.ts +2 -0
  123. package/src/plugins/perf-metric/index.d.ts.map +1 -0
  124. package/src/plugins/perf-metric/index.js +2 -0
  125. package/src/plugins/perf-metric/index.js.map +1 -0
  126. package/src/plugins/perf-metric/perf-metric.fetch.d.ts +133 -0
  127. package/src/plugins/perf-metric/perf-metric.fetch.d.ts.map +1 -0
  128. package/src/plugins/perf-metric/perf-metric.fetch.js +111 -0
  129. package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -0
  130. package/src/plugins/retry/index.d.ts +2 -0
  131. package/src/plugins/retry/index.d.ts.map +1 -0
  132. package/src/plugins/retry/index.js +2 -0
  133. package/src/plugins/retry/index.js.map +1 -0
  134. package/src/plugins/retry/retry.fetch.d.ts +53 -0
  135. package/src/plugins/retry/retry.fetch.d.ts.map +1 -0
  136. package/src/plugins/retry/retry.fetch.js +66 -0
  137. package/src/plugins/retry/retry.fetch.js.map +1 -0
  138. package/src/plugins/timeout/index.d.ts +2 -0
  139. package/src/plugins/timeout/index.d.ts.map +1 -0
  140. package/src/plugins/timeout/index.js +2 -0
  141. package/src/plugins/timeout/index.js.map +1 -0
  142. package/src/plugins/timeout/timeout.fetch.d.ts +47 -0
  143. package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -0
  144. package/src/plugins/timeout/timeout.fetch.js +105 -0
  145. package/src/plugins/timeout/timeout.fetch.js.map +1 -0
  146. package/src/plugins/wait-for/index.d.ts +2 -0
  147. package/src/plugins/wait-for/index.d.ts.map +1 -0
  148. package/src/plugins/wait-for/index.js +2 -0
  149. package/src/plugins/wait-for/index.js.map +1 -0
  150. package/src/plugins/wait-for/wait-for.fetch.d.ts +78 -0
  151. package/src/plugins/wait-for/wait-for.fetch.d.ts.map +1 -0
  152. package/src/plugins/wait-for/wait-for.fetch.js +104 -0
  153. package/src/plugins/wait-for/wait-for.fetch.js.map +1 -0
  154. package/src/public_api.d.ts +4 -0
  155. package/src/public_api.d.ts.map +1 -0
  156. package/src/public_api.js +4 -0
  157. package/src/public_api.js.map +1 -0
@@ -0,0 +1,350 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "WaitForFetch", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return WaitForFetch;
9
+ }
10
+ });
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
12
+ try {
13
+ var info = gen[key](arg);
14
+ var value = info.value;
15
+ } catch (error) {
16
+ reject(error);
17
+ return;
18
+ }
19
+ if (info.done) {
20
+ resolve(value);
21
+ } else {
22
+ Promise.resolve(value).then(_next, _throw);
23
+ }
24
+ }
25
+ function _async_to_generator(fn) {
26
+ return function() {
27
+ var self = this, args = arguments;
28
+ return new Promise(function(resolve, reject) {
29
+ var gen = fn.apply(self, args);
30
+ function _next(value) {
31
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
32
+ }
33
+ function _throw(err) {
34
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
35
+ }
36
+ _next(undefined);
37
+ });
38
+ };
39
+ }
40
+ function _class_call_check(instance, Constructor) {
41
+ if (!(instance instanceof Constructor)) {
42
+ throw new TypeError("Cannot call a class as a function");
43
+ }
44
+ }
45
+ function _defineProperties(target, props) {
46
+ for(var i = 0; i < props.length; i++){
47
+ var descriptor = props[i];
48
+ descriptor.enumerable = descriptor.enumerable || false;
49
+ descriptor.configurable = true;
50
+ if ("value" in descriptor) descriptor.writable = true;
51
+ Object.defineProperty(target, descriptor.key, descriptor);
52
+ }
53
+ }
54
+ function _create_class(Constructor, protoProps, staticProps) {
55
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
56
+ if (staticProps) _defineProperties(Constructor, staticProps);
57
+ return Constructor;
58
+ }
59
+ function _define_property(obj, key, value) {
60
+ if (key in obj) {
61
+ Object.defineProperty(obj, key, {
62
+ value: value,
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true
66
+ });
67
+ } else {
68
+ obj[key] = value;
69
+ }
70
+ return obj;
71
+ }
72
+ function _object_spread(target) {
73
+ for(var i = 1; i < arguments.length; i++){
74
+ var source = arguments[i] != null ? arguments[i] : {};
75
+ var ownKeys = Object.keys(source);
76
+ if (typeof Object.getOwnPropertySymbols === "function") {
77
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
78
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
79
+ }));
80
+ }
81
+ ownKeys.forEach(function(key) {
82
+ _define_property(target, key, source[key]);
83
+ });
84
+ }
85
+ return target;
86
+ }
87
+ function ownKeys(object, enumerableOnly) {
88
+ var keys = Object.keys(object);
89
+ if (Object.getOwnPropertySymbols) {
90
+ var symbols = Object.getOwnPropertySymbols(object);
91
+ if (enumerableOnly) {
92
+ symbols = symbols.filter(function(sym) {
93
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
94
+ });
95
+ }
96
+ keys.push.apply(keys, symbols);
97
+ }
98
+ return keys;
99
+ }
100
+ function _object_spread_props(target, source) {
101
+ source = source != null ? source : {};
102
+ if (Object.getOwnPropertyDescriptors) {
103
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
104
+ } else {
105
+ ownKeys(Object(source)).forEach(function(key) {
106
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
107
+ });
108
+ }
109
+ return target;
110
+ }
111
+ function _ts_generator(thisArg, body) {
112
+ var f, y, t, g, _ = {
113
+ label: 0,
114
+ sent: function() {
115
+ if (t[0] & 1) throw t[1];
116
+ return t[1];
117
+ },
118
+ trys: [],
119
+ ops: []
120
+ };
121
+ return g = {
122
+ next: verb(0),
123
+ "throw": verb(1),
124
+ "return": verb(2)
125
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
126
+ return this;
127
+ }), g;
128
+ function verb(n) {
129
+ return function(v) {
130
+ return step([
131
+ n,
132
+ v
133
+ ]);
134
+ };
135
+ }
136
+ function step(op) {
137
+ if (f) throw new TypeError("Generator is already executing.");
138
+ while(_)try {
139
+ 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;
140
+ if (y = 0, t) op = [
141
+ op[0] & 2,
142
+ t.value
143
+ ];
144
+ switch(op[0]){
145
+ case 0:
146
+ case 1:
147
+ t = op;
148
+ break;
149
+ case 4:
150
+ _.label++;
151
+ return {
152
+ value: op[1],
153
+ done: false
154
+ };
155
+ case 5:
156
+ _.label++;
157
+ y = op[1];
158
+ op = [
159
+ 0
160
+ ];
161
+ continue;
162
+ case 7:
163
+ op = _.ops.pop();
164
+ _.trys.pop();
165
+ continue;
166
+ default:
167
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
168
+ _ = 0;
169
+ continue;
170
+ }
171
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
172
+ _.label = op[1];
173
+ break;
174
+ }
175
+ if (op[0] === 6 && _.label < t[1]) {
176
+ _.label = t[1];
177
+ t = op;
178
+ break;
179
+ }
180
+ if (t && _.label < t[2]) {
181
+ _.label = t[2];
182
+ _.ops.push(op);
183
+ break;
184
+ }
185
+ if (t[2]) _.ops.pop();
186
+ _.trys.pop();
187
+ continue;
188
+ }
189
+ op = body.call(thisArg, _);
190
+ } catch (e) {
191
+ op = [
192
+ 6,
193
+ e
194
+ ];
195
+ y = 0;
196
+ } finally{
197
+ f = t = 0;
198
+ }
199
+ if (op[0] & 5) throw op[1];
200
+ return {
201
+ value: op[0] ? op[1] : void 0,
202
+ done: true
203
+ };
204
+ }
205
+ }
206
+ var WaitForFetch = /*#__PURE__*/ function() {
207
+ "use strict";
208
+ function WaitForFetch(canStartCondition, timeout, callback) {
209
+ _class_call_check(this, WaitForFetch);
210
+ /** Condition to wait to start the call */ _define_property(this, "canStartCondition", void 0);
211
+ /** Timeout in ms (infinit if not defined) */ _define_property(this, "timeout", void 0);
212
+ /** Function callback called when the fetch call has been executed */ _define_property(this, "callback", void 0);
213
+ this.canStartCondition = canStartCondition;
214
+ this.timeout = timeout;
215
+ this.callback = callback;
216
+ }
217
+ _create_class(WaitForFetch, [
218
+ {
219
+ key: "load",
220
+ value: /** @inheritDoc */ function load(context) {
221
+ var data;
222
+ var _this = this;
223
+ return {
224
+ // eslint-disable-next-line no-async-promise-executor
225
+ canStart: function() {
226
+ return new Promise(function() {
227
+ var _ref = _async_to_generator(function(resolve) {
228
+ var didTimeOut, timer, canStartCondition, canStart, ex;
229
+ return _ts_generator(this, function(_state) {
230
+ switch(_state.label){
231
+ case 0:
232
+ didTimeOut = false;
233
+ if (_this.timeout) {
234
+ timer = setTimeout(function() {
235
+ didTimeOut = true;
236
+ resolve(false);
237
+ }, _this.timeout);
238
+ }
239
+ _state.label = 1;
240
+ case 1:
241
+ _state.trys.push([
242
+ 1,
243
+ 4,
244
+ 5,
245
+ 6
246
+ ]);
247
+ return [
248
+ 4,
249
+ _this.canStartCondition(context)
250
+ ];
251
+ case 2:
252
+ canStartCondition = _state.sent();
253
+ data = canStartCondition.data;
254
+ return [
255
+ 4,
256
+ canStartCondition.result
257
+ ];
258
+ case 3:
259
+ canStart = _state.sent();
260
+ if (!didTimeOut) {
261
+ resolve(canStart);
262
+ }
263
+ return [
264
+ 3,
265
+ 6
266
+ ];
267
+ case 4:
268
+ ex = _state.sent();
269
+ if (!didTimeOut) {
270
+ resolve(false);
271
+ }
272
+ return [
273
+ 3,
274
+ 6
275
+ ];
276
+ case 5:
277
+ if (timer) {
278
+ clearTimeout(timer);
279
+ }
280
+ return [
281
+ 7
282
+ ];
283
+ case 6:
284
+ return [
285
+ 2
286
+ ];
287
+ }
288
+ });
289
+ });
290
+ return function(resolve) {
291
+ return _ref.apply(this, arguments);
292
+ };
293
+ }());
294
+ },
295
+ transform: function() {
296
+ var _ref = _async_to_generator(function(fetchCall) {
297
+ var response, e;
298
+ return _ts_generator(this, function(_state) {
299
+ switch(_state.label){
300
+ case 0:
301
+ if (!_this.callback) {
302
+ return [
303
+ 2,
304
+ fetchCall
305
+ ];
306
+ }
307
+ _state.label = 1;
308
+ case 1:
309
+ _state.trys.push([
310
+ 1,
311
+ 3,
312
+ ,
313
+ 4
314
+ ]);
315
+ return [
316
+ 4,
317
+ fetchCall
318
+ ];
319
+ case 2:
320
+ response = _state.sent();
321
+ _this.callback(_object_spread_props(_object_spread({}, context), {
322
+ data: data
323
+ }), fetchCall, response);
324
+ return [
325
+ 2,
326
+ response
327
+ ];
328
+ case 3:
329
+ e = _state.sent();
330
+ _this.callback(_object_spread_props(_object_spread({}, context), {
331
+ data: data
332
+ }), fetchCall, response);
333
+ throw e;
334
+ case 4:
335
+ return [
336
+ 2
337
+ ];
338
+ }
339
+ });
340
+ });
341
+ return function(fetchCall) {
342
+ return _ref.apply(this, arguments);
343
+ };
344
+ }()
345
+ };
346
+ }
347
+ }
348
+ ]);
349
+ return WaitForFetch;
350
+ }();