diff --git a/OpenAPI.json b/OpenAPI.json index aebe171..73d176f 100644 --- a/OpenAPI.json +++ b/OpenAPI.json @@ -36,6 +36,30 @@ { "name": "Relationships", "description": "Manage your friendships and block list on the platform" + }, + { + "name": "Channel Information", + "description": "Query and fetch channels on Revolt" + }, + { + "name": "Channel Invites", + "description": "Create and manage invites for channels" + }, + { + "name": "Channel Permissions", + "description": "Manage permissions for channels" + }, + { + "name": "Messaging", + "description": "Send and manipulate messages" + }, + { + "name": "Groups", + "description": "Create, invite users and manipulate groups" + }, + { + "name": "Voice", + "description": "Join and talk with other users" } ], "x-tagGroups": [ @@ -53,6 +77,17 @@ "Direct Messaging", "Relationships" ] + }, + { + "name": "Channels", + "tags": [ + "Channel Information", + "Channel Invites", + "Channel Permissions", + "Messaging", + "Groups", + "Voice" + ] } ], "paths": { @@ -224,16 +259,16 @@ }, "background": { "description": "Autumn file ID, [learn more](https://example.com/TODO).", + "minLength": 1, + "maxLength": 128, "type": "string" } - }, - "required": [ - "background", - "content" - ] + } }, "avatar": { "description": "Autumn file ID, [learn more](https://example.com/TODO).", + "minLength": 1, + "maxLength": 128, "type": "string" }, "remove": { @@ -247,12 +282,6 @@ "type": "string" } }, - "required": [ - "avatar", - "profile", - "remove", - "status" - ], "definitions": { "Presence": { "description": "User presence", @@ -909,7 +938,7 @@ ] } }, - "/users/:user/friend": { + "/users/:username/friend": { "put": { "summary": "Send Friend Request / Accept Request", "description": "Send a friend request to another user or accept another user's friend request.", @@ -918,12 +947,12 @@ ], "parameters": [ { - "name": "user", + "name": "username", "in": "path", "required": true, - "description": "User ID", + "description": "Username", "schema": { - "$ref": "#/definitions/Id" + "$ref": "#/definitions/Username" } } ], @@ -954,12 +983,12 @@ ], "parameters": [ { - "name": "user", + "name": "username", "in": "path", "required": true, - "description": "User ID", + "description": "Username", "schema": { - "$ref": "#/definitions/Id" + "$ref": "#/definitions/Username" } } ], @@ -1056,6 +1085,5657 @@ } ] } + }, + "/channels/:channel": { + "get": { + "summary": "Fetch Channel", + "description": "Retrieve a channel.", + "tags": [ + "Channel Information" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "Retrieved channel.", + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/Channel" + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + }, + "patch": { + "summary": "Edit Channel", + "description": "Edit a channel object.", + "tags": [ + "Channel Information" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Requested changes to channel object.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "description": "Channel name", + "type": "string" + }, + "description": { + "description": "Channel description", + "type": "string" + }, + "icon": { + "description": "Autumn file ID, [learn more](https://example.com/TODO).", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "remove": { + "description": "Field to remove from channel object", + "enum": [ + "Description", + "Icon" + ], + "type": "string" + } + }, + "required": [ + "name" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Succesfully changed channel object." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + }, + "delete": { + "summary": "Close Channel", + "description": "Deletes a server channel, leaves a group or closes a DM.", + "tags": [ + "Channel Information" + ], + "responses": { + "200": { + "description": "Deleted Channel" + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/invites": { + "post": { + "summary": "Create Invite", + "description": "Creates an invite to this channel.\n\nChannel must be a `TextChannel`.", + "tags": [ + "Channel Invites" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "Invite", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "description": "Invite Code", + "type": "string" + } + }, + "required": [ + "code" + ] + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/permissions/:role": { + "put": { + "summary": "Set Role Permission", + "description": "Sets permissions for the specified role in this channel.\n\nChannel must be a `TextChannel` or `VoiceChannel`.", + "tags": [ + "Channel Permissions" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "role", + "in": "path", + "required": true, + "description": "Role ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Channel Permissions", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "permissions": { + "type": "number" + } + }, + "required": [ + "permissions" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Successfully updated permissions." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/permissions/default": { + "put": { + "summary": "Set Default Permission", + "description": "Sets permissions for the default role in this channel.\n\nChannel must be a `Group`, `TextChannel` or `VoiceChannel`.", + "tags": [ + "Channel Permissions" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Channel Permissions", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "permissions": { + "type": "number" + } + }, + "required": [ + "permissions" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Successfully updated permissions." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/messages": { + "post": { + "summary": "Send Message", + "description": "Sends a message to the given channel.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Message to be sent.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "content": { + "description": "Message content to send.", + "minLength": 0, + "maxLength": 2000, + "type": "string" + }, + "nonce": { + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", + "minLength": 1, + "maxLength": 36, + "type": "string" + }, + "attachments": { + "description": "Attachments to include in message.", + "type": "array", + "items": { + "type": "string" + } + }, + "replies": { + "description": "Messages to reply to.", + "type": "object", + "properties": { + "id": { + "description": "Message Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "mention": { + "description": "Whether this reply should mention the message's author.", + "type": "boolean" + } + }, + "required": [ + "id", + "mention" + ] + } + }, + "required": [ + "content", + "nonce" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Sent message.", + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/Message" + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + }, + "get": { + "summary": "Fetch Messages", + "description": "Fetches multiple messages.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Fetch Options", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "limit": { + "description": "Maximum number of messages to fetch.\n\nFor fetching nearby messages, this is `(limit + 1)`.", + "minimum": 1, + "maximum": 100, + "type": "number" + }, + "before": { + "description": "Message id before which messages should be fetched.", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "after": { + "description": "Message id after which messages should be fetched.", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "sort": { + "description": "Message sort direction", + "enum": [ + "Latest", + "Oldest" + ], + "type": "string" + }, + "nearby": { + "description": "Message id to fetch around, this will ignore 'before', 'after' and 'sort' options.\nLimits in each direction will be half of the specified limit.\nIt also fetches the specified message ID.", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "include_users": { + "description": "Whether to include user (and member, if server channel) objects.", + "type": "boolean" + } + }, + "required": [ + "sort" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Message array or object with requested data.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Message Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "nonce": { + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", + "minLength": 1, + "maxLength": 36, + "type": "string" + }, + "channel": { + "description": "Channel Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "author": { + "description": "Author Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "content": { + "description": "Message content, can be an object *only* if sent by the system user.", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "text" + ] + }, + "content": { + "type": "string" + } + }, + "required": [ + "content", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_added" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_remove" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_joined" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_left" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_kicked" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_banned" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_renamed" + ] + }, + "name": { + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "name", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_description_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_icon_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "string" + } + ] + }, + "attachments": { + "description": "Message attachments", + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + } + }, + "edited": { + "description": "Unix timestamp of when message was last edited", + "type": "object", + "properties": { + "$date": { + "type": "string" + } + }, + "required": [ + "$date" + ] + }, + "embeds": { + "description": "Message link embeds", + "type": "array", + "items": { + "description": "Message embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Website" + ] + }, + "url": { + "type": "string" + }, + "special": { + "description": "A special 3rd party embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "YouTube" + ] + }, + "id": { + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Twitch" + ] + }, + "content_type": { + "enum": [ + "Channel", + "Clip", + "Video" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Spotify" + ] + }, + "content_type": { + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Soundcloud" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Bandcamp" + ] + }, + "content_type": { + "enum": [ + "Album", + "Track" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + } + ] + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "image": { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + }, + "video": { + "description": "An embedded video", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "url", + "width" + ] + }, + "site_name": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "color": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + { + "allOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + } + }, + "required": [ + "type" + ] + }, + { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + } + ] + } + ] + } + }, + "mentions": { + "description": "Array of user IDs mentioned in message", + "type": "array", + "items": { + "type": "string" + } + }, + "replies": { + "description": "Array of message IDs replied to", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "_id", + "author", + "channel", + "content" + ] + } + }, + { + "type": "object", + "properties": { + "messages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Message Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "nonce": { + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", + "minLength": 1, + "maxLength": 36, + "type": "string" + }, + "channel": { + "description": "Channel Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "author": { + "description": "Author Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "content": { + "description": "Message content, can be an object *only* if sent by the system user.", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "text" + ] + }, + "content": { + "type": "string" + } + }, + "required": [ + "content", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_added" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_remove" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_joined" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_left" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_kicked" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_banned" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_renamed" + ] + }, + "name": { + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "name", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_description_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_icon_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "string" + } + ] + }, + "attachments": { + "description": "Message attachments", + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + } + }, + "edited": { + "description": "Unix timestamp of when message was last edited", + "type": "object", + "properties": { + "$date": { + "type": "string" + } + }, + "required": [ + "$date" + ] + }, + "embeds": { + "description": "Message link embeds", + "type": "array", + "items": { + "description": "Message embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Website" + ] + }, + "url": { + "type": "string" + }, + "special": { + "description": "A special 3rd party embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "YouTube" + ] + }, + "id": { + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Twitch" + ] + }, + "content_type": { + "enum": [ + "Channel", + "Clip", + "Video" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Spotify" + ] + }, + "content_type": { + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Soundcloud" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Bandcamp" + ] + }, + "content_type": { + "enum": [ + "Album", + "Track" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + } + ] + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "image": { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + }, + "video": { + "description": "An embedded video", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "url", + "width" + ] + }, + "site_name": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "color": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + { + "allOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + } + }, + "required": [ + "type" + ] + }, + { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + } + ] + } + ] + } + }, + "mentions": { + "description": "Array of user IDs mentioned in message", + "type": "array", + "items": { + "type": "string" + } + }, + "replies": { + "description": "Array of message IDs replied to", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "_id", + "author", + "channel", + "content" + ] + } + }, + "users": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + }, + "members": { + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "type": "object", + "properties": { + "server": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "user": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "server", + "user" + ] + }, + "nickname": { + "type": "string" + }, + "avatar": { + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + }, + "roles": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "_id" + ] + } + } + }, + "required": [ + "messages", + "users" + ] + } + ], + "definitions": { + "AttachmentTag": { + "description": "Attachment tag", + "enum": [ + "attachments", + "avatars", + "backgrounds", + "banners", + "icons" + ], + "type": "string" + }, + "User": { + "type": "object", + "properties": { + "_id": { + "description": "User ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "username": { + "description": "Username", + "minLength": 2, + "maxLength": 32, + "pattern": "^[a-zA-Z0-9_.]+$", + "type": "string" + }, + "avatar": { + "description": "User avatar", + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + }, + "relations": { + "description": "Relationships with other known users\nOnly present if fetching self", + "type": "array", + "items": { + "allOf": [ + { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/RelationshipStatus" + } + }, + "required": [ + "status" + ] + }, + { + "type": "object", + "properties": { + "_id": { + "description": "Other user's ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "_id" + ] + } + ] + } + }, + "badges": { + "description": "Bitfield of user's badges", + "type": "number" + }, + "status": { + "description": "User status", + "type": "object", + "properties": { + "text": { + "description": "Custom status text", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "presence": { + "$ref": "#/definitions/Presence" + } + } + }, + "relationship": { + "description": "Relationship to user", + "allOf": [ + { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/RelationshipStatus" + } + }, + "required": [ + "status" + ] + }, + { + "type": "object", + "properties": { + "_id": { + "description": "Other user's ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "_id" + ] + } + ] + }, + "online": { + "description": "Whether the user is online", + "type": "boolean" + } + }, + "required": [ + "_id", + "username" + ] + }, + "RelationshipStatus": { + "description": "Your relationship with the user", + "enum": [ + "Blocked", + "BlockedOther", + "Friend", + "Incoming", + "None", + "Outgoing", + "User" + ], + "type": "string" + }, + "Presence": { + "description": "User presence", + "enum": [ + "Busy", + "Idle", + "Invisible", + "Online" + ], + "type": "string" + } + } + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/messages/:message": { + "get": { + "summary": "Fetch Message", + "description": "Retrieves a message by ID.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "message", + "in": "path", + "required": true, + "description": "Message ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "Message", + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/Message" + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + }, + "patch": { + "summary": "Edit Message", + "description": "Edits a message that you've previously sent.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "message", + "in": "path", + "required": true, + "description": "Message ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Message edit data.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "content": { + "description": "Message content", + "minLength": 1, + "maxLength": 2000, + "type": "string" + } + }, + "required": [ + "content" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Message was changed." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + }, + "delete": { + "summary": "Delete Message", + "description": "Delete a message you've sent or one you have permission to delete.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "message", + "in": "path", + "required": true, + "description": "Message ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "Message was deleted." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/messages/stale": { + "post": { + "summary": "Poll Message Changes", + "description": "This route returns any changed message objects and tells you if any have been deleted.\n\nDon't actually poll this route, instead use this to update your local database.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Poll Options", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "ids": { + "description": "Array of message IDs.", + "maxItems": 150, + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "ids" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Polled Information", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "changed": { + "description": "Changed message objects.", + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Message Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "nonce": { + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", + "minLength": 1, + "maxLength": 36, + "type": "string" + }, + "channel": { + "description": "Channel Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "author": { + "description": "Author Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "content": { + "description": "Message content, can be an object *only* if sent by the system user.", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "text" + ] + }, + "content": { + "type": "string" + } + }, + "required": [ + "content", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_added" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_remove" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_joined" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_left" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_kicked" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_banned" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_renamed" + ] + }, + "name": { + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "name", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_description_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_icon_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "string" + } + ] + }, + "attachments": { + "description": "Message attachments", + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + } + }, + "edited": { + "description": "Unix timestamp of when message was last edited", + "type": "object", + "properties": { + "$date": { + "type": "string" + } + }, + "required": [ + "$date" + ] + }, + "embeds": { + "description": "Message link embeds", + "type": "array", + "items": { + "description": "Message embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Website" + ] + }, + "url": { + "type": "string" + }, + "special": { + "description": "A special 3rd party embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "YouTube" + ] + }, + "id": { + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Twitch" + ] + }, + "content_type": { + "enum": [ + "Channel", + "Clip", + "Video" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Spotify" + ] + }, + "content_type": { + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Soundcloud" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Bandcamp" + ] + }, + "content_type": { + "enum": [ + "Album", + "Track" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + } + ] + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "image": { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + }, + "video": { + "description": "An embedded video", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "url", + "width" + ] + }, + "site_name": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "color": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + { + "allOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + } + }, + "required": [ + "type" + ] + }, + { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + } + ] + } + ] + } + }, + "mentions": { + "description": "Array of user IDs mentioned in message", + "type": "array", + "items": { + "type": "string" + } + }, + "replies": { + "description": "Array of message IDs replied to", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "_id", + "author", + "channel", + "content" + ] + } + }, + "deleted": { + "description": "Array of deleted message IDs.", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "changed", + "deleted" + ], + "definitions": { + "AttachmentTag": { + "description": "Attachment tag", + "enum": [ + "attachments", + "avatars", + "backgrounds", + "banners", + "icons" + ], + "type": "string" + } + } + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/messages/search": { + "post": { + "summary": "Search for Messages", + "description": "This route searches for messages within the given parameters.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "requestBody": { + "description": "Search Options", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query": { + "description": "Full-text search query.\n\nSee [MongoDB documentation](https://docs.mongodb.com/manual/text-search/#-text-operator) for more information.", + "minLength": 1, + "maxLength": 64, + "type": "string" + }, + "limit": { + "description": "Maximum number of messages to fetch.", + "minimum": 1, + "maximum": 100, + "type": "number" + }, + "before": { + "description": "Message id before which messages should be fetched.", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "after": { + "description": "Message id after which messages should be fetched.", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "sort": { + "description": "Message sort direction", + "enum": [ + "Latest", + "Oldest", + "Relevance" + ], + "type": "string" + }, + "include_users": { + "description": "Whether to include user (and member, if server channel) objects.", + "type": "boolean" + } + }, + "required": [ + "query", + "sort" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Message array or object with requested data.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Message Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "nonce": { + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", + "minLength": 1, + "maxLength": 36, + "type": "string" + }, + "channel": { + "description": "Channel Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "author": { + "description": "Author Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "content": { + "description": "Message content, can be an object *only* if sent by the system user.", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "text" + ] + }, + "content": { + "type": "string" + } + }, + "required": [ + "content", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_added" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_remove" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_joined" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_left" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_kicked" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_banned" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_renamed" + ] + }, + "name": { + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "name", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_description_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_icon_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "string" + } + ] + }, + "attachments": { + "description": "Message attachments", + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + } + }, + "edited": { + "description": "Unix timestamp of when message was last edited", + "type": "object", + "properties": { + "$date": { + "type": "string" + } + }, + "required": [ + "$date" + ] + }, + "embeds": { + "description": "Message link embeds", + "type": "array", + "items": { + "description": "Message embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Website" + ] + }, + "url": { + "type": "string" + }, + "special": { + "description": "A special 3rd party embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "YouTube" + ] + }, + "id": { + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Twitch" + ] + }, + "content_type": { + "enum": [ + "Channel", + "Clip", + "Video" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Spotify" + ] + }, + "content_type": { + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Soundcloud" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Bandcamp" + ] + }, + "content_type": { + "enum": [ + "Album", + "Track" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + } + ] + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "image": { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + }, + "video": { + "description": "An embedded video", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "url", + "width" + ] + }, + "site_name": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "color": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + { + "allOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + } + }, + "required": [ + "type" + ] + }, + { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + } + ] + } + ] + } + }, + "mentions": { + "description": "Array of user IDs mentioned in message", + "type": "array", + "items": { + "type": "string" + } + }, + "replies": { + "description": "Array of message IDs replied to", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "_id", + "author", + "channel", + "content" + ] + } + }, + { + "type": "object", + "properties": { + "messages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Message Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "nonce": { + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", + "minLength": 1, + "maxLength": 36, + "type": "string" + }, + "channel": { + "description": "Channel Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "author": { + "description": "Author Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "content": { + "description": "Message content, can be an object *only* if sent by the system user.", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "text" + ] + }, + "content": { + "type": "string" + } + }, + "required": [ + "content", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_added" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_remove" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_joined" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_left" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_kicked" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "user_banned" + ] + }, + "id": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_renamed" + ] + }, + "name": { + "type": "string" + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "name", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_description_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_icon_changed" + ] + }, + "by": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "by", + "type" + ] + }, + { + "type": "string" + } + ] + }, + "attachments": { + "description": "Message attachments", + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + } + }, + "edited": { + "description": "Unix timestamp of when message was last edited", + "type": "object", + "properties": { + "$date": { + "type": "string" + } + }, + "required": [ + "$date" + ] + }, + "embeds": { + "description": "Message link embeds", + "type": "array", + "items": { + "description": "Message embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Website" + ] + }, + "url": { + "type": "string" + }, + "special": { + "description": "A special 3rd party embed", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "None" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "YouTube" + ] + }, + "id": { + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Twitch" + ] + }, + "content_type": { + "enum": [ + "Channel", + "Clip", + "Video" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Spotify" + ] + }, + "content_type": { + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Soundcloud" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Bandcamp" + ] + }, + "content_type": { + "enum": [ + "Album", + "Track" + ], + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "content_type", + "id", + "type" + ] + } + ] + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "image": { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + }, + "video": { + "description": "An embedded video", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "url", + "width" + ] + }, + "site_name": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "color": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + { + "allOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + } + }, + "required": [ + "type" + ] + }, + { + "description": "An embedded image", + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "size": { + "enum": [ + "Large", + "Preview" + ], + "type": "string" + } + }, + "required": [ + "height", + "size", + "url", + "width" + ] + } + ] + } + ] + } + }, + "mentions": { + "description": "Array of user IDs mentioned in message", + "type": "array", + "items": { + "type": "string" + } + }, + "replies": { + "description": "Array of message IDs replied to", + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "_id", + "author", + "channel", + "content" + ] + } + }, + "users": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + }, + "members": { + "type": "array", + "items": { + "type": "object", + "properties": { + "_id": { + "type": "object", + "properties": { + "server": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "user": { + "description": "Id", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "server", + "user" + ] + }, + "nickname": { + "type": "string" + }, + "avatar": { + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + }, + "roles": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "_id" + ] + } + } + }, + "required": [ + "messages", + "users" + ] + } + ], + "definitions": { + "AttachmentTag": { + "description": "Attachment tag", + "enum": [ + "attachments", + "avatars", + "backgrounds", + "banners", + "icons" + ], + "type": "string" + }, + "User": { + "type": "object", + "properties": { + "_id": { + "description": "User ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "username": { + "description": "Username", + "minLength": 2, + "maxLength": 32, + "pattern": "^[a-zA-Z0-9_.]+$", + "type": "string" + }, + "avatar": { + "description": "User avatar", + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + }, + "relations": { + "description": "Relationships with other known users\nOnly present if fetching self", + "type": "array", + "items": { + "allOf": [ + { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/RelationshipStatus" + } + }, + "required": [ + "status" + ] + }, + { + "type": "object", + "properties": { + "_id": { + "description": "Other user's ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "_id" + ] + } + ] + } + }, + "badges": { + "description": "Bitfield of user's badges", + "type": "number" + }, + "status": { + "description": "User status", + "type": "object", + "properties": { + "text": { + "description": "Custom status text", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "presence": { + "$ref": "#/definitions/Presence" + } + } + }, + "relationship": { + "description": "Relationship to user", + "allOf": [ + { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/RelationshipStatus" + } + }, + "required": [ + "status" + ] + }, + { + "type": "object", + "properties": { + "_id": { + "description": "Other user's ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "_id" + ] + } + ] + }, + "online": { + "description": "Whether the user is online", + "type": "boolean" + } + }, + "required": [ + "_id", + "username" + ] + }, + "RelationshipStatus": { + "description": "Your relationship with the user", + "enum": [ + "Blocked", + "BlockedOther", + "Friend", + "Incoming", + "None", + "Outgoing", + "User" + ], + "type": "string" + }, + "Presence": { + "description": "User presence", + "enum": [ + "Busy", + "Idle", + "Invisible", + "Online" + ], + "type": "string" + } + } + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/ack/:message": { + "put": { + "summary": "Acknowledge Message", + "description": "Lets the server and all other clients know that we've seen this message id in this channel.", + "tags": [ + "Messaging" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "message", + "in": "path", + "required": true, + "description": "Message ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "Acknowledged message." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/create": { + "post": { + "summary": "Create Group", + "description": "Create a new group with friends.", + "tags": [ + "Groups" + ], + "requestBody": { + "description": "Group Data", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "description": "Group name", + "minLength": 1, + "maxLength": 32, + "type": "string" + }, + "description": { + "description": "Group description", + "minLength": 0, + "maxLength": 1024, + "type": "string" + }, + "nonce": { + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", + "minLength": 1, + "maxLength": 36, + "type": "string" + }, + "users": { + "description": "Array of user IDs to add to the group.\n\nMust be friends with them.", + "maxItems": 49, + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "name", + "nonce" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Group", + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/GroupChannel" + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/members": { + "get": { + "summary": "Fetch Group Members", + "description": "Retrieves users who are part of this group.", + "tags": [ + "Groups" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "message", + "in": "path", + "required": true, + "description": "Message ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "Members", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + }, + "definitions": { + "User": { + "type": "object", + "properties": { + "_id": { + "description": "User ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + }, + "username": { + "description": "Username", + "minLength": 2, + "maxLength": 32, + "pattern": "^[a-zA-Z0-9_.]+$", + "type": "string" + }, + "avatar": { + "description": "User avatar", + "type": "object", + "properties": { + "_id": { + "description": "Attachment ID", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "tag": { + "$ref": "#/definitions/AttachmentTag" + }, + "size": { + "description": "File size (in bytes)", + "type": "number" + }, + "filename": { + "description": "File name", + "type": "string" + }, + "metadata": { + "description": "Metadata", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "File" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Text" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Audio" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Image" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Video" + ] + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "required": [ + "height", + "type", + "width" + ] + } + ] + }, + "content_type": { + "description": "Content type", + "type": "string" + } + }, + "required": [ + "_id", + "content_type", + "filename", + "metadata", + "size", + "tag" + ] + }, + "relations": { + "description": "Relationships with other known users\nOnly present if fetching self", + "type": "array", + "items": { + "allOf": [ + { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/RelationshipStatus" + } + }, + "required": [ + "status" + ] + }, + { + "type": "object", + "properties": { + "_id": { + "description": "Other user's ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "_id" + ] + } + ] + } + }, + "badges": { + "description": "Bitfield of user's badges", + "type": "number" + }, + "status": { + "description": "User status", + "type": "object", + "properties": { + "text": { + "description": "Custom status text", + "minLength": 1, + "maxLength": 128, + "type": "string" + }, + "presence": { + "$ref": "#/definitions/Presence" + } + } + }, + "relationship": { + "description": "Relationship to user", + "allOf": [ + { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/RelationshipStatus" + } + }, + "required": [ + "status" + ] + }, + { + "type": "object", + "properties": { + "_id": { + "description": "Other user's ID", + "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", + "type": "string" + } + }, + "required": [ + "_id" + ] + } + ] + }, + "online": { + "description": "Whether the user is online", + "type": "boolean" + } + }, + "required": [ + "_id", + "username" + ] + }, + "AttachmentTag": { + "description": "Attachment tag", + "enum": [ + "attachments", + "avatars", + "backgrounds", + "banners", + "icons" + ], + "type": "string" + }, + "RelationshipStatus": { + "description": "Your relationship with the user", + "enum": [ + "Blocked", + "BlockedOther", + "Friend", + "Incoming", + "None", + "Outgoing", + "User" + ], + "type": "string" + }, + "Presence": { + "description": "User presence", + "enum": [ + "Busy", + "Idle", + "Invisible", + "Online" + ], + "type": "string" + } + } + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + }, + "put": { + "summary": "Add Group Member", + "description": "Adds another user to the group.", + "tags": [ + "Groups" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "message", + "in": "path", + "required": true, + "description": "Message ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "User was added to the group." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + }, + "delete": { + "summary": "Remove Group Member", + "description": "Removes a user from the group.", + "tags": [ + "Groups" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + }, + { + "name": "message", + "in": "path", + "required": true, + "description": "Message ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "User was removed from the group." + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } + }, + "/channels/:channel/join_call": { + "post": { + "summary": "Join Call", + "description": "Asks the voice server for a token to join the call.", + "tags": [ + "Voice" + ], + "parameters": [ + { + "name": "channel", + "in": "path", + "required": true, + "description": "Channel ID", + "schema": { + "$ref": "#/definitions/Id" + } + } + ], + "responses": { + "200": { + "description": "Join Data", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "token": { + "description": "Voso Token", + "type": "string" + } + }, + "required": [ + "token" + ] + } + } + } + } + }, + "security": [ + { + "userId": [], + "sessionToken": [] + } + ] + } } }, "definitions": { @@ -3036,7 +8716,7 @@ "type": "string" }, "nonce": { - "description": "Nonce value, prefer to use ULIDs here for better feature support.", + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", "minLength": 1, "maxLength": 36, "type": "string" @@ -6052,6 +11732,26 @@ } } }, + "Username": { + "description": "Username", + "minLength": 2, + "maxLength": 32, + "pattern": "^[a-zA-Z0-9_.]+$", + "type": "string", + "definitions": { + "AttachmentTag": { + "description": "Attachment tag", + "enum": [ + "attachments", + "avatars", + "backgrounds", + "banners", + "icons" + ], + "type": "string" + } + } + }, "RelationshipStatus": { "description": "Your relationship with the user", "enum": [ @@ -6743,36 +12443,17 @@ } } }, - "FetchRelationships": { - "type": "array", - "items": { - "allOf": [ - { - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/RelationshipStatus" - } - }, - "required": [ - "status" - ] - }, - { - "type": "object", - "properties": { - "_id": { - "description": "Other user's ID", - "pattern": "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}", - "type": "string" - } - }, - "required": [ - "_id" - ] - } - ] + "JoinData": { + "type": "object", + "properties": { + "token": { + "description": "Voso Token", + "type": "string" + } }, + "required": [ + "token" + ], "definitions": { "AttachmentTag": { "description": "Attachment tag", @@ -6852,7 +12533,7 @@ } }, "Nonce": { - "description": "Nonce value, prefer to use ULIDs here for better feature support.", + "description": "Nonce value, prefer to use ULIDs here for better feature support.\n\nUsed to prevent double requests to create objects.", "minLength": 1, "maxLength": 36, "type": "string", @@ -6895,6 +12576,8 @@ }, "AutumnId": { "description": "Autumn file ID, [learn more](https://example.com/TODO).", + "minLength": 1, + "maxLength": 128, "type": "string", "definitions": { "AttachmentTag": { diff --git a/src/openapi/paths.ts b/src/openapi/paths.ts index 28fa534..cfca7ed 100644 --- a/src/openapi/paths.ts +++ b/src/openapi/paths.ts @@ -37,6 +37,7 @@ export function tag(name: string, description: string) { export function resource(path: string, methods: OpenAPIV3.PathItemObject) { console.info(`Generating resource ${path}.`); + if (resources[path]) throw `Resource ${path} already exists!`; resources[path] = methods; } diff --git a/src/routes/channels.ts b/src/routes/channels.ts new file mode 100644 index 0000000..064d9de --- /dev/null +++ b/src/routes/channels.ts @@ -0,0 +1,487 @@ +import { body, parameter, ref, success } from "../openapi/generators.js"; +import { group, resource, routeAuthenticated, tag } from "../openapi/paths.js"; +import { schema } from "../typescript.js"; + +group("Channels"); + +//#region Channel Information +tag("Channel Information", "Query and fetch channels on Revolt"); + +const channelParams = { + parameters: [ + await parameter('channel', 'Channel ID', ref("Id")) + ] +} + +resource('/channels/:channel', { + get: routeAuthenticated( + "Fetch Channel", + "Retrieve a channel.", + { + ...channelParams, + ...await success( + "Retrieved channel.", + ref("Channel") + ) + } + ), + patch: routeAuthenticated( + "Edit Channel", + "Edit a channel object.", + { + ...channelParams, + ...await body("Requested changes to channel object.", schema` + import type { Status } from './Users'; + import type { AutumnId } from './_common'; + + interface ${'EditChannels'} { + /** + * Channel name + **/ + name: string; + + /** + * Channel description + **/ + description?: string; + + icon?: AutumnId; + + /** + * Field to remove from channel object + */ + remove?: 'Icon' | 'Description'; + } + `), + ...await success("Succesfully changed channel object.") + } + ), + delete: routeAuthenticated( + "Close Channel", + "Deletes a server channel, leaves a group or closes a DM.", + await success("Deleted Channel") + ) +}); +//#endregion + +//#region Channel Invites +tag("Channel Invites", "Create and manage invites for channels"); + +resource('/channels/:channel/invites', { + post: routeAuthenticated( + "Create Invite", + "Creates an invite to this channel.\n\nChannel must be a `TextChannel`.", + { + ...channelParams, + ...await success("Invite", schema` + interface ${'InviteCode'} { + /** + * Invite Code + */ + code: string; + } + `) + } + ) +}); +//#endregion + +//#region Channel Permissions +tag("Channel Permissions", "Manage permissions for channels"); + +const roleParams = { + parameters: [ + await parameter('channel', 'Channel ID', ref("Id")), + await parameter('role', 'Role ID', ref("Id")) + ] +} + +const channelPermissions = await body("Channel Permissions", schema` + interface ${'ChannelPermissions'} { + permissions: number + } +`) + +resource('/channels/:channel/permissions/:role', { + put: routeAuthenticated( + "Set Role Permission", + "Sets permissions for the specified role in this channel.\n\nChannel must be a `TextChannel` or `VoiceChannel`.", + { + ...roleParams, + ...channelPermissions, + ...await success("Successfully updated permissions.") + } + ) +}); + +resource('/channels/:channel/permissions/default', { + put: routeAuthenticated( + "Set Default Permission", + "Sets permissions for the default role in this channel.\n\nChannel must be a `Group`, `TextChannel` or `VoiceChannel`.", + { + ...channelParams, + ...channelPermissions, + ...await success("Successfully updated permissions.") + } + ) +}); +//#endregion + +//#region Messaging +tag("Messaging", "Send and manipulate messages"); + +const messageParams = { + parameters: [ + await parameter('channel', 'Channel ID', ref("Id")), + await parameter('message', 'Message ID', ref("Id")) + ] +} + +const retrievedMessages = await success("Message array or object with requested data.", schema` + import { Message } from './Channels'; + import { User } from './Users'; + import { Member } from './Servers'; + + type ${'RetrievedMessages'} = Message[] | { + messages: Message[], + users: User[], + members?: Member[] + } +`); + +resource('/channels/:channel/messages', { + post: routeAuthenticated( + "Send Message", + "Sends a message to the given channel.", + { + ...channelParams, + ...await body("Message to be sent.", schema` + import type { Id, Nonce, AutumnId } from './_common'; + + interface ${'SendMessage'} { + /** + * Message content to send. + * @minLength 0 + * @maxLength 2000 + */ + content: string; + + nonce: Nonce; + + /** + * Attachments to include in message. + */ + attachments?: AutumnId[]; + + /** + * Messages to reply to. + */ + replies?: { + /** + * Message Id + */ + id: Id; + + /** + * Whether this reply should mention the message's author. + */ + mention: boolean; + } + } + `), + ...await success( + "Sent message.", + ref("Message") + ) + } + ), + get: routeAuthenticated( + "Fetch Messages", + "Fetches multiple messages.", + { + ...channelParams, + ...await body("Fetch Options", schema` + import { Id } from './_common'; + + interface ${'FetchOptions'} { + /** + * Maximum number of messages to fetch. + * + * For fetching nearby messages, this is \`(limit + 1)\`. + * + * @minimum 1 + * @maximum 100 + */ + limit?: number; + + /** + * Message id before which messages should be fetched. + */ + before?: Id; + + /** + * Message id after which messages should be fetched. + */ + after?: Id; + + /** + * Message sort direction + */ + sort: 'Latest' | 'Oldest'; + + /** + * Message id to fetch around, this will ignore 'before', 'after' and 'sort' options. + * Limits in each direction will be half of the specified limit. + * It also fetches the specified message ID. + */ + nearby?: Id; + + /** + * Whether to include user (and member, if server channel) objects. + */ + include_users?: boolean; + } + `), + ...retrievedMessages + } + ) +}); + +resource('/channels/:channel/messages/:message', { + get: routeAuthenticated( + "Fetch Message", + "Retrieves a message by ID.", + { + ...messageParams, + ...await success( + "Message", + ref("Message") + ) + } + ), + patch: routeAuthenticated( + "Edit Message", + "Edits a message that you've previously sent.", + { + ...messageParams, + ...await body("Message edit data.", schema` + interface ${'MessageEdit'} { + /** + * Message content + * @minLength 1 + * @maxLength 2000 + */ + content: string; + } + `), + ...await success("Message was changed.") + } + ), + delete: routeAuthenticated( + "Delete Message", + "Delete a message you've sent or one you have permission to delete.", + { + ...messageParams, + ...await success("Message was deleted.") + } + ) +}); + +resource('/channels/:channel/messages/stale', { + post: routeAuthenticated( + "Poll Message Changes", + "This route returns any changed message objects and tells you if any have been deleted.\n\nDon't actually poll this route, instead use this to update your local database.", + { + ...channelParams, + ...await body("Poll Options", schema` + import { Id } from './_common'; + + interface ${'PollOptions'} { + /** + * Array of message IDs. + * + * @maxItems 150 + */ + ids: Id[]; + } + `), + ...await success("Polled Information", schema` + import { Message } from './Channels'; + + interface ${'PolledInformation'} { + /** + * Changed message objects. + */ + changed: Message[], + + /** + * Array of deleted message IDs. + */ + deleted: string[] + } + `) + } + ) +}); + +resource('/channels/:channel/messages/search', { + post: routeAuthenticated( + "Search for Messages", + "This route searches for messages within the given parameters.", + { + ...channelParams, + ...await body("Search Options", schema` + import { Id } from './_common'; + + interface ${'SearchOptions'} { + /** + * Full-text search query. + * + * See [MongoDB documentation](https://docs.mongodb.com/manual/text-search/#-text-operator) for more information. + * + * @minLength 1 + * @maxLength 64 + */ + query: string; + + /** + * Maximum number of messages to fetch. + * + * @minimum 1 + * @maximum 100 + */ + limit?: number; + + /** + * Message id before which messages should be fetched. + */ + before?: Id; + + /** + * Message id after which messages should be fetched. + */ + after?: Id; + + /** + * Message sort direction + */ + sort: 'Relevance' | 'Latest' | 'Oldest'; + + /** + * Whether to include user (and member, if server channel) objects. + */ + include_users?: boolean; + } + `), + ...retrievedMessages + } + ) +}); + +resource('/channels/:channel/ack/:message', { + put: routeAuthenticated( + "Acknowledge Message", + "Lets the server and all other clients know that we've seen this message id in this channel.", + { + ...messageParams, + ...await success("Acknowledged message.") + } + ) +}); +//#endregion + +//#region Groups +tag("Groups", "Create, invite users and manipulate groups"); + +resource('/channels/create', { + post: routeAuthenticated( + "Create Group", + "Create a new group with friends.", + { + ...await body("Group Data", schema` + import { Id, Nonce } from './_common'; + + interface ${'GroupData'} { + /** + * Group name + * @minLength 1 + * @maxLength 32 + */ + name: string; + + /** + * Group description + * @minLength 0 + * @maxLength 1024 + */ + description?: string; + + nonce: Nonce; + + /** + * Array of user IDs to add to the group. + * + * Must be friends with them. + * + * @maxItems 49 + */ + users?: string[]; + } + `), + ...await success('Group', ref("GroupChannel")) + } + ) +}); + +resource('/channels/:channel/members', { + get: routeAuthenticated( + "Fetch Group Members", + "Retrieves users who are part of this group.", + { + ...messageParams, + ...await success("Members", schema` + import { User } from './Users'; + type ${'Members'} = User[]; + `) + } + ), + put: routeAuthenticated( + "Add Group Member", + "Adds another user to the group.", + { + ...messageParams, + ...await success("User was added to the group.") + } + ), + delete: routeAuthenticated( + "Remove Group Member", + "Removes a user from the group.", + { + ...messageParams, + ...await success("User was removed from the group.") + } + ) +}); +//#endregion + +//#region Voice +tag("Voice", "Join and talk with other users"); + +resource('/channels/:channel/join_call', { + post: routeAuthenticated( + "Join Call", + "Asks the voice server for a token to join the call.", + { + ...channelParams, + ...await success("Join Data", schema` + interface ${'JoinData'} { + /** + * Voso Token + */ + token: string; + } + `) + } + ) +}); +//#endregion diff --git a/src/routes/index.ts b/src/routes/index.ts index 61be40f..a43e906 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -1,6 +1,7 @@ export async function load() { await import('./core.js'); await import('./users.js'); + await import('./channels.js'); } await load(); diff --git a/src/routes/users.ts b/src/routes/users.ts index 3d28a9e..f3a4ede 100644 --- a/src/routes/users.ts +++ b/src/routes/users.ts @@ -7,14 +7,18 @@ group("Users"); //#region User Information tag("User Information", "Query and fetch users on Revolt"); +const userParams = { + parameters: [ + await parameter('user', 'User ID', ref("Id")) + ] +} + resource('/users/:user', { get: routeAuthenticated( "Fetch User", "Retrieve a user's information.", { - parameters: [ - await parameter('user', 'User ID', ref("Id")) - ], + ...userParams, ...await success( "User information.", ref("User") @@ -33,27 +37,27 @@ resource('/users/@me', { import type { AutumnId } from './_common'; interface ${'EditUser'} { - status: Status; + status?: Status; /** * User profile data **/ - profile: { + profile?: { /** * Text to set as user profile description * @maxLength 2000 */ - content: string; + content?: string; - background: AutumnId; + background?: AutumnId; } - avatar: AutumnId; + avatar?: AutumnId; /** * Field to remove from user object */ - remove: 'ProfileContent' | 'ProfileBackground' | 'StatusText' | 'Avatar'; + remove?: 'ProfileContent' | 'ProfileBackground' | 'StatusText' | 'Avatar'; } `), ...await success("Succesfully changed user object.") @@ -94,9 +98,7 @@ resource('/users/:user/profile', { "Fetch User Profile", "Retrieve a user's profile data.", { - parameters: [ - await parameter('user', 'User ID', ref("Id")) - ], + ...userParams, ...await success( "User profile.", ref("Profile") @@ -110,9 +112,7 @@ resource('/users/:user/default_avatar', { "Fetch Default Avatar", "This returns a default avatar based on the given id.", { - parameters: [ - await parameter('user', 'User ID', ref("Id")) - ], + ...userParams, responses: { '200': { description: "Default avatar in PNG format", @@ -135,9 +135,7 @@ resource('/users/:user/mutual', { "Fetch Mutual Friends", "Retrieve a list of mutual friends with another user.", { - parameters: [ - await parameter('user', 'User ID', ref("Id")) - ], + ...userParams, ...await success( "Mutual friends.", schema` @@ -179,9 +177,7 @@ resource('/users/:user/dm', { "Open Direct Message", "Open a DM with another user.", { - parameters: [ - await parameter('user', 'User ID', ref('Id')) - ], + ...userParams, ...await success( "DM channel with user.", ref("DirectMessageChannel") @@ -213,9 +209,7 @@ resource('/users/:user/relationship', { "Fetch Relationship", "Fetch your relationship with another other user.", { - parameters: [ - await parameter('user', 'User ID', ref('Id')) - ], + ...userParams, ...await success( "Your relationship with the user.", ref("RelationshipOnly") @@ -224,14 +218,18 @@ resource('/users/:user/relationship', { ) }); -resource('/users/:user/friend', { +const friendParams = { + parameters: [ + await parameter('username', 'Username', ref("Username")) + ], +} + +resource('/users/:username/friend', { put: routeAuthenticated( "Send Friend Request / Accept Request", "Send a friend request to another user or accept another user's friend request.", { - parameters: [ - await parameter('user', 'User ID', ref('Id')) - ], + ...friendParams, ...await success( "Sent friend request / added user as friend.", ref("RelationshipOnly") @@ -242,9 +240,7 @@ resource('/users/:user/friend', { "Deny Friend Request / Remove Friend", "Denies another user's friend request or removes an existing friend.", { - parameters: [ - await parameter('user', 'User ID', ref('Id')) - ], + ...friendParams, ...await success( "Deleted friend request / removed user from friends.", ref("RelationshipOnly") @@ -258,9 +254,7 @@ resource('/users/:user/block', { "Block User", "Block another user.", { - parameters: [ - await parameter('user', 'User ID', ref('Id')) - ], + ...userParams, ...await success( "Blocked user.", ref("RelationshipOnly") @@ -271,9 +265,7 @@ resource('/users/:user/block', { "Unblock User", "Unblock another user.", { - parameters: [ - await parameter('user', 'User ID', ref('Id')) - ], + ...userParams, ...await success( "Unblocked user.", ref("RelationshipOnly") diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo index 5af4ad2..8b1ab2b 100644 --- a/tsconfig.tsbuildinfo +++ b/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"program":{"fileNames":["./node_modules/typescript/lib/lib.es5.d.ts","./node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/typescript/lib/lib.dom.d.ts","./node_modules/typescript/lib/lib.dom.iterable.d.ts","./node_modules/typescript/lib/lib.webworker.importscripts.d.ts","./node_modules/typescript/lib/lib.scripthost.d.ts","./node_modules/typescript/lib/lib.es2015.core.d.ts","./node_modules/typescript/lib/lib.es2015.collection.d.ts","./node_modules/typescript/lib/lib.es2015.generator.d.ts","./node_modules/typescript/lib/lib.es2015.iterable.d.ts","./node_modules/typescript/lib/lib.es2015.promise.d.ts","./node_modules/typescript/lib/lib.es2015.proxy.d.ts","./node_modules/typescript/lib/lib.es2015.reflect.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2016.array.include.d.ts","./node_modules/typescript/lib/lib.es2017.object.d.ts","./node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2017.string.d.ts","./node_modules/typescript/lib/lib.es2017.intl.d.ts","./node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","./node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","./node_modules/typescript/lib/lib.es2018.intl.d.ts","./node_modules/typescript/lib/lib.es2018.promise.d.ts","./node_modules/typescript/lib/lib.es2018.regexp.d.ts","./node_modules/typescript/lib/lib.es2019.array.d.ts","./node_modules/typescript/lib/lib.es2019.object.d.ts","./node_modules/typescript/lib/lib.es2019.string.d.ts","./node_modules/typescript/lib/lib.es2019.symbol.d.ts","./node_modules/typescript/lib/lib.es2020.bigint.d.ts","./node_modules/typescript/lib/lib.es2020.promise.d.ts","./node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2020.string.d.ts","./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2020.intl.d.ts","./node_modules/typescript/lib/lib.esnext.intl.d.ts","./node_modules/typescript/lib/lib.es2020.full.d.ts","./node_modules/openapi-types/dist/index.d.ts","./node_modules/typescript-json-schema/node_modules/typescript/lib/typescript.d.ts","./node_modules/@types/json-schema/index.d.ts","./node_modules/typescript-json-schema/dist/typescript-json-schema.d.ts","./src/openapi/info.ts","./node_modules/@openapi-contrib/json-schema-to-openapi-schema/index.d.ts","./src/typescript.ts","./src/openapi/definitions.ts","./src/openapi/paths.ts","./src/openapi/generators.ts","./src/routes/core.ts","./src/routes/users.ts","./src/routes/index.ts","./src/index.ts","./node_modules/@types/node/globals.d.ts","./node_modules/@types/node/async_hooks.d.ts","./node_modules/@types/node/buffer.d.ts","./node_modules/@types/node/child_process.d.ts","./node_modules/@types/node/cluster.d.ts","./node_modules/@types/node/console.d.ts","./node_modules/@types/node/constants.d.ts","./node_modules/@types/node/crypto.d.ts","./node_modules/@types/node/dgram.d.ts","./node_modules/@types/node/dns.d.ts","./node_modules/@types/node/domain.d.ts","./node_modules/@types/node/events.d.ts","./node_modules/@types/node/fs.d.ts","./node_modules/@types/node/fs/promises.d.ts","./node_modules/@types/node/http.d.ts","./node_modules/@types/node/http2.d.ts","./node_modules/@types/node/https.d.ts","./node_modules/@types/node/inspector.d.ts","./node_modules/@types/node/module.d.ts","./node_modules/@types/node/net.d.ts","./node_modules/@types/node/os.d.ts","./node_modules/@types/node/path.d.ts","./node_modules/@types/node/perf_hooks.d.ts","./node_modules/@types/node/process.d.ts","./node_modules/@types/node/punycode.d.ts","./node_modules/@types/node/querystring.d.ts","./node_modules/@types/node/readline.d.ts","./node_modules/@types/node/repl.d.ts","./node_modules/@types/node/stream.d.ts","./node_modules/@types/node/string_decoder.d.ts","./node_modules/@types/node/timers.d.ts","./node_modules/@types/node/tls.d.ts","./node_modules/@types/node/trace_events.d.ts","./node_modules/@types/node/tty.d.ts","./node_modules/@types/node/url.d.ts","./node_modules/@types/node/util.d.ts","./node_modules/@types/node/v8.d.ts","./node_modules/@types/node/vm.d.ts","./node_modules/@types/node/worker_threads.d.ts","./node_modules/@types/node/zlib.d.ts","./node_modules/@types/node/globals.global.d.ts","./node_modules/@types/node/wasi.d.ts","./node_modules/@types/node/ts3.6/base.d.ts","./node_modules/@types/node/assert.d.ts","./node_modules/@types/node/base.d.ts","./node_modules/@types/node/index.d.ts","./node_modules/@types/normalize-package-data/index.d.ts","./node_modules/@types/urijs/dom-monkeypatch.d.ts","./node_modules/@types/urijs/index.d.ts"],"fileInfos":[{"version":"ac3a8c4040e183ce38da69d23b96939112457d1936198e6542672b7963cf0fce","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"1dad4fe1561d99dfd6709127608b99a76e5c2643626c800434f99c48038567ee","affectsGlobalScope":true},{"version":"a8fe23ae87c3e9d2877032cafeb290f2ebe0c51e216d175a0408b10915ebe9f0","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"cce43d02223f8049864f8568bed322c39424013275cd3bcc3f51492d8b546cb3","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"8dff1b4c2df638fcd976cbb0e636f23ab5968e836cd45084cc31d47d1ab19c49","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"8f4c9f651c8294a2eb1cbd12581fe25bfb901ab1d474bb93cd38c7e2f4be7a30","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"60761e6ea886034af0f294f025a7199360ce4e2c8ba4ec6408bc049cf9b89799","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e","affectsGlobalScope":true},"f58c6d0669d1ee04b2fcb0e87fb949b6828602f3f29c7bf6c76a214f16fd50d5","22f7331ced6368f3c0e43b28037b821cfbbfc2e92ed0c2ca852b1911c94f09c2","b4e3edb529b83431180aba7ea2d39302afe8919962344db98d71fe0253951b62","a185ebc69c9f6798ebd67bfdfd72a37457dc67c23459784783c7128ae9bd5250","6f6cd024262d1f27ccd61c1da510875b18ce4b64ab4df6aca845f09b482c6353",{"version":"e4582c5cb6645d68edeaf060b51c069302fe3ad2c6985dda4efe2e43789fdc87","signature":"fe0d8a53cf3de50ece9b12859abc312631b44303c0791a23b29e0d4ea370ee2e"},"d28688041fc3686eb9842d1e2a883ec9af6a0d983ac3a969f22a264319612fa9","977756569c123972466f369e2bed001330ddbcf98e1e1c8fb1ad8f59205aa984",{"version":"6c0e70e7f91887eb669a71d97950fb2e633ccacef74aaf17f896e35986715120","signature":"3e512af78903190c7dd84cdb8e306bd3cb350a37f9b4cd27c8d7bea5b8a5d758"},{"version":"90f31704c73a4ca1f94886cd51905355cdbb2095106224e7462085a012bae1f1","signature":"54b322ddd515eaed558f0c9915ad0b9d90069722ca6e53c42959a985c19d2a64"},{"version":"1bed1f694295b6adec93ab3e065c9ff21f841ff0804c7d9ee841bdaeb49ffaa3","signature":"971c879b0ef703441b33a4577083ebdac085158f8e7c502b3d222cb432655ef5"},{"version":"990a8011272b92e9b750e4f6bc0699c2c7d28b61d60be1908c10ae2e1d11bcee","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"199e6456508ddbd70d470e0b9fdedbf6045f75b856c249f7302ceff95fe7586d","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"5bd4ad3d9a1b4cc114887f9fbdddcdb3fda51d860aaa9560d89e24afe1d5337f","signature":"c8844ed00e939d6bf966ee18a2e870f4029d61ee8505119d8ff260c28fcbd305"},{"version":"490c94a41844f37ed6ef71a196956cfe148b1237d9974cf09d6dda3eba6aa37b","signature":"57293441f7fc6659e400b0585c14b94a8930ae37ba37831b0a7c9f849c266708"},{"version":"3e432cdf56538889e5742d388cdf03d670bfb17f4547dbbb1daf90701ec790d5","affectsGlobalScope":true},"85d545d430795d54a8b2896f67f9aeb7bf19fd74a1469ae0627311eb72f0dfa2","a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b","55cb77e6ff3d95a68568446f53d3f1dc8fca753575d7c60471a865685f08dcc3","3d68ecf05475492f041c88395372c3a01b30351619bebcd38287ab185be7f7e4",{"version":"36c956a3a6dc279f1e6b77aa4b97b7b229b7d828102573ef5002de456ff5e1d9","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","6e8b894365ab993dbb55c58542598d1548fdda072c974f98b89c218891e2ba09","ddd6169dff8e5263397a9399ba7ba92521d3959f8f9dcdc27f24403dc7b751ba","508e1e25ca40ea6cde332d3232c826fcd82f456f45ae535d817754684f048f9e",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"8f8f6ee2a0c94077f79439f51640a625ac7e2f5dd6866bd3b5a41705c836adfc","affectsGlobalScope":true},"dda27180d5ff550ace8378f5df0f7a26e616f0c4e310c77e94329e2355f9c255","839421b494b57cd2bc0074e914130277051850eba6def6c25870056e6652640b","12a01de318341fefb7be11f22eb4bf28478a5f137b1b4546c509156e9c158198","88587b5c94b0c4f5d78026e4beeb93383b3933c860d9840b55d6bf47d7b632bb","5aa2a9a778a055cd668ea419ea80ba6e195210eb37d47707a1a58886aa4d80f0","9e8947666e44137405fd378f3a8a0515a492e967e552406c02b991c98c78fc61","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","9e6a556cf660a94faa51f5bce6ed009b9e02373546a4c67925da909f36c039d0","69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16","a39a4c527b7a2dc7a2661b711a534c10c76852c5ad6ae320767d3f7d2621b67d","1bb5c9857b2ee32c199dd85bc0f4c0299112485d6e5dc91428eabfdee0dbd68c",{"version":"61dd09b57a0a5cf1486c3ceb3a18ad23babfe602c323035ce3d01544c5e3e0b6","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","662661bbf9ccd869f3bca82d34234b2abdc95c657e2187c35352d42dddb24c2d","5caa645cc390a0a8d5a031072b6b4e49218c17017cd80a63bd2557b19be13c5f","4c4334eb5d8fae83416a361d787b55a5743916aed8af812a909898bc7333e709","352104835f5c468c7d8a277f2c8c02fac239a37cd2293181fe421faa153878d3","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b","a4aa075328fe61190b8547e74fae18179591a67fedb2ad274c63044a00716743","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","40c6ed5dc58e1c6afa7dcd23b1697bf290cc5b1170c63d0a4dd12f52aa39291c","71d6da3b0150ecdcd16c08b3b546fe4cc7f53df642eccfeb03c813ee788fae0c","a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d","c5ec3b97d9db756c689cd11f4a11eaa9e6077b2768e3e9b54ff727a93c03a909","bdb07038733b2d74a75ba9c381dcb92774cd6f161ee125bfa921eae7d883ccc9","ad93e960a3a07dff7394bf0c8a558006a9ff2d0725ab28fc33dec227d4cb251e",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"c14e9e86f18189c7d32b5dd03b4cf3f40bed68f0509dec06d75d41b82c065fe2","ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c","d555cd63a3fc837840db192596273fdf52fb28092b0a33bec98e89a0334b3a4c","e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b","49daf80661034e07d919f1c716aef69324e34d18a63a282f8100f52c961b58a7","6fa0008bf91a4cc9c8963bace4bba0bd6865cbfa29c3e3ccc461155660fb113a",{"version":"159733de19927f949b83112a45b7c52ebc0bbad1605a668d5c19ba65e0ee9128","affectsGlobalScope":true},{"version":"8445addb196de41a30b99f3c6ceeb45213f459fcbf7beb01b1f435f75fcdceff","affectsGlobalScope":true}],"options":{"esModuleInterop":true,"module":99,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"strict":true,"target":7},"fileIdsList":[[100,101],[69,70,77,86],[61,69,77],[93],[65,70,78],[86],[67,69,77],[69],[69,71,86,92],[70],[77,86,92],[69,70,72,77,86,89,92],[72,89,92],[102],[92],[67,69,86],[59],[91],[84,93,95],[77],[58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99],[83],[69,71,86,92,95],[105],[45,46],[44,47,48,51,52,56,71],[47,49,50,70],[44],[44,71],[50,52,53],[54,55],[47,49,70,79],[56],[47]],"referencedMap":[[102,1],[61,2],[62,3],[63,4],[64,5],[65,6],[66,7],[68,8],[69,8],[70,9],[71,10],[72,11],[73,12],[74,13],[103,14],[75,8],[76,15],[77,16],[80,17],[81,18],[84,8],[85,19],[86,8],[89,20],[100,21],[91,20],[92,22],[94,6],[96,23],[97,6],[106,24],[47,25],[57,26],[51,27],[53,28],[48,29],[52,28],[54,30],[56,31],[55,30],[50,32]],"exportedModulesMap":[[102,1],[61,2],[62,3],[63,4],[64,5],[65,6],[66,7],[68,8],[69,8],[70,9],[71,10],[72,11],[73,12],[74,13],[103,14],[75,8],[76,15],[77,16],[80,17],[81,18],[84,8],[85,19],[86,8],[89,20],[100,21],[91,20],[92,22],[94,6],[96,23],[97,6],[106,24],[47,25],[57,33],[51,34],[53,28],[48,28],[52,28],[50,32]],"semanticDiagnosticsPerFile":[49,46,101,59,102,60,61,62,63,64,65,66,67,68,69,70,71,58,98,72,73,74,103,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,100,91,92,93,94,95,99,96,97,104,105,106,44,47,45,8,9,13,12,2,14,15,16,17,18,19,20,21,3,4,25,22,23,24,26,27,28,5,29,30,31,32,6,33,34,35,36,7,43,41,37,38,39,40,1,42,11,10,57,51,53,48,52,54,56,55,50]},"version":"4.3.5"} \ No newline at end of file +{"program":{"fileNames":["./node_modules/typescript/lib/lib.es5.d.ts","./node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/typescript/lib/lib.dom.d.ts","./node_modules/typescript/lib/lib.dom.iterable.d.ts","./node_modules/typescript/lib/lib.webworker.importscripts.d.ts","./node_modules/typescript/lib/lib.scripthost.d.ts","./node_modules/typescript/lib/lib.es2015.core.d.ts","./node_modules/typescript/lib/lib.es2015.collection.d.ts","./node_modules/typescript/lib/lib.es2015.generator.d.ts","./node_modules/typescript/lib/lib.es2015.iterable.d.ts","./node_modules/typescript/lib/lib.es2015.promise.d.ts","./node_modules/typescript/lib/lib.es2015.proxy.d.ts","./node_modules/typescript/lib/lib.es2015.reflect.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2016.array.include.d.ts","./node_modules/typescript/lib/lib.es2017.object.d.ts","./node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2017.string.d.ts","./node_modules/typescript/lib/lib.es2017.intl.d.ts","./node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","./node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","./node_modules/typescript/lib/lib.es2018.intl.d.ts","./node_modules/typescript/lib/lib.es2018.promise.d.ts","./node_modules/typescript/lib/lib.es2018.regexp.d.ts","./node_modules/typescript/lib/lib.es2019.array.d.ts","./node_modules/typescript/lib/lib.es2019.object.d.ts","./node_modules/typescript/lib/lib.es2019.string.d.ts","./node_modules/typescript/lib/lib.es2019.symbol.d.ts","./node_modules/typescript/lib/lib.es2020.bigint.d.ts","./node_modules/typescript/lib/lib.es2020.promise.d.ts","./node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2020.string.d.ts","./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2020.intl.d.ts","./node_modules/typescript/lib/lib.esnext.intl.d.ts","./node_modules/typescript/lib/lib.es2020.full.d.ts","./node_modules/openapi-types/dist/index.d.ts","./node_modules/typescript-json-schema/node_modules/typescript/lib/typescript.d.ts","./node_modules/@types/json-schema/index.d.ts","./node_modules/typescript-json-schema/dist/typescript-json-schema.d.ts","./src/openapi/info.ts","./node_modules/@openapi-contrib/json-schema-to-openapi-schema/index.d.ts","./src/typescript.ts","./src/openapi/definitions.ts","./src/openapi/paths.ts","./src/openapi/generators.ts","./src/routes/core.ts","./src/routes/users.ts","./src/routes/channels.ts","./src/routes/index.ts","./src/index.ts","./node_modules/@types/node/globals.d.ts","./node_modules/@types/node/async_hooks.d.ts","./node_modules/@types/node/buffer.d.ts","./node_modules/@types/node/child_process.d.ts","./node_modules/@types/node/cluster.d.ts","./node_modules/@types/node/console.d.ts","./node_modules/@types/node/constants.d.ts","./node_modules/@types/node/crypto.d.ts","./node_modules/@types/node/dgram.d.ts","./node_modules/@types/node/dns.d.ts","./node_modules/@types/node/domain.d.ts","./node_modules/@types/node/events.d.ts","./node_modules/@types/node/fs.d.ts","./node_modules/@types/node/fs/promises.d.ts","./node_modules/@types/node/http.d.ts","./node_modules/@types/node/http2.d.ts","./node_modules/@types/node/https.d.ts","./node_modules/@types/node/inspector.d.ts","./node_modules/@types/node/module.d.ts","./node_modules/@types/node/net.d.ts","./node_modules/@types/node/os.d.ts","./node_modules/@types/node/path.d.ts","./node_modules/@types/node/perf_hooks.d.ts","./node_modules/@types/node/process.d.ts","./node_modules/@types/node/punycode.d.ts","./node_modules/@types/node/querystring.d.ts","./node_modules/@types/node/readline.d.ts","./node_modules/@types/node/repl.d.ts","./node_modules/@types/node/stream.d.ts","./node_modules/@types/node/string_decoder.d.ts","./node_modules/@types/node/timers.d.ts","./node_modules/@types/node/tls.d.ts","./node_modules/@types/node/trace_events.d.ts","./node_modules/@types/node/tty.d.ts","./node_modules/@types/node/url.d.ts","./node_modules/@types/node/util.d.ts","./node_modules/@types/node/v8.d.ts","./node_modules/@types/node/vm.d.ts","./node_modules/@types/node/worker_threads.d.ts","./node_modules/@types/node/zlib.d.ts","./node_modules/@types/node/globals.global.d.ts","./node_modules/@types/node/wasi.d.ts","./node_modules/@types/node/ts3.6/base.d.ts","./node_modules/@types/node/assert.d.ts","./node_modules/@types/node/base.d.ts","./node_modules/@types/node/index.d.ts","./node_modules/@types/normalize-package-data/index.d.ts","./node_modules/@types/urijs/dom-monkeypatch.d.ts","./node_modules/@types/urijs/index.d.ts"],"fileInfos":[{"version":"ac3a8c4040e183ce38da69d23b96939112457d1936198e6542672b7963cf0fce","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"1dad4fe1561d99dfd6709127608b99a76e5c2643626c800434f99c48038567ee","affectsGlobalScope":true},{"version":"a8fe23ae87c3e9d2877032cafeb290f2ebe0c51e216d175a0408b10915ebe9f0","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"cce43d02223f8049864f8568bed322c39424013275cd3bcc3f51492d8b546cb3","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"8dff1b4c2df638fcd976cbb0e636f23ab5968e836cd45084cc31d47d1ab19c49","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"8f4c9f651c8294a2eb1cbd12581fe25bfb901ab1d474bb93cd38c7e2f4be7a30","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"60761e6ea886034af0f294f025a7199360ce4e2c8ba4ec6408bc049cf9b89799","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e","affectsGlobalScope":true},"f58c6d0669d1ee04b2fcb0e87fb949b6828602f3f29c7bf6c76a214f16fd50d5","22f7331ced6368f3c0e43b28037b821cfbbfc2e92ed0c2ca852b1911c94f09c2","b4e3edb529b83431180aba7ea2d39302afe8919962344db98d71fe0253951b62","a185ebc69c9f6798ebd67bfdfd72a37457dc67c23459784783c7128ae9bd5250","6f6cd024262d1f27ccd61c1da510875b18ce4b64ab4df6aca845f09b482c6353",{"version":"e4582c5cb6645d68edeaf060b51c069302fe3ad2c6985dda4efe2e43789fdc87","signature":"fe0d8a53cf3de50ece9b12859abc312631b44303c0791a23b29e0d4ea370ee2e"},"d28688041fc3686eb9842d1e2a883ec9af6a0d983ac3a969f22a264319612fa9","977756569c123972466f369e2bed001330ddbcf98e1e1c8fb1ad8f59205aa984",{"version":"6c0e70e7f91887eb669a71d97950fb2e633ccacef74aaf17f896e35986715120","signature":"3e512af78903190c7dd84cdb8e306bd3cb350a37f9b4cd27c8d7bea5b8a5d758"},{"version":"60ab16ff77f9a7351ad9863d904661526ac17f494d569420cf8767a5a49e92f4","signature":"54b322ddd515eaed558f0c9915ad0b9d90069722ca6e53c42959a985c19d2a64"},{"version":"1bed1f694295b6adec93ab3e065c9ff21f841ff0804c7d9ee841bdaeb49ffaa3","signature":"971c879b0ef703441b33a4577083ebdac085158f8e7c502b3d222cb432655ef5"},{"version":"990a8011272b92e9b750e4f6bc0699c2c7d28b61d60be1908c10ae2e1d11bcee","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"2f1cf450f1a04cbe8cf48edbf9c664f4851d651c6975fcf6fc74a2c6fbe9be64","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"87892f8d3f8ab9ec3e77fd172302b1d68fb1edb1f854f7123676849c9559b7f7","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"014742176f4a6602766c7c4074a37c3a654bad0b79dd1d76ed4904a6d4c4373c","signature":"c8844ed00e939d6bf966ee18a2e870f4029d61ee8505119d8ff260c28fcbd305"},{"version":"490c94a41844f37ed6ef71a196956cfe148b1237d9974cf09d6dda3eba6aa37b","signature":"57293441f7fc6659e400b0585c14b94a8930ae37ba37831b0a7c9f849c266708"},{"version":"3e432cdf56538889e5742d388cdf03d670bfb17f4547dbbb1daf90701ec790d5","affectsGlobalScope":true},"85d545d430795d54a8b2896f67f9aeb7bf19fd74a1469ae0627311eb72f0dfa2","a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b","55cb77e6ff3d95a68568446f53d3f1dc8fca753575d7c60471a865685f08dcc3","3d68ecf05475492f041c88395372c3a01b30351619bebcd38287ab185be7f7e4",{"version":"36c956a3a6dc279f1e6b77aa4b97b7b229b7d828102573ef5002de456ff5e1d9","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","6e8b894365ab993dbb55c58542598d1548fdda072c974f98b89c218891e2ba09","ddd6169dff8e5263397a9399ba7ba92521d3959f8f9dcdc27f24403dc7b751ba","508e1e25ca40ea6cde332d3232c826fcd82f456f45ae535d817754684f048f9e",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"8f8f6ee2a0c94077f79439f51640a625ac7e2f5dd6866bd3b5a41705c836adfc","affectsGlobalScope":true},"dda27180d5ff550ace8378f5df0f7a26e616f0c4e310c77e94329e2355f9c255","839421b494b57cd2bc0074e914130277051850eba6def6c25870056e6652640b","12a01de318341fefb7be11f22eb4bf28478a5f137b1b4546c509156e9c158198","88587b5c94b0c4f5d78026e4beeb93383b3933c860d9840b55d6bf47d7b632bb","5aa2a9a778a055cd668ea419ea80ba6e195210eb37d47707a1a58886aa4d80f0","9e8947666e44137405fd378f3a8a0515a492e967e552406c02b991c98c78fc61","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","9e6a556cf660a94faa51f5bce6ed009b9e02373546a4c67925da909f36c039d0","69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16","a39a4c527b7a2dc7a2661b711a534c10c76852c5ad6ae320767d3f7d2621b67d","1bb5c9857b2ee32c199dd85bc0f4c0299112485d6e5dc91428eabfdee0dbd68c",{"version":"61dd09b57a0a5cf1486c3ceb3a18ad23babfe602c323035ce3d01544c5e3e0b6","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","662661bbf9ccd869f3bca82d34234b2abdc95c657e2187c35352d42dddb24c2d","5caa645cc390a0a8d5a031072b6b4e49218c17017cd80a63bd2557b19be13c5f","4c4334eb5d8fae83416a361d787b55a5743916aed8af812a909898bc7333e709","352104835f5c468c7d8a277f2c8c02fac239a37cd2293181fe421faa153878d3","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b","a4aa075328fe61190b8547e74fae18179591a67fedb2ad274c63044a00716743","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","40c6ed5dc58e1c6afa7dcd23b1697bf290cc5b1170c63d0a4dd12f52aa39291c","71d6da3b0150ecdcd16c08b3b546fe4cc7f53df642eccfeb03c813ee788fae0c","a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d","c5ec3b97d9db756c689cd11f4a11eaa9e6077b2768e3e9b54ff727a93c03a909","bdb07038733b2d74a75ba9c381dcb92774cd6f161ee125bfa921eae7d883ccc9","ad93e960a3a07dff7394bf0c8a558006a9ff2d0725ab28fc33dec227d4cb251e",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"c14e9e86f18189c7d32b5dd03b4cf3f40bed68f0509dec06d75d41b82c065fe2","ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c","d555cd63a3fc837840db192596273fdf52fb28092b0a33bec98e89a0334b3a4c","e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b","49daf80661034e07d919f1c716aef69324e34d18a63a282f8100f52c961b58a7","6fa0008bf91a4cc9c8963bace4bba0bd6865cbfa29c3e3ccc461155660fb113a",{"version":"159733de19927f949b83112a45b7c52ebc0bbad1605a668d5c19ba65e0ee9128","affectsGlobalScope":true},{"version":"8445addb196de41a30b99f3c6ceeb45213f459fcbf7beb01b1f435f75fcdceff","affectsGlobalScope":true}],"options":{"esModuleInterop":true,"module":99,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"strict":true,"target":7},"fileIdsList":[[101,102],[70,71,78,87],[62,70,78],[94],[66,71,79],[87],[68,70,78],[70],[70,72,87,93],[71],[78,87,93],[70,71,73,78,87,90,93],[73,90,93],[103],[93],[68,70,87],[60],[92],[85,94,96],[78],[59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100],[84],[70,72,87,93,96],[106],[45,46],[44,47,48,51,52,57,72],[47,49,50,71],[44],[44,72],[50,52,53],[54,55,56],[47,49,71,80],[57],[47]],"referencedMap":[[103,1],[62,2],[63,3],[64,4],[65,5],[66,6],[67,7],[69,8],[70,8],[71,9],[72,10],[73,11],[74,12],[75,13],[104,14],[76,8],[77,15],[78,16],[81,17],[82,18],[85,8],[86,19],[87,8],[90,20],[101,21],[92,20],[93,22],[95,6],[97,23],[98,6],[107,24],[47,25],[58,26],[51,27],[53,28],[48,29],[52,28],[56,30],[54,30],[57,31],[55,30],[50,32]],"exportedModulesMap":[[103,1],[62,2],[63,3],[64,4],[65,5],[66,6],[67,7],[69,8],[70,8],[71,9],[72,10],[73,11],[74,12],[75,13],[104,14],[76,8],[77,15],[78,16],[81,17],[82,18],[85,8],[86,19],[87,8],[90,20],[101,21],[92,20],[93,22],[95,6],[97,23],[98,6],[107,24],[47,25],[58,33],[51,34],[53,28],[48,28],[52,28],[50,32]],"semanticDiagnosticsPerFile":[49,46,102,60,103,61,62,63,64,65,66,67,68,69,70,71,72,59,99,73,74,75,104,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,101,92,93,94,95,96,100,97,98,105,106,107,44,47,45,8,9,13,12,2,14,15,16,17,18,19,20,21,3,4,25,22,23,24,26,27,28,5,29,30,31,32,6,33,34,35,36,7,43,41,37,38,39,40,1,42,11,10,58,51,53,48,52,56,54,57,55,50]},"version":"4.3.5"} \ No newline at end of file diff --git a/types/Users.ts b/types/Users.ts index 0f002c9..e6fb18b 100644 --- a/types/Users.ts +++ b/types/Users.ts @@ -1,6 +1,14 @@ import type { Attachment } from './Autumn'; import type { Id } from './_common'; +/** + * Username + * @minLength 2 + * @maxLength 32 + * @pattern ^[a-zA-Z0-9_.]+$ + */ +export type Username = string; + /** * Your relationship with the user */ @@ -64,13 +72,7 @@ export interface User { */ _id: Id - /** - * Username - * @minLength 2 - * @maxLength 32 - * @pattern ^[a-zA-Z0-9_.]+$ - */ - username: string + username: Username /** * User avatar diff --git a/types/__temp.ts b/types/__temp.ts index 5f33637..715cf53 100644 --- a/types/__temp.ts +++ b/types/__temp.ts @@ -1,4 +1,8 @@ - import type { Relationship } from "./Users"; - type FetchRelationships = Relationship[]; + interface JoinData { + /** + * Voso Token + */ + token: string; + } \ No newline at end of file diff --git a/types/_common.ts b/types/_common.ts index 8d7343d..565de4f 100644 --- a/types/_common.ts +++ b/types/_common.ts @@ -6,6 +6,9 @@ export type Id = string; /** * Nonce value, prefer to use ULIDs here for better feature support. + * + * Used to prevent double requests to create objects. + * * @minLength 1 * @maxLength 36 */ @@ -13,5 +16,7 @@ export type Nonce = string; /** * Autumn file ID, [learn more](https://example.com/TODO). + * @minLength 1 + * @maxLength 128 */ export type AutumnId = string;