nhl-api-ts 0.0.0-stage → 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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +295 -2
  3. package/dist/api/edge.d.mts +179 -0
  4. package/dist/api/edge.mjs +184 -0
  5. package/dist/api/game-center.d.mts +83 -0
  6. package/dist/api/game-center.mjs +74 -0
  7. package/dist/api/helpers.d.mts +46 -0
  8. package/dist/api/helpers.mjs +106 -0
  9. package/dist/api/misc.d.mts +40 -0
  10. package/dist/api/misc.mjs +43 -0
  11. package/dist/api/players.d.mts +27 -0
  12. package/dist/api/players.mjs +18 -0
  13. package/dist/api/query/builder.d.mts +20 -0
  14. package/dist/api/query/builder.mjs +28 -0
  15. package/dist/api/query/errors.d.mts +3 -0
  16. package/dist/api/query/errors.mjs +6 -0
  17. package/dist/api/query/filters/base.d.mts +4 -0
  18. package/dist/api/query/filters/base.mjs +2 -0
  19. package/dist/api/query/filters/decision.d.mts +13 -0
  20. package/dist/api/query/filters/decision.mjs +26 -0
  21. package/dist/api/query/filters/draft.d.mts +15 -0
  22. package/dist/api/query/filters/draft.mjs +27 -0
  23. package/dist/api/query/filters/experience.d.mts +9 -0
  24. package/dist/api/query/filters/experience.mjs +17 -0
  25. package/dist/api/query/filters/franchise.d.mts +9 -0
  26. package/dist/api/query/filters/franchise.mjs +15 -0
  27. package/dist/api/query/filters/game-type.d.mts +10 -0
  28. package/dist/api/query/filters/game-type.mjs +16 -0
  29. package/dist/api/query/filters/goalie-sorts.d.mts +3 -0
  30. package/dist/api/query/filters/goalie-sorts.mjs +55 -0
  31. package/dist/api/query/filters/home-road.d.mts +9 -0
  32. package/dist/api/query/filters/home-road.mjs +16 -0
  33. package/dist/api/query/filters/index.d.mts +14 -0
  34. package/dist/api/query/filters/index.mjs +14 -0
  35. package/dist/api/query/filters/nationality.d.mts +12 -0
  36. package/dist/api/query/filters/nationality.mjs +19 -0
  37. package/dist/api/query/filters/opponent.d.mts +10 -0
  38. package/dist/api/query/filters/opponent.mjs +16 -0
  39. package/dist/api/query/filters/position.d.mts +16 -0
  40. package/dist/api/query/filters/position.mjs +28 -0
  41. package/dist/api/query/filters/season.d.mts +14 -0
  42. package/dist/api/query/filters/season.mjs +24 -0
  43. package/dist/api/query/filters/shoot-catch.d.mts +9 -0
  44. package/dist/api/query/filters/shoot-catch.mjs +16 -0
  45. package/dist/api/query/filters/status.d.mts +20 -0
  46. package/dist/api/query/filters/status.mjs +28 -0
  47. package/dist/api/query/filters.d.mts +93 -0
  48. package/dist/api/query/filters.mjs +118 -0
  49. package/dist/api/query/index.d.mts +4 -0
  50. package/dist/api/query/index.mjs +4 -0
  51. package/dist/api/query/sorting/goalie-sorts.d.mts +6 -0
  52. package/dist/api/query/sorting/goalie-sorts.mjs +59 -0
  53. package/dist/api/query/sorting/sorting-options.d.mts +11 -0
  54. package/dist/api/query/sorting/sorting-options.mjs +93 -0
  55. package/dist/api/schedule.d.mts +116 -0
  56. package/dist/api/schedule.mjs +131 -0
  57. package/dist/api/standings.d.mts +28 -0
  58. package/dist/api/standings.mjs +38 -0
  59. package/dist/api/stats.d.mts +148 -0
  60. package/dist/api/stats.mjs +148 -0
  61. package/dist/api/teams.d.mts +58 -0
  62. package/dist/api/teams.mjs +91 -0
  63. package/dist/cli/colors.d.mts +14 -0
  64. package/dist/cli/colors.mjs +13 -0
  65. package/dist/cli/commands.d.mts +27 -0
  66. package/dist/cli/commands.mjs +695 -0
  67. package/dist/cli/run.d.mts +9 -0
  68. package/dist/cli/run.mjs +313 -0
  69. package/dist/cli.d.mts +2 -0
  70. package/dist/cli.mjs +13 -0
  71. package/dist/config.d.mts +20 -0
  72. package/dist/config.mjs +4 -0
  73. package/dist/context.d.mts +6 -0
  74. package/dist/context.mjs +1 -0
  75. package/dist/errors.d.mts +35 -0
  76. package/dist/errors.mjs +49 -0
  77. package/dist/http-client.d.mts +27 -0
  78. package/dist/http-client.mjs +95 -0
  79. package/dist/index.d.mts +21 -0
  80. package/dist/index.mjs +15 -0
  81. package/dist/logging.d.mts +14 -0
  82. package/dist/logging.mjs +13 -0
  83. package/dist/nhl-client.d.mts +97 -0
  84. package/dist/nhl-client.mjs +40 -0
  85. package/dist/utils.d.mts +5 -0
  86. package/dist/utils.mjs +3 -0
  87. package/package.json +77 -3
