cricinfo-cli-go 0.1.1 → 0.1.4
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/internal/cli/matches.go +126 -2
- package/internal/cli/matches_test.go +82 -0
- package/internal/cli/search.go +156 -0
- package/internal/cricinfo/analysis.go +393 -93
- package/internal/cricinfo/analysis_phase15_test.go +38 -0
- package/internal/cricinfo/client.go +23 -2
- package/internal/cricinfo/coverage_ledger_test.go +2 -22
- package/internal/cricinfo/entity_index.go +27 -0
- package/internal/cricinfo/historical_hydration.go +82 -42
- package/internal/cricinfo/matches.go +1641 -88
- package/internal/cricinfo/matches_phase7_test.go +11 -4
- package/internal/cricinfo/normalize_entities.go +83 -35
- package/internal/cricinfo/players.go +236 -2
- package/internal/cricinfo/render_contract.go +191 -49
- package/internal/cricinfo/renderer.go +613 -19
- package/internal/cricinfo/resolver.go +134 -13
- package/internal/cricinfo/teams.go +109 -6
- package/internal/cricinfo/testdata/coverage/cricinfo-field-path-catalog.txt +2536 -0
- package/internal/cricinfo/testdata/coverage/cricinfo-working-templates.tsv +56 -0
- package/package.json +1 -1
|
@@ -16,6 +16,8 @@ const (
|
|
|
16
16
|
EntityMatch EntityKind = "match"
|
|
17
17
|
EntityMatchScorecard EntityKind = "match_scorecard"
|
|
18
18
|
EntityMatchSituation EntityKind = "match_situation"
|
|
19
|
+
EntityMatchDuel EntityKind = "match_duel"
|
|
20
|
+
EntityMatchPhases EntityKind = "match_phases"
|
|
19
21
|
EntityCompetition EntityKind = "competition"
|
|
20
22
|
EntityCompOfficial EntityKind = "competition_official"
|
|
21
23
|
EntityCompBroadcast EntityKind = "competition_broadcast"
|
|
@@ -118,6 +120,43 @@ type MatchScorecard struct {
|
|
|
118
120
|
Extensions map[string]any `json:"extensions,omitempty"`
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
// MatchPhases is a fan-oriented phase/momentum breakdown for each innings.
|
|
124
|
+
type MatchPhases struct {
|
|
125
|
+
MatchID string `json:"matchId,omitempty"`
|
|
126
|
+
LeagueID string `json:"leagueId,omitempty"`
|
|
127
|
+
EventID string `json:"eventId,omitempty"`
|
|
128
|
+
CompetitionID string `json:"competitionId,omitempty"`
|
|
129
|
+
Fixture string `json:"fixture,omitempty"`
|
|
130
|
+
Result string `json:"result,omitempty"`
|
|
131
|
+
Innings []MatchPhaseInning `json:"innings,omitempty"`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// MatchPhaseInning captures phase splits and momentum points for one innings.
|
|
135
|
+
type MatchPhaseInning struct {
|
|
136
|
+
TeamID string `json:"teamId,omitempty"`
|
|
137
|
+
TeamName string `json:"teamName,omitempty"`
|
|
138
|
+
InningsNumber int `json:"inningsNumber,omitempty"`
|
|
139
|
+
Period int `json:"period,omitempty"`
|
|
140
|
+
Score string `json:"score,omitempty"`
|
|
141
|
+
Target int `json:"target,omitempty"`
|
|
142
|
+
Powerplay PhaseSummary `json:"powerplay,omitempty"`
|
|
143
|
+
Middle PhaseSummary `json:"middle,omitempty"`
|
|
144
|
+
Death PhaseSummary `json:"death,omitempty"`
|
|
145
|
+
BestScoringOver int `json:"bestScoringOver,omitempty"`
|
|
146
|
+
BestScoringOverRuns int `json:"bestScoringOverRuns,omitempty"`
|
|
147
|
+
CollapseOver int `json:"collapseOver,omitempty"`
|
|
148
|
+
CollapseWickets int `json:"collapseWickets,omitempty"`
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// PhaseSummary is a normalized run/wicket split across a phase bucket.
|
|
152
|
+
type PhaseSummary struct {
|
|
153
|
+
Name string `json:"name,omitempty"`
|
|
154
|
+
Runs int `json:"runs,omitempty"`
|
|
155
|
+
Wickets int `json:"wickets,omitempty"`
|
|
156
|
+
Overs float64 `json:"overs,omitempty"`
|
|
157
|
+
RunRate float64 `json:"runRate,omitempty"`
|
|
158
|
+
}
|
|
159
|
+
|
|
121
160
|
// BattingCard is a normalized batting card section from matchcards.
|
|
122
161
|
type BattingCard struct {
|
|
123
162
|
InningsNumber int `json:"inningsNumber,omitempty"`
|
|
@@ -188,9 +227,78 @@ type MatchSituation struct {
|
|
|
188
227
|
MatchID string `json:"matchId,omitempty"`
|
|
189
228
|
OddsRef string `json:"oddsRef,omitempty"`
|
|
190
229
|
Data map[string]any `json:"data,omitempty"`
|
|
230
|
+
Live *MatchLiveView `json:"live,omitempty"`
|
|
191
231
|
Extensions map[string]any `json:"extensions,omitempty"`
|
|
192
232
|
}
|
|
193
233
|
|
|
234
|
+
// MatchLiveView is a synthesized fan-first live snapshot when upstream situation payload is sparse.
|
|
235
|
+
type MatchLiveView struct {
|
|
236
|
+
Fixture string `json:"fixture,omitempty"`
|
|
237
|
+
Status string `json:"status,omitempty"`
|
|
238
|
+
Score string `json:"score,omitempty"`
|
|
239
|
+
Overs string `json:"overs,omitempty"`
|
|
240
|
+
CurrentOver int `json:"currentOver,omitempty"`
|
|
241
|
+
BallInOver int `json:"ballInOver,omitempty"`
|
|
242
|
+
BattingTeam string `json:"battingTeam,omitempty"`
|
|
243
|
+
BowlingTeam string `json:"bowlingTeam,omitempty"`
|
|
244
|
+
Batters []LiveBatterView `json:"batters,omitempty"`
|
|
245
|
+
Bowlers []LiveBowlerView `json:"bowlers,omitempty"`
|
|
246
|
+
RecentBalls []DeliveryEvent `json:"recentBalls,omitempty"`
|
|
247
|
+
CurrentBalls []DeliveryEvent `json:"currentOverBalls,omitempty"`
|
|
248
|
+
LastDetailID string `json:"lastDetailId,omitempty"`
|
|
249
|
+
LastUpdateMS int64 `json:"lastUpdateMs,omitempty"`
|
|
250
|
+
SnapshotAt string `json:"snapshotAt,omitempty"`
|
|
251
|
+
SourceRoute string `json:"sourceRoute,omitempty"`
|
|
252
|
+
Stale bool `json:"stale"`
|
|
253
|
+
StaleReason string `json:"staleReason,omitempty"`
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// LiveBatterView captures in-progress batter figures.
|
|
257
|
+
type LiveBatterView struct {
|
|
258
|
+
PlayerID string `json:"playerId,omitempty"`
|
|
259
|
+
PlayerName string `json:"playerName,omitempty"`
|
|
260
|
+
Runs int `json:"runs,omitempty"`
|
|
261
|
+
Balls int `json:"balls,omitempty"`
|
|
262
|
+
Fours int `json:"fours,omitempty"`
|
|
263
|
+
Sixes int `json:"sixes,omitempty"`
|
|
264
|
+
StrikeRate float64 `json:"strikeRate,omitempty"`
|
|
265
|
+
OnStrike bool `json:"onStrike"`
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// LiveBowlerView captures in-progress bowler figures.
|
|
269
|
+
type LiveBowlerView struct {
|
|
270
|
+
PlayerID string `json:"playerId,omitempty"`
|
|
271
|
+
PlayerName string `json:"playerName,omitempty"`
|
|
272
|
+
Overs float64 `json:"overs,omitempty"`
|
|
273
|
+
Balls int `json:"balls,omitempty"`
|
|
274
|
+
Maidens int `json:"maidens,omitempty"`
|
|
275
|
+
Conceded int `json:"conceded,omitempty"`
|
|
276
|
+
Wickets int `json:"wickets,omitempty"`
|
|
277
|
+
Economy float64 `json:"economy,omitempty"`
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// MatchDuel summarizes a batter-vs-bowler matchup in one match.
|
|
281
|
+
type MatchDuel struct {
|
|
282
|
+
MatchID string `json:"matchId,omitempty"`
|
|
283
|
+
Fixture string `json:"fixture,omitempty"`
|
|
284
|
+
Score string `json:"score,omitempty"`
|
|
285
|
+
BatterID string `json:"batterId,omitempty"`
|
|
286
|
+
BatterName string `json:"batterName,omitempty"`
|
|
287
|
+
BowlerID string `json:"bowlerId,omitempty"`
|
|
288
|
+
BowlerName string `json:"bowlerName,omitempty"`
|
|
289
|
+
Balls int `json:"balls,omitempty"`
|
|
290
|
+
Runs int `json:"runs,omitempty"`
|
|
291
|
+
Dots int `json:"dots,omitempty"`
|
|
292
|
+
Fours int `json:"fours,omitempty"`
|
|
293
|
+
Sixes int `json:"sixes,omitempty"`
|
|
294
|
+
Wickets int `json:"wickets,omitempty"`
|
|
295
|
+
StrikeRate float64 `json:"strikeRate,omitempty"`
|
|
296
|
+
RecentBalls []DeliveryEvent `json:"recentBalls,omitempty"`
|
|
297
|
+
LastUpdateMS int64 `json:"lastUpdateMs,omitempty"`
|
|
298
|
+
SnapshotAt string `json:"snapshotAt,omitempty"`
|
|
299
|
+
SourceRoute string `json:"sourceRoute,omitempty"`
|
|
300
|
+
}
|
|
301
|
+
|
|
194
302
|
// Competition is the normalized competition metadata root view.
|
|
195
303
|
type Competition struct {
|
|
196
304
|
Ref string `json:"ref,omitempty"`
|
|
@@ -450,6 +558,7 @@ type TeamRosterEntry struct {
|
|
|
450
558
|
PlayerRef string `json:"playerRef,omitempty"`
|
|
451
559
|
DisplayName string `json:"displayName,omitempty"`
|
|
452
560
|
TeamID string `json:"teamId,omitempty"`
|
|
561
|
+
TeamName string `json:"teamName,omitempty"`
|
|
453
562
|
TeamRef string `json:"teamRef,omitempty"`
|
|
454
563
|
MatchID string `json:"matchId,omitempty"`
|
|
455
564
|
Scope TeamScope `json:"scope,omitempty"`
|
|
@@ -654,43 +763,67 @@ type InningsWicket struct {
|
|
|
654
763
|
|
|
655
764
|
// DeliveryEvent is the normalized ball-level event shape.
|
|
656
765
|
type DeliveryEvent struct {
|
|
657
|
-
Ref
|
|
658
|
-
ID
|
|
659
|
-
LeagueID
|
|
660
|
-
EventID
|
|
661
|
-
CompetitionID
|
|
662
|
-
MatchID
|
|
663
|
-
TeamID
|
|
664
|
-
Period
|
|
665
|
-
PeriodText
|
|
666
|
-
OverNumber
|
|
667
|
-
BallNumber
|
|
668
|
-
ScoreValue
|
|
669
|
-
ShortText
|
|
670
|
-
Text
|
|
671
|
-
HomeScore
|
|
672
|
-
AwayScore
|
|
673
|
-
BatsmanRef
|
|
674
|
-
BowlerRef
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
766
|
+
Ref string `json:"ref,omitempty"`
|
|
767
|
+
ID string `json:"id,omitempty"`
|
|
768
|
+
LeagueID string `json:"leagueId,omitempty"`
|
|
769
|
+
EventID string `json:"eventId,omitempty"`
|
|
770
|
+
CompetitionID string `json:"competitionId,omitempty"`
|
|
771
|
+
MatchID string `json:"matchId,omitempty"`
|
|
772
|
+
TeamID string `json:"teamId,omitempty"`
|
|
773
|
+
Period int `json:"period,omitempty"`
|
|
774
|
+
PeriodText string `json:"periodText,omitempty"`
|
|
775
|
+
OverNumber int `json:"overNumber,omitempty"`
|
|
776
|
+
BallNumber int `json:"ballNumber,omitempty"`
|
|
777
|
+
ScoreValue int `json:"scoreValue,omitempty"`
|
|
778
|
+
ShortText string `json:"shortText,omitempty"`
|
|
779
|
+
Text string `json:"text,omitempty"`
|
|
780
|
+
HomeScore string `json:"homeScore,omitempty"`
|
|
781
|
+
AwayScore string `json:"awayScore,omitempty"`
|
|
782
|
+
BatsmanRef string `json:"batsmanRef,omitempty"`
|
|
783
|
+
BowlerRef string `json:"bowlerRef,omitempty"`
|
|
784
|
+
OtherBatsmanRef string `json:"otherBatsmanRef,omitempty"`
|
|
785
|
+
OtherBowlerRef string `json:"otherBowlerRef,omitempty"`
|
|
786
|
+
BatsmanPlayerID string `json:"batsmanPlayerId,omitempty"`
|
|
787
|
+
BowlerPlayerID string `json:"bowlerPlayerId,omitempty"`
|
|
788
|
+
OtherBatsmanID string `json:"otherBatsmanPlayerId,omitempty"`
|
|
789
|
+
OtherBowlerID string `json:"otherBowlerPlayerId,omitempty"`
|
|
790
|
+
FielderPlayerID string `json:"fielderPlayerId,omitempty"`
|
|
791
|
+
AthletePlayerIDs []string `json:"athletePlayerIds,omitempty"`
|
|
792
|
+
Involvement []string `json:"involvement,omitempty"`
|
|
793
|
+
BatsmanRuns int `json:"batsmanRuns,omitempty"`
|
|
794
|
+
BatsmanTotalRuns int `json:"batsmanTotalRuns,omitempty"`
|
|
795
|
+
BatsmanBalls int `json:"batsmanBalls,omitempty"`
|
|
796
|
+
BatsmanFours int `json:"batsmanFours,omitempty"`
|
|
797
|
+
BatsmanSixes int `json:"batsmanSixes,omitempty"`
|
|
798
|
+
OtherBatterRuns int `json:"otherBatterRuns,omitempty"`
|
|
799
|
+
OtherBatterBalls int `json:"otherBatterBalls,omitempty"`
|
|
800
|
+
OtherBatterFours int `json:"otherBatterFours,omitempty"`
|
|
801
|
+
OtherBatterSixes int `json:"otherBatterSixes,omitempty"`
|
|
802
|
+
BowlerOvers float64 `json:"bowlerOvers,omitempty"`
|
|
803
|
+
BowlerBalls int `json:"bowlerBalls,omitempty"`
|
|
804
|
+
BowlerMaidens int `json:"bowlerMaidens,omitempty"`
|
|
805
|
+
BowlerConceded int `json:"bowlerConceded,omitempty"`
|
|
806
|
+
BowlerWickets int `json:"bowlerWickets,omitempty"`
|
|
807
|
+
OtherBowlerOvers float64 `json:"otherBowlerOvers,omitempty"`
|
|
808
|
+
OtherBowlerBalls int `json:"otherBowlerBalls,omitempty"`
|
|
809
|
+
OtherBowlerMaidens int `json:"otherBowlerMaidens,omitempty"`
|
|
810
|
+
OtherBowlerConceded int `json:"otherBowlerConceded,omitempty"`
|
|
811
|
+
OtherBowlerWickets int `json:"otherBowlerWickets,omitempty"`
|
|
812
|
+
Sequence int `json:"sequence,omitempty"`
|
|
813
|
+
PlayType map[string]any `json:"playType,omitempty"`
|
|
814
|
+
Dismissal map[string]any `json:"dismissal,omitempty"`
|
|
815
|
+
DismissalType string `json:"dismissalType,omitempty"`
|
|
816
|
+
DismissalName string `json:"dismissalName,omitempty"`
|
|
817
|
+
DismissalCard string `json:"dismissalCard,omitempty"`
|
|
818
|
+
DismissalText string `json:"dismissalText,omitempty"`
|
|
819
|
+
SpeedKPH float64 `json:"speedKPH,omitempty"`
|
|
820
|
+
XCoordinate *float64 `json:"xCoordinate"`
|
|
821
|
+
YCoordinate *float64 `json:"yCoordinate"`
|
|
822
|
+
BBBTimestamp int64 `json:"bbbTimestamp"`
|
|
823
|
+
CoordinateX *float64 `json:"coordinateX,omitempty"`
|
|
824
|
+
CoordinateY *float64 `json:"coordinateY,omitempty"`
|
|
825
|
+
Timestamp int64 `json:"timestamp,omitempty"`
|
|
826
|
+
Extensions map[string]any `json:"extensions,omitempty"`
|
|
694
827
|
}
|
|
695
828
|
|
|
696
829
|
// StatCategory is the normalized grouped statistics shape.
|
|
@@ -774,18 +907,18 @@ type FallOfWicket struct {
|
|
|
774
907
|
|
|
775
908
|
// AnalysisScope captures the resolved analysis traversal scope.
|
|
776
909
|
type AnalysisScope struct {
|
|
777
|
-
Mode
|
|
778
|
-
RequestedLeagueID string
|
|
779
|
-
LeagueID
|
|
780
|
-
LeagueName
|
|
781
|
-
Seasons
|
|
782
|
-
MatchIDs
|
|
783
|
-
MatchCount
|
|
784
|
-
DateFrom
|
|
785
|
-
DateTo
|
|
786
|
-
TypeQuery
|
|
787
|
-
GroupQuery
|
|
788
|
-
HydrationMetric
|
|
910
|
+
Mode string `json:"mode"`
|
|
911
|
+
RequestedLeagueID string `json:"requestedLeagueId,omitempty"`
|
|
912
|
+
LeagueID string `json:"leagueId,omitempty"`
|
|
913
|
+
LeagueName string `json:"leagueName,omitempty"`
|
|
914
|
+
Seasons []string `json:"seasons,omitempty"`
|
|
915
|
+
MatchIDs []string `json:"matchIds,omitempty"`
|
|
916
|
+
MatchCount int `json:"matchCount"`
|
|
917
|
+
DateFrom string `json:"dateFrom,omitempty"`
|
|
918
|
+
DateTo string `json:"dateTo,omitempty"`
|
|
919
|
+
TypeQuery string `json:"type,omitempty"`
|
|
920
|
+
GroupQuery string `json:"group,omitempty"`
|
|
921
|
+
HydrationMetric HydrationMetrics `json:"hydrationMetrics,omitempty"`
|
|
789
922
|
}
|
|
790
923
|
|
|
791
924
|
// AnalysisFilters captures user-level row filters.
|
|
@@ -924,6 +1057,10 @@ func kindPlural(kind EntityKind) string {
|
|
|
924
1057
|
return "match scorecards"
|
|
925
1058
|
case EntityMatchSituation:
|
|
926
1059
|
return "match situations"
|
|
1060
|
+
case EntityMatchDuel:
|
|
1061
|
+
return "match duels"
|
|
1062
|
+
case EntityMatchPhases:
|
|
1063
|
+
return "match phase reports"
|
|
927
1064
|
case EntityCompetition:
|
|
928
1065
|
return "competitions"
|
|
929
1066
|
case EntityCompOfficial:
|
|
@@ -999,11 +1136,16 @@ func kindPlural(kind EntityKind) string {
|
|
|
999
1136
|
|
|
1000
1137
|
func compactWarnings(warnings []string) []string {
|
|
1001
1138
|
out := make([]string, 0, len(warnings))
|
|
1139
|
+
seen := map[string]struct{}{}
|
|
1002
1140
|
for _, warning := range warnings {
|
|
1003
1141
|
warning = strings.TrimSpace(warning)
|
|
1004
1142
|
if warning == "" {
|
|
1005
1143
|
continue
|
|
1006
1144
|
}
|
|
1145
|
+
if _, ok := seen[warning]; ok {
|
|
1146
|
+
continue
|
|
1147
|
+
}
|
|
1148
|
+
seen[warning] = struct{}{}
|
|
1007
1149
|
out = append(out, warning)
|
|
1008
1150
|
}
|
|
1009
1151
|
if len(out) == 0 {
|