@zimic/interceptor 0.19.1-canary.2 → 0.19.1-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-6PRFBMY7.mjs → chunk-7BR57OM2.mjs} +3 -3
- package/dist/chunk-7BR57OM2.mjs.map +1 -0
- package/dist/{chunk-3NJLJSD6.js → chunk-QB2A2272.js} +3 -3
- package/dist/chunk-QB2A2272.js.map +1 -0
- package/dist/cli.js +20 -20
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/http.d.ts +262 -467
- package/dist/http.js +5 -5
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +5 -5
- package/dist/http.mjs.map +1 -1
- package/dist/server.d.ts +14 -15
- package/dist/server.js +6 -6
- package/dist/server.mjs +1 -1
- package/package.json +3 -3
- package/src/cli/server/start.ts +1 -1
- package/src/cli/server/token/create.ts +1 -1
- package/src/http/interceptor/errors/NotRunningHttpInterceptorError.ts +3 -3
- package/src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts +2 -2
- package/src/http/interceptor/errors/RunningHttpInterceptorError.ts +3 -3
- package/src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts +1 -1
- package/src/http/interceptor/factory.ts +1 -9
- package/src/http/interceptor/types/options.ts +32 -132
- package/src/http/interceptor/types/public.ts +153 -236
- package/src/http/interceptor/types/schema.ts +2 -3
- package/src/http/interceptorWorker/HttpInterceptorWorker.ts +1 -1
- package/src/http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError.ts +2 -2
- package/src/http/requestHandler/errors/DisabledRequestSavingError.ts +2 -2
- package/src/http/requestHandler/errors/TimesCheckError.ts +1 -1
- package/src/http/requestHandler/types/public.ts +60 -73
- package/src/http/requestHandler/types/restrictions.ts +6 -6
- package/src/server/errors/InvalidInterceptorTokenError.ts +1 -1
- package/src/server/errors/InvalidInterceptorTokenFileError.ts +1 -1
- package/src/server/errors/InvalidInterceptorTokenValueError.ts +1 -1
- package/src/server/errors/RunningInterceptorServerError.ts +1 -1
- package/src/server/factory.ts +3 -3
- package/src/server/types/options.ts +2 -3
- package/src/server/types/public.ts +8 -8
- package/dist/chunk-3NJLJSD6.js.map +0 -1
- package/dist/chunk-6PRFBMY7.mjs.map +0 -1
|
@@ -3,42 +3,11 @@ import { HttpSchema } from '@zimic/http';
|
|
|
3
3
|
import { SyncHttpInterceptorMethodHandler, AsyncHttpInterceptorMethodHandler } from './handlers';
|
|
4
4
|
import { HttpInterceptorPlatform, RemoteHttpInterceptorOptions, UnhandledRequestStrategy } from './options';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Configures if the intercepted requests are saved and how they are handled.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#saving-requests Saving intercepted requests}
|
|
10
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/guides‐testing‐interceptor Testing}
|
|
11
|
-
*/
|
|
6
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference} */
|
|
12
7
|
export interface HttpInterceptorRequestSaving {
|
|
13
|
-
/**
|
|
14
|
-
* Whether {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httprequesthandler request handlers}
|
|
15
|
-
* should save their intercepted requests in memory and make them accessible through
|
|
16
|
-
* {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-handlerrequests `handler.requests`}.
|
|
17
|
-
*
|
|
18
|
-
* If you are using
|
|
19
|
-
* {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorchecktimes `interceptor.checkTimes()`}
|
|
20
|
-
* or
|
|
21
|
-
* {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-handlerchecktimes `handler.checkTimes()`}
|
|
22
|
-
* during tests, consider enabling this option to get more detailed information in `TimesCheckError` errors.
|
|
23
|
-
*
|
|
24
|
-
* **Important**: If `requestSaving.enabled` is `true`, make sure to regularly clear the interceptor to avoid requests
|
|
25
|
-
* accumulating in memory. A common practice is to call
|
|
26
|
-
* {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorclear `interceptor.clear()`}
|
|
27
|
-
* after each test.
|
|
28
|
-
*
|
|
29
|
-
* @default process.env.NODE_ENV === 'test'
|
|
30
|
-
*/
|
|
8
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference} */
|
|
31
9
|
enabled: boolean;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The safe number of requests to save in memory before logging warnings in the console. If `requestSaving.enabled` is
|
|
35
|
-
* `true` and the interceptor is not regularly cleared with
|
|
36
|
-
* {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorclear `interceptor.clear()`},
|
|
37
|
-
* the requests may accumulate in memory and cause performance issues. This option does not limit the number of
|
|
38
|
-
* requests saved in memory, only when to log warnings.
|
|
39
|
-
*
|
|
40
|
-
* @default 1000
|
|
41
|
-
*/
|
|
10
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference} */
|
|
42
11
|
safeLimit: number;
|
|
43
12
|
}
|
|
44
13
|
|
|
@@ -46,7 +15,7 @@ export interface HttpInterceptorRequestSaving {
|
|
|
46
15
|
* An interceptor to handle HTTP requests and return mock responses. The methods, paths, status codes, parameters, and
|
|
47
16
|
* responses are statically-typed based on the provided service schema.
|
|
48
17
|
*
|
|
49
|
-
* @see {@link https://
|
|
18
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor `HttpInterceptor` API reference}
|
|
50
19
|
*/
|
|
51
20
|
// The schema is still a generic type for backward compatibility.
|
|
52
21
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -54,15 +23,15 @@ export interface HttpInterceptor<_Schema extends HttpSchema> {
|
|
|
54
23
|
/**
|
|
55
24
|
* The base URL used by the interceptor.
|
|
56
25
|
*
|
|
57
|
-
* @see {@link https://
|
|
26
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorbaseurl `interceptor.baseURL` API reference}
|
|
58
27
|
*/
|
|
59
28
|
baseURL: string;
|
|
60
29
|
|
|
61
30
|
/**
|
|
62
31
|
* Configures if the intercepted requests are saved and how they are handled.
|
|
63
32
|
*
|
|
64
|
-
* @see {@link https://
|
|
65
|
-
* @see {@link https://
|
|
33
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference}
|
|
34
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/testing Testing}
|
|
66
35
|
*/
|
|
67
36
|
requestSaving: HttpInterceptorRequestSaving;
|
|
68
37
|
|
|
@@ -70,7 +39,7 @@ export interface HttpInterceptor<_Schema extends HttpSchema> {
|
|
|
70
39
|
* The platform the interceptor is running on.
|
|
71
40
|
*
|
|
72
41
|
* @readonly
|
|
73
|
-
* @see {@link https://
|
|
42
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorplatform `interceptor.platform` API reference}
|
|
74
43
|
*/
|
|
75
44
|
get platform(): HttpInterceptorPlatform | null;
|
|
76
45
|
|
|
@@ -78,7 +47,7 @@ export interface HttpInterceptor<_Schema extends HttpSchema> {
|
|
|
78
47
|
* Whether the interceptor is currently running and ready to use.
|
|
79
48
|
*
|
|
80
49
|
* @readonly
|
|
81
|
-
* @see {@link https://
|
|
50
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorisrunning `interceptor.isRunning` API reference}
|
|
82
51
|
*/
|
|
83
52
|
get isRunning(): boolean;
|
|
84
53
|
|
|
@@ -90,55 +59,53 @@ export interface HttpInterceptor<_Schema extends HttpSchema> {
|
|
|
90
59
|
*
|
|
91
60
|
* @throws {UnregisteredServiceWorkerError} When the worker is targeting a browser environment and the mock service
|
|
92
61
|
* worker is not registered.
|
|
93
|
-
* @see {@link https://
|
|
62
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()` API reference}
|
|
94
63
|
*/
|
|
95
64
|
start: () => Promise<void>;
|
|
96
65
|
|
|
97
66
|
/**
|
|
98
67
|
* Stops the interceptor, preventing it from intercepting HTTP requests. Stopped interceptors are automatically
|
|
99
68
|
* cleared, exactly as if
|
|
100
|
-
* {@link https://
|
|
101
|
-
*
|
|
69
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorclear `interceptor.clear()`} had been
|
|
70
|
+
* called.
|
|
102
71
|
*
|
|
103
|
-
* @see {@link https://
|
|
72
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstop `interceptor.stop()` API reference}
|
|
104
73
|
*/
|
|
105
74
|
stop: () => Promise<void>;
|
|
106
75
|
|
|
107
76
|
/**
|
|
108
77
|
* Checks if all handlers created by this interceptor have matched the number of requests declared with
|
|
109
|
-
* {@link https://
|
|
78
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()`}.
|
|
110
79
|
*
|
|
111
80
|
* If some handler has matched fewer or more requests than expected, this method will throw a `TimesCheckError` error,
|
|
112
81
|
* including a stack trace to the
|
|
113
|
-
* {@link https://
|
|
114
|
-
*
|
|
82
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()`} that was not
|
|
83
|
+
* satisfied.
|
|
115
84
|
*
|
|
116
85
|
* This is useful in an `afterEach` hook (or equivalent) to make sure that all expected requests were made at the end
|
|
117
86
|
* of each test.
|
|
118
87
|
*
|
|
119
|
-
* When
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* expected and received data. This is useful for debugging requests that did not match a handler with
|
|
124
|
-
* {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-handlerwithrestriction restrictions}.
|
|
88
|
+
* When {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `requestSaving.enabled`} is `true` in
|
|
89
|
+
* your interceptor, the `TimesCheckError` errors will also list each unmatched request with diff of the expected and
|
|
90
|
+
* received data. This is useful for debugging requests that did not match a handler with
|
|
91
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}.
|
|
125
92
|
*
|
|
126
93
|
* @throws {TimesCheckError} If some handler has matched less or more requests than the expected number of requests.
|
|
127
|
-
* @see {@link https://
|
|
128
|
-
* @see {@link https://
|
|
94
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorchecktimes `interceptor.checkTimes()` API reference}
|
|
95
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/testing Testing guide}
|
|
129
96
|
*/
|
|
130
97
|
checkTimes: (() => void) | (() => Promise<void>);
|
|
131
98
|
|
|
132
99
|
/**
|
|
133
100
|
* Clears the interceptor and all of its
|
|
134
|
-
* {@link https://
|
|
135
|
-
*
|
|
136
|
-
*
|
|
101
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} instances, including their
|
|
102
|
+
* registered responses and intercepted requests. After calling this method, the interceptor will no longer intercept
|
|
103
|
+
* any requests until new mock responses are registered.
|
|
137
104
|
*
|
|
138
105
|
* This method is useful to reset the interceptor mocks between tests.
|
|
139
106
|
*
|
|
140
107
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
141
|
-
* @see {@link https://
|
|
108
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorclear `interceptor.clear()` API reference}
|
|
142
109
|
*/
|
|
143
110
|
clear: (() => void) | (() => Promise<void>);
|
|
144
111
|
}
|
|
@@ -148,9 +115,9 @@ export interface HttpInterceptor<_Schema extends HttpSchema> {
|
|
|
148
115
|
* and responses are statically-typed based on the provided service schema.
|
|
149
116
|
*
|
|
150
117
|
* To intercept HTTP requests, the interceptor must have been started with
|
|
151
|
-
* {@link https://
|
|
118
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()`}.
|
|
152
119
|
*
|
|
153
|
-
* @see {@link https://
|
|
120
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor `HttpInterceptor` API reference}
|
|
154
121
|
*/
|
|
155
122
|
export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInterceptor<Schema> {
|
|
156
123
|
/** @readonly */
|
|
@@ -161,21 +128,19 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
161
128
|
* matching handler exists, this strategy will be used. If a function is provided, it will be called with the
|
|
162
129
|
* unhandled request.
|
|
163
130
|
*
|
|
164
|
-
* @see {@link https://
|
|
131
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests}
|
|
165
132
|
*/
|
|
166
133
|
onUnhandledRequest?: UnhandledRequestStrategy.Local;
|
|
167
134
|
|
|
168
135
|
/**
|
|
169
|
-
* Creates a GET
|
|
170
|
-
*
|
|
171
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
136
|
+
* Creates a GET {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
137
|
+
* The path and method must be declared in the interceptor schema.
|
|
172
138
|
*
|
|
173
139
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
174
140
|
* interceptor, and the method, path,
|
|
175
|
-
* {@link https://
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
141
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
142
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
143
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
179
144
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
180
145
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
181
146
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -183,25 +148,22 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
183
148
|
*
|
|
184
149
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
185
150
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
186
|
-
* @returns A GET
|
|
187
|
-
*
|
|
188
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
151
|
+
* @returns A GET {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
152
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
189
153
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
190
|
-
* @see {@link https://
|
|
154
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
191
155
|
*/
|
|
192
156
|
get: SyncHttpInterceptorMethodHandler<Schema, 'GET'>;
|
|
193
157
|
|
|
194
158
|
/**
|
|
195
|
-
* Creates a POST
|
|
196
|
-
*
|
|
197
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
159
|
+
* Creates a POST {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
160
|
+
* The path and method must be declared in the interceptor schema.
|
|
198
161
|
*
|
|
199
162
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
200
163
|
* interceptor, and the method, path,
|
|
201
|
-
* {@link https://
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
164
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
165
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
166
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
205
167
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
206
168
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
207
169
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -209,25 +171,22 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
209
171
|
*
|
|
210
172
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
211
173
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
212
|
-
* @returns A POST
|
|
213
|
-
*
|
|
214
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
174
|
+
* @returns A POST {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
175
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
215
176
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
216
|
-
* @see {@link https://
|
|
177
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
217
178
|
*/
|
|
218
179
|
post: SyncHttpInterceptorMethodHandler<Schema, 'POST'>;
|
|
219
180
|
|
|
220
181
|
/**
|
|
221
|
-
* Creates a PATCH
|
|
222
|
-
*
|
|
223
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
182
|
+
* Creates a PATCH {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
183
|
+
* The path and method must be declared in the interceptor schema.
|
|
224
184
|
*
|
|
225
185
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
226
186
|
* interceptor, and the method, path,
|
|
227
|
-
* {@link https://
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
187
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
188
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
189
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
231
190
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
232
191
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
233
192
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -235,25 +194,22 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
235
194
|
*
|
|
236
195
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
237
196
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
238
|
-
* @returns A PATCH
|
|
239
|
-
*
|
|
240
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
197
|
+
* @returns A PATCH {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
198
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
241
199
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
242
|
-
* @see {@link https://
|
|
200
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
243
201
|
*/
|
|
244
202
|
patch: SyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;
|
|
245
203
|
|
|
246
204
|
/**
|
|
247
|
-
* Creates a PUT
|
|
248
|
-
*
|
|
249
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
205
|
+
* Creates a PUT {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
206
|
+
* The path and method must be declared in the interceptor schema.
|
|
250
207
|
*
|
|
251
208
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
252
209
|
* interceptor, and the method, path,
|
|
253
|
-
* {@link https://
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
210
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
211
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
212
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
257
213
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
258
214
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
259
215
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -261,25 +217,22 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
261
217
|
*
|
|
262
218
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
263
219
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
264
|
-
* @returns A PUT
|
|
265
|
-
*
|
|
266
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
220
|
+
* @returns A PUT {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
221
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
267
222
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
268
|
-
* @see {@link https://
|
|
223
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
269
224
|
*/
|
|
270
225
|
put: SyncHttpInterceptorMethodHandler<Schema, 'PUT'>;
|
|
271
226
|
|
|
272
227
|
/**
|
|
273
|
-
* Creates a DELETE
|
|
274
|
-
*
|
|
275
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
228
|
+
* Creates a DELETE {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a
|
|
229
|
+
* path. The path and method must be declared in the interceptor schema.
|
|
276
230
|
*
|
|
277
231
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
278
232
|
* interceptor, and the method, path,
|
|
279
|
-
* {@link https://
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
233
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
234
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
235
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
283
236
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
284
237
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
285
238
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -287,25 +240,22 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
287
240
|
*
|
|
288
241
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
289
242
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
290
|
-
* @returns A DELETE
|
|
291
|
-
*
|
|
292
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
243
|
+
* @returns A DELETE {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
244
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
293
245
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
294
|
-
* @see {@link https://
|
|
246
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
295
247
|
*/
|
|
296
248
|
delete: SyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;
|
|
297
249
|
|
|
298
250
|
/**
|
|
299
|
-
* Creates a HEAD
|
|
300
|
-
*
|
|
301
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
251
|
+
* Creates a HEAD {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
252
|
+
* The path and method must be declared in the interceptor schema.
|
|
302
253
|
*
|
|
303
254
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
304
255
|
* interceptor, and the method, path,
|
|
305
|
-
* {@link https://
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
256
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
257
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
258
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
309
259
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
310
260
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
311
261
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -313,25 +263,22 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
313
263
|
*
|
|
314
264
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
315
265
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
316
|
-
* @returns A HEAD
|
|
317
|
-
*
|
|
318
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
266
|
+
* @returns A HEAD {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
267
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
319
268
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
320
|
-
* @see {@link https://
|
|
269
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
321
270
|
*/
|
|
322
271
|
head: SyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;
|
|
323
272
|
|
|
324
273
|
/**
|
|
325
|
-
* Creates an OPTIONS
|
|
326
|
-
*
|
|
327
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
274
|
+
* Creates an OPTIONS {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a
|
|
275
|
+
* path. The path and method must be declared in the interceptor schema.
|
|
328
276
|
*
|
|
329
277
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
330
278
|
* interceptor, and the method, path,
|
|
331
|
-
* {@link https://
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
279
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
280
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
281
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
335
282
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
336
283
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
337
284
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -339,11 +286,10 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
339
286
|
*
|
|
340
287
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
341
288
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
342
|
-
* @returns An OPTIONS
|
|
343
|
-
*
|
|
344
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
289
|
+
* @returns An OPTIONS {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
290
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
345
291
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
346
|
-
* @see {@link https://
|
|
292
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
347
293
|
*/
|
|
348
294
|
options: SyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;
|
|
349
295
|
|
|
@@ -357,11 +303,10 @@ export interface LocalHttpInterceptor<Schema extends HttpSchema> extends HttpInt
|
|
|
357
303
|
* and responses are statically-typed based on the provided service schema.
|
|
358
304
|
*
|
|
359
305
|
* To intercept HTTP requests, the interceptor must have been started with
|
|
360
|
-
* {@link https://
|
|
361
|
-
*
|
|
362
|
-
* running.
|
|
306
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()`} and an
|
|
307
|
+
* {@link https://zimic.dev/docs/interceptor/cli/server interceptor server} should be running.
|
|
363
308
|
*
|
|
364
|
-
* @see {@link https://
|
|
309
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor `HttpInterceptor` API reference}
|
|
365
310
|
*/
|
|
366
311
|
export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpInterceptor<Schema> {
|
|
367
312
|
/** @readonly */
|
|
@@ -371,7 +316,7 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
371
316
|
* Options to authenticate the interceptor when connecting to an interceptor server. This is required if the
|
|
372
317
|
* interceptor server was started with the `--tokens-dir` option.
|
|
373
318
|
*
|
|
374
|
-
* @see {@link https://
|
|
319
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication Interceptor server authentication}
|
|
375
320
|
*/
|
|
376
321
|
auth?: RemoteHttpInterceptorOptions['auth'];
|
|
377
322
|
|
|
@@ -380,26 +325,23 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
380
325
|
* matching handler exists, this strategy will be used. If a function is provided, it will be called with the
|
|
381
326
|
* unhandled request.
|
|
382
327
|
*
|
|
383
|
-
* @see {@link https://
|
|
328
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests}
|
|
384
329
|
*/
|
|
385
330
|
onUnhandledRequest?: UnhandledRequestStrategy.Remote;
|
|
386
331
|
|
|
387
332
|
/**
|
|
388
|
-
* Creates a GET
|
|
389
|
-
*
|
|
390
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
333
|
+
* Creates a GET {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
334
|
+
* The path and method must be declared in the interceptor schema.
|
|
391
335
|
*
|
|
392
|
-
* When using a
|
|
393
|
-
* {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptor}, creating
|
|
336
|
+
* When using a {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptor}, creating
|
|
394
337
|
* a handler is an asynchronous operation, so you need to `await` it. You can also chain any number of operations and
|
|
395
338
|
* apply them by awaiting the handler.
|
|
396
339
|
*
|
|
397
340
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
398
341
|
* interceptor, and the method, path,
|
|
399
|
-
* {@link https://
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
342
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
343
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
344
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
403
345
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
404
346
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
405
347
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -407,30 +349,26 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
407
349
|
*
|
|
408
350
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
409
351
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
410
|
-
* @returns A GET
|
|
411
|
-
*
|
|
412
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
352
|
+
* @returns A GET {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
353
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
413
354
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
414
|
-
* @see {@link https://
|
|
355
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
415
356
|
*/
|
|
416
357
|
get: AsyncHttpInterceptorMethodHandler<Schema, 'GET'>;
|
|
417
358
|
|
|
418
359
|
/**
|
|
419
|
-
* Creates a POST
|
|
420
|
-
*
|
|
421
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
360
|
+
* Creates a POST {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
361
|
+
* The path and method must be declared in the interceptor schema.
|
|
422
362
|
*
|
|
423
|
-
* When using a
|
|
424
|
-
* {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptor}, creating
|
|
363
|
+
* When using a {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptor}, creating
|
|
425
364
|
* a handler is an asynchronous operation, so you need to `await` it. You can also chain any number of operations and
|
|
426
365
|
* apply them by awaiting the handler.
|
|
427
366
|
*
|
|
428
367
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
429
368
|
* interceptor, and the method, path,
|
|
430
|
-
* {@link https://
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
369
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
370
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
371
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
434
372
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
435
373
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
436
374
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -438,30 +376,26 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
438
376
|
*
|
|
439
377
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
440
378
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
441
|
-
* @returns A POST
|
|
442
|
-
*
|
|
443
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
379
|
+
* @returns A POST {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
380
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
444
381
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
445
|
-
* @see {@link https://
|
|
382
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
446
383
|
*/
|
|
447
384
|
post: AsyncHttpInterceptorMethodHandler<Schema, 'POST'>;
|
|
448
385
|
|
|
449
386
|
/**
|
|
450
|
-
* Creates a PATCH
|
|
451
|
-
*
|
|
452
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
387
|
+
* Creates a PATCH {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
388
|
+
* The path and method must be declared in the interceptor schema.
|
|
453
389
|
*
|
|
454
|
-
* When using a
|
|
455
|
-
* {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptor}, creating
|
|
390
|
+
* When using a {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptor}, creating
|
|
456
391
|
* a handler is an asynchronous operation, so you need to `await` it. You can also chain any number of operations and
|
|
457
392
|
* apply them by awaiting the handler.
|
|
458
393
|
*
|
|
459
394
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
460
395
|
* interceptor, and the method, path,
|
|
461
|
-
* {@link https://
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
396
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
397
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
398
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
465
399
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
466
400
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
467
401
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -469,30 +403,26 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
469
403
|
*
|
|
470
404
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
471
405
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
472
|
-
* @returns A PATCH
|
|
473
|
-
*
|
|
474
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
406
|
+
* @returns A PATCH {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
407
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
475
408
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
476
|
-
* @see {@link https://
|
|
409
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
477
410
|
*/
|
|
478
411
|
patch: AsyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;
|
|
479
412
|
|
|
480
413
|
/**
|
|
481
|
-
* Creates a PUT
|
|
482
|
-
*
|
|
483
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
414
|
+
* Creates a PUT {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
415
|
+
* The path and method must be declared in the interceptor schema.
|
|
484
416
|
*
|
|
485
|
-
* When using a
|
|
486
|
-
* {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptor}, creating
|
|
417
|
+
* When using a {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptor}, creating
|
|
487
418
|
* a handler is an asynchronous operation, so you need to `await` it. You can also chain any number of operations and
|
|
488
419
|
* apply them by awaiting the handler.
|
|
489
420
|
*
|
|
490
421
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
491
422
|
* interceptor, and the method, path,
|
|
492
|
-
* {@link https://
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
423
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
424
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
425
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
496
426
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
497
427
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
498
428
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -500,30 +430,26 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
500
430
|
*
|
|
501
431
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
502
432
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
503
|
-
* @returns A PUT
|
|
504
|
-
*
|
|
505
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
433
|
+
* @returns A PUT {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
434
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
506
435
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
507
|
-
* @see {@link https://
|
|
436
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
508
437
|
*/
|
|
509
438
|
put: AsyncHttpInterceptorMethodHandler<Schema, 'PUT'>;
|
|
510
439
|
|
|
511
440
|
/**
|
|
512
|
-
* Creates a DELETE
|
|
513
|
-
*
|
|
514
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
441
|
+
* Creates a DELETE {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a
|
|
442
|
+
* path. The path and method must be declared in the interceptor schema.
|
|
515
443
|
*
|
|
516
|
-
* When using a
|
|
517
|
-
* {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptor}, creating
|
|
444
|
+
* When using a {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptor}, creating
|
|
518
445
|
* a handler is an asynchronous operation, so you need to `await` it. You can also chain any number of operations and
|
|
519
446
|
* apply them by awaiting the handler.
|
|
520
447
|
*
|
|
521
448
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
522
449
|
* interceptor, and the method, path,
|
|
523
|
-
* {@link https://
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
450
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
451
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
452
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
527
453
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
528
454
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
529
455
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -531,30 +457,26 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
531
457
|
*
|
|
532
458
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
533
459
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
534
|
-
* @returns A DELETE
|
|
535
|
-
*
|
|
536
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
460
|
+
* @returns A DELETE {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
461
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
537
462
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
538
|
-
* @see {@link https://
|
|
463
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
539
464
|
*/
|
|
540
465
|
delete: AsyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;
|
|
541
466
|
|
|
542
467
|
/**
|
|
543
|
-
* Creates a HEAD
|
|
544
|
-
*
|
|
545
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
468
|
+
* Creates a HEAD {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a path.
|
|
469
|
+
* The path and method must be declared in the interceptor schema.
|
|
546
470
|
*
|
|
547
|
-
* When using a
|
|
548
|
-
* {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptor}, creating
|
|
471
|
+
* When using a {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptor}, creating
|
|
549
472
|
* a handler is an asynchronous operation, so you need to `await` it. You can also chain any number of operations and
|
|
550
473
|
* apply them by awaiting the handler.
|
|
551
474
|
*
|
|
552
475
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
553
476
|
* interceptor, and the method, path,
|
|
554
|
-
* {@link https://
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
477
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
478
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
479
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
558
480
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
559
481
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
560
482
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -562,30 +484,26 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
562
484
|
*
|
|
563
485
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
564
486
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
565
|
-
* @returns A HEAD
|
|
566
|
-
*
|
|
567
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
487
|
+
* @returns A HEAD {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
488
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
568
489
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
569
|
-
* @see {@link https://
|
|
490
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
570
491
|
*/
|
|
571
492
|
head: AsyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;
|
|
572
493
|
|
|
573
494
|
/**
|
|
574
|
-
* Creates an OPTIONS
|
|
575
|
-
*
|
|
576
|
-
* a path. The path and method must be declared in the interceptor schema.
|
|
495
|
+
* Creates an OPTIONS {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for a
|
|
496
|
+
* path. The path and method must be declared in the interceptor schema.
|
|
577
497
|
*
|
|
578
|
-
* When using a
|
|
579
|
-
* {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptor}, creating
|
|
498
|
+
* When using a {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptor}, creating
|
|
580
499
|
* a handler is an asynchronous operation, so you need to `await` it. You can also chain any number of operations and
|
|
581
500
|
* apply them by awaiting the handler.
|
|
582
501
|
*
|
|
583
502
|
* After a request is intercepted, Zimic tries to find a handler that matches it, considering the base URL of the
|
|
584
503
|
* interceptor, and the method, path,
|
|
585
|
-
* {@link https://
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
* of the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
504
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}, and
|
|
505
|
+
* {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes limits on the number of requests} of
|
|
506
|
+
* the handler. The handlers are checked from the **last** one created to the first one, so new handlers have
|
|
589
507
|
* preference over older ones. This allows you to declare generic and specific handlers based on their order of
|
|
590
508
|
* creation. For example, a generic handler for `GET /users` can return an empty list, while a specific handler in a
|
|
591
509
|
* test case can return a list with some users. In this case, the specific handler will be considered first as long as
|
|
@@ -593,11 +511,10 @@ export interface RemoteHttpInterceptor<Schema extends HttpSchema> extends HttpIn
|
|
|
593
511
|
*
|
|
594
512
|
* @param path The path to intercept. Paths with dynamic parameters, such as `/users/:id`, are supported, but you need
|
|
595
513
|
* to specify the original path as a type parameter to get type-inference and type-validation.
|
|
596
|
-
* @returns An OPTIONS
|
|
597
|
-
*
|
|
598
|
-
* for the provided path. The path and method must be declared in the interceptor schema.
|
|
514
|
+
* @returns An OPTIONS {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler`} for the
|
|
515
|
+
* provided path. The path and method must be declared in the interceptor schema.
|
|
599
516
|
* @throws {NotRunningHttpInterceptorError} If the interceptor is not running.
|
|
600
|
-
* @see {@link https://
|
|
517
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}
|
|
601
518
|
*/
|
|
602
519
|
options: AsyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;
|
|
603
520
|
|