@arex95/vue-core 1.1.43 → 3.0.0

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.
Files changed (74) hide show
  1. package/README.md +90 -57
  2. package/dist/composables/auth/useAuth.d.ts +20 -6
  3. package/dist/composables/axios/axiosFetch.d.ts +7 -5
  4. package/dist/composables/axios/index.d.ts +0 -1
  5. package/dist/composables/axios/useFetch.d.ts +14 -5
  6. package/dist/composables/breakpoints/useBreakpoint.d.ts +11 -2
  7. package/dist/composables/filters/useFilter.d.ts +13 -8
  8. package/dist/composables/monitoring/useApiActivity.d.ts +17 -6
  9. package/dist/composables/monitoring/useUserActivity.d.ts +20 -5
  10. package/dist/composables/paginators/usePaginator.d.ts +13 -5
  11. package/dist/composables/sorters/useSorter.d.ts +13 -7
  12. package/dist/config/auth/authFetcher.d.ts +30 -0
  13. package/dist/config/auth/index.d.ts +1 -0
  14. package/dist/config/axios/axiosConfig.d.ts +30 -0
  15. package/dist/config/axios/axiosInstance.d.ts +14 -0
  16. package/dist/config/global/endpointsConfig.d.ts +9 -13
  17. package/dist/config/global/keyConfig.d.ts +7 -10
  18. package/dist/config/global/sessionConfig.d.ts +15 -17
  19. package/dist/config/global/tokenPathsConfig.d.ts +17 -18
  20. package/dist/config/global/tokensConfig.d.ts +9 -9
  21. package/dist/config/index.d.ts +1 -0
  22. package/dist/enums/breakpointsEnums.d.ts +7 -4
  23. package/dist/enums/errorsEnums.d.ts +26 -19
  24. package/dist/enums/fileTypesEnums.d.ts +33 -1
  25. package/dist/enums/httpExceptionsEnums.d.ts +3 -1
  26. package/dist/enums/keyCodesEnums.d.ts +2 -4
  27. package/dist/enums/storageEnums.d.ts +4 -4
  28. package/dist/errors/AuthError.d.ts +10 -0
  29. package/dist/errors/BaseError.d.ts +16 -0
  30. package/dist/errors/NetworkError.d.ts +9 -0
  31. package/dist/errors/ServerError.d.ts +10 -0
  32. package/dist/errors/ValidationError.d.ts +14 -0
  33. package/dist/errors/index.d.ts +5 -0
  34. package/dist/fetchers/axios.d.ts +22 -0
  35. package/dist/fetchers/index.d.ts +2 -0
  36. package/dist/fetchers/ofetch.d.ts +33 -0
  37. package/dist/index.d.ts +8 -6
  38. package/dist/index.mjs +1633 -875
  39. package/dist/rest/RestStd.d.ts +146 -102
  40. package/dist/services/credentials.d.ts +24 -29
  41. package/dist/services/extractTokens.d.ts +7 -6
  42. package/dist/services/refreshTokens.d.ts +11 -12
  43. package/dist/services/storeTokens.d.ts +8 -6
  44. package/dist/types/AppKeyConfig.d.ts +7 -0
  45. package/dist/types/ArexVueCoreOptions.d.ts +20 -0
  46. package/dist/types/Auth.d.ts +15 -0
  47. package/dist/types/AxiosOptionsParameter.d.ts +14 -7
  48. package/dist/types/AxiosServiceOptions.d.ts +9 -0
  49. package/dist/types/DecodedJwtPayload.d.ts +12 -0
  50. package/dist/types/EndpointsConfig.d.ts +7 -0
  51. package/dist/types/ErrorType.d.ts +4 -2
  52. package/dist/types/ExtendedQueryOptions.d.ts +10 -0
  53. package/dist/types/Fetcher.d.ts +24 -0
  54. package/dist/types/RestStdOptions.d.ts +62 -0
  55. package/dist/types/SessionConfig.d.ts +25 -1
  56. package/dist/types/TokenConfig.d.ts +7 -0
  57. package/dist/types/TokenValidationResult.d.ts +7 -0
  58. package/dist/types/index.d.ts +2 -0
  59. package/dist/utils/browser.d.ts +20 -14
  60. package/dist/utils/dates.d.ts +47 -34
  61. package/dist/utils/debounces.d.ts +54 -32
  62. package/dist/utils/encryption.d.ts +28 -24
  63. package/dist/utils/errors.d.ts +27 -8
  64. package/dist/utils/exports.d.ts +24 -19
  65. package/dist/utils/files.d.ts +33 -25
  66. package/dist/utils/index.d.ts +3 -0
  67. package/dist/utils/io.d.ts +70 -54
  68. package/dist/utils/objects.d.ts +78 -60
  69. package/dist/utils/retry.d.ts +8 -0
  70. package/dist/utils/ssr.d.ts +27 -0
  71. package/dist/utils/storage.d.ts +20 -14
  72. package/dist/utils/strings.d.ts +42 -31
  73. package/dist/utils/validations.d.ts +76 -57
  74. package/package.json +7 -16
