@databallr/sdk 0.3.2 → 0.3.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/dist/errors.d.ts CHANGED
@@ -3,8 +3,7 @@ interface DataballrErrorFields {
3
3
  /**
4
4
  * The shared envelope's `error` in UPPER_SNAKE (`INVALID_TOKEN`,
5
5
  * `INSUFFICIENT_SCOPE`, `RATE_LIMITED`, ...), or `HTTP_ERROR` when the body
6
- * is not that envelope. An older lowercase spelling from the API reads the
7
- * same.
6
+ * is not that envelope.
8
7
  */
9
8
  readonly code: string;
10
9
  /** The envelope's `type` (`validation`, `rate_limited`, `unavailable`, ...), when the API sends one. */
package/dist/errors.js CHANGED
@@ -19,7 +19,7 @@ export function errorFromResponse(response, text) {
19
19
  }
20
20
  catch { }
21
21
  const envelope = isEnvelope(body) ? body : undefined;
22
- const code = envelope ? wireCode(envelope.error) : "HTTP_ERROR";
22
+ const code = envelope ? envelope.error : "HTTP_ERROR";
23
23
  return new DataballrError(stringOrUndefined(envelope?.message) ??
24
24
  (envelope ? code : `Request failed with status ${response.status}`), {
25
25
  status: response.status,
@@ -32,10 +32,6 @@ export function errorFromResponse(response, text) {
32
32
  body,
33
33
  });
34
34
  }
35
- const LOWER_SNAKE_RE = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
36
- function wireCode(error) {
37
- return LOWER_SNAKE_RE.test(error) ? error.toUpperCase() : error;
38
- }
39
35
  function secondsFromRetryAfter(header) {
40
36
  if (header === null)
41
37
  return undefined;
@@ -1,5 +1,5 @@
1
1
  /** First 12 hex characters of the SHA-256 of the key-callable spec these files came from. */
2
- export declare const SPEC_HASH = "1f310d89facc";
2
+ export declare const SPEC_HASH = "16658e571a15";
3
3
  /**
4
4
  * Every generated method: GET operations by path, POST queries as
5
5
  * `POST <path>`. `Databallr` turns this table into `dbr.nba.players.search(...)`.
@@ -1,4 +1,4 @@
1
- export const SPEC_HASH = "1f310d89facc";
1
+ export const SPEC_HASH = "16658e571a15";
2
2
  export const methods = {
3
3
  apps: {
4
4
  sixrings: {
@@ -3088,13 +3088,26 @@ export interface components {
3088
3088
  /** @description YYYY-MM-DD */
3089
3089
  end_date?: string;
3090
3090
  exclude_garbage_time?: boolean;
3091
+ /** @description Only games in which every one of these players was on the floor, for either team. A game-level choice: the game counts whole or not at all. Listed in the manifest's options as `games_with`. */
3092
+ games_with?: number[];
3093
+ /** @description Only games in which none of these players was on the floor: the games a player missed. Unlike `players_off`, which keeps his games and drops his minutes. Listed in the manifest's options as `games_without`. */
3094
+ games_without?: number[];
3091
3095
  /** @description Also return the detail counters (possession start origin, turnover and foul types, rebounds by shot type, assists by type and zone, per-player possession phase). Off by default: on the lineup-stints fast path they need a second file read. */
3092
3096
  include_detail?: boolean;
3097
+ /** @description Also return `game_log` (one line per counted game: what the filters kept of it and its final score) and `record` (wins and losses in the games the filters touched). Listed in the manifest's options as `include_games`. */
3098
+ include_games?: boolean;
3099
+ /** @description Only possessions at these leverage levels: how much the possession's result can move the offense's win probability (cuts at 0.02, 0.055 and 0.10; about 25%, 70%, 4% and 1% of possessions). NBA only. Answered from the plays (the engine path). Listed in the manifest's options as `leverage`. */
3100
+ leverage?: ("low" | "medium" | "high" | "very_high")[];
3093
3101
  /**
3094
3102
  * @description Only the team's home or away games, from its game logs. A neutral site (the 2020 bubble, Cup finals, international games) counts for the NBA's designated home team. A game the logs do not list is left out and counted in quality.location_unknown_games. Listed in the manifest's options as `location`.
3095
3103
  * @enum {string}
3096
3104
  */
3097
3105
  location?: "home" | "away";
3106
+ /** @description Only possessions the team started leading by min to max points (negative: trailing); either end may be left out. {min: -5, max: 5} is within five either way. Decided per possession from the score before its first play. Answered from the plays (the engine path), not the lineup-stints fast path. Listed in the manifest's options as `margin`. */
3107
+ margin?: {
3108
+ max?: number;
3109
+ min?: number;
3110
+ };
3098
3111
  /** @description Only games in these calendar months (1-12), in any of the seasons: [12] is every December. Listed in the manifest's options as `months`. */
3099
3112
  months?: number[];
3100
3113
  opp_filter?: {
@@ -3121,7 +3134,7 @@ export interface components {
3121
3134
  * @enum {string}
3122
3135
  */
3123
3136
  season_type?: "regular" | "playoffs";
3124
- /** @description 1-5 seasons. Defaults to ["2025-26"]. */
3137
+ /** @description 1-10 seasons when the lineup-stints fast path answers; 1-5 with `margin`, `leverage` or a `time_range` that starts or ends inside a period (those read every game's plays), and 1-5 with `include_detail`. Defaults to ["2025-26"]. */
3125
3138
  seasons?: (string | number)[] | (string | number);
3126
3139
  /** @description YYYY-MM-DD */
3127
3140
  start_date?: string;
@@ -3146,6 +3159,13 @@ export interface components {
3146
3159
  };
3147
3160
  };
3148
3161
  NbaPbpAnalyticsResponse: {
3162
+ /** @description With `include_games`: one line per counted game, oldest first, as columns (game_id, date, opponent, seconds, off_poss, def_poss, points, opp_points, team_score, opp_score, won). seconds, possessions and points are what the filters kept; the scores are the game's final. */
3163
+ game_log?: {
3164
+ columns: {
3165
+ [key: string]: (number | string | boolean | (null))[];
3166
+ };
3167
+ rows: number;
3168
+ };
3149
3169
  games: number;
3150
3170
  lineups?: {
3151
3171
  ids: number[];
@@ -3168,6 +3188,12 @@ export interface components {
3168
3188
  location_unknown_games?: number;
3169
3189
  unknown_team_events: number;
3170
3190
  };
3191
+ /** @description With `include_games`: the team's record in the counted games that have any filtered time. */
3192
+ record?: {
3193
+ games: number;
3194
+ losses: number;
3195
+ wins: number;
3196
+ };
3171
3197
  results?: {
3172
3198
  off_ids: number[];
3173
3199
  on_ids: number[];
@@ -3226,13 +3252,24 @@ export interface components {
3226
3252
  /** @description YYYY-MM-DD */
3227
3253
  end_date?: string;
3228
3254
  exclude_garbage_time?: boolean;
3255
+ /** @description Only games in which every one of these players was on the floor, for either team. A game-level choice: the game counts whole or not at all. Listed in the manifest's options as `games_with`. */
3256
+ games_with?: number[];
3257
+ /** @description Only games in which none of these players was on the floor: the games a player missed. Unlike `players_off`, which keeps his games and drops his minutes. Listed in the manifest's options as `games_without`. */
3258
+ games_without?: number[];
3229
3259
  /** @description Also return the detail counters (possession start origin, turnover and foul types, rebounds by shot type, assists by type and zone, per-player possession phase). Off by default: on the lineup-stints fast path they need a second file read. */
3230
3260
  include_detail?: boolean;
3261
+ /** @description Only possessions at these leverage levels: how much the possession's result can move the offense's win probability (cuts at 0.02, 0.055 and 0.10; about 25%, 70%, 4% and 1% of possessions). NBA only. Answered from the plays (the engine path). Listed in the manifest's options as `leverage`. */
3262
+ leverage?: ("low" | "medium" | "high" | "very_high")[];
3231
3263
  /**
3232
3264
  * @description Only the team's home or away games, from its game logs. A neutral site (the 2020 bubble, Cup finals, international games) counts for the NBA's designated home team. A game the logs do not list is left out and counted in quality.location_unknown_games. Listed in the manifest's options as `location`.
3233
3265
  * @enum {string}
3234
3266
  */
3235
3267
  location?: "home" | "away";
3268
+ /** @description Only possessions the team started leading by min to max points (negative: trailing); either end may be left out. {min: -5, max: 5} is within five either way. Decided per possession from the score before its first play. Answered from the plays (the engine path), not the lineup-stints fast path. Listed in the manifest's options as `margin`. */
3269
+ margin?: {
3270
+ max?: number;
3271
+ min?: number;
3272
+ };
3236
3273
  /** @description Only games in these calendar months (1-12), in any of the seasons: [12] is every December. Listed in the manifest's options as `months`. */
3237
3274
  months?: number[];
3238
3275
  /** @description The focus player. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databallr/sdk",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "TypeScript client for the databallr API (NBA and WNBA stats, SixRings)",
5
5
  "license": "MIT",
6
6
  "repository": {