@zimic/interceptor 0.16.0-canary.0 → 0.16.0-canary.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/{chunk-6TSSHQW5.mjs → chunk-2RNFR6TF.mjs} +6 -47
- package/dist/chunk-2RNFR6TF.mjs.map +1 -0
- package/dist/{chunk-R2ROSKU4.js → chunk-D7CDDSQE.js} +6 -47
- package/dist/chunk-D7CDDSQE.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/http.d.ts +1 -35
- package/dist/http.js +5 -74
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +5 -74
- package/dist/http.mjs.map +1 -1
- package/dist/server.js +6 -6
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/src/http/index.ts +0 -1
- package/src/http/interceptorWorker/HttpInterceptorWorker.ts +4 -29
- package/src/http/namespace/HttpInterceptorNamespace.ts +0 -60
- package/src/http/requestHandler/errors/DisabledRequestSavingError.ts +1 -1
- package/dist/chunk-6TSSHQW5.mjs.map +0 -1
- package/dist/chunk-R2ROSKU4.js.map +0 -1
- package/src/http/interceptorWorker/HttpInterceptorWorkerStore.ts +0 -34
package/dist/http.mjs
CHANGED
|
@@ -126,7 +126,7 @@ var DisabledRequestSavingError = class extends TypeError {
|
|
|
126
126
|
}
|
|
127
127
|
constructor() {
|
|
128
128
|
super(
|
|
129
|
-
"Intercepted requests are not saved
|
|
129
|
+
"Intercepted requests are not being saved. Did you forget to use `saveRequests: true` when creating the interceptor?\n\nLearn more: https://github.com/zimicjs/zimic/wiki/api\u2010zimic\u2010interceptor\u2010http#saving-requests"
|
|
130
130
|
);
|
|
131
131
|
this.name = "DisabledRequestSavingError";
|
|
132
132
|
}
|
|
@@ -784,29 +784,6 @@ var InvalidJSONError = class extends SyntaxError {
|
|
|
784
784
|
};
|
|
785
785
|
var InvalidJSONError_default = InvalidJSONError;
|
|
786
786
|
|
|
787
|
-
// src/http/interceptorWorker/HttpInterceptorWorkerStore.ts
|
|
788
|
-
var HttpInterceptorWorkerStore = class _HttpInterceptorWorkerStore {
|
|
789
|
-
static {
|
|
790
|
-
__name(this, "HttpInterceptorWorkerStore");
|
|
791
|
-
}
|
|
792
|
-
static _defaultOnUnhandledRequest = {
|
|
793
|
-
local: { ...DEFAULT_UNHANDLED_REQUEST_STRATEGY.local },
|
|
794
|
-
remote: { ...DEFAULT_UNHANDLED_REQUEST_STRATEGY.remote }
|
|
795
|
-
};
|
|
796
|
-
class = _HttpInterceptorWorkerStore;
|
|
797
|
-
defaultOnUnhandledRequest(interceptorType) {
|
|
798
|
-
return this.class._defaultOnUnhandledRequest[interceptorType];
|
|
799
|
-
}
|
|
800
|
-
setDefaultOnUnhandledRequest(interceptorType, strategy) {
|
|
801
|
-
if (interceptorType === "local") {
|
|
802
|
-
this.class._defaultOnUnhandledRequest[interceptorType] = strategy;
|
|
803
|
-
} else {
|
|
804
|
-
this.class._defaultOnUnhandledRequest[interceptorType] = strategy;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
var HttpInterceptorWorkerStore_default = HttpInterceptorWorkerStore;
|
|
809
|
-
|
|
810
787
|
// src/http/interceptorWorker/HttpInterceptorWorker.ts
|
|
811
788
|
var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
812
789
|
static {
|
|
@@ -816,7 +793,6 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
816
793
|
isRunning = false;
|
|
817
794
|
startingPromise;
|
|
818
795
|
stoppingPromise;
|
|
819
|
-
store = new HttpInterceptorWorkerStore_default();
|
|
820
796
|
runningInterceptors = [];
|
|
821
797
|
async sharedStart(internalStart) {
|
|
822
798
|
if (this.isRunning) {
|
|
@@ -875,24 +851,18 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
875
851
|
);
|
|
876
852
|
}
|
|
877
853
|
async getUnhandledRequestStrategyCandidates(request, interceptorType) {
|
|
878
|
-
const globalDefaultStrategy =
|
|
854
|
+
const globalDefaultStrategy = DEFAULT_UNHANDLED_REQUEST_STRATEGY[interceptorType];
|
|
879
855
|
try {
|
|
880
856
|
const interceptor = this.findInterceptorByRequestBaseURL(request);
|
|
881
857
|
if (!interceptor) {
|
|
882
858
|
return [];
|
|
883
859
|
}
|
|
884
860
|
const requestClone = request.clone();
|
|
885
|
-
const
|
|
886
|
-
|
|
887
|
-
this.getInterceptorUnhandledRequestStrategy(requestClone, interceptor)
|
|
888
|
-
]);
|
|
889
|
-
const candidatesOrPromises = [interceptorStrategy, defaultStrategy, globalDefaultStrategy];
|
|
890
|
-
const candidateStrategies = await Promise.all(candidatesOrPromises.filter(isDefined_default));
|
|
891
|
-
return candidateStrategies;
|
|
861
|
+
const interceptorStrategy = await this.getInterceptorUnhandledRequestStrategy(requestClone, interceptor);
|
|
862
|
+
return [interceptorStrategy, globalDefaultStrategy].filter(isDefined_default);
|
|
892
863
|
} catch (error) {
|
|
893
864
|
console.error(error);
|
|
894
|
-
|
|
895
|
-
return candidateStrategies;
|
|
865
|
+
return [globalDefaultStrategy];
|
|
896
866
|
}
|
|
897
867
|
}
|
|
898
868
|
registerRunningInterceptor(interceptor) {
|
|
@@ -907,17 +877,6 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
907
877
|
});
|
|
908
878
|
return interceptor;
|
|
909
879
|
}
|
|
910
|
-
getGlobalDefaultUnhandledRequestStrategy(interceptorType) {
|
|
911
|
-
return DEFAULT_UNHANDLED_REQUEST_STRATEGY[interceptorType];
|
|
912
|
-
}
|
|
913
|
-
async getDefaultUnhandledRequestStrategy(request, interceptorType) {
|
|
914
|
-
const defaultStrategyOrFactory = this.store.defaultOnUnhandledRequest(interceptorType);
|
|
915
|
-
if (typeof defaultStrategyOrFactory === "function") {
|
|
916
|
-
const parsedRequest = await _HttpInterceptorWorker.parseRawUnhandledRequest(request);
|
|
917
|
-
return defaultStrategyOrFactory(parsedRequest);
|
|
918
|
-
}
|
|
919
|
-
return defaultStrategyOrFactory;
|
|
920
|
-
}
|
|
921
880
|
async getInterceptorUnhandledRequestStrategy(request, interceptor) {
|
|
922
881
|
if (typeof interceptor.onUnhandledRequest === "function") {
|
|
923
882
|
const parsedRequest = await _HttpInterceptorWorker.parseRawUnhandledRequest(request);
|
|
@@ -2606,32 +2565,6 @@ function createHttpInterceptor(options) {
|
|
|
2606
2565
|
__name(createHttpInterceptor, "createHttpInterceptor");
|
|
2607
2566
|
|
|
2608
2567
|
// src/http/namespace/HttpInterceptorNamespace.ts
|
|
2609
|
-
var HttpInterceptorNamespaceDefault = class {
|
|
2610
|
-
static {
|
|
2611
|
-
__name(this, "HttpInterceptorNamespaceDefault");
|
|
2612
|
-
}
|
|
2613
|
-
local;
|
|
2614
|
-
remote;
|
|
2615
|
-
constructor() {
|
|
2616
|
-
const workerStore = new HttpInterceptorWorkerStore_default();
|
|
2617
|
-
this.local = {
|
|
2618
|
-
get onUnhandledRequest() {
|
|
2619
|
-
return workerStore.defaultOnUnhandledRequest("local");
|
|
2620
|
-
},
|
|
2621
|
-
set onUnhandledRequest(strategy) {
|
|
2622
|
-
workerStore.setDefaultOnUnhandledRequest("local", strategy);
|
|
2623
|
-
}
|
|
2624
|
-
};
|
|
2625
|
-
this.remote = {
|
|
2626
|
-
get onUnhandledRequest() {
|
|
2627
|
-
return workerStore.defaultOnUnhandledRequest("remote");
|
|
2628
|
-
},
|
|
2629
|
-
set onUnhandledRequest(strategy) {
|
|
2630
|
-
workerStore.setDefaultOnUnhandledRequest("remote", strategy);
|
|
2631
|
-
}
|
|
2632
|
-
};
|
|
2633
|
-
}
|
|
2634
|
-
};
|
|
2635
2568
|
var HttpInterceptorNamespace = class {
|
|
2636
2569
|
static {
|
|
2637
2570
|
__name(this, "HttpInterceptorNamespace");
|
|
@@ -2646,8 +2579,6 @@ var HttpInterceptorNamespace = class {
|
|
|
2646
2579
|
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httpinterceptorcreateoptions `httpInterceptor.create(options)` API reference}
|
|
2647
2580
|
*/
|
|
2648
2581
|
create = createHttpInterceptor;
|
|
2649
|
-
/** Default HTTP interceptor settings. */
|
|
2650
|
-
default = Object.freeze(new HttpInterceptorNamespaceDefault());
|
|
2651
2582
|
};
|
|
2652
2583
|
var HttpInterceptorNamespace_default = HttpInterceptorNamespace;
|
|
2653
2584
|
|