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/mutations/channel.js
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
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
|
-
exports.
|
|
11
|
+
exports.updateChannel = exports.removeChannelMembers = exports.deleteChannel = exports.createChannel = exports.addChannelMembers = void 0;
|
|
12
12
|
|
|
13
|
-
require("core-js/modules/es6.function.name");
|
|
13
|
+
require("core-js/modules/es6.function.name.js");
|
|
14
14
|
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
|
|
15
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
18
16
|
|
|
19
17
|
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol"));
|
|
20
18
|
|
|
21
|
-
var
|
|
19
|
+
var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
|
|
22
20
|
|
|
23
21
|
var _CoreManager = _interopRequireDefault(require("../CoreManager"));
|
|
24
22
|
|
|
23
|
+
var _channel = require("../graphql/channel");
|
|
24
|
+
|
|
25
|
+
var _Network = require("../Network");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the MIT license found in the
|
|
31
|
+
* LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/
|
|
25
33
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
26
34
|
function adopt(value) {
|
|
27
35
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -165,106 +173,71 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
165
173
|
}
|
|
166
174
|
};
|
|
167
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Create a new channel.
|
|
178
|
+
*
|
|
179
|
+
* @async
|
|
180
|
+
* @function createChannel
|
|
181
|
+
* @param {ChannelInput} channel - Configuration options of the new channel.
|
|
182
|
+
* @returns {Promise<any>} The data of the newly created channel.
|
|
183
|
+
*/
|
|
168
184
|
var createChannel = function createChannel(channel) {
|
|
169
185
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
-
var token, projectId, endpoint, query;
|
|
171
186
|
return __generator(this, function (_a) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
linkUrl: channel.linkUrl,
|
|
200
|
-
imageUrl: 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
|
-
}
|
|
187
|
+
if (!channel.members) channel.members = [];
|
|
188
|
+
return [2
|
|
189
|
+
/*return*/
|
|
190
|
+
, (0, _Network.fetchData)("createChannel", _channel.createChannelQuery, {
|
|
191
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
192
|
+
name: channel.name,
|
|
193
|
+
type: channel.type,
|
|
194
|
+
uniqueId: channel.uniqueId,
|
|
195
|
+
translation: channel.translation,
|
|
196
|
+
push: channel.push,
|
|
197
|
+
mutes: channel.mutes,
|
|
198
|
+
customField: channel.customField,
|
|
199
|
+
linkUrl: channel.linkUrl,
|
|
200
|
+
imageUrl: channel.imageUrl,
|
|
201
|
+
disabled: channel.disabled,
|
|
202
|
+
members: channel.members
|
|
203
|
+
})];
|
|
218
204
|
});
|
|
219
205
|
});
|
|
220
206
|
};
|
|
207
|
+
/**
|
|
208
|
+
* Update channel options.
|
|
209
|
+
*
|
|
210
|
+
* @async
|
|
211
|
+
* @function updateChannel
|
|
212
|
+
* @param {string} channelId - An id of the channel.
|
|
213
|
+
* @param {ChannelInput} channel - New options of the channel.
|
|
214
|
+
* @returns {Promise<any>} The data of the updated channel.
|
|
215
|
+
*/
|
|
216
|
+
|
|
221
217
|
|
|
222
218
|
exports.createChannel = createChannel;
|
|
223
219
|
|
|
224
220
|
var updateChannel = function updateChannel(channelId, channel) {
|
|
225
221
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
226
|
-
var token, projectId, endpoint, query;
|
|
227
222
|
return __generator(this, function (_a) {
|
|
228
223
|
switch (_a.label) {
|
|
229
224
|
case 0:
|
|
230
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
231
|
-
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
232
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
233
225
|
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 $members: [String]\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 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
226
|
return [4
|
|
236
227
|
/*yield*/
|
|
237
|
-
,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
linkUrl: channel.linkUrl,
|
|
257
|
-
imageUrl: 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;
|
|
228
|
+
, (0, _Network.fetchData)("updateChannel", _channel.updateChannelQuery, {
|
|
229
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
230
|
+
id: channelId,
|
|
231
|
+
name: channel.name,
|
|
232
|
+
type: channel.type,
|
|
233
|
+
uniqueId: channel.uniqueId,
|
|
234
|
+
translation: channel.translation,
|
|
235
|
+
push: channel.push,
|
|
236
|
+
mutes: channel.mutes,
|
|
237
|
+
linkUrl: channel.linkUrl,
|
|
238
|
+
imageUrl: channel.imageUrl,
|
|
239
|
+
disabled: channel.disabled,
|
|
240
|
+
members: channel.members
|
|
268
241
|
})];
|
|
269
242
|
|
|
270
243
|
case 1:
|
|
@@ -275,42 +248,28 @@ var updateChannel = function updateChannel(channelId, channel) {
|
|
|
275
248
|
});
|
|
276
249
|
});
|
|
277
250
|
};
|
|
251
|
+
/**
|
|
252
|
+
* Delete a channel.
|
|
253
|
+
*
|
|
254
|
+
* @async
|
|
255
|
+
* @function deleteChannel
|
|
256
|
+
* @param {string} channelId - An channel id.
|
|
257
|
+
* @returns {Promise<any>}
|
|
258
|
+
*/
|
|
259
|
+
|
|
278
260
|
|
|
279
261
|
exports.updateChannel = updateChannel;
|
|
280
262
|
|
|
281
263
|
var deleteChannel = function deleteChannel(channelId) {
|
|
282
264
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
283
|
-
var token, projectId, endpoint, query;
|
|
284
265
|
return __generator(this, function (_a) {
|
|
285
266
|
switch (_a.label) {
|
|
286
267
|
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 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
268
|
return [4
|
|
292
269
|
/*yield*/
|
|
293
|
-
,
|
|
294
|
-
|
|
295
|
-
|
|
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;
|
|
270
|
+
, (0, _Network.fetchData)("deleteChannel", _channel.deleteChannelQuery, {
|
|
271
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
272
|
+
id: channelId
|
|
314
273
|
})];
|
|
315
274
|
|
|
316
275
|
case 1:
|
|
@@ -321,44 +280,32 @@ var deleteChannel = function deleteChannel(channelId) {
|
|
|
321
280
|
});
|
|
322
281
|
});
|
|
323
282
|
};
|
|
283
|
+
/**
|
|
284
|
+
* Add members to the private channel.
|
|
285
|
+
*
|
|
286
|
+
* @async
|
|
287
|
+
* @function addChannelMembers
|
|
288
|
+
* @param {string} channelId - An private channel id.
|
|
289
|
+
* @param {string[]} memberIds - An array of member ids to be added.
|
|
290
|
+
* @param {any} options
|
|
291
|
+
* @returns {Promise<any>}
|
|
292
|
+
*/
|
|
293
|
+
|
|
324
294
|
|
|
325
295
|
exports.deleteChannel = deleteChannel;
|
|
326
296
|
|
|
327
297
|
var addChannelMembers = function addChannelMembers(channelId, memberIds, options) {
|
|
328
298
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
329
|
-
var token, projectId, endpoint, query;
|
|
330
299
|
return __generator(this, function (_a) {
|
|
331
300
|
switch (_a.label) {
|
|
332
301
|
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 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
302
|
return [4
|
|
338
303
|
/*yield*/
|
|
339
|
-
,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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;
|
|
304
|
+
, (0, _Network.fetchData)("addChannelMembers", _channel.addChannelMembersQuery, {
|
|
305
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
306
|
+
channelId: channelId,
|
|
307
|
+
memberIds: memberIds,
|
|
308
|
+
options: options
|
|
362
309
|
})];
|
|
363
310
|
|
|
364
311
|
case 1:
|
|
@@ -369,43 +316,30 @@ var addChannelMembers = function addChannelMembers(channelId, memberIds, options
|
|
|
369
316
|
});
|
|
370
317
|
});
|
|
371
318
|
};
|
|
319
|
+
/**
|
|
320
|
+
* Remove members from the private channel.
|
|
321
|
+
*
|
|
322
|
+
* @async
|
|
323
|
+
* @function removeChannelMembers
|
|
324
|
+
* @param {string} channelId - An private channel id.
|
|
325
|
+
* @param {string[]} memberIds - An array of the member ids to be deleted.
|
|
326
|
+
* @returns {Promise<any>}
|
|
327
|
+
*/
|
|
328
|
+
|
|
372
329
|
|
|
373
330
|
exports.addChannelMembers = addChannelMembers;
|
|
374
331
|
|
|
375
332
|
var removeChannelMembers = function removeChannelMembers(channelId, memberIds) {
|
|
376
333
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
377
|
-
var token, projectId, endpoint, query;
|
|
378
334
|
return __generator(this, function (_a) {
|
|
379
335
|
switch (_a.label) {
|
|
380
336
|
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 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
337
|
return [4
|
|
386
338
|
/*yield*/
|
|
387
|
-
,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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
|
-
}
|
|
402
|
-
})
|
|
403
|
-
}).then(function (res) {
|
|
404
|
-
return res.json();
|
|
405
|
-
}).then(function (data) {
|
|
406
|
-
if (data.errors) throw data.errors[0];
|
|
407
|
-
if (data.code) throw data;
|
|
408
|
-
return data.data.removeChannelMembers.channel;
|
|
339
|
+
, (0, _Network.fetchData)("removeChannelMembers", _channel.removeChannelMembersQuery, {
|
|
340
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
341
|
+
channelId: channelId,
|
|
342
|
+
memberIds: memberIds
|
|
409
343
|
})];
|
|
410
344
|
|
|
411
345
|
case 1:
|
package/lib/mutations/friend.js
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
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
|
-
exports.
|
|
12
|
-
|
|
13
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
11
|
+
exports.requestFriend = exports.removeFriend = exports.rejectFriend = exports.acceptFriend = void 0;
|
|
14
12
|
|
|
15
|
-
var
|
|
13
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
16
14
|
|
|
17
15
|
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol"));
|
|
18
16
|
|
|
19
|
-
var
|
|
17
|
+
var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
|
|
20
18
|
|
|
21
19
|
var _CoreManager = _interopRequireDefault(require("../CoreManager"));
|
|
22
20
|
|
|
21
|
+
var _friend = require("../graphql/friend");
|
|
22
|
+
|
|
23
|
+
var _Network = require("../Network");
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Copyright (c) NBASE CORP. and its affiliates.
|
|
27
|
+
*
|
|
28
|
+
* This source code is licensed under the MIT license found in the
|
|
29
|
+
* LICENSE file in the root directory of this source tree.
|
|
30
|
+
*/
|
|
23
31
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
24
32
|
function adopt(value) {
|
|
25
33
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -163,41 +171,24 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
163
171
|
}
|
|
164
172
|
};
|
|
165
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Request a friendship to a user.
|
|
176
|
+
*
|
|
177
|
+
* @async
|
|
178
|
+
* @function requestFriend
|
|
179
|
+
* @param {string} friendId - An id of the friend to request.
|
|
180
|
+
* @returns {Promise<any>}
|
|
181
|
+
*/
|
|
166
182
|
var requestFriend = function requestFriend(friendId) {
|
|
167
183
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
-
var token, projectId, endpoint, query;
|
|
169
184
|
return __generator(this, function (_a) {
|
|
170
185
|
switch (_a.label) {
|
|
171
186
|
case 0:
|
|
172
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
173
|
-
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
174
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
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 name\n profile\n }\n friend {\n id\n name\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
176
187
|
return [4
|
|
177
188
|
/*yield*/
|
|
178
|
-
,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
'Authorization': 'Bearer ' + token,
|
|
182
|
-
'X-PROJECT-ID': projectId,
|
|
183
|
-
'Content-Type': 'application/json',
|
|
184
|
-
'Accept': 'application/json'
|
|
185
|
-
},
|
|
186
|
-
body: (0, _stringify["default"])({
|
|
187
|
-
query: query,
|
|
188
|
-
variables: {
|
|
189
|
-
projectId: projectId,
|
|
190
|
-
friendId: friendId
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
}).then(function (res) {
|
|
194
|
-
return res.json();
|
|
195
|
-
}).then(function (data) {
|
|
196
|
-
if (data.errors) {
|
|
197
|
-
throw data.errors[0];
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return data.data.requestFriend.friendship;
|
|
189
|
+
, (0, _Network.fetchData)("requestFriend", _friend.requestFriendQuery, {
|
|
190
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
191
|
+
friendId: friendId
|
|
201
192
|
})];
|
|
202
193
|
|
|
203
194
|
case 1:
|
|
@@ -208,44 +199,28 @@ var requestFriend = function requestFriend(friendId) {
|
|
|
208
199
|
});
|
|
209
200
|
});
|
|
210
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Accept a friends request.
|
|
204
|
+
*
|
|
205
|
+
* @async
|
|
206
|
+
* @function acceptFriend
|
|
207
|
+
* @param {string} friendId - The id of the friend to accept the request.
|
|
208
|
+
* @returns {Promise<any>}
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
211
|
|
|
212
212
|
exports.requestFriend = requestFriend;
|
|
213
213
|
|
|
214
214
|
var acceptFriend = function acceptFriend(friendId) {
|
|
215
215
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
216
|
-
var token, projectId, endpoint, query;
|
|
217
216
|
return __generator(this, function (_a) {
|
|
218
217
|
switch (_a.label) {
|
|
219
218
|
case 0:
|
|
220
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
221
|
-
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
222
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
223
|
-
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 name\n profile\n }\n friend {\n id\n name\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
224
219
|
return [4
|
|
225
220
|
/*yield*/
|
|
226
|
-
,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
'Authorization': 'Bearer ' + token,
|
|
230
|
-
'X-PROJECT-ID': projectId,
|
|
231
|
-
'Content-Type': 'application/json',
|
|
232
|
-
'Accept': 'application/json'
|
|
233
|
-
},
|
|
234
|
-
body: (0, _stringify["default"])({
|
|
235
|
-
query: query,
|
|
236
|
-
variables: {
|
|
237
|
-
projectId: projectId,
|
|
238
|
-
friendId: friendId
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
}).then(function (res) {
|
|
242
|
-
return res.json();
|
|
243
|
-
}).then(function (data) {
|
|
244
|
-
if (data.errors) {
|
|
245
|
-
throw data.errors[0];
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return data.data.acceptFriend.friendship;
|
|
221
|
+
, (0, _Network.fetchData)("acceptFriend", _friend.acceptFriendQuery, {
|
|
222
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
223
|
+
friendId: friendId
|
|
249
224
|
})];
|
|
250
225
|
|
|
251
226
|
case 1:
|
|
@@ -256,42 +231,28 @@ var acceptFriend = function acceptFriend(friendId) {
|
|
|
256
231
|
});
|
|
257
232
|
});
|
|
258
233
|
};
|
|
234
|
+
/**
|
|
235
|
+
* Reject a friend request.
|
|
236
|
+
*
|
|
237
|
+
* @async
|
|
238
|
+
* @function rejectFriend
|
|
239
|
+
* @param {string} friendId - An id of the friend to be rejected.
|
|
240
|
+
* @returns {Promise<any>}
|
|
241
|
+
*/
|
|
242
|
+
|
|
259
243
|
|
|
260
244
|
exports.acceptFriend = acceptFriend;
|
|
261
245
|
|
|
262
246
|
var rejectFriend = function rejectFriend(friendId) {
|
|
263
247
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
264
|
-
var token, projectId, endpoint, query;
|
|
265
248
|
return __generator(this, function (_a) {
|
|
266
249
|
switch (_a.label) {
|
|
267
250
|
case 0:
|
|
268
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
269
|
-
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
270
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
271
|
-
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 name\n profile\n }\n friend {\n id\n name\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
272
251
|
return [4
|
|
273
252
|
/*yield*/
|
|
274
|
-
,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
'Authorization': 'Bearer ' + token,
|
|
278
|
-
'X-PROJECT-ID': projectId,
|
|
279
|
-
'Content-Type': 'application/json',
|
|
280
|
-
'Accept': 'application/json'
|
|
281
|
-
},
|
|
282
|
-
body: (0, _stringify["default"])({
|
|
283
|
-
query: query,
|
|
284
|
-
variables: {
|
|
285
|
-
projectId: projectId,
|
|
286
|
-
friendId: friendId
|
|
287
|
-
}
|
|
288
|
-
})
|
|
289
|
-
}).then(function (res) {
|
|
290
|
-
return res.json();
|
|
291
|
-
}).then(function (data) {
|
|
292
|
-
if (data.errors) throw data.errors[0];
|
|
293
|
-
if (data.code) throw data;
|
|
294
|
-
return data.data.rejectFriend.friendship;
|
|
253
|
+
, (0, _Network.fetchData)("rejectFriend", _friend.rejectFriendQuery, {
|
|
254
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
255
|
+
friendId: friendId
|
|
295
256
|
})];
|
|
296
257
|
|
|
297
258
|
case 1:
|
|
@@ -302,42 +263,28 @@ var rejectFriend = function rejectFriend(friendId) {
|
|
|
302
263
|
});
|
|
303
264
|
});
|
|
304
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* Remove a friend.
|
|
268
|
+
*
|
|
269
|
+
* @async
|
|
270
|
+
* @function removeFriend
|
|
271
|
+
* @param {string} friendId - An id of the friend to be removed.
|
|
272
|
+
* @returns {Promise<any>}
|
|
273
|
+
*/
|
|
274
|
+
|
|
305
275
|
|
|
306
276
|
exports.rejectFriend = rejectFriend;
|
|
307
277
|
|
|
308
278
|
var removeFriend = function removeFriend(friendId) {
|
|
309
279
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
310
|
-
var token, projectId, endpoint, query;
|
|
311
280
|
return __generator(this, function (_a) {
|
|
312
281
|
switch (_a.label) {
|
|
313
282
|
case 0:
|
|
314
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
315
|
-
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
316
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
317
|
-
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 name\n profile\n }\n friend {\n id\n name\n profile\n }\n friend_id\n created_at\n updated_at\n requested_at\n }\n }\n }\n ";
|
|
318
283
|
return [4
|
|
319
284
|
/*yield*/
|
|
320
|
-
,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
'Authorization': 'Bearer ' + token,
|
|
324
|
-
'X-PROJECT-ID': projectId,
|
|
325
|
-
'Content-Type': 'application/json',
|
|
326
|
-
'Accept': 'application/json'
|
|
327
|
-
},
|
|
328
|
-
body: (0, _stringify["default"])({
|
|
329
|
-
query: query,
|
|
330
|
-
variables: {
|
|
331
|
-
projectId: projectId,
|
|
332
|
-
friendId: friendId
|
|
333
|
-
}
|
|
334
|
-
})
|
|
335
|
-
}).then(function (res) {
|
|
336
|
-
return res.json();
|
|
337
|
-
}).then(function (data) {
|
|
338
|
-
if (data.errors) throw data.errors[0];
|
|
339
|
-
if (data.code) throw data;
|
|
340
|
-
return data.data.removeFriend.friendship;
|
|
285
|
+
, (0, _Network.fetchData)("removeFriend", _friend.removeFriendQuery, {
|
|
286
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
287
|
+
friendId: friendId
|
|
341
288
|
})];
|
|
342
289
|
|
|
343
290
|
case 1:
|