/** * @since 1.0.0 */ import * as Context from "effect/Context"; import { type Pipeable } from "effect/Pipeable"; import * as Record from "effect/Record"; import * as Schema from "effect/Schema"; import type * as HttpApiEndpoint from "./HttpApiEndpoint.js"; import type { HttpApiDecodeError } from "./HttpApiError.js"; import type * as HttpApiMiddleware from "./HttpApiMiddleware.js"; /** * @since 1.0.0 * @category type ids */ export declare const TypeId: unique symbol; /** * @since 1.0.0 * @category type ids */ export type TypeId = typeof TypeId; /** * @since 1.0.0 * @category guards */ export declare const isHttpApiGroup: (u: unknown) => u is HttpApiGroup.Any; /** * An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to * represent a portion of your domain. * * The endpoints can be implemented later using the `HttpApiBuilder.group` api. * * @since 1.0.0 * @category models */ export interface HttpApiGroup extends Pipeable { new (_: never): {}; readonly [TypeId]: TypeId; readonly identifier: Id; readonly topLevel: TopLevel; readonly endpoints: Record.ReadonlyRecord; readonly errorSchema: Schema.Schema; readonly annotations: Context.Context; readonly middlewares: ReadonlySet; /** * Add an `HttpApiEndpoint` to an `HttpApiGroup`. */ add(endpoint: A): HttpApiGroup; /** * Add an error schema to an `HttpApiGroup`, which is shared by all endpoints in the * group. */ addError(schema: Schema.Schema, annotations?: { readonly status?: number | undefined; }): HttpApiGroup; /** * Add a path prefix to all endpoints in an `HttpApiGroup`. Note that this will only * add the prefix to the endpoints before this api is called. */ prefix(prefix: HttpApiEndpoint.PathSegment): HttpApiGroup; /** * Add an `HttpApiMiddleware` to the `HttpApiGroup`. * * It will be applied to all endpoints in the group. */ middleware(middleware: Context.Tag): HttpApiGroup, R | I | HttpApiMiddleware.HttpApiMiddleware.ErrorContext, TopLevel>; /** * Add an `HttpApiMiddleware` to each endpoint in the `HttpApiGroup`. * * Endpoints added after this api is called will not have the middleware * applied. */ middlewareEndpoints(middleware: Context.Tag): HttpApiGroup, Error, R, TopLevel>; /** * Merge the annotations of an `HttpApiGroup` with a new context. */ annotateContext(context: Context.Context): HttpApiGroup; /** * Add an annotation to an `HttpApiGroup`. */ annotate(tag: Context.Tag, value: S): HttpApiGroup; /** * For each endpoint in an `HttpApiGroup`, update the annotations with a new * context. * * Note that this will only update the annotations before this api is called. */ annotateEndpointsContext(context: Context.Context): HttpApiGroup; /** * For each endpoint in an `HttpApiGroup`, add an annotation. * * Note that this will only add the annotation to the endpoints before this api * is called. */ annotateEndpoints(tag: Context.Tag, value: S): HttpApiGroup; } /** * @since 1.0.0 * @category models */ export interface ApiGroup { readonly _: unique symbol; readonly apiId: ApiId; readonly name: Name; } /** * @since 1.0.0 * @category models */ export declare namespace HttpApiGroup { /** * @since 1.0.0 * @category models */ interface Any { readonly [TypeId]: TypeId; readonly identifier: string; } /** * @since 1.0.0 * @category models */ type AnyWithProps = HttpApiGroup; /** * @since 1.0.0 * @category models */ type ToService = A extends HttpApiGroup ? ApiGroup : never; /** * @since 1.0.0 * @category models */ type WithName = Extract; /** * @since 1.0.0 * @category models */ type Name = Group extends HttpApiGroup ? _Name : never; /** * @since 1.0.0 * @category models */ type Endpoints = Group extends HttpApiGroup ? _Endpoints : never; /** * @since 1.0.0 * @category models */ type EndpointsWithName = Endpoints>; /** * @since 1.0.0 * @category models */ type Error = Group extends HttpApiGroup ? _Error : never; /** * @since 1.0.0 * @category models */ type AddContext = [R] extends [never] ? Group : Group extends HttpApiGroup ? HttpApiGroup<_Name, _Endpoints, _Error, _R | R, _TopLevel> : never; /** * @since 1.0.0 * @category models */ type Provides = HttpApiMiddleware.HttpApiMiddleware.ExtractProvides>; /** * @since 1.0.0 * @category models */ type ErrorWithName = Error>; /** * @since 1.0.0 * @category models */ type Context = Group extends HttpApiGroup ? HttpApiMiddleware.HttpApiMiddleware.Without<_R> : never; /** * @since 1.0.0 * @category models */ type Middleware = Group extends HttpApiGroup ? HttpApiMiddleware.HttpApiMiddleware.Only<_R> : never; /** * @since 1.0.0 * @category models */ type ClientContext = Group extends HttpApiGroup ? _R | HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints> | HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints> : never; /** * @since 1.0.0 * @category models */ type ErrorContext = Group extends HttpApiGroup ? HttpApiMiddleware.HttpApiMiddleware.Without<_R> | HttpApiEndpoint.HttpApiEndpoint.ErrorContext<_Endpoints> : never; /** * @since 1.0.0 * @category models */ type ContextWithName = Context>; /** * @since 1.0.0 * @category models */ type MiddlewareWithName = Middleware>; } /** * An `HttpApiGroup` is a collection of `HttpApiEndpoint`s. You can use an `HttpApiGroup` to * represent a portion of your domain. * * The endpoints can be implemented later using the `HttpApiBuilder.group` api. * * @since 1.0.0 * @category constructors */ export declare const make: (identifier: Id, options?: { readonly topLevel?: TopLevel | undefined; }) => HttpApiGroup; //# sourceMappingURL=HttpApiGroup.d.ts.map