@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,46 +1,54 @@
1
1
  /**
2
- * Converts a FormData object to a plain JavaScript object.
3
- * @param {FormData} formData The FormData object to convert.
4
- * @returns {Record<string, any>} The plain JavaScript object.
2
+ * Converts a `FormData` object into a regular JavaScript object. It correctly handles
3
+ * multiple values for the same key by creating an array for that key.
4
+ *
5
+ * @param {FormData} formData - The `FormData` object to convert.
6
+ * @returns {Record<string, any>} A plain JavaScript object representation of the FormData.
5
7
  */
6
8
  export declare function formDataToObject(formData: FormData): Record<string, any>;
7
9
  /**
8
- * Reads a file as text.
9
- * @param {File} file The file to read.
10
- * @returns {Promise<string>} A promise that resolves with the file content.
10
+ * Asynchronously reads the content of a `File` object as a text string.
11
+ *
12
+ * @param {File} file - The `File` object to read.
13
+ * @returns {Promise<string>} A promise that resolves with the text content of the file.
11
14
  */
12
15
  export declare function readFileAsText(file: File): Promise<string>;
13
16
  /**
14
- * Reads a file as a Data URL.
15
- * @param {File} file The file to read.
16
- * @returns {Promise<string>} A promise that resolves with the Data URL.
17
+ * Asynchronously reads the content of a `File` object as a Base64-encoded Data URL.
18
+ *
19
+ * @param {File} file - The `File` object to read.
20
+ * @returns {Promise<string>} A promise that resolves with the Data URL representing the file's content.
17
21
  */
18
22
  export declare function readFileAsDataURL(file: File): Promise<string>;
19
23
  /**
20
- * Creates a Blob from a string.
21
- * @param {string} content The string content for the Blob.
22
- * @param {string} [type='text/plain'] The MIME type of the Blob.
23
- * @returns {Blob} The Blob object.
24
+ * Creates a `Blob` object from a string.
25
+ *
26
+ * @param {string} content - The string content to be put into the Blob.
27
+ * @param {string} [type='text/plain'] - The MIME type of the Blob.
28
+ * @returns {Blob} A new `Blob` object.
24
29
  */
25
30
  export declare function stringToBlob(content: string, type?: string): Blob;
26
31
  /**
27
- * Creates a Blob from an ArrayBuffer.
28
- * @param {ArrayBuffer} buffer The ArrayBuffer to convert.
29
- * @param {string} [type='application/octet-stream'] The MIME type of the Blob.
30
- * @returns {Blob} The Blob object.
32
+ * Creates a `Blob` object from an `ArrayBuffer`.
33
+ *
34
+ * @param {ArrayBuffer} buffer - The `ArrayBuffer` to be put into the Blob.
35
+ * @param {string} [type='application/octet-stream'] - The MIME type of the Blob.
36
+ * @returns {Blob} A new `Blob` object.
31
37
  */
32
38
  export declare function bufferToBlob(buffer: ArrayBuffer, type?: string): Blob;
33
39
  /**
34
- * Creates and downloads a file from Blob data.
35
- * @param {Blob} blob The Blob containing the file data.
36
- * @param {string} fileName The name of the file to create.
40
+ * Triggers a browser download for a file created from a `Blob` object.
41
+ *
42
+ * @param {Blob} blob - The `Blob` containing the file data.
43
+ * @param {string} fileName - The desired name for the downloaded file.
37
44
  */
38
45
  export declare function downloadBlob(blob: Blob, fileName: string): void;
39
46
  /**
40
- * Creates a FormData object containing a Blob.
41
- * @param {Blob} blob The Blob to include in the FormData.
42
- * @param {string} name The name of the form field.
43
- * @param {string} [fileName='file'] The file name for the Blob.
44
- * @returns {FormData} The FormData object.
47
+ * Appends a `Blob` to a new `FormData` object.
48
+ *
49
+ * @param {Blob} blob - The `Blob` to append.
50
+ * @param {string} name - The name of the field to append the blob as.
51
+ * @param {string} [fileName='file'] - The filename to associate with the blob in the `FormData`.
52
+ * @returns {FormData} A new `FormData` object containing the blob.
45
53
  */
