mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 22:40:21 +00:00
refactor: dedupe feishu string helper
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
resolveMergedAccountConfig,
|
||||
} from "openclaw/plugin-sdk/account-resolution";
|
||||
import { coerceSecretRef } from "openclaw/plugin-sdk/provider-auth";
|
||||
import { normalizeString } from "./comment-shared.js";
|
||||
import type {
|
||||
FeishuConfig,
|
||||
FeishuAccountConfig,
|
||||
@@ -27,14 +28,6 @@ export { listFeishuAccountIds };
|
||||
type FeishuCredentialResolutionMode = "inspect" | "strict";
|
||||
type FeishuResolvedSecretRef = NonNullable<ReturnType<typeof coerceSecretRef>>;
|
||||
|
||||
function normalizeString(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const trimmed = value.trim();
|
||||
return trimmed ? trimmed : undefined;
|
||||
}
|
||||
|
||||
function formatSecretRefLabel(ref: FeishuResolvedSecretRef): string {
|
||||
return `${ref.source}:${ref.provider}:${ref.id}`;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ export function readString(value: unknown): string | undefined {
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
|
||||
export function normalizeString(value: unknown): string | undefined {
|
||||
return readString(value)?.trim() || undefined;
|
||||
}
|
||||
|
||||
export function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
@@ -17,19 +17,12 @@ import {
|
||||
resolveDefaultFeishuAccountId,
|
||||
resolveFeishuAccount,
|
||||
} from "./accounts.js";
|
||||
import { normalizeString } from "./comment-shared.js";
|
||||
import { probeFeishu } from "./probe.js";
|
||||
import type { FeishuAccountConfig, FeishuConfig } from "./types.js";
|
||||
|
||||
const channel = "feishu" as const;
|
||||
|
||||
function normalizeString(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const trimmed = value.trim();
|
||||
return trimmed || undefined;
|
||||
}
|
||||
|
||||
type ScopedFeishuConfig = Partial<FeishuConfig> & Partial<FeishuAccountConfig>;
|
||||
|
||||
function getScopedFeishuConfig(cfg: OpenClawConfig, accountId: string): ScopedFeishuConfig {
|
||||
|
||||
Reference in New Issue
Block a user