@xeno-js/shared 2.0.1 → 3.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/README.md +675 -678
- package/dist/axios.cjs +2230 -0
- package/dist/axios.cjs.map +1 -0
- package/dist/axios.d.cts +19 -0
- package/dist/axios.d.ts +19 -0
- package/dist/axios.js +2203 -0
- package/dist/axios.js.map +1 -0
- package/dist/common.types-DT8JtZ0E.d.cts +214 -0
- package/dist/common.types-DT8JtZ0E.d.ts +214 -0
- package/dist/iauth-service.contracts-DotziBbm.d.ts +230 -0
- package/dist/iauth-service.contracts-DyFYvLdb.d.cts +230 -0
- package/dist/ihttp-client.contracts-DX2hDTW6.d.ts +299 -0
- package/dist/ihttp-client.contracts-KMkYuIHH.d.cts +299 -0
- package/dist/index.cjs +2 -348
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +973 -2295
- package/dist/index.d.ts +973 -2295
- package/dist/index.js +1 -341
- package/dist/index.js.map +1 -1
- package/dist/ivalidator-service.contracts-DGMounqU.d.cts +102 -0
- package/dist/ivalidator-service.contracts-ulue7FGh.d.ts +102 -0
- package/dist/result.types-BNTzjCgR.d.cts +381 -0
- package/dist/result.types-DRyxvpQs.d.ts +381 -0
- package/dist/supabase.cjs +2431 -0
- package/dist/supabase.cjs.map +1 -0
- package/dist/supabase.d.cts +53 -0
- package/dist/supabase.d.ts +53 -0
- package/dist/supabase.js +2402 -0
- package/dist/supabase.js.map +1 -0
- package/dist/zod.cjs +2372 -0
- package/dist/zod.cjs.map +1 -0
- package/dist/zod.d.cts +63 -0
- package/dist/zod.d.ts +63 -0
- package/dist/zod.js +2344 -0
- package/dist/zod.js.map +1 -0
- package/package.json +17 -2
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { O as Optional, D as Dictionary, M as Maybe } from './common.types-DT8JtZ0E.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Supported HTTP methods.
|
|
5
|
+
|
|
6
|
+
*
|
|
7
|
+
* @author Xeno
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
* @since 2025-09-30
|
|
10
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
11
|
+
*/
|
|
12
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
13
|
+
/**
|
|
14
|
+
* @description Header map used by agnostic HTTP clients.
|
|
15
|
+
|
|
16
|
+
*
|
|
17
|
+
* @author Xeno
|
|
18
|
+
* @version 1.0.0
|
|
19
|
+
* @since 2025-09-30
|
|
20
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
21
|
+
*/
|
|
22
|
+
type HttpHeaders = Dictionary<Optional<string | string[]>>;
|
|
23
|
+
/**
|
|
24
|
+
* @description Query string value accepted by the HTTP contract.
|
|
25
|
+
|
|
26
|
+
*
|
|
27
|
+
* @author Xeno
|
|
28
|
+
* @version 1.0.0
|
|
29
|
+
* @since 2025-09-30
|
|
30
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
31
|
+
*/
|
|
32
|
+
type HttpQueryValue = Maybe<string | number | boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* @description Agnostic contract used to execute HTTP calls independently
|
|
35
|
+
* from concrete transport libraries (fetch, axios, undici, etc.).
|
|
36
|
+
|
|
37
|
+
*
|
|
38
|
+
* @author Xeno
|
|
39
|
+
* @version 1.0.0
|
|
40
|
+
* @since 2025-09-30
|
|
41
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
42
|
+
*/
|
|
43
|
+
type HttpOptions = 'url' | 'method' | 'body';
|
|
44
|
+
/**
|
|
45
|
+
* @description Base Request options accepted by the agnostic HTTP client.
|
|
46
|
+
*
|
|
47
|
+
* @author Xeno
|
|
48
|
+
* @version 1.0.0
|
|
49
|
+
* @since 2025-09-30
|
|
50
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
51
|
+
*/
|
|
52
|
+
interface HttpBaseRequest {
|
|
53
|
+
/** @description Optional query string parameters.
|
|
54
|
+
*
|
|
55
|
+
* @author Xeno
|
|
56
|
+
* @version 1.0.0
|
|
57
|
+
* @since 2025-09-30
|
|
58
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
59
|
+
*/
|
|
60
|
+
readonly query?: Optional<Dictionary<HttpQueryValue>>;
|
|
61
|
+
/** @description Optional request headers.
|
|
62
|
+
*
|
|
63
|
+
* @author Xeno
|
|
64
|
+
* @version 1.0.0
|
|
65
|
+
* @since 2025-09-30
|
|
66
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
67
|
+
*/
|
|
68
|
+
readonly headers?: Optional<HttpHeaders>;
|
|
69
|
+
/** @description Optional abort signal used to cancel the request.
|
|
70
|
+
*
|
|
71
|
+
* @author Xeno
|
|
72
|
+
* @version 1.0.0
|
|
73
|
+
* @since 2025-09-30
|
|
74
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
75
|
+
*/
|
|
76
|
+
readonly signal: Optional<AbortSignal>;
|
|
77
|
+
/** @description Optional request timeout in milliseconds.
|
|
78
|
+
*
|
|
79
|
+
* @author Xeno
|
|
80
|
+
* @version 1.0.0
|
|
81
|
+
* @since 2025-09-30
|
|
82
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
83
|
+
*/
|
|
84
|
+
readonly timeoutMs?: Optional<number>;
|
|
85
|
+
/**
|
|
86
|
+
* @description Optional response type for the request.
|
|
87
|
+
*
|
|
88
|
+
* @author Xeno
|
|
89
|
+
* @version 1.0.0
|
|
90
|
+
* @since 2025-09-30
|
|
91
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
92
|
+
*/
|
|
93
|
+
readonly responseType?: Optional<HttpResponseType>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @description Represents the structure of an HTTP response.
|
|
97
|
+
*
|
|
98
|
+
* @author Xeno
|
|
99
|
+
* @version 1.0.0
|
|
100
|
+
* @since 2025-09-30
|
|
101
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
102
|
+
*/
|
|
103
|
+
type HttpResponseType = 'json' | 'blob' | 'text' | 'arraybuffer';
|
|
104
|
+
/**
|
|
105
|
+
* @description Request options accepted by the agnostic HTTP client.
|
|
106
|
+
|
|
107
|
+
*
|
|
108
|
+
* @author Xeno
|
|
109
|
+
* @version 1.0.0
|
|
110
|
+
* @since 2025-09-30
|
|
111
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
112
|
+
*/
|
|
113
|
+
interface HttpRequest<TBody = unknown> extends HttpBaseRequest {
|
|
114
|
+
/** @description HTTP method used for the outgoing call.
|
|
115
|
+
*
|
|
116
|
+
* @author Xeno
|
|
117
|
+
* @version 1.0.0
|
|
118
|
+
* @since 2025-09-30
|
|
119
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
120
|
+
*/
|
|
121
|
+
readonly method: HttpMethod;
|
|
122
|
+
/** @description Optional request body.
|
|
123
|
+
*
|
|
124
|
+
* @author Xeno
|
|
125
|
+
* @version 1.0.0
|
|
126
|
+
* @since 2025-09-30
|
|
127
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
128
|
+
*/
|
|
129
|
+
readonly body?: Optional<TBody>;
|
|
130
|
+
/** @description Absolute or relative target URL.
|
|
131
|
+
*
|
|
132
|
+
* @author Xeno
|
|
133
|
+
* @version 1.0.0
|
|
134
|
+
* @since 2025-09-30
|
|
135
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
136
|
+
*/
|
|
137
|
+
readonly url?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @description Normalized response returned by an agnostic HTTP client.
|
|
141
|
+
|
|
142
|
+
*
|
|
143
|
+
* @author Xeno
|
|
144
|
+
* @version 1.0.0
|
|
145
|
+
* @since 2025-09-30
|
|
146
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
147
|
+
*/
|
|
148
|
+
interface HttpResponse<TData = unknown> {
|
|
149
|
+
/** @description HTTP status code returned by the server.
|
|
150
|
+
*
|
|
151
|
+
* @author Xeno
|
|
152
|
+
* @version 1.0.0
|
|
153
|
+
* @since 2025-09-30
|
|
154
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
155
|
+
*/
|
|
156
|
+
readonly status: number;
|
|
157
|
+
/** @description Indicates if the response status is in the 2xx range.
|
|
158
|
+
*
|
|
159
|
+
* @author Xeno
|
|
160
|
+
* @version 1.0.0
|
|
161
|
+
* @since 2025-09-30
|
|
162
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
163
|
+
*/
|
|
164
|
+
readonly ok: boolean;
|
|
165
|
+
/** @description Response headers normalized as a dictionary.
|
|
166
|
+
*
|
|
167
|
+
* @author Xeno
|
|
168
|
+
* @version 1.0.0
|
|
169
|
+
* @since 2025-09-30
|
|
170
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
171
|
+
*/
|
|
172
|
+
readonly headers: HttpHeaders;
|
|
173
|
+
/** @description Parsed response payload.
|
|
174
|
+
*
|
|
175
|
+
* @author Xeno
|
|
176
|
+
* @version 1.0.0
|
|
177
|
+
* @since 2025-09-30
|
|
178
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
179
|
+
*/
|
|
180
|
+
readonly data: TData;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @description Represents the CookieOptions interface.
|
|
184
|
+
*
|
|
185
|
+
* @author Xeno
|
|
186
|
+
* @version 1.0.0
|
|
187
|
+
* @since 2025-09-30
|
|
188
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
189
|
+
*/
|
|
190
|
+
interface CookieOptions {
|
|
191
|
+
/** @description The path for which the cookie is valid. Defaults to '/'. */
|
|
192
|
+
path?: Optional<string>;
|
|
193
|
+
/** @description The value of the maximum age in seconds. If not specified, the cookie will expire when the browser session ends. */
|
|
194
|
+
maxAge?: Optional<number>;
|
|
195
|
+
/** @description The domain for which the cookie is valid. Defaults to the domain of the current document host. */
|
|
196
|
+
domain?: Optional<string>;
|
|
197
|
+
/** @description Whether the cookie is only transmitted over secure (HTTPS) connections. Defaults to true in production. */
|
|
198
|
+
secure?: Optional<boolean>;
|
|
199
|
+
/** @description Controls whether the cookie is withheld on cross-site requests, providing some protection against cross-site request forgery attacks. */
|
|
200
|
+
sameSite?: Optional<'lax' | 'strict' | 'none' | boolean>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @description Represents an extended Request object that includes additional properties
|
|
204
|
+
* required by the Xeno-js framework, such as custom path handling.
|
|
205
|
+
*
|
|
206
|
+
* @author Xeno
|
|
207
|
+
* @version 1.0.0
|
|
208
|
+
* @since 2025-09-30
|
|
209
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
210
|
+
*/
|
|
211
|
+
interface ExtendedRequest extends Request {
|
|
212
|
+
/**
|
|
213
|
+
* @description The path of the request, which may be modified by middleware.
|
|
214
|
+
* Example: '/api/v1/user'
|
|
215
|
+
*/
|
|
216
|
+
path: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @description Agnostic contract used to execute HTTP calls independently from concrete transport libraries (fetch, axios, undici, etc.).
|
|
221
|
+
|
|
222
|
+
*
|
|
223
|
+
* @author Xeno
|
|
224
|
+
* @version 1.0.0
|
|
225
|
+
* @since 2025-09-30
|
|
226
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
227
|
+
*/
|
|
228
|
+
interface IHttpClient {
|
|
229
|
+
/**
|
|
230
|
+
* @description Executes an HTTP GET request to the specified URL with optional request options.
|
|
231
|
+
* @param url The URL to which the GET request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
232
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
233
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
234
|
+
|
|
235
|
+
*
|
|
236
|
+
* @author Xeno
|
|
237
|
+
* @version 1.0.0
|
|
238
|
+
* @since 2025-09-30
|
|
239
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
240
|
+
*/
|
|
241
|
+
get<TResponse = unknown>(url: string, options: Optional<Omit<HttpRequest<never>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
242
|
+
/**
|
|
243
|
+
* @description Executes an HTTP POST request to the specified URL with the provided request body and optional request options.
|
|
244
|
+
* @param url The URL to which the POST request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
245
|
+
* @param body The request body to be sent with the POST request. This can be of any type, such as an object, string, or FormData, depending on the requirements of the server endpoint.
|
|
246
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
247
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
248
|
+
|
|
249
|
+
*
|
|
250
|
+
* @author Xeno
|
|
251
|
+
* @version 1.0.0
|
|
252
|
+
* @since 2025-09-30
|
|
253
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
254
|
+
*/
|
|
255
|
+
post<TResponse = unknown, TBody = unknown>(url: string, body: Optional<TBody>, options: Optional<Omit<HttpRequest<TBody>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
256
|
+
/**
|
|
257
|
+
* @description Executes an HTTP PUT request to the specified URL with the provided request body and optional request options.
|
|
258
|
+
* @param url The URL to which the PUT request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
259
|
+
* @param body The request body to be sent with the PUT request. This can be of any type, such as an object, string, or FormData, depending on the requirements of the server endpoint.
|
|
260
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
261
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
262
|
+
|
|
263
|
+
*
|
|
264
|
+
* @author Xeno
|
|
265
|
+
* @version 1.0.0
|
|
266
|
+
* @since 2025-09-30
|
|
267
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
268
|
+
*/
|
|
269
|
+
put<TResponse = unknown, TBody = unknown>(url: string, body: Optional<TBody>, options: Optional<Omit<HttpRequest<TBody>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
270
|
+
/**
|
|
271
|
+
* @description Executes an HTTP PATCH request to the specified URL with the provided request body and optional request options.
|
|
272
|
+
* @param url The URL to which the PATCH request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
273
|
+
* @param body The request body to be sent with the PATCH request. This can be of any type, such as an object, string, or FormData, depending on the requirements of the server endpoint.
|
|
274
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
275
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
276
|
+
|
|
277
|
+
*
|
|
278
|
+
* @author Xeno
|
|
279
|
+
* @version 1.0.0
|
|
280
|
+
* @since 2025-09-30
|
|
281
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
282
|
+
*/
|
|
283
|
+
patch<TResponse = unknown, TBody = unknown>(url: string, body: Optional<TBody>, options: Optional<Omit<HttpRequest<TBody>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
284
|
+
/**
|
|
285
|
+
* @description Executes an HTTP DELETE request to the specified URL with optional request options.
|
|
286
|
+
* @param url The URL to which the DELETE request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
287
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
288
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
289
|
+
|
|
290
|
+
*
|
|
291
|
+
* @author Xeno
|
|
292
|
+
* @version 1.0.0
|
|
293
|
+
* @since 2025-09-30
|
|
294
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
295
|
+
*/
|
|
296
|
+
delete<TResponse = unknown>(url: string, options: Optional<Omit<HttpRequest<never>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export type { CookieOptions as C, ExtendedRequest as E, HttpRequest as H, IHttpClient as I, HttpOptions as a, HttpResponse as b, HttpHeaders as c, HttpBaseRequest as d, HttpMethod as e, HttpQueryValue as f, HttpResponseType as g };
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { O as Optional, D as Dictionary, M as Maybe } from './common.types-DT8JtZ0E.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Supported HTTP methods.
|
|
5
|
+
|
|
6
|
+
*
|
|
7
|
+
* @author Xeno
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
* @since 2025-09-30
|
|
10
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
11
|
+
*/
|
|
12
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
13
|
+
/**
|
|
14
|
+
* @description Header map used by agnostic HTTP clients.
|
|
15
|
+
|
|
16
|
+
*
|
|
17
|
+
* @author Xeno
|
|
18
|
+
* @version 1.0.0
|
|
19
|
+
* @since 2025-09-30
|
|
20
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
21
|
+
*/
|
|
22
|
+
type HttpHeaders = Dictionary<Optional<string | string[]>>;
|
|
23
|
+
/**
|
|
24
|
+
* @description Query string value accepted by the HTTP contract.
|
|
25
|
+
|
|
26
|
+
*
|
|
27
|
+
* @author Xeno
|
|
28
|
+
* @version 1.0.0
|
|
29
|
+
* @since 2025-09-30
|
|
30
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
31
|
+
*/
|
|
32
|
+
type HttpQueryValue = Maybe<string | number | boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* @description Agnostic contract used to execute HTTP calls independently
|
|
35
|
+
* from concrete transport libraries (fetch, axios, undici, etc.).
|
|
36
|
+
|
|
37
|
+
*
|
|
38
|
+
* @author Xeno
|
|
39
|
+
* @version 1.0.0
|
|
40
|
+
* @since 2025-09-30
|
|
41
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
42
|
+
*/
|
|
43
|
+
type HttpOptions = 'url' | 'method' | 'body';
|
|
44
|
+
/**
|
|
45
|
+
* @description Base Request options accepted by the agnostic HTTP client.
|
|
46
|
+
*
|
|
47
|
+
* @author Xeno
|
|
48
|
+
* @version 1.0.0
|
|
49
|
+
* @since 2025-09-30
|
|
50
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
51
|
+
*/
|
|
52
|
+
interface HttpBaseRequest {
|
|
53
|
+
/** @description Optional query string parameters.
|
|
54
|
+
*
|
|
55
|
+
* @author Xeno
|
|
56
|
+
* @version 1.0.0
|
|
57
|
+
* @since 2025-09-30
|
|
58
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
59
|
+
*/
|
|
60
|
+
readonly query?: Optional<Dictionary<HttpQueryValue>>;
|
|
61
|
+
/** @description Optional request headers.
|
|
62
|
+
*
|
|
63
|
+
* @author Xeno
|
|
64
|
+
* @version 1.0.0
|
|
65
|
+
* @since 2025-09-30
|
|
66
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
67
|
+
*/
|
|
68
|
+
readonly headers?: Optional<HttpHeaders>;
|
|
69
|
+
/** @description Optional abort signal used to cancel the request.
|
|
70
|
+
*
|
|
71
|
+
* @author Xeno
|
|
72
|
+
* @version 1.0.0
|
|
73
|
+
* @since 2025-09-30
|
|
74
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
75
|
+
*/
|
|
76
|
+
readonly signal: Optional<AbortSignal>;
|
|
77
|
+
/** @description Optional request timeout in milliseconds.
|
|
78
|
+
*
|
|
79
|
+
* @author Xeno
|
|
80
|
+
* @version 1.0.0
|
|
81
|
+
* @since 2025-09-30
|
|
82
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
83
|
+
*/
|
|
84
|
+
readonly timeoutMs?: Optional<number>;
|
|
85
|
+
/**
|
|
86
|
+
* @description Optional response type for the request.
|
|
87
|
+
*
|
|
88
|
+
* @author Xeno
|
|
89
|
+
* @version 1.0.0
|
|
90
|
+
* @since 2025-09-30
|
|
91
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
92
|
+
*/
|
|
93
|
+
readonly responseType?: Optional<HttpResponseType>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @description Represents the structure of an HTTP response.
|
|
97
|
+
*
|
|
98
|
+
* @author Xeno
|
|
99
|
+
* @version 1.0.0
|
|
100
|
+
* @since 2025-09-30
|
|
101
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
102
|
+
*/
|
|
103
|
+
type HttpResponseType = 'json' | 'blob' | 'text' | 'arraybuffer';
|
|
104
|
+
/**
|
|
105
|
+
* @description Request options accepted by the agnostic HTTP client.
|
|
106
|
+
|
|
107
|
+
*
|
|
108
|
+
* @author Xeno
|
|
109
|
+
* @version 1.0.0
|
|
110
|
+
* @since 2025-09-30
|
|
111
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
112
|
+
*/
|
|
113
|
+
interface HttpRequest<TBody = unknown> extends HttpBaseRequest {
|
|
114
|
+
/** @description HTTP method used for the outgoing call.
|
|
115
|
+
*
|
|
116
|
+
* @author Xeno
|
|
117
|
+
* @version 1.0.0
|
|
118
|
+
* @since 2025-09-30
|
|
119
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
120
|
+
*/
|
|
121
|
+
readonly method: HttpMethod;
|
|
122
|
+
/** @description Optional request body.
|
|
123
|
+
*
|
|
124
|
+
* @author Xeno
|
|
125
|
+
* @version 1.0.0
|
|
126
|
+
* @since 2025-09-30
|
|
127
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
128
|
+
*/
|
|
129
|
+
readonly body?: Optional<TBody>;
|
|
130
|
+
/** @description Absolute or relative target URL.
|
|
131
|
+
*
|
|
132
|
+
* @author Xeno
|
|
133
|
+
* @version 1.0.0
|
|
134
|
+
* @since 2025-09-30
|
|
135
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
136
|
+
*/
|
|
137
|
+
readonly url?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @description Normalized response returned by an agnostic HTTP client.
|
|
141
|
+
|
|
142
|
+
*
|
|
143
|
+
* @author Xeno
|
|
144
|
+
* @version 1.0.0
|
|
145
|
+
* @since 2025-09-30
|
|
146
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
147
|
+
*/
|
|
148
|
+
interface HttpResponse<TData = unknown> {
|
|
149
|
+
/** @description HTTP status code returned by the server.
|
|
150
|
+
*
|
|
151
|
+
* @author Xeno
|
|
152
|
+
* @version 1.0.0
|
|
153
|
+
* @since 2025-09-30
|
|
154
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
155
|
+
*/
|
|
156
|
+
readonly status: number;
|
|
157
|
+
/** @description Indicates if the response status is in the 2xx range.
|
|
158
|
+
*
|
|
159
|
+
* @author Xeno
|
|
160
|
+
* @version 1.0.0
|
|
161
|
+
* @since 2025-09-30
|
|
162
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
163
|
+
*/
|
|
164
|
+
readonly ok: boolean;
|
|
165
|
+
/** @description Response headers normalized as a dictionary.
|
|
166
|
+
*
|
|
167
|
+
* @author Xeno
|
|
168
|
+
* @version 1.0.0
|
|
169
|
+
* @since 2025-09-30
|
|
170
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
171
|
+
*/
|
|
172
|
+
readonly headers: HttpHeaders;
|
|
173
|
+
/** @description Parsed response payload.
|
|
174
|
+
*
|
|
175
|
+
* @author Xeno
|
|
176
|
+
* @version 1.0.0
|
|
177
|
+
* @since 2025-09-30
|
|
178
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
179
|
+
*/
|
|
180
|
+
readonly data: TData;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @description Represents the CookieOptions interface.
|
|
184
|
+
*
|
|
185
|
+
* @author Xeno
|
|
186
|
+
* @version 1.0.0
|
|
187
|
+
* @since 2025-09-30
|
|
188
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
189
|
+
*/
|
|
190
|
+
interface CookieOptions {
|
|
191
|
+
/** @description The path for which the cookie is valid. Defaults to '/'. */
|
|
192
|
+
path?: Optional<string>;
|
|
193
|
+
/** @description The value of the maximum age in seconds. If not specified, the cookie will expire when the browser session ends. */
|
|
194
|
+
maxAge?: Optional<number>;
|
|
195
|
+
/** @description The domain for which the cookie is valid. Defaults to the domain of the current document host. */
|
|
196
|
+
domain?: Optional<string>;
|
|
197
|
+
/** @description Whether the cookie is only transmitted over secure (HTTPS) connections. Defaults to true in production. */
|
|
198
|
+
secure?: Optional<boolean>;
|
|
199
|
+
/** @description Controls whether the cookie is withheld on cross-site requests, providing some protection against cross-site request forgery attacks. */
|
|
200
|
+
sameSite?: Optional<'lax' | 'strict' | 'none' | boolean>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @description Represents an extended Request object that includes additional properties
|
|
204
|
+
* required by the Xeno-js framework, such as custom path handling.
|
|
205
|
+
*
|
|
206
|
+
* @author Xeno
|
|
207
|
+
* @version 1.0.0
|
|
208
|
+
* @since 2025-09-30
|
|
209
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
210
|
+
*/
|
|
211
|
+
interface ExtendedRequest extends Request {
|
|
212
|
+
/**
|
|
213
|
+
* @description The path of the request, which may be modified by middleware.
|
|
214
|
+
* Example: '/api/v1/user'
|
|
215
|
+
*/
|
|
216
|
+
path: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @description Agnostic contract used to execute HTTP calls independently from concrete transport libraries (fetch, axios, undici, etc.).
|
|
221
|
+
|
|
222
|
+
*
|
|
223
|
+
* @author Xeno
|
|
224
|
+
* @version 1.0.0
|
|
225
|
+
* @since 2025-09-30
|
|
226
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
227
|
+
*/
|
|
228
|
+
interface IHttpClient {
|
|
229
|
+
/**
|
|
230
|
+
* @description Executes an HTTP GET request to the specified URL with optional request options.
|
|
231
|
+
* @param url The URL to which the GET request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
232
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
233
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
234
|
+
|
|
235
|
+
*
|
|
236
|
+
* @author Xeno
|
|
237
|
+
* @version 1.0.0
|
|
238
|
+
* @since 2025-09-30
|
|
239
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
240
|
+
*/
|
|
241
|
+
get<TResponse = unknown>(url: string, options: Optional<Omit<HttpRequest<never>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
242
|
+
/**
|
|
243
|
+
* @description Executes an HTTP POST request to the specified URL with the provided request body and optional request options.
|
|
244
|
+
* @param url The URL to which the POST request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
245
|
+
* @param body The request body to be sent with the POST request. This can be of any type, such as an object, string, or FormData, depending on the requirements of the server endpoint.
|
|
246
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
247
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
248
|
+
|
|
249
|
+
*
|
|
250
|
+
* @author Xeno
|
|
251
|
+
* @version 1.0.0
|
|
252
|
+
* @since 2025-09-30
|
|
253
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
254
|
+
*/
|
|
255
|
+
post<TResponse = unknown, TBody = unknown>(url: string, body: Optional<TBody>, options: Optional<Omit<HttpRequest<TBody>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
256
|
+
/**
|
|
257
|
+
* @description Executes an HTTP PUT request to the specified URL with the provided request body and optional request options.
|
|
258
|
+
* @param url The URL to which the PUT request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
259
|
+
* @param body The request body to be sent with the PUT request. This can be of any type, such as an object, string, or FormData, depending on the requirements of the server endpoint.
|
|
260
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
261
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
262
|
+
|
|
263
|
+
*
|
|
264
|
+
* @author Xeno
|
|
265
|
+
* @version 1.0.0
|
|
266
|
+
* @since 2025-09-30
|
|
267
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
268
|
+
*/
|
|
269
|
+
put<TResponse = unknown, TBody = unknown>(url: string, body: Optional<TBody>, options: Optional<Omit<HttpRequest<TBody>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
270
|
+
/**
|
|
271
|
+
* @description Executes an HTTP PATCH request to the specified URL with the provided request body and optional request options.
|
|
272
|
+
* @param url The URL to which the PATCH request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
273
|
+
* @param body The request body to be sent with the PATCH request. This can be of any type, such as an object, string, or FormData, depending on the requirements of the server endpoint.
|
|
274
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
275
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
276
|
+
|
|
277
|
+
*
|
|
278
|
+
* @author Xeno
|
|
279
|
+
* @version 1.0.0
|
|
280
|
+
* @since 2025-09-30
|
|
281
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
282
|
+
*/
|
|
283
|
+
patch<TResponse = unknown, TBody = unknown>(url: string, body: Optional<TBody>, options: Optional<Omit<HttpRequest<TBody>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
284
|
+
/**
|
|
285
|
+
* @description Executes an HTTP DELETE request to the specified URL with optional request options.
|
|
286
|
+
* @param url The URL to which the DELETE request is sent. This can be an absolute or relative URL depending on the configuration of the HTTP client.
|
|
287
|
+
* @param options Optional request options that can include headers, query parameters, abort signal, and timeout settings. These options allow for customization of the HTTP request, such as adding specific headers, including query parameters in the URL, setting a timeout for the request, or providing an abort signal to cancel the request if needed.
|
|
288
|
+
* @returns A promise that resolves to an HttpResponse object containing the status code, response headers, and response data from the server. The HttpResponse object provides information about the outcome of the HTTP request, including whether it was successful (status code 2xx) or if there was an error (status code 4xx or 5xx).
|
|
289
|
+
|
|
290
|
+
*
|
|
291
|
+
* @author Xeno
|
|
292
|
+
* @version 1.0.0
|
|
293
|
+
* @since 2025-09-30
|
|
294
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
295
|
+
*/
|
|
296
|
+
delete<TResponse = unknown>(url: string, options: Optional<Omit<HttpRequest<never>, HttpOptions>>): Promise<HttpResponse<TResponse>>;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export type { CookieOptions as C, ExtendedRequest as E, HttpRequest as H, IHttpClient as I, HttpOptions as a, HttpResponse as b, HttpHeaders as c, HttpBaseRequest as d, HttpMethod as e, HttpQueryValue as f, HttpResponseType as g };
|