diff --git a/src/cli/outbound-send-mapping.ts b/src/cli/outbound-send-mapping.ts index aa4242bd73a..a5f8dd866cd 100644 --- a/src/cli/outbound-send-mapping.ts +++ b/src/cli/outbound-send-mapping.ts @@ -1,5 +1,8 @@ import { normalizeAnyChannelId } from "../channels/registry.js"; -import type { OutboundSendDeps } from "../infra/outbound/send-deps.js"; +import { + resolveLegacyOutboundSendDepKeys, + type OutboundSendDeps, +} from "../infra/outbound/send-deps.js"; import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js"; /** @@ -27,23 +30,6 @@ function resolveChannelIdFromLegacySourceKey(key: string): string | undefined { return normalizeAnyChannelId(normalizedStem) ?? (normalizedStem || undefined); } -function resolveLegacyDepKeysForChannel(channelId: string): string[] { - const compact = channelId.replace(/[^a-z0-9]+/gi, ""); - if (!compact) { - return []; - } - const pascal = compact.charAt(0).toUpperCase() + compact.slice(1); - const keys = new Set(); - keys.add(`send${pascal}`); - if (pascal.startsWith("I") && pascal.length > 1) { - keys.add(`sendI${pascal.slice(1)}`); - } - if (pascal.startsWith("Ms") && pascal.length > 2) { - keys.add(`sendMS${pascal.slice(2)}`); - } - return [...keys]; -} - /** * Pass CLI send sources through as-is — both CliOutboundSendSource and * OutboundSendDeps are now channel-ID-keyed records. @@ -67,7 +53,7 @@ export function createOutboundSendDepsFromCliSource(deps: CliOutboundSendSource) if (sourceValue === undefined) { continue; } - for (const legacyDepKey of resolveLegacyDepKeysForChannel(channelId)) { + for (const legacyDepKey of resolveLegacyOutboundSendDepKeys(channelId)) { if (outbound[legacyDepKey] === undefined) { outbound[legacyDepKey] = sourceValue; } diff --git a/src/infra/outbound/send-deps.ts b/src/infra/outbound/send-deps.ts index 7b491fdd8b3..b6394cede17 100644 --- a/src/infra/outbound/send-deps.ts +++ b/src/infra/outbound/send-deps.ts @@ -5,7 +5,7 @@ */ export type OutboundSendDeps = { [channelId: string]: unknown }; -function resolveLegacyDepKeysForChannel(channelId: string): string[] { +export function resolveLegacyOutboundSendDepKeys(channelId: string): string[] { const compact = channelId.replace(/[^a-z0-9]+/gi, ""); if (!compact) { return []; @@ -36,7 +36,10 @@ export function resolveOutboundSendDep( if (dynamic !== undefined) { return dynamic as T; } - const legacyKeys = [...resolveLegacyDepKeysForChannel(channelId), ...(options?.legacyKeys ?? [])]; + const legacyKeys = [ + ...resolveLegacyOutboundSendDepKeys(channelId), + ...(options?.legacyKeys ?? []), + ]; for (const legacyKey of legacyKeys) { const legacy = deps?.[legacyKey]; if (legacy !== undefined) {