@effect/platform 0.67.0 → 0.68.0

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.
Files changed (63) hide show
  1. package/README.md +66 -52
  2. package/dist/cjs/FetchHttpClient.js.map +1 -1
  3. package/dist/cjs/HttpClient.js +43 -31
  4. package/dist/cjs/HttpClient.js.map +1 -1
  5. package/dist/cjs/HttpClientRequest.js.map +1 -1
  6. package/dist/cjs/internal/fetchHttpClient.js +1 -1
  7. package/dist/cjs/internal/fetchHttpClient.js.map +1 -1
  8. package/dist/cjs/internal/httpBody.js +0 -3
  9. package/dist/cjs/internal/httpBody.js.map +1 -1
  10. package/dist/cjs/internal/httpClient.js +41 -38
  11. package/dist/cjs/internal/httpClient.js.map +1 -1
  12. package/dist/cjs/internal/httpClientRequest.js +5 -9
  13. package/dist/cjs/internal/httpClientRequest.js.map +1 -1
  14. package/dist/cjs/internal/httpMultiplex.js +0 -3
  15. package/dist/cjs/internal/httpMultiplex.js.map +1 -1
  16. package/dist/cjs/internal/httpRouter.js +0 -3
  17. package/dist/cjs/internal/httpRouter.js.map +1 -1
  18. package/dist/cjs/internal/httpServerResponse.js +0 -3
  19. package/dist/cjs/internal/httpServerResponse.js.map +1 -1
  20. package/dist/dts/FetchHttpClient.d.ts +1 -1
  21. package/dist/dts/FetchHttpClient.d.ts.map +1 -1
  22. package/dist/dts/HttpApiClient.d.ts +2 -2
  23. package/dist/dts/HttpApiClient.d.ts.map +1 -1
  24. package/dist/dts/HttpClient.d.ts +118 -186
  25. package/dist/dts/HttpClient.d.ts.map +1 -1
  26. package/dist/dts/HttpClientRequest.d.ts +2 -5
  27. package/dist/dts/HttpClientRequest.d.ts.map +1 -1
  28. package/dist/dts/HttpServer.d.ts +1 -1
  29. package/dist/dts/HttpServer.d.ts.map +1 -1
  30. package/dist/dts/internal/httpClient.d.ts +23 -1
  31. package/dist/dts/internal/httpClient.d.ts.map +1 -1
  32. package/dist/dts/internal/httpRouter.d.ts.map +1 -1
  33. package/dist/esm/FetchHttpClient.js.map +1 -1
  34. package/dist/esm/HttpClient.js +42 -30
  35. package/dist/esm/HttpClient.js.map +1 -1
  36. package/dist/esm/HttpClientRequest.js.map +1 -1
  37. package/dist/esm/internal/fetchHttpClient.js +1 -1
  38. package/dist/esm/internal/fetchHttpClient.js.map +1 -1
  39. package/dist/esm/internal/httpBody.js +0 -3
  40. package/dist/esm/internal/httpBody.js.map +1 -1
  41. package/dist/esm/internal/httpClient.js +29 -33
  42. package/dist/esm/internal/httpClient.js.map +1 -1
  43. package/dist/esm/internal/httpClientRequest.js +4 -8
  44. package/dist/esm/internal/httpClientRequest.js.map +1 -1
  45. package/dist/esm/internal/httpMultiplex.js +0 -3
  46. package/dist/esm/internal/httpMultiplex.js.map +1 -1
  47. package/dist/esm/internal/httpRouter.js +0 -3
  48. package/dist/esm/internal/httpRouter.js.map +1 -1
  49. package/dist/esm/internal/httpServerResponse.js +0 -3
  50. package/dist/esm/internal/httpServerResponse.js.map +1 -1
  51. package/package.json +3 -3
  52. package/src/FetchHttpClient.ts +1 -1
  53. package/src/HttpApiClient.ts +2 -2
  54. package/src/HttpClient.ts +258 -279
  55. package/src/HttpClientRequest.ts +2 -7
  56. package/src/HttpServer.ts +1 -1
  57. package/src/internal/fetchHttpClient.ts +1 -1
  58. package/src/internal/httpBody.ts +0 -3
  59. package/src/internal/httpClient.ts +191 -303
  60. package/src/internal/httpClientRequest.ts +4 -10
  61. package/src/internal/httpMultiplex.ts +0 -3
  62. package/src/internal/httpRouter.ts +0 -3
  63. package/src/internal/httpServerResponse.ts +0 -3
package/src/HttpClient.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type { ParseOptions } from "@effect/schema/AST"
5
- import type * as ParseResult from "@effect/schema/ParseResult"
6
- import type * as Schema from "@effect/schema/Schema"
7
4
  import type * as Context from "effect/Context"
8
5
  import type * as Effect from "effect/Effect"
9
6
  import type { RuntimeFiber } from "effect/Fiber"
@@ -37,17 +34,38 @@ export type TypeId = typeof TypeId
37
34
  * @since 1.0.0
38
35
  * @category models
39
36
  */
