@ama-sdk/core 12.1.8 → 12.1.11

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 (111) hide show
  1. package/cjs/clients/api-angular-client.js +13 -18
  2. package/cjs/clients/api-fetch-client.js +16 -21
  3. package/cjs/fwk/api.helpers.js +11 -11
  4. package/cjs/fwk/date.js +5 -5
  5. package/cjs/fwk/errors.js +7 -7
  6. package/cjs/fwk/mocks/alf-mock-adapter.js +58 -60
  7. package/cjs/fwk/mocks/base-mock-adapter.js +15 -19
  8. package/cjs/fwk/mocks/helpers.js +3 -3
  9. package/cjs/fwk/param-serialization.js +6 -6
  10. package/cjs/fwk/reviver.js +4 -4
  11. package/cjs/plugins/abort/abort.spec.js +83 -81
  12. package/cjs/plugins/additional-params/additional-params.request.js +18 -25
  13. package/cjs/plugins/additional-params/additional-params.spec.js +194 -186
  14. package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
  15. package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
  16. package/cjs/plugins/api-key/api-key.request.js +12 -19
  17. package/cjs/plugins/api-key/api-key.spec.js +50 -50
  18. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +25 -36
  19. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
  20. package/cjs/plugins/client-facts/client-facts.request.js +18 -25
  21. package/cjs/plugins/client-facts/client-facts.spec.js +218 -208
  22. package/cjs/plugins/concurrent/concurrent.fetch.js +12 -20
  23. package/cjs/plugins/concurrent/concurrent.spec.js +99 -99
  24. package/cjs/plugins/custom-info/custom-info.spec.js +90 -90
  25. package/cjs/plugins/fetch-cache/fetch-cache.spec.js +100 -98
  26. package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
  27. package/cjs/plugins/json-token/json-token.spec.js +109 -107
  28. package/cjs/plugins/keepalive/keepalive.request.js +7 -12
  29. package/cjs/plugins/keepalive/keepalive.spec.js +32 -34
  30. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +11 -23
  31. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
  32. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
  33. package/cjs/plugins/mock-intercept/mock-intercept.angular.js +94 -100
  34. package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
  35. package/cjs/plugins/mock-intercept/mock-intercept.interface.js +3 -3
  36. package/cjs/plugins/mock-intercept/mock-intercept.request.js +12 -19
  37. package/cjs/plugins/mock-intercept/mock-intercept.spec.js +245 -237
  38. package/cjs/plugins/perf-metric/perf-metric.fetch.js +11 -18
  39. package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +19 -27
  40. package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
  41. package/cjs/plugins/raw-response-info/raw-response-info.spec.js +67 -67
  42. package/cjs/plugins/retry/retry.fetch.js +18 -27
  43. package/cjs/plugins/retry/retry.spec.js +233 -225
  44. package/cjs/plugins/reviver/reviver.spec.js +88 -86
  45. package/cjs/plugins/session-id/session-id.spec.js +98 -94
  46. package/cjs/plugins/si-token/si-token.spec.js +27 -29
  47. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
  48. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
  49. package/cjs/plugins/timeout/timeout.fetch.js +16 -22
  50. package/cjs/plugins/timeout/timeout.spec.js +211 -205
  51. package/cjs/plugins/url-rewrite/url-rewrite.request.js +9 -16
  52. package/cjs/plugins/url-rewrite/url-rewrite.spec.js +48 -48
  53. package/cjs/plugins/wait-for/wait-for.fetch.js +19 -29
  54. package/cjs/plugins/wait-for/wait-for.spec.js +211 -203
  55. package/cjs/utils/crypto.js +15 -27
  56. package/cjs/utils/generic-api.js +9 -14
  57. package/cjs/utils/json-token.js +19 -26
  58. package/cjs/utils/json-token.spec.js +495 -497
  59. package/cjs/utils/mime-types.js +3 -3
  60. package/esm2015/clients/api-angular-client.js +13 -18
  61. package/esm2015/clients/api-fetch-client.js +16 -21
  62. package/esm2015/fwk/mocks/alf-mock-adapter.js +58 -60
  63. package/esm2015/fwk/mocks/base-mock-adapter.js +15 -19
  64. package/esm2015/plugins/abort/abort.spec.js +83 -81
  65. package/esm2015/plugins/additional-params/additional-params.request.js +15 -22
  66. package/esm2015/plugins/additional-params/additional-params.spec.js +194 -186
  67. package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
  68. package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
  69. package/esm2015/plugins/api-key/api-key.request.js +12 -19
  70. package/esm2015/plugins/api-key/api-key.spec.js +50 -50
  71. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +21 -32
  72. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
  73. package/esm2015/plugins/client-facts/client-facts.request.js +15 -22
  74. package/esm2015/plugins/client-facts/client-facts.spec.js +218 -208
  75. package/esm2015/plugins/concurrent/concurrent.fetch.js +12 -20
  76. package/esm2015/plugins/concurrent/concurrent.spec.js +99 -99
  77. package/esm2015/plugins/custom-info/custom-info.spec.js +90 -90
  78. package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +100 -98
  79. package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
  80. package/esm2015/plugins/json-token/json-token.spec.js +109 -107
  81. package/esm2015/plugins/keepalive/keepalive.request.js +7 -12
  82. package/esm2015/plugins/keepalive/keepalive.spec.js +32 -34
  83. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +8 -20
  84. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
  85. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
  86. package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +94 -100
  87. package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
  88. package/esm2015/plugins/mock-intercept/mock-intercept.request.js +12 -19
  89. package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +245 -237
  90. package/esm2015/plugins/perf-metric/perf-metric.fetch.js +11 -18
  91. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +15 -23
  92. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
  93. package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +67 -67
  94. package/esm2015/plugins/retry/retry.fetch.js +18 -27
  95. package/esm2015/plugins/retry/retry.spec.js +233 -225
  96. package/esm2015/plugins/reviver/reviver.spec.js +88 -86
  97. package/esm2015/plugins/session-id/session-id.spec.js +98 -94
  98. package/esm2015/plugins/si-token/si-token.spec.js +27 -29
  99. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
  100. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
  101. package/esm2015/plugins/timeout/timeout.fetch.js +13 -19
  102. package/esm2015/plugins/timeout/timeout.spec.js +211 -205
  103. package/esm2015/plugins/url-rewrite/url-rewrite.request.js +9 -16
  104. package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +48 -48
  105. package/esm2015/plugins/wait-for/wait-for.fetch.js +19 -29
  106. package/esm2015/plugins/wait-for/wait-for.spec.js +211 -203
  107. package/esm2015/utils/crypto.js +8 -20
  108. package/esm2015/utils/generic-api.js +9 -14
  109. package/esm2015/utils/json-token.js +10 -17
  110. package/esm2015/utils/json-token.spec.js +495 -497
  111. package/package.json +6 -6
