@only-chat/client 0.2.0-beta.10
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/README.md +4 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +846 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { UserStore } from '@only-chat/types/userStore.js';
|
|
2
|
+
import type { Conversation, MessageStore } from '@only-chat/types/store.js';
|
|
3
|
+
import type { Log } from '@only-chat/types/log.js';
|
|
4
|
+
import type { Message as QueueMessage, MessageQueue } from '@only-chat/types/queue.js';
|
|
5
|
+
import type { Transport } from '@only-chat/types/transport.js';
|
|
6
|
+
export declare enum TransportState {
|
|
7
|
+
/** The connection is not yet open. */
|
|
8
|
+
CONNECTING = 0,
|
|
9
|
+
/** The connection is open and ready to communicate. */
|
|
10
|
+
OPEN = 1,
|
|
11
|
+
/** The connection is in the process of closing. */
|
|
12
|
+
CLOSING = 2,
|
|
13
|
+
/** The connection is closed. */
|
|
14
|
+
CLOSED = 3
|
|
15
|
+
}
|
|
16
|
+
export interface Config {
|
|
17
|
+
queue: MessageQueue;
|
|
18
|
+
store: MessageStore;
|
|
19
|
+
userStore: UserStore;
|
|
20
|
+
instanceId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface LoadRequest {
|
|
23
|
+
from?: number;
|
|
24
|
+
size?: number;
|
|
25
|
+
excludeIds?: string[];
|
|
26
|
+
before?: Date;
|
|
27
|
+
}
|
|
28
|
+
interface ConversationInfo {
|
|
29
|
+
participants: Set<string>;
|
|
30
|
+
clients: WsClient[];
|
|
31
|
+
}
|
|
32
|
+
export declare enum WsClientState {
|
|
33
|
+
None = 0,
|
|
34
|
+
Authenticated = 1,
|
|
35
|
+
Connected = 2,
|
|
36
|
+
Session = 3,
|
|
37
|
+
WatchSession = 4,
|
|
38
|
+
Disconnected = 255
|
|
39
|
+
}
|
|
40
|
+
export declare class WsClient {
|
|
41
|
+
static readonly connectedClients: Set<string>;
|
|
42
|
+
static readonly watchers: Map<string, WsClient>;
|
|
43
|
+
static readonly conversations: Map<string, ConversationInfo>;
|
|
44
|
+
private static readonly conversationsCache;
|
|
45
|
+
connectionId?: string;
|
|
46
|
+
conversation?: Conversation;
|
|
47
|
+
state: WsClientState;
|
|
48
|
+
id?: string;
|
|
49
|
+
private readonly transport;
|
|
50
|
+
private lastError?;
|
|
51
|
+
constructor(t: Transport);
|
|
52
|
+
static addClient(conversation: Conversation, wc: WsClient): Promise<void>;
|
|
53
|
+
private static removeClient;
|
|
54
|
+
private static addWatchClient;
|
|
55
|
+
private static removeWatchClient;
|
|
56
|
+
private static publishToWatchList;
|
|
57
|
+
private static getConversationParticipants;
|
|
58
|
+
private static publishToWsList;
|
|
59
|
+
private static syncConversation;
|
|
60
|
+
static translateQueueMessage(qm: QueueMessage): Promise<void>;
|
|
61
|
+
private publishMessage;
|
|
62
|
+
private send;
|
|
63
|
+
private stop;
|
|
64
|
+
private watch;
|
|
65
|
+
private join;
|
|
66
|
+
private onMessage;
|
|
67
|
+
private onClose;
|
|
68
|
+
private deleteMessage;
|
|
69
|
+
private updateMessage;
|
|
70
|
+
private updateConversation;
|
|
71
|
+
private closeDeleteConversation;
|
|
72
|
+
private processRequest;
|
|
73
|
+
private processConversationRequest;
|
|
74
|
+
private connect;
|
|
75
|
+
private getConversations;
|
|
76
|
+
private findMessages;
|
|
77
|
+
private loadMessages;
|
|
78
|
+
private loadConversations;
|
|
79
|
+
}
|
|
80
|
+
export declare function initialize(config: Config, log?: Log): void;
|
|
81
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,846 @@
|
|
|
1
|
+
export var TransportState;
|
|
2
|
+
(function (TransportState) {
|
|
3
|
+
/** The connection is not yet open. */
|
|
4
|
+
TransportState[TransportState["CONNECTING"] = 0] = "CONNECTING";
|
|
5
|
+
/** The connection is open and ready to communicate. */
|
|
6
|
+
TransportState[TransportState["OPEN"] = 1] = "OPEN";
|
|
7
|
+
/** The connection is in the process of closing. */
|
|
8
|
+
TransportState[TransportState["CLOSING"] = 2] = "CLOSING";
|
|
9
|
+
/** The connection is closed. */
|
|
10
|
+
TransportState[TransportState["CLOSED"] = 3] = "CLOSED";
|
|
11
|
+
})(TransportState || (TransportState = {}));
|
|
12
|
+
export var WsClientState;
|
|
13
|
+
(function (WsClientState) {
|
|
14
|
+
WsClientState[WsClientState["None"] = 0] = "None";
|
|
15
|
+
WsClientState[WsClientState["Authenticated"] = 1] = "Authenticated";
|
|
16
|
+
WsClientState[WsClientState["Connected"] = 2] = "Connected";
|
|
17
|
+
WsClientState[WsClientState["Session"] = 3] = "Session";
|
|
18
|
+
WsClientState[WsClientState["WatchSession"] = 4] = "WatchSession";
|
|
19
|
+
WsClientState[WsClientState["Disconnected"] = 255] = "Disconnected";
|
|
20
|
+
})(WsClientState || (WsClientState = {}));
|
|
21
|
+
const defaultSize = 100;
|
|
22
|
+
const sendStates = [WsClientState.Connected, WsClientState.Session, WsClientState.WatchSession];
|
|
23
|
+
const connectedRequestTypes = ['close', 'delete', 'load', 'update'];
|
|
24
|
+
const types = ['file', 'text'];
|
|
25
|
+
let instanceId = undefined;
|
|
26
|
+
let logger;
|
|
27
|
+
let queue = undefined;
|
|
28
|
+
let store = undefined;
|
|
29
|
+
let userStore = undefined;
|
|
30
|
+
export class WsClient {
|
|
31
|
+
// These members are public for testing purposes only
|
|
32
|
+
static connectedClients = new Set();
|
|
33
|
+
static watchers = new Map();
|
|
34
|
+
static conversations = new Map();
|
|
35
|
+
static conversationsCache = new Map();
|
|
36
|
+
connectionId;
|
|
37
|
+
conversation;
|
|
38
|
+
state = WsClientState.None;
|
|
39
|
+
id;
|
|
40
|
+
transport;
|
|
41
|
+
lastError;
|
|
42
|
+
constructor(t) {
|
|
43
|
+
this.transport = t;
|
|
44
|
+
t.on('message', this.onMessage.bind(this));
|
|
45
|
+
t.once('close', this.onClose.bind(this));
|
|
46
|
+
t.send(JSON.stringify({ type: 'hello', instanceId }), { binary: false, fin: true });
|
|
47
|
+
}
|
|
48
|
+
static async addClient(conversation, wc) {
|
|
49
|
+
let info = WsClient.conversations.get(conversation.id);
|
|
50
|
+
if (!info) {
|
|
51
|
+
info = { participants: new Set(conversation.participants), clients: [wc] };
|
|
52
|
+
WsClient.conversations.set(conversation.id, info);
|
|
53
|
+
WsClient.conversationsCache.delete(conversation.id);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
info.clients.push(wc);
|
|
57
|
+
}
|
|
58
|
+
for (const c of info.clients) {
|
|
59
|
+
if (c.id && !info.participants.has(c.id)) {
|
|
60
|
+
await c.stop('Removed by new participant');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static removeClient(conversationId, wc) {
|
|
65
|
+
const info = WsClient.conversations.get(conversationId);
|
|
66
|
+
if (!info) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const index = info.clients.indexOf(wc);
|
|
70
|
+
if (index < 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
info.clients.splice(index, 1);
|
|
74
|
+
if (!info.clients.length) {
|
|
75
|
+
WsClient.conversations.delete(conversationId);
|
|
76
|
+
for (const id of info.participants) {
|
|
77
|
+
if (WsClient.watchers.has(id)) {
|
|
78
|
+
WsClient.conversationsCache.set(conversationId, info.participants);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
static addWatchClient(wc) {
|
|
86
|
+
if (wc.id) {
|
|
87
|
+
WsClient.watchers.set(wc.id, wc);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
static removeWatchClient(wc) {
|
|
93
|
+
if (!wc.id) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const result = WsClient.watchers.delete(wc.id);
|
|
97
|
+
if (result) {
|
|
98
|
+
const toRemove = [];
|
|
99
|
+
WsClient.conversationsCache.forEach((v, k) => {
|
|
100
|
+
if (v.has(wc.id)) {
|
|
101
|
+
for (const id of v) {
|
|
102
|
+
if (WsClient.watchers.has(id)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
toRemove.push(k);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
toRemove.forEach(WsClient.conversationsCache.delete);
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
static publishToWatchList(userId, action) {
|
|
114
|
+
if (!WsClient.watchers.size) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const clients = new Set([userId]);
|
|
118
|
+
WsClient.conversations.forEach(info => {
|
|
119
|
+
if (info.participants.has(userId)) {
|
|
120
|
+
info.participants.forEach(p => clients.add(p));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
WsClient.conversationsCache.forEach(participants => {
|
|
124
|
+
if (participants.has(userId)) {
|
|
125
|
+
participants.forEach(p => clients.add(p));
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
clients.forEach(c => {
|
|
129
|
+
const client = WsClient.watchers.get(c);
|
|
130
|
+
client && action(client);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
static async getConversationParticipants(conversationId) {
|
|
134
|
+
const info = WsClient.conversations.get(conversationId);
|
|
135
|
+
if (info) {
|
|
136
|
+
return info.participants;
|
|
137
|
+
}
|
|
138
|
+
let participants = WsClient.conversationsCache.get(conversationId);
|
|
139
|
+
if (!participants) {
|
|
140
|
+
const conversation = await store.getConversationById(conversationId);
|
|
141
|
+
if (!conversation) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
participants = new Set(conversation.participants);
|
|
145
|
+
WsClient.conversationsCache.set(conversationId, participants);
|
|
146
|
+
}
|
|
147
|
+
return participants;
|
|
148
|
+
}
|
|
149
|
+
static async publishToWsList(conversationId, action, l) {
|
|
150
|
+
const tasks = [];
|
|
151
|
+
const info = WsClient.conversations.get(conversationId);
|
|
152
|
+
if (info) {
|
|
153
|
+
info.clients.forEach(client => {
|
|
154
|
+
l?.push(client.id);
|
|
155
|
+
tasks.push(action(client, info.participants));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (WsClient.watchers?.size) {
|
|
159
|
+
const participants = await WsClient.getConversationParticipants(conversationId);
|
|
160
|
+
participants?.forEach(id => {
|
|
161
|
+
const client = WsClient.watchers.get(id);
|
|
162
|
+
if (client) {
|
|
163
|
+
l?.push(client.id);
|
|
164
|
+
tasks.push(action(client));
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return Promise.all(tasks);
|
|
169
|
+
}
|
|
170
|
+
static async syncConversation(conversationId) {
|
|
171
|
+
const conversation = await store.getConversationById(conversationId);
|
|
172
|
+
if (!conversation) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
WsClient.conversationsCache.delete(conversationId);
|
|
176
|
+
const info = WsClient.conversations.get(conversationId);
|
|
177
|
+
if (info) {
|
|
178
|
+
const eqSet = (a, b) => {
|
|
179
|
+
return a.size === b.length && b.every(a.has.bind(a));
|
|
180
|
+
};
|
|
181
|
+
if (eqSet(info.participants, conversation.participants)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
info.participants = new Set(conversation.participants);
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
static async translateQueueMessage(qm) {
|
|
189
|
+
logger?.debug('Queue message received: ' + JSON.stringify(qm));
|
|
190
|
+
if (['connected', 'disconnected'].includes(qm.type)) {
|
|
191
|
+
if (qm.type === 'disconnected') {
|
|
192
|
+
WsClient.connectedClients.delete(qm.fromId);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
WsClient.connectedClients.add(qm.fromId);
|
|
196
|
+
}
|
|
197
|
+
WsClient.publishToWatchList(qm.fromId, wc => {
|
|
198
|
+
if (qm.connectionId !== wc.connectionId || qm.instanceId !== instanceId) {
|
|
199
|
+
wc.send({
|
|
200
|
+
id: qm.id,
|
|
201
|
+
connectionId: qm.connectionId,
|
|
202
|
+
fromId: qm.fromId,
|
|
203
|
+
type: qm.type,
|
|
204
|
+
createdAt: qm.createdAt,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (['closed', 'deleted'].includes(qm.type)) {
|
|
211
|
+
const conversationId = qm.data.conversationId ?? qm.conversationId;
|
|
212
|
+
if (conversationId) {
|
|
213
|
+
await WsClient.publishToWsList(conversationId, async (wc, _) => {
|
|
214
|
+
if (qm.connectionId !== wc.connectionId || qm.instanceId !== instanceId) {
|
|
215
|
+
wc.send(qm);
|
|
216
|
+
}
|
|
217
|
+
if (wc.conversation?.id === conversationId && qm.type === 'deleted') {
|
|
218
|
+
await wc.stop('Deleted');
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
if (qm.type === 'deleted') {
|
|
222
|
+
WsClient.conversationsCache.delete(conversationId);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
switch (qm.type) {
|
|
228
|
+
case 'text':
|
|
229
|
+
case 'file':
|
|
230
|
+
if (null === qm.data) {
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
/* FALLTHROUGH */
|
|
234
|
+
case 'joined':
|
|
235
|
+
case 'left':
|
|
236
|
+
case 'message-updated':
|
|
237
|
+
case 'message-deleted':
|
|
238
|
+
if (qm.conversationId) {
|
|
239
|
+
const ids = [];
|
|
240
|
+
await WsClient.publishToWsList(qm.conversationId, async (wc, _) => {
|
|
241
|
+
wc.send(qm);
|
|
242
|
+
}, ids);
|
|
243
|
+
}
|
|
244
|
+
break;
|
|
245
|
+
case 'updated':
|
|
246
|
+
{
|
|
247
|
+
const conversationId = qm.data.conversationId ?? qm.conversationId;
|
|
248
|
+
if (conversationId) {
|
|
249
|
+
const updated = await WsClient.syncConversation(conversationId);
|
|
250
|
+
await WsClient.publishToWsList(conversationId, async (wc, participants) => {
|
|
251
|
+
wc.send(qm);
|
|
252
|
+
if (updated && false === participants?.has(wc.id)) {
|
|
253
|
+
await wc.stop('Removed');
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async publishMessage(type, clientMessageId, data, save) {
|
|
262
|
+
let id = undefined;
|
|
263
|
+
const createdAt = new Date();
|
|
264
|
+
if (save) {
|
|
265
|
+
const m = {
|
|
266
|
+
type: type,
|
|
267
|
+
conversationId: this.conversation?.id,
|
|
268
|
+
participants: this.conversation?.participants,
|
|
269
|
+
connectionId: this.connectionId,
|
|
270
|
+
clientMessageId: clientMessageId,
|
|
271
|
+
fromId: this.id,
|
|
272
|
+
createdAt,
|
|
273
|
+
data: data,
|
|
274
|
+
};
|
|
275
|
+
const response = await store.saveMessage(m);
|
|
276
|
+
if (response.result !== 'created') {
|
|
277
|
+
logger?.error(`Index message failed`);
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
id = response?._id;
|
|
281
|
+
}
|
|
282
|
+
if (!Array.isArray(queue.acceptTypes) || queue.acceptTypes.includes(type)) {
|
|
283
|
+
return await queue.publish({
|
|
284
|
+
type,
|
|
285
|
+
id,
|
|
286
|
+
instanceId,
|
|
287
|
+
conversationId: this.conversation?.id,
|
|
288
|
+
participants: this.conversation?.participants,
|
|
289
|
+
connectionId: this.connectionId,
|
|
290
|
+
fromId: this.id,
|
|
291
|
+
clientMessageId: clientMessageId,
|
|
292
|
+
createdAt,
|
|
293
|
+
data: data,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
send(msg) {
|
|
299
|
+
if (this.transport && this.transport.readyState === TransportState.OPEN && sendStates.includes(this.state)) {
|
|
300
|
+
return this.transport.send(JSON.stringify(msg), { binary: false, fin: true });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async stop(statusDescription, err) {
|
|
304
|
+
if (logger && err?.message) {
|
|
305
|
+
logger.error(err.message);
|
|
306
|
+
}
|
|
307
|
+
if (this.state === WsClientState.Disconnected) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.state = WsClientState.Disconnected;
|
|
311
|
+
const maxStatusLen = 123;
|
|
312
|
+
const dotSpace = '. ';
|
|
313
|
+
[this.lastError, err?.message].forEach(v => {
|
|
314
|
+
if (v && statusDescription.length + dotSpace.length < maxStatusLen) {
|
|
315
|
+
statusDescription += dotSpace + v.substring(0, maxStatusLen - statusDescription.length - dotSpace.length);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
if (this.connectionId && this.id) {
|
|
319
|
+
if (this.conversation) {
|
|
320
|
+
await this.publishMessage('left', undefined, null, true);
|
|
321
|
+
}
|
|
322
|
+
await this.publishMessage('disconnected', undefined, null, false);
|
|
323
|
+
}
|
|
324
|
+
if ([TransportState.CLOSING, TransportState.CLOSED].includes(this.transport.readyState)) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (statusDescription.length > maxStatusLen) {
|
|
328
|
+
statusDescription = statusDescription.substring(0, maxStatusLen);
|
|
329
|
+
}
|
|
330
|
+
this.transport.close(err ? 1011 : 1000, statusDescription);
|
|
331
|
+
this.transport.removeAllListeners();
|
|
332
|
+
}
|
|
333
|
+
async watch() {
|
|
334
|
+
this.state = WsClientState.WatchSession;
|
|
335
|
+
const conversations = await this.getConversations(0, 0);
|
|
336
|
+
WsClient.addWatchClient(this);
|
|
337
|
+
this.send({ type: 'watching', conversations });
|
|
338
|
+
logger?.debug(`Watch client with id ${this.id} added successfully`);
|
|
339
|
+
}
|
|
340
|
+
async join(request) {
|
|
341
|
+
let conversation;
|
|
342
|
+
let created = false;
|
|
343
|
+
const data = request.data;
|
|
344
|
+
if (data.conversationId) {
|
|
345
|
+
conversation = await store.getParticipantConversationById(this.id, data.conversationId);
|
|
346
|
+
if (!conversation?.id) {
|
|
347
|
+
this.lastError = "Wrong conversation";
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
const participants = new Set(data.participants?.map(p => p.trim()).filter(s => s.length));
|
|
353
|
+
participants.add(this.id);
|
|
354
|
+
if (participants.size < 2) {
|
|
355
|
+
this.lastError = "Less than 2 participants";
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
let conversationId;
|
|
359
|
+
const participantsArray = Array.from(participants);
|
|
360
|
+
if (!data.title && participants.size == 2) {
|
|
361
|
+
conversationId = await store.getPeerToPeerConversationId(participantsArray[0], participantsArray[1]);
|
|
362
|
+
if (!conversationId) {
|
|
363
|
+
this.lastError = 'Unable to get peer to peer conversation identifier';
|
|
364
|
+
logger?.error(this.lastError);
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
conversation = await store.getConversationById(conversationId);
|
|
368
|
+
}
|
|
369
|
+
else if (!data.title) {
|
|
370
|
+
this.lastError = "Conversation title required";
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
const conversationsParticipans = conversation ? new Set(conversation.participants) : undefined;
|
|
374
|
+
if (!conversationsParticipans
|
|
375
|
+
|| participants.size !== conversationsParticipans.size
|
|
376
|
+
|| participantsArray.some(p => !conversationsParticipans.has(p))) {
|
|
377
|
+
const now = new Date();
|
|
378
|
+
conversation = {
|
|
379
|
+
id: conversationId,
|
|
380
|
+
participants: participantsArray,
|
|
381
|
+
title: conversation?.title ?? data.title,
|
|
382
|
+
createdBy: conversation?.createdBy ?? this.id,
|
|
383
|
+
updatedAt: conversation?.createdAt ? now : undefined,
|
|
384
|
+
createdAt: conversation?.createdAt ?? now,
|
|
385
|
+
};
|
|
386
|
+
const response = await store.saveConversation(conversation);
|
|
387
|
+
created = response.result === 'created';
|
|
388
|
+
if (!created && response.result !== 'updated') {
|
|
389
|
+
logger?.error(`Save conversation with id ${conversation.id} failed`);
|
|
390
|
+
this.lastError = "Save conversation failed";
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
conversation.id = response._id;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
this.state = WsClientState.Session;
|
|
397
|
+
this.conversation = conversation;
|
|
398
|
+
await WsClient.addClient(conversation, this);
|
|
399
|
+
const size = data.messagesSize ?? defaultSize;
|
|
400
|
+
let lastMessage = undefined;
|
|
401
|
+
let oldMessages = undefined;
|
|
402
|
+
if (!created) {
|
|
403
|
+
const fr = {
|
|
404
|
+
size,
|
|
405
|
+
conversationIds: [conversation.id],
|
|
406
|
+
types,
|
|
407
|
+
sort: 'createdAt',
|
|
408
|
+
sortDesc: true,
|
|
409
|
+
};
|
|
410
|
+
oldMessages = await store.findMessages(fr);
|
|
411
|
+
lastMessage = await store.getParticipantLastMessage(this.id, conversation.id);
|
|
412
|
+
}
|
|
413
|
+
const connected = conversation.participants.filter(p => WsClient.connectedClients.has(p));
|
|
414
|
+
const joined = {
|
|
415
|
+
type: 'conversation',
|
|
416
|
+
clientMessageId: request.clientMessageId,
|
|
417
|
+
conversation,
|
|
418
|
+
connected,
|
|
419
|
+
messages: oldMessages?.messages.reverse(),
|
|
420
|
+
total: oldMessages?.total,
|
|
421
|
+
leftAt: lastMessage?.createdAt,
|
|
422
|
+
closedAt: conversation.closedAt,
|
|
423
|
+
};
|
|
424
|
+
this.send(joined);
|
|
425
|
+
logger?.debug(`Client with id ${this.id} added successfully`);
|
|
426
|
+
return this.publishMessage('joined', request.clientMessageId, null, true);
|
|
427
|
+
}
|
|
428
|
+
onMessage(data, isBinary) {
|
|
429
|
+
try {
|
|
430
|
+
if (!(data instanceof Buffer)) {
|
|
431
|
+
throw new Error('Wrong message');
|
|
432
|
+
}
|
|
433
|
+
if (isBinary) {
|
|
434
|
+
throw new Error('Binary message received!');
|
|
435
|
+
}
|
|
436
|
+
if (sendStates.includes(this.state)) {
|
|
437
|
+
const msg = JSON.parse(data.toString());
|
|
438
|
+
if (connectedRequestTypes.includes(msg.type)) {
|
|
439
|
+
this.processRequest(msg).then(result => {
|
|
440
|
+
if (!result) {
|
|
441
|
+
this.stop('Failed processRequest');
|
|
442
|
+
}
|
|
443
|
+
}).catch(e => {
|
|
444
|
+
this.stop('Failed processRequest', e);
|
|
445
|
+
});
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
switch (this.state) {
|
|
450
|
+
case WsClientState.None:
|
|
451
|
+
{
|
|
452
|
+
const request = JSON.parse(data.toString());
|
|
453
|
+
this.connect(request).then(response => {
|
|
454
|
+
if (!response) {
|
|
455
|
+
this.stop('Failed connect');
|
|
456
|
+
}
|
|
457
|
+
}).catch(e => {
|
|
458
|
+
this.stop('Failed connect', e);
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
break;
|
|
462
|
+
case WsClientState.Connected:
|
|
463
|
+
{
|
|
464
|
+
const request = JSON.parse(data.toString());
|
|
465
|
+
switch (request.type) {
|
|
466
|
+
case 'join':
|
|
467
|
+
this.join(request).then(response => {
|
|
468
|
+
if (!response) {
|
|
469
|
+
this.stop('Failed join');
|
|
470
|
+
}
|
|
471
|
+
}).catch(e => {
|
|
472
|
+
this.stop('Failed join', e);
|
|
473
|
+
});
|
|
474
|
+
break;
|
|
475
|
+
case 'watch':
|
|
476
|
+
this.watch().catch(e => {
|
|
477
|
+
this.stop('Failed watch', e);
|
|
478
|
+
});
|
|
479
|
+
break;
|
|
480
|
+
default:
|
|
481
|
+
throw new Error('Wrong request type');
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
case WsClientState.Session:
|
|
486
|
+
case WsClientState.WatchSession:
|
|
487
|
+
{
|
|
488
|
+
const request = JSON.parse(data.toString());
|
|
489
|
+
if (request) {
|
|
490
|
+
this.processConversationRequest(request).then(result => {
|
|
491
|
+
if (!result) {
|
|
492
|
+
this.stop('Failed processConversationRequest');
|
|
493
|
+
}
|
|
494
|
+
}).catch(e => {
|
|
495
|
+
this.stop('Failed processConversationRequest', e);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
this.stop('Wrong message');
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
break;
|
|
503
|
+
case WsClientState.Disconnected:
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
catch (e) {
|
|
508
|
+
this.stop('Failed message processing', e);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
onClose() {
|
|
512
|
+
this.stop('Stopped').finally(() => {
|
|
513
|
+
if (this.conversation?.id) {
|
|
514
|
+
WsClient.removeClient(this.conversation.id, this);
|
|
515
|
+
logger?.debug(`Client with id ${this.id} removed successfully`);
|
|
516
|
+
}
|
|
517
|
+
else if (WsClientState.WatchSession === this.state) {
|
|
518
|
+
WsClient.removeWatchClient(this);
|
|
519
|
+
logger?.debug(`Watch client with id ${this.id} removed successfully`);
|
|
520
|
+
}
|
|
521
|
+
delete this.conversation;
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
async deleteMessage(request) {
|
|
525
|
+
const findResult = await store.findMessages({
|
|
526
|
+
ids: [request.messageId],
|
|
527
|
+
conversationIds: [this.conversation.id],
|
|
528
|
+
});
|
|
529
|
+
const message = findResult.messages?.[0];
|
|
530
|
+
if (!message || message.fromId != this.id) {
|
|
531
|
+
this.lastError = 'User is not allowed to delete message';
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
message.deletedAt = new Date();
|
|
535
|
+
const response = await store.saveMessage(message);
|
|
536
|
+
if (response.result !== 'updated') {
|
|
537
|
+
logger?.error(`Delete message with id ${message.id} failed`);
|
|
538
|
+
this.lastError = 'Delete message failed';
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
logger?.debug(`Message with id ${message.id} was deleted successfully`);
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
async updateMessage(request) {
|
|
545
|
+
const findResult = await store.findMessages({
|
|
546
|
+
ids: [request.messageId],
|
|
547
|
+
conversationIds: [this.conversation.id],
|
|
548
|
+
});
|
|
549
|
+
const message = findResult.messages?.[0];
|
|
550
|
+
if (!message) {
|
|
551
|
+
this.lastError = 'Wrong message';
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
if (message.fromId !== this.id) {
|
|
555
|
+
this.lastError = 'User is not allowed to update message';
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
switch (message.type) {
|
|
559
|
+
case 'file':
|
|
560
|
+
{
|
|
561
|
+
const { link, name, type, size } = request;
|
|
562
|
+
message.data = { link, name, type, size };
|
|
563
|
+
}
|
|
564
|
+
break;
|
|
565
|
+
case 'text':
|
|
566
|
+
{
|
|
567
|
+
const { text } = request;
|
|
568
|
+
message.data = { text };
|
|
569
|
+
}
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
message.updatedAt = request.updatedAt;
|
|
573
|
+
const response = await store.saveMessage(message);
|
|
574
|
+
if (response.result !== 'updated') {
|
|
575
|
+
logger?.error(`Update message with id ${message.id} failed`);
|
|
576
|
+
this.lastError = 'Update message failed';
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
logger?.debug(`Message with id ${message.id} was updated successfully`);
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
async updateConversation(data) {
|
|
583
|
+
const conversation = data.conversationId ? await store.getConversationById(data.conversationId) : this.conversation;
|
|
584
|
+
if (!conversation || this.id !== conversation.createdBy) {
|
|
585
|
+
//Only creator can update conversation
|
|
586
|
+
this.lastError = 'User is not allowed to update conversation';
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
conversation.title = data.title;
|
|
590
|
+
conversation.updatedAt = data.updatedAt;
|
|
591
|
+
const participants = new Set([conversation.createdBy]);
|
|
592
|
+
data.participants?.forEach(p => participants.add(p.trim()));
|
|
593
|
+
conversation.participants = Array.from(participants);
|
|
594
|
+
const response = await store.saveConversation(conversation);
|
|
595
|
+
if (response.result !== 'updated') {
|
|
596
|
+
logger?.error(`Update conversation with id ${conversation.id} failed`);
|
|
597
|
+
this.lastError = 'Update conversation failed';
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
logger?.debug(`Conversation with id ${conversation.id} was updated successfully`);
|
|
601
|
+
return true;
|
|
602
|
+
}
|
|
603
|
+
async closeDeleteConversation(data, del) {
|
|
604
|
+
const id = data.conversationId ?? this.conversation?.id;
|
|
605
|
+
if (!id) {
|
|
606
|
+
this.lastError = 'Wrong conversation identifier';
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
const conversation = await store.getConversationById(id);
|
|
610
|
+
if (!conversation) {
|
|
611
|
+
//Only creator can close or delete conversation
|
|
612
|
+
this.lastError = 'Conversation not found';
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
if (!del && conversation.closedAt) {
|
|
616
|
+
this.lastError = 'Conversation already closed';
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
if (conversation.deletedAt) {
|
|
620
|
+
this.lastError = 'Conversation already deleted';
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
623
|
+
let type = 'updated';
|
|
624
|
+
if (this.id === conversation.createdBy) {
|
|
625
|
+
//Only creator can close or delete conversation
|
|
626
|
+
conversation.closedAt = data.closedAt;
|
|
627
|
+
if (del) {
|
|
628
|
+
conversation.deletedAt = data.deletedAt;
|
|
629
|
+
type = 'deleted';
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
type = 'closed';
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
else if (del) {
|
|
636
|
+
//leave conversation
|
|
637
|
+
const count = conversation.participants.length;
|
|
638
|
+
conversation.participants = conversation.participants.filter(p => p !== this.id);
|
|
639
|
+
if (count === conversation.participants.length) {
|
|
640
|
+
this.lastError = 'User is not allowed to delete conversation';
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
data.participants = conversation.participants;
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
this.lastError = 'User is not allowed to close conversation';
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
const response = await store.saveConversation(conversation);
|
|
650
|
+
if (response.result !== 'updated') {
|
|
651
|
+
logger?.error(`Close conversation with id ${conversation.id} failed`);
|
|
652
|
+
this.lastError = 'Close conversation failed';
|
|
653
|
+
return null;
|
|
654
|
+
}
|
|
655
|
+
logger?.debug(`Conversation with id ${conversation.id} was updated successfully`);
|
|
656
|
+
return type;
|
|
657
|
+
}
|
|
658
|
+
async processRequest(request) {
|
|
659
|
+
if (!request.data) {
|
|
660
|
+
this.lastError = 'Wrong message';
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
const clientMessageId = request.clientMessageId;
|
|
664
|
+
switch (request.type) {
|
|
665
|
+
case 'close':
|
|
666
|
+
case 'delete':
|
|
667
|
+
{
|
|
668
|
+
const { conversationId } = request.data;
|
|
669
|
+
const now = new Date();
|
|
670
|
+
let data = {
|
|
671
|
+
conversationId,
|
|
672
|
+
closedAt: now,
|
|
673
|
+
};
|
|
674
|
+
const del = request.type === 'delete';
|
|
675
|
+
if (del) {
|
|
676
|
+
data.deletedAt = now;
|
|
677
|
+
}
|
|
678
|
+
let type = await this.closeDeleteConversation(data, del);
|
|
679
|
+
if (type) {
|
|
680
|
+
this.send({ type, clientMessageId, data });
|
|
681
|
+
return this.publishMessage(type, clientMessageId, data, true);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
break;
|
|
685
|
+
case 'load':
|
|
686
|
+
await this.loadConversations(request.data, clientMessageId);
|
|
687
|
+
return true;
|
|
688
|
+
case 'update':
|
|
689
|
+
{
|
|
690
|
+
const { conversationId, title, participants } = request.data;
|
|
691
|
+
let data = {
|
|
692
|
+
conversationId,
|
|
693
|
+
title,
|
|
694
|
+
participants,
|
|
695
|
+
updatedAt: new Date(),
|
|
696
|
+
};
|
|
697
|
+
if (await this.updateConversation(data)) {
|
|
698
|
+
const type = 'updated';
|
|
699
|
+
this.send({ type, clientMessageId, data });
|
|
700
|
+
return this.publishMessage(type, clientMessageId, data, true);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
async processConversationRequest(request) {
|
|
708
|
+
if (!request.data) {
|
|
709
|
+
this.lastError = 'Wrong message';
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
const verifyConversation = () => {
|
|
713
|
+
if (this.conversation.closedAt) {
|
|
714
|
+
this.lastError = 'Conversation closed';
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
return true;
|
|
718
|
+
};
|
|
719
|
+
let broadcastType = request.type;
|
|
720
|
+
switch (request.type) {
|
|
721
|
+
case 'text':
|
|
722
|
+
if (!verifyConversation()) {
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
break;
|
|
726
|
+
case 'file':
|
|
727
|
+
if (!verifyConversation()) {
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
if (!request.data.name) {
|
|
731
|
+
this.lastError = 'Wrong file name';
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
break;
|
|
735
|
+
case 'message-update':
|
|
736
|
+
request.data.updatedAt = new Date();
|
|
737
|
+
if (!await this.updateMessage(request.data)) {
|
|
738
|
+
return false;
|
|
739
|
+
}
|
|
740
|
+
broadcastType = 'message-updated';
|
|
741
|
+
break;
|
|
742
|
+
case 'message-delete':
|
|
743
|
+
if (!await this.deleteMessage(request.data)) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
broadcastType = 'message-deleted';
|
|
747
|
+
break;
|
|
748
|
+
case 'find':
|
|
749
|
+
await this.findMessages(request.data, request.clientMessageId);
|
|
750
|
+
return true;
|
|
751
|
+
case 'load-messages':
|
|
752
|
+
await this.loadMessages(request.data, request.clientMessageId);
|
|
753
|
+
return true;
|
|
754
|
+
default:
|
|
755
|
+
this.lastError = 'Wrong message type';
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
return this.publishMessage(broadcastType, request.clientMessageId, request.data, true);
|
|
759
|
+
}
|
|
760
|
+
async connect(request) {
|
|
761
|
+
this.id = request?.authInfo && await userStore.authenticate(request.authInfo);
|
|
762
|
+
if (!this.id) {
|
|
763
|
+
this.lastError = 'Authentication failed';
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
this.state = WsClientState.Authenticated;
|
|
767
|
+
const response = await store.saveConnection(this.id, instanceId);
|
|
768
|
+
if (response.result !== 'created') {
|
|
769
|
+
logger?.debug(`Save connection with id ${response._id} failed`);
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
this.state = WsClientState.Connected;
|
|
773
|
+
this.connectionId = response._id;
|
|
774
|
+
logger?.debug(`Save connection with id ${this.connectionId} succeeded`);
|
|
775
|
+
const conversations = await this.getConversations(0, request.conversationsSize);
|
|
776
|
+
this.transport.send(JSON.stringify({
|
|
777
|
+
type: 'connection',
|
|
778
|
+
connectionId: this.connectionId,
|
|
779
|
+
id: this.id,
|
|
780
|
+
conversations,
|
|
781
|
+
}), { binary: false, fin: true });
|
|
782
|
+
return this.publishMessage('connected', undefined, null, false);
|
|
783
|
+
}
|
|
784
|
+
async getConversations(from = 0, conversationsSize, excludeIds) {
|
|
785
|
+
const size = conversationsSize != null && conversationsSize >= 0 ? conversationsSize : defaultSize;
|
|
786
|
+
const result = await store.getParticipantConversations(this.id, excludeIds || [], from, size);
|
|
787
|
+
const ids = result.conversations.map(c => c.id);
|
|
788
|
+
if (!ids?.length) {
|
|
789
|
+
return result;
|
|
790
|
+
}
|
|
791
|
+
const messagesInfo = await store.getLastMessagesTimestamps(this.id, ids);
|
|
792
|
+
const conversations = result.conversations.map(c => ({
|
|
793
|
+
...c,
|
|
794
|
+
leftAt: c.id in messagesInfo ? messagesInfo[c.id].left : undefined,
|
|
795
|
+
latestMessage: c.id in messagesInfo ? messagesInfo[c.id].latest : undefined,
|
|
796
|
+
}));
|
|
797
|
+
return {
|
|
798
|
+
conversations,
|
|
799
|
+
from,
|
|
800
|
+
size,
|
|
801
|
+
total: result.total,
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
async findMessages(request, clientMessageId) {
|
|
805
|
+
const result = await store.getParticipantConversations(this.id, [], request.from ?? 0, request.size ?? defaultSize);
|
|
806
|
+
if (request.conversationIds?.length) {
|
|
807
|
+
request.conversationIds = Array.from(new Set(result.conversations.map(c => c.id).concat(request.conversationIds)));
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
request.conversationIds = result.conversations.map(c => c.id);
|
|
811
|
+
}
|
|
812
|
+
const findResult = await store.findMessages(request);
|
|
813
|
+
this.send({ type: 'find', clientMessageId, messages: findResult.messages, from: findResult.from, size: findResult.size, total: findResult.total });
|
|
814
|
+
}
|
|
815
|
+
async loadMessages(request, clientMessageId) {
|
|
816
|
+
if (!this.conversation?.id) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const findRequest = {
|
|
820
|
+
from: request.from,
|
|
821
|
+
size: request.size,
|
|
822
|
+
sort: 'createdAt',
|
|
823
|
+
sortDesc: true,
|
|
824
|
+
conversationIds: [this.conversation.id],
|
|
825
|
+
createdTo: request.before,
|
|
826
|
+
types,
|
|
827
|
+
excludeIds: request.excludeIds,
|
|
828
|
+
};
|
|
829
|
+
const result = await store.findMessages(findRequest);
|
|
830
|
+
result.messages.reverse();
|
|
831
|
+
this.send({ type: 'loaded-messages', clientMessageId, messages: result.messages, count: result.total });
|
|
832
|
+
}
|
|
833
|
+
async loadConversations(request, clientMessageId) {
|
|
834
|
+
const result = await this.getConversations(request.from, request.size, request.excludeIds);
|
|
835
|
+
this.send({ type: 'loaded', clientMessageId, conversations: result.conversations, count: result.total });
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
export function initialize(config, log) {
|
|
839
|
+
instanceId = config.instanceId;
|
|
840
|
+
logger = log;
|
|
841
|
+
queue = config.queue;
|
|
842
|
+
store = config.store;
|
|
843
|
+
userStore = config.userStore;
|
|
844
|
+
queue?.subscribe(WsClient.translateQueueMessage);
|
|
845
|
+
}
|
|
846
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACtB,sCAAsC;IACtC,+DAAc,CAAA;IACd,uDAAuD;IACvD,mDAAI,CAAA;IACJ,mDAAmD;IACnD,yDAAO,CAAA;IACP,gCAAgC;IAChC,uDAAM,CAAA;AACV,CAAC,EATW,cAAc,KAAd,cAAc,QASzB;AA2CD,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACrB,iDAAQ,CAAA;IACR,mEAAiB,CAAA;IACjB,2DAAa,CAAA;IACb,uDAAW,CAAA;IACX,iEAAgB,CAAA;IAChB,mEAAmB,CAAA;AACvB,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB;AAED,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,UAAU,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;AAEhG,MAAM,qBAAqB,GAAkB,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEnF,MAAM,KAAK,GAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD,IAAI,UAAU,GAAW,SAAU,CAAC;AACpC,IAAI,MAAuB,CAAC;AAC5B,IAAI,KAAK,GAAiB,SAAU,CAAC;AACrC,IAAI,KAAK,GAAiB,SAAU,CAA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AE,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5G,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,OAAoB,EAAE,eAAwB;QAC1E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE3F,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7G,CAAC;;AAGL,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,GAAS;IAChD,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IAC/B,MAAM,GAAG,GAAG,CAAC;IACb,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IACrB,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IACrB,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IAE7B,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AACrD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@only-chat/client",
|
|
3
|
+
"version": "0.2.0-beta.10",
|
|
4
|
+
"description": "Client for only-chat",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/only-chat/node-backend.git",
|
|
11
|
+
"directory": "packages/client"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc --project tsconfig.production.json",
|
|
15
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
16
|
+
},
|
|
17
|
+
"author": "only-chat",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@jest/globals": "^29.7.0",
|
|
21
|
+
"@only-chat/in-memory-queue": "0.2.0-beta.10",
|
|
22
|
+
"@only-chat/in-memory-store": "0.2.0-beta.10",
|
|
23
|
+
"@only-chat/in-memory-user-store": "0.2.0-beta.10",
|
|
24
|
+
"@only-chat/types": "0.2.0-beta.10",
|
|
25
|
+
"@types/jest": "^29.5.12",
|
|
26
|
+
"jest": "^29.7.0",
|
|
27
|
+
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
28
|
+
"ts-jest": "^29.1.4",
|
|
29
|
+
"ts-node": "^10.9.2",
|
|
30
|
+
"typescript": "^5.4.5"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/"
|
|
36
|
+
],
|
|
37
|
+
"keywords": [
|
|
38
|
+
"only-chat",
|
|
39
|
+
"client"
|
|
40
|
+
]
|
|
41
|
+
}
|