@dxtmisha/functional-basic 1.1.5 → 1.1.6

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 (178) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/ai-description.txt +1 -0
  3. package/ai-types.txt +1055 -951
  4. package/dist/classes/Api.d.ts +201 -0
  5. package/dist/classes/ApiCache.d.ts +152 -0
  6. package/dist/classes/ApiDataReturn.d.ts +76 -0
  7. package/dist/classes/ApiDefault.d.ts +49 -0
  8. package/dist/classes/ApiHeaders.d.ts +37 -0
  9. package/dist/classes/ApiHydration.d.ts +39 -0
  10. package/dist/classes/ApiInstance.d.ts +283 -0
  11. package/dist/classes/ApiPreparation.d.ts +58 -0
  12. package/dist/classes/ApiResponse.d.ts +154 -0
  13. package/dist/classes/ApiStatus.d.ts +130 -0
  14. package/dist/classes/BroadcastMessage.d.ts +75 -0
  15. package/dist/classes/Cache.d.ts +38 -0
  16. package/dist/classes/CacheItem.d.ts +62 -0
  17. package/dist/classes/CacheStatic.d.ts +36 -0
  18. package/dist/classes/Cookie.d.ts +54 -0
  19. package/dist/classes/CookieBlock.d.ts +30 -0
  20. package/dist/classes/CookieBlockInstance.d.ts +23 -0
  21. package/dist/classes/CookieStorage.d.ts +174 -0
  22. package/dist/classes/DataStorage.d.ts +107 -0
  23. package/dist/classes/Datetime.d.ts +570 -0
  24. package/dist/classes/ErrorCenter.d.ts +72 -0
  25. package/dist/classes/ErrorCenterHandler.d.ts +64 -0
  26. package/dist/classes/ErrorCenterInstance.d.ts +85 -0
  27. package/dist/classes/EventItem.d.ts +251 -0
  28. package/dist/classes/Formatters.d.ts +161 -0
  29. package/dist/classes/Geo.d.ts +151 -0
  30. package/dist/classes/GeoFlag.d.ts +98 -0
  31. package/dist/classes/GeoInstance.d.ts +215 -0
  32. package/dist/classes/GeoIntl.d.ts +304 -0
  33. package/dist/classes/GeoPhone.d.ts +108 -0
  34. package/dist/classes/Global.d.ts +29 -0
  35. package/dist/classes/Hash.d.ts +57 -0
  36. package/dist/classes/HashInstance.d.ts +95 -0
  37. package/dist/classes/Icons.d.ts +128 -0
  38. package/dist/classes/Loading.d.ts +66 -0
  39. package/dist/classes/LoadingInstance.d.ts +99 -0
  40. package/dist/classes/Meta.d.ts +186 -0
  41. package/dist/classes/MetaManager.d.ts +121 -0
  42. package/dist/classes/MetaOg.d.ts +115 -0
  43. package/dist/classes/MetaStatic.d.ts +179 -0
  44. package/dist/classes/MetaTwitter.d.ts +115 -0
  45. package/dist/classes/ResumableTimer.d.ts +81 -0
  46. package/dist/classes/ScrollbarWidth.d.ts +51 -0
  47. package/dist/classes/SearchList.d.ts +128 -0
  48. package/dist/classes/SearchListData.d.ts +143 -0
  49. package/dist/classes/SearchListItem.d.ts +49 -0
  50. package/dist/classes/SearchListMatcher.d.ts +57 -0
  51. package/dist/classes/SearchListOptions.d.ts +66 -0
  52. package/dist/classes/ServerStorage.d.ts +106 -0
  53. package/dist/classes/StorageCallback.d.ts +84 -0
  54. package/dist/classes/Translate.d.ts +119 -0
  55. package/dist/classes/TranslateFile.d.ts +81 -0
  56. package/dist/classes/TranslateInstance.d.ts +206 -0
  57. package/dist/functions/addTagHighlightMatch.d.ts +11 -0
  58. package/dist/functions/anyToString.d.ts +10 -0
  59. package/dist/functions/applyTemplate.d.ts +10 -0
  60. package/dist/functions/arrFill.d.ts +9 -0
  61. package/dist/functions/blobToBase64.d.ts +9 -0
  62. package/dist/functions/capitalize.d.ts +9 -0
  63. package/dist/functions/copyObject.d.ts +10 -0
  64. package/dist/functions/copyObjectLite.d.ts +9 -0
  65. package/dist/functions/createElement.d.ts +21 -0
  66. package/dist/functions/domQuerySelector.d.ts +8 -0
  67. package/dist/functions/domQuerySelectorAll.d.ts +8 -0
  68. package/dist/functions/encodeAttribute.d.ts +8 -0
  69. package/dist/functions/encodeLiteAttribute.d.ts +8 -0
  70. package/dist/functions/ensureMaxSize.d.ts +10 -0
  71. package/dist/functions/escapeExp.d.ts +7 -0
  72. package/dist/functions/eventStopPropagation.d.ts +7 -0
  73. package/dist/functions/executeFunction.d.ts +12 -0
  74. package/dist/functions/executePromise.d.ts +11 -0
  75. package/dist/functions/forEach.d.ts +14 -0
  76. package/dist/functions/frame.d.ts +10 -0
  77. package/dist/functions/getArrayHighlightMatch.d.ts +10 -0
  78. package/dist/functions/getAttributes.d.ts +9 -0
  79. package/dist/functions/getClipboardData.d.ts +9 -0
  80. package/dist/functions/getColumn.d.ts +10 -0
  81. package/dist/functions/getCurrentDate.d.ts +19 -0
  82. package/dist/functions/getCurrentTime.d.ts +15 -0
  83. package/dist/functions/getElement.d.ts +9 -0
  84. package/dist/functions/getElementId.d.ts +26 -0
  85. package/dist/functions/getElementImage.d.ts +8 -0
  86. package/dist/functions/getElementItem.d.ts +12 -0
  87. package/dist/functions/getElementOrWindow.d.ts +8 -0
  88. package/dist/functions/getElementSafeScript.d.ts +9 -0
  89. package/dist/functions/getExactSearchExp.d.ts +8 -0
  90. package/dist/functions/getExp.d.ts +14 -0
  91. package/dist/functions/getHydrationData.d.ts +10 -0
  92. package/dist/functions/getItemByPath.d.ts +9 -0
  93. package/dist/functions/getKey.d.ts +8 -0
  94. package/dist/functions/getLengthOfAllArray.d.ts +8 -0
  95. package/dist/functions/getMaxLengthAllArray.d.ts +9 -0
  96. package/dist/functions/getMinLengthAllArray.d.ts +8 -0
  97. package/dist/functions/getMouseClient.d.ts +9 -0
  98. package/dist/functions/getMouseClientX.d.ts +8 -0
  99. package/dist/functions/getMouseClientY.d.ts +8 -0
  100. package/dist/functions/getObjectByKeys.d.ts +8 -0
  101. package/dist/functions/getObjectNoUndefined.d.ts +9 -0
  102. package/dist/functions/getObjectOrNone.d.ts +8 -0
  103. package/dist/functions/getOnlyText.d.ts +8 -0
  104. package/dist/functions/getRandomText.d.ts +12 -0
  105. package/dist/functions/getRequestString.d.ts +11 -0
  106. package/dist/functions/getSearchExp.d.ts +12 -0
  107. package/dist/functions/getSeparatingSearchExp.d.ts +9 -0
  108. package/dist/functions/getStepPercent.d.ts +9 -0
  109. package/dist/functions/getStepValue.d.ts +9 -0
  110. package/dist/functions/goScroll.d.ts +10 -0
  111. package/dist/functions/goScrollSmooth.d.ts +10 -0
  112. package/dist/functions/goScrollTo.d.ts +10 -0
  113. package/dist/functions/handleShare.d.ts +10 -0
  114. package/dist/functions/inArray.d.ts +9 -0
  115. package/dist/functions/initScrollbarOffset.d.ts +7 -0
  116. package/dist/functions/intersectKey.d.ts +9 -0
  117. package/dist/functions/isApiSuccess.d.ts +9 -0
  118. package/dist/functions/isArray.d.ts +8 -0
  119. package/dist/functions/isDifferent.d.ts +10 -0
  120. package/dist/functions/isDomData.d.ts +7 -0
  121. package/dist/functions/isDomRuntime.d.ts +10 -0
  122. package/dist/functions/isElementVisible.d.ts +11 -0
  123. package/dist/functions/isEnter.d.ts +9 -0
  124. package/dist/functions/isFilled.d.ts +10 -0
  125. package/dist/functions/isFloat.d.ts +8 -0
  126. package/dist/functions/isFunction.d.ts +9 -0
  127. package/dist/functions/isInDom.d.ts +9 -0
  128. package/dist/functions/isInput.d.ts +8 -0
  129. package/dist/functions/isIntegerBetween.d.ts +9 -0
  130. package/dist/functions/isNull.d.ts +9 -0
  131. package/dist/functions/isNumber.d.ts +8 -0
  132. package/dist/functions/isObject.d.ts +8 -0
  133. package/dist/functions/isObjectNotArray.d.ts +8 -0
  134. package/dist/functions/isOnLine.d.ts +7 -0
  135. package/dist/functions/isSelected.d.ts +9 -0
  136. package/dist/functions/isSelectedByList.d.ts +9 -0
  137. package/dist/functions/isShare.d.ts +7 -0
  138. package/dist/functions/isString.d.ts +8 -0
  139. package/dist/functions/isWindow.d.ts +7 -0
  140. package/dist/functions/random.d.ts +9 -0
  141. package/dist/functions/removeCommonPrefix.d.ts +9 -0
  142. package/dist/functions/replaceComponentName.d.ts +9 -0
  143. package/dist/functions/replaceRecursive.d.ts +11 -0
  144. package/dist/functions/replaceTemplate.d.ts +10 -0
  145. package/dist/functions/resizeImageByMax.d.ts +19 -0
  146. package/dist/functions/secondToTime.d.ts +9 -0
  147. package/dist/functions/setElementItem.d.ts +11 -0
  148. package/dist/functions/setValues.d.ts +18 -0
  149. package/dist/functions/sleep.d.ts +8 -0
  150. package/dist/functions/splice.d.ts +13 -0
  151. package/dist/functions/strFill.d.ts +9 -0
  152. package/dist/functions/strSplit.d.ts +12 -0
  153. package/dist/functions/toArray.d.ts +17 -0
  154. package/dist/functions/toCamelCase.d.ts +8 -0
  155. package/dist/functions/toCamelCaseFirst.d.ts +8 -0
  156. package/dist/functions/toDate.d.ts +8 -0
  157. package/dist/functions/toKebabCase.d.ts +15 -0
  158. package/dist/functions/toNumber.d.ts +19 -0
  159. package/dist/functions/toNumberByMax.d.ts +11 -0
  160. package/dist/functions/toPercent.d.ts +9 -0
  161. package/dist/functions/toPercentBy100.d.ts +9 -0
  162. package/dist/functions/toString.d.ts +8 -0
  163. package/dist/functions/transformation.d.ts +21 -0
  164. package/dist/functions/uint8ArrayToBase64.d.ts +8 -0
  165. package/dist/functions/uniqueArray.d.ts +8 -0
  166. package/dist/functions/writeClipboardData.d.ts +8 -0
  167. package/dist/library.d.ts +171 -8891
  168. package/dist/library.js +5 -5
  169. package/dist/media/errorCauseList.d.ts +2 -0
  170. package/dist/types/apiTypes.d.ts +217 -0
  171. package/dist/types/basicTypes.d.ts +131 -0
  172. package/dist/types/errorCenter.d.ts +42 -0
  173. package/dist/types/formattersTypes.d.ts +224 -0
  174. package/dist/types/geoTypes.d.ts +86 -0
  175. package/dist/types/metaTypes.d.ts +586 -0
  176. package/dist/types/searchTypes.d.ts +53 -0
  177. package/dist/types/translateTypes.d.ts +54 -0
  178. package/package.json +5 -4
