From f73d8e8d9eadda7f5d3aaec0c37c5525bbec57e9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 20 Apr 2026 15:21:20 +0100 Subject: [PATCH] refactor: share configured account id helper --- src/plugin-sdk/account-configured-ids.ts | 17 +++++++++++++++++ src/plugin-sdk/account-core.ts | 19 +------------------ src/plugin-sdk/account-resolution-runtime.ts | 19 +------------------ 3 files changed, 19 insertions(+), 36 deletions(-) create mode 100644 src/plugin-sdk/account-configured-ids.ts diff --git a/src/plugin-sdk/account-configured-ids.ts b/src/plugin-sdk/account-configured-ids.ts new file mode 100644 index 00000000000..2ab3c72eb29 --- /dev/null +++ b/src/plugin-sdk/account-configured-ids.ts @@ -0,0 +1,17 @@ +/** List normalized configured account ids from a raw channel account record map. */ +export function listConfiguredAccountIds(params: { + accounts: Record | undefined; + normalizeAccountId: (accountId: string) => string; +}): string[] { + if (!params.accounts) { + return []; + } + const ids = new Set(); + for (const key of Object.keys(params.accounts)) { + if (!key) { + continue; + } + ids.add(params.normalizeAccountId(key)); + } + return [...ids]; +} diff --git a/src/plugin-sdk/account-core.ts b/src/plugin-sdk/account-core.ts index a8129970270..e6751a66eaf 100644 --- a/src/plugin-sdk/account-core.ts +++ b/src/plugin-sdk/account-core.ts @@ -17,6 +17,7 @@ export { normalizeOptionalAccountId, } from "../routing/session-key.js"; export { normalizeE164, pathExists, resolveUserPath } from "../utils.js"; +export { listConfiguredAccountIds } from "./account-configured-ids.js"; /** Resolve an account by id, then fall back to the default account when the primary lacks credentials. */ export function resolveAccountWithDefaultFallback(params: { @@ -43,21 +44,3 @@ export function resolveAccountWithDefaultFallback(params: { } return fallback; } - -/** List normalized configured account ids from a raw channel account record map. */ -export function listConfiguredAccountIds(params: { - accounts: Record | undefined; - normalizeAccountId: (accountId: string) => string; -}): string[] { - if (!params.accounts) { - return []; - } - const ids = new Set(); - for (const key of Object.keys(params.accounts)) { - if (!key) { - continue; - } - ids.add(params.normalizeAccountId(key)); - } - return [...ids]; -} diff --git a/src/plugin-sdk/account-resolution-runtime.ts b/src/plugin-sdk/account-resolution-runtime.ts index 771307700a1..bf657d78849 100644 --- a/src/plugin-sdk/account-resolution-runtime.ts +++ b/src/plugin-sdk/account-resolution-runtime.ts @@ -1,20 +1,3 @@ export { resolveMergedAccountConfig } from "../channels/plugins/account-helpers.js"; export { resolveNormalizedAccountEntry } from "../routing/account-lookup.js"; - -/** List normalized configured account ids from a raw channel account record map. */ -export function listConfiguredAccountIds(params: { - accounts: Record | undefined; - normalizeAccountId: (accountId: string) => string; -}): string[] { - if (!params.accounts) { - return []; - } - const ids = new Set(); - for (const key of Object.keys(params.accounts)) { - if (!key) { - continue; - } - ids.add(params.normalizeAccountId(key)); - } - return [...ids]; -} +export { listConfiguredAccountIds } from "./account-configured-ids.js";