@levrbet/shared 0.2.82 → 0.3.1

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 (57) hide show
  1. package/dist/core/config/urls.js +4 -4
  2. package/dist/core/config/urls.js.map +1 -1
  3. package/dist/core/utils/game.utils.d.ts +2 -0
  4. package/dist/core/utils/game.utils.js +69 -1
  5. package/dist/core/utils/game.utils.js.map +1 -1
  6. package/dist/server/oracle/config/game-periods/providers/lsports.periods.js +3 -3
  7. package/dist/server/oracle/config/game-periods/providers/lsports.periods.js.map +1 -1
  8. package/dist/server/oracle/config/game-periods/providers/optic-odds.periods.d.ts +4 -27
  9. package/dist/server/oracle/config/game-periods/providers/optic-odds.periods.js +4 -27
  10. package/dist/server/oracle/config/game-periods/providers/optic-odds.periods.js.map +1 -1
  11. package/dist/server/oracle/config/game-periods/sports.config.js +8 -73
  12. package/dist/server/oracle/config/game-periods/sports.config.js.map +1 -1
  13. package/dist/server/oracle/config/game-periods/types.d.ts +2 -6
  14. package/dist/server/oracle/config/game-periods/types.js +0 -1
  15. package/dist/server/oracle/config/game-periods/types.js.map +1 -1
  16. package/dist/server/oracle/redis-cache-manager/cache.keys.utils.d.ts +45 -74
  17. package/dist/server/oracle/redis-cache-manager/cache.keys.utils.js +65 -120
  18. package/dist/server/oracle/redis-cache-manager/cache.keys.utils.js.map +1 -1
  19. package/dist/server/oracle/redis-cache-manager/game.query.engine.d.ts +90 -0
  20. package/dist/server/oracle/redis-cache-manager/game.query.engine.js +436 -0
  21. package/dist/server/oracle/redis-cache-manager/game.query.engine.js.map +1 -0
  22. package/dist/server/oracle/redis-cache-manager/index.d.ts +2 -3
  23. package/dist/server/oracle/redis-cache-manager/index.js +2 -3
  24. package/dist/server/oracle/redis-cache-manager/index.js.map +1 -1
  25. package/dist/server/oracle/redis-cache-manager/market.query.engine.d.ts +50 -97
  26. package/dist/server/oracle/redis-cache-manager/market.query.engine.js +310 -467
  27. package/dist/server/oracle/redis-cache-manager/market.query.engine.js.map +1 -1
  28. package/dist/server/oracle/types/providers/game-clock/index.d.ts +1 -1
  29. package/dist/server/oracle/types/providers/game-clock/index.js +1 -1
  30. package/dist/server/oracle/types/providers/game-clock/index.js.map +1 -1
  31. package/dist/server/{utils/game_progress → oracle/types/providers/game-clock}/parser.d.ts +7 -1
  32. package/dist/server/{utils/game_progress → oracle/types/providers/game-clock}/parser.js +13 -2
  33. package/dist/server/oracle/types/providers/game-clock/parser.js.map +1 -0
  34. package/dist/server/utils/index.d.ts +0 -1
  35. package/dist/server/utils/index.js +0 -1
  36. package/dist/server/utils/index.js.map +1 -1
  37. package/package.json +5 -4
  38. package/scripts/setup-prisma.js +0 -0
  39. package/dist/server/oracle/redis-cache-manager/game.cache.service.d.ts +0 -185
  40. package/dist/server/oracle/redis-cache-manager/game.cache.service.js +0 -712
  41. package/dist/server/oracle/redis-cache-manager/game.cache.service.js.map +0 -1
  42. package/dist/server/oracle/redis-cache-manager/game.progress.d.ts +0 -4
  43. package/dist/server/oracle/redis-cache-manager/game.progress.js +0 -27
  44. package/dist/server/oracle/redis-cache-manager/game.progress.js.map +0 -1
  45. package/dist/server/oracle/redis-cache-manager/market.cache.service.d.ts +0 -87
  46. package/dist/server/oracle/redis-cache-manager/market.cache.service.js +0 -139
  47. package/dist/server/oracle/redis-cache-manager/market.cache.service.js.map +0 -1
  48. package/dist/server/utils/game_progress/caclulate.game.progress.d.ts +0 -6
  49. package/dist/server/utils/game_progress/caclulate.game.progress.js +0 -96
  50. package/dist/server/utils/game_progress/caclulate.game.progress.js.map +0 -1
  51. package/dist/server/utils/game_progress/game.utils.d.ts +0 -2
  52. package/dist/server/utils/game_progress/game.utils.js +0 -64
  53. package/dist/server/utils/game_progress/game.utils.js.map +0 -1
  54. package/dist/server/utils/game_progress/index.d.ts +0 -3
  55. package/dist/server/utils/game_progress/index.js +0 -20
  56. package/dist/server/utils/game_progress/index.js.map +0 -1
  57. package/dist/server/utils/game_progress/parser.js.map +0 -1
