ncloudchat 1.0.13 → 1.0.16

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.
@@ -1,227 +0,0 @@
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.login = 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 login = function login(user_id, name, profile, token) {
167
- if (name === void 0) {
168
- name = '';
169
- }
170
-
171
- if (profile === void 0) {
172
- profile = '';
173
- }
174
-
175
- if (token === void 0) {
176
- token = '';
177
- }
178
-
179
- return __awaiter(void 0, void 0, void 0, function () {
180
- var projectId, endpoint, mutation;
181
- return __generator(this, function (_a) {
182
- switch (_a.label) {
183
- case 0:
184
- _CoreManager["default"].set("TOKEN", token);
185
-
186
- projectId = _CoreManager["default"].get("PROJECT_ID");
187
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
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 }";
189
- return [4
190
- /*yield*/
191
- , fetch(endpoint, {
192
- method: 'POST',
193
- headers: {
194
- 'Authorization': 'Bearer ' + token,
195
- 'X-PROJECT-ID': projectId,
196
- 'Content-Type': 'application/json',
197
- 'Accept': 'application/json'
198
- },
199
- body: (0, _stringify["default"])({
200
- query: mutation,
201
- variables: {
202
- projectId: projectId,
203
- userId: user_id,
204
- name: name,
205
- profile: profile,
206
- token: token
207
- }
208
- })
209
- }).then(function (res) {
210
- return res.json();
211
- }).then(function (data) {
212
- if (data.errors) throw data.errors[0];
213
- if (data.code) throw data;else if (data.data.login.token) {
214
- return data.data.login.token;
215
- } else return false;
216
- })];
217
-
218
- case 1:
219
- return [2
220
- /*return*/
221
- , _a.sent()];
222
- }
223
- });
224
- });
225
- };
226
-
227
- exports.login = login;
@@ -1,283 +0,0 @@
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.getChannels = exports.getChannel = 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 _Util = require("../Util");
24
-
25
- var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) {
27
- return value instanceof P ? value : new P(function (resolve) {
28
- resolve(value);
29
- });
30
- }
31
-
32
- return new (P || (P = _promise["default"]))(function (resolve, reject) {
33
- function fulfilled(value) {
34
- try {
35
- step(generator.next(value));
36
- } catch (e) {
37
- reject(e);
38
- }
39
- }
40
-
41
- function rejected(value) {
42
- try {
43
- step(generator["throw"](value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- }
48
-
49
- function step(result) {
50
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
51
- }
52
-
53
- step((generator = generator.apply(thisArg, _arguments || [])).next());
54
- });
55
- };
56
-
57
- var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
58
- var _ = {
59
- label: 0,
60
- sent: function sent() {
61
- if (t[0] & 1) throw t[1];
62
- return t[1];
63
- },
64
- trys: [],
65
- ops: []
66
- },
67
- f,
68
- y,
69
- t,
70
- g;
71
- return g = {
72
- next: verb(0),
73
- "throw": verb(1),
74
- "return": verb(2)
75
- }, typeof _symbol["default"] === "function" && (g[_iterator["default"]] = function () {
76
- return this;
77
- }), g;
78
-
79
- function verb(n) {
80
- return function (v) {
81
- return step([n, v]);
82
- };
83
- }
84
-
85
- function step(op) {
86
- if (f) throw new TypeError("Generator is already executing.");
87
-
88
- while (_) {
89
- try {
90
- 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;
91
- if (y = 0, t) op = [op[0] & 2, t.value];
92
-
93
- switch (op[0]) {
94
- case 0:
95
- case 1:
96
- t = op;
97
- break;
98
-
99
- case 4:
100
- _.label++;
101
- return {
102
- value: op[1],
103
- done: false
104
- };
105
-
106
- case 5:
107
- _.label++;
108
- y = op[1];
109
- op = [0];
110
- continue;
111
-
112
- case 7:
113
- op = _.ops.pop();
114
-
115
- _.trys.pop();
116
-
117
- continue;
118
-
119
- default:
120
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
121
- _ = 0;
122
- continue;
123
- }
124
-
125
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
126
- _.label = op[1];
127
- break;
128
- }
129
-
130
- if (op[0] === 6 && _.label < t[1]) {
131
- _.label = t[1];
132
- t = op;
133
- break;
134
- }
135
-
136
- if (t && _.label < t[2]) {
137
- _.label = t[2];
138
-
139
- _.ops.push(op);
140
-
141
- break;
142
- }
143
-
144
- if (t[2]) _.ops.pop();
145
-
146
- _.trys.pop();
147
-
148
- continue;
149
- }
150
-
151
- op = body.call(thisArg, _);
152
- } catch (e) {
153
- op = [6, e];
154
- y = 0;
155
- } finally {
156
- f = t = 0;
157
- }
158
- }
159
-
160
- if (op[0] & 5) throw op[1];
161
- return {
162
- value: op[0] ? op[1] : void 0,
163
- done: true
164
- };
165
- }
166
- };
167
-
168
- var getChannel = function getChannel(id) {
169
- return __awaiter(void 0, void 0, void 0, function () {
170
- var token, projectId, endpoint, query;
171
- return __generator(this, function (_a) {
172
- switch (_a.label) {
173
- 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 channel ($projectId: String!, $id: String!) {\n channel(projectId: $projectId, id:$id) {\n id\n project_id\n name\n user_id { \n id\n name\n nickname\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 created_at\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 ";
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': 'application/json',
192
- Accept: 'application/json'
193
- },
194
- body: (0, _stringify["default"])({
195
- query: query,
196
- variables: {
197
- projectId: projectId,
198
- id: id
199
- }
200
- })
201
- }).then(function (res) {
202
- return res.json();
203
- }).then(function (data) {
204
- if (data.errors) throw data.errors[0];
205
- if (data.code) throw data;
206
-
207
- if (data.data.channel) {
208
- data.data.channel.id = (0, _Util.ObjectId)(data.data.channel.id);
209
- return data.data.channel;
210
- }
211
-
212
- return false;
213
- })];
214
-
215
- case 1:
216
- return [2
217
- /*return*/
218
- , _a.sent()];
219
- }
220
- });
221
- });
222
- };
223
-
224
- exports.getChannel = getChannel;
225
-
226
- var getChannels = function getChannels(filter, sort, option) {
227
- return __awaiter(void 0, void 0, void 0, function () {
228
- var token, projectId, endpoint, query;
229
- return __generator(this, function (_a) {
230
- switch (_a.label) {
231
- case 0:
232
- token = _CoreManager["default"].get('TOKEN');
233
- if (!token) return [2
234
- /*return*/
235
- , null];
236
- projectId = _CoreManager["default"].get('PROJECT_ID');
237
- if (!projectId) return [2
238
- /*return*/
239
- , null];
240
- endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
241
- query = "\n query channels ($projectId: String!, $filter: String!, $sort: String, $option:String) {\n channels(projectId: $projectId, filter:$filter, sort:$sort, option:$option) {\n totalCount\n edges {\n node {\n id\n project_id\n name\n user_id { \n id\n name\n nickname\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 }\n ";
242
- return [4
243
- /*yield*/
244
- , fetch(endpoint, {
245
- method: 'POST',
246
- headers: {
247
- Authorization: 'Bearer ' + token,
248
- 'X-PROJECT-ID': projectId,
249
- 'Content-Type': 'application/json',
250
- Accept: 'application/json'
251
- },
252
- body: (0, _stringify["default"])({
253
- query: query,
254
- variables: {
255
- projectId: projectId,
256
- filter: filter,
257
- sort: sort,
258
- option: option
259
- }
260
- })
261
- }).then(function (res) {
262
- return res.json();
263
- }).then(function (data) {
264
- if (data.errors) throw data.errors[0];
265
- if (data.code) throw data;
266
-
267
- if (data.data.channels) {
268
- return data.data.channels.edges;
269
- }
270
-
271
- return [];
272
- })];
273
-
274
- case 1:
275
- return [2
276
- /*return*/
277
- , _a.sent()];
278
- }
279
- });
280
- });
281
- };
282
-
283
- exports.getChannels = getChannels;