@taphubhq/sdk-core 0.20.1 → 0.21.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 +44 -13
- package/dist/index.d.mts +38 -12
- package/dist/index.d.ts +38 -12
- package/dist/index.js +44 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -633,8 +633,14 @@ function normaliseRankBoard(wire) {
|
|
|
633
633
|
sort: wire.sort,
|
|
634
634
|
sortDir: wire.sortDir,
|
|
635
635
|
total: wire.total,
|
|
636
|
-
entries: Array.isArray(wire.entries) ? wire.entries.map(normaliseRankEntry) : []
|
|
637
|
-
|
|
636
|
+
entries: Array.isArray(wire.entries) ? wire.entries.map(normaliseRankEntry) : []
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function normaliseRankMe(wire) {
|
|
640
|
+
return {
|
|
641
|
+
rank: wire.rank,
|
|
642
|
+
total: wire.total,
|
|
643
|
+
entry: wire.entry ? normaliseRankEntry(wire.entry) : null
|
|
638
644
|
};
|
|
639
645
|
}
|
|
640
646
|
|
|
@@ -652,7 +658,13 @@ var RANK_LEADERBOARD_V2_QUERY = `query RankLeaderboardV2($input: RankBoardInput!
|
|
|
652
658
|
sortDir
|
|
653
659
|
total
|
|
654
660
|
entries { userId loginBy username rank pnl vol payout wins bids }
|
|
655
|
-
|
|
661
|
+
}
|
|
662
|
+
}`;
|
|
663
|
+
var RANK_ME_QUERY = `query RankMe($input: RankMeInput!) {
|
|
664
|
+
rank_me(input: $input) {
|
|
665
|
+
rank
|
|
666
|
+
total
|
|
667
|
+
entry { userId loginBy username rank pnl vol payout wins bids }
|
|
656
668
|
}
|
|
657
669
|
}`;
|
|
658
670
|
|
|
@@ -676,19 +688,17 @@ var LeaderboardModule = class {
|
|
|
676
688
|
return normaliseLeaderboard(body.leaderboard);
|
|
677
689
|
}
|
|
678
690
|
/**
|
|
679
|
-
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
691
|
+
* Fetch the public duration-scoped rank board (`rank_leaderboardV2`).
|
|
680
692
|
*
|
|
681
693
|
* Supports the fixed period presets plus `custom` (which requires an
|
|
682
694
|
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
683
|
-
* pagination, a `total` count for "#X of N" UI
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
* Optional args are omitted from the wire `input` when undefined so the
|
|
687
|
-
* server defaults apply (`sort = pnl`, `sortDir = desc`, `limit = 50`,
|
|
688
|
-
* `offset = 0`).
|
|
695
|
+
* pagination, and a `total` count for "#X of N" UI. Optional args are omitted
|
|
696
|
+
* from the wire `input` when undefined so the server defaults apply
|
|
697
|
+
* (`sort = pnl`, `sortDir = desc`, `limit = 50`, `offset = 0`).
|
|
689
698
|
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
699
|
+
* bid-260606-leaderboard-split-my-rank: the board is **public and identical for
|
|
700
|
+
* every caller** — it carries no per-user data. For the signed-in caller's own
|
|
701
|
+
* row+rank, use {@link LeaderboardModule.myRank}.
|
|
692
702
|
*/
|
|
693
703
|
async rankBoard(args) {
|
|
694
704
|
const input = { period: args.period };
|
|
@@ -698,13 +708,34 @@ var LeaderboardModule = class {
|
|
|
698
708
|
if (args.limit != null || args.offset != null) {
|
|
699
709
|
input.p = { limit: args.limit, offset: args.offset };
|
|
700
710
|
}
|
|
701
|
-
const body = await this.#graphql.
|
|
711
|
+
const body = await this.#graphql.publicRequest(
|
|
702
712
|
RANK_LEADERBOARD_V2_QUERY,
|
|
703
713
|
{ input },
|
|
704
714
|
args.signal ? { signal: args.signal } : void 0
|
|
705
715
|
);
|
|
706
716
|
return normaliseRankBoard(body.rank_leaderboardV2);
|
|
707
717
|
}
|
|
718
|
+
/**
|
|
719
|
+
* Fetch the signed-in caller's own row + rank for the same window (`rank_me`) —
|
|
720
|
+
* the per-user companion to {@link LeaderboardModule.rankBoard}.
|
|
721
|
+
*
|
|
722
|
+
* Unlike the board, this attaches the user JWT (`request`, not `publicRequest`)
|
|
723
|
+
* so the backend resolves the caller. Returns `null` when no user is signed in
|
|
724
|
+
* (the backend returns `rank_me: null`). `MyRank.entry` is `null` when the
|
|
725
|
+
* caller has no activity in the window.
|
|
726
|
+
*/
|
|
727
|
+
async myRank(args) {
|
|
728
|
+
const input = { period: args.period };
|
|
729
|
+
if (args.range) input.range = { from: args.range.from, to: args.range.to };
|
|
730
|
+
if (args.sort) input.sort = args.sort;
|
|
731
|
+
if (args.sortDir) input.sortDir = args.sortDir;
|
|
732
|
+
const body = await this.#graphql.request(
|
|
733
|
+
RANK_ME_QUERY,
|
|
734
|
+
{ input },
|
|
735
|
+
args.signal ? { signal: args.signal } : void 0
|
|
736
|
+
);
|
|
737
|
+
return body.rank_me ? normaliseRankMe(body.rank_me) : null;
|
|
738
|
+
}
|
|
708
739
|
};
|
|
709
740
|
|
|
710
741
|
// src/modules/locale/normalise.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -312,8 +312,16 @@ interface RankBoard {
|
|
|
312
312
|
/** All active users in the window → "#X of N". */
|
|
313
313
|
total: number;
|
|
314
314
|
entries: RankEntry[];
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The signed-in caller's own row + rank (`rank_me`), split out of {@link RankBoard} so the
|
|
318
|
+
* board stays a pure public/cacheable read. `entry` is `null` when the caller has no activity
|
|
319
|
+
* in the window (`rank` is then 0); `total` is the ranked-pool size for "#rank of total".
|
|
320
|
+
*/
|
|
321
|
+
interface MyRank {
|
|
322
|
+
rank: number;
|
|
323
|
+
entry: RankEntry | null;
|
|
324
|
+
total: number;
|
|
317
325
|
}
|
|
318
326
|
|
|
319
327
|
interface LeaderboardModuleDeps {
|
|
@@ -333,19 +341,17 @@ declare class LeaderboardModule {
|
|
|
333
341
|
signal?: AbortSignal;
|
|
334
342
|
}): Promise<LeaderboardEntry[]>;
|
|
335
343
|
/**
|
|
336
|
-
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
344
|
+
* Fetch the public duration-scoped rank board (`rank_leaderboardV2`).
|
|
337
345
|
*
|
|
338
346
|
* Supports the fixed period presets plus `custom` (which requires an
|
|
339
347
|
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
340
|
-
* pagination, a `total` count for "#X of N" UI
|
|
341
|
-
*
|
|
348
|
+
* pagination, and a `total` count for "#X of N" UI. Optional args are omitted
|
|
349
|
+
* from the wire `input` when undefined so the server defaults apply
|
|
350
|
+
* (`sort = pnl`, `sortDir = desc`, `limit = 50`, `offset = 0`).
|
|
342
351
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
* `me` is `null` for anonymous callers (the backend populates it only from an
|
|
348
|
-
* authenticated session).
|
|
352
|
+
* bid-260606-leaderboard-split-my-rank: the board is **public and identical for
|
|
353
|
+
* every caller** — it carries no per-user data. For the signed-in caller's own
|
|
354
|
+
* row+rank, use {@link LeaderboardModule.myRank}.
|
|
349
355
|
*/
|
|
350
356
|
rankBoard(args: {
|
|
351
357
|
period: RankPeriod;
|
|
@@ -360,6 +366,26 @@ declare class LeaderboardModule {
|
|
|
360
366
|
offset?: number;
|
|
361
367
|
signal?: AbortSignal;
|
|
362
368
|
}): Promise<RankBoard>;
|
|
369
|
+
/**
|
|
370
|
+
* Fetch the signed-in caller's own row + rank for the same window (`rank_me`) —
|
|
371
|
+
* the per-user companion to {@link LeaderboardModule.rankBoard}.
|
|
372
|
+
*
|
|
373
|
+
* Unlike the board, this attaches the user JWT (`request`, not `publicRequest`)
|
|
374
|
+
* so the backend resolves the caller. Returns `null` when no user is signed in
|
|
375
|
+
* (the backend returns `rank_me: null`). `MyRank.entry` is `null` when the
|
|
376
|
+
* caller has no activity in the window.
|
|
377
|
+
*/
|
|
378
|
+
myRank(args: {
|
|
379
|
+
period: RankPeriod;
|
|
380
|
+
/** ISO 8601 UTC, hour-aligned. Required iff `period === 'custom'`. */
|
|
381
|
+
range?: {
|
|
382
|
+
from: string;
|
|
383
|
+
to: string;
|
|
384
|
+
};
|
|
385
|
+
sort?: RankSort;
|
|
386
|
+
sortDir?: SortDir;
|
|
387
|
+
signal?: AbortSignal;
|
|
388
|
+
}): Promise<MyRank | null>;
|
|
363
389
|
}
|
|
364
390
|
|
|
365
391
|
/**
|
|
@@ -1098,4 +1124,4 @@ declare function adaptiveSimpson(f: (x: number) => number, a: number, b: number,
|
|
|
1098
1124
|
declare function calculateProbWin(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1099
1125
|
declare function calculateProbWin_v2(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1100
1126
|
|
|
1101
|
-
export { type AgencyPairFilter, AgencyPairModule, type AgencyPairStats, type AgencyPairStatus, AuthModule, type BackendHealth, type Bid, BidModule, type BidStatus, type CancelBidResult, type Candle, type Constraints, type Currency, GameChannel, type GameConfig, type GridConfig, type LeaderboardEntry, LeaderboardModule, type LeaderboardPeriod, type LeaderboardSortBy, LocaleModule, type LocaleRefreshResult, type LocaleResponse, type LocaleTranslations, type LoginResult, type Me, type MqttAcceptedBid, type MqttAgencyPairStatsEvent, type MqttBalanceEvent, type MqttBidAcceptedEvent, type MqttBidLostEvent, type MqttBidWonEvent, type MqttCandleEvent, type MqttConfigEvent, type MqttIdealConfigEvent, type MqttWalletBalanceEvent, type NetworkLevel, type NetworkQuality, NetworkQualityMonitor, type Pair, type PairInfo, PairModule, type PlaceBidInput, type RankBoard, type RankEntry, type RankPeriod, type RankSort, RealtimeModule, type Sample, type SampleReason, type SignalSource, type SortDir, TaphubAuthError, TaphubClient, type TaphubClientConfig, TaphubError, TaphubEventBus, type TaphubEventMap, TaphubNetworkError, TaphubServerError, TaphubSlippageError, TaphubStorage, type TaphubStorageAdapter, TaphubValidationError, type User, UserModule, type UserPnL, type UserPnLPeriod, type Wallet as UserWallet, type Wallet$1 as Wallet, type WalletBalanceReason, WalletChannel, adaptiveSimpson, autoDetectStorage, calculateProbWin, calculateProbWin_v2, errorFunction, isCancelled, isLoss, isPending, isTerminal, isWin, normalCDF, normalPDF };
|
|
1127
|
+
export { type AgencyPairFilter, AgencyPairModule, type AgencyPairStats, type AgencyPairStatus, AuthModule, type BackendHealth, type Bid, BidModule, type BidStatus, type CancelBidResult, type Candle, type Constraints, type Currency, GameChannel, type GameConfig, type GridConfig, type LeaderboardEntry, LeaderboardModule, type LeaderboardPeriod, type LeaderboardSortBy, LocaleModule, type LocaleRefreshResult, type LocaleResponse, type LocaleTranslations, type LoginResult, type Me, type MqttAcceptedBid, type MqttAgencyPairStatsEvent, type MqttBalanceEvent, type MqttBidAcceptedEvent, type MqttBidLostEvent, type MqttBidWonEvent, type MqttCandleEvent, type MqttConfigEvent, type MqttIdealConfigEvent, type MqttWalletBalanceEvent, type MyRank, type NetworkLevel, type NetworkQuality, NetworkQualityMonitor, type Pair, type PairInfo, PairModule, type PlaceBidInput, type RankBoard, type RankEntry, type RankPeriod, type RankSort, RealtimeModule, type Sample, type SampleReason, type SignalSource, type SortDir, TaphubAuthError, TaphubClient, type TaphubClientConfig, TaphubError, TaphubEventBus, type TaphubEventMap, TaphubNetworkError, TaphubServerError, TaphubSlippageError, TaphubStorage, type TaphubStorageAdapter, TaphubValidationError, type User, UserModule, type UserPnL, type UserPnLPeriod, type Wallet as UserWallet, type Wallet$1 as Wallet, type WalletBalanceReason, WalletChannel, adaptiveSimpson, autoDetectStorage, calculateProbWin, calculateProbWin_v2, errorFunction, isCancelled, isLoss, isPending, isTerminal, isWin, normalCDF, normalPDF };
|
package/dist/index.d.ts
CHANGED
|
@@ -312,8 +312,16 @@ interface RankBoard {
|
|
|
312
312
|
/** All active users in the window → "#X of N". */
|
|
313
313
|
total: number;
|
|
314
314
|
entries: RankEntry[];
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The signed-in caller's own row + rank (`rank_me`), split out of {@link RankBoard} so the
|
|
318
|
+
* board stays a pure public/cacheable read. `entry` is `null` when the caller has no activity
|
|
319
|
+
* in the window (`rank` is then 0); `total` is the ranked-pool size for "#rank of total".
|
|
320
|
+
*/
|
|
321
|
+
interface MyRank {
|
|
322
|
+
rank: number;
|
|
323
|
+
entry: RankEntry | null;
|
|
324
|
+
total: number;
|
|
317
325
|
}
|
|
318
326
|
|
|
319
327
|
interface LeaderboardModuleDeps {
|
|
@@ -333,19 +341,17 @@ declare class LeaderboardModule {
|
|
|
333
341
|
signal?: AbortSignal;
|
|
334
342
|
}): Promise<LeaderboardEntry[]>;
|
|
335
343
|
/**
|
|
336
|
-
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
344
|
+
* Fetch the public duration-scoped rank board (`rank_leaderboardV2`).
|
|
337
345
|
*
|
|
338
346
|
* Supports the fixed period presets plus `custom` (which requires an
|
|
339
347
|
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
340
|
-
* pagination, a `total` count for "#X of N" UI
|
|
341
|
-
*
|
|
348
|
+
* pagination, and a `total` count for "#X of N" UI. Optional args are omitted
|
|
349
|
+
* from the wire `input` when undefined so the server defaults apply
|
|
350
|
+
* (`sort = pnl`, `sortDir = desc`, `limit = 50`, `offset = 0`).
|
|
342
351
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
* `me` is `null` for anonymous callers (the backend populates it only from an
|
|
348
|
-
* authenticated session).
|
|
352
|
+
* bid-260606-leaderboard-split-my-rank: the board is **public and identical for
|
|
353
|
+
* every caller** — it carries no per-user data. For the signed-in caller's own
|
|
354
|
+
* row+rank, use {@link LeaderboardModule.myRank}.
|
|
349
355
|
*/
|
|
350
356
|
rankBoard(args: {
|
|
351
357
|
period: RankPeriod;
|
|
@@ -360,6 +366,26 @@ declare class LeaderboardModule {
|
|
|
360
366
|
offset?: number;
|
|
361
367
|
signal?: AbortSignal;
|
|
362
368
|
}): Promise<RankBoard>;
|
|
369
|
+
/**
|
|
370
|
+
* Fetch the signed-in caller's own row + rank for the same window (`rank_me`) —
|
|
371
|
+
* the per-user companion to {@link LeaderboardModule.rankBoard}.
|
|
372
|
+
*
|
|
373
|
+
* Unlike the board, this attaches the user JWT (`request`, not `publicRequest`)
|
|
374
|
+
* so the backend resolves the caller. Returns `null` when no user is signed in
|
|
375
|
+
* (the backend returns `rank_me: null`). `MyRank.entry` is `null` when the
|
|
376
|
+
* caller has no activity in the window.
|
|
377
|
+
*/
|
|
378
|
+
myRank(args: {
|
|
379
|
+
period: RankPeriod;
|
|
380
|
+
/** ISO 8601 UTC, hour-aligned. Required iff `period === 'custom'`. */
|
|
381
|
+
range?: {
|
|
382
|
+
from: string;
|
|
383
|
+
to: string;
|
|
384
|
+
};
|
|
385
|
+
sort?: RankSort;
|
|
386
|
+
sortDir?: SortDir;
|
|
387
|
+
signal?: AbortSignal;
|
|
388
|
+
}): Promise<MyRank | null>;
|
|
363
389
|
}
|
|
364
390
|
|
|
365
391
|
/**
|
|
@@ -1098,4 +1124,4 @@ declare function adaptiveSimpson(f: (x: number) => number, a: number, b: number,
|
|
|
1098
1124
|
declare function calculateProbWin(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1099
1125
|
declare function calculateProbWin_v2(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1100
1126
|
|
|
1101
|
-
export { type AgencyPairFilter, AgencyPairModule, type AgencyPairStats, type AgencyPairStatus, AuthModule, type BackendHealth, type Bid, BidModule, type BidStatus, type CancelBidResult, type Candle, type Constraints, type Currency, GameChannel, type GameConfig, type GridConfig, type LeaderboardEntry, LeaderboardModule, type LeaderboardPeriod, type LeaderboardSortBy, LocaleModule, type LocaleRefreshResult, type LocaleResponse, type LocaleTranslations, type LoginResult, type Me, type MqttAcceptedBid, type MqttAgencyPairStatsEvent, type MqttBalanceEvent, type MqttBidAcceptedEvent, type MqttBidLostEvent, type MqttBidWonEvent, type MqttCandleEvent, type MqttConfigEvent, type MqttIdealConfigEvent, type MqttWalletBalanceEvent, type NetworkLevel, type NetworkQuality, NetworkQualityMonitor, type Pair, type PairInfo, PairModule, type PlaceBidInput, type RankBoard, type RankEntry, type RankPeriod, type RankSort, RealtimeModule, type Sample, type SampleReason, type SignalSource, type SortDir, TaphubAuthError, TaphubClient, type TaphubClientConfig, TaphubError, TaphubEventBus, type TaphubEventMap, TaphubNetworkError, TaphubServerError, TaphubSlippageError, TaphubStorage, type TaphubStorageAdapter, TaphubValidationError, type User, UserModule, type UserPnL, type UserPnLPeriod, type Wallet as UserWallet, type Wallet$1 as Wallet, type WalletBalanceReason, WalletChannel, adaptiveSimpson, autoDetectStorage, calculateProbWin, calculateProbWin_v2, errorFunction, isCancelled, isLoss, isPending, isTerminal, isWin, normalCDF, normalPDF };
|
|
1127
|
+
export { type AgencyPairFilter, AgencyPairModule, type AgencyPairStats, type AgencyPairStatus, AuthModule, type BackendHealth, type Bid, BidModule, type BidStatus, type CancelBidResult, type Candle, type Constraints, type Currency, GameChannel, type GameConfig, type GridConfig, type LeaderboardEntry, LeaderboardModule, type LeaderboardPeriod, type LeaderboardSortBy, LocaleModule, type LocaleRefreshResult, type LocaleResponse, type LocaleTranslations, type LoginResult, type Me, type MqttAcceptedBid, type MqttAgencyPairStatsEvent, type MqttBalanceEvent, type MqttBidAcceptedEvent, type MqttBidLostEvent, type MqttBidWonEvent, type MqttCandleEvent, type MqttConfigEvent, type MqttIdealConfigEvent, type MqttWalletBalanceEvent, type MyRank, type NetworkLevel, type NetworkQuality, NetworkQualityMonitor, type Pair, type PairInfo, PairModule, type PlaceBidInput, type RankBoard, type RankEntry, type RankPeriod, type RankSort, RealtimeModule, type Sample, type SampleReason, type SignalSource, type SortDir, TaphubAuthError, TaphubClient, type TaphubClientConfig, TaphubError, TaphubEventBus, type TaphubEventMap, TaphubNetworkError, TaphubServerError, TaphubSlippageError, TaphubStorage, type TaphubStorageAdapter, TaphubValidationError, type User, UserModule, type UserPnL, type UserPnLPeriod, type Wallet as UserWallet, type Wallet$1 as Wallet, type WalletBalanceReason, WalletChannel, adaptiveSimpson, autoDetectStorage, calculateProbWin, calculateProbWin_v2, errorFunction, isCancelled, isLoss, isPending, isTerminal, isWin, normalCDF, normalPDF };
|
package/dist/index.js
CHANGED
|
@@ -568,8 +568,14 @@ function normaliseRankBoard(wire) {
|
|
|
568
568
|
sort: wire.sort,
|
|
569
569
|
sortDir: wire.sortDir,
|
|
570
570
|
total: wire.total,
|
|
571
|
-
entries: Array.isArray(wire.entries) ? wire.entries.map(normaliseRankEntry) : []
|
|
572
|
-
|
|
571
|
+
entries: Array.isArray(wire.entries) ? wire.entries.map(normaliseRankEntry) : []
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function normaliseRankMe(wire) {
|
|
575
|
+
return {
|
|
576
|
+
rank: wire.rank,
|
|
577
|
+
total: wire.total,
|
|
578
|
+
entry: wire.entry ? normaliseRankEntry(wire.entry) : null
|
|
573
579
|
};
|
|
574
580
|
}
|
|
575
581
|
|
|
@@ -587,7 +593,13 @@ var RANK_LEADERBOARD_V2_QUERY = `query RankLeaderboardV2($input: RankBoardInput!
|
|
|
587
593
|
sortDir
|
|
588
594
|
total
|
|
589
595
|
entries { userId loginBy username rank pnl vol payout wins bids }
|
|
590
|
-
|
|
596
|
+
}
|
|
597
|
+
}`;
|
|
598
|
+
var RANK_ME_QUERY = `query RankMe($input: RankMeInput!) {
|
|
599
|
+
rank_me(input: $input) {
|
|
600
|
+
rank
|
|
601
|
+
total
|
|
602
|
+
entry { userId loginBy username rank pnl vol payout wins bids }
|
|
591
603
|
}
|
|
592
604
|
}`;
|
|
593
605
|
|
|
@@ -611,19 +623,17 @@ var LeaderboardModule = class {
|
|
|
611
623
|
return normaliseLeaderboard(body.leaderboard);
|
|
612
624
|
}
|
|
613
625
|
/**
|
|
614
|
-
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
626
|
+
* Fetch the public duration-scoped rank board (`rank_leaderboardV2`).
|
|
615
627
|
*
|
|
616
628
|
* Supports the fixed period presets plus `custom` (which requires an
|
|
617
629
|
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
618
|
-
* pagination, a `total` count for "#X of N" UI
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
* Optional args are omitted from the wire `input` when undefined so the
|
|
622
|
-
* server defaults apply (`sort = pnl`, `sortDir = desc`, `limit = 50`,
|
|
623
|
-
* `offset = 0`).
|
|
630
|
+
* pagination, and a `total` count for "#X of N" UI. Optional args are omitted
|
|
631
|
+
* from the wire `input` when undefined so the server defaults apply
|
|
632
|
+
* (`sort = pnl`, `sortDir = desc`, `limit = 50`, `offset = 0`).
|
|
624
633
|
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
634
|
+
* bid-260606-leaderboard-split-my-rank: the board is **public and identical for
|
|
635
|
+
* every caller** — it carries no per-user data. For the signed-in caller's own
|
|
636
|
+
* row+rank, use {@link LeaderboardModule.myRank}.
|
|
627
637
|
*/
|
|
628
638
|
async rankBoard(args) {
|
|
629
639
|
const input = { period: args.period };
|
|
@@ -633,13 +643,34 @@ var LeaderboardModule = class {
|
|
|
633
643
|
if (args.limit != null || args.offset != null) {
|
|
634
644
|
input.p = { limit: args.limit, offset: args.offset };
|
|
635
645
|
}
|
|
636
|
-
const body = await this.#graphql.
|
|
646
|
+
const body = await this.#graphql.publicRequest(
|
|
637
647
|
RANK_LEADERBOARD_V2_QUERY,
|
|
638
648
|
{ input },
|
|
639
649
|
args.signal ? { signal: args.signal } : void 0
|
|
640
650
|
);
|
|
641
651
|
return normaliseRankBoard(body.rank_leaderboardV2);
|
|
642
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* Fetch the signed-in caller's own row + rank for the same window (`rank_me`) —
|
|
655
|
+
* the per-user companion to {@link LeaderboardModule.rankBoard}.
|
|
656
|
+
*
|
|
657
|
+
* Unlike the board, this attaches the user JWT (`request`, not `publicRequest`)
|
|
658
|
+
* so the backend resolves the caller. Returns `null` when no user is signed in
|
|
659
|
+
* (the backend returns `rank_me: null`). `MyRank.entry` is `null` when the
|
|
660
|
+
* caller has no activity in the window.
|
|
661
|
+
*/
|
|
662
|
+
async myRank(args) {
|
|
663
|
+
const input = { period: args.period };
|
|
664
|
+
if (args.range) input.range = { from: args.range.from, to: args.range.to };
|
|
665
|
+
if (args.sort) input.sort = args.sort;
|
|
666
|
+
if (args.sortDir) input.sortDir = args.sortDir;
|
|
667
|
+
const body = await this.#graphql.request(
|
|
668
|
+
RANK_ME_QUERY,
|
|
669
|
+
{ input },
|
|
670
|
+
args.signal ? { signal: args.signal } : void 0
|
|
671
|
+
);
|
|
672
|
+
return body.rank_me ? normaliseRankMe(body.rank_me) : null;
|
|
673
|
+
}
|
|
643
674
|
};
|
|
644
675
|
|
|
645
676
|
// src/modules/locale/normalise.ts
|