import { BackendFeature } from '../../types'; /** * TODO * * @public */ export type ServiceRef = { id: string; /** * This determines the scope at which this service is available. * * Root scoped services are available to all other services but * may only depend on other root scoped services. * * Plugin scoped services are only available to other plugin scoped * services but may depend on all other services. */ scope: TScope; /** * Utility for getting the type of the service, using `typeof serviceRef.T`. * Attempting to actually read this value will result in an exception. */ T: TService; toString(): string; $$type: '@backstage/ServiceRef'; }; /** @public */ export interface ServiceFactory extends BackendFeature { service: ServiceRef; } /** * Represents either a {@link ServiceFactory} or a function that returns one. * * @public */ export type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory); /** @public */ export interface ServiceRefConfig { id: string; scope?: TScope; defaultFactory?: (service: ServiceRef) => Promise; } /** * Creates a new service definition. This overload is used to create plugin scoped services. * * @public */ export declare function createServiceRef(config: ServiceRefConfig): ServiceRef; /** * Creates a new service definition. This overload is used to create root scoped services. * * @public */ export declare function createServiceRef(config: ServiceRefConfig): ServiceRef; /** @ignore */ type ServiceRefsToInstances; }, TScope extends 'root' | 'plugin' = 'root' | 'plugin'> = { [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T']; }; /** @public */ export interface RootServiceFactoryConfig; }> { service: ServiceRef; deps: TDeps; factory(deps: ServiceRefsToInstances): TImpl | Promise; } /** @public */ export interface PluginServiceFactoryConfig; }> { service: ServiceRef; deps: TDeps; createRootContext?(deps: ServiceRefsToInstances): TContext | Promise; factory(deps: ServiceRefsToInstances, context: TContext): TImpl | Promise; } /** * Creates a root scoped service factory without options. * * @public * @param config - The service factory configuration. */ export declare function createServiceFactory; }, TOpts extends object | undefined = undefined>(config: RootServiceFactoryConfig): () => ServiceFactory; /** * Creates a root scoped service factory with optional options. * * @public * @param config - The service factory configuration. */ export declare function createServiceFactory; }, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => RootServiceFactoryConfig): (options?: TOpts) => ServiceFactory; /** * Creates a plugin scoped service factory without options. * * @public * @param config - The service factory configuration. */ export declare function createServiceFactory; }, TContext = undefined, TOpts extends object | undefined = undefined>(config: PluginServiceFactoryConfig): () => ServiceFactory; /** * Creates a plugin scoped service factory with optional options. * * @public * @param config - The service factory configuration. */ export declare function createServiceFactory; }, TContext = undefined, TOpts extends object | undefined = undefined>(config: (options?: TOpts) => PluginServiceFactoryConfig): (options?: TOpts) => ServiceFactory; export {};