@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.
- package/README.md +90 -57
- package/dist/composables/auth/useAuth.d.ts +20 -6
- package/dist/composables/axios/axiosFetch.d.ts +7 -5
- package/dist/composables/axios/index.d.ts +0 -1
- package/dist/composables/axios/useFetch.d.ts +14 -5
- package/dist/composables/breakpoints/useBreakpoint.d.ts +11 -2
- package/dist/composables/filters/useFilter.d.ts +13 -8
- package/dist/composables/monitoring/useApiActivity.d.ts +17 -6
- package/dist/composables/monitoring/useUserActivity.d.ts +20 -5
- package/dist/composables/paginators/usePaginator.d.ts +13 -5
- package/dist/composables/sorters/useSorter.d.ts +13 -7
- package/dist/config/auth/authFetcher.d.ts +30 -0
- package/dist/config/auth/index.d.ts +1 -0
- package/dist/config/axios/axiosConfig.d.ts +30 -0
- package/dist/config/axios/axiosInstance.d.ts +14 -0
- package/dist/config/global/endpointsConfig.d.ts +9 -13
- package/dist/config/global/keyConfig.d.ts +7 -10
- package/dist/config/global/sessionConfig.d.ts +15 -17
- package/dist/config/global/tokenPathsConfig.d.ts +17 -18
- package/dist/config/global/tokensConfig.d.ts +9 -9
- package/dist/config/index.d.ts +1 -0
- package/dist/enums/breakpointsEnums.d.ts +7 -4
- package/dist/enums/errorsEnums.d.ts +26 -19
- package/dist/enums/fileTypesEnums.d.ts +33 -1
- package/dist/enums/httpExceptionsEnums.d.ts +3 -1
- package/dist/enums/keyCodesEnums.d.ts +2 -4
- package/dist/enums/storageEnums.d.ts +4 -4
- package/dist/errors/AuthError.d.ts +10 -0
- package/dist/errors/BaseError.d.ts +16 -0
- package/dist/errors/NetworkError.d.ts +9 -0
- package/dist/errors/ServerError.d.ts +10 -0
- package/dist/errors/ValidationError.d.ts +14 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/fetchers/axios.d.ts +22 -0
- package/dist/fetchers/index.d.ts +2 -0
- package/dist/fetchers/ofetch.d.ts +33 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.mjs +1633 -875
- package/dist/rest/RestStd.d.ts +146 -102
- package/dist/services/credentials.d.ts +24 -29
- package/dist/services/extractTokens.d.ts +7 -6
- package/dist/services/refreshTokens.d.ts +11 -12
- package/dist/services/storeTokens.d.ts +8 -6
- package/dist/types/AppKeyConfig.d.ts +7 -0
- package/dist/types/ArexVueCoreOptions.d.ts +20 -0
- package/dist/types/Auth.d.ts +15 -0
- package/dist/types/AxiosOptionsParameter.d.ts +14 -7
- package/dist/types/AxiosServiceOptions.d.ts +9 -0
- package/dist/types/DecodedJwtPayload.d.ts +12 -0
- package/dist/types/EndpointsConfig.d.ts +7 -0
- package/dist/types/ErrorType.d.ts +4 -2
- package/dist/types/ExtendedQueryOptions.d.ts +10 -0
- package/dist/types/Fetcher.d.ts +24 -0
- package/dist/types/RestStdOptions.d.ts +62 -0
- package/dist/types/SessionConfig.d.ts +25 -1
- package/dist/types/TokenConfig.d.ts +7 -0
- package/dist/types/TokenValidationResult.d.ts +7 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/utils/browser.d.ts +20 -14
- package/dist/utils/dates.d.ts +47 -34
- package/dist/utils/debounces.d.ts +54 -32
- package/dist/utils/encryption.d.ts +28 -24
- package/dist/utils/errors.d.ts +27 -8
- package/dist/utils/exports.d.ts +24 -19
- package/dist/utils/files.d.ts +33 -25
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/io.d.ts +70 -54
- package/dist/utils/objects.d.ts +78 -60
- package/dist/utils/retry.d.ts +8 -0
- package/dist/utils/ssr.d.ts +27 -0
- package/dist/utils/storage.d.ts +20 -14
- package/dist/utils/strings.d.ts +42 -31
- package/dist/utils/validations.d.ts +76 -57
- package/package.json +7 -16
package/dist/utils/files.d.ts
CHANGED
|
@@ -1,46 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts a FormData object
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
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
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
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
|
-
*
|
|
22
|
-
* @param {string}
|
|
23
|
-
* @
|
|
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
|
-
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @
|
|
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
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @param {
|
|
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
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {string}
|
|
44
|
-
* @
|
|
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;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/io.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
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
|
-
*
|
|
22
|
+
* Re-enables all mouse buttons that were previously disabled by `disableMouseButtons`.
|
|
22
23
|
*/
|
|
23
24
|
export declare function enableMouseButtons(): void;
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @param {
|
|
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
|
|
32
|
-
*
|
|
33
|
-
* @param {
|
|
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
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {
|
|
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
|
-
*
|
|
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
|
|
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
|
|
59
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @param {
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {boolean} [
|
|
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
|
|
76
|
-
*
|
|
77
|
-
* @param {
|
|
78
|
-
* @param {boolean} [
|
|
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
|
|
83
|
-
*
|
|
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
|
-
*
|
|
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
|
|
95
|
-
*
|
|
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
|
-
*
|
|
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
|
|
113
|
-
*
|
|
114
|
-
* @param {
|
|
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
|
|
133
|
+
* Removes all key listeners that were added using `addKeyListener`.
|
|
122
134
|
*/
|
|
123
135
|
export declare function removeKeyListeners(): void;
|
|
124
136
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* @param {
|
|
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
|
-
*
|
|
147
|
+
* Removes all key hold listeners that were added by `detectKeyHold`.
|
|
135
148
|
*/
|
|
136
149
|
export declare function stopDetectingKeyHold(): void;
|
|
137
150
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
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
|
|
147
|
-
*
|
|
148
|
-
* @param {
|
|
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
|
|
173
|
+
* Removes all keyboard shortcut listeners that were added by `customShortcut`.
|
|
159
174
|
*/
|
|
160
175
|
export declare function removeCustomShortcuts(): void;
|
|
161
176
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* @param {
|
|
165
|
-
* @param {boolean}
|
|
166
|
-
* @param {boolean}
|
|
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;
|
package/dist/utils/objects.d.ts
CHANGED
|
@@ -1,109 +1,127 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts a Proxy object
|
|
3
|
-
*
|
|
4
|
-
* @
|
|
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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param {
|
|
11
|
-
* @
|
|
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
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param {
|
|
18
|
-
* @
|
|
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
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
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
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
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
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @param {
|
|
37
|
-
* @
|
|
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
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @param {
|
|
44
|
-
* @
|
|
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
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
* @
|
|
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
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
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
|
|
62
|
-
*
|
|
63
|
-
* @param {
|
|
64
|
-
* @
|
|
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
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
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
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @
|
|
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
|
|
81
|
-
*
|
|
82
|
-
* @
|
|
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
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* @param {
|
|
89
|
-
* @param {
|
|
90
|
-
* @
|
|
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
|
-
*
|
|
111
|
+
* Recursively converts a JavaScript object into a `FormData` object, handling nested objects and boolean conversion.
|
|
95
112
|
*
|
|
96
|
-
* @param obj - The object to
|
|
97
|
-
* @param form - An optional FormData
|
|
98
|
-
* @param namespace - An optional namespace
|
|
99
|
-
* @returns
|
|
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
|
|
104
|
-
*
|
|
105
|
-
* @param {string}
|
|
106
|
-
* @param {
|
|
107
|
-
* @
|
|
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;
|
package/dist/utils/storage.d.ts
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { LocationPreference } from "@/types";
|
|
2
|
+
import { CookieOptions } from "./ssr";
|
|
2
3
|
/**
|
|
3
|
-
* Encrypts and stores
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
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
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
18
|
-
* @
|
|
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>;
|