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:
@@ -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)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user