mirror of
https://github.com/stoatchat/javascript-client-api.git
synced 2026-07-20 01:25:03 -04:00
Change: Return 204 for empty content.
Change: Return bots and users.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt-api",
|
||||
"version": "0.5.2-alpha.0",
|
||||
"version": "0.5.2-alpha.1",
|
||||
"description": "Revolt API typings",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
|
||||
@@ -16,6 +16,14 @@ export async function success(description: string, json?: Promise<OpenAPIV3.Medi
|
||||
return { responses: { "200": response } };
|
||||
}
|
||||
|
||||
export async function noContent(description: string): Promise<{ responses: OpenAPIV3.ResponsesObject }> {
|
||||
const response: OpenAPIV3.ResponseObject = {
|
||||
description
|
||||
};
|
||||
|
||||
return { responses: { "204": response } };
|
||||
}
|
||||
|
||||
export async function body(description: string, json: Promise<OpenAPIV3.MediaTypeObject> | OpenAPIV3.MediaTypeObject | OpenAPIV3.ReferenceObject): Promise<{ requestBody: OpenAPIV3.RequestBodyObject }> {
|
||||
return {
|
||||
requestBody: {
|
||||
|
||||
+17
-6
@@ -1,4 +1,4 @@
|
||||
import { body, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { body, noContent, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { group, resource, routeAuthenticated, tag } from "../openapi/paths.js";
|
||||
import { schema } from "../typescript.js";
|
||||
|
||||
@@ -37,7 +37,11 @@ resource('/bots/@me', {
|
||||
{
|
||||
...await success("Array of bot objects.", schema`
|
||||
import type { Bot } from './Bots';
|
||||
type ${'MyBots'} = Bot[];
|
||||
import type { User } from './Users';
|
||||
type ${'MyBots'} = {
|
||||
bots: Bot[],
|
||||
users: User[]
|
||||
};
|
||||
`)
|
||||
}
|
||||
)
|
||||
@@ -55,7 +59,14 @@ resource('/bots/:bot', {
|
||||
"Fetch details of an owned bot.",
|
||||
{
|
||||
...botParams,
|
||||
...await success("Bot", ref("Bot"))
|
||||
...await success("Bot", schema`
|
||||
import type { Bot } from './Bots';
|
||||
import type { User } from './Users';
|
||||
type ${'MyBot'} = {
|
||||
bot: Bot,
|
||||
user: User
|
||||
};
|
||||
`)
|
||||
}
|
||||
),
|
||||
patch: routeAuthenticated(
|
||||
@@ -89,7 +100,7 @@ resource('/bots/:bot', {
|
||||
remove?: 'InteractionsURL';
|
||||
}
|
||||
`),
|
||||
...await success("Succesfully changed bot object.")
|
||||
...await noContent("Succesfully changed bot object.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
@@ -97,7 +108,7 @@ resource('/bots/:bot', {
|
||||
"Delete a bot.",
|
||||
{
|
||||
...botParams,
|
||||
...await success("Deleted bot.")
|
||||
...await noContent("Deleted bot.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -134,7 +145,7 @@ resource('/bots/:bot/invite', {
|
||||
}
|
||||
)
|
||||
`),
|
||||
...await success("Added bot to server / group.")
|
||||
...await noContent("Added bot to server / group.")
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
import { body, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { body, noContent, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { group, resource, routeAuthenticated, tag } from "../openapi/paths.js";
|
||||
import { schema } from "../typescript.js";
|
||||
|
||||
@@ -57,7 +57,7 @@ resource('/channels/:channel', {
|
||||
remove?: 'Icon' | 'Description';
|
||||
}
|
||||
`),
|
||||
...await success("Succesfully changed channel object.")
|
||||
...await noContent("Succesfully changed channel object.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
@@ -65,7 +65,7 @@ resource('/channels/:channel', {
|
||||
"Deletes a server channel, leaves a group or closes a DM.",
|
||||
{
|
||||
...channelParams,
|
||||
...await success("Deleted Channel")
|
||||
...await noContent("Deleted Channel")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -116,7 +116,7 @@ resource('/channels/:channel/permissions/:role', {
|
||||
{
|
||||
...roleParams,
|
||||
...channelPermissions,
|
||||
...await success("Successfully updated permissions.")
|
||||
...await noContent("Successfully updated permissions.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -128,7 +128,7 @@ resource('/channels/:channel/permissions/default', {
|
||||
{
|
||||
...channelParams,
|
||||
...channelPermissions,
|
||||
...await success("Successfully updated permissions.")
|
||||
...await noContent("Successfully updated permissions.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -281,7 +281,7 @@ resource('/channels/:channel/messages/:message', {
|
||||
content: string;
|
||||
}
|
||||
`),
|
||||
...await success("Message was changed.")
|
||||
...await noContent("Message was changed.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
@@ -289,7 +289,7 @@ resource('/channels/:channel/messages/:message', {
|
||||
"Delete a message you've sent or one you have permission to delete.",
|
||||
{
|
||||
...messageParams,
|
||||
...await success("Message was deleted.")
|
||||
...await noContent("Message was deleted.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -391,7 +391,7 @@ resource('/channels/:channel/ack/:message', {
|
||||
"Lets the server and all other clients know that we've seen this message id in this channel.",
|
||||
{
|
||||
...messageParams,
|
||||
...await success("Acknowledged message.")
|
||||
...await noContent("Acknowledged message.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -457,7 +457,7 @@ resource('/channels/:channel/members', {
|
||||
"Adds another user to the group.",
|
||||
{
|
||||
...messageParams,
|
||||
...await success("User was added to the group.")
|
||||
...await noContent("User was added to the group.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
@@ -465,7 +465,7 @@ resource('/channels/:channel/members', {
|
||||
"Removes a user from the group.",
|
||||
{
|
||||
...messageParams,
|
||||
...await success("User was removed from the group.")
|
||||
...await noContent("User was removed from the group.")
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { group, resource, route, routeAuthenticated, tag } from "../openapi/paths.js";
|
||||
import { body, ref, success } from "../openapi/generators.js";
|
||||
import { body, noContent, ref, success } from "../openapi/generators.js";
|
||||
import { schema } from "../typescript.js";
|
||||
|
||||
group("Chat Platform");
|
||||
@@ -47,7 +47,7 @@ resource('/onboard/complete', {
|
||||
username: string;
|
||||
}
|
||||
`),
|
||||
...await success("Successfully set username")
|
||||
...await noContent("Successfully set username")
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
import { body, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { body, noContent, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { group, resource, route, routeAuthenticated, tag } from "../openapi/paths.js";
|
||||
import { schema } from "../typescript.js";
|
||||
|
||||
@@ -44,7 +44,7 @@ resource('/invites/:invite', {
|
||||
"Delete an invite by its ID.",
|
||||
{
|
||||
...inviteParams,
|
||||
...await success("Deleted invite.")
|
||||
...await noContent("Deleted invite.")
|
||||
}
|
||||
),
|
||||
});
|
||||
@@ -93,7 +93,7 @@ resource('/sync/settings/set', {
|
||||
[key: string]: string
|
||||
}
|
||||
`),
|
||||
...await success("Successfully synced data.")
|
||||
...await noContent("Successfully synced data.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -116,7 +116,7 @@ resource('/push/subscribe', {
|
||||
"Create a new Web Push subscription.\n\nIf an existing subscription exists on this session, it will be removed.",
|
||||
{
|
||||
...await body("Web Push Subscription", ref("WebPushSubscription")),
|
||||
...await success("Subscribed successfully.")
|
||||
...await noContent("Subscribed successfully.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -125,7 +125,7 @@ resource('/push/unsubscribe', {
|
||||
post: routeAuthenticated(
|
||||
"Unsubscribe",
|
||||
"Remove the Web Push subscription associated with the current session.",
|
||||
await success("Unsubscribed successfully.")
|
||||
await noContent("Unsubscribed successfully.")
|
||||
)
|
||||
});
|
||||
//#endregion
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
import { body, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { body, noContent, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { group, resource, route, routeAuthenticated, tag } from "../openapi/paths.js";
|
||||
import { schema } from "../typescript.js";
|
||||
|
||||
@@ -69,7 +69,7 @@ resource('/servers/:server', {
|
||||
remove?: 'Icon' | 'Banner' | 'Description';
|
||||
}
|
||||
`),
|
||||
...await success("Succesfully changed channel object.")
|
||||
...await noContent("Succesfully changed channel object.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
@@ -77,7 +77,7 @@ resource('/servers/:server', {
|
||||
"Deletes a server if owner otherwise leaves.",
|
||||
{
|
||||
...serverParams,
|
||||
...await success("Deleted Server")
|
||||
...await noContent("Deleted Server")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -186,7 +186,7 @@ resource('/servers/:server/ack', {
|
||||
"Mark all channels in a server as read.",
|
||||
{
|
||||
...serverParams,
|
||||
...await success("Marked as read.")
|
||||
...await noContent("Marked as read.")
|
||||
}
|
||||
),
|
||||
});
|
||||
@@ -243,13 +243,13 @@ resource('/servers/:server/members/:member', {
|
||||
remove?: 'Nickname' | 'Avatar';
|
||||
}
|
||||
`),
|
||||
...await success("Succesfully changed member object.")
|
||||
...await noContent("Succesfully changed member object.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
"Kick Member",
|
||||
"Removes a member from the server.",
|
||||
await success("Removed Member")
|
||||
await noContent("Removed Member")
|
||||
)
|
||||
});
|
||||
|
||||
@@ -291,7 +291,7 @@ resource('/servers/:server/bans/:member', {
|
||||
reason?: string
|
||||
}
|
||||
`),
|
||||
...await success("Banned user.")
|
||||
...await noContent("Banned user.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
@@ -299,7 +299,7 @@ resource('/servers/:server/bans/:member', {
|
||||
"Removes a user's ban.",
|
||||
{
|
||||
...memberParams,
|
||||
...await success("Unbanned user.")
|
||||
...await noContent("Unbanned user.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -373,7 +373,7 @@ resource('/servers/:server/permissions/:role', {
|
||||
{
|
||||
...roleParams,
|
||||
...serverPermissions,
|
||||
...await success("Successfully updated permissions.")
|
||||
...await noContent("Successfully updated permissions.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -385,7 +385,7 @@ resource('/servers/:server/permissions/default', {
|
||||
{
|
||||
...serverParams,
|
||||
...serverPermissions,
|
||||
...await success("Successfully updated permissions.")
|
||||
...await noContent("Successfully updated permissions.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -439,7 +439,7 @@ resource('/servers/:server/roles/:role', {
|
||||
remove?: 'Colour';
|
||||
}
|
||||
`),
|
||||
...await success("Succesfully changed role object.")
|
||||
...await noContent("Succesfully changed role object.")
|
||||
}
|
||||
),
|
||||
delete: routeAuthenticated(
|
||||
@@ -447,7 +447,7 @@ resource('/servers/:server/roles/:role', {
|
||||
"Deletes a server role by ID.",
|
||||
{
|
||||
...roleParams,
|
||||
...await success("Successfully deleted role.")
|
||||
...await noContent("Successfully deleted role.")
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { body, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { body, noContent, parameter, ref, success } from "../openapi/generators.js";
|
||||
import { group, resource, route, routeAuthenticated, tag } from "../openapi/paths.js";
|
||||
import { schema } from "../typescript.js";
|
||||
|
||||
@@ -60,7 +60,7 @@ resource('/users/@me', {
|
||||
remove?: 'ProfileContent' | 'ProfileBackground' | 'StatusText' | 'Avatar';
|
||||
}
|
||||
`),
|
||||
...await success("Succesfully changed user object.")
|
||||
...await noContent("Succesfully changed user object.")
|
||||
}
|
||||
)
|
||||
});
|
||||
@@ -88,7 +88,7 @@ resource('/users/@me/username', {
|
||||
password: string;
|
||||
}
|
||||
`),
|
||||
...await success("Succesfully changed user object.")
|
||||
...await noContent("Succesfully changed user object.")
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user