@@ -3,34 +3,33 @@ interface TokenPathsConfig {
3
3
  refreshTokenPath?: string;
4
4
  }
5
5
  /**
6
- * Configures the paths for access and refresh tokens in the authentication response.
7
- * This function freezes the object to prevent further modifications.
6
+ * Configures the dot-notation paths for extracting access and refresh tokens from the initial login response.
7
+ * The configuration is frozen to prevent runtime changes.
8
8
  *
9
- * @param {TokenPathsConfig} config - An object containing the paths for access and refresh tokens.
10
- * @param {string} [config.accessTokenPath="data.access_token"] - Path to the access token in the response.
11
- * @param {string} [config.refreshTokenPath="data.refresh_token"] - Path to the refresh token in the response.
12
- *
13
- * @returns {void} Does not return anything but freezes the token paths configuration object.
9
+ * @param {TokenPathsConfig} config - An object containing the token paths.
10
+ * @param {string} [config.accessTokenPath="data.access_token"] - The path to the access token.
11
+ * @param {string} [config.refreshTokenPath="data.refresh_token"] - The path to the refresh token.
14
12
  */
15
13
  export declare function configTokenPaths(config: TokenPathsConfig): void;
16
14
  /**
17
- * Configures the paths for access and refresh tokens in the refresh response.
18
- * This function freezes the object to prevent further modifications.
19
- *
20
- * @param {TokenPathsConfig} config - An object containing the paths for access and refresh tokens.
21
- * @param {string} [config.accessTokenPath="data.access_token"] - Path to the access token in the response.
22
- * @param {string} [config.refreshTokenPath="data.refresh_token"] - Path to the refresh token in the response.
15
+ * Configures the dot-notation paths for extracting access and refresh tokens from the token refresh response.
16
+ * The configuration is frozen to prevent runtime changes.
23
17
  *
24
- * @returns {void} Does not return anything but freezes the refresh token paths configuration object.
18
+ * @param {TokenPathsConfig} config - An object containing the token paths for the refresh response.
19
+ * @param {string} [config.accessTokenPath="data.access_token"] - The path to the new access token.
20
+ * @param {string} [config.refreshTokenPath="data.refresh_token"] - The path to the new refresh token.
25
21
  */
26
22
  export declare function configRefreshTokenPaths(config: TokenPathsConfig): void;
27
23
  /**
28
- * Retrieves the configured authentication token paths.
24
+ * Retrieves the configured token paths for the initial login response.
29
25
  *
30
- * @returns {AuthTokenPaths} An object containing the configured authentication token paths.
31
- * @property {string} accessTokenPath - Path to the access token in the response.
32
- * @property {string} refreshTokenPath - Path to the refresh token in the response.
26
+ * @returns {AuthTokenPaths} A frozen object containing the `accessTokenPath` and `refreshTokenPath`.
33
27
  */
