moons-ta-client 1.3.1 → 1.3.3

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.
@@ -1,5 +1,5 @@
1
1
  import { CustomEventEmitter } from "./custom-event-emitter.js";
2
- import { User, Match, CoreServer, GameplayParameters, Map, QualifierEvent_EventSettings, QualifierEvent_LeaderboardSort, Tournament_TournamentSettings_Team, Tournament_TournamentSettings_Pool, RealtimeScore, Role } from "./models/models.js";
2
+ import { User, Match, CoreServer, GameplayParameters, Map, QualifierEvent_EventSettings, QualifierEvent_LeaderboardSort, Tournament_TournamentSettings_Team, Tournament_TournamentSettings_Pool, RealtimeScore, Role, GlobalConfiguration } 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";
@@ -78,6 +78,7 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
78
78
  showColor: (tournamentId: string, color: string, userIds: string[]) => void;
79
79
  delayTestFinished: (tournamentId: string, userIds: string[]) => void;
80
80
  joinTournament: (tournamentId: string) => Promise<Response>;
81
+ leaveTournament: (tournamentId: string) => Promise<Response>;
81
82
  getLeaderboard: (tournamentId: string, qualifierId: string, mapId: string) => Promise<Response>;
82
83
  loadSong: (tournamentId: string, levelId: string, userIds: string[], timeout?: number) => Promise<ResponseFromUser[]>;
83
84
  loadImage: (tournamentId: string, bitmap: Uint8Array, userIds: string[]) => Promise<ResponseFromUser[]>;
@@ -91,12 +92,14 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
91
92
  setMatchLeader: (tournamentId: string, matchId: string, userId: string) => Promise<Response>;
92
93
  setMatchMap: (tournamentId: string, matchId: string, map: Map) => Promise<Response>;
93
94
  deleteMatch: (tournamentId: string, matchId: string) => Promise<Response>;
94
- createQualifierEvent: (tournamentId: string, name: string, infoChannelId: string, maps: Map[], flags: QualifierEvent_EventSettings, sort: QualifierEvent_LeaderboardSort, qualifierImage: Uint8Array) => Promise<Response>;
95
+ createQualifierEvent: (tournamentId: string, name: string, infoChannelId: string, maps: Map[], flags: QualifierEvent_EventSettings, sort: QualifierEvent_LeaderboardSort, qualifierImage: Uint8Array, startTime?: Date, endTime?: Date) => Promise<Response>;
95
96
  setQualifierName: (tournamentId: string, qualifierId: string, qualifierName: string) => Promise<Response>;
96
97
  setQualifierImage: (tournamentId: string, qualifierId: string, qualifierImage: Uint8Array) => Promise<Response>;
97
98
  setQualifierInfoChannel: (tournamentId: string, qualifierId: string, infoChannel: Channel) => Promise<Response>;
98
99
  setQualifierFlags: (tournamentId: string, qualifierId: string, qualifierFlags: QualifierEvent_EventSettings) => Promise<Response>;
99
100
  setQualifierLeaderboardSort: (tournamentId: string, qualifierId: string, qualifierLeaderboardSort: QualifierEvent_LeaderboardSort) => Promise<Response>;
101
+ setQualifierStartTime: (tournamentId: string, qualifierId: string, startTime?: Date) => Promise<Response>;
102
+ setQualifierEndTime: (tournamentId: string, qualifierId: string, endTime?: Date) => Promise<Response>;
100
103
  addQualifierMaps: (tournamentId: string, qualifierId: string, maps: Map[]) => Promise<Response>;
101
104
  updateQualifierMap: (tournamentId: string, qualifierId: string, map: Map) => Promise<Response>;
102
105
  removeQualifierMap: (tournamentId: string, qualifierId: string, mapId: string) => Promise<Response>;
@@ -108,12 +111,17 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
108
111
  getBotTokensForUser: (ownerDiscordId: string) => Promise<Response>;
109
112
  generateBotToken: (username: string) => Promise<Response>;
110
113
  revokeBotToken: (botTokenGuid: string) => Promise<Response>;