40
- export interface HttpClient<A = ClientResponse.HttpClientResponse, E = never, R = never> extends Pipeable, Inspectable {
37
+ export interface HttpClient<E = Error.HttpClientError, R = Scope.Scope> extends Pipeable, Inspectable {
41
38
  readonly [TypeId]: TypeId
42
- readonly execute: (request: ClientRequest.HttpClientRequest) => Effect.Effect<A, E, R>
43
-
44
- readonly get: (url: string | URL, options?: ClientRequest.Options.NoBody) => Effect.Effect<A, E, R>
45
- readonly head: (url: string | URL, options?: ClientRequest.Options.NoBody) => Effect.Effect<A, E, R>
46
- readonly post: (url: string | URL, options?: ClientRequest.Options.NoUrl) => Effect.Effect<A, E, R>
47
- readonly patch: (url: string | URL, options?: ClientRequest.Options.NoUrl) => Effect.Effect<A, E, R>
48
- readonly put: (url: string | URL, options?: ClientRequest.Options.NoUrl) => Effect.Effect<A, E, R>
49
- readonly del: (url: string | URL, options?: ClientRequest.Options.NoUrl) => Effect.Effect<A, E, R>
50
- readonly options: (url: string | URL, options?: ClientRequest.Options.NoUrl) => Effect.Effect<A, E, R>
39
+ readonly execute: (request: ClientRequest.HttpClientRequest) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
40
+
41
+ readonly get: (
42
+ url: string | URL,
43
+ options?: ClientRequest.Options.NoBody
44
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
45
+ readonly head: (
46
+ url: string | URL,
47
+ options?: ClientRequest.Options.NoBody
48
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
49
+ readonly post: (
50
+ url: string | URL,
51
+ options?: ClientRequest.Options.NoUrl
52
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
53
+ readonly patch: (
54
+ url: string | URL,
55
+ options?: ClientRequest.Options.NoUrl
56
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
57
+ readonly put: (
58
+ url: string | URL,
59
+ options?: ClientRequest.Options.NoUrl
60
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
61
+ readonly del: (
62
+ url: string | URL,
63
+ options?: ClientRequest.Options.NoUrl
64
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
65
+ readonly options: (
66
+ url: string | URL,
67
+ options?: ClientRequest.Options.NoUrl
68
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
51
69
  }
52
70
 
53
71
  /**
@@ -66,28 +84,116 @@ export declare namespace HttpClient {
66
84
  * @since 1.0.0
67
85
  * @category models
68
86
  */
69
- export type Postprocess<A, E = never, R = never> = (
87
+ export type Postprocess<E = never, R = never> = (
70
88
  request: Effect.Effect<ClientRequest.HttpClientRequest, E, R>
71
- ) => Effect.Effect<A, E, R>
72
-
73
- /**
74
- * @since 1.0.0
75
- * @category models
76
- */
77
- export type WithResponse<E = never, R = never> = HttpClient<ClientResponse.HttpClientResponse, E, R>
78
-
79
- /**
80
- * @since 1.0.0
81
- * @category models
82
- */
83
- export type Service = WithResponse<Error.HttpClientError, Scope.Scope>
89
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>
84
90
  }
85
91
 
86
92
  /**
87
93
  * @since 1.0.0
88
94
  * @category tags
89
95
  */
90
- export const HttpClient: Context.Tag<HttpClient.Service, HttpClient.Service> = internal.tag
96
+ export const HttpClient: Context.Tag<HttpClient, HttpClient> = internal.tag
97
+
98
+ /**
99
+ * @since 1.0.0
100
+ * @category accessors
101
+ */
102
+ export const execute: (
103
+ request: ClientRequest.HttpClientRequest
104
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError, Scope.Scope | HttpClient> =
105
+ internal.execute
106
+
107
+ /**
108
+ * @since 1.0.0
109
+ * @category accessors
110
+ */
111
+ export const get: (
112
+ url: string | URL,
113
+ options?: ClientRequest.Options.NoBody | undefined
114
+ ) => Effect.Effect<
115
+ ClientResponse.HttpClientResponse,
116
+ Error.HttpClientError,
117
+ Scope.Scope | HttpClient
118
+ > = internal.get
119
+
120
+ /**
121
+ * @since 1.0.0
122
+ * @category accessors
123
+ */
124
+ export const head: (
125
+ url: string | URL,
126
+ options?: ClientRequest.Options.NoBody | undefined
127
+ ) => Effect.Effect<
128
+ ClientResponse.HttpClientResponse,
129
+ Error.HttpClientError,
130
+ Scope.Scope | HttpClient
131
+ > = internal.head
132
+
133
+ /**
134
+ * @since 1.0.0
135
+ * @category accessors
136
+ */
137
+ export const post: (
138
+ url: string | URL,
139
+ options?: ClientRequest.Options.NoUrl | undefined
140
+ ) => Effect.Effect<
141
+ ClientResponse.HttpClientResponse,
142
+ Error.HttpClientError,
143
+ Scope.Scope | HttpClient
144
+ > = internal.post
145
+
146
+ /**
147
+ * @since 1.0.0
148
+ * @category accessors
149
+ */
150
+ export const patch: (
151
+ url: string | URL,
152
+ options?: ClientRequest.Options.NoUrl | undefined
153
+ ) => Effect.Effect<
154
+ ClientResponse.HttpClientResponse,
155
+ Error.HttpClientError,
156
+ Scope.Scope | HttpClient
157
+ > = internal.patch
158
+
159
+ /**
160
+ * @since 1.0.0
161
+ * @category accessors
162
+ */
163
+ export const put: (
164
+ url: string | URL,
165
+ options?: ClientRequest.Options.NoUrl | undefined
166
+ ) => Effect.Effect<
167
+ ClientResponse.HttpClientResponse,
168
+ Error.HttpClientError,
169
+ Scope.Scope | HttpClient
170
+ > = internal.put
171
+
172
+ /**
173
+ * @since 1.0.0
174
+ * @category accessors
175
+ */
176
+ export const del: (
177
+ url: string | URL,
178
+ options?: ClientRequest.Options.NoUrl | undefined
179
+ ) => Effect.Effect<
180
+ ClientResponse.HttpClientResponse,
181
+ Error.HttpClientError,
182
+ Scope.Scope | HttpClient
183
+ > = internal.del
184
+
185
+ /**
186
+ * @since 1.0.0
187
+ * @category accessors
188
+ */
189
+ export const options: (
190
+ url: string | URL,
191
+ options?: ClientRequest.Options.NoUrl | undefined
192
+ ) => Effect.Effect<
193
+ ClientResponse.HttpClientResponse,
194
+ Error.HttpClientError,
195
+ Scope.Scope | HttpClient
196
+ > = internal.options
91
197
 
92
198
  /**
93
199
  * @since 1.0.0
@@ -98,17 +204,14 @@ export const catchAll: {
98
204
  * @since 1.0.0
99
205
  * @category error handling
100
206
  */
101
- <E, E2, R2, A2>(
102
- f: (e: E) => Effect.Effect<A2, E2, R2>
103
- ): <A, R>(self: HttpClient<A, E, R>) => HttpClient<A2 | A, E2, R2 | R>
207
+ <E, E2, R2>(
208
+ f: (e: E) => Effect.Effect<ClientResponse.HttpClientResponse, E2, R2>
209
+ ): <R>(self: HttpClient<E, R>) => HttpClient<E2, R2 | R>
104
210
  /**
105
211
  * @since 1.0.0
106
212
  * @category error handling
107
213
  */
108
- <A, E, R, A2, E2, R2>(
109
- self: HttpClient<A, E, R>,
110
- f: (e: E) => Effect.Effect<A2, E2, R2>
111
- ): HttpClient<A | A2, E2, R | R2>
214
+ <E, R, A2, E2, R2>(self: HttpClient<E, R>, f: (e: E) => Effect.Effect<A2, E2, R2>): HttpClient<E2, R | R2>
112
215
  } = internal.catchAll
113
216
 
114
217
  /**
@@ -120,19 +223,19 @@ export const catchTag: {
120
223
  * @since 1.0.0
121
224
  * @category error handling
122
225
  */
123
- <E extends { _tag: string }, K extends E["_tag"] & string, A1, E1, R1>(
226
+ <K extends E extends { _tag: string } ? E["_tag"] : never, E, E1, R1>(
124
227
  tag: K,
125
- f: (e: Extract<E, { _tag: K }>) => Effect.Effect<A1, E1, R1>
126
- ): <A, R>(self: HttpClient<A, E, R>) => HttpClient<A1 | A, E1 | Exclude<E, { _tag: K }>, R1 | R>
228
+ f: (e: Extract<E, { _tag: K }>) => Effect.Effect<ClientResponse.HttpClientResponse, E1, R1>
229
+ ): <R>(self: HttpClient<E, R>) => HttpClient<E1 | Exclude<E, { _tag: K }>, R1 | R>
127
230
  /**
128
231
  * @since 1.0.0
129
232
  * @category error handling
130
233
  */
131
- <A, E extends { _tag: string }, R, K extends E["_tag"] & string, A1, E1, R1>(
132
- self: HttpClient<A, E, R>,
234
+ <R, E, K extends E extends { _tag: string } ? E["_tag"] : never, R1, E1>(
235
+ self: HttpClient<E, R>,
133
236
  tag: K,
134
- f: (e: Extract<E, { _tag: K }>) => Effect.Effect<A1, E1, R1>
135
- ): HttpClient<A | A1, E1 | Exclude<E, { _tag: K }>, R | R1>
237
+ f: (e: Extract<E, { _tag: K }>) => Effect.Effect<ClientResponse.HttpClientResponse, E1, R1>
238
+ ): HttpClient<E1 | Exclude<E, { _tag: K }>, R1 | R>
136
239
  } = internal.catchTag
137
240
 
138
241
  /**
@@ -145,15 +248,17 @@ export const catchTags: {
145
248
  * @category error handling
146
249
  */
147
250
  <
148
- E extends { _tag: string },
149
- Cases extends { [K in E["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => Effect.Effect<any, any, any>) | undefined }
150
- >(cases: Cases): <A, R>(
151
- self: HttpClient<A, E, R>
251
+ E,
252
+ Cases extends
253
+ & {
254
+ [K in Extract<E, { _tag: string }>["_tag"]]+?: (
255
+ error: Extract<E, { _tag: K }>
256
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, any, any>
257
+ }
258
+ & (unknown extends E ? {} : { [K in Exclude<keyof Cases, Extract<E, { _tag: string }>["_tag"]>]: never })
259
+ >(cases: Cases): <R>(
260
+ self: HttpClient<E, R>
152
261
  ) => HttpClient<
153
- | A
154
- | {
155
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never
156
- }[keyof Cases],
157
262
  | Exclude<E, { _tag: keyof Cases }>
158
263
  | {
159
264
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, infer E, any> ? E : never
@@ -168,15 +273,16 @@ export const catchTags: {
168
273
  * @category error handling
169
274
  */
170
275
  <
171
- A,
172
276
  E extends { _tag: string },
173
277
  R,
174
- Cases extends { [K in E["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => Effect.Effect<any, any, any>) | undefined }
175
- >(self: HttpClient<A, E, R>, cases: Cases): HttpClient<
176
- | A
177
- | {
178
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never
179
- }[keyof Cases],
278
+ Cases extends
279
+ & {
280
+ [K in Extract<E, { _tag: string }>["_tag"]]+?: (
281
+ error: Extract<E, { _tag: K }>
282
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, any, any>
283
+ }
284
+ & (unknown extends E ? {} : { [K in Exclude<keyof Cases, Extract<E, { _tag: string }>["_tag"]>]: never })
285
+ >(self: HttpClient<E, R>, cases: Cases): HttpClient<
180
286
  | Exclude<E, { _tag: keyof Cases }>
181
287
  | {
182
288
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, infer E, any> ? E : never
@@ -201,44 +307,21 @@ export const filterOrElse: {
201
307
  * @since 1.0.0
202
308
  * @category filters
203
309
  */
204
- <A, B extends A, C, E2, R2>(
205
- refinement: Predicate.Refinement<NoInfer<A>, B>,
206
- orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
207
- ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<B | C, E | E2, R | R2>
208
- /**
209
- * Filters the result of a response, or runs an alternative effect if the predicate fails.
210
- *
211
- * @since 1.0.0
212
- * @category filters
213
- */
214
- <A, B, E2, R2>(
215
- predicate: Predicate.Predicate<NoInfer<A>>,
216
- orElse: (a: NoInfer<A>) => Effect.Effect<B, E2, R2>
217
- ): <E, R>(
218
- self: HttpClient<A, E, R>
219
- ) => HttpClient<A | B, E2 | E, R2 | R>
220
- /**
221
- * Filters the result of a response, or runs an alternative effect if the predicate fails.
222
- *
223
- * @since 1.0.0
224
- * @category filters
225
- */
226
- <A, E, R, B extends A, C, E2, R2>(
227
- self: HttpClient<A, E, R>,
228
- refinement: Predicate.Refinement<A, B>,
229
- orElse: (a: A) => Effect.Effect<C, E2, R2>
230
- ): HttpClient<B | C, E | E2, R | R2>
310
+ <E2, R2>(
311
+ predicate: Predicate.Predicate<ClientResponse.HttpClientResponse>,
312
+ orElse: (response: ClientResponse.HttpClientResponse) => Effect.Effect<ClientResponse.HttpClientResponse, E2, R2>
313
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E2 | E, R2 | R>
231
314
  /**
232
315
  * Filters the result of a response, or runs an alternative effect if the predicate fails.
233
316
  *
234
317
  * @since 1.0.0
235
318
  * @category filters
236
319
  */
237
- <A, E, R, B, E2, R2>(
238
- self: HttpClient<A, E, R>,
239
- predicate: Predicate.Predicate<A>,
240
- orElse: (a: A) => Effect.Effect<B, E2, R2>
241
- ): HttpClient<A | B, E2 | E, R2 | R>
320
+ <E, R, E2, R2>(
321
+ self: HttpClient<E, R>,
322
+ predicate: Predicate.Predicate<ClientResponse.HttpClientResponse>,
323
+ orElse: (response: ClientResponse.HttpClientResponse) => Effect.Effect<ClientResponse.HttpClientResponse, E2, R2>
324
+ ): HttpClient<E2 | E, R2 | R>
242
325
  } = internal.filterOrElse
243
326
 
244
327
  /**
@@ -254,42 +337,21 @@ export const filterOrFail: {
254
337
  * @since 1.0.0
255
338
  * @category filters
256
339
  */
257
- <A, B extends A, E2>(
258
- refinement: Predicate.Refinement<NoInfer<A>, B>,
259
- orFailWith: (a: NoInfer<A>) => E2
260
- ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<B, E | E2, R>
261
- /**
262
- * Filters the result of a response, or throws an error if the predicate fails.
263
- *
264
- * @since 1.0.0
265
- * @category filters
266
- */
267
- <A, E2>(
268
- predicate: Predicate.Predicate<NoInfer<A>>,
269
- orFailWith: (a: NoInfer<A>) => E2
270
- ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E2 | E, R>
340
+ <E2>(
341
+ predicate: Predicate.Predicate<ClientResponse.HttpClientResponse>,
342
+ orFailWith: (response: ClientResponse.HttpClientResponse) => E2
343
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E2 | E, R>
271
344
  /**
272
345
  * Filters the result of a response, or throws an error if the predicate fails.
273
346
  *
274
347
  * @since 1.0.0
275
348
  * @category filters
276
349
  */
277
- <A, B extends A, E, R, E2>(
278
- self: HttpClient<A, E, R>,
279
- refinement: Predicate.Refinement<A, B>,
280
- orFailWith: (a: A) => E2
281
- ): HttpClient<B, E2 | E, R>
282
- /**
283
- * Filters the result of a response, or throws an error if the predicate fails.
284
- *
285
- * @since 1.0.0
286
- * @category filters
287
- */
288
- <A, E, R, E2>(
289
- self: HttpClient<A, E, R>,
290
- predicate: Predicate.Predicate<A>,
291
- orFailWith: (a: A) => E2
292
- ): HttpClient<A, E2 | E, R>
350
+ <E, R, E2>(
351
+ self: HttpClient<E, R>,
352
+ predicate: Predicate.Predicate<ClientResponse.HttpClientResponse>,
353
+ orFailWith: (response: ClientResponse.HttpClientResponse) => E2
354
+ ): HttpClient<E2 | E, R>
293
355
  } = internal.filterOrFail
294
356
 
295
357
  /**
@@ -305,19 +367,14 @@ export const filterStatus: {
305
367
  * @since 1.0.0
306
368
  * @category filters
307
369
  */
308
- (
309
- f: (status: number) => boolean
310
- ): <E, R>(self: HttpClient.WithResponse<E, R>) => HttpClient.WithResponse<E | Error.ResponseError, R>
370
+ (f: (status: number) => boolean): <E, R>(self: HttpClient<E, R>) => HttpClient<E | Error.ResponseError, R>
311
371
  /**
312
372
  * Filters responses by HTTP status code.
313
373
  *
314
374
  * @since 1.0.0
315
375
  * @category filters
316
376
  */
317
- <E, R>(
318
- self: HttpClient.WithResponse<E, R>,
319
- f: (status: number) => boolean
320
- ): HttpClient.WithResponse<Error.ResponseError | E, R>
377
+ <E, R>(self: HttpClient<E, R>, f: (status: number) => boolean): HttpClient<E | Error.ResponseError, R>
321
378
  } = internal.filterStatus
322
379
 
323
380
  /**
@@ -326,31 +383,32 @@ export const filterStatus: {
326
383
  * @since 1.0.0
327
384
  * @category filters
328
385
  */
329
- export const filterStatusOk: <E, R>(
330
- self: HttpClient.WithResponse<E, R>
331
- ) => HttpClient.WithResponse<Error.ResponseError | E, R> = internal.filterStatusOk
386
+ export const filterStatusOk: <E, R>(self: HttpClient<E, R>) => HttpClient<E | Error.ResponseError, R> =
387
+ internal.filterStatusOk
332
388
 
333
389
  /**
334
390
  * @since 1.0.0
335
391
  * @category constructors
336
392
  */
337
- export const make: <A, E, R, E2, R2>(
338
- execute: (request: Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>) => Effect.Effect<A, E, R>,
393
+ export const makeWith: <E2, R2, E, R>(
394
+ postprocess: (
395
+ request: Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>
396
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E, R>,
339
397
  preprocess: HttpClient.Preprocess<E2, R2>
340
- ) => HttpClient<A, E, R> = internal.make
398
+ ) => HttpClient<E, R> = internal.makeWith
341
399
 
342
400
  /**
343
401
  * @since 1.0.0
344
402
  * @category constructors
345
403
  */
346
- export const makeService: (
404
+ export const make: (
347
405
  f: (
348
406
  request: ClientRequest.HttpClientRequest,
349
407
  url: URL,
350
408
  signal: AbortSignal,
351
409
  fiber: RuntimeFiber<ClientResponse.HttpClientResponse, Error.HttpClientError>
352
410
  ) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError, Scope.Scope>
353
- ) => HttpClient.Service = internal.makeService
411
+ ) => HttpClient = internal.make
354
412
 
355
413
  /**
356
414
  * @since 1.0.0
@@ -361,17 +419,23 @@ export const transform: {
361
419
  * @since 1.0.0
362
420
  * @category mapping & sequencing
363
421
  */
364
- <A, E, R, A1, E1, R1>(
365
- f: (effect: Effect.Effect<A, E, R>, request: ClientRequest.HttpClientRequest) => Effect.Effect<A1, E1, R1>
366
- ): (self: HttpClient<A, E, R>) => HttpClient<A1, E | E1, R | R1>
422
+ <E, R, E1, R1>(
423
+ f: (
424
+ effect: Effect.Effect<ClientResponse.HttpClientResponse, E, R>,
425
+ request: ClientRequest.HttpClientRequest
426
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E1, R1>
427
+ ): (self: HttpClient<E, R>) => HttpClient<E | E1, R | R1>
367
428
  /**
368
429
  * @since 1.0.0
369
430
  * @category mapping & sequencing
370
431
  */
371
- <A, E, R, A1, E1, R1>(
372
- self: HttpClient<A, E, R>,
373
- f: (effect: Effect.Effect<A, E, R>, request: ClientRequest.HttpClientRequest) => Effect.Effect<A1, E1, R1>
374
- ): HttpClient<A1, E | E1, R | R1>
432
+ <E, R, E1, R1>(
433
+ self: HttpClient<E, R>,
434
+ f: (
435
+ effect: Effect.Effect<ClientResponse.HttpClientResponse, E, R>,
436
+ request: ClientRequest.HttpClientRequest
437
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E1, R1>
438
+ ): HttpClient<E | E1, R | R1>
375
439
  } = internal.transform
376
440
 
377
441
  /**
@@ -383,67 +447,23 @@ export const transformResponse: {
383
447
  * @since 1.0.0
384
448
  * @category mapping & sequencing
385
449
  */
386
- <A, E, R, A1, E1, R1>(
387
- f: (effect: Effect.Effect<A, E, R>) => Effect.Effect<A1, E1, R1>
388
- ): (self: HttpClient<A, E, R>) => HttpClient<A1, E1, R1>
450
+ <E, R, E1, R1>(
451
+ f: (
452
+ effect: Effect.Effect<ClientResponse.HttpClientResponse, E, R>
453
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E1, R1>
454
+ ): (self: HttpClient<E, R>) => HttpClient<E1, R1>
389
455
  /**
390
456
  * @since 1.0.0
391
457
  * @category mapping & sequencing
392
458
  */
393
- <A, E, R, A1, E1, R1>(
394
- self: HttpClient<A, E, R>,
395
- f: (effect: Effect.Effect<A, E, R>) => Effect.Effect<A1, E1, R1>
396
- ): HttpClient<A1, E1, R1>
459
+ <E, R, E1, R1>(
460
+ self: HttpClient<E, R>,
461
+ f: (
462
+ effect: Effect.Effect<ClientResponse.HttpClientResponse, E, R>
463
+ ) => Effect.Effect<ClientResponse.HttpClientResponse, E1, R1>
464
+ ): HttpClient<E1, R1>
397
465
  } = internal.transformResponse
398
466
 
399
- /**
400
- * Transforms the result of a request.
401
- *
402
- * @since 1.0.0
403
- * @category mapping & sequencing
404
- */
405
- export const map: {
406
- /**
407
- * Transforms the result of a request.
408
- *
409
- * @since 1.0.0
410
- * @category mapping & sequencing
411
- */
412
- <A, B>(f: (a: A) => B): <E, R>(self: HttpClient<A, E, R>) => HttpClient<B, E, R>
413
- /**
414
- * Transforms the result of a request.
415
- *
416
- * @since 1.0.0
417
- * @category mapping & sequencing
418
- */
419
- <A, E, R, B>(self: HttpClient<A, E, R>, f: (a: A) => B): HttpClient<B, E, R>
420
- } = internal.map
421
-
422
- /**
423
- * Transforms the result of a request using an effectful function.
424
- *
425
- * @since 1.0.0
426
- * @category mapping & sequencing
427
- */
428
- export const mapEffect: {
429
- /**
430
- * Transforms the result of a request using an effectful function.
431
- *
432
- * @since 1.0.0
433
- * @category mapping & sequencing
434
- */
435
- <A, B, E2, R2>(
436
- f: (a: A) => Effect.Effect<B, E2, R2>
437
- ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<B, E2 | E, R2 | R>
438
- /**
439
- * Transforms the result of a request using an effectful function.
440
- *
441
- * @since 1.0.0
442
- * @category mapping & sequencing
443
- */
444
- <A, E, R, B, E2, R2>(self: HttpClient<A, E, R>, f: (a: A) => Effect.Effect<B, E2, R2>): HttpClient<B, E | E2, R2 | R>
445
- } = internal.mapEffect
446
-
447
467
  /**
448
468
  * Appends a transformation of the request object before sending it.
449
469
  *
@@ -459,17 +479,17 @@ export const mapRequest: {
459
479
  */
460
480
  (
461
481
  f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest
462
- ): <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E, R>
482
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E, R>
463
483
  /**
464
484
  * Appends a transformation of the request object before sending it.
465
485
  *
466
486
  * @since 1.0.0
467
487
  * @category mapping & sequencing
468
488
  */
469
- <A, E, R>(
470
- self: HttpClient<A, E, R>,
489
+ <E, R>(
490
+ self: HttpClient<E, R>,
471
491
  f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest
472
- ): HttpClient<A, E, R>
492
+ ): HttpClient<E, R>
473
493
  } = internal.mapRequest
474
494
 
475
495
  /**
@@ -487,17 +507,17 @@ export const mapRequestEffect: {
487
507
  */
488
508
  <E2, R2>(
489
509
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>
490
- ): <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E2 | E, R2 | R>
510
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E | E2, R | R2>
491
511
  /**
492
512
  * Appends an effectful transformation of the request object before sending it.
493
513
  *
494
514
  * @since 1.0.0
495
515
  * @category mapping & sequencing
496
516
  */
497
- <A, E, R, E2, R2>(
498
- self: HttpClient<A, E, R>,
517
+ <E, R, E2, R2>(
518
+ self: HttpClient<E, R>,
499
519
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>
500
- ): HttpClient<A, E | E2, R | R2>
520
+ ): HttpClient<E | E2, R | R2>
501
521
  } = internal.mapRequestEffect
502
522
 
503
523
  /**
@@ -515,17 +535,17 @@ export const mapRequestInput: {
515
535
  */
516
536
  (
517
537
  f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest
518
- ): <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E, R>
538
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E, R>
519
539
  /**
520
540
  * Prepends a transformation of the request object before sending it.
521
541
  *
522
542
  * @since 1.0.0
523
543
  * @category mapping & sequencing
524
544
  */
525
- <A, E, R>(
526
- self: HttpClient<A, E, R>,
545
+ <E, R>(
546
+ self: HttpClient<E, R>,
527
547
  f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest
528
- ): HttpClient<A, E, R>
548
+ ): HttpClient<E, R>
529
549
  } = internal.mapRequestInput
530
550
 
531
551
  /**
@@ -543,17 +563,17 @@ export const mapRequestInputEffect: {
543
563
  */
544
564
  <E2, R2>(
545
565
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>
546
- ): <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E2 | E, R2 | R>
566
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E | E2, R | R2>
547
567
  /**
548
568
  * Prepends an effectful transformation of the request object before sending it.
549
569
  *
550
570
  * @since 1.0.0
551
571
  * @category mapping & sequencing
552
572
  */
553
- <A, E, R, E2, R2>(
554
- self: HttpClient<A, E, R>,
573
+ <E, R, E2, R2>(
574
+ self: HttpClient<E, R>,
555
575
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>
556
- ): HttpClient<A, E | E2, R2 | R>
576
+ ): HttpClient<E | E2, R | R2>
557
577
  } = internal.mapRequestInputEffect
558
578
 
559
579
  /**
@@ -565,8 +585,7 @@ export declare namespace Retry {
565
585
  * @since 1.0.0
566
586
  * @category error handling
567
587
  */
568
- export type Return<R, E, A, O extends Effect.Retry.Options<E>> = HttpClient<
569
- A,
588
+ export type Return<R, E, O extends Effect.Retry.Options<E>> = HttpClient<
570
589
  | (O extends { schedule: Schedule.Schedule<infer _O, infer _I, infer _R> } ? E
571
590
  : O extends { until: Predicate.Refinement<E, infer E2> } ? E2
572
591
  : E)
@@ -592,30 +611,28 @@ export const retry: {
592
611
  * @since 1.0.0
593
612
  * @category error handling
594
613
  */
595
- <E, O extends Effect.Retry.Options<E>>(options: O): <A, R>(self: HttpClient<A, E, R>) => Retry.Return<R, E, A, O>
614
+ <E, O extends Effect.Retry.Options<E>>(options: O): <R>(self: HttpClient<E, R>) => Retry.Return<R, E, O>
596
615
  /**
597
616
  * Retries the request based on a provided schedule or policy.
598
617
  *
599
618
  * @since 1.0.0
600
619
  * @category error handling
601
620
  */
602
- <B, E, R1>(
603
- policy: Schedule.Schedule<B, NoInfer<E>, R1>
604
- ): <A, R>(self: HttpClient<A, E, R>) => HttpClient<A, E, R1 | R>
621
+ <B, E, R1>(policy: Schedule.Schedule<B, NoInfer<E>, R1>): <R>(self: HttpClient<E, R>) => HttpClient<E, R1 | R>
605
622
  /**
606
623
  * Retries the request based on a provided schedule or policy.
607
624
  *
608
625
  * @since 1.0.0
609
626
  * @category error handling
610
627
  */
611
- <A, E, R, O extends Effect.Retry.Options<E>>(self: HttpClient<A, E, R>, options: O): Retry.Return<R, E, A, O>
628
+ <E, R, O extends Effect.Retry.Options<E>>(self: HttpClient<E, R>, options: O): Retry.Return<R, E, O>
612
629
  /**
613
630
  * Retries the request based on a provided schedule or policy.
614
631
  *
615
632
  * @since 1.0.0
616
633
  * @category error handling
617
634
  */
618
- <A, E, R, B, R1>(self: HttpClient<A, E, R>, policy: Schedule.Schedule<B, E, R1>): HttpClient<A, E, R1 | R>
635
+ <E, R, B, R1>(self: HttpClient<E, R>, policy: Schedule.Schedule<B, E, R1>): HttpClient<E, R1 | R>
619
636
  } = internal.retry
620
637
 
621
638
  /**
@@ -635,62 +652,21 @@ export const retryTransient: {
635
652
  options:
636
653
  | { readonly schedule?: Schedule.Schedule<B, NoInfer<E>, R1>; readonly times?: number }
637
654
  | Schedule.Schedule<B, NoInfer<E>, R1>
638
- ): <A, R>(self: HttpClient<A, E, R>) => HttpClient<A, E, R1 | R>
655
+ ): <R>(self: HttpClient<E, R>) => HttpClient<E, R1 | R>
639
656
  /**
640
657
  * Retries common transient errors, such as rate limiting or network issues.
641
658
  *
642
659
  * @since 1.0.0
643
660
  * @category error handling
644
661
  */
645
- <A, E, R, B, R1 = never>(
646
- self: HttpClient<A, E, R>,
662
+ <E, R, B, R1 = never>(
663
+ self: HttpClient<E, R>,
647
664
  options:
648
665
  | { readonly schedule?: Schedule.Schedule<B, NoInfer<E>, R1>; readonly times?: number }
649
666
  | Schedule.Schedule<B, NoInfer<E>, R1>
650
- ): HttpClient<A, E, R1 | R>
667
+ ): HttpClient<E, R1 | R>
651
668
  } = internal.retryTransient
652
669
 
653
- /**
654
- * Ensures resources are properly scoped and released after execution.
655
- *
656
- * @since 1.0.0
657
- * @category resources & finalizers
658
- */
659
- export const scoped: <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E, Exclude<R, Scope.Scope>> = internal.scoped
660
-
661
- /**
662
- * Creates a function that validates request data against a schema before sending it.
663
- *
664
- * @since 1.0.0
665
- * @category schema
666
- */
667
- export const schemaFunction: {
668
- /**
669
- * Creates a function that validates request data against a schema before sending it.
670
- *
671
- * @since 1.0.0
672
- * @category schema
673
- */
674
- <SA, SI, SR>(schema: Schema.Schema<SA, SI, SR>, options?: ParseOptions | undefined): <A, E, R>(
675
- self: HttpClient<A, E, R>
676
- ) => (
677
- request: ClientRequest.HttpClientRequest
678
- ) => (a: SA) => Effect.Effect<A, Error.RequestError | E | ParseResult.ParseError, SR | R>
679
- /**
680
- * Creates a function that validates request data against a schema before sending it.
681
- *
682
- * @since 1.0.0
683
- * @category schema
684
- */
685
- <A, E, R, SA, SI, SR>(
686
- self: HttpClient<A, E, R>,
687
- schema: Schema.Schema<SA, SI, SR>,
688
- options?: ParseOptions | undefined
689
- ): (
690
- request: ClientRequest.HttpClientRequest
691
- ) => (a: SA) => Effect.Effect<A, Error.RequestError | ParseResult.ParseError | E, R | SR>
692
- } = internal.schemaFunction
693
-
694
670
  /**
695
671
  * Performs an additional effect after a successful request.
696
672
  *
@@ -704,16 +680,19 @@ export const tap: {
704
680
  * @since 1.0.0
705
681
  * @category mapping & sequencing
706
682
  */
707
- <A, _, E2, R2>(
708
- f: (a: A) => Effect.Effect<_, E2, R2>
709
- ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E2 | E, R2 | R>
683
+ <_, E2, R2>(
684
+ f: (response: ClientResponse.HttpClientResponse) => Effect.Effect<_, E2, R2>
685
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E | E2, R | R2>
710
686
  /**
711
687
  * Performs an additional effect after a successful request.
712
688
  *
713
689
  * @since 1.0.0
714
690
  * @category mapping & sequencing
715
691
  */
716
- <A, E, R, _, E2, R2>(self: HttpClient<A, E, R>, f: (a: A) => Effect.Effect<_, E2, R2>): HttpClient<A, E | E2, R2 | R>
692
+ <E, R, _, E2, R2>(
693
+ self: HttpClient<E, R>,
694
+ f: (response: ClientResponse.HttpClientResponse) => Effect.Effect<_, E2, R2>
695
+ ): HttpClient<E | E2, R | R2>
717
696
  } = internal.tap
718
697
 
719
698
  /**
@@ -731,17 +710,17 @@ export const tapRequest: {
731
710
  */
732
711
  <_, E2, R2>(
733
712
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<_, E2, R2>
734
- ): <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E2 | E, R2 | R>
713
+ ): <E, R>(self: HttpClient<E, R>) => HttpClient<E | E2, R | R2>
735
714
  /**
736
715
  * Performs an additional effect on the request before sending it.
737
716
  *
738
717
  * @since 1.0.0
739
718
  * @category mapping & sequencing
740
719
  */
741
- <A, E, R, _, E2, R2>(
742
- self: HttpClient<A, E, R>,
720
+ <E, R, _, E2, R2>(
721
+ self: HttpClient<E, R>,
743
722
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<_, E2, R2>
744
- ): HttpClient<A, E | E2, R | R2>
723
+ ): HttpClient<E | E2, R | R2>
745
724
  } = internal.tapRequest
746
725
 
747
726
  /**
@@ -757,14 +736,14 @@ export const withCookiesRef: {
757
736
  * @since 1.0.0
758
737
  * @category cookies
759
738
  */
760
- (ref: Ref<Cookies>): <E, R>(self: HttpClient.WithResponse<E, R>) => HttpClient.WithResponse<E, R>
739
+ (ref: Ref<Cookies>): <E, R>(self: HttpClient<E, R>) => HttpClient<E, R>
761
740
  /**
762
741
  * Associates a `Ref` of cookies with the client for handling cookies across requests.
763
742
  *
764
743
  * @since 1.0.0
765
744
  * @category cookies
766
745
  */
767
- <E, R>(self: HttpClient.WithResponse<E, R>, ref: Ref<Cookies>): HttpClient.WithResponse<E, R>
746
+ <E, R>(self: HttpClient<E, R>, ref: Ref<Cookies>): HttpClient<E, R>
768
747
  } = internal.withCookiesRef
769
748
 
770
749
  /**
@@ -780,14 +759,14 @@ export const followRedirects: {
780
759
  * @since 1.0.0
781
760
  * @category redirects
782
761
  */
783
- (maxRedirects?: number | undefined): <E, R>(self: HttpClient.WithResponse<E, R>) => HttpClient.WithResponse<E, R>
762
+ (maxRedirects?: number | undefined): <E, R>(self: HttpClient<E, R>) => HttpClient<E, R>
784
763
  /**
785
764
  * Follows HTTP redirects up to a specified number of times.
786
765
  *
787
766
  * @since 1.0.0
788
767
  * @category redirects
789
768
  */
790
- <E, R>(self: HttpClient.WithResponse<E, R>, maxRedirects?: number | undefined): HttpClient.WithResponse<E, R>
769
+ <E, R>(self: HttpClient<E, R>, maxRedirects?: number | undefined): HttpClient<E, R>
791
770
  } = internal.followRedirects
792
771
 
793
772
  /**
@@ -858,5 +837,5 @@ export const withTracerPropagation: {
858
837
  * @since 1.0.0
859
838
  */
860
839
  export const layerMergedContext: <E, R>(
861
- effect: Effect.Effect<HttpClient.Service, E, R>
862
- ) => Layer<HttpClient.Service, E, R> = internal.layerMergedContext
840
+ effect: Effect.Effect<HttpClient, E, R>
841
+ ) => Layer<HttpClient, E, R> = internal.layerMergedContext