@ipcom/asterisk-ari 0.0.16 → 0.0.18

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 +663 -50
  2. package/dist/cjs/index.cjs.map +3 -3
  3. package/dist/esm/index.js +658 -49
  4. package/dist/esm/index.js.map +3 -3
  5. package/dist/types/ari-client/ariClient.d.ts +208 -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/applications.types.d.ts +10 -0
  10. package/dist/types/ari-client/interfaces/applications.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 +7 -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/applications.d.ts +28 -0
  20. package/dist/types/ari-client/resources/applications.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
package/dist/esm/index.js CHANGED
@@ -583,26 +583,94 @@ var BaseClient = class {
583
583
  auth: { username, password }
584
584
  });
585
585
  }
586
+ /**
587
+ * Executes a GET request.
588
+ * @param path - The API endpoint path.
589
+ */
586
590
  async get(path) {
587
591
  const response = await this.client.get(path);
588
592
  return response.data;
589
593
  }
594
+ /**
595
+ * Executes a POST request.
596
+ * @param path - The API endpoint path.
597
+ * @param data - Optional payload to send with the request.
598
+ */
590
599
  async post(path, data) {
591
600
  const response = await this.client.post(path, data);
592
601
  return response.data;
593
602
  }
603
+ /**
604
+ * Executes a PUT request.
605
+ * @param path - The API endpoint path.
606
+ * @param data - Payload to send with the request.
607
+ */
608
+ async put(path, data) {
609
+ const response = await this.client.put(path, data);
610
+ return response.data;
611
+ }
612
+ /**
613
+ * Executes a DELETE request.
614
+ * @param path - The API endpoint path.
615
+ */
616
+ async delete(path) {
617
+ const response = await this.client.delete(path);
618
+ return response.data;
619
+ }
620
+ };
621
+
622
+ // src/ari-client/resources/applications.ts
623
+ var Applications = class {
624
+ constructor(client) {
625
+ this.client = client;
626
+ }
627
+ /**
628
+ * Lists all applications.
629
+ *
630
+ * @returns A promise that resolves to an array of Application objects representing all registered applications.
631
+ * @throws {Error} If the API response is not an array.
632
+ */
633
+ async list() {
634
+ const applications = await this.client.get("/applications");
635
+ if (!Array.isArray(applications)) {
636
+ throw new Error("Resposta da API /applications n\xE3o \xE9 um array.");
637
+ }
638
+ return applications;
639
+ }
640
+ /**
641
+ * Retrieves details of a specific application.
642
+ *
643
+ * @param appName - The unique name of the application.
644
+ * @returns A promise that resolves to an ApplicationDetails object containing the details of the specified application.
645
+ */
646
+ async getDetails(appName) {
647
+ return this.client.get(`/applications/${appName}`);
648
+ }
649
+ /**
650
+ * Sends a message to a specific application.
651
+ *
652
+ * @param appName - The unique name of the application.
653
+ * @param body - The message body to send.
654
+ * @returns A promise that resolves when the message is sent successfully.
655
+ */
656
+ async sendMessage(appName, body) {
657
+ await this.client.post(`/applications/${appName}/messages`, body);
658
+ }
594
659
  };
595
660
 
596
661
  // src/ari-client/resources/channels.ts
