@nerimity/nerimity.js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +39 -0
- package/build/Client.d.ts +75 -0
- package/build/Client.d.ts.map +1 -0
- package/build/Client.js +152 -0
- package/build/Client.js.map +1 -0
- package/build/EventNames.d.ts +46 -0
- package/build/EventNames.d.ts.map +1 -0
- package/build/EventNames.js +44 -0
- package/build/EventNames.js.map +1 -0
- package/build/RawData.d.ts +61 -0
- package/build/RawData.d.ts.map +1 -0
- package/build/RawData.js +18 -0
- package/build/RawData.js.map +1 -0
- package/build/example.d.ts +2 -0
- package/build/example.d.ts.map +1 -0
- package/build/example.js +12 -0
- package/build/example.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -0
- package/build/services/MessageService.d.ts +27 -0
- package/build/services/MessageService.d.ts.map +1 -0
- package/build/services/MessageService.js +56 -0
- package/build/services/MessageService.js.map +1 -0
- package/build/services/serviceEndpoints.d.ts +6 -0
- package/build/services/serviceEndpoints.d.ts.map +1 -0
- package/build/services/serviceEndpoints.js +13 -0
- package/build/services/serviceEndpoints.js.map +1 -0
- package/package.json +28 -0
- package/src/Client.ts +205 -0
- package/src/EventNames.ts +62 -0
- package/src/RawData.ts +63 -0
- package/src/example.ts +15 -0
- package/src/index.ts +2 -0
- package/src/services/MessageService.ts +80 -0
- package/src/services/serviceEndpoints.ts +10 -0
- package/tsconfig.json +109 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
'env': {
|
|
3
|
+
'browser': true,
|
|
4
|
+
'es2021': true,
|
|
5
|
+
'node': true
|
|
6
|
+
},
|
|
7
|
+
'extends': [
|
|
8
|
+
'eslint:recommended',
|
|
9
|
+
'plugin:@typescript-eslint/recommended'
|
|
10
|
+
],
|
|
11
|
+
'overrides': [
|
|
12
|
+
],
|
|
13
|
+
'parser': '@typescript-eslint/parser',
|
|
14
|
+
'parserOptions': {
|
|
15
|
+
'ecmaVersion': 'latest',
|
|
16
|
+
'sourceType': 'module'
|
|
17
|
+
},
|
|
18
|
+
'plugins': [
|
|
19
|
+
'@typescript-eslint'
|
|
20
|
+
],
|
|
21
|
+
'rules': {
|
|
22
|
+
'indent': [
|
|
23
|
+
'error',
|
|
24
|
+
4
|
|
25
|
+
],
|
|
26
|
+
'linebreak-style': [
|
|
27
|
+
'error',
|
|
28
|
+
'windows'
|
|
29
|
+
],
|
|
30
|
+
'quotes': [
|
|
31
|
+
'error',
|
|
32
|
+
'single'
|
|
33
|
+
],
|
|
34
|
+
'semi': [
|
|
35
|
+
'error',
|
|
36
|
+
'always'
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { Socket } from 'socket.io-client';
|
|
3
|
+
import { ClientEventMap } from './EventNames';
|
|
4
|
+
import { ChannelType, MessageType, RawChannel, RawMessage, RawUser } from './RawData';
|
|
5
|
+
export declare const Events: {
|
|
6
|
+
readonly Ready: "ready";
|
|
7
|
+
readonly MessageCreate: "messageCreate";
|
|
8
|
+
};
|
|
9
|
+
export declare class Client extends EventEmitter<ClientEventMap> {
|
|
10
|
+
socket: Socket;
|
|
11
|
+
token: string | undefined;
|
|
12
|
+
user: ClientUser | undefined;
|
|
13
|
+
channels: Channels;
|
|
14
|
+
constructor();
|
|
15
|
+
login(token: string): void;
|
|
16
|
+
}
|
|
17
|
+
export declare class Channels {
|
|
18
|
+
client: Client;
|
|
19
|
+
cache: Collection<string, AllChannel>;
|
|
20
|
+
constructor(client: Client);
|
|
21
|
+
setCache(rawChannel: RawChannel): void;
|
|
22
|
+
}
|
|
23
|
+
export type AllChannel = ServerChannel | Channel;
|
|
24
|
+
export declare class Channel {
|
|
25
|
+
client: Client;
|
|
26
|
+
id: string;
|
|
27
|
+
type: ChannelType;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
lastMessagedAt?: number;
|
|
30
|
+
constructor(client: Client, channel: RawChannel);
|
|
31
|
+
send(content: string): Promise<Message>;
|
|
32
|
+
toString(): string;
|
|
33
|
+
}
|
|
34
|
+
export declare class ServerChannel extends Channel {
|
|
35
|
+
createdById: string;
|
|
36
|
+
name: string;
|
|
37
|
+
serverId: string;
|
|
38
|
+
permissions: number;
|
|
39
|
+
categoryId?: string;
|
|
40
|
+
constructor(client: Client, channel: RawChannel);
|
|
41
|
+
}
|
|
42
|
+
export declare class Message {
|
|
43
|
+
client: Client;
|
|
44
|
+
id: string;
|
|
45
|
+
content?: string;
|
|
46
|
+
type: MessageType;
|
|
47
|
+
createdAt: number;
|
|
48
|
+
channelId: string;
|
|
49
|
+
channel: AllChannel;
|
|
50
|
+
user: User;
|
|
51
|
+
constructor(client: Client, message: RawMessage);
|
|
52
|
+
reply(content: string): Promise<Message>;
|
|
53
|
+
edit(content: string): Promise<Message>;
|
|
54
|
+
}
|
|
55
|
+
declare class User {
|
|
56
|
+
client: Client;
|
|
57
|
+
id: string;
|
|
58
|
+
avatar?: string;
|
|
59
|
+
banner?: string;
|
|
60
|
+
username: string;
|
|
61
|
+
hexColor: string;
|
|
62
|
+
tag: string;
|
|
63
|
+
badges: number;
|
|
64
|
+
joinedAt?: number;
|
|
65
|
+
constructor(client: Client, user: RawUser);
|
|
66
|
+
toString(): string;
|
|
67
|
+
}
|
|
68
|
+
declare class ClientUser extends User {
|
|
69
|
+
constructor(client: Client, user: RawUser);
|
|
70
|
+
}
|
|
71
|
+
declare class Collection<K, V> extends Map<K, V> {
|
|
72
|
+
constructor();
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=Client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":"AAAA,O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EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;CAQlD;AAGD,qBAAa,OAAO;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;gBACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAW/C,KAAK,CAAC,OAAO,EAAE,MAAM;IAGf,IAAI,CAAC,OAAO,EAAE,MAAM;CAU7B;AAID,cAAM,IAAI;IACN,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;gBACN,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IAazC,QAAQ;CAGX;AAED,cAAM,UAAW,SAAQ,IAAI;gBACb,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAG5C;AAGD,cAAM,UAAU,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;;CAIvC"}
|
package/build/Client.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Message = exports.ServerChannel = exports.Channel = exports.Channels = exports.Client = exports.Events = void 0;
|
|
7
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
8
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
9
|
+
const EventNames_1 = require("./EventNames");
|
|
10
|
+
const MessageService_1 = require("./services/MessageService");
|
|
11
|
+
exports.Events = EventNames_1.ClientEvents;
|
|
12
|
+
class Client extends eventemitter3_1.default {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.socket = (0, socket_io_client_1.io)('https://nerimity.com', {
|
|
16
|
+
transports: ['websocket'],
|
|
17
|
+
autoConnect: false,
|
|
18
|
+
});
|
|
19
|
+
this.channels = new Channels(this);
|
|
20
|
+
new EventHandlers(this);
|
|
21
|
+
}
|
|
22
|
+
login(token) {
|
|
23
|
+
this.token = token;
|
|
24
|
+
this.socket.connect();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Client = Client;
|
|
28
|
+
class EventHandlers {
|
|
29
|
+
constructor(client) {
|
|
30
|
+
this.client = client;
|
|
31
|
+
this.socket = client.socket;
|
|
32
|
+
client.socket.on(EventNames_1.SocketServerEvents.CONNECT, this.onConnect.bind(this));
|
|
33
|
+
client.socket.on(EventNames_1.SocketServerEvents.USER_AUTHENTICATED, this.onAuthenticated.bind(this));
|
|
34
|
+
client.socket.on(EventNames_1.SocketServerEvents.MESSAGE_CREATED, this.onMessageCreated.bind(this));
|
|
35
|
+
}
|
|
36
|
+
onConnect() {
|
|
37
|
+
this.socket.emit(EventNames_1.SocketClientEvents.AUTHENTICATE, { token: this.client.token });
|
|
38
|
+
}
|
|
39
|
+
onAuthenticated(payload) {
|
|
40
|
+
this.client.user = new ClientUser(this.client, payload.user);
|
|
41
|
+
for (let i = 0; i < payload.channels.length; i++) {
|
|
42
|
+
const rawChannel = payload.channels[i];
|
|
43
|
+
this.client.channels.setCache(rawChannel);
|
|
44
|
+
}
|
|
45
|
+
this.client.emit(EventNames_1.ClientEvents.Ready);
|
|
46
|
+
}
|
|
47
|
+
onMessageCreated(payload) {
|
|
48
|
+
const message = new Message(this.client, payload.message);
|
|
49
|
+
this.client.emit(EventNames_1.ClientEvents.MessageCreate, message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class Channels {
|
|
53
|
+
constructor(client) {
|
|
54
|
+
this.client = client;
|
|
55
|
+
this.cache = new Collection();
|
|
56
|
+
}
|
|
57
|
+
setCache(rawChannel) {
|
|
58
|
+
let channel;
|
|
59
|
+
if (rawChannel.serverId)
|
|
60
|
+
channel = new ServerChannel(this.client, rawChannel);
|
|
61
|
+
else
|
|
62
|
+
channel = new Channel(this.client, rawChannel);
|
|
63
|
+
this.cache.set(channel.id, channel);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Channels = Channels;
|
|
67
|
+
class Channel {
|
|
68
|
+
constructor(client, channel) {
|
|
69
|
+
this.client = client;
|
|
70
|
+
this.id = channel.id;
|
|
71
|
+
this.type = channel.type;
|
|
72
|
+
this.createdAt = channel.createdAt;
|
|
73
|
+
this.lastMessagedAt = channel.lastMessagedAt;
|
|
74
|
+
}
|
|
75
|
+
async send(content) {
|
|
76
|
+
const RawMessage = await (0, MessageService_1.postMessage)({
|
|
77
|
+
client: this.client,
|
|
78
|
+
channelId: this.id,
|
|
79
|
+
content: content
|
|
80
|
+
});
|
|
81
|
+
const message = new Message(this.client, RawMessage);
|
|
82
|
+
return message;
|
|
83
|
+
}
|
|
84
|
+
toString() {
|
|
85
|
+
return `[#:${this.id}]`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.Channel = Channel;
|
|
89
|
+
class ServerChannel extends Channel {
|
|
90
|
+
constructor(client, channel) {
|
|
91
|
+
super(client, channel);
|
|
92
|
+
this.name = channel.name;
|
|
93
|
+
this.permissions = channel.permissions;
|
|
94
|
+
this.createdById = channel.createdById;
|
|
95
|
+
this.serverId = channel.serverId;
|
|
96
|
+
this.categoryId = channel.categoryId;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.ServerChannel = ServerChannel;
|
|
100
|
+
class Message {
|
|
101
|
+
constructor(client, message) {
|
|
102
|
+
this.client = client;
|
|
103
|
+
this.id = message.id;
|
|
104
|
+
this.channelId = message.channelId;
|
|
105
|
+
this.channel = client.channels.cache.get(this.channelId);
|
|
106
|
+
this.content = message.content;
|
|
107
|
+
this.type = message.type;
|
|
108
|
+
this.createdAt = message.createdAt;
|
|
109
|
+
this.user = new User(client, message.createdBy);
|
|
110
|
+
}
|
|
111
|
+
reply(content) {
|
|
112
|
+
return this.channel.send(`${this.user} ${content}`);
|
|
113
|
+
}
|
|
114
|
+
async edit(content) {
|
|
115
|
+
const RawMessage = await (0, MessageService_1.editMessage)({
|
|
116
|
+
client: this.client,
|
|
117
|
+
channelId: this.channel.id,
|
|
118
|
+
messageId: this.id,
|
|
119
|
+
content: content
|
|
120
|
+
});
|
|
121
|
+
const message = new Message(this.client, RawMessage);
|
|
122
|
+
return message;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.Message = Message;
|
|
126
|
+
class User {
|
|
127
|
+
constructor(client, user) {
|
|
128
|
+
this.client = client;
|
|
129
|
+
this.id = user.id;
|
|
130
|
+
this.username = user.username;
|
|
131
|
+
this.tag = user.tag;
|
|
132
|
+
this.hexColor = user.hexColor;
|
|
133
|
+
this.badges = user.badges;
|
|
134
|
+
this.joinedAt = user.joinedAt;
|
|
135
|
+
this.avatar = user.avatar;
|
|
136
|
+
this.banner = user.banner;
|
|
137
|
+
}
|
|
138
|
+
toString() {
|
|
139
|
+
return `[@:${this.id}]`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class ClientUser extends User {
|
|
143
|
+
constructor(client, user) {
|
|
144
|
+
super(client, user);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
class Collection extends Map {
|
|
148
|
+
constructor() {
|
|
149
|
+
super();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//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AAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QAEpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,QAAQ;QACJ,OAAO,MAAM,IAAI,CAAC,EAAE,GAAG,CAAC;IAC5B,CAAC;CACJ;AAED,MAAM,UAAW,SAAQ,IAAI;IACzB,YAAY,MAAc,EAAE,IAAa;QACrC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;CACJ;AAGD,MAAM,UAAiB,SAAQ,GAAS;IACpC;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;CACJ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Message } from './Client';
|
|
2
|
+
export declare const ClientEvents: {
|
|
3
|
+
readonly Ready: "ready";
|
|
4
|
+
readonly MessageCreate: "messageCreate";
|
|
5
|
+
};
|
|
6
|
+
export type ClientEventMap = {
|
|
7
|
+
'ready': () => void;
|
|
8
|
+
'messageCreate': (message: Message) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const SocketClientEvents: {
|
|
11
|
+
AUTHENTICATE: string;
|
|
12
|
+
NOTIFICATION_DISMISS: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const SocketServerEvents: {
|
|
15
|
+
readonly CONNECT: "connect";
|
|
16
|
+
readonly AUTHENTICATE_ERROR: "user:authenticate_error";
|
|
17
|
+
readonly USER_UPDATED: "user:updated";
|
|
18
|
+
readonly USER_AUTHENTICATED: "user:authenticated";
|
|
19
|
+
readonly USER_PRESENCE_UPDATE: "user:presence_update";
|
|
20
|
+
readonly FRIEND_REQUEST_SENT: "friend:request_sent";
|
|
21
|
+
readonly FRIEND_REQUEST_PENDING: "friend:request_pending";
|
|
22
|
+
readonly FRIEND_REQUEST_ACCEPTED: "friend:request_accepted";
|
|
23
|
+
readonly FRIEND_REMOVED: "friend:removed";
|
|
24
|
+
readonly INBOX_OPENED: "inbox:opened";
|
|
25
|
+
readonly NOTIFICATION_DISMISSED: "notification:dismissed";
|
|
26
|
+
readonly SERVER_JOINED: "server:joined";
|
|
27
|
+
readonly SERVER_LEFT: "server:left";
|
|
28
|
+
readonly SERVER_UPDATED: "server:updated";
|
|
29
|
+
readonly SERVER_ROLE_CREATED: "server:role_created";
|
|
30
|
+
readonly SERVER_ROLE_UPDATED: "server:role_updated";
|
|
31
|
+
readonly SERVER_ROLE_ORDER_UPDATED: "server:role_order_updated";
|
|
32
|
+
readonly SERVER_CHANNEL_ORDER_UPDATED: "server:channel_order_updated";
|
|
33
|
+
readonly SERVER_ROLE_DELETED: "server:role_deleted";
|
|
34
|
+
readonly SERVER_MEMBER_JOINED: "server:member_joined";
|
|
35
|
+
readonly SERVER_MEMBER_LEFT: "server:member_left";
|
|
36
|
+
readonly SERVER_MEMBER_UPDATED: "server:member_updated";
|
|
37
|
+
readonly SERVER_CHANNEL_CREATED: "server:channel_created";
|
|
38
|
+
readonly SERVER_CHANNEL_UPDATED: "server:channel_updated";
|
|
39
|
+
readonly SERVER_CHANNEL_DELETED: "server:channel_deleted";
|
|
40
|
+
readonly SERVER_ORDER_UPDATED: "server:order_updated";
|
|
41
|
+
readonly CHANNEL_TYPING: "channel:typing";
|
|
42
|
+
readonly MESSAGE_CREATED: "message:created";
|
|
43
|
+
readonly MESSAGE_UPDATED: "message:updated";
|
|
44
|
+
readonly MESSAGE_DELETED: "message:deleted";
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=EventNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventNames.d.ts","sourceRoot":"","sources":["../src/EventNames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAGX,MAAM,MAAM,cAAc,GAAG;IACzB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/C,CAAA;AAID,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCrB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocketServerEvents = exports.SocketClientEvents = exports.ClientEvents = void 0;
|
|
4
|
+
exports.ClientEvents = {
|
|
5
|
+
Ready: 'ready',
|
|
6
|
+
MessageCreate: 'messageCreate'
|
|
7
|
+
};
|
|
8
|
+
exports.SocketClientEvents = {
|
|
9
|
+
AUTHENTICATE: 'user:authenticate',
|
|
10
|
+
NOTIFICATION_DISMISS: 'notification:dismiss',
|
|
11
|
+
};
|
|
12
|
+
exports.SocketServerEvents = {
|
|
13
|
+
CONNECT: 'connect',
|
|
14
|
+
AUTHENTICATE_ERROR: 'user:authenticate_error',
|
|
15
|
+
USER_UPDATED: 'user:updated',
|
|
16
|
+
USER_AUTHENTICATED: 'user:authenticated',
|
|
17
|
+
USER_PRESENCE_UPDATE: 'user:presence_update',
|
|
18
|
+
FRIEND_REQUEST_SENT: 'friend:request_sent',
|
|
19
|
+
FRIEND_REQUEST_PENDING: 'friend:request_pending',
|
|
20
|
+
FRIEND_REQUEST_ACCEPTED: 'friend:request_accepted',
|
|
21
|
+
FRIEND_REMOVED: 'friend:removed',
|
|
22
|
+
INBOX_OPENED: 'inbox:opened',
|
|
23
|
+
NOTIFICATION_DISMISSED: 'notification:dismissed',
|
|
24
|
+
SERVER_JOINED: 'server:joined',
|
|
25
|
+
SERVER_LEFT: 'server:left',
|
|
26
|
+
SERVER_UPDATED: 'server:updated',
|
|
27
|
+
SERVER_ROLE_CREATED: 'server:role_created',
|
|
28
|
+
SERVER_ROLE_UPDATED: 'server:role_updated',
|
|
29
|
+
SERVER_ROLE_ORDER_UPDATED: 'server:role_order_updated',
|
|
30
|
+
SERVER_CHANNEL_ORDER_UPDATED: 'server:channel_order_updated',
|
|
31
|
+
SERVER_ROLE_DELETED: 'server:role_deleted',
|
|
32
|
+
SERVER_MEMBER_JOINED: 'server:member_joined',
|
|
33
|
+
SERVER_MEMBER_LEFT: 'server:member_left',
|
|
34
|
+
SERVER_MEMBER_UPDATED: 'server:member_updated',
|
|
35
|
+
SERVER_CHANNEL_CREATED: 'server:channel_created',
|
|
36
|
+
SERVER_CHANNEL_UPDATED: 'server:channel_updated',
|
|
37
|
+
SERVER_CHANNEL_DELETED: 'server:channel_deleted',
|
|
38
|
+
SERVER_ORDER_UPDATED: 'server:order_updated',
|
|
39
|
+
CHANNEL_TYPING: 'channel:typing',
|
|
40
|
+
MESSAGE_CREATED: 'message:created',
|
|
41
|
+
MESSAGE_UPDATED: 'message:updated',
|
|
42
|
+
MESSAGE_DELETED: 'message:deleted',
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=EventNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventNames.js","sourceRoot":"","sources":["../src/EventNames.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,aAAa,EAAE,eAAe;CACxB,CAAC;AAUE,QAAA,kBAAkB,GAAG;IAC9B,YAAY,EAAE,mBAAmB;IACjC,oBAAoB,EAAE,sBAAsB;CAC/C,CAAC;AAEW,QAAA,kBAAkB,GAAG;IAC9B,OAAO,EAAE,SAAS;IAClB,kBAAkB,EAAC,yBAAyB;IAC5C,YAAY,EAAE,cAAc;IAE5B,kBAAkB,EAAE,oBAAoB;IAExC,oBAAoB,EAAE,sBAAsB;IAE5C,mBAAmB,EAAE,qBAAqB;IAC1C,sBAAsB,EAAE,wBAAwB;IAChD,uBAAuB,EAAE,yBAAyB;IAClD,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,sBAAsB,EAAE,wBAAwB;IAEhD,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;IAChC,mBAAmB,EAAE,qBAAqB;IAC1C,mBAAmB,EAAE,qBAAqB;IAC1C,yBAAyB,EAAE,2BAA2B;IACtD,4BAA4B,EAAE,8BAA8B;IAE5D,mBAAmB,EAAE,qBAAqB;IAG1C,oBAAoB,EAAE,sBAAsB;IAC5C,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,sBAAsB,EAAE,wBAAwB;IAChD,sBAAsB,EAAE,wBAAwB;IAChD,sBAAsB,EAAE,wBAAwB;IAChD,oBAAoB,EAAE,sBAAsB;IAI5C,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;CAC5B,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface AuthenticatedPayload {
|
|
2
|
+
user: RawUser;
|
|
3
|
+
servers: any[];
|
|
4
|
+
serverMembers: any[];
|
|
5
|
+
messageMentions: any[];
|
|
6
|
+
channels: any[];
|
|
7
|
+
serverRoles: any[];
|
|
8
|
+
presences: any[];
|
|
9
|
+
friends: any[];
|
|
10
|
+
inbox: any[];
|
|
11
|
+
lastSeenServerChannelIds: Record<string, number>;
|
|
12
|
+
}
|
|
13
|
+
export interface RawUser {
|
|
14
|
+
id: string;
|
|
15
|
+
avatar?: string;
|
|
16
|
+
banner?: string;
|
|
17
|
+
username: string;
|
|
18
|
+
hexColor: string;
|
|
19
|
+
tag: string;
|
|
20
|
+
badges: number;
|
|
21
|
+
joinedAt?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare enum MessageType {
|
|
24
|
+
CONTENT = 0,
|
|
25
|
+
JOIN_SERVER = 1,
|
|
26
|
+
LEAVE_SERVER = 2,
|
|
27
|
+
KICK_USER = 3,
|
|
28
|
+
BAN_USER = 4
|
|
29
|
+
}
|
|
30
|
+
export interface RawMessage {
|
|
31
|
+
id: string;
|
|
32
|
+
channelId: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
createdBy: RawUser;
|
|
35
|
+
type: MessageType;
|
|
36
|
+
createdAt: number;
|
|
37
|
+
editedAt?: number;
|
|
38
|
+
mentions?: Array<RawUser>;
|
|
39
|
+
attachments?: Array<any>;
|
|
40
|
+
}
|
|
41
|
+
export declare enum ChannelType {
|
|
42
|
+
DM_TEXT = 0,
|
|
43
|
+
SERVER_TEXT = 1,
|
|
44
|
+
CATEGORY = 2
|
|
45
|
+
}
|
|
46
|
+
export interface RawChannel {
|
|
47
|
+
id: string;
|
|
48
|
+
categoryId?: string;
|
|
49
|
+
name: string;
|
|
50
|
+
createdById?: string;
|
|
51
|
+
serverId?: string;
|
|
52
|
+
type: ChannelType;
|
|
53
|
+
permissions?: number;
|
|
54
|
+
createdAt: number;
|
|
55
|
+
lastMessagedAt?: number;
|
|
56
|
+
order?: number;
|
|
57
|
+
_count?: {
|
|
58
|
+
attachments: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=RawData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RawData.d.ts","sourceRoot":"","sources":["../src/RawData.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,G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,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC,CAAA;CACjC"}
|
package/build/RawData.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChannelType = exports.MessageType = void 0;
|
|
4
|
+
var MessageType;
|
|
5
|
+
(function (MessageType) {
|
|
6
|
+
MessageType[MessageType["CONTENT"] = 0] = "CONTENT";
|
|
7
|
+
MessageType[MessageType["JOIN_SERVER"] = 1] = "JOIN_SERVER";
|
|
8
|
+
MessageType[MessageType["LEAVE_SERVER"] = 2] = "LEAVE_SERVER";
|
|
9
|
+
MessageType[MessageType["KICK_USER"] = 3] = "KICK_USER";
|
|
10
|
+
MessageType[MessageType["BAN_USER"] = 4] = "BAN_USER";
|
|
11
|
+
})(MessageType = exports.MessageType || (exports.MessageType = {}));
|
|
12
|
+
var ChannelType;
|
|
13
|
+
(function (ChannelType) {
|
|
14
|
+
ChannelType[ChannelType["DM_TEXT"] = 0] = "DM_TEXT";
|
|
15
|
+
ChannelType[ChannelType["SERVER_TEXT"] = 1] = "SERVER_TEXT";
|
|
16
|
+
ChannelType[ChannelType["CATEGORY"] = 2] = "CATEGORY";
|
|
17
|
+
})(ChannelType = exports.ChannelType || (exports.ChannelType = {}));
|
|
18
|
+
//# sourceMappingURL=RawData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RawData.js","sourceRoot":"","sources":["../src/RawData.ts"],"names":[],"mappings":";;;AAwBA,IAAY,WAMX;AAND,WAAY,WAAW;IACnB,mDAAW,CAAA;IACX,2DAAe,CAAA;IACf,6DAAgB,CAAA;IAChB,uDAAa,CAAA;IACb,qDAAY,CAAA;AAChB,CAAC,EANW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAMtB;AAcD,IAAY,WAIT;AAJH,WAAY,WAAW;IACnB,mDAAW,CAAA;IACX,2DAAe,CAAA;IACf,qDAAY,CAAA;AACd,CAAC,EAJS,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAIpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":""}
|
package/build/example.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Client_1 = require("./Client");
|
|
4
|
+
const client = new Client_1.Client();
|
|
5
|
+
client.on(Client_1.Events.Ready, () => {
|
|
6
|
+
console.log(`Connected as ${client.user?.username}!`);
|
|
7
|
+
});
|
|
8
|
+
client.on(Client_1.Events.MessageCreate, message => {
|
|
9
|
+
console.log(message.content);
|
|
10
|
+
});
|
|
11
|
+
client.login('token');
|
|
12
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":";;AAAA,qCAA0C;AAE1C,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;AAG5B,MAAM,CAAC,EAAE,CAAC,eAAM,CAAC,KAAK,EAAE,GAAG,EAAE;IACzB,OAAO,CAAC,GAAG,CAAC,gBAAgB,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,EAAE,CAAC,eAAM,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE;IACtC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAGH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Events = exports.Client = void 0;
|
|
4
|
+
var Client_1 = require("./Client");
|
|
5
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.Client; } });
|
|
6
|
+
Object.defineProperty(exports, "Events", { enumerable: true, get: function () { return Client_1.Events; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAAjC,gGAAA,MAAM,OAAA;AAAE,gGAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Client } from '../Client';
|
|
2
|
+
import { RawMessage } from '../RawData';
|
|
3
|
+
interface PostMessageOpts {
|
|
4
|
+
client: Client;
|
|
5
|
+
channelId: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function postMessage(opts: PostMessageOpts): Promise<RawMessage>;
|
|
9
|
+
interface EditMessageOpts {
|
|
10
|
+
client: Client;
|
|
11
|
+
channelId: string;
|
|
12
|
+
messageId: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function editMessage(opts: EditMessageOpts): Promise<RawMessage>;
|
|
16
|
+
interface RequestOpts {
|
|
17
|
+
url: string;
|
|
18
|
+
method: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
|
|
19
|
+
body?: any;
|
|
20
|
+
useToken?: boolean;
|
|
21
|
+
notJSON?: boolean;
|
|
22
|
+
params?: Record<any, any>;
|
|
23
|
+
client: Client;
|
|
24
|
+
}
|
|
25
|
+
export declare function request<T>(opts: RequestOpts): Promise<T>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=MessageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageService.d.ts","sourceRoot":"","sources":["../../src/services/MessageService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC,UAAU,eAAe;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,uBAQhD;AAED,UAAU,eAAe;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,uBAQhD;AAMD,UAAU,WAAW;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAEH,wBAAsB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CA0B9D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.request = exports.editMessage = exports.postMessage = void 0;
|
|
7
|
+
const serviceEndpoints_1 = require("./serviceEndpoints");
|
|
8
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
|
+
function postMessage(opts) {
|
|
10
|
+
return request({
|
|
11
|
+
client: opts.client,
|
|
12
|
+
url: serviceEndpoints_1.ServiceEndpoints.PostMessage(opts.channelId),
|
|
13
|
+
method: 'POST',
|
|
14
|
+
body: { content: opts.content },
|
|
15
|
+
useToken: true,
|
|
16
|
+
}).catch(err => { throw err.message; });
|
|
17
|
+
}
|
|
18
|
+
exports.postMessage = postMessage;
|
|
19
|
+
function editMessage(opts) {
|
|
20
|
+
return request({
|
|
21
|
+
client: opts.client,
|
|
22
|
+
url: serviceEndpoints_1.ServiceEndpoints.EditMessage(opts.channelId, opts.messageId),
|
|
23
|
+
method: 'PATCH',
|
|
24
|
+
body: { content: opts.content },
|
|
25
|
+
useToken: true,
|
|
26
|
+
}).catch(err => { throw err.message; });
|
|
27
|
+
}
|
|
28
|
+
exports.editMessage = editMessage;
|
|
29
|
+
async function request(opts) {
|
|
30
|
+
const url = new URL(opts.url);
|
|
31
|
+
url.search = new URLSearchParams(opts.params || {}).toString();
|
|
32
|
+
const response = await (0, node_fetch_1.default)(url, {
|
|
33
|
+
method: opts.method,
|
|
34
|
+
body: JSON.stringify(opts.body),
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
'Authorization': opts.useToken ? opts.client.token : ''
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
.catch(err => { throw { message: 'Could not connect to server. ' + err.message }; });
|
|
41
|
+
const text = await response.text();
|
|
42
|
+
if (opts.notJSON)
|
|
43
|
+
return text;
|
|
44
|
+
try {
|
|
45
|
+
const json = JSON.parse(text);
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
return Promise.reject(json);
|
|
48
|
+
}
|
|
49
|
+
return json;
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
throw { message: text };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.request = request;
|
|
56
|
+
//# sourceMappingURL=MessageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageService.js","sourceRoot":"","sources":["../../src/services/MessageService.ts"],"names":[],"mappings":";;;;;;AAEA,yDAAsD;AACtD,4DAA+B;AAQ/B,SAAgB,WAAW,CAAC,IAAqB;IAC7C,OAAO,OAAO,CAAa;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,EAAE,mCAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;QACjD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,EAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAC;QAC7B,QAAQ,EAAE,IAAI;KACjB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAE,MAAM,GAAG,CAAC,OAAO,CAAC,CAAA,CAAC,CAAC,CAAC;AAC1C,CAAC;AARD,kCAQC;AASD,SAAgB,WAAW,CAAC,IAAqB;IAC7C,OAAO,OAAO,CAAa;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,EAAE,mCAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC;QACjE,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,EAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAC;QAC7B,QAAQ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AAC,CAAC;KACzB;AACL,CAAC;AA1BD,0BA0BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceEndpoints.d.ts","sourceRoot":"","sources":["../../src/services/serviceEndpoints.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB;6BAJG,MAAM;6BACN,MAAM;6BACN,MAAM,aAAa,MAAM;CAMxD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceEndpoints = void 0;
|
|
4
|
+
const BaseUrl = 'https://nerimity.com/api';
|
|
5
|
+
const GetMessages = (channelId) => `${BaseUrl}/channels/${channelId}/messages`;
|
|
6
|
+
const PostMessage = (channelId) => `${BaseUrl}/channels/${channelId}/messages`;
|
|
7
|
+
const EditMessage = (channelId, messageId) => `${BaseUrl}/channels/${channelId}/messages/${messageId}`;
|
|
8
|
+
exports.ServiceEndpoints = {
|
|
9
|
+
GetMessages,
|
|
10
|
+
PostMessage,
|
|
11
|
+
EditMessage
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=serviceEndpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceEndpoints.js","sourceRoot":"","sources":["../../src/services/serviceEndpoints.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAC3C,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,GAAG,OAAO,aAAa,SAAS,WAAW,CAAC;AACvF,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,GAAG,OAAO,aAAa,SAAS,WAAW,CAAC;AACvF,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,SAAiB,EAAE,EAAE,CAAC,GAAG,OAAO,aAAa,SAAS,aAAa,SAAS,EAAE,CAAC;AAE1G,QAAA,gBAAgB,GAAG;IAC5B,WAAW;IACX,WAAW;IACX,WAAW;CACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nerimity/nerimity.js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"prepublishOnly": "tsc"
|
|
9
|
+
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node-fetch": "^2.6.3",
|
|
16
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
17
|
+
"@typescript-eslint/parser": "^5.59.5",
|
|
18
|
+
"eslint": "^8.40.0",
|
|
19
|
+
"nodemon": "^2.0.22",
|
|
20
|
+
"ts-node": "^10.9.1",
|
|
21
|
+
"typescript": "^5.0.4"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"eventemitter3": "^5.0.1",
|
|
25
|
+
"node-fetch": "2",
|
|
26
|
+
"socket.io-client": "^4.6.1"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/Client.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import {Socket, io} from 'socket.io-client';
|
|
3
|
+
import { ClientEventMap, ClientEvents, SocketClientEvents, SocketServerEvents } from './EventNames';
|
|
4
|
+
import { AuthenticatedPayload, ChannelType, MessageType, RawChannel, RawMessage, RawUser } from './RawData';
|
|
5
|
+
import { editMessage, postMessage } from './services/MessageService';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const Events = ClientEvents;
|
|
9
|
+
|
|
10
|
+
export class Client extends EventEmitter<ClientEventMap> {
|
|
11
|
+
socket: Socket;
|
|
12
|
+
token: string | undefined;
|
|
13
|
+
user: ClientUser | undefined;
|
|
14
|
+
channels: Channels;
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.socket = io('https://nerimity.com', {
|
|
18
|
+
transports: ['websocket'],
|
|
19
|
+
autoConnect: false,
|
|
20
|
+
});
|
|
21
|
+
this.channels = new Channels(this);
|
|
22
|
+
new EventHandlers(this);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public login(token: string) {
|
|
26
|
+
this.token = token;
|
|
27
|
+
this.socket.connect();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class EventHandlers {
|
|
33
|
+
client: Client;
|
|
34
|
+
socket: Socket;
|
|
35
|
+
constructor(client: Client) {
|
|
36
|
+
this.client = client;
|
|
37
|
+
this.socket = client.socket;
|
|
38
|
+
|
|
39
|
+
client.socket.on(SocketServerEvents.CONNECT, this.onConnect.bind(this));
|
|
40
|
+
client.socket.on(SocketServerEvents.USER_AUTHENTICATED, this.onAuthenticated.bind(this));
|
|
41
|
+
client.socket.on(SocketServerEvents.MESSAGE_CREATED, this.onMessageCreated.bind(this));
|
|
42
|
+
}
|
|
43
|
+
onConnect() {
|
|
44
|
+
this.socket.emit(SocketClientEvents.AUTHENTICATE, {token: this.client.token});
|
|
45
|
+
}
|
|
46
|
+
onAuthenticated(payload: AuthenticatedPayload) {
|
|
47
|
+
this.client.user = new ClientUser(this.client, payload.user);
|
|
48
|
+
|
|
49
|
+
for (let i = 0; i < payload.channels.length; i++) {
|
|
50
|
+
const rawChannel = payload.channels[i];
|
|
51
|
+
this.client.channels.setCache(rawChannel);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.client.emit(ClientEvents.Ready);
|
|
55
|
+
}
|
|
56
|
+
onMessageCreated(payload: {message: RawMessage}) {
|
|
57
|
+
const message = new Message(this.client, payload.message);
|
|
58
|
+
this.client.emit(ClientEvents.MessageCreate, message);
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
export class Channels {
|
|
66
|
+
client: Client;
|
|
67
|
+
cache: Collection<string, AllChannel>;
|
|
68
|
+
constructor(client: Client) {
|
|
69
|
+
this.client = client;
|
|
70
|
+
this.cache = new Collection();
|
|
71
|
+
}
|
|
72
|
+
setCache(rawChannel: RawChannel) {
|
|
73
|
+
let channel: AllChannel;
|
|
74
|
+
if (rawChannel.serverId) channel = new ServerChannel(this.client, rawChannel);
|
|
75
|
+
else channel = new Channel(this.client, rawChannel);
|
|
76
|
+
this.cache.set(channel.id, channel);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export type AllChannel = ServerChannel | Channel
|
|
82
|
+
|
|
83
|
+
export class Channel {
|
|
84
|
+
client: Client;
|
|
85
|
+
id: string;
|
|
86
|
+
|
|
87
|
+
type: ChannelType;
|
|
88
|
+
createdAt: number;
|
|
89
|
+
lastMessagedAt?: number;
|
|
90
|
+
constructor(client: Client, channel: RawChannel) {
|
|
91
|
+
this.client = client;
|
|
92
|
+
this.id = channel.id;
|
|
93
|
+
this.type = channel.type;
|
|
94
|
+
this.createdAt = channel.createdAt;
|
|
95
|
+
this.lastMessagedAt = channel.lastMessagedAt;
|
|
96
|
+
}
|
|
97
|
+
async send(content: string) {
|
|
98
|
+
const RawMessage = await postMessage({
|
|
99
|
+
client: this.client,
|
|
100
|
+
channelId: this.id,
|
|
101
|
+
content: content
|
|
102
|
+
});
|
|
103
|
+
const message = new Message(this.client, RawMessage);
|
|
104
|
+
return message;
|
|
105
|
+
}
|
|
106
|
+
toString() {
|
|
107
|
+
return `[#:${this.id}]`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class ServerChannel extends Channel {
|
|
112
|
+
createdById: string;
|
|
113
|
+
name: string;
|
|
114
|
+
serverId: string;
|
|
115
|
+
permissions: number;
|
|
116
|
+
categoryId?: string;
|
|
117
|
+
|
|
118
|
+
constructor(client: Client, channel: RawChannel) {
|
|
119
|
+
super(client, channel);
|
|
120
|
+
this.name = channel.name;
|
|
121
|
+
this.permissions = channel.permissions!;
|
|
122
|
+
this.createdById = channel.createdById!;
|
|
123
|
+
this.serverId = channel.serverId!;
|
|
124
|
+
this.categoryId = channel.categoryId!;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
export class Message {
|
|
130
|
+
client: Client;
|
|
131
|
+
id: string;
|
|
132
|
+
content?: string;
|
|
133
|
+
type: MessageType;
|
|
134
|
+
createdAt: number;
|
|
135
|
+
channelId: string;
|
|
136
|
+
channel: AllChannel;
|
|
137
|
+
user: User;
|
|
138
|
+
constructor(client: Client, message: RawMessage) {
|
|
139
|
+
this.client = client;
|
|
140
|
+
|
|
141
|
+
this.id = message.id;
|
|
142
|
+
this.channelId = message.channelId;
|
|
143
|
+
this.channel = client.channels.cache.get(this.channelId)!;
|
|
144
|
+
this.content = message.content;
|
|
145
|
+
this.type = message.type;
|
|
146
|
+
this.createdAt = message.createdAt;
|
|
147
|
+
this.user = new User(client, message.createdBy);
|
|
148
|
+
}
|
|
149
|
+
reply(content: string) {
|
|
150
|
+
return this.channel.send(`${this.user} ${content}`);
|
|
151
|
+
}
|
|
152
|
+
async edit(content: string) {
|
|
153
|
+
const RawMessage = await editMessage({
|
|
154
|
+
client: this.client,
|
|
155
|
+
channelId: this.channel.id,
|
|
156
|
+
messageId: this.id,
|
|
157
|
+
content: content
|
|
158
|
+
});
|
|
159
|
+
const message = new Message(this.client, RawMessage);
|
|
160
|
+
return message;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class User {
|
|
167
|
+
client: Client;
|
|
168
|
+
id: string;
|
|
169
|
+
avatar?: string;
|
|
170
|
+
banner?: string;
|
|
171
|
+
username: string;
|
|
172
|
+
hexColor: string;
|
|
173
|
+
tag: string;
|
|
174
|
+
badges: number;
|
|
175
|
+
joinedAt?: number;
|
|
176
|
+
constructor(client: Client, user: RawUser) {
|
|
177
|
+
this.client = client;
|
|
178
|
+
|
|
179
|
+
this.id = user.id;
|
|
180
|
+
this.username = user.username;
|
|
181
|
+
this.tag = user.tag;
|
|
182
|
+
|
|
183
|
+
this.hexColor = user.hexColor;
|
|
184
|
+
this.badges = user.badges;
|
|
185
|
+
this.joinedAt = user.joinedAt;
|
|
186
|
+
this.avatar = user.avatar;
|
|
187
|
+
this.banner = user.banner;
|
|
188
|
+
}
|
|
189
|
+
toString() {
|
|
190
|
+
return `[@:${this.id}]`;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
class ClientUser extends User {
|
|
195
|
+
constructor(client: Client, user: RawUser) {
|
|
196
|
+
super(client, user);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class Collection<K, V> extends Map<K, V> {
|
|
202
|
+
constructor() {
|
|
203
|
+
super();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Message } from './Client';
|
|
2
|
+
|
|
3
|
+
export const ClientEvents = {
|
|
4
|
+
Ready: 'ready',
|
|
5
|
+
MessageCreate: 'messageCreate'
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export type ClientEventMap = {
|
|
10
|
+
'ready': () => void;
|
|
11
|
+
'messageCreate': (message: Message) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export const SocketClientEvents = {
|
|
17
|
+
AUTHENTICATE: 'user:authenticate',
|
|
18
|
+
NOTIFICATION_DISMISS: 'notification:dismiss',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const SocketServerEvents = {
|
|
22
|
+
CONNECT: 'connect',
|
|
23
|
+
AUTHENTICATE_ERROR:'user:authenticate_error',
|
|
24
|
+
USER_UPDATED: 'user:updated',
|
|
25
|
+
|
|
26
|
+
USER_AUTHENTICATED: 'user:authenticated',
|
|
27
|
+
|
|
28
|
+
USER_PRESENCE_UPDATE: 'user:presence_update',
|
|
29
|
+
|
|
30
|
+
FRIEND_REQUEST_SENT: 'friend:request_sent',
|
|
31
|
+
FRIEND_REQUEST_PENDING: 'friend:request_pending',
|
|
32
|
+
FRIEND_REQUEST_ACCEPTED: 'friend:request_accepted',
|
|
33
|
+
FRIEND_REMOVED: 'friend:removed',
|
|
34
|
+
INBOX_OPENED: 'inbox:opened',
|
|
35
|
+
NOTIFICATION_DISMISSED: 'notification:dismissed',
|
|
36
|
+
|
|
37
|
+
SERVER_JOINED: 'server:joined',
|
|
38
|
+
SERVER_LEFT: 'server:left',
|
|
39
|
+
SERVER_UPDATED: 'server:updated',
|
|
40
|
+
SERVER_ROLE_CREATED: 'server:role_created',
|
|
41
|
+
SERVER_ROLE_UPDATED: 'server:role_updated',
|
|
42
|
+
SERVER_ROLE_ORDER_UPDATED: 'server:role_order_updated',
|
|
43
|
+
SERVER_CHANNEL_ORDER_UPDATED: 'server:channel_order_updated',
|
|
44
|
+
|
|
45
|
+
SERVER_ROLE_DELETED: 'server:role_deleted',
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
SERVER_MEMBER_JOINED: 'server:member_joined',
|
|
49
|
+
SERVER_MEMBER_LEFT: 'server:member_left',
|
|
50
|
+
SERVER_MEMBER_UPDATED: 'server:member_updated',
|
|
51
|
+
SERVER_CHANNEL_CREATED: 'server:channel_created',
|
|
52
|
+
SERVER_CHANNEL_UPDATED: 'server:channel_updated',
|
|
53
|
+
SERVER_CHANNEL_DELETED: 'server:channel_deleted',
|
|
54
|
+
SERVER_ORDER_UPDATED: 'server:order_updated',
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
CHANNEL_TYPING: 'channel:typing',
|
|
59
|
+
MESSAGE_CREATED: 'message:created',
|
|
60
|
+
MESSAGE_UPDATED: 'message:updated',
|
|
61
|
+
MESSAGE_DELETED: 'message:deleted',
|
|
62
|
+
} as const;
|
package/src/RawData.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
export interface AuthenticatedPayload {
|
|
3
|
+
user: RawUser;
|
|
4
|
+
servers: any[];
|
|
5
|
+
serverMembers: any[];
|
|
6
|
+
messageMentions: any[]
|
|
7
|
+
channels: any[];
|
|
8
|
+
serverRoles: any[];
|
|
9
|
+
presences: any[];
|
|
10
|
+
friends: any[];
|
|
11
|
+
inbox: any[];
|
|
12
|
+
lastSeenServerChannelIds: Record<string, number>; // { [channelId]: timestamp }
|
|
13
|
+
}
|
|
14
|
+
export interface RawUser {
|
|
15
|
+
id: string;
|
|
16
|
+
avatar?: string;
|
|
17
|
+
banner?: string;
|
|
18
|
+
username: string;
|
|
19
|
+
hexColor: string;
|
|
20
|
+
tag: string;
|
|
21
|
+
badges: number;
|
|
22
|
+
joinedAt?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export enum MessageType {
|
|
26
|
+
CONTENT = 0,
|
|
27
|
+
JOIN_SERVER = 1,
|
|
28
|
+
LEAVE_SERVER = 2,
|
|
29
|
+
KICK_USER = 3,
|
|
30
|
+
BAN_USER = 4
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface RawMessage {
|
|
34
|
+
id: string;
|
|
35
|
+
channelId: string;
|
|
36
|
+
content?: string;
|
|
37
|
+
createdBy: RawUser;
|
|
38
|
+
type: MessageType;
|
|
39
|
+
createdAt: number;
|
|
40
|
+
editedAt?: number;
|
|
41
|
+
mentions?: Array<RawUser>;
|
|
42
|
+
attachments?: Array<any>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export enum ChannelType {
|
|
46
|
+
DM_TEXT = 0,
|
|
47
|
+
SERVER_TEXT = 1,
|
|
48
|
+
CATEGORY = 2,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface RawChannel {
|
|
52
|
+
id: string;
|
|
53
|
+
categoryId?: string;
|
|
54
|
+
name: string
|
|
55
|
+
createdById?: string;
|
|
56
|
+
serverId?: string;
|
|
57
|
+
type: ChannelType;
|
|
58
|
+
permissions?: number
|
|
59
|
+
createdAt: number
|
|
60
|
+
lastMessagedAt?: number;
|
|
61
|
+
order?: number;
|
|
62
|
+
_count?: {attachments: number}
|
|
63
|
+
}
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Client, Events } from './Client';
|
|
2
|
+
|
|
3
|
+
const client = new Client();
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
client.on(Events.Ready, () => {
|
|
7
|
+
console.log(`Connected as ${client.user?.username}!`);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
client.on(Events.MessageCreate, message => {
|
|
11
|
+
console.log(message.content);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
client.login('token');
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Client } from '../Client';
|
|
2
|
+
import { RawMessage } from '../RawData';
|
|
3
|
+
import { ServiceEndpoints } from './serviceEndpoints';
|
|
4
|
+
import fetch from 'node-fetch';
|
|
5
|
+
|
|
6
|
+
interface PostMessageOpts {
|
|
7
|
+
client: Client;
|
|
8
|
+
channelId: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function postMessage(opts: PostMessageOpts) {
|
|
13
|
+
return request<RawMessage>({
|
|
14
|
+
client: opts.client,
|
|
15
|
+
url: ServiceEndpoints.PostMessage(opts.channelId),
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: {content: opts.content},
|
|
18
|
+
useToken: true,
|
|
19
|
+
}).catch(err => {throw err.message;});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface EditMessageOpts {
|
|
23
|
+
client: Client;
|
|
24
|
+
channelId: string;
|
|
25
|
+
messageId: string;
|
|
26
|
+
content: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function editMessage(opts: EditMessageOpts) {
|
|
30
|
+
return request<RawMessage>({
|
|
31
|
+
client: opts.client,
|
|
32
|
+
url: ServiceEndpoints.EditMessage(opts.channelId, opts.messageId),
|
|
33
|
+
method: 'PATCH',
|
|
34
|
+
body: {content: opts.content},
|
|
35
|
+
useToken: true,
|
|
36
|
+
}).catch(err => {throw err.message;});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
interface RequestOpts {
|
|
44
|
+
url: string;
|
|
45
|
+
method: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
|
|
46
|
+
body?: any;
|
|
47
|
+
useToken?: boolean;
|
|
48
|
+
notJSON?: boolean;
|
|
49
|
+
params?: Record<any, any>;
|
|
50
|
+
client: Client;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function request<T>(opts: RequestOpts): Promise<T> {
|
|
54
|
+
const url = new URL(opts.url);
|
|
55
|
+
url.search = new URLSearchParams(opts.params || {}).toString();
|
|
56
|
+
|
|
57
|
+
const response = await fetch(url, {
|
|
58
|
+
method: opts.method,
|
|
59
|
+
body: JSON.stringify(opts.body),
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
'Authorization': opts.useToken ? opts.client.token! : ''
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
.catch(err => { throw { message: 'Could not connect to server. ' + err.message }; });
|
|
66
|
+
|
|
67
|
+
const text = await response.text();
|
|
68
|
+
if (opts.notJSON) return text as T;
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const json = JSON.parse(text);
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
return Promise.reject(json);
|
|
74
|
+
}
|
|
75
|
+
return json;
|
|
76
|
+
} catch (e) {
|
|
77
|
+
throw {message: text};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const BaseUrl = 'https://nerimity.com/api';
|
|
2
|
+
const GetMessages = (channelId: string) => `${BaseUrl}/channels/${channelId}/messages`;
|
|
3
|
+
const PostMessage = (channelId: string) => `${BaseUrl}/channels/${channelId}/messages`;
|
|
4
|
+
const EditMessage = (channelId: string, messageId: string) => `${BaseUrl}/channels/${channelId}/messages/${messageId}`;
|
|
5
|
+
|
|
6
|
+
export const ServiceEndpoints = {
|
|
7
|
+
GetMessages,
|
|
8
|
+
PostMessage,
|
|
9
|
+
EditMessage
|
|
10
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
|
|
27
|
+
/* Modules */
|
|
28
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
29
|
+
"rootDir": "./src", /* Specify the root folder within your source files. */
|
|
30
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
+
|
|
46
|
+
/* JavaScript Support */
|
|
47
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
+
|
|
51
|
+
/* Emit */
|
|
52
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
+
"declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
+
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
+
"outDir": "./build", /* Specify an output folder for all emitted files. */
|
|
59
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
+
|
|
76
|
+
/* Interop Constraints */
|
|
77
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
+
|
|
84
|
+
/* Type Checking */
|
|
85
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
+
|
|
105
|
+
/* Completeness */
|
|
106
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
+
}
|
|
109
|
+
}
|