frontend-plugin-api: inline RouteResolutionApiResolveOptions

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-08-01 15:02:06 +02:00
parent f2c4abfc03
commit a082429d1d
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';
@@ -196,7 +195,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,
@@ -169,7 +168,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
@@ -1765,18 +1765,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;
}