import { InterfaceSpec, ReferenceSpec } from "./InterfaceSpec"; import { ServiceRepr } from "./ServiceRepr"; export type ReadonlyServiceLookup = Pick; export interface Unimplemented { type: "unimplemented"; } export interface Ambiguous { type: "ambiguous"; choices: AmbiguousChoice[]; } export type AmbiguousChoice = [serviceId: string, qualifier: string | undefined]; export interface Found { type: "found"; value: T; } export type ServiceLookupResult = Unimplemented | Ambiguous | Found; export type ServicesLookupResult = Found; export declare class ServiceLookup { private services; private _count; /** * Returns the total number of registered services. */ get serviceCount(): number; /** * Attempts to register the given service as an implementation of `interfaceName`. * Throws if the registration did not complete successfully. * * All services should be registered before any lookups are attempted. */ register(service: ServiceRepr, { interfaceName, qualifier }: InterfaceSpec): void; /** * Attempts to find the service(s) required by the given reference spec. */ lookup(ref: ReferenceSpec): ServiceLookupResult | ServicesLookupResult; /** * Attempts to find a service implementing the given interface. */ lookupOne({ interfaceName, qualifier }: InterfaceSpec): ServiceLookupResult; /** * Returns all services implementing the given interface. */ lookupAll(interfaceName: string): ServicesLookupResult; private ensureInterfaceEntry; } export declare function renderAmbiguousServiceChoices(choices: AmbiguousChoice[], max?: number): string;