@@ -41,7 +41,7 @@ function _define_property(obj, key, value) {
41
41
  return obj;
42
42
  }
43
43
  function _ts_generator(thisArg, body) {
44
- var f, y, t, g, _ = {
44
+ var f, y, t, _ = {
45
45
  label: 0,
46
46
  sent: function() {
47
47
  if (t[0] & 1) throw t[1];
@@ -49,12 +49,8 @@ function _ts_generator(thisArg, body) {
49
49
  },
50
50
  trys: [],
51
51
  ops: []
52
- };
53
- return g = {
54
- next: verb(0),
55
- "throw": verb(1),
56
- "return": verb(2)
57
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
52
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
53
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
58
54
  return this;
59
55
  }), g;
60
56
  function verb(n) {
@@ -67,7 +63,7 @@ function _ts_generator(thisArg, body) {
67
63
  }
68
64
  function step(op) {
69
65
  if (f) throw new TypeError("Generator is already executing.");
70
- while(_)try {
66
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
71
67
  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;
72
68
  if (y = 0, t) op = [
73
69
  op[0] & 2,
@@ -169,114 +165,120 @@ describe('Mock intercept', function() {
169
165
  return jest.clearAllMocks();
170
166
  });
171
167
  describe('request plugin', function() {
172
- it('should do nothing if disabled is true', /*#__PURE__*/ _async_to_generator(function() {
173
- var plugin, originalRequest, loaded;
174
- return _ts_generator(this, function(_state) {
175
- switch(_state.label){
176
- case 0:
177
- plugin = new MockInterceptRequest({
178
- disabled: true,
179
- adapter: testMockAdapter
180
- });
181
- originalRequest = {
182
- method: 'get',
183
- headers: new Headers({
184
- test: 'true'
185
- }),
186
- basePath: 'myurl'
187
- };
188
- loaded = plugin.load();
189
- return [
190
- 4,
191
- loaded.transform(originalRequest)
192
- ];
193
- case 1:
194
- expect.apply(void 0, [
195
- _state.sent()
196
- ]).toEqual(originalRequest);
197
- expect(initializeSpy).toHaveBeenCalled();
198
- return [
199
- 2
200
- ];
201
- }
202
- });
203
- }));
204
- it('should not stringify provided api', /*#__PURE__*/ _async_to_generator(function() {
205
- var plugin, loaded, originalRequest;
206
- return _ts_generator(this, function(_state) {
207
- switch(_state.label){
208
- case 0:
209
- plugin = new MockInterceptRequest({
210
- disabled: false,
211
- adapter: testMockAdapter
212
- });
213
- loaded = plugin.load();
214
- originalRequest = {
215
- method: 'get',
216
- headers: new Headers({
217
- test: 'true'
218
- }),
219
- basePath: 'myurl',
220
- api: 'should not exist'
221
- };
222
- return [
223
- 4,
224
- loaded.transform(originalRequest)
225
- ];
226
- case 1:
227
- _state.sent();
228
- expect(originalRequest.headers.has(CUSTOM_MOCK_REQUEST_HEADER)).toBe(true);
229
- expect(Object.keys(JSON.parse(originalRequest.headers.get(CUSTOM_MOCK_REQUEST_HEADER)))).not.toContainEqual('api');
230
- return [
231
- 2
232
- ];
233
- }
234
- });
235
- }));
236
- it('should intercept the request', /*#__PURE__*/ _async_to_generator(function() {
237
- var plugin, originalRequest, loaded, transformed, res, text;
238
- return _ts_generator(this, function(_state) {
239
- switch(_state.label){
240
- case 0:
241
- // Disabled because Blob URL is not supported on NodeJS
242
- plugin = new MockInterceptRequest({
243
- adapter: testMockAdapter
244
- });
245
- originalRequest = {
246
- headers: new Headers({
247
- test: 'true'
248
- }),
249
- basePath: 'myurl',
250
- method: 'PATCH'
251
- };
252
- loaded = plugin.load();
253
- return [
254
- 4,
255
- loaded.transform(originalRequest)
256
- ];
257
- case 1:
258
- transformed = _state.sent();
259
- return [
260
- 4,
261
- fetch(transformed.basePath, transformed)
262
- ];
263
- case 2:
264
- res = _state.sent();
265
- return [
266
- 4,
267
- res.text()
268
- ];
269
- case 3:
270
- text = _state.sent();
271
- expect(getMockSpy).toHaveBeenCalled();
272
- expect(text).toBe(JSON.stringify(testMock.mockData));
273
- expect(initializeSpy).toHaveBeenCalled();
274
- return [
275
- 2
276
- ];
277
- }
278
- });
279
- }));
168
+ it('should do nothing if disabled is true', function() {
169
+ return _async_to_generator(function() {
170
+ var plugin, originalRequest, loaded;
171
+ return _ts_generator(this, function(_state) {
172
+ switch(_state.label){
173
+ case 0:
174
+ plugin = new MockInterceptRequest({
175
+ disabled: true,
176
+ adapter: testMockAdapter
177
+ });
178
+ originalRequest = {
179
+ method: 'get',
180
+ headers: new Headers({
181
+ test: 'true'
182
+ }),
183
+ basePath: 'myurl'
184
+ };
185
+ loaded = plugin.load();
186
+ return [
187
+ 4,
188
+ loaded.transform(originalRequest)
189
+ ];
190
+ case 1:
191
+ expect.apply(void 0, [
192
+ _state.sent()
193
+ ]).toEqual(originalRequest);
194
+ expect(initializeSpy).toHaveBeenCalled();
195
+ return [
196
+ 2
197
+ ];
198
+ }
199
+ });
200
+ })();
201
+ });
202
+ it('should not stringify provided api', function() {
203
+ return _async_to_generator(function() {
204
+ var plugin, loaded, originalRequest;
205
+ return _ts_generator(this, function(_state) {
206
+ switch(_state.label){
207
+ case 0:
208
+ plugin = new MockInterceptRequest({
209
+ disabled: false,
210
+ adapter: testMockAdapter
211
+ });
212
+ loaded = plugin.load();
213
+ originalRequest = {
214
+ method: 'get',
215
+ headers: new Headers({
216
+ test: 'true'
217
+ }),
218
+ basePath: 'myurl',
219
+ api: 'should not exist'
220
+ };
221
+ return [
222
+ 4,
223
+ loaded.transform(originalRequest)
224
+ ];
225
+ case 1:
226
+ _state.sent();
227
+ expect(originalRequest.headers.has(CUSTOM_MOCK_REQUEST_HEADER)).toBe(true);
228
+ expect(Object.keys(JSON.parse(originalRequest.headers.get(CUSTOM_MOCK_REQUEST_HEADER)))).not.toContainEqual('api');
229
+ return [
230
+ 2
231
+ ];
232
+ }
233
+ });
234
+ })();
235
+ });
236
+ it('should intercept the request', function() {
237
+ return _async_to_generator(function() {
238
+ var plugin, originalRequest, loaded, transformed, res, text;
239
+ return _ts_generator(this, function(_state) {
240
+ switch(_state.label){
241
+ case 0:
242
+ // Disabled because Blob URL is not supported on NodeJS
243
+ plugin = new MockInterceptRequest({
244
+ adapter: testMockAdapter
245
+ });
246
+ originalRequest = {
247
+ headers: new Headers({
248
+ test: 'true'
249
+ }),
250
+ basePath: 'myurl',
251
+ method: 'PATCH'
252
+ };
253
+ loaded = plugin.load();
254
+ return [
255
+ 4,
256
+ loaded.transform(originalRequest)
257
+ ];
258
+ case 1:
259
+ transformed = _state.sent();
260
+ return [
261
+ 4,
262
+ fetch(transformed.basePath, transformed)
263
+ ];
264
+ case 2:
265
+ res = _state.sent();
266
+ return [
267
+ 4,
268
+ res.text()
269
+ ];
270
+ case 3:
271
+ text = _state.sent();
272
+ expect(getMockSpy).toHaveBeenCalled();
273
+ expect(text).toBe(JSON.stringify(testMock.mockData));
274
+ expect(initializeSpy).toHaveBeenCalled();
275
+ return [
276
+ 2
277
+ ];
278
+ }
279
+ });
280
+ })();
281
+ });
280
282
  });
281
283
  describe('fetch plugin', function() {
282
284
  describe('when using an initialization function', function() {
@@ -293,148 +295,154 @@ describe('Mock intercept', function() {
293
295
  adapter: asyncMockAdapter
294
296
  });
295
297
  });
296
- it('should call initialize fn', /*#__PURE__*/ _async_to_generator(function() {
297
- var loadedPlugin, testData;
298
+ it('should call initialize fn', function() {
299
+ return _async_to_generator(function() {
300
+ var loadedPlugin, testData;
301
+ return _ts_generator(this, function(_state) {
302
+ switch(_state.label){
303
+ case 0:
304
+ loadedPlugin = plugin.load({
305
+ fetchPlugins: [],
306
+ url: 'myurl',
307
+ apiClient: apiClient,
308
+ options: {
309
+ headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
310
+ }
311
+ });
312
+ testData = {
313
+ test: true
314
+ };
315
+ return [
316
+ 4,
317
+ loadedPlugin.transform(Promise.resolve(testData))
318
+ ];
319
+ case 1:
320
+ _state.sent();
321
+ expect(initializeSpy).toHaveBeenCalled();
322
+ expect(getMockSpy).not.toHaveBeenCalled();
323
+ expect(getLatestMockSpy).toHaveBeenCalledWith('testOperation');
324
+ return [
325
+ 2
326
+ ];
327
+ }
328
+ });
329
+ })();
330
+ });
331
+ it('should throw if there is no request plugin', function() {
332
+ var config = {
333
+ fetchPlugins: [],
334
+ url: 'myurl',
335
+ apiClient: {
336
+ options: {
337
+ requestPlugins: []
338
+ }
339
+ },
340
+ options: {
341
+ headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
342
+ }
343
+ };
344
+ expect(function() {
345
+ return plugin.load(config);
346
+ }).toThrow();
347
+ });
348
+ });
349
+ });
350
+ describe('with delay', function() {
351
+ it('should delay the response of the specific number', function() {
352
+ return _async_to_generator(function() {
353
+ var plugin, loadedPlugin, callback, run;
298
354
  return _ts_generator(this, function(_state) {
299
355
  switch(_state.label){
300
356
  case 0:
357
+ plugin = new MockInterceptFetch({
358
+ adapter: testMockAdapter,
359
+ delayTiming: 700
360
+ });
301
361
  loadedPlugin = plugin.load({
302
362
  fetchPlugins: [],
303
- url: 'myurl',
363
+ url: '',
304
364
  apiClient: apiClient,
305
365
  options: {
306
366
  headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
307
367
  }
308
368
  });
309
- testData = {
310
- test: true
311
- };
369
+ callback = jest.fn();
370
+ run = loadedPlugin.transform(Promise.resolve({})).then(callback);
312
371
  return [
313
372
  4,
314
- loadedPlugin.transform(Promise.resolve(testData))
373
+ jest.advanceTimersByTimeAsync(699)
315
374
  ];
316
375
  case 1:
317
376
  _state.sent();
318
- expect(initializeSpy).toHaveBeenCalled();
319
- expect(getMockSpy).not.toHaveBeenCalled();
320
- expect(getLatestMockSpy).toHaveBeenCalledWith('testOperation');
377
+ expect(callback).not.toHaveBeenCalled();
378
+ return [
379
+ 4,
380
+ jest.advanceTimersByTimeAsync(1)
381
+ ];
382
+ case 2:
383
+ _state.sent();
384
+ expect(callback).toHaveBeenCalled();
385
+ return [
386
+ 4,
387
+ run
388
+ ];
389
+ case 3:
390
+ _state.sent();
321
391
  return [
322
392
  2
323
393
  ];
324
394
  }
325
395
  });
326
- }));
327
- it('should throw if there is no request plugin', function() {
328
- var config = {
329
- fetchPlugins: [],
330
- url: 'myurl',
331
- apiClient: {
332
- options: {
333
- requestPlugins: []
334
- }
335
- },
336
- options: {
337
- headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
396
+ })();
397
+ });
398
+ it('should delay the response based on callback', function() {
399
+ return _async_to_generator(function() {
400
+ var plugin, loadedPlugin, callback, run;
401
+ return _ts_generator(this, function(_state) {
402
+ switch(_state.label){
403
+ case 0:
404
+ plugin = new MockInterceptFetch({
405
+ adapter: testMockAdapter,
406
+ delayTiming: function() {
407
+ return 800;
408
+ }
409
+ });
410
+ loadedPlugin = plugin.load({
411
+ fetchPlugins: [],
412
+ url: '',
413
+ apiClient: apiClient,
414
+ options: {
415
+ headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
416
+ }
417
+ });
418
+ callback = jest.fn();
419
+ run = loadedPlugin.transform(Promise.resolve({})).then(callback);
420
+ return [
421
+ 4,
422
+ jest.advanceTimersByTimeAsync(799)
423
+ ];
424
+ case 1:
425
+ _state.sent();
426
+ expect(callback).not.toHaveBeenCalled();
427
+ return [
428
+ 4,
429
+ jest.advanceTimersByTimeAsync(1)
430
+ ];
431
+ case 2:
432
+ _state.sent();
433
+ expect(callback).toHaveBeenCalled();
434
+ return [
435
+ 4,
436
+ run
437
+ ];
438
+ case 3:
439
+ _state.sent();
440
+ return [
441
+ 2
442
+ ];
338
443
  }
339
- };
340
- expect(function() {
341
- return plugin.load(config);
342
- }).toThrow();
343
- });
444
+ });
445
+ })();
344
446
  });
345
447
  });
346
- describe('with delay', function() {
347
- it('should delay the response of the specific number', /*#__PURE__*/ _async_to_generator(function() {
348
- var plugin, loadedPlugin, callback, run;
349
- return _ts_generator(this, function(_state) {
350
- switch(_state.label){
351
- case 0:
352
- plugin = new MockInterceptFetch({
353
- adapter: testMockAdapter,
354
- delayTiming: 700
355
- });
356
- loadedPlugin = plugin.load({
357
- fetchPlugins: [],
358
- url: '',
359
- apiClient: apiClient,
360
- options: {
361
- headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
362
- }
363
- });
364
- callback = jest.fn();
365
- run = loadedPlugin.transform(Promise.resolve({})).then(callback);
366
- return [
367
- 4,
368
- jest.advanceTimersByTimeAsync(699)
369
- ];
370
- case 1:
371
- _state.sent();
372
- expect(callback).not.toHaveBeenCalled();
373
- return [
374
- 4,
375
- jest.advanceTimersByTimeAsync(1)
376
- ];
377
- case 2:
378
- _state.sent();
379
- expect(callback).toHaveBeenCalled();
380
- return [
381
- 4,
382
- run
383
- ];
384
- case 3:
385
- _state.sent();
386
- return [
387
- 2
388
- ];
389
- }
390
- });
391
- }));
392
- it('should delay the response based on callback', /*#__PURE__*/ _async_to_generator(function() {
393
- var plugin, loadedPlugin, callback, run;
394
- return _ts_generator(this, function(_state) {
395
- switch(_state.label){
396
- case 0:
397
- plugin = new MockInterceptFetch({
398
- adapter: testMockAdapter,
399
- delayTiming: function() {
400
- return 800;
401
- }
402
- });
403
- loadedPlugin = plugin.load({
404
- fetchPlugins: [],
405
- url: '',
406
- apiClient: apiClient,
407
- options: {
408
- headers: new Headers(_define_property({}, CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
409
- }
410
- });
411
- callback = jest.fn();
412
- run = loadedPlugin.transform(Promise.resolve({})).then(callback);
413
- return [
414
- 4,
415
- jest.advanceTimersByTimeAsync(799)
416
- ];
417
- case 1:
418
- _state.sent();
419
- expect(callback).not.toHaveBeenCalled();
420
- return [
421
- 4,
422
- jest.advanceTimersByTimeAsync(1)
423
- ];
424
- case 2:
425
- _state.sent();
426
- expect(callback).toHaveBeenCalled();
427
- return [
428
- 4,
429
- run
430
- ];
431
- case 3:
432
- _state.sent();
433
- return [
434
- 2
435
- ];
436
- }
437
- });
438
- }));
439
- });
440
448
  });
@@ -106,7 +106,7 @@ function _object_spread_props(target, source) {
106
106
  return target;
107
107
  }
108
108
  function _ts_generator(thisArg, body) {
109
- var f, y, t, g, _ = {
109
+ var f, y, t, _ = {
110
110
  label: 0,
111
111
  sent: function() {
112
112
  if (t[0] & 1) throw t[1];
@@ -114,12 +114,8 @@ function _ts_generator(thisArg, body) {
114
114
  },
115
115
  trys: [],
116
116
  ops: []
117
- };
118
- return g = {
119
- next: verb(0),
120
- "throw": verb(1),
121
- "return": verb(2)
122
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
117
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
118
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
123
119
  return this;
124
120
  }), g;
125
121
  function verb(n) {
@@ -132,7 +128,7 @@ function _ts_generator(thisArg, body) {
132
128
  }
133
129
  function step(op) {
134
130
  if (f) throw new TypeError("Generator is already executing.");
135
- while(_)try {
131
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
136
132
  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;
137
133
  if (y = 0, t) op = [
138
134
  op[0] & 2,
@@ -322,13 +318,13 @@ import { v4 } from 'uuid';
322
318
  value: /** @inheritDoc */ function load(context) {
323
319
  var _this = this;
324
320
  return {
325
- transform: /*#__PURE__*/ function() {
326
- var _ref = _async_to_generator(function(fetchCall) {
321
+ transform: function(fetchCall) {
322
+ return _async_to_generator(function() {
327
323
  var markId, response, exception;
328
324
  return _ts_generator(this, function(_state) {
329
325
  switch(_state.label){
330
326
  case 0:
331
- markId = _this.openMark(context.url, context.options);
327
+ markId = this.openMark(context.url, context.options);
332
328
  _state.label = 1;
333
329
  case 1:
334
330
  _state.trys.push([
@@ -343,7 +339,7 @@ import { v4 } from 'uuid';
343
339
  ];
344
340
  case 2:
345
341
  response = _state.sent();
346
- _this.closeMark(markId, response);
342
+ this.closeMark(markId, response);
347
343
  return [
348
344
  2,
349
345
  response
@@ -351,7 +347,7 @@ import { v4 } from 'uuid';
351
347
  case 3:
352
348
  exception = _state.sent();
353
349
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access -- type is explicitly `any`
354
- _this.closeMarkWithError(markId, _instanceof(exception, Error) ? exception : new Error(exception.toString()));
350
+ this.closeMarkWithError(markId, _instanceof(exception, Error) ? exception : new Error(exception.toString()));
355
351
  throw exception;
356
352
  case 4:
357
353
  return [
@@ -359,11 +355,8 @@ import { v4 } from 'uuid';
359
355
  ];
360
356
  }
361
357
  });
362
- });
363
- return function(fetchCall) {
364
- return _ref.apply(this, arguments);
365
- };
366
- }()
358
+ }).call(_this);
359
+ }
367
360
  };
368
361
  }
369
362
  }