ncloudchat 1.0.13 → 1.0.16

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.
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
-
9
- exports["default"] = void 0;
10
- var config = {
11
- // Defaults
12
- IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node,
13
- REQUEST_ATTEMPT_LIMIT: 5,
14
- REQUEST_BATCH_SIZE: 20,
15
- REQUEST_HEADERS: {},
16
- TOKEN: "",
17
- SERVER_URL: "https://ncloudchat.apigw.ntruss.com/gpapps/v1",
18
- SOCKET_URL: "https://soc.ncloudchat.ntruss.com",
19
- VERSION: 'js' + require('../package.json').version,
20
- PROJECT_ID: null
21
- };
22
- var CoreManager = {
23
- get: function get(key) {
24
- if (config.hasOwnProperty(key)) {
25
- return config[key];
26
- }
27
-
28
- throw new Error('Configuration key not found: ' + key);
29
- },
30
- set: function set(key, value) {
31
- config[key] = value;
32
- }
33
- };
34
- var _default = CoreManager;
35
- exports["default"] = _default;
package/lib/Dispatcher.js DELETED
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
-
9
- exports["default"] = void 0;
10
-
11
- require("core-js/modules/es6.array.for-each");
12
-
13
- require("core-js/modules/es6.array.index-of");
14
-
15
- require("core-js/modules/es7.array.includes");
16
-
17
- require("core-js/modules/es6.string.includes");
18
-
19
- var DispatcherEvent =
20
- /** @class */
21
- function () {
22
- function DispatcherEvent() {
23
- this.callbacks = [];
24
- }
25
-
26
- DispatcherEvent.prototype.getCallbacks = function () {
27
- return this.callbacks;
28
- };
29
-
30
- DispatcherEvent.prototype.register = function (cb) {
31
- if (!this.callbacks.includes(cb)) {
32
- this.callbacks.push(cb);
33
- }
34
- };
35
-
36
- DispatcherEvent.prototype.unregister = function (cb) {
37
- var index = this.callbacks.indexOf(cb);
38
-
39
- if (index > -1) {
40
- this.callbacks.splice(index, 1);
41
- }
42
- };
43
-
44
- DispatcherEvent.prototype.execute = function (param1, param2, param3, param4, param5, param6) {
45
- if (this.callbacks.length > 0) {
46
- this.callbacks.slice(0).forEach(function (callback) {
47
- if (!param2) callback(param1);else if (!param3) callback(param1, param2);else if (!param4) callback(param1, param2, param3);else if (!param5) callback(param1, param2, param3, param4);else if (!param6) callback(param1, param2, param3, param4, param5);else callback(param1, param2, param3, param4, param5, param6);
48
- });
49
- }
50
- };
51
-
52
- return DispatcherEvent;
53
- }();
54
-
55
- var Dispatcher =
56
- /** @class */
57
- function () {
58
- function Dispatcher() {
59
- this.eventProvider = {};
60
- }
61
-
62
- Dispatcher.prototype.getProvider = function () {
63
- return this.eventProvider;
64
- };
65
-
66
- Dispatcher.prototype.dispatch = function (name, param1, param2, param3, param4, param5, param6) {
67
- var event = this.eventProvider[name];
68
-
69
- if (event) {
70
- event.execute(param1, param2, param3, param4, param5, param6);
71
- }
72
- };
73
-
74
- Dispatcher.prototype.on = function (name, callback) {
75
- var event = this.eventProvider[name];
76
-
77
- if (!event) {
78
- event = new DispatcherEvent();
79
- this.eventProvider[name] = event;
80
- }
81
-
82
- event.register(callback);
83
- };
84
-
85
- Dispatcher.prototype.off = function (name, callback) {
86
- var event = this.eventProvider[name];
87
-
88
- if (event) {
89
- event.unregister(callback);
90
-
91
- if (event.getCallbacks().length === 0) {
92
- delete this.eventProvider[name];
93
- }
94
- }
95
- };
96
-
97
- Dispatcher.prototype.offall = function (name) {
98
- var event = this.eventProvider[name];
99
-
100
- if (event) {
101
- delete this.eventProvider[name];
102
- }
103
- };
104
-
105
- return Dispatcher;
106
- }();
107
-
108
- var _default = Dispatcher;
109
- exports["default"] = _default;
package/lib/Type.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
-
9
- exports.MessageType = exports.ChannelType = void 0;
10
- var ChannelType;
11
- exports.ChannelType = ChannelType;
12
-
13
- (function (ChannelType) {
14
- ChannelType["PRIVATE"] = "PRIVATE";
15
- ChannelType["PUBLIC"] = "PUBLIC";
16
- })(ChannelType || (exports.ChannelType = ChannelType = {}));
17
-
18
- var MessageType;
19
- exports.MessageType = MessageType;
20
-
21
- (function (MessageType) {
22
- MessageType["text"] = "text";
23
- MessageType["photo"] = "photo";
24
- MessageType["file"] = "file";
25
- })(MessageType || (exports.MessageType = MessageType = {}));
package/lib/Util.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
-
9
- exports.ObjectId = void 0;
10
-
11
- require("core-js/modules/es6.regexp.split");
12
-
13
- var ObjectId = function ObjectId(id) {
14
- if (!id) return "";
15
- return atob(id).split(":")[1];
16
- };
17
-
18
- exports.ObjectId = ObjectId;
package/lib/logger.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
-
9
- exports.info = exports.error = exports.debug = void 0;
10
-
11
- var debug = function debug(value) {
12
- return console.log(value);
13
- };
14
-
15
- exports.debug = debug;
16
-
17
- var error = function error(value) {
18
- return console.error(value);
19
- };
20
-
21
- exports.error = error;
22
-
23
- var info = function info(value) {
24
- return console.log(value);
25
- };
26
-
27
- exports.info = info;
@@ -1,421 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
-
5
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
6
-
7
- _Object$defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
-
11
- exports.removeChannelMembers = exports.addChannelMembers = exports.deleteChannel = exports.updateChannel = exports.createChannel = void 0;
12
-
13
- require("core-js/modules/es6.function.name");
14
-
15
- var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
16
-
17
- var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
18
-
19
- var _symbol = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol"));
20
-
21
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
22
-
23
- var _CoreManager = _interopRequireDefault(require("../CoreManager"));
24
-
25
- var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) {
27
- return value instanceof P ? value : new P(function (resolve) {
28
- resolve(value);
29
- });
30
- }
31
-
32
- return new (P || (P = _promise["default"]))(function (resolve, reject) {
33
- function fulfilled(value) {
34
- try {
35
- step(generator.next(value));
36
- } catch (e) {
37
- reject(e);
38
- }
39
- }
40
-
41
- function rejected(value) {
42
- try {
43
- step(generator["throw"](value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- }
48
-
49
- function step(result) {
50
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
51
- }
52
-
53
- step((generator = generator.apply(thisArg, _arguments || [])).next());
54
- });
55
- };
56
-
57
- var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
58
- var _ = {
59
- label: 0,
60
- sent: function sent() {
61
- if (t[0] & 1) throw t[1];
62
- return t[1];
63
- },
64
- trys: [],
65
- ops: []
66
- },
67
- f,
68
- y,
69
- t,
70
- g;
71
- return g = {
72
- next: verb(0),
73
- "throw": verb(1),
74
- "return": verb(2)
75
- }, typeof _symbol["default"] === "function" && (g[_iterator["default"]] = function () {
76
- return this;
77
- }), g;
78
-
79
- function verb(n) {
80
- return function (v) {
81
- return step([n, v]);
82
- };
83
- }
84
-
85
- function step(op) {
86
- if (f) throw new TypeError("Generator is already executing.");
87
-
88
- while (_) {
89
- try {
90
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
91
- if (y = 0, t) op = [op[0] & 2, t.value];
92
-
93
- switch (op[0]) {
94
- case 0:
95
- case 1:
96
- t = op;
97
- break;
98
-
99
- case 4:
100
- _.label++;
101
- return {
102
- value: op[1],
103
- done: false
104
- };
105
-
106
- case 5:
107
- _.label++;
108
- y = op[1];
109
- op = [0];
110
- continue;
111
-
112
- case 7:
113
- op = _.ops.pop();
114
-
115
- _.trys.pop();
116
-
117
- continue;
118
-
119
- default:
120
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
121
- _ = 0;
122
- continue;
123
- }
124
-
125
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
126
- _.label = op[1];
127
- break;
128
- }
129
-
130
- if (op[0] === 6 && _.label < t[1]) {
131
- _.label = t[1];
132
- t = op;
133
- break;
134
- }
135
-
136
- if (t && _.label < t[2]) {
137
- _.label = t[2];
138
-
139
- _.ops.push(op);
140
-
141
- break;
142
- }
143
-
144
- if (t[2]) _.ops.pop();
145
-
146
- _.trys.pop();
147
-
148
- continue;
149
- }
150
-
151
- op = body.call(thisArg, _);
152
- } catch (e) {
153
- op = [6, e];
154
- y = 0;
155
- } finally {
156
- f = t = 0;
157
- }
158
- }
159
-
160
- if (op[0] & 5) throw op[1];
161
- return {
162
- value: op[0] ? op[1] : void 0,
163
- done: true
164
- };
165
- }
166
- };
167
-
168
- var createChannel = function createChannel(channel) {
169
- return __awaiter(void 0, void 0, void 0, function () {
170
- var token, projectId, endpoint, query;
171
- return __generator(this, function (_a) {
172
- switch (_a.label) {
173
- case 0:
174
- token = _CoreManager["default"].get("TOKEN");
175
- projectId = _CoreManager["default"].get("PROJECT_ID");
176
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
177
- if (!channel.members) channel.members = [];
178
- query = "\n mutation (\n $id: String,\n $projectId: String!, \n $name: String!, \n $type: String!,\n $uniqueId: String,\n $translation: Boolean,\n $push: Boolean,\n $mutes: Boolean,\n $linkUrl: String,\n $imageUrl: String,\n $members: [String]\n ) {\n createChannel(\n input: { \n id: $id,\n projectId: $projectId, \n name: $name, \n type: $type,\n uniqueId: $uniqueId,\n translation:$translation,\n push:$push,\n mutes: $mutes,\n linkUrl:$linkUrl,\n imageUrl:$imageUrl\n members: $members,\n }\n ) {\n channel {\n id\n project_id\n name\n user_id { \n id\n name\n nickname\n profile\n device_type\n language\n }\n last_message {\n message_id\n sort_id\n project_id\n channel_id\n message_type\n mentions\n mentions_everyone\n has\n sender {\n id\n name\n profile\n }\n admin {\n id\n name\n profile\n }\n content\n }\n unique_id\n type\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n } \n ";
179
- return [4
180
- /*yield*/
181
- , fetch(endpoint, {
182
- method: 'POST',
183
- headers: {
184
- 'Authorization': 'Bearer ' + token,
185
- 'X-PROJECT-ID': projectId,
186
- 'Content-Type': 'application/json',
187
- 'Accept': 'application/json'
188
- },
189
- body: (0, _stringify["default"])({
190
- query: query,
191
- variables: {
192
- projectId: projectId,
193
- name: channel.name,
194
- type: channel.type,
195
- uniqueId: channel.uniqueId,
196
- translation: channel.translation,
197
- push: channel.push,
198
- mutes: channel.mutes,
199
- link_url: channel.linkUrl,
200
- image_url: channel.imageUrl,
201
- disabled: channel.disabled,
202
- members: channel.members
203
- }
204
- })
205
- }).then(function (res) {
206
- return res.json();
207
- }).then(function (data) {
208
- if (data.errors) throw data.errors[0];
209
- if (data.code) throw data;
210
- return data.data.createChannel.channel;
211
- })];
212
-
213
- case 1:
214
- return [2
215
- /*return*/
216
- , _a.sent()];
217
- }
218
- });
219
- });
220
- };
221
-
222
- exports.createChannel = createChannel;
223
-
224
- var updateChannel = function updateChannel(channelId, channel) {
225
- return __awaiter(void 0, void 0, void 0, function () {
226
- var token, projectId, endpoint, query;
227
- return __generator(this, function (_a) {
228
- switch (_a.label) {
229
- case 0:
230
- token = _CoreManager["default"].get("TOKEN");
231
- projectId = _CoreManager["default"].get("PROJECT_ID");
232
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
233
- if (!channel.members) channel.members = [];
234
- query = "\n mutation (\n $projectId: String!, \n $name: String!, \n $type: String!,\n $uniqueId: String,\n $translation: Boolean,\n $push: Boolean,\n $linkUrl: String,\n $imageUrl: String,\n $id: ID!,\n ) {\n updateChannel(\n input: { \n projectId: $projectId, \n name: $name, \n type: $type,\n id: $id,\n members: $members,\n uniqueId: $uniqueId,\n translation:$translation,\n push:$push,\n linkUrl:$linkUrl,\n imageUrl:$imageUrl\n }\n ) {\n channel {\n id\n project_id\n name\n user_id { \n id\n name\n nickname\n profile\n device_type\n language\n }\n last_message {\n message_id\n sort_id\n project_id\n channel_id\n message_type\n mentions\n mentions_everyone\n has\n sender {\n id\n name\n profile\n }\n admin {\n id\n name\n profile\n }\n content\n }\n unique_id\n type\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n } \n ";
235
- return [4
236
- /*yield*/
237
- , fetch(endpoint, {
238
- method: 'POST',
239
- headers: {
240
- 'Authorization': 'Bearer ' + token,
241
- 'X-PROJECT-ID': projectId,
242
- 'Content-Type': 'application/json',
243
- 'Accept': 'application/json'
244
- },
245
- body: (0, _stringify["default"])({
246
- query: query,
247
- variables: {
248
- projectId: projectId,
249
- id: channelId,
250
- name: channel.name,
251
- type: channel.type,
252
- uniqueId: channel.uniqueId,
253
- translation: channel.translation,
254
- push: channel.push,
255
- mutes: channel.mutes,
256
- link_url: channel.linkUrl,
257
- image_url: channel.imageUrl,
258
- disabled: channel.disabled,
259
- members: channel.members
260
- }
261
- })
262
- }).then(function (res) {
263
- return res.json();
264
- }).then(function (data) {
265
- if (data.errors) throw data.errors[0];
266
- if (data.code) throw data;
267
- return data.data.updateChannel.channel;
268
- })];
269
-
270
- case 1:
271
- return [2
272
- /*return*/
273
- , _a.sent()];
274
- }
275
- });
276
- });
277
- };
278
-
279
- exports.updateChannel = updateChannel;
280
-
281
- var deleteChannel = function deleteChannel(channelId) {
282
- return __awaiter(void 0, void 0, void 0, function () {
283
- var token, projectId, endpoint, query;
284
- return __generator(this, function (_a) {
285
- switch (_a.label) {
286
- case 0:
287
- token = _CoreManager["default"].get("TOKEN");
288
- projectId = _CoreManager["default"].get("PROJECT_ID");
289
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
290
- query = "\n mutation (\n $projectId: String!, \n $id: ID!\n ) {\n deleteChannel(\n input: { \n projectId: $projectId, \n id: $id,\n }\n ) {\n channel {\n id\n project_id\n name\n user_id { \n id\n name\n nickname\n profile\n device_type\n language\n }\n last_message {\n message_id\n sort_id\n project_id\n channel_id\n message_type\n mentions\n mentions_everyone\n has\n sender {\n id\n name\n profile\n }\n admin {\n id\n name\n profile\n }\n content\n }\n unique_id\n type\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n } \n ";
291
- return [4
292
- /*yield*/
293
- , fetch(endpoint, {
294
- method: 'POST',
295
- headers: {
296
- 'Authorization': 'Bearer ' + token,
297
- 'X-PROJECT-ID': projectId,
298
- 'Content-Type': 'application/json',
299
- 'Accept': 'application/json'
300
- },
301
- body: (0, _stringify["default"])({
302
- query: query,
303
- variables: {
304
- projectId: projectId,
305
- id: channelId
306
- }
307
- })
308
- }).then(function (res) {
309
- return res.json();
310
- }).then(function (data) {
311
- if (data.errors) throw data.errors[0];
312
- if (data.code) throw data;
313
- return data.data.deleteChannel.channel;
314
- })];
315
-
316
- case 1:
317
- return [2
318
- /*return*/
319
- , _a.sent()];
320
- }
321
- });
322
- });
323
- };
324
-
325
- exports.deleteChannel = deleteChannel;
326
-
327
- var addChannelMembers = function addChannelMembers(channelId, memberIds, options) {
328
- return __awaiter(void 0, void 0, void 0, function () {
329
- var token, projectId, endpoint, query;
330
- return __generator(this, function (_a) {
331
- switch (_a.label) {
332
- case 0:
333
- token = _CoreManager["default"].get("TOKEN");
334
- projectId = _CoreManager["default"].get("PROJECT_ID");
335
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
336
- query = "\n mutation ($projectId: String!, $channelId: String!, $memberIds: [String]!) {\n addChannelMembers(input: {projectId: $projectId, channelId: $channelId, memberIds:$memberIds }) {\n channel {\n id\n project_id\n name\n user_id { \n id\n name\n nickname\n profile\n device_type\n language\n }\n unique_id\n type\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n }\n ";
337
- return [4
338
- /*yield*/
339
- , fetch(endpoint, {
340
- method: 'POST',
341
- headers: {
342
- 'Authorization': 'Bearer ' + token,
343
- 'X-PROJECT-ID': projectId,
344
- 'Content-Type': 'application/json',
345
- 'Accept': 'application/json'
346
- },
347
- body: (0, _stringify["default"])({
348
- query: query,
349
- variables: {
350
- projectId: projectId,
351
- channelId: channelId,
352
- memberIds: memberIds,
353
- options: options
354
- }
355
- })
356
- }).then(function (res) {
357
- return res.json();
358
- }).then(function (data) {
359
- if (data.errors) throw data.errors[0];
360
- if (data.code) throw data;
361
- return data.data.addChannelMembers.channel;
362
- })];
363
-
364
- case 1:
365
- return [2
366
- /*return*/
367
- , _a.sent()];
368
- }
369
- });
370
- });
371
- };
372
-
373
- exports.addChannelMembers = addChannelMembers;
374
-
375
- var removeChannelMembers = function removeChannelMembers(channelId, memberIds, options) {
376
- return __awaiter(void 0, void 0, void 0, function () {
377
- var token, projectId, endpoint, query;
378
- return __generator(this, function (_a) {
379
- switch (_a.label) {
380
- case 0:
381
- token = _CoreManager["default"].get("TOKEN");
382
- projectId = _CoreManager["default"].get("PROJECT_ID");
383
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
384
- query = "\n mutation ($projectId: String!, $channelId: String!, $memberIds: [String]!) {\n removeChannelMembers(input: {projectId: $projectId, channelId: $channelId, memberIds:$memberIds }) {\n channel {\n id\n project_id\n name\n user_id { \n id\n name\n nickname\n profile\n device_type\n language\n }\n unique_id\n type\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n }\n ";
385
- return [4
386
- /*yield*/
387
- , fetch(endpoint, {
388
- method: 'POST',
389
- headers: {
390
- 'Authorization': 'Bearer ' + token,
391
- 'X-PROJECT-ID': projectId,
392
- 'Content-Type': 'application/json',
393
- 'Accept': 'application/json'
394
- },
395
- body: (0, _stringify["default"])({
396
- query: query,
397
- variables: {
398
- projectId: projectId,
399
- channelId: channelId,
400
- memberIds: memberIds,
401
- options: options
402
- }
403
- })
404
- }).then(function (res) {
405
- return res.json();
406
- }).then(function (data) {
407
- if (data.errors) throw data.errors[0];
408
- if (data.code) throw data;
409
- return data.data.removeChannelMembers.channel;
410
- })];
411
-
412
- case 1:
413
- return [2
414
- /*return*/
415
- , _a.sent()];
416
- }
417
- });
418
- });
419
- };
420
-
421
- exports.removeChannelMembers = removeChannelMembers;