Merge pull request #25571 from backstage/rugvip/compat

backend-*: deprecate or remove support for installing backend features with callback form
This commit is contained in:
Patrik Oldsberg
2024-07-16 09:16:22 +02:00
committed by GitHub
10 changed files with 67 additions and 54 deletions
+3 -6
View File
@@ -371,9 +371,7 @@ export namespace mockServices {
// @public
export class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
static from<TService, TScope extends 'root' | 'plugin'>(
subject:
| ServiceFactory<TService, TScope>
| (() => ServiceFactory<TService, TScope>),
subject: ServiceFactory<TService, TScope>,
options?: ServiceFactoryTesterOptions,
): ServiceFactoryTester<TService, TScope>;
// @deprecated
@@ -391,7 +389,7 @@ export class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
// @public
export interface ServiceFactoryTesterOptions {
dependencies?: Array<ServiceFactory | (() => ServiceFactory)>;
dependencies?: Array<ServiceFactory>;
}
// @public (undocumented)
@@ -436,9 +434,8 @@ export interface TestBackendOptions<TExtensionPoints extends any[]> {
// (undocumented)
features?: Array<
| BackendFeature
| (() => BackendFeature)
| Promise<{
default: BackendFeature | (() => BackendFeature);
default: BackendFeature;
}>
>;
}
@@ -35,7 +35,7 @@ export interface ServiceFactoryTesterOptions {
* If a service factory is provided for a service that already has a default
* implementation, the provided factory will override the default.
*/
dependencies?: Array<ServiceFactory | (() => ServiceFactory)>;
dependencies?: Array<ServiceFactory>;
}
/**
@@ -55,20 +55,15 @@ export class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
* @returns A new tester instance for the provided subject.
*/
static from<TService, TScope extends 'root' | 'plugin'>(
subject:
| ServiceFactory<TService, TScope>
| (() => ServiceFactory<TService, TScope>),
subject: ServiceFactory<TService, TScope>,
options?: ServiceFactoryTesterOptions,
) {
const subjectFactory = typeof subject === 'function' ? subject() : subject;
const registry = ServiceRegistry.create([
...defaultServiceFactories,
...(options?.dependencies?.map(f =>
typeof f === 'function' ? f() : f,
) ?? []),
subjectFactory,
...(options?.dependencies ?? []),
subject,
]);
return new ServiceFactoryTester(subjectFactory.service, registry);
return new ServiceFactoryTester(subject.service, registry);
}
private constructor(
@@ -48,11 +48,7 @@ export interface TestBackendOptions<TExtensionPoints extends any[]> {
];
},
];
features?: Array<
| BackendFeature
| (() => BackendFeature)
| Promise<{ default: BackendFeature | (() => BackendFeature) }>
>;
features?: Array<BackendFeature | Promise<{ default: BackendFeature }>>;
}
/** @public */