@effect/platform 0.64.1 → 0.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FetchHttpClient/package.json +6 -0
- package/README.md +173 -195
- package/dist/cjs/FetchHttpClient.js +32 -0
- package/dist/cjs/FetchHttpClient.js.map +1 -0
- package/dist/cjs/HttpApiClient.js +1 -1
- package/dist/cjs/HttpApiClient.js.map +1 -1
- package/dist/cjs/HttpClient.js +5 -36
- package/dist/cjs/HttpClient.js.map +1 -1
- package/dist/cjs/HttpClientRequest.js +11 -11
- package/dist/cjs/HttpClientRequest.js.map +1 -1
- package/dist/cjs/HttpClientResponse.js +2 -61
- package/dist/cjs/HttpClientResponse.js.map +1 -1
- package/dist/cjs/HttpIncomingMessage.js +2 -29
- package/dist/cjs/HttpIncomingMessage.js.map +1 -1
- package/dist/cjs/Runtime.js +1 -1
- package/dist/cjs/Runtime.js.map +1 -1
- package/dist/cjs/Socket.js +42 -53
- package/dist/cjs/Socket.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/internal/fetchHttpClient.js +52 -0
- package/dist/cjs/internal/fetchHttpClient.js.map +1 -0
- package/dist/cjs/internal/httpClient.js +82 -71
- package/dist/cjs/internal/httpClient.js.map +1 -1
- package/dist/cjs/internal/httpClientRequest.js +17 -15
- package/dist/cjs/internal/httpClientRequest.js.map +1 -1
- package/dist/cjs/internal/httpClientResponse.js +1 -33
- package/dist/cjs/internal/httpClientResponse.js.map +1 -1
- package/dist/cjs/internal/worker.js +21 -29
- package/dist/cjs/internal/worker.js.map +1 -1
- package/dist/dts/FetchHttpClient.d.ts +27 -0
- package/dist/dts/FetchHttpClient.d.ts.map +1 -0
- package/dist/dts/HttpApiClient.d.ts +2 -2
- package/dist/dts/HttpClient.d.ts +53 -61
- package/dist/dts/HttpClient.d.ts.map +1 -1
- package/dist/dts/HttpClientRequest.d.ts +16 -15
- package/dist/dts/HttpClientRequest.d.ts.map +1 -1
- package/dist/dts/HttpClientResponse.d.ts +4 -90
- package/dist/dts/HttpClientResponse.d.ts.map +1 -1
- package/dist/dts/HttpIncomingMessage.d.ts +0 -16
- package/dist/dts/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/dts/HttpServer.d.ts +1 -1
- package/dist/dts/Socket.d.ts +3 -3
- package/dist/dts/Socket.d.ts.map +1 -1
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/fetchHttpClient.d.ts +2 -0
- package/dist/dts/internal/fetchHttpClient.d.ts.map +1 -0
- package/dist/esm/FetchHttpClient.js +21 -0
- package/dist/esm/FetchHttpClient.js.map +1 -0
- package/dist/esm/HttpApiClient.js +1 -1
- package/dist/esm/HttpApiClient.js.map +1 -1
- package/dist/esm/HttpClient.js +4 -35
- package/dist/esm/HttpClient.js.map +1 -1
- package/dist/esm/HttpClientRequest.js +10 -10
- package/dist/esm/HttpClientRequest.js.map +1 -1
- package/dist/esm/HttpClientResponse.js +1 -63
- package/dist/esm/HttpClientResponse.js.map +1 -1
- package/dist/esm/HttpIncomingMessage.js +0 -24
- package/dist/esm/HttpIncomingMessage.js.map +1 -1
- package/dist/esm/Runtime.js +1 -1
- package/dist/esm/Runtime.js.map +1 -1
- package/dist/esm/Socket.js +42 -53
- package/dist/esm/Socket.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/fetchHttpClient.js +44 -0
- package/dist/esm/internal/fetchHttpClient.js.map +1 -0
- package/dist/esm/internal/httpClient.js +79 -69
- package/dist/esm/internal/httpClient.js.map +1 -1
- package/dist/esm/internal/httpClientRequest.js +15 -13
- package/dist/esm/internal/httpClientRequest.js.map +1 -1
- package/dist/esm/internal/httpClientResponse.js +0 -24
- package/dist/esm/internal/httpClientResponse.js.map +1 -1
- package/dist/esm/internal/worker.js +21 -29
- package/dist/esm/internal/worker.js.map +1 -1
- package/package.json +11 -3
- package/src/FetchHttpClient.ts +25 -0
- package/src/HttpApiClient.ts +5 -5
- package/src/HttpClient.ts +79 -85
- package/src/HttpClientRequest.ts +26 -25
- package/src/HttpClientResponse.ts +4 -162
- package/src/HttpIncomingMessage.ts +0 -43
- package/src/HttpServer.ts +1 -1
- package/src/Runtime.ts +1 -1
- package/src/Socket.ts +42 -58
- package/src/index.ts +5 -0
- package/src/internal/fetchHttpClient.ts +53 -0
- package/src/internal/httpClient.ts +149 -125
- package/src/internal/httpClientRequest.ts +33 -18
- package/src/internal/httpClientResponse.ts +6 -96
- 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
|
|
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
|
|
44
|
-
|
|
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
|
|
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
|
|
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.
|
|
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
|
-
|
|
205
|
-
orElse: (a: A) => Effect.Effect<B, E2, R2>
|
|
206
|
-
): <E, 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
|
-
|
|
194
|
+
predicate: Predicate.Predicate<A>,
|
|
210
195
|
orElse: (a: A) => Effect.Effect<B, E2, R2>
|
|
211
|
-
): HttpClient<A | B,
|
|
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
|
-
|
|
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
|
-
|
|
219
|
+
predicate: Predicate.Predicate<A>,
|
|
226
220
|
orFailWith: (a: A) => E2
|
|
227
|
-
): HttpClient<A,
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
356
|
+
} = internal.mapRequestInput
|
|
377
357
|
|
|
378
358
|
/**
|
|
379
359
|
* @since 1.0.0
|
|
380
360
|
* @category mapping & sequencing
|
|
381
361
|
*/
|
|
382
|
-
export const
|
|
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.
|
|
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
|
-
<
|
|
398
|
-
|
|
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
|
|
401
|
-
|
|
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
|
|
524
|
-
|
|
525
|
-
|
|
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
|
package/src/HttpClientRequest.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type * as Schema from "@effect/schema/Schema"
|
|
|
6
6
|
import type * as Effect from "effect/Effect"
|
|
7
7
|
import type { Inspectable } from "effect/Inspectable"
|
|
8
8
|
import type * as Option from "effect/Option"
|
|
9
|
+
import type { Redacted } from "effect/Redacted"
|
|
9
10
|
import type { Scope } from "effect/Scope"
|
|
10
11
|
import type * as Stream from "effect/Stream"
|
|
11
12
|
import type * as PlatformError from "./Error.js"
|
|
@@ -36,7 +37,7 @@ export type TypeId = typeof TypeId
|
|
|
36
37
|
* @category models
|
|
37
38
|
*/
|
|
38
39
|
export interface HttpClientRequest
|
|
39
|
-
extends Effect.Effect<HttpClientResponse, HttpClientError, HttpClient.
|
|
40
|
+
extends Effect.Effect<HttpClientResponse, HttpClientError, HttpClient.Service | Scope>, Inspectable
|
|
40
41
|
{
|
|
41
42
|
readonly [TypeId]: TypeId
|
|
42
43
|
readonly method: HttpMethod
|
|
@@ -173,8 +174,8 @@ export const setHeaders: {
|
|
|
173
174
|
* @category combinators
|
|
174
175
|
*/
|
|
175
176
|
export const basicAuth: {
|
|
176
|
-
(username: string, password: string): (self: HttpClientRequest) => HttpClientRequest
|
|
177
|
-
(self: HttpClientRequest, username: string, password: string): HttpClientRequest
|
|
177
|
+
(username: string | Redacted, password: string | Redacted): (self: HttpClientRequest) => HttpClientRequest
|
|
178
|
+
(self: HttpClientRequest, username: string | Redacted, password: string | Redacted): HttpClientRequest
|
|
178
179
|
} = internal.basicAuth
|
|
179
180
|
|
|
180
181
|
/**
|
|
@@ -182,8 +183,8 @@ export const basicAuth: {
|
|
|
182
183
|
* @category combinators
|
|
183
184
|
*/
|
|
184
185
|
export const bearerToken: {
|
|
185
|
-
(token: string): (self: HttpClientRequest) => HttpClientRequest
|
|
186
|
-
(self: HttpClientRequest, token: string): HttpClientRequest
|
|
186
|
+
(token: string | Redacted): (self: HttpClientRequest) => HttpClientRequest
|
|
187
|
+
(self: HttpClientRequest, token: string | Redacted): HttpClientRequest
|
|
187
188
|
} = internal.bearerToken
|
|
188
189
|
|
|
189
190
|
/**
|
|
@@ -301,73 +302,73 @@ export const setBody: {
|
|
|
301
302
|
* @since 1.0.0
|
|
302
303
|
* @category combinators
|
|
303
304
|
*/
|
|
304
|
-
export const
|
|
305
|
+
export const bodyUint8Array: {
|
|
305
306
|
(body: Uint8Array, contentType?: string): (self: HttpClientRequest) => HttpClientRequest
|
|
306
307
|
(self: HttpClientRequest, body: Uint8Array, contentType?: string): HttpClientRequest
|
|
307
|
-
} = internal.
|
|
308
|
+
} = internal.bodyUint8Array
|
|
308
309
|
|
|
309
310
|
/**
|
|
310
311
|
* @since 1.0.0
|
|
311
312
|
* @category combinators
|
|
312
313
|
*/
|
|
313
|
-
export const
|
|
314
|
+
export const bodyText: {
|
|
314
315
|
(body: string, contentType?: string): (self: HttpClientRequest) => HttpClientRequest
|
|
315
316
|
(self: HttpClientRequest, body: string, contentType?: string): HttpClientRequest
|
|
316
|
-
} = internal.
|
|
317
|
+
} = internal.bodyText
|
|
317
318
|
|
|
318
319
|
/**
|
|
319
320
|
* @since 1.0.0
|
|
320
321
|
* @category combinators
|
|
321
322
|
*/
|
|
322
|
-
export const
|
|
323
|
+
export const bodyJson: {
|
|
323
324
|
(body: unknown): (self: HttpClientRequest) => Effect.Effect<HttpClientRequest, Body.HttpBodyError>
|
|
324
325
|
(self: HttpClientRequest, body: unknown): Effect.Effect<HttpClientRequest, Body.HttpBodyError>
|
|
325
|
-
} = internal.
|
|
326
|
+
} = internal.bodyJson
|
|
326
327
|
|
|
327
328
|
/**
|
|
328
329
|
* @since 1.0.0
|
|
329
330
|
* @category combinators
|
|
330
331
|
*/
|
|
331
|
-
export const
|
|
332
|
+
export const bodyUnsafeJson: {
|
|
332
333
|
(body: unknown): (self: HttpClientRequest) => HttpClientRequest
|
|
333
334
|
(self: HttpClientRequest, body: unknown): HttpClientRequest
|
|
334
|
-
} = internal.
|
|
335
|
+
} = internal.bodyUnsafeJson
|
|
335
336
|
|
|
336
337
|
/**
|
|
337
338
|
* @since 1.0.0
|
|
338
339
|
* @category combinators
|
|
339
340
|
*/
|
|
340
|
-
export const
|
|
341
|
+
export const schemaBodyJson: <A, I, R>(
|
|
341
342
|
schema: Schema.Schema<A, I, R>,
|
|
342
343
|
options?: ParseOptions | undefined
|
|
343
344
|
) => {
|
|
344
345
|
(body: A): (self: HttpClientRequest) => Effect.Effect<HttpClientRequest, Body.HttpBodyError, R>
|
|
345
346
|
(self: HttpClientRequest, body: A): Effect.Effect<HttpClientRequest, Body.HttpBodyError, R>
|
|
346
|
-
} = internal.
|
|
347
|
+
} = internal.schemaBodyJson
|
|
347
348
|
|
|
348
349
|
/**
|
|
349
350
|
* @since 1.0.0
|
|
350
351
|
* @category combinators
|
|
351
352
|
*/
|
|
352
|
-
export const
|
|
353
|
+
export const bodyUrlParams: {
|
|
353
354
|
(input: UrlParams.Input): (self: HttpClientRequest) => HttpClientRequest
|
|
354
355
|
(self: HttpClientRequest, input: UrlParams.Input): HttpClientRequest
|
|
355
|
-
} = internal.
|
|
356
|
+
} = internal.bodyUrlParams
|
|
356
357
|
|
|
357
358
|
/**
|
|
358
359
|
* @since 1.0.0
|
|
359
360
|
* @category combinators
|
|
360
361
|
*/
|
|
361
|
-
export const
|
|
362
|
+
export const bodyFormData: {
|
|
362
363
|
(body: FormData): (self: HttpClientRequest) => HttpClientRequest
|
|
363
364
|
(self: HttpClientRequest, body: FormData): HttpClientRequest
|
|
364
|
-
} = internal.
|
|
365
|
+
} = internal.bodyFormData
|
|
365
366
|
|
|
366
367
|
/**
|
|
367
368
|
* @since 1.0.0
|
|
368
369
|
* @category combinators
|
|
369
370
|
*/
|
|
370
|
-
export const
|
|
371
|
+
export const bodyStream: {
|
|
371
372
|
(
|
|
372
373
|
body: Stream.Stream<Uint8Array, unknown>,
|
|
373
374
|
options?: { readonly contentType?: string | undefined; readonly contentLength?: number | undefined } | undefined
|
|
@@ -377,13 +378,13 @@ export const streamBody: {
|
|
|
377
378
|
body: Stream.Stream<Uint8Array, unknown>,
|
|
378
379
|
options?: { readonly contentType?: string | undefined; readonly contentLength?: number | undefined } | undefined
|
|
379
380
|
): HttpClientRequest
|
|
380
|
-
} = internal.
|
|
381
|
+
} = internal.bodyStream
|
|
381
382
|
|
|
382
383
|
/**
|
|
383
384
|
* @since 1.0.0
|
|
384
385
|
* @category combinators
|
|
385
386
|
*/
|
|
386
|
-
export const
|
|
387
|
+
export const bodyFile: {
|
|
387
388
|
(
|
|
388
389
|
path: string,
|
|
389
390
|
options?: FileSystem.StreamOptions & { readonly contentType?: string }
|
|
@@ -393,13 +394,13 @@ export const fileBody: {
|
|
|
393
394
|
path: string,
|
|
394
395
|
options?: FileSystem.StreamOptions & { readonly contentType?: string }
|
|
395
396
|
): Effect.Effect<HttpClientRequest, PlatformError.PlatformError, FileSystem.FileSystem>
|
|
396
|
-
} = internal.
|
|
397
|
+
} = internal.bodyFile
|
|
397
398
|
|
|
398
399
|
/**
|
|
399
400
|
* @since 1.0.0
|
|
400
401
|
* @category combinators
|
|
401
402
|
*/
|
|
402
|
-
export const
|
|
403
|
+
export const bodyFileWeb: {
|
|
403
404
|
(file: Body.HttpBody.FileLike): (self: HttpClientRequest) => HttpClientRequest
|
|
404
405
|
(self: HttpClientRequest, file: Body.HttpBody.FileLike): HttpClientRequest
|
|
405
|
-
} = internal.
|
|
406
|
+
} = 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
|
-
|
|
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
|