@zimic/interceptor 1.0.2-canary.1 → 1.0.2

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
@@ -704,7 +704,7 @@ var HttpRequestHandlerClient = class {
704
704
  async matchesRequest(request) {
705
705
  const hasDeclaredResponse = this.createResponseDeclaration !== void 0;
706
706
  const restrictionsMatch = await this.matchesRequestRestrictions(request);
707
- if (restrictionsMatch.value) {
707
+ if (restrictionsMatch.success) {
708
708
  this.numberOfMatchedRequests++;
709
709
  } else {
710
710
  const shouldSaveUnmatchedGroup = this.interceptor.requestSaving.enabled && this.restrictions.length > 0 && this.timesDeclarationPointer !== void 0;
@@ -716,7 +716,7 @@ var HttpRequestHandlerClient = class {
716
716
  return false;
717
717
  }
718
718
  const isWithinLimits = this.numberOfMatchedRequests <= this.limits.numberOfRequests.max;
719
- return restrictionsMatch.value && isWithinLimits;
719
+ return restrictionsMatch.success && isWithinLimits;
720
720
  }
721
721
  async matchesRequestRestrictions(request) {
722
722
  for (const restriction of this.restrictions) {
@@ -724,7 +724,7 @@ var HttpRequestHandlerClient = class {
724
724
  const matchesComputedRestriction = await restriction(request);
725
725
  if (!matchesComputedRestriction) {
726
726
  return {
727
- value: false,
727
+ success: false,
728
728
  diff: { computed: { expected: true, received: false } }
729
729
  };
730
730
  }
@@ -733,10 +733,10 @@ var HttpRequestHandlerClient = class {
733
733
  const matchesHeadersRestrictions = this.matchesRequestHeadersRestrictions(request, restriction);
734
734
  const matchesSearchParamsRestrictions = this.matchesRequestSearchParamsRestrictions(request, restriction);
735
735
  const matchesBodyRestrictions = await this.matchesRequestBodyRestrictions(request, restriction);
736
- const matchesRestriction = matchesHeadersRestrictions.value && matchesSearchParamsRestrictions.value && matchesBodyRestrictions.value;
736
+ const matchesRestriction = matchesHeadersRestrictions.success && matchesSearchParamsRestrictions.success && matchesBodyRestrictions.success;
737
737
  if (!matchesRestriction) {
738
738
  return {
739
- value: false,
739
+ success: false,
740
740
  diff: {
741
741
  headers: matchesHeadersRestrictions.diff,
742
742
  searchParams: matchesSearchParamsRestrictions.diff,
@@ -745,77 +745,77 @@ var HttpRequestHandlerClient = class {
745
745
  };
746
746
  }
747
747
  }
748
- return { value: true };
748
+ return { success: true };
749
749
  }
750
750
  matchesRequestHeadersRestrictions(request, restriction) {
751
751
  if (restriction.headers === void 0) {
752
- return { value: true };
752
+ return { success: true };
753
753
  }
754
754
  const restrictedHeaders = new HttpHeaders(
755
755
  restriction.headers
756
756
  );
757
757
  const matchesRestriction = restriction.exact ? request.headers.equals(restrictedHeaders) : request.headers.contains(restrictedHeaders);
758
- return matchesRestriction ? { value: true } : {
759
- value: false,
758
+ return matchesRestriction ? { success: true } : {
759
+ success: false,
760
760
  diff: { expected: restrictedHeaders, received: request.headers }
761
761
  };
762
762
  }
763
763
  matchesRequestSearchParamsRestrictions(request, restriction) {
764
764
  if (restriction.searchParams === void 0) {
765
- return { value: true };
765
+ return { success: true };
766
766
  }
767
767
  const restrictedSearchParams = new HttpSearchParams(
768
768
  restriction.searchParams
769
769
  );
770
770
  const matchesRestriction = restriction.exact ? request.searchParams.equals(restrictedSearchParams) : request.searchParams.contains(restrictedSearchParams);
771
- return matchesRestriction ? { value: true } : {
772
- value: false,
771
+ return matchesRestriction ? { success: true } : {
772
+ success: false,
773
773
  diff: { expected: restrictedSearchParams, received: request.searchParams }
774
774
  };
775
775
  }
776
776
  async matchesRequestBodyRestrictions(request, restriction) {
777
777
  if (restriction.body === void 0) {
778
- return { value: true };
778
+ return { success: true };
779
779
  }
780
780
  const body = request.body;
781
781
  const restrictionBody = restriction.body;
782
782
  if (typeof body === "string" && typeof restrictionBody === "string") {
783
783
  const matchesRestriction2 = restriction.exact ? body === restrictionBody : body.includes(restrictionBody);
784
- return matchesRestriction2 ? { value: true } : {
785
- value: false,
784
+ return matchesRestriction2 ? { success: true } : {
785
+ success: false,
786
786
  diff: { expected: restrictionBody, received: body }
787
787
  };
788
788
  }
789
789
  if (restrictionBody instanceof HttpFormData) {
790
790
  if (!(body instanceof HttpFormData)) {
791
791
  return {
792
- value: false,
792
+ success: false,
793
793
  diff: { expected: restrictionBody, received: body }
794
794
  };
795
795
  }
796
796
  const matchesRestriction2 = restriction.exact ? await body.equals(restrictionBody) : await body.contains(restrictionBody);
797
- return matchesRestriction2 ? { value: true } : {
798
- value: false,
797
+ return matchesRestriction2 ? { success: true } : {
798
+ success: false,
799
799
  diff: { expected: restrictionBody, received: body }
800
800
  };
801
801
  }
802
802
  if (restrictionBody instanceof HttpSearchParams) {
803
803
  if (!(body instanceof HttpSearchParams)) {
804
804
  return {
805
- value: false,
805
+ success: false,
806
806
  diff: { expected: restrictionBody, received: body }
807
807
  };
808
808
  }
809
809
  const matchesRestriction2 = restriction.exact ? body.equals(restrictionBody) : body.contains(restrictionBody);
810
- return matchesRestriction2 ? { value: true } : {
811
- value: false,
810
+ return matchesRestriction2 ? { success: true } : {
811
+ success: false,
812
812
  diff: { expected: restrictionBody, received: body }
813
813
  };
814
814
  }
815
815
  if (restrictionBody instanceof Blob || restrictionBody instanceof ArrayBuffer || restrictionBody instanceof ReadableStream) {
816
816
  if (!(body instanceof Blob)) {
817
817
  return {
818
- value: false,
818
+ success: false,
819
819
  diff: { expected: restrictionBody, received: body }
820
820
  };
821
821
  }
@@ -831,14 +831,14 @@ var HttpRequestHandlerClient = class {
831
831
  restrictionBodyAsBlob = restrictionBody;
832
832
  }
833
833
  const matchesRestriction2 = await blobEquals_default(body, restrictionBodyAsBlob);
834
- return matchesRestriction2 ? { value: true } : {
835
- value: false,
834
+ return matchesRestriction2 ? { success: true } : {
835
+ success: false,
836
836
  diff: { expected: restrictionBody, received: body }
837
837
  };
838
838
  }
839
839
  const matchesRestriction = restriction.exact ? jsonEquals_default(request.body, restriction.body) : jsonContains_default(request.body, restriction.body);
840
- return matchesRestriction ? { value: true } : {
841
- value: false,
840
+ return matchesRestriction ? { success: true } : {
841
+ success: false,
842
842
  diff: { expected: restrictionBody, received: body }
843
843
  };
844
844
  }