@arex95/vue-core 1.0.4 → 1.0.6
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/README.md
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# @arex95/vue-core
|
|
2
|
+
|
|
3
|
+
Opinionated Vue Core
|
|
4
|
+
|
|
5
|
+
## Descripción
|
|
6
|
+
|
|
7
|
+
Este proyecto es un conjunto de composables y utilidades para Vue.js, diseñado para facilitar el desarrollo de aplicaciones Vue. Proporciona herramientas para manejar peticiones HTTP con Axios, aplicar filtros personalizados, y crear paginadores flexibles. Además, incluye wrappers para TanStack Vue Query, que simplifican la gestión de estados de datos asíncronos, y una implementación estándar para interactuar con APIs RESTful, facilitando la creación, lectura, actualización y eliminación de recursos.
|
|
8
|
+
|
|
9
|
+
## Estructura del Proyecto
|
|
10
|
+
|
|
11
|
+
- **src/composables**: Contiene composables reutilizables para Axios, filtros, paginadores y ordenadores.
|
|
12
|
+
- **src/config**: Configuraciones para Axios.
|
|
13
|
+
- **src/constants**: Constantes utilizadas en el proyecto, como enumeraciones de breakpoints, excepciones, tipos de archivos, etc.
|
|
14
|
+
- **src/rest**: Implementación estándar de una interfaz REST para operaciones CRUD. Proporciona una forma sencilla y estandarizada de interactuar con APIs RESTful, facilitando la creación de servicios que pueden realizar operaciones como crear, leer, actualizar y eliminar recursos.
|
|
15
|
+
- **src/types**: Tipos TypeScript utilizados en el proyecto.
|
|
16
|
+
- **src/utils**: Utilidades varias, como funciones para manejar fechas, validaciones, manipulación de strings, etc.
|
|
17
|
+
|
|
18
|
+
## Instalación
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install @arex95/vue-core
|
|
@@ -3,8 +3,7 @@ import { UseQueryOptions } from '@tanstack/vue-query';
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a fetchComposable for Axios requests with an optional custom instance.
|
|
5
5
|
* @param fetchComposable - The composable to use for the request (can be any fetch function).
|
|
6
|
-
* @param
|
|
7
|
-
* @param axiosInstance - An optional custom Axios instance to use for the request.
|
|
6
|
+
* @param axiosCustomInstance - An optional custom Axios instance to use for the request.
|
|
8
7
|
* @returns A function that handles the request using the provided composable.
|
|
9
8
|
*/
|
|
10
|
-
export declare function createFetch(fetchComposable: Function,
|
|
9
|
+
export declare function createFetch(fetchComposable: Function, axiosCustomInstance?: AxiosInstance): (axiosRequestConfig: AxiosRequestConfig, options?: UseQueryOptions) => any;
|
package/dist/index.mjs
CHANGED
|
@@ -239,15 +239,25 @@ class AxiosService {
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
let axiosInstance;
|
|
243
|
+
const configureAxios = (baseURL) => {
|
|
244
|
+
axiosInstance = new AxiosService(baseURL);
|
|
245
|
+
};
|
|
246
|
+
const getAxiosInstance = () => {
|
|
247
|
+
if (!axiosInstance) {
|
|
248
|
+
throw new Error('Axios instance not configured. Call configureAxios first.');
|
|
249
|
+
}
|
|
250
|
+
return axiosInstance.getAxiosInstance();
|
|
251
|
+
};
|
|
252
|
+
|
|
242
253
|
/**
|
|
243
254
|
* Creates a fetchComposable for Axios requests with an optional custom instance.
|
|
244
255
|
* @param fetchComposable - The composable to use for the request (can be any fetch function).
|
|
245
|
-
* @param
|
|
246
|
-
* @param axiosInstance - An optional custom Axios instance to use for the request.
|
|
256
|
+
* @param axiosCustomInstance - An optional custom Axios instance to use for the request.
|
|
247
257
|
* @returns A function that handles the request using the provided composable.
|
|
248
258
|
*/
|
|
249
|
-
function createFetch(fetchComposable,
|
|
250
|
-
const instance =
|
|
259
|
+
function createFetch(fetchComposable, axiosCustomInstance) {
|
|
260
|
+
const instance = axiosCustomInstance || getAxiosInstance();
|
|
251
261
|
return (axiosRequestConfig, options) => {
|
|
252
262
|
return fetchComposable(instance, axiosRequestConfig, options);
|
|
253
263
|
};
|
|
@@ -2447,4 +2457,4 @@ function isValidHexNumber(hex) {
|
|
|
2447
2457
|
// console.log(isValidHexNumber('1A3F')); // true
|
|
2448
2458
|
// console.log(isValidHexNumber('GHIJ')); // false
|
|
2449
2459
|
|
|
2450
|
-
export { APP_LOCAL_CACHE_KEY, APP_SESSION_CACHE_KEY, AxiosService, CacheTypeEnum, ContentTypeEnum, ExceptionEnum, FileMetaTypes, ImageTypes, KeyCodeEnum, LOCALE_KEY, LOCK_INFO_KEY, PROJ_CFG_KEY, ROLES_KEY, RestStd, TOKEN_KEY, USER_INFO_KEY, addCustomKeyboardShortcut, addDays, addDoubleClickListener, addKeyListener, ageAtDate, axiosFetch, blobToFormData, bufferToBlob, calculateAge, clickOutside, compareObject, copyToClipboard, countWords, createFetch, createKeyMap, customShortcut, daysBetween, daysToNextBirthday, debounce, debounceAsync, debounceAsyncValidator, debounceAsyncWithImmediate, debounceLeading, debounceLeadingTrailing, debounceTrailing, deepClone, deepEqual, deepMerge, detectKeyHold, disableCopy, disableF12Key, disableMouseButtons, disableRightClick, disableSpecificKeys, downloadBlob, enableMouseButtons, enableRightClick, enableSpecificKeys, exportToCSV, exportToExcel, exportToJSON, exportToText, exportToXML, filterObjectByKeys, flattenObject, formDataToObject, formatDate, generateRandomString, getEndOfMonth, getObjectDifferences, getObjectKeys, getQueryParam, getStartOfMonth, hasNestedProperties, isEmptyObject, isLeapYear, isStrongPassword, isValidAge, isValidCreditCard, isValidDate, isValidEmail, isValidExpiryDate, isValidHexColor, isValidHexColorAlpha, isValidHexNumber, isValidIP, isValidPhoneNumber, isValidSSN, isValidTime, isValidURL, isValidUsername, isValidZIP, lowerFirst, objectToFormData, objectToFormDataEnhanced, objectToQueryString, openWindow, parseDate, proxyToPlainObject, readFileAsDataURL, readFileAsText, registerKeyboardShortcuts, removeAccent, removeClickOutside, removeCustomKeyboardShortcut, removeCustomShortcuts, removeDoubleClickListener, removeEmptyProperties, removeKeyListeners, replaceAll, reverseString, safeGet, screenEnum, screenMap, scrollToTop, simulateKeyPress, sizeEnum, stopDetectingKeyHold, stringToBlob, subtractDays, throttle, toCamelCase, toKebabCase, toggleTabNavigation, truncateString, unregisterKeyboardShortcuts, upperFirst, useBreakpoint, useFilter, usePagination, useSorter, useVueQuery, validateAlphanumeric, validateLetters, validateNumbers };
|
|
2460
|
+
export { APP_LOCAL_CACHE_KEY, APP_SESSION_CACHE_KEY, AxiosService, CacheTypeEnum, ContentTypeEnum, ExceptionEnum, FileMetaTypes, ImageTypes, KeyCodeEnum, LOCALE_KEY, LOCK_INFO_KEY, PROJ_CFG_KEY, ROLES_KEY, RestStd, TOKEN_KEY, USER_INFO_KEY, addCustomKeyboardShortcut, addDays, addDoubleClickListener, addKeyListener, ageAtDate, axiosFetch, blobToFormData, bufferToBlob, calculateAge, clickOutside, compareObject, configureAxios, copyToClipboard, countWords, createFetch, createKeyMap, customShortcut, daysBetween, daysToNextBirthday, debounce, debounceAsync, debounceAsyncValidator, debounceAsyncWithImmediate, debounceLeading, debounceLeadingTrailing, debounceTrailing, deepClone, deepEqual, deepMerge, detectKeyHold, disableCopy, disableF12Key, disableMouseButtons, disableRightClick, disableSpecificKeys, downloadBlob, enableMouseButtons, enableRightClick, enableSpecificKeys, exportToCSV, exportToExcel, exportToJSON, exportToText, exportToXML, filterObjectByKeys, flattenObject, formDataToObject, formatDate, generateRandomString, getAxiosInstance, getEndOfMonth, getObjectDifferences, getObjectKeys, getQueryParam, getStartOfMonth, hasNestedProperties, isEmptyObject, isLeapYear, isStrongPassword, isValidAge, isValidCreditCard, isValidDate, isValidEmail, isValidExpiryDate, isValidHexColor, isValidHexColorAlpha, isValidHexNumber, isValidIP, isValidPhoneNumber, isValidSSN, isValidTime, isValidURL, isValidUsername, isValidZIP, lowerFirst, objectToFormData, objectToFormDataEnhanced, objectToQueryString, openWindow, parseDate, proxyToPlainObject, readFileAsDataURL, readFileAsText, registerKeyboardShortcuts, removeAccent, removeClickOutside, removeCustomKeyboardShortcut, removeCustomShortcuts, removeDoubleClickListener, removeEmptyProperties, removeKeyListeners, replaceAll, reverseString, safeGet, screenEnum, screenMap, scrollToTop, simulateKeyPress, sizeEnum, stopDetectingKeyHold, stringToBlob, subtractDays, throttle, toCamelCase, toKebabCase, toggleTabNavigation, truncateString, unregisterKeyboardShortcuts, upperFirst, useBreakpoint, useFilter, usePagination, useSorter, useVueQuery, validateAlphanumeric, validateLetters, validateNumbers };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arex95/vue-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Opinionated Vue Core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,24 +28,26 @@
|
|
|
28
28
|
"author": "Arturo Rafael Serrano Girón",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tanstack/vue-query": "
|
|
32
|
-
"@vueuse/core": "
|
|
33
|
-
"axios": "
|
|
34
|
-
"vue": "
|
|
31
|
+
"@tanstack/vue-query": ">=5.0.0",
|
|
32
|
+
"@vueuse/core": ">=12.8.2",
|
|
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"
|
|
35
41
|
},
|
|
36
42
|
"devDependencies": {
|
|
37
43
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
38
44
|
"@rollup/plugin-json": "^6.1.0",
|
|
39
45
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
40
46
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
41
|
-
"@tanstack/vue-query": "^5.0.0",
|
|
42
47
|
"@types/node": "^22.13.9",
|
|
43
|
-
"@vueuse/core": "^12.8.2",
|
|
44
|
-
"axios": "^1.6.0",
|
|
45
48
|
"rollup": "^4.34.9",
|
|
46
49
|
"ts-node": "^10.9.2",
|
|
47
50
|
"tslib": "^2.8.1",
|
|
48
|
-
"typescript": "^5.0.0"
|
|
49
|
-
"vue": "^3.0.0"
|
|
51
|
+
"typescript": "^5.0.0"
|
|
50
52
|
}
|
|
51
|
-
}
|
|
53
|
+
}
|