@backstage/frontend-app-api 0.16.2 → 0.16.3-next.1
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 +26 -0
- package/dist/index.d.ts +7 -0
- package/dist/routing/RouteResolver.esm.js +2 -8
- package/dist/routing/RouteResolver.esm.js.map +1 -1
- package/dist/routing/extractRouteInfoFromAppNode.esm.js +2 -8
- package/dist/routing/extractRouteInfoFromAppNode.esm.js.map +1 -1
- package/dist/routing/joinPaths.esm.js +10 -0
- package/dist/routing/joinPaths.esm.js.map +1 -0
- package/dist/wiring/apiFactories.esm.js +36 -21
- package/dist/wiring/apiFactories.esm.js.map +1 -1
- package/dist/wiring/createErrorCollector.esm.js.map +1 -1
- package/dist/wiring/prepareSpecializedApp.esm.js +2 -2
- package/dist/wiring/prepareSpecializedApp.esm.js.map +1 -1
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @backstage/frontend-app-api
|
|
2
2
|
|
|
3
|
+
## 0.16.3-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b6ca666: Invalid feature flag declarations no longer crash the app during bootstrap. They are now reported through the error collector and skipped, letting the rest of the app load normally.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/frontend-defaults@0.5.2-next.1
|
|
10
|
+
- @backstage/frontend-plugin-api@0.17.0-next.1
|
|
11
|
+
- @backstage/core-plugin-api@1.12.6-next.1
|
|
12
|
+
|
|
13
|
+
## 0.16.3-next.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- f79eaf2: Internal cleanup of routing utilities.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/errors@1.3.1-next.0
|
|
20
|
+
- @backstage/frontend-plugin-api@0.17.0-next.0
|
|
21
|
+
- @backstage/frontend-defaults@0.5.2-next.0
|
|
22
|
+
- @backstage/core-app-api@1.20.1-next.0
|
|
23
|
+
- @backstage/config@1.3.8-next.0
|
|
24
|
+
- @backstage/core-plugin-api@1.12.6-next.0
|
|
25
|
+
- @backstage/filter-predicates@0.1.3-next.0
|
|
26
|
+
- @backstage/types@1.2.2
|
|
27
|
+
- @backstage/version-bridge@1.0.12
|
|
28
|
+
|
|
3
29
|
## 0.16.2
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,13 @@ type AppErrorTypes = {
|
|
|
176
176
|
bootstrapPluginId: string;
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
|
+
FEATURE_FLAG_INVALID: {
|
|
180
|
+
context: {
|
|
181
|
+
pluginId: string;
|
|
182
|
+
flagName: string;
|
|
183
|
+
error: Error;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
179
186
|
ROUTE_DUPLICATE: {
|
|
180
187
|
context: {
|
|
181
188
|
routeId: string;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { generatePath, matchRoutes } from 'react-router-dom';
|
|
2
2
|
import mapValues from 'lodash/mapValues';
|
|
3
|
+
import { joinPaths } from './joinPaths.esm.js';
|
|
3
4
|
import { OpaqueExternalRouteRef } from '../frontend-internal/src/routing/OpaqueExternalRouteRef.esm.js';
|
|
4
5
|
import { OpaqueRouteRef } from '../frontend-internal/src/routing/OpaqueRouteRef.esm.js';
|
|
5
6
|
import { OpaqueSubRouteRef } from '../frontend-internal/src/routing/OpaqueSubRouteRef.esm.js';
|
|
6
7
|
|
|
7
|
-
function joinPaths(...paths) {
|
|
8
|
-
const normalized = paths.join("/").replace(/\/\/+/g, "/");
|
|
9
|
-
if (normalized !== "/" && normalized.endsWith("/")) {
|
|
10
|
-
return normalized.slice(0, -1);
|
|
11
|
-
}
|
|
12
|
-
return normalized;
|
|
13
|
-
}
|
|
14
8
|
function resolveTargetRef(targetRouteRef, routePaths, routeBindings, routeRefsById) {
|
|
15
9
|
let ref = targetRouteRef;
|
|
16
10
|
let path = "";
|
|
@@ -133,5 +127,5 @@ class RouteResolver {
|
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
export { RouteResolver
|
|
130
|
+
export { RouteResolver };
|
|
137
131
|
//# sourceMappingURL=RouteResolver.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteResolver.esm.js","sources":["../../src/routing/RouteResolver.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 { generatePath, matchRoutes } from 'react-router-dom';\nimport {\n RouteRef,\n ExternalRouteRef,\n SubRouteRef,\n AnyRouteRefParams,\n RouteFunc,\n RouteResolutionApi,\n} from '@backstage/frontend-plugin-api';\nimport mapValues from 'lodash/mapValues';\nimport { AnyRouteRef, BackstageRouteObject } from './types';\nimport {\n OpaqueRouteRef,\n OpaqueExternalRouteRef,\n OpaqueSubRouteRef,\n} from '@internal/frontend';\nimport { RouteAliasResolver } from './RouteAliasResolver';\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\n/**\n * Resolves the absolute route ref that our target route ref is pointing pointing to, as well\n * as the relative target path.\n *\n * Returns an undefined target ref if one could not be fully resolved.\n */\nfunction resolveTargetRef(\n targetRouteRef: AnyRouteRef,\n routePaths: Map<RouteRef, string>,\n routeBindings: Map<AnyRouteRef, AnyRouteRef | undefined>,\n routeRefsById: Map<string, RouteRef | SubRouteRef>,\n): readonly [RouteRef | undefined, string] {\n // First we figure out which absolute route ref we're dealing with, an if there was an sub route path to append.\n // For sub routes it will be the parent path, while for external routes it will be the bound route.\n let ref: AnyRouteRef = targetRouteRef;\n let path = '';\n\n if (OpaqueExternalRouteRef.isType(ref)) {\n let resolvedRoute = routeBindings.get(ref);\n if (!resolvedRoute) {\n const internal = OpaqueExternalRouteRef.toInternal(ref);\n const defaultTarget = internal.getDefaultTarget();\n if (defaultTarget) {\n resolvedRoute = routeRefsById.get(defaultTarget);\n }\n }\n if (!resolvedRoute) {\n return [undefined, ''];\n }\n ref = resolvedRoute;\n }\n\n if (OpaqueSubRouteRef.isType(ref)) {\n const internal = OpaqueSubRouteRef.toInternal(ref);\n path = ref.path;\n ref = internal.getParent();\n }\n\n if (!OpaqueRouteRef.isType(ref)) {\n throw new Error(\n `Unexpectedly resolved ${targetRouteRef} to a non-route ref ${ref}`,\n );\n }\n\n // Find the path that our target route is bound to\n const resolvedPath = routePaths.get(ref);\n if (resolvedPath === undefined) {\n return [undefined, ''];\n }\n\n return [ref, path ? joinPaths(resolvedPath, path) : resolvedPath];\n}\n\n/**\n * Resolves the complete base path for navigating to the target RouteRef.\n */\nfunction resolveBasePath(\n targetRef: RouteRef,\n sourceLocation: Parameters<typeof matchRoutes>[1],\n routePaths: Map<RouteRef, string>,\n routeParents: Map<RouteRef, RouteRef | undefined>,\n routeObjects: BackstageRouteObject[],\n) {\n // While traversing the app element tree we build up the routeObjects structure\n // used here. It is the same kind of structure that react-router creates, with the\n // addition that associated route refs are stored throughout the tree. This lets\n // us look up all route refs that can be reached from our source location.\n // Because of the similar route object structure, we can use `matchRoutes` from\n // react-router to do the lookup of our current location.\n const match = matchRoutes(routeObjects, sourceLocation) ?? [];\n\n // While we search for a common routing root between our current location and\n // the target route, we build a list of all route refs we find that we need\n // to traverse to reach the target.\n const refDiffList = Array<RouteRef>();\n\n let matchIndex = -1;\n for (\n let targetSearchRef: RouteRef | undefined = targetRef;\n targetSearchRef;\n targetSearchRef = routeParents.get(targetSearchRef)\n ) {\n // The match contains a list of all ancestral route refs present at our current location\n // Starting at the desired target ref and traversing back through its parents, we search\n // for a target ref that is present in the match for our current location. When a match\n // is found it means we have found a common base to resolve the route from.\n matchIndex = match.findIndex(m =>\n (m.route as BackstageRouteObject).routeRefs.has(targetSearchRef!),\n );\n if (matchIndex !== -1) {\n break;\n }\n\n // Every time we move a step up in the ancestry of the target ref, we add the current ref\n // to the diff list, which ends up being the list of route refs to traverse form the common base\n // in order to reach our target.\n refDiffList.unshift(targetSearchRef);\n }\n\n // If our target route is present in the initial match we need to construct the final path\n // from the parent of the matched route segment. That's to allow the caller of the route\n // function to supply their own params.\n if (refDiffList.length === 0) {\n matchIndex -= 1;\n }\n\n // This is the part of the route tree that the target and source locations have in common.\n // We re-use the existing pathname directly along with all params.\n const parentPath = matchIndex === -1 ? '' : match[matchIndex].pathname;\n\n // This constructs the mid section of the path using paths resolved from all route refs\n // we need to traverse to reach our target except for the very last one. None of these\n // paths are allowed to require any parameters, as the caller would have no way of knowing\n // what parameters those are.\n const diffPaths = refDiffList.slice(0, -1).map(ref => {\n const path = routePaths.get(ref);\n if (path === undefined) {\n throw new Error(`No path for ${ref}`);\n }\n if (path.includes(':')) {\n throw new Error(\n `Cannot route to ${targetRef} with parent ${ref} as it has parameters`,\n );\n }\n return path;\n });\n\n return `${joinPaths(parentPath, ...diffPaths)}/`;\n}\n\nexport class RouteResolver implements RouteResolutionApi {\n private readonly routePaths: Map<RouteRef, string>;\n private readonly routeParents: Map<RouteRef, RouteRef | undefined>;\n private readonly routeObjects: BackstageRouteObject[];\n private readonly routeBindings: Map<ExternalRouteRef, RouteRef | SubRouteRef>;\n private readonly appBasePath: string; // base path without a trailing slash\n private readonly routeAliasResolver: RouteAliasResolver;\n private readonly routeRefsById: Map<string, RouteRef | SubRouteRef>;\n\n constructor(\n routePaths: Map<RouteRef, string>,\n routeParents: Map<RouteRef, RouteRef | undefined>,\n routeObjects: BackstageRouteObject[],\n routeBindings: Map<ExternalRouteRef, RouteRef | SubRouteRef>,\n appBasePath: string, // base path without a trailing slash\n routeAliasResolver: RouteAliasResolver,\n routeRefsById: Map<string, RouteRef | SubRouteRef>,\n ) {\n this.routePaths = routePaths;\n this.routeParents = routeParents;\n this.routeObjects = routeObjects;\n this.routeBindings = routeBindings;\n this.appBasePath = appBasePath;\n this.routeAliasResolver = routeAliasResolver;\n this.routeRefsById = routeRefsById;\n }\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: { sourcePath?: string },\n ): RouteFunc<TParams> | undefined {\n // First figure out what our target absolute ref is, as well as our target path.\n const [targetRef, targetPath] = resolveTargetRef(\n anyRouteRef?.$$type === '@backstage/RouteRef'\n ? this.routeAliasResolver(anyRouteRef)\n : anyRouteRef,\n this.routePaths,\n this.routeBindings,\n this.routeRefsById,\n );\n if (!targetRef) {\n return undefined;\n }\n\n // The location that we get passed in uses the full path, so start by trimming off\n // the app base path prefix in case we're running the app on a sub-path.\n const relativeSourceLocation = this.trimPath(options?.sourcePath ?? '');\n\n // Next we figure out the base path, which is the combination of the common parent path\n // between our current location and our target location, as well as the additional path\n // that is the difference between the parent path and the base of our target location.\n const basePath = resolveBasePath(\n targetRef,\n relativeSourceLocation,\n this.routePaths,\n this.routeParents,\n this.routeObjects,\n );\n\n const routeFunc: RouteFunc<TParams> = (...[params]) => {\n // We selectively encode some some known-dangerous characters in the\n // params. The reason that we don't perform a blanket `encodeURIComponent`\n // here is that this encoding was added defensively long after the initial\n // release of this code. There's likely to be many users of this code that\n // already encode their parameters knowing that this code didn't do this\n // for them in the past. Therefore, we are extra careful NOT to include\n // the percent character in this set, even though that might seem like a\n // bad idea.\n const encodedParams =\n params &&\n mapValues(params, value => {\n if (typeof value === 'string') {\n return value.replaceAll(/[&?#;\\/]/g, c => encodeURIComponent(c));\n }\n return value;\n });\n return joinPaths(basePath, generatePath(targetPath, encodedParams));\n };\n return routeFunc;\n }\n\n private trimPath(targetPath: string) {\n if (!targetPath) {\n return targetPath;\n }\n\n if (targetPath.startsWith(this.appBasePath)) {\n return targetPath.slice(this.appBasePath.length);\n }\n return targetPath;\n }\n}\n"],"names":[],"mappings":";;;;;;AAmCO,SAAS,aAAa,KAAA,EAAyB;AACpD,EAAA,MAAM,aAAa,KAAA,CAAM,IAAA,CAAK,GAAG,CAAA,CAAE,OAAA,CAAQ,UAAU,GAAG,CAAA;AACxD,EAAA,IAAI,UAAA,KAAe,GAAA,IAAO,UAAA,CAAW,QAAA,CAAS,GAAG,CAAA,EAAG;AAClD,IAAA,OAAO,UAAA,CAAW,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,UAAA;AACT;AAQA,SAAS,gBAAA,CACP,cAAA,EACA,UAAA,EACA,aAAA,EACA,aAAA,EACyC;AAGzC,EAAA,IAAI,GAAA,GAAmB,cAAA;AACvB,EAAA,IAAI,IAAA,GAAO,EAAA;AAEX,EAAA,IAAI,sBAAA,CAAuB,MAAA,CAAO,GAAG,CAAA,EAAG;AACtC,IAAA,IAAI,aAAA,GAAgB,aAAA,CAAc,GAAA,CAAI,GAAG,CAAA;AACzC,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,MAAM,QAAA,GAAW,sBAAA,CAAuB,UAAA,CAAW,GAAG,CAAA;AACtD,MAAA,MAAM,aAAA,GAAgB,SAAS,gBAAA,EAAiB;AAChD,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,aAAA,GAAgB,aAAA,CAAc,IAAI,aAAa,CAAA;AAAA,MACjD;AAAA,IACF;AACA,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,OAAO,CAAC,QAAW,EAAE,CAAA;AAAA,IACvB;AACA,IAAA,GAAA,GAAM,aAAA;AAAA,EACR;AAEA,EAAA,IAAI,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SAAS,UAAA,EAAoB;AACnC,IAAA,IAAI,CAAC,UAAA,EAAY;AACf,MAAA,OAAO,UAAA;AAAA,IACT;AAEA,IAAA,IAAI,UAAA,CAAW,UAAA,CAAW,IAAA,CAAK,WAAW,CAAA,EAAG;AAC3C,MAAA,OAAO,UAAA,CAAW,KAAA,CAAM,IAAA,CAAK,WAAA,CAAY,MAAM,CAAA;AAAA,IACjD;AACA,IAAA,OAAO,UAAA;AAAA,EACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"RouteResolver.esm.js","sources":["../../src/routing/RouteResolver.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 { generatePath, matchRoutes } from 'react-router-dom';\nimport {\n RouteRef,\n ExternalRouteRef,\n SubRouteRef,\n AnyRouteRefParams,\n RouteFunc,\n RouteResolutionApi,\n} from '@backstage/frontend-plugin-api';\nimport mapValues from 'lodash/mapValues';\nimport { AnyRouteRef, BackstageRouteObject } from './types';\nimport {\n OpaqueRouteRef,\n OpaqueExternalRouteRef,\n OpaqueSubRouteRef,\n} from '@internal/frontend';\nimport { RouteAliasResolver } from './RouteAliasResolver';\nimport { joinPaths } from './joinPaths';\n\n/**\n * Resolves the absolute route ref that our target route ref is pointing pointing to, as well\n * as the relative target path.\n *\n * Returns an undefined target ref if one could not be fully resolved.\n */\nfunction resolveTargetRef(\n targetRouteRef: AnyRouteRef,\n routePaths: Map<RouteRef, string>,\n routeBindings: Map<AnyRouteRef, AnyRouteRef | undefined>,\n routeRefsById: Map<string, RouteRef | SubRouteRef>,\n): readonly [RouteRef | undefined, string] {\n // First we figure out which absolute route ref we're dealing with, an if there was an sub route path to append.\n // For sub routes it will be the parent path, while for external routes it will be the bound route.\n let ref: AnyRouteRef = targetRouteRef;\n let path = '';\n\n if (OpaqueExternalRouteRef.isType(ref)) {\n let resolvedRoute = routeBindings.get(ref);\n if (!resolvedRoute) {\n const internal = OpaqueExternalRouteRef.toInternal(ref);\n const defaultTarget = internal.getDefaultTarget();\n if (defaultTarget) {\n resolvedRoute = routeRefsById.get(defaultTarget);\n }\n }\n if (!resolvedRoute) {\n return [undefined, ''];\n }\n ref = resolvedRoute;\n }\n\n if (OpaqueSubRouteRef.isType(ref)) {\n const internal = OpaqueSubRouteRef.toInternal(ref);\n path = ref.path;\n ref = internal.getParent();\n }\n\n if (!OpaqueRouteRef.isType(ref)) {\n throw new Error(\n `Unexpectedly resolved ${targetRouteRef} to a non-route ref ${ref}`,\n );\n }\n\n // Find the path that our target route is bound to\n const resolvedPath = routePaths.get(ref);\n if (resolvedPath === undefined) {\n return [undefined, ''];\n }\n\n return [ref, path ? joinPaths(resolvedPath, path) : resolvedPath];\n}\n\n/**\n * Resolves the complete base path for navigating to the target RouteRef.\n */\nfunction resolveBasePath(\n targetRef: RouteRef,\n sourceLocation: Parameters<typeof matchRoutes>[1],\n routePaths: Map<RouteRef, string>,\n routeParents: Map<RouteRef, RouteRef | undefined>,\n routeObjects: BackstageRouteObject[],\n) {\n // While traversing the app element tree we build up the routeObjects structure\n // used here. It is the same kind of structure that react-router creates, with the\n // addition that associated route refs are stored throughout the tree. This lets\n // us look up all route refs that can be reached from our source location.\n // Because of the similar route object structure, we can use `matchRoutes` from\n // react-router to do the lookup of our current location.\n const match = matchRoutes(routeObjects, sourceLocation) ?? [];\n\n // While we search for a common routing root between our current location and\n // the target route, we build a list of all route refs we find that we need\n // to traverse to reach the target.\n const refDiffList = Array<RouteRef>();\n\n let matchIndex = -1;\n for (\n let targetSearchRef: RouteRef | undefined = targetRef;\n targetSearchRef;\n targetSearchRef = routeParents.get(targetSearchRef)\n ) {\n // The match contains a list of all ancestral route refs present at our current location\n // Starting at the desired target ref and traversing back through its parents, we search\n // for a target ref that is present in the match for our current location. When a match\n // is found it means we have found a common base to resolve the route from.\n matchIndex = match.findIndex(m =>\n (m.route as BackstageRouteObject).routeRefs.has(targetSearchRef!),\n );\n if (matchIndex !== -1) {\n break;\n }\n\n // Every time we move a step up in the ancestry of the target ref, we add the current ref\n // to the diff list, which ends up being the list of route refs to traverse form the common base\n // in order to reach our target.\n refDiffList.unshift(targetSearchRef);\n }\n\n // If our target route is present in the initial match we need to construct the final path\n // from the parent of the matched route segment. That's to allow the caller of the route\n // function to supply their own params.\n if (refDiffList.length === 0) {\n matchIndex -= 1;\n }\n\n // This is the part of the route tree that the target and source locations have in common.\n // We re-use the existing pathname directly along with all params.\n const parentPath = matchIndex === -1 ? '' : match[matchIndex].pathname;\n\n // This constructs the mid section of the path using paths resolved from all route refs\n // we need to traverse to reach our target except for the very last one. None of these\n // paths are allowed to require any parameters, as the caller would have no way of knowing\n // what parameters those are.\n const diffPaths = refDiffList.slice(0, -1).map(ref => {\n const path = routePaths.get(ref);\n if (path === undefined) {\n throw new Error(`No path for ${ref}`);\n }\n if (path.includes(':')) {\n throw new Error(\n `Cannot route to ${targetRef} with parent ${ref} as it has parameters`,\n );\n }\n return path;\n });\n\n return `${joinPaths(parentPath, ...diffPaths)}/`;\n}\n\nexport class RouteResolver implements RouteResolutionApi {\n private readonly routePaths: Map<RouteRef, string>;\n private readonly routeParents: Map<RouteRef, RouteRef | undefined>;\n private readonly routeObjects: BackstageRouteObject[];\n private readonly routeBindings: Map<ExternalRouteRef, RouteRef | SubRouteRef>;\n private readonly appBasePath: string; // base path without a trailing slash\n private readonly routeAliasResolver: RouteAliasResolver;\n private readonly routeRefsById: Map<string, RouteRef | SubRouteRef>;\n\n constructor(\n routePaths: Map<RouteRef, string>,\n routeParents: Map<RouteRef, RouteRef | undefined>,\n routeObjects: BackstageRouteObject[],\n routeBindings: Map<ExternalRouteRef, RouteRef | SubRouteRef>,\n appBasePath: string, // base path without a trailing slash\n routeAliasResolver: RouteAliasResolver,\n routeRefsById: Map<string, RouteRef | SubRouteRef>,\n ) {\n this.routePaths = routePaths;\n this.routeParents = routeParents;\n this.routeObjects = routeObjects;\n this.routeBindings = routeBindings;\n this.appBasePath = appBasePath;\n this.routeAliasResolver = routeAliasResolver;\n this.routeRefsById = routeRefsById;\n }\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: { sourcePath?: string },\n ): RouteFunc<TParams> | undefined {\n // First figure out what our target absolute ref is, as well as our target path.\n const [targetRef, targetPath] = resolveTargetRef(\n anyRouteRef?.$$type === '@backstage/RouteRef'\n ? this.routeAliasResolver(anyRouteRef)\n : anyRouteRef,\n this.routePaths,\n this.routeBindings,\n this.routeRefsById,\n );\n if (!targetRef) {\n return undefined;\n }\n\n // The location that we get passed in uses the full path, so start by trimming off\n // the app base path prefix in case we're running the app on a sub-path.\n const relativeSourceLocation = this.trimPath(options?.sourcePath ?? '');\n\n // Next we figure out the base path, which is the combination of the common parent path\n // between our current location and our target location, as well as the additional path\n // that is the difference between the parent path and the base of our target location.\n const basePath = resolveBasePath(\n targetRef,\n relativeSourceLocation,\n this.routePaths,\n this.routeParents,\n this.routeObjects,\n );\n\n const routeFunc: RouteFunc<TParams> = (...[params]) => {\n // We selectively encode some some known-dangerous characters in the\n // params. The reason that we don't perform a blanket `encodeURIComponent`\n // here is that this encoding was added defensively long after the initial\n // release of this code. There's likely to be many users of this code that\n // already encode their parameters knowing that this code didn't do this\n // for them in the past. Therefore, we are extra careful NOT to include\n // the percent character in this set, even though that might seem like a\n // bad idea.\n const encodedParams =\n params &&\n mapValues(params, value => {\n if (typeof value === 'string') {\n return value.replaceAll(/[&?#;\\/]/g, c => encodeURIComponent(c));\n }\n return value;\n });\n return joinPaths(basePath, generatePath(targetPath, encodedParams));\n };\n return routeFunc;\n }\n\n private trimPath(targetPath: string) {\n if (!targetPath) {\n return targetPath;\n }\n\n if (targetPath.startsWith(this.appBasePath)) {\n return targetPath.slice(this.appBasePath.length);\n }\n return targetPath;\n }\n}\n"],"names":[],"mappings":";;;;;;;AAyCA,SAAS,gBAAA,CACP,cAAA,EACA,UAAA,EACA,aAAA,EACA,aAAA,EACyC;AAGzC,EAAA,IAAI,GAAA,GAAmB,cAAA;AACvB,EAAA,IAAI,IAAA,GAAO,EAAA;AAEX,EAAA,IAAI,sBAAA,CAAuB,MAAA,CAAO,GAAG,CAAA,EAAG;AACtC,IAAA,IAAI,aAAA,GAAgB,aAAA,CAAc,GAAA,CAAI,GAAG,CAAA;AACzC,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,MAAM,QAAA,GAAW,sBAAA,CAAuB,UAAA,CAAW,GAAG,CAAA;AACtD,MAAA,MAAM,aAAA,GAAgB,SAAS,gBAAA,EAAiB;AAChD,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,aAAA,GAAgB,aAAA,CAAc,IAAI,aAAa,CAAA;AAAA,MACjD;AAAA,IACF;AACA,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,OAAO,CAAC,QAAW,EAAE,CAAA;AAAA,IACvB;AACA,IAAA,GAAA,GAAM,aAAA;AAAA,EACR;AAEA,EAAA,IAAI,iBAAA,CAAkB,MAAA,CAAO,GAAG,CAAA,EAAG;AACjC,IAAA,MAAM,QAAA,GAAW,iBAAA,CAAkB,UAAA,CAAW,GAAG,CAAA;AACjD,IAAA,IAAA,GAAO,GAAA,CAAI,IAAA;AACX,IAAA,GAAA,GAAM,SAAS,SAAA,EAAU;AAAA,EAC3B;AAEA,EAAA,IAAI,CAAC,cAAA,CAAe,MAAA,CAAO,GAAG,CAAA,EAAG;AAC/B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,sBAAA,EAAyB,cAAc,CAAA,oBAAA,EAAuB,GAAG,CAAA;AAAA,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import { createExactRouteAliasResolver } from './RouteAliasResolver.esm.js';
|
|
3
|
+
import { joinPaths } from './joinPaths.esm.js';
|
|
3
4
|
|
|
4
5
|
const MATCH_ALL_ROUTE = {
|
|
5
6
|
caseSensitive: false,
|
|
@@ -8,13 +9,6 @@ const MATCH_ALL_ROUTE = {
|
|
|
8
9
|
// These elements aren't used, so we add in a bit of debug information
|
|
9
10
|
routeRefs: /* @__PURE__ */ new Set()
|
|
10
11
|
};
|
|
11
|
-
function joinPaths(...paths) {
|
|
12
|
-
const normalized = paths.join("/").replace(/\/\/+/g, "/");
|
|
13
|
-
if (normalized !== "/" && normalized.endsWith("/")) {
|
|
14
|
-
return normalized.slice(0, -1);
|
|
15
|
-
}
|
|
16
|
-
return normalized;
|
|
17
|
-
}
|
|
18
12
|
function extractRouteInfoFromAppNode(node, routeAliasResolver) {
|
|
19
13
|
const routePaths = /* @__PURE__ */ new Map();
|
|
20
14
|
const routeParents = /* @__PURE__ */ new Map();
|
|
@@ -85,5 +79,5 @@ function extractRouteInfoFromAppNode(node, routeAliasResolver) {
|
|
|
85
79
|
};
|
|
86
80
|
}
|
|
87
81
|
|
|
88
|
-
export { MATCH_ALL_ROUTE, extractRouteInfoFromAppNode
|
|
82
|
+
export { MATCH_ALL_ROUTE, extractRouteInfoFromAppNode };
|
|
89
83
|
//# sourceMappingURL=extractRouteInfoFromAppNode.esm.js.map
|
|
@@ -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 {\n createExactRouteAliasResolver,\n RouteAliasResolver,\n} from './RouteAliasResolver';\n\n/** @internal */\nexport type RouteInfo = {\n routePaths: Map<RouteRef, string>;\n routeParents: Map<RouteRef, RouteRef | undefined>;\n routeObjects: BackstageRouteObject[];\n routeAliasResolver: RouteAliasResolver;\n};\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};\n\
|
|
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 {\n createExactRouteAliasResolver,\n RouteAliasResolver,\n} from './RouteAliasResolver';\nimport { joinPaths } from './joinPaths';\n\n/** @internal */\nexport type RouteInfo = {\n routePaths: Map<RouteRef, string>;\n routeParents: Map<RouteRef, RouteRef | undefined>;\n routeObjects: BackstageRouteObject[];\n routeAliasResolver: RouteAliasResolver;\n};\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};\n\nexport function extractRouteInfoFromAppNode(\n node: AppNode,\n routeAliasResolver: RouteAliasResolver,\n): RouteInfo {\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 // This tracks all resolved route aliases. By storing and re-using the resolutions here we make sure that it's not\n // possible to pass an aliased route ref directly to the resolver, e.g. `useRouteRef(createRouteRef({ aliasFor: 'example.root' }))`\n const routeAliases = new Map<RouteRef, RouteRef | undefined>();\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\n const foundRouteRef = current.instance?.getData(coreExtensionData.routeRef);\n const routeRef = routeAliasResolver(foundRouteRef, current.spec.plugin?.id);\n if (foundRouteRef && routeRef !== foundRouteRef) {\n routeAliases.set(foundRouteRef, routeRef);\n }\n\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 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 }\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 {\n routePaths,\n routeParents,\n routeObjects,\n routeAliasResolver: createExactRouteAliasResolver(routeAliases),\n };\n}\n"],"names":[],"mappings":";;;;AAqCO,MAAM,eAAA,GAAwC;AAAA,EACnD,aAAA,EAAe,KAAA;AAAA,EACf,IAAA,EAAM,GAAA;AAAA,EACN,OAAA,EAAS,WAAA;AAAA;AAAA,EACT,SAAA,sBAAe,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0 +1,10 @@
|
|
|
1
|
+
function joinPaths(...paths) {
|
|
2
|
+
const normalized = paths.join("/").replace(/\/\/+/g, "/");
|
|
3
|
+
if (normalized !== "/" && normalized.endsWith("/")) {
|
|
4
|
+
return normalized.slice(0, -1);
|
|
5
|
+
}
|
|
6
|
+
return normalized;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { joinPaths };
|
|
10
|
+
//# sourceMappingURL=joinPaths.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joinPaths.esm.js","sources":["../../src/routing/joinPaths.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// 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"],"names":[],"mappings":"AAiBO,SAAS,aAAa,KAAA,EAAyB;AACpD,EAAA,MAAM,aAAa,KAAA,CAAM,IAAA,CAAK,GAAG,CAAA,CAAE,OAAA,CAAQ,UAAU,GAAG,CAAA;AACxD,EAAA,IAAI,UAAA,KAAe,GAAA,IAAO,UAAA,CAAW,QAAA,CAAS,GAAG,CAAA,EAAG;AAClD,IAAA,OAAO,UAAA,CAAW,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,UAAA;AACT;;;;"}
|
|
@@ -6,13 +6,13 @@ import '../frontend-internal/src/wiring/InternalExtensionDefinition.esm.js';
|
|
|
6
6
|
import '../frontend-internal/src/wiring/InternalExtensionInput.esm.js';
|
|
7
7
|
import '../frontend-internal/src/wiring/InternalSwappableComponentRef.esm.js';
|
|
8
8
|
|
|
9
|
-
function registerFeatureFlagDeclarationsInHolder(apis, features) {
|
|
9
|
+
function registerFeatureFlagDeclarationsInHolder(apis, features, collector) {
|
|
10
10
|
const featureFlagApi = apis.get(featureFlagsApiRef);
|
|
11
11
|
if (featureFlagApi) {
|
|
12
|
-
registerFeatureFlagDeclarations(featureFlagApi, features);
|
|
12
|
+
registerFeatureFlagDeclarations(featureFlagApi, features, collector);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function wrapFeatureFlagApiFactory(factory, features) {
|
|
15
|
+
function wrapFeatureFlagApiFactory(factory, features, collector) {
|
|
16
16
|
if (factory.api.id !== featureFlagsApiRef.id) {
|
|
17
17
|
return factory;
|
|
18
18
|
}
|
|
@@ -22,7 +22,7 @@ function wrapFeatureFlagApiFactory(factory, features) {
|
|
|
22
22
|
const featureFlagApi = factory.factory(
|
|
23
23
|
deps
|
|
24
24
|
);
|
|
25
|
-
registerFeatureFlagDeclarations(featureFlagApi, features);
|
|
25
|
+
registerFeatureFlagDeclarations(featureFlagApi, features, collector);
|
|
26
26
|
return featureFlagApi;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
@@ -61,7 +61,11 @@ function syncFinalApiFactories(options) {
|
|
|
61
61
|
return true;
|
|
62
62
|
});
|
|
63
63
|
const changedFactories = changedEntries.map(
|
|
64
|
-
(entry) => wrapFeatureFlagApiFactory(
|
|
64
|
+
(entry) => wrapFeatureFlagApiFactory(
|
|
65
|
+
entry.factory,
|
|
66
|
+
options.features,
|
|
67
|
+
options.collector
|
|
68
|
+
)
|
|
65
69
|
);
|
|
66
70
|
options.appApiRegistry.setAll(changedFactories);
|
|
67
71
|
options.apiResolver.invalidate(
|
|
@@ -86,25 +90,36 @@ const EMPTY_API_HOLDER = {
|
|
|
86
90
|
return void 0;
|
|
87
91
|
}
|
|
88
92
|
};
|
|
89
|
-
function registerFeatureFlagDeclarations(featureFlagApi, features) {
|
|
93
|
+
function registerFeatureFlagDeclarations(featureFlagApi, features, collector) {
|
|
90
94
|
for (const feature of features) {
|
|
95
|
+
let pluginId;
|
|
96
|
+
let flags;
|
|
97
|
+
let source;
|
|
91
98
|
if (OpaqueFrontendPlugin.isType(feature)) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
pluginId = feature.id;
|
|
100
|
+
flags = OpaqueFrontendPlugin.toInternal(feature).featureFlags;
|
|
101
|
+
source = "Plugin";
|
|
102
|
+
} else if (isInternalFrontendModule(feature)) {
|
|
103
|
+
pluginId = feature.pluginId;
|
|
104
|
+
flags = toInternalFrontendModule(feature).featureFlags;
|
|
105
|
+
source = "Module for plugin";
|
|
99
106
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
if (pluginId && flags && source) {
|
|
108
|
+
for (const flag of flags) {
|
|
109
|
+
try {
|
|
110
|
+
featureFlagApi.registerFlag({
|
|
111
|
+
name: flag.name,
|
|
112
|
+
description: flag.description,
|
|
113
|
+
pluginId
|
|
114
|
+
});
|
|
115
|
+
} catch (error) {
|
|
116
|
+
collector.report({
|
|
117
|
+
code: "FEATURE_FLAG_INVALID",
|
|
118
|
+
message: `${source} '${pluginId}' declared invalid feature flag '${flag.name}': ${error}`,
|
|
119
|
+
context: { pluginId, flagName: flag.name, error }
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
108
123
|
}
|
|
109
124
|
}
|
|
110
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiFactories.esm.js","sources":["../../src/wiring/apiFactories.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n AnyApiFactory,\n ApiHolder,\n AppNode,\n FrontendFeature,\n featureFlagsApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { OpaqueFrontendPlugin } from '@internal/frontend';\nimport { instantiateAppNodeSubtree } from '../tree/instantiateAppNodeTree';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isInternalFrontendModule,\n toInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\nimport { ErrorCollector } from './createErrorCollector';\nimport {\n FrontendApiRegistry,\n FrontendApiResolver,\n} from './FrontendApiRegistry';\nimport { type ExtensionPredicateContext } from './predicates';\n\nexport type ApiFactoryEntry = {\n node: AppNode;\n pluginId: string;\n factory: AnyApiFactory;\n};\n\n/**\n * Registers feature flag declarations on an already prepared API holder.\n *\n * This is primarily used when bootstrap reuses APIs from a provided session\n * state rather than building a fresh registry from bootstrap-visible factories.\n */\nexport function registerFeatureFlagDeclarationsInHolder(\n apis: ApiHolder,\n features: FrontendFeature[],\n) {\n const featureFlagApi = apis.get(featureFlagsApiRef);\n if (featureFlagApi) {\n registerFeatureFlagDeclarations(featureFlagApi, features);\n }\n}\n\n/**\n * Decorates the feature flags API factory so plugin and module declarations are\n * registered whenever that API is instantiated.\n */\nexport function wrapFeatureFlagApiFactory(\n factory: AnyApiFactory,\n features: FrontendFeature[],\n) {\n if (factory.api.id !== featureFlagsApiRef.id) {\n return factory;\n }\n\n return {\n ...factory,\n factory(deps) {\n const featureFlagApi = factory.factory(\n deps,\n ) as typeof featureFlagsApiRef.T;\n registerFeatureFlagDeclarations(featureFlagApi, features);\n return featureFlagApi;\n },\n } as AnyApiFactory;\n}\n\n/**\n * Reconciles deferred API factories into the finalized API registry.\n *\n * It preserves bootstrap-frozen APIs, allows safe deferred additions, and\n * reports cases where bootstrap-visible extensions relied on APIs that only\n * became available during finalization.\n */\nexport function syncFinalApiFactories(options: {\n deferredApiNodes: Iterable<AppNode>;\n appApiRegistry: FrontendApiRegistry;\n apiResolver: FrontendApiResolver;\n collector: ErrorCollector;\n features: FrontendFeature[];\n bootstrapApiFactoryEntries: ReadonlyMap<string, ApiFactoryEntry>;\n bootstrapMissingApiAccesses: Map<string, { node: AppNode; apiRefId: string }>;\n predicateContext: ExtensionPredicateContext;\n}) {\n const finalApiEntries = collectApiFactoryEntries({\n apiNodes: options.deferredApiNodes,\n collector: options.collector,\n predicateContext: options.predicateContext,\n entries: new Map(options.bootstrapApiFactoryEntries),\n });\n // Only newly introduced or still-safe overrides are registered here. Any\n // bootstrap-materialized API remains frozen for the lifetime of the app.\n const changedEntries = Array.from(finalApiEntries.values()).filter(entry => {\n const bootstrapEntry = options.bootstrapApiFactoryEntries.get(\n entry.factory.api.id,\n );\n if (!bootstrapEntry) {\n return true;\n }\n if (bootstrapEntry.factory === entry.factory) {\n return false;\n }\n if (options.apiResolver.isMaterialized(entry.factory.api.id)) {\n options.collector.report({\n code: 'EXTENSION_BOOTSTRAP_API_OVERRIDE_IGNORED',\n message:\n `Extension '${entry.node.spec.id}' tried to override API ` +\n `'${entry.factory.api.id}' after it had already been materialized during bootstrap. ` +\n 'The bootstrap implementation was kept and the deferred override was ignored.',\n context: {\n node: entry.node,\n apiRefId: entry.factory.api.id,\n bootstrapNode: bootstrapEntry.node,\n pluginId: entry.pluginId,\n bootstrapPluginId: bootstrapEntry.pluginId,\n },\n });\n return false;\n }\n return true;\n });\n const changedFactories = changedEntries.map(entry =>\n wrapFeatureFlagApiFactory(entry.factory, options.features),\n );\n options.appApiRegistry.setAll(changedFactories);\n options.apiResolver.invalidate(\n changedFactories.map(factory => factory.api.id),\n );\n for (const bootstrapAccess of options.bootstrapMissingApiAccesses.values()) {\n if (\n options.bootstrapApiFactoryEntries.has(bootstrapAccess.apiRefId) ||\n !finalApiEntries.has(bootstrapAccess.apiRefId)\n ) {\n continue;\n }\n\n options.collector.report({\n code: 'EXTENSION_BOOTSTRAP_API_UNAVAILABLE',\n message:\n `Extension '${bootstrapAccess.node.spec.id}' tried to access API ` +\n `'${bootstrapAccess.apiRefId}' during bootstrap before it was available. ` +\n 'That API became available during finalization, so bootstrap-visible extensions must not depend on deferred APIs.',\n context: {\n node: bootstrapAccess.node,\n apiRefId: bootstrapAccess.apiRefId,\n },\n });\n }\n}\n\nconst EMPTY_API_HOLDER: ApiHolder = {\n get() {\n return undefined;\n },\n};\n\nfunction registerFeatureFlagDeclarations(\n featureFlagApi: typeof featureFlagsApiRef.T,\n features: FrontendFeature[],\n) {\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 description: flag.description,\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 description: flag.description,\n pluginId: feature.pluginId,\n }),\n );\n }\n }\n}\n\n/**\n * Instantiates API extension subtrees in isolation and extracts the factories\n * they provide without mutating the live app tree.\n *\n * The collected entries are later used both for bootstrap registration and for\n * the finalization-time reconciliation of deferred API roots.\n */\nexport function collectApiFactoryEntries(options: {\n apiNodes: Iterable<AppNode>;\n collector: ErrorCollector;\n predicateContext?: ExtensionPredicateContext;\n entries?: Map<string, ApiFactoryEntry>;\n}): Map<string, ApiFactoryEntry> {\n const factoriesById = options.entries ?? new Map<string, ApiFactoryEntry>();\n for (const apiNode of options.apiNodes) {\n // API extensions are instantiated in isolation so we can inspect the\n // produced factories without mutating the live app tree.\n const detachedApiNode = instantiateAppNodeSubtree({\n rootNode: apiNode,\n apis: EMPTY_API_HOLDER,\n collector: options.collector,\n predicateContext: options.predicateContext,\n writeNodeInstances: false,\n reuseExistingInstances: false,\n });\n if (!detachedApiNode) {\n continue;\n }\n const apiFactory = detachedApiNode.instance?.getData(\n ApiBlueprint.dataRefs.factory,\n );\n if (apiFactory) {\n const apiRefId = apiFactory.api.id;\n const ownerId = getApiOwnerId(apiRefId);\n const pluginId = apiNode.spec.plugin.pluginId ?? 'app';\n const existingFactory = factoriesById.get(apiRefId);\n\n // This allows modules to override factories provided by the plugin, but\n // it rejects API overrides from other plugins. In the event of a\n // conflict, the owning plugin is attempted to be inferred from the API\n // reference ID.\n if (existingFactory && existingFactory.pluginId !== pluginId) {\n const shouldReplace =\n ownerId === pluginId && existingFactory.pluginId !== ownerId;\n const acceptedPluginId = shouldReplace\n ? pluginId\n : existingFactory.pluginId;\n const rejectedPluginId = shouldReplace\n ? existingFactory.pluginId\n : pluginId;\n\n options.collector.report({\n code: 'API_FACTORY_CONFLICT',\n message: `API '${apiRefId}' is already provided by plugin '${acceptedPluginId}', cannot also be provided by '${rejectedPluginId}'.`,\n context: {\n node: apiNode,\n apiRefId,\n pluginId: rejectedPluginId,\n existingPluginId: acceptedPluginId,\n },\n });\n if (shouldReplace) {\n factoriesById.set(apiRefId, {\n pluginId,\n node: apiNode,\n factory: apiFactory,\n });\n }\n continue;\n }\n\n factoriesById.set(apiRefId, {\n pluginId,\n node: apiNode,\n factory: apiFactory,\n });\n } else {\n options.collector.report({\n code: 'API_EXTENSION_INVALID',\n message: `API extension '${apiNode.spec.id}' did not output an API factory`,\n context: {\n node: apiNode,\n },\n });\n }\n }\n\n return factoriesById;\n}\n\n// TODO(Rugvip): It would be good if this was more explicit, but I think that\n// might need to wait for some future update for API factories.\nfunction getApiOwnerId(apiRefId: string): string {\n const [prefix, ...rest] = apiRefId.split('.');\n if (!prefix) {\n return apiRefId;\n }\n if (prefix === 'core') {\n return 'app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;AACA,EAAA,IAAI,MAAA,KAAW,QAAA,IAAY,IAAA,CAAK,CAAC,CAAA,EAAG;AAClC,IAAA,OAAO,KAAK,CAAC,CAAA;AAAA,EACf;AACA,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"apiFactories.esm.js","sources":["../../src/wiring/apiFactories.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n AnyApiFactory,\n ApiHolder,\n AppNode,\n FrontendFeature,\n featureFlagsApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { OpaqueFrontendPlugin } from '@internal/frontend';\nimport { instantiateAppNodeSubtree } from '../tree/instantiateAppNodeTree';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isInternalFrontendModule,\n toInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\nimport { ErrorCollector } from './createErrorCollector';\nimport {\n FrontendApiRegistry,\n FrontendApiResolver,\n} from './FrontendApiRegistry';\nimport { type ExtensionPredicateContext } from './predicates';\n\nexport type ApiFactoryEntry = {\n node: AppNode;\n pluginId: string;\n factory: AnyApiFactory;\n};\n\n/**\n * Registers feature flag declarations on an already prepared API holder.\n *\n * This is primarily used when bootstrap reuses APIs from a provided session\n * state rather than building a fresh registry from bootstrap-visible factories.\n */\nexport function registerFeatureFlagDeclarationsInHolder(\n apis: ApiHolder,\n features: FrontendFeature[],\n collector: ErrorCollector,\n) {\n const featureFlagApi = apis.get(featureFlagsApiRef);\n if (featureFlagApi) {\n registerFeatureFlagDeclarations(featureFlagApi, features, collector);\n }\n}\n\n/**\n * Decorates the feature flags API factory so plugin and module declarations are\n * registered whenever that API is instantiated.\n */\nexport function wrapFeatureFlagApiFactory(\n factory: AnyApiFactory,\n features: FrontendFeature[],\n collector: ErrorCollector,\n) {\n if (factory.api.id !== featureFlagsApiRef.id) {\n return factory;\n }\n\n return {\n ...factory,\n factory(deps) {\n const featureFlagApi = factory.factory(\n deps,\n ) as typeof featureFlagsApiRef.T;\n registerFeatureFlagDeclarations(featureFlagApi, features, collector);\n return featureFlagApi;\n },\n } as AnyApiFactory;\n}\n\n/**\n * Reconciles deferred API factories into the finalized API registry.\n *\n * It preserves bootstrap-frozen APIs, allows safe deferred additions, and\n * reports cases where bootstrap-visible extensions relied on APIs that only\n * became available during finalization.\n */\nexport function syncFinalApiFactories(options: {\n deferredApiNodes: Iterable<AppNode>;\n appApiRegistry: FrontendApiRegistry;\n apiResolver: FrontendApiResolver;\n collector: ErrorCollector;\n features: FrontendFeature[];\n bootstrapApiFactoryEntries: ReadonlyMap<string, ApiFactoryEntry>;\n bootstrapMissingApiAccesses: Map<string, { node: AppNode; apiRefId: string }>;\n predicateContext: ExtensionPredicateContext;\n}) {\n const finalApiEntries = collectApiFactoryEntries({\n apiNodes: options.deferredApiNodes,\n collector: options.collector,\n predicateContext: options.predicateContext,\n entries: new Map(options.bootstrapApiFactoryEntries),\n });\n // Only newly introduced or still-safe overrides are registered here. Any\n // bootstrap-materialized API remains frozen for the lifetime of the app.\n const changedEntries = Array.from(finalApiEntries.values()).filter(entry => {\n const bootstrapEntry = options.bootstrapApiFactoryEntries.get(\n entry.factory.api.id,\n );\n if (!bootstrapEntry) {\n return true;\n }\n if (bootstrapEntry.factory === entry.factory) {\n return false;\n }\n if (options.apiResolver.isMaterialized(entry.factory.api.id)) {\n options.collector.report({\n code: 'EXTENSION_BOOTSTRAP_API_OVERRIDE_IGNORED',\n message:\n `Extension '${entry.node.spec.id}' tried to override API ` +\n `'${entry.factory.api.id}' after it had already been materialized during bootstrap. ` +\n 'The bootstrap implementation was kept and the deferred override was ignored.',\n context: {\n node: entry.node,\n apiRefId: entry.factory.api.id,\n bootstrapNode: bootstrapEntry.node,\n pluginId: entry.pluginId,\n bootstrapPluginId: bootstrapEntry.pluginId,\n },\n });\n return false;\n }\n return true;\n });\n const changedFactories = changedEntries.map(entry =>\n wrapFeatureFlagApiFactory(\n entry.factory,\n options.features,\n options.collector,\n ),\n );\n options.appApiRegistry.setAll(changedFactories);\n options.apiResolver.invalidate(\n changedFactories.map(factory => factory.api.id),\n );\n for (const bootstrapAccess of options.bootstrapMissingApiAccesses.values()) {\n if (\n options.bootstrapApiFactoryEntries.has(bootstrapAccess.apiRefId) ||\n !finalApiEntries.has(bootstrapAccess.apiRefId)\n ) {\n continue;\n }\n\n options.collector.report({\n code: 'EXTENSION_BOOTSTRAP_API_UNAVAILABLE',\n message:\n `Extension '${bootstrapAccess.node.spec.id}' tried to access API ` +\n `'${bootstrapAccess.apiRefId}' during bootstrap before it was available. ` +\n 'That API became available during finalization, so bootstrap-visible extensions must not depend on deferred APIs.',\n context: {\n node: bootstrapAccess.node,\n apiRefId: bootstrapAccess.apiRefId,\n },\n });\n }\n}\n\nconst EMPTY_API_HOLDER: ApiHolder = {\n get() {\n return undefined;\n },\n};\n\nfunction registerFeatureFlagDeclarations(\n featureFlagApi: typeof featureFlagsApiRef.T,\n features: FrontendFeature[],\n collector: ErrorCollector,\n) {\n for (const feature of features) {\n let pluginId: string | undefined;\n let flags: Array<{ name: string; description?: string }> | undefined;\n let source: string | undefined;\n\n if (OpaqueFrontendPlugin.isType(feature)) {\n pluginId = feature.id;\n flags = OpaqueFrontendPlugin.toInternal(feature).featureFlags;\n source = 'Plugin';\n } else if (isInternalFrontendModule(feature)) {\n pluginId = feature.pluginId;\n flags = toInternalFrontendModule(feature).featureFlags;\n source = 'Module for plugin';\n }\n\n if (pluginId && flags && source) {\n for (const flag of flags) {\n try {\n featureFlagApi.registerFlag({\n name: flag.name,\n description: flag.description,\n pluginId,\n });\n } catch (error) {\n collector.report({\n code: 'FEATURE_FLAG_INVALID',\n message: `${source} '${pluginId}' declared invalid feature flag '${flag.name}': ${error}`,\n context: { pluginId, flagName: flag.name, error: error as Error },\n });\n }\n }\n }\n }\n}\n\n/**\n * Instantiates API extension subtrees in isolation and extracts the factories\n * they provide without mutating the live app tree.\n *\n * The collected entries are later used both for bootstrap registration and for\n * the finalization-time reconciliation of deferred API roots.\n */\nexport function collectApiFactoryEntries(options: {\n apiNodes: Iterable<AppNode>;\n collector: ErrorCollector;\n predicateContext?: ExtensionPredicateContext;\n entries?: Map<string, ApiFactoryEntry>;\n}): Map<string, ApiFactoryEntry> {\n const factoriesById = options.entries ?? new Map<string, ApiFactoryEntry>();\n for (const apiNode of options.apiNodes) {\n // API extensions are instantiated in isolation so we can inspect the\n // produced factories without mutating the live app tree.\n const detachedApiNode = instantiateAppNodeSubtree({\n rootNode: apiNode,\n apis: EMPTY_API_HOLDER,\n collector: options.collector,\n predicateContext: options.predicateContext,\n writeNodeInstances: false,\n reuseExistingInstances: false,\n });\n if (!detachedApiNode) {\n continue;\n }\n const apiFactory = detachedApiNode.instance?.getData(\n ApiBlueprint.dataRefs.factory,\n );\n if (apiFactory) {\n const apiRefId = apiFactory.api.id;\n const ownerId = getApiOwnerId(apiRefId);\n const pluginId = apiNode.spec.plugin.pluginId ?? 'app';\n const existingFactory = factoriesById.get(apiRefId);\n\n // This allows modules to override factories provided by the plugin, but\n // it rejects API overrides from other plugins. In the event of a\n // conflict, the owning plugin is attempted to be inferred from the API\n // reference ID.\n if (existingFactory && existingFactory.pluginId !== pluginId) {\n const shouldReplace =\n ownerId === pluginId && existingFactory.pluginId !== ownerId;\n const acceptedPluginId = shouldReplace\n ? pluginId\n : existingFactory.pluginId;\n const rejectedPluginId = shouldReplace\n ? existingFactory.pluginId\n : pluginId;\n\n options.collector.report({\n code: 'API_FACTORY_CONFLICT',\n message: `API '${apiRefId}' is already provided by plugin '${acceptedPluginId}', cannot also be provided by '${rejectedPluginId}'.`,\n context: {\n node: apiNode,\n apiRefId,\n pluginId: rejectedPluginId,\n existingPluginId: acceptedPluginId,\n },\n });\n if (shouldReplace) {\n factoriesById.set(apiRefId, {\n pluginId,\n node: apiNode,\n factory: apiFactory,\n });\n }\n continue;\n }\n\n factoriesById.set(apiRefId, {\n pluginId,\n node: apiNode,\n factory: apiFactory,\n });\n } else {\n options.collector.report({\n code: 'API_EXTENSION_INVALID',\n message: `API extension '${apiNode.spec.id}' did not output an API factory`,\n context: {\n node: apiNode,\n },\n });\n }\n }\n\n return factoriesById;\n}\n\n// TODO(Rugvip): It would be good if this was more explicit, but I think that\n// might need to wait for some future update for API factories.\nfunction getApiOwnerId(apiRefId: string): string {\n const [prefix, ...rest] = apiRefId.split('.');\n if (!prefix) {\n return apiRefId;\n }\n if (prefix === 'core') {\n return 'app';\n }\n if (prefix === 'plugin' && rest[0]) {\n return rest[0];\n }\n return prefix;\n}\n"],"names":[],"mappings":";;;;;;;;AAkDO,SAAS,uCAAA,CACd,IAAA,EACA,QAAA,EACA,SAAA,EACA;AACA,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,GAAA,CAAI,kBAAkB,CAAA;AAClD,EAAA,IAAI,cAAA,EAAgB;AAClB,IAAA,+BAAA,CAAgC,cAAA,EAAgB,UAAU,SAAS,CAAA;AAAA,EACrE;AACF;AAMO,SAAS,yBAAA,CACd,OAAA,EACA,QAAA,EACA,SAAA,EACA;AACA,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,EAAA,KAAO,kBAAA,CAAmB,EAAA,EAAI;AAC5C,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,OAAA;AAAA,IACH,QAAQ,IAAA,EAAM;AACZ,MAAA,MAAM,iBAAiB,OAAA,CAAQ,OAAA;AAAA,QAC7B;AAAA,OACF;AACA,MAAA,+BAAA,CAAgC,cAAA,EAAgB,UAAU,SAAS,CAAA;AACnE,M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AA;AAAA,EACf;AACA,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createErrorCollector.esm.js","sources":["../../src/wiring/createErrorCollector.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 { AppNode, FrontendPlugin } from '@backstage/frontend-plugin-api';\n\n/**\n * @public\n */\nexport type AppErrorTypes = {\n // resolveAppNodeSpecs\n EXTENSION_IGNORED: {\n context: { plugin: FrontendPlugin; extensionId: string };\n };\n INVALID_EXTENSION_CONFIG_KEY: {\n context: { extensionId: string };\n };\n // resolveAppTree\n EXTENSION_INPUT_REDIRECT_CONFLICT: {\n context: { node: AppNode; inputName: string };\n };\n // instantiateAppNodeTree\n EXTENSION_INPUT_DATA_IGNORED: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_INPUT_DATA_MISSING: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_INPUT_INTERNAL_IGNORED: {\n context: {\n node: AppNode;\n inputName: string;\n extensionId: string;\n plugin: FrontendPlugin;\n };\n };\n EXTENSION_ATTACHMENT_CONFLICT: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_ATTACHMENT_MISSING: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_CONFIGURATION_INVALID: {\n context: { node: AppNode };\n };\n EXTENSION_INVALID: {\n context: { node: AppNode };\n };\n EXTENSION_OUTPUT_CONFLICT: {\n context: { node: AppNode; dataRefId: string };\n };\n EXTENSION_OUTPUT_MISSING: {\n context: { node: AppNode; dataRefId: string };\n };\n EXTENSION_OUTPUT_IGNORED: {\n context: { node: AppNode; dataRefId: string };\n };\n EXTENSION_FACTORY_ERROR: {\n context: { node: AppNode };\n };\n // createSpecializedApp\n API_EXTENSION_INVALID: {\n context: { node: AppNode };\n };\n API_FACTORY_CONFLICT: {\n context: {\n node: AppNode;\n apiRefId: string;\n pluginId: string;\n existingPluginId: string;\n };\n };\n EXTENSION_BOOTSTRAP_PREDICATE_IGNORED: {\n context: { node: AppNode };\n };\n EXTENSION_BOOTSTRAP_API_UNAVAILABLE: {\n context: { node: AppNode; apiRefId: string };\n };\n EXTENSION_BOOTSTRAP_API_OVERRIDE_IGNORED: {\n context: {\n node: AppNode;\n apiRefId: string;\n bootstrapNode: AppNode;\n pluginId: string;\n bootstrapPluginId: string;\n };\n };\n // routing\n ROUTE_DUPLICATE: {\n context: { routeId: string };\n };\n ROUTE_BINDING_INVALID_VALUE: {\n context: { routeId: string };\n };\n ROUTE_NOT_FOUND: {\n context: { routeId: string };\n };\n};\n\n/**\n * @public\n */\nexport type AppError =\n keyof AppErrorTypes extends infer ICode extends keyof AppErrorTypes\n ? ICode extends any\n ? {\n code: ICode;\n message: string;\n context: AppErrorTypes[ICode]['context'];\n }\n : never\n : never;\n\n/** @internal */\nexport interface ErrorCollector<TContext extends {} = {}> {\n report<TCode extends keyof AppErrorTypes>(\n report: Omit<\n AppErrorTypes[TCode]['context'],\n keyof TContext\n > extends infer IContext extends {}\n ? {} extends IContext\n ? {\n code: TCode;\n message: string;\n }\n : {\n code: TCode;\n message: string;\n context: IContext;\n }\n : never,\n ): void;\n child<TAdditionalContext extends {}>(\n context: TAdditionalContext,\n ): ErrorCollector<TContext & TAdditionalContext>;\n collectErrors(): AppError[] | undefined;\n}\n\n/** @internal */\nexport function createErrorCollector(\n context?: Partial<AppError['context']>,\n): ErrorCollector {\n const errors: AppError[] = [];\n const children: ErrorCollector[] = [];\n return {\n report(report: { code: string; message: string; context?: {} }) {\n errors.push({\n ...report,\n context: { ...context, ...report.context },\n } as AppError);\n },\n collectErrors() {\n const allErrors = [\n ...errors,\n ...children.flatMap(child => child.collectErrors() ?? []),\n ];\n errors.length = 0;\n if (allErrors.length === 0) {\n return undefined;\n }\n return allErrors;\n },\n child(childContext) {\n const child = createErrorCollector({ ...context, ...childContext });\n children.push(child);\n return child as ErrorCollector<any>;\n },\n };\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createErrorCollector.esm.js","sources":["../../src/wiring/createErrorCollector.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 { AppNode, FrontendPlugin } from '@backstage/frontend-plugin-api';\n\n/**\n * @public\n */\nexport type AppErrorTypes = {\n // resolveAppNodeSpecs\n EXTENSION_IGNORED: {\n context: { plugin: FrontendPlugin; extensionId: string };\n };\n INVALID_EXTENSION_CONFIG_KEY: {\n context: { extensionId: string };\n };\n // resolveAppTree\n EXTENSION_INPUT_REDIRECT_CONFLICT: {\n context: { node: AppNode; inputName: string };\n };\n // instantiateAppNodeTree\n EXTENSION_INPUT_DATA_IGNORED: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_INPUT_DATA_MISSING: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_INPUT_INTERNAL_IGNORED: {\n context: {\n node: AppNode;\n inputName: string;\n extensionId: string;\n plugin: FrontendPlugin;\n };\n };\n EXTENSION_ATTACHMENT_CONFLICT: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_ATTACHMENT_MISSING: {\n context: { node: AppNode; inputName: string };\n };\n EXTENSION_CONFIGURATION_INVALID: {\n context: { node: AppNode };\n };\n EXTENSION_INVALID: {\n context: { node: AppNode };\n };\n EXTENSION_OUTPUT_CONFLICT: {\n context: { node: AppNode; dataRefId: string };\n };\n EXTENSION_OUTPUT_MISSING: {\n context: { node: AppNode; dataRefId: string };\n };\n EXTENSION_OUTPUT_IGNORED: {\n context: { node: AppNode; dataRefId: string };\n };\n EXTENSION_FACTORY_ERROR: {\n context: { node: AppNode };\n };\n // createSpecializedApp\n API_EXTENSION_INVALID: {\n context: { node: AppNode };\n };\n API_FACTORY_CONFLICT: {\n context: {\n node: AppNode;\n apiRefId: string;\n pluginId: string;\n existingPluginId: string;\n };\n };\n EXTENSION_BOOTSTRAP_PREDICATE_IGNORED: {\n context: { node: AppNode };\n };\n EXTENSION_BOOTSTRAP_API_UNAVAILABLE: {\n context: { node: AppNode; apiRefId: string };\n };\n EXTENSION_BOOTSTRAP_API_OVERRIDE_IGNORED: {\n context: {\n node: AppNode;\n apiRefId: string;\n bootstrapNode: AppNode;\n pluginId: string;\n bootstrapPluginId: string;\n };\n };\n FEATURE_FLAG_INVALID: {\n context: { pluginId: string; flagName: string; error: Error };\n };\n // routing\n ROUTE_DUPLICATE: {\n context: { routeId: string };\n };\n ROUTE_BINDING_INVALID_VALUE: {\n context: { routeId: string };\n };\n ROUTE_NOT_FOUND: {\n context: { routeId: string };\n };\n};\n\n/**\n * @public\n */\nexport type AppError =\n keyof AppErrorTypes extends infer ICode extends keyof AppErrorTypes\n ? ICode extends any\n ? {\n code: ICode;\n message: string;\n context: AppErrorTypes[ICode]['context'];\n }\n : never\n : never;\n\n/** @internal */\nexport interface ErrorCollector<TContext extends {} = {}> {\n report<TCode extends keyof AppErrorTypes>(\n report: Omit<\n AppErrorTypes[TCode]['context'],\n keyof TContext\n > extends infer IContext extends {}\n ? {} extends IContext\n ? {\n code: TCode;\n message: string;\n }\n : {\n code: TCode;\n message: string;\n context: IContext;\n }\n : never,\n ): void;\n child<TAdditionalContext extends {}>(\n context: TAdditionalContext,\n ): ErrorCollector<TContext & TAdditionalContext>;\n collectErrors(): AppError[] | undefined;\n}\n\n/** @internal */\nexport function createErrorCollector(\n context?: Partial<AppError['context']>,\n): ErrorCollector {\n const errors: AppError[] = [];\n const children: ErrorCollector[] = [];\n return {\n report(report: { code: string; message: string; context?: {} }) {\n errors.push({\n ...report,\n context: { ...context, ...report.context },\n } as AppError);\n },\n collectErrors() {\n const allErrors = [\n ...errors,\n ...children.flatMap(child => child.collectErrors() ?? []),\n ];\n errors.length = 0;\n if (allErrors.length === 0) {\n return undefined;\n }\n return allErrors;\n },\n child(childContext) {\n const child = createErrorCollector({ ...context, ...childContext });\n children.push(child);\n return child as ErrorCollector<any>;\n },\n };\n}\n"],"names":[],"mappings":"AA0JO,SAAS,qBACd,OAAA,EACgB;AAChB,EAAA,MAAM,SAAqB,EAAC;AAC5B,EAAA,MAAM,WAA6B,EAAC;AACpC,EAAA,OAAO;AAAA,IACL,OAAO,MAAA,EAAyD;AAC9D,MAAA,MAAA,CAAO,IAAA,CAAK;AAAA,QACV,GAAG,MAAA;AAAA,QACH,SAAS,EAAE,GAAG,OAAA,EAAS,GAAG,OAAO,OAAA;AAAQ,OAC9B,CAAA;AAAA,IACf,CAAA;AAAA,IACA,aAAA,GAAgB;AACd,MAAA,MAAM,SAAA,GAAY;AAAA,QAChB,GAAG,MAAA;AAAA,QACH,GAAG,SAAS,OAAA,CAAQ,CAAA,KAAA,KAAS,MAAM,aAAA,EAAc,IAAK,EAAE;AAAA,OAC1D;AACA,MAAA,MAAA,CAAO,MAAA,GAAS,CAAA;AAChB,MAAA,IAAI,SAAA,CAAU,WAAW,CAAA,EAAG;AAC1B,QAAA,OAAO,MAAA;AAAA,MACT;AACA,MAAA,OAAO,SAAA;AAAA,IACT,CAAA;AAAA,IACA,MAAM,YAAA,EAAc;AAClB,MAAA,MAAM,QAAQ,oBAAA,CAAqB,EAAE,GAAG,OAAA,EAAS,GAAG,cAAc,CAAA;AAClE,MAAA,QAAA,CAAS,KAAK,KAAK,CAAA;AACnB,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACF;AACF;;;;"}
|
|
@@ -94,7 +94,7 @@ function prepareSpecializedApp(options) {
|
|
|
94
94
|
const bootstrapApiFactoryEntries = /* @__PURE__ */ new Map();
|
|
95
95
|
const bootstrapMissingApiAccesses = /* @__PURE__ */ new Map();
|
|
96
96
|
if (providedApis) {
|
|
97
|
-
registerFeatureFlagDeclarationsInHolder(providedApis, features);
|
|
97
|
+
registerFeatureFlagDeclarationsInHolder(providedApis, features, collector);
|
|
98
98
|
} else {
|
|
99
99
|
collectApiFactoryEntries({
|
|
100
100
|
apiNodes: (tree.root.edges.attachments.get("apis") ?? []).filter(
|
|
@@ -105,7 +105,7 @@ function prepareSpecializedApp(options) {
|
|
|
105
105
|
});
|
|
106
106
|
const apiFactories = Array.from(
|
|
107
107
|
bootstrapApiFactoryEntries.values(),
|
|
108
|
-
(entry) => wrapFeatureFlagApiFactory(entry.factory, features)
|
|
108
|
+
(entry) => wrapFeatureFlagApiFactory(entry.factory, features, collector)
|
|
109
109
|
);
|
|
110
110
|
appApiRegistry.registerAll(apiFactories);
|
|
111
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareSpecializedApp.esm.js","sources":["../../src/wiring/prepareSpecializedApp.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 { isError } from '@backstage/errors';\nimport {\n AnyApiFactory,\n ApiHolder,\n AppTree,\n ConfigApi,\n coreExtensionData,\n AppNode,\n ExtensionFactoryMiddleware,\n FrontendFeature,\n IdentityApi,\n identityApiRef,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\nimport {\n createExtensionDataContainer,\n OpaqueFrontendPlugin,\n} from '@internal/frontend';\nimport { OpaqueType } from '@internal/opaque';\nimport { ComponentType, ReactNode } from 'react';\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 { CreateAppRouteBinder } from '../routing';\nimport { resolveRouteBindings } from '../routing/resolveRouteBindings';\nimport { collectRouteIds } from '../routing/collectRouteIds';\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 {\n createPluginInfoAttacher,\n FrontendPluginInfoResolver,\n} from './createPluginInfoAttacher';\nimport {\n AppError,\n createErrorCollector,\n ErrorCollector,\n} from './createErrorCollector';\nimport {\n createPhaseApis,\n instantiateAndInitializePhaseTree,\n setIdentityApiTarget,\n} from './phaseApis';\nimport {\n collectPredicateReferences,\n createPredicateContextLoader,\n EMPTY_PREDICATE_CONTEXT,\n type ExtensionPredicateContext,\n} from './predicates';\nimport { FrontendApiRegistry } from './FrontendApiRegistry';\nimport {\n ApiFactoryEntry,\n collectApiFactoryEntries,\n registerFeatureFlagDeclarationsInHolder,\n syncFinalApiFactories,\n wrapFeatureFlagApiFactory,\n} from './apiFactories';\nimport {\n attachThrowingFinalizationChild,\n BootstrapClassification,\n classifyBootstrapTree,\n clearFinalizationBoundaryInstances,\n createBootstrapApp,\n prepareFinalizedTree,\n} from './treeLifecycle';\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\ntype SignInPageProps = {\n onSignInSuccess(identityApi: IdentityApi): void;\n children?: ReactNode;\n};\n\n/**\n * Result of bootstrapping a prepared specialized app.\n *\n * @public\n */\nexport type BootstrapSpecializedApp = {\n apis: ApiHolder;\n element: JSX.Element;\n tree: AppTree;\n};\n\n/**\n * Result of finalizing a prepared specialized app.\n *\n * @public\n */\nexport type FinalizedSpecializedApp = {\n apis: ApiHolder;\n element: JSX.Element;\n sessionState: SpecializedAppSessionState;\n tree: AppTree;\n errors?: AppError[];\n};\n\ntype SignInRuntime = {\n readyIdentityApi?: IdentityApi;\n requiresSignIn: boolean;\n};\n\ntype FinalizationState = {\n started: boolean;\n promise: Promise<FinalizedSpecializedApp>;\n resolve(app: FinalizedSpecializedApp): void;\n reject(error: unknown): void;\n};\n\ntype FinalizationMode = 'onFinalized' | 'finalize';\n\ntype InternalSpecializedAppSessionState = {\n apis: ApiHolder;\n identityApi?: IdentityApi;\n predicateContext: ExtensionPredicateContext;\n};\n\n/**\n * Opaque reusable session state for specialized apps.\n *\n * @public\n */\nexport type SpecializedAppSessionState = {\n $$type: '@backstage/SpecializedAppSessionState';\n};\n\nconst OpaqueSpecializedAppSessionState = OpaqueType.create<{\n public: SpecializedAppSessionState;\n versions: InternalSpecializedAppSessionState & {\n version: 'v1';\n };\n}>({\n type: '@backstage/SpecializedAppSessionState',\n versions: ['v1'],\n});\n\nconst signInPageComponentDataRef = createExtensionDataRef<\n ComponentType<SignInPageProps>\n>().with({ id: 'core.sign-in-page.component' });\n\n/**\n * Options for {@link prepareSpecializedApp}.\n *\n * @public\n */\nexport type PrepareSpecializedAppOptions = {\n /**\n * The list of features to load.\n */\n features?: FrontendFeature[];\n\n /**\n * The config API implementation to use. For most normal apps, this should be\n * specified.\n *\n * If none is given, a new _empty_ config will be used during startup. In\n * later stages of the app lifecycle, the config API in the API holder will be\n * used.\n */\n config?: ConfigApi;\n\n /**\n * Allows for the binding of plugins' external route refs within the app.\n */\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n\n /**\n * Advanced, more rarely used options.\n */\n advanced?: {\n /**\n * A reusable specialized app session state to use.\n *\n * This can be obtained from either the app passed to\n * {@link PreparedSpecializedApp.onFinalized} or from\n * {@link PreparedSpecializedApp.finalize}, and reused in a future app\n * instance to skip sign-in and session preparation.\n */\n sessionState?: SpecializedAppSessionState;\n\n /**\n * Applies one or more middleware on every extension, as they are added to\n * the application.\n *\n * This is an advanced use case for modifying extension data on the fly as\n * it gets emitted by extensions being instantiated.\n */\n extensionFactoryMiddleware?:\n | ExtensionFactoryMiddleware\n | ExtensionFactoryMiddleware[];\n\n /**\n * Allows for customizing how plugin info is retrieved.\n */\n pluginInfoResolver?: FrontendPluginInfoResolver;\n };\n};\n\n/**\n * Result of {@link prepareSpecializedApp}.\n *\n * @public\n */\nexport type PreparedSpecializedApp = {\n getBootstrapApp(): BootstrapSpecializedApp;\n onFinalized(callback: (app: FinalizedSpecializedApp) => void): () => void;\n finalize(): FinalizedSpecializedApp;\n};\n\n// Internal options type, not exported in the public API\nexport interface CreateSpecializedAppInternalOptions\n extends PrepareSpecializedAppOptions {\n __internal?: {\n apiFactoryOverrides?: AnyApiFactory[];\n };\n}\n\nexport function createSessionStateFromApis(\n apis: ApiHolder,\n): SpecializedAppSessionState {\n return OpaqueSpecializedAppSessionState.createInstance('v1', {\n apis,\n identityApi: apis.get(identityApiRef),\n predicateContext: EMPTY_PREDICATE_CONTEXT,\n });\n}\n\n/**\n * Prepares an app without instantiating the full extension tree.\n *\n * @remarks\n *\n * This is useful for split sign-in flows where the sign-in page should be\n * rendered first, and the full app finalized once an identity has been\n * captured.\n *\n * @public\n */\nexport function prepareSpecializedApp(\n options?: PrepareSpecializedAppOptions,\n): PreparedSpecializedApp {\n const internalOptions = options as CreateSpecializedAppInternalOptions;\n const config = options?.config ?? new ConfigReader({}, 'empty-config');\n const features = deduplicateFeatures(options?.features ?? []).map(\n createPluginInfoAttacher(config, options?.advanced?.pluginInfoResolver),\n );\n\n const collector = createErrorCollector();\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 collector,\n }),\n collector,\n );\n\n const appBasePath = getBasePath(config);\n const routeRefsById = collectRouteIds(features, collector);\n const routeBindings = resolveRouteBindings(\n options?.bindRoutes,\n config,\n routeRefsById,\n collector,\n );\n\n const mergedExtensionFactoryMiddleware = mergeExtensionFactoryMiddleware(\n options?.advanced?.extensionFactoryMiddleware,\n );\n const providedSessionState = options?.advanced?.sessionState;\n const providedSessionData = providedSessionState\n ? OpaqueSpecializedAppSessionState.toInternal(providedSessionState)\n : undefined;\n const providedApis = providedSessionData?.apis;\n // Bootstrap only renders the parts of the tree that are known to be safe\n // before predicate context and sign-in have been resolved.\n const bootstrapClassification = classifyBootstrapTree({\n tree,\n collector,\n });\n const predicateReferences = collectPredicateReferences(tree.nodes.values());\n const appApiRegistry = new FrontendApiRegistry();\n const internalStaticFactories =\n internalOptions?.__internal?.apiFactoryOverrides ?? [];\n const phaseStaticFactories = [...internalStaticFactories];\n const bootstrapApiFactoryEntries = new Map<string, ApiFactoryEntry>();\n const bootstrapMissingApiAccesses = new Map<\n string,\n { node: AppNode; apiRefId: string }\n >();\n\n if (providedApis) {\n // Reused session state already carries a fully prepared API holder, so the\n // bootstrap path only needs to register feature flag declarations on top.\n registerFeatureFlagDeclarationsInHolder(providedApis, features);\n } else {\n // Bootstrap materializes only the immediately visible API factories. Any\n // predicate-gated API roots are revisited during finalization.\n collectApiFactoryEntries({\n apiNodes: (tree.root.edges.attachments.get('apis') ?? []).filter(\n apiNode => !bootstrapClassification.deferredApiRoots.has(apiNode),\n ),\n collector,\n entries: bootstrapApiFactoryEntries,\n });\n const apiFactories = Array.from(\n bootstrapApiFactoryEntries.values(),\n entry => wrapFeatureFlagApiFactory(entry.factory, features),\n );\n appApiRegistry.registerAll(apiFactories);\n }\n const phase = createPhaseApis({\n tree,\n config,\n appApiRegistry,\n fallbackApis: providedApis,\n includeConfigApi: !providedApis,\n appBasePath,\n routeBindings,\n staticFactories: phaseStaticFactories,\n });\n const predicateContextLoader = createPredicateContextLoader({\n apis: phase.apis,\n predicateReferences,\n });\n let signInRuntime: SignInRuntime | undefined;\n let finalized: FinalizedSpecializedApp | undefined;\n let bootstrapApp: BootstrapSpecializedApp | undefined;\n\n function updateIdentityApiTarget(identityApi?: IdentityApi) {\n if (!identityApi) {\n return;\n }\n\n setIdentityApiTarget({\n identityApiProxy: phase.identityApiProxy,\n identityApi,\n signOutTargetUrl: appBasePath || '/',\n });\n }\n\n function createSessionState(predicateContext: ExtensionPredicateContext) {\n const identityApi =\n signInRuntime?.readyIdentityApi ?? providedSessionData?.identityApi;\n // As soon as a real identity is available we swap the phase proxy over so\n // the finalized tree observes the same API instance.\n updateIdentityApiTarget(identityApi);\n const sessionState = OpaqueSpecializedAppSessionState.createInstance('v1', {\n apis: phase.apis,\n identityApi,\n predicateContext,\n });\n return sessionState;\n }\n\n function getSynchronousSessionState() {\n if (providedSessionState) {\n return providedSessionState;\n }\n // The direct finalize() path is intentionally synchronous. If sign-in is\n // still pending we refuse to guess and force the caller to wait.\n if (signInRuntime?.requiresSignIn) {\n return undefined;\n }\n\n const predicateContext = predicateContextLoader.getImmediate();\n if (!predicateContext) {\n return undefined;\n }\n\n return createSessionState(predicateContext);\n }\n\n function loadAsyncSessionState() {\n if (providedSessionState) {\n return Promise.resolve(providedSessionState);\n }\n if (signInRuntime?.requiresSignIn && !signInRuntime.readyIdentityApi) {\n return Promise.reject(\n new Error(\n 'prepareSpecializedApp requires waiting for the bootstrap app to be ready before calling finalize()',\n ),\n );\n }\n\n // For apps without sign-in we can sometimes finalize immediately from the\n // already available predicate context, skipping the async loader.\n if (!signInRuntime?.requiresSignIn) {\n const immediateSessionState = getSynchronousSessionState();\n if (immediateSessionState) {\n return Promise.resolve(immediateSessionState);\n }\n }\n\n return predicateContextLoader.load().then(createSessionState);\n }\n\n function finalizeWithSessionState(\n finalizedSessionState: SpecializedAppSessionState,\n ) {\n return finalizeFromSessionState({\n finalized,\n finalizedSessionState,\n tree,\n collector,\n phase,\n extensionFactoryMiddleware: mergedExtensionFactoryMiddleware,\n routeRefsById,\n appBasePath,\n providedApis,\n features,\n appApiRegistry,\n bootstrapClassification,\n bootstrapApiFactoryEntries,\n bootstrapMissingApiAccesses,\n });\n }\n\n function finalizeWithBootstrapError(\n error: Error,\n finalizedSessionState?: SpecializedAppSessionState,\n ) {\n return finalizeFromBootstrapError({\n finalized,\n error,\n finalizedSessionState,\n tree,\n collector,\n phase,\n extensionFactoryMiddleware: mergedExtensionFactoryMiddleware,\n routeRefsById,\n signInRuntime,\n providedSessionData,\n });\n }\n\n const finalization = createFinalizationController({\n getFinalized() {\n return finalized;\n },\n setFinalized(finalizedApp) {\n finalized = finalizedApp;\n },\n finalizeFromSessionState: finalizeWithSessionState,\n finalizeFromBootstrapError: finalizeWithBootstrapError,\n });\n\n function getBootstrapApp() {\n if (bootstrapApp) {\n return bootstrapApp;\n }\n\n const runtime: SignInRuntime = {\n requiresSignIn: false,\n };\n if (!providedSessionState) {\n phase.identityApiProxy.setTargetHandlers({\n onTargetSet(identityApi) {\n runtime.readyIdentityApi = identityApi;\n // Sign-in completion only auto-starts finalization for onFinalized().\n // The direct finalize() path stays explicit and synchronous.\n if (finalization.getMode() === 'onFinalized') {\n finalization.start(loadAsyncSessionState);\n }\n },\n });\n }\n\n const result = createBootstrapApp({\n tree,\n apis: phase.apis,\n collector,\n routeRefsById,\n routeResolutionApi: phase.routeResolutionApi,\n appTreeApi: phase.appTreeApi,\n extensionFactoryMiddleware: mergedExtensionFactoryMiddleware,\n disableSignIn: Boolean(providedSessionState),\n skipBootstrapChild({ child }) {\n return bootstrapClassification.deferredRoots.has(child);\n },\n onMissingApi({ node, apiRefId }) {\n bootstrapMissingApiAccesses.set(`${node.spec.id}:${apiRefId}`, {\n node,\n apiRefId,\n });\n },\n hasSignInPage(signInPageNode) {\n return Boolean(\n signInPageNode?.instance?.getData(signInPageComponentDataRef),\n );\n },\n });\n if (!result.requiresSignIn) {\n phase.identityApiProxy.clearTargetHandlers();\n }\n\n runtime.requiresSignIn = result.requiresSignIn;\n signInRuntime = runtime;\n bootstrapApp = { ...result.bootstrapApp, apis: phase.apis };\n\n return bootstrapApp;\n }\n\n return {\n getBootstrapApp,\n onFinalized(callback) {\n finalization.selectMode('onFinalized');\n // Subscribing to finalization also ensures the bootstrap tree exists,\n // because sign-in may need to capture identity before finalization starts.\n getBootstrapApp();\n\n let subscribed = true;\n\n if (finalized) {\n const finalizedApp = finalized;\n Promise.resolve().then(() => {\n if (subscribed) {\n callback(finalizedApp);\n }\n });\n return () => {\n subscribed = false;\n };\n }\n\n // If sign-in is still in progress we wait for the shared promise created\n // by the sign-in callback. Otherwise we can start finalization right away.\n const finalizedAppPromise =\n signInRuntime?.requiresSignIn && !signInRuntime.readyIdentityApi\n ? finalization.getPromise()\n : finalization.start(loadAsyncSessionState);\n finalizedAppPromise\n .then(finalizedApp => {\n if (subscribed) {\n callback(finalizedApp);\n }\n })\n .catch(() => {});\n\n return () => {\n subscribed = false;\n };\n },\n finalize() {\n finalization.selectMode('finalize');\n if (finalized) {\n return finalized;\n }\n if (!providedSessionState) {\n // finalize() still depends on bootstrap classification and sign-in\n // discovery unless a reusable session was supplied up front, so we make\n // sure the bootstrap tree has been prepared first.\n getBootstrapApp();\n }\n\n // Direct finalization never waits for async session preparation. Callers\n // must either provide sessionState during prepareSpecializedApp() or\n // invoke finalize() only when the predicate context is already available\n // synchronously.\n const finalizedSessionState = signInRuntime?.requiresSignIn\n ? undefined\n : getSynchronousSessionState();\n if (!finalizedSessionState) {\n if (signInRuntime?.requiresSignIn) {\n throw new Error(\n 'prepareSpecializedApp requires waiting for the bootstrap app to be ready before calling finalize()',\n );\n }\n throw new Error(\n 'prepareSpecializedApp requires waiting for asynchronous finalization before calling finalize()',\n );\n }\n\n finalized = finalizeWithSessionState(finalizedSessionState);\n return finalized;\n },\n };\n}\n\n/**\n * Materializes the fully finalized app tree from a prepared session state.\n *\n * This is responsible for switching the identity proxy to the resolved target,\n * synchronizing any deferred API factories, and re-instantiating the parts of\n * the tree that are only valid once predicate context is available.\n */\nfunction finalizeFromSessionState(options: {\n finalized?: FinalizedSpecializedApp;\n finalizedSessionState: SpecializedAppSessionState;\n tree: AppTree;\n collector: ErrorCollector;\n phase: ReturnType<typeof createPhaseApis>;\n extensionFactoryMiddleware?: ExtensionFactoryMiddleware;\n routeRefsById: ReturnType<typeof collectRouteIds>;\n appBasePath: string;\n providedApis?: ApiHolder;\n features: FrontendFeature[];\n appApiRegistry: FrontendApiRegistry;\n bootstrapClassification: BootstrapClassification;\n bootstrapApiFactoryEntries: Map<string, ApiFactoryEntry>;\n bootstrapMissingApiAccesses: Map<string, { node: AppNode; apiRefId: string }>;\n}): FinalizedSpecializedApp {\n if (options.finalized) {\n return options.finalized;\n }\n\n const sessionStateData = OpaqueSpecializedAppSessionState.toInternal(\n options.finalizedSessionState,\n );\n if (sessionStateData.identityApi) {\n // Finalization retargets the identity proxy before any additional nodes are\n // instantiated so the full tree observes the captured identity immediately.\n setIdentityApiTarget({\n identityApiProxy: options.phase.identityApiProxy,\n identityApi: sessionStateData.identityApi,\n signOutTargetUrl: options.appBasePath || '/',\n });\n }\n if (!options.providedApis) {\n // Deferred API roots are synchronized at finalization time, but bootstrap-\n // materialized APIs stay frozen if they were already observed earlier.\n syncFinalApiFactories({\n deferredApiNodes: options.bootstrapClassification.deferredApiRoots,\n appApiRegistry: options.appApiRegistry,\n apiResolver: options.phase.apis,\n collector: options.collector,\n features: options.features,\n bootstrapApiFactoryEntries: options.bootstrapApiFactoryEntries,\n bootstrapMissingApiAccesses: options.bootstrapMissingApiAccesses,\n predicateContext: sessionStateData.predicateContext,\n });\n }\n\n prepareFinalizedTree({\n tree: options.tree,\n });\n // Finalization re-instantiates the boundary subtree so predicate-gated app\n // content can be re-evaluated without disturbing preserved bootstrap nodes.\n clearFinalizationBoundaryInstances(options.tree);\n instantiateAndInitializePhaseTree({\n tree: options.tree,\n apis: options.phase.apis,\n collector: options.collector,\n extensionFactoryMiddleware: options.extensionFactoryMiddleware,\n routeResolutionApi: options.phase.routeResolutionApi,\n appTreeApi: options.phase.appTreeApi,\n routeRefsById: options.routeRefsById,\n predicateContext: sessionStateData.predicateContext,\n });\n\n const element = options.tree.root.instance?.getData(\n coreExtensionData.reactElement,\n );\n if (!element) {\n throw new Error('Expected finalized app tree to expose a root element');\n }\n\n return {\n apis: options.phase.apis,\n element,\n sessionState: options.finalizedSessionState,\n tree: options.tree,\n errors: options.collector.collectErrors(),\n };\n}\n\n/**\n * Builds a finalized app that rethrows a bootstrap-time failure through the\n * normal app root boundary.\n *\n * This keeps the error handling path aligned with normal finalization while\n * preserving any session state that was already resolved before the failure.\n */\nfunction finalizeFromBootstrapError(options: {\n finalized?: FinalizedSpecializedApp;\n error: Error;\n finalizedSessionState?: SpecializedAppSessionState;\n tree: AppTree;\n collector: ErrorCollector;\n phase: ReturnType<typeof createPhaseApis>;\n extensionFactoryMiddleware?: ExtensionFactoryMiddleware;\n routeRefsById: ReturnType<typeof collectRouteIds>;\n signInRuntime?: SignInRuntime;\n providedSessionData?: InternalSpecializedAppSessionState;\n}): FinalizedSpecializedApp {\n if (options.finalized) {\n return options.finalized;\n }\n\n // If finalization fails after session state was already prepared, keep using\n // it so the error app reflects the same identity and API view.\n const finalizedSessionState =\n options.finalizedSessionState ??\n OpaqueSpecializedAppSessionState.createInstance('v1', {\n apis: options.phase.apis,\n identityApi:\n options.signInRuntime?.readyIdentityApi ??\n options.providedSessionData?.identityApi,\n predicateContext: EMPTY_PREDICATE_CONTEXT,\n });\n\n prepareFinalizedTree({\n tree: options.tree,\n });\n clearFinalizationBoundaryInstances(options.tree);\n // The final app reports bootstrap failures through app/root.children so the\n // normal app root boundary renders the error state for us.\n attachThrowingFinalizationChild(options.tree, options.error);\n instantiateAndInitializePhaseTree({\n tree: options.tree,\n apis: options.phase.apis,\n collector: options.collector,\n extensionFactoryMiddleware: options.extensionFactoryMiddleware,\n routeResolutionApi: options.phase.routeResolutionApi,\n appTreeApi: options.phase.appTreeApi,\n routeRefsById: options.routeRefsById,\n });\n\n const element = options.tree.root.instance?.getData(\n coreExtensionData.reactElement,\n );\n if (!element) {\n throw new Error('Expected finalized app tree to expose a root element');\n }\n\n return {\n apis: options.phase.apis,\n element,\n sessionState: finalizedSessionState,\n tree: options.tree,\n };\n}\n\n/**\n * Owns the callback-driven finalization lifecycle for a prepared app.\n *\n * The controller enforces the selected finalization mode, memoizes the shared\n * async finalization promise for `onFinalized()` subscribers, and funnels both\n * successful and failing async finalization through the same resolution path.\n */\nfunction createFinalizationController(options: {\n getFinalized(): FinalizedSpecializedApp | undefined;\n setFinalized(finalizedApp: FinalizedSpecializedApp): void;\n finalizeFromSessionState(\n finalizedSessionState: SpecializedAppSessionState,\n ): FinalizedSpecializedApp;\n finalizeFromBootstrapError(\n error: Error,\n finalizedSessionState?: SpecializedAppSessionState,\n ): FinalizedSpecializedApp;\n}) {\n let finalizationState: FinalizationState | undefined;\n let finalizationMode: FinalizationMode | undefined;\n\n function getState(): FinalizationState {\n if (finalizationState) {\n return finalizationState;\n }\n\n // onFinalized() subscribers all fan into the same promise so that the full\n // finalization flow only ever runs once.\n let resolve: ((app: FinalizedSpecializedApp) => void) | undefined;\n let reject: ((error: unknown) => void) | undefined;\n const promise = new Promise<FinalizedSpecializedApp>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n if (!resolve || !reject) {\n throw new Error('Failed to create finalization state');\n }\n\n finalizationState = {\n started: false,\n promise,\n resolve,\n reject,\n };\n return finalizationState;\n }\n\n return {\n getMode() {\n return finalizationMode;\n },\n getPromise() {\n return getState().promise;\n },\n selectMode(mode: FinalizationMode) {\n if (finalizationMode && finalizationMode !== mode) {\n throw new Error(\n `prepareSpecializedApp only supports using either onFinalized() or finalize(), not both`,\n );\n }\n\n // A prepared app now has one owner: either the callback-driven path or\n // the direct finalize() path, never both.\n finalizationMode = mode;\n },\n start(loader: () => Promise<SpecializedAppSessionState>) {\n const finalized = options.getFinalized();\n if (finalized) {\n return Promise.resolve(finalized);\n }\n\n const state = getState();\n if (state.started) {\n return state.promise;\n }\n state.started = true;\n\n // If loading finishes but final tree materialization fails, we still\n // want to preserve the resolved session state when building the error app.\n let finalizedSessionState: SpecializedAppSessionState | undefined;\n loader()\n .then(sessionState => {\n finalizedSessionState = sessionState;\n const finalizedApp = options.finalizeFromSessionState(sessionState);\n options.setFinalized(finalizedApp);\n state.resolve(finalizedApp);\n })\n .catch(error => {\n try {\n const bootstrapFailure = isError(error)\n ? error\n : new Error(String(error));\n const finalizedApp = options.finalizeFromBootstrapError(\n bootstrapFailure,\n finalizedSessionState,\n );\n options.setFinalized(finalizedApp);\n state.resolve(finalizedApp);\n } catch (finalizationError) {\n finalizationState = undefined;\n state.reject(finalizationError);\n }\n });\n\n return state.promise;\n },\n };\n}\n\n/**\n * Combines one or more extension factory middlewares into a single middleware\n * invocation chain that preserves Backstage's extension data container shape.\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 'extension factory middleware',\n );\n }, ctx);\n };\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,SAAS,oBACP,WAAA,EACmB;AAEnB,EAAA,MAAM,WAAW,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,WAAW,CAAC,CAAA;AAGhD,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAY;AAChC,EAAA,OAAO,QAAA,CACJ,OAAA,EAAQ,CACR,MAAA,CAAO,CAAA,OAAA,KAAW;AACjB,IAAA,IAAI,CAAC,oBAAA,CAAqB,MAAA,CAAO,OAAO,CAAA,EAAG;AACzC,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA,EAAG;AAC3B,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,OAAA,CAAQ,GAAA,CAAI,QAAQ,EAAE,CAAA;AACtB,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,EACA,OAAA,EAAQ;AACb;AA4DA,MAAM,gCAAA,GAAmC,WAAW,MAAA,CAKjD;AAAA,EACD,IAAA,EAAM,uCAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC,CAAA;AAED,MAAM,6BAA6B,sBAAA,EAEjC,CAAE,KAAK,EAAE,EAAA,EAAI,+BAA+B,CAAA;AA+EvC,SAAS,2BACd,IAAA,EAC4B;AAC5B,EAAA,OAAO,gCAAA,CAAiC,eAAe,IAAA,EAAM;AAAA,IAC3D,IAAA;AAAA,IACA,WAAA,EAAa,IAAA,CAAK,GAAA,CAAI,cAAc,CAAA;AAAA,IACpC,gBAAA,EAAkB;AAAA,GACnB,CAAA;AACH;AAaO,SAAS,sBACd,OAAA,EACwB;AACxB,EAAA,MAAM,eAAA,GAAkB,OAAA;AACxB,EAAA,MAAM,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B,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC/B,IAAA,OAAO,WAAA;AAAA,EACT;AACA,EAAA,IAAI,WAAA,CAAY,UAAU,CAAA,EAAG;AAC3B,IAAA,OAAO,YAAY,CAAC,CAAA;AAAA,EACtB;AACA,EAAA,OAAO,WAAA,CAAY,MAAA,CAAO,CAAC,IAAA,EAAM,IAAA,KAAS;AACxC,IAAA,IAAI,CAAC,IAAA,IAAQ,CAAC,IAAA,EAAM;AAClB,MAAA,OAAO,IAAA,IAAQ,IAAA;AAAA,IACjB;AACA,IAAA,OAAO,CAAC,MAAM,GAAA,KAAQ;AACpB,MAAA,MAAM,WAAA,GAAc,mBAAA,CAAoB,GAAA,CAAI,IAAA,CAAK,KAAK,SAAS,CAAA;AAC/D,MAAA,IAAI,WAAA,CAAY,YAAY,IAAA,EAAM;AAChC,QAAA,OAAO,IAAA,EAAK;AAAA,MACd;AACA,MAAA,OAAO,KAAK,CAAA,YAAA,KAAgB;AAC1B,QAAA,OAAO,4BAAA;AAAA,UACL,KAAK,IAAA,EAAM;AAAA,YACT,MAAM,GAAA,CAAI,IAAA;AAAA,YACV,MAAM,GAAA,CAAI,IAAA;AAAA,YACV,MAAA,EAAQ,YAAA,EAAc,MAAA,IAAU,GAAA,CAAI;AAAA,WACrC,CAAA;AAAA,UACD;AAAA,SACF;AAAA,MACF,GAAG,GAAG,CAAA;AAAA,IACR,CAAA;AAAA,EACF,CAAC,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"prepareSpecializedApp.esm.js","sources":["../../src/wiring/prepareSpecializedApp.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 { isError } from '@backstage/errors';\nimport {\n AnyApiFactory,\n ApiHolder,\n AppTree,\n ConfigApi,\n coreExtensionData,\n AppNode,\n ExtensionFactoryMiddleware,\n FrontendFeature,\n IdentityApi,\n identityApiRef,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\nimport {\n createExtensionDataContainer,\n OpaqueFrontendPlugin,\n} from '@internal/frontend';\nimport { OpaqueType } from '@internal/opaque';\nimport { ComponentType, ReactNode } from 'react';\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 { CreateAppRouteBinder } from '../routing';\nimport { resolveRouteBindings } from '../routing/resolveRouteBindings';\nimport { collectRouteIds } from '../routing/collectRouteIds';\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 {\n createPluginInfoAttacher,\n FrontendPluginInfoResolver,\n} from './createPluginInfoAttacher';\nimport {\n AppError,\n createErrorCollector,\n ErrorCollector,\n} from './createErrorCollector';\nimport {\n createPhaseApis,\n instantiateAndInitializePhaseTree,\n setIdentityApiTarget,\n} from './phaseApis';\nimport {\n collectPredicateReferences,\n createPredicateContextLoader,\n EMPTY_PREDICATE_CONTEXT,\n type ExtensionPredicateContext,\n} from './predicates';\nimport { FrontendApiRegistry } from './FrontendApiRegistry';\nimport {\n ApiFactoryEntry,\n collectApiFactoryEntries,\n registerFeatureFlagDeclarationsInHolder,\n syncFinalApiFactories,\n wrapFeatureFlagApiFactory,\n} from './apiFactories';\nimport {\n attachThrowingFinalizationChild,\n BootstrapClassification,\n classifyBootstrapTree,\n clearFinalizationBoundaryInstances,\n createBootstrapApp,\n prepareFinalizedTree,\n} from './treeLifecycle';\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\ntype SignInPageProps = {\n onSignInSuccess(identityApi: IdentityApi): void;\n children?: ReactNode;\n};\n\n/**\n * Result of bootstrapping a prepared specialized app.\n *\n * @public\n */\nexport type BootstrapSpecializedApp = {\n apis: ApiHolder;\n element: JSX.Element;\n tree: AppTree;\n};\n\n/**\n * Result of finalizing a prepared specialized app.\n *\n * @public\n */\nexport type FinalizedSpecializedApp = {\n apis: ApiHolder;\n element: JSX.Element;\n sessionState: SpecializedAppSessionState;\n tree: AppTree;\n errors?: AppError[];\n};\n\ntype SignInRuntime = {\n readyIdentityApi?: IdentityApi;\n requiresSignIn: boolean;\n};\n\ntype FinalizationState = {\n started: boolean;\n promise: Promise<FinalizedSpecializedApp>;\n resolve(app: FinalizedSpecializedApp): void;\n reject(error: unknown): void;\n};\n\ntype FinalizationMode = 'onFinalized' | 'finalize';\n\ntype InternalSpecializedAppSessionState = {\n apis: ApiHolder;\n identityApi?: IdentityApi;\n predicateContext: ExtensionPredicateContext;\n};\n\n/**\n * Opaque reusable session state for specialized apps.\n *\n * @public\n */\nexport type SpecializedAppSessionState = {\n $$type: '@backstage/SpecializedAppSessionState';\n};\n\nconst OpaqueSpecializedAppSessionState = OpaqueType.create<{\n public: SpecializedAppSessionState;\n versions: InternalSpecializedAppSessionState & {\n version: 'v1';\n };\n}>({\n type: '@backstage/SpecializedAppSessionState',\n versions: ['v1'],\n});\n\nconst signInPageComponentDataRef = createExtensionDataRef<\n ComponentType<SignInPageProps>\n>().with({ id: 'core.sign-in-page.component' });\n\n/**\n * Options for {@link prepareSpecializedApp}.\n *\n * @public\n */\nexport type PrepareSpecializedAppOptions = {\n /**\n * The list of features to load.\n */\n features?: FrontendFeature[];\n\n /**\n * The config API implementation to use. For most normal apps, this should be\n * specified.\n *\n * If none is given, a new _empty_ config will be used during startup. In\n * later stages of the app lifecycle, the config API in the API holder will be\n * used.\n */\n config?: ConfigApi;\n\n /**\n * Allows for the binding of plugins' external route refs within the app.\n */\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n\n /**\n * Advanced, more rarely used options.\n */\n advanced?: {\n /**\n * A reusable specialized app session state to use.\n *\n * This can be obtained from either the app passed to\n * {@link PreparedSpecializedApp.onFinalized} or from\n * {@link PreparedSpecializedApp.finalize}, and reused in a future app\n * instance to skip sign-in and session preparation.\n */\n sessionState?: SpecializedAppSessionState;\n\n /**\n * Applies one or more middleware on every extension, as they are added to\n * the application.\n *\n * This is an advanced use case for modifying extension data on the fly as\n * it gets emitted by extensions being instantiated.\n */\n extensionFactoryMiddleware?:\n | ExtensionFactoryMiddleware\n | ExtensionFactoryMiddleware[];\n\n /**\n * Allows for customizing how plugin info is retrieved.\n */\n pluginInfoResolver?: FrontendPluginInfoResolver;\n };\n};\n\n/**\n * Result of {@link prepareSpecializedApp}.\n *\n * @public\n */\nexport type PreparedSpecializedApp = {\n getBootstrapApp(): BootstrapSpecializedApp;\n onFinalized(callback: (app: FinalizedSpecializedApp) => void): () => void;\n finalize(): FinalizedSpecializedApp;\n};\n\n// Internal options type, not exported in the public API\nexport interface CreateSpecializedAppInternalOptions\n extends PrepareSpecializedAppOptions {\n __internal?: {\n apiFactoryOverrides?: AnyApiFactory[];\n };\n}\n\nexport function createSessionStateFromApis(\n apis: ApiHolder,\n): SpecializedAppSessionState {\n return OpaqueSpecializedAppSessionState.createInstance('v1', {\n apis,\n identityApi: apis.get(identityApiRef),\n predicateContext: EMPTY_PREDICATE_CONTEXT,\n });\n}\n\n/**\n * Prepares an app without instantiating the full extension tree.\n *\n * @remarks\n *\n * This is useful for split sign-in flows where the sign-in page should be\n * rendered first, and the full app finalized once an identity has been\n * captured.\n *\n * @public\n */\nexport function prepareSpecializedApp(\n options?: PrepareSpecializedAppOptions,\n): PreparedSpecializedApp {\n const internalOptions = options as CreateSpecializedAppInternalOptions;\n const config = options?.config ?? new ConfigReader({}, 'empty-config');\n const features = deduplicateFeatures(options?.features ?? []).map(\n createPluginInfoAttacher(config, options?.advanced?.pluginInfoResolver),\n );\n\n const collector = createErrorCollector();\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 collector,\n }),\n collector,\n );\n\n const appBasePath = getBasePath(config);\n const routeRefsById = collectRouteIds(features, collector);\n const routeBindings = resolveRouteBindings(\n options?.bindRoutes,\n config,\n routeRefsById,\n collector,\n );\n\n const mergedExtensionFactoryMiddleware = mergeExtensionFactoryMiddleware(\n options?.advanced?.extensionFactoryMiddleware,\n );\n const providedSessionState = options?.advanced?.sessionState;\n const providedSessionData = providedSessionState\n ? OpaqueSpecializedAppSessionState.toInternal(providedSessionState)\n : undefined;\n const providedApis = providedSessionData?.apis;\n // Bootstrap only renders the parts of the tree that are known to be safe\n // before predicate context and sign-in have been resolved.\n const bootstrapClassification = classifyBootstrapTree({\n tree,\n collector,\n });\n const predicateReferences = collectPredicateReferences(tree.nodes.values());\n const appApiRegistry = new FrontendApiRegistry();\n const internalStaticFactories =\n internalOptions?.__internal?.apiFactoryOverrides ?? [];\n const phaseStaticFactories = [...internalStaticFactories];\n const bootstrapApiFactoryEntries = new Map<string, ApiFactoryEntry>();\n const bootstrapMissingApiAccesses = new Map<\n string,\n { node: AppNode; apiRefId: string }\n >();\n\n if (providedApis) {\n // Reused session state already carries a fully prepared API holder, so the\n // bootstrap path only needs to register feature flag declarations on top.\n registerFeatureFlagDeclarationsInHolder(providedApis, features, collector);\n } else {\n // Bootstrap materializes only the immediately visible API factories. Any\n // predicate-gated API roots are revisited during finalization.\n collectApiFactoryEntries({\n apiNodes: (tree.root.edges.attachments.get('apis') ?? []).filter(\n apiNode => !bootstrapClassification.deferredApiRoots.has(apiNode),\n ),\n collector,\n entries: bootstrapApiFactoryEntries,\n });\n const apiFactories = Array.from(\n bootstrapApiFactoryEntries.values(),\n entry => wrapFeatureFlagApiFactory(entry.factory, features, collector),\n );\n appApiRegistry.registerAll(apiFactories);\n }\n const phase = createPhaseApis({\n tree,\n config,\n appApiRegistry,\n fallbackApis: providedApis,\n includeConfigApi: !providedApis,\n appBasePath,\n routeBindings,\n staticFactories: phaseStaticFactories,\n });\n const predicateContextLoader = createPredicateContextLoader({\n apis: phase.apis,\n predicateReferences,\n });\n let signInRuntime: SignInRuntime | undefined;\n let finalized: FinalizedSpecializedApp | undefined;\n let bootstrapApp: BootstrapSpecializedApp | undefined;\n\n function updateIdentityApiTarget(identityApi?: IdentityApi) {\n if (!identityApi) {\n return;\n }\n\n setIdentityApiTarget({\n identityApiProxy: phase.identityApiProxy,\n identityApi,\n signOutTargetUrl: appBasePath || '/',\n });\n }\n\n function createSessionState(predicateContext: ExtensionPredicateContext) {\n const identityApi =\n signInRuntime?.readyIdentityApi ?? providedSessionData?.identityApi;\n // As soon as a real identity is available we swap the phase proxy over so\n // the finalized tree observes the same API instance.\n updateIdentityApiTarget(identityApi);\n const sessionState = OpaqueSpecializedAppSessionState.createInstance('v1', {\n apis: phase.apis,\n identityApi,\n predicateContext,\n });\n return sessionState;\n }\n\n function getSynchronousSessionState() {\n if (providedSessionState) {\n return providedSessionState;\n }\n // The direct finalize() path is intentionally synchronous. If sign-in is\n // still pending we refuse to guess and force the caller to wait.\n if (signInRuntime?.requiresSignIn) {\n return undefined;\n }\n\n const predicateContext = predicateContextLoader.getImmediate();\n if (!predicateContext) {\n return undefined;\n }\n\n return createSessionState(predicateContext);\n }\n\n function loadAsyncSessionState() {\n if (providedSessionState) {\n return Promise.resolve(providedSessionState);\n }\n if (signInRuntime?.requiresSignIn && !signInRuntime.readyIdentityApi) {\n return Promise.reject(\n new Error(\n 'prepareSpecializedApp requires waiting for the bootstrap app to be ready before calling finalize()',\n ),\n );\n }\n\n // For apps without sign-in we can sometimes finalize immediately from the\n // already available predicate context, skipping the async loader.\n if (!signInRuntime?.requiresSignIn) {\n const immediateSessionState = getSynchronousSessionState();\n if (immediateSessionState) {\n return Promise.resolve(immediateSessionState);\n }\n }\n\n return predicateContextLoader.load().then(createSessionState);\n }\n\n function finalizeWithSessionState(\n finalizedSessionState: SpecializedAppSessionState,\n ) {\n return finalizeFromSessionState({\n finalized,\n finalizedSessionState,\n tree,\n collector,\n phase,\n extensionFactoryMiddleware: mergedExtensionFactoryMiddleware,\n routeRefsById,\n appBasePath,\n providedApis,\n features,\n appApiRegistry,\n bootstrapClassification,\n bootstrapApiFactoryEntries,\n bootstrapMissingApiAccesses,\n });\n }\n\n function finalizeWithBootstrapError(\n error: Error,\n finalizedSessionState?: SpecializedAppSessionState,\n ) {\n return finalizeFromBootstrapError({\n finalized,\n error,\n finalizedSessionState,\n tree,\n collector,\n phase,\n extensionFactoryMiddleware: mergedExtensionFactoryMiddleware,\n routeRefsById,\n signInRuntime,\n providedSessionData,\n });\n }\n\n const finalization = createFinalizationController({\n getFinalized() {\n return finalized;\n },\n setFinalized(finalizedApp) {\n finalized = finalizedApp;\n },\n finalizeFromSessionState: finalizeWithSessionState,\n finalizeFromBootstrapError: finalizeWithBootstrapError,\n });\n\n function getBootstrapApp() {\n if (bootstrapApp) {\n return bootstrapApp;\n }\n\n const runtime: SignInRuntime = {\n requiresSignIn: false,\n };\n if (!providedSessionState) {\n phase.identityApiProxy.setTargetHandlers({\n onTargetSet(identityApi) {\n runtime.readyIdentityApi = identityApi;\n // Sign-in completion only auto-starts finalization for onFinalized().\n // The direct finalize() path stays explicit and synchronous.\n if (finalization.getMode() === 'onFinalized') {\n finalization.start(loadAsyncSessionState);\n }\n },\n });\n }\n\n const result = createBootstrapApp({\n tree,\n apis: phase.apis,\n collector,\n routeRefsById,\n routeResolutionApi: phase.routeResolutionApi,\n appTreeApi: phase.appTreeApi,\n extensionFactoryMiddleware: mergedExtensionFactoryMiddleware,\n disableSignIn: Boolean(providedSessionState),\n skipBootstrapChild({ child }) {\n return bootstrapClassification.deferredRoots.has(child);\n },\n onMissingApi({ node, apiRefId }) {\n bootstrapMissingApiAccesses.set(`${node.spec.id}:${apiRefId}`, {\n node,\n apiRefId,\n });\n },\n hasSignInPage(signInPageNode) {\n return Boolean(\n signInPageNode?.instance?.getData(signInPageComponentDataRef),\n );\n },\n });\n if (!result.requiresSignIn) {\n phase.identityApiProxy.clearTargetHandlers();\n }\n\n runtime.requiresSignIn = result.requiresSignIn;\n signInRuntime = runtime;\n bootstrapApp = { ...result.bootstrapApp, apis: phase.apis };\n\n return bootstrapApp;\n }\n\n return {\n getBootstrapApp,\n onFinalized(callback) {\n finalization.selectMode('onFinalized');\n // Subscribing to finalization also ensures the bootstrap tree exists,\n // because sign-in may need to capture identity before finalization starts.\n getBootstrapApp();\n\n let subscribed = true;\n\n if (finalized) {\n const finalizedApp = finalized;\n Promise.resolve().then(() => {\n if (subscribed) {\n callback(finalizedApp);\n }\n });\n return () => {\n subscribed = false;\n };\n }\n\n // If sign-in is still in progress we wait for the shared promise created\n // by the sign-in callback. Otherwise we can start finalization right away.\n const finalizedAppPromise =\n signInRuntime?.requiresSignIn && !signInRuntime.readyIdentityApi\n ? finalization.getPromise()\n : finalization.start(loadAsyncSessionState);\n finalizedAppPromise\n .then(finalizedApp => {\n if (subscribed) {\n callback(finalizedApp);\n }\n })\n .catch(() => {});\n\n return () => {\n subscribed = false;\n };\n },\n finalize() {\n finalization.selectMode('finalize');\n if (finalized) {\n return finalized;\n }\n if (!providedSessionState) {\n // finalize() still depends on bootstrap classification and sign-in\n // discovery unless a reusable session was supplied up front, so we make\n // sure the bootstrap tree has been prepared first.\n getBootstrapApp();\n }\n\n // Direct finalization never waits for async session preparation. Callers\n // must either provide sessionState during prepareSpecializedApp() or\n // invoke finalize() only when the predicate context is already available\n // synchronously.\n const finalizedSessionState = signInRuntime?.requiresSignIn\n ? undefined\n : getSynchronousSessionState();\n if (!finalizedSessionState) {\n if (signInRuntime?.requiresSignIn) {\n throw new Error(\n 'prepareSpecializedApp requires waiting for the bootstrap app to be ready before calling finalize()',\n );\n }\n throw new Error(\n 'prepareSpecializedApp requires waiting for asynchronous finalization before calling finalize()',\n );\n }\n\n finalized = finalizeWithSessionState(finalizedSessionState);\n return finalized;\n },\n };\n}\n\n/**\n * Materializes the fully finalized app tree from a prepared session state.\n *\n * This is responsible for switching the identity proxy to the resolved target,\n * synchronizing any deferred API factories, and re-instantiating the parts of\n * the tree that are only valid once predicate context is available.\n */\nfunction finalizeFromSessionState(options: {\n finalized?: FinalizedSpecializedApp;\n finalizedSessionState: SpecializedAppSessionState;\n tree: AppTree;\n collector: ErrorCollector;\n phase: ReturnType<typeof createPhaseApis>;\n extensionFactoryMiddleware?: ExtensionFactoryMiddleware;\n routeRefsById: ReturnType<typeof collectRouteIds>;\n appBasePath: string;\n providedApis?: ApiHolder;\n features: FrontendFeature[];\n appApiRegistry: FrontendApiRegistry;\n bootstrapClassification: BootstrapClassification;\n bootstrapApiFactoryEntries: Map<string, ApiFactoryEntry>;\n bootstrapMissingApiAccesses: Map<string, { node: AppNode; apiRefId: string }>;\n}): FinalizedSpecializedApp {\n if (options.finalized) {\n return options.finalized;\n }\n\n const sessionStateData = OpaqueSpecializedAppSessionState.toInternal(\n options.finalizedSessionState,\n );\n if (sessionStateData.identityApi) {\n // Finalization retargets the identity proxy before any additional nodes are\n // instantiated so the full tree observes the captured identity immediately.\n setIdentityApiTarget({\n identityApiProxy: options.phase.identityApiProxy,\n identityApi: sessionStateData.identityApi,\n signOutTargetUrl: options.appBasePath || '/',\n });\n }\n if (!options.providedApis) {\n // Deferred API roots are synchronized at finalization time, but bootstrap-\n // materialized APIs stay frozen if they were already observed earlier.\n syncFinalApiFactories({\n deferredApiNodes: options.bootstrapClassification.deferredApiRoots,\n appApiRegistry: options.appApiRegistry,\n apiResolver: options.phase.apis,\n collector: options.collector,\n features: options.features,\n bootstrapApiFactoryEntries: options.bootstrapApiFactoryEntries,\n bootstrapMissingApiAccesses: options.bootstrapMissingApiAccesses,\n predicateContext: sessionStateData.predicateContext,\n });\n }\n\n prepareFinalizedTree({\n tree: options.tree,\n });\n // Finalization re-instantiates the boundary subtree so predicate-gated app\n // content can be re-evaluated without disturbing preserved bootstrap nodes.\n clearFinalizationBoundaryInstances(options.tree);\n instantiateAndInitializePhaseTree({\n tree: options.tree,\n apis: options.phase.apis,\n collector: options.collector,\n extensionFactoryMiddleware: options.extensionFactoryMiddleware,\n routeResolutionApi: options.phase.routeResolutionApi,\n appTreeApi: options.phase.appTreeApi,\n routeRefsById: options.routeRefsById,\n predicateContext: sessionStateData.predicateContext,\n });\n\n const element = options.tree.root.instance?.getData(\n coreExtensionData.reactElement,\n );\n if (!element) {\n throw new Error('Expected finalized app tree to expose a root element');\n }\n\n return {\n apis: options.phase.apis,\n element,\n sessionState: options.finalizedSessionState,\n tree: options.tree,\n errors: options.collector.collectErrors(),\n };\n}\n\n/**\n * Builds a finalized app that rethrows a bootstrap-time failure through the\n * normal app root boundary.\n *\n * This keeps the error handling path aligned with normal finalization while\n * preserving any session state that was already resolved before the failure.\n */\nfunction finalizeFromBootstrapError(options: {\n finalized?: FinalizedSpecializedApp;\n error: Error;\n finalizedSessionState?: SpecializedAppSessionState;\n tree: AppTree;\n collector: ErrorCollector;\n phase: ReturnType<typeof createPhaseApis>;\n extensionFactoryMiddleware?: ExtensionFactoryMiddleware;\n routeRefsById: ReturnType<typeof collectRouteIds>;\n signInRuntime?: SignInRuntime;\n providedSessionData?: InternalSpecializedAppSessionState;\n}): FinalizedSpecializedApp {\n if (options.finalized) {\n return options.finalized;\n }\n\n // If finalization fails after session state was already prepared, keep using\n // it so the error app reflects the same identity and API view.\n const finalizedSessionState =\n options.finalizedSessionState ??\n OpaqueSpecializedAppSessionState.createInstance('v1', {\n apis: options.phase.apis,\n identityApi:\n options.signInRuntime?.readyIdentityApi ??\n options.providedSessionData?.identityApi,\n predicateContext: EMPTY_PREDICATE_CONTEXT,\n });\n\n prepareFinalizedTree({\n tree: options.tree,\n });\n clearFinalizationBoundaryInstances(options.tree);\n // The final app reports bootstrap failures through app/root.children so the\n // normal app root boundary renders the error state for us.\n attachThrowingFinalizationChild(options.tree, options.error);\n instantiateAndInitializePhaseTree({\n tree: options.tree,\n apis: options.phase.apis,\n collector: options.collector,\n extensionFactoryMiddleware: options.extensionFactoryMiddleware,\n routeResolutionApi: options.phase.routeResolutionApi,\n appTreeApi: options.phase.appTreeApi,\n routeRefsById: options.routeRefsById,\n });\n\n const element = options.tree.root.instance?.getData(\n coreExtensionData.reactElement,\n );\n if (!element) {\n throw new Error('Expected finalized app tree to expose a root element');\n }\n\n return {\n apis: options.phase.apis,\n element,\n sessionState: finalizedSessionState,\n tree: options.tree,\n };\n}\n\n/**\n * Owns the callback-driven finalization lifecycle for a prepared app.\n *\n * The controller enforces the selected finalization mode, memoizes the shared\n * async finalization promise for `onFinalized()` subscribers, and funnels both\n * successful and failing async finalization through the same resolution path.\n */\nfunction createFinalizationController(options: {\n getFinalized(): FinalizedSpecializedApp | undefined;\n setFinalized(finalizedApp: FinalizedSpecializedApp): void;\n finalizeFromSessionState(\n finalizedSessionState: SpecializedAppSessionState,\n ): FinalizedSpecializedApp;\n finalizeFromBootstrapError(\n error: Error,\n finalizedSessionState?: SpecializedAppSessionState,\n ): FinalizedSpecializedApp;\n}) {\n let finalizationState: FinalizationState | undefined;\n let finalizationMode: FinalizationMode | undefined;\n\n function getState(): FinalizationState {\n if (finalizationState) {\n return finalizationState;\n }\n\n // onFinalized() subscribers all fan into the same promise so that the full\n // finalization flow only ever runs once.\n let resolve: ((app: FinalizedSpecializedApp) => void) | undefined;\n let reject: ((error: unknown) => void) | undefined;\n const promise = new Promise<FinalizedSpecializedApp>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n if (!resolve || !reject) {\n throw new Error('Failed to create finalization state');\n }\n\n finalizationState = {\n started: false,\n promise,\n resolve,\n reject,\n };\n return finalizationState;\n }\n\n return {\n getMode() {\n return finalizationMode;\n },\n getPromise() {\n return getState().promise;\n },\n selectMode(mode: FinalizationMode) {\n if (finalizationMode && finalizationMode !== mode) {\n throw new Error(\n `prepareSpecializedApp only supports using either onFinalized() or finalize(), not both`,\n );\n }\n\n // A prepared app now has one owner: either the callback-driven path or\n // the direct finalize() path, never both.\n finalizationMode = mode;\n },\n start(loader: () => Promise<SpecializedAppSessionState>) {\n const finalized = options.getFinalized();\n if (finalized) {\n return Promise.resolve(finalized);\n }\n\n const state = getState();\n if (state.started) {\n return state.promise;\n }\n state.started = true;\n\n // If loading finishes but final tree materialization fails, we still\n // want to preserve the resolved session state when building the error app.\n let finalizedSessionState: SpecializedAppSessionState | undefined;\n loader()\n .then(sessionState => {\n finalizedSessionState = sessionState;\n const finalizedApp = options.finalizeFromSessionState(sessionState);\n options.setFinalized(finalizedApp);\n state.resolve(finalizedApp);\n })\n .catch(error => {\n try {\n const bootstrapFailure = isError(error)\n ? error\n : new Error(String(error));\n const finalizedApp = options.finalizeFromBootstrapError(\n bootstrapFailure,\n finalizedSessionState,\n );\n options.setFinalized(finalizedApp);\n state.resolve(finalizedApp);\n } catch (finalizationError) {\n finalizationState = undefined;\n state.reject(finalizationError);\n }\n });\n\n return state.promise;\n },\n };\n}\n\n/**\n * Combines one or more extension factory middlewares into a single middleware\n * invocation chain that preserves Backstage's extension data container shape.\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 'extension factory middleware',\n );\n }, ctx);\n };\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,SAAS,oBACP,WAAA,EACmB;AAEnB,EAAA,MAAM,WAAW,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,WAAW,CAAC,CAAA;AAGhD,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAY;AAChC,EAAA,OAAO,QAAA,CACJ,OAAA,EAAQ,CACR,MAAA,CAAO,CAAA,OAAA,KAAW;AACjB,IAAA,IAAI,CAAC,oBAAA,CAAqB,MAAA,CAAO,OAAO,CAAA,EAAG;AACzC,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,OAAA,CAAQ,EAAE,CAAA,EAAG;AAC3B,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,OAAA,CAAQ,GAAA,CAAI,QAAQ,EAAE,CAAA;AACtB,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,EACA,OAAA,EAAQ;AACb;AA4DA,MAAM,gCAAA,GAAmC,WAAW,MAAA,CAKjD;AAAA,EACD,IAAA,EAAM,uCAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC,CAAA;AAED,MAAM,6BAA6B,sBAAA,EAEjC,CAAE,KAAK,EAAE,EAAA,EAAI,+BAA+B,CAAA;AA+EvC,SAAS,2BACd,IAAA,EAC4B;AAC5B,EAAA,OAAO,gC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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-app-api",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3-next.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -32,24 +32,24 @@
|
|
|
32
32
|
"test": "backstage-cli package test"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@backstage/config": "
|
|
36
|
-
"@backstage/core-app-api": "
|
|
37
|
-
"@backstage/core-plugin-api": "
|
|
38
|
-
"@backstage/errors": "
|
|
39
|
-
"@backstage/filter-predicates": "
|
|
40
|
-
"@backstage/frontend-defaults": "
|
|
41
|
-
"@backstage/frontend-plugin-api": "
|
|
42
|
-
"@backstage/types": "
|
|
43
|
-
"@backstage/version-bridge": "
|
|
35
|
+
"@backstage/config": "1.3.8-next.0",
|
|
36
|
+
"@backstage/core-app-api": "1.20.1-next.0",
|
|
37
|
+
"@backstage/core-plugin-api": "1.12.6-next.1",
|
|
38
|
+
"@backstage/errors": "1.3.1-next.0",
|
|
39
|
+
"@backstage/filter-predicates": "0.1.3-next.0",
|
|
40
|
+
"@backstage/frontend-defaults": "0.5.2-next.1",
|
|
41
|
+
"@backstage/frontend-plugin-api": "0.17.0-next.1",
|
|
42
|
+
"@backstage/types": "1.2.2",
|
|
43
|
+
"@backstage/version-bridge": "1.0.12",
|
|
44
44
|
"lodash": "^4.17.21",
|
|
45
45
|
"zod": "^3.25.76 || ^4.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@backstage/cli": "
|
|
49
|
-
"@backstage/frontend-test-utils": "
|
|
50
|
-
"@backstage/plugin-app": "
|
|
51
|
-
"@backstage/plugin-permission-common": "
|
|
52
|
-
"@backstage/test-utils": "
|
|
48
|
+
"@backstage/cli": "0.36.2-next.1",
|
|
49
|
+
"@backstage/frontend-test-utils": "0.5.3-next.1",
|
|
50
|
+
"@backstage/plugin-app": "0.4.6-next.1",
|
|
51
|
+
"@backstage/plugin-permission-common": "0.9.9-next.1",
|
|
52
|
+
"@backstage/test-utils": "1.7.18-next.0",
|
|
53
53
|
"@testing-library/jest-dom": "^6.0.0",
|
|
54
54
|
"@testing-library/react": "^16.0.0",
|
|
55
55
|
"@types/react": "^18.0.0",
|