import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api'; import { DiscoveryService, RootConfigService, LoggerService } from '@backstage/backend-plugin-api'; /** * Service discovery for inter-plugin communication. * * See {@link @backstage/code-plugin-api#DiscoveryService} * and {@link https://backstage.io/docs/backend-system/core-services/discovery | the service docs} * for more information. * * @public */ declare const discoveryServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api.DiscoveryService, "plugin", "singleton">; /** * A list of target base URLs and their associated plugins. * * @public */ interface HostDiscoveryEndpoint { /** * The target base URL to use for the given set of plugins. Note that this * needs to be a full URL _including_ the protocol and path parts that fully * address the root of a plugin's API endpoints. * * @remarks * * Can be either a single URL or an object where you can explicitly give a * dedicated URL for internal (as seen from the backend) and/or external (as * seen from the frontend) lookups. * * The default behavior is to use the backend base URL for external lookups, * and a URL formed from the `.listen` and `.https` configs for internal * lookups. Adding discovery endpoints as described here overrides one or both * of those behaviors for a given set of plugins. * * URLs can be in the form of a regular HTTP or HTTPS URL if you are using * A/AAAA/CNAME records or IP addresses. Specifically for internal URLs, if * you add `+src` to the protocol part then the hostname is treated as an SRV * record name and resolved. For example, if you pass in * `http+srv:///path` then the record part is resolved into an * actual host and port (with random weighted choice as usual when there is * more than one match). * * Any strings with `{{pluginId}}` or `{{ pluginId }}` placeholders in them * will have them replaced with the plugin ID. * * Example URLs: * * - `https://internal.example.com/secure/api/{{ pluginId }}` * - `http+srv://backstage-plugin-{{pluginId}}.http.services.company.net/api/{{pluginId}}` * (can only be used in the `internal` key) */ target: string | { internal?: string; external?: string; }; /** * Array of plugins which use that target base URL. * * The special value `*` can be used to match all plugins. */ plugins: string[]; } /** * Options for the {@link HostDiscovery} class. * * @public */ interface HostDiscoveryOptions { /** * The logger to use. */ logger: LoggerService; /** * A default set of endpoints to use. * * @remarks * * These endpoints have lower priority than any that are defined in * app-config, but higher priority than the fallback ones. * * This parameter is usedful for example if you want to provide a shared * library of core services to your plugin developers, which is set up for the * default behaviors in your org. This alleviates the need for replicating any * given set of endpoint config in every backend that you deploy. */ defaultEndpoints?: HostDiscoveryEndpoint[]; } /** * A basic {@link @backstage/backend-plugin-api#DiscoveryService} implementation * that can handle plugins that are hosted in a single or multiple deployments. * * @public * @remarks * * Configuration is read from the `backend` config section, specifically the * `.baseUrl` for discovering the external URL, and the `.listen` and `.https` * config for the internal one. The fixed base path for these is `/api`, meaning * for example the default full internal path for the `catalog` plugin typically * will be `http://localhost:7007/api/catalog`. * * Those defaults can be overridden by providing a target and corresponding * plugins in `discovery.endpoints`, e.g.: * * ```yaml * discovery: * endpoints: * # Set a static internal and external base URL for a plugin * - target: https://internal.example.com/internal-catalog * plugins: [catalog] * # Sets a dynamic internal and external base URL pattern for two plugins * - target: https://internal.example.com/secure/api/{{pluginId}} * plugins: [auth, permission] * # Sets a dynamic base URL pattern for only the internal resolution for all * # other plugins, while leaving the external resolution unaffected * - target: * internal: http+srv://backstage-plugin-{{pluginId}}.http.${SERVICE_DOMAIN}/api/{{pluginId}} * plugins: [*] * ``` */ declare class HostDiscovery implements DiscoveryService { #private; static fromConfig(config: RootConfigService, options?: HostDiscoveryOptions): HostDiscovery; private constructor(); getBaseUrl(pluginId: string): Promise; getExternalBaseUrl(pluginId: string): Promise; } export { HostDiscovery, discoveryServiceFactory }; export type { HostDiscoveryEndpoint, HostDiscoveryOptions };