@effect/platform 0.10.4 → 0.11.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.
Files changed (125) hide show
  1. package/Effectify.d.ts.map +1 -1
  2. package/Http/Body.d.ts +129 -0
  3. package/Http/Body.d.ts.map +1 -0
  4. package/Http/Body.js +70 -0
  5. package/Http/Body.js.map +1 -0
  6. package/Http/Client.d.ts +213 -0
  7. package/Http/Client.d.ts.map +1 -0
  8. package/Http/Client.js +124 -0
  9. package/Http/Client.js.map +1 -0
  10. package/Http/ClientError.d.ts +70 -0
  11. package/Http/ClientError.d.ts.map +1 -0
  12. package/Http/ClientError.js +28 -0
  13. package/Http/ClientError.js.map +1 -0
  14. package/Http/ClientRequest.d.ts +317 -0
  15. package/Http/ClientRequest.d.ts.map +1 -0
  16. package/Http/ClientRequest.js +202 -0
  17. package/Http/ClientRequest.js.map +1 -0
  18. package/Http/ClientResponse.d.ts +36 -0
  19. package/Http/ClientResponse.d.ts.map +1 -0
  20. package/Http/ClientResponse.js +29 -0
  21. package/Http/ClientResponse.js.map +1 -0
  22. package/Http/FormData.d.ts +56 -0
  23. package/Http/FormData.d.ts.map +1 -0
  24. package/Http/FormData.js +13 -0
  25. package/Http/FormData.js.map +1 -0
  26. package/Http/Headers.d.ts +38 -0
  27. package/Http/Headers.d.ts.map +1 -0
  28. package/Http/Headers.js +54 -0
  29. package/Http/Headers.js.map +1 -0
  30. package/Http/IncomingMessage.d.ts +37 -0
  31. package/Http/IncomingMessage.d.ts.map +1 -0
  32. package/Http/IncomingMessage.js +30 -0
  33. package/Http/IncomingMessage.js.map +1 -0
  34. package/Http/Method.d.ts +10 -0
  35. package/Http/Method.d.ts.map +1 -0
  36. package/Http/Method.js +12 -0
  37. package/Http/Method.js.map +1 -0
  38. package/Http/UrlParams.d.ts +56 -0
  39. package/Http/UrlParams.d.ts.map +1 -0
  40. package/Http/UrlParams.js +74 -0
  41. package/Http/UrlParams.js.map +1 -0
  42. package/HttpClient.d.ts +32 -0
  43. package/HttpClient.d.ts.map +1 -0
  44. package/HttpClient.js +23 -0
  45. package/HttpClient.js.map +1 -0
  46. package/README.md +3 -0
  47. package/internal/console.js.map +1 -1
  48. package/internal/effectify.js.map +1 -1
  49. package/internal/error.js.map +1 -1
  50. package/internal/http/body.d.ts +2 -0
  51. package/internal/http/body.d.ts.map +1 -0
  52. package/internal/http/body.js +101 -0
  53. package/internal/http/body.js.map +1 -0
  54. package/internal/http/client.d.ts +3 -0
  55. package/internal/http/client.d.ts.map +1 -0
  56. package/internal/http/client.js +147 -0
  57. package/internal/http/client.js.map +1 -0
  58. package/internal/http/clientError.d.ts +2 -0
  59. package/internal/http/clientError.d.ts.map +1 -0
  60. package/internal/http/clientError.js +24 -0
  61. package/internal/http/clientError.js.map +1 -0
  62. package/internal/http/clientRequest.d.ts +2 -0
  63. package/internal/http/clientRequest.d.ts.map +1 -0
  64. package/internal/http/clientRequest.js +180 -0
  65. package/internal/http/clientRequest.js.map +1 -0
  66. package/internal/http/clientResponse.d.ts +2 -0
  67. package/internal/http/clientResponse.d.ts.map +1 -0
  68. package/internal/http/clientResponse.js +101 -0
  69. package/internal/http/clientResponse.js.map +1 -0
  70. package/mjs/Http/Body.mjs +52 -0
  71. package/mjs/Http/Body.mjs.map +1 -0
  72. package/mjs/Http/Client.mjs +97 -0
  73. package/mjs/Http/Client.mjs.map +1 -0
  74. package/mjs/Http/ClientError.mjs +17 -0
  75. package/mjs/Http/ClientError.mjs.map +1 -0
  76. package/mjs/Http/ClientRequest.mjs +162 -0
  77. package/mjs/Http/ClientRequest.mjs.map +1 -0
  78. package/mjs/Http/ClientResponse.mjs +18 -0
  79. package/mjs/Http/ClientResponse.mjs.map +1 -0
  80. package/mjs/Http/FormData.mjs +6 -0
  81. package/mjs/Http/FormData.mjs.map +1 -0
  82. package/mjs/Http/Headers.mjs +40 -0
  83. package/mjs/Http/Headers.mjs.map +1 -0
  84. package/mjs/Http/IncomingMessage.mjs +19 -0
  85. package/mjs/Http/IncomingMessage.mjs.map +1 -0
  86. package/mjs/Http/Method.mjs +5 -0
  87. package/mjs/Http/Method.mjs.map +1 -0
  88. package/mjs/Http/UrlParams.mjs +57 -0
  89. package/mjs/Http/UrlParams.mjs.map +1 -0
  90. package/mjs/HttpClient.mjs +18 -0
  91. package/mjs/HttpClient.mjs.map +1 -0
  92. package/mjs/internal/console.mjs.map +1 -1
  93. package/mjs/internal/effectify.mjs.map +1 -1
  94. package/mjs/internal/error.mjs.map +1 -1
  95. package/mjs/internal/http/body.mjs +83 -0
  96. package/mjs/internal/http/body.mjs.map +1 -0
  97. package/mjs/internal/http/client.mjs +120 -0
  98. package/mjs/internal/http/client.mjs.map +1 -0
  99. package/mjs/internal/http/clientError.mjs +13 -0
  100. package/mjs/internal/http/clientError.mjs.map +1 -0
  101. package/mjs/internal/http/clientRequest.mjs +138 -0
  102. package/mjs/internal/http/clientRequest.mjs.map +1 -0
  103. package/mjs/internal/http/clientResponse.mjs +91 -0
  104. package/mjs/internal/http/clientResponse.mjs.map +1 -0
  105. package/package.json +13 -8
  106. package/src/Effectify.ts +65 -65
  107. package/src/Http/Body.ts +148 -0
  108. package/src/Http/Client.ts +280 -0
  109. package/src/Http/ClientError.ts +80 -0
  110. package/src/Http/ClientRequest.ts +383 -0
  111. package/src/Http/ClientResponse.ts +42 -0
  112. package/src/Http/FormData.ts +61 -0
  113. package/src/Http/Headers.ts +69 -0
  114. package/src/Http/IncomingMessage.ts +45 -0
  115. package/src/Http/Method.ts +17 -0
  116. package/src/Http/UrlParams.ts +106 -0
  117. package/src/HttpClient.ts +32 -0
  118. package/src/internal/console.ts +6 -6
  119. package/src/internal/effectify.ts +14 -14
  120. package/src/internal/error.ts +2 -2
  121. package/src/internal/http/body.ts +113 -0
  122. package/src/internal/http/client.ts +437 -0
  123. package/src/internal/http/clientError.ts +20 -0
  124. package/src/internal/http/clientRequest.ts +390 -0
  125. package/src/internal/http/clientResponse.ts +114 -0
