mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-21 04:25:27 -04:00
Update API definitions.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "3.0.3-alpha.7",
|
||||
"version": "3.0.3-alpha.8",
|
||||
"main": "dist/index.js",
|
||||
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
|
||||
"author": "Paul Makles <insrt.uk>",
|
||||
|
||||
+3
-1
@@ -8,9 +8,10 @@ import { Core, Auth, Users, Channels } from './api/objects';
|
||||
|
||||
import { Route, RoutePath, RouteMethod } from './api/routes';
|
||||
|
||||
import User, { SystemUser } from './objects/User';
|
||||
import Channel from './objects/Channel';
|
||||
import Message from './objects/Message';
|
||||
import User, { SystemUser } from './objects/User';
|
||||
import { ClientboundNotification } from './websocket/notifications';
|
||||
|
||||
export interface ClientOptions {
|
||||
apiURL: string,
|
||||
@@ -24,6 +25,7 @@ export declare interface Client {
|
||||
on(event: 'connecting', listener: () => void): this;
|
||||
on(event: 'dropped', listener: () => void): this;
|
||||
on(event: 'ready', listener: () => void): this;
|
||||
on(event: 'packet', listener: (packet: ClientboundNotification) => void): this;
|
||||
|
||||
// Object creation.
|
||||
on(event: 'create/user', listener: (user: User) => void): this;
|
||||
|
||||
@@ -187,6 +187,15 @@ type Routes =
|
||||
status: Users.Relationship
|
||||
}
|
||||
}
|
||||
| {
|
||||
// Fetch your mutual relationships with another user.
|
||||
method: 'GET',
|
||||
route: '/users/:id/mutual',
|
||||
data: undefined,
|
||||
response: {
|
||||
users: string[]
|
||||
}
|
||||
}
|
||||
| {
|
||||
// Send a friend request / accept a friend request.
|
||||
method: 'PUT',
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ export { default as User } from './objects/User';
|
||||
export { default as Message } from './objects/Message';
|
||||
export { default as Channel, SavedMessagesChannel, DirectMessageChannel, GroupChannel } from './objects/Channel';
|
||||
|
||||
export const LIBRARY_VERSION = '3.0.3-alpha.7';
|
||||
export const LIBRARY_VERSION = '3.0.3-alpha.8';
|
||||
|
||||
export const defaultConfig = {
|
||||
apiURL: 'https://api.revolt.chat',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { result } from 'lodash';
|
||||
import { Client, Channel } from '..';
|
||||
import { Users } from '../api/objects';
|
||||
import { hasChanged } from '../util/object';
|
||||
@@ -78,6 +79,17 @@ export default class User {
|
||||
return relationship;
|
||||
}
|
||||
|
||||
async fetchMutualConnections(): Promise<{ users: User[] }> {
|
||||
let data = await this.client.req<'GET', '/users/:id/mutual'>('GET', `/users/${this.id}/mutual` as any);
|
||||
let users = [];
|
||||
|
||||
for (let user of data.users) {
|
||||
users.push(await this.client.fetchUser(user));
|
||||
}
|
||||
|
||||
return { users };
|
||||
}
|
||||
|
||||
async addFriend() {
|
||||
let data = await this.client.req<'PUT', '/users/:id/friend'>('PUT', `/users/${this.username}/friend` as any);
|
||||
this.patch({ relationship: data.status }, true);
|
||||
|
||||
@@ -5,7 +5,9 @@ type WebSocketError = {
|
||||
};
|
||||
|
||||
export type ServerboundNotification = (
|
||||
({ type: 'Authenticate' } & Auth.Session)
|
||||
({ type: 'Authenticate' } & Auth.Session) |
|
||||
({ type: 'BeginTyping', channel: string }) |
|
||||
({ type: 'EndTyping', channel: string })
|
||||
);
|
||||
|
||||
export type ClientboundNotification = (
|
||||
@@ -22,6 +24,8 @@ export type ClientboundNotification = (
|
||||
({ type: 'ChannelGroupJoin', id: string, user: string }) |
|
||||
({ type: 'ChannelGroupLeave', id: string, user: string }) |
|
||||
({ type: 'ChannelDelete', id: string }) |
|
||||
({ type: 'ChannelStartTyping', id: string, user: string }) |
|
||||
({ type: 'ChannelStopTyping', id: string, user: string }) |
|
||||
|
||||
{ type: 'UserRelationship', user: string, status: Users.Relationship } |
|
||||
{ type: 'UserPresence', id: string, online: boolean }
|
||||
|
||||
Reference in New Issue
Block a user