rhythia-api 243.0.0 → 244.0.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/api/createBeatmap.ts +13 -7
- package/api/executeAdminOperation.ts +1291 -1030
- package/api/getChangelog.ts +46 -0
- package/api/getProfile.ts +297 -297
- package/handleApi.ts +24 -24
- package/index.ts +72 -50
- package/package.json +4 -2
- package/supabase/.temp/cli-latest +1 -0
- package/supabase/.temp/linked-project.json +1 -0
- package/types/database.ts +178 -1
- package/utils/beatmapHash.ts +239 -336
- package/utils/moderation.ts +101 -0
- package/utils/requestUtils.ts +2 -2
- package/utils/star-calc/formatSingle.ts +107 -0
- package/utils/star-calc/rhmParser.ts +214 -0
- package/worker.ts +197 -195
- package/.env +0 -1
package/handleApi.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
let endpoint = "https://development.rhythia.com";
|
|
3
|
-
import { profanity, CensorType } from "@2toad/profanity";
|
|
4
|
-
export function setEnvironment(
|
|
5
|
-
stage: "development" | "testing" | "production"
|
|
6
|
-
) {
|
|
7
|
-
endpoint = `https://${stage}.rhythia.com`;
|
|
8
|
-
}
|
|
9
|
-
export function setEndpoint(value: string) {
|
|
10
|
-
endpoint = value;
|
|
11
|
-
}
|
|
12
|
-
export function handleApi<
|
|
13
|
-
T extends { url: string; input: z.ZodObject<any>; output: z.
|
|
14
|
-
>(apiSchema: T) {
|
|
15
|
-
profanity.whitelist.addWords(["willy"]);
|
|
16
|
-
return async (input: T["input"]["_type"]): Promise<T["output"]["_type"]> => {
|
|
17
|
-
const response = await fetch(`${endpoint}${apiSchema.url}`, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
body: JSON.stringify(input),
|
|
20
|
-
});
|
|
21
|
-
const output = await response.text();
|
|
22
|
-
return JSON.parse(profanity.censor(output));
|
|
23
|
-
};
|
|
24
|
-
}
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
let endpoint = "https://development.rhythia.com";
|
|
3
|
+
import { profanity, CensorType } from "@2toad/profanity";
|
|
4
|
+
export function setEnvironment(
|
|
5
|
+
stage: "development" | "testing" | "production"
|
|
6
|
+
) {
|
|
7
|
+
endpoint = `https://${stage}.rhythia.com`;
|
|
8
|
+
}
|
|
9
|
+
export function setEndpoint(value: string) {
|
|
10
|
+
endpoint = value;
|
|
11
|
+
}
|
|
12
|
+
export function handleApi<
|
|
13
|
+
T extends { url: string; input: z.ZodObject<any>; output: z.ZodTypeAny }
|
|
14
|
+
>(apiSchema: T) {
|
|
15
|
+
profanity.whitelist.addWords(["willy"]);
|
|
16
|
+
return async (input: T["input"]["_type"]): Promise<T["output"]["_type"]> => {
|
|
17
|
+
const response = await fetch(`${endpoint}${apiSchema.url}`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
body: JSON.stringify(input),
|
|
20
|
+
});
|
|
21
|
+
const output = await response.text();
|
|
22
|
+
return JSON.parse(profanity.censor(output));
|
|
23
|
+
};
|
|
24
|
+
}
|
package/index.ts
CHANGED
|
@@ -709,6 +709,28 @@ import { Schema as GetBeatmapStarRating } from "./api/getBeatmapStarRating"
|
|
|
709
709
|
export { Schema as SchemaGetBeatmapStarRating } from "./api/getBeatmapStarRating"
|
|
710
710
|
export const getBeatmapStarRating = handleApi({url:"/api/getBeatmapStarRating",...GetBeatmapStarRating})
|
|
711
711
|
|
|
712
|
+
// ./api/getChangelog.ts API
|
|
713
|
+
|
|
714
|
+
/*
|
|
715
|
+
export const Schema = {
|
|
716
|
+
input: z.strictObject({
|
|
717
|
+
type: changelogType,
|
|
718
|
+
skip: z.number().default(0),
|
|
719
|
+
limit: z.number().default(10),
|
|
720
|
+
}),
|
|
721
|
+
output: z.array(
|
|
722
|
+
z.object({
|
|
723
|
+
id: z.number(),
|
|
724
|
+
type: z.string(),
|
|
725
|
+
date: z.string(),
|
|
726
|
+
markdown: z.string(),
|
|
727
|
+
})
|
|
728
|
+
),
|
|
729
|
+
};*/
|
|
730
|
+
import { Schema as GetChangelog } from "./api/getChangelog"
|
|
731
|
+
export { Schema as SchemaGetChangelog } from "./api/getChangelog"
|
|
732
|
+
export const getChangelog = handleApi({url:"/api/getChangelog",...GetChangelog})
|
|
733
|
+
|
|
712
734
|
// ./api/getClan.ts API
|
|
713
735
|
|
|
714
736
|
/*
|
|
@@ -1007,56 +1029,56 @@ export const getPassToken = handleApi({url:"/api/getPassToken",...GetPassToken})
|
|
|
1007
1029
|
// ./api/getProfile.ts API
|
|
1008
1030
|
|
|
1009
1031
|
/*
|
|
1010
|
-
export const Schema = {
|
|
1011
|
-
input: z.strictObject({
|
|
1012
|
-
session: z.string(),
|
|
1013
|
-
id: z.number().nullable().optional(),
|
|
1014
|
-
}),
|
|
1015
|
-
output: z.object({
|
|
1016
|
-
error: z.string().optional(),
|
|
1017
|
-
user: z
|
|
1018
|
-
.object({
|
|
1019
|
-
about_me: z.string().nullable(),
|
|
1020
|
-
avatar_url: z.string().nullable(),
|
|
1021
|
-
profile_image: z.string().nullable(),
|
|
1022
|
-
badges: z.any().nullable(),
|
|
1023
|
-
created_at: z.number().nullable(),
|
|
1024
|
-
flag: z.string().nullable(),
|
|
1025
|
-
id: z.number(),
|
|
1026
|
-
uid: z.string().nullable(),
|
|
1027
|
-
ban: z.string().nullable(),
|
|
1028
|
-
username: z.string().nullable(),
|
|
1029
|
-
verified: z.boolean().nullable(),
|
|
1030
|
-
verificationDeadline: z.number().nullable(),
|
|
1031
|
-
play_count: z.number().nullable(),
|
|
1032
|
-
skill_points: z.number().nullable(),
|
|
1033
|
-
squares_hit: z.number().nullable(),
|
|
1034
|
-
total_score: z.number().nullable(),
|
|
1035
|
-
position: z.number().nullable(),
|
|
1036
|
-
country_position: z.number().nullable(),
|
|
1037
|
-
activity_status: z.enum(["active", "inactive"]),
|
|
1038
|
-
is_online: z.boolean(),
|
|
1039
|
-
last_active_timestamp: z.number().nullable(),
|
|
1040
|
-
friend_count: z.number(),
|
|
1041
|
-
friend_state: friendStateSchema,
|
|
1042
|
-
can_change_flag: z.boolean(),
|
|
1043
|
-
next_username_change_at: z.string().nullable(),
|
|
1044
|
-
previous_usernames: z.array(
|
|
1045
|
-
z.object({
|
|
1046
|
-
username: z.string(),
|
|
1047
|
-
changed_at: z.string(),
|
|
1048
|
-
})
|
|
1049
|
-
),
|
|
1050
|
-
clans: z
|
|
1051
|
-
.object({
|
|
1052
|
-
id: z.number(),
|
|
1053
|
-
acronym: z.string(),
|
|
1054
|
-
})
|
|
1055
|
-
.optional()
|
|
1056
|
-
.nullable(),
|
|
1057
|
-
})
|
|
1058
|
-
.optional(),
|
|
1059
|
-
}),
|
|
1032
|
+
export const Schema = {
|
|
1033
|
+
input: z.strictObject({
|
|
1034
|
+
session: z.string(),
|
|
1035
|
+
id: z.number().nullable().optional(),
|
|
1036
|
+
}),
|
|
1037
|
+
output: z.object({
|
|
1038
|
+
error: z.string().optional(),
|
|
1039
|
+
user: z
|
|
1040
|
+
.object({
|
|
1041
|
+
about_me: z.string().nullable(),
|
|
1042
|
+
avatar_url: z.string().nullable(),
|
|
1043
|
+
profile_image: z.string().nullable(),
|
|
1044
|
+
badges: z.any().nullable(),
|
|
1045
|
+
created_at: z.number().nullable(),
|
|
1046
|
+
flag: z.string().nullable(),
|
|
1047
|
+
id: z.number(),
|
|
1048
|
+
uid: z.string().nullable(),
|
|
1049
|
+
ban: z.string().nullable(),
|
|
1050
|
+
username: z.string().nullable(),
|
|
1051
|
+
verified: z.boolean().nullable(),
|
|
1052
|
+
verificationDeadline: z.number().nullable(),
|
|
1053
|
+
play_count: z.number().nullable(),
|
|
1054
|
+
skill_points: z.number().nullable(),
|
|
1055
|
+
squares_hit: z.number().nullable(),
|
|
1056
|
+
total_score: z.number().nullable(),
|
|
1057
|
+
position: z.number().nullable(),
|
|
1058
|
+
country_position: z.number().nullable(),
|
|
1059
|
+
activity_status: z.enum(["active", "inactive"]),
|
|
1060
|
+
is_online: z.boolean(),
|
|
1061
|
+
last_active_timestamp: z.number().nullable(),
|
|
1062
|
+
friend_count: z.number(),
|
|
1063
|
+
friend_state: friendStateSchema,
|
|
1064
|
+
can_change_flag: z.boolean(),
|
|
1065
|
+
next_username_change_at: z.string().nullable(),
|
|
1066
|
+
previous_usernames: z.array(
|
|
1067
|
+
z.object({
|
|
1068
|
+
username: z.string(),
|
|
1069
|
+
changed_at: z.string(),
|
|
1070
|
+
})
|
|
1071
|
+
),
|
|
1072
|
+
clans: z
|
|
1073
|
+
.object({
|
|
1074
|
+
id: z.number(),
|
|
1075
|
+
acronym: z.string(),
|
|
1076
|
+
})
|
|
1077
|
+
.optional()
|
|
1078
|
+
.nullable(),
|
|
1079
|
+
})
|
|
1080
|
+
.optional(),
|
|
1081
|
+
}),
|
|
1060
1082
|
};*/
|
|
1061
1083
|
import { Schema as GetProfile } from "./api/getProfile"
|
|
1062
1084
|
export { Schema as SchemaGetProfile } from "./api/getProfile"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rhythia-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "244.0.0",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"author": "online-contributors-cunev",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"query-push": "bun run scripts/deploy-queries.ts",
|
|
20
20
|
"queries:pull": "bun run scripts/pull-queries.ts",
|
|
21
21
|
"queries:deploy": "bun run scripts/deploy-queries.ts",
|
|
22
|
-
"sync": "npx supabase gen types typescript --project-id \"pfkajngbllcbdzoylrvp\" --schema public > types/database.ts"
|
|
22
|
+
"sync": "npx supabase gen types typescript --project-id \"pfkajngbllcbdzoylrvp\" --schema public > types/database.ts",
|
|
23
|
+
"sync-dev": "npx supabase gen types typescript --project-id \"gcxlgiajvbpbimrfqbwp\" --schema public > types/database.ts"
|
|
23
24
|
},
|
|
24
25
|
"license": "MIT",
|
|
25
26
|
"dependencies": {
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"osu-classes": "^3.1.0",
|
|
45
46
|
"osu-parsers": "^4.1.7",
|
|
46
47
|
"osu-standard-stable": "^5.0.0",
|
|
48
|
+
"pako": "^2.1.0",
|
|
47
49
|
"pg": "^8.18.0",
|
|
48
50
|
"redis": "^5.10.0",
|
|
49
51
|
"remote-cloudflare-kv": "^1.0.1",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v2.101.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"ref":"pfkajngbllcbdzoylrvp","name":"Rhythia","organization_id":"ljnnninaexvxjtaftvet","organization_slug":"ljnnninaexvxjtaftvet"}
|
package/types/database.ts
CHANGED
|
@@ -14,6 +14,36 @@ export type Database = {
|
|
|
14
14
|
}
|
|
15
15
|
public: {
|
|
16
16
|
Tables: {
|
|
17
|
+
ac_builds: {
|
|
18
|
+
Row: {
|
|
19
|
+
active: boolean
|
|
20
|
+
created_at: string
|
|
21
|
+
game_branch: string
|
|
22
|
+
hash: string
|
|
23
|
+
id: number
|
|
24
|
+
platform: string
|
|
25
|
+
url: string
|
|
26
|
+
}
|
|
27
|
+
Insert: {
|
|
28
|
+
active: boolean
|
|
29
|
+
created_at?: string
|
|
30
|
+
game_branch?: string
|
|
31
|
+
hash: string
|
|
32
|
+
id?: number
|
|
33
|
+
platform?: string
|
|
34
|
+
url: string
|
|
35
|
+
}
|
|
36
|
+
Update: {
|
|
37
|
+
active?: boolean
|
|
38
|
+
created_at?: string
|
|
39
|
+
game_branch?: string
|
|
40
|
+
hash?: string
|
|
41
|
+
id?: number
|
|
42
|
+
platform?: string
|
|
43
|
+
url?: string
|
|
44
|
+
}
|
|
45
|
+
Relationships: []
|
|
46
|
+
}
|
|
17
47
|
admin_actions: {
|
|
18
48
|
Row: {
|
|
19
49
|
action_type: string
|
|
@@ -276,6 +306,33 @@ export type Database = {
|
|
|
276
306
|
}
|
|
277
307
|
Relationships: []
|
|
278
308
|
}
|
|
309
|
+
changelogs: {
|
|
310
|
+
Row: {
|
|
311
|
+
created_at: string
|
|
312
|
+
date: string
|
|
313
|
+
id: number
|
|
314
|
+
markdown: string
|
|
315
|
+
name: string
|
|
316
|
+
type: string
|
|
317
|
+
}
|
|
318
|
+
Insert: {
|
|
319
|
+
created_at?: string
|
|
320
|
+
date: string
|
|
321
|
+
id?: number
|
|
322
|
+
markdown: string
|
|
323
|
+
name: string
|
|
324
|
+
type: string
|
|
325
|
+
}
|
|
326
|
+
Update: {
|
|
327
|
+
created_at?: string
|
|
328
|
+
date?: string
|
|
329
|
+
id?: number
|
|
330
|
+
markdown?: string
|
|
331
|
+
name?: string
|
|
332
|
+
type?: string
|
|
333
|
+
}
|
|
334
|
+
Relationships: []
|
|
335
|
+
}
|
|
279
336
|
chartedValues: {
|
|
280
337
|
Row: {
|
|
281
338
|
created_at: string
|
|
@@ -864,6 +921,76 @@ export type Database = {
|
|
|
864
921
|
},
|
|
865
922
|
]
|
|
866
923
|
}
|
|
924
|
+
user_violations: {
|
|
925
|
+
Row: {
|
|
926
|
+
active_period: unknown
|
|
927
|
+
created_at: string
|
|
928
|
+
effective_until: string | null
|
|
929
|
+
expires_at: string | null
|
|
930
|
+
id: number
|
|
931
|
+
metadata: Json
|
|
932
|
+
moderated_by: number | null
|
|
933
|
+
profile_id: number
|
|
934
|
+
reason: string
|
|
935
|
+
revoke_reason: string | null
|
|
936
|
+
revoked_at: string | null
|
|
937
|
+
revoked_by: number | null
|
|
938
|
+
violation_type: Database["public"]["Enums"]["user_violation_type"]
|
|
939
|
+
}
|
|
940
|
+
Insert: {
|
|
941
|
+
active_period?: unknown
|
|
942
|
+
created_at?: string
|
|
943
|
+
effective_until?: string | null
|
|
944
|
+
expires_at?: string | null
|
|
945
|
+
id?: number
|
|
946
|
+
metadata?: Json
|
|
947
|
+
moderated_by?: number | null
|
|
948
|
+
profile_id: number
|
|
949
|
+
reason: string
|
|
950
|
+
revoke_reason?: string | null
|
|
951
|
+
revoked_at?: string | null
|
|
952
|
+
revoked_by?: number | null
|
|
953
|
+
violation_type: Database["public"]["Enums"]["user_violation_type"]
|
|
954
|
+
}
|
|
955
|
+
Update: {
|
|
956
|
+
active_period?: unknown
|
|
957
|
+
created_at?: string
|
|
958
|
+
effective_until?: string | null
|
|
959
|
+
expires_at?: string | null
|
|
960
|
+
id?: number
|
|
961
|
+
metadata?: Json
|
|
962
|
+
moderated_by?: number | null
|
|
963
|
+
profile_id?: number
|
|
964
|
+
reason?: string
|
|
965
|
+
revoke_reason?: string | null
|
|
966
|
+
revoked_at?: string | null
|
|
967
|
+
revoked_by?: number | null
|
|
968
|
+
violation_type?: Database["public"]["Enums"]["user_violation_type"]
|
|
969
|
+
}
|
|
970
|
+
Relationships: [
|
|
971
|
+
{
|
|
972
|
+
foreignKeyName: "user_violations_moderated_by_fkey"
|
|
973
|
+
columns: ["moderated_by"]
|
|
974
|
+
isOneToOne: false
|
|
975
|
+
referencedRelation: "profiles"
|
|
976
|
+
referencedColumns: ["id"]
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
foreignKeyName: "user_violations_profile_id_fkey"
|
|
980
|
+
columns: ["profile_id"]
|
|
981
|
+
isOneToOne: false
|
|
982
|
+
referencedRelation: "profiles"
|
|
983
|
+
referencedColumns: ["id"]
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
foreignKeyName: "user_violations_revoked_by_fkey"
|
|
987
|
+
columns: ["revoked_by"]
|
|
988
|
+
isOneToOne: false
|
|
989
|
+
referencedRelation: "profiles"
|
|
990
|
+
referencedColumns: ["id"]
|
|
991
|
+
},
|
|
992
|
+
]
|
|
993
|
+
}
|
|
867
994
|
vetos: {
|
|
868
995
|
Row: {
|
|
869
996
|
beatmapPage: number
|
|
@@ -908,6 +1035,37 @@ export type Database = {
|
|
|
908
1035
|
[_ in never]: never
|
|
909
1036
|
}
|
|
910
1037
|
Functions: {
|
|
1038
|
+
add_user_violation: {
|
|
1039
|
+
Args: {
|
|
1040
|
+
_expires_at?: string
|
|
1041
|
+
_metadata?: Json
|
|
1042
|
+
_moderated_by?: number
|
|
1043
|
+
_profile_id: number
|
|
1044
|
+
_reason: string
|
|
1045
|
+
_violation_type: Database["public"]["Enums"]["user_violation_type"]
|
|
1046
|
+
}
|
|
1047
|
+
Returns: {
|
|
1048
|
+
active_period: unknown
|
|
1049
|
+
created_at: string
|
|
1050
|
+
effective_until: string | null
|
|
1051
|
+
expires_at: string | null
|
|
1052
|
+
id: number
|
|
1053
|
+
metadata: Json
|
|
1054
|
+
moderated_by: number | null
|
|
1055
|
+
profile_id: number
|
|
1056
|
+
reason: string
|
|
1057
|
+
revoke_reason: string | null
|
|
1058
|
+
revoked_at: string | null
|
|
1059
|
+
revoked_by: number | null
|
|
1060
|
+
violation_type: Database["public"]["Enums"]["user_violation_type"]
|
|
1061
|
+
}
|
|
1062
|
+
SetofOptions: {
|
|
1063
|
+
from: "*"
|
|
1064
|
+
to: "user_violations"
|
|
1065
|
+
isOneToOne: true
|
|
1066
|
+
isSetofReturn: false
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
911
1069
|
admin_delete_user: { Args: { user_id: number }; Returns: boolean }
|
|
912
1070
|
admin_exclude_user: { Args: { user_id: number }; Returns: boolean }
|
|
913
1071
|
admin_invalidate_ranked_scores: {
|
|
@@ -1062,7 +1220,6 @@ export type Database = {
|
|
|
1062
1220
|
id: number
|
|
1063
1221
|
image: string
|
|
1064
1222
|
length: number
|
|
1065
|
-
map_hash: string
|
|
1066
1223
|
owner: number
|
|
1067
1224
|
owner_username: string
|
|
1068
1225
|
playcount: number
|
|
@@ -1378,6 +1535,15 @@ export type Database = {
|
|
|
1378
1535
|
Args: { limit_param: number; userid: number }
|
|
1379
1536
|
Returns: Json
|
|
1380
1537
|
}
|
|
1538
|
+
get_user_violation_state: {
|
|
1539
|
+
Args: { _profile_id: number }
|
|
1540
|
+
Returns: {
|
|
1541
|
+
active_violations: Json
|
|
1542
|
+
excluded: boolean
|
|
1543
|
+
restricted: boolean
|
|
1544
|
+
silenced: boolean
|
|
1545
|
+
}[]
|
|
1546
|
+
}
|
|
1381
1547
|
grant_special_badges: {
|
|
1382
1548
|
Args: {
|
|
1383
1549
|
p_beatmap_id: number
|
|
@@ -1387,10 +1553,20 @@ export type Database = {
|
|
|
1387
1553
|
}
|
|
1388
1554
|
Returns: Json
|
|
1389
1555
|
}
|
|
1556
|
+
revoke_user_violation: {
|
|
1557
|
+
Args: {
|
|
1558
|
+
_profile_id: number
|
|
1559
|
+
_revoke_reason?: string
|
|
1560
|
+
_revoked_by?: number
|
|
1561
|
+
_violation_type: Database["public"]["Enums"]["user_violation_type"]
|
|
1562
|
+
}
|
|
1563
|
+
Returns: number
|
|
1564
|
+
}
|
|
1390
1565
|
}
|
|
1391
1566
|
Enums: {
|
|
1392
1567
|
banTypes: "cool" | "silenced" | "restricted" | "excluded"
|
|
1393
1568
|
discordWebhookType: "maps" | "scores"
|
|
1569
|
+
user_violation_type: "silenced" | "restricted" | "excluded"
|
|
1394
1570
|
}
|
|
1395
1571
|
CompositeTypes: {
|
|
1396
1572
|
[_ in never]: never
|
|
@@ -1520,6 +1696,7 @@ export const Constants = {
|
|
|
1520
1696
|
Enums: {
|
|
1521
1697
|
banTypes: ["cool", "silenced", "restricted", "excluded"],
|
|
1522
1698
|
discordWebhookType: ["maps", "scores"],
|
|
1699
|
+
user_violation_type: ["silenced", "restricted", "excluded"],
|
|
1523
1700
|
},
|
|
1524
1701
|
},
|
|
1525
1702
|
} as const
|