moons-ta-client 1.2.0 → 1.2.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/constants.d.ts +3 -2
- package/dist/constants.js +3 -2
- package/dist/index.d.ts +82 -27
- package/dist/index.esm.js +378 -147
- package/dist/models/commands.d.ts +9 -1
- package/dist/models/commands.js +8 -0
- package/dist/models/models.d.ts +9 -13
- package/dist/models/models.js +35 -42
- package/dist/models/pushes.d.ts +8 -0
- package/dist/models/pushes.js +16 -2
- package/dist/models/requests.d.ts +39 -6
- package/dist/models/requests.js +92 -21
- package/dist/models/responses.d.ts +4 -0
- package/dist/models/responses.js +9 -2
- package/dist/tournament-assistant-client.d.ts +10 -5
- package/dist/tournament-assistant-client.js +126 -14
- package/package.json +1 -1
package/dist/models/requests.js
CHANGED
|
@@ -59,6 +59,7 @@ class Request$Type extends MessageType {
|
|
|
59
59
|
{ no: 27, name: "remove_tournament_team", kind: "message", oneof: "type", T: () => Request_RemoveTournamentTeam },
|
|
60
60
|
{ no: 28, name: "add_tournament_pool", kind: "message", oneof: "type", T: () => Request_AddTournamentPool },
|
|
61
61
|
{ no: 29, name: "set_tournament_pool_name", kind: "message", oneof: "type", T: () => Request_SetTournamentPoolName },
|
|
62
|
+
{ no: 63, name: "set_tournament_pool_image", kind: "message", oneof: "type", T: () => Request_SetTournamentPoolImage },
|
|
62
63
|
{ no: 30, name: "add_tournament_pool_maps", kind: "message", oneof: "type", T: () => Request_AddTournamentPoolMaps },
|
|
63
64
|
{ no: 31, name: "update_tournament_pool_map", kind: "message", oneof: "type", T: () => Request_UpdateTournamentPoolMap },
|
|
64
65
|
{ no: 32, name: "remove_tournament_pool_map", kind: "message", oneof: "type", T: () => Request_RemoveTournamentPoolMap },
|
|
@@ -323,6 +324,12 @@ class Request$Type extends MessageType {
|
|
|
323
324
|
setTournamentPoolName: Request_SetTournamentPoolName.internalBinaryRead(reader, reader.uint32(), options, message.type.setTournamentPoolName)
|
|
324
325
|
};
|
|
325
326
|
break;
|
|
327
|
+
case /* proto.packets.Request.SetTournamentPoolImage set_tournament_pool_image */ 63:
|
|
328
|
+
message.type = {
|
|
329
|
+
oneofKind: "setTournamentPoolImage",
|
|
330
|
+
setTournamentPoolImage: Request_SetTournamentPoolImage.internalBinaryRead(reader, reader.uint32(), options, message.type.setTournamentPoolImage)
|
|
331
|
+
};
|
|
332
|
+
break;
|
|
326
333
|
case /* proto.packets.Request.AddTournamentPoolMaps add_tournament_pool_maps */ 30:
|
|
327
334
|
message.type = {
|
|
328
335
|
oneofKind: "addTournamentPoolMaps",
|
|
@@ -581,6 +588,9 @@ class Request$Type extends MessageType {
|
|
|
581
588
|
/* proto.packets.Request.SetTournamentPoolName set_tournament_pool_name = 29; */
|
|
582
589
|
if (message.type.oneofKind === "setTournamentPoolName")
|
|
583
590
|
Request_SetTournamentPoolName.internalBinaryWrite(message.type.setTournamentPoolName, writer.tag(29, WireType.LengthDelimited).fork(), options).join();
|
|
591
|
+
/* proto.packets.Request.SetTournamentPoolImage set_tournament_pool_image = 63; */
|
|
592
|
+
if (message.type.oneofKind === "setTournamentPoolImage")
|
|
593
|
+
Request_SetTournamentPoolImage.internalBinaryWrite(message.type.setTournamentPoolImage, writer.tag(63, WireType.LengthDelimited).fork(), options).join();
|
|
584
594
|
/* proto.packets.Request.AddTournamentPoolMaps add_tournament_pool_maps = 30; */
|
|
585
595
|
if (message.type.oneofKind === "addTournamentPoolMaps")
|
|
586
596
|
Request_AddTournamentPoolMaps.internalBinaryWrite(message.type.addTournamentPoolMaps, writer.tag(30, WireType.LengthDelimited).fork(), options).join();
|
|
@@ -1184,11 +1194,11 @@ class Request_SetQualifierImage$Type extends MessageType {
|
|
|
1184
1194
|
super("proto.packets.Request.SetQualifierImage", [
|
|
1185
1195
|
{ no: 1, name: "tournament_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
1186
1196
|
{ no: 2, name: "qualifier_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
1187
|
-
{ no: 3, name: "qualifier_image", kind: "scalar", T:
|
|
1197
|
+
{ no: 3, name: "qualifier_image", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
|
1188
1198
|
]);
|
|
1189
1199
|
}
|
|
1190
1200
|
create(value) {
|
|
1191
|
-
const message = { tournamentId: "", qualifierId: "", qualifierImage:
|
|
1201
|
+
const message = { tournamentId: "", qualifierId: "", qualifierImage: "" };
|
|
1192
1202
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
1193
1203
|
if (value !== undefined)
|
|
1194
1204
|
reflectionMergePartial(this, message, value);
|
|
@@ -1205,8 +1215,8 @@ class Request_SetQualifierImage$Type extends MessageType {
|
|
|
1205
1215
|
case /* string qualifier_id */ 2:
|
|
1206
1216
|
message.qualifierId = reader.string();
|
|
1207
1217
|
break;
|
|
1208
|
-
case /*
|
|
1209
|
-
message.qualifierImage = reader.
|
|
1218
|
+
case /* string qualifier_image */ 3:
|
|
1219
|
+
message.qualifierImage = reader.string();
|
|
1210
1220
|
break;
|
|
1211
1221
|
default:
|
|
1212
1222
|
let u = options.readUnknownField;
|
|
@@ -1226,9 +1236,9 @@ class Request_SetQualifierImage$Type extends MessageType {
|
|
|
1226
1236
|
/* string qualifier_id = 2; */
|
|
1227
1237
|
if (message.qualifierId !== "")
|
|
1228
1238
|
writer.tag(2, WireType.LengthDelimited).string(message.qualifierId);
|
|
1229
|
-
/*
|
|
1230
|
-
if (message.qualifierImage
|
|
1231
|
-
writer.tag(3, WireType.LengthDelimited).
|
|
1239
|
+
/* string qualifier_image = 3; */
|
|
1240
|
+
if (message.qualifierImage !== "")
|
|
1241
|
+
writer.tag(3, WireType.LengthDelimited).string(message.qualifierImage);
|
|
1232
1242
|
let u = options.writeUnknownFields;
|
|
1233
1243
|
if (u !== false)
|
|
1234
1244
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -2042,11 +2052,11 @@ class Request_SetTournamentImage$Type extends MessageType {
|
|
|
2042
2052
|
constructor() {
|
|
2043
2053
|
super("proto.packets.Request.SetTournamentImage", [
|
|
2044
2054
|
{ no: 1, name: "tournament_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
2045
|
-
{ no: 2, name: "tournament_image", kind: "scalar", T:
|
|
2055
|
+
{ no: 2, name: "tournament_image", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
|
2046
2056
|
]);
|
|
2047
2057
|
}
|
|
2048
2058
|
create(value) {
|
|
2049
|
-
const message = { tournamentId: "", tournamentImage:
|
|
2059
|
+
const message = { tournamentId: "", tournamentImage: "" };
|
|
2050
2060
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
2051
2061
|
if (value !== undefined)
|
|
2052
2062
|
reflectionMergePartial(this, message, value);
|
|
@@ -2060,8 +2070,8 @@ class Request_SetTournamentImage$Type extends MessageType {
|
|
|
2060
2070
|
case /* string tournament_id */ 1:
|
|
2061
2071
|
message.tournamentId = reader.string();
|
|
2062
2072
|
break;
|
|
2063
|
-
case /*
|
|
2064
|
-
message.tournamentImage = reader.
|
|
2073
|
+
case /* string tournament_image */ 2:
|
|
2074
|
+
message.tournamentImage = reader.string();
|
|
2065
2075
|
break;
|
|
2066
2076
|
default:
|
|
2067
2077
|
let u = options.readUnknownField;
|
|
@@ -2078,9 +2088,9 @@ class Request_SetTournamentImage$Type extends MessageType {
|
|
|
2078
2088
|
/* string tournament_id = 1; */
|
|
2079
2089
|
if (message.tournamentId !== "")
|
|
2080
2090
|
writer.tag(1, WireType.LengthDelimited).string(message.tournamentId);
|
|
2081
|
-
/*
|
|
2082
|
-
if (message.tournamentImage
|
|
2083
|
-
writer.tag(2, WireType.LengthDelimited).
|
|
2091
|
+
/* string tournament_image = 2; */
|
|
2092
|
+
if (message.tournamentImage !== "")
|
|
2093
|
+
writer.tag(2, WireType.LengthDelimited).string(message.tournamentImage);
|
|
2084
2094
|
let u = options.writeUnknownFields;
|
|
2085
2095
|
if (u !== false)
|
|
2086
2096
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -2590,11 +2600,11 @@ class Request_SetTournamentTeamImage$Type extends MessageType {
|
|
|
2590
2600
|
super("proto.packets.Request.SetTournamentTeamImage", [
|
|
2591
2601
|
{ no: 1, name: "tournament_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
2592
2602
|
{ no: 2, name: "team_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
2593
|
-
{ no: 3, name: "team_image", kind: "scalar", T:
|
|
2603
|
+
{ no: 3, name: "team_image", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
|
2594
2604
|
]);
|
|
2595
2605
|
}
|
|
2596
2606
|
create(value) {
|
|
2597
|
-
const message = { tournamentId: "", teamId: "", teamImage:
|
|
2607
|
+
const message = { tournamentId: "", teamId: "", teamImage: "" };
|
|
2598
2608
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
2599
2609
|
if (value !== undefined)
|
|
2600
2610
|
reflectionMergePartial(this, message, value);
|
|
@@ -2611,8 +2621,8 @@ class Request_SetTournamentTeamImage$Type extends MessageType {
|
|
|
2611
2621
|
case /* string team_id */ 2:
|
|
2612
2622
|
message.teamId = reader.string();
|
|
2613
2623
|
break;
|
|
2614
|
-
case /*
|
|
2615
|
-
message.teamImage = reader.
|
|
2624
|
+
case /* string team_image */ 3:
|
|
2625
|
+
message.teamImage = reader.string();
|
|
2616
2626
|
break;
|
|
2617
2627
|
default:
|
|
2618
2628
|
let u = options.readUnknownField;
|
|
@@ -2632,9 +2642,9 @@ class Request_SetTournamentTeamImage$Type extends MessageType {
|
|
|
2632
2642
|
/* string team_id = 2; */
|
|
2633
2643
|
if (message.teamId !== "")
|
|
2634
2644
|
writer.tag(2, WireType.LengthDelimited).string(message.teamId);
|
|
2635
|
-
/*
|
|
2636
|
-
if (message.teamImage
|
|
2637
|
-
writer.tag(3, WireType.LengthDelimited).
|
|
2645
|
+
/* string team_image = 3; */
|
|
2646
|
+
if (message.teamImage !== "")
|
|
2647
|
+
writer.tag(3, WireType.LengthDelimited).string(message.teamImage);
|
|
2638
2648
|
let u = options.writeUnknownFields;
|
|
2639
2649
|
if (u !== false)
|
|
2640
2650
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -2815,6 +2825,67 @@ class Request_SetTournamentPoolName$Type extends MessageType {
|
|
|
2815
2825
|
*/
|
|
2816
2826
|
export const Request_SetTournamentPoolName = new Request_SetTournamentPoolName$Type();
|
|
2817
2827
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
2828
|
+
class Request_SetTournamentPoolImage$Type extends MessageType {
|
|
2829
|
+
constructor() {
|
|
2830
|
+
super("proto.packets.Request.SetTournamentPoolImage", [
|
|
2831
|
+
{ no: 1, name: "tournament_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
2832
|
+
{ no: 2, name: "pool_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
2833
|
+
{ no: 3, name: "pool_image", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
|
2834
|
+
]);
|
|
2835
|
+
}
|
|
2836
|
+
create(value) {
|
|
2837
|
+
const message = { tournamentId: "", poolId: "", poolImage: "" };
|
|
2838
|
+
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
2839
|
+
if (value !== undefined)
|
|
2840
|
+
reflectionMergePartial(this, message, value);
|
|
2841
|
+
return message;
|
|
2842
|
+
}
|
|
2843
|
+
internalBinaryRead(reader, length, options, target) {
|
|
2844
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
2845
|
+
while (reader.pos < end) {
|
|
2846
|
+
let [fieldNo, wireType] = reader.tag();
|
|
2847
|
+
switch (fieldNo) {
|
|
2848
|
+
case /* string tournament_id */ 1:
|
|
2849
|
+
message.tournamentId = reader.string();
|
|
2850
|
+
break;
|
|
2851
|
+
case /* string pool_id */ 2:
|
|
2852
|
+
message.poolId = reader.string();
|
|
2853
|
+
break;
|
|
2854
|
+
case /* string pool_image */ 3:
|
|
2855
|
+
message.poolImage = reader.string();
|
|
2856
|
+
break;
|
|
2857
|
+
default:
|
|
2858
|
+
let u = options.readUnknownField;
|
|
2859
|
+
if (u === "throw")
|
|
2860
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
2861
|
+
let d = reader.skip(wireType);
|
|
2862
|
+
if (u !== false)
|
|
2863
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
return message;
|
|
2867
|
+
}
|
|
2868
|
+
internalBinaryWrite(message, writer, options) {
|
|
2869
|
+
/* string tournament_id = 1; */
|
|
2870
|
+
if (message.tournamentId !== "")
|
|
2871
|
+
writer.tag(1, WireType.LengthDelimited).string(message.tournamentId);
|
|
2872
|
+
/* string pool_id = 2; */
|
|
2873
|
+
if (message.poolId !== "")
|
|
2874
|
+
writer.tag(2, WireType.LengthDelimited).string(message.poolId);
|
|
2875
|
+
/* string pool_image = 3; */
|
|
2876
|
+
if (message.poolImage !== "")
|
|
2877
|
+
writer.tag(3, WireType.LengthDelimited).string(message.poolImage);
|
|
2878
|
+
let u = options.writeUnknownFields;
|
|
2879
|
+
if (u !== false)
|
|
2880
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
2881
|
+
return writer;
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
/**
|
|
2885
|
+
* @generated MessageType for protobuf message proto.packets.Request.SetTournamentPoolImage
|
|
2886
|
+
*/
|
|
2887
|
+
export const Request_SetTournamentPoolImage = new Request_SetTournamentPoolImage$Type();
|
|
2888
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
2818
2889
|
class Request_AddTournamentPoolMaps$Type extends MessageType {
|
|
2819
2890
|
constructor() {
|
|
2820
2891
|
super("proto.packets.Request.AddTournamentPoolMaps", [
|
|
@@ -524,6 +524,10 @@ export interface Response_LoadSong {
|
|
|
524
524
|
* @generated from protobuf field: string level_id = 1;
|
|
525
525
|
*/
|
|
526
526
|
levelId: string;
|
|
527
|
+
/**
|
|
528
|
+
* @generated from protobuf field: string message = 2;
|
|
529
|
+
*/
|
|
530
|
+
message: string;
|
|
527
531
|
}
|
|
528
532
|
/**
|
|
529
533
|
* @generated from protobuf message proto.packets.Response.PreloadImageForStreamSync
|
package/dist/models/responses.js
CHANGED
|
@@ -1522,11 +1522,12 @@ export const Response_LeaderboardEntries = new Response_LeaderboardEntries$Type(
|
|
|
1522
1522
|
class Response_LoadSong$Type extends MessageType {
|
|
1523
1523
|
constructor() {
|
|
1524
1524
|
super("proto.packets.Response.LoadSong", [
|
|
1525
|
-
{ no: 1, name: "level_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
|
1525
|
+
{ no: 1, name: "level_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
1526
|
+
{ no: 2, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
|
1526
1527
|
]);
|
|
1527
1528
|
}
|
|
1528
1529
|
create(value) {
|
|
1529
|
-
const message = { levelId: "" };
|
|
1530
|
+
const message = { levelId: "", message: "" };
|
|
1530
1531
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
1531
1532
|
if (value !== undefined)
|
|
1532
1533
|
reflectionMergePartial(this, message, value);
|
|
@@ -1540,6 +1541,9 @@ class Response_LoadSong$Type extends MessageType {
|
|
|
1540
1541
|
case /* string level_id */ 1:
|
|
1541
1542
|
message.levelId = reader.string();
|
|
1542
1543
|
break;
|
|
1544
|
+
case /* string message */ 2:
|
|
1545
|
+
message.message = reader.string();
|
|
1546
|
+
break;
|
|
1543
1547
|
default:
|
|
1544
1548
|
let u = options.readUnknownField;
|
|
1545
1549
|
if (u === "throw")
|
|
@@ -1555,6 +1559,9 @@ class Response_LoadSong$Type extends MessageType {
|
|
|
1555
1559
|
/* string level_id = 1; */
|
|
1556
1560
|
if (message.levelId !== "")
|
|
1557
1561
|
writer.tag(1, WireType.LengthDelimited).string(message.levelId);
|
|
1562
|
+
/* string message = 2; */
|
|
1563
|
+
if (message.message !== "")
|
|
1564
|
+
writer.tag(2, WireType.LengthDelimited).string(message.message);
|
|
1558
1565
|
let u = options.writeUnknownFields;
|
|
1559
1566
|
if (u !== false)
|
|
1560
1567
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomEventEmitter } from "./custom-event-emitter.js";
|
|
2
|
-
import { User, Match,
|
|
2
|
+
import { User, Match, CoreServer, GameplayParameters, Map, QualifierEvent_EventSettings, QualifierEvent_LeaderboardSort, Tournament_TournamentSettings_Team, Tournament_TournamentSettings_Pool, RealtimeScore, Role } from "./models/models.js";
|
|
3
3
|
import { StateManager } from "./state-manager.js";
|
|
4
4
|
import { Response, Response_Connect } from "./models/responses.js";
|
|
5
5
|
import { Request_LoadSong, Request_ShowPrompt_PromptOption } from "./models/requests.js";
|
|
@@ -43,6 +43,7 @@ type TAClientEvents = {
|
|
|
43
43
|
failedToDeleteQualifier: {};
|
|
44
44
|
};
|
|
45
45
|
export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
|
|
46
|
+
private _imageServer;
|
|
46
47
|
stateManager: StateManager;
|
|
47
48
|
private uiVersion;
|
|
48
49
|
private client?;
|
|
@@ -55,6 +56,7 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
|
|
|
55
56
|
connect(serverAddress: string, port: string): Promise<Response>;
|
|
56
57
|
disconnect(): void;
|
|
57
58
|
setAuthToken(token: string): void;
|
|
59
|
+
private uploadImage;
|
|
58
60
|
private sendCommand;
|
|
59
61
|
private sendRequest;
|
|
60
62
|
sendResponse(response: Response): Promise<void>;
|
|
@@ -62,6 +64,8 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
|
|
|
62
64
|
returnToMenu: (tournamentId: string, userIds: string[]) => void;
|
|
63
65
|
flipColors: (tournamentId: string, userIds: string[]) => void;
|
|
64
66
|
flipHands: (tournamentId: string, userIds: string[]) => void;
|
|
67
|
+
disableBlueNotes: (tournamentId: string, userIds: string[]) => void;
|
|
68
|
+
disableRedNotes: (tournamentId: string, userIds: string[]) => void;
|
|
65
69
|
showLoadedImage: (tournamentId: string, userIds: string[], show?: boolean) => void;
|
|
66
70
|
showColor: (tournamentId: string, color: string, userIds: string[]) => void;
|
|
67
71
|
delayTestFinished: (tournamentId: string, userIds: string[]) => void;
|
|
@@ -79,7 +83,7 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
|
|
|
79
83
|
setMatchLeader: (tournamentId: string, matchId: string, userId: string) => Promise<Response>;
|
|
80
84
|
setMatchMap: (tournamentId: string, matchId: string, map: Map) => Promise<Response>;
|
|
81
85
|
deleteMatch: (tournamentId: string, matchId: string) => Promise<Response>;
|
|
82
|
-
createQualifierEvent: (tournamentId: string,
|
|
86
|
+
createQualifierEvent: (tournamentId: string, name: string, infoChannelId: string, maps: Map[], flags: QualifierEvent_EventSettings, sort: QualifierEvent_LeaderboardSort, qualifierImage: Uint8Array) => Promise<Response>;
|
|
83
87
|
setQualifierName: (tournamentId: string, qualifierId: string, qualifierName: string) => Promise<Response>;
|
|
84
88
|
setQualifierImage: (tournamentId: string, qualifierId: string, qualifierImage: Uint8Array) => Promise<Response>;
|
|
85
89
|
setQualifierInfoChannel: (tournamentId: string, qualifierId: string, infoChannel: Channel) => Promise<Response>;
|
|
@@ -96,7 +100,7 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
|
|
|
96
100
|
getBotTokensForUser: (ownerDiscordId: string) => Promise<Response>;
|
|
97
101
|
generateBotToken: (username: string) => Promise<Response>;
|
|
98
102
|
revokeBotToken: (botTokenGuid: string) => Promise<Response>;
|
|
99
|
-
createTournament: (
|
|
103
|
+
createTournament: (serverAddress: string, serverName: string, serverPort: string, serverWebsocketPort: string, name: string, tournamentImage?: Uint8Array, enableTeams?: boolean, enablePools?: boolean, showTournamentButton?: boolean, showQualifierButton?: boolean, roles?: Role[], teams?: Tournament_TournamentSettings_Team[], scoreUpdateFrequency?: number, bannedMods?: string[], pools?: Tournament_TournamentSettings_Pool[], allowUnauthorizedView?: boolean) => Promise<Response>;
|
|
100
104
|
setTournamentName: (tournamentId: string, tournamentName: string) => Promise<Response>;
|
|
101
105
|
setTournamentImage: (tournamentId: string, tournamentImage: Uint8Array) => Promise<Response>;
|
|
102
106
|
setTournamentEnableTeams: (tournamentId: string, enableTeams: boolean) => Promise<Response>;
|
|
@@ -110,12 +114,13 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
|
|
|
110
114
|
setTournamentRoleName: (tournamentId: string, roleId: string, roleName: string) => Promise<Response>;
|
|
111
115
|
setTournamentRolePermissions: (tournamentId: string, roleId: string, permissions: string[]) => Promise<Response>;
|
|
112
116
|
removeTournamentRole: (tournamentId: string, roleId: string) => Promise<Response>;
|
|
113
|
-
addTournamentTeam: (tournamentId: string,
|
|
117
|
+
addTournamentTeam: (tournamentId: string, name: string, image: Uint8Array) => Promise<Response>;
|
|
114
118
|
setTournamentTeamName: (tournamentId: string, teamId: string, teamName: string) => Promise<Response>;
|
|
115
119
|
setTournamentTeamImage: (tournamentId: string, teamId: string, teamImage: Uint8Array) => Promise<Response>;
|
|
116
120
|
removeTournamentTeam: (tournamentId: string, teamId: string) => Promise<Response>;
|
|
117
|
-
addTournamentPool: (tournamentId: string,
|
|
121
|
+
addTournamentPool: (tournamentId: string, name: string, image: Uint8Array, maps: Map[]) => Promise<Response>;
|
|
118
122
|
setTournamentPoolName: (tournamentId: string, poolId: string, poolName: string) => Promise<Response>;
|
|
123
|
+
setTournamentPoolImage: (tournamentId: string, poolId: string, image: Uint8Array) => Promise<Response>;
|
|
119
124
|
addTournamentPoolMaps: (tournamentId: string, poolId: string, maps: Map[]) => Promise<Response>;
|
|
120
125
|
updateTournamentPoolMap: (tournamentId: string, poolId: string, map: Map) => Promise<Response>;
|
|
121
126
|
removeTournamentPoolMap: (tournamentId: string, poolId: string, mapId: string) => Promise<Response>;
|
|
@@ -4,12 +4,13 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
4
4
|
import { StateManager } from "./state-manager.js";
|
|
5
5
|
import { Response_ResponseType, } from "./models/responses.js";
|
|
6
6
|
import { Command_ModifyGameplay_Modifier } from "./models/commands.js";
|
|
7
|
-
import { versionCode } from "./constants.js";
|
|
7
|
+
import { masterAddress, masterApiPort, versionCode } from "./constants.js";
|
|
8
8
|
import WebSocket from "ws";
|
|
9
9
|
// Created by Moon on 6/12/2022
|
|
10
10
|
export * from "./scraper.js";
|
|
11
11
|
export * from "./models/models.js";
|
|
12
12
|
export class TAClient extends CustomEventEmitter {
|
|
13
|
+
_imageServer = `https://${masterAddress}:${masterApiPort}`;
|
|
13
14
|
stateManager;
|
|
14
15
|
uiVersion;
|
|
15
16
|
client;
|
|
@@ -99,6 +100,31 @@ export class TAClient extends CustomEventEmitter {
|
|
|
99
100
|
this.token = token;
|
|
100
101
|
this.client?.setToken(token);
|
|
101
102
|
}
|
|
103
|
+
async uploadImage(bytes) {
|
|
104
|
+
// If the image is one byte, assume we are uploading no image.
|
|
105
|
+
// This is related to the way I am forced to represent empty Uint8Arrays
|
|
106
|
+
if (bytes.length < 3) {
|
|
107
|
+
return "";
|
|
108
|
+
}
|
|
109
|
+
const blob = new Blob([bytes], { type: "image/png" });
|
|
110
|
+
const file = new File([blob], "dummy.png", {
|
|
111
|
+
type: "image/png",
|
|
112
|
+
});
|
|
113
|
+
const formData = new FormData();
|
|
114
|
+
formData.append("file", file);
|
|
115
|
+
const response = await fetch(`${this._imageServer}/api/file/upload`, {
|
|
116
|
+
method: "POST",
|
|
117
|
+
headers: {
|
|
118
|
+
Authorization: `Bearer ${this.token}`,
|
|
119
|
+
},
|
|
120
|
+
body: formData,
|
|
121
|
+
});
|
|
122
|
+
if (!response.ok) {
|
|
123
|
+
const error = await response.text();
|
|
124
|
+
throw new Error("Upload failed: " + error);
|
|
125
|
+
}
|
|
126
|
+
return await response.text();
|
|
127
|
+
}
|
|
102
128
|
sendCommand(command) {
|
|
103
129
|
this.client?.send({
|
|
104
130
|
token: "",
|
|
@@ -122,7 +148,7 @@ export class TAClient extends CustomEventEmitter {
|
|
|
122
148
|
};
|
|
123
149
|
const responseDictionary = [];
|
|
124
150
|
// Create a promise that resolves when all responses are received
|
|
125
|
-
const responsesPromise = new Promise((resolve) => {
|
|
151
|
+
const responsesPromise = new Promise((resolve, reject) => {
|
|
126
152
|
const addListeners = () => {
|
|
127
153
|
this.on("responseReceived", onResponseReceived);
|
|
128
154
|
this.on("authorizationRequestedFromServer", onAuthorizationRequested);
|
|
@@ -189,7 +215,7 @@ export class TAClient extends CustomEventEmitter {
|
|
|
189
215
|
// to provide a valid token, so we will combust
|
|
190
216
|
const onAuthorizationRequested = () => {
|
|
191
217
|
clearTimeout(timeoutTimer);
|
|
192
|
-
|
|
218
|
+
reject("Authorization token invalid or not provided");
|
|
193
219
|
};
|
|
194
220
|
addListeners();
|
|
195
221
|
});
|
|
@@ -255,6 +281,30 @@ export class TAClient extends CustomEventEmitter {
|
|
|
255
281
|
},
|
|
256
282
|
});
|
|
257
283
|
};
|
|
284
|
+
disableBlueNotes = (tournamentId, userIds) => {
|
|
285
|
+
this.sendCommand({
|
|
286
|
+
tournamentId,
|
|
287
|
+
forwardTo: userIds,
|
|
288
|
+
type: {
|
|
289
|
+
oneofKind: "modifyGameplay",
|
|
290
|
+
modifyGameplay: {
|
|
291
|
+
modifier: Command_ModifyGameplay_Modifier.DisableBlueNotes,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
disableRedNotes = (tournamentId, userIds) => {
|
|
297
|
+
this.sendCommand({
|
|
298
|
+
tournamentId,
|
|
299
|
+
forwardTo: userIds,
|
|
300
|
+
type: {
|
|
301
|
+
oneofKind: "modifyGameplay",
|
|
302
|
+
modifyGameplay: {
|
|
303
|
+
modifier: Command_ModifyGameplay_Modifier.DisableRedNotes,
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
};
|
|
258
308
|
showLoadedImage = (tournamentId, userIds, show = true) => {
|
|
259
309
|
this.sendCommand({
|
|
260
310
|
tournamentId,
|
|
@@ -681,13 +731,24 @@ export class TAClient extends CustomEventEmitter {
|
|
|
681
731
|
}
|
|
682
732
|
return response[0].response;
|
|
683
733
|
};
|
|
684
|
-
createQualifierEvent = async (tournamentId,
|
|
734
|
+
createQualifierEvent = async (tournamentId, name, infoChannelId, maps, flags, sort, qualifierImage) => {
|
|
685
735
|
const response = await this.sendRequest({
|
|
686
736
|
type: {
|
|
687
737
|
oneofKind: "createQualifierEvent",
|
|
688
738
|
createQualifierEvent: {
|
|
689
739
|
tournamentId,
|
|
690
|
-
event
|
|
740
|
+
event: {
|
|
741
|
+
guid: "",
|
|
742
|
+
name,
|
|
743
|
+
infoChannel: {
|
|
744
|
+
id: infoChannelId,
|
|
745
|
+
name: "dummy",
|
|
746
|
+
},
|
|
747
|
+
qualifierMaps: maps,
|
|
748
|
+
flags,
|
|
749
|
+
sort,
|
|
750
|
+
image: await this.uploadImage(qualifierImage),
|
|
751
|
+
},
|
|
691
752
|
},
|
|
692
753
|
},
|
|
693
754
|
});
|
|
@@ -719,7 +780,7 @@ export class TAClient extends CustomEventEmitter {
|
|
|
719
780
|
setQualifierImage: {
|
|
720
781
|
tournamentId,
|
|
721
782
|
qualifierId,
|
|
722
|
-
qualifierImage,
|
|
783
|
+
qualifierImage: await this.uploadImage(qualifierImage),
|
|
723
784
|
},
|
|
724
785
|
},
|
|
725
786
|
});
|
|
@@ -941,12 +1002,38 @@ export class TAClient extends CustomEventEmitter {
|
|
|
941
1002
|
}
|
|
942
1003
|
return response[0].response;
|
|
943
1004
|
};
|
|
944
|
-
createTournament = async (
|
|
1005
|
+
createTournament = async (serverAddress, serverName, serverPort, serverWebsocketPort, name, tournamentImage = new Uint8Array([1]), enableTeams = false, enablePools = false, showTournamentButton = true, showQualifierButton = true, roles = [], teams = [], scoreUpdateFrequency = 30, bannedMods = [], pools = [], allowUnauthorizedView = false) => {
|
|
945
1006
|
const response = await this.sendRequest({
|
|
946
1007
|
type: {
|
|
947
1008
|
oneofKind: "createTournament",
|
|
948
1009
|
createTournament: {
|
|
949
|
-
tournament
|
|
1010
|
+
tournament: {
|
|
1011
|
+
guid: uuidv4(),
|
|
1012
|
+
users: [],
|
|
1013
|
+
matches: [],
|
|
1014
|
+
qualifiers: [],
|
|
1015
|
+
settings: {
|
|
1016
|
+
tournamentName: name,
|
|
1017
|
+
tournamentImage: await this.uploadImage(tournamentImage),
|
|
1018
|
+
enableTeams,
|
|
1019
|
+
enablePools,
|
|
1020
|
+
showTournamentButton,
|
|
1021
|
+
showQualifierButton,
|
|
1022
|
+
roles,
|
|
1023
|
+
teams,
|
|
1024
|
+
scoreUpdateFrequency,
|
|
1025
|
+
bannedMods,
|
|
1026
|
+
pools,
|
|
1027
|
+
allowUnauthorizedView,
|
|
1028
|
+
myPermissions: [],
|
|
1029
|
+
},
|
|
1030
|
+
server: {
|
|
1031
|
+
address: serverAddress,
|
|
1032
|
+
name: serverName,
|
|
1033
|
+
port: +serverPort,
|
|
1034
|
+
websocketPort: +serverWebsocketPort,
|
|
1035
|
+
},
|
|
1036
|
+
},
|
|
950
1037
|
},
|
|
951
1038
|
},
|
|
952
1039
|
});
|
|
@@ -976,7 +1063,7 @@ export class TAClient extends CustomEventEmitter {
|
|
|
976
1063
|
oneofKind: "setTournamentImage",
|
|
977
1064
|
setTournamentImage: {
|
|
978
1065
|
tournamentId,
|
|
979
|
-
tournamentImage,
|
|
1066
|
+
tournamentImage: await this.uploadImage(tournamentImage),
|
|
980
1067
|
},
|
|
981
1068
|
},
|
|
982
1069
|
});
|
|
@@ -1152,13 +1239,17 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1152
1239
|
}
|
|
1153
1240
|
return response[0].response;
|
|
1154
1241
|
};
|
|
1155
|
-
addTournamentTeam = async (tournamentId,
|
|
1242
|
+
addTournamentTeam = async (tournamentId, name, image) => {
|
|
1156
1243
|
const response = await this.sendRequest({
|
|
1157
1244
|
type: {
|
|
1158
1245
|
oneofKind: "addTournamentTeam",
|
|
1159
1246
|
addTournamentTeam: {
|
|
1160
1247
|
tournamentId,
|
|
1161
|
-
team
|
|
1248
|
+
team: {
|
|
1249
|
+
guid: uuidv4(),
|
|
1250
|
+
name,
|
|
1251
|
+
image: await this.uploadImage(image),
|
|
1252
|
+
},
|
|
1162
1253
|
},
|
|
1163
1254
|
},
|
|
1164
1255
|
});
|
|
@@ -1190,7 +1281,7 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1190
1281
|
setTournamentTeamImage: {
|
|
1191
1282
|
tournamentId,
|
|
1192
1283
|
teamId,
|
|
1193
|
-
teamImage,
|
|
1284
|
+
teamImage: await this.uploadImage(teamImage),
|
|
1194
1285
|
},
|
|
1195
1286
|
},
|
|
1196
1287
|
});
|
|
@@ -1214,13 +1305,18 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1214
1305
|
}
|
|
1215
1306
|
return response[0].response;
|
|
1216
1307
|
};
|
|
1217
|
-
addTournamentPool = async (tournamentId,
|
|
1308
|
+
addTournamentPool = async (tournamentId, name, image, maps) => {
|
|
1218
1309
|
const response = await this.sendRequest({
|
|
1219
1310
|
type: {
|
|
1220
1311
|
oneofKind: "addTournamentPool",
|
|
1221
1312
|
addTournamentPool: {
|
|
1222
1313
|
tournamentId,
|
|
1223
|
-
pool
|
|
1314
|
+
pool: {
|
|
1315
|
+
guid: uuidv4(),
|
|
1316
|
+
name,
|
|
1317
|
+
image: await this.uploadImage(image),
|
|
1318
|
+
maps,
|
|
1319
|
+
},
|
|
1224
1320
|
},
|
|
1225
1321
|
},
|
|
1226
1322
|
});
|
|
@@ -1245,6 +1341,22 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1245
1341
|
}
|
|
1246
1342
|
return response[0].response;
|
|
1247
1343
|
};
|
|
1344
|
+
setTournamentPoolImage = async (tournamentId, poolId, image) => {
|
|
1345
|
+
const response = await this.sendRequest({
|
|
1346
|
+
type: {
|
|
1347
|
+
oneofKind: "setTournamentPoolImage",
|
|
1348
|
+
setTournamentPoolImage: {
|
|
1349
|
+
tournamentId,
|
|
1350
|
+
poolId,
|
|
1351
|
+
poolImage: await this.uploadImage(image),
|
|
1352
|
+
},
|
|
1353
|
+
},
|
|
1354
|
+
});
|
|
1355
|
+
if (response.length <= 0) {
|
|
1356
|
+
throw new Error("Server timed out");
|
|
1357
|
+
}
|
|
1358
|
+
return response[0].response;
|
|
1359
|
+
};
|
|
1248
1360
|
addTournamentPoolMaps = async (tournamentId, poolId, maps) => {
|
|
1249
1361
|
const response = await this.sendRequest({
|
|
1250
1362
|
type: {
|