@zimic/interceptor 1.5.1 → 1.5.2-canary.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/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/http.d.ts +7 -3
- package/dist/http.js +19 -1
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +19 -1
- package/dist/http.mjs.map +1 -1
- package/package.json +10 -10
- package/src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts +3 -1
- package/src/http/interceptor/factory.ts +3 -0
package/dist/http.mjs
CHANGED
|
@@ -23,8 +23,25 @@ var NotRunningHttpInterceptorError = class extends Error {
|
|
|
23
23
|
};
|
|
24
24
|
var NotRunningHttpInterceptorError_default = NotRunningHttpInterceptorError;
|
|
25
25
|
|
|
26
|
+
// ../zimic-utils/dist/validation.mjs
|
|
27
|
+
var ValidationError = class extends TypeError {
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "ValidationError";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var ValidationError_default = ValidationError;
|
|
34
|
+
function assertTypeOf(field, value, expectedType, options) {
|
|
35
|
+
const actualType = typeof value;
|
|
36
|
+
if (actualType !== expectedType && !(options?.nullable && value === null) && !(options?.optional && value === void 0)) {
|
|
37
|
+
const receivedType = value === null ? "null" : actualType;
|
|
38
|
+
throw new ValidationError_default(`Expected ${field} to be ${expectedType}, but got ${receivedType}.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
var assertTypeOf_default = assertTypeOf;
|
|
42
|
+
|
|
26
43
|
// src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts
|
|
27
|
-
var UnknownHttpInterceptorPlatformError = class extends
|
|
44
|
+
var UnknownHttpInterceptorPlatformError = class extends ValidationError_default {
|
|
28
45
|
/* istanbul ignore next -- @preserve
|
|
29
46
|
* Ignoring because checking unknown platforms is currently not possible in our Vitest setup. */
|
|
30
47
|
constructor() {
|
|
@@ -2858,6 +2875,7 @@ function isRemoteHttpInterceptorOptions(options) {
|
|
|
2858
2875
|
return options.type === "remote";
|
|
2859
2876
|
}
|
|
2860
2877
|
function createHttpInterceptor(options) {
|
|
2878
|
+
assertTypeOf_default("options.baseURL", options.baseURL, "string");
|
|
2861
2879
|
const type = options.type;
|
|
2862
2880
|
if (isLocalHttpInterceptorOptions(options)) {
|
|
2863
2881
|
return new LocalHttpInterceptor_default(options);
|