@ama-sdk/core 11.0.0-next.0 → 11.0.0-next.1

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 (268) hide show
  1. package/README.md +4 -1
  2. package/cjs/clients/api-angular-client.js +45 -23
  3. package/cjs/clients/api-beacon-client.js +64 -20
  4. package/cjs/clients/api-fetch-client.js +66 -21
  5. package/cjs/fwk/Reviver.js +7 -7
  6. package/cjs/fwk/api.helper.spec.js +20 -20
  7. package/cjs/fwk/api.helpers.js +14 -14
  8. package/cjs/fwk/core/api-client.js +1 -1
  9. package/cjs/fwk/core/base-api-constructor.js +1 -1
  10. package/cjs/fwk/date.js +9 -9
  11. package/cjs/fwk/date.spec.js +25 -25
  12. package/cjs/fwk/errors.js +3 -3
  13. package/cjs/fwk/mocks/alf-mock-adapter.js +4 -4
  14. package/cjs/fwk/mocks/base-mock-adapter.js +2 -2
  15. package/cjs/fwk/mocks/helpers.js +3 -3
  16. package/cjs/fwk/reviver.spec.js +46 -10
  17. package/cjs/plugins/additional-params/additional-params-sync.request.js +2 -2
  18. package/cjs/plugins/additional-params/additional-params.request.js +3 -3
  19. package/cjs/plugins/additional-params/additional-params.spec.js +30 -30
  20. package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
  21. package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +13 -13
  22. package/cjs/plugins/api-key/api-key.request.js +2 -2
  23. package/cjs/plugins/api-key/api-key.spec.js +11 -11
  24. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +6 -5
  25. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +33 -33
  26. package/cjs/plugins/client-facts/client-facts.request.js +3 -3
  27. package/cjs/plugins/client-facts/client-facts.spec.js +27 -27
  28. package/cjs/plugins/concurrent/concurrent.fetch.js +1 -0
  29. package/cjs/plugins/concurrent/concurrent.spec.js +4 -4
  30. package/cjs/plugins/custom-info/custom-info.spec.js +15 -15
  31. package/cjs/plugins/exception/exception.reply.js +2 -2
  32. package/cjs/plugins/exception/exception.spec.js +15 -15
  33. package/cjs/plugins/fetch-cache/fetch-cache.request.js +4 -4
  34. package/cjs/plugins/fetch-cache/fetch-cache.spec.js +20 -20
  35. package/cjs/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
  36. package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +8 -8
  37. package/cjs/plugins/json-token/json-token.reply.js +5 -5
  38. package/cjs/plugins/json-token/json-token.request.js +4 -4
  39. package/cjs/plugins/json-token/json-token.spec.js +24 -24
  40. package/cjs/plugins/keepalive/keepalive.request.js +2 -2
  41. package/cjs/plugins/keepalive/keepalive.spec.js +4 -4
  42. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +32 -40
  43. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +30 -26
  44. package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +3 -3
  45. package/cjs/plugins/mock-intercept/mock-intercept.interface.js +2 -2
  46. package/cjs/plugins/mock-intercept/mock-intercept.request.js +3 -3
  47. package/cjs/plugins/mock-intercept/mock-intercept.spec.js +28 -28
  48. package/cjs/plugins/perf-metric/perf-metric.fetch.js +1 -1
  49. package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +9 -9
  50. package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +11 -11
  51. package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +94 -94
  52. package/cjs/plugins/raw-response-info/raw-response-info.spec.js +12 -12
  53. package/cjs/plugins/retry/retry.spec.js +20 -20
  54. package/cjs/plugins/reviver/reviver.reply.js +35 -2
  55. package/cjs/plugins/reviver/reviver.spec.js +6 -6
  56. package/cjs/plugins/session-id/session-id.request.js +7 -6
  57. package/cjs/plugins/session-id/session-id.spec.js +13 -13
  58. package/cjs/plugins/si-token/si-token.spec.js +9 -9
  59. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +4 -4
  60. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +44 -44
  61. package/cjs/plugins/timeout/timeout.fetch.js +12 -10
  62. package/cjs/plugins/timeout/timeout.spec.js +13 -13
  63. package/cjs/plugins/url-rewrite/url-rewrite.spec.js +9 -9
  64. package/cjs/plugins/wait-for/wait-for.spec.js +9 -9
  65. package/cjs/utils/crypto.js +14 -14
  66. package/cjs/utils/generic-api.js +253 -0
  67. package/cjs/utils/index.js +1 -0
  68. package/cjs/utils/json-token.js +30 -30
  69. package/cjs/utils/json-token.spec.js +31 -31
  70. package/cli/files-pack.cjs +12 -12
  71. package/cli/files-pack.cjs.map +1 -1
  72. package/esm2015/clients/api-angular-client.js +49 -27
  73. package/esm2015/clients/api-beacon-client.js +65 -21
  74. package/esm2015/clients/api-fetch-client.js +70 -25
  75. package/esm2015/clients/index.js +2 -2
  76. package/esm2015/fwk/Reviver.js +10 -7
  77. package/esm2015/fwk/api.helper.spec.js +21 -21
  78. package/esm2015/fwk/api.helpers.js +14 -14
  79. package/esm2015/fwk/core/api-client.js +1 -1
  80. package/esm2015/fwk/core/base-api-constructor.js +1 -1
  81. package/esm2015/fwk/core/index.js +2 -2
  82. package/esm2015/fwk/date.js +9 -9
  83. package/esm2015/fwk/date.spec.js +26 -26
  84. package/esm2015/fwk/errors.js +3 -3
  85. package/esm2015/fwk/index.js +10 -10
  86. package/esm2015/fwk/mocks/alf-mock-adapter.js +6 -6
  87. package/esm2015/fwk/mocks/base-mock-adapter.js +3 -3
  88. package/esm2015/fwk/mocks/helpers.js +3 -3
  89. package/esm2015/fwk/mocks/index.js +10 -10
  90. package/esm2015/fwk/mocks/random-mock-adapter.js +1 -1
  91. package/esm2015/fwk/mocks/sequential-mock-adapter.js +1 -1
  92. package/esm2015/fwk/reviver.spec.js +47 -11
  93. package/esm2015/plugins/additional-params/additional-params-sync.request.js +3 -3
  94. package/esm2015/plugins/additional-params/additional-params.request.js +3 -3
  95. package/esm2015/plugins/additional-params/additional-params.spec.js +32 -32
  96. package/esm2015/plugins/additional-params/index.js +2 -2
  97. package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
  98. package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +14 -14
  99. package/esm2015/plugins/api-configuration-override/index.js +1 -1
  100. package/esm2015/plugins/api-key/api-key.request.js +2 -2
  101. package/esm2015/plugins/api-key/api-key.spec.js +12 -12
  102. package/esm2015/plugins/api-key/index.js +1 -1
  103. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +6 -6
  104. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +34 -34
  105. package/esm2015/plugins/bot-protection-fingerprint/index.js +1 -1
  106. package/esm2015/plugins/client-facts/client-facts.request.js +4 -4
  107. package/esm2015/plugins/client-facts/client-facts.spec.js +28 -28
  108. package/esm2015/plugins/client-facts/index.js +1 -1
  109. package/esm2015/plugins/concurrent/concurrent.fetch.js +1 -0
  110. package/esm2015/plugins/concurrent/concurrent.spec.js +5 -5
  111. package/esm2015/plugins/concurrent/index.js +1 -1
  112. package/esm2015/plugins/core/index.js +4 -4
  113. package/esm2015/plugins/custom-info/custom-info.spec.js +17 -17
  114. package/esm2015/plugins/custom-info/index.js +1 -1
  115. package/esm2015/plugins/exception/exception.reply.js +4 -4
  116. package/esm2015/plugins/exception/exception.spec.js +18 -18
  117. package/esm2015/plugins/exception/index.js +1 -1
  118. package/esm2015/plugins/fetch-cache/fetch-cache.request.js +4 -4
  119. package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +21 -21
  120. package/esm2015/plugins/fetch-cache/index.js +1 -1
  121. package/esm2015/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
  122. package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +9 -9
  123. package/esm2015/plugins/fetch-credentials/index.js +1 -1
  124. package/esm2015/plugins/index.js +25 -25
  125. package/esm2015/plugins/json-token/index.js +2 -2
  126. package/esm2015/plugins/json-token/json-token.reply.js +5 -5
  127. package/esm2015/plugins/json-token/json-token.request.js +4 -4
  128. package/esm2015/plugins/json-token/json-token.spec.js +27 -27
  129. package/esm2015/plugins/keepalive/index.js +1 -1
  130. package/esm2015/plugins/keepalive/keepalive.request.js +2 -2
  131. package/esm2015/plugins/keepalive/keepalive.spec.js +5 -5
  132. package/esm2015/plugins/mgw-mdw-auth/index.js +1 -1
  133. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +34 -42
  134. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +32 -28
  135. package/esm2015/plugins/mock-intercept/index.js +2 -2
  136. package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +5 -5
  137. package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +2 -2
  138. package/esm2015/plugins/mock-intercept/mock-intercept.request.js +4 -4
  139. package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +32 -32
  140. package/esm2015/plugins/perf-metric/index.js +1 -1
  141. package/esm2015/plugins/perf-metric/perf-metric.fetch.js +2 -2
  142. package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +10 -10
  143. package/esm2015/plugins/pii-tokenizer/index.js +1 -1
  144. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +12 -12
  145. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +96 -96
  146. package/esm2015/plugins/raw-response-info/index.js +1 -1
  147. package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +14 -14
  148. package/esm2015/plugins/retry/index.js +1 -1
  149. package/esm2015/plugins/retry/retry.fetch.js +1 -1
  150. package/esm2015/plugins/retry/retry.spec.js +21 -21
  151. package/esm2015/plugins/reviver/index.js +1 -1
  152. package/esm2015/plugins/reviver/reviver.reply.js +35 -2
  153. package/esm2015/plugins/reviver/reviver.spec.js +8 -8
  154. package/esm2015/plugins/session-id/index.js +1 -1
  155. package/esm2015/plugins/session-id/session-id.request.js +8 -7
  156. package/esm2015/plugins/session-id/session-id.spec.js +14 -14
  157. package/esm2015/plugins/si-token/index.js +1 -1
  158. package/esm2015/plugins/si-token/si-token.request.js +1 -1
  159. package/esm2015/plugins/si-token/si-token.spec.js +10 -10
  160. package/esm2015/plugins/simple-api-key-authentication/index.js +1 -1
  161. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +5 -5
  162. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +46 -46
  163. package/esm2015/plugins/timeout/index.js +1 -1
  164. package/esm2015/plugins/timeout/timeout.fetch.js +13 -11
  165. package/esm2015/plugins/timeout/timeout.spec.js +15 -15
  166. package/esm2015/plugins/url-rewrite/index.js +1 -1
  167. package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +10 -10
  168. package/esm2015/plugins/wait-for/index.js +1 -1
  169. package/esm2015/plugins/wait-for/wait-for.spec.js +10 -10
  170. package/esm2015/public_api.js +4 -4
  171. package/esm2015/utils/crypto.js +15 -15
  172. package/esm2015/utils/generic-api.js +245 -0
  173. package/esm2015/utils/index.js +6 -5
  174. package/esm2015/utils/json-token.js +32 -32
  175. package/esm2015/utils/json-token.spec.js +32 -32
  176. package/package.json +67 -40
  177. package/schematics/ng-add/index.d.ts +4 -2
  178. package/schematics/ng-add/index.d.ts.map +1 -1
  179. package/schematics/ng-add/index.js +58 -40
  180. package/schematics/ng-add/index.js.map +1 -1
  181. package/src/clients/api-angular-client.d.ts +6 -3
  182. package/src/clients/api-angular-client.d.ts.map +1 -1
  183. package/src/clients/api-angular-client.js +31 -16
  184. package/src/clients/api-angular-client.js.map +1 -1
  185. package/src/clients/api-beacon-client.d.ts +7 -5
  186. package/src/clients/api-beacon-client.d.ts.map +1 -1
  187. package/src/clients/api-beacon-client.js +24 -14
  188. package/src/clients/api-beacon-client.js.map +1 -1
  189. package/src/clients/api-fetch-client.d.ts +5 -3
  190. package/src/clients/api-fetch-client.d.ts.map +1 -1
  191. package/src/clients/api-fetch-client.js +26 -14
  192. package/src/clients/api-fetch-client.js.map +1 -1
  193. package/src/fwk/Reviver.d.ts +16 -4
  194. package/src/fwk/Reviver.d.ts.map +1 -1
  195. package/src/fwk/Reviver.js +9 -6
  196. package/src/fwk/Reviver.js.map +1 -1
  197. package/src/fwk/api.helpers.d.ts +1 -1
  198. package/src/fwk/api.helpers.d.ts.map +1 -1
  199. package/src/fwk/api.helpers.js +1 -1
  200. package/src/fwk/api.helpers.js.map +1 -1
  201. package/src/fwk/core/api-client.d.ts +36 -1
  202. package/src/fwk/core/api-client.d.ts.map +1 -1
  203. package/src/fwk/core/api-client.js.map +1 -1
  204. package/src/fwk/date.js.map +1 -1
  205. package/src/fwk/mocks/alf-mock-adapter.js.map +1 -1
  206. package/src/fwk/mocks/base-mock-adapter.js.map +1 -1
  207. package/src/fwk/mocks/helpers.js.map +1 -1
  208. package/src/fwk/mocks/random-mock-adapter.js.map +1 -1
  209. package/src/fwk/mocks/sequential-mock-adapter.js.map +1 -1
  210. package/src/plugins/additional-params/additional-params-sync.request.js.map +1 -1
  211. package/src/plugins/additional-params/additional-params.request.js.map +1 -1
  212. package/src/plugins/api-configuration-override/api-configuration-override.request.js.map +1 -1
  213. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts +1 -1
  214. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts.map +1 -1
  215. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +1 -1
  216. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js.map +1 -1
  217. package/src/plugins/client-facts/client-facts.request.js.map +1 -1
  218. package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -1
  219. package/src/plugins/concurrent/concurrent.fetch.js +1 -0
  220. package/src/plugins/concurrent/concurrent.fetch.js.map +1 -1
  221. package/src/plugins/core/plugin.d.ts +6 -1
  222. package/src/plugins/core/plugin.d.ts.map +1 -1
  223. package/src/plugins/core/reply-plugin.d.ts +0 -2
  224. package/src/plugins/core/reply-plugin.d.ts.map +1 -1
  225. package/src/plugins/core/request-plugin.d.ts +2 -0
  226. package/src/plugins/core/request-plugin.d.ts.map +1 -1
  227. package/src/plugins/exception/exception.reply.js.map +1 -1
  228. package/src/plugins/fetch-cache/fetch-cache.request.js.map +1 -1
  229. package/src/plugins/json-token/json-token.reply.js.map +1 -1
  230. package/src/plugins/json-token/json-token.request.js.map +1 -1
  231. package/src/plugins/keepalive/keepalive.request.js.map +1 -1
  232. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts +2 -2
  233. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts.map +1 -1
  234. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +26 -28
  235. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js.map +1 -1
  236. package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -1
  237. package/src/plugins/mock-intercept/mock-intercept.request.js.map +1 -1
  238. package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -1
  239. package/src/plugins/pii-tokenizer/pii-tokenizer.request.d.ts.map +1 -1
  240. package/src/plugins/pii-tokenizer/pii-tokenizer.request.js.map +1 -1
  241. package/src/plugins/raw-response-info/raw-response-info.reply.js.map +1 -1
  242. package/src/plugins/retry/retry.fetch.js.map +1 -1
  243. package/src/plugins/reviver/reviver.reply.d.ts +7 -0
  244. package/src/plugins/reviver/reviver.reply.d.ts.map +1 -1
  245. package/src/plugins/reviver/reviver.reply.js +12 -1
  246. package/src/plugins/reviver/reviver.reply.js.map +1 -1
  247. package/src/plugins/session-id/session-id.request.d.ts +1 -0
  248. package/src/plugins/session-id/session-id.request.d.ts.map +1 -1
  249. package/src/plugins/session-id/session-id.request.js +1 -0
  250. package/src/plugins/session-id/session-id.request.js.map +1 -1
  251. package/src/plugins/si-token/si-token.request.js.map +1 -1
  252. package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js.map +1 -1
  253. package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -1
  254. package/src/plugins/timeout/timeout.fetch.js +2 -0
  255. package/src/plugins/timeout/timeout.fetch.js.map +1 -1
  256. package/src/plugins/wait-for/wait-for.fetch.js.map +1 -1
  257. package/src/utils/crypto.js.map +1 -1
  258. package/src/utils/encoder.js.map +1 -1
  259. package/src/utils/generic-api.d.ts +39 -0
  260. package/src/utils/generic-api.d.ts.map +1 -0
  261. package/src/utils/generic-api.js +43 -0
  262. package/src/utils/generic-api.js.map +1 -0
  263. package/src/utils/index.d.ts +1 -0
  264. package/src/utils/index.d.ts.map +1 -1
  265. package/src/utils/index.js +1 -0
  266. package/src/utils/index.js.map +1 -1
  267. package/src/utils/json-token.d.ts.map +1 -1
  268. package/src/utils/json-token.js.map +1 -1
