diff --git a/assets/openapi.json b/assets/openapi.json
index 974780bf..23da8478 100644
--- a/assets/openapi.json
+++ b/assets/openapi.json
@@ -3820,6 +3820,54 @@
"version"
]
},
+ "ReportingMenuResponse": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "variant": {
+ "type": "string"
+ },
+ "postback_url": {
+ "type": "string"
+ },
+ "language": {
+ "type": "string"
+ },
+ "root_node_id": {
+ "type": "integer"
+ },
+ "success_node_id": {
+ "type": "integer"
+ },
+ "fail_node_id": {
+ "type": "integer"
+ },
+ "nodes": {
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[0-9]+$": {
+ "$ref": "#/components/schemas/ReportNode"
+ }
+ }
+ }
+ },
+ "required": [
+ "fail_node_id",
+ "name",
+ "nodes",
+ "postback_url",
+ "root_node_id",
+ "success_node_id",
+ "variant",
+ "version"
+ ]
+ },
"IdentifySchema": {
"type": "object",
"properties": {
@@ -14558,6 +14606,132 @@
"src"
]
},
+ "ReportNode": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "report_type": {
+ "type": "string"
+ },
+ "key": {
+ "type": "string"
+ },
+ "header": {
+ "type": "string"
+ },
+ "subheader": {
+ "type": "string"
+ },
+ "info": {
+ "type": "string"
+ },
+ "children": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ReportNodeChild"
+ }
+ },
+ "elements": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ReportElement"
+ }
+ },
+ "button": {
+ "$ref": "#/components/schemas/ReportButton"
+ },
+ "is_multi_select_required": {
+ "type": "boolean"
+ },
+ "is_auto_submit": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "children",
+ "elements",
+ "header",
+ "id",
+ "is_auto_submit",
+ "is_multi_select_required",
+ "key"
+ ]
+ },
+ "ReportNodeChild": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "target_node_id": {
+ "type": "integer"
+ }
+ },
+ "required": [
+ "name",
+ "target_node_id"
+ ]
+ },
+ "ReportElement": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "data": {
+ "type": "object",
+ "properties": {},
+ "additionalProperties": true
+ },
+ "should_submit_data": {
+ "type": "boolean"
+ },
+ "skip_if_unlocalized": {
+ "type": "boolean"
+ },
+ "is_localized": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "data",
+ "is_localized",
+ "name",
+ "should_submit_data",
+ "skip_if_unlocalized",
+ "type"
+ ]
+ },
+ "ReportButton": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "$ref": "#/components/schemas/ReportButtonType"
+ },
+ "target": {
+ "type": "integer",
+ "nullable": true
+ }
+ },
+ "required": [
+ "target",
+ "type"
+ ]
+ },
+ "ReportButtonType": {
+ "type": "string",
+ "enum": [
+ "submit",
+ "done",
+ "cancel",
+ "next"
+ ]
+ },
"DmChannelDTO": {
"type": "object",
"properties": {
@@ -18515,7 +18689,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/Array<ReportMenuTypeNames>"
+ "$ref": "#/components/schemas/ReportMenuTypeNames"
}
}
}
diff --git a/assets/schemas.json b/assets/schemas.json
index 14235013..97ea6b1b 100644
--- a/assets/schemas.json
+++ b/assets/schemas.json
@@ -4069,6 +4069,56 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
+ "ReportingMenuResponse": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "variant": {
+ "type": "string"
+ },
+ "postback_url": {
+ "type": "string"
+ },
+ "language": {
+ "type": "string"
+ },
+ "root_node_id": {
+ "type": "integer"
+ },
+ "success_node_id": {
+ "type": "integer"
+ },
+ "fail_node_id": {
+ "type": "integer"
+ },
+ "nodes": {
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[0-9]+$": {
+ "$ref": "#/definitions/ReportNode"
+ }
+ }
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "fail_node_id",
+ "name",
+ "nodes",
+ "postback_url",
+ "root_node_id",
+ "success_node_id",
+ "variant",
+ "version"
+ ],
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
"IdentifySchema": {
"type": "object",
"properties": {
@@ -15497,6 +15547,143 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
+ "ReportNode": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "report_type": {
+ "type": "string"
+ },
+ "key": {
+ "type": "string"
+ },
+ "header": {
+ "type": "string"
+ },
+ "subheader": {
+ "type": "string"
+ },
+ "info": {
+ "type": "string"
+ },
+ "children": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ReportNodeChild"
+ }
+ },
+ "elements": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ReportElement"
+ }
+ },
+ "button": {
+ "$ref": "#/definitions/ReportButton"
+ },
+ "is_multi_select_required": {
+ "type": "boolean"
+ },
+ "is_auto_submit": {
+ "type": "boolean"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "children",
+ "elements",
+ "header",
+ "id",
+ "is_auto_submit",
+ "is_multi_select_required",
+ "key"
+ ],
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
+ "ReportNodeChild": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "target_node_id": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "name",
+ "target_node_id"
+ ],
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
+ "ReportElement": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "data": {
+ "type": "object",
+ "properties": {},
+ "additionalProperties": true
+ },
+ "should_submit_data": {
+ "type": "boolean"
+ },
+ "skip_if_unlocalized": {
+ "type": "boolean"
+ },
+ "is_localized": {
+ "type": "boolean"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "data",
+ "is_localized",
+ "name",
+ "should_submit_data",
+ "skip_if_unlocalized",
+ "type"
+ ],
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
+ "ReportButton": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "$ref": "#/definitions/ReportButtonType"
+ },
+ "target": {
+ "type": [
+ "null",
+ "integer"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "target",
+ "type"
+ ],
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
+ "ReportButtonType": {
+ "type": "string",
+ "enum": [
+ "submit",
+ "done",
+ "cancel",
+ "next"
+ ],
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
"DmChannelDTO": {
"type": "object",
"properties": {
diff --git a/src/api/routes/reporting/index.ts b/src/api/routes/reporting/index.ts
index 0b23cafd..28f95053 100644
--- a/src/api/routes/reporting/index.ts
+++ b/src/api/routes/reporting/index.ts
@@ -21,7 +21,7 @@ import path from "node:path";
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server/HTTPError";
import { route } from "@spacebar/api/middlewares";
-import { ReportMenuType, ReportMenuTypeNames, CreateReportSchema } from "@spacebar/schemas";
+import { ReportMenuTypeNames, ReportMenuType, type CreateReportSchema, ReportMenuTypeNameArray } from "@spacebar/schemas";
import { FieldErrors } from "@spacebar/util";
const router = Router({ mergeParams: true });
@@ -32,7 +32,7 @@ router.get(
description: "[EXT] Get available reporting menu types.",
responses: {
200: {
- body: "Array<ReportMenuTypeNames>",
+ body: "ReportMenuTypeNames",
},
},
}),
@@ -161,9 +161,7 @@ for (const type of Object.values(ReportMenuTypeNames)) {
);
};
- const t = Number(Object.entries(ReportMenuTypeNames).find((x) => x[1] === type)?.[0]) as ReportMenuType;
- // TODO: did i miss anything?
- switch (t) {
+ switch (type) {
case ReportMenuType.GUILD:
case ReportMenuType.GUILD_DISCOVERY:
requireFields(body, ["guild_id"]);
diff --git a/src/api/routes/webhooks/#webhook_id/#webhook_token/index.ts b/src/api/routes/webhooks/#webhook_id/#webhook_token/index.ts
index 3c2891f2..4cdd645d 100644
--- a/src/api/routes/webhooks/#webhook_id/#webhook_token/index.ts
+++ b/src/api/routes/webhooks/#webhook_id/#webhook_token/index.ts
@@ -23,7 +23,7 @@ import { route } from "@spacebar/api/middlewares";
import { Webhook, Message } from "@spacebar/database";
import { Config, DiscordApiErrors, emitEvent, handleFile, ValidateName, WebhooksUpdateEvent } from "@spacebar/util";
import { executeWebhook } from "@spacebar/api/util/handlers/Webhook";
-import { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
+import type { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
const router = Router({ mergeParams: true });
diff --git a/src/api/routes/webhooks/#webhook_id/index.ts b/src/api/routes/webhooks/#webhook_id/index.ts
index 5d402be3..5f8b5728 100644
--- a/src/api/routes/webhooks/#webhook_id/index.ts
+++ b/src/api/routes/webhooks/#webhook_id/index.ts
@@ -22,7 +22,7 @@ import { In } from "typeorm";
import { route } from "@spacebar/api/middlewares";
import { Webhook, Channel, Message } from "@spacebar/database";
import { Config, DiscordApiErrors, getPermission, WebhooksUpdateEvent, emitEvent, handleFile, ValidateName, MessageDeleteBulkEvent } from "@spacebar/util";
-import { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
+import type { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
const router = Router({ mergeParams: true });
diff --git a/src/schemas/api/reports/ReportMenu.ts b/src/schemas/api/reports/ReportMenu.ts
index 0a8f0972..3c47e194 100644
--- a/src/schemas/api/reports/ReportMenu.ts
+++ b/src/schemas/api/reports/ReportMenu.ts
@@ -17,18 +17,19 @@
*/
export enum ReportMenuType {
- GUILD,
- GUILD_DISCOVERY,
- GUILD_DIRECTORY_ENTRY,
- GUILD_SCHEDULED_EVENT,
- MESSAGE,
- STAGE_CHANNEL,
- FIRST_DM,
- USER,
- APPLICATION,
- WIDGET,
+ GUILD = "guild",
+ GUILD_DISCOVERY = "guild_discovery",
+ GUILD_DIRECTORY_ENTRY = "guild_directory_entry",
+ GUILD_SCHEDULED_EVENT = "guild_scheduled_event",
+ MESSAGE = "message",
+ STAGE_CHANNEL = "stage_channel",
+ FIRST_DM = "first_dm",
+ USER = "user",
+ APPLICATION = "application",
+ WIDGET = "widget",
}
+export type ReportMenuTypeNameArray = ReportMenuType[];
export const ReportMenuTypeNames: Record<ReportMenuType, string> = {
[ReportMenuType.GUILD]: "guild",
[ReportMenuType.GUILD_DISCOVERY]: "guild_discovery",
@@ -48,3 +49,48 @@ export enum ReportButtonType {
CANCEL = "cancel",
NEXT = "next",
}
+
+export interface ReportingMenuResponse {
+ name: string;
+ version: string;
+ variant: string;
+ postback_url: string;
+ language?: string;
+ root_node_id: number;
+ success_node_id: number;
+ fail_node_id: number;
+ nodes: Record<number, ReportNode>;
+}
+
+export interface ReportNode {
+ id: number;
+ report_type?: string;
+ key: string;
+ header: string;
+ subheader?: string;
+ info?: string;
+ children: ReportNodeChild[];
+ elements: ReportElement[];
+ button?: ReportButton;
+ is_multi_select_required: boolean;
+ is_auto_submit: boolean;
+}
+
+export interface ReportButton {
+ type: ReportButtonType;
+ target: number | null;
+}
+
+export interface ReportNodeChild {
+ name: string;
+ target_node_id: number;
+}
+
+export interface ReportElement {
+ name: string;
+ type: string;
+ data: object;
+ should_submit_data: boolean;
+ skip_if_unlocalized: boolean;
+ is_localized: boolean;
+}
|