@b3-business/cherry 0.2.5 → 0.2.7

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 (2) hide show
  1. package/README.md +24 -32
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,16 +4,17 @@
4
4
 
5
5
  A tree-shakeable, minimal API client factory. Import only the routes you need — nothing more.
6
6
 
7
- <a href="https://www.npmjs.com/package/@b3-business/cherry" target="_blank"><img src="https://img.shields.io/npm/v/@b3-business/cherry" alt="npm"></a>
8
- <a href="https://jsr.io/@b3-business/cherry" target="_blank"><img src="https://jsr.io/badges/@b3-business/cherry" alt="JSR"></a>
9
- <a href="https://github.com/b3-business/cherry" target="_blank"><img src="https://img.shields.io/badge/GitHub-b3--business%2Fcherry-blue?logo=github" alt="GitHub"></a>
7
+ [![npm](https://img.shields.io/npm/v/@b3-business/cherry)](https://www.npmjs.com/package/@b3-business/cherry)
8
+ [![JSR](https://jsr.io/badges/@b3-business/cherry)](https://jsr.io/@b3-business/cherry)
9
+ [![GitHub](https://img.shields.io/badge/GitHub-b3--business%2Fcherry-blue?logo=github)](https://github.com/b3-business/cherry)
10
10
 
11
11
  ---
12
12
 
13
- ## Latest Changelog - 0.2.5
13
+ ## Latest Changelog - 0.2.7
14
14
 
15
- - README badges now open in new tab
16
- - GitHub badge shows repo name instead of stars
15
+ - README: Reconcile documentation with actual API (`createCherryClient`, `route`, `path` tagged template)
16
+ - README: Remove unimplemented OpenAPI generator section
17
+ - Example: JSONPlaceholder now uses sub-namespaced routes (`posts.list`, `users.get`)
17
18
 
18
19
  See [CHANGELOG.md](https://github.com/b3-business/cherry/blob/main/packages/cherry/CHANGELOG.md) for full history.
19
20
 
@@ -24,10 +25,10 @@ See [CHANGELOG.md](https://github.com/b3-business/cherry/blob/main/packages/cher
24
25
  Cherry is a lightweight API client library that separates **route definitions** from the **client runtime**. Routes are plain objects with validation schemas — import only what you use, bundle only what you import.
25
26
 
26
27
  ```ts
27
- import { createClient } from "@b3b/cherry";
28
+ import { createCherryClient } from "@b3b/cherry";
28
29
  import { listZones, getZone } from "./routes/cloudflare";
29
30
 
30
- const cf = createClient({
31
+ const cf = createCherryClient({
31
32
  baseUrl: "https://api.cloudflare.com/client/v4",
32
33
  headers: () => ({ Authorization: `Bearer ${process.env.CF_TOKEN}` }),
33
34
  routes: { listZones, getZone },
@@ -96,12 +97,12 @@ deno add jsr:@b3b/cherry
96
97
 
97
98
  ```ts
98
99
  import * as v from "valibot";
99
- import { defineRoute } from "@b3b/cherry";
100
+ import { route, path, param } from "@b3b/cherry";
100
101
 
101
- export const listZones = defineRoute({
102
+ export const listZones = route({
102
103
  method: "GET",
103
- path: "/zones",
104
- params: v.object({
104
+ path: path`/zones`,
105
+ queryParams: v.object({
105
106
  account_id: v.string(),
106
107
  page: v.optional(v.number()),
107
108
  }),
@@ -114,10 +115,10 @@ export const listZones = defineRoute({
114
115
  ### 2. Create a Client
115
116
 
116
117
  ```ts
117
- import { createClient } from "@b3b/cherry";
118
+ import { createCherryClient } from "@b3b/cherry";
118
119
  import { listZones, getZone, createDnsRecord } from "./routes/cloudflare";
119
120
 
120
- const cf = createClient({
121
+ const cf = createCherryClient({
121
122
  baseUrl: "https://api.cloudflare.com/client/v4",
122
123
  headers: () => ({ Authorization: `Bearer ${process.env.CF_TOKEN}` }),
123
124
  routes: { listZones, getZone, createDnsRecord },
@@ -141,10 +142,10 @@ const zones = await cf.call(listZones, { account_id: "abc" });
141
142
  ### Dynamic Path Parameters
142
143
 
143
144
  ```ts
144
- export const getZone = defineRoute({
145
+ export const getZone = route({
145
146
  method: "GET",
146
- path: (p) => `/zones/${p.zone_id}`,
147
- params: v.object({ zone_id: v.string() }),
147
+ path: path`/zones/${param("zone_id")}`,
148
+ pathParams: v.object({ zone_id: v.string() }),
148
149
  response: v.object({ /* ... */ }),
149
150
  });
150
151
  ```
@@ -154,7 +155,7 @@ export const getZone = defineRoute({
154
155
  Replace the underlying fetch logic for logging, retries, auth refresh, etc.
155
156
 
156
157
  ```ts
157
- createClient({
158
+ createCherryClient({
158
159
  baseUrl: "...",
159
160
  fetcher: async (req) => {
160
161
  console.log(`→ ${req.init.method} ${req.url}`);
@@ -187,8 +188,11 @@ const withLogging = (fetcher: Fetcher): Fetcher =>
187
188
  return fetcher(req);
188
189
  };
189
190
 
190
- createClient({
191
- fetcher: withLogging(withRetry(defaultFetcher)),
191
+ const baseFetcher: Fetcher = (req) => fetch(req.url, req.init);
192
+
193
+ createCherryClient({
194
+ baseUrl: "...",
195
+ fetcher: withLogging(withRetry(baseFetcher)),
192
196
  });
193
197
  ```
194
198
 
@@ -204,18 +208,6 @@ createClient({
204
208
 
205
209
  ---
206
210
 
207
- ## Generating Routes from OpenAPI
208
-
209
- Cherry includes a generator that transforms OpenAPI 3.x specs into route definitions:
210
-
211
- ```bash
212
- cherry generate --input ./openapi.json --output ./routes/
213
- ```
214
-
215
- See [ARCHITECTURE.md](./agent/ARCHITECTURE.md) for generator implementation details.
216
-
217
- ---
218
-
219
211
  ## Stack
220
212
 
221
213
  - **Runtime:** Bun
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3-business/cherry",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "A tree-shakeable, minimal API client factory. Import only the routes you need — nothing more.",
5
5
  "repository": {
6
6
  "type": "git",