Git Product home page Git Product logo

api's Introduction

Revolt API

revolt-api

This package contains typings for objects in the Revolt API and a fully typed API request builder.

Example Usage

If you just need access to types:

import type { User } from 'revolt-api';

If you want to send requests:

import { API } from 'revolt-api';

// Initialise a new API client:
const client = new API();

// or with authentication:
const client = new API({ authentication: { revolt: 'bot-token' } });

// Make requests with ease:
client.get('/users/@me')
    // Fully typed responses!
    .then(user => user.username);

// No need to worry about the details:
let channel_id = "some channel id";
client.post(`/channels/${channel_id}/messages`, {
    // Parameters given are fully typed as well!
    content: "some content"
});

For more details on how this works, see the README of @insertish/oapi.

api's People

Contributors

goaaats avatar insertish avatar jackenmen avatar jan0660 avatar revolt-ci avatar rexogamer avatar sussycatgirl avatar zomatree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

api's Issues

Custom message routing

What do you want to see?

This could be useful for cross-posting and IoT-related use cases. Custom route management should be permissions-gated to prevent spamming by randomly creating message routes.

The semantics should be as follows: server-wide permissions allow you to create, alter and drop a message route targeting any channel, while per-guild permission only allows you to do so while requiring you to have either:

  • Posting, storage, view all within that guild
  • Posting channel is null (meaning that route is read-only) and view channel is within that guild, no constraints on storage channel

Routing rule

A routing rule shall consist of eight elements:

  • Timestamp of the registration (stored as snowflake)
  • Source channel
  • Storage channel
  • Sink channel
  • Source users (user, group or role ID)
  • Target users (user, group or role ID)
  • Valid since timestamp
  • Valid until timestamp

Invariants

  • Valid since cannot be earlier than time of registration
  • Valid until cannot be earlier than valid since
  • Source user set has to have message posting permission in the source channel at the time of use
  • Event type validity checks are done based on the storage channel
  • Target user set has to have read messages permission in the source channel at the time of use
  • Each routing rule is considered immutable once created, except for valid until timestamp, which can be set to any future time while the routing rule is still in effect

A routing rule can only be deleted in either of the following cases:

  • none of the source channels are present
  • none of the storage channels are present
  • none of the sink channels are present
  • the routing rule is not in effect AND no messages are affected by deletion of the routing rule

feature request: Make "Permissions" API objects consistent

What do you want to see?

There are multiple places in the API spec where an object representing a role's permissions (allowed and denied) is expressed, but I've noticed an inconsistency: Sometimes the fields are allow and deny (example: Set Role Permission), and sometimes they are a and d (example: Create Role). Could this be fixed up and unified in one way or another? It would make some API wrappers' lives easier not needing to include special JSON deserialization logic to handle the same model with differing field names, or having to include redundant model code. ๐Ÿ˜„

feature request: Make GET channels/{target}/messages use request body instead of query parameters

What do you want to see?

At the moment, Search for Messages (POST channels/{target}/search) utilizes nearly identical parameters to Fetch Messages (GET channels/{target}/messages), but the former uses a JSON request body whereas the latter uses query parameters, which in my personal opinion is a worse way to build requests especially with as many parameters as the methods allow.

Would it be possible to make both endpoints use the same request body type (specifically a JSON request body instead of query parameters) for consistency? This would obviously be a breaking change for clients and API wrappers which depend on this functionality, but I think it would be better to get that over with sooner rather than later.

Create isBot property in User interface

It would be a great idea to create one more property in the User interface, where it returns a Boolean value to check if the user is a bot.

export interface User {
    isBot: Boolean;
}

So it would be simpler to identify the user type directly by the revolt.js bookstore.

My Revolt Profile: TiaGoiNsaNy

bug: missing files and types when installing

When the package is installed there is only one index.js file left in the dist folder with no type files and no other files in the dist folder.

As currently seen:

image

As it should look:

image

bug: Focus isn't allowed in api.patch "/users/@me"

What happened?

So apparently the focus presence isn't defined in the api.patch function, returning a typeerror since it doesn't match "Online" | "Idle" | "Busy" | "Invisible" | undefined | null.

Screenshot_20220930_071417

But when testing, It does indeed change the status to Focus.

Screenshot_20220930_071500

bug: Usage to complete MFA on login doesn't work as documented

What happened?

On this page:
https://developers.revolt.chat/api/#tag/Session/operation/login_login

On the first request sample, where it shows what to do to fufil mfa as copied here:

{
  "mfa_ticket": "string",
  "mfa_response": {
    "password": "string"
  },
  "friendly_name": "string"
}

It'd throw error code 400 (Bad Request)

Turns out when inspecting network traffic from Revite, where it'd say password, it actually uses a field named "totp_code", which did work as intended and generated a new login session.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.