backend-app-api: avoid using service factory options for plugin meta service

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-07-11 11:18:18 +02:00
parent 87d3f665f8
commit 617a7d29c2
2 changed files with 11 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-app-api': patch
---
Internal refactor that avoids the use of service factory options.
@@ -48,13 +48,13 @@ function toInternalServiceFactory<TService, TScope extends 'plugin' | 'root'>(
return f;
}
const pluginMetadataServiceFactory = createServiceFactory(
(options?: { pluginId: string }) => ({
function createPluginMetadataServiceFactory(pluginId: string) {
return createServiceFactory({
service: coreServices.pluginMetadata,
deps: {},
factory: async () => ({ getId: () => options?.pluginId! }),
}),
);
factory: async () => ({ getId: () => pluginId }),
});
}
export class ServiceRegistry {
static create(factories: Array<ServiceFactory>): ServiceRegistry {
@@ -97,7 +97,7 @@ export class ServiceRegistry {
// Special case handling of the plugin metadata service, generating a custom factory for it each time
if (ref.id === coreServices.pluginMetadata.id) {
return Promise.resolve(
toInternalServiceFactory(pluginMetadataServiceFactory({ pluginId })),
toInternalServiceFactory(createPluginMetadataServiceFactory(pluginId)),
);
}