34
28
  export declare function getTokenPathsConfig(): TokenPathsConfig;
29
+ /**
30
+ * Retrieves the configured token paths for the token refresh response.
31
+ *
32
+ * @returns {AuthTokenPaths} A frozen object containing the `accessTokenPath` and `refreshTokenPath` for the refresh response.
33
+ */
35
34
  export declare function getRefreshTokenPathsConfig(): TokenPathsConfig;
36
35
  export {};
@@ -7,20 +7,20 @@ interface TokenKeyConfig {
7
7
  refreshTokenKey: string;
8
8
  }
9
9
  /**
10
- * Configures the global keys for access and refresh tokens.
11
- * Once set, they cannot be modified.
10
+ * Configures the global storage keys for the access and refresh tokens.
11
+ * This function should be called once at application startup to define the keys
12
+ * used for storing tokens in `localStorage` or `sessionStorage`. The configuration
13
+ * is frozen to prevent runtime changes.
12
14
  *
13
- * @param {TokenKeyConfig} config - An object containing the token keys.
14
- * @param {string} config.accessTokenKey - The name of the key for the access token.
15
- * @param {string} config.refreshTokenKey - The name of the key for the refresh token.
16
- *
17
- * @returns {void} Does not return anything, but freezes the token configuration object.
15
+ * @param {TokenKeyConfig} config - An object containing the token storage keys.
16
+ * @param {string} config.accessTokenKey - The key for the access token.
17
+ * @param {string} config.refreshTokenKey - The key for the refresh token.
18
18
  */
19
19
  export declare function configTokenKeys(config: TokenKeyConfig): void;
20
20
  /**
21
- * Retrieves the current token configuration.
21
+ * Retrieves the configured storage keys for the access and refresh tokens.
22
22
  *
23
- * @returns {TokensConfig} The configuration of the access and refresh token keys.
23
+ * @returns {TokensConfig} A frozen object containing the `ACCESS_TOKEN` and `REFRESH_TOKEN` keys.
24
24
  */
25
25
  export declare function getTokenConfig(): TokensConfig;
26
26
  export {};
@@ -1,2 +1,3 @@
1
1
  export * from './axios';
2
2
  export * from './global';
3
+ export * from './auth';
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Enum defining available screen sizes.
2
+ * An enum that defines a set of standardized screen size labels, ranging from extra-small (XS) to extra-extra-large (XXL).
3
+ * These labels are used to create a consistent vocabulary for responsive design across the application.
3
4
  */
