refactor: extend channel plugin boundary

This commit is contained in:
Peter Steinberger
2026-01-20 11:49:31 +00:00
parent 439044068a
commit 9a2bf57e1c
31 changed files with 234 additions and 162 deletions

View File

@@ -60,6 +60,8 @@ export const ChannelsStatusResultSchema = Type.Object(
ts: Type.Integer({ minimum: 0 }),
channelOrder: Type.Array(NonEmptyString),
channelLabels: Type.Record(NonEmptyString, NonEmptyString),
channelDetailLabels: Type.Optional(Type.Record(NonEmptyString, NonEmptyString)),
channelSystemImages: Type.Optional(Type.Record(NonEmptyString, NonEmptyString)),
channels: Type.Record(NonEmptyString, Type.Unknown()),
channelAccounts: Type.Record(NonEmptyString, Type.Array(ChannelAccountSnapshotSchema)),
channelDefaultAccountId: Type.Record(NonEmptyString, NonEmptyString),

View File

@@ -188,10 +188,24 @@ export const channelsHandlers: GatewayRequestHandlers = {
return { accounts, defaultAccountId, defaultAccount, resolvedAccounts };
};
const channelLabels = Object.fromEntries(plugins.map((plugin) => [plugin.id, plugin.meta.label]));
const channelDetailLabels = Object.fromEntries(
plugins.map((plugin) => [
plugin.id,
plugin.meta.detailLabel ?? plugin.meta.selectionLabel ?? plugin.meta.label,
]),
);
const channelSystemImages = Object.fromEntries(
plugins.flatMap((plugin) =>
plugin.meta.systemImage ? [[plugin.id, plugin.meta.systemImage]] : [],
),
);
const payload: Record<string, unknown> = {
ts: Date.now(),
channelOrder: plugins.map((plugin) => plugin.id),
channelLabels: Object.fromEntries(plugins.map((plugin) => [plugin.id, plugin.meta.label])),
channelLabels,
channelDetailLabels,
channelSystemImages,
channels: {} as Record<string, unknown>,
channelAccounts: {} as Record<string, unknown>,
channelDefaultAccountId: {} as Record<string, unknown>,