frontend-plugin-api: store extension ID parts in an object type parameter
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -191,9 +191,11 @@ export type AnyRoutes = {
|
||||
|
||||
// @public
|
||||
export const ApiBlueprint: ExtensionBlueprint<
|
||||
'api',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'api';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
factory: AnyApiFactory;
|
||||
},
|
||||
@@ -263,9 +265,11 @@ export interface AppNodeSpec {
|
||||
|
||||
// @public
|
||||
export const AppRootElementBlueprint: ExtensionBlueprint<
|
||||
'app-root-element',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'app-root-element';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
element: JSX.Element | (() => JSX.Element);
|
||||
},
|
||||
@@ -278,9 +282,11 @@ export const AppRootElementBlueprint: ExtensionBlueprint<
|
||||
|
||||
// @public
|
||||
export const AppRootWrapperBlueprint: ExtensionBlueprint<
|
||||
'app-root-wrapper',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'app-root-wrapper';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
Component: ComponentType<PropsWithChildren<{}>>;
|
||||
},
|
||||
@@ -475,9 +481,11 @@ export function createApiExtension<
|
||||
TConfig,
|
||||
never,
|
||||
never,
|
||||
string | undefined,
|
||||
string | undefined,
|
||||
string | undefined
|
||||
{
|
||||
kind?: string | undefined;
|
||||
namespace?: string | undefined;
|
||||
name?: string | undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -579,9 +587,11 @@ export function createComponentExtension<
|
||||
TConfig,
|
||||
never,
|
||||
never,
|
||||
string | undefined,
|
||||
string | undefined,
|
||||
string | undefined
|
||||
{
|
||||
kind?: string | undefined;
|
||||
namespace?: string | undefined;
|
||||
name?: string | undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -642,9 +652,11 @@ export function createExtension<
|
||||
>,
|
||||
UOutput,
|
||||
TInputs,
|
||||
string | undefined extends TKind ? undefined : TKind,
|
||||
string | undefined extends TNamespace ? undefined : TNamespace,
|
||||
string | undefined extends TName ? undefined : TName
|
||||
{
|
||||
kind: string | undefined extends TKind ? undefined : TKind;
|
||||
namespace: string | undefined extends TNamespace ? undefined : TNamespace;
|
||||
name: string | undefined extends TName ? undefined : TName;
|
||||
}
|
||||
>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
@@ -698,9 +710,11 @@ export function createExtensionBlueprint<
|
||||
TDataRefs
|
||||
>,
|
||||
): ExtensionBlueprint<
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName,
|
||||
{
|
||||
kind: TKind;
|
||||
namespace: TNamespace;
|
||||
name: TName;
|
||||
},
|
||||
TParams,
|
||||
UOutput,
|
||||
string extends keyof TInputs ? {} : TInputs,
|
||||
@@ -928,9 +942,11 @@ export function createNavItemExtension(options: {
|
||||
},
|
||||
never,
|
||||
never,
|
||||
string | undefined,
|
||||
string | undefined,
|
||||
string | undefined
|
||||
{
|
||||
kind?: string | undefined;
|
||||
namespace?: string | undefined;
|
||||
name?: string | undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -958,9 +974,11 @@ export function createNavLogoExtension(options: {
|
||||
unknown,
|
||||
never,
|
||||
never,
|
||||
string | undefined,
|
||||
string | undefined,
|
||||
string | undefined
|
||||
{
|
||||
kind?: string | undefined;
|
||||
namespace?: string | undefined;
|
||||
name?: string | undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -1109,16 +1127,16 @@ export function createSubRouteRef<
|
||||
}): MakeSubRouteRef<PathParams<Path>, ParentParams>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export function createThemeExtension(
|
||||
theme: AppTheme,
|
||||
): ExtensionDefinition<
|
||||
export function createThemeExtension(theme: AppTheme): ExtensionDefinition<
|
||||
unknown,
|
||||
unknown,
|
||||
never,
|
||||
never,
|
||||
string | undefined,
|
||||
string | undefined,
|
||||
string | undefined
|
||||
{
|
||||
kind?: string | undefined;
|
||||
namespace?: string | undefined;
|
||||
name?: string | undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
@@ -1140,9 +1158,11 @@ export function createTranslationExtension(options: {
|
||||
unknown,
|
||||
never,
|
||||
never,
|
||||
string | undefined,
|
||||
string | undefined,
|
||||
string | undefined
|
||||
{
|
||||
kind?: string | undefined;
|
||||
namespace?: string | undefined;
|
||||
name?: string | undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
@@ -1199,9 +1219,11 @@ export interface Extension<TConfig, TConfigInput = TConfig> {
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ExtensionBlueprint<
|
||||
TKind extends string,
|
||||
TNamespace extends string | undefined,
|
||||
TName extends string | undefined,
|
||||
TIdParts extends {
|
||||
kind: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
},
|
||||
TParams,
|
||||
UOutput extends AnyExtensionDataRef,
|
||||
TInputs extends {
|
||||
@@ -1243,9 +1265,13 @@ export interface ExtensionBlueprint<
|
||||
TConfigInput,
|
||||
UOutput,
|
||||
TInputs,
|
||||
TKind,
|
||||
string | undefined extends TNewNamespace ? TNamespace : TNewNamespace,
|
||||
string | undefined extends TNewName ? TName : TNewName
|
||||
{
|
||||
kind: TIdParts['kind'];
|
||||
namespace: string | undefined extends TNewNamespace
|
||||
? TIdParts['namespace']
|
||||
: TNewNamespace;
|
||||
name: string | undefined extends TNewName ? TIdParts['name'] : TNewName;
|
||||
}
|
||||
>;
|
||||
makeWithOverrides<
|
||||
TNewNamespace extends string | undefined,
|
||||
@@ -1321,9 +1347,13 @@ export interface ExtensionBlueprint<
|
||||
TConfigInput,
|
||||
AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput,
|
||||
TInputs & TExtraInputs,
|
||||
TKind,
|
||||
string | undefined extends TNewNamespace ? TNamespace : TNewNamespace,
|
||||
string | undefined extends TNewName ? TName : TNewName
|
||||
{
|
||||
kind: TIdParts['kind'];
|
||||
namespace: string | undefined extends TNewNamespace
|
||||
? TIdParts['namespace']
|
||||
: TNewNamespace;
|
||||
name: string | undefined extends TNewName ? TIdParts['name'] : TNewName;
|
||||
}
|
||||
>;
|
||||
}
|
||||
|
||||
@@ -1419,9 +1449,15 @@ export interface ExtensionDefinition<
|
||||
}
|
||||
>;
|
||||
} = {},
|
||||
TKind extends string | undefined = string | undefined,
|
||||
TNamespace extends string | undefined = string | undefined,
|
||||
TName extends string | undefined = string | undefined,
|
||||
TIdParts extends {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
} = {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
},
|
||||
> {
|
||||
// (undocumented)
|
||||
$$type: '@backstage/ExtensionDefinition';
|
||||
@@ -1435,11 +1471,11 @@ export interface ExtensionDefinition<
|
||||
// (undocumented)
|
||||
readonly disabled: boolean;
|
||||
// (undocumented)
|
||||
readonly kind?: TKind;
|
||||
readonly kind?: TIdParts['kind'];
|
||||
// (undocumented)
|
||||
readonly name?: TName;
|
||||
readonly name?: TIdParts['name'];
|
||||
// (undocumented)
|
||||
readonly namespace?: TNamespace;
|
||||
readonly namespace?: TIdParts['namespace'];
|
||||
// (undocumented)
|
||||
override<
|
||||
TExtensionConfigSchema extends {
|
||||
@@ -1509,9 +1545,7 @@ export interface ExtensionDefinition<
|
||||
TConfigInput,
|
||||
AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput,
|
||||
TInputs & TExtraInputs,
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName
|
||||
TIdParts
|
||||
>;
|
||||
}
|
||||
|
||||
@@ -1591,9 +1625,11 @@ export { googleAuthApiRef };
|
||||
|
||||
// @public (undocumented)
|
||||
export const IconBundleBlueprint: ExtensionBlueprint<
|
||||
'icon-bundle',
|
||||
'app',
|
||||
undefined,
|
||||
{
|
||||
kind: 'icon-bundle';
|
||||
namespace: 'app';
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
icons: {
|
||||
[x: string]: IconComponent;
|
||||
@@ -1705,9 +1741,11 @@ export { microsoftAuthApiRef };
|
||||
|
||||
// @public
|
||||
export const NavItemBlueprint: ExtensionBlueprint<
|
||||
'nav-item',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'nav-item';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
title: string;
|
||||
icon: IconComponent_2;
|
||||
@@ -1740,9 +1778,11 @@ export const NavItemBlueprint: ExtensionBlueprint<
|
||||
|
||||
// @public
|
||||
export const NavLogoBlueprint: ExtensionBlueprint<
|
||||
'nav-logo',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'nav-logo';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
logoIcon: JSX.Element;
|
||||
logoFull: JSX.Element;
|
||||
@@ -1790,9 +1830,11 @@ export { OpenIdConnectApi };
|
||||
|
||||
// @public
|
||||
export const PageBlueprint: ExtensionBlueprint<
|
||||
'page',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'page';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
defaultPath: string;
|
||||
loader: () => Promise<JSX.Element>;
|
||||
@@ -1951,9 +1993,11 @@ export type RouteFunc<TParams extends AnyRouteRefParams> = (
|
||||
|
||||
// @public (undocumented)
|
||||
export const RouterBlueprint: ExtensionBlueprint<
|
||||
'app-router-component',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'app-router-component';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
Component: ComponentType<PropsWithChildren<{}>>;
|
||||
},
|
||||
@@ -2014,9 +2058,11 @@ export { SessionState };
|
||||
|
||||
// @public
|
||||
export const SignInPageBlueprint: ExtensionBlueprint<
|
||||
'sign-in-page',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'sign-in-page';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
loader: () => Promise<ComponentType<SignInPageProps>>;
|
||||
},
|
||||
@@ -2057,9 +2103,11 @@ export interface SubRouteRef<
|
||||
|
||||
// @public
|
||||
export const ThemeBlueprint: ExtensionBlueprint<
|
||||
'theme',
|
||||
'app',
|
||||
undefined,
|
||||
{
|
||||
kind: 'theme';
|
||||
namespace: 'app';
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
theme: AppTheme;
|
||||
},
|
||||
@@ -2074,9 +2122,11 @@ export const ThemeBlueprint: ExtensionBlueprint<
|
||||
|
||||
// @public
|
||||
export const TranslationBlueprint: ExtensionBlueprint<
|
||||
'translation',
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
kind: 'translation';
|
||||
namespace: undefined;
|
||||
name: undefined;
|
||||
},
|
||||
{
|
||||
resource: TranslationResource | TranslationMessages;
|
||||
},
|
||||
|
||||
@@ -218,14 +218,20 @@ export interface ExtensionDefinition<
|
||||
{ optional: boolean; singleton: boolean }
|
||||
>;
|
||||
} = {},
|
||||
TKind extends string | undefined = string | undefined,
|
||||
TNamespace extends string | undefined = string | undefined,
|
||||
TName extends string | undefined = string | undefined,
|
||||
TIdParts extends {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
} = {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
},
|
||||
> {
|
||||
$$type: '@backstage/ExtensionDefinition';
|
||||
readonly kind?: TKind;
|
||||
readonly namespace?: TNamespace;
|
||||
readonly name?: TName;
|
||||
readonly kind?: TIdParts['kind'];
|
||||
readonly namespace?: TIdParts['namespace'];
|
||||
readonly name?: TIdParts['name'];
|
||||
readonly attachTo: { id: string; input: string };
|
||||
readonly disabled: boolean;
|
||||
readonly configSchema?: PortableSchema<TConfig, TConfigInput>;
|
||||
@@ -292,9 +298,7 @@ export interface ExtensionDefinition<
|
||||
TConfigInput,
|
||||
AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput,
|
||||
TInputs & TExtraInputs,
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName
|
||||
TIdParts
|
||||
>;
|
||||
}
|
||||
|
||||
@@ -309,18 +313,16 @@ export type InternalExtensionDefinition<
|
||||
{ optional: boolean; singleton: boolean }
|
||||
>;
|
||||
} = {},
|
||||
TKind extends string | undefined = string | undefined,
|
||||
TNamespace extends string | undefined = string | undefined,
|
||||
TName extends string | undefined = string | undefined,
|
||||
> = ExtensionDefinition<
|
||||
TConfig,
|
||||
TConfigInput,
|
||||
UOutput,
|
||||
TInputs,
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName
|
||||
> &
|
||||
TIdParts extends {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
} = {
|
||||
kind?: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
},
|
||||
> = ExtensionDefinition<TConfig, TConfigInput, UOutput, TInputs, TIdParts> &
|
||||
(
|
||||
| {
|
||||
readonly version: 'v1';
|
||||
@@ -411,9 +413,11 @@ export function createExtension<
|
||||
>,
|
||||
UOutput,
|
||||
TInputs,
|
||||
string | undefined extends TKind ? undefined : TKind,
|
||||
string | undefined extends TNamespace ? undefined : TNamespace,
|
||||
string | undefined extends TName ? undefined : TName
|
||||
{
|
||||
kind: string | undefined extends TKind ? undefined : TKind;
|
||||
namespace: string | undefined extends TNamespace ? undefined : TNamespace;
|
||||
name: string | undefined extends TName ? undefined : TName;
|
||||
}
|
||||
>;
|
||||
/**
|
||||
* @public
|
||||
@@ -482,9 +486,11 @@ export function createExtension<
|
||||
>),
|
||||
UOutput,
|
||||
TInputs,
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName
|
||||
{
|
||||
kind: TKind;
|
||||
namespace: TNamespace;
|
||||
name: TName;
|
||||
}
|
||||
> {
|
||||
if ('configSchema' in options && 'config' in options) {
|
||||
throw new Error(`Cannot provide both configSchema and config.schema`);
|
||||
@@ -596,9 +602,11 @@ export function createExtension<
|
||||
>,
|
||||
AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput,
|
||||
TInputs & TExtraInputs,
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName
|
||||
{
|
||||
kind: TKind;
|
||||
namespace: TNamespace;
|
||||
name: TName;
|
||||
}
|
||||
> => {
|
||||
if (!Array.isArray(options.output)) {
|
||||
throw new Error(
|
||||
@@ -697,8 +705,10 @@ export function createExtension<
|
||||
>),
|
||||
UOutput,
|
||||
TInputs,
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName
|
||||
{
|
||||
kind: TKind;
|
||||
namespace: TNamespace;
|
||||
name: TName;
|
||||
}
|
||||
>;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,11 @@ export type CreateExtensionBlueprintOptions<
|
||||
* @public
|
||||
*/
|
||||
export interface ExtensionBlueprint<
|
||||
TKind extends string,
|
||||
TNamespace extends string | undefined,
|
||||
TName extends string | undefined,
|
||||
TIdParts extends {
|
||||
kind: string;
|
||||
namespace?: string;
|
||||
name?: string;
|
||||
},
|
||||
TParams,
|
||||
UOutput extends AnyExtensionDataRef,
|
||||
TInputs extends {
|
||||
@@ -116,9 +118,13 @@ export interface ExtensionBlueprint<
|
||||
TConfigInput,
|
||||
UOutput,
|
||||
TInputs,
|
||||
TKind,
|
||||
string | undefined extends TNewNamespace ? TNamespace : TNewNamespace,
|
||||
string | undefined extends TNewName ? TName : TNewName
|
||||
{
|
||||
kind: TIdParts['kind'];
|
||||
namespace: string | undefined extends TNewNamespace
|
||||
? TIdParts['namespace']
|
||||
: TNewNamespace;
|
||||
name: string | undefined extends TNewName ? TIdParts['name'] : TNewName;
|
||||
}
|
||||
>;
|
||||
|
||||
/**
|
||||
@@ -195,9 +201,13 @@ export interface ExtensionBlueprint<
|
||||
TConfigInput,
|
||||
AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput,
|
||||
TInputs & TExtraInputs,
|
||||
TKind,
|
||||
string | undefined extends TNewNamespace ? TNamespace : TNewNamespace,
|
||||
string | undefined extends TNewName ? TName : TNewName
|
||||
{
|
||||
kind: TIdParts['kind'];
|
||||
namespace: string | undefined extends TNewNamespace
|
||||
? TIdParts['namespace']
|
||||
: TNewNamespace;
|
||||
name: string | undefined extends TNewName ? TIdParts['name'] : TNewName;
|
||||
}
|
||||
>;
|
||||
}
|
||||
|
||||
@@ -422,9 +432,11 @@ export function createExtensionBlueprint<
|
||||
TDataRefs
|
||||
>,
|
||||
): ExtensionBlueprint<
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName,
|
||||
{
|
||||
kind: TKind;
|
||||
namespace: TNamespace;
|
||||
name: TName;
|
||||
},
|
||||
TParams,
|
||||
UOutput,
|
||||
string extends keyof TInputs ? {} : TInputs,
|
||||
@@ -441,9 +453,11 @@ export function createExtensionBlueprint<
|
||||
TDataRefs
|
||||
> {
|
||||
return new ExtensionBlueprintImpl(options) as ExtensionBlueprint<
|
||||
TKind,
|
||||
TNamespace,
|
||||
TName,
|
||||
{
|
||||
kind: TKind;
|
||||
namespace: TNamespace;
|
||||
name: TName;
|
||||
},
|
||||
TParams,
|
||||
UOutput,
|
||||
string extends keyof TInputs ? {} : TInputs,
|
||||
|
||||
@@ -108,7 +108,13 @@ describe('ResolveExtensionId', () => {
|
||||
TKind extends string | undefined,
|
||||
TNamespace extends string | undefined,
|
||||
TName extends string | undefined,
|
||||
> = ExtensionDefinition<any, any, any, any, TKind, TNamespace, TName>;
|
||||
> = ExtensionDefinition<
|
||||
any,
|
||||
any,
|
||||
any,
|
||||
any,
|
||||
{ kind: TKind; namespace: TNamespace; name: TName }
|
||||
>;
|
||||
|
||||
const id1: 'k:ns' = {} as ResolveExtensionId<
|
||||
NamedExtension<'k', 'ns', undefined>,
|
||||
|
||||
@@ -103,9 +103,11 @@ export type ResolveExtensionId<
|
||||
any,
|
||||
any,
|
||||
any,
|
||||
infer IKind,
|
||||
infer INamespace,
|
||||
infer IName
|
||||
{
|
||||
kind: infer IKind extends string | undefined;
|
||||
namespace: infer INamespace extends string | undefined;
|
||||
name: infer IName extends string | undefined;
|
||||
}
|
||||
>
|
||||
? [string | undefined] extends [IKind | INamespace | IName]
|
||||
? never
|
||||
|
||||
Reference in New Issue
Block a user