46
54
  export declare function blobToFormData(blob: Blob, name: string, fileName?: string): FormData;
@@ -11,3 +11,6 @@ export * from '../services/credentials';
11
11
  export * from './storage';
12
12
  export * from './encryption';
13
13
  export * from './errors';
14
+ export * from './retry';
15
+ export * from './ssr';
16
+ export type { CookieOptions } from './ssr';
@@ -1,42 +1,46 @@
1
1
  /**
2
- * Disables the right-click context menu on the window.
2
+ * Disables the default right-click context menu on the entire window.
3
3
  */
4
4
  export declare function disableRightClick(): void;
5
5
  export declare namespace disableRightClick {
6
6
  var handler: any;
7
7
  }
8
8
  /**
9
- * Enables the right-click context menu on the window.
9
+ * Re-enables the right-click context menu if it was previously disabled by `disableRightClick`.
10
10
  */
11
11
  export declare function enableRightClick(): void;
12
12
  /**
13
- * Disables specific mouse buttons.
14
- * @param {Array<number>} buttons Array of mouse button codes to disable (0 for left, 1 for middle, 2 for right).
13
+ * Prevents the default action for specific mouse buttons on the `mousedown` event.
14
+ *
15
+ * @param {number[]} buttons - An array of mouse button codes to disable (0 for left, 1 for middle, 2 for right).
15
16
  */
16
17
  export declare function disableMouseButtons(buttons: number[]): void;
17
18
  export declare namespace disableMouseButtons {
18
19
  var handlers: ((event: MouseEvent) => void)[];
19
20
  }
20
21
  /**
21
- * Enables all previously disabled mouse buttons.
22
+ * Re-enables all mouse buttons that were previously disabled by `disableMouseButtons`.
22
23
  */
23
24
  export declare function enableMouseButtons(): void;
24
25
  /**
25
- * Adds a double-click event listener to a specific element.
26
- * @param {HTMLElement} element The target element.
27
- * @param {(event: MouseEvent) => void} callback The callback function to execute on double click.
26
+ * Attaches a `dblclick` event listener to a specified HTML element.
27
+ *
28
+ * @param {HTMLElement} element - The DOM element to attach the listener to.
29
+ * @param {(event: MouseEvent) => void} callback - The function to execute when the element is double-clicked.
28
30
  */
29
31
  export declare function addDoubleClickListener(element: HTMLElement, callback: (event: MouseEvent) => void): void;
30
32
  /**
31
- * Removes a double-click event listener from a specific element.
32
- * @param {HTMLElement} element The target element.
33
- * @param {(event: MouseEvent) => void} callback The callback function to remove.
33
+ * Removes a `dblclick` event listener from a specified HTML element.
34
+ *
35
+ * @param {HTMLElement} element - The DOM element to remove the listener from.
36
+ * @param {(event: MouseEvent) => void} callback - The callback function that was originally added.
34
37
  */
35
38
  export declare function removeDoubleClickListener(element: HTMLElement, callback: (event: MouseEvent) => void): void;
36
39
  /**
37
- * Detects a click outside a specific element and triggers a callback.
38
- * @param {HTMLElement} element The element to detect clicks outside of.
39
- * @param {() => void} callback The callback function to execute when a click outside is detected.
40
+ * Sets up a global click listener to detect when a user clicks outside of a specified element.
41
+ *
42
+ * @param {HTMLElement} element - The element to monitor for outside clicks.
43
+ * @param {() => void} callback - The function to execute when a click outside the element is detected.
40
44
  */
41
45
  export declare function clickOutside(element: HTMLElement, callback: () => void): void;
42
46
  export declare namespace clickOutside {
@@ -46,53 +50,60 @@ export declare namespace clickOutside {
46
50
  }[];
47
51
  }
