ncloudchat 1.0.21 → 1.0.31
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/LICENSE.md +1 -1
- package/deploy.sh +1 -1
- package/esm/CloudChat.d.ts +434 -9
- package/esm/CloudChat.js +979 -273
- package/esm/CloudChat.js.map +1 -1
- package/esm/CoreManager.d.ts +6 -0
- package/esm/CoreManager.js +13 -4
- package/esm/CoreManager.js.map +1 -1
- package/esm/Dispatcher.d.ts +16 -0
- package/esm/Dispatcher.js +19 -4
- package/esm/Dispatcher.js.map +1 -1
- package/esm/Network.d.ts +7 -0
- package/esm/Network.js +93 -0
- package/esm/Network.js.map +1 -0
- package/esm/Type.d.ts +43 -0
- package/esm/Type.js +16 -0
- package/esm/Type.js.map +1 -1
- package/esm/Util.d.ts +13 -0
- package/esm/Util.js +13 -0
- package/esm/Util.js.map +1 -1
- package/esm/graphql/channel.d.ts +13 -0
- package/esm/graphql/channel.js +16 -0
- package/esm/graphql/channel.js.map +1 -0
- package/esm/graphql/friend.d.ts +11 -0
- package/esm/graphql/friend.js +13 -0
- package/esm/graphql/friend.js.map +1 -0
- package/esm/graphql/invite.d.ts +7 -0
- package/esm/graphql/invite.js +8 -0
- package/esm/graphql/invite.js.map +1 -0
- package/esm/graphql/member.d.ts +11 -0
- package/esm/graphql/member.js +13 -0
- package/esm/graphql/member.js.map +1 -0
- package/esm/graphql/message.d.ts +11 -0
- package/esm/graphql/message.js +13 -0
- package/esm/graphql/message.js.map +1 -0
- package/esm/graphql/pin.d.ts +10 -0
- package/esm/graphql/pin.js +12 -0
- package/esm/graphql/pin.js.map +1 -0
- package/esm/graphql/project.d.ts +7 -0
- package/esm/graphql/project.js +8 -0
- package/esm/graphql/project.js.map +1 -0
- package/esm/graphql/subscription.d.ts +11 -0
- package/esm/graphql/subscription.js +13 -0
- package/esm/graphql/subscription.js.map +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +6 -0
- package/esm/index.js.map +1 -1
- package/esm/logger.d.ts +9 -3
- package/esm/logger.js +6 -0
- package/esm/logger.js.map +1 -1
- package/esm/mutations/channel.d.ts +50 -0
- package/esm/mutations/channel.js +97 -176
- package/esm/mutations/channel.js.map +1 -1
- package/esm/mutations/friend.d.ts +38 -0
- package/esm/mutations/friend.js +57 -119
- package/esm/mutations/friend.js.map +1 -1
- package/esm/mutations/index.d.ts +5 -3
- package/esm/mutations/index.js +5 -3
- package/esm/mutations/index.js.map +1 -1
- package/esm/mutations/invite.d.ts +15 -0
- package/esm/mutations/invite.js +23 -32
- package/esm/mutations/invite.js.map +1 -1
- package/esm/mutations/member.d.ts +39 -2
- package/esm/mutations/member.js +64 -111
- package/esm/mutations/member.js.map +1 -1
- package/esm/mutations/message.d.ts +35 -0
- package/esm/mutations/message.js +66 -45
- package/esm/mutations/message.js.map +1 -1
- package/esm/mutations/pin.d.ts +28 -0
- package/esm/mutations/pin.js +88 -0
- package/esm/mutations/pin.js.map +1 -0
- package/esm/mutations/subscription.d.ts +33 -1
- package/esm/mutations/subscription.js +51 -93
- package/esm/mutations/subscription.js.map +1 -1
- package/esm/queries/channel.d.ts +24 -0
- package/esm/queries/channel.js +37 -79
- package/esm/queries/channel.js.map +1 -1
- package/esm/queries/friend.d.ts +16 -0
- package/esm/queries/friend.js +25 -40
- package/esm/queries/friend.js.map +1 -1
- package/esm/queries/index.d.ts +8 -0
- package/esm/queries/index.js +8 -0
- package/esm/queries/index.js.map +1 -1
- package/esm/queries/member.d.ts +16 -0
- package/esm/queries/member.js +25 -40
- package/esm/queries/member.js.map +1 -1
- package/esm/queries/memberblocks.d.ts +17 -0
- package/esm/queries/memberblocks.js +69 -0
- package/esm/queries/memberblocks.js.map +1 -0
- package/esm/queries/message.d.ts +33 -0
- package/esm/queries/message.js +50 -111
- package/esm/queries/message.js.map +1 -1
- package/esm/queries/pin.d.ts +28 -0
- package/esm/queries/pin.js +92 -0
- package/esm/queries/pin.js.map +1 -0
- package/esm/queries/project.d.ts +13 -0
- package/esm/queries/project.js +20 -32
- package/esm/queries/project.js.map +1 -1
- package/esm/queries/subscription.d.ts +25 -0
- package/esm/queries/subscription.js +39 -76
- package/esm/queries/subscription.js.map +1 -1
- package/lib/CloudChat.js +1230 -321
- package/lib/CoreManager.js +13 -3
- package/lib/Dispatcher.js +25 -9
- package/lib/Network.js +226 -0
- package/lib/Type.js +19 -0
- package/lib/Util.js +15 -1
- package/lib/graphql/channel.js +32 -0
- package/lib/graphql/friend.js +27 -0
- package/lib/graphql/invite.js +18 -0
- package/lib/graphql/member.js +27 -0
- package/lib/graphql/message.js +27 -0
- package/lib/graphql/pin.js +25 -0
- package/lib/graphql/project.js +18 -0
- package/lib/graphql/subscription.js +27 -0
- package/lib/index.js +2 -2
- package/lib/logger.js +6 -0
- package/lib/mutations/channel.js +106 -172
- package/lib/mutations/friend.js +62 -115
- package/lib/mutations/index.js +23 -3
- package/lib/mutations/invite.js +27 -33
- package/lib/mutations/member.js +73 -100
- package/lib/mutations/message.js +86 -48
- package/lib/mutations/pin.js +229 -0
- package/lib/mutations/subscription.js +56 -95
- package/lib/queries/channel.js +40 -84
- package/lib/queries/friend.js +29 -45
- package/lib/queries/index.js +37 -3
- package/lib/queries/member.js +29 -45
- package/lib/queries/memberblocks.js +207 -0
- package/lib/queries/message.js +56 -109
- package/lib/queries/pin.js +243 -0
- package/lib/queries/project.js +24 -41
- package/lib/queries/subscription.js +42 -78
- package/package.json +19 -45
- package/tsconfig.json +1 -0
- package//353/260/260/355/217/254/354/210/234/354/204/234.md +8 -0
- package/package copy.json +0 -74
package/lib/CloudChat.js
CHANGED
|
@@ -1,32 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
6
4
|
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
7
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
exports["default"] = void 0;
|
|
12
12
|
|
|
13
|
-
require("core-js/modules/es6.
|
|
13
|
+
require("core-js/modules/es6.regexp.replace.js");
|
|
14
14
|
|
|
15
|
-
require("core-js/modules/es6.
|
|
15
|
+
require("core-js/modules/es6.array.slice.js");
|
|
16
16
|
|
|
17
|
-
require("core-js/modules/es6.function.
|
|
17
|
+
require("core-js/modules/es6.function.name.js");
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
require("core-js/modules/es6.function.bind.js");
|
|
20
20
|
|
|
21
|
-
require("core-js/modules/es6.
|
|
21
|
+
require("core-js/modules/es6.regexp.split.js");
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
require("core-js/modules/es6.array.map.js");
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
26
26
|
|
|
27
27
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol"));
|
|
30
|
+
|
|
31
|
+
var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
|
|
32
|
+
|
|
33
|
+
var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
|
|
34
|
+
|
|
35
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
30
36
|
|
|
31
37
|
var _socket = require("socket.io-client");
|
|
32
38
|
|
|
@@ -40,6 +46,12 @@ var _queries = require("./queries");
|
|
|
40
46
|
|
|
41
47
|
var _mutations = require("./mutations");
|
|
42
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
51
|
+
*
|
|
52
|
+
* This source code is licensed under the MIT license found in the
|
|
53
|
+
* LICENSE file in the root directory of this source tree.
|
|
54
|
+
*/
|
|
43
55
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
44
56
|
__assign = _assign["default"] || function (t) {
|
|
45
57
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -199,26 +211,86 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
199
211
|
}
|
|
200
212
|
};
|
|
201
213
|
|
|
214
|
+
var __values = void 0 && (void 0).__values || function (o) {
|
|
215
|
+
var s = typeof _symbol["default"] === "function" && _iterator["default"],
|
|
216
|
+
m = s && o[s],
|
|
217
|
+
i = 0;
|
|
218
|
+
if (m) return m.call(o);
|
|
219
|
+
if (o && typeof o.length === "number") return {
|
|
220
|
+
next: function next() {
|
|
221
|
+
if (o && i >= o.length) o = void 0;
|
|
222
|
+
return {
|
|
223
|
+
value: o && o[i++],
|
|
224
|
+
done: !o
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
var __read = void 0 && (void 0).__read || function (o, n) {
|
|
232
|
+
var m = typeof _symbol["default"] === "function" && o[_iterator["default"]];
|
|
233
|
+
if (!m) return o;
|
|
234
|
+
var i = m.call(o),
|
|
235
|
+
r,
|
|
236
|
+
ar = [],
|
|
237
|
+
e;
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
241
|
+
ar.push(r.value);
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
e = {
|
|
245
|
+
error: error
|
|
246
|
+
};
|
|
247
|
+
} finally {
|
|
248
|
+
try {
|
|
249
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
250
|
+
} finally {
|
|
251
|
+
if (e) throw e.error;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return ar;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Class NCloudChat holds all the NCloudChat functionalities.
|
|
260
|
+
*
|
|
261
|
+
* @class
|
|
262
|
+
*/
|
|
202
263
|
var NCloudChat =
|
|
203
264
|
/** @class */
|
|
204
265
|
function () {
|
|
205
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Create a `NCloudChat` instance and a Dispatcher.
|
|
268
|
+
*
|
|
269
|
+
* @constructs
|
|
270
|
+
*/
|
|
271
|
+
function NCloudChat(debug) {
|
|
272
|
+
if (debug === void 0) {
|
|
273
|
+
debug = false;
|
|
274
|
+
}
|
|
275
|
+
|
|
206
276
|
this.socket = null;
|
|
207
277
|
this.connected = false;
|
|
208
278
|
this.connectedCount = 0;
|
|
209
279
|
this.dp = new _Dispatcher["default"]();
|
|
280
|
+
if (!debug) console.log = function () {};
|
|
210
281
|
}
|
|
211
282
|
|
|
212
283
|
NCloudChat.prototype.clear = function () {};
|
|
284
|
+
/**
|
|
285
|
+
* Initialize a new `NCloudChat` instance of project and user.
|
|
286
|
+
*
|
|
287
|
+
* @function initialize
|
|
288
|
+
* @param {string} projectId - The id of a project.
|
|
289
|
+
*/
|
|
213
290
|
|
|
214
|
-
NCloudChat.prototype.initialize = function (projectId) {
|
|
215
|
-
_CoreManager["default"].set("PROJECT_ID", projectId);
|
|
216
291
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
name: "",
|
|
220
|
-
image: ""
|
|
221
|
-
});
|
|
292
|
+
NCloudChat.prototype.initialize = function (projectId) {
|
|
293
|
+
this.setProjectId(projectId);
|
|
222
294
|
};
|
|
223
295
|
|
|
224
296
|
NCloudChat.prototype.getLang = function () {
|
|
@@ -229,13 +301,17 @@ function () {
|
|
|
229
301
|
return _CoreManager["default"].get("USER");
|
|
230
302
|
};
|
|
231
303
|
|
|
304
|
+
NCloudChat.prototype.getProjectId = function () {
|
|
305
|
+
return _CoreManager["default"].get("PROJECT_ID");
|
|
306
|
+
};
|
|
307
|
+
|
|
232
308
|
NCloudChat.prototype.setServerUrl = function (url) {
|
|
233
309
|
if (!/^[hHtTpP]{4}(s)?(:\/\/)[a-zA-Z0-9\.\/-:]+/.test(url)) {
|
|
234
310
|
throw Error("invalied url : (ex)http://domain.com, https://domain.com");
|
|
235
311
|
return;
|
|
236
312
|
}
|
|
237
313
|
|
|
238
|
-
if (url.length > 1 && url.substring(url.length - 1) ===
|
|
314
|
+
if (url.length > 1 && url.substring(url.length - 1) === "/") {
|
|
239
315
|
url = url.substring(0, url.length - 1);
|
|
240
316
|
}
|
|
241
317
|
|
|
@@ -258,13 +334,52 @@ function () {
|
|
|
258
334
|
_CoreManager["default"].set("USER", user);
|
|
259
335
|
};
|
|
260
336
|
|
|
337
|
+
NCloudChat.prototype.inputValidation = function (inputs) {
|
|
338
|
+
var e_1, _a;
|
|
339
|
+
|
|
340
|
+
if (!this.isConnected()) throw Error("You are not connected.");
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
for (var _b = __values((0, _entries["default"])(inputs)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
344
|
+
var _d = __read(_c.value, 2),
|
|
345
|
+
key = _d[0],
|
|
346
|
+
value = _d[1];
|
|
347
|
+
|
|
348
|
+
if (!value) {
|
|
349
|
+
var result = key.replace(/([A-Z])/g, " $1");
|
|
350
|
+
var word = result.charAt(0).toUpperCase() + result.slice(1);
|
|
351
|
+
throw Error("You need a(n) ".concat(word, "."));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
} catch (e_1_1) {
|
|
355
|
+
e_1 = {
|
|
356
|
+
error: e_1_1
|
|
357
|
+
};
|
|
358
|
+
} finally {
|
|
359
|
+
try {
|
|
360
|
+
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
|
|
361
|
+
} finally {
|
|
362
|
+
if (e_1) throw e_1.error;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Create a connection between a socket and a client.
|
|
368
|
+
*
|
|
369
|
+
* @async connect
|
|
370
|
+
* @param {any} user
|
|
371
|
+
* @param {string} userToken
|
|
372
|
+
* @returns
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
|
|
261
376
|
NCloudChat.prototype.connect = function (user, userToken) {
|
|
262
377
|
if (userToken === void 0) {
|
|
263
378
|
userToken = "";
|
|
264
379
|
}
|
|
265
380
|
|
|
266
381
|
return __awaiter(this, void 0, void 0, function () {
|
|
267
|
-
var url,
|
|
382
|
+
var url, image, name, lang, customField, response, e_2, options;
|
|
268
383
|
|
|
269
384
|
var _this = this;
|
|
270
385
|
|
|
@@ -284,22 +399,13 @@ function () {
|
|
|
284
399
|
_a.label = 2;
|
|
285
400
|
|
|
286
401
|
case 2:
|
|
287
|
-
url = _CoreManager["default"].get("SOCKET_URL") +
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (!project_id) {
|
|
291
|
-
throw Error("Project ID not found");
|
|
292
|
-
} // const user = CoreManager.get("USER");
|
|
293
|
-
// if (!user.id && user.id) user_id = user.id;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (!user.id) {
|
|
297
|
-
throw Error("UserID not found");
|
|
298
|
-
}
|
|
299
|
-
|
|
402
|
+
url = _CoreManager["default"].get("SOCKET_URL") + "/cloudchat";
|
|
403
|
+
if (!this.getProjectId()) throw Error("Project ID not found");
|
|
404
|
+
if (!user.id) throw Error("UserID not found");
|
|
300
405
|
image = user.profile;
|
|
301
406
|
name = user.name;
|
|
302
407
|
lang = this.getLang();
|
|
408
|
+
customField = user.customField;
|
|
303
409
|
_a.label = 3;
|
|
304
410
|
|
|
305
411
|
case 3:
|
|
@@ -307,23 +413,27 @@ function () {
|
|
|
307
413
|
|
|
308
414
|
return [4
|
|
309
415
|
/*yield*/
|
|
310
|
-
, (0, _mutations.login)(user.id, name, image, userToken)];
|
|
416
|
+
, (0, _mutations.login)(user.id, name, image, userToken, customField)];
|
|
311
417
|
|
|
312
418
|
case 4:
|
|
313
|
-
|
|
419
|
+
response = _a.sent();
|
|
420
|
+
this.setUser({
|
|
421
|
+
id: user.id,
|
|
422
|
+
name: name,
|
|
423
|
+
image: image,
|
|
424
|
+
customField: customField
|
|
425
|
+
});
|
|
426
|
+
userToken = response["token"]; // parse token object
|
|
427
|
+
|
|
314
428
|
return [3
|
|
315
429
|
/*break*/
|
|
316
430
|
, 6];
|
|
317
431
|
|
|
318
432
|
case 5:
|
|
319
|
-
|
|
320
|
-
throw
|
|
433
|
+
e_2 = _a.sent();
|
|
434
|
+
throw e_2;
|
|
321
435
|
|
|
322
436
|
case 6:
|
|
323
|
-
if (!userToken) {
|
|
324
|
-
throw Error("Token is not found");
|
|
325
|
-
}
|
|
326
|
-
|
|
327
437
|
_CoreManager["default"].set("TOKEN", userToken);
|
|
328
438
|
|
|
329
439
|
options = {
|
|
@@ -334,11 +444,12 @@ function () {
|
|
|
334
444
|
reconnectionDelayMax: 2000 * 100,
|
|
335
445
|
randomizationFactor: 0.5,
|
|
336
446
|
query: {
|
|
337
|
-
project_id:
|
|
447
|
+
project_id: this.getProjectId(),
|
|
338
448
|
user_id: user.id,
|
|
339
449
|
lang: lang,
|
|
340
450
|
image: image,
|
|
341
451
|
name: name,
|
|
452
|
+
customField: customField,
|
|
342
453
|
token: userToken
|
|
343
454
|
}
|
|
344
455
|
};
|
|
@@ -346,14 +457,14 @@ function () {
|
|
|
346
457
|
this.socket.on("connect", function (data) {
|
|
347
458
|
_this.connectedCount++;
|
|
348
459
|
_this.connected = true;
|
|
349
|
-
(0, _logger.info)("Connected to "
|
|
460
|
+
(0, _logger.info)("Connected to ".concat(url, " with id: ").concat(_this.socket.id));
|
|
350
461
|
|
|
351
462
|
_this.dp.dispatch("onConnected", data);
|
|
352
463
|
});
|
|
353
464
|
this.socket.on("unauthorized", function (data) {});
|
|
354
465
|
this.socket.on("disconnect", function (reason) {
|
|
355
466
|
_this.connected = false;
|
|
356
|
-
(0, _logger.info)("Disconnected to "
|
|
467
|
+
(0, _logger.info)("Disconnected to ".concat(url, " with id: ").concat(_this.socket.id));
|
|
357
468
|
|
|
358
469
|
_this.dp.dispatch("onDisconnected", reason);
|
|
359
470
|
});
|
|
@@ -377,15 +488,15 @@ function () {
|
|
|
377
488
|
|
|
378
489
|
_this.dp.dispatch("onStopTyping", data);
|
|
379
490
|
});
|
|
380
|
-
this.socket.on("member
|
|
491
|
+
this.socket.on("member joined", function (payload) {
|
|
381
492
|
var data = JSON.parse(payload);
|
|
382
493
|
|
|
383
|
-
_this.dp.dispatch("
|
|
494
|
+
_this.dp.dispatch("onMemberJoined", data);
|
|
384
495
|
});
|
|
385
|
-
this.socket.on("member
|
|
496
|
+
this.socket.on("member leaved", function (payload) {
|
|
386
497
|
var data = JSON.parse(payload);
|
|
387
498
|
|
|
388
|
-
_this.dp.dispatch("
|
|
499
|
+
_this.dp.dispatch("onMemberLeaved", data);
|
|
389
500
|
});
|
|
390
501
|
this.socket.on("member updated", function (payload) {
|
|
391
502
|
var data = JSON.parse(payload);
|
|
@@ -434,17 +545,25 @@ function () {
|
|
|
434
545
|
});
|
|
435
546
|
});
|
|
436
547
|
};
|
|
548
|
+
/**
|
|
549
|
+
* Mute channel notifications.
|
|
550
|
+
*
|
|
551
|
+
* @async
|
|
552
|
+
* @function mute
|
|
553
|
+
* @param {string} channel
|
|
554
|
+
* @returns {Promise<any>}
|
|
555
|
+
*/
|
|
556
|
+
|
|
437
557
|
|
|
438
558
|
NCloudChat.prototype.mute = function (channel) {
|
|
439
559
|
return __awaiter(this, void 0, void 0, function () {
|
|
440
|
-
var subscription,
|
|
560
|
+
var subscription, e_3;
|
|
441
561
|
return __generator(this, function (_a) {
|
|
442
562
|
switch (_a.label) {
|
|
443
563
|
case 0:
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
|
|
564
|
+
this.inputValidation({
|
|
565
|
+
channelId: channel
|
|
566
|
+
});
|
|
448
567
|
_a.label = 1;
|
|
449
568
|
|
|
450
569
|
case 1:
|
|
@@ -458,34 +577,42 @@ function () {
|
|
|
458
577
|
|
|
459
578
|
case 2:
|
|
460
579
|
subscription = _a.sent();
|
|
461
|
-
if (subscription) subscription
|
|
580
|
+
if (subscription["subscription"]) subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
462
581
|
return [2
|
|
463
582
|
/*return*/
|
|
464
|
-
, subscription];
|
|
583
|
+
, subscription["subscription"]];
|
|
465
584
|
|
|
466
585
|
case 3:
|
|
467
|
-
|
|
468
|
-
throw
|
|
586
|
+
e_3 = _a.sent();
|
|
587
|
+
throw e_3;
|
|
469
588
|
|
|
470
589
|
case 4:
|
|
471
590
|
return [2
|
|
472
591
|
/*return*/
|
|
473
|
-
|
|
592
|
+
];
|
|
474
593
|
}
|
|
475
594
|
});
|
|
476
595
|
});
|
|
477
596
|
};
|
|
597
|
+
/**
|
|
598
|
+
* Unmute channel notifications.
|
|
599
|
+
*
|
|
600
|
+
* @async
|
|
601
|
+
* @function unmute
|
|
602
|
+
* @param {string} channel
|
|
603
|
+
* @returns {Promise<any>}
|
|
604
|
+
*/
|
|
605
|
+
|
|
478
606
|
|
|
479
607
|
NCloudChat.prototype.unmute = function (channel) {
|
|
480
608
|
return __awaiter(this, void 0, void 0, function () {
|
|
481
|
-
var subscription,
|
|
609
|
+
var subscription, e_4;
|
|
482
610
|
return __generator(this, function (_a) {
|
|
483
611
|
switch (_a.label) {
|
|
484
612
|
case 0:
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
|
|
613
|
+
this.inputValidation({
|
|
614
|
+
channelId: channel
|
|
615
|
+
});
|
|
489
616
|
_a.label = 1;
|
|
490
617
|
|
|
491
618
|
case 1:
|
|
@@ -499,23 +626,33 @@ function () {
|
|
|
499
626
|
|
|
500
627
|
case 2:
|
|
501
628
|
subscription = _a.sent();
|
|
502
|
-
if (subscription) subscription
|
|
629
|
+
if (subscription["subscription"]) subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
503
630
|
return [2
|
|
504
631
|
/*return*/
|
|
505
|
-
, subscription];
|
|
632
|
+
, subscription["subscription"]];
|
|
506
633
|
|
|
507
634
|
case 3:
|
|
508
|
-
|
|
509
|
-
throw
|
|
635
|
+
e_4 = _a.sent();
|
|
636
|
+
throw e_4;
|
|
510
637
|
|
|
511
638
|
case 4:
|
|
512
639
|
return [2
|
|
513
640
|
/*return*/
|
|
514
|
-
|
|
641
|
+
];
|
|
515
642
|
}
|
|
516
643
|
});
|
|
517
644
|
});
|
|
518
645
|
};
|
|
646
|
+
/**
|
|
647
|
+
* Subscribe a channel.
|
|
648
|
+
*
|
|
649
|
+
* @async
|
|
650
|
+
* @function subscibe
|
|
651
|
+
* @param {string} channel - The id of a channel.
|
|
652
|
+
* @param {any} option
|
|
653
|
+
* @returns
|
|
654
|
+
*/
|
|
655
|
+
|
|
519
656
|
|
|
520
657
|
NCloudChat.prototype.subscribe = function (channel, option) {
|
|
521
658
|
if (option === void 0) {
|
|
@@ -523,14 +660,13 @@ function () {
|
|
|
523
660
|
}
|
|
524
661
|
|
|
525
662
|
return __awaiter(this, void 0, void 0, function () {
|
|
526
|
-
var subscription,
|
|
663
|
+
var subscription, e_5;
|
|
527
664
|
return __generator(this, function (_a) {
|
|
528
665
|
switch (_a.label) {
|
|
529
666
|
case 0:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
|
|
667
|
+
this.inputValidation({
|
|
668
|
+
channelId: channel
|
|
669
|
+
});
|
|
534
670
|
_a.label = 1;
|
|
535
671
|
|
|
536
672
|
case 1:
|
|
@@ -542,34 +678,42 @@ function () {
|
|
|
542
678
|
|
|
543
679
|
case 2:
|
|
544
680
|
subscription = _a.sent();
|
|
545
|
-
if (subscription) subscription
|
|
681
|
+
if (subscription["subscription"]) subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
546
682
|
return [2
|
|
547
683
|
/*return*/
|
|
548
|
-
, subscription];
|
|
684
|
+
, subscription["subscription"]];
|
|
549
685
|
|
|
550
686
|
case 3:
|
|
551
|
-
|
|
552
|
-
throw
|
|
687
|
+
e_5 = _a.sent();
|
|
688
|
+
throw e_5;
|
|
553
689
|
|
|
554
690
|
case 4:
|
|
555
691
|
return [2
|
|
556
692
|
/*return*/
|
|
557
|
-
|
|
693
|
+
];
|
|
558
694
|
}
|
|
559
695
|
});
|
|
560
696
|
});
|
|
561
697
|
};
|
|
698
|
+
/**
|
|
699
|
+
* Unsubscribe from a channel.
|
|
700
|
+
*
|
|
701
|
+
* @async
|
|
702
|
+
* @function unsubscribe
|
|
703
|
+
* @param {string} channel - The id of a chennel
|
|
704
|
+
* @returns {Promise<any>}
|
|
705
|
+
*/
|
|
706
|
+
|
|
562
707
|
|
|
563
708
|
NCloudChat.prototype.unsubscribe = function (channel) {
|
|
564
709
|
return __awaiter(this, void 0, void 0, function () {
|
|
565
|
-
var subscription,
|
|
710
|
+
var subscription, e_6;
|
|
566
711
|
return __generator(this, function (_a) {
|
|
567
712
|
switch (_a.label) {
|
|
568
713
|
case 0:
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
|
|
714
|
+
this.inputValidation({
|
|
715
|
+
channelId: channel
|
|
716
|
+
});
|
|
573
717
|
_a.label = 1;
|
|
574
718
|
|
|
575
719
|
case 1:
|
|
@@ -581,39 +725,52 @@ function () {
|
|
|
581
725
|
|
|
582
726
|
case 2:
|
|
583
727
|
subscription = _a.sent();
|
|
728
|
+
if (subscription["subscription"]) subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
584
729
|
return [2
|
|
585
730
|
/*return*/
|
|
586
|
-
, subscription];
|
|
731
|
+
, subscription["subscription"]];
|
|
587
732
|
|
|
588
733
|
case 3:
|
|
589
|
-
|
|
590
|
-
throw
|
|
734
|
+
e_6 = _a.sent();
|
|
735
|
+
throw e_6;
|
|
591
736
|
|
|
592
737
|
case 4:
|
|
593
738
|
return [2
|
|
594
739
|
/*return*/
|
|
595
|
-
|
|
740
|
+
];
|
|
596
741
|
}
|
|
597
742
|
});
|
|
598
743
|
});
|
|
599
744
|
};
|
|
745
|
+
/**
|
|
746
|
+
* Translate a message from a souce language to a target language.
|
|
747
|
+
*
|
|
748
|
+
* @async
|
|
749
|
+
* @function translateMessage
|
|
750
|
+
* @param {string} channelId - The id of a channel.
|
|
751
|
+
* @param {string} source - A source language.
|
|
752
|
+
* @param {string} target - A target language.
|
|
753
|
+
* @param {string} message - An message to be translated.
|
|
754
|
+
* @returns {Promise<any>}
|
|
755
|
+
*/
|
|
756
|
+
|
|
600
757
|
|
|
601
758
|
NCloudChat.prototype.translateMessage = function (channelId, source, target, message) {
|
|
602
759
|
return __awaiter(this, void 0, void 0, function () {
|
|
603
|
-
var
|
|
760
|
+
var result, e_7;
|
|
604
761
|
return __generator(this, function (_a) {
|
|
605
762
|
switch (_a.label) {
|
|
606
763
|
case 0:
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
764
|
+
this.inputValidation({
|
|
765
|
+
channelId: channelId,
|
|
766
|
+
sourceLanguage: source,
|
|
767
|
+
targetLanguage: target
|
|
768
|
+
});
|
|
611
769
|
_a.label = 1;
|
|
612
770
|
|
|
613
771
|
case 1:
|
|
614
772
|
_a.trys.push([1, 3,, 4]);
|
|
615
773
|
|
|
616
|
-
user = _CoreManager["default"].get("USER");
|
|
617
774
|
return [4
|
|
618
775
|
/*yield*/
|
|
619
776
|
, (0, _mutations.translate)(channelId, source, target, message)];
|
|
@@ -622,55 +779,114 @@ function () {
|
|
|
622
779
|
result = _a.sent();
|
|
623
780
|
return [2
|
|
624
781
|
/*return*/
|
|
625
|
-
, result];
|
|
782
|
+
, result["translation"]];
|
|
626
783
|
|
|
627
784
|
case 3:
|
|
628
|
-
|
|
629
|
-
|
|
785
|
+
e_7 = _a.sent();
|
|
786
|
+
|
|
787
|
+
if (e_7 instanceof Error) {
|
|
788
|
+
throw Error(e_7.message);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
return [3
|
|
792
|
+
/*break*/
|
|
793
|
+
, 4];
|
|
630
794
|
|
|
631
795
|
case 4:
|
|
632
796
|
return [2
|
|
633
797
|
/*return*/
|
|
634
|
-
|
|
798
|
+
];
|
|
635
799
|
}
|
|
636
800
|
});
|
|
637
801
|
});
|
|
638
802
|
};
|
|
803
|
+
/**
|
|
804
|
+
* Send a message to a channel.
|
|
805
|
+
*
|
|
806
|
+
* @async
|
|
807
|
+
* @function sendMessage
|
|
808
|
+
* @param {string} channel - The id of a channel.
|
|
809
|
+
* @param {any} opt
|
|
810
|
+
* @returns {Promise<any>}
|
|
811
|
+
*/
|
|
812
|
+
|
|
639
813
|
|
|
640
814
|
NCloudChat.prototype.sendMessage = function (channel, opt) {
|
|
641
815
|
return __awaiter(this, void 0, void 0, function () {
|
|
642
|
-
var
|
|
816
|
+
var data, result, e_8;
|
|
643
817
|
return __generator(this, function (_a) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
818
|
+
switch (_a.label) {
|
|
819
|
+
case 0:
|
|
820
|
+
this.inputValidation({
|
|
821
|
+
channelId: channel,
|
|
822
|
+
message: opt.message
|
|
823
|
+
});
|
|
824
|
+
if (!opt.type) opt.type = "text";
|
|
825
|
+
_a.label = 1;
|
|
647
826
|
|
|
827
|
+
case 1:
|
|
828
|
+
_a.trys.push([1, 3,, 4]);
|
|
648
829
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
830
|
+
data = __assign({
|
|
831
|
+
channelId: channel
|
|
832
|
+
}, opt);
|
|
833
|
+
return [4
|
|
834
|
+
/*yield*/
|
|
835
|
+
, (0, _mutations.message)(data)];
|
|
652
836
|
|
|
653
|
-
|
|
837
|
+
case 2:
|
|
838
|
+
result = _a.sent();
|
|
839
|
+
return [2
|
|
840
|
+
/*return*/
|
|
841
|
+
, result["message"]];
|
|
654
842
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
843
|
+
case 3:
|
|
844
|
+
e_8 = _a.sent();
|
|
845
|
+
throw e_8;
|
|
658
846
|
|
|
847
|
+
case 4:
|
|
848
|
+
return [2
|
|
849
|
+
/*return*/
|
|
850
|
+
];
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
};
|
|
855
|
+
/**
|
|
856
|
+
* Send an express message to a channel.
|
|
857
|
+
*
|
|
858
|
+
* @async
|
|
859
|
+
* @function sendExpressMessage
|
|
860
|
+
* @param {string} channel - The id of a channel.
|
|
861
|
+
* @param {any} opt
|
|
862
|
+
* @returns {Promise<any>}
|
|
863
|
+
*/
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
NCloudChat.prototype.sendExpressMessage = function (channel, opt) {
|
|
867
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
868
|
+
var user, data;
|
|
869
|
+
return __generator(this, function (_a) {
|
|
870
|
+
if (!this.isConnected()) throw Error("You are not connected.");
|
|
871
|
+
this.inputValidation({
|
|
872
|
+
channelId: channel,
|
|
873
|
+
message: opt.message
|
|
874
|
+
});
|
|
875
|
+
if (!opt.type) opt.type = "text";
|
|
659
876
|
user = _CoreManager["default"].get("USER");
|
|
877
|
+
if (!user) throw Error('user is null');
|
|
660
878
|
|
|
661
879
|
try {
|
|
662
880
|
data = __assign({
|
|
663
881
|
channelId: channel,
|
|
664
882
|
user: user
|
|
665
883
|
}, opt);
|
|
666
|
-
this.socket.emit("message", data);
|
|
884
|
+
this.socket.emit("express message", data);
|
|
667
885
|
return [2
|
|
668
886
|
/*return*/
|
|
669
887
|
, data];
|
|
670
888
|
} catch (e) {
|
|
671
|
-
|
|
672
|
-
/*return*/
|
|
673
|
-
, false];
|
|
889
|
+
throw e;
|
|
674
890
|
}
|
|
675
891
|
|
|
676
892
|
return [2
|
|
@@ -679,18 +895,26 @@ function () {
|
|
|
679
895
|
});
|
|
680
896
|
});
|
|
681
897
|
};
|
|
898
|
+
/**
|
|
899
|
+
* Send an image to a channel. Only supports png, jpg, jpeg file types.
|
|
900
|
+
*
|
|
901
|
+
* @async
|
|
902
|
+
* @function sendImage
|
|
903
|
+
* @param {string} channelId - The id of a channel.
|
|
904
|
+
* @param {any} file - An image file.
|
|
905
|
+
* @returns {Promise<any>}
|
|
906
|
+
*/
|
|
907
|
+
|
|
682
908
|
|
|
683
909
|
NCloudChat.prototype.sendImage = function (channelId, file) {
|
|
684
910
|
return __awaiter(this, void 0, void 0, function () {
|
|
685
|
-
var
|
|
911
|
+
var result;
|
|
686
912
|
return __generator(this, function (_a) {
|
|
687
913
|
switch (_a.label) {
|
|
688
914
|
case 0:
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
user = _CoreManager["default"].get("USER");
|
|
915
|
+
this.inputValidation({
|
|
916
|
+
channelId: channelId
|
|
917
|
+
});
|
|
694
918
|
return [4
|
|
695
919
|
/*yield*/
|
|
696
920
|
, (0, _mutations.upload)(channelId, file)];
|
|
@@ -705,6 +929,17 @@ function () {
|
|
|
705
929
|
});
|
|
706
930
|
});
|
|
707
931
|
};
|
|
932
|
+
/**
|
|
933
|
+
* Update a message.
|
|
934
|
+
*
|
|
935
|
+
* @todo
|
|
936
|
+
* @async
|
|
937
|
+
* @function updateMessage
|
|
938
|
+
* @param {string} channel
|
|
939
|
+
* @param {string} message_id
|
|
940
|
+
* @param {string} message
|
|
941
|
+
*/
|
|
942
|
+
|
|
708
943
|
|
|
709
944
|
NCloudChat.prototype.updateMessage = function (channel, message_id, message) {
|
|
710
945
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -715,6 +950,14 @@ function () {
|
|
|
715
950
|
});
|
|
716
951
|
});
|
|
717
952
|
};
|
|
953
|
+
/**
|
|
954
|
+
* Delete a message.
|
|
955
|
+
* @async
|
|
956
|
+
* @function deleteMessage
|
|
957
|
+
* @param {string} channel
|
|
958
|
+
* @param {string} message_id
|
|
959
|
+
*/
|
|
960
|
+
|
|
718
961
|
|
|
719
962
|
NCloudChat.prototype.deleteMessage = function (channel, message_id) {
|
|
720
963
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -725,6 +968,14 @@ function () {
|
|
|
725
968
|
});
|
|
726
969
|
});
|
|
727
970
|
};
|
|
971
|
+
/**
|
|
972
|
+
* Disconnect from a socket.
|
|
973
|
+
*
|
|
974
|
+
* @async
|
|
975
|
+
* @function disconnect
|
|
976
|
+
* @returns
|
|
977
|
+
*/
|
|
978
|
+
|
|
728
979
|
|
|
729
980
|
NCloudChat.prototype.disconnect = function () {
|
|
730
981
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -733,20 +984,47 @@ function () {
|
|
|
733
984
|
/*return*/
|
|
734
985
|
];
|
|
735
986
|
this.socket.disconnect();
|
|
987
|
+
|
|
988
|
+
_CoreManager["default"].set("TOKEN", "");
|
|
989
|
+
|
|
736
990
|
return [2
|
|
737
991
|
/*return*/
|
|
738
992
|
];
|
|
739
993
|
});
|
|
740
994
|
});
|
|
741
995
|
};
|
|
996
|
+
/**
|
|
997
|
+
* Check if a client is connected to a socket.
|
|
998
|
+
*
|
|
999
|
+
* @function isConnected
|
|
1000
|
+
* @returns {boolean}
|
|
1001
|
+
*/
|
|
1002
|
+
|
|
742
1003
|
|
|
743
1004
|
NCloudChat.prototype.isConnected = function () {
|
|
1005
|
+
var token = _CoreManager["default"].get("TOKEN");
|
|
1006
|
+
|
|
1007
|
+
if (token) return true;
|
|
1008
|
+
return false;
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
NCloudChat.prototype.isSocketConnected = function () {
|
|
744
1012
|
return this.connected ? true : false;
|
|
745
1013
|
};
|
|
1014
|
+
/**
|
|
1015
|
+
* Bind fn event handlers.
|
|
1016
|
+
*
|
|
1017
|
+
* @async
|
|
1018
|
+
* @function bind
|
|
1019
|
+
* @param {string} id
|
|
1020
|
+
* @param {any} fn
|
|
1021
|
+
*/
|
|
1022
|
+
|
|
746
1023
|
|
|
747
1024
|
NCloudChat.prototype.bind = function (id, fn) {
|
|
748
1025
|
return __awaiter(this, void 0, void 0, function () {
|
|
749
1026
|
return __generator(this, function (_a) {
|
|
1027
|
+
this.dp.off(id);
|
|
750
1028
|
this.dp.on(id, fn);
|
|
751
1029
|
return [2
|
|
752
1030
|
/*return*/
|
|
@@ -754,17 +1032,31 @@ function () {
|
|
|
754
1032
|
});
|
|
755
1033
|
});
|
|
756
1034
|
};
|
|
1035
|
+
/**
|
|
1036
|
+
* Unbind fn event handlers.
|
|
1037
|
+
*
|
|
1038
|
+
* @async
|
|
1039
|
+
* @function unbind
|
|
1040
|
+
* @param {string} id
|
|
1041
|
+
* @param {any} fn
|
|
1042
|
+
*/
|
|
1043
|
+
|
|
757
1044
|
|
|
758
|
-
NCloudChat.prototype.unbind = function (id
|
|
1045
|
+
NCloudChat.prototype.unbind = function (id) {
|
|
759
1046
|
return __awaiter(this, void 0, void 0, function () {
|
|
760
1047
|
return __generator(this, function (_a) {
|
|
761
|
-
this.dp.off(id
|
|
1048
|
+
this.dp.off(id);
|
|
762
1049
|
return [2
|
|
763
1050
|
/*return*/
|
|
764
1051
|
];
|
|
765
1052
|
});
|
|
766
1053
|
});
|
|
767
1054
|
};
|
|
1055
|
+
/**
|
|
1056
|
+
* Unbind all event handlers.
|
|
1057
|
+
* @param id
|
|
1058
|
+
*/
|
|
1059
|
+
|
|
768
1060
|
|
|
769
1061
|
NCloudChat.prototype.unbindall = function (id) {
|
|
770
1062
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -776,11 +1068,30 @@ function () {
|
|
|
776
1068
|
});
|
|
777
1069
|
});
|
|
778
1070
|
};
|
|
1071
|
+
/**
|
|
1072
|
+
* Decodes a base-64 encoded string.
|
|
1073
|
+
*
|
|
1074
|
+
* @function ObjectId
|
|
1075
|
+
* @param {string} id - An encoded string to be decoded.
|
|
1076
|
+
* @returns {string} decoded string.
|
|
1077
|
+
*/
|
|
1078
|
+
|
|
779
1079
|
|
|
780
1080
|
NCloudChat.prototype.ObjectId = function (id) {
|
|
781
1081
|
if (!id) return "";
|
|
782
1082
|
return atob(id).split(":")[1];
|
|
783
1083
|
};
|
|
1084
|
+
/**
|
|
1085
|
+
* Get current friends list of all status.
|
|
1086
|
+
*
|
|
1087
|
+
* @async
|
|
1088
|
+
* @function getFriendships
|
|
1089
|
+
* @param {string} filter - Field value for filter.
|
|
1090
|
+
* @param {string} sort - Field value for sorting.
|
|
1091
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1092
|
+
* @returns {Promise<any>}
|
|
1093
|
+
*/
|
|
1094
|
+
|
|
784
1095
|
|
|
785
1096
|
NCloudChat.prototype.getFriendships = function (filter, sort, option) {
|
|
786
1097
|
if (sort === void 0) {
|
|
@@ -792,14 +1103,14 @@ function () {
|
|
|
792
1103
|
}
|
|
793
1104
|
|
|
794
1105
|
return __awaiter(this, void 0, void 0, function () {
|
|
795
|
-
var entries, friends,
|
|
1106
|
+
var entries, friends, e_9;
|
|
1107
|
+
|
|
1108
|
+
var _this = this;
|
|
1109
|
+
|
|
796
1110
|
return __generator(this, function (_a) {
|
|
797
1111
|
switch (_a.label) {
|
|
798
1112
|
case 0:
|
|
799
|
-
|
|
800
|
-
throw Error("You are not connected.");
|
|
801
|
-
}
|
|
802
|
-
|
|
1113
|
+
this.inputValidation({});
|
|
803
1114
|
_a.label = 1;
|
|
804
1115
|
|
|
805
1116
|
case 1:
|
|
@@ -813,7 +1124,9 @@ function () {
|
|
|
813
1124
|
entries = _a.sent();
|
|
814
1125
|
|
|
815
1126
|
if (entries) {
|
|
816
|
-
friends = entries.map(function (item) {
|
|
1127
|
+
friends = entries["edges"].map(function (item) {
|
|
1128
|
+
item.node.friend.id = _this.ObjectId(item.node.friend.id);
|
|
1129
|
+
item.node.user.id = _this.ObjectId(item.node.user.id);
|
|
817
1130
|
return __assign(__assign({}, item.node), {
|
|
818
1131
|
id: item.node.id
|
|
819
1132
|
});
|
|
@@ -825,11 +1138,11 @@ function () {
|
|
|
825
1138
|
|
|
826
1139
|
return [2
|
|
827
1140
|
/*return*/
|
|
828
|
-
, entries];
|
|
1141
|
+
, entries["edges"]];
|
|
829
1142
|
|
|
830
1143
|
case 3:
|
|
831
|
-
|
|
832
|
-
throw
|
|
1144
|
+
e_9 = _a.sent();
|
|
1145
|
+
throw e_9;
|
|
833
1146
|
|
|
834
1147
|
case 4:
|
|
835
1148
|
return [2
|
|
@@ -839,8 +1152,19 @@ function () {
|
|
|
839
1152
|
});
|
|
840
1153
|
});
|
|
841
1154
|
};
|
|
842
|
-
|
|
843
|
-
|
|
1155
|
+
/**
|
|
1156
|
+
* Get member blocks.
|
|
1157
|
+
*
|
|
1158
|
+
* @async
|
|
1159
|
+
* @function getBannedUsers
|
|
1160
|
+
* @param {string} filter - Field value for filter.
|
|
1161
|
+
* @param {string} sort - Field value for sorting.
|
|
1162
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1163
|
+
* @returns {Promise<any>}
|
|
1164
|
+
*/
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
NCloudChat.prototype.getBannedUsers = function (filter, sort, option) {
|
|
844
1168
|
if (sort === void 0) {
|
|
845
1169
|
sort = {};
|
|
846
1170
|
}
|
|
@@ -850,17 +1174,14 @@ function () {
|
|
|
850
1174
|
}
|
|
851
1175
|
|
|
852
1176
|
return __awaiter(this, void 0, void 0, function () {
|
|
853
|
-
var entries, members,
|
|
1177
|
+
var entries, members, e_10;
|
|
854
1178
|
|
|
855
1179
|
var _this = this;
|
|
856
1180
|
|
|
857
1181
|
return __generator(this, function (_a) {
|
|
858
1182
|
switch (_a.label) {
|
|
859
1183
|
case 0:
|
|
860
|
-
|
|
861
|
-
throw Error("You are not connected.");
|
|
862
|
-
}
|
|
863
|
-
|
|
1184
|
+
this.inputValidation({});
|
|
864
1185
|
_a.label = 1;
|
|
865
1186
|
|
|
866
1187
|
case 1:
|
|
@@ -868,13 +1189,13 @@ function () {
|
|
|
868
1189
|
|
|
869
1190
|
return [4
|
|
870
1191
|
/*yield*/
|
|
871
|
-
, (0, _queries.
|
|
1192
|
+
, (0, _queries.getMemberBlocks)((0, _stringify["default"])(filter), (0, _stringify["default"])(sort), (0, _stringify["default"])(option))];
|
|
872
1193
|
|
|
873
1194
|
case 2:
|
|
874
1195
|
entries = _a.sent();
|
|
875
1196
|
|
|
876
|
-
if (entries) {
|
|
877
|
-
members = entries.map(function (item) {
|
|
1197
|
+
if (entries["edges"]) {
|
|
1198
|
+
members = entries["edges"].map(function (item) {
|
|
878
1199
|
return __assign(__assign({}, item.node), {
|
|
879
1200
|
id: _this.ObjectId(item.node.id)
|
|
880
1201
|
});
|
|
@@ -886,11 +1207,11 @@ function () {
|
|
|
886
1207
|
|
|
887
1208
|
return [2
|
|
888
1209
|
/*return*/
|
|
889
|
-
, entries];
|
|
1210
|
+
, entries["edges"]];
|
|
890
1211
|
|
|
891
1212
|
case 3:
|
|
892
|
-
|
|
893
|
-
throw
|
|
1213
|
+
e_10 = _a.sent();
|
|
1214
|
+
throw e_10;
|
|
894
1215
|
|
|
895
1216
|
case 4:
|
|
896
1217
|
return [2
|
|
@@ -900,8 +1221,19 @@ function () {
|
|
|
900
1221
|
});
|
|
901
1222
|
});
|
|
902
1223
|
};
|
|
903
|
-
|
|
904
|
-
|
|
1224
|
+
/**
|
|
1225
|
+
* Get information data of the member.
|
|
1226
|
+
*
|
|
1227
|
+
* @async
|
|
1228
|
+
* @function getUsers
|
|
1229
|
+
* @param {string} filter - Field value for filter.
|
|
1230
|
+
* @param {string} sort - Field value for sorting.
|
|
1231
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1232
|
+
* @returns {Promise<any>}
|
|
1233
|
+
*/
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
NCloudChat.prototype.getUsers = function (filter, sort, option) {
|
|
905
1237
|
if (sort === void 0) {
|
|
906
1238
|
sort = {};
|
|
907
1239
|
}
|
|
@@ -911,17 +1243,14 @@ function () {
|
|
|
911
1243
|
}
|
|
912
1244
|
|
|
913
1245
|
return __awaiter(this, void 0, void 0, function () {
|
|
914
|
-
var entries,
|
|
1246
|
+
var entries, members, e_11;
|
|
915
1247
|
|
|
916
1248
|
var _this = this;
|
|
917
1249
|
|
|
918
1250
|
return __generator(this, function (_a) {
|
|
919
1251
|
switch (_a.label) {
|
|
920
1252
|
case 0:
|
|
921
|
-
|
|
922
|
-
throw Error("You are not connected.");
|
|
923
|
-
}
|
|
924
|
-
|
|
1253
|
+
this.inputValidation({});
|
|
925
1254
|
_a.label = 1;
|
|
926
1255
|
|
|
927
1256
|
case 1:
|
|
@@ -929,29 +1258,29 @@ function () {
|
|
|
929
1258
|
|
|
930
1259
|
return [4
|
|
931
1260
|
/*yield*/
|
|
932
|
-
, (0, _queries.
|
|
1261
|
+
, (0, _queries.getMembers)((0, _stringify["default"])(filter), (0, _stringify["default"])(sort), (0, _stringify["default"])(option))];
|
|
933
1262
|
|
|
934
1263
|
case 2:
|
|
935
1264
|
entries = _a.sent();
|
|
936
1265
|
|
|
937
1266
|
if (entries) {
|
|
938
|
-
|
|
1267
|
+
members = entries['edges'].map(function (item) {
|
|
939
1268
|
return __assign(__assign({}, item.node), {
|
|
940
1269
|
id: _this.ObjectId(item.node.id)
|
|
941
1270
|
});
|
|
942
1271
|
});
|
|
943
1272
|
return [2
|
|
944
1273
|
/*return*/
|
|
945
|
-
,
|
|
1274
|
+
, members];
|
|
946
1275
|
}
|
|
947
1276
|
|
|
948
|
-
return [
|
|
949
|
-
/*
|
|
950
|
-
,
|
|
1277
|
+
return [3
|
|
1278
|
+
/*break*/
|
|
1279
|
+
, 4];
|
|
951
1280
|
|
|
952
1281
|
case 3:
|
|
953
|
-
|
|
954
|
-
throw
|
|
1282
|
+
e_11 = _a.sent();
|
|
1283
|
+
throw e_11;
|
|
955
1284
|
|
|
956
1285
|
case 4:
|
|
957
1286
|
return [2
|
|
@@ -961,17 +1290,25 @@ function () {
|
|
|
961
1290
|
});
|
|
962
1291
|
});
|
|
963
1292
|
};
|
|
1293
|
+
/**
|
|
1294
|
+
* Request a friendship to a user.
|
|
1295
|
+
*
|
|
1296
|
+
* @async
|
|
1297
|
+
* @function requestFriend
|
|
1298
|
+
* @param {string} friendId - An id of the friend to request.
|
|
1299
|
+
* @returns {Promise<any>}
|
|
1300
|
+
*/
|
|
1301
|
+
|
|
964
1302
|
|
|
965
1303
|
NCloudChat.prototype.requestFriend = function (friendId) {
|
|
966
1304
|
return __awaiter(this, void 0, void 0, function () {
|
|
967
|
-
var
|
|
1305
|
+
var result, e_12;
|
|
968
1306
|
return __generator(this, function (_a) {
|
|
969
1307
|
switch (_a.label) {
|
|
970
1308
|
case 0:
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
|
|
1309
|
+
this.inputValidation({
|
|
1310
|
+
friendId: friendId
|
|
1311
|
+
});
|
|
975
1312
|
_a.label = 1;
|
|
976
1313
|
|
|
977
1314
|
case 1:
|
|
@@ -982,13 +1319,20 @@ function () {
|
|
|
982
1319
|
, (0, _mutations.requestFriend)(friendId)];
|
|
983
1320
|
|
|
984
1321
|
case 2:
|
|
1322
|
+
result = _a.sent();
|
|
1323
|
+
|
|
1324
|
+
if (result["friendship"]) {
|
|
1325
|
+
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
1326
|
+
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
985
1329
|
return [2
|
|
986
1330
|
/*return*/
|
|
987
|
-
,
|
|
1331
|
+
, result["friendship"]];
|
|
988
1332
|
|
|
989
1333
|
case 3:
|
|
990
|
-
|
|
991
|
-
throw
|
|
1334
|
+
e_12 = _a.sent();
|
|
1335
|
+
throw e_12;
|
|
992
1336
|
|
|
993
1337
|
case 4:
|
|
994
1338
|
return [2
|
|
@@ -998,17 +1342,25 @@ function () {
|
|
|
998
1342
|
});
|
|
999
1343
|
});
|
|
1000
1344
|
};
|
|
1345
|
+
/**
|
|
1346
|
+
* Accept a friends request.
|
|
1347
|
+
*
|
|
1348
|
+
* @async
|
|
1349
|
+
* @function acceptFriend
|
|
1350
|
+
* @param {string} friendId - The id of the friend to accept the request.
|
|
1351
|
+
* @returns {Promise<any>}
|
|
1352
|
+
*/
|
|
1353
|
+
|
|
1001
1354
|
|
|
1002
1355
|
NCloudChat.prototype.acceptFriend = function (friendId) {
|
|
1003
1356
|
return __awaiter(this, void 0, void 0, function () {
|
|
1004
|
-
var
|
|
1357
|
+
var result, e_13;
|
|
1005
1358
|
return __generator(this, function (_a) {
|
|
1006
1359
|
switch (_a.label) {
|
|
1007
1360
|
case 0:
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1361
|
+
this.inputValidation({
|
|
1362
|
+
friendId: friendId
|
|
1363
|
+
});
|
|
1012
1364
|
_a.label = 1;
|
|
1013
1365
|
|
|
1014
1366
|
case 1:
|
|
@@ -1019,13 +1371,20 @@ function () {
|
|
|
1019
1371
|
, (0, _mutations.acceptFriend)(friendId)];
|
|
1020
1372
|
|
|
1021
1373
|
case 2:
|
|
1374
|
+
result = _a.sent();
|
|
1375
|
+
|
|
1376
|
+
if (result["friendship"]) {
|
|
1377
|
+
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
1378
|
+
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1022
1381
|
return [2
|
|
1023
1382
|
/*return*/
|
|
1024
|
-
,
|
|
1383
|
+
, result["friendship"]];
|
|
1025
1384
|
|
|
1026
1385
|
case 3:
|
|
1027
|
-
|
|
1028
|
-
throw
|
|
1386
|
+
e_13 = _a.sent();
|
|
1387
|
+
throw e_13;
|
|
1029
1388
|
|
|
1030
1389
|
case 4:
|
|
1031
1390
|
return [2
|
|
@@ -1035,17 +1394,25 @@ function () {
|
|
|
1035
1394
|
});
|
|
1036
1395
|
});
|
|
1037
1396
|
};
|
|
1397
|
+
/**
|
|
1398
|
+
* Reject a friend request.
|
|
1399
|
+
*
|
|
1400
|
+
* @async
|
|
1401
|
+
* @function rejectFriend
|
|
1402
|
+
* @param {string} friendId - An id of the friend to be rejected.
|
|
1403
|
+
* @returns {Promise<any>}
|
|
1404
|
+
*/
|
|
1405
|
+
|
|
1038
1406
|
|
|
1039
1407
|
NCloudChat.prototype.rejectFriend = function (friendId) {
|
|
1040
1408
|
return __awaiter(this, void 0, void 0, function () {
|
|
1041
|
-
var
|
|
1409
|
+
var result, e_14;
|
|
1042
1410
|
return __generator(this, function (_a) {
|
|
1043
1411
|
switch (_a.label) {
|
|
1044
1412
|
case 0:
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1413
|
+
this.inputValidation({
|
|
1414
|
+
friendId: friendId
|
|
1415
|
+
});
|
|
1049
1416
|
_a.label = 1;
|
|
1050
1417
|
|
|
1051
1418
|
case 1:
|
|
@@ -1056,13 +1423,20 @@ function () {
|
|
|
1056
1423
|
, (0, _mutations.rejectFriend)(friendId)];
|
|
1057
1424
|
|
|
1058
1425
|
case 2:
|
|
1426
|
+
result = _a.sent();
|
|
1427
|
+
|
|
1428
|
+
if (result["friendship"]) {
|
|
1429
|
+
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
1430
|
+
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1059
1433
|
return [2
|
|
1060
1434
|
/*return*/
|
|
1061
|
-
,
|
|
1435
|
+
, result["friendship"]];
|
|
1062
1436
|
|
|
1063
1437
|
case 3:
|
|
1064
|
-
|
|
1065
|
-
throw
|
|
1438
|
+
e_14 = _a.sent();
|
|
1439
|
+
throw e_14;
|
|
1066
1440
|
|
|
1067
1441
|
case 4:
|
|
1068
1442
|
return [2
|
|
@@ -1072,17 +1446,25 @@ function () {
|
|
|
1072
1446
|
});
|
|
1073
1447
|
});
|
|
1074
1448
|
};
|
|
1449
|
+
/**
|
|
1450
|
+
* Remove a friend.
|
|
1451
|
+
*
|
|
1452
|
+
* @async
|
|
1453
|
+
* @function removeFriend
|
|
1454
|
+
* @param {string} friendId - An id of the friend to be removed.
|
|
1455
|
+
* @returns {Promise<any>}
|
|
1456
|
+
*/
|
|
1457
|
+
|
|
1075
1458
|
|
|
1076
1459
|
NCloudChat.prototype.removeFriend = function (friendId) {
|
|
1077
1460
|
return __awaiter(this, void 0, void 0, function () {
|
|
1078
|
-
var
|
|
1461
|
+
var result, e_15;
|
|
1079
1462
|
return __generator(this, function (_a) {
|
|
1080
1463
|
switch (_a.label) {
|
|
1081
1464
|
case 0:
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1465
|
+
this.inputValidation({
|
|
1466
|
+
friendId: friendId
|
|
1467
|
+
});
|
|
1086
1468
|
_a.label = 1;
|
|
1087
1469
|
|
|
1088
1470
|
case 1:
|
|
@@ -1093,13 +1475,20 @@ function () {
|
|
|
1093
1475
|
, (0, _mutations.removeFriend)(friendId)];
|
|
1094
1476
|
|
|
1095
1477
|
case 2:
|
|
1478
|
+
result = _a.sent();
|
|
1479
|
+
|
|
1480
|
+
if (result["friendship"]) {
|
|
1481
|
+
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
1482
|
+
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1096
1485
|
return [2
|
|
1097
1486
|
/*return*/
|
|
1098
|
-
,
|
|
1487
|
+
, result["friendship"]];
|
|
1099
1488
|
|
|
1100
1489
|
case 3:
|
|
1101
|
-
|
|
1102
|
-
throw
|
|
1490
|
+
e_15 = _a.sent();
|
|
1491
|
+
throw e_15;
|
|
1103
1492
|
|
|
1104
1493
|
case 4:
|
|
1105
1494
|
return [2
|
|
@@ -1109,17 +1498,25 @@ function () {
|
|
|
1109
1498
|
});
|
|
1110
1499
|
});
|
|
1111
1500
|
};
|
|
1501
|
+
/**
|
|
1502
|
+
* Get a count of unread messages of a channel.
|
|
1503
|
+
*
|
|
1504
|
+
* @async
|
|
1505
|
+
* @function countUnread
|
|
1506
|
+
* @param {string} channelId - The id of a channel.
|
|
1507
|
+
* @returns {Promise<any>}
|
|
1508
|
+
*/
|
|
1509
|
+
|
|
1112
1510
|
|
|
1113
1511
|
NCloudChat.prototype.countUnread = function (channelId) {
|
|
1114
1512
|
return __awaiter(this, void 0, void 0, function () {
|
|
1115
|
-
var
|
|
1513
|
+
var e_16;
|
|
1116
1514
|
return __generator(this, function (_a) {
|
|
1117
1515
|
switch (_a.label) {
|
|
1118
1516
|
case 0:
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1517
|
+
this.inputValidation({
|
|
1518
|
+
channelId: channelId
|
|
1519
|
+
});
|
|
1123
1520
|
_a.label = 1;
|
|
1124
1521
|
|
|
1125
1522
|
case 1:
|
|
@@ -1135,8 +1532,8 @@ function () {
|
|
|
1135
1532
|
, _a.sent()];
|
|
1136
1533
|
|
|
1137
1534
|
case 3:
|
|
1138
|
-
|
|
1139
|
-
throw
|
|
1535
|
+
e_16 = _a.sent();
|
|
1536
|
+
throw e_16;
|
|
1140
1537
|
|
|
1141
1538
|
case 4:
|
|
1142
1539
|
return [2
|
|
@@ -1146,17 +1543,27 @@ function () {
|
|
|
1146
1543
|
});
|
|
1147
1544
|
});
|
|
1148
1545
|
};
|
|
1546
|
+
/**
|
|
1547
|
+
* Get subscription data of the user.
|
|
1548
|
+
*
|
|
1549
|
+
* @async
|
|
1550
|
+
* @function getSubscription
|
|
1551
|
+
* @param {string} channelId - The id of a channel.
|
|
1552
|
+
* @param {string} id
|
|
1553
|
+
* @returns {Promise<any>}
|
|
1554
|
+
*/
|
|
1555
|
+
|
|
1149
1556
|
|
|
1150
1557
|
NCloudChat.prototype.getSubscription = function (channelId, id) {
|
|
1151
1558
|
return __awaiter(this, void 0, void 0, function () {
|
|
1152
|
-
var
|
|
1559
|
+
var subscription, e_17;
|
|
1153
1560
|
return __generator(this, function (_a) {
|
|
1154
1561
|
switch (_a.label) {
|
|
1155
1562
|
case 0:
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1563
|
+
this.inputValidation({
|
|
1564
|
+
channelId: channelId,
|
|
1565
|
+
subscriptionId: id
|
|
1566
|
+
});
|
|
1160
1567
|
_a.label = 1;
|
|
1161
1568
|
|
|
1162
1569
|
case 1:
|
|
@@ -1167,33 +1574,43 @@ function () {
|
|
|
1167
1574
|
, (0, _queries.getSubscription)(channelId, id)];
|
|
1168
1575
|
|
|
1169
1576
|
case 2:
|
|
1577
|
+
subscription = _a.sent();
|
|
1578
|
+
if (subscription) subscription["id"] = this.ObjectId(subscription["id"]);
|
|
1170
1579
|
return [2
|
|
1171
1580
|
/*return*/
|
|
1172
|
-
,
|
|
1581
|
+
, subscription];
|
|
1173
1582
|
|
|
1174
1583
|
case 3:
|
|
1175
|
-
|
|
1176
|
-
throw
|
|
1584
|
+
e_17 = _a.sent();
|
|
1585
|
+
throw e_17;
|
|
1177
1586
|
|
|
1178
1587
|
case 4:
|
|
1179
1588
|
return [2
|
|
1180
1589
|
/*return*/
|
|
1181
|
-
|
|
1590
|
+
];
|
|
1182
1591
|
}
|
|
1183
1592
|
});
|
|
1184
1593
|
});
|
|
1185
1594
|
};
|
|
1595
|
+
/**
|
|
1596
|
+
* Get data of a single channel from the endpoint.
|
|
1597
|
+
*
|
|
1598
|
+
* @async
|
|
1599
|
+
* @function getChannel
|
|
1600
|
+
* @param {string} channelId - An id of the channel.
|
|
1601
|
+
* @returns {Promise<any>} The data of the channel.
|
|
1602
|
+
*/
|
|
1603
|
+
|
|
1186
1604
|
|
|
1187
1605
|
NCloudChat.prototype.getChannel = function (channelId) {
|
|
1188
1606
|
return __awaiter(this, void 0, void 0, function () {
|
|
1189
|
-
var
|
|
1607
|
+
var result, e_18;
|
|
1190
1608
|
return __generator(this, function (_a) {
|
|
1191
1609
|
switch (_a.label) {
|
|
1192
1610
|
case 0:
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1611
|
+
this.inputValidation({
|
|
1612
|
+
channelId: channelId
|
|
1613
|
+
});
|
|
1197
1614
|
_a.label = 1;
|
|
1198
1615
|
|
|
1199
1616
|
case 1:
|
|
@@ -1204,33 +1621,118 @@ function () {
|
|
|
1204
1621
|
, (0, _queries.getChannel)(channelId)];
|
|
1205
1622
|
|
|
1206
1623
|
case 2:
|
|
1624
|
+
result = _a.sent();
|
|
1625
|
+
|
|
1626
|
+
if (result) {
|
|
1627
|
+
result.id = this.ObjectId(result.id);
|
|
1628
|
+
result["user_id"]["id"] = this.ObjectId(result["user_id"]["id"]);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1207
1631
|
return [2
|
|
1208
1632
|
/*return*/
|
|
1209
|
-
,
|
|
1633
|
+
, result];
|
|
1210
1634
|
|
|
1211
1635
|
case 3:
|
|
1212
|
-
|
|
1213
|
-
throw
|
|
1636
|
+
e_18 = _a.sent();
|
|
1637
|
+
throw e_18;
|
|
1214
1638
|
|
|
1215
1639
|
case 4:
|
|
1216
1640
|
return [2
|
|
1217
1641
|
/*return*/
|
|
1218
|
-
|
|
1642
|
+
];
|
|
1219
1643
|
}
|
|
1220
1644
|
});
|
|
1221
1645
|
});
|
|
1222
1646
|
};
|
|
1647
|
+
/**
|
|
1648
|
+
* Get data of multiple channels.
|
|
1649
|
+
*
|
|
1650
|
+
* @async
|
|
1651
|
+
* @function getChannels
|
|
1652
|
+
* @param {string} filter - Field value for filter.
|
|
1653
|
+
* @param {string} sort - Field value for sorting.
|
|
1654
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1655
|
+
* @returns {Promise<any[]>} An array of data of all channels.
|
|
1656
|
+
*/
|
|
1657
|
+
|
|
1658
|
+
|
|
1659
|
+
NCloudChat.prototype.getChannels = function (filter, sort, option) {
|
|
1660
|
+
if (sort === void 0) {
|
|
1661
|
+
sort = {};
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
if (option === void 0) {
|
|
1665
|
+
option = {};
|
|
1666
|
+
}
|
|
1223
1667
|
|
|
1224
|
-
NCloudChat.prototype.getMessage = function (channelId, messageId) {
|
|
1225
1668
|
return __awaiter(this, void 0, void 0, function () {
|
|
1226
|
-
var
|
|
1669
|
+
var entries, channels, e_19;
|
|
1670
|
+
|
|
1671
|
+
var _this = this;
|
|
1672
|
+
|
|
1227
1673
|
return __generator(this, function (_a) {
|
|
1228
1674
|
switch (_a.label) {
|
|
1229
1675
|
case 0:
|
|
1230
|
-
|
|
1231
|
-
|
|
1676
|
+
this.inputValidation({});
|
|
1677
|
+
_a.label = 1;
|
|
1678
|
+
|
|
1679
|
+
case 1:
|
|
1680
|
+
_a.trys.push([1, 3,, 4]);
|
|
1681
|
+
|
|
1682
|
+
return [4
|
|
1683
|
+
/*yield*/
|
|
1684
|
+
, (0, _queries.getChannels)((0, _stringify["default"])(filter), (0, _stringify["default"])(sort), (0, _stringify["default"])(option))];
|
|
1685
|
+
|
|
1686
|
+
case 2:
|
|
1687
|
+
entries = _a.sent();
|
|
1688
|
+
|
|
1689
|
+
if (entries["edges"]) {
|
|
1690
|
+
channels = entries["edges"].map(function (item) {
|
|
1691
|
+
item.node.user_id.id = _this.ObjectId(item.node.user_id.id);
|
|
1692
|
+
return __assign(__assign({}, item.node), {
|
|
1693
|
+
id: _this.ObjectId(item.node.id)
|
|
1694
|
+
});
|
|
1695
|
+
});
|
|
1696
|
+
return [2
|
|
1697
|
+
/*return*/
|
|
1698
|
+
, channels];
|
|
1232
1699
|
}
|
|
1233
1700
|
|
|
1701
|
+
return [2
|
|
1702
|
+
/*return*/
|
|
1703
|
+
, entries["edges"]];
|
|
1704
|
+
|
|
1705
|
+
case 3:
|
|
1706
|
+
e_19 = _a.sent();
|
|
1707
|
+
throw e_19;
|
|
1708
|
+
|
|
1709
|
+
case 4:
|
|
1710
|
+
return [2
|
|
1711
|
+
/*return*/
|
|
1712
|
+
];
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
});
|
|
1716
|
+
};
|
|
1717
|
+
/**
|
|
1718
|
+
* @async
|
|
1719
|
+
* @function getMessage
|
|
1720
|
+
* @param {string} channelId - The id of a channel.
|
|
1721
|
+
* @param {string} messageId - The id of a message.
|
|
1722
|
+
* @returns {Promise<any>}
|
|
1723
|
+
*/
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
NCloudChat.prototype.getMessage = function (channelId, messageId) {
|
|
1727
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1728
|
+
var entry, e_20;
|
|
1729
|
+
return __generator(this, function (_a) {
|
|
1730
|
+
switch (_a.label) {
|
|
1731
|
+
case 0:
|
|
1732
|
+
this.inputValidation({
|
|
1733
|
+
channelId: channelId,
|
|
1734
|
+
messageId: messageId
|
|
1735
|
+
});
|
|
1234
1736
|
_a.label = 1;
|
|
1235
1737
|
|
|
1236
1738
|
case 1:
|
|
@@ -1252,11 +1754,11 @@ function () {
|
|
|
1252
1754
|
|
|
1253
1755
|
return [2
|
|
1254
1756
|
/*return*/
|
|
1255
|
-
,
|
|
1757
|
+
, entry];
|
|
1256
1758
|
|
|
1257
1759
|
case 3:
|
|
1258
|
-
|
|
1259
|
-
throw
|
|
1760
|
+
e_20 = _a.sent();
|
|
1761
|
+
throw e_20;
|
|
1260
1762
|
|
|
1261
1763
|
case 4:
|
|
1262
1764
|
return [2
|
|
@@ -1266,20 +1768,28 @@ function () {
|
|
|
1266
1768
|
});
|
|
1267
1769
|
});
|
|
1268
1770
|
};
|
|
1771
|
+
/**
|
|
1772
|
+
* Get data of the all messages.
|
|
1773
|
+
*
|
|
1774
|
+
* @async
|
|
1775
|
+
* @function getMessages
|
|
1776
|
+
* @param {string} filter - Field value for filter.
|
|
1777
|
+
* @param {string} sort - Field value for sorting.
|
|
1778
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1779
|
+
* @returns {Promise<any>}
|
|
1780
|
+
*/
|
|
1781
|
+
|
|
1269
1782
|
|
|
1270
1783
|
NCloudChat.prototype.getMessages = function (filter, sort, option) {
|
|
1271
1784
|
return __awaiter(this, void 0, void 0, function () {
|
|
1272
|
-
var entries, messages,
|
|
1785
|
+
var entries, messages, e_21;
|
|
1273
1786
|
|
|
1274
1787
|
var _this = this;
|
|
1275
1788
|
|
|
1276
1789
|
return __generator(this, function (_a) {
|
|
1277
1790
|
switch (_a.label) {
|
|
1278
1791
|
case 0:
|
|
1279
|
-
|
|
1280
|
-
throw Error("You are not connected.");
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1792
|
+
this.inputValidation({});
|
|
1283
1793
|
_a.label = 1;
|
|
1284
1794
|
|
|
1285
1795
|
case 1:
|
|
@@ -1292,8 +1802,8 @@ function () {
|
|
|
1292
1802
|
case 2:
|
|
1293
1803
|
entries = _a.sent();
|
|
1294
1804
|
|
|
1295
|
-
if (entries) {
|
|
1296
|
-
messages = entries.map(function (item) {
|
|
1805
|
+
if (entries["edges"]) {
|
|
1806
|
+
messages = entries["edges"].map(function (item) {
|
|
1297
1807
|
return __assign(__assign({}, item.node), {
|
|
1298
1808
|
id: _this.ObjectId(item.node.id)
|
|
1299
1809
|
});
|
|
@@ -1305,11 +1815,11 @@ function () {
|
|
|
1305
1815
|
|
|
1306
1816
|
return [2
|
|
1307
1817
|
/*return*/
|
|
1308
|
-
, entries];
|
|
1818
|
+
, entries["edges"]];
|
|
1309
1819
|
|
|
1310
1820
|
case 3:
|
|
1311
|
-
|
|
1312
|
-
throw
|
|
1821
|
+
e_21 = _a.sent();
|
|
1822
|
+
throw e_21;
|
|
1313
1823
|
|
|
1314
1824
|
case 4:
|
|
1315
1825
|
return [2
|
|
@@ -1319,20 +1829,25 @@ function () {
|
|
|
1319
1829
|
});
|
|
1320
1830
|
});
|
|
1321
1831
|
};
|
|
1832
|
+
/**
|
|
1833
|
+
* Get a list of subscibed member of the channel.
|
|
1834
|
+
* @param {string} filter - Field value for filter.
|
|
1835
|
+
* @param {string} sort - Field value for sorting.
|
|
1836
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1837
|
+
* @returns {Promise<any>}
|
|
1838
|
+
*/
|
|
1839
|
+
|
|
1322
1840
|
|
|
1323
1841
|
NCloudChat.prototype.getSubscriptions = function (filter, sort, option) {
|
|
1324
1842
|
return __awaiter(this, void 0, void 0, function () {
|
|
1325
|
-
var entries, subscribes,
|
|
1843
|
+
var entries, subscribes, e_22;
|
|
1326
1844
|
|
|
1327
1845
|
var _this = this;
|
|
1328
1846
|
|
|
1329
1847
|
return __generator(this, function (_a) {
|
|
1330
1848
|
switch (_a.label) {
|
|
1331
1849
|
case 0:
|
|
1332
|
-
|
|
1333
|
-
throw Error("You are not connected.");
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1850
|
+
this.inputValidation({});
|
|
1336
1851
|
_a.label = 1;
|
|
1337
1852
|
|
|
1338
1853
|
case 1:
|
|
@@ -1345,8 +1860,8 @@ function () {
|
|
|
1345
1860
|
case 2:
|
|
1346
1861
|
entries = _a.sent();
|
|
1347
1862
|
|
|
1348
|
-
if (entries) {
|
|
1349
|
-
subscribes = entries.map(function (item) {
|
|
1863
|
+
if (entries["edges"]) {
|
|
1864
|
+
subscribes = entries["edges"].map(function (item) {
|
|
1350
1865
|
return __assign(__assign({}, item.node), {
|
|
1351
1866
|
id: _this.ObjectId(item.node.id)
|
|
1352
1867
|
});
|
|
@@ -1358,11 +1873,11 @@ function () {
|
|
|
1358
1873
|
|
|
1359
1874
|
return [2
|
|
1360
1875
|
/*return*/
|
|
1361
|
-
, entries];
|
|
1876
|
+
, entries["edges"]];
|
|
1362
1877
|
|
|
1363
1878
|
case 3:
|
|
1364
|
-
|
|
1365
|
-
throw
|
|
1879
|
+
e_22 = _a.sent();
|
|
1880
|
+
throw e_22;
|
|
1366
1881
|
|
|
1367
1882
|
case 4:
|
|
1368
1883
|
return [2
|
|
@@ -1372,17 +1887,26 @@ function () {
|
|
|
1372
1887
|
});
|
|
1373
1888
|
});
|
|
1374
1889
|
};
|
|
1890
|
+
/**
|
|
1891
|
+
* Create a new channel.
|
|
1892
|
+
*
|
|
1893
|
+
* @async
|
|
1894
|
+
* @function createChannel
|
|
1895
|
+
* @param {ChannelInput} channel - Configuration options of the new channel.
|
|
1896
|
+
* @returns {Promise<any>} The data of the newly created channel.
|
|
1897
|
+
*/
|
|
1898
|
+
|
|
1375
1899
|
|
|
1376
1900
|
NCloudChat.prototype.createChannel = function (channel) {
|
|
1377
1901
|
return __awaiter(this, void 0, void 0, function () {
|
|
1378
|
-
var
|
|
1902
|
+
var result, e_23;
|
|
1379
1903
|
return __generator(this, function (_a) {
|
|
1380
1904
|
switch (_a.label) {
|
|
1381
1905
|
case 0:
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1906
|
+
this.inputValidation({
|
|
1907
|
+
channelType: channel.type,
|
|
1908
|
+
channelName: channel.name
|
|
1909
|
+
});
|
|
1386
1910
|
_a.label = 1;
|
|
1387
1911
|
|
|
1388
1912
|
case 1:
|
|
@@ -1393,13 +1917,20 @@ function () {
|
|
|
1393
1917
|
, (0, _mutations.createChannel)(channel)];
|
|
1394
1918
|
|
|
1395
1919
|
case 2:
|
|
1920
|
+
result = _a.sent();
|
|
1921
|
+
|
|
1922
|
+
if (result["channel"]) {
|
|
1923
|
+
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
1924
|
+
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1396
1927
|
return [2
|
|
1397
1928
|
/*return*/
|
|
1398
|
-
,
|
|
1929
|
+
, result["channel"]];
|
|
1399
1930
|
|
|
1400
1931
|
case 3:
|
|
1401
|
-
|
|
1402
|
-
throw
|
|
1932
|
+
e_23 = _a.sent();
|
|
1933
|
+
throw e_23;
|
|
1403
1934
|
|
|
1404
1935
|
case 4:
|
|
1405
1936
|
return [2
|
|
@@ -1409,17 +1940,27 @@ function () {
|
|
|
1409
1940
|
});
|
|
1410
1941
|
});
|
|
1411
1942
|
};
|
|
1943
|
+
/**
|
|
1944
|
+
* Update channel options.
|
|
1945
|
+
*
|
|
1946
|
+
* @async
|
|
1947
|
+
* @function updateChannel
|
|
1948
|
+
* @param {string} channelId - An id of the channel.
|
|
1949
|
+
* @param {ChannelInput} channel - New options of the channel.
|
|
1950
|
+
* @returns {Promise<any>} The data of the updated channel.
|
|
1951
|
+
*/
|
|
1952
|
+
|
|
1412
1953
|
|
|
1413
1954
|
NCloudChat.prototype.updateChannel = function (channelId, channel) {
|
|
1414
1955
|
return __awaiter(this, void 0, void 0, function () {
|
|
1415
|
-
var
|
|
1956
|
+
var result, e_24;
|
|
1416
1957
|
return __generator(this, function (_a) {
|
|
1417
1958
|
switch (_a.label) {
|
|
1418
1959
|
case 0:
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1960
|
+
this.inputValidation({
|
|
1961
|
+
channelId: channelId
|
|
1962
|
+
});
|
|
1963
|
+
if (!channel.name) throw Error("You need at least a channel name or a type.");
|
|
1423
1964
|
_a.label = 1;
|
|
1424
1965
|
|
|
1425
1966
|
case 1:
|
|
@@ -1430,13 +1971,20 @@ function () {
|
|
|
1430
1971
|
, (0, _mutations.updateChannel)(channelId, channel)];
|
|
1431
1972
|
|
|
1432
1973
|
case 2:
|
|
1974
|
+
result = _a.sent();
|
|
1975
|
+
|
|
1976
|
+
if (result["channel"]) {
|
|
1977
|
+
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
1978
|
+
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1433
1981
|
return [2
|
|
1434
1982
|
/*return*/
|
|
1435
|
-
,
|
|
1983
|
+
, result["channel"]];
|
|
1436
1984
|
|
|
1437
1985
|
case 3:
|
|
1438
|
-
|
|
1439
|
-
throw
|
|
1986
|
+
e_24 = _a.sent();
|
|
1987
|
+
throw e_24;
|
|
1440
1988
|
|
|
1441
1989
|
case 4:
|
|
1442
1990
|
return [2
|
|
@@ -1446,17 +1994,25 @@ function () {
|
|
|
1446
1994
|
});
|
|
1447
1995
|
});
|
|
1448
1996
|
};
|
|
1997
|
+
/**
|
|
1998
|
+
* Delete a channel.
|
|
1999
|
+
*
|
|
2000
|
+
* @async
|
|
2001
|
+
* @function deleteChannel
|
|
2002
|
+
* @param {string} channelId - An channel id.
|
|
2003
|
+
* @returns {Promise<any>}
|
|
2004
|
+
*/
|
|
2005
|
+
|
|
1449
2006
|
|
|
1450
2007
|
NCloudChat.prototype.deleteChannel = function (channelId) {
|
|
1451
2008
|
return __awaiter(this, void 0, void 0, function () {
|
|
1452
|
-
var
|
|
2009
|
+
var result, e_25;
|
|
1453
2010
|
return __generator(this, function (_a) {
|
|
1454
2011
|
switch (_a.label) {
|
|
1455
2012
|
case 0:
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
}
|
|
1459
|
-
|
|
2013
|
+
this.inputValidation({
|
|
2014
|
+
channelId: channelId
|
|
2015
|
+
});
|
|
1460
2016
|
_a.label = 1;
|
|
1461
2017
|
|
|
1462
2018
|
case 1:
|
|
@@ -1467,13 +2023,20 @@ function () {
|
|
|
1467
2023
|
, (0, _mutations.deleteChannel)(channelId)];
|
|
1468
2024
|
|
|
1469
2025
|
case 2:
|
|
2026
|
+
result = _a.sent();
|
|
2027
|
+
|
|
2028
|
+
if (result["channel"]) {
|
|
2029
|
+
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
2030
|
+
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
2031
|
+
}
|
|
2032
|
+
|
|
1470
2033
|
return [2
|
|
1471
2034
|
/*return*/
|
|
1472
|
-
,
|
|
2035
|
+
, result["channel"]];
|
|
1473
2036
|
|
|
1474
2037
|
case 3:
|
|
1475
|
-
|
|
1476
|
-
throw
|
|
2038
|
+
e_25 = _a.sent();
|
|
2039
|
+
throw e_25;
|
|
1477
2040
|
|
|
1478
2041
|
case 4:
|
|
1479
2042
|
return [2
|
|
@@ -1483,6 +2046,17 @@ function () {
|
|
|
1483
2046
|
});
|
|
1484
2047
|
});
|
|
1485
2048
|
};
|
|
2049
|
+
/**
|
|
2050
|
+
* Update a subscription information, such as marking message read.
|
|
2051
|
+
*
|
|
2052
|
+
* @async
|
|
2053
|
+
* @function markRead
|
|
2054
|
+
* @param {string} channelId - The id of a channel.
|
|
2055
|
+
* @param {MarkInput} mark
|
|
2056
|
+
* @param {string} option
|
|
2057
|
+
* @returns {Promise<any>}
|
|
2058
|
+
*/
|
|
2059
|
+
|
|
1486
2060
|
|
|
1487
2061
|
NCloudChat.prototype.markRead = function (channelId, mark, option) {
|
|
1488
2062
|
if (option === void 0) {
|
|
@@ -1490,14 +2064,16 @@ function () {
|
|
|
1490
2064
|
}
|
|
1491
2065
|
|
|
1492
2066
|
return __awaiter(this, void 0, void 0, function () {
|
|
1493
|
-
var
|
|
2067
|
+
var result, e_26;
|
|
1494
2068
|
return __generator(this, function (_a) {
|
|
1495
2069
|
switch (_a.label) {
|
|
1496
2070
|
case 0:
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
2071
|
+
this.inputValidation({
|
|
2072
|
+
channelId: channelId,
|
|
2073
|
+
userId: mark.userId,
|
|
2074
|
+
messageId: mark.messageId,
|
|
2075
|
+
sortId: mark.sortId
|
|
2076
|
+
});
|
|
1501
2077
|
_a.label = 1;
|
|
1502
2078
|
|
|
1503
2079
|
case 1:
|
|
@@ -1508,13 +2084,14 @@ function () {
|
|
|
1508
2084
|
, (0, _mutations.updateSubscription)(channelId, mark, (0, _stringify["default"])(option))];
|
|
1509
2085
|
|
|
1510
2086
|
case 2:
|
|
2087
|
+
result = _a.sent();
|
|
1511
2088
|
return [2
|
|
1512
2089
|
/*return*/
|
|
1513
|
-
,
|
|
2090
|
+
, result["subscription"]];
|
|
1514
2091
|
|
|
1515
2092
|
case 3:
|
|
1516
|
-
|
|
1517
|
-
throw
|
|
2093
|
+
e_26 = _a.sent();
|
|
2094
|
+
throw e_26;
|
|
1518
2095
|
|
|
1519
2096
|
case 4:
|
|
1520
2097
|
return [2
|
|
@@ -1524,37 +2101,52 @@ function () {
|
|
|
1524
2101
|
});
|
|
1525
2102
|
});
|
|
1526
2103
|
};
|
|
1527
|
-
|
|
1528
|
-
|
|
2104
|
+
/**
|
|
2105
|
+
* Add members to the private channel.
|
|
2106
|
+
*
|
|
2107
|
+
* @async
|
|
2108
|
+
* @function addUsers
|
|
2109
|
+
* @param {string} channelId - An private channel id.
|
|
2110
|
+
* @param {string[]} userIds - An array of member ids to be added.
|
|
2111
|
+
* @param {any} options
|
|
2112
|
+
* @returns {Promise<any>}
|
|
2113
|
+
*/
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
NCloudChat.prototype.addUsers = function (channelId, userIds, options) {
|
|
1529
2117
|
return __awaiter(this, void 0, void 0, function () {
|
|
1530
|
-
var
|
|
2118
|
+
var result, e_27;
|
|
1531
2119
|
return __generator(this, function (_a) {
|
|
1532
2120
|
switch (_a.label) {
|
|
1533
2121
|
case 0:
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
2122
|
+
this.inputValidation({
|
|
2123
|
+
channelId: channelId,
|
|
2124
|
+
userIds: userIds
|
|
2125
|
+
});
|
|
1538
2126
|
_a.label = 1;
|
|
1539
2127
|
|
|
1540
2128
|
case 1:
|
|
1541
2129
|
_a.trys.push([1, 3,, 4]);
|
|
1542
2130
|
|
|
1543
|
-
input = {
|
|
1544
|
-
members: memberIds
|
|
1545
|
-
};
|
|
1546
2131
|
return [4
|
|
1547
2132
|
/*yield*/
|
|
1548
|
-
, (0, _mutations.addChannelMembers)(channelId,
|
|
2133
|
+
, (0, _mutations.addChannelMembers)(channelId, userIds, options)];
|
|
1549
2134
|
|
|
1550
2135
|
case 2:
|
|
2136
|
+
result = _a.sent();
|
|
2137
|
+
|
|
2138
|
+
if (result["channel"]) {
|
|
2139
|
+
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
2140
|
+
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
2141
|
+
}
|
|
2142
|
+
|
|
1551
2143
|
return [2
|
|
1552
2144
|
/*return*/
|
|
1553
|
-
,
|
|
2145
|
+
, result["channel"]];
|
|
1554
2146
|
|
|
1555
2147
|
case 3:
|
|
1556
|
-
|
|
1557
|
-
throw
|
|
2148
|
+
e_27 = _a.sent();
|
|
2149
|
+
throw e_27;
|
|
1558
2150
|
|
|
1559
2151
|
case 4:
|
|
1560
2152
|
return [2
|
|
@@ -1564,17 +2156,28 @@ function () {
|
|
|
1564
2156
|
});
|
|
1565
2157
|
});
|
|
1566
2158
|
};
|
|
1567
|
-
|
|
1568
|
-
|
|
2159
|
+
/**
|
|
2160
|
+
* Remove members from the private channel.
|
|
2161
|
+
*
|
|
2162
|
+
* @async
|
|
2163
|
+
* @function removeUsers
|
|
2164
|
+
* @param {string} channelId - An private channel id.
|
|
2165
|
+
* @param {string[]} userIds - An array of the member ids to be deleted.
|
|
2166
|
+
* @param {any} options
|
|
2167
|
+
* @returns {Promise<any>}
|
|
2168
|
+
*/
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
NCloudChat.prototype.removeUsers = function (channelId, userIds, options) {
|
|
1569
2172
|
return __awaiter(this, void 0, void 0, function () {
|
|
1570
|
-
var
|
|
2173
|
+
var result, e_28;
|
|
1571
2174
|
return __generator(this, function (_a) {
|
|
1572
2175
|
switch (_a.label) {
|
|
1573
2176
|
case 0:
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
2177
|
+
this.inputValidation({
|
|
2178
|
+
channelId: channelId,
|
|
2179
|
+
userIds: userIds
|
|
2180
|
+
});
|
|
1578
2181
|
_a.label = 1;
|
|
1579
2182
|
|
|
1580
2183
|
case 1:
|
|
@@ -1582,16 +2185,23 @@ function () {
|
|
|
1582
2185
|
|
|
1583
2186
|
return [4
|
|
1584
2187
|
/*yield*/
|
|
1585
|
-
, (0, _mutations.removeChannelMembers)(channelId,
|
|
2188
|
+
, (0, _mutations.removeChannelMembers)(channelId, userIds)];
|
|
1586
2189
|
|
|
1587
2190
|
case 2:
|
|
2191
|
+
result = _a.sent();
|
|
2192
|
+
|
|
2193
|
+
if (result["channel"]) {
|
|
2194
|
+
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
2195
|
+
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
2196
|
+
}
|
|
2197
|
+
|
|
1588
2198
|
return [2
|
|
1589
2199
|
/*return*/
|
|
1590
|
-
,
|
|
2200
|
+
, result["channel"]];
|
|
1591
2201
|
|
|
1592
2202
|
case 3:
|
|
1593
|
-
|
|
1594
|
-
throw
|
|
2203
|
+
e_28 = _a.sent();
|
|
2204
|
+
throw e_28;
|
|
1595
2205
|
|
|
1596
2206
|
case 4:
|
|
1597
2207
|
return [2
|
|
@@ -1601,6 +2211,16 @@ function () {
|
|
|
1601
2211
|
});
|
|
1602
2212
|
});
|
|
1603
2213
|
};
|
|
2214
|
+
/**
|
|
2215
|
+
* Emit "start typing" to a conneted socket.
|
|
2216
|
+
*
|
|
2217
|
+
* @async
|
|
2218
|
+
* @function startTyping
|
|
2219
|
+
* @param {string} channelId - The id of a channel that the typing is happening.
|
|
2220
|
+
* @param {string} threadId - The id of a thread that the typing is happening.
|
|
2221
|
+
* @returns {Promise<any>}
|
|
2222
|
+
*/
|
|
2223
|
+
|
|
1604
2224
|
|
|
1605
2225
|
NCloudChat.prototype.startTyping = function (channelId, threadId) {
|
|
1606
2226
|
if (threadId === void 0) {
|
|
@@ -1610,18 +2230,21 @@ function () {
|
|
|
1610
2230
|
return __awaiter(this, void 0, void 0, function () {
|
|
1611
2231
|
var data;
|
|
1612
2232
|
return __generator(this, function (_a) {
|
|
1613
|
-
if (!this.isConnected())
|
|
1614
|
-
|
|
1615
|
-
|
|
2233
|
+
if (!this.isConnected()) throw Error("You are not connected.");
|
|
2234
|
+
this.inputValidation({
|
|
2235
|
+
channelId: channelId,
|
|
2236
|
+
threadId: threadId
|
|
2237
|
+
});
|
|
1616
2238
|
|
|
1617
2239
|
try {
|
|
1618
2240
|
data = {
|
|
1619
2241
|
channelId: channelId,
|
|
1620
2242
|
threadId: threadId
|
|
1621
2243
|
};
|
|
2244
|
+
this.socket.emit("start typing", data);
|
|
1622
2245
|
return [2
|
|
1623
2246
|
/*return*/
|
|
1624
|
-
,
|
|
2247
|
+
, data];
|
|
1625
2248
|
} catch (e) {
|
|
1626
2249
|
throw e;
|
|
1627
2250
|
}
|
|
@@ -1632,6 +2255,16 @@ function () {
|
|
|
1632
2255
|
});
|
|
1633
2256
|
});
|
|
1634
2257
|
};
|
|
2258
|
+
/**
|
|
2259
|
+
* Emit "stop typing" to a connected socket.
|
|
2260
|
+
*
|
|
2261
|
+
* @async
|
|
2262
|
+
* @function
|
|
2263
|
+
* @param {string} channelId - The id of a channel that the typing is stopped.
|
|
2264
|
+
* @param {string} threadId - The id of a thread that the typing is stopped.
|
|
2265
|
+
* @returns {Promise<any>}
|
|
2266
|
+
*/
|
|
2267
|
+
|
|
1635
2268
|
|
|
1636
2269
|
NCloudChat.prototype.stopTyping = function (channelId, threadId) {
|
|
1637
2270
|
if (threadId === void 0) {
|
|
@@ -1641,18 +2274,21 @@ function () {
|
|
|
1641
2274
|
return __awaiter(this, void 0, void 0, function () {
|
|
1642
2275
|
var data;
|
|
1643
2276
|
return __generator(this, function (_a) {
|
|
1644
|
-
if (!this.isConnected())
|
|
1645
|
-
|
|
1646
|
-
|
|
2277
|
+
if (!this.isConnected()) throw Error("You are not connected.");
|
|
2278
|
+
this.inputValidation({
|
|
2279
|
+
channelId: channelId,
|
|
2280
|
+
threadId: threadId
|
|
2281
|
+
});
|
|
1647
2282
|
|
|
1648
2283
|
try {
|
|
1649
2284
|
data = {
|
|
1650
2285
|
channelId: channelId,
|
|
1651
2286
|
threadId: threadId
|
|
1652
2287
|
};
|
|
2288
|
+
this.socket.emit("stop typing", data);
|
|
1653
2289
|
return [2
|
|
1654
2290
|
/*return*/
|
|
1655
|
-
,
|
|
2291
|
+
, data];
|
|
1656
2292
|
} catch (e) {
|
|
1657
2293
|
throw e;
|
|
1658
2294
|
}
|
|
@@ -1663,6 +2299,17 @@ function () {
|
|
|
1663
2299
|
});
|
|
1664
2300
|
});
|
|
1665
2301
|
};
|
|
2302
|
+
/**
|
|
2303
|
+
* Ban a member from a channel.
|
|
2304
|
+
*
|
|
2305
|
+
* @async
|
|
2306
|
+
* @function banUser
|
|
2307
|
+
* @param {string} channelId - The id of a channel.
|
|
2308
|
+
* @param {string} memberId - The id of a member.
|
|
2309
|
+
* @param {any} options
|
|
2310
|
+
* @returns {Promise<any>}
|
|
2311
|
+
*/
|
|
2312
|
+
|
|
1666
2313
|
|
|
1667
2314
|
NCloudChat.prototype.banUser = function (channelId, memberId, options) {
|
|
1668
2315
|
if (options === void 0) {
|
|
@@ -1670,14 +2317,14 @@ function () {
|
|
|
1670
2317
|
}
|
|
1671
2318
|
|
|
1672
2319
|
return __awaiter(this, void 0, void 0, function () {
|
|
1673
|
-
var
|
|
2320
|
+
var memberBlock, e_29;
|
|
1674
2321
|
return __generator(this, function (_a) {
|
|
1675
2322
|
switch (_a.label) {
|
|
1676
2323
|
case 0:
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
2324
|
+
this.inputValidation({
|
|
2325
|
+
channelId: channelId,
|
|
2326
|
+
memberId: memberId
|
|
2327
|
+
});
|
|
1681
2328
|
_a.label = 1;
|
|
1682
2329
|
|
|
1683
2330
|
case 1:
|
|
@@ -1688,13 +2335,15 @@ function () {
|
|
|
1688
2335
|
, (0, _mutations.createMemberBlock)(channelId, memberId, (0, _stringify["default"])(options))];
|
|
1689
2336
|
|
|
1690
2337
|
case 2:
|
|
2338
|
+
memberBlock = _a.sent();
|
|
2339
|
+
if (memberBlock["memberBlock"]) memberBlock["memberBlock"]["id"] = this.ObjectId(memberBlock["memberBlock"]["id"]);
|
|
1691
2340
|
return [2
|
|
1692
2341
|
/*return*/
|
|
1693
|
-
,
|
|
2342
|
+
, memberBlock["memberBlock"]];
|
|
1694
2343
|
|
|
1695
2344
|
case 3:
|
|
1696
|
-
|
|
1697
|
-
throw
|
|
2345
|
+
e_29 = _a.sent();
|
|
2346
|
+
throw e_29;
|
|
1698
2347
|
|
|
1699
2348
|
case 4:
|
|
1700
2349
|
return [2
|
|
@@ -1704,17 +2353,143 @@ function () {
|
|
|
1704
2353
|
});
|
|
1705
2354
|
});
|
|
1706
2355
|
};
|
|
2356
|
+
/**
|
|
2357
|
+
* Unban a member from a channel.
|
|
2358
|
+
*
|
|
2359
|
+
* @async
|
|
2360
|
+
* @function unbanUser
|
|
2361
|
+
* @param {string} channelId - The id of a channel.
|
|
2362
|
+
* @param {string} memberId - The id of a member.
|
|
2363
|
+
* @returns {Promise<any>}
|
|
2364
|
+
*/
|
|
2365
|
+
|
|
1707
2366
|
|
|
1708
2367
|
NCloudChat.prototype.unbanUser = function (channelId, memberId) {
|
|
1709
2368
|
return __awaiter(this, void 0, void 0, function () {
|
|
1710
|
-
var
|
|
2369
|
+
var memberBlock, e_30;
|
|
1711
2370
|
return __generator(this, function (_a) {
|
|
1712
2371
|
switch (_a.label) {
|
|
1713
2372
|
case 0:
|
|
1714
|
-
|
|
1715
|
-
|
|
2373
|
+
this.inputValidation({
|
|
2374
|
+
channelId: channelId,
|
|
2375
|
+
memberId: memberId
|
|
2376
|
+
});
|
|
2377
|
+
_a.label = 1;
|
|
2378
|
+
|
|
2379
|
+
case 1:
|
|
2380
|
+
_a.trys.push([1, 3,, 4]);
|
|
2381
|
+
|
|
2382
|
+
return [4
|
|
2383
|
+
/*yield*/
|
|
2384
|
+
, (0, _mutations.deleteMemberBlock)(channelId, memberId)];
|
|
2385
|
+
|
|
2386
|
+
case 2:
|
|
2387
|
+
memberBlock = _a.sent();
|
|
2388
|
+
if (memberBlock["memberBlock"]) memberBlock["memberBlock"]["id"] = this.ObjectId(memberBlock["memberBlock"]["id"]);
|
|
2389
|
+
return [2
|
|
2390
|
+
/*return*/
|
|
2391
|
+
, memberBlock["memberBlock"]];
|
|
2392
|
+
|
|
2393
|
+
case 3:
|
|
2394
|
+
e_30 = _a.sent();
|
|
2395
|
+
throw e_30;
|
|
2396
|
+
|
|
2397
|
+
case 4:
|
|
2398
|
+
return [2
|
|
2399
|
+
/*return*/
|
|
2400
|
+
];
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
});
|
|
2404
|
+
};
|
|
2405
|
+
/**
|
|
2406
|
+
* Get data of a single pin from the endpoint.
|
|
2407
|
+
*
|
|
2408
|
+
* @async
|
|
2409
|
+
* @function getPin
|
|
2410
|
+
* @param {string} channelId - An id of the channel.
|
|
2411
|
+
* @param {string} id - An id of the pin.
|
|
2412
|
+
* @returns {Promise<any>} The data of the pin.
|
|
2413
|
+
*/
|
|
2414
|
+
|
|
2415
|
+
|
|
2416
|
+
NCloudChat.prototype.getPin = function (channelId, id) {
|
|
2417
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2418
|
+
var result, e_31;
|
|
2419
|
+
return __generator(this, function (_a) {
|
|
2420
|
+
switch (_a.label) {
|
|
2421
|
+
case 0:
|
|
2422
|
+
this.inputValidation({
|
|
2423
|
+
channelId: channelId,
|
|
2424
|
+
pinId: id
|
|
2425
|
+
});
|
|
2426
|
+
_a.label = 1;
|
|
2427
|
+
|
|
2428
|
+
case 1:
|
|
2429
|
+
_a.trys.push([1, 3,, 4]);
|
|
2430
|
+
|
|
2431
|
+
return [4
|
|
2432
|
+
/*yield*/
|
|
2433
|
+
, (0, _queries.getPin)(channelId, id)];
|
|
2434
|
+
|
|
2435
|
+
case 2:
|
|
2436
|
+
result = _a.sent();
|
|
2437
|
+
|
|
2438
|
+
if (result) {
|
|
2439
|
+
result.id = this.ObjectId(result.id);
|
|
2440
|
+
|
|
2441
|
+
if (result["user_id"]) {
|
|
2442
|
+
result["user_id"]["id"] = this.ObjectId(result["user_id"]["id"]);
|
|
2443
|
+
}
|
|
1716
2444
|
}
|
|
1717
2445
|
|
|
2446
|
+
return [2
|
|
2447
|
+
/*return*/
|
|
2448
|
+
, result];
|
|
2449
|
+
|
|
2450
|
+
case 3:
|
|
2451
|
+
e_31 = _a.sent();
|
|
2452
|
+
throw e_31;
|
|
2453
|
+
|
|
2454
|
+
case 4:
|
|
2455
|
+
return [2
|
|
2456
|
+
/*return*/
|
|
2457
|
+
];
|
|
2458
|
+
}
|
|
2459
|
+
});
|
|
2460
|
+
});
|
|
2461
|
+
};
|
|
2462
|
+
/**
|
|
2463
|
+
* Get data of multiple pins.
|
|
2464
|
+
*
|
|
2465
|
+
* @async
|
|
2466
|
+
* @function getPins
|
|
2467
|
+
* @param {string} channelId - An id of the channel.
|
|
2468
|
+
* @param {string} filter - Field value for filter.
|
|
2469
|
+
* @param {string} sort - Field value for sorting.
|
|
2470
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
2471
|
+
* @returns {Promise<any[]>} An array of data of all channels.
|
|
2472
|
+
*/
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
NCloudChat.prototype.getPins = function (channelId, filter, sort, option) {
|
|
2476
|
+
if (sort === void 0) {
|
|
2477
|
+
sort = {};
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
if (option === void 0) {
|
|
2481
|
+
option = {};
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2485
|
+
var entries, channels, e_32;
|
|
2486
|
+
|
|
2487
|
+
var _this = this;
|
|
2488
|
+
|
|
2489
|
+
return __generator(this, function (_a) {
|
|
2490
|
+
switch (_a.label) {
|
|
2491
|
+
case 0:
|
|
2492
|
+
this.inputValidation({});
|
|
1718
2493
|
_a.label = 1;
|
|
1719
2494
|
|
|
1720
2495
|
case 1:
|
|
@@ -1722,16 +2497,140 @@ function () {
|
|
|
1722
2497
|
|
|
1723
2498
|
return [4
|
|
1724
2499
|
/*yield*/
|
|
1725
|
-
, (0,
|
|
2500
|
+
, (0, _queries.getPins)(channelId, (0, _stringify["default"])(filter), (0, _stringify["default"])(sort), (0, _stringify["default"])(option))];
|
|
1726
2501
|
|
|
1727
2502
|
case 2:
|
|
2503
|
+
entries = _a.sent();
|
|
2504
|
+
|
|
2505
|
+
if (entries["edges"]) {
|
|
2506
|
+
channels = entries["edges"].map(function (item) {
|
|
2507
|
+
var _a, _b;
|
|
2508
|
+
|
|
2509
|
+
if (item.node.user_id) item.node.user_id.id = _this.ObjectId((_b = (_a = item.node) === null || _a === void 0 ? void 0 : _a.user_id) === null || _b === void 0 ? void 0 : _b.id);
|
|
2510
|
+
return __assign(__assign({}, item.node), {
|
|
2511
|
+
id: _this.ObjectId(item.node.id)
|
|
2512
|
+
});
|
|
2513
|
+
});
|
|
2514
|
+
return [2
|
|
2515
|
+
/*return*/
|
|
2516
|
+
, channels];
|
|
2517
|
+
}
|
|
2518
|
+
|
|
1728
2519
|
return [2
|
|
1729
2520
|
/*return*/
|
|
1730
|
-
,
|
|
2521
|
+
, entries["edges"]];
|
|
1731
2522
|
|
|
1732
2523
|
case 3:
|
|
1733
|
-
|
|
1734
|
-
throw
|
|
2524
|
+
e_32 = _a.sent();
|
|
2525
|
+
throw e_32;
|
|
2526
|
+
|
|
2527
|
+
case 4:
|
|
2528
|
+
return [2
|
|
2529
|
+
/*return*/
|
|
2530
|
+
];
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
});
|
|
2534
|
+
};
|
|
2535
|
+
/**
|
|
2536
|
+
* Create a new pin.
|
|
2537
|
+
*
|
|
2538
|
+
* @async
|
|
2539
|
+
* @function createPin
|
|
2540
|
+
* @param {string} channelId - An id of the channel.
|
|
2541
|
+
* @param {PinInput} pin - Configuration options of the new pin.
|
|
2542
|
+
* @returns {Promise<any>} The data of the newly created pin.
|
|
2543
|
+
*/
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
NCloudChat.prototype.createPin = function (channelId, pin) {
|
|
2547
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2548
|
+
var result, e_33;
|
|
2549
|
+
return __generator(this, function (_a) {
|
|
2550
|
+
switch (_a.label) {
|
|
2551
|
+
case 0:
|
|
2552
|
+
this.inputValidation({
|
|
2553
|
+
channelId: channelId,
|
|
2554
|
+
pinned: pin.pinned
|
|
2555
|
+
});
|
|
2556
|
+
_a.label = 1;
|
|
2557
|
+
|
|
2558
|
+
case 1:
|
|
2559
|
+
_a.trys.push([1, 3,, 4]);
|
|
2560
|
+
|
|
2561
|
+
return [4
|
|
2562
|
+
/*yield*/
|
|
2563
|
+
, (0, _mutations.createPin)(channelId, pin)];
|
|
2564
|
+
|
|
2565
|
+
case 2:
|
|
2566
|
+
result = _a.sent();
|
|
2567
|
+
|
|
2568
|
+
if (result["pin"]) {
|
|
2569
|
+
result["pin"]["id"] = this.ObjectId(result["pin"]["id"]);
|
|
2570
|
+
result["pin"]["user_id"]["id"] = this.ObjectId(result["pin"]["user_id"]["id"]);
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
return [2
|
|
2574
|
+
/*return*/
|
|
2575
|
+
, result["pin"]];
|
|
2576
|
+
|
|
2577
|
+
case 3:
|
|
2578
|
+
e_33 = _a.sent();
|
|
2579
|
+
throw e_33;
|
|
2580
|
+
|
|
2581
|
+
case 4:
|
|
2582
|
+
return [2
|
|
2583
|
+
/*return*/
|
|
2584
|
+
];
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
});
|
|
2588
|
+
};
|
|
2589
|
+
/**
|
|
2590
|
+
* Update pin options.
|
|
2591
|
+
*
|
|
2592
|
+
* @async
|
|
2593
|
+
* @function updatePin
|
|
2594
|
+
* @param {string} channelId - An id of the channel.
|
|
2595
|
+
* @param {PinInput} pin - New options of the pin.
|
|
2596
|
+
* @returns {Promise<any>} The data of the updated pin.
|
|
2597
|
+
*/
|
|
2598
|
+
|
|
2599
|
+
|
|
2600
|
+
NCloudChat.prototype.updatePin = function (pinId, channelId, pin) {
|
|
2601
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2602
|
+
var result, e_34;
|
|
2603
|
+
return __generator(this, function (_a) {
|
|
2604
|
+
switch (_a.label) {
|
|
2605
|
+
case 0:
|
|
2606
|
+
this.inputValidation({
|
|
2607
|
+
channelId: channelId,
|
|
2608
|
+
pinned: pin.pinned
|
|
2609
|
+
});
|
|
2610
|
+
_a.label = 1;
|
|
2611
|
+
|
|
2612
|
+
case 1:
|
|
2613
|
+
_a.trys.push([1, 3,, 4]);
|
|
2614
|
+
|
|
2615
|
+
return [4
|
|
2616
|
+
/*yield*/
|
|
2617
|
+
, (0, _mutations.updatePin)(pinId, channelId, pin)];
|
|
2618
|
+
|
|
2619
|
+
case 2:
|
|
2620
|
+
result = _a.sent();
|
|
2621
|
+
|
|
2622
|
+
if (result["pin"]) {
|
|
2623
|
+
result["pin"]["id"] = this.ObjectId(result["pin"]["id"]);
|
|
2624
|
+
result["pin"]["user_id"]["id"] = this.ObjectId(result["pin"]["user_id"]["id"]);
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
return [2
|
|
2628
|
+
/*return*/
|
|
2629
|
+
, result["pin"]];
|
|
2630
|
+
|
|
2631
|
+
case 3:
|
|
2632
|
+
e_34 = _a.sent();
|
|
2633
|
+
throw e_34;
|
|
1735
2634
|
|
|
1736
2635
|
case 4:
|
|
1737
2636
|
return [2
|
|
@@ -1742,6 +2641,16 @@ function () {
|
|
|
1742
2641
|
});
|
|
1743
2642
|
};
|
|
1744
2643
|
|
|
2644
|
+
NCloudChat.prototype.getServerUrl = function () {
|
|
2645
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2646
|
+
return __generator(this, function (_a) {
|
|
2647
|
+
return [2
|
|
2648
|
+
/*return*/
|
|
2649
|
+
, _CoreManager["default"].get("SERVER_URL")];
|
|
2650
|
+
});
|
|
2651
|
+
});
|
|
2652
|
+
};
|
|
2653
|
+
|
|
1745
2654
|
return NCloudChat;
|
|
1746
2655
|
}();
|
|
1747
2656
|
|