ncloudchat 0.0.19-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 (104) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +69 -0
  3. package/esm/CloudChat.d.ts +38 -0
  4. package/esm/CloudChat.js +592 -0
  5. package/esm/CloudChat.js.map +1 -0
  6. package/esm/CoreManager.d.ts +5 -0
  7. package/esm/CoreManager.js +27 -0
  8. package/esm/CoreManager.js.map +1 -0
  9. package/esm/Dispatcher.d.ts +21 -0
  10. package/esm/Dispatcher.js +78 -0
  11. package/esm/Dispatcher.js.map +1 -0
  12. package/esm/Type.d.ts +35 -0
  13. package/esm/Type.js +12 -0
  14. package/esm/Type.js.map +1 -0
  15. package/esm/index.d.ts +2 -0
  16. package/esm/index.js +3 -0
  17. package/esm/index.js.map +1 -0
  18. package/esm/logger.d.ts +4 -0
  19. package/esm/logger.js +11 -0
  20. package/esm/logger.js.map +1 -0
  21. package/esm/mutations/channel.d.ts +4 -0
  22. package/esm/mutations/channel.js +162 -0
  23. package/esm/mutations/channel.js.map +1 -0
  24. package/esm/mutations/friend.d.ts +5 -0
  25. package/esm/mutations/friend.js +146 -0
  26. package/esm/mutations/friend.js.map +1 -0
  27. package/esm/mutations/index.d.ts +14 -0
  28. package/esm/mutations/index.js +15 -0
  29. package/esm/mutations/index.js.map +1 -0
  30. package/esm/mutations/invite.d.ts +1 -0
  31. package/esm/mutations/invite.js +71 -0
  32. package/esm/mutations/invite.js.map +1 -0
  33. package/esm/mutations/memberinvitation.d.ts +2 -0
  34. package/esm/mutations/memberinvitation.js +103 -0
  35. package/esm/mutations/memberinvitation.js.map +1 -0
  36. package/esm/mutations/memberreport.d.ts +10 -0
  37. package/esm/mutations/memberreport.js +110 -0
  38. package/esm/mutations/memberreport.js.map +1 -0
  39. package/esm/mutations/message.d.ts +2 -0
  40. package/esm/mutations/message.js +97 -0
  41. package/esm/mutations/message.js.map +1 -0
  42. package/esm/mutations/messageread.d.ts +1 -0
  43. package/esm/mutations/messageread.js +69 -0
  44. package/esm/mutations/messageread.js.map +1 -0
  45. package/esm/mutations/subscription.d.ts +4 -0
  46. package/esm/mutations/subscription.js +139 -0
  47. package/esm/mutations/subscription.js.map +1 -0
  48. package/esm/mutations/user.d.ts +1 -0
  49. package/esm/mutations/user.js +74 -0
  50. package/esm/mutations/user.js.map +1 -0
  51. package/esm/queries/channel.d.ts +2 -0
  52. package/esm/queries/channel.js +119 -0
  53. package/esm/queries/channel.js.map +1 -0
  54. package/esm/queries/friend.d.ts +1 -0
  55. package/esm/queries/friend.js +80 -0
  56. package/esm/queries/friend.js.map +1 -0
  57. package/esm/queries/index.d.ts +7 -0
  58. package/esm/queries/index.js +8 -0
  59. package/esm/queries/index.js.map +1 -0
  60. package/esm/queries/memberinvitation.d.ts +2 -0
  61. package/esm/queries/memberinvitation.js +110 -0
  62. package/esm/queries/memberinvitation.js.map +1 -0
  63. package/esm/queries/message.d.ts +2 -0
  64. package/esm/queries/message.js +117 -0
  65. package/esm/queries/message.js.map +1 -0
  66. package/esm/queries/messageread.d.ts +1 -0
  67. package/esm/queries/messageread.js +74 -0
  68. package/esm/queries/messageread.js.map +1 -0
  69. package/esm/queries/project.d.ts +1 -0
  70. package/esm/queries/project.js +74 -0
  71. package/esm/queries/project.js.map +1 -0
  72. package/esm/queries/subscription.d.ts +2 -0
  73. package/esm/queries/subscription.js +112 -0
  74. package/esm/queries/subscription.js.map +1 -0
  75. package/lib/CloudChat.js +1032 -0
  76. package/lib/CoreManager.js +35 -0
  77. package/lib/Dispatcher.js +109 -0
  78. package/lib/Type.js +25 -0
  79. package/lib/index.js +18 -0
  80. package/lib/logger.js +27 -0
  81. package/lib/mutations/channel.js +324 -0
  82. package/lib/mutations/friend.js +319 -0
  83. package/lib/mutations/index.js +128 -0
  84. package/lib/mutations/invite.js +208 -0
  85. package/lib/mutations/memberinvitation.js +271 -0
  86. package/lib/mutations/memberreport.js +272 -0
  87. package/lib/mutations/message.js +246 -0
  88. package/lib/mutations/messageread.js +215 -0
  89. package/lib/mutations/subscription.js +299 -0
  90. package/lib/mutations/user.js +207 -0
  91. package/lib/queries/channel.js +274 -0
  92. package/lib/queries/friend.js +220 -0
  93. package/lib/queries/index.js +102 -0
  94. package/lib/queries/memberinvitation.js +273 -0
  95. package/lib/queries/message.js +267 -0
  96. package/lib/queries/messageread.js +219 -0
  97. package/lib/queries/project.js +217 -0
  98. package/lib/queries/subscription.js +264 -0
  99. package/ncloudchat_javascript.md +290 -0
  100. package/package copy.json +74 -0
  101. package/package.json +76 -0
  102. package/tsconfig.json +31 -0
  103. package/types/exif.d.ts +10 -0
  104. package/types/window.d.ts +5 -0
