una-nuxt-module 2.1.22 → 2.1.24
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/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/ui/auto-form/AutoFormFieldObject.vue +1 -1
- package/dist/runtime/composables/useAuthorization.js +1 -2
- package/dist/runtime/constants/request.d.ts +2 -2
- package/dist/runtime/enums/index.d.ts +0 -1
- package/dist/runtime/enums/index.js +0 -1
- package/dist/runtime/i18n/i18n.config.d.ts +5 -0
- package/dist/runtime/stores/appStatus.d.ts +8 -8
- package/dist/runtime/types/index.d.ts +8 -151
- package/dist/runtime/types/index.js +0 -1
- package/package.json +39 -39
- package/dist/runtime/classes/FetchClient.d.ts +0 -61
- package/dist/runtime/classes/FetchClient.js +0 -74
- package/dist/runtime/enums/ERequestMethod.d.ts +0 -9
- package/dist/runtime/enums/ERequestMethod.js +0 -7
- package/dist/runtime/utils/buildUrlWithParams.d.ts +0 -36
- package/dist/runtime/utils/buildUrlWithParams.js +0 -10
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -20,7 +20,7 @@ const props = defineProps({
|
|
|
20
20
|
fieldName: { type: String, required: true },
|
|
21
21
|
required: { type: Boolean, required: false },
|
|
22
22
|
config: { type: null, required: false },
|
|
23
|
-
schema: { type:
|
|
23
|
+
schema: { type: Object, required: false },
|
|
24
24
|
disabled: { type: Boolean, required: false }
|
|
25
25
|
});
|
|
26
26
|
const shapes = computed(() => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DEFAULT_ERROR_RESPONSE } from "../constants/index.js";
|
|
2
|
-
import { ERequestMethod } from "../enums/index.js";
|
|
3
2
|
import { ref } from "vue";
|
|
4
3
|
import { useAsyncData, useNuxtApp, useRuntimeConfig } from "#imports";
|
|
5
4
|
import { useI18n } from "vue-i18n";
|
|
@@ -45,7 +44,7 @@ export const useAuthorization = () => {
|
|
|
45
44
|
await useAsyncData(
|
|
46
45
|
() => $fetch(AUTHORIZATION_API.endpoints.getResources, {
|
|
47
46
|
baseURL: AUTHORIZATION_API.baseUrl,
|
|
48
|
-
method:
|
|
47
|
+
method: "GET",
|
|
49
48
|
headers: {
|
|
50
49
|
// Se agrega el token de la sesión
|
|
51
50
|
Authorization: `Bearer ${token}`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IApiResponse } from "../types/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Mensaje de error por defecto al realizar una petición.
|
|
4
4
|
*/
|
|
5
|
-
export declare const DEFAULT_ERROR_RESPONSE:
|
|
5
|
+
export declare const DEFAULT_ERROR_RESPONSE: IApiResponse;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IApiResponseInfo, IApiResponse } from "../types/index.js";
|
|
2
2
|
interface IStateUpdateBeforeRequestOptions {
|
|
3
3
|
makingRequest?: boolean;
|
|
4
4
|
hasError?: boolean;
|
|
5
5
|
showInfo?: boolean;
|
|
6
6
|
keepPreviousInfo?: boolean;
|
|
7
|
-
info?:
|
|
7
|
+
info?: IApiResponseInfo | null;
|
|
8
8
|
}
|
|
9
9
|
interface IStateUpdateAfterRequestOptions {
|
|
10
10
|
showInfo?: boolean;
|
|
@@ -21,7 +21,7 @@ export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStat
|
|
|
21
21
|
info: import("vue").Ref<{
|
|
22
22
|
title: string;
|
|
23
23
|
description: string;
|
|
24
|
-
} | null,
|
|
24
|
+
} | null, IApiResponseInfo | {
|
|
25
25
|
title: string;
|
|
26
26
|
description: string;
|
|
27
27
|
} | null>;
|
|
@@ -32,7 +32,7 @@ export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStat
|
|
|
32
32
|
setOpenDialogDelete: (newState: boolean) => void;
|
|
33
33
|
setOpenDialogExport: (newState: boolean) => void;
|
|
34
34
|
setStateBeforeRequest: (options?: IStateUpdateBeforeRequestOptions) => void;
|
|
35
|
-
setStateAfterRequest: <T = unknown>(response:
|
|
35
|
+
setStateAfterRequest: <T = unknown>(response: IApiResponse<T>, options?: IStateUpdateAfterRequestOptions) => void;
|
|
36
36
|
}, "makingRequest" | "hasError" | "showInfo" | "info" | "openDialogDelete" | "openDialogExport">, Pick<{
|
|
37
37
|
makingRequest: import("vue").Ref<boolean, boolean>;
|
|
38
38
|
hasError: import("vue").Ref<boolean, boolean>;
|
|
@@ -40,7 +40,7 @@ export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStat
|
|
|
40
40
|
info: import("vue").Ref<{
|
|
41
41
|
title: string;
|
|
42
42
|
description: string;
|
|
43
|
-
} | null,
|
|
43
|
+
} | null, IApiResponseInfo | {
|
|
44
44
|
title: string;
|
|
45
45
|
description: string;
|
|
46
46
|
} | null>;
|
|
@@ -51,7 +51,7 @@ export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStat
|
|
|
51
51
|
setOpenDialogDelete: (newState: boolean) => void;
|
|
52
52
|
setOpenDialogExport: (newState: boolean) => void;
|
|
53
53
|
setStateBeforeRequest: (options?: IStateUpdateBeforeRequestOptions) => void;
|
|
54
|
-
setStateAfterRequest: <T = unknown>(response:
|
|
54
|
+
setStateAfterRequest: <T = unknown>(response: IApiResponse<T>, options?: IStateUpdateAfterRequestOptions) => void;
|
|
55
55
|
}, never>, Pick<{
|
|
56
56
|
makingRequest: import("vue").Ref<boolean, boolean>;
|
|
57
57
|
hasError: import("vue").Ref<boolean, boolean>;
|
|
@@ -59,7 +59,7 @@ export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStat
|
|
|
59
59
|
info: import("vue").Ref<{
|
|
60
60
|
title: string;
|
|
61
61
|
description: string;
|
|
62
|
-
} | null,
|
|
62
|
+
} | null, IApiResponseInfo | {
|
|
63
63
|
title: string;
|
|
64
64
|
description: string;
|
|
65
65
|
} | null>;
|
|
@@ -70,6 +70,6 @@ export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStat
|
|
|
70
70
|
setOpenDialogDelete: (newState: boolean) => void;
|
|
71
71
|
setOpenDialogExport: (newState: boolean) => void;
|
|
72
72
|
setStateBeforeRequest: (options?: IStateUpdateBeforeRequestOptions) => void;
|
|
73
|
-
setStateAfterRequest: <T = unknown>(response:
|
|
73
|
+
setStateAfterRequest: <T = unknown>(response: IApiResponse<T>, options?: IStateUpdateAfterRequestOptions) => void;
|
|
74
74
|
}, "setMakingRequest" | "setShowInfo" | "setOpenDialogDelete" | "setOpenDialogExport" | "setStateBeforeRequest" | "setStateAfterRequest">>;
|
|
75
75
|
export {};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { FetchError } from "ofetch";
|
|
3
|
-
import type { EAuthorization, EFormField, EFormMode, ERequestMethod } from "../enums/index.js";
|
|
4
|
-
import type { FetchOptions } from "ofetch";
|
|
5
|
-
export { FetchClient } from "../classes/FetchClient.js";
|
|
1
|
+
import type { EAuthorization, EFormField, EFormMode } from "../enums/index.js";
|
|
6
2
|
/**
|
|
7
3
|
* Los tipos definidos en este archivo son exportados globalmente, lo que hace que no sea necesario importarlos para usarlos.
|
|
8
4
|
*/
|
|
@@ -96,43 +92,15 @@ export type TAuthorization = keyof typeof EAuthorization;
|
|
|
96
92
|
export type TFormField = keyof typeof EFormField;
|
|
97
93
|
/** Tipo de modo de edición de formulario. */
|
|
98
94
|
export type TFormMode = keyof typeof EFormMode;
|
|
99
|
-
/** Tipo de petición */
|
|
100
|
-
export type TRequestMethod = keyof typeof ERequestMethod;
|
|
101
|
-
/**
|
|
102
|
-
* Interfaz que define los parámetros necesarios para realizar una petición HTTP.
|
|
103
|
-
*/
|
|
104
|
-
export interface IFetchParams {
|
|
105
|
-
key: string;
|
|
106
|
-
/**
|
|
107
|
-
* Método HTTP de la petición (GET, POST, PUT, DELETE, etc.).
|
|
108
|
-
* Por defecto, se utiliza el método GET.
|
|
109
|
-
*/
|
|
110
|
-
method?: TRequestMethod;
|
|
111
|
-
/**
|
|
112
|
-
* URL o endpoint al cual se realizará la petición.
|
|
113
|
-
*/
|
|
114
|
-
url: string;
|
|
115
|
-
/**
|
|
116
|
-
* Datos que se enviarán en el cuerpo de la petición.
|
|
117
|
-
* Puede ser un objeto, un valor compatible con BodyInit o null/undefined.
|
|
118
|
-
*/
|
|
119
|
-
body?: BodyInit | Record<string, any> | null | undefined;
|
|
120
|
-
/**
|
|
121
|
-
* Opciones adicionales para configurar la petición, como encabezados y parámetros de configuración.
|
|
122
|
-
*/
|
|
123
|
-
fetchOptions?: FetchOptions<"json">;
|
|
124
|
-
}
|
|
125
|
-
export interface IApiCallWithAsyncData<T = unknown> extends AsyncData<IRequestResponse<T> | null, FetchError<any> | null> {
|
|
126
|
-
}
|
|
127
95
|
/**
|
|
128
96
|
* Interfaz para la información base de respuesta de las peticiones.
|
|
129
97
|
*
|
|
130
|
-
* @interface
|
|
98
|
+
* @interface IApiResponseInfo
|
|
131
99
|
*
|
|
132
100
|
* @property {string} - *title* - Titulo del mensaje
|
|
133
101
|
* @property {string} - *description* - Descripción del mensaje
|
|
134
102
|
*/
|
|
135
|
-
export interface
|
|
103
|
+
export interface IApiResponseInfo {
|
|
136
104
|
/** Titulo del mensaje */
|
|
137
105
|
title: string;
|
|
138
106
|
/** Descripción del mensaje */
|
|
@@ -140,9 +108,9 @@ export interface IRequestInfo {
|
|
|
140
108
|
}
|
|
141
109
|
/**
|
|
142
110
|
* Interfaz para mapear la respuesta de las peticiones a APIS.
|
|
143
|
-
* Extiende de `
|
|
111
|
+
* Extiende de `IApiResponseInfo` para incluir información adicional del mensaje.
|
|
144
112
|
*
|
|
145
|
-
* @interface
|
|
113
|
+
* @interface IApiResponse
|
|
146
114
|
*
|
|
147
115
|
* @property {number} - *statusCode* - Código del resultado de la petición
|
|
148
116
|
* @property {boolean} - *success* - Indica si la peticion fue exitosa
|
|
@@ -151,7 +119,7 @@ export interface IRequestInfo {
|
|
|
151
119
|
* @property {string} - *title* - Titulo del mensaje
|
|
152
120
|
* @property {string} - *description* - Descripción del mensaje
|
|
153
121
|
*/
|
|
154
|
-
export interface
|
|
122
|
+
export interface IApiResponse<T = unknown> extends IApiResponseInfo {
|
|
155
123
|
/** Código del resultado de la petición */
|
|
156
124
|
statusCode: number;
|
|
157
125
|
/** Indica si la peticion fue exitosa */
|
|
@@ -216,36 +184,6 @@ export interface IPaginationSort {
|
|
|
216
184
|
/** Indica si no hay criterios de ordenamiento. */
|
|
217
185
|
empty: boolean;
|
|
218
186
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Interfaz para los parámetros del composable de peticiones a APIS.
|
|
221
|
-
*
|
|
222
|
-
* @interface IUseRequestWraperParameters
|
|
223
|
-
*
|
|
224
|
-
* @property {string} - *baseURL* - Dirección del servidor
|
|
225
|
-
* @property {string} - *url* - Endpoint a consumir
|
|
226
|
-
* @property {TRequestMethod} - *method* - Método de la petición
|
|
227
|
-
* @property {Object, null} - *body* - Body de la petición
|
|
228
|
-
* @property {Object} - *query* - Query de la petición
|
|
229
|
-
* @property {any} - *headers* - Headers de la petición
|
|
230
|
-
*/
|
|
231
|
-
export interface IUseRequestWraperParameters {
|
|
232
|
-
/** Dirección del servidor */
|
|
233
|
-
host: string;
|
|
234
|
-
/** Endpoint a consumir */
|
|
235
|
-
url?: string;
|
|
236
|
-
/** Método HTTP de la petición */
|
|
237
|
-
method?: TRequestMethod;
|
|
238
|
-
/** Cuerpo de la petición (body). */
|
|
239
|
-
body?: Object | null;
|
|
240
|
-
/** Parámetros de la consulta (query). */
|
|
241
|
-
query?: {
|
|
242
|
-
[key: string]: any;
|
|
243
|
-
};
|
|
244
|
-
/** Encabezados de la petición. */
|
|
245
|
-
headers?: {
|
|
246
|
-
[key: string]: any;
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
187
|
/**
|
|
250
188
|
* Representa una entidad identificada por un 'id' único.
|
|
251
189
|
*/
|
|
@@ -340,7 +278,7 @@ export interface IGetAllParams {
|
|
|
340
278
|
* @property {boolean} - *makingRequest* - Almacena si la aplicación esta realizando una petición
|
|
341
279
|
* @property {boolean} - *hasError* - Almacena si la petión respondio con un error
|
|
342
280
|
* @property {boolean} - *showInfo* - Almacena si la aplicación debe mostrar la respuesta de información de la petición
|
|
343
|
-
* @property {
|
|
281
|
+
* @property {IApiResponseInfo, null} - *info* - Almacena la respuesta de información de la petición
|
|
344
282
|
* @property {boolean} - *openDialogDelete* - Almacena si se debe abrir el diálogo de eliminar
|
|
345
283
|
* @property {boolean} - *openDialogExport* - Almacena si se debe abrir el diálogo de exportar
|
|
346
284
|
*/
|
|
@@ -352,7 +290,7 @@ export interface IAppStatusState {
|
|
|
352
290
|
/** Almacena si la aplicación debe mostrar la respuesta de información de la petición */
|
|
353
291
|
showInfo: boolean;
|
|
354
292
|
/** Almacena la respuesta de información de la petición */
|
|
355
|
-
info:
|
|
293
|
+
info: IApiResponseInfo | null;
|
|
356
294
|
/** Almacena si se debe abrir el diálogo de eliminar */
|
|
357
295
|
openDialogDelete: boolean;
|
|
358
296
|
/** Almacena si se debe abrir el diálogo de exportar */
|
|
@@ -528,84 +466,3 @@ export interface IBreadcrumb {
|
|
|
528
466
|
type: "page" | "link";
|
|
529
467
|
to?: string;
|
|
530
468
|
}
|
|
531
|
-
export type TFormBuilderField = IFormBuilderFieldText | IFormBuilderFieldTextArea | IFormBuilderFieldNumber | IFormBuilderFieldDate | IFormBuilderFieldSelect | IFormBuilderFieldSlot | IFormBuilderFieldCheckBox | IFormBuilderFieldRadioButton | IFormBuilderFieldSwitch;
|
|
532
|
-
export interface IFormBuilderConfig {
|
|
533
|
-
rows?: IFormBuilderRow[];
|
|
534
|
-
tabs?: IFormBuilderTab[];
|
|
535
|
-
title: string;
|
|
536
|
-
variant: "SINGLEFORM" | "TABS" | "STEPPERS";
|
|
537
|
-
stepper?: {
|
|
538
|
-
LabelLocation?: "LEFT" | "BOTTOM";
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
export interface IFormBuilderTab {
|
|
542
|
-
rows: IFormBuilderRow[];
|
|
543
|
-
title: string;
|
|
544
|
-
value: number;
|
|
545
|
-
}
|
|
546
|
-
export interface IFormBuilderRow {
|
|
547
|
-
class?: string;
|
|
548
|
-
fields: TFormBuilderField[];
|
|
549
|
-
section?: IFormBuilderSection;
|
|
550
|
-
}
|
|
551
|
-
export interface IFormBuilderSection {
|
|
552
|
-
title: string;
|
|
553
|
-
}
|
|
554
|
-
export interface IFormBuilderFieldBase {
|
|
555
|
-
disabled?: boolean;
|
|
556
|
-
key: string;
|
|
557
|
-
label: string;
|
|
558
|
-
model: any;
|
|
559
|
-
placeHolder?: string;
|
|
560
|
-
readonly?: boolean;
|
|
561
|
-
required: boolean;
|
|
562
|
-
rules: any[];
|
|
563
|
-
size: number;
|
|
564
|
-
title: string;
|
|
565
|
-
type: TFormField;
|
|
566
|
-
}
|
|
567
|
-
export interface IFormBuilderFieldSlot extends IFormBuilderFieldBase {
|
|
568
|
-
}
|
|
569
|
-
export interface IFormBuilderFieldText extends IFormBuilderFieldBase {
|
|
570
|
-
maxlength?: number;
|
|
571
|
-
}
|
|
572
|
-
export interface IFormBuilderFieldTextArea extends IFormBuilderFieldBase {
|
|
573
|
-
maxlength?: number;
|
|
574
|
-
resizable?: boolean;
|
|
575
|
-
rows?: number;
|
|
576
|
-
}
|
|
577
|
-
export interface IFormBuilderFieldNumber extends IFormBuilderFieldBase {
|
|
578
|
-
max?: number;
|
|
579
|
-
maxlength?: number;
|
|
580
|
-
min?: number;
|
|
581
|
-
}
|
|
582
|
-
export interface IFormBuilderFieldDate extends IFormBuilderFieldBase {
|
|
583
|
-
displayFormat: any;
|
|
584
|
-
}
|
|
585
|
-
export interface IFormBuilderFieldSelect extends IFormBuilderFieldBase {
|
|
586
|
-
items: any[];
|
|
587
|
-
itemTitle: string;
|
|
588
|
-
itemValue: string;
|
|
589
|
-
returnObject: boolean;
|
|
590
|
-
}
|
|
591
|
-
export interface IFormBuilderFieldCheckBox extends IFormBuilderFieldBase {
|
|
592
|
-
falseValue?: any;
|
|
593
|
-
indeterminate?: boolean;
|
|
594
|
-
trueValue?: any;
|
|
595
|
-
}
|
|
596
|
-
export interface IFormBuilderFieldRadioButtonItem {
|
|
597
|
-
label: string;
|
|
598
|
-
value: any;
|
|
599
|
-
}
|
|
600
|
-
export interface IFormBuilderFieldRadioButton extends IFormBuilderFieldBase {
|
|
601
|
-
inline: boolean;
|
|
602
|
-
items: IFormBuilderFieldRadioButtonItem[];
|
|
603
|
-
labelLocation: "TOP" | "LEFT";
|
|
604
|
-
}
|
|
605
|
-
export interface IFormBuilderFieldSwitch extends IFormBuilderFieldBase {
|
|
606
|
-
falseValue?: any;
|
|
607
|
-
indeterminate?: boolean;
|
|
608
|
-
inset?: boolean;
|
|
609
|
-
labelPrepend?: string;
|
|
610
|
-
trueValue?: any;
|
|
611
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { FetchClient } from "../classes/FetchClient.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "una-nuxt-module",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.24",
|
|
4
4
|
"description": "Módulo Nuxt para desarrollo CGI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,49 +57,49 @@
|
|
|
57
57
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@asgardeo/auth-spa": "
|
|
61
|
-
"@nuxt/fonts": "
|
|
60
|
+
"@asgardeo/auth-spa": "3.3.0",
|
|
61
|
+
"@nuxt/fonts": "0.11.4",
|
|
62
62
|
"@nuxt/icon": "2.0.0",
|
|
63
|
-
"@nuxt/image": "
|
|
64
|
-
"@nuxt/kit": "
|
|
65
|
-
"@nuxtjs/i18n": "10.0
|
|
66
|
-
"@tailwindcss/vite": "
|
|
67
|
-
"@tanstack/vue-table": "
|
|
68
|
-
"@vee-validate/zod": "
|
|
69
|
-
"@vueuse/core": "
|
|
70
|
-
"class-variance-authority": "
|
|
71
|
-
"clsx": "
|
|
72
|
-
"defu": "
|
|
73
|
-
"embla-carousel-vue": "
|
|
74
|
-
"lucide-vue-next": "
|
|
75
|
-
"pinia": "
|
|
76
|
-
"reka-ui": "
|
|
77
|
-
"scule": "
|
|
78
|
-
"tailwind-merge": "
|
|
79
|
-
"tailwindcss": "
|
|
80
|
-
"tw-animate-css": "
|
|
81
|
-
"vaul-vue": "
|
|
82
|
-
"vee-validate": "
|
|
83
|
-
"vue-json-pretty": "
|
|
84
|
-
"vue-sonner": "
|
|
85
|
-
"zod": "
|
|
63
|
+
"@nuxt/image": "1.11.0",
|
|
64
|
+
"@nuxt/kit": "4.1.1",
|
|
65
|
+
"@nuxtjs/i18n": "10.1.0",
|
|
66
|
+
"@tailwindcss/vite": "4.1.13",
|
|
67
|
+
"@tanstack/vue-table": "8.21.3",
|
|
68
|
+
"@vee-validate/zod": "4.15.1",
|
|
69
|
+
"@vueuse/core": "13.9.0",
|
|
70
|
+
"class-variance-authority": "0.7.1",
|
|
71
|
+
"clsx": "2.1.1",
|
|
72
|
+
"defu": "6.1.4",
|
|
73
|
+
"embla-carousel-vue": "8.6.0",
|
|
74
|
+
"lucide-vue-next": "0.543.0",
|
|
75
|
+
"pinia": "2.2.8",
|
|
76
|
+
"reka-ui": "2.5.0",
|
|
77
|
+
"scule": "1.3.0",
|
|
78
|
+
"tailwind-merge": "3.3.1",
|
|
79
|
+
"tailwindcss": "4.1.13",
|
|
80
|
+
"tw-animate-css": "1.3.8",
|
|
81
|
+
"vaul-vue": "0.4.1",
|
|
82
|
+
"vee-validate": "4.15.1",
|
|
83
|
+
"vue-json-pretty": "2.5.0",
|
|
84
|
+
"vue-sonner": "2.0.8",
|
|
85
|
+
"zod": "3.25.63"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
|
-
"@nuxt/devtools": "
|
|
89
|
-
"@nuxt/eslint-config": "
|
|
90
|
-
"@nuxt/module-builder": "
|
|
91
|
-
"@nuxt/schema": "
|
|
92
|
-
"@nuxt/test-utils": "
|
|
93
|
-
"@nuxtjs/color-mode": "
|
|
94
|
-
"@pinia/nuxt": "
|
|
95
|
-
"@types/node": "
|
|
96
|
-
"changelogen": "
|
|
97
|
-
"eslint": "
|
|
98
|
-
"nuxt": "
|
|
88
|
+
"@nuxt/devtools": "2.6.3",
|
|
89
|
+
"@nuxt/eslint-config": "1.9.0",
|
|
90
|
+
"@nuxt/module-builder": "1.0.2",
|
|
91
|
+
"@nuxt/schema": "4.1.1",
|
|
92
|
+
"@nuxt/test-utils": "3.19.2",
|
|
93
|
+
"@nuxtjs/color-mode": "3.5.2",
|
|
94
|
+
"@pinia/nuxt": "0.5.5",
|
|
95
|
+
"@types/node": "24.3.1",
|
|
96
|
+
"changelogen": "0.6.2",
|
|
97
|
+
"eslint": "9.35.0",
|
|
98
|
+
"nuxt": "4.1.1",
|
|
99
99
|
"shadcn-nuxt": "2.2.0",
|
|
100
100
|
"typescript": "~5.9.2",
|
|
101
|
-
"vitest": "
|
|
102
|
-
"vue-tsc": "
|
|
101
|
+
"vitest": "3.2.4",
|
|
102
|
+
"vue-tsc": "3.0.6"
|
|
103
103
|
},
|
|
104
104
|
"directories": {
|
|
105
105
|
"test": "test"
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { $Fetch } from "ofetch";
|
|
2
|
-
import type { IApiCallWithAsyncData, IFetchParams } from "../types/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Clase que gestiona las peticiones HTTP .
|
|
5
|
-
* Proporciona una forma sencilla de realizar llamadas a APIs con configuración opcional.
|
|
6
|
-
*/
|
|
7
|
-
export declare class FetchClient {
|
|
8
|
-
/** Instancia de $fetch utilizada para realizar las peticiones HTTP. */
|
|
9
|
-
private $fetch;
|
|
10
|
-
/**
|
|
11
|
-
* Constructor de la clase `FetchClient`.
|
|
12
|
-
*
|
|
13
|
-
* @param fetcher Instancia de `$fetch` que se utilizará para realizar las peticiones.
|
|
14
|
-
*/
|
|
15
|
-
constructor(fetcher: $Fetch);
|
|
16
|
-
/**
|
|
17
|
-
* Realiza una llamada HTTP .
|
|
18
|
-
*
|
|
19
|
-
* @template T Tipo de los datos esperados en la respuesta.
|
|
20
|
-
* @param params Objeto que contiene los parámetros de la petición (método, URL, opciones, etc.).
|
|
21
|
-
* @returns Una promesa que resuelve con los datos obtenidos de la respuesta.
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Realiza una llamada HTTP y devuelve los datos de la respuesta en un formato esperado.
|
|
25
|
-
*
|
|
26
|
-
* @template T Tipo de los datos esperados en la respuesta.
|
|
27
|
-
* @param params Objeto que contiene los parámetros necesarios para realizar la petición.
|
|
28
|
-
* @param params.method Método HTTP de la petición (GET, POST, PUT, DELETE, etc.). Por defecto, se utiliza `GET`.
|
|
29
|
-
* @param params.url URL o endpoint al cual se realizará la petición.
|
|
30
|
-
* @param params.fetchOptions Opciones adicionales para configurar la petición, como encabezados, credenciales o parámetros.
|
|
31
|
-
* @returns Una promesa que resuelve con los datos obtenidos de la respuesta, envueltos en el composable [`useAsyncData`](https://nuxt.com/docs/api/composables/use-async-data).
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* // Ejemplo de uso para obtener datos con un GET:
|
|
35
|
-
* class UserModule extends FetchClient {
|
|
36
|
-
*
|
|
37
|
-
* async getAll() {
|
|
38
|
-
* return await this.call<IRequestResponse<IUser>>({
|
|
39
|
-
* url: "/api/users",
|
|
40
|
-
* fetchOptions: {
|
|
41
|
-
* headers: { Authorization: 'Bearer token' },
|
|
42
|
-
* query: { page: 1 },
|
|
43
|
-
* },
|
|
44
|
-
* });
|
|
45
|
-
* }
|
|
46
|
-
*
|
|
47
|
-
* * @example
|
|
48
|
-
* // Ejemplo de uso para enviar datos con un POST:
|
|
49
|
-
* class UserModule extends FetchClient {
|
|
50
|
-
*
|
|
51
|
-
* async create(user: IUser) {
|
|
52
|
-
* return await this.call<IRequestResponse<IUser>>({
|
|
53
|
-
* method: 'POST',
|
|
54
|
-
* url: "/api/user/create",
|
|
55
|
-
* fetchOptions: { body: JSON.stringify(user) },
|
|
56
|
-
* });
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
*/
|
|
60
|
-
call<T = unknown>(params: IFetchParams): Promise<IApiCallWithAsyncData<T>>;
|
|
61
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ERequestMethod } from "../enums/index.js";
|
|
2
|
-
import { useAsyncData } from "#app";
|
|
3
|
-
export class FetchClient {
|
|
4
|
-
/** Instancia de $fetch utilizada para realizar las peticiones HTTP. */
|
|
5
|
-
$fetch;
|
|
6
|
-
/**
|
|
7
|
-
* Constructor de la clase `FetchClient`.
|
|
8
|
-
*
|
|
9
|
-
* @param fetcher Instancia de `$fetch` que se utilizará para realizar las peticiones.
|
|
10
|
-
*/
|
|
11
|
-
constructor(fetcher) {
|
|
12
|
-
this.$fetch = fetcher;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Realiza una llamada HTTP .
|
|
16
|
-
*
|
|
17
|
-
* @template T Tipo de los datos esperados en la respuesta.
|
|
18
|
-
* @param params Objeto que contiene los parámetros de la petición (método, URL, opciones, etc.).
|
|
19
|
-
* @returns Una promesa que resuelve con los datos obtenidos de la respuesta.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Realiza una llamada HTTP y devuelve los datos de la respuesta en un formato esperado.
|
|
23
|
-
*
|
|
24
|
-
* @template T Tipo de los datos esperados en la respuesta.
|
|
25
|
-
* @param params Objeto que contiene los parámetros necesarios para realizar la petición.
|
|
26
|
-
* @param params.method Método HTTP de la petición (GET, POST, PUT, DELETE, etc.). Por defecto, se utiliza `GET`.
|
|
27
|
-
* @param params.url URL o endpoint al cual se realizará la petición.
|
|
28
|
-
* @param params.fetchOptions Opciones adicionales para configurar la petición, como encabezados, credenciales o parámetros.
|
|
29
|
-
* @returns Una promesa que resuelve con los datos obtenidos de la respuesta, envueltos en el composable [`useAsyncData`](https://nuxt.com/docs/api/composables/use-async-data).
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* // Ejemplo de uso para obtener datos con un GET:
|
|
33
|
-
* class UserModule extends FetchClient {
|
|
34
|
-
*
|
|
35
|
-
* async getAll() {
|
|
36
|
-
* return await this.call<IRequestResponse<IUser>>({
|
|
37
|
-
* url: "/api/users",
|
|
38
|
-
* fetchOptions: {
|
|
39
|
-
* headers: { Authorization: 'Bearer token' },
|
|
40
|
-
* query: { page: 1 },
|
|
41
|
-
* },
|
|
42
|
-
* });
|
|
43
|
-
* }
|
|
44
|
-
*
|
|
45
|
-
* * @example
|
|
46
|
-
* // Ejemplo de uso para enviar datos con un POST:
|
|
47
|
-
* class UserModule extends FetchClient {
|
|
48
|
-
*
|
|
49
|
-
* async create(user: IUser) {
|
|
50
|
-
* return await this.call<IRequestResponse<IUser>>({
|
|
51
|
-
* method: 'POST',
|
|
52
|
-
* url: "/api/user/create",
|
|
53
|
-
* fetchOptions: { body: JSON.stringify(user) },
|
|
54
|
-
* });
|
|
55
|
-
* }
|
|
56
|
-
* }
|
|
57
|
-
*/
|
|
58
|
-
async call(params) {
|
|
59
|
-
const {
|
|
60
|
-
key,
|
|
61
|
-
method = ERequestMethod.GET,
|
|
62
|
-
url,
|
|
63
|
-
body = void 0,
|
|
64
|
-
fetchOptions = {}
|
|
65
|
-
} = params;
|
|
66
|
-
return useAsyncData(key, () => {
|
|
67
|
-
return this.$fetch(url, {
|
|
68
|
-
method,
|
|
69
|
-
body,
|
|
70
|
-
...fetchOptions
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Construye una URL completa agregando parámetros de consulta (query parameters) a una URL base.
|
|
3
|
-
*
|
|
4
|
-
* Esta función toma una URL base y un objeto de parámetros, filtra los valores válidos
|
|
5
|
-
* y construye una URL completa con los parámetros de consulta apropiados.
|
|
6
|
-
*
|
|
7
|
-
* @param baseUrl - La URL base sin parámetros de consulta
|
|
8
|
-
* @param params - Objeto con los parámetros a agregar como query string
|
|
9
|
-
* @returns La URL completa con los parámetros de consulta, o solo la URL base si no hay parámetros válidos
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // URL simple sin parámetros
|
|
14
|
-
* buildUrlWithParams('/api/users', {})
|
|
15
|
-
* // Returns: '/api/users'
|
|
16
|
-
*
|
|
17
|
-
* // URL con parámetros válidos
|
|
18
|
-
* buildUrlWithParams('/api/users', { page: 1, size: 10, name: 'John' })
|
|
19
|
-
* // Returns: '/api/users?page=1&size=10&name=John'
|
|
20
|
-
*
|
|
21
|
-
* // Filtra valores nulos, undefined y strings vacíos
|
|
22
|
-
* buildUrlWithParams('/api/users', { page: 1, name: null, filter: '', active: undefined })
|
|
23
|
-
* // Returns: '/api/users?page=1'
|
|
24
|
-
*
|
|
25
|
-
* // Convierte números y booleanos a string automáticamente
|
|
26
|
-
* buildUrlWithParams('/api/products', { price: 99.99, inStock: true })
|
|
27
|
-
* // Returns: '/api/products?price=99.99&inStock=true'
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* - Los valores `null`, `undefined` y strings vacíos (`""`) son automáticamente excluidos
|
|
32
|
-
* - Todos los valores son convertidos a string usando `toString()`
|
|
33
|
-
* - Si no hay parámetros válidos, retorna solo la URL base sin el símbolo `?`
|
|
34
|
-
*/
|
|
35
|
-
declare const _default: (baseUrl: string, params: Record<string, any>) => string;
|
|
36
|
-
export default _default;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default (baseUrl, params) => {
|
|
2
|
-
const urlParams = new URLSearchParams();
|
|
3
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
4
|
-
if (value !== void 0 && value !== null && value !== "") {
|
|
5
|
-
urlParams.append(key, value.toString());
|
|
6
|
-
}
|
|
7
|
-
});
|
|
8
|
-
const queryString = urlParams.toString();
|
|
9
|
-
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
10
|
-
};
|