@zimic/interceptor 0.14.0-canary.22 → 0.14.0-canary.24

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/http.d.ts CHANGED
@@ -1,5 +1,17 @@
1
1
  import { HttpMethodSchema, HttpStatusCode, HttpRequest, HttpHeaders, HttpRequestHeadersSchema, InferPathParams, HttpSearchParams, HttpRequestSearchParamsSchema, HttpRequestBodySchema, HttpResponse, HttpResponseHeadersSchema, HttpResponseBodySchema, HttpResponseSchema, HttpHeadersInit, HttpSchema, HttpBody, HttpSchemaMethod, HttpSchemaPath, HttpHeadersSchema, HttpSearchParamsSchema, HttpFormData, HttpResponseSchemaStatusCode, HttpMethod, LiteralHttpSchemaPathFromNonLiteral } from '@zimic/http';
2
- import { Default, PossiblePromise, ReplaceBy, IfNever, DeepPartial, Range } from '@zimic/utils/types';
2
+
3
+ type Default<Type, IfEmpty = never> = [undefined | void] extends [Type] ? IfEmpty : Exclude<Type, undefined | void>;
4
+ type IfNever<Type, Yes, No = Type> = [Type] extends [never] ? Yes : No;
5
+ type PossiblePromise<Type> = Type | PromiseLike<Type>;
6
+ type ReplaceBy<Type, Source, Target> = Type extends Source ? Target : Type;
7
+ type PartialByKey<Type, Key extends keyof Type> = Omit<Type, Key> & Partial<Pick<Type, Key>>;
8
+ type DeepPartial<Type> = Type extends (...parameters: never[]) => unknown ? Type : Type extends (infer ArrayItem)[] ? DeepPartial<ArrayItem>[] : Type extends object ? {
9
+ [Key in keyof Type]?: DeepPartial<Type[Key]>;
10
+ } : Type;
11
+ interface Range<Type> {
12
+ min: Type;
13
+ max: Type;
14
+ }
3
15
 
4
16
  type HttpRequestHandlerResponseWithBody<ResponseSchema extends HttpResponseSchema> = unknown extends ResponseSchema['body'] ? {
5
17
  body?: null;
@@ -8,10 +20,13 @@ type HttpRequestHandlerResponseWithBody<ResponseSchema extends HttpResponseSchem
8
20
  } : {
9
21
  body: ReplaceBy<ResponseSchema['body'], ArrayBuffer, Blob>;
10
22
  };
23
+ type HttpRequestHandlerResponseHeaders<ResponseSchema extends HttpResponseSchema> = HttpHeadersInit<PartialByKey<Default<ResponseSchema['headers']>, 'content-type'>>;
11
24
  type HttpRequestHandlerResponseWithHeaders<ResponseSchema extends HttpResponseSchema> = undefined extends ResponseSchema['headers'] ? {
12
- headers?: undefined;
25
+ headers?: HttpRequestHandlerResponseHeaders<ResponseSchema>;
26
+ } : keyof ResponseSchema['headers'] extends 'content-type' ? {
27
+ headers?: HttpRequestHandlerResponseHeaders<ResponseSchema>;
13
28
  } : {
14
- headers: HttpHeadersInit<Default<ResponseSchema['headers']>>;
29
+ headers: HttpRequestHandlerResponseHeaders<ResponseSchema>;
15
30
  };
16
31
  /** A declaration of an HTTP response for an intercepted request. */
17
32
  type HttpRequestHandlerResponseDeclaration<MethodSchema extends HttpMethodSchema = HttpMethodSchema, StatusCode extends HttpStatusCode = HttpStatusCode> = StatusCode extends StatusCode ? {