@ipcom/asterisk-ari 0.0.17 → 0.0.19

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.
Files changed (29) hide show
  1. package/dist/cjs/index.cjs +705 -50
  2. package/dist/cjs/index.cjs.map +4 -4
  3. package/dist/esm/index.js +700 -49
  4. package/dist/esm/index.js.map +4 -4
  5. package/dist/types/ari-client/ariClient.d.ts +218 -23
  6. package/dist/types/ari-client/ariClient.d.ts.map +1 -1
  7. package/dist/types/ari-client/baseClient.d.ts +20 -0
  8. package/dist/types/ari-client/baseClient.d.ts.map +1 -1
  9. package/dist/types/ari-client/interfaces/asterisk.types.d.ts +39 -0
  10. package/dist/types/ari-client/interfaces/asterisk.types.d.ts.map +1 -0
  11. package/dist/types/ari-client/interfaces/channels.types.d.ts +54 -5
  12. package/dist/types/ari-client/interfaces/channels.types.d.ts.map +1 -1
  13. package/dist/types/ari-client/interfaces/index.d.ts +8 -0
  14. package/dist/types/ari-client/interfaces/index.d.ts.map +1 -0
  15. package/dist/types/ari-client/interfaces/playbacks.types.d.ts +11 -0
  16. package/dist/types/ari-client/interfaces/playbacks.types.d.ts.map +1 -0
  17. package/dist/types/ari-client/interfaces/sounds.types.d.ts +11 -0
  18. package/dist/types/ari-client/interfaces/sounds.types.d.ts.map +1 -0
  19. package/dist/types/ari-client/resources/asterisk.d.ts +37 -0
  20. package/dist/types/ari-client/resources/asterisk.d.ts.map +1 -1
  21. package/dist/types/ari-client/resources/channels.d.ts +125 -26
  22. package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
  23. package/dist/types/ari-client/resources/playbacks.d.ts +28 -0
  24. package/dist/types/ari-client/resources/playbacks.d.ts.map +1 -1
  25. package/dist/types/ari-client/resources/sounds.d.ts +21 -0
  26. package/dist/types/ari-client/resources/sounds.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +5 -2
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/package.json +1 -1
@@ -579,8 +579,12 @@ var require_backoff = __commonJS({
579
579
  // src/index.ts
580
580
  var src_exports = {};
581
581
  __export(src_exports, {
582
+ Applications: () => Applications,
582
583
  AriClient: () => AriClient,
583
- Channels: () => Channels
584
+ Channels: () => Channels,
585
+ Endpoints: () => Endpoints,
586
+ Playbacks: () => Playbacks,
587
+ Sounds: () => Sounds
584
588
  });
585
589
  module.exports = __toCommonJS(src_exports);
586
590
 
@@ -597,14 +601,40 @@ var BaseClient = class {
597
601
  auth: { username, password }
598
602
  });
599
603
  }
604
+ /**
605
+ * Executes a GET request.
606
+ * @param path - The API endpoint path.
607
+ */
600
608
  async get(path) {
601
609
  const response = await this.client.get(path);
602
610
  return response.data;
603
611
  }
612
+ /**
613
+ * Executes a POST request.
614
+ * @param path - The API endpoint path.
615
+ * @param data - Optional payload to send with the request.
616
+ */
604
617
  async post(path, data) {
605
618
  const response = await this.client.post(path, data);
606
619
  return response.data;
607
620
  }
621
+ /**
622
+ * Executes a PUT request.
623
+ * @param path - The API endpoint path.
624
+ * @param data - Payload to send with the request.
625
+ */
626
+ async put(path, data) {
627
+ const response = await this.client.put(path, data);
628
+ return response.data;
629
+ }
630
+ /**
631
+ * Executes a DELETE request.
632
+ * @param path - The API endpoint path.
633
+ */
634
+ async delete(path) {
635
+ const response = await this.client.delete(path);
636
+ return response.data;
637
+ }
608
638
  };
609
639
 
610
640
  // src/ari-client/resources/applications.ts
@@ -646,16 +676,82 @@ var Applications = class {
646
676
  }
647
677
  };
648
678
 
