flysoft-react-ui 0.2.2 → 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.
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/apiClient.d.ts +38 -14
- package/dist/services/apiClient.d.ts.map +1 -1
- package/dist/services/apiClient.js +18 -15
- package/package.json +1 -1
|
@@ -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
|
-
|
|
14
|
-
|
|
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;
|
|
@@ -34,43 +61,40 @@ declare class ApiClientService {
|
|
|
34
61
|
private axiosRequest;
|
|
35
62
|
/**
|
|
36
63
|
* Realiza una petición GET
|
|
37
|
-
* @param url URL del endpoint
|
|
38
|
-
* @param params Parámetros opcionales que se enviarán como query string
|
|
39
|
-
* @param headers Headers opcionales de la petición
|
|
40
64
|
*/
|
|
41
|
-
get<T = unknown>(
|
|
65
|
+
get<T = unknown>(options: GetRequestOptions): Promise<T>;
|
|
42
66
|
/**
|
|
43
67
|
* Realiza una petición POST
|
|
44
68
|
*/
|
|
45
|
-
post<T = unknown>(
|
|
69
|
+
post<T = unknown>(options: PostRequestOptions): Promise<T>;
|
|
46
70
|
/**
|
|
47
71
|
* Realiza una petición PUT
|
|
48
72
|
*/
|
|
49
|
-
put<T = unknown>(
|
|
73
|
+
put<T = unknown>(options: PutRequestOptions): Promise<T>;
|
|
50
74
|
/**
|
|
51
75
|
* Realiza una petición DELETE
|
|
52
76
|
*/
|
|
53
|
-
del<T = unknown>(
|
|
77
|
+
del<T = unknown>(options: DeleteRequestOptions): Promise<T>;
|
|
54
78
|
/**
|
|
55
79
|
* Obtiene un archivo como Blob
|
|
56
80
|
*/
|
|
57
|
-
getFile(
|
|
81
|
+
getFile(options: FileRequestOptions): Promise<FileResponse>;
|
|
58
82
|
/**
|
|
59
83
|
* Obtiene un archivo y retorna su URL como objeto
|
|
60
84
|
*/
|
|
61
|
-
getFileAsUrl(
|
|
85
|
+
getFileAsUrl(options: FileRequestOptions): Promise<string>;
|
|
62
86
|
/**
|
|
63
87
|
* Abre un archivo en una nueva ventana
|
|
64
88
|
*/
|
|
65
|
-
openFile(
|
|
89
|
+
openFile(options: FileRequestOptions): Promise<void>;
|
|
66
90
|
/**
|
|
67
91
|
* Descarga un archivo
|
|
68
92
|
*/
|
|
69
|
-
downloadFile(
|
|
93
|
+
downloadFile(options: FileRequestOptions): Promise<void>;
|
|
70
94
|
/**
|
|
71
95
|
* Sube uno o más archivos usando FormData
|
|
72
96
|
*/
|
|
73
|
-
uploadFile<T = unknown>(
|
|
97
|
+
uploadFile<T = unknown>(options: UploadFileOptions): Promise<T>;
|
|
74
98
|
}
|
|
75
99
|
/**
|
|
76
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,EAAsB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtE,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,
|
|
1
|
+
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../../src/services/apiClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAAsB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtE,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,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,UAAU,kBAAkB;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,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AAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAWhE;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC;IAW9D;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC;IAUjE;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAYjE;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAMhE;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB9D;;OAEG;IACG,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC;CAgBtE;AAKD;;GAEG;AACH,eAAO,MAAM,SAAS,kBAAe,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,eAAe,KAAG,gBAE1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,aAAa,GAAG,SAAS,KAClC,IAEF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAO,IAE9C,CAAC"}
|
|
@@ -76,11 +76,9 @@ class ApiClientService {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Realiza una petición GET
|
|
79
|
-
* @param url URL del endpoint
|
|
80
|
-
* @param params Parámetros opcionales que se enviarán como query string
|
|
81
|
-
* @param headers Headers opcionales de la petición
|
|
82
79
|
*/
|
|
83
|
-
async get(
|
|
80
|
+
async get(options) {
|
|
81
|
+
const { url, params, headers } = options;
|
|
84
82
|
const response = await this.axiosRequest({
|
|
85
83
|
method: "GET",
|
|
86
84
|
url,
|
|
@@ -92,7 +90,8 @@ class ApiClientService {
|
|
|
92
90
|
/**
|
|
93
91
|
* Realiza una petición POST
|
|
94
92
|
*/
|
|
95
|
-
async post(
|
|
93
|
+
async post(options) {
|
|
94
|
+
const { url, body, headers } = options;
|
|
96
95
|
const response = await this.axiosRequest({
|
|
97
96
|
method: "POST",
|
|
98
97
|
url,
|
|
@@ -104,7 +103,8 @@ class ApiClientService {
|
|
|
104
103
|
/**
|
|
105
104
|
* Realiza una petición PUT
|
|
106
105
|
*/
|
|
107
|
-
async put(
|
|
106
|
+
async put(options) {
|
|
107
|
+
const { url, body, headers } = options;
|
|
108
108
|
const response = await this.axiosRequest({
|
|
109
109
|
method: "PUT",
|
|
110
110
|
url,
|
|
@@ -116,7 +116,8 @@ class ApiClientService {
|
|
|
116
116
|
/**
|
|
117
117
|
* Realiza una petición DELETE
|
|
118
118
|
*/
|
|
119
|
-
async del(
|
|
119
|
+
async del(options) {
|
|
120
|
+
const { url, headers } = options;
|
|
120
121
|
const response = await this.axiosRequest({
|
|
121
122
|
method: "DELETE",
|
|
122
123
|
url,
|
|
@@ -127,7 +128,8 @@ class ApiClientService {
|
|
|
127
128
|
/**
|
|
128
129
|
* Obtiene un archivo como Blob
|
|
129
130
|
*/
|
|
130
|
-
async getFile(
|
|
131
|
+
async getFile(options) {
|
|
132
|
+
const { url, headers = {} } = options;
|
|
131
133
|
const response = await this.instance.get(url, {
|
|
132
134
|
responseType: "blob",
|
|
133
135
|
headers,
|
|
@@ -140,24 +142,24 @@ class ApiClientService {
|
|
|
140
142
|
/**
|
|
141
143
|
* Obtiene un archivo y retorna su URL como objeto
|
|
142
144
|
*/
|
|
143
|
-
async getFileAsUrl(
|
|
144
|
-
const { data } = await this.getFile(
|
|
145
|
+
async getFileAsUrl(options) {
|
|
146
|
+
const { data } = await this.getFile(options);
|
|
145
147
|
const blob = new Blob([data], { type: data.type });
|
|
146
148
|
return URL.createObjectURL(blob);
|
|
147
149
|
}
|
|
148
150
|
/**
|
|
149
151
|
* Abre un archivo en una nueva ventana
|
|
150
152
|
*/
|
|
151
|
-
async openFile(
|
|
152
|
-
const { data } = await this.getFile(
|
|
153
|
+
async openFile(options) {
|
|
154
|
+
const { data } = await this.getFile(options);
|
|
153
155
|
const urlData = URL.createObjectURL(data);
|
|
154
156
|
window.open(urlData);
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
157
159
|
* Descarga un archivo
|
|
158
160
|
*/
|
|
159
|
-
async downloadFile(
|
|
160
|
-
const { data, headers: dataHeaders } = await this.getFile(
|
|
161
|
+
async downloadFile(options) {
|
|
162
|
+
const { data, headers: dataHeaders } = await this.getFile(options);
|
|
161
163
|
const contentDisposition = dataHeaders["content-disposition"] || dataHeaders["Content-Disposition"];
|
|
162
164
|
const fileName = contentDisposition
|
|
163
165
|
?.split("filename=")[1]
|
|
@@ -174,7 +176,8 @@ class ApiClientService {
|
|
|
174
176
|
/**
|
|
175
177
|
* Sube uno o más archivos usando FormData
|
|
176
178
|
*/
|
|
177
|
-
async uploadFile(
|
|
179
|
+
async uploadFile(options) {
|
|
180
|
+
const { url, files, headers } = options;
|
|
178
181
|
const formData = new FormData();
|
|
179
182
|
const { paramName = "file", ...newHeaders } = headers || {};
|
|
180
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.
|
|
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": [
|