@zimic/interceptor 0.15.0-canary.0 → 0.15.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.
Files changed (41) hide show
  1. package/README.md +6 -7
  2. package/dist/{chunk-YGJD3JT6.mjs → chunk-3O3YPVEG.mjs} +69 -104
  3. package/dist/chunk-3O3YPVEG.mjs.map +1 -0
  4. package/dist/{chunk-L6Y4EV6T.js → chunk-CWBDZYUG.js} +69 -104
  5. package/dist/chunk-CWBDZYUG.js.map +1 -0
  6. package/dist/cli.js +7 -7
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cli.mjs +3 -3
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/http.d.ts +38 -35
  11. package/dist/http.js +173 -235
  12. package/dist/http.js.map +1 -1
  13. package/dist/http.mjs +173 -235
  14. package/dist/http.mjs.map +1 -1
  15. package/dist/server.d.ts +15 -10
  16. package/dist/server.js +5 -5
  17. package/dist/server.mjs +1 -1
  18. package/package.json +10 -10
  19. package/src/cli/server/start.ts +1 -1
  20. package/src/http/interceptor/HttpInterceptorClient.ts +23 -34
  21. package/src/http/interceptor/HttpInterceptorStore.ts +2 -2
  22. package/src/http/interceptor/LocalHttpInterceptor.ts +22 -25
  23. package/src/http/interceptor/RemoteHttpInterceptor.ts +22 -25
  24. package/src/http/interceptor/errors/NotStartedHttpInterceptorError.ts +1 -1
  25. package/src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts +1 -1
  26. package/src/http/interceptor/types/options.ts +3 -3
  27. package/src/http/interceptor/types/public.ts +12 -9
  28. package/src/http/interceptorWorker/HttpInterceptorWorker.ts +10 -28
  29. package/src/http/interceptorWorker/LocalHttpInterceptorWorker.ts +21 -25
  30. package/src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts +22 -26
  31. package/src/http/requestHandler/HttpRequestHandlerClient.ts +11 -22
  32. package/src/http/requestHandler/LocalHttpRequestHandler.ts +16 -20
  33. package/src/http/requestHandler/RemoteHttpRequestHandler.ts +18 -28
  34. package/src/http/requestHandler/types/public.ts +22 -24
  35. package/src/server/InterceptorServer.ts +45 -68
  36. package/src/server/types/public.ts +15 -10
  37. package/src/webSocket/WebSocketClient.ts +1 -1
  38. package/src/webSocket/WebSocketHandler.ts +11 -19
  39. package/src/webSocket/WebSocketServer.ts +4 -4
  40. package/dist/chunk-L6Y4EV6T.js.map +0 -1
  41. package/dist/chunk-YGJD3JT6.mjs.map +0 -1
