frontend-plugin-api: avoid spreading all extension options
Co-authored-by: Camila Belo <camilaibs@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@ function unused(..._any: any[]) {}
|
||||
describe('createExtension', () => {
|
||||
it('should create an extension with a simple output', () => {
|
||||
const baseConfig = {
|
||||
id: 'test',
|
||||
namespace: 'test',
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
output: {
|
||||
foo: stringData,
|
||||
@@ -39,7 +39,7 @@ describe('createExtension', () => {
|
||||
};
|
||||
},
|
||||
});
|
||||
expect(extension.id).toBe('test');
|
||||
expect(extension.namespace).toBe('test');
|
||||
|
||||
// When declared as an error function without a block the TypeScript errors
|
||||
// are a more specific and will point at the property that is problematic.
|
||||
@@ -163,7 +163,7 @@ describe('createExtension', () => {
|
||||
|
||||
it('should create an extension with a some optional output', () => {
|
||||
const baseConfig = {
|
||||
id: 'test',
|
||||
namespace: 'test',
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
output: {
|
||||
foo: stringData,
|
||||
@@ -176,7 +176,7 @@ describe('createExtension', () => {
|
||||
foo: 'bar',
|
||||
}),
|
||||
});
|
||||
expect(extension.id).toBe('test');
|
||||
expect(extension.namespace).toBe('test');
|
||||
|
||||
createExtension({
|
||||
...baseConfig,
|
||||
@@ -233,7 +233,7 @@ describe('createExtension', () => {
|
||||
|
||||
it('should create an extension with input', () => {
|
||||
const extension = createExtension({
|
||||
id: 'test',
|
||||
namespace: 'test',
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
inputs: {
|
||||
mixed: createExtensionInput({
|
||||
@@ -286,6 +286,6 @@ describe('createExtension', () => {
|
||||
};
|
||||
},
|
||||
});
|
||||
expect(extension.id).toBe('test');
|
||||
expect(extension.namespace).toBe('test');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -137,10 +137,15 @@ export function createExtension<
|
||||
options: CreateExtensionOptions<TOutput, TInputs, TConfig>,
|
||||
): ExtensionDefinition<TConfig> {
|
||||
return {
|
||||
...options,
|
||||
disabled: options.disabled ?? false,
|
||||
$$type: '@backstage/ExtensionDefinition',
|
||||
kind: options.kind,
|
||||
namespace: options.namespace,
|
||||
name: options.name,
|
||||
attachTo: options.attachTo,
|
||||
disabled: options.disabled ?? false,
|
||||
inputs: options.inputs ?? {},
|
||||
output: options.output,
|
||||
configSchema: options.configSchema,
|
||||
factory({ inputs, ...rest }) {
|
||||
// TODO: Simplify this, but TS wouldn't infer the input type for some reason
|
||||
return options.factory({
|
||||
|
||||
Reference in New Issue
Block a user