@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.
- package/dist/cjs/index.cjs +663 -50
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/esm/index.js +658 -49
- package/dist/esm/index.js.map +3 -3
- package/dist/types/ari-client/ariClient.d.ts +208 -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/applications.types.d.ts +10 -0
- package/dist/types/ari-client/interfaces/applications.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 +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/applications.d.ts +28 -0
- package/dist/types/ari-client/resources/applications.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/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,26 +601,94 @@ 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
|
+
}
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// src/ari-client/resources/applications.ts
|
|
641
|
+
var Applications = class {
|
|
642
|
+
constructor(client) {
|
|
643
|
+
this.client = client;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Lists all applications.
|
|
647
|
+
*
|
|
648
|
+
* @returns A promise that resolves to an array of Application objects representing all registered applications.
|
|
649
|
+
* @throws {Error} If the API response is not an array.
|
|
650
|
+
*/
|
|
651
|
+
async list() {
|
|
652
|
+
const applications = await this.client.get("/applications");
|
|
653
|
+
if (!Array.isArray(applications)) {
|
|
654
|
+
throw new Error("Resposta da API /applications n\xE3o \xE9 um array.");
|
|
655
|
+
}
|
|
656
|
+
return applications;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Retrieves details of a specific application.
|
|
660
|
+
*
|
|
661
|
+
* @param appName - The unique name of the application.
|
|
662
|
+
* @returns A promise that resolves to an ApplicationDetails object containing the details of the specified application.
|
|
663
|
+
*/
|
|
664
|
+
async getDetails(appName) {
|
|
665
|
+
return this.client.get(`/applications/${appName}`);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Sends a message to a specific application.
|
|
669
|
+
*
|
|
670
|
+
* @param appName - The unique name of the application.
|
|
671
|
+
* @param body - The message body to send.
|
|
672
|
+
* @returns A promise that resolves when the message is sent successfully.
|
|
673
|
+
*/
|
|
674
|
+
async sendMessage(appName, body) {
|
|
675
|
+
await this.client.post(`/applications/${appName}/messages`, body);
|
|
676
|
+
}
|
|
608
677
|
};
|
|
609
678
|
|
|
610
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
|
+
}
|
|
611
686
|
var Channels = class {
|
|
612
687
|
constructor(client) {
|
|
613
688
|
this.client = client;
|
|
614
689
|
}
|
|
615
690
|
/**
|
|
616
691
|
* Lists all active channels.
|
|
617
|
-
*
|
|
618
|
-
* @returns A promise that resolves to an array of Channel objects representing all active channels.
|
|
619
|
-
* @throws {Error} If the API response is not an array.
|
|
620
692
|
*/
|
|
621
693
|
async list() {
|
|
622
694
|
const channels = await this.client.get("/channels");
|
|
@@ -627,40 +699,45 @@ var Channels = class {
|
|
|
627
699
|
}
|
|
628
700
|
/**
|
|
629
701
|
* Creates a new channel.
|
|
630
|
-
*
|
|
631
|
-
* @param data - The OriginateRequest object containing the necessary data to create a new channel.
|
|
632
|
-
* @returns A promise that resolves to a Channel object representing the newly created channel.
|
|
633
702
|
*/
|
|
634
703
|
async originate(data) {
|
|
635
704
|
return this.client.post("/channels", data);
|
|
636
705
|
}
|
|
637
706
|
/**
|
|
638
707
|
* Retrieves details of a specific channel.
|
|
639
|
-
*
|
|
640
|
-
* @param channelId - The unique identifier of the channel.
|
|
641
|
-
* @returns A promise that resolves to a Channel object containing the details of the specified channel.
|
|
642
708
|
*/
|
|
643
709
|
async getDetails(channelId) {
|
|
644
710
|
return this.client.get(`/channels/${channelId}`);
|
|
645
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
|
+
}
|
|
646
724
|
/**
|
|
647
725
|
* Hangs up (terminates) a specific channel.
|
|
648
|
-
*
|
|
649
|
-
* @param channelId - The unique identifier of the channel to be hung up.
|
|
650
|
-
* @returns A promise that resolves when the channel has been successfully hung up.
|
|
651
726
|
*/
|
|
652
|
-
|
|
653
|
-
|
|
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
|
+
);
|
|
654
738
|
}
|
|
655
739
|
/**
|
|
656
740
|
* Continues the dialplan for a specific channel.
|
|
657
|
-
*
|
|
658
|
-
* @param channelId - The unique identifier of the channel.
|
|
659
|
-
* @param context - Optional. The context to continue in the dialplan.
|
|
660
|
-
* @param extension - Optional. The extension to continue in the dialplan.
|
|
661
|
-
* @param priority - Optional. The priority to continue in the dialplan.
|
|
662
|
-
* @param label - Optional. The label to continue in the dialplan.
|
|
663
|
-
* @returns A promise that resolves when the dialplan continuation has been successfully initiated.
|
|
664
741
|
*/
|
|
665
742
|
async continueDialplan(channelId, context, extension, priority, label) {
|
|
666
743
|
return this.client.post(`/channels/${channelId}/continue`, {
|
|
@@ -672,11 +749,6 @@ var Channels = class {
|
|
|
672
749
|
}
|
|
673
750
|
/**
|
|
674
751
|
* Moves the channel to another Stasis application.
|
|
675
|
-
*
|
|
676
|
-
* @param channelId - The unique identifier of the channel to be moved.
|
|
677
|
-
* @param app - The name of the Stasis application to move the channel to.
|
|
678
|
-
* @param appArgs - Optional. Arguments to be passed to the Stasis application.
|
|
679
|
-
* @returns A promise that resolves when the channel has been successfully moved to the new application.
|
|
680
752
|
*/
|
|
681
753
|
async moveToApplication(channelId, app, appArgs) {
|
|
682
754
|
return this.client.post(`/channels/${channelId}/move`, {
|
|
@@ -684,6 +756,224 @@ var Channels = class {
|
|
|
684
756
|
appArgs
|
|
685
757
|
});
|
|
686
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
|
+
}
|
|
687
977
|
};
|
|
688
978
|
|
|
689
979
|
// src/ari-client/resources/endpoints.ts
|
|
@@ -732,6 +1022,75 @@ var Endpoints = class {
|
|
|
732
1022
|
}
|
|
733
1023
|
};
|
|
734
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
|
+
|
|
735
1094
|
// src/ari-client/websocketClient.ts
|
|
736
1095
|
var import_ws = __toESM(require("ws"), 1);
|
|
737
1096
|
var WebSocketClient = class {
|
|
@@ -826,12 +1185,18 @@ var AriClient = class {
|
|
|
826
1185
|
this.baseClient = new BaseClient(baseUrl, config.username, config.password);
|
|
827
1186
|
this.channels = new Channels(this.baseClient);
|
|
828
1187
|
this.endpoints = new Endpoints(this.baseClient);
|
|
1188
|
+
this.applications = new Applications(this.baseClient);
|
|
1189
|
+
this.playbacks = new Playbacks(this.baseClient);
|
|
1190
|
+
this.sounds = new Sounds(this.baseClient);
|
|
829
1191
|
}
|
|
830
1192
|
wsClient = null;
|
|
831
1193
|
baseClient;
|
|
832
1194
|
isReconnecting = false;
|
|
833
1195
|
channels;
|
|
834
1196
|
endpoints;
|
|
1197
|
+
applications;
|
|
1198
|
+
playbacks;
|
|
1199
|
+
sounds;
|
|
835
1200
|
/**
|
|
836
1201
|
* Connects to the ARI WebSocket for a specific application.
|
|
837
1202
|
*
|
|
@@ -939,45 +1304,32 @@ var AriClient = class {
|
|
|
939
1304
|
*
|
|
940
1305
|
* @returns {Promise<Channel[]>} A promise resolving to the list of active channels.
|
|
941
1306
|
*/
|
|
1307
|
+
/**
|
|
1308
|
+
* Lists all active channels.
|
|
1309
|
+
*/
|
|
942
1310
|
async listChannels() {
|
|
943
1311
|
return this.channels.list();
|
|
944
1312
|
}
|
|
945
1313
|
/**
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
* @param data - The parameters for creating the new channel.
|
|
949
|
-
* @returns {Promise<Channel>} A promise resolving to the new channel's details.
|
|
1314
|
+
* Creates a new channel.
|
|
950
1315
|
*/
|
|
951
1316
|
async originateChannel(data) {
|
|
952
1317
|
return this.channels.originate(data);
|
|
953
1318
|
}
|
|
954
1319
|
/**
|
|
955
1320
|
* Retrieves details of a specific channel.
|
|
956
|
-
*
|
|
957
|
-
* @param channelId - The unique identifier of the channel.
|
|
958
|
-
* @returns {Promise<Channel>} A promise resolving to the details of the channel.
|
|
959
1321
|
*/
|
|
960
1322
|
async getChannelDetails(channelId) {
|
|
961
1323
|
return this.channels.getDetails(channelId);
|
|
962
1324
|
}
|
|
963
1325
|
/**
|
|
964
1326
|
* Hangs up a specific channel.
|
|
965
|
-
*
|
|
966
|
-
* @param channelId - The unique identifier of the channel to hang up.
|
|
967
|
-
* @returns {Promise<void>}
|
|
968
1327
|
*/
|
|
969
1328
|
async hangupChannel(channelId) {
|
|
970
1329
|
return this.channels.hangup(channelId);
|
|
971
1330
|
}
|
|
972
1331
|
/**
|
|
973
1332
|
* Continues the dialplan for a specific channel.
|
|
974
|
-
*
|
|
975
|
-
* @param channelId - The unique identifier of the channel.
|
|
976
|
-
* @param context - Optional. The context to continue in the dialplan.
|
|
977
|
-
* @param extension - Optional. The extension to continue in the dialplan.
|
|
978
|
-
* @param priority - Optional. The priority to continue in the dialplan.
|
|
979
|
-
* @param label - Optional. The label to continue in the dialplan.
|
|
980
|
-
* @returns {Promise<void>}
|
|
981
1333
|
*/
|
|
982
1334
|
async continueChannelDialplan(channelId, context, extension, priority, label) {
|
|
983
1335
|
return this.channels.continueDialplan(
|
|
@@ -990,15 +1342,197 @@ var AriClient = class {
|
|
|
990
1342
|
}
|
|
991
1343
|
/**
|
|
992
1344
|
* Moves a channel to another Stasis application.
|
|
993
|
-
*
|
|
994
|
-
* @param channelId - The unique identifier of the channel.
|
|
995
|
-
* @param app - The name of the Stasis application to move the channel to.
|
|
996
|
-
* @param appArgs - Optional arguments for the Stasis application.
|
|
997
|
-
* @returns {Promise<void>}
|
|
998
1345
|
*/
|
|
999
1346
|
async moveChannelToApplication(channelId, app, appArgs) {
|
|
1000
1347
|
return this.channels.moveToApplication(channelId, app, appArgs);
|
|
1001
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
|
+
}
|
|
1002
1536
|
// Métodos relacionados a endpoints:
|
|
1003
1537
|
/**
|
|
1004
1538
|
* Lists all endpoints.
|
|
@@ -1029,10 +1563,89 @@ var AriClient = class {
|
|
|
1029
1563
|
async sendMessageToEndpoint(technology, resource, body) {
|
|
1030
1564
|
return this.endpoints.sendMessage(technology, resource, body);
|
|
1031
1565
|
}
|
|
1566
|
+
// Métodos relacionados a applications
|
|
1567
|
+
/**
|
|
1568
|
+
* Lists all applications.
|
|
1569
|
+
*
|
|
1570
|
+
* @returns {Promise<Application[]>} A promise resolving to the list of applications.
|
|
1571
|
+
*/
|
|
1572
|
+
async listApplications() {
|
|
1573
|
+
return this.applications.list();
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Retrieves details of a specific application.
|
|
1577
|
+
*
|
|
1578
|
+
* @param appName - The name of the application.
|
|
1579
|
+
* @returns {Promise<ApplicationDetails>} A promise resolving to the application details.
|
|
1580
|
+
*/
|
|
1581
|
+
async getApplicationDetails(appName) {
|
|
1582
|
+
return this.applications.getDetails(appName);
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* Sends a message to a specific application.
|
|
1586
|
+
*
|
|
1587
|
+
* @param appName - The name of the application.
|
|
1588
|
+
* @param body - The message body to send.
|
|
1589
|
+
* @returns {Promise<void>} A promise resolving when the message is sent successfully.
|
|
1590
|
+
*/
|
|
1591
|
+
async sendMessageToApplication(appName, body) {
|
|
1592
|
+
return this.applications.sendMessage(appName, body);
|
|
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
|
+
}
|
|
1032
1641
|
};
|
|
1033
1642
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1034
1643
|
0 && (module.exports = {
|
|
1644
|
+
Applications,
|
|
1035
1645
|
AriClient,
|
|
1036
|
-
Channels
|
|
1646
|
+
Channels,
|
|
1647
|
+
Endpoints,
|
|
1648
|
+
Playbacks,
|
|
1649
|
+
Sounds
|
|
1037
1650
|
});
|
|
1038
1651
|
//# sourceMappingURL=index.cjs.map
|