chore: fix tests and update api-reports
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com> Co-authored-by: Fredrik Adelöw <freben@users.noreply.github.com> Co-authored-by: Camila Belo <camilaibs@users.noreply.github.com> Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -68,7 +68,7 @@ function makeNode<TConfig, TConfigInput>(
|
||||
|
||||
function makeInstanceWithId<TConfig, TConfigInput>(
|
||||
extension: Extension<TConfig, TConfigInput>,
|
||||
config?: TConfig,
|
||||
config?: TConfigInput,
|
||||
): AppNode {
|
||||
const node = makeNode(extension, { config });
|
||||
return {
|
||||
@@ -640,12 +640,12 @@ describe('instantiateAppNodeTree', () => {
|
||||
name: 'test',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: [testDataRef, otherDataRef.optional()],
|
||||
configSchema: createSchemaFromZod(z =>
|
||||
z.object({
|
||||
output: z.string().default('test'),
|
||||
other: z.number().optional(),
|
||||
}),
|
||||
),
|
||||
config: {
|
||||
schema: {
|
||||
output: z => z.string().default('test'),
|
||||
other: z => z.number().optional(),
|
||||
},
|
||||
},
|
||||
factory({ config }) {
|
||||
return [
|
||||
testDataRef(config.output),
|
||||
|
||||
@@ -48,6 +48,7 @@ function makeExtDef(
|
||||
name,
|
||||
attachTo: { id: attachId, input: 'default' },
|
||||
disabled: status === 'disabled',
|
||||
override: () => ({} as ExtensionDefinition<unknown>),
|
||||
} as ExtensionDefinition<unknown>;
|
||||
}
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ export function createApiExtension<
|
||||
configSchema?: PortableSchema<TConfig>;
|
||||
inputs?: TInputs;
|
||||
},
|
||||
): ExtensionDefinition<TConfig & {}, TConfig & {}>;
|
||||
): ExtensionDefinition<TConfig, TConfig, never, never>;
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace createApiExtension {
|
||||
@@ -492,7 +492,7 @@ export function createComponentExtension<
|
||||
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
||||
}) => ComponentType<TProps>;
|
||||
};
|
||||
}): ExtensionDefinition<TConfig & {}, TConfig & {}>;
|
||||
}): ExtensionDefinition<TConfig, TConfig, never, never>;
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace createComponentExtension {
|
||||
@@ -524,8 +524,6 @@ export function createExtension<
|
||||
}
|
||||
>;
|
||||
},
|
||||
TConfig,
|
||||
TConfigInput,
|
||||
TConfigSchema extends {
|
||||
[key: string]: (zImpl: typeof z) => z.ZodType;
|
||||
},
|
||||
@@ -534,26 +532,20 @@ export function createExtension<
|
||||
options: CreateExtensionOptions<
|
||||
UOutput,
|
||||
TInputs,
|
||||
TConfig,
|
||||
TConfigInput,
|
||||
TConfigSchema,
|
||||
UFactoryOutput
|
||||
>,
|
||||
): ExtensionDefinition<
|
||||
TConfig &
|
||||
(string extends keyof TConfigSchema
|
||||
? {}
|
||||
: {
|
||||
[key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
|
||||
}),
|
||||
TConfigInput &
|
||||
(string extends keyof TConfigSchema
|
||||
? {}
|
||||
: z.input<
|
||||
z.ZodObject<{
|
||||
[key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;
|
||||
}>
|
||||
>)
|
||||
{
|
||||
[key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
|
||||
},
|
||||
z.input<
|
||||
z.ZodObject<{
|
||||
[key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;
|
||||
}>
|
||||
>,
|
||||
UOutput,
|
||||
TInputs
|
||||
>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
@@ -562,33 +554,14 @@ export function createExtension<
|
||||
TInputs extends AnyExtensionInputMap,
|
||||
TConfig,
|
||||
TConfigInput,
|
||||
TConfigSchema extends {
|
||||
[key: string]: (zImpl: typeof z) => z.ZodType;
|
||||
},
|
||||
>(
|
||||
options: LegacyCreateExtensionOptions<
|
||||
TOutput,
|
||||
TInputs,
|
||||
TConfig,
|
||||
TConfigInput,
|
||||
TConfigSchema
|
||||
TConfigInput
|
||||
>,
|
||||
): ExtensionDefinition<
|
||||
TConfig &
|
||||
(string extends keyof TConfigSchema
|
||||
? {}
|
||||
: {
|
||||
[key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
|
||||
}),
|
||||
TConfigInput &
|
||||
(string extends keyof TConfigSchema
|
||||
? {}
|
||||
: z.input<
|
||||
z.ZodObject<{
|
||||
[key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;
|
||||
}>
|
||||
>)
|
||||
>;
|
||||
): ExtensionDefinition<TConfig, TConfigInput, never, never>;
|
||||
|
||||
// @public
|
||||
export function createExtensionBlueprint<
|
||||
@@ -751,8 +724,6 @@ export type CreateExtensionOptions<
|
||||
}
|
||||
>;
|
||||
},
|
||||
TConfig,
|
||||
TConfigInput,
|
||||
TConfigSchema extends {
|
||||
[key: string]: (zImpl: typeof z) => z.ZodType;
|
||||
},
|
||||
@@ -768,20 +739,14 @@ export type CreateExtensionOptions<
|
||||
disabled?: boolean;
|
||||
inputs?: TInputs;
|
||||
output: Array<UOutput>;
|
||||
configSchema?: PortableSchema<TConfig, TConfigInput>;
|
||||
config?: {
|
||||
schema: TConfigSchema;
|
||||
};
|
||||
factory(context: {
|
||||
node: AppNode;
|
||||
config: TConfig &
|
||||
(string extends keyof TConfigSchema
|
||||
? {}
|
||||
: {
|
||||
[key in keyof TConfigSchema]: z.infer<
|
||||
ReturnType<TConfigSchema[key]>
|
||||
>;
|
||||
});
|
||||
config: {
|
||||
[key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
|
||||
};
|
||||
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
||||
}): Iterable<UFactoryOutput>;
|
||||
} & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;
|
||||
@@ -827,7 +792,9 @@ export function createNavItemExtension(options: {
|
||||
},
|
||||
{
|
||||
title?: string | undefined;
|
||||
}
|
||||
},
|
||||
never,
|
||||
never
|
||||
>;
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -850,7 +817,7 @@ export function createNavLogoExtension(options: {
|
||||
namespace?: string;
|
||||
logoIcon: JSX.Element;
|
||||
logoFull: JSX.Element;
|
||||
}): ExtensionDefinition<{}, {}>;
|
||||
}): ExtensionDefinition<unknown, unknown, never, never>;
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace createNavLogoExtension {
|
||||
@@ -1005,7 +972,7 @@ export function createSubRouteRef<
|
||||
// @public (undocumented)
|
||||
export function createThemeExtension(
|
||||
theme: AppTheme,
|
||||
): ExtensionDefinition<{}, {}>;
|
||||
): ExtensionDefinition<unknown, unknown, never, never>;
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace createThemeExtension {
|
||||
@@ -1021,7 +988,7 @@ export namespace createThemeExtension {
|
||||
export function createTranslationExtension(options: {
|
||||
name?: string;
|
||||
resource: TranslationResource | TranslationMessages;
|
||||
}): ExtensionDefinition<{}, {}>;
|
||||
}): ExtensionDefinition<unknown, unknown, never, never>;
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace createTranslationExtension {
|
||||
@@ -1259,7 +1226,20 @@ export type ExtensionDataValues<TExtensionData extends AnyExtensionDataMap> = {
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ExtensionDefinition<TConfig, TConfigInput = TConfig> {
|
||||
export interface ExtensionDefinition<
|
||||
TConfig,
|
||||
TConfigInput = TConfig,
|
||||
UOutput extends AnyExtensionDataRef = AnyExtensionDataRef,
|
||||
TInputs extends {
|
||||
[inputName in string]: ExtensionInput<
|
||||
AnyExtensionDataRef,
|
||||
{
|
||||
optional: boolean;
|
||||
singleton: boolean;
|
||||
}
|
||||
>;
|
||||
} = {},
|
||||
> {
|
||||
// (undocumented)
|
||||
$$type: '@backstage/ExtensionDefinition';
|
||||
// (undocumented)
|
||||
@@ -1277,6 +1257,76 @@ export interface ExtensionDefinition<TConfig, TConfigInput = TConfig> {
|
||||
readonly name?: string;
|
||||
// (undocumented)
|
||||
readonly namespace?: string;
|
||||
// (undocumented)
|
||||
override<
|
||||
TExtensionConfigSchema extends {
|
||||
[key in string]: (zImpl: typeof z) => z.ZodType;
|
||||
},
|
||||
UFactoryOutput extends ExtensionDataValue<any, any>,
|
||||
UNewOutput extends AnyExtensionDataRef,
|
||||
TExtraInputs extends {
|
||||
[inputName in string]: ExtensionInput<
|
||||
AnyExtensionDataRef,
|
||||
{
|
||||
optional: boolean;
|
||||
singleton: boolean;
|
||||
}
|
||||
>;
|
||||
},
|
||||
>(
|
||||
args: {
|
||||
attachTo?: {
|
||||
id: string;
|
||||
input: string;
|
||||
};
|
||||
disabled?: boolean;
|
||||
inputs?: TExtraInputs & {
|
||||
[KName in keyof TInputs]?: `Error: Input '${KName &
|
||||
string}' is already defined in parent definition`;
|
||||
};
|
||||
output?: Array<UNewOutput>;
|
||||
config?: {
|
||||
schema: TExtensionConfigSchema & {
|
||||
[KName in keyof TConfig]?: `Error: Config key '${KName &
|
||||
string}' is already defined in parent schema`;
|
||||
};
|
||||
};
|
||||
factory(
|
||||
originalFactory: (context?: {
|
||||
config?: TConfig;
|
||||
inputs?: Expand<ResolvedExtensionInputs<TInputs>>;
|
||||
}) => ExtensionDataContainer<UOutput>,
|
||||
context: {
|
||||
node: AppNode;
|
||||
config: TConfig & {
|
||||
[key in keyof TExtensionConfigSchema]: z.infer<
|
||||
ReturnType<TExtensionConfigSchema[key]>
|
||||
>;
|
||||
};
|
||||
inputs: Expand<ResolvedExtensionInputs<TInputs & TExtraInputs>>;
|
||||
},
|
||||
): Iterable<UFactoryOutput>;
|
||||
} & VerifyExtensionFactoryOutput<
|
||||
AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput,
|
||||
UFactoryOutput
|
||||
>,
|
||||
): ExtensionDefinition<
|
||||
{
|
||||
[key in keyof TExtensionConfigSchema]: z.infer<
|
||||
ReturnType<TExtensionConfigSchema[key]>
|
||||
>;
|
||||
} & TConfig,
|
||||
z.input<
|
||||
z.ZodObject<{
|
||||
[key in keyof TExtensionConfigSchema]: ReturnType<
|
||||
TExtensionConfigSchema[key]
|
||||
>;
|
||||
}>
|
||||
> &
|
||||
TConfigInput,
|
||||
AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput,
|
||||
TInputs & TExtraInputs
|
||||
>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -1418,9 +1468,6 @@ export interface LegacyCreateExtensionOptions<
|
||||
TInputs extends AnyExtensionInputMap,
|
||||
TConfig,
|
||||
TConfigInput,
|
||||
TConfigSchema extends {
|
||||
[key: string]: (zImpl: typeof z) => z.ZodType;
|
||||
},
|
||||
> {
|
||||
// (undocumented)
|
||||
attachTo: {
|
||||
@@ -1428,24 +1475,13 @@ export interface LegacyCreateExtensionOptions<
|
||||
input: string;
|
||||
};
|
||||
// (undocumented)
|
||||
config?: {
|
||||
schema: TConfigSchema;
|
||||
};
|
||||
// @deprecated (undocumented)
|
||||
configSchema?: PortableSchema<TConfig, TConfigInput>;
|
||||
// (undocumented)
|
||||
disabled?: boolean;
|
||||
// (undocumented)
|
||||
factory(context: {
|
||||
node: AppNode;
|
||||
config: TConfig &
|
||||
(string extends keyof TConfigSchema
|
||||
? {}
|
||||
: {
|
||||
[key in keyof TConfigSchema]: z.infer<
|
||||
ReturnType<TConfigSchema[key]>
|
||||
>;
|
||||
});
|
||||
config: TConfig;
|
||||
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
||||
}): Expand<ExtensionDataValues<TOutput>>;
|
||||
// (undocumented)
|
||||
|
||||
@@ -75,7 +75,6 @@ describe('createExtensionOverrides', () => {
|
||||
"id": "a",
|
||||
"inputs": {},
|
||||
"output": {},
|
||||
"override": [Function],
|
||||
"toString": [Function],
|
||||
"version": "v1",
|
||||
},
|
||||
@@ -91,7 +90,6 @@ describe('createExtensionOverrides', () => {
|
||||
"id": "b",
|
||||
"inputs": {},
|
||||
"output": {},
|
||||
"override": [Function],
|
||||
"toString": [Function],
|
||||
"version": "v1",
|
||||
},
|
||||
@@ -107,7 +105,6 @@ describe('createExtensionOverrides', () => {
|
||||
"id": "k:c/n",
|
||||
"inputs": {},
|
||||
"output": {},
|
||||
"override": [Function],
|
||||
"toString": [Function],
|
||||
"version": "v1",
|
||||
},
|
||||
|
||||
@@ -23,6 +23,7 @@ describe('resolveExtensionDefinition', () => {
|
||||
version: 'v2',
|
||||
attachTo: { id: '', input: '' },
|
||||
disabled: false,
|
||||
override: () => ({} as ExtensionDefinition<unknown>),
|
||||
};
|
||||
|
||||
it.each([
|
||||
@@ -63,6 +64,7 @@ describe('old resolveExtensionDefinition', () => {
|
||||
version: 'v1',
|
||||
attachTo: { id: '', input: '' },
|
||||
disabled: false,
|
||||
override: () => ({} as ExtensionDefinition<unknown>),
|
||||
};
|
||||
|
||||
it.each([
|
||||
|
||||
@@ -100,7 +100,13 @@ export function resolveExtensionDefinition<TConfig, TConfigInput>(
|
||||
context?: { namespace?: string },
|
||||
): Extension<TConfig, TConfigInput> {
|
||||
const internalDefinition = toInternalExtensionDefinition(definition);
|
||||
const { name, kind, namespace: _, ...rest } = internalDefinition;
|
||||
const {
|
||||
name,
|
||||
kind,
|
||||
namespace: _skip1,
|
||||
override: _skip2,
|
||||
...rest
|
||||
} = internalDefinition;
|
||||
const namespace = internalDefinition.namespace ?? context?.namespace;
|
||||
|
||||
const namePart =
|
||||
|
||||
@@ -169,7 +169,7 @@ export class ExtensionTester {
|
||||
: [...internal.output, coreExtensionData.routePath],
|
||||
factory: params => {
|
||||
const parentOutput = Array.from(
|
||||
internal.factory(params) as Iterable<
|
||||
internal.factory(params as any) as Iterable<
|
||||
ExtensionDataValue<any, any>
|
||||
>,
|
||||
).filter(val => val.id !== coreExtensionData.routePath.id);
|
||||
|
||||
@@ -115,7 +115,7 @@ export function createEntityCardExtension<
|
||||
config: TConfig;
|
||||
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
||||
}) => Promise<JSX.Element>;
|
||||
}): ExtensionDefinition<TConfig & {}, TConfig & {}>;
|
||||
}): ExtensionDefinition<TConfig, TConfig, never, never>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
export function createEntityContentExtension<
|
||||
@@ -148,7 +148,9 @@ export function createEntityContentExtension<
|
||||
filter?: string | undefined;
|
||||
title?: string | undefined;
|
||||
path?: string | undefined;
|
||||
}
|
||||
},
|
||||
never,
|
||||
never
|
||||
>;
|
||||
|
||||
// @alpha
|
||||
|
||||
@@ -108,7 +108,7 @@ export function createCatalogFilterExtension<
|
||||
inputs?: TInputs;
|
||||
configSchema?: PortableSchema<TConfig>;
|
||||
loader: (options: { config: TConfig }) => Promise<JSX.Element>;
|
||||
}): ExtensionDefinition<TConfig & {}, TConfig & {}>;
|
||||
}): ExtensionDefinition<TConfig, TConfig, never, never>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
const _default: BackstagePlugin<
|
||||
|
||||
@@ -25,7 +25,7 @@ export function createSearchResultListItemExtension<
|
||||
},
|
||||
>(
|
||||
options: SearchResultItemExtensionOptions<TConfig>,
|
||||
): ExtensionDefinition<TConfig & {}, TConfig & {}>;
|
||||
): ExtensionDefinition<TConfig, TConfig, never, never>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
export namespace createSearchResultListItemExtension {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { AnyExtensionDataRef } from '@backstage/frontend-plugin-api';
|
||||
import { BackstagePlugin } from '@backstage/frontend-plugin-api';
|
||||
import { ExtensionDefinition } from '@backstage/frontend-plugin-api';
|
||||
import { RouteRef } from '@backstage/frontend-plugin-api';
|
||||
@@ -17,7 +18,7 @@ const _default: BackstagePlugin<
|
||||
export default _default;
|
||||
|
||||
// @alpha (undocumented)
|
||||
export const searchApi: ExtensionDefinition<{}, {}>;
|
||||
export const searchApi: ExtensionDefinition<{}, {}, never, never>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
export const searchNavItem: ExtensionDefinition<
|
||||
@@ -26,7 +27,9 @@ export const searchNavItem: ExtensionDefinition<
|
||||
},
|
||||
{
|
||||
title?: string | undefined;
|
||||
}
|
||||
},
|
||||
never,
|
||||
never
|
||||
>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
@@ -38,7 +41,9 @@ export const searchPage: ExtensionDefinition<
|
||||
{
|
||||
path: string;
|
||||
noTrack: boolean;
|
||||
}
|
||||
},
|
||||
AnyExtensionDataRef,
|
||||
{}
|
||||
>;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
@@ -37,7 +37,9 @@ export const techDocsSearchResultListItemExtension: ExtensionDefinition<
|
||||
asListItem: boolean;
|
||||
asLink: boolean;
|
||||
title?: string | undefined;
|
||||
}
|
||||
},
|
||||
never,
|
||||
never
|
||||
>;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
@@ -24,7 +24,9 @@ export const settingsNavItem: ExtensionDefinition<
|
||||
},
|
||||
{
|
||||
title?: string | undefined;
|
||||
}
|
||||
},
|
||||
never,
|
||||
never
|
||||
>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
|
||||
Reference in New Issue
Block a user