@backstage/frontend-plugin-api 0.15.0-next.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/dist/alpha.d.ts +6 -71
  3. package/dist/alpha.esm.js +4 -0
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/analytics/useAnalytics.esm.js +2 -0
  6. package/dist/analytics/useAnalytics.esm.js.map +1 -1
  7. package/dist/apis/definitions/AlertApi.esm.js +3 -2
  8. package/dist/apis/definitions/AlertApi.esm.js.map +1 -1
  9. package/dist/apis/definitions/AnalyticsApi.esm.js +3 -2
  10. package/dist/apis/definitions/AnalyticsApi.esm.js.map +1 -1
  11. package/dist/apis/definitions/AppLanguageApi.esm.js +3 -2
  12. package/dist/apis/definitions/AppLanguageApi.esm.js.map +1 -1
  13. package/dist/apis/definitions/AppThemeApi.esm.js +3 -2
  14. package/dist/apis/definitions/AppThemeApi.esm.js.map +1 -1
  15. package/dist/apis/definitions/AppTreeApi.esm.js +4 -1
  16. package/dist/apis/definitions/AppTreeApi.esm.js.map +1 -1
  17. package/dist/apis/definitions/ConfigApi.esm.js +3 -2
  18. package/dist/apis/definitions/ConfigApi.esm.js.map +1 -1
  19. package/dist/apis/definitions/DialogApi.esm.js +3 -2
  20. package/dist/apis/definitions/DialogApi.esm.js.map +1 -1
  21. package/dist/apis/definitions/DiscoveryApi.esm.js +3 -2
  22. package/dist/apis/definitions/DiscoveryApi.esm.js.map +1 -1
  23. package/dist/apis/definitions/ErrorApi.esm.js +3 -2
  24. package/dist/apis/definitions/ErrorApi.esm.js.map +1 -1
  25. package/dist/apis/definitions/FeatureFlagsApi.esm.js +3 -2
  26. package/dist/apis/definitions/FeatureFlagsApi.esm.js.map +1 -1
  27. package/dist/apis/definitions/FetchApi.esm.js +3 -2
  28. package/dist/apis/definitions/FetchApi.esm.js.map +1 -1
  29. package/dist/apis/definitions/IconsApi.esm.js +3 -2
  30. package/dist/apis/definitions/IconsApi.esm.js.map +1 -1
  31. package/dist/apis/definitions/IdentityApi.esm.js +3 -2
  32. package/dist/apis/definitions/IdentityApi.esm.js.map +1 -1
  33. package/dist/apis/definitions/OAuthRequestApi.esm.js +3 -2
  34. package/dist/apis/definitions/OAuthRequestApi.esm.js.map +1 -1
  35. package/dist/apis/definitions/PluginHeaderActionsApi.esm.js +3 -2
  36. package/dist/apis/definitions/PluginHeaderActionsApi.esm.js.map +1 -1
  37. package/dist/apis/definitions/PluginWrapperApi.esm.js +7 -3
  38. package/dist/apis/definitions/PluginWrapperApi.esm.js.map +1 -1
  39. package/dist/apis/definitions/RouteResolutionApi.esm.js +3 -2
  40. package/dist/apis/definitions/RouteResolutionApi.esm.js.map +1 -1
  41. package/dist/apis/definitions/StorageApi.esm.js +3 -2
  42. package/dist/apis/definitions/StorageApi.esm.js.map +1 -1
  43. package/dist/apis/definitions/SwappableComponentsApi.esm.js +3 -2
  44. package/dist/apis/definitions/SwappableComponentsApi.esm.js.map +1 -1
  45. package/dist/apis/definitions/ToastApi.esm.js +11 -0
  46. package/dist/apis/definitions/ToastApi.esm.js.map +1 -0
  47. package/dist/apis/definitions/TranslationApi.esm.js +3 -2
  48. package/dist/apis/definitions/TranslationApi.esm.js.map +1 -1
  49. package/dist/apis/definitions/auth.esm.js +33 -22
  50. package/dist/apis/definitions/auth.esm.js.map +1 -1
  51. package/dist/apis/system/ApiRef.esm.js +28 -20
  52. package/dist/apis/system/ApiRef.esm.js.map +1 -1
  53. package/dist/blueprints/AnalyticsImplementationBlueprint.esm.js +1 -1
  54. package/dist/blueprints/ApiBlueprint.esm.js +1 -1
  55. package/dist/blueprints/AppRootElementBlueprint.esm.js +1 -1
  56. package/dist/blueprints/NavItemBlueprint.esm.js +1 -1
  57. package/dist/blueprints/PageBlueprint.esm.js +17 -6
  58. package/dist/blueprints/PageBlueprint.esm.js.map +1 -1
  59. package/dist/blueprints/PluginHeaderActionBlueprint.esm.js +3 -1
  60. package/dist/blueprints/PluginHeaderActionBlueprint.esm.js.map +1 -1
  61. package/dist/blueprints/PluginWrapperBlueprint.esm.js +4 -2
  62. package/dist/blueprints/PluginWrapperBlueprint.esm.js.map +1 -1
  63. package/dist/blueprints/SubPageBlueprint.esm.js +3 -1
  64. package/dist/blueprints/SubPageBlueprint.esm.js.map +1 -1
  65. package/dist/components/ExtensionBoundary.esm.js +3 -2
  66. package/dist/components/ExtensionBoundary.esm.js.map +1 -1
  67. package/dist/components/createSwappableComponent.esm.js +2 -0
  68. package/dist/components/createSwappableComponent.esm.js.map +1 -1
  69. package/dist/frontend-internal/src/apis/OpaqueApiRef.esm.js +9 -0
  70. package/dist/frontend-internal/src/apis/OpaqueApiRef.esm.js.map +1 -0
  71. package/dist/frontend-internal/src/wiring/InternalExtensionDefinition.esm.js.map +1 -1
  72. package/dist/frontend-internal/src/wiring/InternalFrontendPlugin.esm.js.map +1 -1
  73. package/dist/index.d.ts +363 -1442
  74. package/dist/index.esm.js +3 -0
  75. package/dist/index.esm.js.map +1 -1
  76. package/dist/routing/useRouteRef.esm.js +2 -0
  77. package/dist/routing/useRouteRef.esm.js.map +1 -1
  78. package/dist/schema/createSchemaFromZod.esm.js +1 -1
  79. package/dist/schema/createSchemaFromZod.esm.js.map +1 -1
  80. package/dist/translation/useTranslationRef.esm.js +2 -0
  81. package/dist/translation/useTranslationRef.esm.js.map +1 -1
  82. package/dist/types/alpha.d-DzeiOzxk.d.ts +1425 -0
  83. package/dist/wiring/createExtension.esm.js +6 -0
  84. package/dist/wiring/createExtension.esm.js.map +1 -1
  85. package/dist/wiring/createExtensionBlueprint.esm.js +2 -0
  86. package/dist/wiring/createExtensionBlueprint.esm.js.map +1 -1
  87. package/dist/wiring/createExtensionDataRef.esm.js.map +1 -1
  88. package/dist/wiring/createFrontendModule.esm.js +1 -0
  89. package/dist/wiring/createFrontendModule.esm.js.map +1 -1
  90. package/dist/wiring/createFrontendPlugin.esm.js +6 -0
  91. package/dist/wiring/createFrontendPlugin.esm.js.map +1 -1
  92. package/dist/wiring/resolveExtensionDefinition.esm.js.map +1 -1
  93. package/dist/wiring/resolveInputOverrides.esm.js.map +1 -1
  94. package/package.json +11 -10
package/dist/index.d.ts CHANGED
@@ -2,9 +2,12 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode, JSX as JSX$1, ComponentType, PropsWithChildren } from 'react';
4
4
  import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
5
- import { Expand, JsonObject, Observable, JsonValue, ExpandRecursive } from '@backstage/types';
6
- import { z } from 'zod';
5
+ import { I as IconElement, R as RouteRef, A as AnyRouteRefParams, S as SubRouteRef, E as ExternalRouteRef, F as FrontendFeature, a as IconComponent, b as AppNode, c as FrontendPlugin, d as ApiRef, e as ApiHolder, T as TypesToApiRefs, f as ApiFactory, g as AnyApiFactory } from './types/alpha.d-DzeiOzxk.js';
6
+ export { n as AnyApiRef, i as AppNodeEdges, j as AppNodeInstance, k as AppNodeSpec, l as AppTree, m as AppTreeApi, J as ConfigurableExtensionDataRef, a1 as CreateExtensionBlueprintOptions, C as CreateExtensionOptions, X as CreateFrontendModuleOptions, L as CreateFrontendPluginOptions, Y as Extension, Z as ExtensionAttachTo, a2 as ExtensionBlueprint, a5 as ExtensionBlueprintDefineParams, a3 as ExtensionBlueprintParameters, a4 as ExtensionBlueprintParams, _ as ExtensionDataContainer, G as ExtensionDataRef, H as ExtensionDataValue, w as ExtensionDefinition, x as ExtensionDefinitionAttachTo, y as ExtensionDefinitionParameters, a0 as ExtensionFactoryMiddleware, B as ExtensionInput, $ as FeatureFlagConfig, W as FrontendModule, Q as FrontendPluginInfo, U as FrontendPluginInfoOptions, O as OverridableExtensionDefinition, M as OverridableFrontendPlugin, N as PluginOptions, P as PluginWrapperApi, o as PluginWrapperBlueprint, q as PluginWrapperDefinition, u as PortableSchema, h as appTreeApiRef, v as createExtension, a6 as createExtensionBlueprint, a7 as createExtensionBlueprintParams, D as createExtensionDataRef, z as createExtensionInput, t as createExternalRouteRef, V as createFrontendModule, K as createFrontendPlugin, r as createRouteRef, s as createSubRouteRef, p as pluginWrapperApiRef } from './types/alpha.d-DzeiOzxk.js';
7
+ import { Observable, JsonValue, Expand, ExpandRecursive } from '@backstage/types';
7
8
  import { Config } from '@backstage/config';
9
+ import '@backstage/filter-predicates';
10
+ import 'zod/v3';
8
11
 
