@backstage/frontend-plugin-api 0.13.3 → 0.14.0-next.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.
- package/CHANGELOG.md +28 -0
- package/dist/components/ExtensionBoundary.esm.js +1 -1
- package/dist/components/ExtensionBoundary.esm.js.map +1 -1
- package/dist/index.d.ts +72 -247
- package/dist/index.esm.js +0 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/wiring/createExtension.esm.js.map +1 -1
- package/dist/wiring/createExtensionInput.esm.js +2 -1
- package/dist/wiring/createExtensionInput.esm.js.map +1 -1
- package/dist/wiring/createFrontendPlugin.esm.js +1 -0
- package/dist/wiring/createFrontendPlugin.esm.js.map +1 -1
- package/dist/wiring/resolveInputOverrides.esm.js.map +1 -1
- package/package.json +10 -10
- package/dist/blueprints/AppRootWrapperBlueprint.esm.js +0 -21
- package/dist/blueprints/AppRootWrapperBlueprint.esm.js.map +0 -1
- package/dist/blueprints/IconBundleBlueprint.esm.js +0 -21
- package/dist/blueprints/IconBundleBlueprint.esm.js.map +0 -1
- package/dist/blueprints/NavContentBlueprint.esm.js +0 -23
- package/dist/blueprints/NavContentBlueprint.esm.js.map +0 -1
- package/dist/blueprints/RouterBlueprint.esm.js +0 -21
- package/dist/blueprints/RouterBlueprint.esm.js.map +0 -1
- package/dist/blueprints/SignInPageBlueprint.esm.js +0 -52
- package/dist/blueprints/SignInPageBlueprint.esm.js.map +0 -1
- package/dist/blueprints/SwappableComponentBlueprint.esm.js +0 -27
- package/dist/blueprints/SwappableComponentBlueprint.esm.js.map +0 -1
- package/dist/blueprints/ThemeBlueprint.esm.js +0 -21
- package/dist/blueprints/ThemeBlueprint.esm.js.map +0 -1
- package/dist/blueprints/TranslationBlueprint.esm.js +0 -21
- package/dist/blueprints/TranslationBlueprint.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @backstage/frontend-plugin-api
|
|
2
2
|
|
|
3
|
+
## 0.14.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c38b74d: **BREAKING**: The following blueprints have been removed and are now only available from `@backstage/plugin-app-react`:
|
|
8
|
+
|
|
9
|
+
- `IconBundleBlueprint`
|
|
10
|
+
- `NavContentBlueprint`
|
|
11
|
+
- `RouterBlueprint`
|
|
12
|
+
- `SignInPageBlueprint`
|
|
13
|
+
- `SwappableComponentBlueprint`
|
|
14
|
+
- `ThemeBlueprint`
|
|
15
|
+
- `TranslationBlueprint`
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 7edb810: Added a new `internal` option to `createExtensionInput` that marks the input as only allowing attachments from the same plugin.
|
|
20
|
+
- 9554c36: **DEPRECATED**: Multiple attachment points for extensions have been deprecated. The functionality continues to work for backward compatibility, but will log a deprecation warning and be removed in a future release.
|
|
21
|
+
|
|
22
|
+
Extensions using array attachment points should migrate to using Utility APIs instead. See the [Sharing Extensions Across Multiple Locations](https://backstage.io/docs/frontend-system/architecture/27-sharing-extensions) guide for the recommended pattern.
|
|
23
|
+
|
|
24
|
+
- 53b6549: Plugins in the new frontend system now have a `pluginId` field rather than `id` to better align with naming conventions used throughout the frontend and backend systems. The old field is still present but marked as deprecated. All internal code has been updated to prefer `pluginId` while maintaining backward compatibility by falling back to `id` when needed.
|
|
25
|
+
- 69d880e: Bump to latest zod to ensure it has the latest features
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/errors@1.2.7
|
|
28
|
+
- @backstage/types@1.2.2
|
|
29
|
+
- @backstage/version-bridge@1.0.11
|
|
30
|
+
|
|
3
31
|
## 0.13.3
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -64,7 +64,7 @@ function ExtensionBoundary(props) {
|
|
|
64
64
|
node.instance?.getData(coreExtensionData.routePath)
|
|
65
65
|
);
|
|
66
66
|
const plugin = node.spec.plugin;
|
|
67
|
-
const pluginId = plugin.
|
|
67
|
+
const pluginId = plugin.pluginId ?? "app";
|
|
68
68
|
const pluginWrapperApi = useOptionalPluginWrapperApi();
|
|
69
69
|
const PluginWrapper = useMemo(() => {
|
|
70
70
|
return pluginWrapperApi?.getPluginWrapper(pluginId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionBoundary.esm.js","sources":["../../src/components/ExtensionBoundary.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n PropsWithChildren,\n ReactNode,\n Suspense,\n useEffect,\n useMemo,\n lazy as reactLazy,\n} from 'react';\nimport { AnalyticsContext, useAnalytics } from '../analytics';\nimport { ErrorDisplayBoundary } from './ErrorDisplayBoundary';\nimport { ErrorApiBoundary } from './ErrorApiBoundary';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routableExtensionRenderedEvent } from '../../../core-plugin-api/src/analytics/Tracker';\nimport { AppNode, ErrorApi, errorApiRef, useApi } from '../apis';\nimport {\n PluginWrapperApi,\n pluginWrapperApiRef,\n} from '../apis/definitions/PluginWrapperApi';\nimport { coreExtensionData } from '../wiring';\nimport { AppNodeProvider } from './AppNodeProvider';\nimport { Progress } from './DefaultSwappableComponents';\n\nfunction useOptionalErrorApi(): ErrorApi | undefined {\n try {\n return useApi(errorApiRef);\n } catch {\n return undefined;\n }\n}\n\nfunction useOptionalPluginWrapperApi(): PluginWrapperApi | undefined {\n try {\n return useApi(pluginWrapperApiRef);\n } catch {\n return undefined;\n }\n}\ntype RouteTrackerProps = PropsWithChildren<{\n enabled?: boolean;\n}>;\n\nconst RouteTracker = (props: RouteTrackerProps) => {\n const { enabled, children } = props;\n const analytics = useAnalytics();\n\n // This event, never exposed to end-users of the analytics API,\n // helps inform which extension metadata gets associated with a\n // navigation event when the route navigated to is a gathered\n // mountpoint.\n useEffect(() => {\n if (enabled) {\n analytics.captureEvent(routableExtensionRenderedEvent, '');\n }\n }, [analytics, enabled]);\n\n return <>{children}</>;\n};\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n errorPresentation?: 'error-api' | 'error-display';\n node: AppNode;\n children: ReactNode;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n const { node, children } = props;\n\n const errorApi = useOptionalErrorApi();\n\n const hasRoutePathOutput = Boolean(\n node.instance?.getData(coreExtensionData.routePath),\n );\n\n const plugin = node.spec.plugin;\n const pluginId = plugin.
|
|
1
|
+
{"version":3,"file":"ExtensionBoundary.esm.js","sources":["../../src/components/ExtensionBoundary.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n PropsWithChildren,\n ReactNode,\n Suspense,\n useEffect,\n useMemo,\n lazy as reactLazy,\n} from 'react';\nimport { AnalyticsContext, useAnalytics } from '../analytics';\nimport { ErrorDisplayBoundary } from './ErrorDisplayBoundary';\nimport { ErrorApiBoundary } from './ErrorApiBoundary';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routableExtensionRenderedEvent } from '../../../core-plugin-api/src/analytics/Tracker';\nimport { AppNode, ErrorApi, errorApiRef, useApi } from '../apis';\nimport {\n PluginWrapperApi,\n pluginWrapperApiRef,\n} from '../apis/definitions/PluginWrapperApi';\nimport { coreExtensionData } from '../wiring';\nimport { AppNodeProvider } from './AppNodeProvider';\nimport { Progress } from './DefaultSwappableComponents';\n\nfunction useOptionalErrorApi(): ErrorApi | undefined {\n try {\n return useApi(errorApiRef);\n } catch {\n return undefined;\n }\n}\n\nfunction useOptionalPluginWrapperApi(): PluginWrapperApi | undefined {\n try {\n return useApi(pluginWrapperApiRef);\n } catch {\n return undefined;\n }\n}\ntype RouteTrackerProps = PropsWithChildren<{\n enabled?: boolean;\n}>;\n\nconst RouteTracker = (props: RouteTrackerProps) => {\n const { enabled, children } = props;\n const analytics = useAnalytics();\n\n // This event, never exposed to end-users of the analytics API,\n // helps inform which extension metadata gets associated with a\n // navigation event when the route navigated to is a gathered\n // mountpoint.\n useEffect(() => {\n if (enabled) {\n analytics.captureEvent(routableExtensionRenderedEvent, '');\n }\n }, [analytics, enabled]);\n\n return <>{children}</>;\n};\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n errorPresentation?: 'error-api' | 'error-display';\n node: AppNode;\n children: ReactNode;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n const { node, children } = props;\n\n const errorApi = useOptionalErrorApi();\n\n const hasRoutePathOutput = Boolean(\n node.instance?.getData(coreExtensionData.routePath),\n );\n\n const plugin = node.spec.plugin;\n const pluginId = plugin.pluginId ?? 'app';\n\n const pluginWrapperApi = useOptionalPluginWrapperApi();\n\n const PluginWrapper = useMemo(() => {\n return pluginWrapperApi?.getPluginWrapper(pluginId);\n }, [pluginWrapperApi, pluginId]);\n\n // Skipping \"routeRef\" attribute in the new system, the extension \"id\" should provide more insight\n const attributes = {\n extensionId: node.spec.id,\n pluginId,\n };\n\n let content = (\n <AnalyticsContext attributes={attributes}>\n <RouteTracker enabled={hasRoutePathOutput}>{children}</RouteTracker>\n </AnalyticsContext>\n );\n\n if (PluginWrapper) {\n content = <PluginWrapper>{content}</PluginWrapper>;\n }\n\n if (props.errorPresentation === 'error-api') {\n content = (\n <ErrorApiBoundary node={node} errorApi={errorApi}>\n {content}\n </ErrorApiBoundary>\n );\n } else {\n content = (\n <ErrorDisplayBoundary plugin={plugin}>{content}</ErrorDisplayBoundary>\n );\n }\n\n return (\n <AppNodeProvider node={node}>\n <Suspense fallback={<Progress />}>{content}</Suspense>\n </AppNodeProvider>\n );\n}\n\n/** @public */\nexport namespace ExtensionBoundary {\n export function lazy(\n appNode: AppNode,\n loader: () => Promise<JSX.Element>,\n ): JSX.Element {\n const ExtensionComponent = reactLazy(() =>\n loader().then(element => ({ default: () => element })),\n );\n return (\n <ExtensionBoundary node={appNode}>\n <ExtensionComponent />\n </ExtensionBoundary>\n );\n }\n\n export function lazyComponent<TProps extends {}>(\n appNode: AppNode,\n loader: () => Promise<(props: TProps) => JSX.Element>,\n ): (props: TProps) => JSX.Element {\n const ExtensionComponent = reactLazy(() =>\n loader().then(Component => ({ default: Component })),\n ) as unknown as React.ComponentType<TProps>;\n\n return (props: TProps) => (\n <ExtensionBoundary node={appNode}>\n <ExtensionComponent {...props} />\n </ExtensionBoundary>\n );\n }\n}\n"],"names":["ExtensionBoundary","lazy","reactLazy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAS,mBAAA,GAA4C;AACnD,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,WAAW,CAAA;AAAA,EAC3B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAEA,SAAS,2BAAA,GAA4D;AACnE,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,mBAAmB,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAKA,MAAM,YAAA,GAAe,CAAC,KAAA,KAA6B;AACjD,EAAA,MAAM,EAAE,OAAA,EAAS,QAAA,EAAS,GAAI,KAAA;AAC9B,EAAA,MAAM,YAAY,YAAA,EAAa;AA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AA,aAAA;AAAA,CAAA,EAfD,iBAAA,KAAA,iBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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 { IconComponent as IconComponent$1, RouteRef as RouteRef$1 } from '@backstage/frontend-plugin-api';
|
|
6
5
|
import { Expand, JsonObject, Observable, JsonValue, ExpandRecursive } from '@backstage/types';
|
|
7
6
|
import { z } from 'zod';
|
|
8
7
|
import { Config } from '@backstage/config';
|
|
@@ -132,9 +131,11 @@ interface ExtensionInput<UExtensionData extends ExtensionDataRef<unknown, string
|
|
|
132
131
|
}> = ExtensionDataRef, TConfig extends {
|
|
133
132
|
singleton: boolean;
|
|
134
133
|
optional: boolean;
|
|
134
|
+
internal?: boolean;
|
|
135
135
|
} = {
|
|
136
136
|
singleton: boolean;
|
|
137
137
|
optional: boolean;
|
|
138
|
+
internal?: boolean;
|
|
138
139
|
}> {
|
|
139
140
|
readonly $$type: '@backstage/ExtensionInput';
|
|
140
141
|
readonly extensionData: Array<UExtensionData>;
|
|
@@ -144,12 +145,59 @@ interface ExtensionInput<UExtensionData extends ExtensionDataRef<unknown, string
|
|
|
144
145
|
input: string;
|
|
145
146
|
}>;
|
|
146
147
|
}
|
|
147
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Creates a new extension input to be passed to the input map of an extension.
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
*
|
|
153
|
+
* Extension inputs created with this function can be passed to any `inputs` map
|
|
154
|
+
* as part of creating or overriding an extension.
|
|
155
|
+
*
|
|
156
|
+
* The array of extension data references defines the data this input expects.
|
|
157
|
+
* If the required data is not provided by the attached extension, the
|
|
158
|
+
* attachment will fail.
|
|
159
|
+
*
|
|
160
|
+
* The `config` object can be used to restrict the behavior and shape of the
|
|
161
|
+
* input. By default an input will accept zero or more extensions from any
|
|
162
|
+
* plugin. The following options are available:
|
|
163
|
+
*
|
|
164
|
+
* - `singleton`: If set to `true`, only one extension can be attached to the
|
|
165
|
+
* input at a time. Additional extensions will trigger an app error and be
|
|
166
|
+
* ignored.
|
|
167
|
+
* - `optional`: If set to `true`, the input is optional and can be omitted,
|
|
168
|
+
* this only has an effect if the `singleton` is set to `true`.
|
|
169
|
+
* - `internal`: If set to `true`, only extensions from the same plugin will be
|
|
170
|
+
* allowed to attach to this input. Other extensions will trigger an app error
|
|
171
|
+
* and be ignored.
|
|
172
|
+
*
|
|
173
|
+
* @param extensionData - The array of extension data references that this input
|
|
174
|
+
* expects.
|
|
175
|
+
* @param config - The configuration object for the input.
|
|
176
|
+
* @returns An extension input declaration.
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const extension = createExtension({
|
|
180
|
+
* attachTo: { id: 'example-parent', input: 'example-input' },
|
|
181
|
+
* inputs: {
|
|
182
|
+
* content: createExtensionInput([coreExtensionData.reactElement], {
|
|
183
|
+
* singleton: true,
|
|
184
|
+
* }),
|
|
185
|
+
* },
|
|
186
|
+
* output: [coreExtensionData.reactElement],
|
|
187
|
+
* *factory({ inputs }) {
|
|
188
|
+
* const content = inputs.content?.get(coreExtensionData.reactElement);
|
|
189
|
+
* yield coreExtensionData.reactElement(<ContentWrapper>{content}</ContentWrapper>);
|
|
190
|
+
* },
|
|
191
|
+
* });
|
|
192
|
+
* ```
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
148
195
|
declare function createExtensionInput<UExtensionData extends ExtensionDataRef<unknown, string, {
|
|
149
196
|
optional?: true;
|
|
150
197
|
}>, TConfig extends {
|
|
151
198
|
singleton?: boolean;
|
|
152
199
|
optional?: boolean;
|
|
200
|
+
internal?: boolean;
|
|
153
201
|
}>(extensionData: Array<UExtensionData>, config?: TConfig & {
|
|
154
202
|
replaces?: Array<{
|
|
155
203
|
id: string;
|
|
@@ -158,6 +206,7 @@ declare function createExtensionInput<UExtensionData extends ExtensionDataRef<un
|
|
|
158
206
|
}): ExtensionInput<UExtensionData, {
|
|
159
207
|
singleton: TConfig['singleton'] extends true ? true : false;
|
|
160
208
|
optional: TConfig['optional'] extends true ? true : false;
|
|
209
|
+
internal: TConfig['internal'] extends true ? true : false;
|
|
161
210
|
}>;
|
|
162
211
|
|
|
163
212
|
/** @ignore */
|
|
@@ -169,17 +218,21 @@ type ResolvedInputValueOverrides<TInputs extends {
|
|
|
169
218
|
[KName in keyof TInputs as TInputs[KName] extends ExtensionInput<any, {
|
|
170
219
|
optional: infer IOptional extends boolean;
|
|
171
220
|
singleton: boolean;
|
|
221
|
+
internal?: boolean;
|
|
172
222
|
}> ? IOptional extends true ? never : KName : never]: TInputs[KName] extends ExtensionInput<infer IDataRefs, {
|
|
173
223
|
optional: boolean;
|
|
174
224
|
singleton: infer ISingleton extends boolean;
|
|
225
|
+
internal?: boolean;
|
|
175
226
|
}> ? ISingleton extends true ? Iterable<ExtensionDataRefToValue<IDataRefs>> : Array<Iterable<ExtensionDataRefToValue<IDataRefs>>> : never;
|
|
176
227
|
} & {
|
|
177
228
|
[KName in keyof TInputs as TInputs[KName] extends ExtensionInput<any, {
|
|
178
229
|
optional: infer IOptional extends boolean;
|
|
179
230
|
singleton: boolean;
|
|
231
|
+
internal?: boolean;
|
|
180
232
|
}> ? IOptional extends true ? KName : never : never]?: TInputs[KName] extends ExtensionInput<infer IDataRefs, {
|
|
181
233
|
optional: boolean;
|
|
182
234
|
singleton: infer ISingleton extends boolean;
|
|
235
|
+
internal?: boolean;
|
|
183
236
|
}> ? ISingleton extends true ? Iterable<ExtensionDataRefToValue<IDataRefs>> : Array<Iterable<ExtensionDataRefToValue<IDataRefs>>> : never;
|
|
184
237
|
}>;
|
|
185
238
|
|
|
@@ -529,6 +582,15 @@ interface FrontendPlugin<TRoutes extends {
|
|
|
529
582
|
[name in string]: ExternalRouteRef;
|
|
530
583
|
}> {
|
|
531
584
|
readonly $$type: '@backstage/FrontendPlugin';
|
|
585
|
+
/**
|
|
586
|
+
* The plugin ID.
|
|
587
|
+
*/
|
|
588
|
+
readonly pluginId: string;
|
|
589
|
+
/**
|
|
590
|
+
* Deprecated alias for `pluginId`.
|
|
591
|
+
*
|
|
592
|
+
* @deprecated Use `pluginId` instead.
|
|
593
|
+
*/
|
|
532
594
|
readonly id: string;
|
|
533
595
|
readonly routes: TRoutes;
|
|
534
596
|
readonly externalRoutes: TExternalRoutes;
|
|
@@ -930,7 +992,7 @@ type VerifyExtensionAttachTo<UOutput extends ExtensionDataRef, UParentInput exte
|
|
|
930
992
|
* const page = ParentBlueprint.make({ ... });
|
|
931
993
|
* const child = ChildBlueprint.make({ attachTo: page.inputs.children });
|
|
932
994
|
*
|
|
933
|
-
* // Attach to multiple parents at once
|
|
995
|
+
* // Attach to multiple parents at once (deprecated - use Utility APIs instead)
|
|
934
996
|
* [
|
|
935
997
|
* { id: 'page/home', input: 'widgets' },
|
|
936
998
|
* { relative: { kind: 'page' }, input: 'widgets' },
|
|
@@ -950,7 +1012,11 @@ type ExtensionDefinitionAttachTo<UParentInputs extends ExtensionDataRef = Extens
|
|
|
950
1012
|
};
|
|
951
1013
|
input: string;
|
|
952
1014
|
id?: never;
|
|
953
|
-
} | ExtensionInput<UParentInputs>
|
|
1015
|
+
} | ExtensionInput<UParentInputs>
|
|
1016
|
+
/**
|
|
1017
|
+
* @deprecated Multiple attachment points are deprecated and will be removed in a future release. Use a Utility API instead to share functionality across multiple locations. See https://backstage.io/docs/frontend-system/architecture/27-sharing-extensions for migration guidance.
|
|
1018
|
+
*/
|
|
1019
|
+
| Array<{
|
|
954
1020
|
id: string;
|
|
955
1021
|
input: string;
|
|
956
1022
|
relative?: never;
|
|
@@ -3190,108 +3256,6 @@ declare const AppRootElementBlueprint: _backstage_frontend_plugin_api.ExtensionB
|
|
|
3190
3256
|
dataRefs: never;
|
|
3191
3257
|
}>;
|
|
3192
3258
|
|
|
3193
|
-
/**
|
|
3194
|
-
* Creates a extensions that render a React wrapper at the app root, enclosing
|
|
3195
|
-
* the app layout. This is useful for example for adding global React contexts
|
|
3196
|
-
* and similar.
|
|
3197
|
-
*
|
|
3198
|
-
* @public
|
|
3199
|
-
* @deprecated Use {@link @backstage/plugin-app-react#AppRootWrapperBlueprint} instead.
|
|
3200
|
-
* If you were using this blueprint to provide a context for your plugin,
|
|
3201
|
-
* use `PluginWrapperBlueprint` from `@backstage/frontend-plugin-api/alpha` instead.
|
|
3202
|
-
*/
|
|
3203
|
-
declare const AppRootWrapperBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3204
|
-
kind: "app-root-wrapper";
|
|
3205
|
-
params: {
|
|
3206
|
-
/** @deprecated use the `component` parameter instead */
|
|
3207
|
-
Component?: [error: "Use the `component` parameter instead"];
|
|
3208
|
-
component: (props: {
|
|
3209
|
-
children: ReactNode;
|
|
3210
|
-
}) => JSX.Element | null;
|
|
3211
|
-
};
|
|
3212
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<(props: {
|
|
3213
|
-
children: ReactNode;
|
|
3214
|
-
}) => JSX.Element | null, "app.root.wrapper", {}>;
|
|
3215
|
-
inputs: {};
|
|
3216
|
-
config: {};
|
|
3217
|
-
configInput: {};
|
|
3218
|
-
dataRefs: {
|
|
3219
|
-
component: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(props: {
|
|
3220
|
-
children: ReactNode;
|
|
3221
|
-
}) => JSX.Element | null, "app.root.wrapper", {}>;
|
|
3222
|
-
};
|
|
3223
|
-
}>;
|
|
3224
|
-
|
|
3225
|
-
/**
|
|
3226
|
-
* @public
|
|
3227
|
-
* @deprecated Use {@link @backstage/plugin-app-react#IconBundleBlueprint} instead.
|
|
3228
|
-
*/
|
|
3229
|
-
declare const IconBundleBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3230
|
-
kind: "icon-bundle";
|
|
3231
|
-
params: {
|
|
3232
|
-
icons: { [key in string]: IconComponent; };
|
|
3233
|
-
};
|
|
3234
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<{
|
|
3235
|
-
[x: string]: IconComponent;
|
|
3236
|
-
}, "core.icons", {}>;
|
|
3237
|
-
inputs: {};
|
|
3238
|
-
config: {};
|
|
3239
|
-
configInput: {};
|
|
3240
|
-
dataRefs: {
|
|
3241
|
-
icons: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<{
|
|
3242
|
-
[x: string]: IconComponent;
|
|
3243
|
-
}, "core.icons", {}>;
|
|
3244
|
-
};
|
|
3245
|
-
}>;
|
|
3246
|
-
|
|
3247
|
-
/**
|
|
3248
|
-
* The props for the {@link NavContentComponent}.
|
|
3249
|
-
*
|
|
3250
|
-
* @public
|
|
3251
|
-
*/
|
|
3252
|
-
interface NavContentComponentProps {
|
|
3253
|
-
/**
|
|
3254
|
-
* The nav items available to the component. These are all the items created
|
|
3255
|
-
* with the {@link NavItemBlueprint} in the app.
|
|
3256
|
-
*
|
|
3257
|
-
* In addition to the original properties from the nav items, these also
|
|
3258
|
-
* include a resolved route path as `to`, and duplicated `title` as `text` to
|
|
3259
|
-
* simplify rendering.
|
|
3260
|
-
*/
|
|
3261
|
-
items: Array<{
|
|
3262
|
-
icon: IconComponent$1;
|
|
3263
|
-
title: string;
|
|
3264
|
-
routeRef: RouteRef$1<undefined>;
|
|
3265
|
-
to: string;
|
|
3266
|
-
text: string;
|
|
3267
|
-
}>;
|
|
3268
|
-
}
|
|
3269
|
-
/**
|
|
3270
|
-
* A component that renders the nav bar content, to be passed to the {@link NavContentBlueprint}.
|
|
3271
|
-
*
|
|
3272
|
-
* @public
|
|
3273
|
-
*/
|
|
3274
|
-
type NavContentComponent = (props: NavContentComponentProps) => JSX.Element | null;
|
|
3275
|
-
/**
|
|
3276
|
-
* Creates an extension that replaces the entire nav bar with your own component.
|
|
3277
|
-
*
|
|
3278
|
-
* @public
|
|
3279
|
-
* @deprecated Use {@link @backstage/plugin-app-react#NavContentBlueprint} instead.
|
|
3280
|
-
*/
|
|
3281
|
-
declare const NavContentBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3282
|
-
kind: "nav-content";
|
|
3283
|
-
params: {
|
|
3284
|
-
component: NavContentComponent;
|
|
3285
|
-
};
|
|
3286
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<NavContentComponent, "core.nav-content.component", {}>;
|
|
3287
|
-
inputs: {};
|
|
3288
|
-
config: {};
|
|
3289
|
-
configInput: {};
|
|
3290
|
-
dataRefs: {
|
|
3291
|
-
component: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<NavContentComponent, "core.nav-content.component", {}>;
|
|
3292
|
-
};
|
|
3293
|
-
}>;
|
|
3294
|
-
|
|
3295
3259
|
/**
|
|
3296
3260
|
* Creates extensions that make up the items of the nav bar.
|
|
3297
3261
|
*
|
|
@@ -3350,144 +3314,5 @@ declare const PageBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
|
3350
3314
|
dataRefs: never;
|
|
3351
3315
|
}>;
|
|
3352
3316
|
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
* @deprecated Use {@link @backstage/plugin-app-react#RouterBlueprint} instead.
|
|
3356
|
-
*/
|
|
3357
|
-
declare const RouterBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3358
|
-
kind: "app-router-component";
|
|
3359
|
-
params: {
|
|
3360
|
-
/** @deprecated use the `component` parameter instead */
|
|
3361
|
-
Component?: [error: "Use the `component` parameter instead"];
|
|
3362
|
-
component: (props: {
|
|
3363
|
-
children: ReactNode;
|
|
3364
|
-
}) => JSX.Element | null;
|
|
3365
|
-
};
|
|
3366
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<(props: {
|
|
3367
|
-
children: ReactNode;
|
|
3368
|
-
}) => JSX.Element | null, "app.router.wrapper", {}>;
|
|
3369
|
-
inputs: {};
|
|
3370
|
-
config: {};
|
|
3371
|
-
configInput: {};
|
|
3372
|
-
dataRefs: {
|
|
3373
|
-
component: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(props: {
|
|
3374
|
-
children: ReactNode;
|
|
3375
|
-
}) => JSX.Element | null, "app.router.wrapper", {}>;
|
|
3376
|
-
};
|
|
3377
|
-
}>;
|
|
3378
|
-
|
|
3379
|
-
/**
|
|
3380
|
-
* Props for the `SignInPage` component.
|
|
3381
|
-
*
|
|
3382
|
-
* @public
|
|
3383
|
-
*/
|
|
3384
|
-
type SignInPageProps = {
|
|
3385
|
-
/**
|
|
3386
|
-
* Set the IdentityApi on successful sign-in. This should only be called once.
|
|
3387
|
-
*/
|
|
3388
|
-
onSignInSuccess(identityApi: IdentityApi): void;
|
|
3389
|
-
/**
|
|
3390
|
-
* The children to render.
|
|
3391
|
-
*/
|
|
3392
|
-
children?: ReactNode;
|
|
3393
|
-
};
|
|
3394
|
-
/**
|
|
3395
|
-
* Creates an extension that replaces the sign in page.
|
|
3396
|
-
*
|
|
3397
|
-
* @public
|
|
3398
|
-
* @deprecated Use {@link @backstage/plugin-app-react#SignInPageBlueprint} instead.
|
|
3399
|
-
*/
|
|
3400
|
-
declare const SignInPageBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3401
|
-
kind: "sign-in-page";
|
|
3402
|
-
params: {
|
|
3403
|
-
loader: () => Promise<ComponentType<SignInPageProps>>;
|
|
3404
|
-
};
|
|
3405
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<ComponentType<SignInPageProps>, "core.sign-in-page.component", {}>;
|
|
3406
|
-
inputs: {};
|
|
3407
|
-
config: {};
|
|
3408
|
-
configInput: {};
|
|
3409
|
-
dataRefs: {
|
|
3410
|
-
component: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<ComponentType<SignInPageProps>, "core.sign-in-page.component", {}>;
|
|
3411
|
-
};
|
|
3412
|
-
}>;
|
|
3413
|
-
|
|
3414
|
-
/**
|
|
3415
|
-
* Creates an extension that adds/replaces an app theme.
|
|
3416
|
-
*
|
|
3417
|
-
* @public
|
|
3418
|
-
* @deprecated Use {@link @backstage/plugin-app-react#ThemeBlueprint} instead.
|
|
3419
|
-
*/
|
|
3420
|
-
declare const ThemeBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3421
|
-
kind: "theme";
|
|
3422
|
-
params: {
|
|
3423
|
-
theme: AppTheme;
|
|
3424
|
-
};
|
|
3425
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<AppTheme, "core.theme.theme", {}>;
|
|
3426
|
-
inputs: {};
|
|
3427
|
-
config: {};
|
|
3428
|
-
configInput: {};
|
|
3429
|
-
dataRefs: {
|
|
3430
|
-
theme: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<AppTheme, "core.theme.theme", {}>;
|
|
3431
|
-
};
|
|
3432
|
-
}>;
|
|
3433
|
-
|
|
3434
|
-
/**
|
|
3435
|
-
* Creates an extension that adds translations to your app.
|
|
3436
|
-
*
|
|
3437
|
-
* @public
|
|
3438
|
-
* @deprecated Use {@link @backstage/plugin-app-react#TranslationBlueprint} instead.
|
|
3439
|
-
*/
|
|
3440
|
-
declare const TranslationBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3441
|
-
kind: "translation";
|
|
3442
|
-
params: {
|
|
3443
|
-
resource: TranslationResource | TranslationMessages;
|
|
3444
|
-
};
|
|
3445
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<TranslationResource<string> | TranslationMessages<string, {
|
|
3446
|
-
[x: string]: string;
|
|
3447
|
-
}, boolean>, "core.translation.translation", {}>;
|
|
3448
|
-
inputs: {};
|
|
3449
|
-
config: {};
|
|
3450
|
-
configInput: {};
|
|
3451
|
-
dataRefs: {
|
|
3452
|
-
translation: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<TranslationResource<string> | TranslationMessages<string, {
|
|
3453
|
-
[x: string]: string;
|
|
3454
|
-
}, boolean>, "core.translation.translation", {}>;
|
|
3455
|
-
};
|
|
3456
|
-
}>;
|
|
3457
|
-
|
|
3458
|
-
/**
|
|
3459
|
-
* Blueprint for creating swappable components from a SwappableComponentRef and a loader
|
|
3460
|
-
*
|
|
3461
|
-
* @public
|
|
3462
|
-
* @deprecated Use {@link @backstage/plugin-app-react#SwappableComponentBlueprint} instead.
|
|
3463
|
-
*/
|
|
3464
|
-
declare const SwappableComponentBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
3465
|
-
kind: "component";
|
|
3466
|
-
params: <Ref extends SwappableComponentRef<any>>(params: {
|
|
3467
|
-
component: Ref extends SwappableComponentRef<any, infer IExternalComponentProps> ? {
|
|
3468
|
-
ref: Ref;
|
|
3469
|
-
} & ((props: IExternalComponentProps) => JSX.Element | null) : never;
|
|
3470
|
-
loader: Ref extends SwappableComponentRef<infer IInnerComponentProps, any> ? (() => (props: IInnerComponentProps) => JSX.Element | null) | (() => Promise<(props: IInnerComponentProps) => JSX.Element | null>) : never;
|
|
3471
|
-
}) => _backstage_frontend_plugin_api.ExtensionBlueprintParams<{
|
|
3472
|
-
component: Ref extends SwappableComponentRef<any, infer IExternalComponentProps> ? {
|
|
3473
|
-
ref: Ref;
|
|
3474
|
-
} & ((props: IExternalComponentProps) => JSX.Element | null) : never;
|
|
3475
|
-
loader: Ref extends SwappableComponentRef<infer IInnerComponentProps, any> ? (() => (props: IInnerComponentProps) => JSX.Element | null) | (() => Promise<(props: IInnerComponentProps) => JSX.Element | null>) : never;
|
|
3476
|
-
}>;
|
|
3477
|
-
output: _backstage_frontend_plugin_api.ExtensionDataRef<{
|
|
3478
|
-
ref: SwappableComponentRef;
|
|
3479
|
-
loader: (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>);
|
|
3480
|
-
}, "core.swappableComponent", {}>;
|
|
3481
|
-
inputs: {};
|
|
3482
|
-
config: {};
|
|
3483
|
-
configInput: {};
|
|
3484
|
-
dataRefs: {
|
|
3485
|
-
component: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<{
|
|
3486
|
-
ref: SwappableComponentRef;
|
|
3487
|
-
loader: (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>);
|
|
3488
|
-
}, "core.swappableComponent", {}>;
|
|
3489
|
-
};
|
|
3490
|
-
}>;
|
|
3491
|
-
|
|
3492
|
-
export { AnalyticsContext, AnalyticsImplementationBlueprint, ApiBlueprint, AppRootElementBlueprint, AppRootWrapperBlueprint, ErrorDisplay, ExtensionBoundary, FeatureFlagState, IconBundleBlueprint, NavContentBlueprint, NavItemBlueprint, NotFoundErrorPage, PageBlueprint, Progress, RouterBlueprint, SessionState, SignInPageBlueprint, SwappableComponentBlueprint, ThemeBlueprint, TranslationBlueprint, 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, routeResolutionApiRef, storageApiRef, swappableComponentsApiRef, translationApiRef, useAnalytics, useApi, useApiHolder, useAppNode, useRouteRef, useRouteRefParams, useTranslationRef, vmwareCloudAuthApiRef, withApis };
|
|
3493
|
-
export type { AlertApi, AlertMessage, AnalyticsApi, AnalyticsContextValue, AnalyticsEvent, AnalyticsEventAttributes, AnalyticsImplementation, AnalyticsImplementationFactory, AnalyticsTracker, AnyApiFactory, AnyApiRef, AnyExtensionDataRef, 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, ExtensionAttachToSpec, 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, IconsApi, IdentityApi, NavContentComponent, NavContentComponentProps, NotFoundErrorPageProps, OAuthApi, OAuthRequestApi, OAuthRequester, OAuthRequesterOptions, OAuthScope, OpenIdConnectApi, OverridableExtensionDefinition, OverridableFrontendPlugin, PendingOAuthRequest, PluginOptions, PortableSchema, ProfileInfo, ProfileInfoApi, ProgressProps, ResolvedExtensionInput, ResolvedExtensionInputs, RouteFunc, RouteRef, RouteResolutionApi, SessionApi, SignInPageProps, StorageApi, StorageValueSnapshot, SubRouteRef, SwappableComponentRef, SwappableComponentsApi, TranslationApi, TranslationFunction, TranslationMessages, TranslationMessagesOptions, TranslationRef, TranslationRefOptions, TranslationResource, TranslationResourceOptions, TranslationSnapshot, TypesToApiRefs };
|
|
3317
|
+
export { AnalyticsContext, AnalyticsImplementationBlueprint, ApiBlueprint, AppRootElementBlueprint, ErrorDisplay, ExtensionBoundary, FeatureFlagState, NavItemBlueprint, NotFoundErrorPage, PageBlueprint, Progress, SessionState, 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, routeResolutionApiRef, storageApiRef, swappableComponentsApiRef, translationApiRef, useAnalytics, useApi, useApiHolder, useAppNode, useRouteRef, useRouteRefParams, useTranslationRef, vmwareCloudAuthApiRef, withApis };
|
|
3318
|
+
export type { AlertApi, AlertMessage, AnalyticsApi, AnalyticsContextValue, AnalyticsEvent, AnalyticsEventAttributes, AnalyticsImplementation, AnalyticsImplementationFactory, AnalyticsTracker, AnyApiFactory, AnyApiRef, AnyExtensionDataRef, 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, ExtensionAttachToSpec, 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, IconsApi, IdentityApi, NotFoundErrorPageProps, OAuthApi, OAuthRequestApi, OAuthRequester, OAuthRequesterOptions, OAuthScope, OpenIdConnectApi, OverridableExtensionDefinition, OverridableFrontendPlugin, PendingOAuthRequest, 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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -25,16 +25,8 @@ export { createApiFactory } from './apis/system/helpers.esm.js';
|
|
|
25
25
|
export { AnalyticsImplementationBlueprint } from './blueprints/AnalyticsImplementationBlueprint.esm.js';
|
|
26
26
|
export { ApiBlueprint } from './blueprints/ApiBlueprint.esm.js';
|
|
27
27
|
export { AppRootElementBlueprint } from './blueprints/AppRootElementBlueprint.esm.js';
|
|
28
|
-
export { AppRootWrapperBlueprint } from './blueprints/AppRootWrapperBlueprint.esm.js';
|
|
29
|
-
export { IconBundleBlueprint } from './blueprints/IconBundleBlueprint.esm.js';
|
|
30
|
-
export { NavContentBlueprint } from './blueprints/NavContentBlueprint.esm.js';
|
|
31
28
|
export { NavItemBlueprint } from './blueprints/NavItemBlueprint.esm.js';
|
|
32
29
|
export { PageBlueprint } from './blueprints/PageBlueprint.esm.js';
|
|
33
|
-
export { RouterBlueprint } from './blueprints/RouterBlueprint.esm.js';
|
|
34
|
-
export { SignInPageBlueprint } from './blueprints/SignInPageBlueprint.esm.js';
|
|
35
|
-
export { ThemeBlueprint } from './blueprints/ThemeBlueprint.esm.js';
|
|
36
|
-
export { TranslationBlueprint } from './blueprints/TranslationBlueprint.esm.js';
|
|
37
|
-
export { SwappableComponentBlueprint } from './blueprints/SwappableComponentBlueprint.esm.js';
|
|
38
30
|
export { ExtensionBoundary } from './components/ExtensionBoundary.esm.js';
|
|
39
31
|
export { createSwappableComponent } from './components/createSwappableComponent.esm.js';
|
|
40
32
|
export { useAppNode } from './components/AppNodeProvider.esm.js';
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtension.esm.js","sources":["../../src/wiring/createExtension.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiHolder, AppNode } from '../apis';\nimport { Expand } from '@backstage/types';\nimport {\n ResolvedInputValueOverrides,\n resolveInputOverrides,\n} from './resolveInputOverrides';\nimport {\n createExtensionDataContainer,\n OpaqueExtensionInput,\n} from '@internal/frontend';\nimport { ExtensionDataRef, ExtensionDataValue } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport type { z } from 'zod';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\nimport { OpaqueExtensionDefinition } from '@internal/frontend';\nimport { ExtensionDataContainer } from './types';\nimport {\n ExtensionBlueprint,\n ExtensionBlueprintDefineParams,\n} from './createExtensionBlueprint';\nimport { FrontendPlugin } from './createFrontendPlugin';\nimport { FrontendModule } from './createFrontendModule';\n\n/**\n * This symbol is used to pass parameter overrides from the extension override to the blueprint factory\n * @internal\n */\nexport const ctxParamsSymbol = Symbol('params');\n\n/**\n * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<TExtensionInput extends ExtensionInput> =\n TExtensionInput['extensionData'] extends Array<ExtensionDataRef>\n ? {\n node: AppNode;\n } & ExtensionDataContainer<TExtensionInput['extensionData'][number]>\n : never;\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends {\n [name in string]: ExtensionInput;\n },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]>>\n : Expand<ResolvedExtensionInput<TInputs[InputName]> | undefined>;\n};\n\ntype ToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\ntype PopUnion<U> = ToIntersection<\n U extends any ? () => U : never\n> extends () => infer R\n ? [rest: Exclude<U, R>, next: R]\n : undefined;\n\n/** @ignore */\ntype JoinStringUnion<\n U,\n TDiv extends string = ', ',\n TResult extends string = '',\n> = PopUnion<U> extends [infer IRest extends string, infer INext extends string]\n ? TResult extends ''\n ? JoinStringUnion<IRest, TDiv, INext>\n : JoinStringUnion<IRest, TDiv, `${TResult}${TDiv}${INext}`>\n : TResult;\n\n/** @ignore */\nexport type RequiredExtensionIds<UExtensionData extends ExtensionDataRef> =\n UExtensionData extends any\n ? UExtensionData['config']['optional'] extends true\n ? never\n : UExtensionData['id']\n : never;\n\n/** @ignore */\nexport type VerifyExtensionFactoryOutput<\n UDeclaredOutput extends ExtensionDataRef,\n UFactoryOutput extends ExtensionDataValue<any, any>,\n> = [RequiredExtensionIds<UDeclaredOutput>] extends [UFactoryOutput['id']]\n ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']]\n ? {}\n : `Error: The extension factory has undeclared output(s): ${JoinStringUnion<\n Exclude<UFactoryOutput['id'], UDeclaredOutput['id']>\n >}`\n : `Error: The extension factory is missing the following output(s): ${JoinStringUnion<\n Exclude<RequiredExtensionIds<UDeclaredOutput>, UFactoryOutput['id']>\n >}`;\n\n/** @ignore */\nexport type VerifyExtensionAttachTo<\n UOutput extends ExtensionDataRef,\n UParentInput extends ExtensionDataRef,\n> = ExtensionDataRef extends UParentInput\n ? {}\n : [RequiredExtensionIds<UParentInput>] extends [RequiredExtensionIds<UOutput>]\n ? {}\n : `Error: This parent extension input requires the following extension data, but it is not declared as guaranteed output of this extension: ${JoinStringUnion<\n Exclude<RequiredExtensionIds<UParentInput>, RequiredExtensionIds<UOutput>>\n >}`;\n\n/**\n * Specifies where an extension should attach in the extension tree.\n *\n * @remarks\n *\n * A standard attachment point declaration will specify the ID of the parent extension, as well as the name of the input to attach to.\n *\n * There are three more advanced forms that are available for more complex use-cases:\n *\n * 1. Relative attachment points: using the `relative` property instead of `id`, the attachment point is resolved relative to the current plugin.\n * 2. Extension input references: using a reference in code to another extension's input in the same plugin. These references are always relative.\n * 3. Array of attachment points: an array of attachment points can be used to clone and attach to multiple extensions at once.\n *\n * @example\n * ```ts\n * // Attach to a specific extension by full ID\n * { id: 'app/routes', input: 'routes' }\n *\n * // Attach to an extension in the same plugin by kind\n * { relative: { kind: 'page' }, input: 'actions' }\n *\n * // Attach to a specific input of another extension\n * const page = ParentBlueprint.make({ ... });\n * const child = ChildBlueprint.make({ attachTo: page.inputs.children });\n *\n * // Attach to multiple parents at once\n * [\n * { id: 'page/home', input: 'widgets' },\n * { relative: { kind: 'page' }, input: 'widgets' },\n * ]\n * ```\n *\n * @public\n */\nexport type ExtensionDefinitionAttachTo<\n UParentInputs extends ExtensionDataRef = ExtensionDataRef,\n> =\n | { id: string; input: string; relative?: never }\n | { relative: { kind?: string; name?: string }; input: string; id?: never }\n | ExtensionInput<UParentInputs>\n | Array<\n | { id: string; input: string; relative?: never }\n | {\n relative: { kind?: string; name?: string };\n input: string;\n id?: never;\n }\n | ExtensionInput<UParentInputs>\n >;\n\n/** @public */\nexport type CreateExtensionOptions<\n TKind extends string | undefined,\n TName extends string | undefined,\n UOutput extends ExtensionDataRef,\n TInputs extends { [inputName in string]: ExtensionInput },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n UParentInputs extends ExtensionDataRef,\n> = {\n kind?: TKind;\n name?: TName;\n attachTo: ExtensionDefinitionAttachTo<UParentInputs> &\n VerifyExtensionAttachTo<UOutput, UParentInputs>;\n disabled?: boolean;\n inputs?: TInputs;\n output: Array<UOutput>;\n config?: {\n schema: TConfigSchema;\n };\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }): Iterable<UFactoryOutput>;\n} & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;\n\n/** @public */\nexport type ExtensionDefinitionParameters = {\n kind?: string;\n name?: string;\n configInput?: { [K in string]: any };\n config?: { [K in string]: any };\n output?: ExtensionDataRef;\n inputs?: { [KName in string]: ExtensionInput };\n params?: object | ExtensionBlueprintDefineParams;\n};\n\n/**\n * Same as the one in `createExtensionBlueprint`, but with `ParamsFactory` inlined.\n * It can't be exported because it breaks API reports.\n * @ignore\n */\ntype AnyParamsInput<TParams extends object | ExtensionBlueprintDefineParams> =\n TParams extends ExtensionBlueprintDefineParams<infer IParams>\n ? IParams | ((define: TParams) => ReturnType<TParams>)\n :\n | TParams\n | ((\n define: ExtensionBlueprintDefineParams<TParams, TParams>,\n ) => ReturnType<ExtensionBlueprintDefineParams<TParams, TParams>>);\n\n/** @public */\nexport interface ExtensionDefinition<\n TParams extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> {\n $$type: '@backstage/ExtensionDefinition';\n readonly T: TParams;\n}\n\n/** @public */\nexport interface OverridableExtensionDefinition<\n T extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> extends ExtensionDefinition<T> {\n /**\n * References to the inputs of this extension, which can be used to attach child extensions.\n */\n readonly inputs: {\n [K in keyof T['inputs']]: ExtensionInput<\n T['inputs'][K] extends ExtensionInput<infer IData> ? IData : never\n >;\n };\n\n override<\n TExtensionConfigSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n UNewOutput extends ExtensionDataRef,\n TExtraInputs extends { [inputName in string]: ExtensionInput },\n TParamsInput extends AnyParamsInput<NonNullable<T['params']>>,\n UParentInputs extends ExtensionDataRef,\n >(\n args: Expand<\n {\n attachTo?: ExtensionDefinitionAttachTo<UParentInputs> &\n VerifyExtensionAttachTo<\n ExtensionDataRef extends UNewOutput\n ? NonNullable<T['output']>\n : UNewOutput,\n UParentInputs\n >;\n disabled?: boolean;\n inputs?: TExtraInputs & {\n [KName in keyof T['inputs']]?: `Error: Input '${KName &\n string}' is already defined in parent definition`;\n };\n output?: Array<UNewOutput>;\n config?: {\n schema: TExtensionConfigSchema & {\n [KName in keyof T['config']]?: `Error: Config key '${KName &\n string}' is already defined in parent schema`;\n };\n };\n factory?(\n originalFactory: <\n TFactoryParamsReturn extends AnyParamsInput<\n NonNullable<T['params']>\n >,\n >(\n context?: Expand<\n {\n config?: T['config'];\n inputs?: ResolvedInputValueOverrides<NonNullable<T['inputs']>>;\n } & ([T['params']] extends [never]\n ? {}\n : {\n params?: TFactoryParamsReturn extends ExtensionBlueprintDefineParams\n ? TFactoryParamsReturn\n : T['params'] extends ExtensionBlueprintDefineParams\n ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams(<params>))`'\n : Partial<T['params']>;\n })\n >,\n ) => ExtensionDataContainer<NonNullable<T['output']>>,\n context: {\n node: AppNode;\n apis: ApiHolder;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n inputs: Expand<ResolvedExtensionInputs<T['inputs'] & TExtraInputs>>;\n },\n ): Iterable<UFactoryOutput>;\n } & ([T['params']] extends [never]\n ? {}\n : {\n params?: TParamsInput extends ExtensionBlueprintDefineParams\n ? TParamsInput\n : T['params'] extends ExtensionBlueprintDefineParams\n ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams(<params>))`'\n : Partial<T['params']>;\n })\n > &\n VerifyExtensionFactoryOutput<\n ExtensionDataRef extends UNewOutput\n ? NonNullable<T['output']>\n : UNewOutput,\n UFactoryOutput\n >,\n ): OverridableExtensionDefinition<{\n kind: T['kind'];\n name: T['name'];\n output: ExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput;\n inputs: T['inputs'] & TExtraInputs;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n configInput: T['configInput'] &\n z.input<\n z.ZodObject<{\n [key in keyof TExtensionConfigSchema]: ReturnType<\n TExtensionConfigSchema[key]\n >;\n }>\n >;\n }>;\n}\n\n/**\n * @internal\n */\nfunction bindInputs(\n inputs: { [inputName in string]: ExtensionInput } | undefined,\n kind?: string,\n name?: string,\n) {\n if (!inputs) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(inputs).map(([inputName, input]) => [\n inputName,\n OpaqueExtensionInput.toInternal(input).withContext?.({\n kind,\n name,\n input: inputName,\n }) ?? input,\n ]),\n );\n}\n\n/**\n * Creates a new extension definition for installation in a Backstage app.\n *\n * @remarks\n *\n * This is a low-level function for creation of extensions with arbitrary inputs\n * and outputs and is typically only intended to be used for advanced overrides\n * or framework-level extensions. For most extension creation needs, it is\n * recommended to use existing {@link ExtensionBlueprint}s instead. You can find\n * blueprints both in the `@backstage/frontend-plugin-api` package as well as\n * other plugin libraries. There is also a list of\n * {@link https://backstage.io/docs/frontend-system/building-plugins/common-extension-blueprints | commonly used blueprints}\n * in the frontend system documentation.\n *\n * Extension definitions that are created with this function can be installed in\n * a Backstage app via a {@link FrontendPlugin} or {@link FrontendModule}.\n *\n * For more details on how extensions work, see the\n * {@link https://backstage.io/docs/frontend-system/architecture/extensions | documentation for extensions}.\n *\n * @example\n *\n * ```ts\n * const myExtension = createExtension({\n * name: 'example',\n * attachTo: { id: 'app', input: 'root' },\n * output: [coreExtensionData.reactElement],\n * factory() {\n * return [coreExtensionData.reactElement(<h1>Hello, world!</h1>)];\n * },\n * });\n * ```\n *\n * @public\n */\nexport function createExtension<\n UOutput extends ExtensionDataRef,\n TInputs extends { [inputName in string]: ExtensionInput },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n const TKind extends string | undefined = undefined,\n const TName extends string | undefined = undefined,\n UParentInputs extends ExtensionDataRef = ExtensionDataRef,\n>(\n options: CreateExtensionOptions<\n TKind,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput,\n UParentInputs\n >,\n): OverridableExtensionDefinition<{\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n // This inference and remapping back to ExtensionDataRef eliminates any occurrences ConfigurationExtensionDataRef\n output: UOutput extends ExtensionDataRef<\n infer IData,\n infer IId,\n infer IConfig\n >\n ? ExtensionDataRef<IData, IId, IConfig>\n : never;\n inputs: TInputs;\n params: never;\n kind: string | undefined extends TKind ? undefined : TKind;\n name: string | undefined extends TName ? undefined : TName;\n}> {\n const schemaDeclaration = options.config?.schema;\n const configSchema =\n schemaDeclaration &&\n createSchemaFromZod(innerZ =>\n innerZ.object(\n Object.fromEntries(\n Object.entries(schemaDeclaration).map(([k, v]) => [k, v(innerZ)]),\n ),\n ),\n );\n\n return OpaqueExtensionDefinition.createInstance('v2', {\n T: undefined as unknown as {\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<\n ReturnType<TConfigSchema[key]>\n >;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n name: string | undefined extends TName ? undefined : TName;\n },\n kind: options.kind,\n name: options.name,\n attachTo: options.attachTo,\n disabled: options.disabled ?? false,\n inputs: bindInputs(options.inputs, options.kind, options.name),\n output: options.output,\n configSchema,\n factory: options.factory,\n toString() {\n const parts: string[] = [];\n if (options.kind) {\n parts.push(`kind=${options.kind}`);\n }\n if (options.name) {\n parts.push(`name=${options.name}`);\n }\n const attachTo = [options.attachTo]\n .flat()\n .map(aAny => {\n const a = aAny as ExtensionDefinitionAttachTo;\n if (OpaqueExtensionInput.isType(a)) {\n const { context } = OpaqueExtensionInput.toInternal(a);\n if (!context) {\n return '<detached-input>';\n }\n let id = '<plugin>';\n if (context?.kind) {\n id = `${context?.kind}:${id}`;\n }\n if (context?.name) {\n id = `${id}/${context?.name}`;\n }\n return `${id}@${context.input}`;\n }\n if ('relative' in a && a.relative) {\n let id = '<plugin>';\n if (a.relative.kind) {\n id = `${a.relative.kind}:${id}`;\n }\n if (a.relative.name) {\n id = `${id}/${a.relative.name}`;\n }\n return `${id}@${a.input}`;\n }\n if ('id' in a) {\n return `${a.id}@${a.input}`;\n }\n throw new Error('Invalid attachment point specification');\n })\n .join('+');\n parts.push(`attachTo=${attachTo}`);\n return `ExtensionDefinition{${parts.join(',')}}`;\n },\n override(overrideOptions) {\n if (!Array.isArray(options.output)) {\n throw new Error(\n 'Cannot override an extension that is not declared using the new format with outputs as an array',\n );\n }\n\n // TODO(Rugvip): Making this a type check would be optimal, but it seems\n // like it's tricky to add that and still have the type\n // inference work correctly for the factory output.\n if (overrideOptions.output && !overrideOptions.factory) {\n throw new Error(\n 'Refused to override output without also overriding factory',\n );\n }\n // TODO(Rugvip): Similar to above, would be nice to error during type checking, but don't want to complicate the types too much\n if (overrideOptions.params && overrideOptions.factory) {\n throw new Error(\n 'Refused to override params and factory at the same time',\n );\n }\n\n return createExtension({\n kind: options.kind,\n name: options.name,\n attachTo: (overrideOptions.attachTo ??\n options.attachTo) as ExtensionDefinitionAttachTo,\n disabled: overrideOptions.disabled ?? options.disabled,\n inputs: bindInputs(\n {\n ...(options.inputs ?? {}),\n ...(overrideOptions.inputs ?? {}),\n },\n options.kind,\n options.name,\n ),\n output: (overrideOptions.output ??\n options.output) as ExtensionDataRef[],\n config:\n options.config || overrideOptions.config\n ? {\n schema: {\n ...options.config?.schema,\n ...overrideOptions.config?.schema,\n },\n }\n : undefined,\n factory: ({ node, apis, config, inputs }) => {\n if (!overrideOptions.factory) {\n return options.factory({\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n [ctxParamsSymbol as any]: overrideOptions.params,\n });\n }\n const parentResult = overrideOptions.factory(\n (innerContext): ExtensionDataContainer<UOutput> => {\n return createExtensionDataContainer<UOutput>(\n options.factory({\n node,\n apis,\n config: (innerContext?.config ?? config) as any,\n inputs: resolveInputOverrides(\n options.inputs,\n inputs,\n innerContext?.inputs,\n ) as any,\n [ctxParamsSymbol as any]: innerContext?.params,\n }) as Iterable<any>,\n 'original extension factory',\n options.output,\n );\n },\n {\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n },\n );\n\n if (\n typeof parentResult !== 'object' ||\n !parentResult?.[Symbol.iterator]\n ) {\n throw new Error(\n 'extension factory override did not provide an iterable object',\n );\n }\n\n const deduplicatedResult = new Map<\n string,\n ExtensionDataValue<any, any>\n >();\n for (const item of parentResult) {\n deduplicatedResult.set(item.id, item);\n }\n\n return deduplicatedResult.values();\n },\n }) as OverridableExtensionDefinition<any>;\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;AA2CO,MAAM,eAAA,0BAAyB,QAAQ;AA2T9C,SAAS,UAAA,CACP,MAAA,EACA,IAAA,EACA,IAAA,EACA;AACA,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,OAAO,MAAA,CAAO,WAAA;AAAA,IACZ,MAAA,CAAO,QAAQ,MAAM,CAAA,CAAE,IAAI,CAAC,CAAC,SAAA,EAAW,KAAK,CAAA,KAAM;AAAA,MACjD,SAAA;AAAA,MACA,oBAAA,CAAqB,UAAA,CAAW,KAAK,CAAA,CAAE,WAAA,GAAc;AAAA,QACnD,IAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA,EAAO;AAAA,OACR,CAAA,IAAK;AAAA,KACP;AAAA,GACH;AACF;AAqCO,SAAS,gBASd,OAAA,EAkCC;AACD,EAAA,MAAM,iBAAA,GAAoB,QAAQ,MAAA,EAAQ,MAAA;AAC1C,EAAA,MAAM,eACJ,iBAAA,IACA,mBAAA;AAAA,IAAoB,YAClB,MAAA,CAAO,MAAA;AAAA,MACL,MAAA,CAAO,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AAmB,GAAA,CAAI,IAAA,CAAK,EAAA,EAAI,IAAI,CAAA;AAAA,UACtC;AAEA,UAAA,OAAO,mBAAmB,MAAA,EAAO;AAAA,QACnC;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"createExtension.esm.js","sources":["../../src/wiring/createExtension.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiHolder, AppNode } from '../apis';\nimport { Expand } from '@backstage/types';\nimport {\n ResolvedInputValueOverrides,\n resolveInputOverrides,\n} from './resolveInputOverrides';\nimport {\n createExtensionDataContainer,\n OpaqueExtensionInput,\n} from '@internal/frontend';\nimport { ExtensionDataRef, ExtensionDataValue } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport type { z } from 'zod';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\nimport { OpaqueExtensionDefinition } from '@internal/frontend';\nimport { ExtensionDataContainer } from './types';\nimport {\n ExtensionBlueprint,\n ExtensionBlueprintDefineParams,\n} from './createExtensionBlueprint';\nimport { FrontendPlugin } from './createFrontendPlugin';\nimport { FrontendModule } from './createFrontendModule';\n\n/**\n * This symbol is used to pass parameter overrides from the extension override to the blueprint factory\n * @internal\n */\nexport const ctxParamsSymbol = Symbol('params');\n\n/**\n * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<TExtensionInput extends ExtensionInput> =\n TExtensionInput['extensionData'] extends Array<ExtensionDataRef>\n ? {\n node: AppNode;\n } & ExtensionDataContainer<TExtensionInput['extensionData'][number]>\n : never;\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends {\n [name in string]: ExtensionInput;\n },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]>>\n : Expand<ResolvedExtensionInput<TInputs[InputName]> | undefined>;\n};\n\ntype ToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\ntype PopUnion<U> = ToIntersection<\n U extends any ? () => U : never\n> extends () => infer R\n ? [rest: Exclude<U, R>, next: R]\n : undefined;\n\n/** @ignore */\ntype JoinStringUnion<\n U,\n TDiv extends string = ', ',\n TResult extends string = '',\n> = PopUnion<U> extends [infer IRest extends string, infer INext extends string]\n ? TResult extends ''\n ? JoinStringUnion<IRest, TDiv, INext>\n : JoinStringUnion<IRest, TDiv, `${TResult}${TDiv}${INext}`>\n : TResult;\n\n/** @ignore */\nexport type RequiredExtensionIds<UExtensionData extends ExtensionDataRef> =\n UExtensionData extends any\n ? UExtensionData['config']['optional'] extends true\n ? never\n : UExtensionData['id']\n : never;\n\n/** @ignore */\nexport type VerifyExtensionFactoryOutput<\n UDeclaredOutput extends ExtensionDataRef,\n UFactoryOutput extends ExtensionDataValue<any, any>,\n> = [RequiredExtensionIds<UDeclaredOutput>] extends [UFactoryOutput['id']]\n ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']]\n ? {}\n : `Error: The extension factory has undeclared output(s): ${JoinStringUnion<\n Exclude<UFactoryOutput['id'], UDeclaredOutput['id']>\n >}`\n : `Error: The extension factory is missing the following output(s): ${JoinStringUnion<\n Exclude<RequiredExtensionIds<UDeclaredOutput>, UFactoryOutput['id']>\n >}`;\n\n/** @ignore */\nexport type VerifyExtensionAttachTo<\n UOutput extends ExtensionDataRef,\n UParentInput extends ExtensionDataRef,\n> = ExtensionDataRef extends UParentInput\n ? {}\n : [RequiredExtensionIds<UParentInput>] extends [RequiredExtensionIds<UOutput>]\n ? {}\n : `Error: This parent extension input requires the following extension data, but it is not declared as guaranteed output of this extension: ${JoinStringUnion<\n Exclude<RequiredExtensionIds<UParentInput>, RequiredExtensionIds<UOutput>>\n >}`;\n\n/**\n * Specifies where an extension should attach in the extension tree.\n *\n * @remarks\n *\n * A standard attachment point declaration will specify the ID of the parent extension, as well as the name of the input to attach to.\n *\n * There are three more advanced forms that are available for more complex use-cases:\n *\n * 1. Relative attachment points: using the `relative` property instead of `id`, the attachment point is resolved relative to the current plugin.\n * 2. Extension input references: using a reference in code to another extension's input in the same plugin. These references are always relative.\n * 3. Array of attachment points: an array of attachment points can be used to clone and attach to multiple extensions at once.\n *\n * @example\n * ```ts\n * // Attach to a specific extension by full ID\n * { id: 'app/routes', input: 'routes' }\n *\n * // Attach to an extension in the same plugin by kind\n * { relative: { kind: 'page' }, input: 'actions' }\n *\n * // Attach to a specific input of another extension\n * const page = ParentBlueprint.make({ ... });\n * const child = ChildBlueprint.make({ attachTo: page.inputs.children });\n *\n * // Attach to multiple parents at once (deprecated - use Utility APIs instead)\n * [\n * { id: 'page/home', input: 'widgets' },\n * { relative: { kind: 'page' }, input: 'widgets' },\n * ]\n * ```\n *\n * @public\n */\nexport type ExtensionDefinitionAttachTo<\n UParentInputs extends ExtensionDataRef = ExtensionDataRef,\n> =\n | { id: string; input: string; relative?: never }\n | { relative: { kind?: string; name?: string }; input: string; id?: never }\n | ExtensionInput<UParentInputs>\n /**\n * @deprecated Multiple attachment points are deprecated and will be removed in a future release. Use a Utility API instead to share functionality across multiple locations. See https://backstage.io/docs/frontend-system/architecture/27-sharing-extensions for migration guidance.\n */\n | Array<\n | { id: string; input: string; relative?: never }\n | {\n relative: { kind?: string; name?: string };\n input: string;\n id?: never;\n }\n | ExtensionInput<UParentInputs>\n >;\n\n/** @public */\nexport type CreateExtensionOptions<\n TKind extends string | undefined,\n TName extends string | undefined,\n UOutput extends ExtensionDataRef,\n TInputs extends { [inputName in string]: ExtensionInput },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n UParentInputs extends ExtensionDataRef,\n> = {\n kind?: TKind;\n name?: TName;\n attachTo: ExtensionDefinitionAttachTo<UParentInputs> &\n VerifyExtensionAttachTo<UOutput, UParentInputs>;\n disabled?: boolean;\n inputs?: TInputs;\n output: Array<UOutput>;\n config?: {\n schema: TConfigSchema;\n };\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }): Iterable<UFactoryOutput>;\n} & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;\n\n/** @public */\nexport type ExtensionDefinitionParameters = {\n kind?: string;\n name?: string;\n configInput?: { [K in string]: any };\n config?: { [K in string]: any };\n output?: ExtensionDataRef;\n inputs?: { [KName in string]: ExtensionInput };\n params?: object | ExtensionBlueprintDefineParams;\n};\n\n/**\n * Same as the one in `createExtensionBlueprint`, but with `ParamsFactory` inlined.\n * It can't be exported because it breaks API reports.\n * @ignore\n */\ntype AnyParamsInput<TParams extends object | ExtensionBlueprintDefineParams> =\n TParams extends ExtensionBlueprintDefineParams<infer IParams>\n ? IParams | ((define: TParams) => ReturnType<TParams>)\n :\n | TParams\n | ((\n define: ExtensionBlueprintDefineParams<TParams, TParams>,\n ) => ReturnType<ExtensionBlueprintDefineParams<TParams, TParams>>);\n\n/** @public */\nexport interface ExtensionDefinition<\n TParams extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> {\n $$type: '@backstage/ExtensionDefinition';\n readonly T: TParams;\n}\n\n/** @public */\nexport interface OverridableExtensionDefinition<\n T extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> extends ExtensionDefinition<T> {\n /**\n * References to the inputs of this extension, which can be used to attach child extensions.\n */\n readonly inputs: {\n [K in keyof T['inputs']]: ExtensionInput<\n T['inputs'][K] extends ExtensionInput<infer IData> ? IData : never\n >;\n };\n\n override<\n TExtensionConfigSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n UNewOutput extends ExtensionDataRef,\n TExtraInputs extends { [inputName in string]: ExtensionInput },\n TParamsInput extends AnyParamsInput<NonNullable<T['params']>>,\n UParentInputs extends ExtensionDataRef,\n >(\n args: Expand<\n {\n attachTo?: ExtensionDefinitionAttachTo<UParentInputs> &\n VerifyExtensionAttachTo<\n ExtensionDataRef extends UNewOutput\n ? NonNullable<T['output']>\n : UNewOutput,\n UParentInputs\n >;\n disabled?: boolean;\n inputs?: TExtraInputs & {\n [KName in keyof T['inputs']]?: `Error: Input '${KName &\n string}' is already defined in parent definition`;\n };\n output?: Array<UNewOutput>;\n config?: {\n schema: TExtensionConfigSchema & {\n [KName in keyof T['config']]?: `Error: Config key '${KName &\n string}' is already defined in parent schema`;\n };\n };\n factory?(\n originalFactory: <\n TFactoryParamsReturn extends AnyParamsInput<\n NonNullable<T['params']>\n >,\n >(\n context?: Expand<\n {\n config?: T['config'];\n inputs?: ResolvedInputValueOverrides<NonNullable<T['inputs']>>;\n } & ([T['params']] extends [never]\n ? {}\n : {\n params?: TFactoryParamsReturn extends ExtensionBlueprintDefineParams\n ? TFactoryParamsReturn\n : T['params'] extends ExtensionBlueprintDefineParams\n ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams(<params>))`'\n : Partial<T['params']>;\n })\n >,\n ) => ExtensionDataContainer<NonNullable<T['output']>>,\n context: {\n node: AppNode;\n apis: ApiHolder;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n inputs: Expand<ResolvedExtensionInputs<T['inputs'] & TExtraInputs>>;\n },\n ): Iterable<UFactoryOutput>;\n } & ([T['params']] extends [never]\n ? {}\n : {\n params?: TParamsInput extends ExtensionBlueprintDefineParams\n ? TParamsInput\n : T['params'] extends ExtensionBlueprintDefineParams\n ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams(<params>))`'\n : Partial<T['params']>;\n })\n > &\n VerifyExtensionFactoryOutput<\n ExtensionDataRef extends UNewOutput\n ? NonNullable<T['output']>\n : UNewOutput,\n UFactoryOutput\n >,\n ): OverridableExtensionDefinition<{\n kind: T['kind'];\n name: T['name'];\n output: ExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput;\n inputs: T['inputs'] & TExtraInputs;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n configInput: T['configInput'] &\n z.input<\n z.ZodObject<{\n [key in keyof TExtensionConfigSchema]: ReturnType<\n TExtensionConfigSchema[key]\n >;\n }>\n >;\n }>;\n}\n\n/**\n * @internal\n */\nfunction bindInputs(\n inputs: { [inputName in string]: ExtensionInput } | undefined,\n kind?: string,\n name?: string,\n) {\n if (!inputs) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(inputs).map(([inputName, input]) => [\n inputName,\n OpaqueExtensionInput.toInternal(input).withContext?.({\n kind,\n name,\n input: inputName,\n }) ?? input,\n ]),\n );\n}\n\n/**\n * Creates a new extension definition for installation in a Backstage app.\n *\n * @remarks\n *\n * This is a low-level function for creation of extensions with arbitrary inputs\n * and outputs and is typically only intended to be used for advanced overrides\n * or framework-level extensions. For most extension creation needs, it is\n * recommended to use existing {@link ExtensionBlueprint}s instead. You can find\n * blueprints both in the `@backstage/frontend-plugin-api` package as well as\n * other plugin libraries. There is also a list of\n * {@link https://backstage.io/docs/frontend-system/building-plugins/common-extension-blueprints | commonly used blueprints}\n * in the frontend system documentation.\n *\n * Extension definitions that are created with this function can be installed in\n * a Backstage app via a {@link FrontendPlugin} or {@link FrontendModule}.\n *\n * For more details on how extensions work, see the\n * {@link https://backstage.io/docs/frontend-system/architecture/extensions | documentation for extensions}.\n *\n * @example\n *\n * ```ts\n * const myExtension = createExtension({\n * name: 'example',\n * attachTo: { id: 'app', input: 'root' },\n * output: [coreExtensionData.reactElement],\n * factory() {\n * return [coreExtensionData.reactElement(<h1>Hello, world!</h1>)];\n * },\n * });\n * ```\n *\n * @public\n */\nexport function createExtension<\n UOutput extends ExtensionDataRef,\n TInputs extends { [inputName in string]: ExtensionInput },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n const TKind extends string | undefined = undefined,\n const TName extends string | undefined = undefined,\n UParentInputs extends ExtensionDataRef = ExtensionDataRef,\n>(\n options: CreateExtensionOptions<\n TKind,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput,\n UParentInputs\n >,\n): OverridableExtensionDefinition<{\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n // This inference and remapping back to ExtensionDataRef eliminates any occurrences ConfigurationExtensionDataRef\n output: UOutput extends ExtensionDataRef<\n infer IData,\n infer IId,\n infer IConfig\n >\n ? ExtensionDataRef<IData, IId, IConfig>\n : never;\n inputs: TInputs;\n params: never;\n kind: string | undefined extends TKind ? undefined : TKind;\n name: string | undefined extends TName ? undefined : TName;\n}> {\n const schemaDeclaration = options.config?.schema;\n const configSchema =\n schemaDeclaration &&\n createSchemaFromZod(innerZ =>\n innerZ.object(\n Object.fromEntries(\n Object.entries(schemaDeclaration).map(([k, v]) => [k, v(innerZ)]),\n ),\n ),\n );\n\n return OpaqueExtensionDefinition.createInstance('v2', {\n T: undefined as unknown as {\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<\n ReturnType<TConfigSchema[key]>\n >;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n name: string | undefined extends TName ? undefined : TName;\n },\n kind: options.kind,\n name: options.name,\n attachTo: options.attachTo,\n disabled: options.disabled ?? false,\n inputs: bindInputs(options.inputs, options.kind, options.name),\n output: options.output,\n configSchema,\n factory: options.factory,\n toString() {\n const parts: string[] = [];\n if (options.kind) {\n parts.push(`kind=${options.kind}`);\n }\n if (options.name) {\n parts.push(`name=${options.name}`);\n }\n const attachTo = [options.attachTo]\n .flat()\n .map(aAny => {\n const a = aAny as ExtensionDefinitionAttachTo;\n if (OpaqueExtensionInput.isType(a)) {\n const { context } = OpaqueExtensionInput.toInternal(a);\n if (!context) {\n return '<detached-input>';\n }\n let id = '<plugin>';\n if (context?.kind) {\n id = `${context?.kind}:${id}`;\n }\n if (context?.name) {\n id = `${id}/${context?.name}`;\n }\n return `${id}@${context.input}`;\n }\n if ('relative' in a && a.relative) {\n let id = '<plugin>';\n if (a.relative.kind) {\n id = `${a.relative.kind}:${id}`;\n }\n if (a.relative.name) {\n id = `${id}/${a.relative.name}`;\n }\n return `${id}@${a.input}`;\n }\n if ('id' in a) {\n return `${a.id}@${a.input}`;\n }\n throw new Error('Invalid attachment point specification');\n })\n .join('+');\n parts.push(`attachTo=${attachTo}`);\n return `ExtensionDefinition{${parts.join(',')}}`;\n },\n override(overrideOptions) {\n if (!Array.isArray(options.output)) {\n throw new Error(\n 'Cannot override an extension that is not declared using the new format with outputs as an array',\n );\n }\n\n // TODO(Rugvip): Making this a type check would be optimal, but it seems\n // like it's tricky to add that and still have the type\n // inference work correctly for the factory output.\n if (overrideOptions.output && !overrideOptions.factory) {\n throw new Error(\n 'Refused to override output without also overriding factory',\n );\n }\n // TODO(Rugvip): Similar to above, would be nice to error during type checking, but don't want to complicate the types too much\n if (overrideOptions.params && overrideOptions.factory) {\n throw new Error(\n 'Refused to override params and factory at the same time',\n );\n }\n\n return createExtension({\n kind: options.kind,\n name: options.name,\n attachTo: (overrideOptions.attachTo ??\n options.attachTo) as ExtensionDefinitionAttachTo,\n disabled: overrideOptions.disabled ?? options.disabled,\n inputs: bindInputs(\n {\n ...(options.inputs ?? {}),\n ...(overrideOptions.inputs ?? {}),\n },\n options.kind,\n options.name,\n ),\n output: (overrideOptions.output ??\n options.output) as ExtensionDataRef[],\n config:\n options.config || overrideOptions.config\n ? {\n schema: {\n ...options.config?.schema,\n ...overrideOptions.config?.schema,\n },\n }\n : undefined,\n factory: ({ node, apis, config, inputs }) => {\n if (!overrideOptions.factory) {\n return options.factory({\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n [ctxParamsSymbol as any]: overrideOptions.params,\n });\n }\n const parentResult = overrideOptions.factory(\n (innerContext): ExtensionDataContainer<UOutput> => {\n return createExtensionDataContainer<UOutput>(\n options.factory({\n node,\n apis,\n config: (innerContext?.config ?? config) as any,\n inputs: resolveInputOverrides(\n options.inputs,\n inputs,\n innerContext?.inputs,\n ) as any,\n [ctxParamsSymbol as any]: innerContext?.params,\n }) as Iterable<any>,\n 'original extension factory',\n options.output,\n );\n },\n {\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n },\n );\n\n if (\n typeof parentResult !== 'object' ||\n !parentResult?.[Symbol.iterator]\n ) {\n throw new Error(\n 'extension factory override did not provide an iterable object',\n );\n }\n\n const deduplicatedResult = new Map<\n string,\n ExtensionDataValue<any, any>\n >();\n for (const item of parentResult) {\n deduplicatedResult.set(item.id, item);\n }\n\n return deduplicatedResult.values();\n },\n }) as OverridableExtensionDefinition<any>;\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;AA2CO,MAAM,eAAA,0BAAyB,QAAQ;AA8T9C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AS,cAAc,MAAA,IAAU,MAAA;AAAA,kBACjC,MAAA,EAAQ,qBAAA;AAAA,oBACN,OAAA,CAAQ,MAAA;AAAA,oBACR,MAAA;AAAA,oBACA,YAAA,EAAc;AAAA,mBAChB;AAAA,kBACA,CAAC,eAAsB,GAAG,YAAA,EAAc;AAAA,iBACzC,CAAA;AAAA,gBACD,4BAAA;AAAA,gBACA,OAAA,CAAQ;AAAA,eACV;AAAA,YACF,CAAA;AAAA,YACA;AAAA,cACE,IAAA;AAAA,cACA,IAAA;AAAA,cACA,MAAA;AAAA,cACA;AAAA;AACF,WACF;AAEA,UAAA,IACE,OAAO,YAAA,KAAiB,QAAA,IACxB,CAAC,YAAA,GAAe,MAAA,CAAO,QAAQ,CAAA,EAC/B;AACA,YAAA,MAAM,IAAI,KAAA;AAAA,cACR;AAAA,aACF;AAAA,UACF;AAEA,UAAA,MAAM,kBAAA,uBAAyB,GAAA,EAG7B;AACF,UAAA,KAAA,MAAW,QAAQ,YAAA,EAAc;AAC/B,YAAA,kBAAA,CAAmB,GAAA,CAAI,IAAA,CAAK,EAAA,EAAI,IAAI,CAAA;AAAA,UACtC;AAEA,UAAA,OAAO,mBAAmB,MAAA,EAAO;AAAA,QACnC;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -25,7 +25,8 @@ function createExtensionInput(extensionData, config) {
|
|
|
25
25
|
extensionData,
|
|
26
26
|
config: {
|
|
27
27
|
singleton: Boolean(config?.singleton),
|
|
28
|
-
optional: Boolean(config?.optional)
|
|
28
|
+
optional: Boolean(config?.optional),
|
|
29
|
+
internal: Boolean(config?.internal)
|
|
29
30
|
},
|
|
30
31
|
replaces: config?.replaces
|
|
31
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtensionInput.esm.js","sources":["../../src/wiring/createExtensionInput.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ExtensionInputContext,\n OpaqueExtensionInput,\n} from '@internal/frontend';\nimport { ExtensionDataRef } from './createExtensionDataRef';\n\n/** @public */\nexport interface ExtensionInput<\n UExtensionData extends ExtensionDataRef<\n unknown,\n string,\n { optional?: true }\n > = ExtensionDataRef,\n TConfig extends {
|
|
1
|
+
{"version":3,"file":"createExtensionInput.esm.js","sources":["../../src/wiring/createExtensionInput.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ExtensionInputContext,\n OpaqueExtensionInput,\n} from '@internal/frontend';\nimport { ExtensionDataRef } from './createExtensionDataRef';\n\n/** @public */\nexport interface ExtensionInput<\n UExtensionData extends ExtensionDataRef<\n unknown,\n string,\n { optional?: true }\n > = ExtensionDataRef,\n TConfig extends {\n singleton: boolean;\n optional: boolean;\n internal?: boolean;\n } = {\n singleton: boolean;\n optional: boolean;\n internal?: boolean;\n },\n> {\n readonly $$type: '@backstage/ExtensionInput';\n readonly extensionData: Array<UExtensionData>;\n readonly config: TConfig;\n readonly replaces?: Array<{ id: string; input: string }>;\n}\n\n/**\n * Creates a new extension input to be passed to the input map of an extension.\n *\n * @remarks\n *\n * Extension inputs created with this function can be passed to any `inputs` map\n * as part of creating or overriding an extension.\n *\n * The array of extension data references defines the data this input expects.\n * If the required data is not provided by the attached extension, the\n * attachment will fail.\n *\n * The `config` object can be used to restrict the behavior and shape of the\n * input. By default an input will accept zero or more extensions from any\n * plugin. The following options are available:\n *\n * - `singleton`: If set to `true`, only one extension can be attached to the\n * input at a time. Additional extensions will trigger an app error and be\n * ignored.\n * - `optional`: If set to `true`, the input is optional and can be omitted,\n * this only has an effect if the `singleton` is set to `true`.\n * - `internal`: If set to `true`, only extensions from the same plugin will be\n * allowed to attach to this input. Other extensions will trigger an app error\n * and be ignored.\n *\n * @param extensionData - The array of extension data references that this input\n * expects.\n * @param config - The configuration object for the input.\n * @returns An extension input declaration.\n * @example\n * ```ts\n * const extension = createExtension({\n * attachTo: { id: 'example-parent', input: 'example-input' },\n * inputs: {\n * content: createExtensionInput([coreExtensionData.reactElement], {\n * singleton: true,\n * }),\n * },\n * output: [coreExtensionData.reactElement],\n * *factory({ inputs }) {\n * const content = inputs.content?.get(coreExtensionData.reactElement);\n * yield coreExtensionData.reactElement(<ContentWrapper>{content}</ContentWrapper>);\n * },\n * });\n * ```\n * @public\n */\nexport function createExtensionInput<\n UExtensionData extends ExtensionDataRef<unknown, string, { optional?: true }>,\n TConfig extends {\n singleton?: boolean;\n optional?: boolean;\n internal?: boolean;\n },\n>(\n extensionData: Array<UExtensionData>,\n config?: TConfig & { replaces?: Array<{ id: string; input: string }> },\n): ExtensionInput<\n UExtensionData,\n {\n singleton: TConfig['singleton'] extends true ? true : false;\n optional: TConfig['optional'] extends true ? true : false;\n internal: TConfig['internal'] extends true ? true : false;\n }\n> {\n if (process.env.NODE_ENV !== 'production') {\n if (Array.isArray(extensionData)) {\n const seen = new Set();\n const duplicates = [];\n for (const dataRef of extensionData) {\n if (seen.has(dataRef.id)) {\n duplicates.push(dataRef.id);\n } else {\n seen.add(dataRef.id);\n }\n }\n if (duplicates.length > 0) {\n throw new Error(\n `ExtensionInput may not have duplicate data refs: '${duplicates.join(\n \"', '\",\n )}'`,\n );\n }\n }\n }\n const baseOptions = {\n extensionData,\n config: {\n singleton: Boolean(config?.singleton) as TConfig['singleton'] extends true\n ? true\n : false,\n optional: Boolean(config?.optional) as TConfig['optional'] extends true\n ? true\n : false,\n internal: Boolean(config?.internal) as TConfig['internal'] extends true\n ? true\n : false,\n },\n replaces: config?.replaces,\n };\n\n function createInstance(parent?: ExtensionInputContext): ExtensionInput<\n UExtensionData,\n {\n singleton: TConfig['singleton'] extends true ? true : false;\n optional: TConfig['optional'] extends true ? true : false;\n internal: TConfig['internal'] extends true ? true : false;\n }\n > {\n return OpaqueExtensionInput.createInstance(undefined, {\n ...baseOptions,\n context: parent,\n withContext: createInstance,\n });\n }\n\n return createInstance();\n}\n"],"names":[],"mappings":";;AA4FO,SAAS,oBAAA,CAQd,eACA,MAAA,EAQA;AACA,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AACzC,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,aAAa,CAAA,EAAG;AAChC,MAAA,MAAM,IAAA,uBAAW,GAAA,EAAI;AACrB,MAAA,MAAM,aAAa,EAAC;AACpB,MAAA,KAAA,MAAW,WAAW,aAAA,EAAe;AACnC,QAAA,IAAI,IAAA,CAAK,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA,EAAG;AACxB,UAAA,UAAA,CAAW,IAAA,CAAK,QAAQ,EAAE,CAAA;AAAA,QAC5B,CAAA,MAAO;AACL,UAAA,IAAA,CAAK,GAAA,CAAI,QAAQ,EAAE,CAAA;AAAA,QACrB;AAAA,MACF;AACA,MAAA,IAAI,UAAA,CAAW,SAAS,CAAA,EAAG;AACzB,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,qDAAqD,UAAA,CAAW,IAAA;AAAA,YAC9D;AAAA,WACD,CAAA,CAAA;AAAA,SACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,MAAM,WAAA,GAAc;AAAA,IAClB,aAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,SAAA,EAAW,OAAA,CAAQ,MAAA,EAAQ,SAAS,CAAA;AAAA,MAGpC,QAAA,EAAU,OAAA,CAAQ,MAAA,EAAQ,QAAQ,CAAA;AAAA,MAGlC,QAAA,EAAU,OAAA,CAAQ,MAAA,EAAQ,QAAQ;AAAA,KAGpC;AAAA,IACA,UAAU,MAAA,EAAQ;AAAA,GACpB;AAEA,EAAA,SAAS,eAAe,MAAA,EAOtB;AACA,IAAA,OAAO,oBAAA,CAAqB,eAAe,MAAA,EAAW;AAAA,MACpD,GAAG,WAAA;AAAA,MACH,OAAA,EAAS,MAAA;AAAA,MACT,WAAA,EAAa;AAAA,KACd,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,cAAA,EAAe;AACxB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFrontendPlugin.esm.js","sources":["../../src/wiring/createFrontendPlugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n OpaqueExtensionDefinition,\n OpaqueFrontendPlugin,\n} from '@internal/frontend';\nimport {\n ExtensionDefinition,\n OverridableExtensionDefinition,\n} from './createExtension';\nimport {\n Extension,\n resolveExtensionDefinition,\n} from './resolveExtensionDefinition';\nimport { FeatureFlagConfig } from './types';\nimport { MakeSortedExtensionsMap } from './MakeSortedExtensionsMap';\nimport { JsonObject } from '@backstage/types';\nimport { RouteRef, SubRouteRef, ExternalRouteRef } from '../routing';\n\n/**\n * Information about the plugin.\n *\n * @public\n * @remarks\n *\n * This interface is intended to be extended via [module\n * augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)\n * in order to add fields that are specific to each project.\n *\n * For example, one might add a `slackChannel` field that is read from the\n * opaque manifest file.\n *\n * See the options for `createApp` for more information about how to\n * customize the parsing of manifest files.\n */\nexport interface FrontendPluginInfo {\n /**\n * The name of the package that implements the plugin.\n */\n packageName?: string;\n\n /**\n * The version of the plugin, typically the version of the package.json file.\n */\n version?: string;\n\n /**\n * As short description of the plugin, typically the description field in\n * package.json.\n */\n description?: string;\n\n /**\n * The owner entity references of the plugin.\n */\n ownerEntityRefs?: string[];\n\n /**\n * Links related to the plugin.\n */\n links?: Array<{ title: string; url: string }>;\n}\n\n/**\n * Options for providing information for a plugin.\n *\n * @public\n */\nexport type FrontendPluginInfoOptions = {\n /**\n * A loader function for the package.json file for the plugin.\n */\n packageJson?: () => Promise<{ name: string } & JsonObject>;\n /**\n * A loader function for an opaque manifest file for the plugin.\n */\n manifest?: () => Promise<JsonObject>;\n};\n\n/**\n * A variant of the {@link FrontendPlugin} interface that can also be used to install overrides for the plugin.\n *\n * @public\n */\nexport interface OverridableFrontendPlugin<\n TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {\n [name in string]: RouteRef | SubRouteRef;\n },\n TExternalRoutes extends { [name in string]: ExternalRouteRef } = {\n [name in string]: ExternalRouteRef;\n },\n TExtensionMap extends { [id in string]: ExtensionDefinition } = {\n [id in string]: ExtensionDefinition;\n },\n> extends FrontendPlugin<TRoutes, TExternalRoutes> {\n getExtension<TId extends keyof TExtensionMap>(\n id: TId,\n ): OverridableExtensionDefinition<TExtensionMap[TId]['T']>;\n withOverrides(options: {\n extensions: Array<ExtensionDefinition>;\n\n /**\n * Overrides the original info loaders of the plugin one by one.\n */\n info?: FrontendPluginInfoOptions;\n }): OverridableFrontendPlugin<TRoutes, TExternalRoutes, TExtensionMap>;\n}\n\n/** @public */\nexport interface FrontendPlugin<\n TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {\n [name in string]: RouteRef | SubRouteRef;\n },\n TExternalRoutes extends { [name in string]: ExternalRouteRef } = {\n [name in string]: ExternalRouteRef;\n },\n> {\n readonly $$type: '@backstage/FrontendPlugin';\n readonly id: string;\n readonly routes: TRoutes;\n readonly externalRoutes: TExternalRoutes;\n\n /**\n * Loads the plugin info.\n */\n info(): Promise<FrontendPluginInfo>;\n}\n\n/** @public */\nexport interface PluginOptions<\n TId extends string,\n TRoutes extends { [name in string]: RouteRef | SubRouteRef },\n TExternalRoutes extends { [name in string]: ExternalRouteRef },\n TExtensions extends readonly ExtensionDefinition[],\n> {\n pluginId: TId;\n routes?: TRoutes;\n externalRoutes?: TExternalRoutes;\n extensions?: TExtensions;\n featureFlags?: FeatureFlagConfig[];\n info?: FrontendPluginInfoOptions;\n}\n\n/**\n * Creates a new plugin that can be installed in a Backstage app.\n *\n * @remarks\n *\n * Every plugin is created with a unique ID and a set of extensions\n * that are installed as part of the plugin.\n *\n * For more information on how plugins work, see the\n * {@link https://backstage.io/docs/frontend-system/building-plugins/index | documentation for plugins}\n * in the frontend system documentation.\n *\n * @example\n *\n * ```tsx\n * import { createFrontendPlugin } from '@backstage/frontend-plugin-api';\n *\n * export const examplePlugin = createFrontendPlugin({\n * pluginId: 'example',\n * extensions: [\n * PageBlueprint.make({\n * path: '/example',\n * loader: () => import('./ExamplePage').then(m => <m.ExamplePage />),\n * }),\n * ],\n * });\n * ```\n *\n * @public\n */\nexport function createFrontendPlugin<\n TId extends string,\n TExtensions extends readonly ExtensionDefinition[],\n TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {},\n TExternalRoutes extends { [name in string]: ExternalRouteRef } = {},\n>(\n options: PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>,\n): OverridableFrontendPlugin<\n TRoutes,\n TExternalRoutes,\n MakeSortedExtensionsMap<TExtensions[number], TId>\n> {\n const pluginId = options.pluginId;\n\n const extensions = new Array<Extension<any>>();\n const extensionDefinitionsById = new Map<\n string,\n typeof OpaqueExtensionDefinition.TInternal\n >();\n\n for (const def of options.extensions ?? []) {\n const internal = OpaqueExtensionDefinition.toInternal(def);\n const ext = resolveExtensionDefinition(def, { namespace: pluginId });\n extensions.push(ext);\n extensionDefinitionsById.set(ext.id, {\n ...internal,\n namespace: pluginId,\n });\n }\n\n if (extensions.length !== extensionDefinitionsById.size) {\n const extensionIds = extensions.map(e => e.id);\n const duplicates = Array.from(\n new Set(\n extensionIds.filter((id, index) => extensionIds.indexOf(id) !== index),\n ),\n );\n // TODO(Rugvip): This could provide some more information about the kind + name of the extensions\n throw new Error(\n `Plugin '${pluginId}' provided duplicate extensions: ${duplicates.join(\n ', ',\n )}`,\n );\n }\n\n return OpaqueFrontendPlugin.createInstance('v1', {\n id: pluginId,\n routes: options.routes ?? ({} as TRoutes),\n externalRoutes: options.externalRoutes ?? ({} as TExternalRoutes),\n featureFlags: options.featureFlags ?? [],\n extensions: extensions,\n infoOptions: options.info,\n\n // This method is overridden when the plugin instance is installed in an app\n async info() {\n throw new Error(\n `Attempted to load plugin info for plugin '${pluginId}', but the plugin instance is not installed in an app`,\n );\n },\n getExtension(id) {\n const ext = extensionDefinitionsById.get(id);\n if (!ext) {\n throw new Error(\n `Attempted to get non-existent extension '${id}' from plugin '${pluginId}'`,\n );\n }\n return ext;\n },\n toString() {\n return `Plugin{id=${pluginId}}`;\n },\n withOverrides(overrides) {\n const overriddenExtensionIds = new Set(\n overrides.extensions.map(\n e => resolveExtensionDefinition(e, { namespace: pluginId }).id,\n ),\n );\n const nonOverriddenExtensions = (options.extensions ?? []).filter(\n e =>\n !overriddenExtensionIds.has(\n resolveExtensionDefinition(e, { namespace: pluginId }).id,\n ),\n );\n return createFrontendPlugin({\n ...options,\n pluginId,\n extensions: [...nonOverriddenExtensions, ...overrides.extensions],\n info: {\n ...options.info,\n ...overrides.info,\n },\n });\n },\n });\n}\n"],"names":[],"mappings":";;;;;;AA2LO,SAAS,qBAMd,OAAA,EAKA;AACA,EAAA,MAAM,W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,UACJ,GAAG,OAAA,CAAQ,IAAA;AAAA,UACX,GAAG,SAAA,CAAU;AAAA;AACf,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"createFrontendPlugin.esm.js","sources":["../../src/wiring/createFrontendPlugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n OpaqueExtensionDefinition,\n OpaqueFrontendPlugin,\n} from '@internal/frontend';\nimport {\n ExtensionDefinition,\n OverridableExtensionDefinition,\n} from './createExtension';\nimport {\n Extension,\n resolveExtensionDefinition,\n} from './resolveExtensionDefinition';\nimport { FeatureFlagConfig } from './types';\nimport { MakeSortedExtensionsMap } from './MakeSortedExtensionsMap';\nimport { JsonObject } from '@backstage/types';\nimport { RouteRef, SubRouteRef, ExternalRouteRef } from '../routing';\n\n/**\n * Information about the plugin.\n *\n * @public\n * @remarks\n *\n * This interface is intended to be extended via [module\n * augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)\n * in order to add fields that are specific to each project.\n *\n * For example, one might add a `slackChannel` field that is read from the\n * opaque manifest file.\n *\n * See the options for `createApp` for more information about how to\n * customize the parsing of manifest files.\n */\nexport interface FrontendPluginInfo {\n /**\n * The name of the package that implements the plugin.\n */\n packageName?: string;\n\n /**\n * The version of the plugin, typically the version of the package.json file.\n */\n version?: string;\n\n /**\n * As short description of the plugin, typically the description field in\n * package.json.\n */\n description?: string;\n\n /**\n * The owner entity references of the plugin.\n */\n ownerEntityRefs?: string[];\n\n /**\n * Links related to the plugin.\n */\n links?: Array<{ title: string; url: string }>;\n}\n\n/**\n * Options for providing information for a plugin.\n *\n * @public\n */\nexport type FrontendPluginInfoOptions = {\n /**\n * A loader function for the package.json file for the plugin.\n */\n packageJson?: () => Promise<{ name: string } & JsonObject>;\n /**\n * A loader function for an opaque manifest file for the plugin.\n */\n manifest?: () => Promise<JsonObject>;\n};\n\n/**\n * A variant of the {@link FrontendPlugin} interface that can also be used to install overrides for the plugin.\n *\n * @public\n */\nexport interface OverridableFrontendPlugin<\n TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {\n [name in string]: RouteRef | SubRouteRef;\n },\n TExternalRoutes extends { [name in string]: ExternalRouteRef } = {\n [name in string]: ExternalRouteRef;\n },\n TExtensionMap extends { [id in string]: ExtensionDefinition } = {\n [id in string]: ExtensionDefinition;\n },\n> extends FrontendPlugin<TRoutes, TExternalRoutes> {\n getExtension<TId extends keyof TExtensionMap>(\n id: TId,\n ): OverridableExtensionDefinition<TExtensionMap[TId]['T']>;\n withOverrides(options: {\n extensions: Array<ExtensionDefinition>;\n\n /**\n * Overrides the original info loaders of the plugin one by one.\n */\n info?: FrontendPluginInfoOptions;\n }): OverridableFrontendPlugin<TRoutes, TExternalRoutes, TExtensionMap>;\n}\n\n/** @public */\nexport interface FrontendPlugin<\n TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {\n [name in string]: RouteRef | SubRouteRef;\n },\n TExternalRoutes extends { [name in string]: ExternalRouteRef } = {\n [name in string]: ExternalRouteRef;\n },\n> {\n readonly $$type: '@backstage/FrontendPlugin';\n /**\n * The plugin ID.\n */\n readonly pluginId: string;\n /**\n * Deprecated alias for `pluginId`.\n *\n * @deprecated Use `pluginId` instead.\n */\n readonly id: string;\n readonly routes: TRoutes;\n readonly externalRoutes: TExternalRoutes;\n\n /**\n * Loads the plugin info.\n */\n info(): Promise<FrontendPluginInfo>;\n}\n\n/** @public */\nexport interface PluginOptions<\n TId extends string,\n TRoutes extends { [name in string]: RouteRef | SubRouteRef },\n TExternalRoutes extends { [name in string]: ExternalRouteRef },\n TExtensions extends readonly ExtensionDefinition[],\n> {\n pluginId: TId;\n routes?: TRoutes;\n externalRoutes?: TExternalRoutes;\n extensions?: TExtensions;\n featureFlags?: FeatureFlagConfig[];\n info?: FrontendPluginInfoOptions;\n}\n\n/**\n * Creates a new plugin that can be installed in a Backstage app.\n *\n * @remarks\n *\n * Every plugin is created with a unique ID and a set of extensions\n * that are installed as part of the plugin.\n *\n * For more information on how plugins work, see the\n * {@link https://backstage.io/docs/frontend-system/building-plugins/index | documentation for plugins}\n * in the frontend system documentation.\n *\n * @example\n *\n * ```tsx\n * import { createFrontendPlugin } from '@backstage/frontend-plugin-api';\n *\n * export const examplePlugin = createFrontendPlugin({\n * pluginId: 'example',\n * extensions: [\n * PageBlueprint.make({\n * path: '/example',\n * loader: () => import('./ExamplePage').then(m => <m.ExamplePage />),\n * }),\n * ],\n * });\n * ```\n *\n * @public\n */\nexport function createFrontendPlugin<\n TId extends string,\n TExtensions extends readonly ExtensionDefinition[],\n TRoutes extends { [name in string]: RouteRef | SubRouteRef } = {},\n TExternalRoutes extends { [name in string]: ExternalRouteRef } = {},\n>(\n options: PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>,\n): OverridableFrontendPlugin<\n TRoutes,\n TExternalRoutes,\n MakeSortedExtensionsMap<TExtensions[number], TId>\n> {\n const pluginId = options.pluginId;\n\n const extensions = new Array<Extension<any>>();\n const extensionDefinitionsById = new Map<\n string,\n typeof OpaqueExtensionDefinition.TInternal\n >();\n\n for (const def of options.extensions ?? []) {\n const internal = OpaqueExtensionDefinition.toInternal(def);\n const ext = resolveExtensionDefinition(def, { namespace: pluginId });\n extensions.push(ext);\n extensionDefinitionsById.set(ext.id, {\n ...internal,\n namespace: pluginId,\n });\n }\n\n if (extensions.length !== extensionDefinitionsById.size) {\n const extensionIds = extensions.map(e => e.id);\n const duplicates = Array.from(\n new Set(\n extensionIds.filter((id, index) => extensionIds.indexOf(id) !== index),\n ),\n );\n // TODO(Rugvip): This could provide some more information about the kind + name of the extensions\n throw new Error(\n `Plugin '${pluginId}' provided duplicate extensions: ${duplicates.join(\n ', ',\n )}`,\n );\n }\n\n return OpaqueFrontendPlugin.createInstance('v1', {\n pluginId,\n id: pluginId,\n routes: options.routes ?? ({} as TRoutes),\n externalRoutes: options.externalRoutes ?? ({} as TExternalRoutes),\n featureFlags: options.featureFlags ?? [],\n extensions: extensions,\n infoOptions: options.info,\n\n // This method is overridden when the plugin instance is installed in an app\n async info() {\n throw new Error(\n `Attempted to load plugin info for plugin '${pluginId}', but the plugin instance is not installed in an app`,\n );\n },\n getExtension(id) {\n const ext = extensionDefinitionsById.get(id);\n if (!ext) {\n throw new Error(\n `Attempted to get non-existent extension '${id}' from plugin '${pluginId}'`,\n );\n }\n return ext;\n },\n toString() {\n return `Plugin{id=${pluginId}}`;\n },\n withOverrides(overrides) {\n const overriddenExtensionIds = new Set(\n overrides.extensions.map(\n e => resolveExtensionDefinition(e, { namespace: pluginId }).id,\n ),\n );\n const nonOverriddenExtensions = (options.extensions ?? []).filter(\n e =>\n !overriddenExtensionIds.has(\n resolveExtensionDefinition(e, { namespace: pluginId }).id,\n ),\n );\n return createFrontendPlugin({\n ...options,\n pluginId,\n extensions: [...nonOverriddenExtensions, ...overrides.extensions],\n info: {\n ...options.info,\n ...overrides.info,\n },\n });\n },\n });\n}\n"],"names":[],"mappings":";;;;;;AAoMO,SAAS,qBAMd,OAAA,EAKA;AACA,EAAA,MAAM,WAAW,OAAA,CAAQ,QAAA;AAEzB,EAAA,MAAM,UAAA,GAAa,IAAI,KAAA,EAAsB;AAC7C,EAAA,MAAM,wBAAA,uBAA+B,GAAA,EAGnC;AAEF,EAAA,KAAA,MAAW,GAAA,IAAO,OAAA,CAAQ,UAAA,IAAc,EAAC,EAAG;AAC1C,IAAA,MAAM,QAAA,GAAW,yBAAA,CAA0B,UAAA,CAAW,GAAG,CAAA;AACzD,IAAA,MAAM,MAAM,0BAAA,CAA2B,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AM,wBAAA,CAAyB,GAAA,CAAI,EAAE,CAAA;AAC3C,MAAA,IAAI,CAAC,GAAA,EAAK;AACR,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,yCAAA,EAA4C,EAAE,CAAA,eAAA,EAAkB,QAAQ,CAAA,CAAA;AAAA,SAC1E;AAAA,MACF;AACA,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA,QAAA,GAAW;AACT,MAAA,OAAO,aAAa,QAAQ,CAAA,CAAA,CAAA;AAAA,IAC9B,CAAA;AAAA,IACA,cAAc,SAAA,EAAW;AACvB,MAAA,MAAM,yBAAyB,IAAI,GAAA;AAAA,QACjC,UAAU,UAAA,CAAW,GAAA;AAAA,UACnB,OAAK,0BAAA,CAA2B,CAAA,EAAG,EAAE,SAAA,EAAW,QAAA,EAAU,CAAA,CAAE;AAAA;AAC9D,OACF;AACA,MAAA,MAAM,uBAAA,GAAA,CAA2B,OAAA,CAAQ,UAAA,IAAc,EAAC,EAAG,MAAA;AAAA,QACzD,CAAA,CAAA,KACE,CAAC,sBAAA,CAAuB,GAAA;AAAA,UACtB,2BAA2B,CAAA,EAAG,EAAE,SAAA,EAAW,QAAA,EAAU,CAAA,CAAE;AAAA;AACzD,OACJ;AACA,MAAA,OAAO,oBAAA,CAAqB;AAAA,QAC1B,GAAG,OAAA;AAAA,QACH,QAAA;AAAA,QACA,YAAY,CAAC,GAAG,uBAAA,EAAyB,GAAG,UAAU,UAAU,CAAA;AAAA,QAChE,IAAA,EAAM;AAAA,UACJ,GAAG,OAAA,CAAQ,IAAA;AAAA,UACX,GAAG,SAAA,CAAU;AAAA;AACf,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveInputOverrides.esm.js","sources":["../../src/wiring/resolveInputOverrides.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AppNode } from '../apis';\nimport { Expand } from '@backstage/types';\nimport { ResolvedExtensionInput } from './createExtension';\nimport { createExtensionDataContainer } from '@internal/frontend';\nimport {\n ExtensionDataRefToValue,\n ExtensionDataValue,\n} from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport { ExtensionDataContainer } from './types';\n\n/** @ignore */\nexport type ResolvedInputValueOverrides<\n TInputs extends { [inputName in string]: ExtensionInput } = {\n [inputName in string]: ExtensionInput;\n },\n> = Expand<\n {\n [KName in keyof TInputs as TInputs[KName] extends ExtensionInput<\n any,\n {\n optional: infer IOptional extends boolean;\n singleton: boolean;\n }\n >\n ? IOptional extends true\n ? never\n : KName\n : never]: TInputs[KName] extends ExtensionInput<\n infer IDataRefs,\n {
|
|
1
|
+
{"version":3,"file":"resolveInputOverrides.esm.js","sources":["../../src/wiring/resolveInputOverrides.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AppNode } from '../apis';\nimport { Expand } from '@backstage/types';\nimport { ResolvedExtensionInput } from './createExtension';\nimport { createExtensionDataContainer } from '@internal/frontend';\nimport {\n ExtensionDataRefToValue,\n ExtensionDataValue,\n} from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport { ExtensionDataContainer } from './types';\n\n/** @ignore */\nexport type ResolvedInputValueOverrides<\n TInputs extends { [inputName in string]: ExtensionInput } = {\n [inputName in string]: ExtensionInput;\n },\n> = Expand<\n {\n [KName in keyof TInputs as TInputs[KName] extends ExtensionInput<\n any,\n {\n optional: infer IOptional extends boolean;\n singleton: boolean;\n internal?: boolean;\n }\n >\n ? IOptional extends true\n ? never\n : KName\n : never]: TInputs[KName] extends ExtensionInput<\n infer IDataRefs,\n {\n optional: boolean;\n singleton: infer ISingleton extends boolean;\n internal?: boolean;\n }\n >\n ? ISingleton extends true\n ? Iterable<ExtensionDataRefToValue<IDataRefs>>\n : Array<Iterable<ExtensionDataRefToValue<IDataRefs>>>\n : never;\n } & {\n [KName in keyof TInputs as TInputs[KName] extends ExtensionInput<\n any,\n {\n optional: infer IOptional extends boolean;\n singleton: boolean;\n internal?: boolean;\n }\n >\n ? IOptional extends true\n ? KName\n : never\n : never]?: TInputs[KName] extends ExtensionInput<\n infer IDataRefs,\n {\n optional: boolean;\n singleton: infer ISingleton extends boolean;\n internal?: boolean;\n }\n >\n ? ISingleton extends true\n ? Iterable<ExtensionDataRefToValue<IDataRefs>>\n : Array<Iterable<ExtensionDataRefToValue<IDataRefs>>>\n : never;\n }\n>;\n\nfunction expectArray<T>(value: T | T[]): T[] {\n return value as T[];\n}\nfunction expectItem<T>(value: T | T[]): T {\n return value as T;\n}\n\n/** @internal */\nexport function resolveInputOverrides(\n declaredInputs?: { [inputName in string]: ExtensionInput },\n inputs?: {\n [KName in string]?:\n | ({ node: AppNode } & ExtensionDataContainer<any>)\n | Array<{ node: AppNode } & ExtensionDataContainer<any>>;\n },\n inputOverrides?: ResolvedInputValueOverrides,\n) {\n if (!declaredInputs || !inputs || !inputOverrides) {\n return inputs;\n }\n\n const newInputs: typeof inputs = {};\n for (const name in declaredInputs) {\n if (!Object.hasOwn(declaredInputs, name)) {\n continue;\n }\n const declaredInput = declaredInputs[name];\n const providedData = inputOverrides[name];\n if (declaredInput.config.singleton) {\n const originalInput = expectItem(inputs[name]);\n if (providedData) {\n const providedContainer = createExtensionDataContainer(\n providedData as Iterable<ExtensionDataValue<any, any>>,\n 'extension input override',\n declaredInput.extensionData,\n );\n if (!originalInput) {\n throw new Error(\n `attempted to override data of input '${name}' but it is not present in the original inputs`,\n );\n }\n newInputs[name] = Object.assign(providedContainer, {\n node: (originalInput as ResolvedExtensionInput<any>).node,\n }) as any;\n }\n } else {\n const originalInput = expectArray(inputs[name]);\n if (!Array.isArray(providedData)) {\n throw new Error(\n `override data provided for input '${name}' must be an array`,\n );\n }\n\n // Regular inputs can be overridden in two different ways:\n // 1) Forward a subset of the original inputs in a new order\n // 2) Provide new data for each original input\n\n // First check if all inputs are being removed\n if (providedData.length === 0) {\n newInputs[name] = [];\n } else {\n // Check how many of the provided data items have a node property, i.e. is a forwarded input\n const withNodesCount = providedData.filter(d => 'node' in d).length;\n if (withNodesCount === 0) {\n if (originalInput.length !== providedData.length) {\n throw new Error(\n `override data provided for input '${name}' must match the length of the original inputs`,\n );\n }\n newInputs[name] = providedData.map((data, i) => {\n const providedContainer = createExtensionDataContainer(\n data as Iterable<ExtensionDataValue<any, any>>,\n 'extension input override',\n declaredInput.extensionData,\n );\n return Object.assign(providedContainer, {\n node: (originalInput[i] as ResolvedExtensionInput<any>).node,\n }) as any;\n });\n } else if (withNodesCount === providedData.length) {\n newInputs[name] = providedData as any;\n } else {\n throw new Error(\n `override data for input '${name}' may not mix forwarded inputs with data overrides`,\n );\n }\n }\n }\n }\n return newInputs;\n}\n"],"names":[],"mappings":";;;;;;AAoFA,SAAS,YAAe,KAAA,EAAqB;AAC3C,EAAA,OAAO,KAAA;AACT;AACA,SAAS,WAAc,KAAA,EAAmB;AACxC,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,qBAAA,CACd,cAAA,EACA,MAAA,EAKA,cAAA,EACA;AACA,EAAA,IAAI,CAAC,cAAA,IAAkB,CAAC,MAA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,MAAO;AAEL,QAAA,MAAM,iBAAiB,YAAA,CAAa,MAAA,CAAO,CAAA,CAAA,KAAK,MAAA,IAAU,CAAC,CAAA,CAAE,MAAA;AAC7D,QAAA,IAAI,mBAAmB,CAAA,EAAG;AACxB,UAAA,IAAI,aAAA,CAAc,MAAA,KAAW,YAAA,CAAa,MAAA,EAAQ;AAChD,YAAA,MAAM,IAAI,KAAA;AAAA,cACR,qCAAqC,IAAI,CAAA,8CAAA;AAAA,aAC3C;AAAA,UACF;AACA,UAAA,SAAA,CAAU,IAAI,CAAA,GAAI,YAAA,CAAa,GAAA,CAAI,CAAC,MAAM,CAAA,KAAM;AAC9C,YAAA,MAAM,iBAAA,GAAoB,4BAAA;AAAA,cACxB,IAAA;AAAA,cACA,0BAAA;AAAA,cACA,aAAA,CAAc;AAAA,aAChB;AACA,YAAA,OAAO,MAAA,CAAO,OAAO,iBAAA,EAAmB;AAAA,cACtC,IAAA,EAAO,aAAA,CAAc,CAAC,CAAA,CAAkC;AAAA,aACzD,CAAA;AAAA,UACH,CAAC,CAAA;AAAA,QACH,CAAA,MAAA,IAAW,cAAA,KAAmB,YAAA,CAAa,MAAA,EAAQ;AACjD,UAAA,SAAA,CAAU,IAAI,CAAA,GAAI,YAAA;AAAA,QACpB,CAAA,MAAO;AACL,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,4BAA4B,IAAI,CAAA,kDAAA;AAAA,WAClC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,SAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-plugin-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-next.0",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
"test": "backstage-cli package test"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@backstage/errors": "
|
|
56
|
-
"@backstage/types": "
|
|
57
|
-
"@backstage/version-bridge": "
|
|
58
|
-
"zod": "^3.
|
|
55
|
+
"@backstage/errors": "1.2.7",
|
|
56
|
+
"@backstage/types": "1.2.2",
|
|
57
|
+
"@backstage/version-bridge": "1.0.11",
|
|
58
|
+
"zod": "^3.25.76",
|
|
59
59
|
"zod-to-json-schema": "^3.25.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@backstage/cli": "
|
|
63
|
-
"@backstage/config": "
|
|
64
|
-
"@backstage/frontend-app-api": "
|
|
65
|
-
"@backstage/frontend-test-utils": "
|
|
66
|
-
"@backstage/test-utils": "
|
|
62
|
+
"@backstage/cli": "0.35.3-next.0",
|
|
63
|
+
"@backstage/config": "1.3.6",
|
|
64
|
+
"@backstage/frontend-app-api": "0.14.1-next.0",
|
|
65
|
+
"@backstage/frontend-test-utils": "0.4.5-next.0",
|
|
66
|
+
"@backstage/test-utils": "1.7.15-next.0",
|
|
67
67
|
"@testing-library/jest-dom": "^6.0.0",
|
|
68
68
|
"@testing-library/react": "^16.0.0",
|
|
69
69
|
"@types/react": "^18.0.0",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import 'zod-to-json-schema';
|
|
4
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
|
-
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
6
|
-
|
|
7
|
-
const componentDataRef = createExtensionDataRef().with({ id: "app.root.wrapper" });
|
|
8
|
-
const AppRootWrapperBlueprint = createExtensionBlueprint({
|
|
9
|
-
kind: "app-root-wrapper",
|
|
10
|
-
attachTo: { id: "app/root", input: "wrappers" },
|
|
11
|
-
output: [componentDataRef],
|
|
12
|
-
dataRefs: {
|
|
13
|
-
component: componentDataRef
|
|
14
|
-
},
|
|
15
|
-
*factory(params) {
|
|
16
|
-
yield componentDataRef(params.component);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export { AppRootWrapperBlueprint };
|
|
21
|
-
//# sourceMappingURL=AppRootWrapperBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppRootWrapperBlueprint.esm.js","sources":["../../src/blueprints/AppRootWrapperBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReactNode } from 'react';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst componentDataRef = createExtensionDataRef<\n (props: { children: ReactNode }) => JSX.Element | null\n>().with({ id: 'app.root.wrapper' });\n\n/**\n * Creates a extensions that render a React wrapper at the app root, enclosing\n * the app layout. This is useful for example for adding global React contexts\n * and similar.\n *\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#AppRootWrapperBlueprint} instead.\n * If you were using this blueprint to provide a context for your plugin,\n * use `PluginWrapperBlueprint` from `@backstage/frontend-plugin-api/alpha` instead.\n */\nexport const AppRootWrapperBlueprint = createExtensionBlueprint({\n kind: 'app-root-wrapper',\n attachTo: { id: 'app/root', input: 'wrappers' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n *factory(params: {\n /** @deprecated use the `component` parameter instead */\n Component?: [error: 'Use the `component` parameter instead'];\n component: (props: { children: ReactNode }) => JSX.Element | null;\n }) {\n yield componentDataRef(params.component);\n },\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,mBAAmB,sBAAA,EAEvB,CAAE,KAAK,EAAE,EAAA,EAAI,oBAAoB,CAAA;AAY5B,MAAM,0BAA0B,wBAAA,CAAyB;AAAA,EAC9D,IAAA,EAAM,kBAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,UAAA,EAAY,OAAO,UAAA,EAAW;AAAA,EAC9C,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAA,EAAU;AAAA,IACR,SAAA,EAAW;AAAA,GACb;AAAA,EACA,CAAC,QAAQ,MAAA,EAIN;AACD,IAAA,MAAM,gBAAA,CAAiB,OAAO,SAAS,CAAA;AAAA,EACzC;AACF,CAAC;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import 'zod-to-json-schema';
|
|
4
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
|
-
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
6
|
-
|
|
7
|
-
const iconsDataRef = createExtensionDataRef().with({ id: "core.icons" });
|
|
8
|
-
const IconBundleBlueprint = createExtensionBlueprint({
|
|
9
|
-
kind: "icon-bundle",
|
|
10
|
-
attachTo: { id: "api:app/icons", input: "icons" },
|
|
11
|
-
output: [iconsDataRef],
|
|
12
|
-
factory: (params) => [
|
|
13
|
-
iconsDataRef(params.icons)
|
|
14
|
-
],
|
|
15
|
-
dataRefs: {
|
|
16
|
-
icons: iconsDataRef
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export { IconBundleBlueprint };
|
|
21
|
-
//# sourceMappingURL=IconBundleBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IconBundleBlueprint.esm.js","sources":["../../src/blueprints/IconBundleBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { IconComponent } from '../icons';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst iconsDataRef = createExtensionDataRef<{\n [key in string]: IconComponent;\n}>().with({ id: 'core.icons' });\n\n/**\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#IconBundleBlueprint} instead.\n */\nexport const IconBundleBlueprint = createExtensionBlueprint({\n kind: 'icon-bundle',\n attachTo: { id: 'api:app/icons', input: 'icons' },\n output: [iconsDataRef],\n factory: (params: { icons: { [key in string]: IconComponent } }) => [\n iconsDataRef(params.icons),\n ],\n dataRefs: {\n icons: iconsDataRef,\n },\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,eAAe,sBAAA,EAElB,CAAE,KAAK,EAAE,EAAA,EAAI,cAAc,CAAA;AAMvB,MAAM,sBAAsB,wBAAA,CAAyB;AAAA,EAC1D,IAAA,EAAM,aAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,eAAA,EAAiB,OAAO,OAAA,EAAQ;AAAA,EAChD,MAAA,EAAQ,CAAC,YAAY,CAAA;AAAA,EACrB,OAAA,EAAS,CAAC,MAAA,KAA0D;AAAA,IAClE,YAAA,CAAa,OAAO,KAAK;AAAA,GAC3B;AAAA,EACA,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA;AAEX,CAAC;;;;"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import 'zod-to-json-schema';
|
|
4
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
|
-
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
6
|
-
|
|
7
|
-
const componentDataRef = createExtensionDataRef().with({
|
|
8
|
-
id: "core.nav-content.component"
|
|
9
|
-
});
|
|
10
|
-
const NavContentBlueprint = createExtensionBlueprint({
|
|
11
|
-
kind: "nav-content",
|
|
12
|
-
attachTo: { id: "app/nav", input: "content" },
|
|
13
|
-
output: [componentDataRef],
|
|
14
|
-
dataRefs: {
|
|
15
|
-
component: componentDataRef
|
|
16
|
-
},
|
|
17
|
-
*factory(params) {
|
|
18
|
-
yield componentDataRef(params.component);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export { NavContentBlueprint };
|
|
23
|
-
//# sourceMappingURL=NavContentBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NavContentBlueprint.esm.js","sources":["../../src/blueprints/NavContentBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { IconComponent, RouteRef } from '@backstage/frontend-plugin-api';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\n/**\n * The props for the {@link NavContentComponent}.\n *\n * @public\n */\nexport interface NavContentComponentProps {\n /**\n * The nav items available to the component. These are all the items created\n * with the {@link NavItemBlueprint} in the app.\n *\n * In addition to the original properties from the nav items, these also\n * include a resolved route path as `to`, and duplicated `title` as `text` to\n * simplify rendering.\n */\n items: Array<{\n // Original props from nav items\n icon: IconComponent;\n title: string;\n routeRef: RouteRef<undefined>;\n\n // Additional props to simplify item rendering\n to: string;\n text: string;\n }>;\n}\n\n/**\n * A component that renders the nav bar content, to be passed to the {@link NavContentBlueprint}.\n *\n * @public\n */\nexport type NavContentComponent = (\n props: NavContentComponentProps,\n) => JSX.Element | null;\n\nconst componentDataRef = createExtensionDataRef<NavContentComponent>().with({\n id: 'core.nav-content.component',\n});\n\n/**\n * Creates an extension that replaces the entire nav bar with your own component.\n *\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#NavContentBlueprint} instead.\n */\nexport const NavContentBlueprint = createExtensionBlueprint({\n kind: 'nav-content',\n attachTo: { id: 'app/nav', input: 'content' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n *factory(params: { component: NavContentComponent }) {\n yield componentDataRef(params.component);\n },\n});\n"],"names":[],"mappings":";;;;;;AAsDA,MAAM,gBAAA,GAAmB,sBAAA,EAA4C,CAAE,IAAA,CAAK;AAAA,EAC1E,EAAA,EAAI;AACN,CAAC,CAAA;AAQM,MAAM,sBAAsB,wBAAA,CAAyB;AAAA,EAC1D,IAAA,EAAM,aAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,SAAA,EAAW,OAAO,SAAA,EAAU;AAAA,EAC5C,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAA,EAAU;AAAA,IACR,SAAA,EAAW;AAAA,GACb;AAAA,EACA,CAAC,QAAQ,MAAA,EAA4C;AACnD,IAAA,MAAM,gBAAA,CAAiB,OAAO,SAAS,CAAA;AAAA,EACzC;AACF,CAAC;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import 'zod-to-json-schema';
|
|
4
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
|
-
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
6
|
-
|
|
7
|
-
const componentDataRef = createExtensionDataRef().with({ id: "app.router.wrapper" });
|
|
8
|
-
const RouterBlueprint = createExtensionBlueprint({
|
|
9
|
-
kind: "app-router-component",
|
|
10
|
-
attachTo: { id: "app/root", input: "router" },
|
|
11
|
-
output: [componentDataRef],
|
|
12
|
-
dataRefs: {
|
|
13
|
-
component: componentDataRef
|
|
14
|
-
},
|
|
15
|
-
*factory(params) {
|
|
16
|
-
yield componentDataRef(params.component);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export { RouterBlueprint };
|
|
21
|
-
//# sourceMappingURL=RouterBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RouterBlueprint.esm.js","sources":["../../src/blueprints/RouterBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReactNode } from 'react';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst componentDataRef = createExtensionDataRef<\n (props: { children: ReactNode }) => JSX.Element | null\n>().with({ id: 'app.router.wrapper' });\n\n/**\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#RouterBlueprint} instead.\n */\nexport const RouterBlueprint = createExtensionBlueprint({\n kind: 'app-router-component',\n attachTo: { id: 'app/root', input: 'router' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n *factory(params: {\n /** @deprecated use the `component` parameter instead */\n Component?: [error: 'Use the `component` parameter instead'];\n component: (props: { children: ReactNode }) => JSX.Element | null;\n }) {\n yield componentDataRef(params.component);\n },\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,mBAAmB,sBAAA,EAEvB,CAAE,KAAK,EAAE,EAAA,EAAI,sBAAsB,CAAA;AAM9B,MAAM,kBAAkB,wBAAA,CAAyB;AAAA,EACtD,IAAA,EAAM,sBAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,UAAA,EAAY,OAAO,QAAA,EAAS;AAAA,EAC5C,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAA,EAAU;AAAA,IACR,SAAA,EAAW;AAAA,GACb;AAAA,EACA,CAAC,QAAQ,MAAA,EAIN;AACD,IAAA,MAAM,gBAAA,CAAiB,OAAO,SAAS,CAAA;AAAA,EACzC;AACF,CAAC;;;;"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { lazy } from 'react';
|
|
3
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
4
|
-
import 'zod';
|
|
5
|
-
import 'zod-to-json-schema';
|
|
6
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
7
|
-
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
8
|
-
import { ExtensionBoundary } from '../components/ExtensionBoundary.esm.js';
|
|
9
|
-
import '../apis/definitions/AppTreeApi.esm.js';
|
|
10
|
-
import '../apis/definitions/auth.esm.js';
|
|
11
|
-
import '../apis/definitions/AlertApi.esm.js';
|
|
12
|
-
import '../apis/definitions/AppLanguageApi.esm.js';
|
|
13
|
-
import '../apis/definitions/AppThemeApi.esm.js';
|
|
14
|
-
import '../apis/definitions/SwappableComponentsApi.esm.js';
|
|
15
|
-
import '../apis/definitions/ConfigApi.esm.js';
|
|
16
|
-
import '../apis/definitions/DiscoveryApi.esm.js';
|
|
17
|
-
import '../apis/definitions/ErrorApi.esm.js';
|
|
18
|
-
import '../apis/definitions/FeatureFlagsApi.esm.js';
|
|
19
|
-
import '../apis/definitions/FetchApi.esm.js';
|
|
20
|
-
import '../apis/definitions/IconsApi.esm.js';
|
|
21
|
-
import '../apis/definitions/IdentityApi.esm.js';
|
|
22
|
-
import '../apis/definitions/DialogApi.esm.js';
|
|
23
|
-
import '../apis/definitions/OAuthRequestApi.esm.js';
|
|
24
|
-
import '../apis/definitions/RouteResolutionApi.esm.js';
|
|
25
|
-
import '../apis/definitions/StorageApi.esm.js';
|
|
26
|
-
import '../apis/definitions/AnalyticsApi.esm.js';
|
|
27
|
-
import '../apis/definitions/TranslationApi.esm.js';
|
|
28
|
-
import '@backstage/version-bridge';
|
|
29
|
-
import '@backstage/errors';
|
|
30
|
-
import '../components/AppNodeProvider.esm.js';
|
|
31
|
-
import '../components/DefaultSwappableComponents.esm.js';
|
|
32
|
-
|
|
33
|
-
const componentDataRef = createExtensionDataRef().with({ id: "core.sign-in-page.component" });
|
|
34
|
-
const SignInPageBlueprint = createExtensionBlueprint({
|
|
35
|
-
kind: "sign-in-page",
|
|
36
|
-
attachTo: { id: "app/root", input: "signInPage" },
|
|
37
|
-
output: [componentDataRef],
|
|
38
|
-
dataRefs: {
|
|
39
|
-
component: componentDataRef
|
|
40
|
-
},
|
|
41
|
-
*factory({
|
|
42
|
-
loader
|
|
43
|
-
}, { node }) {
|
|
44
|
-
const ExtensionComponent = lazy(
|
|
45
|
-
() => loader().then((component) => ({ default: component }))
|
|
46
|
-
);
|
|
47
|
-
yield componentDataRef((props) => /* @__PURE__ */ jsx(ExtensionBoundary, { node, children: /* @__PURE__ */ jsx(ExtensionComponent, { ...props }) }));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export { SignInPageBlueprint };
|
|
52
|
-
//# sourceMappingURL=SignInPageBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SignInPageBlueprint.esm.js","sources":["../../src/blueprints/SignInPageBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentType, lazy, ReactNode } from 'react';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\nimport { ExtensionBoundary } from '../components';\nimport { IdentityApi } from '../apis';\n\n/**\n * Props for the `SignInPage` component.\n *\n * @public\n */\nexport type SignInPageProps = {\n /**\n * Set the IdentityApi on successful sign-in. This should only be called once.\n */\n onSignInSuccess(identityApi: IdentityApi): void;\n\n /**\n * The children to render.\n */\n children?: ReactNode;\n};\n\nconst componentDataRef = createExtensionDataRef<\n ComponentType<SignInPageProps>\n>().with({ id: 'core.sign-in-page.component' });\n\n/**\n * Creates an extension that replaces the sign in page.\n *\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#SignInPageBlueprint} instead.\n */\nexport const SignInPageBlueprint = createExtensionBlueprint({\n kind: 'sign-in-page',\n attachTo: { id: 'app/root', input: 'signInPage' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n *factory(\n {\n loader,\n }: {\n loader: () => Promise<ComponentType<SignInPageProps>>;\n },\n { node },\n ) {\n const ExtensionComponent = lazy(() =>\n loader().then(component => ({ default: component })),\n );\n\n yield componentDataRef(props => (\n <ExtensionBoundary node={node}>\n <ExtensionComponent {...props} />\n </ExtensionBoundary>\n ));\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,mBAAmB,sBAAA,EAEvB,CAAE,KAAK,EAAE,EAAA,EAAI,+BAA+B,CAAA;AAQvC,MAAM,sBAAsB,wBAAA,CAAyB;AAAA,EAC1D,IAAA,EAAM,cAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,UAAA,EAAY,OAAO,YAAA,EAAa;AAAA,EAChD,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAA,EAAU;AAAA,IACR,SAAA,EAAW;AAAA,GACb;AAAA,EACA,CAAC,OAAA,CACC;AAAA,IACE;AAAA,GACF,EAGA,EAAE,IAAA,EAAK,EACP;AACA,IAAA,MAAM,kBAAA,GAAqB,IAAA;AAAA,MAAK,MAC9B,QAAO,CAAE,IAAA,CAAK,gBAAc,EAAE,OAAA,EAAS,WAAU,CAAE;AAAA,KACrD;AAEA,IAAA,MAAM,gBAAA,CAAiB,CAAA,KAAA,qBACrB,GAAA,CAAC,iBAAA,EAAA,EAAkB,IAAA,EACjB,8BAAC,kBAAA,EAAA,EAAoB,GAAG,KAAA,EAAO,CAAA,EACjC,CACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import 'zod-to-json-schema';
|
|
4
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
|
-
import { createExtensionBlueprint, createExtensionBlueprintParams } from '../wiring/createExtensionBlueprint.esm.js';
|
|
6
|
-
|
|
7
|
-
const componentDataRef = createExtensionDataRef().with({ id: "core.swappableComponent" });
|
|
8
|
-
const SwappableComponentBlueprint = createExtensionBlueprint({
|
|
9
|
-
kind: "component",
|
|
10
|
-
attachTo: { id: "api:app/swappable-components", input: "components" },
|
|
11
|
-
output: [componentDataRef],
|
|
12
|
-
dataRefs: {
|
|
13
|
-
component: componentDataRef
|
|
14
|
-
},
|
|
15
|
-
defineParams(params) {
|
|
16
|
-
return createExtensionBlueprintParams(params);
|
|
17
|
-
},
|
|
18
|
-
factory: (params) => [
|
|
19
|
-
componentDataRef({
|
|
20
|
-
ref: params.component.ref,
|
|
21
|
-
loader: params.loader
|
|
22
|
-
})
|
|
23
|
-
]
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export { SwappableComponentBlueprint, componentDataRef };
|
|
27
|
-
//# sourceMappingURL=SwappableComponentBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SwappableComponentBlueprint.esm.js","sources":["../../src/blueprints/SwappableComponentBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { SwappableComponentRef } from '../components';\nimport {\n createExtensionBlueprint,\n createExtensionBlueprintParams,\n createExtensionDataRef,\n} from '../wiring';\n\nexport const componentDataRef = createExtensionDataRef<{\n ref: SwappableComponentRef;\n loader:\n | (() => (props: {}) => JSX.Element | null)\n | (() => Promise<(props: {}) => JSX.Element | null>);\n}>().with({ id: 'core.swappableComponent' });\n\n/**\n * Blueprint for creating swappable components from a SwappableComponentRef and a loader\n *\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#SwappableComponentBlueprint} instead.\n */\nexport const SwappableComponentBlueprint = createExtensionBlueprint({\n kind: 'component',\n attachTo: { id: 'api:app/swappable-components', input: 'components' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n defineParams<Ref extends SwappableComponentRef<any>>(params: {\n component: Ref extends SwappableComponentRef<\n any,\n infer IExternalComponentProps\n >\n ? { ref: Ref } & ((props: IExternalComponentProps) => JSX.Element | null)\n : never;\n loader: Ref extends SwappableComponentRef<infer IInnerComponentProps, any>\n ?\n | (() => (props: IInnerComponentProps) => JSX.Element | null)\n | (() => Promise<(props: IInnerComponentProps) => JSX.Element | null>)\n : never;\n }) {\n return createExtensionBlueprintParams(params);\n },\n factory: params => [\n componentDataRef({\n ref: params.component.ref,\n loader: params.loader,\n }),\n ],\n});\n"],"names":[],"mappings":";;;;;;AAsBO,MAAM,mBAAmB,sBAAA,EAK7B,CAAE,KAAK,EAAE,EAAA,EAAI,2BAA2B;AAQpC,MAAM,8BAA8B,wBAAA,CAAyB;AAAA,EAClE,IAAA,EAAM,WAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,8BAAA,EAAgC,OAAO,YAAA,EAAa;AAAA,EACpE,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAA,EAAU;AAAA,IACR,SAAA,EAAW;AAAA,GACb;AAAA,EACA,aAAqD,MAAA,EAYlD;AACD,IAAA,OAAO,+BAA+B,MAAM,CAAA;AAAA,EAC9C,CAAA;AAAA,EACA,SAAS,CAAA,MAAA,KAAU;AAAA,IACjB,gBAAA,CAAiB;AAAA,MACf,GAAA,EAAK,OAAO,SAAA,CAAU,GAAA;AAAA,MACtB,QAAQ,MAAA,CAAO;AAAA,KAChB;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import 'zod-to-json-schema';
|
|
4
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
|
-
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
6
|
-
|
|
7
|
-
const themeDataRef = createExtensionDataRef().with({
|
|
8
|
-
id: "core.theme.theme"
|
|
9
|
-
});
|
|
10
|
-
const ThemeBlueprint = createExtensionBlueprint({
|
|
11
|
-
kind: "theme",
|
|
12
|
-
attachTo: { id: "api:app/app-theme", input: "themes" },
|
|
13
|
-
output: [themeDataRef],
|
|
14
|
-
dataRefs: {
|
|
15
|
-
theme: themeDataRef
|
|
16
|
-
},
|
|
17
|
-
factory: ({ theme }) => [themeDataRef(theme)]
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export { ThemeBlueprint };
|
|
21
|
-
//# sourceMappingURL=ThemeBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeBlueprint.esm.js","sources":["../../src/blueprints/ThemeBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AppTheme } from '../apis/definitions/AppThemeApi';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst themeDataRef = createExtensionDataRef<AppTheme>().with({\n id: 'core.theme.theme',\n});\n\n/**\n * Creates an extension that adds/replaces an app theme.\n *\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#ThemeBlueprint} instead.\n */\nexport const ThemeBlueprint = createExtensionBlueprint({\n kind: 'theme',\n attachTo: { id: 'api:app/app-theme', input: 'themes' },\n output: [themeDataRef],\n dataRefs: {\n theme: themeDataRef,\n },\n factory: ({ theme }: { theme: AppTheme }) => [themeDataRef(theme)],\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,YAAA,GAAe,sBAAA,EAAiC,CAAE,IAAA,CAAK;AAAA,EAC3D,EAAA,EAAI;AACN,CAAC,CAAA;AAQM,MAAM,iBAAiB,wBAAA,CAAyB;AAAA,EACrD,IAAA,EAAM,OAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,mBAAA,EAAqB,OAAO,QAAA,EAAS;AAAA,EACrD,MAAA,EAAQ,CAAC,YAAY,CAAA;AAAA,EACrB,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA,GACT;AAAA,EACA,OAAA,EAAS,CAAC,EAAE,KAAA,OAAiC,CAAC,YAAA,CAAa,KAAK,CAAC;AACnE,CAAC;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import 'zod-to-json-schema';
|
|
4
|
-
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
|
-
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
6
|
-
|
|
7
|
-
const translationDataRef = createExtensionDataRef().with({ id: "core.translation.translation" });
|
|
8
|
-
const TranslationBlueprint = createExtensionBlueprint({
|
|
9
|
-
kind: "translation",
|
|
10
|
-
attachTo: { id: "api:app/translations", input: "translations" },
|
|
11
|
-
output: [translationDataRef],
|
|
12
|
-
dataRefs: {
|
|
13
|
-
translation: translationDataRef
|
|
14
|
-
},
|
|
15
|
-
factory: ({
|
|
16
|
-
resource
|
|
17
|
-
}) => [translationDataRef(resource)]
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export { TranslationBlueprint };
|
|
21
|
-
//# sourceMappingURL=TranslationBlueprint.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationBlueprint.esm.js","sources":["../../src/blueprints/TranslationBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\nimport { TranslationMessages, TranslationResource } from '../translation';\n\nconst translationDataRef = createExtensionDataRef<\n TranslationResource | TranslationMessages\n>().with({ id: 'core.translation.translation' });\n\n/**\n * Creates an extension that adds translations to your app.\n *\n * @public\n * @deprecated Use {@link @backstage/plugin-app-react#TranslationBlueprint} instead.\n */\nexport const TranslationBlueprint = createExtensionBlueprint({\n kind: 'translation',\n attachTo: { id: 'api:app/translations', input: 'translations' },\n output: [translationDataRef],\n dataRefs: {\n translation: translationDataRef,\n },\n factory: ({\n resource,\n }: {\n resource: TranslationResource | TranslationMessages;\n }) => [translationDataRef(resource)],\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,qBAAqB,sBAAA,EAEzB,CAAE,KAAK,EAAE,EAAA,EAAI,gCAAgC,CAAA;AAQxC,MAAM,uBAAuB,wBAAA,CAAyB;AAAA,EAC3D,IAAA,EAAM,aAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,sBAAA,EAAwB,OAAO,cAAA,EAAe;AAAA,EAC9D,MAAA,EAAQ,CAAC,kBAAkB,CAAA;AAAA,EAC3B,QAAA,EAAU;AAAA,IACR,WAAA,EAAa;AAAA,GACf;AAAA,EACA,SAAS,CAAC;AAAA,IACR;AAAA,GACF,KAEM,CAAC,kBAAA,CAAmB,QAAQ,CAAC;AACrC,CAAC;;;;"}
|