@@ -193,10 +193,10 @@ function _ts_generator(thisArg, body) {
193
193
  };
194
194
  }
195
195
  }
196
- import { ExceptionReply } from "../plugins/exception";
197
- import { ReviverReply } from "../plugins/reviver";
198
- import { extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, tokenizeRequestOptions } from "../fwk/api.helpers";
199
- import { EmptyResponseError } from "../fwk/errors";
196
+ import { ExceptionReply } from '../plugins/exception';
197
+ import { ReviverReply } from '../plugins/reviver';
198
+ import { extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, tokenizeRequestOptions } from '../fwk/api.helpers';
199
+ import { EmptyResponseError } from '../fwk/errors';
200
200
  var DEFAULT_OPTIONS = {
201
201
  replyPlugins: [
202
202
  new ReviverReply(),
@@ -222,24 +222,18 @@ var DEFAULT_OPTIONS = {
222
222
  }
223
223
  },
224
224
  {
225
- key: "prepareOptions",
226
- value: function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata) {
225
+ key: "getRequestOptions",
226
+ value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
227
227
  var _this = this;
228
228
  return _async_to_generator(function() {
229
- var options, opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, err;
229
+ var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
230
230
  return _ts_generator(this, function(_state) {
231
231
  switch(_state.label){
232
232
  case 0:
233
- options = {
234
- method: method,
235
- headers: new Headers(filterUndefinedValues(headers)),
236
- body: body,
237
- queryParams: filterUndefinedValues(queryParams),
238
- basePath: url,
239
- tokenizedOptions: tokenizedOptions,
240
- metadata: metadata
241
- };
242
- opts = options;
233
+ opts = _object_spread_props(_object_spread({}, requestOptionsParameters), {
234
+ headers: new Headers(filterUndefinedValues(requestOptionsParameters.headers)),
235
+ queryParams: filterUndefinedValues(requestOptionsParameters.queryParams)
236
+ });
243
237
  if (!_this.options.requestPlugins) return [
244
238
  3,
245
239
  8
@@ -264,7 +258,8 @@ var DEFAULT_OPTIONS = {
264
258
  return [
265
259
  4,
266
260
  plugin.load({
267
- logger: _this.options.logger
261
+ logger: _this.options.logger,
262
+ apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
268
263
  }).transform(opts)
269
264
  ];
270
265
  case 3:
@@ -312,6 +307,29 @@ var DEFAULT_OPTIONS = {
312
307
  })();
313
308
  }
314
309
  },
310
+ {
311
+ key: "prepareOptions",
312
+ value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
313
+ var _this = this;
314
+ return _async_to_generator(function() {
315
+ return _ts_generator(this, function(_state) {
316
+ return [
317
+ 2,
318
+ _this.getRequestOptions({
319
+ headers: headers,
320
+ method: method,
321
+ basePath: url,
322
+ queryParams: queryParams,
323
+ body: body,
324
+ metadata: metadata,
325
+ tokenizedOptions: tokenizedOptions,
326
+ api: api
327
+ })
328
+ ];
329
+ });
330
+ })();
331
+ }
332
+ },
315
333
  {
316
334
  key: "prepareUrl",
317
335
  value: /** @inheritdoc */ function prepareUrl1(url) {
@@ -336,11 +354,11 @@ var DEFAULT_OPTIONS = {
336
354
  value: function processCall(url, options, apiType, apiName, revivers, operationId) {
337
355
  var _this = this;
338
356
  return _async_to_generator(function() {
339
- var response, root, exception, origin, headers, controller, asyncResponse, e, reviver, replyPlugins, parsedData, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, pluginRunner, err;
357
+ var response, root, exception, origin, headers, asyncResponse, e, reviver, replyPlugins, parsedData, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, pluginRunner, err;
340
358
  return _ts_generator(this, function(_state) {
341
359
  switch(_state.label){
342
360
  case 0:
343
- origin = options.headers.get("Origin");
361
+ origin = options.headers.get('Origin');
344
362
  _state.label = 1;
345
363
  case 1:
346
364
  _state.trys.push([
@@ -350,14 +368,13 @@ var DEFAULT_OPTIONS = {
350
368
  4
351
369
  ]);
352
370
  headers = Object.fromEntries(options.headers.entries());
353
- controller = typeof AbortController !== "undefined" ? new AbortController() : undefined;
354
- if (controller) {
355
- options.signal = controller.signal;
356
- }
357
371
  asyncResponse = new Promise(function(resolve, reject) {
372
+ var _options_metadata;
358
373
  var data;
359
- _this.options.httpClient.request(options.method, url, _object_spread_props(_object_spread({}, options), {
360
- observe: "response",
374
+ var metadataSignal = (_options_metadata = options.metadata) === null || _options_metadata === void 0 ? void 0 : _options_metadata.signal;
375
+ metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
376
+ var subscription = _this.options.httpClient.request(options.method, url, _object_spread_props(_object_spread({}, options), {
377
+ observe: 'response',
361
378
  headers: headers
362
379
  })).subscribe({
363
380
  next: function(res) {
@@ -370,6 +387,11 @@ var DEFAULT_OPTIONS = {
370
387
  return resolve(data);
371
388
  }
372
389
  });
390
+ metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
391
+ metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener('abort', function() {
392
+ subscription.unsubscribe();
393
+ reject(metadataSignal.reason);
394
+ });
373
395
  });
374
396
  return [
375
397
  4,
@@ -384,7 +406,7 @@ var DEFAULT_OPTIONS = {
384
406
  ];
385
407
  case 3:
386
408
  e = _state.sent();
387
- exception = new EmptyResponseError(e.message || "Fail to Fetch", undefined, {
409
+ exception = new EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
388
410
  apiName: apiName,
389
411
  operationId: operationId,
390
412
  url: url,
@@ -30,6 +30,13 @@ function _define_property(obj, key, value) {
30
30
  }
31
31
  return obj;
32
32
  }
33
+ function _instanceof(left, right) {
34
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
35
+ return !!right[Symbol.hasInstance](left);
36
+ } else {
37
+ return left instanceof right;
38
+ }
39
+ }
33
40
  function _object_spread(target) {
34
41
  for(var i = 1; i < arguments.length; i++){
35
42
  var source = arguments[i] != null ? arguments[i] : {};
@@ -45,7 +52,31 @@ function _object_spread(target) {
45
52
  }
46
53
  return target;
47
54
  }
48
- import { extractQueryParams, filterUndefinedValues, prepareUrl, processFormData, tokenizeRequestOptions } from "../fwk/api.helpers";
55
+ function ownKeys(object, enumerableOnly) {
56
+ var keys = Object.keys(object);
57
+ if (Object.getOwnPropertySymbols) {
58
+ var symbols = Object.getOwnPropertySymbols(object);
59
+ if (enumerableOnly) {
60
+ symbols = symbols.filter(function(sym) {
61
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
62
+ });
63
+ }
64
+ keys.push.apply(keys, symbols);
65
+ }
66
+ return keys;
67
+ }
68
+ function _object_spread_props(target, source) {
69
+ source = source != null ? source : {};
70
+ if (Object.getOwnPropertyDescriptors) {
71
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
72
+ } else {
73
+ ownKeys(Object(source)).forEach(function(key) {
74
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
75
+ });
76
+ }
77
+ return target;
78
+ }
79
+ import { extractQueryParams, filterUndefinedValues, prepareUrl, processFormData, tokenizeRequestOptions } from '../fwk/api.helpers';
49
80
  var DEFAULT_OPTIONS = {
50
81
  replyPlugins: [],
51
82
  requestPlugins: [],
@@ -54,8 +85,10 @@ var DEFAULT_OPTIONS = {
54
85
  /**
55
86
  * Determine if the given value is a promise
56
87
  * @param value The value to test
57
- */ var isPromise = function(value) {
58
- return value && typeof value.then === "function";
88
+ */ // NOTE: the `extends unknown` is required for ESM build with TSC
89
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
90
+ var isPromise = function(value) {
91
+ return _instanceof(value, Promise);
59
92
  };
60
93
  /**
61
94
  * The Beacon API client is an implementation of the API Client using the Navigator Beacon API.
@@ -65,8 +98,8 @@ var DEFAULT_OPTIONS = {
65
98
  function ApiBeaconClient(options) {
66
99
  _class_call_check(this, ApiBeaconClient);
67
100
  /** @inheritdoc */ _define_property(this, "options", void 0);
68
- if (typeof navigator === "undefined" || !navigator.sendBeacon) {
69
- throw new Error("Beacon API is not supported in this context");
101
+ if (typeof navigator === 'undefined' || !navigator.sendBeacon) {
102
+ throw new Error('Beacon API is not supported in this context');
70
103
  }
71
104
  this.options = _object_spread({}, DEFAULT_OPTIONS, options);
72
105
  }
@@ -78,28 +111,24 @@ var DEFAULT_OPTIONS = {
78
111
  }
79
112
  },
80
113
  {
81
- key: "prepareOptions",
82
- value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata) {
83
- if (method.toUpperCase() !== "POST") {
84
- throw new Error("Unsupported method: ".concat(method, ". The beacon API only supports POST."));
114
+ key: "getRequestOptions",
115
+ value: /** @inheritdoc */ function getRequestOptions(options) {
116
+ if (options.method.toUpperCase() !== 'POST') {
117
+ throw new Error("Unsupported method: ".concat(options.method, ". The beacon API only supports POST."));
85
118
  }
86
- var options = {
87
- method: method,
88
- headers: new Headers(filterUndefinedValues(headers)),
89
- body: body,
90
- queryParams: filterUndefinedValues(queryParams),
91
- basePath: url,
92
- tokenizedOptions: tokenizedOptions,
93
- metadata: metadata
94
- };
95
- var opts = options;
119
+ var opts = _object_spread_props(_object_spread({}, options), {
120
+ headers: new Headers(filterUndefinedValues(options.headers)),
121
+ queryParams: filterUndefinedValues(options.queryParams)
122
+ });
96
123
  if (this.options.requestPlugins) {
97
124
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
98
125
  try {
99
126
  for(var _iterator = this.options.requestPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
100
127
  var plugin = _step.value;
128
+ var _options_api;
101
129
  var changedOpt = plugin.load({
102
- logger: this.options.logger
130
+ logger: this.options.logger,
131
+ apiName: (_options_api = options.api) === null || _options_api === void 0 ? void 0 : _options_api.apiName
103
132
  }).transform(opts);
104
133
  if (isPromise(changedOpt)) {
105
134
  throw new Error("Request plugin ".concat(plugin.constructor.name, " has async transform method. Only sync methods are supported with the Beacon client."));
@@ -125,6 +154,21 @@ var DEFAULT_OPTIONS = {
125
154
  return Promise.resolve(opts);
126
155
  }
127
156
  },
157
+ {
158
+ key: "prepareOptions",
159
+ value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
160
+ return this.getRequestOptions({
161
+ headers: headers,
162
+ method: method,
163
+ basePath: url,
164
+ queryParams: queryParams,
165
+ body: body,
166
+ metadata: metadata,
167
+ tokenizedOptions: tokenizedOptions,
168
+ api: api
169
+ });
170
+ }
171
+ },
128
172
  {
129
173
  key: "prepareUrl",
130
174
  value: /** @inheritdoc */ function prepareUrl1(url, queryParameters) {
@@ -147,7 +191,7 @@ var DEFAULT_OPTIONS = {
147
191
  key: "processCall",
148
192
  value: /** @inheritdoc */ function processCall(url, options, _apiType, _apiName, _revivers, _operationId) {
149
193
  var headers = _object_spread({
150
- type: "application/json"
194
+ type: 'application/json'
151
195
  }, options.headers.entries());
152
196
  var blob = new Blob(options.body ? [
153
197
  JSON.stringify(options.body)
@@ -95,6 +95,30 @@ function _object_spread(target) {
95
95
  }
96
96
  return target;
97
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
+ }
98
122
  function _to_consumable_array(arr) {
99
123
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
100
124
  }
@@ -201,10 +225,10 @@ function _ts_generator(thisArg, body) {
201
225
  };
202
226
  }
203
227
  }
204
- import { ExceptionReply } from "../plugins/exception";
205
- import { ReviverReply } from "../plugins/reviver";
206
- import { extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, tokenizeRequestOptions } from "../fwk/api.helpers";
207
- import { CanceledCallError, EmptyResponseError, ResponseJSONParseError } from "../fwk/errors";
228
+ import { ExceptionReply } from '../plugins/exception';
229
+ import { ReviverReply } from '../plugins/reviver';
230
+ import { extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, tokenizeRequestOptions } from '../fwk/api.helpers';
231
+ import { CanceledCallError, EmptyResponseError, ResponseJSONParseError } from '../fwk/errors';
208
232
  var DEFAULT_OPTIONS = {
209
233
  replyPlugins: [
210
234
  new ReviverReply(),
@@ -236,24 +260,18 @@ var DEFAULT_OPTIONS = {
236
260
  }
237
261
  },
238
262
  {
239
- key: "prepareOptions",
240
- value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata) {
263
+ key: "getRequestOptions",
264
+ value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
241
265
  var _this = this;
242
266
  return _async_to_generator(function() {
243
- var options, opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, err;
267
+ var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
244
268
  return _ts_generator(this, function(_state) {
245
269
  switch(_state.label){
246
270
  case 0:
247
- options = {
248
- method: method,
249
- headers: new Headers(filterUndefinedValues(headers)),
250
- body: body,
251
- queryParams: filterUndefinedValues(queryParams),
252
- basePath: url,
253
- tokenizedOptions: tokenizedOptions,
254
- metadata: metadata
255
- };
256
- opts = options;
271
+ opts = _object_spread_props(_object_spread({}, requestOptionsParameters), {
272
+ headers: new Headers(filterUndefinedValues(requestOptionsParameters.headers)),
273
+ queryParams: filterUndefinedValues(requestOptionsParameters.queryParams)
274
+ });
257
275
  if (!_this.options.requestPlugins) return [
258
276
  3,
259
277
  8
@@ -278,7 +296,8 @@ var DEFAULT_OPTIONS = {
278
296
  return [
279
297
  4,
280
298
  plugin.load({
281
- logger: _this.options.logger
299
+ logger: _this.options.logger,
300
+ apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
282
301
  }).transform(opts)
283
302
  ];
284
303
  case 3:
@@ -326,6 +345,29 @@ var DEFAULT_OPTIONS = {
326
345
  })();
327
346
  }
328
347
  },
348
+ {
349
+ key: "prepareOptions",
350
+ value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
351
+ var _this = this;
352
+ return _async_to_generator(function() {
353
+ return _ts_generator(this, function(_state) {
354
+ return [
355
+ 2,
356
+ _this.getRequestOptions({
357
+ headers: headers,
358
+ method: method,
359
+ basePath: url,
360
+ queryParams: queryParams,
361
+ body: body,
362
+ metadata: metadata,
363
+ tokenizedOptions: tokenizedOptions,
364
+ api: api
365
+ })
366
+ ];
367
+ });
368
+ })();
369
+ }
370
+ },
329
371
  {
330
372
  key: "prepareUrl",
331
373
  value: /** @inheritdoc */ function prepareUrl1(url) {
@@ -344,11 +386,11 @@ var DEFAULT_OPTIONS = {
344
386
  value: function processCall(url, options, apiType, apiName, revivers, operationId) {
345
387
  var _this = this;
346
388
  return _async_to_generator(function() {
347
- var response, asyncResponse, root, body, exception, origin, controller, loadedPlugins, _loadedPlugins, canStart, isCanceledBy, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, e, reviver, replyPlugins, parsedData, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, pluginRunner, err;
389
+ 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;
348
390
  return _ts_generator(this, function(_state) {
349
391
  switch(_state.label){
350
392
  case 0:
351
- origin = options.headers.get("Origin");
393
+ origin = options.headers.get('Origin');
352
394
  _state.label = 1;
353
395
  case 1:
354
396
  _state.trys.push([
@@ -357,10 +399,13 @@ var DEFAULT_OPTIONS = {
357
399
  ,
358
400
  6
359
401
  ]);
402
+ metadataSignal = (_options_metadata = options.metadata) === null || _options_metadata === void 0 ? void 0 : _options_metadata.signal;
403
+ metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
360
404
  controller = new AbortController();
361
- if (controller) {
362
- options.signal = controller.signal;
363
- }
405
+ options.signal = controller.signal;
406
+ metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener('abort', function() {
407
+ return controller.abort();
408
+ });
364
409
  loadedPlugins = [];
365
410
  if (_this.options.fetchPlugins) {
366
411
  ;
@@ -436,7 +481,7 @@ var DEFAULT_OPTIONS = {
436
481
  if (_instanceof(e, CanceledCallError)) {
437
482
  exception = e;
438
483
  } else {
439
- exception = new EmptyResponseError(e.message || "Fail to Fetch", undefined, {
484
+ exception = new EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
440
485
  apiName: apiName,
441
486
  operationId: operationId,
442
487
  url: url,
@@ -451,7 +496,7 @@ var DEFAULT_OPTIONS = {
451
496
  try {
452
497
  root = body ? JSON.parse(body) : undefined;
453
498
  } catch (e) {
454
- exception = new ResponseJSONParseError(e.message || "Fail to parse response body", response && response.status || 0, body, {
499
+ exception = new ResponseJSONParseError(e.message || 'Fail to parse response body', response && response.status || 0, body, {
455
500
  apiName: apiName,
456
501
  operationId: operationId,
457
502
  url: url,
@@ -1,2 +1,2 @@
1
- export * from "./api-beacon-client";
2
- export * from "./api-fetch-client";
1
+ export * from './api-beacon-client';
2
+ export * from './api-fetch-client';
@@ -1,10 +1,11 @@
1
- /** Reviver type */ /**
1
+ /**
2
2
  * Used in case of maps (dictionaries): All values of the map must be of the same type. reviveWithType will be called
3
3
  * for each of these elements.
4
4
  * @param dictionaries
5
5
  * @param reviver
6
+ * @param options Reviver options
6
7
  */ export function reviveMap(data) {
7
- var dictionaries = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null, reviver = arguments.length > 2 ? arguments[2] : void 0;
8
+ var dictionaries = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null, reviver = arguments.length > 2 ? arguments[2] : void 0, options = arguments.length > 3 ? arguments[3] : void 0;
8
9
  if (!data) {
9
10
  return undefined;
10
11
  }
@@ -12,7 +13,7 @@
12
13
  for(var key in data){
13
14
  // eslint-disable-next-line no-prototype-builtins
14
15
  if (data.hasOwnProperty(key)) {
15
- revived[key] = reviver(data[key], dictionaries);
16
+ revived[key] = reviver(data[key], dictionaries, options);
16
17
  }
17
18
  }
18
19
  return revived;
@@ -22,13 +23,14 @@
22
23
  * @param data
23
24
  * @param dictionaries
24
25
  * @param reviver
26
+ * @param options Reviver options
25
27
  */ export function reviveArray(data) {
26
- var dictionaries = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null, reviver = arguments.length > 2 ? arguments[2] : void 0;
28
+ var dictionaries = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null, reviver = arguments.length > 2 ? arguments[2] : void 0, options = arguments.length > 3 ? arguments[3] : void 0;
27
29
  if (!data) {
28
30
  return undefined;
29
31
  }
30
32
  for(var i = 0; i < data.length; i++){
31
- data[i] = reviver(data[i], dictionaries);
33
+ data[i] = reviver(data[i], dictionaries, options);
32
34
  }
33
35
  return data;
34
36
  }
@@ -38,13 +40,14 @@
38
40
  * @param dictionary : Specific dictionary associated to T
39
41
  * @param reviver : Function to revive the Data object, once retrieved from the dictionary.
40
42
  * If not passed as argument, the map entry won't be revived
43
+ * @param options Reviver options
41
44
  * @returns Map of id : {revived dictionarized item}
42
- */ export function reviveDictionarizedArray(ids, dictionary, reviver) {
45
+ */ export function reviveDictionarizedArray(ids, dictionary, reviver, options) {
43
46
  if (!ids) {
44
47
  return undefined;
45
48
  }
46
49
  return ids.reduce(function(map, id) {
47
- map[id] = reviver ? reviver(dictionary[id], dictionary) : dictionary[id];
50
+ map[id] = reviver ? reviver(dictionary[id], dictionary, options) : dictionary[id];
48
51
  return map;
49
52
  }, {});
50
53
  }
@@ -1,43 +1,43 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable no-console */ import { getResponseReviver } from "@ama-sdk/core";
2
- describe("getResponseReviver - revivers by status code", function() {
1
+ /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable no-console */ import { getResponseReviver } from '@ama-sdk/core';
2
+ describe('getResponseReviver - revivers by status code', function() {
3
3
  var revivers = {
4
4
  202: jest.fn(),
5
5
  201: jest.fn()
6
6
  };
7
7
  beforeEach(function() {
8
- jest.spyOn(console, "error");
8
+ jest.spyOn(console, 'error');
9
9
  });
10
10
  afterEach(function() {
11
11
  jest.clearAllMocks();
12
12
  });
13
- it("should not return a reviver for a non ok response", function() {
13
+ it('should not return a reviver for a non ok response', function() {
14
14
  expect(getResponseReviver(revivers, {
15
15
  status: 300,
16
16
  ok: false
17
17
  })).toBe(undefined);
18
18
  });
19
- it("should return a reason but not reviver for a 204 No Content Response", function() {
19
+ it('should return a reason but not reviver for a 204 No Content Response', function() {
20
20
  expect(getResponseReviver(revivers, {
21
21
  status: 204,
22
22
  ok: true
23
23
  })).toBe(undefined);
24
- expect(console.error).toHaveBeenCalledWith("API status code error for unknown endpoint - 204 response is not defined in the API specification");
24
+ expect(console.error).toHaveBeenCalledWith('API status code error for unknown endpoint - 204 response is not defined in the API specification');
25
25
  });
26
- it("should return the status code's reviver", function() {
26
+ it('should return the status code\'s reviver', function() {
27
27
  expect(getResponseReviver(revivers, {
28
28
  status: 202,
29
29
  ok: true
30
- }, "myEndpoint")).toBe(revivers[202]);
30
+ }, 'myEndpoint')).toBe(revivers[202]);
31
31
  expect(console.error).not.toHaveBeenCalled();
32
32
  });
33
- it("should fallback on the first defined status if the status code's reviver is not defined", function() {
33
+ it('should fallback on the first defined status if the status code\'s reviver is not defined', function() {
34
34
  expect(getResponseReviver(revivers, {
35
35
  status: undefined,
36
36
  ok: true
37
- }, "myEndpoint")).toBe(revivers[201]);
38
- expect(console.error).toHaveBeenCalledWith("API status code error for myEndpoint endpoint - Unknown undefined code returned by the API - Fallback to 201's reviver");
37
+ }, 'myEndpoint')).toBe(revivers[201]);
38
+ expect(console.error).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Unknown undefined code returned by the API - Fallback to 201\'s reviver');
39
39
  });
40
- it("should not fallback on 204 (No Content)'s reviver", function() {
40
+ it('should not fallback on 204 (No Content)\'s reviver', function() {
41
41
  var reviversWith204 = {
42
42
  204: jest.fn(),
43
43
  206: jest.fn()
@@ -45,33 +45,33 @@ describe("getResponseReviver - revivers by status code", function() {
45
45
  var fallback = getResponseReviver(reviversWith204, {
46
46
  status: 201,
47
47
  ok: true
48
- }, "myEndpoint");
48
+ }, 'myEndpoint');
49
49
  expect(fallback).toBe(reviversWith204[206]);
50
50
  expect(fallback).not.toBe(reviversWith204[204]);
51
- expect(console.error).toHaveBeenCalledWith("API status code error for myEndpoint endpoint - Unknown 201 code returned by the API - Fallback to 206's reviver");
51
+ expect(console.error).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Unknown 201 code returned by the API - Fallback to 206\'s reviver');
52
52
  });
53
- it("should not fallback if the feature is deactivated", function() {
54
- jest.spyOn(console, "log");
53
+ it('should not fallback if the feature is deactivated', function() {
54
+ jest.spyOn(console, 'log');
55
55
  expect(getResponseReviver(revivers, {
56
56
  status: 206,
57
57
  ok: true
58
- }, "myEndpoint", {
58
+ }, 'myEndpoint', {
59
59
  disableFallback: true,
60
60
  log: console.log
61
61
  })).toBe(undefined);
62
62
  expect(console.error).not.toHaveBeenCalled();
63
- expect(console.log).toHaveBeenCalledWith("API status code error for myEndpoint endpoint - Missing 206 from API specification - fallback is deactivated, no revive will run on this response");
63
+ expect(console.log).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Missing 206 from API specification - fallback is deactivated, no revive will run on this response');
64
64
  });
65
65
  });
66
- describe("getResponseReviver - reviver as function", function() {
66
+ describe('getResponseReviver - reviver as function', function() {
67
67
  var reviver = jest.fn();
68
- it("should not return a reviver for a non ok response", function() {
68
+ it('should not return a reviver for a non ok response', function() {
69
69
  expect(getResponseReviver(reviver, {
70
70
  status: 300,
71
71
  ok: false
72
72
  })).toBe(undefined);
73
73
  });
74
- it("should only return the reviver if the endpoint reviver is a function or an undefined object", function() {
74
+ it('should only return the reviver if the endpoint reviver is a function or an undefined object', function() {
75
75
  expect(getResponseReviver(reviver, {
76
76
  status: 200,
77
77
  ok: true