@zap-studio/fetch 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +10 -0
  3. package/package.json +11 -3
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.1.1]
8
+
9
+ ### Changed
10
+
11
+ `@zap-studio/logger` is now an optional peer dependency instead of a regular dependency. Every import from it is type-only (`import type { Logger }`), so it was never pulled in at runtime — pass any object matching the `Logger` shape (including `pino`) with no install required. Existing consumers of `logger?: Logger` are unaffected.
12
+
7
13
  ## [1.1.0]
8
14
 
9
15
  ### Added
package/README.md CHANGED
@@ -4,6 +4,16 @@ A small fetch wrapper with [**Standard Schema**](https://standardschema.dev/sche
4
4
 
5
5
  Full documentation: [zapstudio.dev/fetch](https://www.zapstudio.dev/fetch)
6
6
 
7
+ ## Motivation
8
+
9
+ Raw `fetch` does not throw on HTTP errors like 404 or 500 — you must check `response.ok` yourself. And it does not check that the JSON body matches what your code expects.
10
+
11
+ So most projects add the same pattern at every call site: check the status, parse the JSON, then validate it with `schema.parse(await res.json())`. It is easy to forget one of these steps somewhere, and that is how bad data or a network error goes unnoticed until it breaks something downstream.
12
+
13
+ `@zap-studio/fetch` makes this pattern the default, not something you write by hand. `api.get(url, UserSchema)` checks the response, validates the body, and throws a clear, typed error — `FetchError` for a bad HTTP status, `ValidationError` for a bad shape — so you always know what went wrong and where.
14
+
15
+ It uses [Standard Schema](https://standardschema.dev/schema), so you are not locked into one validation library: start with Zod, move to Valibot later, and the call sites do not change. And because it only wraps the global `fetch` function, it is not a Node-only HTTP client — it runs the same way on Bun, Deno, Cloudflare Workers, and in the browser.
16
+
7
17
  ## Installation
8
18
 
9
19
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zap-studio/fetch",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "private": false,
5
5
  "description": "A type-safe, tree-shakeable fetch wrapper for HTTP requests with runtime schema validation.",
6
6
  "keywords": [
@@ -46,8 +46,7 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@zap-studio/validation": "1.0.0",
50
- "@zap-studio/logger": "1.0.0"
49
+ "@zap-studio/validation": "1.0.0"
51
50
  },
52
51
  "devDependencies": {
53
52
  "arktype": "^2.2.3",
@@ -56,8 +55,17 @@
56
55
  "valibot": "^1.4.2",
57
56
  "vitest": "^4.1.10",
58
57
  "zod": "^4.4.3",
58
+ "@zap-studio/logger": "1.0.0",
59
59
  "@zap-studio/typescript": "0.0.0"
60
60
  },
61
+ "peerDependencies": {
62
+ "@zap-studio/logger": "1.0.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@zap-studio/logger": {
66
+ "optional": true
67
+ }
68
+ },
61
69
  "engines": {
62
70
  "node": ">=18.0.0"
63
71
  }