@voltro/plugin-leaderboards 0.0.0-stage → 0.87.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/CHANGELOG.md +24329 -0
- package/LICENSE +61 -0
- package/README.md +1087 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +5007 -0
- package/dist/administration.js +5 -0
- package/dist/bracketAdmission.js +294 -0
- package/dist/bracketAdmissionPolicy.js +22 -0
- package/dist/bracketInstallation.js +133 -0
- package/dist/bracketMatchPorts.js +5 -0
- package/dist/bracketMatches.js +546 -0
- package/dist/brackets.d.ts +149 -0
- package/dist/brackets.js +379 -0
- package/dist/bucketStore.js +93 -0
- package/dist/buckets.js +9 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +17 -0
- package/dist/glicko2.js +72 -0
- package/dist/index.d.ts +1208 -0
- package/dist/index.js +15 -0
- package/dist/inspect.js +84 -0
- package/dist/json.js +39 -0
- package/dist/leaderboard.d.ts +49 -0
- package/dist/leaderboard.js +57 -0
- package/dist/leagueSchedule.js +40 -0
- package/dist/leagues.js +31 -0
- package/dist/openskill.js +74 -0
- package/dist/plugin.js +338 -0
- package/dist/portLifetime.js +67 -0
- package/dist/ports.d.ts +294 -0
- package/dist/ports.js +7 -0
- package/dist/rankQuery.js +24 -0
- package/dist/ranking.d.ts +42 -0
- package/dist/ranking.js +71 -0
- package/dist/rating.d.ts +103 -0
- package/dist/rating.js +50 -0
- package/dist/ratingPools.js +134 -0
- package/dist/ratingStore.js +334 -0
- package/dist/ratingStrategies.js +108 -0
- package/dist/records.d.ts +116 -0
- package/dist/records.js +88 -0
- package/dist/rpc.d.ts +321 -0
- package/dist/rpc.js +306 -0
- package/dist/score.d.ts +13 -0
- package/dist/score.js +27 -0
- package/dist/server.d.ts +1477 -0
- package/dist/server.js +17 -0
- package/dist/service.js +949 -0
- package/dist/subjectFences.js +44 -0
- package/dist/tables.entity.js +188 -0
- package/dist/testing.d.ts +872 -0
- package/dist/testing.js +368 -0
- package/dist/tournament-app/tournament.advance.workflow.server.tsx +3 -0
- package/dist/tournament-app/tournament.advance.workflow.tsx +12 -0
- package/dist/tournament-app/tournament.stage.workflow.server.tsx +3 -0
- package/dist/tournament-app/tournament.stage.workflow.tsx +10 -0
- package/dist/tournamentInstallation.js +168 -0
- package/dist/tournamentPrizes.js +34 -0
- package/dist/tournamentStage.js +151 -0
- package/dist/tournamentStagePorts.js +5 -0
- package/dist/tournamentWorkflow.js +101 -0
- package/dist/tournamentWorkflowSchemas.js +54 -0
- package/dist/tournaments.d.ts +32 -0
- package/dist/tournaments.js +21 -0
- package/dist/web.d.ts +175 -0
- package/dist/web.js +17 -0
- package/package.json +113 -4
package/dist/rpc.d.ts
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { ActionProcedureDescriptor } from '@voltro/protocol';
|
|
2
|
+
import { PluginRpcClientDescriptor } from '@voltro/protocol';
|
|
3
|
+
import { QueryProcedureDescriptor } from '@voltro/protocol';
|
|
4
|
+
import { Schema } from 'effect';
|
|
5
|
+
import { YieldableError } from 'effect/Cause';
|
|
6
|
+
|
|
7
|
+
export declare const aroundDescriptor: QueryProcedureDescriptor<"leaderboards.around", Schema.Struct<{
|
|
8
|
+
readonly board: Schema.NonEmptyString;
|
|
9
|
+
readonly radius: Schema.optional<Schema.Number>;
|
|
10
|
+
}>, Schema.$Array<Schema.Struct<{
|
|
11
|
+
readonly rank: Schema.Number;
|
|
12
|
+
readonly id: Schema.String;
|
|
13
|
+
readonly board: Schema.String;
|
|
14
|
+
readonly periodId: Schema.String;
|
|
15
|
+
readonly ownerId: Schema.String;
|
|
16
|
+
readonly score: Schema.String;
|
|
17
|
+
readonly subscore: Schema.String;
|
|
18
|
+
readonly numSubmits: Schema.Number;
|
|
19
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
20
|
+
readonly updatedAt: Schema.Number;
|
|
21
|
+
readonly bucket: Schema.NullOr<Schema.String>;
|
|
22
|
+
}>>, typeof LeaderboardError>;
|
|
23
|
+
|
|
24
|
+
export declare const BASE_NAME = "@voltro/plugin-leaderboards";
|
|
25
|
+
|
|
26
|
+
export declare const BracketAdmissionStatusSchema: Schema.Struct<{
|
|
27
|
+
readonly phase: Schema.Literals<readonly ["open", "sealed", "erasing", "cancelled"]>;
|
|
28
|
+
readonly entries: Schema.Int;
|
|
29
|
+
readonly checkedIn: Schema.Int;
|
|
30
|
+
readonly own: Schema.NullOr<Schema.Struct<{
|
|
31
|
+
readonly ownerId: Schema.NonEmptyString;
|
|
32
|
+
readonly joinedAt: Schema.Int;
|
|
33
|
+
readonly checkedInAt: Schema.NullOr<Schema.Int>;
|
|
34
|
+
}>>;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export declare const bracketRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
38
|
+
|
|
39
|
+
export declare const bracketStatusDescriptor: QueryProcedureDescriptor<"leaderboards.bracketStatus", Schema.Struct<{
|
|
40
|
+
readonly tournamentId: Schema.String;
|
|
41
|
+
}>, Schema.NullOr<Schema.Struct<{
|
|
42
|
+
readonly phase: Schema.Literals<readonly ["open", "sealed", "erasing", "cancelled"]>;
|
|
43
|
+
readonly entries: Schema.Int;
|
|
44
|
+
readonly checkedIn: Schema.Int;
|
|
45
|
+
readonly own: Schema.NullOr<Schema.Struct<{
|
|
46
|
+
readonly ownerId: Schema.NonEmptyString;
|
|
47
|
+
readonly joinedAt: Schema.Int;
|
|
48
|
+
readonly checkedInAt: Schema.NullOr<Schema.Int>;
|
|
49
|
+
}>>;
|
|
50
|
+
}>>, typeof LeaderboardError>;
|
|
51
|
+
|
|
52
|
+
export declare const bracketViewDescriptor: QueryProcedureDescriptor<"leaderboards.bracketView", Schema.Struct<{
|
|
53
|
+
readonly tournamentId: Schema.String;
|
|
54
|
+
}>, Schema.NullOr<Schema.Struct<{
|
|
55
|
+
readonly phase: Schema.Literals<readonly ["active", "paused", "complete", "erasing", "cancelled"]>;
|
|
56
|
+
readonly format: Schema.Literals<readonly ["single-elimination", "double-elimination", "round-robin", "swiss"]>;
|
|
57
|
+
readonly champion: Schema.NullOr<Schema.NonEmptyString>;
|
|
58
|
+
readonly matches: Schema.$Array<Schema.Struct<{
|
|
59
|
+
readonly matchId: Schema.NonEmptyString;
|
|
60
|
+
readonly round: Schema.Int;
|
|
61
|
+
readonly status: Schema.Literals<readonly ["pending", "ready", "walkover", "complete", "empty", "inactive"]>;
|
|
62
|
+
readonly left: Schema.NullOr<Schema.NonEmptyString>;
|
|
63
|
+
readonly right: Schema.NullOr<Schema.NonEmptyString>;
|
|
64
|
+
readonly winnerId: Schema.NullOr<Schema.NonEmptyString>;
|
|
65
|
+
}>>;
|
|
66
|
+
}>>, typeof LeaderboardError>;
|
|
67
|
+
|
|
68
|
+
export declare const checkInBracketDescriptor: ActionProcedureDescriptor<"leaderboards.checkInBracket", Schema.Struct<{
|
|
69
|
+
readonly tournamentId: Schema.String;
|
|
70
|
+
}>, Schema.Struct<{
|
|
71
|
+
readonly phase: Schema.Literals<readonly ["open", "sealed", "erasing", "cancelled"]>;
|
|
72
|
+
readonly entries: Schema.Int;
|
|
73
|
+
readonly checkedIn: Schema.Int;
|
|
74
|
+
readonly own: Schema.NullOr<Schema.Struct<{
|
|
75
|
+
readonly ownerId: Schema.NonEmptyString;
|
|
76
|
+
readonly joinedAt: Schema.Int;
|
|
77
|
+
readonly checkedInAt: Schema.NullOr<Schema.Int>;
|
|
78
|
+
}>>;
|
|
79
|
+
}>, typeof LeaderboardError>;
|
|
80
|
+
|
|
81
|
+
export declare const disputeBracketDescriptor: ActionProcedureDescriptor<"leaderboards.disputeBracket", Schema.Struct<{
|
|
82
|
+
readonly tournamentId: Schema.String;
|
|
83
|
+
readonly matchId: Schema.String;
|
|
84
|
+
readonly disputeId: Schema.String;
|
|
85
|
+
readonly reason: Schema.Literals<readonly ["result_mismatch", "no_show", "connection"]>;
|
|
86
|
+
}>, Schema.Struct<{
|
|
87
|
+
readonly phase: Schema.Literals<readonly ["active", "paused", "complete", "erasing", "cancelled"]>;
|
|
88
|
+
readonly ready: Schema.Int;
|
|
89
|
+
readonly completed: Schema.Int;
|
|
90
|
+
readonly waiting: Schema.Int;
|
|
91
|
+
readonly unresolvedDisputes: Schema.Int;
|
|
92
|
+
}>, typeof LeaderboardError>;
|
|
93
|
+
|
|
94
|
+
export declare const historyDescriptor: QueryProcedureDescriptor<"leaderboards.history", Schema.Struct<{
|
|
95
|
+
readonly board: Schema.NonEmptyString;
|
|
96
|
+
readonly limit: Schema.optional<Schema.Number>;
|
|
97
|
+
}>, Schema.$Array<Schema.Struct<{
|
|
98
|
+
readonly id: Schema.String;
|
|
99
|
+
readonly board: Schema.String;
|
|
100
|
+
readonly startsAt: Schema.Number;
|
|
101
|
+
readonly endsAt: Schema.NullOr<Schema.Number>;
|
|
102
|
+
readonly state: Schema.Literals<readonly ["active", "closed", "archived"]>;
|
|
103
|
+
readonly summary: Schema.NullOr<Schema.Struct<{
|
|
104
|
+
readonly participants: Schema.Number;
|
|
105
|
+
readonly top: Schema.$Array<Schema.Struct<{
|
|
106
|
+
readonly id: Schema.String;
|
|
107
|
+
readonly tenantId: Schema.String;
|
|
108
|
+
readonly board: Schema.String;
|
|
109
|
+
readonly periodId: Schema.String;
|
|
110
|
+
readonly ownerId: Schema.String;
|
|
111
|
+
readonly score: Schema.String;
|
|
112
|
+
readonly subscore: Schema.String;
|
|
113
|
+
readonly updatedAt: Schema.Number;
|
|
114
|
+
readonly rank: Schema.Number;
|
|
115
|
+
}>>;
|
|
116
|
+
}>>;
|
|
117
|
+
}>>, typeof LeaderboardError>;
|
|
118
|
+
|
|
119
|
+
export declare const joinTournamentDescriptor: ActionProcedureDescriptor<"leaderboards.joinTournament", Schema.Struct<{
|
|
120
|
+
readonly tournament: Schema.NonEmptyString;
|
|
121
|
+
}>, Schema.Struct<{
|
|
122
|
+
readonly tournament: Schema.String;
|
|
123
|
+
readonly joinedAt: Schema.Number;
|
|
124
|
+
readonly attemptsLeft: Schema.Number;
|
|
125
|
+
}>, typeof LeaderboardError>;
|
|
126
|
+
|
|
127
|
+
declare class LeaderboardError extends LeaderboardError_base {
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare const LeaderboardError_base: Schema.Class<LeaderboardError, Schema.TaggedStruct<"LeaderboardError", {
|
|
131
|
+
readonly code: Schema.Literals<readonly ["invalid_board", "invalid_score", "invalid_record", "invalid_input", "overflow", "unavailable", "forbidden", "not_found", "conflict", "erased", "limit_exceeded"]>;
|
|
132
|
+
}>, YieldableError>;
|
|
133
|
+
|
|
134
|
+
export declare const leaderboardRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
135
|
+
|
|
136
|
+
export declare const meDescriptor: QueryProcedureDescriptor<"leaderboards.me", Schema.Struct<{
|
|
137
|
+
readonly board: Schema.NonEmptyString;
|
|
138
|
+
}>, Schema.NullOr<Schema.Struct<{
|
|
139
|
+
readonly rank: Schema.Number;
|
|
140
|
+
readonly id: Schema.String;
|
|
141
|
+
readonly board: Schema.String;
|
|
142
|
+
readonly periodId: Schema.String;
|
|
143
|
+
readonly ownerId: Schema.String;
|
|
144
|
+
readonly score: Schema.String;
|
|
145
|
+
readonly subscore: Schema.String;
|
|
146
|
+
readonly numSubmits: Schema.Number;
|
|
147
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
148
|
+
readonly updatedAt: Schema.Number;
|
|
149
|
+
readonly bucket: Schema.NullOr<Schema.String>;
|
|
150
|
+
}>>, typeof LeaderboardError>;
|
|
151
|
+
|
|
152
|
+
export declare const myBracketMatchesDescriptor: QueryProcedureDescriptor<"leaderboards.myBracketMatches", Schema.Struct<{
|
|
153
|
+
readonly tournamentId: Schema.String;
|
|
154
|
+
}>, Schema.NullOr<Schema.Struct<{
|
|
155
|
+
readonly phase: Schema.Literals<readonly ["active", "paused", "complete", "erasing", "cancelled"]>;
|
|
156
|
+
readonly champion: Schema.Boolean;
|
|
157
|
+
readonly matches: Schema.$Array<Schema.Struct<{
|
|
158
|
+
readonly matchId: Schema.NonEmptyString;
|
|
159
|
+
readonly round: Schema.Int;
|
|
160
|
+
readonly status: Schema.Literals<readonly ["pending", "ready", "walkover", "complete", "empty", "inactive"]>;
|
|
161
|
+
readonly opponentId: Schema.NullOr<Schema.NonEmptyString>;
|
|
162
|
+
readonly roomId: Schema.NullOr<Schema.NonEmptyString>;
|
|
163
|
+
readonly won: Schema.NullOr<Schema.Boolean>;
|
|
164
|
+
}>>;
|
|
165
|
+
}>>, typeof LeaderboardError>;
|
|
166
|
+
|
|
167
|
+
/** The caller's own bracket matches: opponent, Room once provisioned, and the result. */
|
|
168
|
+
export declare const MyBracketMatchesSchema: Schema.Struct<{
|
|
169
|
+
readonly phase: Schema.Literals<readonly ["active", "paused", "complete", "erasing", "cancelled"]>;
|
|
170
|
+
readonly champion: Schema.Boolean;
|
|
171
|
+
readonly matches: Schema.$Array<Schema.Struct<{
|
|
172
|
+
readonly matchId: Schema.NonEmptyString;
|
|
173
|
+
readonly round: Schema.Int;
|
|
174
|
+
readonly status: Schema.Literals<readonly ["pending", "ready", "walkover", "complete", "empty", "inactive"]>;
|
|
175
|
+
readonly opponentId: Schema.NullOr<Schema.NonEmptyString>;
|
|
176
|
+
readonly roomId: Schema.NullOr<Schema.NonEmptyString>;
|
|
177
|
+
readonly won: Schema.NullOr<Schema.Boolean>;
|
|
178
|
+
}>>;
|
|
179
|
+
}>;
|
|
180
|
+
|
|
181
|
+
export declare const myRatingDescriptor: QueryProcedureDescriptor<"leaderboards.myRating", Schema.Struct<{
|
|
182
|
+
readonly pool: Schema.NonEmptyString;
|
|
183
|
+
}>, Schema.Struct<{
|
|
184
|
+
readonly pool: Schema.NonEmptyString;
|
|
185
|
+
readonly state: Schema.Union<readonly [Schema.Struct<{
|
|
186
|
+
readonly algorithm: Schema.Literal<"elo">;
|
|
187
|
+
readonly rating: Schema.Number;
|
|
188
|
+
}>, Schema.Struct<{
|
|
189
|
+
readonly algorithm: Schema.Literal<"openskill">;
|
|
190
|
+
readonly mu: Schema.Number;
|
|
191
|
+
readonly sigma: Schema.Number;
|
|
192
|
+
}>, Schema.Struct<{
|
|
193
|
+
readonly algorithm: Schema.Literal<"glicko2">;
|
|
194
|
+
readonly rating: Schema.Number;
|
|
195
|
+
readonly deviation: Schema.Number;
|
|
196
|
+
readonly volatility: Schema.Number;
|
|
197
|
+
}>]>;
|
|
198
|
+
readonly games: Schema.Number;
|
|
199
|
+
readonly updatedAt: Schema.NullOr<Schema.Number>;
|
|
200
|
+
}>, typeof LeaderboardError>;
|
|
201
|
+
|
|
202
|
+
export declare const ratingRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
203
|
+
|
|
204
|
+
export declare const registerBracketDescriptor: ActionProcedureDescriptor<"leaderboards.registerBracket", Schema.Struct<{
|
|
205
|
+
readonly tournamentId: Schema.String;
|
|
206
|
+
}>, Schema.Struct<{
|
|
207
|
+
readonly phase: Schema.Literals<readonly ["open", "sealed", "erasing", "cancelled"]>;
|
|
208
|
+
readonly entries: Schema.Int;
|
|
209
|
+
readonly checkedIn: Schema.Int;
|
|
210
|
+
readonly own: Schema.NullOr<Schema.Struct<{
|
|
211
|
+
readonly ownerId: Schema.NonEmptyString;
|
|
212
|
+
readonly joinedAt: Schema.Int;
|
|
213
|
+
readonly checkedInAt: Schema.NullOr<Schema.Int>;
|
|
214
|
+
}>>;
|
|
215
|
+
}>, typeof LeaderboardError>;
|
|
216
|
+
|
|
217
|
+
export declare const topDescriptor: QueryProcedureDescriptor<"leaderboards.top", Schema.Struct<{
|
|
218
|
+
readonly board: Schema.NonEmptyString;
|
|
219
|
+
readonly limit: Schema.optional<Schema.Number>;
|
|
220
|
+
readonly scope: Schema.optional<Schema.Literals<readonly ["global", "bucket"]>>;
|
|
221
|
+
}>, Schema.$Array<Schema.Struct<{
|
|
222
|
+
readonly rank: Schema.Number;
|
|
223
|
+
readonly id: Schema.String;
|
|
224
|
+
readonly board: Schema.String;
|
|
225
|
+
readonly periodId: Schema.String;
|
|
226
|
+
readonly ownerId: Schema.String;
|
|
227
|
+
readonly score: Schema.String;
|
|
228
|
+
readonly subscore: Schema.String;
|
|
229
|
+
readonly numSubmits: Schema.Number;
|
|
230
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
231
|
+
readonly updatedAt: Schema.Number;
|
|
232
|
+
readonly bucket: Schema.NullOr<Schema.String>;
|
|
233
|
+
}>>, typeof LeaderboardError>;
|
|
234
|
+
|
|
235
|
+
export declare const TournamentAdvancePayload: Schema.Struct<{
|
|
236
|
+
readonly tenantId: Schema.String;
|
|
237
|
+
readonly tournamentId: Schema.String;
|
|
238
|
+
readonly runKey: Schema.String;
|
|
239
|
+
}>;
|
|
240
|
+
|
|
241
|
+
export declare type TournamentAdvancePayload = typeof TournamentAdvancePayload.Type;
|
|
242
|
+
|
|
243
|
+
/** The whole bracket for the tournament's players: rounds, pairings, results and the champion.
|
|
244
|
+
* Room IDs are not part of it; each player reads their own Room with `myBracketMatches`. */
|
|
245
|
+
export declare const TournamentBracketViewSchema: Schema.Struct<{
|
|
246
|
+
readonly phase: Schema.Literals<readonly ["active", "paused", "complete", "erasing", "cancelled"]>;
|
|
247
|
+
readonly format: Schema.Literals<readonly ["single-elimination", "double-elimination", "round-robin", "swiss"]>;
|
|
248
|
+
readonly champion: Schema.NullOr<Schema.NonEmptyString>;
|
|
249
|
+
readonly matches: Schema.$Array<Schema.Struct<{
|
|
250
|
+
readonly matchId: Schema.NonEmptyString;
|
|
251
|
+
readonly round: Schema.Int;
|
|
252
|
+
readonly status: Schema.Literals<readonly ["pending", "ready", "walkover", "complete", "empty", "inactive"]>;
|
|
253
|
+
readonly left: Schema.NullOr<Schema.NonEmptyString>;
|
|
254
|
+
readonly right: Schema.NullOr<Schema.NonEmptyString>;
|
|
255
|
+
readonly winnerId: Schema.NullOr<Schema.NonEmptyString>;
|
|
256
|
+
}>>;
|
|
257
|
+
}>;
|
|
258
|
+
|
|
259
|
+
export declare const tournamentCoordinationRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
260
|
+
|
|
261
|
+
export declare const TournamentDisputeInput: Schema.Struct<{
|
|
262
|
+
readonly tournamentId: Schema.String;
|
|
263
|
+
readonly matchId: Schema.String;
|
|
264
|
+
readonly disputeId: Schema.String;
|
|
265
|
+
readonly reason: Schema.Literals<readonly ["result_mismatch", "no_show", "connection"]>;
|
|
266
|
+
}>;
|
|
267
|
+
|
|
268
|
+
export declare const tournamentRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
269
|
+
|
|
270
|
+
export declare const TournamentStageNotification: Schema.Struct<{
|
|
271
|
+
readonly notified: Schema.Boolean;
|
|
272
|
+
}>;
|
|
273
|
+
|
|
274
|
+
export declare const TournamentStagePayload: Schema.Struct<{
|
|
275
|
+
readonly format: Schema.Literals<readonly ["single-elimination", "double-elimination", "round-robin", "swiss"]>;
|
|
276
|
+
readonly ruleVersion: Schema.String;
|
|
277
|
+
readonly tenantId: Schema.String;
|
|
278
|
+
readonly tournamentId: Schema.String;
|
|
279
|
+
readonly runKey: Schema.String;
|
|
280
|
+
}>;
|
|
281
|
+
|
|
282
|
+
export declare type TournamentStagePayload = typeof TournamentStagePayload.Type;
|
|
283
|
+
|
|
284
|
+
export declare const TournamentStageWindow: Schema.Struct<{
|
|
285
|
+
readonly registrationOpensAt: Schema.Int;
|
|
286
|
+
readonly registrationClosesAt: Schema.Int;
|
|
287
|
+
readonly checkInOpensAt: Schema.Int;
|
|
288
|
+
readonly checkInClosesAt: Schema.Int;
|
|
289
|
+
readonly maxEntries: Schema.Int;
|
|
290
|
+
}>;
|
|
291
|
+
|
|
292
|
+
export declare const tournamentStatusDescriptor: QueryProcedureDescriptor<"leaderboards.tournamentStatus", Schema.Struct<{
|
|
293
|
+
readonly tournament: Schema.NonEmptyString;
|
|
294
|
+
}>, Schema.Struct<{
|
|
295
|
+
readonly tournament: Schema.String;
|
|
296
|
+
readonly board: Schema.String;
|
|
297
|
+
readonly startsAt: Schema.Number;
|
|
298
|
+
readonly endsAt: Schema.Number;
|
|
299
|
+
readonly observedAt: Schema.Number;
|
|
300
|
+
readonly joinRequired: Schema.Boolean;
|
|
301
|
+
readonly state: Schema.Literals<readonly ["upcoming", "open", "ended"]>;
|
|
302
|
+
readonly entry: Schema.NullOr<Schema.Struct<{
|
|
303
|
+
readonly tournament: Schema.String;
|
|
304
|
+
readonly joinedAt: Schema.Number;
|
|
305
|
+
readonly attemptsLeft: Schema.Number;
|
|
306
|
+
}>>;
|
|
307
|
+
}>, typeof LeaderboardError>;
|
|
308
|
+
|
|
309
|
+
/** Counts only: no roster/winner/ratings/Room credentials in workflow journals. */
|
|
310
|
+
export declare const TournamentWorkflowSummary: Schema.Struct<{
|
|
311
|
+
readonly phase: Schema.Literals<readonly ["active", "paused", "complete", "erasing", "cancelled"]>;
|
|
312
|
+
readonly ready: Schema.Int;
|
|
313
|
+
readonly completed: Schema.Int;
|
|
314
|
+
/** Advance work still open: ready matches without a Room, plus the champion's settlement. */
|
|
315
|
+
readonly waiting: Schema.Int;
|
|
316
|
+
readonly unresolvedDisputes: Schema.Int;
|
|
317
|
+
}>;
|
|
318
|
+
|
|
319
|
+
export declare type TournamentWorkflowSummary = typeof TournamentWorkflowSummary.Type;
|
|
320
|
+
|
|
321
|
+
export { }
|
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { LeaderboardError as e } from "./errors.js";
|
|
2
|
+
import { BOARDS_TABLE as t, BUCKET_ASSIGNMENTS_TABLE as n, LeaderboardPeriodSchema as r, LeaderboardRecordSchema as i, LeaderboardTournamentEntrySchema as a, LeaderboardTournamentStatusSchema as o, MyRatingSchema as s, PERIODS_TABLE as c, RECORDS_TABLE as l, TOURNAMENTS_TABLE as u, TOURNAMENT_ENTRIES_TABLE as d } from "./records.js";
|
|
3
|
+
import { TournamentAdvancePayload as f, TournamentStageNotification as p, TournamentStagePayload as m, TournamentStageWindow as h, TournamentWorkflowSummary as g } from "./tournamentWorkflowSchemas.js";
|
|
4
|
+
import { Schema as _ } from "effect";
|
|
5
|
+
import { defineAction as v, defineQuery as y } from "@voltro/protocol";
|
|
6
|
+
//#region src/rpc.ts
|
|
7
|
+
var b = "@voltro/plugin-leaderboards", x = "The adapter requires a verified human and resolves the tenant from the request, never a player-supplied tenant or score.", S = _.Struct({
|
|
8
|
+
...i.fields,
|
|
9
|
+
rank: _.Number.pipe(_.check(_.isInt()), _.check(_.isGreaterThan(0)))
|
|
10
|
+
}), C = _.Struct({
|
|
11
|
+
phase: _.Literals([
|
|
12
|
+
"open",
|
|
13
|
+
"sealed",
|
|
14
|
+
"erasing",
|
|
15
|
+
"cancelled"
|
|
16
|
+
]),
|
|
17
|
+
entries: _.Int.pipe(_.check(_.isBetween({
|
|
18
|
+
minimum: 0,
|
|
19
|
+
maximum: 256
|
|
20
|
+
}))),
|
|
21
|
+
checkedIn: _.Int.pipe(_.check(_.isBetween({
|
|
22
|
+
minimum: 0,
|
|
23
|
+
maximum: 256
|
|
24
|
+
}))),
|
|
25
|
+
own: _.NullOr(_.Struct({
|
|
26
|
+
ownerId: _.NonEmptyString,
|
|
27
|
+
joinedAt: _.Int.pipe(_.check(_.isGreaterThanOrEqualTo(0))),
|
|
28
|
+
checkedInAt: _.NullOr(_.Int.pipe(_.check(_.isGreaterThanOrEqualTo(0))))
|
|
29
|
+
}))
|
|
30
|
+
}).pipe(_.check(_.makeFilter((e) => e.checkedIn <= e.entries))), w = _.Struct({ tournamentId: _.String.pipe(_.check(_.isMinLength(1)), _.check(_.isMaxLength(120))) }), T = _.Struct({
|
|
31
|
+
tournamentId: w.fields.tournamentId,
|
|
32
|
+
matchId: _.String.pipe(_.check(_.isMinLength(1)), _.check(_.isMaxLength(120))),
|
|
33
|
+
disputeId: _.String.pipe(_.check(_.isMinLength(1)), _.check(_.isMaxLength(120))),
|
|
34
|
+
reason: _.Literals([
|
|
35
|
+
"result_mismatch",
|
|
36
|
+
"no_show",
|
|
37
|
+
"connection"
|
|
38
|
+
])
|
|
39
|
+
}), E = v({
|
|
40
|
+
name: "leaderboards.disputeBracket",
|
|
41
|
+
input: T,
|
|
42
|
+
output: g,
|
|
43
|
+
error: e,
|
|
44
|
+
openAccess: x
|
|
45
|
+
}), D = v({
|
|
46
|
+
name: "leaderboards.registerBracket",
|
|
47
|
+
input: w,
|
|
48
|
+
output: C,
|
|
49
|
+
error: e,
|
|
50
|
+
openAccess: x
|
|
51
|
+
}), O = v({
|
|
52
|
+
name: "leaderboards.checkInBracket",
|
|
53
|
+
input: w,
|
|
54
|
+
output: C,
|
|
55
|
+
error: e,
|
|
56
|
+
openAccess: x
|
|
57
|
+
}), k = _.Struct({
|
|
58
|
+
phase: _.Literals([
|
|
59
|
+
"active",
|
|
60
|
+
"paused",
|
|
61
|
+
"complete",
|
|
62
|
+
"erasing",
|
|
63
|
+
"cancelled"
|
|
64
|
+
]),
|
|
65
|
+
champion: _.Boolean,
|
|
66
|
+
matches: _.Array(_.Struct({
|
|
67
|
+
matchId: _.NonEmptyString,
|
|
68
|
+
round: _.Int.pipe(_.check(_.isBetween({
|
|
69
|
+
minimum: 1,
|
|
70
|
+
maximum: 128
|
|
71
|
+
}))),
|
|
72
|
+
status: _.Literals([
|
|
73
|
+
"pending",
|
|
74
|
+
"ready",
|
|
75
|
+
"walkover",
|
|
76
|
+
"complete",
|
|
77
|
+
"empty",
|
|
78
|
+
"inactive"
|
|
79
|
+
]),
|
|
80
|
+
opponentId: _.NullOr(_.NonEmptyString),
|
|
81
|
+
roomId: _.NullOr(_.NonEmptyString),
|
|
82
|
+
won: _.NullOr(_.Boolean)
|
|
83
|
+
})).pipe(_.check(_.isMaxLength(127)))
|
|
84
|
+
}), A = y({
|
|
85
|
+
name: "leaderboards.myBracketMatches",
|
|
86
|
+
input: w,
|
|
87
|
+
output: _.NullOr(k),
|
|
88
|
+
error: e,
|
|
89
|
+
source: "_voltro_brackets",
|
|
90
|
+
openAccess: x
|
|
91
|
+
}), j = _.Struct({
|
|
92
|
+
phase: _.Literals([
|
|
93
|
+
"active",
|
|
94
|
+
"paused",
|
|
95
|
+
"complete",
|
|
96
|
+
"erasing",
|
|
97
|
+
"cancelled"
|
|
98
|
+
]),
|
|
99
|
+
format: _.Literals([
|
|
100
|
+
"single-elimination",
|
|
101
|
+
"double-elimination",
|
|
102
|
+
"round-robin",
|
|
103
|
+
"swiss"
|
|
104
|
+
]),
|
|
105
|
+
champion: _.NullOr(_.NonEmptyString),
|
|
106
|
+
matches: _.Array(_.Struct({
|
|
107
|
+
matchId: _.NonEmptyString,
|
|
108
|
+
round: _.Int.pipe(_.check(_.isBetween({
|
|
109
|
+
minimum: 1,
|
|
110
|
+
maximum: 128
|
|
111
|
+
}))),
|
|
112
|
+
status: _.Literals([
|
|
113
|
+
"pending",
|
|
114
|
+
"ready",
|
|
115
|
+
"walkover",
|
|
116
|
+
"complete",
|
|
117
|
+
"empty",
|
|
118
|
+
"inactive"
|
|
119
|
+
]),
|
|
120
|
+
left: _.NullOr(_.NonEmptyString),
|
|
121
|
+
right: _.NullOr(_.NonEmptyString),
|
|
122
|
+
winnerId: _.NullOr(_.NonEmptyString)
|
|
123
|
+
})).pipe(_.check(_.isMaxLength(127)))
|
|
124
|
+
}), M = y({
|
|
125
|
+
name: "leaderboards.bracketView",
|
|
126
|
+
input: w,
|
|
127
|
+
output: _.NullOr(j),
|
|
128
|
+
error: e,
|
|
129
|
+
source: "_voltro_brackets",
|
|
130
|
+
openAccess: x
|
|
131
|
+
}), N = y({
|
|
132
|
+
name: "leaderboards.bracketStatus",
|
|
133
|
+
input: w,
|
|
134
|
+
output: _.NullOr(C),
|
|
135
|
+
error: e,
|
|
136
|
+
source: "_voltro_tournament_admissions",
|
|
137
|
+
openAccess: x
|
|
138
|
+
}), P = y({
|
|
139
|
+
name: "leaderboards.myRating",
|
|
140
|
+
input: _.Struct({ pool: _.NonEmptyString }),
|
|
141
|
+
output: s,
|
|
142
|
+
error: e,
|
|
143
|
+
source: "_voltro_lb_ratings",
|
|
144
|
+
openAccess: x
|
|
145
|
+
}), F = y({
|
|
146
|
+
name: "leaderboards.top",
|
|
147
|
+
input: _.Struct({
|
|
148
|
+
board: _.NonEmptyString,
|
|
149
|
+
limit: _.optional(_.Number.pipe(_.check(_.isInt()), _.check(_.isBetween({
|
|
150
|
+
minimum: 1,
|
|
151
|
+
maximum: 1e3
|
|
152
|
+
})))),
|
|
153
|
+
scope: _.optional(_.Literals(["global", "bucket"]))
|
|
154
|
+
}),
|
|
155
|
+
output: _.Array(S),
|
|
156
|
+
error: e,
|
|
157
|
+
source: [
|
|
158
|
+
l,
|
|
159
|
+
t,
|
|
160
|
+
n
|
|
161
|
+
],
|
|
162
|
+
openAccess: x
|
|
163
|
+
}), I = y({
|
|
164
|
+
name: "leaderboards.me",
|
|
165
|
+
input: _.Struct({ board: _.NonEmptyString }),
|
|
166
|
+
output: _.NullOr(S),
|
|
167
|
+
error: e,
|
|
168
|
+
source: [
|
|
169
|
+
l,
|
|
170
|
+
t,
|
|
171
|
+
n
|
|
172
|
+
],
|
|
173
|
+
openAccess: x
|
|
174
|
+
}), L = y({
|
|
175
|
+
name: "leaderboards.around",
|
|
176
|
+
input: _.Struct({
|
|
177
|
+
board: _.NonEmptyString,
|
|
178
|
+
radius: _.optional(_.Number.pipe(_.check(_.isInt()), _.check(_.isBetween({
|
|
179
|
+
minimum: 0,
|
|
180
|
+
maximum: 500
|
|
181
|
+
}))))
|
|
182
|
+
}),
|
|
183
|
+
output: _.Array(S),
|
|
184
|
+
error: e,
|
|
185
|
+
source: [
|
|
186
|
+
l,
|
|
187
|
+
t,
|
|
188
|
+
n
|
|
189
|
+
],
|
|
190
|
+
openAccess: x
|
|
191
|
+
}), R = y({
|
|
192
|
+
name: "leaderboards.history",
|
|
193
|
+
input: _.Struct({
|
|
194
|
+
board: _.NonEmptyString,
|
|
195
|
+
limit: _.optional(_.Number.pipe(_.check(_.isInt()), _.check(_.isBetween({
|
|
196
|
+
minimum: 1,
|
|
197
|
+
maximum: 1e5
|
|
198
|
+
}))))
|
|
199
|
+
}),
|
|
200
|
+
output: _.Array(r),
|
|
201
|
+
error: e,
|
|
202
|
+
source: c,
|
|
203
|
+
openAccess: x
|
|
204
|
+
}), z = v({
|
|
205
|
+
name: "leaderboards.joinTournament",
|
|
206
|
+
input: _.Struct({ tournament: _.NonEmptyString }),
|
|
207
|
+
output: a,
|
|
208
|
+
error: e,
|
|
209
|
+
openAccess: x
|
|
210
|
+
}), B = y({
|
|
211
|
+
name: "leaderboards.tournamentStatus",
|
|
212
|
+
input: _.Struct({ tournament: _.NonEmptyString }),
|
|
213
|
+
output: o,
|
|
214
|
+
error: e,
|
|
215
|
+
source: [
|
|
216
|
+
d,
|
|
217
|
+
u,
|
|
218
|
+
t
|
|
219
|
+
],
|
|
220
|
+
openAccess: x
|
|
221
|
+
}), V = [
|
|
222
|
+
"top",
|
|
223
|
+
"me",
|
|
224
|
+
"around",
|
|
225
|
+
"history"
|
|
226
|
+
].map((e) => ({
|
|
227
|
+
tag: "leaderboards." + e,
|
|
228
|
+
kind: "query",
|
|
229
|
+
import: {
|
|
230
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
231
|
+
name: e + "Descriptor"
|
|
232
|
+
}
|
|
233
|
+
})), H = [{
|
|
234
|
+
tag: "leaderboards.joinTournament",
|
|
235
|
+
kind: "action",
|
|
236
|
+
import: {
|
|
237
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
238
|
+
name: "joinTournamentDescriptor"
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
tag: "leaderboards.tournamentStatus",
|
|
242
|
+
kind: "query",
|
|
243
|
+
import: {
|
|
244
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
245
|
+
name: "tournamentStatusDescriptor"
|
|
246
|
+
}
|
|
247
|
+
}], U = [{
|
|
248
|
+
tag: "leaderboards.myRating",
|
|
249
|
+
kind: "query",
|
|
250
|
+
import: {
|
|
251
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
252
|
+
name: "myRatingDescriptor"
|
|
253
|
+
}
|
|
254
|
+
}], W = [
|
|
255
|
+
{
|
|
256
|
+
tag: "leaderboards.registerBracket",
|
|
257
|
+
kind: "action",
|
|
258
|
+
import: {
|
|
259
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
260
|
+
name: "registerBracketDescriptor"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
tag: "leaderboards.checkInBracket",
|
|
265
|
+
kind: "action",
|
|
266
|
+
import: {
|
|
267
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
268
|
+
name: "checkInBracketDescriptor"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
tag: "leaderboards.bracketStatus",
|
|
273
|
+
kind: "query",
|
|
274
|
+
import: {
|
|
275
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
276
|
+
name: "bracketStatusDescriptor"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
], G = [
|
|
280
|
+
{
|
|
281
|
+
tag: "leaderboards.disputeBracket",
|
|
282
|
+
kind: "action",
|
|
283
|
+
import: {
|
|
284
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
285
|
+
name: "disputeBracketDescriptor"
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
tag: "leaderboards.myBracketMatches",
|
|
290
|
+
kind: "query",
|
|
291
|
+
import: {
|
|
292
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
293
|
+
name: "myBracketMatchesDescriptor"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
tag: "leaderboards.bracketView",
|
|
298
|
+
kind: "query",
|
|
299
|
+
import: {
|
|
300
|
+
module: "@voltro/plugin-leaderboards/rpc",
|
|
301
|
+
name: "bracketViewDescriptor"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
];
|
|
305
|
+
//#endregion
|
|
306
|
+
export { b as BASE_NAME, C as BracketAdmissionStatusSchema, k as MyBracketMatchesSchema, f as TournamentAdvancePayload, j as TournamentBracketViewSchema, T as TournamentDisputeInput, p as TournamentStageNotification, m as TournamentStagePayload, h as TournamentStageWindow, g as TournamentWorkflowSummary, L as aroundDescriptor, W as bracketRpcClientImports, N as bracketStatusDescriptor, M as bracketViewDescriptor, O as checkInBracketDescriptor, E as disputeBracketDescriptor, R as historyDescriptor, z as joinTournamentDescriptor, V as leaderboardRpcClientImports, I as meDescriptor, A as myBracketMatchesDescriptor, P as myRatingDescriptor, U as ratingRpcClientImports, D as registerBracketDescriptor, F as topDescriptor, G as tournamentCoordinationRpcClientImports, H as tournamentRpcClientImports, B as tournamentStatusDescriptor };
|
package/dist/score.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Submission idempotency belongs to SQL, not this pure arithmetic function. */
|
|
2
|
+
export declare const applyScore: (previous: string | bigint | number | null, submitted: string | bigint | number, operator: ScoreOperator, sort?: LeaderboardSort) => string;
|
|
3
|
+
|
|
4
|
+
export declare type LeaderboardSort = 'asc' | 'desc';
|
|
5
|
+
|
|
6
|
+
export declare type ScoreOperator = 'best' | 'set' | 'increment' | 'decrement';
|
|
7
|
+
|
|
8
|
+
export declare const scoreString: (input: string | bigint | number) => string;
|
|
9
|
+
|
|
10
|
+
/** SQL signed BIGINT range; wire values use canonical decimal strings. */
|
|
11
|
+
export declare const scoreValue: (input: string | bigint | number) => bigint;
|
|
12
|
+
|
|
13
|
+
export { }
|
package/dist/score.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { leaderboardError as e } from "./errors.js";
|
|
2
|
+
//#region src/score.ts
|
|
3
|
+
var t = -(1n << 63n), n = (1n << 63n) - 1n, r = (r) => {
|
|
4
|
+
let i;
|
|
5
|
+
if (typeof r == "bigint") i = r;
|
|
6
|
+
else if (typeof r == "number" && Number.isSafeInteger(r) && !Object.is(r, -0)) i = BigInt(r);
|
|
7
|
+
else if (typeof r == "string" && r.length <= 20 && /^(?:0|-?[1-9][0-9]*)$/.test(r)) i = BigInt(r);
|
|
8
|
+
else throw e("invalid_score");
|
|
9
|
+
if (i < t || i > n) throw e("overflow");
|
|
10
|
+
return i;
|
|
11
|
+
}, i = (e) => r(e).toString(), a = (t, n, a, o = "desc") => {
|
|
12
|
+
if (![
|
|
13
|
+
"best",
|
|
14
|
+
"set",
|
|
15
|
+
"increment",
|
|
16
|
+
"decrement"
|
|
17
|
+
].includes(a) || !["asc", "desc"].includes(o)) throw e("invalid_board");
|
|
18
|
+
let s = r(n), c = t === null ? void 0 : r(t);
|
|
19
|
+
switch (a) {
|
|
20
|
+
case "set": return s.toString();
|
|
21
|
+
case "best": return (c === void 0 || (o === "desc" ? s > c : s < c) ? s : c).toString();
|
|
22
|
+
case "increment": return i((c ?? 0n) + s);
|
|
23
|
+
case "decrement": return i((c ?? 0n) - s);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { a as applyScore, i as scoreString, r as scoreValue };
|