backend-plugin-api: switch createBackendPlugin id -> pluginId
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ describe('createExtensionPoint', () => {
|
||||
describe('createBackendPlugin', () => {
|
||||
it('should create a BackendPlugin', () => {
|
||||
const plugin = createBackendPlugin((_options: { a: string }) => ({
|
||||
id: 'x',
|
||||
pluginId: 'x',
|
||||
register() {},
|
||||
}));
|
||||
expect(plugin).toBeDefined();
|
||||
@@ -47,7 +47,7 @@ describe('createBackendPlugin', () => {
|
||||
|
||||
it('should create plugins with optional options', () => {
|
||||
const plugin = createBackendPlugin((_options?: { a: string }) => ({
|
||||
id: 'x',
|
||||
pluginId: 'x',
|
||||
register() {},
|
||||
}));
|
||||
expect(plugin).toBeDefined();
|
||||
@@ -59,7 +59,7 @@ describe('createBackendPlugin', () => {
|
||||
|
||||
it('should create plugins without options', () => {
|
||||
const plugin = createBackendPlugin({
|
||||
id: 'x',
|
||||
pluginId: 'x',
|
||||
register() {},
|
||||
});
|
||||
expect(plugin).toBeDefined();
|
||||
@@ -74,7 +74,7 @@ describe('createBackendPlugin', () => {
|
||||
a: string;
|
||||
}
|
||||
const plugin = createBackendPlugin((_options: TestOptions) => ({
|
||||
id: 'x',
|
||||
pluginId: 'x',
|
||||
register() {},
|
||||
}));
|
||||
expect(plugin).toBeDefined();
|
||||
@@ -91,7 +91,7 @@ describe('createBackendPlugin', () => {
|
||||
a: string;
|
||||
}
|
||||
const plugin = createBackendPlugin((_options?: TestOptions) => ({
|
||||
id: 'x',
|
||||
pluginId: 'x',
|
||||
register() {},
|
||||
}));
|
||||
expect(plugin).toBeDefined();
|
||||
|
||||
@@ -72,7 +72,7 @@ export interface BackendPluginConfig {
|
||||
*
|
||||
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
||||
*/
|
||||
id: string;
|
||||
pluginId: string;
|
||||
register(reg: BackendPluginRegistrationPoints): void;
|
||||
}
|
||||
|
||||
@@ -87,10 +87,18 @@ export function createBackendPlugin<TOptions extends [options?: object] = []>(
|
||||
config: BackendPluginConfig | ((...params: TOptions) => BackendPluginConfig),
|
||||
): (...params: TOptions) => BackendFeature {
|
||||
if (typeof config === 'function') {
|
||||
return config;
|
||||
return (...options: TOptions) => {
|
||||
const c = config(...options);
|
||||
return {
|
||||
...c,
|
||||
id: c.pluginId,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
return () => config;
|
||||
return () => ({
|
||||
...config,
|
||||
id: config.pluginId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user