moons-ta-client 1.3.2 → 1.4.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/dist/constants.d.ts +2 -2
- package/dist/constants.js +2 -2
- package/dist/custom-event-emitter.js +1 -1
- package/dist/index.d.ts +866 -8
- package/dist/index.esm.js +6656 -4198
- package/dist/models/models.d.ts +216 -2
- package/dist/models/models.js +412 -3
- package/dist/models/pushes.d.ts +40 -0
- package/dist/models/pushes.js +82 -1
- package/dist/models/requests.d.ts +382 -0
- package/dist/models/requests.js +834 -1
- package/dist/models/responses.d.ts +217 -0
- package/dist/models/responses.js +469 -1
- package/dist/scraper.js +3 -4
- package/dist/tournament-assistant-client.d.ts +11 -2
- package/dist/tournament-assistant-client.js +109 -0
- package/package.json +4 -10
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Client } from "./client.js";
|
|
2
2
|
import { CustomEventEmitter } from "./custom-event-emitter.js";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
|
4
|
+
import { ReplayRetention, } from "./models/models.js";
|
|
4
5
|
import { StateManager } from "./state-manager.js";
|
|
5
6
|
import { Response_ResponseType } from "./models/responses.js";
|
|
6
7
|
import { Command_ModifyGameplay_Modifier } from "./models/commands.js";
|
|
@@ -644,6 +645,9 @@ export class TAClient extends CustomEventEmitter {
|
|
|
644
645
|
else if (push.data.oneofKind === "qualifierScoreSubmtited") {
|
|
645
646
|
this.emit("qualifierScoreSubmitted", push.data.qualifierScoreSubmtited);
|
|
646
647
|
}
|
|
648
|
+
else if (push.data.oneofKind === "replaySubmitted") {
|
|
649
|
+
this.emit("replaySubmitted", push.data.replaySubmitted);
|
|
650
|
+
}
|
|
647
651
|
}
|
|
648
652
|
};
|
|
649
653
|
// --- State Actions --- //
|
|
@@ -1124,7 +1128,13 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1124
1128
|
enableTeams,
|
|
1125
1129
|
enablePools,
|
|
1126
1130
|
enableReplayStreaming,
|
|
1131
|
+
enableReplayRecording: false,
|
|
1132
|
+
replayRetention: ReplayRetention.ThirtyDays,
|
|
1133
|
+
updatedAt: 0n,
|
|
1134
|
+
autoHideAt: 0n,
|
|
1127
1135
|
allowMockClients,
|
|
1136
|
+
isBkTournament: false,
|
|
1137
|
+
beatKhanaTournamentGuid: "",
|
|
1128
1138
|
showTournamentButton,
|
|
1129
1139
|
showQualifierButton,
|
|
1130
1140
|
roles,
|
|
@@ -1225,6 +1235,65 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1225
1235
|
}
|
|
1226
1236
|
return response[0].response;
|
|
1227
1237
|
};
|
|
1238
|
+
setTournamentEnableReplayRecording = async (tournamentId, enableReplayRecording) => {
|
|
1239
|
+
const response = await this.sendRequest({
|
|
1240
|
+
type: {
|
|
1241
|
+
oneofKind: "setTournamentEnableReplayRecording",
|
|
1242
|
+
setTournamentEnableReplayRecording: {
|
|
1243
|
+
tournamentId,
|
|
1244
|
+
enableReplayRecording,
|
|
1245
|
+
},
|
|
1246
|
+
},
|
|
1247
|
+
});
|
|
1248
|
+
if (response.length <= 0) {
|
|
1249
|
+
throw new Error("Server timed out");
|
|
1250
|
+
}
|
|
1251
|
+
return response[0].response;
|
|
1252
|
+
};
|
|
1253
|
+
setTournamentReplayRetention = async (tournamentId, replayRetention) => {
|
|
1254
|
+
const response = await this.sendRequest({
|
|
1255
|
+
type: {
|
|
1256
|
+
oneofKind: "setTournamentReplayRetention",
|
|
1257
|
+
setTournamentReplayRetention: {
|
|
1258
|
+
tournamentId,
|
|
1259
|
+
replayRetention,
|
|
1260
|
+
},
|
|
1261
|
+
},
|
|
1262
|
+
});
|
|
1263
|
+
if (response.length <= 0) {
|
|
1264
|
+
throw new Error("Server timed out");
|
|
1265
|
+
}
|
|
1266
|
+
return response[0].response;
|
|
1267
|
+
};
|
|
1268
|
+
// Pages start at 0, the newest replays come first
|
|
1269
|
+
getReplays = async (tournamentId, page, pageSize) => {
|
|
1270
|
+
const response = await this.sendRequest({
|
|
1271
|
+
type: { oneofKind: "getReplays", getReplays: { tournamentId, page, pageSize } },
|
|
1272
|
+
});
|
|
1273
|
+
if (response.length <= 0)
|
|
1274
|
+
throw new Error("Server timed out");
|
|
1275
|
+
return response[0].response;
|
|
1276
|
+
};
|
|
1277
|
+
deleteReplay = async (tournamentId, replayGuid) => {
|
|
1278
|
+
const response = await this.sendRequest({
|
|
1279
|
+
type: { oneofKind: "deleteReplay", deleteReplay: { tournamentId, replayGuid } },
|
|
1280
|
+
});
|
|
1281
|
+
if (response.length <= 0)
|
|
1282
|
+
throw new Error("Server timed out");
|
|
1283
|
+
return response[0].response;
|
|
1284
|
+
};
|
|
1285
|
+
// Replays can be larger than a packet, so they are downloaded over the REST API with the same token
|
|
1286
|
+
downloadReplay = async (downloadUrl) => {
|
|
1287
|
+
const response = await fetch(downloadUrl, {
|
|
1288
|
+
headers: {
|
|
1289
|
+
Authorization: `Bearer ${this.token}`,
|
|
1290
|
+
},
|
|
1291
|
+
});
|
|
1292
|
+
if (!response.ok) {
|
|
1293
|
+
throw new Error("Download failed: " + (await response.text()));
|
|
1294
|
+
}
|
|
1295
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
1296
|
+
};
|
|
1228
1297
|
setTournamentAllowMockClients = async (tournamentId, allowMockClients) => {
|
|
1229
1298
|
const response = await this.sendRequest({
|
|
1230
1299
|
type: {
|
|
@@ -1586,4 +1655,44 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1586
1655
|
}
|
|
1587
1656
|
return response[0].response;
|
|
1588
1657
|
};
|
|
1658
|
+
getGlobalConfiguration = async () => {
|
|
1659
|
+
const response = await this.sendRequest({
|
|
1660
|
+
type: {
|
|
1661
|
+
oneofKind: "getGlobalConfiguration",
|
|
1662
|
+
getGlobalConfiguration: {},
|
|
1663
|
+
},
|
|
1664
|
+
});
|
|
1665
|
+
if (response.length <= 0) {
|
|
1666
|
+
throw new Error("Server timed out");
|
|
1667
|
+
}
|
|
1668
|
+
return response[0].response;
|
|
1669
|
+
};
|
|
1670
|
+
updateGlobalConfiguration = async (configuration) => {
|
|
1671
|
+
const response = await this.sendRequest({
|
|
1672
|
+
type: {
|
|
1673
|
+
oneofKind: "updateGlobalConfiguration",
|
|
1674
|
+
updateGlobalConfiguration: { configuration },
|
|
1675
|
+
},
|
|
1676
|
+
});
|
|
1677
|
+
if (response.length <= 0) {
|
|
1678
|
+
throw new Error("Server timed out");
|
|
1679
|
+
}
|
|
1680
|
+
return response[0].response;
|
|
1681
|
+
};
|
|
1682
|
+
setBKTournamentLink = async (tournamentId, isBKTournament, beatKhanaTournamentGuid) => {
|
|
1683
|
+
const response = await this.sendRequest({
|
|
1684
|
+
type: {
|
|
1685
|
+
oneofKind: "setBkTournamentLink",
|
|
1686
|
+
setBkTournamentLink: {
|
|
1687
|
+
tournamentId,
|
|
1688
|
+
isBkTournament: isBKTournament,
|
|
1689
|
+
beatKhanaTournamentGuid,
|
|
1690
|
+
},
|
|
1691
|
+
},
|
|
1692
|
+
});
|
|
1693
|
+
if (response.length <= 0) {
|
|
1694
|
+
throw new Error("Server timed out");
|
|
1695
|
+
}
|
|
1696
|
+
return response[0].response;
|
|
1697
|
+
};
|
|
1589
1698
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moons-ta-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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
|
-
"
|
|
48
|
-
"README.md",
|
|
49
|
-
"dist",
|
|
50
|
-
"package.json"
|
|
44
|
+
"dist"
|
|
51
45
|
]
|
|
52
|
-
}
|
|
46
|
+
}
|