ncloudchat 0.0.24-beta → 0.0.27-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.
- package/esm/CloudChat.d.ts +6 -1
- package/esm/CloudChat.js +171 -52
- package/esm/CloudChat.js.map +1 -1
- package/esm/mutations/friend.d.ts +3 -4
- package/esm/mutations/friend.js +51 -19
- package/esm/mutations/friend.js.map +1 -1
- package/esm/mutations/user.d.ts +1 -1
- package/esm/mutations/user.js +11 -5
- package/esm/mutations/user.js.map +1 -1
- package/esm/queries/friend.d.ts +1 -1
- package/esm/queries/friend.js +7 -8
- package/esm/queries/friend.js.map +1 -1
- package/lib/CloudChat.js +258 -50
- package/lib/mutations/friend.js +62 -29
- package/lib/mutations/user.js +13 -5
- package/lib/queries/friend.js +9 -10
- package/ncloudchat_javascript.md +3 -4
- package/package.json +3 -2
package/lib/mutations/friend.js
CHANGED
|
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
exports.
|
|
11
|
+
exports.removeFriend = exports.rejectFriend = exports.acceptFriend = exports.requestFriend = void 0;
|
|
12
12
|
|
|
13
13
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
14
14
|
|
|
@@ -163,7 +163,7 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
-
var
|
|
166
|
+
var requestFriend = function requestFriend(friendId) {
|
|
167
167
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
168
168
|
var token, projectId, endpoint, query;
|
|
169
169
|
return __generator(this, function (_a) {
|
|
@@ -172,7 +172,7 @@ var createFriend = function createFriend(channelId, friendIds) {
|
|
|
172
172
|
token = _CoreManager["default"].get("TOKEN");
|
|
173
173
|
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
174
174
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
175
|
-
query = "\n mutation (
|
|
175
|
+
query = "\n mutation ($projectId: String!, $friendId: String!) {\n requestFriend(input: {projectId: $projectId, friendId: $friendId}) {\n friendship {\n project_id\n id\n status\n user {\n id\n nickname\n profile\n }\n friend {\n id\n nickname\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
176
176
|
return [4
|
|
177
177
|
/*yield*/
|
|
178
178
|
, fetch(endpoint, {
|
|
@@ -186,14 +186,17 @@ var createFriend = function createFriend(channelId, friendIds) {
|
|
|
186
186
|
query: query,
|
|
187
187
|
variables: {
|
|
188
188
|
projectId: projectId,
|
|
189
|
-
|
|
190
|
-
friendIds: friendIds
|
|
189
|
+
friendId: friendId
|
|
191
190
|
}
|
|
192
191
|
})
|
|
193
192
|
}).then(function (res) {
|
|
194
193
|
return res.json();
|
|
195
194
|
}).then(function (data) {
|
|
196
|
-
|
|
195
|
+
if (data.errors) {
|
|
196
|
+
throw data.errors[0];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return data.data.requestFriend.friendship;
|
|
197
200
|
})];
|
|
198
201
|
|
|
199
202
|
case 1:
|
|
@@ -205,7 +208,7 @@ var createFriend = function createFriend(channelId, friendIds) {
|
|
|
205
208
|
});
|
|
206
209
|
};
|
|
207
210
|
|
|
208
|
-
exports.
|
|
211
|
+
exports.requestFriend = requestFriend;
|
|
209
212
|
|
|
210
213
|
var acceptFriend = function acceptFriend(friendId) {
|
|
211
214
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -216,7 +219,7 @@ var acceptFriend = function acceptFriend(friendId) {
|
|
|
216
219
|
token = _CoreManager["default"].get("TOKEN");
|
|
217
220
|
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
218
221
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
219
|
-
query = "\n mutation (
|
|
222
|
+
query = "\n mutation ($projectId: String!, $friendId: String!) {\n acceptFriend(input: {projectId: $projectId, friendId: $friendId}) {\n friendship {\n project_id\n id\n status\n user {\n id\n nickname\n profile\n }\n friend {\n id\n nickname\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
220
223
|
return [4
|
|
221
224
|
/*yield*/
|
|
222
225
|
, fetch(endpoint, {
|
|
@@ -236,7 +239,11 @@ var acceptFriend = function acceptFriend(friendId) {
|
|
|
236
239
|
}).then(function (res) {
|
|
237
240
|
return res.json();
|
|
238
241
|
}).then(function (data) {
|
|
239
|
-
|
|
242
|
+
if (data.errors) {
|
|
243
|
+
throw data.errors[0];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return data.data.acceptFriend.friendship;
|
|
240
247
|
})];
|
|
241
248
|
|
|
242
249
|
case 1:
|
|
@@ -250,7 +257,7 @@ var acceptFriend = function acceptFriend(friendId) {
|
|
|
250
257
|
|
|
251
258
|
exports.acceptFriend = acceptFriend;
|
|
252
259
|
|
|
253
|
-
var rejectFriend = function rejectFriend(
|
|
260
|
+
var rejectFriend = function rejectFriend(friendId) {
|
|
254
261
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
255
262
|
var token, projectId, endpoint, query;
|
|
256
263
|
return __generator(this, function (_a) {
|
|
@@ -259,7 +266,7 @@ var rejectFriend = function rejectFriend(channelId, friendIds) {
|
|
|
259
266
|
token = _CoreManager["default"].get("TOKEN");
|
|
260
267
|
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
261
268
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
262
|
-
query = "\n mutation (
|
|
269
|
+
query = "\n mutation ($projectId: String!, $friendId: String!) {\n rejectFriend(input: {projectId: $projectId, friendId: $friendId}) {\n friendship {\n project_id\n id\n status\n user {\n id\n nickname\n profile\n }\n friend {\n id\n nickname\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
263
270
|
return [4
|
|
264
271
|
/*yield*/
|
|
265
272
|
, fetch(endpoint, {
|
|
@@ -273,14 +280,17 @@ var rejectFriend = function rejectFriend(channelId, friendIds) {
|
|
|
273
280
|
query: query,
|
|
274
281
|
variables: {
|
|
275
282
|
projectId: projectId,
|
|
276
|
-
|
|
277
|
-
friendIds: friendIds
|
|
283
|
+
friendId: friendId
|
|
278
284
|
}
|
|
279
285
|
})
|
|
280
286
|
}).then(function (res) {
|
|
281
287
|
return res.json();
|
|
282
288
|
}).then(function (data) {
|
|
283
|
-
|
|
289
|
+
if (data.errors) {
|
|
290
|
+
throw data.errors[0];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return data.data.rejectFriend.friendship;
|
|
284
294
|
})];
|
|
285
295
|
|
|
286
296
|
case 1:
|
|
@@ -294,26 +304,49 @@ var rejectFriend = function rejectFriend(channelId, friendIds) {
|
|
|
294
304
|
|
|
295
305
|
exports.rejectFriend = rejectFriend;
|
|
296
306
|
|
|
297
|
-
var
|
|
307
|
+
var removeFriend = function removeFriend(friendId) {
|
|
298
308
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
309
|
+
var token, projectId, endpoint, query;
|
|
299
310
|
return __generator(this, function (_a) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
};
|
|
311
|
+
switch (_a.label) {
|
|
312
|
+
case 0:
|
|
313
|
+
token = _CoreManager["default"].get("TOKEN");
|
|
314
|
+
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
315
|
+
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
316
|
+
query = "\n mutation ($projectId: String!, $friendId: String!) {\n removeFriend(input: {projectId: $projectId, friendId: $friendId}) {\n friendship {\n project_id\n id\n status\n user {\n id\n nickname\n profile\n }\n friend {\n id\n nickname\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
317
|
+
return [4
|
|
318
|
+
/*yield*/
|
|
319
|
+
, fetch(endpoint, {
|
|
320
|
+
method: 'POST',
|
|
321
|
+
headers: {
|
|
322
|
+
'Authorization': 'Bearer ' + token,
|
|
323
|
+
'Content-Type': 'application/json',
|
|
324
|
+
'Accept': 'application/json'
|
|
325
|
+
},
|
|
326
|
+
body: (0, _stringify["default"])({
|
|
327
|
+
query: query,
|
|
328
|
+
variables: {
|
|
329
|
+
projectId: projectId,
|
|
330
|
+
friendId: friendId
|
|
331
|
+
}
|
|
332
|
+
})
|
|
333
|
+
}).then(function (res) {
|
|
334
|
+
return res.json();
|
|
335
|
+
}).then(function (data) {
|
|
336
|
+
if (data.errors) {
|
|
337
|
+
throw data.errors[0];
|
|
338
|
+
}
|
|
306
339
|
|
|
307
|
-
|
|
340
|
+
return data.data.removeFriend.friendship;
|
|
341
|
+
})];
|
|
308
342
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
];
|
|
343
|
+
case 1:
|
|
344
|
+
return [2
|
|
345
|
+
/*return*/
|
|
346
|
+
, _a.sent()];
|
|
347
|
+
}
|
|
315
348
|
});
|
|
316
349
|
});
|
|
317
350
|
};
|
|
318
351
|
|
|
319
|
-
exports.
|
|
352
|
+
exports.removeFriend = removeFriend;
|
package/lib/mutations/user.js
CHANGED
|
@@ -163,7 +163,7 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
-
var login = function login(user_id, name, profile) {
|
|
166
|
+
var login = function login(user_id, name, profile, token) {
|
|
167
167
|
if (name === void 0) {
|
|
168
168
|
name = '';
|
|
169
169
|
}
|
|
@@ -172,11 +172,17 @@ var login = function login(user_id, name, profile) {
|
|
|
172
172
|
profile = '';
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
if (token === void 0) {
|
|
176
|
+
token = '';
|
|
177
|
+
}
|
|
178
|
+
|
|
175
179
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
176
180
|
var projectId, endpoint, mutation;
|
|
177
181
|
return __generator(this, function (_a) {
|
|
178
182
|
switch (_a.label) {
|
|
179
183
|
case 0:
|
|
184
|
+
_CoreManager["default"].set("TOKEN", token);
|
|
185
|
+
|
|
180
186
|
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
181
187
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
182
188
|
mutation = "mutation login ($projectId: String!, $userId: String!, $name: String, $profile: String) {\n login(input :{ projectId: $projectId, userId:$userId, name:$name, profile:$profile}) {\n token\n }\n }";
|
|
@@ -185,6 +191,7 @@ var login = function login(user_id, name, profile) {
|
|
|
185
191
|
, fetch(endpoint, {
|
|
186
192
|
method: 'POST',
|
|
187
193
|
headers: {
|
|
194
|
+
'Authorization': 'Bearer ' + token,
|
|
188
195
|
'Content-Type': 'application/json',
|
|
189
196
|
'Accept': 'application/json'
|
|
190
197
|
},
|
|
@@ -194,15 +201,16 @@ var login = function login(user_id, name, profile) {
|
|
|
194
201
|
projectId: projectId,
|
|
195
202
|
userId: user_id,
|
|
196
203
|
name: name,
|
|
197
|
-
profile: profile
|
|
204
|
+
profile: profile,
|
|
205
|
+
token: token
|
|
198
206
|
}
|
|
199
207
|
})
|
|
200
208
|
}).then(function (res) {
|
|
201
209
|
return res.json();
|
|
202
210
|
}).then(function (data) {
|
|
203
|
-
if (data.errors) {
|
|
204
|
-
|
|
205
|
-
} else
|
|
211
|
+
if (data.errors) throw data.errors[0];else if (data.message) throw data;else if (data.data.login.token) {
|
|
212
|
+
return data.data.login.token;
|
|
213
|
+
} else return false;
|
|
206
214
|
})];
|
|
207
215
|
|
|
208
216
|
case 1:
|
package/lib/queries/friend.js
CHANGED
|
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
exports.
|
|
11
|
+
exports.getFriendships = void 0;
|
|
12
12
|
|
|
13
13
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
14
14
|
|
|
@@ -163,7 +163,7 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
-
var
|
|
166
|
+
var getFriendships = function getFriendships(filter, sort, option) {
|
|
167
167
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
168
168
|
var token, projectId, endpoint, lquery;
|
|
169
169
|
return __generator(this, function (_a) {
|
|
@@ -178,7 +178,7 @@ var getFriends = function getFriends(offset, per_page, search, query) {
|
|
|
178
178
|
/*return*/
|
|
179
179
|
, null];
|
|
180
180
|
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
181
|
-
lquery = "\n
|
|
181
|
+
lquery = "\n query friendships ($projectId: String!, $filter: String!, $sort: String, $option: String) {\n friendships(projectId: $projectId, filter:$filter, sort:$sort, option: $option) {\n totalCount\n edges {\n node {\n project_id\n id\n status\n user {\n id\n nickname\n profile\n }\n friend {\n id\n nickname\n profile\n }\n user_id\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n }\n ";
|
|
182
182
|
return [4
|
|
183
183
|
/*yield*/
|
|
184
184
|
, fetch(endpoint, {
|
|
@@ -192,17 +192,16 @@ var getFriends = function getFriends(offset, per_page, search, query) {
|
|
|
192
192
|
query: lquery,
|
|
193
193
|
variables: {
|
|
194
194
|
projectId: projectId,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
query: query === "" ? undefined : query
|
|
195
|
+
filter: filter,
|
|
196
|
+
sort: sort,
|
|
197
|
+
option: option
|
|
199
198
|
}
|
|
200
199
|
})
|
|
201
200
|
}).then(function (res) {
|
|
202
201
|
return res.json();
|
|
203
202
|
}).then(function (data) {
|
|
204
|
-
if (data.data.
|
|
205
|
-
return data.data.
|
|
203
|
+
if (data.data.friendships) {
|
|
204
|
+
return data.data.friendships.edges;
|
|
206
205
|
}
|
|
207
206
|
|
|
208
207
|
return [];
|
|
@@ -217,4 +216,4 @@ var getFriends = function getFriends(offset, per_page, search, query) {
|
|
|
217
216
|
});
|
|
218
217
|
};
|
|
219
218
|
|
|
220
|
-
exports.
|
|
219
|
+
exports.getFriendships = getFriendships;
|
package/ncloudchat_javascript.md
CHANGED
|
@@ -26,12 +26,11 @@ chat.initialize(projectId);
|
|
|
26
26
|
- 초기화가 완료되면 사용자명, 이름, 프로필 이미지주소(옵션) 을 입력 후에 접속해야 합니다.
|
|
27
27
|
|
|
28
28
|
```javascript
|
|
29
|
-
chat.
|
|
29
|
+
const user = await chat.connect({
|
|
30
30
|
id: USERNAME,
|
|
31
31
|
name: NAME,
|
|
32
32
|
profile: PROFILE_URL
|
|
33
|
-
});
|
|
34
|
-
const user = await chat.connect(user_id);
|
|
33
|
+
}, TOKEN);
|
|
35
34
|
```
|
|
36
35
|
|
|
37
36
|
| ID | type | desc |
|
|
@@ -39,7 +38,7 @@ const user = await chat.connect(user_id);
|
|
|
39
38
|
| USERNAME | string | 아이디 |
|
|
40
39
|
| NAME | string | 이름 |
|
|
41
40
|
| PROFILE_URL | string | 프로필 주소 |
|
|
42
|
-
|
|
41
|
+
| TOKEN | string | 토큰 값 |
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
### 3. Disconnect from NCloud Chat Server
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ncloudchat",
|
|
3
3
|
"jsName": "ncloudchat",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.27-beta",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "",
|
|
7
7
|
"keywords": [
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"start": "npm run lint && webpack-dev-server --open --config webpack.dev.js",
|
|
23
23
|
"lint": "tsc --noEmit && eslint --ext .ts",
|
|
24
24
|
"server": "node test/server.js",
|
|
25
|
-
"publish-dev": "aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp dist/ncloudchat.min.js s3://ncloudchat/dev/ --acl public-read"
|
|
25
|
+
"publish-dev": "aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp dist/ncloudchat.min.js s3://ncloudchat/dev/ --acl public-read",
|
|
26
|
+
"publish": "aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp dist/ncloudchat.min.js s3://ncloudchat/ --acl public-read"
|
|
26
27
|
},
|
|
27
28
|
"repository": {
|
|
28
29
|
"type": "git"
|