@arex95/vue-core 1.0.6 → 1.0.7

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.
@@ -1,10 +1,19 @@
1
- /**
2
- * A standard REST API interface for handling basic CRUD operations.
3
- * This class can be instantiated with a resource endpoint and a fetch composable for API requests.
4
- */
5
1
  export declare class RestStd {
6
2
  static resource: string;
3
+ static isFormData: boolean;
4
+ static headers: Record<string, string>;
7
5
  static fetchComposable: Function;
6
+ /**
7
+ * Set global headers for all requests.
8
+ * @param headers Object containing headers to be set globally.
9
+ */
10
+ static setHeaders(headers: Record<string, string>): void;
11
+ /**
12
+ * Convert data to FormData if isFormData is true, otherwise return the data as is.
13
+ * @param data Data to be converted.
14
+ * @returns Data in FormData format or as is.
15
+ */
16
+ static transformData(data: any): any;
8
17
  /**
9
18
  * Fetch a list of items from the server.
10
19
  *
@@ -62,9 +71,17 @@ export declare class RestStd {
62
71
  * @param method HTTP method (GET, POST, etc.).
63
72
  * @param params Query parameters.
64
73
  * @param data Request body data.
65
- * @param token Authorization token (optional).
66
74
  * @param options Additional options for the fetch composable.
67
75
  * @returns The result of the fetch composable (typically a promise).
68
76
  */
69
77
  static customRequest<T>(method: string, params?: Record<string, any>, data?: any, options?: object): any;
78
+ /**
79
+ * Save method that decides whether to create or update based on the presence of 'id'.
80
+ * It calls either create or update based on the data.
81
+ *
82
+ * @param data The data for the item to create or update.
83
+ * @param options Additional options for the fetch composable.
84
+ * @returns The result of the fetch composable (typically a promise).
85
+ */
86
+ static save<T>(data: any, options?: object): any;
70
87
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tipos de errores permitidos
3
+ */
4
+ export type ErrorType = 'warning' | 'error' | 'critical' | 'validation' | 'component' | 'network' | 'authentication' | 'runtime' | 'type' | 'reference' | 'syntax' | 'range' | 'eval' | 'uri';
5
+ /**
6
+ * Métodos disponibles para pasar errores a la ruta
7
+ */
8
+ export type ErrorPassMethod = 'query' | 'localStorage' | 'sessionStorage';
@@ -1,2 +1,3 @@
1
1
  export * from './AxiosOptionsParameter';
2
2
  export * from './ExtendedQueryOptions';
3
+ export * from './ErrorType';
@@ -0,0 +1,10 @@
1
+ import { ErrorPassMethod } from '@/types';
2
+ /**
3
+ * Maneja y registra errores en la consola, además de permitir redirecciones configurables.
4
+ * @param error - Error capturado (string o Error)
5
+ * @param redirect - `true` si se quiere redirigir a una página de error
6
+ * @param route - Ruta personalizada para la página de error (por defecto: `/error`)
7
+ * @param passMethod - Método para pasar el error a la ruta (`query`, `localStorage`, `sessionStorage`)
8
+ * @returns Mensaje user-friendly del error
9
+ */
10
+ export declare function handleError(error: unknown, redirect?: boolean, route?: string, passMethod?: ErrorPassMethod): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arex95/vue-core",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Opinionated Vue Core",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,23 +31,28 @@
31
31
  "@tanstack/vue-query": ">=5.0.0",
32
32
  "@vueuse/core": ">=12.8.2",
33
33
  "axios": ">=1.6.0",
34
- "vue": ">=3.0.0"
35
- },
36
- "optionalDependencies": {
37
- "@tanstack/vue-query": ">=5.0.0",
38
- "@vueuse/core": ">=12.8.2",
39
- "axios": ">=1.6.0",
40
- "vue": ">=3.0.0"
34
+ "vue": ">=3.0.0",
35
+ "vue-router": "^4.5.0"
41
36
  },
42
37
  "devDependencies": {
43
38
  "@rollup/plugin-commonjs": "^28.0.3",
44
39
  "@rollup/plugin-json": "^6.1.0",
45
40
  "@rollup/plugin-node-resolve": "^16.0.0",
46
41
  "@rollup/plugin-typescript": "^12.1.2",
47
- "@types/node": "^22.13.9",
48
- "rollup": "^4.34.9",
42
+ "@types/crypto-js": "^4.2.2",
43
+ "@types/node": "^22.13.10",
44
+ "rollup": "^4.35.0",
49
45
  "ts-node": "^10.9.2",
50
46
  "tslib": "^2.8.1",
51
- "typescript": "^5.0.0"
47
+ "typescript": "^5.8.2"
48
+ },
49
+ "dependencies": {
50
+ "crypto-js": "^4.2.0",
51
+ "jwt-decode": "^4.0.0",
52
+ "vue-router": "^4.5.0",
53
+ "@tanstack/vue-query": ">=5.0.0",
54
+ "@vueuse/core": ">=12.8.2",
55
+ "axios": ">=1.6.0",
56
+ "vue": ">=3.0.0"
52
57
  }
53
- }
58
+ }