@effect/platform 0.66.1 → 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/OpenApiJsonSchema.js +40 -27
- package/dist/cjs/OpenApiJsonSchema.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/OpenApiJsonSchema.js +40 -27
- package/dist/esm/OpenApiJsonSchema.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/OpenApiJsonSchema.ts +39 -21
- 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/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,
|
package/src/HttpApiGroup.ts
CHANGED
|
@@ -175,21 +175,30 @@ export const make = <Name extends string>(identifier: Name): HttpApiGroup<Name>
|
|
|
175
175
|
* @category endpoints
|
|
176
176
|
*/
|
|
177
177
|
export const add: {
|
|
178
|
+
/**
|
|
179
|
+
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
180
|
+
*
|
|
181
|
+
* @since 1.0.0
|
|
182
|
+
* @category endpoints
|
|
183
|
+
*/
|
|
178
184
|
<A extends HttpApiEndpoint.HttpApiEndpoint.All>(
|
|
179
185
|
endpoint: A
|
|
180
186
|
): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
181
187
|
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
182
188
|
) => HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
|
|
189
|
+
/**
|
|
190
|
+
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
191
|
+
*
|
|
192
|
+
* @since 1.0.0
|
|
193
|
+
* @category endpoints
|
|
194
|
+
*/
|
|
183
195
|
<
|
|
184
196
|
Name extends string,
|
|
185
197
|
Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All,
|
|
186
198
|
Error,
|
|
187
199
|
ErrorR,
|
|
188
200
|
A extends HttpApiEndpoint.HttpApiEndpoint.All
|
|
189
|
-
>(
|
|
190
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
191
|
-
endpoint: A
|
|
192
|
-
): HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
|
|
201
|
+
>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>, endpoint: A): HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
|
|
193
202
|
} = dual(2, <
|
|
194
203
|
Name extends string,
|
|
195
204
|
Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All,
|
|
@@ -215,6 +224,13 @@ export const add: {
|
|
|
215
224
|
* @category errors
|
|
216
225
|
*/
|
|
217
226
|
export const addError: {
|
|
227
|
+
/**
|
|
228
|
+
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
229
|
+
* group.
|
|
230
|
+
*
|
|
231
|
+
* @since 1.0.0
|
|
232
|
+
* @category errors
|
|
233
|
+
*/
|
|
218
234
|
<A, I, R>(
|
|
219
235
|
schema: Schema.Schema<A, I, R>,
|
|
220
236
|
annotations?: {
|
|
@@ -223,6 +239,13 @@ export const addError: {
|
|
|
223
239
|
): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
224
240
|
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
225
241
|
) => HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>
|
|
242
|
+
/**
|
|
243
|
+
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
244
|
+
* group.
|
|
245
|
+
*
|
|
246
|
+
* @since 1.0.0
|
|
247
|
+
* @category errors
|
|
248
|
+
*/
|
|
226
249
|
<Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A, I, R>(
|
|
227
250
|
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
228
251
|
schema: Schema.Schema<A, I, R>,
|
|
@@ -260,11 +283,23 @@ export const addError: {
|
|
|
260
283
|
* @category endpoints
|
|
261
284
|
*/
|
|
262
285
|
export const prefix: {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
288
|
+
* add the prefix to the endpoints before this api is called.
|
|
289
|
+
*
|
|
290
|
+
* @since 1.0.0
|
|
291
|
+
* @category endpoints
|
|
292
|
+
*/
|
|
293
|
+
(prefix: PathInput): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
266
294
|
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
267
295
|
) => HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
296
|
+
/**
|
|
297
|
+
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
298
|
+
* add the prefix to the endpoints before this api is called.
|
|
299
|
+
*
|
|
300
|
+
* @since 1.0.0
|
|
301
|
+
* @category endpoints
|
|
302
|
+
*/
|
|
268
303
|
<Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
269
304
|
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
270
305
|
prefix: PathInput
|
|
@@ -287,7 +322,19 @@ export const prefix: {
|
|
|
287
322
|
* @category annotations
|
|
288
323
|
*/
|
|
289
324
|
export const annotateMerge: {
|
|
325
|
+
/**
|
|
326
|
+
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
327
|
+
*
|
|
328
|
+
* @since 1.0.0
|
|
329
|
+
* @category annotations
|
|
330
|
+
*/
|
|
290
331
|
<I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A
|
|
332
|
+
/**
|
|
333
|
+
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
334
|
+
*
|
|
335
|
+
* @since 1.0.0
|
|
336
|
+
* @category annotations
|
|
337
|
+
*/
|
|
291
338
|
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
|
|
292
339
|
} = dual(
|
|
293
340
|
2,
|
|
@@ -305,7 +352,19 @@ export const annotateMerge: {
|
|
|
305
352
|
* @category annotations
|
|
306
353
|
*/
|
|
307
354
|
export const annotate: {
|
|
355
|
+
/**
|
|
356
|
+
* Add an annotation to an `HttpApiGroup`.
|
|
357
|
+
*
|
|
358
|
+
* @since 1.0.0
|
|
359
|
+
* @category annotations
|
|
360
|
+
*/
|
|
308
361
|
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A
|
|
362
|
+
/**
|
|
363
|
+
* Add an annotation to an `HttpApiGroup`.
|
|
364
|
+
*
|
|
365
|
+
* @since 1.0.0
|
|
366
|
+
* @category annotations
|
|
367
|
+
*/
|
|
309
368
|
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
|
|
310
369
|
} = dual(
|
|
311
370
|
3,
|
|
@@ -328,7 +387,25 @@ export const annotate: {
|
|
|
328
387
|
* @category annotations
|
|
329
388
|
*/
|
|
330
389
|
export const annotateEndpointsMerge: {
|
|
390
|
+
/**
|
|
391
|
+
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
392
|
+
* context.
|
|
393
|
+
*
|
|
394
|
+
* Note that this will only update the annotations before this api is called.
|
|
395
|
+
*
|
|
396
|
+
* @since 1.0.0
|
|
397
|
+
* @category annotations
|
|
398
|
+
*/
|
|
331
399
|
<I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A
|
|
400
|
+
/**
|
|
401
|
+
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
402
|
+
* context.
|
|
403
|
+
*
|
|
404
|
+
* Note that this will only update the annotations before this api is called.
|
|
405
|
+
*
|
|
406
|
+
* @since 1.0.0
|
|
407
|
+
* @category annotations
|
|
408
|
+
*/
|
|
332
409
|
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
|
|
333
410
|
} = dual(
|
|
334
411
|
2,
|
|
@@ -351,7 +428,25 @@ export const annotateEndpointsMerge: {
|
|
|
351
428
|
* @category annotations
|
|
352
429
|
*/
|
|
353
430
|
export const annotateEndpoints: {
|
|
431
|
+
/**
|
|
432
|
+
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
433
|
+
*
|
|
434
|
+
* Note that this will only add the annotation to the endpoints before this api
|
|
435
|
+
* is called.
|
|
436
|
+
*
|
|
437
|
+
* @since 1.0.0
|
|
438
|
+
* @category annotations
|
|
439
|
+
*/
|
|
354
440
|
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A
|
|
441
|
+
/**
|
|
442
|
+
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
443
|
+
*
|
|
444
|
+
* Note that this will only add the annotation to the endpoints before this api
|
|
445
|
+
* is called.
|
|
446
|
+
*
|
|
447
|
+
* @since 1.0.0
|
|
448
|
+
* @category annotations
|
|
449
|
+
*/
|
|
355
450
|
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
|
|
356
451
|
} = dual(
|
|
357
452
|
3,
|
package/src/HttpApiSchema.ts
CHANGED
|
@@ -181,10 +181,20 @@ export interface asEmpty<
|
|
|
181
181
|
* @category empty response
|
|
182
182
|
*/
|
|
183
183
|
export const asEmpty: {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
/**
|
|
185
|
+
* @since 1.0.0
|
|
186
|
+
* @category empty response
|
|
187
|
+
*/
|
|
188
|
+
<S extends Schema.Schema.Any>(
|
|
189
|
+
options: {
|
|
190
|
+
readonly status: number
|
|
191
|
+
readonly decode: LazyArg<Schema.Schema.Type<S>>
|
|
192
|
+
}
|
|
193
|
+
): (self: S) => asEmpty<S>
|
|
194
|
+
/**
|
|
195
|
+
* @since 1.0.0
|
|
196
|
+
* @category empty response
|
|
197
|
+
*/
|
|
188
198
|
<S extends Schema.Schema.Any>(
|
|
189
199
|
self: S,
|
|
190
200
|
options: {
|
|
@@ -335,12 +345,20 @@ export declare namespace Encoding {
|
|
|
335
345
|
* @category encoding
|
|
336
346
|
*/
|
|
337
347
|
export const withEncoding: {
|
|
348
|
+
/**
|
|
349
|
+
* @since 1.0.0
|
|
350
|
+
* @category encoding
|
|
351
|
+
*/
|
|
338
352
|
<A extends Schema.Schema.Any, Kind extends Encoding["kind"]>(
|
|
339
353
|
options: {
|
|
340
354
|
readonly kind: Kind
|
|
341
355
|
readonly contentType?: string | undefined
|
|
342
356
|
} & Encoding.Validate<A, Kind>
|
|
343
357
|
): (self: A) => A
|
|
358
|
+
/**
|
|
359
|
+
* @since 1.0.0
|
|
360
|
+
* @category encoding
|
|
361
|
+
*/
|
|
344
362
|
<A extends Schema.Schema.Any, Kind extends Encoding["kind"]>(
|
|
345
363
|
self: A,
|
|
346
364
|
options: {
|
package/src/HttpApiSecurity.ts
CHANGED
|
@@ -141,7 +141,15 @@ export const basic: Basic = Object.assign(Object.create(Proto), {
|
|
|
141
141
|
* @category annotations
|
|
142
142
|
*/
|
|
143
143
|
export const annotateMerge: {
|
|
144
|
+
/**
|
|
145
|
+
* @since 1.0.0
|
|
146
|
+
* @category annotations
|
|
147
|
+
*/
|
|
144
148
|
<I>(context: Context.Context<I>): <A extends HttpApiSecurity>(self: A) => A
|
|
149
|
+
/**
|
|
150
|
+
* @since 1.0.0
|
|
151
|
+
* @category annotations
|
|
152
|
+
*/
|
|
145
153
|
<A extends HttpApiSecurity, I>(self: A, context: Context.Context<I>): A
|
|
146
154
|
} = dual(
|
|
147
155
|
2,
|
|
@@ -157,7 +165,15 @@ export const annotateMerge: {
|
|
|
157
165
|
* @category annotations
|
|
158
166
|
*/
|
|
159
167
|
export const annotate: {
|
|
168
|
+
/**
|
|
169
|
+
* @since 1.0.0
|
|
170
|
+
* @category annotations
|
|
171
|
+
*/
|
|
160
172
|
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiSecurity>(self: A) => A
|
|
173
|
+
/**
|
|
174
|
+
* @since 1.0.0
|
|
175
|
+
* @category annotations
|
|
176
|
+
*/
|
|
161
177
|
<A extends HttpApiSecurity, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
|
|
162
178
|
} = dual(
|
|
163
179
|
3,
|
package/src/HttpApp.ts
CHANGED
|
@@ -136,7 +136,15 @@ export const appendPreResponseHandler: (handler: PreResponseHandler) => Effect.E
|
|
|
136
136
|
* @category fiber refs
|
|
137
137
|
*/
|
|
138
138
|
export const withPreResponseHandler = dual<
|
|
139
|
+
/**
|
|
140
|
+
* @since 1.0.0
|
|
141
|
+
* @category fiber refs
|
|
142
|
+
*/
|
|
139
143
|
(handler: PreResponseHandler) => <A, E, R>(self: HttpApp<A, E, R>) => HttpApp<A, E, R>,
|
|
144
|
+
/**
|
|
145
|
+
* @since 1.0.0
|
|
146
|
+
* @category fiber refs
|
|
147
|
+
*/
|
|
140
148
|
<A, E, R>(self: HttpApp<A, E, R>, handler: PreResponseHandler) => HttpApp<A, E, R>
|
|
141
149
|
>(2, (self, handler) =>
|
|
142
150
|
Effect.locallyWith(
|