@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
@@ -1,6 +1,16 @@
1
1
  import { UseQueryOptions } from '@tanstack/vue-query';
2
+ /**
3
+ * Extends the standard `UseQueryOptions` from Vue Query with additional properties
4
+ * to control server-side execution and provide a custom query key.
5
+ */
2
6
  export type ExtendedQueryOptions = {
7
+ /** The standard Vue Query options object. */
3
8
  options?: UseQueryOptions;
9
+ /**
10
+ * If `false`, the query will not be executed on the server during server-side rendering (SSR).
11
+ * @default true
12
+ */
4
13
  server?: boolean;
14
+ /** An optional custom query key to override the default key generation. */
5
15
  queryKey?: string;
6
16
  };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Configuration object for making HTTP requests.
3
+ * This interface is agnostic of any specific HTTP library.
4
+ */
5
+ export interface FetcherConfig {
6
+ /** HTTP method (GET, POST, PUT, DELETE, PATCH, etc.) */
7
+ method: string;
8
+ /** URL endpoint (can be relative or absolute) */
9
+ url: string;
10
+ /** Query parameters (will be converted to query string) */
11
+ params?: Record<string, any>;
12
+ /** Request body data */
13
+ data?: any;
14
+ /** HTTP headers */
15
+ headers?: Record<string, string>;
16
+ }
17
+ /**
18
+ * A generic fetcher function that accepts FetcherConfig and returns a Promise.
19
+ * This function is agnostic of any specific HTTP library (axios, ofetch, fetch, etc.).
20
+ *
21
+ * @param config - The request configuration
22
+ * @returns A promise that resolves with the response data
23
+ */
24
+ export type Fetcher = (config: FetcherConfig) => Promise<any>;
@@ -0,0 +1,62 @@
1
+ export interface GetAllOptions<TParams extends Record<string, unknown> = Record<string, unknown>> {
2
+ params?: TParams;
3
+ options?: Record<string, unknown>;
4
+ url?: string;
5
+ }
6
+ export interface GetOneOptions<TParams extends Record<string, unknown> = Record<string, unknown>> {
7
+ id: string | number;
8
+ params?: TParams;
9
+ options?: Record<string, unknown>;
10
+ url?: string;
11
+ }
12
+ export interface CreateOptions<TData = unknown> {
13
+ data: TData;
14
+ options?: Record<string, unknown>;
15
+ url?: string;
16
+ }
17
+ export interface UpdateOptions<TData = unknown> {
18
+ id: string | number;
19
+ data: TData;
20
+ options?: Record<string, unknown>;
21
+ url?: string;
22
+ }
23
+ export interface PatchOptions<TData = unknown> {
24
+ id: string | number;
25
+ data: Partial<TData>;
26
+ options?: Record<string, unknown>;
27
+ url?: string;
28
+ }
29
+ export interface DeleteOptions {
30
+ id: string | number;
31
+ options?: Record<string, unknown>;
32
+ url?: string;
33
+ }
34
+ export interface BulkCreateOptions<TData = unknown> {
35
+ data: TData[];
36
+ options?: Record<string, unknown>;
37
+ url?: string;
38
+ }
39
+ export interface BulkUpdateOptions<TData = unknown> {
40
+ data: TData[];
41
+ options?: Record<string, unknown>;
42
+ url?: string;
43
+ }
44
+ export interface BulkDeleteOptions {
45
+ ids: (string | number)[];
46
+ options?: Record<string, unknown>;
47
+ url?: string;
48
+ }
49
+ export interface UpsertOptions<TData = unknown> {
50
+ data: TData & {
51
+ id?: string | number;
52
+ };
53
+ options?: Record<string, unknown>;
54
+ url?: string;
55
+ }
56
+ export interface CustomRequestOptions<TParams extends Record<string, unknown> = Record<string, unknown>, TData = unknown> {
57
+ method: string;
58
+ url: string;
59
+ params?: TParams;
60
+ data?: TData;
61
+ options?: Record<string, unknown>;
62
+ }
@@ -1,13 +1,37 @@
1
- export type LocationPreference = "local" | "session" | "any";
1
+ /**
2
+ * Defines the possible storage locations for session data.
3
+ * - `local`: `localStorage`, persists after the browser is closed.
4
+ * - `session`: `sessionStorage`, cleared when the browser is closed.
5
+ * - `cookie`: Cookies with encryption and security options (Secure, SameSite).
6
+ * - `any`: Used for retrieval operations to check all storage locations (session, local, cookie).
7
+ */
8
+ export type LocationPreference = "local" | "session" | "cookie" | "any";
9
+ /**
10
+ * Defines the structure of the session configuration object that is stored and retrieved.
11
+ */
2
12
  export type SessionConfig = {
13
+ /** The unique identifier for the current session. */
3
14
  SESSION_ID: string;
15
+ /** The chosen storage location for the session data. */
4
16
  PERSISTENCE: LocationPreference;
5
17
  };