@@ -1,10 +1,6 @@
1
- import { Market, MarketStatus, MarketType, Odds } from "@prisma/client";
2
- import { Redis } from "ioredis";
3
- import { LevrChain, MarketWithRelations } from "../../../core";
4
- /**
5
- * Redis Query Engine using RediSearch
6
- * Provides advanced querying capabilities for markets and odds using Prisma types
7
- */
1
+ import type { Market, MarketStatus, MarketType, Odds } from "@prisma/client";
2
+ import type { Redis } from "ioredis";
3
+ import type { LevrChain, MarketWithRelations } from "../../../core";
8
4
  export interface SearchQuery {
9
5
  marketType?: MarketType;
10
6
  levrGameObjectId?: string;
@@ -24,129 +20,86 @@ export interface SearchResult<T> {
24
20
  results: T[];
25
21
  duration: number;
26
22
  }
23
+ export interface UpdateMarketCacheResult {
24
+ success: number;
25
+ failed: number;
26
+ total: number;
27
+ }
27
28
  /**
28
- * Get all odds for a specific game and market type with pagination
29
- * @param redis - Redis client instance
30
- * @param gameUniqueId - Unique game identifier
31
- * @param marketType - Market type
32
- * @param limit - Number of latest odds to return (from the end)
33
- * @returns Array of Odds objects
34
- */
35
- export declare const getOddsList: (redis: Redis, gameUniqueId: string, marketType: MarketType) => Promise<Odds[]>;
36
- /**
37
- * Fallback market query engine for Redis instances without RediSearch support
38
- * Uses simple hash operations instead of full-text search indexing
39
- */
40
- export declare const searchMarketsFallback: (redis: Redis, levrGameObjectId: string, marketType: MarketType) => Promise<Market | null>;
41
- /**
42
- * Add a new market to cache with RediSearch indexing
43
- * @param redis - Redis client instance
44
- * @param market - Array of Market objects to cache
45
- */
46
- export declare const updateMarketCache: (redis: Redis, market: Market[]) => Promise<void>;
47
- /**
48
- * Create market index with proper schema
29
+ * Create market index with proper schema and versioning
30
+ * Validates existing index schema and recreates if mismatched
49
31
  */
50
32
  export declare const createMarketIndex: (redis: Redis) => Promise<void>;
51
33
  /**
52
- * Creates a RediSearch index for odds lists by market identifiers
34
+ * Drop market search index
53
35
  * @param redis - Redis client instance
54
36
  */
55
- export declare const createOddsIndex: (redis: Redis) => Promise<void>;
37
+ export declare const dropMarketIndex: (redis: Redis) => Promise<void>;
56
38
  /**
57
- * Search markets using RediSearch query engine
39
+ * Add markets to cache with RediSearch indexing
58
40
  * @param redis - Redis client instance
59
- * @param params - Search parameters
60
- * @returns Array of Market objects
41
+ * @param markets - Array of Market objects to cache
42
+ * @returns Result object with success/failed counts
61
43
  */
62
- export declare const searchMarkets: (redis: Redis, params: SearchQuery) => Promise<Market[]>;
63
- /**
64
- * Get market by game unique ID and market type directly from hash
65
- * @param redis - Redis client instance
66
- * @param gameUniqueId - Unique game identifier
67
- * @param marketType - Market type
68
- * @returns Market object or null if not found
69
- */
70
- export declare const getMarketByGameAndType: (redis: Redis, gameUniqueId: string, marketType: MarketType) => Promise<Market | null>;
44
+ export declare const updateMarketCache: (redis: Redis, markets: Market[]) => Promise<UpdateMarketCacheResult>;
45
+ export interface MarketSearchResult {
46
+ markets: Market[];
47
+ total: number;
48
+ }
71
49
  /**
72
- * Search markets with their associated odds - FALLBACK version
73
- * Uses simple hash operations when RediSearch is unavailable
50
+ * Get markets using RediSearch query engine
74
51
  * @param redis - Redis client instance
75
- * @param levrGameObjectId - Unique game identifier
76
- * @param marketType - Market type
77
- * @returns Markets with their odds
52
+ * @param params - Search parameters
53
+ * @returns Search result with markets array and total count
78
54
  */
79
- export declare const searchMarketsWithOddsFallback: (redis: Redis, levrGameObjectId: string, marketType: MarketType) => Promise<MarketWithRelations | null>;
55
+ export declare const getGameMarkets: (redis: Redis, params: SearchQuery) => Promise<MarketSearchResult>;
80
56
  /**
81
- * Search markets with their associated odds
57
+ * Get markets with their associated odds
82
58
  * @param redis - Redis client instance
83
59
  * @param query - Search query parameters
84
- * @returns Search results with markets and their odds
60
+ * @returns Results with markets and their odds
85
61
  */
86
- export declare const searchMarketsWithOdds: (redis: Redis, query: any) => Promise<SearchResult<MarketWithRelations>>;
62
+ export declare const getGameMarketsWithOdds: (redis: Redis, query: SearchQuery) => Promise<SearchResult<MarketWithRelations>>;
87
63
  /**
88
- * Search multiple markets with their associated odds - FALLBACK version
89
- * Uses simple hash operations when RediSearch is unavailable
90
- * @param redis - Redis client instance
91
- * @param queries - Array of search query parameters with gameUniqueIdentifier and marketType
92
- * @returns Combined search results with markets and their odds
93
- */
94
- export declare const searchMultipleMarketsWithOddsFallback: (redis: Redis, queries: Array<{
95
- gameUniqueIdentifier: string;
96
- marketType: MarketType;
97
- }>) => Promise<{
98
- total: number;
99
- results: Record<string, MarketWithRelations[]>;
100
- duration: number;
101
- }>;
102
- /**
103
- * Search multiple markets with their associated odds using multiple queries
64
+ * Get multiple markets with their associated odds using multiple queries
104
65
  * @param redis - Redis client instance
105
66
  * @param queries - Array of search query parameters
106
- * @returns Combined search results with markets and their odds
67
+ * @returns Combined results with markets and their odds
107
68
  */
108
- export declare const searchMultipleMarketsWithOdds: (redis: Redis, queries: SearchQuery[]) => Promise<{
69
+ export declare const getMultipleMarketsWithOdds: (redis: Redis, queries: SearchQuery[]) => Promise<{
109
70
  total: number;
110
71
  results: Record<string, MarketWithRelations[]>;
111
72
  duration: number;
112
73
  }>;
113
74
  /**
114
- * Add odds to cache as a simple JSON list with searchable metadata
115
- * @param redis - Redis client instance
116
- * @param gameUniqueId - Unique game identifier
117
- * @param marketType - Market type
118
- * @param odds - Array of Odds objects to cache
119
- */
120
- export declare const addOddsToOddsCache: (redis: Redis, gameUniqueId: string, marketType: MarketType, odds: Odds[]) => Promise<void>;
121
- /**
122
- * Search odds lists by market identifiers using RediSearch
75
+ * Get market data with associated odds for multiple games and market types
123
76
  * @param redis - Redis client instance
124
- * @param gameMarketId - Game market ID to search
125
- * @param marketType - Market type to search
126
- * @param levrGameObjectId - Levr game object ID to search
127
- * @returns Array of odds lists matching the query
77
+ * @param query - Array of query objects with gameUniqueIdentifier and marketType
78
+ * @returns Map of game IDs to their markets with odds
128
79
  */
129
- export declare const searchOddsLists: (redis: Redis, gameMarketId?: string, marketType?: MarketType, levrGameObjectId?: string) => Promise<Odds[][]>;
80
+ export declare const getMarketDataCacheWithOdds: (redis: Redis, query: Array<{
81
+ gameUniqueIdentifier: string;
82
+ marketType: MarketType;
83
+ }>) => Promise<Record<string, MarketWithRelations[]>>;
130
84
  /**
131
- * Get the latest odds for a specific game and market type
85
+ * Get odds for a specific gameMarketId with pagination using Redis LIST
132
86
  * @param redis - Redis client instance
133
- * @param gameUniqueId - Unique game identifier
134
- * @param marketType - Market type
135
- * @returns Latest Odds object or null if not found
87
+ * @param gameMarketId - The game market identifier (key suffix)
88
+ * @param limit - Number of latest odds to return (from the end). Use -1 for all.
89
+ * @returns Array of Odds objects (most recent last)
136
90
  */
137
- export declare const getLatestOdds: (redis: Redis, gameUniqueId: string, marketType: MarketType) => Promise<Odds | null>;
91
+ export declare const getOddsList: (redis: Redis, gameMarketId: string, limit?: number) => Promise<Odds[]>;
138
92
  /**
139
- * Get the latest odds with its related market
93
+ * Add odds to cache using Redis LIST (RPUSH)
140
94
  * @param redis - Redis client instance
141
- * @param gameUniqueId - Unique game identifier
142
- * @param marketType - Market type
143
- * @returns Odds with related market or null if not found
95
+ * @param gameMarketId - The game market identifier (used as key suffix)
96
+ * @param odds - Array of Odds objects to append to the list
144
97
  */
145
- export declare const getLatestOddsWithMarket: (redis: Redis, gameUniqueId: string, marketType: MarketType) => Promise<(Odds & {
146
- market?: Market;
147
- }) | null>;
98
+ export declare const addOddsToOddsCache: (redis: Redis, gameMarketId: string, odds: Odds[]) => Promise<void>;
148
99
  /**
149
- * Drop all search indices
100
+ * Get the latest odds for a specific gameMarketId
150
101
  * @param redis - Redis client instance
102
+ * @param gameMarketId - The game market identifier
103
+ * @returns Latest Odds object or null if not found
151
104
  */
152
- export declare const dropAllIndices: (redis: Redis) => Promise<void>;
105
+ export declare const getLatestOdds: (redis: Redis, gameMarketId: string) => Promise<Odds | null>;