Skip to content

Releases: mshindi-labs/refetch

v3.2.0

Choose a tag to compare

@github-actions github-actions released this 20 Oct 22:07
9a534de

3.2.0 (2026-10-20)

Features

  • retry: honour Retry-After, add back-off strategies, jitter, method and status allow-lists (#42) (73924c6), closes #11

v3.1.2

Choose a tag to compare

@github-actions github-actions released this 20 Oct 21:53
e6f8137

3.1.2 (2026-10-20)

Bug Fixes

  • keep Headers-shaped request headers in middleware and serialise query params safely (#40) (f03e4f6)

v3.1.1

Choose a tag to compare

@github-actions github-actions released this 20 Oct 21:42
32787c4

3.1.1 (2026-10-20)

Bug Fixes

  • report parse failures, never throw from interceptors, send stream bodies with duplex (4a4cffb)
  • report parse failures, never throw from interceptors, send stream bodies with duplex (05bf41c), closes #5 #6 #7

v3.1.0

Choose a tag to compare

@github-actions github-actions released this 20 Oct 21:11
d52c803

3.1.0 (2026-10-20)

Bug Fixes

  • fetch: typed timeout/transport errors, honoured cancellation, body-read timeout (1db8251)
  • fetch: typed timeout/transport errors, honoured cancellation, body-read timeout (c70bff5), closes #2 #3 #4 #10
  • package: resolve CJS types, add sideEffects and metadata, raise engines (62019f7)
  • package: resolve CJS types, add sideEffects and metadata, raise engines (e9b59ef), closes #14

Continuous Integration

  • release: automate versioning, changelog and npm publishing with release-please (b88f3be), closes #33

v3.0.0

Choose a tag to compare

@Baraka-Mulumia Baraka-Mulumia released this 22 Apr 03:59
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

v2.0.10

Choose a tag to compare

@mshindi-labs mshindi-labs released this 02 Nov 09:33

Full Changelog: v2.0.8...v2.0.10

v2.0.7

Choose a tag to compare

@mshindi-labs mshindi-labs released this 01 Nov 08:48

fix: prevent config spread from overriding merged headers
Fixed a critical bug where DEFAULT_HEADERS (Content-Type: application/json)
were being stripped from requests.

Problem

The spread operator ...config at the end of fetchConfig construction was
overriding the carefully merged headers. Since config contained headers from
state.config (an empty Headers object for new instances), it would replace
our merged headers with an empty object.

Solution

Moved the ...config spread to the beginning of the fetchConfig object,
then explicitly override with our processed values (method, headers, body, timeout).
This ensures our merged headers always take precedence.

Testing

Verified with httpbin.org:

  • ✅ JSON POST requests now correctly have Content-Type: application/json
  • ✅ FormData requests still correctly have multipart/form-data with boundary
  • ✅ All other request types working as expected

Impact

  • Fixes JSON API calls not working correctly due to missing Content-Type
  • Maintains FormData/URLSearchParams behavior (skips JSON headers)
  • No breaking changes to API surface

v2.0.6

Choose a tag to compare

@mshindi-labs mshindi-labs released this 01 Nov 08:48

feat!: major optimizations, bug fixes, and new HTTP methods
This commit introduces significant improvements to code quality, bundle size,
and API completeness while fixing critical bugs.

Critical Bug Fixes

  • Fixed DEFAULT_HEADERS being incorrectly applied to FormData and URLSearchParams

    • File uploads and form submissions now work correctly
    • JSON headers are now conditionally applied based on body type
    • Fixes issue where multipart/form-data was being overridden
  • Fixed inconsistent error response handling

    • All error paths now use normalizeErrorResponse() consistently
    • Ensures uniform response structure across HTTP and network errors
    • Removed manual error response construction

New Features

  • Added LINK and UNLINK HTTP methods for resource linking scenarios
  • Added any() generic request method for custom HTTP verbs (PROPFIND, MKCOL, etc.)
  • Added getBaseURL() method for base URL introspection
  • Complete feature parity with apisauce API

Code Quality Improvements

  • Extracted duplicate query parameter building logic into buildQueryString() helper

    • Eliminated ~30 lines of code duplication
    • Improved maintainability and reduced bug surface area
  • Simplified header management by normalizing to Headers class

    • Reduced setHeader() from 19 lines to 3 lines
    • Reduced deleteHeader() from 12 lines to 3 lines
    • Eliminated complex branching logic for header format handling
  • Removed redundant PROBLEM_CODES constant (use PROBLEM_CODE enum directly)

  • Removed unused ERROR_MESSAGES constants, inlined single usage

  • Cleaned up imports, removing unused classifyProblem and headersToObject

Bundle Size Optimizations

  • Enabled minification in tsup.config.ts
  • Reduced bundle size to ~2.3 KB gzipped (40% smaller than v2.0.2)
  • Removed ~80+ lines of code through refactoring
  • Better tree-shaking support

Documentation

  • Updated README.md with new HTTP methods and getBaseURL() usage
  • Documented v2.0.3 optimizations and bug fixes
  • Removed apisauce comparison table, added "Why Refetch?" section
  • Added comprehensive examples for LINK, UNLINK, and any() methods

Performance

  • No runtime performance impact, only build-time improvements
  • Smaller bundle size means faster downloads and parsing
  • Cleaner code leads to better maintainability

Files Changed

  • src/utils.ts: Extracted buildQueryString(), removed duplicate code
  • src/refetch.ts: Fixed DEFAULT_HEADERS bug, added new HTTP methods, simplified headers
  • src/constants.ts: Removed PROBLEM_CODES and ERROR_MESSAGES
  • src/types.ts: Added type definitions for new methods
  • src/index.ts: Removed PROBLEM_CODES export
  • tsup.config.ts: Enabled minification
  • README.md: Updated documentation
  • apisauce.md: Added reference documentation

v2.0.2

Choose a tag to compare

@mshindi-labs mshindi-labs released this 30 Oct 18:52

Initial commit: refetch HTTP client library
Add lightweight, apisauce-inspired HTTP client built on native fetch API with full TypeScript support.

Features:

  • Native fetch API wrapper with standardized response format
  • Request/response transforms (sync & async)
  • Response monitors for logging/analytics
  • Timeout support via AbortController
  • Error classification with PROBLEM_CODE enum
  • Full TypeScript support with generics
  • Dual package format (ESM + CommonJS)

Build infrastructure:

  • tsup for fast bundling with dual format output
  • TypeScript declarations generation
  • Source maps for debugging

Package configuration:

  • Scoped package: @mshindi-labs/refetch
  • MIT licensed
  • Node.js 18+ required
  • Comprehensive README with examples

Co-Authored-By: Mshindi Labs INC 184962783+mshindi-labs@users.noreply.github.com