ncloudchat 0.0.19-beta → 0.0.22-beta

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.
Files changed (40) hide show
  1. package/esm/CloudChat.d.ts +7 -1
  2. package/esm/CloudChat.js +172 -49
  3. package/esm/CloudChat.js.map +1 -1
  4. package/esm/Type.d.ts +0 -1
  5. package/esm/Type.js.map +1 -1
  6. package/esm/Util.d.ts +2 -0
  7. package/esm/Util.js +7 -0
  8. package/esm/Util.js.map +1 -0
  9. package/esm/mutations/channel.d.ts +1 -0
  10. package/esm/mutations/channel.js +39 -7
  11. package/esm/mutations/channel.js.map +1 -1
  12. package/esm/mutations/message.d.ts +1 -1
  13. package/esm/mutations/message.js +2 -1
  14. package/esm/mutations/message.js.map +1 -1
  15. package/esm/queries/channel.d.ts +1 -1
  16. package/esm/queries/channel.js +16 -15
  17. package/esm/queries/channel.js.map +1 -1
  18. package/esm/queries/index.d.ts +1 -0
  19. package/esm/queries/index.js +1 -0
  20. package/esm/queries/index.js.map +1 -1
  21. package/esm/queries/member.d.ts +1 -0
  22. package/esm/queries/member.js +79 -0
  23. package/esm/queries/member.js.map +1 -0
  24. package/esm/queries/message.d.ts +1 -0
  25. package/esm/queries/message.js +38 -0
  26. package/esm/queries/message.js.map +1 -1
  27. package/esm/queries/project.js.map +1 -1
  28. package/esm/queries/subscription.d.ts +1 -1
  29. package/esm/queries/subscription.js +13 -10
  30. package/esm/queries/subscription.js.map +1 -1
  31. package/lib/CloudChat.js +253 -52
  32. package/lib/Util.js +18 -0
  33. package/lib/mutations/channel.js +53 -9
  34. package/lib/mutations/message.js +2 -1
  35. package/lib/queries/channel.js +20 -19
  36. package/lib/queries/index.js +13 -0
  37. package/lib/queries/member.js +219 -0
  38. package/lib/queries/message.js +52 -2
  39. package/lib/queries/subscription.js +16 -13
  40. package/package.json +1 -1
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
 
11
- exports.getChannel = exports.getChannels = void 0;
11
+ exports.getChannels = exports.getChannel = void 0;
12
12
 
13
13
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
14
14
 
@@ -20,6 +20,8 @@ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/pr
20
20
 
21
21
  var _CoreManager = _interopRequireDefault(require("../CoreManager"));
22
22
 
23
+ var _Util = require("../Util");
24
+
23
25
  var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
