This commit is contained in:
Madeline
2022-09-26 22:41:21 +10:00
parent fcc0884e36
commit 99ee7e9400
280 changed files with 6800 additions and 3908 deletions
+3 -2
View File
@@ -41,7 +41,8 @@ export const ActivitySchema = {
$id: String,
$sync_id: String,
$metadata: { // spotify
$metadata: {
// spotify
$context_uri: String,
album_id: String,
artist_ids: [String],
@@ -57,4 +58,4 @@ export interface ActivitySchema {
status: Status;
activities?: Activity[];
since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle
}
}
@@ -1,3 +1,3 @@
export interface BackupCodesChallengeSchema {
password: string;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface BanCreateSchema {
delete_message_days?: string;
reason?: string;
};
}
+1 -1
View File
@@ -4,4 +4,4 @@ export interface BanModeratorSchema {
guild_id: string;
executor_id: string;
reason?: string | undefined;
};
}
+1 -1
View File
@@ -5,4 +5,4 @@ export interface BanRegistrySchema {
executor_id: string;
ip?: string;
reason?: string | undefined;
};
}
+1 -1
View File
@@ -1,3 +1,3 @@
export interface BulkDeleteSchema {
messages: string[];
}
}
+1 -1
View File
@@ -27,4 +27,4 @@ export interface ChannelModifySchema {
flags?: number;
default_thread_rate_limit_per_user?: number;
video_quality_mode?: number;
}
}
+1 -1
View File
@@ -2,4 +2,4 @@ export interface CodesVerificationSchema {
key: string;
nonce: string;
regenerate?: boolean;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface DmChannelCreateSchema {
name?: string;
recipients: string[];
}
}
+1 -1
View File
@@ -3,4 +3,4 @@ export interface EmojiCreateSchema {
image: string;
require_colons?: boolean | null;
roles?: string[];
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface EmojiModifySchema {
name?: string;
roles?: string[];
}
}
+1 -1
View File
@@ -11,4 +11,4 @@ export interface GuildCreateSchema {
guild_template_code?: string;
system_channel_id?: string;
rules_channel_id?: string;
}
}
@@ -1,4 +1,4 @@
export interface GuildTemplateCreateSchema {
name: string;
avatar?: string | null;
}
}
@@ -7,4 +7,4 @@ export interface GuildUpdateWelcomeScreenSchema {
}[];
enabled?: boolean;
description?: string;
}
}
+1 -1
View File
@@ -8,4 +8,4 @@ export interface InviteCreateSchema {
unique?: boolean;
target_user?: string;
target_user_type?: number;
}
}
+1 -1
View File
@@ -5,4 +5,4 @@ export interface LoginSchema {
captcha_key?: string;
login_source?: string;
gift_code_sku_id?: string;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface MemberChangeSchema {
roles?: string[];
nick?: string;
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
export interface MemberNickChangeSchema {
nick: string;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface MessageAcknowledgeSchema {
manual?: boolean;
mention_count?: number;
}
}
+1 -1
View File
@@ -30,4 +30,4 @@ export interface MessageCreateSchema {
**/
attachments?: any[];
sticker_ids?: string[];
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface MfaCodesSchema {
password: string;
regenerate?: boolean;
}
}
+1 -1
View File
@@ -12,4 +12,4 @@ export interface ModifyGuildStickerSchema {
* @maxLength 200
*/
tags: string;
}
}
+1 -1
View File
@@ -3,4 +3,4 @@ export interface PruneSchema {
* @min 0
*/
days: number;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface PurgeSchema {
before: string;
after: string;
}
}
+1 -1
View File
@@ -24,4 +24,4 @@ export interface RegisterSchema {
captcha_key?: string;
promotional_email_opt_in?: boolean;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface RelationshipPostSchema {
discriminator: string;
username: string;
}
}
+1 -1
View File
@@ -2,4 +2,4 @@ import { RelationshipType } from "@fosscord/util";
export interface RelationshipPutSchema {
type?: RelationshipType;
}
}
+1 -1
View File
@@ -7,4 +7,4 @@ export interface RoleModifySchema {
position?: number;
icon?: string;
unicode_emoji?: string;
}
}
+7 -7
View File
@@ -1,12 +1,12 @@
export interface SelectProtocolSchema {
protocol: "webrtc" | "udp";
data:
| string
| {
address: string;
port: number;
mode: string;
};
| string
| {
address: string;
port: number;
mode: string;
};
sdp?: string;
codecs?: {
name: "opus" | "VP8" | "VP9" | "H264";
@@ -16,4 +16,4 @@ export interface SelectProtocolSchema {
rtx_payload_type?: number | null;
}[];
rtc_connection_id?: string; // uuid
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface TemplateCreateSchema {
name: string;
description?: string;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface TemplateModifySchema {
name: string;
description?: string;
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
export interface TotpDisableSchema {
code: string;
}
}
+1 -1
View File
@@ -2,4 +2,4 @@ export interface TotpEnableSchema {
password: string;
code?: string;
secret?: string;
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
export interface TotpSchema {
code: string,
ticket: string,
gift_code_sku_id?: string | null,
login_source?: string | null,
}
code: string;
ticket: string;
gift_code_sku_id?: string | null;
login_source?: string | null;
}
+1 -1
View File
@@ -16,4 +16,4 @@ export interface UserModifySchema {
code?: string;
email?: string;
discriminator?: string;
}
}
+18 -4
View File
@@ -3,7 +3,14 @@ import addFormats from "ajv-formats";
import fs from "fs";
import path from "path";
const SchemaPath = path.join(__dirname, "..", "..", "..", "assets", "schemas.json");
const SchemaPath = path.join(
__dirname,
"..",
"..",
"..",
"assets",
"schemas.json",
);
const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
export const ajv = new Ajv({
@@ -14,7 +21,7 @@ export const ajv = new Ajv({
coerceTypes: true,
messages: true,
strict: true,
strictRequired: true
strictRequired: true,
});
addFormats(ajv);
@@ -41,7 +48,14 @@ export const normalizeBody = (body: any = {}) => {
} else {
for (const [key, value] of Object.entries(object)) {
if (value == null) {
if (key === "icon" || key === "avatar" || key === "banner" || key === "splash" || key === "discovery_splash") continue;
if (
key === "icon" ||
key === "avatar" ||
key === "banner" ||
key === "splash" ||
key === "discovery_splash"
)
continue;
delete object[key];
} else if (typeof value === "object") {
normalizeObject(value);
@@ -51,4 +65,4 @@ export const normalizeBody = (body: any = {}) => {
};
normalizeObject(body);
return body;
};
};
+1 -1
View File
@@ -4,4 +4,4 @@ export interface VanityUrlSchema {
* @maxLength 20
*/
code?: string;
}
}
+1 -1
View File
@@ -9,4 +9,4 @@ export interface VoiceIdentifySchema {
rid: string;
quality: number;
}[];
}
}
+2 -2
View File
@@ -15,8 +15,8 @@ export const VoiceStateUpdateSchema = {
$channel_id: String,
self_mute: Boolean,
self_deaf: Boolean,
$self_video: Boolean, //required in docs but bots don't always send it
$self_video: Boolean, //required in docs but bots don't always send it
$preferred_region: String,
$request_to_speak_timestamp: Date,
$suppress: Boolean,
};
};
+2 -2
View File
@@ -12,6 +12,6 @@ export interface VoiceVideoSchema {
rtx_ssrc: number;
max_bitrate: number;
max_framerate: number;
max_resolution: { type: string; width: number; height: number; };
max_resolution: { type: string; width: number; height: number };
}[];
}
}
+1 -1
View File
@@ -5,4 +5,4 @@ export interface WebhookCreateSchema {
*/
name: string;
avatar: string;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface WidgetModifySchema {
enabled: boolean; // whether the widget is enabled
channel_id: string; // the widget channel id
}
}
+1 -1
View File
@@ -38,4 +38,4 @@ export * from "./VoiceStateUpdateSchema";
export * from "./VoiceVideoSchema";
export * from "./IdentifySchema";
export * from "./ActivitySchema";
export * from "./LazyRequestSchema";
export * from "./LazyRequestSchema";