@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/cjs/index.cjs
CHANGED
|
@@ -860,22 +860,90 @@ var import_events = require("events");
|
|
|
860
860
|
function toQueryParams2(options) {
|
|
861
861
|
return new URLSearchParams(
|
|
862
862
|
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
|
|
863
|
-
// Garante que value é string
|
|
864
863
|
).toString();
|
|
865
864
|
}
|
|
865
|
+
var ChannelInstance = class extends import_events.EventEmitter {
|
|
866
|
+
constructor(client, channelId) {
|
|
867
|
+
super();
|
|
868
|
+
this.client = client;
|
|
869
|
+
this.channelId = channelId;
|
|
870
|
+
}
|
|
871
|
+
channelData = null;
|
|
872
|
+
/**
|
|
873
|
+
* Origina um canal físico no Asterisk.
|
|
874
|
+
*/
|
|
875
|
+
async originate(data) {
|
|
876
|
+
if (this.channelData) {
|
|
877
|
+
throw new Error("O canal j\xE1 foi criado.");
|
|
878
|
+
}
|
|
879
|
+
const channel = await this.client.post("/channels", data);
|
|
880
|
+
this.channelData = channel;
|
|
881
|
+
this.emit("ChannelCreated", channel, this);
|
|
882
|
+
return channel;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Obtém os detalhes do canal.
|
|
886
|
+
*/
|
|
887
|
+
async getDetails() {
|
|
888
|
+
if (!this.channelId && !this.channelData) {
|
|
889
|
+
throw new Error("Nenhum canal est\xE1 associado a esta inst\xE2ncia.");
|
|
890
|
+
}
|
|
891
|
+
const id = this.channelId || this.channelData?.id;
|
|
892
|
+
const details = await this.client.get(`/channels/${id}`);
|
|
893
|
+
this.channelData = details;
|
|
894
|
+
return details;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Encerra o canal, se ele já foi criado.
|
|
898
|
+
*/
|
|
899
|
+
async hangup() {
|
|
900
|
+
if (!this.channelData) {
|
|
901
|
+
throw new Error("O canal ainda n\xE3o foi criado.");
|
|
902
|
+
}
|
|
903
|
+
await this.client.delete(`/channels/${this.channelData.id}`);
|
|
904
|
+
this.emit("ChannelHungUp", this.channelData);
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Adiciona um listener para eventos de canal.
|
|
908
|
+
*/
|
|
909
|
+
on(event, callback) {
|
|
910
|
+
super.on(event, callback);
|
|
911
|
+
return this;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Adiciona um listener para ser chamado apenas uma vez.
|
|
915
|
+
*/
|
|
916
|
+
once(event, callback) {
|
|
917
|
+
super.once(event, callback);
|
|
918
|
+
return this;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Remove um listener específico.
|
|
922
|
+
*/
|
|
923
|
+
off(event, callback) {
|
|
924
|
+
super.off(event, callback);
|
|
925
|
+
return this;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
866
928
|
var Channels = class extends import_events.EventEmitter {
|
|
867
929
|
constructor(client) {
|
|
868
930
|
super();
|
|
869
931
|
this.client = client;
|
|
870
932
|
}
|
|
871
933
|
/**
|
|
872
|
-
*
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
*
|
|
934
|
+
* Cria uma nova instância de `ChannelInstance` sem originar um canal físico.
|
|
935
|
+
*/
|
|
936
|
+
createChannelInstance(channelId) {
|
|
937
|
+
return new ChannelInstance(this.client, channelId);
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Origina um canal físico diretamente, sem uma instância de `ChannelInstance`.
|
|
941
|
+
*/
|
|
942
|
+
async originate(data) {
|
|
943
|
+
return this.client.post("/channels", data);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Lida com eventos relacionados ao canal e os emite para listeners registrados.
|
|
879
947
|
*/
|
|
880
948
|
emitChannelEvent(eventType, data) {
|
|
881
949
|
if ("channel" in data) {
|
|
@@ -887,37 +955,25 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
887
955
|
this.emit(eventType, data);
|
|
888
956
|
}
|
|
889
957
|
/**
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
* @param eventType - The type of WebSocket event to listen for.
|
|
893
|
-
* @param channelId - The ID of the channel to listen for.
|
|
894
|
-
* @param callback - The callback function to execute when the event occurs.
|
|
958
|
+
* Registra um listener para eventos de canal específicos.
|
|
895
959
|
*/
|
|
896
960
|
registerChannelListener(eventType, channelId, callback) {
|
|
897
961
|
this.on(`${eventType}:${channelId}`, callback);
|
|
898
962
|
}
|
|
899
963
|
/**
|
|
900
|
-
*
|
|
901
|
-
*
|
|
902
|
-
* @param eventType - The type of WebSocket event to stop listening for.
|
|
903
|
-
* @param channelId - The ID of the channel to stop listening for.
|
|
904
|
-
* @param callback - The callback function to remove.
|
|
964
|
+
* Remove um listener específico de eventos de canal.
|
|
905
965
|
*/
|
|
906
966
|
unregisterChannelListener(eventType, channelId, callback) {
|
|
907
967
|
this.off(`${eventType}:${channelId}`, callback);
|
|
908
968
|
}
|
|
909
969
|
/**
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
* @param eventType - The type of event to check.
|
|
913
|
-
* @param channelId - The channel ID associated with the listener.
|
|
914
|
-
* @returns True if a listener is already registered, false otherwise.
|
|
970
|
+
* Verifica se um listener já está registrado para um evento de canal.
|
|
915
971
|
*/
|
|
916
972
|
isChannelListenerRegistered(eventType, channelId) {
|
|
917
973
|
return this.listenerCount(`${eventType}:${channelId}`) > 0;
|
|
918
974
|
}
|
|
919
975
|
/**
|
|
920
|
-
*
|
|
976
|
+
* Lista todos os canais ativos.
|
|
921
977
|
*/
|
|
922
978
|
async list() {
|
|
923
979
|
const channels = await this.client.get("/channels");
|
|
@@ -927,34 +983,23 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
927
983
|
return channels;
|
|
928
984
|
}
|
|
929
985
|
/**
|
|
930
|
-
*
|
|
931
|
-
*/
|
|
932
|
-
async originate(data) {
|
|
933
|
-
return this.client.post("/channels", data);
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* Retrieves details of a specific channel.
|
|
986
|
+
* Obtém detalhes de um canal específico.
|
|
937
987
|
*/
|
|
938
988
|
async getDetails(channelId) {
|
|
939
989
|
return this.client.get(`/channels/${channelId}`);
|
|
940
990
|
}
|
|
941
991
|
/**
|
|
942
|
-
*
|
|
943
|
-
*/
|
|
944
|
-
async createChannel(data) {
|
|
945
|
-
return this.client.post("/channels/create", data);
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* Creates a new channel with a specific ID and originates a call.
|
|
992
|
+
* Reproduz mídia em um canal.
|
|
949
993
|
*/
|
|
950
|
-
async
|
|
951
|
-
|
|
994
|
+
async playMedia(channelId, media, options) {
|
|
995
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
996
|
+
return this.client.post(
|
|
997
|
+
`/channels/${channelId}/play${queryParams}`,
|
|
998
|
+
{ media }
|
|
999
|
+
);
|
|
952
1000
|
}
|
|
953
1001
|
/**
|
|
954
|
-
*
|
|
955
|
-
*/
|
|
956
|
-
/**
|
|
957
|
-
* Hangs up a specific channel with optional reason or reason code.
|
|
1002
|
+
* Encerra um canal específico.
|
|
958
1003
|
*/
|
|
959
1004
|
async hangup(channelId, options) {
|
|
960
1005
|
const queryParams = new URLSearchParams({
|
|
@@ -966,15 +1011,82 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
966
1011
|
);
|
|
967
1012
|
}
|
|
968
1013
|
/**
|
|
969
|
-
*
|
|
1014
|
+
* Inicia a escuta em um canal.
|
|
970
1015
|
*/
|
|
971
|
-
async
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1016
|
+
async snoopChannel(channelId, options) {
|
|
1017
|
+
const queryParams = toQueryParams2(options);
|
|
1018
|
+
return this.client.post(
|
|
1019
|
+
`/channels/${channelId}/snoop?${queryParams}`
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
async startSilence(channelId) {
|
|
1023
|
+
return this.client.post(`/channels/${channelId}/silence`);
|
|
1024
|
+
}
|
|
1025
|
+
async stopSilence(channelId) {
|
|
1026
|
+
return this.client.delete(`/channels/${channelId}/silence`);
|
|
1027
|
+
}
|
|
1028
|
+
async getRTPStatistics(channelId) {
|
|
1029
|
+
return this.client.get(`/channels/${channelId}/rtp_statistics`);
|
|
1030
|
+
}
|
|
1031
|
+
async createExternalMedia(options) {
|
|
1032
|
+
const queryParams = new URLSearchParams(options);
|
|
1033
|
+
return this.client.post(
|
|
1034
|
+
`/channels/externalMedia?${queryParams.toString()}`
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
async playWithId(channelId, playbackId, media, options) {
|
|
1038
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
1039
|
+
return this.client.post(
|
|
1040
|
+
`/channels/${channelId}/play/${playbackId}${queryParams}`,
|
|
1041
|
+
{ media }
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
async snoopChannelWithId(channelId, snoopId, options) {
|
|
1045
|
+
const queryParams = new URLSearchParams(options);
|
|
1046
|
+
return this.client.post(
|
|
1047
|
+
`/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
async startMohWithClass(channelId, mohClass) {
|
|
1051
|
+
const queryParams = `mohClass=${encodeURIComponent(mohClass)}`;
|
|
1052
|
+
return this.client.post(`/channels/${channelId}/moh?${queryParams}`);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Gets the value of a channel variable or function.
|
|
1056
|
+
*
|
|
1057
|
+
* @param channelId - The ID of the channel.
|
|
1058
|
+
* @param variable - The name of the channel variable or function to retrieve.
|
|
1059
|
+
* @returns A promise that resolves to the value of the variable.
|
|
1060
|
+
* @throws Will throw an error if the variable is missing or the channel is not found.
|
|
1061
|
+
*/
|
|
1062
|
+
async getChannelVariable(channelId, variable) {
|
|
1063
|
+
if (!variable) {
|
|
1064
|
+
throw new Error("The 'variable' parameter is required.");
|
|
1065
|
+
}
|
|
1066
|
+
return this.client.get(
|
|
1067
|
+
`/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Sets the value of a channel variable or function.
|
|
1072
|
+
*
|
|
1073
|
+
* @param channelId - The ID of the channel.
|
|
1074
|
+
* @param variable - The name of the channel variable or function to set.
|
|
1075
|
+
* @param value - The value to set the variable to.
|
|
1076
|
+
* @returns A promise that resolves when the variable is successfully set.
|
|
1077
|
+
* @throws Will throw an error if the variable is missing or the channel is not found.
|
|
1078
|
+
*/
|
|
1079
|
+
async setChannelVariable(channelId, variable, value) {
|
|
1080
|
+
if (!variable) {
|
|
1081
|
+
throw new Error("The 'variable' parameter is required.");
|
|
1082
|
+
}
|
|
1083
|
+
const queryParams = new URLSearchParams({
|
|
1084
|
+
variable,
|
|
1085
|
+
...value && { value }
|
|
977
1086
|
});
|
|
1087
|
+
await this.client.post(
|
|
1088
|
+
`/channels/${channelId}/variable?${queryParams.toString()}`
|
|
1089
|
+
);
|
|
978
1090
|
}
|
|
979
1091
|
/**
|
|
980
1092
|
* Moves the channel to another Stasis application.
|
|
@@ -986,31 +1098,21 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
986
1098
|
});
|
|
987
1099
|
}
|
|
988
1100
|
/**
|
|
989
|
-
*
|
|
1101
|
+
* Continues the dialplan for a specific channel.
|
|
990
1102
|
*/
|
|
991
|
-
async
|
|
992
|
-
return this.client.post(`/channels/${channelId}/
|
|
993
|
-
|
|
994
|
-
|
|
1103
|
+
async continueDialplan(channelId, context, extension, priority, label) {
|
|
1104
|
+
return this.client.post(`/channels/${channelId}/continue`, {
|
|
1105
|
+
context,
|
|
1106
|
+
extension,
|
|
1107
|
+
priority,
|
|
1108
|
+
label
|
|
995
1109
|
});
|
|
996
1110
|
}
|
|
997
1111
|
/**
|
|
998
|
-
*
|
|
999
|
-
*/
|
|
1000
|
-
async getVariable(channelId, variable) {
|
|
1001
|
-
return this.client.get(
|
|
1002
|
-
`/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
|
|
1003
|
-
);
|
|
1004
|
-
}
|
|
1005
|
-
/**
|
|
1006
|
-
* Plays a media file to a channel.
|
|
1112
|
+
* Stops music on hold (MOH) for a channel.
|
|
1007
1113
|
*/
|
|
1008
|
-
async
|
|
1009
|
-
|
|
1010
|
-
return this.client.post(
|
|
1011
|
-
`/channels/${channelId}/play${queryParams}`,
|
|
1012
|
-
{ media }
|
|
1013
|
-
);
|
|
1114
|
+
async stopMusicOnHold(channelId) {
|
|
1115
|
+
return this.client.delete(`/channels/${channelId}/moh`);
|
|
1014
1116
|
}
|
|
1015
1117
|
/**
|
|
1016
1118
|
* Starts music on hold (MOH) for a channel.
|
|
@@ -1019,11 +1121,8 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1019
1121
|
return this.client.post(`/channels/${channelId}/moh`);
|
|
1020
1122
|
}
|
|
1021
1123
|
/**
|
|
1022
|
-
*
|
|
1124
|
+
* Starts playback of a media file on a channel.
|
|
1023
1125
|
*/
|
|
1024
|
-
async stopMusicOnHold(channelId) {
|
|
1025
|
-
return this.client.delete(`/channels/${channelId}/moh`);
|
|
1026
|
-
}
|
|
1027
1126
|
/**
|
|
1028
1127
|
* Starts playback of a media file on a channel.
|
|
1029
1128
|
*/
|
|
@@ -1089,24 +1188,6 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1089
1188
|
`/channels/${channelId}/record?${queryParams.toString()}`
|
|
1090
1189
|
);
|
|
1091
1190
|
}
|
|
1092
|
-
/**
|
|
1093
|
-
* Starts snooping on a channel.
|
|
1094
|
-
*/
|
|
1095
|
-
async snoopChannel(channelId, options) {
|
|
1096
|
-
const queryParams = toQueryParams2(options);
|
|
1097
|
-
return this.client.post(
|
|
1098
|
-
`/channels/${channelId}/snoop?${queryParams}`
|
|
1099
|
-
);
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* Starts snooping on a channel with a specific snoop ID.
|
|
1103
|
-
*/
|
|
1104
|
-
async snoopChannelWithId(channelId, snoopId, options) {
|
|
1105
|
-
const queryParams = new URLSearchParams(options);
|
|
1106
|
-
return this.client.post(
|
|
1107
|
-
`/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
|
|
1108
|
-
);
|
|
1109
|
-
}
|
|
1110
1191
|
/**
|
|
1111
1192
|
* Dials a created channel.
|
|
1112
1193
|
*/
|
|
@@ -1119,21 +1200,6 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1119
1200
|
`/channels/${channelId}/dial?${queryParams.toString()}`
|
|
1120
1201
|
);
|
|
1121
1202
|
}
|
|
1122
|
-
/**
|
|
1123
|
-
* Retrieves RTP statistics for a channel.
|
|
1124
|
-
*/
|
|
1125
|
-
async getRTPStatistics(channelId) {
|
|
1126
|
-
return this.client.get(`/channels/${channelId}/rtp_statistics`);
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* Creates a channel to an external media source/sink.
|
|
1130
|
-
*/
|
|
1131
|
-
async createExternalMedia(options) {
|
|
1132
|
-
const queryParams = new URLSearchParams(options);
|
|
1133
|
-
return this.client.post(
|
|
1134
|
-
`/channels/externalMedia?${queryParams.toString()}`
|
|
1135
|
-
);
|
|
1136
|
-
}
|
|
1137
1203
|
/**
|
|
1138
1204
|
* Redirects the channel to a different location.
|
|
1139
1205
|
*/
|
|
@@ -1203,6 +1269,18 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1203
1269
|
async unholdChannel(channelId) {
|
|
1204
1270
|
return this.client.delete(`/channels/${channelId}/hold`);
|
|
1205
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Creates a channel and places it in a Stasis app without dialing it.
|
|
1274
|
+
*/
|
|
1275
|
+
async createChannel(data) {
|
|
1276
|
+
return this.client.post("/channels/create", data);
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Creates a new channel with a specific ID and originates a call.
|
|
1280
|
+
*/
|
|
1281
|
+
async originateWithId(channelId, data) {
|
|
1282
|
+
return this.client.post(`/channels/${channelId}`, data);
|
|
1283
|
+
}
|
|
1206
1284
|
};
|
|
1207
1285
|
|
|
1208
1286
|
// src/ari-client/resources/endpoints.ts
|
|
@@ -1253,11 +1331,92 @@ var Endpoints = class {
|
|
|
1253
1331
|
|
|
1254
1332
|
// src/ari-client/resources/playbacks.ts
|
|
1255
1333
|
var import_events2 = require("events");
|
|
1334
|
+
var PlaybackInstance = class extends import_events2.EventEmitter {
|
|
1335
|
+
constructor(client, playbackId) {
|
|
1336
|
+
super();
|
|
1337
|
+
this.client = client;
|
|
1338
|
+
this.playbackId = playbackId;
|
|
1339
|
+
}
|
|
1340
|
+
playbackData = null;
|
|
1341
|
+
/**
|
|
1342
|
+
* Obtém os detalhes do playback.
|
|
1343
|
+
*/
|
|
1344
|
+
async getDetails() {
|
|
1345
|
+
if (!this.playbackId && !this.playbackData) {
|
|
1346
|
+
throw new Error("Nenhum playback associado a esta inst\xE2ncia.");
|
|
1347
|
+
}
|
|
1348
|
+
const id = this.playbackId || this.playbackData?.id;
|
|
1349
|
+
const details = await this.client.get(`/playbacks/${id}`);
|
|
1350
|
+
this.playbackData = details;
|
|
1351
|
+
return details;
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Controla o playback.
|
|
1355
|
+
*/
|
|
1356
|
+
async control(operation) {
|
|
1357
|
+
if (!this.playbackId) {
|
|
1358
|
+
throw new Error("Nenhum playback associado para controlar.");
|
|
1359
|
+
}
|
|
1360
|
+
await this.client.post(`/playbacks/${this.playbackId}/control`, {
|
|
1361
|
+
operation
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Encerra o playback.
|
|
1366
|
+
*/
|
|
1367
|
+
async stop() {
|
|
1368
|
+
if (!this.playbackId) {
|
|
1369
|
+
throw new Error("Nenhum playback associado para encerrar.");
|
|
1370
|
+
}
|
|
1371
|
+
await this.client.post(`/playbacks/${this.playbackId}/stop`);
|
|
1372
|
+
this.emit("PlaybackStopped", this.playbackData);
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Adiciona um listener para eventos de playback.
|
|
1376
|
+
*/
|
|
1377
|
+
on(event, callback) {
|
|
1378
|
+
super.on(event, callback);
|
|
1379
|
+
return this;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Adiciona um listener para ser chamado apenas uma vez.
|
|
1383
|
+
*/
|
|
1384
|
+
once(event, callback) {
|
|
1385
|
+
super.once(event, callback);
|
|
1386
|
+
return this;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Remove um listener específico.
|
|
1390
|
+
*/
|
|
1391
|
+
off(event, callback) {
|
|
1392
|
+
super.off(event, callback);
|
|
1393
|
+
return this;
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1256
1396
|
var Playbacks = class extends import_events2.EventEmitter {
|
|
1257
1397
|
constructor(client) {
|
|
1258
1398
|
super();
|
|
1259
1399
|
this.client = client;
|
|
1260
1400
|
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Inicializa uma nova instância de `PlaybackInstance`.
|
|
1403
|
+
*/
|
|
1404
|
+
Playback(playbackId) {
|
|
1405
|
+
return new PlaybackInstance(this.client, playbackId);
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Emite eventos de playback.
|
|
1409
|
+
* Atualizado para gerenciar eventos específicos para `PlaybackInstance`.
|
|
1410
|
+
*/
|
|
1411
|
+
emitPlaybackEvent(eventType, data) {
|
|
1412
|
+
if ("playbackId" in data) {
|
|
1413
|
+
const playbackId = data.playbackId;
|
|
1414
|
+
if (playbackId) {
|
|
1415
|
+
this.emit(`${eventType}:${playbackId}`, data);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
this.emit(eventType, data);
|
|
1419
|
+
}
|
|
1261
1420
|
/**
|
|
1262
1421
|
* Retrieves details of a specific playback.
|
|
1263
1422
|
*
|
|
@@ -1325,19 +1484,6 @@ var Playbacks = class extends import_events2.EventEmitter {
|
|
|
1325
1484
|
isListenerRegistered(eventType, playbackId) {
|
|
1326
1485
|
return this.listenerCount(`${eventType}:${playbackId}`) > 0;
|
|
1327
1486
|
}
|
|
1328
|
-
/**
|
|
1329
|
-
* Emits playback events received via WebSocket.
|
|
1330
|
-
* This method should be called by the WebSocket client when playback events occur.
|
|
1331
|
-
*
|
|
1332
|
-
* @param eventType - The type of the WebSocket event.
|
|
1333
|
-
* @param data - The data associated with the event.
|
|
1334
|
-
*/
|
|
1335
|
-
emitPlaybackEvent(eventType, data) {
|
|
1336
|
-
if ("playbackId" in data) {
|
|
1337
|
-
this.emit(`${eventType}:${data.playbackId}`, data);
|
|
1338
|
-
}
|
|
1339
|
-
this.emit(eventType, data);
|
|
1340
|
-
}
|
|
1341
1487
|
};
|
|
1342
1488
|
|
|
1343
1489
|
// src/ari-client/resources/sounds.ts
|
|
@@ -1837,13 +1983,13 @@ var AriClient = class {
|
|
|
1837
1983
|
* Sets a channel variable.
|
|
1838
1984
|
*/
|
|
1839
1985
|
async setChannelVariable(channelId, variable, value) {
|
|
1840
|
-
return this.channels.
|
|
1986
|
+
return this.channels.setChannelVariable(channelId, variable, value);
|
|
1841
1987
|
}
|
|
1842
1988
|
/**
|
|
1843
1989
|
* Gets a channel variable.
|
|
1844
1990
|
*/
|
|
1845
1991
|
async getChannelVariable(channelId, variable) {
|
|
1846
|
-
return this.channels.
|
|
1992
|
+
return this.channels.getChannelVariable(channelId, variable);
|
|
1847
1993
|
}
|
|
1848
1994
|
/**
|
|
1849
1995
|
* Plays a media file to a channel.
|
|
@@ -2314,6 +2460,24 @@ var AriClient = class {
|
|
|
2314
2460
|
async setGlobalVariable(variableName, value) {
|
|
2315
2461
|
return this.asterisk.setGlobalVariable(variableName, value);
|
|
2316
2462
|
}
|
|
2463
|
+
/**
|
|
2464
|
+
* Inicializa uma nova instância de `ChannelInstance` para manipular canais localmente.
|
|
2465
|
+
*
|
|
2466
|
+
* @param channelId - O ID do canal, se disponível. Caso contrário, a instância será para um canal ainda não criado.
|
|
2467
|
+
* @returns Uma instância de `ChannelInstance` vinculada ao cliente atual.
|
|
2468
|
+
*/
|
|
2469
|
+
Channel(channelId) {
|
|
2470
|
+
return this.channels.createChannelInstance(channelId);
|
|
2471
|
+
}
|
|
2472
|
+
/**
|
|
2473
|
+
* Inicializa uma nova instância de `PlaybackInstance` para manipular playbacks.
|
|
2474
|
+
*
|
|
2475
|
+
* @param playbackId - O ID do playback, se disponível. Caso contrário, a instância será para um playback ainda não inicializado.
|
|
2476
|
+
* @returns Uma instância de `PlaybackInstance` vinculada ao cliente atual.
|
|
2477
|
+
*/
|
|
2478
|
+
Playback(playbackId) {
|
|
2479
|
+
return this.playbacks.Playback(playbackId);
|
|
2480
|
+
}
|
|
2317
2481
|
};
|
|
2318
2482
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2319
2483
|
0 && (module.exports = {
|