From 5cad431d0c6704d669b11b4807803100f853bd27 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 2 Dec 2022 14:29:50 +0100 Subject: [PATCH] backend-plugin-api: export service refs via single coreServices object Co-authored-by: Johan Haals Signed-off-by: Patrik Oldsberg --- packages/backend-plugin-api/api-report.md | 45 +++++++++++++------ .../src/services/definitions/coreServices.ts | 29 ++++++++++++ .../src/services/definitions/index.ts | 16 ++----- 3 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 packages/backend-plugin-api/src/services/definitions/coreServices.ts diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index b73a85c32e..17cae29bff 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -76,10 +76,29 @@ export interface BackendRegistrationPoints { } // @public (undocumented) -export const cacheServiceRef: ServiceRef; +const cacheServiceRef: ServiceRef; // @public (undocumented) -export const configServiceRef: ServiceRef; +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, + rootLoggerServiceRef as rootLogger, + pluginMetadataServiceRef as pluginMetadata, + lifecycleServiceRef as lifecycle, + }; +} +export { coreServices }; // @public export function createBackendModule< @@ -146,10 +165,10 @@ export function createServiceRef(options: { }): ServiceRef; // @public (undocumented) -export const databaseServiceRef: ServiceRef; +const databaseServiceRef: ServiceRef; // @public (undocumented) -export const discoveryServiceRef: ServiceRef; +const discoveryServiceRef: ServiceRef; // @public export type ExtensionPoint = { @@ -166,10 +185,10 @@ export interface HttpRouterService { } // @public (undocumented) -export const httpRouterServiceRef: ServiceRef; +const httpRouterServiceRef: ServiceRef; // @public (undocumented) -export const lifecycleServiceRef: ServiceRef; +const lifecycleServiceRef: ServiceRef; // @public (undocumented) export interface Logger { @@ -180,7 +199,7 @@ export interface Logger { } // @public (undocumented) -export const loggerServiceRef: ServiceRef; +const loggerServiceRef: ServiceRef; // @public (undocumented) export function loggerToWinstonLogger( @@ -189,7 +208,7 @@ export function loggerToWinstonLogger( ): Logger_2; // @public (undocumented) -export const permissionsServiceRef: ServiceRef< +const permissionsServiceRef: ServiceRef< PermissionAuthorizer | PermissionEvaluator, 'plugin' >; @@ -201,13 +220,13 @@ export interface PluginMetadata { } // @public (undocumented) -export const pluginMetadataServiceRef: ServiceRef; +const pluginMetadataServiceRef: ServiceRef; // @public (undocumented) -export const rootLoggerServiceRef: ServiceRef; +const rootLoggerServiceRef: ServiceRef; // @public (undocumented) -export const schedulerServiceRef: ServiceRef; +const schedulerServiceRef: ServiceRef; // @public (undocumented) export type ServiceFactory = @@ -249,7 +268,7 @@ export type ServiceRef< }; // @public (undocumented) -export const tokenManagerServiceRef: ServiceRef; +const tokenManagerServiceRef: ServiceRef; // @public (undocumented) export type TypesToServiceRef = { @@ -257,5 +276,5 @@ export type TypesToServiceRef = { }; // @public (undocumented) -export const urlReaderServiceRef: ServiceRef; +const urlReaderServiceRef: ServiceRef; ``` diff --git a/packages/backend-plugin-api/src/services/definitions/coreServices.ts b/packages/backend-plugin-api/src/services/definitions/coreServices.ts new file mode 100644 index 0000000000..d5a5953806 --- /dev/null +++ b/packages/backend-plugin-api/src/services/definitions/coreServices.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +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 { rootLoggerServiceRef as rootLogger } from './rootLoggerServiceRef'; +export { pluginMetadataServiceRef as pluginMetadata } from './pluginMetadataServiceRef'; +export { lifecycleServiceRef as lifecycle } from './lifecycleServiceRef'; diff --git a/packages/backend-plugin-api/src/services/definitions/index.ts b/packages/backend-plugin-api/src/services/definitions/index.ts index cf997a344d..1ff33362fa 100644 --- a/packages/backend-plugin-api/src/services/definitions/index.ts +++ b/packages/backend-plugin-api/src/services/definitions/index.ts @@ -14,21 +14,11 @@ * limitations under the License. */ -export { configServiceRef } from './configServiceRef'; -export { httpRouterServiceRef } from './httpRouterServiceRef'; +import * as coreServices from './coreServices'; + +export { coreServices }; export type { HttpRouterService } from './httpRouterServiceRef'; -export { loggerServiceRef } from './loggerServiceRef'; export type { Logger } from './loggerServiceRef'; -export { urlReaderServiceRef } from './urlReaderServiceRef'; -export { cacheServiceRef } from './cacheServiceRef'; -export { databaseServiceRef } from './databaseServiceRef'; -export { discoveryServiceRef } from './discoveryServiceRef'; -export { tokenManagerServiceRef } from './tokenManagerServiceRef'; -export { permissionsServiceRef } from './permissionsServiceRef'; -export { schedulerServiceRef } from './schedulerServiceRef'; -export { rootLoggerServiceRef } from './rootLoggerServiceRef'; -export { pluginMetadataServiceRef } from './pluginMetadataServiceRef'; -export { lifecycleServiceRef } from './lifecycleServiceRef'; export type { BackendLifecycle, BackendLifecycleShutdownHook,