@tahanabavi/typefetch 1.5.7 → 1.6.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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **TypeFetch** is a strongly typed HTTP client for TypeScript projects, built around **Zod** contracts.
4
4
 
5
- Define your API once with Zod schemas, then TypeFetch generates a fully typed client with request validation, response validation, middleware support, retries, mock data, response wrappers, token handling, and structured request support.
5
+ Define your API once with Zod schemas, then TypeFetch generates a fully typed client with request validation, response validation, middleware support, retries, mock data, response wrappers, token handling, structured request support, contract-driven API testing, CLI workflows, and report generation.
6
6
 
7
7
  ```ts
8
8
  const user = await api.user.getUser({
@@ -29,6 +29,68 @@ const user = await api.user.getUser({
29
29
  * Normalized error handling with `RichError`
30
30
  * Field-level encryption middleware
31
31
  * Backward-compatible flat request schemas
32
+ * Contract-driven API test runner
33
+ * Automatic test input generation from Zod schemas
34
+ * Schema, mock, live, and full API test modes
35
+ * Markdown, HTML, and JSON test reports
36
+ * CLI commands for project setup, endpoint listing, API testing, and release documentation
37
+ * Versioned release documentation under `docs/releases`
38
+
39
+ ---
40
+
41
+ ## What's New in v1.6.0
42
+
43
+ TypeFetch now includes a contract-driven testing layer and CLI tooling.
44
+
45
+ ### Testing runner
46
+
47
+ The testing runner can discover endpoints from your contracts, generate valid request inputs, run schema/mock/live checks, validate responses, and export reports.
48
+
49
+ Supported modes:
50
+
51
+ * `schema` — validates generated or custom request input without network calls
52
+ * `mock` — validates endpoint `mockData` against the response schema
53
+ * `live` — executes real requests through `ApiClient`
54
+ * `full` — runs schema, mock, and live phases where applicable
55
+
56
+ ### CLI
57
+
58
+ The CLI provides a simple workflow for setting up and running contract tests.
59
+
60
+ ```bash
61
+ typefetch init
62
+ typefetch test --mode full --format markdown,json,html --output ./typefetch-report/report
63
+ typefetch list
64
+ typefetch release-doc --version v1.6.0 --title "CLI & Testing Feature"
65
+ ```
66
+
67
+ ### Endpoint test metadata
68
+
69
+ Endpoints can now include optional `test` metadata for custom inputs, tags, expected errors, destructive endpoint safety, and context-based flows.
70
+
71
+ ```ts
72
+ getUserById: {
73
+ method: "GET",
74
+ path: "/users/:id",
75
+ request: z.object({
76
+ path: z.object({
77
+ id: z.string(),
78
+ }),
79
+ }),
80
+ response: z.object({
81
+ id: z.string(),
82
+ name: z.string(),
83
+ }),
84
+ test: {
85
+ tags: ["user", "smoke"],
86
+ input: {
87
+ path: {
88
+ id: "user-1",
89
+ },
90
+ },
91
+ },
92
+ }
93
+ ```
32
94
 
33
95
  ---
34
96
 
@@ -1088,21 +1150,6 @@ Invalid input fails at compile time when possible and at runtime through Zod val
1088
1150
 
1089
1151
  ---
1090
1152
 
1091
- ## Recommended Project Structure
1092
-
1093
- ```txt
1094
- src/
1095
- api/
1096
- contracts.ts
1097
- client.ts
1098
- middlewares/
1099
- logging.ts
1100
- retry.ts
1101
- cache.ts
1102
- auth.ts
1103
- encryption.ts
1104
- ```
1105
-
1106
1153
  Example:
1107
1154
 
1108
1155
  ```ts
@@ -1151,6 +1198,21 @@ const user = await api.user.getUser({
1151
1198
  expect(user.name).toBe("Taha");
1152
1199
  ```
1153
1200
 
1201
+ Contract-driven API testing can also be run through the TypeFetch CLI.
1202
+
1203
+ ```bash
1204
+ typefetch init
1205
+ typefetch test --mode schema
1206
+ typefetch test --mode mock
1207
+ typefetch test --mode live --base-url http://localhost:3000
1208
+ ```
1209
+
1210
+ Generated reports can be exported as Markdown, HTML, or JSON:
1211
+
1212
+ ```bash
1213
+ typefetch test --mode full --format markdown,json,html --output ./typefetch-report/report
1214
+ ```
1215
+
1154
1216
  Recommended test coverage:
1155
1217
 
1156
1218
  * Request validation
@@ -1171,6 +1233,20 @@ Recommended test coverage:
1171
1233
 
1172
1234
  ---
1173
1235
 
1236
+ ## Versioned Release Documentation
1237
+
1238
+ Starting with v1.6.0, detailed documentation for larger updates is stored separately under `docs/releases`.
1239
+
1240
+ The main README stays focused on quick usage and core concepts, while release files contain deeper implementation notes, migration details, CLI examples, test strategy, and full feature explanations.
1241
+
1242
+ Recommended structure:
1243
+
1244
+ ```txt
1245
+ docs/
1246
+ releases/
1247
+ v1.6.0.md
1248
+ ```
1249
+
1174
1250
  ## Notes
1175
1251
 
1176
1252
  * Always call `client.init()` before using `client.modules`.
@@ -1182,6 +1258,8 @@ Recommended test coverage:
1182
1258
  * `form-data` endpoints should use `bodyType: "form-data"`.
1183
1259
  * Auth tokens are only required for endpoints with `auth: true`.
1184
1260
  * Mock data bypasses network calls but still validates responses.
1261
+ * Use `typefetch test --mode schema` for fast contract validation.
1262
+ * Keep detailed release documentation in `docs/releases`.
1185
1263
 
1186
1264
  ---
1187
1265