@ipcom/asterisk-ari 0.0.28 → 0.0.30
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 +84 -51
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/esm/index.js +82 -51
- package/dist/esm/index.js.map +2 -2
- package/dist/types/ari-client/resources/channels.d.ts +18 -2
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/resources/playbacks.d.ts +3 -2
- package/dist/types/ari-client/resources/playbacks.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -583,8 +583,10 @@ __export(src_exports, {
|
|
|
583
583
|
AriClient: () => AriClient,
|
|
584
584
|
Asterisk: () => Asterisk,
|
|
585
585
|
Bridges: () => Bridges,
|
|
586
|
+
ChannelInstance: () => ChannelInstance,
|
|
586
587
|
Channels: () => Channels,
|
|
587
588
|
Endpoints: () => Endpoints,
|
|
589
|
+
PlaybackInstance: () => PlaybackInstance,
|
|
588
590
|
Playbacks: () => Playbacks,
|
|
589
591
|
Sounds: () => Sounds
|
|
590
592
|
});
|
|
@@ -863,9 +865,10 @@ function toQueryParams2(options) {
|
|
|
863
865
|
).toString();
|
|
864
866
|
}
|
|
865
867
|
var ChannelInstance = class extends import_events.EventEmitter {
|
|
866
|
-
constructor(client, channelId) {
|
|
868
|
+
constructor(client, baseClient, channelId) {
|
|
867
869
|
super();
|
|
868
870
|
this.client = client;
|
|
871
|
+
this.baseClient = baseClient;
|
|
869
872
|
this.channelId = channelId;
|
|
870
873
|
}
|
|
871
874
|
channelData = null;
|
|
@@ -876,7 +879,7 @@ var ChannelInstance = class extends import_events.EventEmitter {
|
|
|
876
879
|
if (this.channelData) {
|
|
877
880
|
throw new Error("O canal j\xE1 foi criado.");
|
|
878
881
|
}
|
|
879
|
-
const channel = await this.
|
|
882
|
+
const channel = await this.baseClient.post("/channels", data);
|
|
880
883
|
this.channelData = channel;
|
|
881
884
|
this.emit("ChannelCreated", channel, this);
|
|
882
885
|
return channel;
|
|
@@ -889,7 +892,7 @@ var ChannelInstance = class extends import_events.EventEmitter {
|
|
|
889
892
|
throw new Error("Nenhum canal est\xE1 associado a esta inst\xE2ncia.");
|
|
890
893
|
}
|
|
891
894
|
const id = this.channelId || this.channelData?.id;
|
|
892
|
-
const details = await this.
|
|
895
|
+
const details = await this.baseClient.get(`/channels/${id}`);
|
|
893
896
|
this.channelData = details;
|
|
894
897
|
return details;
|
|
895
898
|
}
|
|
@@ -900,9 +903,27 @@ var ChannelInstance = class extends import_events.EventEmitter {
|
|
|
900
903
|
if (!this.channelData) {
|
|
901
904
|
throw new Error("O canal ainda n\xE3o foi criado.");
|
|
902
905
|
}
|
|
903
|
-
await this.
|
|
906
|
+
await this.baseClient.delete(`/channels/${this.channelData.id}`);
|
|
904
907
|
this.emit("ChannelHungUp", this.channelData);
|
|
905
908
|
}
|
|
909
|
+
/**
|
|
910
|
+
* Toca um arquivo de mídia no canal.
|
|
911
|
+
*
|
|
912
|
+
* @param options - Opções para o playback, incluindo mídia e idioma.
|
|
913
|
+
* @param playback - (Opcional) Uma instância de `PlaybackInstance` para gerenciar o playback. Se não fornecido, será criada uma nova.
|
|
914
|
+
* @returns Uma instância de `PlaybackInstance` associada ao playback.
|
|
915
|
+
*/
|
|
916
|
+
async play(options, playback) {
|
|
917
|
+
if (!playback) {
|
|
918
|
+
playback = this.client.Playback();
|
|
919
|
+
}
|
|
920
|
+
await this.baseClient.post(
|
|
921
|
+
`/channels/${this.channelData?.id}/play/${playback.id}`,
|
|
922
|
+
// Agora o ID é garantido
|
|
923
|
+
options
|
|
924
|
+
);
|
|
925
|
+
return playback;
|
|
926
|
+
}
|
|
906
927
|
/**
|
|
907
928
|
* Adiciona um listener para eventos de canal.
|
|
908
929
|
*/
|
|
@@ -926,21 +947,23 @@ var ChannelInstance = class extends import_events.EventEmitter {
|
|
|
926
947
|
}
|
|
927
948
|
};
|
|
928
949
|
var Channels = class extends import_events.EventEmitter {
|
|
929
|
-
constructor(client) {
|
|
950
|
+
constructor(baseClient, client, channelId) {
|
|
930
951
|
super();
|
|
952
|
+
this.baseClient = baseClient;
|
|
931
953
|
this.client = client;
|
|
954
|
+
this.channelId = channelId;
|
|
932
955
|
}
|
|
933
956
|
/**
|
|
934
957
|
* Cria uma nova instância de `ChannelInstance` sem originar um canal físico.
|
|
935
958
|
*/
|
|
936
959
|
createChannelInstance(channelId) {
|
|
937
|
-
return new ChannelInstance(this.client, channelId);
|
|
960
|
+
return new ChannelInstance(this.client, this.baseClient, channelId);
|
|
938
961
|
}
|
|
939
962
|
/**
|
|
940
963
|
* Origina um canal físico diretamente, sem uma instância de `ChannelInstance`.
|
|
941
964
|
*/
|
|
942
965
|
async originate(data) {
|
|
943
|
-
return this.
|
|
966
|
+
return this.baseClient.post("/channels", data);
|
|
944
967
|
}
|
|
945
968
|
/**
|
|
946
969
|
* Lida com eventos relacionados ao canal e os emite para listeners registrados.
|
|
@@ -976,7 +999,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
976
999
|
* Lista todos os canais ativos.
|
|
977
1000
|
*/
|
|
978
1001
|
async list() {
|
|
979
|
-
const channels = await this.
|
|
1002
|
+
const channels = await this.baseClient.get("/channels");
|
|
980
1003
|
if (!Array.isArray(channels)) {
|
|
981
1004
|
throw new Error("Resposta da API /channels n\xE3o \xE9 um array.");
|
|
982
1005
|
}
|
|
@@ -986,14 +1009,14 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
986
1009
|
* Obtém detalhes de um canal específico.
|
|
987
1010
|
*/
|
|
988
1011
|
async getDetails(channelId) {
|
|
989
|
-
return this.
|
|
1012
|
+
return this.baseClient.get(`/channels/${channelId}`);
|
|
990
1013
|
}
|
|
991
1014
|
/**
|
|
992
1015
|
* Reproduz mídia em um canal.
|
|
993
1016
|
*/
|
|
994
1017
|
async playMedia(channelId, media, options) {
|
|
995
1018
|
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
996
|
-
return this.
|
|
1019
|
+
return this.baseClient.post(
|
|
997
1020
|
`/channels/${channelId}/play${queryParams}`,
|
|
998
1021
|
{ media }
|
|
999
1022
|
);
|
|
@@ -1006,7 +1029,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1006
1029
|
...options?.reason_code && { reason_code: options.reason_code },
|
|
1007
1030
|
...options?.reason && { reason: options.reason }
|
|
1008
1031
|
});
|
|
1009
|
-
return this.
|
|
1032
|
+
return this.baseClient.delete(
|
|
1010
1033
|
`/channels/${channelId}?${queryParams.toString()}`
|
|
1011
1034
|
);
|
|
1012
1035
|
}
|
|
@@ -1015,41 +1038,45 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1015
1038
|
*/
|
|
1016
1039
|
async snoopChannel(channelId, options) {
|
|
1017
1040
|
const queryParams = toQueryParams2(options);
|
|
1018
|
-
return this.
|
|
1041
|
+
return this.baseClient.post(
|
|
1019
1042
|
`/channels/${channelId}/snoop?${queryParams}`
|
|
1020
1043
|
);
|
|
1021
1044
|
}
|
|
1022
1045
|
async startSilence(channelId) {
|
|
1023
|
-
return this.
|
|
1046
|
+
return this.baseClient.post(`/channels/${channelId}/silence`);
|
|
1024
1047
|
}
|
|
1025
1048
|
async stopSilence(channelId) {
|
|
1026
|
-
return this.
|
|
1049
|
+
return this.baseClient.delete(`/channels/${channelId}/silence`);
|
|
1027
1050
|
}
|
|
1028
1051
|
async getRTPStatistics(channelId) {
|
|
1029
|
-
return this.
|
|
1052
|
+
return this.baseClient.get(
|
|
1053
|
+
`/channels/${channelId}/rtp_statistics`
|
|
1054
|
+
);
|
|
1030
1055
|
}
|
|
1031
1056
|
async createExternalMedia(options) {
|
|
1032
1057
|
const queryParams = new URLSearchParams(options);
|
|
1033
|
-
return this.
|
|
1058
|
+
return this.baseClient.post(
|
|
1034
1059
|
`/channels/externalMedia?${queryParams.toString()}`
|
|
1035
1060
|
);
|
|
1036
1061
|
}
|
|
1037
1062
|
async playWithId(channelId, playbackId, media, options) {
|
|
1038
1063
|
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
1039
|
-
return this.
|
|
1064
|
+
return this.baseClient.post(
|
|
1040
1065
|
`/channels/${channelId}/play/${playbackId}${queryParams}`,
|
|
1041
1066
|
{ media }
|
|
1042
1067
|
);
|
|
1043
1068
|
}
|
|
1044
1069
|
async snoopChannelWithId(channelId, snoopId, options) {
|
|
1045
1070
|
const queryParams = new URLSearchParams(options);
|
|
1046
|
-
return this.
|
|
1071
|
+
return this.baseClient.post(
|
|
1047
1072
|
`/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
|
|
1048
1073
|
);
|
|
1049
1074
|
}
|
|
1050
1075
|
async startMohWithClass(channelId, mohClass) {
|
|
1051
1076
|
const queryParams = `mohClass=${encodeURIComponent(mohClass)}`;
|
|
1052
|
-
return this.
|
|
1077
|
+
return this.baseClient.post(
|
|
1078
|
+
`/channels/${channelId}/moh?${queryParams}`
|
|
1079
|
+
);
|
|
1053
1080
|
}
|
|
1054
1081
|
/**
|
|
1055
1082
|
* Gets the value of a channel variable or function.
|
|
@@ -1063,7 +1090,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1063
1090
|
if (!variable) {
|
|
1064
1091
|
throw new Error("The 'variable' parameter is required.");
|
|
1065
1092
|
}
|
|
1066
|
-
return this.
|
|
1093
|
+
return this.baseClient.get(
|
|
1067
1094
|
`/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
|
|
1068
1095
|
);
|
|
1069
1096
|
}
|
|
@@ -1084,7 +1111,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1084
1111
|
variable,
|
|
1085
1112
|
...value && { value }
|
|
1086
1113
|
});
|
|
1087
|
-
await this.
|
|
1114
|
+
await this.baseClient.post(
|
|
1088
1115
|
`/channels/${channelId}/variable?${queryParams.toString()}`
|
|
1089
1116
|
);
|
|
1090
1117
|
}
|
|
@@ -1092,7 +1119,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1092
1119
|
* Moves the channel to another Stasis application.
|
|
1093
1120
|
*/
|
|
1094
1121
|
async moveToApplication(channelId, app, appArgs) {
|
|
1095
|
-
return this.
|
|
1122
|
+
return this.baseClient.post(`/channels/${channelId}/move`, {
|
|
1096
1123
|
app,
|
|
1097
1124
|
appArgs
|
|
1098
1125
|
});
|
|
@@ -1101,7 +1128,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1101
1128
|
* Continues the dialplan for a specific channel.
|
|
1102
1129
|
*/
|
|
1103
1130
|
async continueDialplan(channelId, context, extension, priority, label) {
|
|
1104
|
-
return this.
|
|
1131
|
+
return this.baseClient.post(`/channels/${channelId}/continue`, {
|
|
1105
1132
|
context,
|
|
1106
1133
|
extension,
|
|
1107
1134
|
priority,
|
|
@@ -1112,13 +1139,13 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1112
1139
|
* Stops music on hold (MOH) for a channel.
|
|
1113
1140
|
*/
|
|
1114
1141
|
async stopMusicOnHold(channelId) {
|
|
1115
|
-
return this.
|
|
1142
|
+
return this.baseClient.delete(`/channels/${channelId}/moh`);
|
|
1116
1143
|
}
|
|
1117
1144
|
/**
|
|
1118
1145
|
* Starts music on hold (MOH) for a channel.
|
|
1119
1146
|
*/
|
|
1120
1147
|
async startMusicOnHold(channelId) {
|
|
1121
|
-
return this.
|
|
1148
|
+
return this.baseClient.post(`/channels/${channelId}/moh`);
|
|
1122
1149
|
}
|
|
1123
1150
|
/**
|
|
1124
1151
|
* Starts playback of a media file on a channel.
|
|
@@ -1128,7 +1155,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1128
1155
|
*/
|
|
1129
1156
|
async startPlayback(channelId, media, options) {
|
|
1130
1157
|
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
1131
|
-
return this.
|
|
1158
|
+
return this.baseClient.post(
|
|
1132
1159
|
`/channels/${channelId}/play${queryParams}`,
|
|
1133
1160
|
{ media }
|
|
1134
1161
|
);
|
|
@@ -1137,7 +1164,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1137
1164
|
* Stops playback of a media file on a channel.
|
|
1138
1165
|
*/
|
|
1139
1166
|
async stopPlayback(channelId, playbackId) {
|
|
1140
|
-
return this.
|
|
1167
|
+
return this.baseClient.delete(
|
|
1141
1168
|
`/channels/${channelId}/play/${playbackId}`
|
|
1142
1169
|
);
|
|
1143
1170
|
}
|
|
@@ -1145,7 +1172,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1145
1172
|
* Pauses playback of a media file on a channel.
|
|
1146
1173
|
*/
|
|
1147
1174
|
async pausePlayback(channelId, playbackId) {
|
|
1148
|
-
return this.
|
|
1175
|
+
return this.baseClient.post(
|
|
1149
1176
|
`/channels/${channelId}/play/${playbackId}/pause`
|
|
1150
1177
|
);
|
|
1151
1178
|
}
|
|
@@ -1153,7 +1180,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1153
1180
|
* Resumes playback of a media file on a channel.
|
|
1154
1181
|
*/
|
|
1155
1182
|
async resumePlayback(channelId, playbackId) {
|
|
1156
|
-
return this.
|
|
1183
|
+
return this.baseClient.delete(
|
|
1157
1184
|
`/channels/${channelId}/play/${playbackId}/pause`
|
|
1158
1185
|
);
|
|
1159
1186
|
}
|
|
@@ -1161,7 +1188,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1161
1188
|
* Rewinds playback of a media file on a channel.
|
|
1162
1189
|
*/
|
|
1163
1190
|
async rewindPlayback(channelId, playbackId, skipMs) {
|
|
1164
|
-
return this.
|
|
1191
|
+
return this.baseClient.post(
|
|
1165
1192
|
`/channels/${channelId}/play/${playbackId}/rewind`,
|
|
1166
1193
|
{ skipMs }
|
|
1167
1194
|
);
|
|
@@ -1170,7 +1197,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1170
1197
|
* Fast-forwards playback of a media file on a channel.
|
|
1171
1198
|
*/
|
|
1172
1199
|
async fastForwardPlayback(channelId, playbackId, skipMs) {
|
|
1173
|
-
return this.
|
|
1200
|
+
return this.baseClient.post(
|
|
1174
1201
|
`/channels/${channelId}/play/${playbackId}/forward`,
|
|
1175
1202
|
{ skipMs }
|
|
1176
1203
|
);
|
|
@@ -1184,7 +1211,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1184
1211
|
([, value]) => value !== void 0
|
|
1185
1212
|
)
|
|
1186
1213
|
);
|
|
1187
|
-
return this.
|
|
1214
|
+
return this.baseClient.post(
|
|
1188
1215
|
`/channels/${channelId}/record?${queryParams.toString()}`
|
|
1189
1216
|
);
|
|
1190
1217
|
}
|
|
@@ -1196,7 +1223,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1196
1223
|
...caller && { caller },
|
|
1197
1224
|
...timeout && { timeout: timeout.toString() }
|
|
1198
1225
|
});
|
|
1199
|
-
return this.
|
|
1226
|
+
return this.baseClient.post(
|
|
1200
1227
|
`/channels/${channelId}/dial?${queryParams.toString()}`
|
|
1201
1228
|
);
|
|
1202
1229
|
}
|
|
@@ -1204,7 +1231,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1204
1231
|
* Redirects the channel to a different location.
|
|
1205
1232
|
*/
|
|
1206
1233
|
async redirectChannel(channelId, endpoint) {
|
|
1207
|
-
return this.
|
|
1234
|
+
return this.baseClient.post(
|
|
1208
1235
|
`/channels/${channelId}/redirect?endpoint=${encodeURIComponent(endpoint)}`
|
|
1209
1236
|
);
|
|
1210
1237
|
}
|
|
@@ -1212,19 +1239,19 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1212
1239
|
* Answers a channel.
|
|
1213
1240
|
*/
|
|
1214
1241
|
async answerChannel(channelId) {
|
|
1215
|
-
return this.
|
|
1242
|
+
return this.baseClient.post(`/channels/${channelId}/answer`);
|
|
1216
1243
|
}
|
|
1217
1244
|
/**
|
|
1218
1245
|
* Sends a ringing indication to a channel.
|
|
1219
1246
|
*/
|
|
1220
1247
|
async ringChannel(channelId) {
|
|
1221
|
-
return this.
|
|
1248
|
+
return this.baseClient.post(`/channels/${channelId}/ring`);
|
|
1222
1249
|
}
|
|
1223
1250
|
/**
|
|
1224
1251
|
* Stops ringing indication on a channel.
|
|
1225
1252
|
*/
|
|
1226
1253
|
async stopRingChannel(channelId) {
|
|
1227
|
-
return this.
|
|
1254
|
+
return this.baseClient.delete(`/channels/${channelId}/ring`);
|
|
1228
1255
|
}
|
|
1229
1256
|
/**
|
|
1230
1257
|
* Sends DTMF to a channel.
|
|
@@ -1237,7 +1264,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1237
1264
|
...options?.duration && { duration: options.duration.toString() },
|
|
1238
1265
|
...options?.after && { after: options.after.toString() }
|
|
1239
1266
|
});
|
|
1240
|
-
return this.
|
|
1267
|
+
return this.baseClient.post(
|
|
1241
1268
|
`/channels/${channelId}/dtmf?${queryParams.toString()}`
|
|
1242
1269
|
);
|
|
1243
1270
|
}
|
|
@@ -1245,7 +1272,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1245
1272
|
* Mutes a channel.
|
|
1246
1273
|
*/
|
|
1247
1274
|
async muteChannel(channelId, direction = "both") {
|
|
1248
|
-
return this.
|
|
1275
|
+
return this.baseClient.post(
|
|
1249
1276
|
`/channels/${channelId}/mute?direction=${direction}`
|
|
1250
1277
|
);
|
|
1251
1278
|
}
|
|
@@ -1253,7 +1280,7 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1253
1280
|
* Unmutes a channel.
|
|
1254
1281
|
*/
|
|
1255
1282
|
async unmuteChannel(channelId, direction = "both") {
|
|
1256
|
-
return this.
|
|
1283
|
+
return this.baseClient.delete(
|
|
1257
1284
|
`/channels/${channelId}/mute?direction=${direction}`
|
|
1258
1285
|
);
|
|
1259
1286
|
}
|
|
@@ -1261,25 +1288,25 @@ var Channels = class extends import_events.EventEmitter {
|
|
|
1261
1288
|
* Puts a channel on hold.
|
|
1262
1289
|
*/
|
|
1263
1290
|
async holdChannel(channelId) {
|
|
1264
|
-
return this.
|
|
1291
|
+
return this.baseClient.post(`/channels/${channelId}/hold`);
|
|
1265
1292
|
}
|
|
1266
1293
|
/**
|
|
1267
1294
|
* Removes a channel from hold.
|
|
1268
1295
|
*/
|
|
1269
1296
|
async unholdChannel(channelId) {
|
|
1270
|
-
return this.
|
|
1297
|
+
return this.baseClient.delete(`/channels/${channelId}/hold`);
|
|
1271
1298
|
}
|
|
1272
1299
|
/**
|
|
1273
1300
|
* Creates a channel and places it in a Stasis app without dialing it.
|
|
1274
1301
|
*/
|
|
1275
1302
|
async createChannel(data) {
|
|
1276
|
-
return this.
|
|
1303
|
+
return this.baseClient.post("/channels/create", data);
|
|
1277
1304
|
}
|
|
1278
1305
|
/**
|
|
1279
1306
|
* Creates a new channel with a specific ID and originates a call.
|
|
1280
1307
|
*/
|
|
1281
1308
|
async originateWithId(channelId, data) {
|
|
1282
|
-
return this.
|
|
1309
|
+
return this.baseClient.post(`/channels/${channelId}`, data);
|
|
1283
1310
|
}
|
|
1284
1311
|
};
|
|
1285
1312
|
|
|
@@ -1332,12 +1359,15 @@ var Endpoints = class {
|
|
|
1332
1359
|
// src/ari-client/resources/playbacks.ts
|
|
1333
1360
|
var import_events2 = require("events");
|
|
1334
1361
|
var PlaybackInstance = class extends import_events2.EventEmitter {
|
|
1335
|
-
|
|
1362
|
+
// Garantimos que o ID esteja disponível
|
|
1363
|
+
constructor(baseClient, playbackId) {
|
|
1336
1364
|
super();
|
|
1337
|
-
this.
|
|
1365
|
+
this.baseClient = baseClient;
|
|
1338
1366
|
this.playbackId = playbackId;
|
|
1367
|
+
this.id = playbackId || `playback-${Date.now()}`;
|
|
1339
1368
|
}
|
|
1340
1369
|
playbackData = null;
|
|
1370
|
+
id;
|
|
1341
1371
|
/**
|
|
1342
1372
|
* Obtém os detalhes do playback.
|
|
1343
1373
|
*/
|
|
@@ -1346,7 +1376,7 @@ var PlaybackInstance = class extends import_events2.EventEmitter {
|
|
|
1346
1376
|
throw new Error("Nenhum playback associado a esta inst\xE2ncia.");
|
|
1347
1377
|
}
|
|
1348
1378
|
const id = this.playbackId || this.playbackData?.id;
|
|
1349
|
-
const details = await this.
|
|
1379
|
+
const details = await this.baseClient.get(`/playbacks/${id}`);
|
|
1350
1380
|
this.playbackData = details;
|
|
1351
1381
|
return details;
|
|
1352
1382
|
}
|
|
@@ -1357,7 +1387,7 @@ var PlaybackInstance = class extends import_events2.EventEmitter {
|
|
|
1357
1387
|
if (!this.playbackId) {
|
|
1358
1388
|
throw new Error("Nenhum playback associado para controlar.");
|
|
1359
1389
|
}
|
|
1360
|
-
await this.
|
|
1390
|
+
await this.baseClient.post(`/playbacks/${this.playbackId}/control`, {
|
|
1361
1391
|
operation
|
|
1362
1392
|
});
|
|
1363
1393
|
}
|
|
@@ -1368,7 +1398,7 @@ var PlaybackInstance = class extends import_events2.EventEmitter {
|
|
|
1368
1398
|
if (!this.playbackId) {
|
|
1369
1399
|
throw new Error("Nenhum playback associado para encerrar.");
|
|
1370
1400
|
}
|
|
1371
|
-
await this.
|
|
1401
|
+
await this.baseClient.post(`/playbacks/${this.playbackId}/stop`);
|
|
1372
1402
|
this.emit("PlaybackStopped", this.playbackData);
|
|
1373
1403
|
}
|
|
1374
1404
|
/**
|
|
@@ -1402,7 +1432,8 @@ var Playbacks = class extends import_events2.EventEmitter {
|
|
|
1402
1432
|
* Inicializa uma nova instância de `PlaybackInstance`.
|
|
1403
1433
|
*/
|
|
1404
1434
|
Playback(playbackId) {
|
|
1405
|
-
|
|
1435
|
+
const id = playbackId || `playback-${Date.now()}`;
|
|
1436
|
+
return new PlaybackInstance(this.client, id);
|
|
1406
1437
|
}
|
|
1407
1438
|
/**
|
|
1408
1439
|
* Emite eventos de playback.
|
|
@@ -1648,7 +1679,7 @@ var AriClient = class {
|
|
|
1648
1679
|
const normalizedHost = config.host.replace(/^https?:\/\//, "");
|
|
1649
1680
|
const baseUrl = `${httpProtocol}://${normalizedHost}:${config.port}/ari`;
|
|
1650
1681
|
this.baseClient = new BaseClient(baseUrl, config.username, config.password);
|
|
1651
|
-
this.channels = new Channels(this.baseClient);
|
|
1682
|
+
this.channels = new Channels(this.baseClient, this);
|
|
1652
1683
|
this.endpoints = new Endpoints(this.baseClient);
|
|
1653
1684
|
this.applications = new Applications(this.baseClient);
|
|
1654
1685
|
this.playbacks = new Playbacks(this.baseClient);
|
|
@@ -2485,8 +2516,10 @@ var AriClient = class {
|
|
|
2485
2516
|
AriClient,
|
|
2486
2517
|
Asterisk,
|
|
2487
2518
|
Bridges,
|
|
2519
|
+
ChannelInstance,
|
|
2488
2520
|
Channels,
|
|
2489
2521
|
Endpoints,
|
|
2522
|
+
PlaybackInstance,
|
|
2490
2523
|
Playbacks,
|
|
2491
2524
|
Sounds
|
|
2492
2525
|
});
|