backend-plugin-api: convert all core service definitions to interfaces

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-01-03 14:50:39 +01:00
parent 16054afdec
commit 6a4419041b
12 changed files with 49 additions and 49 deletions
+16 -12
View File
@@ -4,19 +4,21 @@
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { CacheService } from '@backstage/backend-plugin-api';
import { ConfigService } from '@backstage/backend-plugin-api';
import { DatabaseService } from '@backstage/backend-plugin-api';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { HttpRouterService } from '@backstage/backend-plugin-api';
import { LifecycleService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PermissionsService } from '@backstage/backend-plugin-api';
import { PluginCacheManager } from '@backstage/backend-common';
import { PluginDatabaseManager } from '@backstage/backend-common';
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { PluginTaskScheduler } from '@backstage/backend-tasks';
import { RootLifecycleService } from '@backstage/backend-plugin-api';
import { RootLoggerService } from '@backstage/backend-plugin-api';
import { SchedulerService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceRef } from '@backstage/backend-plugin-api';
import { TokenManager } from '@backstage/backend-common';
import { TokenManagerService } from '@backstage/backend-plugin-api';
import { UrlReader } from '@backstage/backend-common';
// @public (undocumented)
@@ -32,10 +34,12 @@ export interface Backend {
// @public (undocumented)
export const cacheFactory: (
options?: undefined,
) => ServiceFactory<PluginCacheManager>;
) => ServiceFactory<CacheService>;
// @public (undocumented)
export const configFactory: (options?: undefined) => ServiceFactory<Config>;
export const configFactory: (
options?: undefined,
) => ServiceFactory<ConfigService>;
// @public (undocumented)
export function createSpecializedBackend(
@@ -51,7 +55,7 @@ export interface CreateSpecializedBackendOptions {
// @public (undocumented)
export const databaseFactory: (
options?: undefined,
) => ServiceFactory<PluginDatabaseManager>;
) => ServiceFactory<DatabaseService>;
// @public (undocumented)
export const discoveryFactory: (
@@ -86,17 +90,17 @@ export const permissionsFactory: (
// @public
export const rootLifecycleFactory: (
options?: undefined,
) => ServiceFactory<LifecycleService>;
) => ServiceFactory<RootLifecycleService>;
// @public (undocumented)
export const rootLoggerFactory: (
options?: undefined,
) => ServiceFactory<LoggerService>;
) => ServiceFactory<RootLoggerService>;
// @public (undocumented)
export const schedulerFactory: (
options?: undefined,
) => ServiceFactory<PluginTaskScheduler>;
) => ServiceFactory<SchedulerService>;
// @public (undocumented)
export type ServiceOrExtensionPoint<T = unknown> =
@@ -106,7 +110,7 @@ export type ServiceOrExtensionPoint<T = unknown> =
// @public (undocumented)
export const tokenManagerFactory: (
options?: undefined,
) => ServiceFactory<TokenManager>;
) => ServiceFactory<TokenManagerService>;
// @public (undocumented)
export const urlReaderFactory: (
+20 -21
View File
@@ -8,7 +8,6 @@
import { Config } from '@backstage/config';
import { Handler } from 'express';
import { Logger } from 'winston';
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
import { PluginCacheManager } from '@backstage/backend-common';
import { PluginDatabaseManager } from '@backstage/backend-common';
@@ -67,26 +66,26 @@ export interface BackendRegistrationPoints {
}
// @public (undocumented)
export type CacheService = PluginCacheManager;
export interface CacheService extends PluginCacheManager {}
// @public (undocumented)
export type ConfigService = Config;
export interface ConfigService extends Config {}
// @public
export namespace coreServices {
const cache: ServiceRef<PluginCacheManager, 'plugin'>;
const config: ServiceRef<Config, 'root'>;
const database: ServiceRef<PluginDatabaseManager, 'plugin'>;
const cache: ServiceRef<CacheService, 'plugin'>;
const config: ServiceRef<ConfigService, 'root'>;
const database: ServiceRef<DatabaseService, 'plugin'>;
const discovery: ServiceRef<DiscoveryService, 'plugin'>;
const httpRouter: ServiceRef<HttpRouterService, 'plugin'>;
const lifecycle: ServiceRef<LifecycleService, 'plugin'>;
const logger: ServiceRef<LoggerService, 'plugin'>;
const permissions: ServiceRef<PermissionsService, 'plugin'>;
const pluginMetadata: ServiceRef<PluginMetadataService, 'plugin'>;
const rootLifecycle: ServiceRef<LifecycleService, 'root'>;
const rootLogger: ServiceRef<LoggerService, 'root'>;
const scheduler: ServiceRef<PluginTaskScheduler, 'plugin'>;
const tokenManager: ServiceRef<TokenManager, 'plugin'>;
const rootLifecycle: ServiceRef<RootLifecycleService, 'root'>;
const rootLogger: ServiceRef<RootLoggerService, 'root'>;
const scheduler: ServiceRef<SchedulerService, 'plugin'>;
const tokenManager: ServiceRef<TokenManagerService, 'plugin'>;
const urlReader: ServiceRef<UrlReaderService, 'plugin'>;
}
@@ -155,13 +154,13 @@ export function createServiceRef<T>(options: {
}): ServiceRef<T, 'root'>;
// @public (undocumented)
export type DatabaseService = PluginDatabaseManager;
export interface DatabaseService extends PluginDatabaseManager {}
// @public
export type DiscoveryService = {
export interface DiscoveryService {
getBaseUrl(pluginId: string): Promise<string>;
getExternalBaseUrl(pluginId: string): Promise<string>;
};
}
// @public
export type ExtensionPoint<T> = {
@@ -214,7 +213,7 @@ export type LogMeta = {
};
// @public (undocumented)
export type PermissionsService = PermissionEvaluator | PermissionAuthorizer;
export interface PermissionsService extends PermissionEvaluator {}
// @public (undocumented)
export interface PluginMetadataService {
@@ -267,13 +266,13 @@ export type ReadUrlResponse = {
};
// @public (undocumented)
export type RootLifecycleService = LifecycleService;
export interface RootLifecycleService extends LifecycleService {}
// @public (undocumented)
export type RootLoggerService = LoggerService;
export interface RootLoggerService extends LoggerService {}
// @public (undocumented)
export type SchedulerService = PluginTaskScheduler;
export interface SchedulerService extends PluginTaskScheduler {}
// @public
export type SearchOptions = {
@@ -333,7 +332,7 @@ export type ServiceRef<
};
// @public (undocumented)
export type TokenManagerService = TokenManager;
export interface TokenManagerService extends TokenManager {}
// @public (undocumented)
export type TypesToServiceRef<T> = {
@@ -341,9 +340,9 @@ export type TypesToServiceRef<T> = {
};
// @public
export type UrlReaderService = {
readUrl(url: string, options?: ReadUrlOptions): Promise<ReadUrlResponse>;
export interface UrlReaderService {
readTree(url: string, options?: ReadTreeOptions): Promise<ReadTreeResponse>;
readUrl(url: string, options?: ReadUrlOptions): Promise<ReadUrlResponse>;
search(url: string, options?: SearchOptions): Promise<SearchResponse>;
};
}
```
@@ -17,4 +17,4 @@
import { PluginCacheManager } from '@backstage/backend-common';
/** @public */
export type CacheService = PluginCacheManager;
export interface CacheService extends PluginCacheManager {}
@@ -19,4 +19,4 @@ import { Config } from '@backstage/config';
/**
* @public
*/
export type ConfigService = Config;
export interface ConfigService extends Config {}
@@ -17,4 +17,4 @@
import { PluginDatabaseManager } from '@backstage/backend-common';
/** @public */
export type DatabaseService = PluginDatabaseManager;
export interface DatabaseService extends PluginDatabaseManager {}
@@ -28,7 +28,7 @@
*
* @public
*/
export type DiscoveryService = {
export interface DiscoveryService {
/**
* Returns the internal HTTP base URL for a given plugin, without a trailing slash.
*
@@ -60,4 +60,4 @@ export type DiscoveryService = {
* like `https://backstage.example.com/api/catalog`
*/
getExternalBaseUrl(pluginId: string): Promise<string>;
};
}
@@ -14,10 +14,7 @@
* limitations under the License.
*/
import {
PermissionAuthorizer,
PermissionEvaluator,
} from '@backstage/plugin-permission-common';
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
/** @public */
export type PermissionsService = PermissionEvaluator | PermissionAuthorizer;
export interface PermissionsService extends PermissionEvaluator {}
@@ -17,4 +17,4 @@
import { LifecycleService } from './LifecycleService';
/** @public */
export type RootLifecycleService = LifecycleService;
export interface RootLifecycleService extends LifecycleService {}
@@ -17,4 +17,4 @@
import { LoggerService } from './LoggerService';
/** @public */
export type RootLoggerService = LoggerService;
export interface RootLoggerService extends LoggerService {}
@@ -17,4 +17,4 @@
import { PluginTaskScheduler } from '@backstage/backend-tasks';
/** @public */
export type SchedulerService = PluginTaskScheduler;
export interface SchedulerService extends PluginTaskScheduler {}
@@ -17,4 +17,4 @@
import { TokenManager } from '@backstage/backend-common';
/** @public */
export type TokenManagerService = TokenManager;
export interface TokenManagerService extends TokenManager {}
@@ -21,7 +21,7 @@ import { Readable } from 'stream';
*
* @public
*/
export type UrlReaderService = {
export interface UrlReaderService {
/**
* Reads a single file and return its content.
*/
@@ -36,7 +36,7 @@ export type UrlReaderService = {
* Searches for a file in a tree using a glob pattern.
*/
search(url: string, options?: SearchOptions): Promise<SearchResponse>;
};
}
/**
* An options object for readUrl operations.