@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,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface for API Error Responses
|
|
3
|
-
*/
|
|
4
|
-
interface IStreamErrorResponse {
|
|
5
|
-
message: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Stream Error Response implementation
|
|
9
|
-
*/
|
|
10
|
-
export declare class StreamErrorResponse implements IStreamErrorResponse {
|
|
11
|
-
message: string;
|
|
12
|
-
/**
|
|
13
|
-
* Stream Error Response constructor
|
|
14
|
-
*
|
|
15
|
-
* @param {string} msg error message
|
|
16
|
-
*/
|
|
17
|
-
constructor(msg: string);
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Interface for API Error Responses
|
|
3
|
+
*/
|
|
4
|
+
interface IStreamErrorResponse {
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Stream Error Response implementation
|
|
9
|
+
*/
|
|
10
|
+
export declare class StreamErrorResponse implements IStreamErrorResponse {
|
|
11
|
+
message: string;
|
|
12
|
+
/**
|
|
13
|
+
* Stream Error Response constructor
|
|
14
|
+
*
|
|
15
|
+
* @param {string} msg error message
|
|
16
|
+
*/
|
|
17
|
+
constructor(msg: string);
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StreamErrorResponse = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Stream Error Response implementation
|
|
6
|
-
*/
|
|
7
|
-
class StreamErrorResponse {
|
|
8
|
-
/**
|
|
9
|
-
* Stream Error Response constructor
|
|
10
|
-
*
|
|
11
|
-
* @param {string} msg error message
|
|
12
|
-
*/
|
|
13
|
-
constructor(msg) {
|
|
14
|
-
this.message = msg;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.StreamErrorResponse = StreamErrorResponse;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamErrorResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Stream Error Response implementation
|
|
6
|
+
*/
|
|
7
|
+
class StreamErrorResponse {
|
|
8
|
+
/**
|
|
9
|
+
* Stream Error Response constructor
|
|
10
|
+
*
|
|
11
|
+
* @param {string} msg error message
|
|
12
|
+
*/
|
|
13
|
+
constructor(msg) {
|
|
14
|
+
this.message = msg;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.StreamErrorResponse = StreamErrorResponse;
|
|
18
18
|
//# sourceMappingURL=stream.error.js.map
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { StreamChat } from "stream-chat";
|
|
2
|
-
import { IChannelData } from "./models";
|
|
3
|
-
import { StreamBase } from "./stream.base";
|
|
4
|
-
/**
|
|
5
|
-
* Channel Api declarations
|
|
6
|
-
*/
|
|
7
|
-
interface IStreamMember {
|
|
8
|
-
/**
|
|
9
|
-
* Add Members to a specific channel
|
|
10
|
-
*/
|
|
11
|
-
inviteMembers(data: IChannelData): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Add new members into a specific channel. *
|
|
14
|
-
*/
|
|
15
|
-
addMembers(data: IChannelData): Promise<boolean>;
|
|
16
|
-
/**
|
|
17
|
-
* Add new moderator into a specific channel.
|
|
18
|
-
*/
|
|
19
|
-
assignModerators(data: IChannelData): Promise<boolean>;
|
|
20
|
-
/**
|
|
21
|
-
* Demote moderator on a specific channel.
|
|
22
|
-
*/
|
|
23
|
-
demoteModerators(data: IChannelData): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Remove Members to a specific channel
|
|
26
|
-
*/
|
|
27
|
-
removeMembers(data: IChannelData): Promise<boolean>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* A class that provides methods to manage StreamAPI Channel
|
|
31
|
-
*/
|
|
32
|
-
export declare class StreamMember extends StreamBase implements IStreamMember {
|
|
33
|
-
/**
|
|
34
|
-
* Stream member constructor
|
|
35
|
-
*
|
|
36
|
-
* @param {StreamChat} server Stream API server
|
|
37
|
-
*/
|
|
38
|
-
constructor(server: StreamChat);
|
|
39
|
-
/**
|
|
40
|
-
* Add new members into a specific channel.
|
|
41
|
-
*
|
|
42
|
-
* @param {IChannelData} data channel data object
|
|
43
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
44
|
-
*/
|
|
45
|
-
inviteMembers(data: IChannelData): Promise<boolean>;
|
|
46
|
-
/**
|
|
47
|
-
* Add new members into a specific channel.
|
|
48
|
-
*
|
|
49
|
-
* @param {IChannelData} data channel data object
|
|
50
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
51
|
-
*/
|
|
52
|
-
addMembers(data: IChannelData): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* Add new moderator into a specific channel.
|
|
55
|
-
*
|
|
56
|
-
* @param {IChannelData} data channel data object
|
|
57
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
58
|
-
*/
|
|
59
|
-
assignModerators(data: IChannelData): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Add new members into a specific channel.
|
|
62
|
-
*
|
|
63
|
-
* @param {IChannelData} data channel data object
|
|
64
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
65
|
-
*/
|
|
66
|
-
demoteModerators(data: IChannelData): Promise<boolean>;
|
|
67
|
-
/**
|
|
68
|
-
* Remove members into a specific channel.
|
|
69
|
-
*
|
|
70
|
-
* @param {IChannelData} data channel data object
|
|
71
|
-
* @returns {Promise<boolean>} promise of the result to remove members
|
|
72
|
-
*/
|
|
73
|
-
removeMembers(data: IChannelData): Promise<boolean>;
|
|
74
|
-
}
|
|
75
|
-
export {};
|
|
1
|
+
import { StreamChat } from "stream-chat";
|
|
2
|
+
import { IChannelData } from "./models";
|
|
3
|
+
import { StreamBase } from "./stream.base";
|
|
4
|
+
/**
|
|
5
|
+
* Channel Api declarations
|
|
6
|
+
*/
|
|
7
|
+
interface IStreamMember {
|
|
8
|
+
/**
|
|
9
|
+
* Add Members to a specific channel
|
|
10
|
+
*/
|
|
11
|
+
inviteMembers(data: IChannelData): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Add new members into a specific channel. *
|
|
14
|
+
*/
|
|
15
|
+
addMembers(data: IChannelData): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Add new moderator into a specific channel.
|
|
18
|
+
*/
|
|
19
|
+
assignModerators(data: IChannelData): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Demote moderator on a specific channel.
|
|
22
|
+
*/
|
|
23
|
+
demoteModerators(data: IChannelData): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Remove Members to a specific channel
|
|
26
|
+
*/
|
|
27
|
+
removeMembers(data: IChannelData): Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A class that provides methods to manage StreamAPI Channel
|
|
31
|
+
*/
|
|
32
|
+
export declare class StreamMember extends StreamBase implements IStreamMember {
|
|
33
|
+
/**
|
|
34
|
+
* Stream member constructor
|
|
35
|
+
*
|
|
36
|
+
* @param {StreamChat} server Stream API server
|
|
37
|
+
*/
|
|
38
|
+
constructor(server: StreamChat);
|
|
39
|
+
/**
|
|
40
|
+
* Add new members into a specific channel.
|
|
41
|
+
*
|
|
42
|
+
* @param {IChannelData} data channel data object
|
|
43
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
44
|
+
*/
|
|
45
|
+
inviteMembers(data: IChannelData): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Add new members into a specific channel.
|
|
48
|
+
*
|
|
49
|
+
* @param {IChannelData} data channel data object
|
|
50
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
51
|
+
*/
|
|
52
|
+
addMembers(data: IChannelData): Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Add new moderator into a specific channel.
|
|
55
|
+
*
|
|
56
|
+
* @param {IChannelData} data channel data object
|
|
57
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
58
|
+
*/
|
|
59
|
+
assignModerators(data: IChannelData): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Add new members into a specific channel.
|
|
62
|
+
*
|
|
63
|
+
* @param {IChannelData} data channel data object
|
|
64
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
65
|
+
*/
|
|
66
|
+
demoteModerators(data: IChannelData): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Remove members into a specific channel.
|
|
69
|
+
*
|
|
70
|
+
* @param {IChannelData} data channel data object
|
|
71
|
+
* @returns {Promise<boolean>} promise of the result to remove members
|
|
72
|
+
*/
|
|
73
|
+
removeMembers(data: IChannelData): Promise<boolean>;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -1,176 +1,176 @@
|
|
|
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.StreamMember = void 0;
|
|
13
|
-
const models_1 = require("./models");
|
|
14
|
-
const stream_base_1 = require("./stream.base");
|
|
15
|
-
/**
|
|
16
|
-
* A class that provides methods to manage StreamAPI Channel
|
|
17
|
-
*/
|
|
18
|
-
class StreamMember extends stream_base_1.StreamBase {
|
|
19
|
-
// properties
|
|
20
|
-
/**
|
|
21
|
-
* Stream member constructor
|
|
22
|
-
*
|
|
23
|
-
* @param {StreamChat} server Stream API server
|
|
24
|
-
*/
|
|
25
|
-
constructor(server) {
|
|
26
|
-
super();
|
|
27
|
-
super.server = server;
|
|
28
|
-
}
|
|
29
|
-
// methods
|
|
30
|
-
/**
|
|
31
|
-
* Add new members into a specific channel.
|
|
32
|
-
*
|
|
33
|
-
* @param {IChannelData} data channel data object
|
|
34
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
35
|
-
*/
|
|
36
|
-
inviteMembers(data) {
|
|
37
|
-
const _super = Object.create(null, {
|
|
38
|
-
getChannelById: { get: () => super.getChannelById }
|
|
39
|
-
});
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
//Retrieve the channel
|
|
42
|
-
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
43
|
-
//get the channel from the response
|
|
44
|
-
const channel = rChannel[0];
|
|
45
|
-
//retrieve the data for members
|
|
46
|
-
const existingMemberCount = channel.data.member_count;
|
|
47
|
-
//Create the message if is necessary
|
|
48
|
-
let message = undefined;
|
|
49
|
-
//Add message text if is necessary
|
|
50
|
-
if (data.inviteMessage !== undefined) {
|
|
51
|
-
message = { text: data.inviteMessage, user_id: channel.data.created_by["id"] };
|
|
52
|
-
}
|
|
53
|
-
//Send the invite request to stream
|
|
54
|
-
const r = yield channel.inviteMembers(data.members, message);
|
|
55
|
-
//check the result
|
|
56
|
-
if (existingMemberCount == r.members.length) {
|
|
57
|
-
// error, did not add members
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
//Members invited successfully
|
|
61
|
-
return true;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Add new members into a specific channel.
|
|
66
|
-
*
|
|
67
|
-
* @param {IChannelData} data channel data object
|
|
68
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
69
|
-
*/
|
|
70
|
-
addMembers(data) {
|
|
71
|
-
const _super = Object.create(null, {
|
|
72
|
-
getChannelById: { get: () => super.getChannelById }
|
|
73
|
-
});
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
//Retrieve the channel
|
|
76
|
-
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
77
|
-
//get the channel from the response
|
|
78
|
-
const channel = rChannel[0];
|
|
79
|
-
//retrieve the data for members
|
|
80
|
-
const existingMemberCount = channel.data.member_count;
|
|
81
|
-
//Create the message if is necessary
|
|
82
|
-
let message = undefined;
|
|
83
|
-
//Add message text if is necessary
|
|
84
|
-
if (data.inviteMessage !== undefined) {
|
|
85
|
-
message = { text: data.inviteMessage, user_id: channel.data.created_by["id"] };
|
|
86
|
-
}
|
|
87
|
-
//Send the invite request to stream
|
|
88
|
-
const r = yield channel.addMembers(data.members, message);
|
|
89
|
-
//check the result
|
|
90
|
-
if (existingMemberCount == r.members.length) {
|
|
91
|
-
// error, did not add members
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
//Members invited successfully
|
|
95
|
-
return true;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Add new moderator into a specific channel.
|
|
100
|
-
*
|
|
101
|
-
* @param {IChannelData} data channel data object
|
|
102
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
103
|
-
*/
|
|
104
|
-
assignModerators(data) {
|
|
105
|
-
const _super = Object.create(null, {
|
|
106
|
-
getChannelById: { get: () => super.getChannelById }
|
|
107
|
-
});
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
//Retrieve the channel
|
|
110
|
-
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
111
|
-
//get the channel from the response
|
|
112
|
-
const channel = rChannel[0];
|
|
113
|
-
const moderators = [];
|
|
114
|
-
data.members.forEach((member) => {
|
|
115
|
-
moderators.push({ user_id: member, channel_role: models_1.StreamDefaultChannelRole.channel_moderator });
|
|
116
|
-
});
|
|
117
|
-
const r = yield channel.assignRoles(moderators);
|
|
118
|
-
//Members invited successfully
|
|
119
|
-
return (r === null || r === void 0 ? void 0 : r.channel) !== undefined;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Add new members into a specific channel.
|
|
124
|
-
*
|
|
125
|
-
* @param {IChannelData} data channel data object
|
|
126
|
-
* @returns {Promise<boolean>} promise of the result to add members
|
|
127
|
-
*/
|
|
128
|
-
demoteModerators(data) {
|
|
129
|
-
const _super = Object.create(null, {
|
|
130
|
-
getChannelById: { get: () => super.getChannelById }
|
|
131
|
-
});
|
|
132
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
//Retrieve the channel
|
|
134
|
-
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
135
|
-
//get the channel from the response
|
|
136
|
-
const channel = rChannel[0];
|
|
137
|
-
const moderators = [];
|
|
138
|
-
data.members.forEach((member) => {
|
|
139
|
-
moderators.push({ user_id: member, channel_role: models_1.StreamDefaultChannelRole.channel_member });
|
|
140
|
-
});
|
|
141
|
-
const r = yield channel.assignRoles(moderators);
|
|
142
|
-
//Members invited successfully
|
|
143
|
-
return (r === null || r === void 0 ? void 0 : r.channel) !== undefined;
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Remove members into a specific channel.
|
|
148
|
-
*
|
|
149
|
-
* @param {IChannelData} data channel data object
|
|
150
|
-
* @returns {Promise<boolean>} promise of the result to remove members
|
|
151
|
-
*/
|
|
152
|
-
removeMembers(data) {
|
|
153
|
-
const _super = Object.create(null, {
|
|
154
|
-
getChannelById: { get: () => super.getChannelById }
|
|
155
|
-
});
|
|
156
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
//Retrieve the channel
|
|
158
|
-
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
159
|
-
//get the channel from the response
|
|
160
|
-
const channel = rChannel[0];
|
|
161
|
-
//retrieve the data for members
|
|
162
|
-
const existingMemberCount = channel.data.member_count;
|
|
163
|
-
//Send the remove member request to stream
|
|
164
|
-
const r = yield channel.removeMembers(data.members);
|
|
165
|
-
//check the result
|
|
166
|
-
if (existingMemberCount == r.members.length) {
|
|
167
|
-
// error, did not remove members
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
//Members removed successfully
|
|
171
|
-
return true;
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.StreamMember = StreamMember;
|
|
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.StreamMember = void 0;
|
|
13
|
+
const models_1 = require("./models");
|
|
14
|
+
const stream_base_1 = require("./stream.base");
|
|
15
|
+
/**
|
|
16
|
+
* A class that provides methods to manage StreamAPI Channel
|
|
17
|
+
*/
|
|
18
|
+
class StreamMember extends stream_base_1.StreamBase {
|
|
19
|
+
// properties
|
|
20
|
+
/**
|
|
21
|
+
* Stream member constructor
|
|
22
|
+
*
|
|
23
|
+
* @param {StreamChat} server Stream API server
|
|
24
|
+
*/
|
|
25
|
+
constructor(server) {
|
|
26
|
+
super();
|
|
27
|
+
super.server = server;
|
|
28
|
+
}
|
|
29
|
+
// methods
|
|
30
|
+
/**
|
|
31
|
+
* Add new members into a specific channel.
|
|
32
|
+
*
|
|
33
|
+
* @param {IChannelData} data channel data object
|
|
34
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
35
|
+
*/
|
|
36
|
+
inviteMembers(data) {
|
|
37
|
+
const _super = Object.create(null, {
|
|
38
|
+
getChannelById: { get: () => super.getChannelById }
|
|
39
|
+
});
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
//Retrieve the channel
|
|
42
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
43
|
+
//get the channel from the response
|
|
44
|
+
const channel = rChannel[0];
|
|
45
|
+
//retrieve the data for members
|
|
46
|
+
const existingMemberCount = channel.data.member_count;
|
|
47
|
+
//Create the message if is necessary
|
|
48
|
+
let message = undefined;
|
|
49
|
+
//Add message text if is necessary
|
|
50
|
+
if (data.inviteMessage !== undefined) {
|
|
51
|
+
message = { text: data.inviteMessage, user_id: channel.data.created_by["id"] };
|
|
52
|
+
}
|
|
53
|
+
//Send the invite request to stream
|
|
54
|
+
const r = yield channel.inviteMembers(data.members, message);
|
|
55
|
+
//check the result
|
|
56
|
+
if (existingMemberCount == r.members.length) {
|
|
57
|
+
// error, did not add members
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
//Members invited successfully
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Add new members into a specific channel.
|
|
66
|
+
*
|
|
67
|
+
* @param {IChannelData} data channel data object
|
|
68
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
69
|
+
*/
|
|
70
|
+
addMembers(data) {
|
|
71
|
+
const _super = Object.create(null, {
|
|
72
|
+
getChannelById: { get: () => super.getChannelById }
|
|
73
|
+
});
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
//Retrieve the channel
|
|
76
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
77
|
+
//get the channel from the response
|
|
78
|
+
const channel = rChannel[0];
|
|
79
|
+
//retrieve the data for members
|
|
80
|
+
const existingMemberCount = channel.data.member_count;
|
|
81
|
+
//Create the message if is necessary
|
|
82
|
+
let message = undefined;
|
|
83
|
+
//Add message text if is necessary
|
|
84
|
+
if (data.inviteMessage !== undefined) {
|
|
85
|
+
message = { text: data.inviteMessage, user_id: channel.data.created_by["id"] };
|
|
86
|
+
}
|
|
87
|
+
//Send the invite request to stream
|
|
88
|
+
const r = yield channel.addMembers(data.members, message);
|
|
89
|
+
//check the result
|
|
90
|
+
if (existingMemberCount == r.members.length) {
|
|
91
|
+
// error, did not add members
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
//Members invited successfully
|
|
95
|
+
return true;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Add new moderator into a specific channel.
|
|
100
|
+
*
|
|
101
|
+
* @param {IChannelData} data channel data object
|
|
102
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
103
|
+
*/
|
|
104
|
+
assignModerators(data) {
|
|
105
|
+
const _super = Object.create(null, {
|
|
106
|
+
getChannelById: { get: () => super.getChannelById }
|
|
107
|
+
});
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
//Retrieve the channel
|
|
110
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
111
|
+
//get the channel from the response
|
|
112
|
+
const channel = rChannel[0];
|
|
113
|
+
const moderators = [];
|
|
114
|
+
data.members.forEach((member) => {
|
|
115
|
+
moderators.push({ user_id: member, channel_role: models_1.StreamDefaultChannelRole.channel_moderator });
|
|
116
|
+
});
|
|
117
|
+
const r = yield channel.assignRoles(moderators);
|
|
118
|
+
//Members invited successfully
|
|
119
|
+
return (r === null || r === void 0 ? void 0 : r.channel) !== undefined;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Add new members into a specific channel.
|
|
124
|
+
*
|
|
125
|
+
* @param {IChannelData} data channel data object
|
|
126
|
+
* @returns {Promise<boolean>} promise of the result to add members
|
|
127
|
+
*/
|
|
128
|
+
demoteModerators(data) {
|
|
129
|
+
const _super = Object.create(null, {
|
|
130
|
+
getChannelById: { get: () => super.getChannelById }
|
|
131
|
+
});
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
//Retrieve the channel
|
|
134
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
135
|
+
//get the channel from the response
|
|
136
|
+
const channel = rChannel[0];
|
|
137
|
+
const moderators = [];
|
|
138
|
+
data.members.forEach((member) => {
|
|
139
|
+
moderators.push({ user_id: member, channel_role: models_1.StreamDefaultChannelRole.channel_member });
|
|
140
|
+
});
|
|
141
|
+
const r = yield channel.assignRoles(moderators);
|
|
142
|
+
//Members invited successfully
|
|
143
|
+
return (r === null || r === void 0 ? void 0 : r.channel) !== undefined;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Remove members into a specific channel.
|
|
148
|
+
*
|
|
149
|
+
* @param {IChannelData} data channel data object
|
|
150
|
+
* @returns {Promise<boolean>} promise of the result to remove members
|
|
151
|
+
*/
|
|
152
|
+
removeMembers(data) {
|
|
153
|
+
const _super = Object.create(null, {
|
|
154
|
+
getChannelById: { get: () => super.getChannelById }
|
|
155
|
+
});
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
//Retrieve the channel
|
|
158
|
+
const rChannel = yield _super.getChannelById.call(this, data.channelId);
|
|
159
|
+
//get the channel from the response
|
|
160
|
+
const channel = rChannel[0];
|
|
161
|
+
//retrieve the data for members
|
|
162
|
+
const existingMemberCount = channel.data.member_count;
|
|
163
|
+
//Send the remove member request to stream
|
|
164
|
+
const r = yield channel.removeMembers(data.members);
|
|
165
|
+
//check the result
|
|
166
|
+
if (existingMemberCount == r.members.length) {
|
|
167
|
+
// error, did not remove members
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
//Members removed successfully
|
|
171
|
+
return true;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.StreamMember = StreamMember;
|
|
176
176
|
//# sourceMappingURL=stream.member.js.map
|