@backstage/frontend-app-api 0.11.2-next.3 → 0.11.3-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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @backstage/frontend-app-api
2
2
 
3
+ ## 0.11.3-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - c38c9e8: Implemented support for the `plugin.info()` method in specialized apps with a default resolved for `package.json` and `catalog-info.yaml`. The default resolution logic can be overridden via the `pluginInfoResolver` option to `createSpecializedApp`, and plugin-specific overrides can be applied via the new `app.pluginOverrides` key in static configuration.
8
+ - Updated dependencies
9
+ - @backstage/frontend-plugin-api@0.10.3-next.0
10
+ - @backstage/frontend-defaults@0.2.3-next.0
11
+
12
+ ## 0.11.2
13
+
14
+ ### Patch Changes
15
+
16
+ - 173db8f: Updates to use the new `plugin` property of `AppNodeSpec`.
17
+ - 1f04491: Added the ability to ignore unknown extension config by passing `{ flags: { allowUnknownExtensionConfig: true } }` to `createSpecializedApp`.
18
+ - 72d019d: Removed various typos
19
+ - Updated dependencies
20
+ - @backstage/frontend-plugin-api@0.10.2
21
+ - @backstage/core-app-api@1.17.0
22
+ - @backstage/core-plugin-api@1.10.7
23
+ - @backstage/frontend-defaults@0.2.2
24
+ - @backstage/config@1.3.2
25
+ - @backstage/errors@1.2.7
26
+ - @backstage/types@1.2.1
27
+ - @backstage/version-bridge@1.0.11
28
+
3
29
  ## 0.11.2-next.3
4
30
 
5
31
  ### Patch Changes
package/config.d.ts CHANGED
@@ -51,5 +51,71 @@ export interface Config {
51
51
  };
52
52
  }
53
53
  >;
54
+
55
+ /**
56
+ * This section enables you to override certain properties of specific or
57
+ * groups of plugins.
58
+ *
59
+ * @remarks
60
+ * All matching entries will be applied to each plugin, with the later
61
+ * entries taking precedence.
62
+ *
63
+ * This configuration is intended to be used primarily to apply overrides
64
+ * for third-party plugins.
65
+ *
66
+ * @deepVisibility frontend
67
+ */
68
+ pluginOverrides?: Array<{
69
+ /**
70
+ * The criteria for matching plugins to override.
71
+ *
72
+ * @remarks
73
+ * If no match criteria are provided, the override will be applied to
74
+ * all plugins.
75
+ */
76
+ match?: {
77
+ /**
78
+ * A pattern that is matched against the plugin ID.
79
+ *
80
+ * @remarks
81
+ * By default the string is interpreted as a glob pattern, but if the
82
+ * string is surrounded by '/' it is interpreted as a regex.
83
+ */
84
+ pluginId?: string;
85
+
86
+ /**
87
+ * A pattern that is matched against the package name.
88
+ *
89
+ * @remarks
90
+ * By default the string is interpreted as a glob pattern, but if the
91
+ * string is surrounded by '/' it is interpreted as a regex.
92
+ *
93
+ * Note that this will only work for plugins that provide a
94
+ * `package.json` info loader.
95
+ */
96
+ packageName?: string;
97
+ };
98
+ /**
99
+ * Overrides individual top-level fields of the plugin info.
100
+ */
101
+ info: {
102
+ /**
103
+ * Override the description of the plugin.
104
+ */
105
+ description?: string;
106
+ /**
107
+ * Override the owner entity references of the plugin.
108
+ *
109
+ * @remarks
110
+ * The provided values are interpreted as entity references defaulting
111
+ * to Group entities in the default namespace.
112
+ */
113
+ ownerEntityRefs?: string[];
114
+ /**
115
+ * Override the links of the plugin.
116
+ */
117
+ links?: Array<{ title: string; url: string }>;
118
+ };
119
+ }>;
54
120
  };
55
121
  }
