@zimic/interceptor 1.2.6-canary.5 → 1.2.6-canary.7

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/http.mjs CHANGED
@@ -542,15 +542,6 @@ function random(lowerLimit, upperLimit) {
542
542
  return Math.random() * range + lowerLimit;
543
543
  }
544
544
 
545
- // src/http/requestHandler/errors/NoResponseDefinitionError.ts
546
- var NoResponseDefinitionError = class extends TypeError {
547
- constructor() {
548
- super("Cannot generate a response without a definition. Use .respond() to set a response.");
549
- this.name = "NoResponseDefinitionError";
550
- }
551
- };
552
- var NoResponseDefinitionError_default = NoResponseDefinitionError;
553
-
554
545
  // src/http/requestHandler/errors/TimesDeclarationPointer.ts
555
546
  var TimesDeclarationPointer = class extends Error {
556
547
  constructor(minNumberOfRequests, maxNumberOfRequests) {
@@ -799,16 +790,13 @@ var HttpRequestHandlerClient = class {
799
790
  return typeof restriction === "function";
800
791
  }
801
792
  async applyResponseDeclaration(request) {
802
- if (!this.createResponseDeclaration) {
803
- throw new NoResponseDefinitionError_default();
804
- }
805
793
  if (this.createResponseDelay) {
806
794
  const delay = await this.createResponseDelay(request);
807
795
  if (delay > 0) {
808
796
  await waitForDelay_default(delay);
809
797
  }
810
798
  }
811
- const appliedDeclaration = await this.createResponseDeclaration(request);
799
+ const appliedDeclaration = await this.createResponseDeclaration?.(request);
812
800
  return appliedDeclaration;
813
801
  }
814
802
  saveInterceptedRequest(request, response) {
@@ -1586,6 +1574,9 @@ var HttpInterceptorClient = class {
1586
1574
  return null;
1587
1575
  }
1588
1576
  const responseDeclaration = await matchedHandler.applyResponseDeclaration(parsedRequest);
1577
+ if (!responseDeclaration) {
1578
+ return null;
1579
+ }
1589
1580
  const response = HttpInterceptorWorker_default.createResponseFromDeclaration(request, responseDeclaration);
1590
1581
  if (this.requestSaving.enabled) {
1591
1582
  const responseClone = response.clone();