@@ -0,0 +1,283 @@
1
+ import { LoadingInstance } from './LoadingInstance';
2
+ import { ErrorCenterInstance } from './ErrorCenterInstance';
3
+ import { ApiDefault } from './ApiDefault';
4
+ import { ApiHeaders } from './ApiHeaders';
5
+ import { ApiHydration } from './ApiHydration';
6
+ import { ApiPreparation } from './ApiPreparation';
7
+ import { ApiStatus } from './ApiStatus';
8
+ import { ApiResponse } from './ApiResponse';
9
+ import { ApiFetch, ApiMethod, ApiPreparationEnd } from '../types/apiTypes';
10
+ /** Options for the API instance / Опции для экземпляра API */
11
+ export type ApiInstanceOptions = {
12
+ /** Class for working with headers / Класс для работы с заголовками */
13
+ headersClass?: typeof ApiHeaders;
14
+ /** Class for working with default request parameters / Класс для работы с параметрами запроса по умолчанию */
15
+ requestDefaultClass?: typeof ApiDefault;
16
+ /** Class for working with status / Класс для работы со статусом */
17
+ statusClass?: typeof ApiStatus;
18
+ /** Class for working with response / Класс для работы с ответом */
19
+ responseClass?: typeof ApiResponse;
20
+ /** Class for working with preparation / Класс для работы с модификацией запроса */
21
+ preparationClass?: typeof ApiPreparation;
22
+ /** Instance of loading handler / Экземпляр обработчика загрузки */
23
+ loadingClass?: LoadingInstance;
24
+ /** Instance of error handler / Экземпляр обработчика ошибок */
25
+ errorCenterClass?: ErrorCenterInstance;
26
+ /** Class for working with hydration / Класс для работы с гидратацией */
27
+ hydrationClass?: typeof ApiHydration;
28
+ };
29
+ /**
30
+ * Core class for managing HTTP requests using the Fetch API.
31
+ *
32
+ * Основной класс для управления HTTP-запросами через Fetch API.
33
+ */
34
+ export declare class ApiInstance {
35
+ protected url: string;
36
+ /** Headers / Заголовки */
37
+ protected headers: ApiHeaders;
38
+ /** Default request parameters / Параметры запроса по умолчанию */
39
+ protected requestDefault: ApiDefault;
40
+ /** Status of the last request / Статус последнего запроса */
41
+ protected status: ApiStatus;
42
+ /** Response handler / Обработчик ответа */
43
+ protected response: ApiResponse;
44
+ /** Request modification handler / Обработчик модификации запроса */
45
+ protected preparation: ApiPreparation;
46
+ /** Loading handler / Обработчик загрузки */
47
+ protected loading: LoadingInstance;
48
+ /** Error handler / Обработчик ошибок */
49
+ protected errorCenter: ErrorCenterInstance;
50
+ /** Hydration handler / Обработчик гидратации */
51
+ protected hydration: ApiHydration;
52
+ /** Timeout for the request in milliseconds / Таймаут запроса в миллисекундах */
53
+ protected timeout: number;
54
+ protected origin?: string;
55
+ /**
56
+ * Constructor
57
+ * @param url base path to the script / базовый путь к скрипту
58
+ * @param options options for the API instance / опции для экземпляра API
59
+ */
60
+ constructor(url?: string, options?: ApiInstanceOptions);
61
+ /**
62
+ * Checks if the server is running on localhost.
63
+ *
64
+ * Проверяет, работает ли сервер на localhost.
65
+ * @returns true if server is localhost / true, если сервер является локальным
66
+ */
67
+ isLocalhost(): boolean;
68
+ /**
69
+ * Returns the status of the last request.
70
+ *
71
+ * Возвращает статус последнего запроса.
72
+ * @returns ApiStatus instance / экземпляр ApiStatus
73
+ */
74
+ getStatus(): ApiStatus;
75
+ /**
76
+ * Gets the response handler.
77
+ *
78
+ * Получает обработчик ответа.
79
+ * @returns ApiResponse instance / экземпляр ApiResponse
80
+ */
81
+ getResponse(): ApiResponse;
82
+ /**
83
+ * Gets the hydration handler.
84
+ *
85
+ * Получает обработчик гидратации.
86
+ * @returns ApiHydration instance / экземпляр ApiHydration
87
+ */
88
+ getHydration(): ApiHydration;
89
+ /**
90
+ * Gets the base origin URL combined with the API path.
91
+ *
92
+ * Получает базовый URL источника, объединенный с путем API.
93
+ * @returns final base URL string / итоговая строка базового URL
94
+ */
95
+ getOrigin(): string;
96
+ /**
97
+ * Gets the full path to the request script.
98
+ *
99
+ * Получает полный путь к скрипту запроса.
100
+ * @param path path to the script / путь к скрипту
101
+ * @param api whether to prepend base API URL / нужно ли добавить базовый URL API
102
+ * @returns full URL / полный URL
103
+ */
104
+ getUrl(path: string, api?: boolean): string;
105
+ /**
106
+ * Gets data for the request body.
107
+ *
108
+ * Получает данные для тела запроса.
109
+ * @param request request data / данные запроса
110
+ * @param method HTTP method / HTTP метод
111
+ * @returns body data for non-GET requests or FormData / данные тела для не-GET запросов или FormData
112
+ */
113
+ getBody(request?: ApiFetch['request'], method?: ApiMethod): string | FormData | undefined;
114
+ /**
115
+ * Gets query string for GET method requests.
116
+ *
117
+ * Получает строку запроса для GET-методов.
118
+ * @param request request data / данные запроса
119
+ * @param path path to request / путь к запросу
120
+ * @param method HTTP method / HTTP метод
121
+ * @returns query string with prefix (? or &) / строка запроса с префиксом (? или &)
122
+ */
123
+ getBodyForGet(request: ApiFetch['request'], path?: string, method?: ApiMethod): string;
124
+ /**
125
+ * Returns a string representation of the hydration data for the client.
126
+ *
127
+ * Возвращает строковое представление данных гидратации для клиента.
128
+ * @returns HTML script element string / строка HTML элемента script
129
+ */
130
+ getHydrationScript(): string;
131
+ /**
132
+ * Modifies the default header data.
133
+ *
134
+ * Изменяет данные заголовка по умолчанию.
135
+ * @param headers default headers / заголовки по умолчанию
136
+ */
137
+ setHeaders(headers: Record<string, string>): this;
138
+ /**
139
+ * Modifies the default request data.
140
+ *
141
+ * Изменяет данные запроса по умолчанию.
142
+ * @param request default request data / данные запроса по умолчанию
143
+ */
144
+ setRequestDefault(request: Record<string, any>): this;
145
+ /**
146
+ * Changes the base path to the script.
147
+ *
148
+ * Изменяет базовый путь к скрипту.
149
+ * @param url path to the script / путь к скрипту
150
+ */
151
+ setUrl(url: string): this;
152
+ /**
153
+ * Modifies the function to be called before the request.
154
+ *
155
+ * Изменяет функцию для вызова перед запросом.
156
+ * @param callback function to call before request / функция для вызова перед запросом
157
+ */
158
+ setPreparation(callback: (apiFetch: ApiFetch) => Promise<void>): this;
159
+ /**
160
+ * Modifies the function to be called after the request.
161
+ *
162
+ * Изменяет функцию для вызова после запроса.
163
+ * @param callback function to call after request / функция для вызова после запроса
164
+ */
165
+ setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): this;
166
+ /**
167
+ * Changes the timeout for the request in milliseconds.
168
+ *
169
+ * Изменяет таймаут запроса в миллисекундах.
170
+ * @param timeout timeout in milliseconds / таймаут в миллисекундах
171
+ */
172
+ setTimeout(timeout: number): this;
173
+ /**
174
+ * Changes the origin (protocol and domain) for the base URL.
175
+ *
176
+ * Изменяет источник (протокол и домен) для базового URL.
177
+ * @param origin protocol and domain / протокол и домен
178
+ */
179
+ setOrigin(origin: string): this;
180
+ /**
181
+ * Executes a request with the given path or configuration.
182
+ *
183
+ * Выполняет запрос с указанным путем или конфигурацией.
184
+ * @param pathRequest path or configuration / путь или конфигурация запроса
185
+ * @returns Promise with response data / Promise с данными ответа
186
+ */
187
+ request<T>(pathRequest: string | ApiFetch): Promise<T>;
188
+ /**
189
+ * Sends a GET method request.
190
+ *
191
+ * Отправляет запрос метода GET.
192
+ * @param request fetch configuration / конфигурация запроса
193
+ * @returns Promise with response data / Promise с данными ответа
194
+ */
195
+ get<T>(request: ApiFetch): Promise<T>;
196
+ /**
197
+ * Sends a POST method request.
198
+ *
199
+ * Отправляет запрос метода POST.
200
+ * @param request fetch configuration / конфигурация запроса
201
+ * @returns Promise with response data / Promise с данными ответа
202
+ */
203
+ post<T>(request: ApiFetch): Promise<T>;
204
+ /**
205
+ * Sends a PUT method request.
206
+ *
207
+ * Отправляет запрос метода PUT.
208
+ * @param request fetch configuration / конфигурация запроса
209
+ * @returns Promise with response data / Promise с данными ответа
210
+ */
211
+ put<T>(request: ApiFetch): Promise<T>;
212
+ /**
213
+ * Sends a PATCH method request.
214
+ *
215
+ * Отправляет запрос метода PATCH.
216
+ * @param request fetch configuration / конфигурация запроса
217
+ * @returns Promise with response data / Promise с данными ответа
218
+ */
219
+ patch<T>(request: ApiFetch): Promise<T>;
220
+ /**
221
+ * Sends a DELETE method request.
222
+ *
223
+ * Отправляет запрос метода DELETE.
224
+ * @param request fetch configuration / конфигурация запроса
225
+ * @returns Promise with response data / Promise с данными ответа
226
+ */
227
+ delete<T>(request: ApiFetch): Promise<T>;
228
+ /**
229
+ * Gets retry delay with jitter.
230
+ *
231
+ * Получает задержку повтора с джиттером.
232
+ * @param retryCount count of retries / количество повторов
233
+ * @param retryDelay base delay between retries / базовая задержка между повторами
234
+ * @returns delay in milliseconds / задержка в миллисекундах
235
+ */
236
+ protected getRetryDelay(retryCount: number, retryDelay: number): number;
237
+ /**
238
+ * Execute API request with retry support.
239
+ *
240
+ * Выполнить запрос API с поддержкой повторов.
241
+ * @param apiFetch fetch configuration / конфигурация запроса
242
+ * @param retryCount current retry count / текущий счетчик повторов
243
+ */
244
+ protected fetch<T>(apiFetch: ApiFetch, retryCount?: number): Promise<T>;
245
+ /**
246
+ * Executing the HTTP request.
247
+ *
248
+ * Выполнение HTTP-запроса.
249
+ * @param apiFetch fetch configuration / конфигурация запроса
250
+ * @param pathToApi base path to API / базовый путь к API
251
+ * @returns object containing response and optional timeout ID / объект, содержащий ответ и опциональный ID таймера
252
+ */
253
+ protected makeQuery(apiFetch: ApiFetch, pathToApi: string): Promise<{
254
+ query: Response;
255
+ timeoutId: any;
256
+ }>;
257
+ /**
258
+ * Processing an error.
259
+ *
260
+ * Обработка ошибки.
261
+ * @param error error object / объект ошибки
262
+ * @param group error group for error center (default: 'api') / группа ошибки для центра ошибок (по умолчанию: 'api')
263
+ */
264
+ protected makeError(error: Record<string, any> & {
265
+ name: string;
266
+ }, group?: string): void;
267
+ /**
268
+ * Processes an error response.
269
+ *
270
+ * Обрабатывает ошибку ответа.
271
+ * @param query error response / ответ с ошибкой
272
+ */
273
+ protected makeErrorQuery(query: Response): void;
274
+ /**
275
+ * Initialize controller for request with timeout support.
276
+ *
277
+ * Инициализация контроллера для запроса с поддержкой таймаута.
278
+ * @param apiFetch request options / опции запроса
279
+ * @param fetchInit request initialization object / объект инициализации запроса
280
+ * @returns timeout ID (from setTimeout) or undefined / ID таймера (от setTimeout) или undefined
281
+ */
282
+ protected initController(apiFetch: ApiFetch, fetchInit: RequestInit): any;
283
+ }
@@ -0,0 +1,58 @@
1
+ import { ApiFetch, ApiPreparationEnd } from '../types/apiTypes';
2
+ /**
3
+ * Class for preparing requests.
4
+ *
5
+ * Класс для подготовки запросов.
6
+ */
7
+ export declare class ApiPreparation {
8
+ /** Function for call before the request / Функция для вызова перед запросом */
9
+ protected callback?: (apiFetch: ApiFetch) => Promise<void>;
10
+ /** Function for call after the request / Функция для вызова после запроса */
11
+ protected callbackEnd?: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>;
12
+ /** Is the preparation in progress / Идет ли подготовка */
13
+ protected loading: boolean;
14
+ /**
15
+ * Executes preparation before the request.
16
+ *
17
+ * Выполняет подготовку перед выполнением запроса.
18
+ * @param active is preparation active / активна ли подготовка
19
+ * @param apiFetch request options / опции запроса
20
+ * @returns Promise<void> / Promise без возвращаемого значения
21
+ */
22
+ make(active: boolean, apiFetch: ApiFetch): Promise<void>;
23
+ /**
24
+ * Analyzes the request after execution.
25
+ *
26
+ * Анализирует запрос после выполнения.
27
+ * @param active is preparation active / активна ли подготовка
28
+ * @param query data received in the request / данные, полученные в запросе
29
+ * @param apiFetch request options / опции запроса
30
+ * @returns preparation end data / данные завершения подготовки
31
+ */
32
+ makeEnd(active: boolean, query: Response, apiFetch: ApiFetch): Promise<ApiPreparationEnd>;
33
+ /**
34
+ * Modifies the function to be called before the request.
35
+ *
36
+ * Изменяет функцию для вызова перед запросом.
37
+ * @param callback function to call before request / функция для вызова перед запросом
38
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
39
+ */
40
+ set(callback: (apiFetch: ApiFetch) => Promise<void>): this;
41
+ /**
42
+ * Modifies the function to be called after the request.
43
+ *
44
+ * Изменяет функцию для вызова после запроса.
45
+ * @param callback function to call after request / функция для вызова после запроса
46
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
47
+ */
48
+ setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): this;
49
+ /**
50
+ * To execute preparation.
51
+ *
52
+ * Выполнить подготовку.
53
+ * @param apiFetch request options / опции запроса
54
+ * @param limit limit of retry attempts / лимит попыток повтора
55
+ * @returns Promise<void> / Promise без возвращаемого значения
56
+ */
57
+ protected go(apiFetch: ApiFetch, limit?: number): Promise<void>;
58
+ }
@@ -0,0 +1,154 @@
1
+ import { ApiDefault } from './ApiDefault';
2
+ import { ApiFetch, ApiMethod, ApiResponseItem } from '../types/apiTypes';
3
+ /**
4
+ * Class for working with API responses.
5
+ *
6
+ * Класс для работы с ответами API.
7
+ */
8
+ export declare class ApiResponse {
9
+ protected readonly requestDefault: ApiDefault;
10
+ /** List of first-time API requests / Список первичных API запросов */
11
+ protected readonly first: ApiResponseItem[];
12
+ /** Cached responses / Кешированные ответы */
13
+ protected readonly response: ApiResponseItem[];
14
+ /** Loading instance / Экземпляр загрузки */
15
+ protected loading?: any;
16
+ /** Developer mode flag / Флаг режима разработчика */
17
+ protected devMode: boolean;
18
+ /**
19
+ * Constructor
20
+ * @param requestDefault default request class/ класс запросов по умолчанию
21
+ */
22
+ constructor(requestDefault: ApiDefault);
23
+ /**
24
+ * Checks if there is a global cached request, if there is, returns it.
25
+ *
26
+ * Проверяет, есть ли глобальный кешированный запрос, если есть, возвращает его.
27
+ * @param path link to the request / ссылка на запрос
28
+ * @param method request method / метод запроса
29
+ * @param request data for the request / данные для запроса
30
+ * @param devMode optional developer mode flag / необязательный флаг режима разработчика
31
+ * @returns cached response item or undefined / кешированный элемент ответа или undefined
32
+ */
33
+ get(path: string | undefined, method: ApiMethod, request?: ApiFetch['request'], devMode?: boolean): ApiResponseItem | undefined;
34
+ /**
35
+ * Returns a list of cached API responses (excluding global responses).
36
+ *
37
+ * Возвращает список кешированных ответов API (исключая глобальные ответы).
38
+ */
39
+ getList(): (ApiResponseItem & Record<string, any>)[];
40
+ /**
41
+ * Adds cached requests.
42
+ *
43
+ * Добавляет кешированные запросы.
44
+ * @param response data for caching / данные для кеширования
45
+ */
46
+ add(response: ApiResponseItem | ApiResponseItem[]): this;
47
+ /**
48
+ * Sets developer mode.
49
+ *
50
+ * Устанавливает режим разработчика.
51
+ * @param devMode is it developer mode / является ли режим разработчика
52
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
53
+ */
54
+ setDevMode(devMode: boolean): this;
55
+ /**
56
+ * Executes the emulator if available.
57
+ *
58
+ * Выполняет эмулятор, если доступно.
59
+ * @param apiFetch fetch configuration / конфигурация запроса
60
+ * @returns emulated response or undefined / эмулированный ответ или undefined
61
+ */
62
+ emulator<T>(apiFetch: ApiFetch): Promise<T | undefined>;
63
+ /**
64
+ * Executes the emulator synchronously if available.
65
+ *
66
+ * Выполняет эмулятор синхронно, если доступно.
67
+ * @param apiFetch fetch configuration / конфигурация запроса
68
+ * @returns emulated response or undefined / эмулированный ответ или undefined
69
+ */
70
+ emulatorAsync<T>(apiFetch: ApiFetch): T | undefined;
71
+ /**
72
+ * Checks if the cached item is disabled.
73
+ *
74
+ * Проверяет, отключен ли кешированный элемент.
75
+ * @param item cached item / кешированный элемент
76
+ * @returns true if item is disabled / true, если элемент отключен
77
+ */
78
+ protected isDisable(item: ApiResponseItem): boolean;
79
+ /**
80
+ * Checks if the path matches the cached one.
81
+ *
82
+ * Проверяет, совпадает ли путь с кешированным.
83
+ * @param item cached item / кешированный элемент
84
+ * @param path request path / путь запроса
85
+ * @returns true if paths match / true, если пути совпадают
86
+ */
87
+ protected isPath(item: ApiResponseItem, path: string): boolean;
88
+ /**
89
+ * Checks if it is developer mode.
90
+ *
91
+ * Проверяет, является ли режимом разработчика.
92
+ * @param devMode is it developer mode / является ли режим разработчика
93
+ * @returns true if in dev mode / true, если в режиме разработчика
94
+ */
95
+ protected isDevMode(devMode?: boolean): boolean;
96
+ /**
97
+ * Checks if this is the first request.
98
+ *
99
+ * Проверяет, является ли это первым запросом.
100
+ * @param item cached item / кешированный элемент
101
+ * @param devMode is it developer mode / является ли режим разработчика
102
+ * @returns true if this is the first request / true, если это первый запрос
103
+ */
104
+ protected isFirst(item: ApiResponseItem, devMode?: boolean): boolean;
105
+ /**
106
+ * Checks if the request matches the cached one.
107
+ *
108
+ * Проверяет, совпадает ли запрос с кешированным.
109
+ * @param item cached item / кешированный элемент
110
+ * @param request request data / данные запроса
111
+ * @returns true if requests match / true, если запросы совпадают
112
+ */
113
+ protected isResponse(item: ApiResponseItem, request?: ApiFetch['request']): boolean;
114
+ /**
115
+ * Reads cached data configuration.
116
+ *
117
+ * Считывает конфигурацию кешированных данных.
118
+ * @param apiFetch fetch configuration / конфигурация запроса
119
+ * @returns object with response and request data or undefined / объект с данными ответа и запроса или undefined
120
+ */
121
+ protected readData(apiFetch: ApiFetch): {
122
+ response: ApiResponseItem;
123
+ request: string | Record<string, any> | FormData | undefined;
124
+ } | undefined;
125
+ /**
126
+ * Emulates an execution request (internal fetch).
127
+ *
128
+ * Эмулирует запрос выполнения (внутренний fetch).
129
+ * @param response response item for emulation / элемент ответа для эмуляции
130
+ * @param request data for the request / данные для запроса
131
+ * @returns Promise with emulated response data / Promise с эмулированными данными ответа
132
+ */
133
+ protected fetch<T>(response: ApiResponseItem, request?: ApiFetch['request']): Promise<T>;
134
+ /**
135
+ * Emulates an execution request synchronously (internal fetch).
136
+ *
137
+ * Эмулирует запрос выполнения синхронно (внутренний fetch).
138
+ * @param response response item for emulation / элемент ответа для эмуляции
139
+ * @returns emulated response data / эмулированные данные ответа
140
+ */
141
+ protected fetchAsync<T>(response: ApiResponseItem): T;
142
+ /**
143
+ * Enables loading for request emulation.
144
+ *
145
+ * Включает загрузку для эмуляции запроса.
146
+ */
147
+ protected startResponseLoading(): void;
148
+ /**
149
+ * Disables loading for request emulation.
150
+ *
151
+ * Отключает загрузку для эмуляции запроса.
152
+ */
153
+ protected stopResponseLoading(): void;
154
+ }
@@ -0,0 +1,130 @@
1
+ import { ApiStatusItem, ApiStatusType } from '../types/apiTypes';
2
+ /**
3
+ * Class for managing API request status.
4
+ *
5
+ * Класс для управления статусом запросов API.
6
+ */
7
+ export declare class ApiStatus {
8
+ protected value?: ApiStatusItem;
9
+ /**
10
+ * Returns the last status item data.
11
+ *
12
+ * Возвращает данные последнего элемента статуса.
13
+ * @returns status item or undefined / элемент статуса или undefined
14
+ */
15
+ get(): ApiStatusItem | undefined;
16
+ /**
17
+ * Returns the execution status code.
18
+ *
19
+ * Возвращает код статуса выполнения.
20
+ * @returns HTTP status code or undefined / код статуса HTTP или undefined
21
+ */
22
+ getStatus(): number | undefined;
23
+ /**
24
+ * Returns the execution status text.
25
+ *
26
+ * Возвращает текст статуса выполнения.
27
+ * @returns status text or undefined / текст статуса или undefined
28
+ */
29
+ getStatusText(): string | undefined;
30
+ /**
31
+ * Returns the last status type.
32
+ *
33
+ * Возвращает последний тип статуса.
34
+ * @returns status type or undefined / тип статуса или undefined
35
+ */
36
+ getStatusType(): ApiStatusType | undefined;
37
+ /**
38
+ * Returns the execution status code (string or number from response).
39
+ *
40
+ * Возвращает код статуса выполнения (строка или число из ответа).
41
+ * @returns status code or undefined / код статуса или undefined
42
+ */
43
+ getCode(): string | undefined;
44
+ /**
45
+ * Returns the script execution error.
46
+ *
47
+ * Возвращает ошибку выполнения скрипта.
48
+ * @returns error message or undefined / сообщение об ошибке или undefined
49
+ */
50
+ getError(): string | undefined;
51
+ /**
52
+ * Returns the data of the last request.
53
+ *
54
+ * Возвращает данные последнего запроса.
55
+ * @returns last response data or undefined / данные последнего ответа или undefined
56
+ */
57
+ getResponse<T>(): T | undefined;
58
+ /**
59
+ * Returns messages from the last request.
60
+ *
61
+ * Возвращает сообщения от последнего запроса.
62
+ * @returns message string / строка сообщения
63
+ */
64
+ getMessage(): string;
65
+ /**
66
+ * Sets the status item data.
67
+ *
68
+ * Устанавливает данные элемента статуса.
69
+ * @param data status item data/ данные элемента статуса
70
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
71
+ */
72
+ set(data: ApiStatusItem): this;
73
+ /**
74
+ * Sets the status code and optional status text.
75
+ *
76
+ * Устанавливает код статуса и необязательный текст статуса.
77
+ * @param status status code / код статуса
78
+ * @param statusText optional status text / необязательный текст статуса
79
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
80
+ */
81
+ setStatus(status?: number, statusText?: string): this;
82
+ /**
83
+ * Sets the error message.
84
+ *
85
+ * Устанавливает сообщение об ошибке.
86
+ * @param error error message/ сообщение об ошибке
87
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
88
+ */
89
+ setError(error?: string): this;
90
+ /**
91
+ * Sets the data of the last response and automatically extracts status/message if it's an object.
92
+ *
93
+ * Устанавливает данные последнего ответа и автоматически извлекает статус / сообщение, если это объект.
94
+ * @param response response data / данные ответа
95
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
96
+ */
97
+ setLastResponse(response?: any): this;
98
+ /**
99
+ * Sets the last status.
100
+ *
101
+ * Устанавливает последний статус.
102
+ * @param status status/ статус
103
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
104
+ */
105
+ setLastStatus(status?: ApiStatusType): this;
106
+ /**
107
+ * Sets the last execution code.
108
+ *
109
+ * Устанавливает последний код выполнения.
110
+ * @param code status code / код статуса
111
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
112
+ */
113
+ setLastCode(code?: string): this;
114
+ /**
115
+ * Sets messages from the last request.
116
+ *
117
+ * Устанавливает сообщения от последнего запроса.
118
+ * @param message message text/ текст сообщения
119
+ * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
120
+ */
121
+ setLastMessage(message?: string): this;
122
+ /**
123
+ * Sets a specific field in the status item.
124
+ *
125
+ * Устанавливает конкретное поле в элементе статуса.
126
+ * @param name field name/ название поля
127
+ * @param value field value/ значение поля
128
+ */
129
+ protected setValue<K extends keyof ApiStatusItem>(name: K, value?: ApiStatusItem[K]): void;
130
+ }