@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,54 +1,54 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TwilioBase = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Base client class
|
|
6
|
-
*/
|
|
7
|
-
class TwilioBase {
|
|
8
|
-
// getter / setter
|
|
9
|
-
/**
|
|
10
|
-
* getter for twilio instance
|
|
11
|
-
*
|
|
12
|
-
* @returns {Twilio} twilio instance
|
|
13
|
-
*/
|
|
14
|
-
get server() {
|
|
15
|
-
return this._server;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* setter for twilio instance
|
|
19
|
-
*
|
|
20
|
-
* @param {TwilioAuth} value twilio instance
|
|
21
|
-
*/
|
|
22
|
-
set server(value) {
|
|
23
|
-
this._server = value;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* getter for twilio auth
|
|
27
|
-
*
|
|
28
|
-
* @returns {TwilioAuth} twilio auth instance
|
|
29
|
-
*/
|
|
30
|
-
get auth() {
|
|
31
|
-
return this._auth;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* setter for twilio auth instance
|
|
35
|
-
*
|
|
36
|
-
* @param {TwilioAuth} value twilio auth instance
|
|
37
|
-
*/
|
|
38
|
-
set auth(value) {
|
|
39
|
-
this._auth = value;
|
|
40
|
-
}
|
|
41
|
-
// methods
|
|
42
|
-
/**
|
|
43
|
-
* Get token for extended classes
|
|
44
|
-
*
|
|
45
|
-
* @param {string} userId user id
|
|
46
|
-
* @param {string} roomName room name
|
|
47
|
-
* @returns {string} returns the token value
|
|
48
|
-
*/
|
|
49
|
-
getToken(userId, roomName) {
|
|
50
|
-
return this.auth.token(userId, roomName);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.TwilioBase = TwilioBase;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TwilioBase = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base client class
|
|
6
|
+
*/
|
|
7
|
+
class TwilioBase {
|
|
8
|
+
// getter / setter
|
|
9
|
+
/**
|
|
10
|
+
* getter for twilio instance
|
|
11
|
+
*
|
|
12
|
+
* @returns {Twilio} twilio instance
|
|
13
|
+
*/
|
|
14
|
+
get server() {
|
|
15
|
+
return this._server;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* setter for twilio instance
|
|
19
|
+
*
|
|
20
|
+
* @param {TwilioAuth} value twilio instance
|
|
21
|
+
*/
|
|
22
|
+
set server(value) {
|
|
23
|
+
this._server = value;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* getter for twilio auth
|
|
27
|
+
*
|
|
28
|
+
* @returns {TwilioAuth} twilio auth instance
|
|
29
|
+
*/
|
|
30
|
+
get auth() {
|
|
31
|
+
return this._auth;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* setter for twilio auth instance
|
|
35
|
+
*
|
|
36
|
+
* @param {TwilioAuth} value twilio auth instance
|
|
37
|
+
*/
|
|
38
|
+
set auth(value) {
|
|
39
|
+
this._auth = value;
|
|
40
|
+
}
|
|
41
|
+
// methods
|
|
42
|
+
/**
|
|
43
|
+
* Get token for extended classes
|
|
44
|
+
*
|
|
45
|
+
* @param {string} userId user id
|
|
46
|
+
* @param {string} roomName room name
|
|
47
|
+
* @returns {string} returns the token value
|
|
48
|
+
*/
|
|
49
|
+
getToken(userId, roomName) {
|
|
50
|
+
return this.auth.token(userId, roomName);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.TwilioBase = TwilioBase;
|
|
54
54
|
//# sourceMappingURL=twilio.base.js.map
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { TwilioAuth } from "./twilio.auth";
|
|
2
|
-
import { Twilio } from "twilio";
|
|
3
|
-
import { TwilioBase } from "./twilio.base";
|
|
4
|
-
import { IRoomData } from "./models";
|
|
5
|
-
/**
|
|
6
|
-
* Twilio Room API declarations
|
|
7
|
-
*/
|
|
8
|
-
interface ITwilioRoom {
|
|
9
|
-
/**
|
|
10
|
-
* Create a new room in Twilio
|
|
11
|
-
*/
|
|
12
|
-
findOrCreateRoom(roomName: string): Promise<IRoomData>;
|
|
13
|
-
/**
|
|
14
|
-
* Find an existing room un Twilio
|
|
15
|
-
*/
|
|
16
|
-
findRoom(roomName: string): Promise<IRoomData>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Twilio Room API implementation
|
|
20
|
-
*/
|
|
21
|
-
export declare class TwilioRoom extends TwilioBase implements ITwilioRoom {
|
|
22
|
-
private _expMinutes;
|
|
23
|
-
/**
|
|
24
|
-
* Twilio room constructor
|
|
25
|
-
*
|
|
26
|
-
* @param {TwilioAuth} auth Twilio auth
|
|
27
|
-
* @param {Twilio} server Twilio API Server
|
|
28
|
-
* @param {number} expMins expiration time for the timeout room, in minutes.
|
|
29
|
-
*/
|
|
30
|
-
constructor(auth: TwilioAuth, server: Twilio, expMins: number);
|
|
31
|
-
/**
|
|
32
|
-
* This will find or Create a new room in Twilio
|
|
33
|
-
*
|
|
34
|
-
* @param {string} roomName room name
|
|
35
|
-
* @returns {Promise<IRoomData>} promise of the result to create or get a room
|
|
36
|
-
*/
|
|
37
|
-
findOrCreateRoom(roomName: string): Promise<IRoomData>;
|
|
38
|
-
/**
|
|
39
|
-
* Find an existing room un Twilio
|
|
40
|
-
*
|
|
41
|
-
* @param {string} roomName room name
|
|
42
|
-
* @returns {Promise<IRoomData>} promise of the result to get a room
|
|
43
|
-
*/
|
|
44
|
-
findRoom(roomName: string): Promise<IRoomData>;
|
|
45
|
-
}
|
|
46
|
-
export {};
|
|
1
|
+
import { TwilioAuth } from "./twilio.auth";
|
|
2
|
+
import { Twilio } from "twilio";
|
|
3
|
+
import { TwilioBase } from "./twilio.base";
|
|
4
|
+
import { IRoomData } from "./models";
|
|
5
|
+
/**
|
|
6
|
+
* Twilio Room API declarations
|
|
7
|
+
*/
|
|
8
|
+
interface ITwilioRoom {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new room in Twilio
|
|
11
|
+
*/
|
|
12
|
+
findOrCreateRoom(roomName: string): Promise<IRoomData>;
|
|
13
|
+
/**
|
|
14
|
+
* Find an existing room un Twilio
|
|
15
|
+
*/
|
|
16
|
+
findRoom(roomName: string): Promise<IRoomData>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Twilio Room API implementation
|
|
20
|
+
*/
|
|
21
|
+
export declare class TwilioRoom extends TwilioBase implements ITwilioRoom {
|
|
22
|
+
private _expMinutes;
|
|
23
|
+
/**
|
|
24
|
+
* Twilio room constructor
|
|
25
|
+
*
|
|
26
|
+
* @param {TwilioAuth} auth Twilio auth
|
|
27
|
+
* @param {Twilio} server Twilio API Server
|
|
28
|
+
* @param {number} expMins expiration time for the timeout room, in minutes.
|
|
29
|
+
*/
|
|
30
|
+
constructor(auth: TwilioAuth, server: Twilio, expMins: number);
|
|
31
|
+
/**
|
|
32
|
+
* This will find or Create a new room in Twilio
|
|
33
|
+
*
|
|
34
|
+
* @param {string} roomName room name
|
|
35
|
+
* @returns {Promise<IRoomData>} promise of the result to create or get a room
|
|
36
|
+
*/
|
|
37
|
+
findOrCreateRoom(roomName: string): Promise<IRoomData>;
|
|
38
|
+
/**
|
|
39
|
+
* Find an existing room un Twilio
|
|
40
|
+
*
|
|
41
|
+
* @param {string} roomName room name
|
|
42
|
+
* @returns {Promise<IRoomData>} promise of the result to get a room
|
|
43
|
+
*/
|
|
44
|
+
findRoom(roomName: string): Promise<IRoomData>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.TwilioRoom = void 0;
|
|
22
|
-
const twilio_auth_1 = require("./twilio.auth");
|
|
23
|
-
const tsyringe_1 = require("tsyringe");
|
|
24
|
-
const twilio_1 = require("twilio");
|
|
25
|
-
const twilio_base_1 = require("./twilio.base");
|
|
26
|
-
/**
|
|
27
|
-
* Twilio Room API implementation
|
|
28
|
-
*/
|
|
29
|
-
let TwilioRoom = class TwilioRoom extends twilio_base_1.TwilioBase {
|
|
30
|
-
/**
|
|
31
|
-
* Twilio room constructor
|
|
32
|
-
*
|
|
33
|
-
* @param {TwilioAuth} auth Twilio auth
|
|
34
|
-
* @param {Twilio} server Twilio API Server
|
|
35
|
-
* @param {number} expMins expiration time for the timeout room, in minutes.
|
|
36
|
-
*/
|
|
37
|
-
constructor(auth, server, expMins) {
|
|
38
|
-
super();
|
|
39
|
-
super.auth = auth;
|
|
40
|
-
super.server = server;
|
|
41
|
-
this._expMinutes = expMins;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* This will find or Create a new room in Twilio
|
|
45
|
-
*
|
|
46
|
-
* @param {string} roomName room name
|
|
47
|
-
* @returns {Promise<IRoomData>} promise of the result to create or get a room
|
|
48
|
-
*/
|
|
49
|
-
findOrCreateRoom(roomName) {
|
|
50
|
-
const _super = Object.create(null, {
|
|
51
|
-
server: { get: () => super.server }
|
|
52
|
-
});
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
try {
|
|
55
|
-
// see if the room exists already. If it doesn't, this will throw
|
|
56
|
-
// error 20404.
|
|
57
|
-
const r = yield _super.server.video.rooms(roomName).fetch();
|
|
58
|
-
return {
|
|
59
|
-
sid: r.sid,
|
|
60
|
-
exist: true,
|
|
61
|
-
status: r.status
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
// the room was not found, so create it
|
|
66
|
-
if (error.code == 20404) {
|
|
67
|
-
//Create the room in Twilio
|
|
68
|
-
const r = yield _super.server.video.rooms.create({
|
|
69
|
-
uniqueName: roomName,
|
|
70
|
-
unusedRoomTimeout: this._expMinutes
|
|
71
|
-
});
|
|
72
|
-
//Check the result of the request
|
|
73
|
-
if (r) {
|
|
74
|
-
//Return the sid for the new room
|
|
75
|
-
return { sid: r.sid, exist: false };
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
//Return null
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// let other errors bubble up
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Find an existing room un Twilio
|
|
91
|
-
*
|
|
92
|
-
* @param {string} roomName room name
|
|
93
|
-
* @returns {Promise<IRoomData>} promise of the result to get a room
|
|
94
|
-
*/
|
|
95
|
-
findRoom(roomName) {
|
|
96
|
-
const _super = Object.create(null, {
|
|
97
|
-
server: { get: () => super.server }
|
|
98
|
-
});
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
// see if the room exists already. If it doesn't, this will return undefined
|
|
101
|
-
try {
|
|
102
|
-
const r = yield _super.server.video.rooms(roomName).fetch();
|
|
103
|
-
return {
|
|
104
|
-
sid: r.sid,
|
|
105
|
-
exist: true,
|
|
106
|
-
status: r.status
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
// the room was not found, so create it
|
|
111
|
-
if (error.code == 20404)
|
|
112
|
-
return undefined;
|
|
113
|
-
// let other errors bubble up
|
|
114
|
-
else
|
|
115
|
-
throw error;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
TwilioRoom = __decorate([
|
|
121
|
-
(0, tsyringe_1.injectable)(),
|
|
122
|
-
__metadata("design:paramtypes", [twilio_auth_1.TwilioAuth, twilio_1.Twilio, Number])
|
|
123
|
-
], TwilioRoom);
|
|
124
|
-
exports.TwilioRoom = TwilioRoom;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.TwilioRoom = void 0;
|
|
22
|
+
const twilio_auth_1 = require("./twilio.auth");
|
|
23
|
+
const tsyringe_1 = require("tsyringe");
|
|
24
|
+
const twilio_1 = require("twilio");
|
|
25
|
+
const twilio_base_1 = require("./twilio.base");
|
|
26
|
+
/**
|
|
27
|
+
* Twilio Room API implementation
|
|
28
|
+
*/
|
|
29
|
+
let TwilioRoom = class TwilioRoom extends twilio_base_1.TwilioBase {
|
|
30
|
+
/**
|
|
31
|
+
* Twilio room constructor
|
|
32
|
+
*
|
|
33
|
+
* @param {TwilioAuth} auth Twilio auth
|
|
34
|
+
* @param {Twilio} server Twilio API Server
|
|
35
|
+
* @param {number} expMins expiration time for the timeout room, in minutes.
|
|
36
|
+
*/
|
|
37
|
+
constructor(auth, server, expMins) {
|
|
38
|
+
super();
|
|
39
|
+
super.auth = auth;
|
|
40
|
+
super.server = server;
|
|
41
|
+
this._expMinutes = expMins;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* This will find or Create a new room in Twilio
|
|
45
|
+
*
|
|
46
|
+
* @param {string} roomName room name
|
|
47
|
+
* @returns {Promise<IRoomData>} promise of the result to create or get a room
|
|
48
|
+
*/
|
|
49
|
+
findOrCreateRoom(roomName) {
|
|
50
|
+
const _super = Object.create(null, {
|
|
51
|
+
server: { get: () => super.server }
|
|
52
|
+
});
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
try {
|
|
55
|
+
// see if the room exists already. If it doesn't, this will throw
|
|
56
|
+
// error 20404.
|
|
57
|
+
const r = yield _super.server.video.rooms(roomName).fetch();
|
|
58
|
+
return {
|
|
59
|
+
sid: r.sid,
|
|
60
|
+
exist: true,
|
|
61
|
+
status: r.status
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
// the room was not found, so create it
|
|
66
|
+
if (error.code == 20404) {
|
|
67
|
+
//Create the room in Twilio
|
|
68
|
+
const r = yield _super.server.video.rooms.create({
|
|
69
|
+
uniqueName: roomName,
|
|
70
|
+
unusedRoomTimeout: this._expMinutes
|
|
71
|
+
});
|
|
72
|
+
//Check the result of the request
|
|
73
|
+
if (r) {
|
|
74
|
+
//Return the sid for the new room
|
|
75
|
+
return { sid: r.sid, exist: false };
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
//Return null
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// let other errors bubble up
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Find an existing room un Twilio
|
|
91
|
+
*
|
|
92
|
+
* @param {string} roomName room name
|
|
93
|
+
* @returns {Promise<IRoomData>} promise of the result to get a room
|
|
94
|
+
*/
|
|
95
|
+
findRoom(roomName) {
|
|
96
|
+
const _super = Object.create(null, {
|
|
97
|
+
server: { get: () => super.server }
|
|
98
|
+
});
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
// see if the room exists already. If it doesn't, this will return undefined
|
|
101
|
+
try {
|
|
102
|
+
const r = yield _super.server.video.rooms(roomName).fetch();
|
|
103
|
+
return {
|
|
104
|
+
sid: r.sid,
|
|
105
|
+
exist: true,
|
|
106
|
+
status: r.status
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
// the room was not found, so create it
|
|
111
|
+
if (error.code == 20404)
|
|
112
|
+
return undefined;
|
|
113
|
+
// let other errors bubble up
|
|
114
|
+
else
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
TwilioRoom = __decorate([
|
|
121
|
+
(0, tsyringe_1.injectable)(),
|
|
122
|
+
__metadata("design:paramtypes", [twilio_auth_1.TwilioAuth, twilio_1.Twilio, Number])
|
|
123
|
+
], TwilioRoom);
|
|
124
|
+
exports.TwilioRoom = TwilioRoom;
|
|
125
125
|
//# sourceMappingURL=twilio.room.js.map
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bwi-mentorspaces/application-utils-npm",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Mentor Spaces npm packages for reusable models, utils, and abstracted, commonly used processes for DB Repo, Logging, etc.",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Mentor Spaces",
|
|
7
|
-
"url": "https://www.mentorspaces.com"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"clean": "rimraf .dist",
|
|
11
|
-
"patch": "npm version patch",
|
|
12
|
-
"lint": "eslint ./ --fix --max-warnings 0 --ext .js,.ts",
|
|
13
|
-
"compile": "tsc --build",
|
|
14
|
-
"build:local": "npm-run-all clean lint compile",
|
|
15
|
-
"build": "npm-run-all clean lint patch compile",
|
|
16
|
-
"deploy": "npm publish .dist --access public"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@types/aws-lambda": "^8.10.92",
|
|
20
|
-
"@types/crypto-js": "^4.1.0",
|
|
21
|
-
"@types/express": "^4.17.13",
|
|
22
|
-
"@types/node": "^17.0.8",
|
|
23
|
-
"@types/supertest": "^2.0.11",
|
|
24
|
-
"@types/uuid": "^8.3.4",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
|
26
|
-
"@typescript-eslint/parser": "^5.9.0",
|
|
27
|
-
"eslint": "^7.32.0",
|
|
28
|
-
"eslint-config-prettier": "^8.3.0",
|
|
29
|
-
"eslint-config-standard": "^16.0.3",
|
|
30
|
-
"eslint-plugin-import": "^2.25.4",
|
|
31
|
-
"eslint-plugin-jsdoc": "^37.6.1",
|
|
32
|
-
"eslint-plugin-node": "^11.1.0",
|
|
33
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
34
|
-
"eslint-plugin-promise": "^5.2.0",
|
|
35
|
-
"npm-run-all": "^4.1.5",
|
|
36
|
-
"prettier": "^2.5.1",
|
|
37
|
-
"rimraf": "^3.0.2",
|
|
38
|
-
"shx": "^0.3.4",
|
|
39
|
-
"typescript": "^4.5.5"
|
|
40
|
-
},
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"aws-lambda": "^1.0.7",
|
|
43
|
-
"axios": "^0.24.0",
|
|
44
|
-
"crypto-js": "^4.1.1",
|
|
45
|
-
"express": "^4.17.2",
|
|
46
|
-
"guid-typescript": "^1.0.9",
|
|
47
|
-
"reflect-metadata": "^0.1.13",
|
|
48
|
-
"serverless-http": "^2.7.0",
|
|
49
|
-
"stream-chat": "^6.6.0",
|
|
50
|
-
"supertest": "^6.2.2",
|
|
51
|
-
"swagger-jsdoc": "^6.1.0",
|
|
52
|
-
"swagger-ui-express": "^4.3.0",
|
|
53
|
-
"tsyringe": "^4.6.0",
|
|
54
|
-
"twilio": "^3.76.0",
|
|
55
|
-
"uuid": "^8.3.2"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bwi-mentorspaces/application-utils-npm",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"description": "Mentor Spaces npm packages for reusable models, utils, and abstracted, commonly used processes for DB Repo, Logging, etc.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Mentor Spaces",
|
|
7
|
+
"url": "https://www.mentorspaces.com"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf .dist",
|
|
11
|
+
"patch": "npm version patch",
|
|
12
|
+
"lint": "eslint ./ --fix --max-warnings 0 --ext .js,.ts",
|
|
13
|
+
"compile": "tsc --build",
|
|
14
|
+
"build:local": "npm-run-all clean lint compile",
|
|
15
|
+
"build": "npm-run-all clean lint patch compile",
|
|
16
|
+
"deploy": "npm publish .dist --access public"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/aws-lambda": "^8.10.92",
|
|
20
|
+
"@types/crypto-js": "^4.1.0",
|
|
21
|
+
"@types/express": "^4.17.13",
|
|
22
|
+
"@types/node": "^17.0.8",
|
|
23
|
+
"@types/supertest": "^2.0.11",
|
|
24
|
+
"@types/uuid": "^8.3.4",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
|
26
|
+
"@typescript-eslint/parser": "^5.9.0",
|
|
27
|
+
"eslint": "^7.32.0",
|
|
28
|
+
"eslint-config-prettier": "^8.3.0",
|
|
29
|
+
"eslint-config-standard": "^16.0.3",
|
|
30
|
+
"eslint-plugin-import": "^2.25.4",
|
|
31
|
+
"eslint-plugin-jsdoc": "^37.6.1",
|
|
32
|
+
"eslint-plugin-node": "^11.1.0",
|
|
33
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
34
|
+
"eslint-plugin-promise": "^5.2.0",
|
|
35
|
+
"npm-run-all": "^4.1.5",
|
|
36
|
+
"prettier": "^2.5.1",
|
|
37
|
+
"rimraf": "^3.0.2",
|
|
38
|
+
"shx": "^0.3.4",
|
|
39
|
+
"typescript": "^4.5.5"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"aws-lambda": "^1.0.7",
|
|
43
|
+
"axios": "^0.24.0",
|
|
44
|
+
"crypto-js": "^4.1.1",
|
|
45
|
+
"express": "^4.17.2",
|
|
46
|
+
"guid-typescript": "^1.0.9",
|
|
47
|
+
"reflect-metadata": "^0.1.13",
|
|
48
|
+
"serverless-http": "^2.7.0",
|
|
49
|
+
"stream-chat": "^6.6.0",
|
|
50
|
+
"supertest": "^6.2.2",
|
|
51
|
+
"swagger-jsdoc": "^6.1.0",
|
|
52
|
+
"swagger-ui-express": "^4.3.0",
|
|
53
|
+
"tsyringe": "^4.6.0",
|
|
54
|
+
"twilio": "^3.76.0",
|
|
55
|
+
"uuid": "^8.3.2"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swagger Config declaration
|
|
3
|
-
*/
|
|
4
|
-
export interface ISwaggerConfig {
|
|
5
|
-
swaggerVersion: string;
|
|
6
|
-
contact: {
|
|
7
|
-
name: string;
|
|
8
|
-
url: string;
|
|
9
|
-
};
|
|
10
|
-
service: {
|
|
11
|
-
version: string;
|
|
12
|
-
title: string;
|
|
13
|
-
description: string;
|
|
14
|
-
routes: string;
|
|
15
|
-
docsUrl: string;
|
|
16
|
-
};
|
|
17
|
-
tags: object[];
|
|
18
|
-
basePath: string;
|
|
19
|
-
paths: object;
|
|
20
|
-
definitions: object;
|
|
21
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Swagger Config declaration
|
|
3
|
+
*/
|
|
4
|
+
export interface ISwaggerConfig {
|
|
5
|
+
swaggerVersion: string;
|
|
6
|
+
contact: {
|
|
7
|
+
name: string;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
service: {
|
|
11
|
+
version: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
routes: string;
|
|
15
|
+
docsUrl: string;
|
|
16
|
+
};
|
|
17
|
+
tags: object[];
|
|
18
|
+
basePath: string;
|
|
19
|
+
paths: object;
|
|
20
|
+
definitions: object;
|
|
21
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=swagger.config.js.map
|