111
- 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, enableReplayStreaming?: boolean) => Promise<Response>;
114
+ getWebhooks: (tournamentId: string) => Promise<Response>;
115
+ createWebhook: (tournamentId: string, url: string, triggers: bigint, signingSecret?: string) => Promise<Response>;
116
+ updateWebhook: (tournamentId: string, webhookGuid: string, url: string, triggers: bigint, replaceSigningSecret?: boolean, signingSecret?: string) => Promise<Response>;
117
+ deleteWebhook: (tournamentId: string, webhookGuid: string) => Promise<Response>;
118
+ 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, enableReplayStreaming?: boolean, allowMockClients?: boolean) => Promise<Response>;
112
119
  setTournamentName: (tournamentId: string, tournamentName: string) => Promise<Response>;
113
120
  setTournamentImage: (tournamentId: string, tournamentImage: Uint8Array) => Promise<Response>;
114
121
  setTournamentEnableTeams: (tournamentId: string, enableTeams: boolean) => Promise<Response>;
115
122
  setTournamentEnablePools: (tournamentId: string, enablePools: boolean) => Promise<Response>;
116
123
  setTournamentEnableReplayStreaming: (tournamentId: string, enableReplayStreaming: boolean) => Promise<Response>;
124
+ setTournamentAllowMockClients: (tournamentId: string, allowMockClients: boolean) => Promise<Response>;
117
125
  setTournamentShowTournamentButton: (tournamentId: string, showTournamentButton: boolean) => Promise<Response>;
118
126
  setTournamentShowQualifierButton: (tournamentId: string, showQualifierButton: boolean) => Promise<Response>;
119
127
  setTournamentAllowUnauthorizedView: (tournamentId: string, allowUnauthorizedView: boolean) => Promise<Response>;
@@ -136,4 +144,7 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
136
144
  removeTournamentPool: (tournamentId: string, poolId: string) => Promise<Response>;
137
145
  deleteTournament: (tournamentId: string) => Promise<Response>;
138
146
  addServer: (server: CoreServer, authToken?: string) => Promise<Response>;
147
+ getGlobalConfiguration: () => Promise<Response>;
148
+ updateGlobalConfiguration: (configuration: GlobalConfiguration) => Promise<Response>;
149
+ setBKTournamentLink: (tournamentId: string, isBKTournament: boolean, beatKhanaTournamentGuid: string) => Promise<Response>;
139
150
  }
@@ -6,6 +6,7 @@ import { Response_ResponseType } from "./models/responses.js";
6
6
  import { Command_ModifyGameplay_Modifier } from "./models/commands.js";
7
7
  import { masterAddress, masterApiPort, versionCode } from "./constants.js";
8
8
  import WebSocket from "ws";
9
+ import { Timestamp } from "./models/google/protobuf/timestamp.js";
9
10
  // Created by Moon on 6/12/2022
10
11
  export * from "./scraper.js";
11
12
  export * from "./models/models.js";
@@ -372,6 +373,17 @@ export class TAClient extends CustomEventEmitter {
372
373
  }
373
374
  return response[0].response;
374
375
  };
