@winxs/wind 0.1.2 โ†’ 0.1.6

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Winxs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Winxs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,187 +1,205 @@
1
- # ๐ŸŒฌ๏ธ Wind โ€” @winxs/wind
2
-
3
- [![npm version](https://img.shields.io/npm/v/@winxs/wind)](https://www.npmjs.com/package/@winxs/wind)
4
- [![npm downloads](https://img.shields.io/npm/dm/@winxs/wind)](https://www.npmjs.com/package/@winxs/wind)
5
- [![license](https://img.shields.io/npm/l/@winxs/wind)](LICENSE)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-ready-blue)](https://www.typescriptlang.org/)
7
- [![npm bundle size](https://img.shields.io/bundlephobia/minzip/@winxs/wind)](https://bundlephobia.com/package/@winxs/wind)
8
-
9
- **Modern HTTP orchestration client for JavaScript & TypeScript**
10
-
11
- > Axios helps you make requests.
12
- > **Wind helps you manage flows.**
13
-
14
- **Wind** is a modern HTTP orchestration client for JavaScript and TypeScript.
15
-
16
- > Axios helps you make requests.
17
- > **Wind helps you manage flows.**
18
-
19
- Wind is built for **real-world APIs** โ€” pagination, retries, batching, circuit breakers, and failure-safe third-party integrations.
20
-
21
- ---
22
-
23
- ## โœจ Why Wind?
24
-
25
- Most HTTP clients stop at `request โ†’ response`.
26
-
27
- In real systems you also need:
28
-
29
- - Pagination without writing loops
30
- - Safe retries
31
- - Partial-failure batch calls
32
- - Protection against unstable third-party APIs
33
- - Worker & SSR-friendly (no global state, isolated clients)
34
- > โš ๏ธ For SSR or workers, always create a new client using `wind()` or `windClient`.
35
-
36
-
37
- **Wind provides these as first-class primitives.**
38
-
39
- ---
40
-
41
- ## ๐Ÿš€ Features
42
-
43
- - โšก **Simple API** (Axios-style defaults)
44
- - ๐Ÿ” **Built-in retry support**
45
- - ๐Ÿ”Œ **Circuit breaker** for failing APIs
46
- - ๐Ÿ“„ **Pagination as async iterators**
47
- - ๐Ÿ“ฆ **Batch requests with partial failures**
48
- - ๐Ÿงต **Worker & SSR safe** (no global mutation)
49
- - ๐Ÿชถ **Lightweight & dependency-minimal**
50
-
51
- ### ๐ŸŒ Runtime Environments
52
-
53
- Wind is designed to run in:
54
-
55
- - Browsers
56
- - Node.js (18+)
57
- - Workers / Edge runtimes
58
-
59
- > Wind does not rely on global mutable state,
60
- making it safe for concurrent and isolated environments.
61
-
62
- ---
63
-
64
- ## ๐Ÿ“ฆ Installation
65
-
66
- ```bash
67
- npm install @winxs/wind
68
- ```
69
- ## ๐Ÿงฉ Usage
70
- ### 1๏ธโƒฃ Quick (Axios-style)
71
- ```ts
72
-
73
- import wind from "@winxs/wind";
74
- const users = await wind.get("/users");
75
- The default wind client is shared.
76
- For production, workers, or multiple APIs โ€” prefer the factory or class.
77
- ```
78
-
79
- ### 2๏ธโƒฃ Recommended: Factory API
80
- ```ts
81
- import { wind } from "@winxs/wind";
82
-
83
- const api = wind({
84
- baseURL: "https://api.example.com",
85
- });
86
-
87
- const users = await api.get("/users");
88
- ```
89
- ### 3๏ธโƒฃ Advanced: Isolated Client
90
- ```ts
91
- import { windClient } from "@winxs/wind";
92
-
93
- const github = new windClient("https://api.github.com");
94
-
95
- const repos = await github.get("/users/octocat/repos");
96
- ```
97
- ### ๐Ÿ” Pagination (No Loops)
98
- #### โŒ Traditional approach
99
- ```ts
100
- let page = 1;
101
- while (true) {
102
- const res = await fetch(`/users?page=${page}`);
103
- if (!res.length) break;
104
- page++;
105
- }
106
- ```
107
- ### โœ… Wind way
108
- ```ts
109
- for await (const page of api.paginate("/users")) {
110
- console.log(page);
111
- }
112
- ```
113
- * Lazy
114
- * Memory-safe
115
- * Failure-aware
116
-
117
- ### ๐Ÿ“ฆ Batch Requests (Promise.all++)
118
- #### โŒ Traditional
119
- ```ts
120
- await Promise.all([
121
- fetch("/a"),
122
- fetch("/b"),
123
- ]);
124
- ```
125
- #### โœ… Wind
126
- ```ts
127
- const { results, errors } = await api.batch(
128
- [
129
- () => api.get("/a"),
130
- () => api.get("/b"),
131
- ],
132
- { concurrency: 2 }
133
- );
134
- ```
135
- * Controlled concurrency
136
- * Partial success support
137
- * No global failures
138
-
139
- ### ๐Ÿ”Œ Circuit Breaker
140
- 1. Wind protects your system from unstable APIs.
141
- 2. Trips on network failures
142
- 3. Trips on 5xx responses
143
- 4. Trips on rate-limits (429)
144
- 5. Ignores 4xx & validation errors
145
-
146
- ```ts
147
- await api.get("/third-party"); // auto-protected
148
- ```
149
- * When the circuit is open, requests fail fast instead of cascading failures.
150
-
151
- ### ๐Ÿ” Retry Support
152
- ```ts
153
- await api.get("/unstable", {
154
- retry: {
155
- attempts: 3,
156
- },
157
- });
158
- ```
159
- * Retry happens before circuit breaker evaluation.
160
-
161
- ### ๐Ÿ”„ Axios โ†’ Wind Migration
162
- #### Axios
163
- ```ts
164
- import axios from "axios";
165
- axios.get("/users");
166
- ```
167
- #### Wind
168
- ```ts
169
- import wind from "@winxs/wind";
170
- wind.get("/users");
171
- ```
172
- #### Axios Instance
173
- ```ts
174
- const api = axios.create({ baseURL });
175
- ```
176
- #### Wind Factory
177
- ```ts
178
- const api = wind({ baseURL });
179
- ```
180
- #### Axios Pagination
181
- ```ts
182
- // manual looping
183
- ```
184
- #### Wind Pagination
185
- ```ts
186
- for await (const page of api.paginate("/users")) {}
1
+ # ๐ŸŒฌ๏ธ Wind โ€” @winxs/wind
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@winxs/wind)](https://www.npmjs.com/package/@winxs/wind)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@winxs/wind)](https://www.npmjs.com/package/@winxs/wind)
5
+ [![license](https://img.shields.io/npm/l/@winxs/wind)](LICENSE)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-ready-blue)](https://www.typescriptlang.org/)
7
+ [![npm bundle size](https://img.shields.io/bundlephobia/minzip/@winxs/wind)](https://bundlephobia.com/package/@winxs/wind)
8
+
9
+ **Modern HTTP orchestration client for JavaScript & TypeScript**
10
+
11
+ > Axios helps you make requests.
12
+ > **Wind helps you manage flows.**
13
+
14
+ **Wind** is a modern HTTP orchestration client for JavaScript and TypeScript.
15
+
16
+ > Axios helps you make requests.
17
+ > **Wind helps you manage flows.**
18
+
19
+ Wind is built for **real-world APIs** โ€” pagination, retries, batching, circuit breakers, and failure-safe third-party integrations.
20
+
21
+ ---
22
+
23
+ ## โœจ Why Wind?
24
+
25
+ Most HTTP clients stop at `request โ†’ response`.
26
+
27
+ In real systems you also need:
28
+
29
+ - Pagination without writing loops
30
+ - Safe retries
31
+ - Partial-failure batch calls
32
+ - Protection against unstable third-party APIs
33
+ - Worker & SSR-friendly (no global state, isolated clients)
34
+ > โš ๏ธ For SSR or workers, always create a new client using `wind()` or `windClient`.
35
+
36
+
37
+ **Wind provides these as first-class primitives.**
38
+
39
+ ---
40
+
41
+ ## ๐Ÿš€ Features
42
+
43
+ - โšก **Simple API** (Axios-style defaults)
44
+ - ๐Ÿ” **Built-in retry support**
45
+ - ๐Ÿ”Œ **Circuit breaker** for failing APIs
46
+ - ๐Ÿ“„ **Pagination as async iterators**
47
+ - ๐Ÿ“ฆ **Batch requests with partial failures**
48
+ - ๐Ÿงต **Worker & SSR safe** (no global mutation)
49
+ - ๐Ÿชถ **Lightweight & dependency-minimal**
50
+
51
+ ### ๐ŸŒ Runtime Environments
52
+
53
+ Wind is designed to run in:
54
+
55
+ - Browsers
56
+ - Node.js (18+)
57
+ - Workers / Edge runtimes
58
+
59
+ > Wind does not rely on global mutable state,
60
+ making it safe for concurrent and isolated environments.
61
+
62
+ ---
63
+
64
+ ## ๐Ÿ“ฆ Installation
65
+
66
+ ```bash
67
+ npm install @winxs/wind
68
+ ```
69
+ ## ๐Ÿงฉ Usage
70
+ ### 1๏ธโƒฃ Quick (Axios-style)
71
+ ```ts
72
+ import wind from "@winxs/wind";
73
+ const users = await wind.get("/users");
74
+ ```
75
+ * The default wind client is shared.
76
+ * For production, workers, or multiple APIs โ€” prefer the factory or class.
77
+
78
+ ### 2๏ธโƒฃ Recommended: Factory API
79
+ ```ts
80
+ import { wind } from "@winxs/wind";
81
+
82
+ const api = wind({
83
+ baseURL: "https://api.example.com",
84
+ });
85
+
86
+ const users = await api.get("/users");
87
+ ```
88
+ ### 3๏ธโƒฃ Advanced: Isolated Client
89
+ ```ts
90
+ import { windClient } from "@winxs/wind";
91
+
92
+ const github = new windClient("https://api.github.com");
93
+
94
+ const repos = await github.get("/users/octocat/repos");
95
+ ```
96
+ ### ๐Ÿ” Pagination (No Loops)
97
+ #### โŒ Traditional approach
98
+ ```ts
99
+ let page = 1;
100
+ while (true) {
101
+ const res = await fetch(`/users?page=${page}`);
102
+ if (!res.length) break;
103
+ page++;
104
+ }
105
+ ```
106
+ ### โœ… Wind way
107
+ #### Config :
108
+ ```ts
109
+ let config ={
110
+ FIXED_PARAMS : {'Env' : 'Prod'},
111
+ TOTAL_SIZE : 10000,
112
+ CHUNK_SIZE : 200,
113
+ stopOnEmpty : true,
114
+ options : {
115
+ method : "POST"
116
+ headers : {authorization : 'Bearer eyeacuh'}
117
+ body: {}
118
+ },
119
+ PARAMS_KEY?: {
120
+ CHUNK_PAGINATION_KEY: 'Start',
121
+ CHUNK_SIZE_KEY: 'Size'
122
+ };
123
+ }
124
+ ```
125
+ ```ts
126
+
127
+ for await (const page of api.paginate("/users", body, config)) {
128
+ console.log(page);
129
+ }
130
+ ```
131
+ * Lazy
132
+ * Memory-safe
133
+ * Failure-aware
134
+
135
+ ### ๐Ÿ“ฆ Batch Requests (Promise.all++)
136
+ #### โŒ Traditional
137
+ ```ts
138
+ await Promise.all([
139
+ fetch("/a"),
140
+ fetch("/b"),
141
+ ]);
142
+ ```
143
+ #### โœ… Wind
144
+ ```ts
145
+ const { results, errors } = await api.batch(
146
+ [
147
+ () => api.get("/a"),
148
+ () => api.get("/b"),
149
+ ],
150
+ { concurrency: 2 }
151
+ );
152
+ ```
153
+ * Controlled concurrency
154
+ * Partial success support
155
+ * No global failures
156
+
157
+ ### ๐Ÿ”Œ Circuit Breaker
158
+ 1. Wind protects your system from unstable APIs.
159
+ 2. Trips on network failures
160
+ 3. Trips on 5xx responses
161
+ 4. Trips on rate-limits (429)
162
+ 5. Ignores 4xx & validation errors
163
+
164
+ ```ts
165
+ await api.get("/third-party"); // auto-protected
166
+ ```
167
+ * When the circuit is open, requests fail fast instead of cascading failures.
168
+
169
+ ### ๐Ÿ” Retry Support
170
+ ```ts
171
+ await api.get("/unstable", {
172
+ retry: {
173
+ attempts: 3,
174
+ },
175
+ });
176
+ ```
177
+ * Retry happens before circuit breaker evaluation.
178
+
179
+ ### ๐Ÿ”„ Axios โ†’ Wind Migration
180
+ #### Axios
181
+ ```ts
182
+ import axios from "axios";
183
+ axios.get("/users");
184
+ ```
185
+ #### Wind
186
+ ```ts
187
+ import wind from "@winxs/wind";
188
+ wind.get("/users");
189
+ ```
190
+ #### Axios Instance
191
+ ```ts
192
+ const api = axios.create({ baseURL });
193
+ ```
194
+ #### Wind Factory
195
+ ```ts
196
+ const api = wind({ baseURL });
197
+ ```
198
+ #### Axios Pagination
199
+ ```ts
200
+ // manual looping
201
+ ```
202
+ #### Wind Pagination
203
+ ```ts
204
+ for await (const page of api.paginate("/users", body, config)) {}
187
205
  ```
@@ -95,14 +95,18 @@ async function coreRequest(url, options) {
95
95
  async function withRetry(fn, options) {
96
96
  const {
97
97
  attempts,
98
- backOffMs = 300,
98
+ backOffMs = 3e4,
99
99
  //5 mins
100
- retryOn = ["NETWORK", "TIMEOUT", "RATE_LIMIT", "SERVER"]
100
+ retryOn = ["NETWORK", "TIMEOUT", "RATE_LIMIT", "SERVER", "UNKNOWN"]
101
101
  } = options;
102
102
  let lastError;
103
103
  for (let i = 0; i < attempts; i++) {
104
104
  try {
105
- return await fn();
105
+ let { data, error } = await fn();
106
+ if (!!error) {
107
+ throw error;
108
+ }
109
+ return { data, error };
106
110
  } catch (err) {
107
111
  let classified = classifyError(err);
108
112
  lastError = classified;
@@ -148,11 +152,7 @@ async function* paginate(fetcher, path, body, config = {}) {
148
152
  if (Array.isArray(pages)) {
149
153
  for (const page of pages) {
150
154
  const paramsPath = `${CHUNK_PAGINATION_KEY}=${page.CHUNK_START}&${CHUNK_SIZE_KEY}=${page.CHUNK_SIZE}` + FIXED_PARAMS;
151
- let args = {
152
- ...config.options,
153
- body
154
- };
155
- const data = await fetcher(`${path}?${paramsPath}`, args);
155
+ const data = await fetcher(`${path}?${paramsPath}`, body, { ...config.options });
156
156
  if (config.stopOnEmpty !== false && (!data || Array.isArray(data) && data.length === 0)) {
157
157
  break;
158
158
  }
package/dist/esm/index.js CHANGED
@@ -67,14 +67,18 @@ async function coreRequest(url, options) {
67
67
  async function withRetry(fn, options) {
68
68
  const {
69
69
  attempts,
70
- backOffMs = 300,
70
+ backOffMs = 3e4,
71
71
  //5 mins
72
- retryOn = ["NETWORK", "TIMEOUT", "RATE_LIMIT", "SERVER"]
72
+ retryOn = ["NETWORK", "TIMEOUT", "RATE_LIMIT", "SERVER", "UNKNOWN"]
73
73
  } = options;
74
74
  let lastError;
75
75
  for (let i = 0; i < attempts; i++) {
76
76
  try {
77
- return await fn();
77
+ let { data, error } = await fn();
78
+ if (!!error) {
79
+ throw error;
80
+ }
81
+ return { data, error };
78
82
  } catch (err) {
79
83
  let classified = classifyError(err);
80
84
  lastError = classified;
@@ -120,11 +124,7 @@ async function* paginate(fetcher, path, body, config = {}) {
120
124
  if (Array.isArray(pages)) {
121
125
  for (const page of pages) {
122
126
  const paramsPath = `${CHUNK_PAGINATION_KEY}=${page.CHUNK_START}&${CHUNK_SIZE_KEY}=${page.CHUNK_SIZE}` + FIXED_PARAMS;
123
- let args = {
124
- ...config.options,
125
- body
126
- };
127
- const data = await fetcher(`${path}?${paramsPath}`, args);
127
+ const data = await fetcher(`${path}?${paramsPath}`, body, { ...config.options });
128
128
  if (config.stopOnEmpty !== false && (!data || Array.isArray(data) && data.length === 0)) {
129
129
  break;
130
130
  }
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "@winxs/wind",
3
- "version": "0.1.2",
4
- "description": "Modern HTTP orchestration client for pagination, retries, batching, and failure-safe APIs",
5
- "license": "MIT",
6
- "author": "Winxs",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "type": "module",
10
- "exports": {
11
- "import": "./dist/esm/index.js",
12
- "require": "./dist/cjs/index.cjs"
13
- },
14
- "files": [
15
- "dist",
16
- "README.md",
17
- "LICENSE"
18
- ],
19
- "scripts": {
20
- "build": "tsup"
21
- },
22
- "keywords": [
23
- "http",
24
- "fetch",
25
- "axios",
26
- "client",
27
- "pagination",
28
- "retry",
29
- "batch",
30
- "workers"
31
- ],
32
- "repository": {
33
- "type": "git",
34
- "url": "https://github.com/adirathod1822/wind"
35
- },
36
- "devDependencies": {
37
- "tsup": "^8.5.1",
38
- "typescript": "^5.9.3"
39
- }
40
- }
1
+ {
2
+ "name": "@winxs/wind",
3
+ "version": "0.1.6",
4
+ "description": "Modern HTTP orchestration client for pagination, retries, batching, and failure-safe APIs",
5
+ "license": "MIT",
6
+ "author": "Winxs",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "type": "module",
10
+ "exports": {
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/cjs/index.cjs"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup"
21
+ },
22
+ "keywords": [
23
+ "http",
24
+ "fetch",
25
+ "axios",
26
+ "client",
27
+ "pagination",
28
+ "retry",
29
+ "batch",
30
+ "workers"
31
+ ],
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/adirathod1822/wind"
35
+ },
36
+ "devDependencies": {
37
+ "tsup": "^8.5.1",
38
+ "typescript": "^5.9.3"
39
+ }
40
+ }