@dxtmisha/functional-basic 1.8.9 → 1.10.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 (200) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/ai-description.md +6 -13
  3. package/ai-mcp-resources.json +14 -2
  4. package/ai-resources/design-config.md +104 -0
  5. package/ai-resources/error-center.md +150 -0
  6. package/ai-types.md +1 -3233
  7. package/dist/library.d.ts +9991 -189
  8. package/dist/library.js +851 -835
  9. package/package.json +7 -2
  10. package/ai-resources/prompts.json +0 -8
  11. package/dist/classes/Api.d.ts +0 -209
  12. package/dist/classes/ApiCache.d.ts +0 -152
  13. package/dist/classes/ApiDataReturn.d.ts +0 -79
  14. package/dist/classes/ApiDefault.d.ts +0 -49
  15. package/dist/classes/ApiError.d.ts +0 -39
  16. package/dist/classes/ApiErrorItem.d.ts +0 -70
  17. package/dist/classes/ApiErrorStorage.d.ts +0 -92
  18. package/dist/classes/ApiHeaders.d.ts +0 -37
  19. package/dist/classes/ApiHydration.d.ts +0 -40
  20. package/dist/classes/ApiInstance.d.ts +0 -299
  21. package/dist/classes/ApiPreparation.d.ts +0 -58
  22. package/dist/classes/ApiResponse.d.ts +0 -154
  23. package/dist/classes/ApiStatus.d.ts +0 -131
  24. package/dist/classes/BroadcastMessage.d.ts +0 -76
  25. package/dist/classes/Cache.d.ts +0 -39
  26. package/dist/classes/CacheItem.d.ts +0 -65
  27. package/dist/classes/CacheStatic.d.ts +0 -36
  28. package/dist/classes/Cookie.d.ts +0 -54
  29. package/dist/classes/CookieBlock.d.ts +0 -30
  30. package/dist/classes/CookieBlockInstance.d.ts +0 -24
  31. package/dist/classes/CookieStorage.d.ts +0 -175
  32. package/dist/classes/DataStorage.d.ts +0 -107
  33. package/dist/classes/Datetime.d.ts +0 -571
  34. package/dist/classes/ErrorCenter.d.ts +0 -86
  35. package/dist/classes/ErrorCenterHandler.d.ts +0 -85
  36. package/dist/classes/ErrorCenterInstance.d.ts +0 -101
  37. package/dist/classes/EventItem.d.ts +0 -230
  38. package/dist/classes/Formatters.d.ts +0 -157
  39. package/dist/classes/Geo.d.ts +0 -172
  40. package/dist/classes/GeoFlag.d.ts +0 -135
  41. package/dist/classes/GeoInstance.d.ts +0 -264
  42. package/dist/classes/GeoIntl.d.ts +0 -291
  43. package/dist/classes/GeoPhone.d.ts +0 -110
  44. package/dist/classes/GeoUnit.d.ts +0 -207
  45. package/dist/classes/Global.d.ts +0 -29
  46. package/dist/classes/Hash.d.ts +0 -57
  47. package/dist/classes/HashInstance.d.ts +0 -29
  48. package/dist/classes/Icons.d.ts +0 -128
  49. package/dist/classes/Loading.d.ts +0 -62
  50. package/dist/classes/LoadingInstance.d.ts +0 -87
  51. package/dist/classes/Meta.d.ts +0 -189
  52. package/dist/classes/MetaManager.d.ts +0 -123
  53. package/dist/classes/MetaOg.d.ts +0 -120
  54. package/dist/classes/MetaStatic.d.ts +0 -179
  55. package/dist/classes/MetaTwitter.d.ts +0 -120
  56. package/dist/classes/Query.d.ts +0 -57
  57. package/dist/classes/QueryInstance.d.ts +0 -29
  58. package/dist/classes/ResumableTimer.d.ts +0 -85
  59. package/dist/classes/ScrollbarWidth.d.ts +0 -52
  60. package/dist/classes/SearchList.d.ts +0 -132
  61. package/dist/classes/SearchListData.d.ts +0 -144
  62. package/dist/classes/SearchListItem.d.ts +0 -49
  63. package/dist/classes/SearchListMatcher.d.ts +0 -58
  64. package/dist/classes/SearchListOptions.d.ts +0 -66
  65. package/dist/classes/ServerStorage.d.ts +0 -110
  66. package/dist/classes/StorageCallback.d.ts +0 -86
  67. package/dist/classes/Translate.d.ts +0 -117
  68. package/dist/classes/TranslateFile.d.ts +0 -81
  69. package/dist/classes/TranslateInstance.d.ts +0 -203
  70. package/dist/classes/UrlInstanceAbstract.d.ts +0 -98
  71. package/dist/classes/UrlItem.d.ts +0 -119
  72. package/dist/functions/addTagHighlightMatch.d.ts +0 -11
  73. package/dist/functions/anyToString.d.ts +0 -10
  74. package/dist/functions/applyTemplate.d.ts +0 -10
  75. package/dist/functions/arrFill.d.ts +0 -9
  76. package/dist/functions/blobToBase64.d.ts +0 -9
  77. package/dist/functions/capitalize.d.ts +0 -9
  78. package/dist/functions/copyObject.d.ts +0 -10
  79. package/dist/functions/copyObjectLite.d.ts +0 -9
  80. package/dist/functions/createElement.d.ts +0 -21
  81. package/dist/functions/domContentLoaded.d.ts +0 -13
  82. package/dist/functions/domQuerySelector.d.ts +0 -8
  83. package/dist/functions/domQuerySelectorAll.d.ts +0 -8
  84. package/dist/functions/encodeAttribute.d.ts +0 -8
  85. package/dist/functions/encodeLiteAttribute.d.ts +0 -8
  86. package/dist/functions/ensureMaxSize.d.ts +0 -10
  87. package/dist/functions/escapeExp.d.ts +0 -7
  88. package/dist/functions/eventStopPropagation.d.ts +0 -7
  89. package/dist/functions/executeFunction.d.ts +0 -12
  90. package/dist/functions/executePromise.d.ts +0 -11
  91. package/dist/functions/forEach.d.ts +0 -14
  92. package/dist/functions/frame.d.ts +0 -10
  93. package/dist/functions/getArrayHighlightMatch.d.ts +0 -10
  94. package/dist/functions/getAttributes.d.ts +0 -9
  95. package/dist/functions/getClipboardData.d.ts +0 -9
  96. package/dist/functions/getColumn.d.ts +0 -10
  97. package/dist/functions/getCurrentDate.d.ts +0 -19
  98. package/dist/functions/getCurrentTime.d.ts +0 -15
  99. package/dist/functions/getElement.d.ts +0 -9
  100. package/dist/functions/getElementId.d.ts +0 -26
  101. package/dist/functions/getElementImage.d.ts +0 -8
  102. package/dist/functions/getElementItem.d.ts +0 -12
  103. package/dist/functions/getElementOrWindow.d.ts +0 -8
  104. package/dist/functions/getElementSafeScript.d.ts +0 -9
  105. package/dist/functions/getExactSearchExp.d.ts +0 -8
  106. package/dist/functions/getExp.d.ts +0 -14
  107. package/dist/functions/getFirst.d.ts +0 -8
  108. package/dist/functions/getHydrationData.d.ts +0 -10
  109. package/dist/functions/getItemByPath.d.ts +0 -9
  110. package/dist/functions/getKey.d.ts +0 -8
  111. package/dist/functions/getLast.d.ts +0 -8
  112. package/dist/functions/getLength.d.ts +0 -10
  113. package/dist/functions/getLengthOfAllArray.d.ts +0 -8
  114. package/dist/functions/getMaxLengthAllArray.d.ts +0 -9
  115. package/dist/functions/getMinLengthAllArray.d.ts +0 -8
  116. package/dist/functions/getMouseClient.d.ts +0 -9
  117. package/dist/functions/getMouseClientX.d.ts +0 -8
  118. package/dist/functions/getMouseClientY.d.ts +0 -8
  119. package/dist/functions/getObjectByKeys.d.ts +0 -8
  120. package/dist/functions/getObjectNoUndefined.d.ts +0 -9
  121. package/dist/functions/getObjectOrNone.d.ts +0 -8
  122. package/dist/functions/getOnlyText.d.ts +0 -8
  123. package/dist/functions/getRandomItem.d.ts +0 -10
  124. package/dist/functions/getRandomText.d.ts +0 -12
  125. package/dist/functions/getRequestString.d.ts +0 -11
  126. package/dist/functions/getSearchExp.d.ts +0 -12
  127. package/dist/functions/getSeparatingSearchExp.d.ts +0 -9
  128. package/dist/functions/getStepPercent.d.ts +0 -9
  129. package/dist/functions/getStepValue.d.ts +0 -9
  130. package/dist/functions/goScroll.d.ts +0 -10
  131. package/dist/functions/goScrollSmooth.d.ts +0 -10
  132. package/dist/functions/goScrollTo.d.ts +0 -10
  133. package/dist/functions/handleShare.d.ts +0 -10
  134. package/dist/functions/inArray.d.ts +0 -9
  135. package/dist/functions/initScrollbarOffset.d.ts +0 -7
  136. package/dist/functions/intersectKey.d.ts +0 -9
  137. package/dist/functions/isApiSuccess.d.ts +0 -9
  138. package/dist/functions/isArray.d.ts +0 -8
  139. package/dist/functions/isDifferent.d.ts +0 -10
  140. package/dist/functions/isDomData.d.ts +0 -7
  141. package/dist/functions/isDomRuntime.d.ts +0 -10
  142. package/dist/functions/isElementVisible.d.ts +0 -11
  143. package/dist/functions/isEnter.d.ts +0 -9
  144. package/dist/functions/isFilled.d.ts +0 -10
  145. package/dist/functions/isFloat.d.ts +0 -8
  146. package/dist/functions/isFunction.d.ts +0 -9
  147. package/dist/functions/isInDom.d.ts +0 -9
  148. package/dist/functions/isInput.d.ts +0 -8
  149. package/dist/functions/isIntegerBetween.d.ts +0 -9
  150. package/dist/functions/isMetaKey.d.ts +0 -8
  151. package/dist/functions/isNull.d.ts +0 -9
  152. package/dist/functions/isNumber.d.ts +0 -8
  153. package/dist/functions/isObject.d.ts +0 -8
  154. package/dist/functions/isObjectNotArray.d.ts +0 -8
  155. package/dist/functions/isOnLine.d.ts +0 -7
  156. package/dist/functions/isSelected.d.ts +0 -9
  157. package/dist/functions/isSelectedByList.d.ts +0 -9
  158. package/dist/functions/isShare.d.ts +0 -7
  159. package/dist/functions/isString.d.ts +0 -8
  160. package/dist/functions/isTab.d.ts +0 -8
  161. package/dist/functions/isWindow.d.ts +0 -7
  162. package/dist/functions/random.d.ts +0 -9
  163. package/dist/functions/removeCommonPrefix.d.ts +0 -9
  164. package/dist/functions/replaceComponentName.d.ts +0 -9
  165. package/dist/functions/replaceRecursive.d.ts +0 -11
  166. package/dist/functions/replaceTemplate.d.ts +0 -10
  167. package/dist/functions/resizeImageByMax.d.ts +0 -19
  168. package/dist/functions/secondToTime.d.ts +0 -9
  169. package/dist/functions/setElementItem.d.ts +0 -11
  170. package/dist/functions/setValues.d.ts +0 -18
  171. package/dist/functions/sleep.d.ts +0 -8
  172. package/dist/functions/sortList.d.ts +0 -11
  173. package/dist/functions/splice.d.ts +0 -13
  174. package/dist/functions/strFill.d.ts +0 -9
  175. package/dist/functions/strSplit.d.ts +0 -12
  176. package/dist/functions/toArray.d.ts +0 -17
  177. package/dist/functions/toCamelCase.d.ts +0 -8
  178. package/dist/functions/toCamelCaseFirst.d.ts +0 -8
  179. package/dist/functions/toDate.d.ts +0 -8
  180. package/dist/functions/toKebabCase.d.ts +0 -15
  181. package/dist/functions/toNumber.d.ts +0 -19
  182. package/dist/functions/toNumberByMax.d.ts +0 -11
  183. package/dist/functions/toNumberPositive.d.ts +0 -9
  184. package/dist/functions/toPercent.d.ts +0 -9
  185. package/dist/functions/toPercentBy100.d.ts +0 -9
  186. package/dist/functions/toString.d.ts +0 -8
  187. package/dist/functions/transformation.d.ts +0 -21
  188. package/dist/functions/uint8ArrayToBase64.d.ts +0 -8
  189. package/dist/functions/uniqueArray.d.ts +0 -8
  190. package/dist/functions/writeClipboardData.d.ts +0 -8
  191. package/dist/media/errorCauseList.d.ts +0 -2
  192. package/dist/types/apiTypes.d.ts +0 -259
  193. package/dist/types/basicTypes.d.ts +0 -131
  194. package/dist/types/errorCenterTypes.d.ts +0 -50
  195. package/dist/types/formattersTypes.d.ts +0 -224
  196. package/dist/types/geoTypes.d.ts +0 -142
  197. package/dist/types/metaTypes.d.ts +0 -586
  198. package/dist/types/searchTypes.d.ts +0 -53
  199. package/dist/types/sortTypes.d.ts +0 -20
  200. package/dist/types/translateTypes.d.ts +0 -54
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxtmisha/functional-basic",
3
3
  "private": false,
