@nukleus-sports/core 0.5.0 → 0.7.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/index.cjs +120 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -6
- package/dist/index.d.ts +31 -6
- package/dist/index.js +116 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -66,12 +66,15 @@ __export(src_exports, {
|
|
|
66
66
|
getSeasonTypeOptions: () => getSeasonTypeOptions,
|
|
67
67
|
getSeasonYearOptions: () => getSeasonYearOptions,
|
|
68
68
|
getStatRankingFootnotes: () => getStatRankingFootnotes,
|
|
69
|
+
getTeamConferenceInfo: () => getTeamConferenceInfo,
|
|
69
70
|
getTeamFacilityConfig: () => getTeamFacilityConfig,
|
|
70
71
|
getTeamFactsConfig: () => getTeamFactsConfig,
|
|
72
|
+
getTeamInitials: () => getTeamInitials,
|
|
71
73
|
getTeamPlaceSummaries: () => getTeamPlaceSummaries,
|
|
72
74
|
getTeamRankingConfigIds: () => getTeamRankingConfigIds,
|
|
73
75
|
getTeamStatColumns: () => getTeamStatColumns,
|
|
74
76
|
getTeamVenueConfig: () => getTeamVenueConfig,
|
|
77
|
+
getTeamWebsiteHref: () => getTeamWebsiteHref,
|
|
75
78
|
getVisibleTeamStatTypes: () => getVisibleTeamStatTypes,
|
|
76
79
|
hasTeamFacts: () => hasTeamFacts,
|
|
77
80
|
isGameBeforeDay: () => isGameBeforeDay,
|
|
@@ -86,6 +89,7 @@ __export(src_exports, {
|
|
|
86
89
|
resolveRecentGameOpponent: () => resolveRecentGameOpponent,
|
|
87
90
|
selectRecentGames: () => selectRecentGames,
|
|
88
91
|
showsTeamStatCategoryPicker: () => showsTeamStatCategoryPicker,
|
|
92
|
+
sortTeamPlayers: () => sortTeamPlayers,
|
|
89
93
|
sortTeamStaff: () => sortTeamStaff,
|
|
90
94
|
startOfLocalDay: () => startOfLocalDay,
|
|
91
95
|
teamFactsDisplayFields: () => teamFactsDisplayFields,
|
|
@@ -234,55 +238,9 @@ function computeSeasonSummary(games, espnId, leagueId) {
|
|
|
234
238
|
return { record, gamesPlayed: completedGames, totalGames };
|
|
235
239
|
}
|
|
236
240
|
|
|
237
|
-
// src/
|
|
238
|
-
var NFL_NBA_WNBA_LEAGUE_IDS = [1, 4, 5];
|
|
239
|
-
var MLB_NHL_LEAGUE_IDS = [7, 14];
|
|
240
|
-
var NCAAF_LEAGUE_IDS = [2, 13];
|
|
241
|
-
var NCAAM_LEAGUE_ID = 6;
|
|
241
|
+
// src/teamRosterFormat.ts
|
|
242
242
|
var MLS_LEAGUE_ID = 10;
|
|
243
243
|
var MLB_LEAGUE_ID = 7;
|
|
244
|
-
var BASE_COLUMNS = [
|
|
245
|
-
{ key: "first_name", label: "Name" },
|
|
246
|
-
{ key: "number", label: "No." },
|
|
247
|
-
{ key: "position", label: "Position" },
|
|
248
|
-
{ key: "height", label: "Height" },
|
|
249
|
-
{ key: "weight", label: "Weight" },
|
|
250
|
-
{ key: "age", label: "Age" }
|
|
251
|
-
];
|
|
252
|
-
function getRosterColumns(leagueId) {
|
|
253
|
-
if (NFL_NBA_WNBA_LEAGUE_IDS.includes(leagueId)) {
|
|
254
|
-
return [
|
|
255
|
-
...BASE_COLUMNS,
|
|
256
|
-
{ key: "experience", label: "Exp." },
|
|
257
|
-
{ key: "college", label: "College" }
|
|
258
|
-
];
|
|
259
|
-
}
|
|
260
|
-
if (MLB_NHL_LEAGUE_IDS.includes(leagueId)) {
|
|
261
|
-
return [
|
|
262
|
-
...BASE_COLUMNS,
|
|
263
|
-
{ key: "experience", label: "Exp" },
|
|
264
|
-
{ key: "birthplace", label: "Birthplace" }
|
|
265
|
-
];
|
|
266
|
-
}
|
|
267
|
-
if (NCAAF_LEAGUE_IDS.includes(leagueId)) {
|
|
268
|
-
return [
|
|
269
|
-
...BASE_COLUMNS,
|
|
270
|
-
{ key: "experience", label: "Class" },
|
|
271
|
-
{ key: "hometown", label: "Hometown" }
|
|
272
|
-
];
|
|
273
|
-
}
|
|
274
|
-
if (leagueId === NCAAM_LEAGUE_ID) {
|
|
275
|
-
return [
|
|
276
|
-
...BASE_COLUMNS,
|
|
277
|
-
{ key: "experience", label: "Class" },
|
|
278
|
-
{ key: "birthplace", label: "Birthplace" }
|
|
279
|
-
];
|
|
280
|
-
}
|
|
281
|
-
if (leagueId === MLS_LEAGUE_ID) {
|
|
282
|
-
return [...BASE_COLUMNS, { key: "birthplace", label: "Birthplace" }];
|
|
283
|
-
}
|
|
284
|
-
return [];
|
|
285
|
-
}
|
|
286
244
|
function calculateAge(birthDateString) {
|
|
287
245
|
const birthDate = new Date(birthDateString);
|
|
288
246
|
const today = /* @__PURE__ */ new Date();
|
|
@@ -333,6 +291,54 @@ function formatHometown(specificData) {
|
|
|
333
291
|
if (state) return state;
|
|
334
292
|
return "--";
|
|
335
293
|
}
|
|
294
|
+
|
|
295
|
+
// src/teamRosterColumns.ts
|
|
296
|
+
var NFL_NBA_WNBA_LEAGUE_IDS = [1, 4, 5];
|
|
297
|
+
var MLB_NHL_LEAGUE_IDS = [7, 14];
|
|
298
|
+
var NCAAF_LEAGUE_IDS = [2, 13];
|
|
299
|
+
var NCAAM_LEAGUE_ID = 6;
|
|
300
|
+
var BASE_COLUMNS = [
|
|
301
|
+
{ key: "first_name", label: "Name" },
|
|
302
|
+
{ key: "number", label: "No." },
|
|
303
|
+
{ key: "position", label: "Position" },
|
|
304
|
+
{ key: "height", label: "Height" },
|
|
305
|
+
{ key: "weight", label: "Weight" },
|
|
306
|
+
{ key: "age", label: "Age" }
|
|
307
|
+
];
|
|
308
|
+
function getRosterColumns(leagueId) {
|
|
309
|
+
if (NFL_NBA_WNBA_LEAGUE_IDS.includes(leagueId)) {
|
|
310
|
+
return [
|
|
311
|
+
...BASE_COLUMNS,
|
|
312
|
+
{ key: "experience", label: "Exp." },
|
|
313
|
+
{ key: "college", label: "College" }
|
|
314
|
+
];
|
|
315
|
+
}
|
|
316
|
+
if (MLB_NHL_LEAGUE_IDS.includes(leagueId)) {
|
|
317
|
+
return [
|
|
318
|
+
...BASE_COLUMNS,
|
|
319
|
+
{ key: "experience", label: "Exp" },
|
|
320
|
+
{ key: "birthplace", label: "Birthplace" }
|
|
321
|
+
];
|
|
322
|
+
}
|
|
323
|
+
if (NCAAF_LEAGUE_IDS.includes(leagueId)) {
|
|
324
|
+
return [
|
|
325
|
+
...BASE_COLUMNS,
|
|
326
|
+
{ key: "experience", label: "Class" },
|
|
327
|
+
{ key: "hometown", label: "Hometown" }
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
if (leagueId === NCAAM_LEAGUE_ID) {
|
|
331
|
+
return [
|
|
332
|
+
...BASE_COLUMNS,
|
|
333
|
+
{ key: "experience", label: "Class" },
|
|
334
|
+
{ key: "birthplace", label: "Birthplace" }
|
|
335
|
+
];
|
|
336
|
+
}
|
|
337
|
+
if (leagueId === MLS_LEAGUE_ID) {
|
|
338
|
+
return [...BASE_COLUMNS, { key: "birthplace", label: "Birthplace" }];
|
|
339
|
+
}
|
|
340
|
+
return [];
|
|
341
|
+
}
|
|
336
342
|
function getRosterCellValue(player, columnKey, leagueId) {
|
|
337
343
|
switch (columnKey) {
|
|
338
344
|
case "first_name":
|
|
@@ -416,10 +422,13 @@ function getTeamPlaceSummaries(specificData, leagueAbbreviation) {
|
|
|
416
422
|
function formatTeamName(team, nickname) {
|
|
417
423
|
return [team, nickname].map((part) => part?.trim()).filter(Boolean).join(" ");
|
|
418
424
|
}
|
|
425
|
+
function getTeamWebsiteHref(officialWebsite) {
|
|
426
|
+
return /^https?:\/\//i.test(officialWebsite) ? officialWebsite : `http://${officialWebsite}`;
|
|
427
|
+
}
|
|
419
428
|
|
|
420
|
-
// src/
|
|
421
|
-
var EMPTY_VALUES = /* @__PURE__ */ new Set(["", "-"]);
|
|
422
|
-
function
|
|
429
|
+
// src/compareSortValues.ts
|
|
430
|
+
var EMPTY_VALUES = /* @__PURE__ */ new Set(["", "-", "--"]);
|
|
431
|
+
function compareSortValues(left, right, desc) {
|
|
423
432
|
const leftMissing = typeof left === "string" && EMPTY_VALUES.has(left);
|
|
424
433
|
const rightMissing = typeof right === "string" && EMPTY_VALUES.has(right);
|
|
425
434
|
if (leftMissing && rightMissing) return 0;
|
|
@@ -431,6 +440,8 @@ function compareValues(left, right, desc) {
|
|
|
431
440
|
}
|
|
432
441
|
return String(left).localeCompare(String(right), void 0, { numeric: true, sensitivity: "base" }) * direction;
|
|
433
442
|
}
|
|
443
|
+
|
|
444
|
+
// src/teamStaffSort.ts
|
|
434
445
|
function sortTeamStaff(staff, sorting) {
|
|
435
446
|
const activeSort = sorting[0];
|
|
436
447
|
if (!activeSort) return staff;
|
|
@@ -445,10 +456,53 @@ function sortTeamStaff(staff, sorting) {
|
|
|
445
456
|
return member.display_order;
|
|
446
457
|
}
|
|
447
458
|
};
|
|
448
|
-
return
|
|
459
|
+
return compareSortValues(value(left), value(right), activeSort.desc);
|
|
449
460
|
});
|
|
450
461
|
}
|
|
451
462
|
|
|
463
|
+
// src/teamRosterSort.ts
|
|
464
|
+
function sortValue(player, columnId, leagueId) {
|
|
465
|
+
const data = player.specific_data;
|
|
466
|
+
switch (columnId) {
|
|
467
|
+
case "first_name":
|
|
468
|
+
return [player.first_name, player.last_name].filter(Boolean).join(" ");
|
|
469
|
+
case "number": {
|
|
470
|
+
if (player.number === null || player.number === void 0 || player.number === "") return "-";
|
|
471
|
+
return Number.parseInt(String(player.number), 10) || String(player.number);
|
|
472
|
+
}
|
|
473
|
+
case "position":
|
|
474
|
+
return player.position ?? "-";
|
|
475
|
+
case "height":
|
|
476
|
+
return String(data?.height ?? "-");
|
|
477
|
+
case "weight":
|
|
478
|
+
return Number(data?.weight) || "-";
|
|
479
|
+
case "age":
|
|
480
|
+
return data?.birth_date ? calculateAge(data.birth_date) : "-";
|
|
481
|
+
case "experience":
|
|
482
|
+
if (player.experience === "0") return 0;
|
|
483
|
+
return Number(player.experience) || player.experience || "-";
|
|
484
|
+
case "college":
|
|
485
|
+
return String(data?.college_name ?? "-");
|
|
486
|
+
case "birthplace":
|
|
487
|
+
return formatBirthplace(data ?? null, leagueId ?? 0);
|
|
488
|
+
case "hometown":
|
|
489
|
+
return formatHometown(data ?? null);
|
|
490
|
+
default:
|
|
491
|
+
return "-";
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function sortTeamPlayers(players, sorting, leagueId) {
|
|
495
|
+
const activeSort = sorting[0];
|
|
496
|
+
if (!activeSort) return players;
|
|
497
|
+
return [...players].sort(
|
|
498
|
+
(left, right) => compareSortValues(
|
|
499
|
+
sortValue(left, activeSort.id, leagueId),
|
|
500
|
+
sortValue(right, activeSort.id, leagueId),
|
|
501
|
+
activeSort.desc
|
|
502
|
+
)
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
452
506
|
// src/teamSeasonStats.ts
|
|
453
507
|
var FOOTBALL_TEAM_STAT_IDS = {
|
|
454
508
|
PASSING_YARDS: 255,
|
|
@@ -1457,6 +1511,17 @@ function buildRecentGameRows({
|
|
|
1457
1511
|
};
|
|
1458
1512
|
});
|
|
1459
1513
|
}
|
|
1514
|
+
|
|
1515
|
+
// src/teamHeader.ts
|
|
1516
|
+
function getTeamInitials(team) {
|
|
1517
|
+
const words = team?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
1518
|
+
if (words.length === 0) return "T";
|
|
1519
|
+
return words.length > 1 ? words[0][0] + words[1][0] : words[0].substring(0, 2);
|
|
1520
|
+
}
|
|
1521
|
+
function getTeamConferenceInfo(conference, division) {
|
|
1522
|
+
if (!conference && !division) return "Conference - Division";
|
|
1523
|
+
return `${conference || ""} ${division || ""}`.trim();
|
|
1524
|
+
}
|
|
1460
1525
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1461
1526
|
0 && (module.exports = {
|
|
1462
1527
|
BASEBALL_TEAM_STAT_IDS,
|
|
@@ -1505,12 +1570,15 @@ function buildRecentGameRows({
|
|
|
1505
1570
|
getSeasonTypeOptions,
|
|
1506
1571
|
getSeasonYearOptions,
|
|
1507
1572
|
getStatRankingFootnotes,
|
|
1573
|
+
getTeamConferenceInfo,
|
|
1508
1574
|
getTeamFacilityConfig,
|
|
1509
1575
|
getTeamFactsConfig,
|
|
1576
|
+
getTeamInitials,
|
|
1510
1577
|
getTeamPlaceSummaries,
|
|
1511
1578
|
getTeamRankingConfigIds,
|
|
1512
1579
|
getTeamStatColumns,
|
|
1513
1580
|
getTeamVenueConfig,
|
|
1581
|
+
getTeamWebsiteHref,
|
|
1514
1582
|
getVisibleTeamStatTypes,
|
|
1515
1583
|
hasTeamFacts,
|
|
1516
1584
|
isGameBeforeDay,
|
|
@@ -1525,6 +1593,7 @@ function buildRecentGameRows({
|
|
|
1525
1593
|
resolveRecentGameOpponent,
|
|
1526
1594
|
selectRecentGames,
|
|
1527
1595
|
showsTeamStatCategoryPicker,
|
|
1596
|
+
sortTeamPlayers,
|
|
1528
1597
|
sortTeamStaff,
|
|
1529
1598
|
startOfLocalDay,
|
|
1530
1599
|
teamFactsDisplayFields,
|