import type { MethodInfo, ServiceType } from "@bufbuild/protobuf"; import type { MethodImpl, ServiceImpl } from "./implementation.js"; import type { UniversalHandler, UniversalHandlerOptions } from "./protocol/universal-handler.js"; /** * ConnectRouter is your single registration point for RPCs. * * Create a file `connect.ts` with a default export such as this: * * ```ts * import {ConnectRouter} from "@bufbuild/connect"; * * export default (router: ConnectRouter) => { * router.service(ElizaService, {}); * } * ``` * * The pass this function to adapters and plugins, for example * from @bufbuild/connect-node, or from @bufbuild/connect-fastify. */ export interface ConnectRouter { readonly handlers: UniversalHandler[]; service(service: T, implementation: Partial>, options?: Partial): this; rpc(service: ServiceType, method: M, impl: MethodImpl, options?: Partial): this; } /** * Options for a ConnectRouter. By default, all three protocols gRPC, gRPC-web, * and Connect are enabled. */ export interface ConnectRouterOptions extends Partial { /** * Enable the gRPC protocol and make your API available to all gRPC clients * for various platforms and languages. See https://grpc.io/ * * The protocol is enabled by default. Set this option to `false` to disable * it, but mind that at least one protocol must be enabled. * * Note that gRPC is typically served with TLS over HTTP/2 and requires access * to HTTP trailers. */ grpc?: boolean; /** * Enable the gRPC-web protocol and make your API available to all gRPC-web * clients. gRPC-web is commonly used in web browsers, but there are client * implementations for other platforms as well, for example in Dart, Kotlin, * and Swift. See https://github.com/grpc/grpc-web * * The protocol is enabled by default. Set this option to `false` to disable * it, but mind that at least one protocol must be enabled. * * gRPC-web works over HTTP 1.1 or HTTP/2 and does not require access to HTTP * trailers. Note that bidi streaming requires HTTP/2, and web browsers may * not support all streaming types. */ grpcWeb?: boolean; /** * Enable the Connect protocol and make your API available to all Connect * clients, but also for a simple call with curl. See https://connectrpc.com/ * * The protocol is enabled by default. Set this option to `false` to disable * it, but mind that at least one protocol must be enabled. * * Connect works over HTTP 1.1 or HTTP/2 and does not require access to HTTP * trailers. Note that bidi streaming requires HTTP/2, and web browsers may * not support all streaming types. */ connect?: boolean; } /** * Create a new ConnectRouter. */ export declare function createConnectRouter(routerOptions?: ConnectRouterOptions): ConnectRouter;