679
+ // src/ari-client/resources/asterisk.ts
680
+ function toQueryParams(options) {
681
+ return new URLSearchParams(
682
+ Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
683
+ ).toString();
684
+ }
685
+ var Asterisk = class {
686
+ constructor(client) {
687
+ this.client = client;
688
+ }
689
+ /**
690
+ * Retrieves information about the Asterisk server.
691
+ */
692
+ async getInfo() {
693
+ return this.client.get("/asterisk/info");
694
+ }
695
+ /**
696
+ * Lists all loaded modules in the Asterisk server.
697
+ */
698
+ async listModules() {
699
+ return this.client.get("/asterisk/modules");
700
+ }
701
+ /**
702
+ * Manages a specific module in the Asterisk server.
703
+ */
704
+ async manageModule(moduleName, action) {
705
+ return this.client.post(
706
+ `/asterisk/modules/${moduleName}?action=${encodeURIComponent(action)}`
707
+ );
708
+ }
709
+ /**
710
+ * Retrieves all configured logging channels.
711
+ */
712
+ async listLoggingChannels() {
713
+ return this.client.get("/asterisk/logging");
714
+ }
715
+ /**
716
+ * Adds or removes a log channel in the Asterisk server.
717
+ */
718
+ async manageLogChannel(logChannelName, action, configuration) {
719
+ const queryParams = toQueryParams(configuration || {});
720
+ return this.client.post(
721
+ `/asterisk/logging/${logChannelName}?action=${encodeURIComponent(action)}&${queryParams}`
722
+ );
723
+ }
724
+ /**
725
+ * Retrieves the value of a global variable.
726
+ */
727
+ async getGlobalVariable(variableName) {
728
+ return this.client.get(
729
+ `/asterisk/variables?variable=${encodeURIComponent(variableName)}`
730
+ );
731
+ }
732
+ /**
733
+ * Sets a global variable.
734
+ */
735
+ async setGlobalVariable(variableName, value) {
736
+ return this.client.post(
737
+ `/asterisk/variables?variable=${encodeURIComponent(variableName)}&value=${encodeURIComponent(value)}`
738
+ );
739
+ }
740
+ };
741
+
649
742
  // src/ari-client/resources/channels.ts
