ncloudchat 1.0.21 → 1.0.31
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/LICENSE.md +1 -1
- package/deploy.sh +1 -1
- package/esm/CloudChat.d.ts +434 -9
- package/esm/CloudChat.js +979 -273
- package/esm/CloudChat.js.map +1 -1
- package/esm/CoreManager.d.ts +6 -0
- package/esm/CoreManager.js +13 -4
- package/esm/CoreManager.js.map +1 -1
- package/esm/Dispatcher.d.ts +16 -0
- package/esm/Dispatcher.js +19 -4
- package/esm/Dispatcher.js.map +1 -1
- package/esm/Network.d.ts +7 -0
- package/esm/Network.js +93 -0
- package/esm/Network.js.map +1 -0
- package/esm/Type.d.ts +43 -0
- package/esm/Type.js +16 -0
- package/esm/Type.js.map +1 -1
- package/esm/Util.d.ts +13 -0
- package/esm/Util.js +13 -0
- package/esm/Util.js.map +1 -1
- package/esm/graphql/channel.d.ts +13 -0
- package/esm/graphql/channel.js +16 -0
- package/esm/graphql/channel.js.map +1 -0
- package/esm/graphql/friend.d.ts +11 -0
- package/esm/graphql/friend.js +13 -0
- package/esm/graphql/friend.js.map +1 -0
- package/esm/graphql/invite.d.ts +7 -0
- package/esm/graphql/invite.js +8 -0
- package/esm/graphql/invite.js.map +1 -0
- package/esm/graphql/member.d.ts +11 -0
- package/esm/graphql/member.js +13 -0
- package/esm/graphql/member.js.map +1 -0
- package/esm/graphql/message.d.ts +11 -0
- package/esm/graphql/message.js +13 -0
- package/esm/graphql/message.js.map +1 -0
- package/esm/graphql/pin.d.ts +10 -0
- package/esm/graphql/pin.js +12 -0
- package/esm/graphql/pin.js.map +1 -0
- package/esm/graphql/project.d.ts +7 -0
- package/esm/graphql/project.js +8 -0
- package/esm/graphql/project.js.map +1 -0
- package/esm/graphql/subscription.d.ts +11 -0
- package/esm/graphql/subscription.js +13 -0
- package/esm/graphql/subscription.js.map +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +6 -0
- package/esm/index.js.map +1 -1
- package/esm/logger.d.ts +9 -3
- package/esm/logger.js +6 -0
- package/esm/logger.js.map +1 -1
- package/esm/mutations/channel.d.ts +50 -0
- package/esm/mutations/channel.js +97 -176
- package/esm/mutations/channel.js.map +1 -1
- package/esm/mutations/friend.d.ts +38 -0
- package/esm/mutations/friend.js +57 -119
- package/esm/mutations/friend.js.map +1 -1
- package/esm/mutations/index.d.ts +5 -3
- package/esm/mutations/index.js +5 -3
- package/esm/mutations/index.js.map +1 -1
- package/esm/mutations/invite.d.ts +15 -0
- package/esm/mutations/invite.js +23 -32
- package/esm/mutations/invite.js.map +1 -1
- package/esm/mutations/member.d.ts +39 -2
- package/esm/mutations/member.js +64 -111
- package/esm/mutations/member.js.map +1 -1
- package/esm/mutations/message.d.ts +35 -0
- package/esm/mutations/message.js +66 -45
- package/esm/mutations/message.js.map +1 -1
- package/esm/mutations/pin.d.ts +28 -0
- package/esm/mutations/pin.js +88 -0
- package/esm/mutations/pin.js.map +1 -0
- package/esm/mutations/subscription.d.ts +33 -1
- package/esm/mutations/subscription.js +51 -93
- package/esm/mutations/subscription.js.map +1 -1
- package/esm/queries/channel.d.ts +24 -0
- package/esm/queries/channel.js +37 -79
- package/esm/queries/channel.js.map +1 -1
- package/esm/queries/friend.d.ts +16 -0
- package/esm/queries/friend.js +25 -40
- package/esm/queries/friend.js.map +1 -1
- package/esm/queries/index.d.ts +8 -0
- package/esm/queries/index.js +8 -0
- package/esm/queries/index.js.map +1 -1
- package/esm/queries/member.d.ts +16 -0
- package/esm/queries/member.js +25 -40
- package/esm/queries/member.js.map +1 -1
- package/esm/queries/memberblocks.d.ts +17 -0
- package/esm/queries/memberblocks.js +69 -0
- package/esm/queries/memberblocks.js.map +1 -0
- package/esm/queries/message.d.ts +33 -0
- package/esm/queries/message.js +50 -111
- package/esm/queries/message.js.map +1 -1
- package/esm/queries/pin.d.ts +28 -0
- package/esm/queries/pin.js +92 -0
- package/esm/queries/pin.js.map +1 -0
- package/esm/queries/project.d.ts +13 -0
- package/esm/queries/project.js +20 -32
- package/esm/queries/project.js.map +1 -1
- package/esm/queries/subscription.d.ts +25 -0
- package/esm/queries/subscription.js +39 -76
- package/esm/queries/subscription.js.map +1 -1
- package/lib/CloudChat.js +1230 -321
- package/lib/CoreManager.js +13 -3
- package/lib/Dispatcher.js +25 -9
- package/lib/Network.js +226 -0
- package/lib/Type.js +19 -0
- package/lib/Util.js +15 -1
- package/lib/graphql/channel.js +32 -0
- package/lib/graphql/friend.js +27 -0
- package/lib/graphql/invite.js +18 -0
- package/lib/graphql/member.js +27 -0
- package/lib/graphql/message.js +27 -0
- package/lib/graphql/pin.js +25 -0
- package/lib/graphql/project.js +18 -0
- package/lib/graphql/subscription.js +27 -0
- package/lib/index.js +2 -2
- package/lib/logger.js +6 -0
- package/lib/mutations/channel.js +106 -172
- package/lib/mutations/friend.js +62 -115
- package/lib/mutations/index.js +23 -3
- package/lib/mutations/invite.js +27 -33
- package/lib/mutations/member.js +73 -100
- package/lib/mutations/message.js +86 -48
- package/lib/mutations/pin.js +229 -0
- package/lib/mutations/subscription.js +56 -95
- package/lib/queries/channel.js +40 -84
- package/lib/queries/friend.js +29 -45
- package/lib/queries/index.js +37 -3
- package/lib/queries/member.js +29 -45
- package/lib/queries/memberblocks.js +207 -0
- package/lib/queries/message.js +56 -109
- package/lib/queries/pin.js +243 -0
- package/lib/queries/project.js +24 -41
- package/lib/queries/subscription.js +42 -78
- package/package.json +19 -45
- package/tsconfig.json +1 -0
- package//353/260/260/355/217/254/354/210/234/354/204/234.md +8 -0
- package/package copy.json +0 -74
|
@@ -0,0 +1,229 @@
|
|
|
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.updatePin = exports.createPin = 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
|
+
* Create a new pin.
|
|
176
|
+
*
|
|
177
|
+
* @async
|
|
178
|
+
* @function createPin
|
|
179
|
+
* @param {string} channelId - An id of the channel.
|
|
180
|
+
* @param {PinInput} pin - Configuration options of the new pin.
|
|
181
|
+
* @returns {Promise<any>} The data of the newly created pin.
|
|
182
|
+
*/
|
|
183
|
+
var createPin = function createPin(channelId, pin) {
|
|
184
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
return [2
|
|
187
|
+
/*return*/
|
|
188
|
+
, (0, _Network.fetchData)("createPin", _pin.createPinQuery, {
|
|
189
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
190
|
+
channelId: channelId,
|
|
191
|
+
pinned: pin.pinned,
|
|
192
|
+
pinnedAt: pin.pinnedAt,
|
|
193
|
+
expiredAt: pin.expiredAt
|
|
194
|
+
})];
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Update pin options.
|
|
200
|
+
*
|
|
201
|
+
* @async
|
|
202
|
+
* @function updatePin
|
|
203
|
+
* @param {string} id - An id of the pin.
|
|
204
|
+
* @param {string} channelId - An id of the channel.
|
|
205
|
+
* @param {PinInput} pin - New options of the pin.
|
|
206
|
+
* @returns {Promise<any>} The data of the updated created pin.
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
exports.createPin = createPin;
|
|
211
|
+
|
|
212
|
+
var updatePin = function updatePin(id, channelId, pin) {
|
|
213
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
return [2
|
|
216
|
+
/*return*/
|
|
217
|
+
, (0, _Network.fetchData)("updatePin", _pin.updatePinQuery, {
|
|
218
|
+
id: id,
|
|
219
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
220
|
+
channelId: channelId,
|
|
221
|
+
pinned: pin.pinned,
|
|
222
|
+
pinnedAt: pin.pinnedAt,
|
|
223
|
+
expiredAt: pin.expiredAt
|
|
224
|
+
})];
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
exports.updatePin = updatePin;
|
|
@@ -1,25 +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
|
-
exports.updateSubscription = exports.deleteSubscription = exports.createSubscription =
|
|
12
|
-
|
|
13
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
11
|
+
exports.updateSubscription = exports.deleteSubscription = exports.createSubscription = void 0;
|
|
14
12
|
|
|
15
|
-
var
|
|
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
|
|
17
|
+
var _iterator = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/symbol/iterator"));
|
|
20
18
|
|
|
21
19
|
var _CoreManager = _interopRequireDefault(require("../CoreManager"));
|
|
22
20
|
|
|
21
|
+
var _Network = require("../Network");
|
|
22
|
+
|
|
23
|
+
var _subscription = require("../graphql/subscription");
|
|
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
|
+
*/
|
|
23
31
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
24
32
|
function adopt(value) {
|
|
25
33
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -163,49 +171,30 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
163
171
|
}
|
|
164
172
|
};
|
|
165
173
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Create a subscription.
|
|
176
|
+
*
|
|
177
|
+
* @async
|
|
178
|
+
* @function createSubscription
|
|
179
|
+
* @param {string} channelId - The id of a channel.
|
|
180
|
+
* @param {string} option
|
|
181
|
+
* @returns {Promise<any>}
|
|
182
|
+
*/
|
|
169
183
|
var createSubscription = function createSubscription(channelId, option) {
|
|
170
184
|
if (option === void 0) {
|
|
171
185
|
option = "";
|
|
172
186
|
}
|
|
173
187
|
|
|
174
188
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
175
|
-
var token, endpoint, projectId, query;
|
|
176
189
|
return __generator(this, function (_a) {
|
|
177
190
|
switch (_a.label) {
|
|
178
191
|
case 0:
|
|
179
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
180
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
181
|
-
projectId = _CoreManager["default"].get('PROJECT_ID');
|
|
182
|
-
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 " + getSubscriptionSchema + "\n }\n }\n }\n ";
|
|
183
192
|
return [4
|
|
184
193
|
/*yield*/
|
|
185
|
-
,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
'X-PROJECT-ID': projectId,
|
|
190
|
-
'Content-Type': 'application/json',
|
|
191
|
-
'Accept': 'application/json'
|
|
192
|
-
},
|
|
193
|
-
body: (0, _stringify["default"])({
|
|
194
|
-
query: query,
|
|
195
|
-
variables: {
|
|
196
|
-
projectId: projectId,
|
|
197
|
-
channelId: channelId,
|
|
198
|
-
option: option
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
}).then(function (res) {
|
|
202
|
-
return res.json();
|
|
203
|
-
}).then(function (data) {
|
|
204
|
-
if (data.errors) {
|
|
205
|
-
throw data.errors[0];
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return data.data.createSubscription.subscription;
|
|
194
|
+
, (0, _Network.fetchData)("createSubscription", _subscription.createSubscriptionQuery, {
|
|
195
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
196
|
+
channelId: channelId,
|
|
197
|
+
option: option
|
|
209
198
|
})];
|
|
210
199
|
|
|
211
200
|
case 1:
|
|
@@ -216,44 +205,28 @@ var createSubscription = function createSubscription(channelId, option) {
|
|
|
216
205
|
});
|
|
217
206
|
});
|
|
218
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
* Delete a subscription.
|
|
210
|
+
*
|
|
211
|
+
* @async
|
|
212
|
+
* @function deleteSubscription
|
|
213
|
+
* @param {string} channelId - The id of a channel.
|
|
214
|
+
* @returns {Promise<any>}
|
|
215
|
+
*/
|
|
216
|
+
|
|
219
217
|
|
|
220
218
|
exports.createSubscription = createSubscription;
|
|
221
219
|
|
|
222
220
|
var deleteSubscription = function deleteSubscription(channelId) {
|
|
223
221
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
-
var token, endpoint, projectId, query;
|
|
225
222
|
return __generator(this, function (_a) {
|
|
226
223
|
switch (_a.label) {
|
|
227
224
|
case 0:
|
|
228
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
229
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
230
|
-
projectId = _CoreManager["default"].get('PROJECT_ID');
|
|
231
|
-
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 " + getSubscriptionSchema + "\n }\n }\n }\n ";
|
|
232
225
|
return [4
|
|
233
226
|
/*yield*/
|
|
234
|
-
,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
'Authorization': 'Bearer ' + token,
|
|
238
|
-
'X-PROJECT-ID': projectId,
|
|
239
|
-
'Content-Type': 'application/json',
|
|
240
|
-
'Accept': 'application/json'
|
|
241
|
-
},
|
|
242
|
-
body: (0, _stringify["default"])({
|
|
243
|
-
query: query,
|
|
244
|
-
variables: {
|
|
245
|
-
projectId: projectId,
|
|
246
|
-
channelId: channelId
|
|
247
|
-
}
|
|
248
|
-
})
|
|
249
|
-
}).then(function (res) {
|
|
250
|
-
return res.json();
|
|
251
|
-
}).then(function (data) {
|
|
252
|
-
if (data.errors) {
|
|
253
|
-
throw data.errors[0];
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return data.data.deleteSubscription.subscription;
|
|
227
|
+
, (0, _Network.fetchData)("deleteSubscription", _subscription.deleteSubscriptionQuery, {
|
|
228
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
229
|
+
channelId: channelId
|
|
257
230
|
})];
|
|
258
231
|
|
|
259
232
|
case 1:
|
|
@@ -264,6 +237,17 @@ var deleteSubscription = function deleteSubscription(channelId) {
|
|
|
264
237
|
});
|
|
265
238
|
});
|
|
266
239
|
};
|
|
240
|
+
/**
|
|
241
|
+
* Update a subscription information, such as marking message read.
|
|
242
|
+
*
|
|
243
|
+
* @async
|
|
244
|
+
* @function updateSubscription
|
|
245
|
+
* @param {string} channelId - The id of a channel.
|
|
246
|
+
* @param {MarkInput} mark
|
|
247
|
+
* @param {string} option
|
|
248
|
+
* @returns {Promise<any>}
|
|
249
|
+
*/
|
|
250
|
+
|
|
267
251
|
|
|
268
252
|
exports.deleteSubscription = deleteSubscription;
|
|
269
253
|
|
|
@@ -273,39 +257,16 @@ var updateSubscription = function updateSubscription(channelId, mark, option) {
|
|
|
273
257
|
}
|
|
274
258
|
|
|
275
259
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
276
|
-
var token, endpoint, projectId, query;
|
|
277
260
|
return __generator(this, function (_a) {
|
|
278
261
|
switch (_a.label) {
|
|
279
262
|
case 0:
|
|
280
|
-
token = _CoreManager["default"].get("TOKEN");
|
|
281
|
-
endpoint = _CoreManager["default"].get('SERVER_URL') + '/graphql';
|
|
282
|
-
projectId = _CoreManager["default"].get('PROJECT_ID');
|
|
283
|
-
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 " + getSubscriptionSchema + "\n }\n }\n }\n ";
|
|
284
263
|
return [4
|
|
285
264
|
/*yield*/
|
|
286
|
-
,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
'Content-Type': 'application/json',
|
|
292
|
-
'Accept': 'application/json'
|
|
293
|
-
},
|
|
294
|
-
body: (0, _stringify["default"])({
|
|
295
|
-
query: query,
|
|
296
|
-
variables: {
|
|
297
|
-
projectId: projectId,
|
|
298
|
-
channelId: channelId,
|
|
299
|
-
mark: mark,
|
|
300
|
-
option: option
|
|
301
|
-
}
|
|
302
|
-
})
|
|
303
|
-
}).then(function (res) {
|
|
304
|
-
return res.json();
|
|
305
|
-
}).then(function (data) {
|
|
306
|
-
if (data.errors) throw data.errors[0];
|
|
307
|
-
if (data.code) throw data;
|
|
308
|
-
return data.data.updateSubscription.subscription;
|
|
265
|
+
, (0, _Network.fetchData)("updateSubscription", _subscription.updateSubscriptionQuery, {
|
|
266
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
267
|
+
channelId: channelId,
|
|
268
|
+
mark: mark,
|
|
269
|
+
option: option
|
|
309
270
|
})];
|
|
310
271
|
|
|
311
272
|
case 1:
|
package/lib/queries/channel.js
CHANGED
|
@@ -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.getChannels = exports.getChannel = void 0;
|
|
12
12
|
|
|
13
|
-
var
|
|
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
|
|
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
|
|
21
|
+
var _channel = require("../graphql/channel");
|
|
22
|
+
|
|
23
|
+
var _Network = require("../Network");
|
|
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,51 +171,24 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
165
171
|
}
|
|
166
172
|
};
|
|
167
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Get data of a single channel from the endpoint.
|
|
176
|
+
*
|
|
177
|
+
* @async
|
|
178
|
+
* @function getChannel
|
|
179
|
+
* @param {string} id - An id of the channel.
|
|
180
|
+
* @returns {Promise<any>} The data of the channel.
|
|
181
|
+
*/
|
|
168
182
|
var getChannel = function getChannel(id) {
|
|
169
183
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
-
var token, projectId, endpoint, query;
|
|
171
184
|
return __generator(this, function (_a) {
|
|
172
185
|
switch (_a.label) {
|
|
173
186
|
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 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
187
|
return [4
|
|
185
188
|
/*yield*/
|
|
186
|
-
,
|
|
187
|
-
|
|
188
|
-
|
|
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;
|
|
189
|
+
, (0, _Network.fetchData)("channel", _channel.getChannelQuery, {
|
|
190
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
191
|
+
id: id
|
|
213
192
|
})];
|
|
214
193
|
|
|
215
194
|
case 1:
|
|
@@ -220,55 +199,32 @@ var getChannel = function getChannel(id) {
|
|
|
220
199
|
});
|
|
221
200
|
});
|
|
222
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Get data of multiple channels.
|
|
204
|
+
*
|
|
205
|
+
* @async
|
|
206
|
+
* @function getChannels
|
|
207
|
+
* @param {string} filter - Field value for filter.
|
|
208
|
+
* @param {string} sort - Field value for sorting.
|
|
209
|
+
* @param {string} option - Optional option: ex) offset, per_page.
|
|
210
|
+
* @returns {Promise<any[]>} An array of data of all channels.
|
|
211
|
+
*/
|
|
212
|
+
|
|
223
213
|
|
|
224
214
|
exports.getChannel = getChannel;
|
|
225
215
|
|
|
226
216
|
var getChannels = function getChannels(filter, sort, option) {
|
|
227
217
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
228
|
-
var token, projectId, endpoint, query;
|
|
229
218
|
return __generator(this, function (_a) {
|
|
230
219
|
switch (_a.label) {
|
|
231
220
|
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 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
221
|
return [4
|
|
243
222
|
/*yield*/
|
|
244
|
-
,
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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 [];
|
|
223
|
+
, (0, _Network.fetchData)("channels", _channel.getChannelsQuery, {
|
|
224
|
+
projectId: _CoreManager["default"].get("PROJECT_ID"),
|
|
225
|
+
filter: filter,
|
|
226
|
+
sort: sort,
|
|
227
|
+
option: option
|
|
272
228
|
})];
|
|
273
229
|
|
|
274
230
|
case 1:
|