@gotza02/sequential-thinking 2026.2.39 → 2026.2.41
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/README.md +7 -4
- package/SYSTEM_INSTRUCTION.md +25 -50
- package/dist/tools/sports/core/base.d.ts +169 -0
- package/dist/tools/sports/core/base.js +289 -0
- package/dist/tools/sports/core/cache.d.ts +106 -0
- package/dist/tools/sports/core/cache.js +305 -0
- package/dist/tools/sports/core/constants.d.ts +179 -0
- package/dist/tools/sports/core/constants.js +149 -0
- package/dist/tools/sports/core/types.d.ts +379 -0
- package/dist/tools/sports/core/types.js +5 -0
- package/dist/tools/sports/index.d.ts +34 -0
- package/dist/tools/sports/index.js +50 -0
- package/dist/tools/sports/providers/api.d.ts +73 -0
- package/dist/tools/sports/providers/api.js +517 -0
- package/dist/tools/sports/providers/scraper.d.ts +66 -0
- package/dist/tools/sports/providers/scraper.js +186 -0
- package/dist/tools/sports/providers/search.d.ts +54 -0
- package/dist/tools/sports/providers/search.js +224 -0
- package/dist/tools/sports/tools/betting.d.ts +6 -0
- package/dist/tools/sports/tools/betting.js +251 -0
- package/dist/tools/sports/tools/league.d.ts +11 -0
- package/dist/tools/sports/tools/league.js +12 -0
- package/dist/tools/sports/tools/live.d.ts +9 -0
- package/dist/tools/sports/tools/live.js +235 -0
- package/dist/tools/sports/tools/match.d.ts +6 -0
- package/dist/tools/sports/tools/match.js +323 -0
- package/dist/tools/sports/tools/player.d.ts +6 -0
- package/dist/tools/sports/tools/player.js +152 -0
- package/dist/tools/sports/tools/team.d.ts +6 -0
- package/dist/tools/sports/tools/team.js +370 -0
- package/dist/tools/sports/utils/calculator.d.ts +69 -0
- package/dist/tools/sports/utils/calculator.js +156 -0
- package/dist/tools/sports/utils/formatter.d.ts +57 -0
- package/dist/tools/sports/utils/formatter.js +206 -0
- package/dist/tools/sports.d.ts +7 -0
- package/dist/tools/sports.js +27 -6
- package/package.json +1 -1
- package/system_instruction.md +155 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPORTS MODULE CONSTANTS
|
|
3
|
+
* Configuration values for the football intelligence system
|
|
4
|
+
*/
|
|
5
|
+
// ============= API Configuration =============
|
|
6
|
+
export const API_CONFIG = {
|
|
7
|
+
// API-Football (RapidAPI)
|
|
8
|
+
API_FOOTBALL_KEY: process.env.API_FOOTBALL_KEY || '',
|
|
9
|
+
API_FOOTBALL_BASE: 'https://api-football-v1.p.rapidapi.com/v3',
|
|
10
|
+
API_FOOTBALL_HOST: 'api-football-v1.p.rapidapi.com',
|
|
11
|
+
// Football-Data.org
|
|
12
|
+
FOOTBALL_DATA_KEY: process.env.FOOTBALL_DATA_KEY || '',
|
|
13
|
+
FOOTBALL_DATA_BASE: 'https://api.football-data.org/v4',
|
|
14
|
+
// TheSportsDB
|
|
15
|
+
SPORTS_DB_KEY: process.env.SPORTS_DB_KEY || '',
|
|
16
|
+
SPORTS_DB_BASE: 'https://www.thesportsdb.com/api/v1/json',
|
|
17
|
+
// Rate limits (requests per minute)
|
|
18
|
+
RATE_LIMITS: {
|
|
19
|
+
API_FOOTBALL: 10,
|
|
20
|
+
FOOTBALL_DATA: 10,
|
|
21
|
+
SPORTS_DB: 30,
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
// ============= Cache Configuration =============
|
|
25
|
+
export const CACHE_CONFIG = {
|
|
26
|
+
// Default TTL in milliseconds
|
|
27
|
+
DEFAULT_TTL: parseInt(process.env.SPORTS_CACHE_TTL || '300000'), // 5 minutes
|
|
28
|
+
// Specific TTLs for different data types
|
|
29
|
+
TTL: {
|
|
30
|
+
LIVE_SCORES: 60 * 1000, // 1 minute
|
|
31
|
+
MATCH_DETAILS: 5 * 60 * 1000, // 5 minutes
|
|
32
|
+
STANDINGS: 30 * 60 * 1000, // 30 minutes
|
|
33
|
+
TEAM_STATS: 60 * 60 * 1000, // 1 hour
|
|
34
|
+
PLAYER_STATS: 60 * 60 * 1000, // 1 hour
|
|
35
|
+
ODDS: 2 * 60 * 1000, // 2 minutes
|
|
36
|
+
TRANSFER_NEWS: 15 * 60 * 1000, // 15 minutes
|
|
37
|
+
},
|
|
38
|
+
// Cache file path
|
|
39
|
+
CACHE_PATH: process.env.SPORTS_CACHE_PATH || '.sports_cache.json',
|
|
40
|
+
// Max cache size (number of entries)
|
|
41
|
+
MAX_SIZE: 1000,
|
|
42
|
+
};
|
|
43
|
+
// ============= Scraping Configuration =============
|
|
44
|
+
export const SCRAPER_CONFIG = {
|
|
45
|
+
// Priority domains for sports data
|
|
46
|
+
PRIORITY_DOMAINS: [
|
|
47
|
+
'whoscored.com',
|
|
48
|
+
'sofascore.com',
|
|
49
|
+
'flashscore.com',
|
|
50
|
+
'understat.com',
|
|
51
|
+
'fbref.com',
|
|
52
|
+
'bbc.co.uk/sport',
|
|
53
|
+
'skysports.com',
|
|
54
|
+
'sportsmole.co.uk',
|
|
55
|
+
'goal.com',
|
|
56
|
+
'thesquareball.net'
|
|
57
|
+
],
|
|
58
|
+
// Scraping timeout in milliseconds
|
|
59
|
+
TIMEOUT: 15000,
|
|
60
|
+
// User agent for scraping
|
|
61
|
+
USER_AGENT: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
|
62
|
+
// Maximum content length
|
|
63
|
+
MAX_CONTENT_LENGTH: 50000,
|
|
64
|
+
};
|
|
65
|
+
// ============= Leagues Configuration =============
|
|
66
|
+
export const LEAGUES = {
|
|
67
|
+
// Major European Leagues
|
|
68
|
+
PREMIER_LEAGUE: { id: 39, name: 'Premier League', country: 'England', code: 'PL' },
|
|
69
|
+
LA_LIGA: { id: 140, name: 'La Liga', country: 'Spain', code: 'LL' },
|
|
70
|
+
BUNDESLIGA: { id: 78, name: 'Bundesliga', country: 'Germany', code: 'BL1' },
|
|
71
|
+
SERIE_A: { id: 135, name: 'Serie A', country: 'Italy', code: 'SA' },
|
|
72
|
+
LIGUE_1: { id: 61, name: 'Ligue 1', country: 'France', code: 'FL1' },
|
|
73
|
+
// Other Top Leagues
|
|
74
|
+
EREDIVISIE: { id: 88, name: 'Eredivisie', country: 'Netherlands', code: 'DED' },
|
|
75
|
+
PRIMEIRA_LIGA: { id: 94, name: 'Primeira Liga', country: 'Portugal', code: 'PPL' },
|
|
76
|
+
CHAMPIONS_LEAGUE: { id: 2, name: 'UEFA Champions League', country: 'Europe', code: 'CL' },
|
|
77
|
+
EUROPA_LEAGUE: { id: 3, name: 'UEFA Europa League', country: 'Europe', code: 'EL' },
|
|
78
|
+
FA_CUP: { id: 45, name: 'FA Cup', country: 'England', code: 'FAC' },
|
|
79
|
+
// Asian Leagues
|
|
80
|
+
J_LEAGUE: { id: 98, name: 'J1 League', country: 'Japan', code: 'J1' },
|
|
81
|
+
K_LEAGUE: { id: 251, name: 'K League 1', country: 'South Korea', code: 'KL1' },
|
|
82
|
+
THAI_LEAGUE: { id: 305, name: 'Thai League 1', country: 'Thailand', code: 'TL1' },
|
|
83
|
+
CSL: { id: 169, name: 'Chinese Super League', country: 'China', code: 'CSL' },
|
|
84
|
+
};
|
|
85
|
+
// ============= Search Query Types =============
|
|
86
|
+
export const QUERY_TYPES = {
|
|
87
|
+
GENERAL: 'general',
|
|
88
|
+
H2H: 'h2h',
|
|
89
|
+
FORM: 'form',
|
|
90
|
+
NEWS: 'news',
|
|
91
|
+
STATS: 'stats',
|
|
92
|
+
ODDS: 'odds',
|
|
93
|
+
REFEREE: 'referee',
|
|
94
|
+
WEATHER: 'weather',
|
|
95
|
+
FATIGUE: 'fatigue',
|
|
96
|
+
SETPIECES: 'setpieces',
|
|
97
|
+
};
|
|
98
|
+
// ============= Betting Constants =============
|
|
99
|
+
export const BETTING = {
|
|
100
|
+
// Kelly Criterion variants
|
|
101
|
+
KELLY_FULL: 'full',
|
|
102
|
+
KELLY_HALF: 'half',
|
|
103
|
+
KELLY_QUARTER: 'quarter',
|
|
104
|
+
// Value thresholds
|
|
105
|
+
VALUE_THRESHOLD: 0.05, // 5% value is worth considering
|
|
106
|
+
HIGH_VALUE_THRESHOLD: 0.10, // 10% value is high value
|
|
107
|
+
// Confidence levels
|
|
108
|
+
CONFIDENCE: {
|
|
109
|
+
LOW: 50,
|
|
110
|
+
MEDIUM: 65,
|
|
111
|
+
HIGH: 80,
|
|
112
|
+
VERY_HIGH: 90,
|
|
113
|
+
},
|
|
114
|
+
// Bankroll management
|
|
115
|
+
DEFAULT_BANKROLL: 1000,
|
|
116
|
+
MAX_STAKE_PERCENTAGE: 0.05, // Max 5% of bankroll per bet
|
|
117
|
+
};
|
|
118
|
+
// ============= Position Types =============
|
|
119
|
+
export const POSITIONS = {
|
|
120
|
+
GOALKEEPER: 'GK',
|
|
121
|
+
DEFENDER: 'DF',
|
|
122
|
+
MIDFIELDER: 'MF',
|
|
123
|
+
FORWARD: 'FW',
|
|
124
|
+
SUBSTITUTE: 'SUB',
|
|
125
|
+
};
|
|
126
|
+
// ============= Match Status =============
|
|
127
|
+
export const MATCH_STATUS = {
|
|
128
|
+
SCHEDULED: 'scheduled',
|
|
129
|
+
LIVE: 'live',
|
|
130
|
+
FINISHED: 'finished',
|
|
131
|
+
POSTPONED: 'postponed',
|
|
132
|
+
CANCELLED: 'cancelled',
|
|
133
|
+
ABANDONED: 'abandoned',
|
|
134
|
+
};
|
|
135
|
+
// ============= Error Messages =============
|
|
136
|
+
export const ERRORS = {
|
|
137
|
+
NO_API_KEY: 'No API key configured. Please set environment variables.',
|
|
138
|
+
RATE_LIMITED: 'API rate limit exceeded. Please try again later.',
|
|
139
|
+
NOT_FOUND: 'Requested data not found.',
|
|
140
|
+
TIMEOUT: 'Request timed out.',
|
|
141
|
+
INVALID_RESPONSE: 'Invalid response from API.',
|
|
142
|
+
ALL_PROVIDERS_FAILED: 'All data providers failed.',
|
|
143
|
+
};
|
|
144
|
+
// ============= Version Info =============
|
|
145
|
+
export const MODULE_INFO = {
|
|
146
|
+
NAME: 'sports-module',
|
|
147
|
+
VERSION: '2.0.0',
|
|
148
|
+
DESCRIPTION: 'Football Intelligence System for MCP Server',
|
|
149
|
+
};
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPORTS MODULE TYPES
|
|
3
|
+
* Complete data models and interfaces for the football intelligence system
|
|
4
|
+
*/
|
|
5
|
+
export type Position = 'GK' | 'DF' | 'MF' | 'FW' | 'SUB';
|
|
6
|
+
export type MatchStatus = 'scheduled' | 'live' | 'finished' | 'postponed' | 'cancelled' | 'abandoned';
|
|
7
|
+
export type BetType = 'home' | 'draw' | 'away' | 'over' | 'under' | 'btts' | 'handicap';
|
|
8
|
+
export type KellyVariant = 'full' | 'half' | 'quarter';
|
|
9
|
+
export type QueryType = 'general' | 'h2h' | 'form' | 'news' | 'stats' | 'odds' | 'referee' | 'weather' | 'fatigue' | 'setpieces';
|
|
10
|
+
export type ProviderType = 'api-football' | 'football-data' | 'sports-db' | 'scraper';
|
|
11
|
+
export interface SearchQuery {
|
|
12
|
+
type: QueryType;
|
|
13
|
+
query: string;
|
|
14
|
+
priority: number;
|
|
15
|
+
}
|
|
16
|
+
export interface Score {
|
|
17
|
+
home: number;
|
|
18
|
+
away: number;
|
|
19
|
+
halfTime?: {
|
|
20
|
+
home: number;
|
|
21
|
+
away: number;
|
|
22
|
+
};
|
|
23
|
+
fullTime?: {
|
|
24
|
+
home: number;
|
|
25
|
+
away: number;
|
|
26
|
+
};
|
|
27
|
+
extraTime?: {
|
|
28
|
+
home: number;
|
|
29
|
+
away: number;
|
|
30
|
+
};
|
|
31
|
+
penalties?: {
|
|
32
|
+
home: number;
|
|
33
|
+
away: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface Team {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
code?: string;
|
|
40
|
+
country: string;
|
|
41
|
+
founded?: number;
|
|
42
|
+
logo?: string;
|
|
43
|
+
venue?: string;
|
|
44
|
+
website?: string;
|
|
45
|
+
stats?: TeamStats;
|
|
46
|
+
}
|
|
47
|
+
export interface TeamStats {
|
|
48
|
+
matchesPlayed: number;
|
|
49
|
+
wins: number;
|
|
50
|
+
draws: number;
|
|
51
|
+
losses: number;
|
|
52
|
+
goalsFor: number;
|
|
53
|
+
goalsAgainst: number;
|
|
54
|
+
goalDifference: number;
|
|
55
|
+
points?: number;
|
|
56
|
+
position?: number;
|
|
57
|
+
xG?: number;
|
|
58
|
+
xGA?: number;
|
|
59
|
+
xGDiff?: number;
|
|
60
|
+
possessionAvg?: number;
|
|
61
|
+
shotsPerGame?: number;
|
|
62
|
+
shotsOnTargetPerGame?: number;
|
|
63
|
+
cornersPerGame?: number;
|
|
64
|
+
foulsPerGame?: number;
|
|
65
|
+
yellowCardsPerGame?: number;
|
|
66
|
+
redCardsPerGame?: number;
|
|
67
|
+
homeStats?: TeamStats;
|
|
68
|
+
awayStats?: TeamStats;
|
|
69
|
+
form?: 'W' | 'D' | 'L'[];
|
|
70
|
+
}
|
|
71
|
+
export interface Player {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
age?: number;
|
|
75
|
+
nationality: string;
|
|
76
|
+
position: Position;
|
|
77
|
+
number?: number;
|
|
78
|
+
photo?: string;
|
|
79
|
+
team?: Team;
|
|
80
|
+
stats?: PlayerStats;
|
|
81
|
+
marketValue?: number;
|
|
82
|
+
injured?: boolean;
|
|
83
|
+
suspended?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface PlayerStats {
|
|
86
|
+
season?: string;
|
|
87
|
+
league?: string;
|
|
88
|
+
matches: number;
|
|
89
|
+
starts: number;
|
|
90
|
+
minutes: number;
|
|
91
|
+
goals: number;
|
|
92
|
+
assists: number;
|
|
93
|
+
goalsPlusAssists?: number;
|
|
94
|
+
shots?: number;
|
|
95
|
+
shotsOnTarget?: number;
|
|
96
|
+
xG?: number;
|
|
97
|
+
xA?: number;
|
|
98
|
+
xGPlusXA?: number;
|
|
99
|
+
yellowCards: number;
|
|
100
|
+
redCards: number;
|
|
101
|
+
tackles?: number;
|
|
102
|
+
interceptions?: number;
|
|
103
|
+
dribbles?: number;
|
|
104
|
+
dribblesWon?: number;
|
|
105
|
+
passes?: number;
|
|
106
|
+
passAccuracy?: number;
|
|
107
|
+
keyPasses?: number;
|
|
108
|
+
aerialDuels?: number;
|
|
109
|
+
aerialDuelsWon?: number;
|
|
110
|
+
}
|
|
111
|
+
export interface League {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
country: string;
|
|
115
|
+
code?: string;
|
|
116
|
+
season?: string;
|
|
117
|
+
type?: 'league' | 'cup' | 'playoff';
|
|
118
|
+
logo?: string;
|
|
119
|
+
standings?: TableEntry[];
|
|
120
|
+
topScorers?: PlayerStats[];
|
|
121
|
+
topAssists?: PlayerStats[];
|
|
122
|
+
}
|
|
123
|
+
export interface TableEntry {
|
|
124
|
+
position: number;
|
|
125
|
+
team: Team;
|
|
126
|
+
played: number;
|
|
127
|
+
won: number;
|
|
128
|
+
drawn: number;
|
|
129
|
+
lost: number;
|
|
130
|
+
goalsFor: number;
|
|
131
|
+
goalsAgainst: number;
|
|
132
|
+
goalDifference: number;
|
|
133
|
+
points: number;
|
|
134
|
+
form?: 'W' | 'D' | 'L'[];
|
|
135
|
+
homeRecord?: {
|
|
136
|
+
played: number;
|
|
137
|
+
won: number;
|
|
138
|
+
drawn: number;
|
|
139
|
+
lost: number;
|
|
140
|
+
goalsFor: number;
|
|
141
|
+
against: number;
|
|
142
|
+
};
|
|
143
|
+
awayRecord?: {
|
|
144
|
+
played: number;
|
|
145
|
+
won: number;
|
|
146
|
+
drawn: number;
|
|
147
|
+
lost: number;
|
|
148
|
+
goalsFor: number;
|
|
149
|
+
against: number;
|
|
150
|
+
};
|
|
151
|
+
lastFive?: {
|
|
152
|
+
result: 'W' | 'D' | 'L';
|
|
153
|
+
for: number;
|
|
154
|
+
against: number;
|
|
155
|
+
}[];
|
|
156
|
+
}
|
|
157
|
+
export interface Match {
|
|
158
|
+
id: string;
|
|
159
|
+
homeTeam: Team;
|
|
160
|
+
awayTeam: Team;
|
|
161
|
+
league: League;
|
|
162
|
+
date: Date;
|
|
163
|
+
status: MatchStatus;
|
|
164
|
+
venue?: string;
|
|
165
|
+
referee?: Referee;
|
|
166
|
+
score?: Score;
|
|
167
|
+
minute?: number;
|
|
168
|
+
extraMinute?: number;
|
|
169
|
+
half?: 'H1' | 'H2' | 'HT' | 'ET' | 'P';
|
|
170
|
+
odds?: MatchOdds;
|
|
171
|
+
attendance?: number;
|
|
172
|
+
weather?: WeatherInfo;
|
|
173
|
+
homeLineup?: Player[];
|
|
174
|
+
awayLineup?: Player[];
|
|
175
|
+
homeSubstitutes?: Player[];
|
|
176
|
+
awaySubstitutes?: Player[];
|
|
177
|
+
events?: MatchEvent[];
|
|
178
|
+
}
|
|
179
|
+
export interface MatchOdds {
|
|
180
|
+
homeWin: number;
|
|
181
|
+
draw: number;
|
|
182
|
+
awayWin: number;
|
|
183
|
+
asianHandicap?: {
|
|
184
|
+
home: number;
|
|
185
|
+
away: number;
|
|
186
|
+
line: number;
|
|
187
|
+
};
|
|
188
|
+
overUnder?: {
|
|
189
|
+
line: number;
|
|
190
|
+
over: number;
|
|
191
|
+
under: number;
|
|
192
|
+
};
|
|
193
|
+
btts?: {
|
|
194
|
+
yes: number;
|
|
195
|
+
no: number;
|
|
196
|
+
};
|
|
197
|
+
provider: string;
|
|
198
|
+
timestamp: Date;
|
|
199
|
+
opening?: MatchOdds;
|
|
200
|
+
}
|
|
201
|
+
export interface MatchEvent {
|
|
202
|
+
id: string;
|
|
203
|
+
type: 'goal' | 'card' | 'substitution' | 'var' | 'injury' | 'whistle';
|
|
204
|
+
team: 'home' | 'away';
|
|
205
|
+
player?: Player;
|
|
206
|
+
assistPlayer?: Player;
|
|
207
|
+
minute: number;
|
|
208
|
+
extraMinute?: number;
|
|
209
|
+
detail?: string;
|
|
210
|
+
}
|
|
211
|
+
export interface Referee {
|
|
212
|
+
id: string;
|
|
213
|
+
name: string;
|
|
214
|
+
country: string;
|
|
215
|
+
age?: number;
|
|
216
|
+
photo?: string;
|
|
217
|
+
stats: RefereeStats;
|
|
218
|
+
}
|
|
219
|
+
export interface RefereeStats {
|
|
220
|
+
matches: number;
|
|
221
|
+
yellowCardsAvg: number;
|
|
222
|
+
redCardsAvg: number;
|
|
223
|
+
penaltiesAvg: number;
|
|
224
|
+
homeWinRate: number;
|
|
225
|
+
awayWinRate: number;
|
|
226
|
+
drawRate: number;
|
|
227
|
+
avgGoals: number;
|
|
228
|
+
}
|
|
229
|
+
export interface ValueBet {
|
|
230
|
+
match: Match;
|
|
231
|
+
betType: BetType;
|
|
232
|
+
fairOdds: number;
|
|
233
|
+
marketOdds: number;
|
|
234
|
+
value: number;
|
|
235
|
+
confidence: number;
|
|
236
|
+
kellyFraction?: number;
|
|
237
|
+
recommendedStake?: number;
|
|
238
|
+
reasoning: string;
|
|
239
|
+
}
|
|
240
|
+
export interface WeatherInfo {
|
|
241
|
+
temperature?: number;
|
|
242
|
+
condition?: string;
|
|
243
|
+
humidity?: number;
|
|
244
|
+
windSpeed?: number;
|
|
245
|
+
windDirection?: string;
|
|
246
|
+
precipitation?: number;
|
|
247
|
+
}
|
|
248
|
+
export interface TransferNews {
|
|
249
|
+
id: string;
|
|
250
|
+
player: Player;
|
|
251
|
+
fromTeam?: Team;
|
|
252
|
+
toTeam?: Team;
|
|
253
|
+
type: 'rumor' | 'confirmed' | 'loan' | 'free_transfer';
|
|
254
|
+
fee?: number;
|
|
255
|
+
feeFormatted?: string;
|
|
256
|
+
source: string;
|
|
257
|
+
timestamp: Date;
|
|
258
|
+
reliability?: 'low' | 'medium' | 'high';
|
|
259
|
+
}
|
|
260
|
+
export interface HeadToHead {
|
|
261
|
+
homeTeam: Team;
|
|
262
|
+
awayTeam: Team;
|
|
263
|
+
totalMatches: number;
|
|
264
|
+
homeWins: number;
|
|
265
|
+
draws: number;
|
|
266
|
+
awayWins: number;
|
|
267
|
+
homeGoals: number;
|
|
268
|
+
awayGoals: number;
|
|
269
|
+
recentMatches: Match[];
|
|
270
|
+
}
|
|
271
|
+
export interface Formation {
|
|
272
|
+
name: string;
|
|
273
|
+
defenders: number;
|
|
274
|
+
midfielders: number;
|
|
275
|
+
forwards: number;
|
|
276
|
+
}
|
|
277
|
+
export interface TacticalAnalysis {
|
|
278
|
+
homeFormation?: Formation;
|
|
279
|
+
awayFormation?: Formation;
|
|
280
|
+
homeStyle?: string;
|
|
281
|
+
awayStyle?: string;
|
|
282
|
+
keyBattles?: TacticalBattle[];
|
|
283
|
+
strengths?: {
|
|
284
|
+
home: string[];
|
|
285
|
+
away: string[];
|
|
286
|
+
};
|
|
287
|
+
weaknesses?: {
|
|
288
|
+
home: string[];
|
|
289
|
+
away: string[];
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
export interface TacticalBattle {
|
|
293
|
+
area: string;
|
|
294
|
+
homePlayer?: Player;
|
|
295
|
+
awayPlayer?: Player;
|
|
296
|
+
analysis: string;
|
|
297
|
+
advantage?: 'home' | 'away' | 'neutral';
|
|
298
|
+
}
|
|
299
|
+
export interface FatigueInfo {
|
|
300
|
+
team: Team;
|
|
301
|
+
daysSinceLastMatch: number;
|
|
302
|
+
lastMatch?: Match;
|
|
303
|
+
upcomingMatches?: Match[];
|
|
304
|
+
travelDistance?: number;
|
|
305
|
+
squadDepth?: number;
|
|
306
|
+
injuries: number;
|
|
307
|
+
suspensions: number;
|
|
308
|
+
fatigueScore: number;
|
|
309
|
+
}
|
|
310
|
+
export interface SetPieceStats {
|
|
311
|
+
team: Team;
|
|
312
|
+
cornersPerGame: number;
|
|
313
|
+
cornersConcededPerGame: number;
|
|
314
|
+
freeKicksPerGame: number;
|
|
315
|
+
goalsFromCorners: number;
|
|
316
|
+
goalsFromFreeKicks: number;
|
|
317
|
+
concededFromCorners: number;
|
|
318
|
+
concededFromFreeKicks: number;
|
|
319
|
+
aerialDuelsWon: number;
|
|
320
|
+
aerialDuelsTotal: number;
|
|
321
|
+
aerialWinRate: number;
|
|
322
|
+
}
|
|
323
|
+
export interface WatchlistAlert {
|
|
324
|
+
id: string;
|
|
325
|
+
type: 'match' | 'odds' | 'news' | 'injury';
|
|
326
|
+
target: string;
|
|
327
|
+
condition: string;
|
|
328
|
+
triggered: boolean;
|
|
329
|
+
createdAt: Date;
|
|
330
|
+
triggeredAt?: Date;
|
|
331
|
+
data?: any;
|
|
332
|
+
}
|
|
333
|
+
export interface CacheEntry<T = any> {
|
|
334
|
+
key: string;
|
|
335
|
+
data: T;
|
|
336
|
+
timestamp: number;
|
|
337
|
+
ttl: number;
|
|
338
|
+
hits: number;
|
|
339
|
+
}
|
|
340
|
+
export interface APIResponse<T = any> {
|
|
341
|
+
success: boolean;
|
|
342
|
+
data?: T;
|
|
343
|
+
error?: string;
|
|
344
|
+
provider?: ProviderType;
|
|
345
|
+
cached?: boolean;
|
|
346
|
+
rateLimited?: boolean;
|
|
347
|
+
}
|
|
348
|
+
export interface ProviderStatus {
|
|
349
|
+
name: ProviderType;
|
|
350
|
+
available: boolean;
|
|
351
|
+
quotaRemaining: number;
|
|
352
|
+
quotaLimit: number;
|
|
353
|
+
rateLimitUntil?: Date;
|
|
354
|
+
lastCall?: Date;
|
|
355
|
+
}
|
|
356
|
+
export interface ComparisonResult {
|
|
357
|
+
teamA: Team;
|
|
358
|
+
teamB: Team;
|
|
359
|
+
metrics: ComparisonMetric[];
|
|
360
|
+
winner?: 'A' | 'B' | 'draw';
|
|
361
|
+
summary: string;
|
|
362
|
+
}
|
|
363
|
+
export interface ComparisonMetric {
|
|
364
|
+
name: string;
|
|
365
|
+
teamAValue: number | string;
|
|
366
|
+
teamBValue: number | string;
|
|
367
|
+
winner?: 'A' | 'B' | 'draw';
|
|
368
|
+
importance: 'high' | 'medium' | 'low';
|
|
369
|
+
analysis?: string;
|
|
370
|
+
}
|
|
371
|
+
export interface LiveScoreUpdate {
|
|
372
|
+
matchId: string;
|
|
373
|
+
homeTeam: string;
|
|
374
|
+
awayTeam: string;
|
|
375
|
+
score: Score;
|
|
376
|
+
minute: number;
|
|
377
|
+
events: MatchEvent[];
|
|
378
|
+
timestamp: Date;
|
|
379
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPORTS MODULE INDEX
|
|
3
|
+
* Main entry point - Exports all sports functionality
|
|
4
|
+
*/
|
|
5
|
+
export * from './core/constants.js';
|
|
6
|
+
export * from './core/types.js';
|
|
7
|
+
export * from './core/cache.js';
|
|
8
|
+
export * from './core/base.js';
|
|
9
|
+
export * from './providers/api.js';
|
|
10
|
+
export * from './providers/scraper.js';
|
|
11
|
+
export * from './providers/search.js';
|
|
12
|
+
export { getGlobalCache, resetGlobalCache, CacheService, } from './core/cache.js';
|
|
13
|
+
export { createAPIProvider, } from './providers/api.js';
|
|
14
|
+
export { getSearchProvider, resetSearchProvider, SearchProvider, } from './providers/search.js';
|
|
15
|
+
export { scrapeMatchContent, findBestMatchUrl, } from './providers/scraper.js';
|
|
16
|
+
export * from './utils/calculator.js';
|
|
17
|
+
export * from './utils/formatter.js';
|
|
18
|
+
export { formatMatchesTable, formatComparisonResult, formatPlayerStats, formatMatchRow, formatScore, formatMatchStatus, formatHeadToHead, } from './utils/formatter.js';
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the sports module with custom configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare function initializeSportsModule(config?: {
|
|
23
|
+
cachePath?: string;
|
|
24
|
+
cacheTTL?: number;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get sports module status
|
|
28
|
+
*/
|
|
29
|
+
export declare function getSportsModuleStatus(): {
|
|
30
|
+
version: string;
|
|
31
|
+
providers: string[];
|
|
32
|
+
searchProviders: string[];
|
|
33
|
+
cacheEnabled: boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPORTS MODULE INDEX
|
|
3
|
+
* Main entry point - Exports all sports functionality
|
|
4
|
+
*/
|
|
5
|
+
// ============= Core Exports =============
|
|
6
|
+
export * from './core/constants.js';
|
|
7
|
+
export * from './core/types.js';
|
|
8
|
+
export * from './core/cache.js';
|
|
9
|
+
export * from './core/base.js';
|
|
10
|
+
// ============= Provider Exports =============
|
|
11
|
+
export * from './providers/api.js';
|
|
12
|
+
export * from './providers/scraper.js';
|
|
13
|
+
export * from './providers/search.js';
|
|
14
|
+
// Re-exports for convenience
|
|
15
|
+
export { getGlobalCache, resetGlobalCache, CacheService, } from './core/cache.js';
|
|
16
|
+
export { createAPIProvider, } from './providers/api.js';
|
|
17
|
+
export { getSearchProvider, resetSearchProvider, SearchProvider, } from './providers/search.js';
|
|
18
|
+
export { scrapeMatchContent, findBestMatchUrl, } from './providers/scraper.js';
|
|
19
|
+
// ============= Utility Exports =============
|
|
20
|
+
export * from './utils/calculator.js';
|
|
21
|
+
export * from './utils/formatter.js';
|
|
22
|
+
// Re-export specific utility functions for convenience
|
|
23
|
+
export { formatMatchesTable, formatComparisonResult, formatPlayerStats, formatMatchRow, formatScore, formatMatchStatus, formatHeadToHead, } from './utils/formatter.js';
|
|
24
|
+
// ============= Utility Functions =============
|
|
25
|
+
/**
|
|
26
|
+
* Initialize the sports module with custom configuration
|
|
27
|
+
*/
|
|
28
|
+
export async function initializeSportsModule(config) {
|
|
29
|
+
const { getGlobalCache } = await import('./core/cache.js');
|
|
30
|
+
// Initialize cache with config if provided
|
|
31
|
+
if (config?.cachePath || config?.cacheTTL) {
|
|
32
|
+
// Cache is already initialized, but we could add reconfiguration here
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get sports module status
|
|
37
|
+
*/
|
|
38
|
+
export function getSportsModuleStatus() {
|
|
39
|
+
const { MODULE_INFO } = require('./core/constants.js');
|
|
40
|
+
const apiProvider = require('./providers/api.js').createAPIProvider();
|
|
41
|
+
const searchProvider = require('./providers/search.js').getSearchProvider();
|
|
42
|
+
return {
|
|
43
|
+
version: MODULE_INFO.VERSION,
|
|
44
|
+
providers: apiProvider.getStatus().available
|
|
45
|
+
? ['api-football', 'football-data', 'sports-db'].filter((p) => process.env[`${p.replace('-', '_').toUpperCase()}_KEY`])
|
|
46
|
+
: [],
|
|
47
|
+
searchProviders: searchProvider.getAvailableProviders(),
|
|
48
|
+
cacheEnabled: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPORTS MODULE API PROVIDERS
|
|
3
|
+
* Concrete implementations of football API providers
|
|
4
|
+
*/
|
|
5
|
+
import { Match, Team, Player, TableEntry, APIResponse } from '../core/types.js';
|
|
6
|
+
import { APIProviderBase, FallbackProvider } from '../core/base.js';
|
|
7
|
+
/**
|
|
8
|
+
* API-Football Provider (via RapidAPI)
|
|
9
|
+
* Documentation: https://rapidapi.com/api-sports/api/api-football
|
|
10
|
+
*/
|
|
11
|
+
export declare class APIFootballProvider extends APIProviderBase {
|
|
12
|
+
constructor();
|
|
13
|
+
protected getAuthHeaders(): Record<string, string>;
|
|
14
|
+
protected transformResponse<T>(data: any): T;
|
|
15
|
+
getMatch(matchId: string): Promise<APIResponse<Match>>;
|
|
16
|
+
getLiveMatches(leagueId?: string): Promise<APIResponse<Match[]>>;
|
|
17
|
+
getStandings(leagueId: string, season?: string): Promise<APIResponse<TableEntry[]>>;
|
|
18
|
+
getTeam(teamId: string): Promise<APIResponse<Team>>;
|
|
19
|
+
getPlayer(playerId: string): Promise<APIResponse<Player>>;
|
|
20
|
+
searchTeams(query: string): Promise<APIResponse<Team[]>>;
|
|
21
|
+
searchPlayers(query: string): Promise<APIResponse<Player[]>>;
|
|
22
|
+
private transformMatch;
|
|
23
|
+
private transformTeam;
|
|
24
|
+
private transformPlayer;
|
|
25
|
+
private transformTableEntry;
|
|
26
|
+
private mapStatus;
|
|
27
|
+
private mapPosition;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Football-Data.org Provider
|
|
31
|
+
* Documentation: https://www.football-data.org/
|
|
32
|
+
*/
|
|
33
|
+
export declare class FootballDataProvider extends APIProviderBase {
|
|
34
|
+
constructor();
|
|
35
|
+
protected getAuthHeaders(): Record<string, string>;
|
|
36
|
+
protected transformResponse<T>(data: any): T;
|
|
37
|
+
getMatch(matchId: string): Promise<APIResponse<Match>>;
|
|
38
|
+
getLiveMatches(leagueId?: string): Promise<APIResponse<Match[]>>;
|
|
39
|
+
getStandings(leagueId: string, season?: string): Promise<APIResponse<TableEntry[]>>;
|
|
40
|
+
getTeam(teamId: string): Promise<APIResponse<Team>>;
|
|
41
|
+
getPlayer(playerId: string): Promise<APIResponse<Player>>;
|
|
42
|
+
searchTeams(query: string): Promise<APIResponse<Team[]>>;
|
|
43
|
+
searchPlayers(query: string): Promise<APIResponse<Player[]>>;
|
|
44
|
+
private transformMatchFD;
|
|
45
|
+
private transformTeamFD;
|
|
46
|
+
private transformTableEntryFD;
|
|
47
|
+
private mapStatusFD;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* TheSportsDB Provider
|
|
51
|
+
* Documentation: https://www.thesportsdb.com/api.php
|
|
52
|
+
*/
|
|
53
|
+
export declare class SportsDBProvider extends APIProviderBase {
|
|
54
|
+
constructor();
|
|
55
|
+
protected getAuthHeaders(): Record<string, string>;
|
|
56
|
+
protected transformResponse<T>(data: any): T;
|
|
57
|
+
getMatch(matchId: string): Promise<APIResponse<Match>>;
|
|
58
|
+
getLiveMatches(): Promise<APIResponse<Match[]>>;
|
|
59
|
+
getStandings(leagueId: string): Promise<APIResponse<TableEntry[]>>;
|
|
60
|
+
getTeam(teamId: string): Promise<APIResponse<Team>>;
|
|
61
|
+
getPlayer(playerId: string): Promise<APIResponse<Player>>;
|
|
62
|
+
searchTeams(query: string): Promise<APIResponse<Team[]>>;
|
|
63
|
+
searchPlayers(query: string): Promise<APIResponse<Player[]>>;
|
|
64
|
+
private transformMatchDB;
|
|
65
|
+
private transformTeamDB;
|
|
66
|
+
private transformPlayerDB;
|
|
67
|
+
private transformTableEntryDB;
|
|
68
|
+
private mapPositionDB;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a fallback provider with all available API providers
|
|
72
|
+
*/
|
|
73
|
+
export declare function createAPIProvider(): FallbackProvider;
|