9
12
  /**
10
13
  * Analytics context envelope.
@@ -39,1426 +42,54 @@ declare const AnalyticsContext: (options: {
39
42
  children: ReactNode;
40
43
  }) => react_jsx_runtime.JSX.Element;
41
44
 
42
- /**
43
- * IconComponent is the common icon type used throughout Backstage when
44
- * working with and rendering generic icons, including the app system icons.
45
- *
46
- * @remarks
47
- *
48
- * The type is based on SvgIcon from Material UI, but we do not want the plugin-api
49
- * package to have a dependency on Material UI, nor do we want the props to be as broad
50
- * as the SvgIconProps interface.
51
- *
52
- * If you have the need to forward additional props from SvgIconProps, you can
53
- * open an issue or submit a PR to the main Backstage repo. When doing so please
54
- * also describe your use-case and reasoning of the addition.
55
- *
56
- * @public
57
- * @deprecated Use {@link IconElement} instead, passing `<MyIcon />` rather than `MyIcon`.
58
- */
59
- type IconComponent = ComponentType<{
60
- fontSize?: 'medium' | 'large' | 'small' | 'inherit';
61
- }>;
62
- /**
63
- * The type used for icon elements throughout Backstage.
64
- *
65
- * @remarks
66
- *
67
- * Icons should be exactly 24x24 pixels in size.
68
- *
69
- * @public
70
- */
71
- type IconElement = JSX$1.Element | null;
72
-
73
- /**
74
- * Catch-all type for route params.
75
- *
76
- * @public
77
- */
78
- type AnyRouteRefParams = {
79
- [param in string]: string;
80
- } | undefined;
81
-
82
- /**
83
- * Absolute route reference.
84
- *
85
- * @remarks
86
- *
87
- * See {@link https://backstage.io/docs/plugins/composability#routing-system}.
88
- *
89
- * @public
90
- */
91
- interface RouteRef<TParams extends AnyRouteRefParams = AnyRouteRefParams> {
92
- readonly $$type: '@backstage/RouteRef';
93
- readonly T: TParams;
94
- }
95
- /**
96
- * Create a {@link RouteRef} from a route descriptor.
97
- *
98
- * @param config - Description of the route reference to be created.
99
- * @public
100
- */
101
- declare function createRouteRef<TParams extends {
102
- [param in TParamKeys]: string;
103
- } | undefined = undefined, TParamKeys extends string = string>(config?: {
104
- /** A list of parameter names that the path that this route ref is bound to must contain */
105
- readonly params?: string extends TParamKeys ? (keyof TParams)[] : TParamKeys[];
106
- aliasFor?: string;
107
- }): RouteRef<keyof TParams extends never ? undefined : string extends TParamKeys ? TParams : {
108
- [param in TParamKeys]: string;
109
- }>;
110
-
111
- /** @public */
112
- declare const coreExtensionData: {
113
- title: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.title", {}>;
114
- /** An icon element for the extension. Should be exactly 24x24 pixels. */
115
- icon: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<IconElement, "core.icon", {}>;
116
- reactElement: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<JSX$1.Element, "core.reactElement", {}>;
117
- routePath: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.routing.path", {}>;
118
- routeRef: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {}>;
119
- };
120
-
121
- /** @public */
122
- type ExtensionDataValue<TData, TId extends string> = {
123
- readonly $$type: '@backstage/ExtensionDataValue';
124
- readonly id: TId;
125
- readonly value: TData;
126
- };
127
- /** @public */
128
- type ExtensionDataRef<TData = unknown, TId extends string = string, TConfig extends {
129
- optional?: true;
130
- } = {
131
- optional?: true;
132
- }> = {
133
- readonly $$type: '@backstage/ExtensionDataRef';
134
- readonly id: TId;
135
- readonly T: TData;
136
- readonly config: TConfig;
137
- };
138
- /** @public */
139
- type ExtensionDataRefToValue<TDataRef extends ExtensionDataRef> = TDataRef extends ExtensionDataRef<infer IData, infer IId, any> ? ExtensionDataValue<IData, IId> : never;
140
- /** @public */
141
- interface ConfigurableExtensionDataRef<TData, TId extends string, TConfig extends {
142
- optional?: true;
143
- } = {}> extends ExtensionDataRef<TData, TId, TConfig> {
144
- optional(): ConfigurableExtensionDataRef<TData, TId, TConfig & {
145
- optional: true;
146
- }>;
147
- (t: TData): ExtensionDataValue<TData, TId>;
148
- }
149
- /** @public */
150
- declare function createExtensionDataRef<TData>(): {
151
- with<TId extends string>(options: {
152
- id: TId;
153
- }): ConfigurableExtensionDataRef<TData, TId>;
154
- };
155
-
156
- /** @public */
157
- interface ExtensionInput<UExtensionData extends ExtensionDataRef<unknown, string, {
158
- optional?: true;
159
- }> = ExtensionDataRef, TConfig extends {
160
- singleton: boolean;
161
- optional: boolean;
162
- internal?: boolean;
163
- } = {
164
- singleton: boolean;
165
- optional: boolean;
166
- internal?: boolean;
167
- }> {
168
- readonly $$type: '@backstage/ExtensionInput';
169
- readonly extensionData: Array<UExtensionData>;
170
- readonly config: TConfig;
171
- readonly replaces?: Array<{
172
- id: string;
173
- input: string;
174
- }>;
175
- }
176
- /**
177
- * Creates a new extension input to be passed to the input map of an extension.
178
- *
179
- * @remarks
180
- *
181
- * Extension inputs created with this function can be passed to any `inputs` map
182
- * as part of creating or overriding an extension.
183
- *
184
- * The array of extension data references defines the data this input expects.
185
- * If the required data is not provided by the attached extension, the
186
- * attachment will fail.
187
- *
188
- * The `config` object can be used to restrict the behavior and shape of the
189
- * input. By default an input will accept zero or more extensions from any
190
- * plugin. The following options are available:
191
- *
192
- * - `singleton`: If set to `true`, only one extension can be attached to the
193
- * input at a time. Additional extensions will trigger an app error and be
194
- * ignored.
195
- * - `optional`: If set to `true`, the input is optional and can be omitted,
196
- * this only has an effect if the `singleton` is set to `true`.
197
- * - `internal`: If set to `true`, only extensions from the same plugin will be
198
- * allowed to attach to this input. Other extensions will trigger an app error
199
- * and be ignored.
200
- *
201
- * @param extensionData - The array of extension data references that this input
202
- * expects.
203
- * @param config - The configuration object for the input.
204
- * @returns An extension input declaration.
205
- * @example
206
- * ```ts
207
- * const extension = createExtension({
208
- * attachTo: { id: 'example-parent', input: 'example-input' },
209
- * inputs: {
210
- * content: createExtensionInput([coreExtensionData.reactElement], {
211
- * singleton: true,
212
- * }),
213
- * },
214
- * output: [coreExtensionData.reactElement],
215
- * *factory({ inputs }) {
216
- * const content = inputs.content?.get(coreExtensionData.reactElement);
217
- * yield coreExtensionData.reactElement(<ContentWrapper>{content}</ContentWrapper>);
218
- * },
219
- * });
220
- * ```
221
- * @public
222
- */
223
- declare function createExtensionInput<UExtensionData extends ExtensionDataRef<unknown, string, {
224
- optional?: true;
225
- }>, TConfig extends {
226
- singleton?: boolean;
227
- optional?: boolean;
228
- internal?: boolean;
229
- }>(extensionData: Array<UExtensionData>, config?: TConfig & {
230
- replaces?: Array<{
231
- id: string;
232
- input: string;
233
- }>;
234
- }): ExtensionInput<UExtensionData, {
235
- singleton: TConfig['singleton'] extends true ? true : false;
236
- optional: TConfig['optional'] extends true ? true : false;
237
- internal: TConfig['internal'] extends true ? true : false;
238
- }>;
239
-
240
- /** @ignore */
241
- type ResolvedInputValueOverrides<TInputs extends {
242
- [inputName in string]: ExtensionInput;
243
- } = {
244
- [inputName in string]: ExtensionInput;
245
- }> = Expand<{
246
- [KName in keyof TInputs as TInputs[KName] extends ExtensionInput<any, {
247
- optional: infer IOptional extends boolean;
248
- singleton: boolean;
249
- internal?: boolean;
250
- }> ? IOptional extends true ? never : KName : never]: TInputs[KName] extends ExtensionInput<infer IDataRefs, {
251
- optional: boolean;
252
- singleton: infer ISingleton extends boolean;
253
- internal?: boolean;
254
- }> ? ISingleton extends true ? Iterable<ExtensionDataRefToValue<IDataRefs>> : Array<Iterable<ExtensionDataRefToValue<IDataRefs>>> : never;
255
- } & {
256
- [KName in keyof TInputs as TInputs[KName] extends ExtensionInput<any, {
257
- optional: infer IOptional extends boolean;
258
- singleton: boolean;
259
- internal?: boolean;
260
- }> ? IOptional extends true ? KName : never : never]?: TInputs[KName] extends ExtensionInput<infer IDataRefs, {
261
- optional: boolean;
262
- singleton: infer ISingleton extends boolean;
263
- internal?: boolean;
264
- }> ? ISingleton extends true ? Iterable<ExtensionDataRefToValue<IDataRefs>> : Array<Iterable<ExtensionDataRefToValue<IDataRefs>>> : never;
265
- }>;
266
-
267
- /** @public */
268
- interface CreateFrontendModuleOptions<TPluginId extends string, TExtensions extends readonly ExtensionDefinition[]> {
269
- pluginId: TPluginId;
270
- extensions?: TExtensions;
271
- featureFlags?: FeatureFlagConfig[];
272
- }
273
- /** @public */
274
- interface FrontendModule {
275
- readonly $$type: '@backstage/FrontendModule';
276
- readonly pluginId: string;
277
- }
278
- /**
279
- * Creates a new module that can be installed in a Backstage app.
280
- *
281
- * @remarks
282
- *
283
- * Modules are used to add or override extensions for an existing plugin. If a
284
- * module provides an extension with the same ID as one provided by the plugin,
285
- * the extension provided by the module will always take precedence.
286
- *
287
- * Every module is created for a specific plugin by providing the
288
- * unique ID of the plugin that the module should be installed for. If that
289
- * plugin is not present in the app, the module will be ignored and have no
290
- * effect.
291
- *
292
- * For more information on how modules work, see the
293
- * {@link https://backstage.io/docs/frontend-system/architecture/extension-overrides#creating-a-frontend-module | documentation for modules}
294
- * in the frontend system documentation.
295
- *
296
- * It is recommended to name the module variable of the form `<pluginId>Module<ModuleName>`.
297
- *
298
- * @example
299
- *
300
- * ```tsx
301
- * import { createFrontendModule } from '@backstage/frontend-plugin-api';
302
- *
303
- * export const exampleModuleCustomPage = createFrontendModule({
304
- * pluginId: 'example',
305
- * extensions: [
306
- * // Overrides the default page for the 'example' plugin
307
- * PageBlueprint.make({
308
- * path: '/example',
309
- * loader: () => import('./CustomPage').then(m => <m.CustomPage />),
310
- * }),
311
- * ],
312
- * });
313
- * ```
314
- *
315
- * @public
316
- */
317
- declare function createFrontendModule<TId extends string, TExtensions extends readonly ExtensionDefinition[]>(options: CreateFrontendModuleOptions<TId, TExtensions>): FrontendModule;
318
-
319
- /** @public */
320
- type PortableSchema<TOutput, TInput = TOutput> = {
321
- parse: (input: TInput) => TOutput;
322
- schema: JsonObject;
323
- };
324
-
325
- /** @public */
326
- type ExtensionAttachTo = {
327
- id: string;
328
- input: string;
329
- };
330
- /** @public */
331
- interface Extension<TConfig, TConfigInput = TConfig> {
332
- $$type: '@backstage/Extension';
333
- readonly id: string;
334
- readonly attachTo: ExtensionAttachTo;
335
- readonly disabled: boolean;
336
- readonly configSchema?: PortableSchema<TConfig, TConfigInput>;
337
- }
338
- /** @ignore */
339
- type ResolveExtensionId<TExtension extends ExtensionDefinition, TNamespace extends string> = TExtension extends ExtensionDefinition<{
340
- kind: infer IKind extends string | undefined;
341
- name: infer IName extends string | undefined;
342
- params: any;
343
- }> ? [string] extends [IKind | IName] ? never : (undefined extends IName ? TNamespace : `${TNamespace}/${IName}`) extends infer INamePart extends string ? IKind extends string ? `${IKind}:${INamePart}` : INamePart : never : never;
344
-
345
- type CompareChars<A extends string, B extends string> = [A, B] extends [
346
- `${infer IAHead}${infer IARest}`,
347
- `${infer IBHead}${infer IBRest}`
348
- ] ? IAHead extends IBHead ? IBRest extends '' ? IARest extends '' ? 'eq' : 'gt' : IARest extends '' ? 'lt' : CompareChars<IARest, IBRest> : `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz` extends `${string}${IAHead}${string}${IBHead}${string}` ? 'lt' : 'gt' : 'eq';
349
- type CompareStrings<A extends string | undefined, B extends string | undefined> = A extends B ? 'eq' : A extends undefined ? 'lt' : B extends undefined ? 'gt' : CompareChars<A & string, B & string>;
350
- type CompareExtensions<A extends ExtensionDefinition, B extends ExtensionDefinition> = CompareStrings<A['T']['kind'], B['T']['kind']> extends 'eq' ? CompareStrings<A['T']['name'], B['T']['name']> : CompareStrings<A['T']['kind'], B['T']['kind']>;
351
- type SortExtensionsInner<TPivot extends ExtensionDefinition, TRest extends readonly ExtensionDefinition[], TLow extends readonly ExtensionDefinition[], THigh extends readonly ExtensionDefinition[]> = TRest extends [
352
- infer IHead extends ExtensionDefinition,
353
- ...infer IRest extends readonly ExtensionDefinition[]
354
- ] ? CompareExtensions<IHead, TPivot> extends 'lt' ? SortExtensionsInner<TPivot, IRest, [...TLow, IHead], THigh> : SortExtensionsInner<TPivot, IRest, TLow, [...THigh, IHead]> : [low: TLow, high: THigh];
355
- type SortExtensions<T extends readonly ExtensionDefinition[]> = T extends [
356
- infer IPivot extends ExtensionDefinition,
357
- ...infer IRest extends readonly ExtensionDefinition[]
358
- ] ? SortExtensionsInner<IPivot, IRest, [], []> extends [
359
- low: infer ILow extends readonly ExtensionDefinition[],
360
- high: infer IHigh extends readonly ExtensionDefinition[]
361
- ] ? [...SortExtensions<ILow>, IPivot, ...SortExtensions<IHigh>] : 'invalid SortExtensionsInner' : [];
362
- type UnionToIntersection$1<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
363
- type PopUnion$1<U> = UnionToIntersection$1<U extends any ? () => U : never> extends () => infer R ? [next: R, rest: Exclude<U, R>] : undefined;
364
- type UnionToArray<U, T = U, TResult extends T[] = []> = PopUnion$1<U> extends [
365
- next: infer INext extends T,
366
- rest: infer IRest extends T
367
- ] ? UnionToArray<IRest, T, [INext, ...TResult]> : TResult;
368
- type ExtensionArrayToMap<T extends ExtensionDefinition[], TId extends string, TOut extends {
369
- [KId in string]: ExtensionDefinition;
370
- } = {}> = T extends [
371
- infer IHead extends ExtensionDefinition,
372
- ...infer IRest extends ExtensionDefinition[]
373
- ] ? ExtensionArrayToMap<IRest, TId, TOut & {
374
- [K in ResolveExtensionId<IHead, TId>]: IHead;
375
- }> : TOut extends infer O ? {
376
- [K in keyof O]: O[K];
377
- } : never;
378
- /** @ignore */
379
- type MakeSortedExtensionsMap<UExtensions extends ExtensionDefinition, TId extends string> = ExtensionArrayToMap<SortExtensions<UnionToArray<UExtensions>>, TId>;
380
-
381
- /**
382
- * Descriptor of a route relative to an absolute {@link RouteRef}.
383
- *
384
- * @remarks
385
- *
386
- * See {@link https://backstage.io/docs/plugins/composability#routing-system}.
387
- *
388
- * @public
389
- */
390
- interface SubRouteRef<TParams extends AnyRouteRefParams = AnyRouteRefParams> {
391
- readonly $$type: '@backstage/SubRouteRef';
392
- readonly T: TParams;
393
- readonly path: string;
394
- }
395
- /**
396
- * Used in {@link PathParams} type declaration.
397
- * @ignore
398
- */
399
- type ParamPart<S extends string> = S extends `:${infer Param}` ? Param : never;
400
- /**
401
- * Used in {@link PathParams} type declaration.
402
- * @ignore
403
- */
404
- type ParamNames<S extends string> = S extends `${infer Part}/${infer Rest}` ? ParamPart<Part> | ParamNames<Rest> : ParamPart<S>;
405
- /**
406
- * This utility type helps us infer a Param object type from a string path
407
- * For example, `/foo/:bar/:baz` inferred to `{ bar: string, baz: string }`
408
- * @ignore
409
- */
410
- type PathParams<S extends string> = {
411
- [name in ParamNames<S>]: string;
412
- };
413
- /**
414
- * Merges a param object type with an optional params type into a params object.
415
- * @ignore
416
- */
417
- type MergeParams<P1 extends {
418
- [param in string]: string;
419
- }, P2 extends AnyRouteRefParams> = (P1[keyof P1] extends never ? {} : P1) & (P2 extends undefined ? {} : P2);
420
- /**
421
- * Convert empty params to undefined.
422
- * @ignore
423
- */
424
- type TrimEmptyParams<Params extends {
425
- [param in string]: string;
426
- }> = keyof Params extends never ? undefined : Params;
427
- /**
428
- * Creates a SubRouteRef type given the desired parameters and parent route parameters.
429
- * The parameters types are merged together while ensuring that there is no overlap between the two.
430
- *
431
- * @ignore
432
- */
433
- type MakeSubRouteRef<Params extends {
434
- [param in string]: string;
435
- }, ParentParams extends AnyRouteRefParams> = keyof Params & keyof ParentParams extends never ? SubRouteRef<TrimEmptyParams<MergeParams<Params, ParentParams>>> : never;
436
- /**
437
- * Create a {@link SubRouteRef} from a route descriptor.
438
- *
439
- * @param config - Description of the route reference to be created.
440
- * @public
441
- */
442
- declare function createSubRouteRef<Path extends string, ParentParams extends AnyRouteRefParams = never>(config: {
443
- path: Path;
444
- parent: RouteRef<ParentParams>;
445
- }): MakeSubRouteRef<PathParams<Path>, ParentParams>;
446
-
447
- /**
448
- * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.
449
- *
450
- * @remarks
451
- *
452
- * See {@link https://backstage.io/docs/plugins/composability#routing-system}.
453
- *
454
- * @public
455
- */
456
- interface ExternalRouteRef<TParams extends AnyRouteRefParams = AnyRouteRefParams> {
457
- readonly $$type: '@backstage/ExternalRouteRef';
458
- readonly T: TParams;
459
- }
460
- /**
461
- * Creates a route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.
462
- *
463
- * @remarks
464
- *
465
- * See {@link https://backstage.io/docs/plugins/composability#routing-system}.
466
- *
467
- * @param options - Description of the route reference to be created.
468
- * @public
469
- */
470
- declare function createExternalRouteRef<TParams extends {
471
- [param in TParamKeys]: string;
472
- } | undefined = undefined, TParamKeys extends string = string>(config?: {
473
- /**
474
- * The parameters that will be provided to the external route reference.
475
- */
476
- readonly params?: string extends TParamKeys ? (keyof TParams)[] : TParamKeys[];
477
- /**
478
- * The route (typically in another plugin) that this should map to by default.
479
- *
480
- * The string is expected to be on the standard `<plugin id>.<route id>` form,
481
- * for example `techdocs.docRoot`.
482
- */
483
- defaultTarget?: string;
484
- }): ExternalRouteRef<keyof TParams extends never ? undefined : string extends TParamKeys ? TParams : {
485
- [param in TParamKeys]: string;
486
- }>;
487
-
488
- /**
489
- * React hook for constructing URLs to routes.
490
- *
491
- * @remarks
492
- *
493
- * See {@link https://backstage.io/docs/plugins/composability#routing-system}
494
- *
495
- * @param routeRef - The ref to route that should be converted to URL.
496
- * @returns A function that will in turn return the concrete URL of the `routeRef`, or `undefined` if the route is not available.
497
- * @public
498
- */
499
- declare function useRouteRef<TParams extends AnyRouteRefParams>(routeRef: RouteRef<TParams> | SubRouteRef<TParams> | ExternalRouteRef<TParams>): RouteFunc<TParams> | undefined;
500
-
501
- /**
502
- * React hook for retrieving dynamic params from the current URL.
503
- * @param _routeRef - Ref of the current route.
504
- * @public
505
- */
506
- declare function useRouteRefParams<Params extends AnyRouteRefParams>(_routeRef: RouteRef<Params> | SubRouteRef<Params>): Params;
507
-
508
- /**
509
- * Information about the plugin.
510
- *
511
- * @public
512
- * @remarks
513
- *
514
- * This interface is intended to be extended via [module
515
- * augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)
516
- * in order to add fields that are specific to each project.
517
- *
518
- * For example, one might add a `slackChannel` field that is read from the
519
- * opaque manifest file.
520
- *
521
- * See the options for `createApp` for more information about how to
522
- * customize the parsing of manifest files.
523
- */
524
- interface FrontendPluginInfo {
525
- /**
526
- * The name of the package that implements the plugin.
527
- */
528
- packageName?: string;
529
- /**
530
- * The version of the plugin, typically the version of the package.json file.
531
- */
532
- version?: string;
533
- /**
534
- * As short description of the plugin, typically the description field in
535
- * package.json.
536
- */
537
- description?: string;
538
- /**
539
- * The owner entity references of the plugin.
540
- */
541
- ownerEntityRefs?: string[];
542
- /**
543
- * Links related to the plugin.
544
- */
545
- links?: Array<{
546
- title: string;
547
- url: string;
548
- }>;
549
- }
550
- /**
551
- * Options for providing information for a plugin.
552
- *
553
- * @public
554
- */
555
- type FrontendPluginInfoOptions = {
556
- /**
557
- * A loader function for the package.json file for the plugin.
558
- */
559
- packageJson?: () => Promise<{
560
- name: string;
561
- } & JsonObject>;
562
- /**
563
- * A loader function for an opaque manifest file for the plugin.
564
- */
565
- manifest?: () => Promise<JsonObject>;
566
- };
567
- /**
568
- * A variant of the {@link FrontendPlugin} interface that can also be used to install overrides for the plugin.
569
- *
570
- * @public
571
- */
572
- interface OverridableFrontendPlugin<TRoutes extends {
573
- [name in string]: RouteRef | SubRouteRef;
574
- } = {
575
- [name in string]: RouteRef | SubRouteRef;
576
- }, TExternalRoutes extends {
577
- [name in string]: ExternalRouteRef;
578
- } = {
579
- [name in string]: ExternalRouteRef;
580
- }, TExtensionMap extends {
581
- [id in string]: ExtensionDefinition;
582
- } = {
583
- [id in string]: ExtensionDefinition;
584
- }> extends FrontendPlugin<TRoutes, TExternalRoutes> {
585
- getExtension<TId extends keyof TExtensionMap>(id: TId): OverridableExtensionDefinition<TExtensionMap[TId]['T']>;
586
- withOverrides(options: {
587
- extensions?: Array<ExtensionDefinition>;
588
- /**
589
- * Overrides the display title of the plugin.
590
- */
591
- title?: string;
592
- /**
593
- * Overrides the display icon of the plugin.
594
- */
595
- icon?: IconElement;
596
- /**
597
- * Overrides the original info loaders of the plugin one by one.
598
- */
599
- info?: FrontendPluginInfoOptions;
600
- }): OverridableFrontendPlugin<TRoutes, TExternalRoutes, TExtensionMap>;
601
- }
602
- /** @public */
603
- interface FrontendPlugin<TRoutes extends {
604
- [name in string]: RouteRef | SubRouteRef;
605
- } = {
606
- [name in string]: RouteRef | SubRouteRef;
607
- }, TExternalRoutes extends {
608
- [name in string]: ExternalRouteRef;
609
- } = {
610
- [name in string]: ExternalRouteRef;
611
- }> {
612
- readonly $$type: '@backstage/FrontendPlugin';
613
- /**
614
- * The plugin ID.
615
- */
616
- readonly pluginId: string;
617
- /**
618
- * Deprecated alias for `pluginId`.
619
- *
620
- * @deprecated Use `pluginId` instead.
621
- */
622
- readonly id: string;
623
- /**
624
- * The display title of the plugin, used in page headers and navigation.
625
- * Falls back to the plugin ID if not provided.
626
- */
627
- readonly title?: string;
628
- /**
629
- * The display icon of the plugin, used in page headers and navigation.
630
- */
631
- readonly icon?: IconElement;
632
- readonly routes: TRoutes;
633
- readonly externalRoutes: TExternalRoutes;
634
- /**
635
- * Loads the plugin info.
636
- */
637
- info(): Promise<FrontendPluginInfo>;
638
- }
639
- /** @public */
640
- interface PluginOptions<TId extends string, TRoutes extends {
641
- [name in string]: RouteRef | SubRouteRef;
642
- }, TExternalRoutes extends {
643
- [name in string]: ExternalRouteRef;
644
- }, TExtensions extends readonly ExtensionDefinition[]> {
645
- pluginId: TId;
646
- /**
647
- * The display title of the plugin, used in page headers and navigation.
648
- * Falls back to the plugin ID if not provided.
649
- */
650
- title?: string;
651
- /**
652
- * The display icon of the plugin, used in page headers and navigation.
653
- */
654
- icon?: IconElement;
655
- routes?: TRoutes;
656
- externalRoutes?: TExternalRoutes;
657
- extensions?: TExtensions;
658
- featureFlags?: FeatureFlagConfig[];
659
- info?: FrontendPluginInfoOptions;
660
- }
661
- /**
662
- * Creates a new plugin that can be installed in a Backstage app.
663
- *
664
- * @remarks
665
- *
666
- * Every plugin is created with a unique ID and a set of extensions
667
- * that are installed as part of the plugin.
668
- *
669
- * For more information on how plugins work, see the
670
- * {@link https://backstage.io/docs/frontend-system/building-plugins/index | documentation for plugins}
671
- * in the frontend system documentation.
672
- *
673
- * @example
674
- *
675
- * ```tsx
676
- * import { createFrontendPlugin } from '@backstage/frontend-plugin-api';
677
- *
678
- * export const examplePlugin = createFrontendPlugin({
679
- * pluginId: 'example',
680
- * extensions: [
681
- * PageBlueprint.make({
682
- * path: '/example',
683
- * loader: () => import('./ExamplePage').then(m => <m.ExamplePage />),
684
- * }),
685
- * ],
686
- * });
687
- * ```
688
- *
689
- * @public
690
- */
691
- declare function createFrontendPlugin<TId extends string, TExtensions extends readonly ExtensionDefinition[], TRoutes extends {
692
- [name in string]: RouteRef | SubRouteRef;
693
- } = {}, TExternalRoutes extends {
694
- [name in string]: ExternalRouteRef;
695
- } = {}>(options: PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>): OverridableFrontendPlugin<TRoutes, TExternalRoutes, MakeSortedExtensionsMap<TExtensions[number], TId>>;
696
-
697
- /**
698
- * Feature flag configuration.
699
- *
700
- * @public
701
- */
702
- type FeatureFlagConfig = {
703
- /** Feature flag name */
704
- name: string;
705
- /** Feature flag description */
706
- description?: string;
707
- };
708
- /** @public */
709
- type ExtensionDataContainer<UExtensionData extends ExtensionDataRef> = Iterable<UExtensionData extends ExtensionDataRef<infer IData, infer IId, infer IConfig> ? IConfig['optional'] extends true ? never : ExtensionDataValue<IData, IId> : never> & {
710
- get<TId extends UExtensionData['id']>(ref: ExtensionDataRef<any, TId, any>): UExtensionData extends ExtensionDataRef<infer IData, TId, infer IConfig> ? IConfig['optional'] extends true ? IData | undefined : IData : never;
711
- };
712
- /**
713
- * @public
714
- * @deprecated Moved to {@link @backstage/frontend-app-api#ExtensionFactoryMiddleware}
715
- */
716
- type ExtensionFactoryMiddleware = (originalFactory: (contextOverrides?: {
717
- config?: JsonObject;
718
- }) => ExtensionDataContainer<ExtensionDataRef>, context: {
719
- node: AppNode;
720
- apis: ApiHolder;
721
- config?: JsonObject;
722
- }) => Iterable<ExtensionDataValue<any, any>>;
723
- /** @public */
724
- type FrontendFeature = (Omit<FrontendPlugin, 'pluginId'> & {
725
- pluginId?: string;
726
- }) | FrontendModule;
727
-
728
- /**
729
- * A function used to define a parameter mapping function in order to facilitate
730
- * advanced parameter typing for extension blueprints.
731
- *
732
- * @remarks
733
- *
734
- * This function is primarily intended to enable the use of inferred type
735
- * parameters for blueprint params, but it can also be used to transoform the
736
- * params before they are handed ot the blueprint.
737
- *
738
- * The function must return an object created with
739
- * {@link createExtensionBlueprintParams}.
740
- *
741
- * @public
742
- */
743
- type ExtensionBlueprintDefineParams<TParams extends object = object, TInput = any> = (params: TInput) => ExtensionBlueprintParams<TParams>;
744
- /**
745
- * An opaque type that represents a set of parameters to be passed to a blueprint.
746
- *
747
- * @remarks
748
- *
749
- * Created with {@link createExtensionBlueprintParams}.
750
- *
751
- * @public
752
- */
753
- type ExtensionBlueprintParams<T extends object = object> = {
754
- $$type: '@backstage/BlueprintParams';
755
- T: T;
756
- };
757
- /**
758
- * Wraps a plain blueprint parameter object in an opaque {@link ExtensionBlueprintParams} object.
759
- *
760
- * This is used in the definition of the `defineParams` option of {@link ExtensionBlueprint}.
761
- *
762
- * @public
763
- * @param params - The plain blueprint parameter object to wrap.
764
- * @returns The wrapped blueprint parameter object.
765
- */
766
- declare function createExtensionBlueprintParams<T extends object = object>(params: T): ExtensionBlueprintParams<T>;
767
- /**
768
- * @public
769
- */
770
- type CreateExtensionBlueprintOptions<TKind extends string, TParams extends object | ExtensionBlueprintDefineParams, UOutput extends ExtensionDataRef, TInputs extends {
771
- [inputName in string]: ExtensionInput;
772
- }, TConfigSchema extends {
773
- [key in string]: (zImpl: typeof z) => z.ZodType;
774
- }, UFactoryOutput extends ExtensionDataValue<any, any>, TDataRefs extends {
775
- [name in string]: ExtensionDataRef;
776
- }, UParentInputs extends ExtensionDataRef> = {
777
- kind: TKind;
778
- attachTo: ExtensionDefinitionAttachTo<UParentInputs> & VerifyExtensionAttachTo<UOutput, UParentInputs>;
779
- disabled?: boolean;
780
- inputs?: TInputs;
781
- output: Array<UOutput>;
782
- config?: {
783
- schema: TConfigSchema;
784
- };
785
- /**
786
- * This option is used to further refine the blueprint params. When this
787
- * option is used, the blueprint will require params to be passed in callback
788
- * form. This function can both transform the params before they are handed to
789
- * the blueprint factory, but importantly it also allows you to define
790
- * inferred type parameters for your blueprint params.
791
- *
792
- * @example
793
- * Blueprint definition with inferred type parameters:
794
- * ```ts
795
- * const ExampleBlueprint = createExtensionBlueprint({
796
- * kind: 'example',
797
- * attachTo: { id: 'example', input: 'example' },
798
- * output: [exampleComponentDataRef, exampleFetcherDataRef],
799
- * defineParams<T>(params: {
800
- * component(props: ExampleProps<T>): JSX.Element | null
801
- * fetcher(options: FetchOptions): Promise<FetchResult<T>>
802
- * }) {
803
- * return createExtensionBlueprintParams(params);
804
- * },
805
- * *factory(params) {
806
- * yield exampleComponentDataRef(params.component)
807
- * yield exampleFetcherDataRef(params.fetcher)
808
- * },
809
- * });
810
- * ```
811
- *
812
- * @example
813
- * Usage of the above example blueprint:
814
- * ```ts
815
- * const example = ExampleBlueprint.make({
816
- * params: defineParams => defineParams({
817
- * component: ...,
818
- * fetcher: ...,
819
- * }),
820
- * });
821
- * ```
822
- */
823
- defineParams?: TParams extends ExtensionBlueprintDefineParams ? TParams : 'The defineParams option must be a function if provided, see the docs for details';
824
- factory(params: TParams extends ExtensionBlueprintDefineParams ? ReturnType<TParams>['T'] : TParams, context: {
825
- node: AppNode;
826
- apis: ApiHolder;
827
- config: {
828
- [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
829
- };
830
- inputs: Expand<ResolvedExtensionInputs<TInputs>>;
831
- }): Iterable<UFactoryOutput>;
832
- dataRefs?: TDataRefs;
833
- } & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;
834
- /** @public */
835
- type ExtensionBlueprintParameters = {
836
- kind: string;
837
- params?: object | ExtensionBlueprintDefineParams;
838
- configInput?: {
839
- [K in string]: any;
840
- };
841
- config?: {
842
- [K in string]: any;
843
- };
844
- output?: ExtensionDataRef;
845
- inputs?: {
846
- [KName in string]: ExtensionInput;
847
- };
848
- dataRefs?: {
849
- [name in string]: ExtensionDataRef;
850
- };
851
- };
852
- /** @ignore */
853
- type ParamsFactory<TDefiner extends ExtensionBlueprintDefineParams> = (defineParams: TDefiner) => ReturnType<TDefiner>;
854
- /**
855
- * Represents any form of params input that can be passed to a blueprint.
856
- * This also includes the invalid form of passing a plain params object to a blueprint that uses a definition callback.
857
- *
858
- * @ignore
859
- */
860
- type AnyParamsInput$1<TParams extends object | ExtensionBlueprintDefineParams> = TParams extends ExtensionBlueprintDefineParams<infer IParams> ? IParams | ParamsFactory<TParams> : TParams | ParamsFactory<ExtensionBlueprintDefineParams<TParams, TParams>>;
861
- /**
862
- * @public
863
- */
864
- interface ExtensionBlueprint<T extends ExtensionBlueprintParameters = ExtensionBlueprintParameters> {
865
- dataRefs: T['dataRefs'];
866
- make<TName extends string | undefined, TParamsInput extends AnyParamsInput$1<NonNullable<T['params']>>, UParentInputs extends ExtensionDataRef>(args: {
867
- name?: TName;
868
- attachTo?: ExtensionDefinitionAttachTo<UParentInputs> & VerifyExtensionAttachTo<NonNullable<T['output']>, UParentInputs>;
869
- disabled?: boolean;
870
- params: TParamsInput extends ExtensionBlueprintDefineParams ? TParamsInput : T['params'] extends ExtensionBlueprintDefineParams ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `<blueprint>.make({ params: defineParams => defineParams(<params>) })`' : T['params'];
871
- }): OverridableExtensionDefinition<{
872
- kind: T['kind'];
873
- name: string | undefined extends TName ? undefined : TName;
874
- config: T['config'];
875
- configInput: T['configInput'];
876
- output: T['output'];
877
- inputs: T['inputs'];
878
- params: T['params'];
879
- }>;
880
- /**
881
- * Creates a new extension from the blueprint.
882
- *
883
- * You must either pass `params` directly, or define a `factory` that can
884
- * optionally call the original factory with the same params.
885
- */
886
- makeWithOverrides<TName extends string | undefined, TExtensionConfigSchema extends {
887
- [key in string]: (zImpl: typeof z) => z.ZodType;
888
- }, UFactoryOutput extends ExtensionDataValue<any, any>, UNewOutput extends ExtensionDataRef, UParentInputs extends ExtensionDataRef, TExtraInputs extends {
889
- [inputName in string]: ExtensionInput;
890
- } = {}>(args: {
891
- name?: TName;
892
- attachTo?: ExtensionDefinitionAttachTo<UParentInputs> & VerifyExtensionAttachTo<ExtensionDataRef extends UNewOutput ? NonNullable<T['output']> : UNewOutput, UParentInputs>;
893
- disabled?: boolean;
894
- inputs?: TExtraInputs & {
895
- [KName in keyof T['inputs']]?: `Error: Input '${KName & string}' is already defined in parent definition`;
896
- };
897
- output?: Array<UNewOutput>;
898
- config?: {
899
- schema: TExtensionConfigSchema & {
900
- [KName in keyof T['config']]?: `Error: Config key '${KName & string}' is already defined in parent schema`;
901
- };
902
- };
903
- factory(originalFactory: <TParamsInput extends AnyParamsInput$1<NonNullable<T['params']>>>(params: TParamsInput extends ExtensionBlueprintDefineParams ? TParamsInput : T['params'] extends ExtensionBlueprintDefineParams ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams(<params>))`' : T['params'], context?: {
904
- config?: T['config'];
905
- inputs?: ResolvedInputValueOverrides<NonNullable<T['inputs']>>;
906
- }) => ExtensionDataContainer<NonNullable<T['output']>>, context: {
907
- node: AppNode;
908
- apis: ApiHolder;
909
- config: T['config'] & {
910
- [key in keyof TExtensionConfigSchema]: z.infer<ReturnType<TExtensionConfigSchema[key]>>;
911
- };
912
- inputs: Expand<ResolvedExtensionInputs<T['inputs'] & TExtraInputs>>;
913
- }): Iterable<UFactoryOutput> & VerifyExtensionFactoryOutput<ExtensionDataRef extends UNewOutput ? NonNullable<T['output']> : UNewOutput, UFactoryOutput>;
914
- }): OverridableExtensionDefinition<{
915
- config: Expand<(string extends keyof TExtensionConfigSchema ? {} : {
916
- [key in keyof TExtensionConfigSchema]: z.infer<ReturnType<TExtensionConfigSchema[key]>>;
917
- }) & T['config']>;
918
- configInput: Expand<(string extends keyof TExtensionConfigSchema ? {} : z.input<z.ZodObject<{
919
- [key in keyof TExtensionConfigSchema]: ReturnType<TExtensionConfigSchema[key]>;
920
- }>>) & T['configInput']>;
921
- output: ExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput;
922
- inputs: Expand<T['inputs'] & TExtraInputs>;
923
- kind: T['kind'];
924
- name: string | undefined extends TName ? undefined : TName;
925
- params: T['params'];
926
- }>;
927
- }
928
- /**
929
- * Creates a new extension blueprint that encapsulates the creation of
930
- * extensions of particular kinds.
931
- *
932
- * @remarks
933
- *
934
- * For details on how blueprints work, see the
935
- * {@link https://backstage.io/docs/frontend-system/architecture/extension-blueprints | documentation for extension blueprints}
936
- * in the frontend system documentation.
937
- *
938
- * Extension blueprints make it much easier for users to create new extensions
939
- * for your plugin. Rather than letting them use {@link createExtension}
940
- * directly, you can define a set of parameters and default factory for your
941
- * blueprint, removing a lot of the boilerplate and complexity that is otherwise
942
- * needed to create an extension.
943
- *
944
- * Each blueprint has its own `kind` that helps identify and group the
945
- * extensions that have been created with it. For example the
946
- * {@link PageBlueprint} has the kind `'page'`, and extensions created with it
947
- * will be given the ID `'page:<plugin-id>[/<name>]'`. Blueprints should always
948
- * be exported as `<PascalCaseKind>Blueprint`.
949
- *
950
- * When creating a blueprint the type of the parameters are inferred from the
951
- * `factory` function that you provide. The exception to that is when you need
952
- * your blueprint to include inferred type parameters, in which case you need to
953
- * use the `defineParams` option. See the documentation for the `defineParams`
954
- * option for more details on how that works.
955
- *
956
- * @example
957
- * ```tsx
958
- * // In your plugin library
959
- * export const GreetingBlueprint = createExtensionBlueprint({
960
- * kind: 'greeting',
961
- * attachTo: { id: 'example', input: 'greetings' },
962
- * output: [coreExtensionData.reactElement],
963
- * factory(params: { greeting: string }) {
964
- * return [coreExtensionData.reactElement(<h1>{params.greeting}</h1>)];
965
- * },
966
- * });
967
- *
968
- * // Someone using your blueprint in their plugin
969
- * const exampleGreeting = GreetingBlueprint.make({
970
- * params: {
971
- * greeting: 'Hello, world!',
972
- * },
973
- * });
974
- * ```
975
- * @public
976
- */
977
- declare function createExtensionBlueprint<TParams extends object | ExtensionBlueprintDefineParams, UOutput extends ExtensionDataRef, TInputs extends {
978
- [inputName in string]: ExtensionInput;
979
- }, TConfigSchema extends {
980
- [key in string]: (zImpl: typeof z) => z.ZodType;
981
- }, UFactoryOutput extends ExtensionDataValue<any, any>, TKind extends string, UParentInputs extends ExtensionDataRef, TDataRefs extends {
982
- [name in string]: ExtensionDataRef;
983
- } = never>(options: CreateExtensionBlueprintOptions<TKind, TParams, UOutput, TInputs, TConfigSchema, UFactoryOutput, TDataRefs, UParentInputs>): ExtensionBlueprint<{
984
- kind: TKind;
985
- params: TParams;
986
- output: UOutput extends ExtensionDataRef<infer IData, infer IId, infer IConfig> ? ExtensionDataRef<IData, IId, IConfig> : never;
987
- inputs: string extends keyof TInputs ? {} : TInputs;
988
- config: string extends keyof TConfigSchema ? {} : {
989
- [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
990
- };
991
- configInput: string extends keyof TConfigSchema ? {} : z.input<z.ZodObject<{
992
- [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;
993
- }>>;
994
- dataRefs: TDataRefs;
995
- }>;
996
-
997
- /**
998
- * Convert a single extension input into a matching resolved input.
999
- * @public
1000
- */
1001
- type ResolvedExtensionInput<TExtensionInput extends ExtensionInput> = TExtensionInput['extensionData'] extends Array<ExtensionDataRef> ? {
1002
- node: AppNode;
1003
- } & ExtensionDataContainer<TExtensionInput['extensionData'][number]> : never;
1004
- /**
1005
- * Converts an extension input map into a matching collection of resolved inputs.
1006
- * @public
1007
- */
1008
- type ResolvedExtensionInputs<TInputs extends {
1009
- [name in string]: ExtensionInput;
1010
- }> = {
1011
- [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton'] ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]>>> : false extends TInputs[InputName]['config']['optional'] ? Expand<ResolvedExtensionInput<TInputs[InputName]>> : Expand<ResolvedExtensionInput<TInputs[InputName]> | undefined>;
1012
- };
1013
- type ToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
1014
- type PopUnion<U> = ToIntersection<U extends any ? () => U : never> extends () => infer R ? [rest: Exclude<U, R>, next: R] : undefined;
1015
- /** @ignore */
1016
- type JoinStringUnion<U, TDiv extends string = ', ', TResult extends string = ''> = PopUnion<U> extends [infer IRest extends string, infer INext extends string] ? TResult extends '' ? JoinStringUnion<IRest, TDiv, INext> : JoinStringUnion<IRest, TDiv, `${TResult}${TDiv}${INext}`> : TResult;
1017
- /** @ignore */
1018
- type RequiredExtensionIds<UExtensionData extends ExtensionDataRef> = UExtensionData extends any ? UExtensionData['config']['optional'] extends true ? never : UExtensionData['id'] : never;
1019
- /** @ignore */
1020
- type VerifyExtensionFactoryOutput<UDeclaredOutput extends ExtensionDataRef, UFactoryOutput extends ExtensionDataValue<any, any>> = [RequiredExtensionIds<UDeclaredOutput>] extends [UFactoryOutput['id']] ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']] ? {} : `Error: The extension factory has undeclared output(s): ${JoinStringUnion<Exclude<UFactoryOutput['id'], UDeclaredOutput['id']>>}` : `Error: The extension factory is missing the following output(s): ${JoinStringUnion<Exclude<RequiredExtensionIds<UDeclaredOutput>, UFactoryOutput['id']>>}`;
1021
- /** @ignore */
1022
- type VerifyExtensionAttachTo<UOutput extends ExtensionDataRef, UParentInput extends ExtensionDataRef> = ExtensionDataRef extends UParentInput ? {} : [RequiredExtensionIds<UParentInput>] extends [RequiredExtensionIds<UOutput>] ? {} : `Error: This parent extension input requires the following extension data, but it is not declared as guaranteed output of this extension: ${JoinStringUnion<Exclude<RequiredExtensionIds<UParentInput>, RequiredExtensionIds<UOutput>>>}`;
1023
- /**
1024
- * Specifies where an extension should attach in the extension tree.
1025
- *
1026
- * @remarks
1027
- *
1028
- * A standard attachment point declaration will specify the ID of the parent extension, as well as the name of the input to attach to.
1029
- *
1030
- * There are two more advanced forms that are available for more complex use-cases:
1031
- *
1032
- * 1. Relative attachment points: using the `relative` property instead of `id`, the attachment point is resolved relative to the current plugin.
1033
- * 2. Extension input references: using a reference in code to another extension's input in the same plugin. These references are always relative.
1034
- *
1035
- * @example
1036
- * ```ts
1037
- * // Attach to a specific extension by full ID
1038
- * { id: 'app/routes', input: 'routes' }
1039
- *
1040
- * // Attach to an extension in the same plugin by kind
1041
- * { relative: { kind: 'page' }, input: 'actions' }
1042
- *
1043
- * // Attach to a specific input of another extension
1044
- * const page = ParentBlueprint.make({ ... });
1045
- * const child = ChildBlueprint.make({ attachTo: page.inputs.children });
1046
- * ```
1047
- *
1048
- * @public
1049
- */
1050
- type ExtensionDefinitionAttachTo<UParentInputs extends ExtensionDataRef = ExtensionDataRef> = {
1051
- id: string;
1052
- input: string;
1053
- relative?: never;
1054
- } | {
1055
- relative: {
1056
- kind?: string;
1057
- name?: string;
1058
- };
1059
- input: string;
1060
- id?: never;
1061
- } | ExtensionInput<UParentInputs>;
1062
- /** @public */
1063
- type CreateExtensionOptions<TKind extends string | undefined, TName extends string | undefined, UOutput extends ExtensionDataRef, TInputs extends {
1064
- [inputName in string]: ExtensionInput;
1065
- }, TConfigSchema extends {
1066
- [key: string]: (zImpl: typeof z) => z.ZodType;
1067
- }, UFactoryOutput extends ExtensionDataValue<any, any>, UParentInputs extends ExtensionDataRef> = {
1068
- kind?: TKind;
1069
- name?: TName;
1070
- attachTo: ExtensionDefinitionAttachTo<UParentInputs> & VerifyExtensionAttachTo<UOutput, UParentInputs>;
1071
- disabled?: boolean;
1072
- inputs?: TInputs;
1073
- output: Array<UOutput>;
1074
- config?: {
1075
- schema: TConfigSchema;
1076
- };
1077
- factory(context: {
1078
- node: AppNode;
1079
- apis: ApiHolder;
1080
- config: {
1081
- [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
1082
- };
1083
- inputs: Expand<ResolvedExtensionInputs<TInputs>>;
1084
- }): Iterable<UFactoryOutput>;
1085
- } & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;
1086
- /** @public */
1087
- type ExtensionDefinitionParameters = {
1088
- kind?: string;
1089
- name?: string;
1090
- configInput?: {
1091
- [K in string]: any;
1092
- };
1093
- config?: {
1094
- [K in string]: any;
1095
- };
1096
- output?: ExtensionDataRef;
1097
- inputs?: {
1098
- [KName in string]: ExtensionInput;
1099
- };
1100
- params?: object | ExtensionBlueprintDefineParams;
1101
- };
1102
- /**
1103
- * Same as the one in `createExtensionBlueprint`, but with `ParamsFactory` inlined.
1104
- * It can't be exported because it breaks API reports.
1105
- * @ignore
1106
- */
1107
- type AnyParamsInput<TParams extends object | ExtensionBlueprintDefineParams> = TParams extends ExtensionBlueprintDefineParams<infer IParams> ? IParams | ((define: TParams) => ReturnType<TParams>) : TParams | ((define: ExtensionBlueprintDefineParams<TParams, TParams>) => ReturnType<ExtensionBlueprintDefineParams<TParams, TParams>>);
1108
- /** @public */
1109
- interface ExtensionDefinition<TParams extends ExtensionDefinitionParameters = ExtensionDefinitionParameters> {
1110
- $$type: '@backstage/ExtensionDefinition';
1111
- readonly T: TParams;
1112
- }
1113
- /** @public */
1114
- interface OverridableExtensionDefinition<T extends ExtensionDefinitionParameters = ExtensionDefinitionParameters> extends ExtensionDefinition<T> {
1115
- /**
1116
- * References to the inputs of this extension, which can be used to attach child extensions.
1117
- */
1118
- readonly inputs: {
1119
- [K in keyof T['inputs']]: ExtensionInput<T['inputs'][K] extends ExtensionInput<infer IData> ? IData : never>;
1120
- };
1121
- override<TExtensionConfigSchema extends {
1122
- [key in string]: (zImpl: typeof z) => z.ZodType;
1123
- }, UFactoryOutput extends ExtensionDataValue<any, any>, UNewOutput extends ExtensionDataRef, TExtraInputs extends {
1124
- [inputName in string]: ExtensionInput;
1125
- }, TParamsInput extends AnyParamsInput<NonNullable<T['params']>>, UParentInputs extends ExtensionDataRef>(args: Expand<{
1126
- attachTo?: ExtensionDefinitionAttachTo<UParentInputs> & VerifyExtensionAttachTo<ExtensionDataRef extends UNewOutput ? NonNullable<T['output']> : UNewOutput, UParentInputs>;
1127
- disabled?: boolean;
1128
- inputs?: TExtraInputs & {
1129
- [KName in keyof T['inputs']]?: `Error: Input '${KName & string}' is already defined in parent definition`;
1130
- };
1131
- output?: Array<UNewOutput>;
1132
- config?: {
1133
- schema: TExtensionConfigSchema & {
1134
- [KName in keyof T['config']]?: `Error: Config key '${KName & string}' is already defined in parent schema`;
1135
- };
1136
- };
1137
- factory?(originalFactory: <TFactoryParamsReturn extends AnyParamsInput<NonNullable<T['params']>>>(context?: Expand<{
1138
- config?: T['config'];
1139
- inputs?: ResolvedInputValueOverrides<NonNullable<T['inputs']>>;
1140
- } & ([T['params']] extends [never] ? {} : {
1141
- params?: TFactoryParamsReturn extends ExtensionBlueprintDefineParams ? TFactoryParamsReturn : T['params'] extends ExtensionBlueprintDefineParams ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams(<params>))`' : Partial<T['params']>;
1142
- })>) => ExtensionDataContainer<NonNullable<T['output']>>, context: {
1143
- node: AppNode;
1144
- apis: ApiHolder;
1145
- config: T['config'] & {
1146
- [key in keyof TExtensionConfigSchema]: z.infer<ReturnType<TExtensionConfigSchema[key]>>;
1147
- };
1148
- inputs: Expand<ResolvedExtensionInputs<T['inputs'] & TExtraInputs>>;
1149
- }): Iterable<UFactoryOutput>;
1150
- } & ([T['params']] extends [never] ? {} : {
1151
- params?: TParamsInput extends ExtensionBlueprintDefineParams ? TParamsInput : T['params'] extends ExtensionBlueprintDefineParams ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams(<params>))`' : Partial<T['params']>;
1152
- })> & VerifyExtensionFactoryOutput<ExtensionDataRef extends UNewOutput ? NonNullable<T['output']> : UNewOutput, UFactoryOutput>): OverridableExtensionDefinition<{
1153
- kind: T['kind'];
1154
- name: T['name'];
1155
- output: ExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput;
1156
- inputs: T['inputs'] & TExtraInputs;
1157
- config: T['config'] & {
1158
- [key in keyof TExtensionConfigSchema]: z.infer<ReturnType<TExtensionConfigSchema[key]>>;
1159
- };
1160
- configInput: T['configInput'] & z.input<z.ZodObject<{
1161
- [key in keyof TExtensionConfigSchema]: ReturnType<TExtensionConfigSchema[key]>;
1162
- }>>;
1163
- }>;
1164
- }
1165
- /**
1166
- * Creates a new extension definition for installation in a Backstage app.
1167
- *
1168
- * @remarks
1169
- *
1170
- * This is a low-level function for creation of extensions with arbitrary inputs
1171
- * and outputs and is typically only intended to be used for advanced overrides
1172
- * or framework-level extensions. For most extension creation needs, it is
1173
- * recommended to use existing {@link ExtensionBlueprint}s instead. You can find
1174
- * blueprints both in the `@backstage/frontend-plugin-api` package as well as
1175
- * other plugin libraries. There is also a list of
1176
- * {@link https://backstage.io/docs/frontend-system/building-plugins/common-extension-blueprints | commonly used blueprints}
1177
- * in the frontend system documentation.
1178
- *
1179
- * Extension definitions that are created with this function can be installed in
1180
- * a Backstage app via a {@link FrontendPlugin} or {@link FrontendModule}.
1181
- *
1182
- * For more details on how extensions work, see the
1183
- * {@link https://backstage.io/docs/frontend-system/architecture/extensions | documentation for extensions}.
1184
- *
1185
- * @example
1186
- *
1187
- * ```ts
1188
- * const myExtension = createExtension({
1189
- * name: 'example',
1190
- * attachTo: { id: 'app', input: 'root' },
1191
- * output: [coreExtensionData.reactElement],
1192
- * factory() {
1193
- * return [coreExtensionData.reactElement(<h1>Hello, world!</h1>)];
1194
- * },
1195
- * });
1196
- * ```
1197
- *
1198
- * @public
1199
- */
1200
- declare function createExtension<UOutput extends ExtensionDataRef, TInputs extends {
1201
- [inputName in string]: ExtensionInput;
1202
- }, TConfigSchema extends {
1203
- [key: string]: (zImpl: typeof z) => z.ZodType;
1204
- }, UFactoryOutput extends ExtensionDataValue<any, any>, const TKind extends string | undefined = undefined, const TName extends string | undefined = undefined, UParentInputs extends ExtensionDataRef = ExtensionDataRef>(options: CreateExtensionOptions<TKind, TName, UOutput, TInputs, TConfigSchema, UFactoryOutput, UParentInputs>): OverridableExtensionDefinition<{
1205
- config: string extends keyof TConfigSchema ? {} : {
1206
- [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
1207
- };
1208
- configInput: string extends keyof TConfigSchema ? {} : z.input<z.ZodObject<{
1209
- [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;
1210
- }>>;
1211
- output: UOutput extends ExtensionDataRef<infer IData, infer IId, infer IConfig> ? ExtensionDataRef<IData, IId, IConfig> : never;
1212
- inputs: TInputs;
1213
- params: never;
1214
- kind: string | undefined extends TKind ? undefined : TKind;
1215
- name: string | undefined extends TName ? undefined : TName;
1216
- }>;
1217
-
1218
- /** @public */
1219
- interface CreateFrontendFeatureLoaderOptions {
1220
- loader(deps: {
1221
- config: ConfigApi;
1222
- }): Iterable<FrontendFeature | FrontendFeatureLoader | Promise<{
1223
- default: FrontendFeature | FrontendFeatureLoader;
1224
- }>> | Promise<Iterable<FrontendFeature | FrontendFeatureLoader | Promise<{
1225
- default: FrontendFeature | FrontendFeatureLoader;
1226
- }>>> | AsyncIterable<FrontendFeature | FrontendFeatureLoader | {
1227
- default: FrontendFeature | FrontendFeatureLoader;
1228
- }>;
1229
- }
1230
- /** @public */
1231
- interface FrontendFeatureLoader {
1232
- readonly $$type: '@backstage/FrontendFeatureLoader';
1233
- }
1234
- /** @public */
1235
- declare function createFrontendFeatureLoader(options: CreateFrontendFeatureLoaderOptions): FrontendFeatureLoader;
1236
-
1237
- /**
1238
- * The specification for this {@link AppNode} in the {@link AppTree}.
1239
- *
1240
- * @public
1241
- * @remarks
1242
- *
1243
- * The specifications for a collection of app nodes is all the information needed
1244
- * to build the tree and instantiate the nodes.
1245
- */
1246
- interface AppNodeSpec {
1247
- readonly id: string;
1248
- readonly attachTo: ExtensionAttachTo;
1249
- readonly extension: Extension<unknown, unknown>;
1250
- readonly disabled: boolean;
1251
- readonly config?: unknown;
1252
- readonly plugin: FrontendPlugin;
1253
- }
1254
- /**
1255
- * The connections from this {@link AppNode} to other nodes.
1256
- *
1257
- * @public
1258
- * @remarks
1259
- *
1260
- * The app node edges are resolved based on the app node specs, regardless of whether
1261
- * adjacent nodes are disabled or not. If no parent attachment is present or
1262
- */
1263
- interface AppNodeEdges {
1264
- readonly attachedTo?: {
1265
- node: AppNode;
1266
- input: string;
1267
- };
1268
- readonly attachments: ReadonlyMap<string, AppNode[]>;
1269
- }
1270
- /**
1271
- * The instance of this {@link AppNode} in the {@link AppTree}.
1272
- *
1273
- * @public
1274
- * @remarks
1275
- *
1276
- * The app node instance is created when the `factory` function of an extension is called.
1277
- * Instances will only be present for nodes in the app that are connected to the root
1278
- * node and not disabled
1279
- */
1280
- interface AppNodeInstance {
1281
- /** Returns a sequence of all extension data refs that were output by this instance */
1282
- getDataRefs(): Iterable<ExtensionDataRef<unknown>>;
1283
- /** Get the output data for a single extension data ref */
1284
- getData<T>(ref: ExtensionDataRef<T>): T | undefined;
1285
- }
1286
- /**
1287
- * A node in the {@link AppTree}.
1288
- *
1289
- * @public
1290
- */
1291
- interface AppNode {
1292
- /** The specification for how this node should be instantiated */
1293
- readonly spec: AppNodeSpec;
1294
- /** The edges from this node to other nodes in the app tree */
1295
- readonly edges: AppNodeEdges;
1296
- /** The instance of this node, if it was instantiated */
1297
- readonly instance?: AppNodeInstance;
1298
- }
1299
- /**
1300
- * The app tree containing all {@link AppNode}s of the app.
1301
- *
1302
- * @public
1303
- */
1304
- interface AppTree {
1305
- /** The root node of the app */
1306
- readonly root: AppNode;
1307
- /** A map of all nodes in the app by ID, including orphaned or disabled nodes */
1308
- readonly nodes: ReadonlyMap<string, AppNode>;
1309
- /** A sequence of all nodes with a parent that is not reachable from the app root node */
1310
- readonly orphans: Iterable<AppNode>;
1311
- }
1312
- /**
1313
- * The API for interacting with the {@link AppTree}.
1314
- *
1315
- * @public
1316
- */
1317
- interface AppTreeApi {
1318
- /**
1319
- * Get the {@link AppTree} for the app.
1320
- */
1321
- getTree(): {
1322
- tree: AppTree;
1323
- };
1324
- /**
1325
- * Get all nodes in the app that are mounted at a given route path.
1326
- */
1327
- getNodesByRoutePath(routePath: string): {
1328
- nodes: AppNode[];
1329
- };
1330
- }
1331
- /**
1332
- * The `ApiRef` of {@link AppTreeApi}.
1333
- *
1334
- * @public
1335
- */
1336
- declare const appTreeApiRef: _backstage_frontend_plugin_api.ApiRef<AppTreeApi>;
1337
-
1338
- /**
1339
- * API reference.
1340
- *
1341
- * @public
1342
- */
1343
- type ApiRef<T> = {
1344
- id: string;
1345
- T: T;
1346
- };
1347
- /**
1348
- * Catch-all {@link ApiRef} type.
1349
- *
1350
- * @public
1351
- */
1352
- type AnyApiRef = ApiRef<unknown>;
1353
- /**
1354
- * Wraps a type with API properties into a type holding their respective {@link ApiRef}s.
1355
- *
1356
- * @public
1357
- */
1358
- type TypesToApiRefs<T> = {
1359
- [key in keyof T]: ApiRef<T[key]>;
1360
- };
1361
- /**
1362
- * Provides lookup of APIs through their {@link ApiRef}s.
1363
- *
1364
- * @public
1365
- */
1366
- type ApiHolder = {
1367
- get<T>(api: ApiRef<T>): T | undefined;
1368
- };
1369
- /**
1370
- * Describes type returning API implementations.
1371
- *
1372
- * @public
1373
- */
1374
- type ApiFactory<Api, Impl extends Api, Deps extends {
1375
- [name in string]: unknown;
1376
- }> = {
1377
- api: ApiRef<Api>;
1378
- deps: TypesToApiRefs<Deps>;
1379
- factory(deps: Deps): Impl;
1380
- };
1381
- /**
1382
- * Catch-all {@link ApiFactory} type.
1383
- *
1384
- * @public
1385
- */
1386
- type AnyApiFactory = ApiFactory<unknown, unknown, {
1387
- [key in string]: unknown;
1388
- }>;
1389
-
1390
- /**
1391
- * React hook for retrieving {@link ApiHolder}, an API catalog.
1392
- *
1393
- * @public
1394
- */
1395
- declare function useApiHolder(): ApiHolder;
1396
- /**
1397
- * React hook for retrieving APIs.
1398
- *
1399
- * @param apiRef - Reference of the API to use.
1400
- * @public
1401
- */
1402
- declare function useApi<T>(apiRef: ApiRef<T>): T;
1403
- /**
1404
- * Wrapper for giving component an API context.
1405
- *
1406
- * @param apis - APIs for the context.
1407
- * @deprecated Use `withApis` from `@backstage/core-compat-api` instead.
1408
- * @public
1409
- */
1410
- declare function withApis<T extends {}>(apis: TypesToApiRefs<T>): <TProps extends T>(WrappedComponent: ComponentType<TProps>) => {
1411
- (props: PropsWithChildren<Omit<TProps, keyof T>>): react_jsx_runtime.JSX.Element;
1412
- displayName: string;
45
+ /** @public */
46
+ declare const coreExtensionData: {
47
+ title: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.title", {}>;
48
+ /** An icon element for the extension. Should be exactly 24x24 pixels. */
49
+ icon: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<IconElement, "core.icon", {}>;
50
+ reactElement: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<JSX$1.Element, "core.reactElement", {}>;
51
+ routePath: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.routing.path", {}>;
52
+ routeRef: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {}>;
1413
53
  };
1414
54
 
1415
55
  /**
1416
- * API reference configuration - holds an ID of the referenced API.
1417
- *
1418
- * @public
1419
- */
1420
- type ApiRefConfig = {
1421
- id: string;
1422
- };
1423
- /**
1424
- * Creates a reference to an API. The provided `id` is a stable identifier for
1425
- * the API implementation.
56
+ * React hook for constructing URLs to routes.
1426
57
  *
1427
58
  * @remarks
1428
59
  *
1429
- * The frontend system infers the owning plugin for an API from the `id`. The
1430
- * recommended pattern is `plugin.<plugin-id>.*` (for example,
1431
- * `plugin.catalog.entity-presentation`). This ensures that other plugins can't
1432
- * mistakenly override your API implementation.
60
+ * See {@link https://backstage.io/docs/plugins/composability#routing-system}
1433
61
  *
1434
- * @param config - The descriptor of the API to reference.
1435
- * @returns An API reference.
62
+ * @param routeRef - The ref to route that should be converted to URL.
63
+ * @returns A function that will in turn return the concrete URL of the `routeRef`, or `undefined` if the route is not available.
1436
64
  * @public
1437
65
  */
1438
- declare function createApiRef<T>(config: ApiRefConfig): ApiRef<T>;
66
+ declare function useRouteRef<TParams extends AnyRouteRefParams>(routeRef: RouteRef<TParams> | SubRouteRef<TParams> | ExternalRouteRef<TParams>): RouteFunc<TParams> | undefined;
1439
67
 
1440
68
  /**
1441
- * Used to infer types for a standalone {@link ApiFactory} that isn't immediately passed
1442
- * to another function.
1443
- *
1444
- * @remarks
1445
- *
1446
- * This function doesn't actually do anything, it's only used to infer types.
1447
- *
1448
- * @public
1449
- */
1450
- declare function createApiFactory<Api, Impl extends Api, Deps extends {
1451
- [name in string]: unknown;
1452
- }>(factory: ApiFactory<Api, Impl, Deps>): ApiFactory<Api, Impl, Deps>;
1453
- /**
1454
- * Used to infer types for a standalone {@link ApiFactory} that isn't immediately passed
1455
- * to another function.
1456
- *
1457
- * @param api - Ref of the API that will be produced by the factory.
1458
- * @param instance - Implementation of the API to use.
69
+ * React hook for retrieving dynamic params from the current URL.
70
+ * @param _routeRef - Ref of the current route.
1459
71
  * @public
1460
72
  */
1461
- declare function createApiFactory<Api, Impl extends Api>(api: ApiRef<Api>, instance: Impl): ApiFactory<Api, Impl, {}>;
73
+ declare function useRouteRefParams<Params extends AnyRouteRefParams>(_routeRef: RouteRef<Params> | SubRouteRef<Params>): Params;
74
+
75
+ /** @public */
76
+ interface CreateFrontendFeatureLoaderOptions {
77
+ loader(deps: {
78
+ config: ConfigApi;
79
+ }): Iterable<FrontendFeature | FrontendFeatureLoader | Promise<{
80
+ default: FrontendFeature | FrontendFeatureLoader;
81
+ }>> | Promise<Iterable<FrontendFeature | FrontendFeatureLoader | Promise<{
82
+ default: FrontendFeature | FrontendFeatureLoader;
83
+ }>>> | AsyncIterable<FrontendFeature | FrontendFeatureLoader | {
84
+ default: FrontendFeature | FrontendFeatureLoader;
85
+ }>;
86
+ }
87
+ /** @public */
88
+ interface FrontendFeatureLoader {
89
+ readonly $$type: '@backstage/FrontendFeatureLoader';
90
+ }
91
+ /** @public */
92
+ declare function createFrontendFeatureLoader(options: CreateFrontendFeatureLoaderOptions): FrontendFeatureLoader;
1462
93
 
1463
94
  /**
1464
95
  * This file contains declarations for common interfaces of auth-related APIs.
@@ -1468,7 +99,10 @@ declare function createApiFactory<Api, Impl extends Api>(api: ApiRef<Api>, insta
1468
99
  * For example, a Google OAuth provider that supports OAuth 2 and OpenID Connect,
1469
100
  * would be declared as follows:
1470
101
  *
1471
- * const googleAuthApiRef = createApiRef<OAuthApi & OpenIDConnectApi>({ ... })
102
+ * const googleAuthApiRef = createApiRef<OAuthApi & OpenIDConnectApi>().with({
103
+ * id: 'core.auth.google',
104
+ * pluginId: 'app',
105
+ * })
1472
106
  */
1473
107
  /**
1474
108
  * Information about the auth provider.
@@ -1491,8 +125,13 @@ type AuthProviderInfo = {
1491
125
  title: string;
1492
126
  /**
1493
127
  * Icon for the auth provider.
128
+ *
129
+ * @remarks
130
+ *
131
+ * Accepts either an `IconElement` (e.g. `<MyIcon />`) or an `IconComponent`
132
+ * (e.g. `MyIcon`). Prefer passing `IconElement`.
1494
133
  */
1495
- icon: IconComponent;
134
+ icon: IconComponent | IconElement;
1496
135
  /**
1497
136
  * Optional user friendly messaage to display for the auth provider.
1498
137
  */
@@ -1736,7 +375,9 @@ type SessionApi = {
1736
375
  * Note that the ID token payload is only guaranteed to contain the user's numerical Google ID,
1737
376
  * email and expiration information. Do not rely on any other fields, as they might not be present.
1738
377
  */
1739
- declare const googleAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
378
+ declare const googleAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.google"> & {
379
+ readonly $$type: "@backstage/ApiRef";
380
+ };
1740
381
  /**
1741
382
  * Provides authentication towards GitHub APIs.
1742
383
  *
@@ -1746,7 +387,9 @@ declare const googleAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfo
1746
387
  * See {@link https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/}
1747
388
  * for a full list of supported scopes.
1748
389
  */
1749
- declare const githubAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
390
+ declare const githubAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.github"> & {
391
+ readonly $$type: "@backstage/ApiRef";
392
+ };
1750
393
  /**
1751
394
  * Provides authentication towards Okta APIs.
1752
395
  *
@@ -1756,7 +399,9 @@ declare const githubAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageIden
1756
399
  * See {@link https://developer.okta.com/docs/guides/implement-oauth-for-okta/scopes/}
1757
400
  * for a full list of supported scopes.
1758
401
  */
1759
- declare const oktaAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
402
+ declare const oktaAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.okta"> & {
403
+ readonly $$type: "@backstage/ApiRef";
404
+ };
1760
405
  /**
1761
406
  * Provides authentication towards GitLab APIs.
1762
407
  *
@@ -1766,7 +411,9 @@ declare const oktaAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoAp
1766
411
  * See {@link https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#limiting-scopes-of-a-personal-access-token}
1767
412
  * for a full list of supported scopes.
1768
413
  */
1769
- declare const gitlabAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
414
+ declare const gitlabAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.gitlab"> & {
415
+ readonly $$type: "@backstage/ApiRef";
416
+ };
1770
417
  /**
1771
418
  * Provides authentication towards Microsoft APIs and identities.
1772
419
  *
@@ -1777,13 +424,17 @@ declare const gitlabAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfo
1777
424
  * - {@link https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent}
1778
425
  * - {@link https://docs.microsoft.com/en-us/graph/permissions-reference}
1779
426
  */
1780
- declare const microsoftAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
427
+ declare const microsoftAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.microsoft"> & {
428
+ readonly $$type: "@backstage/ApiRef";
429
+ };
1781
430
  /**
1782
431
  * Provides authentication towards OneLogin APIs.
1783
432
  *
1784
433
  * @public
1785
434
  */
1786
- declare const oneloginAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
435
+ declare const oneloginAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.onelogin"> & {
436
+ readonly $$type: "@backstage/ApiRef";
437
+ };
1787
438
  /**
1788
439
  * Provides authentication towards Bitbucket APIs.
1789
440
  *
@@ -1793,7 +444,9 @@ declare const oneloginAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileIn
1793
444
  * See {@link https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/}
1794
445
  * for a full list of supported scopes.
1795
446
  */
1796
- declare const bitbucketAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
447
+ declare const bitbucketAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.bitbucket"> & {
448
+ readonly $$type: "@backstage/ApiRef";
449
+ };
1797
450
  /**
1798
451
  * Provides authentication towards Bitbucket Server APIs.
1799
452
  *
@@ -1803,7 +456,9 @@ declare const bitbucketAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageI
1803
456
  * See {@link https://confluence.atlassian.com/bitbucketserver/bitbucket-oauth-2-0-provider-api-1108483661.html#BitbucketOAuth2.0providerAPI-scopes}
1804
457
  * for a full list of supported scopes.
1805
458
  */
1806
- declare const bitbucketServerAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
459
+ declare const bitbucketServerAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.bitbucket-server"> & {
460
+ readonly $$type: "@backstage/ApiRef";
461
+ };
1807
462
  /**
1808
463
  * Provides authentication towards Atlassian APIs.
1809
464
  *
@@ -1813,7 +468,9 @@ declare const bitbucketServerAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & Back
1813
468
  * See {@link https://developer.atlassian.com/cloud/jira/platform/scopes-for-connect-and-oauth-2-3LO-apps/}
1814
469
  * for a full list of supported scopes.
1815
470
  */
1816
- declare const atlassianAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
471
+ declare const atlassianAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.atlassian"> & {
472
+ readonly $$type: "@backstage/ApiRef";
473
+ };
1817
474
  /**
1818
475
  * Provides authentication towards VMware Cloud APIs and identities.
1819
476
  *
@@ -1823,7 +480,9 @@ declare const atlassianAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageI
1823
480
  * For more info about VMware Cloud identity and access management:
1824
481
  * - {@link https://docs.vmware.com/en/VMware-Cloud-services/services/Using-VMware-Cloud-Services/GUID-53D39337-D93A-4B84-BD18-DDF43C21479A.html}
1825
482
  */
1826
- declare const vmwareCloudAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
483
+ declare const vmwareCloudAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.vmware-cloud"> & {
484
+ readonly $$type: "@backstage/ApiRef";
485
+ };
1827
486
  /**
1828
487
  * Provides authentication towards OpenShift APIs and identities.
1829
488
  *
@@ -1835,12 +494,22 @@ declare const vmwareCloudAuthApiRef: ApiRef<OAuthApi & OpenIdConnectApi & Profil
1835
494
  * {@link https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html-single/authentication_and_authorization/index#tokens-scoping-about_configuring-internal-oauth}
1836
495
  * for available scopes.
1837
496
  */
1838
- declare const openshiftAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi>;
497
+ declare const openshiftAuthApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi, "core.auth.openshift"> & {
498
+ readonly $$type: "@backstage/ApiRef";
499
+ };
1839
500
 
1840
501
  /**
1841
502
  * Message handled by the {@link AlertApi}.
1842
503
  *
1843
504
  * @public
505
+ * @deprecated Use {@link ToastApiMessage} from {@link ToastApi} instead. AlertApi will be removed in a future release.
506
+ *
507
+ * Migration guide:
508
+ * - `message` becomes `title`
509
+ * - `severity: 'error'` becomes `status: 'danger'`
510
+ * - `severity: 'success' | 'info' | 'warning'` becomes `status: 'success' | 'info' | 'warning'`
511
+ * - `display: 'transient'` becomes `timeout: 5000` (or custom milliseconds)
512
+ * - `display: 'permanent'` means omitting `timeout`
1844
513
  */
1845
514
  type AlertMessage = {
1846
515
  message: string;
@@ -1851,6 +520,23 @@ type AlertMessage = {
1851
520
  * The alert API is used to report alerts to the app, and display them to the user.
1852
521
  *
1853
522
  * @public
523
+ * @deprecated Use {@link ToastApi} instead. AlertApi will be removed in a future release.
524
+ *
525
+ * ToastApi provides richer notification features including:
526
+ * - Title and optional description
527
+ * - Action links
528
+ * - Custom icons
529
+ * - Per-toast timeout control
530
+ * - Programmatic dismiss via returned key
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * // Before (AlertApi)
535
+ * alertApi.post({ message: 'Saved!', severity: 'success', display: 'transient' });
536
+ *
537
+ * // After (ToastApi)
538
+ * toastApi.post({ title: 'Saved!', status: 'success', timeout: 5000 });
539
+ * ```
1854
540
  */
1855
541
  type AlertApi = {
1856
542
  /**
@@ -1866,8 +552,11 @@ type AlertApi = {
1866
552
  * The {@link ApiRef} of {@link AlertApi}.
1867
553
  *
1868
554
  * @public
555
+ * @deprecated Use {@link toastApiRef} instead. AlertApi will be removed in a future release.
1869
556
  */
1870
- declare const alertApiRef: ApiRef<AlertApi>;
557
+ declare const alertApiRef: _backstage_frontend_plugin_api.ApiRef<AlertApi, "core.alert"> & {
558
+ readonly $$type: "@backstage/ApiRef";
559
+ };
1871
560
 
1872
561
  /** @public */
1873
562
  type AppLanguageApi = {
@@ -1885,7 +574,9 @@ type AppLanguageApi = {
1885
574
  /**
1886
575
  * @public
1887
576
  */
1888
- declare const appLanguageApiRef: ApiRef<AppLanguageApi>;
577
+ declare const appLanguageApiRef: _backstage_frontend_plugin_api.ApiRef<AppLanguageApi, "core.applanguage"> & {
578
+ readonly $$type: "@backstage/ApiRef";
579
+ };
1889
580
 
1890
581
  /**
1891
582
  * Describes a theme provided by the app.
@@ -1944,7 +635,9 @@ type AppThemeApi = {
1944
635
  *
1945
636
  * @public
1946
637
  */
1947
- declare const appThemeApiRef: ApiRef<AppThemeApi>;
638
+ declare const appThemeApiRef: _backstage_frontend_plugin_api.ApiRef<AppThemeApi, "core.apptheme"> & {
639
+ readonly $$type: "@backstage/ApiRef";
640
+ };
1948
641
 
1949
642
  /** @public */
1950
643
  interface ExtensionBoundaryProps {
@@ -2089,7 +782,9 @@ interface SwappableComponentsApi {
2089
782
  *
2090
783
  * @public
2091
784
  */
2092
- declare const swappableComponentsApiRef: _backstage_frontend_plugin_api.ApiRef<SwappableComponentsApi>;
785
+ declare const swappableComponentsApiRef: _backstage_frontend_plugin_api.ApiRef<SwappableComponentsApi, "core.swappable-components"> & {
786
+ readonly $$type: "@backstage/ApiRef";
787
+ };
2093
788
 
2094
789
  /**
2095
790
  * The Config API is used to provide a mechanism to access the
@@ -2103,7 +798,9 @@ type ConfigApi = Config;
2103
798
  *
2104
799
  * @public
2105
800
  */
2106
- declare const configApiRef: ApiRef<ConfigApi>;
801
+ declare const configApiRef: _backstage_frontend_plugin_api.ApiRef<Config, "core.config"> & {
802
+ readonly $$type: "@backstage/ApiRef";
803
+ };
2107
804
 
2108
805
  /**
2109
806
  * The discovery API is used to provide a mechanism for plugins to
@@ -2139,7 +836,9 @@ type DiscoveryApi = {
2139
836
  *
2140
837
  * @public
2141
838
  */
2142
- declare const discoveryApiRef: ApiRef<DiscoveryApi>;
839
+ declare const discoveryApiRef: _backstage_frontend_plugin_api.ApiRef<DiscoveryApi, "core.discovery"> & {
840
+ readonly $$type: "@backstage/ApiRef";
841
+ };
2143
842
 
2144
843
  /**
2145
844
  * Mirrors the JavaScript Error class, for the purpose of
@@ -2206,7 +905,9 @@ type ErrorApi = {
2206
905
  *
2207
906
  * @public
2208
907
  */
2209
- declare const errorApiRef: ApiRef<ErrorApi>;
908
+ declare const errorApiRef: _backstage_frontend_plugin_api.ApiRef<ErrorApi, "core.error"> & {
909
+ readonly $$type: "@backstage/ApiRef";
910
+ };
2210
911
 
2211
912
  /**
2212
913
  * Feature flag descriptor.
@@ -2300,7 +1001,9 @@ interface FeatureFlagsApi {
2300
1001
  *
2301
1002
  * @public
2302
1003
  */
2303
- declare const featureFlagsApiRef: ApiRef<FeatureFlagsApi>;
1004
+ declare const featureFlagsApiRef: _backstage_frontend_plugin_api.ApiRef<FeatureFlagsApi, "core.featureflags"> & {
1005
+ readonly $$type: "@backstage/ApiRef";
1006
+ };
2304
1007
 
2305
1008
  /**
2306
1009
  * A wrapper for the fetch API, that has additional behaviors such as the
@@ -2331,7 +1034,9 @@ type FetchApi = {
2331
1034
  *
2332
1035
  * @public
2333
1036
  */
2334
- declare const fetchApiRef: ApiRef<FetchApi>;
1037
+ declare const fetchApiRef: _backstage_frontend_plugin_api.ApiRef<FetchApi, "core.fetch"> & {
1038
+ readonly $$type: "@backstage/ApiRef";
1039
+ };
2335
1040
 
2336
1041
  /**
2337
1042
  * API for accessing app icons.
@@ -2354,7 +1059,9 @@ interface IconsApi {
2354
1059
  *
2355
1060
  * @public
2356
1061
  */
2357
- declare const iconsApiRef: _backstage_frontend_plugin_api.ApiRef<IconsApi>;
1062
+ declare const iconsApiRef: _backstage_frontend_plugin_api.ApiRef<IconsApi, "core.icons"> & {
1063
+ readonly $$type: "@backstage/ApiRef";
1064
+ };
2358
1065
 
2359
1066
  /**
2360
1067
  * The Identity API used to identify and get information about the signed in user.
@@ -2389,7 +1096,9 @@ type IdentityApi = {
2389
1096
  *
2390
1097
  * @public
2391
1098
  */
2392
- declare const identityApiRef: ApiRef<IdentityApi>;
1099
+ declare const identityApiRef: _backstage_frontend_plugin_api.ApiRef<IdentityApi, "core.identity"> & {
1100
+ readonly $$type: "@backstage/ApiRef";
1101
+ };
2393
1102
 
2394
1103
  /**
2395
1104
  * A handle for an open dialog that can be used to interact with it.
@@ -2533,7 +1242,9 @@ interface DialogApi {
2533
1242
  *
2534
1243
  * @public
2535
1244
  */
2536
- declare const dialogApiRef: _backstage_frontend_plugin_api.ApiRef<DialogApi>;
1245
+ declare const dialogApiRef: _backstage_frontend_plugin_api.ApiRef<DialogApi, "core.dialog"> & {
1246
+ readonly $$type: "@backstage/ApiRef";
1247
+ };
2537
1248
 
2538
1249
  /**
2539
1250
  * Describes how to handle auth requests. Both how to show them to the user, and what to do when
@@ -2631,7 +1342,9 @@ type OAuthRequestApi = {
2631
1342
  *
2632
1343
  * @public
2633
1344
  */
2634
- declare const oauthRequestApiRef: ApiRef<OAuthRequestApi>;
1345
+ declare const oauthRequestApiRef: _backstage_frontend_plugin_api.ApiRef<OAuthRequestApi, "core.oauthrequest"> & {
1346
+ readonly $$type: "@backstage/ApiRef";
1347
+ };
2635
1348
 
2636
1349
  /**
2637
1350
  * TS magic for handling route parameters.
@@ -2664,7 +1377,9 @@ interface RouteResolutionApi {
2664
1377
  *
2665
1378
  * @public
2666
1379
  */
2667
- declare const routeResolutionApiRef: _backstage_frontend_plugin_api.ApiRef<RouteResolutionApi>;
1380
+ declare const routeResolutionApiRef: _backstage_frontend_plugin_api.ApiRef<RouteResolutionApi, "core.route-resolution"> & {
1381
+ readonly $$type: "@backstage/ApiRef";
1382
+ };
2668
1383
 
2669
1384
  /**
2670
1385
  * A snapshot in time of the current known value of a storage key.
@@ -2744,7 +1459,9 @@ interface StorageApi {
2744
1459
  *
2745
1460
  * @public
2746
1461
  */
2747
- declare const storageApiRef: ApiRef<StorageApi>;
1462
+ declare const storageApiRef: _backstage_frontend_plugin_api.ApiRef<StorageApi, "core.storage"> & {
1463
+ readonly $$type: "@backstage/ApiRef";
1464
+ };
2748
1465
 
2749
1466
  /**
2750
1467
  * Represents an event worth tracking in an analytics system that could inform
@@ -2867,7 +1584,207 @@ type AnalyticsApi = {
2867
1584
  *
2868
1585
  * @public
2869
1586
  */
2870
- declare const analyticsApiRef: ApiRef<AnalyticsApi>;
1587
+ declare const analyticsApiRef: _backstage_frontend_plugin_api.ApiRef<AnalyticsApi, "core.analytics"> & {
1588
+ readonly $$type: "@backstage/ApiRef";
1589
+ };
1590
+
1591
+ /**
1592
+ * React hook for retrieving {@link ApiHolder}, an API catalog.
1593
+ *
1594
+ * @public
1595
+ */
1596
+ declare function useApiHolder(): ApiHolder;
1597
+ /**
1598
+ * React hook for retrieving APIs.
1599
+ *
1600
+ * @param apiRef - Reference of the API to use.
1601
+ * @public
1602
+ */
1603
+ declare function useApi<T>(apiRef: ApiRef<T>): T;
1604
+ /**
1605
+ * Wrapper for giving component an API context.
1606
+ *
1607
+ * @param apis - APIs for the context.
1608
+ * @deprecated Use `withApis` from `@backstage/core-compat-api` instead.
1609
+ * @public
1610
+ */
1611
+ declare function withApis<T extends {}>(apis: TypesToApiRefs<T>): <TProps extends T>(WrappedComponent: ComponentType<TProps>) => {
1612
+ (props: PropsWithChildren<Omit<TProps, keyof T>>): react_jsx_runtime.JSX.Element;
1613
+ displayName: string;
1614
+ };
1615
+
1616
+ /**
1617
+ * API reference configuration - holds an ID of the referenced API.
1618
+ *
1619
+ * @public
1620
+ */
1621
+ type ApiRefConfig = {
1622
+ id: string;
1623
+ };
1624
+ /**
1625
+ * Creates a reference to an API.
1626
+ *
1627
+ * @remarks
1628
+ *
1629
+ * The `id` is a stable identifier for the API implementation. The frontend
1630
+ * system infers the owning plugin for an API from the `id`. When using the
1631
+ * builder form, you can instead provide a `pluginId` explicitly. The
1632
+ * recommended pattern is `plugin.<plugin-id>.*` (for example,
1633
+ * `plugin.catalog.entity-presentation`). This ensures that other plugins can't
1634
+ * mistakenly override your API implementation.
1635
+ *
1636
+ * The recommended way to create an API reference is:
1637
+ *
1638
+ * ```ts
1639
+ * const myApiRef = createApiRef<MyApi>().with({
1640
+ * id: 'my-api',
1641
+ * pluginId: 'my-plugin',
1642
+ * });
1643
+ * ```
1644
+ *
1645
+ * The legacy way to create an API reference is:
1646
+ *
1647
+ * ```ts
1648
+ * const myApiRef = createApiRef<MyApi>({ id: 'plugin.my.api' });
1649
+ * ```
1650
+ *
1651
+ * @public
1652
+ */
1653
+ /**
1654
+ * Creates a reference to an API.
1655
+ *
1656
+ * @deprecated Use `createApiRef<T>().with(...)` instead.
1657
+ * @public
1658
+ */
1659
+ declare function createApiRef<T>(config: ApiRefConfig): ApiRef<T> & {
1660
+ readonly $$type: '@backstage/ApiRef';
1661
+ };
1662
+ /**
1663
+ * Creates a reference to an API.
1664
+ *
1665
+ * @remarks
1666
+ *
1667
+ * Returns a builder with a `.with()` method for providing the API reference
1668
+ * configuration.
1669
+ *
1670
+ * @public
1671
+ */
1672
+ declare function createApiRef<T>(): {
1673
+ with<const TId extends string>(config: ApiRefConfig & {
1674
+ id: TId;
1675
+ pluginId?: string;
1676
+ }): ApiRef<T, TId> & {
1677
+ readonly $$type: '@backstage/ApiRef';
1678
+ };
1679
+ };
1680
+
1681
+ /**
1682
+ * Used to infer types for a standalone {@link ApiFactory} that isn't immediately passed
1683
+ * to another function.
1684
+ *
1685
+ * @remarks
1686
+ *
1687
+ * This function doesn't actually do anything, it's only used to infer types.
1688
+ *
1689
+ * @public
1690
+ */
1691
+ declare function createApiFactory<Api, Impl extends Api, Deps extends {
1692
+ [name in string]: unknown;
1693
+ }>(factory: ApiFactory<Api, Impl, Deps>): ApiFactory<Api, Impl, Deps>;
1694
+ /**
1695
+ * Used to infer types for a standalone {@link ApiFactory} that isn't immediately passed
1696
+ * to another function.
1697
+ *
1698
+ * @param api - Ref of the API that will be produced by the factory.
1699
+ * @param instance - Implementation of the API to use.
1700
+ * @public
1701
+ */
1702
+ declare function createApiFactory<Api, Impl extends Api>(api: ApiRef<Api>, instance: Impl): ApiFactory<Api, Impl, {}>;
1703
+
1704
+ /**
1705
+ * Link item for toast notifications.
1706
+ *
1707
+ * @public
1708
+ */
1709
+ type ToastApiMessageLink = {
1710
+ /** Display text for the link */
1711
+ label: string;
1712
+ /** URL the link points to */
1713
+ href: string;
1714
+ };
1715
+ /**
1716
+ * Message handled by the {@link ToastApi}.
1717
+ *
1718
+ * @public
1719
+ */
1720
+ type ToastApiMessage = {
1721
+ /** Title of the toast (required) */
1722
+ title: ReactNode;
1723
+ /** Optional description text */
1724
+ description?: ReactNode;
1725
+ /** Status variant of the toast - defaults to 'success' */
1726
+ status?: 'neutral' | 'info' | 'success' | 'warning' | 'danger';
1727
+ /** Optional array of links to display */
1728
+ links?: ToastApiMessageLink[];
1729
+ /** Timeout in milliseconds before auto-dismiss. If not set, toast is permanent. */
1730
+ timeout?: number;
1731
+ };
1732
+ /**
1733
+ * Handle returned by {@link ToastApi.post} that allows programmatic control
1734
+ * of the posted toast.
1735
+ *
1736
+ * @public
1737
+ */
1738
+ type ToastApiPostResult = {
1739
+ /** Dismiss the toast. */
1740
+ close(): void;
1741
+ };
1742
+ /**
1743
+ * The toast API is used to display toast notifications to the user.
1744
+ *
1745
+ * @remarks
1746
+ * This API provides richer notification capabilities than the AlertApi,
1747
+ * including title/description, links, and per-toast timeout control.
1748
+ *
1749
+ * @example
1750
+ * ```tsx
1751
+ * const toastApi = useApi(toastApiRef);
1752
+ *
1753
+ * // Full-featured toast
1754
+ * toastApi.post({
1755
+ * title: 'Entity saved',
1756
+ * description: 'Your changes have been saved successfully.',
1757
+ * status: 'success',
1758
+ * timeout: 5000,
1759
+ * links: [{ label: 'View entity', href: '/catalog/default/component/my-service' }],
1760
+ * });
1761
+ *
1762
+ * // Simple toast
1763
+ * toastApi.post({ title: 'Processing...', status: 'info' });
1764
+ *
1765
+ * // Programmatic dismiss
1766
+ * const { close } = toastApi.post({ title: 'Uploading...', status: 'info' });
1767
+ * // Later...
1768
+ * close();
1769
+ * ```
1770
+ *
1771
+ * @public
1772
+ */
1773
+ type ToastApi = {
1774
+ /**
1775
+ * Post a toast notification for display to the user.
1776
+ *
1777
+ * @param toast - The toast message to display
1778
+ * @returns A handle with a `close()` method to programmatically dismiss the toast
1779
+ */
1780
+ post(toast: ToastApiMessage): ToastApiPostResult;
1781
+ };
1782
+ /**
1783
+ * The {@link ApiRef} of {@link ToastApi}.
1784
+ *
1785
+ * @public
1786
+ */
1787
+ declare const toastApiRef: ApiRef<ToastApi>;
2871
1788
 
2872
1789
  /** @public */
2873
1790
  interface TranslationRef<TId extends string = string, TMessages extends {
@@ -3246,7 +2163,9 @@ type TranslationApi = {
3246
2163
  /**
3247
2164
  * @public
3248
2165
  */
3249
- declare const translationApiRef: ApiRef<TranslationApi>;
2166
+ declare const translationApiRef: _backstage_frontend_plugin_api.ApiRef<TranslationApi, "core.translation"> & {
2167
+ readonly $$type: "@backstage/ApiRef";
2168
+ };
3250
2169
 
3251
2170
  /**
3252
2171
  * API for retrieving plugin-scoped header actions.
@@ -3270,7 +2189,9 @@ type PluginHeaderActionsApi = {
3270
2189
  *
3271
2190
  * @public
3272
2191
  */
3273
- declare const pluginHeaderActionsApiRef: _backstage_frontend_plugin_api.ApiRef<PluginHeaderActionsApi>;
2192
+ declare const pluginHeaderActionsApiRef: _backstage_frontend_plugin_api.ApiRef<PluginHeaderActionsApi, "core.plugin-header-actions"> & {
2193
+ readonly $$type: "@backstage/ApiRef";
2194
+ };
3274
2195
 
3275
2196
  /**
3276
2197
  * Gets a pre-configured analytics tracker.
@@ -3513,5 +2434,5 @@ declare const PluginHeaderActionBlueprint: _backstage_frontend_plugin_api.Extens
3513
2434
  dataRefs: never;
3514
2435
  }>;
3515
2436
 
3516
- export { AnalyticsContext, AnalyticsImplementationBlueprint, ApiBlueprint, AppRootElementBlueprint, ErrorDisplay, ExtensionBoundary, FeatureFlagState, NavItemBlueprint, NotFoundErrorPage, PageBlueprint, PageLayout, PluginHeaderActionBlueprint, Progress, SessionState, SubPageBlueprint, alertApiRef, analyticsApiRef, appLanguageApiRef, appThemeApiRef, appTreeApiRef, atlassianAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, configApiRef, coreExtensionData, createApiFactory, createApiRef, createExtension, createExtensionBlueprint, createExtensionBlueprintParams, createExtensionDataRef, createExtensionInput, createExternalRouteRef, createFrontendFeatureLoader, createFrontendModule, createFrontendPlugin, createRouteRef, createSubRouteRef, createSwappableComponent, createTranslationMessages, createTranslationRef, createTranslationResource, dialogApiRef, discoveryApiRef, errorApiRef, featureFlagsApiRef, fetchApiRef, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, iconsApiRef, identityApiRef, microsoftAuthApiRef, oauthRequestApiRef, oktaAuthApiRef, oneloginAuthApiRef, openshiftAuthApiRef, pluginHeaderActionsApiRef, routeResolutionApiRef, storageApiRef, swappableComponentsApiRef, translationApiRef, useAnalytics, useApi, useApiHolder, useAppNode, useRouteRef, useRouteRefParams, useTranslationRef, vmwareCloudAuthApiRef, withApis };
3517
- export type { AlertApi, AlertMessage, AnalyticsApi, AnalyticsContextValue, AnalyticsEvent, AnalyticsEventAttributes, AnalyticsImplementation, AnalyticsImplementationFactory, AnalyticsTracker, AnyApiFactory, AnyApiRef, AnyRouteRefParams, ApiFactory, ApiHolder, ApiRef, ApiRefConfig, AppLanguageApi, AppNode, AppNodeEdges, AppNodeInstance, AppNodeSpec, AppTheme, AppThemeApi, AppTree, AppTreeApi, AuthProviderInfo, AuthRequestOptions, BackstageIdentityApi, BackstageIdentityResponse, BackstageUserIdentity, ConfigApi, ConfigurableExtensionDataRef, CreateExtensionBlueprintOptions, CreateExtensionOptions, CreateFrontendFeatureLoaderOptions, CreateFrontendModuleOptions, CreateSwappableComponentOptions, DialogApi, DialogApiDialog, DiscoveryApi, ErrorApi, ErrorApiError, ErrorApiErrorContext, ErrorDisplayProps, Extension, ExtensionAttachTo, ExtensionBlueprint, ExtensionBlueprintDefineParams, ExtensionBlueprintParameters, ExtensionBlueprintParams, ExtensionBoundaryProps, ExtensionDataContainer, ExtensionDataRef, ExtensionDataRefToValue, ExtensionDataValue, ExtensionDefinition, ExtensionDefinitionAttachTo, ExtensionDefinitionParameters, ExtensionFactoryMiddleware, ExtensionInput, ExternalRouteRef, FeatureFlag, FeatureFlagConfig, FeatureFlagsApi, FeatureFlagsSaveOptions, FetchApi, FrontendFeature, FrontendFeatureLoader, FrontendModule, FrontendPlugin, FrontendPluginInfo, FrontendPluginInfoOptions, IconComponent, IconElement, IconsApi, IdentityApi, NotFoundErrorPageProps, OAuthApi, OAuthRequestApi, OAuthRequester, OAuthRequesterOptions, OAuthScope, OpenIdConnectApi, OverridableExtensionDefinition, OverridableFrontendPlugin, PageLayoutProps, PageLayoutTab, PageTab, PendingOAuthRequest, PluginHeaderActionsApi, PluginOptions, PortableSchema, ProfileInfo, ProfileInfoApi, ProgressProps, ResolvedExtensionInput, ResolvedExtensionInputs, RouteFunc, RouteRef, RouteResolutionApi, SessionApi, StorageApi, StorageValueSnapshot, SubRouteRef, SwappableComponentRef, SwappableComponentsApi, TranslationApi, TranslationFunction, TranslationMessages, TranslationMessagesOptions, TranslationRef, TranslationRefOptions, TranslationResource, TranslationResourceOptions, TranslationSnapshot, TypesToApiRefs };
2437
+ export { AnalyticsContext, AnalyticsImplementationBlueprint, AnyApiFactory, AnyRouteRefParams, ApiBlueprint, ApiFactory, ApiHolder, ApiRef, AppNode, AppRootElementBlueprint, ErrorDisplay, ExtensionBoundary, ExternalRouteRef, FeatureFlagState, FrontendFeature, FrontendPlugin, IconComponent, IconElement, NavItemBlueprint, NotFoundErrorPage, PageBlueprint, PageLayout, PluginHeaderActionBlueprint, Progress, RouteRef, SessionState, SubPageBlueprint, SubRouteRef, TypesToApiRefs, alertApiRef, analyticsApiRef, appLanguageApiRef, appThemeApiRef, atlassianAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, configApiRef, coreExtensionData, createApiFactory, createApiRef, createFrontendFeatureLoader, createSwappableComponent, createTranslationMessages, createTranslationRef, createTranslationResource, dialogApiRef, discoveryApiRef, errorApiRef, featureFlagsApiRef, fetchApiRef, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, iconsApiRef, identityApiRef, microsoftAuthApiRef, oauthRequestApiRef, oktaAuthApiRef, oneloginAuthApiRef, openshiftAuthApiRef, pluginHeaderActionsApiRef, routeResolutionApiRef, storageApiRef, swappableComponentsApiRef, toastApiRef, translationApiRef, useAnalytics, useApi, useApiHolder, useAppNode, useRouteRef, useRouteRefParams, useTranslationRef, vmwareCloudAuthApiRef, withApis };
2438
+ export type { AlertApi, AlertMessage, AnalyticsApi, AnalyticsContextValue, AnalyticsEvent, AnalyticsEventAttributes, AnalyticsImplementation, AnalyticsImplementationFactory, AnalyticsTracker, ApiRefConfig, AppLanguageApi, AppTheme, AppThemeApi, AuthProviderInfo, AuthRequestOptions, BackstageIdentityApi, BackstageIdentityResponse, BackstageUserIdentity, ConfigApi, CreateFrontendFeatureLoaderOptions, CreateSwappableComponentOptions, DialogApi, DialogApiDialog, DiscoveryApi, ErrorApi, ErrorApiError, ErrorApiErrorContext, ErrorDisplayProps, ExtensionBoundaryProps, FeatureFlag, FeatureFlagsApi, FeatureFlagsSaveOptions, FetchApi, FrontendFeatureLoader, IconsApi, IdentityApi, NotFoundErrorPageProps, OAuthApi, OAuthRequestApi, OAuthRequester, OAuthRequesterOptions, OAuthScope, OpenIdConnectApi, PageLayoutProps, PageLayoutTab, PageTab, PendingOAuthRequest, PluginHeaderActionsApi, ProfileInfo, ProfileInfoApi, ProgressProps, RouteFunc, RouteResolutionApi, SessionApi, StorageApi, StorageValueSnapshot, SwappableComponentRef, SwappableComponentsApi, ToastApi, ToastApiMessage, ToastApiMessageLink, ToastApiPostResult, TranslationApi, TranslationFunction, TranslationMessages, TranslationMessagesOptions, TranslationRef, TranslationRefOptions, TranslationResource, TranslationResourceOptions, TranslationSnapshot };