propline 0.45.0 → 0.46.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
@@ -1476,6 +1476,24 @@ interface ReplayWebhookEventsOptions {
1476
1476
  /** Max events per page. Default 100, max 500. */
1477
1477
  limit?: number;
1478
1478
  }
1479
+ interface StreamOptions {
1480
+ /** Subscription to stream. Must be transport="websocket". */
1481
+ webhookId: number;
1482
+ /** Resume point — the last `seq` you processed. Default 0. */
1483
+ sinceSeq?: number;
1484
+ /** Auto-reconnect and resume from the last seq. Default true. */
1485
+ reconnect?: boolean;
1486
+ /** Override the websocket origin (default: derived from baseUrl). */
1487
+ wsUrl?: string;
1488
+ /** Called on every successful handshake with the `ready` frame. */
1489
+ onReady?: (ready: ReplayPage) => void;
1490
+ /**
1491
+ * Called when the server reports events after your cursor have aged out of
1492
+ * retention. This is the one case the stream cannot make you whole —
1493
+ * resync from the REST endpoints.
1494
+ */
1495
+ onTruncated?: (ready: ReplayPage) => void;
1496
+ }
1479
1497
  interface VerifySignatureOptions {
1480
1498
  /** Webhook signing secret (returned once from `createWebhook`). */
1481
1499
  secret: string;
@@ -1927,6 +1945,30 @@ declare class PropLine {
1927
1945
  * Does not count against your daily request quota.
1928
1946
  */
1929
1947
  replayWebhookEvents(webhookId: number, options?: ReplayWebhookEventsOptions): Promise<ReplayPage>;
1948
+ /**
1949
+ * Stream a websocket subscription as an async iterable.
1950
+ *
1951
+ * ```ts
1952
+ * for await (const ev of client.stream({ webhookId: 12, sinceSeq: 4180 })) {
1953
+ * console.log(ev.seq, ev.event_type, ev.data);
1954
+ * }
1955
+ * ```
1956
+ *
1957
+ * The subscription must have been created with `transport: "websocket"`.
1958
+ * Same events, same filters, same `seq` as an HTTP webhook — one
1959
+ * subscription, different transport.
1960
+ *
1961
+ * **Reconnects automatically and resumes from the last `seq` it saw**, which
1962
+ * is the whole point of the sequence: a dropped connection does not become a
1963
+ * gap in your data. Set `reconnect: false` to get a single connection that
1964
+ * ends when the socket closes.
1965
+ *
1966
+ * If the server reports `truncated` — events after your cursor aged out of
1967
+ * retention and are gone — `onTruncated` fires. Handle it: that is the one
1968
+ * case where the stream cannot make you whole and you should resync from the
1969
+ * REST endpoints.
1970
+ */
1971
+ stream(options: StreamOptions): AsyncGenerator<ReplayEvent, void, void>;
1930
1972
  /**
1931
1973
  * Grade placed bets against their closing lines (CLV).
1932
1974
  *
@@ -2028,6 +2070,6 @@ declare const Bookmakers: {
2028
2070
  readonly PRIZEPICKS: "prizepicks";
2029
2071
  };
2030
2072
  type BookmakerKey = (typeof Bookmakers)[keyof typeof Bookmakers];
2031
- declare const VERSION = "0.45.0";
2073
+ declare const VERSION = "0.46.0";
2032
2074
 
2033
- export { AuthError, type BestLine, type BestLineSide, type BestPrice, type Bookmaker, type BookmakerKey, Bookmakers, type CalcEventEvOptions, type ClosingBookmaker, type ClosingMarket, type ClosingOutcome, type ClvBetInput, type ClvGradeResponse, type ClvGradedBet, type ClvSummary, type ContextResponse, type CreateWebhookOptions, type DfsPayoutTier, type DfsPayoutsResponse, type DfsPlayPayout, type EvLine, type EvOutcome, type Event, type EventBestLineResponse, type EventEvCalcResponse, type EventEvResponse, type EventProjectionsResponse, type ExportOddsHistoryOptions, type ExportResolvedPropsOptions, type FuturesEvent, type FuturesMarket, type FuturesOutcome, type GetDfsPayoutsOptions, type GetEventBestLineOptions, type GetEventEvOptions, type GetEventProjectionsOptions, type GetMlbGrandSalamiOptions, type GetNhlDailyGoalsTotalOptions, type GetOddsClosingOptions, type GetOddsHistoryOptions, type GetOddsOptions, type GetPlayerGamesOptions, type GetPlayerHistoryOptions, type GetPlayerTrendsOptions, type GetResultsOptions, type GetScoresOptions, type GetStatsOptions, type HitRateSplit, type ListWebhookDeliveriesOptions, type Market, type MarketSummary, type MlbGrandSalamiBook, type MlbGrandSalamiResponse, type MovementBookmaker, type MovementMarket, type MovementOutcome, type MovementResponse, type NhlDailyGoalsTotalBook, type NhlDailyGoalsTotalResponse, type OddsClosingResponse, type OddsHistoryBookmaker, type OddsHistoryMarket, type OddsHistoryOutcome, type OddsHistoryResponse, type OddsResponse, type Outcome, type OutcomeSnapshot, type PeriodFilter, type PlayerGame, type PlayerGameLog, type PlayerHistoryEntry, type PlayerHistoryResponse, type PlayerMarketTrend, type PlayerStat, type PlayerTrends, type ProjectionRow, PropLine, PropLineError, type PropLineErrorInfo, type PropLineOptions, type QuotaStatus, RateLimitError, type ReplayEvent, type ReplayPage, type ReplayWebhookEventsOptions, type ResolutionSummary, type ResolutionSummaryMarket, type ResolutionSummarySport, type ResolvedOutcome, type ResultsMarket, type ResultsResponse, type ScoreEvent, type Sport, type StatsResponse, type SteamMove, type TrendLastGame, type TrendStreak, type UpdateWebhookOptions, VERSION, type VerifySignatureOptions, type WeatherInfo, type Webhook, type WebhookDelivery, type WebhookEventType };
2075
+ export { AuthError, type BestLine, type BestLineSide, type BestPrice, type Bookmaker, type BookmakerKey, Bookmakers, type CalcEventEvOptions, type ClosingBookmaker, type ClosingMarket, type ClosingOutcome, type ClvBetInput, type ClvGradeResponse, type ClvGradedBet, type ClvSummary, type ContextResponse, type CreateWebhookOptions, type DfsPayoutTier, type DfsPayoutsResponse, type DfsPlayPayout, type EvLine, type EvOutcome, type Event, type EventBestLineResponse, type EventEvCalcResponse, type EventEvResponse, type EventProjectionsResponse, type ExportOddsHistoryOptions, type ExportResolvedPropsOptions, type FuturesEvent, type FuturesMarket, type FuturesOutcome, type GetDfsPayoutsOptions, type GetEventBestLineOptions, type GetEventEvOptions, type GetEventProjectionsOptions, type GetMlbGrandSalamiOptions, type GetNhlDailyGoalsTotalOptions, type GetOddsClosingOptions, type GetOddsHistoryOptions, type GetOddsOptions, type GetPlayerGamesOptions, type GetPlayerHistoryOptions, type GetPlayerTrendsOptions, type GetResultsOptions, type GetScoresOptions, type GetStatsOptions, type HitRateSplit, type ListWebhookDeliveriesOptions, type Market, type MarketSummary, type MlbGrandSalamiBook, type MlbGrandSalamiResponse, type MovementBookmaker, type MovementMarket, type MovementOutcome, type MovementResponse, type NhlDailyGoalsTotalBook, type NhlDailyGoalsTotalResponse, type OddsClosingResponse, type OddsHistoryBookmaker, type OddsHistoryMarket, type OddsHistoryOutcome, type OddsHistoryResponse, type OddsResponse, type Outcome, type OutcomeSnapshot, type PeriodFilter, type PlayerGame, type PlayerGameLog, type PlayerHistoryEntry, type PlayerHistoryResponse, type PlayerMarketTrend, type PlayerStat, type PlayerTrends, type ProjectionRow, PropLine, PropLineError, type PropLineErrorInfo, type PropLineOptions, type QuotaStatus, RateLimitError, type ReplayEvent, type ReplayPage, type ReplayWebhookEventsOptions, type ResolutionSummary, type ResolutionSummaryMarket, type ResolutionSummarySport, type ResolvedOutcome, type ResultsMarket, type ResultsResponse, type ScoreEvent, type Sport, type StatsResponse, type SteamMove, type StreamOptions, type TrendLastGame, type TrendStreak, type UpdateWebhookOptions, VERSION, type VerifySignatureOptions, type WeatherInfo, type Webhook, type WebhookDelivery, type WebhookEventType };
package/dist/index.d.ts CHANGED
@@ -1476,6 +1476,24 @@ interface ReplayWebhookEventsOptions {
1476
1476
  /** Max events per page. Default 100, max 500. */
1477
1477
  limit?: number;
1478
1478
  }
1479
+ interface StreamOptions {
1480
+ /** Subscription to stream. Must be transport="websocket". */
1481
+ webhookId: number;
1482
+ /** Resume point — the last `seq` you processed. Default 0. */
1483
+ sinceSeq?: number;
1484
+ /** Auto-reconnect and resume from the last seq. Default true. */
1485
+ reconnect?: boolean;
1486
+ /** Override the websocket origin (default: derived from baseUrl). */
1487
+ wsUrl?: string;
1488
+ /** Called on every successful handshake with the `ready` frame. */
1489
+ onReady?: (ready: ReplayPage) => void;
1490
+ /**
1491
+ * Called when the server reports events after your cursor have aged out of
1492
+ * retention. This is the one case the stream cannot make you whole —
1493
+ * resync from the REST endpoints.
1494
+ */
1495
+ onTruncated?: (ready: ReplayPage) => void;
1496
+ }
1479
1497
  interface VerifySignatureOptions {
1480
1498
  /** Webhook signing secret (returned once from `createWebhook`). */
1481
1499
  secret: string;
@@ -1927,6 +1945,30 @@ declare class PropLine {
1927
1945
  * Does not count against your daily request quota.
1928
1946
  */
1929
1947
  replayWebhookEvents(webhookId: number, options?: ReplayWebhookEventsOptions): Promise<ReplayPage>;
1948
+ /**
1949
+ * Stream a websocket subscription as an async iterable.
1950
+ *
1951
+ * ```ts
1952
+ * for await (const ev of client.stream({ webhookId: 12, sinceSeq: 4180 })) {
1953
+ * console.log(ev.seq, ev.event_type, ev.data);
1954
+ * }
1955
+ * ```
1956
+ *
1957
+ * The subscription must have been created with `transport: "websocket"`.
1958
+ * Same events, same filters, same `seq` as an HTTP webhook — one
1959
+ * subscription, different transport.
1960
+ *
1961
+ * **Reconnects automatically and resumes from the last `seq` it saw**, which
1962
+ * is the whole point of the sequence: a dropped connection does not become a
1963
+ * gap in your data. Set `reconnect: false` to get a single connection that
1964
+ * ends when the socket closes.
1965
+ *
1966
+ * If the server reports `truncated` — events after your cursor aged out of
1967
+ * retention and are gone — `onTruncated` fires. Handle it: that is the one
1968
+ * case where the stream cannot make you whole and you should resync from the
1969
+ * REST endpoints.
1970
+ */
1971
+ stream(options: StreamOptions): AsyncGenerator<ReplayEvent, void, void>;
1930
1972
  /**
1931
1973
  * Grade placed bets against their closing lines (CLV).
1932
1974
  *
@@ -2028,6 +2070,6 @@ declare const Bookmakers: {
2028
2070
  readonly PRIZEPICKS: "prizepicks";
2029
2071
  };
2030
2072
  type BookmakerKey = (typeof Bookmakers)[keyof typeof Bookmakers];
2031
- declare const VERSION = "0.45.0";
2073
+ declare const VERSION = "0.46.0";
2032
2074
 
2033
- export { AuthError, type BestLine, type BestLineSide, type BestPrice, type Bookmaker, type BookmakerKey, Bookmakers, type CalcEventEvOptions, type ClosingBookmaker, type ClosingMarket, type ClosingOutcome, type ClvBetInput, type ClvGradeResponse, type ClvGradedBet, type ClvSummary, type ContextResponse, type CreateWebhookOptions, type DfsPayoutTier, type DfsPayoutsResponse, type DfsPlayPayout, type EvLine, type EvOutcome, type Event, type EventBestLineResponse, type EventEvCalcResponse, type EventEvResponse, type EventProjectionsResponse, type ExportOddsHistoryOptions, type ExportResolvedPropsOptions, type FuturesEvent, type FuturesMarket, type FuturesOutcome, type GetDfsPayoutsOptions, type GetEventBestLineOptions, type GetEventEvOptions, type GetEventProjectionsOptions, type GetMlbGrandSalamiOptions, type GetNhlDailyGoalsTotalOptions, type GetOddsClosingOptions, type GetOddsHistoryOptions, type GetOddsOptions, type GetPlayerGamesOptions, type GetPlayerHistoryOptions, type GetPlayerTrendsOptions, type GetResultsOptions, type GetScoresOptions, type GetStatsOptions, type HitRateSplit, type ListWebhookDeliveriesOptions, type Market, type MarketSummary, type MlbGrandSalamiBook, type MlbGrandSalamiResponse, type MovementBookmaker, type MovementMarket, type MovementOutcome, type MovementResponse, type NhlDailyGoalsTotalBook, type NhlDailyGoalsTotalResponse, type OddsClosingResponse, type OddsHistoryBookmaker, type OddsHistoryMarket, type OddsHistoryOutcome, type OddsHistoryResponse, type OddsResponse, type Outcome, type OutcomeSnapshot, type PeriodFilter, type PlayerGame, type PlayerGameLog, type PlayerHistoryEntry, type PlayerHistoryResponse, type PlayerMarketTrend, type PlayerStat, type PlayerTrends, type ProjectionRow, PropLine, PropLineError, type PropLineErrorInfo, type PropLineOptions, type QuotaStatus, RateLimitError, type ReplayEvent, type ReplayPage, type ReplayWebhookEventsOptions, type ResolutionSummary, type ResolutionSummaryMarket, type ResolutionSummarySport, type ResolvedOutcome, type ResultsMarket, type ResultsResponse, type ScoreEvent, type Sport, type StatsResponse, type SteamMove, type TrendLastGame, type TrendStreak, type UpdateWebhookOptions, VERSION, type VerifySignatureOptions, type WeatherInfo, type Webhook, type WebhookDelivery, type WebhookEventType };
2075
+ export { AuthError, type BestLine, type BestLineSide, type BestPrice, type Bookmaker, type BookmakerKey, Bookmakers, type CalcEventEvOptions, type ClosingBookmaker, type ClosingMarket, type ClosingOutcome, type ClvBetInput, type ClvGradeResponse, type ClvGradedBet, type ClvSummary, type ContextResponse, type CreateWebhookOptions, type DfsPayoutTier, type DfsPayoutsResponse, type DfsPlayPayout, type EvLine, type EvOutcome, type Event, type EventBestLineResponse, type EventEvCalcResponse, type EventEvResponse, type EventProjectionsResponse, type ExportOddsHistoryOptions, type ExportResolvedPropsOptions, type FuturesEvent, type FuturesMarket, type FuturesOutcome, type GetDfsPayoutsOptions, type GetEventBestLineOptions, type GetEventEvOptions, type GetEventProjectionsOptions, type GetMlbGrandSalamiOptions, type GetNhlDailyGoalsTotalOptions, type GetOddsClosingOptions, type GetOddsHistoryOptions, type GetOddsOptions, type GetPlayerGamesOptions, type GetPlayerHistoryOptions, type GetPlayerTrendsOptions, type GetResultsOptions, type GetScoresOptions, type GetStatsOptions, type HitRateSplit, type ListWebhookDeliveriesOptions, type Market, type MarketSummary, type MlbGrandSalamiBook, type MlbGrandSalamiResponse, type MovementBookmaker, type MovementMarket, type MovementOutcome, type MovementResponse, type NhlDailyGoalsTotalBook, type NhlDailyGoalsTotalResponse, type OddsClosingResponse, type OddsHistoryBookmaker, type OddsHistoryMarket, type OddsHistoryOutcome, type OddsHistoryResponse, type OddsResponse, type Outcome, type OutcomeSnapshot, type PeriodFilter, type PlayerGame, type PlayerGameLog, type PlayerHistoryEntry, type PlayerHistoryResponse, type PlayerMarketTrend, type PlayerStat, type PlayerTrends, type ProjectionRow, PropLine, PropLineError, type PropLineErrorInfo, type PropLineOptions, type QuotaStatus, RateLimitError, type ReplayEvent, type ReplayPage, type ReplayWebhookEventsOptions, type ResolutionSummary, type ResolutionSummaryMarket, type ResolutionSummarySport, type ResolvedOutcome, type ResultsMarket, type ResultsResponse, type ScoreEvent, type Sport, type StatsResponse, type SteamMove, type StreamOptions, type TrendLastGame, type TrendStreak, type UpdateWebhookOptions, VERSION, type VerifySignatureOptions, type WeatherInfo, type Webhook, type WebhookDelivery, type WebhookEventType };
package/dist/index.js CHANGED
@@ -815,6 +815,111 @@ var PropLine = class {
815
815
  { params: { since_seq: options.sinceSeq ?? 0, limit: options.limit ?? 100 } }
816
816
  );
817
817
  }
818
+ /**
819
+ * Stream a websocket subscription as an async iterable.
820
+ *
821
+ * ```ts
822
+ * for await (const ev of client.stream({ webhookId: 12, sinceSeq: 4180 })) {
823
+ * console.log(ev.seq, ev.event_type, ev.data);
824
+ * }
825
+ * ```
826
+ *
827
+ * The subscription must have been created with `transport: "websocket"`.
828
+ * Same events, same filters, same `seq` as an HTTP webhook — one
829
+ * subscription, different transport.
830
+ *
831
+ * **Reconnects automatically and resumes from the last `seq` it saw**, which
832
+ * is the whole point of the sequence: a dropped connection does not become a
833
+ * gap in your data. Set `reconnect: false` to get a single connection that
834
+ * ends when the socket closes.
835
+ *
836
+ * If the server reports `truncated` — events after your cursor aged out of
837
+ * retention and are gone — `onTruncated` fires. Handle it: that is the one
838
+ * case where the stream cannot make you whole and you should resync from the
839
+ * REST endpoints.
840
+ */
841
+ async *stream(options) {
842
+ const wsBase = (options.wsUrl ?? this.baseUrl).replace(/^http:/, "ws:").replace(/^https:/, "wss:").replace(/\/v1\/?$/, "");
843
+ const url = `${wsBase}/v1/stream`;
844
+ let cursor = options.sinceSeq ?? 0;
845
+ let attempt = 0;
846
+ for (; ; ) {
847
+ const queue = [];
848
+ let notify = null;
849
+ let closed = null;
850
+ let opened = false;
851
+ const ws = new WebSocket(url);
852
+ const wake = () => {
853
+ const n = notify;
854
+ notify = null;
855
+ n?.();
856
+ };
857
+ ws.addEventListener("open", () => {
858
+ opened = true;
859
+ ws.send(JSON.stringify({
860
+ type: "auth",
861
+ api_key: this.apiKey,
862
+ webhook_id: options.webhookId,
863
+ since_seq: cursor
864
+ }));
865
+ });
866
+ ws.addEventListener("message", (e) => {
867
+ let msg;
868
+ try {
869
+ msg = JSON.parse(String(e.data));
870
+ } catch {
871
+ return;
872
+ }
873
+ if (msg.type === "ready") {
874
+ attempt = 0;
875
+ if (msg.truncated) options.onTruncated?.(msg);
876
+ options.onReady?.(msg);
877
+ } else if (msg.type === "event") {
878
+ queue.push(msg);
879
+ wake();
880
+ }
881
+ });
882
+ ws.addEventListener("close", (e) => {
883
+ const terminal = [4400, 4401, 4403, 4404].includes(e.code);
884
+ closed = new PropLineError(
885
+ e.code,
886
+ `stream closed${e.reason ? `: ${e.reason}` : ""}`
887
+ );
888
+ closed.terminal = terminal;
889
+ wake();
890
+ });
891
+ ws.addEventListener("error", () => {
892
+ if (!closed) closed = new PropLineError(0, "stream connection error");
893
+ wake();
894
+ });
895
+ try {
896
+ for (; ; ) {
897
+ while (queue.length) {
898
+ const ev = queue.shift();
899
+ cursor = ev.seq;
900
+ yield ev;
901
+ }
902
+ if (closed) break;
903
+ await new Promise((r) => {
904
+ notify = r;
905
+ });
906
+ }
907
+ } finally {
908
+ try {
909
+ ws.close();
910
+ } catch {
911
+ }
912
+ }
913
+ const err = closed;
914
+ if (err?.terminal) throw err;
915
+ if (options.reconnect === false) {
916
+ if (err && !opened) throw err;
917
+ return;
918
+ }
919
+ const delayMs = Math.min(3e4, 500 * 2 ** attempt++);
920
+ await new Promise((r) => setTimeout(r, delayMs));
921
+ }
922
+ }
818
923
  /**
819
924
  * Grade placed bets against their closing lines (CLV).
820
925
  *
@@ -955,7 +1060,7 @@ var Bookmakers = {
955
1060
  POLYMARKET: "polymarket",
956
1061
  PRIZEPICKS: "prizepicks"
957
1062
  };
958
- var VERSION = "0.45.0";
1063
+ var VERSION = "0.46.0";
959
1064
  export {
960
1065
  AuthError,
961
1066
  Bookmakers,