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.
- package/esm/mutations/channel.js +5 -5
- package/esm/mutations/channel.js.map +1 -1
- package/package-lock.json +36183 -0
- package/package.json +1 -1
- package/lib/CloudChat.js +0 -1676
- package/lib/CoreManager.js +0 -35
- package/lib/Dispatcher.js +0 -109
- package/lib/Type.js +0 -25
- package/lib/Util.js +0 -18
- package/lib/logger.js +0 -27
- package/lib/mutations/channel.js +0 -421
- package/lib/mutations/friend.js +0 -352
- package/lib/mutations/index.js +0 -89
- package/lib/mutations/invite.js +0 -211
- package/lib/mutations/message.js +0 -252
- package/lib/mutations/subscription.js +0 -317
- package/lib/mutations/user.js +0 -227
- package/lib/queries/channel.js +0 -283
- package/lib/queries/friend.js +0 -223
- package/lib/queries/index.js +0 -89
- package/lib/queries/member.js +0 -223
- package/lib/queries/message.js +0 -326
- package/lib/queries/project.js +0 -218
- package/lib/queries/subscription.js +0 -277
package/lib/mutations/message.js
DELETED
|
@@ -1,252 +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.upload = exports.translate = 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 translate = function translate(channelId, srcLang, targetLang, text) {
|
|
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 ($projectId: String!, $channelId: String!, $srcLang: String!, $text: String!, $targetLang:String!) {\n translation(input: {projectId:$projectId, channelId:$channelId,srcLang:$srcLang,targetLang:$targetLang, text:$text }) {\n result\n {\n status\n message\n lang\n }\n }\n }\n ";
|
|
176
|
-
return [4
|
|
177
|
-
/*yield*/
|
|
178
|
-
, fetch(endpoint, {
|
|
179
|
-
method: 'POST',
|
|
180
|
-
headers: {
|
|
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
|
-
channelId: channelId,
|
|
191
|
-
srcLang: srcLang,
|
|
192
|
-
targetLang: targetLang,
|
|
193
|
-
text: text
|
|
194
|
-
}
|
|
195
|
-
})
|
|
196
|
-
}).then(function (res) {
|
|
197
|
-
return res.json();
|
|
198
|
-
}).then(function (data) {
|
|
199
|
-
if (data.errors) throw data.errors[0];
|
|
200
|
-
if (data.code) throw data;
|
|
201
|
-
return data;
|
|
202
|
-
})];
|
|
203
|
-
|
|
204
|
-
case 1:
|
|
205
|
-
return [2
|
|
206
|
-
/*return*/
|
|
207
|
-
, _a.sent()];
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
exports.translate = translate;
|
|
214
|
-
|
|
215
|
-
var upload = function upload(channelId, file) {
|
|
216
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
217
|
-
var token, projectId, endpoint, form, result;
|
|
218
|
-
return __generator(this, function (_a) {
|
|
219
|
-
switch (_a.label) {
|
|
220
|
-
case 0:
|
|
221
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
222
|
-
projectId = _CoreManager["default"].get("PROJECT_ID");
|
|
223
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/upload';
|
|
224
|
-
form = new FormData();
|
|
225
|
-
form.append('file', file);
|
|
226
|
-
form.append('channelId', channelId);
|
|
227
|
-
form.append('upload', '1');
|
|
228
|
-
return [4
|
|
229
|
-
/*yield*/
|
|
230
|
-
, fetch(endpoint, {
|
|
231
|
-
method: 'POST',
|
|
232
|
-
headers: {
|
|
233
|
-
'Authorization': 'Bearer ' + token,
|
|
234
|
-
'X-PROJECT-ID': projectId,
|
|
235
|
-
'projectid': projectId
|
|
236
|
-
},
|
|
237
|
-
body: form
|
|
238
|
-
}).then(function (res) {
|
|
239
|
-
return res.json();
|
|
240
|
-
})];
|
|
241
|
-
|
|
242
|
-
case 1:
|
|
243
|
-
result = _a.sent();
|
|
244
|
-
return [2
|
|
245
|
-
/*return*/
|
|
246
|
-
, result];
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
exports.upload = upload;
|
|
@@ -1,317 +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.updateSubscription = exports.deleteSubscription = exports.createSubscription = 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 createSubscription = function createSubscription(channelId, option) {
|
|
167
|
-
if (option === void 0) {
|
|
168
|
-
option = "";
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
172
|
-
var token, endpoint, projectId, query;
|
|
173
|
-
return __generator(this, function (_a) {
|
|
174
|
-
switch (_a.label) {
|
|
175
|
-
case 0:
|
|
176
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
177
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
178
|
-
projectId = _CoreManager["default"].get('PROJECT_ID');
|
|
179
|
-
query = "\n mutation (\n $projectId: String!, \n $channelId: String!,\n $option: String,\n ) {\n createSubscription (\n input: {\n projectId: $projectId, \n channelId: $channelId,\n option: $option\n }\n ) {\n subscription {\n id\n channel_id\n user_id\n language\n push\n mute\n online\n uniquekey\n created_at\n updated_at\n }\n }\n }\n ";
|
|
180
|
-
return [4
|
|
181
|
-
/*yield*/
|
|
182
|
-
, fetch(endpoint, {
|
|
183
|
-
method: 'POST',
|
|
184
|
-
headers: {
|
|
185
|
-
'Authorization': 'Bearer ' + token,
|
|
186
|
-
'X-PROJECT-ID': projectId,
|
|
187
|
-
'Content-Type': 'application/json',
|
|
188
|
-
'Accept': 'application/json'
|
|
189
|
-
},
|
|
190
|
-
body: (0, _stringify["default"])({
|
|
191
|
-
query: query,
|
|
192
|
-
variables: {
|
|
193
|
-
projectId: projectId,
|
|
194
|
-
channelId: channelId,
|
|
195
|
-
option: option
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
}).then(function (res) {
|
|
199
|
-
return res.json();
|
|
200
|
-
}).then(function (data) {
|
|
201
|
-
if (data.errors) {
|
|
202
|
-
throw data.errors[0];
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return data.data.createSubscription.subscription;
|
|
206
|
-
})];
|
|
207
|
-
|
|
208
|
-
case 1:
|
|
209
|
-
return [2
|
|
210
|
-
/*return*/
|
|
211
|
-
, _a.sent()];
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
exports.createSubscription = createSubscription;
|
|
218
|
-
|
|
219
|
-
var deleteSubscription = function deleteSubscription(channelId) {
|
|
220
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
221
|
-
var token, endpoint, projectId, query;
|
|
222
|
-
return __generator(this, function (_a) {
|
|
223
|
-
switch (_a.label) {
|
|
224
|
-
case 0:
|
|
225
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
226
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
227
|
-
projectId = _CoreManager["default"].get('PROJECT_ID');
|
|
228
|
-
query = "\n mutation (\n $projectId: String!, \n $channelId: String!\n ) {\n deleteSubscription (\n input: {\n projectId: $projectId, \n channelId: $channelId\n }\n ) {\n subscription {\n id\n channel_id\n user_id\n language\n push\n online\n uniquekey\n created_at\n updated_at\n }\n }\n }\n ";
|
|
229
|
-
return [4
|
|
230
|
-
/*yield*/
|
|
231
|
-
, fetch(endpoint, {
|
|
232
|
-
method: 'POST',
|
|
233
|
-
headers: {
|
|
234
|
-
'Authorization': 'Bearer ' + token,
|
|
235
|
-
'X-PROJECT-ID': projectId,
|
|
236
|
-
'Content-Type': 'application/json',
|
|
237
|
-
'Accept': 'application/json'
|
|
238
|
-
},
|
|
239
|
-
body: (0, _stringify["default"])({
|
|
240
|
-
query: query,
|
|
241
|
-
variables: {
|
|
242
|
-
projectId: projectId,
|
|
243
|
-
channelId: channelId
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
}).then(function (res) {
|
|
247
|
-
return res.json();
|
|
248
|
-
}).then(function (data) {
|
|
249
|
-
if (data.errors) {
|
|
250
|
-
throw data.errors[0];
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return data.data.deleteSubscription.subscription;
|
|
254
|
-
})];
|
|
255
|
-
|
|
256
|
-
case 1:
|
|
257
|
-
return [2
|
|
258
|
-
/*return*/
|
|
259
|
-
, _a.sent()];
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
exports.deleteSubscription = deleteSubscription;
|
|
266
|
-
|
|
267
|
-
var updateSubscription = function updateSubscription(channelId, mark, option) {
|
|
268
|
-
if (option === void 0) {
|
|
269
|
-
option = "";
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
273
|
-
var token, endpoint, projectId, query;
|
|
274
|
-
return __generator(this, function (_a) {
|
|
275
|
-
switch (_a.label) {
|
|
276
|
-
case 0:
|
|
277
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
278
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
279
|
-
projectId = _CoreManager["default"].get('PROJECT_ID');
|
|
280
|
-
query = "\n mutation ($projectId: String!, $channelId: String!, $mark: MarkInput, $option: String!) {\n updateSubscription(input: {projectId: $projectId,channelId: $channelId, mark: $mark, option: $option}) {\n subscription {\n id\n channel_id\n user_id\n language\n push\n online\n mute\n uniquekey\n mark {\n user_id\n message_id\n sort_id\n unread\n }\n created_at\n updated_at\n }\n }\n }\n ";
|
|
281
|
-
return [4
|
|
282
|
-
/*yield*/
|
|
283
|
-
, fetch(endpoint, {
|
|
284
|
-
method: 'POST',
|
|
285
|
-
headers: {
|
|
286
|
-
'Authorization': 'Bearer ' + token,
|
|
287
|
-
'X-PROJECT-ID': projectId,
|
|
288
|
-
'Content-Type': 'application/json',
|
|
289
|
-
'Accept': 'application/json'
|
|
290
|
-
},
|
|
291
|
-
body: (0, _stringify["default"])({
|
|
292
|
-
query: query,
|
|
293
|
-
variables: {
|
|
294
|
-
projectId: projectId,
|
|
295
|
-
channelId: channelId,
|
|
296
|
-
mark: mark,
|
|
297
|
-
option: option
|
|
298
|
-
}
|
|
299
|
-
})
|
|
300
|
-
}).then(function (res) {
|
|
301
|
-
return res.json();
|
|
302
|
-
}).then(function (data) {
|
|
303
|
-
if (data.errors) throw data.errors[0];
|
|
304
|
-
if (data.code) throw data;
|
|
305
|
-
return data.data.updateSubscription.subscription;
|
|
306
|
-
})];
|
|
307
|
-
|
|
308
|
-
case 1:
|
|
309
|
-
return [2
|
|
310
|
-
/*return*/
|
|
311
|
-
, _a.sent()];
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
exports.updateSubscription = updateSubscription;
|