You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+85Lines changed: 85 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,91 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [2.0.0] - 2025-12-14
9
+
10
+
### ⚠️ Breaking Changes
11
+
12
+
-**Removed legacy API support** - The deprecated `requiredProps`, `defaultProps`, `pathParams`, and `queryParams` options have been completely removed. You must use the unified `options` array instead.
13
+
-**Path params are now auto-extracted** - Path parameters are automatically extracted from the endpoint string (e.g., `/users/:userId`). You no longer need to define them.
14
+
-**Function names are auto-generated** - Function names are now automatically generated from the HTTP method:
15
+
-`GET` → `fetchData`
16
+
-`POST` → `postData`
17
+
-`PUT` → `putData`
18
+
-`PATCH` → `patchData`
19
+
-`DELETE` → `deleteData`
20
+
-**New function signature** - Functions now accept grouped parameters:
21
+
```typescript
22
+
fetchData({
23
+
path: { userId: "123" },
24
+
header: { Authorization: "Bearer token" },
25
+
body: { name: "John" },
26
+
query: { lang: "en" }
27
+
})
28
+
```
29
+
-**Endpoint is now string only** - The `endpoint` property no longer accepts functions, only strings.
30
+
31
+
### Added
32
+
33
+
-**Unified `options` array configuration** - New unified way to define API parameters using a single `options` array
34
+
-`ParamLocation` type with support for `"query"`, `"header"`, and `"body"` locations (path params are auto-extracted)
35
+
-`ApiParam<T>` interface for type-safe parameter definitions
36
+
-`param<T>()` helper function for improved TypeScript type inference
37
+
- Support for header parameters via the options array
38
+
- Support for body parameters via the options array
39
+
-**Automatic path parameter extraction** - Path params are automatically extracted from endpoint strings (e.g., `/users/:userId`)
40
+
-**Automatic function name generation** - Function names are auto-generated from HTTP methods
41
+
-**Grouped parameter structure** - Parameters are now passed grouped by location (`path`, `header`, `body`, `query`)
42
+
-**Simplified parameter requirements** - Options with `defaultValue` are always optional (implicit), reducing boilerplate
43
+
44
+
### Changed
45
+
46
+
- Improved type inference for parameter values using the `valueType` property in `ApiParam`
47
+
- Better organization of parameter configuration - each parameter is now defined once with all its properties
48
+
- Function calls now use grouped parameters for better clarity and organization
49
+
50
+
### Example Migration
51
+
52
+
**Before (v1.x):**
53
+
```typescript
54
+
const useGetUser =createApiHook({
55
+
method: "GET",
56
+
baseURL: "https://api.example.com",
57
+
endpoint: "/users/:userId",
58
+
requiredProps: ["userId"],
59
+
defaultProps: { lang: "en_US" },
60
+
pathParams: ["userId"],
61
+
queryParams: ["lang"],
62
+
});
63
+
64
+
// Usage
65
+
fetchData({ userId: "123", lang: "es_ES" });
66
+
```
67
+
68
+
**After (v2.0.0):**
69
+
```typescript
70
+
const useGetUser =createApiHook({
71
+
method: "GET",
72
+
baseURL: "https://api.example.com",
73
+
endpoint: "/users/:userId",
74
+
// Path params are automatically extracted from endpoint
0 commit comments