frontend-app-api: backfill pluginId field
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -252,12 +252,11 @@ function resolveV2Inputs(
|
||||
return mapValues(inputMap, (input, inputName) => {
|
||||
const allAttachedNodes = attachments.get(inputName) ?? [];
|
||||
const collector = parentCollector.child({ inputName });
|
||||
const inputPluginId = node.spec.plugin.pluginId ?? node.spec.plugin.id;
|
||||
const inputPluginId = node.spec.plugin.pluginId;
|
||||
|
||||
const attachedNodes = input.config.internal
|
||||
? allAttachedNodes.filter(attachment => {
|
||||
const attachmentPluginId =
|
||||
attachment.spec.plugin.pluginId ?? attachment.spec.plugin.id;
|
||||
const attachmentPluginId = attachment.spec.plugin.pluginId;
|
||||
if (attachmentPluginId !== inputPluginId) {
|
||||
collector.report({
|
||||
code: 'EXTENSION_INPUT_INTERNAL_IGNORED',
|
||||
|
||||
@@ -32,6 +32,14 @@ import {
|
||||
import { toInternalExtension } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';
|
||||
import { ErrorCollector } from '../wiring/createErrorCollector';
|
||||
|
||||
function normalizePlugin(plugin: FrontendPlugin): FrontendPlugin {
|
||||
// Ensure pluginId is always set for plugins in the app
|
||||
if (!plugin.pluginId && 'id' in plugin && typeof plugin.id === 'string') {
|
||||
(plugin as any).pluginId = plugin.id;
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function resolveAppNodeSpecs(options: {
|
||||
features?: FrontendFeature[];
|
||||
@@ -48,7 +56,9 @@ export function resolveAppNodeSpecs(options: {
|
||||
collector,
|
||||
} = options;
|
||||
|
||||
const plugins = features.filter(OpaqueFrontendPlugin.isType);
|
||||
const plugins = features
|
||||
.filter(OpaqueFrontendPlugin.isType)
|
||||
.map(normalizePlugin);
|
||||
const modules = features.filter(isInternalFrontendModule);
|
||||
|
||||
const filterForbidden = (
|
||||
@@ -57,11 +67,7 @@ export function resolveAppNodeSpecs(options: {
|
||||
if (forbidden.has(extension.id)) {
|
||||
collector.report({
|
||||
code: 'EXTENSION_IGNORED',
|
||||
message: `It is forbidden to override the '${
|
||||
extension.id
|
||||
}' extension, attempted by the '${
|
||||
extension.plugin.pluginId ?? extension.plugin.id
|
||||
}' plugin`,
|
||||
message: `It is forbidden to override the '${extension.id}' extension, attempted by the '${extension.plugin.pluginId}' plugin`,
|
||||
context: {
|
||||
plugin: extension.plugin,
|
||||
extensionId: extension.id,
|
||||
@@ -84,7 +90,7 @@ export function resolveAppNodeSpecs(options: {
|
||||
toInternalFrontendModule(mod)
|
||||
.extensions.flatMap(extension => {
|
||||
// Modules for plugins that are not installed are ignored
|
||||
const plugin = plugins.find(p => p.id === mod.pluginId);
|
||||
const plugin = plugins.find(p => p.pluginId === mod.pluginId);
|
||||
if (!plugin) {
|
||||
return [];
|
||||
}
|
||||
@@ -95,7 +101,7 @@ export function resolveAppNodeSpecs(options: {
|
||||
);
|
||||
|
||||
const appPlugin =
|
||||
plugins.find(plugin => (plugin.pluginId ?? plugin.id) === 'app') ??
|
||||
plugins.find(plugin => plugin.pluginId === 'app') ??
|
||||
createFrontendPlugin({
|
||||
pluginId: 'app',
|
||||
});
|
||||
@@ -163,9 +169,7 @@ export function resolveAppNodeSpecs(options: {
|
||||
if (seenExtensionIds.has(extension.id)) {
|
||||
collector.report({
|
||||
code: 'EXTENSION_IGNORED',
|
||||
message: `The '${extension.id}' extension from the '${
|
||||
params.plugin.pluginId ?? params.plugin.id
|
||||
}' plugin is a duplicate and will be ignored`,
|
||||
message: `The '${extension.id}' extension from the '${params.plugin.pluginId}' plugin is a duplicate and will be ignored`,
|
||||
context: {
|
||||
plugin: params.plugin,
|
||||
extensionId: extension.id,
|
||||
|
||||
@@ -78,7 +78,7 @@ export function createPluginInfoAttacher(
|
||||
});
|
||||
|
||||
const infoWithOverrides = applyInfoOverrides(
|
||||
plugin.pluginId ?? plugin.id,
|
||||
plugin.pluginId,
|
||||
resolvedInfo,
|
||||
);
|
||||
return normalizePluginInfo(infoWithOverrides);
|
||||
|
||||
@@ -401,8 +401,7 @@ function createApiFactories(options: {
|
||||
if (apiFactory) {
|
||||
const apiRefId = apiFactory.api.id;
|
||||
const ownerId = getApiOwnerId(apiRefId);
|
||||
const pluginId =
|
||||
apiNode.spec.plugin.pluginId ?? apiNode.spec.plugin.id ?? 'app';
|
||||
const pluginId = apiNode.spec.plugin.pluginId ?? 'app';
|
||||
const existingFactory = factoriesById.get(apiRefId);
|
||||
|
||||
// This allows modules to override factories provided by the plugin, but
|
||||
|
||||
Reference in New Issue
Block a user