ncloudchat 1.0.23 → 1.0.33

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 (138) hide show
  1. package/LICENSE.md +1 -1
  2. package/deploy.sh +1 -1
  3. package/esm/CloudChat.d.ts +436 -11
  4. package/esm/CloudChat.js +978 -304
  5. package/esm/CloudChat.js.map +1 -1
  6. package/esm/CoreManager.d.ts +6 -0
  7. package/esm/CoreManager.js +13 -4
  8. package/esm/CoreManager.js.map +1 -1
  9. package/esm/Dispatcher.d.ts +16 -0
  10. package/esm/Dispatcher.js +19 -4
  11. package/esm/Dispatcher.js.map +1 -1
  12. package/esm/Network.d.ts +7 -0
  13. package/esm/Network.js +96 -0
  14. package/esm/Network.js.map +1 -0
  15. package/esm/Type.d.ts +43 -0
  16. package/esm/Type.js +16 -0
  17. package/esm/Type.js.map +1 -1
  18. package/esm/Util.d.ts +13 -0
  19. package/esm/Util.js +13 -0
  20. package/esm/Util.js.map +1 -1
  21. package/esm/graphql/channel.d.ts +13 -0
  22. package/esm/graphql/channel.js +16 -0
  23. package/esm/graphql/channel.js.map +1 -0
  24. package/esm/graphql/friend.d.ts +11 -0
  25. package/esm/graphql/friend.js +13 -0
  26. package/esm/graphql/friend.js.map +1 -0
  27. package/esm/graphql/invite.d.ts +7 -0
  28. package/esm/graphql/invite.js +8 -0
  29. package/esm/graphql/invite.js.map +1 -0
  30. package/esm/graphql/member.d.ts +11 -0
  31. package/esm/graphql/member.js +13 -0
  32. package/esm/graphql/member.js.map +1 -0
  33. package/esm/graphql/message.d.ts +11 -0
  34. package/esm/graphql/message.js +13 -0
  35. package/esm/graphql/message.js.map +1 -0
  36. package/esm/graphql/pin.d.ts +10 -0
  37. package/esm/graphql/pin.js +12 -0
  38. package/esm/graphql/pin.js.map +1 -0
  39. package/esm/graphql/project.d.ts +6 -0
  40. package/esm/graphql/project.js +8 -0
  41. package/esm/graphql/project.js.map +1 -0
  42. package/esm/graphql/subscription.d.ts +11 -0
  43. package/esm/graphql/subscription.js +13 -0
  44. package/esm/graphql/subscription.js.map +1 -0
  45. package/esm/index.d.ts +6 -0
  46. package/esm/index.js +6 -0
  47. package/esm/index.js.map +1 -1
  48. package/esm/logger.d.ts +9 -3
  49. package/esm/logger.js +6 -0
  50. package/esm/logger.js.map +1 -1
  51. package/esm/mutations/channel.d.ts +50 -0
  52. package/esm/mutations/channel.js +97 -187
  53. package/esm/mutations/channel.js.map +1 -1
  54. package/esm/mutations/friend.d.ts +38 -0
  55. package/esm/mutations/friend.js +57 -119
  56. package/esm/mutations/friend.js.map +1 -1
  57. package/esm/mutations/index.d.ts +5 -3
  58. package/esm/mutations/index.js +5 -3
  59. package/esm/mutations/index.js.map +1 -1
  60. package/esm/mutations/invite.d.ts +15 -0
  61. package/esm/mutations/invite.js +23 -32
  62. package/esm/mutations/invite.js.map +1 -1
  63. package/esm/mutations/member.d.ts +39 -2
  64. package/esm/mutations/member.js +64 -111
  65. package/esm/mutations/member.js.map +1 -1
  66. package/esm/mutations/message.d.ts +35 -0
  67. package/esm/mutations/message.js +68 -45
  68. package/esm/mutations/message.js.map +1 -1
  69. package/esm/mutations/pin.d.ts +28 -0
  70. package/esm/mutations/pin.js +88 -0
  71. package/esm/mutations/pin.js.map +1 -0
  72. package/esm/mutations/subscription.d.ts +33 -1
  73. package/esm/mutations/subscription.js +51 -93
  74. package/esm/mutations/subscription.js.map +1 -1
  75. package/esm/queries/channel.d.ts +24 -0
  76. package/esm/queries/channel.js +37 -79
  77. package/esm/queries/channel.js.map +1 -1
  78. package/esm/queries/friend.d.ts +16 -0
  79. package/esm/queries/friend.js +25 -40
  80. package/esm/queries/friend.js.map +1 -1
  81. package/esm/queries/index.d.ts +7 -0
  82. package/esm/queries/index.js +7 -0
  83. package/esm/queries/index.js.map +1 -1
  84. package/esm/queries/member.d.ts +16 -0
  85. package/esm/queries/member.js +25 -40
  86. package/esm/queries/member.js.map +1 -1
  87. package/esm/queries/memberblocks.d.ts +16 -0
  88. package/esm/queries/memberblocks.js +25 -40
  89. package/esm/queries/memberblocks.js.map +1 -1
  90. package/esm/queries/message.d.ts +33 -0
  91. package/esm/queries/message.js +50 -111
  92. package/esm/queries/message.js.map +1 -1
  93. package/esm/queries/pin.d.ts +28 -0
  94. package/esm/queries/pin.js +92 -0
  95. package/esm/queries/pin.js.map +1 -0
  96. package/esm/queries/project.d.ts +14 -1
  97. package/esm/queries/project.js +21 -74
  98. package/esm/queries/project.js.map +1 -1
  99. package/esm/queries/subscription.d.ts +25 -0
  100. package/esm/queries/subscription.js +39 -76
  101. package/esm/queries/subscription.js.map +1 -1
  102. package/lib/CloudChat.js +1215 -364
  103. package/lib/CoreManager.js +13 -3
  104. package/lib/Dispatcher.js +25 -9
  105. package/lib/Network.js +229 -0
  106. package/lib/Type.js +19 -0
  107. package/lib/Util.js +15 -1
  108. package/lib/graphql/channel.js +32 -0
  109. package/lib/graphql/friend.js +27 -0
  110. package/lib/graphql/invite.js +18 -0
  111. package/lib/graphql/member.js +27 -0
  112. package/lib/graphql/message.js +27 -0
  113. package/lib/graphql/pin.js +25 -0
  114. package/lib/graphql/project.js +7 -0
  115. package/lib/graphql/subscription.js +27 -0
  116. package/lib/index.js +2 -2
  117. package/lib/logger.js +6 -0
  118. package/lib/mutations/channel.js +105 -178
  119. package/lib/mutations/friend.js +62 -115
  120. package/lib/mutations/index.js +23 -3
  121. package/lib/mutations/invite.js +27 -33
  122. package/lib/mutations/member.js +73 -100
  123. package/lib/mutations/message.js +88 -48
  124. package/lib/mutations/pin.js +229 -0
  125. package/lib/mutations/subscription.js +56 -95
  126. package/lib/queries/channel.js +40 -84
  127. package/lib/queries/friend.js +29 -45
  128. package/lib/queries/index.js +24 -3
  129. package/lib/queries/member.js +29 -45
  130. package/lib/queries/memberblocks.js +28 -44
  131. package/lib/queries/message.js +56 -109
  132. package/lib/queries/pin.js +243 -0
  133. package/lib/queries/project.js +1 -212
  134. package/lib/queries/subscription.js +42 -78
  135. package/package.json +20 -45
  136. package/tsconfig.json +1 -0
  137. package//353/260/260/355/217/254/354/210/234/354/204/234.md +8 -0
  138. package/package copy.json +0 -74
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.getPins = exports.getPin = void 0;
12
+
13
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
14
+
15
+ var _symbol = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol"));
16
+
17
+ var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
18
+
19
+ var _CoreManager = _interopRequireDefault(require("../CoreManager"));
20
+
21
+ var _Network = require("../Network");
22
+
23
+ var _pin = require("../graphql/pin");
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
+ */
31
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
32
+ function adopt(value) {
33
+ return value instanceof P ? value : new P(function (resolve) {
34
+ resolve(value);
35
+ });
36
+ }
37
+
38
+ return new (P || (P = _promise["default"]))(function (resolve, reject) {
39
+ function fulfilled(value) {
40
+ try {
41
+ step(generator.next(value));
42
+ } catch (e) {
43
+ reject(e);
44
+ }
45
+ }
46
+
47
+ function rejected(value) {
48
+ try {
49
+ step(generator["throw"](value));
50
+ } catch (e) {
51
+ reject(e);
52
+ }
53
+ }
54
+
55
+ function step(result) {
56
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
57
+ }
58
+
59
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
60
+ });
61
+ };
62
+
63
+ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
64
+ var _ = {
65
+ label: 0,
66
+ sent: function sent() {
67
+ if (t[0] & 1) throw t[1];
68
+ return t[1];
69
+ },
70
+ trys: [],
71
+ ops: []
72
+ },
73
+ f,
74
+ y,
75
+ t,
76
+ g;
77
+ return g = {
78
+ next: verb(0),
79
+ "throw": verb(1),
80
+ "return": verb(2)
81
+ }, typeof _symbol["default"] === "function" && (g[_iterator["default"]] = function () {
82
+ return this;
83
+ }), g;
84
+
85
+ function verb(n) {
86
+ return function (v) {
87
+ return step([n, v]);
88
+ };
89
+ }
90
+
91
+ function step(op) {
92
+ if (f) throw new TypeError("Generator is already executing.");
93
+
94
+ while (_) {
95
+ try {
96
+ 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;
97
+ if (y = 0, t) op = [op[0] & 2, t.value];
98
+
99
+ switch (op[0]) {
100
+ case 0:
101
+ case 1:
102
+ t = op;
103
+ break;
104
+
105
+ case 4:
106
+ _.label++;
107
+ return {
108
+ value: op[1],
109
+ done: false
110
+ };
111
+
112
+ case 5:
113
+ _.label++;
114
+ y = op[1];
115
+ op = [0];
116
+ continue;
117
+
118
+ case 7:
119
+ op = _.ops.pop();
120
+
121
+ _.trys.pop();
122
+
123
+ continue;
124
+
125
+ default:
126
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
127
+ _ = 0;
128
+ continue;
129
+ }
130
+
131
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
132
+ _.label = op[1];
133
+ break;
134
+ }
135
+
136
+ if (op[0] === 6 && _.label < t[1]) {
137
+ _.label = t[1];
138
+ t = op;
139
+ break;
140
+ }
141
+
142
+ if (t && _.label < t[2]) {
143
+ _.label = t[2];
144
+
145
+ _.ops.push(op);
146
+
147
+ break;
148
+ }
149
+
150
+ if (t[2]) _.ops.pop();
151
+
152
+ _.trys.pop();
153
+
154
+ continue;
155
+ }
156
+
157
+ op = body.call(thisArg, _);
158
+ } catch (e) {
159
+ op = [6, e];
160
+ y = 0;
161
+ } finally {
162
+ f = t = 0;
163
+ }
164
+ }
165
+
166
+ if (op[0] & 5) throw op[1];
167
+ return {
168
+ value: op[0] ? op[1] : void 0,
169
+ done: true
170
+ };
171
+ }
172
+ };
173
+
174
+ /**
175
+ * Get data of a single pin from the endpoint.
176
+ *
177
+ * @async
178
+ * @function getPin
179
+ * @param {string} channelId - An id of the channel.
180
+ * @param {string} id - An id of the pin.
181
+ * @returns {Promise<any>} The data of the pin.
182
+ */
183
+ var getPin = function getPin(channelId, id) {
184
+ return __awaiter(void 0, void 0, void 0, function () {
185
+ return __generator(this, function (_a) {
186
+ switch (_a.label) {
187
+ case 0:
188
+ return [4
189
+ /*yield*/
190
+ , (0, _Network.fetchData)("pin", _pin.getPinQuery, {
191
+ projectId: _CoreManager["default"].get("PROJECT_ID"),
192
+ channelId: channelId,
193
+ id: id
194
+ })];
195
+
196
+ case 1:
197
+ return [2
198
+ /*return*/
199
+ , _a.sent()];
200
+ }
201
+ });
202
+ });
203
+ };
204
+ /**
205
+ * Get data of multiple pins.
206
+ *
207
+ * @async
208
+ * @function getPins
209
+ * @param {string} channelId - An id of the channel.
210
+ * @param {string} filter - Field value for filter.
211
+ * @param {string} sort - Field value for sorting.
212
+ * @param {string} option - Optional option: ex) offset, per_page.
213
+ * @returns {Promise<any[]>} An array of data of all pins.
214
+ */
215
+
216
+
217
+ exports.getPin = getPin;
218
+
219
+ var getPins = function getPins(channelId, filter, sort, option) {
220
+ return __awaiter(void 0, void 0, void 0, function () {
221
+ return __generator(this, function (_a) {
222
+ switch (_a.label) {
223
+ case 0:
224
+ return [4
225
+ /*yield*/
226
+ , (0, _Network.fetchData)("pins", _pin.getPinsQuery, {
227
+ projectId: _CoreManager["default"].get("PROJECT_ID"),
228
+ channelId: channelId,
229
+ filter: filter,
230
+ sort: sort,
231
+ option: option
232
+ })];
233
+
234
+ case 1:
235
+ return [2
236
+ /*return*/
237
+ , _a.sent()];
238
+ }
239
+ });
240
+ });
241
+ };
242
+
243
+ exports.getPins = getPins;
@@ -1,218 +1,7 @@
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
 
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
- });
10
-
11
- exports.getProject = 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 getProject = function getProject() {
167
- return __awaiter(void 0, void 0, void 0, function () {
168
- var token, projectId, url, endpoint, query, CONTENT_TYPE, response, json;
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
- url = _CoreManager["default"].get('SERVER_URL');
181
- endpoint = url + "/graphql";
182
- query = "\n query project($id: ID!) {\n project(id:$id) { \n ncp_project_id\n name\n }\n }\n ";
183
- CONTENT_TYPE = 'application/json';
184
- return [4
185
- /*yield*/
186
- , fetch(endpoint, {
187
- method: 'POST',
188
- headers: {
189
- 'Authorization': "Bearer " + token,
190
- 'X-PROJECT-ID': projectId,
191
- 'Content-Type': CONTENT_TYPE,
192
- 'Accept': CONTENT_TYPE
193
- },
194
- body: (0, _stringify["default"])({
195
- query: query,
196
- variables: {
197
- id: projectId
198
- }
199
- })
200
- })];
201
-
202
- case 1:
203
- response = _a.sent();
204
- return [4
205
- /*yield*/
206
- , response.json()];
207
-
208
- case 2:
209
- json = _a.sent();
210
- return [2
211
- /*return*/
212
- , json.data.project];
213
- }
214
- });
215
- });
216
- };
217
-
218
- exports.getProject = getProject;
7
+ });
@@ -1,27 +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
11
  exports.getSubscriptions = exports.getSubscription = void 0;
