@bwi-mentorspaces/application-utils-npm 0.0.5 → 0.0.7
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/chat/index.d.ts +36 -36
- package/chat/index.js +58 -58
- package/chat/stream/enum/index.d.ts +33 -27
- package/chat/stream/enum/index.js +41 -34
- package/chat/stream/enum/index.js.map +1 -1
- package/chat/stream/index.d.ts +9 -9
- package/chat/stream/index.js +17 -17
- package/chat/stream/models/_/channel.data.d.ts +19 -19
- package/chat/stream/models/_/channel.data.js +2 -2
- package/chat/stream/models/_/channel.member.d.ts +14 -14
- package/chat/stream/models/_/channel.member.js +11 -11
- package/chat/stream/models/_/channel.response.d.ts +8 -8
- package/chat/stream/models/_/channel.response.js +2 -2
- package/chat/stream/models/_/event.data.d.ts +16 -0
- package/chat/stream/models/_/event.data.js +4 -0
- package/chat/stream/models/_/event.data.js.map +1 -0
- package/chat/stream/models/_/message.response.d.ts +8 -8
- package/chat/stream/models/_/message.response.js +2 -2
- package/chat/stream/models/_/stream.config.d.ts +22 -22
- package/chat/stream/models/_/stream.config.js +2 -2
- package/chat/stream/models/_/user.response.d.ts +8 -8
- package/chat/stream/models/_/user.response.js +2 -2
- package/chat/stream/models/index.d.ts +9 -7
- package/chat/stream/models/index.js +5 -5
- package/chat/stream/models/index.js.map +1 -1
- package/chat/stream/stream.api.d.ts +63 -63
- package/chat/stream/stream.api.js +76 -76
- package/chat/stream/stream.auth.d.ts +70 -70
- package/chat/stream/stream.auth.js +80 -80
- package/chat/stream/stream.base.d.ts +56 -56
- package/chat/stream/stream.base.js +93 -93
- package/chat/stream/stream.channel.d.ts +132 -118
- package/chat/stream/stream.channel.js +306 -285
- package/chat/stream/stream.channel.js.map +1 -1
- package/chat/stream/stream.error.d.ts +19 -19
- package/chat/stream/stream.error.js +17 -17
- package/chat/stream/stream.member.d.ts +75 -75
- package/chat/stream/stream.member.js +175 -175
- package/chat/stream/stream.message.d.ts +59 -59
- package/chat/stream/stream.message.js +112 -112
- package/chat/stream/stream.user.d.ts +49 -49
- package/chat/stream/stream.user.js +90 -90
- package/core/_/api-error.d.ts +24 -24
- package/core/_/api-error.js +21 -21
- package/core/_/api-response.d.ts +25 -25
- package/core/_/api-response.js +21 -21
- package/core/_/cors-headers.d.ts +16 -16
- package/core/_/cors-headers.js +32 -32
- package/core/_/model.d.ts +39 -31
- package/core/_/model.js +2 -2
- package/core/_/service-request.d.ts +66 -66
- package/core/_/service-request.js +104 -104
- package/core/_/service-request.js.map +1 -1
- package/core/index.d.ts +10 -10
- package/core/index.js +11 -11
- package/deployment/_/serverless.d.ts +26 -26
- package/deployment/_/serverless.js +43 -43
- package/deployment/index.d.ts +2 -2
- package/deployment/index.js +5 -5
- package/endpoint-test-factory/_/test-factory.d.ts +45 -45
- package/endpoint-test-factory/_/test-factory.js +91 -91
- package/endpoint-test-factory/index.d.ts +2 -2
- package/endpoint-test-factory/index.js +5 -5
- package/enums/index.d.ts +92 -92
- package/enums/index.js +2 -2
- package/meet/index.d.ts +36 -36
- package/meet/index.js +58 -58
- package/meet/twilio/enum/index.d.ts +6 -6
- package/meet/twilio/enum/index.js +10 -10
- package/meet/twilio/index.d.ts +5 -5
- package/meet/twilio/index.js +11 -11
- package/meet/twilio/models/_/room.data.d.ts +6 -6
- package/meet/twilio/models/_/room.data.js +2 -2
- package/meet/twilio/models/_/twilio.config.d.ts +29 -29
- package/meet/twilio/models/_/twilio.config.js +2 -2
- package/meet/twilio/models/index.d.ts +3 -3
- package/meet/twilio/models/index.js +2 -2
- package/meet/twilio/twilio.api.d.ts +28 -28
- package/meet/twilio/twilio.api.js +45 -45
- package/meet/twilio/twilio.auth.d.ts +55 -55
- package/meet/twilio/twilio.auth.js +83 -83
- package/meet/twilio/twilio.base.d.ts +41 -41
- package/meet/twilio/twilio.base.js +53 -53
- package/meet/twilio/twilio.room.d.ts +46 -46
- package/meet/twilio/twilio.room.js +124 -124
- package/package.json +57 -57
- package/swagger/_/swagger.config.d.ts +21 -21
- package/swagger/_/swagger.config.js +2 -2
- package/swagger/_/swagger.d.ts +37 -37
- package/swagger/_/swagger.js +78 -78
- package/swagger/index.d.ts +3 -3
- package/swagger/index.js +5 -5
- package/types/index.d.ts +19 -19
- package/types/index.js +2 -2
- package/utils/_/encoder.d.ts +19 -19
- package/utils/_/encoder.js +27 -27
- package/utils/_/encryptor.d.ts +26 -26
- package/utils/_/encryptor.js +67 -67
- package/utils/_/hasher.d.ts +25 -25
- package/utils/_/hasher.js +63 -63
- package/utils/_/object-mapper.d.ts +12 -12
- package/utils/_/object-mapper.js +22 -22
- package/utils/_/string-formatter.d.ts +34 -34
- package/utils/_/string-formatter.js +49 -49
- package/utils/_/utc-date.d.ts +35 -35
- package/utils/_/utc-date.js +84 -84
- package/utils/index.d.ts +7 -7
- package/utils/index.js +15 -15
- package/validators/_/checker.d.ts +62 -62
- package/validators/_/checker.js +98 -98
- package/validators/_/regex.d.ts +98 -98
- package/validators/_/regex.js +142 -142
- package/validators/_/regex.js.map +1 -1
- package/validators/index.d.ts +3 -3
- package/validators/index.js +7 -7
|
@@ -1,286 +1,307 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.StreamChannel = void 0;
|
|
13
|
-
const utils_1 = require("../../utils");
|
|
14
|
-
const stream_base_1 = require("./stream.base");
|
|
15
|
-
/**
|
|
16
|
-
* A class that provides methods to manage StreamAPI Channel
|
|
17
|
-
*/
|
|
18
|
-
class StreamChannel extends stream_base_1.StreamBase {
|
|
19
|
-
// properties
|
|
20
|
-
/**
|
|
21
|
-
* Stream channel constructor
|
|
22
|
-
*
|
|
23
|
-
* @param {StreamAuth} auth Auth class
|
|
24
|
-
* @param {StreamChat} server Stream API server
|
|
25
|
-
*/
|
|
26
|
-
constructor(auth, server) {
|
|
27
|
-
super();
|
|
28
|
-
super.auth = auth;
|
|
29
|
-
super.server = server;
|
|
30
|
-
}
|
|
31
|
-
// methods
|
|
32
|
-
/**
|
|
33
|
-
* Create channel
|
|
34
|
-
*
|
|
35
|
-
* @param {IChannelData} data channel data object
|
|
36
|
-
* @returns {ChannelAPIResponse} channel object response
|
|
37
|
-
*/
|
|
38
|
-
create(data) {
|
|
39
|
-
const _super = Object.create(null, {
|
|
40
|
-
server: { get: () => super.server }
|
|
41
|
-
});
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return _super.server
|
|
44
|
-
.channel(data.type, data.channelId, {
|
|
45
|
-
name: data.name,
|
|
46
|
-
created_by_id: data.createdById,
|
|
47
|
-
subType: data.subType ? data.subType.toString() : undefined,
|
|
48
|
-
companyId: data.companyId ? data.companyId.toString() : undefined,
|
|
49
|
-
topicRef: data.topicRef ? data.topicRef.toString() : undefined
|
|
50
|
-
})
|
|
51
|
-
.create();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @param {
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @param {
|
|
118
|
-
* @returns {Promise<Channel[]>} channel response
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
const _super = Object.create(null, {
|
|
122
|
-
server: { get: () => super.server }
|
|
123
|
-
});
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StreamChannel = void 0;
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
const stream_base_1 = require("./stream.base");
|
|
15
|
+
/**
|
|
16
|
+
* A class that provides methods to manage StreamAPI Channel
|
|
17
|
+
*/
|
|
18
|
+
class StreamChannel extends stream_base_1.StreamBase {
|
|
19
|
+
// properties
|
|
20
|
+
/**
|
|
21
|
+
* Stream channel constructor
|
|
22
|
+
*
|
|
23
|
+
* @param {StreamAuth} auth Auth class
|
|
24
|
+
* @param {StreamChat} server Stream API server
|
|
25
|
+
*/
|
|
26
|
+
constructor(auth, server) {
|
|
27
|
+
super();
|
|
28
|
+
super.auth = auth;
|
|
29
|
+
super.server = server;
|
|
30
|
+
}
|
|
31
|
+
// methods
|
|
32
|
+
/**
|
|
33
|
+
* Create channel
|
|
34
|
+
*
|
|
35
|
+
* @param {IChannelData} data channel data object
|
|
36
|
+
* @returns {ChannelAPIResponse} channel object response
|
|
37
|
+
*/
|
|
38
|
+
create(data) {
|
|
39
|
+
const _super = Object.create(null, {
|
|
40
|
+
server: { get: () => super.server }
|
|
41
|
+
});
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return _super.server
|
|
44
|
+
.channel(data.type, data.channelId, {
|
|
45
|
+
name: data.name,
|
|
46
|
+
created_by_id: data.createdById,
|
|
47
|
+
subType: data.subType ? data.subType.toString() : undefined,
|
|
48
|
+
companyId: data.companyId ? data.companyId.toString() : undefined,
|
|
49
|
+
topicRef: data.topicRef ? data.topicRef.toString() : undefined
|
|
50
|
+
})
|
|
51
|
+
.create();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Send event to channel
|
|
56
|
+
*
|
|
57
|
+
* @param {string} channelId the channel id
|
|
58
|
+
* @param {IEventTypes} eventType the event type
|
|
59
|
+
* @param {string} user user responsible for sent the event
|
|
60
|
+
* @param {IEventTypesData} customData the data to send with the event
|
|
61
|
+
* @returns {Promise<EventAPIResponse<DefaultGenerics>>} channel object response
|
|
62
|
+
*/
|
|
63
|
+
sendChannelEvent(channelId, eventType, user, customData) {
|
|
64
|
+
const _super = Object.create(null, {
|
|
65
|
+
getChannelById: { get: () => super.getChannelById }
|
|
66
|
+
});
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const rChannel = yield _super.getChannelById.call(this, channelId);
|
|
69
|
+
if (rChannel && rChannel.length > 0) {
|
|
70
|
+
const channel = rChannel[0];
|
|
71
|
+
return yield channel.sendEvent(Object.assign({ type: eventType, user }, customData));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Add new members into a specific channel.
|
|
77
|
+
*
|
|
78
|
+
* @param {IChannelData} data channel data object
|
|
79
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
80
|
+
*/
|
|
81
|
+
addMembers(data) {
|
|
82
|
+
const _super = Object.create(null, {
|
|
83
|
+
getChannelById: { get: () => super.getChannelById }
|
|
84
|
+
});
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
//Retrieve the channel
|
|
87
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
88
|
+
if (rChannel && rChannel.length > 0) {
|
|
89
|
+
//get the channel from the response
|
|
90
|
+
const channel = rChannel[0];
|
|
91
|
+
//retrieve the data for members
|
|
92
|
+
const existingMemberCount = channel.data.member_count;
|
|
93
|
+
//Create the message if is necessary
|
|
94
|
+
let message = undefined;
|
|
95
|
+
//Add message text if is necessary
|
|
96
|
+
if (data.inviteMessage !== undefined) {
|
|
97
|
+
message = { text: data.inviteMessage, user_id: channel.data.created_by["id"] };
|
|
98
|
+
}
|
|
99
|
+
//Send the invite request to stream
|
|
100
|
+
const r = yield channel.inviteMembers(data.members, message);
|
|
101
|
+
//check the result
|
|
102
|
+
if (existingMemberCount == r.members.length) {
|
|
103
|
+
// error, did not add members
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
//Members invited successfully
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if exist a channel with specific members
|
|
116
|
+
*
|
|
117
|
+
* @param {IChannelData} data channel data object
|
|
118
|
+
* @returns {Promise<Channel[]>} channel response
|
|
119
|
+
*/
|
|
120
|
+
getByMembers(data) {
|
|
121
|
+
const _super = Object.create(null, {
|
|
122
|
+
server: { get: () => super.server }
|
|
123
|
+
});
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
//Create the filter
|
|
126
|
+
const filter = { type: data.type, members: { $eq: data.members } };
|
|
127
|
+
//Create the sort
|
|
128
|
+
const sort = [{ last_message_at: -1 }];
|
|
129
|
+
//return the result of the querying
|
|
130
|
+
return _super.server.queryChannels(filter, sort);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get channel by filter
|
|
135
|
+
*
|
|
136
|
+
* @param {ChannelFilters} filter filter parameters
|
|
137
|
+
* @param {ChannelSort} sort sort parameters
|
|
138
|
+
* @param {ChannelOptions} options options parameter
|
|
139
|
+
* @returns {Promise<Channel[]>} channel response
|
|
140
|
+
*/
|
|
141
|
+
getChannel(filter, sort, options) {
|
|
142
|
+
const _super = Object.create(null, {
|
|
143
|
+
server: { get: () => super.server }
|
|
144
|
+
});
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
return _super.server.queryChannels(filter, sort, options);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Allow to partial update some fields on stream channel
|
|
151
|
+
*
|
|
152
|
+
* @param {IChannelData} data channel data object
|
|
153
|
+
* @returns {Promise<UpdateChannelAPIResponse>} channel object response
|
|
154
|
+
*/
|
|
155
|
+
updateChannel(data) {
|
|
156
|
+
const _super = Object.create(null, {
|
|
157
|
+
getChannelById: { get: () => super.getChannelById }
|
|
158
|
+
});
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
//Retrieve the channel
|
|
161
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
162
|
+
if (rChannel && rChannel.length > 0) {
|
|
163
|
+
//get the channel from the response
|
|
164
|
+
const channel = rChannel[0];
|
|
165
|
+
const partialObj = utils_1.ObjectMapper.keyValueMapper(data);
|
|
166
|
+
//check if this is a recovery channel request
|
|
167
|
+
if (data.frozen === false && data.disabled === false) {
|
|
168
|
+
//hide the channel for the current members
|
|
169
|
+
for (const member in channel.state.members) {
|
|
170
|
+
yield channel.show(member);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return channel.updatePartial({ set: partialObj });
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* This will be delete a specific channel from Stream
|
|
179
|
+
*
|
|
180
|
+
* @param {string} channelId channel id of the channel
|
|
181
|
+
* @param {boolean} isHard is Hard delete
|
|
182
|
+
* @returns {Promise<boolean>} promise of the result to delete channel
|
|
183
|
+
*/
|
|
184
|
+
deleteChannel(channelId, isHard = false) {
|
|
185
|
+
const _super = Object.create(null, {
|
|
186
|
+
getChannelById: { get: () => super.getChannelById }
|
|
187
|
+
});
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
//Retrieve the channel
|
|
190
|
+
const rChannel = yield _super.getChannelById.call(this, channelId);
|
|
191
|
+
if (rChannel && rChannel.length > 0) {
|
|
192
|
+
//get the channel from the response
|
|
193
|
+
const channel = rChannel[0];
|
|
194
|
+
let destroy = null;
|
|
195
|
+
//define if is a hard delete request
|
|
196
|
+
if (isHard) {
|
|
197
|
+
// server-side delete hard
|
|
198
|
+
destroy = yield channel.delete();
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
destroy = yield this.updateChannel({ channelId: channelId, frozen: true, disabled: true });
|
|
202
|
+
//hide the channel for the current members
|
|
203
|
+
for (const member in channel.state.members) {
|
|
204
|
+
yield channel.hide(member);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//Check the response
|
|
208
|
+
if (!destroy.channel) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Accept invited channel
|
|
220
|
+
*
|
|
221
|
+
* @param {string} channelId channel id of the channel
|
|
222
|
+
* @param {string} userId user id from stream
|
|
223
|
+
* @returns {boolean} true / false
|
|
224
|
+
*/
|
|
225
|
+
acceptInvite(channelId, userId) {
|
|
226
|
+
const _super = Object.create(null, {
|
|
227
|
+
getChannelById: { get: () => super.getChannelById }
|
|
228
|
+
});
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
let channelResponse;
|
|
231
|
+
//Retrieve the channel
|
|
232
|
+
const rChannel = yield _super.getChannelById.call(this, channelId);
|
|
233
|
+
if (rChannel && rChannel.length > 0) {
|
|
234
|
+
//get the channel from the response
|
|
235
|
+
const channel = rChannel[0];
|
|
236
|
+
//server-side accept invite
|
|
237
|
+
const r = yield channel.acceptInvite({ user_id: userId });
|
|
238
|
+
//Check the result
|
|
239
|
+
if (r) {
|
|
240
|
+
channelResponse = r;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return channelResponse;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Reject invited channel
|
|
248
|
+
*
|
|
249
|
+
* @param {string} channelId channel id of the channel
|
|
250
|
+
* @param {string} userId user id from stream
|
|
251
|
+
* @returns {boolean} true / false
|
|
252
|
+
*/
|
|
253
|
+
rejectInvite(channelId, userId) {
|
|
254
|
+
const _super = Object.create(null, {
|
|
255
|
+
getChannelById: { get: () => super.getChannelById }
|
|
256
|
+
});
|
|
257
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
let channelResponse;
|
|
259
|
+
//Retrieve the channel
|
|
260
|
+
const rChannel = yield _super.getChannelById.call(this, channelId);
|
|
261
|
+
if (rChannel && rChannel.length > 0) {
|
|
262
|
+
//get the channel from the response
|
|
263
|
+
const channel = rChannel[0];
|
|
264
|
+
//server-side accept invite
|
|
265
|
+
const r = yield channel.rejectInvite({ user_id: userId });
|
|
266
|
+
//Archive the channel if user reject invite
|
|
267
|
+
const ar = yield this.deleteChannel(channelId);
|
|
268
|
+
//Check the result
|
|
269
|
+
if (r && ar) {
|
|
270
|
+
channelResponse = r;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return channelResponse;
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Sync a channel
|
|
278
|
+
*
|
|
279
|
+
* @param {IChannelData} data channel data
|
|
280
|
+
* @returns {Promise<boolean>} promise of the type boolean
|
|
281
|
+
*/
|
|
282
|
+
syncChannel(data) {
|
|
283
|
+
const _super = Object.create(null, {
|
|
284
|
+
getChannelById: { get: () => super.getChannelById }
|
|
285
|
+
});
|
|
286
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
287
|
+
//Retrieve the channel
|
|
288
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
289
|
+
if (rChannel && rChannel.length > 0) {
|
|
290
|
+
//get the channel from the response
|
|
291
|
+
const channel = rChannel[0];
|
|
292
|
+
//Update the channel
|
|
293
|
+
const r = yield channel.update(data);
|
|
294
|
+
//Check the result
|
|
295
|
+
if (!r) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
exports.StreamChannel = StreamChannel;
|
|
286
307
|
//# sourceMappingURL=stream.channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.channel.js","sourceRoot":"","sources":["../../../chat/stream/stream.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"stream.channel.js","sourceRoot":"","sources":["../../../chat/stream/stream.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,uCAA2C;AAE3C,+CAA2C;AAqD3C;;GAEG;AACH,MAAa,aAAc,SAAQ,wBAAU;IACzC,aAAa;IAEb;;;;;OAKG;IACH,YAAY,IAAgB,EAAE,MAAkB;QAC5C,KAAK,EAAE,CAAC;QACR,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC1B,CAAC;IACD,UAAU;IAEV;;;;;OAKG;IACG,MAAM,CAAC,IAAkB;;;;;YAC3B,OAAO,OAAM,MAAM;iBACd,OAAO,CAAC,IAAI,CAAC,I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