summary refs log tree commit diff
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-12 11:42:34 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 21:57:51 +0200
commit1f4ba6395bf96237fd8b638fd70926b887b9c374 (patch)
tree3ee4145490ff392837eb979b72843f6e8c90cbda
parentSplit schemas into files in util (diff)
downloadserver-1f4ba6395bf96237fd8b638fd70926b887b9c374.tar.xz
Forgot some schemas, removed no longer used paths from generate schema script
-rw-r--r--api/assets/schemas.json541
-rw-r--r--api/scripts/generate_schema.js5
-rw-r--r--api/src/routes/guilds/#guild_id/channels.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/roles/index.ts8
-rw-r--r--util/src/schemas/ChannelReorderSchema.ts1
-rw-r--r--util/src/schemas/RolePositionUpdateSchema.ts4
-rw-r--r--util/src/schemas/index.ts2
7 files changed, 193 insertions, 372 deletions
diff --git a/api/assets/schemas.json b/api/assets/schemas.json
index f102f9d0..9286b804 100644
--- a/api/assets/schemas.json
+++ b/api/assets/schemas.json
@@ -98,175 +98,27 @@
         ],
         "$schema": "http://json-schema.org/draft-07/schema#"
     },
-    "ActivitySchema": {
+    "RouteResponse": {
         "type": "object",
         "properties": {
-            "afk": {
-                "type": "boolean"
-            },
             "status": {
-                "$ref": "#/definitions/Status"
+                "type": "integer"
             },
-            "activities": {
+            "body": {
                 "type": "array",
                 "items": {
-                    "$ref": "#/definitions/Activity"
+                    "type": "string"
                 }
             },
-            "since": {
-                "type": "integer"
+            "headers": {
+                "$ref": "#/definitions/Record<string,string>"
             }
         },
         "additionalProperties": false,
-        "required": [
-            "afk",
-            "status"
-        ],
         "definitions": {
-            "Status": {
-                "enum": [
-                    "dnd",
-                    "idle",
-                    "invisible",
-                    "offline",
-                    "online"
-                ],
-                "type": "string"
-            },
-            "Activity": {
+            "Record<string,string>": {
                 "type": "object",
-                "properties": {
-                    "name": {
-                        "type": "string"
-                    },
-                    "type": {
-                        "$ref": "#/definitions/ActivityType"
-                    },
-                    "url": {
-                        "type": "string"
-                    },
-                    "created_at": {
-                        "type": "integer"
-                    },
-                    "timestamps": {
-                        "type": "object",
-                        "properties": {
-                            "start": {
-                                "type": "integer"
-                            },
-                            "end": {
-                                "type": "integer"
-                            }
-                        },
-                        "additionalProperties": false,
-                        "required": [
-                            "end",
-                            "start"
-                        ]
-                    },
-                    "application_id": {
-                        "type": "string"
-                    },
-                    "details": {
-                        "type": "string"
-                    },
-                    "state": {
-                        "type": "string"
-                    },
-                    "emoji": {
-                        "type": "object",
-                        "properties": {
-                            "name": {
-                                "type": "string"
-                            },
-                            "id": {
-                                "type": "string"
-                            },
-                            "animated": {
-                                "type": "boolean"
-                            }
-                        },
-                        "additionalProperties": false,
-                        "required": [
-                            "animated",
-                            "name"
-                        ]
-                    },
-                    "party": {
-                        "type": "object",
-                        "properties": {
-                            "id": {
-                                "type": "string"
-                            },
-                            "size": {
-                                "type": "array",
-                                "items": [
-                                    {
-                                        "type": "integer"
-                                    }
-                                ],
-                                "minItems": 1,
-                                "maxItems": 1
-                            }
-                        },
-                        "additionalProperties": false
-                    },
-                    "assets": {
-                        "type": "object",
-                        "properties": {
-                            "large_image": {
-                                "type": "string"
-                            },
-                            "large_text": {
-                                "type": "string"
-                            },
-                            "small_image": {
-                                "type": "string"
-                            },
-                            "small_text": {
-                                "type": "string"
-                            }
-                        },
-                        "additionalProperties": false
-                    },
-                    "secrets": {
-                        "type": "object",
-                        "properties": {
-                            "join": {
-                                "type": "string"
-                            },
-                            "spectate": {
-                                "type": "string"
-                            },
-                            "match": {
-                                "type": "string"
-                            }
-                        },
-                        "additionalProperties": false
-                    },
-                    "instance": {
-                        "type": "boolean"
-                    },
-                    "flags": {
-                        "type": "string"
-                    }
-                },
-                "additionalProperties": false,
-                "required": [
-                    "flags",
-                    "name",
-                    "type"
-                ]
-            },
-            "ActivityType": {
-                "enum": [
-                    0,
-                    1,
-                    2,
-                    4,
-                    5
-                ],
-                "type": "number"
+                "additionalProperties": false
             }
         },
         "$schema": "http://json-schema.org/draft-07/schema#"
@@ -510,6 +362,31 @@
         },
         "$schema": "http://json-schema.org/draft-07/schema#"
     },
+    "ChannelReorderSchema": {
+        "type": "array",
+        "items": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "string"
+                },
+                "position": {
+                    "type": "integer"
+                },
+                "lock_permissions": {
+                    "type": "boolean"
+                },
+                "parent_id": {
+                    "type": "string"
+                }
+            },
+            "additionalProperties": false,
+            "required": [
+                "id"
+            ]
+        },
+        "$schema": "http://json-schema.org/draft-07/schema#"
+    },
     "DmChannelCreateSchema": {
         "type": "object",
         "properties": {
@@ -1678,6 +1555,26 @@
         "additionalProperties": false,
         "$schema": "http://json-schema.org/draft-07/schema#"
     },
+    "RolePositionUpdateSchema": {
+        "type": "array",
+        "items": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "string"
+                },
+                "position": {
+                    "type": "integer"
+                }
+            },
+            "additionalProperties": false,
+            "required": [
+                "id",
+                "position"
+            ]
+        },
+        "$schema": "http://json-schema.org/draft-07/schema#"
+    },
     "TemplateCreateSchema": {
         "type": "object",
         "properties": {
@@ -2111,253 +2008,177 @@
         ],
         "$schema": "http://json-schema.org/draft-07/schema#"
     },