package/dist/server.d.ts CHANGED
@@ -29,31 +29,36 @@ interface InterceptorServerOptions {
29
29
  */
30
30
  interface InterceptorServer {
31
31
  /**
32
- * @returns The hostname of the server.
32
+ * The hostname of the server.
33
+ *
33
34
  * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
34
35
  */
35
- hostname: () => string;
36
+ hostname: string;
36
37
  /**
37
- * @returns The port of the server.
38
+ * The port of the server.
39
+ *
38
40
  * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
39
41
  */
40
- port: () => number | undefined;
42
+ port: number | undefined;
41
43
  /**
44
+ * Whether to log warnings about unhandled requests to the console.
45
+ *
42
46
  * @default true
43
- * @returns Whether to log warnings about unhandled requests to the console.
44
47
  * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
45
48
  */
46
- logUnhandledRequests: () => boolean;
49
+ logUnhandledRequests: boolean;
47
50
  /**
48
- * @returns The HTTP URL of the server.
51
+ * The HTTP URL of the server.
52
+ *
49
53
  * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
50
54
  */
51
- httpURL: () => string | undefined;
55
+ httpURL: string | undefined;
52
56
  /**
53
- * @returns Whether the server is running.
57
+ * Whether the server is running.
58
+ *
54
59
  * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
55
60
  */
56
- isRunning: () => boolean;
61
+ isRunning: boolean;
57
62
  /**
58
63
  * Starts the server.
59
64
  *
package/dist/server.js CHANGED
@@ -1,25 +1,25 @@
1
1
  'use strict';
2
2
 
3
- var chunkL6Y4EV6T_js = require('./chunk-L6Y4EV6T.js');
3
+ var chunkCWBDZYUG_js = require('./chunk-CWBDZYUG.js');
4
4
  require('./chunk-WCQVDF3K.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "DEFAULT_ACCESS_CONTROL_HEADERS", {
9
9
  enumerable: true,
10
- get: function () { return chunkL6Y4EV6T_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
10
+ get: function () { return chunkCWBDZYUG_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
11
11
  });
12
12
  Object.defineProperty(exports, "DEFAULT_PREFLIGHT_STATUS_CODE", {
13
13
  enumerable: true,
14
- get: function () { return chunkL6Y4EV6T_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
14
+ get: function () { return chunkCWBDZYUG_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
15
15
  });
16
16
  Object.defineProperty(exports, "NotStartedInterceptorServerError", {
17
17
  enumerable: true,
18
- get: function () { return chunkL6Y4EV6T_js.NotStartedInterceptorServerError_default; }
18
+ get: function () { return chunkCWBDZYUG_js.NotStartedInterceptorServerError_default; }
19
19
  });
20
20
  Object.defineProperty(exports, "interceptorServer", {
21
21
  enumerable: true,
22
- get: function () { return chunkL6Y4EV6T_js.interceptorServer; }
22
+ get: function () { return chunkCWBDZYUG_js.interceptorServer; }
23
23
  });
24
24
  //# sourceMappingURL=server.js.map
25
25
  //# sourceMappingURL=server.js.map
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, NotStartedInterceptorServerError_default as NotStartedInterceptorServerError, interceptorServer } from './chunk-YGJD3JT6.mjs';
1
+ export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, NotStartedInterceptorServerError_default as NotStartedInterceptorServerError, interceptorServer } from './chunk-3O3YPVEG.mjs';
2
2
  import './chunk-CGILA3WO.mjs';
3
3
  //# sourceMappingURL=server.mjs.map
4
4
  //# sourceMappingURL=server.mjs.map
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "api",
15
15
  "static"
16
16
  ],
17
- "version": "0.15.0-canary.0",
17
+ "version": "0.15.0-canary.2",
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "https://github.com/zimicjs/zimic.git",
@@ -74,7 +74,7 @@
74
74
  "./package.json": "./package.json"
75
75
  },
76
76
  "dependencies": {
77
- "@whatwg-node/server": "0.9.70",
77
+ "@whatwg-node/server": "0.10.1",
78
78
  "chalk": "4.1.2",
79
79
  "execa": "9.5.2",
80
80
  "isomorphic-ws": "5.0.0",
@@ -86,20 +86,20 @@
86
86
  "bufferutil": "4.0.9"
87
87
  },
88
88
  "devDependencies": {
89
- "@types/node": "^22.13.8",
90
- "@types/ws": "^8.5.14",
89
+ "@types/node": "^22.13.10",
90
+ "@types/ws": "^8.18.0",
91
91
  "@types/yargs": "^17.0.33",
92
- "@vitest/browser": "^3.0.7",
93
- "@vitest/coverage-istanbul": "^3.0.7",
92
+ "@vitest/browser": "^3.0.8",
93
+ "@vitest/coverage-istanbul": "^3.0.8",
94
94
  "dotenv-cli": "^8.0.0",
95
- "eslint": "^9.21.0",
96
- "playwright": "^1.50.1",
95
+ "eslint": "^9.22.0",
96
+ "playwright": "^1.51.0",
97
97
  "tsup": "^8.4.0",
98
98
  "typescript": "^5.8.2",
99
- "vitest": "^3.0.7",
99
+ "vitest": "^3.0.8",
100
100
  "@zimic/eslint-config-node": "0.0.0",
101
- "@zimic/tsconfig": "0.0.0",
102
101
  "@zimic/lint-staged-config": "0.0.0",
102
+ "@zimic/tsconfig": "0.0.0",
103
103
  "@zimic/utils": "0.0.0"
104
104
  },
105
105
  "peerDependencies": {
@@ -59,7 +59,7 @@ async function startInterceptorServer({
59
59
 
60
60
  await server.start();
61
61
 
62
- logWithPrefix(`${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${server.httpURL()}`);
62
+ logWithPrefix(`${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${server.httpURL}`);
63
63
 
64
64
  if (onReady) {
65
65
  try {
@@ -31,10 +31,11 @@ class HttpInterceptorClient<
31
31
  > {
32
32
  private worker: HttpInterceptorWorker;
33
33
  private store: HttpInterceptorStore;
34
+
34
35
  private _baseURL: URL;
35
- private _isRunning = false;
36
- private _onUnhandledRequest?: UnhandledRequestStrategy;
37
- private _shouldSaveRequests = false;
36
+ isRunning = false;
37
+ onUnhandledRequest?: UnhandledRequestStrategy;
38
+ shouldSaveRequests = false;
38
39
 
39
40
  private Handler: HandlerConstructor;
40
41
 
@@ -62,34 +63,22 @@ class HttpInterceptorClient<
62
63
  this.store = options.store;
63
64
  this._baseURL = options.baseURL;
64
65
  this.Handler = options.Handler;
65
- this._onUnhandledRequest = options.onUnhandledRequest;
66
- this._shouldSaveRequests = options.saveRequests ?? false;
66
+ this.onUnhandledRequest = options.onUnhandledRequest;
67
+ this.shouldSaveRequests = options.saveRequests ?? false;
67
68
  }
68
69
 
69
- baseURL() {
70
+ get baseURLAsString() {
70
71
  const baseURL = this._baseURL;
71
72
 
72
73
  if (baseURL.href === `${baseURL.origin}/`) {
73
74
  return baseURL.origin;
74
75
  }
75
76
 
76
- return baseURL.toString();
77
- }
78
-
79
- platform() {
80
- return this.worker.platform();
81
- }
82
-
83
- onUnhandledRequest() {
84
- return this._onUnhandledRequest;
85
- }
86
-
87
- isRunning() {
88
- return this.worker.isRunning() && this._isRunning;
77
+ return baseURL.href;
89
78
  }
90
79
 
91
- shouldSaveRequests() {
92
- return this._shouldSaveRequests;
80
+ get platform() {
81
+ return this.worker.platform;
93
82
  }
94
83
 
95
84
  async start() {
@@ -115,12 +104,12 @@ class HttpInterceptorClient<
115
104
  } else {
116
105
  this.store.markRemoteInterceptorAsRunning(this, isRunning, this._baseURL);
117
106
  }
118
- this._isRunning = isRunning;
107
+ this.isRunning = isRunning;
119
108
  }
120
109
 
121
110
  private numberOfRunningInterceptors() {
122
111
  if (this.worker instanceof LocalHttpInterceptorWorker) {
123
- return this.store.numberOfRunningLocalInterceptors();
112
+ return this.store.numberOfRunningLocalInterceptors;
124
113
  } else {
125
114
  return this.store.numberOfRunningRemoteInterceptors(this._baseURL);
126
115
  }
@@ -158,7 +147,7 @@ class HttpInterceptorClient<
158
147
  Method extends HttpSchemaMethod<Schema>,
159
148
  Path extends HttpSchemaPath<Schema, Method>,
160
149
  >(method: Method, path: Path): HttpRequestHandler<Schema, Method, Path> {
161
- if (!this.isRunning()) {
150
+ if (!this.isRunning) {
162
151
  throw new NotStartedHttpInterceptorError();
163
152
  }
164
153
 
@@ -173,30 +162,30 @@ class HttpInterceptorClient<
173
162
  Path extends HttpSchemaPath<Schema, Method>,
174
163
  StatusCode extends HttpStatusCode = never,
175
164
  >(handler: InternalHttpRequestHandler<Schema, Method, Path, StatusCode>) {
176
- const handlerClients = this.handlerClientsByMethod[handler.method()].get(handler.path()) ?? [];
165
+ const handlerClients = this.handlerClientsByMethod[handler.method].get(handler.path) ?? [];
177
166
 
178
- const isAlreadyRegistered = handlerClients.includes(handler.client());
167
+ const isAlreadyRegistered = handlerClients.includes(handler.client);
179
168
  if (isAlreadyRegistered) {
180
169
  return;
181
170
  }
182
171
 
183
- handlerClients.push(handler.client());
172
+ handlerClients.push(handler.client);
184
173
 
185
174
  const isFirstHandlerForMethodPath = handlerClients.length === 1;
186
175
  if (!isFirstHandlerForMethodPath) {
187
176
  return;
188
177
  }
189
178
 
190
- this.handlerClientsByMethod[handler.method()].set(handler.path(), handlerClients);
179
+ this.handlerClientsByMethod[handler.method].set(handler.path, handlerClients);
191
180
 
192
- const url = joinURL(this.baseURL(), handler.path());
181
+ const url = joinURL(this.baseURLAsString, handler.path);
193
182
  const urlRegex = createRegExpFromURL(url);
194
183
 
195
- const registrationResult = this.worker.use(this, handler.method(), url, async (context) => {
184
+ const registrationResult = this.worker.use(this, handler.method, url, async (context) => {
196
185
  const response = await this.handleInterceptedRequest(
197
186
  urlRegex,
198
- handler.method(),
199
- handler.path(),
187
+ handler.method,
188
+ handler.path,
200
189
  context as HttpInterceptorRequestContext<Schema, Method, Path>,
201
190
  );
202
191
  return response;
@@ -225,7 +214,7 @@ class HttpInterceptorClient<
225
214
  const responseDeclaration = await matchedHandler.applyResponseDeclaration(parsedRequest);
226
215
  const response = HttpInterceptorWorker.createResponseFromDeclaration(request, responseDeclaration);
227
216
 
228
- if (this.shouldSaveRequests()) {
217
+ if (this.shouldSaveRequests) {
229
218
  const responseClone = response.clone();
230
219
 
231
220
  const parsedResponse = await HttpInterceptorWorker.parseRawResponse<
@@ -275,7 +264,7 @@ class HttpInterceptorClient<
275
264
  }
276
265
 
277
266
  clear(options: { onCommitSuccess?: () => void; onCommitError?: () => void } = {}) {
278
- if (!this.isRunning()) {
267
+ if (!this.isRunning) {
279
268
  throw new NotStartedHttpInterceptorError();
280
269
  }
281
270
 
@@ -16,7 +16,7 @@ class HttpInterceptorStore {
16
16
 
17
17
  private class = HttpInterceptorStore;
18
18
 
19
- localWorker() {
19
+ get localWorker() {
20
20
  return this.class._localWorker;
21
21
  }
22
22
 
@@ -24,7 +24,7 @@ class HttpInterceptorStore {
24
24
  return this.class.remoteWorkers.get(baseURL.origin);
25
25
  }
26
26
 
27
- numberOfRunningLocalInterceptors() {
27
+ get numberOfRunningLocalInterceptors() {
28
28
  return this.class.runningLocalInterceptors.size;
29
29
  }
30
30
 
@@ -13,7 +13,8 @@ class LocalHttpInterceptor<Schema extends HttpSchema> implements PublicLocalHttp
13
13
  readonly type: 'local';
14
14
 
15
15
  private store = new HttpInterceptorStore();
16
- private _client: HttpInterceptorClient<Schema>;
16
+
17
+ client: HttpInterceptorClient<Schema>;
17
18
 
18
19
  constructor(options: LocalHttpInterceptorOptions) {
19
20
  this.type = options.type;
@@ -24,7 +25,7 @@ class LocalHttpInterceptor<Schema extends HttpSchema> implements PublicLocalHttp
24
25
 
25
26
  const worker = this.store.getOrCreateLocalWorker({});
26
27
 
27
- this._client = new HttpInterceptorClient<Schema>({
28
+ this.client = new HttpInterceptorClient<Schema>({
28
29
  worker,
29
30
  store: this.store,
30
31
  baseURL,
@@ -34,73 +35,69 @@ class LocalHttpInterceptor<Schema extends HttpSchema> implements PublicLocalHttp
34
35
  });
35
36
  }
36
37
 
37
- client() {
38
- return this._client;
39
- }
40
-
41
- baseURL() {
42
- return this._client.baseURL();
38
+ get baseURL() {
39
+ return this.client.baseURLAsString;
43
40
  }
44
41
 
45
- platform() {
46
- return this._client.platform();
42
+ get platform() {
43
+ return this.client.platform;
47
44
  }
48
45
 
49
- isRunning() {
50
- return this._client.isRunning();
46
+ get isRunning() {
47
+ return this.client.isRunning;
51
48
  }
52
49
 
53
50
  async start() {
54
- if (this.isRunning()) {
51
+ if (this.isRunning) {
55
52
  return;
56
53
  }
57
54
 
58
- await this._client.start();
55
+ await this.client.start();
59
56
  }
60
57
 
61
58
  async stop() {
62
- if (!this.isRunning()) {
59
+ if (!this.isRunning) {
63
60
  return;
64
61
  }
65
62
 
66
63
  this.clear();
67
- await this._client.stop();
64
+ await this.client.stop();
68
65
  }
69
66
 
70
67
  get = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
71
- return this._client.get(path);
68
+ return this.client.get(path);
72
69
  }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'GET'>;
73
70
 
74
71
  post = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
75
- return this._client.post(path);
72
+ return this.client.post(path);
76
73
  }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'POST'>;
77
74
 
78
75
  patch = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
79
- return this._client.patch(path);
76
+ return this.client.patch(path);
80
77
  }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;
81
78
 
82
79
  put = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
83
- return this._client.put(path);
80
+ return this.client.put(path);
84
81
  }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'PUT'>;
85
82
 
86
83
  delete = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
87
- return this._client.delete(path);
84
+ return this.client.delete(path);
88
85
  }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;
89
86
 
90
87
  head = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
91
- return this._client.head(path);
88
+ return this.client.head(path);
92
89
  }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;
93
90
 
94
91
  options = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
95
- return this._client.options(path);
92
+ return this.client.options(path);
96
93
  }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;
97
94
 
98
95
  checkTimes() {
99
- this._client.checkTimes();
96
+ this.client.checkTimes();
100
97
  }
101
98
 
102
99
  clear() {
103
- this._client.clear();
100
+ this.client.clear();
104
101
  }
105
102
  }
106
103
 
@@ -13,7 +13,8 @@ class RemoteHttpInterceptor<Schema extends HttpSchema> implements PublicRemoteHt
13
13
  readonly type: 'remote';
14
14
 
15
15
  private store = new HttpInterceptorStore();
16
- private _client: HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>;
16
+
17
+ client: HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>;
17
18
 
18
19
  constructor(options: RemoteHttpInterceptorOptions) {
19
20
  this.type = options.type;
@@ -26,7 +27,7 @@ class RemoteHttpInterceptor<Schema extends HttpSchema> implements PublicRemoteHt
26
27
 
27
28
  const worker = this.store.getOrCreateRemoteWorker({ serverURL });
28
29
 
29
- this._client = new HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>({
30
+ this.client = new HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>({
30
31
  worker,
31
32
  store: this.store,
32
33
  baseURL,
@@ -36,71 +37,67 @@ class RemoteHttpInterceptor<Schema extends HttpSchema> implements PublicRemoteHt
36
37
  });
37
38
  }
38
39
 
39
- client() {
40
- return this._client;
41
- }
42
-
43
- baseURL() {
44
- return this._client.baseURL();
40
+ get baseURL() {
41
+ return this.client.baseURLAsString;
45
42
  }
46
43
 
47
- platform() {
48
- return this._client.platform();
44
+ get platform() {
45
+ return this.client.platform;
49
46
  }
50
47
 
51
- isRunning() {
52
- return this._client.isRunning();
48
+ get isRunning() {
49
+ return this.client.isRunning;
53
50
  }
54
51
 
55
52
  async start() {
56
- if (this.isRunning()) {
53
+ if (this.isRunning) {
57
54
  return;
58
55
  }
59
56
 
60
- await this._client.start();
57
+ await this.client.start();
61
58
  }
62
59
 
63
60
  async stop() {
64
- if (!this.isRunning()) {
61
+ if (!this.isRunning) {
65
62
  return;
66
63
  }
67
64
 
68
65
  await this.clear();
69
- await this._client.stop();
66
+ await this.client.stop();
70
67
  }
71
68
 
72
69
  get = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
73
- return this._client.get(path);
70
+ return this.client.get(path);
74
71
  }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'GET'>;
75
72
 
76
73
  post = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
77
- return this._client.post(path);
74
+ return this.client.post(path);
78
75
  }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'POST'>;
79
76
 
80
77
  patch = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
81
- return this._client.patch(path);
78
+ return this.client.patch(path);
82
79
  }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;
83
80
 
84
81
  put = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
85
- return this._client.put(path);
82
+ return this.client.put(path);
86
83
  }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'PUT'>;
87
84
 
88
85
  delete = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
89
- return this._client.delete(path);
86
+ return this.client.delete(path);
90
87
  }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;
91
88
 
92
89
  head = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
93
- return this._client.head(path);
90
+ return this.client.head(path);
94
91
  }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;
95
92
 
96
93
  options = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {
97
- return this._client.options(path);
94
+ return this.client.options(path);
98
95
  }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;
99
96
 
100
97
  checkTimes() {
101
98
  return new Promise<void>((resolve, reject) => {
102
99
  try {
103
- this._client.checkTimes();
100
+ this.client.checkTimes();
104
101
  resolve();
105
102
  } catch (error) {
106
103
  reject(error);
@@ -110,7 +107,7 @@ class RemoteHttpInterceptor<Schema extends HttpSchema> implements PublicRemoteHt
110
107
 
111
108
  async clear() {
112
109
  await new Promise<void>((resolve, reject) => {
113
- this._client.clear({
110
+ this.client.clear({
114
111
  onCommitSuccess: resolve,
115
112
  onCommitError: reject,
116
113
  });
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorstart `interceptor.start()` API reference}
5
5
  * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorstop `interceptor.stop()` API reference}
6
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorisrunning `interceptor.isRunning()` API reference}
6
+ * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorisrunning `interceptor.isRunning` API reference}
7
7
  */
8
8
  class NotStartedHttpInterceptorError extends Error {
9
9
  constructor() {
@@ -2,7 +2,7 @@
2
2
  * An error thrown when an unknown interceptor platform is detected. Currently, the platforms `node` and `browser` are
3
3
  * supported.
4
4
  *
5
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform()` API reference}
5
+ * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform` API reference}
6
6
  */
7
7
  class UnknownHttpInterceptorPlatformError extends Error {
8
8
  /* istanbul ignore next -- @preserve
@@ -12,7 +12,7 @@ export type HttpInterceptorType = 'local' | 'remote';
12
12
  /**
13
13
  * The platform where an HTTP interceptor is running.
14
14
  *
15
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform()` API reference}
15
+ * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform` API reference}
16
16
  */
17
17
  export type HttpInterceptorPlatform = 'node' | 'browser';
18
18
 
@@ -121,9 +121,9 @@ export interface SharedHttpInterceptorOptions {
121
121
  /**
122
122
  * Whether {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httprequesthandler request handlers}
123
123
  * should save their intercepted requests in memory and make them accessible through
124
- * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-handlerrequests `handler.requests()`}.
124
+ * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-handlerrequests `handler.requests`}.
125
125
  *
126
- * **IMPORTANT**: Saving the intercepted requests will lead to a memory leak if not accompanied by clearing of the
126
+ * **Important**: Saving the intercepted requests will lead to a memory leak if not accompanied by clearing of the
127
127
  * interceptor or disposal of the handlers (i.e. garbage collection). If you plan on accessing those requests, such as
128
128
  * to assert them in your tests, set this option to `true` and make sure to regularly clear the interceptor. A common
129
129
  * practice is to call
@@ -13,22 +13,25 @@ import { HttpInterceptorPlatform } from './options';
13
13
  // eslint-disable-next-line @typescript-eslint/naming-convention
14
14
  export interface HttpInterceptor<_Schema extends HttpSchema> {
15
15
  /**
16
- * @returns The base URL used by the interceptor.
17
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorbaseurl `interceptor.baseURL()` API reference}
16
+ * The base URL used by the interceptor.
17
+ *
18
+ * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorbaseurl `interceptor.baseURL` API reference}
18
19
  */
19
- baseURL: () => string;
20
+ baseURL: string;
20
21
 
21
22
  /**
22
- * @returns The platform the interceptor is running on.
23
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform()` API reference}
23
+ * The platform the interceptor is running on.
24
+ *
25
+ * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform` API reference}
24
26
  */
25
- platform: () => HttpInterceptorPlatform | null;
27
+ platform: HttpInterceptorPlatform | null;
26
28
 
27
29
  /**
28
- * @returns Whether the interceptor is currently running and ready to use.
29
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorisrunning `interceptor.isRunning()` API reference}
30
+ * Whether the interceptor is currently running and ready to use.
31
+ *
32
+ * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorisrunning `interceptor.isRunning` API reference}
30
33
  */
31
- isRunning: () => boolean;
34
+ isRunning: boolean;
32
35
 
33
36
  /**
34
37
  * Starts the interceptor, allowing it to intercept HTTP requests.