@hyper-fetch/core 5.1.2 → 5.2.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
  */
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,
@@ -2194,6 +2194,7 @@ var Client = class {
2194
2194
  this.loggerManager = new LoggerManager(this);
2195
2195
  this.defaultMethod = "GET" /* get */;
2196
2196
  this.defaultExtra = xhrExtra;
2197
+ this.isMockEnabled = true;
2197
2198
  this.effects = [];
2198
2199
  this.abortKeyMapper = getSimpleKey;
2199
2200
  this.cacheKeyMapper = getRequestKey;
@@ -2240,6 +2241,10 @@ var Client = class {
2240
2241
  this.payloadMapper = payloadMapper;
2241
2242
  return this;
2242
2243
  };
2244
+ this.setEnableGlobalMocking = (isMockEnabled) => {
2245
+ this.isMockEnabled = isMockEnabled;
2246
+ return this;
2247
+ };
2243
2248
  this.setEndpointMapper = (endpointMapper) => {
2244
2249
  this.endpointMapper = endpointMapper;
2245
2250
  return this;