Skip to content

QueryResult

QueryResult<T, E> = { data: undefined; error: null; isError: false; isPending: true; isSuccess: false; status: "pending"; refetch: Promise<void>; } | { data: T; error: null; isError: false; isPending: false; isSuccess: true; status: "success"; refetch: Promise<void>; } | { data: T | undefined; error: E; isError: true; isPending: false; isSuccess: false; status: "error"; refetch: Promise<void>; }

Defined in: console-sdk/src/firmware/types.ts:45

The SDK’s one request-shaped read contract (SDK_PLAN.md §3.9.2). A discriminated union over status, with matching boolean flags so callers can branch on whichever reads best (status === 'success' or isSuccess) and get data narrowed to T with no non-null assertions.

The 'error' variant keeps the last-known data (stale-while-error) so a failed refresh never blanks a card that was previously populated. Every variant carries refetch() to re-run the read.

T

the successfully-loaded data shape.

E extends FirmwareError = FirmwareError

the error type on failure; defaults to FirmwareError (the only request-shaped read is firmware status).

{ data: undefined; error: null; isError: false; isPending: true; isSuccess: false; status: "pending"; refetch: Promise<void>; }

data: undefined

No data yet.

error: null

No error.

isError: false

Always false in this variant.

isPending: true

Always true in this variant.

isSuccess: false

Always false in this variant.

status: "pending"

The read is in flight and has no prior data.

refetch(): Promise<void>

Re-runs the read.

Promise<void>


{ data: T; error: null; isError: false; isPending: false; isSuccess: true; status: "success"; refetch: Promise<void>; }

data: T

The loaded data.

error: null

No error.

isError: false

Always false in this variant.

isPending: false

Always false in this variant.

isSuccess: true

Always true in this variant.

status: "success"

The read succeeded; data is populated.

refetch(): Promise<void>

Re-runs the read.

Promise<void>


{ data: T | undefined; error: E; isError: true; isPending: false; isSuccess: false; status: "error"; refetch: Promise<void>; }

data: T | undefined

Last-known data if a prior read succeeded, else undefined (stale-while-error — a failed refresh does not blank the card).

error: E

The failure.

isError: true

Always true in this variant.

isPending: false

Always false in this variant.

isSuccess: false

Always false in this variant.

status: "error"

The read failed; error is populated.

refetch(): Promise<void>

Re-runs the read.

Promise<void>