@@ -0,0 +1,319 @@
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.deleteFriend = exports.updateFriend = exports.rejectFriend = exports.acceptFriend = exports.createFriend = 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 createFriend = function createFriend(channelId, friendIds) {
167
+ return __awaiter(void 0, void 0, void 0, function () {
168
+ var token, projectId, endpoint, query;
169
+ return __generator(this, function (_a) {
170
+ switch (_a.label) {
171
+ 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 (\n $projectId: String!, \n $channelId: String!,\n $friendIds: String!\n ) {\n requestFriend(\n input: {\n projectId: $projectId, \n channelId: $channelId,\n friendIds: $friendIds\n }\n ) {\n friendship {\n id\n }\n }\n }\n ";
176
+ return [4
177
+ /*yield*/
178
+ , fetch(endpoint, {
179
+ method: 'POST',
180
+ headers: {
181
+ 'Authorization': 'Bearer ' + token,
182
+ 'Content-Type': 'application/json',
183
+ 'Accept': 'application/json'
184
+ },
185
+ body: (0, _stringify["default"])({
186
+ query: query,
187
+ variables: {
188
+ projectId: projectId,
189
+ channelId: channelId,
190
+ friendIds: friendIds
191
+ }
192
+ })
193
+ }).then(function (res) {
194
+ return res.json();
195
+ }).then(function (data) {
196
+ return data.data.createFriend.friendship;
197
+ })];
198
+
199
+ case 1:
200
+ return [2
201
+ /*return*/
202
+ , _a.sent()];
203
+ }
204
+ });
205
+ });
206
+ };
207
+
208
+ exports.createFriend = createFriend;
209
+
210
+ var acceptFriend = function acceptFriend(friendId) {
211
+ return __awaiter(void 0, void 0, void 0, function () {
212
+ var token, projectId, endpoint, query;
213
+ return __generator(this, function (_a) {
214
+ switch (_a.label) {
215
+ case 0:
216
+ token = _CoreManager["default"].get("TOKEN");
217
+ projectId = _CoreManager["default"].get("PROJECT_ID");
218
+ endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
219
+ query = "\n mutation (\n $projectId: String!, \n $friendId: String!\n ) {\n requestFriend(\n input: {\n projectId: $projectId, \n friendId: $friendId\n }\n ) {\n friendship {\n id\n }\n }\n }\n ";
220
+ return [4
221
+ /*yield*/
222
+ , fetch(endpoint, {
223
+ method: 'POST',
224
+ headers: {
225
+ 'Authorization': 'Bearer ' + token,
226
+ 'Content-Type': 'application/json',
227
+ 'Accept': 'application/json'
228
+ },
229
+ body: (0, _stringify["default"])({
230
+ query: query,
231
+ variables: {
232
+ projectId: projectId,
233
+ friendId: friendId
234
+ }
235
+ })
236
+ }).then(function (res) {
237
+ return res.json();
238
+ }).then(function (data) {
239
+ return data.data.createFriend.friendship;
240
+ })];
241
+
242
+ case 1:
243
+ return [2
244
+ /*return*/
245
+ , _a.sent()];
246
+ }
247
+ });
248
+ });
249
+ };
250
+
251
+ exports.acceptFriend = acceptFriend;
252
+
253
+ var rejectFriend = function rejectFriend(channelId, friendIds) {
254
+ return __awaiter(void 0, void 0, void 0, function () {
255
+ var token, projectId, endpoint, query;
256
+ return __generator(this, function (_a) {
257
+ switch (_a.label) {
258
+ case 0:
259
+ token = _CoreManager["default"].get("TOKEN");
260
+ projectId = _CoreManager["default"].get("PROJECT_ID");
261
+ endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
262
+ query = "\n mutation (\n $projectId: String!, \n $channelId: String!,\n $friendIds: String!\n ) {\n requestFriend(\n input: {\n projectId: $projectId, \n channelId: $channelId,\n friendIds: $friendIds\n }\n ) {\n friendship {\n id\n }\n }\n }\n ";
263
+ return [4
264
+ /*yield*/
265
+ , fetch(endpoint, {
266
+ method: 'POST',
267
+ headers: {
268
+ 'Authorization': 'Bearer ' + token,
269
+ 'Content-Type': 'application/json',
270
+ 'Accept': 'application/json'
271
+ },
272
+ body: (0, _stringify["default"])({
273
+ query: query,
274
+ variables: {
275
+ projectId: projectId,
276
+ channelId: channelId,
277
+ friendIds: friendIds
278
+ }
279
+ })
280
+ }).then(function (res) {
281
+ return res.json();
282
+ }).then(function (data) {
283
+ return data.data.createFriend.friendship;
284
+ })];
285
+
286
+ case 1:
287
+ return [2
288
+ /*return*/
289
+ , _a.sent()];
290
+ }
291
+ });
292
+ });
293
+ };
294
+
295
+ exports.rejectFriend = rejectFriend;
296
+
297
+ var updateFriend = function updateFriend() {
298
+ return __awaiter(void 0, void 0, void 0, function () {
299
+ return __generator(this, function (_a) {
300
+ return [2
301
+ /*return*/
302
+ ];
303
+ });
304
+ });
305
+ };
306
+
307
+ exports.updateFriend = updateFriend;
308
+
309
+ var deleteFriend = function deleteFriend() {
310
+ return __awaiter(void 0, void 0, void 0, function () {
311
+ return __generator(this, function (_a) {
312
+ return [2
313
+ /*return*/
314
+ ];
315
+ });
316
+ });
317
+ };
318
+
319
+ exports.deleteFriend = deleteFriend;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
4
+
5
+ require("core-js/modules/es6.array.for-each");
6
+
7
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
8
+
9
+ _Object$defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+
13
+ var _user = require("./user");
14
+
15
+ _Object$keys(_user).forEach(function (key) {
16
+ if (key === "default" || key === "__esModule") return;
17
+
18
+ _Object$defineProperty(exports, key, {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _user[key];
22
+ }
23
+ });
24
+ });
25
+
26
+ var _channel = require("./channel");
27
+
28
+ _Object$keys(_channel).forEach(function (key) {
29
+ if (key === "default" || key === "__esModule") return;
30
+
31
+ _Object$defineProperty(exports, key, {
32
+ enumerable: true,
33
+ get: function get() {
34
+ return _channel[key];
35
+ }
36
+ });
37
+ });
38
+
39
+ var _message = require("./message");
40
+
41
+ _Object$keys(_message).forEach(function (key) {
42
+ if (key === "default" || key === "__esModule") return;
43
+
44
+ _Object$defineProperty(exports, key, {
45
+ enumerable: true,
46
+ get: function get() {
47
+ return _message[key];
48
+ }
49
+ });
50
+ });
51
+
52
+ var _friend = require("./friend");
53
+
54
+ _Object$keys(_friend).forEach(function (key) {
55
+ if (key === "default" || key === "__esModule") return;
56
+
57
+ _Object$defineProperty(exports, key, {
58
+ enumerable: true,
59
+ get: function get() {
60
+ return _friend[key];
61
+ }
62
+ });
63
+ });
64
+
65
+ var _invite = require("./invite");
66
+
67
+ _Object$keys(_invite).forEach(function (key) {
68
+ if (key === "default" || key === "__esModule") return;
69
+
70
+ _Object$defineProperty(exports, key, {
71
+ enumerable: true,
72
+ get: function get() {
73
+ return _invite[key];
74
+ }
75
+ });
76
+ });
77
+
78
+ var _subscription = require("./subscription");
79
+
80
+ _Object$keys(_subscription).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 _subscription[key];
87
+ }
88
+ });
89
+ });
90
+
91
+ var _messageread = require("./messageread");
92
+
93
+ _Object$keys(_messageread).forEach(function (key) {
94
+ if (key === "default" || key === "__esModule") return;
95
+
96
+ _Object$defineProperty(exports, key, {
97
+ enumerable: true,
98
+ get: function get() {
99
+ return _messageread[key];
100
+ }
101
+ });
102
+ });
103
+
104
+ var _memberinvitation = require("./memberinvitation");
105
+
106
+ _Object$keys(_memberinvitation).forEach(function (key) {
107
+ if (key === "default" || key === "__esModule") return;
108
+
109
+ _Object$defineProperty(exports, key, {
110
+ enumerable: true,
111
+ get: function get() {
112
+ return _memberinvitation[key];
113
+ }
114
+ });
115
+ });
116
+
117
+ var _memberreport = require("./memberreport");
118
+
119
+ _Object$keys(_memberreport).forEach(function (key) {
120
+ if (key === "default" || key === "__esModule") return;
121
+
122
+ _Object$defineProperty(exports, key, {
123
+ enumerable: true,
124
+ get: function get() {
125
+ return _memberreport[key];
126
+ }
127
+ });
128
+ });
@@ -0,0 +1,208 @@
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.createInvite = 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 createInvite = function createInvite(channelId, friendIds) {
167
+ return __awaiter(void 0, void 0, void 0, function () {
168
+ var token, projectId, endpoint, query;
169
+ return __generator(this, function (_a) {
170
+ switch (_a.label) {
171
+ 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 (\n $projectId: String!, \n $channelId: String!,\n $friendIds: String!\n ) {\n createInvite(\n input: {\n projectId: $projectId, \n channelId: $channelId,\n friendIds: $friendIds\n }\n ) {\n invite {\n id\n }\n }\n }\n ";
176
+ return [4
177
+ /*yield*/
178
+ , fetch(endpoint, {
179
+ method: 'POST',
180
+ headers: {
181
+ 'Authorization': 'Bearer ' + token,
182
+ 'Content-Type': 'application/json',
183
+ 'Accept': 'application/json'
184
+ },
185
+ body: (0, _stringify["default"])({
186
+ query: query,
187
+ variables: {
188
+ projectId: projectId,
189
+ channelId: channelId,
190
+ friendIds: friendIds
191
+ }
192
+ })
193
+ }).then(function (res) {
194
+ return res.json();
195
+ }).then(function (data) {
196
+ return data.data.createFriend.friendship;
197
+ })];
198
+
199
+ case 1:
200
+ return [2
201
+ /*return*/
202
+ , _a.sent()];
203
+ }
204
+ });
205
+ });
206
+ };
207
+
208
+ exports.createInvite = createInvite;