@zimic/interceptor 0.16.0-canary.6 → 0.16.0-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/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 +28 -19
- package/dist/http.js +49 -45
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +49 -46
- package/dist/http.mjs.map +1 -1
- package/package.json +4 -4
- package/src/http/index.ts +5 -2
- package/src/http/interceptor/HttpInterceptorClient.ts +5 -1
package/dist/http.mjs
CHANGED
|
@@ -8,30 +8,6 @@ import ClientSocket from 'isomorphic-ws';
|
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
9
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
10
|
|
|
11
|
-
// src/http/interceptorWorker/errors/InvalidJSONError.ts
|
|
12
|
-
var InvalidJSONError = class extends SyntaxError {
|
|
13
|
-
static {
|
|
14
|
-
__name(this, "InvalidJSONError");
|
|
15
|
-
}
|
|
16
|
-
constructor(value) {
|
|
17
|
-
super(`Failed to parse value as JSON: ${value}`);
|
|
18
|
-
this.name = "InvalidJSONError";
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var InvalidJSONError_default = InvalidJSONError;
|
|
22
|
-
|
|
23
|
-
// src/http/interceptorWorker/errors/InvalidFormDataError.ts
|
|
24
|
-
var InvalidFormDataError = class extends SyntaxError {
|
|
25
|
-
static {
|
|
26
|
-
__name(this, "InvalidFormDataError");
|
|
27
|
-
}
|
|
28
|
-
constructor(value) {
|
|
29
|
-
super(`Failed to parse value as form data: ${value}`);
|
|
30
|
-
this.name = "InvalidFormDataError";
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var InvalidFormDataError_default = InvalidFormDataError;
|
|
34
|
-
|
|
35
11
|
// src/http/interceptor/errors/RunningHttpInterceptorError.ts
|
|
36
12
|
var RunningHttpInterceptorError = class extends Error {
|
|
37
13
|
static {
|
|
@@ -84,6 +60,50 @@ var UnknownHttpInterceptorTypeError = class extends TypeError {
|
|
|
84
60
|
};
|
|
85
61
|
var UnknownHttpInterceptorTypeError_default = UnknownHttpInterceptorTypeError;
|
|
86
62
|
|
|
63
|
+
// src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts
|
|
64
|
+
var RequestSavingSafeLimitExceededError = class extends TypeError {
|
|
65
|
+
static {
|
|
66
|
+
__name(this, "RequestSavingSafeLimitExceededError");
|
|
67
|
+
}
|
|
68
|
+
constructor(numberOfSavedRequests, safeLimit) {
|
|
69
|
+
super(
|
|
70
|
+
`The number of intercepted requests saved in memory (${numberOfSavedRequests}) exceeded the safe limit of ${safeLimit}. Did you forget to call \`interceptor.clear()\`?
|
|
71
|
+
|
|
72
|
+
If you need to save requests, make sure to regularly call \`interceptor.clear()\`. Alternatively, you can hide this warning by increasing \`requestSaving.safeLimit\` in your interceptor. Note that saving too many requests in memory can lead to performance issues.
|
|
73
|
+
|
|
74
|
+
If you do not need to save requests, consider setting \`requestSaving.enabled: false\` in your interceptor.
|
|
75
|
+
|
|
76
|
+
Learn more: https://github.com/zimicjs/zimic/wiki/api\u2010zimic\u2010interceptor\u2010http#saving-requests`
|
|
77
|
+
);
|
|
78
|
+
this.name = "RequestSavingSafeLimitExceededError";
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var RequestSavingSafeLimitExceededError_default = RequestSavingSafeLimitExceededError;
|
|
82
|
+
|
|
83
|
+
// src/http/interceptorWorker/errors/InvalidFormDataError.ts
|
|
84
|
+
var InvalidFormDataError = class extends SyntaxError {
|
|
85
|
+
static {
|
|
86
|
+
__name(this, "InvalidFormDataError");
|
|
87
|
+
}
|
|
88
|
+
constructor(value) {
|
|
89
|
+
super(`Failed to parse value as form data: ${value}`);
|
|
90
|
+
this.name = "InvalidFormDataError";
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var InvalidFormDataError_default = InvalidFormDataError;
|
|
94
|
+
|
|
95
|
+
// src/http/interceptorWorker/errors/InvalidJSONError.ts
|
|
96
|
+
var InvalidJSONError = class extends SyntaxError {
|
|
97
|
+
static {
|
|
98
|
+
__name(this, "InvalidJSONError");
|
|
99
|
+
}
|
|
100
|
+
constructor(value) {
|
|
101
|
+
super(`Failed to parse value as JSON: ${value}`);
|
|
102
|
+
this.name = "InvalidJSONError";
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var InvalidJSONError_default = InvalidJSONError;
|
|
106
|
+
|
|
87
107
|
// src/cli/browser/shared/constants.ts
|
|
88
108
|
var SERVICE_WORKER_FILE_NAME = "mockServiceWorker.js";
|
|
89
109
|
|
|
@@ -1462,26 +1482,6 @@ var RemoteHttpRequestHandler = class {
|
|
|
1462
1482
|
};
|
|
1463
1483
|
var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
|
|
1464
1484
|
|
|
1465
|
-
// src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts
|
|
1466
|
-
var RequestSavingSafeLimitExceededError = class extends TypeError {
|
|
1467
|
-
static {
|
|
1468
|
-
__name(this, "RequestSavingSafeLimitExceededError");
|
|
1469
|
-
}
|
|
1470
|
-
constructor(numberOfSavedRequests, safeLimit) {
|
|
1471
|
-
super(
|
|
1472
|
-
`The number of intercepted requests saved in memory (${numberOfSavedRequests}) exceeded the safe limit of ${safeLimit}. Did you forget to call \`interceptor.clear()\`?
|
|
1473
|
-
|
|
1474
|
-
If you need to save requests, make sure to regularly call \`interceptor.clear()\`. Alternatively, you can hide this warning by increasing \`requestSaving.safeLimit\` in your interceptor. Note that saving too many requests in memory can lead to performance issues.
|
|
1475
|
-
|
|
1476
|
-
If you do not need to save requests, consider setting \`requestSaving.enabled: false\` in your interceptor.
|
|
1477
|
-
|
|
1478
|
-
Learn more: https://github.com/zimicjs/zimic/wiki/api\u2010zimic\u2010interceptor\u2010http#saving-requests`
|
|
1479
|
-
);
|
|
1480
|
-
this.name = "RequestSavingSafeLimitExceededError";
|
|
1481
|
-
}
|
|
1482
|
-
};
|
|
1483
|
-
var RequestSavingSafeLimitExceededError_default = RequestSavingSafeLimitExceededError;
|
|
1484
|
-
|
|
1485
1485
|
// src/http/interceptor/HttpInterceptorClient.ts
|
|
1486
1486
|
var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
|
|
1487
1487
|
var DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1e3;
|
|
@@ -1511,12 +1511,15 @@ var HttpInterceptorClient = class {
|
|
|
1511
1511
|
this.store = options.store;
|
|
1512
1512
|
this.baseURL = options.baseURL;
|
|
1513
1513
|
this.requestSaving = {
|
|
1514
|
-
enabled: options.requestSaving?.enabled ?? (
|
|
1514
|
+
enabled: options.requestSaving?.enabled ?? this.getDefaultRequestSavingEnabled(),
|
|
1515
1515
|
safeLimit: options.requestSaving?.safeLimit ?? DEFAULT_REQUEST_SAVING_SAFE_LIMIT
|
|
1516
1516
|
};
|
|
1517
1517
|
this.onUnhandledRequest = options.onUnhandledRequest;
|
|
1518
1518
|
this.Handler = options.Handler;
|
|
1519
1519
|
}
|
|
1520
|
+
getDefaultRequestSavingEnabled() {
|
|
1521
|
+
return isServerSide() ? process.env.NODE_ENV === "test" : false;
|
|
1522
|
+
}
|
|
1520
1523
|
get baseURL() {
|
|
1521
1524
|
return this._baseURL;
|
|
1522
1525
|
}
|
|
@@ -2605,6 +2608,6 @@ __name(createHttpInterceptor, "createHttpInterceptor");
|
|
|
2605
2608
|
* Reply listeners are always present when notified in normal conditions. If they were not present, the request
|
|
2606
2609
|
* would reach a timeout and not be responded. The empty set serves as a fallback. */
|
|
2607
2610
|
|
|
2608
|
-
export { DisabledRequestSavingError_default as DisabledRequestSavingError, InvalidFormDataError_default as InvalidFormDataError, InvalidJSONError_default as InvalidJSONError, NotRunningHttpInterceptorError_default as NotRunningHttpInterceptorError, RunningHttpInterceptorError_default as RunningHttpInterceptorError, TimesCheckError_default as TimesCheckError, UnknownHttpInterceptorPlatformError_default as UnknownHttpInterceptorPlatformError, UnknownHttpInterceptorTypeError_default as UnknownHttpInterceptorTypeError, UnregisteredBrowserServiceWorkerError_default as UnregisteredBrowserServiceWorkerError, createHttpInterceptor };
|
|
2611
|
+
export { DisabledRequestSavingError_default as DisabledRequestSavingError, InvalidFormDataError_default as InvalidFormDataError, InvalidJSONError_default as InvalidJSONError, NotRunningHttpInterceptorError_default as NotRunningHttpInterceptorError, RequestSavingSafeLimitExceededError_default as RequestSavingSafeLimitExceededError, RunningHttpInterceptorError_default as RunningHttpInterceptorError, TimesCheckError_default as TimesCheckError, UnknownHttpInterceptorPlatformError_default as UnknownHttpInterceptorPlatformError, UnknownHttpInterceptorTypeError_default as UnknownHttpInterceptorTypeError, UnregisteredBrowserServiceWorkerError_default as UnregisteredBrowserServiceWorkerError, createHttpInterceptor };
|
|
2609
2612
|
//# sourceMappingURL=http.mjs.map
|
|
2610
2613
|
//# sourceMappingURL=http.mjs.map
|