mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:00:43 +00:00
refactor: drop unused qqbot utility exports
This commit is contained in:
@@ -49,23 +49,8 @@ export function normalizeLowercaseStringOrEmpty(value: unknown): string {
|
||||
return normalizeOptionalLowercaseString(value) ?? "";
|
||||
}
|
||||
|
||||
/** Return the raw string value or `undefined`. No trimming. */
|
||||
export function readStringValue(value: unknown): string | undefined {
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
|
||||
/** Return true when the value is a non-empty trimmed string. */
|
||||
export function hasNonEmptyString(value: unknown): value is string {
|
||||
return normalizeOptionalString(value) !== undefined;
|
||||
}
|
||||
|
||||
// ---- Record coercion ----
|
||||
|
||||
/** Coerce a value into a `Record<string, unknown>`, defaulting to `{}`. */
|
||||
export function asRecord(value: unknown): Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
|
||||
}
|
||||
|
||||
/** Coerce a value into a `Record<string, unknown>` or `undefined`. */
|
||||
export function asOptionalObjectRecord(value: unknown): Record<string, unknown> | undefined {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : undefined;
|
||||
@@ -80,37 +65,6 @@ export function readStringField(
|
||||
return typeof v === "string" ? v : undefined;
|
||||
}
|
||||
|
||||
/** Read a number field from a record. */
|
||||
export function readNumberField(
|
||||
record: Record<string, unknown> | null | undefined,
|
||||
key: string,
|
||||
): number | undefined {
|
||||
const v = record?.[key];
|
||||
return typeof v === "number" ? v : undefined;
|
||||
}
|
||||
|
||||
/** Read a boolean field from a record. */
|
||||
export function readBooleanField(
|
||||
record: Record<string, unknown> | null | undefined,
|
||||
key: string,
|
||||
): boolean | undefined {
|
||||
const v = record?.[key];
|
||||
return typeof v === "boolean" ? v : undefined;
|
||||
}
|
||||
|
||||
/** Coerce a value into a string→string map, filtering out non-string values. */
|
||||
export function readStringMap(value: unknown): Record<string, string> {
|
||||
const record = asOptionalObjectRecord(value);
|
||||
if (!record) {
|
||||
return {};
|
||||
}
|
||||
return Object.fromEntries(
|
||||
Object.entries(record).flatMap(([key, entryValue]) =>
|
||||
typeof entryValue === "string" ? [[key, entryValue]] : [],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ---- Filename normalization ----
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
/** Maximum text length for a single QQ Bot message. */
|
||||
export const TEXT_CHUNK_LIMIT = 5000;
|
||||
|
||||
/** Text chunker function signature. */
|
||||
export type ChunkTextFn = (text: string, limit: number) => string[];
|
||||
|
||||
/**
|
||||
* Naive text chunking fallback.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user