flysoft-react-ui 0.2.1 → 0.2.3

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.
@@ -9,9 +9,36 @@ interface FileResponse {
9
9
  data: Blob;
10
10
  headers: AxiosResponse["headers"];
11
11
  }
12
+ interface GetRequestOptions {
13
+ url: string;
14
+ params?: Record<string, unknown>;
15
+ headers?: Record<string, string>;
16
+ }
17
+ interface PostRequestOptions {
18
+ url: string;
19
+ body?: unknown;
20
+ headers?: Record<string, string>;
21
+ }
22
+ interface PutRequestOptions {
23
+ url: string;
24
+ body?: unknown;
25
+ headers?: Record<string, string>;
26
+ }
27
+ interface DeleteRequestOptions {
28
+ url: string;
29
+ headers?: Record<string, string>;
30
+ }
31
+ interface FileRequestOptions {
32
+ url: string;
33
+ headers?: Record<string, string>;
34
+ }
12
35
  interface UploadFileOptions {
13
- paramName?: string;
14
- [key: string]: unknown;
36
+ url: string;
37
+ files: FileList | File[];
38
+ headers?: {
39
+ paramName?: string;
40
+ [key: string]: unknown;
41
+ };
15
42
  }
16
43
  declare class ApiClientService {
17
44
  private instance;
@@ -35,39 +62,39 @@ declare class ApiClientService {
35
62
  /**
36
63
  * Realiza una petición GET
37
64
  */
38
- get<T = unknown>(url: string, headers?: Record<string, string>): Promise<T>;
65
+ get<T = unknown>(options: GetRequestOptions): Promise<T>;
39
66
  /**
40
67
  * Realiza una petición POST
41
68
  */
42
- post<T = unknown>(url: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
69
+ post<T = unknown>(options: PostRequestOptions): Promise<T>;
43
70
  /**
44
71
  * Realiza una petición PUT
45
72
  */
46
- put<T = unknown>(url: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
73
+ put<T = unknown>(options: PutRequestOptions): Promise<T>;
47
74
  /**
48
75
  * Realiza una petición DELETE
49
76
  */
50
- del<T = unknown>(url: string, headers?: Record<string, string>): Promise<T>;
77
+ del<T = unknown>(options: DeleteRequestOptions): Promise<T>;
51
78
  /**
52
79
  * Obtiene un archivo como Blob
53
80
  */
54
- getFile(url: string, headers?: Record<string, string>): Promise<FileResponse>;
81
+ getFile(options: FileRequestOptions): Promise<FileResponse>;
55
82
  /**
56
83
  * Obtiene un archivo y retorna su URL como objeto
57
84
  */
58
- getFileAsUrl(url: string, headers?: Record<string, string>): Promise<string>;
85
+ getFileAsUrl(options: FileRequestOptions): Promise<string>;
59
86
  /**
60
87
  * Abre un archivo en una nueva ventana
61
88
  */
62
- openFile(url: string, headers?: Record<string, string>): Promise<void>;
89
+ openFile(options: FileRequestOptions): Promise<void>;
63
90
  /**
64
91
  * Descarga un archivo
65
92
  */
66
- downloadFile(url: string, headers?: Record<string, string>): Promise<void>;
93
+ downloadFile(options: FileRequestOptions): Promise<void>;
67
94
  /**
68
95
  * Sube uno o más archivos usando FormData
69
96
  */
70
- uploadFile<T = unknown>(url: string, files: FileList | File[], headers?: UploadFileOptions): Promise<T>;
97
+ uploadFile<T = unknown>(options: UploadFileOptions): Promise<T>;
71
98
  }
72
99
  /**
73
100
  * Cliente de API compartido con todas las funciones de HTTP
@@ -1 +1 @@
1
- {"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../../src/services/apiClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAEZ,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAEf,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,KAAK,aAAa,GAAG,MAAM,MAAM,GAAG,SAAS,CAAC;AAE9C,UAAU,YAAY;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACnC;AAED,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAA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AEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAO,IAE9C,CAAC"}
@@ -19,7 +19,8 @@ class ApiClientService {
19
19
  const token = this.tokenProvider?.();
20
20
  if (token && config.headers) {
21
21
  // Manejo compatible con diferentes versiones de axios
22
- if ("set" in config.headers && typeof config.headers.set === "function") {
22
+ if ("set" in config.headers &&
23
+ typeof config.headers.set === "function") {
23
24
  config.headers.set("Authorization", `Bearer ${token}`);
24
25
  }
25
26
  else {
@@ -64,21 +65,24 @@ class ApiClientService {
64
65
  Object.assign(this.instance.defaults.headers.common || {}, config.headers);
65
66
  }
66
67
  }
67
- async axiosRequest({ method, url, headers, body, }) {
68
+ async axiosRequest({ method, url, headers, body, params, }) {
68
69
  return await this.instance({
69
70
  method,
70
71
  headers,
71
72
  url,
72
73
  data: body,
74
+ params,
73
75
  });
74
76
  }
75
77
  /**
76
78
  * Realiza una petición GET
77
79
  */
78
- async get(url, headers) {
80
+ async get(options) {
81
+ const { url, params, headers } = options;
79
82
  const response = await this.axiosRequest({
80
83
  method: "GET",
81
84
  url,
85
+ params,
82
86
  headers,
83
87
  });
84
88
  return response.data;
@@ -86,7 +90,8 @@ class ApiClientService {
86
90
  /**
87
91
  * Realiza una petición POST
88
92
  */
89
- async post(url, body, headers) {
93
+ async post(options) {
94
+ const { url, body, headers } = options;
90
95
  const response = await this.axiosRequest({
91
96
  method: "POST",
92
97
  url,
@@ -98,7 +103,8 @@ class ApiClientService {
98
103
  /**
99
104
  * Realiza una petición PUT
100
105
  */
101
- async put(url, body, headers) {
106
+ async put(options) {
107
+ const { url, body, headers } = options;
102
108
  const response = await this.axiosRequest({
103
109
  method: "PUT",
104
110
  url,
@@ -110,7 +116,8 @@ class ApiClientService {
110
116
  /**
111
117
  * Realiza una petición DELETE
112
118
  */
113
- async del(url, headers) {
119
+ async del(options) {
120
+ const { url, headers } = options;
114
121
  const response = await this.axiosRequest({
115
122
  method: "DELETE",
116
123
  url,
@@ -121,7 +128,8 @@ class ApiClientService {
121
128
  /**
122
129
  * Obtiene un archivo como Blob
123
130
  */
124
- async getFile(url, headers = {}) {
131
+ async getFile(options) {
132
+ const { url, headers = {} } = options;
125
133
  const response = await this.instance.get(url, {
126
134
  responseType: "blob",
127
135
  headers,
@@ -134,24 +142,24 @@ class ApiClientService {
134
142
  /**
135
143
  * Obtiene un archivo y retorna su URL como objeto
136
144
  */
137
- async getFileAsUrl(url, headers = {}) {
138
- const { data } = await this.getFile(url, headers);
145
+ async getFileAsUrl(options) {
146
+ const { data } = await this.getFile(options);
139
147
  const blob = new Blob([data], { type: data.type });
140
148
  return URL.createObjectURL(blob);
141
149
  }
142
150
  /**
143
151
  * Abre un archivo en una nueva ventana
144
152
  */
145
- async openFile(url, headers) {
146
- const { data } = await this.getFile(url, headers);
153
+ async openFile(options) {
154
+ const { data } = await this.getFile(options);
147
155
  const urlData = URL.createObjectURL(data);
148
156
  window.open(urlData);
149
157
  }
150
158
  /**
151
159
  * Descarga un archivo
152
160
  */
153
- async downloadFile(url, headers) {
154
- const { data, headers: dataHeaders } = await this.getFile(url, headers);
161
+ async downloadFile(options) {
162
+ const { data, headers: dataHeaders } = await this.getFile(options);
155
163
  const contentDisposition = dataHeaders["content-disposition"] || dataHeaders["Content-Disposition"];
156
164
  const fileName = contentDisposition
157
165
  ?.split("filename=")[1]
@@ -168,7 +176,8 @@ class ApiClientService {
168
176
  /**
169
177
  * Sube uno o más archivos usando FormData
170
178
  */
171
- async uploadFile(url, files, headers) {
179
+ async uploadFile(options) {
180
+ const { url, files, headers } = options;
172
181
  const formData = new FormData();
173
182
  const { paramName = "file", ...newHeaders } = headers || {};
174
183
  const fileArray = Array.from(files);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flysoft-react-ui",
3
3
  "private": false,
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "type": "module",
6
6
  "description": "A modern React UI component library with Tailwind CSS, TypeScript, and FontAwesome 5. Includes forms, layouts, themes, and templates for rapid development.",
7
7
  "keywords": [