@effect/platform 0.66.2 → 0.66.3
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/dist/cjs/Command.js.map +1 -1
- package/dist/cjs/Cookies.js.map +1 -1
- package/dist/cjs/Effectify.js.map +1 -1
- package/dist/cjs/Headers.js.map +1 -1
- package/dist/cjs/HttpApi.js.map +1 -1
- package/dist/cjs/HttpApiBuilder.js.map +1 -1
- package/dist/cjs/HttpApiEndpoint.js.map +1 -1
- package/dist/cjs/HttpApiGroup.js.map +1 -1
- package/dist/cjs/HttpApiSchema.js.map +1 -1
- package/dist/cjs/HttpApiSecurity.js.map +1 -1
- package/dist/cjs/HttpApp.js.map +1 -1
- package/dist/cjs/HttpClient.js +8 -1
- package/dist/cjs/HttpClient.js.map +1 -1
- package/dist/cjs/HttpClientError.js +8 -1
- package/dist/cjs/HttpClientError.js.map +1 -1
- package/dist/cjs/HttpClientRequest.js.map +1 -1
- package/dist/cjs/HttpClientResponse.js +11 -1
- package/dist/cjs/HttpClientResponse.js.map +1 -1
- package/dist/cjs/HttpIncomingMessage.js.map +1 -1
- package/dist/cjs/HttpMiddleware.js.map +1 -1
- package/dist/cjs/HttpMultiplex.js.map +1 -1
- package/dist/cjs/HttpRouter.js.map +1 -1
- package/dist/cjs/HttpServer.js.map +1 -1
- package/dist/cjs/HttpServerResponse.js.map +1 -1
- package/dist/cjs/KeyValueStore.js.map +1 -1
- package/dist/cjs/Multipart.js.map +1 -1
- package/dist/cjs/OpenApi.js.map +1 -1
- package/dist/cjs/PlatformLogger.js.map +1 -1
- package/dist/cjs/Socket.js +4 -1
- package/dist/cjs/Socket.js.map +1 -1
- package/dist/cjs/Transferable.js.map +1 -1
- package/dist/cjs/UrlParams.js.map +1 -1
- package/dist/cjs/internal/httpClient.js +12 -14
- package/dist/cjs/internal/httpClient.js.map +1 -1
- package/dist/cjs/internal/httpClientResponse.js +16 -1
- package/dist/cjs/internal/httpClientResponse.js.map +1 -1
- package/dist/dts/Command.d.ts +134 -0
- package/dist/dts/Command.d.ts.map +1 -1
- package/dist/dts/Cookies.d.ts +120 -0
- package/dist/dts/Cookies.d.ts.map +1 -1
- package/dist/dts/Effectify.d.ts +9 -0
- package/dist/dts/Effectify.d.ts.map +1 -1
- package/dist/dts/Headers.d.ts +56 -0
- package/dist/dts/Headers.d.ts.map +1 -1
- package/dist/dts/HttpApi.d.ts +58 -0
- package/dist/dts/HttpApi.d.ts.map +1 -1
- package/dist/dts/HttpApiBuilder.d.ts +84 -0
- package/dist/dts/HttpApiBuilder.d.ts.map +1 -1
- package/dist/dts/HttpApiEndpoint.d.ts +118 -0
- package/dist/dts/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/dts/HttpApiGroup.d.ts +100 -0
- package/dist/dts/HttpApiGroup.d.ts.map +1 -1
- package/dist/dts/HttpApiSchema.d.ts +16 -0
- package/dist/dts/HttpApiSchema.d.ts.map +1 -1
- package/dist/dts/HttpApiSecurity.d.ts +16 -0
- package/dist/dts/HttpApiSecurity.d.ts.map +1 -1
- package/dist/dts/HttpApp.d.ts.map +1 -1
- package/dist/dts/HttpClient.d.ts +308 -0
- package/dist/dts/HttpClient.d.ts.map +1 -1
- package/dist/dts/HttpClientError.d.ts +5 -0
- package/dist/dts/HttpClientError.d.ts.map +1 -1
- package/dist/dts/HttpClientRequest.d.ts +208 -0
- package/dist/dts/HttpClientRequest.d.ts.map +1 -1
- package/dist/dts/HttpClientResponse.d.ts +30 -0
- package/dist/dts/HttpClientResponse.d.ts.map +1 -1
- package/dist/dts/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/dts/HttpMiddleware.d.ts +24 -0
- package/dist/dts/HttpMiddleware.d.ts.map +1 -1
- package/dist/dts/HttpMultiplex.d.ts +72 -0
- package/dist/dts/HttpMultiplex.d.ts.map +1 -1
- package/dist/dts/HttpRouter.d.ts +184 -0
- package/dist/dts/HttpRouter.d.ts.map +1 -1
- package/dist/dts/HttpServer.d.ts +32 -0
- package/dist/dts/HttpServer.d.ts.map +1 -1
- package/dist/dts/HttpServerResponse.d.ts +96 -0
- package/dist/dts/HttpServerResponse.d.ts.map +1 -1
- package/dist/dts/KeyValueStore.d.ts +8 -0
- package/dist/dts/KeyValueStore.d.ts.map +1 -1
- package/dist/dts/Multipart.d.ts +32 -0
- package/dist/dts/Multipart.d.ts.map +1 -1
- package/dist/dts/OpenApi.d.ts +8 -0
- package/dist/dts/OpenApi.d.ts.map +1 -1
- package/dist/dts/PlatformLogger.d.ts +46 -0
- package/dist/dts/PlatformLogger.d.ts.map +1 -1
- package/dist/dts/Socket.d.ts +8 -0
- package/dist/dts/Socket.d.ts.map +1 -1
- package/dist/dts/Transferable.d.ts +8 -0
- package/dist/dts/Transferable.d.ts.map +1 -1
- package/dist/dts/UrlParams.d.ts +64 -0
- package/dist/dts/UrlParams.d.ts.map +1 -1
- package/dist/esm/Command.js.map +1 -1
- package/dist/esm/Cookies.js.map +1 -1
- package/dist/esm/Effectify.js.map +1 -1
- package/dist/esm/Headers.js.map +1 -1
- package/dist/esm/HttpApi.js.map +1 -1
- package/dist/esm/HttpApiBuilder.js.map +1 -1
- package/dist/esm/HttpApiEndpoint.js.map +1 -1
- package/dist/esm/HttpApiGroup.js.map +1 -1
- package/dist/esm/HttpApiSchema.js.map +1 -1
- package/dist/esm/HttpApiSecurity.js.map +1 -1
- package/dist/esm/HttpApp.js.map +1 -1
- package/dist/esm/HttpClient.js +7 -0
- package/dist/esm/HttpClient.js.map +1 -1
- package/dist/esm/HttpClientError.js +6 -0
- package/dist/esm/HttpClientError.js.map +1 -1
- package/dist/esm/HttpClientRequest.js.map +1 -1
- package/dist/esm/HttpClientResponse.js +10 -0
- package/dist/esm/HttpClientResponse.js.map +1 -1
- package/dist/esm/HttpIncomingMessage.js.map +1 -1
- package/dist/esm/HttpMiddleware.js.map +1 -1
- package/dist/esm/HttpMultiplex.js.map +1 -1
- package/dist/esm/HttpRouter.js.map +1 -1
- package/dist/esm/HttpServer.js.map +1 -1
- package/dist/esm/HttpServerResponse.js.map +1 -1
- package/dist/esm/KeyValueStore.js.map +1 -1
- package/dist/esm/Multipart.js.map +1 -1
- package/dist/esm/OpenApi.js.map +1 -1
- package/dist/esm/PlatformLogger.js.map +1 -1
- package/dist/esm/Socket.js +4 -1
- package/dist/esm/Socket.js.map +1 -1
- package/dist/esm/Transferable.js.map +1 -1
- package/dist/esm/UrlParams.js.map +1 -1
- package/dist/esm/internal/httpClient.js +11 -13
- package/dist/esm/internal/httpClient.js.map +1 -1
- package/dist/esm/internal/httpClientResponse.js +14 -0
- package/dist/esm/internal/httpClientResponse.js.map +1 -1
- package/package.json +3 -3
- package/src/Command.ts +134 -0
- package/src/Cookies.ts +128 -38
- package/src/Effectify.ts +9 -0
- package/src/Headers.ts +106 -7
- package/src/HttpApi.ts +58 -0
- package/src/HttpApiBuilder.ts +85 -3
- package/src/HttpApiEndpoint.ts +121 -9
- package/src/HttpApiGroup.ts +102 -7
- package/src/HttpApiSchema.ts +22 -4
- package/src/HttpApiSecurity.ts +16 -0
- package/src/HttpApp.ts +8 -0
- package/src/HttpClient.ts +315 -11
- package/src/HttpClientError.ts +7 -0
- package/src/HttpClientRequest.ts +213 -1
- package/src/HttpClientResponse.ts +33 -0
- package/src/HttpIncomingMessage.ts +8 -0
- package/src/HttpMiddleware.ts +24 -0
- package/src/HttpMultiplex.ts +72 -0
- package/src/HttpRouter.ts +189 -18
- package/src/HttpServer.ts +34 -6
- package/src/HttpServerResponse.ts +98 -10
- package/src/KeyValueStore.ts +8 -0
- package/src/Multipart.ts +32 -0
- package/src/OpenApi.ts +31 -18
- package/src/PlatformLogger.ts +46 -0
- package/src/Socket.ts +19 -13
- package/src/Transferable.ts +9 -3
- package/src/UrlParams.ts +64 -0
- package/src/internal/httpClient.ts +41 -26
- package/src/internal/httpClientResponse.ts +40 -1
package/src/Headers.ts
CHANGED
|
@@ -117,10 +117,26 @@ export const unsafeFromRecord = (input: Record.ReadonlyRecord<string, string>):
|
|
|
117
117
|
* @category combinators
|
|
118
118
|
*/
|
|
119
119
|
export const has: {
|
|
120
|
+
/**
|
|
121
|
+
* @since 1.0.0
|
|
122
|
+
* @category combinators
|
|
123
|
+
*/
|
|
120
124
|
(key: string): (self: Headers) => boolean
|
|
125
|
+
/**
|
|
126
|
+
* @since 1.0.0
|
|
127
|
+
* @category combinators
|
|
128
|
+
*/
|
|
121
129
|
(self: Headers, key: string): boolean
|
|
122
130
|
} = dual<
|
|
131
|
+
/**
|
|
132
|
+
* @since 1.0.0
|
|
133
|
+
* @category combinators
|
|
134
|
+
*/
|
|
123
135
|
(key: string) => (self: Headers) => boolean,
|
|
136
|
+
/**
|
|
137
|
+
* @since 1.0.0
|
|
138
|
+
* @category combinators
|
|
139
|
+
*/
|
|
124
140
|
(self: Headers, key: string) => boolean
|
|
125
141
|
>(2, (self, key) => key.toLowerCase() in self)
|
|
126
142
|
|
|
@@ -129,10 +145,26 @@ export const has: {
|
|
|
129
145
|
* @category combinators
|
|
130
146
|
*/
|
|
131
147
|
export const get: {
|
|
148
|
+
/**
|
|
149
|
+
* @since 1.0.0
|
|
150
|
+
* @category combinators
|
|
151
|
+
*/
|
|
132
152
|
(key: string): (self: Headers) => Option.Option<string>
|
|
153
|
+
/**
|
|
154
|
+
* @since 1.0.0
|
|
155
|
+
* @category combinators
|
|
156
|
+
*/
|
|
133
157
|
(self: Headers, key: string): Option.Option<string>
|
|
134
158
|
} = dual<
|
|
159
|
+
/**
|
|
160
|
+
* @since 1.0.0
|
|
161
|
+
* @category combinators
|
|
162
|
+
*/
|
|
135
163
|
(key: string) => (self: Headers) => Option.Option<string>,
|
|
164
|
+
/**
|
|
165
|
+
* @since 1.0.0
|
|
166
|
+
* @category combinators
|
|
167
|
+
*/
|
|
136
168
|
(self: Headers, key: string) => Option.Option<string>
|
|
137
169
|
>(2, (self, key) => Record.get(self as Record<string, string>, key.toLowerCase()))
|
|
138
170
|
|
|
@@ -141,10 +173,26 @@ export const get: {
|
|
|
141
173
|
* @category combinators
|
|
142
174
|
*/
|
|
143
175
|
export const set: {
|
|
176
|
+
/**
|
|
177
|
+
* @since 1.0.0
|
|
178
|
+
* @category combinators
|
|
179
|
+
*/
|
|
144
180
|
(key: string, value: string): (self: Headers) => Headers
|
|
181
|
+
/**
|
|
182
|
+
* @since 1.0.0
|
|
183
|
+
* @category combinators
|
|
184
|
+
*/
|
|
145
185
|
(self: Headers, key: string, value: string): Headers
|
|
146
186
|
} = dual<
|
|
187
|
+
/**
|
|
188
|
+
* @since 1.0.0
|
|
189
|
+
* @category combinators
|
|
190
|
+
*/
|
|
147
191
|
(key: string, value: string) => (self: Headers) => Headers,
|
|
192
|
+
/**
|
|
193
|
+
* @since 1.0.0
|
|
194
|
+
* @category combinators
|
|
195
|
+
*/
|
|
148
196
|
(self: Headers, key: string, value: string) => Headers
|
|
149
197
|
>(3, (self, key, value) => {
|
|
150
198
|
const out = make(self)
|
|
@@ -157,10 +205,26 @@ export const set: {
|
|
|
157
205
|
* @category combinators
|
|
158
206
|
*/
|
|
159
207
|
export const setAll: {
|
|
208
|
+
/**
|
|
209
|
+
* @since 1.0.0
|
|
210
|
+
* @category combinators
|
|
211
|
+
*/
|
|
160
212
|
(headers: Input): (self: Headers) => Headers
|
|
213
|
+
/**
|
|
214
|
+
* @since 1.0.0
|
|
215
|
+
* @category combinators
|
|
216
|
+
*/
|
|
161
217
|
(self: Headers, headers: Input): Headers
|
|
162
218
|
} = dual<
|
|
219
|
+
/**
|
|
220
|
+
* @since 1.0.0
|
|
221
|
+
* @category combinators
|
|
222
|
+
*/
|
|
163
223
|
(headers: Input) => (self: Headers) => Headers,
|
|
224
|
+
/**
|
|
225
|
+
* @since 1.0.0
|
|
226
|
+
* @category combinators
|
|
227
|
+
*/
|
|
164
228
|
(self: Headers, headers: Input) => Headers
|
|
165
229
|
>(2, (self, headers) =>
|
|
166
230
|
make({
|
|
@@ -173,10 +237,26 @@ export const setAll: {
|
|
|
173
237
|
* @category combinators
|
|
174
238
|
*/
|
|
175
239
|
export const merge: {
|
|
240
|
+
/**
|
|
241
|
+
* @since 1.0.0
|
|
242
|
+
* @category combinators
|
|
243
|
+
*/
|
|
176
244
|
(headers: Headers): (self: Headers) => Headers
|
|
245
|
+
/**
|
|
246
|
+
* @since 1.0.0
|
|
247
|
+
* @category combinators
|
|
248
|
+
*/
|
|
177
249
|
(self: Headers, headers: Headers): Headers
|
|
178
250
|
} = dual<
|
|
251
|
+
/**
|
|
252
|
+
* @since 1.0.0
|
|
253
|
+
* @category combinators
|
|
254
|
+
*/
|
|
179
255
|
(headers: Headers) => (self: Headers) => Headers,
|
|
256
|
+
/**
|
|
257
|
+
* @since 1.0.0
|
|
258
|
+
* @category combinators
|
|
259
|
+
*/
|
|
180
260
|
(self: Headers, headers: Headers) => Headers
|
|
181
261
|
>(2, (self, headers) => {
|
|
182
262
|
const out = make(self)
|
|
@@ -189,10 +269,26 @@ export const merge: {
|
|
|
189
269
|
* @category combinators
|
|
190
270
|
*/
|
|
191
271
|
export const remove: {
|
|
272
|
+
/**
|
|
273
|
+
* @since 1.0.0
|
|
274
|
+
* @category combinators
|
|
275
|
+
*/
|
|
192
276
|
(key: string): (self: Headers) => Headers
|
|
277
|
+
/**
|
|
278
|
+
* @since 1.0.0
|
|
279
|
+
* @category combinators
|
|
280
|
+
*/
|
|
193
281
|
(self: Headers, key: string): Headers
|
|
194
282
|
} = dual<
|
|
283
|
+
/**
|
|
284
|
+
* @since 1.0.0
|
|
285
|
+
* @category combinators
|
|
286
|
+
*/
|
|
195
287
|
(key: string) => (self: Headers) => Headers,
|
|
288
|
+
/**
|
|
289
|
+
* @since 1.0.0
|
|
290
|
+
* @category combinators
|
|
291
|
+
*/
|
|
196
292
|
(self: Headers, key: string) => Headers
|
|
197
293
|
>(2, (self, key) => {
|
|
198
294
|
const out = make(self)
|
|
@@ -205,13 +301,16 @@ export const remove: {
|
|
|
205
301
|
* @category combinators
|
|
206
302
|
*/
|
|
207
303
|
export const redact: {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
304
|
+
/**
|
|
305
|
+
* @since 1.0.0
|
|
306
|
+
* @category combinators
|
|
307
|
+
*/
|
|
308
|
+
(key: string | RegExp | ReadonlyArray<string | RegExp>): (self: Headers) => Record<string, string | Redacted.Redacted>
|
|
309
|
+
/**
|
|
310
|
+
* @since 1.0.0
|
|
311
|
+
* @category combinators
|
|
312
|
+
*/
|
|
313
|
+
(self: Headers, key: string | RegExp | ReadonlyArray<string | RegExp>): Record<string, string | Redacted.Redacted>
|
|
215
314
|
} = dual(
|
|
216
315
|
2,
|
|
217
316
|
(
|
package/src/HttpApi.ts
CHANGED
|
@@ -134,21 +134,45 @@ export const empty: HttpApi = makeProto({
|
|
|
134
134
|
* @category constructors
|
|
135
135
|
*/
|
|
136
136
|
export const addGroup: {
|
|
137
|
+
/**
|
|
138
|
+
* Add a `HttpApiGroup` to an `HttpApi`.
|
|
139
|
+
*
|
|
140
|
+
* @since 1.0.0
|
|
141
|
+
* @category constructors
|
|
142
|
+
*/
|
|
137
143
|
<Group extends HttpApiGroup.HttpApiGroup.Any>(
|
|
138
144
|
group: Group
|
|
139
145
|
): <Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR>(
|
|
140
146
|
self: HttpApi<Groups, Error, ErrorR>
|
|
141
147
|
) => HttpApi<Groups | Group, Error, ErrorR>
|
|
148
|
+
/**
|
|
149
|
+
* Add a `HttpApiGroup` to an `HttpApi`.
|
|
150
|
+
*
|
|
151
|
+
* @since 1.0.0
|
|
152
|
+
* @category constructors
|
|
153
|
+
*/
|
|
142
154
|
<Group extends HttpApiGroup.HttpApiGroup.Any>(
|
|
143
155
|
path: HttpRouter.PathInput,
|
|
144
156
|
group: Group
|
|
145
157
|
): <Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR>(
|
|
146
158
|
self: HttpApi<Groups, Error, ErrorR>
|
|
147
159
|
) => HttpApi<Groups | Group, Error, ErrorR>
|
|
160
|
+
/**
|
|
161
|
+
* Add a `HttpApiGroup` to an `HttpApi`.
|
|
162
|
+
*
|
|
163
|
+
* @since 1.0.0
|
|
164
|
+
* @category constructors
|
|
165
|
+
*/
|
|
148
166
|
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, Group extends HttpApiGroup.HttpApiGroup.Any>(
|
|
149
167
|
self: HttpApi<Groups, Error, ErrorR>,
|
|
150
168
|
group: Group
|
|
151
169
|
): HttpApi<Groups | Group, Error, ErrorR>
|
|
170
|
+
/**
|
|
171
|
+
* Add a `HttpApiGroup` to an `HttpApi`.
|
|
172
|
+
*
|
|
173
|
+
* @since 1.0.0
|
|
174
|
+
* @category constructors
|
|
175
|
+
*/
|
|
152
176
|
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, Group extends HttpApiGroup.HttpApiGroup.Any>(
|
|
153
177
|
self: HttpApi<Groups, Error, ErrorR>,
|
|
154
178
|
path: HttpRouter.PathInput,
|
|
@@ -178,6 +202,15 @@ export const addGroup: {
|
|
|
178
202
|
* @category errors
|
|
179
203
|
*/
|
|
180
204
|
export const addError: {
|
|
205
|
+
/**
|
|
206
|
+
* Add an error schema to an `HttpApi`, which is shared by all endpoints in the
|
|
207
|
+
* `HttpApi`.
|
|
208
|
+
*
|
|
209
|
+
* Useful for adding error types from middleware or other shared error types.
|
|
210
|
+
*
|
|
211
|
+
* @since 1.0.0
|
|
212
|
+
* @category errors
|
|
213
|
+
*/
|
|
181
214
|
<A, I, R>(
|
|
182
215
|
schema: Schema.Schema<A, I, R>,
|
|
183
216
|
annotations?: {
|
|
@@ -186,6 +219,15 @@ export const addError: {
|
|
|
186
219
|
): <Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR>(
|
|
187
220
|
self: HttpApi<Groups, Error, ErrorR>
|
|
188
221
|
) => HttpApi<Groups, Error | A, ErrorR | R>
|
|
222
|
+
/**
|
|
223
|
+
* Add an error schema to an `HttpApi`, which is shared by all endpoints in the
|
|
224
|
+
* `HttpApi`.
|
|
225
|
+
*
|
|
226
|
+
* Useful for adding error types from middleware or other shared error types.
|
|
227
|
+
*
|
|
228
|
+
* @since 1.0.0
|
|
229
|
+
* @category errors
|
|
230
|
+
*/
|
|
189
231
|
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, A, I, R>(
|
|
190
232
|
self: HttpApi<Groups, Error, ErrorR>,
|
|
191
233
|
schema: Schema.Schema<A, I, R>,
|
|
@@ -219,7 +261,15 @@ export const addError: {
|
|
|
219
261
|
* @category annotations
|
|
220
262
|
*/
|
|
221
263
|
export const annotateMerge: {
|
|
264
|
+
/**
|
|
265
|
+
* @since 1.0.0
|
|
266
|
+
* @category annotations
|
|
267
|
+
*/
|
|
222
268
|
<I>(context: Context.Context<I>): <A extends HttpApi.Any>(self: A) => A
|
|
269
|
+
/**
|
|
270
|
+
* @since 1.0.0
|
|
271
|
+
* @category annotations
|
|
272
|
+
*/
|
|
223
273
|
<A extends HttpApi.Any, I>(self: A, context: Context.Context<I>): A
|
|
224
274
|
} = dual(
|
|
225
275
|
2,
|
|
@@ -236,7 +286,15 @@ export const annotateMerge: {
|
|
|
236
286
|
* @category annotations
|
|
237
287
|
*/
|
|
238
288
|
export const annotate: {
|
|
289
|
+
/**
|
|
290
|
+
* @since 1.0.0
|
|
291
|
+
* @category annotations
|
|
292
|
+
*/
|
|
239
293
|
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApi.Any>(self: A) => A
|
|
294
|
+
/**
|
|
295
|
+
* @since 1.0.0
|
|
296
|
+
* @category annotations
|
|
297
|
+
*/
|
|
240
298
|
<A extends HttpApi.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
|
|
241
299
|
} = dual(
|
|
242
300
|
3,
|
package/src/HttpApiBuilder.ts
CHANGED
|
@@ -57,10 +57,28 @@ export class Router extends HttpRouter.Tag("@effect/platform/HttpApiBuilder/Rout
|
|
|
57
57
|
* @category constructors
|
|
58
58
|
*/
|
|
59
59
|
export const serve: {
|
|
60
|
+
/**
|
|
61
|
+
* Build an `HttpApp` from an `HttpApi` instance, and serve it using an
|
|
62
|
+
* `HttpServer`.
|
|
63
|
+
*
|
|
64
|
+
* Optionally, you can provide a middleware function that will be applied to
|
|
65
|
+
* the `HttpApp` before serving.
|
|
66
|
+
*
|
|
67
|
+
* @since 1.0.0
|
|
68
|
+
* @category constructors
|
|
69
|
+
*/
|
|
60
70
|
(): Layer.Layer<never, never, HttpServer.HttpServer | HttpApi.HttpApi.Service | HttpRouter.HttpRouter.DefaultServices>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Build an `HttpApp` from an `HttpApi` instance, and serve it using an
|
|
73
|
+
* `HttpServer`.
|
|
74
|
+
*
|
|
75
|
+
* Optionally, you can provide a middleware function that will be applied to
|
|
76
|
+
* the `HttpApp` before serving.
|
|
77
|
+
*
|
|
78
|
+
* @since 1.0.0
|
|
79
|
+
* @category constructors
|
|
80
|
+
*/
|
|
81
|
+
<R>(middleware: (httpApp: HttpApp.Default) => HttpApp.Default<never, R>): Layer.Layer<
|
|
64
82
|
never,
|
|
65
83
|
never,
|
|
66
84
|
| HttpServer.HttpServer
|
|
@@ -313,6 +331,12 @@ export const group = <
|
|
|
313
331
|
* @category handlers
|
|
314
332
|
*/
|
|
315
333
|
export const handle: {
|
|
334
|
+
/**
|
|
335
|
+
* Add the implementation for an `HttpApiEndpoint` to a `Handlers` group.
|
|
336
|
+
*
|
|
337
|
+
* @since 1.0.0
|
|
338
|
+
* @category handlers
|
|
339
|
+
*/
|
|
316
340
|
<Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, const Name extends Endpoints["name"], E, R>(
|
|
317
341
|
name: Name,
|
|
318
342
|
handler: HttpApiEndpoint.HttpApiEndpoint.HandlerWithName<Endpoints, Name, E, R>
|
|
@@ -321,6 +345,12 @@ export const handle: {
|
|
|
321
345
|
RG | HttpApiEndpoint.HttpApiEndpoint.ExcludeProvided<R>,
|
|
322
346
|
HttpApiEndpoint.HttpApiEndpoint.ExcludeName<Endpoints, Name>
|
|
323
347
|
>
|
|
348
|
+
/**
|
|
349
|
+
* Add the implementation for an `HttpApiEndpoint` to a `Handlers` group.
|
|
350
|
+
*
|
|
351
|
+
* @since 1.0.0
|
|
352
|
+
* @category handlers
|
|
353
|
+
*/
|
|
324
354
|
<Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, const Name extends Endpoints["name"], E, R>(
|
|
325
355
|
name: Name,
|
|
326
356
|
handler: HttpApiEndpoint.HttpApiEndpoint.HandlerResponseWithName<Endpoints, Name, E, R>,
|
|
@@ -436,18 +466,36 @@ const middlewareAddNoContext = (
|
|
|
436
466
|
* @category middleware
|
|
437
467
|
*/
|
|
438
468
|
export const middlewareLayer: {
|
|
469
|
+
/**
|
|
470
|
+
* Create an `HttpApi` level middleware `Layer`.
|
|
471
|
+
*
|
|
472
|
+
* @since 1.0.0
|
|
473
|
+
* @category middleware
|
|
474
|
+
*/
|
|
439
475
|
<EX = never, RX = never>(
|
|
440
476
|
middleware: ApiMiddleware.Fn<never> | Effect.Effect<ApiMiddleware.Fn<never>, EX, RX>,
|
|
441
477
|
options?: {
|
|
442
478
|
readonly withContext?: false | undefined
|
|
443
479
|
}
|
|
444
480
|
): Layer.Layer<never, EX, RX>
|
|
481
|
+
/**
|
|
482
|
+
* Create an `HttpApi` level middleware `Layer`.
|
|
483
|
+
*
|
|
484
|
+
* @since 1.0.0
|
|
485
|
+
* @category middleware
|
|
486
|
+
*/
|
|
445
487
|
<R, EX = never, RX = never>(
|
|
446
488
|
middleware: ApiMiddleware.Fn<never, R> | Effect.Effect<ApiMiddleware.Fn<never, R>, EX, RX>,
|
|
447
489
|
options: {
|
|
448
490
|
readonly withContext: true
|
|
449
491
|
}
|
|
450
492
|
): Layer.Layer<never, EX, HttpRouter.HttpRouter.ExcludeProvided<R> | RX>
|
|
493
|
+
/**
|
|
494
|
+
* Create an `HttpApi` level middleware `Layer`.
|
|
495
|
+
*
|
|
496
|
+
* @since 1.0.0
|
|
497
|
+
* @category middleware
|
|
498
|
+
*/
|
|
451
499
|
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, EX = never, RX = never>(
|
|
452
500
|
api: HttpApi.HttpApi<Groups, Error, ErrorR>,
|
|
453
501
|
middleware: ApiMiddleware.Fn<NoInfer<Error>> | Effect.Effect<ApiMiddleware.Fn<NoInfer<Error>>, EX, RX>,
|
|
@@ -455,6 +503,12 @@ export const middlewareLayer: {
|
|
|
455
503
|
readonly withContext?: false | undefined
|
|
456
504
|
}
|
|
457
505
|
): Layer.Layer<never, EX, RX>
|
|
506
|
+
/**
|
|
507
|
+
* Create an `HttpApi` level middleware `Layer`.
|
|
508
|
+
*
|
|
509
|
+
* @since 1.0.0
|
|
510
|
+
* @category middleware
|
|
511
|
+
*/
|
|
458
512
|
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, R, EX = never, RX = never>(
|
|
459
513
|
api: HttpApi.HttpApi<Groups, Error, ErrorR>,
|
|
460
514
|
middleware: ApiMiddleware.Fn<NoInfer<Error>, R> | Effect.Effect<ApiMiddleware.Fn<NoInfer<Error>, R>, EX, RX>,
|
|
@@ -493,18 +547,39 @@ export const middlewareLayer: {
|
|
|
493
547
|
* @category middleware
|
|
494
548
|
*/
|
|
495
549
|
export const middlewareLayerScoped: {
|
|
550
|
+
/**
|
|
551
|
+
* Create an `HttpApi` level middleware `Layer`, that has a `Scope` provided to
|
|
552
|
+
* the constructor.
|
|
553
|
+
*
|
|
554
|
+
* @since 1.0.0
|
|
555
|
+
* @category middleware
|
|
556
|
+
*/
|
|
496
557
|
<EX, RX>(
|
|
497
558
|
middleware: Effect.Effect<ApiMiddleware.Fn<never>, EX, RX>,
|
|
498
559
|
options?: {
|
|
499
560
|
readonly withContext?: false | undefined
|
|
500
561
|
}
|
|
501
562
|
): Layer.Layer<never, EX, Exclude<RX, Scope>>
|
|
563
|
+
/**
|
|
564
|
+
* Create an `HttpApi` level middleware `Layer`, that has a `Scope` provided to
|
|
565
|
+
* the constructor.
|
|
566
|
+
*
|
|
567
|
+
* @since 1.0.0
|
|
568
|
+
* @category middleware
|
|
569
|
+
*/
|
|
502
570
|
<R, EX, RX>(
|
|
503
571
|
middleware: Effect.Effect<ApiMiddleware.Fn<never, R>, EX, RX>,
|
|
504
572
|
options: {
|
|
505
573
|
readonly withContext: true
|
|
506
574
|
}
|
|
507
575
|
): Layer.Layer<never, EX, HttpRouter.HttpRouter.ExcludeProvided<R> | Exclude<RX, Scope>>
|
|
576
|
+
/**
|
|
577
|
+
* Create an `HttpApi` level middleware `Layer`, that has a `Scope` provided to
|
|
578
|
+
* the constructor.
|
|
579
|
+
*
|
|
580
|
+
* @since 1.0.0
|
|
581
|
+
* @category middleware
|
|
582
|
+
*/
|
|
508
583
|
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, EX, RX>(
|
|
509
584
|
api: HttpApi.HttpApi<Groups, Error, ErrorR>,
|
|
510
585
|
middleware: Effect.Effect<ApiMiddleware.Fn<NoInfer<Error>>, EX, RX>,
|
|
@@ -512,6 +587,13 @@ export const middlewareLayerScoped: {
|
|
|
512
587
|
readonly withContext?: false | undefined
|
|
513
588
|
}
|
|
514
589
|
): Layer.Layer<never, EX, Exclude<RX, Scope>>
|
|
590
|
+
/**
|
|
591
|
+
* Create an `HttpApi` level middleware `Layer`, that has a `Scope` provided to
|
|
592
|
+
* the constructor.
|
|
593
|
+
*
|
|
594
|
+
* @since 1.0.0
|
|
595
|
+
* @category middleware
|
|
596
|
+
*/
|
|
515
597
|
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, R, EX, RX>(
|
|
516
598
|
api: HttpApi.HttpApi<Groups, Error, ErrorR>,
|
|
517
599
|
middleware: Effect.Effect<ApiMiddleware.Fn<NoInfer<Error>, R>, EX, RX>,
|
package/src/HttpApiEndpoint.ts
CHANGED
|
@@ -444,6 +444,13 @@ export const del: <const Name extends string>(
|
|
|
444
444
|
* @category result
|
|
445
445
|
*/
|
|
446
446
|
export const setSuccess: {
|
|
447
|
+
/**
|
|
448
|
+
* Set the schema for the success response of the endpoint. The status code
|
|
449
|
+
* will be inferred from the schema, otherwise it will default to 200.
|
|
450
|
+
*
|
|
451
|
+
* @since 1.0.0
|
|
452
|
+
* @category result
|
|
453
|
+
*/
|
|
447
454
|
<S extends Schema.Schema.Any>(
|
|
448
455
|
schema: S,
|
|
449
456
|
annotations?: {
|
|
@@ -461,6 +468,13 @@ export const setSuccess: {
|
|
|
461
468
|
>(
|
|
462
469
|
self: HttpApiEndpoint<Name, Method, _Path, _P, _H, _S, _E, _R>
|
|
463
470
|
) => HttpApiEndpoint<Name, Method, _Path, _P, _H, Schema.Schema.Type<S>, _E, _R | Schema.Schema.Context<S>>
|
|
471
|
+
/**
|
|
472
|
+
* Set the schema for the success response of the endpoint. The status code
|
|
473
|
+
* will be inferred from the schema, otherwise it will default to 200.
|
|
474
|
+
*
|
|
475
|
+
* @since 1.0.0
|
|
476
|
+
* @category result
|
|
477
|
+
*/
|
|
464
478
|
<
|
|
465
479
|
Name extends string,
|
|
466
480
|
Method extends HttpMethod,
|
|
@@ -513,6 +527,13 @@ export const setSuccess: {
|
|
|
513
527
|
* @category result
|
|
514
528
|
*/
|
|
515
529
|
export const addError: {
|
|
530
|
+
/**
|
|
531
|
+
* Add an error response schema to the endpoint. The status code
|
|
532
|
+
* will be inferred from the schema, otherwise it will default to 500.
|
|
533
|
+
*
|
|
534
|
+
* @since 1.0.0
|
|
535
|
+
* @category result
|
|
536
|
+
*/
|
|
516
537
|
<E extends Schema.Schema.All>(
|
|
517
538
|
schema: E,
|
|
518
539
|
annotations?: {
|
|
@@ -530,6 +551,13 @@ export const addError: {
|
|
|
530
551
|
>(
|
|
531
552
|
self: HttpApiEndpoint<Name, Method, _Path, _P, _H, _S, _E, _R>
|
|
532
553
|
) => HttpApiEndpoint<Name, Method, _Path, _P, _H, _S, _E | Schema.Schema.Type<E>, _R | Schema.Schema.Context<E>>
|
|
554
|
+
/**
|
|
555
|
+
* Add an error response schema to the endpoint. The status code
|
|
556
|
+
* will be inferred from the schema, otherwise it will default to 500.
|
|
557
|
+
*
|
|
558
|
+
* @since 1.0.0
|
|
559
|
+
* @category result
|
|
560
|
+
*/
|
|
533
561
|
<
|
|
534
562
|
Name extends string,
|
|
535
563
|
Method extends HttpMethod,
|
|
@@ -593,9 +621,20 @@ export const addError: {
|
|
|
593
621
|
* @category request
|
|
594
622
|
*/
|
|
595
623
|
export const setPayload: {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
624
|
+
/**
|
|
625
|
+
* Set the schema for the request body of the endpoint. The schema will be
|
|
626
|
+
* used to validate the request body before the handler is called.
|
|
627
|
+
*
|
|
628
|
+
* For endpoints with no request body, the payload will use the url search
|
|
629
|
+
* parameters.
|
|
630
|
+
*
|
|
631
|
+
* You can set a multipart schema to handle file uploads by using the
|
|
632
|
+
* `HttpApiSchema.Multipart` combinator.
|
|
633
|
+
*
|
|
634
|
+
* @since 1.0.0
|
|
635
|
+
* @category request
|
|
636
|
+
*/
|
|
637
|
+
<Method extends HttpMethod, P extends Schema.Schema.All>(schema: P & HttpApiEndpoint.ValidatePayload<Method, P>): <
|
|
599
638
|
Name extends string,
|
|
600
639
|
_Path,
|
|
601
640
|
_P,
|
|
@@ -606,6 +645,19 @@ export const setPayload: {
|
|
|
606
645
|
>(
|
|
607
646
|
self: HttpApiEndpoint<Name, Method, _Path, _P, _H, _S, _E, _R>
|
|
608
647
|
) => HttpApiEndpoint<Name, Method, _Path, Schema.Schema.Type<P>, _H, _S, _E, _R | Schema.Schema.Context<P>>
|
|
648
|
+
/**
|
|
649
|
+
* Set the schema for the request body of the endpoint. The schema will be
|
|
650
|
+
* used to validate the request body before the handler is called.
|
|
651
|
+
*
|
|
652
|
+
* For endpoints with no request body, the payload will use the url search
|
|
653
|
+
* parameters.
|
|
654
|
+
*
|
|
655
|
+
* You can set a multipart schema to handle file uploads by using the
|
|
656
|
+
* `HttpApiSchema.Multipart` combinator.
|
|
657
|
+
*
|
|
658
|
+
* @since 1.0.0
|
|
659
|
+
* @category request
|
|
660
|
+
*/
|
|
609
661
|
<
|
|
610
662
|
Name extends string,
|
|
611
663
|
Method extends HttpMethod,
|
|
@@ -650,9 +702,14 @@ export const setPayload: {
|
|
|
650
702
|
* @category request
|
|
651
703
|
*/
|
|
652
704
|
export const setPath: {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
705
|
+
/**
|
|
706
|
+
* Set the schema for the path parameters of the endpoint. The schema will be
|
|
707
|
+
* used to validate the path parameters before the handler is called.
|
|
708
|
+
*
|
|
709
|
+
* @since 1.0.0
|
|
710
|
+
* @category request
|
|
711
|
+
*/
|
|
712
|
+
<Path extends Schema.Schema.Any>(schema: Path & HttpApiEndpoint.ValidatePath<Path>): <
|
|
656
713
|
Name extends string,
|
|
657
714
|
Method extends HttpMethod,
|
|
658
715
|
_Path,
|
|
@@ -664,6 +721,13 @@ export const setPath: {
|
|
|
664
721
|
>(
|
|
665
722
|
self: HttpApiEndpoint<Name, Method, _Path, _P, _H, _S, _E, _R>
|
|
666
723
|
) => HttpApiEndpoint<Name, Method, Schema.Schema.Type<Path>, _P, _H, _S, _E, _R | Schema.Schema.Context<Path>>
|
|
724
|
+
/**
|
|
725
|
+
* Set the schema for the path parameters of the endpoint. The schema will be
|
|
726
|
+
* used to validate the path parameters before the handler is called.
|
|
727
|
+
*
|
|
728
|
+
* @since 1.0.0
|
|
729
|
+
* @category request
|
|
730
|
+
*/
|
|
667
731
|
<
|
|
668
732
|
Name extends string,
|
|
669
733
|
Method extends HttpMethod,
|
|
@@ -708,9 +772,14 @@ export const setPath: {
|
|
|
708
772
|
* @category request
|
|
709
773
|
*/
|
|
710
774
|
export const setHeaders: {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
775
|
+
/**
|
|
776
|
+
* Set the schema for the headers of the endpoint. The schema will be
|
|
777
|
+
* used to validate the headers before the handler is called.
|
|
778
|
+
*
|
|
779
|
+
* @since 1.0.0
|
|
780
|
+
* @category request
|
|
781
|
+
*/
|
|
782
|
+
<Method extends HttpMethod, H extends Schema.Schema.Any>(schema: H & HttpApiEndpoint.ValidateHeaders<H>): <
|
|
714
783
|
Name extends string,
|
|
715
784
|
_Path,
|
|
716
785
|
_P,
|
|
@@ -721,6 +790,13 @@ export const setHeaders: {
|
|
|
721
790
|
>(
|
|
722
791
|
self: HttpApiEndpoint<Name, Method, _Path, _P, _H, _S, _E, _R>
|
|
723
792
|
) => HttpApiEndpoint<Name, Method, _Path, _P, Schema.Schema.Type<H>, _S, _E, _R | Schema.Schema.Context<H>>
|
|
793
|
+
/**
|
|
794
|
+
* Set the schema for the headers of the endpoint. The schema will be
|
|
795
|
+
* used to validate the headers before the handler is called.
|
|
796
|
+
*
|
|
797
|
+
* @since 1.0.0
|
|
798
|
+
* @category request
|
|
799
|
+
*/
|
|
724
800
|
<
|
|
725
801
|
Name extends string,
|
|
726
802
|
Method extends HttpMethod,
|
|
@@ -764,7 +840,19 @@ export const setHeaders: {
|
|
|
764
840
|
* @category request
|
|
765
841
|
*/
|
|
766
842
|
export const prefix: {
|
|
843
|
+
/**
|
|
844
|
+
* Add a prefix to the path of the endpoint.
|
|
845
|
+
*
|
|
846
|
+
* @since 1.0.0
|
|
847
|
+
* @category request
|
|
848
|
+
*/
|
|
767
849
|
(prefix: HttpRouter.PathInput): <A extends HttpApiEndpoint.All>(self: A) => A
|
|
850
|
+
/**
|
|
851
|
+
* Add a prefix to the path of the endpoint.
|
|
852
|
+
*
|
|
853
|
+
* @since 1.0.0
|
|
854
|
+
* @category request
|
|
855
|
+
*/
|
|
768
856
|
<A extends HttpApiEndpoint.All>(self: A, prefix: HttpRouter.PathInput): A
|
|
769
857
|
} = dual(2, <A extends HttpApiEndpoint.All>(self: A, prefix: HttpRouter.PathInput): A =>
|
|
770
858
|
makeProto({
|
|
@@ -788,7 +876,19 @@ export const schemaSuccess = <A extends HttpApiEndpoint.All>(
|
|
|
788
876
|
* @category annotations
|
|
789
877
|
*/
|
|
790
878
|
export const annotateMerge: {
|
|
879
|
+
/**
|
|
880
|
+
* Merge the annotations of the endpoint with the provided context.
|
|
881
|
+
*
|
|
882
|
+
* @since 1.0.0
|
|
883
|
+
* @category annotations
|
|
884
|
+
*/
|
|
791
885
|
<I>(context: Context.Context<I>): <A extends HttpApiEndpoint.All>(self: A) => A
|
|
886
|
+
/**
|
|
887
|
+
* Merge the annotations of the endpoint with the provided context.
|
|
888
|
+
*
|
|
889
|
+
* @since 1.0.0
|
|
890
|
+
* @category annotations
|
|
891
|
+
*/
|
|
792
892
|
<A extends HttpApiEndpoint.All, I>(self: A, context: Context.Context<I>): A
|
|
793
893
|
} = dual(
|
|
794
894
|
2,
|
|
@@ -806,7 +906,19 @@ export const annotateMerge: {
|
|
|
806
906
|
* @category annotations
|
|
807
907
|
*/
|
|
808
908
|
export const annotate: {
|
|
909
|
+
/**
|
|
910
|
+
* Add an annotation to the endpoint.
|
|
911
|
+
*
|
|
912
|
+
* @since 1.0.0
|
|
913
|
+
* @category annotations
|
|
914
|
+
*/
|
|
809
915
|
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiEndpoint.All>(self: A) => A
|
|
916
|
+
/**
|
|
917
|
+
* Add an annotation to the endpoint.
|
|
918
|
+
*
|
|
919
|
+
* @since 1.0.0
|
|
920
|
+
* @category annotations
|
|
921
|
+
*/
|
|
810
922
|
<A extends HttpApiEndpoint.All, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
|
|
811
923
|
} = dual(
|
|
812
924
|
3,
|