MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / toStringRecord

Function toStringRecord

apps/ui/src/lib/api/openapi.ts:162–176  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

160 * Throw-on-error: bridges openapi-fetch's `{ data, error, response }` shape
161 * to TanStack Query's "throw to signal failure" expectation. Runs AFTER
162 * `tokenRefresh` so a transparent retry has a chance first.
163 * ----------------------------------------------------------------------------
164 */
165
166/*
167 * The api always envelopes errors as `{ success: false, error: { code,
168 * message, fieldErrors?, timestamp } }`. The flat `IApiErrorBody` shape
169 * (no envelope) is retained as a fallback for any non-enveloped 4xx that
170 * slips through, opaque proxy errors, 502s from edge, etc., so the
171 * caller always sees a usable code/message instead of `undefined`.
172 */
173/* Keep only string-valued entries, fieldErrors is `Record<string, string>`. */
174const toStringRecord = (value: unknown): Record<string, string> | undefined => {
175 if (typeof value !== "object" || value === null) {
176 return undefined;
177 }
178
179 const out: Record<string, string> = {};

Callers 1

toErrorBodyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected