(
self: HttpApi<Id, Groups, Error, R>,
options: {
readonly predicate?: Predicate.Predicate<{
readonly endpoint: HttpApiEndpoint.HttpApiEndpoint.AnyWithProps
readonly group: HttpApiGroup.HttpApiGroup.AnyWithProps
}>
readonly onGroup: (options: {
readonly group: HttpApiGroup.HttpApiGroup.AnyWithProps
readonly mergedAnnotations: Context.Context<never>
}) => void
readonly onEndpoint: (options: {
readonly group: HttpApiGroup.HttpApiGroup.AnyWithProps
readonly endpoint: HttpApiEndpoint.HttpApiEndpoint<string, HttpMethod>
readonly mergedAnnotations: Context.Context<never>
readonly middleware: ReadonlySet<HttpApiMiddleware.TagClassAny>
readonly payloads: ReadonlyMap<string, {
readonly encoding: HttpApiSchema.Encoding
readonly ast: AST.AST
}>
readonly successes: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}>
readonly errors: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}>
}) => void
}
)
| 277 | * @category reflection |
| 278 | */ |
| 279 | export const reflect = <Id extends string, Groups extends HttpApiGroup.HttpApiGroup.Any, Error, R>( |
| 280 | self: HttpApi<Id, Groups, Error, R>, |
| 281 | options: { |
| 282 | readonly predicate?: Predicate.Predicate<{ |
| 283 | readonly endpoint: HttpApiEndpoint.HttpApiEndpoint.AnyWithProps |
| 284 | readonly group: HttpApiGroup.HttpApiGroup.AnyWithProps |
| 285 | }> |
| 286 | readonly onGroup: (options: { |
| 287 | readonly group: HttpApiGroup.HttpApiGroup.AnyWithProps |
| 288 | readonly mergedAnnotations: Context.Context<never> |
| 289 | }) => void |
| 290 | readonly onEndpoint: (options: { |
| 291 | readonly group: HttpApiGroup.HttpApiGroup.AnyWithProps |
| 292 | readonly endpoint: HttpApiEndpoint.HttpApiEndpoint<string, HttpMethod> |
| 293 | readonly mergedAnnotations: Context.Context<never> |
| 294 | readonly middleware: ReadonlySet<HttpApiMiddleware.TagClassAny> |
| 295 | readonly payloads: ReadonlyMap<string, { |
| 296 | readonly encoding: HttpApiSchema.Encoding |
| 297 | readonly ast: AST.AST |
| 298 | }> |
| 299 | readonly successes: ReadonlyMap<number, { |
| 300 | readonly ast: Option.Option<AST.AST> |
| 301 | readonly description: Option.Option<string> |
| 302 | }> |
| 303 | readonly errors: ReadonlyMap<number, { |
| 304 | readonly ast: Option.Option<AST.AST> |
| 305 | readonly description: Option.Option<string> |
| 306 | }> |
| 307 | }) => void |
| 308 | } |
| 309 | ) => { |
| 310 | const apiErrors = extractMembers(self.errorSchema.ast, new Map(), HttpApiSchema.getStatusErrorAST) |
| 311 | const groups = Object.values(self.groups) as any as Array<HttpApiGroup.HttpApiGroup.AnyWithProps> |
| 312 | for (const group of groups) { |
| 313 | const groupErrors = extractMembers(group.errorSchema.ast, apiErrors, HttpApiSchema.getStatusErrorAST) |
| 314 | const groupAnnotations = Context.merge(self.annotations, group.annotations) |
| 315 | options.onGroup({ |
| 316 | group, |
| 317 | mergedAnnotations: groupAnnotations |
| 318 | }) |
| 319 | const endpoints = Object.values(group.endpoints) as Iterable<HttpApiEndpoint.HttpApiEndpoint<string, HttpMethod>> |
| 320 | for (const endpoint of endpoints) { |
| 321 | if ( |
| 322 | options.predicate && !options.predicate({ |
| 323 | endpoint, |
| 324 | group |
| 325 | } as any) |
| 326 | ) continue |
| 327 | |
| 328 | const errors = extractMembers(endpoint.errorSchema.ast, groupErrors, HttpApiSchema.getStatusErrorAST) |
| 329 | options.onEndpoint({ |
| 330 | group, |
| 331 | endpoint, |
| 332 | middleware: new Set([...group.middlewares, ...endpoint.middlewares]), |
| 333 | mergedAnnotations: Context.merge(groupAnnotations, endpoint.annotations), |
| 334 | payloads: endpoint.payloadSchema._tag === "Some" ? extractPayloads(endpoint.payloadSchema.value.ast) : emptyMap, |
| 335 | successes: extractMembers(endpoint.successSchema.ast, new Map(), HttpApiSchema.getStatusSuccessAST), |
| 336 | errors |
nothing calls this directly
no test coverage detected