@effect/platform 0.11.0 → 0.11.2

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