@effect/platform 0.48.29 → 0.49.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 (157) hide show
  1. package/README.md +12 -12
  2. package/dist/cjs/Http/App.js +9 -7
  3. package/dist/cjs/Http/App.js.map +1 -1
  4. package/dist/cjs/Http/Client.js +13 -3
  5. package/dist/cjs/Http/Client.js.map +1 -1
  6. package/dist/cjs/Http/ClientResponse.js +9 -9
  7. package/dist/cjs/Http/ClientResponse.js.map +1 -1
  8. package/dist/cjs/Http/Cookies.js +7 -7
  9. package/dist/cjs/Http/Cookies.js.map +1 -1
  10. package/dist/cjs/Http/Headers.js +7 -7
  11. package/dist/cjs/Http/Headers.js.map +1 -1
  12. package/dist/cjs/Http/IncomingMessage.js +7 -7
  13. package/dist/cjs/Http/IncomingMessage.js.map +1 -1
  14. package/dist/cjs/Http/Middleware.js +11 -1
  15. package/dist/cjs/Http/Middleware.js.map +1 -1
  16. package/dist/cjs/Http/Multiplex.js.map +1 -1
  17. package/dist/cjs/Http/Router.js.map +1 -1
  18. package/dist/cjs/Http/UrlParams.js +13 -13
  19. package/dist/cjs/Http/UrlParams.js.map +1 -1
  20. package/dist/cjs/PlatformConfigProvider.js +2 -2
  21. package/dist/cjs/PlatformConfigProvider.js.map +1 -1
  22. package/dist/cjs/Socket.js +6 -6
  23. package/dist/cjs/Socket.js.map +1 -1
  24. package/dist/cjs/Transferable.js +1 -1
  25. package/dist/cjs/Transferable.js.map +1 -1
  26. package/dist/cjs/WorkerRunner.js.map +1 -1
  27. package/dist/cjs/internal/command.js +1 -1
  28. package/dist/cjs/internal/command.js.map +1 -1
  29. package/dist/cjs/internal/fileSystem.js +2 -2
  30. package/dist/cjs/internal/fileSystem.js.map +1 -1
  31. package/dist/cjs/internal/http/client.js +19 -16
  32. package/dist/cjs/internal/http/client.js.map +1 -1
  33. package/dist/cjs/internal/http/clientResponse.js +5 -5
  34. package/dist/cjs/internal/http/clientResponse.js.map +1 -1
  35. package/dist/cjs/internal/http/middleware.js +8 -3
  36. package/dist/cjs/internal/http/middleware.js.map +1 -1
  37. package/dist/cjs/internal/http/multipart.js +4 -4
  38. package/dist/cjs/internal/http/multipart.js.map +1 -1
  39. package/dist/cjs/internal/http/multiplex.js +2 -2
  40. package/dist/cjs/internal/http/multiplex.js.map +1 -1
  41. package/dist/cjs/internal/http/router.js +2 -1
  42. package/dist/cjs/internal/http/router.js.map +1 -1
  43. package/dist/cjs/internal/worker.js +7 -7
  44. package/dist/cjs/internal/worker.js.map +1 -1
  45. package/dist/cjs/internal/workerRunner.js +14 -13
  46. package/dist/cjs/internal/workerRunner.js.map +1 -1
  47. package/dist/dts/Command.d.ts +3 -3
  48. package/dist/dts/Command.d.ts.map +1 -1
  49. package/dist/dts/Http/App.d.ts +7 -7
  50. package/dist/dts/Http/App.d.ts.map +1 -1
  51. package/dist/dts/Http/Client.d.ts +78 -65
  52. package/dist/dts/Http/Client.d.ts.map +1 -1
  53. package/dist/dts/Http/ClientResponse.d.ts +5 -5
  54. package/dist/dts/Http/Cookies.d.ts +3 -3
  55. package/dist/dts/Http/Cookies.d.ts.map +1 -1
  56. package/dist/dts/Http/Headers.d.ts +4 -4
  57. package/dist/dts/Http/Headers.d.ts.map +1 -1
  58. package/dist/dts/Http/IncomingMessage.d.ts +4 -3
  59. package/dist/dts/Http/IncomingMessage.d.ts.map +1 -1
  60. package/dist/dts/Http/Middleware.d.ts +22 -5
  61. package/dist/dts/Http/Middleware.d.ts.map +1 -1
  62. package/dist/dts/Http/Multiplex.d.ts +22 -22
  63. package/dist/dts/Http/Multiplex.d.ts.map +1 -1
  64. package/dist/dts/Http/Router.d.ts +80 -80
  65. package/dist/dts/Http/Router.d.ts.map +1 -1
  66. package/dist/dts/Http/Server.d.ts +11 -11
  67. package/dist/dts/Http/Server.d.ts.map +1 -1
  68. package/dist/dts/Http/ServerRequest.d.ts +1 -1
  69. package/dist/dts/Http/ServerRequest.d.ts.map +1 -1
  70. package/dist/dts/Http/TraceContext.d.ts.map +1 -1
  71. package/dist/dts/Http/UrlParams.d.ts.map +1 -1
  72. package/dist/dts/PlatformConfigProvider.d.ts.map +1 -1
  73. package/dist/dts/Socket.d.ts +10 -10
  74. package/dist/dts/Socket.d.ts.map +1 -1
  75. package/dist/dts/Transferable.d.ts.map +1 -1
  76. package/dist/dts/Worker.d.ts +6 -6
  77. package/dist/dts/Worker.d.ts.map +1 -1
  78. package/dist/dts/WorkerRunner.d.ts +5 -5
  79. package/dist/dts/WorkerRunner.d.ts.map +1 -1
  80. package/dist/dts/internal/http/router.d.ts +1 -1
  81. package/dist/dts/internal/http/router.d.ts.map +1 -1
  82. package/dist/esm/Http/App.js +9 -7
  83. package/dist/esm/Http/App.js.map +1 -1
  84. package/dist/esm/Http/Client.js +12 -2
  85. package/dist/esm/Http/Client.js.map +1 -1
  86. package/dist/esm/Http/ClientResponse.js +5 -5
  87. package/dist/esm/Http/ClientResponse.js.map +1 -1
  88. package/dist/esm/Http/Cookies.js +7 -7
  89. package/dist/esm/Http/Cookies.js.map +1 -1
  90. package/dist/esm/Http/Headers.js +7 -7
  91. package/dist/esm/Http/Headers.js.map +1 -1
  92. package/dist/esm/Http/IncomingMessage.js +3 -3
  93. package/dist/esm/Http/IncomingMessage.js.map +1 -1
  94. package/dist/esm/Http/Middleware.js +10 -0
  95. package/dist/esm/Http/Middleware.js.map +1 -1
  96. package/dist/esm/Http/Multiplex.js.map +1 -1
  97. package/dist/esm/Http/Router.js.map +1 -1
  98. package/dist/esm/Http/UrlParams.js +13 -13
  99. package/dist/esm/Http/UrlParams.js.map +1 -1
  100. package/dist/esm/PlatformConfigProvider.js +2 -2
  101. package/dist/esm/PlatformConfigProvider.js.map +1 -1
  102. package/dist/esm/Socket.js +6 -6
  103. package/dist/esm/Socket.js.map +1 -1
  104. package/dist/esm/Transferable.js +1 -1
  105. package/dist/esm/Transferable.js.map +1 -1
  106. package/dist/esm/WorkerRunner.js.map +1 -1
  107. package/dist/esm/internal/command.js +1 -1
  108. package/dist/esm/internal/command.js.map +1 -1
  109. package/dist/esm/internal/fileSystem.js +2 -2
  110. package/dist/esm/internal/fileSystem.js.map +1 -1
  111. package/dist/esm/internal/http/client.js +18 -13
  112. package/dist/esm/internal/http/client.js.map +1 -1
  113. package/dist/esm/internal/http/clientResponse.js +2 -2
  114. package/dist/esm/internal/http/clientResponse.js.map +1 -1
  115. package/dist/esm/internal/http/middleware.js +7 -2
  116. package/dist/esm/internal/http/middleware.js.map +1 -1
  117. package/dist/esm/internal/http/multipart.js +4 -4
  118. package/dist/esm/internal/http/multipart.js.map +1 -1
  119. package/dist/esm/internal/http/multiplex.js +2 -2
  120. package/dist/esm/internal/http/multiplex.js.map +1 -1
  121. package/dist/esm/internal/http/router.js +2 -1
  122. package/dist/esm/internal/http/router.js.map +1 -1
  123. package/dist/esm/internal/worker.js +7 -7
  124. package/dist/esm/internal/worker.js.map +1 -1
  125. package/dist/esm/internal/workerRunner.js +14 -13
  126. package/dist/esm/internal/workerRunner.js.map +1 -1
  127. package/package.json +3 -3
  128. package/src/Command.ts +3 -3
  129. package/src/Http/App.ts +21 -17
  130. package/src/Http/Client.ts +105 -90
  131. package/src/Http/ClientResponse.ts +7 -7
  132. package/src/Http/Cookies.ts +9 -9
  133. package/src/Http/Headers.ts +12 -12
  134. package/src/Http/IncomingMessage.ts +16 -6
  135. package/src/Http/Middleware.ts +30 -6
  136. package/src/Http/Multiplex.ts +38 -38
  137. package/src/Http/Router.ts +136 -134
  138. package/src/Http/Server.ts +16 -16
  139. package/src/Http/ServerRequest.ts +1 -1
  140. package/src/Http/UrlParams.ts +15 -15
  141. package/src/PlatformConfigProvider.ts +2 -2
  142. package/src/Socket.ts +6 -6
  143. package/src/Transferable.ts +1 -1
  144. package/src/Worker.ts +9 -9
  145. package/src/WorkerRunner.ts +5 -4
  146. package/src/internal/command.ts +12 -6
  147. package/src/internal/fileSystem.ts +2 -2
  148. package/src/internal/http/client.ts +221 -204
  149. package/src/internal/http/clientResponse.ts +2 -2
  150. package/src/internal/http/middleware.ts +24 -1
  151. package/src/internal/http/multipart.ts +4 -4
  152. package/src/internal/http/multiplex.ts +54 -54
  153. package/src/internal/http/router.ts +121 -104
  154. package/src/internal/http/server.ts +17 -17
  155. package/src/internal/http/serverRequest.ts +1 -1
  156. package/src/internal/worker.ts +14 -14
  157. package/src/internal/workerRunner.ts +20 -16
