Merge pull request #30724 from backstage/rugvip/inlines

frontend-plugin-api: inline RouteResolutionApiResolveOptions
This commit is contained in:
Patrik Oldsberg
2025-08-04 11:11:39 +02:00
committed by GitHub
6 changed files with 18 additions and 24 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/frontend-plugin-api': minor
---
**BREAKING**: The separate `RouteResolutionApiResolveOptions` type has been removed.
@@ -33,7 +33,6 @@ import {
RouteFunc,
RouteRef,
RouteResolutionApi,
RouteResolutionApiResolveOptions,
SubRouteRef,
componentsApiRef,
coreComponentRefs,
@@ -112,7 +111,7 @@ class CompatRouteResolutionApi implements RouteResolutionApi {
| RouteRef<TParams>
| SubRouteRef<TParams>
| ExternalRouteRef<TParams>,
options?: RouteResolutionApiResolveOptions | undefined,
options?: { sourcePath?: string },
): RouteFunc<TParams> | undefined {
const legacyRef = convertLegacyRouteRef(anyRouteRef as RouteRef<TParams>);
return this.#routeResolver.resolve(legacyRef, options?.sourcePath ?? '/');
@@ -21,7 +21,6 @@ import {
SubRouteRef,
AnyRouteRefParams,
RouteFunc,
RouteResolutionApiResolveOptions,
RouteResolutionApi,
} from '@backstage/frontend-plugin-api';
import mapValues from 'lodash/mapValues';
@@ -198,7 +197,7 @@ export class RouteResolver implements RouteResolutionApi {
| RouteRef<TParams>
| SubRouteRef<TParams>
| ExternalRouteRef<TParams>,
options?: RouteResolutionApiResolveOptions,
options?: { sourcePath?: string },
): RouteFunc<TParams> | undefined {
// First figure out what our target absolute ref is, as well as our target path.
const [targetRef, targetPath] = resolveTargetRef(
@@ -25,7 +25,6 @@ import {
SubRouteRef,
AnyRouteRefParams,
RouteFunc,
RouteResolutionApiResolveOptions,
RouteResolutionApi,
createApiFactory,
routeResolutionApiRef,
@@ -170,7 +169,7 @@ class RouteResolutionApiProxy implements RouteResolutionApi {
| RouteRef<TParams>
| SubRouteRef<TParams>
| ExternalRouteRef<TParams>,
options?: RouteResolutionApiResolveOptions,
options?: { sourcePath?: string },
): RouteFunc<TParams> | undefined {
if (!this.#delegate) {
throw new Error(
+3 -6
View File
@@ -1767,18 +1767,15 @@ export interface RouteResolutionApi {
| RouteRef<TParams>
| SubRouteRef<TParams>
| ExternalRouteRef<TParams>,
options?: RouteResolutionApiResolveOptions,
options?: {
sourcePath?: string;
},
): RouteFunc<TParams> | undefined;
}
// @public
export const routeResolutionApiRef: ApiRef<RouteResolutionApi>;
// @public (undocumented)
export type RouteResolutionApiResolveOptions = {
sourcePath?: string;
};
export { SessionApi };
export { SessionState };
@@ -41,17 +41,6 @@ export type RouteFunc<TParams extends AnyRouteRefParams> = (
: readonly [params: TParams]
) => string;
/**
* @public
*/
export type RouteResolutionApiResolveOptions = {
/**
* An absolute path to use as a starting point when resolving the route.
* If no path is provided the route will be resolved from the root of the app.
*/
sourcePath?: string;
};
/**
* @public
*/
@@ -61,7 +50,13 @@ export interface RouteResolutionApi {
| RouteRef<TParams>
| SubRouteRef<TParams>
| ExternalRouteRef<TParams>,
options?: RouteResolutionApiResolveOptions,
options?: {
/**
* An absolute path to use as a starting point when resolving the route.
* If no path is provided the route will be resolved from the root of the app.
*/
sourcePath?: string;
},
): RouteFunc<TParams> | undefined;
}