New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@satorijs/core

Package Overview
Dependencies
Maintainers
1
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@satorijs/core - npm Package Compare versions

Comparing version 3.0.0-alpha.2 to 3.0.0-rc.0

403

lib/index.d.ts

@@ -1,206 +0,42 @@

/// <reference types="ws" />
import * as cordis from 'cordis';
import Element from '@satorijs/element';
import { Dict, Awaitable } from 'cosmokit';
import WebSocket from 'ws';
import { Event, GuildMember, Message, User, SendOptions, Login, Methods, Status, WebSocket } from '@satorijs/protocol';
import h from '@satorijs/element';
import { Awaitable, Dict } from 'cosmokit';
import Schema from 'schemastery';
import Logger from 'reggol';
import Quester from 'cordis-axios';
export { Universal as Satori };
export namespace Universal {
interface Field {
name: string;
declare module '@satorijs/protocol' {
interface SendOptions {
session?: Session;
}
interface Method {
name: string;
fields: Field[];
}
const Methods: Dict<Method>;
interface List<T> {
data: T[];
next?: string;
}
interface Methods {
sendMessage(channelId: string, content: Element.Fragment, guildId?: string, options?: SendOptions): Promise<string[]>;
sendPrivateMessage(userId: string, content: Element.Fragment, options?: SendOptions): Promise<string[]>;
getMessage(channelId: string, messageId: string): Promise<Message>;
getMessageList(channelId: string, next?: string): Promise<List<Message>>;
getMessageIter(channelId: string): AsyncIterable<Message>;
editMessage(channelId: string, messageId: string, content: Element.Fragment): Promise<void>;
deleteMessage(channelId: string, messageId: string): Promise<void>;
createReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
deleteReaction(channelId: string, messageId: string, emoji: string, userId?: string): Promise<void>;
clearReaction(channelId: string, messageId: string, emoji?: string): Promise<void>;
getReactionList(channelId: string, messageId: string, emoji: string, next?: string): Promise<List<User>>;
getReactionIter(channelId: string, messageId: string, emoji: string): AsyncIterable<User>;
getSelf(): Promise<User>;
getUser(userId: string, guildId?: string): Promise<User>;
getFriendList(next?: string): Promise<List<User>>;
getFriendIter(): AsyncIterable<User>;
deleteFriend(userId: string): Promise<void>;
getGuild(guildId: string): Promise<Guild>;
getGuildList(next?: string): Promise<List<Guild>>;
getGuildIter(): AsyncIterable<Guild>;
getGuildMember(guildId: string, userId: string): Promise<GuildMember>;
getGuildMemberList(guildId: string, next?: string): Promise<List<GuildMember>>;
getGuildMemberIter(guildId: string): AsyncIterable<GuildMember>;
kickGuildMember(guildId: string, userId: string, permanent?: boolean): Promise<void>;
muteGuildMember(guildId: string, userId: string, duration: number, reason?: string): Promise<void>;
setGuildMemberRole(guildId: string, userId: string, roleId: string): Promise<void>;
unsetGuildMemberRole(guildId: string, userId: string, roleId: string): Promise<void>;
getGuildRoleList(guildId: string, next?: string): Promise<List<GuildRole>>;
getGuildRoleIter(guildId: string): AsyncIterable<GuildRole>;
createGuildRole(guildId: string, data: Partial<GuildRole>): Promise<string>;
modifyGuildRole(guildId: string, roleId: string, data: Partial<GuildRole>): Promise<void>;
deleteGuildRole(guildId: string, roleId: string): Promise<void>;
getChannel(channelId: string, guildId?: string): Promise<Channel>;
getChannelList(guildId: string, next?: string): Promise<List<Channel>>;
getChannelIter(guildId: string): AsyncIterable<Channel>;
muteChannel(channelId: string, guildId?: string, enable?: boolean): Promise<void>;
handleFriendRequest(messageId: string, approve: boolean, comment?: string): Promise<void>;
handleGuildRequest(messageId: string, approve: boolean, comment?: string): Promise<void>;
handleGuildMemberRequest(messageId: string, approve: boolean, comment?: string): Promise<void>;
updateCommands(commands: Command[]): Promise<void>;
}
interface Channel {
id: string;
name?: string;
parentId?: string;
/** @deprecated */
channelId?: string;
/** @deprecated */
channelName?: string;
}
interface Guild {
id: string;
name: string;
/** @deprecated */
guildId?: string;
/** @deprecated */
guildName?: string;
}
interface GuildRole {
id: string;
name: string;
color: number;
position: number;
permissions: bigint;
hoist: boolean;
mentionable: boolean;
}
interface User {
id: string;
name?: string;
nick?: string;
/** @deprecated */
userId?: string;
/** @deprecated */
username?: string;
avatar?: string;
discriminator?: string;
isBot?: boolean;
}
interface GuildMember {
user: User;
title?: string;
nickname?: string;
avatar?: string;
roles?: string[];
anonymous?: string;
}
/** @deprecated */
type Author = Partial<Omit<GuildMember, 'user'> & User>;
interface Message {
messageId?: string;
channelId?: string;
guildId?: string;
userId?: string;
content?: string;
elements?: Element[];
timestamp?: number;
author?: Author;
member?: Partial<GuildMember>;
quote?: Message;
isDirect?: boolean;
/** @deprecated please use `isDirect` instead */
subtype?: string;
}
interface Command {
name: string;
aliases: string[];
description: Dict<string>;
arguments: Command.Argument[];
options: Command.Option[];
children: Command[];
}
namespace Command {
interface Argument {
name: string;
description: Dict<string>;
type: string;
required: boolean;
}
interface Option {
name: string;
description: Dict<string>;
type: string;
required: boolean;
}
}
interface Argv {
name: string;
arguments: any[];
options: Dict;
}
interface EventData {
role?: GuildRole;
argv?: Argv;
channel?: Channel;
guild?: Guild;
member?: GuildMember;
user?: User;
}
}
export interface SendOptions {
session?: Session;
linkPreview?: boolean;
export interface Session {
type: string;
subtype: string;
subsubtype: string;
selfId: string;
platform: string;
timestamp: number;
userId: string;
channelId: string;
guildId: string;
messageId: string;
operatorId: string;
roleId: string;
quote: Message;
}
export interface Session extends Session.Payload, Satori.Session {
}
export namespace Session {
interface Payload {
isDirect?: boolean;
platform?: string;
selfId?: string;
type?: string;
/** @deprecated */
subtype?: string;
/** @deprecated */
subsubtype?: string;
messageId?: string;
channelId?: string;
guildId?: string;
userId?: string;
content?: string;
elements?: Element[];
timestamp?: number;
author?: Universal.Author;
member?: Universal.GuildMember;
quote?: Universal.Message;
channelName?: string;
guildName?: string;
operatorId?: string;
targetId?: string;
duration?: number;
roleId?: string;
data?: Universal.EventData;
locales?: string[];
}
}
export class Session {
static counter: number;
id: number;
bot: Bot;
app: Context['root'];
constructor(bot: Bot, payload?: Partial<Session.Payload>);
event: Event;
locales: string[];
constructor(bot: Bot, payload: Partial<Event>);
initialize(): void;
/** @deprecated */
get data(): Event;
get isDirect(): boolean;
set isDirect(value: boolean);
get author(): GuildMember & User;
get uid(): string;

@@ -211,7 +47,11 @@ get gid(): string;

get sid(): string;
get content(): string;
set content(value: string);
transform(elements: Element[]): Promise<Element[]>;
toJSON(): Session.Payload;
get elements(): h[];
set elements(value: h[]);
get content(): string | undefined;
set content(value: string | undefined);
setInternal(type: string, data: any): void;
transform(elements: h[]): Promise<h[]>;
toJSON(): Event;
}
export function defineAccessor(prototype: {}, name: string, keys: string[]): void;
export abstract class MessageEncoder<B extends Bot = Bot> {

@@ -223,3 +63,3 @@ bot: B;

errors: Error[];
results: Session[];
results: Message[];
session: Session;

@@ -229,12 +69,13 @@ constructor(bot: B, channelId: string, guildId?: string, options?: SendOptions);

abstract flush(): Promise<void>;
abstract visit(element: Element): Promise<void>;
render(elements: Element[], flush?: boolean): Promise<void>;
send(content: Element.Fragment): Promise<string[]>;
abstract visit(element: h): Promise<void>;
render(elements: h[], flush?: boolean): Promise<void>;
send(content: h.Fragment): Promise<Message[]>;
}
export { MessageEncoder as Modulator, MessageEncoder as Messenger };
export interface Bot extends Universal.Methods, Universal.User {
socket?: WebSocket;
export interface Bot extends Methods {
userId: string;
selfId: string;
internal: any;
}
export abstract class Bot<T extends Bot.Config = Bot.Config> {
export abstract class Bot<T = any> implements Login {
ctx: Context;

@@ -245,15 +86,17 @@ config: T;

static MessageEncoder?: new (bot: Bot, channelId: string, guildId?: string, options?: SendOptions) => MessageEncoder;
user: User;
isBot: boolean;
hidden: boolean;
platform: string;
selfId: string;
adapter?: Adapter<this>;
error?: Error;
protected context: Context;
protected _status: Bot.Status;
protected _status: Status;
constructor(ctx: Context, config: T);
get userId(): string;
set userId(value: string);
get status(): Bot.Status;
set status(value: Bot.Status);
update(login: Login): void;
dispose(): Promise<void>;
private dispatchLoginEvent;
dispatchUpdate(): void;
get status(): Status;
set status(value: Status);
get isActive(): boolean;

@@ -265,16 +108,13 @@ online(): void;

get sid(): string;
session(payload?: Partial<Session.Payload>): Session;
session(body?: Partial<Event>): Session;
dispatch(session: Session): void;
sendMessage(channelId: string, content: Fragment, guildId?: string, options?: SendOptions): Promise<string[]>;
sendPrivateMessage(channelId: string, content: Fragment, options?: SendOptions): Promise<string[]>;
sendPrivateMessage(userId: string, content: Fragment, options?: SendOptions): Promise<string[]>;
supports(name: string, session?: Partial<Session>): Promise<boolean>;
checkPermission(name: string, session: Partial<Session>): Promise<boolean>;
toJSON(): Login;
getLogin(): Promise<Login>;
/** @deprecated use `bot.getLogin()` instead */
getSelf(): Promise<User>;
}
export namespace Bot {
interface Config {
platform?: string;
selfId?: string;
}
type Status = 'offline' | 'online' | 'connect' | 'disconnect' | 'reconnect';
}
export interface Context {

@@ -284,3 +124,3 @@ internal: Internal;

}
export type Component = Element.Render<Awaitable<Element.Fragment>, Session>;
export type Component = h.Render<Awaitable<h.Fragment>, Session>;
export namespace Component {

@@ -300,37 +140,6 @@ interface Options {

export type { Fragment, Render } from '@satorijs/element';
export { Schema, Schema as z, Logger, Element as segment, Element, Element as h, Quester };
declare global {
namespace Satori {
type Genres = 'friend' | 'channel' | 'guild' | 'guild-member' | 'guild-role' | 'guild-file' | 'guild-emoji';
type Actions = 'added' | 'deleted' | 'updated';
interface Session {
}
interface Events extends Record<`${Genres}-${Actions}`, {}> {
'message': {};
'message-deleted': {};
'message-updated': {};
'message-pinned': {};
'message-unpinned': {};
'interaction/command': {};
'reaction-added': {};
'reaction-deleted': {};
'reaction-deleted/one': {};
'reaction-deleted/all': {};
'reaction-deleted/emoji': {};
'send': {};
'friend-request': {};
'guild-request': {};
'guild-member-request': {};
'guild-member/role': {};
'guild-member/ban': {};
'guild-member/nickname': {};
'notice/poke': {};
'notice/lucky-king': {};
'notice/honor': {};
'notice/honor/talkative': {};
'notice/honor/performer': {};
'notice/honor/emotion': {};
}
}
}
export { h, h as Element, h as segment };
export { Schema, Schema as z, Logger, Quester };
export * as Satori from '@satorijs/protocol';
export * as Universal from '@satorijs/protocol';
declare module 'cordis-axios' {

@@ -343,7 +152,35 @@ namespace Quester {

type EventCallback<T = void, R extends any[] = []> = (this: Session, session: Session, ...args: R) => T;
export interface Events<C extends Context = Context> extends cordis.Events<C>, Record<keyof Satori.Events, EventCallback> {
export interface Events<C extends Context = Context> extends cordis.Events<C> {
'internal/session'(session: Session): void;
'interaction/command'(session: Session): void;
'message'(session: Session): void;
'message-created'(session: Session): void;
'message-deleted'(session: Session): void;
'message-updated'(session: Session): void;
'message-pinned'(session: Session): void;
'message-unpinned'(session: Session): void;
'guild-added'(session: Session): void;
'guild-removed'(session: Session): void;
'guild-updated'(session: Session): void;
'guild-member-added'(session: Session): void;
'guild-member-removed'(session: Session): void;
'guild-member-updated'(session: Session): void;
'guild-role-created'(session: Session): void;
'guild-role-deleted'(session: Session): void;
'guild-role-updated'(session: Session): void;
'reaction-added'(session: Session): void;
'reaction-removed'(session: Session): void;
'login-added'(session: Session): void;
'login-removed'(session: Session): void;
'login-updated'(session: Session): void;
'friend-request'(session: Session): void;
'guild-request'(session: Session): void;
'guild-member-request'(session: Session): void;
'before-send': EventCallback<Awaitable<void | boolean>, [SendOptions]>;
'send'(session: Session): void;
/** @deprecated use `login-added` instead */
'bot-added'(client: Bot): void;
/** @deprecated use `login-removed` instead */
'bot-removed'(client: Bot): void;
/** @deprecated use `login-updated` instead */
'bot-status-updated'(client: Bot): void;

@@ -373,33 +210,37 @@ 'bot-connect'(client: Bot): Awaitable<void>;

export abstract class Adapter<T extends Bot = Bot> {
start(bot: T): Promise<void>;
stop(bot: T): Promise<void>;
static schema: boolean;
bots: T[];
connect(bot: T): Promise<void>;
disconnect(bot: T): Promise<void>;
fork(ctx: Context, bot: T): void;
}
export namespace Adapter {
abstract class Client<T extends Bot = Bot> extends Adapter<T> {
protected ctx: Context;
protected bot: T;
static schema: boolean;
static reusable: boolean;
constructor(ctx: Context, bot: T);
interface WsClientConfig {
retryLazy?: number;
retryTimes?: number;
retryInterval?: number;
}
abstract class Server<T extends Bot = Bot> extends Adapter<T> {
static schema: boolean;
bots: T[];
fork(ctx: Context, bot: T): void;
const WsClientConfig: Schema<WsClientConfig>;
abstract class WsClientBase<T extends Bot = Bot> extends Adapter<T> {
ctx: Context;
config: WsClientConfig;
protected socket: WebSocket;
protected abstract prepare(): Awaitable<WebSocket>;
protected abstract accept(socket: WebSocket): void;
protected abstract getActive(): boolean;
protected abstract setStatus(status: Status, error?: Error): void;
constructor(ctx: Context, config: WsClientConfig);
start(): Promise<void>;
stop(): Promise<void>;
}
namespace WsClient {
interface Config extends Bot.Config {
retryLazy?: number;
retryTimes?: number;
retryInterval?: number;
}
}
abstract class WsClient<T extends Bot<WsClient.Config>> extends Adapter.Client<T> {
abstract class WsClient<T extends Bot<WsClientConfig>> extends WsClientBase<T> {
bot: T;
static reusable: boolean;
static Config: Schema<Adapter.WsClient.Config>;
protected abstract prepare(bot: T): Awaitable<WebSocket>;
protected abstract accept(bot: T): void;
start(bot: T): Promise<void>;
stop(bot: T): Promise<void>;
static Config: Schema<WsClientConfig>;
constructor(ctx: Context, bot: T);
getActive(): boolean;
setStatus(status: Status, error?: Error): void;
connect(bot: T): Promise<void>;
disconnect(bot: T): Promise<void>;
}
}
{
"name": "@satorijs/core",
"description": "Core components of Satorijs",
"version": "3.0.0-alpha.2",
"version": "3.0.0-rc.0",
"main": "lib/index.cjs",

@@ -34,13 +34,14 @@ "module": "lib/index.mjs",

"devDependencies": {
"@types/ws": "^8.5.5"
"@types/ws": "^8.5.6"
},
"dependencies": {
"@satorijs/element": "^2.5.1",
"@satorijs/protocol": "^1.0.0",
"cordis": "^2.8.8",
"cordis-axios": "^3.3.0",
"cordis-axios": "^3.3.1",
"cosmokit": "^1.4.5",
"ws": "^8.13.0",
"ws": "^8.14.2",
"reggol": "^1.5.1",
"schemastery": "^3.13.0"
"schemastery": "^3.13.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc