@backstage/frontend-plugin-api 0.6.7 → 0.6.8-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 +71 -0
- package/dist/components/ExtensionBoundary.esm.js +5 -1
- package/dist/components/ExtensionBoundary.esm.js.map +1 -1
- package/dist/extensions/IconBundleBlueprint.esm.js +20 -0
- package/dist/extensions/IconBundleBlueprint.esm.js.map +1 -0
- package/dist/extensions/createApiExtension.esm.js +5 -2
- package/dist/extensions/createApiExtension.esm.js.map +1 -1
- package/dist/extensions/createAppRootWrapperExtension.esm.js +1 -3
- package/dist/extensions/createAppRootWrapperExtension.esm.js.map +1 -1
- package/dist/extensions/createComponentExtension.esm.js +3 -2
- package/dist/extensions/createComponentExtension.esm.js.map +1 -1
- package/dist/extensions/createNavItemExtension.esm.js +3 -2
- package/dist/extensions/createNavItemExtension.esm.js.map +1 -1
- package/dist/extensions/createNavLogoExtension.esm.js +3 -2
- package/dist/extensions/createNavLogoExtension.esm.js.map +1 -1
- package/dist/extensions/createPageExtension.esm.js +1 -1
- package/dist/extensions/createPageExtension.esm.js.map +1 -1
- package/dist/extensions/createRouterExtension.esm.js +1 -3
- package/dist/extensions/createRouterExtension.esm.js.map +1 -1
- package/dist/extensions/createSignInPageExtension.esm.js +3 -2
- package/dist/extensions/createSignInPageExtension.esm.js.map +1 -1
- package/dist/extensions/createThemeExtension.esm.js +5 -2
- package/dist/extensions/createThemeExtension.esm.js.map +1 -1
- package/dist/extensions/createTranslationExtension.esm.js +3 -2
- package/dist/extensions/createTranslationExtension.esm.js.map +1 -1
- package/dist/index.d.ts +114 -21
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/wiring/coreExtensionData.esm.js +5 -3
- package/dist/wiring/coreExtensionData.esm.js.map +1 -1
- package/dist/wiring/createExtension.esm.js.map +1 -1
- package/dist/wiring/createExtensionBlueprint.esm.js +51 -0
- package/dist/wiring/createExtensionBlueprint.esm.js.map +1 -0
- package/dist/wiring/createExtensionDataRef.esm.js +11 -3
- package/dist/wiring/createExtensionDataRef.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# @backstage/frontend-plugin-api
|
|
2
2
|
|
|
3
|
+
## 0.6.8-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4e53ad6: Introduce a new way to encapsulate extension kinds that replaces the extension creator pattern with `createExtensionBlueprint`
|
|
8
|
+
|
|
9
|
+
This allows the creation of extension instances with the following pattern:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// create the extension blueprint which is used to create instances
|
|
13
|
+
const EntityCardBlueprint = createExtensionBlueprint({
|
|
14
|
+
kind: 'entity-card',
|
|
15
|
+
attachTo: { id: 'test', input: 'default' },
|
|
16
|
+
output: {
|
|
17
|
+
element: coreExtensionData.reactElement,
|
|
18
|
+
},
|
|
19
|
+
factory(params: { text: string }) {
|
|
20
|
+
return {
|
|
21
|
+
element: <h1>{params.text}</h1>,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// create an instance of the extension blueprint with params
|
|
27
|
+
const testExtension = EntityCardBlueprint.make({
|
|
28
|
+
name: 'foo',
|
|
29
|
+
params: {
|
|
30
|
+
text: 'Hello World',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- 9b89b82: The `ExtensionBoundary` now by default infers whether it's routable from whether it outputs a route path.
|
|
36
|
+
- 7777b5f: Added a new `IconBundleBlueprint` that lets you create icon bundle extensions that can be installed in an App in order to override or add new app icons.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { IconBundleBlueprint } from '@backstage/frontend-plugin-api';
|
|
40
|
+
|
|
41
|
+
const exampleIconBundle = IconBundleBlueprint.make({
|
|
42
|
+
name: 'example-bundle',
|
|
43
|
+
params: {
|
|
44
|
+
icons: {
|
|
45
|
+
user: MyOwnUserIcon,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- 31bfc44: Extension data references can now be defined in a way that encapsulates the ID string in the type, in addition to the data type itself. The old way of creating extension data references is deprecated and will be removed in a future release.
|
|
52
|
+
|
|
53
|
+
For example, the following code:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
export const myExtension =
|
|
57
|
+
createExtensionDataRef<MyType>('my-plugin.my-data');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Should be updated to the following:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
export const myExtension = createExtensionDataRef<MyType>().with({
|
|
64
|
+
id: 'my-plugin.my-data',
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- Updated dependencies
|
|
69
|
+
- @backstage/core-components@0.14.10-next.0
|
|
70
|
+
- @backstage/core-plugin-api@1.9.3
|
|
71
|
+
- @backstage/types@1.1.1
|
|
72
|
+
- @backstage/version-bridge@1.0.8
|
|
73
|
+
|
|
3
74
|
## 0.6.7
|
|
4
75
|
|
|
5
76
|
### Patch Changes
|
|
@@ -8,6 +8,7 @@ import '../apis/definitions/IconsApi.esm.js';
|
|
|
8
8
|
import '../apis/definitions/RouteResolutionApi.esm.js';
|
|
9
9
|
import '../apis/definitions/AnalyticsApi.esm.js';
|
|
10
10
|
import { coreComponentRefs } from './coreComponentRefs.esm.js';
|
|
11
|
+
import { coreExtensionData } from '../wiring/coreExtensionData.esm.js';
|
|
11
12
|
|
|
12
13
|
const RouteTracker = (props) => {
|
|
13
14
|
const { disableTracking, children } = props;
|
|
@@ -20,6 +21,9 @@ const RouteTracker = (props) => {
|
|
|
20
21
|
};
|
|
21
22
|
function ExtensionBoundary(props) {
|
|
22
23
|
const { node, routable, children } = props;
|
|
24
|
+
const doesOutputRoutePath = Boolean(
|
|
25
|
+
node.instance?.getData(coreExtensionData.routePath)
|
|
26
|
+
);
|
|
23
27
|
const plugin = node.spec.source;
|
|
24
28
|
const Progress = useComponentRef(coreComponentRefs.progress);
|
|
25
29
|
const fallback = useComponentRef(coreComponentRefs.errorBoundaryFallback);
|
|
@@ -27,7 +31,7 @@ function ExtensionBoundary(props) {
|
|
|
27
31
|
extensionId: node.spec.id,
|
|
28
32
|
pluginId: node.spec.source?.id ?? "app"
|
|
29
33
|
};
|
|
30
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Progress, null) }, /* @__PURE__ */ React.createElement(ErrorBoundary, { plugin, Fallback: fallback }, /* @__PURE__ */ React.createElement(AnalyticsContext, { attributes }, /* @__PURE__ */ React.createElement(RouteTracker, { disableTracking: !routable }, children))));
|
|
34
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Progress, null) }, /* @__PURE__ */ React.createElement(ErrorBoundary, { plugin, Fallback: fallback }, /* @__PURE__ */ React.createElement(AnalyticsContext, { attributes }, /* @__PURE__ */ React.createElement(RouteTracker, { disableTracking: !(routable ?? doesOutputRoutePath) }, children))));
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
export { ExtensionBoundary };
|
|
@@ -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 React, {\n PropsWithChildren,\n ReactNode,\n Suspense,\n useEffect,\n} from 'react';\nimport { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';\nimport { ErrorBoundary } from './ErrorBoundary';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routableExtensionRenderedEvent } from '../../../core-plugin-api/src/analytics/Tracker';\nimport { AppNode, useComponentRef } from '../apis';\nimport { coreComponentRefs } from './coreComponentRefs';\n\ntype RouteTrackerProps = PropsWithChildren<{\n disableTracking?: boolean;\n}>;\n\nconst RouteTracker = (props: RouteTrackerProps) => {\n const { disableTracking, 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 (disableTracking) return;\n analytics.captureEvent(routableExtensionRenderedEvent, '');\n }, [analytics, disableTracking]);\n\n return <>{children}</>;\n};\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n node: AppNode;\n routable?: boolean;\n children: ReactNode;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n const { node, routable, children } = props;\n\n const plugin = node.spec.source;\n const Progress = useComponentRef(coreComponentRefs.progress);\n const fallback = useComponentRef(coreComponentRefs.errorBoundaryFallback);\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: node.spec.source?.id ?? 'app',\n };\n\n return (\n <Suspense fallback={<Progress />}>\n <ErrorBoundary plugin={plugin} Fallback={fallback}>\n <AnalyticsContext attributes={attributes}>\n <RouteTracker disableTracking={!routable}
|
|
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 React, {\n PropsWithChildren,\n ReactNode,\n Suspense,\n useEffect,\n} from 'react';\nimport { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';\nimport { ErrorBoundary } from './ErrorBoundary';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routableExtensionRenderedEvent } from '../../../core-plugin-api/src/analytics/Tracker';\nimport { AppNode, useComponentRef } from '../apis';\nimport { coreComponentRefs } from './coreComponentRefs';\nimport { coreExtensionData } from '../wiring';\n\ntype RouteTrackerProps = PropsWithChildren<{\n disableTracking?: boolean;\n}>;\n\nconst RouteTracker = (props: RouteTrackerProps) => {\n const { disableTracking, 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 (disableTracking) return;\n analytics.captureEvent(routableExtensionRenderedEvent, '');\n }, [analytics, disableTracking]);\n\n return <>{children}</>;\n};\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n node: AppNode;\n /**\n * This explicitly marks the extension as routable for the purpose of\n * capturing analytics events. If not provided, the extension boundary will be\n * marked as routable if it outputs a routePath.\n */\n routable?: boolean;\n children: ReactNode;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n const { node, routable, children } = props;\n\n const doesOutputRoutePath = Boolean(\n node.instance?.getData(coreExtensionData.routePath),\n );\n\n const plugin = node.spec.source;\n const Progress = useComponentRef(coreComponentRefs.progress);\n const fallback = useComponentRef(coreComponentRefs.errorBoundaryFallback);\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: node.spec.source?.id ?? 'app',\n };\n\n return (\n <Suspense fallback={<Progress />}>\n <ErrorBoundary plugin={plugin} Fallback={fallback}>\n <AnalyticsContext attributes={attributes}>\n <RouteTracker disableTracking={!(routable ?? doesOutputRoutePath)}>\n {children}\n </RouteTracker>\n </AnalyticsContext>\n </ErrorBoundary>\n </Suspense>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAkCA,MAAM,YAAA,GAAe,CAAC,KAA6B,KAAA;AACjD,EAAM,MAAA,EAAE,eAAiB,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AACtC,EAAA,MAAM,YAAY,YAAa,EAAA,CAAA;AAM/B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,eAAiB,EAAA,OAAA;AACrB,IAAU,SAAA,CAAA,YAAA,CAAa,gCAAgC,EAAE,CAAA,CAAA;AAAA,GACxD,EAAA,CAAC,SAAW,EAAA,eAAe,CAAC,CAAA,CAAA;AAE/B,EAAA,iEAAU,QAAS,CAAA,CAAA;AACrB,CAAA,CAAA;AAeO,SAAS,kBAAkB,KAA+B,EAAA;AAC/D,EAAA,MAAM,EAAE,IAAA,EAAM,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AAErC,EAAA,MAAM,mBAAsB,GAAA,OAAA;AAAA,IAC1B,IAAK,CAAA,QAAA,EAAU,OAAQ,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAAA,GACpD,CAAA;AAEA,EAAM,MAAA,MAAA,GAAS,KAAK,IAAK,CAAA,MAAA,CAAA;AACzB,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,QAAQ,CAAA,CAAA;AAC3D,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,qBAAqB,CAAA,CAAA;AAGxE,EAAA,MAAM,UAAa,GAAA;AAAA,IACjB,WAAA,EAAa,KAAK,IAAK,CAAA,EAAA;AAAA,IACvB,QAAU,EAAA,IAAA,CAAK,IAAK,CAAA,MAAA,EAAQ,EAAM,IAAA,KAAA;AAAA,GACpC,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,YAAS,QAAU,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAS,CAC5B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,MAAA,EAAgB,QAAU,EAAA,QAAA,EAAA,sCACtC,gBAAiB,EAAA,EAAA,UAAA,EAAA,kBACf,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,eAAiB,EAAA,EAAE,YAAY,mBAC1C,CAAA,EAAA,EAAA,QACH,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
2
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
3
|
+
import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
|
|
4
|
+
|
|
5
|
+
const iconsDataRef = createExtensionDataRef().with({ id: "core.icons" });
|
|
6
|
+
const IconBundleBlueprint = createExtensionBlueprint({
|
|
7
|
+
kind: "icon-bundle",
|
|
8
|
+
namespace: "app",
|
|
9
|
+
attachTo: { id: "app", input: "icons" },
|
|
10
|
+
output: {
|
|
11
|
+
icons: iconsDataRef
|
|
12
|
+
},
|
|
13
|
+
factory: (params) => params,
|
|
14
|
+
dataRefs: {
|
|
15
|
+
icons: iconsDataRef
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { IconBundleBlueprint };
|
|
20
|
+
//# sourceMappingURL=IconBundleBlueprint.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconBundleBlueprint.esm.js","sources":["../../src/extensions/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 */\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/** @public */\nexport const IconBundleBlueprint = createExtensionBlueprint({\n kind: 'icon-bundle',\n namespace: 'app',\n attachTo: { id: 'app', input: 'icons' },\n output: {\n icons: iconsDataRef,\n },\n factory: (params: { icons: { [key in string]: IconComponent } }) => params,\n dataRefs: {\n icons: iconsDataRef,\n },\n});\n"],"names":[],"mappings":";;;;AAkBA,MAAM,eAAe,sBAElB,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,cAAc,CAAA,CAAA;AAGvB,MAAM,sBAAsB,wBAAyB,CAAA;AAAA,EAC1D,IAAM,EAAA,aAAA;AAAA,EACN,SAAW,EAAA,KAAA;AAAA,EACX,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,OAAQ,EAAA;AAAA,EACtC,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,YAAA;AAAA,GACT;AAAA,EACA,OAAA,EAAS,CAAC,MAA0D,KAAA,MAAA;AAAA,EACpE,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,YAAA;AAAA,GACT;AACF,CAAC;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
2
2
|
import { createExtension } from '../wiring/createExtension.esm.js';
|
|
3
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
3
4
|
|
|
4
5
|
function createApiExtension(options) {
|
|
5
6
|
const { factory, configSchema, inputs: extensionInputs } = options;
|
|
@@ -24,7 +25,9 @@ function createApiExtension(options) {
|
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
((createApiExtension2) => {
|
|
27
|
-
createApiExtension2.factoryDataRef = createExtensionDataRef(
|
|
28
|
+
createApiExtension2.factoryDataRef = createExtensionDataRef().with({
|
|
29
|
+
id: "core.api.factory"
|
|
30
|
+
});
|
|
28
31
|
})(createApiExtension || (createApiExtension = {}));
|
|
29
32
|
|
|
30
33
|
export { createApiExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createApiExtension.esm.js","sources":["../../src/extensions/createApiExtension.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 { AnyApiFactory, AnyApiRef } from '@backstage/core-plugin-api';\nimport { PortableSchema } from '../schema';\nimport {\n ResolvedExtensionInputs,\n createExtension,\n createExtensionDataRef,\n} from '../wiring';\nimport { AnyExtensionInputMap } from '../wiring/createExtension';\nimport { Expand } from '../types';\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<ResolvedExtensionInputs<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 kind: 'api',\n // Since ApiRef IDs use a global namespace we use the namespace here in order to override\n // potential plugin IDs and always end up with the format `api:<api-ref-id>`\n namespace: apiRef.id,\n attachTo: { id: 'app', input: 'apis' },\n inputs: extensionInputs,\n configSchema,\n output: {\n api: createApiExtension.factoryDataRef,\n },\n factory({ config, inputs }) {\n if (typeof factory === 'function') {\n return { api: factory({ config, inputs }) };\n }\n return { api: factory };\n },\n });\n}\n\n/** @public */\nexport namespace createApiExtension {\n export const factoryDataRef
|
|
1
|
+
{"version":3,"file":"createApiExtension.esm.js","sources":["../../src/extensions/createApiExtension.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 { AnyApiFactory, AnyApiRef } from '@backstage/core-plugin-api';\nimport { PortableSchema } from '../schema';\nimport {\n ResolvedExtensionInputs,\n createExtension,\n createExtensionDataRef,\n} from '../wiring';\nimport { AnyExtensionInputMap } from '../wiring/createExtension';\nimport { Expand } from '../types';\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<ResolvedExtensionInputs<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 kind: 'api',\n // Since ApiRef IDs use a global namespace we use the namespace here in order to override\n // potential plugin IDs and always end up with the format `api:<api-ref-id>`\n namespace: apiRef.id,\n attachTo: { id: 'app', input: 'apis' },\n inputs: extensionInputs,\n configSchema,\n output: {\n api: createApiExtension.factoryDataRef,\n },\n factory({ config, inputs }) {\n if (typeof factory === 'function') {\n return { api: factory({ config, inputs }) };\n }\n return { api: factory };\n },\n });\n}\n\n/** @public */\nexport namespace createApiExtension {\n export const factoryDataRef = createExtensionDataRef<AnyApiFactory>().with({\n id: 'core.api.factory',\n });\n}\n"],"names":["createApiExtension"],"mappings":";;;;AA2BO,SAAS,mBAId,OAeA,EAAA;AACA,EAAA,MAAM,EAAE,OAAA,EAAS,YAAc,EAAA,MAAA,EAAQ,iBAAoB,GAAA,OAAA,CAAA;AAE3D,EAAA,MAAM,MACJ,GAAA,KAAA,IAAS,OAAU,GAAA,OAAA,CAAQ,MAAO,OAA+B,CAAA,GAAA,CAAA;AAEnE,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,KAAA;AAAA;AAAA;AAAA,IAGN,WAAW,MAAO,CAAA,EAAA;AAAA,IAClB,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,MAAO,EAAA;AAAA,IACrC,MAAQ,EAAA,eAAA;AAAA,IACR,YAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAK,kBAAmB,CAAA,cAAA;AAAA,KAC1B;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAU,EAAA;AAC1B,MAAI,IAAA,OAAO,YAAY,UAAY,EAAA;AACjC,QAAA,OAAO,EAAE,GAAK,EAAA,OAAA,CAAQ,EAAE,MAAQ,EAAA,MAAA,EAAQ,CAAE,EAAA,CAAA;AAAA,OAC5C;AACA,MAAO,OAAA,EAAE,KAAK,OAAQ,EAAA,CAAA;AAAA,KACxB;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,mBAAV,KAAA;AACE,EAAMA,mBAAA,CAAA,cAAA,GAAiB,sBAAsC,EAAA,CAAE,IAAK,CAAA;AAAA,IACzE,EAAI,EAAA,kBAAA;AAAA,GACL,CAAA,CAAA;AAAA,CAHc,EAAA,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -25,9 +25,7 @@ function createAppRootWrapperExtension(options) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
((createAppRootWrapperExtension2) => {
|
|
28
|
-
createAppRootWrapperExtension2.componentDataRef = createExtensionDataRef(
|
|
29
|
-
"app.root.wrapper"
|
|
30
|
-
);
|
|
28
|
+
createAppRootWrapperExtension2.componentDataRef = createExtensionDataRef().with({ id: "app.root.wrapper" });
|
|
31
29
|
})(createAppRootWrapperExtension || (createAppRootWrapperExtension = {}));
|
|
32
30
|
|
|
33
31
|
export { createAppRootWrapperExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAppRootWrapperExtension.esm.js","sources":["../../src/extensions/createAppRootWrapperExtension.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 React, { ComponentType, PropsWithChildren } from 'react';\nimport { PortableSchema } from '../schema/types';\nimport {\n AnyExtensionInputMap,\n ExtensionDefinition,\n ResolvedExtensionInputs,\n createExtension,\n} from '../wiring/createExtension';\nimport { createExtensionDataRef } from '../wiring/createExtensionDataRef';\nimport { Expand } from '../types';\n\n/**\n * Creates an extension that renders 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 */\nexport function createAppRootWrapperExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n configSchema?: PortableSchema<TConfig>;\n disabled?: boolean;\n inputs?: TInputs;\n Component: ComponentType<\n PropsWithChildren<{\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n config: TConfig;\n }>\n >;\n}): ExtensionDefinition<TConfig> {\n return createExtension({\n kind: 'app-root-wrapper',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? { id: 'app/root', input: 'wrappers' },\n configSchema: options.configSchema,\n disabled: options.disabled,\n inputs: options.inputs,\n output: {\n component: createAppRootWrapperExtension.componentDataRef,\n },\n factory({ inputs, config }) {\n const Component = (props: PropsWithChildren<{}>) => {\n return (\n <options.Component inputs={inputs} config={config}>\n {props.children}\n </options.Component>\n );\n };\n return {\n component: Component,\n };\n },\n });\n}\n\n/** @public */\nexport namespace createAppRootWrapperExtension {\n export const componentDataRef
|
|
1
|
+
{"version":3,"file":"createAppRootWrapperExtension.esm.js","sources":["../../src/extensions/createAppRootWrapperExtension.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 React, { ComponentType, PropsWithChildren } from 'react';\nimport { PortableSchema } from '../schema/types';\nimport {\n AnyExtensionInputMap,\n ExtensionDefinition,\n ResolvedExtensionInputs,\n createExtension,\n} from '../wiring/createExtension';\nimport { createExtensionDataRef } from '../wiring/createExtensionDataRef';\nimport { Expand } from '../types';\n\n/**\n * Creates an extension that renders 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 */\nexport function createAppRootWrapperExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n configSchema?: PortableSchema<TConfig>;\n disabled?: boolean;\n inputs?: TInputs;\n Component: ComponentType<\n PropsWithChildren<{\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n config: TConfig;\n }>\n >;\n}): ExtensionDefinition<TConfig> {\n return createExtension({\n kind: 'app-root-wrapper',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? { id: 'app/root', input: 'wrappers' },\n configSchema: options.configSchema,\n disabled: options.disabled,\n inputs: options.inputs,\n output: {\n component: createAppRootWrapperExtension.componentDataRef,\n },\n factory({ inputs, config }) {\n const Component = (props: PropsWithChildren<{}>) => {\n return (\n <options.Component inputs={inputs} config={config}>\n {props.children}\n </options.Component>\n );\n };\n return {\n component: Component,\n };\n },\n });\n}\n\n/** @public */\nexport namespace createAppRootWrapperExtension {\n export const componentDataRef = createExtensionDataRef<\n ComponentType<PropsWithChildren<{}>>\n >().with({ id: 'app.root.wrapper' });\n}\n"],"names":["createAppRootWrapperExtension"],"mappings":";;;;AAkCO,SAAS,8BAGd,OAa+B,EAAA;AAC/B,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,kBAAA;AAAA,IACN,WAAW,OAAQ,CAAA,SAAA;AAAA,IACnB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,UAAU,OAAQ,CAAA,QAAA,IAAY,EAAE,EAAI,EAAA,UAAA,EAAY,OAAO,UAAW,EAAA;AAAA,IAClE,cAAc,OAAQ,CAAA,YAAA;AAAA,IACtB,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,WAAW,6BAA8B,CAAA,gBAAA;AAAA,KAC3C;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAU,EAAA;AAC1B,MAAM,MAAA,SAAA,GAAY,CAAC,KAAiC,KAAA;AAClD,QAAA,2CACG,OAAQ,CAAA,SAAA,EAAR,EAAkB,MAAgB,EAAA,MAAA,EAAA,EAChC,MAAM,QACT,CAAA,CAAA;AAAA,OAEJ,CAAA;AACA,MAAO,OAAA;AAAA,QACL,SAAW,EAAA,SAAA;AAAA,OACb,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,8BAAV,KAAA;AACE,EAAMA,8BAAAA,CAAA,mBAAmB,sBAE9B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,oBAAoB,CAAA,CAAA;AAAA,CAHpB,EAAA,6BAAA,KAAA,6BAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lazy } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
3
3
|
import { createExtension } from '../wiring/createExtension.esm.js';
|
|
4
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
4
5
|
|
|
5
6
|
function createComponentExtension(options) {
|
|
6
7
|
return createExtension({
|
|
@@ -39,7 +40,7 @@ function createComponentExtension(options) {
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
((createComponentExtension2) => {
|
|
42
|
-
createComponentExtension2.componentDataRef = createExtensionDataRef("core.component.component");
|
|
43
|
+
createComponentExtension2.componentDataRef = createExtensionDataRef().with({ id: "core.component.component" });
|
|
43
44
|
})(createComponentExtension || (createComponentExtension = {}));
|
|
44
45
|
|
|
45
46
|
export { createComponentExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponentExtension.esm.js","sources":["../../src/extensions/createComponentExtension.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 { lazy, ComponentType } from 'react';\nimport {\n AnyExtensionInputMap,\n ResolvedExtensionInputs,\n createExtension,\n createExtensionDataRef,\n} from '../wiring';\nimport { Expand } from '../types';\nimport { PortableSchema } from '../schema';\nimport { ComponentRef } from '../components';\n\n/** @public */\nexport function createComponentExtension<\n TProps extends {},\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n ref: ComponentRef<TProps>;\n name?: string;\n disabled?: boolean;\n inputs?: TInputs;\n configSchema?: PortableSchema<TConfig>;\n loader:\n | {\n lazy: (values: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<ComponentType<TProps>>;\n }\n | {\n sync: (values: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => ComponentType<TProps>;\n };\n}) {\n return createExtension({\n kind: 'component',\n namespace: options.ref.id,\n name: options.name,\n attachTo: { id: 'app', input: 'components' },\n inputs: options.inputs,\n disabled: options.disabled,\n configSchema: options.configSchema,\n output: {\n component: createComponentExtension.componentDataRef,\n },\n factory({ config, inputs }) {\n if ('sync' in options.loader) {\n return {\n component: {\n ref: options.ref,\n impl: options.loader.sync({ config, inputs }) as ComponentType,\n },\n };\n }\n const lazyLoader = options.loader.lazy;\n const ExtensionComponent = lazy(() =>\n lazyLoader({ config, inputs }).then(Component => ({\n default: Component,\n })),\n ) as unknown as ComponentType;\n\n return {\n component: {\n ref: options.ref,\n impl: ExtensionComponent,\n },\n };\n },\n });\n}\n\n/** @public */\nexport namespace createComponentExtension {\n export const componentDataRef = createExtensionDataRef<{\n ref: ComponentRef;\n impl: ComponentType;\n }>('core.component.component');\n}\n"],"names":["createComponentExtension"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createComponentExtension.esm.js","sources":["../../src/extensions/createComponentExtension.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 { lazy, ComponentType } from 'react';\nimport {\n AnyExtensionInputMap,\n ResolvedExtensionInputs,\n createExtension,\n createExtensionDataRef,\n} from '../wiring';\nimport { Expand } from '../types';\nimport { PortableSchema } from '../schema';\nimport { ComponentRef } from '../components';\n\n/** @public */\nexport function createComponentExtension<\n TProps extends {},\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n ref: ComponentRef<TProps>;\n name?: string;\n disabled?: boolean;\n inputs?: TInputs;\n configSchema?: PortableSchema<TConfig>;\n loader:\n | {\n lazy: (values: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<ComponentType<TProps>>;\n }\n | {\n sync: (values: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => ComponentType<TProps>;\n };\n}) {\n return createExtension({\n kind: 'component',\n namespace: options.ref.id,\n name: options.name,\n attachTo: { id: 'app', input: 'components' },\n inputs: options.inputs,\n disabled: options.disabled,\n configSchema: options.configSchema,\n output: {\n component: createComponentExtension.componentDataRef,\n },\n factory({ config, inputs }) {\n if ('sync' in options.loader) {\n return {\n component: {\n ref: options.ref,\n impl: options.loader.sync({ config, inputs }) as ComponentType,\n },\n };\n }\n const lazyLoader = options.loader.lazy;\n const ExtensionComponent = lazy(() =>\n lazyLoader({ config, inputs }).then(Component => ({\n default: Component,\n })),\n ) as unknown as ComponentType;\n\n return {\n component: {\n ref: options.ref,\n impl: ExtensionComponent,\n },\n };\n },\n });\n}\n\n/** @public */\nexport namespace createComponentExtension {\n export const componentDataRef = createExtensionDataRef<{\n ref: ComponentRef;\n impl: ComponentType;\n }>().with({ id: 'core.component.component' });\n}\n"],"names":["createComponentExtension"],"mappings":";;;;;AA4BO,SAAS,yBAId,OAmBC,EAAA;AACD,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,WAAA;AAAA,IACN,SAAA,EAAW,QAAQ,GAAI,CAAA,EAAA;AAAA,IACvB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,YAAa,EAAA;AAAA,IAC3C,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,cAAc,OAAQ,CAAA,YAAA;AAAA,IACtB,MAAQ,EAAA;AAAA,MACN,WAAW,wBAAyB,CAAA,gBAAA;AAAA,KACtC;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAU,EAAA;AAC1B,MAAI,IAAA,MAAA,IAAU,QAAQ,MAAQ,EAAA;AAC5B,QAAO,OAAA;AAAA,UACL,SAAW,EAAA;AAAA,YACT,KAAK,OAAQ,CAAA,GAAA;AAAA,YACb,MAAM,OAAQ,CAAA,MAAA,CAAO,KAAK,EAAE,MAAA,EAAQ,QAAQ,CAAA;AAAA,WAC9C;AAAA,SACF,CAAA;AAAA,OACF;AACA,MAAM,MAAA,UAAA,GAAa,QAAQ,MAAO,CAAA,IAAA,CAAA;AAClC,MAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,QAAK,MAC9B,WAAW,EAAE,MAAA,EAAQ,QAAQ,CAAA,CAAE,KAAK,CAAc,SAAA,MAAA;AAAA,UAChD,OAAS,EAAA,SAAA;AAAA,SACT,CAAA,CAAA;AAAA,OACJ,CAAA;AAEA,MAAO,OAAA;AAAA,QACL,SAAW,EAAA;AAAA,UACT,KAAK,OAAQ,CAAA,GAAA;AAAA,UACb,IAAM,EAAA,kBAAA;AAAA,SACR;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,yBAAV,KAAA;AACE,EAAMA,yBAAAA,CAAA,mBAAmB,sBAG7B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,4BAA4B,CAAA,CAAA;AAAA,CAJ7B,EAAA,wBAAA,KAAA,wBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createSchemaFromZod } from '../schema/createSchemaFromZod.esm.js';
|
|
2
|
-
import
|
|
2
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
3
3
|
import { createExtension } from '../wiring/createExtension.esm.js';
|
|
4
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
4
5
|
|
|
5
6
|
function createNavItemExtension(options) {
|
|
6
7
|
const { routeRef, title, icon, namespace, name } = options;
|
|
@@ -27,7 +28,7 @@ function createNavItemExtension(options) {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
((createNavItemExtension2) => {
|
|
30
|
-
createNavItemExtension2.targetDataRef = createExtensionDataRef("core.nav-item.target");
|
|
31
|
+
createNavItemExtension2.targetDataRef = createExtensionDataRef().with({ id: "core.nav-item.target" });
|
|
31
32
|
})(createNavItemExtension || (createNavItemExtension = {}));
|
|
32
33
|
|
|
33
34
|
export { createNavItemExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNavItemExtension.esm.js","sources":["../../src/extensions/createNavItemExtension.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 { IconComponent } from '@backstage/core-plugin-api';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\nimport { createExtension, createExtensionDataRef } from '../wiring';\nimport { RouteRef } from '../routing';\n\n/**\n * Helper for creating extensions for a nav item.\n * @public\n */\nexport function createNavItemExtension(options: {\n namespace?: string;\n name?: string;\n routeRef: RouteRef<undefined>;\n title: string;\n icon: IconComponent;\n}) {\n const { routeRef, title, icon, namespace, name } = options;\n return createExtension({\n namespace,\n name,\n kind: 'nav-item',\n attachTo: { id: 'app/nav', input: 'items' },\n configSchema: createSchemaFromZod(z =>\n z.object({\n title: z.string().default(title),\n }),\n ),\n output: {\n navTarget: createNavItemExtension.targetDataRef,\n },\n factory: ({ config }) => ({\n navTarget: {\n title: config.title,\n icon,\n routeRef,\n },\n }),\n });\n}\n\n/** @public */\nexport namespace createNavItemExtension {\n // TODO(Rugvip): Should this be broken apart into separate refs? title/icon/routeRef\n export const targetDataRef = createExtensionDataRef<{\n title: string;\n icon: IconComponent;\n routeRef: RouteRef<undefined>;\n }>('core.nav-item.target');\n}\n"],"names":["createNavItemExtension"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createNavItemExtension.esm.js","sources":["../../src/extensions/createNavItemExtension.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 { IconComponent } from '@backstage/core-plugin-api';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\nimport { createExtension, createExtensionDataRef } from '../wiring';\nimport { RouteRef } from '../routing';\n\n/**\n * Helper for creating extensions for a nav item.\n * @public\n */\nexport function createNavItemExtension(options: {\n namespace?: string;\n name?: string;\n routeRef: RouteRef<undefined>;\n title: string;\n icon: IconComponent;\n}) {\n const { routeRef, title, icon, namespace, name } = options;\n return createExtension({\n namespace,\n name,\n kind: 'nav-item',\n attachTo: { id: 'app/nav', input: 'items' },\n configSchema: createSchemaFromZod(z =>\n z.object({\n title: z.string().default(title),\n }),\n ),\n output: {\n navTarget: createNavItemExtension.targetDataRef,\n },\n factory: ({ config }) => ({\n navTarget: {\n title: config.title,\n icon,\n routeRef,\n },\n }),\n });\n}\n\n/** @public */\nexport namespace createNavItemExtension {\n // TODO(Rugvip): Should this be broken apart into separate refs? title/icon/routeRef\n export const targetDataRef = createExtensionDataRef<{\n title: string;\n icon: IconComponent;\n routeRef: RouteRef<undefined>;\n }>().with({ id: 'core.nav-item.target' });\n}\n"],"names":["createNavItemExtension"],"mappings":";;;;;AAyBO,SAAS,uBAAuB,OAMpC,EAAA;AACD,EAAA,MAAM,EAAE,QAAU,EAAA,KAAA,EAAO,IAAM,EAAA,SAAA,EAAW,MAAS,GAAA,OAAA,CAAA;AACnD,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,SAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAM,EAAA,UAAA;AAAA,IACN,QAAU,EAAA,EAAE,EAAI,EAAA,SAAA,EAAW,OAAO,OAAQ,EAAA;AAAA,IAC1C,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,sBAAuB,CAAA,aAAA;AAAA,KACpC;AAAA,IACA,OAAS,EAAA,CAAC,EAAE,MAAA,EAAc,MAAA;AAAA,MACxB,SAAW,EAAA;AAAA,QACT,OAAO,MAAO,CAAA,KAAA;AAAA,QACd,IAAA;AAAA,QACA,QAAA;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,uBAAV,KAAA;AAEE,EAAMA,uBAAAA,CAAA,gBAAgB,sBAI1B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,wBAAwB,CAAA,CAAA;AAAA,CANzB,EAAA,sBAAA,KAAA,sBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
2
2
|
import { createExtension } from '../wiring/createExtension.esm.js';
|
|
3
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
3
4
|
|
|
4
5
|
function createNavLogoExtension(options) {
|
|
5
6
|
const { logoIcon, logoFull } = options;
|
|
@@ -22,7 +23,7 @@ function createNavLogoExtension(options) {
|
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
((createNavLogoExtension2) => {
|
|
25
|
-
createNavLogoExtension2.logoElementsDataRef = createExtensionDataRef("core.nav-logo.logo-elements");
|
|
26
|
+
createNavLogoExtension2.logoElementsDataRef = createExtensionDataRef().with({ id: "core.nav-logo.logo-elements" });
|
|
26
27
|
})(createNavLogoExtension || (createNavLogoExtension = {}));
|
|
27
28
|
|
|
28
29
|
export { createNavLogoExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNavLogoExtension.esm.js","sources":["../../src/extensions/createNavLogoExtension.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 { createExtension, createExtensionDataRef } from '../wiring';\n\n/**\n * Helper for creating extensions for a nav logos.\n * @public\n */\nexport function createNavLogoExtension(options: {\n name?: string;\n namespace?: string;\n logoIcon: JSX.Element;\n logoFull: JSX.Element;\n}) {\n const { logoIcon, logoFull } = options;\n return createExtension({\n kind: 'nav-logo',\n name: options?.name,\n namespace: options?.namespace,\n attachTo: { id: 'app/nav', input: 'logos' },\n output: {\n logos: createNavLogoExtension.logoElementsDataRef,\n },\n factory: () => {\n return {\n logos: {\n logoIcon,\n logoFull,\n },\n };\n },\n });\n}\n\n/** @public */\nexport namespace createNavLogoExtension {\n export const logoElementsDataRef = createExtensionDataRef<{\n logoIcon?: JSX.Element;\n logoFull?: JSX.Element;\n }>('core.nav-logo.logo-elements');\n}\n"],"names":["createNavLogoExtension"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createNavLogoExtension.esm.js","sources":["../../src/extensions/createNavLogoExtension.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 { createExtension, createExtensionDataRef } from '../wiring';\n\n/**\n * Helper for creating extensions for a nav logos.\n * @public\n */\nexport function createNavLogoExtension(options: {\n name?: string;\n namespace?: string;\n logoIcon: JSX.Element;\n logoFull: JSX.Element;\n}) {\n const { logoIcon, logoFull } = options;\n return createExtension({\n kind: 'nav-logo',\n name: options?.name,\n namespace: options?.namespace,\n attachTo: { id: 'app/nav', input: 'logos' },\n output: {\n logos: createNavLogoExtension.logoElementsDataRef,\n },\n factory: () => {\n return {\n logos: {\n logoIcon,\n logoFull,\n },\n };\n },\n });\n}\n\n/** @public */\nexport namespace createNavLogoExtension {\n export const logoElementsDataRef = createExtensionDataRef<{\n logoIcon?: JSX.Element;\n logoFull?: JSX.Element;\n }>().with({ id: 'core.nav-logo.logo-elements' });\n}\n"],"names":["createNavLogoExtension"],"mappings":";;;;AAsBO,SAAS,uBAAuB,OAKpC,EAAA;AACD,EAAM,MAAA,EAAE,QAAU,EAAA,QAAA,EAAa,GAAA,OAAA,CAAA;AAC/B,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,UAAA;AAAA,IACN,MAAM,OAAS,EAAA,IAAA;AAAA,IACf,WAAW,OAAS,EAAA,SAAA;AAAA,IACpB,QAAU,EAAA,EAAE,EAAI,EAAA,SAAA,EAAW,OAAO,OAAQ,EAAA;AAAA,IAC1C,MAAQ,EAAA;AAAA,MACN,OAAO,sBAAuB,CAAA,mBAAA;AAAA,KAChC;AAAA,IACA,SAAS,MAAM;AACb,MAAO,OAAA;AAAA,QACL,KAAO,EAAA;AAAA,UACL,QAAA;AAAA,UACA,QAAA;AAAA,SACF;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,uBAAV,KAAA;AACE,EAAMA,uBAAAA,CAAA,sBAAsB,sBAGhC,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,+BAA+B,CAAA,CAAA;AAAA,CAJhC,EAAA,sBAAA,KAAA,sBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -28,7 +28,7 @@ function createPageExtension(options) {
|
|
|
28
28
|
return {
|
|
29
29
|
path: config.path,
|
|
30
30
|
routeRef: options.routeRef,
|
|
31
|
-
element: /* @__PURE__ */ React.createElement(ExtensionBoundary, { node
|
|
31
|
+
element: /* @__PURE__ */ React.createElement(ExtensionBoundary, { node }, /* @__PURE__ */ React.createElement(ExtensionComponent, null))
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPageExtension.esm.js","sources":["../../src/extensions/createPageExtension.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 React, { lazy } from 'react';\nimport { ExtensionBoundary } from '../components';\nimport { createSchemaFromZod, PortableSchema } from '../schema';\nimport {\n coreExtensionData,\n createExtension,\n ResolvedExtensionInputs,\n AnyExtensionInputMap,\n} from '../wiring';\nimport { RouteRef } from '../routing';\nimport { Expand } from '../types';\nimport { ExtensionDefinition } 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 namespace?: string;\n name?: 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<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n },\n): ExtensionDefinition<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 kind: 'page',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? { id: 'app/routes', input: 'routes' },\n configSchema,\n inputs: options.inputs,\n disabled: options.disabled,\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef.optional(),\n },\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ config, inputs })\n .then(element => ({ default: () => element })),\n );\n\n return {\n path: config.path,\n routeRef: options.routeRef,\n element: (\n <ExtensionBoundary node={node}
|
|
1
|
+
{"version":3,"file":"createPageExtension.esm.js","sources":["../../src/extensions/createPageExtension.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 React, { lazy } from 'react';\nimport { ExtensionBoundary } from '../components';\nimport { createSchemaFromZod, PortableSchema } from '../schema';\nimport {\n coreExtensionData,\n createExtension,\n ResolvedExtensionInputs,\n AnyExtensionInputMap,\n} from '../wiring';\nimport { RouteRef } from '../routing';\nimport { Expand } from '../types';\nimport { ExtensionDefinition } 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 namespace?: string;\n name?: 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<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n },\n): ExtensionDefinition<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 kind: 'page',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? { id: 'app/routes', input: 'routes' },\n configSchema,\n inputs: options.inputs,\n disabled: options.disabled,\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef.optional(),\n },\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ config, inputs })\n .then(element => ({ default: () => element })),\n );\n\n return {\n path: config.path,\n routeRef: options.routeRef,\n element: (\n <ExtensionBoundary node={node}>\n <ExtensionComponent />\n </ExtensionBoundary>\n ),\n };\n },\n });\n}\n"],"names":[],"mappings":";;;;;;AAkCO,SAAS,oBAId,OAmB8B,EAAA;AAC9B,EAAA,MAAM,YACJ,GAAA,cAAA,IAAkB,OACd,GAAA,OAAA,CAAQ,YACP,GAAA,mBAAA;AAAA,IAAoB,CACnB,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA,EAAE,IAAM,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,OAAQ,CAAA,OAAA,CAAQ,WAAW,CAAA,EAAG,CAAA;AAAA,GAC5D,CAAA;AAEN,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,MAAA;AAAA,IACN,WAAW,OAAQ,CAAA,SAAA;AAAA,IACnB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,UAAU,OAAQ,CAAA,QAAA,IAAY,EAAE,EAAI,EAAA,YAAA,EAAc,OAAO,QAAS,EAAA;AAAA,IAClE,YAAA;AAAA,IACA,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,MAAQ,EAAA;AAAA,MACN,SAAS,iBAAkB,CAAA,YAAA;AAAA,MAC3B,MAAM,iBAAkB,CAAA,SAAA;AAAA,MACxB,QAAA,EAAU,iBAAkB,CAAA,QAAA,CAAS,QAAS,EAAA;AAAA,KAChD;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,MAAQ,EAAA;AAChC,MAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,QAAK,MAC9B,OAAA,CACG,MAAO,CAAA,EAAE,QAAQ,MAAO,EAAC,CACzB,CAAA,IAAA,CAAK,CAAY,OAAA,MAAA,EAAE,OAAS,EAAA,MAAM,SAAU,CAAA,CAAA;AAAA,OACjD,CAAA;AAEA,MAAO,OAAA;AAAA,QACL,MAAM,MAAO,CAAA,IAAA;AAAA,QACb,UAAU,OAAQ,CAAA,QAAA;AAAA,QAClB,yBACG,KAAA,CAAA,aAAA,CAAA,iBAAA,EAAA,EAAkB,IACjB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,wBAAmB,CACtB,CAAA;AAAA,OAEJ,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
|
@@ -25,9 +25,7 @@ function createRouterExtension(options) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
((createRouterExtension2) => {
|
|
28
|
-
createRouterExtension2.componentDataRef = createExtensionDataRef(
|
|
29
|
-
"app.router.wrapper"
|
|
30
|
-
);
|
|
28
|
+
createRouterExtension2.componentDataRef = createExtensionDataRef().with({ id: "app.router.wrapper" });
|
|
31
29
|
})(createRouterExtension || (createRouterExtension = {}));
|
|
32
30
|
|
|
33
31
|
export { createRouterExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouterExtension.esm.js","sources":["../../src/extensions/createRouterExtension.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 React, { ComponentType, PropsWithChildren } from 'react';\nimport { PortableSchema } from '../schema/types';\nimport {\n AnyExtensionInputMap,\n ExtensionDefinition,\n ResolvedExtensionInputs,\n createExtension,\n} from '../wiring/createExtension';\nimport { createExtensionDataRef } from '../wiring/createExtensionDataRef';\nimport { Expand } from '../types';\n\n/**\n * Creates an extension that replaces the router implementation at the app root.\n * This is useful to be able to for example replace the BrowserRouter with a\n * MemoryRouter in tests, or to add additional props to a BrowserRouter.\n *\n * @public\n */\nexport function createRouterExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n configSchema?: PortableSchema<TConfig>;\n disabled?: boolean;\n inputs?: TInputs;\n Component: ComponentType<\n PropsWithChildren<{\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n config: TConfig;\n }>\n >;\n}): ExtensionDefinition<TConfig> {\n return createExtension({\n kind: 'app-router-component',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? { id: 'app/root', input: 'router' },\n configSchema: options.configSchema,\n disabled: options.disabled,\n inputs: options.inputs,\n output: {\n component: createRouterExtension.componentDataRef,\n },\n factory({ inputs, config }) {\n const Component = (props: PropsWithChildren<{}>) => {\n return (\n <options.Component inputs={inputs} config={config}>\n {props.children}\n </options.Component>\n );\n };\n return {\n component: Component,\n };\n },\n });\n}\n\n/** @public */\nexport namespace createRouterExtension {\n export const componentDataRef
|
|
1
|
+
{"version":3,"file":"createRouterExtension.esm.js","sources":["../../src/extensions/createRouterExtension.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 React, { ComponentType, PropsWithChildren } from 'react';\nimport { PortableSchema } from '../schema/types';\nimport {\n AnyExtensionInputMap,\n ExtensionDefinition,\n ResolvedExtensionInputs,\n createExtension,\n} from '../wiring/createExtension';\nimport { createExtensionDataRef } from '../wiring/createExtensionDataRef';\nimport { Expand } from '../types';\n\n/**\n * Creates an extension that replaces the router implementation at the app root.\n * This is useful to be able to for example replace the BrowserRouter with a\n * MemoryRouter in tests, or to add additional props to a BrowserRouter.\n *\n * @public\n */\nexport function createRouterExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n configSchema?: PortableSchema<TConfig>;\n disabled?: boolean;\n inputs?: TInputs;\n Component: ComponentType<\n PropsWithChildren<{\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n config: TConfig;\n }>\n >;\n}): ExtensionDefinition<TConfig> {\n return createExtension({\n kind: 'app-router-component',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? { id: 'app/root', input: 'router' },\n configSchema: options.configSchema,\n disabled: options.disabled,\n inputs: options.inputs,\n output: {\n component: createRouterExtension.componentDataRef,\n },\n factory({ inputs, config }) {\n const Component = (props: PropsWithChildren<{}>) => {\n return (\n <options.Component inputs={inputs} config={config}>\n {props.children}\n </options.Component>\n );\n };\n return {\n component: Component,\n };\n },\n });\n}\n\n/** @public */\nexport namespace createRouterExtension {\n export const componentDataRef = createExtensionDataRef<\n ComponentType<PropsWithChildren<{}>>\n >().with({ id: 'app.router.wrapper' });\n}\n"],"names":["createRouterExtension"],"mappings":";;;;AAkCO,SAAS,sBAGd,OAa+B,EAAA;AAC/B,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,sBAAA;AAAA,IACN,WAAW,OAAQ,CAAA,SAAA;AAAA,IACnB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,UAAU,OAAQ,CAAA,QAAA,IAAY,EAAE,EAAI,EAAA,UAAA,EAAY,OAAO,QAAS,EAAA;AAAA,IAChE,cAAc,OAAQ,CAAA,YAAA;AAAA,IACtB,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,WAAW,qBAAsB,CAAA,gBAAA;AAAA,KACnC;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAU,EAAA;AAC1B,MAAM,MAAA,SAAA,GAAY,CAAC,KAAiC,KAAA;AAClD,QAAA,2CACG,OAAQ,CAAA,SAAA,EAAR,EAAkB,MAAgB,EAAA,MAAA,EAAA,EAChC,MAAM,QACT,CAAA,CAAA;AAAA,OAEJ,CAAA;AACA,MAAO,OAAA;AAAA,QACL,SAAW,EAAA,SAAA;AAAA,OACb,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,sBAAV,KAAA;AACE,EAAMA,sBAAAA,CAAA,mBAAmB,sBAE9B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,sBAAsB,CAAA,CAAA;AAAA,CAHtB,EAAA,qBAAA,KAAA,qBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { lazy } from 'react';
|
|
2
2
|
import { ExtensionBoundary } from '../components/ExtensionBoundary.esm.js';
|
|
3
|
-
import
|
|
3
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
4
4
|
import { createExtension } from '../wiring/createExtension.esm.js';
|
|
5
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
5
6
|
|
|
6
7
|
function createSignInPageExtension(options) {
|
|
7
8
|
return createExtension({
|
|
@@ -26,7 +27,7 @@ function createSignInPageExtension(options) {
|
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
((createSignInPageExtension2) => {
|
|
29
|
-
createSignInPageExtension2.componentDataRef = createExtensionDataRef("core.sign-in-page.component");
|
|
30
|
+
createSignInPageExtension2.componentDataRef = createExtensionDataRef().with({ id: "core.sign-in-page.component" });
|
|
30
31
|
})(createSignInPageExtension || (createSignInPageExtension = {}));
|
|
31
32
|
|
|
32
33
|
export { createSignInPageExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSignInPageExtension.esm.js","sources":["../../src/extensions/createSignInPageExtension.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 React, { ComponentType, lazy } from 'react';\nimport { ExtensionBoundary } from '../components';\nimport { PortableSchema } from '../schema';\nimport {\n createExtension,\n ResolvedExtensionInputs,\n AnyExtensionInputMap,\n createExtensionDataRef,\n ExtensionDefinition,\n} from '../wiring';\nimport { Expand } from '../types';\nimport { SignInPageProps } from '@backstage/core-plugin-api';\n\n/**\n *\n * @public\n */\nexport function createSignInPageExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n configSchema?: PortableSchema<TConfig>;\n disabled?: boolean;\n inputs?: TInputs;\n loader: (options: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<ComponentType<SignInPageProps>>;\n}): ExtensionDefinition<TConfig> {\n return createExtension({\n kind: 'sign-in-page',\n namespace: options?.namespace,\n name: options?.name,\n attachTo: options.attachTo ?? { id: 'app/root', input: 'signInPage' },\n configSchema: options.configSchema,\n inputs: options.inputs,\n disabled: options.disabled,\n output: {\n component: createSignInPageExtension.componentDataRef,\n },\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ config, inputs })\n .then(component => ({ default: component })),\n );\n\n return {\n component: props => (\n <ExtensionBoundary node={node} routable>\n <ExtensionComponent {...props} />\n </ExtensionBoundary>\n ),\n };\n },\n });\n}\n\n/** @public */\nexport namespace createSignInPageExtension {\n export const componentDataRef = createExtensionDataRef<\n ComponentType<SignInPageProps>\n >('core.sign-in-page.component');\n}\n"],"names":["createSignInPageExtension"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createSignInPageExtension.esm.js","sources":["../../src/extensions/createSignInPageExtension.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 React, { ComponentType, lazy } from 'react';\nimport { ExtensionBoundary } from '../components';\nimport { PortableSchema } from '../schema';\nimport {\n createExtension,\n ResolvedExtensionInputs,\n AnyExtensionInputMap,\n createExtensionDataRef,\n ExtensionDefinition,\n} from '../wiring';\nimport { Expand } from '../types';\nimport { SignInPageProps } from '@backstage/core-plugin-api';\n\n/**\n *\n * @public\n */\nexport function createSignInPageExtension<\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n configSchema?: PortableSchema<TConfig>;\n disabled?: boolean;\n inputs?: TInputs;\n loader: (options: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<ComponentType<SignInPageProps>>;\n}): ExtensionDefinition<TConfig> {\n return createExtension({\n kind: 'sign-in-page',\n namespace: options?.namespace,\n name: options?.name,\n attachTo: options.attachTo ?? { id: 'app/root', input: 'signInPage' },\n configSchema: options.configSchema,\n inputs: options.inputs,\n disabled: options.disabled,\n output: {\n component: createSignInPageExtension.componentDataRef,\n },\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ config, inputs })\n .then(component => ({ default: component })),\n );\n\n return {\n component: props => (\n <ExtensionBoundary node={node} routable>\n <ExtensionComponent {...props} />\n </ExtensionBoundary>\n ),\n };\n },\n });\n}\n\n/** @public */\nexport namespace createSignInPageExtension {\n export const componentDataRef = createExtensionDataRef<\n ComponentType<SignInPageProps>\n >().with({ id: 'core.sign-in-page.component' });\n}\n"],"names":["createSignInPageExtension"],"mappings":";;;;;;AAiCO,SAAS,0BAGd,OAW+B,EAAA;AAC/B,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,cAAA;AAAA,IACN,WAAW,OAAS,EAAA,SAAA;AAAA,IACpB,MAAM,OAAS,EAAA,IAAA;AAAA,IACf,UAAU,OAAQ,CAAA,QAAA,IAAY,EAAE,EAAI,EAAA,UAAA,EAAY,OAAO,YAAa,EAAA;AAAA,IACpE,cAAc,OAAQ,CAAA,YAAA;AAAA,IACtB,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,MAAQ,EAAA;AAAA,MACN,WAAW,yBAA0B,CAAA,gBAAA;AAAA,KACvC;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,MAAQ,EAAA;AAChC,MAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,QAAK,MAC9B,OAAA,CACG,MAAO,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,CAAA,CACzB,IAAK,CAAA,CAAA,SAAA,MAAc,EAAE,OAAA,EAAS,WAAY,CAAA,CAAA;AAAA,OAC/C,CAAA;AAEA,MAAO,OAAA;AAAA,QACL,SAAA,EAAW,CACT,KAAA,qBAAA,KAAA,CAAA,aAAA,CAAC,iBAAkB,EAAA,EAAA,IAAA,EAAY,QAAQ,EAAA,IAAA,EAAA,kBACpC,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA,EAAoB,GAAG,KAAA,EAAO,CACjC,CAAA;AAAA,OAEJ,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,0BAAV,KAAA;AACE,EAAMA,0BAAAA,CAAA,mBAAmB,sBAE9B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,+BAA+B,CAAA,CAAA;AAAA,CAH/B,EAAA,yBAAA,KAAA,yBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
2
2
|
import { createExtension } from '../wiring/createExtension.esm.js';
|
|
3
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
3
4
|
|
|
4
5
|
function createThemeExtension(theme) {
|
|
5
6
|
return createExtension({
|
|
@@ -14,7 +15,9 @@ function createThemeExtension(theme) {
|
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
((createThemeExtension2) => {
|
|
17
|
-
createThemeExtension2.themeDataRef = createExtensionDataRef(
|
|
18
|
+
createThemeExtension2.themeDataRef = createExtensionDataRef().with({
|
|
19
|
+
id: "core.theme.theme"
|
|
20
|
+
});
|
|
18
21
|
})(createThemeExtension || (createThemeExtension = {}));
|
|
19
22
|
|
|
20
23
|
export { createThemeExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createThemeExtension.esm.js","sources":["../../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 { createExtension, createExtensionDataRef } from '../wiring';\nimport { AppTheme } from '@backstage/core-plugin-api';\n\n/** @public */\nexport function createThemeExtension(theme: AppTheme) {\n return createExtension({\n kind: 'theme',\n namespace: 'app',\n name: theme.id,\n attachTo: { id: 'app', input: 'themes' },\n output: {\n theme: createThemeExtension.themeDataRef,\n },\n factory: () => ({ theme }),\n });\n}\n\n/** @public */\nexport namespace createThemeExtension {\n export const themeDataRef
|
|
1
|
+
{"version":3,"file":"createThemeExtension.esm.js","sources":["../../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 { createExtension, createExtensionDataRef } from '../wiring';\nimport { AppTheme } from '@backstage/core-plugin-api';\n\n/** @public */\nexport function createThemeExtension(theme: AppTheme) {\n return createExtension({\n kind: 'theme',\n namespace: 'app',\n name: theme.id,\n attachTo: { id: 'app', input: 'themes' },\n output: {\n theme: createThemeExtension.themeDataRef,\n },\n factory: () => ({ theme }),\n });\n}\n\n/** @public */\nexport namespace createThemeExtension {\n export const themeDataRef = createExtensionDataRef<AppTheme>().with({\n id: 'core.theme.theme',\n });\n}\n"],"names":["createThemeExtension"],"mappings":";;;;AAoBO,SAAS,qBAAqB,KAAiB,EAAA;AACpD,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,OAAA;AAAA,IACN,SAAW,EAAA,KAAA;AAAA,IACX,MAAM,KAAM,CAAA,EAAA;AAAA,IACZ,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,QAAS,EAAA;AAAA,IACvC,MAAQ,EAAA;AAAA,MACN,OAAO,oBAAqB,CAAA,YAAA;AAAA,KAC9B;AAAA,IACA,OAAA,EAAS,OAAO,EAAE,KAAM,EAAA,CAAA;AAAA,GACzB,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,qBAAV,KAAA;AACE,EAAMA,qBAAA,CAAA,YAAA,GAAe,sBAAiC,EAAA,CAAE,IAAK,CAAA;AAAA,IAClE,EAAI,EAAA,kBAAA;AAAA,GACL,CAAA,CAAA;AAAA,CAHc,EAAA,oBAAA,KAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../wiring/coreExtensionData.esm.js';
|
|
2
2
|
import { createExtension } from '../wiring/createExtension.esm.js';
|
|
3
|
+
import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
|
|
3
4
|
|
|
4
5
|
function createTranslationExtension(options) {
|
|
5
6
|
return createExtension({
|
|
@@ -14,7 +15,7 @@ function createTranslationExtension(options) {
|
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
((createTranslationExtension2) => {
|
|
17
|
-
createTranslationExtension2.translationDataRef = createExtensionDataRef("core.translation.translation");
|
|
18
|
+
createTranslationExtension2.translationDataRef = createExtensionDataRef().with({ id: "core.translation.translation" });
|
|
18
19
|
})(createTranslationExtension || (createTranslationExtension = {}));
|
|
19
20
|
|
|
20
21
|
export { createTranslationExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTranslationExtension.esm.js","sources":["../../src/extensions/createTranslationExtension.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 { TranslationMessages, TranslationResource } from '../translation';\nimport { createExtension, createExtensionDataRef } from '../wiring';\n\n/** @public */\nexport function createTranslationExtension(options: {\n name?: string;\n resource: TranslationResource | TranslationMessages;\n}) {\n return createExtension({\n kind: 'translation',\n namespace: options.resource.id,\n name: options.name,\n attachTo: { id: 'app', input: 'translations' },\n output: {\n resource: createTranslationExtension.translationDataRef,\n },\n factory: () => ({ resource: options.resource }),\n });\n}\n\n/** @public */\nexport namespace createTranslationExtension {\n export const translationDataRef = createExtensionDataRef<\n TranslationResource | TranslationMessages\n >('core.translation.translation');\n}\n"],"names":["createTranslationExtension"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createTranslationExtension.esm.js","sources":["../../src/extensions/createTranslationExtension.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 { TranslationMessages, TranslationResource } from '../translation';\nimport { createExtension, createExtensionDataRef } from '../wiring';\n\n/** @public */\nexport function createTranslationExtension(options: {\n name?: string;\n resource: TranslationResource | TranslationMessages;\n}) {\n return createExtension({\n kind: 'translation',\n namespace: options.resource.id,\n name: options.name,\n attachTo: { id: 'app', input: 'translations' },\n output: {\n resource: createTranslationExtension.translationDataRef,\n },\n factory: () => ({ resource: options.resource }),\n });\n}\n\n/** @public */\nexport namespace createTranslationExtension {\n export const translationDataRef = createExtensionDataRef<\n TranslationResource | TranslationMessages\n >().with({ id: 'core.translation.translation' });\n}\n"],"names":["createTranslationExtension"],"mappings":";;;;AAoBO,SAAS,2BAA2B,OAGxC,EAAA;AACD,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,aAAA;AAAA,IACN,SAAA,EAAW,QAAQ,QAAS,CAAA,EAAA;AAAA,IAC5B,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,cAAe,EAAA;AAAA,IAC7C,MAAQ,EAAA;AAAA,MACN,UAAU,0BAA2B,CAAA,kBAAA;AAAA,KACvC;AAAA,IACA,OAAS,EAAA,OAAO,EAAE,QAAA,EAAU,QAAQ,QAAS,EAAA,CAAA;AAAA,GAC9C,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,2BAAV,KAAA;AACE,EAAMA,2BAAAA,CAAA,qBAAqB,sBAEhC,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,gCAAgC,CAAA,CAAA;AAAA,CAHhC,EAAA,0BAAA,KAAA,0BAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -233,30 +233,39 @@ declare function useRouteRef<TParams extends AnyRouteRefParams>(routeRef: RouteR
|
|
|
233
233
|
declare function useRouteRefParams<Params extends AnyRouteRefParams>(_routeRef: RouteRef<Params> | SubRouteRef<Params>): Params;
|
|
234
234
|
|
|
235
235
|
/** @public */
|
|
236
|
-
type ExtensionDataRef<TData, TConfig extends {
|
|
236
|
+
type ExtensionDataRef<TData, TId extends string = string, TConfig extends {
|
|
237
237
|
optional?: true;
|
|
238
238
|
} = {}> = {
|
|
239
|
-
id:
|
|
239
|
+
id: TId;
|
|
240
240
|
T: TData;
|
|
241
241
|
config: TConfig;
|
|
242
242
|
$$type: '@backstage/ExtensionDataRef';
|
|
243
243
|
};
|
|
244
244
|
/** @public */
|
|
245
|
-
interface ConfigurableExtensionDataRef<TData, TConfig extends {
|
|
245
|
+
interface ConfigurableExtensionDataRef<TId extends string, TData, TConfig extends {
|
|
246
246
|
optional?: true;
|
|
247
|
-
} = {}> extends ExtensionDataRef<TData, TConfig> {
|
|
248
|
-
optional(): ConfigurableExtensionDataRef<TData, TData & {
|
|
247
|
+
} = {}> extends ExtensionDataRef<TData, TId, TConfig> {
|
|
248
|
+
optional(): ConfigurableExtensionDataRef<TId, TData, TData & {
|
|
249
249
|
optional: true;
|
|
250
250
|
}>;
|
|
251
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* @public
|
|
254
|
+
* @deprecated Use the following form instead: `createExtensionDataRef<Type>().with({ id: 'core.foo' })`
|
|
255
|
+
*/
|
|
256
|
+
declare function createExtensionDataRef<TData>(id: string): ConfigurableExtensionDataRef<string, TData>;
|
|
252
257
|
/** @public */
|
|
253
|
-
declare function createExtensionDataRef<TData>(
|
|
258
|
+
declare function createExtensionDataRef<TData>(): {
|
|
259
|
+
with<TId extends string>(options: {
|
|
260
|
+
id: TId;
|
|
261
|
+
}): ConfigurableExtensionDataRef<TId, TData>;
|
|
262
|
+
};
|
|
254
263
|
|
|
255
264
|
/** @public */
|
|
256
265
|
declare const coreExtensionData: {
|
|
257
|
-
reactElement: ConfigurableExtensionDataRef<JSX$1.Element, {}>;
|
|
258
|
-
routePath: ConfigurableExtensionDataRef<string, {}>;
|
|
259
|
-
routeRef: ConfigurableExtensionDataRef<RouteRef<AnyRouteRefParams>, {}>;
|
|
266
|
+
reactElement: ConfigurableExtensionDataRef<"core.reactElement", JSX$1.Element, {}>;
|
|
267
|
+
routePath: ConfigurableExtensionDataRef<"core.routing.path", string, {}>;
|
|
268
|
+
routeRef: ConfigurableExtensionDataRef<"core.routing.ref", RouteRef<AnyRouteRefParams>, {}>;
|
|
260
269
|
};
|
|
261
270
|
|
|
262
271
|
/** @public */
|
|
@@ -308,7 +317,7 @@ declare function createExtensionInput<TExtensionData extends AnyExtensionDataMap
|
|
|
308
317
|
|
|
309
318
|
/** @public */
|
|
310
319
|
type AnyExtensionDataMap = {
|
|
311
|
-
[name in string]: ExtensionDataRef<unknown, {
|
|
320
|
+
[name in string]: ExtensionDataRef<unknown, string, {
|
|
312
321
|
optional?: true;
|
|
313
322
|
}>;
|
|
314
323
|
};
|
|
@@ -362,7 +371,7 @@ interface CreateExtensionOptions<TOutput extends AnyExtensionDataMap, TInputs ex
|
|
|
362
371
|
inputs?: TInputs;
|
|
363
372
|
output: TOutput;
|
|
364
373
|
configSchema?: PortableSchema<TConfig>;
|
|
365
|
-
factory(
|
|
374
|
+
factory(context: {
|
|
366
375
|
node: AppNode;
|
|
367
376
|
config: TConfig;
|
|
368
377
|
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
|
@@ -446,6 +455,70 @@ interface ExtensionOverridesOptions {
|
|
|
446
455
|
/** @public */
|
|
447
456
|
declare function createExtensionOverrides(options: ExtensionOverridesOptions): ExtensionOverrides;
|
|
448
457
|
|
|
458
|
+
/**
|
|
459
|
+
* @public
|
|
460
|
+
*/
|
|
461
|
+
interface CreateExtensionBlueprintOptions<TParams, TInputs extends AnyExtensionInputMap, TOutput extends AnyExtensionDataMap, TConfig, TDataRefs extends AnyExtensionDataMap> {
|
|
462
|
+
kind: string;
|
|
463
|
+
namespace?: string;
|
|
464
|
+
attachTo: {
|
|
465
|
+
id: string;
|
|
466
|
+
input: string;
|
|
467
|
+
};
|
|
468
|
+
disabled?: boolean;
|
|
469
|
+
inputs?: TInputs;
|
|
470
|
+
output: TOutput;
|
|
471
|
+
configSchema?: PortableSchema<TConfig>;
|
|
472
|
+
factory(params: TParams, context: {
|
|
473
|
+
node: AppNode;
|
|
474
|
+
config: TConfig;
|
|
475
|
+
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
|
476
|
+
}): Expand<ExtensionDataValues<TOutput>>;
|
|
477
|
+
dataRefs?: TDataRefs;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* @public
|
|
481
|
+
*/
|
|
482
|
+
interface ExtensionBlueprint<TParams, TInputs extends AnyExtensionInputMap, TOutput extends AnyExtensionDataMap, TConfig, TDataRefs extends AnyExtensionDataMap> {
|
|
483
|
+
dataRefs: TDataRefs;
|
|
484
|
+
/**
|
|
485
|
+
* Creates a new extension from the blueprint.
|
|
486
|
+
*
|
|
487
|
+
* You must either pass `params` directly, or define a `factory` that can
|
|
488
|
+
* optionally call the original factory with the same params.
|
|
489
|
+
*/
|
|
490
|
+
make(args: {
|
|
491
|
+
namespace?: string;
|
|
492
|
+
name?: string;
|
|
493
|
+
attachTo?: {
|
|
494
|
+
id: string;
|
|
495
|
+
input: string;
|
|
496
|
+
};
|
|
497
|
+
disabled?: boolean;
|
|
498
|
+
inputs?: TInputs;
|
|
499
|
+
output?: TOutput;
|
|
500
|
+
configSchema?: PortableSchema<TConfig>;
|
|
501
|
+
} & ({
|
|
502
|
+
factory(originalFactory: (params: TParams, context?: {
|
|
503
|
+
config?: TConfig;
|
|
504
|
+
inputs?: Expand<ResolvedExtensionInputs<TInputs>>;
|
|
505
|
+
}) => Expand<ExtensionDataValues<TOutput>>, context: {
|
|
506
|
+
node: AppNode;
|
|
507
|
+
config: TConfig;
|
|
508
|
+
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
|
509
|
+
}): Expand<ExtensionDataValues<TOutput>>;
|
|
510
|
+
} | {
|
|
511
|
+
params: TParams;
|
|
512
|
+
})): ExtensionDefinition<TConfig>;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* A simpler replacement for wrapping up `createExtension` inside a kind or type. This allows for a cleaner API for creating
|
|
516
|
+
* types and instances of those types.
|
|
517
|
+
*
|
|
518
|
+
* @public
|
|
519
|
+
*/
|
|
520
|
+
declare function createExtensionBlueprint<TParams, TInputs extends AnyExtensionInputMap, TOutput extends AnyExtensionDataMap, TConfig, TDataRefs extends AnyExtensionDataMap = never>(options: CreateExtensionBlueprintOptions<TParams, TInputs, TOutput, TConfig, TDataRefs>): ExtensionBlueprint<TParams, TInputs, TOutput, TConfig, TDataRefs>;
|
|
521
|
+
|
|
449
522
|
/**
|
|
450
523
|
* The specification for this {@link AppNode} in the {@link AppTree}.
|
|
451
524
|
*
|
|
@@ -547,6 +620,11 @@ declare const appTreeApiRef: _backstage_core_plugin_api.ApiRef<AppTreeApi>;
|
|
|
547
620
|
/** @public */
|
|
548
621
|
interface ExtensionBoundaryProps {
|
|
549
622
|
node: AppNode;
|
|
623
|
+
/**
|
|
624
|
+
* This explicitly marks the extension as routable for the purpose of
|
|
625
|
+
* capturing analytics events. If not provided, the extension boundary will be
|
|
626
|
+
* marked as routable if it outputs a routePath.
|
|
627
|
+
*/
|
|
550
628
|
routable?: boolean;
|
|
551
629
|
children: ReactNode;
|
|
552
630
|
}
|
|
@@ -786,7 +864,7 @@ declare function createApiExtension<TConfig extends {}, TInputs extends AnyExten
|
|
|
786
864
|
}): ExtensionDefinition<TConfig>;
|
|
787
865
|
/** @public */
|
|
788
866
|
declare namespace createApiExtension {
|
|
789
|
-
const factoryDataRef: ConfigurableExtensionDataRef<AnyApiFactory, {}>;
|
|
867
|
+
const factoryDataRef: ConfigurableExtensionDataRef<"core.api.factory", AnyApiFactory, {}>;
|
|
790
868
|
}
|
|
791
869
|
|
|
792
870
|
/**
|
|
@@ -835,7 +913,7 @@ declare function createAppRootWrapperExtension<TConfig extends {}, TInputs exten
|
|
|
835
913
|
}): ExtensionDefinition<TConfig>;
|
|
836
914
|
/** @public */
|
|
837
915
|
declare namespace createAppRootWrapperExtension {
|
|
838
|
-
const componentDataRef: ConfigurableExtensionDataRef<React.ComponentType<{
|
|
916
|
+
const componentDataRef: ConfigurableExtensionDataRef<"app.root.wrapper", React.ComponentType<{
|
|
839
917
|
children?: React.ReactNode;
|
|
840
918
|
}>, {}>;
|
|
841
919
|
}
|
|
@@ -864,7 +942,7 @@ declare function createRouterExtension<TConfig extends {}, TInputs extends AnyEx
|
|
|
864
942
|
}): ExtensionDefinition<TConfig>;
|
|
865
943
|
/** @public */
|
|
866
944
|
declare namespace createRouterExtension {
|
|
867
|
-
const componentDataRef: ConfigurableExtensionDataRef<React.ComponentType<{
|
|
945
|
+
const componentDataRef: ConfigurableExtensionDataRef<"app.router.wrapper", React.ComponentType<{
|
|
868
946
|
children?: React.ReactNode;
|
|
869
947
|
}>, {}>;
|
|
870
948
|
}
|
|
@@ -911,7 +989,7 @@ declare function createNavItemExtension(options: {
|
|
|
911
989
|
}>;
|
|
912
990
|
/** @public */
|
|
913
991
|
declare namespace createNavItemExtension {
|
|
914
|
-
const targetDataRef: ConfigurableExtensionDataRef<{
|
|
992
|
+
const targetDataRef: ConfigurableExtensionDataRef<"core.nav-item.target", {
|
|
915
993
|
title: string;
|
|
916
994
|
icon: IconComponent$1;
|
|
917
995
|
routeRef: RouteRef<undefined>;
|
|
@@ -930,7 +1008,7 @@ declare function createNavLogoExtension(options: {
|
|
|
930
1008
|
}): ExtensionDefinition<never>;
|
|
931
1009
|
/** @public */
|
|
932
1010
|
declare namespace createNavLogoExtension {
|
|
933
|
-
const logoElementsDataRef: ConfigurableExtensionDataRef<{
|
|
1011
|
+
const logoElementsDataRef: ConfigurableExtensionDataRef<"core.nav-logo.logo-elements", {
|
|
934
1012
|
logoIcon?: JSX.Element | undefined;
|
|
935
1013
|
logoFull?: JSX.Element | undefined;
|
|
936
1014
|
}, {}>;
|
|
@@ -957,14 +1035,14 @@ declare function createSignInPageExtension<TConfig extends {}, TInputs extends A
|
|
|
957
1035
|
}): ExtensionDefinition<TConfig>;
|
|
958
1036
|
/** @public */
|
|
959
1037
|
declare namespace createSignInPageExtension {
|
|
960
|
-
const componentDataRef: ConfigurableExtensionDataRef<React.ComponentType<SignInPageProps>, {}>;
|
|
1038
|
+
const componentDataRef: ConfigurableExtensionDataRef<"core.sign-in-page.component", React.ComponentType<SignInPageProps>, {}>;
|
|
961
1039
|
}
|
|
962
1040
|
|
|
963
1041
|
/** @public */
|
|
964
1042
|
declare function createThemeExtension(theme: AppTheme): ExtensionDefinition<never>;
|
|
965
1043
|
/** @public */
|
|
966
1044
|
declare namespace createThemeExtension {
|
|
967
|
-
const themeDataRef: ConfigurableExtensionDataRef<AppTheme, {}>;
|
|
1045
|
+
const themeDataRef: ConfigurableExtensionDataRef<"core.theme.theme", AppTheme, {}>;
|
|
968
1046
|
}
|
|
969
1047
|
|
|
970
1048
|
/** @public */
|
|
@@ -988,7 +1066,7 @@ declare function createComponentExtension<TProps extends {}, TConfig extends {},
|
|
|
988
1066
|
}): ExtensionDefinition<TConfig>;
|
|
989
1067
|
/** @public */
|
|
990
1068
|
declare namespace createComponentExtension {
|
|
991
|
-
const componentDataRef: ConfigurableExtensionDataRef<{
|
|
1069
|
+
const componentDataRef: ConfigurableExtensionDataRef<"core.component.component", {
|
|
992
1070
|
ref: ComponentRef;
|
|
993
1071
|
impl: ComponentType;
|
|
994
1072
|
}, {}>;
|
|
@@ -1001,9 +1079,24 @@ declare function createTranslationExtension(options: {
|
|
|
1001
1079
|
}): ExtensionDefinition<never>;
|
|
1002
1080
|
/** @public */
|
|
1003
1081
|
declare namespace createTranslationExtension {
|
|
1004
|
-
const translationDataRef: ConfigurableExtensionDataRef<TranslationResource<string> | TranslationMessages<string, {
|
|
1082
|
+
const translationDataRef: ConfigurableExtensionDataRef<"core.translation.translation", TranslationResource<string> | TranslationMessages<string, {
|
|
1005
1083
|
[x: string]: string;
|
|
1006
1084
|
}, boolean>, {}>;
|
|
1007
1085
|
}
|
|
1008
1086
|
|
|
1009
|
-
|
|
1087
|
+
/** @public */
|
|
1088
|
+
declare const IconBundleBlueprint: ExtensionBlueprint<{
|
|
1089
|
+
icons: {
|
|
1090
|
+
[x: string]: IconComponent;
|
|
1091
|
+
};
|
|
1092
|
+
}, AnyExtensionInputMap, {
|
|
1093
|
+
icons: ConfigurableExtensionDataRef<"core.icons", {
|
|
1094
|
+
[x: string]: IconComponent;
|
|
1095
|
+
}, {}>;
|
|
1096
|
+
}, unknown, {
|
|
1097
|
+
icons: ConfigurableExtensionDataRef<"core.icons", {
|
|
1098
|
+
[x: string]: IconComponent;
|
|
1099
|
+
}, {}>;
|
|
1100
|
+
}>;
|
|
1101
|
+
|
|
1102
|
+
export { type AnalyticsApi, AnalyticsContext, type AnalyticsContextValue, type AnalyticsEvent, type AnalyticsEventAttributes, type AnalyticsTracker, type AnyExtensionDataMap, type AnyExtensionInputMap, type AnyExternalRoutes, type AnyRouteRefParams, type AnyRoutes, type AppNode, type AppNodeEdges, type AppNodeInstance, type AppNodeSpec, type AppTree, type AppTreeApi, type BackstagePlugin, type CommonAnalyticsContext, type ComponentRef, type ComponentsApi, type ConfigurableExtensionDataRef, type CoreErrorBoundaryFallbackProps, type CoreNotFoundErrorPageProps, type CoreProgressProps, type CreateExtensionBlueprintOptions, type CreateExtensionOptions, type Extension, type ExtensionBlueprint, ExtensionBoundary, type ExtensionBoundaryProps, type ExtensionDataRef, type ExtensionDataValues, type ExtensionDefinition, type ExtensionInput, type ExtensionOverrides, type ExtensionOverridesOptions, type ExternalRouteRef, type FeatureFlagConfig, type FrontendFeature, IconBundleBlueprint, type IconComponent, type IconsApi, type PluginOptions, type PortableSchema, type ResolvedExtensionInput, type ResolvedExtensionInputs, type RouteFunc, type RouteRef, type RouteResolutionApi, type RouteResolutionApiResolveOptions, type SubRouteRef, analyticsApiRef, appTreeApiRef, componentsApiRef, coreComponentRefs, coreExtensionData, createApiExtension, createAppRootElementExtension, createAppRootWrapperExtension, createComponentExtension, createComponentRef, createExtension, createExtensionBlueprint, createExtensionDataRef, createExtensionInput, createExtensionOverrides, createExternalRouteRef, createNavItemExtension, createNavLogoExtension, createPageExtension, createPlugin, createRouteRef, createRouterExtension, createSchemaFromZod, createSignInPageExtension, createSubRouteRef, createThemeExtension, createTranslationExtension, iconsApiRef, routeResolutionApiRef, useAnalytics, useComponentRef, useRouteRef, useRouteRefParams };
|
package/dist/index.esm.js
CHANGED
|
@@ -20,6 +20,7 @@ export { createSignInPageExtension } from './extensions/createSignInPageExtensio
|
|
|
20
20
|
export { createThemeExtension } from './extensions/createThemeExtension.esm.js';
|
|
21
21
|
export { createComponentExtension } from './extensions/createComponentExtension.esm.js';
|
|
22
22
|
export { createTranslationExtension } from './extensions/createTranslationExtension.esm.js';
|
|
23
|
+
export { IconBundleBlueprint } from './extensions/IconBundleBlueprint.esm.js';
|
|
23
24
|
export { createRouteRef } from './routing/RouteRef.esm.js';
|
|
24
25
|
export { createSubRouteRef } from './routing/SubRouteRef.esm.js';
|
|
25
26
|
export { createExternalRouteRef } from './routing/ExternalRouteRef.esm.js';
|
|
@@ -33,4 +34,5 @@ export { createExtensionInput } from './wiring/createExtensionInput.esm.js';
|
|
|
33
34
|
export { createExtensionDataRef } from './wiring/createExtensionDataRef.esm.js';
|
|
34
35
|
export { createPlugin } from './wiring/createPlugin.esm.js';
|
|
35
36
|
export { createExtensionOverrides } from './wiring/createExtensionOverrides.esm.js';
|
|
37
|
+
export { createExtensionBlueprint } from './wiring/createExtensionBlueprint.esm.js';
|
|
36
38
|
//# sourceMappingURL=index.esm.js.map
|
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,9 +1,11 @@
|
|
|
1
1
|
import { createExtensionDataRef } from './createExtensionDataRef.esm.js';
|
|
2
2
|
|
|
3
3
|
const coreExtensionData = {
|
|
4
|
-
reactElement: createExtensionDataRef(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
reactElement: createExtensionDataRef().with({
|
|
5
|
+
id: "core.reactElement"
|
|
6
|
+
}),
|
|
7
|
+
routePath: createExtensionDataRef().with({ id: "core.routing.path" }),
|
|
8
|
+
routeRef: createExtensionDataRef().with({ id: "core.routing.ref" })
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export { coreExtensionData };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreExtensionData.esm.js","sources":["../../src/wiring/coreExtensionData.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 { JSX } from 'react';\nimport { RouteRef } from '../routing';\nimport { createExtensionDataRef } from './createExtensionDataRef';\n\n/** @public */\nexport const coreExtensionData = {\n reactElement: createExtensionDataRef<JSX.Element>('core.reactElement'),\n routePath: createExtensionDataRef<string>('core.routing.path'),\n routeRef: createExtensionDataRef<RouteRef>('core.routing.ref'),\n};\n"],"names":[],"mappings":";;AAqBO,MAAM,iBAAoB,GAAA;AAAA,EAC/B,YAAA,EAAc,
|
|
1
|
+
{"version":3,"file":"coreExtensionData.esm.js","sources":["../../src/wiring/coreExtensionData.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 { JSX } from 'react';\nimport { RouteRef } from '../routing';\nimport { createExtensionDataRef } from './createExtensionDataRef';\n\n/** @public */\nexport const coreExtensionData = {\n reactElement: createExtensionDataRef<JSX.Element>().with({\n id: 'core.reactElement',\n }),\n routePath: createExtensionDataRef<string>().with({ id: 'core.routing.path' }),\n routeRef: createExtensionDataRef<RouteRef>().with({ id: 'core.routing.ref' }),\n};\n"],"names":[],"mappings":";;AAqBO,MAAM,iBAAoB,GAAA;AAAA,EAC/B,YAAA,EAAc,sBAAoC,EAAA,CAAE,IAAK,CAAA;AAAA,IACvD,EAAI,EAAA,mBAAA;AAAA,GACL,CAAA;AAAA,EACD,WAAW,sBAA+B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,qBAAqB,CAAA;AAAA,EAC5E,UAAU,sBAAiC,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,oBAAoB,CAAA;AAC9E;;;;"}
|
|
@@ -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 { AppNode } from '../apis';\nimport { PortableSchema } from '../schema';\nimport { Expand } from '../types';\nimport { ExtensionDataRef } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\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/**\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 * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<TExtensionData extends AnyExtensionDataMap> =\n {\n node: AppNode;\n output: ExtensionDataValues<TExtensionData>;\n };\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends { [name in string]: ExtensionInput<any, any> },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>\n : Expand<\n ResolvedExtensionInput<TInputs[InputName]['extensionData']> | undefined\n >;\n};\n\n/** @public */\nexport interface CreateExtensionOptions<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig,\n> {\n kind?: string;\n namespace?: string;\n name?: string;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: TOutput;\n configSchema?: PortableSchema<TConfig>;\n factory(
|
|
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 { AppNode } from '../apis';\nimport { PortableSchema } from '../schema';\nimport { Expand } from '../types';\nimport { ExtensionDataRef } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\n\n/** @public */\nexport type AnyExtensionDataMap = {\n [name in string]: ExtensionDataRef<unknown, string, { 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/**\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 * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<TExtensionData extends AnyExtensionDataMap> =\n {\n node: AppNode;\n output: ExtensionDataValues<TExtensionData>;\n };\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends { [name in string]: ExtensionInput<any, any> },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>\n : Expand<\n ResolvedExtensionInput<TInputs[InputName]['extensionData']> | undefined\n >;\n};\n\n/** @public */\nexport interface CreateExtensionOptions<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig,\n> {\n kind?: string;\n namespace?: string;\n name?: string;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: TOutput;\n configSchema?: PortableSchema<TConfig>;\n factory(context: {\n node: AppNode;\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }): Expand<ExtensionDataValues<TOutput>>;\n}\n\n/** @public */\nexport interface ExtensionDefinition<TConfig> {\n $$type: '@backstage/ExtensionDefinition';\n readonly kind?: string;\n readonly namespace?: string;\n readonly name?: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<TConfig>;\n}\n\n/** @internal */\nexport interface InternalExtensionDefinition<TConfig>\n extends ExtensionDefinition<TConfig> {\n readonly version: 'v1';\n readonly inputs: AnyExtensionInputMap;\n readonly output: AnyExtensionDataMap;\n factory(context: {\n node: AppNode;\n config: TConfig;\n inputs: ResolvedExtensionInputs<any>;\n }): ExtensionDataValues<any>;\n}\n\n/** @internal */\nexport function toInternalExtensionDefinition<TConfig>(\n overrides: ExtensionDefinition<TConfig>,\n): InternalExtensionDefinition<TConfig> {\n const internal = overrides as InternalExtensionDefinition<TConfig>;\n if (internal.$$type !== '@backstage/ExtensionDefinition') {\n throw new Error(\n `Invalid extension definition instance, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid extension definition instance, bad version '${internal.version}'`,\n );\n }\n return internal;\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): ExtensionDefinition<TConfig> {\n return {\n $$type: '@backstage/ExtensionDefinition',\n version: 'v1',\n kind: options.kind,\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo,\n disabled: options.disabled ?? false,\n inputs: options.inputs ?? {},\n output: options.output,\n configSchema: options.configSchema,\n factory({ inputs, ...rest }) {\n // TODO: Simplify this, but TS wouldn't infer the input type for some reason\n return options.factory({\n inputs: inputs as Expand<ResolvedExtensionInputs<TInputs>>,\n ...rest,\n });\n },\n toString() {\n const parts: string[] = [];\n if (options.kind) {\n parts.push(`kind=${options.kind}`);\n }\n if (options.namespace) {\n parts.push(`namespace=${options.namespace}`);\n }\n if (options.name) {\n parts.push(`name=${options.name}`);\n }\n parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`);\n return `ExtensionDefinition{${parts.join(',')}}`;\n },\n } as InternalExtensionDefinition<TConfig>;\n}\n"],"names":[],"mappings":"AA6HO,SAAS,8BACd,SACsC,EAAA;AACtC,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,gCAAkC,EAAA;AACxD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,iDAAA,EAAoD,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,KACrE,CAAA;AAAA,GACF;AACA,EAAI,IAAA,QAAA,CAAS,YAAY,IAAM,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,oDAAA,EAAuD,SAAS,OAAO,CAAA,CAAA,CAAA;AAAA,KACzE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAGO,SAAS,gBAKd,OAC8B,EAAA;AAC9B,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA,gCAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,IACT,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,WAAW,OAAQ,CAAA,SAAA;AAAA,IACnB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,QAAA,EAAU,QAAQ,QAAY,IAAA,KAAA;AAAA,IAC9B,MAAA,EAAQ,OAAQ,CAAA,MAAA,IAAU,EAAC;AAAA,IAC3B,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,cAAc,OAAQ,CAAA,YAAA;AAAA,IACtB,OAAQ,CAAA,EAAE,MAAQ,EAAA,GAAG,MAAQ,EAAA;AAE3B,MAAA,OAAO,QAAQ,OAAQ,CAAA;AAAA,QACrB,MAAA;AAAA,QACA,GAAG,IAAA;AAAA,OACJ,CAAA,CAAA;AAAA,KACH;AAAA,IACA,QAAW,GAAA;AACT,MAAA,MAAM,QAAkB,EAAC,CAAA;AACzB,MAAA,IAAI,QAAQ,IAAM,EAAA;AAChB,QAAA,KAAA,CAAM,IAAK,CAAA,CAAA,KAAA,EAAQ,OAAQ,CAAA,IAAI,CAAE,CAAA,CAAA,CAAA;AAAA,OACnC;AACA,MAAA,IAAI,QAAQ,SAAW,EAAA;AACrB,QAAA,KAAA,CAAM,IAAK,CAAA,CAAA,UAAA,EAAa,OAAQ,CAAA,SAAS,CAAE,CAAA,CAAA,CAAA;AAAA,OAC7C;AACA,MAAA,IAAI,QAAQ,IAAM,EAAA;AAChB,QAAA,KAAA,CAAM,IAAK,CAAA,CAAA,KAAA,EAAQ,OAAQ,CAAA,IAAI,CAAE,CAAA,CAAA,CAAA;AAAA,OACnC;AACA,MAAM,KAAA,CAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,QAAA,CAAS,EAAE,CAAI,CAAA,EAAA,OAAA,CAAQ,QAAS,CAAA,KAAK,CAAE,CAAA,CAAA,CAAA;AACtE,MAAA,OAAO,CAAuB,oBAAA,EAAA,KAAA,CAAM,IAAK,CAAA,GAAG,CAAC,CAAA,CAAA,CAAA,CAAA;AAAA,KAC/C;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createExtension } from './createExtension.esm.js';
|
|
2
|
+
|
|
3
|
+
class ExtensionBlueprintImpl {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = options;
|
|
6
|
+
this.dataRefs = options.dataRefs;
|
|
7
|
+
}
|
|
8
|
+
dataRefs;
|
|
9
|
+
make(args) {
|
|
10
|
+
return createExtension({
|
|
11
|
+
kind: this.options.kind,
|
|
12
|
+
namespace: args.namespace ?? this.options.namespace,
|
|
13
|
+
name: args.name,
|
|
14
|
+
attachTo: args.attachTo ?? this.options.attachTo,
|
|
15
|
+
disabled: args.disabled ?? this.options.disabled,
|
|
16
|
+
inputs: args.inputs ?? this.options.inputs,
|
|
17
|
+
output: args.output ?? this.options.output,
|
|
18
|
+
configSchema: args.configSchema ?? this.options.configSchema,
|
|
19
|
+
// TODO: some config merging or smth
|
|
20
|
+
factory: ({ node, config, inputs }) => {
|
|
21
|
+
if (args.factory) {
|
|
22
|
+
return args.factory(
|
|
23
|
+
(innerParams, innerContext) => this.options.factory(innerParams, {
|
|
24
|
+
node,
|
|
25
|
+
config: innerContext?.config ?? config,
|
|
26
|
+
inputs: innerContext?.inputs ?? inputs
|
|
27
|
+
}),
|
|
28
|
+
{
|
|
29
|
+
node,
|
|
30
|
+
config,
|
|
31
|
+
inputs
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
} else if (args.params) {
|
|
35
|
+
return this.options.factory(args.params, {
|
|
36
|
+
node,
|
|
37
|
+
config,
|
|
38
|
+
inputs
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
throw new Error("Either params or factory must be provided");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function createExtensionBlueprint(options) {
|
|
47
|
+
return new ExtensionBlueprintImpl(options);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { createExtensionBlueprint };
|
|
51
|
+
//# sourceMappingURL=createExtensionBlueprint.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createExtensionBlueprint.esm.js","sources":["../../src/wiring/createExtensionBlueprint.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 { PortableSchema } from '../schema';\nimport { Expand } from '../types';\nimport {\n AnyExtensionDataMap,\n AnyExtensionInputMap,\n ExtensionDataValues,\n ExtensionDefinition,\n ResolvedExtensionInputs,\n createExtension,\n} from './createExtension';\n\n/**\n * @public\n */\nexport interface CreateExtensionBlueprintOptions<\n TParams,\n TInputs extends AnyExtensionInputMap,\n TOutput extends AnyExtensionDataMap,\n TConfig,\n TDataRefs extends AnyExtensionDataMap,\n> {\n kind: string;\n namespace?: string;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: TOutput;\n configSchema?: PortableSchema<TConfig>;\n factory(\n params: TParams,\n context: {\n node: AppNode;\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n },\n ): Expand<ExtensionDataValues<TOutput>>;\n\n dataRefs?: TDataRefs;\n}\n\n/**\n * @public\n */\nexport interface ExtensionBlueprint<\n TParams,\n TInputs extends AnyExtensionInputMap,\n TOutput extends AnyExtensionDataMap,\n TConfig,\n TDataRefs extends AnyExtensionDataMap,\n> {\n dataRefs: TDataRefs;\n\n /**\n * Creates a new extension from the blueprint.\n *\n * You must either pass `params` directly, or define a `factory` that can\n * optionally call the original factory with the same params.\n */\n make(\n args: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output?: TOutput;\n configSchema?: PortableSchema<TConfig>;\n } & (\n | {\n factory(\n originalFactory: (\n params: TParams,\n context?: {\n config?: TConfig;\n inputs?: Expand<ResolvedExtensionInputs<TInputs>>;\n },\n ) => Expand<ExtensionDataValues<TOutput>>,\n context: {\n node: AppNode;\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n },\n ): Expand<ExtensionDataValues<TOutput>>;\n }\n | {\n params: TParams;\n }\n ),\n ): ExtensionDefinition<TConfig>;\n}\n\n/**\n * @internal\n */\nclass ExtensionBlueprintImpl<\n TParams,\n TInputs extends AnyExtensionInputMap,\n TOutput extends AnyExtensionDataMap,\n TConfig,\n TDataRefs extends AnyExtensionDataMap,\n> {\n constructor(\n private readonly options: CreateExtensionBlueprintOptions<\n TParams,\n TInputs,\n TOutput,\n TConfig,\n TDataRefs\n >,\n ) {\n this.dataRefs = options.dataRefs!;\n }\n\n dataRefs: TDataRefs;\n\n public make(args: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output?: TOutput;\n configSchema?: PortableSchema<TConfig>;\n params?: TParams;\n factory?(\n originalFactory: (\n params: TParams,\n context?: {\n config?: TConfig;\n inputs?: Expand<ResolvedExtensionInputs<TInputs>>;\n },\n ) => Expand<ExtensionDataValues<TOutput>>,\n context: {\n node: AppNode;\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n },\n ): Expand<ExtensionDataValues<TOutput>>;\n }): ExtensionDefinition<TConfig> {\n return createExtension({\n kind: this.options.kind,\n namespace: args.namespace ?? this.options.namespace,\n name: args.name,\n attachTo: args.attachTo ?? this.options.attachTo,\n disabled: args.disabled ?? this.options.disabled,\n inputs: args.inputs ?? this.options.inputs,\n output: args.output ?? this.options.output,\n configSchema: args.configSchema ?? this.options.configSchema, // TODO: some config merging or smth\n factory: ({ node, config, inputs }) => {\n if (args.factory) {\n return args.factory(\n (\n innerParams: TParams,\n innerContext?: {\n config?: TConfig;\n inputs?: Expand<ResolvedExtensionInputs<TInputs>>;\n },\n ) =>\n this.options.factory(innerParams, {\n node,\n config: innerContext?.config ?? config,\n inputs: innerContext?.inputs ?? inputs,\n }),\n {\n node,\n config,\n inputs,\n },\n );\n } else if (args.params) {\n return this.options.factory(args.params, {\n node,\n config,\n inputs,\n });\n }\n throw new Error('Either params or factory must be provided');\n },\n });\n }\n}\n\n/**\n * A simpler replacement for wrapping up `createExtension` inside a kind or type. This allows for a cleaner API for creating\n * types and instances of those types.\n *\n * @public\n */\nexport function createExtensionBlueprint<\n TParams,\n TInputs extends AnyExtensionInputMap,\n TOutput extends AnyExtensionDataMap,\n TConfig,\n TDataRefs extends AnyExtensionDataMap = never,\n>(\n options: CreateExtensionBlueprintOptions<\n TParams,\n TInputs,\n TOutput,\n TConfig,\n TDataRefs\n >,\n): ExtensionBlueprint<TParams, TInputs, TOutput, TConfig, TDataRefs> {\n return new ExtensionBlueprintImpl(options);\n}\n"],"names":[],"mappings":";;AA+GA,MAAM,sBAMJ,CAAA;AAAA,EACA,YACmB,OAOjB,EAAA;AAPiB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA,CAAA;AAQjB,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA,CAAA;AAAA,GAC1B;AAAA,EAEA,QAAA,CAAA;AAAA,EAEO,KAAK,IAuBqB,EAAA;AAC/B,IAAA,OAAO,eAAgB,CAAA;AAAA,MACrB,IAAA,EAAM,KAAK,OAAQ,CAAA,IAAA;AAAA,MACnB,SAAW,EAAA,IAAA,CAAK,SAAa,IAAA,IAAA,CAAK,OAAQ,CAAA,SAAA;AAAA,MAC1C,MAAM,IAAK,CAAA,IAAA;AAAA,MACX,QAAU,EAAA,IAAA,CAAK,QAAY,IAAA,IAAA,CAAK,OAAQ,CAAA,QAAA;AAAA,MACxC,QAAU,EAAA,IAAA,CAAK,QAAY,IAAA,IAAA,CAAK,OAAQ,CAAA,QAAA;AAAA,MACxC,MAAQ,EAAA,IAAA,CAAK,MAAU,IAAA,IAAA,CAAK,OAAQ,CAAA,MAAA;AAAA,MACpC,MAAQ,EAAA,IAAA,CAAK,MAAU,IAAA,IAAA,CAAK,OAAQ,CAAA,MAAA;AAAA,MACpC,YAAc,EAAA,IAAA,CAAK,YAAgB,IAAA,IAAA,CAAK,OAAQ,CAAA,YAAA;AAAA;AAAA,MAChD,SAAS,CAAC,EAAE,IAAM,EAAA,MAAA,EAAQ,QAAa,KAAA;AACrC,QAAA,IAAI,KAAK,OAAS,EAAA;AAChB,UAAA,OAAO,IAAK,CAAA,OAAA;AAAA,YACV,CACE,WACA,EAAA,YAAA,KAKA,IAAK,CAAA,OAAA,CAAQ,QAAQ,WAAa,EAAA;AAAA,cAChC,IAAA;AAAA,cACA,MAAA,EAAQ,cAAc,MAAU,IAAA,MAAA;AAAA,cAChC,MAAA,EAAQ,cAAc,MAAU,IAAA,MAAA;AAAA,aACjC,CAAA;AAAA,YACH;AAAA,cACE,IAAA;AAAA,cACA,MAAA;AAAA,cACA,MAAA;AAAA,aACF;AAAA,WACF,CAAA;AAAA,SACF,MAAA,IAAW,KAAK,MAAQ,EAAA;AACtB,UAAA,OAAO,IAAK,CAAA,OAAA,CAAQ,OAAQ,CAAA,IAAA,CAAK,MAAQ,EAAA;AAAA,YACvC,IAAA;AAAA,YACA,MAAA;AAAA,YACA,MAAA;AAAA,WACD,CAAA,CAAA;AAAA,SACH;AACA,QAAM,MAAA,IAAI,MAAM,2CAA2C,CAAA,CAAA;AAAA,OAC7D;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAA;AAQO,SAAS,yBAOd,OAOmE,EAAA;AACnE,EAAO,OAAA,IAAI,uBAAuB,OAAO,CAAA,CAAA;AAC3C;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function createExtensionDataRef(id) {
|
|
2
|
-
|
|
3
|
-
id,
|
|
2
|
+
const createRef = (refId) => ({
|
|
3
|
+
id: refId,
|
|
4
4
|
$$type: "@backstage/ExtensionDataRef",
|
|
5
5
|
config: {},
|
|
6
6
|
optional() {
|
|
@@ -11,7 +11,15 @@ function createExtensionDataRef(id) {
|
|
|
11
11
|
},
|
|
12
12
|
toString() {
|
|
13
13
|
const optional = Boolean(this.config.optional);
|
|
14
|
-
return `ExtensionDataRef{id=${
|
|
14
|
+
return `ExtensionDataRef{id=${refId},optional=${optional}}`;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
if (id) {
|
|
18
|
+
return createRef(id);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
with(options) {
|
|
22
|
+
return createRef(options.id);
|
|
15
23
|
}
|
|
16
24
|
};
|
|
17
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtensionDataRef.esm.js","sources":["../../src/wiring/createExtensionDataRef.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\n/** @public */\nexport type ExtensionDataRef<\n TData,\n TConfig extends { optional?: true } = {},\n> = {\n id:
|
|
1
|
+
{"version":3,"file":"createExtensionDataRef.esm.js","sources":["../../src/wiring/createExtensionDataRef.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\n/** @public */\nexport type ExtensionDataRef<\n TData,\n TId extends string = string,\n TConfig extends { optional?: true } = {},\n> = {\n id: TId;\n T: TData;\n config: TConfig;\n $$type: '@backstage/ExtensionDataRef';\n};\n\n/** @public */\nexport interface ConfigurableExtensionDataRef<\n TId extends string,\n TData,\n TConfig extends { optional?: true } = {},\n> extends ExtensionDataRef<TData, TId, TConfig> {\n optional(): ConfigurableExtensionDataRef<\n TId,\n TData,\n TData & { optional: true }\n >;\n}\n\n/**\n * @public\n * @deprecated Use the following form instead: `createExtensionDataRef<Type>().with({ id: 'core.foo' })`\n */\nexport function createExtensionDataRef<TData>(\n id: string,\n): ConfigurableExtensionDataRef<string, TData>;\n/** @public */\nexport function createExtensionDataRef<TData>(): {\n with<TId extends string>(options: {\n id: TId;\n }): ConfigurableExtensionDataRef<TId, TData>;\n};\nexport function createExtensionDataRef<TData>(id?: string):\n | ConfigurableExtensionDataRef<string, TData>\n | {\n with<TId extends string>(options: {\n id: TId;\n }): ConfigurableExtensionDataRef<TId, TData>;\n } {\n const createRef = <TId extends string>(refId: TId) =>\n ({\n id: refId,\n $$type: '@backstage/ExtensionDataRef',\n config: {},\n optional() {\n return {\n ...this,\n config: { ...this.config, optional: true },\n };\n },\n toString() {\n const optional = Boolean(this.config.optional);\n return `ExtensionDataRef{id=${refId},optional=${optional}}`;\n },\n } as ConfigurableExtensionDataRef<TId, TData, { optional?: true }>);\n if (id) {\n return createRef(id);\n }\n return {\n with<TId extends string>(options: { id: TId }) {\n return createRef(options.id);\n },\n };\n}\n"],"names":[],"mappings":"AAsDO,SAAS,uBAA8B,EAMxC,EAAA;AACJ,EAAM,MAAA,SAAA,GAAY,CAAqB,KACpC,MAAA;AAAA,IACC,EAAI,EAAA,KAAA;AAAA,IACJ,MAAQ,EAAA,6BAAA;AAAA,IACR,QAAQ,EAAC;AAAA,IACT,QAAW,GAAA;AACT,MAAO,OAAA;AAAA,QACL,GAAG,IAAA;AAAA,QACH,QAAQ,EAAE,GAAG,IAAK,CAAA,MAAA,EAAQ,UAAU,IAAK,EAAA;AAAA,OAC3C,CAAA;AAAA,KACF;AAAA,IACA,QAAW,GAAA;AACT,MAAA,MAAM,QAAW,GAAA,OAAA,CAAQ,IAAK,CAAA,MAAA,CAAO,QAAQ,CAAA,CAAA;AAC7C,MAAO,OAAA,CAAA,oBAAA,EAAuB,KAAK,CAAA,UAAA,EAAa,QAAQ,CAAA,CAAA,CAAA,CAAA;AAAA,KAC1D;AAAA,GACF,CAAA,CAAA;AACF,EAAA,IAAI,EAAI,EAAA;AACN,IAAA,OAAO,UAAU,EAAE,CAAA,CAAA;AAAA,GACrB;AACA,EAAO,OAAA;AAAA,IACL,KAAyB,OAAsB,EAAA;AAC7C,MAAO,OAAA,SAAA,CAAU,QAAQ,EAAE,CAAA,CAAA;AAAA,KAC7B;AAAA,GACF,CAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-plugin-api",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8-next.0",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "backstage-cli package test"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@backstage/core-components": "^0.14.
|
|
34
|
+
"@backstage/core-components": "^0.14.10-next.0",
|
|
35
35
|
"@backstage/core-plugin-api": "^1.9.3",
|
|
36
36
|
"@backstage/types": "^1.1.1",
|
|
37
37
|
"@backstage/version-bridge": "^1.0.8",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"zod-to-json-schema": "^3.21.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@backstage/cli": "^0.
|
|
46
|
-
"@backstage/frontend-app-api": "^0.7.
|
|
47
|
-
"@backstage/frontend-test-utils": "^0.1.
|
|
48
|
-
"@backstage/test-utils": "^1.5.
|
|
45
|
+
"@backstage/cli": "^0.27.0-next.0",
|
|
46
|
+
"@backstage/frontend-app-api": "^0.7.4-next.0",
|
|
47
|
+
"@backstage/frontend-test-utils": "^0.1.11-next.0",
|
|
48
|
+
"@backstage/test-utils": "^1.5.9-next.0",
|
|
49
49
|
"@testing-library/jest-dom": "^6.0.0",
|
|
50
50
|
"@testing-library/react": "^15.0.0",
|
|
51
51
|
"history": "^5.3.0"
|