48
52
  /**
49
- * Removes the click outside listener for a specific element.
50
- * @param {HTMLElement} element The element to stop detecting clicks outside of.
53
+ * Removes the "click outside" event listener for a specific element that was added by `clickOutside`.
54
+ *
55
+ * @param {HTMLElement} element - The element for which to remove the listener.
51
56
  */
52
57
  export declare function removeClickOutside(element: HTMLElement): void;
53
58
  /**
54
- * Disables the F12 key and certain key combinations for developer tools.
59
+ * Disables the F12 key and common developer tool shortcuts (Ctrl+Shift+I, Ctrl+Shift+J)
60
+ * to prevent users from easily opening the browser's developer console.
55
61
  */
56
62
  export declare function disableF12Key(): void;
57
63
  /**
58
- * Enables or disables the tab navigation (Tab key) on the page.
59
- * @param {boolean} enable Whether to enable or disable tab navigation.
64
+ * Enables or disables the ability to navigate through focusable elements using the Tab key.
65
+ *
66
+ * @param {boolean} enable - If `true`, tab navigation is enabled; if `false`, it is disabled.
60
67
  */
61
68
  export declare function toggleTabNavigation(enable: boolean): void;
62
69
  /**
63
- * Disables the copy (Ctrl + C) functionality on the page.
70
+ * Prevents users from copying content from the page by intercepting the `copy` event.
64
71
  */
65
72
  export declare function disableCopy(): void;
66
73
  /**
67
- * Adds a custom keyboard shortcut to execute a given callback function.
68
- * @param {string} key The key to trigger the callback.
69
- * @param {Function} callback The function to execute on the key press.
70
- * @param {boolean} [ctrlKey=false] Whether Ctrl key should be pressed.
71
- * @param {boolean} [shiftKey=false] Whether Shift key should be pressed.
74
+ * Registers a global keyboard shortcut that triggers a callback when a specific key combination is pressed.
75
+ *
76
+ * @param {string} key - The main key for the shortcut (e.g., 'S', 'F1').
77
+ * @param {() => void} callback - The function to execute when the shortcut is pressed.
78
+ * @param {boolean} [ctrlKey=false] - If `true`, the Ctrl key must be pressed.
79
+ * @param {boolean} [shiftKey=false] - If `true`, the Shift key must be pressed.
72
80
  */
73
81
  export declare function addCustomKeyboardShortcut(key: string, callback: () => void, ctrlKey?: boolean, shiftKey?: boolean): void;
74
82
  /**
75
- * Removes a custom keyboard shortcut by key and modifiers.
76
- * @param {string} key The key to trigger the callback.
77
- * @param {boolean} [ctrlKey=false] Whether Ctrl key should be pressed.
78
- * @param {boolean} [shiftKey=false] Whether Shift key should be pressed.
83
+ * Removes a global keyboard shortcut that was previously added.
84
+ *
85
+ * @param {string} key - The main key of the shortcut to remove.
86
+ * @param {boolean} [ctrlKey=false] - The Ctrl key modifier of the shortcut.
87
+ * @param {boolean} [shiftKey=false] - The Shift key modifier of the shortcut.
79
88
  */
80
89
  export declare function removeCustomKeyboardShortcut(key: string, ctrlKey?: boolean, shiftKey?: boolean): void;
81
90
  /**
82
- * Disables specific keys or key combinations.
83
- * @param {Array<string>} keys Array of key names to disable (e.g., ['F1', 'F5', 'Control+S']).
91
+ * Disables a list of specified keys or key combinations.
92
+ *
93
+ * @param {string[]} keys - An array of key names or combinations (e.g., 'F1', 'Control+S') to disable.
84
94
  */
85
95
  export declare function disableSpecificKeys(keys: string[]): void;
86
96
  export declare namespace disableSpecificKeys {
87
97
  var handlers: ((event: KeyboardEvent) => void)[];
88
98
  }
89
99
  /**
90
- * Enables keys that were previously disabled using disableSpecificKeys.
100
+ * Re-enables all keys that were previously disabled by `disableSpecificKeys`.
91
101
  */
92
102
  export declare function enableSpecificKeys(): void;