12
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"));
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 _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
17
+ var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
20
18
 
21
19
  var _CoreManager = _interopRequireDefault(require("../CoreManager"));
22
20
 
23
- var _Util = require("../Util");
21
+ var _Network = require("../Network");
22
+
23
+ var _subscription = require("../graphql/subscription");
24
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
+ */
25
31
  var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
26
32
  function adopt(value) {
27
33
  return value instanceof P ? value : new P(function (resolve) {
@@ -165,50 +171,26 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
165
171
  }
166
172
  };
167
173
 
174
+ /**
175
+ * Get subscription data of the user.
176
+ *
177
+ * @async
178
+ * @function getSubscription
179
+ * @param {string} channelId - The id of a channel.
180
+ * @param {string} id
181
+ * @returns {Promise<any>}
182
+ */
168
183
  var getSubscription = function getSubscription(channelId, id) {
169
184
  return __awaiter(void 0, void 0, void 0, function () {
170
- var token, projectId, endpoint, query;
171
185
  return __generator(this, function (_a) {
172
186
  switch (_a.label) {
173
187
  case 0:
174
- token = _CoreManager["default"].get("TOKEN");
175
- if (!token) return [2
176
- /*return*/
177
- , null];
178
- projectId = _CoreManager["default"].get("PROJECT_ID");
179
- if (!projectId) return [2
180
- /*return*/
181
- , null];
182
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
183
- query = "\n query subscription ($projectId: String!,$channelId: String!, $id: String!) {\n subscription(projectId: $projectId, channelId: $channelId, id:$id) {\n id\n user {\n name\n profile\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 ";
184
188
  return [4
185
189
  /*yield*/
186
- , fetch(endpoint, {
187
- method: 'POST',
188
- headers: {
189
- 'Authorization': 'Bearer ' + token,
190
- 'X-PROJECT-ID': projectId,
191
- 'Content-Type': 'application/json',
192
- 'Accept': 'application/json'
193
- },
194
- body: (0, _stringify["default"])({
195
- query: query,
196
- variables: {
197
- projectId: projectId,
198
- channelId: channelId,
199
- id: id
200
- }
201
- })
202
- }).then(function (res) {
203
- return res.json();
204
- }).then(function (data) {
205
- if (data.errors) throw data.errors[0];
206
- if (data.code) throw data;
207
-
208
- if (data.data.subscription) {
209
- data.data.subscription.id = (0, _Util.ObjectId)(data.data.subscription.id);
210
- return data.data.subscription;
211
- }
190
+ , (0, _Network.fetchData)("subscription", _subscription.getSubscriptionQuery, {
191
+ projectId: _CoreManager["default"].get("PROJECT_ID"),
192
+ channelId: channelId,
193
+ id: id
212
194
  })];
213
195
 
214
196
  case 1:
@@ -219,50 +201,32 @@ var getSubscription = function getSubscription(channelId, id) {
219
201
  });
220
202
  });
221
203
  };
204
+ /**
205
+ * Get a list of subscibed member of the channel.
206
+ *
207
+ * @async
208
+ * @function getSubscriptions
209
+ * @param {string} filter - Field value for filter.
210
+ * @param {string} sort - Field value for sorting.
211
+ * @param {string} option - Optional option: ex) offset, per_page.
212
+ * @returns {Promise<any>}
213
+ */
214
+
222
215
 
223
216
  exports.getSubscription = getSubscription;
224
217
 
225
218
  var getSubscriptions = function getSubscriptions(filter, sort, option) {
226
219
  return __awaiter(void 0, void 0, void 0, function () {
227
- var token, projectId, endpoint, query;
228
220
  return __generator(this, function (_a) {
229
221
  switch (_a.label) {
230
222
  case 0:
231
- token = _CoreManager["default"].get("TOKEN");
232
- if (!token) return [2
233
- /*return*/
234
- , null];
235
- projectId = _CoreManager["default"].get("PROJECT_ID");
236
- if (!projectId) return [2
237
- /*return*/
238
- , null];
239
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
240
- 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 name\n profile\n country\n }\n channel_id\n user_id\n online\n push\n created_at\n }\n }\n }\n }\n ";
241
223
  return [4
242
224
  /*yield*/
243
- , fetch(endpoint, {
244
- method: 'POST',
245
- headers: {
246
- 'Authorization': 'Bearer ' + token,
247
- 'X-PROJECT-ID': projectId,
248
- 'Content-Type': 'application/json',
249
- 'Accept': 'application/json'
250
- },
251
- body: (0, _stringify["default"])({
252
- query: query,
253
- variables: {
254
- projectId: projectId,
255
- option: option,
256
- filter: filter,
257
- sort: sort
258
- }
259
- })
260
- }).then(function (res) {
261
- return res.json();
262
- }).then(function (data) {
263
- if (data.errors) throw data.errors[0];
264
- if (data.code) throw data;
265
- return data.data.subscriptions.edges;
225
+ , (0, _Network.fetchData)("subscriptions", _subscription.getSubscriptionsQuery, {
226
+ projectId: _CoreManager["default"].get("PROJECT_ID"),
227
+ option: option,
228
+ filter: filter,
229
+ sort: sort
266
230
  })];
267
231
 
268
232
  case 1: