ncloudchat 1.0.9 → 1.0.12
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/deploy.sh +20 -0
- package/esm/CloudChat.d.ts +8 -3
- package/esm/CloudChat.js +231 -83
- package/esm/CloudChat.js.map +1 -1
- package/esm/mutations/channel.d.ts +2 -1
- package/esm/mutations/channel.js +47 -7
- package/esm/mutations/channel.js.map +1 -1
- package/esm/mutations/subscription.d.ts +2 -2
- package/esm/mutations/subscription.js +78 -71
- package/esm/mutations/subscription.js.map +1 -1
- package/esm/queries/channel.js +2 -2
- package/esm/queries/channel.js.map +1 -1
- package/lib/CloudChat.js +316 -83
- package/lib/mutations/channel.js +58 -9
- package/lib/mutations/subscription.js +15 -6
- package/lib/queries/channel.js +2 -2
- package/package.json +3 -4
package/deploy.sh
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
VERSION='';
|
|
2
|
+
re="\"(version)\": \"([^\"]*)\"";
|
|
3
|
+
|
|
4
|
+
while read -r l; do
|
|
5
|
+
if [[ $l =~ $re ]]; then
|
|
6
|
+
value="${BASH_REMATCH[2]}";
|
|
7
|
+
VERSION="$value";
|
|
8
|
+
fi
|
|
9
|
+
done < package.json;
|
|
10
|
+
|
|
11
|
+
if [ "dev" == "$1" ]; then
|
|
12
|
+
npm run build
|
|
13
|
+
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp dist/ncloudchat-${VERSION}.min.js s3://ncloudchat/dev/ --acl public-read
|
|
14
|
+
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp dist/ncloudchat-${VERSION}.min.js s3://ncloudchat/dev/ncloudchat-lastest.min.js --acl public-read
|
|
15
|
+
|
|
16
|
+
elif [ "release" = "$1" ]; then
|
|
17
|
+
npm run build
|
|
18
|
+
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp dist/ncloudchat-${VERSION}.min.js s3://ncloudchat/ --acl public-read
|
|
19
|
+
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp dist/ncloudchat-${VERSION}.min.js s3://ncloudchat/ncloudchat-lastest.min.js --acl public-read
|
|
20
|
+
fi
|
package/esm/CloudChat.d.ts
CHANGED
|
@@ -15,9 +15,10 @@ export default class NCloudChat {
|
|
|
15
15
|
setToken(token: string): void;
|
|
16
16
|
setUser(user: any): void;
|
|
17
17
|
connect(user: any, userToken?: string): Promise<any>;
|
|
18
|
-
|
|
18
|
+
mute(channel: string): Promise<any>;
|
|
19
|
+
unmute(channel: string): Promise<any>;
|
|
20
|
+
subscribe(channel: string, option?: any): Promise<any>;
|
|
19
21
|
unsubscribe(channel: string): Promise<any>;
|
|
20
|
-
inviteMembers(channelId: string, memberIds: any): Promise<any>;
|
|
21
22
|
translateMessage(channelId: string, source: string, target: string, message: string): Promise<any>;
|
|
22
23
|
sendMessage(channel: string, opt: any): Promise<any>;
|
|
23
24
|
sendImage(channelId: string, file: any): Promise<any>;
|
|
@@ -45,5 +46,9 @@ export default class NCloudChat {
|
|
|
45
46
|
createChannel(channel: ChannelInput): Promise<any>;
|
|
46
47
|
updateChannel(channelId: string, channel: ChannelInput): Promise<any>;
|
|
47
48
|
deleteChannel(channelId: string): Promise<any>;
|
|
48
|
-
markRead(channelId: string, mark: MarkInput): Promise<any>;
|
|
49
|
+
markRead(channelId: string, mark: MarkInput, option?: any): Promise<any>;
|
|
50
|
+
addMembers(channelId: string, memberIds: any, options: any): Promise<any>;
|
|
51
|
+
removeMembers(channelId: string, memberIds: any, options: any): Promise<any>;
|
|
52
|
+
startTyping(channelId: string, threadId?: string): Promise<any>;
|
|
53
|
+
stopTyping(channelId: string, threadId?: string): Promise<any>;
|
|
49
54
|
}
|
package/esm/CloudChat.js
CHANGED
|
@@ -50,7 +50,7 @@ import CoreManager from "./CoreManager";
|
|
|
50
50
|
import Dispatcher from "./Dispatcher";
|
|
51
51
|
import { info } from "./logger";
|
|
52
52
|
import { getChannel, getChannels, getMessage, getMessages, getSubscription, getSubscriptions, getMembers, getFriendships, unreadCount, } from "./queries";
|
|
53
|
-
import { login, createChannel, updateChannel, deleteChannel, translate, upload,
|
|
53
|
+
import { login, createChannel, updateChannel, deleteChannel, translate, upload, createSubscription, deleteSubscription, updateSubscription, addChannelMembers, removeChannelMembers, requestFriend, acceptFriend, rejectFriend, removeFriend } from "./mutations";
|
|
54
54
|
var NCloudChat = /** @class */ (function () {
|
|
55
55
|
function NCloudChat() {
|
|
56
56
|
this.socket = null;
|
|
@@ -68,8 +68,6 @@ var NCloudChat = /** @class */ (function () {
|
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
70
|
NCloudChat.prototype.getLang = function () {
|
|
71
|
-
if (typeof navigator === 'undefined')
|
|
72
|
-
return "en";
|
|
73
71
|
return navigator.language;
|
|
74
72
|
};
|
|
75
73
|
NCloudChat.prototype.getUser = function () {
|
|
@@ -169,18 +167,53 @@ var NCloudChat = /** @class */ (function () {
|
|
|
169
167
|
_this.dp.dispatch("onDisconnected", reason);
|
|
170
168
|
});
|
|
171
169
|
this.socket.on("message", function (payload) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
_this.dp.dispatch("onMessageReceived", message.channel_id, message);
|
|
175
|
-
}
|
|
176
|
-
catch (e) {
|
|
177
|
-
console.error(e);
|
|
178
|
-
}
|
|
170
|
+
var message = JSON.parse(payload);
|
|
171
|
+
_this.dp.dispatch("onMessageReceived", message.channel_id, message);
|
|
179
172
|
});
|
|
180
173
|
this.socket.on("event", function (payload) {
|
|
181
174
|
var message = JSON.parse(payload);
|
|
182
175
|
_this.dp.dispatch("onEventReceived", message.channel_id, message);
|
|
183
176
|
});
|
|
177
|
+
this.socket.on("start typing", function (payload) {
|
|
178
|
+
var data = JSON.parse(payload);
|
|
179
|
+
_this.dp.dispatch("onStartTyping", data);
|
|
180
|
+
});
|
|
181
|
+
this.socket.on("stop typing", function (payload) {
|
|
182
|
+
var data = JSON.parse(payload);
|
|
183
|
+
_this.dp.dispatch("onStopTyping", data);
|
|
184
|
+
});
|
|
185
|
+
this.socket.on("member added", function (payload) {
|
|
186
|
+
var data = JSON.parse(payload);
|
|
187
|
+
_this.dp.dispatch("onMemberAdded", data);
|
|
188
|
+
});
|
|
189
|
+
this.socket.on("member removed", function (payload) {
|
|
190
|
+
var data = JSON.parse(payload);
|
|
191
|
+
_this.dp.dispatch("onMemberRemoved", data);
|
|
192
|
+
});
|
|
193
|
+
this.socket.on("member updated", function (payload) {
|
|
194
|
+
var data = JSON.parse(payload);
|
|
195
|
+
_this.dp.dispatch("onMemberUpdated", data);
|
|
196
|
+
});
|
|
197
|
+
this.socket.on("message deleted", function (payload) {
|
|
198
|
+
var data = JSON.parse(payload);
|
|
199
|
+
_this.dp.dispatch("onMessageDeleted", data);
|
|
200
|
+
});
|
|
201
|
+
this.socket.on("message updated", function (payload) {
|
|
202
|
+
var data = JSON.parse(payload);
|
|
203
|
+
_this.dp.dispatch("onMessageUpdated", data);
|
|
204
|
+
});
|
|
205
|
+
this.socket.on("user banned", function (payload) {
|
|
206
|
+
var data = JSON.parse(payload);
|
|
207
|
+
_this.dp.dispatch("onUserBanned", data);
|
|
208
|
+
});
|
|
209
|
+
this.socket.on("user deleted", function (payload) {
|
|
210
|
+
var data = JSON.parse(payload);
|
|
211
|
+
_this.dp.dispatch("onUserDeleted", data);
|
|
212
|
+
});
|
|
213
|
+
this.socket.on("user updated", function (payload) {
|
|
214
|
+
var data = JSON.parse(payload);
|
|
215
|
+
_this.dp.dispatch("onUserUpdated", data);
|
|
216
|
+
});
|
|
184
217
|
this.socket.on("result", function (payload) {
|
|
185
218
|
var message = JSON.parse(payload);
|
|
186
219
|
_this.dp.dispatch("onResult", message);
|
|
@@ -194,8 +227,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
194
227
|
});
|
|
195
228
|
});
|
|
196
229
|
};
|
|
197
|
-
NCloudChat.prototype.
|
|
198
|
-
if (language === void 0) { language = 'en'; }
|
|
230
|
+
NCloudChat.prototype.mute = function (channel) {
|
|
199
231
|
return __awaiter(this, void 0, void 0, function () {
|
|
200
232
|
var subscription, e_2;
|
|
201
233
|
return __generator(this, function (_a) {
|
|
@@ -207,7 +239,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
207
239
|
_a.label = 1;
|
|
208
240
|
case 1:
|
|
209
241
|
_a.trys.push([1, 3, , 4]);
|
|
210
|
-
return [4 /*yield*/,
|
|
242
|
+
return [4 /*yield*/, updateSubscription(channel, null, JSON.stringify({ mute: true }))];
|
|
211
243
|
case 2:
|
|
212
244
|
subscription = _a.sent();
|
|
213
245
|
if (subscription)
|
|
@@ -221,9 +253,9 @@ var NCloudChat = /** @class */ (function () {
|
|
|
221
253
|
});
|
|
222
254
|
});
|
|
223
255
|
};
|
|
224
|
-
NCloudChat.prototype.
|
|
256
|
+
NCloudChat.prototype.unmute = function (channel) {
|
|
225
257
|
return __awaiter(this, void 0, void 0, function () {
|
|
226
|
-
var
|
|
258
|
+
var subscription, e_3;
|
|
227
259
|
return __generator(this, function (_a) {
|
|
228
260
|
switch (_a.label) {
|
|
229
261
|
case 0:
|
|
@@ -233,12 +265,11 @@ var NCloudChat = /** @class */ (function () {
|
|
|
233
265
|
_a.label = 1;
|
|
234
266
|
case 1:
|
|
235
267
|
_a.trys.push([1, 3, , 4]);
|
|
236
|
-
|
|
237
|
-
if (!user.id)
|
|
238
|
-
throw Error("unauthorized");
|
|
239
|
-
return [4 /*yield*/, deleteSubscription(channel)];
|
|
268
|
+
return [4 /*yield*/, updateSubscription(channel, null, JSON.stringify({ mute: false }))];
|
|
240
269
|
case 2:
|
|
241
270
|
subscription = _a.sent();
|
|
271
|
+
if (subscription)
|
|
272
|
+
subscription.id = this.ObjectId(subscription.id);
|
|
242
273
|
return [2 /*return*/, subscription];
|
|
243
274
|
case 3:
|
|
244
275
|
e_3 = _a.sent();
|
|
@@ -248,9 +279,10 @@ var NCloudChat = /** @class */ (function () {
|
|
|
248
279
|
});
|
|
249
280
|
});
|
|
250
281
|
};
|
|
251
|
-
NCloudChat.prototype.
|
|
282
|
+
NCloudChat.prototype.subscribe = function (channel, option) {
|
|
283
|
+
if (option === void 0) { option = null; }
|
|
252
284
|
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
-
var
|
|
285
|
+
var subscription, e_4;
|
|
254
286
|
return __generator(this, function (_a) {
|
|
255
287
|
switch (_a.label) {
|
|
256
288
|
case 0:
|
|
@@ -260,13 +292,12 @@ var NCloudChat = /** @class */ (function () {
|
|
|
260
292
|
_a.label = 1;
|
|
261
293
|
case 1:
|
|
262
294
|
_a.trys.push([1, 3, , 4]);
|
|
263
|
-
|
|
264
|
-
if (!user.id)
|
|
265
|
-
throw Error("unauthorized");
|
|
266
|
-
return [4 /*yield*/, createInviteMember(channelId, memberIds)];
|
|
295
|
+
return [4 /*yield*/, createSubscription(channel, JSON.stringify(option))];
|
|
267
296
|
case 2:
|
|
268
|
-
|
|
269
|
-
|
|
297
|
+
subscription = _a.sent();
|
|
298
|
+
if (subscription)
|
|
299
|
+
subscription.id = this.ObjectId(subscription.id);
|
|
300
|
+
return [2 /*return*/, subscription];
|
|
270
301
|
case 3:
|
|
271
302
|
e_4 = _a.sent();
|
|
272
303
|
throw e_4;
|
|
@@ -275,9 +306,33 @@ var NCloudChat = /** @class */ (function () {
|
|
|
275
306
|
});
|
|
276
307
|
});
|
|
277
308
|
};
|
|
309
|
+
NCloudChat.prototype.unsubscribe = function (channel) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
311
|
+
var subscription, e_5;
|
|
312
|
+
return __generator(this, function (_a) {
|
|
313
|
+
switch (_a.label) {
|
|
314
|
+
case 0:
|
|
315
|
+
if (!this.isConnected()) {
|
|
316
|
+
throw Error("You are not connected.");
|
|
317
|
+
}
|
|
318
|
+
_a.label = 1;
|
|
319
|
+
case 1:
|
|
320
|
+
_a.trys.push([1, 3, , 4]);
|
|
321
|
+
return [4 /*yield*/, deleteSubscription(channel)];
|
|
322
|
+
case 2:
|
|
323
|
+
subscription = _a.sent();
|
|
324
|
+
return [2 /*return*/, subscription];
|
|
325
|
+
case 3:
|
|
326
|
+
e_5 = _a.sent();
|
|
327
|
+
throw e_5;
|
|
328
|
+
case 4: return [2 /*return*/, null];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
};
|
|
278
333
|
NCloudChat.prototype.translateMessage = function (channelId, source, target, message) {
|
|
279
334
|
return __awaiter(this, void 0, void 0, function () {
|
|
280
|
-
var user, result,
|
|
335
|
+
var user, result, e_6;
|
|
281
336
|
return __generator(this, function (_a) {
|
|
282
337
|
switch (_a.label) {
|
|
283
338
|
case 0:
|
|
@@ -293,8 +348,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
293
348
|
result = _a.sent();
|
|
294
349
|
return [2 /*return*/, result];
|
|
295
350
|
case 3:
|
|
296
|
-
|
|
297
|
-
throw Error(
|
|
351
|
+
e_6 = _a.sent();
|
|
352
|
+
throw Error(e_6.message);
|
|
298
353
|
case 4: return [2 /*return*/, null];
|
|
299
354
|
}
|
|
300
355
|
});
|
|
@@ -405,7 +460,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
405
460
|
if (sort === void 0) { sort = {}; }
|
|
406
461
|
if (option === void 0) { option = {}; }
|
|
407
462
|
return __awaiter(this, void 0, void 0, function () {
|
|
408
|
-
var entries, friends,
|
|
463
|
+
var entries, friends, e_7;
|
|
409
464
|
return __generator(this, function (_a) {
|
|
410
465
|
switch (_a.label) {
|
|
411
466
|
case 0:
|
|
@@ -426,8 +481,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
426
481
|
}
|
|
427
482
|
return [2 /*return*/, entries];
|
|
428
483
|
case 3:
|
|
429
|
-
|
|
430
|
-
throw
|
|
484
|
+
e_7 = _a.sent();
|
|
485
|
+
throw e_7;
|
|
431
486
|
case 4: return [2 /*return*/];
|
|
432
487
|
}
|
|
433
488
|
});
|
|
@@ -437,7 +492,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
437
492
|
if (sort === void 0) { sort = {}; }
|
|
438
493
|
if (option === void 0) { option = {}; }
|
|
439
494
|
return __awaiter(this, void 0, void 0, function () {
|
|
440
|
-
var entries, members,
|
|
495
|
+
var entries, members, e_8;
|
|
441
496
|
var _this = this;
|
|
442
497
|
return __generator(this, function (_a) {
|
|
443
498
|
switch (_a.label) {
|
|
@@ -459,8 +514,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
459
514
|
}
|
|
460
515
|
return [2 /*return*/, entries];
|
|
461
516
|
case 3:
|
|
462
|
-
|
|
463
|
-
throw
|
|
517
|
+
e_8 = _a.sent();
|
|
518
|
+
throw e_8;
|
|
464
519
|
case 4: return [2 /*return*/];
|
|
465
520
|
}
|
|
466
521
|
});
|
|
@@ -470,7 +525,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
470
525
|
if (sort === void 0) { sort = {}; }
|
|
471
526
|
if (option === void 0) { option = {}; }
|
|
472
527
|
return __awaiter(this, void 0, void 0, function () {
|
|
473
|
-
var entries, channels,
|
|
528
|
+
var entries, channels, e_9;
|
|
474
529
|
var _this = this;
|
|
475
530
|
return __generator(this, function (_a) {
|
|
476
531
|
switch (_a.label) {
|
|
@@ -492,8 +547,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
492
547
|
}
|
|
493
548
|
return [2 /*return*/, entries];
|
|
494
549
|
case 3:
|
|
495
|
-
|
|
496
|
-
throw
|
|
550
|
+
e_9 = _a.sent();
|
|
551
|
+
throw e_9;
|
|
497
552
|
case 4: return [2 /*return*/];
|
|
498
553
|
}
|
|
499
554
|
});
|
|
@@ -501,7 +556,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
501
556
|
};
|
|
502
557
|
NCloudChat.prototype.requestFriend = function (friendId) {
|
|
503
558
|
return __awaiter(this, void 0, void 0, function () {
|
|
504
|
-
var
|
|
559
|
+
var e_10;
|
|
505
560
|
return __generator(this, function (_a) {
|
|
506
561
|
switch (_a.label) {
|
|
507
562
|
case 0:
|
|
@@ -514,8 +569,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
514
569
|
return [4 /*yield*/, requestFriend(friendId)];
|
|
515
570
|
case 2: return [2 /*return*/, _a.sent()];
|
|
516
571
|
case 3:
|
|
517
|
-
|
|
518
|
-
throw
|
|
572
|
+
e_10 = _a.sent();
|
|
573
|
+
throw e_10;
|
|
519
574
|
case 4: return [2 /*return*/];
|
|
520
575
|
}
|
|
521
576
|
});
|
|
@@ -523,7 +578,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
523
578
|
};
|
|
524
579
|
NCloudChat.prototype.acceptFriend = function (friendId) {
|
|
525
580
|
return __awaiter(this, void 0, void 0, function () {
|
|
526
|
-
var
|
|
581
|
+
var e_11;
|
|
527
582
|
return __generator(this, function (_a) {
|
|
528
583
|
switch (_a.label) {
|
|
529
584
|
case 0:
|
|
@@ -536,8 +591,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
536
591
|
return [4 /*yield*/, acceptFriend(friendId)];
|
|
537
592
|
case 2: return [2 /*return*/, _a.sent()];
|
|
538
593
|
case 3:
|
|
539
|
-
|
|
540
|
-
throw
|
|
594
|
+
e_11 = _a.sent();
|
|
595
|
+
throw e_11;
|
|
541
596
|
case 4: return [2 /*return*/];
|
|
542
597
|
}
|
|
543
598
|
});
|
|
@@ -545,7 +600,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
545
600
|
};
|
|
546
601
|
NCloudChat.prototype.rejectFriend = function (friendId) {
|
|
547
602
|
return __awaiter(this, void 0, void 0, function () {
|
|
548
|
-
var
|
|
603
|
+
var e_12;
|
|
549
604
|
return __generator(this, function (_a) {
|
|
550
605
|
switch (_a.label) {
|
|
551
606
|
case 0:
|
|
@@ -558,8 +613,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
558
613
|
return [4 /*yield*/, rejectFriend(friendId)];
|
|
559
614
|
case 2: return [2 /*return*/, _a.sent()];
|
|
560
615
|
case 3:
|
|
561
|
-
|
|
562
|
-
throw
|
|
616
|
+
e_12 = _a.sent();
|
|
617
|
+
throw e_12;
|
|
563
618
|
case 4: return [2 /*return*/];
|
|
564
619
|
}
|
|
565
620
|
});
|
|
@@ -567,7 +622,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
567
622
|
};
|
|
568
623
|
NCloudChat.prototype.removeFriend = function (friendId) {
|
|
569
624
|
return __awaiter(this, void 0, void 0, function () {
|
|
570
|
-
var
|
|
625
|
+
var e_13;
|
|
571
626
|
return __generator(this, function (_a) {
|
|
572
627
|
switch (_a.label) {
|
|
573
628
|
case 0:
|
|
@@ -580,8 +635,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
580
635
|
return [4 /*yield*/, removeFriend(friendId)];
|
|
581
636
|
case 2: return [2 /*return*/, _a.sent()];
|
|
582
637
|
case 3:
|
|
583
|
-
|
|
584
|
-
throw
|
|
638
|
+
e_13 = _a.sent();
|
|
639
|
+
throw e_13;
|
|
585
640
|
case 4: return [2 /*return*/];
|
|
586
641
|
}
|
|
587
642
|
});
|
|
@@ -589,7 +644,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
589
644
|
};
|
|
590
645
|
NCloudChat.prototype.countUnread = function (channelId) {
|
|
591
646
|
return __awaiter(this, void 0, void 0, function () {
|
|
592
|
-
var
|
|
647
|
+
var e_14;
|
|
593
648
|
return __generator(this, function (_a) {
|
|
594
649
|
switch (_a.label) {
|
|
595
650
|
case 0:
|
|
@@ -602,8 +657,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
602
657
|
return [4 /*yield*/, unreadCount(channelId)];
|
|
603
658
|
case 2: return [2 /*return*/, _a.sent()];
|
|
604
659
|
case 3:
|
|
605
|
-
|
|
606
|
-
throw
|
|
660
|
+
e_14 = _a.sent();
|
|
661
|
+
throw e_14;
|
|
607
662
|
case 4: return [2 /*return*/];
|
|
608
663
|
}
|
|
609
664
|
});
|
|
@@ -611,7 +666,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
611
666
|
};
|
|
612
667
|
NCloudChat.prototype.getSubscription = function (channelId, id) {
|
|
613
668
|
return __awaiter(this, void 0, void 0, function () {
|
|
614
|
-
var
|
|
669
|
+
var e_15;
|
|
615
670
|
return __generator(this, function (_a) {
|
|
616
671
|
switch (_a.label) {
|
|
617
672
|
case 0:
|
|
@@ -624,8 +679,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
624
679
|
return [4 /*yield*/, getSubscription(channelId, id)];
|
|
625
680
|
case 2: return [2 /*return*/, _a.sent()];
|
|
626
681
|
case 3:
|
|
627
|
-
|
|
628
|
-
throw
|
|
682
|
+
e_15 = _a.sent();
|
|
683
|
+
throw e_15;
|
|
629
684
|
case 4: return [2 /*return*/, null];
|
|
630
685
|
}
|
|
631
686
|
});
|
|
@@ -633,7 +688,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
633
688
|
};
|
|
634
689
|
NCloudChat.prototype.getChannel = function (channelId) {
|
|
635
690
|
return __awaiter(this, void 0, void 0, function () {
|
|
636
|
-
var
|
|
691
|
+
var e_16;
|
|
637
692
|
return __generator(this, function (_a) {
|
|
638
693
|
switch (_a.label) {
|
|
639
694
|
case 0:
|
|
@@ -646,8 +701,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
646
701
|
return [4 /*yield*/, getChannel(channelId)];
|
|
647
702
|
case 2: return [2 /*return*/, _a.sent()];
|
|
648
703
|
case 3:
|
|
649
|
-
|
|
650
|
-
throw
|
|
704
|
+
e_16 = _a.sent();
|
|
705
|
+
throw e_16;
|
|
651
706
|
case 4: return [2 /*return*/, null];
|
|
652
707
|
}
|
|
653
708
|
});
|
|
@@ -655,7 +710,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
655
710
|
};
|
|
656
711
|
NCloudChat.prototype.getMessage = function (channelId, messageId) {
|
|
657
712
|
return __awaiter(this, void 0, void 0, function () {
|
|
658
|
-
var entry,
|
|
713
|
+
var entry, e_17;
|
|
659
714
|
return __generator(this, function (_a) {
|
|
660
715
|
switch (_a.label) {
|
|
661
716
|
case 0:
|
|
@@ -674,8 +729,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
674
729
|
}
|
|
675
730
|
return [2 /*return*/, null];
|
|
676
731
|
case 3:
|
|
677
|
-
|
|
678
|
-
throw
|
|
732
|
+
e_17 = _a.sent();
|
|
733
|
+
throw e_17;
|
|
679
734
|
case 4: return [2 /*return*/];
|
|
680
735
|
}
|
|
681
736
|
});
|
|
@@ -683,7 +738,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
683
738
|
};
|
|
684
739
|
NCloudChat.prototype.getMessages = function (filter, sort, option) {
|
|
685
740
|
return __awaiter(this, void 0, void 0, function () {
|
|
686
|
-
var entries, messages,
|
|
741
|
+
var entries, messages, e_18;
|
|
687
742
|
var _this = this;
|
|
688
743
|
return __generator(this, function (_a) {
|
|
689
744
|
switch (_a.label) {
|
|
@@ -705,8 +760,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
705
760
|
}
|
|
706
761
|
return [2 /*return*/, entries];
|
|
707
762
|
case 3:
|
|
708
|
-
|
|
709
|
-
throw
|
|
763
|
+
e_18 = _a.sent();
|
|
764
|
+
throw e_18;
|
|
710
765
|
case 4: return [2 /*return*/];
|
|
711
766
|
}
|
|
712
767
|
});
|
|
@@ -714,7 +769,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
714
769
|
};
|
|
715
770
|
NCloudChat.prototype.getSubscriptions = function (filter, sort, option) {
|
|
716
771
|
return __awaiter(this, void 0, void 0, function () {
|
|
717
|
-
var entries, subscribes,
|
|
772
|
+
var entries, subscribes, e_19;
|
|
718
773
|
var _this = this;
|
|
719
774
|
return __generator(this, function (_a) {
|
|
720
775
|
switch (_a.label) {
|
|
@@ -736,8 +791,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
736
791
|
}
|
|
737
792
|
return [2 /*return*/, entries];
|
|
738
793
|
case 3:
|
|
739
|
-
|
|
740
|
-
throw
|
|
794
|
+
e_19 = _a.sent();
|
|
795
|
+
throw e_19;
|
|
741
796
|
case 4: return [2 /*return*/];
|
|
742
797
|
}
|
|
743
798
|
});
|
|
@@ -745,7 +800,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
745
800
|
};
|
|
746
801
|
NCloudChat.prototype.createChannel = function (channel) {
|
|
747
802
|
return __awaiter(this, void 0, void 0, function () {
|
|
748
|
-
var
|
|
803
|
+
var e_20;
|
|
749
804
|
return __generator(this, function (_a) {
|
|
750
805
|
switch (_a.label) {
|
|
751
806
|
case 0:
|
|
@@ -758,8 +813,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
758
813
|
return [4 /*yield*/, createChannel(channel)];
|
|
759
814
|
case 2: return [2 /*return*/, _a.sent()];
|
|
760
815
|
case 3:
|
|
761
|
-
|
|
762
|
-
throw
|
|
816
|
+
e_20 = _a.sent();
|
|
817
|
+
throw e_20;
|
|
763
818
|
case 4: return [2 /*return*/];
|
|
764
819
|
}
|
|
765
820
|
});
|
|
@@ -767,7 +822,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
767
822
|
};
|
|
768
823
|
NCloudChat.prototype.updateChannel = function (channelId, channel) {
|
|
769
824
|
return __awaiter(this, void 0, void 0, function () {
|
|
770
|
-
var
|
|
825
|
+
var e_21;
|
|
771
826
|
return __generator(this, function (_a) {
|
|
772
827
|
switch (_a.label) {
|
|
773
828
|
case 0:
|
|
@@ -780,8 +835,8 @@ var NCloudChat = /** @class */ (function () {
|
|
|
780
835
|
return [4 /*yield*/, updateChannel(channelId, channel)];
|
|
781
836
|
case 2: return [2 /*return*/, _a.sent()];
|
|
782
837
|
case 3:
|
|
783
|
-
|
|
784
|
-
throw
|
|
838
|
+
e_21 = _a.sent();
|
|
839
|
+
throw e_21;
|
|
785
840
|
case 4: return [2 /*return*/];
|
|
786
841
|
}
|
|
787
842
|
});
|
|
@@ -789,7 +844,7 @@ var NCloudChat = /** @class */ (function () {
|
|
|
789
844
|
};
|
|
790
845
|
NCloudChat.prototype.deleteChannel = function (channelId) {
|
|
791
846
|
return __awaiter(this, void 0, void 0, function () {
|
|
792
|
-
var
|
|
847
|
+
var e_22;
|
|
793
848
|
return __generator(this, function (_a) {
|
|
794
849
|
switch (_a.label) {
|
|
795
850
|
case 0:
|
|
@@ -802,16 +857,17 @@ var NCloudChat = /** @class */ (function () {
|
|
|
802
857
|
return [4 /*yield*/, deleteChannel(channelId)];
|
|
803
858
|
case 2: return [2 /*return*/, _a.sent()];
|
|
804
859
|
case 3:
|
|
805
|
-
|
|
806
|
-
throw
|
|
860
|
+
e_22 = _a.sent();
|
|
861
|
+
throw e_22;
|
|
807
862
|
case 4: return [2 /*return*/];
|
|
808
863
|
}
|
|
809
864
|
});
|
|
810
865
|
});
|
|
811
866
|
};
|
|
812
|
-
NCloudChat.prototype.markRead = function (channelId, mark) {
|
|
867
|
+
NCloudChat.prototype.markRead = function (channelId, mark, option) {
|
|
868
|
+
if (option === void 0) { option = null; }
|
|
813
869
|
return __awaiter(this, void 0, void 0, function () {
|
|
814
|
-
var
|
|
870
|
+
var e_23;
|
|
815
871
|
return __generator(this, function (_a) {
|
|
816
872
|
switch (_a.label) {
|
|
817
873
|
case 0:
|
|
@@ -821,16 +877,108 @@ var NCloudChat = /** @class */ (function () {
|
|
|
821
877
|
_a.label = 1;
|
|
822
878
|
case 1:
|
|
823
879
|
_a.trys.push([1, 3, , 4]);
|
|
824
|
-
return [4 /*yield*/, updateSubscription(channelId, mark)];
|
|
880
|
+
return [4 /*yield*/, updateSubscription(channelId, mark, JSON.stringify(option))];
|
|
825
881
|
case 2: return [2 /*return*/, _a.sent()];
|
|
826
882
|
case 3:
|
|
827
|
-
|
|
828
|
-
throw
|
|
883
|
+
e_23 = _a.sent();
|
|
884
|
+
throw e_23;
|
|
885
|
+
case 4: return [2 /*return*/];
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
});
|
|
889
|
+
};
|
|
890
|
+
NCloudChat.prototype.addMembers = function (channelId, memberIds, options) {
|
|
891
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
892
|
+
var input, e_24;
|
|
893
|
+
return __generator(this, function (_a) {
|
|
894
|
+
switch (_a.label) {
|
|
895
|
+
case 0:
|
|
896
|
+
if (!this.isConnected()) {
|
|
897
|
+
throw Error("You are not connected.");
|
|
898
|
+
}
|
|
899
|
+
_a.label = 1;
|
|
900
|
+
case 1:
|
|
901
|
+
_a.trys.push([1, 3, , 4]);
|
|
902
|
+
input = {
|
|
903
|
+
members: memberIds
|
|
904
|
+
};
|
|
905
|
+
return [4 /*yield*/, addChannelMembers(channelId, memberIds, options)];
|
|
906
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
907
|
+
case 3:
|
|
908
|
+
e_24 = _a.sent();
|
|
909
|
+
throw e_24;
|
|
829
910
|
case 4: return [2 /*return*/];
|
|
830
911
|
}
|
|
831
912
|
});
|
|
832
913
|
});
|
|
833
914
|
};
|
|
915
|
+
NCloudChat.prototype.removeMembers = function (channelId, memberIds, options) {
|
|
916
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
917
|
+
var e_25;
|
|
918
|
+
return __generator(this, function (_a) {
|
|
919
|
+
switch (_a.label) {
|
|
920
|
+
case 0:
|
|
921
|
+
if (!this.isConnected()) {
|
|
922
|
+
throw Error("You are not connected.");
|
|
923
|
+
}
|
|
924
|
+
_a.label = 1;
|
|
925
|
+
case 1:
|
|
926
|
+
_a.trys.push([1, 4, , 5]);
|
|
927
|
+
return [4 /*yield*/, removeChannelMembers(channelId, memberIds, options)];
|
|
928
|
+
case 2: return [4 /*yield*/, _a.sent()];
|
|
929
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
930
|
+
case 4:
|
|
931
|
+
e_25 = _a.sent();
|
|
932
|
+
throw e_25;
|
|
933
|
+
case 5: return [2 /*return*/];
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
};
|
|
938
|
+
NCloudChat.prototype.startTyping = function (channelId, threadId) {
|
|
939
|
+
if (threadId === void 0) { threadId = ""; }
|
|
940
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
941
|
+
var data;
|
|
942
|
+
return __generator(this, function (_a) {
|
|
943
|
+
if (!this.isConnected()) {
|
|
944
|
+
throw Error("You are not connected.");
|
|
945
|
+
}
|
|
946
|
+
try {
|
|
947
|
+
data = {
|
|
948
|
+
channelId: channelId,
|
|
949
|
+
threadId: threadId
|
|
950
|
+
};
|
|
951
|
+
return [2 /*return*/, this.socket.emit("start typing", data)];
|
|
952
|
+
}
|
|
953
|
+
catch (e) {
|
|
954
|
+
throw e;
|
|
955
|
+
}
|
|
956
|
+
return [2 /*return*/];
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
};
|
|
960
|
+
NCloudChat.prototype.stopTyping = function (channelId, threadId) {
|
|
961
|
+
if (threadId === void 0) { threadId = ""; }
|
|
962
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
963
|
+
var data;
|
|
964
|
+
return __generator(this, function (_a) {
|
|
965
|
+
if (!this.isConnected()) {
|
|
966
|
+
throw Error("You are not connected.");
|
|
967
|
+
}
|
|
968
|
+
try {
|
|
969
|
+
data = {
|
|
970
|
+
channelId: channelId,
|
|
971
|
+
threadId: threadId
|
|
972
|
+
};
|
|
973
|
+
return [2 /*return*/, this.socket.emit("stop typing", data)];
|
|
974
|
+
}
|
|
975
|
+
catch (e) {
|
|
976
|
+
throw e;
|
|
977
|
+
}
|
|
978
|
+
return [2 /*return*/];
|
|
979
|
+
});
|
|
980
|
+
});
|
|
981
|
+
};
|
|
834
982
|
return NCloudChat;
|
|
835
983
|
}());
|
|
836
984
|
export default NCloudChat;
|