@effect/platform 0.64.1 → 0.65.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 (91) hide show
  1. package/FetchHttpClient/package.json +6 -0
  2. package/README.md +173 -195
  3. package/dist/cjs/FetchHttpClient.js +32 -0
  4. package/dist/cjs/FetchHttpClient.js.map +1 -0
  5. package/dist/cjs/HttpApiClient.js +1 -1
  6. package/dist/cjs/HttpApiClient.js.map +1 -1
  7. package/dist/cjs/HttpClient.js +5 -36
  8. package/dist/cjs/HttpClient.js.map +1 -1
  9. package/dist/cjs/HttpClientRequest.js +11 -11
  10. package/dist/cjs/HttpClientRequest.js.map +1 -1
  11. package/dist/cjs/HttpClientResponse.js +2 -61
  12. package/dist/cjs/HttpClientResponse.js.map +1 -1
  13. package/dist/cjs/HttpIncomingMessage.js +2 -29
  14. package/dist/cjs/HttpIncomingMessage.js.map +1 -1
  15. package/dist/cjs/Runtime.js +1 -1
  16. package/dist/cjs/Runtime.js.map +1 -1
  17. package/dist/cjs/Socket.js +42 -53
  18. package/dist/cjs/Socket.js.map +1 -1
  19. package/dist/cjs/index.js +3 -1
  20. package/dist/cjs/internal/fetchHttpClient.js +52 -0
  21. package/dist/cjs/internal/fetchHttpClient.js.map +1 -0
  22. package/dist/cjs/internal/httpClient.js +82 -71
  23. package/dist/cjs/internal/httpClient.js.map +1 -1
  24. package/dist/cjs/internal/httpClientRequest.js +13 -13
  25. package/dist/cjs/internal/httpClientRequest.js.map +1 -1
  26. package/dist/cjs/internal/httpClientResponse.js +1 -33
  27. package/dist/cjs/internal/httpClientResponse.js.map +1 -1
  28. package/dist/cjs/internal/worker.js +21 -29
  29. package/dist/cjs/internal/worker.js.map +1 -1
  30. package/dist/dts/FetchHttpClient.d.ts +27 -0
  31. package/dist/dts/FetchHttpClient.d.ts.map +1 -0
  32. package/dist/dts/HttpApiClient.d.ts +2 -2
  33. package/dist/dts/HttpClient.d.ts +53 -61
  34. package/dist/dts/HttpClient.d.ts.map +1 -1
  35. package/dist/dts/HttpClientRequest.d.ts +11 -11
  36. package/dist/dts/HttpClientRequest.d.ts.map +1 -1
  37. package/dist/dts/HttpClientResponse.d.ts +4 -90
  38. package/dist/dts/HttpClientResponse.d.ts.map +1 -1
  39. package/dist/dts/HttpIncomingMessage.d.ts +0 -16
  40. package/dist/dts/HttpIncomingMessage.d.ts.map +1 -1
  41. package/dist/dts/HttpServer.d.ts +1 -1
  42. package/dist/dts/Socket.d.ts +3 -3
  43. package/dist/dts/Socket.d.ts.map +1 -1
  44. package/dist/dts/index.d.ts +4 -0
  45. package/dist/dts/index.d.ts.map +1 -1
  46. package/dist/dts/internal/fetchHttpClient.d.ts +2 -0
  47. package/dist/dts/internal/fetchHttpClient.d.ts.map +1 -0
  48. package/dist/esm/FetchHttpClient.js +21 -0
  49. package/dist/esm/FetchHttpClient.js.map +1 -0
  50. package/dist/esm/HttpApiClient.js +1 -1
  51. package/dist/esm/HttpApiClient.js.map +1 -1
  52. package/dist/esm/HttpClient.js +4 -35
  53. package/dist/esm/HttpClient.js.map +1 -1
  54. package/dist/esm/HttpClientRequest.js +10 -10
  55. package/dist/esm/HttpClientRequest.js.map +1 -1
  56. package/dist/esm/HttpClientResponse.js +1 -63
  57. package/dist/esm/HttpClientResponse.js.map +1 -1
  58. package/dist/esm/HttpIncomingMessage.js +0 -24
  59. package/dist/esm/HttpIncomingMessage.js.map +1 -1
  60. package/dist/esm/Runtime.js +1 -1
  61. package/dist/esm/Runtime.js.map +1 -1
  62. package/dist/esm/Socket.js +42 -53
  63. package/dist/esm/Socket.js.map +1 -1
  64. package/dist/esm/index.js +4 -0
  65. package/dist/esm/index.js.map +1 -1
  66. package/dist/esm/internal/fetchHttpClient.js +44 -0
  67. package/dist/esm/internal/fetchHttpClient.js.map +1 -0
  68. package/dist/esm/internal/httpClient.js +79 -69
  69. package/dist/esm/internal/httpClient.js.map +1 -1
  70. package/dist/esm/internal/httpClientRequest.js +11 -11
  71. package/dist/esm/internal/httpClientRequest.js.map +1 -1
  72. package/dist/esm/internal/httpClientResponse.js +0 -24
  73. package/dist/esm/internal/httpClientResponse.js.map +1 -1
  74. package/dist/esm/internal/worker.js +21 -29
  75. package/dist/esm/internal/worker.js.map +1 -1
  76. package/package.json +11 -3
  77. package/src/FetchHttpClient.ts +25 -0
  78. package/src/HttpApiClient.ts +5 -5
  79. package/src/HttpClient.ts +79 -85
  80. package/src/HttpClientRequest.ts +21 -21
  81. package/src/HttpClientResponse.ts +4 -162
  82. package/src/HttpIncomingMessage.ts +0 -43
  83. package/src/HttpServer.ts +1 -1
  84. package/src/Runtime.ts +1 -1
  85. package/src/Socket.ts +42 -58
  86. package/src/index.ts +5 -0
  87. package/src/internal/fetchHttpClient.ts +53 -0
  88. package/src/internal/httpClient.ts +149 -125
  89. package/src/internal/httpClientRequest.ts +12 -12
  90. package/src/internal/httpClientResponse.ts +6 -96
  91. package/src/internal/worker.ts +40 -55
