@backstage/frontend-app-api 0.16.0-next.1 → 0.16.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 +30 -0
- package/dist/frontend-internal/src/wiring/InternalExtensionDefinition.esm.js.map +1 -1
- package/dist/frontend-internal/src/wiring/InternalFrontendPlugin.esm.js.map +1 -1
- package/dist/frontend-plugin-api/src/wiring/createFrontendModule.esm.js.map +1 -1
- package/dist/frontend-plugin-api/src/wiring/resolveExtensionDefinition.esm.js.map +1 -1
- package/dist/index.d.ts +145 -26
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/routing/RouteAliasResolver.esm.js +0 -2
- package/dist/routing/RouteAliasResolver.esm.js.map +1 -1
- package/dist/routing/RouteResolver.esm.js +1 -1
- package/dist/routing/resolveRouteBindings.esm.js +2 -0
- package/dist/routing/resolveRouteBindings.esm.js.map +1 -1
- package/dist/tree/instantiateAppNodeTree.esm.js +72 -15
- package/dist/tree/instantiateAppNodeTree.esm.js.map +1 -1
- package/dist/tree/resolveAppNodeSpecs.esm.js +50 -9
- package/dist/tree/resolveAppNodeSpecs.esm.js.map +1 -1
- package/dist/wiring/FrontendApiRegistry.esm.js +92 -0
- package/dist/wiring/FrontendApiRegistry.esm.js.map +1 -0
- package/dist/wiring/apiFactories.esm.js +185 -0
- package/dist/wiring/apiFactories.esm.js.map +1 -0
- package/dist/wiring/createErrorCollector.esm.js.map +1 -1
- package/dist/wiring/createPluginInfoAttacher.esm.js.map +1 -1
- package/dist/wiring/createSpecializedApp.esm.js +11 -285
- package/dist/wiring/createSpecializedApp.esm.js.map +1 -1
- package/dist/wiring/phaseApis.esm.js +161 -0
- package/dist/wiring/phaseApis.esm.js.map +1 -0
- package/dist/wiring/predicates.esm.js +116 -0
- package/dist/wiring/predicates.esm.js.map +1 -0
- package/dist/wiring/prepareSpecializedApp.esm.js +518 -0
- package/dist/wiring/prepareSpecializedApp.esm.js.map +1 -0
- package/dist/wiring/treeLifecycle.esm.js +186 -0
- package/dist/wiring/treeLifecycle.esm.js.map +1 -0
- package/package.json +16 -14
- package/dist/core-app-api/src/apis/system/ApiRegistry.esm.js +0 -50
- package/dist/core-app-api/src/apis/system/ApiRegistry.esm.js.map +0 -1
|
@@ -0,0 +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';\n }\n if (prefix === 'plugin' && rest[0]) {\n return rest[0];\n }\n return prefix;\n}\n"],"names":[],"mappings":";;;;;AAkDO,SAAS,uCAAA,CACd,MACA,QAAA,EACA;AACA,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,GAAA,CAAI,kBAAkB,CAAA;AAClD,EAAA,IAAI,cAAA,EAAgB;AAClB,IAAA,+BAAA,CAAgC,gBAAgB,QAAQ,CAAA;AAAA,EAC1D;AACF;AAMO,SAAS,yBAAA,CACd,SACA,QAAA,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,gBAAgB,QAAQ,CAAA;AACxD,MAAA,OAAO,cAAA;AAAA,IACT;AAAA,GACF;AACF;AASO,SAAS,sBAAsB,OAAA,EASnC;AACD,EAAA,MAAM,kBAAkB,wBAAA,CAAyB;AAAA,IAC/C,UAAU,OAAA,CAAQ,gBAAA;AAAA,IAClB,WAAW,OAAA,CAAQ,SAAA;AAAA,IACnB,kBAAkB,OAAA,CAAQ,gBAAA;AAAA,IAC1B,OAAA,EAAS,IAAI,GAAA,CAAI,OAAA,CA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;AAAA,EACF;AAEA,EAAA,OAAO,aAAA;AACT;AAIA,SAAS,cAAc,QAAA,EAA0B;AAC/C,EAAA,MAAM,CAAC,MAAA,EAAQ,GAAG,IAAI,CAAA,GAAI,QAAA,CAAS,MAAM,GAAG,CAAA;AAC5C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,IAAA,OAAO,KAAA;AAAA,EACT;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 +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 // 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 // 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":"AAuJO,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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPluginInfoAttacher.esm.js","sources":["../../src/wiring/createPluginInfoAttacher.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport {\n FrontendFeature,\n FrontendPluginInfo,\n} from '@backstage/frontend-plugin-api';\nimport { OpaqueFrontendPlugin } from '@internal/frontend';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport once from 'lodash/once';\n// Avoid full dependency on catalog-model\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n parseEntityRef,\n stringifyEntityRef,\n} from '../../../catalog-model/src/entity/ref';\n\n/**\n * A function that resolves plugin info from a plugin manifest and package.json.\n *\n * @public\n */\nexport type FrontendPluginInfoResolver = (ctx: {\n packageJson(): Promise<JsonObject | undefined>;\n manifest(): Promise<JsonObject | undefined>;\n defaultResolver(sources: {\n packageJson: JsonObject | undefined;\n manifest: JsonObject | undefined;\n }): Promise<{ info: FrontendPluginInfo }>;\n}) => Promise<{ info: FrontendPluginInfo }>;\n\nexport function createPluginInfoAttacher(\n config: ConfigApi,\n infoResolver: FrontendPluginInfoResolver = async ctx =>\n ctx.defaultResolver({\n packageJson: await ctx.packageJson(),\n manifest: await ctx.manifest(),\n }),\n): (feature: FrontendFeature) => FrontendFeature {\n const applyInfoOverrides = createPluginInfoOverrider(config);\n\n return (feature: FrontendFeature) => {\n if (!OpaqueFrontendPlugin.isType(feature)) {\n return feature;\n }\n\n const plugin = OpaqueFrontendPlugin.toInternal(feature);\n\n return {\n ...plugin,\n info: once(async () => {\n const manifestLoader = plugin.infoOptions?.manifest;\n const packageJsonLoader = plugin.infoOptions?.packageJson;\n\n const { info: resolvedInfo } = await infoResolver({\n manifest: async () => manifestLoader?.(),\n packageJson: async () => packageJsonLoader?.(),\n defaultResolver: async sources => ({\n info: {\n ...resolvePackageInfo(sources.packageJson),\n ...resolveManifestInfo(sources.manifest),\n },\n }),\n });\n\n const infoWithOverrides = applyInfoOverrides(\n plugin.pluginId,\n resolvedInfo,\n );\n return normalizePluginInfo(infoWithOverrides);\n }),\n };\n };\n}\n\nfunction normalizePluginInfo(info: FrontendPluginInfo) {\n return {\n ...info,\n ownerEntityRefs: info.ownerEntityRefs?.map(ref =>\n stringifyEntityRef(\n parseEntityRef(ref, {\n defaultKind: 'Group',\n }),\n ),\n ),\n };\n}\n\nfunction createPluginInfoOverrider(config: ConfigApi) {\n const overrideConfigs =\n config.getOptionalConfigArray('app.pluginOverrides') ?? [];\n\n const overrideMatchers = overrideConfigs.map(overrideConfig => {\n const pluginIdMatcher = makeStringMatcher(\n overrideConfig.getOptionalString('match.pluginId'),\n );\n const packageNameMatcher = makeStringMatcher(\n overrideConfig.getOptionalString('match.packageName'),\n );\n const description = overrideConfig.getOptionalString('info.description');\n const ownerEntityRefs = overrideConfig.getOptionalStringArray(\n 'info.ownerEntityRefs',\n );\n const links = overrideConfig\n .getOptionalConfigArray('info.links')\n ?.map(linkConfig => ({\n title: linkConfig.getString('title'),\n url: linkConfig.getString('url'),\n }));\n\n return {\n test(pluginId: string, packageName?: string) {\n return packageNameMatcher(packageName) && pluginIdMatcher(pluginId);\n },\n info: {\n description,\n ownerEntityRefs,\n links,\n },\n };\n });\n\n return (pluginId: string, info: FrontendPluginInfo) => {\n const { packageName } = info;\n for (const matcher of overrideMatchers) {\n if (matcher.test(pluginId, packageName)) {\n if (matcher.info.description) {\n info.description = matcher.info.description;\n }\n if (matcher.info.ownerEntityRefs) {\n info.ownerEntityRefs = matcher.info.ownerEntityRefs;\n }\n if (matcher.info.links) {\n info.links = matcher.info.links;\n }\n }\n }\n return info;\n };\n}\n\nfunction resolveManifestInfo(manifest?: JsonValue) {\n if (!isJsonObject(manifest) || !isJsonObject(manifest.metadata)) {\n return undefined;\n }\n\n const info: FrontendPluginInfo = {};\n\n if (isJsonObject(manifest.spec) && typeof manifest.spec.owner === 'string') {\n info.ownerEntityRefs = [\n stringifyEntityRef(\n parseEntityRef(manifest.spec.owner, {\n defaultKind: 'Group',\n defaultNamespace: manifest.metadata.namespace?.toString(),\n }),\n ),\n ];\n }\n\n if (Array.isArray(manifest.metadata.links)) {\n info.links = manifest.metadata.links.filter(isJsonObject).map(link => ({\n title: String(link.title),\n url: String(link.url),\n }));\n }\n\n return info;\n}\n\nfunction resolvePackageInfo(packageJson?: JsonObject) {\n if (!packageJson) {\n return undefined;\n }\n\n const info: FrontendPluginInfo = {\n packageName: packageJson?.name?.toString(),\n version: packageJson?.version?.toString(),\n description: packageJson?.description?.toString(),\n };\n\n const links: { title: string; url: string }[] = [];\n\n if (typeof packageJson.homepage === 'string') {\n links.push({\n title: 'Homepage',\n url: packageJson.homepage,\n });\n }\n\n if (\n isJsonObject(packageJson.repository) &&\n typeof packageJson.repository?.url === 'string'\n ) {\n try {\n const url = new URL(packageJson.repository?.url);\n if (url.protocol === 'http:' || url.protocol === 'https:') {\n // TODO(Rugvip): Support more variants\n if (\n url.hostname === 'github.com' &&\n typeof packageJson.repository.directory === 'string'\n ) {\n const path = `${url.pathname}/tree/-/${packageJson.repository.directory}`;\n url.pathname = path.replaceAll('//', '/');\n }\n\n links.push({\n title: 'Repository',\n url: url.toString(),\n });\n }\n } catch {\n /* ignored */\n }\n }\n\n if (links.length > 0) {\n info.links = links;\n }\n return info;\n}\n\nfunction makeStringMatcher(pattern: string | undefined) {\n if (!pattern) {\n return () => true;\n }\n if (pattern.startsWith('/') && pattern.endsWith('/') && pattern.length > 2) {\n const regex = new RegExp(pattern.slice(1, -1));\n return (str?: string) => (str ? regex.test(str) : false);\n }\n\n return (str?: string) => str === pattern;\n}\n\nfunction isJsonObject(value?: JsonValue): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"names":[],"mappings":";;;;AA6CO,SAAS,yBACd,MAAA,EACA,YAAA,GAA2C,OAAM,GAAA,KAC/C,IAAI,eAAA,CAAgB;AAAA,EAClB,WAAA,EAAa,MAAM,GAAA,CAAI,WAAA,EAAY;AAAA,EACnC,QAAA,EAAU,MAAM,GAAA,CAAI,QAAA;AACtB,CAAC,CAAA,EAC4C;AAC/C,EAAA,MAAM,kBAAA,GAAqB,0BAA0B,MAAM,CAAA;AAE3D,EAAA,OAAO,CAAC,OAAA,KAA6B;AACnC,IAAA,IAAI,CAAC,oBAAA,CAAqB,MAAA,CAAO,OAAO,CAAA,EAAG;AACzC,MAAA,OAAO,OAAA;AAAA,IACT;AAEA,IAAA,MAAM,MAAA,GAAS,oBAAA,CAAqB,UAAA,CAAW,OAAO,CAAA;AAEtD,IAAA,OAAO;AAAA,MACL,GAAG,MAAA;AAAA,MACH,IAAA,EAAM,KAAK,YAAY;AACrB,QAAA,MAAM,cAAA,GAAiB,OAAO,WAAA,EAAa,QAAA;AAC3C,QAAA,MAAM,iBAAA,GAAoB,OAAO,WAAA,EAAa,WAAA;AAE9C,QAAA,MAAM,EAAE,IAAA,EAAM,YAAA,EAAa,GAAI,MAAM,YAAA,CAAa;AAAA,UAChD,QAAA,EAAU,YAAY,cAAA,IAAiB;AAAA,UACvC,WAAA,EAAa,YAAY,iBAAA,IAAoB;AAAA,UAC7C,eAAA,EAAiB,OAAM,OAAA,MAAY;AAAA,YACjC,IAAA,EAAM;AAAA,cACJ,GAAG,kBAAA,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,CAAC,GAAA,KAAkB,GAAA,GAAM,KAAA,CAAM,IAAA,CAAK,GAAG,CAAA,GAAI,KAAA;AAAA,EACpD;AAEA,EAAA,OAAO,CAAC,QAAiB,GAAA,KAAQ,OAAA;AACnC;AAEA,SAAS,aAAa,KAAA,EAAwC;AAC5D,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;;;;"}
|
|
1
|
+
{"version":3,"file":"createPluginInfoAttacher.esm.js","sources":["../../src/wiring/createPluginInfoAttacher.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ConfigApi } from '@backstage/frontend-plugin-api';\nimport {\n FrontendFeature,\n FrontendPluginInfo,\n} from '@backstage/frontend-plugin-api';\nimport { OpaqueFrontendPlugin } from '@internal/frontend';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport once from 'lodash/once';\n// Avoid full dependency on catalog-model\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n parseEntityRef,\n stringifyEntityRef,\n} from '../../../catalog-model/src/entity/ref';\n\n/**\n * A function that resolves plugin info from a plugin manifest and package.json.\n *\n * @public\n */\nexport type FrontendPluginInfoResolver = (ctx: {\n packageJson(): Promise<JsonObject | undefined>;\n manifest(): Promise<JsonObject | undefined>;\n defaultResolver(sources: {\n packageJson: JsonObject | undefined;\n manifest: JsonObject | undefined;\n }): Promise<{ info: FrontendPluginInfo }>;\n}) => Promise<{ info: FrontendPluginInfo }>;\n\nexport function createPluginInfoAttacher(\n config: ConfigApi,\n infoResolver: FrontendPluginInfoResolver = async ctx =>\n ctx.defaultResolver({\n packageJson: await ctx.packageJson(),\n manifest: await ctx.manifest(),\n }),\n): (feature: FrontendFeature) => FrontendFeature {\n const applyInfoOverrides = createPluginInfoOverrider(config);\n\n return (feature: FrontendFeature) => {\n if (!OpaqueFrontendPlugin.isType(feature)) {\n return feature;\n }\n\n const plugin = OpaqueFrontendPlugin.toInternal(feature);\n\n return {\n ...plugin,\n info: once(async () => {\n const manifestLoader = plugin.infoOptions?.manifest;\n const packageJsonLoader = plugin.infoOptions?.packageJson;\n\n const { info: resolvedInfo } = await infoResolver({\n manifest: async () => manifestLoader?.(),\n packageJson: async () => packageJsonLoader?.(),\n defaultResolver: async sources => ({\n info: {\n ...resolvePackageInfo(sources.packageJson),\n ...resolveManifestInfo(sources.manifest),\n },\n }),\n });\n\n const infoWithOverrides = applyInfoOverrides(\n plugin.pluginId,\n resolvedInfo,\n );\n return normalizePluginInfo(infoWithOverrides);\n }),\n };\n };\n}\n\nfunction normalizePluginInfo(info: FrontendPluginInfo) {\n return {\n ...info,\n ownerEntityRefs: info.ownerEntityRefs?.map(ref =>\n stringifyEntityRef(\n parseEntityRef(ref, {\n defaultKind: 'Group',\n }),\n ),\n ),\n };\n}\n\nfunction createPluginInfoOverrider(config: ConfigApi) {\n const overrideConfigs =\n config.getOptionalConfigArray('app.pluginOverrides') ?? [];\n\n const overrideMatchers = overrideConfigs.map(overrideConfig => {\n const pluginIdMatcher = makeStringMatcher(\n overrideConfig.getOptionalString('match.pluginId'),\n );\n const packageNameMatcher = makeStringMatcher(\n overrideConfig.getOptionalString('match.packageName'),\n );\n const description = overrideConfig.getOptionalString('info.description');\n const ownerEntityRefs = overrideConfig.getOptionalStringArray(\n 'info.ownerEntityRefs',\n );\n const links = overrideConfig\n .getOptionalConfigArray('info.links')\n ?.map(linkConfig => ({\n title: linkConfig.getString('title'),\n url: linkConfig.getString('url'),\n }));\n\n return {\n test(pluginId: string, packageName?: string) {\n return packageNameMatcher(packageName) && pluginIdMatcher(pluginId);\n },\n info: {\n description,\n ownerEntityRefs,\n links,\n },\n };\n });\n\n return (pluginId: string, info: FrontendPluginInfo) => {\n const { packageName } = info;\n for (const matcher of overrideMatchers) {\n if (matcher.test(pluginId, packageName)) {\n if (matcher.info.description) {\n info.description = matcher.info.description;\n }\n if (matcher.info.ownerEntityRefs) {\n info.ownerEntityRefs = matcher.info.ownerEntityRefs;\n }\n if (matcher.info.links) {\n info.links = matcher.info.links;\n }\n }\n }\n return info;\n };\n}\n\nfunction resolveManifestInfo(manifest?: JsonValue) {\n if (!isJsonObject(manifest) || !isJsonObject(manifest.metadata)) {\n return undefined;\n }\n\n const info: FrontendPluginInfo = {};\n\n if (isJsonObject(manifest.spec) && typeof manifest.spec.owner === 'string') {\n info.ownerEntityRefs = [\n stringifyEntityRef(\n parseEntityRef(manifest.spec.owner, {\n defaultKind: 'Group',\n defaultNamespace: manifest.metadata.namespace?.toString(),\n }),\n ),\n ];\n }\n\n if (Array.isArray(manifest.metadata.links)) {\n info.links = manifest.metadata.links.filter(isJsonObject).map(link => ({\n title: String(link.title),\n url: String(link.url),\n }));\n }\n\n return info;\n}\n\nfunction resolvePackageInfo(packageJson?: JsonObject) {\n if (!packageJson) {\n return undefined;\n }\n\n const info: FrontendPluginInfo = {\n packageName: packageJson?.name?.toString(),\n version: packageJson?.version?.toString(),\n description: packageJson?.description?.toString(),\n };\n\n const links: { title: string; url: string }[] = [];\n\n if (typeof packageJson.homepage === 'string') {\n links.push({\n title: 'Homepage',\n url: packageJson.homepage,\n });\n }\n\n if (\n isJsonObject(packageJson.repository) &&\n typeof packageJson.repository?.url === 'string'\n ) {\n try {\n const url = new URL(packageJson.repository?.url);\n if (url.protocol === 'http:' || url.protocol === 'https:') {\n // TODO(Rugvip): Support more variants\n if (\n url.hostname === 'github.com' &&\n typeof packageJson.repository.directory === 'string'\n ) {\n const path = `${url.pathname}/tree/-/${packageJson.repository.directory}`;\n url.pathname = path.replaceAll('//', '/');\n }\n\n links.push({\n title: 'Repository',\n url: url.toString(),\n });\n }\n } catch {\n /* ignored */\n }\n }\n\n if (links.length > 0) {\n info.links = links;\n }\n return info;\n}\n\nfunction makeStringMatcher(pattern: string | undefined) {\n if (!pattern) {\n return () => true;\n }\n if (pattern.startsWith('/') && pattern.endsWith('/') && pattern.length > 2) {\n const regex = new RegExp(pattern.slice(1, -1));\n return (str?: string) => (str ? regex.test(str) : false);\n }\n\n return (str?: string) => str === pattern;\n}\n\nfunction isJsonObject(value?: JsonValue): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"names":[],"mappings":";;;;AA6CO,SAAS,yBACd,MAAA,EACA,YAAA,GAA2C,OAAM,GAAA,KAC/C,IAAI,eAAA,CAAgB;AAAA,EAClB,WAAA,EAAa,MAAM,GAAA,CAAI,WAAA,EAAY;AAAA,EACnC,QAAA,EAAU,MAAM,GAAA,CAAI,QAAA;AACtB,CAAC,CAAA,EAC4C;AAC/C,EAAA,MAAM,kBAAA,GAAqB,0BAA0B,MAAM,CAAA;AAE3D,EAAA,OAAO,CAAC,OAAA,KAA6B;AACnC,IAAA,IAAI,CAAC,oBAAA,CAAqB,MAAA,CAAO,OAAO,CAAA,EAAG;AACzC,MAAA,OAAO,OAAA;AAAA,IACT;AAEA,IAAA,MAAM,MAAA,GAAS,oBAAA,CAAqB,UAAA,CAAW,OAAO,CAAA;AAEtD,IAAA,OAAO;AAAA,MACL,GAAG,MAAA;AAAA,MACH,IAAA,EAAM,KAAK,YAAY;AACrB,QAAA,MAAM,cAAA,GAAiB,OAAO,WAAA,EAAa,QAAA;AAC3C,QAAA,MAAM,iBAAA,GAAoB,OAAO,WAAA,EAAa,WAAA;AAE9C,QAAA,MAAM,EAAE,IAAA,EAAM,YAAA,EAAa,GAAI,MAAM,YAAA,CAAa;AAAA,UAChD,QAAA,EAAU,YAAY,cAAA,IAAiB;AAAA,UACvC,WAAA,EAAa,YAAY,iBAAA,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A,MAAM,QAAQ,IAAI,MAAA,CAAO,QAAQ,KAAA,CAAM,CAAA,EAAG,EAAE,CAAC,CAAA;AAC7C,IAAA,OAAO,CAAC,GAAA,KAAkB,GAAA,GAAM,KAAA,CAAM,IAAA,CAAK,GAAG,CAAA,GAAI,KAAA;AAAA,EACpD;AAEA,EAAA,OAAO,CAAC,QAAiB,GAAA,KAAQ,OAAA;AACnC;AAEA,SAAS,aAAa,KAAA,EAAwC;AAC5D,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;;;;"}
|
|
@@ -1,290 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createApiFactory, appTreeApiRef, routeResolutionApiRef, ApiBlueprint } from '@backstage/frontend-plugin-api';
|
|
3
|
-
import { configApiRef, identityApiRef, featureFlagsApiRef } from '@backstage/core-plugin-api';
|
|
4
|
-
import { ApiFactoryRegistry, ApiResolver } from '@backstage/core-app-api';
|
|
5
|
-
import { resolveExtensionDefinition, toInternalExtension } from '../frontend-plugin-api/src/wiring/resolveExtensionDefinition.esm.js';
|
|
6
|
-
import { extractRouteInfoFromAppNode } from '../routing/extractRouteInfoFromAppNode.esm.js';
|
|
7
|
-
import { RouteResolver } from '../routing/RouteResolver.esm.js';
|
|
8
|
-
import { resolveRouteBindings } from '../routing/resolveRouteBindings.esm.js';
|
|
9
|
-
import { collectRouteIds } from '../routing/collectRouteIds.esm.js';
|
|
10
|
-
import { isInternalFrontendModule, toInternalFrontendModule } from '../frontend-plugin-api/src/wiring/createFrontendModule.esm.js';
|
|
11
|
-
import { getBasePath } from '../routing/getBasePath.esm.js';
|
|
12
|
-
import { Root } from '../extensions/Root.esm.js';
|
|
13
|
-
import { resolveAppTree } from '../tree/resolveAppTree.esm.js';
|
|
14
|
-
import { resolveAppNodeSpecs } from '../tree/resolveAppNodeSpecs.esm.js';
|
|
15
|
-
import { readAppExtensionsConfig } from '../tree/readAppExtensionsConfig.esm.js';
|
|
16
|
-
import { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree.esm.js';
|
|
17
|
-
import { ApiRegistry } from '../core-app-api/src/apis/system/ApiRegistry.esm.js';
|
|
18
|
-
import { AppIdentityProxy } from '../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy.esm.js';
|
|
19
|
-
import { matchRoutes } from 'react-router-dom';
|
|
20
|
-
import { createPluginInfoAttacher } from './createPluginInfoAttacher.esm.js';
|
|
21
|
-
import { createRouteAliasResolver } from '../routing/RouteAliasResolver.esm.js';
|
|
22
|
-
import { createErrorCollector } from './createErrorCollector.esm.js';
|
|
23
|
-
import { OpaqueFrontendPlugin } from '../frontend-internal/src/wiring/InternalFrontendPlugin.esm.js';
|
|
24
|
-
import { createExtensionDataContainer } from '../frontend-internal/src/wiring/createExtensionDataContainer.esm.js';
|
|
1
|
+
import { createSessionStateFromApis, prepareSpecializedApp } from './prepareSpecializedApp.esm.js';
|
|
25
2
|
|
|
26
|
-
function deduplicateFeatures(allFeatures) {
|
|
27
|
-
const features = Array.from(new Set(allFeatures));
|
|
28
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
29
|
-
return features.reverse().filter((feature) => {
|
|
30
|
-
if (!OpaqueFrontendPlugin.isType(feature)) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (seenIds.has(feature.id)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
seenIds.add(feature.id);
|
|
37
|
-
return true;
|
|
38
|
-
}).reverse();
|
|
39
|
-
}
|
|
40
|
-
class AppTreeApiProxy {
|
|
41
|
-
#routeInfo;
|
|
42
|
-
tree;
|
|
43
|
-
appBasePath;
|
|
44
|
-
constructor(tree, appBasePath) {
|
|
45
|
-
this.tree = tree;
|
|
46
|
-
this.appBasePath = appBasePath;
|
|
47
|
-
}
|
|
48
|
-
checkIfInitialized() {
|
|
49
|
-
if (!this.#routeInfo) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
`You can't access the AppTreeApi during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
getTree() {
|
|
56
|
-
this.checkIfInitialized();
|
|
57
|
-
return { tree: this.tree };
|
|
58
|
-
}
|
|
59
|
-
getNodesByRoutePath(routePath) {
|
|
60
|
-
this.checkIfInitialized();
|
|
61
|
-
let path = routePath;
|
|
62
|
-
if (path.startsWith(this.appBasePath)) {
|
|
63
|
-
path = path.slice(this.appBasePath.length);
|
|
64
|
-
}
|
|
65
|
-
const matchedRoutes = matchRoutes(this.#routeInfo.routeObjects, path);
|
|
66
|
-
const matchedAppNodes = matchedRoutes?.filter((routeObj) => !!routeObj.route.appNode).map((routeObj) => routeObj.route.appNode) || [];
|
|
67
|
-
return { nodes: matchedAppNodes };
|
|
68
|
-
}
|
|
69
|
-
initialize(routeInfo) {
|
|
70
|
-
this.#routeInfo = routeInfo;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
class RouteResolutionApiProxy {
|
|
74
|
-
#delegate;
|
|
75
|
-
#routeObjects;
|
|
76
|
-
routeBindings;
|
|
77
|
-
appBasePath;
|
|
78
|
-
constructor(routeBindings, appBasePath) {
|
|
79
|
-
this.routeBindings = routeBindings;
|
|
80
|
-
this.appBasePath = appBasePath;
|
|
81
|
-
}
|
|
82
|
-
resolve(anyRouteRef, options) {
|
|
83
|
-
if (!this.#delegate) {
|
|
84
|
-
throw new Error(
|
|
85
|
-
`You can't access the RouteResolver during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
return this.#delegate.resolve(anyRouteRef, options);
|
|
89
|
-
}
|
|
90
|
-
initialize(routeInfo, routeRefsById) {
|
|
91
|
-
this.#delegate = new RouteResolver(
|
|
92
|
-
routeInfo.routePaths,
|
|
93
|
-
routeInfo.routeParents,
|
|
94
|
-
routeInfo.routeObjects,
|
|
95
|
-
this.routeBindings,
|
|
96
|
-
this.appBasePath,
|
|
97
|
-
routeInfo.routeAliasResolver,
|
|
98
|
-
routeRefsById
|
|
99
|
-
);
|
|
100
|
-
this.#routeObjects = routeInfo.routeObjects;
|
|
101
|
-
return routeInfo;
|
|
102
|
-
}
|
|
103
|
-
getRouteObjects() {
|
|
104
|
-
return this.#routeObjects;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
3
|
function createSpecializedApp(options) {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
builtinExtensions: [
|
|
119
|
-
resolveExtensionDefinition(Root, { namespace: "root" })
|
|
120
|
-
],
|
|
121
|
-
parameters: readAppExtensionsConfig(config),
|
|
122
|
-
forbidden: /* @__PURE__ */ new Set(["root"]),
|
|
123
|
-
collector
|
|
124
|
-
}),
|
|
125
|
-
collector
|
|
126
|
-
);
|
|
127
|
-
const factories = createApiFactories({ tree, collector });
|
|
128
|
-
const appBasePath = getBasePath(config);
|
|
129
|
-
const appTreeApi = new AppTreeApiProxy(tree, appBasePath);
|
|
130
|
-
const routeRefsById = collectRouteIds(features, collector);
|
|
131
|
-
const routeResolutionApi = new RouteResolutionApiProxy(
|
|
132
|
-
resolveRouteBindings(options?.bindRoutes, config, routeRefsById, collector),
|
|
133
|
-
appBasePath
|
|
134
|
-
);
|
|
135
|
-
const appIdentityProxy = new AppIdentityProxy();
|
|
136
|
-
const apis = options?.advanced?.apis ?? createApiHolder({
|
|
137
|
-
factories,
|
|
138
|
-
staticFactories: [
|
|
139
|
-
createApiFactory(appTreeApiRef, appTreeApi),
|
|
140
|
-
createApiFactory(configApiRef, config),
|
|
141
|
-
createApiFactory(routeResolutionApiRef, routeResolutionApi),
|
|
142
|
-
createApiFactory(identityApiRef, appIdentityProxy),
|
|
143
|
-
...internalOptions?.__internal?.apiFactoryOverrides ?? []
|
|
144
|
-
]
|
|
145
|
-
});
|
|
146
|
-
const featureFlagApi = apis.get(featureFlagsApiRef);
|
|
147
|
-
if (featureFlagApi) {
|
|
148
|
-
for (const feature of features) {
|
|
149
|
-
if (OpaqueFrontendPlugin.isType(feature)) {
|
|
150
|
-
OpaqueFrontendPlugin.toInternal(feature).featureFlags.forEach(
|
|
151
|
-
(flag) => featureFlagApi.registerFlag({
|
|
152
|
-
name: flag.name,
|
|
153
|
-
description: flag.description,
|
|
154
|
-
pluginId: feature.id
|
|
155
|
-
})
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
if (isInternalFrontendModule(feature)) {
|
|
159
|
-
toInternalFrontendModule(feature).featureFlags.forEach(
|
|
160
|
-
(flag) => featureFlagApi.registerFlag({
|
|
161
|
-
name: flag.name,
|
|
162
|
-
description: flag.description,
|
|
163
|
-
pluginId: feature.pluginId
|
|
164
|
-
})
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
instantiateAppNodeTree(
|
|
170
|
-
tree.root,
|
|
171
|
-
apis,
|
|
172
|
-
collector,
|
|
173
|
-
mergeExtensionFactoryMiddleware(
|
|
174
|
-
options?.advanced?.extensionFactoryMiddleware
|
|
175
|
-
)
|
|
176
|
-
);
|
|
177
|
-
const routeInfo = extractRouteInfoFromAppNode(
|
|
178
|
-
tree.root,
|
|
179
|
-
createRouteAliasResolver(routeRefsById)
|
|
180
|
-
);
|
|
181
|
-
routeResolutionApi.initialize(routeInfo, routeRefsById.routes);
|
|
182
|
-
appTreeApi.initialize(routeInfo);
|
|
183
|
-
return { apis, tree, errors: collector.collectErrors() };
|
|
184
|
-
}
|
|
185
|
-
function createApiFactories(options) {
|
|
186
|
-
const emptyApiHolder = ApiRegistry.from([]);
|
|
187
|
-
const factoriesById = /* @__PURE__ */ new Map();
|
|
188
|
-
for (const apiNode of options.tree.root.edges.attachments.get("apis") ?? []) {
|
|
189
|
-
if (!instantiateAppNodeTree(apiNode, emptyApiHolder, options.collector)) {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
const apiFactory = apiNode.instance?.getData(ApiBlueprint.dataRefs.factory);
|
|
193
|
-
if (apiFactory) {
|
|
194
|
-
const apiRefId = apiFactory.api.id;
|
|
195
|
-
const ownerId = getApiOwnerId(apiRefId);
|
|
196
|
-
const pluginId = apiNode.spec.plugin.pluginId ?? "app";
|
|
197
|
-
const existingFactory = factoriesById.get(apiRefId);
|
|
198
|
-
if (existingFactory && existingFactory.pluginId !== pluginId) {
|
|
199
|
-
const shouldReplace = ownerId === pluginId && existingFactory.pluginId !== ownerId;
|
|
200
|
-
const acceptedPluginId = shouldReplace ? pluginId : existingFactory.pluginId;
|
|
201
|
-
const rejectedPluginId = shouldReplace ? existingFactory.pluginId : pluginId;
|
|
202
|
-
options.collector.report({
|
|
203
|
-
code: "API_FACTORY_CONFLICT",
|
|
204
|
-
message: `API '${apiRefId}' is already provided by plugin '${acceptedPluginId}', cannot also be provided by '${rejectedPluginId}'.`,
|
|
205
|
-
context: {
|
|
206
|
-
node: apiNode,
|
|
207
|
-
apiRefId,
|
|
208
|
-
pluginId: rejectedPluginId,
|
|
209
|
-
existingPluginId: acceptedPluginId
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
if (shouldReplace) {
|
|
213
|
-
factoriesById.set(apiRefId, {
|
|
214
|
-
pluginId,
|
|
215
|
-
factory: apiFactory
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
factoriesById.set(apiRefId, { pluginId, factory: apiFactory });
|
|
221
|
-
} else {
|
|
222
|
-
options.collector.report({
|
|
223
|
-
code: "API_EXTENSION_INVALID",
|
|
224
|
-
message: `API extension '${apiNode.spec.id}' did not output an API factory`,
|
|
225
|
-
context: {
|
|
226
|
-
node: apiNode
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return Array.from(factoriesById.values(), (entry) => entry.factory);
|
|
232
|
-
}
|
|
233
|
-
function getApiOwnerId(apiRefId) {
|
|
234
|
-
const [prefix, ...rest] = apiRefId.split(".");
|
|
235
|
-
if (!prefix) {
|
|
236
|
-
return apiRefId;
|
|
237
|
-
}
|
|
238
|
-
if (prefix === "core") {
|
|
239
|
-
return "app";
|
|
240
|
-
}
|
|
241
|
-
if (prefix === "plugin" && rest[0]) {
|
|
242
|
-
return rest[0];
|
|
243
|
-
}
|
|
244
|
-
return prefix;
|
|
245
|
-
}
|
|
246
|
-
function createApiHolder(options) {
|
|
247
|
-
const factoryRegistry = new ApiFactoryRegistry();
|
|
248
|
-
for (const factory of options.factories.slice().reverse()) {
|
|
249
|
-
factoryRegistry.register("default", factory);
|
|
250
|
-
}
|
|
251
|
-
for (const factory of options.staticFactories) {
|
|
252
|
-
factoryRegistry.register("static", factory);
|
|
253
|
-
}
|
|
254
|
-
ApiResolver.validateFactories(factoryRegistry, factoryRegistry.getAllApis());
|
|
255
|
-
return new ApiResolver(factoryRegistry);
|
|
256
|
-
}
|
|
257
|
-
function mergeExtensionFactoryMiddleware(middlewares) {
|
|
258
|
-
if (!middlewares) {
|
|
259
|
-
return void 0;
|
|
260
|
-
}
|
|
261
|
-
if (!Array.isArray(middlewares)) {
|
|
262
|
-
return middlewares;
|
|
263
|
-
}
|
|
264
|
-
if (middlewares.length <= 1) {
|
|
265
|
-
return middlewares[0];
|
|
266
|
-
}
|
|
267
|
-
return middlewares.reduce((prev, next) => {
|
|
268
|
-
if (!prev || !next) {
|
|
269
|
-
return prev ?? next;
|
|
270
|
-
}
|
|
271
|
-
return (orig, ctx) => {
|
|
272
|
-
const internalExt = toInternalExtension(ctx.node.spec.extension);
|
|
273
|
-
if (internalExt.version !== "v2") {
|
|
274
|
-
return orig();
|
|
275
|
-
}
|
|
276
|
-
return next((ctxOverrides) => {
|
|
277
|
-
return createExtensionDataContainer(
|
|
278
|
-
prev(orig, {
|
|
279
|
-
node: ctx.node,
|
|
280
|
-
apis: ctx.apis,
|
|
281
|
-
config: ctxOverrides?.config ?? ctx.config
|
|
282
|
-
}),
|
|
283
|
-
"extension factory middleware"
|
|
284
|
-
);
|
|
285
|
-
}, ctx);
|
|
286
|
-
};
|
|
287
|
-
});
|
|
4
|
+
const sessionState = options?.advanced?.apis ? createSessionStateFromApis(options.advanced.apis) : void 0;
|
|
5
|
+
return prepareSpecializedApp({
|
|
6
|
+
features: options?.features,
|
|
7
|
+
config: options?.config,
|
|
8
|
+
bindRoutes: options?.bindRoutes,
|
|
9
|
+
advanced: {
|
|
10
|
+
...options?.advanced,
|
|
11
|
+
sessionState
|
|
12
|
+
}
|
|
13
|
+
}).finalize();
|
|
288
14
|
}
|
|
289
15
|
|
|
290
16
|
export { createSpecializedApp };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSpecializedApp.esm.js","sources":["../../src/wiring/createSpecializedApp.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ConfigReader } from '@backstage/config';\nimport {\n ApiBlueprint,\n AppTree,\n AppTreeApi,\n appTreeApiRef,\n RouteRef,\n ExternalRouteRef,\n SubRouteRef,\n AnyRouteRefParams,\n RouteFunc,\n RouteResolutionApi,\n createApiFactory,\n routeResolutionApiRef,\n AppNode,\n FrontendFeature,\n} from '@backstage/frontend-plugin-api';\nimport { ExtensionFactoryMiddleware } from './types';\nimport {\n AnyApiFactory,\n ApiHolder,\n ConfigApi,\n configApiRef,\n featureFlagsApiRef,\n identityApiRef,\n} from '@backstage/core-plugin-api';\nimport { ApiFactoryRegistry, ApiResolver } from '@backstage/core-app-api';\nimport {\n createExtensionDataContainer,\n OpaqueFrontendPlugin,\n} from '@internal/frontend';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n resolveExtensionDefinition,\n toInternalExtension,\n} from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n\nimport {\n extractRouteInfoFromAppNode,\n RouteInfo,\n} from '../routing/extractRouteInfoFromAppNode';\n\nimport { CreateAppRouteBinder } from '../routing';\nimport { RouteResolver } from '../routing/RouteResolver';\nimport { resolveRouteBindings } from '../routing/resolveRouteBindings';\nimport { collectRouteIds } from '../routing/collectRouteIds';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n toInternalFrontendModule,\n isInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\nimport { getBasePath } from '../routing/getBasePath';\nimport { Root } from '../extensions/Root';\nimport { resolveAppTree } from '../tree/resolveAppTree';\nimport { resolveAppNodeSpecs } from '../tree/resolveAppNodeSpecs';\nimport { readAppExtensionsConfig } from '../tree/readAppExtensionsConfig';\nimport { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiRegistry } from '../../../core-app-api/src/apis/system/ApiRegistry';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppIdentityProxy } from '../../../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy';\nimport { BackstageRouteObject } from '../routing/types';\nimport { matchRoutes } from 'react-router-dom';\nimport {\n createPluginInfoAttacher,\n FrontendPluginInfoResolver,\n} from './createPluginInfoAttacher';\nimport { createRouteAliasResolver } from '../routing/RouteAliasResolver';\nimport {\n AppError,\n createErrorCollector,\n ErrorCollector,\n} from './createErrorCollector';\n\nfunction deduplicateFeatures(\n allFeatures: FrontendFeature[],\n): FrontendFeature[] {\n // Start by removing duplicates by reference\n const features = Array.from(new Set(allFeatures));\n\n // Plugins are deduplicated by ID, last one wins\n const seenIds = new Set<string>();\n return features\n .reverse()\n .filter(feature => {\n if (!OpaqueFrontendPlugin.isType(feature)) {\n return true;\n }\n if (seenIds.has(feature.id)) {\n return false;\n }\n seenIds.add(feature.id);\n return true;\n })\n .reverse();\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass AppTreeApiProxy implements AppTreeApi {\n #routeInfo?: RouteInfo;\n private readonly tree: AppTree;\n private readonly appBasePath: string;\n\n constructor(tree: AppTree, appBasePath: string) {\n this.tree = tree;\n this.appBasePath = appBasePath;\n }\n\n private checkIfInitialized() {\n if (!this.#routeInfo) {\n throw new Error(\n `You can't access the AppTreeApi during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n }\n\n getTree() {\n this.checkIfInitialized();\n\n return { tree: this.tree };\n }\n\n getNodesByRoutePath(routePath: string): { nodes: AppNode[] } {\n this.checkIfInitialized();\n\n let path = routePath;\n if (path.startsWith(this.appBasePath)) {\n path = path.slice(this.appBasePath.length);\n }\n\n const matchedRoutes = matchRoutes(this.#routeInfo!.routeObjects, path);\n\n const matchedAppNodes =\n matchedRoutes\n ?.filter(routeObj => !!routeObj.route.appNode)\n .map(routeObj => routeObj.route.appNode!) || [];\n\n return { nodes: matchedAppNodes };\n }\n\n initialize(routeInfo: RouteInfo) {\n this.#routeInfo = routeInfo;\n }\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass RouteResolutionApiProxy implements RouteResolutionApi {\n #delegate: RouteResolutionApi | undefined;\n #routeObjects: BackstageRouteObject[] | undefined;\n\n private readonly routeBindings: Map<ExternalRouteRef, RouteRef | SubRouteRef>;\n private readonly appBasePath: string;\n\n constructor(\n routeBindings: Map<ExternalRouteRef, RouteRef | SubRouteRef>,\n appBasePath: string,\n ) {\n this.routeBindings = routeBindings;\n this.appBasePath = appBasePath;\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 if (!this.#delegate) {\n throw new Error(\n `You can't access the RouteResolver during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n\n return this.#delegate.resolve(anyRouteRef, options);\n }\n\n initialize(\n routeInfo: RouteInfo,\n routeRefsById: Map<string, RouteRef | SubRouteRef>,\n ) {\n this.#delegate = new RouteResolver(\n routeInfo.routePaths,\n routeInfo.routeParents,\n routeInfo.routeObjects,\n this.routeBindings,\n this.appBasePath,\n routeInfo.routeAliasResolver,\n routeRefsById,\n );\n this.#routeObjects = routeInfo.routeObjects;\n\n return routeInfo;\n }\n\n getRouteObjects() {\n return this.#routeObjects;\n }\n}\n\n/**\n * Options for {@link createSpecializedApp}.\n *\n * @public\n */\nexport type CreateSpecializedAppOptions = {\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 replacement API holder implementation to use.\n *\n * By default, a new API holder will be constructed automatically based on\n * the other inputs. If you pass in a custom one here, none of that\n * automation will take place - so you will have to take care to supply all\n * those APIs yourself.\n */\n apis?: ApiHolder;\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// Internal options type, not exported in the public API\nexport interface CreateSpecializedAppInternalOptions\n extends CreateSpecializedAppOptions {\n __internal?: {\n apiFactoryOverrides?: AnyApiFactory[];\n };\n}\n\n/**\n * Creates an empty app without any default features. This is a low-level API is\n * intended for use in tests or specialized setups. Typically you want to use\n * `createApp` from `@backstage/frontend-defaults` instead.\n *\n * @public\n */\nexport function createSpecializedApp(options?: CreateSpecializedAppOptions): {\n apis: ApiHolder;\n tree: AppTree;\n errors?: AppError[];\n} {\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 factories = createApiFactories({ tree, collector });\n const appBasePath = getBasePath(config);\n const appTreeApi = new AppTreeApiProxy(tree, appBasePath);\n\n const routeRefsById = collectRouteIds(features, collector);\n const routeResolutionApi = new RouteResolutionApiProxy(\n resolveRouteBindings(options?.bindRoutes, config, routeRefsById, collector),\n appBasePath,\n );\n\n const appIdentityProxy = new AppIdentityProxy();\n const apis =\n options?.advanced?.apis ??\n createApiHolder({\n factories,\n staticFactories: [\n createApiFactory(appTreeApiRef, appTreeApi),\n createApiFactory(configApiRef, config),\n createApiFactory(routeResolutionApiRef, routeResolutionApi),\n createApiFactory(identityApiRef, appIdentityProxy),\n ...(internalOptions?.__internal?.apiFactoryOverrides ?? []),\n ],\n });\n\n const featureFlagApi = apis.get(featureFlagsApiRef);\n if (featureFlagApi) {\n for (const feature of features) {\n if (OpaqueFrontendPlugin.isType(feature)) {\n OpaqueFrontendPlugin.toInternal(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n 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 // Now instantiate the entire tree, which will skip anything that's already been instantiated\n instantiateAppNodeTree(\n tree.root,\n apis,\n collector,\n mergeExtensionFactoryMiddleware(\n options?.advanced?.extensionFactoryMiddleware,\n ),\n );\n\n const routeInfo = extractRouteInfoFromAppNode(\n tree.root,\n createRouteAliasResolver(routeRefsById),\n );\n\n routeResolutionApi.initialize(routeInfo, routeRefsById.routes);\n appTreeApi.initialize(routeInfo);\n\n return { apis, tree, errors: collector.collectErrors() };\n}\n\nfunction createApiFactories(options: {\n tree: AppTree;\n collector: ErrorCollector;\n}): AnyApiFactory[] {\n const emptyApiHolder = ApiRegistry.from([]);\n const factoriesById = new Map<\n string,\n { pluginId: string; factory: AnyApiFactory }\n >();\n\n for (const apiNode of options.tree.root.edges.attachments.get('apis') ?? []) {\n if (!instantiateAppNodeTree(apiNode, emptyApiHolder, options.collector)) {\n continue;\n }\n const apiFactory = apiNode.instance?.getData(ApiBlueprint.dataRefs.factory);\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 factory: apiFactory,\n });\n }\n continue;\n }\n\n factoriesById.set(apiRefId, { pluginId, factory: apiFactory });\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 Array.from(factoriesById.values(), entry => entry.factory);\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\nfunction createApiHolder(options: {\n factories: AnyApiFactory[];\n staticFactories: AnyApiFactory[];\n}): ApiHolder {\n const factoryRegistry = new ApiFactoryRegistry();\n\n for (const factory of options.factories.slice().reverse()) {\n factoryRegistry.register('default', factory);\n }\n\n for (const factory of options.staticFactories) {\n factoryRegistry.register('static', factory);\n }\n\n ApiResolver.validateFactories(factoryRegistry, factoryRegistry.getAllApis());\n\n return new ApiResolver(factoryRegistry);\n}\n\nfunction mergeExtensionFactoryMiddleware(\n middlewares?: ExtensionFactoryMiddleware | ExtensionFactoryMiddleware[],\n): ExtensionFactoryMiddleware | undefined {\n if (!middlewares) {\n return undefined;\n }\n if (!Array.isArray(middlewares)) {\n return middlewares;\n }\n if (middlewares.length <= 1) {\n return middlewares[0];\n }\n return middlewares.reduce((prev, next) => {\n if (!prev || !next) {\n return prev ?? next;\n }\n return (orig, ctx) => {\n const internalExt = toInternalExtension(ctx.node.spec.extension);\n if (internalExt.version !== 'v2') {\n return orig();\n }\n return next(ctxOverrides => {\n return createExtensionDataContainer(\n prev(orig, {\n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e,CAAA;AACxC;AAEA,SAAS,gCACP,WAAA,EACwC;AACxC,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,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":"createSpecializedApp.esm.js","sources":["../../src/wiring/createSpecializedApp.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiHolder,\n ConfigApi,\n ExtensionFactoryMiddleware,\n FrontendFeature,\n} from '@backstage/frontend-plugin-api';\nimport { CreateAppRouteBinder } from '../routing';\nimport { FrontendPluginInfoResolver } from './createPluginInfoAttacher';\nimport {\n createSessionStateFromApis,\n CreateSpecializedAppInternalOptions,\n FinalizedSpecializedApp,\n prepareSpecializedApp,\n} from './prepareSpecializedApp';\n\nexport type { CreateSpecializedAppInternalOptions };\n\n/**\n * Options for {@link createSpecializedApp}.\n *\n * @deprecated Use `PrepareSpecializedAppOptions` with `prepareSpecializedApp` instead.\n *\n * @public\n */\nexport type CreateSpecializedAppOptions = {\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 * APIs to expose to the app during startup.\n */\n apis?: ApiHolder;\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 * Creates an empty app without any default features. This is a low-level API is\n * intended for use in tests or specialized setups. Typically you want to use\n * `createApp` from `@backstage/frontend-defaults` instead.\n *\n * @deprecated Use `prepareSpecializedApp` instead.\n *\n * @public\n */\nexport function createSpecializedApp(\n options?: CreateSpecializedAppOptions,\n): FinalizedSpecializedApp {\n const sessionState = options?.advanced?.apis\n ? createSessionStateFromApis(options.advanced.apis)\n : undefined;\n\n return prepareSpecializedApp({\n features: options?.features,\n config: options?.config,\n bindRoutes: options?.bindRoutes,\n advanced: {\n ...options?.advanced,\n sessionState,\n },\n }).finalize();\n}\n"],"names":[],"mappings":";;AAiGO,SAAS,qBACd,OAAA,EACyB;AACzB,EAAA,MAAM,YAAA,GAAe,SAAS,QAAA,EAAU,IAAA,GACpC,2BAA2B,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA,GAChD,MAAA;AAEJ,EAAA,OAAO,qBAAA,CAAsB;AAAA,IAC3B,UAAU,OAAA,EAAS,QAAA;AAAA,IACnB,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,YAAY,OAAA,EAAS,UAAA;AAAA,IACrB,QAAA,EAAU;AAAA,MACR,GAAG,OAAA,EAAS,QAAA;AAAA,MACZ;AAAA;AACF,GACD,EAAE,QAAA,EAAS;AACd;;;;"}
|