tbarequest 1.0.8 → 1.2.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/index.d.mts +2958 -167
- package/dist/index.mjs +110 -18
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import { ArkErrors, type } from "arktype";
|
|
2
2
|
|
|
3
|
-
//#region src/utils.ts
|
|
4
|
-
async function tryCatch(promise) {
|
|
5
|
-
try {
|
|
6
|
-
return {
|
|
7
|
-
data: await promise,
|
|
8
|
-
error: null
|
|
9
|
-
};
|
|
10
|
-
} catch (error) {
|
|
11
|
-
return {
|
|
12
|
-
data: null,
|
|
13
|
-
error
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
3
|
//#region src/types/schemas/teams.ts
|
|
20
4
|
const Team_Simple = type({
|
|
21
5
|
key: "string",
|
|
@@ -781,12 +765,13 @@ const Match_Simple = type({
|
|
|
781
765
|
actual_time: "number | null",
|
|
782
766
|
predicted_time: "number | null"
|
|
783
767
|
});
|
|
768
|
+
const scoreBreakdownYears = msb["2015"].or(msb["2016"]).or(msb["2017"]).or(msb["2018"]).or(msb["2019"]).or(msb["2020"]).or(msb["2022"]).or(msb["2023"]).or(msb["2024"]).or(msb["2025"]).or(msb["2026"]);
|
|
784
769
|
const Match = Match_Simple.and({
|
|
785
770
|
videos: type({
|
|
786
771
|
type: "string",
|
|
787
772
|
key: "string"
|
|
788
773
|
}).array(),
|
|
789
|
-
score_breakdown:
|
|
774
|
+
score_breakdown: type(scoreBreakdownYears, "|", "null")
|
|
790
775
|
});
|
|
791
776
|
|
|
792
777
|
//#endregion
|
|
@@ -1274,6 +1259,113 @@ const endpoints = {
|
|
|
1274
1259
|
...searchIndex
|
|
1275
1260
|
};
|
|
1276
1261
|
|
|
1262
|
+
//#endregion
|
|
1263
|
+
//#region src/types/webhooks.ts
|
|
1264
|
+
const upcomingMatch = type({
|
|
1265
|
+
message_type: "'upcoming_match'",
|
|
1266
|
+
message_data: {
|
|
1267
|
+
event_key: "string",
|
|
1268
|
+
match_key: "string",
|
|
1269
|
+
team_key: "string?",
|
|
1270
|
+
event_name: "string",
|
|
1271
|
+
team_keys: "string[]",
|
|
1272
|
+
scheduled_time: "number?",
|
|
1273
|
+
predicted_time: "number?",
|
|
1274
|
+
webcast: Webcast.optional()
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
const matchScore = type({
|
|
1278
|
+
message_type: "'match_score'",
|
|
1279
|
+
message_data: {
|
|
1280
|
+
event_key: "string",
|
|
1281
|
+
match_key: "string",
|
|
1282
|
+
team_key: "string?",
|
|
1283
|
+
event_name: "string",
|
|
1284
|
+
match: Match
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
const matchVideo = type({
|
|
1288
|
+
message_type: "'match_video'",
|
|
1289
|
+
message_data: {
|
|
1290
|
+
event_key: "string",
|
|
1291
|
+
match_key: "string",
|
|
1292
|
+
team_key: "string?",
|
|
1293
|
+
event_name: "string",
|
|
1294
|
+
match: Match
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
const startingCompLevel = type({
|
|
1298
|
+
message_type: "'starting_comp_level'",
|
|
1299
|
+
message_data: {
|
|
1300
|
+
event_key: "string",
|
|
1301
|
+
event_name: "string",
|
|
1302
|
+
comp_level: "'qm' | 'ef' | 'qf' | 'sf' |'f'",
|
|
1303
|
+
scheduled_time: "number?"
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
const allianceSelection = type({
|
|
1307
|
+
message_type: "'alliance_selection'",
|
|
1308
|
+
message_data: {
|
|
1309
|
+
event_key: "string",
|
|
1310
|
+
team_key: "string?",
|
|
1311
|
+
event_name: "string",
|
|
1312
|
+
event: Event
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
const awardsPosted = type({
|
|
1316
|
+
message_type: "'awards_posted'",
|
|
1317
|
+
message_data: {
|
|
1318
|
+
event_key: "string",
|
|
1319
|
+
team_key: "string?",
|
|
1320
|
+
event_name: "string",
|
|
1321
|
+
awards: Award.array()
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
const eventScheduleUpdated = type({
|
|
1325
|
+
message_type: "'schedule_updated'",
|
|
1326
|
+
message_data: {
|
|
1327
|
+
event_key: "string",
|
|
1328
|
+
event_name: "string",
|
|
1329
|
+
first_match_time: "number?"
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
const ping = type({
|
|
1333
|
+
message_type: "'ping'",
|
|
1334
|
+
message_data: {
|
|
1335
|
+
title: "string",
|
|
1336
|
+
desc: "string"
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
const broadcast = type({
|
|
1340
|
+
message_type: "'broadcast'",
|
|
1341
|
+
message_data: {
|
|
1342
|
+
title: "string",
|
|
1343
|
+
desc: "string",
|
|
1344
|
+
url: "string"
|
|
1345
|
+
}
|
|
1346
|
+
});
|
|
1347
|
+
const webhookVerification = type({
|
|
1348
|
+
message_type: "'verification'",
|
|
1349
|
+
message_data: { verification_key: "string" }
|
|
1350
|
+
});
|
|
1351
|
+
const notification = upcomingMatch.or(matchScore).or(matchVideo).or(startingCompLevel).or(allianceSelection).or(awardsPosted).or(eventScheduleUpdated).or(ping).or(broadcast).or(webhookVerification);
|
|
1352
|
+
|
|
1353
|
+
//#endregion
|
|
1354
|
+
//#region src/utils.ts
|
|
1355
|
+
async function tryCatch(promise) {
|
|
1356
|
+
try {
|
|
1357
|
+
return {
|
|
1358
|
+
data: await promise,
|
|
1359
|
+
error: null
|
|
1360
|
+
};
|
|
1361
|
+
} catch (error) {
|
|
1362
|
+
return {
|
|
1363
|
+
data: null,
|
|
1364
|
+
error
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1277
1369
|
//#endregion
|
|
1278
1370
|
//#region src/index.ts
|
|
1279
1371
|
function createTBACaller(api_key) {
|
|
@@ -1328,4 +1420,4 @@ async function TBA(endpoint, api_key, ...args) {
|
|
|
1328
1420
|
}
|
|
1329
1421
|
|
|
1330
1422
|
//#endregion
|
|
1331
|
-
export { createTBACaller };
|
|
1423
|
+
export { createTBACaller, notification };
|