@@ -0,0 +1,383 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type { Pipeable } from "@effect/data/Pipeable"
5
+ import type * as Body from "@effect/platform/Http/Body"
6
+ import type * as Error from "@effect/platform/Http/ClientError"
7
+ import type * as Headers from "@effect/platform/Http/Headers"
8
+ import type { Method } from "@effect/platform/Http/Method"
9
+ import type * as UrlParams from "@effect/platform/Http/UrlParams"
10
+ import * as internal from "@effect/platform/internal/http/clientRequest"
11
+ import type * as Schema from "@effect/schema/Schema"
12
+ import type * as Stream from "@effect/stream/Stream"
13
+
14
+ /**
15
+ * @since 1.0.0
16
+ * @category type ids
17
+ */
18
+ export const TypeId = Symbol.for("@effect/platform/Http/ClientRequest")
19
+
20
+ /**
21
+ * @since 1.0.0
22
+ * @category type ids
23
+ */
24
+ export type TypeId = typeof TypeId
25
+
26
+ /**
27
+ * @since 1.0.0
28
+ * @category models
29
+ */
30
+ export interface ClientRequest extends Pipeable {
31
+ readonly [TypeId]: TypeId
32
+ readonly method: Method
33
+ readonly url: string
34
+ readonly urlParams: UrlParams.UrlParams
35
+ readonly headers: Headers.Headers
36
+ readonly body: Body.Body
37
+ }
38
+
39
+ /**
40
+ * @since 1.0.0
41
+ * @category constructors
42
+ */
43
+ export const make: (
44
+ method: Method
45
+ ) => (
46
+ url: string,
47
+ options?: {
48
+ readonly url?: string
49
+ readonly urlParams?: UrlParams.Input
50
+ readonly headers?: Headers.Input
51
+ readonly body?: Body.Body
52
+ readonly accept?: string
53
+ readonly acceptJson?: boolean
54
+ }
55
+ ) => ClientRequest = internal.make
56
+
57
+ /**
58
+ * @since 1.0.0
59
+ * @category constructors
60
+ */
61
+ export const get: (
62
+ url: string,
63
+ options?: {
64
+ readonly url?: string
65
+ readonly urlParams?: UrlParams.Input
66
+ readonly headers?: Headers.Input
67
+ readonly accept?: string
68
+ readonly acceptJson?: boolean
69
+ }
70
+ ) => ClientRequest = internal.get
71
+
72
+ /**
73
+ * @since 1.0.0
74
+ * @category constructors
75
+ */
76
+ export const post: (
77
+ url: string,
78
+ options?: {
79
+ readonly url?: string
80
+ readonly urlParams?: UrlParams.Input
81
+ readonly headers?: Headers.Input
82
+ readonly body?: Body.Body
83
+ readonly accept?: string
84
+ readonly acceptJson?: boolean
85
+ }
86
+ ) => ClientRequest = internal.post
87
+
88
+ /**
89
+ * @since 1.0.0
90
+ * @category constructors
91
+ */
92
+ export const patch: (
93
+ url: string,
94
+ options?: {
95
+ readonly url?: string
96
+ readonly urlParams?: UrlParams.Input
97
+ readonly headers?: Headers.Input
98
+ readonly body?: Body.Body
99
+ readonly accept?: string
100
+ readonly acceptJson?: boolean
101
+ }
102
+ ) => ClientRequest = internal.patch
103
+
104
+ /**
105
+ * @since 1.0.0
106
+ * @category constructors
107
+ */
108
+ export const put: (
109
+ url: string,
110
+ options?: {
111
+ readonly url?: string
112
+ readonly urlParams?: UrlParams.Input
113
+ readonly headers?: Headers.Input
114
+ readonly body?: Body.Body
115
+ readonly accept?: string
116
+ readonly acceptJson?: boolean
117
+ }
118
+ ) => ClientRequest = internal.put
119
+
120
+ /**
121
+ * @since 1.0.0
122
+ * @category constructors
123
+ */
124
+ export const del: (
125
+ url: string,
126
+ options?: {
127
+ readonly url?: string
128
+ readonly urlParams?: UrlParams.Input
129
+ readonly headers?: Headers.Input
130
+ readonly accept?: string
131
+ readonly acceptJson?: boolean
132
+ }
133
+ ) => ClientRequest = internal.del
134
+
135
+ /**
136
+ * @since 1.0.0
137
+ * @category constructors
138
+ */
139
+ export const head: (
140
+ url: string,
141
+ options?: {
142
+ readonly url?: string
143
+ readonly urlParams?: UrlParams.Input
144
+ readonly headers?: Headers.Input
145
+ readonly accept?: string
146
+ readonly acceptJson?: boolean
147
+ }
148
+ ) => ClientRequest = internal.head
149
+
150
+ /**
151
+ * @since 1.0.0
152
+ * @category constructors
153
+ */
154
+ export const options: (
155
+ url: string,
156
+ options?: {
157
+ readonly url?: string
158
+ readonly urlParams?: UrlParams.Input
159
+ readonly headers?: Headers.Input
160
+ readonly accept?: string
161
+ readonly acceptJson?: boolean
162
+ }
163
+ ) => ClientRequest = internal.options
164
+
165
+ /**
166
+ * @since 1.0.0
167
+ * @category combinators
168
+ */
169
+ export const modify: {
170
+ (
171
+ options: {
172
+ readonly method?: Method
173
+ readonly url?: string
174
+ readonly urlParams?: UrlParams.Input
175
+ readonly headers?: Headers.Input
176
+ readonly body?: Body.Body
177
+ readonly accept?: string
178
+ readonly acceptJson?: boolean
179
+ }
180
+ ): (self: ClientRequest) => ClientRequest
181
+ (
182
+ self: ClientRequest,
183
+ options: {
184
+ readonly method?: Method
185
+ readonly url?: string
186
+ readonly urlParams?: UrlParams.Input
187
+ readonly headers?: Headers.Input
188
+ readonly body?: Body.Body
189
+ readonly accept?: string
190
+ readonly acceptJson?: boolean
191
+ }
192
+ ): ClientRequest
193
+ } = internal.modify
194
+
195
+ /**
196
+ * @since 1.0.0
197
+ * @category combinators
198
+ */
199
+ export const setMethod: {
200
+ (method: Method): (self: ClientRequest) => ClientRequest
201
+ (self: ClientRequest, method: Method): ClientRequest
202
+ } = internal.setMethod
203
+
204
+ /**
205
+ * @since 1.0.0
206
+ * @category combinators
207
+ */
208
+ export const setHeader: {
209
+ (key: string, value: string): (self: ClientRequest) => ClientRequest
210
+ (self: ClientRequest, key: string, value: string): ClientRequest
211
+ } = internal.setHeader
212
+
213
+ /**
214
+ * @since 1.0.0
215
+ * @category combinators
216
+ */
217
+ export const setHeaders: {
218
+ (input: Headers.Input): (self: ClientRequest) => ClientRequest
219
+ (self: ClientRequest, input: Headers.Input): ClientRequest
220
+ } = internal.setHeaders
221
+
222
+ /**
223
+ * @since 1.0.0
224
+ * @category combinators
225
+ */
226
+ export const basicAuth: {
227
+ (username: string, password: string): (self: ClientRequest) => ClientRequest
228
+ (self: ClientRequest, username: string, password: string): ClientRequest
229
+ } = internal.basicAuth
230
+
231
+ /**
232
+ * @since 1.0.0
233
+ * @category combinators
234
+ */
235
+ export const accept: {
236
+ (mediaType: string): (self: ClientRequest) => ClientRequest
237
+ (self: ClientRequest, mediaType: string): ClientRequest
238
+ } = internal.accept
239
+
240
+ /**
241
+ * @since 1.0.0
242
+ * @category combinators
243
+ */
244
+ export const acceptJson: (self: ClientRequest) => ClientRequest = internal.acceptJson
245
+
246
+ /**
247
+ * @since 1.0.0
248
+ * @category combinators
249
+ */
250
+ export const setUrl: {
251
+ (url: string): (self: ClientRequest) => ClientRequest
252
+ (self: ClientRequest, url: string): ClientRequest
253
+ } = internal.setUrl
254
+
255
+ /**
256
+ * @since 1.0.0
257
+ * @category combinators
258
+ */
259
+ export const prependUrl: {
260
+ (path: string): (self: ClientRequest) => ClientRequest
261
+ (self: ClientRequest, path: string): ClientRequest
262
+ } = internal.prependUrl
263
+
264
+ /**
265
+ * @since 1.0.0
266
+ * @category combinators
267
+ */
268
+ export const appendUrl: {
269
+ (path: string): (self: ClientRequest) => ClientRequest
270
+ (self: ClientRequest, path: string): ClientRequest
271
+ } = internal.appendUrl
272
+
273
+ /**
274
+ * @since 1.0.0
275
+ * @category combinators
276
+ */
277
+ export const updateUrl: {
278
+ (f: (url: string) => string): (self: ClientRequest) => ClientRequest
279
+ (self: ClientRequest, f: (url: string) => string): ClientRequest
280
+ } = internal.updateUrl
281
+
282
+ /**
283
+ * @since 1.0.0
284
+ * @category combinators
285
+ */
286
+ export const setUrlParam = internal.setUrlParam
287
+
288
+ /**
289
+ * @since 1.0.0
290
+ * @category combinators
291
+ */
292
+ export const setUrlParams = internal.setUrlParams
293
+
294
+ /**
295
+ * @since 1.0.0
296
+ * @category combinators
297
+ */
298
+ export const appendUrlParam = internal.appendUrlParam
299
+
300
+ /**
301
+ * @since 1.0.0
302
+ * @category combinators
303
+ */
304
+ export const appendUrlParams = internal.appendUrlParams
305
+
306
+ /**
307
+ * @since 1.0.0
308
+ * @category combinators
309
+ */
310
+ export const setBody: {
311
+ (body: Body.Body): (self: ClientRequest) => ClientRequest
312
+ (self: ClientRequest, body: Body.Body): ClientRequest
313
+ } = internal.setBody
314
+
315
+ /**
316
+ * @since 1.0.0
317
+ * @category combinators
318
+ */
319
+ export const binaryBody: {
320
+ (body: Uint8Array, contentType?: string): (self: ClientRequest) => ClientRequest
321
+ (self: ClientRequest, body: Uint8Array, contentType?: string): ClientRequest
322
+ } = internal.binaryBody
323
+
324
+ /**
325
+ * @since 1.0.0
326
+ * @category combinators
327
+ */
328
+ export const textBody: {
329
+ (body: string, contentType?: string): (self: ClientRequest) => ClientRequest
330
+ (self: ClientRequest, body: string, contentType?: string): ClientRequest
331
+ } = internal.textBody
332
+
333
+ /**
334
+ * @since 1.0.0
335
+ * @category combinators
336
+ */
337
+ export const jsonBody: {
338
+ (body: unknown): (self: ClientRequest) => ClientRequest
339
+ (self: ClientRequest, body: string): ClientRequest
340
+ } = internal.jsonBody
341
+
342
+ /**
343
+ * @since 1.0.0
344
+ * @category combinators
345
+ */
346
+ export const schemaBody: <I, A>(schema: Schema.Schema<I, A>) => {
347
+ (body: A): (self: ClientRequest) => ClientRequest
348
+ (self: ClientRequest, body: A): ClientRequest
349
+ } = internal.schemaBody
350
+
351
+ /**
352
+ * @since 1.0.0
353
+ * @category combinators
354
+ */
355
+ export const urlParamsBody: {
356
+ (input: UrlParams.Input): (self: ClientRequest) => ClientRequest
357
+ (self: ClientRequest, input: UrlParams.Input): ClientRequest
358
+ } = internal.urlParamsBody
359
+
360
+ /**
361
+ * @since 1.0.0
362
+ * @category combinators
363
+ */
364
+ export const formDataBody: {
365
+ (body: FormData): (self: ClientRequest) => ClientRequest
366
+ (self: ClientRequest, body: FormData): ClientRequest
367
+ } = internal.formDataBody
368
+
369
+ /**
370
+ * @since 1.0.0
371
+ * @category combinators
372
+ */
373
+ export const streamBody: {
374
+ (
375
+ body: Stream.Stream<never, Error.RequestError, Uint8Array>,
376
+ options?: { readonly contentType?: string; readonly contentLength?: number }
377
+ ): (self: ClientRequest) => ClientRequest
378
+ (
379
+ self: ClientRequest,
380
+ body: Stream.Stream<never, Error.RequestError, Uint8Array>,
381
+ options?: { readonly contentType?: string; readonly contentLength?: number }
382
+ ): ClientRequest
383
+ } = internal.streamBody
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as Error from "@effect/platform/Http/ClientError"
5
+ import type * as ClientRequest from "@effect/platform/Http/ClientRequest"
6
+ import type * as IncomingMessage from "@effect/platform/Http/IncomingMessage"
7
+ import * as internal from "@effect/platform/internal/http/clientResponse"
8
+
9
+ export {
10
+ /**
11
+ * @since 1.0.0
12
+ * @category schema
13
+ */
14
+ parseSchema
15
+ } from "@effect/platform/Http/IncomingMessage"
16
+
17
+ /**
18
+ * @since 1.0.0
19
+ * @category type ids
20
+ */
21
+ export const TypeId: unique symbol = internal.TypeId
22
+
23
+ /**
24
+ * @since 1.0.0
25
+ * @category type ids
26
+ */
27
+ export type TypeId = typeof TypeId
28
+
29
+ /**
30
+ * @since 1.0.0
31
+ * @category models
32
+ */
33
+ export interface ClientResponse extends IncomingMessage.IncomingMessage<Error.ResponseError> {
34
+ readonly [TypeId]: TypeId
35
+ readonly status: number
36
+ }
37
+
38
+ /**
39
+ * @since 1.0.0
40
+ * @category constructors
41
+ */
42
+ export const fromWeb: (request: ClientRequest.ClientRequest, source: Response) => ClientResponse = internal.fromWeb
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as Error from "@effect/platform/Http/ClientError"
5
+ import type * as Stream from "@effect/stream/Stream"
6
+
7
+ /**
8
+ * @since 1.0.0
9
+ * @category type ids
10
+ */
11
+ export const TypeId = Symbol.for("@effect/platform/Http/FormData")
12
+
13
+ /**
14
+ * @since 1.0.0
15
+ * @category type ids
16
+ */
17
+ export type TypeId = typeof TypeId
18
+
19
+ /**
20
+ * @since 1.0.0
21
+ * @category models
22
+ */
23
+ export type Part = Field | File
24
+
25
+ /**
26
+ * @since 1.0.0
27
+ */
28
+ export namespace Part {
29
+ /**
30
+ * @since 1.0.0
31
+ * @category models
32
+ */
33
+ export interface Proto {
34
+ readonly [TypeId]: TypeId
35
+ readonly _tag: string
36
+ }
37
+ }
38
+
39
+ /**
40
+ * @since 1.0.0
41
+ * @category models
42
+ */
43
+ export interface Field extends Part.Proto {
44
+ readonly _tag: "FormDataField"
45
+ readonly key: string
46
+ readonly contentType: string
47
+ readonly value: string
48
+ }
49
+
50
+ /**
51
+ * @since 1.0.0
52
+ * @category models
53
+ */
54
+ export interface File extends Part.Proto {
55
+ readonly _tag: "File"
56
+ readonly key: string
57
+ readonly name: string
58
+ readonly contentType: string
59
+ readonly content: Stream.Stream<never, Error.RequestError, Uint8Array>
60
+ readonly source?: unknown
61
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import { dual } from "@effect/data/Function"
5
+ import * as HashMap from "@effect/data/HashMap"
6
+
7
+ /**
8
+ * @since 1.0.0
9
+ * @category models
10
+ */
11
+ export interface Headers extends HashMap.HashMap<string, string> {}
12
+
13
+ /**
14
+ * @since 1.0.0
15
+ * @category models
16
+ */
17
+ export type Input = Headers | Readonly<Record<string, string>> | Iterable<readonly [string, string]>
18
+
19
+ /**
20
+ * @since 1.0.0
21
+ * @category constructors
22
+ */
23
+ export const empty: Headers = HashMap.empty()
24
+
25
+ /**
26
+ * @since 1.0.0
27
+ * @category constructors
28
+ */
29
+ export const fromInput: (input?: Input) => Headers = (input) => {
30
+ if (input === undefined) {
31
+ return empty
32
+ } else if (HashMap.isHashMap(input)) {
33
+ return input
34
+ } else if (Symbol.iterator in input) {
35
+ return HashMap.fromIterable([...input].map(([k, v]) => [k.toLowerCase(), v])) as Headers
36
+ }
37
+ return HashMap.fromIterable(Object.entries(input).map(([k, v]) => [k.toLowerCase(), v]))
38
+ }
39
+
40
+ /**
41
+ * @since 1.0.0
42
+ * @category combinators
43
+ */
44
+ export const set = dual<
45
+ (key: string, value: string) => (self: Headers) => Headers,
46
+ (self: Headers, key: string, value: string) => Headers
47
+ >(3, (self, key, value) => HashMap.set(self, key.toLowerCase(), value))
48
+
49
+ /**
50
+ * @since 1.0.0
51
+ * @category combinators
52
+ */
53
+ export const setAll = dual<
54
+ (headers: Input) => (self: Headers) => Headers,
55
+ (self: Headers, headers: Input) => Headers
56
+ >(2, (self, headers) =>
57
+ HashMap.union(
58
+ self,
59
+ fromInput(headers)
60
+ ))
61
+
62
+ /**
63
+ * @since 1.0.0
64
+ * @category combinators
65
+ */
66
+ export const remove = dual<
67
+ (key: string) => (self: Headers) => Headers,
68
+ (self: Headers, key: string) => Headers
69
+ >(2, (self, key) => HashMap.remove(self, key.toLowerCase()))
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Effect from "@effect/io/Effect"
5
+ import type * as Headers from "@effect/platform/Http/Headers"
6
+ import type * as ParseResult from "@effect/schema/ParseResult"
7
+ import * as Schema from "@effect/schema/Schema"
8
+ import type * as Stream from "@effect/stream/Stream"
9
+
10
+ /**
11
+ * @since 1.0.0
12
+ * @category type ids
13
+ */
14
+ export const TypeId = Symbol.for("@effect/platform/Http/IncomingMessage")
15
+
16
+ /**
17
+ * @since 1.0.0
18
+ * @category type ids
19
+ */
20
+ export type TypeId = typeof TypeId
21
+
22
+ /**
23
+ * @since 1.0.0
24
+ * @category models
25
+ */
26
+ export interface IncomingMessage<E> {
27
+ readonly [TypeId]: TypeId
28
+ readonly headers: Headers.Headers
29
+ readonly json: Effect.Effect<never, E, unknown>
30
+ readonly text: Effect.Effect<never, E, string>
31
+ readonly blob: Effect.Effect<never, E, Blob>
32
+ readonly formData: Effect.Effect<never, E, FormData>
33
+ // readonly formDataStream: Stream.Stream<never, Error.TransportError, FormData.Part>
34
+ readonly stream: Stream.Stream<never, E, Uint8Array>
35
+ }
36
+
37
+ /**
38
+ * @since 1.0.0
39
+ * @category schema
40
+ */
41
+ export const parseSchema = <I, A>(schema: Schema.Schema<I, A>) => {
42
+ const parse = Schema.parse(schema)
43
+ return <E>(self: IncomingMessage<E>): Effect.Effect<never, E | ParseResult.ParseError, A> =>
44
+ Effect.flatMap(self.json, parse)
45
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @since 1.0.0
3
+ * @category models
4
+ */
5
+ export type Method =
6
+ | "GET"
7
+ | "POST"
8
+ | "PUT"
9
+ | "DELETE"
10
+ | "PATCH"
11
+ | "HEAD"
12
+ | "OPTIONS"
13
+
14
+ /**
15
+ * @since 1.0.0
16
+ */
17
+ export const hasBody = (method: Method): boolean => method !== "GET" && method !== "HEAD"