veloxis 1.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AngelitoSystems
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
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # Veloxis 🚀
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Strongly%20Typed-blue.svg)](https://www.typescriptlang.org/)
5
+ [![Performance](https://img.shields.io/badge/Performance-Ultra%20Fast-green.svg)](#benchmarks)
6
+
7
+ **Veloxis** is a modern, ultra-fast HTTP and GraphQL client designed for Node.js and browser environments. Built with a focus on performance, modularity, and TypeScript first-class support.
8
+
9
+ ## Key Features
10
+
11
+ - ⚡ **Ultra Fast**: Minimal abstraction layers over native `fetch`.
12
+ - 🧩 **Modular Architecture**: Use only what you need.
13
+ - 📡 **REST + GraphQL**: First-class support for both, with a unified API.
14
+ - 🔌 **Plugin System**: Powerful middleware hooks for requests, responses, and errors.
15
+ - 📦 **Built-in Plugins**: Includes Retry (exponential backoff), Cache (TTL), and Auth.
16
+ - 📄 **Advanced Pagination**: Reusable utility for cursor and offset-based pagination.
17
+ - 🛡️ **Strongly Typed**: Full generic support for all requests and responses.
18
+ - 🚦 **Interceptors**: Async request/response interceptors similar to Axios.
19
+ - ⏱️ **Timeout Control**: Built-in support via `AbortController`.
20
+ - 👯 **Request Deduplication**: Avoid redundant simultaneous calls.
21
+
22
+ ## Comparison with Other Clients
23
+
24
+ | Feature | Veloxis | Axios | Native Fetch |
25
+ |---------|---------|-------|--------------|
26
+ | **Engine** | Native Fetch | XHR / Node HTTP | Native |
27
+ | **GraphQL Support** | ✅ Built-in | ❌ (Manual POST) | ❌ (Manual POST) |
28
+ | **Plugin System** | ✅ Advanced Hooks | ❌ (Interceptors only) | ❌ |
29
+ | **Bundle Size** | 🚀 ~2kb (gzipped) | 📦 ~10kb (gzipped) | 0kb |
30
+ | **TypeScript** | 🔥 First-class | ✅ Good | ⚠️ Manual Types |
31
+ | **Auto-Retries** | ✅ Plugin (Backoff) | ❌ (Plugin required) | ❌ |
32
+ | **Pagination** | ✅ Built-in Utility | ❌ | ❌ |
33
+ | **Deduplication** | ✅ Built-in | ❌ | ❌ |
34
+
35
+ ### Why choose Veloxis over Axios?
36
+ - **Modernity**: Axios uses legacy XHR under the hood in browsers. Veloxis leverages native `fetch` and modern ESM architecture.
37
+ - **Speed**: Minimal abstraction layers mean Veloxis has significantly lower execution overhead.
38
+ - **All-in-One**: First-class GraphQL support and advanced pagination utilities are included, not afterthoughts.
39
+ - **Modularity**: Veloxis's plugin system is more flexible than interceptors alone, allowing plugins to handle their own error recovery and retry logic seamlessly.
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ bun add veloxis
45
+ # or
46
+ npm install veloxis
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ### REST Request
52
+ ```typescript
53
+ import veloxis from 'veloxis';
54
+
55
+ const { data } = await veloxis.get('https://api.example.com/posts/1');
56
+ console.log(data.title);
57
+ ```
58
+
59
+ ### GraphQL Query
60
+ ```typescript
61
+ const data = await veloxis.graphql<Country>('https://countries.trevorblades.com/', {
62
+ query: 'query { country(code: "BR") { name } }'
63
+ });
64
+ console.log(data.country.name);
65
+ ```
66
+
67
+ ### Using Plugins
68
+ ```typescript
69
+ import { Veloxis, retryPlugin, cachePlugin } from 'veloxis';
70
+
71
+ const api = new Veloxis();
72
+ api.use(retryPlugin());
73
+ api.use(cachePlugin(60000));
74
+
75
+ // Request with cache enabled
76
+ await api.get('/api/data', { cache: true });
77
+ ```
78
+
79
+ ## Documentation & Examples
80
+
81
+ Detailed documentation is available in the [`/docs`](/docs) folder:
82
+ - [Getting Started](/docs/getting-started.md)
83
+ - [REST API](/docs/rest.md)
84
+ - [GraphQL](/docs/graphql.md)
85
+ - [Plugins](/docs/plugins.md)
86
+ - [Pagination](/docs/pagination.md)
87
+ - [Error Handling](/docs/errors.md)
88
+
89
+ Explore practical code in the [`/examples`](/examples) folder.
90
+
91
+ ## Tests
92
+
93
+ Veloxis is fully covered by unit and integration tests using **Bun test**. To run them:
94
+
95
+ ```bash
96
+ bun test
97
+ ```
98
+ See [Testing Documentation](/docs/testing.md) for more details.
99
+
100
+ ## Benchmarks
101
+
102
+ Performance is at the heart of Veloxis. We've implemented explicit benchmarks to measure execution overhead and comparison against standard fetch usage.
103
+
104
+ ### Running Benchmarks
105
+ ```bash
106
+ bun run bench
107
+ ```
108
+
109
+ **What we measure:**
110
+ - **Execution Overhead**: The library's internal processing time vs raw fetch.
111
+ - **Plugin Impact**: The cost of stacking multiple middlewares.
112
+ - **GraphQL Parsing**: Speed of structured GraphQL vs manual POST.
113
+
114
+ Our goal is to remain as close to native `fetch` speed as possible while providing a rich feature set. See [Benchmarks Documentation](/docs/benchmarks.md).
115
+
116
+ ## Project Structure
117
+
118
+ ```text
119
+ src/ # Source code (modular)
120
+ docs/ # Detailed documentation
121
+ examples/ # Practical usage examples
122
+ tests/ # Unit and integration tests
123
+ benchmarks/ # Performance measurement files
124
+ ```
125
+
126
+ ## License
127
+
128
+ MIT © AngelitoSystems
@@ -0,0 +1,38 @@
1
+ import type { VeloxisRequestConfig, VeloxisResponse, VeloxisInterceptor, VeloxisPlugin, GraphQLOptions } from '../types';
2
+ /**
3
+ * The main Veloxis HTTP Client.
4
+ */
5
+ export declare class Veloxis {
6
+ private defaults;
7
+ private interceptors;
8
+ private plugins;
9
+ constructor(options?: VeloxisRequestConfig);
10
+ /**
11
+ * Registers a plugin.
12
+ */
13
+ use(plugin: VeloxisPlugin): this;
14
+ /**
15
+ * Adds an interceptor.
16
+ */
17
+ intercept(type: 'request' | 'response', interceptor: VeloxisInterceptor<any>): this;
18
+ get<T = any>(url: string, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>>;
19
+ post<T = any>(url: string, data?: any, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>>;
20
+ put<T = any>(url: string, data?: any, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>>;
21
+ delete<T = any>(url: string, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>>;
22
+ /**
23
+ * GraphQL request method.
24
+ */
25
+ graphql<T = any, V = any>(url: string, options: GraphQLOptions<V>, config?: VeloxisRequestConfig): Promise<T>;
26
+ /**
27
+ * Orchestrates the entire request/response lifecycle.
28
+ */
29
+ request<T = any>(config: VeloxisRequestConfig): Promise<VeloxisResponse<T>>;
30
+ /**
31
+ * Executes the actual fetch and processes the response.
32
+ */
33
+ private performRequest;
34
+ /**
35
+ * Handles errors through plugins and interceptors.
36
+ */
37
+ private handleError;
38
+ }
@@ -0,0 +1,5 @@
1
+ import type { VeloxisRequestConfig } from '../types';
2
+ /**
3
+ * Executes the native fetch call with the provided configuration.
4
+ */
5
+ export declare function executeFetch(url: string, config: VeloxisRequestConfig): Promise<Response>;
@@ -0,0 +1,5 @@
1
+ import type { VeloxisRequestConfig, VeloxisResponse } from '../types';
2
+ /**
3
+ * Parses the raw Fetch Response and wraps it in a VeloxisResponse.
4
+ */
5
+ export declare function parseResponse<T = any>(response: Response, config: VeloxisRequestConfig): Promise<VeloxisResponse<T>>;
@@ -0,0 +1,6 @@
1
+ import type { Veloxis } from '../core/client';
2
+ import type { GraphQLOptions, VeloxisRequestConfig } from '../types';
3
+ /**
4
+ * Helper to handle GraphQL requests using a Veloxis client instance.
5
+ */
6
+ export declare function performGraphQLRequest<T = any, V = any>(client: Veloxis, url: string, options: GraphQLOptions<V>, config?: VeloxisRequestConfig): Promise<T>;
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ class O extends Error{config;response;status;code;constructor(J,z,P,S){super(J);this.name="VeloxisError",this.config=z,this.code=P,this.response=S,this.status=S?.status,Object.setPrototypeOf(this,O.prototype)}toJSON(){return{message:this.message,name:this.name,code:this.code,status:this.status,config:this.config}}}function Y(J,z){if(!J)return z||"";if(!z)return J;return J.replace(/\/+$/,"")+"/"+z.replace(/^\/+/,"")}function Z(J,z){if(!z||Object.keys(z).length===0)return J;let P=new URLSearchParams;Object.entries(z).forEach(([T,B])=>{if(B!==void 0&&B!==null)P.append(T,String(B))});let S=P.toString();return S?`${J}${J.includes("?")?"&":"?"}${S}`:J}var Q={pending:new Map,generateKey(J){return`${J.method}:${J.url}:${JSON.stringify(J.params)}:${JSON.stringify(J.data)}`}};function N(J,...z){if(J.debug)console.log("[Veloxis][DEBUG]",...z)}async function _(J,z){let P=new AbortController,{signal:S}=P;if(z.signal)z.signal.addEventListener("abort",()=>P.abort());let T;if(z.timeout)T=setTimeout(()=>P.abort("timeout"),z.timeout);let B={method:z.method||"GET",headers:new Headers(z.headers),body:z.data?typeof z.data==="object"?JSON.stringify(z.data):z.data:void 0,signal:S};try{N(z,`Request: ${z.method} ${J}`);let H=await fetch(J,B);if(T)clearTimeout(T);return H}catch(H){if(T)clearTimeout(T);if(H.name==="AbortError"||H==="timeout")throw new O(z.timeout?`Request timed out after ${z.timeout}ms`:"Request aborted",z,"TIMEOUT");throw new O(H.message,z,"NETWORK_ERROR")}}function $(J){let z=J.get("content-type");return!!z&&z.includes("application/json")}async function j(J,z){let P;try{if($(J.headers))P=await J.json();else P=await J.text()}catch(T){P={}}let S={data:P,status:J.status,statusText:J.statusText,headers:J.headers,config:z};if(!J.ok)throw new O(`Request failed with status ${J.status}`,z,"BAD_STATUS",S);return N(z,`Response: ${J.status} ${z.url}`),S}class W{defaults;interceptors={request:[],response:[]};plugins=[];constructor(J={}){this.defaults={timeout:0,headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json"},...J}}use(J){return this.plugins.push(J),this}intercept(J,z){return this.interceptors[J].push(z),this}async get(J,z){return this.request({...z,url:J,method:"GET"})}async post(J,z,P){return this.request({...P,url:J,method:"POST",data:z})}async put(J,z,P){return this.request({...P,url:J,method:"PUT",data:z})}async delete(J,z){return this.request({...z,url:J,method:"DELETE"})}async graphql(J,z,P){let S=await this.post(J,{query:z.query,variables:z.variables,operationName:z.operationName},P);if(S.data.errors)throw new O("GraphQL Error",S.config,"GRAPHQL_ERROR",S);return S.data.data}async request(J){let z={...this.defaults,...J,headers:{...this.defaults.headers,...J.headers}};try{for(let B of this.plugins)if(B.onBeforeRequest){let H=await B.onBeforeRequest(z);if(H)z=H;if(z._cachedResponse)return z._cachedResponse}for(let B of this.interceptors.request)if(B.fulfilled)z=await B.fulfilled(z);let P=Z(Y(z.baseURL,z.url),z.params),S=Q.generateKey(z);if(z.dedupe&&Q.pending.has(S))return N(z,`Deduplicating request: ${P}`),Q.pending.get(S);let T=this.performRequest(P,z);if(z.dedupe)Q.pending.set(S,T),T.finally(()=>Q.pending.delete(S));return await T}catch(P){return this.handleError(P)}}async performRequest(J,z){let P=await _(J,z),S=await j(P,z);for(let T of this.plugins)if(T.onAfterResponse){let B=await T.onAfterResponse(S);if(B)S=B}for(let T of this.interceptors.response)if(T.fulfilled)S=await T.fulfilled(S);return S}async handleError(J){let z=J;for(let P of this.plugins)if(P.onError)try{let S=await P.onError(z);if(S&&!(S instanceof Error)&&typeof S==="object")return this.request(S);if(S instanceof Error)z=S}catch(S){z=S}for(let P of this.interceptors.response)if(P.rejected)try{z=await P.rejected(z)}catch(S){z=S}throw z}}class k{config;state;fetchPromise=null;constructor(J){this.config={pageSize:10,initialParams:{},transform:(z)=>z,dedupeKey:(z)=>z.id??JSON.stringify(z),...J},this.state=this.getInitialState()}getInitialState(){return{items:[],accumulatedItems:[],isLoading:!1,error:null,currentPage:0,currentCursor:null,hasMore:!0}}reset(){this.state=this.getInitialState(),this.fetchPromise=null}async next(){if(!this.state.hasMore||this.state.isLoading)return this.state.items;if(this.fetchPromise)return(await this.fetchPromise).items;this.state.isLoading=!0,this.state.error=null;let J=this.buildParams();try{this.fetchPromise=this.config.fetch(J);let z=await this.fetchPromise,P=this.config.transform(z.items);return this.state.items=P,this.updateAccumulated(P),this.state.hasMore=z.hasMore,this.state.currentCursor=z.nextCursor??null,this.state.currentPage++,P}catch(z){throw this.state.error=z,z}finally{this.state.isLoading=!1,this.fetchPromise=null}}async all(J=50){let z=0;while(this.state.hasMore&&z<J)await this.next(),z++;return this.state.accumulatedItems}buildParams(){let J={...this.config.initialParams};if(this.config.type==="offset")return{...J,limit:this.config.pageSize,offset:this.state.currentPage*this.config.pageSize};else return{...J,first:this.config.pageSize,after:this.state.currentCursor}}updateAccumulated(J){let z=new Set(this.state.accumulatedItems.map(this.config.dedupeKey)),P=J.filter((S)=>!z.has(this.config.dedupeKey(S)));this.state.accumulatedItems=[...this.state.accumulatedItems,...P]}getState(){return{...this.state}}getItems(){return this.state.items}getAccumulated(){return this.state.accumulatedItems}hasNext(){return this.state.hasMore}isLoading(){return this.state.isLoading}}function m(J){return new k(J)}function G(J=3,z=1000){return{name:"retry",onError:async(P)=>{let S=P.config;if(!S||!S.retry)throw P;if(P.code==="TIMEOUT"&&!S.timeout)throw P;let T=typeof S.retry==="boolean"?{attempts:J,delay:z}:{attempts:S.retry.attempts??J,delay:S.retry.delay??z},B=S._retryAttempt||0;if(B<T.attempts){let H=B+1,X=T.delay*Math.pow(2,B);return N(S,`Retry Attempt ${H}/${T.attempts} in ${X}ms`),await new Promise((F)=>setTimeout(F,X)),{...S,_retryAttempt:H}}throw P}}}function M(J=60000){let z=new Map;return{name:"cache",onBeforeRequest:async(P)=>{if(!P.cache||P.method!=="GET")return;let S=`${P.method}:${P.url}:${JSON.stringify(P.params)}`,T=z.get(S);if(T&&T.expiresAt>Date.now())return N(P,`Cache HIT: ${P.url}`),{...P,_cachedResponse:T.response};N(P,`Cache MISS: ${P.url}`)},onAfterResponse:(P)=>{let{config:S}=P;if(!S.cache||S.method!=="GET")return;let T=typeof S.cache==="object"?S.cache.ttl??J:J,B=`${S.method}:${S.url}:${JSON.stringify(S.params)}`;z.set(B,{response:P,expiresAt:Date.now()+T})}}}function D(J){return{name:"auth",onBeforeRequest:async(z)=>{let P=typeof J==="function"?await J():J;return z.headers={...z.headers,...P},z}}}var K=new W,Jz=K;export{K as veloxis,G as retryPlugin,Jz as default,m as createPaginator,M as cachePlugin,D as authPlugin,O as VeloxisError,W as Veloxis,k as Paginator};
@@ -0,0 +1,14 @@
1
+ export * from './types';
2
+ export * from './types/pagination';
3
+ export * from './core/client';
4
+ export * from './utils/errors';
5
+ export * from './utils/pagination';
6
+ export { retryPlugin } from './plugins/retry';
7
+ export { cachePlugin } from './plugins/cache';
8
+ export { authPlugin } from './plugins/auth';
9
+ import { Veloxis } from './core/client';
10
+ /**
11
+ * Default instance of Veloxis client.
12
+ */
13
+ export declare const veloxis: Veloxis;
14
+ export default veloxis;
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["..\\src\\utils\\helpers.ts", "..\\src\\plugins\\retry.ts", "..\\src\\plugins\\cache.ts", "..\\src\\plugins\\auth.ts", "..\\src\\utils\\errors.ts", "..\\src\\core\\request.ts", "..\\src\\utils\\headers.ts", "..\\src\\core\\response.ts", "..\\src\\core\\client.ts", "..\\src\\utils\\pagination.ts", "..\\src\\index.ts"],
4
+ "sourcesContent": [
5
+ "import type { VeloxisRequestConfig } from '../types';\r\n\r\n/**\r\n * Combine baseURL and relative URL.\r\n */\r\nexport function mergeURLs(baseURL?: string, relativeURL?: string): string {\r\n if (!baseURL) return relativeURL || '';\r\n if (!relativeURL) return baseURL;\r\n return baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '');\r\n}\r\n\r\n/**\r\n * Append query parameters to a URL.\r\n */\r\nexport function buildURL(url: string, params?: Record<string, any>): string {\r\n if (!params || Object.keys(params).length === 0) return url;\r\n \r\n const searchParams = new URLSearchParams();\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null) {\r\n searchParams.append(key, String(value));\r\n }\r\n });\r\n \r\n const queryString = searchParams.toString();\r\n return queryString ? `${url}${url.includes('?') ? '&' : '?'}${queryString}` : url;\r\n}\r\n\r\n/**\r\n * Deduplication manager to prevent concurrent identical requests.\r\n */\r\nexport const dedupeManager = {\r\n pending: new Map<string, Promise<any>>(),\r\n \r\n generateKey(config: VeloxisRequestConfig): string {\r\n return `${config.method}:${config.url}:${JSON.stringify(config.params)}:${JSON.stringify(config.data)}`;\r\n }\r\n};\r\n\r\n/**\r\n * Utility for debug logging.\r\n */\r\nexport function debugLog(config: VeloxisRequestConfig, ...args: any[]) {\r\n if (config.debug) {\r\n console.log(`[Veloxis][DEBUG]`, ...args);\r\n }\r\n}\r\n",
6
+ "import type { VeloxisPlugin, VeloxisRequestConfig } from '../types';\r\nimport { debugLog } from '../utils/helpers';\r\n\r\n/**\r\n * Plugin to retry failed requests with exponential backoff.\r\n */\r\nexport function retryPlugin(defaultAttempts = 3, defaultDelay = 1000): VeloxisPlugin {\r\n return {\r\n name: 'retry',\r\n onError: async (error: any) => {\r\n const config = error.config as VeloxisRequestConfig;\r\n if (!config || !config.retry) throw error;\r\n\r\n // Skip retry for abort or manual cancel\r\n if (error.code === 'TIMEOUT' && !config.timeout) throw error;\r\n\r\n const retryConfig = typeof config.retry === 'boolean' \r\n ? { attempts: defaultAttempts, delay: defaultDelay } \r\n : { attempts: config.retry.attempts ?? defaultAttempts, delay: config.retry.delay ?? defaultDelay };\r\n\r\n const currentAttempt = config._retryAttempt || 0;\r\n\r\n if (currentAttempt < retryConfig.attempts) {\r\n const nextAttempt = currentAttempt + 1;\r\n const delay = retryConfig.delay * Math.pow(2, currentAttempt);\r\n\r\n debugLog(config, `Retry Attempt ${nextAttempt}/${retryConfig.attempts} in ${delay}ms`);\r\n\r\n await new Promise(resolve => setTimeout(resolve, delay));\r\n \r\n // Return updated config for retry\r\n return { ...config, _retryAttempt: nextAttempt };\r\n }\r\n\r\n throw error;\r\n }\r\n };\r\n}\r\n",
7
+ "import type { VeloxisPlugin, VeloxisResponse } from '../types';\r\nimport { debugLog } from '../utils/helpers';\r\n\r\ninterface CacheItem {\r\n response: VeloxisResponse;\r\n expiresAt: number;\r\n}\r\n\r\n/**\r\n * Plugin to cache GET requests in memory with TTL.\r\n */\r\nexport function cachePlugin(defaultTTL = 60000): VeloxisPlugin {\r\n const cache = new Map<string, CacheItem>();\r\n\r\n return {\r\n name: 'cache',\r\n onBeforeRequest: async (config) => {\r\n if (!config.cache || config.method !== 'GET') return;\r\n\r\n const cacheKey = `${config.method}:${config.url}:${JSON.stringify(config.params)}`;\r\n const cached = cache.get(cacheKey);\r\n\r\n if (cached && cached.expiresAt > Date.now()) {\r\n debugLog(config, `Cache HIT: ${config.url}`);\r\n return { ...config, _cachedResponse: cached.response } as any;\r\n }\r\n \r\n debugLog(config, `Cache MISS: ${config.url}`);\r\n },\r\n onAfterResponse: (response) => {\r\n const { config } = response;\r\n if (!config.cache || config.method !== 'GET') return;\r\n\r\n const ttl = typeof config.cache === 'object' ? config.cache.ttl ?? defaultTTL : defaultTTL;\r\n const cacheKey = `${config.method}:${config.url}:${JSON.stringify(config.params)}`;\r\n\r\n cache.set(cacheKey, {\r\n response,\r\n expiresAt: Date.now() + ttl\r\n });\r\n }\r\n };\r\n}\r\n",
8
+ "import type { VeloxisPlugin, VeloxisHeaders } from '../types';\r\n\r\n/**\r\n * Plugin to automatically inject auth headers.\r\n */\r\nexport function authPlugin(headers: VeloxisHeaders | (() => VeloxisHeaders | Promise<VeloxisHeaders>)): VeloxisPlugin {\r\n return {\r\n name: 'auth',\r\n onBeforeRequest: async (config) => {\r\n const authHeaders = typeof headers === 'function' ? await headers() : headers;\r\n config.headers = { ...config.headers, ...authHeaders };\r\n return config;\r\n }\r\n };\r\n}\r\n",
9
+ "import type { VeloxisRequestConfig, VeloxisResponse } from '../types';\r\n\r\n/**\r\n * Custom error class for Veloxis library.\r\n */\r\nexport class VeloxisError extends Error {\r\n config: VeloxisRequestConfig;\r\n response?: VeloxisResponse;\r\n status?: number;\r\n code?: string;\r\n\r\n constructor(\r\n message: string,\r\n config: VeloxisRequestConfig,\r\n code?: string,\r\n response?: VeloxisResponse\r\n ) {\r\n super(message);\r\n this.name = 'VeloxisError';\r\n this.config = config;\r\n this.code = code;\r\n this.response = response;\r\n this.status = response?.status;\r\n\r\n Object.setPrototypeOf(this, VeloxisError.prototype);\r\n }\r\n\r\n toJSON() {\r\n return {\r\n message: this.message,\r\n name: this.name,\r\n code: this.code,\r\n status: this.status,\r\n config: this.config,\r\n };\r\n }\r\n}\r\n",
10
+ "import type { VeloxisRequestConfig } from '../types';\r\nimport { VeloxisError } from '../utils/errors';\r\nimport { debugLog } from '../utils/helpers';\r\n\r\n/**\r\n * Executes the native fetch call with the provided configuration.\r\n */\r\nexport async function executeFetch(url: string, config: VeloxisRequestConfig): Promise<Response> {\r\n const controller = new AbortController();\r\n const { signal } = controller;\r\n \r\n // Link external signal if provided\r\n if (config.signal) {\r\n config.signal.addEventListener('abort', () => controller.abort());\r\n }\r\n\r\n let timeoutId: any;\r\n if (config.timeout) {\r\n timeoutId = setTimeout(() => controller.abort('timeout'), config.timeout);\r\n }\r\n\r\n const fetchOptions: RequestInit = {\r\n method: config.method || 'GET',\r\n headers: new Headers(config.headers as Record<string, string>),\r\n body: config.data ? (typeof config.data === 'object' ? JSON.stringify(config.data) : config.data) : undefined,\r\n signal\r\n };\r\n\r\n try {\r\n debugLog(config, `Request: ${config.method} ${url}`);\r\n const response = await fetch(url, fetchOptions);\r\n if (timeoutId) clearTimeout(timeoutId);\r\n return response;\r\n } catch (error: any) {\r\n if (timeoutId) clearTimeout(timeoutId);\r\n\r\n if (error.name === 'AbortError' || error === 'timeout') {\r\n throw new VeloxisError(\r\n config.timeout ? `Request timed out after ${config.timeout}ms` : 'Request aborted',\r\n config,\r\n 'TIMEOUT'\r\n );\r\n }\r\n throw new VeloxisError(error.message, config, 'NETWORK_ERROR');\r\n }\r\n}\r\n",
11
+ "/**\r\n * Utility to check if a response has a JSON content type.\r\n */\r\nexport function isJSONResponse(headers: Headers): boolean {\r\n const contentType = headers.get('content-type');\r\n return !!contentType && contentType.includes('application/json');\r\n}\r\n",
12
+ "import type { VeloxisRequestConfig, VeloxisResponse } from '../types';\r\nimport { isJSONResponse } from '../utils/headers';\r\nimport { VeloxisError } from '../utils/errors';\r\nimport { debugLog } from '../utils/helpers';\r\n\r\n/**\r\n * Parses the raw Fetch Response and wraps it in a VeloxisResponse.\r\n */\r\nexport async function parseResponse<T = any>(\r\n response: Response,\r\n config: VeloxisRequestConfig\r\n): Promise<VeloxisResponse<T>> {\r\n let data: any;\r\n \r\n try {\r\n if (isJSONResponse(response.headers)) {\r\n data = await response.json();\r\n } else {\r\n data = await response.text();\r\n }\r\n } catch (error) {\r\n // If parsing fails, use an empty object or the original text\r\n data = {};\r\n }\r\n\r\n const veloxisResponse: VeloxisResponse<T> = {\r\n data,\r\n status: response.status,\r\n statusText: response.statusText,\r\n headers: response.headers,\r\n config\r\n };\r\n\r\n if (!response.ok) {\r\n throw new VeloxisError(\r\n `Request failed with status ${response.status}`,\r\n config,\r\n 'BAD_STATUS',\r\n veloxisResponse\r\n );\r\n }\r\n\r\n debugLog(config, `Response: ${response.status} ${config.url}`);\r\n return veloxisResponse;\r\n}\r\n",
13
+ "import type { \r\n VeloxisRequestConfig, \r\n VeloxisResponse, \r\n VeloxisInterceptor, \r\n VeloxisPlugin, \r\n GraphQLOptions,\r\n HTTPMethod\r\n} from '../types';\r\nimport { executeFetch } from './request';\r\nimport { parseResponse } from './response';\r\nimport { mergeURLs, buildURL, dedupeManager, debugLog } from '../utils/helpers';\r\nimport { VeloxisError } from '../utils/errors';\r\n\r\n/**\r\n * The main Veloxis HTTP Client.\r\n */\r\nexport class Veloxis {\r\n private defaults: VeloxisRequestConfig;\r\n private interceptors = {\r\n request: [] as VeloxisInterceptor<VeloxisRequestConfig>[],\r\n response: [] as VeloxisInterceptor<VeloxisResponse>[]\r\n };\r\n private plugins: VeloxisPlugin[] = [];\r\n\r\n constructor(options: VeloxisRequestConfig = {}) {\r\n this.defaults = {\r\n timeout: 0,\r\n headers: {\r\n 'Accept': 'application/json, text/plain, */*',\r\n 'Content-Type': 'application/json'\r\n },\r\n ...options\r\n };\r\n }\r\n\r\n /**\r\n * Registers a plugin.\r\n */\r\n use(plugin: VeloxisPlugin) {\r\n this.plugins.push(plugin);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds an interceptor.\r\n */\r\n intercept(type: 'request' | 'response', interceptor: VeloxisInterceptor<any>) {\r\n this.interceptors[type].push(interceptor);\r\n return this;\r\n }\r\n\r\n async get<T = any>(url: string, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>> {\r\n return this.request<T>({ ...config, url, method: 'GET' });\r\n }\r\n\r\n async post<T = any>(url: string, data?: any, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>> {\r\n return this.request<T>({ ...config, url, method: 'POST', data });\r\n }\r\n\r\n async put<T = any>(url: string, data?: any, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>> {\r\n return this.request<T>({ ...config, url, method: 'PUT', data });\r\n }\r\n\r\n async delete<T = any>(url: string, config?: VeloxisRequestConfig): Promise<VeloxisResponse<T>> {\r\n return this.request<T>({ ...config, url, method: 'DELETE' });\r\n }\r\n\r\n /**\r\n * GraphQL request method.\r\n */\r\n async graphql<T = any, V = any>(url: string, options: GraphQLOptions<V>, config?: VeloxisRequestConfig): Promise<T> {\r\n const res = await this.post<any>(url, {\r\n query: options.query,\r\n variables: options.variables,\r\n operationName: options.operationName\r\n }, config);\r\n \r\n if (res.data.errors) {\r\n throw new VeloxisError('GraphQL Error', res.config, 'GRAPHQL_ERROR', res);\r\n }\r\n \r\n return res.data.data;\r\n }\r\n\r\n /**\r\n * Orchestrates the entire request/response lifecycle.\r\n */\r\n async request<T = any>(config: VeloxisRequestConfig): Promise<VeloxisResponse<T>> {\r\n let mergedConfig: VeloxisRequestConfig = {\r\n ...this.defaults,\r\n ...config,\r\n headers: { ...this.defaults.headers, ...config.headers }\r\n };\r\n\r\n try {\r\n // 1. Plugins: onBeforeRequest\r\n for (const plugin of this.plugins) {\r\n if (plugin.onBeforeRequest) {\r\n const result = await plugin.onBeforeRequest(mergedConfig);\r\n if (result) mergedConfig = result;\r\n \r\n // Plugin may return a cached response\r\n if ((mergedConfig as any)._cachedResponse) {\r\n return (mergedConfig as any)._cachedResponse;\r\n }\r\n }\r\n }\r\n\r\n // 2. Interceptors: request\r\n for (const interceptor of this.interceptors.request) {\r\n if (interceptor.fulfilled) {\r\n mergedConfig = await interceptor.fulfilled(mergedConfig);\r\n }\r\n }\r\n\r\n const fullURL = buildURL(mergeURLs(mergedConfig.baseURL, mergedConfig.url), mergedConfig.params);\r\n \r\n // 3. Deduplication\r\n const dedupeKey = dedupeManager.generateKey(mergedConfig);\r\n if (mergedConfig.dedupe && dedupeManager.pending.has(dedupeKey)) {\r\n debugLog(mergedConfig, `Deduplicating request: ${fullURL}`);\r\n return dedupeManager.pending.get(dedupeKey);\r\n }\r\n\r\n const requestPromise = this.performRequest<T>(fullURL, mergedConfig);\r\n\r\n if (mergedConfig.dedupe) {\r\n dedupeManager.pending.set(dedupeKey, requestPromise);\r\n requestPromise.finally(() => dedupeManager.pending.delete(dedupeKey));\r\n }\r\n\r\n return await requestPromise;\r\n\r\n } catch (error: any) {\r\n return this.handleError(error);\r\n }\r\n }\r\n\r\n /**\r\n * Executes the actual fetch and processes the response.\r\n */\r\n private async performRequest<T>(url: string, config: VeloxisRequestConfig): Promise<VeloxisResponse<T>> {\r\n const rawResponse = await executeFetch(url, config);\r\n let response = await parseResponse<T>(rawResponse, config);\r\n\r\n // 4. Plugins: onAfterResponse\r\n for (const plugin of this.plugins) {\r\n if (plugin.onAfterResponse) {\r\n const result = await plugin.onAfterResponse(response);\r\n if (result) response = result;\r\n }\r\n }\r\n\r\n // 5. Interceptors: response\r\n for (const interceptor of this.interceptors.response) {\r\n if (interceptor.fulfilled) {\r\n response = await interceptor.fulfilled(response);\r\n }\r\n }\r\n\r\n return response;\r\n }\r\n\r\n /**\r\n * Handles errors through plugins and interceptors.\r\n */\r\n private async handleError(error: any): Promise<any> {\r\n let finalError = error;\r\n\r\n // 6. Plugins: onError\r\n for (const plugin of this.plugins) {\r\n if (plugin.onError) {\r\n try {\r\n const result = await plugin.onError(finalError);\r\n // If plugin returns a config, retry the request\r\n if (result && !(result instanceof Error) && typeof result === 'object') {\r\n return this.request(result);\r\n }\r\n if (result instanceof Error) finalError = result;\r\n } catch (pluginError) {\r\n finalError = pluginError;\r\n }\r\n }\r\n }\r\n\r\n // 7. Interceptors: response rejected\r\n for (const interceptor of this.interceptors.response) {\r\n if (interceptor.rejected) {\r\n try {\r\n finalError = await interceptor.rejected(finalError);\r\n } catch (interceptorError) {\r\n finalError = interceptorError;\r\n }\r\n }\r\n }\r\n\r\n throw finalError;\r\n }\r\n}\r\n",
14
+ "import type { \r\n PaginationConfig, \r\n PaginationResponse, \r\n PaginationState \r\n} from '../types/pagination';\r\n\r\n/**\r\n * Reusable Pagination Utility for Veloxis.\r\n */\r\nexport class Paginator<T, P extends Record<string, any> = any> {\r\n private config: Required<PaginationConfig<T, P>>;\r\n private state: PaginationState<T>;\r\n private fetchPromise: Promise<PaginationResponse<T>> | null = null;\r\n\r\n constructor(config: PaginationConfig<T, P>) {\r\n this.config = {\r\n pageSize: 10,\r\n initialParams: {} as P,\r\n transform: (data) => data,\r\n dedupeKey: (item: any) => item.id ?? JSON.stringify(item),\r\n ...config\r\n };\r\n\r\n this.state = this.getInitialState();\r\n }\r\n\r\n private getInitialState(): PaginationState<T> {\r\n return {\r\n items: [],\r\n accumulatedItems: [],\r\n isLoading: false,\r\n error: null,\r\n currentPage: 0,\r\n currentCursor: null,\r\n hasMore: true\r\n };\r\n }\r\n\r\n /**\r\n * Resets the paginator state.\r\n */\r\n reset() {\r\n this.state = this.getInitialState();\r\n this.fetchPromise = null;\r\n }\r\n\r\n /**\r\n * Fetches the next page of results.\r\n */\r\n async next(): Promise<T[]> {\r\n if (!this.state.hasMore || this.state.isLoading) return this.state.items;\r\n\r\n if (this.fetchPromise) return (await this.fetchPromise).items;\r\n\r\n this.state.isLoading = true;\r\n this.state.error = null;\r\n\r\n const params = this.buildParams();\r\n\r\n try {\r\n this.fetchPromise = this.config.fetch(params);\r\n const response = await this.fetchPromise;\r\n\r\n const newItems = this.config.transform(response.items);\r\n \r\n // Update items with deduplication\r\n this.state.items = newItems;\r\n this.updateAccumulated(newItems);\r\n\r\n this.state.hasMore = response.hasMore;\r\n this.state.currentCursor = response.nextCursor ?? null;\r\n this.state.currentPage++;\r\n \r\n return newItems;\r\n } catch (error) {\r\n this.state.error = error;\r\n throw error;\r\n } finally {\r\n this.state.isLoading = false;\r\n this.fetchPromise = null;\r\n }\r\n }\r\n\r\n /**\r\n * Fetches all pages automatically.\r\n */\r\n async all(maxPages = 50): Promise<T[]> {\r\n let pages = 0;\r\n while (this.state.hasMore && pages < maxPages) {\r\n await this.next();\r\n pages++;\r\n }\r\n return this.state.accumulatedItems;\r\n }\r\n\r\n private buildParams(): P {\r\n const base = { ...this.config.initialParams };\r\n \r\n if (this.config.type === 'offset') {\r\n return {\r\n ...base,\r\n limit: this.config.pageSize,\r\n offset: this.state.currentPage * this.config.pageSize\r\n } as unknown as P;\r\n } else {\r\n return {\r\n ...base,\r\n first: this.config.pageSize,\r\n after: this.state.currentCursor\r\n } as unknown as P;\r\n }\r\n }\r\n\r\n private updateAccumulated(newItems: T[]) {\r\n const existingKeys = new Set(this.state.accumulatedItems.map(this.config.dedupeKey));\r\n const uniqueNew = newItems.filter(item => !existingKeys.has(this.config.dedupeKey(item)));\r\n this.state.accumulatedItems = [...this.state.accumulatedItems, ...uniqueNew];\r\n }\r\n\r\n // Getters\r\n getState() { return { ...this.state }; }\r\n getItems() { return this.state.items; }\r\n getAccumulated() { return this.state.accumulatedItems; }\r\n hasNext() { return this.state.hasMore; }\r\n isLoading() { return this.state.isLoading; }\r\n}\r\n\r\nexport function createPaginator<T, P extends Record<string, any> = any>(config: PaginationConfig<T, P>) {\r\n return new Paginator<T, P>(config);\r\n}\r\n",
15
+ "export * from './types';\r\nexport * from './types/pagination';\r\nexport * from './core/client';\r\nexport * from './utils/errors';\r\nexport * from './utils/pagination';\r\nexport { retryPlugin } from './plugins/retry';\r\nexport { cachePlugin } from './plugins/cache';\r\nexport { authPlugin } from './plugins/auth';\r\n\r\nimport { Veloxis } from './core/client';\r\n\r\n/**\r\n * Default instance of Veloxis client.\r\n */\r\nexport const veloxis = new Veloxis();\r\n\r\nexport default veloxis;\r\n"
16
+ ],
17
+ "mappings": "AAKO,SAAS,CAAS,CAAC,EAAkB,EAA8B,CACxE,GAAI,CAAC,EAAS,OAAO,GAAe,GACpC,GAAI,CAAC,EAAa,OAAO,EACzB,OAAO,EAAQ,QAAQ,OAAQ,EAAE,EAAI,IAAM,EAAY,QAAQ,OAAQ,EAAE,EAMpE,SAAS,CAAQ,CAAC,EAAa,EAAsC,CAC1E,GAAI,CAAC,GAAU,OAAO,KAAK,CAAM,EAAE,SAAW,EAAG,OAAO,EAExD,IAAM,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atically inject auth headers.
4
+ */
5
+ export declare function authPlugin(headers: VeloxisHeaders | (() => VeloxisHeaders | Promise<VeloxisHeaders>)): VeloxisPlugin;
@@ -0,0 +1,3 @@
1
+ function q(b){return{name:"auth",onBeforeRequest:async(k)=>{let p=typeof b==="function"?await b():b;return k.headers={...k.headers,...p},k}}}export{q as authPlugin};
2
+
3
+ //# debugId=633AD09F2C15D09A64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["..\\src\\plugins\\auth.ts"],
4
+ "sourcesContent": [
5
+ "import type { VeloxisPlugin, VeloxisHeaders } from '../types';\r\n\r\n/**\r\n * Plugin to automatically inject auth headers.\r\n */\r\nexport function authPlugin(headers: VeloxisHeaders | (() => VeloxisHeaders | Promise<VeloxisHeaders>)): VeloxisPlugin {\r\n return {\r\n name: 'auth',\r\n onBeforeRequest: async (config) => {\r\n const authHeaders = typeof headers === 'function' ? await headers() : headers;\r\n config.headers = { ...config.headers, ...authHeaders };\r\n return config;\r\n }\r\n };\r\n}\r\n"
6
+ ],
7
+ "mappings": "AAKO,SAAS,CAAU,CAAC,EAA2F,CACpH,MAAO,CACL,KAAM,OACN,gBAAiB,MAAO,IAAW,CACjC,IAAM,EAAc,OAAO,IAAY,WAAa,MAAM,EAAQ,EAAI,EAEtE,OADA,EAAO,QAAU,IAAK,EAAO,WAAY,CAAY,EAC9C,EAEX",
8
+ "debugId": "633AD09F2C15D09A64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,5 @@
1
+ import type { VeloxisPlugin } from '../types';
2
+ /**
3
+ * Plugin to cache GET requests in memory with TTL.
4
+ */
5
+ export declare function cachePlugin(defaultTTL?: number): VeloxisPlugin;
@@ -0,0 +1,3 @@
1
+ function F(j,z){if(!j)return z||"";if(!z)return j;return j.replace(/\/+$/,"")+"/"+z.replace(/^\/+/,"")}function H(j,z){if(!z||Object.keys(z).length===0)return j;let x=new URLSearchParams;Object.entries(z).forEach(([B,C])=>{if(C!==void 0&&C!==null)x.append(B,String(C))});let A=x.toString();return A?`${j}${j.includes("?")?"&":"?"}${A}`:j}var I={pending:new Map,generateKey(j){return`${j.method}:${j.url}:${JSON.stringify(j.params)}:${JSON.stringify(j.data)}`}};function D(j,...z){if(j.debug)console.log("[Veloxis][DEBUG]",...z)}function N(j=60000){let z=new Map;return{name:"cache",onBeforeRequest:async(x)=>{if(!x.cache||x.method!=="GET")return;let A=`${x.method}:${x.url}:${JSON.stringify(x.params)}`,B=z.get(A);if(B&&B.expiresAt>Date.now())return D(x,`Cache HIT: ${x.url}`),{...x,_cachedResponse:B.response};D(x,`Cache MISS: ${x.url}`)},onAfterResponse:(x)=>{let{config:A}=x;if(!A.cache||A.method!=="GET")return;let B=typeof A.cache==="object"?A.cache.ttl??j:j,C=`${A.method}:${A.url}:${JSON.stringify(A.params)}`;z.set(C,{response:x,expiresAt:Date.now()+B})}}}export{N as cachePlugin};
2
+
3
+ //# debugId=55446141E74F371464756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["..\\src\\utils\\helpers.ts", "..\\src\\plugins\\cache.ts"],
4
+ "sourcesContent": [
5
+ "import type { VeloxisRequestConfig } from '../types';\r\n\r\n/**\r\n * Combine baseURL and relative URL.\r\n */\r\nexport function mergeURLs(baseURL?: string, relativeURL?: string): string {\r\n if (!baseURL) return relativeURL || '';\r\n if (!relativeURL) return baseURL;\r\n return baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '');\r\n}\r\n\r\n/**\r\n * Append query parameters to a URL.\r\n */\r\nexport function buildURL(url: string, params?: Record<string, any>): string {\r\n if (!params || Object.keys(params).length === 0) return url;\r\n \r\n const searchParams = new URLSearchParams();\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null) {\r\n searchParams.append(key, String(value));\r\n }\r\n });\r\n \r\n const queryString = searchParams.toString();\r\n return queryString ? `${url}${url.includes('?') ? '&' : '?'}${queryString}` : url;\r\n}\r\n\r\n/**\r\n * Deduplication manager to prevent concurrent identical requests.\r\n */\r\nexport const dedupeManager = {\r\n pending: new Map<string, Promise<any>>(),\r\n \r\n generateKey(config: VeloxisRequestConfig): string {\r\n return `${config.method}:${config.url}:${JSON.stringify(config.params)}:${JSON.stringify(config.data)}`;\r\n }\r\n};\r\n\r\n/**\r\n * Utility for debug logging.\r\n */\r\nexport function debugLog(config: VeloxisRequestConfig, ...args: any[]) {\r\n if (config.debug) {\r\n console.log(`[Veloxis][DEBUG]`, ...args);\r\n }\r\n}\r\n",
6
+ "import type { VeloxisPlugin, VeloxisResponse } from '../types';\r\nimport { debugLog } from '../utils/helpers';\r\n\r\ninterface CacheItem {\r\n response: VeloxisResponse;\r\n expiresAt: number;\r\n}\r\n\r\n/**\r\n * Plugin to cache GET requests in memory with TTL.\r\n */\r\nexport function cachePlugin(defaultTTL = 60000): VeloxisPlugin {\r\n const cache = new Map<string, CacheItem>();\r\n\r\n return {\r\n name: 'cache',\r\n onBeforeRequest: async (config) => {\r\n if (!config.cache || config.method !== 'GET') return;\r\n\r\n const cacheKey = `${config.method}:${config.url}:${JSON.stringify(config.params)}`;\r\n const cached = cache.get(cacheKey);\r\n\r\n if (cached && cached.expiresAt > Date.now()) {\r\n debugLog(config, `Cache HIT: ${config.url}`);\r\n return { ...config, _cachedResponse: cached.response } as any;\r\n }\r\n \r\n debugLog(config, `Cache MISS: ${config.url}`);\r\n },\r\n onAfterResponse: (response) => {\r\n const { config } = response;\r\n if (!config.cache || config.method !== 'GET') return;\r\n\r\n const ttl = typeof config.cache === 'object' ? config.cache.ttl ?? defaultTTL : defaultTTL;\r\n const cacheKey = `${config.method}:${config.url}:${JSON.stringify(config.params)}`;\r\n\r\n cache.set(cacheKey, {\r\n response,\r\n expiresAt: Date.now() + ttl\r\n });\r\n }\r\n };\r\n}\r\n"
7
+ ],
8
+ "mappings": "AAKO,SAAS,CAAS,CAAC,EAAkB,EAA8B,CACxE,GAAI,CAAC,EAAS,OAA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ACnB,GAAI,CAAC,EAAO,OAAS,EAAO,SAAW,MAAO,OAE9C,IAAM,EAAM,OAAO,EAAO,QAAU,SAAW,EAAO,MAAM,KAAO,EAAa,EAC1E,EAAW,GAAG,EAAO,UAAU,EAAO,OAAO,KAAK,UAAU,EAAO,MAAM,IAE/E,EAAM,IAAI,EAAU,CAClB,WACA,UAAW,KAAK,IAAI,EAAI,CAC1B,CAAC,EAEL",
9
+ "debugId": "55446141E74F371464756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,5 @@
1
+ import type { VeloxisPlugin } from '../types';
2
+ /**
3
+ * Plugin to retry failed requests with exponential backoff.
4
+ */
5
+ export declare function retryPlugin(defaultAttempts?: number, defaultDelay?: number): VeloxisPlugin;
@@ -0,0 +1,3 @@
1
+ function K(j,w){if(!j)return w||"";if(!w)return j;return j.replace(/\/+$/,"")+"/"+w.replace(/^\/+/,"")}function M(j,w){if(!w||Object.keys(w).length===0)return j;let B=new URLSearchParams;Object.entries(w).forEach(([F,E])=>{if(E!==void 0&&E!==null)B.append(F,String(E))});let z=B.toString();return z?`${j}${j.includes("?")?"&":"?"}${z}`:j}var N={pending:new Map,generateKey(j){return`${j.method}:${j.url}:${JSON.stringify(j.params)}:${JSON.stringify(j.data)}`}};function I(j,...w){if(j.debug)console.log("[Veloxis][DEBUG]",...w)}function T(j=3,w=1000){return{name:"retry",onError:async(B)=>{let z=B.config;if(!z||!z.retry)throw B;if(B.code==="TIMEOUT"&&!z.timeout)throw B;let F=typeof z.retry==="boolean"?{attempts:j,delay:w}:{attempts:z.retry.attempts??j,delay:z.retry.delay??w},E=z._retryAttempt||0;if(E<F.attempts){let G=E+1,H=F.delay*Math.pow(2,E);return I(z,`Retry Attempt ${G}/${F.attempts} in ${H}ms`),await new Promise((J)=>setTimeout(J,H)),{...z,_retryAttempt:G}}throw B}}}export{T as retryPlugin};
2
+
3
+ //# debugId=726A775211CC6E6A64756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["..\\src\\utils\\helpers.ts", "..\\src\\plugins\\retry.ts"],
4
+ "sourcesContent": [
5
+ "import type { VeloxisRequestConfig } from '../types';\r\n\r\n/**\r\n * Combine baseURL and relative URL.\r\n */\r\nexport function mergeURLs(baseURL?: string, relativeURL?: string): string {\r\n if (!baseURL) return relativeURL || '';\r\n if (!relativeURL) return baseURL;\r\n return baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '');\r\n}\r\n\r\n/**\r\n * Append query parameters to a URL.\r\n */\r\nexport function buildURL(url: string, params?: Record<string, any>): string {\r\n if (!params || Object.keys(params).length === 0) return url;\r\n \r\n const searchParams = new URLSearchParams();\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null) {\r\n searchParams.append(key, String(value));\r\n }\r\n });\r\n \r\n const queryString = searchParams.toString();\r\n return queryString ? `${url}${url.includes('?') ? '&' : '?'}${queryString}` : url;\r\n}\r\n\r\n/**\r\n * Deduplication manager to prevent concurrent identical requests.\r\n */\r\nexport const dedupeManager = {\r\n pending: new Map<string, Promise<any>>(),\r\n \r\n generateKey(config: VeloxisRequestConfig): string {\r\n return `${config.method}:${config.url}:${JSON.stringify(config.params)}:${JSON.stringify(config.data)}`;\r\n }\r\n};\r\n\r\n/**\r\n * Utility for debug logging.\r\n */\r\nexport function debugLog(config: VeloxisRequestConfig, ...args: any[]) {\r\n if (config.debug) {\r\n console.log(`[Veloxis][DEBUG]`, ...args);\r\n }\r\n}\r\n",
6
+ "import type { VeloxisPlugin, VeloxisRequestConfig } from '../types';\r\nimport { debugLog } from '../utils/helpers';\r\n\r\n/**\r\n * Plugin to retry failed requests with exponential backoff.\r\n */\r\nexport function retryPlugin(defaultAttempts = 3, defaultDelay = 1000): VeloxisPlugin {\r\n return {\r\n name: 'retry',\r\n onError: async (error: any) => {\r\n const config = error.config as VeloxisRequestConfig;\r\n if (!config || !config.retry) throw error;\r\n\r\n // Skip retry for abort or manual cancel\r\n if (error.code === 'TIMEOUT' && !config.timeout) throw error;\r\n\r\n const retryConfig = typeof config.retry === 'boolean' \r\n ? { attempts: defaultAttempts, delay: defaultDelay } \r\n : { attempts: config.retry.attempts ?? defaultAttempts, delay: config.retry.delay ?? defaultDelay };\r\n\r\n const currentAttempt = config._retryAttempt || 0;\r\n\r\n if (currentAttempt < retryConfig.attempts) {\r\n const nextAttempt = currentAttempt + 1;\r\n const delay = retryConfig.delay * Math.pow(2, currentAttempt);\r\n\r\n debugLog(config, `Retry Attempt ${nextAttempt}/${retryConfig.attempts} in ${delay}ms`);\r\n\r\n await new Promise(resolve => setTimeout(resolve, delay));\r\n \r\n // Return updated config for retry\r\n return { ...config, _retryAttempt: nextAttempt };\r\n }\r\n\r\n throw error;\r\n }\r\n };\r\n}\r\n"
7
+ ],
8
+ "mappings": "AAKO,SAAS,CAAS,CAAC,EAAkB,EAA8B,CACxE,GAAI,CAAC,EAAS,OAAO,GAAe,GACpC,GAAI,CAAC,EAAa,OAAO,EACzB,OAAO,EAAQ,QAAQ,OAAQ,EAAE,EAAI,IAAM,EAAY,QAAQ,OAAQ,EAAE,EAMpE,SAAS,CAAQ,CAAC,EAAa,EAAsC,CAC1E,GAAI,CAAC,GAAU,OAAO,KAAK,CAAM,EAAE,SAAW,EAAG,OAAO,EAExD,IAAM,EAAe,IAAI,gBACzB,OAAO,QAAQ,CAAM,EAAE,QAAQ,EAAE,EAAK,KAAW,CAC/C,GAAI,IAAU,QAAa,IAAU,KACnC,EAAa,OAAO,EAAK,OAAO,CAAK,CAAC,EAEzC,EAED,IAAM,EAAc,EAAa,SAAS,EAC1C,OAAO,EAAc,GAAG,IAAM,EAAI,SAAS,GAAG,EAAI,IAAM,MAAM,IAAgB,EAMzE,IAAM,EAAgB,CAC3B,QAAS,IAAI,IAEb,WAAW,CAAC,EAAsC,CAChD,MAAO,GAAG,EAAO,UAAU,EAAO,OAAO,KAAK,UAAU,EAAO,MAAM,KAAK,KAAK,UAAU,EAAO,IAAI,IAExG,EAKO,SAAS,CAAQ,CAAC,KAAiC,EAAa,CACrE,GAAI,EAAO,MACT,QAAQ,IAAI,mBAAoB,GAAG,CAAI,ECtCpC,SAAS,CAAW,CAAC,EAAkB,EAAG,EAAe,KAAqB,CACnF,MAAO,CACL,KAAM,QACN,QAAS,MAAO,IAAe,CAC7B,IAAM,EAAS,EAAM,OACrB,GAAI,CAAC,GAAU,CAAC,EAAO,MAAO,MAAM,EAGpC,GAAI,EAAM,OAAS,WAAa,CAAC,EAAO,QAAS,MAAM,EAEvD,IAAM,EAAc,OAAO,EAAO,QAAU,UACxC,CAAE,SAAU,EAAiB,MAAO,CAAa,EACjD,CAAE,SAAU,EAAO,MAAM,UAAY,EAAiB,MAAO,EAAO,MAAM,OAAS,CAAa,EAE9F,EAAiB,EAAO,eAAiB,EAE/C,GAAI,EAAiB,EAAY,SAAU,CACzC,IAAM,EAAc,EAAiB,EAC/B,EAAQ,EAAY,MAAQ,KAAK,IAAI,EAAG,CAAc,EAO5D,OALA,EAAS,EAAQ,iBAAiB,KAAe,EAAY,eAAe,KAAS,EAErF,MAAM,IAAI,QAAQ,KAAW,WAAW,EAAS,CAAK,CAAC,EAGhD,IAAK,EAAQ,cAAe,CAAY,EAGjD,MAAM,EAEV",
9
+ "debugId": "726A775211CC6E6A64756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,49 @@
1
+ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
2
+ export interface VeloxisHeaders extends Record<string, string> {
3
+ }
4
+ export interface VeloxisRequestConfig<T = any> {
5
+ url?: string;
6
+ method?: HTTPMethod;
7
+ baseURL?: string;
8
+ headers?: VeloxisHeaders;
9
+ params?: Record<string, string | number | boolean | undefined>;
10
+ data?: T;
11
+ timeout?: number;
12
+ cache?: boolean | {
13
+ ttl?: number;
14
+ };
15
+ retry?: boolean | {
16
+ attempts?: number;
17
+ delay?: number;
18
+ };
19
+ dedupe?: boolean;
20
+ debug?: boolean;
21
+ signal?: AbortSignal;
22
+ [key: string]: any;
23
+ }
24
+ export interface VeloxisResponse<T = any> {
25
+ data: T;
26
+ status: number;
27
+ statusText: string;
28
+ headers: Headers;
29
+ config: VeloxisRequestConfig;
30
+ }
31
+ export interface VeloxisInterceptor<T> {
32
+ fulfilled?: (value: T) => T | Promise<T>;
33
+ rejected?: (error: any) => any;
34
+ }
35
+ export interface VeloxisPlugin {
36
+ name: string;
37
+ onBeforeRequest?: (config: VeloxisRequestConfig) => void | VeloxisRequestConfig | Promise<void | VeloxisRequestConfig>;
38
+ onAfterResponse?: (response: VeloxisResponse) => void | VeloxisResponse | Promise<void | VeloxisResponse>;
39
+ onError?: (error: any) => void | any | Promise<void | any>;
40
+ }
41
+ export interface GraphQLOptions<V = Record<string, any>> {
42
+ query: string;
43
+ variables?: V;
44
+ operationName?: string;
45
+ }
46
+ export interface GraphQLResponse<T = any> {
47
+ data: T;
48
+ errors?: any[];
49
+ }
@@ -0,0 +1,24 @@
1
+ export type PaginationType = 'offset' | 'cursor';
2
+ export interface PaginationConfig<T, P = any> {
3
+ fetch: (params: P) => Promise<PaginationResponse<T>>;
4
+ type: PaginationType;
5
+ pageSize?: number;
6
+ initialParams?: P;
7
+ transform?: (data: any) => T[];
8
+ dedupeKey?: (item: T) => string | number;
9
+ }
10
+ export interface PaginationResponse<T> {
11
+ items: T[];
12
+ total?: number;
13
+ nextCursor?: string | null;
14
+ hasMore: boolean;
15
+ }
16
+ export interface PaginationState<T> {
17
+ items: T[];
18
+ accumulatedItems: T[];
19
+ isLoading: boolean;
20
+ error: any | null;
21
+ currentPage: number;
22
+ currentCursor: string | null;
23
+ hasMore: boolean;
24
+ }
@@ -0,0 +1,18 @@
1
+ import type { VeloxisRequestConfig, VeloxisResponse } from '../types';
2
+ /**
3
+ * Custom error class for Veloxis library.
4
+ */
5
+ export declare class VeloxisError extends Error {
6
+ config: VeloxisRequestConfig;
7
+ response?: VeloxisResponse;
8
+ status?: number;
9
+ code?: string;
10
+ constructor(message: string, config: VeloxisRequestConfig, code?: string, response?: VeloxisResponse);
11
+ toJSON(): {
12
+ message: string;
13
+ name: string;
14
+ code: string | undefined;
15
+ status: number | undefined;
16
+ config: VeloxisRequestConfig<any>;
17
+ };
18
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Utility to check if a response has a JSON content type.
3
+ */
4
+ export declare function isJSONResponse(headers: Headers): boolean;
@@ -0,0 +1,20 @@
1
+ import type { VeloxisRequestConfig } from '../types';
2
+ /**
3
+ * Combine baseURL and relative URL.
4
+ */
5
+ export declare function mergeURLs(baseURL?: string, relativeURL?: string): string;
6
+ /**
7
+ * Append query parameters to a URL.
8
+ */
9
+ export declare function buildURL(url: string, params?: Record<string, any>): string;
10
+ /**
11
+ * Deduplication manager to prevent concurrent identical requests.
12
+ */
13
+ export declare const dedupeManager: {
14
+ pending: Map<string, Promise<any>>;
15
+ generateKey(config: VeloxisRequestConfig): string;
16
+ };
17
+ /**
18
+ * Utility for debug logging.
19
+ */
20
+ export declare function debugLog(config: VeloxisRequestConfig, ...args: any[]): void;
@@ -0,0 +1,39 @@
1
+ import type { PaginationConfig } from '../types/pagination';
2
+ /**
3
+ * Reusable Pagination Utility for Veloxis.
4
+ */
5
+ export declare class Paginator<T, P extends Record<string, any> = any> {
6
+ private config;
7
+ private state;
8
+ private fetchPromise;
9
+ constructor(config: PaginationConfig<T, P>);
10
+ private getInitialState;
11
+ /**
12
+ * Resets the paginator state.
13
+ */
14
+ reset(): void;
15
+ /**
16
+ * Fetches the next page of results.
17
+ */
18
+ next(): Promise<T[]>;
19
+ /**
20
+ * Fetches all pages automatically.
21
+ */
22
+ all(maxPages?: number): Promise<T[]>;
23
+ private buildParams;
24
+ private updateAccumulated;
25
+ getState(): {
26
+ items: T[];
27
+ accumulatedItems: T[];
28
+ isLoading: boolean;
29
+ error: any | null;
30
+ currentPage: number;
31
+ currentCursor: string | null;
32
+ hasMore: boolean;
33
+ };
34
+ getItems(): T[];
35
+ getAccumulated(): T[];
36
+ hasNext(): boolean;
37
+ isLoading(): boolean;
38
+ }
39
+ export declare function createPaginator<T, P extends Record<string, any> = any>(config: PaginationConfig<T, P>): Paginator<T, P>;
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "veloxis",
3
+ "version": "1.0.0",
4
+ "description": "Ultra-fast, modular HTTP & GraphQL client for Node.js and Browser.",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./plugins/*": {
16
+ "import": "./dist/plugins/*.js",
17
+ "types": "./dist/plugins/*.d.ts"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "dev": "bun run --watch src/index.ts",
27
+ "build": "bun run build.ts && tsc --emitDeclarationOnly",
28
+ "test": "bun test",
29
+ "lint": "bun x eslint src/**/*.ts",
30
+ "bench": "bun run benchmarks/*.bench.ts",
31
+ "prepublishOnly": "bun run test && bun run build",
32
+ "release": "npm version patch && git push --follow-tags"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/AngelitoSystems/Veloxis.git"
37
+ },
38
+ "homepage": "https://github.com/AngelitoSystems/Veloxis#readme",
39
+ "bugs": {
40
+ "url": "https://github.com/AngelitoSystems/Veloxis/issues"
41
+ },
42
+ "keywords": [
43
+ "http",
44
+ "fetch",
45
+ "graphql",
46
+ "client",
47
+ "axios",
48
+ "rest",
49
+ "typescript",
50
+ "performance",
51
+ "bun"
52
+ ],
53
+ "author": "AngelitoSystems",
54
+ "license": "MIT",
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "devDependencies": {
59
+ "@types/bun": "latest",
60
+ "typescript": "^5.0.0",
61
+ "mitata": "latest"
62
+ }
63
+ }