@ipcom/asterisk-ari 0.0.27 → 0.0.28
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 +287 -123
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/esm/index.js +287 -123
- package/dist/esm/index.js.map +2 -2
- package/dist/types/ari-client/ariClient.d.ts +16 -2
- package/dist/types/ari-client/ariClient.d.ts.map +1 -1
- package/dist/types/ari-client/resources/channels.d.ts +94 -66
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/resources/playbacks.d.ts +47 -10
- package/dist/types/ari-client/resources/playbacks.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -840,22 +840,90 @@ import { EventEmitter } from "events";
|
|
|
840
840
|
function toQueryParams2(options) {
|
|
841
841
|
return new URLSearchParams(
|
|
842
842
|
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
|
|
843
|
-
// Garante que value é string
|
|
844
843
|
).toString();
|
|
845
844
|
}
|
|
845
|
+
var ChannelInstance = class extends EventEmitter {
|
|
846
|
+
constructor(client, channelId) {
|
|
847
|
+
super();
|
|
848
|
+
this.client = client;
|
|
849
|
+
this.channelId = channelId;
|
|
850
|
+
}
|
|
851
|
+
channelData = null;
|
|
852
|
+
/**
|
|
853
|
+
* Origina um canal físico no Asterisk.
|
|
854
|
+
*/
|
|
855
|
+
async originate(data) {
|
|
856
|
+
if (this.channelData) {
|
|
857
|
+
throw new Error("O canal j\xE1 foi criado.");
|
|
858
|
+
}
|
|
859
|
+
const channel = await this.client.post("/channels", data);
|
|
860
|
+
this.channelData = channel;
|
|
861
|
+
this.emit("ChannelCreated", channel, this);
|
|
862
|
+
return channel;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Obtém os detalhes do canal.
|
|
866
|
+
*/
|
|
867
|
+
async getDetails() {
|
|
868
|
+
if (!this.channelId && !this.channelData) {
|
|
869
|
+
throw new Error("Nenhum canal est\xE1 associado a esta inst\xE2ncia.");
|
|
870
|
+
}
|
|
871
|
+
const id = this.channelId || this.channelData?.id;
|
|
872
|
+
const details = await this.client.get(`/channels/${id}`);
|
|
873
|
+
this.channelData = details;
|
|
874
|
+
return details;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Encerra o canal, se ele já foi criado.
|
|
878
|
+
*/
|
|
879
|
+
async hangup() {
|
|
880
|
+
if (!this.channelData) {
|
|
881
|
+
throw new Error("O canal ainda n\xE3o foi criado.");
|
|
882
|
+
}
|
|
883
|
+
await this.client.delete(`/channels/${this.channelData.id}`);
|
|
884
|
+
this.emit("ChannelHungUp", this.channelData);
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Adiciona um listener para eventos de canal.
|
|
888
|
+
*/
|
|
889
|
+
on(event, callback) {
|
|
890
|
+
super.on(event, callback);
|
|
891
|
+
return this;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Adiciona um listener para ser chamado apenas uma vez.
|
|
895
|
+
*/
|
|
896
|
+
once(event, callback) {
|
|
897
|
+
super.once(event, callback);
|
|
898
|
+
return this;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Remove um listener específico.
|
|
902
|
+
*/
|
|
903
|
+
off(event, callback) {
|
|
904
|
+
super.off(event, callback);
|
|
905
|
+
return this;
|
|
906
|
+
}
|
|
907
|
+
};
|
|
846
908
|
var Channels = class extends EventEmitter {
|
|
847
909
|
constructor(client) {
|
|
848
910
|
super();
|
|
849
911
|
this.client = client;
|
|
850
912
|
}
|
|
851
913
|
/**
|
|
852
|
-
*
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
*
|
|
914
|
+
* Cria uma nova instância de `ChannelInstance` sem originar um canal físico.
|
|
915
|
+
*/
|
|
916
|
+
createChannelInstance(channelId) {
|
|
917
|
+
return new ChannelInstance(this.client, channelId);
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Origina um canal físico diretamente, sem uma instância de `ChannelInstance`.
|
|
921
|
+
*/
|
|
922
|
+
async originate(data) {
|
|
923
|
+
return this.client.post("/channels", data);
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Lida com eventos relacionados ao canal e os emite para listeners registrados.
|
|
859
927
|
*/
|
|
860
928
|
emitChannelEvent(eventType, data) {
|
|
861
929
|
if ("channel" in data) {
|
|
@@ -867,37 +935,25 @@ var Channels = class extends EventEmitter {
|
|
|
867
935
|
this.emit(eventType, data);
|
|
868
936
|
}
|
|
869
937
|
/**
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
* @param eventType - The type of WebSocket event to listen for.
|
|
873
|
-
* @param channelId - The ID of the channel to listen for.
|
|
874
|
-
* @param callback - The callback function to execute when the event occurs.
|
|
938
|
+
* Registra um listener para eventos de canal específicos.
|
|
875
939
|
*/
|
|
876
940
|
registerChannelListener(eventType, channelId, callback) {
|
|
877
941
|
this.on(`${eventType}:${channelId}`, callback);
|
|
878
942
|
}
|
|
879
943
|
/**
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
* @param eventType - The type of WebSocket event to stop listening for.
|
|
883
|
-
* @param channelId - The ID of the channel to stop listening for.
|
|
884
|
-
* @param callback - The callback function to remove.
|
|
944
|
+
* Remove um listener específico de eventos de canal.
|
|
885
945
|
*/
|
|
886
946
|
unregisterChannelListener(eventType, channelId, callback) {
|
|
887
947
|
this.off(`${eventType}:${channelId}`, callback);
|
|
888
948
|
}
|
|
889
949
|
/**
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
* @param eventType - The type of event to check.
|
|
893
|
-
* @param channelId - The channel ID associated with the listener.
|
|
894
|
-
* @returns True if a listener is already registered, false otherwise.
|
|
950
|
+
* Verifica se um listener já está registrado para um evento de canal.
|
|
895
951
|
*/
|
|
896
952
|
isChannelListenerRegistered(eventType, channelId) {
|
|
897
953
|
return this.listenerCount(`${eventType}:${channelId}`) > 0;
|
|
898
954
|
}
|
|
899
955
|
/**
|
|
900
|
-
*
|
|
956
|
+
* Lista todos os canais ativos.
|
|
901
957
|
*/
|
|
902
958
|
async list() {
|
|
903
959
|
const channels = await this.client.get("/channels");
|
|
@@ -907,34 +963,23 @@ var Channels = class extends EventEmitter {
|
|
|
907
963
|
return channels;
|
|
908
964
|
}
|
|
909
965
|
/**
|
|
910
|
-
*
|
|
911
|
-
*/
|
|
912
|
-
async originate(data) {
|
|
913
|
-
return this.client.post("/channels", data);
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Retrieves details of a specific channel.
|
|
966
|
+
* Obtém detalhes de um canal específico.
|
|
917
967
|
*/
|
|
918
968
|
async getDetails(channelId) {
|
|
919
969
|
return this.client.get(`/channels/${channelId}`);
|
|
920
970
|
}
|
|
921
971
|
/**
|
|
922
|
-
*
|
|
923
|
-
*/
|
|
924
|
-
async createChannel(data) {
|
|
925
|
-
return this.client.post("/channels/create", data);
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* Creates a new channel with a specific ID and originates a call.
|
|
972
|
+
* Reproduz mídia em um canal.
|
|
929
973
|
*/
|
|
930
|
-
async
|
|
931
|
-
|
|
974
|
+
async playMedia(channelId, media, options) {
|
|
975
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
976
|
+
return this.client.post(
|
|
977
|
+
`/channels/${channelId}/play${queryParams}`,
|
|
978
|
+
{ media }
|
|
979
|
+
);
|
|
932
980
|
}
|
|
933
981
|
/**
|
|
934
|
-
*
|
|
935
|
-
*/
|
|
936
|
-
/**
|
|
937
|
-
* Hangs up a specific channel with optional reason or reason code.
|
|
982
|
+
* Encerra um canal específico.
|
|
938
983
|
*/
|
|
939
984
|
async hangup(channelId, options) {
|
|
940
985
|
const queryParams = new URLSearchParams({
|
|
@@ -946,15 +991,82 @@ var Channels = class extends EventEmitter {
|
|
|
946
991
|
);
|
|
947
992
|
}
|
|
948
993
|
/**
|
|
949
|
-
*
|
|
994
|
+
* Inicia a escuta em um canal.
|
|
950
995
|
*/
|
|
951
|
-
async
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
996
|
+
async snoopChannel(channelId, options) {
|
|
997
|
+
const queryParams = toQueryParams2(options);
|
|
998
|
+
return this.client.post(
|
|
999
|
+
`/channels/${channelId}/snoop?${queryParams}`
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
async startSilence(channelId) {
|
|
1003
|
+
return this.client.post(`/channels/${channelId}/silence`);
|
|
1004
|
+
}
|
|
1005
|
+
async stopSilence(channelId) {
|
|
1006
|
+
return this.client.delete(`/channels/${channelId}/silence`);
|
|
1007
|
+
}
|
|
1008
|
+
async getRTPStatistics(channelId) {
|
|
1009
|
+
return this.client.get(`/channels/${channelId}/rtp_statistics`);
|
|
1010
|
+
}
|
|
1011
|
+
async createExternalMedia(options) {
|
|
1012
|
+
const queryParams = new URLSearchParams(options);
|
|
1013
|
+
return this.client.post(
|
|
1014
|
+
`/channels/externalMedia?${queryParams.toString()}`
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
async playWithId(channelId, playbackId, media, options) {
|
|
1018
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
1019
|
+
return this.client.post(
|
|
1020
|
+
`/channels/${channelId}/play/${playbackId}${queryParams}`,
|
|
1021
|
+
{ media }
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
async snoopChannelWithId(channelId, snoopId, options) {
|
|
1025
|
+
const queryParams = new URLSearchParams(options);
|
|
1026
|
+
return this.client.post(
|
|
1027
|
+
`/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
|
|
1028
|
+
);
|
|
1029
|
+
}
|
|
1030
|
+
async startMohWithClass(channelId, mohClass) {
|
|
1031
|
+
const queryParams = `mohClass=${encodeURIComponent(mohClass)}`;
|
|
1032
|
+
return this.client.post(`/channels/${channelId}/moh?${queryParams}`);
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Gets the value of a channel variable or function.
|
|
1036
|
+
*
|
|
1037
|
+
* @param channelId - The ID of the channel.
|
|
1038
|
+
* @param variable - The name of the channel variable or function to retrieve.
|
|
1039
|
+
* @returns A promise that resolves to the value of the variable.
|
|
1040
|
+
* @throws Will throw an error if the variable is missing or the channel is not found.
|
|
1041
|
+
*/
|
|
1042
|
+
async getChannelVariable(channelId, variable) {
|
|
1043
|
+
if (!variable) {
|
|
1044
|
+
throw new Error("The 'variable' parameter is required.");
|
|
1045
|
+
}
|
|
1046
|
+
return this.client.get(
|
|
1047
|
+
`/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Sets the value of a channel variable or function.
|
|
1052
|
+
*
|
|
1053
|
+
* @param channelId - The ID of the channel.
|
|
1054
|
+
* @param variable - The name of the channel variable or function to set.
|
|
1055
|
+
* @param value - The value to set the variable to.
|
|
1056
|
+
* @returns A promise that resolves when the variable is successfully set.
|
|
1057
|
+
* @throws Will throw an error if the variable is missing or the channel is not found.
|
|
1058
|
+
*/
|
|
1059
|
+
async setChannelVariable(channelId, variable, value) {
|
|
1060
|
+
if (!variable) {
|
|
1061
|
+
throw new Error("The 'variable' parameter is required.");
|
|
1062
|
+
}
|
|
1063
|
+
const queryParams = new URLSearchParams({
|
|
1064
|
+
variable,
|
|
1065
|
+
...value && { value }
|
|
957
1066
|
});
|
|
1067
|
+
await this.client.post(
|
|
1068
|
+
`/channels/${channelId}/variable?${queryParams.toString()}`
|
|
1069
|
+
);
|
|
958
1070
|
}
|
|
959
1071
|
/**
|
|
960
1072
|
* Moves the channel to another Stasis application.
|
|
@@ -966,31 +1078,21 @@ var Channels = class extends EventEmitter {
|
|
|
966
1078
|
});
|
|
967
1079
|
}
|
|
968
1080
|
/**
|
|
969
|
-
*
|
|
1081
|
+
* Continues the dialplan for a specific channel.
|
|
970
1082
|
*/
|
|
971
|
-
async
|
|
972
|
-
return this.client.post(`/channels/${channelId}/
|
|
973
|
-
|
|
974
|
-
|
|
1083
|
+
async continueDialplan(channelId, context, extension, priority, label) {
|
|
1084
|
+
return this.client.post(`/channels/${channelId}/continue`, {
|
|
1085
|
+
context,
|
|
1086
|
+
extension,
|
|
1087
|
+
priority,
|
|
1088
|
+
label
|
|
975
1089
|
});
|
|
976
1090
|
}
|
|
977
1091
|
/**
|
|
978
|
-
*
|
|
979
|
-
*/
|
|
980
|
-
async getVariable(channelId, variable) {
|
|
981
|
-
return this.client.get(
|
|
982
|
-
`/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
|
|
983
|
-
);
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* Plays a media file to a channel.
|
|
1092
|
+
* Stops music on hold (MOH) for a channel.
|
|
987
1093
|
*/
|
|
988
|
-
async
|
|
989
|
-
|
|
990
|
-
return this.client.post(
|
|
991
|
-
`/channels/${channelId}/play${queryParams}`,
|
|
992
|
-
{ media }
|
|
993
|
-
);
|
|
1094
|
+
async stopMusicOnHold(channelId) {
|
|
1095
|
+
return this.client.delete(`/channels/${channelId}/moh`);
|
|
994
1096
|
}
|
|
995
1097
|
/**
|
|
996
1098
|
* Starts music on hold (MOH) for a channel.
|
|
@@ -999,11 +1101,8 @@ var Channels = class extends EventEmitter {
|
|
|
999
1101
|
return this.client.post(`/channels/${channelId}/moh`);
|
|
1000
1102
|
}
|
|
1001
1103
|
/**
|
|
1002
|
-
*
|
|
1104
|
+
* Starts playback of a media file on a channel.
|
|
1003
1105
|
*/
|
|
1004
|
-
async stopMusicOnHold(channelId) {
|
|
1005
|
-
return this.client.delete(`/channels/${channelId}/moh`);
|
|
1006
|
-
}
|
|
1007
1106
|
/**
|
|
1008
1107
|
* Starts playback of a media file on a channel.
|
|
1009
1108
|
*/
|
|
@@ -1069,24 +1168,6 @@ var Channels = class extends EventEmitter {
|
|
|
1069
1168
|
`/channels/${channelId}/record?${queryParams.toString()}`
|
|
1070
1169
|
);
|
|
1071
1170
|
}
|
|
1072
|
-
/**
|
|
1073
|
-
* Starts snooping on a channel.
|
|
1074
|
-
*/
|
|
1075
|
-
async snoopChannel(channelId, options) {
|
|
1076
|
-
const queryParams = toQueryParams2(options);
|
|
1077
|
-
return this.client.post(
|
|
1078
|
-
`/channels/${channelId}/snoop?${queryParams}`
|
|
1079
|
-
);
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Starts snooping on a channel with a specific snoop ID.
|
|
1083
|
-
*/
|
|
1084
|
-
async snoopChannelWithId(channelId, snoopId, options) {
|
|
1085
|
-
const queryParams = new URLSearchParams(options);
|
|
1086
|
-
return this.client.post(
|
|
1087
|
-
`/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
|
|
1088
|
-
);
|
|
1089
|
-
}
|
|
1090
1171
|
/**
|
|
1091
1172
|
* Dials a created channel.
|
|
1092
1173
|
*/
|
|
@@ -1099,21 +1180,6 @@ var Channels = class extends EventEmitter {
|
|
|
1099
1180
|
`/channels/${channelId}/dial?${queryParams.toString()}`
|
|
1100
1181
|
);
|
|
1101
1182
|
}
|
|
1102
|
-
/**
|
|
1103
|
-
* Retrieves RTP statistics for a channel.
|
|
1104
|
-
*/
|
|
1105
|
-
async getRTPStatistics(channelId) {
|
|
1106
|
-
return this.client.get(`/channels/${channelId}/rtp_statistics`);
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Creates a channel to an external media source/sink.
|
|
1110
|
-
*/
|
|
1111
|
-
async createExternalMedia(options) {
|
|
1112
|
-
const queryParams = new URLSearchParams(options);
|
|
1113
|
-
return this.client.post(
|
|
1114
|
-
`/channels/externalMedia?${queryParams.toString()}`
|
|
1115
|
-
);
|
|
1116
|
-
}
|
|
1117
1183
|
/**
|
|
1118
1184
|
* Redirects the channel to a different location.
|
|
1119
1185
|
*/
|
|
@@ -1183,6 +1249,18 @@ var Channels = class extends EventEmitter {
|
|
|
1183
1249
|
async unholdChannel(channelId) {
|
|
1184
1250
|
return this.client.delete(`/channels/${channelId}/hold`);
|
|
1185
1251
|
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Creates a channel and places it in a Stasis app without dialing it.
|
|
1254
|
+
*/
|
|
1255
|
+
async createChannel(data) {
|
|
1256
|
+
return this.client.post("/channels/create", data);
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Creates a new channel with a specific ID and originates a call.
|
|
1260
|
+
*/
|
|
1261
|
+
async originateWithId(channelId, data) {
|
|
1262
|
+
return this.client.post(`/channels/${channelId}`, data);
|
|
1263
|
+
}
|
|
1186
1264
|
};
|
|
1187
1265
|
|
|
1188
1266
|
// src/ari-client/resources/endpoints.ts
|
|
@@ -1233,11 +1311,92 @@ var Endpoints = class {
|
|
|
1233
1311
|
|
|
1234
1312
|
// src/ari-client/resources/playbacks.ts
|
|
1235
1313
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
1314
|
+
var PlaybackInstance = class extends EventEmitter2 {
|
|
1315
|
+
constructor(client, playbackId) {
|
|
1316
|
+
super();
|
|
1317
|
+
this.client = client;
|
|
1318
|
+
this.playbackId = playbackId;
|
|
1319
|
+
}
|
|
1320
|
+
playbackData = null;
|
|
1321
|
+
/**
|
|
1322
|
+
* Obtém os detalhes do playback.
|
|
1323
|
+
*/
|
|
1324
|
+
async getDetails() {
|
|
1325
|
+
if (!this.playbackId && !this.playbackData) {
|
|
1326
|
+
throw new Error("Nenhum playback associado a esta inst\xE2ncia.");
|
|
1327
|
+
}
|
|
1328
|
+
const id = this.playbackId || this.playbackData?.id;
|
|
1329
|
+
const details = await this.client.get(`/playbacks/${id}`);
|
|
1330
|
+
this.playbackData = details;
|
|
1331
|
+
return details;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Controla o playback.
|
|
1335
|
+
*/
|
|
1336
|
+
async control(operation) {
|
|
1337
|
+
if (!this.playbackId) {
|
|
1338
|
+
throw new Error("Nenhum playback associado para controlar.");
|
|
1339
|
+
}
|
|
1340
|
+
await this.client.post(`/playbacks/${this.playbackId}/control`, {
|
|
1341
|
+
operation
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Encerra o playback.
|
|
1346
|
+
*/
|
|
1347
|
+
async stop() {
|
|
1348
|
+
if (!this.playbackId) {
|
|
1349
|
+
throw new Error("Nenhum playback associado para encerrar.");
|
|
1350
|
+
}
|
|
1351
|
+
await this.client.post(`/playbacks/${this.playbackId}/stop`);
|
|
1352
|
+
this.emit("PlaybackStopped", this.playbackData);
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Adiciona um listener para eventos de playback.
|
|
1356
|
+
*/
|
|
1357
|
+
on(event, callback) {
|
|
1358
|
+
super.on(event, callback);
|
|
1359
|
+
return this;
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Adiciona um listener para ser chamado apenas uma vez.
|
|
1363
|
+
*/
|
|
1364
|
+
once(event, callback) {
|
|
1365
|
+
super.once(event, callback);
|
|
1366
|
+
return this;
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Remove um listener específico.
|
|
1370
|
+
*/
|
|
1371
|
+
off(event, callback) {
|
|
1372
|
+
super.off(event, callback);
|
|
1373
|
+
return this;
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1236
1376
|
var Playbacks = class extends EventEmitter2 {
|
|
1237
1377
|
constructor(client) {
|
|
1238
1378
|
super();
|
|
1239
1379
|
this.client = client;
|
|
1240
1380
|
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Inicializa uma nova instância de `PlaybackInstance`.
|
|
1383
|
+
*/
|
|
1384
|
+
Playback(playbackId) {
|
|
1385
|
+
return new PlaybackInstance(this.client, playbackId);
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Emite eventos de playback.
|
|
1389
|
+
* Atualizado para gerenciar eventos específicos para `PlaybackInstance`.
|
|
1390
|
+
*/
|
|
1391
|
+
emitPlaybackEvent(eventType, data) {
|
|
1392
|
+
if ("playbackId" in data) {
|
|
1393
|
+
const playbackId = data.playbackId;
|
|
1394
|
+
if (playbackId) {
|
|
1395
|
+
this.emit(`${eventType}:${playbackId}`, data);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
this.emit(eventType, data);
|
|
1399
|
+
}
|
|
1241
1400
|
/**
|
|
1242
1401
|
* Retrieves details of a specific playback.
|
|
1243
1402
|
*
|
|
@@ -1305,19 +1464,6 @@ var Playbacks = class extends EventEmitter2 {
|
|
|
1305
1464
|
isListenerRegistered(eventType, playbackId) {
|
|
1306
1465
|
return this.listenerCount(`${eventType}:${playbackId}`) > 0;
|
|
1307
1466
|
}
|
|
1308
|
-
/**
|
|
1309
|
-
* Emits playback events received via WebSocket.
|
|
1310
|
-
* This method should be called by the WebSocket client when playback events occur.
|
|
1311
|
-
*
|
|
1312
|
-
* @param eventType - The type of the WebSocket event.
|
|
1313
|
-
* @param data - The data associated with the event.
|
|
1314
|
-
*/
|
|
1315
|
-
emitPlaybackEvent(eventType, data) {
|
|
1316
|
-
if ("playbackId" in data) {
|
|
1317
|
-
this.emit(`${eventType}:${data.playbackId}`, data);
|
|
1318
|
-
}
|
|
1319
|
-
this.emit(eventType, data);
|
|
1320
|
-
}
|
|
1321
1467
|
};
|
|
1322
1468
|
|
|
1323
1469
|
// src/ari-client/resources/sounds.ts
|
|
@@ -1817,13 +1963,13 @@ var AriClient = class {
|
|
|
1817
1963
|
* Sets a channel variable.
|
|
1818
1964
|
*/
|
|
1819
1965
|
async setChannelVariable(channelId, variable, value) {
|
|
1820
|
-
return this.channels.
|
|
1966
|
+
return this.channels.setChannelVariable(channelId, variable, value);
|
|
1821
1967
|
}
|
|
1822
1968
|
/**
|
|
1823
1969
|
* Gets a channel variable.
|
|
1824
1970
|
*/
|
|
1825
1971
|
async getChannelVariable(channelId, variable) {
|
|
1826
|
-
return this.channels.
|
|
1972
|
+
return this.channels.getChannelVariable(channelId, variable);
|
|
1827
1973
|
}
|
|
1828
1974
|
/**
|
|
1829
1975
|
* Plays a media file to a channel.
|
|
@@ -2294,6 +2440,24 @@ var AriClient = class {
|
|
|
2294
2440
|
async setGlobalVariable(variableName, value) {
|
|
2295
2441
|
return this.asterisk.setGlobalVariable(variableName, value);
|
|
2296
2442
|
}
|
|
2443
|
+
/**
|
|
2444
|
+
* Inicializa uma nova instância de `ChannelInstance` para manipular canais localmente.
|
|
2445
|
+
*
|
|
2446
|
+
* @param channelId - O ID do canal, se disponível. Caso contrário, a instância será para um canal ainda não criado.
|
|
2447
|
+
* @returns Uma instância de `ChannelInstance` vinculada ao cliente atual.
|
|
2448
|
+
*/
|
|
2449
|
+
Channel(channelId) {
|
|
2450
|
+
return this.channels.createChannelInstance(channelId);
|
|
2451
|
+
}
|
|
2452
|
+
/**
|
|
2453
|
+
* Inicializa uma nova instância de `PlaybackInstance` para manipular playbacks.
|
|
2454
|
+
*
|
|
2455
|
+
* @param playbackId - O ID do playback, se disponível. Caso contrário, a instância será para um playback ainda não inicializado.
|
|
2456
|
+
* @returns Uma instância de `PlaybackInstance` vinculada ao cliente atual.
|
|
2457
|
+
*/
|
|
2458
|
+
Playback(playbackId) {
|
|
2459
|
+
return this.playbacks.Playback(playbackId);
|
|
2460
|
+
}
|
|
2297
2461
|
};
|
|
2298
2462
|
export {
|
|
2299
2463
|
Applications,
|