diff --git a/.changeset/rich-clouds-smile.md b/.changeset/rich-clouds-smile.md new file mode 100644 index 0000000000..ee7b70644d --- /dev/null +++ b/.changeset/rich-clouds-smile.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-plugin-api': patch +--- + +Documented `coreServices` an all of its members. diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index ef88d9a9d0..fa3f3bec2e 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -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; +) => ServiceFactory; // @public (undocumented) -export const configFactory: (options?: undefined) => ServiceFactory; +export const configFactory: ( + options?: undefined, +) => ServiceFactory; // @public (undocumented) export function createSpecializedBackend( @@ -51,7 +55,7 @@ export interface CreateSpecializedBackendOptions { // @public (undocumented) export const databaseFactory: ( options?: undefined, -) => ServiceFactory; +) => ServiceFactory; // @public (undocumented) export const discoveryFactory: ( @@ -86,17 +90,17 @@ export const permissionsFactory: ( // @public export const rootLifecycleFactory: ( options?: undefined, -) => ServiceFactory; +) => ServiceFactory; // @public (undocumented) export const rootLoggerFactory: ( options?: undefined, -) => ServiceFactory; +) => ServiceFactory; // @public (undocumented) export const schedulerFactory: ( options?: undefined, -) => ServiceFactory; +) => ServiceFactory; // @public (undocumented) export type ServiceOrExtensionPoint = @@ -106,7 +110,7 @@ export type ServiceOrExtensionPoint = // @public (undocumented) export const tokenManagerFactory: ( options?: undefined, -) => ServiceFactory; +) => ServiceFactory; // @public (undocumented) export const urlReaderFactory: ( diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index e0fa44eb20..9c6ffe6dd5 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -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,36 +66,28 @@ export interface BackendRegistrationPoints { } // @public (undocumented) -export type CacheService = PluginCacheManager; +export interface CacheService extends PluginCacheManager {} // @public (undocumented) -const cacheServiceRef: ServiceRef; +export interface ConfigService extends Config {} -// @public (undocumented) -export type ConfigService = Config; - -// @public (undocumented) -const configServiceRef: ServiceRef; - -declare namespace coreServices { - export { - configServiceRef as config, - httpRouterServiceRef as httpRouter, - loggerServiceRef as logger, - urlReaderServiceRef as urlReader, - cacheServiceRef as cache, - databaseServiceRef as database, - discoveryServiceRef as discovery, - tokenManagerServiceRef as tokenManager, - permissionsServiceRef as permissions, - schedulerServiceRef as scheduler, - rootLifecycleServiceRef as rootLifecycle, - rootLoggerServiceRef as rootLogger, - pluginMetadataServiceRef as pluginMetadata, - lifecycleServiceRef as lifecycle, - }; +// @public +export namespace coreServices { + const cache: ServiceRef; + const config: ServiceRef; + const database: ServiceRef; + const discovery: ServiceRef; + const httpRouter: ServiceRef; + const lifecycle: ServiceRef; + const logger: ServiceRef; + const permissions: ServiceRef; + const pluginMetadata: ServiceRef; + const rootLifecycle: ServiceRef; + const rootLogger: ServiceRef; + const scheduler: ServiceRef; + const tokenManager: ServiceRef; + const urlReader: ServiceRef; } -export { coreServices }; // @public export function createBackendModule< @@ -163,19 +154,13 @@ export function createServiceRef(options: { }): ServiceRef; // @public (undocumented) -export type DatabaseService = PluginDatabaseManager; - -// @public (undocumented) -const databaseServiceRef: ServiceRef; +export interface DatabaseService extends PluginDatabaseManager {} // @public -export type DiscoveryService = { +export interface DiscoveryService { getBaseUrl(pluginId: string): Promise; getExternalBaseUrl(pluginId: string): Promise; -}; - -// @public (undocumented) -const discoveryServiceRef: ServiceRef; +} // @public export type ExtensionPoint = { @@ -191,24 +176,18 @@ export interface HttpRouterService { use(handler: Handler): void; } -// @public (undocumented) -const httpRouterServiceRef: ServiceRef; - // @public (undocumented) export interface LifecycleService { addShutdownHook(options: LifecycleServiceShutdownHook): void; } -// @public (undocumented) -const lifecycleServiceRef: ServiceRef; - // @public (undocumented) export type LifecycleServiceShutdownHook = { fn: () => void | Promise; labels?: Record; }; -// @public (undocumented) +// @public export interface LoggerService { // (undocumented) child(meta: LogMeta): LoggerService; @@ -222,9 +201,6 @@ export interface LoggerService { warn(message: string, meta?: Error | LogMeta): void; } -// @public (undocumented) -const loggerServiceRef: ServiceRef; - // @public (undocumented) export function loggerToWinstonLogger( logger: LoggerService, @@ -237,10 +213,7 @@ export type LogMeta = { }; // @public (undocumented) -export type PermissionsService = PermissionEvaluator | PermissionAuthorizer; - -// @public (undocumented) -const permissionsServiceRef: ServiceRef; +export interface PermissionsService extends PermissionEvaluator {} // @public (undocumented) export interface PluginMetadataService { @@ -248,9 +221,6 @@ export interface PluginMetadataService { getId(): string; } -// @public (undocumented) -const pluginMetadataServiceRef: ServiceRef; - // @public export type ReadTreeOptions = { filter?( @@ -296,22 +266,13 @@ export type ReadUrlResponse = { }; // @public (undocumented) -export type RootLifecycleService = LifecycleService; +export interface RootLifecycleService extends LifecycleService {} // @public (undocumented) -const rootLifecycleServiceRef: ServiceRef; +export interface RootLoggerService extends LoggerService {} // @public (undocumented) -export type RootLoggerService = LoggerService; - -// @public (undocumented) -const rootLoggerServiceRef: ServiceRef; - -// @public (undocumented) -export type SchedulerService = PluginTaskScheduler; - -// @public (undocumented) -const schedulerServiceRef: ServiceRef; +export interface SchedulerService extends PluginTaskScheduler {} // @public export type SearchOptions = { @@ -371,10 +332,7 @@ export type ServiceRef< }; // @public (undocumented) -export type TokenManagerService = TokenManager; - -// @public (undocumented) -const tokenManagerServiceRef: ServiceRef; +export interface TokenManagerService extends TokenManager {} // @public (undocumented) export type TypesToServiceRef = { @@ -382,12 +340,9 @@ export type TypesToServiceRef = { }; // @public -export type UrlReaderService = { - readUrl(url: string, options?: ReadUrlOptions): Promise; +export interface UrlReaderService { readTree(url: string, options?: ReadTreeOptions): Promise; + readUrl(url: string, options?: ReadUrlOptions): Promise; search(url: string, options?: SearchOptions): Promise; -}; - -// @public (undocumented) -const urlReaderServiceRef: ServiceRef; +} ``` diff --git a/packages/backend-plugin-api/src/services/definitions/cacheServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/CacheService.ts similarity index 76% rename from packages/backend-plugin-api/src/services/definitions/cacheServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/CacheService.ts index aff913b06a..79c930f435 100644 --- a/packages/backend-plugin-api/src/services/definitions/cacheServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/CacheService.ts @@ -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({ - id: 'core.cache', -}); +export interface CacheService extends PluginCacheManager {} diff --git a/packages/backend-plugin-api/src/services/definitions/configServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/ConfigService.ts similarity index 75% rename from packages/backend-plugin-api/src/services/definitions/configServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/ConfigService.ts index 15e9cb9aa6..db9aa88dda 100644 --- a/packages/backend-plugin-api/src/services/definitions/configServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/ConfigService.ts @@ -15,17 +15,8 @@ */ import { Config } from '@backstage/config'; -import { createServiceRef } from '../system/types'; /** * @public */ -export type ConfigService = Config; - -/** - * @public - */ -export const configServiceRef = createServiceRef({ - id: 'core.root.config', - scope: 'root', -}); +export interface ConfigService extends Config {} diff --git a/packages/backend-plugin-api/src/services/definitions/databaseServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/DatabaseService.ts similarity index 75% rename from packages/backend-plugin-api/src/services/definitions/databaseServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/DatabaseService.ts index aaea5d304f..30f1f574f2 100644 --- a/packages/backend-plugin-api/src/services/definitions/databaseServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/DatabaseService.ts @@ -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({ - id: 'core.database', -}); +export interface DatabaseService extends PluginDatabaseManager {} diff --git a/packages/backend-plugin-api/src/services/definitions/discoveryServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/DiscoveryService.ts similarity index 92% rename from packages/backend-plugin-api/src/services/definitions/discoveryServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/DiscoveryService.ts index fb508a7ae1..c3f0820c28 100644 --- a/packages/backend-plugin-api/src/services/definitions/discoveryServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/DiscoveryService.ts @@ -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. @@ -30,7 +28,7 @@ import { createServiceRef } from '../system/types'; * * @public */ -export type DiscoveryService = { +export interface DiscoveryService { /** * Returns the internal HTTP base URL for a given plugin, without a trailing slash. * @@ -62,11 +60,4 @@ export type DiscoveryService = { * like `https://backstage.example.com/api/catalog` */ getExternalBaseUrl(pluginId: string): Promise; -}; - -/** - * @public - */ -export const discoveryServiceRef = createServiceRef({ - id: 'core.discovery', -}); +} diff --git a/packages/backend-plugin-api/src/services/definitions/httpRouterServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/HttpRouterService.ts similarity index 80% rename from packages/backend-plugin-api/src/services/definitions/httpRouterServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/HttpRouterService.ts index fbc5a27e87..3c45ef1da1 100644 --- a/packages/backend-plugin-api/src/services/definitions/httpRouterServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/HttpRouterService.ts @@ -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({ - id: 'core.httpRouter', -}); diff --git a/packages/backend-plugin-api/src/services/definitions/lifecycleServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/LifecycleService.ts similarity index 83% rename from packages/backend-plugin-api/src/services/definitions/lifecycleServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/LifecycleService.ts index e54f650fcc..b6f2b69e1c 100644 --- a/packages/backend-plugin-api/src/services/definitions/lifecycleServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/LifecycleService.ts @@ -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({ - id: 'core.lifecycle', - scope: 'plugin', -}); diff --git a/packages/backend-plugin-api/src/services/definitions/loggerServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/LoggerService.ts similarity index 85% rename from packages/backend-plugin-api/src/services/definitions/loggerServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/LoggerService.ts index 1c094549c1..269dfa0166 100644 --- a/packages/backend-plugin-api/src/services/definitions/loggerServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/LoggerService.ts @@ -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({ - id: 'core.logger', -}); diff --git a/packages/backend-plugin-api/src/services/definitions/PermissionsService.ts b/packages/backend-plugin-api/src/services/definitions/PermissionsService.ts new file mode 100644 index 0000000000..5847f55ee6 --- /dev/null +++ b/packages/backend-plugin-api/src/services/definitions/PermissionsService.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { PermissionEvaluator } from '@backstage/plugin-permission-common'; + +/** @public */ +export interface PermissionsService extends PermissionEvaluator {} diff --git a/packages/backend-plugin-api/src/services/definitions/pluginMetadataServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/PluginMetadataService.ts similarity index 77% rename from packages/backend-plugin-api/src/services/definitions/pluginMetadataServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/PluginMetadataService.ts index 4c1ecb130e..48328e4db9 100644 --- a/packages/backend-plugin-api/src/services/definitions/pluginMetadataServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/PluginMetadataService.ts @@ -14,20 +14,9 @@ * limitations under the License. */ -import { createServiceRef } from '../system/types'; - /** * @public */ export interface PluginMetadataService { getId(): string; } - -/** - * @public - */ -export const pluginMetadataServiceRef = createServiceRef( - { - id: 'core.plugin-metadata', - }, -); diff --git a/packages/backend-plugin-api/src/services/definitions/RootLifecycleService.ts b/packages/backend-plugin-api/src/services/definitions/RootLifecycleService.ts new file mode 100644 index 0000000000..e0e09cb859 --- /dev/null +++ b/packages/backend-plugin-api/src/services/definitions/RootLifecycleService.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LifecycleService } from './LifecycleService'; + +/** @public */ +export interface RootLifecycleService extends LifecycleService {} diff --git a/packages/backend-plugin-api/src/services/definitions/RootLoggerService.ts b/packages/backend-plugin-api/src/services/definitions/RootLoggerService.ts new file mode 100644 index 0000000000..ad318ef53f --- /dev/null +++ b/packages/backend-plugin-api/src/services/definitions/RootLoggerService.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LoggerService } from './LoggerService'; + +/** @public */ +export interface RootLoggerService extends LoggerService {} diff --git a/packages/backend-plugin-api/src/services/definitions/schedulerServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/SchedulerService.ts similarity index 75% rename from packages/backend-plugin-api/src/services/definitions/schedulerServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/SchedulerService.ts index 160f2fbb93..07c436bd6b 100644 --- a/packages/backend-plugin-api/src/services/definitions/schedulerServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/SchedulerService.ts @@ -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({ - id: 'core.scheduler', -}); +export interface SchedulerService extends PluginTaskScheduler {} diff --git a/packages/backend-plugin-api/src/services/definitions/tokenManagerServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/TokenManagerService.ts similarity index 74% rename from packages/backend-plugin-api/src/services/definitions/tokenManagerServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/TokenManagerService.ts index 4b12acdc58..7fccb60c7a 100644 --- a/packages/backend-plugin-api/src/services/definitions/tokenManagerServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/TokenManagerService.ts @@ -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({ - id: 'core.tokenManager', -}); +export interface TokenManagerService extends TokenManager {} diff --git a/packages/backend-plugin-api/src/services/definitions/urlReaderServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts similarity index 97% rename from packages/backend-plugin-api/src/services/definitions/urlReaderServiceRef.ts rename to packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts index db296b5807..ef825a7fcd 100644 --- a/packages/backend-plugin-api/src/services/definitions/urlReaderServiceRef.ts +++ b/packages/backend-plugin-api/src/services/definitions/UrlReaderService.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { createServiceRef } from '../system/types'; import { Readable } from 'stream'; /** @@ -22,7 +21,7 @@ import { Readable } from 'stream'; * * @public */ -export type UrlReaderService = { +export interface UrlReaderService { /** * Reads a single file and return its content. */ @@ -37,7 +36,7 @@ export type UrlReaderService = { * Searches for a file in a tree using a glob pattern. */ search(url: string, options?: SearchOptions): Promise; -}; +} /** * An options object for readUrl operations. @@ -280,10 +279,3 @@ export type SearchResponseFile = { */ content(): Promise; }; - -/** - * @public - */ -export const urlReaderServiceRef = createServiceRef({ - id: 'core.urlReader', -}); diff --git a/packages/backend-plugin-api/src/services/definitions/coreServices.ts b/packages/backend-plugin-api/src/services/definitions/coreServices.ts index a2b1a04d41..fc96ec8be9 100644 --- a/packages/backend-plugin-api/src/services/definitions/coreServices.ts +++ b/packages/backend-plugin-api/src/services/definitions/coreServices.ts @@ -14,17 +14,137 @@ * 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({ + id: 'core.cache', + }); + + /** + * The service reference for the root scoped {@link ConfigService}. + * + * @public + */ + export const config = createServiceRef< + import('./ConfigService').ConfigService + >({ id: 'core.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' }); + + /** + * 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.pluginMetadata' }); + + /** + * 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.rootLogger', 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' }); +} diff --git a/packages/backend-plugin-api/src/services/definitions/index.ts b/packages/backend-plugin-api/src/services/definitions/index.ts index 953d4b28ad..dedfd6223e 100644 --- a/packages/backend-plugin-api/src/services/definitions/index.ts +++ b/packages/backend-plugin-api/src/services/definitions/index.ts @@ -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'; diff --git a/packages/backend-plugin-api/src/services/definitions/permissionsServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/permissionsServiceRef.ts deleted file mode 100644 index b24b2f5f46..0000000000 --- a/packages/backend-plugin-api/src/services/definitions/permissionsServiceRef.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2022 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createServiceRef } from '../system/types'; -import { - PermissionAuthorizer, - PermissionEvaluator, -} from '@backstage/plugin-permission-common'; - -/** @public */ -export type PermissionsService = PermissionEvaluator | PermissionAuthorizer; - -/** - * @public - */ -export const permissionsServiceRef = createServiceRef({ - id: 'core.permissions', -}); diff --git a/packages/backend-plugin-api/src/services/definitions/rootLifecycleServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/rootLifecycleServiceRef.ts deleted file mode 100644 index e0d5355983..0000000000 --- a/packages/backend-plugin-api/src/services/definitions/rootLifecycleServiceRef.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createServiceRef } from '../system/types'; -import { LifecycleService } from './lifecycleServiceRef'; - -/** @public */ -export type RootLifecycleService = LifecycleService; - -/** - * @public - */ -export const rootLifecycleServiceRef = createServiceRef({ - id: 'core.rootLifecycle', - scope: 'root', -}); diff --git a/packages/backend-plugin-api/src/services/definitions/rootLoggerServiceRef.ts b/packages/backend-plugin-api/src/services/definitions/rootLoggerServiceRef.ts deleted file mode 100644 index af26ce8899..0000000000 --- a/packages/backend-plugin-api/src/services/definitions/rootLoggerServiceRef.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createServiceRef } from '../system/types'; -import { LoggerService } from './loggerServiceRef'; - -/** @public */ -export type RootLoggerService = LoggerService; - -/** - * @public - */ -export const rootLoggerServiceRef = createServiceRef({ - id: 'core.root.logger', - scope: 'root', -});