@effect/platform 0.62.5 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/HttpApi/package.json +6 -0
  2. package/HttpApiBuilder/package.json +6 -0
  3. package/HttpApiClient/package.json +6 -0
  4. package/HttpApiEndpoint/package.json +6 -0
  5. package/HttpApiError/package.json +6 -0
  6. package/HttpApiGroup/package.json +6 -0
  7. package/HttpApiSchema/package.json +6 -0
  8. package/HttpApiSecurity/package.json +6 -0
  9. package/HttpApiSwagger/package.json +6 -0
  10. package/OpenApi/package.json +6 -0
  11. package/README.md +863 -302
  12. package/dist/cjs/HttpApi.js +168 -0
  13. package/dist/cjs/HttpApi.js.map +1 -0
  14. package/dist/cjs/HttpApiBuilder.js +471 -0
  15. package/dist/cjs/HttpApiBuilder.js.map +1 -0
  16. package/dist/cjs/HttpApiClient.js +134 -0
  17. package/dist/cjs/HttpApiClient.js.map +1 -0
  18. package/dist/cjs/HttpApiEndpoint.js +181 -0
  19. package/dist/cjs/HttpApiEndpoint.js.map +1 -0
  20. package/dist/cjs/HttpApiError.js +69 -0
  21. package/dist/cjs/HttpApiError.js.map +1 -0
  22. package/dist/cjs/HttpApiGroup.js +151 -0
  23. package/dist/cjs/HttpApiGroup.js.map +1 -0
  24. package/dist/cjs/HttpApiSchema.js +241 -0
  25. package/dist/cjs/HttpApiSchema.js.map +1 -0
  26. package/dist/cjs/HttpApiSecurity.js +83 -0
  27. package/dist/cjs/HttpApiSecurity.js.map +1 -0
  28. package/dist/cjs/HttpApiSwagger.js +50 -0
  29. package/dist/cjs/HttpApiSwagger.js.map +1 -0
  30. package/dist/cjs/HttpMethod.js +1 -1
  31. package/dist/cjs/HttpMethod.js.map +1 -1
  32. package/dist/cjs/HttpRouter.js +6 -1
  33. package/dist/cjs/HttpRouter.js.map +1 -1
  34. package/dist/cjs/OpenApi.js +317 -0
  35. package/dist/cjs/OpenApi.js.map +1 -0
  36. package/dist/cjs/index.js +21 -1
  37. package/dist/cjs/internal/apiSwagger.js +2 -0
  38. package/dist/cjs/internal/apiSwagger.js.map +1 -0
  39. package/dist/cjs/internal/httpRouter.js +6 -1
  40. package/dist/cjs/internal/httpRouter.js.map +1 -1
  41. package/dist/cjs/internal/multipart.js +5 -1
  42. package/dist/cjs/internal/multipart.js.map +1 -1
  43. package/dist/dts/HttpApi.d.ts +156 -0
  44. package/dist/dts/HttpApi.d.ts.map +1 -0
  45. package/dist/dts/HttpApiBuilder.d.ts +296 -0
  46. package/dist/dts/HttpApiBuilder.d.ts.map +1 -0
  47. package/dist/dts/HttpApiClient.d.ts +31 -0
  48. package/dist/dts/HttpApiClient.d.ts.map +1 -0
  49. package/dist/dts/HttpApiEndpoint.d.ts +350 -0
  50. package/dist/dts/HttpApiEndpoint.d.ts.map +1 -0
  51. package/dist/dts/HttpApiError.d.ts +70 -0
  52. package/dist/dts/HttpApiError.d.ts.map +1 -0
  53. package/dist/dts/HttpApiGroup.d.ts +196 -0
  54. package/dist/dts/HttpApiGroup.d.ts.map +1 -0
  55. package/dist/dts/HttpApiSchema.d.ts +223 -0
  56. package/dist/dts/HttpApiSchema.d.ts.map +1 -0
  57. package/dist/dts/HttpApiSecurity.d.ts +122 -0
  58. package/dist/dts/HttpApiSecurity.d.ts.map +1 -0
  59. package/dist/dts/HttpApiSwagger.d.ts +10 -0
  60. package/dist/dts/HttpApiSwagger.d.ts.map +1 -0
  61. package/dist/dts/HttpMethod.d.ts +16 -0
  62. package/dist/dts/HttpMethod.d.ts.map +1 -1
  63. package/dist/dts/HttpRouter.d.ts +8 -0
  64. package/dist/dts/HttpRouter.d.ts.map +1 -1
  65. package/dist/dts/HttpServerResponse.d.ts +3 -3
  66. package/dist/dts/HttpServerResponse.d.ts.map +1 -1
  67. package/dist/dts/OpenApi.d.ts +348 -0
  68. package/dist/dts/OpenApi.d.ts.map +1 -0
  69. package/dist/dts/index.d.ts +40 -0
  70. package/dist/dts/index.d.ts.map +1 -1
  71. package/dist/dts/internal/apiSwagger.d.ts +2 -0
  72. package/dist/dts/internal/apiSwagger.d.ts.map +1 -0
  73. package/dist/dts/internal/httpRouter.d.ts.map +1 -1
  74. package/dist/esm/HttpApi.js +157 -0
  75. package/dist/esm/HttpApi.js.map +1 -0
  76. package/dist/esm/HttpApiBuilder.js +447 -0
  77. package/dist/esm/HttpApiBuilder.js.map +1 -0
  78. package/dist/esm/HttpApiClient.js +124 -0
  79. package/dist/esm/HttpApiClient.js.map +1 -0
  80. package/dist/esm/HttpApiEndpoint.js +169 -0
  81. package/dist/esm/HttpApiEndpoint.js.map +1 -0
  82. package/dist/esm/HttpApiError.js +59 -0
  83. package/dist/esm/HttpApiError.js.map +1 -0
  84. package/dist/esm/HttpApiGroup.js +140 -0
  85. package/dist/esm/HttpApiGroup.js.map +1 -0
  86. package/dist/esm/HttpApiSchema.js +217 -0
  87. package/dist/esm/HttpApiSchema.js.map +1 -0
  88. package/dist/esm/HttpApiSecurity.js +73 -0
  89. package/dist/esm/HttpApiSecurity.js.map +1 -0
  90. package/dist/esm/HttpApiSwagger.js +40 -0
  91. package/dist/esm/HttpApiSwagger.js.map +1 -0
  92. package/dist/esm/HttpMethod.js +1 -1
  93. package/dist/esm/HttpMethod.js.map +1 -1
  94. package/dist/esm/HttpRouter.js +5 -0
  95. package/dist/esm/HttpRouter.js.map +1 -1
  96. package/dist/esm/OpenApi.js +299 -0
  97. package/dist/esm/OpenApi.js.map +1 -0
  98. package/dist/esm/index.js +40 -0
  99. package/dist/esm/index.js.map +1 -1
  100. package/dist/esm/internal/apiSwagger.js +2 -0
  101. package/dist/esm/internal/apiSwagger.js.map +1 -0
  102. package/dist/esm/internal/httpRouter.js +5 -0
  103. package/dist/esm/internal/httpRouter.js.map +1 -1
  104. package/dist/esm/internal/multipart.js +5 -1
  105. package/dist/esm/internal/multipart.js.map +1 -1
  106. package/package.json +83 -3
  107. package/src/HttpApi.ts +342 -0
  108. package/src/HttpApiBuilder.ts +869 -0
  109. package/src/HttpApiClient.ts +228 -0
  110. package/src/HttpApiEndpoint.ts +818 -0
  111. package/src/HttpApiError.ts +113 -0
  112. package/src/HttpApiGroup.ts +365 -0
  113. package/src/HttpApiSchema.ts +384 -0
  114. package/src/HttpApiSecurity.ts +169 -0
  115. package/src/HttpApiSwagger.ts +46 -0
  116. package/src/HttpMethod.ts +19 -1
  117. package/src/HttpRouter.ts +9 -0
  118. package/src/HttpServerResponse.ts +3 -3
  119. package/src/OpenApi.ts +665 -0
  120. package/src/index.ts +50 -0
  121. package/src/internal/apiSwagger.ts +7 -0
  122. package/src/internal/httpRouter.ts +9 -0
  123. package/src/internal/multipart.ts +5 -1
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @since 1.0.0
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
+ import * as Effect from "effect/Effect"
9
+ import { identity } from "effect/Function"
10
+ import * as HttpApiSchema from "./HttpApiSchema.js"
11
+
12
+ /**
13
+ * @since 1.0.0
14
+ * @category type ids
15
+ */
16
+ export const TypeId: unique symbol = Symbol.for("@effect/platform/HttpApiError")
17
+
18
+ /**
19
+ * @since 1.0.0
20
+ * @category type ids
21
+ */
22
+ export type TypeId = typeof TypeId
23
+
24
+ /**
25
+ * @since 1.0.0
26
+ * @category schemas
27
+ */
28
+ export interface Issue extends
29
+ Schema.Struct<
30
+ {
31
+ _tag: Schema.Literal<
32
+ ["Pointer", "Unexpected", "Missing", "Composite", "Refinement", "Transformation", "Type", "Forbidden"]
33
+ >
34
+ path: PropertyKeysNoSymbol
35
+ message: typeof Schema.String
36
+ }
37
+ >
38
+ {}
39
+
40
+ /**
41
+ * @since 1.0.0
42
+ * @category schemas
43
+ */
44
+ export interface PropertyKeysNoSymbol extends
45
+ Schema.transform<
46
+ Schema.Array$<Schema.Union<[typeof Schema.String, typeof Schema.Number]>>,
47
+ Schema.Array$<Schema.Union<[typeof Schema.SymbolFromSelf, typeof Schema.String, typeof Schema.Number]>>
48
+ >
49
+ {}
50
+
51
+ /**
52
+ * @since 1.0.0
53
+ * @category schemas
54
+ */
55
+ export const PropertyKeysNoSymbol: PropertyKeysNoSymbol = Schema.transform(
56
+ Schema.Array(Schema.Union(Schema.String, Schema.Number)),
57
+ Schema.Array(Schema.Union(Schema.SymbolFromSelf, Schema.String, Schema.Number)),
58
+ {
59
+ decode: identity,
60
+ encode: (items) => items.filter((item) => typeof item !== "symbol")
61
+ }
62
+ )
63
+
64
+ /**
65
+ * @since 1.0.0
66
+ * @category schemas
67
+ */
68
+ export const Issue: Issue = Schema.Struct({
69
+ _tag: Schema.Literal(
70
+ "Pointer",
71
+ "Unexpected",
72
+ "Missing",
73
+ "Composite",
74
+ "Refinement",
75
+ "Transformation",
76
+ "Type",
77
+ "Forbidden"
78
+ ),
79
+ path: PropertyKeysNoSymbol,
80
+ message: Schema.String
81
+ })
82
+
83
+ /**
84
+ * @since 1.0.0
85
+ * @category errors
86
+ */
87
+ export class HttpApiDecodeError extends Schema.TaggedError<HttpApiDecodeError>()(
88
+ "HttpApiDecodeError",
89
+ {
90
+ issues: Schema.Array(Issue),
91
+ message: Schema.String
92
+ },
93
+ HttpApiSchema.annotations({
94
+ status: 400,
95
+ description: "HttpApiDecodeError: The request did not match the expected schema"
96
+ })
97
+ ) {
98
+ /**
99
+ * @since 1.0.0
100
+ */
101
+ static fromParseError(error: ParseResult.ParseError): Effect.Effect<HttpApiDecodeError> {
102
+ return ArrayFormatter.formatError(error).pipe(
103
+ Effect.zip(TreeFormatter.formatError(error)),
104
+ Effect.map(([issues, message]) => new HttpApiDecodeError({ issues, message }))
105
+ )
106
+ }
107
+ /**
108
+ * @since 1.0.0
109
+ */
110
+ static refailParseError(error: ParseResult.ParseError): Effect.Effect<never, HttpApiDecodeError> {
111
+ return Effect.flatMap(HttpApiDecodeError.fromParseError(error), Effect.fail)
112
+ }
113
+ }
@@ -0,0 +1,365 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Schema from "@effect/schema/Schema"
5
+ import * as Chunk from "effect/Chunk"
6
+ import * as Context from "effect/Context"
7
+ import { dual } from "effect/Function"
8
+ import { type Pipeable, pipeArguments } from "effect/Pipeable"
9
+ import * as Predicate from "effect/Predicate"
10
+ import * as HttpApiEndpoint from "./HttpApiEndpoint.js"
11
+ import type { HttpApiDecodeError } from "./HttpApiError.js"
12
+ import * as HttpApiSchema from "./HttpApiSchema.js"
13
+ import type { PathInput } from "./HttpRouter.js"
14
+
15
+ /**
16
+ * @since 1.0.0
17
+ * @category type ids
18
+ */
19
+ export const TypeId: unique symbol = Symbol.for("@effect/platform/HttpApiGroup")
20
+
21
+ /**
22
+ * @since 1.0.0
23
+ * @category type ids
24
+ */
25
+ export type TypeId = typeof TypeId
26
+
27
+ /**
28
+ * @since 1.0.0
29
+ * @category guards
30
+ */
31
+ export const isHttpApiGroup = (u: unknown): u is HttpApiGroup.Any => Predicate.hasProperty(u, TypeId)
32
+
33
+ /**
34
+ * An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to
35
+ * represent a portion of your domain.
36
+ *
37
+ * The endpoints can be implemented later using the `HttpApiBuilder.group` api.
38
+ *
39
+ * @since 1.0.0
40
+ * @category models
41
+ */
42
+ export interface HttpApiGroup<
43
+ out Name extends string,
44
+ out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All = never,
45
+ in out Error = HttpApiDecodeError,
46
+ out ErrorR = never
47
+ > extends Pipeable {
48
+ new(_: never): {}
49
+ readonly [TypeId]: TypeId
50
+ readonly identifier: Name
51
+ readonly endpoints: Chunk.Chunk<Endpoints>
52
+ readonly errorSchema: Schema.Schema<Error, unknown, ErrorR>
53
+ readonly annotations: Context.Context<never>
54
+ }
55
+
56
+ /**
57
+ * @since 1.0.0
58
+ * @category models
59
+ */
60
+ export declare namespace HttpApiGroup {
61
+ /**
62
+ * @since 1.0.0
63
+ * @category models
64
+ */
65
+ export type Any =
66
+ | HttpApiGroup<any, any, any, any>
67
+ | HttpApiGroup<any, any, any, never>
68
+ | HttpApiGroup<any, any, never, never>
69
+
70
+ /**
71
+ * @since 1.0.0
72
+ * @category models
73
+ */
74
+ export interface Service<Name extends string> {
75
+ readonly _: unique symbol
76
+ readonly name: Name
77
+ }
78
+
79
+ /**
80
+ * @since 1.0.0
81
+ * @category models
82
+ */
83
+ export type ToService<Group> = Group extends HttpApiGroup<infer Name, infer _Endpoints, infer _Error, infer _ErrorR>
84
+ ? Service<Name>
85
+ : never
86
+
87
+ /**
88
+ * @since 1.0.0
89
+ * @category models
90
+ */
91
+ export type WithName<Group, Name extends string> = Extract<Group, { readonly identifier: Name }>
92
+
93
+ /**
94
+ * @since 1.0.0
95
+ * @category models
96
+ */
97
+ export type Endpoints<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR>
98
+ ? _Endpoints
99
+ : never
100
+
101
+ /**
102
+ * @since 1.0.0
103
+ * @category models
104
+ */
105
+ export type EndpointsWithName<Group extends Any, Name extends string> = Endpoints<WithName<Group, Name>>
106
+
107
+ /**
108
+ * @since 1.0.0
109
+ * @category models
110
+ */
111
+ export type Error<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR> ?
112
+ _Error
113
+ : never
114
+
115
+ /**
116
+ * @since 1.0.0
117
+ * @category models
118
+ */
119
+ export type ErrorWithName<Group extends Any, Name extends string> = Error<WithName<Group, Name>>
120
+
121
+ /**
122
+ * @since 1.0.0
123
+ * @category models
124
+ */
125
+ export type Context<Group> = Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR>
126
+ ? _ErrorR | HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints>
127
+ : never
128
+
129
+ /**
130
+ * @since 1.0.0
131
+ * @category models
132
+ */
133
+ export type ContextWithName<Group extends Any, Name extends string> = Context<WithName<Group, Name>>
134
+ }
135
+
136
+ const Proto = {
137
+ [TypeId]: TypeId,
138
+ pipe() {
139
+ return pipeArguments(this, arguments)
140
+ }
141
+ }
142
+
143
+ const makeProto = <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(options: {
144
+ readonly identifier: Name
145
+ readonly endpoints: Chunk.Chunk<Endpoints>
146
+ readonly errorSchema: Schema.Schema<Error, unknown, ErrorR>
147
+ readonly annotations: Context.Context<never>
148
+ }): HttpApiGroup<Name, Endpoints, Error, ErrorR> => {
149
+ function HttpApiGroup() {}
150
+ Object.setPrototypeOf(HttpApiGroup, Proto)
151
+ return Object.assign(HttpApiGroup, options) as any
152
+ }
153
+
154
+ /**
155
+ * An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to
156
+ * represent a portion of your domain.
157
+ *
158
+ * The endpoints can be implemented later using the `HttpApiBuilder.group` api.
159
+ *
160
+ * @since 1.0.0
161
+ * @category constructors
162
+ */
163
+ export const make = <Name extends string>(identifier: Name): HttpApiGroup<Name> =>
164
+ makeProto({
165
+ identifier,
166
+ endpoints: Chunk.empty(),
167
+ errorSchema: Schema.Never as any,
168
+ annotations: Context.empty()
169
+ })
170
+
171
+ /**
172
+ * Add an `HttpApiEndpoint` to an `HttpApiGroup`.
173
+ *
174
+ * @since 1.0.0
175
+ * @category endpoints
176
+ */
177
+ export const add: {
178
+ <A extends HttpApiEndpoint.HttpApiEndpoint.All>(
179
+ endpoint: A
180
+ ): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
181
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
182
+ ) => HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
183
+ <
184
+ Name extends string,
185
+ Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All,
186
+ Error,
187
+ ErrorR,
188
+ A extends HttpApiEndpoint.HttpApiEndpoint.All
189
+ >(
190
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
191
+ endpoint: A
192
+ ): HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
193
+ } = dual(2, <
194
+ Name extends string,
195
+ Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All,
196
+ Error,
197
+ ErrorR,
198
+ A extends HttpApiEndpoint.HttpApiEndpoint.All
199
+ >(
200
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
201
+ endpoint: A
202
+ ): HttpApiGroup<Name, Endpoints | A, Error, ErrorR> =>
203
+ makeProto({
204
+ identifier: self.identifier,
205
+ errorSchema: self.errorSchema,
206
+ annotations: self.annotations,
207
+ endpoints: Chunk.append(self.endpoints, endpoint)
208
+ }))
209
+
210
+ /**
211
+ * Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the
212
+ * group.
213
+ *
214
+ * @since 1.0.0
215
+ * @category errors
216
+ */
217
+ export const addError: {
218
+ <A, I, R>(
219
+ schema: Schema.Schema<A, I, R>,
220
+ annotations?: {
221
+ readonly status?: number | undefined
222
+ }
223
+ ): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
224
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
225
+ ) => HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>
226
+ <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A, I, R>(
227
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
228
+ schema: Schema.Schema<A, I, R>,
229
+ annotations?: {
230
+ readonly status?: number | undefined
231
+ }
232
+ ): HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>
233
+ } = dual(
234
+ (args) => isHttpApiGroup(args[0]),
235
+ <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A, I, R>(
236
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
237
+ schema: Schema.Schema<A, I, R>,
238
+ annotations?: {
239
+ readonly status?: number | undefined
240
+ }
241
+ ): HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R> =>
242
+ makeProto({
243
+ identifier: self.identifier,
244
+ annotations: self.annotations,
245
+ endpoints: self.endpoints,
246
+ errorSchema: HttpApiSchema.UnionUnify(
247
+ self.errorSchema,
248
+ schema.annotations(HttpApiSchema.annotations({
249
+ status: annotations?.status ?? HttpApiSchema.getStatusError(schema)
250
+ }))
251
+ )
252
+ })
253
+ )
254
+
255
+ /**
256
+ * Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only
257
+ * add the prefix to the endpoints before this api is called.
258
+ *
259
+ * @since 1.0.0
260
+ * @category endpoints
261
+ */
262
+ export const prefix: {
263
+ (
264
+ prefix: PathInput
265
+ ): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
266
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
267
+ ) => HttpApiGroup<Name, Endpoints, Error, ErrorR>
268
+ <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
269
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
270
+ prefix: PathInput
271
+ ): HttpApiGroup<Name, Endpoints, Error, ErrorR>
272
+ } = dual(2, <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
273
+ self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
274
+ prefix: PathInput
275
+ ): HttpApiGroup<Name, Endpoints, Error, ErrorR> =>
276
+ makeProto({
277
+ identifier: self.identifier,
278
+ errorSchema: self.errorSchema,
279
+ annotations: self.annotations,
280
+ endpoints: Chunk.map(self.endpoints, HttpApiEndpoint.prefix(prefix))
281
+ }))
282
+
283
+ /**
284
+ * Merge the annotations of an `HttpApiGroup` with a new context.
285
+ *
286
+ * @since 1.0.0
287
+ * @category annotations
288
+ */
289
+ export const annotateMerge: {
290
+ <I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A
291
+ <A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
292
+ } = dual(
293
+ 2,
294
+ <A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A =>
295
+ makeProto({
296
+ ...self as any,
297
+ annotations: Context.merge(self.annotations, context)
298
+ }) as A
299
+ )
300
+
301
+ /**
302
+ * Add an annotation to an `HttpApiGroup`.
303
+ *
304
+ * @since 1.0.0
305
+ * @category annotations
306
+ */
307
+ export const annotate: {
308
+ <I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A
309
+ <A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
310
+ } = dual(
311
+ 3,
312
+ <A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A =>
313
+ makeProto({
314
+ identifier: self.identifier,
315
+ errorSchema: self.errorSchema as any,
316
+ endpoints: self.endpoints,
317
+ annotations: Context.add(self.annotations, tag, value)
318
+ }) as A
319
+ )
320
+
321
+ /**
322
+ * For each endpoint in an `HttpApiGroup`, update the annotations with a new
323
+ * context.
324
+ *
325
+ * Note that this will only update the annotations before this api is called.
326
+ *
327
+ * @since 1.0.0
328
+ * @category annotations
329
+ */
330
+ export const annotateEndpointsMerge: {
331
+ <I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A
332
+ <A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
333
+ } = dual(
334
+ 2,
335
+ <A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A =>
336
+ makeProto({
337
+ identifier: self.identifier,
338
+ errorSchema: self.errorSchema as any,
339
+ annotations: self.annotations,
340
+ endpoints: Chunk.map(self.endpoints, HttpApiEndpoint.annotateMerge(context))
341
+ }) as A
342
+ )
343
+
344
+ /**
345
+ * For each endpoint in an `HttpApiGroup`, add an annotation.
346
+ *
347
+ * Note that this will only add the annotation to the endpoints before this api
348
+ * is called.
349
+ *
350
+ * @since 1.0.0
351
+ * @category annotations
352
+ */
353
+ export const annotateEndpoints: {
354
+ <I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A
355
+ <A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
356
+ } = dual(
357
+ 3,
358
+ <A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A =>
359
+ makeProto({
360
+ identifier: self.identifier,
361
+ errorSchema: self.errorSchema as any,
362
+ annotations: self.annotations,
363
+ endpoints: Chunk.map(self.endpoints, HttpApiEndpoint.annotate(tag, value))
364
+ }) as A
365
+ )