frontend-plugin-api: removed deprecated variant of createExtensionDataRef

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-03-10 23:49:43 +01:00
parent 8aa63b60be
commit 0d1a397010
4 changed files with 6 additions and 32 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/frontend-plugin-api': minor
---
**BREAKING**: Removed deprecated variant of `createExtensionDataRef` where the ID is passed directly.
@@ -610,11 +610,6 @@ export type CreateExtensionBlueprintOptions<
dataRefs?: TDataRefs;
} & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;
// @public @deprecated (undocumented)
export function createExtensionDataRef<TData>(
id: string,
): ConfigurableExtensionDataRef<TData, string>;
// @public (undocumented)
export function createExtensionDataRef<TData>(): {
with<TId extends string>(options: {
@@ -29,15 +29,6 @@ describe('createExtensionDataRef', () => {
expect(String(refOptional)).toBe('ExtensionDataRef{id=foo,optional=true}');
});
it('can be created and read in the deprecated way', () => {
const ref = createExtensionDataRef('foo');
expect(ref.id).toBe('foo');
expect(String(ref)).toBe('ExtensionDataRef{id=foo,optional=false}');
const refOptional = ref.optional();
expect(refOptional.id).toBe('foo');
expect(String(refOptional)).toBe('ExtensionDataRef{id=foo,optional=true}');
});
it('can be used to encapsulate a value', () => {
const ref = createExtensionDataRef<string>().with({ id: 'foo' });
const val: ExtensionDataValue<string, 'foo'> = ref('hello');
@@ -60,26 +60,12 @@ export interface ConfigurableExtensionDataRef<
(t: TData): ExtensionDataValue<TData, TId>;
}
/**
* @public
* @deprecated Use the following form instead: `createExtensionDataRef<Type>().with({ id: 'core.foo' })`
*/
export function createExtensionDataRef<TData>(
id: string,
): ConfigurableExtensionDataRef<TData, string>;
/** @public */
export function createExtensionDataRef<TData>(): {
with<TId extends string>(options: {
id: TId;
}): ConfigurableExtensionDataRef<TData, TId>;
};
export function createExtensionDataRef<TData>(id?: string):
| ConfigurableExtensionDataRef<TData, string>
| {
with<TId extends string>(options: {
id: TId;
}): ConfigurableExtensionDataRef<TData, TId>;
} {
} {
const createRef = <TId extends string>(refId: TId) =>
Object.assign(
(value: TData): ExtensionDataValue<TData, TId> => ({
@@ -103,9 +89,6 @@ export function createExtensionDataRef<TData>(id?: string):
},
} as ConfigurableExtensionDataRef<TData, TId, { optional?: true }>,
);
if (id) {
return createRef(id);
}
return {
with<TId extends string>(options: { id: TId }) {
return createRef(options.id);