backend-app-api: simplify defaultServiceFactories option

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-07-10 13:24:37 +02:00
parent 87d3f665f8
commit f691c9bf75
5 changed files with 31 additions and 30 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-app-api': minor
---
**BREAKING**: Removed the ability to pass callback-form service factories through the `defaultServiceFactories` option of `createSpecializedBackend`. This is an immediate breaking change as usage of this function is expected to be very rare.
+2 -2
View File
@@ -38,8 +38,8 @@ import { RootLifecycleService } from '@backstage/backend-plugin-api';
import { RootLoggerService } from '@backstage/backend-plugin-api';
import { SchedulerService } from '@backstage/backend-plugin-api';
import type { Server } from 'node:http';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceFactoryCompat } from '@backstage/backend-plugin-api';
import { ServiceFactoryOrFunction } from '@backstage/backend-plugin-api';
import { TokenManagerService } from '@backstage/backend-plugin-api';
import { transport } from 'winston';
import { UrlReaderService } from '@backstage/backend-plugin-api';
@@ -99,7 +99,7 @@ export function createSpecializedBackend(
// @public (undocumented)
export interface CreateSpecializedBackendOptions {
// (undocumented)
defaultServiceFactories: ServiceFactoryOrFunction[];
defaultServiceFactories: ServiceFactory[];
}
// @public @deprecated (undocumented)
@@ -24,13 +24,9 @@ import { Backend, CreateSpecializedBackendOptions } from './types';
export function createSpecializedBackend(
options: CreateSpecializedBackendOptions,
): Backend {
const services = options.defaultServiceFactories.map(sf =>
typeof sf === 'function' ? sf() : sf,
);
const exists = new Set<string>();
const duplicates = new Set<string>();
for (const { service } of services) {
for (const { service } of options.defaultServiceFactories) {
if (exists.has(service.id)) {
duplicates.add(service.id);
} else {
@@ -47,5 +43,5 @@ export function createSpecializedBackend(
);
}
return new BackstageBackend(services);
return new BackstageBackend(options.defaultServiceFactories);
}
+2 -2
View File
@@ -18,7 +18,7 @@ import {
BackendFeature,
ExtensionPoint,
ServiceRef,
ServiceFactoryOrFunction,
ServiceFactory,
} from '@backstage/backend-plugin-api';
/**
@@ -39,7 +39,7 @@ export interface Backend {
* @public
*/
export interface CreateSpecializedBackendOptions {
defaultServiceFactories: ServiceFactoryOrFunction[];
defaultServiceFactories: ServiceFactory[];
}
/**
+20 -20
View File
@@ -40,26 +40,26 @@ import { userInfoServiceFactory } from '@backstage/backend-defaults/userInfo';
import { eventsServiceFactory } from '@backstage/plugin-events-node';
export const defaultServiceFactories = [
authServiceFactory(),
cacheServiceFactory(),
rootConfigServiceFactory(),
databaseServiceFactory(),
discoveryServiceFactory(),
httpAuthServiceFactory(),
httpRouterServiceFactory(),
identityServiceFactory(),
lifecycleServiceFactory(),
loggerServiceFactory(),
permissionsServiceFactory(),
rootHealthServiceFactory(),
rootHttpRouterServiceFactory(),
rootLifecycleServiceFactory(),
rootLoggerServiceFactory(),
schedulerServiceFactory(),
tokenManagerServiceFactory(),
userInfoServiceFactory(),
urlReaderServiceFactory(),
eventsServiceFactory(),
authServiceFactory,
cacheServiceFactory,
rootConfigServiceFactory,
databaseServiceFactory,
discoveryServiceFactory,
httpAuthServiceFactory,
httpRouterServiceFactory,
identityServiceFactory,
lifecycleServiceFactory,
loggerServiceFactory,
permissionsServiceFactory,
rootHealthServiceFactory,
rootHttpRouterServiceFactory,
rootLifecycleServiceFactory,
rootLoggerServiceFactory,
schedulerServiceFactory,
tokenManagerServiceFactory,
userInfoServiceFactory,
urlReaderServiceFactory,
eventsServiceFactory,
];
/**