@effect/platform 0.68.6 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +243 -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 +84 -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 +231 -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 +236 -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 +532 -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 +318 -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
package/src/HttpApiError.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import * as ArrayFormatter from "@effect/schema/ArrayFormatter"
|
|
5
|
-
import type * as ParseResult from "@effect/schema/ParseResult"
|
|
6
|
-
import * as Schema from "@effect/schema/Schema"
|
|
7
|
-
import * as TreeFormatter from "@effect/schema/TreeFormatter"
|
|
8
4
|
import * as Effect from "effect/Effect"
|
|
9
5
|
import { identity } from "effect/Function"
|
|
6
|
+
import * as ParseResult from "effect/ParseResult"
|
|
7
|
+
import * as Schema from "effect/Schema"
|
|
10
8
|
import * as HttpApiSchema from "./HttpApiSchema.js"
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -99,8 +97,8 @@ export class HttpApiDecodeError extends Schema.TaggedError<HttpApiDecodeError>()
|
|
|
99
97
|
* @since 1.0.0
|
|
100
98
|
*/
|
|
101
99
|
static fromParseError(error: ParseResult.ParseError): Effect.Effect<HttpApiDecodeError> {
|
|
102
|
-
return ArrayFormatter.formatError(error).pipe(
|
|
103
|
-
Effect.zip(TreeFormatter.formatError(error)),
|
|
100
|
+
return ParseResult.ArrayFormatter.formatError(error).pipe(
|
|
101
|
+
Effect.zip(ParseResult.TreeFormatter.formatError(error)),
|
|
104
102
|
Effect.map(([issues, message]) => new HttpApiDecodeError({ issues, message }))
|
|
105
103
|
)
|
|
106
104
|
}
|
package/src/HttpApiGroup.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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"
|
|
7
|
-
import
|
|
5
|
+
import * as HashMap from "effect/HashMap"
|
|
6
|
+
import * as HashSet from "effect/HashSet"
|
|
8
7
|
import { type Pipeable, pipeArguments } from "effect/Pipeable"
|
|
9
8
|
import * as Predicate from "effect/Predicate"
|
|
10
|
-
import * as
|
|
9
|
+
import * as Schema from "effect/Schema"
|
|
10
|
+
import type * as HttpApiEndpoint from "./HttpApiEndpoint.js"
|
|
11
11
|
import type { HttpApiDecodeError } from "./HttpApiError.js"
|
|
12
|
+
import type * as HttpApiMiddleware from "./HttpApiMiddleware.js"
|
|
12
13
|
import * as HttpApiSchema from "./HttpApiSchema.js"
|
|
13
14
|
import type { PathInput } from "./HttpRouter.js"
|
|
14
15
|
|
|
@@ -40,17 +41,108 @@ export const isHttpApiGroup = (u: unknown): u is HttpApiGroup.Any => Predicate.h
|
|
|
40
41
|
* @category models
|
|
41
42
|
*/
|
|
42
43
|
export interface HttpApiGroup<
|
|
43
|
-
out
|
|
44
|
-
out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.
|
|
44
|
+
out Id extends string,
|
|
45
|
+
out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.Any = never,
|
|
45
46
|
in out Error = HttpApiDecodeError,
|
|
46
|
-
out
|
|
47
|
+
out R = never,
|
|
48
|
+
out TopLevel extends (true | false) = false
|
|
47
49
|
> extends Pipeable {
|
|
48
50
|
new(_: never): {}
|
|
49
51
|
readonly [TypeId]: TypeId
|
|
50
|
-
readonly identifier:
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
52
|
+
readonly identifier: Id
|
|
53
|
+
readonly topLevel: TopLevel
|
|
54
|
+
readonly endpoints: HashMap.HashMap<string, Endpoints>
|
|
55
|
+
readonly errorSchema: Schema.Schema<Error, unknown, R>
|
|
53
56
|
readonly annotations: Context.Context<never>
|
|
57
|
+
readonly middlewares: HashSet.HashSet<HttpApiMiddleware.TagClassAny>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
61
|
+
*/
|
|
62
|
+
add<A extends HttpApiEndpoint.HttpApiEndpoint.Any>(
|
|
63
|
+
endpoint: A
|
|
64
|
+
): HttpApiGroup<Id, Endpoints | A, Error, R, TopLevel>
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
68
|
+
* group.
|
|
69
|
+
*/
|
|
70
|
+
addError<A, I, R>(
|
|
71
|
+
schema: Schema.Schema<A, I, R>,
|
|
72
|
+
annotations?: {
|
|
73
|
+
readonly status?: number | undefined
|
|
74
|
+
}
|
|
75
|
+
): HttpApiGroup<Id, Endpoints, Error | A, R | R, TopLevel>
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
79
|
+
* add the prefix to the endpoints before this api is called.
|
|
80
|
+
*/
|
|
81
|
+
prefix(prefix: PathInput): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Add an `HttpApiMiddleware` to the `HttpApiGroup`.
|
|
85
|
+
*
|
|
86
|
+
* It will be applied to all endpoints in the group.
|
|
87
|
+
*/
|
|
88
|
+
middleware<I extends HttpApiMiddleware.HttpApiMiddleware.AnyId, S>(middleware: Context.Tag<I, S>): HttpApiGroup<
|
|
89
|
+
Id,
|
|
90
|
+
Endpoints,
|
|
91
|
+
Error | HttpApiMiddleware.HttpApiMiddleware.Error<I>,
|
|
92
|
+
R | I | HttpApiMiddleware.HttpApiMiddleware.ErrorContext<I>,
|
|
93
|
+
TopLevel
|
|
94
|
+
>
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Add an `HttpApiMiddleware` to each endpoint in the `HttpApiGroup`.
|
|
98
|
+
*
|
|
99
|
+
* Endpoints added after this api is called will not have the middleware
|
|
100
|
+
* applied.
|
|
101
|
+
*/
|
|
102
|
+
middlewareEndpoints<I extends HttpApiMiddleware.HttpApiMiddleware.AnyId, S>(
|
|
103
|
+
middleware: Context.Tag<I, S>
|
|
104
|
+
): HttpApiGroup<
|
|
105
|
+
Id,
|
|
106
|
+
HttpApiEndpoint.HttpApiEndpoint.AddContext<Endpoints, I>,
|
|
107
|
+
Error,
|
|
108
|
+
R,
|
|
109
|
+
TopLevel
|
|
110
|
+
>
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
114
|
+
*/
|
|
115
|
+
annotateContext<I>(context: Context.Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Add an annotation to an `HttpApiGroup`.
|
|
119
|
+
*/
|
|
120
|
+
annotate<I, S>(tag: Context.Tag<I, S>, value: S): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
124
|
+
* context.
|
|
125
|
+
*
|
|
126
|
+
* Note that this will only update the annotations before this api is called.
|
|
127
|
+
*/
|
|
128
|
+
annotateEndpointsContext<I>(context: Context.Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
132
|
+
*
|
|
133
|
+
* Note that this will only add the annotation to the endpoints before this api
|
|
134
|
+
* is called.
|
|
135
|
+
*/
|
|
136
|
+
annotateEndpoints<I, S>(tag: Context.Tag<I, S>, value: S): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @since 1.0.0
|
|
141
|
+
* @category models
|
|
142
|
+
*/
|
|
143
|
+
export interface Group<Name extends string> {
|
|
144
|
+
readonly _: unique symbol
|
|
145
|
+
readonly name: Name
|
|
54
146
|
}
|
|
55
147
|
|
|
56
148
|
/**
|
|
@@ -62,26 +154,22 @@ export declare namespace HttpApiGroup {
|
|
|
62
154
|
* @since 1.0.0
|
|
63
155
|
* @category models
|
|
64
156
|
*/
|
|
65
|
-
export
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
| HttpApiGroup<any, any, never, never>
|
|
157
|
+
export interface Any {
|
|
158
|
+
readonly [TypeId]: TypeId
|
|
159
|
+
}
|
|
69
160
|
|
|
70
161
|
/**
|
|
71
162
|
* @since 1.0.0
|
|
72
163
|
* @category models
|
|
73
164
|
*/
|
|
74
|
-
export
|
|
75
|
-
readonly _: unique symbol
|
|
76
|
-
readonly name: Name
|
|
77
|
-
}
|
|
165
|
+
export type AnyWithProps = HttpApiGroup<string, HttpApiEndpoint.HttpApiEndpoint.AnyWithProps, any, any, boolean>
|
|
78
166
|
|
|
79
167
|
/**
|
|
80
168
|
* @since 1.0.0
|
|
81
169
|
* @category models
|
|
82
170
|
*/
|
|
83
|
-
export type ToService<
|
|
84
|
-
?
|
|
171
|
+
export type ToService<A> = A extends
|
|
172
|
+
HttpApiGroup<infer Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? Group<Name>
|
|
85
173
|
: never
|
|
86
174
|
|
|
87
175
|
/**
|
|
@@ -94,8 +182,16 @@ export declare namespace HttpApiGroup {
|
|
|
94
182
|
* @since 1.0.0
|
|
95
183
|
* @category models
|
|
96
184
|
*/
|
|
97
|
-
export type
|
|
98
|
-
?
|
|
185
|
+
export type Name<Group> = Group extends
|
|
186
|
+
HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Name
|
|
187
|
+
: never
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @since 1.0.0
|
|
191
|
+
* @category models
|
|
192
|
+
*/
|
|
193
|
+
export type Endpoints<Group> = Group extends
|
|
194
|
+
HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Endpoints
|
|
99
195
|
: never
|
|
100
196
|
|
|
101
197
|
/**
|
|
@@ -108,10 +204,16 @@ export declare namespace HttpApiGroup {
|
|
|
108
204
|
* @since 1.0.0
|
|
109
205
|
* @category models
|
|
110
206
|
*/
|
|
111
|
-
export type Error<Group> = Group extends
|
|
112
|
-
_Error
|
|
207
|
+
export type Error<Group> = Group extends
|
|
208
|
+
HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ? _Error
|
|
113
209
|
: never
|
|
114
210
|
|
|
211
|
+
/**
|
|
212
|
+
* @since 1.0.0
|
|
213
|
+
* @category models
|
|
214
|
+
*/
|
|
215
|
+
export type Provides<Group extends Any> = HttpApiMiddleware.HttpApiMiddleware.ExtractProvides<Context<Group>>
|
|
216
|
+
|
|
115
217
|
/**
|
|
116
218
|
* @since 1.0.0
|
|
117
219
|
* @category models
|
|
@@ -122,8 +224,33 @@ export declare namespace HttpApiGroup {
|
|
|
122
224
|
* @since 1.0.0
|
|
123
225
|
* @category models
|
|
124
226
|
*/
|
|
125
|
-
export type Context<Group> = Group extends
|
|
126
|
-
|
|
227
|
+
export type Context<Group> = Group extends
|
|
228
|
+
HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ?
|
|
229
|
+
| HttpApiMiddleware.HttpApiMiddleware.Only<_R>
|
|
230
|
+
| Exclude<
|
|
231
|
+
HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints>,
|
|
232
|
+
HttpApiMiddleware.HttpApiMiddleware.ExtractProvides<HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints> | _R>
|
|
233
|
+
>
|
|
234
|
+
: never
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @since 1.0.0
|
|
238
|
+
* @category models
|
|
239
|
+
*/
|
|
240
|
+
export type ClientContext<Group> = Group extends
|
|
241
|
+
HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel> ?
|
|
242
|
+
| _R
|
|
243
|
+
| HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints>
|
|
244
|
+
| HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints>
|
|
245
|
+
: never
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @since 1.0.0
|
|
249
|
+
* @category models
|
|
250
|
+
*/
|
|
251
|
+
export type ErrorContext<Group> = Group extends
|
|
252
|
+
HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _R, infer _TopLevel>
|
|
253
|
+
? HttpApiMiddleware.HttpApiMiddleware.Without<_R> | HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints>
|
|
127
254
|
: never
|
|
128
255
|
|
|
129
256
|
/**
|
|
@@ -135,17 +262,129 @@ export declare namespace HttpApiGroup {
|
|
|
135
262
|
|
|
136
263
|
const Proto = {
|
|
137
264
|
[TypeId]: TypeId,
|
|
265
|
+
add<A extends HttpApiEndpoint.HttpApiEndpoint.AnyWithProps>(this: HttpApiGroup.AnyWithProps, endpoint: A) {
|
|
266
|
+
return makeProto({
|
|
267
|
+
identifier: this.identifier,
|
|
268
|
+
topLevel: this.topLevel,
|
|
269
|
+
endpoints: HashMap.set(this.endpoints, endpoint.name, endpoint),
|
|
270
|
+
errorSchema: this.errorSchema,
|
|
271
|
+
annotations: this.annotations,
|
|
272
|
+
middlewares: this.middlewares
|
|
273
|
+
})
|
|
274
|
+
},
|
|
275
|
+
addError<A, I, R>(
|
|
276
|
+
this: HttpApiGroup.AnyWithProps,
|
|
277
|
+
schema: Schema.Schema<A, I, R>,
|
|
278
|
+
annotations?: { readonly status?: number }
|
|
279
|
+
) {
|
|
280
|
+
return makeProto({
|
|
281
|
+
identifier: this.identifier,
|
|
282
|
+
topLevel: this.topLevel,
|
|
283
|
+
endpoints: this.endpoints,
|
|
284
|
+
errorSchema: HttpApiSchema.UnionUnify(
|
|
285
|
+
this.errorSchema,
|
|
286
|
+
schema.annotations(HttpApiSchema.annotations({
|
|
287
|
+
status: annotations?.status ?? HttpApiSchema.getStatusError(schema)
|
|
288
|
+
}))
|
|
289
|
+
),
|
|
290
|
+
annotations: this.annotations,
|
|
291
|
+
middlewares: this.middlewares
|
|
292
|
+
})
|
|
293
|
+
},
|
|
294
|
+
prefix(this: HttpApiGroup.AnyWithProps, prefix: PathInput) {
|
|
295
|
+
return makeProto({
|
|
296
|
+
identifier: this.identifier,
|
|
297
|
+
topLevel: this.topLevel,
|
|
298
|
+
endpoints: HashMap.map(this.endpoints, (endpoint) => endpoint.prefix(prefix)),
|
|
299
|
+
errorSchema: this.errorSchema,
|
|
300
|
+
annotations: this.annotations,
|
|
301
|
+
middlewares: this.middlewares
|
|
302
|
+
})
|
|
303
|
+
},
|
|
304
|
+
middleware(this: HttpApiGroup.AnyWithProps, middleware: HttpApiMiddleware.TagClassAny) {
|
|
305
|
+
return makeProto({
|
|
306
|
+
identifier: this.identifier,
|
|
307
|
+
topLevel: this.topLevel,
|
|
308
|
+
endpoints: this.endpoints,
|
|
309
|
+
errorSchema: HttpApiSchema.UnionUnify(
|
|
310
|
+
this.errorSchema,
|
|
311
|
+
middleware.failure.annotations(HttpApiSchema.annotations({
|
|
312
|
+
status: HttpApiSchema.getStatusError(middleware.failure)
|
|
313
|
+
}) as any)
|
|
314
|
+
),
|
|
315
|
+
annotations: this.annotations,
|
|
316
|
+
middlewares: HashSet.add(this.middlewares, middleware)
|
|
317
|
+
})
|
|
318
|
+
},
|
|
319
|
+
middlewareEndpoints(this: HttpApiGroup.AnyWithProps, middleware: HttpApiMiddleware.TagClassAny) {
|
|
320
|
+
return makeProto({
|
|
321
|
+
identifier: this.identifier,
|
|
322
|
+
topLevel: this.topLevel,
|
|
323
|
+
endpoints: HashMap.map(this.endpoints, (endpoint) => endpoint.middleware(middleware)),
|
|
324
|
+
errorSchema: this.errorSchema,
|
|
325
|
+
annotations: this.annotations,
|
|
326
|
+
middlewares: this.middlewares
|
|
327
|
+
})
|
|
328
|
+
},
|
|
329
|
+
annotateContext<I>(this: HttpApiGroup.AnyWithProps, context: Context.Context<I>) {
|
|
330
|
+
return makeProto({
|
|
331
|
+
identifier: this.identifier,
|
|
332
|
+
topLevel: this.topLevel,
|
|
333
|
+
endpoints: this.endpoints,
|
|
334
|
+
errorSchema: this.errorSchema,
|
|
335
|
+
annotations: Context.merge(this.annotations, context),
|
|
336
|
+
middlewares: this.middlewares
|
|
337
|
+
})
|
|
338
|
+
},
|
|
339
|
+
annotate<I, S>(this: HttpApiGroup.AnyWithProps, tag: Context.Tag<I, S>, value: S) {
|
|
340
|
+
return makeProto({
|
|
341
|
+
identifier: this.identifier,
|
|
342
|
+
topLevel: this.topLevel,
|
|
343
|
+
endpoints: this.endpoints,
|
|
344
|
+
errorSchema: this.errorSchema,
|
|
345
|
+
annotations: Context.add(this.annotations, tag, value),
|
|
346
|
+
middlewares: this.middlewares
|
|
347
|
+
})
|
|
348
|
+
},
|
|
349
|
+
annotateEndpointsContext<I>(this: HttpApiGroup.AnyWithProps, context: Context.Context<I>) {
|
|
350
|
+
return makeProto({
|
|
351
|
+
identifier: this.identifier,
|
|
352
|
+
topLevel: this.topLevel,
|
|
353
|
+
endpoints: HashMap.map(this.endpoints, (endpoint) => endpoint.annotateContext(context)),
|
|
354
|
+
errorSchema: this.errorSchema,
|
|
355
|
+
annotations: this.annotations,
|
|
356
|
+
middlewares: this.middlewares
|
|
357
|
+
})
|
|
358
|
+
},
|
|
359
|
+
annotateEndpoints<I, S>(this: HttpApiGroup.AnyWithProps, tag: Context.Tag<I, S>, value: S) {
|
|
360
|
+
return makeProto({
|
|
361
|
+
identifier: this.identifier,
|
|
362
|
+
topLevel: this.topLevel,
|
|
363
|
+
endpoints: HashMap.map(this.endpoints, (endpoint) => endpoint.annotate(tag, value)),
|
|
364
|
+
errorSchema: this.errorSchema,
|
|
365
|
+
annotations: this.annotations,
|
|
366
|
+
middlewares: this.middlewares
|
|
367
|
+
})
|
|
368
|
+
},
|
|
138
369
|
pipe() {
|
|
139
370
|
return pipeArguments(this, arguments)
|
|
140
371
|
}
|
|
141
372
|
}
|
|
142
373
|
|
|
143
|
-
const makeProto = <
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
374
|
+
const makeProto = <
|
|
375
|
+
Id extends string,
|
|
376
|
+
Endpoints extends HttpApiEndpoint.HttpApiEndpoint.Any,
|
|
377
|
+
Error,
|
|
378
|
+
R,
|
|
379
|
+
TopLevel extends (true | false)
|
|
380
|
+
>(options: {
|
|
381
|
+
readonly identifier: Id
|
|
382
|
+
readonly topLevel: TopLevel
|
|
383
|
+
readonly endpoints: HashMap.HashMap<string, Endpoints>
|
|
384
|
+
readonly errorSchema: Schema.Schema<Error, unknown, R>
|
|
147
385
|
readonly annotations: Context.Context<never>
|
|
148
|
-
|
|
386
|
+
readonly middlewares: HashSet.HashSet<HttpApiMiddleware.TagClassAny>
|
|
387
|
+
}): HttpApiGroup<Id, Endpoints, Error, R, TopLevel> => {
|
|
149
388
|
function HttpApiGroup() {}
|
|
150
389
|
Object.setPrototypeOf(HttpApiGroup, Proto)
|
|
151
390
|
return Object.assign(HttpApiGroup, options) as any
|
|
@@ -160,301 +399,14 @@ const makeProto = <Name extends string, Endpoints extends HttpApiEndpoint.HttpAp
|
|
|
160
399
|
* @since 1.0.0
|
|
161
400
|
* @category constructors
|
|
162
401
|
*/
|
|
163
|
-
export const make = <
|
|
402
|
+
export const make = <const Id extends string, const TopLevel extends (true | false) = false>(identifier: Id, options?: {
|
|
403
|
+
readonly topLevel?: TopLevel | undefined
|
|
404
|
+
}): HttpApiGroup<Id, never, never, never, TopLevel> =>
|
|
164
405
|
makeProto({
|
|
165
406
|
identifier,
|
|
166
|
-
|
|
407
|
+
topLevel: options?.topLevel ?? false as any,
|
|
408
|
+
endpoints: HashMap.empty(),
|
|
167
409
|
errorSchema: Schema.Never as any,
|
|
168
|
-
annotations: Context.empty()
|
|
410
|
+
annotations: Context.empty(),
|
|
411
|
+
middlewares: HashSet.empty()
|
|
169
412
|
})
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
173
|
-
*
|
|
174
|
-
* @since 1.0.0
|
|
175
|
-
* @category endpoints
|
|
176
|
-
*/
|
|
177
|
-
export const add: {
|
|
178
|
-
/**
|
|
179
|
-
* Add an `HttpApiEndpoint` to an `HttpApiGroup`.
|
|
180
|
-
*
|
|
181
|
-
* @since 1.0.0
|
|
182
|
-
* @category endpoints
|
|
183
|
-
*/
|
|
184
|
-
<A extends HttpApiEndpoint.HttpApiEndpoint.All>(
|
|
185
|
-
endpoint: A
|
|
186
|
-
): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
187
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
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
|
-
*/
|
|
195
|
-
<
|
|
196
|
-
Name extends string,
|
|
197
|
-
Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All,
|
|
198
|
-
Error,
|
|
199
|
-
ErrorR,
|
|
200
|
-
A extends HttpApiEndpoint.HttpApiEndpoint.All
|
|
201
|
-
>(self: HttpApiGroup<Name, Endpoints, Error, ErrorR>, endpoint: A): HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
|
|
202
|
-
} = dual(2, <
|
|
203
|
-
Name extends string,
|
|
204
|
-
Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All,
|
|
205
|
-
Error,
|
|
206
|
-
ErrorR,
|
|
207
|
-
A extends HttpApiEndpoint.HttpApiEndpoint.All
|
|
208
|
-
>(
|
|
209
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
210
|
-
endpoint: A
|
|
211
|
-
): HttpApiGroup<Name, Endpoints | A, Error, ErrorR> =>
|
|
212
|
-
makeProto({
|
|
213
|
-
identifier: self.identifier,
|
|
214
|
-
errorSchema: self.errorSchema,
|
|
215
|
-
annotations: self.annotations,
|
|
216
|
-
endpoints: Chunk.append(self.endpoints, endpoint)
|
|
217
|
-
}))
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
|
|
221
|
-
* group.
|
|
222
|
-
*
|
|
223
|
-
* @since 1.0.0
|
|
224
|
-
* @category errors
|
|
225
|
-
*/
|
|
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
|
-
*/
|
|
234
|
-
<A, I, R>(
|
|
235
|
-
schema: Schema.Schema<A, I, R>,
|
|
236
|
-
annotations?: {
|
|
237
|
-
readonly status?: number | undefined
|
|
238
|
-
}
|
|
239
|
-
): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
240
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
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
|
-
*/
|
|
249
|
-
<Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A, I, R>(
|
|
250
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
251
|
-
schema: Schema.Schema<A, I, R>,
|
|
252
|
-
annotations?: {
|
|
253
|
-
readonly status?: number | undefined
|
|
254
|
-
}
|
|
255
|
-
): HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>
|
|
256
|
-
} = dual(
|
|
257
|
-
(args) => isHttpApiGroup(args[0]),
|
|
258
|
-
<Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A, I, R>(
|
|
259
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
260
|
-
schema: Schema.Schema<A, I, R>,
|
|
261
|
-
annotations?: {
|
|
262
|
-
readonly status?: number | undefined
|
|
263
|
-
}
|
|
264
|
-
): HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R> =>
|
|
265
|
-
makeProto({
|
|
266
|
-
identifier: self.identifier,
|
|
267
|
-
annotations: self.annotations,
|
|
268
|
-
endpoints: self.endpoints,
|
|
269
|
-
errorSchema: HttpApiSchema.UnionUnify(
|
|
270
|
-
self.errorSchema,
|
|
271
|
-
schema.annotations(HttpApiSchema.annotations({
|
|
272
|
-
status: annotations?.status ?? HttpApiSchema.getStatusError(schema)
|
|
273
|
-
}))
|
|
274
|
-
)
|
|
275
|
-
})
|
|
276
|
-
)
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
|
|
280
|
-
* add the prefix to the endpoints before this api is called.
|
|
281
|
-
*
|
|
282
|
-
* @since 1.0.0
|
|
283
|
-
* @category endpoints
|
|
284
|
-
*/
|
|
285
|
-
export const prefix: {
|
|
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>(
|
|
294
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
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
|
-
*/
|
|
303
|
-
<Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
304
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
305
|
-
prefix: PathInput
|
|
306
|
-
): HttpApiGroup<Name, Endpoints, Error, ErrorR>
|
|
307
|
-
} = dual(2, <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
|
|
308
|
-
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
|
|
309
|
-
prefix: PathInput
|
|
310
|
-
): HttpApiGroup<Name, Endpoints, Error, ErrorR> =>
|
|
311
|
-
makeProto({
|
|
312
|
-
identifier: self.identifier,
|
|
313
|
-
errorSchema: self.errorSchema,
|
|
314
|
-
annotations: self.annotations,
|
|
315
|
-
endpoints: Chunk.map(self.endpoints, HttpApiEndpoint.prefix(prefix))
|
|
316
|
-
}))
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Merge the annotations of an `HttpApiGroup` with a new context.
|
|
320
|
-
*
|
|
321
|
-
* @since 1.0.0
|
|
322
|
-
* @category annotations
|
|
323
|
-
*/
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
338
|
-
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
|
|
339
|
-
} = dual(
|
|
340
|
-
2,
|
|
341
|
-
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A =>
|
|
342
|
-
makeProto({
|
|
343
|
-
...self as any,
|
|
344
|
-
annotations: Context.merge(self.annotations, context)
|
|
345
|
-
}) as A
|
|
346
|
-
)
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Add an annotation to an `HttpApiGroup`.
|
|
350
|
-
*
|
|
351
|
-
* @since 1.0.0
|
|
352
|
-
* @category annotations
|
|
353
|
-
*/
|
|
354
|
-
export const annotate: {
|
|
355
|
-
/**
|
|
356
|
-
* Add an annotation to an `HttpApiGroup`.
|
|
357
|
-
*
|
|
358
|
-
* @since 1.0.0
|
|
359
|
-
* @category annotations
|
|
360
|
-
*/
|
|
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
|
-
*/
|
|
368
|
-
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
|
|
369
|
-
} = dual(
|
|
370
|
-
3,
|
|
371
|
-
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A =>
|
|
372
|
-
makeProto({
|
|
373
|
-
identifier: self.identifier,
|
|
374
|
-
errorSchema: self.errorSchema as any,
|
|
375
|
-
endpoints: self.endpoints,
|
|
376
|
-
annotations: Context.add(self.annotations, tag, value)
|
|
377
|
-
}) as A
|
|
378
|
-
)
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* For each endpoint in an `HttpApiGroup`, update the annotations with a new
|
|
382
|
-
* context.
|
|
383
|
-
*
|
|
384
|
-
* Note that this will only update the annotations before this api is called.
|
|
385
|
-
*
|
|
386
|
-
* @since 1.0.0
|
|
387
|
-
* @category annotations
|
|
388
|
-
*/
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
409
|
-
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
|
|
410
|
-
} = dual(
|
|
411
|
-
2,
|
|
412
|
-
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A =>
|
|
413
|
-
makeProto({
|
|
414
|
-
identifier: self.identifier,
|
|
415
|
-
errorSchema: self.errorSchema as any,
|
|
416
|
-
annotations: self.annotations,
|
|
417
|
-
endpoints: Chunk.map(self.endpoints, HttpApiEndpoint.annotateMerge(context))
|
|
418
|
-
}) as A
|
|
419
|
-
)
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* For each endpoint in an `HttpApiGroup`, add an annotation.
|
|
423
|
-
*
|
|
424
|
-
* Note that this will only add the annotation to the endpoints before this api
|
|
425
|
-
* is called.
|
|
426
|
-
*
|
|
427
|
-
* @since 1.0.0
|
|
428
|
-
* @category annotations
|
|
429
|
-
*/
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
450
|
-
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
|
|
451
|
-
} = dual(
|
|
452
|
-
3,
|
|
453
|
-
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A =>
|
|
454
|
-
makeProto({
|
|
455
|
-
identifier: self.identifier,
|
|
456
|
-
errorSchema: self.errorSchema as any,
|
|
457
|
-
annotations: self.annotations,
|
|
458
|
-
endpoints: Chunk.map(self.endpoints, HttpApiEndpoint.annotate(tag, value))
|
|
459
|
-
}) as A
|
|
460
|
-
)
|