662
+ function toQueryParams(options) {
663
+ return new URLSearchParams(
664
+ Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
665
+ // Garante que value é string
666
+ ).toString();
667
+ }
597
668
  var Channels = class {
598
669
  constructor(client) {
599
670
  this.client = client;
600
671
  }
601
672
  /**
602
673
  * Lists all active channels.
603
- *
604
- * @returns A promise that resolves to an array of Channel objects representing all active channels.
605
- * @throws {Error} If the API response is not an array.
606
674
  */
607
675
  async list() {
608
676
  const channels = await this.client.get("/channels");
@@ -613,40 +681,45 @@ var Channels = class {
613
681
  }
614
682
  /**
615
683
  * Creates a new channel.
616
- *
617
- * @param data - The OriginateRequest object containing the necessary data to create a new channel.
618
- * @returns A promise that resolves to a Channel object representing the newly created channel.
619
684
  */
620
685
  async originate(data) {
621
686
  return this.client.post("/channels", data);
622
687
  }
623
688
  /**
624
689
  * Retrieves details of a specific channel.
625
- *
626
- * @param channelId - The unique identifier of the channel.
627
- * @returns A promise that resolves to a Channel object containing the details of the specified channel.
628
690
  */
629
691
  async getDetails(channelId) {
630
692
  return this.client.get(`/channels/${channelId}`);
631
693
  }
694
+ /**
695
+ * Creates a channel and places it in a Stasis app without dialing it.
696
+ */
697
+ async createChannel(data) {
698
+ return this.client.post("/channels/create", data);
699
+ }
700
+ /**
701
+ * Creates a new channel with a specific ID and originates a call.
702
+ */
703
+ async originateWithId(channelId, data) {
704
+ return this.client.post(`/channels/${channelId}`, data);
705
+ }
632
706
  /**
633
707
  * Hangs up (terminates) a specific channel.
634
- *
635
- * @param channelId - The unique identifier of the channel to be hung up.
636
- * @returns A promise that resolves when the channel has been successfully hung up.
637
708
  */
638
- async hangup(channelId) {
639
- return this.client.post(`/channels/${channelId}/hangup`);
709
+ /**
710
+ * Hangs up a specific channel with optional reason or reason code.
711
+ */
712
+ async hangup(channelId, options) {
713
+ const queryParams = new URLSearchParams({
714
+ ...options?.reason_code && { reason_code: options.reason_code },
715
+ ...options?.reason && { reason: options.reason }
716
+ });
717
+ return this.client.delete(
718
+ `/channels/${channelId}?${queryParams.toString()}`
719
+ );
640
720
  }
641
721
  /**
642
722
  * Continues the dialplan for a specific channel.
643
- *
644
- * @param channelId - The unique identifier of the channel.
645
- * @param context - Optional. The context to continue in the dialplan.
646
- * @param extension - Optional. The extension to continue in the dialplan.
647
- * @param priority - Optional. The priority to continue in the dialplan.
648
- * @param label - Optional. The label to continue in the dialplan.
649
- * @returns A promise that resolves when the dialplan continuation has been successfully initiated.
650
723
  */
651
724
  async continueDialplan(channelId, context, extension, priority, label) {
652
725
  return this.client.post(`/channels/${channelId}/continue`, {
@@ -658,11 +731,6 @@ var Channels = class {
658
731
  }
659
732
  /**
660
733
  * Moves the channel to another Stasis application.
661
- *
662
- * @param channelId - The unique identifier of the channel to be moved.
663
- * @param app - The name of the Stasis application to move the channel to.
664
- * @param appArgs - Optional. Arguments to be passed to the Stasis application.
665
- * @returns A promise that resolves when the channel has been successfully moved to the new application.
666
734
  */
667
735
  async moveToApplication(channelId, app, appArgs) {
668
736
  return this.client.post(`/channels/${channelId}/move`, {
@@ -670,6 +738,224 @@ var Channels = class {
670
738
  appArgs
671
739
  });
672
740
  }
741
+ /**
742
+ * Sets a channel variable.
743
+ */
744
+ async setVariable(channelId, variable, value) {
745
+ return this.client.post(`/channels/${channelId}/variable`, {
746
+ variable,
747
+ value
748
+ });
749
+ }
750
+ /**
751
+ * Gets a channel variable.
752
+ */
753
+ async getVariable(channelId, variable) {
754
+ return this.client.get(
755
+ `/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
756
+ );
757
+ }
758
+ /**
759
+ * Plays a media file to a channel.
760
+ */
761
+ async playMedia(channelId, media, options) {
762
+ const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
763
+ return this.client.post(
764
+ `/channels/${channelId}/play${queryParams}`,
765
+ { media }
766
+ );
767
+ }
768
+ /**
769
+ * Starts music on hold (MOH) for a channel.
770
+ */
771
+ async startMusicOnHold(channelId) {
772
+ return this.client.post(`/channels/${channelId}/moh`);
773
+ }
774
+ /**
775
+ * Stops music on hold (MOH) for a channel.
776
+ */
777
+ async stopMusicOnHold(channelId) {
778
+ return this.client.delete(`/channels/${channelId}/moh`);
779
+ }
780
+ /**
781
+ * Starts playback of a media file on a channel.
782
+ */
783
+ async startPlayback(channelId, media, options) {
784
+ const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
785
+ return this.client.post(
786
+ `/channels/${channelId}/play${queryParams}`,
787
+ { media }
788
+ );
789
+ }
790
+ /**
791
+ * Stops playback of a media file on a channel.
792
+ */
793
+ async stopPlayback(channelId, playbackId) {
794
+ return this.client.delete(
795
+ `/channels/${channelId}/play/${playbackId}`
796
+ );
797
+ }
798
+ /**
799
+ * Pauses playback of a media file on a channel.
800
+ */
801
+ async pausePlayback(channelId, playbackId) {
802
+ return this.client.post(
803
+ `/channels/${channelId}/play/${playbackId}/pause`
804
+ );
805
+ }
806
+ /**
807
+ * Resumes playback of a media file on a channel.
808
+ */
809
+ async resumePlayback(channelId, playbackId) {
810
+ return this.client.delete(
811
+ `/channels/${channelId}/play/${playbackId}/pause`
812
+ );
813
+ }
814
+ /**
815
+ * Rewinds playback of a media file on a channel.
816
+ */
817
+ async rewindPlayback(channelId, playbackId, skipMs) {
818
+ return this.client.post(
819
+ `/channels/${channelId}/play/${playbackId}/rewind`,
820
+ { skipMs }
821
+ );
822
+ }
823
+ /**
824
+ * Fast-forwards playback of a media file on a channel.
825
+ */
826
+ async fastForwardPlayback(channelId, playbackId, skipMs) {
827
+ return this.client.post(
828
+ `/channels/${channelId}/play/${playbackId}/forward`,
829
+ { skipMs }
830
+ );
831
+ }
832
+ /**
833
+ * Records audio from a channel.
834
+ */
835
+ async record(channelId, options) {
836
+ const queryParams = new URLSearchParams(
837
+ Object.entries(options).filter(
838
+ ([, value]) => value !== void 0
839
+ )
840
+ );
841
+ return this.client.post(
842
+ `/channels/${channelId}/record?${queryParams.toString()}`
843
+ );
844
+ }
845
+ /**
846
+ * Starts snooping on a channel.
847
+ */
848
+ async snoopChannel(channelId, options) {
849
+ const queryParams = toQueryParams(options);
850
+ return this.client.post(
851
+ `/channels/${channelId}/snoop?${queryParams}`
852
+ );
853
+ }
854
+ /**
855
+ * Starts snooping on a channel with a specific snoop ID.
856
+ */
857
+ async snoopChannelWithId(channelId, snoopId, options) {
858
+ const queryParams = new URLSearchParams(options);
859
+ return this.client.post(
860
+ `/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
861
+ );
862
+ }
863
+ /**
864
+ * Dials a created channel.
865
+ */
866
+ async dial(channelId, caller, timeout) {
867
+ const queryParams = new URLSearchParams({
868
+ ...caller && { caller },
869
+ ...timeout && { timeout: timeout.toString() }
870
+ });
871
+ return this.client.post(
872
+ `/channels/${channelId}/dial?${queryParams.toString()}`
873
+ );
874
+ }
875
+ /**
876
+ * Retrieves RTP statistics for a channel.
877
+ */
878
+ async getRTPStatistics(channelId) {
879
+ return this.client.get(`/channels/${channelId}/rtp_statistics`);
880
+ }
881
+ /**
882
+ * Creates a channel to an external media source/sink.
883
+ */
884
+ async createExternalMedia(options) {
885
+ const queryParams = new URLSearchParams(options);
886
+ return this.client.post(
887
+ `/channels/externalMedia?${queryParams.toString()}`
888
+ );
889
+ }
890
+ /**
891
+ * Redirects the channel to a different location.
892
+ */
893
+ async redirectChannel(channelId, endpoint) {
894
+ return this.client.post(
895
+ `/channels/${channelId}/redirect?endpoint=${encodeURIComponent(endpoint)}`
896
+ );
897
+ }
898
+ /**
899
+ * Answers a channel.
900
+ */
901
+ async answerChannel(channelId) {
902
+ return this.client.post(`/channels/${channelId}/answer`);
903
+ }
904
+ /**
905
+ * Sends a ringing indication to a channel.
906
+ */
907
+ async ringChannel(channelId) {
908
+ return this.client.post(`/channels/${channelId}/ring`);
909
+ }
910
+ /**
911
+ * Stops ringing indication on a channel.
912
+ */
913
+ async stopRingChannel(channelId) {
914
+ return this.client.delete(`/channels/${channelId}/ring`);
915
+ }
916
+ /**
917
+ * Sends DTMF to a channel.
918
+ */
919
+ async sendDTMF(channelId, dtmf, options) {
920
+ const queryParams = new URLSearchParams({
921
+ dtmf,
922
+ ...options?.before && { before: options.before.toString() },
923
+ ...options?.between && { between: options.between.toString() },
924
+ ...options?.duration && { duration: options.duration.toString() },
925
+ ...options?.after && { after: options.after.toString() }
926
+ });
927
+ return this.client.post(
928
+ `/channels/${channelId}/dtmf?${queryParams.toString()}`
929
+ );
930
+ }
931
+ /**
932
+ * Mutes a channel.
933
+ */
934
+ async muteChannel(channelId, direction = "both") {
935
+ return this.client.post(
936
+ `/channels/${channelId}/mute?direction=${direction}`
937
+ );
938
+ }
939
+ /**
940
+ * Unmutes a channel.
941
+ */
942
+ async unmuteChannel(channelId, direction = "both") {
943
+ return this.client.delete(
944
+ `/channels/${channelId}/mute?direction=${direction}`
945
+ );
946
+ }
947
+ /**
948
+ * Puts a channel on hold.
949
+ */
950
+ async holdChannel(channelId) {
951
+ return this.client.post(`/channels/${channelId}/hold`);
952
+ }
953
+ /**
954
+ * Removes a channel from hold.
955
+ */
956
+ async unholdChannel(channelId) {
957
+ return this.client.delete(`/channels/${channelId}/hold`);
958
+ }
673
959
  };
674
960
 
675
961
  // src/ari-client/resources/endpoints.ts
@@ -718,6 +1004,75 @@ var Endpoints = class {
718
1004
  }
719
1005
  };
720
1006
 
1007
+ // src/ari-client/resources/playbacks.ts
1008
+ var Playbacks = class {
1009
+ constructor(client) {
1010
+ this.client = client;
1011
+ }
1012
+ /**
1013
+ * Retrieves details of a specific playback.
1014
+ *
1015
+ * @param playbackId - The unique identifier of the playback.
1016
+ * @returns A promise that resolves to a Playback object containing the details of the specified playback.
1017
+ */
1018
+ async getDetails(playbackId) {
1019
+ return this.client.get(`/playbacks/${playbackId}`);
1020
+ }
1021
+ /**
1022
+ * Controls a specific playback (e.g., pause, resume, rewind, forward, stop).
1023
+ *
1024
+ * @param playbackId - The unique identifier of the playback to control.
1025
+ * @param controlRequest - The PlaybackControlRequest containing the control operation.
1026
+ * @returns A promise that resolves when the control operation is successfully executed.
1027
+ */
1028
+ async control(playbackId, controlRequest) {
1029
+ await this.client.post(
1030
+ `/playbacks/${playbackId}/control`,
1031
+ controlRequest
1032
+ );
1033
+ }
1034
+ /**
1035
+ * Stops a specific playback.
1036
+ *
1037
+ * @param playbackId - The unique identifier of the playback to stop.
1038
+ * @returns A promise that resolves when the playback is successfully stopped.
1039
+ */
1040
+ async stop(playbackId) {
1041
+ await this.client.post(`/playbacks/${playbackId}/stop`);
1042
+ }
1043
+ };
1044
+
1045
+ // src/ari-client/resources/sounds.ts
1046
+ var Sounds = class {
1047
+ constructor(client) {
1048
+ this.client = client;
1049
+ }
1050
+ /**
1051
+ * Lists all available sounds.
1052
+ *
1053
+ * @param params - Optional parameters to filter the list of sounds.
1054
+ * @returns A promise that resolves to an array of Sound objects.
1055
+ * @throws {Error} If the API response is not an array.
1056
+ */
1057
+ async list(params) {
1058
+ const query = params ? `?${new URLSearchParams(params).toString()}` : "";
1059
+ const sounds = await this.client.get(`/sounds${query}`);
1060
+ if (!Array.isArray(sounds)) {
1061
+ throw new Error("Resposta da API /sounds n\xE3o \xE9 um array.");
1062
+ }
1063
+ return sounds;
1064
+ }
1065
+ /**
1066
+ * Retrieves details of a specific sound.
1067
+ *
1068
+ * @param soundId - The unique identifier of the sound.
1069
+ * @returns A promise that resolves to a Sound object containing the details of the specified sound.
1070
+ */
1071
+ async getDetails(soundId) {
1072
+ return this.client.get(`/sounds/${soundId}`);
1073
+ }
1074
+ };
1075
+
721
1076
  // src/ari-client/websocketClient.ts
722
1077
  import WebSocket from "ws";
723
1078
  var WebSocketClient = class {
@@ -812,12 +1167,18 @@ var AriClient = class {
812
1167
  this.baseClient = new BaseClient(baseUrl, config.username, config.password);
813
1168
  this.channels = new Channels(this.baseClient);
814
1169
  this.endpoints = new Endpoints(this.baseClient);
1170
+ this.applications = new Applications(this.baseClient);
1171
+ this.playbacks = new Playbacks(this.baseClient);
1172
+ this.sounds = new Sounds(this.baseClient);
815
1173
  }
816
1174
  wsClient = null;
817
1175
  baseClient;
818
1176
  isReconnecting = false;
819
1177
  channels;
820
1178
  endpoints;
1179
+ applications;
1180
+ playbacks;
1181
+ sounds;
821
1182
  /**
822
1183
  * Connects to the ARI WebSocket for a specific application.
823
1184
  *
@@ -925,45 +1286,32 @@ var AriClient = class {
925
1286
  *
926
1287
  * @returns {Promise<Channel[]>} A promise resolving to the list of active channels.
927
1288
  */
1289
+ /**
1290
+ * Lists all active channels.
1291
+ */
928
1292
  async listChannels() {
929
1293
  return this.channels.list();
930
1294
  }
931
1295
  /**
932
- * Initiates a new channel on the Asterisk server.
933
- *
934
- * @param data - The parameters for creating the new channel.
935
- * @returns {Promise<Channel>} A promise resolving to the new channel's details.
1296
+ * Creates a new channel.
936
1297
  */
937
1298
  async originateChannel(data) {
938
1299
  return this.channels.originate(data);
939
1300
  }
940
1301
  /**
941
1302
  * Retrieves details of a specific channel.
942
- *
943
- * @param channelId - The unique identifier of the channel.
944
- * @returns {Promise<Channel>} A promise resolving to the details of the channel.
945
1303
  */
946
1304
  async getChannelDetails(channelId) {
947
1305
  return this.channels.getDetails(channelId);
948
1306
  }
949
1307
  /**
950
1308
  * Hangs up a specific channel.
951
- *
952
- * @param channelId - The unique identifier of the channel to hang up.
953
- * @returns {Promise<void>}
954
1309
  */
955
1310
  async hangupChannel(channelId) {
956
1311
  return this.channels.hangup(channelId);
957
1312
  }
958
1313
  /**
959
1314
  * Continues the dialplan for a specific channel.
960
- *
961
- * @param channelId - The unique identifier of the channel.
962
- * @param context - Optional. The context to continue in the dialplan.
963
- * @param extension - Optional. The extension to continue in the dialplan.
964
- * @param priority - Optional. The priority to continue in the dialplan.
965
- * @param label - Optional. The label to continue in the dialplan.
966
- * @returns {Promise<void>}
967
1315
  */
968
1316
  async continueChannelDialplan(channelId, context, extension, priority, label) {
969
1317
  return this.channels.continueDialplan(
@@ -976,15 +1324,197 @@ var AriClient = class {
976
1324
  }
977
1325
  /**
978
1326
  * Moves a channel to another Stasis application.
979
- *
980
- * @param channelId - The unique identifier of the channel.
981
- * @param app - The name of the Stasis application to move the channel to.
982
- * @param appArgs - Optional arguments for the Stasis application.
983
- * @returns {Promise<void>}
984
1327
  */
985
1328
  async moveChannelToApplication(channelId, app, appArgs) {
986
1329
  return this.channels.moveToApplication(channelId, app, appArgs);
987
1330
  }
1331
+ /**
1332
+ * Sets a channel variable.
1333
+ */
1334
+ async setChannelVariable(channelId, variable, value) {
1335
+ return this.channels.setVariable(channelId, variable, value);
1336
+ }
1337
+ /**
1338
+ * Gets a channel variable.
1339
+ */
1340
+ async getChannelVariable(channelId, variable) {
1341
+ return this.channels.getVariable(channelId, variable);
1342
+ }
1343
+ /**
1344
+ * Plays a media file to a channel.
1345
+ */
1346
+ async playMediaToChannel(channelId, media, options) {
1347
+ return this.channels.playMedia(channelId, media, options);
1348
+ }
1349
+ /**
1350
+ * Starts music on hold for a channel.
1351
+ */
1352
+ async startChannelMusicOnHold(channelId) {
1353
+ return this.channels.startMusicOnHold(channelId);
1354
+ }
1355
+ /**
1356
+ * Stops music on hold for a channel.
1357
+ */
1358
+ async stopChannelMusicOnHold(channelId) {
1359
+ return this.channels.stopMusicOnHold(channelId);
1360
+ }
1361
+ /**
1362
+ * Starts playback of a media file on a channel.
1363
+ */
1364
+ async startChannelPlayback(channelId, media, options) {
1365
+ return this.channels.startPlayback(channelId, media, options);
1366
+ }
1367
+ /**
1368
+ * Stops playback of a media file on a channel.
1369
+ */
1370
+ async stopChannelPlayback(channelId, playbackId) {
1371
+ return this.channels.stopPlayback(channelId, playbackId);
1372
+ }
1373
+ /**
1374
+ * Pauses playback of a media file on a channel.
1375
+ */
1376
+ async pauseChannelPlayback(channelId, playbackId) {
1377
+ return this.channels.pausePlayback(channelId, playbackId);
1378
+ }
1379
+ /**
1380
+ * Resumes playback of a media file on a channel.
1381
+ */
1382
+ async resumeChannelPlayback(channelId, playbackId) {
1383
+ return this.channels.resumePlayback(channelId, playbackId);
1384
+ }
1385
+ /**
1386
+ * Rewinds playback of a media file on a channel.
1387
+ */
1388
+ async rewindChannelPlayback(channelId, playbackId, skipMs) {
1389
+ return this.channels.rewindPlayback(channelId, playbackId, skipMs);
1390
+ }
1391
+ /**
1392
+ * Fast-forwards playback of a media file on a channel.
1393
+ */
1394
+ async fastForwardChannelPlayback(channelId, playbackId, skipMs) {
1395
+ return this.channels.fastForwardPlayback(channelId, playbackId, skipMs);
1396
+ }
1397
+ /**
1398
+ * Records audio from a channel.
1399
+ */
1400
+ async recordAudio(channelId, options) {
1401
+ return this.channels.record(channelId, options);
1402
+ }
1403
+ /**
1404
+ * Starts snooping on a channel.
1405
+ */
1406
+ async snoopChannel(channelId, options) {
1407
+ return this.channels.snoopChannel(channelId, options);
1408
+ }
1409
+ /**
1410
+ * Starts snooping on a channel with a specific snoop ID.
1411
+ */
1412
+ async snoopChannelWithId(channelId, snoopId, options) {
1413
+ return this.channels.snoopChannelWithId(channelId, snoopId, options);
1414
+ }
1415
+ /**
1416
+ * Dials a created channel.
1417
+ */
1418
+ async dialChannel(channelId, caller, timeout) {
1419
+ return this.channels.dial(channelId, caller, timeout);
1420
+ }
1421
+ /**
1422
+ * Retrieves RTP statistics for a channel.
1423
+ */
1424
+ async getRTPStatistics(channelId) {
1425
+ return this.channels.getRTPStatistics(channelId);
1426
+ }
1427
+ /**
1428
+ * Creates a channel to an external media source/sink.
1429
+ */
1430
+ async createExternalMedia(options) {
1431
+ return this.channels.createExternalMedia(options);
1432
+ }
1433
+ /**
1434
+ * Redirects a channel to a different location.
1435
+ */
1436
+ async redirectChannel(channelId, endpoint) {
1437
+ return this.channels.redirectChannel(channelId, endpoint);
1438
+ }
1439
+ /**
1440
+ * Answers a channel.
1441
+ */
1442
+ async answerChannel(channelId) {
1443
+ return this.channels.answerChannel(channelId);
1444
+ }
1445
+ /**
1446
+ * Sends a ringing indication to a channel.
1447
+ */
1448
+ async ringChannel(channelId) {
1449
+ return this.channels.ringChannel(channelId);
1450
+ }
1451
+ /**
1452
+ * Stops ringing indication on a channel.
1453
+ */
1454
+ async stopRingChannel(channelId) {
1455
+ return this.channels.stopRingChannel(channelId);
1456
+ }
1457
+ /**
1458
+ * Sends DTMF to a channel.
1459
+ */
1460
+ async sendDTMF(channelId, dtmf, options) {
1461
+ return this.channels.sendDTMF(channelId, dtmf, options);
1462
+ }
1463
+ /**
1464
+ * Mutes a channel.
1465
+ */
1466
+ async muteChannel(channelId, direction = "both") {
1467
+ return this.channels.muteChannel(channelId, direction);
1468
+ }
1469
+ /**
1470
+ * Unmutes a channel.
1471
+ */
1472
+ async unmuteChannel(channelId, direction = "both") {
1473
+ return this.channels.unmuteChannel(channelId, direction);
1474
+ }
1475
+ /**
1476
+ * Puts a channel on hold.
1477
+ */
1478
+ async holdChannel(channelId) {
1479
+ return this.channels.holdChannel(channelId);
1480
+ }
1481
+ /**
1482
+ * Removes a channel from hold.
1483
+ */
1484
+ async unholdChannel(channelId) {
1485
+ return this.channels.unholdChannel(channelId);
1486
+ }
1487
+ /**
1488
+ * Creates a new channel using the provided originate request data.
1489
+ *
1490
+ * @param data - The originate request data containing channel creation parameters.
1491
+ * @returns A promise that resolves to the created Channel object.
1492
+ */
1493
+ async createChannel(data) {
1494
+ return this.channels.createChannel(data);
1495
+ }
1496
+ /**
1497
+ * Hangs up a specific channel.
1498
+ *
1499
+ * @param channelId - The unique identifier of the channel to hang up.
1500
+ * @param options - Optional parameters for the hangup operation.
1501
+ * @param options.reason_code - An optional reason code for the hangup.
1502
+ * @param options.reason - An optional textual reason for the hangup.
1503
+ * @returns A promise that resolves when the hangup operation is complete.
1504
+ */
1505
+ async hangup(channelId, options) {
1506
+ return this.channels.hangup(channelId, options);
1507
+ }
1508
+ /**
1509
+ * Originates a new channel with a specified ID using the provided originate request data.
1510
+ *
1511
+ * @param channelId - The desired unique identifier for the new channel.
1512
+ * @param data - The originate request data containing channel creation parameters.
1513
+ * @returns A promise that resolves to the created Channel object.
1514
+ */
1515
+ async originateWithId(channelId, data) {
1516
+ return this.channels.originateWithId(channelId, data);
1517
+ }
988
1518
  // Métodos relacionados a endpoints:
989
1519
  /**
990
1520
  * Lists all endpoints.
@@ -1015,9 +1545,88 @@ var AriClient = class {
1015
1545
  async sendMessageToEndpoint(technology, resource, body) {
1016
1546
  return this.endpoints.sendMessage(technology, resource, body);
1017
1547
  }
1548
+ // Métodos relacionados a applications
1549
+ /**
1550
+ * Lists all applications.
1551
+ *
1552
+ * @returns {Promise<Application[]>} A promise resolving to the list of applications.
1553
+ */
1554
+ async listApplications() {
1555
+ return this.applications.list();
1556
+ }
1557
+ /**
1558
+ * Retrieves details of a specific application.
1559
+ *
1560
+ * @param appName - The name of the application.
1561
+ * @returns {Promise<ApplicationDetails>} A promise resolving to the application details.
1562
+ */
1563
+ async getApplicationDetails(appName) {
1564
+ return this.applications.getDetails(appName);
1565
+ }
1566
+ /**
1567
+ * Sends a message to a specific application.
1568
+ *
1569
+ * @param appName - The name of the application.
1570
+ * @param body - The message body to send.
1571
+ * @returns {Promise<void>} A promise resolving when the message is sent successfully.
1572
+ */
1573
+ async sendMessageToApplication(appName, body) {
1574
+ return this.applications.sendMessage(appName, body);
1575
+ }
1576
+ // Métodos relacionados a playbacks
1577
+ /**
1578
+ * Retrieves details of a specific playback.
1579
+ *
1580
+ * @param playbackId - The unique identifier of the playback.
1581
+ * @returns {Promise<Playback>} A promise resolving to the playback details.
1582
+ */
1583
+ async getPlaybackDetails(playbackId) {
1584
+ return this.playbacks.getDetails(playbackId);
1585
+ }
1586
+ /**
1587
+ * Controls a specific playback.
1588
+ *
1589
+ * @param playbackId - The unique identifier of the playback.
1590
+ * @param controlRequest - The PlaybackControlRequest containing the control operation.
1591
+ * @returns {Promise<void>} A promise resolving when the control operation is successfully executed.
1592
+ */
1593
+ async controlPlayback(playbackId, controlRequest) {
1594
+ return this.playbacks.control(playbackId, controlRequest);
1595
+ }
1596
+ /**
1597
+ * Stops a specific playback.
1598
+ *
1599
+ * @param playbackId - The unique identifier of the playback.
1600
+ * @returns {Promise<void>} A promise resolving when the playback is successfully stopped.
1601
+ */
1602
+ async stopPlayback(playbackId) {
1603
+ return this.playbacks.stop(playbackId);
1604
+ }
1605
+ /**
1606
+ * Lists all available sounds.
1607
+ *
1608
+ * @param params - Optional parameters to filter the list of sounds.
1609
+ * @returns {Promise<Sound[]>} A promise resolving to the list of sounds.
1610
+ */
1611
+ async listSounds(params) {
1612
+ return this.sounds.list(params);
1613
+ }
1614
+ /**
1615
+ * Retrieves details of a specific sound.
1616
+ *
1617
+ * @param soundId - The unique identifier of the sound.
1618
+ * @returns {Promise<Sound>} A promise resolving to the sound details.
1619
+ */
1620
+ async getSoundDetails(soundId) {
1621
+ return this.sounds.getDetails(soundId);
1622
+ }
1018
1623
  };
1019
1624
  export {
1625
+ Applications,
1020
1626
  AriClient,
1021
- Channels
1627
+ Channels,
1628
+ Endpoints,
1629
+ Playbacks,
1630
+ Sounds
1022
1631
  };
1023
1632
  //# sourceMappingURL=index.js.map