mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-20 13:41:30 +00:00
refactor: dedupe thread id normalizers
This commit is contained in:
@@ -24,6 +24,18 @@ export function resolvePrimaryStringValue(value: unknown): string | undefined {
|
||||
return normalizeOptionalString((value as { primary?: unknown }).primary);
|
||||
}
|
||||
|
||||
export function normalizeOptionalThreadValue(value: unknown): string | number | undefined {
|
||||
if (typeof value === "number") {
|
||||
return Number.isFinite(value) ? Math.trunc(value) : undefined;
|
||||
}
|
||||
return normalizeOptionalString(value);
|
||||
}
|
||||
|
||||
export function normalizeOptionalStringifiedId(value: unknown): string | undefined {
|
||||
const normalized = normalizeOptionalThreadValue(value);
|
||||
return normalized == null ? undefined : String(normalized);
|
||||
}
|
||||
|
||||
export function hasNonEmptyString(value: unknown): value is string {
|
||||
return normalizeOptionalString(value) !== undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user