nectiasw 0.0.13 → 0.0.14

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.
@@ -0,0 +1,28 @@
1
+ import { ContextProps } from '../../context';
2
+ import { URLMapping } from '@nectiasw/providers/https';
3
+
4
+ export declare enum Method {
5
+ GET = "GET",
6
+ PUT = "PUT",
7
+ POST = "POST",
8
+ PATCH = "PATCH",
9
+ DELETE = "DELETE"
10
+ }
11
+ export type Arguments = {
12
+ endpoint: string;
13
+ baseURL: string;
14
+ method?: Method;
15
+ normalize?: boolean;
16
+ };
17
+ export interface FetchRequest<T> {
18
+ result: T;
19
+ status: number;
20
+ message: string;
21
+ }
22
+ /**
23
+ * @description
24
+ * Sends a request to the server.
25
+ * This is commonly used on useQuery hooks from react-query.
26
+ * @param session - session object.
27
+ */
28
+ export declare function signalHttps<T, M = Record<string, never>, S extends ContextProps["session"] = ContextProps["session"]>(session: S, args: Arguments, config?: URLMapping, mutation?: M): () => Promise<FetchRequest<T>>;
@@ -0,0 +1,65 @@
1
+ import { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
+
3
+ export interface HttpResponse<T> extends Promise<T> {
4
+ data: T;
5
+ status: number;
6
+ message: string;
7
+ }
8
+ export interface HttpClientOptions {
9
+ baseURL?: string;
10
+ timeout?: number;
11
+ headers?: Record<string, string>;
12
+ logger?: Console["log"];
13
+ requestInterceptor?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
14
+ responseInterceptor?: (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
15
+ }
16
+ export interface URLMapping {
17
+ provide?: string;
18
+ params?: Array<string | number>;
19
+ query?: Record<string, string | number | boolean>;
20
+ }
21
+ export declare class HttpClient {
22
+ private https;
23
+ private logger;
24
+ private requestInterceptor;
25
+ private responseInterceptor;
26
+ constructor({ baseURL, timeout, headers, logger, requestInterceptor, responseInterceptor, }?: HttpClientOptions);
27
+ get<T>(url: string | URLMapping, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
28
+ /**
29
+ * @description
30
+ * Makes a DELETE request to the specified URL.
31
+ * @param url - The URL to which the request is sent.
32
+ * @param config - The config to be used for the request.
33
+ */
34
+ delete<T>(url: string | URLMapping, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
35
+ /**
36
+ * @description
37
+ * Makes a PATCH request to the specified URL.
38
+ * @param url - The URL to which the request is sent.
39
+ * @param data - The data to be sent as the request body.
40
+ * @param config - The config to be used for the request.
41
+ */
42
+ patch<T, B>(url: string | URLMapping, data?: B, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
43
+ /**
44
+ * @description
45
+ * Makes a POST request to the specified URL.
46
+ * @param url - The URL to which the request is sent.
47
+ * @param data - The data to be sent as the request body.
48
+ * @param config - The config to be used for the request.
49
+ */
50
+ post<T, B>(url: string | URLMapping, data?: B, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
51
+ /**
52
+ * @description
53
+ * Makes a PUT request to the specified URL.
54
+ * @param url The URL to which the request is sent.
55
+ * @param data The data to be sent as the request body.
56
+ * @param config The config to be used for the request.
57
+ */
58
+ put<T, B>(url: string | URLMapping, data?: B, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
59
+ /**
60
+ * @description
61
+ * Removes all interceptors, including the default ones.
62
+ */
63
+ removeInterceptors(): void;
64
+ }
65
+ export default HttpClient;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @description
3
+ * Create a Bearer token.
4
+ * @param token - Token to be used in the Bearer header.
5
+ */
6
+ export declare function bearer(token: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nectiasw",
3
3
  "private": false,
4
- "version": "0.0.13",
4
+ "version": "0.0.14",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",
7
7
  "main": "dist/index.umd.js",
@@ -35,6 +35,7 @@
35
35
  "axios": "^1.7.2",
36
36
  "clsx": "^2.1.1",
37
37
  "date-fns": "^3.6.0",
38
+ "history": "^5.3.0",
38
39
  "lodash": "^4.17.21",
39
40
  "moment": "^2.30.1",
40
41
  "nectiasw": "^0.0.4",