@taphubhq/sdk-core 0.19.0 → 0.20.1
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 +75 -0
- package/dist/index.d.mts +79 -1
- package/dist/index.d.ts +79 -1
- package/dist/index.js +75 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -608,6 +608,35 @@ function normaliseLeaderboard(rows) {
|
|
|
608
608
|
gain: row.gain
|
|
609
609
|
}));
|
|
610
610
|
}
|
|
611
|
+
function normaliseRankEntry(row) {
|
|
612
|
+
return {
|
|
613
|
+
userId: row.userId,
|
|
614
|
+
loginBy: row.loginBy,
|
|
615
|
+
username: row.username,
|
|
616
|
+
rank: row.rank,
|
|
617
|
+
pnl: row.pnl,
|
|
618
|
+
vol: row.vol,
|
|
619
|
+
payout: row.payout,
|
|
620
|
+
wins: row.wins,
|
|
621
|
+
bids: row.bids
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
function normaliseRankBoard(wire) {
|
|
625
|
+
if (wire == null || typeof wire !== "object") {
|
|
626
|
+
throw new TaphubServerError("Invalid response from server", {
|
|
627
|
+
code: "InvalidResponse"
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
return {
|
|
631
|
+
period: wire.period,
|
|
632
|
+
range: { from: wire.range?.from, to: wire.range?.to },
|
|
633
|
+
sort: wire.sort,
|
|
634
|
+
sortDir: wire.sortDir,
|
|
635
|
+
total: wire.total,
|
|
636
|
+
entries: Array.isArray(wire.entries) ? wire.entries.map(normaliseRankEntry) : [],
|
|
637
|
+
me: wire.me ? normaliseRankEntry(wire.me) : null
|
|
638
|
+
};
|
|
639
|
+
}
|
|
611
640
|
|
|
612
641
|
// src/modules/leaderboard/queries.ts
|
|
613
642
|
var LEADERBOARD_QUERY = `query Leaderboard($period: String!, $sort_by: String!) {
|
|
@@ -615,6 +644,17 @@ var LEADERBOARD_QUERY = `query Leaderboard($period: String!, $sort_by: String!)
|
|
|
615
644
|
user_id username rank total_bids total_wins total_wagered total_payout gain
|
|
616
645
|
}
|
|
617
646
|
}`;
|
|
647
|
+
var RANK_LEADERBOARD_V2_QUERY = `query RankLeaderboardV2($input: RankBoardInput!) {
|
|
648
|
+
rank_leaderboardV2(input: $input) {
|
|
649
|
+
period
|
|
650
|
+
range { from to }
|
|
651
|
+
sort
|
|
652
|
+
sortDir
|
|
653
|
+
total
|
|
654
|
+
entries { userId loginBy username rank pnl vol payout wins bids }
|
|
655
|
+
me { userId loginBy username rank pnl vol payout wins bids }
|
|
656
|
+
}
|
|
657
|
+
}`;
|
|
618
658
|
|
|
619
659
|
// src/modules/leaderboard/index.ts
|
|
620
660
|
var LeaderboardModule = class {
|
|
@@ -622,6 +662,11 @@ var LeaderboardModule = class {
|
|
|
622
662
|
constructor(deps) {
|
|
623
663
|
this.#graphql = deps.graphql;
|
|
624
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* @deprecated Use {@link LeaderboardModule.rankBoard}. The backend
|
|
667
|
+
* `leaderboard` query is `@deprecated` in favour of `rank_leaderboardV2`
|
|
668
|
+
* (duration presets, pnl/vol sort, pagination, current-user `me`).
|
|
669
|
+
*/
|
|
625
670
|
async list(args) {
|
|
626
671
|
const body = await this.#graphql.publicRequest(
|
|
627
672
|
LEADERBOARD_QUERY,
|
|
@@ -630,6 +675,36 @@ var LeaderboardModule = class {
|
|
|
630
675
|
);
|
|
631
676
|
return normaliseLeaderboard(body.leaderboard);
|
|
632
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
680
|
+
*
|
|
681
|
+
* Supports the fixed period presets plus `custom` (which requires an
|
|
682
|
+
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
683
|
+
* pagination, a `total` count for "#X of N" UI, and `me` — the caller's own
|
|
684
|
+
* row+rank even when outside the requested page.
|
|
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`).
|
|
689
|
+
*
|
|
690
|
+
* `me` is `null` for anonymous callers (the backend populates it only from an
|
|
691
|
+
* authenticated session).
|
|
692
|
+
*/
|
|
693
|
+
async rankBoard(args) {
|
|
694
|
+
const input = { period: args.period };
|
|
695
|
+
if (args.range) input.range = { from: args.range.from, to: args.range.to };
|
|
696
|
+
if (args.sort) input.sort = args.sort;
|
|
697
|
+
if (args.sortDir) input.sortDir = args.sortDir;
|
|
698
|
+
if (args.limit != null || args.offset != null) {
|
|
699
|
+
input.p = { limit: args.limit, offset: args.offset };
|
|
700
|
+
}
|
|
701
|
+
const body = await this.#graphql.request(
|
|
702
|
+
RANK_LEADERBOARD_V2_QUERY,
|
|
703
|
+
{ input },
|
|
704
|
+
args.signal ? { signal: args.signal } : void 0
|
|
705
|
+
);
|
|
706
|
+
return normaliseRankBoard(body.rank_leaderboardV2);
|
|
707
|
+
}
|
|
633
708
|
};
|
|
634
709
|
|
|
635
710
|
// src/modules/locale/normalise.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -261,7 +261,15 @@ declare class BidModule {
|
|
|
261
261
|
}): Promise<Bid[]>;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
/**
|
|
265
|
+
* @deprecated Use {@link RankPeriod} with `client.leaderboard.rankBoard`. The
|
|
266
|
+
* v1 `leaderboard` query is `@deprecated` on the backend in favour of
|
|
267
|
+
* `rank_leaderboardV2` (duration presets + current-user rank + pnl/vol).
|
|
268
|
+
*/
|
|
264
269
|
type LeaderboardPeriod = 'weekly' | 'all_time';
|
|
270
|
+
/**
|
|
271
|
+
* @deprecated Use {@link RankSort} with `client.leaderboard.rankBoard`.
|
|
272
|
+
*/
|
|
265
273
|
type LeaderboardSortBy = 'gain' | 'wagered';
|
|
266
274
|
interface LeaderboardEntry {
|
|
267
275
|
userId: string;
|
|
@@ -273,6 +281,40 @@ interface LeaderboardEntry {
|
|
|
273
281
|
totalPayout: string;
|
|
274
282
|
gain: string;
|
|
275
283
|
}
|
|
284
|
+
/** Fixed duration filters. `custom` requires an hour-aligned `range`. */
|
|
285
|
+
type RankPeriod = 'today' | 'yesterday' | 'last_7d' | 'last_30d' | 'all_time' | 'custom';
|
|
286
|
+
/** `pnl` = net profit (payout - vol); `vol` = wagered volume. */
|
|
287
|
+
type RankSort = 'pnl' | 'vol';
|
|
288
|
+
type SortDir = 'asc' | 'desc';
|
|
289
|
+
interface RankEntry {
|
|
290
|
+
userId: string;
|
|
291
|
+
/** Same denormalised value as `username`; dashboard display alias. */
|
|
292
|
+
loginBy: string;
|
|
293
|
+
username: string;
|
|
294
|
+
rank: number;
|
|
295
|
+
/** Net profit = payout - vol (decimal as string). */
|
|
296
|
+
pnl: string;
|
|
297
|
+
/** Total wagered volume (decimal as string). */
|
|
298
|
+
vol: string;
|
|
299
|
+
payout: string;
|
|
300
|
+
wins: number;
|
|
301
|
+
bids: number;
|
|
302
|
+
}
|
|
303
|
+
interface RankBoard {
|
|
304
|
+
period: RankPeriod;
|
|
305
|
+
/** Resolved window (after hour-align) for UI display. */
|
|
306
|
+
range: {
|
|
307
|
+
from: string;
|
|
308
|
+
to: string;
|
|
309
|
+
};
|
|
310
|
+
sort: RankSort;
|
|
311
|
+
sortDir: SortDir;
|
|
312
|
+
/** All active users in the window → "#X of N". */
|
|
313
|
+
total: number;
|
|
314
|
+
entries: RankEntry[];
|
|
315
|
+
/** Caller's own row+rank even if outside the page; `null` when anon. */
|
|
316
|
+
me: RankEntry | null;
|
|
317
|
+
}
|
|
276
318
|
|
|
277
319
|
interface LeaderboardModuleDeps {
|
|
278
320
|
graphql: GraphQLTransport;
|
|
@@ -280,11 +322,44 @@ interface LeaderboardModuleDeps {
|
|
|
280
322
|
declare class LeaderboardModule {
|
|
281
323
|
#private;
|
|
282
324
|
constructor(deps: LeaderboardModuleDeps);
|
|
325
|
+
/**
|
|
326
|
+
* @deprecated Use {@link LeaderboardModule.rankBoard}. The backend
|
|
327
|
+
* `leaderboard` query is `@deprecated` in favour of `rank_leaderboardV2`
|
|
328
|
+
* (duration presets, pnl/vol sort, pagination, current-user `me`).
|
|
329
|
+
*/
|
|
283
330
|
list(args: {
|
|
284
331
|
period: LeaderboardPeriod;
|
|
285
332
|
sortBy: LeaderboardSortBy;
|
|
286
333
|
signal?: AbortSignal;
|
|
287
334
|
}): Promise<LeaderboardEntry[]>;
|
|
335
|
+
/**
|
|
336
|
+
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
337
|
+
*
|
|
338
|
+
* Supports the fixed period presets plus `custom` (which requires an
|
|
339
|
+
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
340
|
+
* pagination, a `total` count for "#X of N" UI, and `me` — the caller's own
|
|
341
|
+
* row+rank even when outside the requested page.
|
|
342
|
+
*
|
|
343
|
+
* Optional args are omitted from the wire `input` when undefined so the
|
|
344
|
+
* server defaults apply (`sort = pnl`, `sortDir = desc`, `limit = 50`,
|
|
345
|
+
* `offset = 0`).
|
|
346
|
+
*
|
|
347
|
+
* `me` is `null` for anonymous callers (the backend populates it only from an
|
|
348
|
+
* authenticated session).
|
|
349
|
+
*/
|
|
350
|
+
rankBoard(args: {
|
|
351
|
+
period: RankPeriod;
|
|
352
|
+
/** ISO 8601 UTC, hour-aligned. Required iff `period === 'custom'`. */
|
|
353
|
+
range?: {
|
|
354
|
+
from: string;
|
|
355
|
+
to: string;
|
|
356
|
+
};
|
|
357
|
+
sort?: RankSort;
|
|
358
|
+
sortDir?: SortDir;
|
|
359
|
+
limit?: number;
|
|
360
|
+
offset?: number;
|
|
361
|
+
signal?: AbortSignal;
|
|
362
|
+
}): Promise<RankBoard>;
|
|
288
363
|
}
|
|
289
364
|
|
|
290
365
|
/**
|
|
@@ -621,7 +696,10 @@ interface MqttCandleEvent {
|
|
|
621
696
|
interface MqttAcceptedBid {
|
|
622
697
|
id: string;
|
|
623
698
|
userId: string;
|
|
699
|
+
/** @deprecated use `pairId`; both carry the bare pair id (e.g. "grid-ETH-USD"). */
|
|
624
700
|
gameUuid: string;
|
|
701
|
+
/** Pair id, e.g. "grid-ETH-USD". */
|
|
702
|
+
pairId?: string;
|
|
625
703
|
currency: string;
|
|
626
704
|
amount: string;
|
|
627
705
|
coefficient: number;
|
|
@@ -1020,4 +1098,4 @@ declare function adaptiveSimpson(f: (x: number) => number, a: number, b: number,
|
|
|
1020
1098
|
declare function calculateProbWin(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1021
1099
|
declare function calculateProbWin_v2(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1022
1100
|
|
|
1023
|
-
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, RealtimeModule, type Sample, type SampleReason, type SignalSource, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -261,7 +261,15 @@ declare class BidModule {
|
|
|
261
261
|
}): Promise<Bid[]>;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
/**
|
|
265
|
+
* @deprecated Use {@link RankPeriod} with `client.leaderboard.rankBoard`. The
|
|
266
|
+
* v1 `leaderboard` query is `@deprecated` on the backend in favour of
|
|
267
|
+
* `rank_leaderboardV2` (duration presets + current-user rank + pnl/vol).
|
|
268
|
+
*/
|
|
264
269
|
type LeaderboardPeriod = 'weekly' | 'all_time';
|
|
270
|
+
/**
|
|
271
|
+
* @deprecated Use {@link RankSort} with `client.leaderboard.rankBoard`.
|
|
272
|
+
*/
|
|
265
273
|
type LeaderboardSortBy = 'gain' | 'wagered';
|
|
266
274
|
interface LeaderboardEntry {
|
|
267
275
|
userId: string;
|
|
@@ -273,6 +281,40 @@ interface LeaderboardEntry {
|
|
|
273
281
|
totalPayout: string;
|
|
274
282
|
gain: string;
|
|
275
283
|
}
|
|
284
|
+
/** Fixed duration filters. `custom` requires an hour-aligned `range`. */
|
|
285
|
+
type RankPeriod = 'today' | 'yesterday' | 'last_7d' | 'last_30d' | 'all_time' | 'custom';
|
|
286
|
+
/** `pnl` = net profit (payout - vol); `vol` = wagered volume. */
|
|
287
|
+
type RankSort = 'pnl' | 'vol';
|
|
288
|
+
type SortDir = 'asc' | 'desc';
|
|
289
|
+
interface RankEntry {
|
|
290
|
+
userId: string;
|
|
291
|
+
/** Same denormalised value as `username`; dashboard display alias. */
|
|
292
|
+
loginBy: string;
|
|
293
|
+
username: string;
|
|
294
|
+
rank: number;
|
|
295
|
+
/** Net profit = payout - vol (decimal as string). */
|
|
296
|
+
pnl: string;
|
|
297
|
+
/** Total wagered volume (decimal as string). */
|
|
298
|
+
vol: string;
|
|
299
|
+
payout: string;
|
|
300
|
+
wins: number;
|
|
301
|
+
bids: number;
|
|
302
|
+
}
|
|
303
|
+
interface RankBoard {
|
|
304
|
+
period: RankPeriod;
|
|
305
|
+
/** Resolved window (after hour-align) for UI display. */
|
|
306
|
+
range: {
|
|
307
|
+
from: string;
|
|
308
|
+
to: string;
|
|
309
|
+
};
|
|
310
|
+
sort: RankSort;
|
|
311
|
+
sortDir: SortDir;
|
|
312
|
+
/** All active users in the window → "#X of N". */
|
|
313
|
+
total: number;
|
|
314
|
+
entries: RankEntry[];
|
|
315
|
+
/** Caller's own row+rank even if outside the page; `null` when anon. */
|
|
316
|
+
me: RankEntry | null;
|
|
317
|
+
}
|
|
276
318
|
|
|
277
319
|
interface LeaderboardModuleDeps {
|
|
278
320
|
graphql: GraphQLTransport;
|
|
@@ -280,11 +322,44 @@ interface LeaderboardModuleDeps {
|
|
|
280
322
|
declare class LeaderboardModule {
|
|
281
323
|
#private;
|
|
282
324
|
constructor(deps: LeaderboardModuleDeps);
|
|
325
|
+
/**
|
|
326
|
+
* @deprecated Use {@link LeaderboardModule.rankBoard}. The backend
|
|
327
|
+
* `leaderboard` query is `@deprecated` in favour of `rank_leaderboardV2`
|
|
328
|
+
* (duration presets, pnl/vol sort, pagination, current-user `me`).
|
|
329
|
+
*/
|
|
283
330
|
list(args: {
|
|
284
331
|
period: LeaderboardPeriod;
|
|
285
332
|
sortBy: LeaderboardSortBy;
|
|
286
333
|
signal?: AbortSignal;
|
|
287
334
|
}): Promise<LeaderboardEntry[]>;
|
|
335
|
+
/**
|
|
336
|
+
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
337
|
+
*
|
|
338
|
+
* Supports the fixed period presets plus `custom` (which requires an
|
|
339
|
+
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
340
|
+
* pagination, a `total` count for "#X of N" UI, and `me` — the caller's own
|
|
341
|
+
* row+rank even when outside the requested page.
|
|
342
|
+
*
|
|
343
|
+
* Optional args are omitted from the wire `input` when undefined so the
|
|
344
|
+
* server defaults apply (`sort = pnl`, `sortDir = desc`, `limit = 50`,
|
|
345
|
+
* `offset = 0`).
|
|
346
|
+
*
|
|
347
|
+
* `me` is `null` for anonymous callers (the backend populates it only from an
|
|
348
|
+
* authenticated session).
|
|
349
|
+
*/
|
|
350
|
+
rankBoard(args: {
|
|
351
|
+
period: RankPeriod;
|
|
352
|
+
/** ISO 8601 UTC, hour-aligned. Required iff `period === 'custom'`. */
|
|
353
|
+
range?: {
|
|
354
|
+
from: string;
|
|
355
|
+
to: string;
|
|
356
|
+
};
|
|
357
|
+
sort?: RankSort;
|
|
358
|
+
sortDir?: SortDir;
|
|
359
|
+
limit?: number;
|
|
360
|
+
offset?: number;
|
|
361
|
+
signal?: AbortSignal;
|
|
362
|
+
}): Promise<RankBoard>;
|
|
288
363
|
}
|
|
289
364
|
|
|
290
365
|
/**
|
|
@@ -621,7 +696,10 @@ interface MqttCandleEvent {
|
|
|
621
696
|
interface MqttAcceptedBid {
|
|
622
697
|
id: string;
|
|
623
698
|
userId: string;
|
|
699
|
+
/** @deprecated use `pairId`; both carry the bare pair id (e.g. "grid-ETH-USD"). */
|
|
624
700
|
gameUuid: string;
|
|
701
|
+
/** Pair id, e.g. "grid-ETH-USD". */
|
|
702
|
+
pairId?: string;
|
|
625
703
|
currency: string;
|
|
626
704
|
amount: string;
|
|
627
705
|
coefficient: number;
|
|
@@ -1020,4 +1098,4 @@ declare function adaptiveSimpson(f: (x: number) => number, a: number, b: number,
|
|
|
1020
1098
|
declare function calculateProbWin(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1021
1099
|
declare function calculateProbWin_v2(time1: number, time2: number, _price1: number, price2: number, creationTime: number, currentPrice: number, volatility: number): number;
|
|
1022
1100
|
|
|
1023
|
-
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, RealtimeModule, type Sample, type SampleReason, type SignalSource, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -543,6 +543,35 @@ function normaliseLeaderboard(rows) {
|
|
|
543
543
|
gain: row.gain
|
|
544
544
|
}));
|
|
545
545
|
}
|
|
546
|
+
function normaliseRankEntry(row) {
|
|
547
|
+
return {
|
|
548
|
+
userId: row.userId,
|
|
549
|
+
loginBy: row.loginBy,
|
|
550
|
+
username: row.username,
|
|
551
|
+
rank: row.rank,
|
|
552
|
+
pnl: row.pnl,
|
|
553
|
+
vol: row.vol,
|
|
554
|
+
payout: row.payout,
|
|
555
|
+
wins: row.wins,
|
|
556
|
+
bids: row.bids
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function normaliseRankBoard(wire) {
|
|
560
|
+
if (wire == null || typeof wire !== "object") {
|
|
561
|
+
throw new TaphubServerError("Invalid response from server", {
|
|
562
|
+
code: "InvalidResponse"
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
return {
|
|
566
|
+
period: wire.period,
|
|
567
|
+
range: { from: wire.range?.from, to: wire.range?.to },
|
|
568
|
+
sort: wire.sort,
|
|
569
|
+
sortDir: wire.sortDir,
|
|
570
|
+
total: wire.total,
|
|
571
|
+
entries: Array.isArray(wire.entries) ? wire.entries.map(normaliseRankEntry) : [],
|
|
572
|
+
me: wire.me ? normaliseRankEntry(wire.me) : null
|
|
573
|
+
};
|
|
574
|
+
}
|
|
546
575
|
|
|
547
576
|
// src/modules/leaderboard/queries.ts
|
|
548
577
|
var LEADERBOARD_QUERY = `query Leaderboard($period: String!, $sort_by: String!) {
|
|
@@ -550,6 +579,17 @@ var LEADERBOARD_QUERY = `query Leaderboard($period: String!, $sort_by: String!)
|
|
|
550
579
|
user_id username rank total_bids total_wins total_wagered total_payout gain
|
|
551
580
|
}
|
|
552
581
|
}`;
|
|
582
|
+
var RANK_LEADERBOARD_V2_QUERY = `query RankLeaderboardV2($input: RankBoardInput!) {
|
|
583
|
+
rank_leaderboardV2(input: $input) {
|
|
584
|
+
period
|
|
585
|
+
range { from to }
|
|
586
|
+
sort
|
|
587
|
+
sortDir
|
|
588
|
+
total
|
|
589
|
+
entries { userId loginBy username rank pnl vol payout wins bids }
|
|
590
|
+
me { userId loginBy username rank pnl vol payout wins bids }
|
|
591
|
+
}
|
|
592
|
+
}`;
|
|
553
593
|
|
|
554
594
|
// src/modules/leaderboard/index.ts
|
|
555
595
|
var LeaderboardModule = class {
|
|
@@ -557,6 +597,11 @@ var LeaderboardModule = class {
|
|
|
557
597
|
constructor(deps) {
|
|
558
598
|
this.#graphql = deps.graphql;
|
|
559
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* @deprecated Use {@link LeaderboardModule.rankBoard}. The backend
|
|
602
|
+
* `leaderboard` query is `@deprecated` in favour of `rank_leaderboardV2`
|
|
603
|
+
* (duration presets, pnl/vol sort, pagination, current-user `me`).
|
|
604
|
+
*/
|
|
560
605
|
async list(args) {
|
|
561
606
|
const body = await this.#graphql.publicRequest(
|
|
562
607
|
LEADERBOARD_QUERY,
|
|
@@ -565,6 +610,36 @@ var LeaderboardModule = class {
|
|
|
565
610
|
);
|
|
566
611
|
return normaliseLeaderboard(body.leaderboard);
|
|
567
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* Fetch the duration-scoped rank board (`rank_leaderboardV2`).
|
|
615
|
+
*
|
|
616
|
+
* Supports the fixed period presets plus `custom` (which requires an
|
|
617
|
+
* hour-aligned `range`), `pnl`/`vol` sort with an explicit direction, offset
|
|
618
|
+
* pagination, a `total` count for "#X of N" UI, and `me` — the caller's own
|
|
619
|
+
* row+rank even when outside the requested page.
|
|
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`).
|
|
624
|
+
*
|
|
625
|
+
* `me` is `null` for anonymous callers (the backend populates it only from an
|
|
626
|
+
* authenticated session).
|
|
627
|
+
*/
|
|
628
|
+
async rankBoard(args) {
|
|
629
|
+
const input = { period: args.period };
|
|
630
|
+
if (args.range) input.range = { from: args.range.from, to: args.range.to };
|
|
631
|
+
if (args.sort) input.sort = args.sort;
|
|
632
|
+
if (args.sortDir) input.sortDir = args.sortDir;
|
|
633
|
+
if (args.limit != null || args.offset != null) {
|
|
634
|
+
input.p = { limit: args.limit, offset: args.offset };
|
|
635
|
+
}
|
|
636
|
+
const body = await this.#graphql.request(
|
|
637
|
+
RANK_LEADERBOARD_V2_QUERY,
|
|
638
|
+
{ input },
|
|
639
|
+
args.signal ? { signal: args.signal } : void 0
|
|
640
|
+
);
|
|
641
|
+
return normaliseRankBoard(body.rank_leaderboardV2);
|
|
642
|
+
}
|
|
568
643
|
};
|
|
569
644
|
|
|
570
645
|
// src/modules/locale/normalise.ts
|