@zimic/interceptor 1.2.6-canary.6 → 1.2.6-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.js +4 -13
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +4 -13
- package/dist/http.mjs.map +1 -1
- package/package.json +1 -1
- package/src/http/interceptor/HttpInterceptorClient.ts +5 -0
- package/src/http/requestHandler/HttpRequestHandlerClient.ts +2 -9
- package/src/http/requestHandler/LocalHttpRequestHandler.ts +1 -3
- package/src/http/requestHandler/RemoteHttpRequestHandler.ts +1 -3
- package/src/http/requestHandler/errors/NoResponseDefinitionError.ts +0 -8
package/package.json
CHANGED
|
@@ -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
|
|