@ufcalendar/sdk 0.6.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.d.cts CHANGED
@@ -139,116 +139,6 @@ interface FightSearchRow extends Fight {
139
139
  }
140
140
  /** `method=` on `findFights`. */
141
141
  type FightSearchMethod = 'ko' | 'sub' | 'dec' | 'finish' | 'any';
142
- interface LiveStatLine {
143
- knockdowns: number | null;
144
- sig_strikes_landed: number | null;
145
- sig_strikes_attempted: number | null;
146
- total_strikes_landed: number | null;
147
- total_strikes_attempted: number | null;
148
- takedowns_landed: number | null;
149
- takedowns_attempted: number | null;
150
- submission_attempts: number | null;
151
- reversals: number | null;
152
- control_time_sec: number;
153
- [k: string]: number | null;
154
- }
155
- interface LiveCorner {
156
- src_id: number | null;
157
- fighter_id: number | null;
158
- name: string;
159
- short: string;
160
- }
161
- interface LiveCardRow {
162
- fight_id: number | null;
163
- src_id: number | null;
164
- order: number | null;
165
- section: 'main' | 'prelims' | 'early_prelims';
166
- status: 'upcoming' | 'live' | 'final' | 'cancelled';
167
- weight_class: string | null;
168
- possible_rounds: number | null;
169
- referee: string | null;
170
- a: LiveCorner | null;
171
- b: LiveCorner | null;
172
- result: {
173
- winner: 'a' | 'b' | null;
174
- method: string | null;
175
- round: number | null;
176
- time: string | null;
177
- nc: boolean;
178
- } | null;
179
- }
180
- interface LiveTimelineEntry {
181
- t: string;
182
- type: string;
183
- round: number | null;
184
- clock: string | null;
185
- side: 'a' | 'b' | null;
186
- }
187
- interface LiveCurrent {
188
- src_id: number | null;
189
- fight_id: number | null;
190
- phase: 'prefight' | 'round' | 'break' | 'over';
191
- round: number | null;
192
- possible_rounds: number | null;
193
- round_length_sec: number;
194
- round_started_at: string | null;
195
- clock_sec: number | null;
196
- clock_observed_at: number;
197
- official: boolean;
198
- stats: {
199
- a: LiveStatLine | null;
200
- b: LiveStatLine | null;
201
- } | null;
202
- rounds: {
203
- n: number;
204
- a: LiveStatLine | null;
205
- b: LiveStatLine | null;
206
- }[];
207
- timeline: LiveTimelineEntry[];
208
- }
209
- /** The real-time document pushed over wss://live.ufcalendar.com/v1 and
210
- * returned by GET /v1/events/{id}/live. */
211
- interface LiveState {
212
- v: 1;
213
- seq: number;
214
- ts: number;
215
- hash: string;
216
- event: {
217
- id: number | null;
218
- slug: string | null;
219
- fmid: number | null;
220
- name: string | null;
221
- org: string;
222
- status: 'upcoming' | 'live' | 'completed';
223
- source: string;
224
- };
225
- card: LiveCardRow[];
226
- current: LiveCurrent | null;
227
- last: {
228
- src_id: number | null;
229
- fight_id: number | null;
230
- winner: 'a' | 'b' | null;
231
- method: string | null;
232
- round: number | null;
233
- time: string | null;
234
- } | null;
235
- }
236
- /** One frame off the live WebSocket (`wss://live.ufcalendar.com/v1`).
237
- *
238
- * `snapshot` arrives on subscribe (`data` is null with `reason: "not_live"`
239
- * when nothing is streaming yet), `update` on every change, `fight.final`
240
- * when a bout is official and `event.completed` when the card is over. */
241
- interface LiveFrame {
242
- type: 'snapshot' | 'update' | 'fight.final' | 'event.completed' | 'pong' | 'error';
243
- data?: LiveState | null;
244
- /** On a `snapshot` with no document: why (`not_live`). */
245
- reason?: string;
246
- /** On `error`. */
247
- code?: string;
248
- message?: string;
249
- /** On `pong`. */
250
- ts?: number;
251
- }
252
142
  /** Normalized method vocabulary; `method` keeps the source's spelling. */