24
26
  function adopt(value) {
25
27
  return value instanceof P ? value : new P(function (resolve) {
@@ -163,7 +165,7 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
163
165
  }
164
166
  };
165
167
 
166
- var getChannels = function getChannels(filter, sort, option) {
168
+ var getChannel = function getChannel(id) {
167
169
  return __awaiter(void 0, void 0, void 0, function () {
168
170
  var token, projectId, endpoint, query;
169
171
  return __generator(this, function (_a) {
@@ -178,7 +180,7 @@ var getChannels = function getChannels(filter, sort, option) {
178
180
  /*return*/
179
181
  , null];
180
182
  endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
181
- query = "\n query channels ($projectId: String!, $filter: String!, $sort: String, $option:String) {\n channels(projectId: $projectId, filter:$filter, sort:$sort, option:$option) {\n totalCount\n edges {\n node {\n id\n project_id\n name\n user_id\n unique_id\n is_private\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n }\n }\n ";
183
+ query = "\n query channel ($projectId: String!, $id: String!) {\n channel(projectId: $projectId, id:$id) {\n id\n project_id\n name\n user_id\n unique_id\n is_private\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n ";
182
184
  return [4
183
185
  /*yield*/
184
186
  , fetch(endpoint, {
@@ -192,19 +194,18 @@ var getChannels = function getChannels(filter, sort, option) {
192
194
  query: query,
193
195
  variables: {
194
196
  projectId: projectId,
195
- filter: filter,
196
- sort: sort,
197
- option: option
197
+ id: id
198
198
  }
199
199
  })
200
200
  }).then(function (res) {
201
201
  return res.json();
202
202
  }).then(function (data) {
203
- if (data.data.channels) {
204
- return data.data.channels.edges;
203
+ if (data.data.channel) {
204
+ data.data.channel.id = (0, _Util.ObjectId)(data.data.channel.id);
205
+ return data.data.channel;
205
206
  }
206
207
 
207
- return [];
208
+ return false;
208
209
  })];
209
210
 
210
211
  case 1:
@@ -216,9 +217,9 @@ var getChannels = function getChannels(filter, sort, option) {
216
217
  });
217
218
  };
218
219
 
219
- exports.getChannels = getChannels;
220
+ exports.getChannel = getChannel;
220
221
 
221
- var getChannel = function getChannel(id) {
222
+ var getChannels = function getChannels(filter, sort, option) {
222
223
  return __awaiter(void 0, void 0, void 0, function () {
223
224
  var token, projectId, endpoint, query;
224
225
  return __generator(this, function (_a) {
@@ -233,7 +234,7 @@ var getChannel = function getChannel(id) {
233
234
  /*return*/
234
235
  , null];
235
236
  endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
236
- query = "\n query channel ($projectId: String!, $id: String!) {\n channel(projectId: $projectId, id:$id) {\n id\n project_id\n name\n user_id\n unique_id\n is_private\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n ";
237
+ query = "\n query channels ($projectId: String!, $filter: String!, $sort: String, $option:String) {\n channels(projectId: $projectId, filter:$filter, sort:$sort, option:$option) {\n totalCount\n edges {\n node {\n id\n project_id\n name\n user_id\n unique_id\n is_private\n translation\n members\n push\n link_url\n image_url \n created_at\n updated_at\n }\n }\n }\n }\n ";
237
238
  return [4
238
239
  /*yield*/
239
240
  , fetch(endpoint, {
@@ -247,19 +248,19 @@ var getChannel = function getChannel(id) {
247
248
  query: query,
248
249
  variables: {
249
250
  projectId: projectId,
250
- id: id
251
+ filter: filter,
252
+ sort: sort,
253
+ option: option
251
254
  }
252
255
  })
253
256
  }).then(function (res) {
254
257
  return res.json();
255
258
  }).then(function (data) {
256
- console.log(data.data);
257
-
258
- if (data.data.channel) {
259
- return data.data.channel;
259
+ if (data.data.channels) {
260
+ return data.data.channels.edges;
260
261
  }
261
262
 
262
- return false;
263
+ return [];
263
264
  })];
264
265
 
265
266
  case 1:
@@ -271,4 +272,4 @@ var getChannel = function getChannel(id) {
271
272
  });
272
273
  };
273
274
 
274
- exports.getChannel = getChannel;
275
+ exports.getChannels = getChannels;
@@ -75,6 +75,19 @@ _Object$keys(_friend).forEach(function (key) {
75
75
  });
76
76
  });
77
77
 
78
+ var _member = require("./member");
79
+
80
+ _Object$keys(_member).forEach(function (key) {
81
+ if (key === "default" || key === "__esModule") return;
82
+
83
+ _Object$defineProperty(exports, key, {
84
+ enumerable: true,
85
+ get: function get() {
86
+ return _member[key];
87
+ }
88
+ });
89
+ });
90
+
78
91
  var _messageread = require("./messageread");
79
92
 
80
93
  _Object$keys(_messageread).forEach(function (key) {
@@ -0,0 +1,219 @@
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.getMembers = void 0;
12
+
13
+ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
14
+
15
+ var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
16
+
17
+ var _symbol = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol"));
18
+
19
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
20
+
21
+ var _CoreManager = _interopRequireDefault(require("../CoreManager"));
22
+
23
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
24
+ function adopt(value) {
25
+ return value instanceof P ? value : new P(function (resolve) {
26
+ resolve(value);
27
+ });
28
+ }
29
+
30
+ return new (P || (P = _promise["default"]))(function (resolve, reject) {
31
+ function fulfilled(value) {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ }
38
+
39
+ function rejected(value) {
40
+ try {
41
+ step(generator["throw"](value));
42
+ } catch (e) {
43
+ reject(e);
44
+ }
45
+ }
46
+
47
+ function step(result) {
48
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
49
+ }
50
+
51
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
52
+ });
53
+ };
54
+
55
+ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
56
+ var _ = {
57
+ label: 0,
58
+ sent: function sent() {
59
+ if (t[0] & 1) throw t[1];
60
+ return t[1];
61
+ },
62
+ trys: [],
63
+ ops: []
64
+ },
65
+ f,
66
+ y,
67
+ t,
68
+ g;
69
+ return g = {
70
+ next: verb(0),
71
+ "throw": verb(1),
72
+ "return": verb(2)
73
+ }, typeof _symbol["default"] === "function" && (g[_iterator["default"]] = function () {
74
+ return this;
75
+ }), g;
76
+
77
+ function verb(n) {
78
+ return function (v) {
79
+ return step([n, v]);
80
+ };
81
+ }
82
+
83
+ function step(op) {
84
+ if (f) throw new TypeError("Generator is already executing.");
85
+
86
+ while (_) {
87
+ try {
88
+ 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;
89
+ if (y = 0, t) op = [op[0] & 2, t.value];
90
+
91
+ switch (op[0]) {
92
+ case 0:
93
+ case 1:
94
+ t = op;
95
+ break;
96
+
97
+ case 4:
98
+ _.label++;
99
+ return {
100
+ value: op[1],
101
+ done: false
102
+ };
103
+
104
+ case 5:
105
+ _.label++;
106
+ y = op[1];
107
+ op = [0];
108
+ continue;
109
+
110
+ case 7:
111
+ op = _.ops.pop();
112
+
113
+ _.trys.pop();
114
+
115
+ continue;
116
+
117
+ default:
118
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
119
+ _ = 0;
120
+ continue;
121
+ }
122
+
123
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
124
+ _.label = op[1];
125
+ break;
126
+ }
127
+
128
+ if (op[0] === 6 && _.label < t[1]) {
129
+ _.label = t[1];
130
+ t = op;
131
+ break;
132
+ }
133
+
134
+ if (t && _.label < t[2]) {
135
+ _.label = t[2];
136
+
137
+ _.ops.push(op);
138
+
139
+ break;
140
+ }
141
+
142
+ if (t[2]) _.ops.pop();
143
+
144
+ _.trys.pop();
145
+
146
+ continue;
147
+ }
148
+
149
+ op = body.call(thisArg, _);
150
+ } catch (e) {
151
+ op = [6, e];
152
+ y = 0;
153
+ } finally {
154
+ f = t = 0;
155
+ }
156
+ }
157
+
158
+ if (op[0] & 5) throw op[1];
159
+ return {
160
+ value: op[0] ? op[1] : void 0,
161
+ done: true
162
+ };
163
+ }
164
+ };
165
+
166
+ var getMembers = function getMembers(filter, sort, option) {
167
+ return __awaiter(void 0, void 0, void 0, function () {
168
+ var token, projectId, endpoint, lquery;
169
+ return __generator(this, function (_a) {
170
+ switch (_a.label) {
171
+ case 0:
172
+ token = _CoreManager["default"].get('TOKEN');
173
+ if (!token) return [2
174
+ /*return*/
175
+ , null];
176
+ projectId = _CoreManager["default"].get('PROJECT_ID');
177
+ if (!projectId) return [2
178
+ /*return*/
179
+ , null];
180
+ endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
181
+ lquery = "\n query membersForQuery ($projectId: String!, $option: String!, $filter: String!, $sort: String ) {\n membersForQuery (projectId: $projectId, option:$option, filter:$filter, sort:$sort) {\n totalCount\n edges {\n node {\n id\n name\n }\n }\n }\n }\n ";
182
+ return [4
183
+ /*yield*/
184
+ , fetch(endpoint, {
185
+ method: 'POST',
186
+ headers: {
187
+ Authorization: 'Bearer ' + token,
188
+ 'Content-Type': 'application/json',
189
+ Accept: 'application/json'
190
+ },
191
+ body: (0, _stringify["default"])({
192
+ query: lquery,
193
+ variables: {
194
+ projectId: projectId,
195
+ filter: filter,
196
+ sort: sort,
197
+ option: option
198
+ }
199
+ })
200
+ }).then(function (res) {
201
+ return res.json();
202
+ }).then(function (data) {
203
+ if (data.data.membersForQuery) {
204
+ return data.data.membersForQuery.edges;
205
+ }
206
+
207
+ return [];
208
+ })];
209
+
210
+ case 1:
211
+ return [2
212
+ /*return*/
213
+ , _a.sent()];
214
+ }
215
+ });
216
+ });
217
+ };
218
+
219
+ exports.getMembers = getMembers;
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
 
11
- exports.getMessage = exports.getMessages = void 0;
11
+ exports.unreadCount = exports.getMessage = exports.getMessages = void 0;
12
12
 
13
13
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
14
14
 
@@ -264,4 +264,54 @@ var getMessage = function getMessage(channelId, messageId) {
264
264
  });
265
265
  };
266
266
 
267
- exports.getMessage = getMessage;
267
+ exports.getMessage = getMessage;
268
+
269
+ var unreadCount = function unreadCount(channelId) {
270
+ return __awaiter(void 0, void 0, void 0, function () {
271
+ var token, projectId, endpoint, queries;
272
+ return __generator(this, function (_a) {
273
+ switch (_a.label) {
274
+ case 0:
275
+ token = _CoreManager["default"].get("TOKEN");
276
+ if (!token) return [2
277
+ /*return*/
278
+ , null];
279
+ projectId = _CoreManager["default"].get("PROJECT_ID");
280
+ if (!projectId) return [2
281
+ /*return*/
282
+ , null];
283
+ endpoint = _CoreManager["default"].get("SERVER_URL") + "/graphql";
284
+ queries = "\n query mark ($projectId: String!, $channelId: String!) { \n mark (projectId: $projectId, channelId:$channelId) { \n user_id,\n message_id,\n sort_id, \n unread\n } \n }\n ";
285
+ return [4
286
+ /*yield*/
287
+ , fetch(endpoint, {
288
+ method: "POST",
289
+ headers: {
290
+ Authorization: "Bearer " + token,
291
+ "Content-Type": "application/json",
292
+ Accept: "application/json"
293
+ },
294
+ body: (0, _stringify["default"])({
295
+ query: queries,
296
+ variables: {
297
+ projectId: projectId,
298
+ channelId: channelId
299
+ }
300
+ })
301
+ }).then(function (res) {
302
+ return res.json();
303
+ }).then(function (data) {
304
+ if (!data || !data.data.mark) return false;
305
+ return data.data.mark;
306
+ })];
307
+
308
+ case 1:
309
+ return [2
310
+ /*return*/
311
+ , _a.sent()];
312
+ }
313
+ });
314
+ });
315
+ };
316
+
317
+ exports.unreadCount = unreadCount;
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
 
11
- exports.getSubscriptionByConnection = exports.getSubscriptions = void 0;
11
+ exports.getSubscriptions = exports.getSubscription = void 0;
12
12
 
13
13
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
14
14
 
@@ -20,6 +20,8 @@ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/pr
20
20
 
21
21
  var _CoreManager = _interopRequireDefault(require("../CoreManager"));
22
22
 
23
+ var _Util = require("../Util");
24
+
23
25
  var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
24
26
  function adopt(value) {
25
27
  return value instanceof P ? value : new P(function (resolve) {
@@ -163,7 +165,7 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
163
165
  }
164
166
  };
165
167
 
166
- var getSubscriptions = function getSubscriptions(filter, sort, option) {
168
+ var getSubscription = function getSubscription(channelId, id) {
167
169
  return __awaiter(void 0, void 0, void 0, function () {
168
170
  var token, projectId, endpoint, query;
169
171
  return __generator(this, function (_a) {
@@ -178,7 +180,7 @@ var getSubscriptions = function getSubscriptions(filter, sort, option) {
178
180
  /*return*/
179
181
  , null];
180
182
  endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
181
- query = "\n query subscriptions ($projectId: String!, $option: String!, $filter: String!, $sort: String ) {\n subscriptions (projectId: $projectId, option:$option, filter:$filter, sort:$sort) {\n totalCount\n edges {\n node {\n id\n user {\n nickname\n profile_url\n country\n }\n channel_id\n user_id\n online\n push\n created_at\n }\n }\n }\n }\n ";
183
+ query = "\n query subscription ($projectId: String!,$channelId: String!, $id: String!) {\n subscription(projectId: $projectId, channelId: $channelUd, id:$id) {\n id\n user {\n nickname\n profile_url\n country\n }\n mark {\n user_id\n message_id\n sort_id\n }\n channel_id\n user_id\n online\n push\n created_at\n }\n }\n ";
182
184
  return [4
183
185
  /*yield*/
184
186
  , fetch(endpoint, {
@@ -192,15 +194,14 @@ var getSubscriptions = function getSubscriptions(filter, sort, option) {
192
194
  query: query,
193
195
  variables: {
194
196
  projectId: projectId,
195
- option: option,
196
- filter: filter,
197
- sort: sort
197
+ channelId: channelId,
198
+ id: id
198
199
  }
199
200
  })
200
201
  }).then(function (res) {
201
202
  return res.json();
202
203
  }).then(function (data) {
203
- return data.data.subscriptions.edges;
204
+ if (data.data.subscription) data.data.subscription.id = (0, _Util.ObjectId)(data.data.subscription.id);
204
205
  })];
205
206
 
206
207
  case 1:
@@ -212,9 +213,9 @@ var getSubscriptions = function getSubscriptions(filter, sort, option) {
212
213
  });
213
214
  };
214
215
 
215
- exports.getSubscriptions = getSubscriptions;
216
+ exports.getSubscription = getSubscription;
216
217
 
217
- var getSubscriptionByConnection = function getSubscriptionByConnection(channelId) {
218
+ var getSubscriptions = function getSubscriptions(filter, sort, option) {
218
219
  return __awaiter(void 0, void 0, void 0, function () {
219
220
  var token, projectId, endpoint, query;
220
221
  return __generator(this, function (_a) {
@@ -229,7 +230,7 @@ var getSubscriptionByConnection = function getSubscriptionByConnection(channelId
229
230
  /*return*/
230
231
  , null];
231
232
  endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
232
- query = "\n query subscriptionsByConnection(\n $projectId: String!, \n $channelId: String!\n ) {\n subscriptionsByConnection(\n projectId: $projectId\n channelId: $channelId\n ) {\n totalCount\n edges {\n node {\n id\n project_id\n channel_id\n user_id\n notice\n member_read {\n id\n project_id\n channel_id\n member_id\n last_member_id\n last_message_id\n last_sort_id\n created_at\n updated_at\n }\n created_at\n updated_at\n }\n }\n }\n }\n ";
233
+ query = "\n query subscriptions ($projectId: String!, $option: String!, $filter: String!, $sort: String ) {\n subscriptions (projectId: $projectId, option:$option, filter:$filter, sort:$sort) {\n totalCount\n edges {\n node {\n id\n user {\n nickname\n profile_url\n country\n }\n channel_id\n user_id\n online\n push\n created_at\n }\n }\n }\n }\n ";
233
234
  return [4
234
235
  /*yield*/
235
236
  , fetch(endpoint, {
@@ -243,13 +244,15 @@ var getSubscriptionByConnection = function getSubscriptionByConnection(channelId
243
244
  query: query,
244
245
  variables: {
245
246
  projectId: projectId,
246
- channelId: channelId
247
+ option: option,
248
+ filter: filter,
249
+ sort: sort
247
250
  }
248
251
  })
249
252
  }).then(function (res) {
250
253
  return res.json();
251
254
  }).then(function (data) {
252
- return data.data.subscriptionsByConnection.edges;
255
+ return data.data.subscriptions.edges;
253
256
  })];
254
257
 
255
258
  case 1:
@@ -261,4 +264,4 @@ var getSubscriptionByConnection = function getSubscriptionByConnection(channelId
261
264
  });
262
265
  };
263
266
 
264
- exports.getSubscriptionByConnection = getSubscriptionByConnection;
267
+ exports.getSubscriptions = getSubscriptions;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ncloudchat",
3
3
  "jsName": "ncloudchat",
4
- "version": "0.0.19-beta",
4
+ "version": "0.0.22-beta",
5
5
  "private": false,
6
6
  "description": "",
7
7
  "keywords": [