mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-30 10:58:07 +03:00
feat: add schemas for new challenge database things
This commit is contained in:
@@ -461,6 +461,15 @@ const PR_CHART_DOCUMENT = (game: Game) => (self: unknown) => {
|
||||
})(self);
|
||||
};
|
||||
|
||||
const PR_CHALLENGE = {
|
||||
chartID: "string",
|
||||
authorID: p.isPositiveNonZeroInteger,
|
||||
type: p.isIn("lamp", "score"),
|
||||
|
||||
game: p.isIn(games),
|
||||
playtype: isValidPlaytype,
|
||||
};
|
||||
|
||||
// Returns true on success, throws on failure.
|
||||
export type SchemaValidatorFunction = (self: unknown) => true;
|
||||
|
||||
@@ -1084,6 +1093,15 @@ const PRE_SCHEMAS = {
|
||||
return p.isPositive(self);
|
||||
},
|
||||
}),
|
||||
|
||||
"challenge-wall": prSchemaFnWrap(PR_CHALLENGE),
|
||||
"challenge-subs": prSchemaFnWrap({
|
||||
...PR_CHALLENGE,
|
||||
userID: p.isPositiveNonZeroInteger,
|
||||
achieved: "boolean",
|
||||
achievedAt: "?number",
|
||||
}),
|
||||
|
||||
notifications: prSchemaFnWrap({
|
||||
title: "string",
|
||||
notifID: "string",
|
||||
@@ -1107,10 +1125,25 @@ const PRE_SCHEMAS = {
|
||||
break;
|
||||
}
|
||||
|
||||
case "MILESTONE_CHANGED":
|
||||
case "MILESTONE_CHANGED": {
|
||||
subSchema = {
|
||||
milestoneID: "string",
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
case "CHALLENGE_BEAT": {
|
||||
subSchema = {
|
||||
userID: p.isPositiveNonZeroInteger,
|
||||
challenge: PR_CHALLENGE,
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
case "CHALLENGE_RECEIVED":
|
||||
subSchema = {
|
||||
challenge: PR_CHALLENGE,
|
||||
};
|
||||
}
|
||||
|
||||
const err = p(self, subSchema);
|
||||
|
||||
Reference in New Issue
Block a user