backend-plugin-api: document core service refs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-01-03 14:46:04 +01:00
parent 0b41cdfbc0
commit 16054afdec
18 changed files with 203 additions and 216 deletions
@@ -14,15 +14,7 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import { PluginCacheManager } from '@backstage/backend-common';
/** @public */
export type CacheService = PluginCacheManager;
/**
* @public
*/
export const cacheServiceRef = createServiceRef<CacheService>({
id: 'core.cache',
});
@@ -15,17 +15,8 @@
*/
import { Config } from '@backstage/config';
import { createServiceRef } from '../system/types';
/**
* @public
*/
export type ConfigService = Config;
/**
* @public
*/
export const configServiceRef = createServiceRef<ConfigService>({
id: 'core.root.config',
scope: 'root',
});
@@ -15,14 +15,6 @@
*/
import { PluginDatabaseManager } from '@backstage/backend-common';
import { createServiceRef } from '../system/types';
/** @public */
export type DatabaseService = PluginDatabaseManager;
/**
* @public
*/
export const databaseServiceRef = createServiceRef<DatabaseService>({
id: 'core.database',
});
@@ -14,8 +14,6 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
/**
* The DiscoveryService is used to provide a mechanism for backend
* plugins to discover the endpoints for itself or other backend plugins.
@@ -63,10 +61,3 @@ export type DiscoveryService = {
*/
getExternalBaseUrl(pluginId: string): Promise<string>;
};
/**
* @public
*/
export const discoveryServiceRef = createServiceRef<DiscoveryService>({
id: 'core.discovery',
});
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import { Handler } from 'express';
/**
@@ -23,10 +22,3 @@ import { Handler } from 'express';
export interface HttpRouterService {
use(handler: Handler): void;
}
/**
* @public
*/
export const httpRouterServiceRef = createServiceRef<HttpRouterService>({
id: 'core.httpRouter',
});
@@ -14,8 +14,6 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
/**
* @public
**/
@@ -35,11 +33,3 @@ export interface LifecycleService {
*/
addShutdownHook(options: LifecycleServiceShutdownHook): void;
}
/**
* @public
*/
export const lifecycleServiceRef = createServiceRef<LifecycleService>({
id: 'core.lifecycle',
scope: 'plugin',
});
@@ -14,14 +14,14 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
/**
* @public
*/
export type LogMeta = { [name: string]: unknown };
/**
* A service that provides a logging facility.
*
* @public
*/
export interface LoggerService {
@@ -32,10 +32,3 @@ export interface LoggerService {
child(meta: LogMeta): LoggerService;
}
/**
* @public
*/
export const loggerServiceRef = createServiceRef<LoggerService>({
id: 'core.logger',
});
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import {
PermissionAuthorizer,
PermissionEvaluator,
@@ -22,10 +21,3 @@ import {
/** @public */
export type PermissionsService = PermissionEvaluator | PermissionAuthorizer;
/**
* @public
*/
export const permissionsServiceRef = createServiceRef<PermissionsService>({
id: 'core.permissions',
});
@@ -14,20 +14,9 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
/**
* @public
*/
export interface PluginMetadataService {
getId(): string;
}
/**
* @public
*/
export const pluginMetadataServiceRef = createServiceRef<PluginMetadataService>(
{
id: 'core.plugin-metadata',
},
);
@@ -14,16 +14,7 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import { LifecycleService } from './lifecycleServiceRef';
import { LifecycleService } from './LifecycleService';
/** @public */
export type RootLifecycleService = LifecycleService;
/**
* @public
*/
export const rootLifecycleServiceRef = createServiceRef<RootLifecycleService>({
id: 'core.rootLifecycle',
scope: 'root',
});
@@ -14,16 +14,7 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import { LoggerService } from './loggerServiceRef';
import { LoggerService } from './LoggerService';
/** @public */
export type RootLoggerService = LoggerService;
/**
* @public
*/
export const rootLoggerServiceRef = createServiceRef<RootLoggerService>({
id: 'core.root.logger',
scope: 'root',
});
@@ -14,15 +14,7 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import { PluginTaskScheduler } from '@backstage/backend-tasks';
/** @public */
export type SchedulerService = PluginTaskScheduler;
/**
* @public
*/
export const schedulerServiceRef = createServiceRef<SchedulerService>({
id: 'core.scheduler',
});
@@ -14,15 +14,7 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import { TokenManager } from '@backstage/backend-common';
/** @public */
export type TokenManagerService = TokenManager;
/**
* @public
*/
export const tokenManagerServiceRef = createServiceRef<TokenManagerService>({
id: 'core.tokenManager',
});
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { createServiceRef } from '../system/types';
import { Readable } from 'stream';
/**
@@ -280,10 +279,3 @@ export type SearchResponseFile = {
*/
content(): Promise<Buffer>;
};
/**
* @public
*/
export const urlReaderServiceRef = createServiceRef<UrlReaderService>({
id: 'core.urlReader',
});
@@ -14,17 +14,165 @@
* limitations under the License.
*/
export { configServiceRef as config } from './configServiceRef';
export { httpRouterServiceRef as httpRouter } from './httpRouterServiceRef';
export { loggerServiceRef as logger } from './loggerServiceRef';
export { urlReaderServiceRef as urlReader } from './urlReaderServiceRef';
export { cacheServiceRef as cache } from './cacheServiceRef';
export { databaseServiceRef as database } from './databaseServiceRef';
export { discoveryServiceRef as discovery } from './discoveryServiceRef';
export { tokenManagerServiceRef as tokenManager } from './tokenManagerServiceRef';
export { permissionsServiceRef as permissions } from './permissionsServiceRef';
export { schedulerServiceRef as scheduler } from './schedulerServiceRef';
export { rootLifecycleServiceRef as rootLifecycle } from './rootLifecycleServiceRef';
export { rootLoggerServiceRef as rootLogger } from './rootLoggerServiceRef';
export { pluginMetadataServiceRef as pluginMetadata } from './pluginMetadataServiceRef';
export { lifecycleServiceRef as lifecycle } from './lifecycleServiceRef';
import { createServiceRef } from '../system';
/**
* All core services references
*
* @public
*/
export namespace coreServices {
/**
* The service reference for the plugin scoped {@link CacheService}.
*
* @public
*/
export const cache = createServiceRef<import('./CacheService').CacheService>({
id: 'core.cache',
});
/**
* The service reference for the root scoped {@link ConfigService}.
*
* @public
*/
export const config = createServiceRef<
import('./ConfigService').ConfigService
>({
id: 'core.root.config',
scope: 'root',
});
/**
* The service reference for the plugin scoped {@link DatabaseService}.
*
* @public
*/
export const database = createServiceRef<
import('./DatabaseService').DatabaseService
>({
id: 'core.database',
});
/**
* The service reference for the plugin scoped {@link DiscoveryService}.
*
* @public
*/
export const discovery = createServiceRef<
import('./DiscoveryService').DiscoveryService
>({
id: 'core.discovery',
});
/**
* The service reference for the plugin scoped {@link HttpRouterService}.
*
* @public
*/
export const httpRouter = createServiceRef<
import('./HttpRouterService').HttpRouterService
>({ id: 'core.httpRouter' });
/**
* The service reference for the plugin scoped {@link LifecycleService}.
*
* @public
*/
export const lifecycle = createServiceRef<
import('./LifecycleService').LifecycleService
>({
id: 'core.lifecycle',
scope: 'plugin',
});
/**
* The service reference for the plugin scoped {@link LoggerService}.
*
* @public
*/
export const logger = createServiceRef<
import('./LoggerService').LoggerService
>({
id: 'core.logger',
});
/**
* The service reference for the plugin scoped {@link PermissionsService}.
*
* @public
*/
export const permissions = createServiceRef<
import('./PermissionsService').PermissionsService
>({
id: 'core.permissions',
});
/**
* The service reference for the plugin scoped {@link PluginMetadataService}.
*
* @public
*/
export const pluginMetadata = createServiceRef<
import('./PluginMetadataService').PluginMetadataService
>({
id: 'core.plugin-metadata',
});
/**
* The service reference for the root scoped {@link RootLifecycleService}.
*
* @public
*/
export const rootLifecycle = createServiceRef<
import('./RootLifecycleService').RootLifecycleService
>({
id: 'core.rootLifecycle',
scope: 'root',
});
/**
* The service reference for the root scoped {@link RootLoggerService}.
*
* @public
*/
export const rootLogger = createServiceRef<
import('./RootLoggerService').RootLoggerService
>({
id: 'core.root.logger',
scope: 'root',
});
/**
* The service reference for the plugin scoped {@link SchedulerService}.
*
* @public
*/
export const scheduler = createServiceRef<
import('./SchedulerService').SchedulerService
>({
id: 'core.scheduler',
});
/**
* The service reference for the plugin scoped {@link TokenManagerService}.
*
* @public
*/
export const tokenManager = createServiceRef<
import('./TokenManagerService').TokenManagerService
>({
id: 'core.tokenManager',
});
/**
* The service reference for the plugin scoped {@link UrlReaderService}.
*
* @public
*/
export const urlReader = createServiceRef<
import('./UrlReaderService').UrlReaderService
>({
id: 'core.urlReader',
});
}
@@ -14,25 +14,23 @@
* limitations under the License.
*/
import * as coreServices from './coreServices';
export { coreServices };
export type { CacheService } from './cacheServiceRef';
export type { ConfigService } from './configServiceRef';
export type { DatabaseService } from './databaseServiceRef';
export type { DiscoveryService } from './discoveryServiceRef';
export type { HttpRouterService } from './httpRouterServiceRef';
export { coreServices } from './coreServices';
export type { CacheService } from './CacheService';
export type { ConfigService } from './ConfigService';
export type { DatabaseService } from './DatabaseService';
export type { DiscoveryService } from './DiscoveryService';
export type { HttpRouterService } from './HttpRouterService';
export type {
LifecycleService,
LifecycleServiceShutdownHook,
} from './lifecycleServiceRef';
export type { LoggerService, LogMeta } from './loggerServiceRef';
export type { PermissionsService } from './permissionsServiceRef';
export type { PluginMetadataService } from './pluginMetadataServiceRef';
export type { RootLifecycleService } from './rootLifecycleServiceRef';
export type { RootLoggerService } from './rootLoggerServiceRef';
export type { SchedulerService } from './schedulerServiceRef';
export type { TokenManagerService } from './tokenManagerServiceRef';
} from './LifecycleService';
export type { LoggerService, LogMeta } from './LoggerService';
export type { PermissionsService } from './PermissionsService';
export type { PluginMetadataService } from './PluginMetadataService';
export type { RootLifecycleService } from './RootLifecycleService';
export type { RootLoggerService } from './RootLoggerService';
export type { SchedulerService } from './SchedulerService';
export type { TokenManagerService } from './TokenManagerService';
export type {
ReadTreeOptions,
ReadTreeResponse,
@@ -44,4 +42,4 @@ export type {
SearchResponse,
SearchResponseFile,
UrlReaderService,
} from './urlReaderServiceRef';
} from './UrlReaderService';