bb-api-platforma 0.1.191 → 0.1.205

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.
@@ -24,6 +24,12 @@ export declare class BetBoosterApi {
24
24
  private _liveTimestampReset;
25
25
  liveRecivedIsFullPackage?: boolean;
26
26
  isNotActive?: boolean;
27
+ /** Приоритетные виды спорта для сортировки и отображения на странице [VidSportaRating]*/
28
+ primarySports: number[];
29
+ /** Приоритетные страны по видам спорта для сортировки и отображения */
30
+ priorityCountries: Record<string, number[]>;
31
+ /** Приоритетные турниры по видам спорта*/
32
+ priorityTournaments: Record<string, number[]>;
27
33
  /**
28
34
  * Represents the BetBoosterApi class.
29
35
  * @constructor
@@ -146,6 +152,57 @@ export declare class BetBoosterApi {
146
152
  * @returns URL for the specified API path and version.
147
153
  */
148
154
  private url;
155
+ /**
156
+ * Сортирует данные по приоритету, указанному в массиве priorityIDs.
157
+ *
158
+ * @template T - Тип объектов в массиве данных
159
+ * @param {Array<T>} data - Массив объектов данных для сортировки.
160
+ * @param {Array<number|string>} priorityIDs - Массив приоритетных ID для сортировки.
161
+ * @param {keyof T} sortField - Поле объекта, по которому будет производиться сортировка.
162
+ * @returns {Array<T>} - Новый массив отсортированных данных.
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * interface Tournament {
167
+ * Id: number;
168
+ * Name: string;
169
+ * SportID: number;
170
+ * }
171
+ *
172
+ * const tournaments: Tournament[] = [
173
+ * { Id: 1, Name: 'Premier League', SportID: 5 },
174
+ * { Id: 2, Name: 'La Liga', SportID: 5 },
175
+ * { Id: 3, Name: 'Serie A', SportID: 5 }
176
+ * ];
177
+ *
178
+ * const sortedTournaments = api.sortDataByPriority(
179
+ * tournaments,
180
+ * [3, 1, 2],
181
+ * 'Id'
182
+ * );
183
+ * // Result: [Serie A, Premier League, La Liga]
184
+ * ```
185
+ */
186
+ sortDataByPriority<T extends Record<string, any>>(data: T[], priorityIDs: Array<number | string>, sortField: keyof T): T[];
187
+ /**
188
+ * Сортирует массив значений по приоритету, указанному в массиве priorityIDs.
189
+ *
190
+ * @template T - Тип элементов массива (number | string)
191
+ * @param {Array<T>} array - Массив значений для сортировки.
192
+ * @param {Array<T>} priorityIDs - Массив приоритетных ID для сортировки.
193
+ * @returns {Array<T>} - Новый массив отсортированных значений.
194
+ *
195
+ * @example
196
+ * ```typescript
197
+ * const sportIds = [1, 5, 3, 8, 2];
198
+ * const prioritySports = [5, 1, 3];
199
+ *
200
+ * const sortedSports = api.sortArrayByPriority(sportIds, prioritySports);
201
+ * // Result: [5, 1, 3, 8, 2]
202
+ * // Elements 5, 1, 3 are sorted by priority, others remain in original order
203
+ * ```
204
+ */
205
+ sortArrayByPriority<T extends number | string>(array: T[], priorityIDs: T[]): T[];
149
206
  /**
150
207
  * Executes an HTTP request with the specified parameters.
151
208
  * @param url - The URL to execute the request.
@@ -220,6 +277,7 @@ export declare class BetBoosterApi {
220
277
  *
221
278
  * @param minutes The number of minutes to consider for the data retrieval. Defaults to 0.
222
279
  * @returns {Promise<Array<any>>} A promise that resolves to an array of line sports data.
280
+ * @deprecated - use this.getLineSportsMain();
223
281
  */
224
282
  getLineSports(minutes?: number): Promise<I.ISport[]>;
225
283
  /**
@@ -232,6 +290,7 @@ export declare class BetBoosterApi {
232
290
  * @param sportId - Идентификатор спорта.
233
291
  * @param minutes - Опциональный параметр, количество минут.
234
292
  * @returns Промис, который разрешается в массив объектов типа ICountry.
293
+ * @deprecated - use this.getCountriesListMain();
235
294
  */
236
295
  getCountriesList(sportId: number, minutes?: number): Promise<I.ICountry[]>;
237
296
  /**
@@ -240,8 +299,9 @@ export declare class BetBoosterApi {
240
299
  * @param countryId - The ID of the country.
241
300
  * @param minutes - The number of minutes ago for which data is to be retrieved.
242
301
  * @returns A promise that resolves to an array of prematch tournaments.
302
+ * @deprecated - use this.getPrematchTournamentsMain();
243
303
  */
244
- getPrematchTournaments(sportId: number, countryId: number, minutes?: number): Promise<I.GetPrematchTournament[]>;
304
+ getPrematchTournaments(sportId: number | string, countryId: number | string, minutes?: number): Promise<I.GetPrematchTournament[]>;
245
305
  /**
246
306
  * Retrieves prematch tournaments based on the specified sport ID and minutes.
247
307
  * @param sportId - The ID of the sport.
@@ -1173,6 +1233,147 @@ export declare class BetBoosterApi {
1173
1233
  status: number;
1174
1234
  statusText: string;
1175
1235
  }>;
1236
+ /**
1237
+ * Retrieves aggregated dictionary data from Redis using FT.AGGREGATE command.
1238
+ * Groups and counts items by specified dictionary type (sport, country, or tournament).
1239
+ *
1240
+ * @param payload - The search parameters for dictionary aggregation
1241
+ * @param payload.locale - Language locale code for filtering results
1242
+ * @param payload.sportId - Sport ID(s) to include in search
1243
+ * @param payload.countryId - Country ID(s) to include in search
1244
+ * @param payload.tournamentId - Tournament ID(s) to include in search
1245
+ * @param payload.dictionary - Dictionary type to group by ('sport' | 'country' | 'tournament')
1246
+ * @param payload.notsport - Sport ID(s) to exclude from search
1247
+ * @param payload.notcountry - Country ID(s) to exclude from search
1248
+ * @param payload.nottournament - Tournament ID(s) to exclude from search
1249
+ * @param payload.LIMIT - Maximum number of results to return
1250
+ * @param payload.minTime - Minimum time filter for events
1251
+ * @param payload.maxTime - Maximum time filter for events
1252
+ *
1253
+ * @returns Promise resolving to aggregated results with total count and grouped items,
1254
+ * or error object with total: 0 and empty results array on failure
1255
+ *
1256
+ * @example
1257
+ * ```typescript
1258
+ * // Get sport dictionary with counts
1259
+ * const sportDict = await redisDb.getDictionary({
1260
+ * locale: 'en',
1261
+ * dictionary: 'sport',
1262
+ * LIMIT: { from: 0, size: 10 },
1263
+ * minTime: 1640995200,
1264
+ * maxTime: 1641081600
1265
+ * });
1266
+ *
1267
+ * // Get country dictionary excluding specific sports
1268
+ * const countryDict = await redisDb.getDictionary({
1269
+ * locale: 'ru',
1270
+ * dictionary: 'country',
1271
+ * notsport: [1, 2, 3],
1272
+ * LIMIT: { from: 0, size: 50 }
1273
+ * });
1274
+ *
1275
+ * // Get tournament dictionary for specific sport and country
1276
+ * const tournamentDict = await redisDb.getDictionary({
1277
+ * locale: 'en',
1278
+ * dictionary: 'tournament',
1279
+ * sportId: [1],
1280
+ * countryId: [225],
1281
+ * LIMIT: { from: 0, size: 100 }
1282
+ * });
1283
+ * ```
1284
+ */
1285
+ getDictionaryNv20(payload: I.RedisDictionaryParams): Promise<{
1286
+ data: any;
1287
+ error: string | null;
1288
+ status: number;
1289
+ statusText: string;
1290
+ }>;
1291
+ /**
1292
+ * Retrieves a list of sports from the NV20 API endpoint with optional time filtering.
1293
+ *
1294
+ * @param {number} [minutes=0] - Optional time window in minutes to filter sports data.
1295
+ * If greater than 0, filters results to include only data
1296
+ * from the current time to the specified minutes in the future.
1297
+ * @param {number} [timeout=MAX_TIME_EXECUTION_MS] - Optional request timeout in milliseconds.
1298
+ * @returns {Promise<I.ISport[]>} A promise that resolves to an array of sports objects sorted by priority.
1299
+ * Each sport contains an ID, Name, and count (cnt) property.
1300
+ *
1301
+ * @example
1302
+ * // Get all available sports
1303
+ * const sports = await betBoosterApi.getLineSportsNv20();
1304
+ *
1305
+ * @example
1306
+ * // Get sports updated in the last 30 minutes with a custom timeout
1307
+ * const sports = await betBoosterApi.getLineSportsNv20(30, 5000);
1308
+ */
1309
+ getLineSportsNv20(minutes?: number, timeout?: number): Promise<I.ISport[]>;
1310
+ /**
1311
+ * Retrieves the main line sports data with fallback mechanism.
1312
+ *
1313
+ * Attempts to fetch line sports data from the NV20 endpoint first with a 2000ms timeout.
1314
+ * If no sports data is returned, falls back to the standard getLineSports endpoint.
1315
+ *
1316
+ * @param minutes - Optional. The number of minutes to look back for sports data. Defaults to 0.
1317
+ * @param timeout - Optional. The timeout duration in milliseconds for the NV20 API request. Defaults to 1500.
1318
+ * @returns A promise that resolves to an array of sports objects containing line sports data.
1319
+ * @example
1320
+ * // Get current line sports
1321
+ * const sports = await getLineSportsMain();
1322
+ *
1323
+ * @example
1324
+ * // Get line sports from the last 30 minutes
1325
+ * const sports = await getLineSportsMain(30);
1326
+ */
1327
+ getLineSportsMain(minutes?: number, timeout?: number): Promise<I.ISport[]>;
1328
+ /**
1329
+ * Retrieves countries for a given sport using the NV20 API.
1330
+ * @param sportId - The sport ID to filter countries by.
1331
+ * @param minutes - Optional time window in minutes for the query. Defaults to 0 (no time filter).
1332
+ * @returns A promise that resolves to the response data containing countries or null if the request fails.
1333
+ */
1334
+ getCountriesBySportNv20(sportId: number, minutes?: number, timeout?: number): Promise<I.ICountry[]>;
1335
+ /**
1336
+ * Retrieves a list of countries for a given sport, with fallback behavior.
1337
+ *
1338
+ * Attempts to fetch countries using the NV20 API with a 5-second timeout.
1339
+ * If no results are returned, falls back to the standard countries list endpoint.
1340
+ *
1341
+ * @param sportId - The unique identifier of the sport
1342
+ * @param minutes - Optional. The number of minutes to use as a filter criteria. Defaults to 0.
1343
+ * @param timeout - Optional. The timeout duration in milliseconds for the NV20 API request. Defaults to 3000.
1344
+ * @returns A promise that resolves to an array of countries for the specified sport
1345
+ *
1346
+ * @example
1347
+ * ```typescript
1348
+ * const countries = await this.getCountriesListMain(1, 30);
1349
+ * ```
1350
+ */
1351
+ getCountriesListMain(sportId: number, minutes?: number, timeout?: number): Promise<I.ICountry[]>;
1352
+ /**
1353
+ * Retrieves tournaments from the NV20 API for a specific sport and optional country.
1354
+ * @param sportId - The sport ID to filter tournaments by
1355
+ * @param countryId - Optional country ID to filter tournaments by
1356
+ * @param minutes - Optional time window in minutes for tournament data (default: 0, no time filter)
1357
+ * @returns A promise that resolves to the response data containing tournaments or null
1358
+ */
1359
+ getPrematchTournamentsNv20(sportId: number | string, countryId: number | string, minutes?: number, timeout?: number): Promise<I.ITournamentShort[]>;
1360
+ /**
1361
+ * Retrieves prematch tournaments for a given sport and country.
1362
+ *
1363
+ * Attempts to fetch tournaments using the NV2.0 API first. If no tournaments are returned,
1364
+ * falls back to the standard API as a failover mechanism.
1365
+ *
1366
+ * @param sportId - The sport identifier (number or string)
1367
+ * @param countryId - The country identifier (number or string)
1368
+ * @param minutes - The time window in minutes for prematch tournaments (default: 0)
1369
+ * @param timeout - The request timeout in milliseconds (default: 3000)
1370
+ * @returns A promise that resolves to an array of tournament objects
1371
+ * @throws May throw an error if both API calls fail
1372
+ *
1373
+ * @example
1374
+ * const tournaments = await betBoosterApi.getPrematchTournamentsMain(1, 'US', 30, 5000);
1375
+ */
1376
+ getPrematchTournamentsMain(sportId: number | string, countryId: number | string, minutes?: number, timeout?: number): Promise<I.ITournamentShort[]>;
1176
1377
  searchPrematchTournametsEventsNv20(searchString: string, options?: I.RedisPrematchSearchParams): Promise<{
1177
1378
  data: any;
1178
1379
  error: string | null;
@@ -1269,6 +1470,9 @@ export declare class BetBoosterApi {
1269
1470
  getFaq(): Promise<any>;
1270
1471
  getFlatpagesList(): Promise<any>;
1271
1472
  test3(): Promise<string>;
1473
+ /**
1474
+ * @deprecated sellBet - Not implemented
1475
+ */
1272
1476
  sellBet(data: any): Promise<void>;
1273
1477
  /** Конвертирует различные представления корзины в единый формат
1274
1478
  * @param betslipItem - элемент корзины