@zimic/interceptor 0.15.0-canary.1 → 0.15.0-canary.3
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-3O3YPVEG.mjs → chunk-6TSSHQW5.mjs} +50 -25
- package/dist/chunk-6TSSHQW5.mjs.map +1 -0
- package/dist/{chunk-CWBDZYUG.js → chunk-R2ROSKU4.js} +51 -25
- package/dist/chunk-R2ROSKU4.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/http.d.ts +84 -40
- package/dist/http.js +144 -83
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +143 -83
- package/dist/http.mjs.map +1 -1
- package/dist/server.d.ts +17 -11
- package/dist/server.js +10 -6
- package/dist/server.mjs +1 -1
- package/package.json +12 -12
- package/src/cli/server/start.ts +1 -1
- package/src/http/index.ts +2 -14
- package/src/http/interceptor/HttpInterceptorClient.ts +51 -19
- package/src/http/interceptor/LocalHttpInterceptor.ts +27 -11
- package/src/http/interceptor/RemoteHttpInterceptor.ts +25 -10
- package/src/http/interceptor/errors/{NotStartedHttpInterceptorError.ts → NotRunningHttpInterceptorError.ts} +3 -3
- package/src/http/interceptor/errors/RunningHttpInterceptorError.ts +15 -0
- package/src/http/interceptor/types/options.ts +4 -6
- package/src/http/interceptor/types/public.ts +58 -20
- package/src/http/interceptorWorker/LocalHttpInterceptorWorker.ts +7 -6
- package/src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts +8 -7
- package/src/http/requestHandler/HttpRequestHandlerClient.ts +4 -6
- package/src/http/requestHandler/types/public.ts +12 -6
- package/src/server/InterceptorServer.ts +28 -11
- package/src/server/constants.ts +1 -0
- package/src/server/errors/NotRunningInterceptorServerError.ts +10 -0
- package/src/server/errors/RunningInterceptorServerError.ts +13 -0
- package/src/server/index.ts +2 -1
- package/src/server/types/public.ts +6 -10
- package/src/webSocket/WebSocketHandler.ts +2 -2
- package/src/webSocket/errors/NotRunningWebSocketHandlerError.ts +8 -0
- package/dist/chunk-3O3YPVEG.mjs.map +0 -1
- package/dist/chunk-CWBDZYUG.js.map +0 -1
- package/src/server/errors/NotStartedInterceptorServerError.ts +0 -10
- package/src/webSocket/errors/NotStartedWebSocketHandlerError.ts +0 -8
package/dist/http.js
CHANGED
|
@@ -53,43 +53,6 @@ var UnknownHttpInterceptorTypeError_default = UnknownHttpInterceptorTypeError;
|
|
|
53
53
|
var __defProp2 = Object.defineProperty;
|
|
54
54
|
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
55
55
|
|
|
56
|
-
// ../zimic-utils/dist/url/excludeURLParams.mjs
|
|
57
|
-
function excludeURLParams(url) {
|
|
58
|
-
url.hash = "";
|
|
59
|
-
url.search = "";
|
|
60
|
-
url.username = "";
|
|
61
|
-
url.password = "";
|
|
62
|
-
return url;
|
|
63
|
-
}
|
|
64
|
-
__name(excludeURLParams, "excludeURLParams");
|
|
65
|
-
__name2(excludeURLParams, "excludeURLParams");
|
|
66
|
-
var excludeURLParams_default = excludeURLParams;
|
|
67
|
-
|
|
68
|
-
// ../zimic-utils/dist/url/validateURLProtocol.mjs
|
|
69
|
-
var UnsupportedURLProtocolError = class extends TypeError {
|
|
70
|
-
static {
|
|
71
|
-
__name(this, "UnsupportedURLProtocolError");
|
|
72
|
-
}
|
|
73
|
-
static {
|
|
74
|
-
__name2(this, "UnsupportedURLProtocolError");
|
|
75
|
-
}
|
|
76
|
-
constructor(protocol, availableProtocols) {
|
|
77
|
-
super(
|
|
78
|
-
`Unsupported URL protocol: '${protocol}'. The available options are ${availableProtocols.map((protocol2) => `'${protocol2}'`).join(", ")}`
|
|
79
|
-
);
|
|
80
|
-
this.name = "UnsupportedURLProtocolError";
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
function validateURLProtocol(url, protocols) {
|
|
84
|
-
const protocol = url.protocol.replace(/:$/, "");
|
|
85
|
-
if (!protocols.includes(protocol)) {
|
|
86
|
-
throw new UnsupportedURLProtocolError(protocol, protocols);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
__name(validateURLProtocol, "validateURLProtocol");
|
|
90
|
-
__name2(validateURLProtocol, "validateURLProtocol");
|
|
91
|
-
var validateURLProtocol_default = validateURLProtocol;
|
|
92
|
-
|
|
93
56
|
// ../zimic-utils/dist/data/blobContains.mjs
|
|
94
57
|
async function blobContains(blob, otherBlob) {
|
|
95
58
|
return blob.type === otherBlob.type && blob.size >= otherBlob.size && (await blob.text()).includes(await otherBlob.text());
|
|
@@ -478,7 +441,7 @@ var HttpRequestHandlerClient = class {
|
|
|
478
441
|
declarationPointer: this.timesDeclarationPointer,
|
|
479
442
|
unmatchedRequestGroups: this.unmatchedRequestGroups,
|
|
480
443
|
hasRestrictions: this.restrictions.length > 0,
|
|
481
|
-
hasSavedRequests: this.interceptor.
|
|
444
|
+
hasSavedRequests: this.interceptor.saveRequests
|
|
482
445
|
});
|
|
483
446
|
}
|
|
484
447
|
}
|
|
@@ -503,7 +466,7 @@ var HttpRequestHandlerClient = class {
|
|
|
503
466
|
if (restrictionsMatch.value) {
|
|
504
467
|
this.numberOfMatchedRequests++;
|
|
505
468
|
} else {
|
|
506
|
-
const shouldSaveUnmatchedGroup = this.interceptor.
|
|
469
|
+
const shouldSaveUnmatchedGroup = this.interceptor.saveRequests && this.restrictions.length > 0 && this.timesDeclarationPointer !== void 0;
|
|
507
470
|
if (shouldSaveUnmatchedGroup) {
|
|
508
471
|
this.unmatchedRequestGroups.push({ request, diff: restrictionsMatch.diff });
|
|
509
472
|
}
|
|
@@ -649,7 +612,7 @@ var HttpRequestHandlerClient = class {
|
|
|
649
612
|
return interceptedRequest;
|
|
650
613
|
}
|
|
651
614
|
get requests() {
|
|
652
|
-
if (!this.interceptor.
|
|
615
|
+
if (!this.interceptor.saveRequests) {
|
|
653
616
|
throw new DisabledRequestSavingError_default();
|
|
654
617
|
}
|
|
655
618
|
return this._requests;
|
|
@@ -719,6 +682,18 @@ __name(createRegExpFromURL, "createRegExpFromURL");
|
|
|
719
682
|
__name2(createRegExpFromURL, "createRegExpFromURL");
|
|
720
683
|
var createRegExpFromURL_default = createRegExpFromURL;
|
|
721
684
|
|
|
685
|
+
// ../zimic-utils/dist/url/excludeURLParams.mjs
|
|
686
|
+
function excludeURLParams(url) {
|
|
687
|
+
url.hash = "";
|
|
688
|
+
url.search = "";
|
|
689
|
+
url.username = "";
|
|
690
|
+
url.password = "";
|
|
691
|
+
return url;
|
|
692
|
+
}
|
|
693
|
+
__name(excludeURLParams, "excludeURLParams");
|
|
694
|
+
__name2(excludeURLParams, "excludeURLParams");
|
|
695
|
+
var excludeURLParams_default = excludeURLParams;
|
|
696
|
+
|
|
722
697
|
// ../zimic-utils/dist/url/joinURL.mjs
|
|
723
698
|
function joinURL(...parts) {
|
|
724
699
|
return parts.map((part, index) => {
|
|
@@ -738,6 +713,31 @@ __name(joinURL, "joinURL");
|
|
|
738
713
|
__name2(joinURL, "joinURL");
|
|
739
714
|
var joinURL_default = joinURL;
|
|
740
715
|
|
|
716
|
+
// ../zimic-utils/dist/url/validateURLProtocol.mjs
|
|
717
|
+
var UnsupportedURLProtocolError = class extends TypeError {
|
|
718
|
+
static {
|
|
719
|
+
__name(this, "UnsupportedURLProtocolError");
|
|
720
|
+
}
|
|
721
|
+
static {
|
|
722
|
+
__name2(this, "UnsupportedURLProtocolError");
|
|
723
|
+
}
|
|
724
|
+
constructor(protocol, availableProtocols) {
|
|
725
|
+
super(
|
|
726
|
+
`Unsupported URL protocol: '${protocol}'. The available options are ${availableProtocols.map((protocol2) => `'${protocol2}'`).join(", ")}`
|
|
727
|
+
);
|
|
728
|
+
this.name = "UnsupportedURLProtocolError";
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
function validateURLProtocol(url, protocols) {
|
|
732
|
+
const protocol = url.protocol.replace(/:$/, "");
|
|
733
|
+
if (!protocols.includes(protocol)) {
|
|
734
|
+
throw new UnsupportedURLProtocolError(protocol, protocols);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
__name(validateURLProtocol, "validateURLProtocol");
|
|
738
|
+
__name2(validateURLProtocol, "validateURLProtocol");
|
|
739
|
+
var validateURLProtocol_default = validateURLProtocol;
|
|
740
|
+
|
|
741
741
|
// src/utils/arrays.ts
|
|
742
742
|
function removeArrayIndex(array, index) {
|
|
743
743
|
if (index >= 0 && index < array.length) {
|
|
@@ -1207,17 +1207,17 @@ __name(validateURLPathParams, "validateURLPathParams");
|
|
|
1207
1207
|
__name2(validateURLPathParams, "validateURLPathParams");
|
|
1208
1208
|
var validateURLPathParams_default = validateURLPathParams;
|
|
1209
1209
|
|
|
1210
|
-
// src/http/interceptor/errors/
|
|
1211
|
-
var
|
|
1210
|
+
// src/http/interceptor/errors/NotRunningHttpInterceptorError.ts
|
|
1211
|
+
var NotRunningHttpInterceptorError = class extends Error {
|
|
1212
1212
|
static {
|
|
1213
|
-
__name(this, "
|
|
1213
|
+
__name(this, "NotRunningHttpInterceptorError");
|
|
1214
1214
|
}
|
|
1215
1215
|
constructor() {
|
|
1216
1216
|
super("Interceptor is not running. Did you forget to call `await interceptor.start()`?");
|
|
1217
|
-
this.name = "
|
|
1217
|
+
this.name = "NotRunningHttpInterceptorError";
|
|
1218
1218
|
}
|
|
1219
1219
|
};
|
|
1220
|
-
var
|
|
1220
|
+
var NotRunningHttpInterceptorError_default = NotRunningHttpInterceptorError;
|
|
1221
1221
|
|
|
1222
1222
|
// src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts
|
|
1223
1223
|
var UnknownHttpInterceptorPlatformError = class extends Error {
|
|
@@ -1262,21 +1262,22 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1262
1262
|
static {
|
|
1263
1263
|
__name(this, "LocalHttpInterceptorWorker");
|
|
1264
1264
|
}
|
|
1265
|
-
type;
|
|
1266
1265
|
internalWorker;
|
|
1267
1266
|
defaultHttpHandler;
|
|
1268
1267
|
httpHandlerGroups = [];
|
|
1269
|
-
constructor(
|
|
1268
|
+
constructor(_options) {
|
|
1270
1269
|
super();
|
|
1271
|
-
this.type = options.type;
|
|
1272
1270
|
this.defaultHttpHandler = msw.http.all("*", async (context) => {
|
|
1273
1271
|
const request = context.request;
|
|
1274
1272
|
return this.bypassOrRejectUnhandledRequest(request);
|
|
1275
1273
|
});
|
|
1276
1274
|
}
|
|
1275
|
+
get type() {
|
|
1276
|
+
return "local";
|
|
1277
|
+
}
|
|
1277
1278
|
get internalWorkerOrThrow() {
|
|
1278
1279
|
if (!this.internalWorker) {
|
|
1279
|
-
throw new
|
|
1280
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
1280
1281
|
}
|
|
1281
1282
|
return this.internalWorker;
|
|
1282
1283
|
}
|
|
@@ -1514,6 +1515,18 @@ var RemoteHttpRequestHandler = class {
|
|
|
1514
1515
|
};
|
|
1515
1516
|
var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
|
|
1516
1517
|
|
|
1518
|
+
// src/http/interceptor/errors/RunningHttpInterceptorError.ts
|
|
1519
|
+
var RunningHttpInterceptorError = class extends Error {
|
|
1520
|
+
static {
|
|
1521
|
+
__name(this, "RunningHttpInterceptorError");
|
|
1522
|
+
}
|
|
1523
|
+
constructor(additionalMessage) {
|
|
1524
|
+
super(`The interceptor is running.${additionalMessage}`);
|
|
1525
|
+
this.name = "RunningHttpInterceptorError";
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
var RunningHttpInterceptorError_default = RunningHttpInterceptorError;
|
|
1529
|
+
|
|
1517
1530
|
// src/http/interceptor/HttpInterceptorClient.ts
|
|
1518
1531
|
var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
|
|
1519
1532
|
var HttpInterceptorClient = class {
|
|
@@ -1523,9 +1536,9 @@ var HttpInterceptorClient = class {
|
|
|
1523
1536
|
worker;
|
|
1524
1537
|
store;
|
|
1525
1538
|
_baseURL;
|
|
1526
|
-
|
|
1539
|
+
_saveRequests = false;
|
|
1527
1540
|
onUnhandledRequest;
|
|
1528
|
-
|
|
1541
|
+
isRunning = false;
|
|
1529
1542
|
Handler;
|
|
1530
1543
|
handlerClientsByMethod = {
|
|
1531
1544
|
GET: /* @__PURE__ */ new Map(),
|
|
@@ -1539,17 +1552,35 @@ var HttpInterceptorClient = class {
|
|
|
1539
1552
|
constructor(options) {
|
|
1540
1553
|
this.worker = options.worker;
|
|
1541
1554
|
this.store = options.store;
|
|
1542
|
-
this.
|
|
1543
|
-
this.
|
|
1555
|
+
this.baseURL = options.baseURL;
|
|
1556
|
+
this._saveRequests = options.saveRequests ?? false;
|
|
1544
1557
|
this.onUnhandledRequest = options.onUnhandledRequest;
|
|
1545
|
-
this.
|
|
1558
|
+
this.Handler = options.Handler;
|
|
1559
|
+
}
|
|
1560
|
+
get baseURL() {
|
|
1561
|
+
return this._baseURL;
|
|
1562
|
+
}
|
|
1563
|
+
set baseURL(newBaseURL) {
|
|
1564
|
+
if (this.isRunning) {
|
|
1565
|
+
throw new RunningHttpInterceptorError_default(
|
|
1566
|
+
"Did you forget to call `await interceptor.stop()` before changing the base URL?"
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
validateURLProtocol_default(newBaseURL, SUPPORTED_BASE_URL_PROTOCOLS);
|
|
1570
|
+
excludeURLParams_default(newBaseURL);
|
|
1571
|
+
this._baseURL = newBaseURL;
|
|
1546
1572
|
}
|
|
1547
1573
|
get baseURLAsString() {
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
return baseURL.origin;
|
|
1574
|
+
if (this.baseURL.href === `${this.baseURL.origin}/`) {
|
|
1575
|
+
return this.baseURL.origin;
|
|
1551
1576
|
}
|
|
1552
|
-
return baseURL.href;
|
|
1577
|
+
return this.baseURL.href;
|
|
1578
|
+
}
|
|
1579
|
+
get saveRequests() {
|
|
1580
|
+
return this._saveRequests;
|
|
1581
|
+
}
|
|
1582
|
+
set saveRequests(saveRequests) {
|
|
1583
|
+
this._saveRequests = saveRequests;
|
|
1553
1584
|
}
|
|
1554
1585
|
get platform() {
|
|
1555
1586
|
return this.worker.platform;
|
|
@@ -1571,7 +1602,7 @@ var HttpInterceptorClient = class {
|
|
|
1571
1602
|
if (this.worker instanceof LocalHttpInterceptorWorker_default) {
|
|
1572
1603
|
this.store.markLocalInterceptorAsRunning(this, isRunning);
|
|
1573
1604
|
} else {
|
|
1574
|
-
this.store.markRemoteInterceptorAsRunning(this, isRunning, this.
|
|
1605
|
+
this.store.markRemoteInterceptorAsRunning(this, isRunning, this.baseURL);
|
|
1575
1606
|
}
|
|
1576
1607
|
this.isRunning = isRunning;
|
|
1577
1608
|
}
|
|
@@ -1579,7 +1610,7 @@ var HttpInterceptorClient = class {
|
|
|
1579
1610
|
if (this.worker instanceof LocalHttpInterceptorWorker_default) {
|
|
1580
1611
|
return this.store.numberOfRunningLocalInterceptors;
|
|
1581
1612
|
} else {
|
|
1582
|
-
return this.store.numberOfRunningRemoteInterceptors(this.
|
|
1613
|
+
return this.store.numberOfRunningRemoteInterceptors(this.baseURL);
|
|
1583
1614
|
}
|
|
1584
1615
|
}
|
|
1585
1616
|
get(path) {
|
|
@@ -1605,7 +1636,7 @@ var HttpInterceptorClient = class {
|
|
|
1605
1636
|
}
|
|
1606
1637
|
createHttpRequestHandler(method, path) {
|
|
1607
1638
|
if (!this.isRunning) {
|
|
1608
|
-
throw new
|
|
1639
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
1609
1640
|
}
|
|
1610
1641
|
const handler = new this.Handler(this, method, path);
|
|
1611
1642
|
this.registerRequestHandler(handler);
|
|
@@ -1648,7 +1679,7 @@ var HttpInterceptorClient = class {
|
|
|
1648
1679
|
}
|
|
1649
1680
|
const responseDeclaration = await matchedHandler.applyResponseDeclaration(parsedRequest);
|
|
1650
1681
|
const response = HttpInterceptorWorker_default.createResponseFromDeclaration(request, responseDeclaration);
|
|
1651
|
-
if (this.
|
|
1682
|
+
if (this._saveRequests) {
|
|
1652
1683
|
const responseClone = response.clone();
|
|
1653
1684
|
const parsedResponse = await HttpInterceptorWorker_default.parseRawResponse(responseClone);
|
|
1654
1685
|
matchedHandler.saveInterceptedRequest(parsedRequest, parsedResponse);
|
|
@@ -1677,7 +1708,7 @@ var HttpInterceptorClient = class {
|
|
|
1677
1708
|
}
|
|
1678
1709
|
clear(options = {}) {
|
|
1679
1710
|
if (!this.isRunning) {
|
|
1680
|
-
throw new
|
|
1711
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
1681
1712
|
}
|
|
1682
1713
|
const clearResults = [];
|
|
1683
1714
|
for (const method of http.HTTP_METHODS) {
|
|
@@ -1882,17 +1913,17 @@ var InvalidWebSocketMessage = class extends Error {
|
|
|
1882
1913
|
};
|
|
1883
1914
|
var InvalidWebSocketMessage_default = InvalidWebSocketMessage;
|
|
1884
1915
|
|
|
1885
|
-
// src/webSocket/errors/
|
|
1886
|
-
var
|
|
1916
|
+
// src/webSocket/errors/NotRunningWebSocketHandlerError.ts
|
|
1917
|
+
var NotRunningWebSocketHandlerError = class extends Error {
|
|
1887
1918
|
static {
|
|
1888
|
-
__name(this, "
|
|
1919
|
+
__name(this, "NotRunningWebSocketHandlerError");
|
|
1889
1920
|
}
|
|
1890
1921
|
constructor() {
|
|
1891
1922
|
super("Web socket handler is not running.");
|
|
1892
|
-
this.name = "
|
|
1923
|
+
this.name = "NotRunningWebSocketHandlerError";
|
|
1893
1924
|
}
|
|
1894
1925
|
};
|
|
1895
|
-
var
|
|
1926
|
+
var NotRunningWebSocketHandlerError_default = NotRunningWebSocketHandlerError;
|
|
1896
1927
|
|
|
1897
1928
|
// src/webSocket/WebSocketHandler.ts
|
|
1898
1929
|
var WebSocketHandler = class {
|
|
@@ -2070,7 +2101,7 @@ var WebSocketHandler = class {
|
|
|
2070
2101
|
}
|
|
2071
2102
|
sendMessage(message, sockets = this.sockets) {
|
|
2072
2103
|
if (!this.isRunning) {
|
|
2073
|
-
throw new
|
|
2104
|
+
throw new NotRunningWebSocketHandlerError_default();
|
|
2074
2105
|
}
|
|
2075
2106
|
const stringifiedMessage = JSON.stringify(message);
|
|
2076
2107
|
for (const socket of sockets) {
|
|
@@ -2177,17 +2208,18 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2177
2208
|
static {
|
|
2178
2209
|
__name(this, "RemoteHttpInterceptorWorker");
|
|
2179
2210
|
}
|
|
2180
|
-
type;
|
|
2181
2211
|
webSocketClient;
|
|
2182
2212
|
httpHandlers = /* @__PURE__ */ new Map();
|
|
2183
2213
|
constructor(options) {
|
|
2184
2214
|
super();
|
|
2185
|
-
this.type = options.type;
|
|
2186
2215
|
const webSocketServerURL = this.deriveWebSocketServerURL(options.serverURL);
|
|
2187
2216
|
this.webSocketClient = new WebSocketClient_default({
|
|
2188
2217
|
url: webSocketServerURL.toString()
|
|
2189
2218
|
});
|
|
2190
2219
|
}
|
|
2220
|
+
get type() {
|
|
2221
|
+
return "remote";
|
|
2222
|
+
}
|
|
2191
2223
|
deriveWebSocketServerURL(serverURL) {
|
|
2192
2224
|
const webSocketServerURL = new URL(serverURL);
|
|
2193
2225
|
webSocketServerURL.protocol = serverURL.protocol.replace(/^http(s)?:$/, "ws$1:");
|
|
@@ -2246,7 +2278,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2246
2278
|
}
|
|
2247
2279
|
async use(interceptor, method, rawURL, createResponse) {
|
|
2248
2280
|
if (!this.isRunning) {
|
|
2249
|
-
throw new
|
|
2281
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
2250
2282
|
}
|
|
2251
2283
|
const crypto = await importCrypto();
|
|
2252
2284
|
const url = new URL(rawURL);
|
|
@@ -2274,7 +2306,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2274
2306
|
}
|
|
2275
2307
|
async clearHandlers() {
|
|
2276
2308
|
if (!this.isRunning) {
|
|
2277
|
-
throw new
|
|
2309
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
2278
2310
|
}
|
|
2279
2311
|
this.httpHandlers.clear();
|
|
2280
2312
|
if (this.webSocketClient.isRunning) {
|
|
@@ -2283,7 +2315,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2283
2315
|
}
|
|
2284
2316
|
async clearInterceptorHandlers(interceptor) {
|
|
2285
2317
|
if (!this.isRunning) {
|
|
2286
|
-
throw new
|
|
2318
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
2287
2319
|
}
|
|
2288
2320
|
for (const handler of this.httpHandlers.values()) {
|
|
2289
2321
|
if (handler.interceptor === interceptor) {
|
|
@@ -2391,14 +2423,10 @@ var LocalHttpInterceptor = class {
|
|
|
2391
2423
|
static {
|
|
2392
2424
|
__name(this, "LocalHttpInterceptor");
|
|
2393
2425
|
}
|
|
2394
|
-
type;
|
|
2395
2426
|
store = new HttpInterceptorStore_default();
|
|
2396
2427
|
client;
|
|
2397
2428
|
constructor(options) {
|
|
2398
|
-
this.type = options.type;
|
|
2399
2429
|
const baseURL = new URL(options.baseURL);
|
|
2400
|
-
validateURLProtocol_default(baseURL, SUPPORTED_BASE_URL_PROTOCOLS);
|
|
2401
|
-
excludeURLParams_default(baseURL);
|
|
2402
2430
|
const worker = this.store.getOrCreateLocalWorker({});
|
|
2403
2431
|
this.client = new HttpInterceptorClient_default({
|
|
2404
2432
|
worker,
|
|
@@ -2409,9 +2437,27 @@ var LocalHttpInterceptor = class {
|
|
|
2409
2437
|
saveRequests: options.saveRequests
|
|
2410
2438
|
});
|
|
2411
2439
|
}
|
|
2440
|
+
get type() {
|
|
2441
|
+
return "local";
|
|
2442
|
+
}
|
|
2412
2443
|
get baseURL() {
|
|
2413
2444
|
return this.client.baseURLAsString;
|
|
2414
2445
|
}
|
|
2446
|
+
set baseURL(baseURL) {
|
|
2447
|
+
this.client.baseURL = new URL(baseURL);
|
|
2448
|
+
}
|
|
2449
|
+
get saveRequests() {
|
|
2450
|
+
return this.client.saveRequests;
|
|
2451
|
+
}
|
|
2452
|
+
set saveRequests(saveRequests) {
|
|
2453
|
+
this.client.saveRequests = saveRequests;
|
|
2454
|
+
}
|
|
2455
|
+
get onUnhandledRequest() {
|
|
2456
|
+
return this.client.onUnhandledRequest;
|
|
2457
|
+
}
|
|
2458
|
+
set onUnhandledRequest(onUnhandledRequest) {
|
|
2459
|
+
this.client.onUnhandledRequest = onUnhandledRequest;
|
|
2460
|
+
}
|
|
2415
2461
|
get platform() {
|
|
2416
2462
|
return this.client.platform;
|
|
2417
2463
|
}
|
|
@@ -2466,14 +2512,10 @@ var RemoteHttpInterceptor = class {
|
|
|
2466
2512
|
static {
|
|
2467
2513
|
__name(this, "RemoteHttpInterceptor");
|
|
2468
2514
|
}
|
|
2469
|
-
type;
|
|
2470
2515
|
store = new HttpInterceptorStore_default();
|
|
2471
2516
|
client;
|
|
2472
2517
|
constructor(options) {
|
|
2473
|
-
this.type = options.type;
|
|
2474
2518
|
const baseURL = new URL(options.baseURL);
|
|
2475
|
-
validateURLProtocol_default(baseURL, SUPPORTED_BASE_URL_PROTOCOLS);
|
|
2476
|
-
excludeURLParams_default(baseURL);
|
|
2477
2519
|
const serverURL = new URL(baseURL.origin);
|
|
2478
2520
|
const worker = this.store.getOrCreateRemoteWorker({ serverURL });
|
|
2479
2521
|
this.client = new HttpInterceptorClient_default({
|
|
@@ -2485,9 +2527,27 @@ var RemoteHttpInterceptor = class {
|
|
|
2485
2527
|
saveRequests: options.saveRequests
|
|
2486
2528
|
});
|
|
2487
2529
|
}
|
|
2530
|
+
get type() {
|
|
2531
|
+
return "remote";
|
|
2532
|
+
}
|
|
2488
2533
|
get baseURL() {
|
|
2489
2534
|
return this.client.baseURLAsString;
|
|
2490
2535
|
}
|
|
2536
|
+
set baseURL(baseURL) {
|
|
2537
|
+
this.client.baseURL = new URL(baseURL);
|
|
2538
|
+
}
|
|
2539
|
+
get saveRequests() {
|
|
2540
|
+
return this.client.saveRequests;
|
|
2541
|
+
}
|
|
2542
|
+
set saveRequests(saveRequests) {
|
|
2543
|
+
this.client.saveRequests = saveRequests;
|
|
2544
|
+
}
|
|
2545
|
+
get onUnhandledRequest() {
|
|
2546
|
+
return this.client.onUnhandledRequest;
|
|
2547
|
+
}
|
|
2548
|
+
set onUnhandledRequest(onUnhandledRequest) {
|
|
2549
|
+
this.client.onUnhandledRequest = onUnhandledRequest;
|
|
2550
|
+
}
|
|
2491
2551
|
get platform() {
|
|
2492
2552
|
return this.client.platform;
|
|
2493
2553
|
}
|
|
@@ -2635,7 +2695,8 @@ var httpInterceptor = Object.freeze(new HttpInterceptorNamespace_default());
|
|
|
2635
2695
|
exports.DisabledRequestSavingError = DisabledRequestSavingError_default;
|
|
2636
2696
|
exports.InvalidFormDataError = InvalidFormDataError_default;
|
|
2637
2697
|
exports.InvalidJSONError = InvalidJSONError_default;
|
|
2638
|
-
exports.
|
|
2698
|
+
exports.NotRunningHttpInterceptorError = NotRunningHttpInterceptorError_default;
|
|
2699
|
+
exports.RunningHttpInterceptorError = RunningHttpInterceptorError_default;
|
|
2639
2700
|
exports.TimesCheckError = TimesCheckError_default;
|
|
2640
2701
|
exports.UnknownHttpInterceptorPlatformError = UnknownHttpInterceptorPlatformError_default;
|
|
2641
2702
|
exports.UnknownHttpInterceptorTypeError = UnknownHttpInterceptorTypeError_default;
|