@zimic/interceptor 1.2.6-canary.6 → 1.2.6

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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "api",
15
15
  "static"
16
16
  ],
17
- "version": "1.2.6-canary.6",
17
+ "version": "1.2.6",
18
18
  "homepage": "https://zimic.dev/docs/interceptor",
19
19
  "repository": {
20
20
  "type": "git",
@@ -284,6 +284,11 @@ class HttpInterceptorClient<
284
284
  }
285
285
 
286
286
  const responseDeclaration = await matchedHandler.applyResponseDeclaration(parsedRequest);
287
+
288
+ if (!responseDeclaration) {
289
+ return null;
290
+ }
291
+
287
292
  const response = HttpInterceptorWorker.createResponseFromDeclaration(request, responseDeclaration);
288
293
 
289
294
  if (this.requestSaving.enabled) {
@@ -20,7 +20,6 @@ import { random } from '@/utils/numbers';
20
20
 
21
21
  import HttpInterceptorClient from '../interceptor/HttpInterceptorClient';
22
22
  import DisabledRequestSavingError from './errors/DisabledRequestSavingError';
23
- import NoResponseDefinitionError from './errors/NoResponseDefinitionError';
24
23
  import TimesCheckError from './errors/TimesCheckError';
25
24
  import TimesDeclarationPointer from './errors/TimesDeclarationPointer';
26
25
  import { InternalHttpRequestHandler } from './types/public';
@@ -433,13 +432,7 @@ class HttpRequestHandlerClient<
433
432
  return typeof restriction === 'function';
434
433
  }
435
434
 
436
- async applyResponseDeclaration(
437
- request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,
438
- ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {
439
- if (!this.createResponseDeclaration) {
440
- throw new NoResponseDefinitionError();
441
- }
442
-
435
+ async applyResponseDeclaration(request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {
443
436
  if (this.createResponseDelay) {
444
437
  const delay = await this.createResponseDelay(request);
445
438
 
@@ -448,7 +441,7 @@ class HttpRequestHandlerClient<
448
441
  }
449
442
  }
450
443
 
451
- const appliedDeclaration = await this.createResponseDeclaration(request);
444
+ const appliedDeclaration = await this.createResponseDeclaration?.(request);
452
445
  return appliedDeclaration;
453
446
  }
454
447
 
@@ -92,9 +92,7 @@ class LocalHttpRequestHandler<
92
92
  return requestMatch;
93
93
  }
94
94
 
95
- async applyResponseDeclaration(
96
- request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,
97
- ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {
95
+ async applyResponseDeclaration(request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {
98
96
  return this.client.applyResponseDeclaration(request);
99
97
  }
100
98
 
@@ -132,9 +132,7 @@ class RemoteHttpRequestHandler<
132
132
  return requestMatch;
133
133
  }
134
134
 
135
- async applyResponseDeclaration(
136
- request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,
137
- ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {
135
+ async applyResponseDeclaration(request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {
138
136
  return this.client.applyResponseDeclaration(request);
139
137
  }
140
138
 
@@ -1,8 +0,0 @@
1
- class NoResponseDefinitionError extends TypeError {
2
- constructor() {
3
- super('Cannot generate a response without a definition. Use .respond() to set a response.');
4
- this.name = 'NoResponseDefinitionError';
5
- }
6
- }
7
-
8
- export default NoResponseDefinitionError;