ncloudchat 1.0.33 → 1.0.36
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/README.md +17 -409
- package/{deploy.sh → deploy.sh.bak} +0 -0
- package/dist/ncloudchat.d.ts +1298 -0
- package/dist/ncloudchat.min.js +1 -0
- package/esm/CloudChat.js +72 -62
- package/esm/CloudChat.js.map +1 -1
- package/esm/CoreManager.js +3 -1
- package/esm/CoreManager.js.map +1 -1
- package/esm/Dispatcher.js +3 -1
- package/esm/Dispatcher.js.map +1 -1
- package/esm/Network.js +14 -7
- package/esm/Network.js.map +1 -1
- package/esm/Type.js +7 -4
- package/esm/Type.js.map +1 -1
- package/esm/Util.js +4 -1
- package/esm/Util.js.map +1 -1
- package/esm/graphql/channel.js +10 -7
- package/esm/graphql/channel.js.map +1 -1
- package/esm/graphql/friend.js +8 -5
- package/esm/graphql/friend.js.map +1 -1
- package/esm/graphql/invite.js +4 -1
- package/esm/graphql/invite.js.map +1 -1
- package/esm/graphql/member.js +8 -5
- package/esm/graphql/member.js.map +1 -1
- package/esm/graphql/message.js +8 -5
- package/esm/graphql/message.js.map +1 -1
- package/esm/graphql/pin.js +7 -4
- package/esm/graphql/pin.js.map +1 -1
- package/esm/graphql/subscription.js +8 -5
- package/esm/graphql/subscription.js.map +1 -1
- package/esm/index.js +8 -2
- package/esm/index.js.map +1 -1
- package/esm/logger.js +6 -1
- package/esm/logger.js.map +1 -1
- package/esm/mutations/channel.js +29 -18
- package/esm/mutations/channel.js.map +1 -1
- package/esm/mutations/friend.js +25 -15
- package/esm/mutations/friend.js.map +1 -1
- package/esm/mutations/index.js +23 -7
- package/esm/mutations/index.js.map +1 -1
- package/esm/mutations/invite.js +13 -6
- package/esm/mutations/invite.js.map +1 -1
- package/esm/mutations/member.js +22 -13
- package/esm/mutations/member.js.map +1 -1
- package/esm/mutations/message.js +24 -15
- package/esm/mutations/message.js.map +1 -1
- package/esm/mutations/pin.js +17 -9
- package/esm/mutations/pin.js.map +1 -1
- package/esm/mutations/subscription.js +21 -12
- package/esm/mutations/subscription.js.map +1 -1
- package/esm/queries/channel.js +17 -9
- package/esm/queries/channel.js.map +1 -1
- package/esm/queries/friend.js +13 -6
- package/esm/queries/friend.js.map +1 -1
- package/esm/queries/index.js +24 -8
- package/esm/queries/index.js.map +1 -1
- package/esm/queries/member.js +13 -6
- package/esm/queries/member.js.map +1 -1
- package/esm/queries/memberblocks.js +13 -6
- package/esm/queries/memberblocks.js.map +1 -1
- package/esm/queries/message.js +21 -12
- package/esm/queries/message.js.map +1 -1
- package/esm/queries/pin.js +17 -9
- package/esm/queries/pin.js.map +1 -1
- package/esm/queries/project.js +2 -1
- package/esm/queries/project.js.map +1 -1
- package/esm/queries/subscription.js +17 -9
- package/esm/queries/subscription.js.map +1 -1
- package/package.json +2 -4
- package/tsconfig.json +1 -1
- package/lib/CloudChat.js +0 -2661
- package/lib/CoreManager.js +0 -45
- package/lib/Dispatcher.js +0 -125
- package/lib/Network.js +0 -229
- package/lib/Type.js +0 -44
- package/lib/Util.js +0 -32
- package/lib/graphql/channel.js +0 -32
- package/lib/graphql/friend.js +0 -27
- package/lib/graphql/invite.js +0 -18
- package/lib/graphql/member.js +0 -27
- package/lib/graphql/message.js +0 -27
- package/lib/graphql/pin.js +0 -25
- package/lib/graphql/project.js +0 -7
- package/lib/graphql/subscription.js +0 -27
- package/lib/index.js +0 -18
- package/lib/logger.js +0 -33
- package/lib/mutations/channel.js +0 -354
- package/lib/mutations/friend.js +0 -299
- package/lib/mutations/index.js +0 -109
- package/lib/mutations/invite.js +0 -205
- package/lib/mutations/member.js +0 -304
- package/lib/mutations/message.js +0 -300
- package/lib/mutations/pin.js +0 -229
- package/lib/mutations/subscription.js +0 -281
- package/lib/queries/channel.js +0 -239
- package/lib/queries/friend.js +0 -207
- package/lib/queries/index.js +0 -123
- package/lib/queries/member.js +0 -207
- package/lib/queries/memberblocks.js +0 -207
- package/lib/queries/message.js +0 -273
- package/lib/queries/pin.js +0 -243
- package/lib/queries/project.js +0 -7
- package/lib/queries/subscription.js +0 -241
- package/ncloudchat_javascript.md +0 -289
- package//353/260/260/355/217/254/354/210/234/354/204/234.md +0 -8
package/lib/mutations/member.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
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.login = exports.deleteMemberBlock = exports.createMemberBlock = 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 _member = require("../graphql/member");
|
|
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
|
-
* Login a user
|
|
176
|
-
*
|
|
177
|
-
* @async
|
|
178
|
-
* @function login
|
|
179
|
-
* @param {string} user_id - The id of a user loggin in.
|
|
180
|
-
* @param {string} name
|
|
181
|
-
* @param {string} profile
|
|
182
|
-
* @param {string} token
|
|
183
|
-
* @returns {Promise<any>}
|
|
184
|
-
*/
|
|
185
|
-
var login = function login(user_id, name, profile, token, customField) {
|
|
186
|
-
if (name === void 0) {
|
|
187
|
-
name = "";
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (profile === void 0) {
|
|
191
|
-
profile = "";
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (token === void 0) {
|
|
195
|
-
token = "";
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (customField === void 0) {
|
|
199
|
-
customField = "";
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
203
|
-
return __generator(this, function (_a) {
|
|
204
|
-
switch (_a.label) {
|
|
205
|
-
case 0:
|
|
206
|
-
_CoreManager["default"].set("TOKEN", token);
|
|
207
|
-
|
|
208
|
-
return [4
|
|
209
|
-
/*yield*/
|
|
210
|
-
, (0, _Network.fetchData)("login", _member.loginQuery, {
|
|
211
|
-
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
212
|
-
userId: user_id,
|
|
213
|
-
name: name,
|
|
214
|
-
profile: profile,
|
|
215
|
-
token: token,
|
|
216
|
-
customField: customField
|
|
217
|
-
})];
|
|
218
|
-
|
|
219
|
-
case 1:
|
|
220
|
-
return [2
|
|
221
|
-
/*return*/
|
|
222
|
-
, _a.sent()];
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
/**
|
|
228
|
-
* Create a member block followed by the getMemberBlockSchema.
|
|
229
|
-
* The member block is to used to ban a member.
|
|
230
|
-
*
|
|
231
|
-
* @async
|
|
232
|
-
* @function createMemberBlock
|
|
233
|
-
* @param {string} channelId - The id of a channel.
|
|
234
|
-
* @param {string} memberId - The id of a member.
|
|
235
|
-
* @param {string} options
|
|
236
|
-
* @returns {Promise<any>}
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
exports.login = login;
|
|
241
|
-
|
|
242
|
-
var createMemberBlock = function createMemberBlock(channelId, memberId, options) {
|
|
243
|
-
if (options === void 0) {
|
|
244
|
-
options = "";
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
248
|
-
return __generator(this, function (_a) {
|
|
249
|
-
switch (_a.label) {
|
|
250
|
-
case 0:
|
|
251
|
-
return [4
|
|
252
|
-
/*yield*/
|
|
253
|
-
, (0, _Network.fetchData)("createMemberBlock", _member.createMemberBlockQuery, {
|
|
254
|
-
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
255
|
-
channelId: channelId,
|
|
256
|
-
memberId: memberId,
|
|
257
|
-
options: options
|
|
258
|
-
})];
|
|
259
|
-
|
|
260
|
-
case 1:
|
|
261
|
-
return [2
|
|
262
|
-
/*return*/
|
|
263
|
-
, _a.sent()];
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* Delete a member block.
|
|
270
|
-
* This is used to unban a member from a channel.
|
|
271
|
-
*
|
|
272
|
-
* @async
|
|
273
|
-
* @function deleteMemberBlock
|
|
274
|
-
* @param {string} channelId - The id of a channel that the member is in.
|
|
275
|
-
* @param {string} memberId - The id of a member to be deleted.
|
|
276
|
-
* @returns {Promise<any>}
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
exports.createMemberBlock = createMemberBlock;
|
|
281
|
-
|
|
282
|
-
var deleteMemberBlock = function deleteMemberBlock(channelId, memberId) {
|
|
283
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
284
|
-
return __generator(this, function (_a) {
|
|
285
|
-
switch (_a.label) {
|
|
286
|
-
case 0:
|
|
287
|
-
return [4
|
|
288
|
-
/*yield*/
|
|
289
|
-
, (0, _Network.fetchData)("deleteMemberBlock", _member.deleteMemberBlockQuery, {
|
|
290
|
-
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
291
|
-
channelId: channelId,
|
|
292
|
-
memberId: memberId
|
|
293
|
-
})];
|
|
294
|
-
|
|
295
|
-
case 1:
|
|
296
|
-
return [2
|
|
297
|
-
/*return*/
|
|
298
|
-
, _a.sent()];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
exports.deleteMemberBlock = deleteMemberBlock;
|
package/lib/mutations/message.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
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.upload = exports.translate = exports.message = 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 _message = require("../graphql/message");
|
|
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
|
-
* Trasnslate a text block to the target language from the source language.
|
|
176
|
-
*
|
|
177
|
-
* @async
|
|
178
|
-
* @function translate
|
|
179
|
-
* @param {string} channelId - The id of a channel.
|
|
180
|
-
* @param {string} srcLang - The source language.
|
|
181
|
-
* @param {string} targetLang - The target language.
|
|
182
|
-
* @param {string} text - The text block to be translated.
|
|
183
|
-
* @returns {Promise<any>}
|
|
184
|
-
*/
|
|
185
|
-
var translate = function translate(channelId, srcLang, targetLang, text) {
|
|
186
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
-
return __generator(this, function (_a) {
|
|
188
|
-
switch (_a.label) {
|
|
189
|
-
case 0:
|
|
190
|
-
return [4
|
|
191
|
-
/*yield*/
|
|
192
|
-
, (0, _Network.fetchData)("", _message.translateQuery, {
|
|
193
|
-
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
194
|
-
channelId: channelId,
|
|
195
|
-
srcLang: srcLang,
|
|
196
|
-
targetLang: targetLang,
|
|
197
|
-
text: text
|
|
198
|
-
})];
|
|
199
|
-
|
|
200
|
-
case 1:
|
|
201
|
-
return [2
|
|
202
|
-
/*return*/
|
|
203
|
-
, _a.sent()];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* Upload a file to a channel. Only supports png, jpg, jpeg file types.
|
|
210
|
-
*
|
|
211
|
-
* @async
|
|
212
|
-
* @function upload
|
|
213
|
-
* @param {string} channelId - The id of a channel.
|
|
214
|
-
* @param {any} file - An image file.
|
|
215
|
-
* @returns {Promise<any>}
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
exports.translate = translate;
|
|
220
|
-
|
|
221
|
-
var upload = function upload(channelId, file) {
|
|
222
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
223
|
-
var token, language, endpoint, form, result;
|
|
224
|
-
return __generator(this, function (_a) {
|
|
225
|
-
switch (_a.label) {
|
|
226
|
-
case 0:
|
|
227
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
228
|
-
|
|
229
|
-
if (!token) {
|
|
230
|
-
console.error("Token is not found");
|
|
231
|
-
return [2
|
|
232
|
-
/*return*/
|
|
233
|
-
];
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
language = _CoreManager["default"].get("LANGUAGE");
|
|
237
|
-
endpoint = _CoreManager["default"].get("SERVER_URL") + "/upload/" + channelId;
|
|
238
|
-
form = new FormData();
|
|
239
|
-
form.append("channelId", channelId);
|
|
240
|
-
form.append("upload", "1");
|
|
241
|
-
form.append("file", file);
|
|
242
|
-
return [4
|
|
243
|
-
/*yield*/
|
|
244
|
-
, fetch(endpoint, {
|
|
245
|
-
method: "POST",
|
|
246
|
-
headers: {
|
|
247
|
-
Authorization: "Bearer " + token,
|
|
248
|
-
"Language": language,
|
|
249
|
-
"X-PROJECT-ID": _CoreManager["default"].get("PROJECT_ID"),
|
|
250
|
-
projectId: _CoreManager["default"].get("PROJECT_ID")
|
|
251
|
-
},
|
|
252
|
-
body: form
|
|
253
|
-
}).then(function (res) {
|
|
254
|
-
return res.json();
|
|
255
|
-
})];
|
|
256
|
-
|
|
257
|
-
case 1:
|
|
258
|
-
result = _a.sent();
|
|
259
|
-
return [2
|
|
260
|
-
/*return*/
|
|
261
|
-
, result];
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
};
|
|
266
|
-
/**
|
|
267
|
-
* Send a Message
|
|
268
|
-
*
|
|
269
|
-
* @async
|
|
270
|
-
* @function translate
|
|
271
|
-
* @param {string} data - The id of a message.
|
|
272
|
-
* @returns {Promise<any>}
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
exports.upload = upload;
|
|
277
|
-
|
|
278
|
-
var message = function message(data) {
|
|
279
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
280
|
-
return __generator(this, function (_a) {
|
|
281
|
-
switch (_a.label) {
|
|
282
|
-
case 0:
|
|
283
|
-
return [4
|
|
284
|
-
/*yield*/
|
|
285
|
-
, (0, _Network.fetchData)("createChannelMessage", _message.messageQuery, {
|
|
286
|
-
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
287
|
-
channelId: data.channelId,
|
|
288
|
-
content: data.message
|
|
289
|
-
})];
|
|
290
|
-
|
|
291
|
-
case 1:
|
|
292
|
-
return [2
|
|
293
|
-
/*return*/
|
|
294
|
-
, _a.sent()];
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
exports.message = message;
|