import { type EncodingOptions, type ServiceDescriptor, type ServiceProvider } from '@dxos/codec-protobuf'; import { RpcPeer, type RpcPeerOptions } from './rpc'; /** * Map of service definitions. */ export type ServiceBundle = { [Key in keyof Services]: ServiceDescriptor; }; export type ServiceHandlers = { [ServiceName in keyof Services]: ServiceProvider; }; export type ServiceTypesOf> = Bundle extends ServiceBundle ? Services : never; /** * Groups multiple services together to be served by a single RPC peer. */ export declare const createServiceBundle: (services: ServiceBundle) => ServiceBundle; /** * Type-safe RPC peer. */ export declare class ProtoRpcPeer { readonly rpc: Service; private readonly _peer; constructor(rpc: Service, _peer: RpcPeer); open(): Promise; close(): Promise; abort(): Promise; } export interface ProtoRpcPeerOptions extends Omit { /** * Services that are expected to be implemented by the counter-space. */ requested?: ServiceBundle; /** * Services exposed to the counter-space. */ exposed?: ServiceBundle; /** * Handlers for the exposed services */ handlers?: ServiceHandlers; /** * Encoding options passed to the underlying proto codec. */ encodingOptions?: EncodingOptions; } /** * Create type-safe RPC peer from a service bundle. * Can both handle and issue requests. */ export declare const createProtoRpcPeer: ({ requested, exposed, handlers, encodingOptions, ...rest }: ProtoRpcPeerOptions) => ProtoRpcPeer; export declare const parseMethodName: (method: string) => [serviceName: string, methodName: string]; /** * Create a type-safe RPC client. * @deprecated Use createProtoRpcPeer instead. */ export declare const createRpcClient: (serviceDef: ServiceDescriptor, options: Omit) => ProtoRpcPeer; /** * @deprecated */ export interface RpcServerOptions extends Omit { service: ServiceDescriptor; handlers: S; } /** * Create a type-safe RPC server. * @deprecated Use createProtoRpcPeer instead. */ export declare const createRpcServer: ({ service, handlers, ...rest }: RpcServerOptions) => RpcPeer; /** * Create type-safe RPC client from a service bundle. * @deprecated Use createProtoRpcPeer instead. */ export declare const createBundledRpcClient: (descriptors: ServiceBundle, options: Omit) => ProtoRpcPeer; /** * @deprecated */ export interface RpcBundledServerOptions extends Omit { services: ServiceBundle; handlers: S; } /** * Create type-safe RPC server from a service bundle. * @deprecated Use createProtoRpcPeer instead. */ export declare const createBundledRpcServer: ({ services, handlers, ...rest }: RpcBundledServerOptions) => RpcPeer; //# sourceMappingURL=service.d.ts.map