una-nuxt-module 1.0.3 → 1.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "configKey": "unaNuxtModule",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
package/dist/module.mjs CHANGED
@@ -1,99 +1,135 @@
1
1
  import { createResolver, defineNuxtModule, useLogger, extendPages, addLayout, addComponentsDir, addImportsDir, addPlugin, addRouteMiddleware, hasNuxtModule } from '@nuxt/kit';
2
2
 
3
3
  const name = "una-nuxt-module";
4
- const version = "1.0.3";
5
-
6
- const CONFIG_KEY = "unaNuxtModule";
4
+ const version = "1.0.4";
7
5
 
8
6
  function resolve(path) {
9
7
  const resolver = createResolver(import.meta.url);
10
8
  return resolver.resolve(`./runtime/${path}`);
11
9
  }
12
10
 
11
+ const CONFIG_KEY = "unaNuxtModule";
12
+ const PAGES_CONFIG = [
13
+ {
14
+ name: "401",
15
+ path: "/401",
16
+ file: resolve("pages/401.vue")
17
+ },
18
+ {
19
+ name: "403",
20
+ path: "/403",
21
+ file: resolve("pages/403.vue")
22
+ },
23
+ {
24
+ name: "ssoCallback",
25
+ path: "/auth/sso/login",
26
+ file: resolve("pages/ssoCallback.vue")
27
+ }
28
+ ];
29
+ const LAYOUTS_CONFIG = [
30
+ { src: resolve("layouts/default.vue"), name: "default" },
31
+ { src: resolve("layouts/empty.vue"), name: "empty" }
32
+ ];
33
+ const PLUGINS_CONFIG = [
34
+ { name: "auth", src: resolve("plugins/auth"), mode: "client" },
35
+ { name: "vue-json", src: resolve("plugins/vue-json"), mode: "client" }
36
+ ];
37
+ const MIDDLEWARE_CONFIG = [
38
+ {
39
+ name: "authentication",
40
+ path: resolve("middleware/authentication"),
41
+ global: true
42
+ },
43
+ {
44
+ name: "authorization",
45
+ path: resolve("middleware/authorization"),
46
+ global: true
47
+ }
48
+ ];
49
+ const AUTO_IMPORT_DIRS = [
50
+ "composables",
51
+ "constants",
52
+ "enums",
53
+ "stores",
54
+ "types",
55
+ "utils"
56
+ ];
57
+
13
58
  const module = defineNuxtModule({
14
- meta: { name: name, version: version, configKey: CONFIG_KEY },
59
+ meta: {
60
+ name: name,
61
+ version: version,
62
+ configKey: CONFIG_KEY
63
+ },
15
64
  defaults: {},
16
65
  setup(_options, _nuxt) {
17
66
  const LOGGER = useLogger(name);
18
- LOGGER.box(`Module: ${name} v${version}`);
19
- LOGGER.start("Module registration started...");
20
- _nuxt.options.nitro.publicAssets = [{ dir: resolve("public") }];
21
- LOGGER.success("Public assets added");
22
- const pages = [
23
- { name: "401", path: "/401", file: resolve("pages/401.vue") },
24
- { name: "403", path: "/403", file: resolve("pages/403.vue") },
25
- {
26
- name: "ssoCallback",
27
- path: "/auth/sso/login",
28
- file: resolve("pages/ssoCallback.vue")
29
- }
30
- ];
31
- extendPages((currentPages) => {
32
- currentPages.push(...pages);
33
- });
34
- LOGGER.success("Custom pages added: ['/401', '/403', '/auth/sso/login']");
35
- const layouts = [
36
- { src: resolve("layouts/default.vue"), name: "default" },
37
- { src: resolve("layouts/empty.vue"), name: "empty" }
38
- ];
39
- layouts.forEach((layout) => addLayout(layout, layout.name));
40
- LOGGER.success("Layouts added: ['default', 'empty']");
41
- addComponentsDir({
42
- path: resolve("components"),
43
- pathPrefix: false,
44
- global: true
45
- });
46
- LOGGER.success("Gloabl components added");
47
- addImportsDir([
48
- resolve("composables"),
49
- resolve("constants"),
50
- resolve("enums"),
51
- resolve("stores"),
52
- resolve("types"),
53
- resolve("utils")
54
- ]);
55
- LOGGER.success(
56
- "Auto-import directories added: [composables, constants, enums, stores, types, utils]"
57
- );
58
- const plugins = [
59
- { name: "auth", src: resolve("plugins/auth"), mode: "client" },
60
- {
61
- name: "vue-json",
62
- src: resolve("plugins/vue-json"),
63
- mode: "client"
64
- }
65
- ];
66
- plugins.forEach((plugin) => addPlugin(plugin));
67
- LOGGER.success("Plugins added: ['auth', 'vue-json']");
68
- const middlewares = [
69
- {
70
- name: "authentication",
71
- path: resolve("middleware/authentication"),
72
- global: true
73
- },
74
- {
75
- name: "authorization",
76
- path: resolve("middleware/authorization"),
67
+ const setupModuleBase = () => {
68
+ LOGGER.box(`Module: ${name} v${version}`);
69
+ LOGGER.start("Module registration started...");
70
+ };
71
+ const setupPublicAssets = () => {
72
+ _nuxt.options.nitro.publicAssets = [{ dir: resolve("public") }];
73
+ LOGGER.success("Public assets added");
74
+ };
75
+ const setupPages = () => {
76
+ extendPages((currentPages) => {
77
+ currentPages.push(...PAGES_CONFIG);
78
+ });
79
+ LOGGER.success("Custom pages added: ['/401', '/403', '/auth/sso/login']");
80
+ };
81
+ const setupLayouts = () => {
82
+ LAYOUTS_CONFIG.forEach((layout) => addLayout(layout, layout.name));
83
+ LOGGER.success("Layouts added: ['default', 'empty']");
84
+ };
85
+ const setupComponents = () => {
86
+ addComponentsDir({
87
+ path: resolve("components"),
88
+ pathPrefix: false,
77
89
  global: true
90
+ });
91
+ LOGGER.success("Global components added");
92
+ };
93
+ const setupAutoImports = () => {
94
+ addImportsDir(AUTO_IMPORT_DIRS.map((dir) => resolve(dir)));
95
+ LOGGER.success(
96
+ `Auto-import directories added: [${AUTO_IMPORT_DIRS.join(", ")}]`
97
+ );
98
+ };
99
+ const setupPlugins = () => {
100
+ PLUGINS_CONFIG.forEach((plugin) => addPlugin(plugin));
101
+ LOGGER.success("Plugins added: ['auth', 'vue-json']");
102
+ };
103
+ const setupMiddleware = () => {
104
+ MIDDLEWARE_CONFIG.forEach((middleware) => addRouteMiddleware(middleware));
105
+ LOGGER.success("Middleware added: ['authentication', 'authorization']");
106
+ };
107
+ const setupI18n = () => {
108
+ if (!hasNuxtModule("@nuxtjs/i18n", _nuxt)) {
109
+ throw new Error("@nuxtjs/i18n module is required but not installed");
78
110
  }
79
- ];
80
- middlewares.forEach((middleware) => addRouteMiddleware(middleware));
81
- LOGGER.success("Middleware added: ['authentication', 'authorization']");
82
- const hasI18nModule = hasNuxtModule("@nuxtjs/i18n", _nuxt);
83
- if (hasI18nModule) {
84
111
  _nuxt.hook("i18n:registerModule", (register) => {
85
112
  register({
86
113
  langDir: resolve("i18n/locales"),
87
114
  locales: [{ code: "es", file: "es.json" }]
88
115
  });
89
116
  });
90
- LOGGER.success("i18n messages extended");
91
- LOGGER.start("Module setup completed!\n");
92
- } else {
93
- LOGGER.error(
94
- "@nuxtjs/i18n module is not registered in nuxt.config.ts!\n"
95
- );
96
- return;
117
+ LOGGER.success("i18n configuration completed");
118
+ };
119
+ try {
120
+ setupModuleBase();
121
+ setupPublicAssets();
122
+ setupPages();
123
+ setupLayouts();
124
+ setupComponents();
125
+ setupAutoImports();
126
+ setupPlugins();
127
+ setupMiddleware();
128
+ setupI18n();
129
+ LOGGER.success("Module setup completed successfully\n");
130
+ } catch (error) {
131
+ LOGGER.error("Module setup failed");
132
+ throw error;
97
133
  }
98
134
  }
99
135
  });
@@ -1,6 +1,5 @@
1
- import { type AsyncData } from "#app";
2
- import type { $Fetch, FetchError } from "ofetch";
3
- import type { IFetchParams, IRequestResponse } from "../types/index.js";
1
+ import type { $Fetch } from "ofetch";
2
+ import type { IApiCallWithAsyncData, IFetchParams } from "../types/index.js";
4
3
  /**
5
4
  * Clase que gestiona las peticiones HTTP .
6
5
  * Proporciona una forma sencilla de realizar llamadas a APIs con configuración opcional.
@@ -58,5 +57,5 @@ export declare class FetchClient {
58
57
  * }
59
58
  * }
60
59
  */
61
- call<T>({ method, url, body, fetchOptions, }: IFetchParams): Promise<AsyncData<Required<IRequestResponse<T>> | null, FetchError<any> | null>>;
60
+ call<T = unknown>(params: IFetchParams): Promise<IApiCallWithAsyncData<T>>;
62
61
  }
@@ -55,12 +55,13 @@ export class FetchClient {
55
55
  * }
56
56
  * }