18
+ /**
19
+ * Represents the internal, mutable state of the session configuration.
20
+ * This is used within the session management module to track the current settings.
21
+ */
6
22
  export interface InternalSessionState {
23
+ /** The current session ID. */
7
24
  sessionId: string;
25
+ /** The current persistence preference. */
8
26
  persistencePreference: LocationPreference;
9
27
  }
28
+ /**
29
+ * Defines the structure for the object used to configure the session.
30
+ * All properties are optional, allowing for partial updates to the session configuration.
31
+ */
10
32
  export interface SessionConfigObject {
33
+ /** An optional new session ID. */
11
34
  sessionId?: string;
35
+ /** An optional new persistence preference. */
12
36
  persistencePreference?: LocationPreference;
13
37
  }
@@ -1,4 +1,11 @@
1
+ /**
2
+ * Defines the structure for the token configuration object, which specifies the storage keys
3
+ * for the access and refresh tokens. The properties are read-only to ensure they are not
4
+ * accidentally modified at runtime.
5
+ */
1
6
  export type TokensConfig = {
7
+ /** The key used to store the access token in `localStorage` or `sessionStorage`. */
2
8
  readonly ACCESS_TOKEN: string;
9
+ /** The key used to store the refresh token in `localStorage` or `sessionStorage`. */
3
10
  readonly REFRESH_TOKEN: string;
4
11
  };
@@ -1,4 +1,11 @@
1
+ /**
2
+ * Represents the successful result of a token extraction and validation operation.
3
+ * This type is used to ensure that both the access and refresh tokens are returned
4
+ * as strings after being validated.
5
+ */
1
6
  export type TokenValidationResult = {
7
+ /** The validated access token. */
2
8
  accessToken: string;
9
+ /** The validated refresh token. */
3
10
  refreshToken: string;
4
11
  };
@@ -10,3 +10,5 @@ export * from './ArexVueCoreOptions';
10
10
  export * from './AppKeyConfig';
11
11
  export * from './AxiosServiceOptions';
12
12
  export * from './TokenValidationResult';
13
+ export * from './Fetcher';
14
+ export * from './RestStdOptions';
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Opens a new window with the specified URL and options.
3
- * @param {string} url The URL to open.
4
- * @param {Object} [opt] Options for the new window.
5
- * @param {string} [opt.target='__blank'] The target window name.
6
- * @param {boolean} [opt.noopener=true] Whether to add 'noopener' attribute.
7
- * @param {boolean} [opt.noreferrer=true] Whether to add 'noreferrer' attribute.
2
+ * Opens a new browser window or tab with a specified URL, providing options for the target and security attributes.
3
+ *
4
+ * @param {string} url - The URL to open in the new window.
5
+ * @param {object} [opt] - Optional configuration for the new window.
6
+ * @param {string} [opt.target='_blank'] - The target attribute for the link, specifying where to open the content (e.g., '_blank', '_self').
7
+ * @param {boolean} [opt.noopener=true] - If `true`, adds `noopener` to the window features to prevent the new window from accessing the original window's object.
8
+ * @param {boolean} [opt.noreferrer=true] - If `true`, adds `noreferrer` to prevent the browser from sending the `Referer` HTTP header.
8
9
  */
