mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-14 19:40:40 +00:00
18 lines
724 B
TypeScript
18 lines
724 B
TypeScript
import type { NodeListNode, PairedNode, PairingList, PendingRequest } from "./node-list-types.js";
|
|
|
|
function asRecord(value: unknown): Record<string, unknown> {
|
|
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
|
|
}
|
|
|
|
export function parsePairingList(value: unknown): PairingList {
|
|
const obj = asRecord(value);
|
|
const pending = Array.isArray(obj.pending) ? (obj.pending as PendingRequest[]) : [];
|
|
const paired = Array.isArray(obj.paired) ? (obj.paired as PairedNode[]) : [];
|
|
return { pending, paired };
|
|
}
|
|
|
|
export function parseNodeList(value: unknown): NodeListNode[] {
|
|
const obj = asRecord(value);
|
|
return Array.isArray(obj.nodes) ? (obj.nodes as NodeListNode[]) : [];
|
|
}
|