fix(api): normalize empty list responses

This commit is contained in:
zetaloop
2026-04-26 01:53:05 +08:00
parent 904148bd55
commit 30c336345e
11 changed files with 28 additions and 23 deletions
+2 -1
View File
@@ -24,7 +24,7 @@ export type ListDisputesOptions = {
}
type Paginated<T> = {
items: T[]
items: T[] | null
meta?: {
total: number
offset: number
@@ -50,6 +50,7 @@ function unwrapItems<T>(value: unknown): T[] {
if ("items" in value) {
const envelope = value as { items?: unknown }
if (Array.isArray(envelope.items)) return envelope.items as T[]
if (envelope.items === null) return []
}
throw new Error("Invalid response")
}