9
10
  export declare function openWindow(url: string, opt?: {
10
11
  target?: string;
@@ -12,19 +13,24 @@ export declare function openWindow(url: string, opt?: {
12
13
  noreferrer?: boolean;
13
14
  }): void;
14
15
  /**
15
- * Copies text to the clipboard.
16
- * @param {string} text The text to copy.
17
- * @returns {Promise<void>} A promise that resolves when the text has been copied.
16
+ * Asynchronously copies a given string to the user's clipboard. It uses the modern `navigator.clipboard` API
17
+ * with a fallback to the deprecated `document.execCommand` for older browsers.
18
+ *
19
+ * @param {string} text - The string to be copied to the clipboard.
20
+ * @returns {Promise<void>} A promise that resolves when the text has been successfully copied.
18
21
  */
19
22
  export declare function copyToClipboard(text: string): Promise<void>;
20
23
  /**
21
- * Scrolls the window to the top smoothly.
22
- * @param {number} [duration=300] Duration of the scroll animation in milliseconds.
24
+ * Smoothly scrolls the window to the top of the page using a `requestAnimationFrame` loop
25
+ * for a fluid animation.
26
+ *
27
+ * @param {number} [duration=300] - The total duration of the scroll animation in milliseconds.
23
28
  */
24
29
  export declare function scrollToTop(duration?: number): void;
25
30
  /**
26
- * Gets the value of a query parameter from the URL.
27
- * @param {string} paramName The name of the query parameter.
28
- * @returns {string | null} The value of the query parameter, or null if it does not exist.
31
+ * Retrieves the value of a specified query parameter from the current URL's search string.
32
+ *
33
+ * @param {string} paramName - The name of the query parameter to retrieve.
34
+ * @returns {string | null} The value of the query parameter, or `null` if the parameter is not present in the URL.
29
35
  */
30
36
  export declare function getQueryParam(paramName: string): string | null;
@@ -1,71 +1,84 @@
1
1
  /**
2
- * Parses a date string into a Date object.
3
- * @param {string} dateString The date string in 'YYYY-MM-DD' format.
4
- * @returns {Date | null} The parsed Date object or null if the format is invalid.
2
+ * Parses a date string in the format 'YYYY-MM-DD' and returns a `Date` object.
3
+ * It includes validation to ensure the parsed date is a valid calendar date.
4
+ *
5
+ * @param {string} dateString - The date string to parse.
6
+ * @returns {Date | null} A `Date` object if the string is a valid date, otherwise `null`.
5
7
  */
6
8
  export declare function parseDate(dateString: string): Date | null;
7
9
  /**
8
- * Formats a Date object into a string.
9
- * @param {Date} date The date to format.
10
- * @param {string} format The format string (e.g., 'YYYY-MM-DD').
10
+ * Formats a `Date` object into a custom string format.
11
+ * Supported format specifiers: YYYY, MM, DD, HH, mm, ss.
12
+ *
13
+ * @param {Date} date - The `Date` object to format.
14
+ * @param {string} format - The desired string format (e.g., 'YYYY-MM-DD HH:mm:ss').
11
15
  * @returns {string} The formatted date string.
12
16
  */
13
17
  export declare function formatDate(date: Date, format: string): string;
14
18
  /**
15
- * Calculates the number of days between two dates.
16
- * @param {Date} startDate The start date.
17
- * @param {Date} endDate The end date.
19
+ * Calculates the total number of full days between two dates.
20
+ *
21
+ * @param {Date} startDate - The starting date.
22
+ * @param {Date} endDate - The ending date.
18
23
  * @returns {number} The number of days between the two dates.
19
24
  */
20
25
  export declare function daysBetween(startDate: Date, endDate: Date): number;
21
26
  /**
22
- * Adds a specified number of days to a date.
23
- * @param {Date} date The date to modify.
24
- * @param {number} days The number of days to add.
25
- * @returns {Date} The new date with days added.
27
+ * Adds a specified number of days to a given date.
28
+ *
29
+ * @param {Date} date - The original date.
30
+ * @param {number} days - The number of days to add (can be negative to subtract).
31
+ * @returns {Date} A new `Date` object representing the resulting date.
26
32
  */
27
33
  export declare function addDays(date: Date, days: number): Date;
28
34
  /**
29
- * Subtracts a specified number of days from a date.
30
- * @param {Date} date The date to modify.
31
- * @param {number} days The number of days to subtract.
32
- * @returns {Date} The new date with days subtracted.
35
+ * Subtracts a specified number of days from a given date.
36
+ *
37
+ * @param {Date} date - The original date.
38
+ * @param {number} days - The number of days to subtract.
39
+ * @returns {Date} A new `Date` object representing the resulting date.
33
40
  */
34
41
  export declare function subtractDays(date: Date, days: number): Date;
35
42
  /**
36
- * Determines if a year is a leap year.
37
- * @param {number} year The year to check.
38
- * @returns {boolean} True if the year is a leap year, false otherwise.
43
+ * Determines whether a given year is a leap year according to the Gregorian calendar rules.
44
+ *
45
+ * @param {number} year - The year to check.
46
+ * @returns {boolean} `true` if the year is a leap year, otherwise `false`.
39
47
  */
40
48
  export declare function isLeapYear(year: number): boolean;
41
49
  /**
42
- * Gets the first day of the month for a given date.
43
- * @param {Date} date The date to use.
44
- * @returns {Date} The first day of the month.
50
+ * Returns a new `Date` object set to the first day of the month for a given date.
51
+ *
52
+ * @param {Date} date - The date from which to determine the month and year.
53
+ * @returns {Date} A `Date` object representing the start of the month.
45
54
  */
46
55
  export declare function getStartOfMonth(date: Date): Date;
47
56
  /**
48
- * Gets the last day of the month for a given date.
49
- * @param {Date} date The date to use.
50
- * @returns {Date} The last day of the month.
57
+ * Returns a new `Date` object set to the last day of the month for a given date.
58
+ *
59
+ * @param {Date} date - The date from which to determine the month and year.
60
+ * @returns {Date} A `Date` object representing the end of the month.
51
61
  */
52
62
  export declare function getEndOfMonth(date: Date): Date;
53
63
  /**
54
- * Calculates age from a given birth date.
55
- * @param {Date} birthDate The birth date.
64
+ * Calculates the current age in years based on a given birth date.
65
+ *
66
+ * @param {Date} birthDate - The date of birth.
56
67
  * @returns {number} The calculated age.
57
68
  */
58
69
  export declare function calculateAge(birthDate: Date): number;
59
70
  /**
60
- * Calculates the number of days until the next birthday.
61
- * @param {Date} birthDate The birth date.
71
+ * Calculates the number of days from the current date until the next birthday.
72
+ *
73
+ * @param {Date} birthDate - The date of birth.
62
74
  * @returns {number} The number of days until the next birthday.
63
75
  */
64
76
  export declare function daysToNextBirthday(birthDate: Date): number;
65
77
  /**
66
- * Calculates the age at a specific date.
67
- * @param {Date} birthDate The birth date.
68
- * @param {Date} atDate The date to calculate the age at.
69
- * @returns {number} The calculated age.
78
+ * Calculates the age of a person on a specific date in the past or future.
79
+ *
80
+ * @param {Date} birthDate - The date of birth.
81
+ * @param {Date} atDate - The target date for which to calculate the age.
82
+ * @returns {number} The age on the specified date.
70
83
  */
71
84
  export declare function ageAtDate(birthDate: Date, atDate: Date): number;
@@ -1,57 +1,79 @@
1
1
  /**
2
- * Creates a debounced asynchronous validator function.
2
+ * Creates a debounced version of an asynchronous validator function. This is useful for scenarios
3
+ * like form input validation where you want to delay validation until the user has stopped typing.
3
4
  *
4
- * @param validator - The async validator function to debounce.
5
- * @param delay - The debounce delay in milliseconds.
6
- * @returns A debounced version of the validator function.
5
+ * @param validator - The asynchronous validator function to be debounced. It receives the value to validate and a `debounce` function.
6
+ * @param {number} delay - The debounce delay in milliseconds.
7
+ * @returns A new function that takes a value and returns a promise that resolves or rejects based on the debounced validation.
7
8
  */
8
9
  export declare function debounceAsyncValidator(validator: (value: any, debounce: () => Promise<void>) => Promise<void>, delay: number): (value: any) => Promise<void>;
9
10
  /**
10
- * Creates a debounced version of an asynchronous function.
11
- * @param {Function} func The asynchronous function to debounce.
12
- * @param {number} wait The number of milliseconds to wait before invoking the function.
13
- * @returns {Function} The debounced function.
11
+ * Creates a debounced version of an asynchronous function. The debounced function will only
12
+ * resolve the promise of the last invocation within the `wait` period.
13
+ *
14
+ * @template T - The type of the asynchronous function.
15
+ * @param {T} func - The asynchronous function to debounce.
16
+ * @param {number} wait - The debounce delay in milliseconds.
17
+ * @returns A new debounced asynchronous function.
14
18
  */
15
19
  export declare function debounceAsync<T extends (...args: any[]) => Promise<any>>(func: T, wait: number): (...args: Parameters<T>) => Promise<ReturnType<T>>;
16
20
  /**
17
- * Creates a debounced asynchronous function that executes immediately on the first call.
18
- * @param {Function} func The asynchronous function to debounce.
19
- * @param {number} wait The number of milliseconds to wait before invoking the function.
20
- * @returns {Function} The debounced function with immediate execution on the first call.
21
+ * Creates a debounced version of an asynchronous function that executes immediately on the first call
22
+ * and then waits for the specified delay before allowing the next execution.
23
+ *
24
+ * @template T - The type of the asynchronous function.
25
+ * @param {T} func - The asynchronous function to debounce.
26
+ * @param {number} wait - The cooldown period in milliseconds after an immediate execution.
27
+ * @returns A new debounced asynchronous function that executes on the leading edge.
21
28
  */
22
29
  export declare function debounceAsyncWithImmediate<T extends (...args: any[]) => Promise<any>>(func: T, wait: number): (...args: Parameters<T>) => Promise<ReturnType<T>>;
23
30
  /**
24
- * Creates a debounced version of a function that executes on the leading edge.
25
- * @param {Function} func The function to debounce.
26
- * @param {number} wait The number of milliseconds to wait before invoking the function.
27
- * @returns {Function} The debounced function.
31
+ * Creates a debounced function that invokes `func` on the leading edge of the `wait` timeout.
32
+ * Subsequent calls within the `wait` period are ignored.
33
+ *
34
+ * @template T - The type of the function.
35
+ * @param {T} func - The function to debounce.
36
+ * @param {number} wait - The debounce delay in milliseconds.
37
+ * @returns A new debounced function.
28
38
  */
29
39
  export declare function debounceLeading<T extends (...args: any[]) => void>(func: T, wait: number): T;
30
40
  /**
31
- * Creates a debounced version of a function that executes on the trailing edge.
32
- * @param {Function} func The function to debounce.
33
- * @param {number} wait The number of milliseconds to wait before invoking the function.
34
- * @returns {Function} The debounced function.
41
+ * Creates a debounced function that invokes `func` on the trailing edge of the `wait` timeout.
42
+ * The function is called only after `wait` milliseconds of inactivity.
43
+ *
44
+ * @template T - The type of the function.
45
+ * @param {T} func - The function to debounce.
46
+ * @param {number} wait - The debounce delay in milliseconds.
47
+ * @returns A new debounced function.
35
48
  */
36
49
  export declare function debounceTrailing<T extends (...args: any[]) => void>(func: T, wait: number): T;
37
50
  /**
38
- * Creates a debounced version of a function that executes on both leading and trailing edges.
39
- * @param {Function} func The function to debounce.
40
- * @param {number} wait The number of milliseconds to wait before invoking the function.
41
- * @returns {Function} The debounced function.
51
+ * Creates a debounced function that invokes `func` on both the leading and trailing edges of the `wait` timeout.
52
+ * This is useful for UIs where an action should happen immediately on the first event, but also after a pause in events.
53
+ *
54
+ * @template T - The type of the function.
55
+ * @param {T} func - The function to debounce.
56
+ * @param {number} wait - The debounce delay in milliseconds.
57
+ * @returns A new debounced function.
42
58
  */
43
59
  export declare function debounceLeadingTrailing<T extends (...args: any[]) => void>(func: T, wait: number): T;
44
60
  /**
45
- * Creates a debounced version of a function.
46
- * @param {Function} func The function to debounce.
47
- * @param {number} wait The number of milliseconds to wait before invoking the function.
48
- * @returns {Function} The debounced function.
61
+ * Creates a standard debounced function that delays invoking `func` until after `wait` milliseconds
62
+ * have elapsed since the last time the debounced function was invoked. (This is an alias for `debounceTrailing`).
63
+ *
64
+ * @template T - The type of the function.
65
+ * @param {T} func - The function to debounce.
66
+ * @param {number} wait - The debounce delay in milliseconds.
67
+ * @returns A new debounced function.
49
68
  */
50
69
  export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number): T;
51
70
  /**
52
- * Creates a throttled version of a function.
53
- * @param {Function} func The function to throttle.
54
- * @param {number} limit The number of milliseconds to wait between function calls.
55
- * @returns {Function} The throttled function.
71
+ * Creates a throttled function that only invokes `func` at most once per every `limit` milliseconds.
72
+ * This is useful for rate-limiting events that fire frequently, such as scrolling or resizing.
73
+ *
74
+ * @template T - The type of the function.
75
+ * @param {T} func - The function to throttle.
76
+ * @param {number} limit - The throttle duration in milliseconds.
77
+ * @returns A new throttled function.
56
78
  */
57
79
  export declare function throttle<T extends (...args: any[]) => void>(func: T, limit: number): T;
@@ -1,40 +1,44 @@
1
1
  /**
2
- * Converts an ArrayBuffer or Uint8Array to a hexadecimal string.
3
- * @param buffer The ArrayBuffer or Uint8Array to convert.
4
- * @returns The hexadecimal string.
2
+ * Converts an `ArrayBuffer` or `Uint8Array` into a hexadecimal string representation.
3
+ *
4
+ * @param {ArrayBuffer | Uint8Array} buffer - The buffer to convert.
5
+ * @returns {string} The resulting hexadecimal string.
5
6
  */
6
7
  export declare function ab2hex(buffer: ArrayBuffer | Uint8Array): string;
7
8
  /**
8
- * Converts a hexadecimal string to a Uint8Array.
9
- * @param hex The hexadecimal string to convert.
10
- * @returns The Uint8Array.
9
+ * Converts a hexadecimal string into a `Uint8Array`.
10
+ *
11
+ * @param {string} hex - The hexadecimal string to convert.
12
+ * @returns {Uint8Array} The resulting `Uint8Array`.
11
13
  * @throws {TypeError} If the input is not a string.
12
- * @throws {Error} If the hexadecimal string format is invalid or has an odd length.
14
+ * @throws {Error} If the hexadecimal string has an invalid format or an odd length.
13
15
  */
14
16
  export declare function hex2ab(hex: string): Uint8Array;
15
17
  /**
16
- * Derives an encryption key from a secret key.
17
- * @param secretKey The secret key in plain text.
18
- * @returns A promise that resolves with the derived CryptoKey.
19
- * @throws {Error} If the secretKey is null or empty.
18
+ * Derives a `CryptoKey` for AES-CBC encryption from a plain-text secret key.
19
+ * It uses SHA-256 to hash the secret key, ensuring a fixed-length key suitable for the Web Crypto API.
20
+ *
21
+ * @param {string} secretKey - The plain-text secret key.
22
+ * @returns {Promise<CryptoKey>} A promise that resolves with the derived `CryptoKey`.
23
+ * @throws {Error} If the `secretKey` is null or empty.
20
24
  */
21
25
  export declare function importKey(secretKey: string): Promise<CryptoKey>;
22
26
  /**
23
- * Encrypts a value with the provided secret key.
24
- * @param value The value to encrypt.
25
- * @param secretKey The secret key for encryption.
26
- * @returns A promise that resolves with the IV (hex) + ciphertext (hex) string.
27
- * @throws {Error} If the secretKey is null or empty (via importKey).
27
+ * Encrypts a plain-text value using AES-CBC with a given secret key.
28
+ * A random 16-byte initialization vector (IV) is generated for each encryption.
29
+ *
30
+ * @param {string} value - The plain-text string to encrypt.
31
+ * @param {string} secretKey - The secret key to use for encryption.
32
+ * @returns {Promise<string>} A promise that resolves with a concatenated hexadecimal string of the IV and the ciphertext.
33
+ * @throws {Error} If the `secretKey` is null or empty.
28
34
  */
29
35
  export declare function encrypt(value: string, secretKey: string): Promise<string>;
30
36
  /**
31
- * Decrypts an encrypted value.
32
- * @param encryptedValue The encrypted string (IV_hex + ciphertext_hex).
33
- * @param secretKey The secret key for decryption.
34
- * @returns A promise that resolves with the decrypted value.
35
- * @throws {Error} If encryptedValue is null or empty, too short,
36
- * or if the IV/ciphertext have incorrect lengths after conversion.
37
- * @throws {Error} If the secretKey is null or empty (via importKey).
38
- * @throws {TypeError} If hex2ab receives an invalid input type.
37
+ * Decrypts a hexadecimal string (IV + ciphertext) using AES-CBC with a given secret key.
38
+ *
39
+ * @param {string} encryptedValue - The concatenated hexadecimal string of the IV and ciphertext.
40
+ * @param {string} secretKey - The secret key to use for decryption.
41
+ * @returns {Promise<string>} A promise that resolves with the decrypted plain-text string.
42
+ * @throws {Error} If the encrypted value is null, empty, or too short, or if the `secretKey` is invalid.
39
43
  */
40
44
  export declare function decrypt(encryptedValue: string, secretKey: string): Promise<string>;
@@ -1,10 +1,29 @@
1
- import { ErrorPassMethod } from '@/types';
1
+ import { ErrorType } from '@/types';
2
+ export interface ErrorInfo {
3
+ message: string;
4
+ type: ErrorType;
5
+ errorData?: Record<string, unknown>;
6
+ }
2
7
  /**
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
8
+ * Handles and logs errors to the console. Supports both standard Error objects and custom error classes
9
+ * (BaseError, NetworkError, etc.). It infers the error type, logs a styled message with detailed information,
10
+ * and returns structured error information for further handling.
11
+ *
12
+ * @param {unknown} error - The captured error, which can be a string, Error object, or custom error class.
13
+ * @returns {ErrorInfo | undefined} An object containing the error message, type, and additional error data,
14
+ * or `undefined` if the error is not an Error instance.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * try {
19
+ * await someOperation();
20
+ * } catch (error) {
21
+ * const errorInfo = handleError(error);
22
+ * if (errorInfo) {
23
+ * // Use errorInfo.message, errorInfo.type, errorInfo.errorData
24
+ * // Handle redirect or other actions as needed
25
+ * }
26
+ * }
27
+ * ```
9
28
  */
10
- export declare function handleError(error: unknown, redirect?: boolean, route?: string, passMethod?: ErrorPassMethod): string | undefined;
29
+ export declare function handleError(error: unknown): ErrorInfo | undefined;
@@ -1,34 +1,39 @@
1
1
  /**
2
- * Exports data to a CSV file.
3
- * @param {string[]} headers The headers for the CSV.
4
- * @param {any[][]} data The data to export, as an array of arrays.
5
- * @param {string} fileName The name of the file to create.
2
+ * Converts an array of data into a CSV format and triggers a download.
3
+ *
4
+ * @param {string[]} headers - An array of strings to be used as the CSV header row.
5
+ * @param {any[][]} data - A 2D array representing the rows and cells of the data to be exported.
6
+ * @param {string} fileName - The desired name for the downloaded CSV file.
6
7
  */
7
8
  export declare function exportToCSV(headers: string[], data: any[][], fileName: string): void;
8
9
  /**
9
- * Exports data to an Excel file (.xls) using HTML table.
10
- * @param {string[]} headers The headers for the Excel file.
11
- * @param {any[][]} data The data to export, as an array of arrays.
12
- * @param {string} fileName The name of the file to create.
10
+ * Converts an array of data into an HTML table, then triggers a download as an Excel (.xls) file.
11
+ *
12
+ * @param {string[]} headers - An array of strings for the table headers.
13
+ * @param {any[][]} data - A 2D array of the data to be exported.
14
+ * @param {string} fileName - The desired name for the downloaded Excel file.
13
15
  */
14
16
  export declare function exportToExcel(headers: string[], data: any[][], fileName: string): void;
15
17
  /**
16
- * Exports data to a JSON file.
17
- * @param {any[]} data The data to export.
18
- * @param {string} fileName The name of the file to create.
18
+ * Converts an array of data into a pretty-printed JSON string and triggers a download.
19
+ *
20
+ * @param {any[]} data - The data to be serialized into JSON.
21
+ * @param {string} fileName - The desired name for the downloaded JSON file.
19
22
  */
20
23
  export declare function exportToJSON(data: any[], fileName: string): void;
21
24
  /**
22
- * Exports data to an XML file.
23
- * @param {string[]} headers The headers for the XML.
24
- * @param {any[][]} data The data to export, as an array of arrays.
25
- * @param {string} fileName The name of the file to create.
25
+ * Converts an array of data into a simple XML format and triggers a download.
26
+ *
27
+ * @param {string[]} headers - An array of strings to be used as column headers in the XML.
28
+ * @param {any[][]} data - A 2D array of the data to be exported.
29
+ * @param {string} fileName - The desired name for the downloaded XML file.
26
30
  */
27
31
  export declare function exportToXML(headers: string[], data: any[][], fileName: string): void;
28
32
  /**
29
- * Exports data to a plain text file.
30
- * @param {string[]} headers The headers for the text file.
31
- * @param {any[][]} data The data to export, as an array of arrays.
32
- * @param {string} fileName The name of the file to create.
33
+ * Converts an array of data into a tab-separated text format and triggers a download.
34
+ *
35
+ * @param {string[]} headers - An array of strings for the header row.
36
+ * @param {any[][]} data - A 2D array of the data to be exported.
37
+ * @param {string} fileName - The desired name for the downloaded text file.
33
38
  */
34
39
  export declare function exportToText(headers: string[], data: any[][], fileName: string): void;