package/src/HttpClient.ts CHANGED
@@ -9,7 +9,7 @@ import type * as Effect from "effect/Effect"
9
9
  import type { RuntimeFiber } from "effect/Fiber"
10
10
  import type * as FiberRef from "effect/FiberRef"
11
11
  import type { Inspectable } from "effect/Inspectable"
12
- import type * as Layer from "effect/Layer"
12
+ import type { Layer } from "effect/Layer"
13
13
  import type { Pipeable } from "effect/Pipeable"
14
14
  import type * as Predicate from "effect/Predicate"
15
15
  import type { Ref } from "effect/Ref"
@@ -38,10 +38,16 @@ export type TypeId = typeof TypeId
38
38
  * @category models
39
39
  */
40
40
  export interface HttpClient<A = ClientResponse.HttpClientResponse, E = never, R = never> extends Pipeable, Inspectable {
41
- (request: ClientRequest.HttpClientRequest): Effect.Effect<A, E, R>
42
41
  readonly [TypeId]: TypeId
43
- readonly preprocess: HttpClient.Preprocess<E, R>
44
- readonly execute: HttpClient.Execute<A, E, R>
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>
45
51
  }
46
52
 
47
53
  /**
@@ -60,7 +66,7 @@ export declare namespace HttpClient {
60
66
  * @since 1.0.0
61
67
  * @category models
62
68
  */
