@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.
- package/dist/cjs/index.cjs +705 -50
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/esm/index.js +700 -49
- package/dist/esm/index.js.map +4 -4
- package/dist/types/ari-client/ariClient.d.ts +218 -23
- package/dist/types/ari-client/ariClient.d.ts.map +1 -1
- package/dist/types/ari-client/baseClient.d.ts +20 -0
- package/dist/types/ari-client/baseClient.d.ts.map +1 -1
- package/dist/types/ari-client/interfaces/asterisk.types.d.ts +39 -0
- package/dist/types/ari-client/interfaces/asterisk.types.d.ts.map +1 -0
- package/dist/types/ari-client/interfaces/channels.types.d.ts +54 -5
- package/dist/types/ari-client/interfaces/channels.types.d.ts.map +1 -1
- package/dist/types/ari-client/interfaces/index.d.ts +8 -0
- package/dist/types/ari-client/interfaces/index.d.ts.map +1 -0
- package/dist/types/ari-client/interfaces/playbacks.types.d.ts +11 -0
- package/dist/types/ari-client/interfaces/playbacks.types.d.ts.map +1 -0
- package/dist/types/ari-client/interfaces/sounds.types.d.ts +11 -0
- package/dist/types/ari-client/interfaces/sounds.types.d.ts.map +1 -0
- package/dist/types/ari-client/resources/asterisk.d.ts +37 -0
- package/dist/types/ari-client/resources/asterisk.d.ts.map +1 -1
- package/dist/types/ari-client/resources/channels.d.ts +125 -26
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/resources/playbacks.d.ts +28 -0
- package/dist/types/ari-client/resources/playbacks.d.ts.map +1 -1
- package/dist/types/ari-client/resources/sounds.d.ts +21 -0
- package/dist/types/ari-client/resources/sounds.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -583,14 +583,40 @@ 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
|
+
}
|
|
594
620
|
};
|
|
595
621
|
|
|
596
622
|
// src/ari-client/resources/applications.ts
|
|
@@ -632,16 +658,82 @@ var Applications = class {
|
|
|
632
658
|
}
|
|
633
659
|
};
|
|
634
660
|
|
|
661
|
+
// src/ari-client/resources/asterisk.ts
|
|
662
|
+
function toQueryParams(options) {
|
|
663
|
+
return new URLSearchParams(
|
|
664
|
+
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
665
|
+
).toString();
|
|
666
|
+
}
|
|
667
|
+
var Asterisk = class {
|
|
668
|
+
constructor(client) {
|
|
669
|
+
this.client = client;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Retrieves information about the Asterisk server.
|
|
673
|
+
*/
|
|
674
|
+
async getInfo() {
|
|
675
|
+
return this.client.get("/asterisk/info");
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Lists all loaded modules in the Asterisk server.
|
|
679
|
+
*/
|
|
680
|
+
async listModules() {
|
|
681
|
+
return this.client.get("/asterisk/modules");
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Manages a specific module in the Asterisk server.
|
|
685
|
+
*/
|
|
686
|
+
async manageModule(moduleName, action) {
|
|
687
|
+
return this.client.post(
|
|
688
|
+
`/asterisk/modules/${moduleName}?action=${encodeURIComponent(action)}`
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Retrieves all configured logging channels.
|
|
693
|
+
*/
|
|
694
|
+
async listLoggingChannels() {
|
|
695
|
+
return this.client.get("/asterisk/logging");
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Adds or removes a log channel in the Asterisk server.
|
|
699
|
+
*/
|
|
700
|
+
async manageLogChannel(logChannelName, action, configuration) {
|
|
701
|
+
const queryParams = toQueryParams(configuration || {});
|
|
702
|
+
return this.client.post(
|
|
703
|
+
`/asterisk/logging/${logChannelName}?action=${encodeURIComponent(action)}&${queryParams}`
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Retrieves the value of a global variable.
|
|
708
|
+
*/
|
|
709
|
+
async getGlobalVariable(variableName) {
|
|
710
|
+
return this.client.get(
|
|
711
|
+
`/asterisk/variables?variable=${encodeURIComponent(variableName)}`
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Sets a global variable.
|
|
716
|
+
*/
|
|
717
|
+
async setGlobalVariable(variableName, value) {
|
|
718
|
+
return this.client.post(
|
|
719
|
+
`/asterisk/variables?variable=${encodeURIComponent(variableName)}&value=${encodeURIComponent(value)}`
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
|
|
635
724
|
// src/ari-client/resources/channels.ts
|
|
725
|
+
function toQueryParams2(options) {
|
|
726
|
+
return new URLSearchParams(
|
|
727
|
+
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
|
|
728
|
+
// Garante que value é string
|
|
729
|
+
).toString();
|
|
730
|
+
}
|
|
636
731
|
var Channels = class {
|
|
637
732
|
constructor(client) {
|
|
638
733
|
this.client = client;
|
|
639
734
|
}
|
|
640
735
|
/**
|
|
641
736
|
* Lists all active channels.
|
|
642
|
-
*
|
|
643
|
-
* @returns A promise that resolves to an array of Channel objects representing all active channels.
|
|
644
|
-
* @throws {Error} If the API response is not an array.
|
|
645
737
|
*/
|
|
646
738
|
async list() {
|
|
647
739
|
const channels = await this.client.get("/channels");
|
|
@@ -652,40 +744,45 @@ var Channels = class {
|
|
|
652
744
|
}
|
|
653
745
|
/**
|
|
654
746
|
* Creates a new channel.
|
|
655
|
-
*
|
|
656
|
-
* @param data - The OriginateRequest object containing the necessary data to create a new channel.
|
|
657
|
-
* @returns A promise that resolves to a Channel object representing the newly created channel.
|
|
658
747
|
*/
|
|
659
748
|
async originate(data) {
|
|
660
749
|
return this.client.post("/channels", data);
|
|
661
750
|
}
|
|
662
751
|
/**
|
|
663
752
|
* Retrieves details of a specific channel.
|
|
664
|
-
*
|
|
665
|
-
* @param channelId - The unique identifier of the channel.
|
|
666
|
-
* @returns A promise that resolves to a Channel object containing the details of the specified channel.
|
|
667
753
|
*/
|
|
668
754
|
async getDetails(channelId) {
|
|
669
755
|
return this.client.get(`/channels/${channelId}`);
|
|
670
756
|
}
|
|
757
|
+
/**
|
|
758
|
+
* Creates a channel and places it in a Stasis app without dialing it.
|
|
759
|
+
*/
|
|
760
|
+
async createChannel(data) {
|
|
761
|
+
return this.client.post("/channels/create", data);
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Creates a new channel with a specific ID and originates a call.
|
|
765
|
+
*/
|
|
766
|
+
async originateWithId(channelId, data) {
|
|
767
|
+
return this.client.post(`/channels/${channelId}`, data);
|
|
768
|
+
}
|
|
671
769
|
/**
|
|
672
770
|
* Hangs up (terminates) a specific channel.
|
|
673
|
-
*
|
|
674
|
-
* @param channelId - The unique identifier of the channel to be hung up.
|
|
675
|
-
* @returns A promise that resolves when the channel has been successfully hung up.
|
|
676
771
|
*/
|
|
677
|
-
|
|
678
|
-
|
|
772
|
+
/**
|
|
773
|
+
* Hangs up a specific channel with optional reason or reason code.
|
|
774
|
+
*/
|
|
775
|
+
async hangup(channelId, options) {
|
|
776
|
+
const queryParams = new URLSearchParams({
|
|
777
|
+
...options?.reason_code && { reason_code: options.reason_code },
|
|
778
|
+
...options?.reason && { reason: options.reason }
|
|
779
|
+
});
|
|
780
|
+
return this.client.delete(
|
|
781
|
+
`/channels/${channelId}?${queryParams.toString()}`
|
|
782
|
+
);
|
|
679
783
|
}
|
|
680
784
|
/**
|
|
681
785
|
* Continues the dialplan for a specific channel.
|
|
682
|
-
*
|
|
683
|
-
* @param channelId - The unique identifier of the channel.
|
|
684
|
-
* @param context - Optional. The context to continue in the dialplan.
|
|
685
|
-
* @param extension - Optional. The extension to continue in the dialplan.
|
|
686
|
-
* @param priority - Optional. The priority to continue in the dialplan.
|
|
687
|
-
* @param label - Optional. The label to continue in the dialplan.
|
|
688
|
-
* @returns A promise that resolves when the dialplan continuation has been successfully initiated.
|
|
689
786
|
*/
|
|
690
787
|
async continueDialplan(channelId, context, extension, priority, label) {
|
|
691
788
|
return this.client.post(`/channels/${channelId}/continue`, {
|
|
@@ -697,11 +794,6 @@ var Channels = class {
|
|
|
697
794
|
}
|
|
698
795
|
/**
|
|
699
796
|
* Moves the channel to another Stasis application.
|
|
700
|
-
*
|
|
701
|
-
* @param channelId - The unique identifier of the channel to be moved.
|
|
702
|
-
* @param app - The name of the Stasis application to move the channel to.
|
|
703
|
-
* @param appArgs - Optional. Arguments to be passed to the Stasis application.
|
|
704
|
-
* @returns A promise that resolves when the channel has been successfully moved to the new application.
|
|
705
797
|
*/
|
|
706
798
|
async moveToApplication(channelId, app, appArgs) {
|
|
707
799
|
return this.client.post(`/channels/${channelId}/move`, {
|
|
@@ -709,6 +801,224 @@ var Channels = class {
|
|
|
709
801
|
appArgs
|
|
710
802
|
});
|
|
711
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Sets a channel variable.
|
|
806
|
+
*/
|
|
807
|
+
async setVariable(channelId, variable, value) {
|
|
808
|
+
return this.client.post(`/channels/${channelId}/variable`, {
|
|
809
|
+
variable,
|
|
810
|
+
value
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Gets a channel variable.
|
|
815
|
+
*/
|
|
816
|
+
async getVariable(channelId, variable) {
|
|
817
|
+
return this.client.get(
|
|
818
|
+
`/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Plays a media file to a channel.
|
|
823
|
+
*/
|
|
824
|
+
async playMedia(channelId, media, options) {
|
|
825
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
826
|
+
return this.client.post(
|
|
827
|
+
`/channels/${channelId}/play${queryParams}`,
|
|
828
|
+
{ media }
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Starts music on hold (MOH) for a channel.
|
|
833
|
+
*/
|
|
834
|
+
async startMusicOnHold(channelId) {
|
|
835
|
+
return this.client.post(`/channels/${channelId}/moh`);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Stops music on hold (MOH) for a channel.
|
|
839
|
+
*/
|
|
840
|
+
async stopMusicOnHold(channelId) {
|
|
841
|
+
return this.client.delete(`/channels/${channelId}/moh`);
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Starts playback of a media file on a channel.
|
|
845
|
+
*/
|
|
846
|
+
async startPlayback(channelId, media, options) {
|
|
847
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
848
|
+
return this.client.post(
|
|
849
|
+
`/channels/${channelId}/play${queryParams}`,
|
|
850
|
+
{ media }
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Stops playback of a media file on a channel.
|
|
855
|
+
*/
|
|
856
|
+
async stopPlayback(channelId, playbackId) {
|
|
857
|
+
return this.client.delete(
|
|
858
|
+
`/channels/${channelId}/play/${playbackId}`
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Pauses playback of a media file on a channel.
|
|
863
|
+
*/
|
|
864
|
+
async pausePlayback(channelId, playbackId) {
|
|
865
|
+
return this.client.post(
|
|
866
|
+
`/channels/${channelId}/play/${playbackId}/pause`
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Resumes playback of a media file on a channel.
|
|
871
|
+
*/
|
|
872
|
+
async resumePlayback(channelId, playbackId) {
|
|
873
|
+
return this.client.delete(
|
|
874
|
+
`/channels/${channelId}/play/${playbackId}/pause`
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Rewinds playback of a media file on a channel.
|
|
879
|
+
*/
|
|
880
|
+
async rewindPlayback(channelId, playbackId, skipMs) {
|
|
881
|
+
return this.client.post(
|
|
882
|
+
`/channels/${channelId}/play/${playbackId}/rewind`,
|
|
883
|
+
{ skipMs }
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Fast-forwards playback of a media file on a channel.
|
|
888
|
+
*/
|
|
889
|
+
async fastForwardPlayback(channelId, playbackId, skipMs) {
|
|
890
|
+
return this.client.post(
|
|
891
|
+
`/channels/${channelId}/play/${playbackId}/forward`,
|
|
892
|
+
{ skipMs }
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Records audio from a channel.
|
|
897
|
+
*/
|
|
898
|
+
async record(channelId, options) {
|
|
899
|
+
const queryParams = new URLSearchParams(
|
|
900
|
+
Object.entries(options).filter(
|
|
901
|
+
([, value]) => value !== void 0
|
|
902
|
+
)
|
|
903
|
+
);
|
|
904
|
+
return this.client.post(
|
|
905
|
+
`/channels/${channelId}/record?${queryParams.toString()}`
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Starts snooping on a channel.
|
|
910
|
+
*/
|
|
911
|
+
async snoopChannel(channelId, options) {
|
|
912
|
+
const queryParams = toQueryParams2(options);
|
|
913
|
+
return this.client.post(
|
|
914
|
+
`/channels/${channelId}/snoop?${queryParams}`
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Starts snooping on a channel with a specific snoop ID.
|
|
919
|
+
*/
|
|
920
|
+
async snoopChannelWithId(channelId, snoopId, options) {
|
|
921
|
+
const queryParams = new URLSearchParams(options);
|
|
922
|
+
return this.client.post(
|
|
923
|
+
`/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Dials a created channel.
|
|
928
|
+
*/
|
|
929
|
+
async dial(channelId, caller, timeout) {
|
|
930
|
+
const queryParams = new URLSearchParams({
|
|
931
|
+
...caller && { caller },
|
|
932
|
+
...timeout && { timeout: timeout.toString() }
|
|
933
|
+
});
|
|
934
|
+
return this.client.post(
|
|
935
|
+
`/channels/${channelId}/dial?${queryParams.toString()}`
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Retrieves RTP statistics for a channel.
|
|
940
|
+
*/
|
|
941
|
+
async getRTPStatistics(channelId) {
|
|
942
|
+
return this.client.get(`/channels/${channelId}/rtp_statistics`);
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Creates a channel to an external media source/sink.
|
|
946
|
+
*/
|
|
947
|
+
async createExternalMedia(options) {
|
|
948
|
+
const queryParams = new URLSearchParams(options);
|
|
949
|
+
return this.client.post(
|
|
950
|
+
`/channels/externalMedia?${queryParams.toString()}`
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Redirects the channel to a different location.
|
|
955
|
+
*/
|
|
956
|
+
async redirectChannel(channelId, endpoint) {
|
|
957
|
+
return this.client.post(
|
|
958
|
+
`/channels/${channelId}/redirect?endpoint=${encodeURIComponent(endpoint)}`
|
|
959
|
+
);
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Answers a channel.
|
|
963
|
+
*/
|
|
964
|
+
async answerChannel(channelId) {
|
|
965
|
+
return this.client.post(`/channels/${channelId}/answer`);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Sends a ringing indication to a channel.
|
|
969
|
+
*/
|
|
970
|
+
async ringChannel(channelId) {
|
|
971
|
+
return this.client.post(`/channels/${channelId}/ring`);
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Stops ringing indication on a channel.
|
|
975
|
+
*/
|
|
976
|
+
async stopRingChannel(channelId) {
|
|
977
|
+
return this.client.delete(`/channels/${channelId}/ring`);
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Sends DTMF to a channel.
|
|
981
|
+
*/
|
|
982
|
+
async sendDTMF(channelId, dtmf, options) {
|
|
983
|
+
const queryParams = new URLSearchParams({
|
|
984
|
+
dtmf,
|
|
985
|
+
...options?.before && { before: options.before.toString() },
|
|
986
|
+
...options?.between && { between: options.between.toString() },
|
|
987
|
+
...options?.duration && { duration: options.duration.toString() },
|
|
988
|
+
...options?.after && { after: options.after.toString() }
|
|
989
|
+
});
|
|
990
|
+
return this.client.post(
|
|
991
|
+
`/channels/${channelId}/dtmf?${queryParams.toString()}`
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Mutes a channel.
|
|
996
|
+
*/
|
|
997
|
+
async muteChannel(channelId, direction = "both") {
|
|
998
|
+
return this.client.post(
|
|
999
|
+
`/channels/${channelId}/mute?direction=${direction}`
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Unmutes a channel.
|
|
1004
|
+
*/
|
|
1005
|
+
async unmuteChannel(channelId, direction = "both") {
|
|
1006
|
+
return this.client.delete(
|
|
1007
|
+
`/channels/${channelId}/mute?direction=${direction}`
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Puts a channel on hold.
|
|
1012
|
+
*/
|
|
1013
|
+
async holdChannel(channelId) {
|
|
1014
|
+
return this.client.post(`/channels/${channelId}/hold`);
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Removes a channel from hold.
|
|
1018
|
+
*/
|
|
1019
|
+
async unholdChannel(channelId) {
|
|
1020
|
+
return this.client.delete(`/channels/${channelId}/hold`);
|
|
1021
|
+
}
|
|
712
1022
|
};
|
|
713
1023
|
|
|
714
1024
|
// src/ari-client/resources/endpoints.ts
|
|
@@ -757,6 +1067,75 @@ var Endpoints = class {
|
|
|
757
1067
|
}
|
|
758
1068
|
};
|
|
759
1069
|
|
|
1070
|
+
// src/ari-client/resources/playbacks.ts
|
|
1071
|
+
var Playbacks = class {
|
|
1072
|
+
constructor(client) {
|
|
1073
|
+
this.client = client;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Retrieves details of a specific playback.
|
|
1077
|
+
*
|
|
1078
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1079
|
+
* @returns A promise that resolves to a Playback object containing the details of the specified playback.
|
|
1080
|
+
*/
|
|
1081
|
+
async getDetails(playbackId) {
|
|
1082
|
+
return this.client.get(`/playbacks/${playbackId}`);
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Controls a specific playback (e.g., pause, resume, rewind, forward, stop).
|
|
1086
|
+
*
|
|
1087
|
+
* @param playbackId - The unique identifier of the playback to control.
|
|
1088
|
+
* @param controlRequest - The PlaybackControlRequest containing the control operation.
|
|
1089
|
+
* @returns A promise that resolves when the control operation is successfully executed.
|
|
1090
|
+
*/
|
|
1091
|
+
async control(playbackId, controlRequest) {
|
|
1092
|
+
await this.client.post(
|
|
1093
|
+
`/playbacks/${playbackId}/control`,
|
|
1094
|
+
controlRequest
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Stops a specific playback.
|
|
1099
|
+
*
|
|
1100
|
+
* @param playbackId - The unique identifier of the playback to stop.
|
|
1101
|
+
* @returns A promise that resolves when the playback is successfully stopped.
|
|
1102
|
+
*/
|
|
1103
|
+
async stop(playbackId) {
|
|
1104
|
+
await this.client.post(`/playbacks/${playbackId}/stop`);
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
// src/ari-client/resources/sounds.ts
|
|
1109
|
+
var Sounds = class {
|
|
1110
|
+
constructor(client) {
|
|
1111
|
+
this.client = client;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Lists all available sounds.
|
|
1115
|
+
*
|
|
1116
|
+
* @param params - Optional parameters to filter the list of sounds.
|
|
1117
|
+
* @returns A promise that resolves to an array of Sound objects.
|
|
1118
|
+
* @throws {Error} If the API response is not an array.
|
|
1119
|
+
*/
|
|
1120
|
+
async list(params) {
|
|
1121
|
+
const query = params ? `?${new URLSearchParams(params).toString()}` : "";
|
|
1122
|
+
const sounds = await this.client.get(`/sounds${query}`);
|
|
1123
|
+
if (!Array.isArray(sounds)) {
|
|
1124
|
+
throw new Error("Resposta da API /sounds n\xE3o \xE9 um array.");
|
|
1125
|
+
}
|
|
1126
|
+
return sounds;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Retrieves details of a specific sound.
|
|
1130
|
+
*
|
|
1131
|
+
* @param soundId - The unique identifier of the sound.
|
|
1132
|
+
* @returns A promise that resolves to a Sound object containing the details of the specified sound.
|
|
1133
|
+
*/
|
|
1134
|
+
async getDetails(soundId) {
|
|
1135
|
+
return this.client.get(`/sounds/${soundId}`);
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
|
|
760
1139
|
// src/ari-client/websocketClient.ts
|
|
761
1140
|
import WebSocket from "ws";
|
|
762
1141
|
var WebSocketClient = class {
|
|
@@ -852,6 +1231,9 @@ var AriClient = class {
|
|
|
852
1231
|
this.channels = new Channels(this.baseClient);
|
|
853
1232
|
this.endpoints = new Endpoints(this.baseClient);
|
|
854
1233
|
this.applications = new Applications(this.baseClient);
|
|
1234
|
+
this.playbacks = new Playbacks(this.baseClient);
|
|
1235
|
+
this.sounds = new Sounds(this.baseClient);
|
|
1236
|
+
this.asterisk = new Asterisk(this.baseClient);
|
|
855
1237
|
}
|
|
856
1238
|
wsClient = null;
|
|
857
1239
|
baseClient;
|
|
@@ -859,6 +1241,9 @@ var AriClient = class {
|
|
|
859
1241
|
channels;
|
|
860
1242
|
endpoints;
|
|
861
1243
|
applications;
|
|
1244
|
+
playbacks;
|
|
1245
|
+
sounds;
|
|
1246
|
+
asterisk;
|
|
862
1247
|
/**
|
|
863
1248
|
* Connects to the ARI WebSocket for a specific application.
|
|
864
1249
|
*
|
|
@@ -966,45 +1351,32 @@ var AriClient = class {
|
|
|
966
1351
|
*
|
|
967
1352
|
* @returns {Promise<Channel[]>} A promise resolving to the list of active channels.
|
|
968
1353
|
*/
|
|
1354
|
+
/**
|
|
1355
|
+
* Lists all active channels.
|
|
1356
|
+
*/
|
|
969
1357
|
async listChannels() {
|
|
970
1358
|
return this.channels.list();
|
|
971
1359
|
}
|
|
972
1360
|
/**
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
* @param data - The parameters for creating the new channel.
|
|
976
|
-
* @returns {Promise<Channel>} A promise resolving to the new channel's details.
|
|
1361
|
+
* Creates a new channel.
|
|
977
1362
|
*/
|
|
978
1363
|
async originateChannel(data) {
|
|
979
1364
|
return this.channels.originate(data);
|
|
980
1365
|
}
|
|
981
1366
|
/**
|
|
982
1367
|
* Retrieves details of a specific channel.
|
|
983
|
-
*
|
|
984
|
-
* @param channelId - The unique identifier of the channel.
|
|
985
|
-
* @returns {Promise<Channel>} A promise resolving to the details of the channel.
|
|
986
1368
|
*/
|
|
987
1369
|
async getChannelDetails(channelId) {
|
|
988
1370
|
return this.channels.getDetails(channelId);
|
|
989
1371
|
}
|
|
990
1372
|
/**
|
|
991
1373
|
* Hangs up a specific channel.
|
|
992
|
-
*
|
|
993
|
-
* @param channelId - The unique identifier of the channel to hang up.
|
|
994
|
-
* @returns {Promise<void>}
|
|
995
1374
|
*/
|
|
996
1375
|
async hangupChannel(channelId) {
|
|
997
1376
|
return this.channels.hangup(channelId);
|
|
998
1377
|
}
|
|
999
1378
|
/**
|
|
1000
1379
|
* Continues the dialplan for a specific channel.
|
|
1001
|
-
*
|
|
1002
|
-
* @param channelId - The unique identifier of the channel.
|
|
1003
|
-
* @param context - Optional. The context to continue in the dialplan.
|
|
1004
|
-
* @param extension - Optional. The extension to continue in the dialplan.
|
|
1005
|
-
* @param priority - Optional. The priority to continue in the dialplan.
|
|
1006
|
-
* @param label - Optional. The label to continue in the dialplan.
|
|
1007
|
-
* @returns {Promise<void>}
|
|
1008
1380
|
*/
|
|
1009
1381
|
async continueChannelDialplan(channelId, context, extension, priority, label) {
|
|
1010
1382
|
return this.channels.continueDialplan(
|
|
@@ -1017,15 +1389,197 @@ var AriClient = class {
|
|
|
1017
1389
|
}
|
|
1018
1390
|
/**
|
|
1019
1391
|
* Moves a channel to another Stasis application.
|
|
1020
|
-
*
|
|
1021
|
-
* @param channelId - The unique identifier of the channel.
|
|
1022
|
-
* @param app - The name of the Stasis application to move the channel to.
|
|
1023
|
-
* @param appArgs - Optional arguments for the Stasis application.
|
|
1024
|
-
* @returns {Promise<void>}
|
|
1025
1392
|
*/
|
|
1026
1393
|
async moveChannelToApplication(channelId, app, appArgs) {
|
|
1027
1394
|
return this.channels.moveToApplication(channelId, app, appArgs);
|
|
1028
1395
|
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Sets a channel variable.
|
|
1398
|
+
*/
|
|
1399
|
+
async setChannelVariable(channelId, variable, value) {
|
|
1400
|
+
return this.channels.setVariable(channelId, variable, value);
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Gets a channel variable.
|
|
1404
|
+
*/
|
|
1405
|
+
async getChannelVariable(channelId, variable) {
|
|
1406
|
+
return this.channels.getVariable(channelId, variable);
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Plays a media file to a channel.
|
|
1410
|
+
*/
|
|
1411
|
+
async playMediaToChannel(channelId, media, options) {
|
|
1412
|
+
return this.channels.playMedia(channelId, media, options);
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Starts music on hold for a channel.
|
|
1416
|
+
*/
|
|
1417
|
+
async startChannelMusicOnHold(channelId) {
|
|
1418
|
+
return this.channels.startMusicOnHold(channelId);
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Stops music on hold for a channel.
|
|
1422
|
+
*/
|
|
1423
|
+
async stopChannelMusicOnHold(channelId) {
|
|
1424
|
+
return this.channels.stopMusicOnHold(channelId);
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Starts playback of a media file on a channel.
|
|
1428
|
+
*/
|
|
1429
|
+
async startChannelPlayback(channelId, media, options) {
|
|
1430
|
+
return this.channels.startPlayback(channelId, media, options);
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Stops playback of a media file on a channel.
|
|
1434
|
+
*/
|
|
1435
|
+
async stopChannelPlayback(channelId, playbackId) {
|
|
1436
|
+
return this.channels.stopPlayback(channelId, playbackId);
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Pauses playback of a media file on a channel.
|
|
1440
|
+
*/
|
|
1441
|
+
async pauseChannelPlayback(channelId, playbackId) {
|
|
1442
|
+
return this.channels.pausePlayback(channelId, playbackId);
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Resumes playback of a media file on a channel.
|
|
1446
|
+
*/
|
|
1447
|
+
async resumeChannelPlayback(channelId, playbackId) {
|
|
1448
|
+
return this.channels.resumePlayback(channelId, playbackId);
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Rewinds playback of a media file on a channel.
|
|
1452
|
+
*/
|
|
1453
|
+
async rewindChannelPlayback(channelId, playbackId, skipMs) {
|
|
1454
|
+
return this.channels.rewindPlayback(channelId, playbackId, skipMs);
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Fast-forwards playback of a media file on a channel.
|
|
1458
|
+
*/
|
|
1459
|
+
async fastForwardChannelPlayback(channelId, playbackId, skipMs) {
|
|
1460
|
+
return this.channels.fastForwardPlayback(channelId, playbackId, skipMs);
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Records audio from a channel.
|
|
1464
|
+
*/
|
|
1465
|
+
async recordAudio(channelId, options) {
|
|
1466
|
+
return this.channels.record(channelId, options);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Starts snooping on a channel.
|
|
1470
|
+
*/
|
|
1471
|
+
async snoopChannel(channelId, options) {
|
|
1472
|
+
return this.channels.snoopChannel(channelId, options);
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Starts snooping on a channel with a specific snoop ID.
|
|
1476
|
+
*/
|
|
1477
|
+
async snoopChannelWithId(channelId, snoopId, options) {
|
|
1478
|
+
return this.channels.snoopChannelWithId(channelId, snoopId, options);
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Dials a created channel.
|
|
1482
|
+
*/
|
|
1483
|
+
async dialChannel(channelId, caller, timeout) {
|
|
1484
|
+
return this.channels.dial(channelId, caller, timeout);
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Retrieves RTP statistics for a channel.
|
|
1488
|
+
*/
|
|
1489
|
+
async getRTPStatistics(channelId) {
|
|
1490
|
+
return this.channels.getRTPStatistics(channelId);
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Creates a channel to an external media source/sink.
|
|
1494
|
+
*/
|
|
1495
|
+
async createExternalMedia(options) {
|
|
1496
|
+
return this.channels.createExternalMedia(options);
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Redirects a channel to a different location.
|
|
1500
|
+
*/
|
|
1501
|
+
async redirectChannel(channelId, endpoint) {
|
|
1502
|
+
return this.channels.redirectChannel(channelId, endpoint);
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Answers a channel.
|
|
1506
|
+
*/
|
|
1507
|
+
async answerChannel(channelId) {
|
|
1508
|
+
return this.channels.answerChannel(channelId);
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Sends a ringing indication to a channel.
|
|
1512
|
+
*/
|
|
1513
|
+
async ringChannel(channelId) {
|
|
1514
|
+
return this.channels.ringChannel(channelId);
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Stops ringing indication on a channel.
|
|
1518
|
+
*/
|
|
1519
|
+
async stopRingChannel(channelId) {
|
|
1520
|
+
return this.channels.stopRingChannel(channelId);
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Sends DTMF to a channel.
|
|
1524
|
+
*/
|
|
1525
|
+
async sendDTMF(channelId, dtmf, options) {
|
|
1526
|
+
return this.channels.sendDTMF(channelId, dtmf, options);
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Mutes a channel.
|
|
1530
|
+
*/
|
|
1531
|
+
async muteChannel(channelId, direction = "both") {
|
|
1532
|
+
return this.channels.muteChannel(channelId, direction);
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Unmutes a channel.
|
|
1536
|
+
*/
|
|
1537
|
+
async unmuteChannel(channelId, direction = "both") {
|
|
1538
|
+
return this.channels.unmuteChannel(channelId, direction);
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Puts a channel on hold.
|
|
1542
|
+
*/
|
|
1543
|
+
async holdChannel(channelId) {
|
|
1544
|
+
return this.channels.holdChannel(channelId);
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Removes a channel from hold.
|
|
1548
|
+
*/
|
|
1549
|
+
async unholdChannel(channelId) {
|
|
1550
|
+
return this.channels.unholdChannel(channelId);
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Creates a new channel using the provided originate request data.
|
|
1554
|
+
*
|
|
1555
|
+
* @param data - The originate request data containing channel creation parameters.
|
|
1556
|
+
* @returns A promise that resolves to the created Channel object.
|
|
1557
|
+
*/
|
|
1558
|
+
async createChannel(data) {
|
|
1559
|
+
return this.channels.createChannel(data);
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Hangs up a specific channel.
|
|
1563
|
+
*
|
|
1564
|
+
* @param channelId - The unique identifier of the channel to hang up.
|
|
1565
|
+
* @param options - Optional parameters for the hangup operation.
|
|
1566
|
+
* @param options.reason_code - An optional reason code for the hangup.
|
|
1567
|
+
* @param options.reason - An optional textual reason for the hangup.
|
|
1568
|
+
* @returns A promise that resolves when the hangup operation is complete.
|
|
1569
|
+
*/
|
|
1570
|
+
async hangup(channelId, options) {
|
|
1571
|
+
return this.channels.hangup(channelId, options);
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Originates a new channel with a specified ID using the provided originate request data.
|
|
1575
|
+
*
|
|
1576
|
+
* @param channelId - The desired unique identifier for the new channel.
|
|
1577
|
+
* @param data - The originate request data containing channel creation parameters.
|
|
1578
|
+
* @returns A promise that resolves to the created Channel object.
|
|
1579
|
+
*/
|
|
1580
|
+
async originateWithId(channelId, data) {
|
|
1581
|
+
return this.channels.originateWithId(channelId, data);
|
|
1582
|
+
}
|
|
1029
1583
|
// Métodos relacionados a endpoints:
|
|
1030
1584
|
/**
|
|
1031
1585
|
* Lists all endpoints.
|
|
@@ -1084,9 +1638,106 @@ var AriClient = class {
|
|
|
1084
1638
|
async sendMessageToApplication(appName, body) {
|
|
1085
1639
|
return this.applications.sendMessage(appName, body);
|
|
1086
1640
|
}
|
|
1641
|
+
// Métodos relacionados a playbacks
|
|
1642
|
+
/**
|
|
1643
|
+
* Retrieves details of a specific playback.
|
|
1644
|
+
*
|
|
1645
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1646
|
+
* @returns {Promise<Playback>} A promise resolving to the playback details.
|
|
1647
|
+
*/
|
|
1648
|
+
async getPlaybackDetails(playbackId) {
|
|
1649
|
+
return this.playbacks.getDetails(playbackId);
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Controls a specific playback.
|
|
1653
|
+
*
|
|
1654
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1655
|
+
* @param controlRequest - The PlaybackControlRequest containing the control operation.
|
|
1656
|
+
* @returns {Promise<void>} A promise resolving when the control operation is successfully executed.
|
|
1657
|
+
*/
|
|
1658
|
+
async controlPlayback(playbackId, controlRequest) {
|
|
1659
|
+
return this.playbacks.control(playbackId, controlRequest);
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Stops a specific playback.
|
|
1663
|
+
*
|
|
1664
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1665
|
+
* @returns {Promise<void>} A promise resolving when the playback is successfully stopped.
|
|
1666
|
+
*/
|
|
1667
|
+
async stopPlayback(playbackId) {
|
|
1668
|
+
return this.playbacks.stop(playbackId);
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* Lists all available sounds.
|
|
1672
|
+
*
|
|
1673
|
+
* @param params - Optional parameters to filter the list of sounds.
|
|
1674
|
+
* @returns {Promise<Sound[]>} A promise resolving to the list of sounds.
|
|
1675
|
+
*/
|
|
1676
|
+
async listSounds(params) {
|
|
1677
|
+
return this.sounds.list(params);
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Retrieves details of a specific sound.
|
|
1681
|
+
*
|
|
1682
|
+
* @param soundId - The unique identifier of the sound.
|
|
1683
|
+
* @returns {Promise<Sound>} A promise resolving to the sound details.
|
|
1684
|
+
*/
|
|
1685
|
+
async getSoundDetails(soundId) {
|
|
1686
|
+
return this.sounds.getDetails(soundId);
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Retrieves information about the Asterisk server.
|
|
1690
|
+
*/
|
|
1691
|
+
async getAsteriskInfo() {
|
|
1692
|
+
return this.asterisk.getInfo();
|
|
1693
|
+
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Lists all loaded modules in the Asterisk server.
|
|
1696
|
+
*/
|
|
1697
|
+
async listModules() {
|
|
1698
|
+
return this.asterisk.listModules();
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Manages a specific module in the Asterisk server.
|
|
1702
|
+
*/
|
|
1703
|
+
async manageModule(moduleName, action) {
|
|
1704
|
+
return this.asterisk.manageModule(moduleName, action);
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Retrieves all configured logging channels.
|
|
1708
|
+
*/
|
|
1709
|
+
async listLoggingChannels() {
|
|
1710
|
+
return this.asterisk.listLoggingChannels();
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Adds or removes a log channel in the Asterisk server.
|
|
1714
|
+
*/
|
|
1715
|
+
async manageLogChannel(logChannelName, action, configuration) {
|
|
1716
|
+
return this.asterisk.manageLogChannel(
|
|
1717
|
+
logChannelName,
|
|
1718
|
+
action,
|
|
1719
|
+
configuration
|
|
1720
|
+
);
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Retrieves the value of a global variable.
|
|
1724
|
+
*/
|
|
1725
|
+
async getGlobalVariable(variableName) {
|
|
1726
|
+
return this.asterisk.getGlobalVariable(variableName);
|
|
1727
|
+
}
|
|
1728
|
+
/**
|
|
1729
|
+
* Sets a global variable.
|
|
1730
|
+
*/
|
|
1731
|
+
async setGlobalVariable(variableName, value) {
|
|
1732
|
+
return this.asterisk.setGlobalVariable(variableName, value);
|
|
1733
|
+
}
|
|
1087
1734
|
};
|
|
1088
1735
|
export {
|
|
1736
|
+
Applications,
|
|
1089
1737
|
AriClient,
|
|
1090
|
-
Channels
|
|
1738
|
+
Channels,
|
|
1739
|
+
Endpoints,
|
|
1740
|
+
Playbacks,
|
|
1741
|
+
Sounds
|
|
1091
1742
|
};
|
|
1092
1743
|
//# sourceMappingURL=index.js.map
|