@ipcom/asterisk-ari 0.0.17 → 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.
- package/dist/cjs/index.cjs +594 -50
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/esm/index.js +589 -49
- package/dist/esm/index.js.map +3 -3
- package/dist/types/ari-client/ariClient.d.ts +184 -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/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 +7 -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/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/cjs/index.cjs
CHANGED
|
@@ -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
|
|
@@ -647,15 +677,18 @@ var Applications = class {
|
|
|
647
677
|
};
|
|
648
678
|
|
|
649
679
|
// src/ari-client/resources/channels.ts
|
|
680
|
+
function toQueryParams(options) {
|
|
681
|
+
return new URLSearchParams(
|
|
682
|
+
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
|
|
683
|
+
// Garante que value é string
|
|
684
|
+
).toString();
|
|
685
|
+
}
|
|
650
686
|
var Channels = class {
|
|
651
687
|
constructor(client) {
|
|
652
688
|
this.client = client;
|
|
653
689
|
}
|
|
654
690
|
/**
|
|
655
691
|
* 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
692
|
*/
|
|
660
693
|
async list() {
|
|
661
694
|
const channels = await this.client.get("/channels");
|
|
@@ -666,40 +699,45 @@ var Channels = class {
|
|
|
666
699
|
}
|
|
667
700
|
/**
|
|
668
701
|
* 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
702
|
*/
|
|
673
703
|
async originate(data) {
|
|
674
704
|
return this.client.post("/channels", data);
|
|
675
705
|
}
|
|
676
706
|
/**
|
|
677
707
|
* 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
708
|
*/
|
|
682
709
|
async getDetails(channelId) {
|
|
683
710
|
return this.client.get(`/channels/${channelId}`);
|
|
684
711
|
}
|
|
712
|
+
/**
|
|
713
|
+
* Creates a channel and places it in a Stasis app without dialing it.
|
|
714
|
+
*/
|
|
715
|
+
async createChannel(data) {
|
|
716
|
+
return this.client.post("/channels/create", data);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Creates a new channel with a specific ID and originates a call.
|
|
720
|
+
*/
|
|
721
|
+
async originateWithId(channelId, data) {
|
|
722
|
+
return this.client.post(`/channels/${channelId}`, data);
|
|
723
|
+
}
|
|
685
724
|
/**
|
|
686
725
|
* 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
726
|
*/
|
|
691
|
-
|
|
692
|
-
|
|
727
|
+
/**
|
|
728
|
+
* Hangs up a specific channel with optional reason or reason code.
|
|
729
|
+
*/
|
|
730
|
+
async hangup(channelId, options) {
|
|
731
|
+
const queryParams = new URLSearchParams({
|
|
732
|
+
...options?.reason_code && { reason_code: options.reason_code },
|
|
733
|
+
...options?.reason && { reason: options.reason }
|
|
734
|
+
});
|
|
735
|
+
return this.client.delete(
|
|
736
|
+
`/channels/${channelId}?${queryParams.toString()}`
|
|
737
|
+
);
|
|
693
738
|
}
|
|
694
739
|
/**
|
|
695
740
|
* 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
741
|
*/
|
|
704
742
|
async continueDialplan(channelId, context, extension, priority, label) {
|
|
705
743
|
return this.client.post(`/channels/${channelId}/continue`, {
|
|
@@ -711,11 +749,6 @@ var Channels = class {
|
|
|
711
749
|
}
|
|
712
750
|
/**
|
|
713
751
|
* 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
752
|
*/
|
|
720
753
|
async moveToApplication(channelId, app, appArgs) {
|
|
721
754
|
return this.client.post(`/channels/${channelId}/move`, {
|
|
@@ -723,6 +756,224 @@ var Channels = class {
|
|
|
723
756
|
appArgs
|
|
724
757
|
});
|
|
725
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Sets a channel variable.
|
|
761
|
+
*/
|
|
762
|
+
async setVariable(channelId, variable, value) {
|
|
763
|
+
return this.client.post(`/channels/${channelId}/variable`, {
|
|
764
|
+
variable,
|
|
765
|
+
value
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Gets a channel variable.
|
|
770
|
+
*/
|
|
771
|
+
async getVariable(channelId, variable) {
|
|
772
|
+
return this.client.get(
|
|
773
|
+
`/channels/${channelId}/variable?variable=${encodeURIComponent(variable)}`
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Plays a media file to a channel.
|
|
778
|
+
*/
|
|
779
|
+
async playMedia(channelId, media, options) {
|
|
780
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
781
|
+
return this.client.post(
|
|
782
|
+
`/channels/${channelId}/play${queryParams}`,
|
|
783
|
+
{ media }
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Starts music on hold (MOH) for a channel.
|
|
788
|
+
*/
|
|
789
|
+
async startMusicOnHold(channelId) {
|
|
790
|
+
return this.client.post(`/channels/${channelId}/moh`);
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Stops music on hold (MOH) for a channel.
|
|
794
|
+
*/
|
|
795
|
+
async stopMusicOnHold(channelId) {
|
|
796
|
+
return this.client.delete(`/channels/${channelId}/moh`);
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Starts playback of a media file on a channel.
|
|
800
|
+
*/
|
|
801
|
+
async startPlayback(channelId, media, options) {
|
|
802
|
+
const queryParams = options ? `?${new URLSearchParams(options).toString()}` : "";
|
|
803
|
+
return this.client.post(
|
|
804
|
+
`/channels/${channelId}/play${queryParams}`,
|
|
805
|
+
{ media }
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Stops playback of a media file on a channel.
|
|
810
|
+
*/
|
|
811
|
+
async stopPlayback(channelId, playbackId) {
|
|
812
|
+
return this.client.delete(
|
|
813
|
+
`/channels/${channelId}/play/${playbackId}`
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Pauses playback of a media file on a channel.
|
|
818
|
+
*/
|
|
819
|
+
async pausePlayback(channelId, playbackId) {
|
|
820
|
+
return this.client.post(
|
|
821
|
+
`/channels/${channelId}/play/${playbackId}/pause`
|
|
822
|
+
);
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Resumes playback of a media file on a channel.
|
|
826
|
+
*/
|
|
827
|
+
async resumePlayback(channelId, playbackId) {
|
|
828
|
+
return this.client.delete(
|
|
829
|
+
`/channels/${channelId}/play/${playbackId}/pause`
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Rewinds playback of a media file on a channel.
|
|
834
|
+
*/
|
|
835
|
+
async rewindPlayback(channelId, playbackId, skipMs) {
|
|
836
|
+
return this.client.post(
|
|
837
|
+
`/channels/${channelId}/play/${playbackId}/rewind`,
|
|
838
|
+
{ skipMs }
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Fast-forwards playback of a media file on a channel.
|
|
843
|
+
*/
|
|
844
|
+
async fastForwardPlayback(channelId, playbackId, skipMs) {
|
|
845
|
+
return this.client.post(
|
|
846
|
+
`/channels/${channelId}/play/${playbackId}/forward`,
|
|
847
|
+
{ skipMs }
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Records audio from a channel.
|
|
852
|
+
*/
|
|
853
|
+
async record(channelId, options) {
|
|
854
|
+
const queryParams = new URLSearchParams(
|
|
855
|
+
Object.entries(options).filter(
|
|
856
|
+
([, value]) => value !== void 0
|
|
857
|
+
)
|
|
858
|
+
);
|
|
859
|
+
return this.client.post(
|
|
860
|
+
`/channels/${channelId}/record?${queryParams.toString()}`
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Starts snooping on a channel.
|
|
865
|
+
*/
|
|
866
|
+
async snoopChannel(channelId, options) {
|
|
867
|
+
const queryParams = toQueryParams(options);
|
|
868
|
+
return this.client.post(
|
|
869
|
+
`/channels/${channelId}/snoop?${queryParams}`
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Starts snooping on a channel with a specific snoop ID.
|
|
874
|
+
*/
|
|
875
|
+
async snoopChannelWithId(channelId, snoopId, options) {
|
|
876
|
+
const queryParams = new URLSearchParams(options);
|
|
877
|
+
return this.client.post(
|
|
878
|
+
`/channels/${channelId}/snoop/${snoopId}?${queryParams.toString()}`
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Dials a created channel.
|
|
883
|
+
*/
|
|
884
|
+
async dial(channelId, caller, timeout) {
|
|
885
|
+
const queryParams = new URLSearchParams({
|
|
886
|
+
...caller && { caller },
|
|
887
|
+
...timeout && { timeout: timeout.toString() }
|
|
888
|
+
});
|
|
889
|
+
return this.client.post(
|
|
890
|
+
`/channels/${channelId}/dial?${queryParams.toString()}`
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Retrieves RTP statistics for a channel.
|
|
895
|
+
*/
|
|
896
|
+
async getRTPStatistics(channelId) {
|
|
897
|
+
return this.client.get(`/channels/${channelId}/rtp_statistics`);
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Creates a channel to an external media source/sink.
|
|
901
|
+
*/
|
|
902
|
+
async createExternalMedia(options) {
|
|
903
|
+
const queryParams = new URLSearchParams(options);
|
|
904
|
+
return this.client.post(
|
|
905
|
+
`/channels/externalMedia?${queryParams.toString()}`
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Redirects the channel to a different location.
|
|
910
|
+
*/
|
|
911
|
+
async redirectChannel(channelId, endpoint) {
|
|
912
|
+
return this.client.post(
|
|
913
|
+
`/channels/${channelId}/redirect?endpoint=${encodeURIComponent(endpoint)}`
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Answers a channel.
|
|
918
|
+
*/
|
|
919
|
+
async answerChannel(channelId) {
|
|
920
|
+
return this.client.post(`/channels/${channelId}/answer`);
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Sends a ringing indication to a channel.
|
|
924
|
+
*/
|
|
925
|
+
async ringChannel(channelId) {
|
|
926
|
+
return this.client.post(`/channels/${channelId}/ring`);
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Stops ringing indication on a channel.
|
|
930
|
+
*/
|
|
931
|
+
async stopRingChannel(channelId) {
|
|
932
|
+
return this.client.delete(`/channels/${channelId}/ring`);
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Sends DTMF to a channel.
|
|
936
|
+
*/
|
|
937
|
+
async sendDTMF(channelId, dtmf, options) {
|
|
938
|
+
const queryParams = new URLSearchParams({
|
|
939
|
+
dtmf,
|
|
940
|
+
...options?.before && { before: options.before.toString() },
|
|
941
|
+
...options?.between && { between: options.between.toString() },
|
|
942
|
+
...options?.duration && { duration: options.duration.toString() },
|
|
943
|
+
...options?.after && { after: options.after.toString() }
|
|
944
|
+
});
|
|
945
|
+
return this.client.post(
|
|
946
|
+
`/channels/${channelId}/dtmf?${queryParams.toString()}`
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Mutes a channel.
|
|
951
|
+
*/
|
|
952
|
+
async muteChannel(channelId, direction = "both") {
|
|
953
|
+
return this.client.post(
|
|
954
|
+
`/channels/${channelId}/mute?direction=${direction}`
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Unmutes a channel.
|
|
959
|
+
*/
|
|
960
|
+
async unmuteChannel(channelId, direction = "both") {
|
|
961
|
+
return this.client.delete(
|
|
962
|
+
`/channels/${channelId}/mute?direction=${direction}`
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Puts a channel on hold.
|
|
967
|
+
*/
|
|
968
|
+
async holdChannel(channelId) {
|
|
969
|
+
return this.client.post(`/channels/${channelId}/hold`);
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Removes a channel from hold.
|
|
973
|
+
*/
|
|
974
|
+
async unholdChannel(channelId) {
|
|
975
|
+
return this.client.delete(`/channels/${channelId}/hold`);
|
|
976
|
+
}
|
|
726
977
|
};
|
|
727
978
|
|
|
728
979
|
// src/ari-client/resources/endpoints.ts
|
|
@@ -771,6 +1022,75 @@ var Endpoints = class {
|
|
|
771
1022
|
}
|
|
772
1023
|
};
|
|
773
1024
|
|
|
1025
|
+
// src/ari-client/resources/playbacks.ts
|
|
1026
|
+
var Playbacks = class {
|
|
1027
|
+
constructor(client) {
|
|
1028
|
+
this.client = client;
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Retrieves details of a specific playback.
|
|
1032
|
+
*
|
|
1033
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1034
|
+
* @returns A promise that resolves to a Playback object containing the details of the specified playback.
|
|
1035
|
+
*/
|
|
1036
|
+
async getDetails(playbackId) {
|
|
1037
|
+
return this.client.get(`/playbacks/${playbackId}`);
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Controls a specific playback (e.g., pause, resume, rewind, forward, stop).
|
|
1041
|
+
*
|
|
1042
|
+
* @param playbackId - The unique identifier of the playback to control.
|
|
1043
|
+
* @param controlRequest - The PlaybackControlRequest containing the control operation.
|
|
1044
|
+
* @returns A promise that resolves when the control operation is successfully executed.
|
|
1045
|
+
*/
|
|
1046
|
+
async control(playbackId, controlRequest) {
|
|
1047
|
+
await this.client.post(
|
|
1048
|
+
`/playbacks/${playbackId}/control`,
|
|
1049
|
+
controlRequest
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Stops a specific playback.
|
|
1054
|
+
*
|
|
1055
|
+
* @param playbackId - The unique identifier of the playback to stop.
|
|
1056
|
+
* @returns A promise that resolves when the playback is successfully stopped.
|
|
1057
|
+
*/
|
|
1058
|
+
async stop(playbackId) {
|
|
1059
|
+
await this.client.post(`/playbacks/${playbackId}/stop`);
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
// src/ari-client/resources/sounds.ts
|
|
1064
|
+
var Sounds = class {
|
|
1065
|
+
constructor(client) {
|
|
1066
|
+
this.client = client;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Lists all available sounds.
|
|
1070
|
+
*
|
|
1071
|
+
* @param params - Optional parameters to filter the list of sounds.
|
|
1072
|
+
* @returns A promise that resolves to an array of Sound objects.
|
|
1073
|
+
* @throws {Error} If the API response is not an array.
|
|
1074
|
+
*/
|
|
1075
|
+
async list(params) {
|
|
1076
|
+
const query = params ? `?${new URLSearchParams(params).toString()}` : "";
|
|
1077
|
+
const sounds = await this.client.get(`/sounds${query}`);
|
|
1078
|
+
if (!Array.isArray(sounds)) {
|
|
1079
|
+
throw new Error("Resposta da API /sounds n\xE3o \xE9 um array.");
|
|
1080
|
+
}
|
|
1081
|
+
return sounds;
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Retrieves details of a specific sound.
|
|
1085
|
+
*
|
|
1086
|
+
* @param soundId - The unique identifier of the sound.
|
|
1087
|
+
* @returns A promise that resolves to a Sound object containing the details of the specified sound.
|
|
1088
|
+
*/
|
|
1089
|
+
async getDetails(soundId) {
|
|
1090
|
+
return this.client.get(`/sounds/${soundId}`);
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
|
|
774
1094
|
// src/ari-client/websocketClient.ts
|
|
775
1095
|
var import_ws = __toESM(require("ws"), 1);
|
|
776
1096
|
var WebSocketClient = class {
|
|
@@ -866,6 +1186,8 @@ var AriClient = class {
|
|
|
866
1186
|
this.channels = new Channels(this.baseClient);
|
|
867
1187
|
this.endpoints = new Endpoints(this.baseClient);
|
|
868
1188
|
this.applications = new Applications(this.baseClient);
|
|
1189
|
+
this.playbacks = new Playbacks(this.baseClient);
|
|
1190
|
+
this.sounds = new Sounds(this.baseClient);
|
|
869
1191
|
}
|
|
870
1192
|
wsClient = null;
|
|
871
1193
|
baseClient;
|
|
@@ -873,6 +1195,8 @@ var AriClient = class {
|
|
|
873
1195
|
channels;
|
|
874
1196
|
endpoints;
|
|
875
1197
|
applications;
|
|
1198
|
+
playbacks;
|
|
1199
|
+
sounds;
|
|
876
1200
|
/**
|
|
877
1201
|
* Connects to the ARI WebSocket for a specific application.
|
|
878
1202
|
*
|
|
@@ -980,45 +1304,32 @@ var AriClient = class {
|
|
|
980
1304
|
*
|
|
981
1305
|
* @returns {Promise<Channel[]>} A promise resolving to the list of active channels.
|
|
982
1306
|
*/
|
|
1307
|
+
/**
|
|
1308
|
+
* Lists all active channels.
|
|
1309
|
+
*/
|
|
983
1310
|
async listChannels() {
|
|
984
1311
|
return this.channels.list();
|
|
985
1312
|
}
|
|
986
1313
|
/**
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
* @param data - The parameters for creating the new channel.
|
|
990
|
-
* @returns {Promise<Channel>} A promise resolving to the new channel's details.
|
|
1314
|
+
* Creates a new channel.
|
|
991
1315
|
*/
|
|
992
1316
|
async originateChannel(data) {
|
|
993
1317
|
return this.channels.originate(data);
|
|
994
1318
|
}
|
|
995
1319
|
/**
|
|
996
1320
|
* 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
1321
|
*/
|
|
1001
1322
|
async getChannelDetails(channelId) {
|
|
1002
1323
|
return this.channels.getDetails(channelId);
|
|
1003
1324
|
}
|
|
1004
1325
|
/**
|
|
1005
1326
|
* Hangs up a specific channel.
|
|
1006
|
-
*
|
|
1007
|
-
* @param channelId - The unique identifier of the channel to hang up.
|
|
1008
|
-
* @returns {Promise<void>}
|
|
1009
1327
|
*/
|
|
1010
1328
|
async hangupChannel(channelId) {
|
|
1011
1329
|
return this.channels.hangup(channelId);
|
|
1012
1330
|
}
|
|
1013
1331
|
/**
|
|
1014
1332
|
* 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
1333
|
*/
|
|
1023
1334
|
async continueChannelDialplan(channelId, context, extension, priority, label) {
|
|
1024
1335
|
return this.channels.continueDialplan(
|
|
@@ -1031,15 +1342,197 @@ var AriClient = class {
|
|
|
1031
1342
|
}
|
|
1032
1343
|
/**
|
|
1033
1344
|
* 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
1345
|
*/
|
|
1040
1346
|
async moveChannelToApplication(channelId, app, appArgs) {
|
|
1041
1347
|
return this.channels.moveToApplication(channelId, app, appArgs);
|
|
1042
1348
|
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Sets a channel variable.
|
|
1351
|
+
*/
|
|
1352
|
+
async setChannelVariable(channelId, variable, value) {
|
|
1353
|
+
return this.channels.setVariable(channelId, variable, value);
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Gets a channel variable.
|
|
1357
|
+
*/
|
|
1358
|
+
async getChannelVariable(channelId, variable) {
|
|
1359
|
+
return this.channels.getVariable(channelId, variable);
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Plays a media file to a channel.
|
|
1363
|
+
*/
|
|
1364
|
+
async playMediaToChannel(channelId, media, options) {
|
|
1365
|
+
return this.channels.playMedia(channelId, media, options);
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Starts music on hold for a channel.
|
|
1369
|
+
*/
|
|
1370
|
+
async startChannelMusicOnHold(channelId) {
|
|
1371
|
+
return this.channels.startMusicOnHold(channelId);
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Stops music on hold for a channel.
|
|
1375
|
+
*/
|
|
1376
|
+
async stopChannelMusicOnHold(channelId) {
|
|
1377
|
+
return this.channels.stopMusicOnHold(channelId);
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Starts playback of a media file on a channel.
|
|
1381
|
+
*/
|
|
1382
|
+
async startChannelPlayback(channelId, media, options) {
|
|
1383
|
+
return this.channels.startPlayback(channelId, media, options);
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Stops playback of a media file on a channel.
|
|
1387
|
+
*/
|
|
1388
|
+
async stopChannelPlayback(channelId, playbackId) {
|
|
1389
|
+
return this.channels.stopPlayback(channelId, playbackId);
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Pauses playback of a media file on a channel.
|
|
1393
|
+
*/
|
|
1394
|
+
async pauseChannelPlayback(channelId, playbackId) {
|
|
1395
|
+
return this.channels.pausePlayback(channelId, playbackId);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Resumes playback of a media file on a channel.
|
|
1399
|
+
*/
|
|
1400
|
+
async resumeChannelPlayback(channelId, playbackId) {
|
|
1401
|
+
return this.channels.resumePlayback(channelId, playbackId);
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Rewinds playback of a media file on a channel.
|
|
1405
|
+
*/
|
|
1406
|
+
async rewindChannelPlayback(channelId, playbackId, skipMs) {
|
|
1407
|
+
return this.channels.rewindPlayback(channelId, playbackId, skipMs);
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Fast-forwards playback of a media file on a channel.
|
|
1411
|
+
*/
|
|
1412
|
+
async fastForwardChannelPlayback(channelId, playbackId, skipMs) {
|
|
1413
|
+
return this.channels.fastForwardPlayback(channelId, playbackId, skipMs);
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Records audio from a channel.
|
|
1417
|
+
*/
|
|
1418
|
+
async recordAudio(channelId, options) {
|
|
1419
|
+
return this.channels.record(channelId, options);
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Starts snooping on a channel.
|
|
1423
|
+
*/
|
|
1424
|
+
async snoopChannel(channelId, options) {
|
|
1425
|
+
return this.channels.snoopChannel(channelId, options);
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Starts snooping on a channel with a specific snoop ID.
|
|
1429
|
+
*/
|
|
1430
|
+
async snoopChannelWithId(channelId, snoopId, options) {
|
|
1431
|
+
return this.channels.snoopChannelWithId(channelId, snoopId, options);
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Dials a created channel.
|
|
1435
|
+
*/
|
|
1436
|
+
async dialChannel(channelId, caller, timeout) {
|
|
1437
|
+
return this.channels.dial(channelId, caller, timeout);
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Retrieves RTP statistics for a channel.
|
|
1441
|
+
*/
|
|
1442
|
+
async getRTPStatistics(channelId) {
|
|
1443
|
+
return this.channels.getRTPStatistics(channelId);
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Creates a channel to an external media source/sink.
|
|
1447
|
+
*/
|
|
1448
|
+
async createExternalMedia(options) {
|
|
1449
|
+
return this.channels.createExternalMedia(options);
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Redirects a channel to a different location.
|
|
1453
|
+
*/
|
|
1454
|
+
async redirectChannel(channelId, endpoint) {
|
|
1455
|
+
return this.channels.redirectChannel(channelId, endpoint);
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Answers a channel.
|
|
1459
|
+
*/
|
|
1460
|
+
async answerChannel(channelId) {
|
|
1461
|
+
return this.channels.answerChannel(channelId);
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Sends a ringing indication to a channel.
|
|
1465
|
+
*/
|
|
1466
|
+
async ringChannel(channelId) {
|
|
1467
|
+
return this.channels.ringChannel(channelId);
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Stops ringing indication on a channel.
|
|
1471
|
+
*/
|
|
1472
|
+
async stopRingChannel(channelId) {
|
|
1473
|
+
return this.channels.stopRingChannel(channelId);
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Sends DTMF to a channel.
|
|
1477
|
+
*/
|
|
1478
|
+
async sendDTMF(channelId, dtmf, options) {
|
|
1479
|
+
return this.channels.sendDTMF(channelId, dtmf, options);
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Mutes a channel.
|
|
1483
|
+
*/
|
|
1484
|
+
async muteChannel(channelId, direction = "both") {
|
|
1485
|
+
return this.channels.muteChannel(channelId, direction);
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* Unmutes a channel.
|
|
1489
|
+
*/
|
|
1490
|
+
async unmuteChannel(channelId, direction = "both") {
|
|
1491
|
+
return this.channels.unmuteChannel(channelId, direction);
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Puts a channel on hold.
|
|
1495
|
+
*/
|
|
1496
|
+
async holdChannel(channelId) {
|
|
1497
|
+
return this.channels.holdChannel(channelId);
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Removes a channel from hold.
|
|
1501
|
+
*/
|
|
1502
|
+
async unholdChannel(channelId) {
|
|
1503
|
+
return this.channels.unholdChannel(channelId);
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Creates a new channel using the provided originate request data.
|
|
1507
|
+
*
|
|
1508
|
+
* @param data - The originate request data containing channel creation parameters.
|
|
1509
|
+
* @returns A promise that resolves to the created Channel object.
|
|
1510
|
+
*/
|
|
1511
|
+
async createChannel(data) {
|
|
1512
|
+
return this.channels.createChannel(data);
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Hangs up a specific channel.
|
|
1516
|
+
*
|
|
1517
|
+
* @param channelId - The unique identifier of the channel to hang up.
|
|
1518
|
+
* @param options - Optional parameters for the hangup operation.
|
|
1519
|
+
* @param options.reason_code - An optional reason code for the hangup.
|
|
1520
|
+
* @param options.reason - An optional textual reason for the hangup.
|
|
1521
|
+
* @returns A promise that resolves when the hangup operation is complete.
|
|
1522
|
+
*/
|
|
1523
|
+
async hangup(channelId, options) {
|
|
1524
|
+
return this.channels.hangup(channelId, options);
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Originates a new channel with a specified ID using the provided originate request data.
|
|
1528
|
+
*
|
|
1529
|
+
* @param channelId - The desired unique identifier for the new channel.
|
|
1530
|
+
* @param data - The originate request data containing channel creation parameters.
|
|
1531
|
+
* @returns A promise that resolves to the created Channel object.
|
|
1532
|
+
*/
|
|
1533
|
+
async originateWithId(channelId, data) {
|
|
1534
|
+
return this.channels.originateWithId(channelId, data);
|
|
1535
|
+
}
|
|
1043
1536
|
// Métodos relacionados a endpoints:
|
|
1044
1537
|
/**
|
|
1045
1538
|
* Lists all endpoints.
|
|
@@ -1098,10 +1591,61 @@ var AriClient = class {
|
|
|
1098
1591
|
async sendMessageToApplication(appName, body) {
|
|
1099
1592
|
return this.applications.sendMessage(appName, body);
|
|
1100
1593
|
}
|
|
1594
|
+
// Métodos relacionados a playbacks
|
|
1595
|
+
/**
|
|
1596
|
+
* Retrieves details of a specific playback.
|
|
1597
|
+
*
|
|
1598
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1599
|
+
* @returns {Promise<Playback>} A promise resolving to the playback details.
|
|
1600
|
+
*/
|
|
1601
|
+
async getPlaybackDetails(playbackId) {
|
|
1602
|
+
return this.playbacks.getDetails(playbackId);
|
|
1603
|
+
}
|
|
1604
|
+
/**
|
|
1605
|
+
* Controls a specific playback.
|
|
1606
|
+
*
|
|
1607
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1608
|
+
* @param controlRequest - The PlaybackControlRequest containing the control operation.
|
|
1609
|
+
* @returns {Promise<void>} A promise resolving when the control operation is successfully executed.
|
|
1610
|
+
*/
|
|
1611
|
+
async controlPlayback(playbackId, controlRequest) {
|
|
1612
|
+
return this.playbacks.control(playbackId, controlRequest);
|
|
1613
|
+
}
|
|
1614
|
+
/**
|
|
1615
|
+
* Stops a specific playback.
|
|
1616
|
+
*
|
|
1617
|
+
* @param playbackId - The unique identifier of the playback.
|
|
1618
|
+
* @returns {Promise<void>} A promise resolving when the playback is successfully stopped.
|
|
1619
|
+
*/
|
|
1620
|
+
async stopPlayback(playbackId) {
|
|
1621
|
+
return this.playbacks.stop(playbackId);
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Lists all available sounds.
|
|
1625
|
+
*
|
|
1626
|
+
* @param params - Optional parameters to filter the list of sounds.
|
|
1627
|
+
* @returns {Promise<Sound[]>} A promise resolving to the list of sounds.
|
|
1628
|
+
*/
|
|
1629
|
+
async listSounds(params) {
|
|
1630
|
+
return this.sounds.list(params);
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Retrieves details of a specific sound.
|
|
1634
|
+
*
|
|
1635
|
+
* @param soundId - The unique identifier of the sound.
|
|
1636
|
+
* @returns {Promise<Sound>} A promise resolving to the sound details.
|
|
1637
|
+
*/
|
|
1638
|
+
async getSoundDetails(soundId) {
|
|
1639
|
+
return this.sounds.getDetails(soundId);
|
|
1640
|
+
}
|
|
1101
1641
|
};
|
|
1102
1642
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1103
1643
|
0 && (module.exports = {
|
|
1644
|
+
Applications,
|
|
1104
1645
|
AriClient,
|
|
1105
|
-
Channels
|
|
1646
|
+
Channels,
|
|
1647
|
+
Endpoints,
|
|
1648
|
+
Playbacks,
|
|
1649
|
+
Sounds
|
|
1106
1650
|
});
|
|
1107
1651
|
//# sourceMappingURL=index.cjs.map
|