4
- "version": "1.8.9",
4
+ "version": "1.10.0",
5
5
  "type": "module",
6
6
  "description": "Foundational isomorphic utility library for modern web and SSR development — HTTP client, state storage, i18n localization, SEO metadata, DOM events, formatting, and data utilities. Framework-agnostic, TypeScript-first.",
7
7
  "keywords": [
@@ -71,6 +71,7 @@
71
71
  },
72
72
  "files": [
73
73
  "ai-resources",
74
+ "ai-screenshot",
74
75
  "dist",
75
76
  "ai-description.md",
76
77
  "ai-doc.md",
@@ -88,7 +89,11 @@
88
89
  ".": {
89
90
  "import": "./dist/library.js",
90
91
  "types": "./dist/library.d.ts"
91
- }
92
+ },
93
+ "./ai-types.md": "./ai-types.md",
94
+ "./ai-description.md": "./ai-description.md",
95
+ "./ai-resources/*": "./ai-resources/*",
96
+ "./ai-screenshot/*": "./ai-screenshot/*"
92
97
  },
93
98
  "engines": {
94
99
  "node": ">=20.0.0"
@@ -1,8 +0,0 @@
1
- [
2
- {
3
- "path": "ai-resources/api-reference.md",
4
- "md5": "5b6b7850a06fbe60c2ff108599c45dc3",
5
- "name": "API Reference and Examples",
6
- "description": "Provides code examples and usage patterns for the @dxtmisha/functional-basic library modules including HTTP client, storage, geolocation, and DOM helpers. It helps AI agents understand how to correctly integrate and utilize utility functions for frontend and backend tasks."
7
- }
8
- ]
@@ -1,209 +0,0 @@
1
- import { ApiInstance } from './ApiInstance';
2
- import { ApiConfig, ApiDefaultValue, ApiFetch, ApiHeadersValue, ApiMethodItem, ApiPreparationEnd } from '../types/apiTypes';
3
- import { ApiStatus } from './ApiStatus';
4
- import { ApiResponse } from './ApiResponse';
5
- import { ApiHydration } from './ApiHydration';
6
- /**
7
- * Class for working with HTTP requests.
8
- *
9
- * Класс для работы с HTTP-запросами.
10
- */
11
- export declare class Api {
12
- /**
13
- * Checks if the server is running on localhost.
14
- *
15
- * Проверяет, работает ли сервер на localhost.
16
- * @returns true if server is localhost / true, если сервер является локальным
17
- */
18
- static isLocalhost(): boolean;
19
- /**
20
- * Returns the singleton instance of the ApiInstance class.
21
- *
22
- * Возвращает синглтон-экземпляр класса ApiInstance.
23
- * @returns ApiInstance singleton / синглтон ApiInstance
24
- */
25
- static getItem(): ApiInstance;
26
- /**
27
- * Returns the status of the last request.
28
- *
29
- * Возвращает статус последнего запроса.
30
- * @returns ApiStatus instance / экземпляр ApiStatus
31
- */
32
- static getStatus(): ApiStatus;
33
- /**
34
- * Gets the response handler.
35
- *
36
- * Получает обработчик ответа.
37
- * @returns ApiResponse instance / экземпляр ApiResponse
38
- */
39
- static getResponse(): ApiResponse;
40
- /**
41
- * Gets the hydration handler.
42
- *
43
- * Получает обработчик гидратации.
44
- * @returns ApiHydration instance / экземпляр ApiHydration
45
- */
46
- static getHydration(): ApiHydration;
47
- /**
48
- * Returns a string representation of the hydration data for the client.
49
- *
50
- * Возвращает строковое представление данных гидратации для клиента.
51
- * @returns HTML script element string / строка HTML элемента script
52
- */
53
- static getHydrationScript(): string;
54
- /**
55
- * Gets the base origin URL combined with the API path.
56
- *
57
- * Получает базовый URL источника, объединенный с путем API.
58
- * @returns final base URL string / итоговая строка базового URL
59
- */
60
- static getOrigin(): string;
61
- /**
62
- * Gets the full path to the request script.
63
- *
64
- * Получает полный путь к скрипту запроса.
65
- * @param path path to the script / путь к скрипту
66
- * @param api whether to prepend base API URL / нужно ли добавить базовый URL API
67
- * @returns full URL / полный URL
68
- */
69
- static getUrl(path: string, api?: boolean): string;
70
- /**
71
- * Gets data for the request body.
72
- *
73
- * Получает данные для тела запроса.
74
- * @param request request data / данные запроса
75
- * @param method HTTP method / HTTP метод
76
- * @returns body data for non-GET requests or FormData / данные тела для не-GET запросов или FormData
77
- */
78
- static getBody(request?: ApiFetch['request'], method?: ApiMethodItem): string | FormData | undefined;
79
- /**
80
- * Gets query string for GET method requests.
81
- *
82
- * Получает строку запроса для GET-методов.
83
- * @param request request data / данные запроса
84
- * @param path path to request / путь к запросу
85
- * @param method HTTP method / HTTP метод
86
- * @returns query string for GET requests / строка запроса для GET-запросов
87
- */
88
- static getBodyForGet(request: ApiFetch['request'], path?: string, method?: ApiMethodItem): string;
89
- /**
90
- * Modifies the default header data.
91
- *
92
- * Изменяет данные заголовка по умолчанию.
93
- * @param headers default headers / заголовки по умолчанию
94
- * @returns void / ничего не возвращает
95
- */
96
- static setHeaders(headers: ApiHeadersValue): void;
97
- /**
98
- * Modifies the default request data.
99
- *
100
- * Изменяет данные запроса по умолчанию.
101
- * @param request default request data / данные запроса по умолчанию
102
- * @returns void / ничего не возвращает
103
- */
104
- static setRequestDefault(request: ApiDefaultValue): void;
105
- /**
106
- * Changes the base path to the script.
107
- *
108
- * Изменяет базовый путь к скрипту.
109
- * @param url path to the script / путь к скрипту
110
- * @returns void / ничего не возвращает
111
- */
112
- static setUrl(url: string): void;
113
- /**
114
- * Modifies the function to be called before the request.
115
- *
116
- * Изменяет функцию для вызова перед запросом.
117
- * @param callback function to call before request / функция для вызова перед запросом
118
- * @returns void / ничего не возвращает
119
- */
120
- static setPreparation(callback: (apiFetch: ApiFetch) => Promise<void>): void;
121
- /**
122
- * Modifies the function to be called after the request.
123
- *
124
- * Изменяет функцию для вызова после запроса.
125
- * @param callback function to call after request / функция для вызова после запроса
126
- * @returns void / ничего не возвращает
127
- */
128
- static setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): void;
129
- /**
130
- * Changes the timeout for the request in milliseconds.
131
- *
132
- * Изменяет таймаут запроса в миллисекундах.
133
- * @param timeout timeout in milliseconds / таймаут в миллисекундах
134
- * @returns void / ничего не возвращает
135
- */
136
- static setTimeout(timeout: number): void;
137
- /**
138
- * Changes the origin (protocol and domain) for the base URL.
139
- *
140
- * Изменяет источник (протокол и домен) для базового URL.
141
- * @param origin protocol and domain / протокол и домен
142
- * @returns void / ничего не возвращает
143
- */
144
- static setOrigin(origin: string): void;
145
- /**
146
- * Sets the wrapper function for requests.
147
- *
148
- * Устанавливает функцию-обертку для запросов.
149
- * @param wrapper wrapper function / функция-обертка
150
- * @returns void / ничего не возвращает
151
- */
152
- static setWrapper(wrapper: <R>(callback: () => Promise<R>, apiFetch: ApiFetch) => Promise<R>): void;
153
- /**
154
- * Sets multiple API configuration options at once.
155
- *
156
- * Устанавливает несколько опций конфигурации API одновременно.
157
- * @param config configuration object / объект конфигурации
158
- * @returns void / ничего не возвращает
159
- */
160
- static setConfig(config?: ApiConfig): void;
161
- /**
162
- * Executes a request with the given path or configuration.
163
- *
164
- * Выполняет запрос с указанным путем или конфигурацией.
165
- * @param pathRequest path or configuration / путь или конфигурация запроса
166
- * @returns Promise with response data / Promise с данными ответа
167
- */
168
- static request<T>(pathRequest: string | ApiFetch): Promise<T>;
169
- /**
170
- * Sends a GET method request.
171
- *
172
- * Отправляет запрос метода GET.
173
- * @param request fetch configuration / конфигурация запроса
174
- * @returns Promise with response data / Promise с данными ответа
175
- */
176
- static get<T>(request: ApiFetch): Promise<T>;
177
- /**
178
- * Sends a POST method request.
179
- *
180
- * Отправляет запрос метода POST.
181
- * @param request fetch configuration / конфигурация запроса
182
- * @returns Promise with response data / Promise с данными ответа
183
- */
184
- static post<T>(request: ApiFetch): Promise<T>;
185
- /**
186
- * Sends a PUT method request.
187
- *
188
- * Отправляет запрос метода PUT.
189
- * @param request fetch configuration / конфигурация запроса
190
- * @returns Promise with response data / Promise с данными ответа
191
- */
192
- static put<T>(request: ApiFetch): Promise<T>;
193
- /**
194
- * Sends a PATCH method request.
195
- *
196
- * Отправляет запрос метода PATCH.
197
- * @param request fetch configuration / конфигурация запроса
198
- * @returns Promise with response data / Promise с данными ответа
199
- */
200
- static patch<T>(request: ApiFetch): Promise<T>;
201
- /**
202
- * Sends a DELETE method request.
203
- *
204
- * Отправляет запрос метода DELETE.
205
- * @param request fetch configuration / конфигурация запроса
206
- * @returns Promise with response data / Promise с данными ответа
207
- */
208
- static delete<T>(request: ApiFetch): Promise<T>;
209
- }
@@ -1,152 +0,0 @@
1
- import { ApiCacheItem, ApiCacheList, ApiFetch } from '../types/apiTypes';
2
- /**
3
- * Class for caching API responses.
4
- *
5
- * Класс для кэширования ответов API.
6
- */
7
- export declare class ApiCache {
8
- /** Cache storage / Кэш-хранилища */
9
- protected static items?: ApiCacheList;
10
- /** Storage mechanism for getting data / механизм хранения для получения данных */
11
- protected static getListener?: (key: string) => Promise<ApiCacheItem | undefined>;
12
- /** Storage mechanism for setting data / механизм хранения для сохранения данных */
13
- protected static setListener?: (key: string, value: ApiCacheItem) => Promise<boolean>;
14
- /** Storage mechanism for removing data / механизм хранения для удаления данных */
15
- protected static removeListener?: (key: string) => Promise<boolean>;
16
- /**
17
- * Number of data retrieval requests before starting the cleaning of old cache/
18
- * Количество запросов получения данных перед началом очистки старого кэша
19
- */
20
- protected static cacheStepAgeClearOld: number;
21
- /** Number of data retrieval requests before starting the cleaning of old cache / Количество запросов получения данных перед началом очистки старого кэша */
22
- protected static stepAgeClearOld: number;
23
- /**
24
- * Initializes the storage with listeners.
25
- *
26
- * Инициализирует хранилище слушателями.
27
- * @param getListener Storage mechanism for getting data / механизм хранения для получения данных
28
- * @param setListener Storage mechanism for setting data / механизм хранения для сохранения данных
29
- * @param removeListener Storage mechanism for removing data / механизм хранения для удаления данных
30
- * @param cacheStepAgeClearOld Number of data retrieval requests before starting the cleaning of old cache / количество запросов получения данных перед началом очистки старого кэша
31
- */
32
- static init(getListener: (key: string) => Promise<ApiCacheItem | undefined>, setListener: (key: string, value: ApiCacheItem) => Promise<boolean>, removeListener: (key: string) => Promise<boolean>, cacheStepAgeClearOld?: number): void;
33
- /**
34
- * Resets the cache by clearing all in-memory items and resetting listeners.
35
- *
36
- * Сбрасывает кэш, очищая все элементы в памяти и сбрасывая слушатели.
37
- * @returns void / ничего не возвращает
38
- */
39
- static reset(): void;
40
- /**
41
- * Gets data from cache.
42
- *
43
- * Получает данные из кэша.
44
- * @param key cache key / ключ кэша
45
- * @returns T | undefined / данные из кэша или undefined
46
- */
47
- static get<T>(key: string): Promise<T | undefined>;
48
- /**
49
- * Gets data from cache using fetch options.
50
- *
51
- * Получает данные из кэша с использованием опций fetch.
52
- * @param fetch fetch options / опции fetch
53
- * @returns T | undefined / данные из кэша или undefined
54
- */
55
- static getByFetch<T>(fetch: ApiFetch): Promise<T | undefined>;
56
- /**
57
- * Saves data to cache.
58
- *
59
- * Сохраняет данные в кэш.
60
- * @param key cache key / ключ кэша
61
- * @param value data to be stored / данные для хранения
62
- * @param age cache age in seconds / возраст кэша в секундах
63
- */
64
- static set<T>(key: string, value: T, age?: number): Promise<void>;
65
- /**
66
- * Saves data to cache using fetch options.
67
- *
68
- * Сохраняет данные в кэш с использованием опций fetch.
69
- * @param fetch fetch options / опции fetch
70
- * @param value data to be stored / данные для хранения
71
- * @returns Promise<void> / Promise без возвращаемого значения
72
- */
73
- static setByFetch<T>(fetch: ApiFetch, value: T): Promise<void>;
74
- /**
75
- * Removes data from cache.
76
- *
77
- * Удаляет данные из кэша.
78
- * @param key cache key / ключ кэша
79
- * @returns Promise<void> / Promise без возвращаемого значения
80
- */
81
- static remove(key: string): Promise<void>;
82
- /**
83
- * Checks if the cache is enabled.
84
- *
85
- * Проверяет, включен ли кэш.
86
- * @param fetch fetch options / опции fetch
87
- * @returns true if cache is enabled / true, если кэш включен
88
- */
89
- protected static isCache(fetch: ApiFetch): boolean;
90
- /**
91
- * Checks if cache item is still valid (not expired).
92
- *
93
- * Проверяет, действителен ли элемент кэша (не истек ли срок действия).
94
- * @param item cache item / элемент кэша
95
- */
96
- protected static isAge(item?: ApiCacheItem): boolean;
97
- /**
98
- * Checks if the key exists in the cache.
99
- *
100
- * Проверяет, существует ли ключ в кэше.
101
- * @param key cache key / ключ кэша
102
- * @returns true if key exists / true, если ключ существует
103
- */
104
- protected static isItem(key: string): boolean;
105
- /**
106
- * Generates cache key from fetch options.
107
- *
108
- * Генерирует ключ кэша из опций fetch.
109
- * @param fetch fetch options / опции fetch
110
- * @returns cache key string / строка ключа кэша (JSON.stringify)
111
- */
112
- protected static generateKey(fetch: ApiFetch): string;
113
- /**
114
- * Gets data from cache using listener.
115
- *
116
- * Получает данные из кэша с использованием слушателя.
117
- * @param key cache key / ключ кэша
118
- * @returns cache item or undefined / элемент кэша или undefined (если не существует или истек срок действия)
119
- */
120
- protected static getItemOrListener(key: string): Promise<ApiCacheItem | undefined>;
121
- /**
122
- * Gets list of cache items.
123
- *
124
- * Получает список элементов кэша.
125
- * @returns list of cache items / список элементов кэша
126
- */
127
- protected static getList(): ApiCacheList;
128
- /**
129
- * Saves data to cache using listener.
130
- *
131
- * Сохраняет данные в кэш с использованием слушателя.
132
- * @param key cache key / ключ кэша
133
- * @param value data to be stored / данные для хранения
134
- * @returns Promise<void> / ничего не возвращает
135
- */
136
- protected static setItemOrListener(key: string, value: ApiCacheItem): Promise<void>;
137
- /**
138
- * Removes data from cache using listener.
139
- *
140
- * Удаляет данные из кэша с использованием слушателя.
141
- * @param key cache key / ключ кэша
142
- * @returns Promise<void> / ничего не возвращает
143
- */
144
- protected static removeItemOrListener(key: string): Promise<void>;
145
- /**
146
- * Clears old in-memory cache data.
147
- *
148
- * Очищает старый кэш в памяти.
149
- * @returns Promise<void> / Promise без возвращаемого значения (удаляет устаревшие элементы из кэша)
150
- */
151
- protected static clearOld(): Promise<void>;
152
- }
@@ -1,79 +0,0 @@
1
- import { ApiStatus } from './ApiStatus';
2
- import { ApiErrorItem } from './ApiErrorItem';
3
- import { ApiData, ApiFetch, ApiPreparationEnd } from '../types/apiTypes';
4
- /**
5
- * Class for handling and processing data returned from an API request.
6
- *
7
- * Класс для обработки и подготовки данных, полученных в результате запроса к API.
8
- */
9
- export declare class ApiDataReturn<T = any> {
10
- protected readonly apiFetch: ApiFetch;
11
- protected readonly query: Response;
12
- protected readonly end: ApiPreparationEnd;
13
- protected readonly error?: ApiErrorItem | undefined;
14
- /**
15
- * Raw data received from the API/
16
- * Исходные данные, полученные от API
17
- */
18
- protected data?: ApiData<T>;
19
- /**
20
- * Processed data ready for use/
21
- * Обработанные данные, готовые к использованию
22
- */
23
- protected dataMod?: ApiData<T>;
24
- /**
25
- * Constructor for ApiDataReturn.
26
- *
27
- * Конструктор ApiDataReturn.
28
- * @param apiFetch API fetch configuration / конфигурация запроса API
29
- * @param query response object / объект ответа
30
- * @param end preparation end data / данные завершения подготовки
31
- * @param error error object / объект ошибки
32
- */
33
- constructor(apiFetch: ApiFetch, query: Response, end: ApiPreparationEnd, error?: ApiErrorItem | undefined);
34
- /**
35
- * Initializes the class by reading data from the response.
36
- *
37
- * Инициализирует класс, считывая данные из ответа.
38
- */
39
- init(): Promise<this>;
40
- /**
41
- * Returns processed data.
42
- *
43
- * Возвращает обработанные данные.
44
- */
45
- get(): ApiData<T>;
46
- /**
47
- * Returns processed data along with the status object.
48
- *
49
- * Возвращает обработанные данные вместе с объектом статуса.
50
- * @param status API status instance / экземпляр статуса API
51
- */
52
- getAndStatus(status: ApiStatus): ApiData<T>;
53
- /**
54
- * Returns raw data received from the API.
55
- *
56
- * Возвращает исходные данные, полученные от API.
57
- */
58
- getData(): ApiData<T> | undefined;
59
- /**
60
- * Reads and parses data from the response.
61
- *
62
- * Считывает и анализирует данные из ответа.
63
- */
64
- protected readData<T>(): Promise<ApiData<T>>;
65
- /**
66
- * Prepares and formats the raw data.
67
- *
68
- * Подготавливает и форматирует исходные данные.
69
- */
70
- protected initData(): ApiData<T>;
71
- /**
72
- * Initializes the result item and merges metadata (success, status, code, message) from raw data.
73
- *
74
- * Инициализирует результирующий объект и переносит метаданные (success, status, code, message) из исходных данных.
75
- * @param data raw response data / исходные данные ответа
76
- * @returns initialized data with metadata / инициализированные данные с метаданными
77
- */
78
- protected initItem(data: Record<string, any>): ApiData<T>;
79
- }
@@ -1,49 +0,0 @@
1
- import { ApiDefaultValue, ApiFetch } from '../types/apiTypes';
2
- /**
3
- * Class for working with default API request data.
4
- *
5
- * Класс для работы с данными запроса API по умолчанию.
6
- */
7
- export declare class ApiDefault {
8
- /** Default request data / Данные запроса по умолчанию */
9
- protected value?: ApiDefaultValue;
10
- /**
11
- * Checks if default request data exists.
12
- *
13
- * Проверяет, существуют ли данные запроса по умолчанию.
14
- * @returns true if default data exists / true, если данные по умолчанию существуют
15
- */
16
- is(): boolean;
17
- /**
18
- * Gets the default request data.
19
- *
20
- * Получает данные запроса по умолчанию.
21
- * @returns default request data or undefined / данные запроса по умолчанию или undefined
22
- */
23
- get(): Record<string, any> | undefined;
24
- /**
25
- * Adds default data to the request.
26
- *
27
- * Добавляет данные по умолчанию к запросу.
28
- * @param request request data / данные запроса
29
- * @returns merged request data / объединенные данные запроса
30
- */
31
- request(request: ApiFetch['request']): ApiFetch['request'];
32
- /**
33
- * Sets the default request data.
34
- *
35
- * Устанавливает данные запроса по умолчанию.
36
- * @param request default request data / данные запроса по умолчанию
37
- * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
38
- */
39
- set(request: ApiDefaultValue): this;
40
- /**
41
- * Adds default data to FormData request.
42
- *
43
- * Добавляет данные по умолчанию к запросу FormData.
44
- * @param request FormData request / запрос FormData
45
- * @param value default values / значения по умолчанию
46
- * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
47
- */
48
- protected addByFormData(request: FormData, value: ApiDefaultValue): this;
49
- }
@@ -1,39 +0,0 @@
1
- import { ApiErrorItem } from './ApiErrorItem';
2
- import { ApiErrorStorage } from './ApiErrorStorage';
3
- import { ApiErrorStorageItem, ApiMethodItem } from '../types/apiTypes';
4
- /**
5
- * Utility class for managing the API error storage and creating error items.
6
- * It provides a centralized way to access the error storage and wrap raw
7
- * responses into structured error items.
8
- *
9
- * Утилитарный класс для управления хранилищем ошибок API и создания элементов ошибок.
10
- * Обеспечивает централизованный способ доступа к хранилищу ошибок и оборачивания
11
- * сырых ответов в структурированные элементы ошибок.
12
- */
13
- export declare class ApiError {
14
- /**
15
- * Retrieves the singleton instance of the API error storage.
16
- *
17
- * Возвращает синглтон-экземпляр хранилища ошибок API.
18
- * @returns error storage instance / экземпляр хранилища ошибок
19
- */
20
- static getStorage(): ApiErrorStorage;
21
- /**
22
- * Adds an error item or a list of error items to the storage.
23
- *
24
- * Добавляет элемент ошибки или список элементов ошибок в хранилище.
25
- * @param item error item or list of error items / элемент ошибки или список элементов ошибок
26
- * @param url URL pattern or RegExp / шаблон URL или регулярное выражение
27
- * @param method HTTP method of the request / HTTP-метод запроса
28
- */
29
- static add(item: Partial<ApiErrorStorageItem> | Partial<ApiErrorStorageItem>[], url?: string | RegExp, method?: ApiMethodItem): void;
30
- /**
31
- * Creates an ApiErrorItem by matching the response against stored error criteria.
32
- *
33
- * Создает ApiErrorItem путем сопоставления ответа с сохраненными критериями ошибок.
34
- * @param method HTTP method of the request / HTTP-метод запроса
35
- * @param response raw Fetch response / сырой ответ Fetch
36
- * @returns structured error item / структурированный элемент ошибки
37
- */
38
- static getItem(method: ApiMethodItem, response: Response): Promise<ApiErrorItem>;
39
- }
@@ -1,70 +0,0 @@
1
- import { ApiErrorStorageItem, ApiMethodItem } from '../types/apiTypes';
2
- /**
3
- * Class for managing and extracting data from an API error response.
4
- * It encapsulates the request method, raw response, and identified error criteria,
5
- * providing unified methods to retrieve error codes, messages, and status.
6
- *
7
- * Класс для управления и извлечения данных из ответа об ошибке API.
8
- * Инкапсулирует метод запроса, сырой ответ и идентифицированные критерии ошибки,
9
- * предоставляя единые методы для получения кодов ошибок, сообщений и статуса.
10
- */
11
- export declare class ApiErrorItem {
12
- protected readonly method: ApiMethodItem;
13
- protected readonly response: Response;
14
- protected readonly error: ApiErrorStorageItem;
15
- /** Cached JSON response body / Кэшированное тело ответа JSON */
16
- protected jsonResponse: any | undefined;
17
- /**
18
- * Constructor for ApiErrorItem.
19
- *
20
- * Конструктор для ApiErrorItem.
21
- * @param method HTTP method used for the request / HTTP-метод, использованный для запроса
22
- * @param response raw Fetch response object / сырой объект ответа Fetch
23
- * @param error matched error item from storage (optional) / найденный элемент ошибки из хранилища (опционально)
24
- */
25
- constructor(method: ApiMethodItem, response: Response, error: ApiErrorStorageItem);
26
- /**
27
- * Returns the HTTP method used for the request.
28
- *
29
- * Возвращает HTTP-метод, использованный для запроса.
30
- * @returns HTTP method / HTTP-метод
31
- */
32
- getMethod(): ApiMethodItem;
33
- /**
34
- * Returns the raw Fetch response object.
35
- *
36
- * Возвращает сырой объект ответа Fetch.
37
- * @returns Fetch response / ответ Fetch
38
- */
39
- getResponse(): Response;
40
- /**
41
- * Returns the identified error item from storage if it exists.
42
- *
43
- * Возвращает идентифицированный элемент ошибки из хранилища, если он существует.
44
- * @returns error item or undefined / элемент ошибки или undefined
45
- */
46
- getError(): ApiErrorStorageItem;
47
- /**
48
- * Asynchronously retrieves the error code from storage or the response body.
49
- *
50
- * Асинхронно получает код ошибки из хранилища или тела ответа.
51
- * @returns error code or undefined / код ошибки или undefined
52
- */
53
- getCode(): string | undefined;
54
- /**
55
- * Asynchronously retrieves the error message.
56
- * Checks the identified error item, the response body, or falls back to status text.
57
- *
58
- * Асинхронно получает сообщение об ошибке.
59
- * Проверяет идентифицированный элемент ошибки, тело ответа или использует текст статуса.
60
- * @returns error message or undefined / сообщение об ошибке или undefined
61
- */
62
- getMessage(): string | undefined;
63
- /**
64
- * Returns the HTTP status code of the response.
65
- *
66
- * Возвращает код статуса HTTP ответа.
67
- * @returns status code / код статуса
68
- */
69
- getStatus(): number;
70
- }