frontend-plugin-api: add routes and externalRoutes to plugins
Co-authored-by: Philipp Hugenroth <philipph@spotify.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
import { AnyApiFactory } from '@backstage/core-plugin-api';
|
||||
import { AnyApiRef } from '@backstage/core-plugin-api';
|
||||
import { AnyExternalRoutes } from '@backstage/core-plugin-api';
|
||||
import { AnyRoutes } from '@backstage/core-plugin-api';
|
||||
import { AppTheme } from '@backstage/core-plugin-api';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
@@ -40,13 +42,20 @@ export type AnyExtensionInputMap = {
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface BackstagePlugin {
|
||||
export interface BackstagePlugin<
|
||||
Routes extends AnyRoutes = AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,
|
||||
> {
|
||||
// (undocumented)
|
||||
$$type: '@backstage/BackstagePlugin';
|
||||
// (undocumented)
|
||||
extensions: Extension<unknown>[];
|
||||
// (undocumented)
|
||||
externalRoutes: ExternalRoutes;
|
||||
// (undocumented)
|
||||
id: string;
|
||||
// (undocumented)
|
||||
routes: Routes;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -205,7 +214,12 @@ export function createPageExtension<
|
||||
): Extension<TConfig>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function createPlugin(options: PluginOptions): BackstagePlugin;
|
||||
export function createPlugin<
|
||||
Routes extends AnyRoutes = AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,
|
||||
>(
|
||||
options: PluginOptions<Routes, ExternalRoutes>,
|
||||
): BackstagePlugin<Routes, ExternalRoutes>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function createSchemaFromZod<TOutput, TInput>(
|
||||
@@ -338,11 +352,18 @@ export type NavTarget = {
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface PluginOptions {
|
||||
export interface PluginOptions<
|
||||
Routes extends AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes,
|
||||
> {
|
||||
// (undocumented)
|
||||
extensions?: Extension<unknown>[];
|
||||
// (undocumented)
|
||||
externalRoutes?: ExternalRoutes;
|
||||
// (undocumented)
|
||||
id: string;
|
||||
// (undocumented)
|
||||
routes?: Routes;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
|
||||
@@ -14,26 +14,44 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AnyExternalRoutes, AnyRoutes } from '@backstage/core-plugin-api';
|
||||
import { Extension } from './createExtension';
|
||||
|
||||
/** @public */
|
||||
export interface PluginOptions {
|
||||
export interface PluginOptions<
|
||||
Routes extends AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes,
|
||||
> {
|
||||
id: string;
|
||||
routes?: Routes;
|
||||
externalRoutes?: ExternalRoutes;
|
||||
extensions?: Extension<unknown>[];
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface BackstagePlugin {
|
||||
export interface BackstagePlugin<
|
||||
Routes extends AnyRoutes = AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,
|
||||
> {
|
||||
$$type: '@backstage/BackstagePlugin';
|
||||
id: string;
|
||||
extensions: Extension<unknown>[];
|
||||
routes: Routes;
|
||||
externalRoutes: ExternalRoutes;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export function createPlugin(options: PluginOptions): BackstagePlugin {
|
||||
export function createPlugin<
|
||||
Routes extends AnyRoutes = AnyRoutes,
|
||||
ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,
|
||||
>(
|
||||
options: PluginOptions<Routes, ExternalRoutes>,
|
||||
): BackstagePlugin<Routes, ExternalRoutes> {
|
||||
return {
|
||||
...options,
|
||||
$$type: '@backstage/BackstagePlugin',
|
||||
routes: options.routes ?? ({} as Routes),
|
||||
externalRoutes: options.externalRoutes ?? ({} as ExternalRoutes),
|
||||
extensions: options.extensions ?? [],
|
||||
$$type: '@backstage/BackstagePlugin',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user