@@ -0,0 +1,97 @@
1
+ import { type ClientOptions } from '#src/config.mjs';
2
+ import type { Context } from '#src/context.mjs';
3
+ type Bound<Module> = {
4
+ [Method in keyof Module]: Module[Method] extends (ctx: Context, ...args: infer Args) => infer MethodResponse ? (...args: Args) => MethodResponse : never;
5
+ };
6
+ /**
7
+ * Builds the main client used to access the NHL API.
8
+ *
9
+ * @example
10
+ * const client = createNHLClient();
11
+ * const client = createNHLClient({ debug: true }); // for a lil extra logging
12
+ * const teams = await client.teams.teams();
13
+ */
14
+ export declare const createNHLClient: (options?: ClientOptions) => {
15
+ readonly config: Readonly<import("#src/config.mjs").Config>;
16
+ readonly teams: Bound<{
17
+ readonly teams: typeof import("#src/api/teams.mjs").teams;
18
+ readonly teamRoster: typeof import("#src/api/teams.mjs").teamRoster;
19
+ readonly franchises: typeof import("#src/api/teams.mjs").franchises;
20
+ }>;
21
+ readonly standings: Bound<{
22
+ readonly leagueStandings: typeof import("#src/api/standings.mjs").leagueStandings;
23
+ readonly seasonStandingManifest: typeof import("#src/api/standings.mjs").seasonStandingManifest;
24
+ }>;
25
+ readonly schedule: Bound<{
26
+ readonly dailySchedule: typeof import("#src/api/schedule.mjs").dailySchedule;
27
+ readonly weeklySchedule: typeof import("#src/api/schedule.mjs").weeklySchedule;
28
+ readonly teamMonthlySchedule: typeof import("#src/api/schedule.mjs").teamMonthlySchedule;
29
+ readonly teamWeeklySchedule: typeof import("#src/api/schedule.mjs").teamWeeklySchedule;
30
+ readonly teamSeasonSchedule: typeof import("#src/api/schedule.mjs").teamSeasonSchedule;
31
+ readonly calendarSchedule: typeof import("#src/api/schedule.mjs").calendarSchedule;
32
+ readonly playoffCarousel: typeof import("#src/api/schedule.mjs").playoffCarousel;
33
+ readonly playoffSeriesSchedule: typeof import("#src/api/schedule.mjs").playoffSeriesSchedule;
34
+ readonly playoffBracket: typeof import("#src/api/schedule.mjs").playoffBracket;
35
+ }>;
36
+ readonly gameCenter: Bound<{
37
+ readonly boxscore: typeof import("#src/api/game-center.mjs").boxscore;
38
+ readonly playByPlay: typeof import("#src/api/game-center.mjs").playByPlay;
39
+ readonly matchUp: typeof import("#src/api/game-center.mjs").matchUp;
40
+ readonly dailyScores: typeof import("#src/api/game-center.mjs").dailyScores;
41
+ readonly shiftChartData: typeof import("#src/api/game-center.mjs").shiftChartData;
42
+ readonly seasonSeriesMatchup: typeof import("#src/api/game-center.mjs").seasonSeriesMatchup;
43
+ readonly gameStory: typeof import("#src/api/game-center.mjs").gameStory;
44
+ }>;
45
+ readonly stats: Bound<{
46
+ readonly gametypesPerSeasonDirectoryByTeam: typeof import("#src/api/stats.mjs").gametypesPerSeasonDirectoryByTeam;
47
+ readonly playerCareerStats: typeof import("#src/api/stats.mjs").playerCareerStats;
48
+ readonly playerGameLog: typeof import("#src/api/stats.mjs").playerGameLog;
49
+ readonly teamSummary: typeof import("#src/api/stats.mjs").teamSummary;
50
+ readonly skaterStatsSummary: typeof import("#src/api/stats.mjs").skaterStatsSummary;
51
+ readonly skaterStatsWithQueryContext: typeof import("#src/api/stats.mjs").skaterStatsWithQueryContext;
52
+ readonly goalieStatsSummary: typeof import("#src/api/stats.mjs").goalieStatsSummary;
53
+ }>;
54
+ readonly misc: Bound<{
55
+ readonly glossary: typeof import("#src/api/misc.mjs").glossary;
56
+ readonly config: typeof import("#src/api/misc.mjs").config;
57
+ readonly countries: typeof import("#src/api/misc.mjs").countries;
58
+ readonly seasonSpecificRulesAndInfo: typeof import("#src/api/misc.mjs").seasonSpecificRulesAndInfo;
59
+ readonly draftYearAndRounds: typeof import("#src/api/misc.mjs").draftYearAndRounds;
60
+ }>;
61
+ readonly helpers: Bound<{
62
+ readonly gameIdsBySeason: typeof import("#src/api/helpers.mjs").gameIdsBySeason;
63
+ readonly allPlayers: typeof import("#src/api/helpers.mjs").allPlayers;
64
+ readonly allPlayersSummaryStatistics: typeof import("#src/api/helpers.mjs").allPlayersSummaryStatistics;
65
+ }>;
66
+ readonly players: Bound<{
67
+ readonly prospectsByTeam: typeof import("#src/api/players.mjs").prospectsByTeam;
68
+ readonly playersByTeam: typeof import("#src/api/players.mjs").playersByTeam;
69
+ }>;
70
+ readonly edge: Bound<{
71
+ readonly skaterDetail: typeof import("#src/api/edge.mjs").skaterDetail;
72
+ readonly skaterShotSpeedDetail: typeof import("#src/api/edge.mjs").skaterShotSpeedDetail;
73
+ readonly skaterSkatingSpeedDetail: typeof import("#src/api/edge.mjs").skaterSkatingSpeedDetail;
74
+ readonly skaterShotLocationDetail: typeof import("#src/api/edge.mjs").skaterShotLocationDetail;
75
+ readonly skaterSkatingDistanceDetail: typeof import("#src/api/edge.mjs").skaterSkatingDistanceDetail;
76
+ readonly skaterComparison: typeof import("#src/api/edge.mjs").skaterComparison;
77
+ readonly skaterZoneTime: typeof import("#src/api/edge.mjs").skaterZoneTime;
78
+ readonly skaterLanding: typeof import("#src/api/edge.mjs").skaterLanding;
79
+ readonly catSkaterDetail: typeof import("#src/api/edge.mjs").catSkaterDetail;
80
+ readonly goalieDetail: typeof import("#src/api/edge.mjs").goalieDetail;
81
+ readonly goalieShotLocationDetail: typeof import("#src/api/edge.mjs").goalieShotLocationDetail;
82
+ readonly goalie5v5Detail: typeof import("#src/api/edge.mjs").goalie5v5Detail;
83
+ readonly goalieComparison: typeof import("#src/api/edge.mjs").goalieComparison;
84
+ readonly goalieSavePercentageDetail: typeof import("#src/api/edge.mjs").goalieSavePercentageDetail;
85
+ readonly goalieLanding: typeof import("#src/api/edge.mjs").goalieLanding;
86
+ readonly catGoalieDetail: typeof import("#src/api/edge.mjs").catGoalieDetail;
87
+ readonly teamDetail: typeof import("#src/api/edge.mjs").teamDetail;
88
+ readonly teamSkatingDistanceDetail: typeof import("#src/api/edge.mjs").teamSkatingDistanceDetail;
89
+ readonly teamZoneTimeDetails: typeof import("#src/api/edge.mjs").teamZoneTimeDetails;
90
+ readonly teamShotLocationDetail: typeof import("#src/api/edge.mjs").teamShotLocationDetail;
91
+ readonly teamLanding: typeof import("#src/api/edge.mjs").teamLanding;
92
+ readonly teamShotSpeedDetail: typeof import("#src/api/edge.mjs").teamShotSpeedDetail;
93
+ readonly teamSkatingSpeedDetail: typeof import("#src/api/edge.mjs").teamSkatingSpeedDetail;
94
+ }>;
95
+ };
96
+ export type NHLClient = ReturnType<typeof createNHLClient>;
97
+ export {};
@@ -0,0 +1,40 @@
1
+ import { edgeApi } from '#src/api/edge.mjs';
2
+ import { gameCenterApi } from '#src/api/game-center.mjs';
3
+ import { helpersApi } from '#src/api/helpers.mjs';
4
+ import { miscApi } from '#src/api/misc.mjs';
5
+ import { playersApi } from '#src/api/players.mjs';
6
+ import { scheduleApi } from '#src/api/schedule.mjs';
7
+ import { standingsApi } from '#src/api/standings.mjs';
8
+ import { statsApi } from '#src/api/stats.mjs';
9
+ import { teamsApi } from '#src/api/teams.mjs';
10
+ import { resolveConfig } from '#src/config.mjs';
11
+ import { createGet } from '#src/http-client.mjs';
12
+ import { sleep } from '#src/utils.mjs';
13
+ const bind = (ctx, api) => Object.fromEntries(Object.entries(api).map(([key, fn]) => [
14
+ key,
15
+ (...args) => fn(ctx, ...args),
16
+ ]));
17
+ /**
18
+ * Builds the main client used to access the NHL API.
19
+ *
20
+ * @example
21
+ * const client = createNHLClient();
22
+ * const client = createNHLClient({ debug: true }); // for a lil extra logging
23
+ * const teams = await client.teams.teams();
24
+ */
25
+ export const createNHLClient = (options = {}) => {
26
+ const config = resolveConfig(options);
27
+ const ctx = { get: createGet(config), sleep };
28
+ return {
29
+ config,
30
+ teams: bind(ctx, teamsApi),
31
+ standings: bind(ctx, standingsApi),
32
+ schedule: bind(ctx, scheduleApi),
33
+ gameCenter: bind(ctx, gameCenterApi),
34
+ stats: bind(ctx, statsApi),
35
+ misc: bind(ctx, miscApi),
36
+ helpers: bind(ctx, helpersApi),
37
+ players: bind(ctx, playersApi),
38
+ edge: bind(ctx, edgeApi),
39
+ };
40
+ };
@@ -0,0 +1,5 @@
1
+ /** Identifiers accepted by the API: player ids, game ids, seasons, etc. */
2
+ export type Id = string | number;
3
+ export type JsonObject = Record<string, any>;
4
+ /** Sleeps for the given number of seconds. */
5
+ export declare const sleep: (seconds: number) => Promise<void>;
package/dist/utils.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { setTimeout as delay } from 'node:timers/promises';
2
+ /** Sleeps for the given number of seconds. */
3
+ export const sleep = (seconds) => delay(seconds * 1000);
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
1
  {
2
2
  "name": "nhl-api-ts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK and CLI for the NHL API and NHL EDGE stats.",
5
+ "keywords": [
6
+ "nhl",
7
+ "api",
8
+ "hockey",
9
+ "sports",
10
+ "edge",
11
+ "stats",
12
+ "sdk",
13
+ "cli"
14
+ ],
15
+ "author": "andrewangelle@gmail.com",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/andrewangelle/nhl-api-ts.git"
20
+ },
21
+ "type": "module",
22
+ "sideEffects": false,
23
+ "main": "dist/index.mjs",
24
+ "types": "dist/index.d.mts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.mts",
28
+ "default": "./dist/index.mjs"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "imports": {
33
+ "#src/*.mjs": {
34
+ "source": "./src/*.mts",
35
+ "types": "./dist/*.d.mts",
36
+ "default": "./dist/*.mjs"
37
+ }
38
+ },
39
+ "bin": {
40
+ "nhl-api-ts": "dist/cli.mjs"
41
+ },
42
+ "engines": {
43
+ "node": ">=24.0.0"
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "devDependencies": {
49
+ "@biomejs/biome": "^2.5.15",
50
+ "@changesets/changelog-github": "^1.0.1",
51
+ "@changesets/cli": "^3.0.3",
52
+ "@microsoft/api-extractor": "^7.59.4",
53
+ "@types/node": "^26.2.0",
54
+ "husky": "^9.1.7",
55
+ "lint-staged": "^17.3.0",
56
+ "typescript": "^7.0.2"
57
+ },
58
+ "lint-staged": {
59
+ "*.{ts,tsx,js,jsx,mts,mjs}": [
60
+ "pnpm lint:fix",
61
+ "pnpm format"
62
+ ]
63
+ },
64
+ "scripts": {
65
+ "build": "pnpm exec tsc",
66
+ "test": "node --conditions=source --test \"test/**/*.test.mts\"",
67
+ "test:update-snapshots": "node --conditions=source --test --test-update-snapshots \"test/**/*.test.mts\"",
68
+ "lint:fix": "pnpm exec biome check . --write",
69
+ "lint:check": "pnpm exec biome check .",
70
+ "format": "pnpm exec biome format . --write",
71
+ "pre-commit": "lint-staged",
72
+ "changeset": "changeset",
73
+ "version-packages": "changeset version",
74
+ "release": "pnpm build && changeset publish",
75
+ "typecheck": "pnpm exec tsc --noEmit",
76
+ "typecheck:examples": "pnpm exec tsc -p examples",
77
+ "api:report": "pnpm build && mkdir -p node_modules/.api-extractor && pnpm exec api-extractor run --local && cp node_modules/.api-extractor/nhl-api-ts.api.md api-report.md",
78
+ "docs:llms": "node scripts/build-llms-full.mts"
79
+ }
6
80
  }