define BackendFeatureFactory
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
committed by
Philipp Hugenroth
parent
0b4dbb4082
commit
36a40b4903
@@ -17,11 +17,10 @@
|
||||
import {
|
||||
BackendModuleRegistrationPoints,
|
||||
BackendPluginRegistrationPoints,
|
||||
BackendFeature,
|
||||
ExtensionPoint,
|
||||
InternalBackendFeature,
|
||||
InternalBackendModuleRegistration,
|
||||
InternalBackendPluginRegistration,
|
||||
BackendFeatureFactory,
|
||||
} from './types';
|
||||
|
||||
/**
|
||||
@@ -92,9 +91,10 @@ export const catalogPlugin = createBackendPlugin({
|
||||
*/
|
||||
export function createBackendPlugin<TOptions extends [options?: object] = []>(
|
||||
config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig),
|
||||
): (...params: TOptions) => BackendFeature {
|
||||
): BackendFeatureFactory<TOptions> {
|
||||
const configCallback = typeof config === 'function' ? config : () => config;
|
||||
const factory = (...options: TOptions): InternalBackendFeature => {
|
||||
|
||||
const factory: BackendFeatureFactory<TOptions> = (...options) => {
|
||||
const c = configCallback(...options);
|
||||
|
||||
let registrations: InternalBackendPluginRegistration[];
|
||||
@@ -149,8 +149,8 @@ export function createBackendPlugin<TOptions extends [options?: object] = []>(
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
factory.$$type = '@backstage/BackendFeatureFactory';
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -184,9 +184,9 @@ export interface BackendModuleConfig {
|
||||
*/
|
||||
export function createBackendModule<TOptions extends [options?: object] = []>(
|
||||
config: BackendModuleConfig | ((...params: TOptions) => BackendModuleConfig),
|
||||
): (...params: TOptions) => BackendFeature {
|
||||
): BackendFeatureFactory<TOptions> {
|
||||
const configCallback = typeof config === 'function' ? config : () => config;
|
||||
return (...options: TOptions): InternalBackendFeature => {
|
||||
const factory: BackendFeatureFactory<TOptions> = (...options: TOptions) => {
|
||||
const c = configCallback(...options);
|
||||
|
||||
let registrations: InternalBackendModuleRegistration[];
|
||||
@@ -231,4 +231,7 @@ export function createBackendModule<TOptions extends [options?: object] = []>(
|
||||
},
|
||||
};
|
||||
};
|
||||
factory.$$type = '@backstage/BackendFeatureFactory';
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -28,5 +28,6 @@ export type {
|
||||
BackendModuleRegistrationPoints,
|
||||
BackendPluginRegistrationPoints,
|
||||
BackendFeature,
|
||||
BackendFeatureFactory,
|
||||
ExtensionPoint,
|
||||
} from './types';
|
||||
|
||||
@@ -67,6 +67,14 @@ export interface BackendModuleRegistrationPoints {
|
||||
}): void;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface BackendFeatureFactory<
|
||||
TOptions extends [options?: object] = [],
|
||||
> {
|
||||
(...options: TOptions): BackendFeature;
|
||||
$$type: '@backstage/BackendFeatureFactory';
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface BackendFeature {
|
||||
// NOTE: This type is opaque in order to simplify future API evolution.
|
||||
|
||||
Reference in New Issue
Block a user