253
143
  type MethodNormalized = 'ko_tko' | 'submission' | 'technical_submission' | 'decision_unanimous' | 'decision_split' | 'decision_majority' | 'decision' | 'draw' | 'no_contest' | 'dq' | 'other';
254
144
  interface FightResult {
@@ -1409,9 +1299,6 @@ interface Article {
1409
1299
  }
1410
1300
 
1411
1301
  declare const DEFAULT_BASE_URL = "https://api.ufcalendar.com/v1";
1412
- /** The live WebSocket (UFC fight nights, Pro plans and up) — the same document
1413
- * `GET /v1/events/{id}/live` returns, pushed on every change. */
1414
- declare const LIVE_WS_URL = "wss://live.ufcalendar.com/v1";
1415
1302
  interface FightAPIOptions {
1416
1303
  /** `ufcalendar_…` key from https://www.ufcalendar.com/account/api. Falls back
1417
1304
  * to `UFCALENDAR_API_KEY` / `UFCAL_API_KEY` in the environment. Only
@@ -1535,32 +1422,6 @@ declare class FightAPI {
1535
1422
  kind?: ChangeKind;
1536
1423
  limit?: number;
1537
1424
  }): AsyncGenerator<ChangeFeedEntry, void, void>;
1538
- /** Latest real-time LiveState snapshot on fight night (Pro plans and up), or
1539
- * null when nothing is being streamed. The WebSocket at
1540
- * wss://live.ufcalendar.com/v1 pushes the same document as it changes — see
1541
- * `subscribeLive()`. */
1542
- eventLive(idOrSlug: string | number): Promise<LiveState | null>;
1543
- /**
1544
- * Subscribe to the live WebSocket and receive every frame (Pro plans and up).
1545
- *
1546
- * The UFC live API: opens `wss://live.ufcalendar.com/v1?key=…`, sends
1547
- * `{"action":"subscribe","event":<slug>}` and calls `onFrame` with each
1548
- * `LiveFrame` — round, running clock, unofficial in-fight statistics and the
1549
- * action timeline, the same `LiveState` `eventLive()` returns.
1550
- *
1551
- * ```ts
1552
- * const stop = api.subscribeLive('ufc-331', (f) => console.log(f.type), { until: 'final' });
1553
- * ```
1554
- *
1555
- * Uses the global `WebSocket` (browser, Node >= 22) unless you inject one
1556
- * (`ws` on older Node). A dropped socket reconnects and re-subscribes ONCE.
1557
- *
1558
- * @returns an unsubscribe function — call it to close the socket for good.
1559
- */
1560
- subscribeLive(event: string, onFrame: (frame: LiveFrame) => void, opts?: {
1561
- until?: 'final';
1562
- WebSocketImpl?: typeof WebSocket;
1563
- }): () => void;
1564
1425
  /** One bout with its result. `include: ['odds']` adds the current consensus line (the closing line once the bout is settled). */
1565
1426
  fight(fightId: number | string, opts?: {
1566
1427
  include?: FightInclude[];
@@ -1836,7 +1697,7 @@ declare class FightAPI {
1836
1697
 
1837
1698
  /** Kept in lockstep with package.json and the User-Agent by
1838
1699
  * `apps/api/src/surfaces.test.ts`. Bump all three together. */
1839
- declare const VERSION = "0.6.0";
1700
+ declare const VERSION = "0.7.0";
1840
1701
 
1841
1702
  /**
1842
1703
  * This file was auto-generated by openapi-typescript.
@@ -2689,134 +2550,6 @@ interface paths {
2689
2550
  patch?: never;
2690
2551
  trace?: never;
2691
2552
  };
2692
- "/v1/events/{idOrSlug}/live": {
2693
- parameters: {
2694
- query?: never;
2695
- header?: never;
2696
- path?: never;
2697
- cookie?: never;
2698
- };
2699
- /**
2700
- * Live snapshot (Pro+)
2701
- * @description The latest real-time document for an event on fight night — the same `LiveState` the WebSocket pushes: card order and statuses, the bout in progress (`current`: phase, round, running clock, unofficial totals and per-round stats, referee, a timestamped action timeline), and the last result. `data` is `null` with `meta.live: false` when nothing is being streamed. Poll it at most every few seconds, or connect to the WebSocket in `meta.websocket` (`?key=` on the URL, then send `{"action":"subscribe","event":"<slug>"}`) and receive every change as it lands. UFC only in v1. Requires Pro or higher (403 `tier_required` otherwise).
2702
- */
2703
- get: {
2704
- parameters: {
2705
- query?: never;
2706
- header?: never;
2707
- path: {
2708
- /** @description Numeric id or slug of the event. Stale slugs 308-redirect to the canonical URL. */
2709
- idOrSlug: string;
2710
- };
2711
- cookie?: never;
2712
- };
2713
- requestBody?: never;
2714
- responses: {
2715
- /** @description LiveState or null. The one GET whose `Cache-Control` is `no-store` (a snapshot changes every few seconds on fight night). */
2716
- 200: {
2717
- headers: {
2718
- /** @description Weak validator over the body, e.g. `W/"GKrimLo826WBqG27jbNFsW2ZHmA"`. Send it back as `If-None-Match` to get a 304. */
2719
- ETag?: string;
2720
- /** @description Always `private, no-cache`. */
2721
- "Cache-Control"?: string;
2722
- /** @description Monthly request quota of the plan. */
2723
- "X-RateLimit-Limit"?: number;
2724
- /** @description Requests left this month. */
2725
- "X-RateLimit-Remaining"?: number;
2726
- /** @description Unix seconds of the monthly reset. */
2727
- "X-RateLimit-Reset"?: number;
2728
- /** @description Quote it to support; the same id is in every error body. */
2729
- "x-request-id"?: string;
2730
- [name: string]: unknown;
2731
- };
2732
- content: {
2733
- /**
2734
- * @example {
2735
- * "data": null,
2736
- * "meta": {
2737
- * "live": false,
2738
- * "websocket": "wss://live.ufcalendar.com/v1",
2739
- * "subscribe": {
2740
- * "action": "subscribe",
2741
- * "event": "ufc-320"
2742
- * }
2743
- * }
2744
- * }
2745
- */
2746
- "application/json": components["schemas"]["EventLiveResponse"];
2747
- };
2748
- };
2749
- /** @description Not Modified — `If-None-Match` matched the current weak `ETag`. Empty body. */
2750
- 304: {
2751
- headers: {
2752
- [name: string]: unknown;
2753
- };
2754
- content?: never;
2755
- };
2756
- /** @description The slug is a retired alias (the event or fighter was renamed). Follow `Location` to the canonical URL; the numeric-id form never redirects. */
2757
- 308: {
2758
- headers: {
2759
- /** @description Canonical `/v1/...` path. */
2760
- Location?: string;
2761
- [name: string]: unknown;
2762
- };
2763
- content?: never;
2764
- };
2765
- /** @description Missing/invalid API key (`unauthorized`). */
2766
- 401: {
2767
- headers: {
2768
- [name: string]: unknown;
2769
- };
2770
- content: {
2771
- "application/json": components["schemas"]["Error"];
2772
- };
2773
- };
2774
- /** @description Requires Pro or above (`tier_required`). */
2775
- 403: {
2776
- headers: {
2777
- [name: string]: unknown;
2778
- };
2779
- content: {
2780
- "application/json": components["schemas"]["Error"];
2781
- };
2782
- };
2783
- /** @description Not found (`not_found`; staged-org data 404s until the org is promoted). */
2784
- 404: {
2785
- headers: {
2786
- [name: string]: unknown;
2787
- };
2788
- content: {
2789
- "application/json": components["schemas"]["Error"];
2790
- };
2791
- };
2792
- /** @description Rate limited (`rate_limited`) or monthly quota reached (`quota_exceeded`). Honor `Retry-After`. */
2793
- 429: {
2794
- headers: {
2795
- [name: string]: unknown;
2796
- };
2797
- content: {
2798
- "application/json": components["schemas"]["Error"];
2799
- };
2800
- };
2801
- /** @description Something broke on our side (`internal_error`). It has been logged under the `request_id`. */
2802
- 500: {
2803
- headers: {
2804
- [name: string]: unknown;
2805
- };
2806
- content: {
2807
- "application/json": components["schemas"]["Error"];
2808
- };
2809
- };
2810
- };
2811
- };
2812
- put?: never;
2813
- post?: never;
2814
- delete?: never;
2815
- options?: never;
2816
- head?: never;
2817
- patch?: never;
2818
- trace?: never;
2819
- };
2820
2553
  "/v1/events/{idOrSlug}/changes": {
2821
2554
  parameters: {
2822
2555
  query?: never;
@@ -10711,35 +10444,6 @@ interface components {
10711
10444
  /** Format: date-time */
10712
10445
  observed_at: string;
10713
10446
  };
10714
- /** @description The real-time document the stream worker publishes (the same one the WebSocket pushes). Open-ended by design — `current`, `card[]` and the timeline grow with the feed. Pinned by `mobile/shared/fixtures/live-stream-cases.json`. */
10715
- LiveState: {
10716
- /** @description Document version. */
10717
- v: number;
10718
- /** @description Publish sequence within one run (restarts count from 1 again — order by `ts`). */
10719
- seq: number;
10720
- /** @description Unix milliseconds of this publish. */
10721
- ts: number;
10722
- /** @description Content hash; a new document is published only when it changes. */
10723
- hash: string;
10724
- /** @description `{id, slug, fmid, name, org, status, source}`. */
10725
- event: {
10726
- [key: string]: unknown;
10727
- };
10728
- /** @description Bout order and statuses (`upcoming` / `live` / `final`), corners (`a`/`b` with `fighter_id`, `name`, `short`) and results. */
10729
- card: {
10730
- [key: string]: unknown;
10731
- }[];
10732
- /** @description The bout in the cage: `phase`, `round`, `possible_rounds`, `round_length_sec`, `round_started_at`, `clock_sec`, `official`, `stats` (`a`/`b` totals), `rounds[]`, `timeline[]`. */
10733
- current?: {
10734
- [key: string]: unknown;
10735
- } | null;
10736
- /** @description The last finished bout: `fight_id`, `winner` (`a`/`b`/null), `method`, `round`, `time`. */
10737
- last?: {
10738
- [key: string]: unknown;
10739
- } | null;
10740
- } & {
10741
- [key: string]: unknown;
10742
- };
10743
10447
  /** @description The one fighter-reference shape every card, fight and search row carries. */
10744
10448
  FighterRef: {
10745
10449
  id: number;
@@ -12657,24 +12361,6 @@ interface components {
12657
12361
  ignored_params?: string[];
12658
12362
  };
12659
12363
  };
12660
- /** @description `data` is null with `meta.live: false` when nothing is being streamed. */
12661
- EventLiveResponse: {
12662
- data: components["schemas"]["LiveState"] | null;
12663
- meta: {
12664
- /** @description true only while the event is in progress on the stream. */
12665
- live: boolean;
12666
- /** @description `wss://live.ufcalendar.com/v1` — add `?key=<key>`. */
12667
- websocket: string;
12668
- subscribe: {
12669
- /** @constant */
12670
- action: "subscribe";
12671
- /** @description The slug to send. */
12672
- event: string;
12673
- };
12674
- /** @description Present only when the request carried query parameters this endpoint does not take — they were ignored. Same list as the `X-UFCalendar-Ignored-Params` header. Sorted, unique. */
12675
- ignored_params?: string[];
12676
- };
12677
- };
12678
12364
  FightResponse: {
12679
12365
  data: components["schemas"]["FightDetail"];
12680
12366
  meta: components["schemas"]["EmptyMeta"];
@@ -13080,4 +12766,4 @@ interface components {
13080
12766
  }
13081
12767
  type operations = Record<string, never>;
13082
12768
 
13083
- export { type Article, type ArticleLocale, type ArticleSummary, type BonusAward, type BonusLedger, type Broadcast, type BroadcastRight, type CareerBout, type CareerStats, type Champion, type ChangeFeedEntry, type ChangeKind, type Compare, type CompareAggregates, type CompareBout, type CredentialConfidence, DEFAULT_BASE_URL, type DissentingJudge, type Envelope, type EventChange, type EventDetail, type EventHeadline, type EventInclude, type EventListInclude, type EventOdds, type EventOddsRow, type EventPickem, type EventRef, type EventStatus, type EventStorylines, type EventSummary, type EventWatch, type Fight, FightAPI, FightAPIError, type FightAPIOptions, type FightInclude, type FightOdds, type FightResult, type FightSearchMethod, type FightSearchRow, type Fighter, type FighterAffiliation, type FighterBout, type FighterCredential, type FighterCredentials, type FighterImage, type FighterInclude, type FighterRef, type FighterSummary, type HeadlineCorner, type Judge, type JudgeColleague, type JudgeLeague, type JudgeScorecardRow, LIVE_WS_URL, type LeaderboardRow, type LiveCardRow, type LiveCorner, type LiveCurrent, type LiveFrame, type LiveStatLine, type LiveState, type LiveTimelineEntry, type MatchmakerCorner, type MatchmakerTag, type Matchup, type Meta, type MethodNormalized, type OddsBlock, type OddsHistoryPoint, type OddsLine, type OddsMovement, type OddsPair, type Org, type OrgDivision, type PickemSplit, type Plan, type Plans, type PowerIndex, type PowerIndexFighter, type PowerIndexMover, type PowerIndexRow, type PowerIndexView, type ProbabilitySource, type PublicSource, type Query, type QueryValue, type RankingDivision, type RankingEntry, type RankingsBoard, type RateLimit, type RecordBookSection, type RecordEntry, type RightsSeries, type Scorecard, type ScorecardRound, type Scorecards, type SplitDecisionRow, type StatMetric, type StatScope, type StatsPanel, type StorylineCorner, type StorylineTag, type Usage, VERSION, type Venue, type WatchProvider, type WebhookEndpoint, type WhosNext, type YearStats, type operations, type paths };
12769
+ export { type Article, type ArticleLocale, type ArticleSummary, type BonusAward, type BonusLedger, type Broadcast, type BroadcastRight, type CareerBout, type CareerStats, type Champion, type ChangeFeedEntry, type ChangeKind, type Compare, type CompareAggregates, type CompareBout, type CredentialConfidence, DEFAULT_BASE_URL, type DissentingJudge, type Envelope, type EventChange, type EventDetail, type EventHeadline, type EventInclude, type EventListInclude, type EventOdds, type EventOddsRow, type EventPickem, type EventRef, type EventStatus, type EventStorylines, type EventSummary, type EventWatch, type Fight, FightAPI, FightAPIError, type FightAPIOptions, type FightInclude, type FightOdds, type FightResult, type FightSearchMethod, type FightSearchRow, type Fighter, type FighterAffiliation, type FighterBout, type FighterCredential, type FighterCredentials, type FighterImage, type FighterInclude, type FighterRef, type FighterSummary, type HeadlineCorner, type Judge, type JudgeColleague, type JudgeLeague, type JudgeScorecardRow, type LeaderboardRow, type MatchmakerCorner, type MatchmakerTag, type Matchup, type Meta, type MethodNormalized, type OddsBlock, type OddsHistoryPoint, type OddsLine, type OddsMovement, type OddsPair, type Org, type OrgDivision, type PickemSplit, type Plan, type Plans, type PowerIndex, type PowerIndexFighter, type PowerIndexMover, type PowerIndexRow, type PowerIndexView, type ProbabilitySource, type PublicSource, type Query, type QueryValue, type RankingDivision, type RankingEntry, type RankingsBoard, type RateLimit, type RecordBookSection, type RecordEntry, type RightsSeries, type Scorecard, type ScorecardRound, type Scorecards, type SplitDecisionRow, type StatMetric, type StatScope, type StatsPanel, type StorylineCorner, type StorylineTag, type Usage, VERSION, type Venue, type WatchProvider, type WebhookEndpoint, type WhosNext, type YearStats, type operations, type paths };