@effect/platform 0.68.6 → 0.69.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HttpApiMiddleware/package.json +6 -0
- package/README.md +306 -233
- package/dist/cjs/Headers.js +7 -2
- package/dist/cjs/Headers.js.map +1 -1
- package/dist/cjs/HttpApi.js +90 -78
- package/dist/cjs/HttpApi.js.map +1 -1
- package/dist/cjs/HttpApiBuilder.js +245 -255
- package/dist/cjs/HttpApiBuilder.js.map +1 -1
- package/dist/cjs/HttpApiClient.js +64 -59
- package/dist/cjs/HttpApiClient.js.map +1 -1
- package/dist/cjs/HttpApiEndpoint.js +74 -109
- package/dist/cjs/HttpApiEndpoint.js.map +1 -1
- package/dist/cjs/HttpApiError.js +3 -4
- package/dist/cjs/HttpApiError.js.map +1 -1
- package/dist/cjs/HttpApiGroup.js +103 -100
- package/dist/cjs/HttpApiGroup.js.map +1 -1
- package/dist/cjs/HttpApiMiddleware.js +67 -0
- package/dist/cjs/HttpApiMiddleware.js.map +1 -0
- package/dist/cjs/HttpApiSchema.js +33 -7
- package/dist/cjs/HttpApiSchema.js.map +1 -1
- package/dist/cjs/HttpApiSecurity.js +2 -2
- package/dist/cjs/HttpApiSecurity.js.map +1 -1
- package/dist/cjs/HttpApiSwagger.js +3 -1
- package/dist/cjs/HttpApiSwagger.js.map +1 -1
- package/dist/cjs/HttpBody.js.map +1 -1
- package/dist/cjs/HttpIncomingMessage.js +5 -1
- package/dist/cjs/HttpIncomingMessage.js.map +1 -1
- package/dist/cjs/HttpServer.js +12 -1
- package/dist/cjs/HttpServer.js.map +1 -1
- package/dist/cjs/HttpServerRespondable.js +1 -1
- package/dist/cjs/HttpServerRespondable.js.map +1 -1
- package/dist/cjs/OpenApi.js +102 -63
- package/dist/cjs/OpenApi.js.map +1 -1
- package/dist/cjs/OpenApiJsonSchema.js +58 -47
- package/dist/cjs/OpenApiJsonSchema.js.map +1 -1
- package/dist/cjs/Transferable.js +2 -2
- package/dist/cjs/Transferable.js.map +1 -1
- package/dist/cjs/UrlParams.js +5 -1
- package/dist/cjs/UrlParams.js.map +1 -1
- package/dist/cjs/Worker.js.map +1 -1
- package/dist/cjs/WorkerError.js +1 -5
- package/dist/cjs/WorkerError.js.map +1 -1
- package/dist/cjs/WorkerRunner.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/internal/httpBody.js +1 -1
- package/dist/cjs/internal/httpBody.js.map +1 -1
- package/dist/cjs/internal/httpClientRequest.js.map +1 -1
- package/dist/cjs/internal/httpClientResponse.js +1 -1
- package/dist/cjs/internal/httpClientResponse.js.map +1 -1
- package/dist/cjs/internal/httpRouter.js +1 -1
- package/dist/cjs/internal/httpRouter.js.map +1 -1
- package/dist/cjs/internal/httpServer.js +7 -1
- package/dist/cjs/internal/httpServer.js.map +1 -1
- package/dist/cjs/internal/httpServerRequest.js +1 -1
- package/dist/cjs/internal/httpServerRequest.js.map +1 -1
- package/dist/cjs/internal/httpServerResponse.js.map +1 -1
- package/dist/cjs/internal/keyValueStore.js +1 -1
- package/dist/cjs/internal/keyValueStore.js.map +1 -1
- package/dist/cjs/internal/multipart.js +1 -1
- package/dist/cjs/internal/multipart.js.map +1 -1
- package/dist/cjs/internal/worker.js +6 -7
- package/dist/cjs/internal/worker.js.map +1 -1
- package/dist/cjs/internal/workerRunner.js +3 -4
- package/dist/cjs/internal/workerRunner.js.map +1 -1
- package/dist/dts/Headers.d.ts +4 -6
- package/dist/dts/Headers.d.ts.map +1 -1
- package/dist/dts/HttpApi.d.ts +64 -140
- package/dist/dts/HttpApi.d.ts.map +1 -1
- package/dist/dts/HttpApiBuilder.d.ts +86 -167
- package/dist/dts/HttpApiBuilder.d.ts.map +1 -1
- package/dist/dts/HttpApiClient.d.ts +34 -11
- package/dist/dts/HttpApiClient.d.ts.map +1 -1
- package/dist/dts/HttpApiEndpoint.d.ts +119 -273
- package/dist/dts/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/dts/HttpApiError.d.ts +5 -2
- package/dist/dts/HttpApiError.d.ts.map +1 -1
- package/dist/dts/HttpApiGroup.d.ts +96 -194
- package/dist/dts/HttpApiGroup.d.ts.map +1 -1
- package/dist/dts/HttpApiMiddleware.d.ts +228 -0
- package/dist/dts/HttpApiMiddleware.d.ts.map +1 -0
- package/dist/dts/HttpApiSchema.d.ts +6 -2
- package/dist/dts/HttpApiSchema.d.ts.map +1 -1
- package/dist/dts/HttpApiSecurity.d.ts +1 -1
- package/dist/dts/HttpApiSecurity.d.ts.map +1 -1
- package/dist/dts/HttpApiSwagger.d.ts +2 -2
- package/dist/dts/HttpApiSwagger.d.ts.map +1 -1
- package/dist/dts/HttpBody.d.ts +2 -2
- package/dist/dts/HttpBody.d.ts.map +1 -1
- package/dist/dts/HttpClientRequest.d.ts +2 -2
- package/dist/dts/HttpClientRequest.d.ts.map +1 -1
- package/dist/dts/HttpClientResponse.d.ts +3 -3
- package/dist/dts/HttpClientResponse.d.ts.map +1 -1
- package/dist/dts/HttpIncomingMessage.d.ts +3 -3
- package/dist/dts/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/dts/HttpRouter.d.ts +3 -3
- package/dist/dts/HttpRouter.d.ts.map +1 -1
- package/dist/dts/HttpServer.d.ts +15 -0
- package/dist/dts/HttpServer.d.ts.map +1 -1
- package/dist/dts/HttpServerRequest.d.ts +3 -3
- package/dist/dts/HttpServerRequest.d.ts.map +1 -1
- package/dist/dts/HttpServerRespondable.d.ts.map +1 -1
- package/dist/dts/HttpServerResponse.d.ts +2 -2
- package/dist/dts/HttpServerResponse.d.ts.map +1 -1
- package/dist/dts/KeyValueStore.d.ts +2 -2
- package/dist/dts/KeyValueStore.d.ts.map +1 -1
- package/dist/dts/Multipart.d.ts +3 -3
- package/dist/dts/Multipart.d.ts.map +1 -1
- package/dist/dts/OpenApi.d.ts +17 -39
- package/dist/dts/OpenApi.d.ts.map +1 -1
- package/dist/dts/OpenApiJsonSchema.d.ts +10 -5
- package/dist/dts/OpenApiJsonSchema.d.ts.map +1 -1
- package/dist/dts/Transferable.d.ts +4 -1
- package/dist/dts/Transferable.d.ts.map +1 -1
- package/dist/dts/UrlParams.d.ts +3 -6
- package/dist/dts/UrlParams.d.ts.map +1 -1
- package/dist/dts/Worker.d.ts +7 -8
- package/dist/dts/Worker.d.ts.map +1 -1
- package/dist/dts/WorkerError.d.ts +1 -1
- package/dist/dts/WorkerError.d.ts.map +1 -1
- package/dist/dts/WorkerRunner.d.ts +2 -3
- package/dist/dts/WorkerRunner.d.ts.map +1 -1
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/httpRouter.d.ts.map +1 -1
- package/dist/esm/Headers.js +7 -2
- package/dist/esm/Headers.js.map +1 -1
- package/dist/esm/HttpApi.js +88 -77
- package/dist/esm/HttpApi.js.map +1 -1
- package/dist/esm/HttpApiBuilder.js +238 -244
- package/dist/esm/HttpApiBuilder.js.map +1 -1
- package/dist/esm/HttpApiClient.js +64 -59
- package/dist/esm/HttpApiClient.js.map +1 -1
- package/dist/esm/HttpApiEndpoint.js +73 -106
- package/dist/esm/HttpApiEndpoint.js.map +1 -1
- package/dist/esm/HttpApiError.js +3 -4
- package/dist/esm/HttpApiError.js.map +1 -1
- package/dist/esm/HttpApiGroup.js +102 -99
- package/dist/esm/HttpApiGroup.js.map +1 -1
- package/dist/esm/HttpApiMiddleware.js +56 -0
- package/dist/esm/HttpApiMiddleware.js.map +1 -0
- package/dist/esm/HttpApiSchema.js +31 -5
- package/dist/esm/HttpApiSchema.js.map +1 -1
- package/dist/esm/HttpApiSecurity.js +1 -1
- package/dist/esm/HttpApiSecurity.js.map +1 -1
- package/dist/esm/HttpApiSwagger.js +4 -2
- package/dist/esm/HttpApiSwagger.js.map +1 -1
- package/dist/esm/HttpBody.js.map +1 -1
- package/dist/esm/HttpIncomingMessage.js +4 -1
- package/dist/esm/HttpIncomingMessage.js.map +1 -1
- package/dist/esm/HttpServer.js +11 -0
- package/dist/esm/HttpServer.js.map +1 -1
- package/dist/esm/HttpServerRespondable.js +1 -1
- package/dist/esm/HttpServerRespondable.js.map +1 -1
- package/dist/esm/OpenApi.js +97 -59
- package/dist/esm/OpenApi.js.map +1 -1
- package/dist/esm/OpenApiJsonSchema.js +56 -46
- package/dist/esm/OpenApiJsonSchema.js.map +1 -1
- package/dist/esm/Transferable.js +2 -2
- package/dist/esm/Transferable.js.map +1 -1
- package/dist/esm/UrlParams.js +4 -1
- package/dist/esm/UrlParams.js.map +1 -1
- package/dist/esm/Worker.js.map +1 -1
- package/dist/esm/WorkerError.js +1 -4
- package/dist/esm/WorkerError.js.map +1 -1
- package/dist/esm/WorkerRunner.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/httpBody.js +1 -1
- package/dist/esm/internal/httpBody.js.map +1 -1
- package/dist/esm/internal/httpClientRequest.js.map +1 -1
- package/dist/esm/internal/httpClientResponse.js +1 -1
- package/dist/esm/internal/httpClientResponse.js.map +1 -1
- package/dist/esm/internal/httpRouter.js +1 -1
- package/dist/esm/internal/httpRouter.js.map +1 -1
- package/dist/esm/internal/httpServer.js +6 -0
- package/dist/esm/internal/httpServer.js.map +1 -1
- package/dist/esm/internal/httpServerRequest.js +1 -1
- package/dist/esm/internal/httpServerRequest.js.map +1 -1
- package/dist/esm/internal/httpServerResponse.js.map +1 -1
- package/dist/esm/internal/keyValueStore.js +1 -1
- package/dist/esm/internal/keyValueStore.js.map +1 -1
- package/dist/esm/internal/multipart.js +1 -1
- package/dist/esm/internal/multipart.js.map +1 -1
- package/dist/esm/internal/worker.js +6 -7
- package/dist/esm/internal/worker.js.map +1 -1
- package/dist/esm/internal/workerRunner.js +3 -4
- package/dist/esm/internal/workerRunner.js.map +1 -1
- package/package.json +10 -3
- package/src/Headers.ts +12 -4
- package/src/HttpApi.ts +183 -258
- package/src/HttpApiBuilder.ts +534 -481
- package/src/HttpApiClient.ts +163 -112
- package/src/HttpApiEndpoint.ts +443 -564
- package/src/HttpApiError.ts +4 -6
- package/src/HttpApiGroup.ts +277 -325
- package/src/HttpApiMiddleware.ts +317 -0
- package/src/HttpApiSchema.ts +39 -2
- package/src/HttpApiSecurity.ts +1 -1
- package/src/HttpApiSwagger.ts +3 -3
- package/src/HttpBody.ts +2 -2
- package/src/HttpClientRequest.ts +2 -2
- package/src/HttpClientResponse.ts +3 -3
- package/src/HttpIncomingMessage.ts +3 -3
- package/src/HttpRouter.ts +3 -3
- package/src/HttpServer.ts +21 -0
- package/src/HttpServerRequest.ts +3 -3
- package/src/HttpServerRespondable.ts +1 -1
- package/src/HttpServerResponse.ts +2 -2
- package/src/KeyValueStore.ts +2 -2
- package/src/Multipart.ts +3 -3
- package/src/OpenApi.ts +113 -104
- package/src/OpenApiJsonSchema.ts +67 -53
- package/src/Transferable.ts +2 -2
- package/src/UrlParams.ts +3 -3
- package/src/Worker.ts +7 -8
- package/src/WorkerError.ts +1 -1
- package/src/WorkerRunner.ts +2 -3
- package/src/index.ts +5 -0
- package/src/internal/httpBody.ts +2 -2
- package/src/internal/httpClientRequest.ts +2 -2
- package/src/internal/httpClientResponse.ts +3 -3
- package/src/internal/httpRouter.ts +2 -2
- package/src/internal/httpServer.ts +13 -0
- package/src/internal/httpServerRequest.ts +3 -3
- package/src/internal/httpServerResponse.ts +2 -2
- package/src/internal/keyValueStore.ts +1 -1
- package/src/internal/multipart.ts +3 -3
- package/src/internal/worker.ts +6 -7
- package/src/internal/workerRunner.ts +3 -4
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import * as Schema from "@effect/schema/Schema";
|
|
5
|
-
import * as Chunk from "effect/Chunk";
|
|
6
4
|
import * as Context from "effect/Context";
|
|
5
|
+
import * as HashMap from "effect/HashMap";
|
|
6
|
+
import * as HashSet from "effect/HashSet";
|
|
7
7
|
import { type Pipeable } from "effect/Pipeable";
|
|
8
|
-
import * as
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
9
|
+
import type * as HttpApiEndpoint from "./HttpApiEndpoint.js";
|
|
9
10
|
import type { HttpApiDecodeError } from "./HttpApiError.js";
|
|
11
|
+
import type * as HttpApiMiddleware from "./HttpApiMiddleware.js";
|
|
10
12
|
import type { PathInput } from "./HttpRouter.js";
|
|
11
13
|
/**
|
|
12
14
|
* @since 1.0.0
|
|
@@ -32,265 +34,165 @@ export declare const isHttpApiGroup: (u: unknown) => u is HttpApiGroup.Any;
|
|
|
32
34
|
* @since 1.0.0
|
|
33
35
|
* @category models
|
|
34
36
|
*/
|
|
35
|
-
export interface HttpApiGroup<out
|
|
37
|
+
export interface HttpApiGroup<out Id extends string, out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.Any = never, in out Error = HttpApiDecodeError, out R = never, out TopLevel extends (true | false) = false> extends Pipeable {
|
|
36
38
|
new (_: never): {};
|
|
37
39
|
readonly [TypeId]: TypeId;
|
|
38
|
-
readonly identifier:
|
|
39
|
-
readonly
|
|
40
|
-
readonly
|
|
40
|
+
readonly identifier: Id;
|
|
41
|
+
readonly topLevel: TopLevel;
|
|
42
|
+
readonly endpoints: HashMap.HashMap<string, Endpoints>;
|
|
43
|
+
readonly errorSchema: Schema.Schema<Error, unknown, R>;
|
|
41
44
|
readonly annotations: Context.Context<never>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @since 1.0.0
|
|
45
|
-
* @category models
|
|
46
|
-
*/
|
|
47
|
-
export declare namespace HttpApiGroup {
|
|
45
|
+
readonly middlewares: HashSet.HashSet<HttpApiMiddleware.TagClassAny>;
|
|
48
46
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @category models
|
|
51
|
-
*/
|
|
52
|
-
type Any = HttpApiGroup<any, any, any, any> | HttpApiGroup<any, any, any, never> | HttpApiGroup<any, any, never, never>;
|
|
53
|
-
/**
|
|
54
|
-
* @since 1.0.0
|
|
55
|
-
* @category models
|
|
47
|
+
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
56
48
|
*/
|
|
57
|
-
|
|
58
|
-
readonly _: unique symbol;
|
|
59
|
-
readonly name: Name;
|
|
60
|
-
}
|
|
49
|
+
add<A extends HttpApiEndpoint.HttpApiEndpoint.Any>(endpoint: A): HttpApiGroup<Id, Endpoints | A, Error, R, TopLevel>;
|
|
61
50
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
51
|
+
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
52
|
+
* group.
|
|
64
53
|
*/
|
|
65
|
-
|
|
54
|
+
addError<A, I, R>(schema: Schema.Schema<A, I, R>, annotations?: {
|
|
55
|
+
readonly status?: number | undefined;
|
|
56
|
+
}): HttpApiGroup<Id, Endpoints, Error | A, R | R, TopLevel>;
|
|
66
57
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
58
|
+
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
59
|
+
* add the prefix to the endpoints before this api is called.
|
|
69
60
|
*/
|
|
70
|
-
|
|
71
|
-
readonly identifier: Name;
|
|
72
|
-
}>;
|
|
61
|
+
prefix(prefix: PathInput): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
|
|
73
62
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
63
|
+
* Add an `HttpApiMiddleware` to the `HttpApiGroup`.
|
|
64
|
+
*
|
|
65
|
+
* It will be applied to all endpoints in the group.
|
|
76
66
|
*/
|
|
77
|
-
|
|
67
|
+
middleware<I extends HttpApiMiddleware.HttpApiMiddleware.AnyId, S>(middleware: Context.Tag<I, S>): HttpApiGroup<Id, Endpoints, Error | HttpApiMiddleware.HttpApiMiddleware.Error<I>, R | I | HttpApiMiddleware.HttpApiMiddleware.ErrorContext<I>, TopLevel>;
|
|
78
68
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
69
|
+
* Add an `HttpApiMiddleware` to each endpoint in the `HttpApiGroup`.
|
|
70
|
+
*
|
|
71
|
+
* Endpoints added after this api is called will not have the middleware
|
|
72
|
+
* applied.
|
|
81
73
|
*/
|
|
82
|
-
|
|
74
|
+
middlewareEndpoints<I extends HttpApiMiddleware.HttpApiMiddleware.AnyId, S>(middleware: Context.Tag<I, S>): HttpApiGroup<Id, HttpApiEndpoint.HttpApiEndpoint.AddContext<Endpoints, I>, Error, R, TopLevel>;
|
|
83
75
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @category models
|
|
76
|
+
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
86
77
|
*/
|
|
87
|
-
|
|
78
|
+
annotateContext<I>(context: Context.Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
|
|
88
79
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @category models
|
|
80
|
+
* Add an annotation to an `HttpApiGroup`.
|
|
91
81
|
*/
|
|
92
|
-
|
|
82
|
+
annotate<I, S>(tag: Context.Tag<I, S>, value: S): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
|
|
93
83
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
84
|
+
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
85
|
+
* context.
|
|
86
|
+
*
|
|
87
|
+
* Note that this will only update the annotations before this api is called.
|
|
96
88
|
*/
|
|
97
|
-
|
|
89
|
+
annotateEndpointsContext<I>(context: Context.Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
|
|
98
90
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
91
|
+
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
92
|
+
*
|
|
93
|
+
* Note that this will only add the annotation to the endpoints before this api
|
|
94
|
+
* is called.
|
|
101
95
|
*/
|
|
102
|
-
|
|
96
|
+
annotateEndpoints<I, S>(tag: Context.Tag<I, S>, value: S): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
|
|
103
97
|
}
|
|
104
98
|
/**
|
|
105
|
-
* An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to
|
|
106
|
-
* represent a portion of your domain.
|
|
107
|
-
*
|
|
108
|
-
* The endpoints can be implemented later using the `HttpApiBuilder.group` api.
|
|
109
|
-
*
|
|
110
99
|
* @since 1.0.0
|
|
111
|
-
* @category
|
|
100
|
+
* @category models
|
|
112
101
|
*/
|
|
113
|
-
export
|
|
102
|
+
export interface Group<Name extends string> {
|
|
103
|
+
readonly _: unique symbol;
|
|
104
|
+
readonly name: Name;
|
|
105
|
+
}
|
|
114
106
|
/**
|
|
115
|
-
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
116
|
-
*
|
|
117
107
|
* @since 1.0.0
|
|
118
|
-
* @category
|
|
108
|
+
* @category models
|
|
119
109
|
*/
|
|
120
|
-
export declare
|
|
110
|
+
export declare namespace HttpApiGroup {
|
|
121
111
|
/**
|
|
122
|
-
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
123
|
-
*
|
|
124
112
|
* @since 1.0.0
|
|
125
|
-
* @category
|
|
113
|
+
* @category models
|
|
126
114
|
*/
|
|
127
|
-
|
|
115
|
+
interface Any {
|
|
116
|
+
readonly [TypeId]: TypeId;
|
|
117
|
+
}
|
|
128
118
|
/**
|
|
129
|
-
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
130
|
-
*
|
|
131
119
|
* @since 1.0.0
|
|
132
|
-
* @category
|
|
120
|
+
* @category models
|
|
133
121
|
*/
|
|
134
|
-
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
138
|
-
* group.
|
|
139
|
-
*
|
|
140
|
-
* @since 1.0.0
|
|
141
|
-
* @category errors
|
|
142
|
-
*/
|
|
143
|
-
export declare const addError: {
|
|
122
|
+
type AnyWithProps = HttpApiGroup<string, HttpApiEndpoint.HttpApiEndpoint.AnyWithProps, any, any, boolean>;
|
|
144
123
|
/**
|
|
145
|
-
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
146
|
-
* group.
|
|
147
|
-
*
|
|
148
124
|
* @since 1.0.0
|
|
149
|
-
* @category
|
|
125
|
+
* @category models
|
|
150
126
|
*/
|
|
151
|
-
<A,
|
|
152
|
-
readonly status?: number | undefined;
|
|
153
|
-
}): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>) => HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>;
|
|
127
|
+
type ToService<A> = A extends HttpApiGroup<infer Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? Group<Name> : never;
|
|
154
128
|
/**
|
|
155
|
-
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
156
|
-
* group.
|
|
157
|
-
*
|
|
158
129
|
* @since 1.0.0
|
|
159
|
-
* @category
|
|
130
|
+
* @category models
|
|
160
131
|
*/
|
|
161
|
-
<Name extends string
|
|
162
|
-
readonly
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
167
|
-
* add the prefix to the endpoints before this api is called.
|
|
168
|
-
*
|
|
169
|
-
* @since 1.0.0
|
|
170
|
-
* @category endpoints
|
|
171
|
-
*/
|
|
172
|
-
export declare const prefix: {
|
|
132
|
+
type WithName<Group, Name extends string> = Extract<Group, {
|
|
133
|
+
readonly identifier: Name;
|
|
134
|
+
}>;
|
|
173
135
|
/**
|
|
174
|
-
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
175
|
-
* add the prefix to the endpoints before this api is called.
|
|
176
|
-
*
|
|
177
136
|
* @since 1.0.0
|
|
178
|
-
* @category
|
|
137
|
+
* @category models
|
|
179
138
|
*/
|
|
180
|
-
|
|
139
|
+
type Name<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Name : never;
|
|
181
140
|
/**
|
|
182
|
-
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
183
|
-
* add the prefix to the endpoints before this api is called.
|
|
184
|
-
*
|
|
185
141
|
* @since 1.0.0
|
|
186
|
-
* @category
|
|
142
|
+
* @category models
|
|
187
143
|
*/
|
|
188
|
-
<
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
192
|
-
*
|
|
193
|
-
* @since 1.0.0
|
|
194
|
-
* @category annotations
|
|
195
|
-
*/
|
|
196
|
-
export declare const annotateMerge: {
|
|
144
|
+
type Endpoints<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Endpoints : never;
|
|
197
145
|
/**
|
|
198
|
-
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
199
|
-
*
|
|
200
146
|
* @since 1.0.0
|
|
201
|
-
* @category
|
|
147
|
+
* @category models
|
|
202
148
|
*/
|
|
203
|
-
|
|
149
|
+
type EndpointsWithName<Group extends Any, Name extends string> = Endpoints<WithName<Group, Name>>;
|
|
204
150
|
/**
|
|
205
|
-
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
206
|
-
*
|
|
207
151
|
* @since 1.0.0
|
|
208
|
-
* @category
|
|
152
|
+
* @category models
|
|
209
153
|
*/
|
|
210
|
-
<
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Add an annotation to an `HttpApiGroup`.
|
|
214
|
-
*
|
|
215
|
-
* @since 1.0.0
|
|
216
|
-
* @category annotations
|
|
217
|
-
*/
|
|
218
|
-
export declare const annotate: {
|
|
154
|
+
type Error<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Error : never;
|
|
219
155
|
/**
|
|
220
|
-
* Add an annotation to an `HttpApiGroup`.
|
|
221
|
-
*
|
|
222
156
|
* @since 1.0.0
|
|
223
|
-
* @category
|
|
157
|
+
* @category models
|
|
224
158
|
*/
|
|
225
|
-
|
|
159
|
+
type Provides<Group extends Any> = HttpApiMiddleware.HttpApiMiddleware.ExtractProvides<Context<Group>>;
|
|
226
160
|
/**
|
|
227
|
-
* Add an annotation to an `HttpApiGroup`.
|
|
228
|
-
*
|
|
229
161
|
* @since 1.0.0
|
|
230
|
-
* @category
|
|
162
|
+
* @category models
|
|
231
163
|
*/
|
|
232
|
-
<
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
236
|
-
* context.
|
|
237
|
-
*
|
|
238
|
-
* Note that this will only update the annotations before this api is called.
|
|
239
|
-
*
|
|
240
|
-
* @since 1.0.0
|
|
241
|
-
* @category annotations
|
|
242
|
-
*/
|
|
243
|
-
export declare const annotateEndpointsMerge: {
|
|
164
|
+
type ErrorWithName<Group extends Any, Name extends string> = Error<WithName<Group, Name>>;
|
|
244
165
|
/**
|
|
245
|
-
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
246
|
-
* context.
|
|
247
|
-
*
|
|
248
|
-
* Note that this will only update the annotations before this api is called.
|
|
249
|
-
*
|
|
250
166
|
* @since 1.0.0
|
|
251
|
-
* @category
|
|
167
|
+
* @category models
|
|
252
168
|
*/
|
|
253
|
-
|
|
169
|
+
type Context<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? HttpApiMiddleware.HttpApiMiddleware.Only<_R> | Exclude<HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints>, HttpApiMiddleware.HttpApiMiddleware.ExtractProvides<HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints> | _R>> : never;
|
|
254
170
|
/**
|
|
255
|
-
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
256
|
-
* context.
|
|
257
|
-
*
|
|
258
|
-
* Note that this will only update the annotations before this api is called.
|
|
259
|
-
*
|
|
260
171
|
* @since 1.0.0
|
|
261
|
-
* @category
|
|
172
|
+
* @category models
|
|
262
173
|
*/
|
|
263
|
-
<
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
267
|
-
*
|
|
268
|
-
* Note that this will only add the annotation to the endpoints before this api
|
|
269
|
-
* is called.
|
|
270
|
-
*
|
|
271
|
-
* @since 1.0.0
|
|
272
|
-
* @category annotations
|
|
273
|
-
*/
|
|
274
|
-
export declare const annotateEndpoints: {
|
|
174
|
+
type ClientContext<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _R | HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints> | HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints> : never;
|
|
275
175
|
/**
|
|
276
|
-
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
277
|
-
*
|
|
278
|
-
* Note that this will only add the annotation to the endpoints before this api
|
|
279
|
-
* is called.
|
|
280
|
-
*
|
|
281
176
|
* @since 1.0.0
|
|
282
|
-
* @category
|
|
177
|
+
* @category models
|
|
283
178
|
*/
|
|
284
|
-
<
|
|
179
|
+
type ErrorContext<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? HttpApiMiddleware.HttpApiMiddleware.Without<_R> | HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints> : never;
|
|
285
180
|
/**
|
|
286
|
-
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
287
|
-
*
|
|
288
|
-
* Note that this will only add the annotation to the endpoints before this api
|
|
289
|
-
* is called.
|
|
290
|
-
*
|
|
291
181
|
* @since 1.0.0
|
|
292
|
-
* @category
|
|
182
|
+
* @category models
|
|
293
183
|
*/
|
|
294
|
-
<
|
|
295
|
-
}
|
|
184
|
+
type ContextWithName<Group extends Any, Name extends string> = Context<WithName<Group, Name>>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to
|
|
188
|
+
* represent a portion of your domain.
|
|
189
|
+
*
|
|
190
|
+
* The endpoints can be implemented later using the `HttpApiBuilder.group` api.
|
|
191
|
+
*
|
|
192
|
+
* @since 1.0.0
|
|
193
|
+
* @category constructors
|
|
194
|
+
*/
|
|
195
|
+
export declare const make: <const Id extends string, const TopLevel extends (true | false) = false>(identifier: Id, options?: {
|
|
196
|
+
readonly topLevel?: TopLevel | undefined;
|
|
197
|
+
}) => HttpApiGroup<Id, never, never, never, TopLevel>;
|
|
296
198
|
//# sourceMappingURL=HttpApiGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpApiGroup.d.ts","sourceRoot":"","sources":["../../src/HttpApiGroup.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"HttpApiGroup.d.ts","sourceRoot":"","sources":["../../src/HttpApiGroup.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,iBAAiB,CAAA;AAE9D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,eAAe,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAAoD,CAAA;AAEhF;;;GAGG;AACH,MAAM,MAAM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AC,CAAA;CACrG;AAoID;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,SAAU,EAAE,SAAS,MAAM,QAAQ,QAAQ,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC,sBAAsB,EAAE,YAAY;IACrH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CACzC,KAAG,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAQ9C,CAAA"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import type * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import type { Simplify } from "effect/Types";
|
|
8
|
+
import type * as HttpApiSecurity from "./HttpApiSecurity.js";
|
|
9
|
+
import type * as HttpRouter from "./HttpRouter.js";
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category type ids
|
|
13
|
+
*/
|
|
14
|
+
export declare const TypeId: unique symbol;
|
|
15
|
+
/**
|
|
16
|
+
* @since 1.0.0
|
|
17
|
+
* @category type ids
|
|
18
|
+
*/
|
|
19
|
+
export type TypeId = typeof TypeId;
|
|
20
|
+
/**
|
|
21
|
+
* @since 1.0.0
|
|
22
|
+
* @category type ids
|
|
23
|
+
*/
|
|
24
|
+
export declare const SecurityTypeId: unique symbol;
|
|
25
|
+
/**
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
* @category type ids
|
|
28
|
+
*/
|
|
29
|
+
export type SecurityTypeId = typeof SecurityTypeId;
|
|
30
|
+
/**
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
* @category guards
|
|
33
|
+
*/
|
|
34
|
+
export declare const isSecurity: (u: TagClassAny) => u is TagClassSecurityAny;
|
|
35
|
+
/**
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
* @category models
|
|
38
|
+
*/
|
|
39
|
+
export interface HttpApiMiddleware<Provides, E> extends Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided> {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @since 1.0.0
|
|
43
|
+
* @category models
|
|
44
|
+
*/
|
|
45
|
+
export type HttpApiMiddlewareSecurity<Security extends Record<string, HttpApiSecurity.HttpApiSecurity>, Provides, E> = {
|
|
46
|
+
readonly [K in keyof Security]: (_: HttpApiSecurity.HttpApiSecurity.Type<Security[K]>) => Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
* @category models
|
|
51
|
+
*/
|
|
52
|
+
export declare namespace HttpApiMiddleware {
|
|
53
|
+
/**
|
|
54
|
+
* @since 1.0.0
|
|
55
|
+
* @category models
|
|
56
|
+
*/
|
|
57
|
+
interface Any {
|
|
58
|
+
readonly [TypeId]: TypeId;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
* @category models
|
|
63
|
+
*/
|
|
64
|
+
interface AnyId {
|
|
65
|
+
readonly [TypeId]: {
|
|
66
|
+
readonly provides: any;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
* @category models
|
|
72
|
+
*/
|
|
73
|
+
type Provides<A> = A extends {
|
|
74
|
+
readonly [TypeId]: {
|
|
75
|
+
readonly provides: infer P;
|
|
76
|
+
};
|
|
77
|
+
} ? P : never;
|
|
78
|
+
/**
|
|
79
|
+
* @since 1.0.0
|
|
80
|
+
* @category models
|
|
81
|
+
*/
|
|
82
|
+
type ExtractProvides<A> = Provides<Only<A>>;
|
|
83
|
+
/**
|
|
84
|
+
* @since 1.0.0
|
|
85
|
+
* @category models
|
|
86
|
+
*/
|
|
87
|
+
type Error<A> = A extends {
|
|
88
|
+
readonly [TypeId]: {
|
|
89
|
+
readonly failure: infer E;
|
|
90
|
+
};
|
|
91
|
+
} ? E : never;
|
|
92
|
+
/**
|
|
93
|
+
* @since 1.0.0
|
|
94
|
+
* @category models
|
|
95
|
+
*/
|
|
96
|
+
type ErrorContext<A> = A extends {
|
|
97
|
+
readonly [TypeId]: {
|
|
98
|
+
readonly failureContext: infer R;
|
|
99
|
+
};
|
|
100
|
+
} ? R : never;
|
|
101
|
+
/**
|
|
102
|
+
* @since 1.0.0
|
|
103
|
+
* @category models
|
|
104
|
+
*/
|
|
105
|
+
type Only<R> = Extract<R, AnyId>;
|
|
106
|
+
/**
|
|
107
|
+
* @since 1.0.0
|
|
108
|
+
* @category models
|
|
109
|
+
*/
|
|
110
|
+
type Without<R> = Exclude<R, AnyId>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @since 1.0.0
|
|
114
|
+
* @category models
|
|
115
|
+
*/
|
|
116
|
+
export type TagClass<Self, Name extends string, Options> = Options extends {
|
|
117
|
+
readonly security: Record<string, HttpApiSecurity.HttpApiSecurity>;
|
|
118
|
+
} ? TagClass.BaseSecurity<Self, Name, Options, Simplify<HttpApiMiddlewareSecurity<Options["security"], TagClass.Service<Options>, TagClass.FailureService<Options>>>, Options["security"]> : TagClass.Base<Self, Name, Options, HttpApiMiddleware<TagClass.Service<Options>, TagClass.FailureService<Options>>>;
|
|
119
|
+
/**
|
|
120
|
+
* @since 1.0.0
|
|
121
|
+
* @category models
|
|
122
|
+
*/
|
|
123
|
+
export declare namespace TagClass {
|
|
124
|
+
/**
|
|
125
|
+
* @since 1.0.0
|
|
126
|
+
* @category models
|
|
127
|
+
*/
|
|
128
|
+
type Provides<Options> = Options extends {
|
|
129
|
+
readonly provides: Context.Tag<any, any>;
|
|
130
|
+
readonly optional?: false;
|
|
131
|
+
} ? Context.Tag.Identifier<Options["provides"]> : never;
|
|
132
|
+
/**
|
|
133
|
+
* @since 1.0.0
|
|
134
|
+
* @category models
|
|
135
|
+
*/
|
|
136
|
+
type Service<Options> = Options extends {
|
|
137
|
+
readonly provides: Context.Tag<any, any>;
|
|
138
|
+
} ? Context.Tag.Service<Options["provides"]> : void;
|
|
139
|
+
/**
|
|
140
|
+
* @since 1.0.0
|
|
141
|
+
* @category models
|
|
142
|
+
*/
|
|
143
|
+
type FailureSchema<Options> = Options extends {
|
|
144
|
+
readonly failure: Schema.Schema.All;
|
|
145
|
+
readonly optional?: false;
|
|
146
|
+
} ? Options["failure"] : typeof Schema.Never;
|
|
147
|
+
/**
|
|
148
|
+
* @since 1.0.0
|
|
149
|
+
* @category models
|
|
150
|
+
*/
|
|
151
|
+
type Failure<Options> = Options extends {
|
|
152
|
+
readonly failure: Schema.Schema<infer _A, infer _I, infer _R>;
|
|
153
|
+
readonly optional?: false;
|
|
154
|
+
} ? _A : never;
|
|
155
|
+
/**
|
|
156
|
+
* @since 1.0.0
|
|
157
|
+
* @category models
|
|
158
|
+
*/
|
|
159
|
+
type FailureContext<Options> = Schema.Schema.Context<FailureSchema<Options>>;
|
|
160
|
+
/**
|
|
161
|
+
* @since 1.0.0
|
|
162
|
+
* @category models
|
|
163
|
+
*/
|
|
164
|
+
type FailureService<Options> = Optional<Options> extends true ? unknown : Failure<Options>;
|
|
165
|
+
/**
|
|
166
|
+
* @since 1.0.0
|
|
167
|
+
* @category models
|
|
168
|
+
*/
|
|
169
|
+
type Optional<Options> = Options extends {
|
|
170
|
+
readonly optional: true;
|
|
171
|
+
} ? true : false;
|
|
172
|
+
/**
|
|
173
|
+
* @since 1.0.0
|
|
174
|
+
* @category models
|
|
175
|
+
*/
|
|
176
|
+
interface Base<Self, Name extends string, Options, Service> extends Context.Tag<Self, Service> {
|
|
177
|
+
new (_: never): Context.TagClassShape<Name, Service> & {
|
|
178
|
+
readonly [TypeId]: {
|
|
179
|
+
readonly provides: Provides<Options>;
|
|
180
|
+
readonly failure: Failure<Options>;
|
|
181
|
+
readonly failureContext: FailureContext<Options>;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
readonly [TypeId]: TypeId;
|
|
185
|
+
readonly optional: Optional<Options>;
|
|
186
|
+
readonly failure: FailureSchema<Options>;
|
|
187
|
+
readonly provides: Options extends {
|
|
188
|
+
readonly provides: Context.Tag<any, any>;
|
|
189
|
+
} ? Options["provides"] : undefined;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* @since 1.0.0
|
|
193
|
+
* @category models
|
|
194
|
+
*/
|
|
195
|
+
interface BaseSecurity<Self, Name extends string, Options, Service, Security extends Record<string, HttpApiSecurity.HttpApiSecurity>> extends Base<Self, Name, Options, Service> {
|
|
196
|
+
readonly [SecurityTypeId]: SecurityTypeId;
|
|
197
|
+
readonly security: Security;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @since 1.0.0
|
|
202
|
+
* @category models
|
|
203
|
+
*/
|
|
204
|
+
export interface TagClassAny extends Context.Tag<any, HttpApiMiddleware.Any> {
|
|
205
|
+
readonly [TypeId]: TypeId;
|
|
206
|
+
readonly optional: boolean;
|
|
207
|
+
readonly provides?: Context.Tag<any, any>;
|
|
208
|
+
readonly failure: Schema.Schema.All;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @since 1.0.0
|
|
212
|
+
* @category models
|
|
213
|
+
*/
|
|
214
|
+
export interface TagClassSecurityAny extends TagClassAny {
|
|
215
|
+
readonly [SecurityTypeId]: SecurityTypeId;
|
|
216
|
+
readonly security: Record<string, HttpApiSecurity.HttpApiSecurity>;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @since 1.0.0
|
|
220
|
+
* @category tags
|
|
221
|
+
*/
|
|
222
|
+
export declare const Tag: <Self>() => <const Name extends string, const Options extends {
|
|
223
|
+
readonly optional?: boolean;
|
|
224
|
+
readonly failure?: Schema.Schema.All;
|
|
225
|
+
readonly provides?: Context.Tag<any, any>;
|
|
226
|
+
readonly security?: Record<string, HttpApiSecurity.HttpApiSecurity>;
|
|
227
|
+
}>(id: Name, options?: Options | undefined) => TagClass<Self, Name, Options>;
|
|
228
|
+
//# sourceMappingURL=HttpApiMiddleware.d.ts.map
|