@@ -37,11 +37,11 @@ export type TypeId = typeof TypeId
37
37
  * @since 1.0.0
38
38
  * @category models
39
39
  */
40
- export interface Client<R, E, A> extends Pipeable, Inspectable {
40
+ export interface Client<A = ClientResponse.ClientResponse, E = never, R = never> extends Pipeable, Inspectable {
41
41
  (request: ClientRequest.ClientRequest): Effect.Effect<A, E, R>
42
42
  readonly [TypeId]: TypeId
43
- readonly preprocess: Client.Preprocess<R, E>
44
- readonly execute: Client.Execute<R, E, A>
43
+ readonly preprocess: Client.Preprocess<E, R>
44
+ readonly execute: Client.Execute<A, E, R>
45
45
  }
46
46
 
47
47
  /**
@@ -52,7 +52,7 @@ export declare namespace Client {
52
52
  * @since 1.0.0
53
53
  * @category models
54
54
  */
55
- export type Preprocess<R, E> = (
55
+ export type Preprocess<E, R> = (
56
56
  request: ClientRequest.ClientRequest
57
57
  ) => Effect.Effect<ClientRequest.ClientRequest, E, R>
58
58
 
@@ -60,7 +60,7 @@ export declare namespace Client {
60
60
  * @since 1.0.0
61
61
  * @category models
62
62
  */
63
- export type Execute<R, E, A> = (
63
+ export type Execute<A, E = never, R = never> = (
64
64
  request: Effect.Effect<ClientRequest.ClientRequest, E, R>
65
65
  ) => Effect.Effect<A, E, R>
66
66
 
@@ -68,13 +68,13 @@ export declare namespace Client {
68
68
  * @since 1.0.0
69
69
  * @category models
70
70
  */
71
- export type WithResponse<R, E> = Client<R, E, ClientResponse.ClientResponse>
71
+ export type WithResponse<E = never, R = never> = Client<ClientResponse.ClientResponse, E, R>
72
72
 
73
73
  /**
74
74
  * @since 1.0.0
75
75
  * @category models
76
76
  */
77
- export type Default = WithResponse<Scope.Scope, Error.HttpClientError>
77
+ export type Default = WithResponse<Error.HttpClientError, Scope.Scope>
78
78
  }
79
79
 
80
80
  /**
@@ -107,21 +107,21 @@ export const layer: Layer.Layer<Client.Default> = internal.layer
107
107
  * @since 1.0.0
108
108
  * @category constructors
109
109
  */
110
- export const fetch: (options?: RequestInit) => Client.Default = internal.fetch
110
+ export const fetch: Client.Default = internal.fetch
111
111
 
112
112
  /**
113
113
  * @since 1.0.0
114
114
  * @category constructors
115
115
  */
116
- export const fetchOk: (options?: RequestInit) => Client.Default = internal.fetchOk
116
+ export const fetchOk: Client.Default = internal.fetchOk
117
117
 
118
118
  /**
119
119
  * @since 1.0.0
120
120
  * @category error handling
121
121
  */
122
122
  export const catchAll: {
123
- <E, R2, E2, A2>(f: (e: E) => Effect.Effect<A2, E2, R2>): <R, A>(self: Client<R, E, A>) => Client<R2 | R, E2, A2 | A>
124
- <R, E, A, R2, E2, A2>(self: Client<R, E, A>, f: (e: E) => Effect.Effect<A2, E2, R2>): Client<R | R2, E2, A | A2>
123
+ <E, R2, E2, A2>(f: (e: E) => Effect.Effect<A2, E2, R2>): <A, R>(self: Client<A, E, R>) => Client<A2 | A, E2, R2 | R>
124
+ <A, E, R, R2, E2, A2>(self: Client<A, E, R>, f: (e: E) => Effect.Effect<A2, E2, R2>): Client<A | A2, E2, R | R2>
125
125
  } = internal.catchAll
126
126
 
127
127
  /**
@@ -132,12 +132,12 @@ export const catchTag: {
132
132
  <E extends { _tag: string }, K extends E["_tag"] & string, R1, E1, A1>(
133
133
  tag: K,
134
134
  f: (e: Extract<E, { _tag: K }>) => Effect.Effect<A1, E1, R1>
135
- ): <R, A>(self: Client<R, E, A>) => Client<R1 | R, E1 | Exclude<E, { _tag: K }>, A1 | A>
135
+ ): <A, R>(self: Client<A, E, R>) => Client<A1 | A, E1 | Exclude<E, { _tag: K }>, R1 | R>
136
136
  <R, E extends { _tag: string }, A, K extends E["_tag"] & string, E1, R1, A1>(
137
- self: Client<R, E, A>,
137
+ self: Client<A, E, R>,
138
138
  tag: K,
139
139
  f: (e: Extract<E, { _tag: K }>) => Effect.Effect<A1, E1, R1>
140
- ): Client<R | R1, E1 | Exclude<E, { _tag: K }>, A | A1>
140
+ ): Client<A | A1, E1 | Exclude<E, { _tag: K }>, R | R1>
141
141
  } = internal.catchTag
142
142
 
143
143
  /**
@@ -150,42 +150,42 @@ export const catchTags: {
150
150
  Cases extends { [K in E["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => Effect.Effect<any, any, any>) | undefined }
151
151
  >(
152
152
  cases: Cases
153
- ): <R, A>(
154
- self: Client<R, E, A>
153
+ ): <A, R>(
154
+ self: Client<A, E, R>
155
155
  ) => Client<
156
- | R
156
+ | A
157
157
  | {
158
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, any, infer R> ? R : never
158
+ [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never
159
159
  }[keyof Cases],
160
160
  | Exclude<E, { _tag: keyof Cases }>
161
161
  | {
162
162
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, infer E, any> ? E : never
163
163
  }[keyof Cases],
164
- | A
164
+ | R
165
165
  | {
166
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never
166
+ [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, any, infer R> ? R : never
167
167
  }[keyof Cases]
168
168
  >
169
169
  <
170
- R,
171
- E extends { _tag: string },
172
170
  A,
171
+ E extends { _tag: string },
172
+ R,
173
173
  Cases extends { [K in E["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => Effect.Effect<any, any, any>) | undefined }
174
174
  >(
175
- self: Client<R, E, A>,
175
+ self: Client<A, E, R>,
176
176
  cases: Cases
177
177
  ): Client<
178
- | R
178
+ | A
179
179
  | {
180
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, any, infer R> ? R : never
180
+ [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never
181
181
  }[keyof Cases],
182
182
  | Exclude<E, { _tag: keyof Cases }>
183
183
  | {
184
184
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, infer E, any> ? E : never
185
185
  }[keyof Cases],
186
- | A
186
+ | R
187
187
  | {
188
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never
188
+ [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect.Effect<any, any, infer R> ? R : never
189
189
  }[keyof Cases]
190
190
  >
191
191
  } = internal.catchTags
@@ -198,12 +198,12 @@ export const filterOrElse: {
198
198
  <A, R2, E2, B>(
199
199
  f: Predicate.Predicate<A>,
200
200
  orElse: (a: A) => Effect.Effect<B, E2, R2>
201
- ): <R, E>(self: Client<R, E, A>) => Client<R2 | R, E2 | E, A | B>
202
- <R, E, A, R2, E2, B>(
203
- self: Client<R, E, A>,
201
+ ): <E, R>(self: Client<A, E, R>) => Client<A | B, E2 | E, R2 | R>
202
+ <A, E, R, R2, E2, B>(
203
+ self: Client<A, E, R>,
204
204
  f: Predicate.Predicate<A>,
205
205
  orElse: (a: A) => Effect.Effect<B, E2, R2>
206
- ): Client<R | R2, E | E2, A | B>
206
+ ): Client<A | B, E | E2, R | R2>
207
207
  } = internal.filterOrElse
208
208
 
209
209
  /**
@@ -211,8 +211,8 @@ export const filterOrElse: {
211
211
  * @category filters
212
212
  */
213
213
  export const filterOrFail: {
214
- <A, E2>(f: Predicate.Predicate<A>, orFailWith: (a: A) => E2): <R, E>(self: Client<R, E, A>) => Client<R, E2 | E, A>
215
- <R, E, A, E2>(self: Client<R, E, A>, f: Predicate.Predicate<A>, orFailWith: (a: A) => E2): Client<R, E | E2, A>
214
+ <A, E2>(f: Predicate.Predicate<A>, orFailWith: (a: A) => E2): <E, R>(self: Client<A, E, R>) => Client<A, E2 | E, R>
215
+ <A, E, R, E2>(self: Client<A, E, R>, f: Predicate.Predicate<A>, orFailWith: (a: A) => E2): Client<A, E | E2, R>
216
216
  } = internal.filterOrFail
217
217
 
218
218
  /**
@@ -222,29 +222,29 @@ export const filterOrFail: {
222
222
  export const filterStatus: {
223
223
  (
224
224
  f: (status: number) => boolean
225
- ): <R, E>(self: Client.WithResponse<R, E>) => Client.WithResponse<R, E | Error.ResponseError>
226
- <R, E>(
227
- self: Client.WithResponse<R, E>,
225
+ ): <E, R>(self: Client.WithResponse<E, R>) => Client.WithResponse<E | Error.ResponseError, R>
226
+ <E, R>(
227
+ self: Client.WithResponse<E, R>,
228
228
  f: (status: number) => boolean
229
- ): Client.WithResponse<R, Error.ResponseError | E>
229
+ ): Client.WithResponse<Error.ResponseError | E, R>
230
230
  } = internal.filterStatus
231
231
 
232
232
  /**
233
233
  * @since 1.0.0
234
234
  * @category filters
235
235
  */
236
- export const filterStatusOk: <R, E>(
237
- self: Client.WithResponse<R, E>
238
- ) => Client.WithResponse<R, Error.ResponseError | E> = internal.filterStatusOk
236
+ export const filterStatusOk: <E, R>(
237
+ self: Client.WithResponse<E, R>
238
+ ) => Client.WithResponse<Error.ResponseError | E, R> = internal.filterStatusOk
239
239
 
240
240
  /**
241
241
  * @since 1.0.0
242
242
  * @category constructors
243
243
  */
244
- export const make: <R, E, A, R2, E2>(
244
+ export const make: <A, E, R, R2, E2>(
245
245
  execute: (request: Effect.Effect<ClientRequest.ClientRequest, E2, R2>) => Effect.Effect<A, E, R>,
246
- preprocess: Client.Preprocess<R2, E2>
247
- ) => Client<R, E, A> = internal.make
246
+ preprocess: Client.Preprocess<E2, R2>
247
+ ) => Client<A, E, R> = internal.make
248
248
 
249
249
  /**
250
250
  * @since 1.0.0
@@ -262,13 +262,13 @@ export const makeDefault: (
262
262
  * @category mapping & sequencing
263
263
  */
264
264
  export const transform: {
265
- <R, E, A, R1, E1, A1>(
265
+ <A, E, R, R1, E1, A1>(
266
266
  f: (effect: Effect.Effect<A, E, R>, request: ClientRequest.ClientRequest) => Effect.Effect<A1, E1, R1>
267
- ): (self: Client<R, E, A>) => Client<R | R1, E | E1, A1>
268
- <R, E, A, R1, E1, A1>(
269
- self: Client<R, E, A>,
267
+ ): (self: Client<A, E, R>) => Client<A1, E | E1, R | R1>
268
+ <A, E, R, R1, E1, A1>(
269
+ self: Client<A, E, R>,
270
270
  f: (effect: Effect.Effect<A, E, R>, request: ClientRequest.ClientRequest) => Effect.Effect<A1, E1, R1>
271
- ): Client<R | R1, E | E1, A1>
271
+ ): Client<A1, E | E1, R | R1>
272
272
  } = internal.transform
273
273
 
274
274
  /**
@@ -276,13 +276,13 @@ export const transform: {
276
276
  * @category mapping & sequencing
277
277
  */
278
278
  export const transformResponse: {
279
- <R, E, A, R1, E1, A1>(
279
+ <A, E, R, R1, E1, A1>(
280
280
  f: (effect: Effect.Effect<A, E, R>) => Effect.Effect<A1, E1, R1>
281
- ): (self: Client<R, E, A>) => Client<R1, E1, A1>
282
- <R, E, A, R1, E1, A1>(
283
- self: Client<R, E, A>,
281
+ ): (self: Client<A, E, R>) => Client<A1, E1, R1>
282
+ <A, E, R, R1, E1, A1>(
283
+ self: Client<A, E, R>,
284
284
  f: (effect: Effect.Effect<A, E, R>) => Effect.Effect<A1, E1, R1>
285
- ): Client<R1, E1, A1>
285
+ ): Client<A1, E1, R1>
286
286
  } = internal.transformResponse
287
287
 
288
288
  /**
@@ -290,8 +290,8 @@ export const transformResponse: {
290
290
  * @category mapping & sequencing
291
291
  */
292
292
  export const map: {
293
- <A, B>(f: (a: A) => B): <R, E>(self: Client<R, E, A>) => Client<R, E, B>
294
- <R, E, A, B>(self: Client<R, E, A>, f: (a: A) => B): Client<R, E, B>
293
+ <A, B>(f: (a: A) => B): <E, R>(self: Client<A, E, R>) => Client<B, E, R>
294
+ <A, E, R, B>(self: Client<A, E, R>, f: (a: A) => B): Client<B, E, R>
295
295
  } = internal.map
296
296
 
297
297
  /**
@@ -299,8 +299,8 @@ export const map: {
299
299
  * @category mapping & sequencing
300
300
  */
301
301
  export const mapEffect: {
302
- <A, R2, E2, B>(f: (a: A) => Effect.Effect<B, E2, R2>): <R, E>(self: Client<R, E, A>) => Client<R2 | R, E2 | E, B>
303
- <R, E, A, R2, E2, B>(self: Client<R, E, A>, f: (a: A) => Effect.Effect<B, E2, R2>): Client<R | R2, E | E2, B>
302
+ <A, R2, E2, B>(f: (a: A) => Effect.Effect<B, E2, R2>): <E, R>(self: Client<A, E, R>) => Client<B, E2 | E, R2 | R>
303
+ <A, E, R, R2, E2, B>(self: Client<A, E, R>, f: (a: A) => Effect.Effect<B, E2, R2>): Client<B, E | E2, R2 | R>
304
304
  } = internal.mapEffect
305
305
 
306
306
  /**
@@ -310,11 +310,11 @@ export const mapEffect: {
310
310
  export const mapEffectScoped: {
311
311
  <A, R2, E2, B>(
312
312
  f: (a: A) => Effect.Effect<B, E2, R2>
313
- ): <R, E>(self: Client<R, E, A>) => Client<Exclude<R2, Scope.Scope> | Exclude<R, Scope.Scope>, E2 | E, B>
314
- <R, E, A, R2, E2, B>(
315
- self: Client<R, E, A>,
313
+ ): <E, R>(self: Client<A, E, R>) => Client<B, E2 | E, Exclude<R2, Scope.Scope> | Exclude<R, Scope.Scope>>
314
+ <A, E, R, R2, E2, B>(
315
+ self: Client<A, E, R>,
316
316
  f: (a: A) => Effect.Effect<B, E2, R2>
317
- ): Client<Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>, E | E2, B>
317
+ ): Client<B, E | E2, Exclude<R2, Scope.Scope> | Exclude<R, Scope.Scope>>
318
318
  } = internal.mapEffectScoped
319
319
 
320
320
  /**
@@ -324,8 +324,8 @@ export const mapEffectScoped: {
324
324
  export const mapRequest: {
325
325
  (
326
326
  f: (a: ClientRequest.ClientRequest) => ClientRequest.ClientRequest
327
- ): <R, E, A>(self: Client<R, E, A>) => Client<R, E, A>
328
- <R, E, A>(self: Client<R, E, A>, f: (a: ClientRequest.ClientRequest) => ClientRequest.ClientRequest): Client<R, E, A>
327
+ ): <A, E, R>(self: Client<A, E, R>) => Client<A, E, R>
328
+ <A, E, R>(self: Client<A, E, R>, f: (a: ClientRequest.ClientRequest) => ClientRequest.ClientRequest): Client<A, E, R>
329
329
  } = internal.mapRequest
330
330
 
331
331
  /**
@@ -335,11 +335,11 @@ export const mapRequest: {
335
335
  export const mapRequestEffect: {
336
336
  <R2, E2>(
337
337
  f: (a: ClientRequest.ClientRequest) => Effect.Effect<ClientRequest.ClientRequest, E2, R2>
338
- ): <R, E, A>(self: Client<R, E, A>) => Client<R2 | R, E2 | E, A>
339
- <R, E, A, R2, E2>(
340
- self: Client<R, E, A>,
338
+ ): <A, E, R>(self: Client<A, E, R>) => Client<A, E2 | E, R2 | R>
339
+ <A, E, R, R2, E2>(
340
+ self: Client<A, E, R>,
341
341
  f: (a: ClientRequest.ClientRequest) => Effect.Effect<ClientRequest.ClientRequest, E2, R2>
342
- ): Client<R | R2, E | E2, A>
342
+ ): Client<A, E | E2, R | R2>
343
343
  } = internal.mapRequestEffect
344
344
 
345
345
  /**
@@ -349,8 +349,8 @@ export const mapRequestEffect: {
349
349
  export const mapInputRequest: {
350
350
  (
351
351
  f: (a: ClientRequest.ClientRequest) => ClientRequest.ClientRequest
352
- ): <R, E, A>(self: Client<R, E, A>) => Client<R, E, A>
353
- <R, E, A>(self: Client<R, E, A>, f: (a: ClientRequest.ClientRequest) => ClientRequest.ClientRequest): Client<R, E, A>
352
+ ): <A, E, R>(self: Client<A, E, R>) => Client<A, E, R>
353
+ <A, E, R>(self: Client<A, E, R>, f: (a: ClientRequest.ClientRequest) => ClientRequest.ClientRequest): Client<A, E, R>
354
354
  } = internal.mapInputRequest
355
355
 
356
356
  /**
@@ -360,11 +360,11 @@ export const mapInputRequest: {
360
360
  export const mapInputRequestEffect: {
361
361
  <R2, E2>(
362
362
  f: (a: ClientRequest.ClientRequest) => Effect.Effect<ClientRequest.ClientRequest, E2, R2>
363
- ): <R, E, A>(self: Client<R, E, A>) => Client<R2 | R, E2 | E, A>
364
- <R, E, A, R2, E2>(
365
- self: Client<R, E, A>,
363
+ ): <A, E, R>(self: Client<A, E, R>) => Client<A, E2 | E, R2 | R>
364
+ <A, E, R, R2, E2>(
365
+ self: Client<A, E, R>,
366
366
  f: (a: ClientRequest.ClientRequest) => Effect.Effect<ClientRequest.ClientRequest, E2, R2>
367
- ): Client<R | R2, E | E2, A>
367
+ ): Client<A, E | E2, R2 | R>
368
368
  } = internal.mapInputRequestEffect
369
369
 
370
370
  /**
@@ -372,15 +372,15 @@ export const mapInputRequestEffect: {
372
372
  * @category error handling
373
373
  */
374
374
  export const retry: {
375
- <R1, E extends E0, E0, B>(policy: Schedule.Schedule<B, E0, R1>): <R, A>(self: Client<R, E, A>) => Client<R1 | R, E, A>
376
- <R, E extends E0, E0, A, R1, B>(self: Client<R, E, A>, policy: Schedule.Schedule<B, E0, R1>): Client<R | R1, E, A>
375
+ <B, E extends E0, E0, R1>(policy: Schedule.Schedule<B, E0, R1>): <A, R>(self: Client<A, E, R>) => Client<A, E, R1 | R>
376
+ <A, E extends E0, E0, R, R1, B>(self: Client<A, E, R>, policy: Schedule.Schedule<B, E0, R1>): Client<A, E, R1 | R>
377
377
  } = internal.retry
378
378
 
379
379
  /**
380
380
  * @since 1.0.0
381
381
  * @category resources & finalizers
382
382
  */
383
- export const scoped: <R, E, A>(self: Client<R, E, A>) => Client<Exclude<R, Scope.Scope>, E, A> = internal.scoped
383
+ export const scoped: <A, E, R>(self: Client<A, E, R>) => Client<A, E, Exclude<R, Scope.Scope>> = internal.scoped
384
384
 
385
385
  /**
386
386
  * @since 1.0.0
@@ -390,13 +390,13 @@ export const schemaFunction: {
390
390
  <SA, SI, SR>(
391
391
  schema: Schema.Schema<SA, SI, SR>,
392
392
  options?: ParseOptions | undefined
393
- ): <R, E, A>(
394
- self: Client<R, E, A>
393
+ ): <A, E, R>(
394
+ self: Client<A, E, R>
395
395
  ) => (
396
396
  request: ClientRequest.ClientRequest
397
397
  ) => (a: SA) => Effect.Effect<A, E | ParseResult.ParseError | Error.RequestError, SR | R>
398
- <R, E, A, SA, SI, SR>(
399
- self: Client<R, E, A>,
398
+ <A, E, R, SA, SI, SR>(
399
+ self: Client<A, E, R>,
400
400
  schema: Schema.Schema<SA, SI, SR>,
401
401
  options?: ParseOptions | undefined
402
402
  ): (
@@ -409,8 +409,8 @@ export const schemaFunction: {
409
409
  * @category mapping & sequencing
410
410
  */
411
411
  export const tap: {
412
- <A, R2, E2, _>(f: (a: A) => Effect.Effect<_, E2, R2>): <R, E>(self: Client<R, E, A>) => Client<R2 | R, E2 | E, A>
413
- <R, E, A, R2, E2, _>(self: Client<R, E, A>, f: (a: A) => Effect.Effect<_, E2, R2>): Client<R | R2, E | E2, A>
412
+ <A, R2, E2, _>(f: (a: A) => Effect.Effect<_, E2, R2>): <E, R>(self: Client<A, E, R>) => Client<A, E2 | E, R2 | R>
413
+ <A, E, R, R2, E2, _>(self: Client<A, E, R>, f: (a: A) => Effect.Effect<_, E2, R2>): Client<A, E | E2, R2 | R>
414
414
  } = internal.tap
415
415
 
416
416
  /**
@@ -420,11 +420,11 @@ export const tap: {
420
420
  export const tapRequest: {
421
421
  <R2, E2, _>(
422
422
  f: (a: ClientRequest.ClientRequest) => Effect.Effect<_, E2, R2>
423
- ): <R, E, A>(self: Client<R, E, A>) => Client<R2 | R, E2 | E, A>
424
- <R, E, A, R2, E2, _>(
425
- self: Client<R, E, A>,
423
+ ): <A, E, R>(self: Client<A, E, R>) => Client<A, E2 | E, R2 | R>
424
+ <A, E, R, R2, E2, _>(
425
+ self: Client<A, E, R>,
426
426
  f: (a: ClientRequest.ClientRequest) => Effect.Effect<_, E2, R2>
427
- ): Client<R | R2, E | E2, A>
427
+ ): Client<A, E | E2, R | R2>
428
428
  } = internal.tapRequest
429
429
 
430
430
  /**
@@ -432,19 +432,19 @@ export const tapRequest: {
432
432
  * @category cookies
433
433
  */
434
434
  export const withCookiesRef: {
435
- (ref: Ref<Cookies>): <R, E>(self: Client.WithResponse<R, E>) => Client.WithResponse<R, E>
436
- <R, E>(self: Client.WithResponse<R, E>, ref: Ref<Cookies>): Client.WithResponse<R, E>
435
+ (ref: Ref<Cookies>): <E, R>(self: Client.WithResponse<E, R>) => Client.WithResponse<E, R>
436
+ <E, R>(self: Client.WithResponse<E, R>, ref: Ref<Cookies>): Client.WithResponse<E, R>
437
437
  } = internal.withCookiesRef
438
438
 
439
439
  /**
440
- * @since 2.0.0
440
+ * @since 1.0.0
441
441
  * @category fiber refs
442
442
  */
443
443
  export const currentTracerDisabledWhen: FiberRef.FiberRef<Predicate.Predicate<ClientRequest.ClientRequest>> =
444
444
  internal.currentTracerDisabledWhen
445
445
 
446
446
  /**
447
- * @since 2.0.0
447
+ * @since 1.0.0
448
448
  * @category fiber refs
449
449
  */
450
450
  export const withTracerDisabledWhen: {
@@ -456,3 +456,18 @@ export const withTracerDisabledWhen: {
456
456
  predicate: Predicate.Predicate<ClientRequest.ClientRequest>
457
457
  ): Effect.Effect<A, E, R>
458
458
  } = internal.withTracerDisabledWhen
459
+
460
+ /**
461
+ * @since 1.0.0
462
+ * @category fiber refs
463
+ */
464
+ export const currentFetchOptions: FiberRef.FiberRef<RequestInit> = internal.currentFetchOptions
465
+
466
+ /**
467
+ * @since 1.0.0
468
+ * @category fiber refs
469
+ */
470
+ export const withFetchOptions: {
471
+ (options: RequestInit): <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
472
+ <R, E, A>(effect: Effect.Effect<A, E, R>, options: RequestInit): Effect.Effect<A, E, R>
473
+ } = internal.withFetchOptions
@@ -24,7 +24,7 @@ export {
24
24
  * @since 1.0.0
25
25
  * @category schema
26
26
  */
27
- schemaBodyJsonEffect,
27
+ schemaBodyJsonScoped,
28
28
  /**
29
29
  * @since 1.0.0
30
30
  * @category schema
@@ -34,7 +34,7 @@ export {
34
34
  * @since 1.0.0
35
35
  * @category schema
36
36
  */
37
- schemaBodyUrlParamsEffect,
37
+ schemaBodyUrlParamsScoped,
38
38
  /**
39
39
  * @since 1.0.0
40
40
  * @category schema
@@ -44,7 +44,7 @@ export {
44
44
  * @since 1.0.0
45
45
  * @category schema
46
46
  */
47
- schemaHeadersEffect
47
+ schemaHeadersScoped
48
48
  } from "./IncomingMessage.js"
49
49
 
50
50
  /**
@@ -161,7 +161,7 @@ export const urlParamsBody: <E, R>(
161
161
  * @since 1.0.0
162
162
  * @category schema
163
163
  */
164
- export const schemaJsonEffect: <
164
+ export const schemaJsonScoped: <
165
165
  R,
166
166
  I extends {
167
167
  readonly status?: number | undefined
@@ -178,13 +178,13 @@ export const schemaJsonEffect: <
178
178
  A,
179
179
  E | Error.ResponseError | ParseResult.ParseError,
180
180
  Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>
181
- > = internal.schemaJsonEffect
181
+ > = internal.schemaJsonScoped
182
182
 
183
183
  /**
184
184
  * @since 1.0.0
185
185
  * @category schema
186
186
  */
187
- export const schemaNoBodyEffect: <
187
+ export const schemaNoBodyScoped: <
188
188
  R,
189
189
  I extends {
190
190
  readonly status?: number | undefined
@@ -197,4 +197,4 @@ export const schemaNoBodyEffect: <
197
197
  ) => <E, R2>(
198
198
  effect: Effect.Effect<ClientResponse, E, R2>
199
199
  ) => Effect.Effect<A, E | ParseResult.ParseError, Exclude<R, Scope.Scope> | Exclude<R2, Scope.Scope>> =
200
- internal.schemaNoBodyEffect
200
+ internal.schemaNoBodyScoped
@@ -8,7 +8,7 @@ import * as Inspectable from "effect/Inspectable"
8
8
  import * as Option from "effect/Option"
9
9
  import { type Pipeable, pipeArguments } from "effect/Pipeable"
10
10
  import * as Predicate from "effect/Predicate"
11
- import * as ReadonlyRecord from "effect/ReadonlyRecord"
11
+ import * as Record from "effect/Record"
12
12
  import type * as Types from "effect/Types"
13
13
  import { TypeIdError } from "../Error.js"
14
14
 
@@ -36,7 +36,7 @@ export const isCookies = (u: unknown): u is Cookies => Predicate.hasProperty(u,
36
36
  */
37
37
  export interface Cookies extends Pipeable, Inspectable.Inspectable {
38
38
  readonly [TypeId]: TypeId
39
- readonly cookies: ReadonlyRecord.ReadonlyRecord<string, Cookie>
39
+ readonly cookies: Record.ReadonlyRecord<string, Cookie>
40
40
  }
41
41
 
42
42
  /**
@@ -103,7 +103,7 @@ const Proto: Omit<Cookies, "cookies"> = {
103
103
  toJSON(this: Cookies) {
104
104
  return {
105
105
  _id: "@effect/platform/Http/Cookies",
106
- cookies: ReadonlyRecord.map(this.cookies, (cookie) => cookie.toJSON())
106
+ cookies: Record.map(this.cookies, (cookie) => cookie.toJSON())
107
107
  }
108
108
  },
109
109
  pipe() {
@@ -117,7 +117,7 @@ const Proto: Omit<Cookies, "cookies"> = {
117
117
  * @since 1.0.0
118
118
  * @category constructors
119
119
  */
120
- export const fromReadonlyRecord = (cookies: ReadonlyRecord.ReadonlyRecord<string, Cookie>): Cookies => {
120
+ export const fromReadonlyRecord = (cookies: Record.ReadonlyRecord<string, Cookie>): Cookies => {
121
121
  const self = Object.create(Proto)
122
122
  self.cookies = cookies
123
123
  return self
@@ -299,7 +299,7 @@ export const empty: Cookies = fromIterable([])
299
299
  * @since 1.0.0
300
300
  * @category refinements
301
301
  */
302
- export const isEmpty = (self: Cookies): boolean => ReadonlyRecord.isEmptyRecord(self.cookies)
302
+ export const isEmpty = (self: Cookies): boolean => Record.isEmptyRecord(self.cookies)
303
303
 
304
304
  // eslint-disable-next-line no-control-regex
305
305
  const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/
@@ -385,7 +385,7 @@ export const setCookie: {
385
385
  } = dual(
386
386
  2,
387
387
  (self: Cookies, cookie: Cookie) =>
388
- fromReadonlyRecord(ReadonlyRecord.set(
388
+ fromReadonlyRecord(Record.set(
389
389
  self.cookies,
390
390
  cookie.name,
391
391
  cookie
@@ -442,7 +442,7 @@ export const remove: {
442
442
  self: Cookies,
443
443
  name: string
444
444
  ): Cookies
445
- } = dual(2, (self: Cookies, name: string) => fromReadonlyRecord(ReadonlyRecord.remove(self.cookies, name)))
445
+ } = dual(2, (self: Cookies, name: string) => fromReadonlyRecord(Record.remove(self.cookies, name)))
446
446
 
447
447
  /**
448
448
  * Add a cookie to a Cookies object
@@ -467,7 +467,7 @@ export const set: {
467
467
  (self: Cookies, name: string, value: string, options?: Cookie["options"]) =>
468
468
  Either.map(
469
469
  makeCookie(name, value, options),
470
- (cookie) => fromReadonlyRecord(ReadonlyRecord.set(self.cookies, name, cookie))
470
+ (cookie) => fromReadonlyRecord(Record.set(self.cookies, name, cookie))
471
471
  )
472
472
  )
473
473
 
@@ -492,7 +492,7 @@ export const unsafeSet: {
492
492
  } = dual(
493
493
  (args) => isCookies(args[0]),
494
494
  (self: Cookies, name: string, value: string, options?: Cookie["options"]) =>
495
- fromReadonlyRecord(ReadonlyRecord.set(
495
+ fromReadonlyRecord(Record.set(
496
496
  self.cookies,
497
497
  name,
498
498
  unsafeMakeCookie(name, value, options)
@@ -2,11 +2,11 @@
2
2
  * @since 1.0.0
3
3
  */
4
4
  import * as Schema from "@effect/schema/Schema"
5
+ import * as Array from "effect/Array"
5
6
  import { dual, identity } from "effect/Function"
6
7
  import type * as Option from "effect/Option"
7
8
  import * as Predicate from "effect/Predicate"
8
- import * as ReadonlyArray from "effect/ReadonlyArray"
9
- import * as ReadonlyRecord from "effect/ReadonlyRecord"
9
+ import * as Record from "effect/Record"
10
10
  import * as Secret from "effect/Secret"
11
11
  import * as String from "effect/String"
12
12
 
@@ -43,15 +43,15 @@ export interface Headers {
43
43
  */
44
44
  export const schemaFromSelf: Schema.Schema<Headers> = Schema.declare(isHeaders, {
45
45
  identifier: "Headers",
46
- equivalence: () => ReadonlyRecord.getEquivalence(String.Equivalence)
46
+ equivalence: () => Record.getEquivalence(String.Equivalence)
47
47
  })
48
48
 
49
49
  /**
50
50
  * @since 1.0.0
51
51
  * @category schemas
52
52
  */
53
- export const schema: Schema.Schema<Headers, ReadonlyRecord.ReadonlyRecord<string, string | ReadonlyArray<string>>> =
54
- Schema.transform(
53
+ export const schema: Schema.Schema<Headers, Record.ReadonlyRecord<string, string | ReadonlyArray<string>>> = Schema
54
+ .transform(
55
55
  Schema.Record(Schema.String, Schema.Union(Schema.String, Schema.Array(Schema.String))),
56
56
  schemaFromSelf,
57
57
  { decode: (record) => fromInput(record), encode: identity }
@@ -62,7 +62,7 @@ export const schema: Schema.Schema<Headers, ReadonlyRecord.ReadonlyRecord<string
62
62
  * @category models
63
63
  */
64
64
  export type Input =
65
- | ReadonlyRecord.ReadonlyRecord<string, string | ReadonlyArray<string> | undefined>
65
+ | Record.ReadonlyRecord<string, string | ReadonlyArray<string> | undefined>
66
66
  | Iterable<readonly [string, string]>
67
67
 
68
68
  /**
@@ -79,12 +79,12 @@ export const fromInput: (input?: Input) => Headers = (input) => {
79
79
  if (input === undefined) {
80
80
  return empty
81
81
  } else if (Symbol.iterator in input) {
82
- return ReadonlyRecord.fromEntries(ReadonlyArray.map(
83
- ReadonlyArray.fromIterable(input),
82
+ return Record.fromEntries(Array.map(
83
+ Array.fromIterable(input),
84
84
  ([k, v]) => [k.toLowerCase(), v] as const
85
85
  )) as Headers
86
86
  }
87
- return ReadonlyRecord.fromEntries(
87
+ return Record.fromEntries(
88
88
  Object.entries(input).map(([k, v]) =>
89
89
  [
90
90
  k.toLowerCase(),
@@ -98,7 +98,7 @@ export const fromInput: (input?: Input) => Headers = (input) => {
98
98
  * @since 1.0.0
99
99
  * @category constructors
100
100
  */
101
- export const unsafeFromRecord = (input: ReadonlyRecord.ReadonlyRecord<string, string>): Headers => input as Headers
101
+ export const unsafeFromRecord = (input: Record.ReadonlyRecord<string, string>): Headers => input as Headers
102
102
 
103
103
  /**
104
104
  * @since 1.0.0
@@ -110,7 +110,7 @@ export const has: {
110
110
  } = dual<
111
111
  (key: string) => (self: Headers) => boolean,
112
112
  (self: Headers, key: string) => boolean
113
- >(2, (self, key) => ReadonlyRecord.has(self as Record<string, string>, key.toLowerCase()))
113
+ >(2, (self, key) => Record.has(self as Record<string, string>, key.toLowerCase()))
114
114
 
115
115
  /**
116
116
  * @since 1.0.0
@@ -122,7 +122,7 @@ export const get: {
122
122
  } = dual<
123
123
  (key: string) => (self: Headers) => Option.Option<string>,
124
124
  (self: Headers, key: string) => Option.Option<string>
125
- >(2, (self, key) => ReadonlyRecord.get(self as Record<string, string>, key.toLowerCase()))
125
+ >(2, (self, key) => Record.get(self as Record<string, string>, key.toLowerCase()))
126
126
 
127
127
  /**
128
128
  * @since 1.0.0