@backstage/frontend-plugin-api 0.1.1-next.1 → 0.2.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 +31 -0
- package/dist/index.d.ts +32 -11
- package/dist/index.esm.js +19 -24
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @backstage/frontend-plugin-api
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 06432f900c: Extension attachment point is now configured via `attachTo: { id, input }` instead of `at: 'id/input'`.
|
|
8
|
+
- 4461d87d5a: Removed support for the new `useRouteRef`.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- d3a37f55c0: Add support for `SidebarGroup` on the sidebar item extension.
|
|
13
|
+
- 2ecd33618a: Plugins can now be assigned `routes` and `externalRoutes` when created.
|
|
14
|
+
- 9a1fce352e: Updated dependency `@testing-library/jest-dom` to `^6.0.0`.
|
|
15
|
+
- c1e9ca6500: Added `createExtensionOverrides` which can be used to install a collection of extensions in an app that will replace any existing ones.
|
|
16
|
+
- 52366db5b3: Added `createThemeExtension` and `coreExtensionData.theme`.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @backstage/core-plugin-api@1.7.0
|
|
19
|
+
- @backstage/types@1.1.1
|
|
20
|
+
|
|
21
|
+
## 0.2.0-next.2
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 06432f900c: Extension attachment point is now configured via `attachTo: { id, input }` instead of `at: 'id/input'`.
|
|
26
|
+
- 4461d87d5a: Removed support for the new `useRouteRef`.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @backstage/core-plugin-api@1.7.0-next.1
|
|
32
|
+
- @backstage/types@1.1.1
|
|
33
|
+
|
|
3
34
|
## 0.1.1-next.1
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React, { JSX as JSX$1, ReactNode } from 'react';
|
|
3
|
+
import { IconComponent, RouteRef, AnyApiFactory, AppTheme, AnyRoutes, AnyExternalRoutes, AnyApiRef } from '@backstage/core-plugin-api';
|
|
3
4
|
import { JsonObject } from '@backstage/types';
|
|
4
|
-
import { IconComponent, RouteRef, AnyApiFactory, AppTheme, AnyApiRef } from '@backstage/core-plugin-api';
|
|
5
5
|
import { z, ZodSchema, ZodTypeDef } from 'zod';
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
@@ -68,18 +68,22 @@ declare function createExtensionInput<TExtensionData extends AnyExtensionDataMap
|
|
|
68
68
|
}>;
|
|
69
69
|
|
|
70
70
|
/** @public */
|
|
71
|
-
interface PluginOptions {
|
|
71
|
+
interface PluginOptions<Routes extends AnyRoutes, ExternalRoutes extends AnyExternalRoutes> {
|
|
72
72
|
id: string;
|
|
73
|
+
routes?: Routes;
|
|
74
|
+
externalRoutes?: ExternalRoutes;
|
|
73
75
|
extensions?: Extension<unknown>[];
|
|
74
76
|
}
|
|
75
77
|
/** @public */
|
|
76
|
-
interface BackstagePlugin {
|
|
78
|
+
interface BackstagePlugin<Routes extends AnyRoutes = AnyRoutes, ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes> {
|
|
77
79
|
$$type: '@backstage/BackstagePlugin';
|
|
78
80
|
id: string;
|
|
79
81
|
extensions: Extension<unknown>[];
|
|
82
|
+
routes: Routes;
|
|
83
|
+
externalRoutes: ExternalRoutes;
|
|
80
84
|
}
|
|
81
85
|
/** @public */
|
|
82
|
-
declare function createPlugin(options: PluginOptions): BackstagePlugin
|
|
86
|
+
declare function createPlugin<Routes extends AnyRoutes = AnyRoutes, ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes>(options: PluginOptions<Routes, ExternalRoutes>): BackstagePlugin<Routes, ExternalRoutes>;
|
|
83
87
|
|
|
84
88
|
/** @public */
|
|
85
89
|
type AnyExtensionDataMap = {
|
|
@@ -126,7 +130,10 @@ type ExtensionInputValues<TInputs extends {
|
|
|
126
130
|
/** @public */
|
|
127
131
|
interface CreateExtensionOptions<TOutput extends AnyExtensionDataMap, TInputs extends AnyExtensionInputMap, TConfig> {
|
|
128
132
|
id: string;
|
|
129
|
-
|
|
133
|
+
attachTo: {
|
|
134
|
+
id: string;
|
|
135
|
+
input: string;
|
|
136
|
+
};
|
|
130
137
|
disabled?: boolean;
|
|
131
138
|
inputs?: TInputs;
|
|
132
139
|
output: TOutput;
|
|
@@ -142,7 +149,10 @@ interface CreateExtensionOptions<TOutput extends AnyExtensionDataMap, TInputs ex
|
|
|
142
149
|
interface Extension<TConfig> {
|
|
143
150
|
$$type: '@backstage/Extension';
|
|
144
151
|
id: string;
|
|
145
|
-
|
|
152
|
+
attachTo: {
|
|
153
|
+
id: string;
|
|
154
|
+
input: string;
|
|
155
|
+
};
|
|
146
156
|
disabled: boolean;
|
|
147
157
|
inputs: AnyExtensionInputMap;
|
|
148
158
|
output: AnyExtensionDataMap;
|
|
@@ -157,6 +167,17 @@ interface Extension<TConfig> {
|
|
|
157
167
|
/** @public */
|
|
158
168
|
declare function createExtension<TOutput extends AnyExtensionDataMap, TInputs extends AnyExtensionInputMap, TConfig = never>(options: CreateExtensionOptions<TOutput, TInputs, TConfig>): Extension<TConfig>;
|
|
159
169
|
|
|
170
|
+
/** @public */
|
|
171
|
+
interface ExtensionOverridesOptions {
|
|
172
|
+
extensions: Extension<unknown>[];
|
|
173
|
+
}
|
|
174
|
+
/** @public */
|
|
175
|
+
interface ExtensionOverrides {
|
|
176
|
+
$$type: '@backstage/ExtensionOverrides';
|
|
177
|
+
}
|
|
178
|
+
/** @public */
|
|
179
|
+
declare function createExtensionOverrides(options: ExtensionOverridesOptions): ExtensionOverrides;
|
|
180
|
+
|
|
160
181
|
/** @public */
|
|
161
182
|
interface ExtensionBoundaryProps {
|
|
162
183
|
children: ReactNode;
|
|
@@ -192,7 +213,10 @@ declare function createPageExtension<TConfig extends {
|
|
|
192
213
|
configSchema: PortableSchema<TConfig>;
|
|
193
214
|
}) & {
|
|
194
215
|
id: string;
|
|
195
|
-
|
|
216
|
+
attachTo?: {
|
|
217
|
+
id: string;
|
|
218
|
+
input: string;
|
|
219
|
+
};
|
|
196
220
|
disabled?: boolean;
|
|
197
221
|
inputs?: TInputs;
|
|
198
222
|
routeRef?: RouteRef;
|
|
@@ -218,7 +242,4 @@ declare function createNavItemExtension(options: {
|
|
|
218
242
|
/** @public */
|
|
219
243
|
declare function createThemeExtension(theme: AppTheme): Extension<never>;
|
|
220
244
|
|
|
221
|
-
|
|
222
|
-
declare function useRouteRef(routeRef: RouteRef<any>): () => string;
|
|
223
|
-
|
|
224
|
-
export { AnyExtensionDataMap, AnyExtensionInputMap, BackstagePlugin, ConfigurableExtensionDataRef, CreateExtensionOptions, Extension, ExtensionBoundary, ExtensionBoundaryProps, ExtensionDataRef, ExtensionDataValues, ExtensionInput, ExtensionInputValues, NavTarget, PluginOptions, PortableSchema, coreExtensionData, createApiExtension, createExtension, createExtensionDataRef, createExtensionInput, createNavItemExtension, createPageExtension, createPlugin, createSchemaFromZod, createThemeExtension, useRouteRef };
|
|
245
|
+
export { AnyExtensionDataMap, AnyExtensionInputMap, BackstagePlugin, ConfigurableExtensionDataRef, CreateExtensionOptions, Extension, ExtensionBoundary, ExtensionBoundaryProps, ExtensionDataRef, ExtensionDataValues, ExtensionInput, ExtensionInputValues, ExtensionOverrides, ExtensionOverridesOptions, NavTarget, PluginOptions, PortableSchema, coreExtensionData, createApiExtension, createExtension, createExtensionDataRef, createExtensionInput, createExtensionOverrides, createNavItemExtension, createPageExtension, createPlugin, createSchemaFromZod, createThemeExtension };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import zodToJsonSchema from 'zod-to-json-schema';
|
|
4
|
-
import { RoutingContext } from '@backstage/frontend-app-api/src/routing/RoutingContext';
|
|
5
|
-
import { useLocation } from 'react-router-dom';
|
|
6
4
|
|
|
7
5
|
function ExtensionBoundary(props) {
|
|
8
6
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
|
|
@@ -57,11 +55,21 @@ function createExtensionInput(extensionData, config) {
|
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
function createPlugin(options) {
|
|
60
|
-
var _a;
|
|
58
|
+
var _a, _b, _c;
|
|
61
59
|
return {
|
|
62
60
|
...options,
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
routes: (_a = options.routes) != null ? _a : {},
|
|
62
|
+
externalRoutes: (_b = options.externalRoutes) != null ? _b : {},
|
|
63
|
+
extensions: (_c = options.extensions) != null ? _c : [],
|
|
64
|
+
$$type: "@backstage/BackstagePlugin"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function createExtensionOverrides(options) {
|
|
69
|
+
return {
|
|
70
|
+
$$type: "@backstage/ExtensionOverrides",
|
|
71
|
+
version: "v1",
|
|
72
|
+
extensions: options.extensions
|
|
65
73
|
};
|
|
66
74
|
}
|
|
67
75
|
|
|
@@ -70,7 +78,7 @@ function createApiExtension(options) {
|
|
|
70
78
|
const apiRef = "api" in options ? options.api : factory.api;
|
|
71
79
|
return createExtension({
|
|
72
80
|
id: `apis.${apiRef.id}`,
|
|
73
|
-
|
|
81
|
+
attachTo: { id: "core", input: "apis" },
|
|
74
82
|
inputs: extensionInputs,
|
|
75
83
|
configSchema,
|
|
76
84
|
output: {
|
|
@@ -122,7 +130,7 @@ function createPageExtension(options) {
|
|
|
122
130
|
);
|
|
123
131
|
return createExtension({
|
|
124
132
|
id: options.id,
|
|
125
|
-
|
|
133
|
+
attachTo: (_a = options.attachTo) != null ? _a : { id: "core.routes", input: "routes" },
|
|
126
134
|
disabled: options.disabled,
|
|
127
135
|
output: {
|
|
128
136
|
element: coreExtensionData.reactElement,
|
|
@@ -148,7 +156,7 @@ function createNavItemExtension(options) {
|
|
|
148
156
|
const { id, routeRef, title, icon } = options;
|
|
149
157
|
return createExtension({
|
|
150
158
|
id,
|
|
151
|
-
|
|
159
|
+
attachTo: { id: "core.nav", input: "items" },
|
|
152
160
|
configSchema: createSchemaFromZod(
|
|
153
161
|
(z) => z.object({
|
|
154
162
|
title: z.string().default(title)
|
|
@@ -172,7 +180,7 @@ function createNavItemExtension(options) {
|
|
|
172
180
|
function createThemeExtension(theme) {
|
|
173
181
|
return createExtension({
|
|
174
182
|
id: `themes.${theme.id}`,
|
|
175
|
-
|
|
183
|
+
attachTo: { id: "core", input: "themes" },
|
|
176
184
|
output: {
|
|
177
185
|
theme: coreExtensionData.theme
|
|
178
186
|
},
|
|
@@ -182,18 +190,5 @@ function createThemeExtension(theme) {
|
|
|
182
190
|
});
|
|
183
191
|
}
|
|
184
192
|
|
|
185
|
-
|
|
186
|
-
const { pathname } = useLocation();
|
|
187
|
-
const resolver = useContext(RoutingContext);
|
|
188
|
-
const routeFunc = useMemo(
|
|
189
|
-
() => resolver && resolver.resolve(routeRef, { pathname }),
|
|
190
|
-
[resolver, routeRef, pathname]
|
|
191
|
-
);
|
|
192
|
-
if (!routeFunc) {
|
|
193
|
-
throw new Error(`Failed to resolve routeRef ${routeRef}`);
|
|
194
|
-
}
|
|
195
|
-
return routeFunc;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export { ExtensionBoundary, coreExtensionData, createApiExtension, createExtension, createExtensionDataRef, createExtensionInput, createNavItemExtension, createPageExtension, createPlugin, createSchemaFromZod, createThemeExtension, useRouteRef };
|
|
193
|
+
export { ExtensionBoundary, coreExtensionData, createApiExtension, createExtension, createExtensionDataRef, createExtensionInput, createExtensionOverrides, createNavItemExtension, createPageExtension, createPlugin, createSchemaFromZod, createThemeExtension };
|
|
199
194
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/components/ExtensionBoundary.tsx","../src/wiring/createExtensionDataRef.ts","../src/wiring/coreExtensionData.ts","../src/wiring/createExtension.ts","../src/wiring/createExtensionInput.ts","../src/wiring/createPlugin.ts","../src/extensions/createApiExtension.ts","../src/schema/createSchemaFromZod.ts","../src/extensions/createPageExtension.tsx","../src/extensions/createNavItemExtension.tsx","../src/extensions/createThemeExtension.ts","../src/routing/useRouteRef.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 React, { ReactNode } from 'react';\nimport { BackstagePlugin } from '../wiring';\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n children: ReactNode;\n source?: BackstagePlugin;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n return <>{props.children}</>;\n}\n","/*\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\n/** @public */\nexport type ExtensionDataRef<\n TData,\n TConfig extends { optional?: true } = {},\n> = {\n id: string;\n T: TData;\n config: TConfig;\n $$type: '@backstage/ExtensionDataRef';\n};\n\n/** @public */\nexport interface ConfigurableExtensionDataRef<\n TData,\n TConfig extends { optional?: true } = {},\n> extends ExtensionDataRef<TData, TConfig> {\n optional(): ConfigurableExtensionDataRef<TData, TData & { optional: true }>;\n}\n\n// TODO: change to options object with ID.\n/** @public */\nexport function createExtensionDataRef<TData>(\n id: string,\n): ConfigurableExtensionDataRef<TData> {\n return {\n id,\n $$type: '@backstage/ExtensionDataRef',\n config: {},\n optional() {\n return { ...this, config: { ...this.config, optional: true } };\n },\n } as ConfigurableExtensionDataRef<TData>;\n}\n","/*\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 { JSX } from 'react';\nimport {\n AnyApiFactory,\n AppTheme,\n IconComponent,\n RouteRef,\n} from '@backstage/core-plugin-api';\nimport { createExtensionDataRef } from './createExtensionDataRef';\n\n/** @public */\nexport type NavTarget = {\n title: string;\n icon: IconComponent;\n routeRef: RouteRef<{}>;\n};\n\n/** @public */\nexport const coreExtensionData = {\n reactElement: createExtensionDataRef<JSX.Element>('core.reactElement'),\n routePath: createExtensionDataRef<string>('core.routing.path'),\n apiFactory: createExtensionDataRef<AnyApiFactory>('core.api.factory'),\n routeRef: createExtensionDataRef<RouteRef>('core.routing.ref'),\n navTarget: createExtensionDataRef<NavTarget>('core.nav.target'),\n theme: createExtensionDataRef<AppTheme>('core.theme'),\n};\n","/*\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 { PortableSchema } from '../schema';\nimport { ExtensionDataRef } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport { BackstagePlugin } from './createPlugin';\n\n/** @public */\nexport type AnyExtensionDataMap = {\n [name in string]: ExtensionDataRef<unknown, { optional?: true }>;\n};\n\n/** @public */\nexport type AnyExtensionInputMap = {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataMap,\n { optional: boolean; singleton: boolean }\n >;\n};\n\n// TODO(Rugvip): This might be a quite useful utility type, maybe add to @backstage/types?\n/**\n * Utility type to expand type aliases into their equivalent type.\n * @ignore\n */\nexport type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;\n\n/**\n * Converts an extension data map into the matching concrete data values type.\n * @public\n */\nexport type ExtensionDataValues<TExtensionData extends AnyExtensionDataMap> = {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? never\n : DataName]: TExtensionData[DataName]['T'];\n} & {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? DataName\n : never]?: TExtensionData[DataName]['T'];\n};\n\n/**\n * Converts an extension input map into the matching concrete input values type.\n * @public\n */\nexport type ExtensionInputValues<\n TInputs extends { [name in string]: ExtensionInput<any, any> },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ExtensionDataValues<TInputs[InputName]['extensionData']>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ExtensionDataValues<TInputs[InputName]['extensionData']>>\n : Expand<\n ExtensionDataValues<TInputs[InputName]['extensionData']> | undefined\n >;\n};\n\n/** @public */\nexport interface CreateExtensionOptions<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig,\n> {\n id: string;\n at: string;\n disabled?: boolean;\n inputs?: TInputs;\n output: TOutput;\n configSchema?: PortableSchema<TConfig>;\n factory(options: {\n source?: BackstagePlugin;\n bind(values: Expand<ExtensionDataValues<TOutput>>): void;\n config: TConfig;\n inputs: Expand<ExtensionInputValues<TInputs>>;\n }): void;\n}\n\n/** @public */\nexport interface Extension<TConfig> {\n $$type: '@backstage/Extension';\n id: string;\n at: string;\n disabled: boolean;\n inputs: AnyExtensionInputMap;\n output: AnyExtensionDataMap;\n configSchema?: PortableSchema<TConfig>;\n factory(options: {\n source?: BackstagePlugin;\n bind(values: ExtensionInputValues<any>): void;\n config: TConfig;\n inputs: Record<\n string,\n undefined | Record<string, unknown> | Array<Record<string, unknown>>\n >;\n }): void;\n}\n\n/** @public */\nexport function createExtension<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig = never,\n>(\n options: CreateExtensionOptions<TOutput, TInputs, TConfig>,\n): Extension<TConfig> {\n return {\n ...options,\n disabled: options.disabled ?? false,\n $$type: '@backstage/Extension',\n inputs: options.inputs ?? {},\n factory({ bind, config, inputs }) {\n // TODO: Simplify this, but TS wouldn't infer the input type for some reason\n return options.factory({\n bind,\n config,\n inputs: inputs as Expand<ExtensionInputValues<TInputs>>,\n });\n },\n };\n}\n","/*\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 { AnyExtensionDataMap } from './createExtension';\n\n/** @public */\nexport interface ExtensionInput<\n TExtensionData extends AnyExtensionDataMap,\n TConfig extends { singleton: boolean; optional: boolean },\n> {\n $$type: '@backstage/ExtensionInput';\n extensionData: TExtensionData;\n config: TConfig;\n}\n\n/** @public */\nexport function createExtensionInput<\n TExtensionData extends AnyExtensionDataMap,\n TConfig extends { singleton?: boolean; optional?: boolean },\n>(\n extensionData: TExtensionData,\n config?: TConfig,\n): ExtensionInput<\n TExtensionData,\n {\n singleton: TConfig['singleton'] extends true ? true : false;\n optional: TConfig['optional'] extends true ? true : false;\n }\n> {\n return {\n $$type: '@backstage/ExtensionInput',\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 },\n };\n}\n","/*\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 { Extension } from './createExtension';\n\n/** @public */\nexport interface PluginOptions {\n id: string;\n extensions?: Extension<unknown>[];\n}\n\n/** @public */\nexport interface BackstagePlugin {\n $$type: '@backstage/BackstagePlugin';\n id: string;\n extensions: Extension<unknown>[];\n}\n\n/** @public */\nexport function createPlugin(options: PluginOptions): BackstagePlugin {\n return {\n ...options,\n $$type: '@backstage/BackstagePlugin',\n extensions: options.extensions ?? [],\n };\n}\n","/*\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 { AnyApiFactory, AnyApiRef } from '@backstage/core-plugin-api';\nimport { PortableSchema } from '../schema';\nimport {\n ExtensionInputValues,\n createExtension,\n coreExtensionData,\n} from '../wiring';\nimport { AnyExtensionInputMap, Expand } from '../wiring/createExtension';\n\n/** @public */\nexport function createApiExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(\n options: (\n | {\n api: AnyApiRef;\n factory: (options: {\n config: TConfig;\n inputs: Expand<ExtensionInputValues<TInputs>>;\n }) => AnyApiFactory;\n }\n | {\n factory: AnyApiFactory;\n }\n ) & {\n configSchema?: PortableSchema<TConfig>;\n inputs?: TInputs;\n },\n) {\n const { factory, configSchema, inputs: extensionInputs } = options;\n\n const apiRef =\n 'api' in options ? options.api : (factory as { api: AnyApiRef }).api;\n\n return createExtension({\n id: `apis.${apiRef.id}`,\n at: 'core/apis',\n inputs: extensionInputs,\n configSchema,\n output: {\n api: coreExtensionData.apiFactory,\n },\n factory({ bind, config, inputs }) {\n if (typeof factory === 'function') {\n bind({ api: factory({ config, inputs }) });\n } else {\n bind({ api: factory });\n }\n },\n });\n}\n","/*\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 { JsonObject } from '@backstage/types';\nimport { z, ZodSchema, ZodTypeDef } from 'zod';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { PortableSchema } from './types';\n\n/** @public */\nexport function createSchemaFromZod<TOutput, TInput>(\n schemaCreator: (zImpl: typeof z) => ZodSchema<TOutput, ZodTypeDef, TInput>,\n): PortableSchema<TOutput> {\n const schema = schemaCreator(z);\n return {\n // TODO: Types allow z.array etc here but it will break stuff\n parse: input => {\n const result = schema.safeParse(input);\n if (result.success) {\n return result.data;\n }\n\n throw new Error(result.error.issues.map(formatIssue).join('; '));\n },\n // TODO: Verify why we are not compatible with the latest zodToJsonSchema.\n schema: zodToJsonSchema(schema) as JsonObject,\n };\n}\n\nfunction formatIssue(issue: z.ZodIssue): string {\n if (issue.code === 'invalid_union') {\n return formatIssue(issue.unionErrors[0].issues[0]);\n }\n let message = issue.message;\n if (message === 'Required') {\n message = `Missing required value`;\n }\n if (issue.path.length) {\n message += ` at '${issue.path.join('.')}'`;\n }\n return message;\n}\n","/*\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 { RouteRef } from '@backstage/core-plugin-api';\nimport React from 'react';\nimport { ExtensionBoundary } from '../components';\nimport { createSchemaFromZod, PortableSchema } from '../schema';\nimport {\n coreExtensionData,\n createExtension,\n Extension,\n ExtensionInputValues,\n} from '../wiring';\nimport { AnyExtensionInputMap, Expand } from '../wiring/createExtension';\n\n/**\n * Helper for creating extensions for a routable React page component.\n *\n * @public\n */\nexport function createPageExtension<\n TConfig extends { path: string },\n TInputs extends AnyExtensionInputMap,\n>(\n options: (\n | {\n defaultPath: string;\n }\n | {\n configSchema: PortableSchema<TConfig>;\n }\n ) & {\n id: string;\n at?: string;\n disabled?: boolean;\n inputs?: TInputs;\n routeRef?: RouteRef;\n loader: (options: {\n config: TConfig;\n inputs: Expand<ExtensionInputValues<TInputs>>;\n }) => Promise<JSX.Element>;\n },\n): Extension<TConfig> {\n const configSchema =\n 'configSchema' in options\n ? options.configSchema\n : (createSchemaFromZod(z =>\n z.object({ path: z.string().default(options.defaultPath) }),\n ) as PortableSchema<TConfig>);\n\n return createExtension({\n id: options.id,\n at: options.at ?? 'core.routes/routes',\n disabled: options.disabled,\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef.optional(),\n },\n inputs: options.inputs,\n configSchema,\n factory({ bind, config, inputs, source }) {\n const LazyComponent = React.lazy(() =>\n options\n .loader({ config, inputs })\n .then(element => ({ default: () => element })),\n );\n\n bind({\n path: config.path,\n element: (\n <ExtensionBoundary source={source}>\n <React.Suspense fallback=\"...\">\n <LazyComponent />\n </React.Suspense>\n </ExtensionBoundary>\n ),\n routeRef: options.routeRef,\n });\n },\n });\n}\n","/*\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 { IconComponent, RouteRef } from '@backstage/core-plugin-api';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\nimport { coreExtensionData, createExtension } from '../wiring';\n\n/**\n * Helper for creating extensions for a nav item.\n * @public\n */\nexport function createNavItemExtension(options: {\n id: string;\n routeRef: RouteRef;\n title: string;\n icon: IconComponent;\n}) {\n const { id, routeRef, title, icon } = options;\n return createExtension({\n id,\n at: 'core.nav/items',\n configSchema: createSchemaFromZod(z =>\n z.object({\n title: z.string().default(title),\n }),\n ),\n output: {\n navTarget: coreExtensionData.navTarget,\n },\n factory: ({ bind, config }) => {\n bind({\n navTarget: {\n title: config.title,\n icon,\n routeRef,\n },\n });\n },\n });\n}\n","/*\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 { createExtension, coreExtensionData } from '../wiring';\nimport { AppTheme } from '@backstage/core-plugin-api';\n\n/** @public */\nexport function createThemeExtension(theme: AppTheme) {\n return createExtension({\n id: `themes.${theme.id}`,\n at: 'core/themes',\n output: {\n theme: coreExtensionData.theme,\n },\n factory({ bind }) {\n bind({ theme });\n },\n });\n}\n","/*\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 { RouteRef } from '@backstage/core-plugin-api';\n// eslint-disable-next-line @backstage/no-forbidden-package-imports\nimport { RoutingContext } from '@backstage/frontend-app-api/src/routing/RoutingContext';\nimport { useContext, useMemo } from 'react';\nimport { useLocation } from 'react-router-dom';\n\n/** @public */\nexport function useRouteRef(routeRef: RouteRef<any>): () => string {\n const { pathname } = useLocation();\n const resolver = useContext(RoutingContext);\n\n const routeFunc = useMemo(\n () => resolver && resolver.resolve(routeRef, { pathname }),\n [resolver, routeRef, pathname],\n );\n\n if (!routeFunc) {\n throw new Error(`Failed to resolve routeRef ${routeRef}`);\n }\n\n return routeFunc;\n}\n"],"names":[],"mappings":";;;;;;A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,IACtB,EAAI,EAAA,aAAA;AAAA,IACJ,MAAQ,EAAA;AAAA,MACN,OAAO,iBAAkB,CAAA,KAAA;AAAA,KAC3B;AAAA,IACA,OAAA,CAAQ,EAAE,IAAA,EAAQ,EAAA;AAChB,MAAK,IAAA,CAAA,EAAE,OAAO,CAAA,CAAA;AAAA,KAChB;AAAA,GACD,CAAA,CAAA;AACH;;ACRO,SAAS,YAAY,QAAuC,EAAA;AACjE,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,WAAY,EAAA,CAAA;AACjC,EAAM,MAAA,QAAA,GAAW,WAAW,cAAc,CAAA,CAAA;AAE1C,EAAA,MAAM,SAAY,GAAA,OAAA;AAAA,IAChB,MAAM,QAAY,IAAA,QAAA,CAAS,QAAQ,QAAU,EAAA,EAAE,UAAU,CAAA;AAAA,IACzD,CAAC,QAAU,EAAA,QAAA,EAAU,QAAQ,CAAA;AAAA,GAC/B,CAAA;AAEA,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAA8B,2BAAA,EAAA,QAAQ,CAAE,CAAA,CAAA,CAAA;AAAA,GAC1D;AAEA,EAAO,OAAA,SAAA,CAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/ExtensionBoundary.tsx","../src/wiring/createExtensionDataRef.ts","../src/wiring/coreExtensionData.ts","../src/wiring/createExtension.ts","../src/wiring/createExtensionInput.ts","../src/wiring/createPlugin.ts","../src/wiring/createExtensionOverrides.ts","../src/extensions/createApiExtension.ts","../src/schema/createSchemaFromZod.ts","../src/extensions/createPageExtension.tsx","../src/extensions/createNavItemExtension.tsx","../src/extensions/createThemeExtension.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 React, { ReactNode } from 'react';\nimport { BackstagePlugin } from '../wiring';\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n children: ReactNode;\n source?: BackstagePlugin;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n return <>{props.children}</>;\n}\n","/*\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\n/** @public */\nexport type ExtensionDataRef<\n TData,\n TConfig extends { optional?: true } = {},\n> = {\n id: string;\n T: TData;\n config: TConfig;\n $$type: '@backstage/ExtensionDataRef';\n};\n\n/** @public */\nexport interface ConfigurableExtensionDataRef<\n TData,\n TConfig extends { optional?: true } = {},\n> extends ExtensionDataRef<TData, TConfig> {\n optional(): ConfigurableExtensionDataRef<TData, TData & { optional: true }>;\n}\n\n// TODO: change to options object with ID.\n/** @public */\nexport function createExtensionDataRef<TData>(\n id: string,\n): ConfigurableExtensionDataRef<TData> {\n return {\n id,\n $$type: '@backstage/ExtensionDataRef',\n config: {},\n optional() {\n return { ...this, config: { ...this.config, optional: true } };\n },\n } as ConfigurableExtensionDataRef<TData>;\n}\n","/*\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 { JSX } from 'react';\nimport {\n AnyApiFactory,\n AppTheme,\n IconComponent,\n RouteRef,\n} from '@backstage/core-plugin-api';\nimport { createExtensionDataRef } from './createExtensionDataRef';\n\n/** @public */\nexport type NavTarget = {\n title: string;\n icon: IconComponent;\n routeRef: RouteRef<{}>;\n};\n\n/** @public */\nexport const coreExtensionData = {\n reactElement: createExtensionDataRef<JSX.Element>('core.reactElement'),\n routePath: createExtensionDataRef<string>('core.routing.path'),\n apiFactory: createExtensionDataRef<AnyApiFactory>('core.api.factory'),\n routeRef: createExtensionDataRef<RouteRef>('core.routing.ref'),\n navTarget: createExtensionDataRef<NavTarget>('core.nav.target'),\n theme: createExtensionDataRef<AppTheme>('core.theme'),\n};\n","/*\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 { PortableSchema } from '../schema';\nimport { ExtensionDataRef } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport { BackstagePlugin } from './createPlugin';\n\n/** @public */\nexport type AnyExtensionDataMap = {\n [name in string]: ExtensionDataRef<unknown, { optional?: true }>;\n};\n\n/** @public */\nexport type AnyExtensionInputMap = {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataMap,\n { optional: boolean; singleton: boolean }\n >;\n};\n\n// TODO(Rugvip): This might be a quite useful utility type, maybe add to @backstage/types?\n/**\n * Utility type to expand type aliases into their equivalent type.\n * @ignore\n */\nexport type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;\n\n/**\n * Converts an extension data map into the matching concrete data values type.\n * @public\n */\nexport type ExtensionDataValues<TExtensionData extends AnyExtensionDataMap> = {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? never\n : DataName]: TExtensionData[DataName]['T'];\n} & {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? DataName\n : never]?: TExtensionData[DataName]['T'];\n};\n\n/**\n * Converts an extension input map into the matching concrete input values type.\n * @public\n */\nexport type ExtensionInputValues<\n TInputs extends { [name in string]: ExtensionInput<any, any> },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ExtensionDataValues<TInputs[InputName]['extensionData']>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ExtensionDataValues<TInputs[InputName]['extensionData']>>\n : Expand<\n ExtensionDataValues<TInputs[InputName]['extensionData']> | undefined\n >;\n};\n\n/** @public */\nexport interface CreateExtensionOptions<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig,\n> {\n id: string;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: TOutput;\n configSchema?: PortableSchema<TConfig>;\n factory(options: {\n source?: BackstagePlugin;\n bind(values: Expand<ExtensionDataValues<TOutput>>): void;\n config: TConfig;\n inputs: Expand<ExtensionInputValues<TInputs>>;\n }): void;\n}\n\n/** @public */\nexport interface Extension<TConfig> {\n $$type: '@backstage/Extension';\n id: string;\n attachTo: { id: string; input: string };\n disabled: boolean;\n inputs: AnyExtensionInputMap;\n output: AnyExtensionDataMap;\n configSchema?: PortableSchema<TConfig>;\n factory(options: {\n source?: BackstagePlugin;\n bind(values: ExtensionInputValues<any>): void;\n config: TConfig;\n inputs: Record<\n string,\n undefined | Record<string, unknown> | Array<Record<string, unknown>>\n >;\n }): void;\n}\n\n/** @public */\nexport function createExtension<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig = never,\n>(\n options: CreateExtensionOptions<TOutput, TInputs, TConfig>,\n): Extension<TConfig> {\n return {\n ...options,\n disabled: options.disabled ?? false,\n $$type: '@backstage/Extension',\n inputs: options.inputs ?? {},\n factory({ bind, config, inputs }) {\n // TODO: Simplify this, but TS wouldn't infer the input type for some reason\n return options.factory({\n bind,\n config,\n inputs: inputs as Expand<ExtensionInputValues<TInputs>>,\n });\n },\n };\n}\n","/*\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 { AnyExtensionDataMap } from './createExtension';\n\n/** @public */\nexport interface ExtensionInput<\n TExtensionData extends AnyExtensionDataMap,\n TConfig extends { singleton: boolean; optional: boolean },\n> {\n $$type: '@backstage/ExtensionInput';\n extensionData: TExtensionData;\n config: TConfig;\n}\n\n/** @public */\nexport function createExtensionInput<\n TExtensionData extends AnyExtensionDataMap,\n TConfig extends { singleton?: boolean; optional?: boolean },\n>(\n extensionData: TExtensionData,\n config?: TConfig,\n): ExtensionInput<\n TExtensionData,\n {\n singleton: TConfig['singleton'] extends true ? true : false;\n optional: TConfig['optional'] extends true ? true : false;\n }\n> {\n return {\n $$type: '@backstage/ExtensionInput',\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 },\n };\n}\n","/*\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 { AnyExternalRoutes, AnyRoutes } from '@backstage/core-plugin-api';\nimport { Extension } from './createExtension';\n\n/** @public */\nexport interface PluginOptions<\n Routes extends AnyRoutes,\n ExternalRoutes extends AnyExternalRoutes,\n> {\n id: string;\n routes?: Routes;\n externalRoutes?: ExternalRoutes;\n extensions?: Extension<unknown>[];\n}\n\n/** @public */\nexport interface BackstagePlugin<\n Routes extends AnyRoutes = AnyRoutes,\n ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,\n> {\n $$type: '@backstage/BackstagePlugin';\n id: string;\n extensions: Extension<unknown>[];\n routes: Routes;\n externalRoutes: ExternalRoutes;\n}\n\n/** @public */\nexport function createPlugin<\n Routes extends AnyRoutes = AnyRoutes,\n ExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,\n>(\n options: PluginOptions<Routes, ExternalRoutes>,\n): BackstagePlugin<Routes, ExternalRoutes> {\n return {\n ...options,\n routes: options.routes ?? ({} as Routes),\n externalRoutes: options.externalRoutes ?? ({} as ExternalRoutes),\n extensions: options.extensions ?? [],\n $$type: '@backstage/BackstagePlugin',\n };\n}\n","/*\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 { Extension } from './createExtension';\n\n/** @public */\nexport interface ExtensionOverridesOptions {\n extensions: Extension<unknown>[];\n}\n\n/** @public */\nexport interface ExtensionOverrides {\n $$type: '@backstage/ExtensionOverrides';\n}\n\n/** @internal */\nexport interface InternalExtensionOverrides extends ExtensionOverrides {\n version: string;\n extensions: Extension<unknown>[];\n}\n\n/** @public */\nexport function createExtensionOverrides(\n options: ExtensionOverridesOptions,\n): ExtensionOverrides {\n return {\n $$type: '@backstage/ExtensionOverrides',\n version: 'v1',\n extensions: options.extensions,\n } as InternalExtensionOverrides;\n}\n\n/** @internal */\nexport function toInternalExtensionOverrides(\n overrides: ExtensionOverrides,\n): InternalExtensionOverrides {\n const internal = overrides as InternalExtensionOverrides;\n if (internal.$$type !== '@backstage/ExtensionOverrides') {\n throw new Error(\n `Invalid translation resource, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid translation resource, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n","/*\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 { AnyApiFactory, AnyApiRef } from '@backstage/core-plugin-api';\nimport { PortableSchema } from '../schema';\nimport {\n ExtensionInputValues,\n createExtension,\n coreExtensionData,\n} from '../wiring';\nimport { AnyExtensionInputMap, Expand } from '../wiring/createExtension';\n\n/** @public */\nexport function createApiExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(\n options: (\n | {\n api: AnyApiRef;\n factory: (options: {\n config: TConfig;\n inputs: Expand<ExtensionInputValues<TInputs>>;\n }) => AnyApiFactory;\n }\n | {\n factory: AnyApiFactory;\n }\n ) & {\n configSchema?: PortableSchema<TConfig>;\n inputs?: TInputs;\n },\n) {\n const { factory, configSchema, inputs: extensionInputs } = options;\n\n const apiRef =\n 'api' in options ? options.api : (factory as { api: AnyApiRef }).api;\n\n return createExtension({\n id: `apis.${apiRef.id}`,\n attachTo: { id: 'core', input: 'apis' },\n inputs: extensionInputs,\n configSchema,\n output: {\n api: coreExtensionData.apiFactory,\n },\n factory({ bind, config, inputs }) {\n if (typeof factory === 'function') {\n bind({ api: factory({ config, inputs }) });\n } else {\n bind({ api: factory });\n }\n },\n });\n}\n","/*\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 { JsonObject } from '@backstage/types';\nimport { z, ZodSchema, ZodTypeDef } from 'zod';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { PortableSchema } from './types';\n\n/** @public */\nexport function createSchemaFromZod<TOutput, TInput>(\n schemaCreator: (zImpl: typeof z) => ZodSchema<TOutput, ZodTypeDef, TInput>,\n): PortableSchema<TOutput> {\n const schema = schemaCreator(z);\n return {\n // TODO: Types allow z.array etc here but it will break stuff\n parse: input => {\n const result = schema.safeParse(input);\n if (result.success) {\n return result.data;\n }\n\n throw new Error(result.error.issues.map(formatIssue).join('; '));\n },\n // TODO: Verify why we are not compatible with the latest zodToJsonSchema.\n schema: zodToJsonSchema(schema) as JsonObject,\n };\n}\n\nfunction formatIssue(issue: z.ZodIssue): string {\n if (issue.code === 'invalid_union') {\n return formatIssue(issue.unionErrors[0].issues[0]);\n }\n let message = issue.message;\n if (message === 'Required') {\n message = `Missing required value`;\n }\n if (issue.path.length) {\n message += ` at '${issue.path.join('.')}'`;\n }\n return message;\n}\n","/*\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 { RouteRef } from '@backstage/core-plugin-api';\nimport React from 'react';\nimport { ExtensionBoundary } from '../components';\nimport { createSchemaFromZod, PortableSchema } from '../schema';\nimport {\n coreExtensionData,\n createExtension,\n Extension,\n ExtensionInputValues,\n} from '../wiring';\nimport { AnyExtensionInputMap, Expand } from '../wiring/createExtension';\n\n/**\n * Helper for creating extensions for a routable React page component.\n *\n * @public\n */\nexport function createPageExtension<\n TConfig extends { path: string },\n TInputs extends AnyExtensionInputMap,\n>(\n options: (\n | {\n defaultPath: string;\n }\n | {\n configSchema: PortableSchema<TConfig>;\n }\n ) & {\n id: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n routeRef?: RouteRef;\n loader: (options: {\n config: TConfig;\n inputs: Expand<ExtensionInputValues<TInputs>>;\n }) => Promise<JSX.Element>;\n },\n): Extension<TConfig> {\n const configSchema =\n 'configSchema' in options\n ? options.configSchema\n : (createSchemaFromZod(z =>\n z.object({ path: z.string().default(options.defaultPath) }),\n ) as PortableSchema<TConfig>);\n\n return createExtension({\n id: options.id,\n attachTo: options.attachTo ?? { id: 'core.routes', input: 'routes' },\n disabled: options.disabled,\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef.optional(),\n },\n inputs: options.inputs,\n configSchema,\n factory({ bind, config, inputs, source }) {\n const LazyComponent = React.lazy(() =>\n options\n .loader({ config, inputs })\n .then(element => ({ default: () => element })),\n );\n\n bind({\n path: config.path,\n element: (\n <ExtensionBoundary source={source}>\n <React.Suspense fallback=\"...\">\n <LazyComponent />\n </React.Suspense>\n </ExtensionBoundary>\n ),\n routeRef: options.routeRef,\n });\n },\n });\n}\n","/*\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 { IconComponent, RouteRef } from '@backstage/core-plugin-api';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\nimport { coreExtensionData, createExtension } from '../wiring';\n\n/**\n * Helper for creating extensions for a nav item.\n * @public\n */\nexport function createNavItemExtension(options: {\n id: string;\n routeRef: RouteRef;\n title: string;\n icon: IconComponent;\n}) {\n const { id, routeRef, title, icon } = options;\n return createExtension({\n id,\n attachTo: { id: 'core.nav', input: 'items' },\n configSchema: createSchemaFromZod(z =>\n z.object({\n title: z.string().default(title),\n }),\n ),\n output: {\n navTarget: coreExtensionData.navTarget,\n },\n factory: ({ bind, config }) => {\n bind({\n navTarget: {\n title: config.title,\n icon,\n routeRef,\n },\n });\n },\n });\n}\n","/*\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 { createExtension, coreExtensionData } from '../wiring';\nimport { AppTheme } from '@backstage/core-plugin-api';\n\n/** @public */\nexport function createThemeExtension(theme: AppTheme) {\n return createExtension({\n id: `themes.${theme.id}`,\n attachTo: { id: 'core', input: 'themes' },\n output: {\n theme: coreExtensionData.theme,\n },\n factory({ bind }) {\n bind({ theme });\n },\n });\n}\n"],"names":[],"mappings":";;;;AA0BO,SAAS,kBAAkB,KAA+B,EAAA;AAC/D,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,MAAM,QAAS,CAAA,CAAA;AAC3B;;ACSO,SAAS,uBACd,EACqC,EAAA;AACrC,EAAO,OAAA;AAAA,IACL,EAAA;AAAA,IACA,MAAQ,EAAA,6BAAA;AAAA,IACR,QAAQ,EAAC;AAAA,IACT,QAAW,GAAA;AACT,MAAO,OAAA,EAAE,GAAG,IAAA,EAAM,MAAQ,EAAA,EAAE,GAAG,IAAK,CAAA,MAAA,EAAQ,QAAU,EAAA,IAAA,EAAO,EAAA,CAAA;AAAA,KAC/D;AAAA,GACF,CAAA;AACF;;ACfO,MAAM,iBAAoB,GAAA;AAAA,EAC/B,YAAA,EAAc,uBAAoC,mBAAmB,CAAA;AAAA,EACrE,SAAA,EAAW,uBAA+B,mBAAmB,CAAA;AAAA,EAC7D,UAAA,EAAY,uBAAsC,kBAAkB,CAAA;AAAA,EACpE,QAAA,EAAU,uBAAiC,kBAAkB,CAAA;AAAA,EAC7D,SAAA,EAAW,uBAAkC,iBAAiB,CAAA;AAAA,EAC9D,KAAA,EAAO,uBAAiC,YAAY,CAAA;AACtD;;AC4EO,SAAS,gBAKd,OACoB,EAAA;AA1HtB,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA2HE,EAAO,OAAA;AAAA,IACL,GAAG,OAAA;AAAA,IACH,QAAA,EAAA,CAAU,EAAQ,GAAA,OAAA,CAAA,QAAA,KAAR,IAAoB,GAAA,EAAA,GAAA,KAAA;AAAA,IAC9B,MAAQ,EAAA,sBAAA;AAAA,IACR,MAAQ,EAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,MAAR,KAAA,IA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A,IAC3C,YAAc,EAAA,mBAAA;AAAA,MAAoB,CAAA,CAAA,KAChC,EAAE,MAAO,CAAA;AAAA,QACP,KAAO,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAQ,KAAK,CAAA;AAAA,OAChC,CAAA;AAAA,KACH;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,WAAW,iBAAkB,CAAA,SAAA;AAAA,KAC/B;AAAA,IACA,OAAS,EAAA,CAAC,EAAE,IAAA,EAAM,QAAa,KAAA;AAC7B,MAAK,IAAA,CAAA;AAAA,QACH,SAAW,EAAA;AAAA,UACT,OAAO,MAAO,CAAA,KAAA;AAAA,UACd,IAAA;AAAA,UACA,QAAA;AAAA,SACF;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACD,CAAA,CAAA;AACH;;AChCO,SAAS,qBAAqB,KAAiB,EAAA;AACpD,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,EAAA,EAAI,CAAU,OAAA,EAAA,KAAA,CAAM,EAAE,CAAA,CAAA;AAAA,IACtB,QAAU,EAAA,EAAE,EAAI,EAAA,MAAA,EAAQ,OAAO,QAAS,EAAA;AAAA,IACxC,MAAQ,EAAA;AAAA,MACN,OAAO,iBAAkB,CAAA,KAAA;AAAA,KAC3B;AAAA,IACA,OAAA,CAAQ,EAAE,IAAA,EAAQ,EAAA;AAChB,MAAK,IAAA,CAAA,EAAE,OAAO,CAAA,CAAA;AAAA,KAChB;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-plugin-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"postpack": "backstage-cli package postpack"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@backstage/cli": "^0.23.0
|
|
27
|
-
"@backstage/frontend-app-api": "^0.2.0
|
|
28
|
-
"@backstage/test-utils": "^1.4.4
|
|
29
|
-
"@testing-library/jest-dom": "^
|
|
26
|
+
"@backstage/cli": "^0.23.0",
|
|
27
|
+
"@backstage/frontend-app-api": "^0.2.0",
|
|
28
|
+
"@backstage/test-utils": "^1.4.4",
|
|
29
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
30
30
|
"@testing-library/react": "^12.1.3"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/core-plugin-api": "^1.7.0
|
|
40
|
+
"@backstage/core-plugin-api": "^1.7.0",
|
|
41
41
|
"@backstage/types": "^1.1.1",
|
|
42
42
|
"@types/react": "^16.13.1 || ^17.0.0",
|
|
43
43
|
"lodash": "^4.17.21",
|