ncloudchat 1.0.16 → 1.0.17
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/lib/CloudChat.js +1676 -0
- package/lib/CoreManager.js +35 -0
- package/lib/Dispatcher.js +109 -0
- package/lib/Type.js +25 -0
- package/lib/Util.js +18 -0
- package/lib/logger.js +27 -0
- package/lib/mutations/channel.js +421 -0
- package/lib/mutations/friend.js +352 -0
- package/lib/mutations/index.js +89 -0
- package/lib/mutations/invite.js +211 -0
- package/lib/mutations/message.js +252 -0
- package/lib/mutations/subscription.js +317 -0
- package/lib/mutations/user.js +227 -0
- package/lib/queries/channel.js +283 -0
- package/lib/queries/friend.js +223 -0
- package/lib/queries/index.js +89 -0
- package/lib/queries/member.js +223 -0
- package/lib/queries/message.js +326 -0
- package/lib/queries/project.js +218 -0
- package/lib/queries/subscription.js +277 -0
- package/package.json +1 -1
- package/package-lock.json +0 -36183
|
@@ -0,0 +1,277 @@
|
|
|
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.getSubscriptions = exports.getSubscription = 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 getSubscription = function getSubscription(channelId, 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 subscription ($projectId: String!,$channelId: String!, $id: String!) {\n subscription(projectId: $projectId, channelId: $channelId, id:$id) {\n id\n user {\n nickname\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
|
+
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
|
+
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
|
+
}
|
|
212
|
+
})];
|
|
213
|
+
|
|
214
|
+
case 1:
|
|
215
|
+
return [2
|
|
216
|
+
/*return*/
|
|
217
|
+
, _a.sent()];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
exports.getSubscription = getSubscription;
|
|
224
|
+
|
|
225
|
+
var getSubscriptions = function getSubscriptions(filter, sort, option) {
|
|
226
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
227
|
+
var token, projectId, endpoint, query;
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
switch (_a.label) {
|
|
230
|
+
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 nickname\n profile\n country\n }\n channel_id\n user_id\n online\n push\n created_at\n }\n }\n }\n }\n ";
|
|
241
|
+
return [4
|
|
242
|
+
/*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;
|
|
266
|
+
})];
|
|
267
|
+
|
|
268
|
+
case 1:
|
|
269
|
+
return [2
|
|
270
|
+
/*return*/
|
|
271
|
+
, _a.sent()];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
exports.getSubscriptions = getSubscriptions;
|