57
57
  */
58
- async call({
59
- method = ERequestMethod.GET,
60
- url,
61
- body,
62
- fetchOptions
63
- }) {
58
+ async call(params) {
59
+ const {
60
+ method = ERequestMethod.GET,
61
+ url,
62
+ body = void 0,
63
+ fetchOptions = {}
64
+ } = params;
64
65
  return useAsyncData(() => {
65
66
  return this.$fetch(url, {
66
67
  method,
@@ -0,0 +1,40 @@
1
+ import { type IFormState, type ITableState, type TFormMode } from "#imports";
2
+ export declare const useCrudState: () => {
3
+ pagination: import("vue").ComputedRef<{
4
+ page: number;
5
+ size: number;
6
+ }>;
7
+ formState: import("vue").Ref<{
8
+ formMode: TFormMode;
9
+ openForm: boolean;
10
+ }, IFormState | {
11
+ formMode: TFormMode;
12
+ openForm: boolean;
13
+ }>;
14
+ tableState: import("vue").Ref<{
15
+ page: number;
16
+ itemsPerPage: {
17
+ value: number;
18
+ title: string;
19
+ };
20
+ textToSearch: string | null;
21
+ totalPages: number;
22
+ totalElements: number;
23
+ }, ITableState | {
24
+ page: number;
25
+ itemsPerPage: {
26
+ value: number;
27
+ title: string;
28
+ };
29
+ textToSearch: string | null;
30
+ totalPages: number;
31
+ totalElements: number;
32
+ }>;
33
+ resetTableStatus: () => void;
34
+ setFormMode: (newState: TFormMode) => void;
35
+ setOpenForm: (newState: boolean) => void;
36
+ updatePagination: (params: {
37
+ totalElements: number;
38
+ totalPages: number;
39
+ }) => void;
40
+ };
@@ -0,0 +1,41 @@
1
+ import { ref } from "vue";
2
+ import {
3
+ computed,
4
+ INITIAL_FORM_STATE,
5
+ INITIAL_TABLE_STATE,
6
+ useFormModeTrackerStore
7
+ } from "#imports";
8
+ export const useCrudState = () => {
9
+ const formState = ref(INITIAL_FORM_STATE);
10
+ const tableState = ref(INITIAL_TABLE_STATE);
11
+ const pagination = computed(() => {
12
+ return {
13
+ page: tableState.value.page - 1,
14
+ size: tableState.value.itemsPerPage.value
15
+ };
16
+ });
17
+ function resetTableStatus() {
18
+ tableState.value = INITIAL_TABLE_STATE;
19
+ }
20
+ function setFormMode(newState) {
21
+ const formModeTrackerStore = useFormModeTrackerStore();
22
+ formModeTrackerStore.setFormMode(newState);
23
+ formState.value.formMode = newState;
24
+ }
25
+ function setOpenForm(newState) {
26
+ formState.value.openForm = newState;
27
+ }
28
+ function updatePagination(params) {
29
+ tableState.value.totalElements = params.totalElements;
30
+ tableState.value.totalPages = params.totalPages;
31
+ }
32
+ return {
33
+ pagination,
34
+ formState,
35
+ tableState,
36
+ resetTableStatus,
37
+ setFormMode,
38
+ setOpenForm,
39
+ updatePagination
40
+ };
41
+ };
@@ -1,63 +1,75 @@
1
- import type { IAppStatusState, IRequestInfo, IRequestResponse } from "../types/index.js";
1
+ import type { IRequestInfo, IRequestResponse } from "../types/index.js";
2
+ interface IStateUpdateBeforeRequestOptions {
3
+ makingRequest?: boolean;
4
+ hasError?: boolean;
5
+ showInfo?: boolean;
6
+ keepPreviousInfo?: boolean;
7
+ info?: IRequestInfo | null;
8
+ }
9
+ interface IStateUpdateAfterRequestOptions {
10
+ showInfo?: boolean;
11
+ makingRequest?: boolean;
12
+ showInfoOnlyOnError?: boolean;
13
+ }
2
14
  /**
3
15
  * Store encargado de almacenar y gestionar la lógica de la aplicación.
4
16
  */
5
- export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStatusStore", IAppStatusState, {}, {
6
- /**
7
- * Actualiza el estado de si la aplicación está realizando una petición.
8
- *
9
- * @param {boolean} newState
10
- */
11
- setMakingRequest(newState: boolean): void;
12
- /**
13
- * Actualiza el estado de si la aplicación tiene un error.
14
- *
15
- * @param {boolean} newState
16
- */
17
- setHasError(newState: boolean): void;
18
- /**
19
- * Controla la visibilidad del snackbar.
20
- *
21
- * @param {boolean} newState
22
- */
23
- setShowInfo(newState: boolean): void;
24
- /**
25
- * Actualiza la información que se mostrará en el snackbar.
26
- *
27
- * @param {IRequestInfo} newState - Nueva información a mostrar en el snackbar (resultado de la peticion).
28
- */
29
- setInfo(newState: IRequestInfo): void;
30
- /**
31
- * Controla la visibilidad del diálogo de eliminación.
32
- *
33
- * @param {boolean} newState
34
- */
35
- setOpenDialogDelete(newState: boolean): void;
36
- /**
37
- * Controla la visibilidad del diálogo de exportación de tabla.
38
- *
39
- * @param {boolean} newState
40
- */
41
- setOpenDialogExport(newState: boolean): void;
42
- /**
43
- * Configura el estado de la aplicación antes de realizar una solicitud.
44
- *
45
- * @param {boolean} [makingRequest=true] - Si la aplicación está haciendo una petición.
46
- * @param {boolean} [hasError=false] - Si la aplicación tiene un error.
47
- * @param {boolean} [showInfo=false] - Si se debe mostrar el snackbar.
48
- * @param {IRequestInfo | null} [info=null] - Información a mostrar en el snackbar.
49
- */
50
- setStateBeforeRequest(makingRequest?: boolean, hasError?: boolean, showInfo?: boolean, info?: IRequestInfo | null): void;
51
- /**
52
- * Configura el estado de la aplicación antes de una solicitud, manteniendo la visibilidad del snackbar si está activo.
53
- */
54
- setStateBeforeRequestAndKeepShowInfo(): void;
55
- /**
56
- * Configura el estado de la aplicación después de realizar una solicitud.
57
- *
58
- * @param {IRequestResponse} response - Respuesta de la solicitud.
59
- * @param {boolean} [showInfo=true] - Si se debe mostrar el snackbar después de la solicitud.
60
- * @param {boolean} [makingRequest=false] - Si la solicitud ha finalizado.
61
- */
62
- setStateAfterRequest(response: IRequestResponse, showInfo?: boolean, makingRequest?: boolean): void;
63
- }>;
17
+ export declare const useAppStatusStore: import("pinia").StoreDefinition<"appStatusStore", import("pinia")._UnwrapAll<Pick<{
18
+ makingRequest: import("vue").Ref<boolean, boolean>;
19
+ hasError: import("vue").Ref<boolean, boolean>;
20
+ showInfo: import("vue").Ref<boolean, boolean>;
21
+ info: import("vue").Ref<{
22
+ title: string;
23
+ description: string;
24
+ } | null, IRequestInfo | {
25
+ title: string;
26
+ description: string;
27
+ } | null>;
28
+ openDialogDelete: import("vue").Ref<boolean, boolean>;
29
+ openDialogExport: import("vue").Ref<boolean, boolean>;
30
+ setMakingRequest: (newState: boolean) => void;
31
+ setShowInfo: (newState: boolean) => void;
32
+ setOpenDialogDelete: (newState: boolean) => void;
33
+ setOpenDialogExport: (newState: boolean) => void;
34
+ setStateBeforeRequest: (options?: IStateUpdateBeforeRequestOptions) => void;
35
+ setStateAfterRequest: <T = unknown>(response: IRequestResponse<T>, options?: IStateUpdateAfterRequestOptions) => void;
36
+ }, "makingRequest" | "hasError" | "showInfo" | "info" | "openDialogDelete" | "openDialogExport">>, Pick<{
37
+ makingRequest: import("vue").Ref<boolean, boolean>;
38
+ hasError: import("vue").Ref<boolean, boolean>;
39
+ showInfo: import("vue").Ref<boolean, boolean>;
40
+ info: import("vue").Ref<{
41
+ title: string;
42
+ description: string;
43
+ } | null, IRequestInfo | {
44
+ title: string;
45
+ description: string;
46
+ } | null>;
47
+ openDialogDelete: import("vue").Ref<boolean, boolean>;
48
+ openDialogExport: import("vue").Ref<boolean, boolean>;
49
+ setMakingRequest: (newState: boolean) => void;
50
+ setShowInfo: (newState: boolean) => void;
51
+ setOpenDialogDelete: (newState: boolean) => void;
52
+ setOpenDialogExport: (newState: boolean) => void;
53
+ setStateBeforeRequest: (options?: IStateUpdateBeforeRequestOptions) => void;
54
+ setStateAfterRequest: <T = unknown>(response: IRequestResponse<T>, options?: IStateUpdateAfterRequestOptions) => void;
55
+ }, never>, Pick<{
56
+ makingRequest: import("vue").Ref<boolean, boolean>;
57
+ hasError: import("vue").Ref<boolean, boolean>;
58
+ showInfo: import("vue").Ref<boolean, boolean>;
59
+ info: import("vue").Ref<{
60
+ title: string;
61
+ description: string;
62
+ } | null, IRequestInfo | {
63
+ title: string;
64
+ description: string;
65
+ } | null>;
66
+ openDialogDelete: import("vue").Ref<boolean, boolean>;
67
+ openDialogExport: import("vue").Ref<boolean, boolean>;
68
+ setMakingRequest: (newState: boolean) => void;
69
+ setShowInfo: (newState: boolean) => void;
70
+ setOpenDialogDelete: (newState: boolean) => void;
71
+ setOpenDialogExport: (newState: boolean) => void;
72
+ setStateBeforeRequest: (options?: IStateUpdateBeforeRequestOptions) => void;
73
+ setStateAfterRequest: <T = unknown>(response: IRequestResponse<T>, options?: IStateUpdateAfterRequestOptions) => void;
74
+ }, "setMakingRequest" | "setShowInfo" | "setOpenDialogDelete" | "setOpenDialogExport" | "setStateBeforeRequest" | "setStateAfterRequest">>;
75
+ export {};
@@ -1,99 +1,71 @@
1
1
  import { defineStore } from "pinia";
2
- export const useAppStatusStore = defineStore({
3
- id: "appStatusStore",
4
- state: () => ({
5
- makingRequest: false,
6
- hasError: false,
7
- showInfo: false,
8
- info: null,
9
- openDialogDelete: false,
10
- openDialogExport: false
11
- }),
12
- actions: {
13
- /**
14
- * Actualiza el estado de si la aplicación está realizando una petición.
15
- *
16
- * @param {boolean} newState
17
- */
18
- setMakingRequest(newState) {
19
- this.makingRequest = newState;
20
- },
21
- /**
22
- * Actualiza el estado de si la aplicación tiene un error.
23
- *
24
- * @param {boolean} newState
25
- */
26
- setHasError(newState) {
27
- this.hasError = newState;
28
- },
29
- /**
30
- * Controla la visibilidad del snackbar.
31
- *
32
- * @param {boolean} newState
33
- */
34
- setShowInfo(newState) {
35
- this.showInfo = newState;
36
- },
37
- /**
38
- * Actualiza la información que se mostrará en el snackbar.
39
- *
40
- * @param {IRequestInfo} newState - Nueva información a mostrar en el snackbar (resultado de la peticion).
41
- */
42
- setInfo(newState) {
43
- this.info = newState;
44
- },
45
- /**
46
- * Controla la visibilidad del diálogo de eliminación.
47
- *
48
- * @param {boolean} newState
49
- */
50
- setOpenDialogDelete(newState) {
51
- this.openDialogDelete = newState;
52
- },
53
- /**
54
- * Controla la visibilidad del diálogo de exportación de tabla.
55
- *
56
- * @param {boolean} newState
57
- */
58
- setOpenDialogExport(newState) {
59
- this.openDialogExport = newState;
60
- },
61
- /**
62
- * Configura el estado de la aplicación antes de realizar una solicitud.
63
- *
64
- * @param {boolean} [makingRequest=true] - Si la aplicación está haciendo una petición.
65
- * @param {boolean} [hasError=false] - Si la aplicación tiene un error.
66
- * @param {boolean} [showInfo=false] - Si se debe mostrar el snackbar.
67
- * @param {IRequestInfo | null} [info=null] - Información a mostrar en el snackbar.
68
- */
69
- setStateBeforeRequest(makingRequest = true, hasError = false, showInfo = false, info = null) {
70
- this.makingRequest = makingRequest;
71
- this.hasError = hasError;
72
- this.showInfo = showInfo;
73
- this.info = info;
74
- },
75
- /**
76
- * Configura el estado de la aplicación antes de una solicitud, manteniendo la visibilidad del snackbar si está activo.
77
- */
78
- setStateBeforeRequestAndKeepShowInfo() {
79
- if (!this.showInfo) {
80
- this.setStateBeforeRequest();
81
- } else {
82
- this.setMakingRequest(true);
83
- }
84
- },
85
- /**
86
- * Configura el estado de la aplicación después de realizar una solicitud.
87
- *
88
- * @param {IRequestResponse} response - Respuesta de la solicitud.
89
- * @param {boolean} [showInfo=true] - Si se debe mostrar el snackbar después de la solicitud.
90
- * @param {boolean} [makingRequest=false] - Si la solicitud ha finalizado.
91
- */
92
- setStateAfterRequest(response, showInfo = true, makingRequest = false) {
93
- this.hasError = !response.success;
94
- this.info = { title: response.title, description: response.description };
95
- this.showInfo = showInfo;
96
- this.makingRequest = makingRequest;
2
+ import { ref } from "vue";
3
+ export const useAppStatusStore = defineStore("appStatusStore", () => {
4
+ const makingRequest = ref(false);
5
+ const hasError = ref(false);
6
+ const showInfo = ref(false);
7
+ const info = ref(null);
8
+ const openDialogDelete = ref(false);
9
+ const openDialogExport = ref(false);
10
+ function setMakingRequest(newState) {
11
+ makingRequest.value = newState;
12
+ }
13
+ function setShowInfo(newState) {
14
+ showInfo.value = newState;
15
+ }
16
+ function setOpenDialogDelete(newState) {
17
+ openDialogDelete.value = newState;
18
+ }
19
+ function setOpenDialogExport(newState) {
20
+ openDialogExport.value = newState;
21
+ }
22
+ function setStateBeforeRequest(options = {}) {
23
+ const {
24
+ makingRequest: makingRequestOpt = true,
25
+ hasError: hasErrorOpt = false,
26
+ showInfo: showInfoOpt = false,
27
+ keepPreviousInfo = false,
28
+ info: infoOpt = null
29
+ } = options;
30
+ if (keepPreviousInfo && showInfo.value) {
31
+ setMakingRequest(true);
32
+ return;
33
+ }
34
+ makingRequest.value = makingRequestOpt;
35
+ hasError.value = hasErrorOpt;
36
+ showInfo.value = showInfoOpt;
37
+ info.value = infoOpt;
38
+ }
39
+ function setStateAfterRequest(response, options = {}) {
40
+ const {
41
+ showInfo: showInfoOpt = true,
42
+ makingRequest: makingRequestOpt = false,
43
+ showInfoOnlyOnError = false
44
+ } = options;
45
+ hasError.value = !response.success;
46
+ showInfo.value = showInfoOpt;
47
+ makingRequest.value = makingRequestOpt;
48
+ if (response.success || showInfoOnlyOnError) {
49
+ info.value = {
50
+ title: response.title,
51
+ description: response.description
52
+ };
97
53
  }
98
54
  }
55
+ return {
56
+ // State
57
+ makingRequest,
58
+ hasError,
59
+ showInfo,
60
+ info,
61
+ openDialogDelete,
62
+ openDialogExport,
63
+ // Actions
64
+ setMakingRequest,
65
+ setShowInfo,
66
+ setOpenDialogDelete,
67
+ setOpenDialogExport,
68
+ setStateBeforeRequest,
69
+ setStateAfterRequest
70
+ };
99
71
  });
@@ -1,3 +1,5 @@
1
+ import type { AsyncData } from "#app";
2
+ import type { FetchError } from "ofetch";
1
3
  import type { EAuthorization, EFormField, EFormMode, ERequestMethod, EVuetifyDateFormats } from "../enums/index.js";
2
4
  import type { FetchOptions } from "ofetch";
3
5
  export { FetchClient } from "../classes/FetchClient.js";
@@ -113,6 +115,8 @@ export interface IFetchParams {
113
115
  */
114
116
  fetchOptions?: FetchOptions<"json">;
115
117
  }
118
+ export interface IApiCallWithAsyncData<T = unknown> extends AsyncData<IRequestResponse<T> | null, FetchError<any> | null> {
119
+ }
116
120
  /**
117
121
  * Interfaz para la información base de respuesta de las peticiones.
118
122
  *
@@ -319,7 +323,7 @@ export interface IBaseStore {
319
323
  * @interface IGetAllParams
320
324
  */
321
325
  export interface IGetAllParams {
322
- makingRequest: boolean;
326
+ makingRequest?: boolean;
323
327
  }
324
328
  /**
325
329
  * Interfaz para el Store de estado de la aplicación.
@@ -573,11 +577,11 @@ export interface IBreadCumbElement {
573
577
  */
574
578
  export interface IBreadCumbs {
575
579
  /** Breadcumbs para listado */
576
- LIST: IBreadCumbElement[];
580
+ list: IBreadCumbElement[];
577
581
  /** Breadcumbs para creación */
578
- CREATE: IBreadCumbElement[];
582
+ create: IBreadCumbElement[];
579
583
  /** Breadcumbs para edición */
580
- EDIT: IBreadCumbElement[];
584
+ edit: IBreadCumbElement[];
581
585
  }
582
586
  export type TFormBuilderField = IFormBuilderFieldText | IFormBuilderFieldTextArea | IFormBuilderFieldNumber | IFormBuilderFieldDate | IFormBuilderFieldSelect | IFormBuilderFieldSlot | IFormBuilderFieldCheckBox | IFormBuilderFieldRadioButton | IFormBuilderFieldSwitch;
583
587
  export interface IFormBuilderConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Módulo Nuxt para desarrollo CGI",
5
5
  "repository": {
6
6
  "type": "git",