@ama-sdk/core 12.1.10 → 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
@@ -49,7 +49,7 @@ function _define_property(obj, key, value) {
49
49
  return obj;
50
50
  }
51
51
  function _ts_generator(thisArg, body) {
52
- var f, y, t, g, _ = {
52
+ var f, y, t, _ = {
53
53
  label: 0,
54
54
  sent: function() {
55
55
  if (t[0] & 1) throw t[1];
@@ -57,12 +57,8 @@ function _ts_generator(thisArg, body) {
57
57
  },
58
58
  trys: [],
59
59
  ops: []
60
- };
61
- return g = {
62
- next: verb(0),
63
- "throw": verb(1),
64
- "return": verb(2)
65
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
60
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
61
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
66
62
  return this;
67
63
  }), g;
68
64
  function verb(n) {
@@ -75,7 +71,7 @@ function _ts_generator(thisArg, body) {
75
71
  }
76
72
  function step(op) {
77
73
  if (f) throw new TypeError("Generator is already executing.");
78
- while(_)try {
74
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
79
75
  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;
80
76
  if (y = 0, t) op = [
81
77
  op[0] & 2,
@@ -173,114 +169,120 @@ describe('Mock intercept', function() {
173
169
  return jest.clearAllMocks();
174
170
  });
175
171
  describe('request plugin', function() {
176
- it('should do nothing if disabled is true', /*#__PURE__*/ _async_to_generator(function() {
177
- var plugin, originalRequest, loaded;
178
- return _ts_generator(this, function(_state) {
179
- switch(_state.label){
180
- case 0:
181
- plugin = new _mockinterceptrequest.MockInterceptRequest({
182
- disabled: true,
183
- adapter: testMockAdapter
184
- });
185
- originalRequest = {
186
- method: 'get',
187
- headers: new Headers({
188
- test: 'true'
189
- }),
190
- basePath: 'myurl'
191
- };
192
- loaded = plugin.load();
193
- return [
194
- 4,
195
- loaded.transform(originalRequest)
196
- ];
197
- case 1:
198
- expect.apply(void 0, [
199
- _state.sent()
200
- ]).toEqual(originalRequest);
201
- expect(initializeSpy).toHaveBeenCalled();
202
- return [
203
- 2
204
- ];
205
- }
206
- });
207
- }));
208
- it('should not stringify provided api', /*#__PURE__*/ _async_to_generator(function() {
209
- var plugin, loaded, originalRequest;
210
- return _ts_generator(this, function(_state) {
211
- switch(_state.label){
212
- case 0:
213
- plugin = new _mockinterceptrequest.MockInterceptRequest({
214
- disabled: false,
215
- adapter: testMockAdapter
216
- });
217
- loaded = plugin.load();
218
- originalRequest = {
219
- method: 'get',
220
- headers: new Headers({
221
- test: 'true'
222
- }),
223
- basePath: 'myurl',
224
- api: 'should not exist'
225
- };
226
- return [
227
- 4,
228
- loaded.transform(originalRequest)
229
- ];
230
- case 1:
231
- _state.sent();
232
- expect(originalRequest.headers.has(_mockinterceptinterface.CUSTOM_MOCK_REQUEST_HEADER)).toBe(true);
233
- expect(Object.keys(JSON.parse(originalRequest.headers.get(_mockinterceptinterface.CUSTOM_MOCK_REQUEST_HEADER)))).not.toContainEqual('api');
234
- return [
235
- 2
236
- ];
237
- }
238
- });
239
- }));
240
- it('should intercept the request', /*#__PURE__*/ _async_to_generator(function() {
241
- var plugin, originalRequest, loaded, transformed, res, text;
242
- return _ts_generator(this, function(_state) {
243
- switch(_state.label){
244
- case 0:
245
- // Disabled because Blob URL is not supported on NodeJS
246
- plugin = new _mockinterceptrequest.MockInterceptRequest({
247
- adapter: testMockAdapter
248
- });
249
- originalRequest = {
250
- headers: new Headers({
251
- test: 'true'
252
- }),
253
- basePath: 'myurl',
254
- method: 'PATCH'
255
- };
256
- loaded = plugin.load();
257
- return [
258
- 4,
259
- loaded.transform(originalRequest)
260
- ];
261
- case 1:
262
- transformed = _state.sent();
263
- return [
264
- 4,
265
- fetch(transformed.basePath, transformed)
266
- ];
267
- case 2:
268
- res = _state.sent();
269
- return [
270
- 4,
271
- res.text()
272
- ];
273
- case 3:
274
- text = _state.sent();
275
- expect(getMockSpy).toHaveBeenCalled();
276
- expect(text).toBe(JSON.stringify(testMock.mockData));
277
- expect(initializeSpy).toHaveBeenCalled();
278
- return [
279
- 2
280
- ];
281
- }
282
- });
283
- }));
172
+ it('should do nothing if disabled is true', function() {
173
+ return _async_to_generator(function() {
174
+ var plugin, originalRequest, loaded;
175
+ return _ts_generator(this, function(_state) {
176
+ switch(_state.label){
177
+ case 0:
178
+ plugin = new _mockinterceptrequest.MockInterceptRequest({
179
+ disabled: true,
180
+ adapter: testMockAdapter
181
+ });
182
+ originalRequest = {
183
+ method: 'get',
184
+ headers: new Headers({
185
+ test: 'true'
186
+ }),
187
+ basePath: 'myurl'
188
+ };
189
+ loaded = plugin.load();
190
+ return [
191
+ 4,
192
+ loaded.transform(originalRequest)
193
+ ];
194
+ case 1:
195
+ expect.apply(void 0, [
196
+ _state.sent()
197
+ ]).toEqual(originalRequest);
198
+ expect(initializeSpy).toHaveBeenCalled();
199
+ return [
200
+ 2
201
+ ];
202
+ }
203
+ });
204
+ })();
205
+ });
206
+ it('should not stringify provided api', function() {
207
+ return _async_to_generator(function() {
208
+ var plugin, loaded, originalRequest;
209
+ return _ts_generator(this, function(_state) {
210
+ switch(_state.label){
211
+ case 0:
212
+ plugin = new _mockinterceptrequest.MockInterceptRequest({
213
+ disabled: false,
214
+ adapter: testMockAdapter
215
+ });
216
+ loaded = plugin.load();
217
+ originalRequest = {
218
+ method: 'get',
219
+ headers: new Headers({
220
+ test: 'true'
221
+ }),
222
+ basePath: 'myurl',
223
+ api: 'should not exist'
224
+ };
225
+ return [
226
+ 4,
227
+ loaded.transform(originalRequest)
228
+ ];
229
+ case 1:
230
+ _state.sent();
231
+ expect(originalRequest.headers.has(_mockinterceptinterface.CUSTOM_MOCK_REQUEST_HEADER)).toBe(true);
232
+ expect(Object.keys(JSON.parse(originalRequest.headers.get(_mockinterceptinterface.CUSTOM_MOCK_REQUEST_HEADER)))).not.toContainEqual('api');
233
+ return [
234
+ 2
235
+ ];
236
+ }
237
+ });
238
+ })();
239
+ });
240
+ it('should intercept the request', function() {
241
+ return _async_to_generator(function() {
242
+ var plugin, originalRequest, loaded, transformed, res, text;
243
+ return _ts_generator(this, function(_state) {
244
+ switch(_state.label){
245
+ case 0:
246
+ // Disabled because Blob URL is not supported on NodeJS
247
+ plugin = new _mockinterceptrequest.MockInterceptRequest({
248
+ adapter: testMockAdapter
249
+ });
250
+ originalRequest = {
251
+ headers: new Headers({
252
+ test: 'true'
253
+ }),
254
+ basePath: 'myurl',
255
+ method: 'PATCH'
256
+ };
257
+ loaded = plugin.load();
258
+ return [
259
+ 4,
260
+ loaded.transform(originalRequest)
261
+ ];
262
+ case 1:
263
+ transformed = _state.sent();
264
+ return [
265
+ 4,
266
+ fetch(transformed.basePath, transformed)
267
+ ];
268
+ case 2:
269
+ res = _state.sent();
270
+ return [
271
+ 4,
272
+ res.text()
273
+ ];
274
+ case 3:
275
+ text = _state.sent();
276
+ expect(getMockSpy).toHaveBeenCalled();
277
+ expect(text).toBe(JSON.stringify(testMock.mockData));
278
+ expect(initializeSpy).toHaveBeenCalled();
279
+ return [
280
+ 2
281
+ ];
282
+ }
283
+ });
284
+ })();
285
+ });
284
286
  });
285
287
  describe('fetch plugin', function() {
286
288
  describe('when using an initialization function', function() {
@@ -297,148 +299,154 @@ describe('Mock intercept', function() {
297
299
  adapter: asyncMockAdapter
298
300
  });
299
301
  });
300
- it('should call initialize fn', /*#__PURE__*/ _async_to_generator(function() {
301
- var loadedPlugin, testData;
302
+ it('should call initialize fn', function() {
303
+ return _async_to_generator(function() {
304
+ var loadedPlugin, testData;
305
+ return _ts_generator(this, function(_state) {
306
+ switch(_state.label){
307
+ case 0:
308
+ loadedPlugin = plugin.load({
309
+ fetchPlugins: [],
310
+ url: 'myurl',
311
+ apiClient: apiClient,
312
+ options: {
313
+ headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
314
+ }
315
+ });
316
+ testData = {
317
+ test: true
318
+ };
319
+ return [
320
+ 4,
321
+ loadedPlugin.transform(Promise.resolve(testData))
322
+ ];
323
+ case 1:
324
+ _state.sent();
325
+ expect(initializeSpy).toHaveBeenCalled();
326
+ expect(getMockSpy).not.toHaveBeenCalled();
327
+ expect(getLatestMockSpy).toHaveBeenCalledWith('testOperation');
328
+ return [
329
+ 2
330
+ ];
331
+ }
332
+ });
333
+ })();
334
+ });
335
+ it('should throw if there is no request plugin', function() {
336
+ var config = {
337
+ fetchPlugins: [],
338
+ url: 'myurl',
339
+ apiClient: {
340
+ options: {
341
+ requestPlugins: []
342
+ }
343
+ },
344
+ options: {
345
+ headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
346
+ }
347
+ };
348
+ expect(function() {
349
+ return plugin.load(config);
350
+ }).toThrow();
351
+ });
352
+ });
353
+ });
354
+ describe('with delay', function() {
355
+ it('should delay the response of the specific number', function() {
356
+ return _async_to_generator(function() {
357
+ var plugin, loadedPlugin, callback, run;
302
358
  return _ts_generator(this, function(_state) {
303
359
  switch(_state.label){
304
360
  case 0:
361
+ plugin = new _mockinterceptfetch.MockInterceptFetch({
362
+ adapter: testMockAdapter,
363
+ delayTiming: 700
364
+ });
305
365
  loadedPlugin = plugin.load({
306
366
  fetchPlugins: [],
307
- url: 'myurl',
367
+ url: '',
308
368
  apiClient: apiClient,
309
369
  options: {
310
370
  headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
311
371
  }
312
372
  });
313
- testData = {
314
- test: true
315
- };
373
+ callback = jest.fn();
374
+ run = loadedPlugin.transform(Promise.resolve({})).then(callback);
316
375
  return [
317
376
  4,
318
- loadedPlugin.transform(Promise.resolve(testData))
377
+ jest.advanceTimersByTimeAsync(699)
319
378
  ];
320
379
  case 1:
321
380
  _state.sent();
322
- expect(initializeSpy).toHaveBeenCalled();
323
- expect(getMockSpy).not.toHaveBeenCalled();
324
- expect(getLatestMockSpy).toHaveBeenCalledWith('testOperation');
381
+ expect(callback).not.toHaveBeenCalled();
382
+ return [
383
+ 4,
384
+ jest.advanceTimersByTimeAsync(1)
385
+ ];
386
+ case 2:
387
+ _state.sent();
388
+ expect(callback).toHaveBeenCalled();
389
+ return [
390
+ 4,
391
+ run
392
+ ];
393
+ case 3:
394
+ _state.sent();
325
395
  return [
326
396
  2
327
397
  ];
328
398
  }
329
399
  });
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({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
400
+ })();
401
+ });
402
+ it('should delay the response based on callback', function() {
403
+ return _async_to_generator(function() {
404
+ var plugin, loadedPlugin, callback, run;
405
+ return _ts_generator(this, function(_state) {
406
+ switch(_state.label){
407
+ case 0:
408
+ plugin = new _mockinterceptfetch.MockInterceptFetch({
409
+ adapter: testMockAdapter,
410
+ delayTiming: function() {
411
+ return 800;
412
+ }
413
+ });
414
+ loadedPlugin = plugin.load({
415
+ fetchPlugins: [],
416
+ url: '',
417
+ apiClient: apiClient,
418
+ options: {
419
+ headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
420
+ }
421
+ });
422
+ callback = jest.fn();
423
+ run = loadedPlugin.transform(Promise.resolve({})).then(callback);
424
+ return [
425
+ 4,
426
+ jest.advanceTimersByTimeAsync(799)
427
+ ];
428
+ case 1:
429
+ _state.sent();
430
+ expect(callback).not.toHaveBeenCalled();
431
+ return [
432
+ 4,
433
+ jest.advanceTimersByTimeAsync(1)
434
+ ];
435
+ case 2:
436
+ _state.sent();
437
+ expect(callback).toHaveBeenCalled();
438
+ return [
439
+ 4,
440
+ run
441
+ ];
442
+ case 3:
443
+ _state.sent();
444
+ return [
445
+ 2
446
+ ];
342
447
  }
343
- };
344
- expect(function() {
345
- return plugin.load(config);
346
- }).toThrow();
347
- });
448
+ });
449
+ })();
348
450
  });
349
451
  });
350
- describe('with delay', function() {
351
- it('should delay the response of the specific number', /*#__PURE__*/ _async_to_generator(function() {
352
- var plugin, loadedPlugin, callback, run;
353
- return _ts_generator(this, function(_state) {
354
- switch(_state.label){
355
- case 0:
356
- plugin = new _mockinterceptfetch.MockInterceptFetch({
357
- adapter: testMockAdapter,
358
- delayTiming: 700
359
- });
360
- loadedPlugin = plugin.load({
361
- fetchPlugins: [],
362
- url: '',
363
- apiClient: apiClient,
364
- options: {
365
- headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
366
- }
367
- });
368
- callback = jest.fn();
369
- run = loadedPlugin.transform(Promise.resolve({})).then(callback);
370
- return [
371
- 4,
372
- jest.advanceTimersByTimeAsync(699)
373
- ];
374
- case 1:
375
- _state.sent();
376
- expect(callback).not.toHaveBeenCalled();
377
- return [
378
- 4,
379
- jest.advanceTimersByTimeAsync(1)
380
- ];
381
- case 2:
382
- _state.sent();
383
- expect(callback).toHaveBeenCalled();
384
- return [
385
- 4,
386
- run
387
- ];
388
- case 3:
389
- _state.sent();
390
- return [
391
- 2
392
- ];
393
- }
394
- });
395
- }));
396
- it('should delay the response based on callback', /*#__PURE__*/ _async_to_generator(function() {
397
- var plugin, loadedPlugin, callback, run;
398
- return _ts_generator(this, function(_state) {
399
- switch(_state.label){
400
- case 0:
401
- plugin = new _mockinterceptfetch.MockInterceptFetch({
402
- adapter: testMockAdapter,
403
- delayTiming: function() {
404
- return 800;
405
- }
406
- });
407
- loadedPlugin = plugin.load({
408
- fetchPlugins: [],
409
- url: '',
410
- apiClient: apiClient,
411
- options: {
412
- headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
413
- }
414
- });
415
- callback = jest.fn();
416
- run = loadedPlugin.transform(Promise.resolve({})).then(callback);
417
- return [
418
- 4,
419
- jest.advanceTimersByTimeAsync(799)
420
- ];
421
- case 1:
422
- _state.sent();
423
- expect(callback).not.toHaveBeenCalled();
424
- return [
425
- 4,
426
- jest.advanceTimersByTimeAsync(1)
427
- ];
428
- case 2:
429
- _state.sent();
430
- expect(callback).toHaveBeenCalled();
431
- return [
432
- 4,
433
- run
434
- ];
435
- case 3:
436
- _state.sent();
437
- return [
438
- 2
439
- ];
440
- }
441
- });
442
- }));
443
- });
444
452
  });
@@ -117,7 +117,7 @@ function _object_spread_props(target, source) {
117
117
  return target;
118
118
  }
119
119
  function _ts_generator(thisArg, body) {
120
- var f, y, t, g, _ = {
120
+ var f, y, t, _ = {
121
121
  label: 0,
122
122
  sent: function() {
123
123
  if (t[0] & 1) throw t[1];
@@ -125,12 +125,8 @@ function _ts_generator(thisArg, body) {
125
125
  },
126
126
  trys: [],
127
127
  ops: []
128
- };
129
- return g = {
130
- next: verb(0),
131
- "throw": verb(1),
132
- "return": verb(2)
133
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
128
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
129
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
134
130
  return this;
135
131
  }), g;
136
132
  function verb(n) {
@@ -143,7 +139,7 @@ function _ts_generator(thisArg, body) {
143
139
  }
144
140
  function step(op) {
145
141
  if (f) throw new TypeError("Generator is already executing.");
146
- while(_)try {
142
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
147
143
  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;
148
144
  if (y = 0, t) op = [
149
145
  op[0] & 2,
@@ -329,13 +325,13 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
329
325
  value: /** @inheritDoc */ function load(context) {
330
326
  var _this = this;
331
327
  return {
332
- transform: /*#__PURE__*/ function() {
333
- var _ref = _async_to_generator(function(fetchCall) {
328
+ transform: function(fetchCall) {
329
+ return _async_to_generator(function() {
334
330
  var markId, response, exception;
335
331
  return _ts_generator(this, function(_state) {
336
332
  switch(_state.label){
337
333
  case 0:
338
- markId = _this.openMark(context.url, context.options);
334
+ markId = this.openMark(context.url, context.options);
339
335
  _state.label = 1;
340
336
  case 1:
341
337
  _state.trys.push([
@@ -350,7 +346,7 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
350
346
  ];
351
347
  case 2:
352
348
  response = _state.sent();
353
- _this.closeMark(markId, response);
349
+ this.closeMark(markId, response);
354
350
  return [
355
351
  2,
356
352
  response
@@ -358,7 +354,7 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
358
354
  case 3:
359
355
  exception = _state.sent();
360
356
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access -- type is explicitly `any`
361
- _this.closeMarkWithError(markId, _instanceof(exception, Error) ? exception : new Error(exception.toString()));
357
+ this.closeMarkWithError(markId, _instanceof(exception, Error) ? exception : new Error(exception.toString()));
362
358
  throw exception;
363
359
  case 4:
364
360
  return [
@@ -366,11 +362,8 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
366
362
  ];
367
363
  }
368
364
  });
369
- });
370
- return function(fetchCall) {
371
- return _ref.apply(this, arguments);
372
- };
373
- }()
365
+ }).call(_this);
366
+ }
374
367
  };
375
368
  }
376
369
  }