63
- export type Execute<A, E = never, R = never> = (
69
+ export type Postprocess<A, E = never, R = never> = (
64
70
  request: Effect.Effect<ClientRequest.HttpClientRequest, E, R>
65
71
  ) => Effect.Effect<A, E, R>
66
72
 
@@ -74,46 +80,14 @@ export declare namespace HttpClient {
74
80
  * @since 1.0.0
75
81
  * @category models
76
82
  */
77
- export type Default = WithResponse<Error.HttpClientError, Scope.Scope>
78
- }
79
-
80
- /**
81
- * @since 1.0.0
82
- * @category models
83
- */
84
- export interface Fetch {
85
- readonly _: unique symbol
83
+ export type Service = WithResponse<Error.HttpClientError, Scope.Scope>
86
84
  }
87
85
 
88
86
  /**
89
87
  * @since 1.0.0
90
88
  * @category tags
91
89
  */
92
- export const HttpClient: Context.Tag<HttpClient.Default, HttpClient.Default> = internal.tag
93
-
94
- /**
95
- * @since 1.0.0
96
- * @category tags
97
- */
98
- export const Fetch: Context.Tag<Fetch, typeof globalThis.fetch> = internal.Fetch
99
-
100
- /**
101
- * @since 1.0.0
102
- * @category layers
103
- */
104
- export const layer: Layer.Layer<HttpClient.Default> = internal.layer
105
-
106
- /**
107
- * @since 1.0.0
108
- * @category constructors
109
- */
110
- export const fetch: HttpClient.Default = internal.fetch
111
-
112
- /**
113
- * @since 1.0.0
114
- * @category constructors
115
- */
116
- export const fetchOk: HttpClient.Default = internal.fetchOk
90
+ export const HttpClient: Context.Tag<HttpClient.Service, HttpClient.Service> = internal.tag
117
91
 
118
92
  /**
119
93
  * @since 1.0.0
@@ -200,15 +174,26 @@ export const catchTags: {
200
174
  * @category filters
201
175
  */
202
176
  export const filterOrElse: {
177
+ <A, B extends A, C, E2, R2>(
178
+ refinement: Predicate.Refinement<NoInfer<A>, B>,
179
+ orElse: (a: NoInfer<A>) => Effect.Effect<C, E2, R2>
180
+ ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<B | C, E | E2, R | R2>
203
181
  <A, B, E2, R2>(
204
- f: Predicate.Predicate<A>,
205
- orElse: (a: A) => Effect.Effect<B, E2, R2>
206
- ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<A | B, E2 | E, R2 | R>
182
+ predicate: Predicate.Predicate<NoInfer<A>>,
183
+ orElse: (a: NoInfer<A>) => Effect.Effect<B, E2, R2>
184
+ ): <E, R>(
185
+ self: HttpClient<A, E, R>
186
+ ) => HttpClient<A | B, E2 | E, R2 | R>
187
+ <A, E, R, B extends A, C, E2, R2>(
188
+ self: HttpClient<A, E, R>,
189
+ refinement: Predicate.Refinement<A, B>,
190
+ orElse: (a: A) => Effect.Effect<C, E2, R2>
191
+ ): HttpClient<B | C, E | E2, R | R2>
207
192
  <A, E, R, B, E2, R2>(
208
193
  self: HttpClient<A, E, R>,
209
- f: Predicate.Predicate<A>,
194
+ predicate: Predicate.Predicate<A>,
210
195
  orElse: (a: A) => Effect.Effect<B, E2, R2>
211
- ): HttpClient<A | B, E | E2, R | R2>
196
+ ): HttpClient<A | B, E2 | E, R2 | R>
212
197
  } = internal.filterOrElse
213
198
 
214
199
  /**
@@ -216,15 +201,24 @@ export const filterOrElse: {
216
201
  * @category filters
217
202
  */
218
203
  export const filterOrFail: {
204
+ <A, B extends A, E2>(
205
+ refinement: Predicate.Refinement<NoInfer<A>, B>,
206
+ orFailWith: (a: NoInfer<A>) => E2
207
+ ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<B, E | E2, R>
219
208
  <A, E2>(
220
- f: Predicate.Predicate<A>,
221
- orFailWith: (a: A) => E2
209
+ predicate: Predicate.Predicate<NoInfer<A>>,
210
+ orFailWith: (a: NoInfer<A>) => E2
222
211
  ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E2 | E, R>
212
+ <A, B extends A, E, R, E2>(
213
+ self: HttpClient<A, E, R>,
214
+ refinement: Predicate.Refinement<A, B>,
215
+ orFailWith: (a: A) => E2
216
+ ): HttpClient<B, E2 | E, R>
223
217
  <A, E, R, E2>(
224
218
  self: HttpClient<A, E, R>,
225
- f: Predicate.Predicate<A>,
219
+ predicate: Predicate.Predicate<A>,
226
220
  orFailWith: (a: A) => E2
227
- ): HttpClient<A, E | E2, R>
221
+ ): HttpClient<A, E2 | E, R>
228
222
  } = internal.filterOrFail
229
223
 
230
224
  /**
@@ -262,14 +256,14 @@ export const make: <A, E, R, E2, R2>(
262
256
  * @since 1.0.0
263
257
  * @category constructors
264
258
  */
265
- export const makeDefault: (
259
+ export const makeService: (
266
260
  f: (
267
261
  request: ClientRequest.HttpClientRequest,
268
262
  url: URL,
269
263
  signal: AbortSignal,
270
264
  fiber: RuntimeFiber<ClientResponse.HttpClientResponse, Error.HttpClientError>
271
265
  ) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError, Scope.Scope>
272
- ) => HttpClient.Default = internal.makeDefault
266
+ ) => HttpClient.Service = internal.makeService
273
267
 
274
268
  /**
275
269
  * @since 1.0.0
@@ -319,20 +313,6 @@ export const mapEffect: {
319
313
  <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>
320
314
  } = internal.mapEffect
321
315
 
322
- /**
323
- * @since 1.0.0
324
- * @category mapping & sequencing
325
- */
326
- export const mapEffectScoped: {
327
- <A, B, E2, R2>(
328
- f: (a: A) => Effect.Effect<B, E2, R2>
329
- ): <E, R>(self: HttpClient<A, E, R>) => HttpClient<B, E2 | E, Exclude<R2, Scope.Scope> | Exclude<R, Scope.Scope>>
330
- <A, E, R, B, E2, R2>(
331
- self: HttpClient<A, E, R>,
332
- f: (a: A) => Effect.Effect<B, E2, R2>
333
- ): HttpClient<B, E | E2, Exclude<R2, Scope.Scope> | Exclude<R, Scope.Scope>>
334
- } = internal.mapEffectScoped
335
-
336
316
  /**
337
317
  * @since 1.0.0
338
318
  * @category mapping & sequencing
@@ -365,7 +345,7 @@ export const mapRequestEffect: {
365
345
  * @since 1.0.0
366
346
  * @category mapping & sequencing
367
347
  */
368
- export const mapInputRequest: {
348
+ export const mapRequestInput: {
369
349
  (
370
350
  f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest
371
351
  ): <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E, R>
@@ -373,13 +353,13 @@ export const mapInputRequest: {
373
353
  self: HttpClient<A, E, R>,
374
354
  f: (a: ClientRequest.HttpClientRequest) => ClientRequest.HttpClientRequest
375
355
  ): HttpClient<A, E, R>
376
- } = internal.mapInputRequest
356
+ } = internal.mapRequestInput
377
357
 
378
358
  /**
379
359
  * @since 1.0.0
380
360
  * @category mapping & sequencing
381
361
  */
382
- export const mapInputRequestEffect: {
362
+ export const mapRequestInputEffect: {
383
363
  <E2, R2>(
384
364
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>
385
365
  ): <A, E, R>(self: HttpClient<A, E, R>) => HttpClient<A, E2 | E, R2 | R>
@@ -387,20 +367,42 @@ export const mapInputRequestEffect: {
387
367
  self: HttpClient<A, E, R>,
388
368
  f: (a: ClientRequest.HttpClientRequest) => Effect.Effect<ClientRequest.HttpClientRequest, E2, R2>
389
369
  ): HttpClient<A, E | E2, R2 | R>
390
- } = internal.mapInputRequestEffect
370
+ } = internal.mapRequestInputEffect
371
+
372
+ /**
373
+ * @since 1.0.0
374
+ * @category error handling
375
+ */
376
+ export declare namespace Retry {
377
+ /**
378
+ * @since 1.0.0
379
+ * @category error handling
380
+ */
381
+ export type Return<R, E, A, O extends Effect.Retry.Options<E>> = HttpClient<
382
+ A,
383
+ | (O extends { schedule: Schedule.Schedule<infer _O, infer _I, infer _R> } ? E
384
+ : O extends { until: Predicate.Refinement<E, infer E2> } ? E2
385
+ : E)
386
+ | (O extends { while: (...args: Array<any>) => Effect.Effect<infer _A, infer E, infer _R> } ? E : never)
387
+ | (O extends { until: (...args: Array<any>) => Effect.Effect<infer _A, infer E, infer _R> } ? E : never),
388
+ | R
389
+ | (O extends { schedule: Schedule.Schedule<infer _O, infer _I, infer R> } ? R : never)
390
+ | (O extends { while: (...args: Array<any>) => Effect.Effect<infer _A, infer _E, infer R> } ? R : never)
391
+ | (O extends { until: (...args: Array<any>) => Effect.Effect<infer _A, infer _E, infer R> } ? R : never)
392
+ > extends infer Z ? Z : never
393
+ }
391
394
 
392
395
  /**
393
396
  * @since 1.0.0
394
397
  * @category error handling
395
398
  */
396
399
  export const retry: {
397
- <B, E extends E0, E0, R1>(
398
- policy: Schedule.Schedule<B, E0, R1>
400
+ <E, O extends Effect.Retry.Options<E>>(options: O): <A, R>(self: HttpClient<A, E, R>) => Retry.Return<R, E, A, O>
401
+ <B, E, R1>(
402
+ policy: Schedule.Schedule<B, NoInfer<E>, R1>
399
403
  ): <A, R>(self: HttpClient<A, E, R>) => HttpClient<A, E, R1 | R>
400
- <A, E extends E0, E0, R, R1, B>(
401
- self: HttpClient<A, E, R>,
402
- policy: Schedule.Schedule<B, E0, R1>
403
- ): HttpClient<A, E, R1 | R>
404
+ <A, E, R, O extends Effect.Retry.Options<E>>(self: HttpClient<A, E, R>, options: O): Retry.Return<R, E, A, O>
405
+ <A, E, R, B, R1>(self: HttpClient<A, E, R>, policy: Schedule.Schedule<B, E, R1>): HttpClient<A, E, R1 | R>
404
406
  } = internal.retry
405
407
 
406
408
  /**
@@ -512,15 +514,7 @@ export const withTracerPropagation: {
512
514
 
513
515
  /**
514
516
  * @since 1.0.0
515
- * @category fiber refs
516
- */
517
- export const currentFetchOptions: FiberRef.FiberRef<RequestInit> = internal.currentFetchOptions
518
-
519
- /**
520
- * @since 1.0.0
521
- * @category fiber refs
522
517
  */
523
- export const withFetchOptions: {
524
- (options: RequestInit): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
525
- <A, E, R>(effect: Effect.Effect<A, E, R>, options: RequestInit): Effect.Effect<A, E, R>
526
- } = internal.withFetchOptions
518
+ export const layerMergedContext: <E, R>(
519
+ effect: Effect.Effect<HttpClient.Service, E, R>
520
+ ) => Layer<HttpClient.Service, E, R> = internal.layerMergedContext
@@ -36,7 +36,7 @@ export type TypeId = typeof TypeId
36
36
  * @category models
37
37
  */
38
38
  export interface HttpClientRequest
39
- extends Effect.Effect<HttpClientResponse, HttpClientError, HttpClient.Default | Scope>, Inspectable
39
+ extends Effect.Effect<HttpClientResponse, HttpClientError, HttpClient.Service | Scope>, Inspectable
40
40
  {
41
41
  readonly [TypeId]: TypeId
42
42
  readonly method: HttpMethod
@@ -301,73 +301,73 @@ export const setBody: {
301
301
  * @since 1.0.0
302
302
  * @category combinators
303
303
  */
304
- export const uint8ArrayBody: {
304
+ export const bodyUint8Array: {
305
305
  (body: Uint8Array, contentType?: string): (self: HttpClientRequest) => HttpClientRequest
306
306
  (self: HttpClientRequest, body: Uint8Array, contentType?: string): HttpClientRequest
307
- } = internal.uint8ArrayBody
307
+ } = internal.bodyUint8Array
308
308
 
309
309
  /**
310
310
  * @since 1.0.0
311
311
  * @category combinators
312
312
  */
313
- export const textBody: {
313
+ export const bodyText: {
314
314
  (body: string, contentType?: string): (self: HttpClientRequest) => HttpClientRequest
315
315
  (self: HttpClientRequest, body: string, contentType?: string): HttpClientRequest
316
- } = internal.textBody
316
+ } = internal.bodyText
317
317
 
318
318
  /**
319
319
  * @since 1.0.0
320
320
  * @category combinators
321
321
  */
322
- export const jsonBody: {
322
+ export const bodyJson: {
323
323
  (body: unknown): (self: HttpClientRequest) => Effect.Effect<HttpClientRequest, Body.HttpBodyError>
324
324
  (self: HttpClientRequest, body: unknown): Effect.Effect<HttpClientRequest, Body.HttpBodyError>
325
- } = internal.jsonBody
325
+ } = internal.bodyJson
326
326
 
327
327
  /**
328
328
  * @since 1.0.0
329
329
  * @category combinators
330
330
  */
331
- export const unsafeJsonBody: {
331
+ export const bodyUnsafeJson: {
332
332
  (body: unknown): (self: HttpClientRequest) => HttpClientRequest
333
333
  (self: HttpClientRequest, body: unknown): HttpClientRequest
334
- } = internal.unsafeJsonBody
334
+ } = internal.bodyUnsafeJson
335
335
 
336
336
  /**
337
337
  * @since 1.0.0
338
338
  * @category combinators
339
339
  */
340
- export const schemaBody: <A, I, R>(
340
+ export const schemaBodyJson: <A, I, R>(
341
341
  schema: Schema.Schema<A, I, R>,
342
342
  options?: ParseOptions | undefined
343
343
  ) => {
344
344
  (body: A): (self: HttpClientRequest) => Effect.Effect<HttpClientRequest, Body.HttpBodyError, R>
345
345
  (self: HttpClientRequest, body: A): Effect.Effect<HttpClientRequest, Body.HttpBodyError, R>
346
- } = internal.schemaBody
346
+ } = internal.schemaBodyJson
347
347
 
348
348
  /**
349
349
  * @since 1.0.0
350
350
  * @category combinators
351
351
  */
352
- export const urlParamsBody: {
352
+ export const bodyUrlParams: {
353
353
  (input: UrlParams.Input): (self: HttpClientRequest) => HttpClientRequest
354
354
  (self: HttpClientRequest, input: UrlParams.Input): HttpClientRequest
355
- } = internal.urlParamsBody
355
+ } = internal.bodyUrlParams
356
356
 
357
357
  /**
358
358
  * @since 1.0.0
359
359
  * @category combinators
360
360
  */
361
- export const formDataBody: {
361
+ export const bodyFormData: {
362
362
  (body: FormData): (self: HttpClientRequest) => HttpClientRequest
363
363
  (self: HttpClientRequest, body: FormData): HttpClientRequest
364
- } = internal.formDataBody
364
+ } = internal.bodyFormData
365
365
 
366
366
  /**
367
367
  * @since 1.0.0
368
368
  * @category combinators
369
369
  */
370
- export const streamBody: {
370
+ export const bodyStream: {
371
371
  (
372
372
  body: Stream.Stream<Uint8Array, unknown>,
373
373
  options?: { readonly contentType?: string | undefined; readonly contentLength?: number | undefined } | undefined
@@ -377,13 +377,13 @@ export const streamBody: {
377
377
  body: Stream.Stream<Uint8Array, unknown>,
378
378
  options?: { readonly contentType?: string | undefined; readonly contentLength?: number | undefined } | undefined
379
379
  ): HttpClientRequest
380
- } = internal.streamBody
380
+ } = internal.bodyStream
381
381
 
382
382
  /**
383
383
  * @since 1.0.0
384
384
  * @category combinators
385
385
  */
386
- export const fileBody: {
386
+ export const bodyFile: {
387
387
  (
388
388
  path: string,
389
389
  options?: FileSystem.StreamOptions & { readonly contentType?: string }
@@ -393,13 +393,13 @@ export const fileBody: {
393
393
  path: string,
394
394
  options?: FileSystem.StreamOptions & { readonly contentType?: string }
395
395
  ): Effect.Effect<HttpClientRequest, PlatformError.PlatformError, FileSystem.FileSystem>
396
- } = internal.fileBody
396
+ } = internal.bodyFile
397
397
 
398
398
  /**
399
399
  * @since 1.0.0
400
400
  * @category combinators
401
401
  */
402
- export const fileWebBody: {
402
+ export const bodyFileWeb: {
403
403
  (file: Body.HttpBody.FileLike): (self: HttpClientRequest) => HttpClientRequest
404
404
  (self: HttpClientRequest, file: Body.HttpBody.FileLike): HttpClientRequest
405
- } = internal.fileWebBody
405
+ } = internal.bodyFileWeb
@@ -7,12 +7,12 @@ import type * as Schema from "@effect/schema/Schema"
7
7
  import type * as Effect from "effect/Effect"
8
8
  import type * as Scope from "effect/Scope"
9
9
  import type * as Stream from "effect/Stream"
10
+ import type { Unify } from "effect/Unify"
10
11
  import type * as Cookies from "./Cookies.js"
11
12
  import type * as Error from "./HttpClientError.js"
12
13
  import type * as ClientRequest from "./HttpClientRequest.js"
13
14
  import type * as IncomingMessage from "./HttpIncomingMessage.js"
14
15
  import * as internal from "./internal/httpClientResponse.js"
15
- import type * as UrlParams from "./UrlParams.js"
16
16
 
17
17
  export {
18
18
  /**
@@ -20,11 +20,6 @@ export {
20
20
  * @category schema
21
21
  */
22
22
  schemaBodyJson,
23
- /**
24
- * @since 1.0.0
25
- * @category schema
26
- */
27
- schemaBodyJsonScoped,
28
23
  /**
29
24
  * @since 1.0.0
30
25
  * @category schema
@@ -34,17 +29,7 @@ export {
34
29
  * @since 1.0.0
35
30
  * @category schema
36
31
  */
37
- schemaBodyUrlParamsScoped,
38
- /**
39
- * @since 1.0.0
40
- * @category schema
41
- */
42
- schemaHeaders,
43
- /**
44
- * @since 1.0.0
45
- * @category schema
46
- */
47
- schemaHeadersScoped
32
+ schemaHeaders
48
33
  } from "./HttpIncomingMessage.js"
49
34
 
50
35
  /**
@@ -111,41 +96,6 @@ export const schemaNoBody: <
111
96
  options?: ParseOptions | undefined
112
97
  ) => (self: HttpClientResponse) => Effect.Effect<A, ParseResult.ParseError, R> = internal.schemaNoBody
113
98
 
114
- /**
115
- * @since 1.0.0
116
- * @category accessors
117
- */
118
- export const arrayBuffer: <E, R>(
119
- effect: Effect.Effect<HttpClientResponse, E, R>
120
- ) => Effect.Effect<ArrayBuffer, Error.ResponseError | E, Exclude<R, Scope.Scope>> = internal.arrayBuffer
121
-
122
- /**
123
- * @since 1.0.0
124
- * @category accessors
125
- */
126
- export const formData: <E, R>(
127
- effect: Effect.Effect<HttpClientResponse, E, R>
128
- ) => Effect.Effect<FormData, Error.ResponseError | E, Exclude<R, Scope.Scope>> = internal.formData
129
-
130
- /**
131
- * @since 1.0.0
132
- * @category accessors
133
- */
134
- export const json: <E, R>(
135
- effect: Effect.Effect<HttpClientResponse, E, R>
136
- ) => Effect.Effect<unknown, Error.ResponseError | E, Exclude<R, Scope.Scope>> = internal.json
137
-
138
- const void_: <E, R>(
139
- effect: Effect.Effect<HttpClientResponse, E, R>
140
- ) => Effect.Effect<void, E, Exclude<R, Scope.Scope>> = internal.void_
141
- export {
142
- /**
143
- * @since 1.0.0
144
- * @category accessors
145
- */
146
- void_ as void
147
- }
148
-
149
99
  /**
150
100
  * @since 1.0.0
151
101
  * @category accessors
@@ -154,64 +104,6 @@ export const stream: <E, R>(
154
104
  effect: Effect.Effect<HttpClientResponse, E, R>
155
105
  ) => Stream.Stream<Uint8Array, Error.ResponseError | E, Exclude<R, Scope.Scope>> = internal.stream
156
106
 
157
- /**
158
- * @since 1.0.0
159
- * @category accessors
160
- */
161
- export const text: <E, R>(
162
- effect: Effect.Effect<HttpClientResponse, E, R>
163
- ) => Effect.Effect<string, Error.ResponseError | E, Exclude<R, Scope.Scope>> = internal.text
164
-
165
- /**
166
- * @since 1.0.0
167
- * @category accessors
168
- */
169
- export const urlParamsBody: <E, R>(
170
- effect: Effect.Effect<HttpClientResponse, E, R>
171
- ) => Effect.Effect<UrlParams.UrlParams, Error.ResponseError | E, Exclude<R, Scope.Scope>> = internal.urlParamsBody
172
-
173
- /**
174
- * @since 1.0.0
175
- * @category schema
176
- */
177
- export const schemaJsonScoped: <
178
- R,
179
- I extends {
180
- readonly status?: number | undefined
181
- readonly headers?: Readonly<Record<string, string>> | undefined
182
- readonly body?: unknown
183
- },
184
- A
185
- >(
186
- schema: Schema.Schema<A, I, R>,
187
- options?: ParseOptions | undefined
188
- ) => <E, R2>(
189
- effect: Effect.Effect<HttpClientResponse, E, R2>
190
- ) => Effect.Effect<
191
- A,
192
- E | Error.ResponseError | ParseResult.ParseError,
193
- Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>
194
- > = internal.schemaJsonScoped
195
-
196
- /**
197
- * @since 1.0.0
198
- * @category schema
199
- */
200
- export const schemaNoBodyScoped: <
201
- R,
202
- I extends {
203
- readonly status?: number | undefined
204
- readonly headers?: Readonly<Record<string, string>> | undefined
205
- },
206
- A
207
- >(
208
- schema: Schema.Schema<A, I, R>,
209
- options?: ParseOptions | undefined
210
- ) => <E, R2>(
211
- effect: Effect.Effect<HttpClientResponse, E, R2>
212
- ) => Effect.Effect<A, E | ParseResult.ParseError, Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>> =
213
- internal.schemaNoBodyScoped
214
-
215
107
  /**
216
108
  * @since 1.0.0
217
109
  * @category pattern matching
@@ -226,7 +118,7 @@ export const matchStatus: {
226
118
  readonly "5xx"?: (_: HttpClientResponse) => any
227
119
  readonly orElse: (_: HttpClientResponse) => any
228
120
  }
229
- >(cases: Cases): (self: HttpClientResponse) => Cases[keyof Cases] extends (_: any) => infer R ? R : never
121
+ >(cases: Cases): (self: HttpClientResponse) => Cases[keyof Cases] extends (_: any) => infer R ? Unify<R> : never
230
122
  <
231
123
  const Cases extends {
232
124
  readonly [status: number]: (_: HttpClientResponse) => any
@@ -236,55 +128,5 @@ export const matchStatus: {
236
128
  readonly "5xx"?: (_: HttpClientResponse) => any
237
129
  readonly orElse: (_: HttpClientResponse) => any
238
130
  }
239
- >(self: HttpClientResponse, cases: Cases): Cases[keyof Cases] extends (_: any) => infer R ? R : never
131
+ >(self: HttpClientResponse, cases: Cases): Cases[keyof Cases] extends (_: any) => infer R ? Unify<R> : never
240
132
  } = internal.matchStatus
241
-
242
- /**
243
- * @since 1.0.0
244
- * @category pattern matching
245
- */
246
- export const matchStatusScoped: {
247
- <
248
- const Cases extends {
249
- readonly [status: number]: (_: HttpClientResponse) => Effect.Effect<any, any, any>
250
- readonly "2xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
251
- readonly "3xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
252
- readonly "4xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
253
- readonly "5xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
254
- readonly orElse: (_: HttpClientResponse) => Effect.Effect<any, any, any>
255
- }
256
- >(
257
- cases: Cases
258
- ): <E, R>(
259
- self: Effect.Effect<HttpClientResponse, E, R>
260
- ) => Effect.Effect<
261
- Cases[keyof Cases] extends (_: any) => Effect.Effect<infer _A, infer _E, infer _R> ? _A : never,
262
- E | (Cases[keyof Cases] extends (_: any) => Effect.Effect<infer _A, infer _E, infer _R> ? _E : never),
263
- Exclude<
264
- R | (Cases[keyof Cases] extends (_: any) => Effect.Effect<infer _A, infer _E, infer _R> ? _R : never),
265
- Scope.Scope
266
- >
267
- >
268
- <
269
- E,
270
- R,
271
- const Cases extends {
272
- readonly [status: number]: (_: HttpClientResponse) => Effect.Effect<any, any, any>
273
- readonly "2xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
274
- readonly "3xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
275
- readonly "4xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
276
- readonly "5xx"?: (_: HttpClientResponse) => Effect.Effect<any, any, any>
277
- readonly orElse: (_: HttpClientResponse) => Effect.Effect<any, any, any>
278
- }
279
- >(
280
- self: Effect.Effect<HttpClientResponse, E, R>,
281
- cases: Cases
282
- ): Effect.Effect<
283
- Cases[keyof Cases] extends (_: any) => Effect.Effect<infer _A, infer _E, infer _R> ? _A : never,
284
- E | (Cases[keyof Cases] extends (_: any) => Effect.Effect<infer _A, infer _E, infer _R> ? _E : never),
285
- Exclude<
286
- R | (Cases[keyof Cases] extends (_: any) => Effect.Effect<infer _A, infer _E, infer _R> ? _R : never),
287
- Scope.Scope
288
- >
289
- >
290
- } = internal.matchStatusScoped
@@ -10,7 +10,6 @@ import { dual } from "effect/Function"
10
10
  import * as Global from "effect/GlobalValue"
11
11
  import type { Inspectable } from "effect/Inspectable"
12
12
  import * as Option from "effect/Option"
13
- import type * as Scope from "effect/Scope"
14
13
  import type * as Stream from "effect/Stream"
15
14
  import * as FileSystem from "./FileSystem.js"
16
15
  import type * as Headers from "./Headers.js"
@@ -53,18 +52,6 @@ export const schemaBodyJson = <A, I, R>(schema: Schema.Schema<A, I, R>, options?
53
52
  Effect.flatMap(self.json, parse)
54
53
  }
55
54
 
56
- /**
57
- * @since 1.0.0
58
- * @category schema
59
- */
60
- export const schemaBodyJsonScoped = <A, I, R>(schema: Schema.Schema<A, I, R>, options?: ParseOptions | undefined) => {
61
- const decode = schemaBodyJson(schema, options)
62
- return <E, E2, R2>(
63
- effect: Effect.Effect<HttpIncomingMessage<E>, E2, R2>
64
- ): Effect.Effect<A, ParseResult.ParseError | E | E2, Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>> =>
65
- Effect.scoped(Effect.flatMap(effect, decode))
66
- }
67
-
68
55
  /**
69
56
  * @since 1.0.0
70
57
  * @category schema
@@ -78,21 +65,6 @@ export const schemaBodyUrlParams = <A, I extends Readonly<Record<string, string
78
65
  Effect.flatMap(self.urlParamsBody, (_) => parse(Object.fromEntries(_)))
79
66
  }
80
67
 
81
- /**
82
- * @since 1.0.0
83
- * @category schema
84
- */
85
- export const schemaBodyUrlParamsScoped = <A, I extends Readonly<Record<string, string | undefined>>, R>(
86
- schema: Schema.Schema<A, I, R>,
87
- options?: ParseOptions | undefined
88
- ) => {
89
- const decode = schemaBodyUrlParams(schema, options)
90
- return <E, E2, R2>(
91
- effect: Effect.Effect<HttpIncomingMessage<E>, E2, R2>
92
- ): Effect.Effect<A, ParseResult.ParseError | E | E2, Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>> =>
93
- Effect.scoped(Effect.flatMap(effect, decode))
94
- }
95
-
96
68
  /**
97
69
  * @since 1.0.0
98
70
  * @category schema
@@ -105,21 +77,6 @@ export const schemaHeaders = <A, I extends Readonly<Record<string, string | unde
105
77
  return <E>(self: HttpIncomingMessage<E>): Effect.Effect<A, ParseResult.ParseError, R> => parse(self.headers)
106
78
  }
107
79
 
108
- /**
109
- * @since 1.0.0
110
- * @category schema
111
- */
112
- export const schemaHeadersScoped = <A, I extends Readonly<Record<string, string | undefined>>, R>(
113
- schema: Schema.Schema<A, I, R>,
114
- options?: ParseOptions | undefined
115
- ) => {
116
- const decode = schemaHeaders(schema, options)
117
- return <E, E2, R2>(
118
- effect: Effect.Effect<HttpIncomingMessage<E>, E2, R2>
119
- ): Effect.Effect<A, ParseResult.ParseError | E2, Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>> =>
120
- Effect.scoped(Effect.flatMap(effect, decode))
121
- }
122
-
123
80
  /**
124
81
  * @since 1.0.0
125
82
  * @category fiber refs