@@ -0,0 +1,4 @@
1
+ const DEFAULT_NAMESPACE = "default";
2
+
3
+ export { DEFAULT_NAMESPACE };
4
+ //# sourceMappingURL=constants.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.esm.js","sources":["../../../../../catalog-model/src/entity/constants.ts"],"sourcesContent":["/*\n * Copyright 2020 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/**\n * The namespace that entities without an explicit namespace fall into.\n *\n * @public\n */\nexport const DEFAULT_NAMESPACE = 'default';\n\n/**\n * Annotation for linking to entity page from catalog pages.\n *\n * @public\n */\nexport const ANNOTATION_VIEW_URL = 'backstage.io/view-url';\n\n/**\n * Annotation for linking to entity edit page from catalog pages.\n *\n * @public\n */\nexport const ANNOTATION_EDIT_URL = 'backstage.io/edit-url';\n\n/**\n * Annotation for specifying the API server of a Kubernetes cluster\n *\n * @deprecated Import this constant from `@backstage/plugin-kubernetes-common` instead\n * @public\n */\nexport const ANNOTATION_KUBERNETES_API_SERVER = 'kubernetes.io/api-server';\n\n/**\n * Annotation for specifying the Certificate Authority of an API server for a Kubernetes cluster\n *\n * @deprecated Import this constant from `@backstage/plugin-kubernetes-common` instead\n * @public\n */\nexport const ANNOTATION_KUBERNETES_API_SERVER_CA =\n 'kubernetes.io/api-server-certificate-authority';\n\n/**\n * Annotation for specifying the auth provider for a Kubernetes cluster\n *\n * @deprecated Import this constant from `@backstage/plugin-kubernetes-common` instead\n * @public\n */\nexport const ANNOTATION_KUBERNETES_AUTH_PROVIDER =\n 'kubernetes.io/auth-provider';\n"],"names":[],"mappings":"AAqBO,MAAM,iBAAoB,GAAA;;;;"}
@@ -0,0 +1,73 @@
1
+ import { DEFAULT_NAMESPACE } from './constants.esm.js';
2
+
3
+ function parseRefString(ref) {
4
+ let colonI = ref.indexOf(":");
5
+ const slashI = ref.indexOf("/");
6
+ if (slashI !== -1 && slashI < colonI) {
7
+ colonI = -1;
8
+ }
9
+ const kind = colonI === -1 ? void 0 : ref.slice(0, colonI);
10
+ const namespace = slashI === -1 ? void 0 : ref.slice(colonI + 1, slashI);
11
+ const name = ref.slice(Math.max(colonI + 1, slashI + 1));
12
+ if (kind === "" || namespace === "" || name === "") {
13
+ throw new TypeError(
14
+ `Entity reference "${ref}" was not on the form [<kind>:][<namespace>/]<name>`
15
+ );
16
+ }
17
+ return { kind, namespace, name };
18
+ }
19
+ function parseEntityRef(ref, context) {
20
+ if (!ref) {
21
+ throw new Error(`Entity reference must not be empty`);
22
+ }
23
+ const defaultKind = context?.defaultKind;
24
+ const defaultNamespace = context?.defaultNamespace || DEFAULT_NAMESPACE;
25
+ let kind;
26
+ let namespace;
27
+ let name;
28
+ if (typeof ref === "string") {
29
+ const parsed = parseRefString(ref);
30
+ kind = parsed.kind ?? defaultKind;
31
+ namespace = parsed.namespace ?? defaultNamespace;
32
+ name = parsed.name;
33
+ } else {
34
+ kind = ref.kind ?? defaultKind;
35
+ namespace = ref.namespace ?? defaultNamespace;
36
+ name = ref.name;
37
+ }
38
+ if (!kind) {
39
+ const textual = JSON.stringify(ref);
40
+ throw new Error(
41
+ `Entity reference ${textual} had missing or empty kind (e.g. did not start with "component:" or similar)`
42
+ );
43
+ } else if (!namespace) {
44
+ const textual = JSON.stringify(ref);
45
+ throw new Error(
46
+ `Entity reference ${textual} had missing or empty namespace`
47
+ );
48
+ } else if (!name) {
49
+ const textual = JSON.stringify(ref);
50
+ throw new Error(`Entity reference ${textual} had missing or empty name`);
51
+ }
52
+ return { kind, namespace, name };
53
+ }
54
+ function stringifyEntityRef(ref) {
55
+ let kind;
56
+ let namespace;
57
+ let name;
58
+ if ("metadata" in ref) {
59
+ kind = ref.kind;
60
+ namespace = ref.metadata.namespace ?? DEFAULT_NAMESPACE;
61
+ name = ref.metadata.name;
62
+ } else {
63
+ kind = ref.kind;
64
+ namespace = ref.namespace ?? DEFAULT_NAMESPACE;
65
+ name = ref.name;
66
+ }
67
+ return `${kind.toLocaleLowerCase("en-US")}:${namespace.toLocaleLowerCase(
68
+ "en-US"
69
+ )}/${name.toLocaleLowerCase("en-US")}`;
70
+ }
71
+
72
+ export { parseEntityRef, stringifyEntityRef };
73
+ //# sourceMappingURL=ref.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.esm.js","sources":["../../../../../catalog-model/src/entity/ref.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { DEFAULT_NAMESPACE } from './constants';\nimport { CompoundEntityRef } from '../types';\nimport { Entity } from './Entity';\n\nfunction parseRefString(ref: string): {\n kind?: string;\n namespace?: string;\n name: string;\n} {\n let colonI = ref.indexOf(':');\n const slashI = ref.indexOf('/');\n\n // If the / is ahead of the :, treat the rest as the name\n if (slashI !== -1 && slashI < colonI) {\n colonI = -1;\n }\n\n const kind = colonI === -1 ? undefined : ref.slice(0, colonI);\n const namespace = slashI === -1 ? undefined : ref.slice(colonI + 1, slashI);\n const name = ref.slice(Math.max(colonI + 1, slashI + 1));\n\n if (kind === '' || namespace === '' || name === '') {\n throw new TypeError(\n `Entity reference \"${ref}\" was not on the form [<kind>:][<namespace>/]<name>`,\n );\n }\n\n return { kind, namespace, name };\n}\n\n/**\n * Extracts the kind, namespace and name that form the compound entity ref\n * triplet of the given entity.\n *\n * @public\n * @param entity - An entity\n * @returns The compound entity ref\n */\nexport function getCompoundEntityRef(entity: Entity): CompoundEntityRef {\n return {\n kind: entity.kind,\n namespace: entity.metadata.namespace || DEFAULT_NAMESPACE,\n name: entity.metadata.name,\n };\n}\n\n/**\n * Parses an entity reference, either on string or compound form, and returns\n * a structure with a name, and optional kind and namespace.\n *\n * @remarks\n *\n * The context object can contain default values for the kind and namespace,\n * that will be used if the input reference did not specify any.\n *\n * @public\n * @param ref - The reference to parse\n * @param context - The context of defaults that the parsing happens within\n * @returns The compound form of the reference\n */\nexport function parseEntityRef(\n ref: string | { kind?: string; namespace?: string; name: string },\n context?: {\n /** The default kind, if none is given in the reference */\n defaultKind?: string;\n /** The default namespace, if none is given in the reference */\n defaultNamespace?: string;\n },\n): CompoundEntityRef {\n if (!ref) {\n throw new Error(`Entity reference must not be empty`);\n }\n\n const defaultKind = context?.defaultKind;\n const defaultNamespace = context?.defaultNamespace || DEFAULT_NAMESPACE;\n\n let kind: string | undefined;\n let namespace: string | undefined;\n let name: string | undefined;\n\n if (typeof ref === 'string') {\n const parsed = parseRefString(ref);\n kind = parsed.kind ?? defaultKind;\n namespace = parsed.namespace ?? defaultNamespace;\n name = parsed.name;\n } else {\n kind = ref.kind ?? defaultKind;\n namespace = ref.namespace ?? defaultNamespace;\n name = ref.name;\n }\n\n if (!kind) {\n const textual = JSON.stringify(ref);\n throw new Error(\n `Entity reference ${textual} had missing or empty kind (e.g. did not start with \"component:\" or similar)`,\n );\n } else if (!namespace) {\n const textual = JSON.stringify(ref);\n throw new Error(\n `Entity reference ${textual} had missing or empty namespace`,\n );\n } else if (!name) {\n const textual = JSON.stringify(ref);\n throw new Error(`Entity reference ${textual} had missing or empty name`);\n }\n\n return { kind, namespace, name };\n}\n\n/**\n * Takes an entity or entity name/reference, and returns the string form of an\n * entity ref.\n *\n * @remarks\n *\n * This function creates a canonical and unique reference to the entity, converting\n * all parts of the name to lowercase and inserts the default namespace if needed.\n * It is typically not the best way to represent the entity reference to the user.\n *\n * @public\n * @param ref - The reference to serialize\n * @returns The same reference on either string or compound form\n */\nexport function stringifyEntityRef(\n ref: Entity | { kind: string; namespace?: string; name: string },\n): string {\n let kind;\n let namespace;\n let name;\n\n if ('metadata' in ref) {\n kind = ref.kind;\n namespace = ref.metadata.namespace ?? DEFAULT_NAMESPACE;\n name = ref.metadata.name;\n } else {\n kind = ref.kind;\n namespace = ref.namespace ?? DEFAULT_NAMESPACE;\n name = ref.name;\n }\n\n return `${kind.toLocaleLowerCase('en-US')}:${namespace.toLocaleLowerCase(\n 'en-US',\n )}/${name.toLocaleLowerCase('en-US')}`;\n}\n"],"names":[],"mappings":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BAAA;AACtC,IAAA,IAAA,GAAO,IAAI,QAAS,CAAA,IAAA;AAAA,GACf,MAAA;AACL,IAAA,IAAA,GAAO,GAAI,CAAA,IAAA;AACX,IAAA,SAAA,GAAY,IAAI,SAAa,IAAA,iBAAA;AAC7B,IAAA,IAAA,GAAO,GAAI,CAAA,IAAA;AAAA;AAGb,EAAA,OAAO,GAAG,IAAK,CAAA,iBAAA,CAAkB,OAAO,CAAC,IAAI,SAAU,CAAA,iBAAA;AAAA,IACrD;AAAA,GACD,CAAA,CAAA,EAAI,IAAK,CAAA,iBAAA,CAAkB,OAAO,CAAC,CAAA,CAAA;AACtC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"InternalFrontendPlugin.esm.js","sources":["../../../../../frontend-internal/src/wiring/InternalFrontendPlugin.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 {\n Extension,\n FeatureFlagConfig,\n FrontendPlugin,\n} from '@backstage/frontend-plugin-api';\nimport { OpaqueType } from '@internal/opaque';\n\nexport const OpaqueFrontendPlugin = OpaqueType.create<{\n public: FrontendPlugin;\n versions: {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n };\n}>({\n type: '@backstage/FrontendPlugin',\n versions: ['v1'],\n});\n"],"names":[],"mappings":";;AAuBa,MAAA,oBAAA,GAAuB,WAAW,MAO5C,CAAA;AAAA,EACD,IAAM,EAAA,2BAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC;;;;"}
1
+ {"version":3,"file":"InternalFrontendPlugin.esm.js","sources":["../../../../../frontend-internal/src/wiring/InternalFrontendPlugin.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 {\n Extension,\n FeatureFlagConfig,\n FrontendPlugin,\n} from '@backstage/frontend-plugin-api';\nimport { JsonObject } from '@backstage/types';\nimport { OpaqueType } from '@internal/opaque';\n\nexport const OpaqueFrontendPlugin = OpaqueType.create<{\n public: FrontendPlugin;\n versions: {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n readonly infoOptions?: {\n packageJson?: () => Promise<JsonObject>;\n manifest?: () => Promise<JsonObject>;\n };\n };\n}>({\n type: '@backstage/FrontendPlugin',\n versions: ['v1'],\n});\n"],"names":[],"mappings":";;AAwBa,MAAA,oBAAA,GAAuB,WAAW,MAW5C,CAAA;AAAA,EACD,IAAM,EAAA,2BAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { ExternalRouteRef, RouteRef, SubRouteRef, FrontendFeature as FrontendFeature$1, ExtensionFactoryMiddleware, AppTree } from '@backstage/frontend-plugin-api';
1
+ import { ExternalRouteRef, RouteRef, SubRouteRef, FrontendPluginInfo, FrontendFeature as FrontendFeature$1, ExtensionFactoryMiddleware, AppTree } from '@backstage/frontend-plugin-api';
2
2
  import { ConfigApi, ApiHolder } from '@backstage/core-plugin-api';
3
+ import { JsonObject } from '@backstage/types';
3
4
 
4
5
  /**
5
6
  * Extracts a union of the keys in a map whose value extends the given type
@@ -39,10 +40,23 @@ type CreateAppRouteBinder = <TExternalRoutes extends {
39
40
  [name: string]: ExternalRouteRef;
40
41
  }>(externalRoutes: TExternalRoutes, targetRoutes: PartialKeys<TargetRouteMap<TExternalRoutes>, KeysWithType<TExternalRoutes, ExternalRouteRef<any>>>) => void;
41
42
 
42
- /** @public
43
- * @deprecated Use {@link @backstage/frontend-plugin-api#FrontendFeature} instead.
43
+ /**
44
+ * A function that resolves plugin info from a plugin manifest and package.json.
45
+ *
46
+ * @public
44
47
  */
45
- type FrontendFeature = FrontendFeature$1;
48
+ type FrontendPluginInfoResolver = (ctx: {
49
+ packageJson(): Promise<JsonObject | undefined>;
50
+ manifest(): Promise<JsonObject | undefined>;
51
+ defaultResolver(sources: {
52
+ packageJson: JsonObject | undefined;
53
+ manifest: JsonObject | undefined;
54
+ }): Promise<{
55
+ info: FrontendPluginInfo;
56
+ }>;
57
+ }) => Promise<{
58
+ info: FrontendPluginInfo;
59
+ }>;
46
60
 
47
61
  /**
48
62
  * Creates an empty app without any default features. This is a low-level API is
@@ -52,7 +66,7 @@ type FrontendFeature = FrontendFeature$1;
52
66
  * @public
53
67
  */
54
68
  declare function createSpecializedApp(options?: {
55
- features?: FrontendFeature[];
69
+ features?: FrontendFeature$1[];
56
70
  config?: ConfigApi;
57
71
  bindRoutes?(context: {
58
72
  bind: CreateAppRouteBinder;
@@ -62,9 +76,15 @@ declare function createSpecializedApp(options?: {
62
76
  flags?: {
63
77
  allowUnknownExtensionConfig?: boolean;
64
78
  };
79
+ pluginInfoResolver?: FrontendPluginInfoResolver;
65
80
  }): {
66
81
  apis: ApiHolder;
67
82
  tree: AppTree;
68
83
  };
69
84
 
70
- export { type CreateAppRouteBinder, type FrontendFeature, createSpecializedApp };
85
+ /** @public
86
+ * @deprecated Use {@link @backstage/frontend-plugin-api#FrontendFeature} instead.
87
+ */
88
+ type FrontendFeature = FrontendFeature$1;
89
+
90
+ export { type CreateAppRouteBinder, type FrontendFeature, type FrontendPluginInfoResolver, createSpecializedApp };
@@ -59,8 +59,8 @@ function extractRouteInfoFromAppNode(node) {
59
59
  }
60
60
  routeParents.set(routeRef, newParentRef);
61
61
  currentObj?.routeRefs.add(routeRef);
62
- if (current.spec.source) {
63
- currentObj?.plugins.add(toLegacyPlugin(current.spec.source));
62
+ if (current.spec.plugin) {
63
+ currentObj?.plugins.add(toLegacyPlugin(current.spec.plugin));
64
64
  }
65
65
  }
66
66
  for (const children of current.edges.attachments.values()) {
@@ -1 +1 @@
1
- {"version":3,"file":"extractRouteInfoFromAppNode.esm.js","sources":["../../src/routing/extractRouteInfoFromAppNode.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 { RouteRef, coreExtensionData } from '@backstage/frontend-plugin-api';\nimport { BackstageRouteObject } from './types';\nimport { AppNode } from '@backstage/frontend-plugin-api';\nimport { toLegacyPlugin } from './toLegacyPlugin';\n\n// We always add a child that matches all subroutes but without any route refs. This makes\n// sure that we're always able to match each route no matter how deep the navigation goes.\n// The route resolver then takes care of selecting the most specific match in order to find\n// mount points that are as deep in the routing tree as possible.\nexport const MATCH_ALL_ROUTE: BackstageRouteObject = {\n caseSensitive: false,\n path: '*',\n element: 'match-all', // These elements aren't used, so we add in a bit of debug information\n routeRefs: new Set(),\n plugins: new Set(),\n};\n\n// Joins a list of paths together, avoiding trailing and duplicate slashes\nexport function joinPaths(...paths: string[]): string {\n const normalized = paths.join('/').replace(/\\/\\/+/g, '/');\n if (normalized !== '/' && normalized.endsWith('/')) {\n return normalized.slice(0, -1);\n }\n return normalized;\n}\n\nexport function extractRouteInfoFromAppNode(node: AppNode): {\n routePaths: Map<RouteRef, string>;\n routeParents: Map<RouteRef, RouteRef | undefined>;\n routeObjects: BackstageRouteObject[];\n} {\n // This tracks the route path for each route ref, the value is the route path relative to the parent ref\n const routePaths = new Map<RouteRef, string>();\n // This tracks the parents of each route ref. To find the full path of any route ref you traverse\n // upwards in this tree and substitute each route ref for its route path along then way.\n const routeParents = new Map<RouteRef, RouteRef | undefined>();\n // This route object tree is passed to react-router in order to be able to look up the current route\n // ref or extension/source based on our current location.\n const routeObjects = new Array<BackstageRouteObject>();\n\n function visit(\n current: AppNode,\n collectedPath?: string,\n foundRefForCollectedPath: boolean = false,\n parentRef?: RouteRef,\n candidateParentRef?: RouteRef,\n parentObj?: BackstageRouteObject,\n ) {\n const routePath = current.instance\n ?.getData(coreExtensionData.routePath)\n ?.replace(/^\\//, '');\n const routeRef = current.instance?.getData(coreExtensionData.routeRef);\n const parentChildren = parentObj?.children ?? routeObjects;\n let currentObj = parentObj;\n\n let newCollectedPath = collectedPath;\n let newFoundRefForCollectedPath = foundRefForCollectedPath;\n\n let newParentRef = parentRef;\n let newCandidateParentRef = candidateParentRef;\n\n // Whenever a route path is encountered, a new node is created in the routing tree.\n if (routePath !== undefined) {\n currentObj = {\n path: routePath,\n element: 'mounted',\n routeRefs: new Set<RouteRef>(),\n caseSensitive: false,\n children: [MATCH_ALL_ROUTE],\n plugins: new Set(),\n appNode: current,\n };\n parentChildren.push(currentObj);\n\n // Each route path that we discover creates a new node in the routing tree, at that point\n // we also switch out our candidate parent ref to be the active one.\n newParentRef = candidateParentRef;\n newCandidateParentRef = undefined;\n\n // We need to collect and concatenate route paths until the path has been assigned a route ref:\n // Once we find a route ref the collection starts over from an empty path, that way each route\n // path assignment only contains the diff from the parent ref.\n if (newFoundRefForCollectedPath) {\n newCollectedPath = routePath;\n newFoundRefForCollectedPath = false;\n } else {\n newCollectedPath = collectedPath\n ? joinPaths(collectedPath, routePath)\n : routePath;\n }\n }\n\n // Whenever a route ref is encountered, we need to give it a route path and position in the ref tree.\n if (routeRef) {\n // The first route ref we find after encountering a route path is selected to be used as the\n // parent ref further down the tree. We don't start using this candidate ref until we encounter\n // another route path though, at which point we repeat the process and select another candidate.\n if (!newCandidateParentRef) {\n newCandidateParentRef = routeRef;\n }\n\n // Check if we've encountered any route paths since the closest route ref, in that case we assign\n // that path to this and following route refs until we encounter another route path.\n if (newCollectedPath !== undefined) {\n routePaths.set(routeRef, newCollectedPath);\n newFoundRefForCollectedPath = true;\n }\n\n routeParents.set(routeRef, newParentRef);\n currentObj?.routeRefs.add(routeRef);\n if (current.spec.source) {\n currentObj?.plugins.add(toLegacyPlugin(current.spec.source));\n }\n }\n\n for (const children of current.edges.attachments.values()) {\n for (const child of children) {\n visit(\n child,\n newCollectedPath,\n newFoundRefForCollectedPath,\n newParentRef,\n newCandidateParentRef,\n currentObj,\n );\n }\n }\n }\n\n visit(node);\n\n return { routePaths, routeParents, routeObjects };\n}\n"],"names":[],"mappings":";;;AAyBO,MAAM,eAAwC,GAAA;AAAA,EACnD,aAAe,EAAA,KAAA;AAAA,EACf,IAAM,EAAA,GAAA;AAAA,EACN,OAAS,EAAA,WAAA;AAAA;AAAA,EACT,SAAA,sBAAe,GAAI,EAAA;AAAA,EACnB,OAAA,sBAAa,GAAI;AACnB;AAGO,SAAS,aAAa,KAAyB,EAAA;AACpD,EAAA,MAAM,aAAa,KAAM,CAAA,IAAA,CAAK,GAAG,CAAE,CAAA,OAAA,CAAQ,UAAU,GAAG,CAAA;AACxD,EAAA,IAAI,UAAe,KAAA,GAAA,IAAO,UAAW,CAAA,QAAA,CAAS,GAAG,CAAG,EAAA;AAClD,IAAO,OAAA,UAAA,CAAW,KAAM,CAAA,CAAA,EAAG,CAAE,CAAA,CAAA;AAAA;AAE/B,EAAO,OAAA,UAAA;AACT;AAEO,SAAS,4BAA4B,IAI1C,EAAA;AAEA,EAAM,MAAA,UAAA,uBAAiB,GAAsB,EAAA;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CAAU,aAAe,EAAA,SAAS,CAClC,GAAA,SAAA;AAAA;AACN;AAIF,IAAA,IAAI,QAAU,EAAA;AAIZ,MAAA,IAAI,CAAC,qBAAuB,EAAA;AAC1B,QAAwB,qBAAA,GAAA,QAAA;AAAA;AAK1B,MAAA,IAAI,qBAAqB,KAAW,CAAA,EAAA;AAClC,QAAW,UAAA,CAAA,GAAA,CAAI,UAAU,gBAAgB,CAAA;AACzC,QAA8B,2BAAA,GAAA,IAAA;AAAA;AAGhC,MAAa,YAAA,CAAA,GAAA,CAAI,UAAU,YAAY,CAAA;AACvC,MAAY,UAAA,EAAA,SAAA,CAAU,IAAI,QAAQ,CAAA;AAClC,MAAI,IAAA,OAAA,CAAQ,KAAK,MAAQ,EAAA;AACvB,QAAA,UAAA,EAAY,QAAQ,GAAI,CAAA,cAAA,CAAe,OAAQ,CAAA,IAAA,CAAK,MAAM,CAAC,CAAA;AAAA;AAC7D;AAGF,IAAA,KAAA,MAAW,QAAY,IAAA,OAAA,CAAQ,KAAM,CAAA,WAAA,CAAY,QAAU,EAAA;AACzD,MAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC5B,QAAA,KAAA;AAAA,UACE,KAAA;AAAA,UACA,gBAAA;AAAA,UACA,2BAAA;AAAA,UACA,YAAA;AAAA,UACA,qBAAA;AAAA,UACA;AAAA,SACF;AAAA;AACF;AACF;AAGF,EAAA,KAAA,CAAM,IAAI,CAAA;AAEV,EAAO,OAAA,EAAE,UAAY,EAAA,YAAA,EAAc,YAAa,EAAA;AAClD;;;;"}
1
+ {"version":3,"file":"extractRouteInfoFromAppNode.esm.js","sources":["../../src/routing/extractRouteInfoFromAppNode.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 { RouteRef, coreExtensionData } from '@backstage/frontend-plugin-api';\nimport { BackstageRouteObject } from './types';\nimport { AppNode } from '@backstage/frontend-plugin-api';\nimport { toLegacyPlugin } from './toLegacyPlugin';\n\n// We always add a child that matches all subroutes but without any route refs. This makes\n// sure that we're always able to match each route no matter how deep the navigation goes.\n// The route resolver then takes care of selecting the most specific match in order to find\n// mount points that are as deep in the routing tree as possible.\nexport const MATCH_ALL_ROUTE: BackstageRouteObject = {\n caseSensitive: false,\n path: '*',\n element: 'match-all', // These elements aren't used, so we add in a bit of debug information\n routeRefs: new Set(),\n plugins: new Set(),\n};\n\n// Joins a list of paths together, avoiding trailing and duplicate slashes\nexport function joinPaths(...paths: string[]): string {\n const normalized = paths.join('/').replace(/\\/\\/+/g, '/');\n if (normalized !== '/' && normalized.endsWith('/')) {\n return normalized.slice(0, -1);\n }\n return normalized;\n}\n\nexport function extractRouteInfoFromAppNode(node: AppNode): {\n routePaths: Map<RouteRef, string>;\n routeParents: Map<RouteRef, RouteRef | undefined>;\n routeObjects: BackstageRouteObject[];\n} {\n // This tracks the route path for each route ref, the value is the route path relative to the parent ref\n const routePaths = new Map<RouteRef, string>();\n // This tracks the parents of each route ref. To find the full path of any route ref you traverse\n // upwards in this tree and substitute each route ref for its route path along then way.\n const routeParents = new Map<RouteRef, RouteRef | undefined>();\n // This route object tree is passed to react-router in order to be able to look up the current route\n // ref or extension/source based on our current location.\n const routeObjects = new Array<BackstageRouteObject>();\n\n function visit(\n current: AppNode,\n collectedPath?: string,\n foundRefForCollectedPath: boolean = false,\n parentRef?: RouteRef,\n candidateParentRef?: RouteRef,\n parentObj?: BackstageRouteObject,\n ) {\n const routePath = current.instance\n ?.getData(coreExtensionData.routePath)\n ?.replace(/^\\//, '');\n const routeRef = current.instance?.getData(coreExtensionData.routeRef);\n const parentChildren = parentObj?.children ?? routeObjects;\n let currentObj = parentObj;\n\n let newCollectedPath = collectedPath;\n let newFoundRefForCollectedPath = foundRefForCollectedPath;\n\n let newParentRef = parentRef;\n let newCandidateParentRef = candidateParentRef;\n\n // Whenever a route path is encountered, a new node is created in the routing tree.\n if (routePath !== undefined) {\n currentObj = {\n path: routePath,\n element: 'mounted',\n routeRefs: new Set<RouteRef>(),\n caseSensitive: false,\n children: [MATCH_ALL_ROUTE],\n plugins: new Set(),\n appNode: current,\n };\n parentChildren.push(currentObj);\n\n // Each route path that we discover creates a new node in the routing tree, at that point\n // we also switch out our candidate parent ref to be the active one.\n newParentRef = candidateParentRef;\n newCandidateParentRef = undefined;\n\n // We need to collect and concatenate route paths until the path has been assigned a route ref:\n // Once we find a route ref the collection starts over from an empty path, that way each route\n // path assignment only contains the diff from the parent ref.\n if (newFoundRefForCollectedPath) {\n newCollectedPath = routePath;\n newFoundRefForCollectedPath = false;\n } else {\n newCollectedPath = collectedPath\n ? joinPaths(collectedPath, routePath)\n : routePath;\n }\n }\n\n // Whenever a route ref is encountered, we need to give it a route path and position in the ref tree.\n if (routeRef) {\n // The first route ref we find after encountering a route path is selected to be used as the\n // parent ref further down the tree. We don't start using this candidate ref until we encounter\n // another route path though, at which point we repeat the process and select another candidate.\n if (!newCandidateParentRef) {\n newCandidateParentRef = routeRef;\n }\n\n // Check if we've encountered any route paths since the closest route ref, in that case we assign\n // that path to this and following route refs until we encounter another route path.\n if (newCollectedPath !== undefined) {\n routePaths.set(routeRef, newCollectedPath);\n newFoundRefForCollectedPath = true;\n }\n\n routeParents.set(routeRef, newParentRef);\n currentObj?.routeRefs.add(routeRef);\n if (current.spec.plugin) {\n currentObj?.plugins.add(toLegacyPlugin(current.spec.plugin));\n }\n }\n\n for (const children of current.edges.attachments.values()) {\n for (const child of children) {\n visit(\n child,\n newCollectedPath,\n newFoundRefForCollectedPath,\n newParentRef,\n newCandidateParentRef,\n currentObj,\n );\n }\n }\n }\n\n visit(node);\n\n return {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MAAW,QAAY,IAAA,OAAA,CAAQ,KAAM,CAAA,WAAA,CAAY,QAAU,EAAA;AACzD,MAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC5B,QAAA,KAAA;AAAA,UACE,KAAA;AAAA,UACA,gBAAA;AAAA,UACA,2BAAA;AAAA,UACA,YAAA;AAAA,UACA,qBAAA;AAAA,UACA;AAAA,SACF;AAAA;AACF;AACF;AAGF,EAAA,KAAA,CAAM,IAAI,CAAA;AAEV,EAAO,OAAA,EAAE,UAAY,EAAA,YAAA,EAAc,YAAa,EAAA;AAClD;;;;"}
@@ -12,44 +12,45 @@ function resolveAppNodeSpecs(options) {
12
12
  } = options;
13
13
  const plugins = features.filter(OpaqueFrontendPlugin.isType);
14
14
  const modules = features.filter(isInternalFrontendModule);
15
- const pluginExtensions = plugins.flatMap((source) => {
16
- return OpaqueFrontendPlugin.toInternal(source).extensions.map(
15
+ const pluginExtensions = plugins.flatMap((plugin) => {
16
+ return OpaqueFrontendPlugin.toInternal(plugin).extensions.map(
17
17
  (extension) => ({
18
18
  ...extension,
19
- source
19
+ plugin
20
20
  })
21
21
  );
22
22
  });
23
23
  const moduleExtensions = modules.flatMap(
24
24
  (mod) => toInternalFrontendModule(mod).extensions.flatMap((extension) => {
25
- const source = plugins.find((p) => p.id === mod.pluginId);
26
- if (!source) {
25
+ const plugin = plugins.find((p) => p.id === mod.pluginId);
26
+ if (!plugin) {
27
27
  return [];
28
28
  }
29
- return [{ ...extension, source }];
29
+ return [{ ...extension, plugin }];
30
30
  })
31
31
  );
32
32
  if (pluginExtensions.some(({ id }) => forbidden.has(id))) {
33
- const pluginsStr = pluginExtensions.filter(({ id }) => forbidden.has(id)).map(({ source }) => `'${source.id}'`).join(", ");
33
+ const pluginsStr = pluginExtensions.filter(({ id }) => forbidden.has(id)).map(({ plugin }) => `'${plugin.id}'`).join(", ");
34
34
  const forbiddenStr = [...forbidden].map((id) => `'${id}'`).join(", ");
35
35
  throw new Error(
36
36
  `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by the following plugin(s): ${pluginsStr}`
37
37
  );
38
38
  }
39
39
  if (moduleExtensions.some(({ id }) => forbidden.has(id))) {
40
- const pluginsStr = moduleExtensions.filter(({ id }) => forbidden.has(id)).map(({ source }) => `'${source.id}'`).join(", ");
40
+ const pluginsStr = moduleExtensions.filter(({ id }) => forbidden.has(id)).map(({ plugin }) => `'${plugin.id}'`).join(", ");
41
41
  const forbiddenStr = [...forbidden].map((id) => `'${id}'`).join(", ");
42
42
  throw new Error(
43
43
  `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by a module for the following plugin(s): ${pluginsStr}`
44
44
  );
45
45
  }
46
46
  const configuredExtensions = [
47
- ...pluginExtensions.map(({ source, ...extension }) => {
47
+ ...pluginExtensions.map(({ plugin, ...extension }) => {
48
48
  const internalExtension = toInternalExtension(extension);
49
49
  return {
50
50
  extension: internalExtension,
51
51
  params: {
52
- source,
52
+ plugin,
53
+ source: plugin,
53
54
  attachTo: internalExtension.attachTo,
54
55
  disabled: internalExtension.disabled,
55
56
  config: void 0
@@ -62,6 +63,7 @@ function resolveAppNodeSpecs(options) {
62
63
  extension: internalExtension,
63
64
  params: {
64
65
  source: void 0,
66
+ plugin: void 0,
65
67
  attachTo: internalExtension.attachTo,
66
68
  disabled: internalExtension.disabled,
67
69
  config: void 0
@@ -82,7 +84,8 @@ function resolveAppNodeSpecs(options) {
82
84
  configuredExtensions.push({
83
85
  extension: internalExtension,
84
86
  params: {
85
- source: extension.source,
87
+ plugin: extension.plugin,
88
+ source: extension.plugin,
86
89
  attachTo: internalExtension.attachTo,
87
90
  disabled: internalExtension.disabled,
88
91
  config: void 0
@@ -150,6 +153,7 @@ function resolveAppNodeSpecs(options) {
150
153
  attachTo: param.params.attachTo,
151
154
  extension: param.extension,
152
155
  disabled: param.params.disabled,
156
+ plugin: param.params.plugin,
153
157
  source: param.params.source,
154
158
  config: param.params.config
155
159
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"resolveAppNodeSpecs.esm.js","sources":["../../src/tree/resolveAppNodeSpecs.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 { Extension } from '@backstage/frontend-plugin-api';\nimport { ExtensionParameters } from './readAppExtensionsConfig';\nimport { AppNodeSpec } from '@backstage/frontend-plugin-api';\nimport { OpaqueFrontendPlugin } from '@internal/frontend';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isInternalFrontendModule,\n toInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtension } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\nimport { FrontendFeature } from '../wiring';\n\n/** @internal */\nexport function resolveAppNodeSpecs(options: {\n features?: FrontendFeature[];\n builtinExtensions?: Extension<any, any>[];\n parameters?: Array<ExtensionParameters>;\n forbidden?: Set<string>;\n allowUnknownExtensionConfig?: boolean;\n}): AppNodeSpec[] {\n const {\n builtinExtensions = [],\n parameters = [],\n forbidden = new Set(),\n features = [],\n allowUnknownExtensionConfig = false,\n } = options;\n\n const plugins = features.filter(OpaqueFrontendPlugin.isType);\n const modules = features.filter(isInternalFrontendModule);\n\n const pluginExtensions = plugins.flatMap(source => {\n return OpaqueFrontendPlugin.toInternal(source).extensions.map(\n extension => ({\n ...extension,\n source,\n }),\n );\n });\n const moduleExtensions = modules.flatMap(mod =>\n toInternalFrontendModule(mod).extensions.flatMap(extension => {\n // Modules for plugins that are not installed are ignored\n const source = plugins.find(p => p.id === mod.pluginId);\n if (!source) {\n return [];\n }\n\n return [{ ...extension, source }];\n }),\n );\n\n // Prevent core override\n if (pluginExtensions.some(({ id }) => forbidden.has(id))) {\n const pluginsStr = pluginExtensions\n .filter(({ id }) => forbidden.has(id))\n .map(({ source }) => `'${source.id}'`)\n .join(', ');\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by the following plugin(s): ${pluginsStr}`,\n );\n }\n if (moduleExtensions.some(({ id }) => forbidden.has(id))) {\n const pluginsStr = moduleExtensions\n .filter(({ id }) => forbidden.has(id))\n .map(({ source }) => `'${source.id}'`)\n .join(', ');\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by a module for the following plugin(s): ${pluginsStr}`,\n );\n }\n\n const configuredExtensions = [\n ...pluginExtensions.map(({ source, ...extension }) => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n source,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ...builtinExtensions.map(extension => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n source: undefined,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ];\n\n // Install all module overrides\n for (const extension of moduleExtensions) {\n const internalExtension = toInternalExtension(extension);\n\n // Check if our override is overriding an extension that already exists\n const index = configuredExtensions.findIndex(\n e => e.extension.id === extension.id,\n );\n if (index !== -1) {\n // Only implementation, attachment point and default disabled status are overridden, the source is kept\n configuredExtensions[index].extension = internalExtension;\n configuredExtensions[index].params.attachTo = internalExtension.attachTo;\n configuredExtensions[index].params.disabled = internalExtension.disabled;\n } else {\n // Add the extension as a new one when not overriding an existing one\n configuredExtensions.push({\n extension: internalExtension,\n params: {\n source: extension.source,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined,\n },\n });\n }\n }\n\n const duplicatedExtensionIds = new Set<string>();\n const duplicatedExtensionData = configuredExtensions.reduce<\n Record<string, Record<string, number>>\n >((data, { extension, params }) => {\n const extensionId = extension.id;\n const extensionData = data?.[extensionId];\n if (extensionData) duplicatedExtensionIds.add(extensionId);\n const pluginId = params.source?.id ?? 'internal';\n const pluginCount = extensionData?.[pluginId] ?? 0;\n return {\n ...data,\n [extensionId]: { ...extensionData, [pluginId]: pluginCount + 1 },\n };\n }, {});\n\n if (duplicatedExtensionIds.size > 0) {\n throw new Error(\n `The following extensions are duplicated: ${Array.from(\n duplicatedExtensionIds,\n )\n .map(\n extensionId =>\n `The extension '${extensionId}' was provided ${Object.keys(\n duplicatedExtensionData[extensionId],\n )\n .map(\n pluginId =>\n `${duplicatedExtensionData[extensionId][pluginId]} time(s) by the plugin '${pluginId}'`,\n )\n .join(' and ')}`,\n )\n .join(', ')}`,\n );\n }\n\n const order = new Map<string, (typeof configuredExtensions)[number]>();\n for (const overrideParam of parameters) {\n const extensionId = overrideParam.id;\n\n if (forbidden.has(extensionId)) {\n throw new Error(\n `Configuration of the '${extensionId}' extension is forbidden`,\n );\n }\n\n const existing = configuredExtensions.find(\n e => e.extension.id === extensionId,\n );\n if (existing) {\n if (overrideParam.attachTo) {\n existing.params.attachTo = overrideParam.attachTo;\n }\n if (overrideParam.config) {\n // TODO: merge config?\n existing.params.config = overrideParam.config;\n }\n if (\n Boolean(existing.params.disabled) !== Boolean(overrideParam.disabled)\n ) {\n existing.params.disabled = Boolean(overrideParam.disabled);\n }\n order.set(extensionId, existing);\n } else if (!allowUnknownExtensionConfig) {\n throw new Error(`Extension ${extensionId} does not exist`);\n }\n }\n\n const orderedExtensions = [\n ...order.values(),\n ...configuredExtensions.filter(e => !order.has(e.extension.id)),\n ];\n\n return orderedExtensions.map(param => ({\n id: param.extension.id,\n attachTo: param.params.attachTo,\n extension: param.extension,\n disabled: param.params.disabled,\n source: param.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AA;AAAA,IAChB,GAAG,oBAAqB,CAAA,MAAA,CAAO,CAAK,CAAA,KAAA,CAAC,MAAM,GAAI,CAAA,CAAA,CAAE,SAAU,CAAA,EAAE,CAAC;AAAA,GAChE;AAEA,EAAO,OAAA,iBAAA,CAAkB,IAAI,CAAU,KAAA,MAAA;AAAA,IACrC,EAAA,EAAI,MAAM,SAAU,CAAA,EAAA;AAAA,IACpB,QAAA,EAAU,MAAM,MAAO,CAAA,QAAA;AAAA,IACvB,WAAW,KAAM,CAAA,SAAA;AAAA,IACjB,QAAA,EAAU,MAAM,MAAO,CAAA,QAAA;AAAA,IACvB,MAAA,EAAQ,MAAM,MAAO,CAAA,MAAA;AAAA,IACrB,MAAA,EAAQ,MAAM,MAAO,CAAA;AAAA,GACrB,CAAA,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"resolveAppNodeSpecs.esm.js","sources":["../../src/tree/resolveAppNodeSpecs.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 { Extension } from '@backstage/frontend-plugin-api';\nimport { ExtensionParameters } from './readAppExtensionsConfig';\nimport { AppNodeSpec } from '@backstage/frontend-plugin-api';\nimport { OpaqueFrontendPlugin } from '@internal/frontend';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isInternalFrontendModule,\n toInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtension } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\nimport { FrontendFeature } from '../wiring';\n\n/** @internal */\nexport function resolveAppNodeSpecs(options: {\n features?: FrontendFeature[];\n builtinExtensions?: Extension<any, any>[];\n parameters?: Array<ExtensionParameters>;\n forbidden?: Set<string>;\n allowUnknownExtensionConfig?: boolean;\n}): AppNodeSpec[] {\n const {\n builtinExtensions = [],\n parameters = [],\n forbidden = new Set(),\n features = [],\n allowUnknownExtensionConfig = false,\n } = options;\n\n const plugins = features.filter(OpaqueFrontendPlugin.isType);\n const modules = features.filter(isInternalFrontendModule);\n\n const pluginExtensions = plugins.flatMap(plugin => {\n return OpaqueFrontendPlugin.toInternal(plugin).extensions.map(\n extension => ({\n ...extension,\n plugin,\n }),\n );\n });\n const moduleExtensions = modules.flatMap(mod =>\n toInternalFrontendModule(mod).extensions.flatMap(extension => {\n // Modules for plugins that are not installed are ignored\n const plugin = plugins.find(p => p.id === mod.pluginId);\n if (!plugin) {\n return [];\n }\n\n return [{ ...extension, plugin }];\n }),\n );\n\n // Prevent core override\n if (pluginExtensions.some(({ id }) => forbidden.has(id))) {\n const pluginsStr = pluginExtensions\n .filter(({ id }) => forbidden.has(id))\n .map(({ plugin }) => `'${plugin.id}'`)\n .join(', ');\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by the following plugin(s): ${pluginsStr}`,\n );\n }\n if (moduleExtensions.some(({ id }) => forbidden.has(id))) {\n const pluginsStr = moduleExtensions\n .filter(({ id }) => forbidden.has(id))\n .map(({ plugin }) => `'${plugin.id}'`)\n .join(', ');\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by a module for the following plugin(s): ${pluginsStr}`,\n );\n }\n\n const configuredExtensions = [\n ...pluginExtensions.map(({ plugin, ...extension }) => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n plugin,\n source: plugin,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ...builtinExtensions.map(extension => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n source: undefined,\n plugin: undefined,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ];\n\n // Install all module overrides\n for (const extension of moduleExtensions) {\n const internalExtension = toInternalExtension(extension);\n\n // Check if our override is overriding an extension that already exists\n const index = configuredExtensions.findIndex(\n e => e.extension.id === extension.id,\n );\n if (index !== -1) {\n // Only implementation, attachment point and default disabled status are overridden, the source is kept\n configuredExtensions[index].extension = internalExtension;\n configuredExtensions[index].params.attachTo = internalExtension.attachTo;\n configuredExtensions[index].params.disabled = internalExtension.disabled;\n } else {\n // Add the extension as a new one when not overriding an existing one\n configuredExtensions.push({\n extension: internalExtension,\n params: {\n plugin: extension.plugin,\n source: extension.plugin,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined,\n },\n });\n }\n }\n\n const duplicatedExtensionIds = new Set<string>();\n const duplicatedExtensionData = configuredExtensions.reduce<\n Record<string, Record<string, number>>\n >((data, { extension, params }) => {\n const extensionId = extension.id;\n const extensionData = data?.[extensionId];\n if (extensionData) duplicatedExtensionIds.add(extensionId);\n const pluginId = params.source?.id ?? 'internal';\n const pluginCount = extensionData?.[pluginId] ?? 0;\n return {\n ...data,\n [extensionId]: { ...extensionData, [pluginId]: pluginCount + 1 },\n };\n }, {});\n\n if (duplicatedExtensionIds.size > 0) {\n throw new Error(\n `The following extensions are duplicated: ${Array.from(\n duplicatedExtensionIds,\n )\n .map(\n extensionId =>\n `The extension '${extensionId}' was provided ${Object.keys(\n duplicatedExtensionData[extensionId],\n )\n .map(\n pluginId =>\n `${duplicatedExtensionData[extensionId][pluginId]} time(s) by the plugin '${pluginId}'`,\n )\n .join(' and ')}`,\n )\n .join(', ')}`,\n );\n }\n\n const order = new Map<string, (typeof configuredExtensions)[number]>();\n for (const overrideParam of parameters) {\n const extensionId = overrideParam.id;\n\n if (forbidden.has(extensionId)) {\n throw new Error(\n `Configuration of the '${extensionId}' extension is forbidden`,\n );\n }\n\n const existing = configuredExtensions.find(\n e => e.extension.id === extensionId,\n );\n if (existing) {\n if (overrideParam.attachTo) {\n existing.params.attachTo = overrideParam.attachTo;\n }\n if (overrideParam.config) {\n // TODO: merge config?\n existing.params.config = overrideParam.config;\n }\n if (\n Boolean(existing.params.disabled) !== Boolean(overrideParam.disabled)\n ) {\n existing.params.disabled = Boolean(overrideParam.disabled);\n }\n order.set(extensionId, existing);\n } else if (!allowUnknownExtensionConfig) {\n throw new Error(`Extension ${extensionId} does not exist`);\n }\n }\n\n const orderedExtensions = [\n ...order.values(),\n ...configuredExtensions.filter(e => !order.has(e.extension.id)),\n ];\n\n return orderedExtensions.map(param => ({\n id: param.extension.id,\n attachTo: param.params.attachTo,\n extension: param.extension,\n disabled: param.params.disabled,\n plugin: param.params.plugin,\n source: param.params.source,\n config: param.params.config,\n }));\n}\n"],"names":[],"mappings":";;;;AA8BO,SAAS,oBAAoB,OAMlB,EAAA;AAChB,EAAM,MAAA;AAAA,IACJ,oBAAoB,EAAC;AAAA,IACrB,aAAa,EAAC;AAAA,IACd,SAAA,uBAAgB,GAAI,EAAA;AAAA,IACpB,WAAW,EAAC;AAAA,IACZ,2BAA8B,GAAA;AAAA,GAC5B,GAAA,OAAA;AAEJ,EAAA,MAAM,OAAU,GAAA,QAAA,CAAS,MAAO,CAAA,oBAAA,CAAqB,MAAM,CAAA;AAC3D,EAAM,MAAA,OAAA,GAAU,QAAS,CAAA,MAAA,CAAO,wBAAwB,CAAA;AAExD,EAAM,MAAA,gBAAA,GAAmB,OAAQ,CAAA,OAAA,CAAQ,CAAU,MAAA,KAAA;AACjD,IAAA,OAAO,oBAAqB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAE,UAAW,CAAA,GAAA;AAAA,MACxD,CAAc,SAAA,MAAA;AAAA,QACZ,GAAG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;AAAA,GACrB,CAAA,CAAA;AACJ;;;;"}
@@ -0,0 +1,169 @@
1
+ import once from 'lodash/once';
2
+ import { stringifyEntityRef, parseEntityRef } from '../catalog-model/src/entity/ref.esm.js';
3
+ import { OpaqueFrontendPlugin } from '../frontend-internal/src/wiring/InternalFrontendPlugin.esm.js';
4
+
5
+ function createPluginInfoAttacher(config, infoResolver = async (ctx) => ctx.defaultResolver({
6
+ packageJson: await ctx.packageJson(),
7
+ manifest: await ctx.manifest()
8
+ })) {
9
+ const applyInfoOverrides = createPluginInfoOverrider(config);
10
+ return (feature) => {
11
+ if (!OpaqueFrontendPlugin.isType(feature)) {
12
+ return feature;
13
+ }
14
+ const plugin = OpaqueFrontendPlugin.toInternal(feature);
15
+ return {
16
+ ...plugin,
17
+ info: once(async () => {
18
+ const manifestLoader = plugin.infoOptions?.manifest;
19
+ const packageJsonLoader = plugin.infoOptions?.packageJson;
20
+ const { info: resolvedInfo } = await infoResolver({
21
+ manifest: async () => manifestLoader?.(),
22
+ packageJson: async () => packageJsonLoader?.(),
23
+ defaultResolver: async (sources) => ({
24
+ info: {
25
+ ...resolvePackageInfo(sources.packageJson),
26
+ ...resolveManifestInfo(sources.manifest)
27
+ }
28
+ })
29
+ });
30
+ const infoWithOverrides = applyInfoOverrides(plugin.id, resolvedInfo);
31
+ return normalizePluginInfo(infoWithOverrides);
32
+ })
33
+ };
34
+ };
35
+ }
36
+ function normalizePluginInfo(info) {
37
+ return {
38
+ ...info,
39
+ ownerEntityRefs: info.ownerEntityRefs?.map(
40
+ (ref) => stringifyEntityRef(
41
+ parseEntityRef(ref, {
42
+ defaultKind: "Group"
43
+ })
44
+ )
45
+ )
46
+ };
47
+ }
48
+ function createPluginInfoOverrider(config) {
49
+ const overrideConfigs = config.getOptionalConfigArray("app.pluginOverrides") ?? [];
50
+ const overrideMatchers = overrideConfigs.map((overrideConfig) => {
51
+ const pluginIdMatcher = makeStringMatcher(
52
+ overrideConfig.getOptionalString("match.pluginId")
53
+ );
54
+ const packageNameMatcher = makeStringMatcher(
55
+ overrideConfig.getOptionalString("match.packageName")
56
+ );
57
+ const description = overrideConfig.getOptionalString("info.description");
58
+ const ownerEntityRefs = overrideConfig.getOptionalStringArray(
59
+ "info.ownerEntityRefs"
60
+ );
61
+ const links = overrideConfig.getOptionalConfigArray("info.links")?.map((linkConfig) => ({
62
+ title: linkConfig.getString("title"),
63
+ url: linkConfig.getString("url")
64
+ }));
65
+ return {
66
+ test(pluginId, packageName) {
67
+ return packageNameMatcher(packageName) && pluginIdMatcher(pluginId);
68
+ },
69
+ info: {
70
+ description,
71
+ ownerEntityRefs,
72
+ links
73
+ }
74
+ };
75
+ });
76
+ return (pluginId, info) => {
77
+ const { packageName } = info;
78
+ for (const matcher of overrideMatchers) {
79
+ if (matcher.test(pluginId, packageName)) {
80
+ if (matcher.info.description) {
81
+ info.description = matcher.info.description;
82
+ }
83
+ if (matcher.info.ownerEntityRefs) {
84
+ info.ownerEntityRefs = matcher.info.ownerEntityRefs;
85
+ }
86
+ if (matcher.info.links) {
87
+ info.links = matcher.info.links;
88
+ }
89
+ }
90
+ }
91
+ return info;
92
+ };
93
+ }
94
+ function resolveManifestInfo(manifest) {
95
+ if (!isJsonObject(manifest) || !isJsonObject(manifest.metadata)) {
96
+ return void 0;
97
+ }
98
+ const info = {};
99
+ if (isJsonObject(manifest.spec) && typeof manifest.spec.owner === "string") {
100
+ info.ownerEntityRefs = [
101
+ stringifyEntityRef(
102
+ parseEntityRef(manifest.spec.owner, {
103
+ defaultKind: "Group",
104
+ defaultNamespace: manifest.metadata.namespace?.toString()
105
+ })
106
+ )
107
+ ];
108
+ }
109
+ if (Array.isArray(manifest.metadata.links)) {
110
+ info.links = manifest.metadata.links.filter(isJsonObject).map((link) => ({
111
+ title: String(link.title),
112
+ url: String(link.url)
113
+ }));
114
+ }
115
+ return info;
116
+ }
117
+ function resolvePackageInfo(packageJson) {
118
+ if (!packageJson) {
119
+ return void 0;
120
+ }
121
+ const info = {
122
+ packageName: packageJson?.name?.toString(),
123
+ version: packageJson?.version?.toString(),
124
+ description: packageJson?.description?.toString()
125
+ };
126
+ const links = [];
127
+ if (typeof packageJson.homepage === "string") {
128
+ links.push({
129
+ title: "Homepage",
130
+ url: packageJson.homepage
131
+ });
132
+ }
133
+ if (isJsonObject(packageJson.repository) && typeof packageJson.repository?.url === "string") {
134
+ try {
135
+ const url = new URL(packageJson.repository?.url);
136
+ if (url.protocol === "http:" || url.protocol === "https:") {
137
+ if (url.hostname === "github.com" && typeof packageJson.repository.directory === "string") {
138
+ const path = `${url.pathname}/tree/-/${packageJson.repository.directory}`;
139
+ url.pathname = path.replaceAll("//", "/");
140
+ }
141
+ links.push({
142
+ title: "Repository",
143
+ url: url.toString()
144
+ });
145
+ }
146
+ } catch {
147
+ }
148
+ }
149
+ if (links.length > 0) {
150
+ info.links = links;
151
+ }
152
+ return info;
153
+ }
154
+ function makeStringMatcher(pattern) {
155
+ if (!pattern) {
156
+ return () => true;
157
+ }
158
+ if (pattern.startsWith("/") && pattern.endsWith("/") && pattern.length > 2) {
159
+ const regex = new RegExp(pattern.slice(1, -1));
160
+ return (str) => str ? regex.test(str) : false;
161
+ }
162
+ return (str) => str === pattern;
163
+ }
164
+ function isJsonObject(value) {
165
+ return typeof value === "object" && value !== null && !Array.isArray(value);
166
+ }
167
+
168
+ export { createPluginInfoAttacher };
169
+ //# sourceMappingURL=createPluginInfoAttacher.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPluginInfoAttacher.esm.js","sources":["../../src/wiring/createPluginInfoAttacher.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport {\n FrontendFeature,\n FrontendPluginInfo,\n} from '@backstage/frontend-plugin-api';\nimport { OpaqueFrontendPlugin } from '@internal/frontend';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport once from 'lodash/once';\n// Avoid full dependency on catalog-model\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n parseEntityRef,\n stringifyEntityRef,\n} from '../../../catalog-model/src/entity/ref';\n\n/**\n * A function that resolves plugin info from a plugin manifest and package.json.\n *\n * @public\n */\nexport type FrontendPluginInfoResolver = (ctx: {\n packageJson(): Promise<JsonObject | undefined>;\n manifest(): Promise<JsonObject | undefined>;\n defaultResolver(sources: {\n packageJson: JsonObject | undefined;\n manifest: JsonObject | undefined;\n }): Promise<{ info: FrontendPluginInfo }>;\n}) => Promise<{ info: FrontendPluginInfo }>;\n\nexport function createPluginInfoAttacher(\n config: ConfigApi,\n infoResolver: FrontendPluginInfoResolver = async ctx =>\n ctx.defaultResolver({\n packageJson: await ctx.packageJson(),\n manifest: await ctx.manifest(),\n }),\n): (feature: FrontendFeature) => FrontendFeature {\n const applyInfoOverrides = createPluginInfoOverrider(config);\n\n return (feature: FrontendFeature) => {\n if (!OpaqueFrontendPlugin.isType(feature)) {\n return feature;\n }\n\n const plugin = OpaqueFrontendPlugin.toInternal(feature);\n\n return {\n ...plugin,\n info: once(async () => {\n const manifestLoader = plugin.infoOptions?.manifest;\n const packageJsonLoader = plugin.infoOptions?.packageJson;\n\n const { info: resolvedInfo } = await infoResolver({\n manifest: async () => manifestLoader?.(),\n packageJson: async () => packageJsonLoader?.(),\n defaultResolver: async sources => ({\n info: {\n ...resolvePackageInfo(sources.packageJson),\n ...resolveManifestInfo(sources.manifest),\n },\n }),\n });\n\n const infoWithOverrides = applyInfoOverrides(plugin.id, resolvedInfo);\n return normalizePluginInfo(infoWithOverrides);\n }),\n };\n };\n}\n\nfunction normalizePluginInfo(info: FrontendPluginInfo) {\n return {\n ...info,\n ownerEntityRefs: info.ownerEntityRefs?.map(ref =>\n stringifyEntityRef(\n parseEntityRef(ref, {\n defaultKind: 'Group',\n }),\n ),\n ),\n };\n}\n\nfunction createPluginInfoOverrider(config: ConfigApi) {\n const overrideConfigs =\n config.getOptionalConfigArray('app.pluginOverrides') ?? [];\n\n const overrideMatchers = overrideConfigs.map(overrideConfig => {\n const pluginIdMatcher = makeStringMatcher(\n overrideConfig.getOptionalString('match.pluginId'),\n );\n const packageNameMatcher = makeStringMatcher(\n overrideConfig.getOptionalString('match.packageName'),\n );\n const description = overrideConfig.getOptionalString('info.description');\n const ownerEntityRefs = overrideConfig.getOptionalStringArray(\n 'info.ownerEntityRefs',\n );\n const links = overrideConfig\n .getOptionalConfigArray('info.links')\n ?.map(linkConfig => ({\n title: linkConfig.getString('title'),\n url: linkConfig.getString('url'),\n }));\n\n return {\n test(pluginId: string, packageName?: string) {\n return packageNameMatcher(packageName) && pluginIdMatcher(pluginId);\n },\n info: {\n description,\n ownerEntityRefs,\n links,\n },\n };\n });\n\n return (pluginId: string, info: FrontendPluginInfo) => {\n const { packageName } = info;\n for (const matcher of overrideMatchers) {\n if (matcher.test(pluginId, packageName)) {\n if (matcher.info.description) {\n info.description = matcher.info.description;\n }\n if (matcher.info.ownerEntityRefs) {\n info.ownerEntityRefs = matcher.info.ownerEntityRefs;\n }\n if (matcher.info.links) {\n info.links = matcher.info.links;\n }\n }\n }\n return info;\n };\n}\n\nfunction resolveManifestInfo(manifest?: JsonValue) {\n if (!isJsonObject(manifest) || !isJsonObject(manifest.metadata)) {\n return undefined;\n }\n\n const info: FrontendPluginInfo = {};\n\n if (isJsonObject(manifest.spec) && typeof manifest.spec.owner === 'string') {\n info.ownerEntityRefs = [\n stringifyEntityRef(\n parseEntityRef(manifest.spec.owner, {\n defaultKind: 'Group',\n defaultNamespace: manifest.metadata.namespace?.toString(),\n }),\n ),\n ];\n }\n\n if (Array.isArray(manifest.metadata.links)) {\n info.links = manifest.metadata.links.filter(isJsonObject).map(link => ({\n title: String(link.title),\n url: String(link.url),\n }));\n }\n\n return info;\n}\n\nfunction resolvePackageInfo(packageJson?: JsonObject) {\n if (!packageJson) {\n return undefined;\n }\n\n const info: FrontendPluginInfo = {\n packageName: packageJson?.name?.toString(),\n version: packageJson?.version?.toString(),\n description: packageJson?.description?.toString(),\n };\n\n const links: { title: string; url: string }[] = [];\n\n if (typeof packageJson.homepage === 'string') {\n links.push({\n title: 'Homepage',\n url: packageJson.homepage,\n });\n }\n\n if (\n isJsonObject(packageJson.repository) &&\n typeof packageJson.repository?.url === 'string'\n ) {\n try {\n const url = new URL(packageJson.repository?.url);\n if (url.protocol === 'http:' || url.protocol === 'https:') {\n // TODO(Rugvip): Support more variants\n if (\n url.hostname === 'github.com' &&\n typeof packageJson.repository.directory === 'string'\n ) {\n const path = `${url.pathname}/tree/-/${packageJson.repository.directory}`;\n url.pathname = path.replaceAll('//', '/');\n }\n\n links.push({\n title: 'Repository',\n url: url.toString(),\n });\n }\n } catch {\n /* ignored */\n }\n }\n\n if (links.length > 0) {\n info.links = links;\n }\n return info;\n}\n\nfunction makeStringMatcher(pattern: string | undefined) {\n if (!pattern) {\n return () => true;\n }\n if (pattern.startsWith('/') && pattern.endsWith('/') && pattern.length > 2) {\n const regex = new RegExp(pattern.slice(1, -1));\n return (str?: string) => (str ? regex.test(str) : false);\n }\n\n return (str?: string) => str === pattern;\n}\n\nfunction isJsonObject(value?: JsonValue): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"names":[],"mappings":";;;;AA6CO,SAAS,yBACd,MACA,EAAA,YAAA,GAA2C,OAAM,GAAA,KAC/C,IAAI,eAAgB,CAAA;AAAA,EAClB,WAAA,EAAa,MAAM,GAAA,CAAI,WAAY,EAAA;AAAA,EACnC,QAAA,EAAU,MAAM,GAAA,CAAI,QAAS;AAC/B,CAAC,CAC4C,EAAA;AAC/C,EAAM,MAAA,kBA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A;AAAA,UACP,GAAA,EAAK,IAAI,QAAS;AAAA,SACnB,CAAA;AAAA;AACH,KACM,CAAA,MAAA;AAAA;AAER;AAGF,EAAI,IAAA,KAAA,CAAM,SAAS,CAAG,EAAA;AACpB,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AAAA;AAEf,EAAO,OAAA,IAAA;AACT;AAEA,SAAS,kBAAkB,OAA6B,EAAA;AACtD,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAA,OAAO,MAAM,IAAA;AAAA;AAEf,EAAI,IAAA,OAAA,CAAQ,UAAW,CAAA,GAAG,CAAK,IAAA,OAAA,CAAQ,SAAS,GAAG,CAAA,IAAK,OAAQ,CAAA,MAAA,GAAS,CAAG,EAAA;AAC1E,IAAA,MAAM,QAAQ,IAAI,MAAA,CAAO,QAAQ,KAAM,CAAA,CAAA,EAAG,EAAE,CAAC,CAAA;AAC7C,IAAA,OAAO,CAAC,GAAkB,KAAA,GAAA,GAAM,KAAM,CAAA,IAAA,CAAK,GAAG,CAAI,GAAA,KAAA;AAAA;AAGpD,EAAO,OAAA,CAAC,QAAiB,GAAQ,KAAA,OAAA;AACnC;AAEA,SAAS,aAAa,KAAwC,EAAA;AAC5D,EAAO,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;;;;"}
@@ -17,6 +17,7 @@ import { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree.esm.js';
17
17
  import { ApiRegistry } from '../core-app-api/src/apis/system/ApiRegistry.esm.js';
18
18
  import { AppIdentityProxy } from '../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy.esm.js';
19
19
  import { matchRoutes } from 'react-router-dom';
20
+ import { createPluginInfoAttacher } from './createPluginInfoAttacher.esm.js';
20
21
  import { OpaqueFrontendPlugin } from '../frontend-internal/src/wiring/InternalFrontendPlugin.esm.js';
21
22
  import { createExtensionDataContainer } from '../frontend-internal/src/wiring/createExtensionDataContainer.esm.js';
22
23
 
@@ -97,7 +98,9 @@ class RouteResolutionApiProxy {
97
98
  }
98
99
  function createSpecializedApp(options) {
99
100
  const config = options?.config ?? new ConfigReader({}, "empty-config");
100
- const features = deduplicateFeatures(options?.features ?? []);
101
+ const features = deduplicateFeatures(options?.features ?? []).map(
102
+ createPluginInfoAttacher(config, options?.pluginInfoResolver)
103
+ );
101
104
  const tree = resolveAppTree(
102
105
  "root",
103
106
  resolveAppNodeSpecs({
@@ -1 +1 @@
1
- {"version":3,"file":"createSpecializedApp.esm.js","sources":["../../src/wiring/createSpecializedApp.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 { ConfigReader } from '@backstage/config';\nimport {\n ApiBlueprint,\n AppTree,\n AppTreeApi,\n appTreeApiRef,\n RouteRef,\n ExternalRouteRef,\n SubRouteRef,\n AnyRouteRefParams,\n RouteFunc,\n RouteResolutionApiResolveOptions,\n RouteResolutionApi,\n createApiFactory,\n routeResolutionApiRef,\n AppNode,\n ExtensionFactoryMiddleware,\n} from '@backstage/frontend-plugin-api';\nimport {\n AnyApiFactory,\n ApiHolder,\n ConfigApi,\n configApiRef,\n featureFlagsApiRef,\n identityApiRef,\n} from '@backstage/core-plugin-api';\nimport { ApiFactoryRegistry, ApiResolver } from '@backstage/core-app-api';\nimport {\n createExtensionDataContainer,\n OpaqueFrontendPlugin,\n} from '@internal/frontend';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n resolveExtensionDefinition,\n toInternalExtension,\n} from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n\nimport { extractRouteInfoFromAppNode } from '../routing/extractRouteInfoFromAppNode';\n\nimport { CreateAppRouteBinder } from '../routing';\nimport { RouteResolver } from '../routing/RouteResolver';\nimport { resolveRouteBindings } from '../routing/resolveRouteBindings';\nimport { collectRouteIds } from '../routing/collectRouteIds';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n toInternalFrontendModule,\n isInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\nimport { getBasePath } from '../routing/getBasePath';\nimport { Root } from '../extensions/Root';\nimport { resolveAppTree } from '../tree/resolveAppTree';\nimport { resolveAppNodeSpecs } from '../tree/resolveAppNodeSpecs';\nimport { readAppExtensionsConfig } from '../tree/readAppExtensionsConfig';\nimport { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiRegistry } from '../../../core-app-api/src/apis/system/ApiRegistry';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppIdentityProxy } from '../../../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy';\nimport { BackstageRouteObject } from '../routing/types';\nimport { FrontendFeature, RouteInfo } from './types';\nimport { matchRoutes } from 'react-router-dom';\n\nfunction deduplicateFeatures(\n allFeatures: FrontendFeature[],\n): FrontendFeature[] {\n // Start by removing duplicates by reference\n const features = Array.from(new Set(allFeatures));\n\n // Plugins are deduplicated by ID, last one wins\n const seenIds = new Set<string>();\n return features\n .reverse()\n .filter(feature => {\n if (!OpaqueFrontendPlugin.isType(feature)) {\n return true;\n }\n if (seenIds.has(feature.id)) {\n return false;\n }\n seenIds.add(feature.id);\n return true;\n })\n .reverse();\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass AppTreeApiProxy implements AppTreeApi {\n #routeInfo?: RouteInfo;\n\n constructor(\n private readonly tree: AppTree,\n private readonly appBasePath: string,\n ) {}\n\n private checkIfInitialized() {\n if (!this.#routeInfo) {\n throw new Error(\n `You can't access the AppTreeApi during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n }\n\n getTree() {\n this.checkIfInitialized();\n\n return { tree: this.tree };\n }\n\n getNodesByRoutePath(sourcePath: string): { nodes: AppNode[] } {\n this.checkIfInitialized();\n\n let path = sourcePath;\n if (path.startsWith(this.appBasePath)) {\n path = path.slice(this.appBasePath.length);\n }\n\n const matchedRoutes = matchRoutes(this.#routeInfo!.routeObjects, path);\n\n const matchedAppNodes =\n matchedRoutes\n ?.filter(routeObj => !!routeObj.route.appNode)\n .map(routeObj => routeObj.route.appNode!) || [];\n\n return { nodes: matchedAppNodes };\n }\n\n initialize(routeInfo: RouteInfo) {\n this.#routeInfo = routeInfo;\n }\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass RouteResolutionApiProxy implements RouteResolutionApi {\n #delegate: RouteResolutionApi | undefined;\n #routeObjects: BackstageRouteObject[] | undefined;\n\n constructor(\n private readonly routeBindings: Map<\n ExternalRouteRef,\n RouteRef | SubRouteRef\n >,\n private readonly appBasePath: string,\n ) {}\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: RouteResolutionApiResolveOptions,\n ): RouteFunc<TParams> | undefined {\n if (!this.#delegate) {\n throw new Error(\n `You can't access the RouteResolver during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n\n return this.#delegate.resolve(anyRouteRef, options);\n }\n\n initialize(routeInfo: RouteInfo) {\n this.#delegate = new RouteResolver(\n routeInfo.routePaths,\n routeInfo.routeParents,\n routeInfo.routeObjects,\n this.routeBindings,\n this.appBasePath,\n );\n this.#routeObjects = routeInfo.routeObjects;\n\n return routeInfo;\n }\n\n getRouteObjects() {\n return this.#routeObjects;\n }\n}\n\n/**\n * Creates an empty app without any default features. This is a low-level API is\n * intended for use in tests or specialized setups. Typically you want to use\n * `createApp` from `@backstage/frontend-defaults` instead.\n *\n * @public\n */\nexport function createSpecializedApp(options?: {\n features?: FrontendFeature[];\n config?: ConfigApi;\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n apis?: ApiHolder;\n extensionFactoryMiddleware?:\n | ExtensionFactoryMiddleware\n | ExtensionFactoryMiddleware[];\n flags?: { allowUnknownExtensionConfig?: boolean };\n}): { apis: ApiHolder; tree: AppTree } {\n const config = options?.config ?? new ConfigReader({}, 'empty-config');\n const features = deduplicateFeatures(options?.features ?? []);\n\n const tree = resolveAppTree(\n 'root',\n resolveAppNodeSpecs({\n features,\n builtinExtensions: [\n resolveExtensionDefinition(Root, { namespace: 'root' }),\n ],\n parameters: readAppExtensionsConfig(config),\n forbidden: new Set(['root']),\n allowUnknownExtensionConfig: options?.flags?.allowUnknownExtensionConfig,\n }),\n );\n\n const factories = createApiFactories({ tree });\n const appBasePath = getBasePath(config);\n const appTreeApi = new AppTreeApiProxy(tree, appBasePath);\n const routeResolutionApi = new RouteResolutionApiProxy(\n resolveRouteBindings(\n options?.bindRoutes,\n config,\n collectRouteIds(features),\n ),\n appBasePath,\n );\n\n const appIdentityProxy = new AppIdentityProxy();\n const apis =\n options?.apis ??\n createApiHolder({\n factories,\n staticFactories: [\n createApiFactory(appTreeApiRef, appTreeApi),\n createApiFactory(configApiRef, config),\n createApiFactory(routeResolutionApiRef, routeResolutionApi),\n createApiFactory(identityApiRef, appIdentityProxy),\n ],\n });\n\n const featureFlagApi = apis.get(featureFlagsApiRef);\n if (featureFlagApi) {\n for (const feature of features) {\n if (OpaqueFrontendPlugin.isType(feature)) {\n OpaqueFrontendPlugin.toInternal(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n pluginId: feature.id,\n }),\n );\n }\n if (isInternalFrontendModule(feature)) {\n toInternalFrontendModule(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n pluginId: feature.pluginId,\n }),\n );\n }\n }\n }\n\n // Now instantiate the entire tree, which will skip anything that's already been instantiated\n instantiateAppNodeTree(\n tree.root,\n apis,\n mergeExtensionFactoryMiddleware(options?.extensionFactoryMiddleware),\n );\n\n const routeInfo = extractRouteInfoFromAppNode(tree.root);\n\n routeResolutionApi.initialize(routeInfo);\n appTreeApi.initialize(routeInfo);\n\n return { apis, tree };\n}\n\nfunction createApiFactories(options: { tree: AppTree }): AnyApiFactory[] {\n const emptyApiHolder = ApiRegistry.from([]);\n const factories = new Array<AnyApiFactory>();\n\n for (const apiNode of options.tree.root.edges.attachments.get('apis') ?? []) {\n instantiateAppNodeTree(apiNode, emptyApiHolder);\n const apiFactory = apiNode.instance?.getData(ApiBlueprint.dataRefs.factory);\n if (!apiFactory) {\n throw new Error(\n `No API factory found in for extension ${apiNode.spec.id}`,\n );\n }\n factories.push(apiFactory);\n }\n\n return factories;\n}\n\nfunction createApiHolder(options: {\n factories: AnyApiFactory[];\n staticFactories: AnyApiFactory[];\n}): ApiHolder {\n const factoryRegistry = new ApiFactoryRegistry();\n\n for (const factory of options.factories.slice().reverse()) {\n factoryRegistry.register('default', factory);\n }\n\n for (const factory of options.staticFactories) {\n factoryRegistry.register('static', factory);\n }\n\n ApiResolver.validateFactories(factoryRegistry, factoryRegistry.getAllApis());\n\n return new ApiResolver(factoryRegistry);\n}\n\nfunction mergeExtensionFactoryMiddleware(\n middlewares?: ExtensionFactoryMiddleware | ExtensionFactoryMiddleware[],\n): ExtensionFactoryMiddleware | undefined {\n if (!middlewares) {\n return undefined;\n }\n if (!Array.isArray(middlewares)) {\n return middlewares;\n }\n if (middlewares.length <= 1) {\n return middlewares[0];\n }\n return middlewares.reduce((prev, next) => {\n if (!prev || !next) {\n return prev ?? next;\n }\n return (orig, ctx) => {\n const internalExt = toInternalExtension(ctx.node.spec.extension);\n if (internalExt.version !== 'v2') {\n return orig();\n }\n return next(ctxOverrides => {\n return createExtensionDataContainer(\n prev(orig, {\n node: ctx.node,\n apis: ctx.apis,\n config: ctxOverrides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I,CAAC,KAAA,CAAM,OAAQ,CAAA,WAAW,CAAG,EAAA;AAC/B,IAAO,OAAA,WAAA;AAAA;AAET,EAAI,IAAA,WAAA,CAAY,UAAU,CAAG,EAAA;AAC3B,IAAA,OAAO,YAAY,CAAC,CAAA;AAAA;AAEtB,EAAA,OAAO,WAAY,CAAA,MAAA,CAAO,CAAC,IAAA,EAAM,IAAS,KAAA;AACxC,IAAI,IAAA,CAAC,IAAQ,IAAA,CAAC,IAAM,EAAA;AAClB,MAAA,OAAO,IAAQ,IAAA,IAAA;AAAA;AAEjB,IAAO,OAAA,CAAC,MAAM,GAAQ,KAAA;AACpB,MAAA,MAAM,WAAc,GAAA,mBAAA,CAAoB,GAAI,CAAA,IAAA,CAAK,KAAK,SAAS,CAAA;AAC/D,MAAI,IAAA,WAAA,CAAY,YAAY,IAAM,EAAA;AAChC,QAAA,OAAO,IAAK,EAAA;AAAA;AAEd,MAAA,OAAO,KAAK,CAAgB,YAAA,KAAA;AAC1B,QAAO,OAAA,4BAAA;AAAA,UACL,KAAK,IAAM,EAAA;AAAA,YACT,MAAM,GAAI,CAAA,IAAA;AAAA,YACV,MAAM,GAAI,CAAA,IAAA;AAAA,YACV,MAAA,EAAQ,YAAc,EAAA,MAAA,IAAU,GAAI,CAAA;AAAA,WACrC;AAAA,SACH;AAAA,SACC,GAAG,CAAA;AAAA,KACR;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"createSpecializedApp.esm.js","sources":["../../src/wiring/createSpecializedApp.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 { ConfigReader } from '@backstage/config';\nimport {\n ApiBlueprint,\n AppTree,\n AppTreeApi,\n appTreeApiRef,\n RouteRef,\n ExternalRouteRef,\n SubRouteRef,\n AnyRouteRefParams,\n RouteFunc,\n RouteResolutionApiResolveOptions,\n RouteResolutionApi,\n createApiFactory,\n routeResolutionApiRef,\n AppNode,\n ExtensionFactoryMiddleware,\n FrontendFeature,\n} from '@backstage/frontend-plugin-api';\nimport {\n AnyApiFactory,\n ApiHolder,\n ConfigApi,\n configApiRef,\n featureFlagsApiRef,\n identityApiRef,\n} from '@backstage/core-plugin-api';\nimport { ApiFactoryRegistry, ApiResolver } from '@backstage/core-app-api';\nimport {\n createExtensionDataContainer,\n OpaqueFrontendPlugin,\n} from '@internal/frontend';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n resolveExtensionDefinition,\n toInternalExtension,\n} from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n\nimport { extractRouteInfoFromAppNode } from '../routing/extractRouteInfoFromAppNode';\n\nimport { CreateAppRouteBinder } from '../routing';\nimport { RouteResolver } from '../routing/RouteResolver';\nimport { resolveRouteBindings } from '../routing/resolveRouteBindings';\nimport { collectRouteIds } from '../routing/collectRouteIds';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n toInternalFrontendModule,\n isInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\nimport { getBasePath } from '../routing/getBasePath';\nimport { Root } from '../extensions/Root';\nimport { resolveAppTree } from '../tree/resolveAppTree';\nimport { resolveAppNodeSpecs } from '../tree/resolveAppNodeSpecs';\nimport { readAppExtensionsConfig } from '../tree/readAppExtensionsConfig';\nimport { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiRegistry } from '../../../core-app-api/src/apis/system/ApiRegistry';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppIdentityProxy } from '../../../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy';\nimport { BackstageRouteObject } from '../routing/types';\nimport { RouteInfo } from './types';\nimport { matchRoutes } from 'react-router-dom';\nimport {\n createPluginInfoAttacher,\n FrontendPluginInfoResolver,\n} from './createPluginInfoAttacher';\n\nfunction deduplicateFeatures(\n allFeatures: FrontendFeature[],\n): FrontendFeature[] {\n // Start by removing duplicates by reference\n const features = Array.from(new Set(allFeatures));\n\n // Plugins are deduplicated by ID, last one wins\n const seenIds = new Set<string>();\n return features\n .reverse()\n .filter(feature => {\n if (!OpaqueFrontendPlugin.isType(feature)) {\n return true;\n }\n if (seenIds.has(feature.id)) {\n return false;\n }\n seenIds.add(feature.id);\n return true;\n })\n .reverse();\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass AppTreeApiProxy implements AppTreeApi {\n #routeInfo?: RouteInfo;\n\n constructor(\n private readonly tree: AppTree,\n private readonly appBasePath: string,\n ) {}\n\n private checkIfInitialized() {\n if (!this.#routeInfo) {\n throw new Error(\n `You can't access the AppTreeApi during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n }\n\n getTree() {\n this.checkIfInitialized();\n\n return { tree: this.tree };\n }\n\n getNodesByRoutePath(sourcePath: string): { nodes: AppNode[] } {\n this.checkIfInitialized();\n\n let path = sourcePath;\n if (path.startsWith(this.appBasePath)) {\n path = path.slice(this.appBasePath.length);\n }\n\n const matchedRoutes = matchRoutes(this.#routeInfo!.routeObjects, path);\n\n const matchedAppNodes =\n matchedRoutes\n ?.filter(routeObj => !!routeObj.route.appNode)\n .map(routeObj => routeObj.route.appNode!) || [];\n\n return { nodes: matchedAppNodes };\n }\n\n initialize(routeInfo: RouteInfo) {\n this.#routeInfo = routeInfo;\n }\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass RouteResolutionApiProxy implements RouteResolutionApi {\n #delegate: RouteResolutionApi | undefined;\n #routeObjects: BackstageRouteObject[] | undefined;\n\n constructor(\n private readonly routeBindings: Map<\n ExternalRouteRef,\n RouteRef | SubRouteRef\n >,\n private readonly appBasePath: string,\n ) {}\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: RouteResolutionApiResolveOptions,\n ): RouteFunc<TParams> | undefined {\n if (!this.#delegate) {\n throw new Error(\n `You can't access the RouteResolver during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n\n return this.#delegate.resolve(anyRouteRef, options);\n }\n\n initialize(routeInfo: RouteInfo) {\n this.#delegate = new RouteResolver(\n routeInfo.routePaths,\n routeInfo.routeParents,\n routeInfo.routeObjects,\n this.routeBindings,\n this.appBasePath,\n );\n this.#routeObjects = routeInfo.routeObjects;\n\n return routeInfo;\n }\n\n getRouteObjects() {\n return this.#routeObjects;\n }\n}\n\n/**\n * Creates an empty app without any default features. This is a low-level API is\n * intended for use in tests or specialized setups. Typically you want to use\n * `createApp` from `@backstage/frontend-defaults` instead.\n *\n * @public\n */\nexport function createSpecializedApp(options?: {\n features?: FrontendFeature[];\n config?: ConfigApi;\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n apis?: ApiHolder;\n extensionFactoryMiddleware?:\n | ExtensionFactoryMiddleware\n | ExtensionFactoryMiddleware[];\n flags?: { allowUnknownExtensionConfig?: boolean };\n pluginInfoResolver?: FrontendPluginInfoResolver;\n}): { apis: ApiHolder; tree: AppTree } {\n const config = options?.config ?? new ConfigReader({}, 'empty-config');\n const features = deduplicateFeatures(options?.features ?? []).map(\n createPluginInfoAttacher(config, options?.pluginInfoResolver),\n );\n\n const tree = resolveAppTree(\n 'root',\n resolveAppNodeSpecs({\n features,\n builtinExtensions: [\n resolveExtensionDefinition(Root, { namespace: 'root' }),\n ],\n parameters: readAppExtensionsConfig(config),\n forbidden: new Set(['root']),\n allowUnknownExtensionConfig: options?.flags?.allowUnknownExtensionConfig,\n }),\n );\n\n const factories = createApiFactories({ tree });\n const appBasePath = getBasePath(config);\n const appTreeApi = new AppTreeApiProxy(tree, appBasePath);\n const routeResolutionApi = new RouteResolutionApiProxy(\n resolveRouteBindings(\n options?.bindRoutes,\n config,\n collectRouteIds(features),\n ),\n appBasePath,\n );\n\n const appIdentityProxy = new AppIdentityProxy();\n const apis =\n options?.apis ??\n createApiHolder({\n factories,\n staticFactories: [\n createApiFactory(appTreeApiRef, appTreeApi),\n createApiFactory(configApiRef, config),\n createApiFactory(routeResolutionApiRef, routeResolutionApi),\n createApiFactory(identityApiRef, appIdentityProxy),\n ],\n });\n\n const featureFlagApi = apis.get(featureFlagsApiRef);\n if (featureFlagApi) {\n for (const feature of features) {\n if (OpaqueFrontendPlugin.isType(feature)) {\n OpaqueFrontendPlugin.toInternal(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n pluginId: feature.id,\n }),\n );\n }\n if (isInternalFrontendModule(feature)) {\n toInternalFrontendModule(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n pluginId: feature.pluginId,\n }),\n );\n }\n }\n }\n\n // Now instantiate the entire tree, which will skip anything that's already been instantiated\n instantiateAppNodeTree(\n tree.root,\n apis,\n mergeExtensionFactoryMiddleware(options?.extensionFactoryMiddleware),\n );\n\n const routeInfo = extractRouteInfoFromAppNode(tree.root);\n\n routeResolutionApi.initialize(routeInfo);\n appTreeApi.initialize(routeInfo);\n\n return { apis, tree };\n}\n\nfunction createApiFactories(options: { tree: AppTree }): AnyApiFactory[] {\n const emptyApiHolder = ApiRegistry.from([]);\n const factories = new Array<AnyApiFactory>();\n\n for (const apiNode of options.tree.root.edges.attachments.get('apis') ?? []) {\n instantiateAppNodeTree(apiNode, emptyApiHolder);\n const apiFactory = apiNode.instance?.getData(ApiBlueprint.dataRefs.factory);\n if (!apiFactory) {\n throw new Error(\n `No API factory found in for extension ${apiNode.spec.id}`,\n );\n }\n factories.push(apiFactory);\n }\n\n return factories;\n}\n\nfunction createApiHolder(options: {\n factories: AnyApiFactory[];\n staticFactories: AnyApiFactory[];\n}): ApiHolder {\n const factoryRegistry = new ApiFactoryRegistry();\n\n for (const factory of options.factories.slice().reverse()) {\n factoryRegistry.register('default', factory);\n }\n\n for (const factory of options.staticFactories) {\n factoryRegistry.register('static', factory);\n }\n\n ApiResolver.validateFactories(factoryRegistry, factoryRegistry.getAllApis());\n\n return new ApiResolver(factoryRegistry);\n}\n\nfunction mergeExtensionFactoryMiddleware(\n middlewares?: ExtensionFactoryMiddleware | ExtensionFactoryMiddleware[],\n): ExtensionFactoryMiddleware | undefined {\n if (!middlewares) {\n return undefined;\n }\n if (!Array.isArray(middlewares)) {\n return middlewares;\n }\n if (middlewares.length <= 1) {\n return middlewares[0];\n }\n return middlewares.reduce((prev, next) => {\n if (!prev || !next) {\n return prev ?? next;\n }\n return (orig, ctx) => {\n const internalExt = toInternalExtension(ctx.node.spec.extension);\n if (internalExt.version !== 'v2') {\n return orig();\n }\n return next(ctxOverrides => {\n return createExtensionDataContainer(\n prev(orig, {\n node: ctx.node,\n apis: ctx.apis,\n config: ctxOverrides?.config ?? ctx.config,\n }),\n );\n }, ctx);\n };\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAS,oBACP,WACmB,EAAA;AAEnB,EAAA,MAAM,WAAW,KAAM,CAAA,IAAA,CAAK,IAAI,GAAA,CAAI,WAAW,CAAC,CAAA;AAGhD,EAAM,MAAA,OAAA,uBAAc,GAAY,EAAA;AAChC,EAAA,OAAO,QACJ,CAAA,OAAA,EACA,CAAA,MAAA,CAAO,CAAW,OAAA,KAAA;AACjB,IAAA,IAAI,CAAC,oBAAA,CAAqB,MAAO,CAAA,OAAO,CAAG,EAAA;AACzC,MAAO,OAAA,IAAA;AAAA;AAET,IAAA,IAAI,OAAQ,CAAA,GAAA,CAAI,OAAQ,CAAA,EAAE,CAAG,EAAA;AAC3B,MAAO,OAAA,KAAA;AAAA;AAET,IA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AK,KAAK,SAAS,CAAA;AAC/D,MAAI,IAAA,WAAA,CAAY,YAAY,IAAM,EAAA;AAChC,QAAA,OAAO,IAAK,EAAA;AAAA;AAEd,MAAA,OAAO,KAAK,CAAgB,YAAA,KAAA;AAC1B,QAAO,OAAA,4BAAA;AAAA,UACL,KAAK,IAAM,EAAA;AAAA,YACT,MAAM,GAAI,CAAA,IAAA;AAAA,YACV,MAAM,GAAI,CAAA,IAAA;AAAA,YACV,MAAA,EAAQ,YAAc,EAAA,MAAA,IAAU,GAAI,CAAA;AAAA,WACrC;AAAA,SACH;AAAA,SACC,GAAG,CAAA;AAAA,KACR;AAAA,GACD,CAAA;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/frontend-app-api",
3
- "version": "0.11.2-next.3",
3
+ "version": "0.11.3-next.0",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -33,20 +33,20 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@backstage/config": "1.3.2",
36
- "@backstage/core-app-api": "1.17.0-next.1",
37
- "@backstage/core-plugin-api": "1.10.7-next.0",
36
+ "@backstage/core-app-api": "1.17.0",
37
+ "@backstage/core-plugin-api": "1.10.7",
38
38
  "@backstage/errors": "1.2.7",
39
- "@backstage/frontend-defaults": "0.2.2-next.3",
40
- "@backstage/frontend-plugin-api": "0.10.2-next.1",
39
+ "@backstage/frontend-defaults": "0.2.3-next.0",
40
+ "@backstage/frontend-plugin-api": "0.10.3-next.0",
41
41
  "@backstage/types": "1.2.1",
42
42
  "@backstage/version-bridge": "1.0.11",
43
43
  "lodash": "^4.17.21",
44
44
  "zod": "^3.22.4"
45
45
  },
46
46
  "devDependencies": {
47
- "@backstage/cli": "0.32.1-next.3",
48
- "@backstage/plugin-app": "0.1.9-next.3",
49
- "@backstage/test-utils": "1.7.8-next.2",
47
+ "@backstage/cli": "0.32.1",
48
+ "@backstage/plugin-app": "0.1.10-next.0",
49
+ "@backstage/test-utils": "1.7.8",
50
50
  "@testing-library/jest-dom": "^6.0.0",
51
51
  "@testing-library/react": "^16.0.0",
52
52
  "@types/react": "^18.0.0",