mirror of
https://github.com/stoatchat/javascript-client-api.git
synced 2026-08-26 12:35:48 -04:00
Start writing Typescript defns.
This commit is contained in:
+3
-2
@@ -1,3 +1,4 @@
|
||||
OpenAPI.json
|
||||
node_modules
|
||||
out
|
||||
*.old
|
||||
dist
|
||||
out
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
FORMAT: 1A
|
||||
HOST: https://api.revolt.chat
|
||||
|
||||
# Revolt
|
||||
|
||||
# Data Structures
|
||||
|
||||
## RelationshipStatus (enum)
|
||||
+ None
|
||||
+ User
|
||||
+ Friend
|
||||
+ Outgoing
|
||||
+ Incoming
|
||||
+ Blocked
|
||||
+ BlockedOther
|
||||
|
||||
## Relationship (object)
|
||||
+ _id: 01AN4Z07BY79KA1307SR9X4MV3 (string, required)
|
||||
+ status (RelationshipStatus, required) - Explain in TODO.
|
||||
|
||||
## Presence (enum)
|
||||
+ Online
|
||||
+ Idle
|
||||
+ Busy
|
||||
+ Invisible
|
||||
|
||||
## UserStatus (object)
|
||||
+ text (string)
|
||||
+ presence (Presence)
|
||||
|
||||
## User (object)
|
||||
+ _id: 01AN4Z07BY79KA1307SR9X4MV3 (string, required)
|
||||
+ username: insert (string, required)
|
||||
+ avatar (File)
|
||||
+ relations (array[Relationship])
|
||||
+ badges (number) - This is a bitfield, see TODO.
|
||||
+ status (UserStatus) - User's status and presence.
|
||||
+ relationship (RelationshipStatus, required) - Explain in TODO.
|
||||
+ online (boolean)
|
||||
|
||||
|
||||
|
||||
# Group Users
|
||||
|
||||
### Fetch User [GET /users/{id}]
|
||||
Fetch a user by their ID.
|
||||
|
||||
+ Parameters
|
||||
+ id - User ID
|
||||
|
||||
+ Request
|
||||
+ Headers
|
||||
x-user-id: 01AN4Z07BY79KA1307SR9X4MV3
|
||||
x-session-token: L305OPR7FkGu28WUSEygHiHW6L7wiiU_EFu8IkvEwlZQ7Y_jkJSfr_z6Sc6_hjns
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (User)
|
||||
|
||||
### Edit User [PATCH /users/@me]
|
||||
Edit your user object.
|
||||
|
||||
+ Request (application/json)
|
||||
|
||||
+ Attributes
|
||||
+ status (UserStatus)
|
||||
+ profile (object)
|
||||
+ content (string) - Profile content, has a maximum length of 2000.
|
||||
+ background (string) - TODO
|
||||
+ avatar (string) - TODO
|
||||
+ remove (enum)
|
||||
+ ProfileContent
|
||||
+ ProfileBackground
|
||||
+ StatusText
|
||||
+ Avatar
|
||||
|
||||
+ Headers
|
||||
x-user-id: 01AN4Z07BY79KA1307SR9X4MV3
|
||||
x-session-token: L305OPR7FkGu28WUSEygHiHW6L7wiiU_EFu8IkvEwlZQ7Y_jkJSfr_z6Sc6_hjns
|
||||
|
||||
+ Response 200
|
||||
|
||||
### Change Username [PATCH /users/@me/username]
|
||||
Change your username.
|
||||
|
||||
+ Request (application/json)
|
||||
|
||||
+ Attributes
|
||||
+ username (string)
|
||||
+ password (string)
|
||||
|
||||
+ Schema
|
||||
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {
|
||||
"type": "string",
|
||||
"minLength": 2,
|
||||
"maxLength": 32,
|
||||
"pattern": "^[a-zA-Z0-9_.]+$"
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"minLength": 8,
|
||||
"maxLength": 72
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ Headers
|
||||
x-user-id: 01AN4Z07BY79KA1307SR9X4MV3
|
||||
x-session-token: L305OPR7FkGu28WUSEygHiHW6L7wiiU_EFu8IkvEwlZQ7Y_jkJSfr_z6Sc6_hjns
|
||||
|
||||
+ Response 200
|
||||
|
||||
### Fetch profile [GET /users/{id}/profile]
|
||||
Returns a user's profile.
|
||||
|
||||
Requires `ViewProfile`.
|
||||
|
||||
+ Parameters
|
||||
+ id - User ID
|
||||
|
||||
+ Response 200 (image/png)
|
||||
|
||||
### Fetch default avatar [GET /users/{id}/default_avatar]
|
||||
Returns a default avatar based on given id.
|
||||
|
||||
+ Parameters
|
||||
+ id - User ID
|
||||
|
||||
+ Response 200 (image/png)
|
||||
# Data Structures
|
||||
|
||||
## SavedMessagesChannel (object)
|
||||
+ _id: 01AN4Z07BY79KA1307SR9X4MV3 (string, required)
|
||||
+ channel_type: SavedMessages (enum, required)
|
||||
+ user (string, required)
|
||||
|
||||
## DirectMessageChannel (object)
|
||||
+ _id: 01AN4Z07BY79KA1307SR9X4MV3 (string, required)
|
||||
+ channel_type: DirectMessage (enum, required)
|
||||
+ active (boolean, required)
|
||||
|
||||
# Group Channels
|
||||
|
||||
### Fetch Channel [GET /channels/{id}]
|
||||
Fetch a channel by its ID.
|
||||
|
||||
+ Parameters
|
||||
+ id - Channel ID
|
||||
|
||||
+ Request
|
||||
+ Headers
|
||||
x-user-id: 01AN4Z07BY79KA1307SR9X4MV3
|
||||
x-session-token: L305OPR7FkGu28WUSEygHiHW6L7wiiU_EFu8IkvEwlZQ7Y_jkJSfr_z6Sc6_hjns
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (enum[SavedMessagesChannel, DirectMessageChannel])
|
||||
# Data Structures
|
||||
|
||||
## File (object)
|
||||
+ _id: 01AN4Z07BY79KA1307SR9X4MV3 (string, required)
|
||||
+ tag: (string)
|
||||
+9
-10
@@ -5,17 +5,16 @@
|
||||
"repository": "https://gitlab.insrt.uk/revolt/api.git",
|
||||
"author": "Paul <paulmakles@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"aglio": "^2.3.0",
|
||||
"apib2swagger": "^1.12.0",
|
||||
"hercule": "^5.1.3",
|
||||
"sirv-cli": "^1.0.12"
|
||||
},
|
||||
"scripts": {
|
||||
"generate:apib": "hercule src/blueprint.md -o API.apib",
|
||||
"generate:html": "aglio -i API.apib -o out/index.html",
|
||||
"generate:openapi": "apib2swagger -i API.apib -o OpenAPI.json",
|
||||
"build": "yarn generate:apib && yarn generate:html && yarn generate:openapi",
|
||||
"build:generator": "tsc",
|
||||
"start:generator": "node dist",
|
||||
"watch:generator": "tsc-watch --onSuccess \"node dist\"",
|
||||
"preview": "sirv out"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsc-watch": "^4.4.0",
|
||||
"sirv-cli": "^1.0.12",
|
||||
"typescript": "^4.3.5",
|
||||
"typescript-json-schema": "^0.50.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
+ Headers
|
||||
x-user-id: :[ULID](../templates/ulid.md)
|
||||
x-session-token: :[Token](../templates/token.md)
|
||||
@@ -1,8 +0,0 @@
|
||||
FORMAT: 1A
|
||||
HOST: https://api.revolt.chat
|
||||
|
||||
# Revolt
|
||||
|
||||
:[Users](resources/users.md)
|
||||
:[Channels](resources/channels.md)
|
||||
:[Autumn](resources/autumn.md)
|
||||
@@ -1 +0,0 @@
|
||||
+ _id: :[ULID](../templates/ulid.md) (string, required)
|
||||
@@ -0,0 +1,20 @@
|
||||
import { resolve } from "path";
|
||||
import * as TJS from "typescript-json-schema";
|
||||
|
||||
const program = TJS.getProgramFromFiles(
|
||||
[
|
||||
resolve("types/January.ts"),
|
||||
resolve("types/Autumn.ts"),
|
||||
resolve("types/Users.ts"),
|
||||
resolve("types/Channels.ts")
|
||||
],
|
||||
{ }
|
||||
);
|
||||
|
||||
const generator = TJS.buildGenerator(program, {
|
||||
required: true,
|
||||
// titles: true
|
||||
});
|
||||
|
||||
import { inspect } from 'util';
|
||||
console.log(inspect(generator?.getSchemaForSymbol("Message"), false, 10, true));
|
||||
@@ -1,5 +0,0 @@
|
||||
# Data Structures
|
||||
|
||||
## File (object)
|
||||
:[_id](../fields/_id.md)
|
||||
+ tag: (string)
|
||||
@@ -1,25 +0,0 @@
|
||||
# Data Structures
|
||||
|
||||
## SavedMessagesChannel (object)
|
||||
:[_id](../fields/_id.md)
|
||||
+ channel_type: SavedMessages (enum, required)
|
||||
+ user (string, required)
|
||||
|
||||
## DirectMessageChannel (object)
|
||||
:[_id](../fields/_id.md)
|
||||
+ channel_type: DirectMessage (enum, required)
|
||||
+ active (boolean, required)
|
||||
|
||||
# Group Channels
|
||||
|
||||
### Fetch Channel [GET /channels/{id}]
|
||||
Fetch a channel by its ID.
|
||||
|
||||
+ Parameters
|
||||
+ id - Channel ID
|
||||
|
||||
+ Request
|
||||
:[rAuth](../auth/headers.md)
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (enum[SavedMessagesChannel, DirectMessageChannel])
|
||||
@@ -1,113 +0,0 @@
|
||||
# Data Structures
|
||||
|
||||
## RelationshipStatus (enum)
|
||||
+ None
|
||||
+ User
|
||||
+ Friend
|
||||
+ Outgoing
|
||||
+ Incoming
|
||||
+ Blocked
|
||||
+ BlockedOther
|
||||
|
||||
## Relationship (object)
|
||||
:[_id](../fields/_id.md)
|
||||
+ status (RelationshipStatus, required) - Explain in TODO.
|
||||
|
||||
## Presence (enum)
|
||||
+ Online
|
||||
+ Idle
|
||||
+ Busy
|
||||
+ Invisible
|
||||
|
||||
## UserStatus (object)
|
||||
+ text (string)
|
||||
+ presence (Presence)
|
||||
|
||||
## User (object)
|
||||
:[_id](../fields/_id.md)
|
||||
+ username: insert (string, required)
|
||||
+ avatar (File)
|
||||
+ relations (array[Relationship])
|
||||
+ badges (number) - This is a bitfield, see TODO.
|
||||
+ status (UserStatus) - User's status and presence.
|
||||
+ relationship (RelationshipStatus, required) - Explain in TODO.
|
||||
+ online (boolean)
|
||||
|
||||
|
||||
|
||||
# Group Users
|
||||
|
||||
### Fetch User [GET /users/{id}]
|
||||
Fetch a user by their ID.
|
||||
|
||||
+ Parameters
|
||||
+ id - User ID
|
||||
|
||||
+ Request
|
||||
:[rAuth](../auth/headers.md)
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (User)
|
||||
|
||||
### Edit User [PATCH /users/@me]
|
||||
Edit your user object.
|
||||
|
||||
+ Request (application/json)
|
||||
|
||||
+ Attributes
|
||||
+ status (UserStatus)
|
||||
+ profile (object)
|
||||
+ content (string) - Profile content, has a maximum length of 2000.
|
||||
+ background (string) - TODO
|
||||
+ avatar (string) - TODO
|
||||
+ remove (enum)
|
||||
+ ProfileContent
|
||||
+ ProfileBackground
|
||||
+ StatusText
|
||||
+ Avatar
|
||||
|
||||
:[rAuth](../auth/headers.md)
|
||||
|
||||
+ Response 200
|
||||
|
||||
### Change Username [PATCH /users/@me/username]
|
||||
Change your username.
|
||||
|
||||
+ Request (application/json)
|
||||
|
||||
+ Attributes
|
||||
+ username (string)
|
||||
+ password (string)
|
||||
|
||||
+ Schema
|
||||
|
||||
{
|
||||
:[schema](../schema/$schema.md),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
:[username](../schema/username.md),
|
||||
:[password](../schema/password.md)
|
||||
}
|
||||
}
|
||||
|
||||
:[rAuth](../auth/headers.md)
|
||||
|
||||
+ Response 200
|
||||
|
||||
### Fetch profile [GET /users/{id}/profile]
|
||||
Returns a user's profile.
|
||||
|
||||
Requires `ViewProfile`.
|
||||
|
||||
+ Parameters
|
||||
+ id - User ID
|
||||
|
||||
+ Response 200 (image/png)
|
||||
|
||||
### Fetch default avatar [GET /users/{id}/default_avatar]
|
||||
Returns a default avatar based on given id.
|
||||
|
||||
+ Parameters
|
||||
+ id - User ID
|
||||
|
||||
+ Response 200 (image/png)
|
||||
@@ -1 +0,0 @@
|
||||
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||
@@ -1,5 +0,0 @@
|
||||
"password": {
|
||||
"type": "string",
|
||||
"minLength": 8,
|
||||
"maxLength": 72
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
"username": {
|
||||
"type": "string",
|
||||
"minLength": 2,
|
||||
"maxLength": 32,
|
||||
"pattern": "^[a-zA-Z0-9_.]+$"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
L305OPR7FkGu28WUSEygHiHW6L7wiiU_EFu8IkvEwlZQ7Y_jkJSfr_z6Sc6_hjns
|
||||
@@ -1 +0,0 @@
|
||||
01AN4Z07BY79KA1307SR9X4MV3
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Attachment ID
|
||||
* @minLength 1
|
||||
* @maxLength 128
|
||||
*/
|
||||
export type AttachmentId = string;
|
||||
|
||||
export type AttachmentMetadata = (
|
||||
{ type: 'File' } |
|
||||
{ type: 'Text' } |
|
||||
{ type: 'Audio' } |
|
||||
{ type: 'Image', width: number, height: number } |
|
||||
{ type: 'Video', width: number, height: number }
|
||||
);
|
||||
|
||||
/**
|
||||
* Attachment tag
|
||||
*/
|
||||
export type AttachmentTag = 'attachments' | 'avatars' | 'backgrounds' | 'icons' | 'banners';
|
||||
|
||||
export type Attachment = {
|
||||
_id: AttachmentId
|
||||
|
||||
tag: AttachmentTag
|
||||
|
||||
/**
|
||||
* File size (in bytes)
|
||||
*/
|
||||
size: number
|
||||
|
||||
/**
|
||||
* File name
|
||||
*/
|
||||
filename: string
|
||||
|
||||
/**
|
||||
* Metadata
|
||||
*/
|
||||
metadata: AttachmentMetadata
|
||||
|
||||
/**
|
||||
* Content type
|
||||
*/
|
||||
content_type: string,
|
||||
};
|
||||
@@ -0,0 +1,212 @@
|
||||
import type { Attachment } from "./Autumn"
|
||||
import type { Id, Nonce } from "./_common"
|
||||
import type { Embed } from "./January"
|
||||
|
||||
/**
|
||||
* Last message sent in channel
|
||||
*/
|
||||
export type LastMessage = {
|
||||
/**
|
||||
* Message ID
|
||||
*/
|
||||
_id: Id
|
||||
|
||||
/**
|
||||
* Author ID
|
||||
*/
|
||||
author: Id
|
||||
|
||||
/**
|
||||
* Short content of message
|
||||
* @maxLength 128
|
||||
*/
|
||||
short: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Saved Messages channel has only one participant, the user who created it.
|
||||
*/
|
||||
export type SavedMessagesChannel = {
|
||||
/**
|
||||
* Channel Id
|
||||
*/
|
||||
_id: Id
|
||||
|
||||
channel_type: 'SavedMessages'
|
||||
|
||||
/**
|
||||
* User Id
|
||||
*/
|
||||
user: Id
|
||||
}
|
||||
|
||||
export type DirectMessageChannel = {
|
||||
/**
|
||||
* Channel Id
|
||||
*/
|
||||
_id: Id
|
||||
|
||||
channel_type: 'DirectMessage'
|
||||
|
||||
/**
|
||||
* Whether this DM is active
|
||||
*/
|
||||
active: boolean
|
||||
|
||||
/**
|
||||
* List of user IDs who are participating in this DM
|
||||
*/
|
||||
recipients: Id[]
|
||||
|
||||
last_message: LastMessage
|
||||
}
|
||||
|
||||
export type GroupChannel = {
|
||||
/**
|
||||
* Channel Id
|
||||
*/
|
||||
_id: Id,
|
||||
|
||||
channel_type: 'Group',
|
||||
|
||||
/**
|
||||
* List of user IDs who are participating in this group
|
||||
*/
|
||||
recipients: Id[],
|
||||
|
||||
/**
|
||||
* Group name
|
||||
*/
|
||||
name: string,
|
||||
|
||||
/**
|
||||
* User ID of group owner
|
||||
*/
|
||||
owner: Id,
|
||||
|
||||
/**
|
||||
* Group description
|
||||
*/
|
||||
description?: string,
|
||||
|
||||
last_message: LastMessage,
|
||||
|
||||
/**
|
||||
* Group icon
|
||||
*/
|
||||
icon?: Attachment,
|
||||
|
||||
/**
|
||||
* Permissions given to group members
|
||||
*/
|
||||
permissions?: number
|
||||
}
|
||||
|
||||
export type ServerChannel = {
|
||||
/**
|
||||
* Channel Id
|
||||
*/
|
||||
_id: Id
|
||||
|
||||
/**
|
||||
* Server Id
|
||||
*/
|
||||
server: Id
|
||||
|
||||
/**
|
||||
* Channel name
|
||||
*/
|
||||
name: string
|
||||
|
||||
/**
|
||||
* Channel description
|
||||
*/
|
||||
description: string
|
||||
|
||||
icon?: Attachment
|
||||
|
||||
/**
|
||||
* Permissions given to all users
|
||||
*/
|
||||
default_permissions?: number
|
||||
|
||||
/**
|
||||
* Permissions given to roles
|
||||
*/
|
||||
role_permissions?: {
|
||||
[key: string]: number
|
||||
}
|
||||
}
|
||||
|
||||
export type TextChannel = ServerChannel & {
|
||||
channel_type: 'TextChannel'
|
||||
|
||||
last_message: string
|
||||
}
|
||||
|
||||
export type VoiceChannel = ServerChannel & {
|
||||
channel_type: 'VoiceChannel'
|
||||
}
|
||||
|
||||
export type Channel = (SavedMessagesChannel | DirectMessageChannel | GroupChannel | TextChannel | VoiceChannel) & { nonce?: string }
|
||||
|
||||
export type Message = {
|
||||
/**
|
||||
* Message Id
|
||||
*/
|
||||
_id: Id
|
||||
|
||||
nonce?: Nonce
|
||||
|
||||
/**
|
||||
* Channel Id
|
||||
*/
|
||||
channel: Id
|
||||
|
||||
/**
|
||||
* Author Id
|
||||
*/
|
||||
author: Id
|
||||
|
||||
/**
|
||||
* Message content, can be an object *only* if sent by the system user.
|
||||
*/
|
||||
content: string | SystemMessage
|
||||
|
||||
/**
|
||||
* Message attachments
|
||||
*/
|
||||
attachments?: Attachment[]
|
||||
|
||||
/**
|
||||
* Unix timestamp of when message was last edited
|
||||
*/
|
||||
edited?: { $date: string }
|
||||
|
||||
/**
|
||||
* Message link embeds
|
||||
*/
|
||||
embeds?: Embed[]
|
||||
|
||||
/**
|
||||
* Array of user IDs mentioned in message
|
||||
*/
|
||||
mentions?: Id[]
|
||||
|
||||
/**
|
||||
* Array of message IDs replied to
|
||||
*/
|
||||
replies?: Id[]
|
||||
}
|
||||
|
||||
export type SystemMessage =
|
||||
| { type: "text"; content: string }
|
||||
| { type: "user_added"; id: Id; by: Id }
|
||||
| { type: "user_remove"; id: Id; by: Id }
|
||||
| { type: "user_joined"; id: Id }
|
||||
| { type: "user_left"; id: Id }
|
||||
| { type: "user_kicked"; id: Id }
|
||||
| { type: "user_banned"; id: Id }
|
||||
| { type: "channel_renamed"; name: string, by: Id }
|
||||
| { type: "channel_description_changed"; by: Id }
|
||||
| { type: "channel_icon_changed"; by: Id };
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* An embedded image
|
||||
*/
|
||||
export type EmbedImage = {
|
||||
url: string
|
||||
|
||||
width: number
|
||||
|
||||
height: number
|
||||
|
||||
size: 'Large' | 'Preview'
|
||||
}
|
||||
|
||||
/**
|
||||
* An embedded video
|
||||
*/
|
||||
export type EmbedVideo = {
|
||||
url: string
|
||||
|
||||
width: number
|
||||
|
||||
height: number
|
||||
}
|
||||
|
||||
/**
|
||||
* A special 3rd party embed
|
||||
*/
|
||||
export type EmbedSpecial = (
|
||||
{ type: 'None' } |
|
||||
{ type: 'YouTube', id: string } |
|
||||
{ type: 'Twitch', content_type: 'Channel' | 'Video' | 'Clip', id: string } |
|
||||
{ type: 'Spotify', content_type: string, id: string } |
|
||||
{ type: 'Soundcloud' } |
|
||||
{ type: 'Bandcamp', content_type: 'Album' | 'Track', id: string }
|
||||
)
|
||||
|
||||
/**
|
||||
* Message embed
|
||||
*/
|
||||
export type Embed = (
|
||||
{
|
||||
type: 'None'
|
||||
} | {
|
||||
type: 'Website'
|
||||
|
||||
url?: string
|
||||
|
||||
special?: EmbedSpecial
|
||||
|
||||
title?: string
|
||||
|
||||
description?: string
|
||||
|
||||
image?: EmbedImage
|
||||
|
||||
video?: EmbedVideo
|
||||
|
||||
site_name?: string
|
||||
|
||||
icon_url?: string
|
||||
|
||||
color?: string
|
||||
} | ({
|
||||
type: 'Image'
|
||||
} & EmbedImage)
|
||||
);
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
import type { Attachment } from './Autumn';
|
||||
import type { Id } from './_common';
|
||||
|
||||
/**
|
||||
* Your relationship with the user
|
||||
*/
|
||||
export enum RelationshipStatus {
|
||||
None = "None",
|
||||
User = "User",
|
||||
Friend = "Friend",
|
||||
Outgoing = "Outgoing",
|
||||
Incoming = "Incoming",
|
||||
Blocked = "Blocked",
|
||||
BlockedOther = "BlockedOther"
|
||||
}
|
||||
|
||||
export type Relationship = {
|
||||
/**
|
||||
* Other user's ID
|
||||
*/
|
||||
_id: Id
|
||||
|
||||
status: Relationship
|
||||
};
|
||||
|
||||
/**
|
||||
* User presence
|
||||
*/
|
||||
export enum Presence {
|
||||
Online = "Online",
|
||||
Idle = "Idle",
|
||||
Busy = "Busy",
|
||||
Invisible = "Invisible"
|
||||
}
|
||||
|
||||
export type Status = {
|
||||
/**
|
||||
* Custom status text
|
||||
* @minLength 1
|
||||
* @maxLength 128
|
||||
*/
|
||||
text?: string
|
||||
|
||||
presence?: Presence
|
||||
}
|
||||
|
||||
export enum Badges {
|
||||
Developer = 1,
|
||||
Translator = 2,
|
||||
Supporter = 4,
|
||||
ResponsibleDisclosure = 8,
|
||||
RevoltTeam = 16,
|
||||
EarlyAdopter = 256,
|
||||
}
|
||||
|
||||
export interface User {
|
||||
/**
|
||||
* User ID
|
||||
*/
|
||||
_id: Id
|
||||
|
||||
/**
|
||||
* @minLength 2
|
||||
* @maxLength 32
|
||||
* @pattern ^[a-zA-Z0-9_.]+$
|
||||
*/
|
||||
username: string
|
||||
|
||||
avatar?: Attachment
|
||||
|
||||
/**
|
||||
* Relationships with other known users
|
||||
* Only present if fetching self
|
||||
*/
|
||||
relations?: Relationship[]
|
||||
|
||||
/**
|
||||
* Bitfield of user's badges
|
||||
*/
|
||||
badges?: number
|
||||
|
||||
status?: Status
|
||||
|
||||
/**
|
||||
* Relationship to user
|
||||
*/
|
||||
relationship?: Relationship
|
||||
|
||||
/**
|
||||
* Whether the user is online
|
||||
*/
|
||||
online?: boolean
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
/**
|
||||
* @minLength 0
|
||||
* @maxLength 2000
|
||||
*/
|
||||
content?: string
|
||||
|
||||
background?: Attachment
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Id
|
||||
* @pattern [0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}
|
||||
*/
|
||||
export type Id = string;
|
||||
|
||||
/**
|
||||
* Nonce value, prefer to use ULIDs here for better feature support.
|
||||
* @minLength 1
|
||||
* @maxLength 36
|
||||
*/
|
||||
export type Nonce = string;
|
||||
Reference in New Issue
Block a user