mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-08 06:54:24 +00:00
refactor: share trimmed list normalization in provider helpers
This commit is contained in:
@@ -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>) {
|
||||
return (list ?? []).map((entry) => String(entry).trim()).filter(Boolean);
|
||||
return normalizeStringEntries(list);
|
||||
}
|
||||
|
||||
function normalizeMatrixUser(raw?: string | null): string {
|
||||
|
||||
@@ -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 { loadMSTeamsSdkWithAuth } from "./sdk.js";
|
||||
import { readAccessToken } from "./token-response.js";
|
||||
@@ -35,7 +39,7 @@ function readStringArray(value: unknown): string[] | undefined {
|
||||
if (!Array.isArray(value)) {
|
||||
return undefined;
|
||||
}
|
||||
const out = value.map((entry) => String(entry).trim()).filter(Boolean);
|
||||
const out = normalizeStringEntries(value);
|
||||
return out.length > 0 ? out : undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ export {
|
||||
resolveDmGroupAccessWithLists,
|
||||
} from "../security/dm-policy-shared.js";
|
||||
export { formatDocsLink } from "../terminal/links.js";
|
||||
export { normalizeStringEntries } from "../shared/string-normalization.js";
|
||||
export type { WizardPrompter } from "../wizard/prompts.js";
|
||||
export {
|
||||
evaluateGroupRouteAccessForPolicy,
|
||||
|
||||
@@ -117,3 +117,4 @@ export {
|
||||
buildRuntimeAccountStatusSnapshot,
|
||||
createDefaultChannelRuntimeState,
|
||||
} from "./status-helpers.js";
|
||||
export { normalizeStringEntries } from "../shared/string-normalization.js";
|
||||
|
||||
Reference in New Issue
Block a user