refactor: share trimmed list normalization in provider helpers

This commit is contained in:
Peter Steinberger 2026-03-07 23:25:39 +00:00
parent c5bd84309a
commit c9128e1f3f
4 changed files with 14 additions and 4 deletions

View File

@ -1,7 +1,11 @@
import { resolveAllowlistMatchByCandidates, type AllowlistMatch } from "openclaw/plugin-sdk/matrix"; import {
normalizeStringEntries,
resolveAllowlistMatchByCandidates,
type AllowlistMatch,
} from "openclaw/plugin-sdk/matrix";
function normalizeAllowList(list?: Array<string | number>) { function normalizeAllowList(list?: Array<string | number>) {
return (list ?? []).map((entry) => String(entry).trim()).filter(Boolean); return normalizeStringEntries(list);
} }
function normalizeMatrixUser(raw?: string | null): string { function normalizeMatrixUser(raw?: string | null): string {

View File

@ -1,4 +1,8 @@
import type { BaseProbeResult, MSTeamsConfig } from "openclaw/plugin-sdk/msteams"; import {
normalizeStringEntries,
type BaseProbeResult,
type MSTeamsConfig,
} from "openclaw/plugin-sdk/msteams";
import { formatUnknownError } from "./errors.js"; import { formatUnknownError } from "./errors.js";
import { loadMSTeamsSdkWithAuth } from "./sdk.js"; import { loadMSTeamsSdkWithAuth } from "./sdk.js";
import { readAccessToken } from "./token-response.js"; import { readAccessToken } from "./token-response.js";
@ -35,7 +39,7 @@ function readStringArray(value: unknown): string[] | undefined {
if (!Array.isArray(value)) { if (!Array.isArray(value)) {
return undefined; return undefined;
} }
const out = value.map((entry) => String(entry).trim()).filter(Boolean); const out = normalizeStringEntries(value);
return out.length > 0 ? out : undefined; return out.length > 0 ? out : undefined;
} }

View File

@ -92,6 +92,7 @@ export {
resolveDmGroupAccessWithLists, resolveDmGroupAccessWithLists,
} from "../security/dm-policy-shared.js"; } from "../security/dm-policy-shared.js";
export { formatDocsLink } from "../terminal/links.js"; export { formatDocsLink } from "../terminal/links.js";
export { normalizeStringEntries } from "../shared/string-normalization.js";
export type { WizardPrompter } from "../wizard/prompts.js"; export type { WizardPrompter } from "../wizard/prompts.js";
export { export {
evaluateGroupRouteAccessForPolicy, evaluateGroupRouteAccessForPolicy,

View File

@ -117,3 +117,4 @@ export {
buildRuntimeAccountStatusSnapshot, buildRuntimeAccountStatusSnapshot,
createDefaultChannelRuntimeState, createDefaultChannelRuntimeState,
} from "./status-helpers.js"; } from "./status-helpers.js";
export { normalizeStringEntries } from "../shared/string-normalization.js";