@hyper-fetch/core 5.1.2 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -627,6 +627,7 @@ declare class Client<GlobalErrorType extends ClientErrorType = Error, Adapter ex
627
627
  submitDispatcher: Dispatcher;
628
628
  defaultMethod: ExtractAdapterMethodType<Adapter>;
629
629
  defaultExtra: ExtractAdapterExtraType<Adapter>;
630
+ isMockEnabled: boolean;
630
631
  effects: RequestEffectInstance[];
631
632
  queryParamsConfig?: QueryStringifyOptionsType;
632
633
  adapterDefaultOptions?: (request: RequestInstance) => ExtractAdapterOptionsType<Adapter>;
@@ -687,6 +688,11 @@ declare class Client<GlobalErrorType extends ClientErrorType = Error, Adapter ex
687
688
  * Set the request payload mapping function which get triggered before request get send
688
689
  */
689
690
  setPayloadMapper: (payloadMapper: AdapterPayloadMappingType) => Client<GlobalErrorType, Adapter, EndpointMapper>;
691
+ /**
692
+ * Set globally if mocking should be enabled or disabled for all client requests.
693
+ * @param isMockEnabled
694
+ */
695
+ setEnableGlobalMocking: (isMockEnabled: boolean) => this;
690
696
  /**
691
697
  * Set the request payload mapping function which get triggered before request get send
692
698
  */
@@ -824,7 +830,7 @@ declare const stringifyDefaultOptions: {
824
830
  readonly strict: true;
825
831
  readonly encode: true;
826
832
  readonly arrayFormat: "bracket";
827
- readonly arraySeparator: "";
833
+ readonly arraySeparator: "bracket";
828
834
  readonly sort: false;
829
835
  readonly skipNull: true;
830
836
  readonly skipEmptyString: true;
package/dist/index.esm.js CHANGED
@@ -1404,7 +1404,7 @@ var getAdapterBindings = (req, requestId, systemErrorStatus, systemErrorExtra) =
1404
1404
  if (processingError) {
1405
1405
  return onError(processingError, systemErrorStatus, systemErrorExtra, () => null);
1406
1406
  }
1407
- if (req.mock && req.isMockEnabled) {
1407
+ if (req.mock && req.isMockEnabled && req.client.isMockEnabled) {
1408
1408
  return mocker(request, {
1409
1409
  onError,
1410
1410
  onResponseEnd,
@@ -1421,6 +1421,13 @@ var getAdapterBindings = (req, requestId, systemErrorStatus, systemErrorExtra) =
1421
1421
  }
1422
1422
  return new Promise(apiCall);
1423
1423
  };
1424
+ logger2.debug(`Finishing request bindings creation`, {
1425
+ fullUrl,
1426
+ data,
1427
+ headers,
1428
+ payload,
1429
+ config
1430
+ });
1424
1431
  return {
1425
1432
  fullUrl,
1426
1433
  data,
@@ -2194,10 +2201,11 @@ var Client = class {
2194
2201
  this.loggerManager = new LoggerManager(this);
2195
2202
  this.defaultMethod = "GET" /* get */;
2196
2203
  this.defaultExtra = xhrExtra;
2204
+ this.isMockEnabled = true;
2197
2205
  this.effects = [];
2198
2206
  this.abortKeyMapper = getSimpleKey;
2199
2207
  this.cacheKeyMapper = getRequestKey;
2200
- this.queueKeyMapper = getSimpleKey;
2208
+ this.queueKeyMapper = getRequestKey;
2201
2209
  this.effectKeyMapper = getSimpleKey;
2202
2210
  this.stringifyQueryParams = (queryParams) => stringifyQueryParams(queryParams, this.queryParamsConfig);
2203
2211
  this.headerMapper = getAdapterHeaders;
@@ -2240,6 +2248,10 @@ var Client = class {
2240
2248
  this.payloadMapper = payloadMapper;
2241
2249
  return this;
2242
2250
  };
2251
+ this.setEnableGlobalMocking = (isMockEnabled) => {
2252
+ this.isMockEnabled = isMockEnabled;
2253
+ return this;
2254
+ };
2243
2255
  this.setEndpointMapper = (endpointMapper) => {
2244
2256
  this.endpointMapper = endpointMapper;
2245
2257
  return this;
@@ -2355,7 +2367,7 @@ var stringifyDefaultOptions = {
2355
2367
  strict: true,
2356
2368
  encode: true,
2357
2369
  arrayFormat: "bracket",
2358
- arraySeparator: "",
2370
+ arraySeparator: "bracket",
2359
2371
  sort: false,
2360
2372
  skipNull: true,
2361
2373
  skipEmptyString: true