@ascnd-gg/client 1.0.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/LICENSE +21 -0
- package/README.md +314 -0
- package/dist/index.cjs +253 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +635 -0
- package/dist/index.d.ts +635 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import { GenService, GenMessage } from '@bufbuild/protobuf/codegenv2';
|
|
2
|
+
import { Message } from '@bufbuild/protobuf';
|
|
3
|
+
export { create } from '@bufbuild/protobuf';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SubmitScoreRequest contains the score submission details.
|
|
7
|
+
*
|
|
8
|
+
* @generated from message ascnd.v1.SubmitScoreRequest
|
|
9
|
+
*/
|
|
10
|
+
type SubmitScoreRequest = Message<"ascnd.v1.SubmitScoreRequest"> & {
|
|
11
|
+
/**
|
|
12
|
+
* The leaderboard to submit the score to.
|
|
13
|
+
*
|
|
14
|
+
* @generated from field: string leaderboard_id = 1;
|
|
15
|
+
*/
|
|
16
|
+
leaderboardId: string;
|
|
17
|
+
/**
|
|
18
|
+
* The player's unique identifier (provided by the game).
|
|
19
|
+
*
|
|
20
|
+
* @generated from field: string player_id = 2;
|
|
21
|
+
*/
|
|
22
|
+
playerId: string;
|
|
23
|
+
/**
|
|
24
|
+
* The score value.
|
|
25
|
+
*
|
|
26
|
+
* @generated from field: int64 score = 3;
|
|
27
|
+
*/
|
|
28
|
+
score: bigint;
|
|
29
|
+
/**
|
|
30
|
+
* Optional metadata (JSON-encoded game-specific data).
|
|
31
|
+
*
|
|
32
|
+
* @generated from field: optional bytes metadata = 4;
|
|
33
|
+
*/
|
|
34
|
+
metadata?: Uint8Array;
|
|
35
|
+
/**
|
|
36
|
+
* Optional idempotency key to prevent duplicate submissions.
|
|
37
|
+
*
|
|
38
|
+
* @generated from field: optional string idempotency_key = 5;
|
|
39
|
+
*/
|
|
40
|
+
idempotencyKey?: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Describes the message ascnd.v1.SubmitScoreRequest.
|
|
44
|
+
* Use `create(SubmitScoreRequestSchema)` to create a new message.
|
|
45
|
+
*/
|
|
46
|
+
declare const SubmitScoreRequestSchema: GenMessage<SubmitScoreRequest>;
|
|
47
|
+
/**
|
|
48
|
+
* SubmitScoreResponse contains the result of the score submission.
|
|
49
|
+
*
|
|
50
|
+
* @generated from message ascnd.v1.SubmitScoreResponse
|
|
51
|
+
*/
|
|
52
|
+
type SubmitScoreResponse = Message<"ascnd.v1.SubmitScoreResponse"> & {
|
|
53
|
+
/**
|
|
54
|
+
* The unique identifier of the submitted score.
|
|
55
|
+
*
|
|
56
|
+
* @generated from field: string score_id = 1;
|
|
57
|
+
*/
|
|
58
|
+
scoreId: string;
|
|
59
|
+
/**
|
|
60
|
+
* The player's rank after this submission.
|
|
61
|
+
*
|
|
62
|
+
* @generated from field: int32 rank = 2;
|
|
63
|
+
*/
|
|
64
|
+
rank: number;
|
|
65
|
+
/**
|
|
66
|
+
* Whether this is the player's new best score for this period.
|
|
67
|
+
*
|
|
68
|
+
* @generated from field: bool is_new_best = 3;
|
|
69
|
+
*/
|
|
70
|
+
isNewBest: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the score was deduplicated (already submitted recently).
|
|
73
|
+
*
|
|
74
|
+
* @generated from field: bool was_deduplicated = 4;
|
|
75
|
+
*/
|
|
76
|
+
wasDeduplicated: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Anticheat validation result (if anticheat is enabled for this leaderboard).
|
|
79
|
+
*
|
|
80
|
+
* @generated from field: optional ascnd.v1.AnticheatResult anticheat = 5;
|
|
81
|
+
*/
|
|
82
|
+
anticheat?: AnticheatResult;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Describes the message ascnd.v1.SubmitScoreResponse.
|
|
86
|
+
* Use `create(SubmitScoreResponseSchema)` to create a new message.
|
|
87
|
+
*/
|
|
88
|
+
declare const SubmitScoreResponseSchema: GenMessage<SubmitScoreResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* AnticheatResult contains the result of anticheat validation.
|
|
91
|
+
*
|
|
92
|
+
* @generated from message ascnd.v1.AnticheatResult
|
|
93
|
+
*/
|
|
94
|
+
type AnticheatResult = Message<"ascnd.v1.AnticheatResult"> & {
|
|
95
|
+
/**
|
|
96
|
+
* Whether the score passed all anticheat checks.
|
|
97
|
+
*
|
|
98
|
+
* @generated from field: bool passed = 1;
|
|
99
|
+
*/
|
|
100
|
+
passed: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* List of violation flags that were triggered.
|
|
103
|
+
*
|
|
104
|
+
* @generated from field: repeated ascnd.v1.AnticheatViolation violations = 2;
|
|
105
|
+
*/
|
|
106
|
+
violations: AnticheatViolation[];
|
|
107
|
+
/**
|
|
108
|
+
* The enforcement action taken: "none", "flag", "shadow_ban", or "reject".
|
|
109
|
+
*
|
|
110
|
+
* @generated from field: string action = 3;
|
|
111
|
+
*/
|
|
112
|
+
action: string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Describes the message ascnd.v1.AnticheatResult.
|
|
116
|
+
* Use `create(AnticheatResultSchema)` to create a new message.
|
|
117
|
+
*/
|
|
118
|
+
declare const AnticheatResultSchema: GenMessage<AnticheatResult>;
|
|
119
|
+
/**
|
|
120
|
+
* AnticheatViolation describes a single anticheat rule violation.
|
|
121
|
+
*
|
|
122
|
+
* @generated from message ascnd.v1.AnticheatViolation
|
|
123
|
+
*/
|
|
124
|
+
type AnticheatViolation = Message<"ascnd.v1.AnticheatViolation"> & {
|
|
125
|
+
/**
|
|
126
|
+
* The type of violation: "bounds_exceeded", "velocity_exceeded",
|
|
127
|
+
* "duplicate_idempotency", "missing_idempotency_key".
|
|
128
|
+
*
|
|
129
|
+
* @generated from field: string flag_type = 1;
|
|
130
|
+
*/
|
|
131
|
+
flagType: string;
|
|
132
|
+
/**
|
|
133
|
+
* Human-readable description of the violation.
|
|
134
|
+
*
|
|
135
|
+
* @generated from field: string reason = 2;
|
|
136
|
+
*/
|
|
137
|
+
reason: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Describes the message ascnd.v1.AnticheatViolation.
|
|
141
|
+
* Use `create(AnticheatViolationSchema)` to create a new message.
|
|
142
|
+
*/
|
|
143
|
+
declare const AnticheatViolationSchema: GenMessage<AnticheatViolation>;
|
|
144
|
+
/**
|
|
145
|
+
* GetLeaderboardRequest specifies which leaderboard and page to retrieve.
|
|
146
|
+
*
|
|
147
|
+
* @generated from message ascnd.v1.GetLeaderboardRequest
|
|
148
|
+
*/
|
|
149
|
+
type GetLeaderboardRequest = Message<"ascnd.v1.GetLeaderboardRequest"> & {
|
|
150
|
+
/**
|
|
151
|
+
* The leaderboard to retrieve.
|
|
152
|
+
*
|
|
153
|
+
* @generated from field: string leaderboard_id = 1;
|
|
154
|
+
*/
|
|
155
|
+
leaderboardId: string;
|
|
156
|
+
/**
|
|
157
|
+
* Maximum number of entries to return (default: 10, max: 100).
|
|
158
|
+
*
|
|
159
|
+
* @generated from field: optional int32 limit = 2;
|
|
160
|
+
*/
|
|
161
|
+
limit?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Number of entries to skip for pagination.
|
|
164
|
+
*
|
|
165
|
+
* @generated from field: optional int32 offset = 3;
|
|
166
|
+
*/
|
|
167
|
+
offset?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Which period to retrieve: "current", "previous", or a timestamp.
|
|
170
|
+
*
|
|
171
|
+
* @generated from field: optional string period = 4;
|
|
172
|
+
*/
|
|
173
|
+
period?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Optional view slug to filter by metadata criteria.
|
|
176
|
+
* If provided, returns rankings within the view (not global rank).
|
|
177
|
+
*
|
|
178
|
+
* @generated from field: optional string view_slug = 5;
|
|
179
|
+
*/
|
|
180
|
+
viewSlug?: string;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Describes the message ascnd.v1.GetLeaderboardRequest.
|
|
184
|
+
* Use `create(GetLeaderboardRequestSchema)` to create a new message.
|
|
185
|
+
*/
|
|
186
|
+
declare const GetLeaderboardRequestSchema: GenMessage<GetLeaderboardRequest>;
|
|
187
|
+
/**
|
|
188
|
+
* GetLeaderboardResponse contains the leaderboard entries.
|
|
189
|
+
*
|
|
190
|
+
* @generated from message ascnd.v1.GetLeaderboardResponse
|
|
191
|
+
*/
|
|
192
|
+
type GetLeaderboardResponse = Message<"ascnd.v1.GetLeaderboardResponse"> & {
|
|
193
|
+
/**
|
|
194
|
+
* The leaderboard entries.
|
|
195
|
+
*
|
|
196
|
+
* @generated from field: repeated ascnd.v1.LeaderboardEntry entries = 1;
|
|
197
|
+
*/
|
|
198
|
+
entries: LeaderboardEntry[];
|
|
199
|
+
/**
|
|
200
|
+
* Approximate total number of entries.
|
|
201
|
+
*
|
|
202
|
+
* @generated from field: int32 total_entries = 2;
|
|
203
|
+
*/
|
|
204
|
+
totalEntries: number;
|
|
205
|
+
/**
|
|
206
|
+
* Whether there are more entries after this page.
|
|
207
|
+
*
|
|
208
|
+
* @generated from field: bool has_more = 3;
|
|
209
|
+
*/
|
|
210
|
+
hasMore: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* The start of the current period (ISO 8601 timestamp).
|
|
213
|
+
*
|
|
214
|
+
* @generated from field: string period_start = 4;
|
|
215
|
+
*/
|
|
216
|
+
periodStart: string;
|
|
217
|
+
/**
|
|
218
|
+
* The end of the current period, if applicable (ISO 8601 timestamp).
|
|
219
|
+
*
|
|
220
|
+
* @generated from field: optional string period_end = 5;
|
|
221
|
+
*/
|
|
222
|
+
periodEnd?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Active view info if filtering by view_slug.
|
|
225
|
+
*
|
|
226
|
+
* @generated from field: optional ascnd.v1.ViewInfo view = 6;
|
|
227
|
+
*/
|
|
228
|
+
view?: ViewInfo;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Describes the message ascnd.v1.GetLeaderboardResponse.
|
|
232
|
+
* Use `create(GetLeaderboardResponseSchema)` to create a new message.
|
|
233
|
+
*/
|
|
234
|
+
declare const GetLeaderboardResponseSchema: GenMessage<GetLeaderboardResponse>;
|
|
235
|
+
/**
|
|
236
|
+
* LeaderboardEntry represents a single entry on the leaderboard.
|
|
237
|
+
*
|
|
238
|
+
* @generated from message ascnd.v1.LeaderboardEntry
|
|
239
|
+
*/
|
|
240
|
+
type LeaderboardEntry = Message<"ascnd.v1.LeaderboardEntry"> & {
|
|
241
|
+
/**
|
|
242
|
+
* The player's rank (1-indexed).
|
|
243
|
+
*
|
|
244
|
+
* @generated from field: int32 rank = 1;
|
|
245
|
+
*/
|
|
246
|
+
rank: number;
|
|
247
|
+
/**
|
|
248
|
+
* The player's unique identifier.
|
|
249
|
+
*
|
|
250
|
+
* @generated from field: string player_id = 2;
|
|
251
|
+
*/
|
|
252
|
+
playerId: string;
|
|
253
|
+
/**
|
|
254
|
+
* The player's score.
|
|
255
|
+
*
|
|
256
|
+
* @generated from field: int64 score = 3;
|
|
257
|
+
*/
|
|
258
|
+
score: bigint;
|
|
259
|
+
/**
|
|
260
|
+
* When the score was submitted (ISO 8601 timestamp).
|
|
261
|
+
*
|
|
262
|
+
* @generated from field: string submitted_at = 4;
|
|
263
|
+
*/
|
|
264
|
+
submittedAt: string;
|
|
265
|
+
/**
|
|
266
|
+
* Optional metadata associated with the score.
|
|
267
|
+
*
|
|
268
|
+
* @generated from field: optional bytes metadata = 5;
|
|
269
|
+
*/
|
|
270
|
+
metadata?: Uint8Array;
|
|
271
|
+
/**
|
|
272
|
+
* Optional bracket assignment for this player.
|
|
273
|
+
*
|
|
274
|
+
* @generated from field: optional ascnd.v1.BracketInfo bracket = 6;
|
|
275
|
+
*/
|
|
276
|
+
bracket?: BracketInfo;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Describes the message ascnd.v1.LeaderboardEntry.
|
|
280
|
+
* Use `create(LeaderboardEntrySchema)` to create a new message.
|
|
281
|
+
*/
|
|
282
|
+
declare const LeaderboardEntrySchema: GenMessage<LeaderboardEntry>;
|
|
283
|
+
/**
|
|
284
|
+
* BracketInfo contains minimal bracket information.
|
|
285
|
+
*
|
|
286
|
+
* @generated from message ascnd.v1.BracketInfo
|
|
287
|
+
*/
|
|
288
|
+
type BracketInfo = Message<"ascnd.v1.BracketInfo"> & {
|
|
289
|
+
/**
|
|
290
|
+
* The bracket's unique identifier.
|
|
291
|
+
*
|
|
292
|
+
* @generated from field: string id = 1;
|
|
293
|
+
*/
|
|
294
|
+
id: string;
|
|
295
|
+
/**
|
|
296
|
+
* The bracket's name (e.g., "Gold", "Silver", "Bronze").
|
|
297
|
+
*
|
|
298
|
+
* @generated from field: string name = 2;
|
|
299
|
+
*/
|
|
300
|
+
name: string;
|
|
301
|
+
/**
|
|
302
|
+
* Optional hex color code (e.g., "#FF5500") for the bracket badge.
|
|
303
|
+
*
|
|
304
|
+
* @generated from field: optional string color = 3;
|
|
305
|
+
*/
|
|
306
|
+
color?: string;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Describes the message ascnd.v1.BracketInfo.
|
|
310
|
+
* Use `create(BracketInfoSchema)` to create a new message.
|
|
311
|
+
*/
|
|
312
|
+
declare const BracketInfoSchema: GenMessage<BracketInfo>;
|
|
313
|
+
/**
|
|
314
|
+
* ViewInfo contains minimal metadata view information.
|
|
315
|
+
*
|
|
316
|
+
* @generated from message ascnd.v1.ViewInfo
|
|
317
|
+
*/
|
|
318
|
+
type ViewInfo = Message<"ascnd.v1.ViewInfo"> & {
|
|
319
|
+
/**
|
|
320
|
+
* The view's slug identifier.
|
|
321
|
+
*
|
|
322
|
+
* @generated from field: string slug = 1;
|
|
323
|
+
*/
|
|
324
|
+
slug: string;
|
|
325
|
+
/**
|
|
326
|
+
* The view's display name.
|
|
327
|
+
*
|
|
328
|
+
* @generated from field: string name = 2;
|
|
329
|
+
*/
|
|
330
|
+
name: string;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Describes the message ascnd.v1.ViewInfo.
|
|
334
|
+
* Use `create(ViewInfoSchema)` to create a new message.
|
|
335
|
+
*/
|
|
336
|
+
declare const ViewInfoSchema: GenMessage<ViewInfo>;
|
|
337
|
+
/**
|
|
338
|
+
* GetPlayerRankRequest specifies which player and leaderboard to query.
|
|
339
|
+
*
|
|
340
|
+
* @generated from message ascnd.v1.GetPlayerRankRequest
|
|
341
|
+
*/
|
|
342
|
+
type GetPlayerRankRequest = Message<"ascnd.v1.GetPlayerRankRequest"> & {
|
|
343
|
+
/**
|
|
344
|
+
* The leaderboard to query.
|
|
345
|
+
*
|
|
346
|
+
* @generated from field: string leaderboard_id = 1;
|
|
347
|
+
*/
|
|
348
|
+
leaderboardId: string;
|
|
349
|
+
/**
|
|
350
|
+
* The player's unique identifier.
|
|
351
|
+
*
|
|
352
|
+
* @generated from field: string player_id = 2;
|
|
353
|
+
*/
|
|
354
|
+
playerId: string;
|
|
355
|
+
/**
|
|
356
|
+
* Which period to query: "current", "previous", or a timestamp.
|
|
357
|
+
*
|
|
358
|
+
* @generated from field: optional string period = 3;
|
|
359
|
+
*/
|
|
360
|
+
period?: string;
|
|
361
|
+
/**
|
|
362
|
+
* Optional view slug to get rank within a filtered view.
|
|
363
|
+
*
|
|
364
|
+
* @generated from field: optional string view_slug = 4;
|
|
365
|
+
*/
|
|
366
|
+
viewSlug?: string;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Describes the message ascnd.v1.GetPlayerRankRequest.
|
|
370
|
+
* Use `create(GetPlayerRankRequestSchema)` to create a new message.
|
|
371
|
+
*/
|
|
372
|
+
declare const GetPlayerRankRequestSchema: GenMessage<GetPlayerRankRequest>;
|
|
373
|
+
/**
|
|
374
|
+
* GetPlayerRankResponse contains the player's rank information.
|
|
375
|
+
*
|
|
376
|
+
* @generated from message ascnd.v1.GetPlayerRankResponse
|
|
377
|
+
*/
|
|
378
|
+
type GetPlayerRankResponse = Message<"ascnd.v1.GetPlayerRankResponse"> & {
|
|
379
|
+
/**
|
|
380
|
+
* The player's rank (null if not on leaderboard).
|
|
381
|
+
* When querying a view, this is the rank within the view.
|
|
382
|
+
*
|
|
383
|
+
* @generated from field: optional int32 rank = 1;
|
|
384
|
+
*/
|
|
385
|
+
rank?: number;
|
|
386
|
+
/**
|
|
387
|
+
* The player's current score (null if not on leaderboard).
|
|
388
|
+
*
|
|
389
|
+
* @generated from field: optional int64 score = 2;
|
|
390
|
+
*/
|
|
391
|
+
score?: bigint;
|
|
392
|
+
/**
|
|
393
|
+
* The player's best score this period.
|
|
394
|
+
*
|
|
395
|
+
* @generated from field: optional int64 best_score = 3;
|
|
396
|
+
*/
|
|
397
|
+
bestScore?: bigint;
|
|
398
|
+
/**
|
|
399
|
+
* Total number of entries on this leaderboard (or view if filtered).
|
|
400
|
+
*
|
|
401
|
+
* @generated from field: int32 total_entries = 4;
|
|
402
|
+
*/
|
|
403
|
+
totalEntries: number;
|
|
404
|
+
/**
|
|
405
|
+
* The player's percentile (e.g., "top 5%").
|
|
406
|
+
*
|
|
407
|
+
* @generated from field: optional string percentile = 5;
|
|
408
|
+
*/
|
|
409
|
+
percentile?: string;
|
|
410
|
+
/**
|
|
411
|
+
* Optional bracket assignment for this player.
|
|
412
|
+
*
|
|
413
|
+
* @generated from field: optional ascnd.v1.BracketInfo bracket = 6;
|
|
414
|
+
*/
|
|
415
|
+
bracket?: BracketInfo;
|
|
416
|
+
/**
|
|
417
|
+
* Active view info if querying with view_slug.
|
|
418
|
+
*
|
|
419
|
+
* @generated from field: optional ascnd.v1.ViewInfo view = 7;
|
|
420
|
+
*/
|
|
421
|
+
view?: ViewInfo;
|
|
422
|
+
/**
|
|
423
|
+
* Global rank when querying a view (shows overall position).
|
|
424
|
+
*
|
|
425
|
+
* @generated from field: optional int32 global_rank = 8;
|
|
426
|
+
*/
|
|
427
|
+
globalRank?: number;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Describes the message ascnd.v1.GetPlayerRankResponse.
|
|
431
|
+
* Use `create(GetPlayerRankResponseSchema)` to create a new message.
|
|
432
|
+
*/
|
|
433
|
+
declare const GetPlayerRankResponseSchema: GenMessage<GetPlayerRankResponse>;
|
|
434
|
+
/**
|
|
435
|
+
* AscndService provides leaderboard management for games.
|
|
436
|
+
*
|
|
437
|
+
* @generated from service ascnd.v1.AscndService
|
|
438
|
+
*/
|
|
439
|
+
declare const AscndService: GenService<{
|
|
440
|
+
/**
|
|
441
|
+
* SubmitScore records a player's score on a leaderboard.
|
|
442
|
+
*
|
|
443
|
+
* @generated from rpc ascnd.v1.AscndService.SubmitScore
|
|
444
|
+
*/
|
|
445
|
+
submitScore: {
|
|
446
|
+
methodKind: "unary";
|
|
447
|
+
input: typeof SubmitScoreRequestSchema;
|
|
448
|
+
output: typeof SubmitScoreResponseSchema;
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* GetLeaderboard retrieves the top scores for a leaderboard.
|
|
452
|
+
*
|
|
453
|
+
* @generated from rpc ascnd.v1.AscndService.GetLeaderboard
|
|
454
|
+
*/
|
|
455
|
+
getLeaderboard: {
|
|
456
|
+
methodKind: "unary";
|
|
457
|
+
input: typeof GetLeaderboardRequestSchema;
|
|
458
|
+
output: typeof GetLeaderboardResponseSchema;
|
|
459
|
+
};
|
|
460
|
+
/**
|
|
461
|
+
* GetPlayerRank retrieves a specific player's rank and score.
|
|
462
|
+
*
|
|
463
|
+
* @generated from rpc ascnd.v1.AscndService.GetPlayerRank
|
|
464
|
+
*/
|
|
465
|
+
getPlayerRank: {
|
|
466
|
+
methodKind: "unary";
|
|
467
|
+
input: typeof GetPlayerRankRequestSchema;
|
|
468
|
+
output: typeof GetPlayerRankResponseSchema;
|
|
469
|
+
};
|
|
470
|
+
}>;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* TypeScript types for the Ascnd gRPC API.
|
|
474
|
+
*
|
|
475
|
+
* Types are generated from the proto file and re-exported here.
|
|
476
|
+
*/
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Configuration options for the Ascnd client.
|
|
480
|
+
*/
|
|
481
|
+
interface AscndClientConfig {
|
|
482
|
+
/** The base URL of the Ascnd API (e.g., "https://api.ascnd.gg"). */
|
|
483
|
+
baseUrl: string;
|
|
484
|
+
/** Your API key for authentication. */
|
|
485
|
+
apiKey: string;
|
|
486
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
487
|
+
timeout?: number;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Custom error class for Ascnd API errors.
|
|
491
|
+
*/
|
|
492
|
+
declare class AscndError extends Error {
|
|
493
|
+
/** gRPC/Connect error code. */
|
|
494
|
+
readonly code: string;
|
|
495
|
+
/** Additional error details. */
|
|
496
|
+
readonly details?: Record<string, unknown>;
|
|
497
|
+
constructor(message: string, code: string, details?: Record<string, unknown>);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Client for the Ascnd leaderboard API using gRPC-Web.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```typescript
|
|
505
|
+
* import { AscndClient, create } from "@ascnd-gg/client";
|
|
506
|
+
* import { SubmitScoreRequestSchema } from "@ascnd-gg/client";
|
|
507
|
+
*
|
|
508
|
+
* const client = new AscndClient({
|
|
509
|
+
* baseUrl: "https://api.ascnd.gg",
|
|
510
|
+
* apiKey: "your-api-key",
|
|
511
|
+
* });
|
|
512
|
+
*
|
|
513
|
+
* // Submit a score
|
|
514
|
+
* const result = await client.submitScore(
|
|
515
|
+
* create(SubmitScoreRequestSchema, {
|
|
516
|
+
* leaderboardId: "high-scores",
|
|
517
|
+
* playerId: "player-123",
|
|
518
|
+
* score: 1000n,
|
|
519
|
+
* })
|
|
520
|
+
* );
|
|
521
|
+
*
|
|
522
|
+
* console.log(`Rank: #${result.rank}`);
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
declare class AscndClient {
|
|
526
|
+
private readonly client;
|
|
527
|
+
/**
|
|
528
|
+
* Creates a new Ascnd client.
|
|
529
|
+
*
|
|
530
|
+
* @param config - Client configuration options.
|
|
531
|
+
*/
|
|
532
|
+
constructor(config: AscndClientConfig);
|
|
533
|
+
/**
|
|
534
|
+
* Submits a player's score to a leaderboard.
|
|
535
|
+
*
|
|
536
|
+
* @param request - The score submission request.
|
|
537
|
+
* @returns The submission result including the player's new rank.
|
|
538
|
+
* @throws {AscndError} If the API returns an error.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* import { create } from "@bufbuild/protobuf";
|
|
543
|
+
* import { SubmitScoreRequestSchema } from "@ascnd-gg/client";
|
|
544
|
+
*
|
|
545
|
+
* const result = await client.submitScore(
|
|
546
|
+
* create(SubmitScoreRequestSchema, {
|
|
547
|
+
* leaderboardId: "high-scores",
|
|
548
|
+
* playerId: "player-123",
|
|
549
|
+
* score: 1000n,
|
|
550
|
+
* metadata: new TextEncoder().encode(JSON.stringify({ level: 5 })),
|
|
551
|
+
* })
|
|
552
|
+
* );
|
|
553
|
+
*
|
|
554
|
+
* console.log(`New rank: ${result.rank}`);
|
|
555
|
+
* if (result.isNewBest) {
|
|
556
|
+
* console.log("New personal best!");
|
|
557
|
+
* }
|
|
558
|
+
* if (result.anticheat && !result.anticheat.passed) {
|
|
559
|
+
* console.log("Anticheat flagged:", result.anticheat.violations);
|
|
560
|
+
* }
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
submitScore(request: SubmitScoreRequest): Promise<SubmitScoreResponse>;
|
|
564
|
+
/**
|
|
565
|
+
* Retrieves the top scores for a leaderboard.
|
|
566
|
+
*
|
|
567
|
+
* @param request - The leaderboard request parameters.
|
|
568
|
+
* @returns The leaderboard entries and pagination info.
|
|
569
|
+
* @throws {AscndError} If the API returns an error.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```typescript
|
|
573
|
+
* import { create } from "@bufbuild/protobuf";
|
|
574
|
+
* import { GetLeaderboardRequestSchema } from "@ascnd-gg/client";
|
|
575
|
+
*
|
|
576
|
+
* const leaderboard = await client.getLeaderboard(
|
|
577
|
+
* create(GetLeaderboardRequestSchema, {
|
|
578
|
+
* leaderboardId: "high-scores",
|
|
579
|
+
* limit: 10,
|
|
580
|
+
* viewSlug: "platform-pc", // Filter by metadata view
|
|
581
|
+
* })
|
|
582
|
+
* );
|
|
583
|
+
*
|
|
584
|
+
* for (const entry of leaderboard.entries) {
|
|
585
|
+
* console.log(`#${entry.rank}: ${entry.playerId} - ${entry.score}`);
|
|
586
|
+
* if (entry.bracket) {
|
|
587
|
+
* console.log(` Bracket: ${entry.bracket.name}`);
|
|
588
|
+
* }
|
|
589
|
+
* }
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
getLeaderboard(request: GetLeaderboardRequest): Promise<GetLeaderboardResponse>;
|
|
593
|
+
/**
|
|
594
|
+
* Retrieves a specific player's rank and score information.
|
|
595
|
+
*
|
|
596
|
+
* @param request - The player rank request parameters.
|
|
597
|
+
* @returns The player's rank, score, and percentile information.
|
|
598
|
+
* @throws {AscndError} If the API returns an error.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```typescript
|
|
602
|
+
* import { create } from "@bufbuild/protobuf";
|
|
603
|
+
* import { GetPlayerRankRequestSchema } from "@ascnd-gg/client";
|
|
604
|
+
*
|
|
605
|
+
* const playerRank = await client.getPlayerRank(
|
|
606
|
+
* create(GetPlayerRankRequestSchema, {
|
|
607
|
+
* leaderboardId: "high-scores",
|
|
608
|
+
* playerId: "player-123",
|
|
609
|
+
* viewSlug: "platform-pc",
|
|
610
|
+
* })
|
|
611
|
+
* );
|
|
612
|
+
*
|
|
613
|
+
* if (playerRank.rank !== undefined) {
|
|
614
|
+
* console.log(`Rank: #${playerRank.rank}`);
|
|
615
|
+
* console.log(`Score: ${playerRank.score}`);
|
|
616
|
+
* console.log(`Percentile: ${playerRank.percentile}`);
|
|
617
|
+
* if (playerRank.bracket) {
|
|
618
|
+
* console.log(`Bracket: ${playerRank.bracket.name}`);
|
|
619
|
+
* }
|
|
620
|
+
* if (playerRank.globalRank !== undefined) {
|
|
621
|
+
* console.log(`Global Rank: #${playerRank.globalRank}`);
|
|
622
|
+
* }
|
|
623
|
+
* } else {
|
|
624
|
+
* console.log("Player not on leaderboard");
|
|
625
|
+
* }
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
getPlayerRank(request: GetPlayerRankRequest): Promise<GetPlayerRankResponse>;
|
|
629
|
+
/**
|
|
630
|
+
* Converts a Connect error to an AscndError.
|
|
631
|
+
*/
|
|
632
|
+
private convertError;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
export { type AnticheatResult, AnticheatResultSchema, type AnticheatViolation, AnticheatViolationSchema, AscndClient, type AscndClientConfig, AscndError, AscndService, type BracketInfo, BracketInfoSchema, type GetLeaderboardRequest, GetLeaderboardRequestSchema, type GetLeaderboardResponse, GetLeaderboardResponseSchema, type GetPlayerRankRequest, GetPlayerRankRequestSchema, type GetPlayerRankResponse, GetPlayerRankResponseSchema, type LeaderboardEntry, LeaderboardEntrySchema, type SubmitScoreRequest, SubmitScoreRequestSchema, type SubmitScoreResponse, SubmitScoreResponseSchema, type ViewInfo, ViewInfoSchema };
|