93
103
  /**
94
- * Registers multiple keyboard shortcuts with their respective callback functions.
95
- * @param {Array<{ key: string, ctrlKey?: boolean, shiftKey?: boolean, altKey?: boolean, callback: Function }>} shortcuts Array of shortcut objects.
104
+ * Registers multiple keyboard shortcuts from an array of shortcut configurations.
105
+ *
106
+ * @param {Array<{ key: string; ctrlKey?: boolean; shiftKey?: boolean; altKey?: boolean; callback: () => void }>} shortcuts - An array of shortcut objects.
96
107
  */
97
108
  export declare function registerKeyboardShortcuts(shortcuts: {
98
109
  key: string;
@@ -105,47 +116,51 @@ export declare namespace registerKeyboardShortcuts {
105
116
  var handlers: ((event: KeyboardEvent) => void)[];
106
117
  }
107
118
  /**
108
- * Unregisters all keyboard shortcuts that were registered with registerKeyboardShortcuts.
119
+ * Removes all keyboard shortcuts that were registered using `registerKeyboardShortcuts`.
109
120
  */
110
121
  export declare function unregisterKeyboardShortcuts(): void;
111
122
  /**
112
- * Adds a listener for a specific key to trigger a custom event.
113
- * @param {string} key The key to listen for (e.g., 'Enter', 'Escape').
114
- * @param {Function} callback The function to execute when the key is pressed.
123
+ * Adds a global `keydown` listener for a specific key.
124
+ *
125
+ * @param {string} key - The key to listen for (e.g., 'Enter', 'Escape').
126
+ * @param {() => void} callback - The function to execute when the key is pressed.
115
127
  */
116
128
  export declare function addKeyListener(key: string, callback: () => void): void;
117
129
  export declare namespace addKeyListener {
118
130
  var handlers: ((event: KeyboardEvent) => void)[];
119
131
  }
120
132
  /**
121
- * Removes all custom key listeners added by addKeyListener.
133
+ * Removes all key listeners that were added using `addKeyListener`.
122
134
  */
123
135
  export declare function removeKeyListeners(): void;
124
136
  /**
125
- * Detects if a specific key is held down.
126
- * @param {string} key The key to detect (e.g., 'Shift', 'Control', 'Alt', 'a').
127
- * @param {Function} onHold Callback function to execute while the key is held down.
137
+ * Executes a callback function repeatedly while a specific key is held down.
138
+ *
139
+ * @param {string} key - The key to monitor.
140
+ * @param {() => void} onHold - The callback function to execute on each `keydown` event for the specified key.
128
141
  */
129
142
  export declare function detectKeyHold(key: string, onHold: () => void): void;
130
143
  export declare namespace detectKeyHold {
131
144
  var handlers: ((event: KeyboardEvent) => void)[];
132
145
  }
133
146
  /**
134
- * Stops detecting if a specific key is held down.
147
+ * Removes all key hold listeners that were added by `detectKeyHold`.
135
148
  */
136
149
  export declare function stopDetectingKeyHold(): void;
137
150
  /**
138
- * Tracks currently pressed keys and provides a map of active keys.
139
- * @returns {Set<string>} A set of currently pressed keys.
151
+ * Creates and maintains a `Set` of currently pressed keys.
152
+ *
153
+ * @returns {Set<string>} A `Set` that dynamically updates with the keys being pressed.
140
154
  */
141
155
  export declare function createKeyMap(): Set<string>;
142
156
  export declare namespace createKeyMap {
143
157
  var clearListeners: () => void;
144
158
  }
145
159
  /**
146
- * Sets up custom keyboard shortcuts with flexible order.
147
- * @param {Array<string>} keys The combination of keys for the shortcut.
148
- * @param {Function} callback The callback function to execute when the combination is detected.
160
+ * Sets up a keyboard shortcut that triggers a callback when a specific combination of keys is held down, regardless of order.
161
+ *
162
+ * @param {string[]} keys - An array of keys that constitute the shortcut.
163
+ * @param {() => void} callback - The function to execute when the key combination is active.
149
164
  */
150
165
  export declare function customShortcut(keys: string[], callback: () => void): void;
151
166
  export declare namespace customShortcut {
@@ -155,14 +170,15 @@ export declare namespace customShortcut {
155
170
  }[];
156
171
  }
157
172
  /**
158
- * Removes all custom keyboard shortcuts added by customShortcut.
173
+ * Removes all keyboard shortcut listeners that were added by `customShortcut`.
159
174
  */
160
175
  export declare function removeCustomShortcuts(): void;
161
176
  /**
162
- * Simulates a key press event.
163
- * @param {string} key The key to simulate (e.g., 'Enter', 'a').
164
- * @param {boolean} ctrlKey If true, include Ctrl key in the event.
165
- * @param {boolean} shiftKey If true, include Shift key in the event.
166
- * @param {boolean} altKey If true, include Alt key in the event.
177
+ * Programmatically dispatches a `keydown` event to simulate a key press.
178
+ *
179
+ * @param {string} key - The key to simulate (e.g., 'Enter', 'a').
180
+ * @param {boolean} [ctrlKey=false] - Whether to simulate the Ctrl key being pressed.
181
+ * @param {boolean} [shiftKey=false] - Whether to simulate the Shift key being pressed.
182
+ * @param {boolean} [altKey=false] - Whether to simulate the Alt key being pressed.
167
183
  */
168
184
  export declare function simulateKeyPress(key: string, ctrlKey?: boolean, shiftKey?: boolean, altKey?: boolean): void;
@@ -1,109 +1,127 @@
1
1
  /**
2
- * Converts a Proxy object to a plain object.
3
- * @param {ProxyConstructor} proxy The Proxy object to convert.
4
- * @returns {Object} The plain object.
2
+ * Converts a Proxy object into a plain JavaScript object.
3
+ *
4
+ * @param {ProxyConstructor} proxy - The Proxy object to convert.
5
+ * @returns {any} A new object containing the properties of the Proxy.
5
6
  */
6
7
  export declare function proxyToPlainObject(proxy: ProxyConstructor): any;
7
8
  /**
8
- * Compares two objects to check if they have the same keys.
9
- * @param {Object} object1 The first object to compare.
10
- * @param {Object} object2 The second object to compare.
11
- * @returns {boolean} True if the objects have the same keys, otherwise false.
9
+ * Performs a shallow comparison to check if two objects have the same keys.
10
+ *
11
+ * @param {Record<string, any>} object1 - The first object.
12
+ * @param {Record<string, any>} object2 - The second object.
13
+ * @returns {boolean} `true` if both objects have the exact same set of keys, otherwise `false`.
12
14
  */
13
15
  export declare function compareObject(object1: Record<string, any>, object2: Record<string, any>): boolean;
14
16
  /**
15
- * Deeply compares two objects to check if they are equal.
16
- * @param {Object} object1 The first object to compare.
17
- * @param {Object} object2 The second object to compare.
18
- * @returns {boolean} True if the objects are deeply equal, otherwise false.
17
+ * Performs a deep comparison between two objects to determine if they are structurally and value-wise equal.
18
+ *
19
+ * @param {Record<string, any>} object1 - The first object.
20
+ * @param {Record<string, any>} object2 - The second object.
21
+ * @returns {boolean} `true` if the objects are deeply equal, otherwise `false`.
19
22
  */
20
23
  export declare function deepEqual(object1: Record<string, any>, object2: Record<string, any>): boolean;
21
24
  /**
22
- * Deeply clones an object.
23
- * @param {Object} obj The object to clone.
24
- * @returns {Object} The cloned object.
25
+ * Creates a deep clone of a given object, including nested objects and arrays.
26
+ *
27
+ * @template T - The type of the object being cloned.
28
+ * @param {T} obj - The object to clone.
29
+ * @returns {T} A new object that is a deep clone of the original.
30
+ * @throws {Error} If the object contains a type that cannot be cloned.
25
31
  */
26
32
  export declare function deepClone<T>(obj: T): T;
27
33
  /**
28
- * Converts an object to a query string.
29
- * @param {Object} obj The object to convert.
30
- * @returns {string} The query string.
34
+ * Converts a flat object into a URL query string.
35
+ *
36
+ * @param {Record<string, any>} obj - The object to convert.
37
+ * @returns {string} The resulting URL query string.
31
38
  */
32
39
  export declare function objectToQueryString(obj: Record<string, any>): string;
33
40
  /**
34
- * Gets the differences between two objects.
35
- * @param {Object} object1 The first object.
36
- * @param {Object} object2 The second object.
37
- * @returns {Object} An object containing the differences.
41
+ * Compares two objects and returns an object containing the keys where their values differ.
42
+ *
43
+ * @param {Record<string, any>} object1 - The first object.
44
+ * @param {Record<string, any>} object2 - The second object.
45
+ * @returns {Record<string, any>} An object where each key represents a difference, and the value contains the differing values from both objects.
38
46
  */
39
47
  export declare function getObjectDifferences(object1: Record<string, any>, object2: Record<string, any>): Record<string, any>;
40
48
  /**
41
- * Filters an object by a list of keys.
42
- * @param {Object} obj The object to filter.
43
- * @param {Array<string>} keys The keys to keep.
44
- * @returns {Object} The filtered object.
49
+ * Creates a new object containing only the specified keys from the original object.
50
+ *
51
+ * @param {Record<string, any>} obj - The source object.
52
+ * @param {string[]} keys - An array of keys to include in the new object.
53
+ * @returns {Record<string, any>} A new object with the filtered properties.
45
54
  */
46
55
  export declare function filterObjectByKeys(obj: Record<string, any>, keys: string[]): Record<string, any>;
47
56
  /**
48
- * Deeply merges two objects.
49
- * @param {Object} target The target object to merge into.
50
- * @param {Object} source The source object to merge from.
51
- * @returns {Object} The merged object.
57
+ * Recursively merges the properties of a source object into a target object.
58
+ *
59
+ * @template T - The type of the target object.
60
+ * @param {T} target - The object to merge properties into.
61
+ * @param {Partial<T>} source - The object from which to merge properties.
62
+ * @returns {T} The modified target object.
52
63
  */
53
64
  export declare function deepMerge<T>(target: T, source: Partial<T>): T;
54
65
  /**
55
- * Checks if an object is empty.
56
- * @param {Object} obj The object to check.
57
- * @returns {boolean} True if the object is empty, otherwise false.
66
+ * Checks if an object has no own enumerable properties.
67
+ *
68
+ * @param {Record<string, any>} obj - The object to check.
69
+ * @returns {boolean} `true` if the object is empty, otherwise `false`.
58
70
  */
59
71
  export declare function isEmptyObject(obj: Record<string, any>): boolean;
60
72
  /**
61
- * Safely accesses nested properties in an object.
62
- * @param {Object} obj The object to access.
63
- * @param {Array<string>} keys The array of keys representing the path.
64
- * @returns {any} The value at the nested path, or undefined if not found.
73
+ * Safely retrieves a nested property from an object using an array of keys as the path.
74
+ *
75
+ * @param {Record<string, any>} obj - The object to query.
76
+ * @param {string[]} keys - An array of keys representing the path to the nested property.
77
+ * @returns {*} The value of the nested property, or `undefined` if the path is not valid.
65
78
  */
66
79
  export declare function safeGet(obj: Record<string, any>, keys: string[]): any;
67
80
  /**
68
- * Removes empty properties (null, undefined, or empty string) from an object.
69
- * @param {Object} obj The object to clean.
70
- * @returns {Object} A new object without empty properties.
81
+ * Creates a new object with all properties that have `null`, `undefined`, or empty string values removed.
82
+ *
83
+ * @param {Record<string, any>} obj - The source object.
84
+ * @returns {Record<string, any>} A new object containing only the non-empty properties.
71
85
  */
72
86
  export declare function removeEmptyProperties(obj: Record<string, any>): Record<string, any>;
73
87
  /**
74
- * Retrieves all keys of an object as an array.
75
- * @param {Object} obj The object to retrieve keys from.
76
- * @returns {Array<string>} The array of keys.
88
+ * Returns an array of an object's own enumerable property names.
89
+ *
90
+ * @param {Record<string, any>} obj - The object to get the keys from.
91
+ * @returns {string[]} An array of string keys.
77
92
  */
78
93
  export declare function getObjectKeys(obj: Record<string, any>): string[];
79
94
  /**
80
- * Checks if an object has nested properties.
81
- * @param {Object} obj The object to check.
82
- * @returns {boolean} True if there are nested properties, false otherwise.
95
+ * Checks if any of the object's properties are themselves objects (and not null).
96
+ *
97
+ * @param {Record<string, any>} obj - The object to inspect.
98
+ * @returns {boolean} `true` if the object contains at least one nested object, otherwise `false`.
83
99
  */
84
100
  export declare function hasNestedProperties(obj: Record<string, any>): boolean;
85
101
  /**
86
- * Converts an object to FormData, handling nested objects.
87
- * @param {Object} obj The object to convert.
88
- * @param {FormData} [formData] The FormData object to append to.
89
- * @param {string} [parentKey] The parent key for nested objects.
90
- * @returns {FormData} The FormData object.
102
+ * Recursively converts a nested object into a `FormData` object.
103
+ *
104
+ * @param {Record<string, any>} obj - The object to convert.
105
+ * @param {FormData} [formData=new FormData()] - An existing `FormData` object to append to.
106
+ * @param {string} [parentKey=''] - The base key for nested properties.
107
+ * @returns {FormData} The resulting `FormData` object.
91
108
  */
92
109
  export declare function objectToFormDataEnhanced(obj: Record<string, any>, formData?: FormData, parentKey?: string): FormData;
93
110
  /**
94
- * Converts a JavaScript object into FormData.
111
+ * Recursively converts a JavaScript object into a `FormData` object, handling nested objects and boolean conversion.
95
112
  *
96
- * @param obj - The object to be converted.
97
- * @param form - An optional FormData instance to use.
98
- * @param namespace - An optional namespace to use for nested objects.
99
- * @returns The FormData instance with the object's key-value pairs.
113
+ * @param {any} obj - The object to convert.
114
+ * @param {FormData} [form] - An optional existing `FormData` object to append to.
115
+ * @param {string} [namespace] - An optional namespace for keys of nested properties.
116
+ * @returns {FormData} The resulting `FormData` object.
100
117
  */
101
118
  export declare const objectToFormData: (obj: any, form?: FormData, namespace?: string) => FormData;
102
119
  /**
103
- * Flattens a nested object, bringing all properties to the top level.
104
- * @param {Object} obj The object to flatten.
105
- * @param {string} [parentKey] The parent key for nested properties.
106
- * @param {Object} [result] The resulting flattened object.
107
- * @returns {Object} The flattened object.
120
+ * Flattens a nested object into a single-level object with dot-separated keys.
121
+ *
122
+ * @param {Record<string, any>} obj - The object to flatten.
123
+ * @param {string} [parentKey=''] - The prefix to use for the keys of the flattened properties.
124
+ * @param {Record<string, any>} [result={}] - An object to merge the flattened properties into.
125
+ * @returns {Record<string, any>} The flattened object.
108
126
  */
109
127
  export declare function flattenObject(obj: Record<string, any>, parentKey?: string, result?: Record<string, any>): Record<string, any>;
@@ -0,0 +1,8 @@
1
+ export interface RetryConfig {
2
+ retries?: number;
3
+ retryDelay?: number;
4
+ retryCondition?: (error: unknown) => boolean;
5
+ maxRetryDelay?: number;
6
+ backoffMultiplier?: number;
7
+ }
8
+ export declare function retryWithBackoff<T>(fn: () => Promise<T>, config?: RetryConfig): Promise<T>;
@@ -0,0 +1,27 @@
1
+ export declare const isServer: boolean;
2
+ export declare const isClient: boolean;
3
+ export declare function getStorage(): Storage | null;
4
+ export declare function getSessionStorage(): Storage | null;
5
+ export interface CookieOptions {
6
+ expires?: number;
7
+ path?: string;
8
+ domain?: string;
9
+ secure?: boolean;
10
+ sameSite?: 'Strict' | 'Lax' | 'None';
11
+ httpOnly?: boolean;
12
+ }
13
+ export interface CookieStorage {
14
+ getItem: (key: string) => string | null;
15
+ setItem: (key: string, value: string, options?: CookieOptions) => void;
16
+ removeItem: (key: string, options?: {
17
+ path?: string;
18
+ domain?: string;
19
+ }) => void;
20
+ }
21
+ export declare function getCookieStorage(): CookieStorage;
22
+ export interface PreferredStorage {
23
+ getItem: (key: string) => string | null;
24
+ setItem: (key: string, value: string) => void;
25
+ removeItem: (key: string) => void;
26
+ }
27
+ export declare function getPreferredStorage(): PreferredStorage;
@@ -1,20 +1,26 @@
1
1
  import { LocationPreference } from "@/types";
2
+ import { CookieOptions } from "./ssr";
2
3
  /**
3
- * Encrypts and stores an item in local or session storage.
4
- * Assumes the `window` environment is available.
5
- * @param key The key under which to store the value.
6
- * @param value The value to encrypt and store.
7
- * @param secretKey The secret key for encryption.
8
- * @param location Determines where the item is stored: 'local' for localStorage, 'session' for sessionStorage.
9
- * @returns A promise that resolves when the item is stored. Throws an error if it fails.
4
+ * Encrypts and stores a key-value pair in either `localStorage`, `sessionStorage`, or cookies.
5
+ * Cookies are automatically used in SSR environments and can be explicitly requested.
6
+ * Cookies include security options: Secure (HTTPS only), SameSite (CSRF protection), and encryption.
7
+ *
8
+ * @param {string} key - The key for the storage item.
9
+ * @param {string} value - The string value to encrypt and store.
10
+ * @param {string} secretKey - The secret key to use for encryption.
11
+ * @param {LocationPreference} location - The storage location: 'local' for `localStorage`, 'session' for `sessionStorage`, 'cookie' for cookies, or 'any' for retrieval.
12
+ * @param {CookieOptions} [cookieOptions] - Optional cookie-specific options (only used when location is 'cookie').
13
+ * @returns {Promise<void>} A promise that resolves when the item has been stored.
10
14
  */
11
- export declare function storeEncryptedItem(key: string, value: string, secretKey: string, location: LocationPreference): Promise<void>;
15
+ export declare function storeEncryptedItem(key: string, value: string, secretKey: string, location: LocationPreference, cookieOptions?: CookieOptions): Promise<void>;
12
16
  /**
13
- * Retrieves and decrypts a value from local or session storage.
14
- * Assumes the `window` environment is available.
15
- * @param key The key of the item to retrieve.
16
- * @param secretKey The secret key for decryption.
17
- * @param location Specifies where to search for the item: 'local' for localStorage, 'session' for sessionStorage, or 'any' to check both (session first).
18
- * @returns A promise that resolves with the decrypted value or null if not found or decryption fails.
17
+ * Retrieves and decrypts an item from `localStorage`, `sessionStorage`, or cookies.
18
+ * When location is 'any', checks in order: sessionStorage, localStorage, cookies.
19
+ * Cookies are automatically checked in SSR environments.
20
+ *
21
+ * @param {string} key - The key of the item to retrieve.
22
+ * @param {string} secretKey - The secret key to use for decryption.
23
+ * @param {LocationPreference} location - The storage location to search: 'local', 'session', 'cookie', or 'any' (checks session, local, cookie in that order).
24
+ * @returns {Promise<string | null>} A promise that resolves with the decrypted value, or `null` if the item is not found or decryption fails.
19
25
  */
20
26
  export declare function getDecryptedItem(key: string, secretKey: string, location: LocationPreference): Promise<string | null>;