-    "RouteResponse": {
+    "ActivitySchema": {
         "type": "object",
         "properties": {
+            "afk": {
+                "type": "boolean"
+            },
             "status": {
-                "type": "integer"
+                "$ref": "#/definitions/Status"
             },
-            "body": {
+            "activities": {
                 "type": "array",
                 "items": {
-                    "type": "string"
+                    "$ref": "#/definitions/Activity"
                 }
             },
-            "headers": {
-                "$ref": "#/definitions/Record<string,string>"
-            }
-        },
-        "additionalProperties": false,
-        "definitions": {
-            "Record<string,string>": {
-                "type": "object",
-                "additionalProperties": false
-            }
-        },
-        "$schema": "http://json-schema.org/draft-07/schema#"
-    },
-    "GatewayBotResponse": {
-        "type": "object",
-        "properties": {
-            "url": {
-                "type": "string"
-            },
-            "shards": {
+            "since": {
                 "type": "integer"
-            },
-            "session_start_limit": {
-                "type": "object",
-                "properties": {
-                    "total": {
-                        "type": "integer"
-                    },
-                    "remaining": {
-                        "type": "integer"
-                    },
-                    "reset_after": {
-                        "type": "integer"
-                    },
-                    "max_concurrency": {
-                        "type": "integer"
-                    }
-                },
-                "additionalProperties": false,
-                "required": [
-                    "max_concurrency",
-                    "remaining",
-                    "reset_after",
-                    "total"
-                ]
             }
         },
         "additionalProperties": false,
         "required": [
-            "session_start_limit",
-            "shards",
-            "url"
+            "afk",
+            "status"
         ],
-        "$schema": "http://json-schema.org/draft-07/schema#"
-    },
-    "GatewayResponse": {
-        "type": "object",
-        "properties": {
-            "url": {
+        "definitions": {
+            "Status": {
+                "enum": [
+                    "dnd",
+                    "idle",
+                    "invisible",
+                    "offline",
+                    "online"
+                ],
                 "type": "string"
-            }
-        },
-        "additionalProperties": false,
-        "required": [
-            "url"
-        ],
-        "$schema": "http://json-schema.org/draft-07/schema#"
-    },
-    "ChannelReorderSchema": {
-        "type": "array",
-        "items": {
-            "type": "object",
-            "properties": {
-                "id": {
-                    "type": "string"
-                },
-                "position": {
-                    "type": "integer"
-                },
-                "lock_permissions": {
-                    "type": "boolean"
-                },
-                "parent_id": {
-                    "type": "string"
-                }
-            },
-            "additionalProperties": false,
-            "required": [
-                "id"
-            ]
-        },
-        "$schema": "http://json-schema.org/draft-07/schema#"
-    },
-    "RolePositionUpdateSchema": {
-        "type": "array",
-        "items": {
-            "type": "object",
-            "properties": {
-                "id": {
-                    "type": "string"
-                },
-                "position": {
-                    "type": "integer"
-                }
             },
-            "additionalProperties": false,
-            "required": [
-                "id",
-                "position"
-            ]
-        },
-        "$schema": "http://json-schema.org/draft-07/schema#"
-    },
-    "UserProfileResponse": {
-        "type": "object",
-        "properties": {
-            "user": {
-                "$ref": "#/definitions/UserPublic"
-            },
-            "connected_accounts": {
-                "$ref": "#/definitions/PublicConnectedAccount"
-            },
-            "premium_guild_since": {
-                "type": "string",
-                "format": "date-time"
-            },
-            "premium_since": {
-                "type": "string",
-                "format": "date-time"
-            }
-        },
-        "additionalProperties": false,
-        "required": [
-            "connected_accounts",
-            "user"
-        ],
-        "definitions": {
-            "UserPublic": {
+            "Activity": {
                 "type": "object",
                 "properties": {
-                    "username": {
+                    "name": {
                         "type": "string"
                     },
-                    "discriminator": {
-                        "type": "string"
+                    "type": {
+                        "$ref": "#/definitions/ActivityType"
                     },
-                    "id": {
+                    "url": {
                         "type": "string"
                     },
-                    "public_flags": {
+                    "created_at": {
                         "type": "integer"
                     },
-                    "avatar": {
-                        "type": "string"
+                    "timestamps": {
+                        "type": "object",
+                        "properties": {
+                            "start": {
+                                "type": "integer"
+                            },
+                            "end": {
+                                "type": "integer"
+                            }
+                        },
+                        "additionalProperties": false,
+                        "required": [
+                            "end",
+                            "start"
+                        ]
                     },
-                    "accent_color": {
-                        "type": "integer"
+                    "application_id": {
+                        "type": "string"
                     },
-                    "banner": {
+                    "details": {
                         "type": "string"
                     },
-                    "bio": {
+                    "state": {
                         "type": "string"
                     },
-                    "bot": {
-                        "type": "boolean"
+                    "emoji": {
+                        "type": "object",
+                        "properties": {
+                            "name": {
+                                "type": "string"
+                            },
+                            "id": {
+                                "type": "string"
+                            },
+                            "animated": {
+                                "type": "boolean"
+                            }
+                        },
+                        "additionalProperties": false,
+                        "required": [
+                            "animated",
+                            "name"
+                        ]
                     },
-                    "premium_since": {
-                        "type": "string",
-                        "format": "date-time"
-                    }
-                },
-                "additionalProperties": false,
-                "required": [
-                    "bio",
-                    "bot",
-                    "discriminator",
-                    "id",
-                    "premium_since",
-                    "public_flags",
-                    "username"
-                ]
-            },
-            "PublicConnectedAccount": {
-                "type": "object",
-                "properties": {
-                    "name": {
-                        "type": "string"
+                    "party": {
+                        "type": "object",
+                        "properties": {
+                            "id": {
+                                "type": "string"
+                            },
+                            "size": {
+                                "type": "array",
+                                "items": [
+                                    {
+                                        "type": "integer"
+                                    }
+                                ],
+                                "minItems": 1,
+                                "maxItems": 1
+                            }
+                        },
+                        "additionalProperties": false
                     },
-                    "type": {
-                        "type": "string"
+                    "assets": {
+                        "type": "object",
+                        "properties": {
+                            "large_image": {
+                                "type": "string"
+                            },
+                            "large_text": {
+                                "type": "string"
+                            },
+                            "small_image": {
+                                "type": "string"
+                            },
+                            "small_text": {
+                                "type": "string"
+                            }
+                        },
+                        "additionalProperties": false
+                    },
+                    "secrets": {
+                        "type": "object",
+                        "properties": {
+                            "join": {
+                                "type": "string"
+                            },
+                            "spectate": {
+                                "type": "string"
+                            },
+                            "match": {
+                                "type": "string"
+                            }
+                        },
+                        "additionalProperties": false
                     },
-                    "verified": {
+                    "instance": {
                         "type": "boolean"
+                    },
+                    "flags": {
+                        "type": "string"
                     }
                 },
                 "additionalProperties": false,
                 "required": [
+                    "flags",
                     "name",
-                    "type",
-                    "verified"
+                    "type"
                 ]
+            },
+            "ActivityType": {
+                "enum": [
+                    0,
+                    1,
+                    2,
+                    4,
+                    5
+                ],
+                "type": "number"
             }
         },
         "$schema": "http://json-schema.org/draft-07/schema#"
-    },
-    "UserRelationsResponse": {
-        "type": "object",
-        "properties": {
-            "object": {
-                "type": "object",
-                "properties": {
-                    "id": {
-                        "type": "string"
-                    },
-                    "username": {
-                        "type": "string"
-                    },
-                    "avatar": {
-                        "type": "string"
-                    },
-                    "discriminator": {
-                        "type": "string"
-                    },
-                    "public_flags": {
-                        "type": "integer"
-                    }
-                },
-                "additionalProperties": false
-            }
-        },
-        "additionalProperties": false,
-        "required": [
-            "object"
-        ],
-        "$schema": "http://json-schema.org/draft-07/schema#"
     }
 }
\ No newline at end of file
diff --git a/api/scripts/generate_schema.js b/api/scripts/generate_schema.js
index 7a498ad6..1badfd32 100644
--- a/api/scripts/generate_schema.js
+++ b/api/scripts/generate_schema.js
@@ -48,9 +48,8 @@ function modify(obj) {
 }
 
 function main() {
-	const files = 		[
-		...walk(path.join(__dirname, "..", "src", "routes")),
-		...walk(path.join(__dirname, "..", "..", "util", "src")),
+	const files = [
+		...walk(path.join(__dirname, "..", "..", "util", "src", "schemas")),
 	];
 	const program = TJS.getProgramFromFiles(
 		files,
diff --git a/api/src/routes/guilds/#guild_id/channels.ts b/api/src/routes/guilds/#guild_id/channels.ts
index df1b7924..8f2d3643 100644
--- a/api/src/routes/guilds/#guild_id/channels.ts
+++ b/api/src/routes/guilds/#guild_id/channels.ts
@@ -1,5 +1,5 @@
 import { Router, Response, Request } from "express";
-import { Channel, ChannelUpdateEvent, getPermission, emitEvent, ChannelModifySchema } from "@fosscord/util";
+import { Channel, ChannelUpdateEvent, getPermission, emitEvent, ChannelModifySchema, ChannelReorderSchema } from "@fosscord/util";
 import { HTTPError } from "@fosscord/util";
 import { route } from "@fosscord/api";
 const router = Router();
@@ -21,8 +21,6 @@ router.post("/", route({ body: "ChannelModifySchema", permission: "MANAGE_CHANNE
 	res.status(201).json(channel);
 });
 
-export type ChannelReorderSchema = { id: string; position?: number; lock_permissions?: boolean; parent_id?: string }[];
-
 router.patch("/", route({ body: "ChannelReorderSchema", permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => {
 	// changes guild channel position
 	const { guild_id } = req.params;
diff --git a/api/src/routes/guilds/#guild_id/roles/index.ts b/api/src/routes/guilds/#guild_id/roles/index.ts
index effa4fcd..17f0b5e9 100644
--- a/api/src/routes/guilds/#guild_id/roles/index.ts
+++ b/api/src/routes/guilds/#guild_id/roles/index.ts
@@ -10,7 +10,8 @@ import {
 	Config,
 	DiscordApiErrors,
 	handleFile,
-	RoleModifySchema
+	RoleModifySchema,
+	RolePositionUpdateSchema
 } from "@fosscord/util";
 import { HTTPError } from "@fosscord/util";
 import { route } from "@fosscord/api";
@@ -18,11 +19,6 @@ import { OrmUtils } from "@fosscord/util";
 
 const router: Router = Router();
 
-export type RolePositionUpdateSchema = {
-	id: string;
-	position: number;
-}[];
-
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const guild_id = req.params.guild_id;
 
diff --git a/util/src/schemas/ChannelReorderSchema.ts b/util/src/schemas/ChannelReorderSchema.ts
new file mode 100644
index 00000000..3715f59e
--- /dev/null
+++ b/util/src/schemas/ChannelReorderSchema.ts
@@ -0,0 +1 @@
+export type ChannelReorderSchema = { id: string; position?: number; lock_permissions?: boolean; parent_id?: string }[];
\ No newline at end of file
diff --git a/util/src/schemas/RolePositionUpdateSchema.ts b/util/src/schemas/RolePositionUpdateSchema.ts
new file mode 100644
index 00000000..1019d504
--- /dev/null
+++ b/util/src/schemas/RolePositionUpdateSchema.ts
@@ -0,0 +1,4 @@
+export type RolePositionUpdateSchema = {
+	id: string;
+	position: number;
+}[];
\ No newline at end of file
diff --git a/util/src/schemas/index.ts b/util/src/schemas/index.ts
index f54ae840..a15ab4b0 100644
--- a/util/src/schemas/index.ts
+++ b/util/src/schemas/index.ts
@@ -5,6 +5,7 @@ export * from "./BanRegistrySchema";
 export * from "./BulkDeleteSchema";
 export * from "./ChannelModifySchema";
 export * from "./ChannelPermissionOverwriteSchema";
+export * from "./ChannelReorderSchema";
 export * from "./DmChannelCreateSchema";
 export * from "./EmojiCreateSchema";
 export * from "./EmojiModifySchema";
@@ -28,6 +29,7 @@ export * from "./RegisterSchema";
 export * from "./RelationshipPostSchema";
 export * from "./RelationshipPutSchema";
 export * from "./RoleModifySchema";
+export * from "./RolePositionUpdateSchema";
 export * from "./TemplateCreateSchema";
 export * from "./TemplateModifySchema";
 export * from "./TotpDisableSchema";