376
+ leaveTournament = async (tournamentId) => {
377
+ const response = await this.sendRequest({
378
+ type: {
379
+ oneofKind: "leaveTournament",
380
+ leaveTournament: { tournamentId },
381
+ },
382
+ });
383
+ if (response.length <= 0)
384
+ throw new Error("Server timed out");
385
+ return response[0].response;
386
+ };
375
387
  getLeaderboard = async (tournamentId, qualifierId, mapId) => {
376
388
  const response = await this.sendRequest({
377
389
  type: {
@@ -745,7 +757,7 @@ export class TAClient extends CustomEventEmitter {
745
757
  }
746
758
  return response[0].response;
747
759
  };
748
- createQualifierEvent = async (tournamentId, name, infoChannelId, maps, flags, sort, qualifierImage) => {
760
+ createQualifierEvent = async (tournamentId, name, infoChannelId, maps, flags, sort, qualifierImage, startTime, endTime) => {
749
761
  const response = await this.sendRequest({
750
762
  type: {
751
763
  oneofKind: "createQualifierEvent",
@@ -762,6 +774,8 @@ export class TAClient extends CustomEventEmitter {
762
774
  flags,
763
775
  sort,
764
776
  image: await this.uploadImage(qualifierImage),
777
+ startTime: startTime ? Timestamp.fromDate(startTime) : undefined,
778
+ endTime: endTime ? Timestamp.fromDate(endTime) : undefined,
765
779
  },
766
780
  },
767
781
  },
@@ -851,6 +865,36 @@ export class TAClient extends CustomEventEmitter {
851
865
  }
852
866
  return response[0].response;
853
867
  };
868
+ setQualifierStartTime = async (tournamentId, qualifierId, startTime) => {
869
+ const response = await this.sendRequest({
870
+ type: {
871
+ oneofKind: "setQualifierStartTime",
872
+ setQualifierStartTime: {
873
+ tournamentId,
874
+ qualifierId,
875
+ startTime: startTime ? Timestamp.fromDate(startTime) : undefined,
876
+ },
877
+ },
878
+ });
879
+ if (response.length <= 0)
880
+ throw new Error("Server timed out");
881
+ return response[0].response;
882
+ };
883
+ setQualifierEndTime = async (tournamentId, qualifierId, endTime) => {
884
+ const response = await this.sendRequest({
885
+ type: {
886
+ oneofKind: "setQualifierEndTime",
887
+ setQualifierEndTime: {
888
+ tournamentId,
889
+ qualifierId,
890
+ endTime: endTime ? Timestamp.fromDate(endTime) : undefined,
891
+ },
892
+ },
893
+ });
894
+ if (response.length <= 0)
895
+ throw new Error("Server timed out");
896
+ return response[0].response;
897
+ };
854
898
  addQualifierMaps = async (tournamentId, qualifierId, maps) => {
855
899
  const response = await this.sendRequest({
856
900
  type: {
@@ -1016,7 +1060,55 @@ export class TAClient extends CustomEventEmitter {
1016
1060
  }
1017
1061
  return response[0].response;
1018
1062
  };
1019
- 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, enableReplayStreaming = false) => {
1063
+ getWebhooks = async (tournamentId) => {
1064
+ const response = await this.sendRequest({
1065
+ type: { oneofKind: "getWebhooks", getWebhooks: { tournamentId } },
1066
+ });
1067
+ if (response.length <= 0)
1068
+ throw new Error("Server timed out");
1069
+ return response[0].response;
1070
+ };
1071
+ createWebhook = async (tournamentId, url, triggers, signingSecret = "") => {
1072
+ const response = await this.sendRequest({
1073
+ type: {
1074
+ oneofKind: "createWebhook",
1075
+ createWebhook: { tournamentId, url, triggers, signingSecret },
1076
+ },
1077
+ });
1078
+ if (response.length <= 0)
1079
+ throw new Error("Server timed out");
1080
+ return response[0].response;
1081
+ };
1082
+ updateWebhook = async (tournamentId, webhookGuid, url, triggers, replaceSigningSecret = false, signingSecret = "") => {
1083
+ const response = await this.sendRequest({
1084
+ type: {
1085
+ oneofKind: "updateWebhook",
1086
+ updateWebhook: {
1087
+ tournamentId,
1088
+ webhookGuid,
1089
+ url,
1090
+ triggers,
1091
+ replaceSigningSecret,
1092
+ signingSecret,
1093
+ },
1094
+ },
1095
+ });
1096
+ if (response.length <= 0)
1097
+ throw new Error("Server timed out");
1098
+ return response[0].response;
1099
+ };
1100
+ deleteWebhook = async (tournamentId, webhookGuid) => {
1101
+ const response = await this.sendRequest({
1102
+ type: {
1103
+ oneofKind: "deleteWebhook",
1104
+ deleteWebhook: { tournamentId, webhookGuid },
1105
+ },
1106
+ });
1107
+ if (response.length <= 0)
1108
+ throw new Error("Server timed out");
1109
+ return response[0].response;
1110
+ };
1111
+ 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, enableReplayStreaming = false, allowMockClients = false) => {
1020
1112
  const response = await this.sendRequest({
1021
1113
  type: {
1022
1114
  oneofKind: "createTournament",
@@ -1032,6 +1124,9 @@ export class TAClient extends CustomEventEmitter {
1032
1124
  enableTeams,
1033
1125
  enablePools,
1034
1126
  enableReplayStreaming,
1127
+ allowMockClients,
1128
+ isBkTournament: false,
1129
+ beatKhanaTournamentGuid: "",
1035
1130
  showTournamentButton,
1036
1131
  showQualifierButton,
1037
1132
  roles,
@@ -1132,6 +1227,20 @@ export class TAClient extends CustomEventEmitter {
1132
1227
  }
1133
1228
  return response[0].response;
1134
1229
  };
1230
+ setTournamentAllowMockClients = async (tournamentId, allowMockClients) => {
1231
+ const response = await this.sendRequest({
1232
+ type: {
1233
+ oneofKind: "setTournamentAllowMockClients",
1234
+ setTournamentAllowMockClients: {
1235
+ tournamentId,
1236
+ allowMockClients,
1237
+ },
1238
+ },
1239
+ });
1240
+ if (response.length <= 0)
1241
+ throw new Error("Server timed out");
1242
+ return response[0].response;
1243
+ };
1135
1244
  setTournamentShowTournamentButton = async (tournamentId, showTournamentButton) => {
1136
1245
  const response = await this.sendRequest({
1137
1246
  type: {
@@ -1479,4 +1588,44 @@ export class TAClient extends CustomEventEmitter {
1479
1588
  }
1480
1589
  return response[0].response;
1481
1590
  };
1591
+ getGlobalConfiguration = async () => {
1592
+ const response = await this.sendRequest({
1593
+ type: {
1594
+ oneofKind: "getGlobalConfiguration",
1595
+ getGlobalConfiguration: {},
1596
+ },
1597
+ });
1598
+ if (response.length <= 0) {
1599
+ throw new Error("Server timed out");
1600
+ }
1601
+ return response[0].response;
1602
+ };
1603
+ updateGlobalConfiguration = async (configuration) => {
1604
+ const response = await this.sendRequest({
1605
+ type: {
1606
+ oneofKind: "updateGlobalConfiguration",
1607
+ updateGlobalConfiguration: { configuration },
1608
+ },
1609
+ });
1610
+ if (response.length <= 0) {
1611
+ throw new Error("Server timed out");
1612
+ }
1613
+ return response[0].response;
1614
+ };
1615
+ setBKTournamentLink = async (tournamentId, isBKTournament, beatKhanaTournamentGuid) => {
1616
+ const response = await this.sendRequest({
1617
+ type: {
1618
+ oneofKind: "setBkTournamentLink",
1619
+ setBkTournamentLink: {
1620
+ tournamentId,
1621
+ isBkTournament: isBKTournament,
1622
+ beatKhanaTournamentGuid,
1623
+ },
1624
+ },
1625
+ });
1626
+ if (response.length <= 0) {
1627
+ throw new Error("Server timed out");
1628
+ }
1629
+ return response[0].response;
1630
+ };
1482
1631
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moons-ta-client",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -28,25 +28,19 @@
28
28
  "@types/uuid": "^8.3.4",
29
29
  "@types/ws": "^8.5.10",
30
30
  "esbuild": "^0.19.12",
31
- "esbuild-plugin-polyfill-node": "^0.3.0",
32
31
  "esbuild-plugin-globals": "^0.2.0",
32
+ "esbuild-plugin-polyfill-node": "^0.3.0",
33
33
  "rollup": "^4.17.2",
34
34
  "rollup-plugin-dts": "^6.1.1",
35
- "tslib": "^2.3.1",
36
35
  "typescript": "^4.5.4"
37
36
  },
38
37
  "dependencies": {
39
38
  "@protobuf-ts/plugin": "^2.6.0",
40
39
  "events": "^3.3.0",
41
- "install": "^0.13.0",
42
- "npm": "^10.8.0",
43
40
  "uuid": "^9.0.0",
44
41
  "ws": "^8.17.0"
45
42
  },
46
43
  "files": [
47
- "LICENSE",
48
- "README.md",
49
- "dist",
50
- "package.json"
44
+ "dist"
51
45
  ]
52
- }
46
+ }