discover backend feature factory

Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2023-08-01 16:52:56 +02:00
committed by Philipp Hugenroth
parent 0c450c0e9e
commit 0b4dbb4082
5 changed files with 147 additions and 4 deletions
@@ -78,6 +78,11 @@ export interface BackendPluginConfig {
register(reg: BackendPluginRegistrationPoints): void;
}
export const catalogPlugin = createBackendPlugin({
pluginId: 'catalog',
register() {},
});
/**
* Creates a new backend plugin.
*
@@ -89,7 +94,7 @@ export function createBackendPlugin<TOptions extends [options?: object] = []>(
config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig),
): (...params: TOptions) => BackendFeature {
const configCallback = typeof config === 'function' ? config : () => config;
return (...options: TOptions): InternalBackendFeature => {
const factory = (...options: TOptions): InternalBackendFeature => {
const c = configCallback(...options);
let registrations: InternalBackendPluginRegistration[];
@@ -144,6 +149,9 @@ export function createBackendPlugin<TOptions extends [options?: object] = []>(
},
};
};
factory.$$type = '@backstage/BackendFeatureFactory';
return factory;
}
/**