v6.0.0
v6.0.0
Major release with improved error handling, new endpoints, and Zod v4.
Highlights
- Updated to Zod v4.
- Added v2 Trades routes.
- Regenerated and refreshed all endpoints.
- Strongly-typed, first-class error handling across the client.
Breaking changes
- fetchApi return types
- Default: now returns a union of success or error.
- Before: assumed success or returned ad‑hoc error strings.
- Now:
Promise<ExtractResponse<S> | AnyError>.
- With
throwOnError: true(and notreturnRaw: true): only returns success, throws on errors.Promise<ExtractResponse<S>>.
- With
returnRaw: true: returns raw response wrapper (and bypasses error parsing).Promise<TypedJsonResponse<ExtractResponse<S>>>.
- Default: now returns a union of success or error.
- fetchApiSplit type
- Now:
Promise<T[] | AnyError>(notArray<T | AnyError>).
- Now:
- fetchApiPages type
- Now:
Promise<ExtractResponse<S>[] | AnyError>. - Generator
fetchApiPagesGenerator: yieldsExtractResponse<S> | AnyError.
- Now:
- Error mapping via
endpoint.errorsno longer returns description strings. Errors are returned as structuredAnyErroror thrown (whenthrowOnErroris used).
New exports
isAnyErrorResponse(value): value is AnyErrorAnyErrortype
Error handling improvements
- Error parsing uses
parse-roblox-errors:- For
roblox.comendpoints:apis.roblox.com→parseBEDEV2Error- other
roblox.com→parseBEDEV1Error
- Non‑Roblox domains: generic textual
AnyError(best effort from JSON/text).
- For
- Only successful responses are cached.
returnRaw: trueshort-circuits before error parsing and returns the raw response.
Migration guide
-
Default usage (non-throwing):
const res = await fetchApi(myEndpoint, params); if (isAnyErrorResponse(res)) { // handle AnyError console.error(res.message); return; } // res is the success payload here
-
Throwing flow (recommended for happy-path code):
const data = await fetchApi(myEndpoint, params, { throwOnError: true }); // data is the success payload, errors throw
-
Raw flow (no error parsing, inspect the Response yourself):
const resp = await fetchApi(myEndpoint, params, { returnRaw: true }); const json = await resp.json();
-
Split and pages helpers:
fetchApiSplit: nowT[] | AnyErrorconst res = await fetchApiSplit(ep, params, { items: 100 }, r => r.data); if (isAnyErrorResponse(res)) { /* error */ } else { /* res is T[] */ }
fetchApiPages: nowExtractResponse<S>[] | AnyErrorconst pages = await fetchApiPages(ep, params); if (isAnyErrorResponse(pages)) { /* error */ } else { /* pages is array */ }
Endpoint updates
- Added v2 Trades routes.
- Regenerated all endpoints from the latest specs (names, params, and response types may have shifted to match upstream).
Zod v4
- Upgraded to Zod v4. Ensure your consumers and build pipeline are compatible with Zod v4.
Notes
- For non‑throwing code, prefer the
isAnyErrorResponseguard for type‑safe error branching. - For throwing code, use
{ throwOnError: true }to keep your code linear and avoid unions. - For custom error handling/parsing, use
{ returnRaw: true }and handle theResponsedirectly.
Full Changelog: v5.0.0...v6.0.0