From 8250215f180d315078111ad105a61e6e13115d4d Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 19 Dec 2024 10:24:39 +1300 Subject: [PATCH] remove generics from HttpClient tag service (#4169) --- .changeset/friendly-kiwis-end.md | 8 + packages/platform/dtslint/HttpApiClient.ts | 6 +- packages/platform/src/HttpClient.ts | 188 ++++++++++--------- packages/platform/src/internal/httpClient.ts | 160 ++++++++-------- 4 files changed, 190 insertions(+), 172 deletions(-) create mode 100644 .changeset/friendly-kiwis-end.md diff --git a/.changeset/friendly-kiwis-end.md b/.changeset/friendly-kiwis-end.md new file mode 100644 index 00000000000..cc25e61c21e --- /dev/null +++ b/.changeset/friendly-kiwis-end.md @@ -0,0 +1,8 @@ +--- +"@effect/platform": minor +--- + +remove generics from HttpClient tag service + +Instead you can now use `HttpClient.With` to specify the error and +requirement types. diff --git a/packages/platform/dtslint/HttpApiClient.ts b/packages/platform/dtslint/HttpApiClient.ts index 7c4a8005b41..268366d9453 100644 --- a/packages/platform/dtslint/HttpApiClient.ts +++ b/packages/platform/dtslint/HttpApiClient.ts @@ -83,7 +83,7 @@ Effect.gen(function*() { const clientEndpointEffect = HttpApiClient.endpoint(TestApi, "Group1", "EndpointA") // $ExpectType never type _clientEndpointEffectError = Effect.Effect.Error - // $ExpectType "ApiErrorR" | "Group1ErrorR" | "EndpointAErrorR" | "EndpointASuccessR" | "EndpointASecurityErrorR" | "Group1SecurityErrorR" | "ApiSecurityErrorR" | HttpClient + // $ExpectType "ApiErrorR" | "Group1ErrorR" | "EndpointAErrorR" | "EndpointASuccessR" | "EndpointASecurityErrorR" | "Group1SecurityErrorR" | "ApiSecurityErrorR" | HttpClient type _clientEndpointEffectContext = Effect.Effect.Context const clientEndpoint = yield* clientEndpointEffect @@ -100,7 +100,7 @@ Effect.gen(function*() { const clientGroupEffect = HttpApiClient.group(TestApi, "Group1") // $ExpectType never type _clientGroupEffectError = Effect.Effect.Error - // $ExpectType "ApiErrorR" | "Group1ErrorR" | "EndpointAErrorR" | "EndpointASuccessR" | "EndpointBErrorR" | "EndpointBSuccessR" | "EndpointASecurityErrorR" | "EndpointBSecurityErrorR" | "Group1SecurityErrorR" | "ApiSecurityErrorR" | HttpClient + // $ExpectType "ApiErrorR" | "Group1ErrorR" | "EndpointAErrorR" | "EndpointASuccessR" | "EndpointBErrorR" | "EndpointBSuccessR" | "EndpointASecurityErrorR" | "EndpointBSecurityErrorR" | "Group1SecurityErrorR" | "ApiSecurityErrorR" | HttpClient type _clientGroupEffectContext = Effect.Effect.Context const clientGroup = yield* clientGroupEffect @@ -117,7 +117,7 @@ Effect.gen(function*() { const clientApiEffect = HttpApiClient.make(TestApi) // $ExpectType never type _clientApiEffectError = Effect.Effect.Error - // $ExpectType "ApiErrorR" | "Group1ErrorR" | "EndpointAErrorR" | "EndpointASuccessR" | "EndpointBErrorR" | "EndpointBSuccessR" | "EndpointASecurityErrorR" | "EndpointBSecurityErrorR" | "Group1SecurityErrorR" | "ApiSecurityErrorR" | "Group2ErrorR" | "EndpointCErrorR" | "EndpointCSuccessR" | HttpClient + // $ExpectType "ApiErrorR" | "Group1ErrorR" | "EndpointAErrorR" | "EndpointASuccessR" | "EndpointBErrorR" | "EndpointBSuccessR" | "EndpointASecurityErrorR" | "EndpointBSecurityErrorR" | "Group1SecurityErrorR" | "ApiSecurityErrorR" | "Group2ErrorR" | "EndpointCErrorR" | "EndpointCSuccessR" | HttpClient type _clientApiEffectContext = Effect.Effect.Context const clientApi = yield* clientApiEffect diff --git a/packages/platform/src/HttpClient.ts b/packages/platform/src/HttpClient.ts index c60b4a3f383..7b6f68b0eda 100644 --- a/packages/platform/src/HttpClient.ts +++ b/packages/platform/src/HttpClient.ts @@ -35,44 +35,52 @@ export type TypeId = typeof TypeId * @since 1.0.0 * @category models */ -export interface HttpClient extends Pipeable, Inspectable { - readonly [TypeId]: TypeId - readonly execute: (request: ClientRequest.HttpClientRequest) => Effect.Effect - - readonly get: ( - url: string | URL, - options?: ClientRequest.Options.NoBody - ) => Effect.Effect - readonly head: ( - url: string | URL, - options?: ClientRequest.Options.NoBody - ) => Effect.Effect - readonly post: ( - url: string | URL, - options?: ClientRequest.Options.NoUrl - ) => Effect.Effect - readonly patch: ( - url: string | URL, - options?: ClientRequest.Options.NoUrl - ) => Effect.Effect - readonly put: ( - url: string | URL, - options?: ClientRequest.Options.NoUrl - ) => Effect.Effect - readonly del: ( - url: string | URL, - options?: ClientRequest.Options.NoUrl - ) => Effect.Effect - readonly options: ( - url: string | URL, - options?: ClientRequest.Options.NoUrl - ) => Effect.Effect -} +export interface HttpClient extends HttpClient.With {} /** * @since 1.0.0 */ export declare namespace HttpClient { + /** + * @since 1.0.0 + * @category models + */ + export interface With extends Pipeable, Inspectable { + readonly [TypeId]: TypeId + readonly execute: ( + request: ClientRequest.HttpClientRequest + ) => Effect.Effect + + readonly get: ( + url: string | URL, + options?: ClientRequest.Options.NoBody + ) => Effect.Effect + readonly head: ( + url: string | URL, + options?: ClientRequest.Options.NoBody + ) => Effect.Effect + readonly post: ( + url: string | URL, + options?: ClientRequest.Options.NoUrl + ) => Effect.Effect + readonly patch: ( + url: string | URL, + options?: ClientRequest.Options.NoUrl + ) => Effect.Effect + readonly put: ( + url: string | URL, + options?: ClientRequest.Options.NoUrl + ) => Effect.Effect + readonly del: ( + url: string | URL, + options?: ClientRequest.Options.NoUrl + ) => Effect.Effect + readonly options: ( + url: string | URL, + options?: ClientRequest.Options.NoUrl + ) => Effect.Effect + } + /** * @since 1.0.0 * @category models @@ -203,11 +211,11 @@ export const options: ( export const catchAll: { ( f: (e: E) => Effect.Effect - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: (e: E) => Effect.Effect - ): HttpClient + ): HttpClient.With } = internal.catchAll /** @@ -218,12 +226,12 @@ export const catchTag: { ( tag: K, f: (e: Extract) => Effect.Effect - ): (self: HttpClient) => HttpClient, R1 | R> + ): (self: HttpClient.With) => HttpClient.With, R1 | R> ( - self: HttpClient, + self: HttpClient.With, tag: K, f: (e: Extract) => Effect.Effect - ): HttpClient, R1 | R> + ): HttpClient.With, R1 | R> } = internal.catchTag /** @@ -243,8 +251,8 @@ export const catchTags: { >( cases: Cases ): ( - self: HttpClient - ) => HttpClient< + self: HttpClient.With + ) => HttpClient.With< | Exclude | { [K in keyof Cases]: Cases[K] extends (...args: Array) => Effect.Effect ? E : never @@ -265,9 +273,9 @@ export const catchTags: { } & (unknown extends E ? {} : { [K in Exclude["_tag"]>]: never }) >( - self: HttpClient, + self: HttpClient.With, cases: Cases - ): HttpClient< + ): HttpClient.With< | Exclude | { [K in keyof Cases]: Cases[K] extends (...args: Array) => Effect.Effect ? E : never @@ -289,12 +297,12 @@ export const filterOrElse: { ( predicate: Predicate.Predicate, orElse: (response: ClientResponse.HttpClientResponse) => Effect.Effect - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, predicate: Predicate.Predicate, orElse: (response: ClientResponse.HttpClientResponse) => Effect.Effect - ): HttpClient + ): HttpClient.With } = internal.filterOrElse /** @@ -307,12 +315,12 @@ export const filterOrFail: { ( predicate: Predicate.Predicate, orFailWith: (response: ClientResponse.HttpClientResponse) => E2 - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, predicate: Predicate.Predicate, orFailWith: (response: ClientResponse.HttpClientResponse) => E2 - ): HttpClient + ): HttpClient.With } = internal.filterOrFail /** @@ -322,8 +330,8 @@ export const filterOrFail: { * @category filters */ export const filterStatus: { - (f: (status: number) => boolean): (self: HttpClient) => HttpClient - (self: HttpClient, f: (status: number) => boolean): HttpClient + (f: (status: number) => boolean): (self: HttpClient.With) => HttpClient.With + (self: HttpClient.With, f: (status: number) => boolean): HttpClient.With } = internal.filterStatus /** @@ -332,7 +340,7 @@ export const filterStatus: { * @since 1.0.0 * @category filters */ -export const filterStatusOk: (self: HttpClient) => HttpClient = +export const filterStatusOk: (self: HttpClient.With) => HttpClient.With = internal.filterStatusOk /** @@ -344,7 +352,7 @@ export const makeWith: ( request: Effect.Effect ) => Effect.Effect, preprocess: HttpClient.Preprocess -) => HttpClient = internal.makeWith +) => HttpClient.With = internal.makeWith /** * @since 1.0.0 @@ -369,14 +377,14 @@ export const transform: { effect: Effect.Effect, request: ClientRequest.HttpClientRequest ) => Effect.Effect - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: ( effect: Effect.Effect, request: ClientRequest.HttpClientRequest ) => Effect.Effect - ): HttpClient + ): HttpClient.With } = internal.transform /** @@ -388,13 +396,13 @@ export const transformResponse: { f: ( effect: Effect.Effect ) => Effect.Effect - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: ( effect: Effect.Effect ) => Effect.Effect - ): HttpClient + ): HttpClient.With } = internal.transformResponse /** @@ -406,11 +414,11 @@ export const transformResponse: { export const mapRequest: { ( f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ): HttpClient + ): HttpClient.With } = internal.mapRequest /** @@ -422,11 +430,11 @@ export const mapRequest: { export const mapRequestEffect: { ( f: (a: ClientRequest.HttpClientRequest) => Effect.Effect - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => Effect.Effect - ): HttpClient + ): HttpClient.With } = internal.mapRequestEffect /** @@ -438,11 +446,11 @@ export const mapRequestEffect: { export const mapRequestInput: { ( f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ): HttpClient + ): HttpClient.With } = internal.mapRequestInput /** @@ -454,11 +462,11 @@ export const mapRequestInput: { export const mapRequestInputEffect: { ( f: (a: ClientRequest.HttpClientRequest) => Effect.Effect - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => Effect.Effect - ): HttpClient + ): HttpClient.With } = internal.mapRequestInputEffect /** @@ -470,7 +478,7 @@ export declare namespace Retry { * @since 1.0.0 * @category error handling */ - export type Return> = HttpClient< + export type Return> = HttpClient.With< | (O extends { schedule: Schedule.Schedule } ? E : O extends { until: Predicate.Refinement } ? E2 : E) @@ -490,10 +498,12 @@ export declare namespace Retry { * @category error handling */ export const retry: { - >(options: O): (self: HttpClient) => Retry.Return - (policy: Schedule.Schedule, R1>): (self: HttpClient) => HttpClient - >(self: HttpClient, options: O): Retry.Return - (self: HttpClient, policy: Schedule.Schedule): HttpClient + >(options: O): (self: HttpClient.With) => Retry.Return + ( + policy: Schedule.Schedule, R1> + ): (self: HttpClient.With) => HttpClient.With + >(self: HttpClient.With, options: O): Retry.Return + (self: HttpClient.With, policy: Schedule.Schedule): HttpClient.With } = internal.retry /** @@ -512,15 +522,15 @@ export const retryTransient: { readonly schedule?: Schedule.Schedule, R1> readonly times?: number } | Schedule.Schedule, R1> - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, options: { readonly while?: Predicate.Predicate> readonly schedule?: Schedule.Schedule, R1> readonly times?: number } | Schedule.Schedule, R1> - ): HttpClient + ): HttpClient.With } = internal.retryTransient /** @@ -532,11 +542,11 @@ export const retryTransient: { export const tap: { <_, E2, R2>( f: (response: ClientResponse.HttpClientResponse) => Effect.Effect<_, E2, R2> - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: (response: ClientResponse.HttpClientResponse) => Effect.Effect<_, E2, R2> - ): HttpClient + ): HttpClient.With } = internal.tap /** @@ -548,11 +558,11 @@ export const tap: { export const tapRequest: { <_, E2, R2>( f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<_, E2, R2> - ): (self: HttpClient) => HttpClient + ): (self: HttpClient.With) => HttpClient.With ( - self: HttpClient, + self: HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<_, E2, R2> - ): HttpClient + ): HttpClient.With } = internal.tapRequest /** @@ -562,8 +572,8 @@ export const tapRequest: { * @category cookies */ export const withCookiesRef: { - (ref: Ref): (self: HttpClient) => HttpClient - (self: HttpClient, ref: Ref): HttpClient + (ref: Ref): (self: HttpClient.With) => HttpClient.With + (self: HttpClient.With, ref: Ref): HttpClient.With } = internal.withCookiesRef /** @@ -573,8 +583,8 @@ export const withCookiesRef: { * @category redirects */ export const followRedirects: { - (maxRedirects?: number | undefined): (self: HttpClient) => HttpClient - (self: HttpClient, maxRedirects?: number | undefined): HttpClient + (maxRedirects?: number | undefined): (self: HttpClient.With) => HttpClient.With + (self: HttpClient.With, maxRedirects?: number | undefined): HttpClient.With } = internal.followRedirects /** diff --git a/packages/platform/src/internal/httpClient.ts b/packages/platform/src/internal/httpClient.ts index 1c684b7b5e7..0a62df595bb 100644 --- a/packages/platform/src/internal/httpClient.ts +++ b/packages/platform/src/internal/httpClient.ts @@ -100,9 +100,9 @@ const ClientProto = { } } -const isClient = (u: unknown): u is Client.HttpClient => Predicate.hasProperty(u, TypeId) +const isClient = (u: unknown): u is Client.HttpClient.With => Predicate.hasProperty(u, TypeId) -interface HttpClientImpl extends Client.HttpClient { +interface HttpClientImpl extends Client.HttpClient.With { readonly preprocess: Client.HttpClient.Preprocess readonly postprocess: Client.HttpClient.Postprocess } @@ -113,7 +113,7 @@ export const makeWith = ( request: Effect.Effect ) => Effect.Effect, preprocess: Client.HttpClient.Preprocess -): Client.HttpClient => { +): Client.HttpClient.With => { const self = Object.create(ClientProto) self.preprocess = preprocess self.postprocess = postprocess @@ -226,14 +226,14 @@ export const transform = dual< effect: Effect.Effect, request: ClientRequest.HttpClientRequest ) => Effect.Effect - ) => (self: Client.HttpClient) => Client.HttpClient, + ) => (self: Client.HttpClient.With) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: ( effect: Effect.Effect, request: ClientRequest.HttpClientRequest ) => Effect.Effect - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => { const client = self as HttpClientImpl return makeWith( @@ -247,18 +247,18 @@ export const filterStatus = dual< ( f: (status: number) => boolean ) => ( - self: Client.HttpClient - ) => Client.HttpClient, + self: Client.HttpClient.With + ) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: (status: number) => boolean - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => transformResponse(self, Effect.flatMap(internalResponse.filterStatus(f)))) /** @internal */ export const filterStatusOk = ( - self: Client.HttpClient -): Client.HttpClient => + self: Client.HttpClient.With +): Client.HttpClient.With => transformResponse(self, Effect.flatMap(internalResponse.filterStatusOk)) /** @internal */ @@ -267,13 +267,13 @@ export const transformResponse = dual< f: ( effect: Effect.Effect ) => Effect.Effect - ) => (self: Client.HttpClient) => Client.HttpClient, + ) => (self: Client.HttpClient.With) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: ( effect: Effect.Effect ) => Effect.Effect - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => { const client = self as HttpClientImpl return makeWith((request) => f(client.postprocess(request)), client.preprocess) @@ -284,7 +284,7 @@ export const catchTag: { ( tag: K, f: (e: Extract) => Effect.Effect - ): (self: Client.HttpClient) => Client.HttpClient, R1 | R> + ): (self: Client.HttpClient.With) => Client.HttpClient.With, R1 | R> < R, E, @@ -292,10 +292,10 @@ export const catchTag: { R1, E1 >( - self: Client.HttpClient, + self: Client.HttpClient.With, tag: K, f: (e: Extract) => Effect.Effect - ): Client.HttpClient, R1 | R> + ): Client.HttpClient.With, R1 | R> } = dual( 3, < @@ -305,10 +305,10 @@ export const catchTag: { R1, E1 >( - self: Client.HttpClient, + self: Client.HttpClient.With, tag: K, f: (e: Extract) => Effect.Effect - ): Client.HttpClient, R1 | R> => transformResponse(self, Effect.catchTag(tag, f)) + ): Client.HttpClient.With, R1 | R> => transformResponse(self, Effect.catchTag(tag, f)) ) /** @internal */ @@ -332,7 +332,7 @@ export const catchTags: { }) >( cases: Cases - ): (self: Client.HttpClient) => Client.HttpClient< + ): (self: Client.HttpClient.With) => Client.HttpClient.With< | Exclude | { [K in keyof Cases]: Cases[K] extends ( @@ -367,9 +367,9 @@ export const catchTags: { ]: never }) >( - self: Client.HttpClient, + self: Client.HttpClient.With, cases: Cases - ): Client.HttpClient< + ): Client.HttpClient.With< | Exclude | { [K in keyof Cases]: Cases[K] extends ( @@ -406,9 +406,9 @@ export const catchTags: { ]: never }) >( - self: Client.HttpClient, + self: Client.HttpClient.With, cases: Cases - ): Client.HttpClient< + ): Client.HttpClient.With< | Exclude | { [K in keyof Cases]: Cases[K] extends ( @@ -430,17 +430,17 @@ export const catchTags: { export const catchAll: { ( f: (e: E) => Effect.Effect - ): (self: Client.HttpClient) => Client.HttpClient + ): (self: Client.HttpClient.With) => Client.HttpClient.With ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: (e: E) => Effect.Effect - ): Client.HttpClient + ): Client.HttpClient.With } = dual( 2, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: (e: E) => Effect.Effect - ): Client.HttpClient => transformResponse(self, Effect.catchAll(f)) + ): Client.HttpClient.With => transformResponse(self, Effect.catchAll(f)) ) /** @internal */ @@ -449,13 +449,13 @@ export const filterOrElse: { predicate: Predicate.Predicate, orElse: (response: ClientResponse.HttpClientResponse) => Effect.Effect ): ( - self: Client.HttpClient - ) => Client.HttpClient + self: Client.HttpClient.With + ) => Client.HttpClient.With ( - self: Client.HttpClient, + self: Client.HttpClient.With, predicate: Predicate.Predicate, orElse: (response: ClientResponse.HttpClientResponse) => Effect.Effect - ): Client.HttpClient + ): Client.HttpClient.With } = dual(3, (self, f, orElse) => transformResponse(self, Effect.filterOrElse(f, orElse))) /** @internal */ @@ -463,23 +463,23 @@ export const filterOrFail: { ( predicate: Predicate.Predicate, orFailWith: (response: ClientResponse.HttpClientResponse) => E2 - ): (self: Client.HttpClient) => Client.HttpClient + ): (self: Client.HttpClient.With) => Client.HttpClient.With ( - self: Client.HttpClient, + self: Client.HttpClient.With, predicate: Predicate.Predicate, orFailWith: (response: ClientResponse.HttpClientResponse) => E2 - ): Client.HttpClient + ): Client.HttpClient.With } = dual(3, (self, f, orFailWith) => transformResponse(self, Effect.filterOrFail(f, orFailWith))) /** @internal */ export const mapRequest = dual< ( f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ) => (self: Client.HttpClient) => Client.HttpClient, + ) => (self: Client.HttpClient.With) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => { const client = self as HttpClientImpl return makeWith(client.postprocess, (request) => Effect.map(client.preprocess(request), f)) @@ -492,14 +492,14 @@ export const mapRequestEffect = dual< a: ClientRequest.HttpClientRequest ) => Effect.Effect ) => ( - self: Client.HttpClient - ) => Client.HttpClient, + self: Client.HttpClient.With + ) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: ( a: ClientRequest.HttpClientRequest ) => Effect.Effect - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => { const client = self as HttpClientImpl return makeWith(client.postprocess as any, (request) => Effect.flatMap(client.preprocess(request), f)) @@ -509,11 +509,11 @@ export const mapRequestEffect = dual< export const mapRequestInput = dual< ( f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ) => (self: Client.HttpClient) => Client.HttpClient, + ) => (self: Client.HttpClient.With) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => { const client = self as HttpClientImpl return makeWith(client.postprocess, (request) => client.preprocess(f(request))) @@ -526,14 +526,14 @@ export const mapRequestInputEffect = dual< a: ClientRequest.HttpClientRequest ) => Effect.Effect ) => ( - self: Client.HttpClient - ) => Client.HttpClient, + self: Client.HttpClient.With + ) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: ( a: ClientRequest.HttpClientRequest ) => Effect.Effect - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => { const client = self as HttpClientImpl return makeWith(client.postprocess as any, (request) => Effect.flatMap(f(request), client.preprocess)) @@ -543,24 +543,24 @@ export const mapRequestInputEffect = dual< export const retry: { >( options: O - ): (self: Client.HttpClient) => Client.Retry.Return + ): (self: Client.HttpClient.With) => Client.Retry.Return ( policy: Schedule.Schedule, R1> - ): (self: Client.HttpClient) => Client.HttpClient + ): (self: Client.HttpClient.With) => Client.HttpClient.With >( - self: Client.HttpClient, + self: Client.HttpClient.With, options: O ): Client.Retry.Return ( - self: Client.HttpClient, + self: Client.HttpClient.With, policy: Schedule.Schedule - ): Client.HttpClient + ): Client.HttpClient.With } = dual( 2, ( - self: Client.HttpClient, + self: Client.HttpClient.With, policy: Schedule.Schedule - ): Client.HttpClient => transformResponse(self, Effect.retry(policy)) + ): Client.HttpClient.With => transformResponse(self, Effect.retry(policy)) ) /** @internal */ @@ -571,25 +571,25 @@ export const retryTransient: { readonly schedule?: Schedule.Schedule, R1> readonly times?: number } | Schedule.Schedule, R1> - ): (self: Client.HttpClient) => Client.HttpClient + ): (self: Client.HttpClient.With) => Client.HttpClient.With ( - self: Client.HttpClient, + self: Client.HttpClient.With, options: { readonly while?: Predicate.Predicate> readonly schedule?: Schedule.Schedule, R1> readonly times?: number } | Schedule.Schedule, R1> - ): Client.HttpClient + ): Client.HttpClient.With } = dual( 2, ( - self: Client.HttpClient, + self: Client.HttpClient.With, options: { readonly while?: Predicate.Predicate> readonly schedule?: Schedule.Schedule, R1> readonly times?: number } | Schedule.Schedule, R1> - ): Client.HttpClient => + ): Client.HttpClient.With => transformResponse( self, Effect.retry({ @@ -614,11 +614,11 @@ const isTransientHttpError = (error: unknown) => export const tap = dual< <_, E2, R2>( f: (response: ClientResponse.HttpClientResponse) => Effect.Effect<_, E2, R2> - ) => (self: Client.HttpClient) => Client.HttpClient, + ) => (self: Client.HttpClient.With) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: (response: ClientResponse.HttpClientResponse) => Effect.Effect<_, E2, R2> - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => transformResponse(self, Effect.tap(f))) /** @internal */ @@ -626,12 +626,12 @@ export const tapRequest = dual< <_, E2, R2>( f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<_, E2, R2> ) => ( - self: Client.HttpClient - ) => Client.HttpClient, + self: Client.HttpClient.With + ) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<_, E2, R2> - ) => Client.HttpClient + ) => Client.HttpClient.With >(2, (self, f) => { const client = self as HttpClientImpl return makeWith(client.postprocess as any, (request) => Effect.tap(client.preprocess(request), f)) @@ -641,17 +641,17 @@ export const tapRequest = dual< export const withCookiesRef = dual< ( ref: Ref.Ref - ) => (self: Client.HttpClient) => Client.HttpClient, + ) => (self: Client.HttpClient.With) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, ref: Ref.Ref - ) => Client.HttpClient + ) => Client.HttpClient.With >( 2, ( - self: Client.HttpClient, + self: Client.HttpClient.With, ref: Ref.Ref - ): Client.HttpClient => { + ): Client.HttpClient.With => { const client = self as HttpClientImpl return makeWith( (request: Effect.Effect) => @@ -676,15 +676,15 @@ export const withCookiesRef = dual< export const followRedirects = dual< ( maxRedirects?: number | undefined - ) => (self: Client.HttpClient) => Client.HttpClient, + ) => (self: Client.HttpClient.With) => Client.HttpClient.With, ( - self: Client.HttpClient, + self: Client.HttpClient.With, maxRedirects?: number | undefined - ) => Client.HttpClient + ) => Client.HttpClient.With >((args) => isClient(args[0]), ( - self: Client.HttpClient, + self: Client.HttpClient.With, maxRedirects?: number | undefined -): Client.HttpClient => { +): Client.HttpClient.With => { const client = self as HttpClientImpl return makeWith( (request) => {