bbdata-cli 0.1.0
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/dist/bin/bbdata.d.ts +2 -0
- package/dist/bin/bbdata.js +1952 -0
- package/dist/bin/bbdata.js.map +1 -0
- package/dist/src/index.d.ts +347 -0
- package/dist/src/index.js +1857 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +63 -0
- package/src/cache/schema.sql +34 -0
- package/src/templates/reports/advance-lineup.hbs +29 -0
- package/src/templates/reports/advance-sp.hbs +60 -0
- package/src/templates/reports/college-hitter-draft.hbs +49 -0
- package/src/templates/reports/college-pitcher-draft.hbs +48 -0
- package/src/templates/reports/dev-progress.hbs +29 -0
- package/src/templates/reports/draft-board-card.hbs +35 -0
- package/src/templates/reports/hs-prospect.hbs +48 -0
- package/src/templates/reports/partials/footer.hbs +7 -0
- package/src/templates/reports/partials/header.hbs +12 -0
- package/src/templates/reports/post-promotion.hbs +25 -0
- package/src/templates/reports/pro-hitter-eval.hbs +65 -0
- package/src/templates/reports/pro-pitcher-eval.hbs +69 -0
- package/src/templates/reports/relief-pitcher-quick.hbs +29 -0
- package/src/templates/reports/trade-target-onepager.hbs +45 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type OutputFormat = 'json' | 'table' | 'csv' | 'markdown';
|
|
4
|
+
|
|
5
|
+
interface QueryOptions {
|
|
6
|
+
template: string;
|
|
7
|
+
player?: string;
|
|
8
|
+
players?: string;
|
|
9
|
+
team?: string;
|
|
10
|
+
season?: number;
|
|
11
|
+
stat?: string;
|
|
12
|
+
pitchType?: string;
|
|
13
|
+
minPa?: number;
|
|
14
|
+
minIp?: number;
|
|
15
|
+
top?: number;
|
|
16
|
+
seasons?: string;
|
|
17
|
+
format?: OutputFormat;
|
|
18
|
+
source?: string;
|
|
19
|
+
cache?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface QueryResult {
|
|
22
|
+
data: Record<string, unknown>[];
|
|
23
|
+
formatted: string;
|
|
24
|
+
meta: {
|
|
25
|
+
template: string;
|
|
26
|
+
source: string;
|
|
27
|
+
cached: boolean;
|
|
28
|
+
rowCount: number;
|
|
29
|
+
season: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Programmatic API — skills and agents call this directly.
|
|
34
|
+
*/
|
|
35
|
+
declare function query(options: QueryOptions): Promise<QueryResult>;
|
|
36
|
+
|
|
37
|
+
type Audience = 'coach' | 'gm' | 'scout' | 'analyst';
|
|
38
|
+
|
|
39
|
+
interface ReportOptions {
|
|
40
|
+
template: string;
|
|
41
|
+
player?: string;
|
|
42
|
+
team?: string;
|
|
43
|
+
season?: number;
|
|
44
|
+
audience?: Audience;
|
|
45
|
+
format?: 'markdown' | 'json';
|
|
46
|
+
validate?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface ReportResult {
|
|
49
|
+
content: string;
|
|
50
|
+
formatted: string;
|
|
51
|
+
validation?: ValidationResult;
|
|
52
|
+
meta: {
|
|
53
|
+
template: string;
|
|
54
|
+
player: string;
|
|
55
|
+
audience: Audience;
|
|
56
|
+
season: number;
|
|
57
|
+
dataSources: string[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
interface ValidationResult {
|
|
61
|
+
passed: boolean;
|
|
62
|
+
issues: {
|
|
63
|
+
severity: 'error' | 'warning';
|
|
64
|
+
message: string;
|
|
65
|
+
}[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Programmatic API — skills and agents call this directly.
|
|
69
|
+
*/
|
|
70
|
+
declare function report(options: ReportOptions): Promise<ReportResult>;
|
|
71
|
+
|
|
72
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
73
|
+
defaultTeam: z.ZodOptional<z.ZodString>;
|
|
74
|
+
defaultFormat: z.ZodDefault<z.ZodEnum<["json", "table", "csv", "markdown"]>>;
|
|
75
|
+
defaultAudience: z.ZodDefault<z.ZodEnum<["coach", "gm", "scout", "analyst"]>>;
|
|
76
|
+
cache: z.ZodDefault<z.ZodObject<{
|
|
77
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
maxAgeDays: z.ZodDefault<z.ZodNumber>;
|
|
79
|
+
directory: z.ZodDefault<z.ZodString>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
maxAgeDays: number;
|
|
83
|
+
directory: string;
|
|
84
|
+
}, {
|
|
85
|
+
enabled?: boolean | undefined;
|
|
86
|
+
maxAgeDays?: number | undefined;
|
|
87
|
+
directory?: string | undefined;
|
|
88
|
+
}>>;
|
|
89
|
+
templates: z.ZodDefault<z.ZodObject<{
|
|
90
|
+
directory: z.ZodDefault<z.ZodString>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
directory: string;
|
|
93
|
+
}, {
|
|
94
|
+
directory?: string | undefined;
|
|
95
|
+
}>>;
|
|
96
|
+
sources: z.ZodDefault<z.ZodObject<{
|
|
97
|
+
savant: z.ZodDefault<z.ZodObject<{
|
|
98
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
}, {
|
|
102
|
+
enabled?: boolean | undefined;
|
|
103
|
+
}>>;
|
|
104
|
+
fangraphs: z.ZodDefault<z.ZodObject<{
|
|
105
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
}, {
|
|
109
|
+
enabled?: boolean | undefined;
|
|
110
|
+
}>>;
|
|
111
|
+
mlbStatsApi: z.ZodDefault<z.ZodObject<{
|
|
112
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
enabled: boolean;
|
|
115
|
+
}, {
|
|
116
|
+
enabled?: boolean | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
baseballReference: z.ZodDefault<z.ZodObject<{
|
|
119
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
}, {
|
|
123
|
+
enabled?: boolean | undefined;
|
|
124
|
+
}>>;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
savant: {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
};
|
|
129
|
+
fangraphs: {
|
|
130
|
+
enabled: boolean;
|
|
131
|
+
};
|
|
132
|
+
mlbStatsApi: {
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
};
|
|
135
|
+
baseballReference: {
|
|
136
|
+
enabled: boolean;
|
|
137
|
+
};
|
|
138
|
+
}, {
|
|
139
|
+
savant?: {
|
|
140
|
+
enabled?: boolean | undefined;
|
|
141
|
+
} | undefined;
|
|
142
|
+
fangraphs?: {
|
|
143
|
+
enabled?: boolean | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
mlbStatsApi?: {
|
|
146
|
+
enabled?: boolean | undefined;
|
|
147
|
+
} | undefined;
|
|
148
|
+
baseballReference?: {
|
|
149
|
+
enabled?: boolean | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
}>>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
defaultFormat: "json" | "table" | "csv" | "markdown";
|
|
154
|
+
defaultAudience: "coach" | "gm" | "scout" | "analyst";
|
|
155
|
+
cache: {
|
|
156
|
+
enabled: boolean;
|
|
157
|
+
maxAgeDays: number;
|
|
158
|
+
directory: string;
|
|
159
|
+
};
|
|
160
|
+
templates: {
|
|
161
|
+
directory: string;
|
|
162
|
+
};
|
|
163
|
+
sources: {
|
|
164
|
+
savant: {
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
};
|
|
167
|
+
fangraphs: {
|
|
168
|
+
enabled: boolean;
|
|
169
|
+
};
|
|
170
|
+
mlbStatsApi: {
|
|
171
|
+
enabled: boolean;
|
|
172
|
+
};
|
|
173
|
+
baseballReference: {
|
|
174
|
+
enabled: boolean;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
defaultTeam?: string | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
defaultTeam?: string | undefined;
|
|
180
|
+
defaultFormat?: "json" | "table" | "csv" | "markdown" | undefined;
|
|
181
|
+
defaultAudience?: "coach" | "gm" | "scout" | "analyst" | undefined;
|
|
182
|
+
cache?: {
|
|
183
|
+
enabled?: boolean | undefined;
|
|
184
|
+
maxAgeDays?: number | undefined;
|
|
185
|
+
directory?: string | undefined;
|
|
186
|
+
} | undefined;
|
|
187
|
+
templates?: {
|
|
188
|
+
directory?: string | undefined;
|
|
189
|
+
} | undefined;
|
|
190
|
+
sources?: {
|
|
191
|
+
savant?: {
|
|
192
|
+
enabled?: boolean | undefined;
|
|
193
|
+
} | undefined;
|
|
194
|
+
fangraphs?: {
|
|
195
|
+
enabled?: boolean | undefined;
|
|
196
|
+
} | undefined;
|
|
197
|
+
mlbStatsApi?: {
|
|
198
|
+
enabled?: boolean | undefined;
|
|
199
|
+
} | undefined;
|
|
200
|
+
baseballReference?: {
|
|
201
|
+
enabled?: boolean | undefined;
|
|
202
|
+
} | undefined;
|
|
203
|
+
} | undefined;
|
|
204
|
+
}>;
|
|
205
|
+
type BbdataConfig = z.infer<typeof ConfigSchema>;
|
|
206
|
+
|
|
207
|
+
declare function getConfig(): BbdataConfig;
|
|
208
|
+
declare function setConfig(updates: Partial<BbdataConfig>): BbdataConfig;
|
|
209
|
+
|
|
210
|
+
type DataSource = 'savant' | 'fangraphs' | 'mlb-stats-api' | 'baseball-reference';
|
|
211
|
+
declare const PitchDataSchema: z.ZodObject<{
|
|
212
|
+
pitcher_id: z.ZodString;
|
|
213
|
+
pitcher_name: z.ZodString;
|
|
214
|
+
batter_id: z.ZodString;
|
|
215
|
+
batter_name: z.ZodString;
|
|
216
|
+
game_date: z.ZodString;
|
|
217
|
+
pitch_type: z.ZodString;
|
|
218
|
+
release_speed: z.ZodNumber;
|
|
219
|
+
release_spin_rate: z.ZodNumber;
|
|
220
|
+
pfx_x: z.ZodNumber;
|
|
221
|
+
pfx_z: z.ZodNumber;
|
|
222
|
+
plate_x: z.ZodNumber;
|
|
223
|
+
plate_z: z.ZodNumber;
|
|
224
|
+
launch_speed: z.ZodNullable<z.ZodNumber>;
|
|
225
|
+
launch_angle: z.ZodNullable<z.ZodNumber>;
|
|
226
|
+
description: z.ZodString;
|
|
227
|
+
events: z.ZodNullable<z.ZodString>;
|
|
228
|
+
bb_type: z.ZodNullable<z.ZodString>;
|
|
229
|
+
stand: z.ZodEnum<["L", "R"]>;
|
|
230
|
+
p_throws: z.ZodEnum<["L", "R"]>;
|
|
231
|
+
estimated_ba: z.ZodNullable<z.ZodNumber>;
|
|
232
|
+
estimated_woba: z.ZodNullable<z.ZodNumber>;
|
|
233
|
+
}, "strip", z.ZodTypeAny, {
|
|
234
|
+
pitcher_id: string;
|
|
235
|
+
pitcher_name: string;
|
|
236
|
+
batter_id: string;
|
|
237
|
+
batter_name: string;
|
|
238
|
+
game_date: string;
|
|
239
|
+
pitch_type: string;
|
|
240
|
+
release_speed: number;
|
|
241
|
+
release_spin_rate: number;
|
|
242
|
+
pfx_x: number;
|
|
243
|
+
pfx_z: number;
|
|
244
|
+
plate_x: number;
|
|
245
|
+
plate_z: number;
|
|
246
|
+
launch_speed: number | null;
|
|
247
|
+
launch_angle: number | null;
|
|
248
|
+
description: string;
|
|
249
|
+
events: string | null;
|
|
250
|
+
bb_type: string | null;
|
|
251
|
+
stand: "L" | "R";
|
|
252
|
+
p_throws: "L" | "R";
|
|
253
|
+
estimated_ba: number | null;
|
|
254
|
+
estimated_woba: number | null;
|
|
255
|
+
}, {
|
|
256
|
+
pitcher_id: string;
|
|
257
|
+
pitcher_name: string;
|
|
258
|
+
batter_id: string;
|
|
259
|
+
batter_name: string;
|
|
260
|
+
game_date: string;
|
|
261
|
+
pitch_type: string;
|
|
262
|
+
release_speed: number;
|
|
263
|
+
release_spin_rate: number;
|
|
264
|
+
pfx_x: number;
|
|
265
|
+
pfx_z: number;
|
|
266
|
+
plate_x: number;
|
|
267
|
+
plate_z: number;
|
|
268
|
+
launch_speed: number | null;
|
|
269
|
+
launch_angle: number | null;
|
|
270
|
+
description: string;
|
|
271
|
+
events: string | null;
|
|
272
|
+
bb_type: string | null;
|
|
273
|
+
stand: "L" | "R";
|
|
274
|
+
p_throws: "L" | "R";
|
|
275
|
+
estimated_ba: number | null;
|
|
276
|
+
estimated_woba: number | null;
|
|
277
|
+
}>;
|
|
278
|
+
type PitchData = z.infer<typeof PitchDataSchema>;
|
|
279
|
+
declare const PlayerStatsSchema: z.ZodObject<{
|
|
280
|
+
player_id: z.ZodString;
|
|
281
|
+
player_name: z.ZodString;
|
|
282
|
+
team: z.ZodString;
|
|
283
|
+
season: z.ZodNumber;
|
|
284
|
+
stat_type: z.ZodEnum<["batting", "pitching", "fielding"]>;
|
|
285
|
+
stats: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodNull]>>;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
player_id: string;
|
|
288
|
+
player_name: string;
|
|
289
|
+
team: string;
|
|
290
|
+
season: number;
|
|
291
|
+
stat_type: "batting" | "pitching" | "fielding";
|
|
292
|
+
stats: Record<string, string | number | null>;
|
|
293
|
+
}, {
|
|
294
|
+
player_id: string;
|
|
295
|
+
player_name: string;
|
|
296
|
+
team: string;
|
|
297
|
+
season: number;
|
|
298
|
+
stat_type: "batting" | "pitching" | "fielding";
|
|
299
|
+
stats: Record<string, string | number | null>;
|
|
300
|
+
}>;
|
|
301
|
+
type PlayerStats = z.infer<typeof PlayerStatsSchema>;
|
|
302
|
+
interface PlayerId {
|
|
303
|
+
mlbam_id: string;
|
|
304
|
+
fangraphs_id?: string;
|
|
305
|
+
bbref_id?: string;
|
|
306
|
+
name: string;
|
|
307
|
+
team?: string;
|
|
308
|
+
position?: string;
|
|
309
|
+
}
|
|
310
|
+
interface AdapterQuery {
|
|
311
|
+
player_name?: string;
|
|
312
|
+
player_id?: string;
|
|
313
|
+
team?: string;
|
|
314
|
+
season: number;
|
|
315
|
+
start_date?: string;
|
|
316
|
+
end_date?: string;
|
|
317
|
+
stat_type: 'batting' | 'pitching' | 'fielding';
|
|
318
|
+
pitch_type?: string[];
|
|
319
|
+
min_pa?: number;
|
|
320
|
+
min_ip?: number;
|
|
321
|
+
metrics?: string[];
|
|
322
|
+
}
|
|
323
|
+
interface AdapterResult<T = PitchData[] | PlayerStats[]> {
|
|
324
|
+
data: T;
|
|
325
|
+
source: DataSource;
|
|
326
|
+
cached: boolean;
|
|
327
|
+
fetchedAt: string;
|
|
328
|
+
meta: {
|
|
329
|
+
rowCount: number;
|
|
330
|
+
season: number;
|
|
331
|
+
query: AdapterQuery;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
interface DataAdapter {
|
|
335
|
+
readonly source: DataSource;
|
|
336
|
+
readonly description: string;
|
|
337
|
+
/** Can this adapter service this query type? */
|
|
338
|
+
supports(query: AdapterQuery): boolean;
|
|
339
|
+
/** Fetch data, checking cache first */
|
|
340
|
+
fetch(query: AdapterQuery, options?: {
|
|
341
|
+
bypassCache?: boolean;
|
|
342
|
+
}): Promise<AdapterResult>;
|
|
343
|
+
/** Resolve a player name to this source's ID */
|
|
344
|
+
resolvePlayer(name: string): Promise<PlayerId | null>;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export { type AdapterQuery, type BbdataConfig, type DataAdapter, type OutputFormat, type PitchData, type PlayerStats, type QueryOptions, type QueryResult, type ReportOptions, type ReportResult, getConfig, query, report, setConfig };
|