Skip to content

v3.0.0

Choose a tag to compare

@Baraka-Mulumia Baraka-Mulumia released this 22 Apr 03:59
· 32 commits to main since this release
v3.0.0
25f177a

[3.0.0] — 2026-04-22

Full architectural redesign. Pure functional TypeScript, 14 single-responsibility modules, zero runtime dependencies.

Breaking Changes

  • Content-Type removed from DEFAULT_HEADERS — set per-request via getBodyContentType() instead
  • post/put/patch body type is now the second generic parameter: post<TResponse, TBody>
  • addRequestTransform / addResponseTransform deprecated in favour of the interceptor API
  • utils.ts dissolved — its exports moved into six focused modules (url.ts, headers.ts, body.ts, response.ts, fetch.ts, errors.ts)

Added

  • Interceptor system — axios-style request/response middleware with Map-based storage, auto-increment IDs, and eject(id) / clear(). Request interceptors run LIFO; response interceptors run FIFO per retry attempt.
  • RefetchError discriminated union — per-kind fields (http, timeout, cancel, network, parse, unknown) alongside PROBLEM_CODE
  • Retry — RetryConfig per-request or instance-wide; shorthand number form; request interceptors run once before the retry loop
  • stream() — returns ApiResponse<ReadableStream<T>> with no body parsing and no retry
  • pipe() + middleware HOFs — withAuth, withTimeout, withHeaders, withBaseURL, withLogging compose onto instances without mutation
  • Sub-path exports — @mshindi-labs/refetch/retry, /middleware, /pipe (tree-shakeable)
  • Richer response body parsing — +json suffix MIME variants, application/x-www-form-urlencoded → Record<string,string>, binary MIME types → Blob, empty-body guard for 204/304/content-length: 0
  • CancelError and createCancelToken for explicit request cancellation

Changed

  • buildRefetchError moved to errors.ts; RefetchError type defined in types.ts
  • FormData Content-Type is always deleted so the browser can set the multipart boundary
  • README, CLAUDE.md, and CONTRIBUTING.md fully rewritten for v3