743
+ function toQueryParams2(options) {
744
+ return new URLSearchParams(
745
+ Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
746
+ // Garante que value é string
747
+ ).toString();
748
+ }
650
749
  var Channels = class {
651
750
  constructor(client) {
652
751
  this.client = client;
653
752
  }
654
753
  /**
655
754
  * Lists all active channels.
656
- *
657
- * @returns A promise that resolves to an array of Channel objects representing all active channels.
658
- * @throws {Error} If the API response is not an array.
659
755
  */
660
756
  async list() {
661
757
  const channels = await this.client.get("/channels");
@@ -666,40 +762,45 @@ var Channels = class {
666
762
  }
667
763
  /**
668
764
  * Creates a new channel.
669
- *
670
- * @param data - The OriginateRequest object containing the necessary data to create a new channel.
671
- * @returns A promise that resolves to a Channel object representing the newly created channel.
672
765
  */
673
766
  async originate(data) {
674
767
  return this.client.post("/channels", data);
675
768
  }
676
769
  /**
677
770
  * Retrieves details of a specific channel.
678
- *
679
- * @param channelId - The unique identifier of the channel.
680
- * @returns A promise that resolves to a Channel object containing the details of the specified channel.
681
771
  */
682
772
  async getDetails(channelId) {
683
773
  return this.client.get(`/channels/${channelId}`);
684
774
  }
775
+ /**
776
+ * Creates a channel and places it in a Stasis app without dialing it.
777
+ */
778
+ async createChannel(data) {
779
+ return this.client.post("/channels/create", data);
780
+ }
781
+ /**
782
+ * Creates a new channel with a specific ID and originates a call.
783
+ */
784
+ async originateWithId(channelId, data) {
785
+ return this.client.post(`/channels/${channelId}`, data);
786
+ }
685
787
  /**
686
788
  * Hangs up (terminates) a specific channel.
687
- *
688
- * @param channelId - The unique identifier of the channel to be hung up.
689
- * @returns A promise that resolves when the channel has been successfully hung up.
690
789
  */
691
- async hangup(channelId) {
692
- return this.client.post(`/channels/${channelId}/hangup`);
790
+ /**
791
+ * Hangs up a specific channel with optional reason or reason code.
792
+ */
793
+ async hangup(channelId, options) {
794
+ const queryParams = new URLSearchParams({
795
+ ...options?.reason_code && { reason_code: options.reason_code },
796
+ ...options?.reason && { reason: options.reason }
797
+ });
798
+ return this.client.delete(
799
+ `/channels/${channelId}?${queryParams.toString()}`
800
+ );
693
801
  }
694
802
  /**
695
803
  * Continues the dialplan for a specific channel.
696
- *
697
- * @param channelId - The unique identifier of the channel.
698
- * @param context - Optional. The context to continue in the dialplan.
699
- * @param extension - Optional. The extension to continue in the dialplan.
700
- * @param priority - Optional. The priority to continue in the dialplan.
701
- * @param label - Optional. The label to continue in the dialplan.
702
- * @returns A promise that resolves when the dialplan continuation has been successfully initiated.
703
804
  */
704
805
  async continueDialplan(channelId, context, extension, priority, label) {
705
806
  return this.client.post(`/channels/${channelId}/continue`, {
@@ -711,11 +812,6 @@ var Channels = class {
711
812
  }
712
813
  /**
713
814
  * Moves the channel to another Stasis application.
714
- *
715
- * @param channelId - The unique identifier of the channel to be moved.
716
- * @param app - The name of the Stasis application to move the channel to.
717
- * @param appArgs - Optional. Arguments to be passed to the Stasis application.
718
- * @returns A promise that resolves when the channel has been successfully moved to the new application.
719
815
  */
720
816
  async moveToApplication(channelId, app, appArgs) {
721
817
  return this.client.post(`/channels/${channelId}/move`, {
@@ -723,6 +819,224 @@ var Channels = class {
723
819
  appArgs
724
820
  });
725
821
  }
822
+ /**
823
+ * Sets a channel variable.
824
+ */
825
+ async setVariable(channelId, variable, value) {
826
+ return this.client.post(`/channels/${channelId}/variable`, {
827
+ variable,
828
+ value
829
+ });
830
+ }
831
+ /**
832
+ * Gets a channel variable.
833
+ */
834
+ async getVariable(channelId, variable) {
835
+ return this.client.get(
836
+ `/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
837
+ );
838
+ }
839
+ /**
840
+ * Plays a media file to a channel.
841
+ */
842
+ async playMedia(channelId, media, options) {
843
+ const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
844
+ return this.client.post(
845
+ `/channels/${channelId}/play${queryParams}`,
846
+ { media }
847
+ );
848
+ }
849
+ /**
850
+ * Starts music on hold (MOH) for a channel.
851
+ */
852
+ async startMusicOnHold(channelId) {
853
+ return this.client.post(`/channels/${channelId}/moh`);
854
+ }
855
+ /**
856
+ * Stops music on hold (MOH) for a channel.
857
+ */
858
+ async stopMusicOnHold(channelId) {
859
+ return this.client.delete(`/channels/${channelId}/moh`);
860
+ }
861
+ /**
862
+ * Starts playback of a media file on a channel.
863
+ */
864
+ async startPlayback(channelId, media, options) {
865
+ const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
866
+ return this.client.post(
867
+ `/channels/${channelId}/play${queryParams}`,
868
+ { media }
869
+ );
870
+ }
871
+ /**
872
+ * Stops playback of a media file on a channel.
873
+ */
874
+ async stopPlayback(channelId, playbackId) {
875
+ return this.client.delete(
876
+ `/channels/${channelId}/play/${playbackId}`
877
+ );
878
+ }
879
+ /**
880
+ * Pauses playback of a media file on a channel.
881
+ */
882
+ async pausePlayback(channelId, playbackId) {
883
+ return this.client.post(
884
+ `/channels/${channelId}/play/${playbackId}/pause`
885
+ );
886
+ }
887
+ /**
888
+ * Resumes playback of a media file on a channel.
889
+ */
890
+ async resumePlayback(channelId, playbackId) {
891
+ return this.client.delete(
892
+ `/channels/${channelId}/play/${playbackId}/pause`
893
+ );
894
+ }
895
+ /**
896
+ * Rewinds playback of a media file on a channel.
897
+ */
898
+ async rewindPlayback(channelId, playbackId, skipMs) {
899
+ return this.client.post(
900
+ `/channels/${channelId}/play/${playbackId}/rewind`,
901
+ { skipMs }
902
+ );
903
+ }
904
+ /**
905
+ * Fast-forwards playback of a media file on a channel.
906
+ */
907
+ async fastForwardPlayback(channelId, playbackId, skipMs) {
908
+ return this.client.post(
909
+ `/channels/${channelId}/play/${playbackId}/forward`,
910
+ { skipMs }
911
+ );
912
+ }
913
+ /**
914
+ * Records audio from a channel.
915
+ */
916
+ async record(channelId, options) {
917
+ const queryParams = new URLSearchParams(
918
+ Object.entries(options).filter(
919
+ ([, value]) => value !== void 0
920
+ )
921
+ );
922
+ return this.client.post(
923
+ `/channels/${channelId}/record?${queryParams.toString()}`
924
+ );
925
+ }
926
+ /**
927
+ * Starts snooping on a channel.
928
+ */
929
+ async snoopChannel(channelId, options) {
930
+ const queryParams = toQueryParams2(options);
931
+ return this.client.post(
932
+ `/channels/${channelId}/snoop?${queryParams}`
933
+ );
934
+ }
935
+ /**
936
+ * Starts snooping on a channel with a specific snoop ID.
937
+ */
938
+ async snoopChannelWithId(channelId, snoopId, options) {
939
+ const queryParams = new URLSearchParams(options);
940
+ return this.client.post(
941
+ `/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
942
+ );
943
+ }
944
+ /**
945
+ * Dials a created channel.
946
+ */
947
+ async dial(channelId, caller, timeout) {
948
+ const queryParams = new URLSearchParams({
949
+ ...caller && { caller },
950
+ ...timeout && { timeout: timeout.toString() }
951
+ });
952
+ return this.client.post(
953
+ `/channels/${channelId}/dial?${queryParams.toString()}`
954
+ );
955
+ }
956
+ /**
957
+ * Retrieves RTP statistics for a channel.
958
+ */
959
+ async getRTPStatistics(channelId) {
960
+ return this.client.get(`/channels/${channelId}/rtp_statistics`);
961
+ }
962
+ /**
963
+ * Creates a channel to an external media source/sink.
964
+ */
965
+ async createExternalMedia(options) {
966
+ const queryParams = new URLSearchParams(options);
967
+ return this.client.post(
968
+ `/channels/externalMedia?${queryParams.toString()}`
969
+ );
970
+ }
971
+ /**
972
+ * Redirects the channel to a different location.
973
+ */
974
+ async redirectChannel(channelId, endpoint) {
975
+ return this.client.post(
976
+ `/channels/${channelId}/redirect?endpoint=${encodeURIComponent(endpoint)}`
977
+ );
978
+ }
979
+ /**
980
+ * Answers a channel.
981
+ */
982
+ async answerChannel(channelId) {
983
+ return this.client.post(`/channels/${channelId}/answer`);
984
+ }
985
+ /**
986
+ * Sends a ringing indication to a channel.
987
+ */
988
+ async ringChannel(channelId) {
989
+ return this.client.post(`/channels/${channelId}/ring`);
990
+ }
991
+ /**
992
+ * Stops ringing indication on a channel.
993
+ */
994
+ async stopRingChannel(channelId) {
995
+ return this.client.delete(`/channels/${channelId}/ring`);
996
+ }
997
+ /**
998
+ * Sends DTMF to a channel.
999
+ */
1000
+ async sendDTMF(channelId, dtmf, options) {
1001
+ const queryParams = new URLSearchParams({
1002
+ dtmf,
1003
+ ...options?.before && { before: options.before.toString() },
1004
+ ...options?.between && { between: options.between.toString() },
1005
+ ...options?.duration && { duration: options.duration.toString() },
1006
+ ...options?.after && { after: options.after.toString() }
1007
+ });
1008
+ return this.client.post(
1009
+ `/channels/${channelId}/dtmf?${queryParams.toString()}`
1010
+ );
1011
+ }
1012
+ /**
1013
+ * Mutes a channel.
1014
+ */
1015
+ async muteChannel(channelId, direction = "both") {
1016
+ return this.client.post(
1017
+ `/channels/${channelId}/mute?direction=${direction}`
1018
+ );
1019
+ }
1020
+ /**
1021
+ * Unmutes a channel.
1022
+ */
1023
+ async unmuteChannel(channelId, direction = "both") {
1024
+ return this.client.delete(
1025
+ `/channels/${channelId}/mute?direction=${direction}`
1026
+ );
1027
+ }
1028
+ /**
1029
+ * Puts a channel on hold.
1030
+ */
1031
+ async holdChannel(channelId) {
1032
+ return this.client.post(`/channels/${channelId}/hold`);
1033
+ }
1034
+ /**
1035
+ * Removes a channel from hold.
1036
+ */
1037
+ async unholdChannel(channelId) {
1038
+ return this.client.delete(`/channels/${channelId}/hold`);
1039
+ }
726
1040
  };
727
1041
 
728
1042
  // src/ari-client/resources/endpoints.ts
@@ -771,6 +1085,75 @@ var Endpoints = class {
771
1085
  }
772
1086
  };
773
1087
 
1088
+ // src/ari-client/resources/playbacks.ts
1089
+ var Playbacks = class {
1090
+ constructor(client) {
1091
+ this.client = client;
1092
+ }
1093
+ /**
1094
+ * Retrieves details of a specific playback.
1095
+ *
1096
+ * @param playbackId - The unique identifier of the playback.
1097
+ * @returns A promise that resolves to a Playback object containing the details of the specified playback.
1098
+ */
1099
+ async getDetails(playbackId) {
1100
+ return this.client.get(`/playbacks/${playbackId}`);
1101
+ }
1102
+ /**
1103
+ * Controls a specific playback (e.g., pause, resume, rewind, forward, stop).
1104
+ *
1105
+ * @param playbackId - The unique identifier of the playback to control.
1106
+ * @param controlRequest - The PlaybackControlRequest containing the control operation.
1107
+ * @returns A promise that resolves when the control operation is successfully executed.
1108
+ */
1109
+ async control(playbackId, controlRequest) {
1110
+ await this.client.post(
1111
+ `/playbacks/${playbackId}/control`,
1112
+ controlRequest
1113
+ );
1114
+ }
1115
+ /**
1116
+ * Stops a specific playback.
1117
+ *
1118
+ * @param playbackId - The unique identifier of the playback to stop.
1119
+ * @returns A promise that resolves when the playback is successfully stopped.
1120
+ */
1121
+ async stop(playbackId) {
1122
+ await this.client.post(`/playbacks/${playbackId}/stop`);
1123
+ }
1124
+ };
1125
+
1126
+ // src/ari-client/resources/sounds.ts
1127
+ var Sounds = class {
1128
+ constructor(client) {
1129
+ this.client = client;
1130
+ }
1131
+ /**
1132
+ * Lists all available sounds.
1133
+ *
1134
+ * @param params - Optional parameters to filter the list of sounds.
1135
+ * @returns A promise that resolves to an array of Sound objects.
1136
+ * @throws {Error} If the API response is not an array.
1137
+ */
1138
+ async list(params) {
1139
+ const query = params ? `?${new URLSearchParams(params).toString()}` : "";
1140
+ const sounds = await this.client.get(`/sounds${query}`);
1141
+ if (!Array.isArray(sounds)) {
1142
+ throw new Error("Resposta da API /sounds n\xE3o \xE9 um array.");
1143
+ }
1144
+ return sounds;
1145
+ }
1146
+ /**
1147
+ * Retrieves details of a specific sound.
1148
+ *
1149
+ * @param soundId - The unique identifier of the sound.
1150
+ * @returns A promise that resolves to a Sound object containing the details of the specified sound.
1151
+ */
1152
+ async getDetails(soundId) {
1153
+ return this.client.get(`/sounds/${soundId}`);
1154
+ }
1155
+ };
1156
+
774
1157
  // src/ari-client/websocketClient.ts
775
1158
  var import_ws = __toESM(require("ws"), 1);
776
1159
  var WebSocketClient = class {
@@ -866,6 +1249,9 @@ var AriClient = class {
866
1249
  this.channels = new Channels(this.baseClient);
867
1250
  this.endpoints = new Endpoints(this.baseClient);
868
1251
  this.applications = new Applications(this.baseClient);
1252
+ this.playbacks = new Playbacks(this.baseClient);
1253
+ this.sounds = new Sounds(this.baseClient);
1254
+ this.asterisk = new Asterisk(this.baseClient);
869
1255
  }
870
1256
  wsClient = null;
871
1257
  baseClient;
@@ -873,6 +1259,9 @@ var AriClient = class {
873
1259
  channels;
874
1260
  endpoints;
875
1261
  applications;
1262
+ playbacks;
1263
+ sounds;
1264
+ asterisk;
876
1265
  /**
877
1266
  * Connects to the ARI WebSocket for a specific application.
878
1267
  *
@@ -980,45 +1369,32 @@ var AriClient = class {
980
1369
  *
981
1370
  * @returns {Promise<Channel[]>} A promise resolving to the list of active channels.
982
1371
  */
1372
+ /**
1373
+ * Lists all active channels.
1374
+ */
983
1375
  async listChannels() {
984
1376
  return this.channels.list();
985
1377
  }
986
1378
  /**
987
- * Initiates a new channel on the Asterisk server.
988
- *
989
- * @param data - The parameters for creating the new channel.
990
- * @returns {Promise<Channel>} A promise resolving to the new channel's details.
1379
+ * Creates a new channel.
991
1380
  */
992
1381
  async originateChannel(data) {
993
1382
  return this.channels.originate(data);
994
1383
  }
995
1384
  /**
996
1385
  * Retrieves details of a specific channel.
997
- *
998
- * @param channelId - The unique identifier of the channel.
999
- * @returns {Promise<Channel>} A promise resolving to the details of the channel.
1000
1386
  */
1001
1387
  async getChannelDetails(channelId) {
1002
1388
  return this.channels.getDetails(channelId);
1003
1389
  }
1004
1390
  /**
1005
1391
  * Hangs up a specific channel.
1006
- *
1007
- * @param channelId - The unique identifier of the channel to hang up.
1008
- * @returns {Promise<void>}
1009
1392
  */
1010
1393
  async hangupChannel(channelId) {
1011
1394
  return this.channels.hangup(channelId);
1012
1395
  }
1013
1396
  /**
1014
1397
  * Continues the dialplan for a specific channel.
1015
- *
1016
- * @param channelId - The unique identifier of the channel.
1017
- * @param context - Optional. The context to continue in the dialplan.
1018
- * @param extension - Optional. The extension to continue in the dialplan.
1019
- * @param priority - Optional. The priority to continue in the dialplan.
1020
- * @param label - Optional. The label to continue in the dialplan.
1021
- * @returns {Promise<void>}
1022
1398
  */
1023
1399
  async continueChannelDialplan(channelId, context, extension, priority, label) {
1024
1400
  return this.channels.continueDialplan(
@@ -1031,15 +1407,197 @@ var AriClient = class {
1031
1407
  }
1032
1408
  /**
1033
1409
  * Moves a channel to another Stasis application.
1034
- *
1035
- * @param channelId - The unique identifier of the channel.
1036
- * @param app - The name of the Stasis application to move the channel to.
1037
- * @param appArgs - Optional arguments for the Stasis application.
1038
- * @returns {Promise<void>}
1039
1410
  */
1040
1411
  async moveChannelToApplication(channelId, app, appArgs) {
1041
1412
  return this.channels.moveToApplication(channelId, app, appArgs);
1042
1413
  }
1414
+ /**
1415
+ * Sets a channel variable.
1416
+ */
1417
+ async setChannelVariable(channelId, variable, value) {
1418
+ return this.channels.setVariable(channelId, variable, value);
1419
+ }
1420
+ /**
1421
+ * Gets a channel variable.
1422
+ */
1423
+ async getChannelVariable(channelId, variable) {
1424
+ return this.channels.getVariable(channelId, variable);
1425
+ }
1426
+ /**
1427
+ * Plays a media file to a channel.
1428
+ */
1429
+ async playMediaToChannel(channelId, media, options) {
1430
+ return this.channels.playMedia(channelId, media, options);
1431
+ }
1432
+ /**
1433
+ * Starts music on hold for a channel.
1434
+ */
1435
+ async startChannelMusicOnHold(channelId) {
1436
+ return this.channels.startMusicOnHold(channelId);
1437
+ }
1438
+ /**
1439
+ * Stops music on hold for a channel.
1440
+ */
1441
+ async stopChannelMusicOnHold(channelId) {
1442
+ return this.channels.stopMusicOnHold(channelId);
1443
+ }
1444
+ /**
1445
+ * Starts playback of a media file on a channel.
1446
+ */
1447
+ async startChannelPlayback(channelId, media, options) {
1448
+ return this.channels.startPlayback(channelId, media, options);
1449
+ }
1450
+ /**
1451
+ * Stops playback of a media file on a channel.
1452
+ */
1453
+ async stopChannelPlayback(channelId, playbackId) {
1454
+ return this.channels.stopPlayback(channelId, playbackId);
1455
+ }
1456
+ /**
1457
+ * Pauses playback of a media file on a channel.
1458
+ */
1459
+ async pauseChannelPlayback(channelId, playbackId) {
1460
+ return this.channels.pausePlayback(channelId, playbackId);
1461
+ }
1462
+ /**
1463
+ * Resumes playback of a media file on a channel.
1464
+ */
1465
+ async resumeChannelPlayback(channelId, playbackId) {
1466
+ return this.channels.resumePlayback(channelId, playbackId);
1467
+ }
1468
+ /**
1469
+ * Rewinds playback of a media file on a channel.
1470
+ */
1471
+ async rewindChannelPlayback(channelId, playbackId, skipMs) {
1472
+ return this.channels.rewindPlayback(channelId, playbackId, skipMs);
1473
+ }
1474
+ /**
1475
+ * Fast-forwards playback of a media file on a channel.
1476
+ */
1477
+ async fastForwardChannelPlayback(channelId, playbackId, skipMs) {
1478
+ return this.channels.fastForwardPlayback(channelId, playbackId, skipMs);
1479
+ }
1480
+ /**
1481
+ * Records audio from a channel.
1482
+ */
1483
+ async recordAudio(channelId, options) {
1484
+ return this.channels.record(channelId, options);
1485
+ }
1486
+ /**
1487
+ * Starts snooping on a channel.
1488
+ */
1489
+ async snoopChannel(channelId, options) {
1490
+ return this.channels.snoopChannel(channelId, options);
1491
+ }
1492
+ /**
1493
+ * Starts snooping on a channel with a specific snoop ID.
1494
+ */
1495
+ async snoopChannelWithId(channelId, snoopId, options) {
1496
+ return this.channels.snoopChannelWithId(channelId, snoopId, options);
1497
+ }
1498
+ /**
1499
+ * Dials a created channel.
1500
+ */
1501
+ async dialChannel(channelId, caller, timeout) {
1502
+ return this.channels.dial(channelId, caller, timeout);
1503
+ }
1504
+ /**
1505
+ * Retrieves RTP statistics for a channel.
1506
+ */
1507
+ async getRTPStatistics(channelId) {
1508
+ return this.channels.getRTPStatistics(channelId);
1509
+ }
1510
+ /**
1511
+ * Creates a channel to an external media source/sink.
1512
+ */
1513
+ async createExternalMedia(options) {
1514
+ return this.channels.createExternalMedia(options);
1515
+ }
1516
+ /**
1517
+ * Redirects a channel to a different location.
1518
+ */
1519
+ async redirectChannel(channelId, endpoint) {
1520
+ return this.channels.redirectChannel(channelId, endpoint);
1521
+ }
1522
+ /**
1523
+ * Answers a channel.
1524
+ */
1525
+ async answerChannel(channelId) {
1526
+ return this.channels.answerChannel(channelId);
1527
+ }
1528
+ /**
1529
+ * Sends a ringing indication to a channel.
1530
+ */
1531
+ async ringChannel(channelId) {
1532
+ return this.channels.ringChannel(channelId);
1533
+ }
1534
+ /**
1535
+ * Stops ringing indication on a channel.
1536
+ */
1537
+ async stopRingChannel(channelId) {
1538
+ return this.channels.stopRingChannel(channelId);
1539
+ }
1540
+ /**
1541
+ * Sends DTMF to a channel.
1542
+ */
1543
+ async sendDTMF(channelId, dtmf, options) {
1544
+ return this.channels.sendDTMF(channelId, dtmf, options);
1545
+ }
1546
+ /**
1547
+ * Mutes a channel.
1548
+ */
1549
+ async muteChannel(channelId, direction = "both") {
1550
+ return this.channels.muteChannel(channelId, direction);
1551
+ }
1552
+ /**
1553
+ * Unmutes a channel.
1554
+ */
1555
+ async unmuteChannel(channelId, direction = "both") {
1556
+ return this.channels.unmuteChannel(channelId, direction);
1557
+ }
1558
+ /**
1559
+ * Puts a channel on hold.
1560
+ */
1561
+ async holdChannel(channelId) {
1562
+ return this.channels.holdChannel(channelId);
1563
+ }
1564
+ /**
1565
+ * Removes a channel from hold.
1566
+ */
1567
+ async unholdChannel(channelId) {
1568
+ return this.channels.unholdChannel(channelId);
1569
+ }
1570
+ /**
1571
+ * Creates a new channel using the provided originate request data.
1572
+ *
1573
+ * @param data - The originate request data containing channel creation parameters.
1574
+ * @returns A promise that resolves to the created Channel object.
1575
+ */
1576
+ async createChannel(data) {
1577
+ return this.channels.createChannel(data);
1578
+ }
1579
+ /**
1580
+ * Hangs up a specific channel.
1581
+ *
1582
+ * @param channelId - The unique identifier of the channel to hang up.
1583
+ * @param options - Optional parameters for the hangup operation.
1584
+ * @param options.reason_code - An optional reason code for the hangup.
1585
+ * @param options.reason - An optional textual reason for the hangup.
1586
+ * @returns A promise that resolves when the hangup operation is complete.
1587
+ */
1588
+ async hangup(channelId, options) {
1589
+ return this.channels.hangup(channelId, options);
1590
+ }
1591
+ /**
1592
+ * Originates a new channel with a specified ID using the provided originate request data.
1593
+ *
1594
+ * @param channelId - The desired unique identifier for the new channel.
1595
+ * @param data - The originate request data containing channel creation parameters.
1596
+ * @returns A promise that resolves to the created Channel object.
1597
+ */
1598
+ async originateWithId(channelId, data) {
1599
+ return this.channels.originateWithId(channelId, data);
1600
+ }
1043
1601
  // Métodos relacionados a endpoints:
1044
1602
  /**
1045
1603
  * Lists all endpoints.
@@ -1098,10 +1656,107 @@ var AriClient = class {
1098
1656
  async sendMessageToApplication(appName, body) {
1099
1657
  return this.applications.sendMessage(appName, body);
1100
1658
  }
1659
+ // Métodos relacionados a playbacks
1660
+ /**
1661
+ * Retrieves details of a specific playback.
1662
+ *
1663
+ * @param playbackId - The unique identifier of the playback.
1664
+ * @returns {Promise<Playback>} A promise resolving to the playback details.
1665
+ */
1666
+ async getPlaybackDetails(playbackId) {
1667
+ return this.playbacks.getDetails(playbackId);
1668
+ }
1669
+ /**
1670
+ * Controls a specific playback.
1671
+ *
1672
+ * @param playbackId - The unique identifier of the playback.
1673
+ * @param controlRequest - The PlaybackControlRequest containing the control operation.
1674
+ * @returns {Promise<void>} A promise resolving when the control operation is successfully executed.
1675
+ */
1676
+ async controlPlayback(playbackId, controlRequest) {
1677
+ return this.playbacks.control(playbackId, controlRequest);
1678
+ }
1679
+ /**
1680
+ * Stops a specific playback.
1681
+ *
1682
+ * @param playbackId - The unique identifier of the playback.
1683
+ * @returns {Promise<void>} A promise resolving when the playback is successfully stopped.
1684
+ */
1685
+ async stopPlayback(playbackId) {
1686
+ return this.playbacks.stop(playbackId);
1687
+ }
1688
+ /**
1689
+ * Lists all available sounds.
1690
+ *
1691
+ * @param params - Optional parameters to filter the list of sounds.
1692
+ * @returns {Promise<Sound[]>} A promise resolving to the list of sounds.
1693
+ */
1694
+ async listSounds(params) {
1695
+ return this.sounds.list(params);
1696
+ }
1697
+ /**
1698
+ * Retrieves details of a specific sound.
1699
+ *
1700
+ * @param soundId - The unique identifier of the sound.
1701
+ * @returns {Promise<Sound>} A promise resolving to the sound details.
1702
+ */
1703
+ async getSoundDetails(soundId) {
1704
+ return this.sounds.getDetails(soundId);
1705
+ }
1706
+ /**
1707
+ * Retrieves information about the Asterisk server.
1708
+ */
1709
+ async getAsteriskInfo() {
1710
+ return this.asterisk.getInfo();
1711
+ }
1712
+ /**
1713
+ * Lists all loaded modules in the Asterisk server.
1714
+ */
1715
+ async listModules() {
1716
+ return this.asterisk.listModules();
1717
+ }
1718
+ /**
1719
+ * Manages a specific module in the Asterisk server.
1720
+ */
1721
+ async manageModule(moduleName, action) {
1722
+ return this.asterisk.manageModule(moduleName, action);
1723
+ }
1724
+ /**
1725
+ * Retrieves all configured logging channels.
1726
+ */
1727
+ async listLoggingChannels() {
1728
+ return this.asterisk.listLoggingChannels();
1729
+ }
1730
+ /**
1731
+ * Adds or removes a log channel in the Asterisk server.
1732
+ */
1733
+ async manageLogChannel(logChannelName, action, configuration) {
1734
+ return this.asterisk.manageLogChannel(
1735
+ logChannelName,
1736
+ action,
1737
+ configuration
1738
+ );
1739
+ }
1740
+ /**
1741
+ * Retrieves the value of a global variable.
1742
+ */
1743
+ async getGlobalVariable(variableName) {
1744
+ return this.asterisk.getGlobalVariable(variableName);
1745
+ }
1746
+ /**
1747
+ * Sets a global variable.
1748
+ */
1749
+ async setGlobalVariable(variableName, value) {
1750
+ return this.asterisk.setGlobalVariable(variableName, value);
1751
+ }
1101
1752
  };
1102
1753
  // Annotate the CommonJS export names for ESM import in node:
1103
1754
  0 && (module.exports = {
1755
+ Applications,
1104
1756
  AriClient,
1105
- Channels
1757
+ Channels,
1758
+ Endpoints,
1759
+ Playbacks,
1760
+ Sounds
1106
1761
  });
1107
1762
  //# sourceMappingURL=index.cjs.map