@ipcom/asterisk-ari 0.0.145-beta → 0.0.145
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/dist/cjs/index.cjs +77 -740
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/esm/index.js +77 -739
- package/dist/esm/index.js.map +4 -4
- package/dist/types/ari-client/ariClient.d.ts +1 -13
- package/dist/types/ari-client/ariClient.d.ts.map +1 -1
- package/dist/types/ari-client/baseClient.d.ts.map +1 -1
- package/dist/types/ari-client/interfaces/events.types.d.ts +0 -5
- package/dist/types/ari-client/interfaces/events.types.d.ts.map +1 -1
- package/dist/types/ari-client/interfaces/index.d.ts +1 -1
- package/dist/types/ari-client/interfaces/index.d.ts.map +1 -1
- package/dist/types/ari-client/resources/bridges.d.ts +14 -365
- package/dist/types/ari-client/resources/bridges.d.ts.map +1 -1
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/resources/playbacks.d.ts +1 -1
- package/dist/types/ari-client/resources/playbacks.d.ts.map +1 -1
- package/dist/types/ari-client/websocketClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -582,7 +582,6 @@ __export(src_exports, {
|
|
|
582
582
|
Applications: () => Applications,
|
|
583
583
|
AriClient: () => AriClient,
|
|
584
584
|
Asterisk: () => Asterisk,
|
|
585
|
-
BridgeInstance: () => BridgeInstance,
|
|
586
585
|
Bridges: () => Bridges,
|
|
587
586
|
ChannelInstance: () => ChannelInstance,
|
|
588
587
|
Channels: () => Channels,
|
|
@@ -632,7 +631,6 @@ var BaseClient = class {
|
|
|
632
631
|
}
|
|
633
632
|
});
|
|
634
633
|
this.addInterceptors();
|
|
635
|
-
console.log(`BaseClient initialized for ${baseUrl}`);
|
|
636
634
|
}
|
|
637
635
|
client;
|
|
638
636
|
/**
|
|
@@ -657,7 +655,6 @@ var BaseClient = class {
|
|
|
657
655
|
addInterceptors() {
|
|
658
656
|
this.client.interceptors.request.use(
|
|
659
657
|
(config) => {
|
|
660
|
-
console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
|
|
661
658
|
return config;
|
|
662
659
|
},
|
|
663
660
|
(error) => {
|
|
@@ -668,7 +665,6 @@ var BaseClient = class {
|
|
|
668
665
|
);
|
|
669
666
|
this.client.interceptors.response.use(
|
|
670
667
|
(response) => {
|
|
671
|
-
console.log(`[Response] ${response.status} ${response.config.url}`);
|
|
672
668
|
return response;
|
|
673
669
|
},
|
|
674
670
|
(error) => {
|
|
@@ -791,7 +787,6 @@ var BaseClient = class {
|
|
|
791
787
|
...this.client.defaults.headers.common,
|
|
792
788
|
...headers
|
|
793
789
|
};
|
|
794
|
-
console.log("Updated client headers");
|
|
795
790
|
}
|
|
796
791
|
/**
|
|
797
792
|
* Gets the current request timeout setting.
|
|
@@ -804,7 +799,6 @@ var BaseClient = class {
|
|
|
804
799
|
*/
|
|
805
800
|
setTimeout(timeout) {
|
|
806
801
|
this.client.defaults.timeout = timeout;
|
|
807
|
-
console.log(`Updated timeout to ${timeout}ms`);
|
|
808
802
|
}
|
|
809
803
|
};
|
|
810
804
|
|
|
@@ -815,7 +809,7 @@ var Applications = class {
|
|
|
815
809
|
}
|
|
816
810
|
/**
|
|
817
811
|
* Lists all applications.
|
|
818
|
-
*
|
|
812
|
+
*
|
|
819
813
|
* @returns A promise that resolves to an array of Application objects.
|
|
820
814
|
* @throws {Error} If the API response is not an array.
|
|
821
815
|
*/
|
|
@@ -828,7 +822,7 @@ var Applications = class {
|
|
|
828
822
|
}
|
|
829
823
|
/**
|
|
830
824
|
* Retrieves details of a specific application.
|
|
831
|
-
*
|
|
825
|
+
*
|
|
832
826
|
* @param appName - The name of the application to retrieve details for.
|
|
833
827
|
* @returns A promise that resolves to an ApplicationDetails object.
|
|
834
828
|
* @throws {Error} If there's an error fetching the application details.
|
|
@@ -845,7 +839,7 @@ var Applications = class {
|
|
|
845
839
|
}
|
|
846
840
|
/**
|
|
847
841
|
* Sends a message to a specific application.
|
|
848
|
-
*
|
|
842
|
+
*
|
|
849
843
|
* @param appName - The name of the application to send the message to.
|
|
850
844
|
* @param body - The message to be sent, containing an event and optional data.
|
|
851
845
|
* @returns A promise that resolves when the message is successfully sent.
|
|
@@ -938,681 +932,97 @@ var Asterisk = class {
|
|
|
938
932
|
};
|
|
939
933
|
|
|
940
934
|
// src/ari-client/resources/bridges.ts
|
|
941
|
-
var import_events = require("events");
|
|
942
|
-
var import_axios2 = require("axios");
|
|
943
|
-
|
|
944
|
-
// src/ari-client/interfaces/events.types.ts
|
|
945
|
-
var bridgeEvents = [
|
|
946
|
-
"BridgeCreated",
|
|
947
|
-
"BridgeDestroyed",
|
|
948
|
-
"BridgeMerged",
|
|
949
|
-
"BridgeBlindTransfer",
|
|
950
|
-
"BridgeAttendedTransfer",
|
|
951
|
-
"BridgeVideoSourceChanged"
|
|
952
|
-
];
|
|
953
|
-
|
|
954
|
-
// src/ari-client/utils.ts
|
|
955
|
-
function toQueryParams2(options) {
|
|
956
|
-
return new URLSearchParams(
|
|
957
|
-
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
|
|
958
|
-
).toString();
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
// src/ari-client/resources/bridges.ts
|
|
962
|
-
var getErrorMessage = (error) => {
|
|
963
|
-
if ((0, import_axios2.isAxiosError)(error)) {
|
|
964
|
-
return error.response?.data?.message || error.message || "Um erro do axios ocorreu";
|
|
965
|
-
}
|
|
966
|
-
if (error instanceof Error) {
|
|
967
|
-
return error.message;
|
|
968
|
-
}
|
|
969
|
-
return "Um erro desconhecido ocorreu";
|
|
970
|
-
};
|
|
971
|
-
var BridgeInstance = class {
|
|
972
|
-
/**
|
|
973
|
-
* Creates a new BridgeInstance.
|
|
974
|
-
*
|
|
975
|
-
* @param client - The AriClient instance for making API calls.
|
|
976
|
-
* @param baseClient - The BaseClient instance for making HTTP requests.
|
|
977
|
-
* @param bridgeId - Optional. The ID of the bridge. If not provided, a new ID will be generated.
|
|
978
|
-
*/
|
|
979
|
-
constructor(client, baseClient, bridgeId) {
|
|
980
|
-
this.client = client;
|
|
981
|
-
this.baseClient = baseClient;
|
|
982
|
-
this.id = bridgeId || `bridge-${Date.now()}`;
|
|
983
|
-
console.log(`BridgeInstance inicializada com ID: ${this.id}`);
|
|
984
|
-
}
|
|
985
|
-
eventEmitter = new import_events.EventEmitter();
|
|
986
|
-
bridgeData = null;
|
|
987
|
-
id;
|
|
988
|
-
/**
|
|
989
|
-
* Registers a listener for specific bridge events.
|
|
990
|
-
*
|
|
991
|
-
* @param event - The type of event to listen for.
|
|
992
|
-
* @param listener - The callback function to be called when the event occurs.
|
|
993
|
-
*/
|
|
994
|
-
/**
|
|
995
|
-
* Registers a listener for specific bridge events.
|
|
996
|
-
*
|
|
997
|
-
* This method allows you to attach an event listener to the bridge instance for a specific event type.
|
|
998
|
-
* When the specified event occurs, the provided listener function will be called with the event data.
|
|
999
|
-
*
|
|
1000
|
-
* @template T - The specific type of WebSocketEvent to listen for.
|
|
1001
|
-
* It receives the event data as its parameter.
|
|
1002
|
-
* @returns {void}
|
|
1003
|
-
*
|
|
1004
|
-
* @example
|
|
1005
|
-
* bridge.on('BridgeCreated', (event) => {
|
|
1006
|
-
* console.log('Bridge created:', event.bridge.id);
|
|
1007
|
-
* });
|
|
1008
|
-
* @param event
|
|
1009
|
-
* @param listener
|
|
1010
|
-
*/
|
|
1011
|
-
on(event, listener) {
|
|
1012
|
-
if (!event) {
|
|
1013
|
-
throw new Error("Event type is required");
|
|
1014
|
-
}
|
|
1015
|
-
const wrappedListener = (data) => {
|
|
1016
|
-
if ("bridge" in data && data.bridge?.id === this.id) {
|
|
1017
|
-
listener(data);
|
|
1018
|
-
}
|
|
1019
|
-
};
|
|
1020
|
-
this.eventEmitter.on(event, wrappedListener);
|
|
1021
|
-
console.log(`Event listener registered for ${event} on bridge ${this.id}`);
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* Registers a one-time listener for specific bridge events.
|
|
1025
|
-
*
|
|
1026
|
-
* @param event - The type of event to listen for.
|
|
1027
|
-
* @param listener - The callback function to be called when the event occurs.
|
|
1028
|
-
*/
|
|
1029
|
-
once(event, listener) {
|
|
1030
|
-
if (!event) {
|
|
1031
|
-
throw new Error("Event type is required");
|
|
1032
|
-
}
|
|
1033
|
-
const wrappedListener = (data) => {
|
|
1034
|
-
if ("bridge" in data && data.bridge?.id === this.id) {
|
|
1035
|
-
listener(data);
|
|
1036
|
-
}
|
|
1037
|
-
};
|
|
1038
|
-
this.eventEmitter.once(event, wrappedListener);
|
|
1039
|
-
console.log(
|
|
1040
|
-
`One-time listener registered for ${event} on bridge ${this.id}`
|
|
1041
|
-
);
|
|
1042
|
-
}
|
|
1043
|
-
/**
|
|
1044
|
-
* Removes event listener(s) from the bridge.
|
|
1045
|
-
*
|
|
1046
|
-
* @param event - The type of event to remove listeners for.
|
|
1047
|
-
* @param listener - Optional. The specific listener to remove. If not provided, all listeners for the event will be removed.
|
|
1048
|
-
*/
|
|
1049
|
-
off(event, listener) {
|
|
1050
|
-
if (!event) {
|
|
1051
|
-
throw new Error("Event type is required");
|
|
1052
|
-
}
|
|
1053
|
-
if (listener) {
|
|
1054
|
-
this.eventEmitter.off(event, listener);
|
|
1055
|
-
console.log(
|
|
1056
|
-
`Specific listener removed for ${event} on bridge ${this.id}`
|
|
1057
|
-
);
|
|
1058
|
-
} else {
|
|
1059
|
-
this.eventEmitter.removeAllListeners(event);
|
|
1060
|
-
console.log(`All listeners removed for ${event} on bridge ${this.id}`);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Emits an event if it corresponds to the current bridge.
|
|
1065
|
-
*
|
|
1066
|
-
* @param event - The WebSocketEvent to emit.
|
|
1067
|
-
*/
|
|
1068
|
-
emitEvent(event) {
|
|
1069
|
-
if (!event) {
|
|
1070
|
-
console.warn("Invalid event received");
|
|
1071
|
-
return;
|
|
1072
|
-
}
|
|
1073
|
-
if ("bridge" in event && event.bridge?.id === this.id) {
|
|
1074
|
-
this.eventEmitter.emit(event.type, event);
|
|
1075
|
-
console.log(`Event ${event.type} emitted for bridge ${this.id}`);
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* Removes all event listeners from this bridge instance.
|
|
1080
|
-
*/
|
|
1081
|
-
removeAllListeners() {
|
|
1082
|
-
this.eventEmitter.removeAllListeners();
|
|
1083
|
-
console.log(`All listeners removed from bridge ${this.id}`);
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* Retrieves the current details of the bridge.
|
|
1087
|
-
*
|
|
1088
|
-
* @returns A Promise that resolves to the Bridge object containing the current details.
|
|
1089
|
-
* @throws An error if the retrieval fails.
|
|
1090
|
-
*/
|
|
1091
|
-
async get() {
|
|
1092
|
-
try {
|
|
1093
|
-
if (!this.id) {
|
|
1094
|
-
throw new Error("No bridge associated with this instance");
|
|
1095
|
-
}
|
|
1096
|
-
this.bridgeData = await this.baseClient.get(
|
|
1097
|
-
`/bridges/${this.id}`
|
|
1098
|
-
);
|
|
1099
|
-
console.log(`Details retrieved for bridge ${this.id}`);
|
|
1100
|
-
return this.bridgeData;
|
|
1101
|
-
} catch (error) {
|
|
1102
|
-
const message = getErrorMessage(error);
|
|
1103
|
-
console.error(`Error retrieving details for bridge ${this.id}:`, message);
|
|
1104
|
-
throw new Error(`Failed to get bridge details: ${message}`);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Adds channels to the bridge.
|
|
1109
|
-
*
|
|
1110
|
-
* @param request - The AddChannelRequest object containing the channels to add.
|
|
1111
|
-
* @throws An error if the operation fails.
|
|
1112
|
-
*/
|
|
1113
|
-
async add(request) {
|
|
1114
|
-
try {
|
|
1115
|
-
const queryParams = toQueryParams2({
|
|
1116
|
-
channel: Array.isArray(request.channel) ? request.channel.join(",") : request.channel,
|
|
1117
|
-
...request.role && { role: request.role }
|
|
1118
|
-
});
|
|
1119
|
-
await this.baseClient.post(
|
|
1120
|
-
`/bridges/${this.id}/addChannel?${queryParams}`
|
|
1121
|
-
);
|
|
1122
|
-
console.log(`Channels added to bridge ${this.id}`);
|
|
1123
|
-
} catch (error) {
|
|
1124
|
-
const message = getErrorMessage(error);
|
|
1125
|
-
console.error(`Error adding channels to bridge ${this.id}:`, message);
|
|
1126
|
-
throw new Error(`Failed to add channels: ${message}`);
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* Removes channels from the bridge.
|
|
1131
|
-
*
|
|
1132
|
-
* @param request - The RemoveChannelRequest object containing the channels to remove.
|
|
1133
|
-
* @throws An error if the operation fails.
|
|
1134
|
-
*/
|
|
1135
|
-
async remove(request) {
|
|
1136
|
-
try {
|
|
1137
|
-
const queryParams = toQueryParams2({
|
|
1138
|
-
channel: Array.isArray(request.channel) ? request.channel.join(",") : request.channel
|
|
1139
|
-
});
|
|
1140
|
-
await this.baseClient.post(
|
|
1141
|
-
`/bridges/${this.id}/removeChannel?${queryParams}`
|
|
1142
|
-
);
|
|
1143
|
-
console.log(`Channels removed from bridge ${this.id}`);
|
|
1144
|
-
} catch (error) {
|
|
1145
|
-
const message = getErrorMessage(error);
|
|
1146
|
-
console.error(`Error removing channels from bridge ${this.id}:`, message);
|
|
1147
|
-
throw new Error(`Failed to remove channels: ${message}`);
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* Plays media on the bridge.
|
|
1152
|
-
*
|
|
1153
|
-
* @param request - The PlayMediaRequest object containing the media details to play.
|
|
1154
|
-
* @returns A Promise that resolves to a BridgePlayback object.
|
|
1155
|
-
* @throws An error if the operation fails.
|
|
1156
|
-
*/
|
|
1157
|
-
async playMedia(request) {
|
|
1158
|
-
try {
|
|
1159
|
-
const queryParams = new URLSearchParams({
|
|
1160
|
-
...request.lang && { lang: request.lang },
|
|
1161
|
-
...request.offsetms && { offsetms: request.offsetms.toString() },
|
|
1162
|
-
...request.skipms && { skipms: request.skipms.toString() },
|
|
1163
|
-
...request.playbackId && { playbackId: request.playbackId }
|
|
1164
|
-
}).toString();
|
|
1165
|
-
const result = await this.baseClient.post(
|
|
1166
|
-
`/bridges/${this.id}/play?${queryParams}`,
|
|
1167
|
-
{ media: request.media }
|
|
1168
|
-
);
|
|
1169
|
-
console.log(`Media playback started on bridge ${this.id}`);
|
|
1170
|
-
return result;
|
|
1171
|
-
} catch (error) {
|
|
1172
|
-
const message = getErrorMessage(error);
|
|
1173
|
-
console.error(`Error playing media on bridge ${this.id}:`, message);
|
|
1174
|
-
throw new Error(`Failed to play media: ${message}`);
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
/**
|
|
1178
|
-
* Stops media playback on the bridge.
|
|
1179
|
-
*
|
|
1180
|
-
* @param playbackId - The ID of the playback to stop.
|
|
1181
|
-
* @throws An error if the operation fails.
|
|
1182
|
-
*/
|
|
1183
|
-
async stopPlayback(playbackId) {
|
|
1184
|
-
try {
|
|
1185
|
-
await this.baseClient.delete(
|
|
1186
|
-
`/bridges/${this.id}/play/${playbackId}`
|
|
1187
|
-
);
|
|
1188
|
-
console.log(`Playback ${playbackId} stopped on bridge ${this.id}`);
|
|
1189
|
-
} catch (error) {
|
|
1190
|
-
const message = getErrorMessage(error);
|
|
1191
|
-
console.error(`Error stopping playback on bridge ${this.id}:`, message);
|
|
1192
|
-
throw new Error(`Failed to stop playback: ${message}`);
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
/**
|
|
1196
|
-
* Sets the video source for the bridge.
|
|
1197
|
-
*
|
|
1198
|
-
* @param channelId - The ID of the channel to set as the video source.
|
|
1199
|
-
* @throws An error if the operation fails.
|
|
1200
|
-
*/
|
|
1201
|
-
async setVideoSource(channelId) {
|
|
1202
|
-
try {
|
|
1203
|
-
await this.baseClient.post(
|
|
1204
|
-
`/bridges/${this.id}/videoSource/${channelId}`
|
|
1205
|
-
);
|
|
1206
|
-
console.log(`Video source set for bridge ${this.id}`);
|
|
1207
|
-
} catch (error) {
|
|
1208
|
-
const message = getErrorMessage(error);
|
|
1209
|
-
console.error(
|
|
1210
|
-
`Error setting video source for bridge ${this.id}:`,
|
|
1211
|
-
message
|
|
1212
|
-
);
|
|
1213
|
-
throw new Error(`Failed to set video source: ${message}`);
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* Removes the video source from the bridge.
|
|
1218
|
-
*
|
|
1219
|
-
* @throws An error if the operation fails.
|
|
1220
|
-
*/
|
|
1221
|
-
async clearVideoSource() {
|
|
1222
|
-
try {
|
|
1223
|
-
await this.baseClient.delete(`/bridges/${this.id}/videoSource`);
|
|
1224
|
-
console.log(`Video source removed from bridge ${this.id}`);
|
|
1225
|
-
} catch (error) {
|
|
1226
|
-
const message = getErrorMessage(error);
|
|
1227
|
-
console.error(
|
|
1228
|
-
`Error removing video source from bridge ${this.id}:`,
|
|
1229
|
-
message
|
|
1230
|
-
);
|
|
1231
|
-
throw new Error(`Failed to remove video source: ${message}`);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* Checks if the bridge has listeners for a specific event.
|
|
1236
|
-
*
|
|
1237
|
-
* @param event - The event type to check for listeners.
|
|
1238
|
-
* @returns A boolean indicating whether there are listeners for the event.
|
|
1239
|
-
*/
|
|
1240
|
-
hasListeners(event) {
|
|
1241
|
-
return this.eventEmitter.listenerCount(event) > 0;
|
|
1242
|
-
}
|
|
1243
|
-
/**
|
|
1244
|
-
* Retrieves the current bridge data without making an API call.
|
|
1245
|
-
*
|
|
1246
|
-
* @returns The current Bridge object or null if no data is available.
|
|
1247
|
-
*/
|
|
1248
|
-
getCurrentData() {
|
|
1249
|
-
return this.bridgeData;
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
935
|
var Bridges = class {
|
|
1253
|
-
constructor(
|
|
1254
|
-
this.baseClient = baseClient;
|
|
936
|
+
constructor(client) {
|
|
1255
937
|
this.client = client;
|
|
1256
938
|
}
|
|
1257
|
-
bridgeInstances = /* @__PURE__ */ new Map();
|
|
1258
|
-
/**
|
|
1259
|
-
* Creates or retrieves a Bridge instance.
|
|
1260
|
-
*
|
|
1261
|
-
* This method manages the creation and retrieval of BridgeInstance objects.
|
|
1262
|
-
* If an ID is provided and an instance with that ID already exists, it returns the existing instance.
|
|
1263
|
-
* If an ID is provided but no instance exists, it creates a new instance with that ID.
|
|
1264
|
-
* If no ID is provided, it creates a new instance with a generated ID.
|
|
1265
|
-
*
|
|
1266
|
-
* @param {Object} params - The parameters for creating or retrieving a Bridge instance.
|
|
1267
|
-
* @param {string} [params.id] - Optional. The ID of the Bridge instance to create or retrieve.
|
|
1268
|
-
*
|
|
1269
|
-
* @returns {BridgeInstance} A BridgeInstance object, either newly created or retrieved from existing instances.
|
|
1270
|
-
*
|
|
1271
|
-
* @throws {Error} If there's an error in creating or retrieving the Bridge instance.
|
|
1272
|
-
*/
|
|
1273
|
-
Bridge({ id }) {
|
|
1274
|
-
try {
|
|
1275
|
-
if (!id) {
|
|
1276
|
-
const instance = new BridgeInstance(this.client, this.baseClient);
|
|
1277
|
-
this.bridgeInstances.set(instance.id, instance);
|
|
1278
|
-
console.log(`New bridge instance created with ID: ${instance.id}`);
|
|
1279
|
-
return instance;
|
|
1280
|
-
}
|
|
1281
|
-
if (!this.bridgeInstances.has(id)) {
|
|
1282
|
-
const instance = new BridgeInstance(this.client, this.baseClient, id);
|
|
1283
|
-
this.bridgeInstances.set(id, instance);
|
|
1284
|
-
console.log(`New bridge instance created with provided ID: ${id}`);
|
|
1285
|
-
return instance;
|
|
1286
|
-
}
|
|
1287
|
-
console.log(`Returning existing bridge instance: ${id}`);
|
|
1288
|
-
return this.bridgeInstances.get(id);
|
|
1289
|
-
} catch (error) {
|
|
1290
|
-
const message = getErrorMessage(error);
|
|
1291
|
-
console.error(`Error creating/retrieving bridge instance:`, message);
|
|
1292
|
-
throw new Error(`Failed to manage bridge instance: ${message}`);
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
/**
|
|
1296
|
-
* Removes a bridge instance from the collection of managed bridges.
|
|
1297
|
-
*
|
|
1298
|
-
* This function removes the specified bridge instance, cleans up its event listeners,
|
|
1299
|
-
* and logs the removal. If the bridge instance doesn't exist, it logs a warning.
|
|
1300
|
-
*
|
|
1301
|
-
* @param {string} bridgeId - The unique identifier of the bridge instance to be removed.
|
|
1302
|
-
* @throws {Error} Throws an error if the bridgeId is not provided.
|
|
1303
|
-
* @returns {void}
|
|
1304
|
-
*/
|
|
1305
|
-
removeBridgeInstance(bridgeId) {
|
|
1306
|
-
if (!bridgeId) {
|
|
1307
|
-
throw new Error("ID da bridge \xE9 obrigat\xF3rio");
|
|
1308
|
-
}
|
|
1309
|
-
if (this.bridgeInstances.has(bridgeId)) {
|
|
1310
|
-
const instance = this.bridgeInstances.get(bridgeId);
|
|
1311
|
-
instance?.removeAllListeners();
|
|
1312
|
-
this.bridgeInstances.delete(bridgeId);
|
|
1313
|
-
console.log(`Inst\xE2ncia de bridge removida: ${bridgeId}`);
|
|
1314
|
-
} else {
|
|
1315
|
-
console.warn(`Tentativa de remover inst\xE2ncia inexistente: ${bridgeId}`);
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
939
|
/**
|
|
1319
|
-
*
|
|
1320
|
-
*
|
|
1321
|
-
* This function checks if the received event is valid and related to a bridge,
|
|
1322
|
-
* then emits the event to the corresponding bridge instance if it exists.
|
|
1323
|
-
*
|
|
1324
|
-
* @param {WebSocketEvent} event - The WebSocket event to be propagated.
|
|
1325
|
-
* This should be an object containing information about the event,
|
|
1326
|
-
* including the bridge ID and event type.
|
|
1327
|
-
*
|
|
1328
|
-
* @returns {void}
|
|
1329
|
-
*
|
|
1330
|
-
* @remarks
|
|
1331
|
-
* - If the event is invalid (null or undefined), a warning is logged and the function returns early.
|
|
1332
|
-
* - The function checks if the event is bridge-related and if the event type is included in the predefined bridge events.
|
|
1333
|
-
* - If a matching bridge instance is found, the event is emitted to that instance.
|
|
1334
|
-
* - If no matching bridge instance is found, a warning is logged.
|
|
1335
|
-
*/
|
|
1336
|
-
propagateEventToBridge(event) {
|
|
1337
|
-
if (!event) {
|
|
1338
|
-
console.warn("Evento WebSocket inv\xE1lido recebido");
|
|
1339
|
-
return;
|
|
1340
|
-
}
|
|
1341
|
-
if ("bridge" in event && event.bridge?.id && bridgeEvents.includes(event.type)) {
|
|
1342
|
-
const instance = this.bridgeInstances.get(event.bridge.id);
|
|
1343
|
-
if (instance) {
|
|
1344
|
-
instance.emitEvent(event);
|
|
1345
|
-
console.log(
|
|
1346
|
-
`Evento propagado para bridge ${event.bridge.id}: ${event.type}`
|
|
1347
|
-
);
|
|
1348
|
-
} else {
|
|
1349
|
-
console.warn(
|
|
1350
|
-
`Nenhuma inst\xE2ncia encontrada para bridge ${event.bridge.id}`
|
|
1351
|
-
);
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* Lists all active bridges in the system.
|
|
1357
|
-
*
|
|
1358
|
-
* This asynchronous function retrieves a list of all currently active bridges
|
|
1359
|
-
* by making a GET request to the "/bridges" endpoint using the base client.
|
|
1360
|
-
*
|
|
1361
|
-
* @returns {Promise<Bridge[]>} A promise that resolves to an array of Bridge objects.
|
|
1362
|
-
* Each Bridge object represents an active bridge in the system.
|
|
1363
|
-
*
|
|
1364
|
-
* @throws {Error} If there's an error in fetching the bridges or if the request fails.
|
|
1365
|
-
*
|
|
1366
|
-
* @example
|
|
1367
|
-
* try {
|
|
1368
|
-
* const bridges = await bridgesInstance.list();
|
|
1369
|
-
* console.log('Active bridges:', bridges);
|
|
1370
|
-
* } catch (error) {
|
|
1371
|
-
* console.error('Failed to fetch bridges:', error);
|
|
1372
|
-
* }
|
|
940
|
+
* Lists all active bridges.
|
|
1373
941
|
*/
|
|
1374
942
|
async list() {
|
|
1375
|
-
return this.
|
|
943
|
+
return this.client.get("/bridges");
|
|
1376
944
|
}
|
|
1377
945
|
/**
|
|
1378
|
-
* Creates a new bridge
|
|
1379
|
-
*
|
|
1380
|
-
* This asynchronous function sends a POST request to create a new bridge
|
|
1381
|
-
* using the provided configuration details.
|
|
1382
|
-
*
|
|
1383
|
-
* @param request - The configuration details for creating the new bridge.
|
|
1384
|
-
* @param request.type - The type of bridge to create (e.g., 'mixing', 'holding').
|
|
1385
|
-
* @param request.name - Optional. A custom name for the bridge.
|
|
1386
|
-
* @param request.bridgeId - Optional. A specific ID for the bridge. If not provided, one will be generated.
|
|
1387
|
-
*
|
|
1388
|
-
* @returns A Promise that resolves to a Bridge object representing the newly created bridge.
|
|
1389
|
-
* The Bridge object contains details such as id, technology, bridge_type, bridge_class, channels, etc.
|
|
1390
|
-
*
|
|
1391
|
-
* @throws Will throw an error if the bridge creation fails or if there's a network issue.
|
|
946
|
+
* Creates a new bridge.
|
|
1392
947
|
*/
|
|
1393
948
|
async createBridge(request) {
|
|
1394
|
-
return this.
|
|
949
|
+
return this.client.post("/bridges", request);
|
|
1395
950
|
}
|
|
1396
951
|
/**
|
|
1397
|
-
* Retrieves
|
|
1398
|
-
*
|
|
1399
|
-
* This asynchronous function fetches the complete details of a bridge
|
|
1400
|
-
* identified by its unique ID. It makes a GET request to the ARI endpoint
|
|
1401
|
-
* for the specified bridge.
|
|
1402
|
-
*
|
|
1403
|
-
* @param bridgeId - The unique identifier of the bridge to retrieve details for.
|
|
1404
|
-
* This should be a string that uniquely identifies the bridge in the system.
|
|
1405
|
-
*
|
|
1406
|
-
* @returns A Promise that resolves to a Bridge object containing all the details
|
|
1407
|
-
* of the specified bridge. This includes information such as the bridge's
|
|
1408
|
-
* ID, type, channels, and other relevant properties.
|
|
1409
|
-
*
|
|
1410
|
-
* @throws Will throw an error if the bridge cannot be found, if there's a network issue,
|
|
1411
|
-
* or if the server responds with an error.
|
|
952
|
+
* Retrieves details of a specific bridge.
|
|
1412
953
|
*/
|
|
1413
|
-
async
|
|
1414
|
-
return this.
|
|
954
|
+
async getDetails(bridgeId) {
|
|
955
|
+
return this.client.get(`/bridges/${bridgeId}`);
|
|
1415
956
|
}
|
|
1416
957
|
/**
|
|
1417
|
-
* Destroys (deletes) a specific bridge
|
|
1418
|
-
*
|
|
1419
|
-
* This asynchronous function sends a DELETE request to remove a bridge
|
|
1420
|
-
* identified by its unique ID. Once destroyed, the bridge and all its
|
|
1421
|
-
* associated resources are permanently removed from the system.
|
|
1422
|
-
*
|
|
1423
|
-
* @param bridgeId - The unique identifier of the bridge to be destroyed.
|
|
1424
|
-
* This should be a string that uniquely identifies the bridge in the system.
|
|
1425
|
-
*
|
|
1426
|
-
* @returns A Promise that resolves to void when the bridge is successfully destroyed.
|
|
1427
|
-
* If the operation is successful, the bridge no longer exists in the system.
|
|
1428
|
-
*
|
|
1429
|
-
* @throws Will throw an error if the bridge cannot be found, if there's a network issue,
|
|
1430
|
-
* or if the server responds with an error during the deletion process.
|
|
958
|
+
* Destroys (deletes) a specific bridge.
|
|
1431
959
|
*/
|
|
1432
960
|
async destroy(bridgeId) {
|
|
1433
|
-
return this.
|
|
961
|
+
return this.client.delete(`/bridges/${bridgeId}`);
|
|
1434
962
|
}
|
|
1435
963
|
/**
|
|
1436
|
-
* Adds
|
|
1437
|
-
*
|
|
1438
|
-
* This asynchronous function sends a POST request to add channels to an existing bridge.
|
|
1439
|
-
* It can handle adding a single channel or multiple channels in one operation.
|
|
1440
|
-
*
|
|
1441
|
-
* @param bridgeId - The unique identifier of the bridge to which channels will be added.
|
|
1442
|
-
* @param request - An object containing the details of the channel(s) to be added.
|
|
1443
|
-
* @param request.channel - A single channel ID or an array of channel IDs to add to the bridge.
|
|
1444
|
-
* @param request.role - Optional. Specifies the role of the channel(s) in the bridge.
|
|
1445
|
-
*
|
|
1446
|
-
* @returns A Promise that resolves to void when the operation is successful.
|
|
1447
|
-
*
|
|
1448
|
-
* @throws Will throw an error if the request fails, such as if the bridge doesn't exist
|
|
1449
|
-
* or if there's a network issue.
|
|
964
|
+
* Adds a channel or multiple channels to a bridge.
|
|
1450
965
|
*/
|
|
1451
966
|
async addChannels(bridgeId, request) {
|
|
1452
|
-
const queryParams =
|
|
967
|
+
const queryParams = new URLSearchParams({
|
|
1453
968
|
channel: Array.isArray(request.channel) ? request.channel.join(",") : request.channel,
|
|
1454
969
|
...request.role && { role: request.role }
|
|
1455
|
-
});
|
|
1456
|
-
await this.
|
|
970
|
+
}).toString();
|
|
971
|
+
await this.client.post(
|
|
1457
972
|
`/bridges/${bridgeId}/addChannel?${queryParams}`
|
|
1458
973
|
);
|
|
1459
974
|
}
|
|
1460
975
|
/**
|
|
1461
|
-
* Removes
|
|
1462
|
-
*
|
|
1463
|
-
* This asynchronous function sends a POST request to remove channels from an existing bridge.
|
|
1464
|
-
* It can handle removing a single channel or multiple channels in one operation.
|
|
1465
|
-
*
|
|
1466
|
-
* @param bridgeId - The unique identifier of the bridge from which channels will be removed.
|
|
1467
|
-
* @param request - An object containing the details of the channel(s) to be removed.
|
|
1468
|
-
* @param request.channel - A single channel ID or an array of channel IDs to remove from the bridge.
|
|
1469
|
-
*
|
|
1470
|
-
* @returns A Promise that resolves to void when the operation is successful.
|
|
1471
|
-
*
|
|
1472
|
-
* @throws Will throw an error if the request fails, such as if the bridge doesn't exist,
|
|
1473
|
-
* if the channels are not in the bridge, or if there's a network issue.
|
|
976
|
+
* Removes a channel or multiple channels from a bridge.
|
|
1474
977
|
*/
|
|
1475
978
|
async removeChannels(bridgeId, request) {
|
|
1476
|
-
const queryParams =
|
|
979
|
+
const queryParams = new URLSearchParams({
|
|
1477
980
|
channel: Array.isArray(request.channel) ? request.channel.join(",") : request.channel
|
|
1478
|
-
});
|
|
1479
|
-
await this.
|
|
981
|
+
}).toString();
|
|
982
|
+
await this.client.post(
|
|
1480
983
|
`/bridges/${bridgeId}/removeChannel?${queryParams}`
|
|
1481
984
|
);
|
|
1482
985
|
}
|
|
1483
986
|
/**
|
|
1484
|
-
* Plays media
|
|
1485
|
-
*
|
|
1486
|
-
* This asynchronous function initiates media playback on a bridge identified by its ID.
|
|
1487
|
-
* It allows for customization of the playback through various options in the request.
|
|
1488
|
-
*
|
|
1489
|
-
* @param bridgeId - The unique identifier of the bridge on which to play the media.
|
|
1490
|
-
* @param request - An object containing the media playback request details.
|
|
1491
|
-
* @param request.media - The media to be played (e.g., sound file, URL).
|
|
1492
|
-
* @param request.lang - Optional. The language of the media content.
|
|
1493
|
-
* @param request.offsetms - Optional. The offset in milliseconds to start playing from.
|
|
1494
|
-
* @param request.skipms - Optional. The number of milliseconds to skip before playing.
|
|
1495
|
-
* @param request.playbackId - Optional. A custom ID for the playback session.
|
|
1496
|
-
*
|
|
1497
|
-
* @returns A Promise that resolves to a BridgePlayback object, containing details about the initiated playback.
|
|
1498
|
-
*
|
|
1499
|
-
* @throws Will throw an error if the playback request fails or if there's a network issue.
|
|
987
|
+
* Plays media to a bridge.
|
|
1500
988
|
*/
|
|
1501
989
|
async playMedia(bridgeId, request) {
|
|
1502
|
-
const queryParams =
|
|
990
|
+
const queryParams = new URLSearchParams({
|
|
1503
991
|
...request.lang && { lang: request.lang },
|
|
1504
992
|
...request.offsetms && { offsetms: request.offsetms.toString() },
|
|
1505
993
|
...request.skipms && { skipms: request.skipms.toString() },
|
|
1506
994
|
...request.playbackId && { playbackId: request.playbackId }
|
|
1507
|
-
});
|
|
1508
|
-
return this.
|
|
995
|
+
}).toString();
|
|
996
|
+
return this.client.post(
|
|
1509
997
|
`/bridges/${bridgeId}/play?${queryParams}`,
|
|
1510
998
|
{ media: request.media }
|
|
1511
999
|
);
|
|
1512
1000
|
}
|
|
1513
1001
|
/**
|
|
1514
|
-
* Stops media playback on a
|
|
1515
|
-
*
|
|
1516
|
-
* This asynchronous function sends a DELETE request to stop the playback of media
|
|
1517
|
-
* on a bridge identified by its ID and a specific playback session.
|
|
1518
|
-
*
|
|
1519
|
-
* @param bridgeId - The unique identifier of the bridge where the playback is to be stopped.
|
|
1520
|
-
* @param playbackId - The unique identifier of the playback session to be stopped.
|
|
1521
|
-
*
|
|
1522
|
-
* @returns A Promise that resolves to void when the playback is successfully stopped.
|
|
1523
|
-
*
|
|
1524
|
-
* @throws Will throw an error if the request fails, such as if the bridge or playback session
|
|
1525
|
-
* doesn't exist, or if there's a network issue.
|
|
1002
|
+
* Stops media playback on a bridge.
|
|
1526
1003
|
*/
|
|
1527
1004
|
async stopPlayback(bridgeId, playbackId) {
|
|
1528
|
-
await this.
|
|
1529
|
-
`/bridges/${bridgeId}/play/${playbackId}`
|
|
1530
|
-
);
|
|
1005
|
+
await this.client.delete(`/bridges/${bridgeId}/play/${playbackId}`);
|
|
1531
1006
|
}
|
|
1532
1007
|
/**
|
|
1533
|
-
* Sets the video source for a
|
|
1534
|
-
*
|
|
1535
|
-
* This asynchronous function configures a channel as the video source for a given bridge.
|
|
1536
|
-
* It sends a POST request to the ARI endpoint to update the bridge's video source.
|
|
1537
|
-
*
|
|
1538
|
-
* @param bridgeId - The unique identifier of the bridge for which to set the video source.
|
|
1539
|
-
* @param channelId - The unique identifier of the channel to be set as the video source.
|
|
1540
|
-
*
|
|
1541
|
-
* @returns A Promise that resolves to void when the video source is successfully set.
|
|
1542
|
-
*
|
|
1543
|
-
* @throws Will throw an error if the request fails, such as if the bridge or channel
|
|
1544
|
-
* doesn't exist, or if there's a network issue.
|
|
1008
|
+
* Sets the video source for a bridge.
|
|
1545
1009
|
*/
|
|
1546
1010
|
async setVideoSource(bridgeId, channelId) {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
`/bridges/${bridgeId}/videoSource?${queryParams}`
|
|
1011
|
+
await this.client.post(
|
|
1012
|
+
`/bridges/${bridgeId}/videoSource?channelId=${encodeURIComponent(channelId)}`
|
|
1550
1013
|
);
|
|
1551
1014
|
}
|
|
1552
1015
|
/**
|
|
1553
|
-
* Clears the video source for a
|
|
1554
|
-
*
|
|
1555
|
-
* This asynchronous function removes the currently set video source from a bridge.
|
|
1556
|
-
* It sends a DELETE request to the ARI endpoint to clear the video source configuration.
|
|
1557
|
-
*
|
|
1558
|
-
* @param bridgeId - The unique identifier of the bridge from which to clear the video source.
|
|
1559
|
-
* This should be a string that uniquely identifies the bridge in the system.
|
|
1560
|
-
*
|
|
1561
|
-
* @returns A Promise that resolves to void when the video source is successfully cleared.
|
|
1562
|
-
* If the operation is successful, the bridge will no longer have a designated video source.
|
|
1563
|
-
*
|
|
1564
|
-
* @throws Will throw an error if the request fails, such as if the bridge doesn't exist,
|
|
1565
|
-
* if there's no video source set, or if there's a network issue.
|
|
1016
|
+
* Clears the video source for a bridge.
|
|
1566
1017
|
*/
|
|
1567
1018
|
async clearVideoSource(bridgeId) {
|
|
1568
|
-
await this.
|
|
1569
|
-
}
|
|
1570
|
-
/**
|
|
1571
|
-
* Retrieves the count of active bridge instances.
|
|
1572
|
-
*
|
|
1573
|
-
* This function returns the total number of bridge instances currently
|
|
1574
|
-
* managed by the Bridges class. It provides a quick way to check how many
|
|
1575
|
-
* active bridges are present in the system.
|
|
1576
|
-
*
|
|
1577
|
-
* @returns {number} The count of active bridge instances.
|
|
1578
|
-
*/
|
|
1579
|
-
getInstanceCount() {
|
|
1580
|
-
return this.bridgeInstances.size;
|
|
1581
|
-
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Checks if a bridge instance exists in the collection of managed bridges.
|
|
1584
|
-
*
|
|
1585
|
-
* This function verifies whether a bridge instance with the specified ID
|
|
1586
|
-
* is currently being managed by the Bridges class.
|
|
1587
|
-
*
|
|
1588
|
-
* @param bridgeId - The unique identifier of the bridge instance to check.
|
|
1589
|
-
* This should be a string that uniquely identifies the bridge in the system.
|
|
1590
|
-
*
|
|
1591
|
-
* @returns A boolean value indicating whether the bridge instance exists.
|
|
1592
|
-
* Returns true if the bridge instance is found, false otherwise.
|
|
1593
|
-
*/
|
|
1594
|
-
hasInstance(bridgeId) {
|
|
1595
|
-
return this.bridgeInstances.has(bridgeId);
|
|
1596
|
-
}
|
|
1597
|
-
/**
|
|
1598
|
-
* Retrieves all active bridge instances currently managed by the Bridges class.
|
|
1599
|
-
*
|
|
1600
|
-
* This method provides a way to access all the BridgeInstance objects that are
|
|
1601
|
-
* currently active and being managed. It returns a new Map to prevent direct
|
|
1602
|
-
* modification of the internal bridgeInstances collection.
|
|
1603
|
-
*
|
|
1604
|
-
* @returns A new Map object containing all active bridge instances, where the keys
|
|
1605
|
-
* are the bridge IDs (strings) and the values are the corresponding
|
|
1606
|
-
* BridgeInstance objects. If no bridges are active, an empty Map is returned.
|
|
1607
|
-
*/
|
|
1608
|
-
getAllInstances() {
|
|
1609
|
-
return new Map(this.bridgeInstances);
|
|
1019
|
+
await this.client.delete(`/bridges/${bridgeId}/videoSource`);
|
|
1610
1020
|
}
|
|
1611
1021
|
};
|
|
1612
1022
|
|
|
1613
1023
|
// src/ari-client/resources/channels.ts
|
|
1614
|
-
var
|
|
1615
|
-
var
|
|
1024
|
+
var import_events = require("events");
|
|
1025
|
+
var import_axios2 = require("axios");
|
|
1616
1026
|
|
|
1617
1027
|
// node_modules/uuid/dist/esm/stringify.js
|
|
1618
1028
|
var byteToHex = [];
|
|
@@ -1659,9 +1069,16 @@ function v4(options, buf, offset) {
|
|
|
1659
1069
|
}
|
|
1660
1070
|
var v4_default = v4;
|
|
1661
1071
|
|
|
1072
|
+
// src/ari-client/utils.ts
|
|
1073
|
+
function toQueryParams2(options) {
|
|
1074
|
+
return new URLSearchParams(
|
|
1075
|
+
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
|
|
1076
|
+
).toString();
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1662
1079
|
// src/ari-client/resources/channels.ts
|
|
1663
|
-
var
|
|
1664
|
-
if ((0,
|
|
1080
|
+
var getErrorMessage = (error) => {
|
|
1081
|
+
if ((0, import_axios2.isAxiosError)(error)) {
|
|
1665
1082
|
return error.response?.data?.message || error.message || "An axios error occurred";
|
|
1666
1083
|
}
|
|
1667
1084
|
if (error instanceof Error) {
|
|
@@ -1674,9 +1091,8 @@ var ChannelInstance = class {
|
|
|
1674
1091
|
this.client = client;
|
|
1675
1092
|
this.baseClient = baseClient;
|
|
1676
1093
|
this.id = channelId || `channel-${Date.now()}`;
|
|
1677
|
-
console.log(`Channel instance initialized with ID: ${this.id}`);
|
|
1678
1094
|
}
|
|
1679
|
-
eventEmitter = new
|
|
1095
|
+
eventEmitter = new import_events.EventEmitter();
|
|
1680
1096
|
channelData = null;
|
|
1681
1097
|
id;
|
|
1682
1098
|
/**
|
|
@@ -1692,7 +1108,6 @@ var ChannelInstance = class {
|
|
|
1692
1108
|
}
|
|
1693
1109
|
};
|
|
1694
1110
|
this.eventEmitter.on(event, wrappedListener);
|
|
1695
|
-
console.log(`Event listener registered for ${event} on channel ${this.id}`);
|
|
1696
1111
|
}
|
|
1697
1112
|
/**
|
|
1698
1113
|
* Registers a one-time event listener
|
|
@@ -1707,9 +1122,6 @@ var ChannelInstance = class {
|
|
|
1707
1122
|
}
|
|
1708
1123
|
};
|
|
1709
1124
|
this.eventEmitter.once(event, wrappedListener);
|
|
1710
|
-
console.log(
|
|
1711
|
-
`One-time event listener registered for ${event} on channel ${this.id}`
|
|
1712
|
-
);
|
|
1713
1125
|
}
|
|
1714
1126
|
/**
|
|
1715
1127
|
* Removes event listener(s) for a specific WebSocket event type.
|
|
@@ -1726,12 +1138,8 @@ var ChannelInstance = class {
|
|
|
1726
1138
|
}
|
|
1727
1139
|
if (listener) {
|
|
1728
1140
|
this.eventEmitter.off(event, listener);
|
|
1729
|
-
console.log(
|
|
1730
|
-
`Specific listener removed for ${event} on channel ${this.id}`
|
|
1731
|
-
);
|
|
1732
1141
|
} else {
|
|
1733
1142
|
this.eventEmitter.removeAllListeners(event);
|
|
1734
|
-
console.log(`All listeners removed for ${event} on channel ${this.id}`);
|
|
1735
1143
|
}
|
|
1736
1144
|
}
|
|
1737
1145
|
/**
|
|
@@ -1744,7 +1152,6 @@ var ChannelInstance = class {
|
|
|
1744
1152
|
}
|
|
1745
1153
|
if ("channel" in event && event.channel?.id === this.id) {
|
|
1746
1154
|
this.eventEmitter.emit(event.type, event);
|
|
1747
|
-
console.log(`Event ${event.type} emitted for channel ${this.id}`);
|
|
1748
1155
|
}
|
|
1749
1156
|
}
|
|
1750
1157
|
/**
|
|
@@ -1754,7 +1161,6 @@ var ChannelInstance = class {
|
|
|
1754
1161
|
* @return {void} This method does not return a value.
|
|
1755
1162
|
*/
|
|
1756
1163
|
removeAllListeners() {
|
|
1757
|
-
console.log(`Removendo todos os listeners para o canal ${this.id}`);
|
|
1758
1164
|
this.eventEmitter.removeAllListeners();
|
|
1759
1165
|
}
|
|
1760
1166
|
/**
|
|
@@ -1763,9 +1169,8 @@ var ChannelInstance = class {
|
|
|
1763
1169
|
async answer() {
|
|
1764
1170
|
try {
|
|
1765
1171
|
await this.baseClient.post(`/channels/${this.id}/answer`);
|
|
1766
|
-
console.log(`Channel ${this.id} answered`);
|
|
1767
1172
|
} catch (error) {
|
|
1768
|
-
const message =
|
|
1173
|
+
const message = getErrorMessage(error);
|
|
1769
1174
|
console.error(`Error answering channel ${this.id}:`, message);
|
|
1770
1175
|
throw new Error(`Failed to answer channel: ${message}`);
|
|
1771
1176
|
}
|
|
@@ -1786,12 +1191,9 @@ var ChannelInstance = class {
|
|
|
1786
1191
|
"/channels",
|
|
1787
1192
|
data
|
|
1788
1193
|
);
|
|
1789
|
-
console.log(
|
|
1790
|
-
`Channel originated successfully with ID: ${this.channelData.id}`
|
|
1791
|
-
);
|
|
1792
1194
|
return this.channelData;
|
|
1793
1195
|
} catch (error) {
|
|
1794
|
-
const message =
|
|
1196
|
+
const message = getErrorMessage(error);
|
|
1795
1197
|
console.error(`Error originating channel:`, message);
|
|
1796
1198
|
throw new Error(`Failed to originate channel: ${message}`);
|
|
1797
1199
|
}
|
|
@@ -1805,7 +1207,6 @@ var ChannelInstance = class {
|
|
|
1805
1207
|
}
|
|
1806
1208
|
try {
|
|
1807
1209
|
if (!this.channelData) {
|
|
1808
|
-
console.log("Initializing channel details...");
|
|
1809
1210
|
this.channelData = await this.getDetails();
|
|
1810
1211
|
}
|
|
1811
1212
|
const playback = this.client.Playback(playbackId || v4_default());
|
|
@@ -1813,10 +1214,9 @@ var ChannelInstance = class {
|
|
|
1813
1214
|
`/channels/${this.id}/play/${playback.id}`,
|
|
1814
1215
|
options
|
|
1815
1216
|
);
|
|
1816
|
-
console.log(`Media playback started on channel ${this.id}`);
|
|
1817
1217
|
return playback;
|
|
1818
1218
|
} catch (error) {
|
|
1819
|
-
const message =
|
|
1219
|
+
const message = getErrorMessage(error);
|
|
1820
1220
|
console.error(`Error playing media on channel ${this.id}:`, message);
|
|
1821
1221
|
throw new Error(`Failed to play media: ${message}`);
|
|
1822
1222
|
}
|
|
@@ -1836,10 +1236,9 @@ var ChannelInstance = class {
|
|
|
1836
1236
|
`/channels/${this.id}`
|
|
1837
1237
|
);
|
|
1838
1238
|
this.channelData = details;
|
|
1839
|
-
console.log(`Retrieved channel details for ${this.id}`);
|
|
1840
1239
|
return details;
|
|
1841
1240
|
} catch (error) {
|
|
1842
|
-
const message =
|
|
1241
|
+
const message = getErrorMessage(error);
|
|
1843
1242
|
console.error(
|
|
1844
1243
|
`Error retrieving channel details for ${this.id}:`,
|
|
1845
1244
|
message
|
|
@@ -1883,7 +1282,6 @@ var ChannelInstance = class {
|
|
|
1883
1282
|
*/
|
|
1884
1283
|
async hangup() {
|
|
1885
1284
|
if (!this.channelData) {
|
|
1886
|
-
console.log("Canal n\xE3o inicializado, buscando detalhes...");
|
|
1887
1285
|
this.channelData = await this.getDetails();
|
|
1888
1286
|
}
|
|
1889
1287
|
if (!this.channelData?.id) {
|
|
@@ -2072,19 +1470,16 @@ var Channels = class {
|
|
|
2072
1470
|
if (!id) {
|
|
2073
1471
|
const instance = new ChannelInstance(this.client, this.baseClient);
|
|
2074
1472
|
this.channelInstances.set(instance.id, instance);
|
|
2075
|
-
console.log(`New channel instance created with ID: ${instance.id}`);
|
|
2076
1473
|
return instance;
|
|
2077
1474
|
}
|
|
2078
1475
|
if (!this.channelInstances.has(id)) {
|
|
2079
1476
|
const instance = new ChannelInstance(this.client, this.baseClient, id);
|
|
2080
1477
|
this.channelInstances.set(id, instance);
|
|
2081
|
-
console.log(`New channel instance created with provided ID: ${id}`);
|
|
2082
1478
|
return instance;
|
|
2083
1479
|
}
|
|
2084
|
-
console.log(`Returning existing channel instance: ${id}`);
|
|
2085
1480
|
return this.channelInstances.get(id);
|
|
2086
1481
|
} catch (error) {
|
|
2087
|
-
const message =
|
|
1482
|
+
const message = getErrorMessage(error);
|
|
2088
1483
|
console.error(`Error creating/retrieving channel instance:`, message);
|
|
2089
1484
|
throw new Error(`Failed to manage channel instance: ${message}`);
|
|
2090
1485
|
}
|
|
@@ -2101,11 +1496,9 @@ var Channels = class {
|
|
|
2101
1496
|
if (!id) {
|
|
2102
1497
|
throw new Error("No channel ID associated with this instance");
|
|
2103
1498
|
}
|
|
2104
|
-
|
|
2105
|
-
console.log(`Retrieved channel details for ${id}`);
|
|
2106
|
-
return details;
|
|
1499
|
+
return await this.baseClient.get(`/channels/${id}`);
|
|
2107
1500
|
} catch (error) {
|
|
2108
|
-
const message =
|
|
1501
|
+
const message = getErrorMessage(error);
|
|
2109
1502
|
console.error(`Error retrieving channel details for ${id}:`, message);
|
|
2110
1503
|
throw new Error(`Failed to get channel details: ${message}`);
|
|
2111
1504
|
}
|
|
@@ -2121,7 +1514,6 @@ var Channels = class {
|
|
|
2121
1514
|
const instance = this.channelInstances.get(channelId);
|
|
2122
1515
|
instance?.removeAllListeners();
|
|
2123
1516
|
this.channelInstances.delete(channelId);
|
|
2124
|
-
console.log(`Channel instance removed: ${channelId}`);
|
|
2125
1517
|
} else {
|
|
2126
1518
|
console.warn(`Attempt to remove non-existent instance: ${channelId}`);
|
|
2127
1519
|
}
|
|
@@ -2138,9 +1530,6 @@ var Channels = class {
|
|
|
2138
1530
|
const instance = this.channelInstances.get(event.channel.id);
|
|
2139
1531
|
if (instance) {
|
|
2140
1532
|
instance.emitEvent(event);
|
|
2141
|
-
console.log(
|
|
2142
|
-
`Event propagated to channel ${event.channel.id}: ${event.type}`
|
|
2143
|
-
);
|
|
2144
1533
|
} else {
|
|
2145
1534
|
console.warn(`No instance found for channel ${event.channel.id}`);
|
|
2146
1535
|
}
|
|
@@ -2154,11 +1543,9 @@ var Channels = class {
|
|
|
2154
1543
|
throw new Error("Endpoint is required for channel origination");
|
|
2155
1544
|
}
|
|
2156
1545
|
try {
|
|
2157
|
-
|
|
2158
|
-
console.log(`Channel originated successfully with ID: ${channel.id}`);
|
|
2159
|
-
return channel;
|
|
1546
|
+
return await this.baseClient.post("/channels", data);
|
|
2160
1547
|
} catch (error) {
|
|
2161
|
-
const message =
|
|
1548
|
+
const message = getErrorMessage(error);
|
|
2162
1549
|
console.error(`Error originating channel:`, message);
|
|
2163
1550
|
throw new Error(`Failed to originate channel: ${message}`);
|
|
2164
1551
|
}
|
|
@@ -2172,10 +1559,9 @@ var Channels = class {
|
|
|
2172
1559
|
if (!Array.isArray(channels)) {
|
|
2173
1560
|
throw new Error("API response for /channels is not an array");
|
|
2174
1561
|
}
|
|
2175
|
-
console.log(`Retrieved ${channels.length} active channels`);
|
|
2176
1562
|
return channels;
|
|
2177
1563
|
} catch (error) {
|
|
2178
|
-
const message =
|
|
1564
|
+
const message = getErrorMessage(error);
|
|
2179
1565
|
console.error(`Error listing channels:`, message);
|
|
2180
1566
|
throw new Error(`Failed to list channels: ${message}`);
|
|
2181
1567
|
}
|
|
@@ -2602,10 +1988,10 @@ var Endpoints = class {
|
|
|
2602
1988
|
};
|
|
2603
1989
|
|
|
2604
1990
|
// src/ari-client/resources/playbacks.ts
|
|
2605
|
-
var
|
|
2606
|
-
var
|
|
2607
|
-
var
|
|
2608
|
-
if ((0,
|
|
1991
|
+
var import_events2 = require("events");
|
|
1992
|
+
var import_axios3 = require("axios");
|
|
1993
|
+
var getErrorMessage2 = (error) => {
|
|
1994
|
+
if ((0, import_axios3.isAxiosError)(error)) {
|
|
2609
1995
|
return error.response?.data?.message || error.message || "An axios error occurred";
|
|
2610
1996
|
}
|
|
2611
1997
|
if (error instanceof Error) {
|
|
@@ -2626,9 +2012,8 @@ var PlaybackInstance = class {
|
|
|
2626
2012
|
this.baseClient = baseClient;
|
|
2627
2013
|
this.playbackId = playbackId;
|
|
2628
2014
|
this.id = playbackId;
|
|
2629
|
-
console.log(`PlaybackInstance initialized with ID: ${this.id}`);
|
|
2630
2015
|
}
|
|
2631
|
-
eventEmitter = new
|
|
2016
|
+
eventEmitter = new import_events2.EventEmitter();
|
|
2632
2017
|
playbackData = null;
|
|
2633
2018
|
id;
|
|
2634
2019
|
/**
|
|
@@ -2647,9 +2032,6 @@ var PlaybackInstance = class {
|
|
|
2647
2032
|
}
|
|
2648
2033
|
};
|
|
2649
2034
|
this.eventEmitter.on(event, wrappedListener);
|
|
2650
|
-
console.log(
|
|
2651
|
-
`Event listener registered for ${event} on playback ${this.id}`
|
|
2652
|
-
);
|
|
2653
2035
|
}
|
|
2654
2036
|
/**
|
|
2655
2037
|
* Registers a one-time event listener for a specific WebSocket event type.
|
|
@@ -2667,9 +2049,6 @@ var PlaybackInstance = class {
|
|
|
2667
2049
|
}
|
|
2668
2050
|
};
|
|
2669
2051
|
this.eventEmitter.once(event, wrappedListener);
|
|
2670
|
-
console.log(
|
|
2671
|
-
`One-time event listener registered for ${event} on playback ${this.id}`
|
|
2672
|
-
);
|
|
2673
2052
|
}
|
|
2674
2053
|
/**
|
|
2675
2054
|
* Removes event listener(s) for a specific WebSocket event type.
|
|
@@ -2683,12 +2062,8 @@ var PlaybackInstance = class {
|
|
|
2683
2062
|
}
|
|
2684
2063
|
if (listener) {
|
|
2685
2064
|
this.eventEmitter.off(event, listener);
|
|
2686
|
-
console.log(
|
|
2687
|
-
`Specific listener removed for ${event} on playback ${this.id}`
|
|
2688
|
-
);
|
|
2689
2065
|
} else {
|
|
2690
2066
|
this.eventEmitter.removeAllListeners(event);
|
|
2691
|
-
console.log(`All listeners removed for ${event} on playback ${this.id}`);
|
|
2692
2067
|
}
|
|
2693
2068
|
}
|
|
2694
2069
|
/**
|
|
@@ -2703,7 +2078,6 @@ var PlaybackInstance = class {
|
|
|
2703
2078
|
}
|
|
2704
2079
|
if ("playback" in event && event.playback?.id === this.id) {
|
|
2705
2080
|
this.eventEmitter.emit(event.type, event);
|
|
2706
|
-
console.log(`Event ${event.type} emitted for playback ${this.id}`);
|
|
2707
2081
|
}
|
|
2708
2082
|
}
|
|
2709
2083
|
/**
|
|
@@ -2720,11 +2094,10 @@ var PlaybackInstance = class {
|
|
|
2720
2094
|
this.playbackData = await this.baseClient.get(
|
|
2721
2095
|
`/playbacks/${this.id}`
|
|
2722
2096
|
);
|
|
2723
|
-
console.log(`Retrieved playback data for ${this.id}`);
|
|
2724
2097
|
return this.playbackData;
|
|
2725
2098
|
} catch (error) {
|
|
2726
|
-
const message =
|
|
2727
|
-
console.
|
|
2099
|
+
const message = getErrorMessage2(error);
|
|
2100
|
+
console.warn(`Error retrieving playback data for ${this.id}:`, message);
|
|
2728
2101
|
throw new Error(`Failed to get playback data: ${message}`);
|
|
2729
2102
|
}
|
|
2730
2103
|
}
|
|
@@ -2742,12 +2115,9 @@ var PlaybackInstance = class {
|
|
|
2742
2115
|
await this.baseClient.post(
|
|
2743
2116
|
`/playbacks/${this.id}/control?operation=${operation}`
|
|
2744
2117
|
);
|
|
2745
|
-
console.log(
|
|
2746
|
-
`Operation ${operation} executed successfully on playback ${this.id}`
|
|
2747
|
-
);
|
|
2748
2118
|
} catch (error) {
|
|
2749
|
-
const message =
|
|
2750
|
-
console.
|
|
2119
|
+
const message = getErrorMessage2(error);
|
|
2120
|
+
console.warn(`Error controlling playback ${this.id}:`, message);
|
|
2751
2121
|
throw new Error(`Failed to control playback: ${message}`);
|
|
2752
2122
|
}
|
|
2753
2123
|
}
|
|
@@ -2762,10 +2132,9 @@ var PlaybackInstance = class {
|
|
|
2762
2132
|
}
|
|
2763
2133
|
try {
|
|
2764
2134
|
await this.baseClient.delete(`/playbacks/${this.id}`);
|
|
2765
|
-
console.log(`Playback ${this.id} stopped successfully`);
|
|
2766
2135
|
} catch (error) {
|
|
2767
|
-
const message =
|
|
2768
|
-
console.
|
|
2136
|
+
const message = getErrorMessage2(error);
|
|
2137
|
+
console.warn(`Error stopping playback ${this.id}:`, message);
|
|
2769
2138
|
throw new Error(`Failed to stop playback: ${message}`);
|
|
2770
2139
|
}
|
|
2771
2140
|
}
|
|
@@ -2774,7 +2143,6 @@ var PlaybackInstance = class {
|
|
|
2774
2143
|
*/
|
|
2775
2144
|
removeAllListeners() {
|
|
2776
2145
|
this.eventEmitter.removeAllListeners();
|
|
2777
|
-
console.log(`All listeners removed from playback ${this.id}`);
|
|
2778
2146
|
}
|
|
2779
2147
|
/**
|
|
2780
2148
|
* Checks if the playback instance has any listeners for a specific event.
|
|
@@ -2812,20 +2180,17 @@ var Playbacks = class {
|
|
|
2812
2180
|
if (!id) {
|
|
2813
2181
|
const instance = new PlaybackInstance(this.client, this.baseClient);
|
|
2814
2182
|
this.playbackInstances.set(instance.id, instance);
|
|
2815
|
-
console.log(`New playback instance created with ID: ${instance.id}`);
|
|
2816
2183
|
return instance;
|
|
2817
2184
|
}
|
|
2818
2185
|
if (!this.playbackInstances.has(id)) {
|
|
2819
2186
|
const instance = new PlaybackInstance(this.client, this.baseClient, id);
|
|
2820
2187
|
this.playbackInstances.set(id, instance);
|
|
2821
|
-
console.log(`New playback instance created with provided ID: ${id}`);
|
|
2822
2188
|
return instance;
|
|
2823
2189
|
}
|
|
2824
|
-
console.log(`Returning existing playback instance: ${id}`);
|
|
2825
2190
|
return this.playbackInstances.get(id);
|
|
2826
2191
|
} catch (error) {
|
|
2827
|
-
const message =
|
|
2828
|
-
console.
|
|
2192
|
+
const message = getErrorMessage2(error);
|
|
2193
|
+
console.warn(`Error creating/retrieving playback instance:`, message);
|
|
2829
2194
|
throw new Error(`Failed to manage playback instance: ${message}`);
|
|
2830
2195
|
}
|
|
2831
2196
|
}
|
|
@@ -2842,7 +2207,6 @@ var Playbacks = class {
|
|
|
2842
2207
|
const instance = this.playbackInstances.get(playbackId);
|
|
2843
2208
|
instance?.removeAllListeners();
|
|
2844
2209
|
this.playbackInstances.delete(playbackId);
|
|
2845
|
-
console.log(`Playback instance removed: ${playbackId}`);
|
|
2846
2210
|
} else {
|
|
2847
2211
|
console.warn(`Attempt to remove non-existent instance: ${playbackId}`);
|
|
2848
2212
|
}
|
|
@@ -2853,16 +2217,12 @@ var Playbacks = class {
|
|
|
2853
2217
|
*/
|
|
2854
2218
|
propagateEventToPlayback(event) {
|
|
2855
2219
|
if (!event) {
|
|
2856
|
-
console.warn("Invalid WebSocket event received");
|
|
2857
2220
|
return;
|
|
2858
2221
|
}
|
|
2859
2222
|
if ("playback" in event && event.playback?.id) {
|
|
2860
2223
|
const instance = this.playbackInstances.get(event.playback.id);
|
|
2861
2224
|
if (instance) {
|
|
2862
2225
|
instance.emitEvent(event);
|
|
2863
|
-
console.log(
|
|
2864
|
-
`Event propagated to playback ${event.playback.id}: ${event.type}`
|
|
2865
|
-
);
|
|
2866
2226
|
} else {
|
|
2867
2227
|
console.warn(`No instance found for playback ${event.playback.id}`);
|
|
2868
2228
|
}
|
|
@@ -2874,15 +2234,15 @@ var Playbacks = class {
|
|
|
2874
2234
|
* @returns {Promise<Playback>} Promise resolving to playback details
|
|
2875
2235
|
* @throws {Error} If the playback ID is invalid or the request fails
|
|
2876
2236
|
*/
|
|
2877
|
-
async
|
|
2237
|
+
async get(playbackId) {
|
|
2878
2238
|
if (!playbackId) {
|
|
2879
2239
|
throw new Error("Playback ID is required");
|
|
2880
2240
|
}
|
|
2881
2241
|
try {
|
|
2882
2242
|
return await this.baseClient.get(`/playbacks/${playbackId}`);
|
|
2883
2243
|
} catch (error) {
|
|
2884
|
-
const message =
|
|
2885
|
-
console.
|
|
2244
|
+
const message = getErrorMessage2(error);
|
|
2245
|
+
console.warn(`Error getting playback details ${playbackId}:`, message);
|
|
2886
2246
|
throw new Error(`Failed to get playback details: ${message}`);
|
|
2887
2247
|
}
|
|
2888
2248
|
}
|
|
@@ -2899,10 +2259,9 @@ var Playbacks = class {
|
|
|
2899
2259
|
try {
|
|
2900
2260
|
const playback = this.Playback({ id: playbackId });
|
|
2901
2261
|
await playback.control(operation);
|
|
2902
|
-
console.log(`Operation ${operation} executed on playback ${playbackId}`);
|
|
2903
2262
|
} catch (error) {
|
|
2904
|
-
const message =
|
|
2905
|
-
console.
|
|
2263
|
+
const message = getErrorMessage2(error);
|
|
2264
|
+
console.warn(`Error controlling playback ${playbackId}:`, message);
|
|
2906
2265
|
throw new Error(`Failed to control playback: ${message}`);
|
|
2907
2266
|
}
|
|
2908
2267
|
}
|
|
@@ -2918,10 +2277,9 @@ var Playbacks = class {
|
|
|
2918
2277
|
try {
|
|
2919
2278
|
const playback = this.Playback({ id: playbackId });
|
|
2920
2279
|
await playback.stop();
|
|
2921
|
-
console.log(`Playback ${playbackId} stopped`);
|
|
2922
2280
|
} catch (error) {
|
|
2923
|
-
const message =
|
|
2924
|
-
console.
|
|
2281
|
+
const message = getErrorMessage2(error);
|
|
2282
|
+
console.warn(`Error stopping playback ${playbackId}:`, message);
|
|
2925
2283
|
throw new Error(`Failed to stop playback: ${message}`);
|
|
2926
2284
|
}
|
|
2927
2285
|
}
|
|
@@ -2974,13 +2332,13 @@ var Sounds = class {
|
|
|
2974
2332
|
};
|
|
2975
2333
|
|
|
2976
2334
|
// src/ari-client/websocketClient.ts
|
|
2977
|
-
var
|
|
2335
|
+
var import_events3 = require("events");
|
|
2978
2336
|
var import_exponential_backoff = __toESM(require_backoff(), 1);
|
|
2979
2337
|
var import_ws = __toESM(require("ws"), 1);
|
|
2980
2338
|
var DEFAULT_MAX_RECONNECT_ATTEMPTS = 10;
|
|
2981
2339
|
var DEFAULT_STARTING_DELAY = 500;
|
|
2982
2340
|
var DEFAULT_MAX_DELAY = 1e4;
|
|
2983
|
-
var WebSocketClient = class extends
|
|
2341
|
+
var WebSocketClient = class extends import_events3.EventEmitter {
|
|
2984
2342
|
/**
|
|
2985
2343
|
* Creates a new WebSocket client instance.
|
|
2986
2344
|
*
|
|
@@ -3100,13 +2458,7 @@ var WebSocketClient = class extends import_events5.EventEmitter {
|
|
|
3100
2458
|
instancePlayback.emitEvent(event);
|
|
3101
2459
|
event.instancePlayback = instancePlayback;
|
|
3102
2460
|
}
|
|
3103
|
-
if ("bridge" in event && event.bridge?.id && this.ariClient) {
|
|
3104
|
-
const instanceBridge = this.ariClient.Bridge(event.bridge.id);
|
|
3105
|
-
instanceBridge.emitEvent(event);
|
|
3106
|
-
event.instanceBridge = instanceBridge;
|
|
3107
|
-
}
|
|
3108
2461
|
this.emit(event.type, event);
|
|
3109
|
-
console.log(`Event processed: ${event.type}`);
|
|
3110
2462
|
} catch (error) {
|
|
3111
2463
|
console.error(
|
|
3112
2464
|
"Error processing WebSocket message:",
|
|
@@ -3188,11 +2540,11 @@ var AriClient = class {
|
|
|
3188
2540
|
this.baseClient = new BaseClient(baseUrl, config.username, config.password);
|
|
3189
2541
|
this.channels = new Channels(this.baseClient, this);
|
|
3190
2542
|
this.playbacks = new Playbacks(this.baseClient, this);
|
|
3191
|
-
this.bridges = new Bridges(this.baseClient, this);
|
|
3192
2543
|
this.endpoints = new Endpoints(this.baseClient);
|
|
3193
2544
|
this.applications = new Applications(this.baseClient);
|
|
3194
2545
|
this.sounds = new Sounds(this.baseClient);
|
|
3195
2546
|
this.asterisk = new Asterisk(this.baseClient);
|
|
2547
|
+
this.bridges = new Bridges(this.baseClient);
|
|
3196
2548
|
console.log(`ARI Client initialized with base URL: ${baseUrl}`);
|
|
3197
2549
|
}
|
|
3198
2550
|
baseClient;
|
|
@@ -3308,20 +2660,6 @@ var AriClient = class {
|
|
|
3308
2660
|
Playback(playbackId, _app) {
|
|
3309
2661
|
return this.playbacks.Playback({ id: playbackId });
|
|
3310
2662
|
}
|
|
3311
|
-
/**
|
|
3312
|
-
* Creates or retrieves a Bridge instance.
|
|
3313
|
-
*
|
|
3314
|
-
* This function allows you to create a new Bridge instance or retrieve an existing one
|
|
3315
|
-
* based on the provided bridge ID.
|
|
3316
|
-
*
|
|
3317
|
-
* @param {string} [bridgeId] - Optional ID of an existing bridge. If provided, retrieves the
|
|
3318
|
-
* existing bridge with this ID. If omitted, creates a new bridge.
|
|
3319
|
-
* @returns {BridgeInstance} A new or existing Bridge instance that can be used to interact
|
|
3320
|
-
* with the Asterisk bridge.
|
|
3321
|
-
*/
|
|
3322
|
-
Bridge(bridgeId) {
|
|
3323
|
-
return this.bridges.Bridge({ id: bridgeId });
|
|
3324
|
-
}
|
|
3325
2663
|
/**
|
|
3326
2664
|
* Gets the current WebSocket connection status.
|
|
3327
2665
|
*
|
|
@@ -3336,7 +2674,6 @@ var AriClient = class {
|
|
|
3336
2674
|
Applications,
|
|
3337
2675
|
AriClient,
|
|
3338
2676
|
Asterisk,
|
|
3339
|
-
BridgeInstance,
|
|
3340
2677
|
Bridges,
|
|
3341
2678
|
ChannelInstance,
|
|
3342
2679
|
Channels,
|