Merge pull request #29144 from backstage/rugvip/cleanup

frontend-*-api: cleanup of deprecated types and exports
This commit is contained in:
Patrik Oldsberg
2025-03-11 10:02:45 +01:00
committed by GitHub
17 changed files with 28 additions and 116 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/frontend-test-utils': minor
---
**BREAKING**: Removed deprecated `setupRequestMockHandlers` which was replaced by `registerMswTestHooks`.
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/frontend-defaults': minor
'@backstage/frontend-app-api': minor
'@backstage/core-compat-api': minor
---
**BREAKING**: Dropped support for the removed opaque `@backstage/ExtensionOverrides` and `@backstage/BackstagePlugin` types.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/frontend-plugin-api': minor
---
**BREAKING**: Removed the deprecated `ExtensionOverrides` and `FrontendFeature` types.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/frontend-plugin-api': minor
---
**BREAKING**: Removed deprecated variant of `createExtensionDataRef` where the ID is passed directly.
+1 -2
View File
@@ -14,7 +14,6 @@ import { AppTheme } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { ComponentType } from 'react';
import { ExtensionDefinition } from '@backstage/frontend-plugin-api';
import { ExtensionOverrides } from '@backstage/frontend-plugin-api';
import { ExternalRouteRef } from '@backstage/core-plugin-api';
import { ExternalRouteRef as ExternalRouteRef_2 } from '@backstage/frontend-plugin-api';
import { FeatureFlag } from '@backstage/core-plugin-api';
@@ -34,7 +33,7 @@ export function compatWrapper(element: ReactNode): React_2.JSX.Element;
// @public (undocumented)
export function convertLegacyApp(
rootElement: React_2.JSX.Element,
): (FrontendPlugin | FrontendModule | ExtensionOverrides)[];
): (FrontendPlugin | FrontendModule)[];
// @public (undocumented)
export function convertLegacyAppOptions(options?: {
@@ -26,7 +26,6 @@ import {
FrontendPlugin,
coreExtensionData,
createExtension,
ExtensionOverrides,
createExtensionInput,
createFrontendModule,
} from '@backstage/frontend-plugin-api';
@@ -63,7 +62,7 @@ function selectChildren(
/** @public */
export function convertLegacyApp(
rootElement: React.JSX.Element,
): (FrontendPlugin | FrontendModule | ExtensionOverrides)[] {
): (FrontendPlugin | FrontendModule)[] {
if (getComponentData(rootElement, 'core.type') === 'FlatRoutes') {
return collectLegacyRoutes(rootElement);
}
+1 -9
View File
@@ -41,13 +41,5 @@ export function createSpecializedApp(options?: {
};
// @public (undocumented)
export type FrontendFeature =
| FrontendPlugin
| FrontendModule
| {
$$type: '@backstage/ExtensionOverrides';
}
| {
$$type: '@backstage/BackstagePlugin';
};
export type FrontendFeature = FrontendPlugin | FrontendModule;
```
@@ -18,12 +18,7 @@ import { FrontendModule, FrontendPlugin } from '@backstage/frontend-plugin-api';
import { BackstageRouteObject } from '../routing/types';
/** @public */
export type FrontendFeature =
| FrontendPlugin
| FrontendModule
// TODO(blam): This is just forwards backwards compatibility, remove after v1.31.0
| { $$type: '@backstage/ExtensionOverrides' }
| { $$type: '@backstage/BackstagePlugin' };
export type FrontendFeature = FrontendPlugin | FrontendModule;
/** @internal */
export type RouteInfo = {
+1 -5
View File
@@ -88,11 +88,7 @@ function isBackstageFeature(obj: unknown): obj is FrontendFeature {
if (obj !== null && typeof obj === 'object' && '$$type' in obj) {
return (
obj.$$type === '@backstage/FrontendPlugin' ||
obj.$$type === '@backstage/FrontendModule' ||
// TODO: Remove this once the old plugin type and extension overrides
// are no longer supported
obj.$$type === '@backstage/BackstagePlugin' ||
obj.$$type === '@backstage/ExtensionOverrides'
obj.$$type === '@backstage/FrontendModule'
);
}
return false;
@@ -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: {
@@ -1212,12 +1207,6 @@ export interface ExtensionInput<
}>;
}
// @public (undocumented)
export interface ExtensionOverrides {
// (undocumented)
readonly $$type: '@backstage/ExtensionOverrides';
}
// @public
export interface ExternalRouteRef<
TParams extends AnyRouteRefParams = AnyRouteRefParams,
@@ -1247,9 +1236,6 @@ export { FetchApi };
export { fetchApiRef };
// @public @deprecated (undocumented)
export type FrontendFeature = FrontendPlugin | ExtensionOverrides;
// @public (undocumented)
export interface FrontendModule {
// (undocumented)
@@ -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);
@@ -51,9 +51,7 @@ export {
type AnyRoutes,
type AnyExternalRoutes,
type ExtensionDataContainer,
type ExtensionOverrides,
type FeatureFlagConfig,
type FrontendFeature,
type ExtensionFactoryMiddleware,
} from './types';
export {
@@ -22,7 +22,6 @@ import {
ExtensionDataRef,
ExtensionDataValue,
} from './createExtensionDataRef';
import { FrontendPlugin } from './createFrontendPlugin';
import { ApiHolder, AppNode } from '../apis';
/**
@@ -48,17 +47,6 @@ export type ExtensionMap<
get<TId extends keyof TExtensionMap>(id: TId): TExtensionMap[TId];
};
/** @public */
export interface ExtensionOverrides {
readonly $$type: '@backstage/ExtensionOverrides';
}
/**
* @public
* @deprecated import from {@link @backstage/frontend-app-api#FrontendFeature} instead
*/
export type FrontendFeature = FrontendPlugin | ExtensionOverrides;
/** @public */
export type ExtensionDataContainer<UExtensionData extends AnyExtensionDataRef> =
Iterable<
@@ -120,13 +120,6 @@ export function renderInTestApp(
options?: TestAppOptions,
): RenderResult;
// @public @deprecated (undocumented)
export function setupRequestMockHandlers(worker: {
listen: (t: any) => void;
close: () => void;
resetHandlers: () => void;
}): void;
export { TestApiProvider };
export { TestApiProviderProps };
@@ -1,29 +0,0 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { registerMswTestHooks } from '@backstage/test-utils';
/**
* @public
* @deprecated Use `registerMswTestHooks` from `@backstage/frontend-test-utils` instead.
*/
export function setupRequestMockHandlers(worker: {
listen: (t: any) => void;
close: () => void;
resetHandlers: () => void;
}): void {
registerMswTestHooks(worker);
}
@@ -20,7 +20,6 @@
* Contains utilities that can be used when testing frontend features such as extensions.
*/
export * from './deprecated';
export * from './apis';
export * from './app';