@dxtmisha/functional-basic 1.1.0 → 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.
- package/CHANGELOG.md +81 -0
- package/ai-description.txt +1 -0
- package/ai-types.txt +1062 -951
- package/dist/classes/Api.d.ts +201 -0
- package/dist/classes/ApiCache.d.ts +152 -0
- package/dist/classes/ApiDataReturn.d.ts +76 -0
- package/dist/classes/ApiDefault.d.ts +49 -0
- package/dist/classes/ApiHeaders.d.ts +37 -0
- package/dist/classes/ApiHydration.d.ts +39 -0
- package/dist/classes/ApiInstance.d.ts +283 -0
- package/dist/classes/ApiPreparation.d.ts +58 -0
- package/dist/classes/ApiResponse.d.ts +154 -0
- package/dist/classes/ApiStatus.d.ts +130 -0
- package/dist/classes/BroadcastMessage.d.ts +75 -0
- package/dist/classes/Cache.d.ts +38 -0
- package/dist/classes/CacheItem.d.ts +62 -0
- package/dist/classes/CacheStatic.d.ts +36 -0
- package/dist/classes/Cookie.d.ts +54 -0
- package/dist/classes/CookieBlock.d.ts +30 -0
- package/dist/classes/CookieBlockInstance.d.ts +23 -0
- package/dist/classes/CookieStorage.d.ts +174 -0
- package/dist/classes/DataStorage.d.ts +107 -0
- package/dist/classes/Datetime.d.ts +570 -0
- package/dist/classes/ErrorCenter.d.ts +72 -0
- package/dist/classes/ErrorCenterHandler.d.ts +64 -0
- package/dist/classes/ErrorCenterInstance.d.ts +85 -0
- package/dist/classes/EventItem.d.ts +251 -0
- package/dist/classes/Formatters.d.ts +161 -0
- package/dist/classes/Geo.d.ts +151 -0
- package/dist/classes/GeoFlag.d.ts +98 -0
- package/dist/classes/GeoInstance.d.ts +215 -0
- package/dist/classes/GeoIntl.d.ts +304 -0
- package/dist/classes/GeoPhone.d.ts +108 -0
- package/dist/classes/Global.d.ts +29 -0
- package/dist/classes/Hash.d.ts +57 -0
- package/dist/classes/HashInstance.d.ts +95 -0
- package/dist/classes/Icons.d.ts +128 -0
- package/dist/classes/Loading.d.ts +66 -0
- package/dist/classes/LoadingInstance.d.ts +99 -0
- package/dist/classes/Meta.d.ts +186 -0
- package/dist/classes/MetaManager.d.ts +121 -0
- package/dist/classes/MetaOg.d.ts +115 -0
- package/dist/classes/MetaStatic.d.ts +179 -0
- package/dist/classes/MetaTwitter.d.ts +115 -0
- package/dist/classes/ResumableTimer.d.ts +81 -0
- package/dist/classes/ScrollbarWidth.d.ts +51 -0
- package/dist/classes/SearchList.d.ts +128 -0
- package/dist/classes/SearchListData.d.ts +143 -0
- package/dist/classes/SearchListItem.d.ts +49 -0
- package/dist/classes/SearchListMatcher.d.ts +57 -0
- package/dist/classes/SearchListOptions.d.ts +66 -0
- package/dist/classes/ServerStorage.d.ts +106 -0
- package/dist/classes/StorageCallback.d.ts +84 -0
- package/dist/classes/Translate.d.ts +119 -0
- package/dist/classes/TranslateFile.d.ts +81 -0
- package/dist/classes/TranslateInstance.d.ts +206 -0
- package/dist/functions/addTagHighlightMatch.d.ts +11 -0
- package/dist/functions/anyToString.d.ts +10 -0
- package/dist/functions/applyTemplate.d.ts +10 -0
- package/dist/functions/arrFill.d.ts +9 -0
- package/dist/functions/blobToBase64.d.ts +9 -0
- package/dist/functions/capitalize.d.ts +9 -0
- package/dist/functions/copyObject.d.ts +10 -0
- package/dist/functions/copyObjectLite.d.ts +9 -0
- package/dist/functions/createElement.d.ts +21 -0
- package/dist/functions/domQuerySelector.d.ts +8 -0
- package/dist/functions/domQuerySelectorAll.d.ts +8 -0
- package/dist/functions/encodeAttribute.d.ts +8 -0
- package/dist/functions/encodeLiteAttribute.d.ts +8 -0
- package/dist/functions/ensureMaxSize.d.ts +10 -0
- package/dist/functions/escapeExp.d.ts +7 -0
- package/dist/functions/eventStopPropagation.d.ts +7 -0
- package/dist/functions/executeFunction.d.ts +12 -0
- package/dist/functions/executePromise.d.ts +11 -0
- package/dist/functions/forEach.d.ts +14 -0
- package/dist/functions/frame.d.ts +10 -0
- package/dist/functions/getArrayHighlightMatch.d.ts +10 -0
- package/dist/functions/getAttributes.d.ts +9 -0
- package/dist/functions/getClipboardData.d.ts +9 -0
- package/dist/functions/getColumn.d.ts +10 -0
- package/dist/functions/getCurrentDate.d.ts +19 -0
- package/dist/functions/getCurrentTime.d.ts +15 -0
- package/dist/functions/getElement.d.ts +9 -0
- package/dist/functions/getElementId.d.ts +26 -0
- package/dist/functions/getElementImage.d.ts +8 -0
- package/dist/functions/getElementItem.d.ts +12 -0
- package/dist/functions/getElementOrWindow.d.ts +8 -0
- package/dist/functions/getElementSafeScript.d.ts +9 -0
- package/dist/functions/getExactSearchExp.d.ts +8 -0
- package/dist/functions/getExp.d.ts +14 -0
- package/dist/functions/getHydrationData.d.ts +10 -0
- package/dist/functions/getItemByPath.d.ts +9 -0
- package/dist/functions/getKey.d.ts +8 -0
- package/dist/functions/getLengthOfAllArray.d.ts +8 -0
- package/dist/functions/getMaxLengthAllArray.d.ts +9 -0
- package/dist/functions/getMinLengthAllArray.d.ts +8 -0
- package/dist/functions/getMouseClient.d.ts +9 -0
- package/dist/functions/getMouseClientX.d.ts +8 -0
- package/dist/functions/getMouseClientY.d.ts +8 -0
- package/dist/functions/getObjectByKeys.d.ts +8 -0
- package/dist/functions/getObjectNoUndefined.d.ts +9 -0
- package/dist/functions/getObjectOrNone.d.ts +8 -0
- package/dist/functions/getOnlyText.d.ts +8 -0
- package/dist/functions/getRandomText.d.ts +12 -0
- package/dist/functions/getRequestString.d.ts +11 -0
- package/dist/functions/getSearchExp.d.ts +12 -0
- package/dist/functions/getSeparatingSearchExp.d.ts +9 -0
- package/dist/functions/getStepPercent.d.ts +9 -0
- package/dist/functions/getStepValue.d.ts +9 -0
- package/dist/functions/goScroll.d.ts +10 -0
- package/dist/functions/goScrollSmooth.d.ts +10 -0
- package/dist/functions/goScrollTo.d.ts +10 -0
- package/dist/functions/handleShare.d.ts +10 -0
- package/dist/functions/inArray.d.ts +9 -0
- package/dist/functions/initScrollbarOffset.d.ts +7 -0
- package/dist/functions/intersectKey.d.ts +9 -0
- package/dist/functions/isApiSuccess.d.ts +9 -0
- package/dist/functions/isArray.d.ts +8 -0
- package/dist/functions/isDifferent.d.ts +10 -0
- package/dist/functions/isDomData.d.ts +7 -0
- package/dist/functions/isDomRuntime.d.ts +10 -0
- package/dist/functions/isElementVisible.d.ts +11 -0
- package/dist/functions/isEnter.d.ts +9 -0
- package/dist/functions/isFilled.d.ts +10 -0
- package/dist/functions/isFloat.d.ts +8 -0
- package/dist/functions/isFunction.d.ts +9 -0
- package/dist/functions/isInDom.d.ts +9 -0
- package/dist/functions/isInput.d.ts +8 -0
- package/dist/functions/isIntegerBetween.d.ts +9 -0
- package/dist/functions/isNull.d.ts +9 -0
- package/dist/functions/isNumber.d.ts +8 -0
- package/dist/functions/isObject.d.ts +8 -0
- package/dist/functions/isObjectNotArray.d.ts +8 -0
- package/dist/functions/isOnLine.d.ts +7 -0
- package/dist/functions/isSelected.d.ts +9 -0
- package/dist/functions/isSelectedByList.d.ts +9 -0
- package/dist/functions/isShare.d.ts +7 -0
- package/dist/functions/isString.d.ts +8 -0
- package/dist/functions/isWindow.d.ts +7 -0
- package/dist/functions/random.d.ts +9 -0
- package/dist/functions/removeCommonPrefix.d.ts +9 -0
- package/dist/functions/replaceComponentName.d.ts +9 -0
- package/dist/functions/replaceRecursive.d.ts +11 -0
- package/dist/functions/replaceTemplate.d.ts +10 -0
- package/dist/functions/resizeImageByMax.d.ts +19 -0
- package/dist/functions/secondToTime.d.ts +9 -0
- package/dist/functions/setElementItem.d.ts +11 -0
- package/dist/functions/setValues.d.ts +18 -0
- package/dist/functions/sleep.d.ts +8 -0
- package/dist/functions/splice.d.ts +13 -0
- package/dist/functions/strFill.d.ts +9 -0
- package/dist/functions/strSplit.d.ts +12 -0
- package/dist/functions/toArray.d.ts +17 -0
- package/dist/functions/toCamelCase.d.ts +8 -0
- package/dist/functions/toCamelCaseFirst.d.ts +8 -0
- package/dist/functions/toDate.d.ts +8 -0
- package/dist/functions/toKebabCase.d.ts +15 -0
- package/dist/functions/toNumber.d.ts +19 -0
- package/dist/functions/toNumberByMax.d.ts +11 -0
- package/dist/functions/toPercent.d.ts +9 -0
- package/dist/functions/toPercentBy100.d.ts +9 -0
- package/dist/functions/toString.d.ts +8 -0
- package/dist/functions/transformation.d.ts +21 -0
- package/dist/functions/uint8ArrayToBase64.d.ts +8 -0
- package/dist/functions/uniqueArray.d.ts +8 -0
- package/dist/functions/writeClipboardData.d.ts +8 -0
- package/dist/library.d.ts +171 -8722
- package/dist/library.js +416 -338
- package/dist/media/errorCauseList.d.ts +2 -0
- package/dist/types/apiTypes.d.ts +217 -0
- package/dist/types/basicTypes.d.ts +131 -0
- package/dist/types/errorCenter.d.ts +42 -0
- package/dist/types/formattersTypes.d.ts +224 -0
- package/dist/types/geoTypes.d.ts +86 -0
- package/dist/types/metaTypes.d.ts +586 -0
- package/dist/types/searchTypes.d.ts +53 -0
- package/dist/types/translateTypes.d.ts +54 -0
- package/package.json +7 -5
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ApiInstance } from './ApiInstance';
|
|
2
|
+
import { ApiConfig, ApiFetch, 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: Record<string, string>): void;
|
|
97
|
+
/**
|
|
98
|
+
* Modifies the default request data.
|
|
99
|
+
*
|
|
100
|
+
* Изменяет данные запроса по умолчанию.
|
|
101
|
+
* @param request default request data / данные запроса по умолчанию
|
|
102
|
+
* @returns void / ничего не возвращает
|
|
103
|
+
*/
|
|
104
|
+
static setRequestDefault(request: Record<string, any>): 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 multiple API configuration options at once.
|
|
147
|
+
*
|
|
148
|
+
* Устанавливает несколько опций конфигурации API одновременно.
|
|
149
|
+
* @param config configuration object / объект конфигурации
|
|
150
|
+
* @returns void / ничего не возвращает
|
|
151
|
+
*/
|
|
152
|
+
static setConfig(config?: ApiConfig): void;
|
|
153
|
+
/**
|
|
154
|
+
* Executes a request with the given path or configuration.
|
|
155
|
+
*
|
|
156
|
+
* Выполняет запрос с указанным путем или конфигурацией.
|
|
157
|
+
* @param pathRequest path or configuration / путь или конфигурация запроса
|
|
158
|
+
* @returns Promise with response data / Promise с данными ответа
|
|
159
|
+
*/
|
|
160
|
+
static request<T>(pathRequest: string | ApiFetch): Promise<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Sends a GET method request.
|
|
163
|
+
*
|
|
164
|
+
* Отправляет запрос метода GET.
|
|
165
|
+
* @param request fetch configuration / конфигурация запроса
|
|
166
|
+
* @returns Promise with response data / Promise с данными ответа
|
|
167
|
+
*/
|
|
168
|
+
static get<T>(request: ApiFetch): Promise<T>;
|
|
169
|
+
/**
|
|
170
|
+
* Sends a POST method request.
|
|
171
|
+
*
|
|
172
|
+
* Отправляет запрос метода POST.
|
|
173
|
+
* @param request fetch configuration / конфигурация запроса
|
|
174
|
+
* @returns Promise with response data / Promise с данными ответа
|
|
175
|
+
*/
|
|
176
|
+
static post<T>(request: ApiFetch): Promise<T>;
|
|
177
|
+
/**
|
|
178
|
+
* Sends a PUT method request.
|
|
179
|
+
*
|
|
180
|
+
* Отправляет запрос метода PUT.
|
|
181
|
+
* @param request fetch configuration / конфигурация запроса
|
|
182
|
+
* @returns Promise with response data / Promise с данными ответа
|
|
183
|
+
*/
|
|
184
|
+
static put<T>(request: ApiFetch): Promise<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Sends a PATCH method request.
|
|
187
|
+
*
|
|
188
|
+
* Отправляет запрос метода PATCH.
|
|
189
|
+
* @param request fetch configuration / конфигурация запроса
|
|
190
|
+
* @returns Promise with response data / Promise с данными ответа
|
|
191
|
+
*/
|
|
192
|
+
static patch<T>(request: ApiFetch): Promise<T>;
|
|
193
|
+
/**
|
|
194
|
+
* Sends a DELETE method request.
|
|
195
|
+
*
|
|
196
|
+
* Отправляет запрос метода DELETE.
|
|
197
|
+
* @param request fetch configuration / конфигурация запроса
|
|
198
|
+
* @returns Promise with response data / Promise с данными ответа
|
|
199
|
+
*/
|
|
200
|
+
static delete<T>(request: ApiFetch): Promise<T>;
|
|
201
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ApiStatus } from './ApiStatus';
|
|
2
|
+
import { ApiData, ApiFetch, ApiPreparationEnd } from '../types/apiTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Class for handling and processing data returned from an API request.
|
|
5
|
+
*
|
|
6
|
+
* Класс для обработки и подготовки данных, полученных в результате запроса к API.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ApiDataReturn<T = any> {
|
|
9
|
+
protected readonly apiFetch: ApiFetch;
|
|
10
|
+
protected readonly query: Response;
|
|
11
|
+
protected readonly end: ApiPreparationEnd;
|
|
12
|
+
/**
|
|
13
|
+
* Raw data received from the API/
|
|
14
|
+
* Исходные данные, полученные от API
|
|
15
|
+
*/
|
|
16
|
+
protected data?: ApiData<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Processed data ready for use/
|
|
19
|
+
* Обработанные данные, готовые к использованию
|
|
20
|
+
*/
|
|
21
|
+
protected dataMod?: ApiData<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Constructor for ApiDataReturn.
|
|
24
|
+
*
|
|
25
|
+
* Конструктор ApiDataReturn.
|
|
26
|
+
* @param apiFetch API fetch configuration / конфигурация запроса API
|
|
27
|
+
* @param query response object / объект ответа
|
|
28
|
+
* @param end preparation end data / данные завершения подготовки
|
|
29
|
+
*/
|
|
30
|
+
constructor(apiFetch: ApiFetch, query: Response, end: ApiPreparationEnd);
|
|
31
|
+
/**
|
|
32
|
+
* Initializes the class by reading data from the response.
|
|
33
|
+
*
|
|
34
|
+
* Инициализирует класс, считывая данные из ответа.
|
|
35
|
+
*/
|
|
36
|
+
init(): Promise<this>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns processed data.
|
|
39
|
+
*
|
|
40
|
+
* Возвращает обработанные данные.
|
|
41
|
+
*/
|
|
42
|
+
get(): ApiData<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Returns processed data along with the status object.
|
|
45
|
+
*
|
|
46
|
+
* Возвращает обработанные данные вместе с объектом статуса.
|
|
47
|
+
* @param status API status instance / экземпляр статуса API
|
|
48
|
+
*/
|
|
49
|
+
getAndStatus(status: ApiStatus): ApiData<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Returns raw data received from the API.
|
|
52
|
+
*
|
|
53
|
+
* Возвращает исходные данные, полученные от API.
|
|
54
|
+
*/
|
|
55
|
+
getData(): ApiData<T> | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Reads and parses data from the response.
|
|
58
|
+
*
|
|
59
|
+
* Считывает и анализирует данные из ответа.
|
|
60
|
+
*/
|
|
61
|
+
protected readData<T>(): Promise<ApiData<T>>;
|
|
62
|
+
/**
|
|
63
|
+
* Prepares and formats the raw data.
|
|
64
|
+
*
|
|
65
|
+
* Подготавливает и форматирует исходные данные.
|
|
66
|
+
*/
|
|
67
|
+
protected initData(): ApiData<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Initializes the result item and merges metadata (success, status, code, message) from raw data.
|
|
70
|
+
*
|
|
71
|
+
* Инициализирует результирующий объект и переносит метаданные (success, status, code, message) из исходных данных.
|
|
72
|
+
* @param data raw response data / исходные данные ответа
|
|
73
|
+
* @returns initialized data with metadata / инициализированные данные с метаданными
|
|
74
|
+
*/
|
|
75
|
+
protected initItem(data: Record<string, any>): ApiData<T>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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(): ApiDefaultValue | 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
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ApiFetch } from '../types/apiTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Class for managing HTTP request headers.
|
|
4
|
+
*
|
|
5
|
+
* Класс для управления заголовками HTTP-запросов.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ApiHeaders {
|
|
8
|
+
/** Default headers / Заголовки по умолчанию */
|
|
9
|
+
protected headers: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the headers for the request.
|
|
12
|
+
*
|
|
13
|
+
* Получает заголовки для запроса.
|
|
14
|
+
* @param value list of headers / список заголовков
|
|
15
|
+
* @param type Content-Type header value / значение заголовка Content-Type
|
|
16
|
+
* @returns merged headers or undefined / объединенные заголовки или undefined
|
|
17
|
+
*/
|
|
18
|
+
get(value?: Record<string, string> | null, type?: string | undefined | null): Record<string, string> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the headers for the request based on request type.
|
|
21
|
+
*
|
|
22
|
+
* Получает заголовки для запроса на основе типа запроса.
|
|
23
|
+
* @param request request data / данные запроса
|
|
24
|
+
* @param value list of headers / список заголовков
|
|
25
|
+
* @param type Content-Type header value / значение заголовка Content-Type
|
|
26
|
+
* @returns merged headers or undefined / объединенные заголовки или undefined
|
|
27
|
+
*/
|
|
28
|
+
getByRequest(request: ApiFetch['request'], value?: Record<string, string> | null, type?: string): Record<string, string> | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the default headers.
|
|
31
|
+
*
|
|
32
|
+
* Устанавливает заголовки по умолчанию.
|
|
33
|
+
* @param headers list of default headers/ список заголовков по умолчанию
|
|
34
|
+
* @returns this instance for chaining / текущий экземпляр для цепочки вызовов
|
|
35
|
+
*/
|
|
36
|
+
set(headers: Record<string, string>): this;
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ApiResponse } from './ApiResponse';
|
|
2
|
+
import { ApiFetch, ApiHydrationList } from '../types/apiTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Class for collecting API data for hydration on the client side during SSR.
|
|
5
|
+
*
|
|
6
|
+
* Класс для сбора данных API для последующей гидратации на стороне клиента при SSR.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ApiHydration {
|
|
9
|
+
protected list: ApiHydrationList;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes the response with hydration data.
|
|
12
|
+
*
|
|
13
|
+
* Инициализирует ответ данными гидратации.
|
|
14
|
+
* @param response API response / ответ API
|
|
15
|
+
* @returns void / ничего не возвращает
|
|
16
|
+
*/
|
|
17
|
+
initResponse(response: ApiResponse): void;
|
|
18
|
+
/**
|
|
19
|
+
* Saves API response for client-side hydration.
|
|
20
|
+
*
|
|
21
|
+
* Сохраняет ответ API для гидратации на стороне клиента.
|
|
22
|
+
* @param apiFetch API request configuration / конфигурация запроса API
|
|
23
|
+
* @param response API response data / данные ответа API
|
|
24
|
+
* @returns void / ничего не возвращает
|
|
25
|
+
*/
|
|
26
|
+
toClient<T>(apiFetch: ApiFetch, response: T): void;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a string representation of the hydration data for the client.
|
|
29
|
+
*
|
|
30
|
+
* Возвращает строковое представление данных гидратации для клиента.
|
|
31
|
+
*/
|
|
32
|
+
toString(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the list of API responses for the client.
|
|
35
|
+
*
|
|
36
|
+
* Возвращает список ответов API для клиента.
|
|
37
|
+
*/
|
|
38
|
+
protected getListByClient(): ApiHydrationList;
|
|
39
|
+
}
|