@ama-sdk/client-fetch 12.3.0-prerelease.70 → 12.3.0-prerelease.71
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/cjs/api-fetch-client.js +12 -13
- package/cjs/plugins/abort/abort.spec.js +79 -73
- package/cjs/plugins/concurrent/concurrent.fetch.js +8 -12
- package/cjs/plugins/concurrent/concurrent.spec.js +95 -91
- package/cjs/plugins/keepalive/keepalive.request.js +3 -4
- package/cjs/plugins/keepalive/keepalive.spec.js +28 -26
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +11 -14
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +243 -231
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +7 -10
- package/cjs/plugins/retry/retry.fetch.js +14 -19
- package/cjs/plugins/retry/retry.spec.js +229 -217
- package/cjs/plugins/timeout/timeout.fetch.js +9 -11
- package/cjs/plugins/timeout/timeout.spec.js +207 -197
- package/cjs/plugins/wait-for/wait-for.fetch.js +15 -21
- package/cjs/plugins/wait-for/wait-for.spec.js +207 -195
- package/esm2015/api-fetch-client.js +12 -13
- package/esm2015/plugins/abort/abort.spec.js +79 -73
- package/esm2015/plugins/concurrent/concurrent.fetch.js +8 -12
- package/esm2015/plugins/concurrent/concurrent.spec.js +95 -91
- package/esm2015/plugins/keepalive/keepalive.request.js +3 -4
- package/esm2015/plugins/keepalive/keepalive.spec.js +28 -26
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +11 -14
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +243 -231
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +7 -10
- package/esm2015/plugins/retry/retry.fetch.js +14 -19
- package/esm2015/plugins/retry/retry.spec.js +229 -217
- package/esm2015/plugins/timeout/timeout.fetch.js +9 -11
- package/esm2015/plugins/timeout/timeout.spec.js +207 -197
- package/esm2015/plugins/wait-for/wait-for.fetch.js +15 -21
- package/esm2015/plugins/wait-for/wait-for.spec.js +207 -195
- package/package.json +8 -8
|
@@ -173,203 +173,215 @@ function _ts_generator(thisArg, body) {
|
|
|
173
173
|
import { WaitForFetch } from './wait-for.fetch';
|
|
174
174
|
describe('Wait For Fetch Plugin', function() {
|
|
175
175
|
var defaultContext = {};
|
|
176
|
-
it('should not start if timeout',
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
runner.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
176
|
+
it('should not start if timeout', function() {
|
|
177
|
+
return _async_to_generator(function() {
|
|
178
|
+
var plugin, runner, canStart;
|
|
179
|
+
return _ts_generator(this, function(_state) {
|
|
180
|
+
switch(_state.label){
|
|
181
|
+
case 0:
|
|
182
|
+
plugin = new WaitForFetch(function() {
|
|
183
|
+
return {
|
|
184
|
+
result: new Promise(function(resolve) {
|
|
185
|
+
return setTimeout(function() {
|
|
186
|
+
return resolve(true);
|
|
187
|
+
}, 2000);
|
|
188
|
+
})
|
|
189
|
+
};
|
|
190
|
+
}, 100);
|
|
191
|
+
runner = plugin.load(defaultContext);
|
|
192
|
+
canStart = runner.canStart();
|
|
193
|
+
return [
|
|
194
|
+
4,
|
|
195
|
+
jest.runAllTimersAsync()
|
|
196
|
+
];
|
|
197
|
+
case 1:
|
|
198
|
+
_state.sent();
|
|
199
|
+
return [
|
|
200
|
+
4,
|
|
201
|
+
canStart
|
|
202
|
+
];
|
|
203
|
+
case 2:
|
|
204
|
+
expect.apply(void 0, [
|
|
205
|
+
_state.sent()
|
|
206
|
+
]).toBe(false);
|
|
207
|
+
return [
|
|
208
|
+
2
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
})();
|
|
213
|
+
});
|
|
214
|
+
it('should start if promise condition passed', function() {
|
|
215
|
+
return _async_to_generator(function() {
|
|
216
|
+
var plugin, runner, canStart;
|
|
217
|
+
return _ts_generator(this, function(_state) {
|
|
218
|
+
switch(_state.label){
|
|
219
|
+
case 0:
|
|
220
|
+
plugin = new WaitForFetch(function() {
|
|
221
|
+
return {
|
|
222
|
+
result: Promise.resolve(true)
|
|
223
|
+
};
|
|
224
|
+
}, 100);
|
|
225
|
+
runner = plugin.load(defaultContext);
|
|
226
|
+
return [
|
|
227
|
+
4,
|
|
228
|
+
runner.canStart()
|
|
229
|
+
];
|
|
230
|
+
case 1:
|
|
231
|
+
canStart = _state.sent();
|
|
232
|
+
expect(canStart).toBe(true);
|
|
233
|
+
return [
|
|
234
|
+
2
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
})();
|
|
239
|
+
});
|
|
240
|
+
it('should start if condition passed', function() {
|
|
241
|
+
return _async_to_generator(function() {
|
|
242
|
+
var plugin, runner, canStart;
|
|
243
|
+
return _ts_generator(this, function(_state) {
|
|
244
|
+
switch(_state.label){
|
|
245
|
+
case 0:
|
|
246
|
+
plugin = new WaitForFetch(function() {
|
|
247
|
+
return {
|
|
248
|
+
result: true
|
|
249
|
+
};
|
|
250
|
+
}, 100);
|
|
251
|
+
runner = plugin.load(defaultContext);
|
|
252
|
+
return [
|
|
253
|
+
4,
|
|
254
|
+
runner.canStart()
|
|
255
|
+
];
|
|
256
|
+
case 1:
|
|
257
|
+
canStart = _state.sent();
|
|
258
|
+
expect(canStart).toBe(true);
|
|
259
|
+
return [
|
|
260
|
+
2
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
})();
|
|
265
|
+
});
|
|
266
|
+
it('should call the callback function on success', function() {
|
|
267
|
+
return _async_to_generator(function() {
|
|
268
|
+
var callback, plugin, runner, response, fetchCall;
|
|
269
|
+
return _ts_generator(this, function(_state) {
|
|
270
|
+
switch(_state.label){
|
|
271
|
+
case 0:
|
|
272
|
+
callback = jest.fn();
|
|
273
|
+
plugin = new WaitForFetch(function() {
|
|
274
|
+
return {
|
|
275
|
+
result: true
|
|
276
|
+
};
|
|
277
|
+
}, 100, callback);
|
|
278
|
+
runner = plugin.load(defaultContext);
|
|
279
|
+
response = {
|
|
280
|
+
test: true
|
|
244
281
|
};
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
})
|
|
260
|
-
it('should call the callback function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
282
|
+
fetchCall = Promise.resolve(response);
|
|
283
|
+
return [
|
|
284
|
+
4,
|
|
285
|
+
runner.transform(fetchCall)
|
|
286
|
+
];
|
|
287
|
+
case 1:
|
|
288
|
+
_state.sent();
|
|
289
|
+
expect(callback).toHaveBeenCalledWith(expect.objectContaining(defaultContext), fetchCall, response);
|
|
290
|
+
return [
|
|
291
|
+
2
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
})();
|
|
296
|
+
});
|
|
297
|
+
it('should call the callback function with the correct data', function() {
|
|
298
|
+
return _async_to_generator(function() {
|
|
299
|
+
var callback, plugin, runner, response, fetchCall;
|
|
300
|
+
return _ts_generator(this, function(_state) {
|
|
301
|
+
switch(_state.label){
|
|
302
|
+
case 0:
|
|
303
|
+
callback = jest.fn();
|
|
304
|
+
plugin = new WaitForFetch(function() {
|
|
305
|
+
return {
|
|
306
|
+
result: true,
|
|
307
|
+
data: 'test'
|
|
308
|
+
};
|
|
309
|
+
}, 100, callback);
|
|
310
|
+
runner = plugin.load(defaultContext);
|
|
311
|
+
response = {
|
|
312
|
+
test: true
|
|
269
313
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
2
|
|
285
|
-
];
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}));
|
|
289
|
-
it('should call the callback function with the correct data', /*#__PURE__*/ _async_to_generator(function() {
|
|
290
|
-
var callback, plugin, runner, response, fetchCall;
|
|
291
|
-
return _ts_generator(this, function(_state) {
|
|
292
|
-
switch(_state.label){
|
|
293
|
-
case 0:
|
|
294
|
-
callback = jest.fn();
|
|
295
|
-
plugin = new WaitForFetch(function() {
|
|
296
|
-
return {
|
|
297
|
-
result: true,
|
|
314
|
+
fetchCall = Promise.resolve(response);
|
|
315
|
+
return [
|
|
316
|
+
4,
|
|
317
|
+
runner.canStart()
|
|
318
|
+
];
|
|
319
|
+
case 1:
|
|
320
|
+
_state.sent();
|
|
321
|
+
return [
|
|
322
|
+
4,
|
|
323
|
+
runner.transform(fetchCall)
|
|
324
|
+
];
|
|
325
|
+
case 2:
|
|
326
|
+
_state.sent();
|
|
327
|
+
expect(callback).toHaveBeenCalledWith(expect.objectContaining(_object_spread_props(_object_spread({}, defaultContext), {
|
|
298
328
|
data: 'test'
|
|
329
|
+
})), fetchCall, response);
|
|
330
|
+
return [
|
|
331
|
+
2
|
|
332
|
+
];
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
})();
|
|
336
|
+
});
|
|
337
|
+
it('should call the callback function on failure', function() {
|
|
338
|
+
return _async_to_generator(function() {
|
|
339
|
+
var callback, plugin, runner, response, fetchCall, e;
|
|
340
|
+
return _ts_generator(this, function(_state) {
|
|
341
|
+
switch(_state.label){
|
|
342
|
+
case 0:
|
|
343
|
+
callback = jest.fn();
|
|
344
|
+
plugin = new WaitForFetch(function() {
|
|
345
|
+
return {
|
|
346
|
+
result: true
|
|
347
|
+
};
|
|
348
|
+
}, 100, callback);
|
|
349
|
+
runner = plugin.load(defaultContext);
|
|
350
|
+
response = {
|
|
351
|
+
test: true
|
|
299
352
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return {
|
|
335
|
-
result: true
|
|
336
|
-
};
|
|
337
|
-
}, 100, callback);
|
|
338
|
-
runner = plugin.load(defaultContext);
|
|
339
|
-
response = {
|
|
340
|
-
test: true
|
|
341
|
-
};
|
|
342
|
-
fetchCall = Promise.reject(new Error(JSON.stringify(response)));
|
|
343
|
-
_state.label = 1;
|
|
344
|
-
case 1:
|
|
345
|
-
_state.trys.push([
|
|
346
|
-
1,
|
|
347
|
-
3,
|
|
348
|
-
,
|
|
349
|
-
4
|
|
350
|
-
]);
|
|
351
|
-
return [
|
|
352
|
-
4,
|
|
353
|
-
runner.transform(fetchCall)
|
|
354
|
-
];
|
|
355
|
-
case 2:
|
|
356
|
-
_state.sent();
|
|
357
|
-
return [
|
|
358
|
-
3,
|
|
359
|
-
4
|
|
360
|
-
];
|
|
361
|
-
case 3:
|
|
362
|
-
e = _state.sent();
|
|
363
|
-
return [
|
|
364
|
-
3,
|
|
365
|
-
4
|
|
366
|
-
];
|
|
367
|
-
case 4:
|
|
368
|
-
expect(callback).toHaveBeenCalledWith(expect.objectContaining(defaultContext), fetchCall, undefined);
|
|
369
|
-
return [
|
|
370
|
-
2
|
|
371
|
-
];
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
}));
|
|
353
|
+
fetchCall = Promise.reject(new Error(JSON.stringify(response)));
|
|
354
|
+
_state.label = 1;
|
|
355
|
+
case 1:
|
|
356
|
+
_state.trys.push([
|
|
357
|
+
1,
|
|
358
|
+
3,
|
|
359
|
+
,
|
|
360
|
+
4
|
|
361
|
+
]);
|
|
362
|
+
return [
|
|
363
|
+
4,
|
|
364
|
+
runner.transform(fetchCall)
|
|
365
|
+
];
|
|
366
|
+
case 2:
|
|
367
|
+
_state.sent();
|
|
368
|
+
return [
|
|
369
|
+
3,
|
|
370
|
+
4
|
|
371
|
+
];
|
|
372
|
+
case 3:
|
|
373
|
+
e = _state.sent();
|
|
374
|
+
return [
|
|
375
|
+
3,
|
|
376
|
+
4
|
|
377
|
+
];
|
|
378
|
+
case 4:
|
|
379
|
+
expect(callback).toHaveBeenCalledWith(expect.objectContaining(defaultContext), fetchCall, undefined);
|
|
380
|
+
return [
|
|
381
|
+
2
|
|
382
|
+
];
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
})();
|
|
386
|
+
});
|
|
375
387
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/client-fetch",
|
|
3
|
-
"version": "12.3.0-prerelease.
|
|
3
|
+
"version": "12.3.0-prerelease.71",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
"build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@o3r/schematics": "^12.3.0-prerelease.
|
|
41
|
+
"@o3r/schematics": "^12.3.0-prerelease.71",
|
|
42
42
|
"@swc/helpers": "~0.5.0",
|
|
43
43
|
"ts-node": "~10.9.2",
|
|
44
44
|
"tslib": "^2.6.2",
|
|
45
45
|
"uuid": "^11.0.5"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@ama-sdk/core": "^12.3.0-prerelease.
|
|
48
|
+
"@ama-sdk/core": "^12.3.0-prerelease.71",
|
|
49
49
|
"@angular-devkit/schematics": "^19.0.0",
|
|
50
50
|
"@angular/cli": "^19.0.0",
|
|
51
51
|
"@angular/common": "^19.0.0",
|
|
52
|
-
"@o3r/schematics": "^12.3.0-prerelease.
|
|
52
|
+
"@o3r/schematics": "^12.3.0-prerelease.71",
|
|
53
53
|
"@schematics/angular": "^19.0.0",
|
|
54
54
|
"isomorphic-fetch": "^3.0.0",
|
|
55
55
|
"typescript": "^5.5.4"
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@ama-sdk/core": "^12.3.0-prerelease.
|
|
81
|
+
"@ama-sdk/core": "^12.3.0-prerelease.71",
|
|
82
82
|
"@angular-devkit/core": "~19.2.0",
|
|
83
83
|
"@angular-devkit/schematics": "~19.2.0",
|
|
84
84
|
"@angular/common": "~19.2.0",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
87
87
|
"@nx/eslint-plugin": "~20.8.0",
|
|
88
88
|
"@nx/jest": "~20.8.0",
|
|
89
|
-
"@o3r/build-helpers": "^12.3.0-prerelease.
|
|
90
|
-
"@o3r/eslint-plugin": "^12.3.0-prerelease.
|
|
91
|
-
"@o3r/test-helpers": "^12.3.0-prerelease.
|
|
89
|
+
"@o3r/build-helpers": "^12.3.0-prerelease.71",
|
|
90
|
+
"@o3r/eslint-plugin": "^12.3.0-prerelease.71",
|
|
91
|
+
"@o3r/test-helpers": "^12.3.0-prerelease.71",
|
|
92
92
|
"@schematics/angular": "~19.2.0",
|
|
93
93
|
"@stylistic/eslint-plugin": "~3.1.0",
|
|
94
94
|
"@stylistic/eslint-plugin-ts": "~3.1.0",
|