4
5
  export declare enum ScreenSize {
5
6
  XS = "XS",
@@ -10,8 +11,8 @@ export declare enum ScreenSize {
10
11
  XXL = "XXL"
11
12
  }
12
13
  /**
13
- * Enum defining breakpoints for design based on screen width.
14
- * Values are in pixels.
14
+ * An enum that establishes specific pixel values for screen width breakpoints, corresponding to the labels in `ScreenSize`.
15
+ * These values are used to implement responsive design changes at standard device widths.
15
16
  */
16
17
  export declare enum ScreenBreakpoint {
17
18
  XS = 480,
@@ -22,7 +23,9 @@ export declare enum ScreenBreakpoint {
22
23
  XXL = 1600
23
24
  }
24
25
  /**
25
- * Map that associates each screen size defined in `ScreenSize` with its corresponding pixel value from `ScreenBreakpoint`.
26
+ * A map that associates the symbolic screen size names from the `ScreenSize` enum with their
27
+ * corresponding pixel values from the `ScreenBreakpoint` enum. This provides an easy way to
28
+ * look up the pixel width for a given screen size label.
26
29
  * @type {Map<ScreenSize, number>}
27
30
  */
28
31
  declare const screenMap: Map<ScreenSize, number>;
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Enum representing different types of errors.
2
+ * An enum that defines a vocabulary of error types, covering a wide range of potential issues
3
+ * from validation and network problems to runtime and syntax errors. This provides a standardized
4
+ * way to classify errors throughout the application.
3
5
  * @readonly
4
6
  */
5
7
  export declare enum ErrorEnum {
@@ -19,27 +21,30 @@ export declare enum ErrorEnum {
19
21
  URI = "uri"
20
22
  }
21
23
  /**
22
- * Enum representing different error messages.
24
+ * An enum that provides standardized, user-friendly messages for different error types.
25
+ * These messages are intended to be displayed to the user or used in logs.
23
26
  * @readonly
24
27
  */
25
28
  export declare enum ErrorMessages {
26
- WARNING = "Algo no est\u00E1 del todo bien. Verifica y vuelve a intentar.",
27
- ERROR = "Ocurri\u00F3 un error inesperado.",
28
- CRITICAL = "Error cr\u00EDtico. Contacta al soporte t\u00E9cnico.",
29
- VALIDATION = "Hay errores en el formulario. Revisa los campos.",
30
- COMPONENT = "Error en la carga del componente. Intenta recargar.",
31
- NETWORK = "Problema de conexi\u00F3n. Verifica tu internet.",
32
- AUTHENTICATION = "No tienes permisos para realizar esta acci\u00F3n.",
33
- RUNTIME = "Error de ejecuci\u00F3n. Intenta nuevamente.",
34
- TYPE = "Tipo de error no identificado.",
35
- REFERENCE = "Referencia no v\u00E1lida.",
36
- SYNTAX = "Error de sintaxis en el c\u00F3digo.",
37
- RANGE = "Error en el rango de valores.",
38
- EVAL = "Error en la evaluaci\u00F3n.",
39
- URI = "URI no v\u00E1lida."
29
+ WARNING = "Something is not quite right. Please check and try again.",
30
+ ERROR = "An unexpected error occurred.",
31
+ CRITICAL = "Critical error. Please contact technical support.",
32
+ VALIDATION = "There are errors in the form. Please review the fields.",
33
+ COMPONENT = "Error loading the component. Try reloading.",
34
+ NETWORK = "Connection problem. Please check your internet.",
35
+ AUTHENTICATION = "You do not have permission to perform this action.",
36
+ RUNTIME = "Execution error. Please try again.",
37
+ TYPE = "Unidentified error type.",
38
+ REFERENCE = "Invalid reference.",
39
+ SYNTAX = "Syntax error in the code.",
40
+ RANGE = "Error in the range of values.",
41
+ EVAL = "Error in evaluation.",
42
+ URI = "Invalid URI."
40
43
  }
41
44
  /**
42
- * Enum representing different error styles.
45
+ * An enum that defines CSS styles for console log messages, corresponding to each error type in `ErrorEnum`.
46
+ * This allows for visually distinct, styled logging in the browser's console, making it easier to
47
+ * identify the severity and type of logged errors during development.
43
48
  * @readonly
44
49
  */
45
50
  export declare enum ErrorStyles {
@@ -59,10 +64,12 @@ export declare enum ErrorStyles {
59
64
  URI = "color: darkcyan; font-weight: bold;"
60
65
  }
61
66
  /**
62
- * A record mapping ErrorEnum to their corresponding error messages.
67
+ * A frozen record that maps each `ErrorEnum` member to its corresponding user-friendly message from `ErrorMessages`.
68
+ * This provides a convenient, type-safe way to look up error messages.
63
69
  */
64
70
  export declare const ERROR_MESSAGES: Record<ErrorEnum, string>;
65
71
  /**
66
- * A record mapping ErrorEnum to their corresponding error styles.
72
+ * A frozen record that maps each `ErrorEnum` member to its corresponding CSS style string from `ErrorStyles`.
73
+ * This enables easy retrieval of the correct style for console logging based on the error type.
67
74
  */
68
75
  export declare const ERROR_STYLES: Record<ErrorEnum, string>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Enum representing various MIME types for different file categories.
2
+ * An enum that defines MIME types for common image formats.
3
3
  * @readonly
4
4
  */
5
5
  export declare enum ImageTypes {
@@ -14,12 +14,24 @@ export declare enum ImageTypes {
14
14
  WEBP = "image/webp",
15
15
  XICON = "image/x-icon"
16
16
  }
17
+ /**
18
+ * An enum for generic audio MIME types.
19
+ * @readonly
20
+ */
17
21
  export declare enum AudioTypes {
18
22
  Audios = "audio/*"
19
23
  }
24
+ /**
25
+ * An enum for generic video MIME types.
26
+ * @readonly
27
+ */
20
28
  export declare enum VideoTypes {
21
29
  Videos = "video/*"
22
30
  }
31
+ /**
32
+ * An enum that defines MIME types for various text-based formats, including plain text, markup, and data serialization formats.
33
+ * @readonly
34
+ */
23
35
  export declare enum TextTypes {
24
36
  PlainText = "text/plain",
25
37
  HTML = "text/html",
@@ -29,6 +41,10 @@ export declare enum TextTypes {
29
41
  JSON = "application/json",
30
42
  XML = "application/xml"
31
43
  }
44
+ /**
45
+ * An enum that defines MIME types for common document formats, such as PDFs and Microsoft Office files.
46
+ * @readonly
47
+ */
32
48
  export declare enum DocumentTypes {
33
49
  PDF = "application/pdf",
34
50
  Word = "application/msword",
@@ -38,23 +54,39 @@ export declare enum DocumentTypes {
38
54
  PowerPoint = "application/vnd.ms-powerpoint",
39
55
  PowerPointOpenXML = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
40
56
  }
57
+ /**
58
+ * An enum that defines MIME types for popular archive and compression formats.
59
+ * @readonly
60
+ */
41
61
  export declare enum ArchiveTypes {
42
62
  ZIP = "application/zip",
43
63
  GZIP = "application/gzip",
44
64
  TAR = "application/x-tar",
45
65
  RAR = "application/x-rar-compressed"
46
66
  }
67
+ /**
68
+ * An enum that defines MIME types for different font file formats.
69
+ * @readonly
70
+ */
47
71
  export declare enum FontTypes {
48
72
  TrueType = "font/ttf",
49
73
  OpenType = "font/otf",
50
74
  WebOpenFont = "font/woff",
51
75
  WebOpenFont2 = "font/woff2"
52
76
  }
77
+ /**
78
+ * An enum that defines MIME types for application-specific formats, including executables and packages.
79
+ * @readonly
80
+ */
53
81
  export declare enum AppTypes {
54
82
  Executable = "application/octet-stream",
55
83
  AndroidAPK = "application/vnd.android.package-archive",
56
84
  Java = "application/java-archive"
57
85
  }
86
+ /**
87
+ * An enum for miscellaneous MIME types that do not fit into the other categories.
88
+ * @readonly
89
+ */
58
90
  export declare enum OtherTypes {
59
91
  JSONLD = "application/ld+json",
60
92
  WASM = "application/wasm"
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Enum representing all HTTP exception codes.
2
+ * An enum that defines a comprehensive set of HTTP status codes, organized by category
3
+ * (Informational, Success, Redirection, Client Errors, Server Errors). It also includes
4
+ * custom error codes for application-specific scenarios like network errors.
3
5
  * @readonly
4
6
  */
5
7
  export declare enum ExceptionEnum {
@@ -1,8 +1,6 @@
1
1
  /**
2
- * Enum for key codes used in keyboard events.
3
- * This object holds various key codes commonly used for handling keyboard events.
4
- * The keys defined here correspond to specific key codes that can be used to detect
5
- * user input in web applications.
2
+ * An enum that provides a comprehensive mapping of common keyboard keys to their corresponding key codes.
3
+ * This is useful for handling keyboard events in a readable and standardized way, avoiding the use of magic numbers.
6
4
  * @readonly
7
5
  * @enum {number}
8
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Enum for different storage keys used in the application.
3
- * This enum contains the keys for storing authentication token, locale information, user info, roles, and more.
2
+ * An enum that defines a standardized set of keys for accessing `localStorage` and `sessionStorage`.
3
+ * This helps to avoid magic strings and ensures consistency when managing data persistence in the browser.
4
4
  * @readonly
5
5
  * @enum {string}
6
6
  */
@@ -47,9 +47,9 @@ export declare enum StorageKeyEnum {
47
47
  APP_SESSION_CACHE_KEY = "COMMON__SESSION__KEY"
48
48
  }
49
49
  /**
50
- * Enum defining types of storage.
50
+ * A frozen object that serves as an enum for storage types, distinguishing between `sessionStorage` and `localStorage`.
51
+ * Using this object provides a type-safe way to specify the desired storage mechanism.
51
52
  * @readonly
52
- * @enum {number}
53
53
  */
54
54
  export declare const StorageTypeEnum: {
55
55
  /**
@@ -0,0 +1,10 @@
1
+ import { BaseError } from './BaseError';
2
+ export declare class AuthError extends BaseError {
3
+ readonly code = "AUTH_ERROR";
4
+ readonly statusCode = 401;
5
+ constructor(message?: string, context?: Record<string, any>);
6
+ static unauthorized(message?: string): AuthError;
7
+ static tokenExpired(): AuthError;
8
+ static tokenInvalid(): AuthError;
9
+ static tokenMissing(): AuthError;
10
+ }
@@ -0,0 +1,16 @@
1
+ export declare abstract class BaseError extends Error {
2
+ abstract readonly code: string;
3
+ abstract readonly statusCode?: number;
4
+ readonly timestamp: Date;
5
+ readonly context?: Record<string, any>;
6
+ constructor(message: string, context?: Record<string, any>);
7
+ toJSON(): {
8
+ name: string;
9
+ message: string;
10
+ code: string;
11
+ statusCode: number | undefined;
12
+ timestamp: string;
13
+ context: Record<string, any> | undefined;
14
+ stack: string | undefined;
15
+ };
16
+ }
@@ -0,0 +1,9 @@
1
+ import { BaseError } from './BaseError';
2
+ export declare class NetworkError extends BaseError {
3
+ readonly code = "NETWORK_ERROR";
4
+ readonly statusCode?: number;
5
+ readonly originalError?: unknown;
6
+ constructor(message?: string, statusCode?: number, originalError?: unknown, context?: Record<string, any>);
7
+ static fromAxiosError(error: any): NetworkError;
8
+ static fromFetchError(error: any): NetworkError;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseError } from './BaseError';
2
+ export declare class ServerError extends BaseError {
3
+ readonly code = "SERVER_ERROR";
4
+ readonly statusCode: number;
5
+ constructor(message?: string, statusCode?: number, context?: Record<string, any>);
6
+ static internal(message?: string): ServerError;
7
+ static badGateway(message?: string): ServerError;
8
+ static serviceUnavailable(message?: string): ServerError;
9
+ static gatewayTimeout(message?: string): ServerError;
10
+ }
@@ -0,0 +1,14 @@
1
+ import { BaseError } from './BaseError';
2
+ export interface ValidationIssue {
3
+ field: string;
4
+ message: string;
5
+ value?: any;
6
+ }
7
+ export declare class ValidationError extends BaseError {
8
+ readonly code = "VALIDATION_ERROR";
9
+ readonly statusCode = 422;
10
+ readonly issues: ValidationIssue[];
11
+ constructor(message?: string, issues?: ValidationIssue[], context?: Record<string, any>);
12
+ static fromIssues(issues: ValidationIssue[]): ValidationError;
13
+ static fromField(field: string, message: string, value?: any): ValidationError;
14
+ }
@@ -0,0 +1,5 @@
1
+ export * from './BaseError';
2
+ export * from './NetworkError';
3
+ export * from './AuthError';
4
+ export * from './ValidationError';
5
+ export * from './ServerError';
@@ -0,0 +1,22 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { Fetcher } from '../types/Fetcher';
3
+ /**
4
+ * Creates a fetcher function using Axios.
5
+ *
6
+ * @param axiosInstance - The Axios instance to use
7
+ * @returns A fetcher function compatible with RestStd
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import axios from 'axios';
12
+ * import { createAxiosFetcher, RestStd } from '@arex95/vue-core';
13
+ *
14
+ * const axiosInstance = axios.create({ baseURL: 'https://api.example.com' });
15
+ *
16
+ * export class Role extends RestStd {
17
+ * static override resource = 'roles';
18
+ * static fetchFn = createAxiosFetcher(axiosInstance);
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function createAxiosFetcher(axiosInstance: AxiosInstance): Fetcher;
@@ -0,0 +1,2 @@
1
+ export * from './axios';
2
+ export * from './ofetch';
@@ -0,0 +1,33 @@
1
+ import { FetchOptions } from 'ofetch';
2
+ import { Fetcher } from '../types/Fetcher';
3
+ /**
4
+ * Creates a fetcher function using ofetch.
5
+ *
6
+ * @param baseURL - Optional base URL for requests
7
+ * @param defaultOptions - Optional default options for ofetch
8
+ * @returns A fetcher function compatible with RestStd
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { createOfetchFetcher, RestStd } from '@arex95/vue-core';
13
+ *
14
+ * export class Role extends RestStd {
15
+ * static override resource = 'roles';
16
+ * static fetchFn = createOfetchFetcher('https://api.example.com');
17
+ * }
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { createFetch } from 'ofetch';
23
+ * import { createOfetchFetcher, RestStd } from '@arex95/vue-core';
24
+ *
25
+ * const ofetchInstance = createFetch({ baseURL: 'https://api.example.com' });
26
+ *
27
+ * export class Role extends RestStd {
28
+ * static override resource = 'roles';
29
+ * static fetchFn = createOfetchFetcher(undefined, { fetch: ofetchInstance });
30
+ * }
31
+ * ```
32
+ */
33
+ export declare function createOfetchFetcher(baseURL?: string, defaultOptions?: FetchOptions): Fetcher;
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { App } from "vue";
2
2
  import { ArexVueCoreOptions } from "./types/ArexVueCoreOptions";
3
3
  /**
4
- * The Vue plugin for @arex95/vue-core.
5
- * Configures the core functionalities for authentication and API communication.
4
+ * A Vue plugin that serves as the entry point for the `@arex95/vue-core` library.
5
+ * It initializes and configures all the core modules, such as authentication, API communication,
6
+ * and token management, based on the provided options.
6
7
  */
7
8
  export declare const ArexVueCore: {
8
9
  /**
9
- * The `install` method is the entry point for the Vue plugin.
10
- * It is automatically called when `app.use(ArexVueCore, options)` is executed.
10
+ * The `install` method required by Vue's plugin system. It is called when `app.use()` is invoked.
11
11
  *
12
- * @param app The Vue application instance.
13
- * @param options The configuration options provided by the user.
12
+ * @param {App} app - The Vue application instance.
13
+ * @param {ArexVueCoreOptions} options - The configuration object for the library.
14
14
  */
15
15
  install: (app: App, options: ArexVueCoreOptions) => void;
16
16
  };
@@ -21,3 +21,5 @@ export * from "./enums";
21
21
  export * from "./types";
22
22
  export * from "./utils";
23
23
  export * from "./services";
24
+ export * from "./fetchers";
25
+ export * from "./errors";